@edux-design/forms 0.0.7 → 0.0.9
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/dist/index.d.mts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +95 -34
- package/dist/index.mjs +106 -45
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
|
|
4
3
|
declare function Label({ children, hint, description, ...props }: {
|
|
@@ -57,7 +56,29 @@ type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
57
56
|
}) => void;
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Minimal radio control wired to the surrounding Field context.
|
|
61
|
+
*
|
|
62
|
+
* @typedef {React.InputHTMLAttributes<HTMLInputElement> & {
|
|
63
|
+
* className?: string,
|
|
64
|
+
* }} RadioProps
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Radio component.
|
|
68
|
+
*
|
|
69
|
+
* Provides a styled radio input that integrates with the Field context and
|
|
70
|
+
* supports both controlled (`checked`) and uncontrolled (`defaultChecked`) use.
|
|
71
|
+
*
|
|
72
|
+
* @component
|
|
73
|
+
* @type {React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>}
|
|
74
|
+
*/
|
|
75
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
76
|
+
/**
|
|
77
|
+
* Minimal radio control wired to the surrounding Field context.
|
|
78
|
+
*/
|
|
79
|
+
type RadioProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
80
|
+
className?: string;
|
|
81
|
+
};
|
|
61
82
|
|
|
62
83
|
declare const Checkbox: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
|
|
63
84
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as react from 'react';
|
|
3
2
|
|
|
4
3
|
declare function Label({ children, hint, description, ...props }: {
|
|
@@ -57,7 +56,29 @@ type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
57
56
|
}) => void;
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Minimal radio control wired to the surrounding Field context.
|
|
61
|
+
*
|
|
62
|
+
* @typedef {React.InputHTMLAttributes<HTMLInputElement> & {
|
|
63
|
+
* className?: string,
|
|
64
|
+
* }} RadioProps
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Radio component.
|
|
68
|
+
*
|
|
69
|
+
* Provides a styled radio input that integrates with the Field context and
|
|
70
|
+
* supports both controlled (`checked`) and uncontrolled (`defaultChecked`) use.
|
|
71
|
+
*
|
|
72
|
+
* @component
|
|
73
|
+
* @type {React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>}
|
|
74
|
+
*/
|
|
75
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
76
|
+
/**
|
|
77
|
+
* Minimal radio control wired to the surrounding Field context.
|
|
78
|
+
*/
|
|
79
|
+
type RadioProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
80
|
+
className?: string;
|
|
81
|
+
};
|
|
61
82
|
|
|
62
83
|
declare const Checkbox: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
|
|
63
84
|
|
package/dist/index.js
CHANGED
|
@@ -283,34 +283,76 @@ Field.Feedback = Feedback;
|
|
|
283
283
|
var import_react6 = __toESM(require("react"));
|
|
284
284
|
var import_utils3 = require("@edux-design/utils");
|
|
285
285
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
286
|
+
var Radio = (0, import_react6.forwardRef)(
|
|
287
|
+
({
|
|
288
|
+
className,
|
|
289
|
+
id: providedId,
|
|
290
|
+
checked,
|
|
291
|
+
defaultChecked,
|
|
292
|
+
disabled,
|
|
293
|
+
onChange,
|
|
294
|
+
...rest
|
|
295
|
+
}, ref) => {
|
|
296
|
+
const {
|
|
297
|
+
["aria-describedby"]: ariaDescribedByProp,
|
|
298
|
+
...inputProps
|
|
299
|
+
} = rest;
|
|
300
|
+
const { labelHTMLForId, describedByIds = [] } = useFieldContext();
|
|
301
|
+
const resolvedId = providedId ?? labelHTMLForId;
|
|
302
|
+
const isControlled = checked !== void 0;
|
|
303
|
+
const isDisabled = Boolean(disabled);
|
|
304
|
+
const describedByTokens = [
|
|
305
|
+
...describedByIds,
|
|
306
|
+
...ariaDescribedByProp ? ariaDescribedByProp.split(" ") : []
|
|
307
|
+
].filter(Boolean);
|
|
308
|
+
const ariaDescribedBy = describedByTokens.length ? describedByTokens.join(" ") : void 0;
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
310
|
+
"div",
|
|
302
311
|
{
|
|
303
312
|
className: (0, import_utils3.cx)(
|
|
304
|
-
"
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
313
|
+
"relative inline-flex h-[28px] w-[28px] items-center justify-center",
|
|
314
|
+
className
|
|
315
|
+
),
|
|
316
|
+
children: [
|
|
317
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
318
|
+
"input",
|
|
319
|
+
{
|
|
320
|
+
id: resolvedId,
|
|
321
|
+
ref,
|
|
322
|
+
type: "radio",
|
|
323
|
+
className: (0, import_utils3.cx)(
|
|
324
|
+
"peer absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-full bg-transparent",
|
|
325
|
+
"focus:shadow-focus focus-visible:shadow-focus focus:outline-none focus-visible:outline-none",
|
|
326
|
+
isDisabled && "cursor-not-allowed"
|
|
327
|
+
),
|
|
328
|
+
"aria-describedby": ariaDescribedBy,
|
|
329
|
+
"aria-disabled": isDisabled ? "true" : void 0,
|
|
330
|
+
disabled: isDisabled,
|
|
331
|
+
checked: isControlled ? checked : void 0,
|
|
332
|
+
defaultChecked: !isControlled ? defaultChecked : void 0,
|
|
333
|
+
onChange,
|
|
334
|
+
...inputProps
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
338
|
+
"span",
|
|
339
|
+
{
|
|
340
|
+
"aria-hidden": "true",
|
|
341
|
+
"data-slot": "radio-control",
|
|
342
|
+
className: (0, import_utils3.cx)(
|
|
343
|
+
"block h-full w-full rounded-full border-2 border-border-base transition-colors",
|
|
344
|
+
"peer-checked:border-border-primary-base peer-checked:border-[8px]",
|
|
345
|
+
"peer-hover:border-2 peer-hover:border-border-primary-base peer-checked:peer-hover:border-[8px] peer-checked:peer-hover:border-border-primary-base",
|
|
346
|
+
"peer-disabled:border-border-subtle peer-disabled:bg-bg-inactive"
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
]
|
|
310
351
|
}
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
Radio.displayName = "Radio";
|
|
314
356
|
|
|
315
357
|
// src/elements/Checkbox.jsx
|
|
316
358
|
var import_react7 = __toESM(require("react"));
|
|
@@ -383,6 +425,7 @@ var Checkbox = (0, import_react7.forwardRef)(
|
|
|
383
425
|
({
|
|
384
426
|
className,
|
|
385
427
|
indeterminate = false,
|
|
428
|
+
plus = false,
|
|
386
429
|
variant = "primary",
|
|
387
430
|
disabled,
|
|
388
431
|
id: providedId,
|
|
@@ -407,7 +450,7 @@ var Checkbox = (0, import_react7.forwardRef)(
|
|
|
407
450
|
...ariaDescribedByProp ? ariaDescribedByProp.split(" ") : []
|
|
408
451
|
].filter(Boolean);
|
|
409
452
|
const describedBy = describedByTokens.length ? describedByTokens.join(" ") : void 0;
|
|
410
|
-
const ariaChecked = indeterminate ? "mixed" : ariaCheckedProp;
|
|
453
|
+
const ariaChecked = indeterminate || plus ? "mixed" : ariaCheckedProp;
|
|
411
454
|
const inputRef = (0, import_react7.useRef)(null);
|
|
412
455
|
const setRefs = (0, import_react7.useCallback)(
|
|
413
456
|
(node) => {
|
|
@@ -468,8 +511,8 @@ var Checkbox = (0, import_react7.forwardRef)(
|
|
|
468
511
|
!isDisabled && intent.activeBg,
|
|
469
512
|
intent.peerSelectedBorder,
|
|
470
513
|
intent.peerSelectedBg,
|
|
471
|
-
indeterminate && intent.selectedBorder,
|
|
472
|
-
indeterminate && intent.selectedBg
|
|
514
|
+
(indeterminate || plus) && intent.selectedBorder,
|
|
515
|
+
(indeterminate || plus) && intent.selectedBg
|
|
473
516
|
)
|
|
474
517
|
}
|
|
475
518
|
),
|
|
@@ -481,7 +524,7 @@ var Checkbox = (0, import_react7.forwardRef)(
|
|
|
481
524
|
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
482
525
|
intent.iconColor,
|
|
483
526
|
"peer-disabled:text-fg-inactive",
|
|
484
|
-
indeterminate ? "opacity-0" : "opacity-0 peer-checked:opacity-100"
|
|
527
|
+
indeterminate || plus ? "opacity-0" : "opacity-0 peer-checked:opacity-100"
|
|
485
528
|
)
|
|
486
529
|
}
|
|
487
530
|
),
|
|
@@ -493,7 +536,19 @@ var Checkbox = (0, import_react7.forwardRef)(
|
|
|
493
536
|
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
494
537
|
intent.iconColor,
|
|
495
538
|
"peer-disabled:text-fg-inactive",
|
|
496
|
-
indeterminate ? "opacity-100" : "opacity-0"
|
|
539
|
+
indeterminate && !plus ? "opacity-100" : "opacity-0"
|
|
540
|
+
)
|
|
541
|
+
}
|
|
542
|
+
),
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
544
|
+
import_icons3.Plus,
|
|
545
|
+
{
|
|
546
|
+
"aria-hidden": "true",
|
|
547
|
+
className: (0, import_utils4.cx)(
|
|
548
|
+
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
549
|
+
intent.iconColor,
|
|
550
|
+
"peer-disabled:text-fg-inactive",
|
|
551
|
+
plus ? "opacity-100" : "opacity-0"
|
|
497
552
|
)
|
|
498
553
|
}
|
|
499
554
|
)
|
|
@@ -578,6 +633,7 @@ var Switch = (0, import_react8.forwardRef)(
|
|
|
578
633
|
disabled,
|
|
579
634
|
id: providedId,
|
|
580
635
|
checked,
|
|
636
|
+
defaultChecked = false,
|
|
581
637
|
onChange,
|
|
582
638
|
...rest
|
|
583
639
|
}, ref) => {
|
|
@@ -593,8 +649,11 @@ var Switch = (0, import_react8.forwardRef)(
|
|
|
593
649
|
const derivedDisabled = Boolean(disabled);
|
|
594
650
|
const isInactiveVariant = variant === "inactive";
|
|
595
651
|
const isDisabled = derivedDisabled || isInactiveVariant;
|
|
596
|
-
const [unControlledChecked, setUnControlledChecked] = (0, import_react8.useState)(
|
|
597
|
-
|
|
652
|
+
const [unControlledChecked, setUnControlledChecked] = (0, import_react8.useState)(
|
|
653
|
+
() => Boolean(defaultChecked)
|
|
654
|
+
);
|
|
655
|
+
const isControlled = checked !== void 0;
|
|
656
|
+
const isOn = isControlled ? checked : unControlledChecked;
|
|
598
657
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
599
658
|
"div",
|
|
600
659
|
{
|
|
@@ -608,8 +667,8 @@ var Switch = (0, import_react8.forwardRef)(
|
|
|
608
667
|
{
|
|
609
668
|
id: resolvedId,
|
|
610
669
|
ref,
|
|
611
|
-
onChange: onChange ? onChange : () => setUnControlledChecked(
|
|
612
|
-
checked:
|
|
670
|
+
onChange: onChange ? onChange : (event) => setUnControlledChecked(event.target.checked),
|
|
671
|
+
checked: isControlled ? checked : unControlledChecked,
|
|
613
672
|
type: "checkbox",
|
|
614
673
|
role: "switch",
|
|
615
674
|
className: (0, import_utils5.cx)(
|
|
@@ -658,12 +717,14 @@ var Switch = (0, import_react8.forwardRef)(
|
|
|
658
717
|
import_icons4.Close,
|
|
659
718
|
{
|
|
660
719
|
"aria-hidden": "true",
|
|
720
|
+
"data-state": "off",
|
|
661
721
|
className: (0, import_utils5.cx)("absolute duration-150", intent.offIcon)
|
|
662
722
|
}
|
|
663
723
|
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
664
724
|
import_icons4.Check,
|
|
665
725
|
{
|
|
666
726
|
"aria-hidden": "true",
|
|
727
|
+
"data-state": "on",
|
|
667
728
|
className: (0, import_utils5.cx)("absolute duration-150", intent.onIcon)
|
|
668
729
|
}
|
|
669
730
|
)
|
package/dist/index.mjs
CHANGED
|
@@ -242,42 +242,84 @@ function Feedback({ id, tone, children, className, ...rest }) {
|
|
|
242
242
|
Field.Feedback = Feedback;
|
|
243
243
|
|
|
244
244
|
// src/elements/Radio.jsx
|
|
245
|
-
import React5 from "react";
|
|
245
|
+
import React5, { forwardRef as forwardRef2 } from "react";
|
|
246
246
|
import { cx as cx3 } from "@edux-design/utils";
|
|
247
247
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
248
|
+
var Radio = forwardRef2(
|
|
249
|
+
({
|
|
250
|
+
className,
|
|
251
|
+
id: providedId,
|
|
252
|
+
checked,
|
|
253
|
+
defaultChecked,
|
|
254
|
+
disabled,
|
|
255
|
+
onChange,
|
|
256
|
+
...rest
|
|
257
|
+
}, ref) => {
|
|
258
|
+
const {
|
|
259
|
+
["aria-describedby"]: ariaDescribedByProp,
|
|
260
|
+
...inputProps
|
|
261
|
+
} = rest;
|
|
262
|
+
const { labelHTMLForId, describedByIds = [] } = useFieldContext();
|
|
263
|
+
const resolvedId = providedId ?? labelHTMLForId;
|
|
264
|
+
const isControlled = checked !== void 0;
|
|
265
|
+
const isDisabled = Boolean(disabled);
|
|
266
|
+
const describedByTokens = [
|
|
267
|
+
...describedByIds,
|
|
268
|
+
...ariaDescribedByProp ? ariaDescribedByProp.split(" ") : []
|
|
269
|
+
].filter(Boolean);
|
|
270
|
+
const ariaDescribedBy = describedByTokens.length ? describedByTokens.join(" ") : void 0;
|
|
271
|
+
return /* @__PURE__ */ jsxs4(
|
|
272
|
+
"div",
|
|
264
273
|
{
|
|
265
274
|
className: cx3(
|
|
266
|
-
"
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
"relative inline-flex h-[28px] w-[28px] items-center justify-center",
|
|
276
|
+
className
|
|
277
|
+
),
|
|
278
|
+
children: [
|
|
279
|
+
/* @__PURE__ */ jsx5(
|
|
280
|
+
"input",
|
|
281
|
+
{
|
|
282
|
+
id: resolvedId,
|
|
283
|
+
ref,
|
|
284
|
+
type: "radio",
|
|
285
|
+
className: cx3(
|
|
286
|
+
"peer absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-full bg-transparent",
|
|
287
|
+
"focus:shadow-focus focus-visible:shadow-focus focus:outline-none focus-visible:outline-none",
|
|
288
|
+
isDisabled && "cursor-not-allowed"
|
|
289
|
+
),
|
|
290
|
+
"aria-describedby": ariaDescribedBy,
|
|
291
|
+
"aria-disabled": isDisabled ? "true" : void 0,
|
|
292
|
+
disabled: isDisabled,
|
|
293
|
+
checked: isControlled ? checked : void 0,
|
|
294
|
+
defaultChecked: !isControlled ? defaultChecked : void 0,
|
|
295
|
+
onChange,
|
|
296
|
+
...inputProps
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
/* @__PURE__ */ jsx5(
|
|
300
|
+
"span",
|
|
301
|
+
{
|
|
302
|
+
"aria-hidden": "true",
|
|
303
|
+
"data-slot": "radio-control",
|
|
304
|
+
className: cx3(
|
|
305
|
+
"block h-full w-full rounded-full border-2 border-border-base transition-colors",
|
|
306
|
+
"peer-checked:border-border-primary-base peer-checked:border-[8px]",
|
|
307
|
+
"peer-hover:border-2 peer-hover:border-border-primary-base peer-checked:peer-hover:border-[8px] peer-checked:peer-hover:border-border-primary-base",
|
|
308
|
+
"peer-disabled:border-border-subtle peer-disabled:bg-bg-inactive"
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
]
|
|
272
313
|
}
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
Radio.displayName = "Radio";
|
|
276
318
|
|
|
277
319
|
// src/elements/Checkbox.jsx
|
|
278
|
-
import React6, { forwardRef as
|
|
320
|
+
import React6, { forwardRef as forwardRef3, useCallback as useCallback3, useEffect as useEffect2, useRef } from "react";
|
|
279
321
|
import { cx as cx4 } from "@edux-design/utils";
|
|
280
|
-
import { Check, Indeterminate } from "@edux-design/icons";
|
|
322
|
+
import { Check, Indeterminate, Plus } from "@edux-design/icons";
|
|
281
323
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
282
324
|
var VARIANT_INTENTS = {
|
|
283
325
|
primary: {
|
|
@@ -341,10 +383,11 @@ var VARIANT_INTENTS = {
|
|
|
341
383
|
iconColor: "text-fg-inactive"
|
|
342
384
|
}
|
|
343
385
|
};
|
|
344
|
-
var Checkbox =
|
|
386
|
+
var Checkbox = forwardRef3(
|
|
345
387
|
({
|
|
346
388
|
className,
|
|
347
389
|
indeterminate = false,
|
|
390
|
+
plus = false,
|
|
348
391
|
variant = "primary",
|
|
349
392
|
disabled,
|
|
350
393
|
id: providedId,
|
|
@@ -369,7 +412,7 @@ var Checkbox = forwardRef2(
|
|
|
369
412
|
...ariaDescribedByProp ? ariaDescribedByProp.split(" ") : []
|
|
370
413
|
].filter(Boolean);
|
|
371
414
|
const describedBy = describedByTokens.length ? describedByTokens.join(" ") : void 0;
|
|
372
|
-
const ariaChecked = indeterminate ? "mixed" : ariaCheckedProp;
|
|
415
|
+
const ariaChecked = indeterminate || plus ? "mixed" : ariaCheckedProp;
|
|
373
416
|
const inputRef = useRef(null);
|
|
374
417
|
const setRefs = useCallback3(
|
|
375
418
|
(node) => {
|
|
@@ -430,8 +473,8 @@ var Checkbox = forwardRef2(
|
|
|
430
473
|
!isDisabled && intent.activeBg,
|
|
431
474
|
intent.peerSelectedBorder,
|
|
432
475
|
intent.peerSelectedBg,
|
|
433
|
-
indeterminate && intent.selectedBorder,
|
|
434
|
-
indeterminate && intent.selectedBg
|
|
476
|
+
(indeterminate || plus) && intent.selectedBorder,
|
|
477
|
+
(indeterminate || plus) && intent.selectedBg
|
|
435
478
|
)
|
|
436
479
|
}
|
|
437
480
|
),
|
|
@@ -443,7 +486,7 @@ var Checkbox = forwardRef2(
|
|
|
443
486
|
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
444
487
|
intent.iconColor,
|
|
445
488
|
"peer-disabled:text-fg-inactive",
|
|
446
|
-
indeterminate ? "opacity-0" : "opacity-0 peer-checked:opacity-100"
|
|
489
|
+
indeterminate || plus ? "opacity-0" : "opacity-0 peer-checked:opacity-100"
|
|
447
490
|
)
|
|
448
491
|
}
|
|
449
492
|
),
|
|
@@ -455,7 +498,19 @@ var Checkbox = forwardRef2(
|
|
|
455
498
|
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
456
499
|
intent.iconColor,
|
|
457
500
|
"peer-disabled:text-fg-inactive",
|
|
458
|
-
indeterminate ? "opacity-100" : "opacity-0"
|
|
501
|
+
indeterminate && !plus ? "opacity-100" : "opacity-0"
|
|
502
|
+
)
|
|
503
|
+
}
|
|
504
|
+
),
|
|
505
|
+
/* @__PURE__ */ jsx6(
|
|
506
|
+
Plus,
|
|
507
|
+
{
|
|
508
|
+
"aria-hidden": "true",
|
|
509
|
+
className: cx4(
|
|
510
|
+
"pointer-events-none absolute left-1/2 top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 transition-opacity duration-150",
|
|
511
|
+
intent.iconColor,
|
|
512
|
+
"peer-disabled:text-fg-inactive",
|
|
513
|
+
plus ? "opacity-100" : "opacity-0"
|
|
459
514
|
)
|
|
460
515
|
}
|
|
461
516
|
)
|
|
@@ -467,7 +522,7 @@ var Checkbox = forwardRef2(
|
|
|
467
522
|
Checkbox.displayName = "Checkbox";
|
|
468
523
|
|
|
469
524
|
// src/elements/Switch.jsx
|
|
470
|
-
import React7, { forwardRef as
|
|
525
|
+
import React7, { forwardRef as forwardRef4, useState as useState2 } from "react";
|
|
471
526
|
import { cx as cx5 } from "@edux-design/utils";
|
|
472
527
|
import { Check as Check2, Close as Close3 } from "@edux-design/icons";
|
|
473
528
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -533,13 +588,14 @@ var SWITCH_INTENTS = {
|
|
|
533
588
|
onIcon: "text-fg-inactive"
|
|
534
589
|
}
|
|
535
590
|
};
|
|
536
|
-
var Switch =
|
|
591
|
+
var Switch = forwardRef4(
|
|
537
592
|
({
|
|
538
593
|
className,
|
|
539
594
|
variant = "primary",
|
|
540
595
|
disabled,
|
|
541
596
|
id: providedId,
|
|
542
597
|
checked,
|
|
598
|
+
defaultChecked = false,
|
|
543
599
|
onChange,
|
|
544
600
|
...rest
|
|
545
601
|
}, ref) => {
|
|
@@ -555,8 +611,11 @@ var Switch = forwardRef3(
|
|
|
555
611
|
const derivedDisabled = Boolean(disabled);
|
|
556
612
|
const isInactiveVariant = variant === "inactive";
|
|
557
613
|
const isDisabled = derivedDisabled || isInactiveVariant;
|
|
558
|
-
const [unControlledChecked, setUnControlledChecked] = useState2(
|
|
559
|
-
|
|
614
|
+
const [unControlledChecked, setUnControlledChecked] = useState2(
|
|
615
|
+
() => Boolean(defaultChecked)
|
|
616
|
+
);
|
|
617
|
+
const isControlled = checked !== void 0;
|
|
618
|
+
const isOn = isControlled ? checked : unControlledChecked;
|
|
560
619
|
return /* @__PURE__ */ jsxs6(
|
|
561
620
|
"div",
|
|
562
621
|
{
|
|
@@ -570,8 +629,8 @@ var Switch = forwardRef3(
|
|
|
570
629
|
{
|
|
571
630
|
id: resolvedId,
|
|
572
631
|
ref,
|
|
573
|
-
onChange: onChange ? onChange : () => setUnControlledChecked(
|
|
574
|
-
checked:
|
|
632
|
+
onChange: onChange ? onChange : (event) => setUnControlledChecked(event.target.checked),
|
|
633
|
+
checked: isControlled ? checked : unControlledChecked,
|
|
575
634
|
type: "checkbox",
|
|
576
635
|
role: "switch",
|
|
577
636
|
className: cx5(
|
|
@@ -620,12 +679,14 @@ var Switch = forwardRef3(
|
|
|
620
679
|
Close3,
|
|
621
680
|
{
|
|
622
681
|
"aria-hidden": "true",
|
|
682
|
+
"data-state": "off",
|
|
623
683
|
className: cx5("absolute duration-150", intent.offIcon)
|
|
624
684
|
}
|
|
625
685
|
) : /* @__PURE__ */ jsx7(
|
|
626
686
|
Check2,
|
|
627
687
|
{
|
|
628
688
|
"aria-hidden": "true",
|
|
689
|
+
"data-state": "on",
|
|
629
690
|
className: cx5("absolute duration-150", intent.onIcon)
|
|
630
691
|
}
|
|
631
692
|
)
|
|
@@ -639,11 +700,11 @@ var Switch = forwardRef3(
|
|
|
639
700
|
Switch.displayName = "Switch";
|
|
640
701
|
|
|
641
702
|
// src/elements/Textarea.jsx
|
|
642
|
-
import React8, { forwardRef as
|
|
703
|
+
import React8, { forwardRef as forwardRef5 } from "react";
|
|
643
704
|
import { cx as cx6 } from "@edux-design/utils";
|
|
644
705
|
import { Close as Close4 } from "@edux-design/icons";
|
|
645
706
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
646
|
-
var Textarea =
|
|
707
|
+
var Textarea = forwardRef5(
|
|
647
708
|
({
|
|
648
709
|
children,
|
|
649
710
|
validation,
|
|
@@ -730,7 +791,7 @@ var Textarea = forwardRef4(
|
|
|
730
791
|
|
|
731
792
|
// src/elements/Combobox.jsx
|
|
732
793
|
import React9, {
|
|
733
|
-
forwardRef as
|
|
794
|
+
forwardRef as forwardRef6,
|
|
734
795
|
useCallback as useCallback4,
|
|
735
796
|
useEffect as useEffect3,
|
|
736
797
|
useId as useId3,
|
|
@@ -768,7 +829,7 @@ var defaultFilter = (option, query) => {
|
|
|
768
829
|
const normalisedLabel = ((_a = option.label) == null ? void 0 : _a.toString().toLowerCase()) ?? "";
|
|
769
830
|
return normalisedLabel.includes(query.trim().toLowerCase());
|
|
770
831
|
};
|
|
771
|
-
var ComboboxRoot =
|
|
832
|
+
var ComboboxRoot = forwardRef6(
|
|
772
833
|
({
|
|
773
834
|
children,
|
|
774
835
|
value,
|
|
@@ -1264,7 +1325,7 @@ var ComboboxRoot = forwardRef5(
|
|
|
1264
1325
|
}
|
|
1265
1326
|
);
|
|
1266
1327
|
ComboboxRoot.displayName = "Combobox";
|
|
1267
|
-
var ComboboxOption =
|
|
1328
|
+
var ComboboxOption = forwardRef6(function ComboboxOption2({ children, label, ...props }, ref) {
|
|
1268
1329
|
return /* @__PURE__ */ jsx9("li", { ref, ...props, children: children ?? label });
|
|
1269
1330
|
});
|
|
1270
1331
|
ComboboxOption.displayName = OPTION_COMPONENT_NAME;
|