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