@spark-ui/components 10.0.2 → 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 +6 -0
- package/dist/checkbox/index.js +117 -478
- 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-JC6KKYUQ.mjs → chunk-7BTJUYP3.mjs} +6 -5
- package/dist/{chunk-JC6KKYUQ.mjs.map → chunk-7BTJUYP3.mjs.map} +1 -1
- package/dist/combobox/index.js +301 -710
- 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 +252 -662
- 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 +47 -454
- package/dist/input/index.js.map +1 -1
- package/dist/input/index.mjs +1 -3
- package/dist/radio-group/index.js +47 -553
- 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 +159 -569
- 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 +110 -516
- 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 +96 -545
- 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 +58 -465
- 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/input/index.js
CHANGED
|
@@ -171,425 +171,15 @@ var InputClearButton = Object.assign(Root, {
|
|
|
171
171
|
});
|
|
172
172
|
Root.displayName = "InputGroup.ClearButton";
|
|
173
173
|
|
|
174
|
-
// src/form-field/FormField.tsx
|
|
175
|
-
var import_class_variance_authority3 = require("class-variance-authority");
|
|
176
|
-
var import_react6 = require("react");
|
|
177
|
-
|
|
178
|
-
// src/form-field/FormFieldContext.tsx
|
|
179
|
-
var import_react4 = require("react");
|
|
180
|
-
var FormFieldContext = (0, import_react4.createContext)(null);
|
|
181
|
-
var ID_PREFIX = ":form-field";
|
|
182
|
-
var useFormField = () => {
|
|
183
|
-
const context = (0, import_react4.useContext)(FormFieldContext);
|
|
184
|
-
if (!context) {
|
|
185
|
-
throw Error("useFormField must be used within a FormField provider");
|
|
186
|
-
}
|
|
187
|
-
return context;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// src/form-field/FormFieldProvider.tsx
|
|
191
|
-
var import_react5 = require("react");
|
|
192
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
193
|
-
var FormFieldProvider = ({
|
|
194
|
-
id,
|
|
195
|
-
name,
|
|
196
|
-
disabled = false,
|
|
197
|
-
readOnly = false,
|
|
198
|
-
state,
|
|
199
|
-
isRequired,
|
|
200
|
-
children
|
|
201
|
-
}) => {
|
|
202
|
-
const labelId = `${ID_PREFIX}-label-${(0, import_react5.useId)()}`;
|
|
203
|
-
const [messageIds, setMessageIds] = (0, import_react5.useState)([]);
|
|
204
|
-
const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
|
|
205
|
-
const handleMessageIdAdd = (0, import_react5.useCallback)((msgId) => {
|
|
206
|
-
setMessageIds((ids) => [...ids, msgId]);
|
|
207
|
-
}, []);
|
|
208
|
-
const handleMessageIdRemove = (0, import_react5.useCallback)((msgId) => {
|
|
209
|
-
setMessageIds((ids) => ids.filter((current) => current !== msgId));
|
|
210
|
-
}, []);
|
|
211
|
-
const value = (0, import_react5.useMemo)(() => {
|
|
212
|
-
const isInvalid = state === "error";
|
|
213
|
-
return {
|
|
214
|
-
id,
|
|
215
|
-
labelId,
|
|
216
|
-
name,
|
|
217
|
-
disabled,
|
|
218
|
-
readOnly,
|
|
219
|
-
state,
|
|
220
|
-
isRequired,
|
|
221
|
-
isInvalid,
|
|
222
|
-
description,
|
|
223
|
-
onMessageIdAdd: handleMessageIdAdd,
|
|
224
|
-
onMessageIdRemove: handleMessageIdRemove
|
|
225
|
-
};
|
|
226
|
-
}, [
|
|
227
|
-
id,
|
|
228
|
-
labelId,
|
|
229
|
-
name,
|
|
230
|
-
disabled,
|
|
231
|
-
readOnly,
|
|
232
|
-
description,
|
|
233
|
-
state,
|
|
234
|
-
isRequired,
|
|
235
|
-
handleMessageIdAdd,
|
|
236
|
-
handleMessageIdRemove
|
|
237
|
-
]);
|
|
238
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormFieldContext.Provider, { value, children });
|
|
239
|
-
};
|
|
240
|
-
FormFieldProvider.displayName = "FormFieldProvider";
|
|
241
|
-
|
|
242
|
-
// src/form-field/FormField.tsx
|
|
243
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
244
|
-
var FormField = ({
|
|
245
|
-
className,
|
|
246
|
-
disabled = false,
|
|
247
|
-
readOnly = false,
|
|
248
|
-
name,
|
|
249
|
-
state,
|
|
250
|
-
isRequired = false,
|
|
251
|
-
asChild = false,
|
|
252
|
-
ref,
|
|
253
|
-
...others
|
|
254
|
-
}) => {
|
|
255
|
-
const id = `${ID_PREFIX}-${(0, import_react6.useId)()}`;
|
|
256
|
-
const Component = asChild ? Slot : "div";
|
|
257
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
258
|
-
FormFieldProvider,
|
|
259
|
-
{
|
|
260
|
-
id,
|
|
261
|
-
name,
|
|
262
|
-
isRequired,
|
|
263
|
-
disabled,
|
|
264
|
-
readOnly,
|
|
265
|
-
state,
|
|
266
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
267
|
-
Component,
|
|
268
|
-
{
|
|
269
|
-
ref,
|
|
270
|
-
"data-spark-component": "form-field",
|
|
271
|
-
className: (0, import_class_variance_authority3.cx)(className, "gap-sm flex flex-col"),
|
|
272
|
-
...others
|
|
273
|
-
}
|
|
274
|
-
)
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
|
-
};
|
|
278
|
-
FormField.displayName = "FormField";
|
|
279
|
-
|
|
280
|
-
// src/form-field/FormFieldStateMessage.tsx
|
|
281
|
-
var import_AlertOutline = require("@spark-ui/icons/AlertOutline");
|
|
282
|
-
var import_Check = require("@spark-ui/icons/Check");
|
|
283
|
-
var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
|
|
284
|
-
var import_class_variance_authority5 = require("class-variance-authority");
|
|
285
|
-
|
|
286
|
-
// src/form-field/FormFieldMessage.tsx
|
|
287
|
-
var import_class_variance_authority4 = require("class-variance-authority");
|
|
288
|
-
var import_react7 = require("react");
|
|
289
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
290
|
-
var FormFieldMessage = ({
|
|
291
|
-
id: idProp,
|
|
292
|
-
className,
|
|
293
|
-
ref,
|
|
294
|
-
...others
|
|
295
|
-
}) => {
|
|
296
|
-
const { onMessageIdAdd, onMessageIdRemove } = useFormField();
|
|
297
|
-
const currentId = `${ID_PREFIX}-message-${(0, import_react7.useId)()}`;
|
|
298
|
-
const id = idProp || currentId;
|
|
299
|
-
(0, import_react7.useEffect)(() => {
|
|
300
|
-
onMessageIdAdd(id);
|
|
301
|
-
return () => {
|
|
302
|
-
onMessageIdRemove(id);
|
|
303
|
-
};
|
|
304
|
-
}, [id, onMessageIdAdd, onMessageIdRemove]);
|
|
305
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
306
|
-
"span",
|
|
307
|
-
{
|
|
308
|
-
ref,
|
|
309
|
-
id,
|
|
310
|
-
"data-spark-component": "form-field-message",
|
|
311
|
-
className: (0, import_class_variance_authority4.cx)(className, "text-caption"),
|
|
312
|
-
...others
|
|
313
|
-
}
|
|
314
|
-
);
|
|
315
|
-
};
|
|
316
|
-
FormFieldMessage.displayName = "FormField.Message";
|
|
317
|
-
|
|
318
|
-
// src/form-field/FormFieldStateMessage.tsx
|
|
319
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
320
|
-
var FormFieldStateMessage = ({
|
|
321
|
-
className,
|
|
322
|
-
state,
|
|
323
|
-
children,
|
|
324
|
-
ref,
|
|
325
|
-
...others
|
|
326
|
-
}) => {
|
|
327
|
-
const field = useFormField();
|
|
328
|
-
if (field.state !== state) {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
332
|
-
FormFieldMessage,
|
|
333
|
-
{
|
|
334
|
-
ref,
|
|
335
|
-
"data-spark-component": "form-field-state-message",
|
|
336
|
-
"aria-live": "polite",
|
|
337
|
-
className: (0, import_class_variance_authority5.cx)(
|
|
338
|
-
"gap-sm flex items-center",
|
|
339
|
-
state === "error" ? "text-error" : "text-on-surface/dim-1",
|
|
340
|
-
className
|
|
341
|
-
),
|
|
342
|
-
...others,
|
|
343
|
-
children: [
|
|
344
|
-
state === "alert" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_WarningOutline.WarningOutline, {}) }),
|
|
345
|
-
state === "error" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_AlertOutline.AlertOutline, {}) }),
|
|
346
|
-
state === "success" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Check.Check, {}) }),
|
|
347
|
-
children
|
|
348
|
-
]
|
|
349
|
-
}
|
|
350
|
-
);
|
|
351
|
-
};
|
|
352
|
-
FormFieldStateMessage.displayName = "FormField.StateMessage";
|
|
353
|
-
|
|
354
|
-
// src/form-field/FormFieldAlertMessage.tsx
|
|
355
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
356
|
-
var FormFieldAlertMessage = ({ ref, ...props }) => {
|
|
357
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
358
|
-
FormFieldStateMessage,
|
|
359
|
-
{
|
|
360
|
-
ref,
|
|
361
|
-
"data-spark-component": "form-field-alert-message",
|
|
362
|
-
state: "alert",
|
|
363
|
-
...props
|
|
364
|
-
}
|
|
365
|
-
);
|
|
366
|
-
};
|
|
367
|
-
FormFieldAlertMessage.displayName = "FormField.AlertMessage";
|
|
368
|
-
|
|
369
|
-
// src/form-field/FormFieldCharactersCount.tsx
|
|
370
|
-
var import_class_variance_authority6 = require("class-variance-authority");
|
|
371
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
372
|
-
var FormFieldCharactersCount = ({
|
|
373
|
-
className,
|
|
374
|
-
value = "",
|
|
375
|
-
maxLength,
|
|
376
|
-
ref,
|
|
377
|
-
...others
|
|
378
|
-
}) => {
|
|
379
|
-
const displayValue = `${value.length}/${maxLength}`;
|
|
380
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
381
|
-
"span",
|
|
382
|
-
{
|
|
383
|
-
ref,
|
|
384
|
-
"data-spark-component": "form-field-characters-count",
|
|
385
|
-
className: (0, import_class_variance_authority6.cx)(className, "text-caption", "text-neutral"),
|
|
386
|
-
...others,
|
|
387
|
-
children: displayValue
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
};
|
|
391
|
-
FormFieldCharactersCount.displayName = "FormField.CharactersCount";
|
|
392
|
-
|
|
393
|
-
// src/form-field/FormFieldControl.tsx
|
|
394
|
-
var import_react8 = require("react");
|
|
395
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
396
|
-
var useFormFieldControl = () => {
|
|
397
|
-
const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = (0, import_react8.useContext)(FormFieldContext) || {};
|
|
398
|
-
return {
|
|
399
|
-
id,
|
|
400
|
-
name,
|
|
401
|
-
description,
|
|
402
|
-
disabled,
|
|
403
|
-
readOnly,
|
|
404
|
-
state,
|
|
405
|
-
labelId,
|
|
406
|
-
isInvalid,
|
|
407
|
-
isRequired
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
|
-
var FormFieldControl = ({ children }) => {
|
|
411
|
-
const props = useFormFieldControl();
|
|
412
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: children(props) });
|
|
413
|
-
};
|
|
414
|
-
FormFieldControl.displayName = "FormField.Control";
|
|
415
|
-
|
|
416
|
-
// src/form-field/FormFieldErrorMessage.tsx
|
|
417
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
418
|
-
var FormFieldErrorMessage = ({ ref, ...props }) => {
|
|
419
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
420
|
-
FormFieldStateMessage,
|
|
421
|
-
{
|
|
422
|
-
ref,
|
|
423
|
-
"data-spark-component": "form-field-error-message",
|
|
424
|
-
state: "error",
|
|
425
|
-
...props
|
|
426
|
-
}
|
|
427
|
-
);
|
|
428
|
-
};
|
|
429
|
-
FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
|
|
430
|
-
|
|
431
|
-
// src/form-field/FormFieldHelperMessage.tsx
|
|
432
|
-
var import_class_variance_authority7 = require("class-variance-authority");
|
|
433
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
434
|
-
var FormFieldHelperMessage = ({
|
|
435
|
-
className,
|
|
436
|
-
ref,
|
|
437
|
-
...others
|
|
438
|
-
}) => {
|
|
439
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
440
|
-
FormFieldMessage,
|
|
441
|
-
{
|
|
442
|
-
ref,
|
|
443
|
-
"data-spark-component": "form-field-helper-message",
|
|
444
|
-
className: (0, import_class_variance_authority7.cx)("text-on-surface/dim-1", className),
|
|
445
|
-
...others
|
|
446
|
-
}
|
|
447
|
-
);
|
|
448
|
-
};
|
|
449
|
-
FormFieldHelperMessage.displayName = "FormField.HelperMessage";
|
|
450
|
-
|
|
451
|
-
// src/form-field/FormFieldLabel.tsx
|
|
452
|
-
var import_class_variance_authority11 = require("class-variance-authority");
|
|
453
|
-
|
|
454
|
-
// src/label/Label.tsx
|
|
455
|
-
var import_class_variance_authority8 = require("class-variance-authority");
|
|
456
|
-
var import_radix_ui2 = require("radix-ui");
|
|
457
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
458
|
-
var Label = ({ className, ref, ...others }) => {
|
|
459
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
460
|
-
import_radix_ui2.Label.Label,
|
|
461
|
-
{
|
|
462
|
-
ref,
|
|
463
|
-
"data-spark-component": "label",
|
|
464
|
-
className: (0, import_class_variance_authority8.cx)("text-body-1", className),
|
|
465
|
-
...others
|
|
466
|
-
}
|
|
467
|
-
);
|
|
468
|
-
};
|
|
469
|
-
Label.displayName = "Label";
|
|
470
|
-
|
|
471
|
-
// src/label/LabelRequiredIndicator.tsx
|
|
472
|
-
var import_class_variance_authority9 = require("class-variance-authority");
|
|
473
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
474
|
-
var LabelRequiredIndicator = ({
|
|
475
|
-
className,
|
|
476
|
-
children = "*",
|
|
477
|
-
ref,
|
|
478
|
-
...others
|
|
479
|
-
}) => {
|
|
480
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
481
|
-
"span",
|
|
482
|
-
{
|
|
483
|
-
ref,
|
|
484
|
-
"data-spark-component": "label-required-indicator",
|
|
485
|
-
role: "presentation",
|
|
486
|
-
"aria-hidden": "true",
|
|
487
|
-
className: (0, import_class_variance_authority9.cx)(className, "text-caption text-on-surface/dim-1"),
|
|
488
|
-
...others,
|
|
489
|
-
children
|
|
490
|
-
}
|
|
491
|
-
);
|
|
492
|
-
};
|
|
493
|
-
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
494
|
-
|
|
495
|
-
// src/label/index.ts
|
|
496
|
-
var Label2 = Object.assign(Label, {
|
|
497
|
-
RequiredIndicator: LabelRequiredIndicator
|
|
498
|
-
});
|
|
499
|
-
Label2.displayName = "Label";
|
|
500
|
-
LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
|
|
501
|
-
|
|
502
|
-
// src/form-field/FormFieldRequiredIndicator.tsx
|
|
503
|
-
var import_class_variance_authority10 = require("class-variance-authority");
|
|
504
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
505
|
-
var FormFieldRequiredIndicator = ({
|
|
506
|
-
className,
|
|
507
|
-
ref,
|
|
508
|
-
...props
|
|
509
|
-
}) => {
|
|
510
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label2.RequiredIndicator, { ref, className: (0, import_class_variance_authority10.cx)("ml-sm", className), ...props });
|
|
511
|
-
};
|
|
512
|
-
FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
|
|
513
|
-
|
|
514
|
-
// src/form-field/FormFieldLabel.tsx
|
|
515
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
516
|
-
var FormFieldLabel = ({
|
|
517
|
-
htmlFor: htmlForProp,
|
|
518
|
-
className,
|
|
519
|
-
children,
|
|
520
|
-
requiredIndicator = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FormFieldRequiredIndicator, {}),
|
|
521
|
-
asChild,
|
|
522
|
-
ref,
|
|
523
|
-
...others
|
|
524
|
-
}) => {
|
|
525
|
-
const control = useFormField();
|
|
526
|
-
const { disabled, labelId, isRequired } = control;
|
|
527
|
-
const htmlFor = asChild ? void 0 : htmlForProp || control.id;
|
|
528
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
529
|
-
Label2,
|
|
530
|
-
{
|
|
531
|
-
ref,
|
|
532
|
-
id: labelId,
|
|
533
|
-
"data-spark-component": "form-field-label",
|
|
534
|
-
htmlFor,
|
|
535
|
-
className: (0, import_class_variance_authority11.cx)(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
|
|
536
|
-
asChild,
|
|
537
|
-
...others,
|
|
538
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
539
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slottable, { children }),
|
|
540
|
-
isRequired && requiredIndicator
|
|
541
|
-
] })
|
|
542
|
-
}
|
|
543
|
-
);
|
|
544
|
-
};
|
|
545
|
-
FormFieldLabel.displayName = "FormField.Label";
|
|
546
|
-
|
|
547
|
-
// src/form-field/FormFieldSuccessMessage.tsx
|
|
548
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
549
|
-
var FormFieldSuccessMessage = ({ ref, ...props }) => {
|
|
550
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
551
|
-
FormFieldStateMessage,
|
|
552
|
-
{
|
|
553
|
-
ref,
|
|
554
|
-
"data-spark-component": "form-field-success-message",
|
|
555
|
-
state: "success",
|
|
556
|
-
...props
|
|
557
|
-
}
|
|
558
|
-
);
|
|
559
|
-
};
|
|
560
|
-
FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
|
|
561
|
-
|
|
562
|
-
// src/form-field/index.ts
|
|
563
|
-
var FormField2 = Object.assign(FormField, {
|
|
564
|
-
Label: FormFieldLabel,
|
|
565
|
-
Control: FormFieldControl,
|
|
566
|
-
StateMessage: FormFieldStateMessage,
|
|
567
|
-
SuccessMessage: FormFieldSuccessMessage,
|
|
568
|
-
AlertMessage: FormFieldAlertMessage,
|
|
569
|
-
ErrorMessage: FormFieldErrorMessage,
|
|
570
|
-
HelperMessage: FormFieldHelperMessage,
|
|
571
|
-
RequiredIndicator: FormFieldRequiredIndicator,
|
|
572
|
-
CharactersCount: FormFieldCharactersCount
|
|
573
|
-
});
|
|
574
|
-
FormField2.displayName = "FormField";
|
|
575
|
-
FormFieldLabel.displayName = "FormField.Label";
|
|
576
|
-
FormFieldControl.displayName = "FormField.Control";
|
|
577
|
-
FormFieldStateMessage.displayName = "FormField.StateMessage";
|
|
578
|
-
FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
|
|
579
|
-
FormFieldAlertMessage.displayName = "FormField.AlertMessage";
|
|
580
|
-
FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
|
|
581
|
-
FormFieldHelperMessage.displayName = "FormField.HelperMessage";
|
|
582
|
-
FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
|
|
583
|
-
FormFieldCharactersCount.displayName = "FormField.CharactersCount";
|
|
584
|
-
|
|
585
174
|
// src/input/InputGroup.tsx
|
|
175
|
+
var import_form_field = require("@spark-ui/components/form-field");
|
|
586
176
|
var import_use_combined_state = require("@spark-ui/use-combined-state");
|
|
587
177
|
var import_use_merge_refs = require("@spark-ui/use-merge-refs");
|
|
588
|
-
var
|
|
178
|
+
var import_react4 = require("react");
|
|
589
179
|
|
|
590
180
|
// src/input/InputGroup.styles.ts
|
|
591
|
-
var
|
|
592
|
-
var inputGroupStyles = (0,
|
|
181
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
182
|
+
var inputGroupStyles = (0, import_class_variance_authority3.cva)(["relative inline-flex w-full"], {
|
|
593
183
|
variants: {
|
|
594
184
|
/**
|
|
595
185
|
* When `true`, prevents the user from interacting.
|
|
@@ -626,7 +216,7 @@ var inputGroupStyles = (0, import_class_variance_authority12.cva)(["relative inl
|
|
|
626
216
|
});
|
|
627
217
|
|
|
628
218
|
// src/input/InputGroup.tsx
|
|
629
|
-
var
|
|
219
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
630
220
|
var InputGroup = ({
|
|
631
221
|
className,
|
|
632
222
|
children: childrenProp,
|
|
@@ -643,18 +233,18 @@ var InputGroup = ({
|
|
|
643
233
|
const findElement = (...values) => {
|
|
644
234
|
return children.find((child) => values.includes(getElementId(child) || ""));
|
|
645
235
|
};
|
|
646
|
-
const children =
|
|
236
|
+
const children = import_react4.Children.toArray(childrenProp).filter(import_react4.isValidElement);
|
|
647
237
|
const input = findElement("Input");
|
|
648
238
|
const props = input?.props || {};
|
|
649
|
-
const inputRef = (0,
|
|
650
|
-
const onClearRef = (0,
|
|
239
|
+
const inputRef = (0, import_react4.useRef)(null);
|
|
240
|
+
const onClearRef = (0, import_react4.useRef)(onClear);
|
|
651
241
|
const ref = (0, import_use_merge_refs.useMergeRefs)(input?.ref, inputRef);
|
|
652
242
|
const [value, onChange] = (0, import_use_combined_state.useCombinedState)(
|
|
653
243
|
props.value,
|
|
654
244
|
props.defaultValue,
|
|
655
245
|
props.onValueChange
|
|
656
246
|
);
|
|
657
|
-
const field = useFormFieldControl();
|
|
247
|
+
const field = (0, import_form_field.useFormFieldControl)();
|
|
658
248
|
const state = field.state ?? stateProp;
|
|
659
249
|
const disabled = field.disabled || !!disabledProp;
|
|
660
250
|
const readOnly = field.readOnly || !!readOnlyProp;
|
|
@@ -674,14 +264,14 @@ var InputGroup = ({
|
|
|
674
264
|
}
|
|
675
265
|
onChange(event.target.value);
|
|
676
266
|
};
|
|
677
|
-
const handleClear = (0,
|
|
267
|
+
const handleClear = (0, import_react4.useCallback)(() => {
|
|
678
268
|
if (onClearRef.current) {
|
|
679
269
|
onClearRef.current();
|
|
680
270
|
}
|
|
681
271
|
onChange("");
|
|
682
272
|
inputRef.current.focus();
|
|
683
273
|
}, [onChange]);
|
|
684
|
-
const current = (0,
|
|
274
|
+
const current = (0, import_react4.useMemo)(() => {
|
|
685
275
|
return {
|
|
686
276
|
state,
|
|
687
277
|
disabled,
|
|
@@ -704,10 +294,10 @@ var InputGroup = ({
|
|
|
704
294
|
hasClearButton,
|
|
705
295
|
handleClear
|
|
706
296
|
]);
|
|
707
|
-
(0,
|
|
297
|
+
(0, import_react4.useEffect)(() => {
|
|
708
298
|
onClearRef.current = onClear;
|
|
709
299
|
}, [onClear]);
|
|
710
|
-
return /* @__PURE__ */ (0,
|
|
300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InputGroupContext.Provider, { value: current, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
711
301
|
"div",
|
|
712
302
|
{
|
|
713
303
|
ref: forwardedRef,
|
|
@@ -715,8 +305,8 @@ var InputGroup = ({
|
|
|
715
305
|
...others,
|
|
716
306
|
children: [
|
|
717
307
|
hasLeadingAddon && leadingAddon,
|
|
718
|
-
/* @__PURE__ */ (0,
|
|
719
|
-
input && (0,
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative inline-flex w-full", children: [
|
|
309
|
+
input && (0, import_react4.cloneElement)(input, {
|
|
720
310
|
ref,
|
|
721
311
|
defaultValue: void 0,
|
|
722
312
|
value: value ?? "",
|
|
@@ -734,14 +324,14 @@ var InputGroup = ({
|
|
|
734
324
|
InputGroup.displayName = "InputGroup";
|
|
735
325
|
|
|
736
326
|
// src/input/InputLeadingAddon.tsx
|
|
737
|
-
var
|
|
327
|
+
var import_class_variance_authority5 = require("class-variance-authority");
|
|
738
328
|
|
|
739
329
|
// src/input/InputAddon.tsx
|
|
740
|
-
var
|
|
330
|
+
var import_react5 = require("react");
|
|
741
331
|
|
|
742
332
|
// src/input/InputAddon.styles.ts
|
|
743
|
-
var
|
|
744
|
-
var inputAddonStyles = (0,
|
|
333
|
+
var import_class_variance_authority4 = require("class-variance-authority");
|
|
334
|
+
var inputAddonStyles = (0, import_class_variance_authority4.cva)(
|
|
745
335
|
[
|
|
746
336
|
"overflow-hidden",
|
|
747
337
|
"border-sm",
|
|
@@ -807,7 +397,7 @@ var inputAddonStyles = (0, import_class_variance_authority13.cva)(
|
|
|
807
397
|
);
|
|
808
398
|
|
|
809
399
|
// src/input/InputAddon.tsx
|
|
810
|
-
var
|
|
400
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
811
401
|
var InputAddon = ({
|
|
812
402
|
asChild: asChildProp,
|
|
813
403
|
className,
|
|
@@ -818,14 +408,14 @@ var InputAddon = ({
|
|
|
818
408
|
const { state, disabled, readOnly } = useInputGroup();
|
|
819
409
|
const isRawText = typeof children === "string";
|
|
820
410
|
const asChild = !!(isRawText ? false : asChildProp);
|
|
821
|
-
const child = isRawText ? children :
|
|
411
|
+
const child = isRawText ? children : import_react5.Children.only(children);
|
|
822
412
|
const Component = asChild && !isRawText ? Slot : "div";
|
|
823
413
|
const getDesign = () => {
|
|
824
414
|
if (isRawText) return "text";
|
|
825
415
|
return asChild ? "solid" : "inline";
|
|
826
416
|
};
|
|
827
417
|
const design = getDesign();
|
|
828
|
-
return /* @__PURE__ */ (0,
|
|
418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
829
419
|
Component,
|
|
830
420
|
{
|
|
831
421
|
ref,
|
|
@@ -846,15 +436,15 @@ var InputAddon = ({
|
|
|
846
436
|
InputAddon.displayName = "InputGroup.Addon";
|
|
847
437
|
|
|
848
438
|
// src/input/InputLeadingAddon.tsx
|
|
849
|
-
var
|
|
439
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
850
440
|
var Root2 = ({ className, ref, ...others }) => {
|
|
851
441
|
const { disabled, readOnly } = useInputGroup();
|
|
852
442
|
const isInactive = disabled || readOnly;
|
|
853
|
-
return /* @__PURE__ */ (0,
|
|
443
|
+
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)(
|
|
854
444
|
InputAddon,
|
|
855
445
|
{
|
|
856
446
|
ref,
|
|
857
|
-
className: (0,
|
|
447
|
+
className: (0, import_class_variance_authority5.cx)(className, "rounded-r-0! mr-[-1px] rounded-l-lg"),
|
|
858
448
|
...others
|
|
859
449
|
}
|
|
860
450
|
) });
|
|
@@ -865,19 +455,19 @@ var InputLeadingAddon = Object.assign(Root2, {
|
|
|
865
455
|
Root2.displayName = "InputGroup.LeadingAddon";
|
|
866
456
|
|
|
867
457
|
// src/input/InputLeadingIcon.tsx
|
|
868
|
-
var
|
|
458
|
+
var import_class_variance_authority7 = require("class-variance-authority");
|
|
869
459
|
|
|
870
460
|
// src/input/InputIcon.tsx
|
|
871
|
-
var
|
|
872
|
-
var
|
|
461
|
+
var import_class_variance_authority6 = require("class-variance-authority");
|
|
462
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
873
463
|
var InputIcon = ({ className, intent, children, ...others }) => {
|
|
874
464
|
const { disabled, readOnly } = useInputGroup();
|
|
875
465
|
const isInactive = disabled || readOnly;
|
|
876
|
-
return /* @__PURE__ */ (0,
|
|
466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
877
467
|
Icon,
|
|
878
468
|
{
|
|
879
469
|
intent,
|
|
880
|
-
className: (0,
|
|
470
|
+
className: (0, import_class_variance_authority6.cx)(
|
|
881
471
|
className,
|
|
882
472
|
"pointer-events-none absolute top-[calc(var(--spacing-sz-44)/2)] -translate-y-1/2",
|
|
883
473
|
intent ? void 0 : "text-neutral peer-focus:text-outline-high",
|
|
@@ -891,22 +481,22 @@ var InputIcon = ({ className, intent, children, ...others }) => {
|
|
|
891
481
|
InputIcon.displayName = "InputGroup.Icon";
|
|
892
482
|
|
|
893
483
|
// src/input/InputLeadingIcon.tsx
|
|
894
|
-
var
|
|
895
|
-
var InputLeadingIcon = ({ className, ...others }) => /* @__PURE__ */ (0,
|
|
484
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
485
|
+
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 });
|
|
896
486
|
InputLeadingIcon.id = "LeadingIcon";
|
|
897
487
|
InputLeadingIcon.displayName = "InputGroup.LeadingIcon";
|
|
898
488
|
|
|
899
489
|
// src/input/InputTrailingAddon.tsx
|
|
900
|
-
var
|
|
901
|
-
var
|
|
490
|
+
var import_class_variance_authority8 = require("class-variance-authority");
|
|
491
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
902
492
|
var Root3 = ({ className, ref, ...others }) => {
|
|
903
493
|
const { disabled, readOnly } = useInputGroup();
|
|
904
494
|
const isInactive = disabled || readOnly;
|
|
905
|
-
return /* @__PURE__ */ (0,
|
|
495
|
+
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)(
|
|
906
496
|
InputAddon,
|
|
907
497
|
{
|
|
908
498
|
ref,
|
|
909
|
-
className: (0,
|
|
499
|
+
className: (0, import_class_variance_authority8.cx)(className, "rounded-l-0! ml-[-1px] rounded-r-lg"),
|
|
910
500
|
...others
|
|
911
501
|
}
|
|
912
502
|
) });
|
|
@@ -917,15 +507,18 @@ var InputTrailingAddon = Object.assign(Root3, {
|
|
|
917
507
|
Root3.displayName = "InputGroup.TrailingAddon";
|
|
918
508
|
|
|
919
509
|
// src/input/InputTrailingIcon.tsx
|
|
920
|
-
var
|
|
921
|
-
var
|
|
922
|
-
var InputTrailingIcon = ({ className, ...others }) => /* @__PURE__ */ (0,
|
|
510
|
+
var import_class_variance_authority9 = require("class-variance-authority");
|
|
511
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
512
|
+
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 });
|
|
923
513
|
InputTrailingIcon.id = "TrailingIcon";
|
|
924
514
|
InputTrailingIcon.displayName = "InputGroup.TrailingIcon";
|
|
925
515
|
|
|
516
|
+
// src/input/Input.tsx
|
|
517
|
+
var import_form_field2 = require("@spark-ui/components/form-field");
|
|
518
|
+
|
|
926
519
|
// src/input/Input.styles.ts
|
|
927
|
-
var
|
|
928
|
-
var inputStyles = (0,
|
|
520
|
+
var import_class_variance_authority10 = require("class-variance-authority");
|
|
521
|
+
var inputStyles = (0, import_class_variance_authority10.cva)(
|
|
929
522
|
[
|
|
930
523
|
"relative",
|
|
931
524
|
"border-sm",
|
|
@@ -1021,7 +614,7 @@ var inputStyles = (0, import_class_variance_authority19.cva)(
|
|
|
1021
614
|
);
|
|
1022
615
|
|
|
1023
616
|
// src/input/Input.tsx
|
|
1024
|
-
var
|
|
617
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1025
618
|
var Root4 = ({
|
|
1026
619
|
className,
|
|
1027
620
|
asChild = false,
|
|
@@ -1033,7 +626,7 @@ var Root4 = ({
|
|
|
1033
626
|
ref,
|
|
1034
627
|
...others
|
|
1035
628
|
}) => {
|
|
1036
|
-
const field = useFormFieldControl();
|
|
629
|
+
const field = (0, import_form_field2.useFormFieldControl)();
|
|
1037
630
|
const group = useInputGroup();
|
|
1038
631
|
const { id, name, isInvalid, isRequired, description } = field;
|
|
1039
632
|
const {
|
|
@@ -1064,7 +657,7 @@ var Root4 = ({
|
|
|
1064
657
|
onClear();
|
|
1065
658
|
}
|
|
1066
659
|
};
|
|
1067
|
-
return /* @__PURE__ */ (0,
|
|
660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1068
661
|
Component,
|
|
1069
662
|
{
|
|
1070
663
|
ref,
|