reshaped 3.8.0-canary.0 → 3.8.0-canary.10

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 (290) hide show
  1. package/CHANGELOG.md +101 -8
  2. package/README.md +2 -2
  3. package/dist/bundle.css +1 -1
  4. package/dist/bundle.d.ts +1 -1
  5. package/dist/bundle.js +11 -11
  6. package/dist/components/Accordion/AccordionControlled.js +1 -0
  7. package/dist/components/Actionable/Actionable.js +17 -3
  8. package/dist/components/Actionable/Actionable.module.css +1 -1
  9. package/dist/components/Actionable/Actionable.types.d.ts +15 -3
  10. package/dist/components/Actionable/tests/Actionable.stories.d.ts +13 -1
  11. package/dist/components/Actionable/tests/Actionable.stories.js +127 -7
  12. package/dist/components/Alert/tests/Alert.stories.d.ts +6 -5
  13. package/dist/components/Alert/tests/Alert.stories.js +15 -2
  14. package/dist/components/Autocomplete/Autocomplete.js +2 -2
  15. package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -1
  16. package/dist/components/Badge/Badge.module.css +1 -1
  17. package/dist/components/Badge/tests/Badge.stories.d.ts +5 -0
  18. package/dist/components/Badge/tests/Badge.stories.js +34 -0
  19. package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -0
  20. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +8 -4
  21. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +57 -1
  22. package/dist/components/Button/Button.js +2 -2
  23. package/dist/components/Button/Button.types.d.ts +1 -1
  24. package/dist/components/Button/tests/Button.stories.d.ts +54 -12
  25. package/dist/components/Button/tests/Button.stories.js +725 -588
  26. package/dist/components/Calendar/CalendarMonth.js +1 -0
  27. package/dist/components/Card/Card.d.ts +1 -1
  28. package/dist/components/Card/Card.module.css +1 -1
  29. package/dist/components/Card/tests/Card.stories.d.ts +29 -7
  30. package/dist/components/Card/tests/Card.stories.js +110 -65
  31. package/dist/components/Carousel/Carousel.js +1 -0
  32. package/dist/components/Carousel/Carousel.module.css +1 -1
  33. package/dist/components/Checkbox/Checkbox.module.css +1 -1
  34. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +20 -4
  35. package/dist/components/Checkbox/tests/Checkbox.stories.js +150 -79
  36. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +9 -2
  37. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +67 -35
  38. package/dist/components/Container/tests/Container.stories.d.ts +2 -0
  39. package/dist/components/Container/tests/Container.stories.js +14 -0
  40. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +10 -1
  41. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +57 -13
  42. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +5 -0
  43. package/dist/components/Dismissible/tests/Dismissible.stories.js +30 -1
  44. package/dist/components/Divider/tests/Divider.stories.d.ts +8 -3
  45. package/dist/components/Divider/tests/Divider.stories.js +71 -41
  46. package/dist/components/DropdownMenu/DropdownMenu.js +4 -4
  47. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +2 -2
  48. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +35 -6
  49. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +222 -115
  50. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +0 -15
  51. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +0 -106
  52. package/dist/components/FileUpload/FileUpload.module.css +1 -1
  53. package/dist/components/Flyout/Flyout.module.css +1 -1
  54. package/dist/components/Flyout/Flyout.types.d.ts +9 -6
  55. package/dist/components/Flyout/FlyoutContent.js +4 -1
  56. package/dist/components/Flyout/FlyoutControlled.js +11 -3
  57. package/dist/components/Flyout/index.d.ts +1 -1
  58. package/dist/components/Flyout/tests/Flyout.stories.d.ts +12 -0
  59. package/dist/components/Flyout/tests/Flyout.stories.js +112 -6
  60. package/dist/components/Flyout/useFlyout.d.ts +1 -6
  61. package/dist/components/Flyout/useFlyout.js +7 -1
  62. package/dist/components/Flyout/utilities/calculatePosition.d.ts +3 -2
  63. package/dist/components/Flyout/utilities/calculatePosition.js +85 -36
  64. package/dist/components/Flyout/utilities/flyout.js +24 -19
  65. package/dist/components/Flyout/utilities/getPositionFallbacks.js +3 -3
  66. package/dist/components/Flyout/utilities/helpers.d.ts +7 -0
  67. package/dist/components/Flyout/utilities/helpers.js +14 -0
  68. package/dist/components/Flyout/utilities/isFullyVisible.d.ts +4 -2
  69. package/dist/components/Flyout/utilities/isFullyVisible.js +6 -8
  70. package/dist/components/FormControl/FormControl.context.d.ts +1 -1
  71. package/dist/components/FormControl/tests/FormControl.stories.d.ts +2 -0
  72. package/dist/components/FormControl/tests/FormControl.stories.js +35 -0
  73. package/dist/components/Hidden/tests/Hidden.stories.d.ts +2 -0
  74. package/dist/components/Hidden/tests/Hidden.stories.js +9 -0
  75. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +2 -0
  76. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +9 -0
  77. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +2 -0
  78. package/dist/components/Hotkey/tests/Hotkey.stories.js +15 -0
  79. package/dist/components/Icon/Icon.js +2 -2
  80. package/dist/components/Icon/Icon.types.d.ts +1 -1
  81. package/dist/components/Icon/tests/Icon.stories.d.ts +3 -0
  82. package/dist/components/Icon/tests/Icon.stories.js +29 -1
  83. package/dist/components/Link/Link.d.ts +1 -1
  84. package/dist/components/Link/Link.js +2 -2
  85. package/dist/components/Link/Link.types.d.ts +1 -1
  86. package/dist/components/Link/tests/Link.stories.d.ts +29 -6
  87. package/dist/components/Link/tests/Link.stories.js +141 -58
  88. package/dist/components/Link/tests/Link.test.stories.d.ts +1 -13
  89. package/dist/components/Link/tests/Link.test.stories.js +0 -76
  90. package/dist/components/Loader/tests/Loader.stories.d.ts +11 -2
  91. package/dist/components/Loader/tests/Loader.stories.js +52 -25
  92. package/dist/components/Loader/tests/Loader.test.stories.d.ts +0 -3
  93. package/dist/components/Loader/tests/Loader.test.stories.js +0 -21
  94. package/dist/components/MenuItem/MenuItem.js +2 -2
  95. package/dist/components/MenuItem/MenuItem.module.css +1 -1
  96. package/dist/components/MenuItem/MenuItem.types.d.ts +1 -1
  97. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +37 -7
  98. package/dist/components/MenuItem/tests/MenuItem.stories.js +218 -112
  99. package/dist/components/Modal/Modal.js +1 -1
  100. package/dist/components/Modal/Modal.module.css +1 -1
  101. package/dist/components/Modal/tests/Modal.stories.d.ts +53 -10
  102. package/dist/components/Modal/tests/Modal.stories.js +367 -210
  103. package/dist/components/Overlay/Overlay.js +2 -1
  104. package/dist/components/Overlay/tests/Overlay.stories.d.ts +15 -1
  105. package/dist/components/Overlay/tests/Overlay.stories.js +135 -1
  106. package/dist/components/Pagination/tests/Pagination.stories.d.ts +14 -1
  107. package/dist/components/Pagination/tests/Pagination.stories.js +93 -15
  108. package/dist/components/PinField/PinField.module.css +1 -1
  109. package/dist/components/PinField/tests/PinField.stories.d.ts +24 -3
  110. package/dist/components/PinField/tests/PinField.stories.js +194 -47
  111. package/dist/components/Popover/Popover.js +2 -2
  112. package/dist/components/Popover/Popover.module.css +1 -1
  113. package/dist/components/Popover/Popover.types.d.ts +3 -1
  114. package/dist/components/Progress/tests/Progress.stories.d.ts +19 -4
  115. package/dist/components/Progress/tests/Progress.stories.js +85 -49
  116. package/dist/components/Radio/Radio.module.css +1 -1
  117. package/dist/components/Radio/tests/Radio.stories.d.ts +25 -4
  118. package/dist/components/Radio/tests/Radio.stories.js +147 -65
  119. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +9 -2
  120. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +64 -38
  121. package/dist/components/Reshaped/Reshaped.css +1 -1
  122. package/dist/components/Scrim/tests/Scrim.stories.d.ts +10 -2
  123. package/dist/components/Scrim/tests/Scrim.stories.js +51 -31
  124. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  125. package/dist/components/Select/Select.d.ts +8 -1
  126. package/dist/components/Select/Select.js +22 -48
  127. package/dist/components/Select/Select.module.css +1 -1
  128. package/dist/components/Select/Select.types.d.ts +83 -38
  129. package/dist/components/Select/SelectCustom.d.ts +3 -0
  130. package/dist/components/Select/SelectCustom.js +12 -0
  131. package/dist/components/Select/SelectCustomControlled.d.ts +4 -0
  132. package/dist/components/Select/SelectCustomControlled.js +105 -0
  133. package/dist/components/Select/SelectCustomUncontrolled.d.ts +4 -0
  134. package/dist/components/Select/SelectCustomUncontrolled.js +18 -0
  135. package/dist/components/Select/SelectEndContent.d.ts +3 -0
  136. package/dist/components/Select/SelectEndContent.js +12 -0
  137. package/dist/components/Select/SelectNative.d.ts +4 -0
  138. package/dist/components/Select/SelectNative.js +29 -0
  139. package/dist/components/Select/SelectOption.d.ts +4 -0
  140. package/dist/components/Select/SelectOption.js +13 -0
  141. package/dist/components/Select/SelectOptionGroup.d.ts +4 -0
  142. package/dist/components/Select/SelectOptionGroup.js +9 -0
  143. package/dist/components/Select/SelectRoot.d.ts +4 -0
  144. package/dist/components/Select/SelectRoot.js +21 -0
  145. package/dist/components/Select/SelectStartContent.d.ts +3 -0
  146. package/dist/components/Select/SelectStartContent.js +20 -0
  147. package/dist/components/Select/SelectTrigger.d.ts +4 -0
  148. package/dist/components/Select/SelectTrigger.js +16 -0
  149. package/dist/components/Select/tests/Select.stories.d.ts +38 -10
  150. package/dist/components/Select/tests/Select.stories.js +504 -175
  151. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +10 -2
  152. package/dist/components/Skeleton/tests/Skeleton.stories.js +46 -28
  153. package/dist/components/Slider/Slider.module.css +1 -1
  154. package/dist/components/Stepper/Stepper.js +2 -2
  155. package/dist/components/Stepper/Stepper.types.d.ts +2 -0
  156. package/dist/components/Stepper/tests/Stepper.stories.d.ts +18 -3
  157. package/dist/components/Stepper/tests/Stepper.stories.js +99 -47
  158. package/dist/components/Switch/Switch.module.css +1 -1
  159. package/dist/components/Switch/tests/Switch.stories.d.ts +10 -2
  160. package/dist/components/Switch/tests/Switch.stories.js +77 -23
  161. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -10
  162. package/dist/components/Switch/tests/Switch.test.stories.js +0 -68
  163. package/dist/components/Table/Table.js +5 -3
  164. package/dist/components/Table/Table.module.css +1 -1
  165. package/dist/components/Table/tests/Table.stories.d.ts +25 -5
  166. package/dist/components/Table/tests/Table.stories.js +274 -177
  167. package/dist/components/Table/tests/Table.test.stories.d.ts +0 -5
  168. package/dist/components/Table/tests/Table.test.stories.js +0 -82
  169. package/dist/components/Tabs/Tabs.module.css +1 -1
  170. package/dist/components/Tabs/TabsControlled.js +1 -0
  171. package/dist/components/TextArea/TextArea.module.css +1 -1
  172. package/dist/components/TextArea/tests/TextArea.stories.d.ts +41 -9
  173. package/dist/components/TextArea/tests/TextArea.stories.js +179 -93
  174. package/dist/components/TextField/TextField.js +1 -1
  175. package/dist/components/TextField/TextField.module.css +1 -1
  176. package/dist/components/TextField/tests/TextField.stories.d.ts +41 -11
  177. package/dist/components/TextField/tests/TextField.stories.js +206 -132
  178. package/dist/components/TextField/tests/TextField.test.stories.d.ts +0 -13
  179. package/dist/components/TextField/tests/TextField.test.stories.js +0 -88
  180. package/dist/components/Theme/Theme.module.css +1 -1
  181. package/dist/components/Timeline/Timeline.js +2 -2
  182. package/dist/components/Timeline/tests/Timeline.stories.d.ts +10 -2
  183. package/dist/components/Timeline/tests/Timeline.stories.js +69 -45
  184. package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +0 -2
  185. package/dist/components/Timeline/tests/Timeline.test.stories.js +0 -21
  186. package/dist/components/Toast/ToastContainer.js +1 -0
  187. package/dist/components/Toast/ToastRegion.js +1 -0
  188. package/dist/components/Toast/tests/Toast.stories.d.ts +32 -8
  189. package/dist/components/Toast/tests/Toast.stories.js +111 -37
  190. package/dist/components/ToggleButton/ToggleButton.types.d.ts +1 -1
  191. package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +1 -0
  192. package/dist/components/Tooltip/Tooltip.js +1 -1
  193. package/dist/components/Tooltip/Tooltip.types.d.ts +2 -2
  194. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +18 -4
  195. package/dist/components/Tooltip/tests/Tooltip.stories.js +139 -107
  196. package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +0 -6
  197. package/dist/components/Tooltip/tests/Tooltip.test.stories.js +0 -29
  198. package/dist/components/View/View.js +11 -4
  199. package/dist/components/View/tests/View.stories.d.ts +4 -0
  200. package/dist/components/View/tests/View.stories.js +39 -0
  201. package/dist/components/_private/Expandable/Expandable.js +3 -1
  202. package/dist/components/_private/Portal/Portal.js +4 -1
  203. package/dist/hooks/_private/useIsDismissible.d.ts +1 -0
  204. package/dist/hooks/_private/useIsDismissible.js +6 -6
  205. package/dist/hooks/_private/usePrevious.js +1 -0
  206. package/dist/hooks/tests/useDrag.stories.js +1 -1
  207. package/dist/hooks/useScrollLock.js +5 -3
  208. package/dist/index.d.ts +1 -1
  209. package/dist/styles/resolvers/align/align.css +1 -1
  210. package/dist/styles/resolvers/aspectRatio/aspectRatio.css +1 -1
  211. package/dist/styles/resolvers/bleed/bleed.module.css +1 -1
  212. package/dist/styles/resolvers/justify/justify.css +1 -1
  213. package/dist/styles/resolvers/maxHeight/maxHeight.module.css +1 -1
  214. package/dist/styles/resolvers/maxWidth/maxWidth.module.css +1 -1
  215. package/dist/styles/resolvers/minHeight/minHeight.module.css +1 -1
  216. package/dist/styles/resolvers/minWidth/minWidth.module.css +1 -1
  217. package/dist/styles/resolvers/position/position.css +1 -1
  218. package/dist/styles/resolvers/textAlign/textAlign.css +1 -1
  219. package/dist/styles/resolvers/width/width.module.css +1 -1
  220. package/dist/utilities/scroll/disable.js +2 -2
  221. package/dist/utilities/scroll/index.d.ts +1 -1
  222. package/dist/utilities/scroll/index.js +1 -1
  223. package/dist/utilities/scroll/lock.d.ts +1 -2
  224. package/dist/utilities/scroll/lock.js +16 -15
  225. package/dist/utilities/scroll/lockSafari.js +1 -0
  226. package/package.json +44 -33
  227. package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +0 -32
  228. package/dist/components/Actionable/tests/Actionable.test.stories.js +0 -130
  229. package/dist/components/Alert/tests/Alert.test.stories.d.ts +0 -15
  230. package/dist/components/Alert/tests/Alert.test.stories.js +0 -26
  231. package/dist/components/Badge/tests/Badge.test.stories.d.ts +0 -20
  232. package/dist/components/Badge/tests/Badge.test.stories.js +0 -46
  233. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +0 -23
  234. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +0 -76
  235. package/dist/components/Button/tests/Button.test.stories.d.ts +0 -27
  236. package/dist/components/Button/tests/Button.test.stories.js +0 -112
  237. package/dist/components/Card/tests/Card.test.stories.d.ts +0 -35
  238. package/dist/components/Card/tests/Card.test.stories.js +0 -54
  239. package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +0 -25
  240. package/dist/components/Checkbox/tests/Checkbox.test.stories.js +0 -104
  241. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +0 -22
  242. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +0 -78
  243. package/dist/components/Container/tests/Container.test.stories.d.ts +0 -15
  244. package/dist/components/Container/tests/Container.test.stories.js +0 -26
  245. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +0 -25
  246. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +0 -53
  247. package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +0 -19
  248. package/dist/components/Dismissible/tests/Dismissible.test.stories.js +0 -42
  249. package/dist/components/Divider/tests/Divider.test.stories.d.ts +0 -18
  250. package/dist/components/Divider/tests/Divider.test.stories.js +0 -47
  251. package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +0 -20
  252. package/dist/components/FormControl/tests/FormControl.test.stories.js +0 -49
  253. package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +0 -15
  254. package/dist/components/Hidden/tests/Hidden.test.stories.js +0 -20
  255. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +0 -15
  256. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +0 -20
  257. package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +0 -15
  258. package/dist/components/Hotkey/tests/Hotkey.test.stories.js +0 -26
  259. package/dist/components/Icon/tests/Icon.test.stories.d.ts +0 -16
  260. package/dist/components/Icon/tests/Icon.test.stories.js +0 -35
  261. package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +0 -26
  262. package/dist/components/MenuItem/tests/MenuItem.test.stories.js +0 -100
  263. package/dist/components/Modal/tests/Modal.test.stories.d.ts +0 -31
  264. package/dist/components/Modal/tests/Modal.test.stories.js +0 -149
  265. package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +0 -28
  266. package/dist/components/Overlay/tests/Overlay.test.stories.js +0 -148
  267. package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +0 -23
  268. package/dist/components/Pagination/tests/Pagination.test.stories.js +0 -86
  269. package/dist/components/PinField/tests/PinField.test.stories.d.ts +0 -29
  270. package/dist/components/PinField/tests/PinField.test.stories.js +0 -177
  271. package/dist/components/Progress/tests/Progress.test.stories.d.ts +0 -16
  272. package/dist/components/Progress/tests/Progress.test.stories.js +0 -35
  273. package/dist/components/Radio/tests/Radio.test.stories.d.ts +0 -30
  274. package/dist/components/Radio/tests/Radio.test.stories.js +0 -118
  275. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +0 -22
  276. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +0 -78
  277. package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +0 -15
  278. package/dist/components/Scrim/tests/Scrim.test.stories.js +0 -25
  279. package/dist/components/Select/tests/Select.test.stories.d.ts +0 -27
  280. package/dist/components/Select/tests/Select.test.stories.js +0 -132
  281. package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +0 -15
  282. package/dist/components/Skeleton/tests/Skeleton.test.stories.js +0 -23
  283. package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +0 -20
  284. package/dist/components/Stepper/tests/Stepper.test.stories.js +0 -28
  285. package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +0 -28
  286. package/dist/components/TextArea/tests/TextArea.test.stories.js +0 -99
  287. package/dist/components/Toast/tests/Toast.test.stories.d.ts +0 -16
  288. package/dist/components/Toast/tests/Toast.test.stories.js +0 -101
  289. package/dist/components/View/tests/View.test.stories.d.ts +0 -24
  290. package/dist/components/View/tests/View.test.stories.js +0 -50
@@ -29,6 +29,18 @@ export declare const positionFallbacks: {
29
29
  name: string;
30
30
  render: () => React.JSX.Element;
31
31
  };
32
+ export declare const fallbackAdjustLayout: {
33
+ name: string;
34
+ render: () => React.JSX.Element;
35
+ };
36
+ export declare const fallbackAdjustLayoutShift: {
37
+ name: string;
38
+ render: () => React.JSX.Element;
39
+ };
40
+ export declare const fallbackAdjustLayoutSize: {
41
+ name: string;
42
+ render: () => React.JSX.Element;
43
+ };
32
44
  export declare const originCoordinates: {
33
45
  name: string;
34
46
  render: () => React.JSX.Element;
@@ -17,7 +17,7 @@ const Content = (props) => (<div style={{
17
17
  background: "var(--rs-color-background-elevation-overlay)",
18
18
  padding: "var(--rs-unit-x4)",
19
19
  height: props.height === false ? undefined : props.height || 150,
20
- minWidth: props.width === false ? undefined : props.width || 160,
20
+ width: props.width === false ? undefined : props.width || 160,
21
21
  borderRadius: "var(--rs-radius-medium)",
22
22
  border: "1px solid var(--rs-color-border-neutral-faded)",
23
23
  boxSizing: "border-box",
@@ -30,17 +30,25 @@ const Demo = (props) => {
30
30
  <Flyout.Trigger>
31
31
  {(attributes) => <Button attributes={attributes}>{text || position}</Button>}
32
32
  </Flyout.Trigger>
33
- <Flyout.Content>
34
- <Content height={contentHeight} width={contentWidth}>
35
- {children}
36
- </Content>
33
+ <Flyout.Content attributes={{
34
+ style: {
35
+ background: "var(--rs-color-background-elevation-overlay)",
36
+ padding: "var(--rs-unit-x4)",
37
+ height: contentHeight === false ? undefined : contentHeight || 150,
38
+ width: contentWidth === false ? undefined : contentWidth || 160,
39
+ borderRadius: "var(--rs-radius-medium)",
40
+ border: "1px solid var(--rs-color-border-neutral-faded)",
41
+ boxSizing: "border-box",
42
+ },
43
+ }}>
44
+ {children || "Content"}
37
45
  </Flyout.Content>
38
46
  </Flyout>);
39
47
  };
40
48
  export const position = {
41
49
  name: "position",
42
50
  render: () => {
43
- return (<View gap={4} padding={50} align="center" justify="center" height="120vh" width="120%">
51
+ return (<View gap={4} padding={50} align="center" justify="center" height="100vh" width="120%">
44
52
  <View gap={4} direction="row">
45
53
  <Demo position="top-start" defaultActive/>
46
54
  <Demo position="top"/>
@@ -222,6 +230,104 @@ export const positionFallbacks = {
222
230
  </Example>);
223
231
  },
224
232
  };
233
+ const FallbackAdjustLayoutControls = ({ containerRef, large, }) => {
234
+ const contentHeight = large ? "2000px" : "200px";
235
+ const contentWidth = large ? "2000px" : "300px";
236
+ return (<>
237
+ {/* Left side */}
238
+ <View position="absolute" insetStart={4} insetTop={10} gap={2}>
239
+ <Demo contentHeight={contentHeight} position="end" fallbackAdjustLayout fallbackPositions={false} containerRef={containerRef}/>
240
+ <Demo contentHeight={contentHeight} position="end-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
241
+ </View>
242
+
243
+ <View position="absolute" insetStart={4} insetTop={80} gap={2}>
244
+ <Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
245
+ <Demo position="top-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
246
+ <Demo position="bottom-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
247
+ <Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
248
+ </View>
249
+
250
+ <View position="absolute" insetBottom={4} insetStart={4} gap={2}>
251
+ <Demo contentHeight={contentHeight} position="end-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
252
+ <Demo contentHeight={contentHeight} position="end" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
253
+ </View>
254
+
255
+ {/* Right side */}
256
+
257
+ <View position="absolute" insetTop={10} insetEnd={4} gap={2}>
258
+ <Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
259
+ <Demo contentHeight={contentHeight} position="start-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
260
+ </View>
261
+
262
+ <View position="absolute" insetEnd={4} insetTop={80} gap={2}>
263
+ <Demo position="top-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
264
+ <Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
265
+ <Demo position="bottom-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
266
+ <Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
267
+ </View>
268
+
269
+ <View position="absolute" insetBottom={4} insetEnd={4} gap={2}>
270
+ <Demo contentHeight={contentHeight} position="start-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
271
+ <Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
272
+ </View>
273
+ </>);
274
+ };
275
+ export const fallbackAdjustLayout = {
276
+ name: "fallbackAdjustLayout",
277
+ render: () => {
278
+ return (<Demo contentHeight={false} position="bottom-start" width="200px" fallbackAdjustLayout defaultActive>
279
+ <div style={{ height: "600px" }}>Content</div>
280
+ </Demo>);
281
+ },
282
+ };
283
+ export const fallbackAdjustLayoutShift = {
284
+ name: "fallbackAdjustLayout, shift",
285
+ render: () => {
286
+ const containerRef = React.useRef(null);
287
+ return (<View gap={10}>
288
+ <View height="95vh" width="100%" align="center" justify="center">
289
+ <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
290
+ <FallbackAdjustLayoutControls />
291
+ <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
292
+ </View>
293
+ </View>
294
+
295
+ <View height="95vh" width="100%" align="center" justify="center">
296
+ <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
297
+ <FallbackAdjustLayoutControls containerRef={containerRef}/>
298
+ <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
299
+ </View>
300
+ </View>
301
+
302
+ <FallbackAdjustLayoutControls />
303
+ <div style={{ height: "100vh", width: "250%" }}/>
304
+ </View>);
305
+ },
306
+ };
307
+ export const fallbackAdjustLayoutSize = {
308
+ name: "fallbackAdjustLayout, size",
309
+ render: () => {
310
+ const containerRef = React.useRef(null);
311
+ return (<View gap={10}>
312
+ <View height="95vh" width="100%" align="center" justify="center">
313
+ <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
314
+ <FallbackAdjustLayoutControls large/>
315
+ <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
316
+ </View>
317
+ </View>
318
+
319
+ <View height="95vh" width="100%" align="center" justify="center">
320
+ <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
321
+ <FallbackAdjustLayoutControls containerRef={containerRef} large/>
322
+ <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
323
+ </View>
324
+ </View>
325
+
326
+ <FallbackAdjustLayoutControls large/>
327
+ <div style={{ height: "100vh", width: "250%" }}/>
328
+ </View>);
329
+ },
330
+ };
225
331
  export const originCoordinates = {
226
332
  name: "originCoordinates",
227
333
  render: () => {
@@ -1,13 +1,8 @@
1
1
  import React from "react";
2
2
  import type * as G from "../../types/global";
3
3
  import type * as T from "./Flyout.types";
4
- type UseFlyout = (args: {
5
- width?: T.Width;
6
- position?: T.Position;
7
- defaultActive?: boolean;
4
+ type UseFlyout = (args: Pick<T.Props, "width" | "position" | "defaultActive" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight" | "contentGap" | "contentShift"> & {
8
5
  fallbackPositions?: T.Position[];
9
- contentGap?: number;
10
- contentShift?: number;
11
6
  container?: HTMLElement | null;
12
7
  triggerElRef: React.RefObject<HTMLElement | null>;
13
8
  flyoutElRef: React.RefObject<HTMLElement | null>;
@@ -38,7 +38,7 @@ const flyoutReducer = (state, action) => {
38
38
  };
39
39
  const useFlyout = (args) => {
40
40
  const { triggerElRef, flyoutElRef, triggerBounds, contentGap, contentShift, ...options } = args;
41
- const { position: defaultPosition = "bottom", fallbackPositions, width, container } = options;
41
+ const { position: defaultPosition = "bottom", fallbackPositions, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, width, container, } = options;
42
42
  const lastUsedPositionRef = React.useRef(defaultPosition);
43
43
  // Memo the array internally to avoid new arrays triggering useCallback
44
44
  const cachedFallbackPositions = React.useMemo(() => fallbackPositions,
@@ -76,6 +76,9 @@ const useFlyout = (args) => {
76
76
  width,
77
77
  position: changePositon ? defaultPosition : lastUsedPositionRef.current,
78
78
  fallbackPositions: changePositon ? cachedFallbackPositions : [],
79
+ fallbackAdjustLayout,
80
+ fallbackMinWidth,
81
+ fallbackMinHeight,
79
82
  lastUsedPosition: lastUsedPositionRef.current,
80
83
  onPositionChoose: handlePosition,
81
84
  rtl: isRTL,
@@ -93,6 +96,7 @@ const useFlyout = (args) => {
93
96
  container,
94
97
  defaultPosition,
95
98
  cachedFallbackPositions,
99
+ fallbackAdjustLayout,
96
100
  isRTL,
97
101
  flyoutElRef,
98
102
  triggerElRef,
@@ -101,6 +105,8 @@ const useFlyout = (args) => {
101
105
  contentGap,
102
106
  contentShift,
103
107
  handlePosition,
108
+ fallbackMinWidth,
109
+ fallbackMinHeight,
104
110
  ]);
105
111
  React.useEffect(() => {
106
112
  if (state.status === "rendered")
@@ -10,15 +10,16 @@ declare const calculatePosition: (args: {
10
10
  };
11
11
  passedContainer?: HTMLElement | null;
12
12
  containerBounds: DOMRect;
13
- } & Pick<T.Options, "position" | "rtl" | "width" | "contentGap" | "contentShift">) => {
13
+ } & Pick<T.Options, "position" | "rtl" | "width" | "contentGap" | "contentShift" | "fallbackAdjustLayout" | "fallbackMinWidth" | "fallbackMinHeight">) => {
14
14
  position: T.Position;
15
15
  styles: {
16
- width: string | number | undefined;
17
16
  left: number | undefined;
18
17
  right: number | undefined;
19
18
  top: number | undefined;
20
19
  bottom: number | undefined;
21
20
  transform: string;
21
+ height: number | undefined;
22
+ width: string | number | undefined;
22
23
  };
23
24
  boundaries: {
24
25
  left: number;
@@ -1,27 +1,17 @@
1
- const SCREEN_OFFSET = 16;
2
- const getRTLPosition = (position) => {
3
- if (position.includes("start"))
4
- return position.replace("start", "end");
5
- if (position.includes("end"))
6
- return position.replace("end", "start");
7
- return position;
8
- };
9
- /**
10
- * Get a position value which centers 2 elements vertically or horizontally
11
- */
12
- const centerBySize = (originSize, targetSize) => {
13
- return Math.floor(originSize / 2 - targetSize / 2);
14
- };
1
+ import { getRTLPosition, centerBySize } from "./helpers.js";
2
+ const SCREEN_OFFSET = 8;
15
3
  /**
16
4
  * Calculate styles for the current position
17
5
  */
18
6
  const calculatePosition = (args) => {
19
- const { triggerBounds, flyoutBounds, containerBounds, position: passedPosition, rtl, width, contentGap = 0, contentShift = 0, passedContainer, } = args;
20
- const isFullWidth = width === "full" || width === "100%";
7
+ const { triggerBounds, flyoutBounds, containerBounds, position: passedPosition, rtl, width: passedWidth, contentGap = 0, contentShift = 0, passedContainer, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, } = args;
8
+ const isFullWidth = passedWidth === "full" || passedWidth === "100%";
21
9
  let left = 0;
22
10
  let top = 0;
23
11
  let bottom = null;
24
12
  let right = null;
13
+ let height = undefined;
14
+ let width = undefined;
25
15
  let position = passedPosition;
26
16
  if (rtl)
27
17
  position = getRTLPosition(position);
@@ -29,25 +19,34 @@ const calculatePosition = (args) => {
29
19
  position = position.includes("top") ? "top" : "bottom";
30
20
  }
31
21
  const isHorizontalPosition = !!position.match(/^(start|end)/);
32
- const isVerticalPosition = !!position.match(/^(top|bottom)/);
33
22
  // contentGap adds padding to the flyout to make sure it doesn't disapper while moving the mouse to the content
34
23
  // So its width/height is bigger than the visible part of the content
35
24
  const flyoutWidth = flyoutBounds.width + (isHorizontalPosition ? contentGap : 0);
36
- const flyoutHeight = flyoutBounds.height + (isVerticalPosition ? contentGap : 0);
37
- const triggerHeight = triggerBounds.height;
25
+ const flyoutHeight = flyoutBounds.height + (!isHorizontalPosition ? contentGap : 0);
38
26
  const triggerWidth = triggerBounds.width;
39
- const containerY = passedContainer?.scrollTop || 0;
40
- const containerX = passedContainer?.scrollLeft || 0;
41
- const relativeLeft = triggerBounds.left - containerBounds.left + containerX;
42
- const relativeTop = triggerBounds.top - containerBounds.top + containerY;
43
- const relativeRight = containerBounds.right - triggerBounds.right - containerX;
44
- const relativeBottom = containerBounds.bottom - triggerBounds.bottom - containerY;
27
+ const triggerHeight = triggerBounds.height;
28
+ // Detect passed container scroll to sync the flyout position with it
29
+ const containerX = passedContainer?.scrollLeft;
30
+ const containerY = passedContainer?.scrollTop;
31
+ const scrollX = containerX ?? window.scrollX;
32
+ const scrollY = containerY ?? window.scrollY;
33
+ const renderContainerHeight = passedContainer?.clientHeight ?? window.innerHeight;
34
+ const renderContainerWidth = passedContainer?.clientWidth ?? window.innerWidth;
35
+ // When rendering in the body, bottom bounds will be larrger than the viewport so we calculate it manually
36
+ const containerBoundsBottom = passedContainer
37
+ ? containerBounds.bottom
38
+ : window.innerHeight - scrollY;
39
+ // When inside a container, adjut position based on the container scroll since flyout is rendered outside the scroll area
40
+ const relativeLeft = triggerBounds.left - containerBounds.left + (containerX || 0);
41
+ const relativeRight = containerBounds.right - triggerBounds.right - (containerX || 0);
42
+ const relativeTop = triggerBounds.top - containerBounds.top + (containerY || 0);
43
+ const relativeBottom = containerBoundsBottom - triggerBounds.bottom - (containerY || 0);
45
44
  switch (position) {
46
45
  case "start":
47
46
  case "start-top":
48
47
  case "start-bottom":
49
- right = relativeRight + triggerWidth;
50
48
  left = relativeLeft - flyoutWidth;
49
+ right = relativeRight + triggerWidth;
51
50
  break;
52
51
  case "end":
53
52
  case "end-top":
@@ -64,8 +63,8 @@ const calculatePosition = (args) => {
64
63
  break;
65
64
  case "top-end":
66
65
  case "bottom-end":
67
- right = relativeRight - contentShift;
68
66
  left = relativeLeft + triggerWidth - flyoutWidth + contentShift;
67
+ right = relativeRight - contentShift;
69
68
  break;
70
69
  default:
71
70
  break;
@@ -74,8 +73,8 @@ const calculatePosition = (args) => {
74
73
  case "top":
75
74
  case "top-start":
76
75
  case "top-end":
77
- bottom = relativeBottom + triggerHeight;
78
76
  top = relativeTop - flyoutHeight;
77
+ bottom = relativeBottom + triggerHeight;
79
78
  break;
80
79
  case "bottom":
81
80
  case "bottom-start":
@@ -92,37 +91,87 @@ const calculatePosition = (args) => {
92
91
  break;
93
92
  case "start-bottom":
94
93
  case "end-bottom":
95
- bottom = relativeBottom - contentShift;
96
94
  top = relativeTop + triggerHeight - flyoutHeight + contentShift;
95
+ bottom = relativeBottom - contentShift;
97
96
  break;
98
97
  default:
99
98
  break;
100
99
  }
101
- let widthStyle;
100
+ if (fallbackAdjustLayout) {
101
+ const getOverflow = () => {
102
+ return {
103
+ top: -top + scrollY + SCREEN_OFFSET,
104
+ bottom: top + flyoutHeight + SCREEN_OFFSET - scrollY - renderContainerHeight,
105
+ left: -left + scrollX + SCREEN_OFFSET,
106
+ right: left + flyoutWidth + SCREEN_OFFSET - scrollX - renderContainerWidth,
107
+ };
108
+ };
109
+ const overflow = getOverflow();
110
+ if (isHorizontalPosition) {
111
+ if (overflow.top > 0) {
112
+ top = SCREEN_OFFSET + scrollY;
113
+ if (bottom !== null)
114
+ bottom = bottom - overflow.top;
115
+ }
116
+ else if (overflow.bottom > 0) {
117
+ top = top - overflow.bottom;
118
+ }
119
+ }
120
+ else {
121
+ if (overflow.left > 0) {
122
+ left = SCREEN_OFFSET + scrollX;
123
+ if (right !== null)
124
+ right = right - overflow.left;
125
+ }
126
+ else if (overflow.right > 0) {
127
+ left = left - overflow.right;
128
+ }
129
+ }
130
+ const updatedOverflow = getOverflow();
131
+ if (updatedOverflow.top > 0) {
132
+ height = Math.max(fallbackMinHeight ? parseInt(fallbackMinHeight) : 0, flyoutHeight - updatedOverflow.top);
133
+ top = top + (flyoutHeight - height);
134
+ }
135
+ else if (updatedOverflow.bottom > 0) {
136
+ height = Math.max(fallbackMinHeight ? parseInt(fallbackMinHeight) : 0, flyoutHeight - updatedOverflow.bottom);
137
+ if (bottom !== null)
138
+ bottom = bottom + (flyoutHeight - height);
139
+ }
140
+ if (updatedOverflow.left > 0) {
141
+ width = Math.max(fallbackMinWidth ? parseInt(fallbackMinWidth) : 0, flyoutWidth - updatedOverflow.left);
142
+ left = left + (flyoutWidth - width);
143
+ }
144
+ else if (updatedOverflow.right > 0) {
145
+ width = Math.max(fallbackMinWidth ? parseInt(fallbackMinWidth) : 0, flyoutWidth - updatedOverflow.right);
146
+ if (right !== null)
147
+ right = right + (flyoutWidth - width);
148
+ }
149
+ }
102
150
  if (isFullWidth) {
103
151
  left = SCREEN_OFFSET;
104
- widthStyle = window.innerWidth - SCREEN_OFFSET * 2;
152
+ width = window.innerWidth - SCREEN_OFFSET * 2;
105
153
  }
106
- else if (width === "trigger") {
107
- widthStyle = triggerBounds.width;
154
+ else if (passedWidth === "trigger") {
155
+ width = triggerBounds.width;
108
156
  }
109
157
  const translateX = right !== null ? -right : left;
110
158
  const translateY = bottom !== null ? -bottom : top;
111
159
  return {
112
160
  position,
113
161
  styles: {
114
- width: widthStyle ?? width,
115
162
  left: right === null ? 0 : undefined,
116
163
  right: right === null ? undefined : 0,
117
164
  top: bottom === null ? 0 : undefined,
118
165
  bottom: bottom === null ? undefined : 0,
119
166
  transform: `translate(${translateX}px, ${translateY}px)`,
167
+ height,
168
+ width: width ?? passedWidth,
120
169
  },
121
170
  boundaries: {
122
171
  left,
123
172
  top,
124
- height: Math.ceil(flyoutHeight),
125
- width: widthStyle ?? Math.ceil(flyoutWidth),
173
+ height: height ?? Math.ceil(flyoutHeight),
174
+ width: width ?? Math.ceil(flyoutWidth),
126
175
  },
127
176
  };
128
177
  };
@@ -7,7 +7,7 @@ import { resetStyles } from "../Flyout.constants.js";
7
7
  * Set position of the target element to fit on the screen
8
8
  */
9
9
  const flyout = (args) => {
10
- const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, position, fallbackPositions, width, container: passedContainer, lastUsedPosition, onPositionChoose, rtl, } = args;
10
+ const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, position, fallbackPositions, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, width, container: passedContainer, lastUsedPosition, onPositionChoose, rtl, } = args;
11
11
  const targetClone = flyoutEl.cloneNode(true);
12
12
  const baseUnit = getComputedStyle(flyoutEl).getPropertyValue("--rs-unit-x1");
13
13
  const unitModifier = baseUnit ? parseInt(baseUnit) : 4;
@@ -42,37 +42,42 @@ const flyout = (args) => {
42
42
  document.body;
43
43
  const renderContainerBounds = container.getBoundingClientRect();
44
44
  const visualContainerBounds = (passedContainer || document.body).getBoundingClientRect();
45
- let calculated = null;
46
- const testOrder = getPositionFallbacks(position, fallbackPositions);
47
- testOrder.some((currentPosition) => {
48
- const tested = calculatePosition({
45
+ const applyPosition = (position) => {
46
+ return calculatePosition({
49
47
  triggerBounds: resolvedTriggerBounds,
50
48
  flyoutBounds,
51
49
  containerBounds: renderContainerBounds,
52
- position: currentPosition,
50
+ position,
53
51
  contentGap: contentGap * unitModifier,
54
52
  contentShift: contentShift * unitModifier,
55
53
  rtl,
56
54
  width,
57
- passedContainer,
55
+ passedContainer: passedContainer ||
56
+ (closestFixedContainer !== document.body ? closestFixedContainer : undefined),
57
+ fallbackAdjustLayout,
58
+ fallbackMinWidth,
59
+ fallbackMinHeight,
58
60
  });
59
- const visible = isFullyVisible({
60
- flyoutBounds: tested.boundaries,
61
+ };
62
+ const testVisibility = (calculated) => {
63
+ return isFullyVisible({
64
+ flyoutBounds: calculated.boundaries,
61
65
  visualContainerBounds,
62
66
  renderContainerBounds,
63
- container,
64
67
  });
65
- const validPosition = visible || fallbackPositions?.length === 0;
66
- // Saving first try in case none of the options work
67
- if (validPosition || lastUsedPosition === currentPosition) {
68
+ };
69
+ let calculated = null;
70
+ const testOrder = getPositionFallbacks(position, fallbackPositions);
71
+ testOrder.some((currentPosition) => {
72
+ const tested = applyPosition(currentPosition);
73
+ const visible = testVisibility(tested);
74
+ if (visible)
68
75
  calculated = tested;
69
- onPositionChoose(currentPosition);
70
- }
71
- return validPosition;
76
+ return visible;
72
77
  });
73
- if (!calculated) {
74
- throw new Error(`[Reshaped] Can't calculate styles for the ${position} position`);
75
- }
78
+ if (!calculated)
79
+ calculated = applyPosition(lastUsedPosition);
80
+ onPositionChoose(calculated.position);
76
81
  targetClone.parentNode?.removeChild(targetClone);
77
82
  return calculated;
78
83
  };
@@ -14,7 +14,7 @@ const fallbackOrder = {
14
14
  };
15
15
  // Get an order of positions to try to fit flyout on the screen based on its starting position
16
16
  const getPositionFallbacks = (position, availableFallbacks) => {
17
- const result = [position];
17
+ const result = new Set([position]);
18
18
  const chunks = position.split("-");
19
19
  const [firstChunk] = chunks;
20
20
  const passedPositionOrder = positions[firstChunk];
@@ -31,9 +31,9 @@ const getPositionFallbacks = (position, availableFallbacks) => {
31
31
  const position = fallbackOrder[index];
32
32
  if (availableFallbacks?.indexOf(position) === -1)
33
33
  return;
34
- result.push(position);
34
+ result.add(position);
35
35
  });
36
36
  });
37
- return result;
37
+ return Array.from(result);
38
38
  };
39
39
  export default getPositionFallbacks;
@@ -0,0 +1,7 @@
1
+ import type * as T from "../Flyout.types";
2
+ /** Mirror the position for RTL */
3
+ export declare const getRTLPosition: (position: T.Position) => T.Position;
4
+ /**
5
+ * Get a position value which centers 2 elements vertically or horizontally
6
+ */
7
+ export declare const centerBySize: (originSize: number, targetSize: number) => number;
@@ -0,0 +1,14 @@
1
+ /** Mirror the position for RTL */
2
+ export const getRTLPosition = (position) => {
3
+ if (position.includes("start"))
4
+ return position.replace("start", "end");
5
+ if (position.includes("end"))
6
+ return position.replace("end", "start");
7
+ return position;
8
+ };
9
+ /**
10
+ * Get a position value which centers 2 elements vertically or horizontally
11
+ */
12
+ export const centerBySize = (originSize, targetSize) => {
13
+ return Math.floor(originSize / 2 - targetSize / 2);
14
+ };
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Check if element visually fits on the screen
2
+ * Check if element visually fits within its render container
3
3
  */
4
4
  declare const isFullyVisible: (args: {
5
+ /** Bounds of the flyout content */
5
6
  flyoutBounds: Pick<DOMRect, "left" | "top" | "width" | "height">;
7
+ /** Bounds of the container where the flyout content should fit */
6
8
  visualContainerBounds: DOMRect;
9
+ /** Bounds of the container where flyout content is rendered */
7
10
  renderContainerBounds: DOMRect;
8
- container: HTMLElement;
9
11
  }) => boolean;
10
12
  export default isFullyVisible;
@@ -1,21 +1,19 @@
1
1
  /**
2
- * Check if element visually fits on the screen
2
+ * Check if element visually fits within its render container
3
3
  */
4
4
  const isFullyVisible = (args) => {
5
- const { flyoutBounds, visualContainerBounds, renderContainerBounds, container } = args;
6
- const scrollX = container === document.body ? window.scrollX : container.scrollLeft;
7
- const scrollY = container === document.body ? window.scrollY : container.scrollTop;
8
- if (renderContainerBounds.left + flyoutBounds.left - scrollX < visualContainerBounds.left) {
5
+ const { flyoutBounds, visualContainerBounds, renderContainerBounds } = args;
6
+ if (renderContainerBounds.left + flyoutBounds.left < visualContainerBounds.left) {
9
7
  return false;
10
8
  }
11
- if (renderContainerBounds.top + flyoutBounds.top - scrollY < visualContainerBounds.top) {
9
+ if (renderContainerBounds.top + flyoutBounds.top < visualContainerBounds.top) {
12
10
  return false;
13
11
  }
14
- if (renderContainerBounds.left + flyoutBounds.left + flyoutBounds.width - scrollX >
12
+ if (renderContainerBounds.left + flyoutBounds.left + flyoutBounds.width >
15
13
  visualContainerBounds.right) {
16
14
  return false;
17
15
  }
18
- if (renderContainerBounds.top + flyoutBounds.top + flyoutBounds.height - scrollY >
16
+ if (renderContainerBounds.top + flyoutBounds.top + flyoutBounds.height >
19
17
  visualContainerBounds.bottom) {
20
18
  return false;
21
19
  }
@@ -51,7 +51,7 @@ export declare const useFormControl: () => {
51
51
  results?: number | undefined | undefined;
52
52
  security?: string | undefined | undefined;
53
53
  unselectable?: "on" | "off" | undefined | undefined;
54
- popover?: "" | "auto" | "manual" | undefined | undefined;
54
+ popover?: "" | "auto" | "manual" | "hint" | undefined | undefined;
55
55
  popoverTargetAction?: "toggle" | "show" | "hide" | undefined | undefined;
56
56
  popoverTarget?: string | undefined | undefined;
57
57
  inert?: boolean | undefined | undefined;
@@ -27,3 +27,5 @@ export declare const composition: {
27
27
  name: string;
28
28
  render: () => import("react").JSX.Element;
29
29
  };
30
+ export declare const className: StoryObj;
31
+ export declare const group: StoryObj;
@@ -3,6 +3,8 @@ import { Example } from "../../../utilities/storybook/index.js";
3
3
  import FormControl from "../index.js";
4
4
  import TextField from "../../TextField/index.js";
5
5
  import View from "../../View/index.js";
6
+ import RadioGroup from "../../RadioGroup/index.js";
7
+ import Radio from "../../Radio/index.js";
6
8
  export default {
7
9
  title: "Utility components/FormControl",
8
10
  component: FormControl,
@@ -106,3 +108,36 @@ export const composition = {
106
108
  </Example.Item>
107
109
  </Example>),
108
110
  };
111
+ export const className = {
112
+ name: "className, attributes",
113
+ render: () => (<FormControl id="test-id" hasError>
114
+ <FormControl.Label>Label</FormControl.Label>
115
+ <TextField name="name"/>
116
+ <FormControl.Helper>Caption</FormControl.Helper>
117
+ <FormControl.Error>Error</FormControl.Error>
118
+ </FormControl>),
119
+ play: async ({ canvas }) => {
120
+ const input = canvas.getByRole("textbox");
121
+ const label = canvas.getByText("Label");
122
+ expect(input).toHaveAttribute("id", "test-id");
123
+ expect(input).toHaveAttribute("aria-describedby", `test-id-caption test-id-error`);
124
+ expect(label).toHaveAttribute("for", "test-id");
125
+ expect(label).toHaveAttribute("id", `test-id-label`);
126
+ },
127
+ };
128
+ export const group = {
129
+ name: "group",
130
+ render: () => (<FormControl group>
131
+ <FormControl.Label>Label</FormControl.Label>
132
+ <RadioGroup name="name">
133
+ <View gap={2}>
134
+ <Radio value="1">One</Radio>
135
+ <Radio value="2">Two</Radio>
136
+ </View>
137
+ </RadioGroup>
138
+ </FormControl>),
139
+ play: async ({ canvas }) => {
140
+ const group = canvas.getByRole("group");
141
+ expect(group).toBeInTheDocument();
142
+ },
143
+ };