@vjdesigns/vjdesigns-ui 3.3.0 → 3.4.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.
package/README.md CHANGED
@@ -753,6 +753,15 @@ To manage several options as one `string[]` value, use `CheckBoxGroup`:
753
753
  </CheckBoxGroup>
754
754
  ```
755
755
 
756
+ For a "select all" box, pass its label as `selectAll`. The group adds the parent box, keeps its checked and mixed states in sync, and links the options to it, so screen readers announce them as belonging to it. Disabled options keep their state.
757
+
758
+ ```tsx
759
+ <CheckBoxGroup label="Pizza order" selectAll="All toppings" name="toppings">
760
+ <CheckBox value="cheese" label="Cheese" />
761
+ <CheckBox value="peppers" label="Peppers" />
762
+ </CheckBoxGroup>
763
+ ```
764
+
756
765
  ---
757
766
 
758
767
  ## Pro
@@ -1,4 +1,4 @@
1
- # @vjdesigns/vjdesigns-ui 3.2.0: full reference
1
+ # @vjdesigns/vjdesigns-ui 3.3.0: full reference
2
2
 
3
3
  > Accessible React 19 component library: WCAG 2.2 AA verified (axe on every story, a contrast check on every color pair), 31 languages with right-to-left support, themeable with any brand color (auto-adjusted to stay accessible), tree-shakable, no runtime dependencies besides React.
4
4
 
@@ -2704,6 +2704,7 @@ Works standalone, inside `Field`, and as an option in `CheckBoxGroup`.
2704
2704
  - Label Position
2705
2705
  - Group
2706
2706
  - Select all (indeterminate parent)
2707
+ - Select all with a disabled option
2707
2708
  - Controlled
2708
2709
  - Composition: terms acceptance
2709
2710
 
@@ -2731,6 +2732,7 @@ legend, or by `aria-label`/`aria-labelledby`.
2731
2732
  - `invalid`: `boolean`. Danger styling and `aria-invalid` on every option. Inherits from `Field`.
2732
2733
  - `label`: `ReactNode`. Visible group label for standalone use. Inside a `Fieldset`, the legend labels the group instead.
2733
2734
  - `description`: `ReactNode`. Supporting text below the group label, linked with `aria-describedby`.
2735
+ - `selectAll`: `ReactNode`. Label of a parent "select all" box above the options (for example "All toppings"). It checks or clears every enabled option and shows a mixed state when only some are checked. The options are wrapped in a nested group named by this label, and the box lists them in `aria-controls`, so screen readers announce that they belong to it.
2734
2736
  - `children`: `ReactNode`. `CheckBox` options, each with a unique `value`.
2735
2737
  - Plus every native `<div>` attribute (className, style, id, aria-*, data-*, event handlers), spread onto the root.
2736
2738
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vjdesigns/vjdesigns-ui",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "summary": "Accessible React 19 component library: WCAG 2.2 AA verified (axe on every story, a contrast check on every color pair), 31 languages with right-to-left support, themeable with any brand color (auto-adjusted to stay accessible), tree-shakable, no runtime dependencies besides React.",
5
5
  "install": "npm install @vjdesigns/vjdesigns-ui",
6
6
  "stylesheet": "@vjdesigns/vjdesigns-ui/dist/vjdesigns-ui.css",
@@ -6371,6 +6371,10 @@
6371
6371
  "name": "Select all (indeterminate parent)",
6372
6372
  "description": ""
6373
6373
  },
6374
+ {
6375
+ "name": "Select all with a disabled option",
6376
+ "description": ""
6377
+ },
6374
6378
  {
6375
6379
  "name": "Controlled",
6376
6380
  "description": ""
@@ -6461,6 +6465,12 @@
6461
6465
  "required": false,
6462
6466
  "description": "Supporting text below the group label, linked with `aria-describedby`."
6463
6467
  },
6468
+ {
6469
+ "name": "selectAll",
6470
+ "type": "ReactNode",
6471
+ "required": false,
6472
+ "description": "Label of a parent \"select all\" box above the options (for example\r\n\"All toppings\"). It checks or clears every enabled option and shows a\r\nmixed state when only some are checked. The options are wrapped in a\r\nnested group named by this label, and the box lists them in\r\n`aria-controls`, so screen readers announce that they belong to it."
6473
+ },
6464
6474
  {
6465
6475
  "name": "children",
6466
6476
  "type": "ReactNode",
@@ -1 +1 @@
1
- "use client";const e=require("../../../hooks/useControllableState.cjs.js"),t=require("../../../hooks/useFormReset.cjs.js"),n=require("../../../utils/cx.cjs.js"),r=require("../../primitives/Icon/icons.cjs.js"),i=require("../Field/FieldContext.cjs.js"),a=require("./CheckBox.module.css.cjs.js");let o=require("react"),s=require("react/jsx-runtime");var c={sm:a.default.sm,md:a.default.md,lg:a.default.lg},l={neutral:a.default.toneNeutral,primary:a.default.tonePrimary,accent:a.default.toneAccent,success:a.default.toneSuccess,warning:a.default.toneWarning,danger:a.default.toneDanger,info:a.default.toneInfo},u={end:a.default.labelEnd,start:a.default.labelStart},d={vertical:a.default.vertical,horizontal:a.default.horizontal},f=(0,o.createContext)(null);function p({checked:d,defaultChecked:p=!1,onCheckedChange:m,indeterminate:h=!1,label:g,description:_,size:v,tone:y,invalid:b,disabled:x,required:S,readOnly:C,labelPosition:w=`end`,value:T,name:E,id:D,className:O,style:k,ref:A,onChange:j,onClick:M,"aria-describedby":N,...P}){let F=(0,o.useContext)(f),I=(0,o.useId)(),L=(0,o.useId)(),R=i.useFieldControl({id:D??(F?I:void 0),invalid:b??F?.invalid,required:S,disabled:x??(F?.disabled||void 0),readOnly:C??(F?.readOnly||void 0),size:v??F?.size,"aria-describedby":[_?L:void 0,N].filter(Boolean).join(` `)||void 0}),z=R.id??I,B=R.size??`md`,V=y??F?.tone??`primary`,{disabled:H,readOnly:U,invalid:W}=R,G=F?[_?L:void 0,F.itemDescribedBy,N].filter(Boolean).join(` `)||void 0:R.ariaProps[`aria-describedby`],[K,q]=e.useControllableState({value:d,defaultValue:p,onChange:m});t.useFormReset(()=>X.current,()=>F?F.reset():q(p??!1),F?!0:d===void 0);let J=T??`on`,Y=F?F.value.includes(J):K,X=(0,o.useRef)(null);(0,o.useLayoutEffect)(()=>{X.current&&(X.current.indeterminate=h)});let Z=(0,o.useCallback)(e=>{if(X.current=e,typeof A==`function`)return A(e);A&&(A.current=e)},[A]),Q=e=>{M?.(e),U&&e.preventDefault()},$=e=>{if(j?.(e),U)return;let t=e.target.checked;F?(F.toggle(J,t),m?.(t)):q(t)};return(0,s.jsxs)(`div`,{className:n.cx(a.default.root,c[B],l[V],u[w],O),style:k,"data-disabled":H||void 0,"data-invalid":W||void 0,"data-readonly":U||void 0,children:[(0,s.jsxs)(`span`,{className:a.default.controlWrap,children:[(0,s.jsx)(`input`,{...P,ref:Z,type:`checkbox`,id:z,name:E??F?.name,value:J,checked:Y,disabled:H,required:F?void 0:R.required,"aria-describedby":G,"aria-invalid":R.ariaProps[`aria-invalid`],"aria-errormessage":F?void 0:R.ariaProps[`aria-errormessage`],"aria-readonly":U||void 0,className:a.default.input,onClick:Q,onChange:$}),(0,s.jsxs)(`span`,{className:a.default.control,"aria-hidden":`true`,children:[(0,s.jsx)(r.CheckIcon,{className:n.cx(a.default.mark,a.default.check),strokeWidth:3.5}),(0,s.jsx)(r.MinusIcon,{className:n.cx(a.default.mark,a.default.minus),strokeWidth:3.5})]})]}),(g||_)&&(0,s.jsxs)(`span`,{className:a.default.text,children:[g&&(0,s.jsx)(`label`,{htmlFor:z,className:a.default.label,children:g}),_&&(0,s.jsx)(`span`,{id:L,className:a.default.description,children:_})]})]})}function m({value:t,defaultValue:r=[],onValueChange:l,name:u,orientation:p=`vertical`,size:m,tone:h,disabled:g,readOnly:_,invalid:v,label:y,description:b,className:x,children:S,"aria-labelledby":C,"aria-describedby":w,...T}){let E=i.useFieldContext(),D=(0,o.useId)(),O=(0,o.useId)(),k=i.useFieldControl({invalid:v,disabled:g,readOnly:_,size:m,"aria-describedby":[b?O:void 0,w].filter(Boolean).join(` `)||void 0}),[A,j]=e.useControllableState({value:t,defaultValue:r,onChange:l}),M=(0,o.useCallback)((e,t)=>{j(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},[j]),N=E?.isGroup===!0&&!C&&!y,P=[C,y?D:void 0].filter(Boolean).join(` `)||void 0,F=[b?O:void 0,w].filter(Boolean).join(` `)||void 0,I={name:u,value:A,toggle:M,size:k.size,tone:h,disabled:k.disabled,readOnly:k.readOnly,invalid:k.invalid,reset:()=>{t===void 0&&j(r??[])},itemDescribedBy:N?F:void 0};return(0,s.jsxs)(`div`,{...T,role:N?void 0:`group`,"aria-labelledby":N?void 0:P,"aria-describedby":N?F:k.ariaProps[`aria-describedby`],className:n.cx(a.default.group,c[k.size??`md`],x),"data-disabled":k.disabled||void 0,"aria-disabled":k.disabled||void 0,children:[(y||b)&&(0,s.jsxs)(`div`,{className:a.default.groupHeader,children:[y&&(0,s.jsx)(`span`,{id:D,className:a.default.groupLabel,children:y}),b&&(0,s.jsx)(`span`,{id:O,className:a.default.description,children:b})]}),(0,s.jsx)(`div`,{className:n.cx(a.default.options,d[p]),children:(0,s.jsx)(f.Provider,{value:I,children:S})})]})}exports.CheckBox=p,exports.CheckBoxGroup=m;
1
+ "use client";const e=require("../../../hooks/useControllableState.cjs.js"),t=require("../../../hooks/useFormReset.cjs.js"),n=require("../../../utils/cx.cjs.js"),r=require("../../primitives/Icon/icons.cjs.js"),i=require("../Field/FieldContext.cjs.js"),a=require("./CheckBox.module.css.cjs.js");let o=require("react"),s=require("react/jsx-runtime");var c={sm:a.default.sm,md:a.default.md,lg:a.default.lg},l={neutral:a.default.toneNeutral,primary:a.default.tonePrimary,accent:a.default.toneAccent,success:a.default.toneSuccess,warning:a.default.toneWarning,danger:a.default.toneDanger,info:a.default.toneInfo},u={end:a.default.labelEnd,start:a.default.labelStart},d={vertical:a.default.vertical,horizontal:a.default.horizontal},f=(0,o.createContext)(null);function p({checked:d,defaultChecked:p=!1,onCheckedChange:m,indeterminate:h=!1,label:g,description:_,size:v,tone:y,invalid:b,disabled:x,required:S,readOnly:C,labelPosition:w=`end`,value:T,name:E,id:D,className:O,style:k,ref:A,onChange:j,onClick:M,"aria-describedby":N,...P}){let F=(0,o.useContext)(f),I=(0,o.useId)(),L=(0,o.useId)(),R=i.useFieldControl({id:D??(F?I:void 0),invalid:b??F?.invalid,required:S,disabled:x??(F?.disabled||void 0),readOnly:C??(F?.readOnly||void 0),size:v??F?.size,"aria-describedby":[_?L:void 0,N].filter(Boolean).join(` `)||void 0}),z=R.id??I,B=R.size??`md`,V=y??F?.tone??`primary`,{disabled:H,readOnly:U,invalid:W}=R,G=F?[_?L:void 0,F.itemDescribedBy,N].filter(Boolean).join(` `)||void 0:R.ariaProps[`aria-describedby`],[K,q]=e.useControllableState({value:d,defaultValue:p,onChange:m});t.useFormReset(()=>Z.current,()=>F?F.reset():q(p??!1),F?!0:d===void 0);let J=T??`on`,Y=F?F.value.includes(J):K,X=F?.register;(0,o.useLayoutEffect)(()=>X?.(J,z,!!H),[X,J,z,H]);let Z=(0,o.useRef)(null);(0,o.useLayoutEffect)(()=>{Z.current&&(Z.current.indeterminate=h)});let Q=(0,o.useCallback)(e=>{if(Z.current=e,typeof A==`function`)return A(e);A&&(A.current=e)},[A]),$=e=>{M?.(e),U&&e.preventDefault()},ee=e=>{if(j?.(e),U)return;let t=e.target.checked;F?(F.toggle(J,t),m?.(t)):q(t)};return(0,s.jsxs)(`div`,{className:n.cx(a.default.root,c[B],l[V],u[w],O),style:k,"data-disabled":H||void 0,"data-invalid":W||void 0,"data-readonly":U||void 0,children:[(0,s.jsxs)(`span`,{className:a.default.controlWrap,children:[(0,s.jsx)(`input`,{...P,ref:Q,type:`checkbox`,id:z,name:E??F?.name,value:J,checked:Y,disabled:H,required:F?void 0:R.required,"aria-describedby":G,"aria-invalid":R.ariaProps[`aria-invalid`],"aria-errormessage":F?void 0:R.ariaProps[`aria-errormessage`],"aria-readonly":U||void 0,className:a.default.input,onClick:$,onChange:ee}),(0,s.jsxs)(`span`,{className:a.default.control,"aria-hidden":`true`,children:[(0,s.jsx)(r.CheckIcon,{className:n.cx(a.default.mark,a.default.check),strokeWidth:3.5}),(0,s.jsx)(r.MinusIcon,{className:n.cx(a.default.mark,a.default.minus),strokeWidth:3.5})]})]}),(g||_)&&(0,s.jsxs)(`span`,{className:a.default.text,children:[g&&(0,s.jsx)(`label`,{id:`${z}-label`,htmlFor:z,className:a.default.label,children:g}),_&&(0,s.jsx)(`span`,{id:L,className:a.default.description,children:_})]})]})}function m({value:t,defaultValue:r=[],onValueChange:l,name:u,orientation:m=`vertical`,size:h,tone:g,disabled:_,readOnly:v,invalid:y,label:b,description:x,selectAll:S,className:C,children:w,"aria-labelledby":T,"aria-describedby":E,...D}){let O=i.useFieldContext(),k=(0,o.useId)(),A=(0,o.useId)(),j=(0,o.useId)(),M=i.useFieldControl({invalid:y,disabled:_,readOnly:v,size:h,"aria-describedby":[x?A:void 0,E].filter(Boolean).join(` `)||void 0}),[N,P]=e.useControllableState({value:t,defaultValue:r,onChange:l}),F=(0,o.useCallback)((e,t)=>{P(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},[P]),[I,L]=(0,o.useState)(()=>new Map),R=S!=null&&S!==!1,z=(0,o.useCallback)((e,t,n)=>(L(r=>new Map(r).set(e,{id:t,disabled:n})),()=>L(n=>{if(n.get(e)?.id!==t)return n;let r=new Map(n);return r.delete(e),r})),[]),B=[...I].filter(([,e])=>!e.disabled).map(([e])=>e),V=B.length>0&&B.every(e=>N.includes(e)),H=[...I.keys()].some(e=>N.includes(e)),U=e=>P(t=>e?[...t,...B.filter(e=>!t.includes(e))]:t.filter(e=>!B.includes(e))),W=O?.isGroup===!0&&!T&&!b,G=[T,b?k:void 0].filter(Boolean).join(` `)||void 0,K=[x?A:void 0,E].filter(Boolean).join(` `)||void 0,q={name:u,value:N,toggle:F,size:M.size,tone:g,disabled:M.disabled,readOnly:M.readOnly,invalid:M.invalid,reset:()=>{t===void 0&&P(r??[])},itemDescribedBy:W?K:void 0,register:R?z:void 0},J=(0,s.jsx)(`div`,{className:n.cx(a.default.options,d[m],R&&a.default.selectAllOptions),role:R?`group`:void 0,"aria-labelledby":R?`${j}-label`:void 0,children:(0,s.jsx)(f.Provider,{value:q,children:w})});return(0,s.jsxs)(`div`,{...D,role:W?void 0:`group`,"aria-labelledby":W?void 0:G,"aria-describedby":W?K:M.ariaProps[`aria-describedby`],className:n.cx(a.default.group,c[M.size??`md`],C),"data-disabled":M.disabled||void 0,"aria-disabled":M.disabled||void 0,children:[(b||x)&&(0,s.jsxs)(`div`,{className:a.default.groupHeader,children:[b&&(0,s.jsx)(`span`,{id:k,className:a.default.groupLabel,children:b}),x&&(0,s.jsx)(`span`,{id:A,className:a.default.description,children:x})]}),R?(0,s.jsxs)(`div`,{className:a.default.selectAll,children:[(0,s.jsx)(i.FieldContext.Provider,{value:null,children:(0,s.jsx)(p,{id:j,label:S,checked:V,indeterminate:H&&!V,onCheckedChange:U,"aria-controls":[...I.values()].map(e=>e.id).join(` `)||void 0,size:M.size,tone:g,disabled:M.disabled||B.length===0,readOnly:M.readOnly,invalid:M.invalid})}),J]}):J]})}exports.CheckBox=p,exports.CheckBoxGroup=m;
@@ -68,6 +68,14 @@ export interface CheckBoxGroupProps extends Omit<ComponentPropsWithRef<"div">, "
68
68
  label?: ReactNode;
69
69
  /** Supporting text below the group label, linked with `aria-describedby`. */
70
70
  description?: ReactNode;
71
+ /**
72
+ * Label of a parent "select all" box above the options (for example
73
+ * "All toppings"). It checks or clears every enabled option and shows a
74
+ * mixed state when only some are checked. The options are wrapped in a
75
+ * nested group named by this label, and the box lists them in
76
+ * `aria-controls`, so screen readers announce that they belong to it.
77
+ */
78
+ selectAll?: ReactNode;
71
79
  /** `CheckBox` options, each with a unique `value`. */
72
80
  children?: ReactNode;
73
81
  }
@@ -76,4 +84,4 @@ export interface CheckBoxGroupProps extends Omit<ComponentPropsWithRef<"div">, "
76
84
  * `role="group"` labelled by its own `label`, by a surrounding `Fieldset`'s
77
85
  * legend, or by `aria-label`/`aria-labelledby`.
78
86
  */
79
- export declare function CheckBoxGroup({ value: valueProp, defaultValue, onValueChange, name, orientation, size: sizeProp, tone, disabled: disabledProp, readOnly: readOnlyProp, invalid: invalidProp, label, description, className, children, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: CheckBoxGroupProps): import("react").JSX.Element;
87
+ export declare function CheckBoxGroup({ value: valueProp, defaultValue, onValueChange, name, orientation, size: sizeProp, tone, disabled: disabledProp, readOnly: readOnlyProp, invalid: invalidProp, label, description, selectAll, className, children, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: CheckBoxGroupProps): import("react").JSX.Element;
@@ -3,166 +3,202 @@ import { useControllableState as e } from "../../../hooks/useControllableState.m
3
3
  import { useFormReset as t } from "../../../hooks/useFormReset.mjs";
4
4
  import { cx as n } from "../../../utils/cx.mjs";
5
5
  import { CheckIcon as r, MinusIcon as i } from "../../primitives/Icon/icons.mjs";
6
- import { useFieldContext as a, useFieldControl as o } from "../Field/FieldContext.mjs";
7
- import s from "./CheckBox.module.css.mjs";
8
- import { createContext as c, useCallback as l, useContext as u, useId as d, useLayoutEffect as f, useRef as p } from "react";
9
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
+ import { FieldContext as a, useFieldContext as o, useFieldControl as s } from "../Field/FieldContext.mjs";
7
+ import c from "./CheckBox.module.css.mjs";
8
+ import { createContext as l, useCallback as u, useContext as d, useId as f, useLayoutEffect as p, useRef as m, useState as h } from "react";
9
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
10
10
  // src/components/forms/CheckBox/CheckBox.tsx
11
- var g = {
12
- sm: s.sm,
13
- md: s.md,
14
- lg: s.lg
15
- }, _ = {
16
- neutral: s.toneNeutral,
17
- primary: s.tonePrimary,
18
- accent: s.toneAccent,
19
- success: s.toneSuccess,
20
- warning: s.toneWarning,
21
- danger: s.toneDanger,
22
- info: s.toneInfo
23
- }, v = {
24
- end: s.labelEnd,
25
- start: s.labelStart
11
+ var v = {
12
+ sm: c.sm,
13
+ md: c.md,
14
+ lg: c.lg
26
15
  }, y = {
27
- vertical: s.vertical,
28
- horizontal: s.horizontal
29
- }, b = c(null);
30
- function x({ checked: a, defaultChecked: c = !1, onCheckedChange: y, indeterminate: x = !1, label: S, description: C, size: w, tone: T, invalid: E, disabled: D, required: O, readOnly: k, labelPosition: A = "end", value: j, name: M, id: N, className: P, style: F, ref: I, onChange: L, onClick: R, "aria-describedby": z, ...B }) {
31
- let V = u(b), H = d(), U = d(), W = o({
32
- id: N ?? (V ? H : void 0),
33
- invalid: E ?? V?.invalid,
34
- required: O,
35
- disabled: D ?? (V?.disabled || void 0),
36
- readOnly: k ?? (V?.readOnly || void 0),
37
- size: w ?? V?.size,
38
- "aria-describedby": [C ? U : void 0, z].filter(Boolean).join(" ") || void 0
39
- }), G = W.id ?? H, K = W.size ?? "md", q = T ?? V?.tone ?? "primary", { disabled: J, readOnly: Y, invalid: X } = W, ee = V ? [
40
- C ? U : void 0,
41
- V.itemDescribedBy,
42
- z
43
- ].filter(Boolean).join(" ") || void 0 : W.ariaProps["aria-describedby"], [te, Z] = e({
16
+ neutral: c.toneNeutral,
17
+ primary: c.tonePrimary,
18
+ accent: c.toneAccent,
19
+ success: c.toneSuccess,
20
+ warning: c.toneWarning,
21
+ danger: c.toneDanger,
22
+ info: c.toneInfo
23
+ }, b = {
24
+ end: c.labelEnd,
25
+ start: c.labelStart
26
+ }, x = {
27
+ vertical: c.vertical,
28
+ horizontal: c.horizontal
29
+ }, S = l(null);
30
+ function C({ checked: a, defaultChecked: o = !1, onCheckedChange: l, indeterminate: h = !1, label: x, description: C, size: w, tone: T, invalid: E, disabled: D, required: ee, readOnly: te, labelPosition: O = "end", value: k, name: A, id: j, className: M, style: N, ref: P, onChange: F, onClick: I, "aria-describedby": L, ...R }) {
31
+ let z = d(S), B = f(), V = f(), H = s({
32
+ id: j ?? (z ? B : void 0),
33
+ invalid: E ?? z?.invalid,
34
+ required: ee,
35
+ disabled: D ?? (z?.disabled || void 0),
36
+ readOnly: te ?? (z?.readOnly || void 0),
37
+ size: w ?? z?.size,
38
+ "aria-describedby": [C ? V : void 0, L].filter(Boolean).join(" ") || void 0
39
+ }), U = H.id ?? B, W = H.size ?? "md", G = T ?? z?.tone ?? "primary", { disabled: K, readOnly: q, invalid: J } = H, Y = z ? [
40
+ C ? V : void 0,
41
+ z.itemDescribedBy,
42
+ L
43
+ ].filter(Boolean).join(" ") || void 0 : H.ariaProps["aria-describedby"], [X, Z] = e({
44
44
  value: a,
45
- defaultValue: c,
46
- onChange: y
45
+ defaultValue: o,
46
+ onChange: l
47
47
  });
48
- t(() => $.current, () => V ? V.reset() : Z(c ?? !1), V ? !0 : a === void 0);
49
- let Q = j ?? "on", ne = V ? V.value.includes(Q) : te, $ = p(null);
50
- f(() => {
51
- $.current && ($.current.indeterminate = x);
48
+ t(() => $.current, () => z ? z.reset() : Z(o ?? !1), z ? !0 : a === void 0);
49
+ let Q = k ?? "on", ne = z ? z.value.includes(Q) : X, re = z?.register;
50
+ p(() => re?.(Q, U, !!K), [
51
+ re,
52
+ Q,
53
+ U,
54
+ K
55
+ ]);
56
+ let $ = m(null);
57
+ p(() => {
58
+ $.current && ($.current.indeterminate = h);
52
59
  });
53
- let re = l((e) => {
54
- if ($.current = e, typeof I == "function") return I(e);
55
- I && (I.current = e);
56
- }, [I]), ie = (e) => {
57
- R?.(e), Y && e.preventDefault();
58
- }, ae = (e) => {
59
- if (L?.(e), Y) return;
60
+ let ie = u((e) => {
61
+ if ($.current = e, typeof P == "function") return P(e);
62
+ P && (P.current = e);
63
+ }, [P]), ae = (e) => {
64
+ I?.(e), q && e.preventDefault();
65
+ }, oe = (e) => {
66
+ if (F?.(e), q) return;
60
67
  let t = e.target.checked;
61
- V ? (V.toggle(Q, t), y?.(t)) : Z(t);
68
+ z ? (z.toggle(Q, t), l?.(t)) : Z(t);
62
69
  };
63
- return /* @__PURE__ */ h("div", {
64
- className: n(s.root, g[K], _[q], v[A], P),
65
- style: F,
66
- "data-disabled": J || void 0,
67
- "data-invalid": X || void 0,
68
- "data-readonly": Y || void 0,
69
- children: [/* @__PURE__ */ h("span", {
70
- className: s.controlWrap,
71
- children: [/* @__PURE__ */ m("input", {
72
- ...B,
73
- ref: re,
70
+ return /* @__PURE__ */ _("div", {
71
+ className: n(c.root, v[W], y[G], b[O], M),
72
+ style: N,
73
+ "data-disabled": K || void 0,
74
+ "data-invalid": J || void 0,
75
+ "data-readonly": q || void 0,
76
+ children: [/* @__PURE__ */ _("span", {
77
+ className: c.controlWrap,
78
+ children: [/* @__PURE__ */ g("input", {
79
+ ...R,
80
+ ref: ie,
74
81
  type: "checkbox",
75
- id: G,
76
- name: M ?? V?.name,
82
+ id: U,
83
+ name: A ?? z?.name,
77
84
  value: Q,
78
85
  checked: ne,
79
- disabled: J,
80
- required: V ? void 0 : W.required,
81
- "aria-describedby": ee,
82
- "aria-invalid": W.ariaProps["aria-invalid"],
83
- "aria-errormessage": V ? void 0 : W.ariaProps["aria-errormessage"],
84
- "aria-readonly": Y || void 0,
85
- className: s.input,
86
- onClick: ie,
87
- onChange: ae
88
- }), /* @__PURE__ */ h("span", {
89
- className: s.control,
86
+ disabled: K,
87
+ required: z ? void 0 : H.required,
88
+ "aria-describedby": Y,
89
+ "aria-invalid": H.ariaProps["aria-invalid"],
90
+ "aria-errormessage": z ? void 0 : H.ariaProps["aria-errormessage"],
91
+ "aria-readonly": q || void 0,
92
+ className: c.input,
93
+ onClick: ae,
94
+ onChange: oe
95
+ }), /* @__PURE__ */ _("span", {
96
+ className: c.control,
90
97
  "aria-hidden": "true",
91
- children: [/* @__PURE__ */ m(r, {
92
- className: n(s.mark, s.check),
98
+ children: [/* @__PURE__ */ g(r, {
99
+ className: n(c.mark, c.check),
93
100
  strokeWidth: 3.5
94
- }), /* @__PURE__ */ m(i, {
95
- className: n(s.mark, s.minus),
101
+ }), /* @__PURE__ */ g(i, {
102
+ className: n(c.mark, c.minus),
96
103
  strokeWidth: 3.5
97
104
  })]
98
105
  })]
99
- }), (S || C) && /* @__PURE__ */ h("span", {
100
- className: s.text,
101
- children: [S && /* @__PURE__ */ m("label", {
102
- htmlFor: G,
103
- className: s.label,
104
- children: S
105
- }), C && /* @__PURE__ */ m("span", {
106
- id: U,
107
- className: s.description,
106
+ }), (x || C) && /* @__PURE__ */ _("span", {
107
+ className: c.text,
108
+ children: [x && /* @__PURE__ */ g("label", {
109
+ id: `${U}-label`,
110
+ htmlFor: U,
111
+ className: c.label,
112
+ children: x
113
+ }), C && /* @__PURE__ */ g("span", {
114
+ id: V,
115
+ className: c.description,
108
116
  children: C
109
117
  })]
110
118
  })]
111
119
  });
112
120
  }
113
- function S({ value: t, defaultValue: r = [], onValueChange: i, name: c, orientation: u = "vertical", size: f, tone: p, disabled: _, readOnly: v, invalid: x, label: S, description: C, className: w, children: T, "aria-labelledby": E, "aria-describedby": D, ...O }) {
114
- let k = a(), A = d(), j = d(), M = o({
115
- invalid: x,
116
- disabled: _,
117
- readOnly: v,
118
- size: f,
119
- "aria-describedby": [C ? j : void 0, D].filter(Boolean).join(" ") || void 0
120
- }), [N, P] = e({
121
+ function w({ value: t, defaultValue: r = [], onValueChange: i, name: l, orientation: d = "vertical", size: p, tone: m, disabled: y, readOnly: b, invalid: w, label: T, description: E, selectAll: D, className: ee, children: te, "aria-labelledby": O, "aria-describedby": k, ...A }) {
122
+ let j = o(), M = f(), N = f(), P = f(), F = s({
123
+ invalid: w,
124
+ disabled: y,
125
+ readOnly: b,
126
+ size: p,
127
+ "aria-describedby": [E ? N : void 0, k].filter(Boolean).join(" ") || void 0
128
+ }), [I, L] = e({
121
129
  value: t,
122
130
  defaultValue: r,
123
131
  onChange: i
124
- }), F = l((e, t) => {
125
- P((n) => t ? n.includes(e) ? n : [...n, e] : n.filter((t) => t !== e));
126
- }, [P]), I = k?.isGroup === !0 && !E && !S, L = [E, S ? A : void 0].filter(Boolean).join(" ") || void 0, R = [C ? j : void 0, D].filter(Boolean).join(" ") || void 0, z = {
127
- name: c,
128
- value: N,
129
- toggle: F,
130
- size: M.size,
131
- tone: p,
132
- disabled: M.disabled,
133
- readOnly: M.readOnly,
134
- invalid: M.invalid,
132
+ }), R = u((e, t) => {
133
+ L((n) => t ? n.includes(e) ? n : [...n, e] : n.filter((t) => t !== e));
134
+ }, [L]), [z, B] = h(() => /* @__PURE__ */ new Map()), V = D != null && D !== !1, H = u((e, t, n) => (B((r) => new Map(r).set(e, {
135
+ id: t,
136
+ disabled: n
137
+ })), () => B((n) => {
138
+ if (n.get(e)?.id !== t) return n;
139
+ let r = new Map(n);
140
+ return r.delete(e), r;
141
+ })), []), U = [...z].filter(([, e]) => !e.disabled).map(([e]) => e), W = U.length > 0 && U.every((e) => I.includes(e)), G = [...z.keys()].some((e) => I.includes(e)), K = (e) => L((t) => e ? [...t, ...U.filter((e) => !t.includes(e))] : t.filter((e) => !U.includes(e))), q = j?.isGroup === !0 && !O && !T, J = [O, T ? M : void 0].filter(Boolean).join(" ") || void 0, Y = [E ? N : void 0, k].filter(Boolean).join(" ") || void 0, X = {
142
+ name: l,
143
+ value: I,
144
+ toggle: R,
145
+ size: F.size,
146
+ tone: m,
147
+ disabled: F.disabled,
148
+ readOnly: F.readOnly,
149
+ invalid: F.invalid,
135
150
  reset: () => {
136
- t === void 0 && P(r ?? []);
151
+ t === void 0 && L(r ?? []);
137
152
  },
138
- itemDescribedBy: I ? R : void 0
139
- };
140
- return /* @__PURE__ */ h("div", {
141
- ...O,
142
- role: I ? void 0 : "group",
143
- "aria-labelledby": I ? void 0 : L,
144
- "aria-describedby": I ? R : M.ariaProps["aria-describedby"],
145
- className: n(s.group, g[M.size ?? "md"], w),
146
- "data-disabled": M.disabled || void 0,
147
- "aria-disabled": M.disabled || void 0,
148
- children: [(S || C) && /* @__PURE__ */ h("div", {
149
- className: s.groupHeader,
150
- children: [S && /* @__PURE__ */ m("span", {
151
- id: A,
152
- className: s.groupLabel,
153
- children: S
154
- }), C && /* @__PURE__ */ m("span", {
155
- id: j,
156
- className: s.description,
157
- children: C
158
- })]
159
- }), /* @__PURE__ */ m("div", {
160
- className: n(s.options, y[u]),
161
- children: /* @__PURE__ */ m(b.Provider, {
162
- value: z,
153
+ itemDescribedBy: q ? Y : void 0,
154
+ register: V ? H : void 0
155
+ }, Z = /* @__PURE__ */ g("div", {
156
+ className: n(c.options, x[d], V && c.selectAllOptions),
157
+ role: V ? "group" : void 0,
158
+ "aria-labelledby": V ? `${P}-label` : void 0,
159
+ children: /* @__PURE__ */ g(S.Provider, {
160
+ value: X,
161
+ children: te
162
+ })
163
+ });
164
+ return /* @__PURE__ */ _("div", {
165
+ ...A,
166
+ role: q ? void 0 : "group",
167
+ "aria-labelledby": q ? void 0 : J,
168
+ "aria-describedby": q ? Y : F.ariaProps["aria-describedby"],
169
+ className: n(c.group, v[F.size ?? "md"], ee),
170
+ "data-disabled": F.disabled || void 0,
171
+ "aria-disabled": F.disabled || void 0,
172
+ children: [(T || E) && /* @__PURE__ */ _("div", {
173
+ className: c.groupHeader,
174
+ children: [T && /* @__PURE__ */ g("span", {
175
+ id: M,
176
+ className: c.groupLabel,
163
177
  children: T
164
- })
165
- })]
178
+ }), E && /* @__PURE__ */ g("span", {
179
+ id: N,
180
+ className: c.description,
181
+ children: E
182
+ })]
183
+ }), V ? /* @__PURE__ */ _("div", {
184
+ className: c.selectAll,
185
+ children: [/* @__PURE__ */ g(a.Provider, {
186
+ value: null,
187
+ children: /* @__PURE__ */ g(C, {
188
+ id: P,
189
+ label: D,
190
+ checked: W,
191
+ indeterminate: G && !W,
192
+ onCheckedChange: K,
193
+ "aria-controls": [...z.values()].map((e) => e.id).join(" ") || void 0,
194
+ size: F.size,
195
+ tone: m,
196
+ disabled: F.disabled || U.length === 0,
197
+ readOnly: F.readOnly,
198
+ invalid: F.invalid
199
+ })
200
+ }), Z]
201
+ }) : Z]
166
202
  });
167
203
  }
168
- export { x as CheckBox, S as CheckBoxGroup };
204
+ export { C as CheckBox, w as CheckBoxGroup };
@@ -1 +1 @@
1
- var e=`_root_1f9i5_35`,t=`_sm_1f9i5_59`,n=`_md_1f9i5_73`,r=`_lg_1f9i5_87`,i=`_tonePrimary_1f9i5_105`,a=`_toneNeutral_1f9i5_117`,o=`_toneAccent_1f9i5_129`,s=`_toneSuccess_1f9i5_141`,c=`_toneWarning_1f9i5_153`,l=`_toneDanger_1f9i5_165`,u=`_toneInfo_1f9i5_177`,d=`_labelEnd_1f9i5_193`,f=`_labelStart_1f9i5_199`,p=`_controlWrap_1f9i5_211`,m=`_input_1f9i5_239`,h=`_control_1f9i5_211`,g=`_mark_1f9i5_299`,_=`_check_1f9i5_363`,v=`_minus_1f9i5_365`,y=`_label_1f9i5_193`,b=`_description_1f9i5_441`,x=`_text_1f9i5_451`,S=`_group_1f9i5_489`,C=`_groupHeader_1f9i5_505`,w=`_groupLabel_1f9i5_517`,T=`_options_1f9i5_539`,E=`_vertical_1f9i5_545`,D=`_horizontal_1f9i5_553`,O={root:e,sm:t,md:n,lg:r,tonePrimary:i,toneNeutral:a,toneAccent:o,toneSuccess:s,toneWarning:c,toneDanger:l,toneInfo:u,labelEnd:d,labelStart:f,controlWrap:p,input:m,control:h,mark:g,check:_,minus:v,label:y,description:b,text:x,group:S,groupHeader:C,groupLabel:w,options:T,vertical:E,horizontal:D};exports.check=_,exports.control=h,exports.controlWrap=p,exports.default=O,exports.description=b,exports.group=S,exports.groupHeader=C,exports.groupLabel=w,exports.horizontal=D,exports.input=m,exports.label=y,exports.labelEnd=d,exports.labelStart=f,exports.lg=r,exports.mark=g,exports.md=n,exports.minus=v,exports.options=T,exports.root=e,exports.sm=t,exports.text=x,exports.toneAccent=o,exports.toneDanger=l,exports.toneInfo=u,exports.toneNeutral=a,exports.tonePrimary=i,exports.toneSuccess=s,exports.toneWarning=c,exports.vertical=E;
1
+ var e=`_root_ovzx7_35`,t=`_sm_ovzx7_59`,n=`_md_ovzx7_73`,r=`_lg_ovzx7_87`,i=`_tonePrimary_ovzx7_105`,a=`_toneNeutral_ovzx7_117`,o=`_toneAccent_ovzx7_129`,s=`_toneSuccess_ovzx7_141`,c=`_toneWarning_ovzx7_153`,l=`_toneDanger_ovzx7_165`,u=`_toneInfo_ovzx7_177`,d=`_labelEnd_ovzx7_193`,f=`_labelStart_ovzx7_199`,p=`_controlWrap_ovzx7_211`,m=`_input_ovzx7_239`,h=`_control_ovzx7_211`,g=`_mark_ovzx7_299`,_=`_check_ovzx7_363`,v=`_minus_ovzx7_365`,y=`_label_ovzx7_193`,b=`_description_ovzx7_441`,x=`_text_ovzx7_451`,S=`_group_ovzx7_489`,C=`_groupHeader_ovzx7_505`,w=`_groupLabel_ovzx7_517`,T=`_options_ovzx7_539`,E=`_vertical_ovzx7_545`,D=`_horizontal_ovzx7_553`,O=`_selectAll_ovzx7_569`,k=`_selectAllOptions_ovzx7_579`,A={root:e,sm:t,md:n,lg:r,tonePrimary:i,toneNeutral:a,toneAccent:o,toneSuccess:s,toneWarning:c,toneDanger:l,toneInfo:u,labelEnd:d,labelStart:f,controlWrap:p,input:m,control:h,mark:g,check:_,minus:v,label:y,description:b,text:x,group:S,groupHeader:C,groupLabel:w,options:T,vertical:E,horizontal:D,selectAll:O,selectAllOptions:k};exports.check=_,exports.control=h,exports.controlWrap=p,exports.default=A,exports.description=b,exports.group=S,exports.groupHeader=C,exports.groupLabel=w,exports.horizontal=D,exports.input=m,exports.label=y,exports.labelEnd=d,exports.labelStart=f,exports.lg=r,exports.mark=g,exports.md=n,exports.minus=v,exports.options=T,exports.root=e,exports.selectAll=O,exports.selectAllOptions=k,exports.sm=t,exports.text=x,exports.toneAccent=o,exports.toneDanger=l,exports.toneInfo=u,exports.toneNeutral=a,exports.tonePrimary=i,exports.toneSuccess=s,exports.toneWarning=c,exports.vertical=E;
@@ -1,5 +1,5 @@
1
1
  // src/components/forms/CheckBox/CheckBox.module.css
2
- var e = "_root_1f9i5_35", t = "_sm_1f9i5_59", n = "_md_1f9i5_73", r = "_lg_1f9i5_87", i = "_tonePrimary_1f9i5_105", a = "_toneNeutral_1f9i5_117", o = "_toneAccent_1f9i5_129", s = "_toneSuccess_1f9i5_141", c = "_toneWarning_1f9i5_153", l = "_toneDanger_1f9i5_165", u = "_toneInfo_1f9i5_177", d = "_labelEnd_1f9i5_193", f = "_labelStart_1f9i5_199", p = "_controlWrap_1f9i5_211", m = "_input_1f9i5_239", h = "_control_1f9i5_211", g = "_mark_1f9i5_299", _ = "_check_1f9i5_363", v = "_minus_1f9i5_365", y = "_label_1f9i5_193", b = "_description_1f9i5_441", x = "_text_1f9i5_451", S = "_group_1f9i5_489", C = "_groupHeader_1f9i5_505", w = "_groupLabel_1f9i5_517", T = "_options_1f9i5_539", E = "_vertical_1f9i5_545", D = "_horizontal_1f9i5_553", O = {
2
+ var e = "_root_ovzx7_35", t = "_sm_ovzx7_59", n = "_md_ovzx7_73", r = "_lg_ovzx7_87", i = "_tonePrimary_ovzx7_105", a = "_toneNeutral_ovzx7_117", o = "_toneAccent_ovzx7_129", s = "_toneSuccess_ovzx7_141", c = "_toneWarning_ovzx7_153", l = "_toneDanger_ovzx7_165", u = "_toneInfo_ovzx7_177", d = "_labelEnd_ovzx7_193", f = "_labelStart_ovzx7_199", p = "_controlWrap_ovzx7_211", m = "_input_ovzx7_239", h = "_control_ovzx7_211", g = "_mark_ovzx7_299", _ = "_check_ovzx7_363", v = "_minus_ovzx7_365", y = "_label_ovzx7_193", b = "_description_ovzx7_441", x = "_text_ovzx7_451", S = "_group_ovzx7_489", C = "_groupHeader_ovzx7_505", w = "_groupLabel_ovzx7_517", T = "_options_ovzx7_539", E = "_vertical_ovzx7_545", D = "_horizontal_ovzx7_553", O = "_selectAll_ovzx7_569", k = "_selectAllOptions_ovzx7_579", A = {
3
3
  root: e,
4
4
  sm: t,
5
5
  md: n,
@@ -27,6 +27,8 @@ var e = "_root_1f9i5_35", t = "_sm_1f9i5_59", n = "_md_1f9i5_73", r = "_lg_1f9i5
27
27
  groupLabel: w,
28
28
  options: T,
29
29
  vertical: E,
30
- horizontal: D
30
+ horizontal: D,
31
+ selectAll: O,
32
+ selectAllOptions: k
31
33
  };
32
- export { _ as check, h as control, p as controlWrap, O as default, b as description, S as group, C as groupHeader, w as groupLabel, D as horizontal, m as input, y as label, d as labelEnd, f as labelStart, r as lg, g as mark, n as md, v as minus, T as options, e as root, t as sm, x as text, o as toneAccent, l as toneDanger, u as toneInfo, a as toneNeutral, i as tonePrimary, s as toneSuccess, c as toneWarning, E as vertical };
34
+ export { _ as check, h as control, p as controlWrap, A as default, b as description, S as group, C as groupHeader, w as groupLabel, D as horizontal, m as input, y as label, d as labelEnd, f as labelStart, r as lg, g as mark, n as md, v as minus, T as options, e as root, O as selectAll, k as selectAllOptions, t as sm, x as text, o as toneAccent, l as toneDanger, u as toneInfo, a as toneNeutral, i as tonePrimary, s as toneSuccess, c as toneWarning, E as vertical };