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