@spark-ui/checkbox 1.13.11 → 1.14.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.14.0](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.13.11...@spark-ui/checkbox@1.14.0) (2023-05-23)
7
+
8
+ ### Features
9
+
10
+ - **checkbox:** add checkbox group and integrate form field ([e65df62](https://github.com/adevinta/spark/commit/e65df6283b708611d8ba213d93fe011fe7080291))
11
+ - **checkbox:** improve api and doc ([bc7c0fc](https://github.com/adevinta/spark/commit/bc7c0fcf54334fcedec2279a5c71ebf2aaba4f20))
12
+ - **checkbox:** minor update ([a9e7ca6](https://github.com/adevinta/spark/commit/a9e7ca68bb9c2bfd3d572fdc9dd6516ac3801ce5))
13
+ - **checkbox:** minor updates and tests ([8ffd0c5](https://github.com/adevinta/spark/commit/8ffd0c51e3b2a843d31ad0438149d19fee67f384))
14
+ - **checkbox:** renamed onChange to onCheckedChange ([2460a10](https://github.com/adevinta/spark/commit/2460a1010f1f124986a5088aba5642806db8b4f6))
15
+ - **checkbox:** update typos and rename variables ([da21719](https://github.com/adevinta/spark/commit/da217196615f0df10aeebb9e44c36dc18339613a))
16
+
6
17
  ## [1.13.11](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.13.10...@spark-ui/checkbox@1.13.11) (2023-05-22)
7
18
 
8
19
  **Note:** Version bump only for package @spark-ui/checkbox
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
- import { type InputProps } from './CheckboxInput';
3
- export type CheckboxProps = InputProps;
4
- export declare const Checkbox: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLButtonElement>>;
1
+ import { CheckboxInputProps } from './CheckboxInput';
2
+ export type CheckboxProps = CheckboxInputProps;
3
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxInputProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,14 @@
1
+ import { ComponentPropsWithoutRef } from 'react';
2
+ import { CheckboxGroupStylesProps } from './CheckboxGroup.styles';
3
+ import { CheckboxGroupContextState } from './CheckboxGroupContext';
4
+ export interface CheckboxGroupProps extends Omit<ComponentPropsWithoutRef<'div'>, 'value' | 'defaultValue' | 'onChange'>, CheckboxGroupStylesProps, Pick<CheckboxGroupContextState, 'intent' | 'name' | 'value'> {
5
+ /**
6
+ * The initial value of the checkbox group
7
+ */
8
+ defaultValue?: string[];
9
+ /**
10
+ * The callback fired when any children Checkbox is checked or unchecked
11
+ */
12
+ onCheckedChange?: (value: string[]) => void;
13
+ }
14
+ export declare const CheckboxGroup: import("react").ForwardRefExoticComponent<CheckboxGroupProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,5 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const checkboxGroupStyles: (props?: ({
3
+ orientation?: "vertical" | "horizontal" | null | undefined;
4
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
+ export type CheckboxGroupStylesProps = VariantProps<typeof checkboxGroupStyles>;
@@ -0,0 +1,33 @@
1
+ import { CheckboxInputStylesProps } from './CheckboxInput.styles';
2
+ export interface CheckboxGroupContextState extends Pick<CheckboxInputStylesProps, 'intent'> {
3
+ /**
4
+ * The id of the checkbox group.
5
+ */
6
+ id: string;
7
+ /**
8
+ * The name of the group. Submitted with its owning form as part of a name/value pair.
9
+ */
10
+ name?: string;
11
+ /**
12
+ * The value of the checkbox group.
13
+ */
14
+ value?: string[];
15
+ /**
16
+ * A set of ids separated by a space used to describe the input component given by a set of messages.
17
+ */
18
+ description?: string;
19
+ /**
20
+ * If true, the checkbox group will be invalid.
21
+ */
22
+ isInvalid?: boolean;
23
+ /**
24
+ * If true, the checkbox group will be required.
25
+ */
26
+ isRequired?: boolean;
27
+ /**
28
+ * Callback used to update or notify the value of the checkbox group.
29
+ */
30
+ onCheckedChange?: (checked: boolean, changed: string) => void;
31
+ }
32
+ export declare const CheckboxGroupContext: import("react").Context<Partial<CheckboxGroupContextState>>;
33
+ export declare const useCheckboxGroup: () => Partial<CheckboxGroupContextState>;
@@ -0,0 +1,3 @@
1
+ import { CheckboxIndicatorProps as CheckboxIndicatorPrimitiveProps } from '@radix-ui/react-checkbox';
2
+ export type CheckboxIndicatorProps = CheckboxIndicatorPrimitiveProps;
3
+ export declare const CheckboxIndicator: import("react").ForwardRefExoticComponent<CheckboxIndicatorPrimitiveProps & import("react").RefAttributes<HTMLSpanElement>>;
@@ -1,23 +1,23 @@
1
- import { ButtonHTMLAttributes, ReactNode } from 'react';
2
- import { type InputStylesProps } from './CheckboxInput.styles';
1
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ import { type CheckboxInputStylesProps } from './CheckboxInput.styles';
3
3
  type CheckedStatus = boolean | 'indeterminate';
4
- interface RadixProps {
4
+ export interface CheckboxInputProps extends CheckboxInputStylesProps, Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'checked' | 'defaultChecked'> {
5
5
  /**
6
- * The checked icon to use
6
+ * The checked icon to use.
7
7
  */
8
8
  icon?: ReactNode;
9
+ /**
10
+ * The indeterminate icon to use.
11
+ */
12
+ indeterminateIcon?: ReactNode;
9
13
  /**
10
14
  * The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.
11
15
  */
12
- defaultChecked?: CheckedStatus;
16
+ defaultChecked?: boolean;
13
17
  /**
14
18
  * The controlled checked state of the checkbox. Must be used in conjunction with onCheckedChange.
15
19
  */
16
20
  checked?: CheckedStatus;
17
- /**
18
- * Event handler called when the checked state of the checkbox changes.
19
- */
20
- onCheckedChange?: (checked: boolean, indeterminate?: boolean) => void;
21
21
  /**
22
22
  * When true, prevents the user from interacting with the checkbox.
23
23
  */
@@ -30,10 +30,14 @@ interface RadixProps {
30
30
  * The name of the checkbox. Submitted with its owning form as part of a name/value pair.
31
31
  */
32
32
  name?: string;
33
+ /**
34
+ * The value given as data when submitted with a name.
35
+ */
36
+ value?: string;
37
+ /**
38
+ * Event handler called when the checked state of the checkbox changes.
39
+ */
40
+ onCheckedChange?: (checked: boolean) => void;
33
41
  }
34
- export interface InputProps extends RadixProps, // Radix props
35
- InputStylesProps, // CVA props (variants)
36
- Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'checked' | 'defaultChecked'> {
37
- }
38
- export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLButtonElement>>;
42
+ export declare const CheckboxInput: import("react").ForwardRefExoticComponent<CheckboxInputProps & import("react").RefAttributes<HTMLButtonElement>>;
39
43
  export {};
@@ -1,5 +1,5 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
- export declare const inputStyles: (props?: ({
2
+ export declare const checkboxInputStyles: (props?: ({
3
3
  intent?: "primary" | "success" | "alert" | "error" | "info" | "neutral" | null | undefined;
4
4
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
- export type InputStylesProps = VariantProps<typeof inputStyles>;
5
+ export type CheckboxInputStylesProps = VariantProps<typeof checkboxInputStyles>;
@@ -1,17 +1,12 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { LabelProps } from '@spark-ui/label';
2
2
  import { type LabelStylesProps } from './CheckboxLabel.styles';
3
- export interface LabelProps extends LabelStylesProps, PropsWithChildren<React.HTMLAttributes<HTMLLabelElement>> {
4
- /**
5
- * Change the component to the HTML tag or custom component of the only child.
6
- */
7
- asChild?: boolean;
8
- /**
9
- * The id of the element the label is associated with.
10
- */
11
- htmlFor?: string;
3
+ export interface CheckboxLabelProps extends LabelProps, LabelStylesProps {
12
4
  /**
13
5
  * When true, prevents the user from interacting with the checkbox item.
14
6
  */
15
7
  disabled?: boolean;
16
8
  }
17
- export declare const Label: ({ className, disabled, ...others }: LabelProps) => JSX.Element;
9
+ export declare const CheckboxLabel: {
10
+ ({ className, disabled, ...others }: CheckboxLabelProps): JSX.Element;
11
+ displayName: string;
12
+ };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { Checkbox } from './Checkbox';
1
+ export * from './Checkbox';
2
+ export * from './CheckboxGroup';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),v=require("@radix-ui/react-checkbox"),C=require("@spark-ui/use-merge-refs"),y=require("@spark-ui/internal-utils"),d=require("class-variance-authority"),w=require("@radix-ui/react-label");function x(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const o=x(v),l=r.forwardRef(({title:e,fill:a="currentColor",stroke:t="none",...s},i)=>r.createElement("svg",{ref:i,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e&&{"data-title":e},fill:a,stroke:t,...s,dangerouslySetInnerHTML:{__html:(e===void 0?"":`<title>${e}</title>`)+'<path d="M8.91958 20.1667C8.73748 20.1667 8.56045 20.1323 8.38847 20.0635C8.21649 19.9947 8.05969 19.8915 7.91806 19.7539L2.42489 14.4176C2.14163 14.1425 2 13.8083 2 13.4152C2 13.0222 2.14163 12.688 2.42489 12.4129C2.70814 12.1377 3.04704 12.0001 3.44158 12.0001C3.83612 12.0001 4.18513 12.1377 4.48862 12.4129L8.91958 16.7173L19.5417 6.42797C19.825 6.1528 20.1639 6.0103 20.5584 6.00048C20.953 5.99065 21.2919 6.13315 21.5751 6.42797C21.8584 6.70313 22 7.03727 22 7.43036C22 7.82346 21.8584 8.15759 21.5751 8.43276L9.92109 19.7539C9.77946 19.8915 9.62266 19.9947 9.45068 20.0635C9.27871 20.1323 9.10167 20.1667 8.91958 20.1667Z"/>'}}));l.displayName="Check";const u=r.forwardRef(({title:e,fill:a="currentColor",stroke:t="none",...s},i)=>r.createElement("svg",{ref:i,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e&&{"data-title":e},fill:a,stroke:t,...s,dangerouslySetInnerHTML:{__html:(e===void 0?"":`<title>${e}</title>`)+'<path fill-rule="evenodd" clip-rule="evenodd" d="M2 11.9999C2 11.379 2.44772 10.8756 3 10.8756H21C21.5523 10.8756 22 11.379 22 11.9999C22 12.6208 21.5523 13.1242 21 13.1242H3C2.44772 13.1242 2 12.6208 2 11.9999Z"/>'}}));u.displayName="Minus";const N=d.cva(["h-sz-20 w-sz-20 border-md peer my-[var(--sz-1)] shrink-0 items-center justify-center self-baseline rounded-sm bg-transparent","spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0","focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2","hover:border-primary-container hover:outline-none hover:ring-2","u-shadow-border-transition"],{variants:{intent:y.makeVariants({primary:["spark-state-unchecked:border-outline","spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary","spark-state-checked:border-primary spark-state-checked:bg-primary"],success:["spark-state-unchecked:border-success","spark-state-indeterminate:border-success spark-state-indeterminate:bg-success","spark-state-checked:border-success spark-state-checked:bg-success"],alert:["spark-state-unchecked:border-alert","spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert","spark-state-checked:border-alert spark-state-checked:bg-alert"],error:["spark-state-unchecked:border-error","spark-state-indeterminate:border-error spark-state-indeterminate:bg-error","spark-state-checked:border-error spark-state-checked:bg-error"],info:["spark-state-unchecked:border-info","spark-state-indeterminate:border-info spark-state-indeterminate:bg-info","spark-state-checked:border-info spark-state-checked:bg-info"],neutral:["spark-state-unchecked:border-neutral","spark-state-indeterminate:border-neutral spark-state-indeterminate:bg-neutral","spark-state-checked:border-neutral spark-state-checked:bg-neutral"]})},defaultVariants:{intent:"primary"}}),E=r.forwardRef(({intent:e,icon:a,className:t,onCheckedChange:s,...i},k)=>{const[b,m]=r.useState(),p=C.useMergeRefs(k,n=>{m(n?.getAttribute("aria-checked"))}),f=(({icon:n,checked:c})=>{if(n)return n;switch(c){case"true":return r.createElement(l,null);case"mixed":return r.createElement(u,null);default:return null}})({icon:a,checked:b}),h=r.useCallback(n=>{if(typeof s=="function"){const[c,g]=[n!=="indeterminate"&&n,n==="indeterminate"||void 0];s(c,g)}},[]);return r.createElement(o.Root,{ref:p,className:N({intent:e,className:t}),...i,onCheckedChange:h},r.createElement(o.Indicator,{className:"text-surface flex items-center justify-center"},f))}),M=d.cva(["flex","items-center","gap-md","text-body-1"],{variants:{disabled:{true:["text-neutral/dim-2","cursor-not-allowed"],false:["cursor-pointer"]}},defaultVariants:{disabled:!1}}),j=({className:e,disabled:a,...t})=>r.createElement(w.Label,{className:M({className:e,disabled:a}),...t}),L=r.forwardRef(({children:e,className:a,...t},s)=>r.createElement(j,{"data-spark-component":"checkbox",className:a,disabled:t.disabled},r.createElement(E,{ref:s,...t}),e));exports.Checkbox=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),V=require("class-variance-authority");require("react-dom");const yr=require("@spark-ui/use-merge-refs"),Ft=require("@radix-ui/react-checkbox"),gr=require("@spark-ui/internal-utils"),_r=require("@spark-ui/label");function kr(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(s,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}return s.default=r,Object.freeze(s)}const zt=kr(n),wr=globalThis?.document?n.useLayoutEffect:()=>{},jr=zt["useId".toString()]||(()=>{});let Cr=0;function Ge(r){const[s,i]=zt.useState(jr());return wr(()=>{r||i(o=>o??String(Cr++))},[r]),r||(s?`radix-${s}`:"")}function oe(){return oe=Object.assign?Object.assign.bind():function(r){for(var s=1;s<arguments.length;s++){var i=arguments[s];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=i[o])}return r},oe.apply(this,arguments)}function xr(...r){return s=>r.forEach(i=>function(o,l){typeof o=="function"?o(l):o!=null&&(o.current=l)}(i,s))}const Ze=n.forwardRef((r,s)=>{const{children:i,...o}=r,l=n.Children.toArray(i),u=l.find(Er);if(u){const d=u.props.children,p=l.map(k=>k===u?n.Children.count(d)>1?n.Children.only(null):n.isValidElement(d)?d.props.children:null:k);return n.createElement(He,oe({},o,{ref:s}),n.isValidElement(d)?n.cloneElement(d,void 0,p):null)}return n.createElement(He,oe({},o,{ref:s}),i)});Ze.displayName="Slot";const He=n.forwardRef((r,s)=>{const{children:i,...o}=r;return n.isValidElement(i)?n.cloneElement(i,{...Nr(o,i.props),ref:xr(s,i.ref)}):n.Children.count(i)>1?n.Children.only(null):null});He.displayName="SlotClone";const St=({children:r})=>n.createElement(n.Fragment,null,r);function Er(r){return n.isValidElement(r)&&r.type===St}function Nr(r,s){const i={...s};for(const o in s){const l=r[o],u=s[o];/^on[A-Z]/.test(o)?l&&u?i[o]=(...d)=>{u(...d),l(...d)}:l&&(i[o]=l):o==="style"?i[o]={...l,...u}:o==="className"&&(i[o]=[l,u].filter(Boolean).join(" "))}return{...r,...i}}const Rr=n.forwardRef((r,s)=>n.createElement(Ze,{ref:s,...r})),Ir=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((r,s)=>{const i=n.forwardRef((o,l)=>{const{asChild:u,...d}=o,p=u?Ze:s;return n.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),n.createElement(p,oe({},d,{ref:l}))});return i.displayName=`Primitive.${s}`,{...r,[s]:i}},{}),Or=n.forwardRef((r,s)=>n.createElement(Ir.label,oe({},r,{ref:s,onMouseDown:i=>{var o;(o=r.onMouseDown)===null||o===void 0||o.call(r,i),!i.defaultPrevented&&i.detail>1&&i.preventDefault()}}))),We=n.createContext(null),Je=()=>{const r=n.useContext(We);if(!r)throw Error("useFormField must be used within a FormField provider");return r},At=({id:r,name:s,isInvalid:i,isRequired:o,children:l})=>{const u=Ge(),[d,p]=n.useState([]),k=d.length>0?d.join(" "):void 0,C=n.useCallback(N=>{p(R=>[...R,N])},[]),g=n.useCallback(N=>{p(R=>R.filter(I=>I!==N))},[]),z=n.useMemo(()=>({id:r,labelId:u,name:s,isInvalid:i,isRequired:o,description:k,onMessageIdAdd:C,onMessageIdRemove:g}),[r,u,s,k,i,o,C,g]);return n.createElement(We.Provider,{value:z},l)};At.displayName="FormFieldProvider";const Mt=n.forwardRef(({className:r,name:s,isInvalid:i=!1,isRequired:o=!1,asChild:l=!1,...u},d)=>{const p=Ge(),k=l?Rr:"div";return n.createElement(At,{id:p,name:s,isRequired:o,isInvalid:i},n.createElement(k,{ref:d,"data-spark-component":"form-control",className:V.cx(r,"flex flex-col gap-xl"),...u}))});Mt.displayName="FormField";const Ke=n.forwardRef(({id:r,className:s,...i},o)=>{const{onMessageIdAdd:l,onMessageIdRemove:u}=Je(),d=Ge(),p=r||d;return n.useEffect(()=>(l(p),()=>{u(p)}),[p,l,u]),n.createElement("span",{ref:o,id:p,className:V.cx(s,"text-caption"),...i})});Ke.displayName="FormField.Message";const qt=n.forwardRef(({className:r,...s},i)=>{const{isInvalid:o}=Je();return o?n.createElement(Ke,{ref:i,"data-spark-component":"form-error-message","aria-live":"polite",className:V.cx(r,"text-error"),...s}):null});qt.displayName="FormField.ErrorMessage";const Lt=n.forwardRef(({className:r,...s},i)=>n.createElement(Ke,{ref:i,"data-spark-component":"form-helper-message",className:V.cx(r,"text-neutral"),...s}));Lt.displayName="FormField.HelperMessage";const Qe=n.forwardRef(({className:r,children:s="*",...i},o)=>n.createElement("span",{ref:o,"data-spark-component":"form-required-indicator",role:"presentation","aria-hidden":"true",className:V.cx(r,"text-error"),...i},s));Qe.displayName="FormField.RequiredIndicator";const Pt=n.forwardRef(({htmlFor:r,className:s,children:i,requiredIndicator:o=n.createElement(Qe,null),asChild:l,...u},d)=>{const p=Je(),{labelId:k,isRequired:C}=p,g=l?void 0:r||p.id;return n.createElement(Or,{ref:d,id:k,"data-spark-component":"form-label",htmlFor:g,className:V.cx(s,"flex items-center gap-sm text-body-1"),asChild:l,...u},n.createElement(St,null,i),C&&o)});Pt.displayName="FormField.Label";const Xe=()=>{const{id:r,name:s,description:i,labelId:o,isRequired:l,isInvalid:u}=n.useContext(We)||{};return{id:r,name:s,description:i,labelId:o,isRequired:l,isInvalid:u}},It=({children:r})=>{const{id:s,name:i,isInvalid:o,labelId:l,isRequired:u,description:d}=Xe();return n.createElement(n.Fragment,null,r({id:s,labelId:l,name:i,isRequired:u,isInvalid:o,description:d}))};It.displayName="FormField.State",Object.assign(Mt,{Label:Pt,State:It,ErrorMessage:qt,HelperMessage:Lt,RequiredIndicator:Qe});const Tt=n.createContext({}),$t=n.forwardRef(({title:r,fill:s="currentColor",stroke:i="none",...o},l)=>n.createElement("svg",{ref:l,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...r&&{"data-title":r},fill:s,stroke:i,...o,dangerouslySetInnerHTML:{__html:(r===void 0?"":`<title>${r}</title>`)+'<path d="M8.91958 20.1667C8.73748 20.1667 8.56045 20.1323 8.38847 20.0635C8.21649 19.9947 8.05969 19.8915 7.91806 19.7539L2.42489 14.4176C2.14163 14.1425 2 13.8083 2 13.4152C2 13.0222 2.14163 12.688 2.42489 12.4129C2.70814 12.1377 3.04704 12.0001 3.44158 12.0001C3.83612 12.0001 4.18513 12.1377 4.48862 12.4129L8.91958 16.7173L19.5417 6.42797C19.825 6.1528 20.1639 6.0103 20.5584 6.00048C20.953 5.99065 21.2919 6.13315 21.5751 6.42797C21.8584 6.70313 22 7.03727 22 7.43036C22 7.82346 21.8584 8.15759 21.5751 8.43276L9.92109 19.7539C9.77946 19.8915 9.62266 19.9947 9.45068 20.0635C9.27871 20.1323 9.10167 20.1667 8.91958 20.1667Z"/>'}}));$t.displayName="Check";const Vt=n.forwardRef(({title:r,fill:s="currentColor",stroke:i="none",...o},l)=>n.createElement("svg",{ref:l,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...r&&{"data-title":r},fill:s,stroke:i,...o,dangerouslySetInnerHTML:{__html:(r===void 0?"":`<title>${r}</title>`)+'<path fill-rule="evenodd" clip-rule="evenodd" d="M2 11.9999C2 11.379 2.44772 10.8756 3 10.8756H21C21.5523 10.8756 22 11.379 22 11.9999C22 12.6208 21.5523 13.1242 21 13.1242H3C2.44772 13.1242 2 12.6208 2 11.9999Z"/>'}}));Vt.displayName="Minus";const Bt=n.forwardRef((r,s)=>n.createElement(Ft.CheckboxIndicator,{ref:s,className:"text-surface flex items-center justify-center",...r}));Bt.displayName="CheckboxIndicator";const Fr=V.cva(["h-sz-20 w-sz-20 border-md peer my-[var(--sz-1)] shrink-0 items-center justify-center self-baseline rounded-sm bg-transparent","spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0","focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2","hover:border-primary-container hover:outline-none hover:ring-2","u-shadow-border-transition"],{variants:{intent:gr.makeVariants({primary:["spark-state-unchecked:border-outline","spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary","spark-state-checked:border-primary spark-state-checked:bg-primary"],success:["spark-state-unchecked:border-success","spark-state-indeterminate:border-success spark-state-indeterminate:bg-success","spark-state-checked:border-success spark-state-checked:bg-success"],alert:["spark-state-unchecked:border-alert","spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert","spark-state-checked:border-alert spark-state-checked:bg-alert"],error:["spark-state-unchecked:border-error","spark-state-indeterminate:border-error spark-state-indeterminate:bg-error","spark-state-checked:border-error spark-state-checked:bg-error"],info:["spark-state-unchecked:border-info","spark-state-indeterminate:border-info spark-state-indeterminate:bg-info","spark-state-checked:border-info spark-state-checked:bg-info"],neutral:["spark-state-unchecked:border-neutral","spark-state-indeterminate:border-neutral spark-state-indeterminate:bg-neutral","spark-state-checked:border-neutral spark-state-checked:bg-neutral"]})},defaultVariants:{intent:"primary"}}),Dt=n.forwardRef(({className:r,icon:s=n.createElement($t,null),indeterminateIcon:i=n.createElement(Vt,null),intent:o,checked:l,...u},d)=>n.createElement(Ft.Checkbox,{ref:d,className:Fr({intent:o,className:r}),checked:l,...u},n.createElement(Bt,null,l==="indeterminate"?i:s)));Dt.displayName="CheckboxInput";const zr=V.cva(["inline-flex","items-center","gap-md","text-body-1"],{variants:{disabled:{true:["text-neutral/dim-2","cursor-not-allowed"],false:["cursor-pointer"]}},defaultVariants:{disabled:!1}}),Ht=({className:r,disabled:s,...i})=>n.createElement(_r.Label,{className:zr({className:r,disabled:s}),...i});Ht.displayName="CheckboxLabel";const Ut=n.forwardRef(({className:r,intent:s,checked:i,value:o,disabled:l,onCheckedChange:u,children:d,...p},k)=>{const C=Xe(),g=n.useContext(Tt),z=n.useRef(),N=yr.useMergeRefs(k,z),R=C.name??g.name,I=C.isRequired??g.isRequired,W=C.isInvalid??g.isInvalid,B=C.id!==g.id,O=B?C.id:void 0,J=B?C.description:void 0,te=W?"error":s??g.intent,re=g.value&&o?g.value.includes(o):i;return n.createElement(Ht,{"data-spark-component":"checkbox",className:r,disabled:l},n.createElement(Dt,{ref:N,id:O,name:R,value:o,intent:te,checked:re,disabled:l,required:I,"aria-describedby":J,"aria-invalid":W,onCheckedChange:M=>{u&&u(M);const D=z.current;g.onCheckedChange&&D?.value&&g.onCheckedChange(M,D.value)},...p}),d)});Ut.displayName="Checkbox";var ze=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ue={exports:{}};(function(r,s){var i="__lodash_hash_undefined__",o=1,l=2,u=9007199254740991,d="[object Arguments]",p="[object Array]",k="[object AsyncFunction]",C="[object Boolean]",g="[object Date]",z="[object Error]",N="[object Function]",R="[object GeneratorFunction]",I="[object Map]",W="[object Number]",B="[object Null]",O="[object Object]",J="[object Promise]",te="[object Proxy]",re="[object RegExp]",M="[object Set]",D="[object String]",he="[object Symbol]",me="[object Undefined]",se="[object WeakMap]",Ye="[object ArrayBuffer]",be="[object DataView]",Gt=/^\[object .+?Constructor\]$/,Zt=/^(?:0|[1-9]\d*)$/,b={};b["[object Float32Array]"]=b["[object Float64Array]"]=b["[object Int8Array]"]=b["[object Int16Array]"]=b["[object Int32Array]"]=b["[object Uint8Array]"]=b["[object Uint8ClampedArray]"]=b["[object Uint16Array]"]=b["[object Uint32Array]"]=!0,b[d]=b[p]=b[Ye]=b[C]=b[be]=b[g]=b[z]=b[N]=b[I]=b[W]=b[O]=b[re]=b[M]=b[D]=b[se]=!1;var et=typeof ze=="object"&&ze&&ze.Object===Object&&ze,Wt=typeof self=="object"&&self&&self.Object===Object&&self,q=et||Wt||Function("return this")(),tt=s&&!s.nodeType&&s,rt=tt&&r&&!r.nodeType&&r,nt=rt&&rt.exports===tt,Se=nt&&et.process,at=function(){try{return Se&&Se.binding&&Se.binding("util")}catch{}}(),it=at&&at.isTypedArray;function Jt(e,t){for(var a=-1,c=e==null?0:e.length;++a<c;)if(t(e[a],a,e))return!0;return!1}function Kt(e){var t=-1,a=Array(e.size);return e.forEach(function(c,v){a[++t]=[v,c]}),a}function Qt(e){var t=-1,a=Array(e.size);return e.forEach(function(c){a[++t]=c}),a}var ot,st,ct,Xt=Array.prototype,Yt=Function.prototype,ve=Object.prototype,Ae=q["__core-js_shared__"],lt=Yt.toString,S=ve.hasOwnProperty,ut=(ot=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||""))?"Symbol(src)_1."+ot:"",dt=ve.toString,er=RegExp("^"+lt.call(S).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ft=nt?q.Buffer:void 0,ye=q.Symbol,pt=q.Uint8Array,ht=ve.propertyIsEnumerable,tr=Xt.splice,K=ye?ye.toStringTag:void 0,mt=Object.getOwnPropertySymbols,rr=ft?ft.isBuffer:void 0,nr=(st=Object.keys,ct=Object,function(e){return st(ct(e))}),Me=ne(q,"DataView"),ce=ne(q,"Map"),qe=ne(q,"Promise"),Le=ne(q,"Set"),Pe=ne(q,"WeakMap"),le=ne(Object,"create"),ar=Y(Me),ir=Y(ce),or=Y(qe),sr=Y(Le),cr=Y(Pe),bt=ye?ye.prototype:void 0,Te=bt?bt.valueOf:void 0;function Q(e){var t=-1,a=e==null?0:e.length;for(this.clear();++t<a;){var c=e[t];this.set(c[0],c[1])}}function L(e){var t=-1,a=e==null?0:e.length;for(this.clear();++t<a;){var c=e[t];this.set(c[0],c[1])}}function X(e){var t=-1,a=e==null?0:e.length;for(this.clear();++t<a;){var c=e[t];this.set(c[0],c[1])}}function ge(e){var t=-1,a=e==null?0:e.length;for(this.__data__=new X;++t<a;)this.add(e[t])}function H(e){var t=this.__data__=new L(e);this.size=t.size}function lr(e,t){var a=we(e),c=!a&&hr(e),v=!a&&!c&&$e(e),f=!a&&!c&&!v&&xt(e),y=a||c||v||f,_=y?function(j,A){for(var P=-1,x=Array(j);++P<j;)x[P]=A(P);return x}(e.length,String):[],F=_.length;for(var w in e)!t&&!S.call(e,w)||y&&(w=="length"||v&&(w=="offset"||w=="parent")||f&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||pr(w,F))||_.push(w);return _}function _e(e,t){for(var a=e.length;a--;)if(kt(e[a][0],t))return a;return-1}function ue(e){return e==null?e===void 0?me:B:K&&K in Object(e)?function(t){var a=S.call(t,K),c=t[K];try{t[K]=void 0;var v=!0}catch{}var f=dt.call(t);return v&&(a?t[K]=c:delete t[K]),f}(e):function(t){return dt.call(t)}(e)}function vt(e){return de(e)&&ue(e)==d}function yt(e,t,a,c,v){return e===t||(e==null||t==null||!de(e)&&!de(t)?e!=e&&t!=t:function(f,y,_,F,w,j){var A=we(f),P=we(y),x=A?p:U(f),T=P?p:U(y),ae=(x=x==d?O:x)==O,je=(T=T==d?O:T)==O,ie=x==T;if(ie&&$e(f)){if(!$e(y))return!1;A=!0,ae=!1}if(ie&&!ae)return j||(j=new H),A||xt(f)?gt(f,y,_,F,w,j):function(m,h,Ce,G,Ve,E,$){switch(Ce){case be:if(m.byteLength!=h.byteLength||m.byteOffset!=h.byteOffset)return!1;m=m.buffer,h=h.buffer;case Ye:return!(m.byteLength!=h.byteLength||!E(new pt(m),new pt(h)));case C:case g:case W:return kt(+m,+h);case z:return m.name==h.name&&m.message==h.message;case re:case D:return m==h+"";case I:var Z=Kt;case M:var pe=G&o;if(Z||(Z=Qt),m.size!=h.size&&!pe)return!1;var xe=$.get(m);if(xe)return xe==h;G|=l,$.set(m,h);var Be=gt(Z(m),Z(h),G,Ve,E,$);return $.delete(m),Be;case he:if(Te)return Te.call(m)==Te.call(h)}return!1}(f,y,x,_,F,w,j);if(!(_&o)){var fe=ae&&S.call(f,"__wrapped__"),Et=je&&S.call(y,"__wrapped__");if(fe||Et){var br=fe?f.value():f,vr=Et?y.value():y;return j||(j=new H),w(br,vr,_,F,j)}}return ie?(j||(j=new H),function(m,h,Ce,G,Ve,E){var $=Ce&o,Z=_t(m),pe=Z.length,xe=_t(h),Be=xe.length;if(pe!=Be&&!$)return!1;for(var Ee=pe;Ee--;){var ee=Z[Ee];if(!($?ee in h:S.call(h,ee)))return!1}var Nt=E.get(m);if(Nt&&E.get(h))return Nt==h;var Ne=!0;E.set(m,h),E.set(h,m);for(var De=$;++Ee<pe;){var Re=m[ee=Z[Ee]],Ie=h[ee];if(G)var Rt=$?G(Ie,Re,ee,h,m,E):G(Re,Ie,ee,m,h,E);if(!(Rt===void 0?Re===Ie||Ve(Re,Ie,Ce,G,E):Rt)){Ne=!1;break}De||(De=ee=="constructor")}if(Ne&&!De){var Oe=m.constructor,Fe=h.constructor;Oe==Fe||!("constructor"in m)||!("constructor"in h)||typeof Oe=="function"&&Oe instanceof Oe&&typeof Fe=="function"&&Fe instanceof Fe||(Ne=!1)}return E.delete(m),E.delete(h),Ne}(f,y,_,F,w,j)):!1}(e,t,a,c,yt,v))}function ur(e){return!(!Ct(e)||function(t){return!!ut&&ut in t}(e))&&(wt(e)?er:Gt).test(Y(e))}function dr(e){if(a=(t=e)&&t.constructor,c=typeof a=="function"&&a.prototype||ve,t!==c)return nr(e);var t,a,c,v=[];for(var f in Object(e))S.call(e,f)&&f!="constructor"&&v.push(f);return v}function gt(e,t,a,c,v,f){var y=a&o,_=e.length,F=t.length;if(_!=F&&!(y&&F>_))return!1;var w=f.get(e);if(w&&f.get(t))return w==t;var j=-1,A=!0,P=a&l?new ge:void 0;for(f.set(e,t),f.set(t,e);++j<_;){var x=e[j],T=t[j];if(c)var ae=y?c(T,x,j,t,e,f):c(x,T,j,e,t,f);if(ae!==void 0){if(ae)continue;A=!1;break}if(P){if(!Jt(t,function(je,ie){if(fe=ie,!P.has(fe)&&(x===je||v(x,je,a,c,f)))return P.push(ie);var fe})){A=!1;break}}else if(x!==T&&!v(x,T,a,c,f)){A=!1;break}}return f.delete(e),f.delete(t),A}function _t(e){return function(t,a,c){var v=a(t);return we(t)?v:function(f,y){for(var _=-1,F=y.length,w=f.length;++_<F;)f[w+_]=y[_];return f}(v,c(t))}(e,mr,fr)}function ke(e,t){var a,c,v=e.__data__;return((c=typeof(a=t))=="string"||c=="number"||c=="symbol"||c=="boolean"?a!=="__proto__":a===null)?v[typeof t=="string"?"string":"hash"]:v.map}function ne(e,t){var a=function(c,v){return c?.[v]}(e,t);return ur(a)?a:void 0}Q.prototype.clear=function(){this.__data__=le?le(null):{},this.size=0},Q.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Q.prototype.get=function(e){var t=this.__data__;if(le){var a=t[e];return a===i?void 0:a}return S.call(t,e)?t[e]:void 0},Q.prototype.has=function(e){var t=this.__data__;return le?t[e]!==void 0:S.call(t,e)},Q.prototype.set=function(e,t){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=le&&t===void 0?i:t,this},L.prototype.clear=function(){this.__data__=[],this.size=0},L.prototype.delete=function(e){var t=this.__data__,a=_e(t,e);return!(a<0)&&(a==t.length-1?t.pop():tr.call(t,a,1),--this.size,!0)},L.prototype.get=function(e){var t=this.__data__,a=_e(t,e);return a<0?void 0:t[a][1]},L.prototype.has=function(e){return _e(this.__data__,e)>-1},L.prototype.set=function(e,t){var a=this.__data__,c=_e(a,e);return c<0?(++this.size,a.push([e,t])):a[c][1]=t,this},X.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(ce||L),string:new Q}},X.prototype.delete=function(e){var t=ke(this,e).delete(e);return this.size-=t?1:0,t},X.prototype.get=function(e){return ke(this,e).get(e)},X.prototype.has=function(e){return ke(this,e).has(e)},X.prototype.set=function(e,t){var a=ke(this,e),c=a.size;return a.set(e,t),this.size+=a.size==c?0:1,this},ge.prototype.add=ge.prototype.push=function(e){return this.__data__.set(e,i),this},ge.prototype.has=function(e){return this.__data__.has(e)},H.prototype.clear=function(){this.__data__=new L,this.size=0},H.prototype.delete=function(e){var t=this.__data__,a=t.delete(e);return this.size=t.size,a},H.prototype.get=function(e){return this.__data__.get(e)},H.prototype.has=function(e){return this.__data__.has(e)},H.prototype.set=function(e,t){var a=this.__data__;if(a instanceof L){var c=a.__data__;if(!ce||c.length<199)return c.push([e,t]),this.size=++a.size,this;a=this.__data__=new X(c)}return a.set(e,t),this.size=a.size,this};var fr=mt?function(e){return e==null?[]:(e=Object(e),function(t,a){for(var c=-1,v=t==null?0:t.length,f=0,y=[];++c<v;){var _=t[c];a(_,c,t)&&(y[f++]=_)}return y}(mt(e),function(t){return ht.call(e,t)}))}:function(){return[]},U=ue;function pr(e,t){return!!(t=t??u)&&(typeof e=="number"||Zt.test(e))&&e>-1&&e%1==0&&e<t}function Y(e){if(e!=null){try{return lt.call(e)}catch{}try{return e+""}catch{}}return""}function kt(e,t){return e===t||e!=e&&t!=t}(Me&&U(new Me(new ArrayBuffer(1)))!=be||ce&&U(new ce)!=I||qe&&U(qe.resolve())!=J||Le&&U(new Le)!=M||Pe&&U(new Pe)!=se)&&(U=function(e){var t=ue(e),a=t==O?e.constructor:void 0,c=a?Y(a):"";if(c)switch(c){case ar:return be;case ir:return I;case or:return J;case sr:return M;case cr:return se}return t});var hr=vt(function(){return arguments}())?vt:function(e){return de(e)&&S.call(e,"callee")&&!ht.call(e,"callee")},we=Array.isArray,$e=rr||function(){return!1};function wt(e){if(!Ct(e))return!1;var t=ue(e);return t==N||t==R||t==k||t==te}function jt(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=u}function Ct(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function de(e){return e!=null&&typeof e=="object"}var xt=it?function(e){return function(t){return e(t)}}(it):function(e){return de(e)&&jt(e.length)&&!!b[ue(e)]};function mr(e){return(t=e)!=null&&jt(t.length)&&!wt(t)?lr(e):dr(e);var t}r.exports=function(e,t){return yt(e,t)}})(Ue,Ue.exports);const Ar=Sr(Ue.exports);function Mr(r,s){const{current:i}=n.useRef(r===void 0?s:r),[o,l]=n.useState(i),u=function(){const p=n.useRef(!1),k=n.useCallback(()=>p.current,[]);return n.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),k}();n.useLayoutEffect(()=>{u()&&r!=null&&l(r)},[r,l,u]);const d=n.useCallback((p,k)=>{(r===void 0||k)&&!Ar(p,o)&&l(p)},[r,l,o]);return[o,d,r!==void 0,i]}const qr=V.cva(["flex","gap-lg"],{variants:{orientation:{vertical:["flex-col"],horizontal:[]}}}),Ot=n.forwardRef(({name:r,value:s,defaultValue:i,className:o,intent:l,orientation:u="vertical",onCheckedChange:d,children:p,...k},C)=>{const[g,z]=Mr(s,i),N=Xe(),R=n.useRef(d),{id:I,labelId:W,description:B,isInvalid:O,isRequired:J}=N,te=r??N.name,re=n.useMemo(()=>({id:I,name:te,value:g,intent:l,isInvalid:O,description:B,isRequired:J,onCheckedChange:(M,D)=>{const he=g||[],me=M?[...he,D]:he.filter(se=>se!==D);z(me),R.current&&R.current(me)}}),[I,te,g,l,O,B,J,z]);return n.useEffect(()=>{R.current=d},[d]),n.createElement(Tt.Provider,{value:re},n.createElement("div",{ref:C,className:qr({className:o,orientation:u}),role:"group","aria-labelledby":W,"aria-describedby":B,...k},p))});Ot.displayName="CheckboxGroup",exports.Checkbox=Ut,exports.CheckboxGroup=Ot;
package/dist/index.mjs CHANGED
@@ -1,35 +1,570 @@
1
- import r, { forwardRef as C, useState as v, useCallback as w } from "react";
2
- import * as d from "@radix-ui/react-checkbox";
3
- import { useMergeRefs as y } from "@spark-ui/use-merge-refs";
4
- import { makeVariants as x } from "@spark-ui/internal-utils";
5
- import { cva as c } from "class-variance-authority";
6
- import { Label as N } from "@radix-ui/react-label";
7
- const l = r.forwardRef(({ title: e, fill: a = "currentColor", stroke: t = "none", ...s }, i) => r.createElement("svg", { ref: i, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...e && { "data-title": e }, fill: a, stroke: t, ...s, dangerouslySetInnerHTML: { __html: (e === void 0 ? "" : `<title>${e}</title>`) + '<path d="M8.91958 20.1667C8.73748 20.1667 8.56045 20.1323 8.38847 20.0635C8.21649 19.9947 8.05969 19.8915 7.91806 19.7539L2.42489 14.4176C2.14163 14.1425 2 13.8083 2 13.4152C2 13.0222 2.14163 12.688 2.42489 12.4129C2.70814 12.1377 3.04704 12.0001 3.44158 12.0001C3.83612 12.0001 4.18513 12.1377 4.48862 12.4129L8.91958 16.7173L19.5417 6.42797C19.825 6.1528 20.1639 6.0103 20.5584 6.00048C20.953 5.99065 21.2919 6.13315 21.5751 6.42797C21.8584 6.70313 22 7.03727 22 7.43036C22 7.82346 21.8584 8.15759 21.5751 8.43276L9.92109 19.7539C9.77946 19.8915 9.62266 19.9947 9.45068 20.0635C9.27871 20.1323 9.10167 20.1667 8.91958 20.1667Z"/>' } }));
8
- l.displayName = "Check";
9
- const m = r.forwardRef(({ title: e, fill: a = "currentColor", stroke: t = "none", ...s }, i) => r.createElement("svg", { ref: i, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...e && { "data-title": e }, fill: a, stroke: t, ...s, dangerouslySetInnerHTML: { __html: (e === void 0 ? "" : `<title>${e}</title>`) + '<path fill-rule="evenodd" clip-rule="evenodd" d="M2 11.9999C2 11.379 2.44772 10.8756 3 10.8756H21C21.5523 10.8756 22 11.379 22 11.9999C22 12.6208 21.5523 13.1242 21 13.1242H3C2.44772 13.1242 2 12.6208 2 11.9999Z"/>' } }));
10
- m.displayName = "Minus";
11
- const E = c(["h-sz-20 w-sz-20 border-md peer my-[var(--sz-1)] shrink-0 items-center justify-center self-baseline rounded-sm bg-transparent", "spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0", "focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2", "hover:border-primary-container hover:outline-none hover:ring-2", "u-shadow-border-transition"], { variants: { intent: x({ primary: ["spark-state-unchecked:border-outline", "spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary", "spark-state-checked:border-primary spark-state-checked:bg-primary"], success: ["spark-state-unchecked:border-success", "spark-state-indeterminate:border-success spark-state-indeterminate:bg-success", "spark-state-checked:border-success spark-state-checked:bg-success"], alert: ["spark-state-unchecked:border-alert", "spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert", "spark-state-checked:border-alert spark-state-checked:bg-alert"], error: ["spark-state-unchecked:border-error", "spark-state-indeterminate:border-error spark-state-indeterminate:bg-error", "spark-state-checked:border-error spark-state-checked:bg-error"], info: ["spark-state-unchecked:border-info", "spark-state-indeterminate:border-info spark-state-indeterminate:bg-info", "spark-state-checked:border-info spark-state-checked:bg-info"], neutral: ["spark-state-unchecked:border-neutral", "spark-state-indeterminate:border-neutral spark-state-indeterminate:bg-neutral", "spark-state-checked:border-neutral spark-state-checked:bg-neutral"] }) }, defaultVariants: { intent: "primary" } }), L = C(({ intent: e, icon: a, className: t, onCheckedChange: s, ...i }, k) => {
12
- const [p, u] = v(), b = y(k, (n) => {
13
- u(n?.getAttribute("aria-checked"));
14
- }), f = (({ icon: n, checked: o }) => {
15
- if (n)
16
- return n;
17
- switch (o) {
18
- case "true":
19
- return r.createElement(l, null);
20
- case "mixed":
21
- return r.createElement(m, null);
22
- default:
23
- return null;
24
- }
25
- })({ icon: a, checked: p }), h = w((n) => {
26
- if (typeof s == "function") {
27
- const [o, g] = [n !== "indeterminate" && n, n === "indeterminate" || void 0];
28
- s(o, g);
29
- }
30
- }, []);
31
- return r.createElement(d.Root, { ref: b, className: E({ intent: e, className: t }), ...i, onCheckedChange: h }, r.createElement(d.Indicator, { className: "text-surface flex items-center justify-center" }, f));
32
- }), M = c(["flex", "items-center", "gap-md", "text-body-1"], { variants: { disabled: { true: ["text-neutral/dim-2", "cursor-not-allowed"], false: ["cursor-pointer"] } }, defaultVariants: { disabled: !1 } }), R = ({ className: e, disabled: a, ...t }) => r.createElement(N, { className: M({ className: e, disabled: a }), ...t }), V = r.forwardRef(({ children: e, className: a, ...t }, s) => r.createElement(R, { "data-spark-component": "checkbox", className: a, disabled: t.disabled }, r.createElement(L, { ref: s, ...t }), e));
1
+ import * as Tt from "react";
2
+ import m, { useLayoutEffect as $t, forwardRef as x, Children as me, isValidElement as qe, createElement as ve, cloneElement as Bt, Fragment as Fr, useEffect as Te, createContext as Vt, useContext as Ye, useState as Dt, useCallback as Le, useMemo as Ht, useRef as Pe } from "react";
3
+ import { cx as se, cva as et } from "class-variance-authority";
4
+ import "react-dom";
5
+ import { useMergeRefs as zr } from "@spark-ui/use-merge-refs";
6
+ import { CheckboxIndicator as Or, Checkbox as Ar } from "@radix-ui/react-checkbox";
7
+ import { makeVariants as Rr } from "@spark-ui/internal-utils";
8
+ import { Label as Mr } from "@spark-ui/label";
9
+ const Sr = globalThis?.document ? $t : () => {
10
+ }, qr = Tt["useId".toString()] || (() => {
11
+ });
12
+ let Lr = 0;
13
+ function tt(r) {
14
+ const [o, i] = Tt.useState(qr());
15
+ return Sr(() => {
16
+ r || i((a) => a ?? String(Lr++));
17
+ }, [r]), r || (o ? `radix-${o}` : "");
18
+ }
19
+ function oe() {
20
+ return oe = Object.assign ? Object.assign.bind() : function(r) {
21
+ for (var o = 1; o < arguments.length; o++) {
22
+ var i = arguments[o];
23
+ for (var a in i)
24
+ Object.prototype.hasOwnProperty.call(i, a) && (r[a] = i[a]);
25
+ }
26
+ return r;
27
+ }, oe.apply(this, arguments);
28
+ }
29
+ function Pr(...r) {
30
+ return (o) => r.forEach((i) => function(a, c) {
31
+ typeof a == "function" ? a(c) : a != null && (a.current = c);
32
+ }(i, o));
33
+ }
34
+ const rt = x((r, o) => {
35
+ const { children: i, ...a } = r, c = me.toArray(i), l = c.find(Tr);
36
+ if (l) {
37
+ const u = l.props.children, f = c.map((k) => k === l ? me.count(u) > 1 ? me.only(null) : qe(u) ? u.props.children : null : k);
38
+ return ve(Qe, oe({}, a, { ref: o }), qe(u) ? Bt(u, void 0, f) : null);
39
+ }
40
+ return ve(Qe, oe({}, a, { ref: o }), i);
41
+ });
42
+ rt.displayName = "Slot";
43
+ const Qe = x((r, o) => {
44
+ const { children: i, ...a } = r;
45
+ return qe(i) ? Bt(i, { ...$r(a, i.props), ref: Pr(o, i.ref) }) : me.count(i) > 1 ? me.only(null) : null;
46
+ });
47
+ Qe.displayName = "SlotClone";
48
+ const Ut = ({ children: r }) => ve(Fr, null, r);
49
+ function Tr(r) {
50
+ return qe(r) && r.type === Ut;
51
+ }
52
+ function $r(r, o) {
53
+ const i = { ...o };
54
+ for (const a in o) {
55
+ const c = r[a], l = o[a];
56
+ /^on[A-Z]/.test(a) ? c && l ? i[a] = (...u) => {
57
+ l(...u), c(...u);
58
+ } : c && (i[a] = c) : a === "style" ? i[a] = { ...c, ...l } : a === "className" && (i[a] = [c, l].filter(Boolean).join(" "));
59
+ }
60
+ return { ...r, ...i };
61
+ }
62
+ const Br = x((r, o) => m.createElement(rt, { ref: o, ...r })), Vr = ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul"].reduce((r, o) => {
63
+ const i = x((a, c) => {
64
+ const { asChild: l, ...u } = a, f = l ? rt : o;
65
+ return Te(() => {
66
+ window[Symbol.for("radix-ui")] = !0;
67
+ }, []), ve(f, oe({}, u, { ref: c }));
68
+ });
69
+ return i.displayName = `Primitive.${o}`, { ...r, [o]: i };
70
+ }, {}), Dr = x((r, o) => ve(Vr.label, oe({}, r, { ref: o, onMouseDown: (i) => {
71
+ var a;
72
+ (a = r.onMouseDown) === null || a === void 0 || a.call(r, i), !i.defaultPrevented && i.detail > 1 && i.preventDefault();
73
+ } }))), nt = Vt(null), at = () => {
74
+ const r = Ye(nt);
75
+ if (!r)
76
+ throw Error("useFormField must be used within a FormField provider");
77
+ return r;
78
+ }, Gt = ({ id: r, name: o, isInvalid: i, isRequired: a, children: c }) => {
79
+ const l = tt(), [u, f] = Dt([]), k = u.length > 0 ? u.join(" ") : void 0, C = Le((I) => {
80
+ f((F) => [...F, I]);
81
+ }, []), g = Le((I) => {
82
+ f((F) => F.filter((z) => z !== I));
83
+ }, []), R = Ht(() => ({ id: r, labelId: l, name: o, isInvalid: i, isRequired: a, description: k, onMessageIdAdd: C, onMessageIdRemove: g }), [r, l, o, k, i, a, C, g]);
84
+ return m.createElement(nt.Provider, { value: R }, c);
85
+ };
86
+ Gt.displayName = "FormFieldProvider";
87
+ const Zt = x(({ className: r, name: o, isInvalid: i = !1, isRequired: a = !1, asChild: c = !1, ...l }, u) => {
88
+ const f = tt(), k = c ? Br : "div";
89
+ return m.createElement(Gt, { id: f, name: o, isRequired: a, isInvalid: i }, m.createElement(k, { ref: u, "data-spark-component": "form-control", className: se(r, "flex flex-col gap-xl"), ...l }));
90
+ });
91
+ Zt.displayName = "FormField";
92
+ const it = x(({ id: r, className: o, ...i }, a) => {
93
+ const { onMessageIdAdd: c, onMessageIdRemove: l } = at(), u = tt(), f = r || u;
94
+ return Te(() => (c(f), () => {
95
+ l(f);
96
+ }), [f, c, l]), m.createElement("span", { ref: a, id: f, className: se(o, "text-caption"), ...i });
97
+ });
98
+ it.displayName = "FormField.Message";
99
+ const Wt = x(({ className: r, ...o }, i) => {
100
+ const { isInvalid: a } = at();
101
+ return a ? m.createElement(it, { ref: i, "data-spark-component": "form-error-message", "aria-live": "polite", className: se(r, "text-error"), ...o }) : null;
102
+ });
103
+ Wt.displayName = "FormField.ErrorMessage";
104
+ const Jt = x(({ className: r, ...o }, i) => m.createElement(it, { ref: i, "data-spark-component": "form-helper-message", className: se(r, "text-neutral"), ...o }));
105
+ Jt.displayName = "FormField.HelperMessage";
106
+ const ot = x(({ className: r, children: o = "*", ...i }, a) => m.createElement("span", { ref: a, "data-spark-component": "form-required-indicator", role: "presentation", "aria-hidden": "true", className: se(r, "text-error"), ...i }, o));
107
+ ot.displayName = "FormField.RequiredIndicator";
108
+ const Kt = x(({ htmlFor: r, className: o, children: i, requiredIndicator: a = m.createElement(ot, null), asChild: c, ...l }, u) => {
109
+ const f = at(), { labelId: k, isRequired: C } = f, g = c ? void 0 : r || f.id;
110
+ return m.createElement(Dr, { ref: u, id: k, "data-spark-component": "form-label", htmlFor: g, className: se(o, "flex items-center gap-sm text-body-1"), asChild: c, ...l }, m.createElement(Ut, null, i), C && a);
111
+ });
112
+ Kt.displayName = "FormField.Label";
113
+ const st = () => {
114
+ const { id: r, name: o, description: i, labelId: a, isRequired: c, isInvalid: l } = Ye(nt) || {};
115
+ return { id: r, name: o, description: i, labelId: a, isRequired: c, isInvalid: l };
116
+ }, Pt = ({ children: r }) => {
117
+ const { id: o, name: i, isInvalid: a, labelId: c, isRequired: l, description: u } = st();
118
+ return m.createElement(m.Fragment, null, r({ id: o, labelId: c, name: i, isRequired: l, isInvalid: a, description: u }));
119
+ };
120
+ Pt.displayName = "FormField.State", Object.assign(Zt, { Label: Kt, State: Pt, ErrorMessage: Wt, HelperMessage: Jt, RequiredIndicator: ot });
121
+ const Qt = Vt({}), Xt = m.forwardRef(({ title: r, fill: o = "currentColor", stroke: i = "none", ...a }, c) => m.createElement("svg", { ref: c, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...r && { "data-title": r }, fill: o, stroke: i, ...a, dangerouslySetInnerHTML: { __html: (r === void 0 ? "" : `<title>${r}</title>`) + '<path d="M8.91958 20.1667C8.73748 20.1667 8.56045 20.1323 8.38847 20.0635C8.21649 19.9947 8.05969 19.8915 7.91806 19.7539L2.42489 14.4176C2.14163 14.1425 2 13.8083 2 13.4152C2 13.0222 2.14163 12.688 2.42489 12.4129C2.70814 12.1377 3.04704 12.0001 3.44158 12.0001C3.83612 12.0001 4.18513 12.1377 4.48862 12.4129L8.91958 16.7173L19.5417 6.42797C19.825 6.1528 20.1639 6.0103 20.5584 6.00048C20.953 5.99065 21.2919 6.13315 21.5751 6.42797C21.8584 6.70313 22 7.03727 22 7.43036C22 7.82346 21.8584 8.15759 21.5751 8.43276L9.92109 19.7539C9.77946 19.8915 9.62266 19.9947 9.45068 20.0635C9.27871 20.1323 9.10167 20.1667 8.91958 20.1667Z"/>' } }));
122
+ Xt.displayName = "Check";
123
+ const Yt = m.forwardRef(({ title: r, fill: o = "currentColor", stroke: i = "none", ...a }, c) => m.createElement("svg", { ref: c, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...r && { "data-title": r }, fill: o, stroke: i, ...a, dangerouslySetInnerHTML: { __html: (r === void 0 ? "" : `<title>${r}</title>`) + '<path fill-rule="evenodd" clip-rule="evenodd" d="M2 11.9999C2 11.379 2.44772 10.8756 3 10.8756H21C21.5523 10.8756 22 11.379 22 11.9999C22 12.6208 21.5523 13.1242 21 13.1242H3C2.44772 13.1242 2 12.6208 2 11.9999Z"/>' } }));
124
+ Yt.displayName = "Minus";
125
+ const er = x((r, o) => m.createElement(Or, { ref: o, className: "text-surface flex items-center justify-center", ...r }));
126
+ er.displayName = "CheckboxIndicator";
127
+ const Hr = et(["h-sz-20 w-sz-20 border-md peer my-[var(--sz-1)] shrink-0 items-center justify-center self-baseline rounded-sm bg-transparent", "spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0", "focus-visible:ring-outline-high focus-visible:outline-none focus-visible:ring-2", "hover:border-primary-container hover:outline-none hover:ring-2", "u-shadow-border-transition"], { variants: { intent: Rr({ primary: ["spark-state-unchecked:border-outline", "spark-state-indeterminate:border-primary spark-state-indeterminate:bg-primary", "spark-state-checked:border-primary spark-state-checked:bg-primary"], success: ["spark-state-unchecked:border-success", "spark-state-indeterminate:border-success spark-state-indeterminate:bg-success", "spark-state-checked:border-success spark-state-checked:bg-success"], alert: ["spark-state-unchecked:border-alert", "spark-state-indeterminate:border-alert spark-state-indeterminate:bg-alert", "spark-state-checked:border-alert spark-state-checked:bg-alert"], error: ["spark-state-unchecked:border-error", "spark-state-indeterminate:border-error spark-state-indeterminate:bg-error", "spark-state-checked:border-error spark-state-checked:bg-error"], info: ["spark-state-unchecked:border-info", "spark-state-indeterminate:border-info spark-state-indeterminate:bg-info", "spark-state-checked:border-info spark-state-checked:bg-info"], neutral: ["spark-state-unchecked:border-neutral", "spark-state-indeterminate:border-neutral spark-state-indeterminate:bg-neutral", "spark-state-checked:border-neutral spark-state-checked:bg-neutral"] }) }, defaultVariants: { intent: "primary" } }), tr = x(({ className: r, icon: o = m.createElement(Xt, null), indeterminateIcon: i = m.createElement(Yt, null), intent: a, checked: c, ...l }, u) => m.createElement(Ar, { ref: u, className: Hr({ intent: a, className: r }), checked: c, ...l }, m.createElement(er, null, c === "indeterminate" ? i : o)));
128
+ tr.displayName = "CheckboxInput";
129
+ const Ur = et(["inline-flex", "items-center", "gap-md", "text-body-1"], { variants: { disabled: { true: ["text-neutral/dim-2", "cursor-not-allowed"], false: ["cursor-pointer"] } }, defaultVariants: { disabled: !1 } }), rr = ({ className: r, disabled: o, ...i }) => m.createElement(Mr, { className: Ur({ className: r, disabled: o }), ...i });
130
+ rr.displayName = "CheckboxLabel";
131
+ const Gr = x(({ className: r, intent: o, checked: i, value: a, disabled: c, onCheckedChange: l, children: u, ...f }, k) => {
132
+ const C = st(), g = Ye(Qt), R = Pe(), I = zr(k, R), F = C.name ?? g.name, z = C.isRequired ?? g.isRequired, W = C.isInvalid ?? g.isInvalid, V = C.id !== g.id, O = V ? C.id : void 0, J = V ? C.description : void 0, te = W ? "error" : o ?? g.intent, re = g.value && a ? g.value.includes(a) : i;
133
+ return m.createElement(rr, { "data-spark-component": "checkbox", className: r, disabled: c }, m.createElement(tr, { ref: I, id: O, name: F, value: a, intent: te, checked: re, disabled: c, required: z, "aria-describedby": J, "aria-invalid": W, onCheckedChange: (q) => {
134
+ l && l(q);
135
+ const D = R.current;
136
+ g.onCheckedChange && D?.value && g.onCheckedChange(q, D.value);
137
+ }, ...f }), u);
138
+ });
139
+ Gr.displayName = "Checkbox";
140
+ var Se = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
141
+ function Zr(r) {
142
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
143
+ }
144
+ var Xe = { exports: {} };
145
+ (function(r, o) {
146
+ var i = "__lodash_hash_undefined__", a = 1, c = 2, l = 9007199254740991, u = "[object Arguments]", f = "[object Array]", k = "[object AsyncFunction]", C = "[object Boolean]", g = "[object Date]", R = "[object Error]", I = "[object Function]", F = "[object GeneratorFunction]", z = "[object Map]", W = "[object Number]", V = "[object Null]", O = "[object Object]", J = "[object Promise]", te = "[object Proxy]", re = "[object RegExp]", q = "[object Set]", D = "[object String]", be = "[object Symbol]", ye = "[object Undefined]", ce = "[object WeakMap]", ct = "[object ArrayBuffer]", ge = "[object DataView]", nr = /^\[object .+?Constructor\]$/, ar = /^(?:0|[1-9]\d*)$/, v = {};
147
+ v["[object Float32Array]"] = v["[object Float64Array]"] = v["[object Int8Array]"] = v["[object Int16Array]"] = v["[object Int32Array]"] = v["[object Uint8Array]"] = v["[object Uint8ClampedArray]"] = v["[object Uint16Array]"] = v["[object Uint32Array]"] = !0, v[u] = v[f] = v[ct] = v[C] = v[ge] = v[g] = v[R] = v[I] = v[z] = v[W] = v[O] = v[re] = v[q] = v[D] = v[ce] = !1;
148
+ var lt = typeof Se == "object" && Se && Se.Object === Object && Se, ir = typeof self == "object" && self && self.Object === Object && self, L = lt || ir || Function("return this")(), ut = o && !o.nodeType && o, dt = ut && r && !r.nodeType && r, ft = dt && dt.exports === ut, $e = ft && lt.process, pt = function() {
149
+ try {
150
+ return $e && $e.binding && $e.binding("util");
151
+ } catch {
152
+ }
153
+ }(), ht = pt && pt.isTypedArray;
154
+ function or(e, t) {
155
+ for (var n = -1, s = e == null ? 0 : e.length; ++n < s; )
156
+ if (t(e[n], n, e))
157
+ return !0;
158
+ return !1;
159
+ }
160
+ function sr(e) {
161
+ var t = -1, n = Array(e.size);
162
+ return e.forEach(function(s, b) {
163
+ n[++t] = [b, s];
164
+ }), n;
165
+ }
166
+ function cr(e) {
167
+ var t = -1, n = Array(e.size);
168
+ return e.forEach(function(s) {
169
+ n[++t] = s;
170
+ }), n;
171
+ }
172
+ var mt, vt, bt, lr = Array.prototype, ur = Function.prototype, _e = Object.prototype, Be = L["__core-js_shared__"], yt = ur.toString, M = _e.hasOwnProperty, gt = (mt = /[^.]+$/.exec(Be && Be.keys && Be.keys.IE_PROTO || "")) ? "Symbol(src)_1." + mt : "", _t = _e.toString, dr = RegExp("^" + yt.call(M).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), kt = ft ? L.Buffer : void 0, ke = L.Symbol, jt = L.Uint8Array, wt = _e.propertyIsEnumerable, fr = lr.splice, K = ke ? ke.toStringTag : void 0, Ct = Object.getOwnPropertySymbols, pr = kt ? kt.isBuffer : void 0, hr = (vt = Object.keys, bt = Object, function(e) {
173
+ return vt(bt(e));
174
+ }), Ve = ne(L, "DataView"), le = ne(L, "Map"), De = ne(L, "Promise"), He = ne(L, "Set"), Ue = ne(L, "WeakMap"), ue = ne(Object, "create"), mr = Y(Ve), vr = Y(le), br = Y(De), yr = Y(He), gr = Y(Ue), Nt = ke ? ke.prototype : void 0, Ge = Nt ? Nt.valueOf : void 0;
175
+ function Q(e) {
176
+ var t = -1, n = e == null ? 0 : e.length;
177
+ for (this.clear(); ++t < n; ) {
178
+ var s = e[t];
179
+ this.set(s[0], s[1]);
180
+ }
181
+ }
182
+ function P(e) {
183
+ var t = -1, n = e == null ? 0 : e.length;
184
+ for (this.clear(); ++t < n; ) {
185
+ var s = e[t];
186
+ this.set(s[0], s[1]);
187
+ }
188
+ }
189
+ function X(e) {
190
+ var t = -1, n = e == null ? 0 : e.length;
191
+ for (this.clear(); ++t < n; ) {
192
+ var s = e[t];
193
+ this.set(s[0], s[1]);
194
+ }
195
+ }
196
+ function je(e) {
197
+ var t = -1, n = e == null ? 0 : e.length;
198
+ for (this.__data__ = new X(); ++t < n; )
199
+ this.add(e[t]);
200
+ }
201
+ function H(e) {
202
+ var t = this.__data__ = new P(e);
203
+ this.size = t.size;
204
+ }
205
+ function _r(e, t) {
206
+ var n = Ne(e), s = !n && Nr(e), b = !n && !s && Ze(e), d = !n && !s && !b && Mt(e), y = n || s || b || d, _ = y ? function(w, S) {
207
+ for (var T = -1, N = Array(w); ++T < w; )
208
+ N[T] = S(T);
209
+ return N;
210
+ }(e.length, String) : [], A = _.length;
211
+ for (var j in e)
212
+ !t && !M.call(e, j) || y && (j == "length" || b && (j == "offset" || j == "parent") || d && (j == "buffer" || j == "byteLength" || j == "byteOffset") || Cr(j, A)) || _.push(j);
213
+ return _;
214
+ }
215
+ function we(e, t) {
216
+ for (var n = e.length; n--; )
217
+ if (zt(e[n][0], t))
218
+ return n;
219
+ return -1;
220
+ }
221
+ function de(e) {
222
+ return e == null ? e === void 0 ? ye : V : K && K in Object(e) ? function(t) {
223
+ var n = M.call(t, K), s = t[K];
224
+ try {
225
+ t[K] = void 0;
226
+ var b = !0;
227
+ } catch {
228
+ }
229
+ var d = _t.call(t);
230
+ return b && (n ? t[K] = s : delete t[K]), d;
231
+ }(e) : function(t) {
232
+ return _t.call(t);
233
+ }(e);
234
+ }
235
+ function xt(e) {
236
+ return fe(e) && de(e) == u;
237
+ }
238
+ function Et(e, t, n, s, b) {
239
+ return e === t || (e == null || t == null || !fe(e) && !fe(t) ? e != e && t != t : function(d, y, _, A, j, w) {
240
+ var S = Ne(d), T = Ne(y), N = S ? f : U(d), $ = T ? f : U(y), ae = (N = N == u ? O : N) == O, xe = ($ = $ == u ? O : $) == O, ie = N == $;
241
+ if (ie && Ze(d)) {
242
+ if (!Ze(y))
243
+ return !1;
244
+ S = !0, ae = !1;
245
+ }
246
+ if (ie && !ae)
247
+ return w || (w = new H()), S || Mt(d) ? It(d, y, _, A, j, w) : function(h, p, Ee, G, We, E, B) {
248
+ switch (Ee) {
249
+ case ge:
250
+ if (h.byteLength != p.byteLength || h.byteOffset != p.byteOffset)
251
+ return !1;
252
+ h = h.buffer, p = p.buffer;
253
+ case ct:
254
+ return !(h.byteLength != p.byteLength || !E(new jt(h), new jt(p)));
255
+ case C:
256
+ case g:
257
+ case W:
258
+ return zt(+h, +p);
259
+ case R:
260
+ return h.name == p.name && h.message == p.message;
261
+ case re:
262
+ case D:
263
+ return h == p + "";
264
+ case z:
265
+ var Z = sr;
266
+ case q:
267
+ var he = G & a;
268
+ if (Z || (Z = cr), h.size != p.size && !he)
269
+ return !1;
270
+ var Ie = B.get(h);
271
+ if (Ie)
272
+ return Ie == p;
273
+ G |= c, B.set(h, p);
274
+ var Je = It(Z(h), Z(p), G, We, E, B);
275
+ return B.delete(h), Je;
276
+ case be:
277
+ if (Ge)
278
+ return Ge.call(h) == Ge.call(p);
279
+ }
280
+ return !1;
281
+ }(d, y, N, _, A, j, w);
282
+ if (!(_ & a)) {
283
+ var pe = ae && M.call(d, "__wrapped__"), St = xe && M.call(y, "__wrapped__");
284
+ if (pe || St) {
285
+ var Er = pe ? d.value() : d, Ir = St ? y.value() : y;
286
+ return w || (w = new H()), j(Er, Ir, _, A, w);
287
+ }
288
+ }
289
+ return ie ? (w || (w = new H()), function(h, p, Ee, G, We, E) {
290
+ var B = Ee & a, Z = Ft(h), he = Z.length, Ie = Ft(p), Je = Ie.length;
291
+ if (he != Je && !B)
292
+ return !1;
293
+ for (var Fe = he; Fe--; ) {
294
+ var ee = Z[Fe];
295
+ if (!(B ? ee in p : M.call(p, ee)))
296
+ return !1;
297
+ }
298
+ var qt = E.get(h);
299
+ if (qt && E.get(p))
300
+ return qt == p;
301
+ var ze = !0;
302
+ E.set(h, p), E.set(p, h);
303
+ for (var Ke = B; ++Fe < he; ) {
304
+ var Oe = h[ee = Z[Fe]], Ae = p[ee];
305
+ if (G)
306
+ var Lt = B ? G(Ae, Oe, ee, p, h, E) : G(Oe, Ae, ee, h, p, E);
307
+ if (!(Lt === void 0 ? Oe === Ae || We(Oe, Ae, Ee, G, E) : Lt)) {
308
+ ze = !1;
309
+ break;
310
+ }
311
+ Ke || (Ke = ee == "constructor");
312
+ }
313
+ if (ze && !Ke) {
314
+ var Re = h.constructor, Me = p.constructor;
315
+ Re == Me || !("constructor" in h) || !("constructor" in p) || typeof Re == "function" && Re instanceof Re && typeof Me == "function" && Me instanceof Me || (ze = !1);
316
+ }
317
+ return E.delete(h), E.delete(p), ze;
318
+ }(d, y, _, A, j, w)) : !1;
319
+ }(e, t, n, s, Et, b));
320
+ }
321
+ function kr(e) {
322
+ return !(!Rt(e) || function(t) {
323
+ return !!gt && gt in t;
324
+ }(e)) && (Ot(e) ? dr : nr).test(Y(e));
325
+ }
326
+ function jr(e) {
327
+ if (n = (t = e) && t.constructor, s = typeof n == "function" && n.prototype || _e, t !== s)
328
+ return hr(e);
329
+ var t, n, s, b = [];
330
+ for (var d in Object(e))
331
+ M.call(e, d) && d != "constructor" && b.push(d);
332
+ return b;
333
+ }
334
+ function It(e, t, n, s, b, d) {
335
+ var y = n & a, _ = e.length, A = t.length;
336
+ if (_ != A && !(y && A > _))
337
+ return !1;
338
+ var j = d.get(e);
339
+ if (j && d.get(t))
340
+ return j == t;
341
+ var w = -1, S = !0, T = n & c ? new je() : void 0;
342
+ for (d.set(e, t), d.set(t, e); ++w < _; ) {
343
+ var N = e[w], $ = t[w];
344
+ if (s)
345
+ var ae = y ? s($, N, w, t, e, d) : s(N, $, w, e, t, d);
346
+ if (ae !== void 0) {
347
+ if (ae)
348
+ continue;
349
+ S = !1;
350
+ break;
351
+ }
352
+ if (T) {
353
+ if (!or(t, function(xe, ie) {
354
+ if (pe = ie, !T.has(pe) && (N === xe || b(N, xe, n, s, d)))
355
+ return T.push(ie);
356
+ var pe;
357
+ })) {
358
+ S = !1;
359
+ break;
360
+ }
361
+ } else if (N !== $ && !b(N, $, n, s, d)) {
362
+ S = !1;
363
+ break;
364
+ }
365
+ }
366
+ return d.delete(e), d.delete(t), S;
367
+ }
368
+ function Ft(e) {
369
+ return function(t, n, s) {
370
+ var b = n(t);
371
+ return Ne(t) ? b : function(d, y) {
372
+ for (var _ = -1, A = y.length, j = d.length; ++_ < A; )
373
+ d[j + _] = y[_];
374
+ return d;
375
+ }(b, s(t));
376
+ }(e, xr, wr);
377
+ }
378
+ function Ce(e, t) {
379
+ var n, s, b = e.__data__;
380
+ return ((s = typeof (n = t)) == "string" || s == "number" || s == "symbol" || s == "boolean" ? n !== "__proto__" : n === null) ? b[typeof t == "string" ? "string" : "hash"] : b.map;
381
+ }
382
+ function ne(e, t) {
383
+ var n = function(s, b) {
384
+ return s?.[b];
385
+ }(e, t);
386
+ return kr(n) ? n : void 0;
387
+ }
388
+ Q.prototype.clear = function() {
389
+ this.__data__ = ue ? ue(null) : {}, this.size = 0;
390
+ }, Q.prototype.delete = function(e) {
391
+ var t = this.has(e) && delete this.__data__[e];
392
+ return this.size -= t ? 1 : 0, t;
393
+ }, Q.prototype.get = function(e) {
394
+ var t = this.__data__;
395
+ if (ue) {
396
+ var n = t[e];
397
+ return n === i ? void 0 : n;
398
+ }
399
+ return M.call(t, e) ? t[e] : void 0;
400
+ }, Q.prototype.has = function(e) {
401
+ var t = this.__data__;
402
+ return ue ? t[e] !== void 0 : M.call(t, e);
403
+ }, Q.prototype.set = function(e, t) {
404
+ var n = this.__data__;
405
+ return this.size += this.has(e) ? 0 : 1, n[e] = ue && t === void 0 ? i : t, this;
406
+ }, P.prototype.clear = function() {
407
+ this.__data__ = [], this.size = 0;
408
+ }, P.prototype.delete = function(e) {
409
+ var t = this.__data__, n = we(t, e);
410
+ return !(n < 0) && (n == t.length - 1 ? t.pop() : fr.call(t, n, 1), --this.size, !0);
411
+ }, P.prototype.get = function(e) {
412
+ var t = this.__data__, n = we(t, e);
413
+ return n < 0 ? void 0 : t[n][1];
414
+ }, P.prototype.has = function(e) {
415
+ return we(this.__data__, e) > -1;
416
+ }, P.prototype.set = function(e, t) {
417
+ var n = this.__data__, s = we(n, e);
418
+ return s < 0 ? (++this.size, n.push([e, t])) : n[s][1] = t, this;
419
+ }, X.prototype.clear = function() {
420
+ this.size = 0, this.__data__ = { hash: new Q(), map: new (le || P)(), string: new Q() };
421
+ }, X.prototype.delete = function(e) {
422
+ var t = Ce(this, e).delete(e);
423
+ return this.size -= t ? 1 : 0, t;
424
+ }, X.prototype.get = function(e) {
425
+ return Ce(this, e).get(e);
426
+ }, X.prototype.has = function(e) {
427
+ return Ce(this, e).has(e);
428
+ }, X.prototype.set = function(e, t) {
429
+ var n = Ce(this, e), s = n.size;
430
+ return n.set(e, t), this.size += n.size == s ? 0 : 1, this;
431
+ }, je.prototype.add = je.prototype.push = function(e) {
432
+ return this.__data__.set(e, i), this;
433
+ }, je.prototype.has = function(e) {
434
+ return this.__data__.has(e);
435
+ }, H.prototype.clear = function() {
436
+ this.__data__ = new P(), this.size = 0;
437
+ }, H.prototype.delete = function(e) {
438
+ var t = this.__data__, n = t.delete(e);
439
+ return this.size = t.size, n;
440
+ }, H.prototype.get = function(e) {
441
+ return this.__data__.get(e);
442
+ }, H.prototype.has = function(e) {
443
+ return this.__data__.has(e);
444
+ }, H.prototype.set = function(e, t) {
445
+ var n = this.__data__;
446
+ if (n instanceof P) {
447
+ var s = n.__data__;
448
+ if (!le || s.length < 199)
449
+ return s.push([e, t]), this.size = ++n.size, this;
450
+ n = this.__data__ = new X(s);
451
+ }
452
+ return n.set(e, t), this.size = n.size, this;
453
+ };
454
+ var wr = Ct ? function(e) {
455
+ return e == null ? [] : (e = Object(e), function(t, n) {
456
+ for (var s = -1, b = t == null ? 0 : t.length, d = 0, y = []; ++s < b; ) {
457
+ var _ = t[s];
458
+ n(_, s, t) && (y[d++] = _);
459
+ }
460
+ return y;
461
+ }(Ct(e), function(t) {
462
+ return wt.call(e, t);
463
+ }));
464
+ } : function() {
465
+ return [];
466
+ }, U = de;
467
+ function Cr(e, t) {
468
+ return !!(t = t ?? l) && (typeof e == "number" || ar.test(e)) && e > -1 && e % 1 == 0 && e < t;
469
+ }
470
+ function Y(e) {
471
+ if (e != null) {
472
+ try {
473
+ return yt.call(e);
474
+ } catch {
475
+ }
476
+ try {
477
+ return e + "";
478
+ } catch {
479
+ }
480
+ }
481
+ return "";
482
+ }
483
+ function zt(e, t) {
484
+ return e === t || e != e && t != t;
485
+ }
486
+ (Ve && U(new Ve(new ArrayBuffer(1))) != ge || le && U(new le()) != z || De && U(De.resolve()) != J || He && U(new He()) != q || Ue && U(new Ue()) != ce) && (U = function(e) {
487
+ var t = de(e), n = t == O ? e.constructor : void 0, s = n ? Y(n) : "";
488
+ if (s)
489
+ switch (s) {
490
+ case mr:
491
+ return ge;
492
+ case vr:
493
+ return z;
494
+ case br:
495
+ return J;
496
+ case yr:
497
+ return q;
498
+ case gr:
499
+ return ce;
500
+ }
501
+ return t;
502
+ });
503
+ var Nr = xt(function() {
504
+ return arguments;
505
+ }()) ? xt : function(e) {
506
+ return fe(e) && M.call(e, "callee") && !wt.call(e, "callee");
507
+ }, Ne = Array.isArray, Ze = pr || function() {
508
+ return !1;
509
+ };
510
+ function Ot(e) {
511
+ if (!Rt(e))
512
+ return !1;
513
+ var t = de(e);
514
+ return t == I || t == F || t == k || t == te;
515
+ }
516
+ function At(e) {
517
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= l;
518
+ }
519
+ function Rt(e) {
520
+ var t = typeof e;
521
+ return e != null && (t == "object" || t == "function");
522
+ }
523
+ function fe(e) {
524
+ return e != null && typeof e == "object";
525
+ }
526
+ var Mt = ht ? function(e) {
527
+ return function(t) {
528
+ return e(t);
529
+ };
530
+ }(ht) : function(e) {
531
+ return fe(e) && At(e.length) && !!v[de(e)];
532
+ };
533
+ function xr(e) {
534
+ return (t = e) != null && At(t.length) && !Ot(t) ? _r(e) : jr(e);
535
+ var t;
536
+ }
537
+ r.exports = function(e, t) {
538
+ return Et(e, t);
539
+ };
540
+ })(Xe, Xe.exports);
541
+ const Wr = Zr(Xe.exports);
542
+ function Jr(r, o) {
543
+ const { current: i } = Pe(r === void 0 ? o : r), [a, c] = Dt(i), l = function() {
544
+ const f = Pe(!1), k = Le(() => f.current, []);
545
+ return Te(() => (f.current = !0, () => {
546
+ f.current = !1;
547
+ }), []), k;
548
+ }();
549
+ $t(() => {
550
+ l() && r != null && c(r);
551
+ }, [r, c, l]);
552
+ const u = Le((f, k) => {
553
+ (r === void 0 || k) && !Wr(f, a) && c(f);
554
+ }, [r, c, a]);
555
+ return [a, u, r !== void 0, i];
556
+ }
557
+ const Kr = et(["flex", "gap-lg"], { variants: { orientation: { vertical: ["flex-col"], horizontal: [] } } }), Qr = x(({ name: r, value: o, defaultValue: i, className: a, intent: c, orientation: l = "vertical", onCheckedChange: u, children: f, ...k }, C) => {
558
+ const [g, R] = Jr(o, i), I = st(), F = Pe(u), { id: z, labelId: W, description: V, isInvalid: O, isRequired: J } = I, te = r ?? I.name, re = Ht(() => ({ id: z, name: te, value: g, intent: c, isInvalid: O, description: V, isRequired: J, onCheckedChange: (q, D) => {
559
+ const be = g || [], ye = q ? [...be, D] : be.filter((ce) => ce !== D);
560
+ R(ye), F.current && F.current(ye);
561
+ } }), [z, te, g, c, O, V, J, R]);
562
+ return Te(() => {
563
+ F.current = u;
564
+ }, [u]), m.createElement(Qt.Provider, { value: re }, m.createElement("div", { ref: C, className: Kr({ className: a, orientation: l }), role: "group", "aria-labelledby": W, "aria-describedby": V, ...k }, f));
565
+ });
566
+ Qr.displayName = "CheckboxGroup";
33
567
  export {
34
- V as Checkbox
568
+ Gr as Checkbox,
569
+ Qr as CheckboxGroup
35
570
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/checkbox",
3
- "version": "1.13.11",
3
+ "version": "1.14.0",
4
4
  "description": "A control that allows the user to toggle between checked and not checked.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,9 +13,9 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@radix-ui/react-checkbox": "1.0.3",
16
- "@radix-ui/react-label": "2.0.1",
17
16
  "@spark-ui/icons": "^1.11.0",
18
17
  "@spark-ui/internal-utils": "^1.6.0",
18
+ "@spark-ui/label": "^1.2.0",
19
19
  "@spark-ui/use-merge-refs": "^0.3.3",
20
20
  "class-variance-authority": "0.5.2"
21
21
  },
@@ -34,5 +34,5 @@
34
34
  },
35
35
  "homepage": "https://sparkui.vercel.app",
36
36
  "license": "MIT",
37
- "gitHead": "8adc6600491da246574c20a992638d0a682d26a3"
37
+ "gitHead": "ca13672e7ef516ad782af187f199a924deef9655"
38
38
  }