@nexus-cross/design-system 1.0.14 → 1.1.1

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 (284) hide show
  1. package/claude-rules/nexus/CLAUDE.md +85 -0
  2. package/claude-rules/nexus/commands/nexus-audit.md +79 -0
  3. package/claude-rules/nexus/commands/nexus-component-map.md +85 -0
  4. package/claude-rules/nexus/commands/nexus-token-check.md +68 -0
  5. package/claude-rules/nexus/skills/nexus-design-system/SKILL.md +92 -0
  6. package/cursor-rules/nexus-ui-api.mdc +910 -41
  7. package/cursor-rules/nexus-ui-decisions.mdc +263 -0
  8. package/dist/accordion.js +0 -1
  9. package/dist/accordion.mjs +0 -1
  10. package/dist/alert.js +0 -1
  11. package/dist/alert.mjs +0 -1
  12. package/dist/avatar.js +0 -1
  13. package/dist/avatar.mjs +0 -1
  14. package/dist/badge.js +0 -1
  15. package/dist/badge.mjs +0 -1
  16. package/dist/breadcrumb.js +0 -1
  17. package/dist/breadcrumb.mjs +0 -1
  18. package/dist/button.js +0 -1
  19. package/dist/button.mjs +0 -1
  20. package/dist/carousel.js +0 -1
  21. package/dist/carousel.mjs +0 -1
  22. package/dist/checkbox.js +0 -1
  23. package/dist/checkbox.mjs +0 -1
  24. package/dist/chip.js +0 -1
  25. package/dist/chip.mjs +0 -1
  26. package/dist/chunks/chunk-2Z52NPWB.js +78 -0
  27. package/dist/chunks/chunk-3SCSND6S.js +7 -0
  28. package/dist/chunks/chunk-46P52MFM.mjs +56 -0
  29. package/dist/chunks/chunk-AG2UJPFX.mjs +621 -0
  30. package/dist/chunks/{chunk-33UFQJIO.mjs → chunk-BJMXZJWO.mjs} +16 -5
  31. package/dist/chunks/{chunk-YZV6FWE7.js → chunk-JLDQNDFT.js} +16 -5
  32. package/dist/chunks/{chunk-K574BYHQ.js → chunk-K3CK7NTP.js} +22 -4
  33. package/dist/chunks/{chunk-Z4YM7LU3.mjs → chunk-PIGHBDK5.mjs} +22 -4
  34. package/dist/chunks/chunk-QWK4CLS2.mjs +5 -0
  35. package/dist/chunks/chunk-RC2Y4UH7.js +648 -0
  36. package/dist/chunks/{chunk-PEIEVKD5.js → chunk-RCIBLLSF.js} +11 -12
  37. package/dist/chunks/{chunk-K2TBLM3F.mjs → chunk-THBE27U3.mjs} +11 -12
  38. package/dist/client-only.js +0 -1
  39. package/dist/client-only.mjs +0 -1
  40. package/dist/combobox.js +28 -0
  41. package/dist/combobox.mjs +3 -0
  42. package/dist/components/Combobox.d.ts +93 -0
  43. package/dist/components/Combobox.d.ts.map +1 -0
  44. package/dist/components/DataGrid.d.ts +44 -0
  45. package/dist/components/DataGrid.d.ts.map +1 -0
  46. package/dist/components/DataList.d.ts +3 -1
  47. package/dist/components/DataList.d.ts.map +1 -1
  48. package/dist/components/RadioGroup.d.ts +4 -0
  49. package/dist/components/RadioGroup.d.ts.map +1 -1
  50. package/dist/components/ToggleGroup.d.ts +2 -1
  51. package/dist/components/ToggleGroup.d.ts.map +1 -1
  52. package/dist/countdown.js +0 -1
  53. package/dist/countdown.mjs +0 -1
  54. package/dist/counter.js +0 -1
  55. package/dist/counter.mjs +0 -1
  56. package/dist/data-grid.js +14 -0
  57. package/dist/data-grid.mjs +5 -0
  58. package/dist/data-list.js +2 -3
  59. package/dist/data-list.mjs +1 -2
  60. package/dist/date-picker.js +0 -1
  61. package/dist/date-picker.mjs +0 -1
  62. package/dist/divider.js +0 -1
  63. package/dist/divider.mjs +0 -1
  64. package/dist/drawer.js +0 -1
  65. package/dist/drawer.mjs +0 -1
  66. package/dist/dropdown-menu.js +0 -1
  67. package/dist/dropdown-menu.mjs +0 -1
  68. package/dist/ellipsis.js +0 -1
  69. package/dist/ellipsis.mjs +0 -1
  70. package/dist/empty-state.js +0 -1
  71. package/dist/empty-state.mjs +0 -1
  72. package/dist/error-boundary.js +0 -1
  73. package/dist/error-boundary.mjs +0 -1
  74. package/dist/hooks/useCheckDevice.js +0 -1
  75. package/dist/hooks/useCheckDevice.mjs +0 -1
  76. package/dist/hooks/useClickOutside.js +0 -1
  77. package/dist/hooks/useClickOutside.mjs +0 -1
  78. package/dist/hooks/useDraggableBottomSheet.js +0 -1
  79. package/dist/hooks/useDraggableBottomSheet.mjs +0 -1
  80. package/dist/hooks/useDraggableWindow.js +0 -1
  81. package/dist/hooks/useDraggableWindow.mjs +0 -1
  82. package/dist/hooks/useInView.js +0 -1
  83. package/dist/hooks/useInView.mjs +0 -1
  84. package/dist/hooks/useModal.js +0 -1
  85. package/dist/hooks/useModal.mjs +0 -1
  86. package/dist/image-upload.js +0 -1
  87. package/dist/image-upload.mjs +0 -1
  88. package/dist/index.d.ts +4 -2
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +101 -85
  91. package/dist/index.mjs +11 -11
  92. package/dist/infinite-scroll.js +0 -1
  93. package/dist/infinite-scroll.mjs +0 -1
  94. package/dist/marquee.js +0 -1
  95. package/dist/marquee.mjs +0 -1
  96. package/dist/modal/index.js +11 -12
  97. package/dist/modal/index.mjs +2 -3
  98. package/dist/number-input.js +0 -1
  99. package/dist/number-input.mjs +0 -1
  100. package/dist/nx-image.js +0 -1
  101. package/dist/nx-image.mjs +0 -1
  102. package/dist/pagination.js +0 -1
  103. package/dist/pagination.mjs +0 -1
  104. package/dist/popover.js +0 -1
  105. package/dist/popover.mjs +0 -1
  106. package/dist/price-input.js +0 -1
  107. package/dist/price-input.mjs +0 -1
  108. package/dist/progress.js +0 -1
  109. package/dist/progress.mjs +0 -1
  110. package/dist/radio-group.js +5 -6
  111. package/dist/radio-group.mjs +1 -2
  112. package/dist/schemas/_all.json +353 -117
  113. package/dist/schemas/accordion.d.ts.map +1 -1
  114. package/dist/schemas/accordion.json +1 -1
  115. package/dist/schemas/alert.d.ts.map +1 -1
  116. package/dist/schemas/alert.json +1 -1
  117. package/dist/schemas/avatar.d.ts.map +1 -1
  118. package/dist/schemas/avatar.json +1 -1
  119. package/dist/schemas/badge.d.ts.map +1 -1
  120. package/dist/schemas/badge.json +1 -1
  121. package/dist/schemas/breadcrumb.d.ts.map +1 -1
  122. package/dist/schemas/breadcrumb.json +1 -1
  123. package/dist/schemas/button.d.ts.map +1 -1
  124. package/dist/schemas/button.json +1 -1
  125. package/dist/schemas/carousel.d.ts.map +1 -1
  126. package/dist/schemas/carousel.json +1 -1
  127. package/dist/schemas/checkBox.json +1 -1
  128. package/dist/schemas/checkbox.d.ts.map +1 -1
  129. package/dist/schemas/chip.d.ts.map +1 -1
  130. package/dist/schemas/chip.json +1 -1
  131. package/dist/schemas/client-only.d.ts.map +1 -1
  132. package/dist/schemas/clientOnly.json +1 -1
  133. package/dist/schemas/combobox.d.ts +108 -0
  134. package/dist/schemas/combobox.d.ts.map +1 -0
  135. package/dist/schemas/combobox.json +98 -0
  136. package/dist/schemas/comboboxOption.json +35 -0
  137. package/dist/schemas/comboboxOptionDescription.json +20 -0
  138. package/dist/schemas/comboboxOptionMeta.json +20 -0
  139. package/dist/schemas/countdown.d.ts.map +1 -1
  140. package/dist/schemas/countdown.json +1 -1
  141. package/dist/schemas/counter.d.ts.map +1 -1
  142. package/dist/schemas/counter.json +1 -1
  143. package/dist/schemas/data-grid.d.ts +74 -0
  144. package/dist/schemas/data-grid.d.ts.map +1 -0
  145. package/dist/schemas/data-list.d.ts.map +1 -1
  146. package/dist/schemas/dataGrid.json +102 -0
  147. package/dist/schemas/dataList.json +1 -1
  148. package/dist/schemas/date-picker.d.ts.map +1 -1
  149. package/dist/schemas/datePicker.json +1 -1
  150. package/dist/schemas/divider.d.ts.map +1 -1
  151. package/dist/schemas/divider.json +1 -1
  152. package/dist/schemas/drawer.d.ts.map +1 -1
  153. package/dist/schemas/drawer.json +1 -1
  154. package/dist/schemas/dropdown-menu.d.ts.map +1 -1
  155. package/dist/schemas/dropdownMenu.json +1 -1
  156. package/dist/schemas/ellipsis.d.ts.map +1 -1
  157. package/dist/schemas/ellipsis.json +1 -1
  158. package/dist/schemas/empty-state.d.ts.map +1 -1
  159. package/dist/schemas/emptyState.json +1 -1
  160. package/dist/schemas/error-boundary.d.ts.map +1 -1
  161. package/dist/schemas/errorBoundary.json +1 -1
  162. package/dist/schemas/image-upload.d.ts.map +1 -1
  163. package/dist/schemas/imageUpload.json +1 -1
  164. package/dist/schemas/index.d.ts +2 -1
  165. package/dist/schemas/index.d.ts.map +1 -1
  166. package/dist/schemas/infinite-scroll.d.ts.map +1 -1
  167. package/dist/schemas/infiniteScroll.json +1 -1
  168. package/dist/schemas/marquee.d.ts.map +1 -1
  169. package/dist/schemas/marquee.json +1 -1
  170. package/dist/schemas/modal.d.ts.map +1 -1
  171. package/dist/schemas/modalTemplate.json +1 -1
  172. package/dist/schemas/number-input.d.ts.map +1 -1
  173. package/dist/schemas/numberInput.json +1 -1
  174. package/dist/schemas/nx-image.d.ts.map +1 -1
  175. package/dist/schemas/nxImage.json +1 -1
  176. package/dist/schemas/pagination.d.ts.map +1 -1
  177. package/dist/schemas/pagination.json +1 -1
  178. package/dist/schemas/popover.d.ts.map +1 -1
  179. package/dist/schemas/popover.json +1 -1
  180. package/dist/schemas/price-input.d.ts.map +1 -1
  181. package/dist/schemas/priceInput.json +1 -1
  182. package/dist/schemas/progress.d.ts.map +1 -1
  183. package/dist/schemas/progress.json +1 -1
  184. package/dist/schemas/radio-group.d.ts +9 -0
  185. package/dist/schemas/radio-group.d.ts.map +1 -1
  186. package/dist/schemas/radioGroup.json +10 -1
  187. package/dist/schemas/radioItem.json +11 -0
  188. package/dist/schemas/select.d.ts.map +1 -1
  189. package/dist/schemas/select.json +1 -1
  190. package/dist/schemas/skeleton.d.ts.map +1 -1
  191. package/dist/schemas/skeleton.json +1 -1
  192. package/dist/schemas/slider.d.ts.map +1 -1
  193. package/dist/schemas/slider.json +1 -1
  194. package/dist/schemas/spinner.d.ts.map +1 -1
  195. package/dist/schemas/spinner.json +1 -1
  196. package/dist/schemas/stepper.d.ts.map +1 -1
  197. package/dist/schemas/stepper.json +1 -1
  198. package/dist/schemas/switch.d.ts.map +1 -1
  199. package/dist/schemas/switch.json +1 -1
  200. package/dist/schemas/tab.d.ts.map +1 -1
  201. package/dist/schemas/tab.json +1 -1
  202. package/dist/schemas/table.d.ts.map +1 -1
  203. package/dist/schemas/table.json +1 -1
  204. package/dist/schemas/tableRow.json +1 -1
  205. package/dist/schemas/tag-input.d.ts.map +1 -1
  206. package/dist/schemas/tagInput.json +1 -1
  207. package/dist/schemas/tdColumn.json +1 -1
  208. package/dist/schemas/text-area.d.ts.map +1 -1
  209. package/dist/schemas/text-input.d.ts +2 -2
  210. package/dist/schemas/text-input.d.ts.map +1 -1
  211. package/dist/schemas/textArea.json +1 -1
  212. package/dist/schemas/textInput.json +1 -1
  213. package/dist/schemas/toast.d.ts.map +1 -1
  214. package/dist/schemas/toastOptions.json +1 -1
  215. package/dist/schemas/toaster.json +1 -1
  216. package/dist/schemas/toggle-group.d.ts +6 -3
  217. package/dist/schemas/toggle-group.d.ts.map +1 -1
  218. package/dist/schemas/toggleGroup.json +9 -3
  219. package/dist/schemas/tooltip.d.ts.map +1 -1
  220. package/dist/schemas/tooltip.json +1 -1
  221. package/dist/schemas/virtual-scroll.d.ts.map +1 -1
  222. package/dist/schemas/virtualGrid.json +1 -1
  223. package/dist/schemas/virtualList.json +1 -1
  224. package/dist/schemas.js +928 -66
  225. package/dist/schemas.mjs +924 -66
  226. package/dist/select.js +0 -1
  227. package/dist/select.mjs +0 -1
  228. package/dist/skeleton.js +0 -1
  229. package/dist/skeleton.mjs +0 -1
  230. package/dist/slider.js +0 -1
  231. package/dist/slider.mjs +0 -1
  232. package/dist/spinner.js +0 -1
  233. package/dist/spinner.mjs +0 -1
  234. package/dist/stepper.js +0 -1
  235. package/dist/stepper.mjs +0 -1
  236. package/dist/styles/.generated/built.d.ts +1 -1
  237. package/dist/styles/.generated/built.d.ts.map +1 -1
  238. package/dist/styles/layer.js +2 -3
  239. package/dist/styles/layer.mjs +1 -2
  240. package/dist/styles.css +484 -13
  241. package/dist/styles.js +2 -3
  242. package/dist/styles.layered.css +484 -13
  243. package/dist/styles.mjs +1 -2
  244. package/dist/switch.js +0 -1
  245. package/dist/switch.mjs +0 -1
  246. package/dist/tab.js +0 -1
  247. package/dist/tab.mjs +0 -1
  248. package/dist/table.js +0 -1
  249. package/dist/table.mjs +0 -1
  250. package/dist/tag-input.js +0 -1
  251. package/dist/tag-input.mjs +0 -1
  252. package/dist/text-area.js +0 -1
  253. package/dist/text-area.mjs +0 -1
  254. package/dist/text-input.js +0 -1
  255. package/dist/text-input.mjs +0 -1
  256. package/dist/toast.js +0 -1
  257. package/dist/toast.mjs +0 -1
  258. package/dist/toggle-group.js +3 -4
  259. package/dist/toggle-group.mjs +1 -2
  260. package/dist/tooltip.js +0 -1
  261. package/dist/tooltip.mjs +0 -1
  262. package/dist/utils/cn.js +0 -1
  263. package/dist/utils/cn.mjs +0 -1
  264. package/dist/utils/scroll.js +0 -1
  265. package/dist/utils/scroll.mjs +0 -1
  266. package/dist/virtual-scroll.js +0 -1
  267. package/dist/virtual-scroll.mjs +0 -1
  268. package/package.json +14 -8
  269. package/scripts/setup-cursor-rules.cjs +164 -27
  270. package/dist/chunks/chunk-22ULI3BF.js +0 -21
  271. package/dist/chunks/chunk-CVYXRSXT.mjs +0 -8
  272. package/dist/chunks/chunk-I252NERB.mjs +0 -21
  273. package/dist/chunks/chunk-JNMCYWGY.js +0 -10
  274. package/dist/chunks/chunk-LAOQRXCE.js +0 -7
  275. package/dist/chunks/chunk-S6ODYMFP.mjs +0 -5
  276. package/dist/components/ThemeProvider.d.ts +0 -25
  277. package/dist/components/ThemeProvider.d.ts.map +0 -1
  278. package/dist/schemas/theme-provider.d.ts +0 -36
  279. package/dist/schemas/theme-provider.d.ts.map +0 -1
  280. package/dist/schemas/themeProvider.json +0 -65
  281. package/dist/theme-provider.js +0 -15
  282. package/dist/theme-provider.mjs +0 -2
  283. package/dist/chunks/{chunk-CWMLTXOH.mjs → chunk-5ZVPTIL3.mjs} +1 -1
  284. package/dist/chunks/{chunk-HFBTS42N.js → chunk-7F4SOLAC.js} +1 -1
@@ -0,0 +1,621 @@
1
+ import { Spinner } from './chunk-BPUQ2CO2.mjs';
2
+ import { cn } from './chunk-MCKOWMLS.mjs';
3
+ import * as React from 'react';
4
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
5
+ import { cva } from 'class-variance-authority';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+
8
+ var comboboxInputVariants = cva("nexus-combobox", {
9
+ variants: {
10
+ size: {
11
+ md: "nexus-combobox--md",
12
+ lg: "nexus-combobox--lg",
13
+ xl: "nexus-combobox--xl"
14
+ },
15
+ state: {
16
+ default: "nexus-combobox--default",
17
+ error: "nexus-combobox--error"
18
+ }
19
+ },
20
+ defaultVariants: { size: "md", state: "default" }
21
+ });
22
+ function ComboboxOption(_) {
23
+ return null;
24
+ }
25
+ ComboboxOption.displayName = "Combobox.Option";
26
+ function ComboboxOptionDescription(_) {
27
+ return null;
28
+ }
29
+ ComboboxOptionDescription.displayName = "Combobox.OptionDescription";
30
+ function ComboboxOptionMeta(_) {
31
+ return null;
32
+ }
33
+ ComboboxOptionMeta.displayName = "Combobox.OptionMeta";
34
+ function isElementOfType(node, type) {
35
+ return React.isValidElement(node) && node.type === type;
36
+ }
37
+ function extractText(node) {
38
+ if (node == null || typeof node === "boolean") return "";
39
+ if (typeof node === "string" || typeof node === "number") return String(node);
40
+ if (Array.isArray(node)) {
41
+ return node.map(extractText).filter(Boolean).join(" ");
42
+ }
43
+ if (React.isValidElement(node)) {
44
+ if (node.type === ComboboxOptionDescription || node.type === ComboboxOptionMeta) {
45
+ return "";
46
+ }
47
+ const children = node.props?.children;
48
+ return extractText(children);
49
+ }
50
+ return "";
51
+ }
52
+ function resolveOptionsFromChildren(children) {
53
+ const resolved = [];
54
+ const seenValues = /* @__PURE__ */ new Set();
55
+ React.Children.forEach(children, (child) => {
56
+ if (!React.isValidElement(child)) return;
57
+ if (child.type !== ComboboxOption) {
58
+ if (process.env.NODE_ENV !== "production") {
59
+ const name = typeof child.type === "string" ? child.type : child.type?.displayName ?? child.type?.name ?? "Unknown";
60
+ console.warn(
61
+ `[Combobox] Ignoring child <${name}>. Only <Combobox.Option> is allowed as a direct child of <Combobox>.`
62
+ );
63
+ }
64
+ return;
65
+ }
66
+ const props = child.props;
67
+ const value = props.value;
68
+ if (typeof value !== "string" || value.length === 0) {
69
+ if (process.env.NODE_ENV !== "production") {
70
+ console.error(
71
+ "[Combobox] <Combobox.Option> requires a non-empty string `value` prop."
72
+ );
73
+ }
74
+ return;
75
+ }
76
+ if (seenValues.has(value)) {
77
+ if (process.env.NODE_ENV !== "production") {
78
+ console.error(
79
+ `[Combobox] Duplicate option value: "${value}". Each <Combobox.Option> must have a unique \`value\`. The duplicate will be ignored.`
80
+ );
81
+ }
82
+ return;
83
+ }
84
+ seenValues.add(value);
85
+ const labelNodes = [];
86
+ let description = null;
87
+ let meta = null;
88
+ React.Children.forEach(props.children, (slot) => {
89
+ if (isElementOfType(slot, ComboboxOptionDescription)) {
90
+ description = slot.props.children;
91
+ return;
92
+ }
93
+ if (isElementOfType(slot, ComboboxOptionMeta)) {
94
+ meta = slot.props.children;
95
+ return;
96
+ }
97
+ labelNodes.push(slot);
98
+ });
99
+ const label = labelNodes.length === 1 ? labelNodes[0] : labelNodes;
100
+ const textValue = typeof props.textValue === "string" && props.textValue.length > 0 ? props.textValue : extractText(label);
101
+ resolved.push({
102
+ value,
103
+ disabled: !!props.disabled,
104
+ textValue,
105
+ className: props.className,
106
+ label,
107
+ description,
108
+ meta
109
+ });
110
+ });
111
+ return resolved;
112
+ }
113
+ var ChevronDown = ({ className }) => /* @__PURE__ */ jsx(
114
+ "svg",
115
+ {
116
+ className,
117
+ width: "16",
118
+ height: "16",
119
+ viewBox: "0 0 16 16",
120
+ fill: "none",
121
+ stroke: "currentColor",
122
+ strokeWidth: "2",
123
+ strokeLinecap: "round",
124
+ strokeLinejoin: "round",
125
+ "aria-hidden": true,
126
+ children: /* @__PURE__ */ jsx("path", { d: "M4 6l4 4 4-4" })
127
+ }
128
+ );
129
+ var ClearIcon = ({ className }) => /* @__PURE__ */ jsx(
130
+ "svg",
131
+ {
132
+ className,
133
+ width: "14",
134
+ height: "14",
135
+ viewBox: "0 0 14 14",
136
+ fill: "none",
137
+ stroke: "currentColor",
138
+ strokeWidth: "1.5",
139
+ strokeLinecap: "round",
140
+ "aria-hidden": true,
141
+ children: /* @__PURE__ */ jsx("path", { d: "M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5" })
142
+ }
143
+ );
144
+ var CloseIcon = ({ className }) => /* @__PURE__ */ jsx(
145
+ "svg",
146
+ {
147
+ className,
148
+ width: "12",
149
+ height: "12",
150
+ viewBox: "0 0 16 16",
151
+ fill: "none",
152
+ stroke: "currentColor",
153
+ strokeWidth: "2",
154
+ strokeLinecap: "round",
155
+ "aria-hidden": true,
156
+ children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8" })
157
+ }
158
+ );
159
+ function defaultFilter(option, query) {
160
+ if (!query) return true;
161
+ const haystack = option.textValue || option.value;
162
+ return haystack.toLowerCase().includes(query.toLowerCase());
163
+ }
164
+ function useDebouncedCallback(callback, delay) {
165
+ const cbRef = React.useRef(callback);
166
+ React.useEffect(() => {
167
+ cbRef.current = callback;
168
+ }, [callback]);
169
+ const timer = React.useRef(null);
170
+ React.useEffect(() => {
171
+ return () => {
172
+ if (timer.current) clearTimeout(timer.current);
173
+ };
174
+ }, []);
175
+ return React.useCallback(
176
+ (...args) => {
177
+ if (timer.current) clearTimeout(timer.current);
178
+ timer.current = setTimeout(() => cbRef.current?.(...args), delay);
179
+ },
180
+ [delay]
181
+ );
182
+ }
183
+ var ComboboxImpl = React.forwardRef(
184
+ function Combobox(props, ref) {
185
+ const {
186
+ children,
187
+ onSearch,
188
+ searchDebounce = 250,
189
+ loading = false,
190
+ filter,
191
+ placeholder,
192
+ emptyMessage = "\uAC80\uC0C9 \uACB0\uACFC \uC5C6\uC74C",
193
+ loadingMessage = "\uAC80\uC0C9 \uC911\u2026",
194
+ size,
195
+ disabled,
196
+ error,
197
+ clearable = true,
198
+ autoOpenOnFocus = true,
199
+ label,
200
+ description,
201
+ className,
202
+ popoverClassName,
203
+ id,
204
+ multiple,
205
+ value: controlledValue,
206
+ defaultValue,
207
+ onValueChange
208
+ } = props;
209
+ const isMultiple = !!multiple;
210
+ const fallbackId = React.useRef(
211
+ `nexus-cmbx-${Math.random().toString(36).slice(2, 9)}`
212
+ );
213
+ const inputId = id || fallbackId.current;
214
+ const listboxId = `${inputId}-listbox`;
215
+ const inputRef = React.useRef(null);
216
+ const anchorRef = React.useRef(null);
217
+ const setInputRef = React.useCallback(
218
+ (node) => {
219
+ inputRef.current = node;
220
+ if (typeof ref === "function") ref(node);
221
+ else if (ref)
222
+ ref.current = node;
223
+ },
224
+ [ref]
225
+ );
226
+ const isControlled = controlledValue !== void 0;
227
+ const initialInternal = React.useMemo(() => {
228
+ if (isMultiple) {
229
+ return Array.isArray(defaultValue) ? defaultValue : [];
230
+ }
231
+ return typeof defaultValue === "string" ? defaultValue : null;
232
+ }, [isMultiple, defaultValue]);
233
+ const [internalValue, setInternalValue] = React.useState(initialInternal);
234
+ const currentValue = isControlled ? controlledValue : internalValue;
235
+ const selectedValues = React.useMemo(() => {
236
+ if (isMultiple) return Array.isArray(currentValue) ? currentValue : [];
237
+ return typeof currentValue === "string" ? [currentValue] : [];
238
+ }, [isMultiple, currentValue]);
239
+ const updateValue = React.useCallback(
240
+ (next) => {
241
+ if (!isControlled) setInternalValue(next);
242
+ if (isMultiple) {
243
+ onValueChange?.(
244
+ next ?? []
245
+ );
246
+ } else {
247
+ onValueChange?.(
248
+ next ?? null
249
+ );
250
+ }
251
+ },
252
+ [isControlled, isMultiple, onValueChange]
253
+ );
254
+ const [open, setOpen] = React.useState(false);
255
+ const [query, setQuery] = React.useState("");
256
+ const [activeIndex, setActiveIndex] = React.useState(0);
257
+ const debouncedSearch = useDebouncedCallback(onSearch, searchDebounce);
258
+ const resolvedOptions = React.useMemo(
259
+ () => resolveOptionsFromChildren(children),
260
+ [children]
261
+ );
262
+ const visibleOptions = React.useMemo(() => {
263
+ if (onSearch) return resolvedOptions;
264
+ const filterFn = filter ?? defaultFilter;
265
+ return resolvedOptions.filter(
266
+ (o) => filterFn(
267
+ { value: o.value, textValue: o.textValue, disabled: o.disabled },
268
+ query
269
+ )
270
+ );
271
+ }, [onSearch, resolvedOptions, filter, query]);
272
+ React.useEffect(() => {
273
+ if (activeIndex >= visibleOptions.length) {
274
+ setActiveIndex(visibleOptions.length > 0 ? 0 : -1);
275
+ }
276
+ }, [visibleOptions, activeIndex]);
277
+ const handleInputChange = (e) => {
278
+ const next = e.target.value;
279
+ setQuery(next);
280
+ setOpen(true);
281
+ setActiveIndex(0);
282
+ if (onSearch) debouncedSearch(next);
283
+ };
284
+ const handleFocus = () => {
285
+ if (autoOpenOnFocus && !disabled) setOpen(true);
286
+ };
287
+ const selectOption = (option) => {
288
+ if (option.disabled) return;
289
+ if (isMultiple) {
290
+ const set = new Set(selectedValues);
291
+ if (set.has(option.value)) set.delete(option.value);
292
+ else set.add(option.value);
293
+ updateValue(Array.from(set));
294
+ setQuery("");
295
+ if (onSearch) debouncedSearch("");
296
+ inputRef.current?.focus();
297
+ } else {
298
+ updateValue(option.value);
299
+ const labelText = option.textValue || option.value;
300
+ setQuery(labelText);
301
+ setOpen(false);
302
+ inputRef.current?.blur();
303
+ }
304
+ };
305
+ const removeChip = (val) => {
306
+ if (!isMultiple) return;
307
+ updateValue(selectedValues.filter((v) => v !== val));
308
+ inputRef.current?.focus();
309
+ };
310
+ const clearAll = () => {
311
+ if (isMultiple) updateValue([]);
312
+ else updateValue(null);
313
+ setQuery("");
314
+ if (onSearch) debouncedSearch("");
315
+ inputRef.current?.focus();
316
+ };
317
+ const handleKeyDown = (e) => {
318
+ if (disabled) return;
319
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;
320
+ if (e.key === "ArrowDown") {
321
+ e.preventDefault();
322
+ if (!open) {
323
+ setOpen(true);
324
+ return;
325
+ }
326
+ if (visibleOptions.length === 0) return;
327
+ let next = activeIndex + 1;
328
+ while (next < visibleOptions.length && visibleOptions[next].disabled)
329
+ next++;
330
+ if (next < visibleOptions.length) setActiveIndex(next);
331
+ else setActiveIndex(visibleOptions.findIndex((o) => !o.disabled));
332
+ return;
333
+ }
334
+ if (e.key === "ArrowUp") {
335
+ e.preventDefault();
336
+ if (!open) {
337
+ setOpen(true);
338
+ return;
339
+ }
340
+ if (visibleOptions.length === 0) return;
341
+ let next = activeIndex - 1;
342
+ while (next >= 0 && visibleOptions[next].disabled) next--;
343
+ if (next >= 0) setActiveIndex(next);
344
+ else {
345
+ for (let i = visibleOptions.length - 1; i >= 0; i--) {
346
+ if (!visibleOptions[i].disabled) {
347
+ setActiveIndex(i);
348
+ break;
349
+ }
350
+ }
351
+ }
352
+ return;
353
+ }
354
+ if (e.key === "Home") {
355
+ e.preventDefault();
356
+ const idx = visibleOptions.findIndex((o) => !o.disabled);
357
+ if (idx >= 0) setActiveIndex(idx);
358
+ return;
359
+ }
360
+ if (e.key === "End") {
361
+ e.preventDefault();
362
+ for (let i = visibleOptions.length - 1; i >= 0; i--) {
363
+ if (!visibleOptions[i].disabled) {
364
+ setActiveIndex(i);
365
+ break;
366
+ }
367
+ }
368
+ return;
369
+ }
370
+ if (e.key === "Enter") {
371
+ if (open && activeIndex >= 0 && visibleOptions[activeIndex]) {
372
+ e.preventDefault();
373
+ selectOption(visibleOptions[activeIndex]);
374
+ }
375
+ return;
376
+ }
377
+ if (e.key === "Escape") {
378
+ if (open) {
379
+ e.preventDefault();
380
+ setOpen(false);
381
+ }
382
+ return;
383
+ }
384
+ if (e.key === "Backspace" && isMultiple && query === "" && selectedValues.length > 0) {
385
+ e.preventDefault();
386
+ removeChip(selectedValues[selectedValues.length - 1]);
387
+ }
388
+ };
389
+ const selectedOptionMap = React.useMemo(() => {
390
+ const map = /* @__PURE__ */ new Map();
391
+ for (const opt of resolvedOptions) map.set(opt.value, opt);
392
+ return map;
393
+ }, [resolvedOptions]);
394
+ const prevValueRef = React.useRef(
395
+ currentValue
396
+ );
397
+ React.useEffect(() => {
398
+ if (isMultiple) {
399
+ prevValueRef.current = currentValue;
400
+ return;
401
+ }
402
+ const valueChanged = prevValueRef.current !== currentValue;
403
+ prevValueRef.current = currentValue;
404
+ if (typeof currentValue !== "string") {
405
+ if (valueChanged) setQuery("");
406
+ return;
407
+ }
408
+ const opt = selectedOptionMap.get(currentValue);
409
+ const labelText = opt ? opt.textValue || currentValue : currentValue;
410
+ if (valueChanged) {
411
+ setQuery(labelText);
412
+ } else {
413
+ setQuery((prev) => prev === currentValue ? labelText : prev);
414
+ }
415
+ }, [isMultiple, currentValue, selectedOptionMap]);
416
+ const hasValue = isMultiple && selectedValues.length > 0 || !isMultiple && typeof currentValue === "string" && currentValue !== "";
417
+ const showClear = clearable && !disabled && (hasValue || query.length > 0);
418
+ const state = error ? "error" : "default";
419
+ const hasField = !!(label || description);
420
+ const inputBox = /* @__PURE__ */ jsxs(
421
+ "div",
422
+ {
423
+ ref: anchorRef,
424
+ className: cn(
425
+ comboboxInputVariants({ size, state }),
426
+ disabled && "nexus-combobox--disabled",
427
+ open && "nexus-combobox--open",
428
+ !hasField && className
429
+ ),
430
+ onClick: () => !disabled && inputRef.current?.focus(),
431
+ children: [
432
+ /* @__PURE__ */ jsxs("div", { className: "nexus-combobox__content", children: [
433
+ isMultiple && selectedValues.map((val) => {
434
+ const opt = selectedOptionMap.get(val);
435
+ const chipLabel = opt ? opt.label ?? opt.textValue ?? val : val;
436
+ return /* @__PURE__ */ jsxs("span", { className: "nexus-combobox__chip", children: [
437
+ /* @__PURE__ */ jsx("span", { className: "nexus-combobox__chip-label", children: chipLabel }),
438
+ !disabled && /* @__PURE__ */ jsx(
439
+ "button",
440
+ {
441
+ type: "button",
442
+ className: "nexus-combobox__chip-remove",
443
+ onClick: (e) => {
444
+ e.stopPropagation();
445
+ removeChip(val);
446
+ },
447
+ "aria-label": `Remove ${val}`,
448
+ tabIndex: -1,
449
+ children: /* @__PURE__ */ jsx(CloseIcon, { className: "nexus-combobox__chip-remove-icon" })
450
+ }
451
+ )
452
+ ] }, val);
453
+ }),
454
+ /* @__PURE__ */ jsx(
455
+ "input",
456
+ {
457
+ ref: setInputRef,
458
+ id: inputId,
459
+ type: "text",
460
+ role: "combobox",
461
+ autoComplete: "off",
462
+ spellCheck: false,
463
+ className: "nexus-combobox__input",
464
+ placeholder: isMultiple && selectedValues.length > 0 ? "" : placeholder,
465
+ value: query,
466
+ disabled,
467
+ "aria-expanded": open,
468
+ "aria-controls": listboxId,
469
+ "aria-autocomplete": "list",
470
+ "aria-activedescendant": open && activeIndex >= 0 && visibleOptions[activeIndex] ? `${inputId}-opt-${activeIndex}` : void 0,
471
+ "aria-invalid": error || void 0,
472
+ "aria-describedby": description ? `${inputId}-desc` : void 0,
473
+ onChange: handleInputChange,
474
+ onFocus: handleFocus,
475
+ onKeyDown: handleKeyDown
476
+ }
477
+ )
478
+ ] }),
479
+ /* @__PURE__ */ jsxs("div", { className: "nexus-combobox__suffix", children: [
480
+ loading && /* @__PURE__ */ jsx("span", { className: "nexus-combobox__icon nexus-combobox__icon--loading", children: /* @__PURE__ */ jsx(Spinner, { size: 16 }) }),
481
+ showClear && !loading && /* @__PURE__ */ jsx(
482
+ "button",
483
+ {
484
+ type: "button",
485
+ className: "nexus-combobox__clear",
486
+ onClick: (e) => {
487
+ e.stopPropagation();
488
+ clearAll();
489
+ },
490
+ tabIndex: -1,
491
+ "aria-label": "Clear",
492
+ children: /* @__PURE__ */ jsx(ClearIcon, {})
493
+ }
494
+ ),
495
+ /* @__PURE__ */ jsx(
496
+ "span",
497
+ {
498
+ className: cn(
499
+ "nexus-combobox__chevron",
500
+ open && "nexus-combobox__chevron--open"
501
+ ),
502
+ "aria-hidden": true,
503
+ children: /* @__PURE__ */ jsx(ChevronDown, {})
504
+ }
505
+ )
506
+ ] })
507
+ ]
508
+ }
509
+ );
510
+ const popoverBody = /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange: setOpen, children: [
511
+ /* @__PURE__ */ jsx(PopoverPrimitive.Anchor, { asChild: true, children: inputBox }),
512
+ /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
513
+ PopoverPrimitive.Content,
514
+ {
515
+ align: "start",
516
+ side: "bottom",
517
+ sideOffset: 4,
518
+ onOpenAutoFocus: (e) => e.preventDefault(),
519
+ onCloseAutoFocus: (e) => e.preventDefault(),
520
+ onPointerDownOutside: (e) => {
521
+ if (anchorRef.current && e.target instanceof Node && anchorRef.current.contains(e.target)) {
522
+ e.preventDefault();
523
+ }
524
+ },
525
+ onInteractOutside: (e) => {
526
+ if (anchorRef.current && e.target instanceof Node && anchorRef.current.contains(e.target)) {
527
+ e.preventDefault();
528
+ }
529
+ },
530
+ className: cn("nexus-combobox-popover", popoverClassName),
531
+ style: { width: "var(--radix-popover-trigger-width)" },
532
+ children: /* @__PURE__ */ jsx(
533
+ "div",
534
+ {
535
+ role: "listbox",
536
+ id: listboxId,
537
+ className: "nexus-combobox-listbox",
538
+ children: loading ? /* @__PURE__ */ jsxs("div", { className: "nexus-combobox-popover__status", children: [
539
+ /* @__PURE__ */ jsx(Spinner, { size: 16 }),
540
+ /* @__PURE__ */ jsx("span", { children: loadingMessage })
541
+ ] }) : visibleOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "nexus-combobox-popover__status", children: /* @__PURE__ */ jsx("span", { children: emptyMessage }) }) : visibleOptions.map((option, idx) => {
542
+ const selected = selectedValues.includes(option.value);
543
+ const active = idx === activeIndex;
544
+ return /* @__PURE__ */ jsxs(
545
+ "div",
546
+ {
547
+ id: `${inputId}-opt-${idx}`,
548
+ role: "option",
549
+ "aria-selected": selected,
550
+ "data-disabled": option.disabled || void 0,
551
+ "data-active": active || void 0,
552
+ "data-selected": selected || void 0,
553
+ className: cn(
554
+ "nexus-combobox-option",
555
+ active && "nexus-combobox-option--active",
556
+ selected && "nexus-combobox-option--selected",
557
+ option.disabled && "nexus-combobox-option--disabled",
558
+ option.className
559
+ ),
560
+ onMouseEnter: () => setActiveIndex(idx),
561
+ onMouseDown: (e) => {
562
+ e.preventDefault();
563
+ selectOption(option);
564
+ },
565
+ children: [
566
+ /* @__PURE__ */ jsxs("div", { className: "nexus-combobox-option__body", children: [
567
+ /* @__PURE__ */ jsx("div", { className: "nexus-combobox-option__label", children: option.label }),
568
+ option.description != null && /* @__PURE__ */ jsx("div", { className: "nexus-combobox-option__description", children: option.description })
569
+ ] }),
570
+ option.meta != null && /* @__PURE__ */ jsx("div", { className: "nexus-combobox-option__meta", children: option.meta }),
571
+ selected && /* @__PURE__ */ jsx(
572
+ "svg",
573
+ {
574
+ className: "nexus-combobox-option__check",
575
+ width: "14",
576
+ height: "14",
577
+ viewBox: "0 0 16 16",
578
+ fill: "none",
579
+ stroke: "currentColor",
580
+ strokeWidth: "2",
581
+ strokeLinecap: "round",
582
+ strokeLinejoin: "round",
583
+ "aria-hidden": true,
584
+ children: /* @__PURE__ */ jsx("path", { d: "M3 8l4 4 6-8" })
585
+ }
586
+ )
587
+ ]
588
+ },
589
+ option.value
590
+ );
591
+ })
592
+ }
593
+ )
594
+ }
595
+ ) })
596
+ ] });
597
+ if (!hasField) return popoverBody;
598
+ return /* @__PURE__ */ jsxs("div", { className: cn("nexus-combobox-field", className), children: [
599
+ label && /* @__PURE__ */ jsx("label", { className: "nexus-combobox-field__label", htmlFor: inputId, children: label }),
600
+ popoverBody,
601
+ description && /* @__PURE__ */ jsx(
602
+ "p",
603
+ {
604
+ id: `${inputId}-desc`,
605
+ className: cn(
606
+ "nexus-combobox-field__description",
607
+ error && "nexus-combobox-field__description--error"
608
+ ),
609
+ children: description
610
+ }
611
+ )
612
+ ] });
613
+ }
614
+ );
615
+ ComboboxImpl.displayName = "Combobox";
616
+ var Combobox2 = ComboboxImpl;
617
+ Combobox2.Option = ComboboxOption;
618
+ Combobox2.OptionDescription = ComboboxOptionDescription;
619
+ Combobox2.OptionMeta = ComboboxOptionMeta;
620
+
621
+ export { Combobox2 as Combobox, ComboboxOption, ComboboxOptionDescription, ComboboxOptionMeta, comboboxInputVariants };
@@ -32,6 +32,7 @@ var RadioGroup = React.forwardRef(
32
32
  value: controlledValue,
33
33
  defaultValue,
34
34
  size = "md",
35
+ variant = "default",
35
36
  disabled,
36
37
  onValueChange,
37
38
  children,
@@ -48,8 +49,8 @@ var RadioGroup = React.forwardRef(
48
49
  [isControlled, onValueChange]
49
50
  );
50
51
  const ctx = React.useMemo(
51
- () => ({ name, value, size, disabled, onValueChange: handleChange }),
52
- [name, value, size, disabled, handleChange]
52
+ () => ({ name, value, size, variant, disabled, onValueChange: handleChange }),
53
+ [name, value, size, variant, disabled, handleChange]
53
54
  );
54
55
  return /* @__PURE__ */ jsx(RadioGroupCtx.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
55
56
  "div",
@@ -69,16 +70,21 @@ var RadioItem = React.forwardRef(
69
70
  className,
70
71
  value,
71
72
  size: sizeProp,
73
+ variant: variantProp,
72
74
  disabled: disabledProp,
73
75
  label,
76
+ description,
74
77
  children,
75
78
  ...props
76
79
  }, ref) => {
77
80
  const ctx = React.useContext(RadioGroupCtx);
78
81
  const size = sizeProp ?? ctx.size ?? "md";
82
+ const variant = variantProp ?? ctx.variant ?? "default";
79
83
  const disabled = disabledProp ?? ctx.disabled;
80
84
  const checked = ctx.value === value;
81
85
  const content = label ?? children;
86
+ const hasDescription = description !== void 0 && description !== null && description !== false;
87
+ const isRing = variant === "ring";
82
88
  const handleChange = React.useCallback(() => {
83
89
  ctx.onValueChange?.(value);
84
90
  }, [ctx, value]);
@@ -88,6 +94,7 @@ var RadioItem = React.forwardRef(
88
94
  className: cn(
89
95
  radioItemVariants({ size }),
90
96
  disabled ? "nexus-radio-item--disabled" : "nexus-radio-item--pointer",
97
+ hasDescription && "nexus-radio-item--with-description",
91
98
  className
92
99
  ),
93
100
  children: [
@@ -109,11 +116,12 @@ var RadioItem = React.forwardRef(
109
116
  "span",
110
117
  {
111
118
  className: cn(
112
- size === "sm" ? "nexus-radio__circle--sm" : "nexus-radio__circle--md",
113
119
  "nexus-radio__circle",
120
+ size === "sm" ? "nexus-radio__circle--sm" : "nexus-radio__circle--md",
121
+ isRing && "nexus-radio__circle--ring",
114
122
  checked ? "nexus-radio__circle--checked" : "nexus-radio__circle--unchecked"
115
123
  ),
116
- children: checked && /* @__PURE__ */ jsx(
124
+ children: checked && !isRing && /* @__PURE__ */ jsx(
117
125
  "span",
118
126
  {
119
127
  className: cn(
@@ -124,7 +132,10 @@ var RadioItem = React.forwardRef(
124
132
  )
125
133
  }
126
134
  ),
127
- content && /* @__PURE__ */ jsx("span", { className: "nexus-radio__label", children: content })
135
+ (content || hasDescription) && /* @__PURE__ */ jsxs("span", { className: "nexus-radio__text", children: [
136
+ content && /* @__PURE__ */ jsx("span", { className: "nexus-radio__label", children: content }),
137
+ hasDescription && /* @__PURE__ */ jsx("span", { className: "nexus-radio__description", children: description })
138
+ ] })
128
139
  ]
129
140
  }
130
141
  );