@spark-ui/components 11.0.1 → 11.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 (143) hide show
  1. package/dist/DialogTrigger-woU7vsJi.d.ts +142 -0
  2. package/dist/Input-N8AWWSmt.d.ts +41 -0
  3. package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +20 -0
  4. package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +19 -0
  5. package/dist/accordion/index.d.ts +73 -0
  6. package/dist/accordion/index.js +325 -0
  7. package/dist/accordion/index.js.map +1 -0
  8. package/dist/alert-dialog/index.d.ts +119 -0
  9. package/dist/alert-dialog/index.js +1554 -0
  10. package/dist/alert-dialog/index.js.map +1 -0
  11. package/dist/avatar/index.d.ts +66 -0
  12. package/dist/avatar/index.js +1303 -0
  13. package/dist/avatar/index.js.map +1 -0
  14. package/dist/badge/index.d.ts +47 -0
  15. package/dist/badge/index.js +122 -0
  16. package/dist/badge/index.js.map +1 -0
  17. package/dist/breadcrumb/index.d.ts +64 -0
  18. package/dist/breadcrumb/index.js +327 -0
  19. package/dist/breadcrumb/index.js.map +1 -0
  20. package/dist/button/index.d.ts +41 -0
  21. package/dist/button/index.js +935 -0
  22. package/dist/button/index.js.map +1 -0
  23. package/dist/card/index.d.ts +61 -0
  24. package/dist/card/index.js +502 -0
  25. package/dist/card/index.js.map +1 -0
  26. package/dist/carousel/index.d.ts +261 -0
  27. package/dist/carousel/index.js +1801 -0
  28. package/dist/carousel/index.js.map +1 -0
  29. package/dist/checkbox/index.d.ts +120 -0
  30. package/dist/checkbox/index.js +511 -0
  31. package/dist/checkbox/index.js.map +1 -0
  32. package/dist/chip/index.d.ts +97 -0
  33. package/dist/chip/index.js +908 -0
  34. package/dist/chip/index.js.map +1 -0
  35. package/dist/collapsible/index.d.ts +43 -0
  36. package/dist/collapsible/index.js +109 -0
  37. package/dist/collapsible/index.js.map +1 -0
  38. package/dist/combobox/index.d.ts +287 -0
  39. package/dist/combobox/index.js +2588 -0
  40. package/dist/combobox/index.js.map +1 -0
  41. package/dist/dialog/index.d.ts +33 -0
  42. package/dist/dialog/index.js +1389 -0
  43. package/dist/dialog/index.js.map +1 -0
  44. package/dist/divider/index.d.ts +61 -0
  45. package/dist/divider/index.js +224 -0
  46. package/dist/divider/index.js.map +1 -0
  47. package/dist/drawer/index.d.ts +152 -0
  48. package/dist/drawer/index.js +1400 -0
  49. package/dist/drawer/index.js.map +1 -0
  50. package/dist/dropdown/index.d.ts +233 -0
  51. package/dist/dropdown/index.js +2051 -0
  52. package/dist/dropdown/index.js.map +1 -0
  53. package/dist/form-field/index.d.ts +186 -0
  54. package/dist/form-field/index.js +553 -0
  55. package/dist/form-field/index.js.map +1 -0
  56. package/dist/icon/index.d.ts +28 -0
  57. package/dist/icon/index.js +127 -0
  58. package/dist/icon/index.js.map +1 -0
  59. package/dist/icon-button/index.d.ts +16 -0
  60. package/dist/icon-button/index.js +980 -0
  61. package/dist/icon-button/index.js.map +1 -0
  62. package/dist/input/index.d.ts +78 -0
  63. package/dist/input/index.js +724 -0
  64. package/dist/input/index.js.map +1 -0
  65. package/dist/kbd/index.d.ts +9 -0
  66. package/dist/kbd/index.js +47 -0
  67. package/dist/kbd/index.js.map +1 -0
  68. package/dist/label/index.d.ts +11 -0
  69. package/dist/label/index.js +78 -0
  70. package/dist/label/index.js.map +1 -0
  71. package/dist/link-box/index.d.ts +34 -0
  72. package/dist/link-box/index.js +92 -0
  73. package/dist/link-box/index.js.map +1 -0
  74. package/dist/pagination/index.d.ts +143 -0
  75. package/dist/pagination/index.js +1353 -0
  76. package/dist/pagination/index.js.map +1 -0
  77. package/dist/popover/index.d.ts +93 -0
  78. package/dist/popover/index.js +1339 -0
  79. package/dist/popover/index.js.map +1 -0
  80. package/dist/portal/index.d.ts +13 -0
  81. package/dist/portal/index.js +37 -0
  82. package/dist/portal/index.js.map +1 -0
  83. package/dist/progress/index.d.ts +48 -0
  84. package/dist/progress/index.js +223 -0
  85. package/dist/progress/index.js.map +1 -0
  86. package/dist/progress-tracker/index.d.ts +80 -0
  87. package/dist/progress-tracker/index.js +571 -0
  88. package/dist/progress-tracker/index.js.map +1 -0
  89. package/dist/radio-group/index.d.ts +100 -0
  90. package/dist/radio-group/index.js +318 -0
  91. package/dist/radio-group/index.js.map +1 -0
  92. package/dist/rating/index.d.ts +78 -0
  93. package/dist/rating/index.js +363 -0
  94. package/dist/rating/index.js.map +1 -0
  95. package/dist/scrolling-list/index.d.ts +118 -0
  96. package/dist/scrolling-list/index.js +1426 -0
  97. package/dist/scrolling-list/index.js.map +1 -0
  98. package/dist/segmented-gauge/index.d.ts +100 -0
  99. package/dist/segmented-gauge/index.js +277 -0
  100. package/dist/segmented-gauge/index.js.map +1 -0
  101. package/dist/select/index.d.ts +167 -0
  102. package/dist/select/index.js +581 -0
  103. package/dist/select/index.js.map +1 -0
  104. package/dist/skeleton/index.d.ts +67 -0
  105. package/dist/skeleton/index.js +206 -0
  106. package/dist/skeleton/index.js.map +1 -0
  107. package/dist/slider/index.d.ts +97 -0
  108. package/dist/slider/index.js +220 -0
  109. package/dist/slider/index.js.map +1 -0
  110. package/dist/slot/index.d.ts +16 -0
  111. package/dist/slot/index.js +51 -0
  112. package/dist/slot/index.js.map +1 -0
  113. package/dist/snackbar/index.d.ts +158 -0
  114. package/dist/snackbar/index.js +1756 -0
  115. package/dist/snackbar/index.js.map +1 -0
  116. package/dist/spinner/index.d.ts +21 -0
  117. package/dist/spinner/index.js +139 -0
  118. package/dist/spinner/index.js.map +1 -0
  119. package/dist/stepper/index.d.ts +81 -0
  120. package/dist/stepper/index.js +1847 -0
  121. package/dist/stepper/index.js.map +1 -0
  122. package/dist/switch/index.d.ts +64 -0
  123. package/dist/switch/index.js +327 -0
  124. package/dist/switch/index.js.map +1 -0
  125. package/dist/tabs/index.d.ts +103 -0
  126. package/dist/tabs/index.js +1376 -0
  127. package/dist/tabs/index.js.map +1 -0
  128. package/dist/tag/index.d.ts +29 -0
  129. package/dist/tag/index.js +283 -0
  130. package/dist/tag/index.js.map +1 -0
  131. package/dist/text-link/index.d.ts +20 -0
  132. package/dist/text-link/index.js +100 -0
  133. package/dist/text-link/index.js.map +1 -0
  134. package/dist/textarea/index.d.ts +57 -0
  135. package/dist/textarea/index.js +797 -0
  136. package/dist/textarea/index.js.map +1 -0
  137. package/dist/toast/index.d.ts +56 -0
  138. package/dist/toast/index.js +1412 -0
  139. package/dist/toast/index.js.map +1 -0
  140. package/dist/visually-hidden/index.d.ts +16 -0
  141. package/dist/visually-hidden/index.js +67 -0
  142. package/dist/visually-hidden/index.js.map +1 -0
  143. package/package.json +5 -5
@@ -0,0 +1,797 @@
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 = ({
140
+ className,
141
+ tabIndex = -1,
142
+ onClick,
143
+ inline = false,
144
+ ref,
145
+ ...others
146
+ }) => {
147
+ const { onClear, hasTrailingIcon } = useInputGroup();
148
+ const handleClick = (event) => {
149
+ if (onClick) {
150
+ onClick(event);
151
+ }
152
+ if (onClear) {
153
+ onClear();
154
+ }
155
+ };
156
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
157
+ "button",
158
+ {
159
+ ref,
160
+ "data-spark-component": "input-clear-button",
161
+ className: (0, import_class_variance_authority2.cx)(
162
+ className,
163
+ "pointer-events-auto absolute",
164
+ inline ? "h-sz-44 top-0 -translate-y-0" : "top-1/2 -translate-y-1/2",
165
+ "inline-flex h-full items-center justify-center outline-hidden",
166
+ "text-neutral hover:text-neutral-hovered",
167
+ hasTrailingIcon ? "right-3xl px-sz-12" : "pl-md pr-lg right-0"
168
+ ),
169
+ tabIndex,
170
+ onClick: handleClick,
171
+ type: "button",
172
+ ...others,
173
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_DeleteOutline.DeleteOutline, {}) })
174
+ }
175
+ );
176
+ };
177
+ var InputClearButton = Object.assign(Root, {
178
+ id: "ClearButton"
179
+ });
180
+ Root.displayName = "InputGroup.ClearButton";
181
+
182
+ // src/input/InputGroup.tsx
183
+ var import_form_field = require("@spark-ui/components/form-field");
184
+ var import_use_combined_state = require("@spark-ui/hooks/use-combined-state");
185
+ var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
186
+ var import_react4 = require("react");
187
+
188
+ // src/input/InputGroup.styles.ts
189
+ var import_class_variance_authority3 = require("class-variance-authority");
190
+ var inputGroupStyles = (0, import_class_variance_authority3.cva)(["relative inline-flex w-full"], {
191
+ variants: {
192
+ /**
193
+ * When `true`, prevents the user from interacting.
194
+ */
195
+ disabled: {
196
+ true: [
197
+ "cursor-not-allowed",
198
+ "relative",
199
+ "after:absolute",
200
+ "after:top-0",
201
+ "after:h-full",
202
+ "after:w-full",
203
+ "after:border-sm after:border-outline",
204
+ "after:rounded-lg"
205
+ ],
206
+ false: "after:hidden"
207
+ },
208
+ /**
209
+ * Sets the component as interactive or not.
210
+ */
211
+ readOnly: {
212
+ true: [
213
+ "relative",
214
+ "after:absolute",
215
+ "after:top-0",
216
+ "after:h-full",
217
+ "after:w-full",
218
+ "after:border-sm after:border-outline",
219
+ "after:rounded-lg"
220
+ ],
221
+ false: "after:hidden"
222
+ }
223
+ }
224
+ });
225
+
226
+ // src/input/InputGroup.tsx
227
+ var import_jsx_runtime5 = require("react/jsx-runtime");
228
+ var InputGroup = ({
229
+ className,
230
+ children: childrenProp,
231
+ state: stateProp,
232
+ disabled: disabledProp,
233
+ readOnly: readOnlyProp,
234
+ onClear,
235
+ ref: forwardedRef,
236
+ ...others
237
+ }) => {
238
+ const getElementId = (element) => {
239
+ return element ? element.type.id : "";
240
+ };
241
+ const findElement = (...values) => {
242
+ return children.find((child) => values.includes(getElementId(child) || ""));
243
+ };
244
+ const children = import_react4.Children.toArray(childrenProp).filter(import_react4.isValidElement);
245
+ const input = findElement("Input");
246
+ const props = input?.props || {};
247
+ const inputRef = (0, import_react4.useRef)(null);
248
+ const onClearRef = (0, import_react4.useRef)(onClear);
249
+ const ref = (0, import_use_merge_refs.useMergeRefs)(input?.ref, inputRef);
250
+ const [value, onChange] = (0, import_use_combined_state.useCombinedState)(
251
+ props.value,
252
+ props.defaultValue,
253
+ props.onValueChange
254
+ );
255
+ const field = (0, import_form_field.useFormFieldControl)();
256
+ const state = field.state ?? stateProp;
257
+ const disabled = field.disabled || !!disabledProp;
258
+ const readOnly = field.readOnly || !!readOnlyProp;
259
+ const leadingAddon = findElement("LeadingAddon");
260
+ const leadingIcon = findElement("LeadingIcon");
261
+ const clearButton = findElement("ClearButton");
262
+ const trailingIcon = findElement("TrailingIcon");
263
+ const trailingAddon = findElement("TrailingAddon");
264
+ const hasLeadingAddon = !!leadingAddon;
265
+ const hasTrailingAddon = !!trailingAddon;
266
+ const hasLeadingIcon = !!leadingIcon;
267
+ const hasTrailingIcon = !!trailingIcon;
268
+ const hasClearButton = !!value && !!clearButton && !disabled && !readOnly;
269
+ const handleChange = (event) => {
270
+ if (props.onChange) {
271
+ props.onChange(event);
272
+ }
273
+ onChange(event.target.value);
274
+ };
275
+ const handleClear = (0, import_react4.useCallback)(() => {
276
+ if (onClearRef.current) {
277
+ onClearRef.current();
278
+ }
279
+ onChange("");
280
+ inputRef.current.focus();
281
+ }, [onChange]);
282
+ const current = (0, import_react4.useMemo)(() => {
283
+ return {
284
+ state,
285
+ disabled,
286
+ readOnly,
287
+ hasLeadingIcon,
288
+ hasTrailingIcon,
289
+ hasLeadingAddon,
290
+ hasTrailingAddon,
291
+ hasClearButton,
292
+ onClear: handleClear
293
+ };
294
+ }, [
295
+ state,
296
+ disabled,
297
+ readOnly,
298
+ hasLeadingIcon,
299
+ hasTrailingIcon,
300
+ hasLeadingAddon,
301
+ hasTrailingAddon,
302
+ hasClearButton,
303
+ handleClear
304
+ ]);
305
+ (0, import_react4.useEffect)(() => {
306
+ onClearRef.current = onClear;
307
+ }, [onClear]);
308
+ const inputRefValue = inputRef.current?.value;
309
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InputGroupContext.Provider, { value: current, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
310
+ "div",
311
+ {
312
+ "data-spark-component": "input-group",
313
+ ref: forwardedRef,
314
+ className: inputGroupStyles({ disabled, readOnly, className }),
315
+ ...others,
316
+ children: [
317
+ hasLeadingAddon && leadingAddon,
318
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative inline-flex w-full", children: [
319
+ input && (0, import_react4.cloneElement)(input, {
320
+ value: value ?? inputRefValue ?? "",
321
+ ref,
322
+ defaultValue: void 0,
323
+ onChange: handleChange
324
+ }),
325
+ leadingIcon,
326
+ hasClearButton && clearButton,
327
+ trailingIcon
328
+ ] }),
329
+ hasTrailingAddon && trailingAddon
330
+ ]
331
+ }
332
+ ) });
333
+ };
334
+ InputGroup.displayName = "InputGroup";
335
+
336
+ // src/input/InputLeadingAddon.tsx
337
+ var import_class_variance_authority5 = require("class-variance-authority");
338
+
339
+ // src/input/InputAddon.tsx
340
+ var import_react5 = require("react");
341
+
342
+ // src/input/InputAddon.styles.ts
343
+ var import_class_variance_authority4 = require("class-variance-authority");
344
+ var inputAddonStyles = (0, import_class_variance_authority4.cva)(
345
+ [
346
+ "overflow-hidden",
347
+ "border-sm",
348
+ "shrink-0",
349
+ "h-full",
350
+ "focus-visible:relative focus-visible:z-raised",
351
+ "mx-0"
352
+ ],
353
+ {
354
+ variants: {
355
+ /**
356
+ * Change the component to the HTML tag or custom component of the only child.
357
+ */
358
+ asChild: { false: ["flex", "items-center", "px-lg"] },
359
+ intent: {
360
+ neutral: "border-outline",
361
+ error: "border-error",
362
+ alert: "border-alert",
363
+ success: "border-success"
364
+ },
365
+ /**
366
+ * Disable the input addon, preventing user interaction and adding opacity.
367
+ */
368
+ disabled: {
369
+ true: ["pointer-events-none border-outline!"]
370
+ },
371
+ /**
372
+ * Changes input addon styles based on the read only status from the input.
373
+ */
374
+ readOnly: {
375
+ true: ["pointer-events-none"]
376
+ },
377
+ /**
378
+ * Main style of the input addon.
379
+ */
380
+ design: {
381
+ text: "",
382
+ solid: "",
383
+ inline: ""
384
+ }
385
+ },
386
+ compoundVariants: [
387
+ {
388
+ disabled: false,
389
+ readOnly: false,
390
+ design: "text",
391
+ class: ["bg-surface", "text-on-surface"]
392
+ },
393
+ {
394
+ disabled: true,
395
+ design: "text",
396
+ class: ["text-on-surface/dim-3"]
397
+ },
398
+ {
399
+ disabled: true,
400
+ design: ["solid", "inline"],
401
+ class: ["opacity-dim-3"]
402
+ }
403
+ ],
404
+ defaultVariants: {
405
+ intent: "neutral"
406
+ }
407
+ }
408
+ );
409
+
410
+ // src/input/InputAddon.tsx
411
+ var import_jsx_runtime6 = require("react/jsx-runtime");
412
+ var InputAddon = ({
413
+ asChild: asChildProp,
414
+ className,
415
+ children,
416
+ ref,
417
+ ...others
418
+ }) => {
419
+ const { state, disabled, readOnly } = useInputGroup();
420
+ const isRawText = typeof children === "string";
421
+ const asChild = !!(isRawText ? false : asChildProp);
422
+ const child = isRawText ? children : import_react5.Children.only(children);
423
+ const Component = asChild && !isRawText ? Slot : "div";
424
+ const getDesign = () => {
425
+ if (isRawText) return "text";
426
+ return asChild ? "solid" : "inline";
427
+ };
428
+ const design = getDesign();
429
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
430
+ Component,
431
+ {
432
+ ref,
433
+ "data-spark-component": "input-addon",
434
+ className: inputAddonStyles({
435
+ className,
436
+ intent: state,
437
+ disabled,
438
+ readOnly,
439
+ asChild,
440
+ design
441
+ }),
442
+ ...disabled && { tabIndex: -1 },
443
+ ...others,
444
+ children: child
445
+ }
446
+ );
447
+ };
448
+ InputAddon.displayName = "InputGroup.Addon";
449
+
450
+ // src/input/InputLeadingAddon.tsx
451
+ var import_jsx_runtime7 = require("react/jsx-runtime");
452
+ var Root2 = ({ className, ref, ...others }) => {
453
+ const { disabled, readOnly } = useInputGroup();
454
+ const isInactive = disabled || readOnly;
455
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_class_variance_authority5.cx)("rounded-l-lg", isInactive ? "bg-on-surface/dim-5" : null), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
456
+ InputAddon,
457
+ {
458
+ ref,
459
+ className: (0, import_class_variance_authority5.cx)(className, "rounded-r-0! mr-[-1px] rounded-l-lg"),
460
+ ...others
461
+ }
462
+ ) });
463
+ };
464
+ var InputLeadingAddon = Object.assign(Root2, {
465
+ id: "LeadingAddon"
466
+ });
467
+ Root2.displayName = "InputGroup.LeadingAddon";
468
+
469
+ // src/input/InputLeadingIcon.tsx
470
+ var import_class_variance_authority7 = require("class-variance-authority");
471
+
472
+ // src/input/InputIcon.tsx
473
+ var import_class_variance_authority6 = require("class-variance-authority");
474
+ var import_jsx_runtime8 = require("react/jsx-runtime");
475
+ var InputIcon = ({ className, intent, children, ...others }) => {
476
+ const { disabled, readOnly } = useInputGroup();
477
+ const isInactive = disabled || readOnly;
478
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
479
+ Icon,
480
+ {
481
+ "data-spark-component": "input-icon",
482
+ intent,
483
+ className: (0, import_class_variance_authority6.cx)(
484
+ className,
485
+ "pointer-events-none absolute top-[calc(var(--spacing-sz-44)/2)] -translate-y-1/2",
486
+ intent ? void 0 : "text-neutral peer-focus:text-outline-high",
487
+ isInactive ? "opacity-dim-3" : void 0
488
+ ),
489
+ ...others,
490
+ children
491
+ }
492
+ );
493
+ };
494
+ InputIcon.displayName = "InputGroup.Icon";
495
+
496
+ // src/input/InputLeadingIcon.tsx
497
+ var import_jsx_runtime9 = require("react/jsx-runtime");
498
+ var InputLeadingIcon = ({ className, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InputIcon, { className: (0, import_class_variance_authority7.cx)(className, "left-lg text-body-1"), ...others });
499
+ InputLeadingIcon.id = "LeadingIcon";
500
+ InputLeadingIcon.displayName = "InputGroup.LeadingIcon";
501
+
502
+ // src/input/InputTrailingAddon.tsx
503
+ var import_class_variance_authority8 = require("class-variance-authority");
504
+ var import_jsx_runtime10 = require("react/jsx-runtime");
505
+ var Root3 = ({ className, ref, ...others }) => {
506
+ const { disabled, readOnly } = useInputGroup();
507
+ const isInactive = disabled || readOnly;
508
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: (0, import_class_variance_authority8.cx)("rounded-r-lg", isInactive ? "bg-on-surface/dim-5" : null), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
509
+ InputAddon,
510
+ {
511
+ ref,
512
+ className: (0, import_class_variance_authority8.cx)(className, "rounded-l-0! ml-[-1px] rounded-r-lg"),
513
+ ...others
514
+ }
515
+ ) });
516
+ };
517
+ var InputTrailingAddon = Object.assign(Root3, {
518
+ id: "TrailingAddon"
519
+ });
520
+ Root3.displayName = "InputGroup.TrailingAddon";
521
+
522
+ // src/input/InputTrailingIcon.tsx
523
+ var import_class_variance_authority9 = require("class-variance-authority");
524
+ var import_jsx_runtime11 = require("react/jsx-runtime");
525
+ var InputTrailingIcon = ({ className, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InputIcon, { className: (0, import_class_variance_authority9.cx)(className, "right-lg text-body-1"), ...others });
526
+ InputTrailingIcon.id = "TrailingIcon";
527
+ InputTrailingIcon.displayName = "InputGroup.TrailingIcon";
528
+
529
+ // src/input/Input.tsx
530
+ var import_form_field2 = require("@spark-ui/components/form-field");
531
+
532
+ // src/input/Input.styles.ts
533
+ var import_class_variance_authority10 = require("class-variance-authority");
534
+ var inputStyles = (0, import_class_variance_authority10.cva)(
535
+ [
536
+ "relative",
537
+ "border-sm",
538
+ "peer",
539
+ "w-full",
540
+ "appearance-none outline-hidden",
541
+ "bg-surface",
542
+ "text-ellipsis text-body-1 text-on-surface",
543
+ "caret-neutral",
544
+ "[&:-webkit-autofill]:[-webkit-text-fill-color:var(--color-on-surface)]",
545
+ "autofill:shadow-surface autofill:shadow-[inset_0_0_0px_1000px]",
546
+ "disabled:cursor-not-allowed disabled:border-outline disabled:bg-on-surface/dim-5 disabled:text-on-surface/dim-3",
547
+ "read-only:cursor-default read-only:pointer-events-none read-only:bg-on-surface/dim-5",
548
+ "focus:ring-1 focus:ring-inset focus:ring-focus focus:border-focus"
549
+ ],
550
+ {
551
+ variants: {
552
+ /**
553
+ * Change the component to the HTML tag or custom component of the only child.
554
+ */
555
+ asChild: {
556
+ true: ["min-h-sz-44"],
557
+ false: ["h-sz-44"]
558
+ },
559
+ /**
560
+ * Color scheme of the button.
561
+ */
562
+ intent: {
563
+ neutral: ["border-outline", "default:hover:border-outline-high"],
564
+ success: ["default:border-success"],
565
+ alert: ["default:border-alert"],
566
+ error: ["default:border-error"]
567
+ },
568
+ /**
569
+ * Sets if there is an addon before the input text.
570
+ */
571
+ hasLeadingAddon: {
572
+ true: ["rounded-l-0"],
573
+ false: ["rounded-l-lg"]
574
+ },
575
+ /**
576
+ * Sets if there is an addon after the input text.
577
+ */
578
+ hasTrailingAddon: {
579
+ true: ["rounded-r-0"],
580
+ false: ["rounded-r-lg"]
581
+ },
582
+ /**
583
+ * Sets if there is an icon before the input text.
584
+ */
585
+ hasLeadingIcon: {
586
+ true: ["pl-3xl"],
587
+ false: ["pl-lg"]
588
+ },
589
+ /**
590
+ * Sets if there is an icon after the input text.
591
+ */
592
+ hasTrailingIcon: { true: "" },
593
+ /**
594
+ * Sets if there is a button to clear the input text.
595
+ */
596
+ hasClearButton: { true: "" }
597
+ },
598
+ compoundVariants: [
599
+ {
600
+ hasTrailingIcon: false,
601
+ hasClearButton: false,
602
+ class: "pr-lg"
603
+ },
604
+ {
605
+ hasTrailingIcon: true,
606
+ hasClearButton: false,
607
+ class: "pr-3xl"
608
+ },
609
+ {
610
+ hasTrailingIcon: false,
611
+ hasClearButton: true,
612
+ class: "pr-3xl"
613
+ },
614
+ {
615
+ hasTrailingIcon: true,
616
+ hasClearButton: true,
617
+ class: "pr-[calc(var(--spacing-3xl)*2)]"
618
+ }
619
+ ],
620
+ defaultVariants: {
621
+ intent: "neutral"
622
+ }
623
+ }
624
+ );
625
+
626
+ // src/input/Input.tsx
627
+ var import_jsx_runtime12 = require("react/jsx-runtime");
628
+ var Root4 = ({
629
+ className,
630
+ asChild = false,
631
+ onValueChange,
632
+ onChange,
633
+ onKeyDown,
634
+ disabled: disabledProp,
635
+ readOnly: readOnlyProp,
636
+ ref,
637
+ ...others
638
+ }) => {
639
+ const field = (0, import_form_field2.useFormFieldControl)();
640
+ const group = useInputGroup();
641
+ const { id, name, isInvalid, isRequired, description } = field;
642
+ const {
643
+ hasLeadingAddon,
644
+ hasTrailingAddon,
645
+ hasLeadingIcon,
646
+ hasTrailingIcon,
647
+ hasClearButton,
648
+ onClear
649
+ } = group;
650
+ const Component = asChild ? Slot : "input";
651
+ const state = field.state || group.state;
652
+ const disabled = field.disabled || group.disabled || disabledProp;
653
+ const readOnly = field.readOnly || group.readOnly || readOnlyProp;
654
+ const handleChange = (event) => {
655
+ if (onChange) {
656
+ onChange(event);
657
+ }
658
+ if (onValueChange) {
659
+ onValueChange(event.target.value);
660
+ }
661
+ };
662
+ const handleKeyDown = (event) => {
663
+ if (onKeyDown) {
664
+ onKeyDown(event);
665
+ }
666
+ if (hasClearButton && onClear && event.key === "Escape") {
667
+ onClear();
668
+ }
669
+ };
670
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
671
+ Component,
672
+ {
673
+ "data-spark-component": "input",
674
+ ref,
675
+ id,
676
+ name,
677
+ className: inputStyles({
678
+ asChild,
679
+ className,
680
+ intent: state,
681
+ hasLeadingAddon: !!hasLeadingAddon,
682
+ hasTrailingAddon: !!hasTrailingAddon,
683
+ hasLeadingIcon: !!hasLeadingIcon,
684
+ hasTrailingIcon: !!hasTrailingIcon,
685
+ hasClearButton: !!hasClearButton
686
+ }),
687
+ disabled,
688
+ readOnly,
689
+ required: isRequired,
690
+ "aria-describedby": description,
691
+ "aria-invalid": isInvalid,
692
+ onChange: handleChange,
693
+ onKeyDown: handleKeyDown,
694
+ ...others
695
+ }
696
+ );
697
+ };
698
+ var Input = Object.assign(Root4, {
699
+ id: "Input"
700
+ });
701
+ Root4.displayName = "Input";
702
+
703
+ // src/input/index.ts
704
+ var InputGroup2 = Object.assign(InputGroup, {
705
+ LeadingAddon: InputLeadingAddon,
706
+ TrailingAddon: InputTrailingAddon,
707
+ LeadingIcon: InputLeadingIcon,
708
+ TrailingIcon: InputTrailingIcon,
709
+ ClearButton: InputClearButton
710
+ });
711
+ InputGroup2.displayName = "InputGroup";
712
+ InputLeadingAddon.displayName = "InputGroup.LeadingAddon";
713
+ InputTrailingAddon.displayName = "InputGroup.TrailingAddon";
714
+ InputLeadingIcon.displayName = "InputGroup.LeadingIcon";
715
+ InputTrailingIcon.displayName = "InputGroup.TrailingIcon";
716
+ InputClearButton.displayName = "InputGroup.ClearButton";
717
+
718
+ // src/textarea/TextareaClearButton.tsx
719
+ var import_jsx_runtime13 = require("react/jsx-runtime");
720
+ var TextareaClearButton = (props) => {
721
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InputGroup2.ClearButton, { inline: true, "data-spark-component": "textarea-group-trailing-icon", ...props });
722
+ };
723
+ TextareaClearButton.id = InputGroup2.ClearButton.id;
724
+ TextareaClearButton.displayName = "TextareaGroup.ClearButton";
725
+
726
+ // src/textarea/TextareaGroup.tsx
727
+ var import_jsx_runtime14 = require("react/jsx-runtime");
728
+ var TextareaGroup = (props) => {
729
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InputGroup2, { ...props });
730
+ };
731
+ TextareaGroup.displayName = "TextareaGroup";
732
+
733
+ // src/textarea/TextareaLeadingIcon.tsx
734
+ var import_jsx_runtime15 = require("react/jsx-runtime");
735
+ var TextareaLeadingIcon = (props) => {
736
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(InputGroup2.LeadingIcon, { "data-spark-component": "textarea-group-leading-icon", ...props });
737
+ };
738
+ TextareaLeadingIcon.id = InputGroup2.LeadingIcon.id;
739
+ TextareaLeadingIcon.displayName = "TextareaGroup.LeadingIcon";
740
+
741
+ // src/textarea/TextareaTrailingIcon.tsx
742
+ var import_jsx_runtime16 = require("react/jsx-runtime");
743
+ var TextareaTrailingIcon = (props) => {
744
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InputGroup2.TrailingIcon, { "data-spark-component": "textarea-group-trailing-icon", ...props });
745
+ };
746
+ TextareaTrailingIcon.id = InputGroup2.TrailingIcon.id;
747
+ TextareaTrailingIcon.displayName = "TextareaGroup.TrailingIcon";
748
+
749
+ // src/textarea/Textarea.tsx
750
+ var import_class_variance_authority11 = require("class-variance-authority");
751
+ var import_jsx_runtime17 = require("react/jsx-runtime");
752
+ var Root5 = ({
753
+ className,
754
+ disabled,
755
+ rows = 1,
756
+ isResizable = true,
757
+ ref,
758
+ onValueChange,
759
+ ...others
760
+ }) => {
761
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
762
+ Input,
763
+ {
764
+ className: (0, import_class_variance_authority11.cx)(
765
+ className,
766
+ "py-[var(--spacing-sz-10)]",
767
+ isResizable ? "resize-y" : "resize-none"
768
+ ),
769
+ "data-spark-component": "textarea",
770
+ disabled,
771
+ asChild: true,
772
+ onValueChange,
773
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { ref, rows, ...others })
774
+ }
775
+ );
776
+ };
777
+ var Textarea = Object.assign(Root5, {
778
+ id: Input.id
779
+ });
780
+ Root5.displayName = "Textarea";
781
+
782
+ // src/textarea/index.ts
783
+ var TextareaGroup2 = Object.assign(TextareaGroup, {
784
+ LeadingIcon: TextareaLeadingIcon,
785
+ TrailingIcon: TextareaTrailingIcon,
786
+ ClearButton: TextareaClearButton
787
+ });
788
+ TextareaGroup2.displayName = "TextareaGroup";
789
+ TextareaLeadingIcon.displayName = "TextareaGroup.LeadingIcon";
790
+ TextareaTrailingIcon.displayName = "TextareaGroup.TrailingIcon";
791
+ TextareaClearButton.displayName = "TextareaGroup.ClearButton";
792
+ // Annotate the CommonJS export names for ESM import in node:
793
+ 0 && (module.exports = {
794
+ Textarea,
795
+ TextareaGroup
796
+ });
797
+ //# sourceMappingURL=index.js.map