@spark-ui/components 16.2.2 → 16.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Switch as BaseSwitch } from '@base-ui/react/switch';
|
|
1
2
|
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
3
|
import { StylesProps } from './SwitchInput.styles';
|
|
3
|
-
export interface SwitchInputProps extends StylesProps, Omit<ComponentPropsWithRef<
|
|
4
|
+
export interface SwitchInputProps extends StylesProps, Omit<ComponentPropsWithRef<typeof BaseSwitch.Root>, 'value' | 'render' | 'onCheckedChange'> {
|
|
4
5
|
/**
|
|
5
6
|
* The state of the switch when it is initially rendered. Use when you do not need to control its state.
|
|
6
7
|
*/
|
|
@@ -9,9 +10,6 @@ export interface SwitchInputProps extends StylesProps, Omit<ComponentPropsWithRe
|
|
|
9
10
|
* The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.
|
|
10
11
|
*/
|
|
11
12
|
checked?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* When true, prevents the user from interacting with the switch.
|
|
14
|
-
*/
|
|
15
13
|
/**
|
|
16
14
|
* Event handler called when the state of the switch changes.
|
|
17
15
|
*/
|
|
@@ -44,8 +42,12 @@ export interface SwitchInputProps extends StylesProps, Omit<ComponentPropsWithRe
|
|
|
44
42
|
* When true, the label will be placed on the left side of the Switch
|
|
45
43
|
*/
|
|
46
44
|
reverse?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
|
47
|
+
*/
|
|
48
|
+
asChild?: boolean;
|
|
47
49
|
}
|
|
48
50
|
export declare const SwitchInput: {
|
|
49
|
-
({ checked, checkedIcon, defaultChecked, intent: intentProp, uncheckedIcon, size,
|
|
51
|
+
({ checked, checkedIcon, defaultChecked, intent: intentProp, uncheckedIcon, size, onCheckedChange, className, required, ref, asChild, ...rest }: SwitchInputProps): import("react/jsx-runtime").JSX.Element;
|
|
50
52
|
displayName: string;
|
|
51
53
|
};
|
package/dist/switch/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("@spark-ui/components/form-field"),c=require("class-variance-authority"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("@spark-ui/components/form-field"),c=require("class-variance-authority"),w=require("react"),k=require("@base-ui/react/switch"),L=require("@spark-ui/hooks/use-combined-state"),P=require("@spark-ui/icons/Check"),T=require("@spark-ui/icons/Close"),_=require("../useRenderSlot-DATwjgpo.js"),S=require("../Slot-DQ8z2zsy.js"),a=require("@spark-ui/internal-utils"),A=require("../label/index.js"),B=c.cva(a.tw(["relative shrink-0 self-baseline","cursor-pointer","rounded-full border-transparent","hover:ring-4","transition-colors duration-200 ease-in-out","disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3","focus-visible:u-outline","data-unchecked:bg-on-surface/dim-3","u-shadow-border-transition","overflow-x-hidden"]),{variants:{size:a.makeVariants({sm:a.tw(["h-sz-24","w-sz-40","border-md"]),md:a.tw(["h-sz-32","w-sz-56","border-[4px]"])}),intent:a.makeVariants({main:["[&[data-checked]]:bg-main","hover:ring-main-container","text-main"],support:["[&[data-checked]]:bg-support","hover:ring-support-container","text-support"],accent:["[&[data-checked]]:bg-accent","hover:ring-accent-container","text-accent"],basic:["[&[data-checked]]:bg-basic","hover:ring-basic-container","text-basic"],success:["[&[data-checked]]:bg-success","hover:ring-success-container","text-success"],alert:["[&[data-checked]]:bg-alert","hover:ring-alert-container","text-alert"],error:["[&[data-checked]]:bg-error","hover:ring-error-container","text-error"],info:["[&[data-checked]]:bg-info","hover:ring-info-container","text-info"],neutral:["[&[data-checked]]:bg-neutral","hover:ring-neutral-container","text-neutral"]})},defaultVariants:{intent:"basic",size:"sm"}}),E=c.cva(["pointer-events-none absolute inset-0 flex items-center","transition-all duration-200 ease-in-out"],{variants:{checked:{true:"translate-x-full",false:"translate-x-0"}}}),G=c.cva(["absolute left-0 top-0 flex items-center justify-center","bg-surface","rounded-full","ring-0","transition-all duration-200 ease-in-out"],{variants:{size:a.makeVariants({sm:["h-sz-20","w-sz-20"],md:["h-sz-24","w-sz-24"]}),checked:{true:"-translate-x-full",false:"translate-x-0 text-on-surface/dim-2"}},defaultVariants:{size:"sm",checked:!1}}),j=c.cva(["transition-opacity duration-200"],{variants:{size:a.makeVariants({sm:["h-sz-10 w-sz-10"],md:["h-sz-12 w-sz-12"]})},defaultVariants:{size:"sm"}}),z=({checked:n,checkedIcon:t=e.jsx(P.Check,{}),defaultChecked:r,intent:b,uncheckedIcon:o=e.jsx(T.Close,{}),size:i="md",onCheckedChange:p,className:x,required:l,ref:d,asChild:f=!1,...u})=>{const[s,h]=L.useCombinedState(n,r),{name:g,description:I,state:F,isRequired:N,isInvalid:V}=y.useFormFieldControl(),R=F??b,D=_.useRenderSlot(f,"span"),v=!!(l||N),$=m=>{h(m),p?.(m)};return e.jsx(k.Switch.Root,{"data-spark-component":"switch-input",ref:d,render:D,className:B({intent:R,size:i,className:x}),checked:n,defaultChecked:r,onCheckedChange:m=>$(m),name:g,required:v,"aria-required":v?!0:void 0,"aria-invalid":V,"aria-describedby":I,...u,children:e.jsx("span",{className:E({checked:s}),children:e.jsxs(k.Switch.Thumb,{className:G({size:i,checked:s}),children:[s&&t&&e.jsx(S.Slot,{className:j({size:i}),children:t}),!s&&o&&e.jsx(S.Slot,{className:j({size:i}),children:o})]})})})};z.displayName="SwitchInput";const M=c.cva("default:text-on-surface",{variants:{disabled:{true:["text-neutral/dim-2","cursor-not-allowed"],false:["cursor-pointer"]}},defaultVariants:{disabled:!1}}),O=({className:n,disabled:t,...r})=>e.jsx(A.Label,{"data-spark-component":"switch-label",className:M({disabled:t,className:n}),...r}),q=":switch",C=({size:n="md",children:t,className:r,id:b,disabled:o,reverse:i=!1,ref:p,...x})=>{const l=y.useFormFieldControl(),d=`${q}-label-${w.useId()}`,f=`${q}-input-${w.useId()}`,u=l.id||b||f,s=t&&e.jsx(O,{disabled:o,htmlFor:u,id:d,children:t}),h=e.jsx(z,{ref:p,size:n,id:u,disabled:o,"aria-labelledby":t?d:l.labelId,...x}),g=i?e.jsxs(e.Fragment,{children:[s,h]}):e.jsxs(e.Fragment,{children:[h,s]});return e.jsx("div",{"data-spark-component":"switch",className:c.cx("gap-md text-body-1 flex items-center",r),children:g})};C.displayName="Switch";exports.Switch=C;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/switch/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-[state=unchecked]:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'basic', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['data-[state=checked]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: [\n 'data-[state=checked]:bg-support',\n 'hover:ring-support-container',\n 'text-support',\n ],\n accent: ['data-[state=checked]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n basic: ['data-[state=checked]:bg-basic', 'hover:ring-basic-container', 'text-basic'],\n success: [\n 'data-[state=checked]:bg-success',\n 'hover:ring-success-container',\n 'text-success',\n ],\n alert: ['data-[state=checked]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['data-[state=checked]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['data-[state=checked]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: [\n 'data-[state=checked]:bg-neutral',\n 'hover:ring-neutral-container',\n 'text-neutral',\n ],\n }),\n },\n defaultVariants: {\n intent: 'basic',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { Switch as RadixSwitch } from 'radix-ui'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends StylesProps,\n Omit<ComponentPropsWithRef<'button'>, 'value'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * When true, prevents the user from interacting with the switch.\n */\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n value = 'on',\n onCheckedChange,\n className,\n required,\n ref,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <RadixSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n className={styles({ intent, size, className })}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={handleCheckedChange}\n name={name}\n required={required || isRequired}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <RadixSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </RadixSwitch.Thumb>\n </span>\n </RadixSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"names":["styles","cva","tw","makeVariants","thumbWrapperStyles","thumbStyles","thumbCheckSVGStyles","SwitchInput","checked","checkedIcon","Check","defaultChecked","intentProp","uncheckedIcon","Close","size","value","onCheckedChange","className","required","ref","rest","isChecked","setIsChecked","useCombinedState","name","description","state","isRequired","isInvalid","useFormFieldControl","intent","handleCheckedChange","updatedValue","jsx","RadixSwitch","jsxs","Slot","labelStyles","SwitchLabel","disabled","others","Label","ID_PREFIX","Switch","children","id","reverse","field","labelID","useId","innerID","fieldID","switchLabel","switchInput","content","Fragment","cx"],"mappings":"6cAGaA,EAASC,EAAAA,IACpBC,KAAG,CACD,kCACA,iBACA,kCACA,eACA,6CACA,qFACA,0BACA,6CACA,6BACA,mBAAA,CACD,EACD,CACE,SAAU,CAIR,KAAMC,EAAAA,aAAmC,CACvC,GAAID,EAAAA,GAAG,CAAC,UAAW,UAAW,WAAW,CAAC,EAC1C,GAAIA,EAAAA,GAAG,CAAC,UAAW,UAAW,cAAc,CAAC,CAA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AiB,CACf,SAAU,EAAA,CAEd,CAAC,ECMYsC,EAAc,CAAC,CAAE,UAAArB,EAAW,SAAAsB,EAAU,GAAGC,KACpDP,EAAAA,IAACQ,EAAAA,MAAA,CACC,uBAAqB,eACrB,UAAWJ,EAAY,CAAE,SAAAE,EAAU,UAAAtB,EAAW,EAC7C,GAAGuB,CAAA,CACN,ECdIE,EAAY,UAELC,EAAS,CAAC,CACrB,KAAA7B,EAAO,KACP,SAAA8B,EACA,UAAA3B,EACA,GAAA4B,EACA,SAAAN,EACA,QAAAO,EAAU,GACV,IAAA3B,EACA,GAAGC,CACL,IAAmB,CACjB,MAAM2B,EAAQlB,EAAAA,oBAAA,EAERmB,EAAU,GAAGN,CAAS,UAAUO,EAAAA,OAAO,GACvCC,EAAU,GAAGR,CAAS,UAAUO,EAAAA,OAAO,GACvCE,EAAUJ,EAAM,IAAMF,GAAMK,EAE5BE,EAAcR,GAClBX,EAAAA,IAACK,EAAA,CAAY,SAAAC,EAAoB,QAASY,EAAS,GAAIH,EACpD,SAAAJ,CAAA,CACH,EAGIS,EACJpB,EAAAA,IAAC3B,EAAA,CACC,IAAAa,EACA,KAAAL,EACA,GAAIqC,EACJ,SAAAZ,EAMA,kBAAiBK,EAAWI,EAAUD,EAAM,QAC3C,GAAG3B,CAAA,CAAA,EAIFkC,EAAUR,EACdX,EAAAA,KAAAoB,EAAAA,SAAA,CACG,SAAA,CAAAH,EACAC,CAAA,CAAA,CACH,EAEAlB,EAAAA,KAAAoB,EAAAA,SAAA,CACG,SAAA,CAAAF,EACAD,CAAA,EACH,EAGF,OACEnB,EAAAA,IAAC,MAAA,CACC,uBAAqB,SACrB,UAAWuB,EAAAA,GAAG,uCAAwCvC,CAAS,EAE9D,SAAAqC,CAAA,CAAA,CAGP,EAEAX,EAAO,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-unchecked:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'basic', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['[&[data-checked]]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: ['[&[data-checked]]:bg-support', 'hover:ring-support-container', 'text-support'],\n accent: ['[&[data-checked]]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n basic: ['[&[data-checked]]:bg-basic', 'hover:ring-basic-container', 'text-basic'],\n success: ['[&[data-checked]]:bg-success', 'hover:ring-success-container', 'text-success'],\n alert: ['[&[data-checked]]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['[&[data-checked]]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['[&[data-checked]]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: ['[&[data-checked]]:bg-neutral', 'hover:ring-neutral-container', 'text-neutral'],\n }),\n },\n defaultVariants: {\n intent: 'basic',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { Switch as BaseSwitch } from '@base-ui/react/switch'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends StylesProps,\n Omit<ComponentPropsWithRef<typeof BaseSwitch.Root>, 'value' | 'render' | 'onCheckedChange'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n const renderSlot = useRenderSlot(asChild, 'span')\n const isRequiredComputed = Boolean(required || isRequired)\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <BaseSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n render={renderSlot}\n className={styles({ intent, size, className })}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={nextChecked => handleCheckedChange(nextChecked)}\n name={name}\n required={isRequiredComputed}\n aria-required={isRequiredComputed ? true : undefined}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <BaseSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </BaseSwitch.Thumb>\n </span>\n </BaseSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"names":["styles","cva","tw","makeVariants","thumbWrapperStyles","thumbStyles","thumbCheckSVGStyles","SwitchInput","checked","checkedIcon","Check","defaultChecked","intentProp","uncheckedIcon","Close","size","onCheckedChange","className","required","ref","asChild","rest","isChecked","setIsChecked","useCombinedState","name","description","state","isRequired","isInvalid","useFormFieldControl","intent","renderSlot","useRenderSlot","isRequiredComputed","handleCheckedChange","updatedValue","jsx","BaseSwitch","nextChecked","jsxs","Slot","labelStyles","SwitchLabel","disabled","others","Label","ID_PREFIX","Switch","children","id","reverse","field","labelID","useId","innerID","fieldID","switchLabel","switchInput","content","Fragment","cx"],"mappings":"ogBAGaA,EAASC,EAAAA,IACpBC,KAAG,CACD,kCACA,iBACA,kCACA,eACA,6CACA,qFACA,0BACA,qCACA,6BACA,mBAAA,CACD,EACD,CACE,SAAU,CAIR,KAAMC,EAAAA,aAAmC,CACvC,GAAID,EAAAA,GAAG,CAAC,UAAW,UAAW,WAAW,CAAC,EAC1C,GAAIA,EAAAA,GAAG,CAAC,UAAW,UAAW,cAAc,CAAC,CAAA,CAC9C,EAID,OAAQC,EAAAA,aAGN,CACA,KAAM,CAAC,4BAA6B,4BAA6B,WAAW,EAC5E,QAAS,CAAC,+BAAgC,+BAAgC,cAAc,EACxF,OAAQ,CAAC,8BAA+B,8BAA+B,aAAa,EACpF,MAAO,CAAC,6BAA8B,6BAA8B,YAAY,EAChF,QAAS,CAAC,+BAAgC,+BAAgC,cAAc,EACxF,MAAO,CAAC,6BAA8B,6BAA8B,YAAY,EAChF,MAAO,CAAC,6BAA8B,6BAA8B,YAAY,EAChF,KAAM,CAAC,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7C,GAAG4B,CAAA,CACN,ECdIE,EAAY,UAELC,EAAS,CAAC,CACrB,KAAAjC,EAAO,KACP,SAAAkC,EACA,UAAAhC,EACA,GAAAiC,EACA,SAAAN,EACA,QAAAO,EAAU,GACV,IAAAhC,EACA,GAAGE,CACL,IAAmB,CACjB,MAAM+B,EAAQtB,EAAAA,oBAAA,EAERuB,EAAU,GAAGN,CAAS,UAAUO,EAAAA,OAAO,GACvCC,EAAU,GAAGR,CAAS,UAAUO,EAAAA,OAAO,GACvCE,EAAUJ,EAAM,IAAMF,GAAMK,EAE5BE,EAAcR,GAClBZ,EAAAA,IAACM,EAAA,CAAY,SAAAC,EAAoB,QAASY,EAAS,GAAIH,EACpD,SAAAJ,CAAA,CACH,EAGIS,EACJrB,EAAAA,IAAC9B,EAAA,CACC,IAAAY,EACA,KAAAJ,EACA,GAAIyC,EACJ,SAAAZ,EAMA,kBAAiBK,EAAWI,EAAUD,EAAM,QAC3C,GAAG/B,CAAA,CAAA,EAIFsC,EAAUR,EACdX,EAAAA,KAAAoB,EAAAA,SAAA,CACG,SAAA,CAAAH,EACAC,CAAA,CAAA,CACH,EAEAlB,EAAAA,KAAAoB,EAAAA,SAAA,CACG,SAAA,CAAAF,EACAD,CAAA,EACH,EAGF,OACEpB,EAAAA,IAAC,MAAA,CACC,uBAAqB,SACrB,UAAWwB,EAAAA,GAAG,uCAAwC5C,CAAS,EAE9D,SAAA0C,CAAA,CAAA,CAGP,EAEAX,EAAO,YAAc"}
|
package/dist/switch/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useFormFieldControl as
|
|
3
|
-
import { cva as o, cx as
|
|
1
|
+
import { jsx as e, jsxs as w, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useFormFieldControl as F } from "@spark-ui/components/form-field";
|
|
3
|
+
import { cva as o, cx as E } from "class-variance-authority";
|
|
4
4
|
import { useId as z } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { Switch as y } from "@base-ui/react/switch";
|
|
6
|
+
import { useCombinedState as G } from "@spark-ui/hooks/use-combined-state";
|
|
7
|
+
import { Check as P } from "@spark-ui/icons/Check";
|
|
8
|
+
import { Close as T } from "@spark-ui/icons/Close";
|
|
9
|
+
import { u as W } from "../useRenderSlot-Bta2kdp4.mjs";
|
|
10
|
+
import { S as C } from "../Slot-DLY1rJrG.mjs";
|
|
11
|
+
import { tw as v, makeVariants as h } from "@spark-ui/internal-utils";
|
|
12
|
+
import { Label as X } from "../label/index.mjs";
|
|
13
|
+
const _ = o(
|
|
14
|
+
v([
|
|
14
15
|
"relative shrink-0 self-baseline",
|
|
15
16
|
"cursor-pointer",
|
|
16
17
|
"rounded-full border-transparent",
|
|
@@ -18,7 +19,7 @@ const W = o(
|
|
|
18
19
|
"transition-colors duration-200 ease-in-out",
|
|
19
20
|
"disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3",
|
|
20
21
|
"focus-visible:u-outline",
|
|
21
|
-
"data-
|
|
22
|
+
"data-unchecked:bg-on-surface/dim-3",
|
|
22
23
|
"u-shadow-border-transition",
|
|
23
24
|
"overflow-x-hidden"
|
|
24
25
|
]),
|
|
@@ -28,34 +29,22 @@ const W = o(
|
|
|
28
29
|
* Size of the switch input.
|
|
29
30
|
*/
|
|
30
31
|
size: h({
|
|
31
|
-
sm:
|
|
32
|
-
md:
|
|
32
|
+
sm: v(["h-sz-24", "w-sz-40", "border-md"]),
|
|
33
|
+
md: v(["h-sz-32", "w-sz-56", "border-[4px]"])
|
|
33
34
|
}),
|
|
34
35
|
/**
|
|
35
36
|
* Color scheme of the switch input.
|
|
36
37
|
*/
|
|
37
38
|
intent: h({
|
|
38
|
-
main: ["data-
|
|
39
|
-
support: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"data-[state=checked]:bg-success",
|
|
48
|
-
"hover:ring-success-container",
|
|
49
|
-
"text-success"
|
|
50
|
-
],
|
|
51
|
-
alert: ["data-[state=checked]:bg-alert", "hover:ring-alert-container", "text-alert"],
|
|
52
|
-
error: ["data-[state=checked]:bg-error", "hover:ring-error-container", "text-error"],
|
|
53
|
-
info: ["data-[state=checked]:bg-info", "hover:ring-info-container", "text-info"],
|
|
54
|
-
neutral: [
|
|
55
|
-
"data-[state=checked]:bg-neutral",
|
|
56
|
-
"hover:ring-neutral-container",
|
|
57
|
-
"text-neutral"
|
|
58
|
-
]
|
|
39
|
+
main: ["[&[data-checked]]:bg-main", "hover:ring-main-container", "text-main"],
|
|
40
|
+
support: ["[&[data-checked]]:bg-support", "hover:ring-support-container", "text-support"],
|
|
41
|
+
accent: ["[&[data-checked]]:bg-accent", "hover:ring-accent-container", "text-accent"],
|
|
42
|
+
basic: ["[&[data-checked]]:bg-basic", "hover:ring-basic-container", "text-basic"],
|
|
43
|
+
success: ["[&[data-checked]]:bg-success", "hover:ring-success-container", "text-success"],
|
|
44
|
+
alert: ["[&[data-checked]]:bg-alert", "hover:ring-alert-container", "text-alert"],
|
|
45
|
+
error: ["[&[data-checked]]:bg-error", "hover:ring-error-container", "text-error"],
|
|
46
|
+
info: ["[&[data-checked]]:bg-info", "hover:ring-info-container", "text-info"],
|
|
47
|
+
neutral: ["[&[data-checked]]:bg-neutral", "hover:ring-neutral-container", "text-neutral"]
|
|
59
48
|
})
|
|
60
49
|
},
|
|
61
50
|
defaultVariants: {
|
|
@@ -63,7 +52,7 @@ const W = o(
|
|
|
63
52
|
size: "sm"
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
),
|
|
55
|
+
), A = o(
|
|
67
56
|
[
|
|
68
57
|
"pointer-events-none absolute inset-0 flex items-center",
|
|
69
58
|
"transition-all duration-200 ease-in-out"
|
|
@@ -76,7 +65,7 @@ const W = o(
|
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
),
|
|
68
|
+
), H = o(
|
|
80
69
|
[
|
|
81
70
|
"absolute left-0 top-0 flex items-center justify-center",
|
|
82
71
|
"bg-surface",
|
|
@@ -100,7 +89,7 @@ const W = o(
|
|
|
100
89
|
checked: !1
|
|
101
90
|
}
|
|
102
91
|
}
|
|
103
|
-
),
|
|
92
|
+
), I = o(["transition-opacity duration-200"], {
|
|
104
93
|
variants: {
|
|
105
94
|
size: h({
|
|
106
95
|
sm: ["h-sz-10 w-sz-10"],
|
|
@@ -110,47 +99,48 @@ const W = o(
|
|
|
110
99
|
defaultVariants: {
|
|
111
100
|
size: "sm"
|
|
112
101
|
}
|
|
113
|
-
}),
|
|
114
|
-
checked:
|
|
115
|
-
checkedIcon: t = /* @__PURE__ */ e(
|
|
116
|
-
defaultChecked:
|
|
117
|
-
intent:
|
|
118
|
-
uncheckedIcon: i = /* @__PURE__ */ e(
|
|
102
|
+
}), R = ({
|
|
103
|
+
checked: r,
|
|
104
|
+
checkedIcon: t = /* @__PURE__ */ e(P, {}),
|
|
105
|
+
defaultChecked: s,
|
|
106
|
+
intent: p,
|
|
107
|
+
uncheckedIcon: i = /* @__PURE__ */ e(T, {}),
|
|
119
108
|
size: n = "md",
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
onCheckedChange: b,
|
|
110
|
+
className: f,
|
|
111
|
+
required: c,
|
|
112
|
+
ref: l,
|
|
113
|
+
asChild: g = !1,
|
|
125
114
|
...d
|
|
126
115
|
}) => {
|
|
127
|
-
const [a, m] =
|
|
128
|
-
m(
|
|
116
|
+
const [a, m] = G(r, s), { name: x, description: V, state: $, isRequired: q, isInvalid: D } = F(), j = $ ?? p, L = W(g, "span"), k = !!(c || q), B = (u) => {
|
|
117
|
+
m(u), b?.(u);
|
|
129
118
|
};
|
|
130
119
|
return /* @__PURE__ */ e(
|
|
131
|
-
|
|
120
|
+
y.Root,
|
|
132
121
|
{
|
|
133
122
|
"data-spark-component": "switch-input",
|
|
134
|
-
ref:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
checked:
|
|
138
|
-
defaultChecked:
|
|
139
|
-
onCheckedChange:
|
|
140
|
-
name:
|
|
141
|
-
required:
|
|
142
|
-
"aria-
|
|
123
|
+
ref: l,
|
|
124
|
+
render: L,
|
|
125
|
+
className: _({ intent: j, size: n, className: f }),
|
|
126
|
+
checked: r,
|
|
127
|
+
defaultChecked: s,
|
|
128
|
+
onCheckedChange: (u) => B(u),
|
|
129
|
+
name: x,
|
|
130
|
+
required: k,
|
|
131
|
+
"aria-required": k ? !0 : void 0,
|
|
132
|
+
"aria-invalid": D,
|
|
143
133
|
"aria-describedby": V,
|
|
144
134
|
...d,
|
|
145
|
-
children: /* @__PURE__ */ e("span", { className:
|
|
146
|
-
a && t && /* @__PURE__ */ e(
|
|
147
|
-
!a && i && /* @__PURE__ */ e(
|
|
135
|
+
children: /* @__PURE__ */ e("span", { className: A({ checked: a }), children: /* @__PURE__ */ w(y.Thumb, { className: H({ size: n, checked: a }), children: [
|
|
136
|
+
a && t && /* @__PURE__ */ e(C, { className: I({ size: n }), children: t }),
|
|
137
|
+
!a && i && /* @__PURE__ */ e(C, { className: I({ size: n }), children: i })
|
|
148
138
|
] }) })
|
|
149
139
|
}
|
|
150
140
|
);
|
|
151
141
|
};
|
|
152
|
-
|
|
153
|
-
const
|
|
142
|
+
R.displayName = "SwitchInput";
|
|
143
|
+
const J = o("default:text-on-surface", {
|
|
154
144
|
variants: {
|
|
155
145
|
disabled: {
|
|
156
146
|
true: ["text-neutral/dim-2", "cursor-not-allowed"],
|
|
@@ -160,37 +150,37 @@ const A = o("default:text-on-surface", {
|
|
|
160
150
|
defaultVariants: {
|
|
161
151
|
disabled: !1
|
|
162
152
|
}
|
|
163
|
-
}),
|
|
164
|
-
|
|
153
|
+
}), K = ({ className: r, disabled: t, ...s }) => /* @__PURE__ */ e(
|
|
154
|
+
X,
|
|
165
155
|
{
|
|
166
156
|
"data-spark-component": "switch-label",
|
|
167
|
-
className:
|
|
168
|
-
...
|
|
157
|
+
className: J({ disabled: t, className: r }),
|
|
158
|
+
...s
|
|
169
159
|
}
|
|
170
|
-
),
|
|
171
|
-
size:
|
|
160
|
+
), N = ":switch", M = ({
|
|
161
|
+
size: r = "md",
|
|
172
162
|
children: t,
|
|
173
|
-
className:
|
|
174
|
-
id:
|
|
163
|
+
className: s,
|
|
164
|
+
id: p,
|
|
175
165
|
disabled: i,
|
|
176
166
|
reverse: n = !1,
|
|
177
167
|
ref: b,
|
|
178
|
-
...
|
|
168
|
+
...f
|
|
179
169
|
}) => {
|
|
180
|
-
const c =
|
|
181
|
-
|
|
170
|
+
const c = F(), l = `${N}-label-${z()}`, g = `${N}-input-${z()}`, d = c.id || p || g, a = t && /* @__PURE__ */ e(K, { disabled: i, htmlFor: d, id: l, children: t }), m = /* @__PURE__ */ e(
|
|
171
|
+
R,
|
|
182
172
|
{
|
|
183
173
|
ref: b,
|
|
184
|
-
size:
|
|
174
|
+
size: r,
|
|
185
175
|
id: d,
|
|
186
176
|
disabled: i,
|
|
187
177
|
"aria-labelledby": t ? l : c.labelId,
|
|
188
|
-
...
|
|
178
|
+
...f
|
|
189
179
|
}
|
|
190
|
-
),
|
|
180
|
+
), x = n ? /* @__PURE__ */ w(S, { children: [
|
|
191
181
|
a,
|
|
192
182
|
m
|
|
193
|
-
] }) : /* @__PURE__ */
|
|
183
|
+
] }) : /* @__PURE__ */ w(S, { children: [
|
|
194
184
|
m,
|
|
195
185
|
a
|
|
196
186
|
] });
|
|
@@ -198,13 +188,13 @@ const A = o("default:text-on-surface", {
|
|
|
198
188
|
"div",
|
|
199
189
|
{
|
|
200
190
|
"data-spark-component": "switch",
|
|
201
|
-
className:
|
|
202
|
-
children:
|
|
191
|
+
className: E("gap-md text-body-1 flex items-center", s),
|
|
192
|
+
children: x
|
|
203
193
|
}
|
|
204
194
|
);
|
|
205
195
|
};
|
|
206
|
-
|
|
196
|
+
M.displayName = "Switch";
|
|
207
197
|
export {
|
|
208
|
-
|
|
198
|
+
M as Switch
|
|
209
199
|
};
|
|
210
200
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-[state=unchecked]:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'basic', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['data-[state=checked]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: [\n 'data-[state=checked]:bg-support',\n 'hover:ring-support-container',\n 'text-support',\n ],\n accent: ['data-[state=checked]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n basic: ['data-[state=checked]:bg-basic', 'hover:ring-basic-container', 'text-basic'],\n success: [\n 'data-[state=checked]:bg-success',\n 'hover:ring-success-container',\n 'text-success',\n ],\n alert: ['data-[state=checked]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['data-[state=checked]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['data-[state=checked]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: [\n 'data-[state=checked]:bg-neutral',\n 'hover:ring-neutral-container',\n 'text-neutral',\n ],\n }),\n },\n defaultVariants: {\n intent: 'basic',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { Switch as RadixSwitch } from 'radix-ui'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends StylesProps,\n Omit<ComponentPropsWithRef<'button'>, 'value'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * When true, prevents the user from interacting with the switch.\n */\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n value = 'on',\n onCheckedChange,\n className,\n required,\n ref,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <RadixSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n className={styles({ intent, size, className })}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={handleCheckedChange}\n name={name}\n required={required || isRequired}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <RadixSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </RadixSwitch.Thumb>\n </span>\n </RadixSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"names":["styles","cva","tw","makeVariants","thumbWrapperStyles","thumbStyles","thumbCheckSVGStyles","SwitchInput","checked","checkedIcon","Check","defaultChecked","intentProp","uncheckedIcon","Close","size","value","onCheckedChange","className","required","ref","rest","isChecked","setIsChecked","useCombinedState","name","description","state","isRequired","isInvalid","useFormFieldControl","intent","handleCheckedChange","updatedValue","jsx","RadixSwitch","jsxs","Slot","labelStyles","SwitchLabel","disabled","others","Label","ID_PREFIX","Switch","children","id","reverse","field","labelID","useId","innerID","fieldID","switchLabel","switchInput","content","Fragment","cx"],"mappings":";;;;;;;;;;;AAGO,MAAMA,IAASC;AAAA,EACpBC,EAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAAA,EACD;AAAA,IACE,UAAU;AAAA;AAAA;AAAA;AAAA,MAIR,MAAMC,EAAmC;AAAA,QACvC,IAAID,EAAG,CAAC,WAAW,WAAW,WAAW,CAAC;AAAA,QAC1C,IAAIA,EAAG,CAAC,WAAW,WAAW,cAAc,CAAC;AAAA,MAAA,CAC9C;AAAA;AAAA;AAAA;AAAA,MAID,QAAQC,EAGN;AAAA,QACA,MAAM,CAAC,gCAAgC,6BAA6B,WAAW;AAAA,QAC/E,SAAS;AAAA,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IAAC3B;AAAA,IAAA;AAAA,MACC,KAAAa;AAAA,MACA,MAAAL;AAAA,MACA,IAAIqC;AAAA,MACJ,UAAAZ;AAAA,MAMA,mBAAiBK,IAAWI,IAAUD,EAAM;AAAA,MAC3C,GAAG3B;AAAA,IAAA;AAAA,EAAA,GAIFkC,IAAUR,IACd,gBAAAX,EAAAoB,GAAA,EACG,UAAA;AAAA,IAAAH;AAAA,IACAC;AAAA,EAAA,EAAA,CACH,IAEA,gBAAAlB,EAAAoB,GAAA,EACG,UAAA;AAAA,IAAAF;AAAA,IACAD;AAAA,EAAA,GACH;AAGF,SACE,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,wBAAqB;AAAA,MACrB,WAAWuB,EAAG,wCAAwCvC,CAAS;AAAA,MAE9D,UAAAqC;AAAA,IAAA;AAAA,EAAA;AAGP;AAEAX,EAAO,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-unchecked:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'basic', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['[&[data-checked]]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: ['[&[data-checked]]:bg-support', 'hover:ring-support-container', 'text-support'],\n accent: ['[&[data-checked]]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n basic: ['[&[data-checked]]:bg-basic', 'hover:ring-basic-container', 'text-basic'],\n success: ['[&[data-checked]]:bg-success', 'hover:ring-success-container', 'text-success'],\n alert: ['[&[data-checked]]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['[&[data-checked]]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['[&[data-checked]]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: ['[&[data-checked]]:bg-neutral', 'hover:ring-neutral-container', 'text-neutral'],\n }),\n },\n defaultVariants: {\n intent: 'basic',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { Switch as BaseSwitch } from '@base-ui/react/switch'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends StylesProps,\n Omit<ComponentPropsWithRef<typeof BaseSwitch.Root>, 'value' | 'render' | 'onCheckedChange'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n const renderSlot = useRenderSlot(asChild, 'span')\n const isRequiredComputed = Boolean(required || isRequired)\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <BaseSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n render={renderSlot}\n className={styles({ intent, size, className })}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={nextChecked => handleCheckedChange(nextChecked)}\n name={name}\n required={isRequiredComputed}\n aria-required={isRequiredComputed ? true : undefined}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <BaseSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </BaseSwitch.Thumb>\n </span>\n </BaseSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"names":["styles","cva","tw","makeVariants","thumbWrapperStyles","thumbStyles","thumbCheckSVGStyles","SwitchInput","checked","checkedIcon","Check","defaultChecked","intentProp","uncheckedIcon","Close","size","onCheckedChange","className","required","ref","asChild","rest","isChecked","setIsChecked","useCombinedState","name","description","state","isRequired","isInvalid","useFormFieldControl","intent","renderSlot","useRenderSlot","isRequiredComputed","handleCheckedChange","updatedValue","jsx","BaseSwitch","nextChecked","jsxs","Slot","labelStyles","SwitchLabel","disabled","others","Label","ID_PREFIX","Switch","children","id","reverse","field","labelID","useId","innerID","fieldID","switchLabel","switchInput","content","Fragment","cx"],"mappings":";;;;;;;;;;;;AAGO,MAAMA,IAASC;AAAA,EACpBC,EAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAAA,EACD;AAAA,IACE,UAAU;AAAA;AAAA;AAAA;AAAA,MAIR,MAAMC,EAAmC;AAAA,QACvC,IAAID,EAAG,CAAC,WAAW,WAAW,WAAW,CAAC;AAAA,QAC1C,IAAIA,EAAG,CAAC,WAAW,WAAW,cAAc,CAAC;AAAA,MAAA,CAC9C;AAAA;AAAA;AAAA;AAAA,MAID,QAAQC,EAGN;AAAA,QACA,MAAM,CAAC,6BAA6B,6BAA6B,WAAW;AAAA,QAC5E,SAAS,CAAC,gCAAgC,gCAAgC,cAAc;AAAA,QACxF,QAAQ,CAAC,+BAA+B,+BAA+B,aAAa;AAAA,QACpF,OAAO,CAAC,8BAA8B,8BAA8B,YAAY;AAAA,QAChF,SAAS,CAAC,gCAAgC,gCAAgC,cAAc;AAAA,QACxF,OAAO,CAAC,8BAA8B,8BAA8B,YAAY;AAAA,QAChF,OAAO,CAAC,8BAA8B,8BAA8B,YAAY;AAAA,QAChF,MAAM,CAAC,6BAA6B,6BAA6B,WAAW;AAAA,QAC5E,SAAS,CAAC,gCAAgC,gCAAgC,cAAc;AAAA,MAAA,CACzF;AAAA,IAAA;AAAA,IAEH,iBAAiB;AAAA,MACf,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ,GAIaC,IAAqBH;AAAA,EAChC;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,EACF;AAEJ,GAEaI,IAAcJ;AAAA,EACzB;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
1
|
{
|
|
2
2
|
"name": "@spark-ui/components",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Spark (Leboncoin design system) components.",
|
|
6
6
|
"exports": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@react-aria/toast": "^3.0.0-beta.18",
|
|
55
55
|
"@react-stately/numberfield": "3.9.11",
|
|
56
56
|
"@react-stately/toast": "^3.0.0-beta.7",
|
|
57
|
-
"@spark-ui/hooks": "^16.2.
|
|
58
|
-
"@spark-ui/icons": "^16.2.
|
|
59
|
-
"@spark-ui/internal-utils": "^16.2.
|
|
57
|
+
"@spark-ui/hooks": "^16.2.3",
|
|
58
|
+
"@spark-ui/icons": "^16.2.3",
|
|
59
|
+
"@spark-ui/internal-utils": "^16.2.3",
|
|
60
60
|
"@zag-js/pagination": "1.30.0",
|
|
61
61
|
"@zag-js/react": "1.30.0",
|
|
62
62
|
"class-variance-authority": "0.7.1",
|