@blueshift-gg/ui-components 0.1.7 → 0.1.9

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 (198) hide show
  1. package/dist/Alert.d.mts +1 -1
  2. package/dist/Alert.d.ts +1 -1
  3. package/dist/Avatar.d.mts +5 -5
  4. package/dist/Avatar.d.ts +5 -5
  5. package/dist/Avatar.js +18 -12
  6. package/dist/Avatar.js.map +1 -1
  7. package/dist/Avatar.mjs +18 -12
  8. package/dist/Avatar.mjs.map +1 -1
  9. package/dist/Badge.d.mts +1 -1
  10. package/dist/Badge.d.ts +1 -1
  11. package/dist/Button.d.mts +4 -2
  12. package/dist/Button.d.ts +4 -2
  13. package/dist/Button.js +9 -3
  14. package/dist/Button.js.map +1 -1
  15. package/dist/Button.mjs +9 -3
  16. package/dist/Button.mjs.map +1 -1
  17. package/dist/DecryptText.js +0 -18
  18. package/dist/DecryptText.js.map +1 -1
  19. package/dist/DecryptText.mjs +0 -18
  20. package/dist/DecryptText.mjs.map +1 -1
  21. package/dist/Dropdown.d.mts +18 -17
  22. package/dist/Dropdown.d.ts +18 -17
  23. package/dist/Dropdown.js +246 -31
  24. package/dist/Dropdown.js.map +1 -1
  25. package/dist/Dropdown.mjs +246 -31
  26. package/dist/Dropdown.mjs.map +1 -1
  27. package/dist/{Icon-CTxwWbdC.d.mts → Icon-BlNfHVtM.d.mts} +3 -0
  28. package/dist/{Icon-llWd6yMa.d.ts → Icon-CyRhTGIG.d.ts} +3 -0
  29. package/dist/Icon.d.mts +1 -1
  30. package/dist/Icon.d.ts +1 -1
  31. package/dist/Input.d.mts +1 -1
  32. package/dist/Input.d.ts +1 -1
  33. package/dist/Pagination.js +1 -0
  34. package/dist/Pagination.js.map +1 -1
  35. package/dist/Pagination.mjs +1 -0
  36. package/dist/Pagination.mjs.map +1 -1
  37. package/dist/Slider.d.mts +1 -1
  38. package/dist/Slider.d.ts +1 -1
  39. package/dist/Tabs.d.mts +1 -1
  40. package/dist/Tabs.d.ts +1 -1
  41. package/dist/Toast.d.mts +1 -1
  42. package/dist/Toast.d.ts +1 -1
  43. package/dist/icons/Anchor.d.mts +1 -1
  44. package/dist/icons/Anchor.d.ts +1 -1
  45. package/dist/icons/ArrowLeft.d.mts +1 -1
  46. package/dist/icons/ArrowLeft.d.ts +1 -1
  47. package/dist/icons/ArrowRight.d.mts +1 -1
  48. package/dist/icons/ArrowRight.d.ts +1 -1
  49. package/dist/icons/Assembly.d.mts +1 -1
  50. package/dist/icons/Assembly.d.ts +1 -1
  51. package/dist/icons/Brave.d.mts +7 -0
  52. package/dist/icons/Brave.d.ts +7 -0
  53. package/dist/icons/Brave.js +60 -0
  54. package/dist/icons/Brave.js.map +1 -0
  55. package/dist/icons/Brave.mjs +58 -0
  56. package/dist/icons/Brave.mjs.map +1 -0
  57. package/dist/icons/Challenge.d.mts +1 -1
  58. package/dist/icons/Challenge.d.ts +1 -1
  59. package/dist/icons/Chevron.d.mts +1 -1
  60. package/dist/icons/Chevron.d.ts +1 -1
  61. package/dist/icons/ChevronLeft.d.mts +1 -1
  62. package/dist/icons/ChevronLeft.d.ts +1 -1
  63. package/dist/icons/ChevronRight.d.mts +1 -1
  64. package/dist/icons/ChevronRight.d.ts +1 -1
  65. package/dist/icons/Claim.d.mts +1 -1
  66. package/dist/icons/Claim.d.ts +1 -1
  67. package/dist/icons/Claimed.d.mts +1 -1
  68. package/dist/icons/Claimed.d.ts +1 -1
  69. package/dist/icons/Close.d.mts +1 -1
  70. package/dist/icons/Close.d.ts +1 -1
  71. package/dist/icons/Code.d.mts +1 -1
  72. package/dist/icons/Code.d.ts +1 -1
  73. package/dist/icons/Copy.d.mts +1 -1
  74. package/dist/icons/Copy.d.ts +1 -1
  75. package/dist/icons/Developer.d.mts +1 -1
  76. package/dist/icons/Developer.d.ts +1 -1
  77. package/dist/icons/Difficulty.d.mts +1 -1
  78. package/dist/icons/Difficulty.d.ts +1 -1
  79. package/dist/icons/Discord.d.mts +1 -1
  80. package/dist/icons/Discord.d.ts +1 -1
  81. package/dist/icons/Dollar.d.mts +1 -1
  82. package/dist/icons/Dollar.d.ts +1 -1
  83. package/dist/icons/DoubleArrow.d.mts +1 -1
  84. package/dist/icons/DoubleArrow.d.ts +1 -1
  85. package/dist/icons/EVM.d.mts +1 -1
  86. package/dist/icons/EVM.d.ts +1 -1
  87. package/dist/icons/Email.d.mts +1 -1
  88. package/dist/icons/Email.d.ts +1 -1
  89. package/dist/icons/Error.d.mts +1 -1
  90. package/dist/icons/Error.d.ts +1 -1
  91. package/dist/icons/External.d.mts +1 -1
  92. package/dist/icons/External.d.ts +1 -1
  93. package/dist/icons/Filter.d.mts +1 -1
  94. package/dist/icons/Filter.d.ts +1 -1
  95. package/dist/icons/Firmware.d.mts +1 -1
  96. package/dist/icons/Firmware.d.ts +1 -1
  97. package/dist/icons/Flag.d.mts +1 -1
  98. package/dist/icons/Flag.d.ts +1 -1
  99. package/dist/icons/Flame.d.mts +1 -1
  100. package/dist/icons/Flame.d.ts +1 -1
  101. package/dist/icons/Flexible.d.mts +1 -1
  102. package/dist/icons/Flexible.d.ts +1 -1
  103. package/dist/icons/Free.d.mts +1 -1
  104. package/dist/icons/Free.d.ts +1 -1
  105. package/dist/icons/General.d.mts +1 -1
  106. package/dist/icons/General.d.ts +1 -1
  107. package/dist/icons/Github.d.mts +1 -1
  108. package/dist/icons/Github.d.ts +1 -1
  109. package/dist/icons/GridView.d.mts +1 -1
  110. package/dist/icons/GridView.d.ts +1 -1
  111. package/dist/icons/Heart.d.mts +1 -1
  112. package/dist/icons/Heart.d.ts +1 -1
  113. package/dist/icons/Info.d.mts +1 -1
  114. package/dist/icons/Info.d.ts +1 -1
  115. package/dist/icons/Language.d.mts +1 -1
  116. package/dist/icons/Language.d.ts +1 -1
  117. package/dist/icons/Lessons.d.mts +1 -1
  118. package/dist/icons/Lessons.d.ts +1 -1
  119. package/dist/icons/Link.d.mts +1 -1
  120. package/dist/icons/Link.d.ts +1 -1
  121. package/dist/icons/ListView.d.mts +1 -1
  122. package/dist/icons/ListView.d.ts +1 -1
  123. package/dist/icons/Loading.d.mts +1 -1
  124. package/dist/icons/Loading.d.ts +1 -1
  125. package/dist/icons/Locked.d.mts +1 -1
  126. package/dist/icons/Locked.d.ts +1 -1
  127. package/dist/icons/Mentor.d.mts +1 -1
  128. package/dist/icons/Mentor.d.ts +1 -1
  129. package/dist/icons/Modular.d.mts +1 -1
  130. package/dist/icons/Modular.d.ts +1 -1
  131. package/dist/icons/NFT.d.mts +1 -1
  132. package/dist/icons/NFT.d.ts +1 -1
  133. package/dist/icons/Online.d.mts +1 -1
  134. package/dist/icons/Online.d.ts +1 -1
  135. package/dist/icons/Password.d.mts +1 -1
  136. package/dist/icons/Password.d.ts +1 -1
  137. package/dist/icons/Phantom.d.mts +7 -0
  138. package/dist/icons/Phantom.d.ts +7 -0
  139. package/dist/icons/Phantom.js +28 -0
  140. package/dist/icons/Phantom.js.map +1 -0
  141. package/dist/icons/Phantom.mjs +26 -0
  142. package/dist/icons/Phantom.mjs.map +1 -0
  143. package/dist/icons/Product.d.mts +1 -1
  144. package/dist/icons/Product.d.ts +1 -1
  145. package/dist/icons/Progress.d.mts +1 -1
  146. package/dist/icons/Progress.d.ts +1 -1
  147. package/dist/icons/Protocol.d.mts +1 -1
  148. package/dist/icons/Protocol.d.ts +1 -1
  149. package/dist/icons/Rewards.d.mts +1 -1
  150. package/dist/icons/Rewards.d.ts +1 -1
  151. package/dist/icons/Rust.d.mts +1 -1
  152. package/dist/icons/Rust.d.ts +1 -1
  153. package/dist/icons/Search.d.mts +1 -1
  154. package/dist/icons/Search.d.ts +1 -1
  155. package/dist/icons/SmartContract.d.mts +1 -1
  156. package/dist/icons/SmartContract.d.ts +1 -1
  157. package/dist/icons/Solana.d.mts +1 -1
  158. package/dist/icons/Solana.d.ts +1 -1
  159. package/dist/icons/Solflare.d.mts +7 -0
  160. package/dist/icons/Solflare.d.ts +7 -0
  161. package/dist/icons/Solflare.js +28 -0
  162. package/dist/icons/Solflare.js.map +1 -0
  163. package/dist/icons/Solflare.mjs +26 -0
  164. package/dist/icons/Solflare.mjs.map +1 -0
  165. package/dist/icons/Success.d.mts +1 -1
  166. package/dist/icons/Success.d.ts +1 -1
  167. package/dist/icons/SuccessCircle.d.mts +1 -1
  168. package/dist/icons/SuccessCircle.d.ts +1 -1
  169. package/dist/icons/Table.d.mts +1 -1
  170. package/dist/icons/Table.d.ts +1 -1
  171. package/dist/icons/Target.d.mts +1 -1
  172. package/dist/icons/Target.d.ts +1 -1
  173. package/dist/icons/Training.d.mts +1 -1
  174. package/dist/icons/Training.d.ts +1 -1
  175. package/dist/icons/Typescript.d.mts +1 -1
  176. package/dist/icons/Typescript.d.ts +1 -1
  177. package/dist/icons/Unclaimed.d.mts +1 -1
  178. package/dist/icons/Unclaimed.d.ts +1 -1
  179. package/dist/icons/Upload.d.mts +1 -1
  180. package/dist/icons/Upload.d.ts +1 -1
  181. package/dist/icons/Wallet.d.mts +1 -1
  182. package/dist/icons/Wallet.d.ts +1 -1
  183. package/dist/icons/WalletSmall.d.mts +1 -1
  184. package/dist/icons/WalletSmall.d.ts +1 -1
  185. package/dist/icons/Warning.d.mts +1 -1
  186. package/dist/icons/Warning.d.ts +1 -1
  187. package/dist/icons/X.d.mts +1 -1
  188. package/dist/icons/X.d.ts +1 -1
  189. package/dist/icons/index.d.mts +1 -1
  190. package/dist/icons/index.d.ts +1 -1
  191. package/dist/icons/index.js +7 -1
  192. package/dist/icons/index.js.map +1 -1
  193. package/dist/icons/index.mjs +7 -1
  194. package/dist/icons/index.mjs.map +1 -1
  195. package/dist/index.d.mts +1 -1
  196. package/dist/index.d.ts +1 -1
  197. package/package.json +10 -11
  198. package/src/theme.css +10 -0
@@ -1,15 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as IconProps } from './Icon-CTxwWbdC.mjs';
2
+ import { a as IconProps } from './Icon-BlNfHVtM.mjs';
3
3
  import './utils/colours.mjs';
4
4
 
5
+ type DropdownOption = {
6
+ label: string;
7
+ icon?: IconProps;
8
+ value: string;
9
+ disabled?: boolean;
10
+ children?: DropdownOption[];
11
+ };
5
12
  type DropdownProps = {
6
13
  className?: string;
7
- items: {
8
- label: string;
9
- icon?: IconProps;
10
- value: string;
11
- disabled?: boolean;
12
- }[];
14
+ items: DropdownOption[];
13
15
  selectedItem?: string | string[] | undefined;
14
16
  handleChange: (item: string | string[] | undefined) => void;
15
17
  multiple?: boolean;
@@ -24,6 +26,7 @@ type DropdownProps = {
24
26
  animationOrigin?: "top-left" | "top-center" | "top-right";
25
27
  search?: string;
26
28
  onClearSearch?: () => void;
29
+ showSelectAll?: boolean;
27
30
  };
28
31
  type DropdownButtonProps = {
29
32
  label: string;
@@ -37,6 +40,7 @@ type DropdownButtonProps = {
37
40
  count?: number;
38
41
  menuIcon?: IconProps;
39
42
  size?: "sm" | "md" | "lg";
43
+ onClear?: () => void;
40
44
  };
41
45
  type DropdownItemProps = {
42
46
  label: string;
@@ -47,12 +51,7 @@ type DropdownItemProps = {
47
51
  size?: "sm" | "md" | "lg";
48
52
  };
49
53
  type DropdownMenuProps = {
50
- items: {
51
- label: string;
52
- icon?: IconProps;
53
- value: string;
54
- disabled?: boolean;
55
- }[];
54
+ items: DropdownOption[];
56
55
  selectedItem?: string | string[] | undefined;
57
56
  handleChange: (item: string | string[] | undefined) => void;
58
57
  multiple?: boolean;
@@ -64,10 +63,12 @@ type DropdownMenuProps = {
64
63
  animationOrigin?: "top-left" | "top-center" | "top-right";
65
64
  search?: string;
66
65
  onClearSearch?: () => void;
66
+ showSelectAll?: boolean;
67
+ showSafeTriangle?: boolean;
67
68
  };
68
- declare const DropdownMenu: ({ items, selectedItem, handleChange, multiple, menuClassName, size, isOpen, onItemClick, isScrollable, animationOrigin, search, onClearSearch, }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
69
- declare const Dropdown: ({ className, items, selectedItem, handleChange, label, multiSelectLabel, disabled, buttonClassName, menuClassName, multiple, menuIcon, size, isScrollable, search, onClearSearch, }: DropdownProps) => react_jsx_runtime.JSX.Element;
70
- declare const DropdownButton: ({ label, multiSelectLabel, disabled, className, onClick, selectedItems, multiple, count, menuIcon, size, }: DropdownButtonProps) => react_jsx_runtime.JSX.Element;
69
+ declare const DropdownMenu: ({ items, selectedItem, handleChange, multiple, menuClassName, size, isOpen, onItemClick, isScrollable, animationOrigin, search, onClearSearch, showSelectAll, showSafeTriangle, }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
70
+ declare const Dropdown: ({ className, items, selectedItem, handleChange, label, multiSelectLabel, disabled, buttonClassName, menuClassName, multiple, menuIcon, size, isScrollable, search, onClearSearch, showSelectAll, }: DropdownProps) => react_jsx_runtime.JSX.Element;
71
+ declare const DropdownButton: ({ label, multiSelectLabel, disabled, className, onClick, selectedItems, multiple, count, menuIcon, size, onClear, }: DropdownButtonProps) => react_jsx_runtime.JSX.Element;
71
72
  declare const DropdownItem: ({ label, icon, onClick, disabled, isSelected, size, }: DropdownItemProps) => react_jsx_runtime.JSX.Element;
72
73
 
73
- export { Dropdown, DropdownButton, type DropdownButtonProps, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownProps };
74
+ export { Dropdown, DropdownButton, type DropdownButtonProps, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownOption, type DropdownProps };
@@ -1,15 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as IconProps } from './Icon-llWd6yMa.js';
2
+ import { a as IconProps } from './Icon-CyRhTGIG.js';
3
3
  import './utils/colours.js';
4
4
 
5
+ type DropdownOption = {
6
+ label: string;
7
+ icon?: IconProps;
8
+ value: string;
9
+ disabled?: boolean;
10
+ children?: DropdownOption[];
11
+ };
5
12
  type DropdownProps = {
6
13
  className?: string;
7
- items: {
8
- label: string;
9
- icon?: IconProps;
10
- value: string;
11
- disabled?: boolean;
12
- }[];
14
+ items: DropdownOption[];
13
15
  selectedItem?: string | string[] | undefined;
14
16
  handleChange: (item: string | string[] | undefined) => void;
15
17
  multiple?: boolean;
@@ -24,6 +26,7 @@ type DropdownProps = {
24
26
  animationOrigin?: "top-left" | "top-center" | "top-right";
25
27
  search?: string;
26
28
  onClearSearch?: () => void;
29
+ showSelectAll?: boolean;
27
30
  };
28
31
  type DropdownButtonProps = {
29
32
  label: string;
@@ -37,6 +40,7 @@ type DropdownButtonProps = {
37
40
  count?: number;
38
41
  menuIcon?: IconProps;
39
42
  size?: "sm" | "md" | "lg";
43
+ onClear?: () => void;
40
44
  };
41
45
  type DropdownItemProps = {
42
46
  label: string;
@@ -47,12 +51,7 @@ type DropdownItemProps = {
47
51
  size?: "sm" | "md" | "lg";
48
52
  };
49
53
  type DropdownMenuProps = {
50
- items: {
51
- label: string;
52
- icon?: IconProps;
53
- value: string;
54
- disabled?: boolean;
55
- }[];
54
+ items: DropdownOption[];
56
55
  selectedItem?: string | string[] | undefined;
57
56
  handleChange: (item: string | string[] | undefined) => void;
58
57
  multiple?: boolean;
@@ -64,10 +63,12 @@ type DropdownMenuProps = {
64
63
  animationOrigin?: "top-left" | "top-center" | "top-right";
65
64
  search?: string;
66
65
  onClearSearch?: () => void;
66
+ showSelectAll?: boolean;
67
+ showSafeTriangle?: boolean;
67
68
  };
68
- declare const DropdownMenu: ({ items, selectedItem, handleChange, multiple, menuClassName, size, isOpen, onItemClick, isScrollable, animationOrigin, search, onClearSearch, }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
69
- declare const Dropdown: ({ className, items, selectedItem, handleChange, label, multiSelectLabel, disabled, buttonClassName, menuClassName, multiple, menuIcon, size, isScrollable, search, onClearSearch, }: DropdownProps) => react_jsx_runtime.JSX.Element;
70
- declare const DropdownButton: ({ label, multiSelectLabel, disabled, className, onClick, selectedItems, multiple, count, menuIcon, size, }: DropdownButtonProps) => react_jsx_runtime.JSX.Element;
69
+ declare const DropdownMenu: ({ items, selectedItem, handleChange, multiple, menuClassName, size, isOpen, onItemClick, isScrollable, animationOrigin, search, onClearSearch, showSelectAll, showSafeTriangle, }: DropdownMenuProps) => react_jsx_runtime.JSX.Element;
70
+ declare const Dropdown: ({ className, items, selectedItem, handleChange, label, multiSelectLabel, disabled, buttonClassName, menuClassName, multiple, menuIcon, size, isScrollable, search, onClearSearch, showSelectAll, }: DropdownProps) => react_jsx_runtime.JSX.Element;
71
+ declare const DropdownButton: ({ label, multiSelectLabel, disabled, className, onClick, selectedItems, multiple, count, menuIcon, size, onClear, }: DropdownButtonProps) => react_jsx_runtime.JSX.Element;
71
72
  declare const DropdownItem: ({ label, icon, onClick, disabled, isSelected, size, }: DropdownItemProps) => react_jsx_runtime.JSX.Element;
72
73
 
73
- export { Dropdown, DropdownButton, type DropdownButtonProps, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownProps };
74
+ export { Dropdown, DropdownButton, type DropdownButtonProps, DropdownItem, type DropdownItemProps, DropdownMenu, type DropdownMenuProps, type DropdownOption, type DropdownProps };
package/dist/Dropdown.js CHANGED
@@ -16,6 +16,59 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
16
 
17
17
  var classNames__default = /*#__PURE__*/_interopDefault(classNames);
18
18
 
19
+ const useMousePosition = () => {
20
+ const [mousePosition, setMousePosition] = react.useState([0, 0]);
21
+ const updateMousePosition = react.useCallback((ev) => {
22
+ setMousePosition([ev.clientX, ev.clientY]);
23
+ }, []);
24
+ react.useEffect(() => {
25
+ const throttledUpdate = (ev) => {
26
+ requestAnimationFrame(() => updateMousePosition(ev));
27
+ };
28
+ window.addEventListener("mousemove", throttledUpdate);
29
+ return () => window.removeEventListener("mousemove", throttledUpdate);
30
+ }, [updateMousePosition]);
31
+ return mousePosition;
32
+ };
33
+ const MouseSafeArea = ({
34
+ parentRef,
35
+ submenuRef,
36
+ onEnter,
37
+ onLeave,
38
+ debug = false
39
+ }) => {
40
+ const {
41
+ x = 0,
42
+ y = 0,
43
+ height: h = 0,
44
+ width: w = 0
45
+ } = submenuRef.current?.getBoundingClientRect() || {};
46
+ const [mouseX, mouseY] = useMousePosition();
47
+ const positions = { x, y, h, w, mouseX, mouseY };
48
+ return /* @__PURE__ */ jsxRuntime.jsx(
49
+ "div",
50
+ {
51
+ style: {
52
+ position: "absolute",
53
+ left: getLeft(positions),
54
+ right: getRight(positions),
55
+ top: 0,
56
+ width: getWidth(positions),
57
+ height: h,
58
+ clipPath: getClipPath(positions),
59
+ pointerEvents: "auto",
60
+ zIndex: 9999,
61
+ backgroundColor: debug ? "rgba(0, 179, 179, 0.25)" : "transparent"
62
+ },
63
+ onMouseEnter: onEnter,
64
+ onMouseLeave: onLeave
65
+ }
66
+ );
67
+ };
68
+ const getLeft = ({ x, mouseX }) => mouseX > x ? void 0 : -Math.max(x - mouseX, 10) + "px";
69
+ const getRight = ({ x, w, mouseX }) => mouseX > x ? -Math.max(mouseX - (x + w), 10) + "px" : void 0;
70
+ const getWidth = ({ x, w, mouseX }) => mouseX > x ? Math.max(mouseX - (x + w), 10) + "px" : Math.max(x - mouseX, 10) + "px";
71
+ const getClipPath = ({ x, y, h, mouseX, mouseY }) => mouseX < x ? `polygon(100% 0%, 0% ${100 * (mouseY - y) / h}%, 100% 100%)` : `polygon(0% 0%, 0% 100%, 100% ${100 * (mouseY - y) / h}%)`;
19
72
  const DropdownMenu = ({
20
73
  items,
21
74
  selectedItem,
@@ -28,7 +81,9 @@ const DropdownMenu = ({
28
81
  isScrollable = false,
29
82
  animationOrigin = "top-left",
30
83
  search,
31
- onClearSearch
84
+ onClearSearch,
85
+ showSelectAll = true,
86
+ showSafeTriangle = false
32
87
  }) => {
33
88
  const [isAtBottom, setIsAtBottom] = react.useState(false);
34
89
  const scrollContainerRef = react.useRef(null);
@@ -68,6 +123,20 @@ const DropdownMenu = ({
68
123
  }
69
124
  return !!selectedItem && selectedItem === value;
70
125
  };
126
+ const flattenSelectable = (options) => {
127
+ const out = [];
128
+ const walk = (nodes) => {
129
+ nodes.forEach((n) => {
130
+ if (n.children && n.children.length > 0) {
131
+ walk(n.children);
132
+ } else {
133
+ out.push(n);
134
+ }
135
+ });
136
+ };
137
+ walk(options);
138
+ return out;
139
+ };
71
140
  const handleItemClick = (value) => {
72
141
  if (multiple) {
73
142
  const currentSelection = Array.isArray(selectedItem) ? selectedItem : [];
@@ -89,7 +158,7 @@ const DropdownMenu = ({
89
158
  };
90
159
  const handleSelectAll = () => {
91
160
  const currentSelection = Array.isArray(selectedItem) ? selectedItem : [];
92
- const allValues = filteredItems.filter((item) => !item.disabled).map((item) => item.value);
161
+ const allValues = flattenSelectable(filteredItems).filter((item) => !item.disabled).map((item) => item.value);
93
162
  if (currentSelection.length === allValues.length) {
94
163
  handleChange([]);
95
164
  } else {
@@ -98,7 +167,9 @@ const DropdownMenu = ({
98
167
  };
99
168
  const isAllSelected = () => {
100
169
  if (!Array.isArray(selectedItem) || selectedItem.length === 0) return false;
101
- const selectableItems = filteredItems.filter((item) => !item.disabled);
170
+ const selectableItems = flattenSelectable(filteredItems).filter(
171
+ (item) => !item.disabled
172
+ );
102
173
  return selectableItems.length > 0 && selectedItem.length === selectableItems.length && selectableItems.every((item) => selectedItem.includes(item.value));
103
174
  };
104
175
  return /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
@@ -109,7 +180,7 @@ const DropdownMenu = ({
109
180
  transition: { duration: 0.1, ease: easings.swift },
110
181
  exit: { opacity: 0, scale: 0.8, y: -5 },
111
182
  className: classNames__default.default(
112
- "absolute top-[calc(100%+6px)] p-1 bg-card-foreground gradient-border before:bg-card-border",
183
+ "z-50 absolute top-[calc(100%+6px)] p-1 bg-card-foreground gradient-border before:bg-card-border",
113
184
  (size === "lg" || size === "md") && "min-w-[200px]",
114
185
  animationOrigin === "top-left" && "origin-top-left",
115
186
  animationOrigin === "top-center" && "origin-top-center",
@@ -129,7 +200,7 @@ const DropdownMenu = ({
129
200
  ]
130
201
  ),
131
202
  children: [
132
- multiple && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group flex flex-col gap-y-1", children: [
203
+ multiple && showSelectAll && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group flex flex-col gap-y-1", children: [
133
204
  /* @__PURE__ */ jsxRuntime.jsxs(
134
205
  "button",
135
206
  {
@@ -145,23 +216,34 @@ const DropdownMenu = ({
145
216
  ),
146
217
  /* @__PURE__ */ jsxRuntime.jsx(Divider.Divider, { direction: "horizontal" })
147
218
  ] }),
148
- filteredItems.length > 0 ? filteredItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
149
- DropdownItem,
150
- {
151
- label: item.label,
152
- icon: item.icon?.name ? {
153
- name: item.icon.name,
154
- className: item.icon.className,
155
- size: item.icon.size,
156
- difficulties: item.icon.difficulties
157
- } : void 0,
158
- onClick: () => handleItemClick(item.value),
159
- disabled: item.disabled,
160
- isSelected: isItemSelected(item.value),
161
- size
162
- },
163
- item.value
164
- )) : /* @__PURE__ */ jsxRuntime.jsx(
219
+ filteredItems.length > 0 ? filteredItems.map(
220
+ (item) => item.children && item.children.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
221
+ DropdownSubmenuItem,
222
+ {
223
+ item,
224
+ size,
225
+ onLeafClick: handleItemClick,
226
+ isLeafSelected: isItemSelected
227
+ },
228
+ item.value
229
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
230
+ DropdownItem,
231
+ {
232
+ label: item.label,
233
+ icon: item.icon?.name ? {
234
+ name: item.icon.name,
235
+ className: item.icon.className,
236
+ size: item.icon.size,
237
+ difficulties: item.icon.difficulties
238
+ } : void 0,
239
+ onClick: () => handleItemClick(item.value),
240
+ disabled: item.disabled,
241
+ isSelected: isItemSelected(item.value),
242
+ size
243
+ },
244
+ item.value
245
+ )
246
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
165
247
  "button",
166
248
  {
167
249
  onClick: () => {
@@ -194,7 +276,8 @@ const Dropdown = ({
194
276
  size = "md",
195
277
  isScrollable = false,
196
278
  search,
197
- onClearSearch
279
+ onClearSearch,
280
+ showSelectAll
198
281
  }) => {
199
282
  const [isOpen, setIsOpen] = react.useState(false);
200
283
  const handleItemClick = (value) => {
@@ -213,13 +296,27 @@ const Dropdown = ({
213
296
  };
214
297
  usehooksTs.useOnClickOutside(ref, handleClickOutside);
215
298
  const getSelectedItems = () => {
299
+ const flatten = (options) => {
300
+ const out = [];
301
+ const walk = (nodes) => {
302
+ nodes.forEach((n) => {
303
+ if (n.children && n.children.length > 0) {
304
+ walk(n.children);
305
+ } else {
306
+ out.push(n);
307
+ }
308
+ });
309
+ };
310
+ walk(options);
311
+ return out;
312
+ };
313
+ const leaves = flatten(items);
216
314
  if (multiple) {
217
315
  const selectedValues = Array.isArray(selectedItem) ? selectedItem : [];
218
- return items.filter((item) => selectedValues.includes(item.value));
219
- } else {
220
- const selected = items.find((item) => item.value === selectedItem);
221
- return selected ? [selected] : [];
316
+ return leaves.filter((item) => selectedValues.includes(item.value));
222
317
  }
318
+ const selected = leaves.find((item) => item.value === selectedItem);
319
+ return selected ? [selected] : [];
223
320
  };
224
321
  return /* @__PURE__ */ jsxRuntime.jsxs(
225
322
  "div",
@@ -242,7 +339,8 @@ const Dropdown = ({
242
339
  multiple,
243
340
  count: getSelectedItems().length,
244
341
  menuIcon,
245
- size
342
+ size,
343
+ onClear: () => handleChange(multiple ? [] : void 0)
246
344
  }
247
345
  ),
248
346
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -258,7 +356,8 @@ const Dropdown = ({
258
356
  onItemClick: handleItemClick,
259
357
  isScrollable,
260
358
  search,
261
- onClearSearch
359
+ onClearSearch,
360
+ showSelectAll
262
361
  }
263
362
  )
264
363
  ]
@@ -275,7 +374,8 @@ const DropdownButton = ({
275
374
  multiple = false,
276
375
  count = 0,
277
376
  menuIcon,
278
- size
377
+ size,
378
+ onClear
279
379
  }) => {
280
380
  const [isHovered, setIsHovered] = react.useState(false);
281
381
  const hasSelection = selectedItems.length > 0;
@@ -319,6 +419,7 @@ const DropdownButton = ({
319
419
  size === "sm" && "!pr-4 !pl-3",
320
420
  className
321
421
  ),
422
+ useDecryptAnimation: false,
322
423
  useHoverEffect: false,
323
424
  crosshairProps: {
324
425
  variant: "corners",
@@ -331,7 +432,18 @@ const DropdownButton = ({
331
432
  },
332
433
  onClick,
333
434
  onMouseEnter: () => setIsHovered(true),
334
- onMouseLeave: () => setIsHovered(false)
435
+ onMouseLeave: () => setIsHovered(false),
436
+ children: hasSelection && multiple && /* @__PURE__ */ jsxRuntime.jsx(
437
+ "div",
438
+ {
439
+ className: "absolute right-2 top-1/2 -translate-y-1/2 h-[24px] w-[24px] flex items-center justify-center hover:bg-background/40 transition duration-100 ease-crisp cursor-pointer",
440
+ onClick: (e) => {
441
+ e.stopPropagation();
442
+ onClear?.();
443
+ },
444
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { name: "Close", size: 12 })
445
+ }
446
+ )
335
447
  }
336
448
  );
337
449
  };
@@ -387,6 +499,109 @@ const DropdownItem = ({
387
499
  }
388
500
  );
389
501
  };
502
+ const DropdownSubmenuItem = ({
503
+ item,
504
+ size = "md",
505
+ onLeafClick,
506
+ isLeafSelected
507
+ }) => {
508
+ const parentRef = react.useRef(null);
509
+ const submenuRef = react.useRef(null);
510
+ const [hoverParent, setHoverParent] = react.useState(false);
511
+ const [hoverSubmenu, setHoverSubmenu] = react.useState(false);
512
+ const [hoverSafe, setHoverSafe] = react.useState(false);
513
+ const open = hoverParent || hoverSubmenu || hoverSafe;
514
+ return /* @__PURE__ */ jsxRuntime.jsxs(
515
+ "div",
516
+ {
517
+ ref: parentRef,
518
+ className: "relative",
519
+ onMouseEnter: () => setHoverParent(true),
520
+ onMouseLeave: () => setHoverParent(false),
521
+ children: [
522
+ /* @__PURE__ */ jsxRuntime.jsxs(
523
+ "button",
524
+ {
525
+ type: "button",
526
+ className: classNames__default.default(
527
+ "hover:bg-border-light/50 relative group/item disabled:opacity-40 flex items-center justify-between gap-x-2.5 w-full outline-none transition-colors duration-100 ease-crisp",
528
+ size === "lg" && "py-4 pl-3 pr-3 text-base",
529
+ size === "md" && "py-3 pl-2.5 pr-3 text-sm",
530
+ size === "sm" && "py-2 pl-2.5 pr-3 h-[36px] text-sm",
531
+ open && "bg-border-light/50"
532
+ ),
533
+ disabled: item.disabled,
534
+ children: [
535
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-x-2.5", children: [
536
+ item.icon?.name && /* @__PURE__ */ jsxRuntime.jsx(
537
+ Icon.Icon,
538
+ {
539
+ name: item.icon.name,
540
+ className: classNames__default.default("flex-shrink-0", item.icon.className),
541
+ size: item.icon.size || 18,
542
+ difficulties: item.icon.difficulties
543
+ }
544
+ ),
545
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-shade-primary font-medium leading-[100%]", children: item.label })
546
+ ] }),
547
+ /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { name: "ChevronRight", size: 14, className: "text-shade-tertiary" })
548
+ ]
549
+ }
550
+ ),
551
+ open && /* @__PURE__ */ jsxRuntime.jsxs(
552
+ "div",
553
+ {
554
+ ref: submenuRef,
555
+ onMouseEnter: () => setHoverSubmenu(true),
556
+ onMouseLeave: () => setHoverSubmenu(false),
557
+ className: classNames__default.default(
558
+ "z-[60] absolute top-0 left-[calc(100%+6px)] p-1 bg-card-foreground gradient-border before:bg-card-border min-w-[180px]"
559
+ ),
560
+ children: [
561
+ /* @__PURE__ */ jsxRuntime.jsx(
562
+ MouseSafeArea,
563
+ {
564
+ parentRef,
565
+ submenuRef,
566
+ onEnter: () => setHoverSafe(true),
567
+ onLeave: () => setHoverSafe(false)
568
+ }
569
+ ),
570
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-1", children: (item.children || []).map(
571
+ (child) => child.children && child.children.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
572
+ DropdownSubmenuItem,
573
+ {
574
+ item: child,
575
+ size,
576
+ onLeafClick,
577
+ isLeafSelected
578
+ },
579
+ child.value
580
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
581
+ DropdownItem,
582
+ {
583
+ label: child.label,
584
+ icon: child.icon?.name ? {
585
+ name: child.icon.name,
586
+ className: child.icon.className,
587
+ size: child.icon.size,
588
+ difficulties: child.icon.difficulties
589
+ } : void 0,
590
+ onClick: () => onLeafClick(child.value),
591
+ disabled: child.disabled,
592
+ isSelected: isLeafSelected(child.value),
593
+ size
594
+ },
595
+ child.value
596
+ )
597
+ ) })
598
+ ]
599
+ }
600
+ )
601
+ ]
602
+ }
603
+ );
604
+ };
390
605
 
391
606
  exports.Dropdown = Dropdown;
392
607
  exports.DropdownButton = DropdownButton;