@traefik-labs/faency 13.7.2 → 13.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.vanilla.js","names":[],"sources":["../../../components/Switch/Switch.vanilla.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\nimport { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { useFieldControl } from '@/components/Field/FieldContext';\n\nimport { switchRecipe, switchThumb } from './Switch.vanilla.css';\n\nconst switchClass = withVariantKeys(switchRecipe);\n\ntype SwitchRecipeVariants = RecipeVariantProps<typeof switchRecipe>;\n\ninterface SwitchVanillaOwnProps extends SwitchRecipeVariants, CSSProps {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n disabled?: boolean;\n required?: boolean;\n name?: string;\n value?: string;\n}\n\nexport type SwitchVanillaProps<C extends ElementType = 'button'> = PolymorphicComponentProps<\n C,\n SwitchVanillaOwnProps\n>;\n\ntype SwitchVanillaComponent = PolymorphicComponent<'button', SwitchVanillaProps<ElementType>>;\n\nconst SwitchVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'button'>(\n {\n as,\n className,\n css,\n style,\n size,\n id,\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n required,\n name,\n value,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n }: SwitchVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const mergedStyles = useInlineStyle(css, style);\n const recipeClass = switchClass({ size });\n\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n labelable: !as,\n });\n\n // With `as`, the switch is a read-only indicator of `checked`, not a control.\n if (as) {\n const Component = as as ElementType;\n const state = (checked ?? defaultChecked) ? 'checked' : 'unchecked';\n\n return (\n <Component\n {...props}\n ref={ref}\n id={control.id}\n role=\"switch\"\n aria-checked={state === 'checked'}\n aria-readonly\n aria-disabled={control.disabled}\n aria-labelledby={ariaLabelledBy ?? control.labelId}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n data-state={state}\n data-disabled={control.disabled ? '' : undefined}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n >\n <span data-state={state} className={switchThumb} />\n </Component>\n );\n }\n\n return (\n <SwitchPrimitive.Root\n {...props}\n ref={ref}\n id={control.id}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={onCheckedChange}\n disabled={control.disabled}\n required={required}\n name={name}\n value={value}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n >\n <SwitchPrimitive.Thumb className={switchThumb} />\n </SwitchPrimitive.Root>\n );\n },\n);\n\nSwitchVanillaComponentImpl.displayName = 'SwitchVanilla';\n\nexport const SwitchVanilla = SwitchVanillaComponentImpl as SwitchVanillaComponent;\n"],"mappings":";;;;;;;;;AAiBA,IAAM,cAAc,gBAAgB,YAAY;AAqBhD,IAAM,6BAA6B,YAE/B,EACE,IACA,WACA,KACA,OACA,MACA,IACA,SACA,gBACA,iBACA,UACA,UACA,MACA,OACA,oBAAoB,iBACpB,gBAAgB,aAChB,mBAAmB,gBACnB,GAAG,SAEL,QACG;CACH,MAAM,eAAe,eAAe,KAAK,KAAK;CAC9C,MAAM,cAAc,YAAY,EAAE,KAAK,CAAC;CAExC,MAAM,UAAU,gBAAgB;EAC9B;EACA;EACA,oBAAoB;EACpB,gBAAgB;EACh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