@spaced-out/ui-design-system 0.3.49 → 0.3.51-beta.0

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 (52) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/AvatarGroup/AvatarGroup.js.flow +2 -2
  3. package/lib/components/ButtonDropdown/ButtonDropdown.js +22 -10
  4. package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +58 -33
  5. package/lib/components/ButtonDropdown/ButtonDropdown.module.css +8 -1
  6. package/lib/components/ButtonDropdown/SimpleButtonDropdown.js +3 -0
  7. package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +6 -1
  8. package/lib/components/ButtonTabs/ButtonTabDropdown.js +13 -6
  9. package/lib/components/ButtonTabs/ButtonTabDropdown.js.flow +40 -24
  10. package/lib/components/ButtonTabs/ButtonTabDropdown.module.css +4 -0
  11. package/lib/components/ButtonTabs/ButtonTabs.js +2 -0
  12. package/lib/components/ButtonTabs/ButtonTabs.js.flow +4 -0
  13. package/lib/components/Dropdown/Dropdown.js +23 -8
  14. package/lib/components/Dropdown/Dropdown.js.flow +57 -32
  15. package/lib/components/Dropdown/Dropdown.module.css +5 -0
  16. package/lib/components/Dropdown/SimpleDropdown.js +2 -0
  17. package/lib/components/Dropdown/SimpleDropdown.js.flow +4 -0
  18. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js +23 -8
  19. package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js.flow +56 -26
  20. package/lib/components/InlineDropdown/InlineDropdown.js +25 -8
  21. package/lib/components/InlineDropdown/InlineDropdown.js.flow +57 -30
  22. package/lib/components/InlineDropdown/InlineDropdown.module.css +5 -0
  23. package/lib/components/InlineDropdown/SimpleInlineDropdown.js +2 -0
  24. package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +4 -0
  25. package/lib/components/Table/StaticTable.js +1 -1
  26. package/lib/components/Table/StaticTable.js.flow +1 -1
  27. package/lib/components/Table/Table.docs.js +1 -1
  28. package/lib/components/Table/Table.docs.js.flow +1 -1
  29. package/lib/components/Tabs/TabList/TabDropdown.js +14 -7
  30. package/lib/components/Tabs/TabList/TabDropdown.js.flow +38 -22
  31. package/lib/components/Tabs/TabList/TabDropdown.module.css +4 -0
  32. package/lib/components/Tabs/TabList/TabList.js +4 -2
  33. package/lib/components/Tabs/TabList/TabList.js.flow +4 -0
  34. package/lib/components/TokenListInput/TokenListInput.js +26 -7
  35. package/lib/components/TokenListInput/TokenListInput.js.flow +58 -32
  36. package/lib/components/TokenListInput/TokenListInput.module.css +5 -0
  37. package/lib/components/Tooltip/Tooltip.js +2 -1
  38. package/lib/components/Tooltip/Tooltip.js.flow +2 -2
  39. package/lib/components/Typeahead/SimpleTypeahead.js +3 -1
  40. package/lib/components/Typeahead/SimpleTypeahead.js.flow +4 -0
  41. package/lib/components/Typeahead/Typeahead.js +25 -8
  42. package/lib/components/Typeahead/Typeahead.js.flow +58 -30
  43. package/lib/components/Typeahead/Typeahead.module.css +5 -0
  44. package/lib/hooks/index.js +11 -0
  45. package/lib/hooks/index.js.flow +1 -0
  46. package/lib/hooks/useReferenceElementWidth/index.js +16 -0
  47. package/lib/hooks/useReferenceElementWidth/index.js.flow +3 -0
  48. package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js +21 -0
  49. package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js.flow +23 -0
  50. package/lib/utils/click-away/click-away.js +4 -0
  51. package/lib/utils/click-away/click-away.js.flow +34 -0
  52. package/package.json +5 -5
@@ -36,6 +36,28 @@ export type ClickAwayProps = {
36
36
  children: (props: ChildProps) => React.Node,
37
37
  onChange?: (isOpen: boolean) => mixed,
38
38
  clickAwayRef?: ClickAwayRefType,
39
+ /**
40
+ * When containsNestedFloatingPortals is true, prevents ClickAway from closing the dropdown if the click target
41
+ * is inside a floating portal root element.
42
+ *
43
+ * This is necessary for nested dropdowns rendered using floating portals,
44
+ * such as via `@floating-ui/react`. Floating portals render elements outside
45
+ * the normal DOM tree (often directly into `document.body` or another container)
46
+ * using `ReactDOM.createPortal`. As a result, these nested dropdowns do not
47
+ * appear inside the parent dropdown's `boundaryRef` or `triggerRef` subtree.
48
+ *
49
+ * To address this, the floating portal ensures that all nested dropdowns
50
+ * are mounted into a **shared root element** — effectively maintaining a
51
+ * common DOM ancestry. This allows parent dropdowns to detect when clicks
52
+ * occur within any of their nested children, even if rendered via portals.
53
+ * The shared root element is the closest parent element that has a `data-floating-ui-portal` attribute.
54
+ * Because of this, the ClickAway logic will not close the parent menu if the click target is inside boundaryRef's parentElement.
55
+ *
56
+ * Enabling `containsNestedFloatingPortals` allows the ClickAway logic to account
57
+ * for this shared root and avoids incorrectly closing the parent menu when
58
+ * interacting with nested dropdowns.
59
+ */
60
+ containsNestedFloatingPortals?: boolean,
39
61
  };
40
62
 
41
63
  type ClickAwayState = {
@@ -48,8 +70,10 @@ type ClickAwayState = {
48
70
 
49
71
  export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
50
72
  static defaultProps: {
73
+ containsNestedFloatingPortals?: boolean,
51
74
  closeOnEscapeKeypress?: boolean,
52
75
  } = {
76
+ containsNestedFloatingPortals: false,
53
77
  closeOnEscapeKeypress: true,
54
78
  };
55
79
 
@@ -145,6 +169,16 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
145
169
  };
146
170
 
147
171
  handleCloseClick: (evt: MouseEvent) => void = (evt: MouseEvent) => {
172
+ if (
173
+ evt.target instanceof Node &&
174
+ this.props.containsNestedFloatingPortals &&
175
+ this.boundaryRef.current?.parentElement &&
176
+ (this.boundaryRef.current.parentElement === evt.target ||
177
+ this.boundaryRef.current.parentElement.contains(evt.target))
178
+ ) {
179
+ return;
180
+ }
181
+
148
182
  if (
149
183
  evt.target instanceof Node &&
150
184
  this.boundaryRef &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.3.49",
3
+ "version": "0.3.51-beta.0",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {
@@ -40,8 +40,8 @@
40
40
  "Sense"
41
41
  ],
42
42
  "peerDependencies": {
43
- "react": ">=16.8.0",
44
- "react-dom": ">=16.8.0"
43
+ "react": ">=19.1.0",
44
+ "react-dom": ">=19.1.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@floating-ui/react": "^0.24.0",
@@ -99,8 +99,8 @@
99
99
  "lint-staged": "^10.5.1",
100
100
  "paths.macro": "^3.0.1",
101
101
  "prettier": "^2.5.1",
102
- "react": "17.0.2",
103
- "react-dom": "17.0.2",
102
+ "react": "^19.1.0",
103
+ "react-dom": "^19.1.0",
104
104
  "rimraf": "^3.0.2",
105
105
  "simple-git": "^3.12.0",
106
106
  "standard-version": "^9.5.0",