reshaped 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.js +11 -11
  4. package/dist/cjs/cli/theming/index.js +0 -1
  5. package/dist/cjs/themes/_generator/definitions/figma.d.ts +1 -1
  6. package/dist/cjs/themes/_generator/definitions/figma.js +6 -5
  7. package/dist/cjs/themes/_generator/utilities/color.js +11 -11
  8. package/dist/cjs/themes/_generator/utilities/generateBackgroundColors.js +0 -2
  9. package/dist/cjs/themes/_generator/utilities/generateColors.js +1 -1
  10. package/dist/cjs/themes/_generator/utilities/generateUnits.js +0 -1
  11. package/dist/cjs/themes/_generator/utilities/mergeDeep.js +1 -1
  12. package/dist/cjs/themes/_generator/utilities/resolveTokenReference.js +2 -0
  13. package/dist/cjs/themes/figma/tailwind.css +1 -1
  14. package/dist/cjs/themes/figma/theme.css +1 -1
  15. package/dist/cli/theming/index.js +0 -1
  16. package/dist/components/Actionable/Actionable.js +2 -0
  17. package/dist/components/Autocomplete/Autocomplete.js +1 -0
  18. package/dist/components/Calendar/Calendar.module.css +1 -1
  19. package/dist/components/Calendar/Calendar.types.d.ts +4 -4
  20. package/dist/components/Calendar/CalendarControlled.js +2 -2
  21. package/dist/components/Calendar/CalendarDate.js +29 -11
  22. package/dist/components/Calendar/CalendarMonth.js +2 -6
  23. package/dist/components/Calendar/tests/Calendar.stories.d.ts +20 -6
  24. package/dist/components/Calendar/tests/Calendar.stories.js +237 -27
  25. package/dist/components/Card/Card.d.ts +1 -1
  26. package/dist/components/Card/Card.js +2 -4
  27. package/dist/components/Card/tests/Card.stories.d.ts +1 -1
  28. package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
  29. package/dist/components/Carousel/Carousel.js +1 -2
  30. package/dist/components/Carousel/Carousel.types.d.ts +1 -5
  31. package/dist/components/Carousel/Carousel.types.js +1 -5
  32. package/dist/components/Carousel/CarouselControl.js +2 -3
  33. package/dist/components/FormControl/FormControl.context.d.ts +4 -0
  34. package/dist/components/Grid/Grid.js +8 -2
  35. package/dist/components/Icon/Icon.js +1 -3
  36. package/dist/components/PinField/PinFieldControlled.js +0 -1
  37. package/dist/components/Resizable/Resizable.js +1 -0
  38. package/dist/components/Slider/SliderControlled.js +9 -3
  39. package/dist/components/Stepper/Stepper.js +7 -2
  40. package/dist/components/Tabs/TabsList.js +7 -3
  41. package/dist/components/Text/Text.js +2 -4
  42. package/dist/components/Timeline/Timeline.js +1 -1
  43. package/dist/components/Toast/ToastProvider.js +8 -4
  44. package/dist/components/View/View.js +10 -5
  45. package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
  46. package/dist/components/_private/Flyout/FlyoutTrigger.js +1 -1
  47. package/dist/components/_private/Flyout/useFlyout.js +2 -0
  48. package/dist/components/_private/Portal/Portal.d.ts +1 -1
  49. package/dist/config/tailwind.d.ts +1 -1
  50. package/dist/hooks/_private/useOnClickOutside.d.ts +1 -1
  51. package/dist/hooks/_private/useSingletonHotkeys.js +2 -0
  52. package/dist/hooks/useResponsiveClientValue.d.ts +1 -1
  53. package/dist/themes/_generator/definitions/figma.d.ts +1 -1
  54. package/dist/themes/_generator/definitions/figma.js +6 -5
  55. package/dist/themes/_generator/utilities/color.js +11 -11
  56. package/dist/themes/_generator/utilities/generateBackgroundColors.js +0 -2
  57. package/dist/themes/_generator/utilities/generateColors.js +1 -1
  58. package/dist/themes/_generator/utilities/generateUnits.js +0 -1
  59. package/dist/themes/_generator/utilities/mergeDeep.js +1 -1
  60. package/dist/themes/_generator/utilities/resolveTokenReference.js +2 -0
  61. package/dist/themes/figma/tailwind.css +1 -1
  62. package/dist/themes/figma/theme.css +1 -1
  63. package/dist/types/global.d.ts +2 -2
  64. package/dist/utilities/helpers.js +4 -1
  65. package/dist/utilities/platform.js +1 -0
  66. package/package.json +36 -40
  67. package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +0 -26
  68. package/dist/components/Calendar/tests/Calendar.test.stories.js +0 -161
@@ -1,26 +0,0 @@
1
- import { StoryObj } from "@storybook/react";
2
- import { fn } from "@storybook/test";
3
- declare const _default: {
4
- title: string;
5
- component: (props: import("./..").CalendarProps) => import("react").JSX.Element;
6
- parameters: {
7
- iframe: {
8
- url: string;
9
- };
10
- chromatic: {
11
- disableSnapshot: boolean;
12
- };
13
- };
14
- };
15
- export default _default;
16
- export declare const base: StoryObj;
17
- export declare const onChange: StoryObj<{
18
- handleChange: ReturnType<typeof fn>;
19
- }>;
20
- export declare const defaultValue: StoryObj;
21
- export declare const value: StoryObj;
22
- export declare const range: StoryObj;
23
- export declare const minMax: StoryObj;
24
- export declare const monthSelection: StoryObj;
25
- export declare const ariaLabels: StoryObj;
26
- export declare const keyboardNavigation: StoryObj;
@@ -1,161 +0,0 @@
1
- import { expect, userEvent, fn } from "@storybook/test";
2
- import Calendar from "../index.js";
3
- export default {
4
- title: "Components/Calendar/tests",
5
- component: Calendar,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/components/calendar",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const base = {
14
- name: "base",
15
- render: () => <Calendar defaultMonth={new Date(2020, 0, 1)}/>,
16
- play: async ({ canvas }) => {
17
- const monthTitleEl = canvas.getByText("January 2020");
18
- const gridEl = canvas.getByRole("grid");
19
- const gridCellEls = canvas.getAllByRole("gridcell");
20
- const dateEls = canvas.getAllByRole("checkbox");
21
- const buttonEls = canvas.getAllByRole("button");
22
- expect(monthTitleEl).toBeInTheDocument();
23
- expect(gridEl).toBeInTheDocument();
24
- expect(gridCellEls).toHaveLength(31);
25
- expect(dateEls).toHaveLength(31);
26
- expect(dateEls[0].getAttribute("aria-label")).toBe("Wednesday, January 1");
27
- expect(dateEls[0]).toHaveAttribute("tabIndex", "0");
28
- expect(dateEls[1]).toHaveAttribute("tabIndex", "-1");
29
- // Previous month button
30
- expect(buttonEls[0].getAttribute("aria-label")).toBe("Previous month");
31
- // Month select button
32
- expect(buttonEls[1].innerHTML).toContain("Select a month");
33
- // Next month button
34
- expect(buttonEls[2].getAttribute("aria-label")).toBe("Next month");
35
- },
36
- };
37
- export const onChange = {
38
- name: "onChange",
39
- args: {
40
- handleChange: fn(),
41
- },
42
- render: (args) => <Calendar defaultMonth={new Date(2020, 0)} onChange={args.handleChange}/>,
43
- play: async ({ canvas, args }) => {
44
- const dateEls = canvas.getAllByRole("checkbox");
45
- await userEvent.click(dateEls[1]);
46
- expect(args.handleChange).toHaveBeenCalledTimes(1);
47
- // TODO: https://github.com/storybookjs/storybook/issues/30503
48
- // expect(args.handleChange).toHaveBeenCalledWith({ value: new Date(2020, 0, 2) });
49
- },
50
- };
51
- export const defaultValue = {
52
- name: "defaultValue",
53
- render: () => <Calendar defaultMonth={new Date(2020, 0)} defaultValue={new Date(2020, 0, 5)}/>,
54
- play: async ({ canvas }) => {
55
- const dateEls = canvas.getAllByRole("checkbox");
56
- const selectedDateEl = dateEls[4];
57
- expect(selectedDateEl).toBeInTheDocument();
58
- expect(selectedDateEl).toHaveAttribute("tabIndex", "0");
59
- expect(selectedDateEl).toHaveAttribute("aria-checked", "true");
60
- await userEvent.click(dateEls[6], { delay: null });
61
- expect(dateEls[6]).toHaveAttribute("aria-checked", "true");
62
- },
63
- };
64
- export const value = {
65
- name: "value",
66
- render: () => <Calendar defaultMonth={new Date(2020, 0)} value={new Date(2020, 0, 5)}/>,
67
- play: async ({ canvas }) => {
68
- const dateEls = canvas.getAllByRole("checkbox");
69
- const selectedDateEl = dateEls[4];
70
- expect(selectedDateEl).toBeInTheDocument();
71
- expect(selectedDateEl).toHaveAttribute("tabIndex", "0");
72
- expect(selectedDateEl).toHaveAttribute("aria-checked", "true");
73
- await userEvent.click(dateEls[6], { delay: null });
74
- expect(dateEls[6]).toHaveAttribute("aria-checked", "false");
75
- },
76
- };
77
- export const range = {
78
- name: "defaultValue, range",
79
- render: () => (<Calendar defaultMonth={new Date(2020, 0)} range defaultValue={{ start: new Date(2020, 0, 5), end: new Date(2020, 0, 7) }}/>),
80
- play: async ({ canvas }) => {
81
- const dateEls = canvas.getAllByRole("checkbox");
82
- const startDateEl = dateEls[4];
83
- const endDateEl = dateEls[6];
84
- expect(startDateEl).toHaveAttribute("tabIndex", "0");
85
- expect(startDateEl).toHaveAttribute("aria-checked", "true");
86
- expect(endDateEl).toHaveAttribute("tabIndex", "-1");
87
- expect(endDateEl).toHaveAttribute("aria-checked", "true");
88
- await userEvent.click(dateEls[3], { delay: null });
89
- expect(dateEls[3]).toHaveAttribute("aria-checked", "true");
90
- expect(dateEls[3]).toHaveAttribute("tabIndex", "0");
91
- expect(startDateEl).toHaveAttribute("aria-checked", "false");
92
- expect(startDateEl).toHaveAttribute("tabIndex", "-1");
93
- expect(endDateEl).toHaveAttribute("aria-checked", "false");
94
- expect(endDateEl).toHaveAttribute("tabIndex", "-1");
95
- // Click before the start date
96
- await userEvent.click(dateEls[2], { delay: null });
97
- expect(dateEls[2]).toHaveAttribute("aria-checked", "true");
98
- expect(dateEls[2]).toHaveAttribute("tabIndex", "0");
99
- expect(dateEls[3]).toHaveAttribute("aria-checked", "false");
100
- expect(dateEls[3]).toHaveAttribute("tabIndex", "-1");
101
- await userEvent.click(dateEls[4], { delay: null });
102
- expect(dateEls[2]).toHaveAttribute("aria-checked", "true");
103
- expect(dateEls[2]).toHaveAttribute("tabIndex", "0");
104
- expect(dateEls[4]).toHaveAttribute("aria-checked", "true");
105
- expect(dateEls[4]).toHaveAttribute("tabIndex", "-1");
106
- },
107
- };
108
- export const minMax = {
109
- name: "min, max",
110
- render: () => (<Calendar min={new Date(2020, 0, 5)} max={new Date(2020, 0, 25)} defaultMonth={new Date(2020, 0)}/>),
111
- play: async ({ canvas }) => {
112
- const dateEls = canvas.getAllByRole("checkbox");
113
- expect(dateEls).toHaveLength(21);
114
- },
115
- };
116
- export const monthSelection = {
117
- name: "month selection",
118
- render: () => <Calendar defaultMonth={new Date(2020, 0)}/>,
119
- play: async ({ canvas }) => {
120
- const buttonEls = canvas.getAllByRole("button");
121
- await userEvent.click(buttonEls[1], { delay: null });
122
- const monthEls = canvas.getAllByRole("button").filter((el) => el.hasAttribute("data-rs-date"));
123
- expect(monthEls).toHaveLength(12);
124
- },
125
- };
126
- export const ariaLabels = {
127
- name: "aria labels",
128
- render: () => (<Calendar defaultMonth={new Date(2020, 0)} nextYearAriaLabel="Test next year" nextMonthAriaLabel="Test next month" renderDateAriaLabel={() => "Test date"} renderMonthAriaLabel={() => "Test month"} previousYearAriaLabel="Test previous year" previousMonthAriaLabel="Test previous month" monthSelectionAriaLabel="Test month selection"/>),
129
- play: async ({ canvas }) => {
130
- const buttonEls = canvas.getAllByRole("button");
131
- const dateEls = canvas.getAllByRole("checkbox");
132
- expect(buttonEls[0]).toHaveAttribute("aria-label", "Test previous month");
133
- expect(buttonEls[1]).toHaveTextContent("Test month selection");
134
- expect(buttonEls[2]).toHaveAttribute("aria-label", "Test next month");
135
- expect(dateEls[0]).toHaveAttribute("aria-label", "Test date");
136
- await userEvent.click(buttonEls[1], { delay: null });
137
- const yearButtonEls = canvas.getAllByRole("button");
138
- expect(yearButtonEls[0]).toHaveAttribute("aria-label", "Test previous year");
139
- expect(yearButtonEls[1]).toHaveAttribute("aria-label", "Test next year");
140
- expect(yearButtonEls[2]).toHaveAttribute("aria-label", "Test month");
141
- },
142
- };
143
- export const keyboardNavigation = {
144
- name: "keyboard navigation",
145
- render: () => <Calendar defaultMonth={new Date(2020, 0)}/>,
146
- play: async ({ canvas }) => {
147
- const user = userEvent.setup();
148
- const dateEls = canvas.getAllByRole("checkbox");
149
- dateEls[0].focus();
150
- await user.keyboard("{ArrowRight/}");
151
- expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-02");
152
- await user.keyboard("{ArrowLeft/}");
153
- expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
154
- await user.keyboard("{ArrowDown/}");
155
- expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-08");
156
- await user.keyboard("{ArrowUp/}");
157
- expect(document.activeElement).toHaveAttribute("data-rs-date", "2020-01-01");
158
- await user.keyboard("{ArrowUp/}");
159
- expect(document.activeElement).toHaveAttribute("data-rs-date", "2019-12-25");
160
- },
161
- };