@luxfi/ui 6.1.3 → 7.1.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 (241) hide show
  1. package/dist/accordion.cjs +213 -0
  2. package/dist/accordion.d.cts +74 -0
  3. package/dist/accordion.d.ts +74 -0
  4. package/dist/accordion.js +186 -0
  5. package/dist/alert.cjs +430 -0
  6. package/dist/alert.d.cts +30 -0
  7. package/dist/alert.d.ts +30 -0
  8. package/dist/alert.js +408 -0
  9. package/dist/avatar.cjs +149 -0
  10. package/dist/avatar.d.cts +25 -0
  11. package/dist/avatar.d.ts +25 -0
  12. package/dist/avatar.js +125 -0
  13. package/dist/badge.cjs +452 -0
  14. package/dist/badge.d.cts +19 -0
  15. package/dist/badge.d.ts +19 -0
  16. package/dist/badge.js +431 -0
  17. package/dist/bank.cjs +272 -0
  18. package/dist/bank.d.cts +76 -0
  19. package/dist/bank.d.ts +76 -0
  20. package/dist/bank.js +258 -0
  21. package/dist/button.cjs +578 -0
  22. package/dist/button.d.cts +55 -0
  23. package/dist/button.d.ts +55 -0
  24. package/dist/button.js +553 -0
  25. package/dist/checkbox.cjs +265 -0
  26. package/dist/checkbox.d.cts +31 -0
  27. package/dist/checkbox.d.ts +31 -0
  28. package/dist/checkbox.js +241 -0
  29. package/dist/close-button.cjs +92 -0
  30. package/dist/close-button.d.cts +9 -0
  31. package/dist/close-button.d.ts +9 -0
  32. package/dist/close-button.js +70 -0
  33. package/dist/collapsible.cjs +555 -0
  34. package/dist/collapsible.d.cts +23 -0
  35. package/dist/collapsible.d.ts +23 -0
  36. package/dist/collapsible.js +532 -0
  37. package/dist/color-mode.cjs +96 -0
  38. package/dist/color-mode.d.cts +25 -0
  39. package/dist/color-mode.d.ts +25 -0
  40. package/dist/color-mode.js +72 -0
  41. package/dist/dialog.cjs +295 -0
  42. package/dist/dialog.d.cts +65 -0
  43. package/dist/dialog.d.ts +65 -0
  44. package/dist/dialog.js +263 -0
  45. package/dist/drawer.cjs +231 -0
  46. package/dist/drawer.d.cts +36 -0
  47. package/dist/drawer.d.ts +36 -0
  48. package/dist/drawer.js +199 -0
  49. package/dist/empty-state.cjs +93 -0
  50. package/dist/empty-state.d.cts +13 -0
  51. package/dist/empty-state.d.ts +13 -0
  52. package/dist/empty-state.js +71 -0
  53. package/dist/expiration-selector.cjs +138 -0
  54. package/dist/expiration-selector.d.cts +16 -0
  55. package/dist/expiration-selector.d.ts +16 -0
  56. package/dist/expiration-selector.js +116 -0
  57. package/dist/field.cjs +183 -0
  58. package/dist/field.d.cts +24 -0
  59. package/dist/field.d.ts +24 -0
  60. package/dist/field.js +160 -0
  61. package/dist/greeks-display.cjs +114 -0
  62. package/dist/greeks-display.d.cts +14 -0
  63. package/dist/greeks-display.d.ts +14 -0
  64. package/dist/greeks-display.js +92 -0
  65. package/dist/heading.cjs +41 -0
  66. package/dist/heading.d.cts +10 -0
  67. package/dist/heading.d.ts +10 -0
  68. package/dist/heading.js +35 -0
  69. package/dist/icon-button.cjs +367 -0
  70. package/dist/icon-button.d.cts +33 -0
  71. package/dist/icon-button.d.ts +33 -0
  72. package/dist/icon-button.js +345 -0
  73. package/dist/image.cjs +425 -0
  74. package/dist/image.d.cts +57 -0
  75. package/dist/image.d.ts +57 -0
  76. package/dist/image.js +404 -0
  77. package/dist/index.cjs +7220 -0
  78. package/dist/index.d.cts +55 -0
  79. package/dist/index.d.ts +55 -0
  80. package/dist/index.js +7043 -0
  81. package/dist/input-group.cjs +155 -0
  82. package/dist/input-group.d.cts +17 -0
  83. package/dist/input-group.d.ts +17 -0
  84. package/dist/input-group.js +133 -0
  85. package/dist/input.cjs +65 -0
  86. package/dist/input.d.cts +11 -0
  87. package/dist/input.d.ts +11 -0
  88. package/dist/input.js +59 -0
  89. package/dist/link.cjs +483 -0
  90. package/dist/link.d.cts +37 -0
  91. package/dist/link.d.ts +37 -0
  92. package/dist/link.js +459 -0
  93. package/dist/menu.cjs +305 -0
  94. package/dist/menu.d.cts +84 -0
  95. package/dist/menu.d.ts +84 -0
  96. package/dist/menu.js +269 -0
  97. package/dist/option-chain.cjs +221 -0
  98. package/dist/option-chain.d.cts +37 -0
  99. package/dist/option-chain.d.ts +37 -0
  100. package/dist/option-chain.js +199 -0
  101. package/dist/option-position.cjs +164 -0
  102. package/dist/option-position.d.cts +29 -0
  103. package/dist/option-position.d.ts +29 -0
  104. package/dist/option-position.js +142 -0
  105. package/dist/pin-input.cjs +182 -0
  106. package/dist/pin-input.d.cts +25 -0
  107. package/dist/pin-input.d.ts +25 -0
  108. package/dist/pin-input.js +160 -0
  109. package/dist/pnl-diagram.cjs +453 -0
  110. package/dist/pnl-diagram.d.cts +11 -0
  111. package/dist/pnl-diagram.d.ts +11 -0
  112. package/dist/pnl-diagram.js +431 -0
  113. package/dist/popover.cjs +342 -0
  114. package/dist/popover.d.cts +73 -0
  115. package/dist/popover.d.ts +73 -0
  116. package/dist/popover.js +310 -0
  117. package/dist/progress-circle.cjs +152 -0
  118. package/dist/progress-circle.d.cts +47 -0
  119. package/dist/progress-circle.d.ts +47 -0
  120. package/dist/progress-circle.js +128 -0
  121. package/dist/progress.cjs +117 -0
  122. package/dist/progress.d.cts +28 -0
  123. package/dist/progress.d.ts +28 -0
  124. package/dist/progress.js +94 -0
  125. package/dist/provider.cjs +62 -0
  126. package/dist/provider.d.cts +7 -0
  127. package/dist/provider.d.ts +7 -0
  128. package/dist/provider.js +40 -0
  129. package/dist/radio.cjs +177 -0
  130. package/dist/radio.d.cts +53 -0
  131. package/dist/radio.d.ts +53 -0
  132. package/dist/radio.js +153 -0
  133. package/dist/rating.cjs +80 -0
  134. package/dist/rating.d.cts +14 -0
  135. package/dist/rating.d.ts +14 -0
  136. package/dist/rating.js +58 -0
  137. package/dist/select.cjs +644 -0
  138. package/dist/select.d.cts +130 -0
  139. package/dist/select.d.ts +130 -0
  140. package/dist/select.js +610 -0
  141. package/dist/separator.cjs +57 -0
  142. package/dist/separator.d.cts +13 -0
  143. package/dist/separator.d.ts +13 -0
  144. package/dist/separator.js +51 -0
  145. package/dist/skeleton.cjs +223 -0
  146. package/dist/skeleton.d.cts +60 -0
  147. package/dist/skeleton.d.ts +60 -0
  148. package/dist/skeleton.js +199 -0
  149. package/dist/slider.cjs +138 -0
  150. package/dist/slider.d.cts +24 -0
  151. package/dist/slider.d.ts +24 -0
  152. package/dist/slider.js +115 -0
  153. package/dist/strategy-builder.cjs +373 -0
  154. package/dist/strategy-builder.d.cts +26 -0
  155. package/dist/strategy-builder.d.ts +26 -0
  156. package/dist/strategy-builder.js +351 -0
  157. package/dist/switch.cjs +163 -0
  158. package/dist/switch.d.cts +27 -0
  159. package/dist/switch.d.ts +27 -0
  160. package/dist/switch.js +140 -0
  161. package/dist/table.cjs +897 -0
  162. package/dist/table.d.cts +107 -0
  163. package/dist/table.d.ts +107 -0
  164. package/dist/table.js +866 -0
  165. package/dist/tabs.cjs +240 -0
  166. package/dist/tabs.d.cts +78 -0
  167. package/dist/tabs.d.ts +78 -0
  168. package/dist/tabs.js +213 -0
  169. package/dist/tag.cjs +529 -0
  170. package/dist/tag.d.cts +21 -0
  171. package/dist/tag.d.ts +21 -0
  172. package/dist/tag.js +507 -0
  173. package/dist/textarea.cjs +65 -0
  174. package/dist/textarea.d.cts +11 -0
  175. package/dist/textarea.d.ts +11 -0
  176. package/dist/textarea.js +59 -0
  177. package/dist/toaster.cjs +99 -0
  178. package/dist/toaster.d.cts +29 -0
  179. package/dist/toaster.d.ts +29 -0
  180. package/dist/toaster.js +96 -0
  181. package/dist/tooltip.cjs +172 -0
  182. package/dist/tooltip.d.cts +38 -0
  183. package/dist/tooltip.d.ts +38 -0
  184. package/dist/tooltip.js +150 -0
  185. package/dist/utils.cjs +11 -0
  186. package/dist/utils.d.cts +5 -0
  187. package/dist/utils.d.ts +5 -0
  188. package/dist/utils.js +9 -0
  189. package/package.json +284 -89
  190. package/src/accordion.tsx +285 -0
  191. package/src/alert.tsx +221 -0
  192. package/src/avatar.tsx +174 -0
  193. package/src/badge.tsx +147 -0
  194. package/src/bank.tsx +325 -0
  195. package/src/button.tsx +477 -0
  196. package/src/checkbox.tsx +307 -0
  197. package/src/close-button.tsx +77 -0
  198. package/src/collapsible.tsx +126 -0
  199. package/src/color-mode.tsx +125 -0
  200. package/src/dialog.tsx +346 -0
  201. package/src/drawer.tsx +186 -0
  202. package/src/empty-state.tsx +97 -0
  203. package/src/expiration-selector.tsx +163 -0
  204. package/src/field.tsx +202 -0
  205. package/src/greeks-display.tsx +138 -0
  206. package/src/heading.tsx +44 -0
  207. package/src/icon-button.tsx +217 -0
  208. package/src/image.tsx +280 -0
  209. package/src/index.ts +267 -138
  210. package/src/input-group.tsx +159 -0
  211. package/src/input.tsx +60 -0
  212. package/src/link.tsx +326 -0
  213. package/src/menu.tsx +471 -0
  214. package/src/option-chain.tsx +261 -0
  215. package/src/option-position.tsx +200 -0
  216. package/src/pin-input.tsx +187 -0
  217. package/src/pnl-diagram.tsx +458 -0
  218. package/src/popover.tsx +386 -0
  219. package/src/progress-circle.tsx +180 -0
  220. package/src/progress.tsx +109 -0
  221. package/src/provider.tsx +12 -0
  222. package/src/radio.tsx +175 -0
  223. package/src/rating.tsx +79 -0
  224. package/src/select.tsx +696 -0
  225. package/src/separator.tsx +59 -0
  226. package/src/skeleton.tsx +254 -0
  227. package/src/slider.tsx +152 -0
  228. package/src/strategy-builder.tsx +466 -0
  229. package/src/switch.tsx +158 -0
  230. package/src/table.tsx +621 -0
  231. package/src/tabs.tsx +354 -0
  232. package/src/tag.tsx +159 -0
  233. package/src/textarea.tsx +60 -0
  234. package/src/toaster.tsx +117 -0
  235. package/src/tokens.css +438 -0
  236. package/src/tooltip.tsx +191 -0
  237. package/src/utils/cn.ts +7 -0
  238. package/src/utils.ts +6 -0
  239. package/tokens.css +438 -0
  240. package/LICENSE +0 -122
  241. package/README.md +0 -109
@@ -0,0 +1,644 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var RadixSelect = require('@radix-ui/react-select');
5
+ var usehooks = require('@uidotdev/usehooks');
6
+ var React2 = require('react');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var RadixSelect__namespace = /*#__PURE__*/_interopNamespace(RadixSelect);
30
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
31
+
32
+ function cn(...inputs) {
33
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
34
+ }
35
+ var SHIM_PROPS = [
36
+ "w",
37
+ "h",
38
+ "minW",
39
+ "maxW",
40
+ "display",
41
+ "flexGrow",
42
+ "flexShrink",
43
+ "flexBasis",
44
+ "fontWeight",
45
+ "textStyle",
46
+ "borderRadius",
47
+ "alignSelf",
48
+ "alignItems",
49
+ "justifyContent",
50
+ "color",
51
+ "mt",
52
+ "mb",
53
+ "ml",
54
+ "mr",
55
+ "height",
56
+ "overflow",
57
+ "whiteSpace",
58
+ "textOverflow",
59
+ "textTransform",
60
+ "gap",
61
+ "gridTemplateColumns",
62
+ "minWidth",
63
+ "boxSize",
64
+ "py",
65
+ "px",
66
+ "p",
67
+ "hideBelow",
68
+ "fontSize",
69
+ "flexWrap",
70
+ "wordBreak",
71
+ "lineHeight",
72
+ "marginRight",
73
+ "position",
74
+ "background"
75
+ ];
76
+ var S = 4;
77
+ function dim(v) {
78
+ if (v == null) return void 0;
79
+ if (typeof v === "number") return `${v * S}px`;
80
+ if (typeof v === "string") return v;
81
+ if (typeof v === "object") {
82
+ const o = v;
83
+ return o.base ?? o.lg ?? o.xl ?? Object.values(o)[0];
84
+ }
85
+ return void 0;
86
+ }
87
+ function sp(v) {
88
+ if (v === void 0) return void 0;
89
+ return typeof v === "number" ? `${v * S}px` : v;
90
+ }
91
+ function shimToStyle(props) {
92
+ const s = {};
93
+ if (props.w !== void 0) s.width = dim(props.w);
94
+ if (props.h !== void 0) s.height = dim(props.h);
95
+ if (props.minW !== void 0) s.minWidth = dim(props.minW);
96
+ if (props.maxW !== void 0) s.maxWidth = dim(props.maxW);
97
+ if (props.display !== void 0) s.display = props.display;
98
+ if (props.flexGrow !== void 0) s.flexGrow = props.flexGrow;
99
+ if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
100
+ if (props.flexBasis !== void 0) s.flexBasis = props.flexBasis;
101
+ if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
102
+ if (props.borderRadius !== void 0) s.borderRadius = props.borderRadius;
103
+ if (props.alignSelf !== void 0) s.alignSelf = props.alignSelf;
104
+ if (props.alignItems !== void 0) s.alignItems = props.alignItems;
105
+ if (props.justifyContent !== void 0) s.justifyContent = props.justifyContent;
106
+ if (props.color !== void 0) s.color = props.color;
107
+ if (props.mt !== void 0) s.marginTop = sp(props.mt);
108
+ if (props.mb !== void 0) s.marginBottom = sp(props.mb);
109
+ if (props.ml !== void 0) s.marginLeft = sp(props.ml);
110
+ if (props.mr !== void 0) s.marginRight = sp(props.mr);
111
+ if (props.height !== void 0) s.height = props.height;
112
+ if (props.overflow !== void 0) s.overflow = props.overflow;
113
+ if (props.whiteSpace !== void 0) s.whiteSpace = props.whiteSpace;
114
+ if (props.textOverflow !== void 0) s.textOverflow = props.textOverflow;
115
+ if (props.textTransform !== void 0) s.textTransform = props.textTransform;
116
+ if (props.gap !== void 0) s.gap = sp(props.gap);
117
+ if (props.gridTemplateColumns !== void 0) s.gridTemplateColumns = props.gridTemplateColumns;
118
+ if (props.minWidth !== void 0) s.minWidth = props.minWidth;
119
+ if (props.boxSize !== void 0) {
120
+ const v = typeof props.boxSize === "number" ? `${props.boxSize * S}px` : props.boxSize;
121
+ s.width = v;
122
+ s.height = v;
123
+ }
124
+ if (props.py !== void 0) {
125
+ const v = sp(props.py);
126
+ s.paddingTop = v;
127
+ s.paddingBottom = v;
128
+ }
129
+ if (props.px !== void 0) {
130
+ const v = sp(props.px);
131
+ s.paddingLeft = v;
132
+ s.paddingRight = v;
133
+ }
134
+ if (props.p !== void 0) s.padding = sp(props.p);
135
+ if (props.fontSize !== void 0) s.fontSize = props.fontSize;
136
+ if (props.flexWrap !== void 0) s.flexWrap = props.flexWrap;
137
+ if (props.wordBreak !== void 0) s.wordBreak = props.wordBreak;
138
+ if (props.lineHeight !== void 0) s.lineHeight = props.lineHeight;
139
+ if (props.marginRight !== void 0) s.marginRight = props.marginRight;
140
+ if (props.position !== void 0) s.position = props.position;
141
+ if (props.background !== void 0) s.background = props.background;
142
+ return s;
143
+ }
144
+ function stripShims(props) {
145
+ const out = { ...props };
146
+ for (const k of SHIM_PROPS) delete out[k];
147
+ return out;
148
+ }
149
+ var SKELETON_CLASSES = [
150
+ "animate-skeleton-shimmer rounded-sm",
151
+ "bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
152
+ "bg-[length:200%_100%]"
153
+ ].join(" ");
154
+ var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
155
+ var Skeleton = React2__namespace.forwardRef(
156
+ function Skeleton2(props, ref) {
157
+ const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
158
+ const shimStyle = shimToStyle(props);
159
+ const mergedStyle = Object.keys(shimStyle).length > 0 || styleProp ? { ...shimStyle, ...styleProp } : void 0;
160
+ const hideBelowClass = props.hideBelow ? HIDE_BELOW_MAP[props.hideBelow] : void 0;
161
+ const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
162
+ const htmlRest = stripShims(allRest);
163
+ if (!loading) {
164
+ if (asChild && React2__namespace.isValidElement(children)) return children;
165
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
166
+ }
167
+ if (asChild && React2__namespace.isValidElement(children)) {
168
+ return /* @__PURE__ */ jsxRuntime.jsx(
169
+ Component,
170
+ {
171
+ ref,
172
+ "data-loading": true,
173
+ className: cn(SKELETON_CLASSES, "text-transparent [&_*]:invisible", cls),
174
+ style: mergedStyle,
175
+ ...htmlRest,
176
+ children
177
+ }
178
+ );
179
+ }
180
+ return /* @__PURE__ */ jsxRuntime.jsx(
181
+ Component,
182
+ {
183
+ ref,
184
+ "data-loading": true,
185
+ className: cn(SKELETON_CLASSES, children ? "text-transparent [&_*]:invisible" : "min-h-5", cls),
186
+ style: mergedStyle,
187
+ ...htmlRest,
188
+ children
189
+ }
190
+ );
191
+ }
192
+ );
193
+ React2__namespace.forwardRef(
194
+ function SkeletonCircle2(props, ref) {
195
+ const { size = 40, loading = true, className, ...rest } = props;
196
+ const dimension = typeof size === "number" ? `${size}px` : size;
197
+ return /* @__PURE__ */ jsxRuntime.jsx(
198
+ Skeleton,
199
+ {
200
+ ref,
201
+ loading,
202
+ className: cn("rounded-full shrink-0", className),
203
+ style: { width: dimension, height: dimension, ...rest.style },
204
+ ...rest
205
+ }
206
+ );
207
+ }
208
+ );
209
+ React2__namespace.forwardRef(
210
+ function SkeletonText2(props, ref) {
211
+ const { noOfLines = 3, loading = true, className, ...rest } = props;
212
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
213
+ Skeleton,
214
+ {
215
+ loading,
216
+ className: cn("h-4", index === noOfLines - 1 && "max-w-[80%]")
217
+ },
218
+ index
219
+ )) });
220
+ }
221
+ );
222
+ function createListCollection(config) {
223
+ return { items: config.items };
224
+ }
225
+ var ArrowIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
226
+ var CheckIcon = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M16.667 5L7.5 14.167 3.333 10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
227
+ function FilterInput({ placeholder, initialValue = "", onChange }) {
228
+ const [value, setValue] = React2__namespace.useState(initialValue);
229
+ const handleChange = React2__namespace.useCallback((e) => {
230
+ setValue(e.target.value);
231
+ onChange?.(e.target.value);
232
+ }, [onChange]);
233
+ return /* @__PURE__ */ jsxRuntime.jsx(
234
+ "input",
235
+ {
236
+ type: "text",
237
+ placeholder,
238
+ value,
239
+ onChange: handleChange,
240
+ className: cn(
241
+ "w-full px-3 py-2 text-sm outline-none",
242
+ "bg-transparent border-b border-[var(--color-border-divider)]",
243
+ "placeholder:text-[var(--color-input-placeholder)]"
244
+ )
245
+ }
246
+ );
247
+ }
248
+ var SelectInternalContext = React2__namespace.createContext(null);
249
+ function useSelectInternalContext() {
250
+ const ctx = React2__namespace.useContext(SelectInternalContext);
251
+ if (!ctx) {
252
+ throw new Error("Select compound components must be rendered inside <SelectRoot>");
253
+ }
254
+ return ctx;
255
+ }
256
+ var SelectRoot = React2__namespace.forwardRef(
257
+ function SelectRoot2(props, ref) {
258
+ const {
259
+ children,
260
+ collection: collectionProp,
261
+ defaultValue: defaultValueArr,
262
+ value: valueProp,
263
+ onValueChange: onValueChangeProp,
264
+ onInteractOutside,
265
+ name,
266
+ disabled,
267
+ readOnly,
268
+ required,
269
+ invalid,
270
+ size,
271
+ variant,
272
+ open: openProp,
273
+ defaultOpen,
274
+ onOpenChange,
275
+ positioning: _positioning,
276
+ lazyMount: _lazyMount,
277
+ unmountOnExit: _unmountOnExit,
278
+ asChild: _asChild,
279
+ className,
280
+ style,
281
+ w,
282
+ maxW,
283
+ minW,
284
+ hideFrom: _hideFrom
285
+ } = props;
286
+ const collection = collectionProp ?? createListCollection({ items: [] });
287
+ const [internalValue, setInternalValue] = React2__namespace.useState(defaultValueArr ?? []);
288
+ const currentValue = valueProp ?? internalValue;
289
+ const selectedItems = React2__namespace.useMemo(() => {
290
+ return currentValue.map((v) => collection.items.find((item) => item.value === v)).filter(Boolean);
291
+ }, [currentValue, collection.items]);
292
+ const [open, setOpen] = React2__namespace.useState(defaultOpen ?? false);
293
+ const isOpen = openProp ?? open;
294
+ const handleOpenChange = React2__namespace.useCallback((nextOpen) => {
295
+ setOpen(nextOpen);
296
+ onOpenChange?.(nextOpen);
297
+ if (!nextOpen) {
298
+ onInteractOutside?.();
299
+ }
300
+ }, [onOpenChange, onInteractOutside]);
301
+ const handleRadixValueChange = React2__namespace.useCallback((radixValue) => {
302
+ const nextArr = [radixValue];
303
+ if (!valueProp) {
304
+ setInternalValue(nextArr);
305
+ }
306
+ const items = collection.items.filter((item) => nextArr.includes(item.value));
307
+ onValueChangeProp?.({ value: nextArr, items });
308
+ }, [valueProp, collection.items, onValueChangeProp]);
309
+ const ctxValue = React2__namespace.useMemo(() => ({
310
+ value: currentValue,
311
+ selectedItems,
312
+ collection,
313
+ onValueChange: (details) => {
314
+ if (!valueProp) {
315
+ setInternalValue(details.value);
316
+ }
317
+ onValueChangeProp?.(details);
318
+ },
319
+ open: isOpen,
320
+ size,
321
+ variant,
322
+ disabled
323
+ }), [currentValue, selectedItems, collection, valueProp, onValueChangeProp, isOpen, size, variant, disabled]);
324
+ const resolveVal = (v) => {
325
+ if (!v) return void 0;
326
+ if (typeof v === "string") return v;
327
+ return v.base ?? v.lg ?? Object.values(v)[0];
328
+ };
329
+ const inlineStyle = React2__namespace.useMemo(() => {
330
+ const s = { ...style };
331
+ const rw = resolveVal(w);
332
+ if (rw) s.width = rw;
333
+ const rmw = resolveVal(maxW);
334
+ if (rmw) s.maxWidth = rmw;
335
+ const rminw = resolveVal(minW);
336
+ if (rminw) s.minWidth = rminw;
337
+ return s;
338
+ }, [style, w, maxW, minW]);
339
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectInternalContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxRuntime.jsx(
340
+ RadixSelect__namespace.Root,
341
+ {
342
+ value: currentValue[0] ?? "",
343
+ defaultValue: defaultValueArr?.[0],
344
+ onValueChange: handleRadixValueChange,
345
+ open: isOpen,
346
+ onOpenChange: handleOpenChange,
347
+ disabled: disabled || readOnly,
348
+ name,
349
+ required,
350
+ children: /* @__PURE__ */ jsxRuntime.jsx(
351
+ "div",
352
+ {
353
+ ref,
354
+ className: cn("relative inline-flex", className),
355
+ style: inlineStyle,
356
+ "data-invalid": invalid || void 0,
357
+ "data-disabled": disabled || void 0,
358
+ "data-variant": variant || void 0,
359
+ "data-size": size || void 0,
360
+ children
361
+ }
362
+ )
363
+ }
364
+ ) });
365
+ }
366
+ );
367
+ var SelectControl = React2__namespace.forwardRef(
368
+ function SelectControl2(props, ref) {
369
+ const { children, noIndicator, triggerProps, loading, defaultValue } = props;
370
+ const ctx = useSelectInternalContext();
371
+ const isDefaultValue = Array.isArray(defaultValue) ? ctx.value.every((item) => defaultValue.includes(item)) : false;
372
+ const { asChild, px: _px, className: triggerClassName, ...radixTriggerProps } = triggerProps ?? {};
373
+ const trigger = /* @__PURE__ */ jsxRuntime.jsx(
374
+ RadixSelect__namespace.Trigger,
375
+ {
376
+ ref,
377
+ asChild,
378
+ className: cn(
379
+ "group peer inline-flex items-center gap-2 cursor-pointer",
380
+ "rounded-lg text-sm transition-colors outline-none",
381
+ "border border-[var(--color-input-border)] bg-[var(--color-input-bg)] text-[var(--color-input-fg)]",
382
+ "hover:border-[var(--color-input-border-hover)]",
383
+ "focus-visible:border-[var(--color-input-border-focus)]",
384
+ "disabled:opacity-50 disabled:cursor-not-allowed",
385
+ ctx.variant === "plain" && "border-transparent bg-transparent px-1 py-0.5",
386
+ ctx.variant !== "plain" && ctx.size === "lg" && "px-4 py-2.5 min-h-[52px]",
387
+ ctx.variant !== "plain" && ctx.size !== "lg" && "px-3 py-1.5 min-h-[36px]",
388
+ triggerClassName
389
+ ),
390
+ "data-default-value": isDefaultValue || void 0,
391
+ ...radixTriggerProps,
392
+ children: asChild ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
393
+ children,
394
+ !noIndicator && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto shrink-0 transition-transform data-[state=open]:rotate-180 text-[var(--color-icon-secondary)]", children: /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { className: "h-5 w-5 -rotate-90" }) })
395
+ ] })
396
+ }
397
+ );
398
+ if (loading) {
399
+ return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { loading, asChild: true, children: trigger });
400
+ }
401
+ return trigger;
402
+ }
403
+ );
404
+ var SelectClearTrigger = React2__namespace.forwardRef(
405
+ function SelectClearTrigger2(props, ref) {
406
+ const { className, ...rest } = props;
407
+ const ctx = useSelectInternalContext();
408
+ const handleClick = React2__namespace.useCallback(() => {
409
+ ctx.onValueChange({ value: [], items: [] });
410
+ }, [ctx]);
411
+ return /* @__PURE__ */ jsxRuntime.jsx(
412
+ "button",
413
+ {
414
+ ref,
415
+ type: "button",
416
+ onClick: handleClick,
417
+ className: cn("pointer-events-auto", className),
418
+ "aria-label": "Clear selection",
419
+ ...rest,
420
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "h-5 w-5", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })
421
+ }
422
+ );
423
+ }
424
+ );
425
+ var SelectContent = React2__namespace.forwardRef(
426
+ function SelectContent2(props, ref) {
427
+ const { portalled = true, portalRef, children, className, ...rest } = props;
428
+ const content = /* @__PURE__ */ jsxRuntime.jsx(
429
+ RadixSelect__namespace.Content,
430
+ {
431
+ ref,
432
+ position: "popper",
433
+ sideOffset: 4,
434
+ className: cn(
435
+ "z-50 min-w-[8rem] overflow-hidden rounded-lg",
436
+ "bg-[var(--color-popover-bg)] shadow-[var(--shadow-popover)]",
437
+ "border border-[var(--color-border-divider)]",
438
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
439
+ "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
440
+ className
441
+ ),
442
+ ...rest,
443
+ children: /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Viewport, { className: "p-1", children })
444
+ }
445
+ );
446
+ if (portalled) {
447
+ return /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Portal, { container: portalRef?.current ?? void 0, children: content });
448
+ }
449
+ return content;
450
+ }
451
+ );
452
+ var SelectItem = React2__namespace.forwardRef(
453
+ function SelectItem2(props, ref) {
454
+ const { item, children, className, ...rest } = props;
455
+ return /* @__PURE__ */ jsxRuntime.jsxs(
456
+ RadixSelect__namespace.Item,
457
+ {
458
+ ref,
459
+ value: item.value,
460
+ textValue: item.label,
461
+ className: cn(
462
+ "relative flex cursor-pointer select-none items-center gap-2",
463
+ "rounded-md px-3 py-2 text-sm outline-none",
464
+ "text-[var(--color-text-primary)]",
465
+ "data-[highlighted]:bg-[var(--color-selected-control-bg)]",
466
+ "data-[state=checked]:font-medium",
467
+ "data-[disabled]:opacity-50 data-[disabled]:pointer-events-none",
468
+ className
469
+ ),
470
+ ...rest,
471
+ children: [
472
+ item.icon,
473
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ItemText, { children }),
474
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.ItemIndicator, { className: "ml-auto shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "h-5 w-5" }) })
475
+ ]
476
+ }
477
+ );
478
+ }
479
+ );
480
+ var SelectValueText = React2__namespace.forwardRef(
481
+ function SelectValueText2(props, ref) {
482
+ const { children, size, required, invalid, errorText, mode, className, style, placeholder: placeholderProp, ...rest } = props;
483
+ const ctx = useSelectInternalContext();
484
+ const placeholderText = `${placeholderProp ?? ""}${required ? "*" : ""}${invalid && errorText ? ` - ${errorText}` : ""}`;
485
+ const content = (() => {
486
+ const items = ctx.selectedItems;
487
+ if (items.length === 0) return null;
488
+ if (children) return children(items);
489
+ if (items.length === 1) {
490
+ const item = items[0];
491
+ if (!item) return null;
492
+ const label = size === "lg" ? /* @__PURE__ */ jsxRuntime.jsx(
493
+ "span",
494
+ {
495
+ className: cn(
496
+ "text-xs block",
497
+ invalid ? "text-[var(--color-text-error)]" : "text-[var(--color-input-placeholder)]"
498
+ ),
499
+ style: { display: "-webkit-box" },
500
+ children: placeholderText
501
+ }
502
+ ) : null;
503
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
504
+ label,
505
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center flex-nowrap gap-1", children: [
506
+ item.icon,
507
+ mode !== "compact" && /* @__PURE__ */ jsxRuntime.jsx(
508
+ "span",
509
+ {
510
+ style: {
511
+ WebkitLineClamp: 1,
512
+ WebkitBoxOrient: "vertical",
513
+ display: "-webkit-box",
514
+ overflow: "hidden"
515
+ },
516
+ children: item.renderLabel ? item.renderLabel("value-text") : item.label
517
+ }
518
+ )
519
+ ] })
520
+ ] });
521
+ }
522
+ return `${items.length} selected`;
523
+ })();
524
+ return /* @__PURE__ */ jsxRuntime.jsx(
525
+ RadixSelect__namespace.Value,
526
+ {
527
+ ref,
528
+ placeholder: placeholderText,
529
+ className: cn("flex flex-col justify-center min-w-0 truncate", className),
530
+ ...rest,
531
+ children: content
532
+ }
533
+ );
534
+ }
535
+ );
536
+ var SelectItemGroup = React2__namespace.forwardRef(
537
+ function SelectItemGroup2(props, ref) {
538
+ const { children, label, className, ...rest } = props;
539
+ return /* @__PURE__ */ jsxRuntime.jsxs(RadixSelect__namespace.Group, { ref, className: cn("py-1", className), ...rest, children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx(RadixSelect__namespace.Label, { className: "px-3 py-1.5 text-xs font-medium text-[var(--color-text-secondary)]", children: label }),
541
+ children
542
+ ] });
543
+ }
544
+ );
545
+ var SelectLabel = RadixSelect__namespace.Label;
546
+ var SelectItemText = RadixSelect__namespace.ItemText;
547
+ var Select = React2__namespace.forwardRef((props, ref) => {
548
+ const { collection, placeholder, portalled = true, loading, errorText, contentProps, contentHeader, itemFilter, mode, ...rest } = props;
549
+ return /* @__PURE__ */ jsxRuntime.jsxs(
550
+ SelectRoot,
551
+ {
552
+ ref,
553
+ collection,
554
+ ...rest,
555
+ children: [
556
+ /* @__PURE__ */ jsxRuntime.jsx(SelectControl, { loading, children: /* @__PURE__ */ jsxRuntime.jsx(
557
+ SelectValueText,
558
+ {
559
+ placeholder,
560
+ size: props.size,
561
+ required: props.required,
562
+ invalid: props.invalid,
563
+ errorText,
564
+ mode
565
+ }
566
+ ) }),
567
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { portalled, ...contentProps, children: [
568
+ contentHeader,
569
+ collection.items.filter(itemFilter ?? (() => true)).map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React2__namespace.Fragment, { children: [
570
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { item, children: item.renderLabel ? item.renderLabel("item") : item.label }),
571
+ item.afterElement
572
+ ] }, item.value))
573
+ ] })
574
+ ]
575
+ }
576
+ );
577
+ });
578
+ var SelectAsync = React2__namespace.forwardRef((props, ref) => {
579
+ const { placeholder, portalled = true, loading, loadOptions, extraControls, onValueChange, errorText, mode, contentHeader, ...rest } = props;
580
+ const [collection, setCollection] = React2__namespace.useState(createListCollection({ items: [] }));
581
+ const [inputValue, setInputValue] = React2__namespace.useState("");
582
+ const [value, setValue] = React2__namespace.useState([]);
583
+ const debouncedInputValue = usehooks.useDebounce(inputValue, 300);
584
+ React2__namespace.useEffect(() => {
585
+ loadOptions(debouncedInputValue, value).then(setCollection);
586
+ }, [debouncedInputValue, loadOptions, value]);
587
+ const handleFilterChange = React2__namespace.useCallback((val) => {
588
+ setInputValue(val);
589
+ }, []);
590
+ const handleValueChange = React2__namespace.useCallback(({ value: v, items }) => {
591
+ setValue(v);
592
+ onValueChange?.({ value: v, items });
593
+ }, [onValueChange]);
594
+ return /* @__PURE__ */ jsxRuntime.jsxs(
595
+ SelectRoot,
596
+ {
597
+ ref,
598
+ collection,
599
+ onValueChange: handleValueChange,
600
+ ...rest,
601
+ children: [
602
+ /* @__PURE__ */ jsxRuntime.jsx(SelectControl, { loading, children: /* @__PURE__ */ jsxRuntime.jsx(
603
+ SelectValueText,
604
+ {
605
+ placeholder,
606
+ size: props.size,
607
+ required: props.required,
608
+ invalid: props.invalid,
609
+ errorText,
610
+ mode
611
+ }
612
+ ) }),
613
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { portalled, children: [
614
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4", children: [
615
+ /* @__PURE__ */ jsxRuntime.jsx(
616
+ FilterInput,
617
+ {
618
+ placeholder: "Search",
619
+ initialValue: inputValue,
620
+ onChange: handleFilterChange
621
+ }
622
+ ),
623
+ extraControls
624
+ ] }),
625
+ contentHeader,
626
+ collection.items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { item, children: item.renderLabel ? item.renderLabel("item") : item.label }, item.value))
627
+ ] })
628
+ ]
629
+ }
630
+ );
631
+ });
632
+
633
+ exports.Select = Select;
634
+ exports.SelectAsync = SelectAsync;
635
+ exports.SelectClearTrigger = SelectClearTrigger;
636
+ exports.SelectContent = SelectContent;
637
+ exports.SelectControl = SelectControl;
638
+ exports.SelectItem = SelectItem;
639
+ exports.SelectItemGroup = SelectItemGroup;
640
+ exports.SelectItemText = SelectItemText;
641
+ exports.SelectLabel = SelectLabel;
642
+ exports.SelectRoot = SelectRoot;
643
+ exports.SelectValueText = SelectValueText;
644
+ exports.createListCollection = createListCollection;