@spark-ui/checkbox 1.13.11 → 1.14.1

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,23 @@
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.1](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.14.0...@spark-ui/checkbox@1.14.1) (2023-05-24)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **checkbox:** checked icon not being displayed in safari ([0ea59cf](https://github.com/adevinta/spark/commit/0ea59cffe5a86b11c03611eb5e1c600d9ec78966))
11
+
12
+ # [1.14.0](https://github.com/adevinta/spark/compare/@spark-ui/checkbox@1.13.11...@spark-ui/checkbox@1.14.0) (2023-05-23)
13
+
14
+ ### Features
15
+
16
+ - **checkbox:** add checkbox group and integrate form field ([e65df62](https://github.com/adevinta/spark/commit/e65df6283b708611d8ba213d93fe011fe7080291))
17
+ - **checkbox:** improve api and doc ([bc7c0fc](https://github.com/adevinta/spark/commit/bc7c0fcf54334fcedec2279a5c71ebf2aaba4f20))
18
+ - **checkbox:** minor update ([a9e7ca6](https://github.com/adevinta/spark/commit/a9e7ca68bb9c2bfd3d572fdc9dd6516ac3801ce5))
19
+ - **checkbox:** minor updates and tests ([8ffd0c5](https://github.com/adevinta/spark/commit/8ffd0c51e3b2a843d31ad0438149d19fee67f384))
20
+ - **checkbox:** renamed onChange to onCheckedChange ([2460a10](https://github.com/adevinta/spark/commit/2460a1010f1f124986a5088aba5642806db8b4f6))
21
+ - **checkbox:** update typos and rename variables ([da21719](https://github.com/adevinta/spark/commit/da217196615f0df10aeebb9e44c36dc18339613a))
22
+
6
23
  ## [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
24
 
8
25
  **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/icon"),_r=require("@spark-ui/internal-utils"),kr=require("@spark-ui/label");function wr(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=wr(n),jr=globalThis?.document?n.useLayoutEffect:()=>{},Cr=zt["useId".toString()]||(()=>{});let xr=0;function Ge(r){const[s,i]=zt.useState(Cr());return jr(()=>{r||i(o=>o??String(xr++))},[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 Er(...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(Nr);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,{...Rr(o,i.props),ref:Er(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 Nr(r){return n.isValidElement(r)&&r.type===St}function Rr(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 Ir=n.forwardRef((r,s)=>n.createElement(Ze,{ref:s,...r})),Or=["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}},{}),Fr=n.forwardRef((r,s)=>n.createElement(Or.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},qt=({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)};qt.displayName="FormFieldProvider";const At=n.forwardRef(({className:r,name:s,isInvalid:i=!1,isRequired:o=!1,asChild:l=!1,...u},d)=>{const p=Ge(),k=l?Ir:"div";return n.createElement(qt,{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}))});At.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 Mt=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});Mt.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(Fr,{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(At,{Label:Pt,State:It,ErrorMessage:Mt,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 h-full w-full items-center justify-center",...r}));Bt.displayName="CheckboxIndicator";const zr=V.cva(["h-sz-16 w-sz-16 border-md box-content items-center justify-center rounded-sm bg-transparent outline-none","spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0","focus-visible:ring-outline-high focus-visible:ring-2","hover:border-primary-container hover:ring-2","u-shadow-border-transition"],{variants:{intent:_r.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:zr({intent:o,className:r}),checked:l,...u},n.createElement(Bt,null,n.createElement(gr.Icon,{size:"sm"},l==="indeterminate"?i:s))));Dt.displayName="CheckboxInput";const Sr=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(kr.Label,{className:Sr({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:A=>{u&&u(A);const D=z.current;g.onCheckedChange&&D?.value&&g.onCheckedChange(A,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 qr(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]",A="[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[A]=b[D]=b[se]=!1;var et=typeof ze=="object"&&ze&&ze.Object===Object&&ze,Wt=typeof self=="object"&&self&&self.Object===Object&&self,M=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,qe=M["__core-js_shared__"],lt=Yt.toString,S=ve.hasOwnProperty,ut=(ot=/[^.]+$/.exec(qe&&qe.keys&&qe.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?M.Buffer:void 0,ye=M.Symbol,pt=M.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))}),Ae=ne(M,"DataView"),ce=ne(M,"Map"),Me=ne(M,"Promise"),Le=ne(M,"Set"),Pe=ne(M,"WeakMap"),le=ne(Object,"create"),ar=Y(Ae),ir=Y(ce),or=Y(Me),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,q){for(var P=-1,x=Array(j);++P<j;)x[P]=q(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 q=we(f),P=we(y),x=q?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;q=!0,ae=!1}if(ie&&!ae)return j||(j=new H),q||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 A: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,q=!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;q=!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})){q=!1;break}}else if(x!==T&&!v(x,T,a,c,f)){q=!1;break}}return f.delete(e),f.delete(t),q}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}(Ae&&U(new Ae(new ArrayBuffer(1)))!=be||ce&&U(new ce)!=I||Me&&U(Me.resolve())!=J||Le&&U(new Le)!=A||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 A;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=qr(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 Lr=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:(A,D)=>{const he=g||[],me=A?[...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:Lr({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,571 @@
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 h, { useLayoutEffect as $t, forwardRef as N, Children as me, isValidElement as qe, createElement as be, 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 { Icon as Rr } from "@spark-ui/icon";
8
+ import { makeVariants as Mr } from "@spark-ui/internal-utils";
9
+ import { Label as Sr } from "@spark-ui/label";
10
+ const qr = globalThis?.document ? $t : () => {
11
+ }, Lr = Tt["useId".toString()] || (() => {
12
+ });
13
+ let Pr = 0;
14
+ function tt(r) {
15
+ const [o, i] = Tt.useState(Lr());
16
+ return qr(() => {
17
+ r || i((a) => a ?? String(Pr++));
18
+ }, [r]), r || (o ? `radix-${o}` : "");
19
+ }
20
+ function oe() {
21
+ return oe = Object.assign ? Object.assign.bind() : function(r) {
22
+ for (var o = 1; o < arguments.length; o++) {
23
+ var i = arguments[o];
24
+ for (var a in i)
25
+ Object.prototype.hasOwnProperty.call(i, a) && (r[a] = i[a]);
26
+ }
27
+ return r;
28
+ }, oe.apply(this, arguments);
29
+ }
30
+ function Tr(...r) {
31
+ return (o) => r.forEach((i) => function(a, c) {
32
+ typeof a == "function" ? a(c) : a != null && (a.current = c);
33
+ }(i, o));
34
+ }
35
+ const rt = N((r, o) => {
36
+ const { children: i, ...a } = r, c = me.toArray(i), l = c.find($r);
37
+ if (l) {
38
+ 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);
39
+ return be(Qe, oe({}, a, { ref: o }), qe(u) ? Bt(u, void 0, f) : null);
40
+ }
41
+ return be(Qe, oe({}, a, { ref: o }), i);
42
+ });
43
+ rt.displayName = "Slot";
44
+ const Qe = N((r, o) => {
45
+ const { children: i, ...a } = r;
46
+ return qe(i) ? Bt(i, { ...Br(a, i.props), ref: Tr(o, i.ref) }) : me.count(i) > 1 ? me.only(null) : null;
47
+ });
48
+ Qe.displayName = "SlotClone";
49
+ const Ut = ({ children: r }) => be(Fr, null, r);
50
+ function $r(r) {
51
+ return qe(r) && r.type === Ut;
52
+ }
53
+ function Br(r, o) {
54
+ const i = { ...o };
55
+ for (const a in o) {
56
+ const c = r[a], l = o[a];
57
+ /^on[A-Z]/.test(a) ? c && l ? i[a] = (...u) => {
58
+ l(...u), c(...u);
59
+ } : c && (i[a] = c) : a === "style" ? i[a] = { ...c, ...l } : a === "className" && (i[a] = [c, l].filter(Boolean).join(" "));
60
+ }
61
+ return { ...r, ...i };
62
+ }
63
+ const Vr = N((r, o) => h.createElement(rt, { ref: o, ...r })), Dr = ["a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "span", "svg", "ul"].reduce((r, o) => {
64
+ const i = N((a, c) => {
65
+ const { asChild: l, ...u } = a, f = l ? rt : o;
66
+ return Te(() => {
67
+ window[Symbol.for("radix-ui")] = !0;
68
+ }, []), be(f, oe({}, u, { ref: c }));
69
+ });
70
+ return i.displayName = `Primitive.${o}`, { ...r, [o]: i };
71
+ }, {}), Hr = N((r, o) => be(Dr.label, oe({}, r, { ref: o, onMouseDown: (i) => {
72
+ var a;
73
+ (a = r.onMouseDown) === null || a === void 0 || a.call(r, i), !i.defaultPrevented && i.detail > 1 && i.preventDefault();
74
+ } }))), nt = Vt(null), at = () => {
75
+ const r = Ye(nt);
76
+ if (!r)
77
+ throw Error("useFormField must be used within a FormField provider");
78
+ return r;
79
+ }, Gt = ({ id: r, name: o, isInvalid: i, isRequired: a, children: c }) => {
80
+ const l = tt(), [u, f] = Dt([]), k = u.length > 0 ? u.join(" ") : void 0, C = Le((I) => {
81
+ f((F) => [...F, I]);
82
+ }, []), g = Le((I) => {
83
+ f((F) => F.filter((z) => z !== I));
84
+ }, []), 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]);
85
+ return h.createElement(nt.Provider, { value: R }, c);
86
+ };
87
+ Gt.displayName = "FormFieldProvider";
88
+ const Zt = N(({ className: r, name: o, isInvalid: i = !1, isRequired: a = !1, asChild: c = !1, ...l }, u) => {
89
+ const f = tt(), k = c ? Vr : "div";
90
+ return h.createElement(Gt, { id: f, name: o, isRequired: a, isInvalid: i }, h.createElement(k, { ref: u, "data-spark-component": "form-control", className: se(r, "flex flex-col gap-xl"), ...l }));
91
+ });
92
+ Zt.displayName = "FormField";
93
+ const it = N(({ id: r, className: o, ...i }, a) => {
94
+ const { onMessageIdAdd: c, onMessageIdRemove: l } = at(), u = tt(), f = r || u;
95
+ return Te(() => (c(f), () => {
96
+ l(f);
97
+ }), [f, c, l]), h.createElement("span", { ref: a, id: f, className: se(o, "text-caption"), ...i });
98
+ });
99
+ it.displayName = "FormField.Message";
100
+ const Wt = N(({ className: r, ...o }, i) => {
101
+ const { isInvalid: a } = at();
102
+ return a ? h.createElement(it, { ref: i, "data-spark-component": "form-error-message", "aria-live": "polite", className: se(r, "text-error"), ...o }) : null;
103
+ });
104
+ Wt.displayName = "FormField.ErrorMessage";
105
+ const Jt = N(({ className: r, ...o }, i) => h.createElement(it, { ref: i, "data-spark-component": "form-helper-message", className: se(r, "text-neutral"), ...o }));
106
+ Jt.displayName = "FormField.HelperMessage";
107
+ const ot = N(({ className: r, children: o = "*", ...i }, a) => h.createElement("span", { ref: a, "data-spark-component": "form-required-indicator", role: "presentation", "aria-hidden": "true", className: se(r, "text-error"), ...i }, o));
108
+ ot.displayName = "FormField.RequiredIndicator";
109
+ const Kt = N(({ htmlFor: r, className: o, children: i, requiredIndicator: a = h.createElement(ot, null), asChild: c, ...l }, u) => {
110
+ const f = at(), { labelId: k, isRequired: C } = f, g = c ? void 0 : r || f.id;
111
+ return h.createElement(Hr, { 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 }, h.createElement(Ut, null, i), C && a);
112
+ });
113
+ Kt.displayName = "FormField.Label";
114
+ const st = () => {
115
+ const { id: r, name: o, description: i, labelId: a, isRequired: c, isInvalid: l } = Ye(nt) || {};
116
+ return { id: r, name: o, description: i, labelId: a, isRequired: c, isInvalid: l };
117
+ }, Pt = ({ children: r }) => {
118
+ const { id: o, name: i, isInvalid: a, labelId: c, isRequired: l, description: u } = st();
119
+ return h.createElement(h.Fragment, null, r({ id: o, labelId: c, name: i, isRequired: l, isInvalid: a, description: u }));
120
+ };
121
+ Pt.displayName = "FormField.State", Object.assign(Zt, { Label: Kt, State: Pt, ErrorMessage: Wt, HelperMessage: Jt, RequiredIndicator: ot });
122
+ const Qt = Vt({}), Xt = h.forwardRef(({ title: r, fill: o = "currentColor", stroke: i = "none", ...a }, c) => h.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"/>' } }));
123
+ Xt.displayName = "Check";
124
+ const Yt = h.forwardRef(({ title: r, fill: o = "currentColor", stroke: i = "none", ...a }, c) => h.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"/>' } }));
125
+ Yt.displayName = "Minus";
126
+ const er = N((r, o) => h.createElement(Or, { ref: o, className: "text-surface flex h-full w-full items-center justify-center", ...r }));
127
+ er.displayName = "CheckboxIndicator";
128
+ const Ur = et(["h-sz-16 w-sz-16 border-md box-content items-center justify-center rounded-sm bg-transparent outline-none", "spark-disabled:opacity-dim-3 spark-disabled:cursor-not-allowed spark-disabled:hover:ring-0", "focus-visible:ring-outline-high focus-visible:ring-2", "hover:border-primary-container hover:ring-2", "u-shadow-border-transition"], { variants: { intent: Mr({ 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 = N(({ className: r, icon: o = h.createElement(Xt, null), indeterminateIcon: i = h.createElement(Yt, null), intent: a, checked: c, ...l }, u) => h.createElement(Ar, { ref: u, className: Ur({ intent: a, className: r }), checked: c, ...l }, h.createElement(er, null, h.createElement(Rr, { size: "sm" }, c === "indeterminate" ? i : o))));
129
+ tr.displayName = "CheckboxInput";
130
+ const Gr = 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 }) => h.createElement(Sr, { className: Gr({ className: r, disabled: o }), ...i });
131
+ rr.displayName = "CheckboxLabel";
132
+ const Zr = N(({ className: r, intent: o, checked: i, value: a, disabled: c, onCheckedChange: l, children: u, ...f }, k) => {
133
+ 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;
134
+ return h.createElement(rr, { "data-spark-component": "checkbox", className: r, disabled: c }, h.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) => {
135
+ l && l(q);
136
+ const D = R.current;
137
+ g.onCheckedChange && D?.value && g.onCheckedChange(q, D.value);
138
+ }, ...f }), u);
139
+ });
140
+ Zr.displayName = "Checkbox";
141
+ var Se = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
142
+ function Wr(r) {
143
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
144
+ }
145
+ var Xe = { exports: {} };
146
+ (function(r, o) {
147
+ 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]", ve = "[object Symbol]", ye = "[object Undefined]", ce = "[object WeakMap]", ct = "[object ArrayBuffer]", ge = "[object DataView]", nr = /^\[object .+?Constructor\]$/, ar = /^(?:0|[1-9]\d*)$/, b = {};
148
+ 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[u] = b[f] = b[ct] = b[C] = b[ge] = b[g] = b[R] = b[I] = b[z] = b[W] = b[O] = b[re] = b[q] = b[D] = b[ce] = !1;
149
+ 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() {
150
+ try {
151
+ return $e && $e.binding && $e.binding("util");
152
+ } catch {
153
+ }
154
+ }(), ht = pt && pt.isTypedArray;
155
+ function or(e, t) {
156
+ for (var n = -1, s = e == null ? 0 : e.length; ++n < s; )
157
+ if (t(e[n], n, e))
158
+ return !0;
159
+ return !1;
160
+ }
161
+ function sr(e) {
162
+ var t = -1, n = Array(e.size);
163
+ return e.forEach(function(s, v) {
164
+ n[++t] = [v, s];
165
+ }), n;
166
+ }
167
+ function cr(e) {
168
+ var t = -1, n = Array(e.size);
169
+ return e.forEach(function(s) {
170
+ n[++t] = s;
171
+ }), n;
172
+ }
173
+ var mt, bt, vt, 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 = (bt = Object.keys, vt = Object, function(e) {
174
+ return bt(vt(e));
175
+ }), 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), br = Y(le), vr = Y(De), yr = Y(He), gr = Y(Ue), xt = ke ? ke.prototype : void 0, Ge = xt ? xt.valueOf : void 0;
176
+ function Q(e) {
177
+ var t = -1, n = e == null ? 0 : e.length;
178
+ for (this.clear(); ++t < n; ) {
179
+ var s = e[t];
180
+ this.set(s[0], s[1]);
181
+ }
182
+ }
183
+ function P(e) {
184
+ var t = -1, n = e == null ? 0 : e.length;
185
+ for (this.clear(); ++t < n; ) {
186
+ var s = e[t];
187
+ this.set(s[0], s[1]);
188
+ }
189
+ }
190
+ function X(e) {
191
+ var t = -1, n = e == null ? 0 : e.length;
192
+ for (this.clear(); ++t < n; ) {
193
+ var s = e[t];
194
+ this.set(s[0], s[1]);
195
+ }
196
+ }
197
+ function je(e) {
198
+ var t = -1, n = e == null ? 0 : e.length;
199
+ for (this.__data__ = new X(); ++t < n; )
200
+ this.add(e[t]);
201
+ }
202
+ function H(e) {
203
+ var t = this.__data__ = new P(e);
204
+ this.size = t.size;
205
+ }
206
+ function _r(e, t) {
207
+ var n = xe(e), s = !n && xr(e), v = !n && !s && Ze(e), d = !n && !s && !v && Mt(e), y = n || s || v || d, _ = y ? function(w, S) {
208
+ for (var T = -1, x = Array(w); ++T < w; )
209
+ x[T] = S(T);
210
+ return x;
211
+ }(e.length, String) : [], A = _.length;
212
+ for (var j in e)
213
+ !t && !M.call(e, j) || y && (j == "length" || v && (j == "offset" || j == "parent") || d && (j == "buffer" || j == "byteLength" || j == "byteOffset") || Cr(j, A)) || _.push(j);
214
+ return _;
215
+ }
216
+ function we(e, t) {
217
+ for (var n = e.length; n--; )
218
+ if (zt(e[n][0], t))
219
+ return n;
220
+ return -1;
221
+ }
222
+ function de(e) {
223
+ return e == null ? e === void 0 ? ye : V : K && K in Object(e) ? function(t) {
224
+ var n = M.call(t, K), s = t[K];
225
+ try {
226
+ t[K] = void 0;
227
+ var v = !0;
228
+ } catch {
229
+ }
230
+ var d = _t.call(t);
231
+ return v && (n ? t[K] = s : delete t[K]), d;
232
+ }(e) : function(t) {
233
+ return _t.call(t);
234
+ }(e);
235
+ }
236
+ function Nt(e) {
237
+ return fe(e) && de(e) == u;
238
+ }
239
+ function Et(e, t, n, s, v) {
240
+ return e === t || (e == null || t == null || !fe(e) && !fe(t) ? e != e && t != t : function(d, y, _, A, j, w) {
241
+ var S = xe(d), T = xe(y), x = S ? f : U(d), $ = T ? f : U(y), ae = (x = x == u ? O : x) == O, Ne = ($ = $ == u ? O : $) == O, ie = x == $;
242
+ if (ie && Ze(d)) {
243
+ if (!Ze(y))
244
+ return !1;
245
+ S = !0, ae = !1;
246
+ }
247
+ if (ie && !ae)
248
+ return w || (w = new H()), S || Mt(d) ? It(d, y, _, A, j, w) : function(m, p, Ee, G, We, E, B) {
249
+ switch (Ee) {
250
+ case ge:
251
+ if (m.byteLength != p.byteLength || m.byteOffset != p.byteOffset)
252
+ return !1;
253
+ m = m.buffer, p = p.buffer;
254
+ case ct:
255
+ return !(m.byteLength != p.byteLength || !E(new jt(m), new jt(p)));
256
+ case C:
257
+ case g:
258
+ case W:
259
+ return zt(+m, +p);
260
+ case R:
261
+ return m.name == p.name && m.message == p.message;
262
+ case re:
263
+ case D:
264
+ return m == p + "";
265
+ case z:
266
+ var Z = sr;
267
+ case q:
268
+ var he = G & a;
269
+ if (Z || (Z = cr), m.size != p.size && !he)
270
+ return !1;
271
+ var Ie = B.get(m);
272
+ if (Ie)
273
+ return Ie == p;
274
+ G |= c, B.set(m, p);
275
+ var Je = It(Z(m), Z(p), G, We, E, B);
276
+ return B.delete(m), Je;
277
+ case ve:
278
+ if (Ge)
279
+ return Ge.call(m) == Ge.call(p);
280
+ }
281
+ return !1;
282
+ }(d, y, x, _, A, j, w);
283
+ if (!(_ & a)) {
284
+ var pe = ae && M.call(d, "__wrapped__"), St = Ne && M.call(y, "__wrapped__");
285
+ if (pe || St) {
286
+ var Er = pe ? d.value() : d, Ir = St ? y.value() : y;
287
+ return w || (w = new H()), j(Er, Ir, _, A, w);
288
+ }
289
+ }
290
+ return ie ? (w || (w = new H()), function(m, p, Ee, G, We, E) {
291
+ var B = Ee & a, Z = Ft(m), he = Z.length, Ie = Ft(p), Je = Ie.length;
292
+ if (he != Je && !B)
293
+ return !1;
294
+ for (var Fe = he; Fe--; ) {
295
+ var ee = Z[Fe];
296
+ if (!(B ? ee in p : M.call(p, ee)))
297
+ return !1;
298
+ }
299
+ var qt = E.get(m);
300
+ if (qt && E.get(p))
301
+ return qt == p;
302
+ var ze = !0;
303
+ E.set(m, p), E.set(p, m);
304
+ for (var Ke = B; ++Fe < he; ) {
305
+ var Oe = m[ee = Z[Fe]], Ae = p[ee];
306
+ if (G)
307
+ var Lt = B ? G(Ae, Oe, ee, p, m, E) : G(Oe, Ae, ee, m, p, E);
308
+ if (!(Lt === void 0 ? Oe === Ae || We(Oe, Ae, Ee, G, E) : Lt)) {
309
+ ze = !1;
310
+ break;
311
+ }
312
+ Ke || (Ke = ee == "constructor");
313
+ }
314
+ if (ze && !Ke) {
315
+ var Re = m.constructor, Me = p.constructor;
316
+ Re == Me || !("constructor" in m) || !("constructor" in p) || typeof Re == "function" && Re instanceof Re && typeof Me == "function" && Me instanceof Me || (ze = !1);
317
+ }
318
+ return E.delete(m), E.delete(p), ze;
319
+ }(d, y, _, A, j, w)) : !1;
320
+ }(e, t, n, s, Et, v));
321
+ }
322
+ function kr(e) {
323
+ return !(!Rt(e) || function(t) {
324
+ return !!gt && gt in t;
325
+ }(e)) && (Ot(e) ? dr : nr).test(Y(e));
326
+ }
327
+ function jr(e) {
328
+ if (n = (t = e) && t.constructor, s = typeof n == "function" && n.prototype || _e, t !== s)
329
+ return hr(e);
330
+ var t, n, s, v = [];
331
+ for (var d in Object(e))
332
+ M.call(e, d) && d != "constructor" && v.push(d);
333
+ return v;
334
+ }
335
+ function It(e, t, n, s, v, d) {
336
+ var y = n & a, _ = e.length, A = t.length;
337
+ if (_ != A && !(y && A > _))
338
+ return !1;
339
+ var j = d.get(e);
340
+ if (j && d.get(t))
341
+ return j == t;
342
+ var w = -1, S = !0, T = n & c ? new je() : void 0;
343
+ for (d.set(e, t), d.set(t, e); ++w < _; ) {
344
+ var x = e[w], $ = t[w];
345
+ if (s)
346
+ var ae = y ? s($, x, w, t, e, d) : s(x, $, w, e, t, d);
347
+ if (ae !== void 0) {
348
+ if (ae)
349
+ continue;
350
+ S = !1;
351
+ break;
352
+ }
353
+ if (T) {
354
+ if (!or(t, function(Ne, ie) {
355
+ if (pe = ie, !T.has(pe) && (x === Ne || v(x, Ne, n, s, d)))
356
+ return T.push(ie);
357
+ var pe;
358
+ })) {
359
+ S = !1;
360
+ break;
361
+ }
362
+ } else if (x !== $ && !v(x, $, n, s, d)) {
363
+ S = !1;
364
+ break;
365
+ }
366
+ }
367
+ return d.delete(e), d.delete(t), S;
368
+ }
369
+ function Ft(e) {
370
+ return function(t, n, s) {
371
+ var v = n(t);
372
+ return xe(t) ? v : function(d, y) {
373
+ for (var _ = -1, A = y.length, j = d.length; ++_ < A; )
374
+ d[j + _] = y[_];
375
+ return d;
376
+ }(v, s(t));
377
+ }(e, Nr, wr);
378
+ }
379
+ function Ce(e, t) {
380
+ var n, s, v = e.__data__;
381
+ return ((s = typeof (n = t)) == "string" || s == "number" || s == "symbol" || s == "boolean" ? n !== "__proto__" : n === null) ? v[typeof t == "string" ? "string" : "hash"] : v.map;
382
+ }
383
+ function ne(e, t) {
384
+ var n = function(s, v) {
385
+ return s?.[v];
386
+ }(e, t);
387
+ return kr(n) ? n : void 0;
388
+ }
389
+ Q.prototype.clear = function() {
390
+ this.__data__ = ue ? ue(null) : {}, this.size = 0;
391
+ }, Q.prototype.delete = function(e) {
392
+ var t = this.has(e) && delete this.__data__[e];
393
+ return this.size -= t ? 1 : 0, t;
394
+ }, Q.prototype.get = function(e) {
395
+ var t = this.__data__;
396
+ if (ue) {
397
+ var n = t[e];
398
+ return n === i ? void 0 : n;
399
+ }
400
+ return M.call(t, e) ? t[e] : void 0;
401
+ }, Q.prototype.has = function(e) {
402
+ var t = this.__data__;
403
+ return ue ? t[e] !== void 0 : M.call(t, e);
404
+ }, Q.prototype.set = function(e, t) {
405
+ var n = this.__data__;
406
+ return this.size += this.has(e) ? 0 : 1, n[e] = ue && t === void 0 ? i : t, this;
407
+ }, P.prototype.clear = function() {
408
+ this.__data__ = [], this.size = 0;
409
+ }, P.prototype.delete = function(e) {
410
+ var t = this.__data__, n = we(t, e);
411
+ return !(n < 0) && (n == t.length - 1 ? t.pop() : fr.call(t, n, 1), --this.size, !0);
412
+ }, P.prototype.get = function(e) {
413
+ var t = this.__data__, n = we(t, e);
414
+ return n < 0 ? void 0 : t[n][1];
415
+ }, P.prototype.has = function(e) {
416
+ return we(this.__data__, e) > -1;
417
+ }, P.prototype.set = function(e, t) {
418
+ var n = this.__data__, s = we(n, e);
419
+ return s < 0 ? (++this.size, n.push([e, t])) : n[s][1] = t, this;
420
+ }, X.prototype.clear = function() {
421
+ this.size = 0, this.__data__ = { hash: new Q(), map: new (le || P)(), string: new Q() };
422
+ }, X.prototype.delete = function(e) {
423
+ var t = Ce(this, e).delete(e);
424
+ return this.size -= t ? 1 : 0, t;
425
+ }, X.prototype.get = function(e) {
426
+ return Ce(this, e).get(e);
427
+ }, X.prototype.has = function(e) {
428
+ return Ce(this, e).has(e);
429
+ }, X.prototype.set = function(e, t) {
430
+ var n = Ce(this, e), s = n.size;
431
+ return n.set(e, t), this.size += n.size == s ? 0 : 1, this;
432
+ }, je.prototype.add = je.prototype.push = function(e) {
433
+ return this.__data__.set(e, i), this;
434
+ }, je.prototype.has = function(e) {
435
+ return this.__data__.has(e);
436
+ }, H.prototype.clear = function() {
437
+ this.__data__ = new P(), this.size = 0;
438
+ }, H.prototype.delete = function(e) {
439
+ var t = this.__data__, n = t.delete(e);
440
+ return this.size = t.size, n;
441
+ }, H.prototype.get = function(e) {
442
+ return this.__data__.get(e);
443
+ }, H.prototype.has = function(e) {
444
+ return this.__data__.has(e);
445
+ }, H.prototype.set = function(e, t) {
446
+ var n = this.__data__;
447
+ if (n instanceof P) {
448
+ var s = n.__data__;
449
+ if (!le || s.length < 199)
450
+ return s.push([e, t]), this.size = ++n.size, this;
451
+ n = this.__data__ = new X(s);
452
+ }
453
+ return n.set(e, t), this.size = n.size, this;
454
+ };
455
+ var wr = Ct ? function(e) {
456
+ return e == null ? [] : (e = Object(e), function(t, n) {
457
+ for (var s = -1, v = t == null ? 0 : t.length, d = 0, y = []; ++s < v; ) {
458
+ var _ = t[s];
459
+ n(_, s, t) && (y[d++] = _);
460
+ }
461
+ return y;
462
+ }(Ct(e), function(t) {
463
+ return wt.call(e, t);
464
+ }));
465
+ } : function() {
466
+ return [];
467
+ }, U = de;
468
+ function Cr(e, t) {
469
+ return !!(t = t ?? l) && (typeof e == "number" || ar.test(e)) && e > -1 && e % 1 == 0 && e < t;
470
+ }
471
+ function Y(e) {
472
+ if (e != null) {
473
+ try {
474
+ return yt.call(e);
475
+ } catch {
476
+ }
477
+ try {
478
+ return e + "";
479
+ } catch {
480
+ }
481
+ }
482
+ return "";
483
+ }
484
+ function zt(e, t) {
485
+ return e === t || e != e && t != t;
486
+ }
487
+ (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) {
488
+ var t = de(e), n = t == O ? e.constructor : void 0, s = n ? Y(n) : "";
489
+ if (s)
490
+ switch (s) {
491
+ case mr:
492
+ return ge;
493
+ case br:
494
+ return z;
495
+ case vr:
496
+ return J;
497
+ case yr:
498
+ return q;
499
+ case gr:
500
+ return ce;
501
+ }
502
+ return t;
503
+ });
504
+ var xr = Nt(function() {
505
+ return arguments;
506
+ }()) ? Nt : function(e) {
507
+ return fe(e) && M.call(e, "callee") && !wt.call(e, "callee");
508
+ }, xe = Array.isArray, Ze = pr || function() {
509
+ return !1;
510
+ };
511
+ function Ot(e) {
512
+ if (!Rt(e))
513
+ return !1;
514
+ var t = de(e);
515
+ return t == I || t == F || t == k || t == te;
516
+ }
517
+ function At(e) {
518
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= l;
519
+ }
520
+ function Rt(e) {
521
+ var t = typeof e;
522
+ return e != null && (t == "object" || t == "function");
523
+ }
524
+ function fe(e) {
525
+ return e != null && typeof e == "object";
526
+ }
527
+ var Mt = ht ? function(e) {
528
+ return function(t) {
529
+ return e(t);
530
+ };
531
+ }(ht) : function(e) {
532
+ return fe(e) && At(e.length) && !!b[de(e)];
533
+ };
534
+ function Nr(e) {
535
+ return (t = e) != null && At(t.length) && !Ot(t) ? _r(e) : jr(e);
536
+ var t;
537
+ }
538
+ r.exports = function(e, t) {
539
+ return Et(e, t);
540
+ };
541
+ })(Xe, Xe.exports);
542
+ const Jr = Wr(Xe.exports);
543
+ function Kr(r, o) {
544
+ const { current: i } = Pe(r === void 0 ? o : r), [a, c] = Dt(i), l = function() {
545
+ const f = Pe(!1), k = Le(() => f.current, []);
546
+ return Te(() => (f.current = !0, () => {
547
+ f.current = !1;
548
+ }), []), k;
549
+ }();
550
+ $t(() => {
551
+ l() && r != null && c(r);
552
+ }, [r, c, l]);
553
+ const u = Le((f, k) => {
554
+ (r === void 0 || k) && !Jr(f, a) && c(f);
555
+ }, [r, c, a]);
556
+ return [a, u, r !== void 0, i];
557
+ }
558
+ const Qr = et(["flex", "gap-lg"], { variants: { orientation: { vertical: ["flex-col"], horizontal: [] } } }), Xr = N(({ name: r, value: o, defaultValue: i, className: a, intent: c, orientation: l = "vertical", onCheckedChange: u, children: f, ...k }, C) => {
559
+ const [g, R] = Kr(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) => {
560
+ const ve = g || [], ye = q ? [...ve, D] : ve.filter((ce) => ce !== D);
561
+ R(ye), F.current && F.current(ye);
562
+ } }), [z, te, g, c, O, V, J, R]);
563
+ return Te(() => {
564
+ F.current = u;
565
+ }, [u]), h.createElement(Qt.Provider, { value: re }, h.createElement("div", { ref: C, className: Qr({ className: a, orientation: l }), role: "group", "aria-labelledby": W, "aria-describedby": V, ...k }, f));
566
+ });
567
+ Xr.displayName = "CheckboxGroup";
33
568
  export {
34
- V as Checkbox
569
+ Zr as Checkbox,
570
+ Xr as CheckboxGroup
35
571
  };
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.1",
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,10 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@radix-ui/react-checkbox": "1.0.3",
16
- "@radix-ui/react-label": "2.0.1",
16
+ "@spark-ui/icon": "^1.7.2",
17
17
  "@spark-ui/icons": "^1.11.0",
18
18
  "@spark-ui/internal-utils": "^1.6.0",
19
+ "@spark-ui/label": "^1.2.0",
19
20
  "@spark-ui/use-merge-refs": "^0.3.3",
20
21
  "class-variance-authority": "0.5.2"
21
22
  },
@@ -34,5 +35,5 @@
34
35
  },
35
36
  "homepage": "https://sparkui.vercel.app",
36
37
  "license": "MIT",
37
- "gitHead": "8adc6600491da246574c20a992638d0a682d26a3"
38
+ "gitHead": "80b1ed13e4c0818e63f038d59a53341e746278bb"
38
39
  }