reshaped 3.5.4-canary.0 → 3.6.0-canary.1

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 (167) hide show
  1. package/CHANGELOG.md +29 -46
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.d.ts +37 -32
  4. package/dist/bundle.js +11 -11
  5. package/dist/components/Accordion/AccordionControlled.js +1 -1
  6. package/dist/components/Accordion/AccordionTrigger.js +1 -1
  7. package/dist/components/ActionBar/ActionBar.js +1 -1
  8. package/dist/components/Actionable/Actionable.js +1 -1
  9. package/dist/components/Avatar/Avatar.js +1 -1
  10. package/dist/components/Badge/Badge.js +1 -1
  11. package/dist/components/Badge/BadgeContainer.js +1 -1
  12. package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -1
  13. package/dist/components/Button/Button.js +1 -1
  14. package/dist/components/Button/Button.types.d.ts +1 -1
  15. package/dist/components/Button/ButtonGroup.js +1 -1
  16. package/dist/components/Calendar/CalendarDate.js +1 -1
  17. package/dist/components/Card/Card.d.ts +1 -1
  18. package/dist/components/Card/Card.js +1 -1
  19. package/dist/components/Card/tests/Card.stories.d.ts +1 -1
  20. package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
  21. package/dist/components/Carousel/Carousel.js +4 -3
  22. package/dist/components/Carousel/CarouselControl.js +1 -1
  23. package/dist/components/Checkbox/Checkbox.js +1 -1
  24. package/dist/components/Container/Container.js +1 -1
  25. package/dist/components/Dismissible/Dismissible.js +1 -1
  26. package/dist/components/Divider/Divider.js +1 -1
  27. package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
  28. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +1 -1
  29. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +1 -1
  30. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +1 -1
  31. package/dist/components/FileUpload/FileUpload.js +1 -1
  32. package/dist/components/Flyout/Flyout.constants.d.ts +6 -0
  33. package/dist/components/Flyout/Flyout.constants.js +19 -0
  34. package/dist/components/{_private/Flyout → Flyout}/Flyout.types.d.ts +3 -3
  35. package/dist/components/{_private/Flyout → Flyout}/FlyoutContent.js +28 -22
  36. package/dist/components/{_private/Flyout → Flyout}/FlyoutControlled.js +9 -9
  37. package/dist/components/{_private/Flyout → Flyout}/tests/Flyout.stories.d.ts +6 -4
  38. package/dist/components/{_private/Flyout → Flyout}/tests/Flyout.stories.js +128 -118
  39. package/dist/components/{_private/Flyout → Flyout}/useFlyout.d.ts +1 -1
  40. package/dist/components/Flyout/useFlyout.js +116 -0
  41. package/dist/components/Flyout/utilities/calculatePosition.d.ts +30 -0
  42. package/dist/components/Flyout/utilities/calculatePosition.js +129 -0
  43. package/dist/components/Flyout/utilities/flyout.d.ts +11 -0
  44. package/dist/components/Flyout/utilities/flyout.js +79 -0
  45. package/dist/components/Flyout/utilities/isFullyVisible.d.ts +10 -0
  46. package/dist/components/Flyout/utilities/isFullyVisible.js +24 -0
  47. package/dist/components/FormControl/FormControl.context.d.ts +0 -2
  48. package/dist/components/Grid/Grid.js +1 -1
  49. package/dist/components/Hidden/Hidden.js +1 -1
  50. package/dist/components/Hotkey/Hotkey.js +1 -1
  51. package/dist/components/Icon/Icon.js +1 -1
  52. package/dist/components/Image/Image.js +1 -1
  53. package/dist/components/Link/Link.d.ts +1 -1
  54. package/dist/components/Link/Link.js +1 -1
  55. package/dist/components/Loader/Loader.js +1 -1
  56. package/dist/components/MenuItem/MenuItem.js +1 -1
  57. package/dist/components/Modal/Modal.js +1 -1
  58. package/dist/components/NumberField/NumberFieldControlled.js +1 -1
  59. package/dist/components/Overlay/Overlay.js +1 -1
  60. package/dist/components/PinField/PinFieldControlled.js +1 -1
  61. package/dist/components/Popover/Popover.d.ts +1 -1
  62. package/dist/components/Popover/Popover.js +4 -4
  63. package/dist/components/Popover/Popover.module.css +1 -1
  64. package/dist/components/Popover/Popover.types.d.ts +3 -1
  65. package/dist/components/Popover/tests/Popover.stories.d.ts +48 -9
  66. package/dist/components/Popover/tests/Popover.stories.js +209 -85
  67. package/dist/components/Progress/Progress.js +1 -1
  68. package/dist/components/ProgressIndicator/ProgressIndicator.js +1 -1
  69. package/dist/components/Radio/Radio.js +1 -1
  70. package/dist/components/Reshaped/Reshaped.js +1 -1
  71. package/dist/components/Resizable/Resizable.js +1 -1
  72. package/dist/components/Scrim/Scrim.js +1 -1
  73. package/dist/components/ScrollArea/ScrollArea.js +6 -6
  74. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  75. package/dist/components/Select/Select.js +1 -1
  76. package/dist/components/Skeleton/Skeleton.js +1 -1
  77. package/dist/components/Slider/Slider.types.d.ts +34 -7
  78. package/dist/components/Slider/SliderControlled.js +32 -20
  79. package/dist/components/Slider/SliderThumb.js +4 -4
  80. package/dist/components/Slider/SliderUncontrolled.js +3 -2
  81. package/dist/components/Slider/tests/Slider.stories.d.ts +38 -8
  82. package/dist/components/Slider/tests/Slider.stories.js +268 -54
  83. package/dist/components/Stepper/Stepper.js +1 -1
  84. package/dist/components/Switch/Switch.js +1 -1
  85. package/dist/components/Table/Table.js +6 -3
  86. package/dist/components/Table/Table.module.css +1 -1
  87. package/dist/components/Tabs/TabsContext.d.ts +2 -2
  88. package/dist/components/Tabs/TabsItem.js +1 -1
  89. package/dist/components/Tabs/TabsList.js +3 -34
  90. package/dist/components/Tabs/TabsPanel.js +1 -1
  91. package/dist/components/Text/Text.js +1 -1
  92. package/dist/components/TextArea/TextArea.js +1 -1
  93. package/dist/components/TextField/TextField.js +1 -1
  94. package/dist/components/Theme/Theme.js +1 -1
  95. package/dist/components/Timeline/Timeline.js +1 -1
  96. package/dist/components/Toast/ToastContainer.js +1 -1
  97. package/dist/components/Toast/ToastRegion.js +1 -1
  98. package/dist/components/Tooltip/Tooltip.js +1 -1
  99. package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
  100. package/dist/components/View/View.js +1 -1
  101. package/dist/components/_private/Aligner/Aligner.js +1 -1
  102. package/dist/components/_private/Expandable/Expandable.js +1 -1
  103. package/dist/components/_private/HiddenInput/HiddenInput.js +1 -1
  104. package/dist/config/tailwind.d.ts +1 -1
  105. package/dist/hooks/_private/useFadeSide.d.ts +5 -0
  106. package/dist/hooks/_private/useFadeSide.js +47 -0
  107. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
  108. package/dist/index.d.ts +37 -32
  109. package/dist/index.js +21 -17
  110. package/dist/styles/align/index.js +1 -1
  111. package/dist/styles/aspectRatio/index.js +1 -1
  112. package/dist/styles/bleed/index.js +1 -1
  113. package/dist/styles/border/index.js +1 -1
  114. package/dist/styles/height/index.js +1 -1
  115. package/dist/styles/inset/index.js +1 -1
  116. package/dist/styles/justify/index.js +1 -1
  117. package/dist/styles/maxHeight/index.js +1 -1
  118. package/dist/styles/maxWidth/index.js +1 -1
  119. package/dist/styles/minHeight/index.js +1 -1
  120. package/dist/styles/minWidth/index.js +1 -1
  121. package/dist/styles/padding/index.js +1 -1
  122. package/dist/styles/position/index.js +1 -1
  123. package/dist/styles/radius/index.js +1 -1
  124. package/dist/styles/textAlign/index.js +1 -1
  125. package/dist/styles/width/index.js +1 -1
  126. package/dist/utilities/dom/event.d.ts +7 -0
  127. package/dist/utilities/dom/event.js +11 -0
  128. package/dist/utilities/dom/find.d.ts +6 -9
  129. package/dist/utilities/dom/find.js +17 -15
  130. package/dist/utilities/dom/index.d.ts +2 -1
  131. package/dist/utilities/dom/index.js +2 -1
  132. package/dist/utilities/helpers.d.ts +1 -15
  133. package/dist/utilities/helpers.js +11 -133
  134. package/dist/utilities/props.d.ts +13 -0
  135. package/dist/utilities/props.js +83 -0
  136. package/dist/utilities/scroll/lock.js +4 -3
  137. package/package.json +24 -24
  138. package/CHANGELOG-old.md +0 -14
  139. package/dist/components/Popover/tests/Popover.test.stories.d.ts +0 -39
  140. package/dist/components/Popover/tests/Popover.test.stories.js +0 -167
  141. package/dist/components/Slider/tests/Slider.test.stories.d.ts +0 -38
  142. package/dist/components/Slider/tests/Slider.test.stories.js +0 -150
  143. package/dist/components/_private/Flyout/Flyout.constants.d.ts +0 -3
  144. package/dist/components/_private/Flyout/Flyout.constants.js +0 -3
  145. package/dist/components/_private/Flyout/useFlyout.js +0 -211
  146. package/dist/components/_private/Flyout/utilities/calculatePosition.d.ts +0 -19
  147. package/dist/components/_private/Flyout/utilities/calculatePosition.js +0 -102
  148. package/dist/components/_private/Flyout/utilities/isFullyVisible.d.ts +0 -8
  149. package/dist/components/_private/Flyout/utilities/isFullyVisible.js +0 -16
  150. /package/dist/components/{_private/Flyout → Flyout}/Flyout.context.d.ts +0 -0
  151. /package/dist/components/{_private/Flyout → Flyout}/Flyout.context.js +0 -0
  152. /package/dist/components/{_private/Flyout → Flyout}/Flyout.d.ts +0 -0
  153. /package/dist/components/{_private/Flyout → Flyout}/Flyout.js +0 -0
  154. /package/dist/components/{_private/Flyout → Flyout}/Flyout.module.css +0 -0
  155. /package/dist/components/{_private/Flyout → Flyout}/Flyout.types.js +0 -0
  156. /package/dist/components/{_private/Flyout → Flyout}/FlyoutContent.d.ts +0 -0
  157. /package/dist/components/{_private/Flyout → Flyout}/FlyoutControlled.d.ts +0 -0
  158. /package/dist/components/{_private/Flyout → Flyout}/FlyoutTrigger.d.ts +0 -0
  159. /package/dist/components/{_private/Flyout → Flyout}/FlyoutTrigger.js +0 -0
  160. /package/dist/components/{_private/Flyout → Flyout}/FlyoutUncontrolled.d.ts +0 -0
  161. /package/dist/components/{_private/Flyout → Flyout}/FlyoutUncontrolled.js +0 -0
  162. /package/dist/components/{_private/Flyout → Flyout}/index.d.ts +0 -0
  163. /package/dist/components/{_private/Flyout → Flyout}/index.js +0 -0
  164. /package/dist/components/{_private/Flyout → Flyout}/utilities/cooldown.d.ts +0 -0
  165. /package/dist/components/{_private/Flyout → Flyout}/utilities/cooldown.js +0 -0
  166. /package/dist/components/{_private/Flyout → Flyout}/utilities/getPositionFallbacks.d.ts +0 -0
  167. /package/dist/components/{_private/Flyout → Flyout}/utilities/getPositionFallbacks.js +0 -0
@@ -1,4 +1,6 @@
1
+ import { expect, fn, userEvent, within, waitFor } from "@storybook/test";
1
2
  import { Example } from "../../../utilities/storybook/index.js";
3
+ import { sleep } from "../../../utilities/helpers.js";
2
4
  import View from "../../View/index.js";
3
5
  import Popover from "../index.js";
4
6
  import Tooltip from "../../Tooltip/index.js";
@@ -26,99 +28,206 @@ const Demo = (props) => {
26
28
  </Popover.Content>
27
29
  </Popover>);
28
30
  };
29
- export const position = () => (<Example>
30
- <Example.Item title="position: bottom">
31
- <View align="center" justify="center" gap={8} direction="row">
32
- <Demo position="bottom-start"/>
33
- <Demo position="bottom"/>
34
- <Demo position="bottom-end"/>
35
- </View>
36
- </Example.Item>
37
- <Example.Item title="position: top">
38
- <View align="center" justify="center" gap={8} direction="row">
39
- <Demo position="top-start"/>
40
- <Demo position="top"/>
41
- <Demo position="top-end"/>
42
- </View>
43
- </Example.Item>
44
- <Example.Item title="position: start">
45
- <View align="center" justify="center" gap={8} direction="row">
46
- <Demo position="start-top"/>
47
- <Demo position="start"/>
48
- <Demo position="start-bottom"/>
49
- </View>
50
- </Example.Item>
51
- <Example.Item title="position: end">
52
- <View align="center" justify="center" gap={8} direction="row">
53
- <Demo position="end-top"/>
54
- <Demo position="end"/>
55
- <Demo position="end-bottom"/>
56
- </View>
57
- </Example.Item>
58
- <Example.Item title={["position: bottom", "changes to top-start because it doesn't fit"]}>
59
- <View align="center">
60
- <Demo position="bottom"/>
61
- </View>
62
- </Example.Item>
63
- </Example>);
64
- export const width = () => (<Example>
65
- <Example.Item title="width: 400">
66
- <Demo width="400px"/>
67
- </Example.Item>
68
- <Example.Item title="width: 100%">
69
- <Demo width="100%"/>
70
- </Example.Item>
71
- </Example>);
72
- export const variant = () => (<Example>
73
- <Example.Item title="variant: headless">
74
- <Popover variant="headless">
31
+ export const position = {
32
+ name: "position",
33
+ render: () => (<Example>
34
+ <Example.Item title="position: bottom">
35
+ <View align="center" justify="center" gap={8} direction="row">
36
+ <Demo position="bottom-start"/>
37
+ <Demo position="bottom"/>
38
+ <Demo position="bottom-end"/>
39
+ </View>
40
+ </Example.Item>
41
+ <Example.Item title="position: top">
42
+ <View align="center" justify="center" gap={8} direction="row">
43
+ <Demo position="top-start"/>
44
+ <Demo position="top"/>
45
+ <Demo position="top-end"/>
46
+ </View>
47
+ </Example.Item>
48
+ <Example.Item title="position: start">
49
+ <View align="center" justify="center" gap={8} direction="row">
50
+ <Demo position="start-top"/>
51
+ <Demo position="start"/>
52
+ <Demo position="start-bottom"/>
53
+ </View>
54
+ </Example.Item>
55
+ <Example.Item title="position: end">
56
+ <View align="center" justify="center" gap={8} direction="row">
57
+ <Demo position="end-top"/>
58
+ <Demo position="end"/>
59
+ <Demo position="end-bottom" defaultActive/>
60
+ </View>
61
+ </Example.Item>
62
+ </Example>),
63
+ };
64
+ export const widthNumber = {
65
+ name: "width: px",
66
+ render: () => <Demo width="400px" defaultActive/>,
67
+ };
68
+ export const widthFull = {
69
+ name: "width: 100%",
70
+ render: () => <Demo width="100%" defaultActive/>,
71
+ };
72
+ export const padding = {
73
+ name: "padding",
74
+ render: () => (<Example>
75
+ <Example.Item title="padding: 0">
76
+ <Demo padding={0}/>
77
+ </Example.Item>
78
+ <Example.Item title="padding: 6">
79
+ <Demo padding={6} defaultActive/>
80
+ </Example.Item>
81
+ </Example>),
82
+ };
83
+ export const elevation = {
84
+ name: "elevation",
85
+ render: () => (<Example>
86
+ <Example.Item title="elevation: raised">
87
+ <Demo elevation="raised" defaultActive/>
88
+ </Example.Item>
89
+ </Example>),
90
+ };
91
+ export const defaultActive = {
92
+ name: "defaultActive, uncontrolled",
93
+ args: {
94
+ handleOpen: fn(),
95
+ handleClose: fn(),
96
+ },
97
+ render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} defaultActive>
98
+ <Popover.Trigger>
99
+ {(attributes) => <Button attributes={attributes}>Open</Button>}
100
+ </Popover.Trigger>
101
+ <Popover.Content>Content</Popover.Content>
102
+ </Popover>),
103
+ play: async ({ canvasElement, args }) => {
104
+ const canvas = within(canvasElement.ownerDocument.body);
105
+ const trigger = canvas.getAllByRole("button")[0];
106
+ let item = canvas.getByText("Content");
107
+ // Wait for the open animation
108
+ await sleep(500);
109
+ await userEvent.click(document.body);
110
+ await waitFor(() => {
111
+ expect(args.handleClose).toHaveBeenCalledTimes(1);
112
+ expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
113
+ expect(item).not.toBeInTheDocument();
114
+ });
115
+ await userEvent.click(trigger);
116
+ await waitFor(() => {
117
+ expect(args.handleOpen).toHaveBeenCalledTimes(1);
118
+ expect(args.handleOpen).toHaveBeenCalledWith();
119
+ });
120
+ item = canvas.getByText("Content");
121
+ expect(item).toBeInTheDocument();
122
+ },
123
+ };
124
+ export const active = {
125
+ name: "active, controlled",
126
+ args: {
127
+ handleOpen: fn(),
128
+ handleClose: fn(),
129
+ },
130
+ render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} active>
131
+ <Popover.Trigger>
132
+ {(attributes) => <Button attributes={attributes}>Open</Button>}
133
+ </Popover.Trigger>
134
+ <Popover.Content>Content</Popover.Content>
135
+ </Popover>),
136
+ play: async ({ canvasElement, args }) => {
137
+ const canvas = within(canvasElement.ownerDocument.body);
138
+ const item = canvas.getByText("Content");
139
+ await userEvent.click(document.body);
140
+ await waitFor(() => {
141
+ expect(args.handleClose).toHaveBeenCalledTimes(1);
142
+ expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
143
+ });
144
+ expect(item).toBeInTheDocument();
145
+ },
146
+ };
147
+ export const activeFalse = {
148
+ name: "active false, controlled",
149
+ args: {
150
+ handleOpen: fn(),
151
+ handleClose: fn(),
152
+ },
153
+ render: (args) => (<Popover onOpen={args.handleOpen} onClose={args.handleClose} active={false}>
154
+ <Popover.Trigger>
155
+ {(attributes) => <Button attributes={attributes}>Open</Button>}
156
+ </Popover.Trigger>
157
+ <Popover.Content>Content</Popover.Content>
158
+ </Popover>),
159
+ play: async ({ canvasElement, args }) => {
160
+ const canvas = within(canvasElement.ownerDocument.body);
161
+ const trigger = canvas.getAllByRole("button")[0];
162
+ await userEvent.click(trigger);
163
+ await waitFor(() => {
164
+ expect(args.handleOpen).toHaveBeenCalledTimes(1);
165
+ expect(args.handleOpen).toHaveBeenCalledWith();
166
+ });
167
+ const item = canvas.queryByText("Content");
168
+ expect(item).not.toBeInTheDocument();
169
+ },
170
+ };
171
+ export const dismissible = {
172
+ name: "dismissible, onClose, className, attributes, closeAriaLabel",
173
+ args: {
174
+ handleClose: fn(),
175
+ },
176
+ render: (args) => (<Popover onClose={args.handleClose} defaultActive>
177
+ <Popover.Trigger>
178
+ {(attributes) => <Button attributes={attributes}>Open</Button>}
179
+ </Popover.Trigger>
180
+ <Popover.Content>
181
+ <Popover.Dismissible closeAriaLabel="Close" attributes={{ "data-testid": "test-id" }} className="test-classname">
182
+ Content
183
+ </Popover.Dismissible>
184
+ </Popover.Content>
185
+ </Popover>),
186
+ play: async ({ canvasElement, args }) => {
187
+ const canvas = within(canvasElement.ownerDocument.body);
188
+ await sleep(300);
189
+ const dismissible = canvas.getByTestId("test-id");
190
+ const closeButton = within(dismissible).getByRole("button");
191
+ expect(dismissible).toHaveClass("test-classname");
192
+ expect(closeButton).toHaveAccessibleName("Close");
193
+ await userEvent.click(closeButton);
194
+ await waitFor(() => {
195
+ expect(args.handleClose).toHaveBeenCalledTimes(1);
196
+ expect(args.handleClose).toHaveBeenCalledWith({});
197
+ });
198
+ await sleep(300);
199
+ const trigger = canvas.getAllByRole("button")[0];
200
+ await userEvent.click(trigger);
201
+ },
202
+ };
203
+ export const className = {
204
+ name: "className, attributes",
205
+ render: () => (<div data-testid="root">
206
+ <Popover active>
75
207
  <Popover.Trigger>
76
208
  {(attributes) => <Button attributes={attributes}>Open</Button>}
77
209
  </Popover.Trigger>
78
- <Popover.Content>
79
- <View height="100px" width="100px" borderColor="primary" borderRadius="medium" backgroundColor="neutral-faded"/>
210
+ <Popover.Content className="test-classname" attributes={{ "data-testid": "test-id" }}>
211
+ Content
80
212
  </Popover.Content>
81
213
  </Popover>
82
- </Example.Item>
83
- </Example>);
84
- export const padding = () => (<Example>
85
- <Example.Item title="padding: 0">
86
- <Demo padding={0}/>
87
- </Example.Item>
88
- <Example.Item title="padding: 6">
89
- <Demo padding={6}/>
90
- </Example.Item>
91
- </Example>);
92
- export const triggerType = () => (<Example>
93
- <Example.Item title="triggerType: hover">
94
- <Demo triggerType="hover"/>
95
- </Example.Item>
96
- </Example>);
97
- export const dismissible = () => {
98
- return (<Example>
99
- <Example.Item title="with dismissible">
100
- <Popover>
101
- <Popover.Trigger>
102
- {(attributes) => <Button attributes={attributes}>Open</Button>}
103
- </Popover.Trigger>
104
- <Popover.Content>
105
- <Popover.Dismissible closeAriaLabel="Close" align="center">
106
- Popover content
107
- </Popover.Dismissible>
108
- </Popover.Content>
109
- </Popover>
110
- </Example.Item>
111
- </Example>);
214
+ </div>),
215
+ play: async ({ canvasElement }) => {
216
+ const canvas = within(canvasElement.ownerDocument.body);
217
+ const menu = await canvas.findByTestId("test-id");
218
+ expect(menu).toHaveClass("test-classname");
219
+ },
112
220
  };
113
- export const edgeCases = () => (<Example>
114
- <Example.Item title="Popover with tooltip">
221
+ export const testWithTooltip = {
222
+ name: "test: with tooltip",
223
+ render: () => (<View paddingTop={10}>
115
224
  <Tooltip position="top" text="Hello">
116
225
  {(tooltipAttributes) => (<Popover position="bottom">
117
226
  <Popover.Trigger>
118
227
  {(attributes) => (<Button attributes={{
119
- ...attributes,
120
- ...tooltipAttributes,
121
- }}>
228
+ ...attributes,
229
+ ...tooltipAttributes,
230
+ }}>
122
231
  Open
123
232
  </Button>)}
124
233
  </Popover.Trigger>
@@ -130,5 +239,20 @@ export const edgeCases = () => (<Example>
130
239
  </Popover.Content>
131
240
  </Popover>)}
132
241
  </Tooltip>
133
- </Example.Item>
134
- </Example>);
242
+ </View>),
243
+ };
244
+ export const variant = {
245
+ name: "variant [deprecated]",
246
+ render: () => (<Example>
247
+ <Example.Item title="variant: headless">
248
+ <Popover variant="headless" defaultActive position="bottom-start">
249
+ <Popover.Trigger>
250
+ {(attributes) => <Button attributes={attributes}>Open</Button>}
251
+ </Popover.Trigger>
252
+ <Popover.Content>
253
+ <View height="100px" width="100px" borderColor="primary" borderRadius="medium" backgroundColor="primary-faded"/>
254
+ </Popover.Content>
255
+ </Popover>
256
+ </Example.Item>
257
+ </Example>),
258
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { classNames } from "../../utilities/helpers.js";
2
+ import { classNames } from "../../utilities/props.js";
3
3
  import s from "./Progress.module.css";
4
4
  const Progress = (props) => {
5
5
  const { value = 0, min = 0, max = 100, color = "primary", size = "medium", duration, ariaLabel, className, attributes, } = props;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames } from "../../utilities/helpers.js";
4
+ import { classNames } from "../../utilities/props.js";
5
5
  import { onNextFrame } from "../../utilities/animation.js";
6
6
  import usePrevious from "../../hooks/_private/usePrevious.js";
7
7
  import s from "./ProgressIndicator.module.css";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/helpers.js";
3
+ import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
4
4
  import HiddenInput from "../_private/HiddenInput/index.js";
5
5
  import Text from "../Text/index.js";
6
6
  import { useRadioGroup } from "../RadioGroup/index.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames } from "../../utilities/helpers.js";
4
+ import { classNames } from "../../utilities/props.js";
5
5
  import { GlobalColorMode, PrivateTheme } from "../Theme/index.js";
6
6
  import { ToastProvider } from "../Toast/index.js";
7
7
  import { useGlobalColorMode } from "../Theme/useTheme.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames } from "../../utilities/helpers.js";
4
+ import { classNames } from "../../utilities/props.js";
5
5
  import useDrag from "../../hooks/_private/useDrag.js";
6
6
  import View from "../View/index.js";
7
7
  import s from "./Resizable.module.css";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { classNames } from "../../utilities/helpers.js";
2
+ import { classNames } from "../../utilities/props.js";
3
3
  import s from "./Scrim.module.css";
4
4
  const Scrim = (props) => {
5
5
  const { children, backgroundSlot, position = "cover", attributes, className, scrimClassName, } = props;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { forwardRef } from "react";
4
- import { classNames } from "../../utilities/helpers.js";
4
+ import { classNames } from "../../utilities/props.js";
5
5
  import { disableUserSelect, enableUserSelect } from "../../utilities/dom/index.js";
6
6
  import getHeightStyles from "../../styles/height/index.js";
7
7
  import getMaxHeightStyles from "../../styles/maxHeight/index.js";
@@ -70,7 +70,7 @@ const ScrollArea = forwardRef((props, ref) => {
70
70
  const [scrollRatio, setScrollRatio] = React.useState({ x: 1, y: 1 });
71
71
  const [scrollPosition, setScrollPosition] = React.useState({ x: 0, y: 0 });
72
72
  const scrollableRef = React.useRef(null);
73
- const contentRef = React.useRef(null);
73
+ const rootRef = React.useRef(null);
74
74
  const heightStyles = getHeightStyles(height);
75
75
  const maxHeightStyles = getMaxHeightStyles(maxHeight);
76
76
  const rootClassNames = classNames(s.root, scrollbarDisplay && s[`--display-${scrollbarDisplay}`], heightStyles?.classNames, className);
@@ -124,14 +124,14 @@ const ScrollArea = forwardRef((props, ref) => {
124
124
  updateScroll();
125
125
  }, [updateScroll]);
126
126
  useIsomorphicLayoutEffect(() => {
127
- const contentEl = contentRef.current;
128
- if (!contentEl)
127
+ const rootEl = rootRef.current;
128
+ if (!rootEl)
129
129
  return;
130
130
  const observer = new ResizeObserver(updateScroll);
131
- observer.observe(contentEl);
131
+ observer.observe(rootEl);
132
132
  return () => observer.disconnect();
133
133
  }, [updateScroll]);
134
- return (_jsxs("div", { ...attributes, className: rootClassNames, style: { ...heightStyles?.variables }, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, tabIndex: 0, children: _jsx("div", { className: contentClassNames, ref: contentRef, style: { ...maxHeightStyles?.variables }, children: children }) }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
134
+ return (_jsxs("div", { ...attributes, ref: rootRef, className: rootClassNames, style: { ...heightStyles?.variables }, children: [_jsx("div", { className: s.scrollable, ref: scrollableRef, onScroll: handleScroll, tabIndex: 0, children: _jsx("div", { className: contentClassNames, style: { ...maxHeightStyles?.variables }, children: children }) }), scrollRatio.y < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { vertical: true, onThumbMove: handleThumbYMove, ratio: scrollRatio.y, position: scrollPosition.y })), scrollRatio.x < 1 && scrollbarDisplay !== "hidden" && (_jsx(ScrollAreaBar, { onThumbMove: handleThumbXMove, ratio: scrollRatio.x, position: scrollPosition.x }))] }));
135
135
  });
136
136
  ScrollArea.displayName = "ScrollArea";
137
137
  export default ScrollArea;
@@ -1 +1 @@
1
- .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){box-shadow:var(--rs-focus-shadow)}.scrollable{height:100%;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:999px;content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
1
+ .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){box-shadow:var(--rs-focus-shadow)}.scrollable{height:100%;outline:none;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:999px;content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
@@ -6,7 +6,7 @@ import { useFormControl } from "../FormControl/index.js";
6
6
  import Actionable from "../Actionable/index.js";
7
7
  import Text from "../Text/index.js";
8
8
  import IconArrow from "../../icons/ChevronVertical.js";
9
- import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/helpers.js";
9
+ import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
10
10
  import useElementId from "../../hooks/useElementId.js";
11
11
  import s from "./Select.module.css";
12
12
  const Select = (props) => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { classNames } from "../../utilities/helpers.js";
2
+ import { classNames } from "../../utilities/props.js";
3
3
  import View from "../View/index.js";
4
4
  import s from "./Skeleton.module.css";
5
5
  const Skeleton = (props) => {
@@ -4,23 +4,49 @@ export type SingleChangeArgs = {
4
4
  minValue?: never;
5
5
  maxValue?: never;
6
6
  name: string;
7
+ minName?: never;
8
+ maxName?: never;
7
9
  };
8
10
  export type RangeChangeArgs = {
9
11
  value?: never;
10
12
  minValue: number;
11
13
  maxValue: number;
12
14
  name: string;
15
+ minName?: never;
16
+ maxName?: never;
13
17
  };
14
- type RangeSelectionProps = {
15
- range: true;
16
- onChange?: (args: RangeChangeArgs) => void;
17
- onChangeCommit?: (args: RangeChangeArgs) => void;
18
+ export type NameRangeChangeArgs = {
19
+ value?: never;
20
+ minValue: number;
21
+ maxValue: number;
22
+ name?: never;
23
+ minName: string;
24
+ maxName: string;
18
25
  };
19
26
  type SingleSelectionProps = {
20
27
  range?: false;
28
+ name: string;
29
+ minName?: never;
30
+ maxName?: never;
21
31
  onChange?: (args: SingleChangeArgs) => void;
22
32
  onChangeCommit?: (args: SingleChangeArgs) => void;
23
33
  };
34
+ type RangeSelectionProps = {
35
+ range: true;
36
+ name: string;
37
+ minName?: never;
38
+ maxName?: never;
39
+ onChange?: (args: RangeChangeArgs) => void;
40
+ onChangeCommit?: (args: RangeChangeArgs) => void;
41
+ };
42
+ type NameRangeSelectionProps = {
43
+ range: true;
44
+ name?: never;
45
+ minName: string;
46
+ maxName: string;
47
+ onChange?: (args: RangeChangeArgs) => void;
48
+ onChangeCommit?: (args: RangeChangeArgs) => void;
49
+ };
24
50
  type ControlledSingleProps = {
25
51
  value: number;
26
52
  defaultValue?: never;
@@ -42,7 +68,6 @@ type UncontrolledRangeProps = {
42
68
  defaultMaxValue?: number;
43
69
  };
44
70
  type BaseProps = {
45
- name: string;
46
71
  step?: number;
47
72
  disabled?: boolean;
48
73
  min?: number;
@@ -54,8 +79,8 @@ type BaseProps = {
54
79
  className?: G.ClassName;
55
80
  attributes?: G.Attributes<"div">;
56
81
  };
57
- export type ControlledProps = BaseProps & ((ControlledSingleProps & SingleSelectionProps) | (ControlledRangeProps & RangeSelectionProps));
58
- export type UncontrolledProps = BaseProps & ((UncontrolledSingleProps & SingleSelectionProps) | (UncontrolledRangeProps & RangeSelectionProps));
82
+ export type ControlledProps = BaseProps & ((ControlledSingleProps & SingleSelectionProps) | (ControlledRangeProps & (RangeSelectionProps | NameRangeSelectionProps)));
83
+ export type UncontrolledProps = BaseProps & ((UncontrolledSingleProps & SingleSelectionProps) | (UncontrolledRangeProps & (RangeSelectionProps | NameRangeSelectionProps)));
59
84
  export type Props = ControlledProps | UncontrolledProps;
60
85
  export type DefaultProps = {
61
86
  min: number;
@@ -70,6 +95,7 @@ export type ThumbProps = {
70
95
  position: number;
71
96
  onChange: (value: number, options?: {
72
97
  commit?: boolean;
98
+ native?: boolean;
73
99
  }) => void;
74
100
  onDragStart: (e: React.TouchEvent | React.MouseEvent) => void;
75
101
  max: number;
@@ -78,5 +104,6 @@ export type ThumbProps = {
78
104
  orientation: NonNullable<BaseProps["orientation"]>;
79
105
  renderValue?: BaseProps["renderValue"];
80
106
  tooltipRef: React.RefObject<HTMLDivElement | null>;
107
+ inputRef: React.RefObject<HTMLInputElement | null>;
81
108
  };
82
109
  export {};
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames } from "../../utilities/helpers.js";
5
- import { enableUserSelect, disableUserSelect } from "../../utilities/dom/index.js";
4
+ import { classNames } from "../../utilities/props.js";
5
+ import { enableUserSelect, disableUserSelect, triggerChangeEvent } from "../../utilities/dom/index.js";
6
6
  import { disableScroll, enableScroll } from "../../utilities/scroll/index.js";
7
7
  import useRTL from "../../hooks/useRTL.js";
8
8
  import useElementId from "../../hooks/useElementId.js";
@@ -19,11 +19,15 @@ const SliderControlled = (props) => {
19
19
  const vertical = orientation === "vertical";
20
20
  const minValue = range && props.minValue !== undefined ? applyStepToValue(props.minValue, step) : undefined;
21
21
  const maxValue = applyStepToValue(range ? props.maxValue : props.value, step);
22
+ const minName = props.minName ?? props.name;
23
+ const maxName = props.maxName ?? props.name;
22
24
  const barRef = React.useRef(null);
23
25
  const minRef = React.useRef(null);
24
26
  const maxRef = React.useRef(null);
25
27
  const minTooltipRef = React.useRef(null);
26
28
  const maxTooltipRef = React.useRef(null);
29
+ const minInputRef = React.useRef(null);
30
+ const maxInputRef = React.useRef(null);
27
31
  const [draggingId, setDraggingId] = React.useState(null);
28
32
  const [rtl] = useRTL();
29
33
  const formControl = useFormControl();
@@ -68,7 +72,7 @@ const SliderControlled = (props) => {
68
72
  const tooltipLeftSide = thumbRect && draggingRect && thumbRect.left - draggingRect.width / 2;
69
73
  const tooltipRightSide = thumbRect && draggingRect && thumbRect.left + draggingRect.width / 2;
70
74
  // Crosses the left slider boundary
71
- if (tooltipLeftSide && barLeftSide && tooltipLeftSide < barLeftSide - 8) {
75
+ if (tooltipLeftSide && barLeftSide && tooltipLeftSide < barLeftSide) {
72
76
  nextTooltipOffset = draggingRect.width / 2 - 8;
73
77
  }
74
78
  // Crosses the right slider boundary
@@ -80,30 +84,38 @@ const SliderControlled = (props) => {
80
84
  tooltipEl.style.setProperty("--rs-slider-tooltip-offset", `${nextTooltipOffset || 0}px`);
81
85
  }
82
86
  }, [minId, vertical]);
83
- const handleMinChange = React.useCallback((value, options) => {
87
+ const handleMinChange = React.useCallback((value, options = {}) => {
84
88
  if (!range)
85
89
  return;
86
- const method = options?.commit ? onChangeCommitRef.current : onChangeRef.current;
90
+ const args = { minValue: value, maxValue, name, minName, maxName };
87
91
  // Manually controlled resolving of single/range handlers
88
92
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
89
93
  // @ts-ignore
90
- method?.({ minValue: value, maxValue, name });
91
- }, [maxValue, name, range, onChangeCommitRef, onChangeRef]);
92
- const handleMaxChange = React.useCallback((value, options) => {
93
- if (range) {
94
- const method = options?.commit ? onChangeCommitRef.current : onChangeRef.current;
95
- // Manually controlled resolving of single/range handlers
96
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97
- // @ts-ignore
98
- method?.({ minValue: minValue, maxValue: value, name });
99
- return;
100
- }
101
- const method = options?.commit ? onChangeCommitRef.current : onChangeRef.current;
94
+ if (options.commit)
95
+ onChangeCommitRef.current?.(args);
96
+ // Manually controlled resolving of single/range handlers
97
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
98
+ // @ts-ignore
99
+ if (options.native)
100
+ onChangeRef.current?.(args);
101
+ triggerChangeEvent(minInputRef.current, value.toString());
102
+ }, [maxValue, name, minName, maxName, range, onChangeCommitRef, onChangeRef]);
103
+ const handleMaxChange = React.useCallback((value, options = {}) => {
104
+ const args = range
105
+ ? { minValue: minValue, maxValue: value, name, minName, maxName }
106
+ : { value, name };
107
+ // Manually controlled resolving of single/range handlers
108
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
109
+ // @ts-ignore
110
+ if (options.commit)
111
+ onChangeCommitRef.current?.(args);
102
112
  // Manually controlled resolving of single/range handlers
103
113
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
104
114
  // @ts-ignore
105
- method?.({ value, name });
106
- }, [minValue, name, range, onChangeRef, onChangeCommitRef]);
115
+ if (options.native)
116
+ onChangeRef.current?.(args);
117
+ triggerChangeEvent(maxInputRef.current, value.toString());
118
+ }, [minValue, name, minName, maxName, range, onChangeRef, onChangeCommitRef]);
107
119
  const handleMouseDown = ({ nativeEvent }) => {
108
120
  if (disabled)
109
121
  return;
@@ -213,7 +225,7 @@ const SliderControlled = (props) => {
213
225
  _jsxs("div", { ...attributes, className: rootClassNames, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: [_jsx("div", { className: s.bar, ref: barRef, children: _jsx("div", { className: s.selection, style: {
214
226
  "--rs-slider-selection-start": `${minPercentPosition || 0}%`,
215
227
  "--rs-slider-selection-size": `${maxPercentPosition - (minPercentPosition || 0)}%`,
216
- } }) }), _jsxs("div", { className: s.thumbs, children: [minValue !== undefined && minPercentPosition !== undefined && (_jsx(SliderThumb, { id: minId, active: minId === draggingId, name: name, disabled: disabled, onChange: handleMinChange, value: minValue, onDragStart: handleMinDragStart, position: minPercentPosition, max: max, min: min, ref: minRef, tooltipRef: minTooltipRef, renderValue: renderValue, step: step, orientation: orientation })), _jsx(SliderThumb, { id: maxId, active: maxId === draggingId, name: name, disabled: disabled, onChange: handleMaxChange, value: maxValue, onDragStart: handleMaxDragStart, position: maxPercentPosition, max: max, min: min, ref: maxRef, tooltipRef: maxTooltipRef, renderValue: renderValue, step: step, orientation: orientation })] })] }));
228
+ } }) }), _jsxs("div", { className: s.thumbs, children: [minValue !== undefined && minPercentPosition !== undefined && (_jsx(SliderThumb, { id: minId, active: minId === draggingId, name: minName, disabled: disabled, onChange: handleMinChange, value: minValue, onDragStart: handleMinDragStart, position: minPercentPosition, max: max, min: min, ref: minRef, tooltipRef: minTooltipRef, inputRef: minInputRef, renderValue: renderValue, step: step, orientation: orientation })), _jsx(SliderThumb, { id: maxId, active: maxId === draggingId, name: maxName, disabled: disabled, onChange: handleMaxChange, value: maxValue, onDragStart: handleMaxDragStart, position: maxPercentPosition, max: max, min: min, ref: maxRef, tooltipRef: maxTooltipRef, inputRef: maxInputRef, renderValue: renderValue, step: step, orientation: orientation })] })] }));
217
229
  };
218
230
  SliderControlled.displayName = "SliderControlled";
219
231
  export default SliderControlled;