@spark-ui/components 10.0.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 (296) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +19 -0
  4. package/dist/DialogTrigger-5SI4dvpK.d.mts +142 -0
  5. package/dist/DialogTrigger-5SI4dvpK.d.ts +142 -0
  6. package/dist/Input-g0LpWuv0.d.mts +17 -0
  7. package/dist/Input-g0LpWuv0.d.ts +17 -0
  8. package/dist/InputGroup-aoaZxCLk.d.mts +28 -0
  9. package/dist/InputGroup-aoaZxCLk.d.ts +28 -0
  10. package/dist/InputTrailingIcon-BBp7sE6D.d.mts +20 -0
  11. package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +20 -0
  12. package/dist/LabelRequiredIndicator-DRnCzHMU.d.mts +19 -0
  13. package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +19 -0
  14. package/dist/accordion/index.d.mts +85 -0
  15. package/dist/accordion/index.d.ts +85 -0
  16. package/dist/accordion/index.js +461 -0
  17. package/dist/accordion/index.js.map +1 -0
  18. package/dist/accordion/index.mjs +249 -0
  19. package/dist/accordion/index.mjs.map +1 -0
  20. package/dist/alert-dialog/index.d.mts +119 -0
  21. package/dist/alert-dialog/index.d.ts +119 -0
  22. package/dist/alert-dialog/index.js +1451 -0
  23. package/dist/alert-dialog/index.js.map +1 -0
  24. package/dist/alert-dialog/index.mjs +177 -0
  25. package/dist/alert-dialog/index.mjs.map +1 -0
  26. package/dist/badge/index.d.mts +47 -0
  27. package/dist/badge/index.d.ts +47 -0
  28. package/dist/badge/index.js +122 -0
  29. package/dist/badge/index.js.map +1 -0
  30. package/dist/badge/index.mjs +95 -0
  31. package/dist/badge/index.mjs.map +1 -0
  32. package/dist/breadcrumb/index.d.mts +64 -0
  33. package/dist/breadcrumb/index.d.ts +64 -0
  34. package/dist/breadcrumb/index.js +326 -0
  35. package/dist/breadcrumb/index.js.map +1 -0
  36. package/dist/breadcrumb/index.mjs +149 -0
  37. package/dist/breadcrumb/index.mjs.map +1 -0
  38. package/dist/button/index.d.mts +40 -0
  39. package/dist/button/index.d.ts +40 -0
  40. package/dist/button/index.js +877 -0
  41. package/dist/button/index.js.map +1 -0
  42. package/dist/button/index.mjs +10 -0
  43. package/dist/button/index.mjs.map +1 -0
  44. package/dist/carousel/index.d.mts +253 -0
  45. package/dist/carousel/index.d.ts +253 -0
  46. package/dist/carousel/index.js +1678 -0
  47. package/dist/carousel/index.js.map +1 -0
  48. package/dist/carousel/index.mjs +716 -0
  49. package/dist/carousel/index.mjs.map +1 -0
  50. package/dist/checkbox/index.d.mts +120 -0
  51. package/dist/checkbox/index.d.ts +120 -0
  52. package/dist/checkbox/index.js +873 -0
  53. package/dist/checkbox/index.js.map +1 -0
  54. package/dist/checkbox/index.mjs +349 -0
  55. package/dist/checkbox/index.mjs.map +1 -0
  56. package/dist/chip/index.d.mts +97 -0
  57. package/dist/chip/index.d.ts +97 -0
  58. package/dist/chip/index.js +905 -0
  59. package/dist/chip/index.js.map +1 -0
  60. package/dist/chip/index.mjs +793 -0
  61. package/dist/chip/index.mjs.map +1 -0
  62. package/dist/chunk-2KPFQEAA.mjs +52 -0
  63. package/dist/chunk-2KPFQEAA.mjs.map +1 -0
  64. package/dist/chunk-4F5DOL57.mjs +26 -0
  65. package/dist/chunk-4F5DOL57.mjs.map +1 -0
  66. package/dist/chunk-6JOA37TZ.mjs +742 -0
  67. package/dist/chunk-6JOA37TZ.mjs.map +1 -0
  68. package/dist/chunk-7PMPYEHJ.mjs +379 -0
  69. package/dist/chunk-7PMPYEHJ.mjs.map +1 -0
  70. package/dist/chunk-AESXFMCC.mjs +68 -0
  71. package/dist/chunk-AESXFMCC.mjs.map +1 -0
  72. package/dist/chunk-B42LOFIZ.mjs +308 -0
  73. package/dist/chunk-B42LOFIZ.mjs.map +1 -0
  74. package/dist/chunk-FGOZHKBT.mjs +97 -0
  75. package/dist/chunk-FGOZHKBT.mjs.map +1 -0
  76. package/dist/chunk-HLXYG643.mjs +52 -0
  77. package/dist/chunk-HLXYG643.mjs.map +1 -0
  78. package/dist/chunk-JKNBJHD5.mjs +601 -0
  79. package/dist/chunk-JKNBJHD5.mjs.map +1 -0
  80. package/dist/chunk-K7VP7DH3.mjs +66 -0
  81. package/dist/chunk-K7VP7DH3.mjs.map +1 -0
  82. package/dist/chunk-MUNDKRAE.mjs +80 -0
  83. package/dist/chunk-MUNDKRAE.mjs.map +1 -0
  84. package/dist/chunk-NBZKMCHF.mjs +36 -0
  85. package/dist/chunk-NBZKMCHF.mjs.map +1 -0
  86. package/dist/chunk-PZWESKAR.mjs +314 -0
  87. package/dist/chunk-PZWESKAR.mjs.map +1 -0
  88. package/dist/collapsible/index.d.mts +60 -0
  89. package/dist/collapsible/index.d.ts +60 -0
  90. package/dist/collapsible/index.js +140 -0
  91. package/dist/collapsible/index.js.map +1 -0
  92. package/dist/collapsible/index.mjs +8 -0
  93. package/dist/collapsible/index.mjs.map +1 -0
  94. package/dist/combobox/index.d.mts +285 -0
  95. package/dist/combobox/index.d.ts +285 -0
  96. package/dist/combobox/index.js +2920 -0
  97. package/dist/combobox/index.js.map +1 -0
  98. package/dist/combobox/index.mjs +1267 -0
  99. package/dist/combobox/index.mjs.map +1 -0
  100. package/dist/dialog/index.d.mts +33 -0
  101. package/dist/dialog/index.d.ts +33 -0
  102. package/dist/dialog/index.js +1286 -0
  103. package/dist/dialog/index.js.map +1 -0
  104. package/dist/dialog/index.mjs +13 -0
  105. package/dist/dialog/index.mjs.map +1 -0
  106. package/dist/divider/index.d.mts +61 -0
  107. package/dist/divider/index.d.ts +61 -0
  108. package/dist/divider/index.js +223 -0
  109. package/dist/divider/index.js.map +1 -0
  110. package/dist/divider/index.mjs +196 -0
  111. package/dist/divider/index.mjs.map +1 -0
  112. package/dist/drawer/index.d.mts +148 -0
  113. package/dist/drawer/index.d.ts +148 -0
  114. package/dist/drawer/index.js +1266 -0
  115. package/dist/drawer/index.js.map +1 -0
  116. package/dist/drawer/index.mjs +299 -0
  117. package/dist/drawer/index.mjs.map +1 -0
  118. package/dist/dropdown/index.d.mts +233 -0
  119. package/dist/dropdown/index.d.ts +233 -0
  120. package/dist/dropdown/index.js +2402 -0
  121. package/dist/dropdown/index.js.map +1 -0
  122. package/dist/dropdown/index.mjs +741 -0
  123. package/dist/dropdown/index.mjs.map +1 -0
  124. package/dist/form-field/index.d.mts +176 -0
  125. package/dist/form-field/index.d.ts +176 -0
  126. package/dist/form-field/index.js +540 -0
  127. package/dist/form-field/index.js.map +1 -0
  128. package/dist/form-field/index.mjs +13 -0
  129. package/dist/form-field/index.mjs.map +1 -0
  130. package/dist/icon/index.d.mts +28 -0
  131. package/dist/icon/index.d.ts +28 -0
  132. package/dist/icon/index.js +127 -0
  133. package/dist/icon/index.js.map +1 -0
  134. package/dist/icon/index.mjs +9 -0
  135. package/dist/icon/index.mjs.map +1 -0
  136. package/dist/icon-button/index.d.mts +16 -0
  137. package/dist/icon-button/index.d.ts +16 -0
  138. package/dist/icon-button/index.js +921 -0
  139. package/dist/icon-button/index.js.map +1 -0
  140. package/dist/icon-button/index.mjs +11 -0
  141. package/dist/icon-button/index.mjs.map +1 -0
  142. package/dist/input/index.d.mts +78 -0
  143. package/dist/input/index.d.ts +78 -0
  144. package/dist/input/index.js +1119 -0
  145. package/dist/input/index.js.map +1 -0
  146. package/dist/input/index.mjs +16 -0
  147. package/dist/input/index.mjs.map +1 -0
  148. package/dist/kbd/index.d.mts +9 -0
  149. package/dist/kbd/index.d.ts +9 -0
  150. package/dist/kbd/index.js +46 -0
  151. package/dist/kbd/index.js.map +1 -0
  152. package/dist/kbd/index.mjs +19 -0
  153. package/dist/kbd/index.mjs.map +1 -0
  154. package/dist/label/index.d.mts +11 -0
  155. package/dist/label/index.d.ts +11 -0
  156. package/dist/label/index.js +78 -0
  157. package/dist/label/index.js.map +1 -0
  158. package/dist/label/index.mjs +7 -0
  159. package/dist/label/index.mjs.map +1 -0
  160. package/dist/link-box/index.d.mts +34 -0
  161. package/dist/link-box/index.d.ts +34 -0
  162. package/dist/link-box/index.js +92 -0
  163. package/dist/link-box/index.js.map +1 -0
  164. package/dist/link-box/index.mjs +58 -0
  165. package/dist/link-box/index.mjs.map +1 -0
  166. package/dist/pagination/index.d.mts +143 -0
  167. package/dist/pagination/index.d.ts +143 -0
  168. package/dist/pagination/index.js +1303 -0
  169. package/dist/pagination/index.js.map +1 -0
  170. package/dist/pagination/index.mjs +326 -0
  171. package/dist/pagination/index.mjs.map +1 -0
  172. package/dist/popover/index.d.mts +93 -0
  173. package/dist/popover/index.d.ts +93 -0
  174. package/dist/popover/index.js +1280 -0
  175. package/dist/popover/index.js.map +1 -0
  176. package/dist/popover/index.mjs +13 -0
  177. package/dist/popover/index.mjs.map +1 -0
  178. package/dist/portal/index.d.mts +13 -0
  179. package/dist/portal/index.d.ts +13 -0
  180. package/dist/portal/index.js +37 -0
  181. package/dist/portal/index.js.map +1 -0
  182. package/dist/portal/index.mjs +10 -0
  183. package/dist/portal/index.mjs.map +1 -0
  184. package/dist/progress/index.d.mts +48 -0
  185. package/dist/progress/index.d.ts +48 -0
  186. package/dist/progress/index.js +201 -0
  187. package/dist/progress/index.js.map +1 -0
  188. package/dist/progress/index.mjs +174 -0
  189. package/dist/progress/index.mjs.map +1 -0
  190. package/dist/progress-tracker/index.d.mts +81 -0
  191. package/dist/progress-tracker/index.d.ts +81 -0
  192. package/dist/progress-tracker/index.js +834 -0
  193. package/dist/progress-tracker/index.js.map +1 -0
  194. package/dist/progress-tracker/index.mjs +716 -0
  195. package/dist/progress-tracker/index.mjs.map +1 -0
  196. package/dist/radio-group/index.d.mts +100 -0
  197. package/dist/radio-group/index.d.ts +100 -0
  198. package/dist/radio-group/index.js +824 -0
  199. package/dist/radio-group/index.js.map +1 -0
  200. package/dist/radio-group/index.mjs +297 -0
  201. package/dist/radio-group/index.mjs.map +1 -0
  202. package/dist/rating/index.d.mts +78 -0
  203. package/dist/rating/index.d.ts +78 -0
  204. package/dist/rating/index.js +362 -0
  205. package/dist/rating/index.js.map +1 -0
  206. package/dist/rating/index.mjs +247 -0
  207. package/dist/rating/index.mjs.map +1 -0
  208. package/dist/scrolling-list/index.d.mts +105 -0
  209. package/dist/scrolling-list/index.d.ts +105 -0
  210. package/dist/scrolling-list/index.js +1367 -0
  211. package/dist/scrolling-list/index.js.map +1 -0
  212. package/dist/scrolling-list/index.mjs +407 -0
  213. package/dist/scrolling-list/index.mjs.map +1 -0
  214. package/dist/select/index.d.mts +167 -0
  215. package/dist/select/index.d.ts +167 -0
  216. package/dist/select/index.js +991 -0
  217. package/dist/select/index.js.map +1 -0
  218. package/dist/select/index.mjs +470 -0
  219. package/dist/select/index.mjs.map +1 -0
  220. package/dist/skeleton/index.d.mts +67 -0
  221. package/dist/skeleton/index.d.ts +67 -0
  222. package/dist/skeleton/index.js +206 -0
  223. package/dist/skeleton/index.js.map +1 -0
  224. package/dist/skeleton/index.mjs +147 -0
  225. package/dist/skeleton/index.mjs.map +1 -0
  226. package/dist/slider/index.d.mts +97 -0
  227. package/dist/slider/index.d.ts +97 -0
  228. package/dist/slider/index.js +209 -0
  229. package/dist/slider/index.js.map +1 -0
  230. package/dist/slider/index.mjs +182 -0
  231. package/dist/slider/index.mjs.map +1 -0
  232. package/dist/slot/index.d.mts +17 -0
  233. package/dist/slot/index.d.ts +17 -0
  234. package/dist/slot/index.js +51 -0
  235. package/dist/slot/index.js.map +1 -0
  236. package/dist/slot/index.mjs +11 -0
  237. package/dist/slot/index.mjs.map +1 -0
  238. package/dist/snackbar/index.d.mts +158 -0
  239. package/dist/snackbar/index.d.ts +158 -0
  240. package/dist/snackbar/index.js +1693 -0
  241. package/dist/snackbar/index.js.map +1 -0
  242. package/dist/snackbar/index.mjs +733 -0
  243. package/dist/snackbar/index.mjs.map +1 -0
  244. package/dist/spinner/index.d.mts +21 -0
  245. package/dist/spinner/index.d.ts +21 -0
  246. package/dist/spinner/index.js +139 -0
  247. package/dist/spinner/index.js.map +1 -0
  248. package/dist/spinner/index.mjs +9 -0
  249. package/dist/spinner/index.mjs.map +1 -0
  250. package/dist/stepper/index.d.mts +82 -0
  251. package/dist/stepper/index.d.ts +82 -0
  252. package/dist/stepper/index.js +2178 -0
  253. package/dist/stepper/index.js.map +1 -0
  254. package/dist/stepper/index.mjs +229 -0
  255. package/dist/stepper/index.mjs.map +1 -0
  256. package/dist/switch/index.d.mts +64 -0
  257. package/dist/switch/index.d.ts +64 -0
  258. package/dist/switch/index.js +768 -0
  259. package/dist/switch/index.js.map +1 -0
  260. package/dist/switch/index.mjs +245 -0
  261. package/dist/switch/index.mjs.map +1 -0
  262. package/dist/tabs/index.d.mts +103 -0
  263. package/dist/tabs/index.d.ts +103 -0
  264. package/dist/tabs/index.js +1315 -0
  265. package/dist/tabs/index.js.map +1 -0
  266. package/dist/tabs/index.mjs +391 -0
  267. package/dist/tabs/index.mjs.map +1 -0
  268. package/dist/tag/index.d.mts +27 -0
  269. package/dist/tag/index.d.ts +27 -0
  270. package/dist/tag/index.js +269 -0
  271. package/dist/tag/index.js.map +1 -0
  272. package/dist/tag/index.mjs +237 -0
  273. package/dist/tag/index.mjs.map +1 -0
  274. package/dist/text-link/index.d.mts +20 -0
  275. package/dist/text-link/index.d.ts +20 -0
  276. package/dist/text-link/index.js +99 -0
  277. package/dist/text-link/index.js.map +1 -0
  278. package/dist/text-link/index.mjs +8 -0
  279. package/dist/text-link/index.mjs.map +1 -0
  280. package/dist/textarea/index.d.mts +47 -0
  281. package/dist/textarea/index.d.ts +47 -0
  282. package/dist/textarea/index.js +1180 -0
  283. package/dist/textarea/index.js.map +1 -0
  284. package/dist/textarea/index.mjs +77 -0
  285. package/dist/textarea/index.mjs.map +1 -0
  286. package/dist/visually-hidden/index.d.mts +16 -0
  287. package/dist/visually-hidden/index.d.ts +16 -0
  288. package/dist/visually-hidden/index.js +67 -0
  289. package/dist/visually-hidden/index.js.map +1 -0
  290. package/dist/visually-hidden/index.mjs +8 -0
  291. package/dist/visually-hidden/index.mjs.map +1 -0
  292. package/global.d.ts +12 -0
  293. package/package.json +75 -0
  294. package/tsconfig.build.json +9 -0
  295. package/tsconfig.json +9 -0
  296. package/tsup.config.ts +11 -0
@@ -0,0 +1,1180 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/textarea/index.ts
21
+ var textarea_exports = {};
22
+ __export(textarea_exports, {
23
+ Textarea: () => Textarea,
24
+ TextareaGroup: () => TextareaGroup2
25
+ });
26
+ module.exports = __toCommonJS(textarea_exports);
27
+
28
+ // src/input/InputClearButton.tsx
29
+ var import_DeleteOutline = require("@spark-ui/icons/DeleteOutline");
30
+ var import_class_variance_authority2 = require("class-variance-authority");
31
+
32
+ // src/icon/Icon.tsx
33
+ var import_react2 = require("react");
34
+
35
+ // src/slot/Slot.tsx
36
+ var import_radix_ui = require("radix-ui");
37
+ var import_react = require("react");
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var Slottable = import_radix_ui.Slot.Slottable;
40
+ var Slot = ({ ref, ...props }) => {
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
42
+ };
43
+
44
+ // src/visually-hidden/VisuallyHidden.tsx
45
+ var import_jsx_runtime2 = require("react/jsx-runtime");
46
+ var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
47
+ const Component = asChild ? Slot : "span";
48
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
49
+ Component,
50
+ {
51
+ ...props,
52
+ ref,
53
+ style: {
54
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
55
+ position: "absolute",
56
+ border: 0,
57
+ width: 1,
58
+ height: 1,
59
+ padding: 0,
60
+ margin: -1,
61
+ overflow: "hidden",
62
+ clip: "rect(0, 0, 0, 0)",
63
+ whiteSpace: "nowrap",
64
+ wordWrap: "normal",
65
+ ...props.style
66
+ }
67
+ }
68
+ );
69
+ };
70
+ VisuallyHidden.displayName = "VisuallyHidden";
71
+
72
+ // src/icon/Icon.styles.tsx
73
+ var import_internal_utils = require("@spark-ui/internal-utils");
74
+ var import_class_variance_authority = require("class-variance-authority");
75
+ var iconStyles = (0, import_class_variance_authority.cva)(["fill-current shrink-0"], {
76
+ variants: {
77
+ /**
78
+ * Color scheme of the icon.
79
+ */
80
+ intent: (0, import_internal_utils.makeVariants)({
81
+ current: ["text-current"],
82
+ main: ["text-main"],
83
+ support: ["text-support"],
84
+ accent: ["text-accent"],
85
+ basic: ["text-basic"],
86
+ success: ["text-success"],
87
+ alert: ["text-alert"],
88
+ error: ["text-error"],
89
+ info: ["text-info"],
90
+ neutral: ["text-neutral"]
91
+ }),
92
+ /**
93
+ * Sets the size of the icon.
94
+ */
95
+ size: (0, import_internal_utils.makeVariants)({
96
+ current: ["u-current-font-size"],
97
+ sm: ["w-sz-16", "h-sz-16"],
98
+ md: ["w-sz-24", "h-sz-24"],
99
+ lg: ["w-sz-32", "h-sz-32"],
100
+ xl: ["w-sz-40", "h-sz-40"]
101
+ })
102
+ }
103
+ });
104
+
105
+ // src/icon/Icon.tsx
106
+ var import_jsx_runtime3 = require("react/jsx-runtime");
107
+ var Icon = ({
108
+ label,
109
+ className,
110
+ size = "current",
111
+ intent = "current",
112
+ children,
113
+ ...others
114
+ }) => {
115
+ const child = import_react2.Children.only(children);
116
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
117
+ (0, import_react2.cloneElement)(child, {
118
+ className: iconStyles({ className, size, intent }),
119
+ "data-spark-component": "icon",
120
+ "aria-hidden": "true",
121
+ focusable: "false",
122
+ ...others
123
+ }),
124
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VisuallyHidden, { children: label })
125
+ ] });
126
+ };
127
+ Icon.displayName = "Icon";
128
+
129
+ // src/input/InputGroupContext.ts
130
+ var import_react3 = require("react");
131
+ var InputGroupContext = (0, import_react3.createContext)(null);
132
+ var useInputGroup = () => {
133
+ const context = (0, import_react3.useContext)(InputGroupContext);
134
+ return context || { isStandalone: true };
135
+ };
136
+
137
+ // src/input/InputClearButton.tsx
138
+ var import_jsx_runtime4 = require("react/jsx-runtime");
139
+ var Root = ({ className, tabIndex = -1, onClick, ref, ...others }) => {
140
+ const { onClear, hasTrailingIcon } = useInputGroup();
141
+ const handleClick = (event) => {
142
+ if (onClick) {
143
+ onClick(event);
144
+ }
145
+ if (onClear) {
146
+ onClear();
147
+ }
148
+ };
149
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
150
+ "button",
151
+ {
152
+ ref,
153
+ className: (0, import_class_variance_authority2.cx)(
154
+ className,
155
+ "pointer-events-auto absolute top-1/2 -translate-y-1/2",
156
+ "inline-flex h-full items-center justify-center outline-hidden",
157
+ "text-neutral hover:text-neutral-hovered",
158
+ hasTrailingIcon ? "right-3xl px-sz-12" : "pl-md pr-lg right-0"
159
+ ),
160
+ tabIndex,
161
+ onClick: handleClick,
162
+ type: "button",
163
+ ...others,
164
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_DeleteOutline.DeleteOutline, {}) })
165
+ }
166
+ );
167
+ };
168
+ var InputClearButton = Object.assign(Root, {
169
+ id: "ClearButton"
170
+ });
171
+ Root.displayName = "InputGroup.ClearButton";
172
+
173
+ // src/input/InputGroup.tsx
174
+ var import_use_combined_state = require("@spark-ui/use-combined-state");
175
+ var import_use_merge_refs = require("@spark-ui/use-merge-refs");
176
+ var import_react9 = require("react");
177
+
178
+ // src/form-field/FormField.tsx
179
+ var import_class_variance_authority3 = require("class-variance-authority");
180
+ var import_react6 = require("react");
181
+
182
+ // src/form-field/FormFieldContext.tsx
183
+ var import_react4 = require("react");
184
+ var FormFieldContext = (0, import_react4.createContext)(null);
185
+ var ID_PREFIX = ":form-field";
186
+ var useFormField = () => {
187
+ const context = (0, import_react4.useContext)(FormFieldContext);
188
+ if (!context) {
189
+ throw Error("useFormField must be used within a FormField provider");
190
+ }
191
+ return context;
192
+ };
193
+
194
+ // src/form-field/FormFieldProvider.tsx
195
+ var import_react5 = require("react");
196
+ var import_jsx_runtime5 = require("react/jsx-runtime");
197
+ var FormFieldProvider = ({
198
+ id,
199
+ name,
200
+ disabled = false,
201
+ readOnly = false,
202
+ state,
203
+ isRequired,
204
+ children
205
+ }) => {
206
+ const labelId = `${ID_PREFIX}-label-${(0, import_react5.useId)()}`;
207
+ const [messageIds, setMessageIds] = (0, import_react5.useState)([]);
208
+ const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
209
+ const handleMessageIdAdd = (0, import_react5.useCallback)((msgId) => {
210
+ setMessageIds((ids) => [...ids, msgId]);
211
+ }, []);
212
+ const handleMessageIdRemove = (0, import_react5.useCallback)((msgId) => {
213
+ setMessageIds((ids) => ids.filter((current) => current !== msgId));
214
+ }, []);
215
+ const value = (0, import_react5.useMemo)(() => {
216
+ const isInvalid = state === "error";
217
+ return {
218
+ id,
219
+ labelId,
220
+ name,
221
+ disabled,
222
+ readOnly,
223
+ state,
224
+ isRequired,
225
+ isInvalid,
226
+ description,
227
+ onMessageIdAdd: handleMessageIdAdd,
228
+ onMessageIdRemove: handleMessageIdRemove
229
+ };
230
+ }, [
231
+ id,
232
+ labelId,
233
+ name,
234
+ disabled,
235
+ readOnly,
236
+ description,
237
+ state,
238
+ isRequired,
239
+ handleMessageIdAdd,
240
+ handleMessageIdRemove
241
+ ]);
242
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormFieldContext.Provider, { value, children });
243
+ };
244
+ FormFieldProvider.displayName = "FormFieldProvider";
245
+
246
+ // src/form-field/FormField.tsx
247
+ var import_jsx_runtime6 = require("react/jsx-runtime");
248
+ var FormField = ({
249
+ className,
250
+ disabled = false,
251
+ readOnly = false,
252
+ name,
253
+ state,
254
+ isRequired = false,
255
+ asChild = false,
256
+ ref,
257
+ ...others
258
+ }) => {
259
+ const id = `${ID_PREFIX}-${(0, import_react6.useId)()}`;
260
+ const Component = asChild ? Slot : "div";
261
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
262
+ FormFieldProvider,
263
+ {
264
+ id,
265
+ name,
266
+ isRequired,
267
+ disabled,
268
+ readOnly,
269
+ state,
270
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
271
+ Component,
272
+ {
273
+ ref,
274
+ "data-spark-component": "form-field",
275
+ className: (0, import_class_variance_authority3.cx)(className, "gap-sm flex flex-col"),
276
+ ...others
277
+ }
278
+ )
279
+ }
280
+ );
281
+ };
282
+ FormField.displayName = "FormField";
283
+
284
+ // src/form-field/FormFieldStateMessage.tsx
285
+ var import_AlertOutline = require("@spark-ui/icons/AlertOutline");
286
+ var import_Check = require("@spark-ui/icons/Check");
287
+ var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
288
+ var import_class_variance_authority5 = require("class-variance-authority");
289
+
290
+ // src/form-field/FormFieldMessage.tsx
291
+ var import_class_variance_authority4 = require("class-variance-authority");
292
+ var import_react7 = require("react");
293
+ var import_jsx_runtime7 = require("react/jsx-runtime");
294
+ var FormFieldMessage = ({
295
+ id: idProp,
296
+ className,
297
+ ref,
298
+ ...others
299
+ }) => {
300
+ const { onMessageIdAdd, onMessageIdRemove } = useFormField();
301
+ const currentId = `${ID_PREFIX}-message-${(0, import_react7.useId)()}`;
302
+ const id = idProp || currentId;
303
+ (0, import_react7.useEffect)(() => {
304
+ onMessageIdAdd(id);
305
+ return () => {
306
+ onMessageIdRemove(id);
307
+ };
308
+ }, [id, onMessageIdAdd, onMessageIdRemove]);
309
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
310
+ "span",
311
+ {
312
+ ref,
313
+ id,
314
+ "data-spark-component": "form-field-message",
315
+ className: (0, import_class_variance_authority4.cx)(className, "text-caption"),
316
+ ...others
317
+ }
318
+ );
319
+ };
320
+ FormFieldMessage.displayName = "FormField.Message";
321
+
322
+ // src/form-field/FormFieldStateMessage.tsx
323
+ var import_jsx_runtime8 = require("react/jsx-runtime");
324
+ var FormFieldStateMessage = ({
325
+ className,
326
+ state,
327
+ children,
328
+ ref,
329
+ ...others
330
+ }) => {
331
+ const field = useFormField();
332
+ if (field.state !== state) {
333
+ return null;
334
+ }
335
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
336
+ FormFieldMessage,
337
+ {
338
+ ref,
339
+ "data-spark-component": "form-field-state-message",
340
+ "aria-live": "polite",
341
+ className: (0, import_class_variance_authority5.cx)(
342
+ "gap-sm flex items-center",
343
+ state === "error" ? "text-error" : "text-on-surface/dim-1",
344
+ className
345
+ ),
346
+ ...others,
347
+ children: [
348
+ state === "alert" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_WarningOutline.WarningOutline, {}) }),
349
+ state === "error" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_AlertOutline.AlertOutline, {}) }),
350
+ state === "success" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Check.Check, {}) }),
351
+ children
352
+ ]
353
+ }
354
+ );
355
+ };
356
+ FormFieldStateMessage.displayName = "FormField.StateMessage";
357
+
358
+ // src/form-field/FormFieldAlertMessage.tsx
359
+ var import_jsx_runtime9 = require("react/jsx-runtime");
360
+ var FormFieldAlertMessage = ({ ref, ...props }) => {
361
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
362
+ FormFieldStateMessage,
363
+ {
364
+ ref,
365
+ "data-spark-component": "form-field-alert-message",
366
+ state: "alert",
367
+ ...props
368
+ }
369
+ );
370
+ };
371
+ FormFieldAlertMessage.displayName = "FormField.AlertMessage";
372
+
373
+ // src/form-field/FormFieldCharactersCount.tsx
374
+ var import_class_variance_authority6 = require("class-variance-authority");
375
+ var import_jsx_runtime10 = require("react/jsx-runtime");
376
+ var FormFieldCharactersCount = ({
377
+ className,
378
+ value = "",
379
+ maxLength,
380
+ ref,
381
+ ...others
382
+ }) => {
383
+ const displayValue = `${value.length}/${maxLength}`;
384
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
385
+ "span",
386
+ {
387
+ ref,
388
+ "data-spark-component": "form-field-characters-count",
389
+ className: (0, import_class_variance_authority6.cx)(className, "text-caption", "text-neutral"),
390
+ ...others,
391
+ children: displayValue
392
+ }
393
+ );
394
+ };
395
+ FormFieldCharactersCount.displayName = "FormField.CharactersCount";
396
+
397
+ // src/form-field/FormFieldControl.tsx
398
+ var import_react8 = require("react");
399
+ var import_jsx_runtime11 = require("react/jsx-runtime");
400
+ var useFormFieldControl = () => {
401
+ const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = (0, import_react8.useContext)(FormFieldContext) || {};
402
+ return {
403
+ id,
404
+ name,
405
+ description,
406
+ disabled,
407
+ readOnly,
408
+ state,
409
+ labelId,
410
+ isInvalid,
411
+ isRequired
412
+ };
413
+ };
414
+ var FormFieldControl = ({ children }) => {
415
+ const props = useFormFieldControl();
416
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: children(props) });
417
+ };
418
+ FormFieldControl.displayName = "FormField.Control";
419
+
420
+ // src/form-field/FormFieldErrorMessage.tsx
421
+ var import_jsx_runtime12 = require("react/jsx-runtime");
422
+ var FormFieldErrorMessage = ({ ref, ...props }) => {
423
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
424
+ FormFieldStateMessage,
425
+ {
426
+ ref,
427
+ "data-spark-component": "form-field-error-message",
428
+ state: "error",
429
+ ...props
430
+ }
431
+ );
432
+ };
433
+ FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
434
+
435
+ // src/form-field/FormFieldHelperMessage.tsx
436
+ var import_class_variance_authority7 = require("class-variance-authority");
437
+ var import_jsx_runtime13 = require("react/jsx-runtime");
438
+ var FormFieldHelperMessage = ({
439
+ className,
440
+ ref,
441
+ ...others
442
+ }) => {
443
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
444
+ FormFieldMessage,
445
+ {
446
+ ref,
447
+ "data-spark-component": "form-field-helper-message",
448
+ className: (0, import_class_variance_authority7.cx)("text-on-surface/dim-1", className),
449
+ ...others
450
+ }
451
+ );
452
+ };
453
+ FormFieldHelperMessage.displayName = "FormField.HelperMessage";
454
+
455
+ // src/form-field/FormFieldLabel.tsx
456
+ var import_class_variance_authority11 = require("class-variance-authority");
457
+
458
+ // src/label/Label.tsx
459
+ var import_class_variance_authority8 = require("class-variance-authority");
460
+ var import_radix_ui2 = require("radix-ui");
461
+ var import_jsx_runtime14 = require("react/jsx-runtime");
462
+ var Label = ({ className, ref, ...others }) => {
463
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
464
+ import_radix_ui2.Label.Label,
465
+ {
466
+ ref,
467
+ "data-spark-component": "label",
468
+ className: (0, import_class_variance_authority8.cx)("text-body-1", className),
469
+ ...others
470
+ }
471
+ );
472
+ };
473
+ Label.displayName = "Label";
474
+
475
+ // src/label/LabelRequiredIndicator.tsx
476
+ var import_class_variance_authority9 = require("class-variance-authority");
477
+ var import_jsx_runtime15 = require("react/jsx-runtime");
478
+ var LabelRequiredIndicator = ({
479
+ className,
480
+ children = "*",
481
+ ref,
482
+ ...others
483
+ }) => {
484
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
485
+ "span",
486
+ {
487
+ ref,
488
+ "data-spark-component": "label-required-indicator",
489
+ role: "presentation",
490
+ "aria-hidden": "true",
491
+ className: (0, import_class_variance_authority9.cx)(className, "text-caption text-on-surface/dim-1"),
492
+ ...others,
493
+ children
494
+ }
495
+ );
496
+ };
497
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
498
+
499
+ // src/label/index.ts
500
+ var Label2 = Object.assign(Label, {
501
+ RequiredIndicator: LabelRequiredIndicator
502
+ });
503
+ Label2.displayName = "Label";
504
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
505
+
506
+ // src/form-field/FormFieldRequiredIndicator.tsx
507
+ var import_class_variance_authority10 = require("class-variance-authority");
508
+ var import_jsx_runtime16 = require("react/jsx-runtime");
509
+ var FormFieldRequiredIndicator = ({
510
+ className,
511
+ ref,
512
+ ...props
513
+ }) => {
514
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label2.RequiredIndicator, { ref, className: (0, import_class_variance_authority10.cx)("ml-sm", className), ...props });
515
+ };
516
+ FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
517
+
518
+ // src/form-field/FormFieldLabel.tsx
519
+ var import_jsx_runtime17 = require("react/jsx-runtime");
520
+ var FormFieldLabel = ({
521
+ htmlFor: htmlForProp,
522
+ className,
523
+ children,
524
+ requiredIndicator = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FormFieldRequiredIndicator, {}),
525
+ asChild,
526
+ ref,
527
+ ...others
528
+ }) => {
529
+ const control = useFormField();
530
+ const { disabled, labelId, isRequired } = control;
531
+ const htmlFor = asChild ? void 0 : htmlForProp || control.id;
532
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
533
+ Label2,
534
+ {
535
+ ref,
536
+ id: labelId,
537
+ "data-spark-component": "form-field-label",
538
+ htmlFor,
539
+ className: (0, import_class_variance_authority11.cx)(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
540
+ asChild,
541
+ ...others,
542
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
543
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slottable, { children }),
544
+ isRequired && requiredIndicator
545
+ ] })
546
+ }
547
+ );
548
+ };
549
+ FormFieldLabel.displayName = "FormField.Label";
550
+
551
+ // src/form-field/FormFieldSuccessMessage.tsx
552
+ var import_jsx_runtime18 = require("react/jsx-runtime");
553
+ var FormFieldSuccessMessage = ({ ref, ...props }) => {
554
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
555
+ FormFieldStateMessage,
556
+ {
557
+ ref,
558
+ "data-spark-component": "form-field-success-message",
559
+ state: "success",
560
+ ...props
561
+ }
562
+ );
563
+ };
564
+ FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
565
+
566
+ // src/form-field/index.ts
567
+ var FormField2 = Object.assign(FormField, {
568
+ Label: FormFieldLabel,
569
+ Control: FormFieldControl,
570
+ StateMessage: FormFieldStateMessage,
571
+ SuccessMessage: FormFieldSuccessMessage,
572
+ AlertMessage: FormFieldAlertMessage,
573
+ ErrorMessage: FormFieldErrorMessage,
574
+ HelperMessage: FormFieldHelperMessage,
575
+ RequiredIndicator: FormFieldRequiredIndicator,
576
+ CharactersCount: FormFieldCharactersCount
577
+ });
578
+ FormField2.displayName = "FormField";
579
+ FormFieldLabel.displayName = "FormField.Label";
580
+ FormFieldControl.displayName = "FormField.Control";
581
+ FormFieldStateMessage.displayName = "FormField.StateMessage";
582
+ FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
583
+ FormFieldAlertMessage.displayName = "FormField.AlertMessage";
584
+ FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
585
+ FormFieldHelperMessage.displayName = "FormField.HelperMessage";
586
+ FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
587
+ FormFieldCharactersCount.displayName = "FormField.CharactersCount";
588
+
589
+ // src/input/InputGroup.styles.ts
590
+ var import_class_variance_authority12 = require("class-variance-authority");
591
+ var inputGroupStyles = (0, import_class_variance_authority12.cva)(["relative inline-flex w-full"], {
592
+ variants: {
593
+ /**
594
+ * When `true`, prevents the user from interacting.
595
+ */
596
+ disabled: {
597
+ true: [
598
+ "cursor-not-allowed",
599
+ "relative",
600
+ "after:absolute",
601
+ "after:top-0",
602
+ "after:h-full",
603
+ "after:w-full",
604
+ "after:border-sm after:border-outline",
605
+ "after:rounded-lg"
606
+ ],
607
+ false: "after:hidden"
608
+ },
609
+ /**
610
+ * Sets the component as interactive or not.
611
+ */
612
+ readOnly: {
613
+ true: [
614
+ "relative",
615
+ "after:absolute",
616
+ "after:top-0",
617
+ "after:h-full",
618
+ "after:w-full",
619
+ "after:border-sm after:border-outline",
620
+ "after:rounded-lg"
621
+ ],
622
+ false: "after:hidden"
623
+ }
624
+ }
625
+ });
626
+
627
+ // src/input/InputGroup.tsx
628
+ var import_jsx_runtime19 = require("react/jsx-runtime");
629
+ var InputGroup = ({
630
+ className,
631
+ children: childrenProp,
632
+ state: stateProp,
633
+ disabled: disabledProp,
634
+ readOnly: readOnlyProp,
635
+ onClear,
636
+ ref: forwardedRef,
637
+ ...others
638
+ }) => {
639
+ const getElementId = (element) => {
640
+ return element ? element.type.id : "";
641
+ };
642
+ const findElement = (...values) => {
643
+ return children.find((child) => values.includes(getElementId(child) || ""));
644
+ };
645
+ const children = import_react9.Children.toArray(childrenProp).filter(import_react9.isValidElement);
646
+ const input = findElement("Input");
647
+ const props = input?.props || {};
648
+ const inputRef = (0, import_react9.useRef)(null);
649
+ const onClearRef = (0, import_react9.useRef)(onClear);
650
+ const ref = (0, import_use_merge_refs.useMergeRefs)(input?.ref, inputRef);
651
+ const [value, onChange] = (0, import_use_combined_state.useCombinedState)(
652
+ props.value,
653
+ props.defaultValue,
654
+ props.onValueChange
655
+ );
656
+ const field = useFormFieldControl();
657
+ const state = field.state ?? stateProp;
658
+ const disabled = field.disabled || !!disabledProp;
659
+ const readOnly = field.readOnly || !!readOnlyProp;
660
+ const leadingAddon = findElement("LeadingAddon");
661
+ const leadingIcon = findElement("LeadingIcon");
662
+ const clearButton = findElement("ClearButton");
663
+ const trailingIcon = findElement("TrailingIcon");
664
+ const trailingAddon = findElement("TrailingAddon");
665
+ const hasLeadingAddon = !!leadingAddon;
666
+ const hasTrailingAddon = !!trailingAddon;
667
+ const hasLeadingIcon = !!leadingIcon;
668
+ const hasTrailingIcon = !!trailingIcon;
669
+ const hasClearButton = !!value && !!clearButton && !disabled && !readOnly;
670
+ const handleChange = (event) => {
671
+ if (props.onChange) {
672
+ props.onChange(event);
673
+ }
674
+ onChange(event.target.value);
675
+ };
676
+ const handleClear = (0, import_react9.useCallback)(() => {
677
+ if (onClearRef.current) {
678
+ onClearRef.current();
679
+ }
680
+ onChange("");
681
+ inputRef.current.focus();
682
+ }, [onChange]);
683
+ const current = (0, import_react9.useMemo)(() => {
684
+ return {
685
+ state,
686
+ disabled,
687
+ readOnly,
688
+ hasLeadingIcon,
689
+ hasTrailingIcon,
690
+ hasLeadingAddon,
691
+ hasTrailingAddon,
692
+ hasClearButton,
693
+ onClear: handleClear
694
+ };
695
+ }, [
696
+ state,
697
+ disabled,
698
+ readOnly,
699
+ hasLeadingIcon,
700
+ hasTrailingIcon,
701
+ hasLeadingAddon,
702
+ hasTrailingAddon,
703
+ hasClearButton,
704
+ handleClear
705
+ ]);
706
+ (0, import_react9.useEffect)(() => {
707
+ onClearRef.current = onClear;
708
+ }, [onClear]);
709
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(InputGroupContext.Provider, { value: current, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
710
+ "div",
711
+ {
712
+ ref: forwardedRef,
713
+ className: inputGroupStyles({ disabled, readOnly, className }),
714
+ ...others,
715
+ children: [
716
+ hasLeadingAddon && leadingAddon,
717
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative inline-flex w-full", children: [
718
+ input && (0, import_react9.cloneElement)(input, {
719
+ ref,
720
+ defaultValue: void 0,
721
+ value: value ?? "",
722
+ onChange: handleChange
723
+ }),
724
+ leadingIcon,
725
+ hasClearButton && clearButton,
726
+ trailingIcon
727
+ ] }),
728
+ hasTrailingAddon && trailingAddon
729
+ ]
730
+ }
731
+ ) });
732
+ };
733
+ InputGroup.displayName = "InputGroup";
734
+
735
+ // src/input/InputLeadingAddon.tsx
736
+ var import_class_variance_authority14 = require("class-variance-authority");
737
+
738
+ // src/input/InputAddon.tsx
739
+ var import_react10 = require("react");
740
+
741
+ // src/input/InputAddon.styles.ts
742
+ var import_class_variance_authority13 = require("class-variance-authority");
743
+ var inputAddonStyles = (0, import_class_variance_authority13.cva)(
744
+ [
745
+ "overflow-hidden",
746
+ "border-sm",
747
+ "shrink-0",
748
+ "h-full",
749
+ "focus-visible:relative focus-visible:z-raised"
750
+ ],
751
+ {
752
+ variants: {
753
+ /**
754
+ * Change the component to the HTML tag or custom component of the only child.
755
+ */
756
+ asChild: { false: ["flex", "items-center", "px-lg"] },
757
+ intent: {
758
+ neutral: "border-outline",
759
+ error: "border-error",
760
+ alert: "border-alert",
761
+ success: "border-success"
762
+ },
763
+ /**
764
+ * Disable the input addon, preventing user interaction and adding opacity.
765
+ */
766
+ disabled: {
767
+ true: ["pointer-events-none border-outline!"]
768
+ },
769
+ /**
770
+ * Changes input addon styles based on the read only status from the input.
771
+ */
772
+ readOnly: {
773
+ true: ["pointer-events-none"]
774
+ },
775
+ /**
776
+ * Main style of the input addon.
777
+ */
778
+ design: {
779
+ text: "",
780
+ solid: "",
781
+ inline: ""
782
+ }
783
+ },
784
+ compoundVariants: [
785
+ {
786
+ disabled: false,
787
+ readOnly: false,
788
+ design: "text",
789
+ class: ["bg-surface", "text-on-surface"]
790
+ },
791
+ {
792
+ disabled: true,
793
+ design: "text",
794
+ class: ["text-on-surface/dim-3"]
795
+ },
796
+ {
797
+ disabled: true,
798
+ design: ["solid", "inline"],
799
+ class: ["opacity-dim-3"]
800
+ }
801
+ ],
802
+ defaultVariants: {
803
+ intent: "neutral"
804
+ }
805
+ }
806
+ );
807
+
808
+ // src/input/InputAddon.tsx
809
+ var import_jsx_runtime20 = require("react/jsx-runtime");
810
+ var InputAddon = ({
811
+ asChild: asChildProp,
812
+ className,
813
+ children,
814
+ ref,
815
+ ...others
816
+ }) => {
817
+ const { state, disabled, readOnly } = useInputGroup();
818
+ const isRawText = typeof children === "string";
819
+ const asChild = !!(isRawText ? false : asChildProp);
820
+ const child = isRawText ? children : import_react10.Children.only(children);
821
+ const Component = asChild && !isRawText ? Slot : "div";
822
+ const getDesign = () => {
823
+ if (isRawText) return "text";
824
+ return asChild ? "solid" : "inline";
825
+ };
826
+ const design = getDesign();
827
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
828
+ Component,
829
+ {
830
+ ref,
831
+ className: inputAddonStyles({
832
+ className,
833
+ intent: state,
834
+ disabled,
835
+ readOnly,
836
+ asChild,
837
+ design
838
+ }),
839
+ ...disabled && { tabIndex: -1 },
840
+ ...others,
841
+ children: child
842
+ }
843
+ );
844
+ };
845
+ InputAddon.displayName = "InputGroup.Addon";
846
+
847
+ // src/input/InputLeadingAddon.tsx
848
+ var import_jsx_runtime21 = require("react/jsx-runtime");
849
+ var Root2 = ({ className, ref, ...others }) => {
850
+ const { disabled, readOnly } = useInputGroup();
851
+ const isInactive = disabled || readOnly;
852
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: (0, import_class_variance_authority14.cx)("rounded-l-lg", isInactive ? "bg-on-surface/dim-5" : null), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
853
+ InputAddon,
854
+ {
855
+ ref,
856
+ className: (0, import_class_variance_authority14.cx)(className, "rounded-r-0! mr-[-1px] rounded-l-lg"),
857
+ ...others
858
+ }
859
+ ) });
860
+ };
861
+ var InputLeadingAddon = Object.assign(Root2, {
862
+ id: "LeadingAddon"
863
+ });
864
+ Root2.displayName = "InputGroup.LeadingAddon";
865
+
866
+ // src/input/InputLeadingIcon.tsx
867
+ var import_class_variance_authority16 = require("class-variance-authority");
868
+
869
+ // src/input/InputIcon.tsx
870
+ var import_class_variance_authority15 = require("class-variance-authority");
871
+ var import_jsx_runtime22 = require("react/jsx-runtime");
872
+ var InputIcon = ({ className, intent, children, ...others }) => {
873
+ const { disabled, readOnly } = useInputGroup();
874
+ const isInactive = disabled || readOnly;
875
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
876
+ Icon,
877
+ {
878
+ intent,
879
+ className: (0, import_class_variance_authority15.cx)(
880
+ className,
881
+ "pointer-events-none absolute top-[calc(var(--spacing-sz-44)/2)] -translate-y-1/2",
882
+ intent ? void 0 : "text-neutral peer-focus:text-outline-high",
883
+ isInactive ? "opacity-dim-3" : void 0
884
+ ),
885
+ ...others,
886
+ children
887
+ }
888
+ );
889
+ };
890
+ InputIcon.displayName = "InputGroup.Icon";
891
+
892
+ // src/input/InputLeadingIcon.tsx
893
+ var import_jsx_runtime23 = require("react/jsx-runtime");
894
+ var InputLeadingIcon = ({ className, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(InputIcon, { className: (0, import_class_variance_authority16.cx)(className, "left-lg text-body-1"), ...others });
895
+ InputLeadingIcon.id = "LeadingIcon";
896
+ InputLeadingIcon.displayName = "InputGroup.LeadingIcon";
897
+
898
+ // src/input/InputTrailingAddon.tsx
899
+ var import_class_variance_authority17 = require("class-variance-authority");
900
+ var import_jsx_runtime24 = require("react/jsx-runtime");
901
+ var Root3 = ({ className, ref, ...others }) => {
902
+ const { disabled, readOnly } = useInputGroup();
903
+ const isInactive = disabled || readOnly;
904
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: (0, import_class_variance_authority17.cx)("rounded-r-lg", isInactive ? "bg-on-surface/dim-5" : null), children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
905
+ InputAddon,
906
+ {
907
+ ref,
908
+ className: (0, import_class_variance_authority17.cx)(className, "rounded-l-0! ml-[-1px] rounded-r-lg"),
909
+ ...others
910
+ }
911
+ ) });
912
+ };
913
+ var InputTrailingAddon = Object.assign(Root3, {
914
+ id: "TrailingAddon"
915
+ });
916
+ Root3.displayName = "InputGroup.TrailingAddon";
917
+
918
+ // src/input/InputTrailingIcon.tsx
919
+ var import_class_variance_authority18 = require("class-variance-authority");
920
+ var import_jsx_runtime25 = require("react/jsx-runtime");
921
+ var InputTrailingIcon = ({ className, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(InputIcon, { className: (0, import_class_variance_authority18.cx)(className, "right-lg text-body-1"), ...others });
922
+ InputTrailingIcon.id = "TrailingIcon";
923
+ InputTrailingIcon.displayName = "InputGroup.TrailingIcon";
924
+
925
+ // src/input/Input.styles.ts
926
+ var import_class_variance_authority19 = require("class-variance-authority");
927
+ var inputStyles = (0, import_class_variance_authority19.cva)(
928
+ [
929
+ "relative",
930
+ "border-sm",
931
+ "peer",
932
+ "w-full",
933
+ "appearance-none outline-hidden",
934
+ "bg-surface",
935
+ "text-ellipsis text-body-1 text-on-surface",
936
+ "caret-neutral",
937
+ "autofill:shadow-surface autofill:shadow-[inset_0_0_0px_1000px]",
938
+ "disabled:cursor-not-allowed disabled:border-outline disabled:bg-on-surface/dim-5 disabled:text-on-surface/dim-3",
939
+ "read-only:cursor-default read-only:pointer-events-none read-only:bg-on-surface/dim-5",
940
+ "focus:ring-1 focus:ring-inset"
941
+ ],
942
+ {
943
+ variants: {
944
+ /**
945
+ * Change the component to the HTML tag or custom component of the only child.
946
+ */
947
+ asChild: {
948
+ true: ["min-h-sz-44"],
949
+ false: ["h-sz-44"]
950
+ },
951
+ /**
952
+ * Color scheme of the button.
953
+ */
954
+ intent: {
955
+ neutral: [
956
+ "border-outline",
957
+ "hover:border-outline-high",
958
+ "focus:ring-outline-high focus:border-outline-high"
959
+ ],
960
+ success: ["border-success", "focus:ring-success"],
961
+ alert: ["border-alert", "focus:ring-alert"],
962
+ error: ["border-error", "focus:ring-error"]
963
+ },
964
+ /**
965
+ * Sets if there is an addon before the input text.
966
+ */
967
+ hasLeadingAddon: {
968
+ true: ["rounded-l-0"],
969
+ false: ["rounded-l-lg"]
970
+ },
971
+ /**
972
+ * Sets if there is an addon after the input text.
973
+ */
974
+ hasTrailingAddon: {
975
+ true: ["rounded-r-0"],
976
+ false: ["rounded-r-lg"]
977
+ },
978
+ /**
979
+ * Sets if there is an icon before the input text.
980
+ */
981
+ hasLeadingIcon: {
982
+ true: ["pl-3xl"],
983
+ false: ["pl-lg"]
984
+ },
985
+ /**
986
+ * Sets if there is an icon after the input text.
987
+ */
988
+ hasTrailingIcon: { true: "" },
989
+ /**
990
+ * Sets if there is a button to clear the input text.
991
+ */
992
+ hasClearButton: { true: "" }
993
+ },
994
+ compoundVariants: [
995
+ {
996
+ hasTrailingIcon: false,
997
+ hasClearButton: false,
998
+ class: "pr-lg"
999
+ },
1000
+ {
1001
+ hasTrailingIcon: true,
1002
+ hasClearButton: false,
1003
+ class: "pr-3xl"
1004
+ },
1005
+ {
1006
+ hasTrailingIcon: false,
1007
+ hasClearButton: true,
1008
+ class: "pr-3xl"
1009
+ },
1010
+ {
1011
+ hasTrailingIcon: true,
1012
+ hasClearButton: true,
1013
+ class: "pr-[calc(var(--spacing-3xl)*2)]"
1014
+ }
1015
+ ],
1016
+ defaultVariants: {
1017
+ intent: "neutral"
1018
+ }
1019
+ }
1020
+ );
1021
+
1022
+ // src/input/Input.tsx
1023
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1024
+ var Root4 = ({
1025
+ className,
1026
+ asChild = false,
1027
+ onValueChange,
1028
+ onChange,
1029
+ onKeyDown,
1030
+ disabled: disabledProp,
1031
+ readOnly: readOnlyProp,
1032
+ ref,
1033
+ ...others
1034
+ }) => {
1035
+ const field = useFormFieldControl();
1036
+ const group = useInputGroup();
1037
+ const { id, name, isInvalid, isRequired, description } = field;
1038
+ const {
1039
+ hasLeadingAddon,
1040
+ hasTrailingAddon,
1041
+ hasLeadingIcon,
1042
+ hasTrailingIcon,
1043
+ hasClearButton,
1044
+ onClear
1045
+ } = group;
1046
+ const Component = asChild ? Slot : "input";
1047
+ const state = field.state || group.state;
1048
+ const disabled = field.disabled || group.disabled || disabledProp;
1049
+ const readOnly = field.readOnly || group.readOnly || readOnlyProp;
1050
+ const handleChange = (event) => {
1051
+ if (onChange) {
1052
+ onChange(event);
1053
+ }
1054
+ if (onValueChange) {
1055
+ onValueChange(event.target.value);
1056
+ }
1057
+ };
1058
+ const handleKeyDown = (event) => {
1059
+ if (onKeyDown) {
1060
+ onKeyDown(event);
1061
+ }
1062
+ if (hasClearButton && onClear && event.key === "Escape") {
1063
+ onClear();
1064
+ }
1065
+ };
1066
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1067
+ Component,
1068
+ {
1069
+ ref,
1070
+ id,
1071
+ name,
1072
+ className: inputStyles({
1073
+ asChild,
1074
+ className,
1075
+ intent: state,
1076
+ hasLeadingAddon: !!hasLeadingAddon,
1077
+ hasTrailingAddon: !!hasTrailingAddon,
1078
+ hasLeadingIcon: !!hasLeadingIcon,
1079
+ hasTrailingIcon: !!hasTrailingIcon,
1080
+ hasClearButton: !!hasClearButton
1081
+ }),
1082
+ disabled,
1083
+ readOnly,
1084
+ required: isRequired,
1085
+ "aria-describedby": description,
1086
+ "aria-invalid": isInvalid,
1087
+ onChange: handleChange,
1088
+ onKeyDown: handleKeyDown,
1089
+ ...others
1090
+ }
1091
+ );
1092
+ };
1093
+ var Input = Object.assign(Root4, {
1094
+ id: "Input"
1095
+ });
1096
+ Root4.displayName = "Input";
1097
+
1098
+ // src/input/index.ts
1099
+ var InputGroup2 = Object.assign(InputGroup, {
1100
+ LeadingAddon: InputLeadingAddon,
1101
+ TrailingAddon: InputTrailingAddon,
1102
+ LeadingIcon: InputLeadingIcon,
1103
+ TrailingIcon: InputTrailingIcon,
1104
+ ClearButton: InputClearButton
1105
+ });
1106
+ InputGroup2.displayName = "InputGroup";
1107
+ InputLeadingAddon.displayName = "InputGroup.LeadingAddon";
1108
+ InputTrailingAddon.displayName = "InputGroup.TrailingAddon";
1109
+ InputLeadingIcon.displayName = "InputGroup.LeadingIcon";
1110
+ InputTrailingIcon.displayName = "InputGroup.TrailingIcon";
1111
+ InputClearButton.displayName = "InputGroup.ClearButton";
1112
+
1113
+ // src/textarea/TextareaGroup.tsx
1114
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1115
+ var TextareaGroup = (props) => {
1116
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(InputGroup2, { ...props });
1117
+ };
1118
+ TextareaGroup.displayName = "TextareaGroup";
1119
+
1120
+ // src/textarea/TextareaLeadingIcon.tsx
1121
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1122
+ var TextareaLeadingIcon = (props) => {
1123
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(InputGroup2.LeadingIcon, { "data-spark-component": "textarea-group-leading-icon", ...props });
1124
+ };
1125
+ TextareaLeadingIcon.id = InputGroup2.LeadingIcon.id;
1126
+ TextareaLeadingIcon.displayName = "TextareaGroup.LeadingIcon";
1127
+
1128
+ // src/textarea/TextareaTrailingIcon.tsx
1129
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1130
+ var TextareaTrailingIcon = (props) => {
1131
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(InputGroup2.TrailingIcon, { "data-spark-component": "textarea-group-trailing-icon", ...props });
1132
+ };
1133
+ TextareaTrailingIcon.id = InputGroup2.TrailingIcon.id;
1134
+ TextareaTrailingIcon.displayName = "TextareaGroup.TrailingIcon";
1135
+
1136
+ // src/textarea/Textarea.tsx
1137
+ var import_class_variance_authority20 = require("class-variance-authority");
1138
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1139
+ var Root5 = ({
1140
+ className,
1141
+ disabled,
1142
+ rows = 1,
1143
+ isResizable = true,
1144
+ ref,
1145
+ ...others
1146
+ }) => {
1147
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1148
+ Input,
1149
+ {
1150
+ className: (0, import_class_variance_authority20.cx)(
1151
+ className,
1152
+ "py-[var(--spacing-sz-10)]",
1153
+ isResizable ? "resize-y" : "resize-none"
1154
+ ),
1155
+ "data-spark-component": "textarea",
1156
+ disabled,
1157
+ asChild: true,
1158
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("textarea", { ref, rows, ...others })
1159
+ }
1160
+ );
1161
+ };
1162
+ var Textarea = Object.assign(Root5, {
1163
+ id: Input.id
1164
+ });
1165
+ Root5.displayName = "Textarea";
1166
+
1167
+ // src/textarea/index.ts
1168
+ var TextareaGroup2 = Object.assign(TextareaGroup, {
1169
+ LeadingIcon: TextareaLeadingIcon,
1170
+ TrailingIcon: TextareaTrailingIcon
1171
+ });
1172
+ TextareaGroup2.displayName = "TextareaGroup";
1173
+ TextareaLeadingIcon.displayName = "TextareaGroup.LeadingIcon";
1174
+ TextareaTrailingIcon.displayName = "TextareaGroup.TrailingIcon";
1175
+ // Annotate the CommonJS export names for ESM import in node:
1176
+ 0 && (module.exports = {
1177
+ Textarea,
1178
+ TextareaGroup
1179
+ });
1180
+ //# sourceMappingURL=index.js.map