@spark-ui/components 10.0.1 → 10.0.3
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.
- package/CHANGELOG.md +12 -0
- package/dist/checkbox/index.js +115 -476
- package/dist/checkbox/index.js.map +1 -1
- package/dist/checkbox/index.mjs +3 -4
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/{chunk-JKNBJHD5.mjs → chunk-7BTJUYP3.mjs} +6 -5
- package/dist/chunk-7BTJUYP3.mjs.map +1 -0
- package/dist/combobox/index.js +298 -707
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +3 -5
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/dropdown/index.js +251 -661
- package/dist/dropdown/index.js.map +1 -1
- package/dist/dropdown/index.mjs +1 -4
- package/dist/dropdown/index.mjs.map +1 -1
- package/dist/form-field/index.mjs +373 -7
- package/dist/form-field/index.mjs.map +1 -1
- package/dist/input/index.js +46 -453
- package/dist/input/index.js.map +1 -1
- package/dist/input/index.mjs +1 -3
- package/dist/radio-group/index.js +46 -552
- package/dist/radio-group/index.js.map +1 -1
- package/dist/radio-group/index.mjs +3 -9
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/select/index.js +158 -568
- package/dist/select/index.js.map +1 -1
- package/dist/select/index.mjs +1 -4
- package/dist/select/index.mjs.map +1 -1
- package/dist/stepper/index.js +108 -514
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/index.mjs +2 -5
- package/dist/stepper/index.mjs.map +1 -1
- package/dist/switch/index.js +94 -543
- package/dist/switch/index.js.map +1 -1
- package/dist/switch/index.mjs +3 -6
- package/dist/switch/index.mjs.map +1 -1
- package/dist/textarea/index.js +57 -464
- package/dist/textarea/index.js.map +1 -1
- package/dist/textarea/index.mjs +1 -3
- package/dist/textarea/index.mjs.map +1 -1
- package/package.json +16 -6
- package/tsup.config.ts +2 -1
- package/dist/chunk-7PMPYEHJ.mjs +0 -379
- package/dist/chunk-7PMPYEHJ.mjs.map +0 -1
- package/dist/chunk-JKNBJHD5.mjs.map +0 -1
package/dist/switch/index.js
CHANGED
|
@@ -25,12 +25,16 @@ __export(switch_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(switch_exports);
|
|
26
26
|
|
|
27
27
|
// src/switch/Switch.tsx
|
|
28
|
-
var
|
|
29
|
-
var
|
|
28
|
+
var import_form_field2 = require("@spark-ui/components/form-field");
|
|
29
|
+
var import_class_variance_authority5 = require("class-variance-authority");
|
|
30
|
+
var import_react2 = require("react");
|
|
30
31
|
|
|
31
|
-
// src/
|
|
32
|
-
var
|
|
33
|
-
var
|
|
32
|
+
// src/switch/SwitchInput.tsx
|
|
33
|
+
var import_form_field = require("@spark-ui/components/form-field");
|
|
34
|
+
var import_Check = require("@spark-ui/icons/Check");
|
|
35
|
+
var import_Close = require("@spark-ui/icons/Close");
|
|
36
|
+
var import_use_combined_state = require("@spark-ui/use-combined-state");
|
|
37
|
+
var import_radix_ui2 = require("radix-ui");
|
|
34
38
|
|
|
35
39
|
// src/slot/Slot.tsx
|
|
36
40
|
var import_radix_ui = require("radix-ui");
|
|
@@ -41,512 +45,11 @@ var Slot = ({ ref, ...props }) => {
|
|
|
41
45
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
|
|
42
46
|
};
|
|
43
47
|
|
|
44
|
-
// src/form-field/FormFieldContext.tsx
|
|
45
|
-
var import_react2 = require("react");
|
|
46
|
-
var FormFieldContext = (0, import_react2.createContext)(null);
|
|
47
|
-
var ID_PREFIX = ":form-field";
|
|
48
|
-
var useFormField = () => {
|
|
49
|
-
const context = (0, import_react2.useContext)(FormFieldContext);
|
|
50
|
-
if (!context) {
|
|
51
|
-
throw Error("useFormField must be used within a FormField provider");
|
|
52
|
-
}
|
|
53
|
-
return context;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/form-field/FormFieldProvider.tsx
|
|
57
|
-
var import_react3 = require("react");
|
|
58
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
59
|
-
var FormFieldProvider = ({
|
|
60
|
-
id,
|
|
61
|
-
name,
|
|
62
|
-
disabled = false,
|
|
63
|
-
readOnly = false,
|
|
64
|
-
state,
|
|
65
|
-
isRequired,
|
|
66
|
-
children
|
|
67
|
-
}) => {
|
|
68
|
-
const labelId = `${ID_PREFIX}-label-${(0, import_react3.useId)()}`;
|
|
69
|
-
const [messageIds, setMessageIds] = (0, import_react3.useState)([]);
|
|
70
|
-
const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
|
|
71
|
-
const handleMessageIdAdd = (0, import_react3.useCallback)((msgId) => {
|
|
72
|
-
setMessageIds((ids) => [...ids, msgId]);
|
|
73
|
-
}, []);
|
|
74
|
-
const handleMessageIdRemove = (0, import_react3.useCallback)((msgId) => {
|
|
75
|
-
setMessageIds((ids) => ids.filter((current) => current !== msgId));
|
|
76
|
-
}, []);
|
|
77
|
-
const value = (0, import_react3.useMemo)(() => {
|
|
78
|
-
const isInvalid = state === "error";
|
|
79
|
-
return {
|
|
80
|
-
id,
|
|
81
|
-
labelId,
|
|
82
|
-
name,
|
|
83
|
-
disabled,
|
|
84
|
-
readOnly,
|
|
85
|
-
state,
|
|
86
|
-
isRequired,
|
|
87
|
-
isInvalid,
|
|
88
|
-
description,
|
|
89
|
-
onMessageIdAdd: handleMessageIdAdd,
|
|
90
|
-
onMessageIdRemove: handleMessageIdRemove
|
|
91
|
-
};
|
|
92
|
-
}, [
|
|
93
|
-
id,
|
|
94
|
-
labelId,
|
|
95
|
-
name,
|
|
96
|
-
disabled,
|
|
97
|
-
readOnly,
|
|
98
|
-
description,
|
|
99
|
-
state,
|
|
100
|
-
isRequired,
|
|
101
|
-
handleMessageIdAdd,
|
|
102
|
-
handleMessageIdRemove
|
|
103
|
-
]);
|
|
104
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FormFieldContext.Provider, { value, children });
|
|
105
|
-
};
|
|
106
|
-
FormFieldProvider.displayName = "FormFieldProvider";
|
|
107
|
-
|
|
108
|
-
// src/form-field/FormField.tsx
|
|
109
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
110
|
-
var FormField = ({
|
|
111
|
-
className,
|
|
112
|
-
disabled = false,
|
|
113
|
-
readOnly = false,
|
|
114
|
-
name,
|
|
115
|
-
state,
|
|
116
|
-
isRequired = false,
|
|
117
|
-
asChild = false,
|
|
118
|
-
ref,
|
|
119
|
-
...others
|
|
120
|
-
}) => {
|
|
121
|
-
const id = `${ID_PREFIX}-${(0, import_react4.useId)()}`;
|
|
122
|
-
const Component = asChild ? Slot : "div";
|
|
123
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
124
|
-
FormFieldProvider,
|
|
125
|
-
{
|
|
126
|
-
id,
|
|
127
|
-
name,
|
|
128
|
-
isRequired,
|
|
129
|
-
disabled,
|
|
130
|
-
readOnly,
|
|
131
|
-
state,
|
|
132
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
133
|
-
Component,
|
|
134
|
-
{
|
|
135
|
-
ref,
|
|
136
|
-
"data-spark-component": "form-field",
|
|
137
|
-
className: (0, import_class_variance_authority.cx)(className, "gap-sm flex flex-col"),
|
|
138
|
-
...others
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
};
|
|
144
|
-
FormField.displayName = "FormField";
|
|
145
|
-
|
|
146
|
-
// src/form-field/FormFieldStateMessage.tsx
|
|
147
|
-
var import_AlertOutline = require("@spark-ui/icons/AlertOutline");
|
|
148
|
-
var import_Check = require("@spark-ui/icons/Check");
|
|
149
|
-
var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
|
|
150
|
-
var import_class_variance_authority4 = require("class-variance-authority");
|
|
151
|
-
|
|
152
|
-
// src/icon/Icon.tsx
|
|
153
|
-
var import_react5 = require("react");
|
|
154
|
-
|
|
155
|
-
// src/visually-hidden/VisuallyHidden.tsx
|
|
156
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
157
|
-
var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
|
|
158
|
-
const Component = asChild ? Slot : "span";
|
|
159
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
160
|
-
Component,
|
|
161
|
-
{
|
|
162
|
-
...props,
|
|
163
|
-
ref,
|
|
164
|
-
style: {
|
|
165
|
-
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
166
|
-
position: "absolute",
|
|
167
|
-
border: 0,
|
|
168
|
-
width: 1,
|
|
169
|
-
height: 1,
|
|
170
|
-
padding: 0,
|
|
171
|
-
margin: -1,
|
|
172
|
-
overflow: "hidden",
|
|
173
|
-
clip: "rect(0, 0, 0, 0)",
|
|
174
|
-
whiteSpace: "nowrap",
|
|
175
|
-
wordWrap: "normal",
|
|
176
|
-
...props.style
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
VisuallyHidden.displayName = "VisuallyHidden";
|
|
182
|
-
|
|
183
|
-
// src/icon/Icon.styles.tsx
|
|
184
|
-
var import_internal_utils = require("@spark-ui/internal-utils");
|
|
185
|
-
var import_class_variance_authority2 = require("class-variance-authority");
|
|
186
|
-
var iconStyles = (0, import_class_variance_authority2.cva)(["fill-current shrink-0"], {
|
|
187
|
-
variants: {
|
|
188
|
-
/**
|
|
189
|
-
* Color scheme of the icon.
|
|
190
|
-
*/
|
|
191
|
-
intent: (0, import_internal_utils.makeVariants)({
|
|
192
|
-
current: ["text-current"],
|
|
193
|
-
main: ["text-main"],
|
|
194
|
-
support: ["text-support"],
|
|
195
|
-
accent: ["text-accent"],
|
|
196
|
-
basic: ["text-basic"],
|
|
197
|
-
success: ["text-success"],
|
|
198
|
-
alert: ["text-alert"],
|
|
199
|
-
error: ["text-error"],
|
|
200
|
-
info: ["text-info"],
|
|
201
|
-
neutral: ["text-neutral"]
|
|
202
|
-
}),
|
|
203
|
-
/**
|
|
204
|
-
* Sets the size of the icon.
|
|
205
|
-
*/
|
|
206
|
-
size: (0, import_internal_utils.makeVariants)({
|
|
207
|
-
current: ["u-current-font-size"],
|
|
208
|
-
sm: ["w-sz-16", "h-sz-16"],
|
|
209
|
-
md: ["w-sz-24", "h-sz-24"],
|
|
210
|
-
lg: ["w-sz-32", "h-sz-32"],
|
|
211
|
-
xl: ["w-sz-40", "h-sz-40"]
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// src/icon/Icon.tsx
|
|
217
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
218
|
-
var Icon = ({
|
|
219
|
-
label,
|
|
220
|
-
className,
|
|
221
|
-
size = "current",
|
|
222
|
-
intent = "current",
|
|
223
|
-
children,
|
|
224
|
-
...others
|
|
225
|
-
}) => {
|
|
226
|
-
const child = import_react5.Children.only(children);
|
|
227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
228
|
-
(0, import_react5.cloneElement)(child, {
|
|
229
|
-
className: iconStyles({ className, size, intent }),
|
|
230
|
-
"data-spark-component": "icon",
|
|
231
|
-
"aria-hidden": "true",
|
|
232
|
-
focusable: "false",
|
|
233
|
-
...others
|
|
234
|
-
}),
|
|
235
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHidden, { children: label })
|
|
236
|
-
] });
|
|
237
|
-
};
|
|
238
|
-
Icon.displayName = "Icon";
|
|
239
|
-
|
|
240
|
-
// src/form-field/FormFieldMessage.tsx
|
|
241
|
-
var import_class_variance_authority3 = require("class-variance-authority");
|
|
242
|
-
var import_react6 = require("react");
|
|
243
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
244
|
-
var FormFieldMessage = ({
|
|
245
|
-
id: idProp,
|
|
246
|
-
className,
|
|
247
|
-
ref,
|
|
248
|
-
...others
|
|
249
|
-
}) => {
|
|
250
|
-
const { onMessageIdAdd, onMessageIdRemove } = useFormField();
|
|
251
|
-
const currentId = `${ID_PREFIX}-message-${(0, import_react6.useId)()}`;
|
|
252
|
-
const id = idProp || currentId;
|
|
253
|
-
(0, import_react6.useEffect)(() => {
|
|
254
|
-
onMessageIdAdd(id);
|
|
255
|
-
return () => {
|
|
256
|
-
onMessageIdRemove(id);
|
|
257
|
-
};
|
|
258
|
-
}, [id, onMessageIdAdd, onMessageIdRemove]);
|
|
259
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
260
|
-
"span",
|
|
261
|
-
{
|
|
262
|
-
ref,
|
|
263
|
-
id,
|
|
264
|
-
"data-spark-component": "form-field-message",
|
|
265
|
-
className: (0, import_class_variance_authority3.cx)(className, "text-caption"),
|
|
266
|
-
...others
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
FormFieldMessage.displayName = "FormField.Message";
|
|
271
|
-
|
|
272
|
-
// src/form-field/FormFieldStateMessage.tsx
|
|
273
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
274
|
-
var FormFieldStateMessage = ({
|
|
275
|
-
className,
|
|
276
|
-
state,
|
|
277
|
-
children,
|
|
278
|
-
ref,
|
|
279
|
-
...others
|
|
280
|
-
}) => {
|
|
281
|
-
const field = useFormField();
|
|
282
|
-
if (field.state !== state) {
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
285
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
286
|
-
FormFieldMessage,
|
|
287
|
-
{
|
|
288
|
-
ref,
|
|
289
|
-
"data-spark-component": "form-field-state-message",
|
|
290
|
-
"aria-live": "polite",
|
|
291
|
-
className: (0, import_class_variance_authority4.cx)(
|
|
292
|
-
"gap-sm flex items-center",
|
|
293
|
-
state === "error" ? "text-error" : "text-on-surface/dim-1",
|
|
294
|
-
className
|
|
295
|
-
),
|
|
296
|
-
...others,
|
|
297
|
-
children: [
|
|
298
|
-
state === "alert" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_WarningOutline.WarningOutline, {}) }),
|
|
299
|
-
state === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_AlertOutline.AlertOutline, {}) }),
|
|
300
|
-
state === "success" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Check.Check, {}) }),
|
|
301
|
-
children
|
|
302
|
-
]
|
|
303
|
-
}
|
|
304
|
-
);
|
|
305
|
-
};
|
|
306
|
-
FormFieldStateMessage.displayName = "FormField.StateMessage";
|
|
307
|
-
|
|
308
|
-
// src/form-field/FormFieldAlertMessage.tsx
|
|
309
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
310
|
-
var FormFieldAlertMessage = ({ ref, ...props }) => {
|
|
311
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
312
|
-
FormFieldStateMessage,
|
|
313
|
-
{
|
|
314
|
-
ref,
|
|
315
|
-
"data-spark-component": "form-field-alert-message",
|
|
316
|
-
state: "alert",
|
|
317
|
-
...props
|
|
318
|
-
}
|
|
319
|
-
);
|
|
320
|
-
};
|
|
321
|
-
FormFieldAlertMessage.displayName = "FormField.AlertMessage";
|
|
322
|
-
|
|
323
|
-
// src/form-field/FormFieldCharactersCount.tsx
|
|
324
|
-
var import_class_variance_authority5 = require("class-variance-authority");
|
|
325
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
326
|
-
var FormFieldCharactersCount = ({
|
|
327
|
-
className,
|
|
328
|
-
value = "",
|
|
329
|
-
maxLength,
|
|
330
|
-
ref,
|
|
331
|
-
...others
|
|
332
|
-
}) => {
|
|
333
|
-
const displayValue = `${value.length}/${maxLength}`;
|
|
334
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
335
|
-
"span",
|
|
336
|
-
{
|
|
337
|
-
ref,
|
|
338
|
-
"data-spark-component": "form-field-characters-count",
|
|
339
|
-
className: (0, import_class_variance_authority5.cx)(className, "text-caption", "text-neutral"),
|
|
340
|
-
...others,
|
|
341
|
-
children: displayValue
|
|
342
|
-
}
|
|
343
|
-
);
|
|
344
|
-
};
|
|
345
|
-
FormFieldCharactersCount.displayName = "FormField.CharactersCount";
|
|
346
|
-
|
|
347
|
-
// src/form-field/FormFieldControl.tsx
|
|
348
|
-
var import_react7 = require("react");
|
|
349
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
350
|
-
var useFormFieldControl = () => {
|
|
351
|
-
const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = (0, import_react7.useContext)(FormFieldContext) || {};
|
|
352
|
-
return {
|
|
353
|
-
id,
|
|
354
|
-
name,
|
|
355
|
-
description,
|
|
356
|
-
disabled,
|
|
357
|
-
readOnly,
|
|
358
|
-
state,
|
|
359
|
-
labelId,
|
|
360
|
-
isInvalid,
|
|
361
|
-
isRequired
|
|
362
|
-
};
|
|
363
|
-
};
|
|
364
|
-
var FormFieldControl = ({ children }) => {
|
|
365
|
-
const props = useFormFieldControl();
|
|
366
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: children(props) });
|
|
367
|
-
};
|
|
368
|
-
FormFieldControl.displayName = "FormField.Control";
|
|
369
|
-
|
|
370
|
-
// src/form-field/FormFieldErrorMessage.tsx
|
|
371
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
372
|
-
var FormFieldErrorMessage = ({ ref, ...props }) => {
|
|
373
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
374
|
-
FormFieldStateMessage,
|
|
375
|
-
{
|
|
376
|
-
ref,
|
|
377
|
-
"data-spark-component": "form-field-error-message",
|
|
378
|
-
state: "error",
|
|
379
|
-
...props
|
|
380
|
-
}
|
|
381
|
-
);
|
|
382
|
-
};
|
|
383
|
-
FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
|
|
384
|
-
|
|
385
|
-
// src/form-field/FormFieldHelperMessage.tsx
|
|
386
|
-
var import_class_variance_authority6 = require("class-variance-authority");
|
|
387
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
388
|
-
var FormFieldHelperMessage = ({
|
|
389
|
-
className,
|
|
390
|
-
ref,
|
|
391
|
-
...others
|
|
392
|
-
}) => {
|
|
393
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
394
|
-
FormFieldMessage,
|
|
395
|
-
{
|
|
396
|
-
ref,
|
|
397
|
-
"data-spark-component": "form-field-helper-message",
|
|
398
|
-
className: (0, import_class_variance_authority6.cx)("text-on-surface/dim-1", className),
|
|
399
|
-
...others
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
};
|
|
403
|
-
FormFieldHelperMessage.displayName = "FormField.HelperMessage";
|
|
404
|
-
|
|
405
|
-
// src/form-field/FormFieldLabel.tsx
|
|
406
|
-
var import_class_variance_authority10 = require("class-variance-authority");
|
|
407
|
-
|
|
408
|
-
// src/label/Label.tsx
|
|
409
|
-
var import_class_variance_authority7 = require("class-variance-authority");
|
|
410
|
-
var import_radix_ui2 = require("radix-ui");
|
|
411
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
412
|
-
var Label = ({ className, ref, ...others }) => {
|
|
413
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
414
|
-
import_radix_ui2.Label.Label,
|
|
415
|
-
{
|
|
416
|
-
ref,
|
|
417
|
-
"data-spark-component": "label",
|
|
418
|
-
className: (0, import_class_variance_authority7.cx)("text-body-1", className),
|
|
419
|
-
...others
|
|
420
|
-
}
|
|
421
|
-
);
|
|
422
|
-
};
|
|
423
|
-
Label.displayName = "Label";
|
|
424
|
-
|
|
425
|
-
// src/label/LabelRequiredIndicator.tsx
|
|
426
|
-
var import_class_variance_authority8 = require("class-variance-authority");
|
|
427
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
428
|
-
var LabelRequiredIndicator = ({
|
|
429
|
-
className,
|
|
430
|
-
children = "*",
|
|
431
|
-
ref,
|
|
432
|
-
...others
|
|
433
|
-
}) => {
|
|
434
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
435
|
-
"span",
|
|
436
|
-
{
|
|
437
|
-
ref,
|
|
438
|
-
"data-spark-component": "label-required-indicator",
|
|
439
|
-
role: "presentation",
|
|
440
|
-
"aria-hidden": "true",
|
|
441
|
-
className: (0, import_class_variance_authority8.cx)(className, "text-caption text-on-surface/dim-1"),
|
|
442
|
-
...others,
|
|
443
|
-
children
|
|
444
|
-
}
|
|
445
|
-
);
|
|
446
|
-
};
|
|
447
|
-
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
448
|
-
|
|
449
|
-
// src/label/index.ts
|
|
450
|
-
var Label2 = Object.assign(Label, {
|
|
451
|
-
RequiredIndicator: LabelRequiredIndicator
|
|
452
|
-
});
|
|
453
|
-
Label2.displayName = "Label";
|
|
454
|
-
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
455
|
-
|
|
456
|
-
// src/form-field/FormFieldRequiredIndicator.tsx
|
|
457
|
-
var import_class_variance_authority9 = require("class-variance-authority");
|
|
458
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
459
|
-
var FormFieldRequiredIndicator = ({
|
|
460
|
-
className,
|
|
461
|
-
ref,
|
|
462
|
-
...props
|
|
463
|
-
}) => {
|
|
464
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label2.RequiredIndicator, { ref, className: (0, import_class_variance_authority9.cx)("ml-sm", className), ...props });
|
|
465
|
-
};
|
|
466
|
-
FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
|
|
467
|
-
|
|
468
|
-
// src/form-field/FormFieldLabel.tsx
|
|
469
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
470
|
-
var FormFieldLabel = ({
|
|
471
|
-
htmlFor: htmlForProp,
|
|
472
|
-
className,
|
|
473
|
-
children,
|
|
474
|
-
requiredIndicator = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FormFieldRequiredIndicator, {}),
|
|
475
|
-
asChild,
|
|
476
|
-
ref,
|
|
477
|
-
...others
|
|
478
|
-
}) => {
|
|
479
|
-
const control = useFormField();
|
|
480
|
-
const { disabled, labelId, isRequired } = control;
|
|
481
|
-
const htmlFor = asChild ? void 0 : htmlForProp || control.id;
|
|
482
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
483
|
-
Label2,
|
|
484
|
-
{
|
|
485
|
-
ref,
|
|
486
|
-
id: labelId,
|
|
487
|
-
"data-spark-component": "form-field-label",
|
|
488
|
-
htmlFor,
|
|
489
|
-
className: (0, import_class_variance_authority10.cx)(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
|
|
490
|
-
asChild,
|
|
491
|
-
...others,
|
|
492
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
493
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Slottable, { children }),
|
|
494
|
-
isRequired && requiredIndicator
|
|
495
|
-
] })
|
|
496
|
-
}
|
|
497
|
-
);
|
|
498
|
-
};
|
|
499
|
-
FormFieldLabel.displayName = "FormField.Label";
|
|
500
|
-
|
|
501
|
-
// src/form-field/FormFieldSuccessMessage.tsx
|
|
502
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
503
|
-
var FormFieldSuccessMessage = ({ ref, ...props }) => {
|
|
504
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
505
|
-
FormFieldStateMessage,
|
|
506
|
-
{
|
|
507
|
-
ref,
|
|
508
|
-
"data-spark-component": "form-field-success-message",
|
|
509
|
-
state: "success",
|
|
510
|
-
...props
|
|
511
|
-
}
|
|
512
|
-
);
|
|
513
|
-
};
|
|
514
|
-
FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
|
|
515
|
-
|
|
516
|
-
// src/form-field/index.ts
|
|
517
|
-
var FormField2 = Object.assign(FormField, {
|
|
518
|
-
Label: FormFieldLabel,
|
|
519
|
-
Control: FormFieldControl,
|
|
520
|
-
StateMessage: FormFieldStateMessage,
|
|
521
|
-
SuccessMessage: FormFieldSuccessMessage,
|
|
522
|
-
AlertMessage: FormFieldAlertMessage,
|
|
523
|
-
ErrorMessage: FormFieldErrorMessage,
|
|
524
|
-
HelperMessage: FormFieldHelperMessage,
|
|
525
|
-
RequiredIndicator: FormFieldRequiredIndicator,
|
|
526
|
-
CharactersCount: FormFieldCharactersCount
|
|
527
|
-
});
|
|
528
|
-
FormField2.displayName = "FormField";
|
|
529
|
-
FormFieldLabel.displayName = "FormField.Label";
|
|
530
|
-
FormFieldControl.displayName = "FormField.Control";
|
|
531
|
-
FormFieldStateMessage.displayName = "FormField.StateMessage";
|
|
532
|
-
FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
|
|
533
|
-
FormFieldAlertMessage.displayName = "FormField.AlertMessage";
|
|
534
|
-
FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
|
|
535
|
-
FormFieldHelperMessage.displayName = "FormField.HelperMessage";
|
|
536
|
-
FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
|
|
537
|
-
FormFieldCharactersCount.displayName = "FormField.CharactersCount";
|
|
538
|
-
|
|
539
|
-
// src/switch/SwitchInput.tsx
|
|
540
|
-
var import_Check2 = require("@spark-ui/icons/Check");
|
|
541
|
-
var import_Close = require("@spark-ui/icons/Close");
|
|
542
|
-
var import_use_combined_state = require("@spark-ui/use-combined-state");
|
|
543
|
-
var import_radix_ui3 = require("radix-ui");
|
|
544
|
-
|
|
545
48
|
// src/switch/SwitchInput.styles.ts
|
|
546
|
-
var
|
|
547
|
-
var
|
|
548
|
-
var styles = (0,
|
|
549
|
-
(0,
|
|
49
|
+
var import_internal_utils = require("@spark-ui/internal-utils");
|
|
50
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
51
|
+
var styles = (0, import_class_variance_authority.cva)(
|
|
52
|
+
(0, import_internal_utils.tw)([
|
|
550
53
|
"relative shrink-0 self-baseline",
|
|
551
54
|
"cursor-pointer",
|
|
552
55
|
"rounded-full border-transparent",
|
|
@@ -563,14 +66,14 @@ var styles = (0, import_class_variance_authority11.cva)(
|
|
|
563
66
|
/**
|
|
564
67
|
* Size of the switch input.
|
|
565
68
|
*/
|
|
566
|
-
size: (0,
|
|
567
|
-
sm: (0,
|
|
568
|
-
md: (0,
|
|
69
|
+
size: (0, import_internal_utils.makeVariants)({
|
|
70
|
+
sm: (0, import_internal_utils.tw)(["h-sz-24", "w-sz-40", "border-md"]),
|
|
71
|
+
md: (0, import_internal_utils.tw)(["h-sz-32", "w-sz-56", "border-[4px]"])
|
|
569
72
|
}),
|
|
570
73
|
/**
|
|
571
74
|
* Color scheme of the switch input.
|
|
572
75
|
*/
|
|
573
|
-
intent: (0,
|
|
76
|
+
intent: (0, import_internal_utils.makeVariants)({
|
|
574
77
|
main: ["data-[state=checked]:bg-main", "hover:ring-main-container", "text-main"],
|
|
575
78
|
support: [
|
|
576
79
|
"data-[state=checked]:bg-support",
|
|
@@ -600,7 +103,7 @@ var styles = (0, import_class_variance_authority11.cva)(
|
|
|
600
103
|
}
|
|
601
104
|
}
|
|
602
105
|
);
|
|
603
|
-
var thumbWrapperStyles = (0,
|
|
106
|
+
var thumbWrapperStyles = (0, import_class_variance_authority.cva)(
|
|
604
107
|
[
|
|
605
108
|
"pointer-events-none absolute inset-0 flex items-center",
|
|
606
109
|
"transition-all duration-200 ease-in-out"
|
|
@@ -614,7 +117,7 @@ var thumbWrapperStyles = (0, import_class_variance_authority11.cva)(
|
|
|
614
117
|
}
|
|
615
118
|
}
|
|
616
119
|
);
|
|
617
|
-
var thumbStyles = (0,
|
|
120
|
+
var thumbStyles = (0, import_class_variance_authority.cva)(
|
|
618
121
|
[
|
|
619
122
|
"absolute left-0 top-0 flex items-center justify-center",
|
|
620
123
|
"bg-surface",
|
|
@@ -624,7 +127,7 @@ var thumbStyles = (0, import_class_variance_authority11.cva)(
|
|
|
624
127
|
],
|
|
625
128
|
{
|
|
626
129
|
variants: {
|
|
627
|
-
size: (0,
|
|
130
|
+
size: (0, import_internal_utils.makeVariants)({
|
|
628
131
|
sm: ["h-sz-20", "w-sz-20"],
|
|
629
132
|
md: ["h-sz-24", "w-sz-24"]
|
|
630
133
|
}),
|
|
@@ -639,9 +142,9 @@ var thumbStyles = (0, import_class_variance_authority11.cva)(
|
|
|
639
142
|
}
|
|
640
143
|
}
|
|
641
144
|
);
|
|
642
|
-
var thumbCheckSVGStyles = (0,
|
|
145
|
+
var thumbCheckSVGStyles = (0, import_class_variance_authority.cva)(["transition-opacity duration-200"], {
|
|
643
146
|
variants: {
|
|
644
|
-
size: (0,
|
|
147
|
+
size: (0, import_internal_utils.makeVariants)({
|
|
645
148
|
sm: ["h-sz-10 w-sz-10"],
|
|
646
149
|
md: ["h-sz-12 w-sz-12"]
|
|
647
150
|
})
|
|
@@ -652,13 +155,13 @@ var thumbCheckSVGStyles = (0, import_class_variance_authority11.cva)(["transitio
|
|
|
652
155
|
});
|
|
653
156
|
|
|
654
157
|
// src/switch/SwitchInput.tsx
|
|
655
|
-
var
|
|
158
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
656
159
|
var SwitchInput = ({
|
|
657
160
|
checked,
|
|
658
|
-
checkedIcon = /* @__PURE__ */ (0,
|
|
161
|
+
checkedIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Check.Check, {}),
|
|
659
162
|
defaultChecked,
|
|
660
163
|
intent: intentProp,
|
|
661
|
-
uncheckedIcon = /* @__PURE__ */ (0,
|
|
164
|
+
uncheckedIcon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_Close.Close, {}),
|
|
662
165
|
size = "md",
|
|
663
166
|
value = "on",
|
|
664
167
|
onCheckedChange,
|
|
@@ -668,14 +171,14 @@ var SwitchInput = ({
|
|
|
668
171
|
...rest
|
|
669
172
|
}) => {
|
|
670
173
|
const [isChecked, setIsChecked] = (0, import_use_combined_state.useCombinedState)(checked, defaultChecked);
|
|
671
|
-
const { name, description, state, isRequired, isInvalid } = useFormFieldControl();
|
|
174
|
+
const { name, description, state, isRequired, isInvalid } = (0, import_form_field.useFormFieldControl)();
|
|
672
175
|
const intent = state ?? intentProp;
|
|
673
176
|
const handleCheckedChange = (updatedValue) => {
|
|
674
177
|
setIsChecked(updatedValue);
|
|
675
178
|
onCheckedChange?.(updatedValue);
|
|
676
179
|
};
|
|
677
|
-
return /* @__PURE__ */ (0,
|
|
678
|
-
|
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
181
|
+
import_radix_ui2.Switch.Root,
|
|
679
182
|
{
|
|
680
183
|
ref,
|
|
681
184
|
className: styles({ intent, size, className }),
|
|
@@ -688,18 +191,66 @@ var SwitchInput = ({
|
|
|
688
191
|
"aria-invalid": isInvalid,
|
|
689
192
|
"aria-describedby": description,
|
|
690
193
|
...rest,
|
|
691
|
-
children: /* @__PURE__ */ (0,
|
|
692
|
-
isChecked && checkedIcon && /* @__PURE__ */ (0,
|
|
693
|
-
!isChecked && uncheckedIcon && /* @__PURE__ */ (0,
|
|
194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: thumbWrapperStyles({ checked: isChecked }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_radix_ui2.Switch.Thumb, { className: thumbStyles({ size, checked: isChecked }), children: [
|
|
195
|
+
isChecked && checkedIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: checkedIcon }),
|
|
196
|
+
!isChecked && uncheckedIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Slot, { className: thumbCheckSVGStyles({ size }), children: uncheckedIcon })
|
|
694
197
|
] }) })
|
|
695
198
|
}
|
|
696
199
|
);
|
|
697
200
|
};
|
|
698
201
|
SwitchInput.displayName = "SwitchInput";
|
|
699
202
|
|
|
203
|
+
// src/label/Label.tsx
|
|
204
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
205
|
+
var import_radix_ui3 = require("radix-ui");
|
|
206
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
207
|
+
var Label = ({ className, ref, ...others }) => {
|
|
208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
209
|
+
import_radix_ui3.Label.Label,
|
|
210
|
+
{
|
|
211
|
+
ref,
|
|
212
|
+
"data-spark-component": "label",
|
|
213
|
+
className: (0, import_class_variance_authority2.cx)("text-body-1", className),
|
|
214
|
+
...others
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
Label.displayName = "Label";
|
|
219
|
+
|
|
220
|
+
// src/label/LabelRequiredIndicator.tsx
|
|
221
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
222
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
223
|
+
var LabelRequiredIndicator = ({
|
|
224
|
+
className,
|
|
225
|
+
children = "*",
|
|
226
|
+
ref,
|
|
227
|
+
...others
|
|
228
|
+
}) => {
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
230
|
+
"span",
|
|
231
|
+
{
|
|
232
|
+
ref,
|
|
233
|
+
"data-spark-component": "label-required-indicator",
|
|
234
|
+
role: "presentation",
|
|
235
|
+
"aria-hidden": "true",
|
|
236
|
+
className: (0, import_class_variance_authority3.cx)(className, "text-caption text-on-surface/dim-1"),
|
|
237
|
+
...others,
|
|
238
|
+
children
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
243
|
+
|
|
244
|
+
// src/label/index.ts
|
|
245
|
+
var Label2 = Object.assign(Label, {
|
|
246
|
+
RequiredIndicator: LabelRequiredIndicator
|
|
247
|
+
});
|
|
248
|
+
Label2.displayName = "Label";
|
|
249
|
+
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
250
|
+
|
|
700
251
|
// src/switch/SwitchLabel.styles.ts
|
|
701
|
-
var
|
|
702
|
-
var labelStyles = (0,
|
|
252
|
+
var import_class_variance_authority4 = require("class-variance-authority");
|
|
253
|
+
var labelStyles = (0, import_class_variance_authority4.cva)("", {
|
|
703
254
|
variants: {
|
|
704
255
|
disabled: {
|
|
705
256
|
true: ["text-neutral/dim-2", "cursor-not-allowed"],
|
|
@@ -712,12 +263,12 @@ var labelStyles = (0, import_class_variance_authority12.cva)("", {
|
|
|
712
263
|
});
|
|
713
264
|
|
|
714
265
|
// src/switch/SwitchLabel.tsx
|
|
715
|
-
var
|
|
716
|
-
var SwitchLabel = ({ className, disabled, ...others }) => /* @__PURE__ */ (0,
|
|
266
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
267
|
+
var SwitchLabel = ({ className, disabled, ...others }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label2, { className: labelStyles({ disabled, className }), ...others });
|
|
717
268
|
|
|
718
269
|
// src/switch/Switch.tsx
|
|
719
|
-
var
|
|
720
|
-
var
|
|
270
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
271
|
+
var ID_PREFIX = ":switch";
|
|
721
272
|
var Switch = ({
|
|
722
273
|
size = "md",
|
|
723
274
|
children,
|
|
@@ -728,12 +279,12 @@ var Switch = ({
|
|
|
728
279
|
ref,
|
|
729
280
|
...rest
|
|
730
281
|
}) => {
|
|
731
|
-
const field = useFormFieldControl();
|
|
732
|
-
const labelID = `${
|
|
733
|
-
const innerID = `${
|
|
282
|
+
const field = (0, import_form_field2.useFormFieldControl)();
|
|
283
|
+
const labelID = `${ID_PREFIX}-label-${(0, import_react2.useId)()}`;
|
|
284
|
+
const innerID = `${ID_PREFIX}-input-${(0, import_react2.useId)()}`;
|
|
734
285
|
const fieldID = field.id || id || innerID;
|
|
735
|
-
const switchLabel = children && /* @__PURE__ */ (0,
|
|
736
|
-
const switchInput = /* @__PURE__ */ (0,
|
|
286
|
+
const switchLabel = children && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SwitchLabel, { disabled, htmlFor: fieldID, id: labelID, children });
|
|
287
|
+
const switchInput = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
737
288
|
SwitchInput,
|
|
738
289
|
{
|
|
739
290
|
ref,
|
|
@@ -744,18 +295,18 @@ var Switch = ({
|
|
|
744
295
|
...rest
|
|
745
296
|
}
|
|
746
297
|
);
|
|
747
|
-
const content = reverse ? /* @__PURE__ */ (0,
|
|
298
|
+
const content = reverse ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
748
299
|
switchLabel,
|
|
749
300
|
switchInput
|
|
750
|
-
] }) : /* @__PURE__ */ (0,
|
|
301
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
751
302
|
switchInput,
|
|
752
303
|
switchLabel
|
|
753
304
|
] });
|
|
754
|
-
return /* @__PURE__ */ (0,
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
755
306
|
"div",
|
|
756
307
|
{
|
|
757
308
|
"data-spark-component": "switch",
|
|
758
|
-
className: (0,
|
|
309
|
+
className: (0, import_class_variance_authority5.cx)("gap-md text-body-1 flex items-center", className),
|
|
759
310
|
children: content
|
|
760
311
|
}
|
|
761
312
|
);
|