@fuf-stack/uniform 2.0.0-next.1 → 2.0.0-next.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.
Files changed (140) hide show
  1. package/dist/Checkboxes/index.d.mts +57 -37
  2. package/dist/Checkboxes/index.d.mts.map +1 -1
  3. package/dist/Checkboxes/index.mjs +19 -20
  4. package/dist/Checkboxes/index.mjs.map +1 -1
  5. package/dist/DatePicker/index.d.mts +71 -31
  6. package/dist/DatePicker/index.d.mts.map +1 -1
  7. package/dist/DatePicker/index.mjs +31 -29
  8. package/dist/DatePicker/index.mjs.map +1 -1
  9. package/dist/FieldArray/index.d.mts +8 -16
  10. package/dist/FieldArray/index.d.mts.map +1 -1
  11. package/dist/FieldArray/index.mjs +18 -32
  12. package/dist/FieldArray/index.mjs.map +1 -1
  13. package/dist/FieldCard/index.d.mts +0 -4
  14. package/dist/FieldCard/index.d.mts.map +1 -1
  15. package/dist/FieldCard/index.mjs +11 -19
  16. package/dist/FieldCard/index.mjs.map +1 -1
  17. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +3 -5
  18. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs.map → FieldCopyTestIdButton-D3_jZYJ1.mjs.map} +1 -1
  19. package/dist/{FieldDescription-C4l0HKGL.mjs → FieldDescription-X_0s1Lhu.mjs} +5 -6
  20. package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
  21. package/dist/{FieldLabel-DKzqkuY1.mjs → FieldLabel-DrNWJIVh.mjs} +15 -12
  22. package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
  23. package/dist/{FieldLayout-BLW5S-Jm.mjs → FieldLayout-DcvQU0zN.mjs} +4 -5
  24. package/dist/{FieldLayout-BLW5S-Jm.mjs.map → FieldLayout-DcvQU0zN.mjs.map} +1 -1
  25. package/dist/FieldReset/index.d.mts +420 -0
  26. package/dist/FieldReset/index.d.mts.map +1 -0
  27. package/dist/FieldReset/index.mjs +258 -0
  28. package/dist/FieldReset/index.mjs.map +1 -0
  29. package/dist/{FieldValidationError-DgkCL3cC.mjs → FieldValidationError-iAayfTEw.mjs} +3 -5
  30. package/dist/{FieldValidationError-DgkCL3cC.mjs.map → FieldValidationError-iAayfTEw.mjs.map} +1 -1
  31. package/dist/Form/index.d.mts +12 -14
  32. package/dist/Form/index.d.mts.map +1 -1
  33. package/dist/Form/index.mjs +7 -10
  34. package/dist/Form/index.mjs.map +1 -1
  35. package/dist/FormContext-BnNJYZOo.d.mts +124 -0
  36. package/dist/FormContext-BnNJYZOo.d.mts.map +1 -0
  37. package/dist/{FormContext-CHctWFAP.mjs → FormContext-PXkVlBdU.mjs} +5 -9
  38. package/dist/{FormContext-CHctWFAP.mjs.map → FormContext-PXkVlBdU.mjs.map} +1 -1
  39. package/dist/Grid/index.d.mts +0 -2
  40. package/dist/Grid/index.d.mts.map +1 -1
  41. package/dist/Grid/index.mjs +1 -1
  42. package/dist/{Grid-DfcZeuib.mjs → Grid-DBL29Kwb.mjs} +3 -5
  43. package/dist/{Grid-DfcZeuib.mjs.map → Grid-DBL29Kwb.mjs.map} +1 -1
  44. package/dist/Input/index.d.mts +167 -115
  45. package/dist/Input/index.d.mts.map +1 -1
  46. package/dist/Input/index.mjs +20 -24
  47. package/dist/Input/index.mjs.map +1 -1
  48. package/dist/RadioBoxes/index.d.mts +226 -2222
  49. package/dist/RadioBoxes/index.d.mts.map +1 -1
  50. package/dist/RadioBoxes/index.mjs +24 -28
  51. package/dist/RadioBoxes/index.mjs.map +1 -1
  52. package/dist/RadioTabs/index.d.mts +121 -66
  53. package/dist/RadioTabs/index.d.mts.map +1 -1
  54. package/dist/RadioTabs/index.mjs +16 -19
  55. package/dist/RadioTabs/index.mjs.map +1 -1
  56. package/dist/Radios/index.d.mts +140 -2056
  57. package/dist/Radios/index.d.mts.map +1 -1
  58. package/dist/Radios/index.mjs +11 -14
  59. package/dist/Radios/index.mjs.map +1 -1
  60. package/dist/Select/index.d.mts +154 -21
  61. package/dist/Select/index.d.mts.map +1 -1
  62. package/dist/Select/index.mjs +65 -49
  63. package/dist/Select/index.mjs.map +1 -1
  64. package/dist/Slider/index.d.mts +143 -77
  65. package/dist/Slider/index.d.mts.map +1 -1
  66. package/dist/Slider/index.mjs +26 -18
  67. package/dist/Slider/index.mjs.map +1 -1
  68. package/dist/SubmitButton/index.d.mts +0 -2
  69. package/dist/SubmitButton/index.d.mts.map +1 -1
  70. package/dist/SubmitButton/index.mjs +2 -4
  71. package/dist/SubmitButton/index.mjs.map +1 -1
  72. package/dist/Switch/index.d.mts +1 -1
  73. package/dist/Switch/index.mjs +16 -18
  74. package/dist/Switch/index.mjs.map +1 -1
  75. package/dist/{Switch-CvPO8IF9.d.mts → Switch-Db2dpGz7.d.mts} +115 -68
  76. package/dist/{Switch-CvPO8IF9.d.mts.map → Switch-Db2dpGz7.d.mts.map} +1 -1
  77. package/dist/SwitchBox/index.d.mts +169 -126
  78. package/dist/SwitchBox/index.d.mts.map +1 -1
  79. package/dist/SwitchBox/index.mjs +18 -18
  80. package/dist/SwitchBox/index.mjs.map +1 -1
  81. package/dist/TextArea/index.d.mts +100 -57
  82. package/dist/TextArea/index.d.mts.map +1 -1
  83. package/dist/TextArea/index.mjs +14 -16
  84. package/dist/TextArea/index.mjs.map +1 -1
  85. package/dist/Time/index.d.mts +44 -28
  86. package/dist/Time/index.d.mts.map +1 -1
  87. package/dist/Time/index.mjs +13 -17
  88. package/dist/Time/index.mjs.map +1 -1
  89. package/dist/helpers/index.d.mts +0 -6
  90. package/dist/helpers/index.d.mts.map +1 -1
  91. package/dist/helpers/index.mjs +3 -6
  92. package/dist/helpers/index.mjs.map +1 -1
  93. package/dist/hooks/useClientValidation/index.d.mts +0 -2
  94. package/dist/hooks/useClientValidation/index.d.mts.map +1 -1
  95. package/dist/hooks/useClientValidation/index.mjs +3 -5
  96. package/dist/hooks/useController/index.d.mts +0 -2
  97. package/dist/hooks/useController/index.d.mts.map +1 -1
  98. package/dist/hooks/useController/index.mjs +2 -3
  99. package/dist/hooks/useFormContext/index.d.mts +31 -52
  100. package/dist/hooks/useFormContext/index.d.mts.map +1 -1
  101. package/dist/hooks/useFormContext/index.mjs +2 -3
  102. package/dist/hooks/useInputValueDebounce/index.d.mts +0 -2
  103. package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
  104. package/dist/hooks/useInputValueDebounce/index.mjs +3 -5
  105. package/dist/hooks/useInputValueTransform/index.d.mts +1 -1
  106. package/dist/hooks/useInputValueTransform/index.mjs +2 -3
  107. package/dist/hooks/useWatchFormReset/index.d.mts +0 -2
  108. package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -1
  109. package/dist/hooks/useWatchFormReset/index.mjs +3 -5
  110. package/dist/hooks/useWatchUserChange/index.d.mts +0 -2
  111. package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
  112. package/dist/hooks/useWatchUserChange/index.mjs +3 -5
  113. package/dist/{index-BS8IoBOn.d.mts → index-cevZBrIN.d.mts} +1 -3
  114. package/dist/index-cevZBrIN.d.mts.map +1 -0
  115. package/dist/partials/FieldCopyTestIdButton/index.d.mts +0 -2
  116. package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -1
  117. package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
  118. package/dist/partials/FieldValidationError/index.d.mts +11 -13
  119. package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
  120. package/dist/partials/FieldValidationError/index.mjs +1 -1
  121. package/dist/{radioControlVariants-Cm6WufWo.mjs → radioControlVariants-BYRfaD6y.mjs} +24 -25
  122. package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
  123. package/dist/{switchVariants-BaQw2DA7.mjs → switchVariants-D16b2VaT.mjs} +4 -4
  124. package/dist/{switchVariants-BaQw2DA7.mjs.map → switchVariants-D16b2VaT.mjs.map} +1 -1
  125. package/dist/{timeVariants-B9HDfNYt.mjs → timeVariants-CtXyNKmW.mjs} +3 -3
  126. package/dist/{timeVariants-B9HDfNYt.mjs.map → timeVariants-CtXyNKmW.mjs.map} +1 -1
  127. package/dist/{useController-BCFeZbBZ.mjs → useController-JtIeurpw.mjs} +3 -4
  128. package/dist/{useController-BCFeZbBZ.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
  129. package/dist/{useFormContext-BPjJjNnM.mjs → useFormContext-piqnN2L-.mjs} +3 -4
  130. package/dist/useFormContext-piqnN2L-.mjs.map +1 -0
  131. package/dist/{useInputValueTransform-Mw8YEOXT.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -3
  132. package/dist/{useInputValueTransform-Mw8YEOXT.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
  133. package/package.json +8 -7
  134. package/dist/FieldDescription-C4l0HKGL.mjs.map +0 -1
  135. package/dist/FieldLabel-DKzqkuY1.mjs.map +0 -1
  136. package/dist/FormContext-CsFiNvuJ.d.mts +0 -19
  137. package/dist/FormContext-CsFiNvuJ.d.mts.map +0 -1
  138. package/dist/index-BS8IoBOn.d.mts.map +0 -1
  139. package/dist/radioControlVariants-Cm6WufWo.mjs.map +0 -1
  140. package/dist/useFormContext-BPjJjNnM.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/Checkboxes/checkboxesVariants.ts","../../src/Checkboxes/subcomponents/CheckboxIndicator.tsx","../../src/Checkboxes/subcomponents/CheckboxLabel.tsx","../../src/Checkboxes/subcomponents/CheckboxControl.tsx","../../src/Checkboxes/subcomponents/CheckboxesControl.tsx","../../src/Checkboxes/Checkboxes.tsx","../../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nconst checkboxColorVariants = tv({\n slots: { wrapper: '' },\n variants: {\n color: {\n danger: {\n wrapper:\n 'text-danger-foreground after:bg-danger after:text-danger-foreground',\n },\n default: {\n wrapper:\n 'text-default-foreground after:bg-default after:text-default-foreground',\n },\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n primary: {\n wrapper:\n 'text-primary-foreground after:bg-primary after:text-primary-foreground',\n },\n secondary: {\n wrapper:\n 'text-secondary-foreground after:bg-secondary after:text-secondary-foreground',\n },\n success: {\n wrapper:\n 'text-success-foreground after:bg-success after:text-success-foreground',\n },\n warning: {\n wrapper:\n 'text-warning-foreground after:bg-warning after:text-warning-foreground',\n },\n },\n },\n});\nexport const checkboxesVariants = tv({\n extend: checkboxColorVariants,\n slots: {\n /** Container for the field control and supporting text */\n base: ['group flex w-full flex-col gap-y-1.5', 'relative'],\n /** Supporting text for the field */\n description: 'text-foreground-400 text-small',\n /** Container for validation messages */\n errorMessage: ['text-tiny', 'text-danger text-small'],\n /** Container for help text and validation messages */\n helperWrapper: 'relative block p-0',\n /** Visible field label */\n label: [\n 'inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n 'relative',\n ],\n /** Clickable checkbox option */\n optionBase: [\n '',\n // option layout and pointer behavior\n 'group relative -m-2 inline-flex max-w-fit cursor-pointer select-none items-center justify-start p-2 tap-highlight-transparent',\n // disabled interaction and opacity\n 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-disabled',\n ],\n /** Checkmark inside the selection indicator */\n optionIcon: [\n '',\n // checkmark dimensions and fade transition\n 'pointer-events-none z-10 h-3 w-4 opacity-0 transition-opacity',\n // selected visibility\n 'group-data-[selected=true]:opacity-100',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Primary option text */\n optionLabel: '',\n /** Additional text below the option label */\n optionLabelSubline: 'text-foreground-400 !text-small',\n /** Outline and fill around the checkmark */\n optionWrapper: [\n '',\n // checkbox dimensions and layout\n 'relative me-2 inline-flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[calc(var(--pixel-radius-medium)*0.6)] transition-transform',\n // unselected border layer\n \"before:absolute before:inset-0 before:box-border before:rounded-[inherit] before:border-2 before:border-solid before:border-default before:transition-colors before:content-['']\",\n // animated selection layer\n \"after:absolute after:inset-0 after:origin-center after:scale-50 after:rounded-[inherit] after:opacity-0 after:duration-200 after:ease-linear after:content-[''] after:transition-transform-opacity\",\n // pressed scale\n 'group-data-[pressed=true]:scale-95',\n // keyboard focus ring\n 'group-data-[focus-visible=true]:ring-2 group-data-[focus-visible=true]:ring-focus group-data-[focus-visible=true]:ring-offset-2 group-data-[focus-visible=true]:ring-offset-background',\n // hover and selected states\n 'group-data-[hover=true]:before:bg-default-100 group-data-[selected=true]:after:scale-100 group-data-[selected=true]:after:opacity-100',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Container arranging the selectable content */\n wrapper: [\n '',\n 'flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row',\n ],\n },\n variants: {\n lineThrough: {\n true: {\n optionLabel: [\n // label layout\n 'inline-flex items-center justify-center',\n // strikethrough line\n \"before:absolute before:h-0.5 before:w-0 before:bg-foreground before:content-['']\",\n // selected strikethrough state\n 'group-data-[selected=true]:opacity-60 group-data-[selected=true]:before:w-full',\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n invalid: {\n true: {\n optionLabel: 'text-danger',\n optionWrapper: 'before:border-danger',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof checkboxesVariants>;\n\nexport type ClassName = TVClassName<typeof checkboxesVariants>;\nexport const checkboxOptionVariants = tv({\n extend: checkboxColorVariants,\n slots: {\n /** Option field context without an additional layout box */\n field: 'contents',\n /** Container for the option label and optional subline */\n label:\n 'relative select-none text-foreground transition-colors-opacity text-medium before:transition-width motion-reduce:transition-none',\n },\n variants: { invalid: { true: { label: 'text-danger' } } },\n});\n\n/** Resolved checkbox group and option slot classes */\nexport type CheckboxClassNames = Record<\n keyof ReturnType<typeof checkboxesVariants>,\n string\n>;\n","interface CheckboxIndicatorProps {\n /** CSS class name */\n className: {\n /** Animated checkmark */\n icon: string;\n /** Selection indicator surface */\n wrapper: string;\n };\n /** Whether the option is selected */\n selected: boolean;\n}\n\n/** Checkbox selection indicator with an animated checkmark */\nconst CheckboxIndicator = ({ className, selected }: CheckboxIndicatorProps) => {\n return (\n <span aria-hidden className={className.wrapper} data-slot=\"wrapper\">\n <svg\n aria-hidden\n className={className.icon}\n data-slot=\"icon\"\n fill=\"none\"\n role=\"presentation\"\n stroke=\"currentColor\"\n strokeDasharray={22}\n strokeDashoffset={selected ? 44 : 66}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n viewBox=\"0 0 17 18\"\n >\n <polyline\n className=\"transition-[stroke-dashoffset] delay-200 duration-250 ease-linear motion-reduce:transition-none\"\n points=\"1 9 7 14 15 4\"\n />\n </svg>\n </span>\n );\n};\n\nexport default CheckboxIndicator;\n","import type { CheckboxOption } from '../Checkboxes';\n\ninterface CheckboxLabelProps extends Pick<\n CheckboxOption,\n 'label' | 'labelSubline'\n> {\n /** CSS class name */\n className: {\n /** Container for the option text */\n base: string;\n /** Primary option text */\n label: string;\n /** Supporting option text */\n subline: string;\n };\n /** Option ID used by the control's accessible-name associations */\n id: string;\n}\n\n/** Checkbox option text with an optional supporting line and accessible-name IDs */\nconst CheckboxLabel = ({\n className,\n id,\n label,\n labelSubline,\n}: CheckboxLabelProps) => {\n return (\n <span className={className.base} data-slot=\"label\" id={`${id}-label`}>\n {labelSubline ? (\n <div className=\"flex grow flex-col items-start\">\n <span className={className.label} id={`${id}-label-text`}>\n {label}\n </span>\n <span className={className.subline} id={`${id}-subline`}>\n {labelSubline}\n </span>\n </div>\n ) : (\n label\n )}\n </span>\n );\n};\n\nexport default CheckboxLabel;\n","import type { CheckboxButtonProps } from 'react-aria-components';\nimport type { CheckboxesProps, CheckboxOption } from '../Checkboxes';\nimport type { CheckboxClassNames } from '../checkboxesVariants';\n\nimport { useId } from 'react';\nimport { CheckboxButton, CheckboxField } from 'react-aria-components';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { checkboxOptionVariants } from '../checkboxesVariants';\nimport CheckboxIndicator from './CheckboxIndicator';\nimport CheckboxLabel from './CheckboxLabel';\n\ninterface CheckboxControlProps {\n /** CSS class name */\n className: CheckboxClassNames;\n /** Color scheme for the selection indicator */\n color: NonNullable<CheckboxesProps['color']>;\n /** Supporting description and error IDs */\n describedBy: string | undefined;\n /** Disables the field */\n disabled: boolean;\n /** Shows validation failure */\n invalid: boolean;\n /** Option label, subline and value */\n option: CheckboxOption;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Checkbox option with an animated indicator, label and optional subline\n *\n * @see https://react-aria.adobe.com/Checkbox\n */\nconst CheckboxControl = ({\n className: classNames,\n color,\n describedBy,\n disabled,\n invalid,\n option,\n testId,\n}: CheckboxControlProps) => {\n const id = useId();\n const styling = useStyling();\n\n const hasSubline = !!option.labelSubline;\n const hasLabel = !!option.label || hasSubline;\n const labelledBy = hasSubline\n ? `${id}-label-text ${id}-subline`\n : `${id}-label`;\n\n // classNames from slots\n const variants = styling.resolve(checkboxOptionVariants, { color, invalid });\n const optionClassNames = styling.variantsToClassNames(variants, {\n label: hasSubline ? undefined : classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n });\n\n // preserve option interaction selectors on the clickable label\n const renderOption: NonNullable<CheckboxButtonProps['render']> = (\n props,\n state,\n ) => {\n return (\n <label\n {...props}\n data-focus={state.isFocused || undefined}\n data-hover={state.isHovered || undefined}\n data-invalid={invalid}\n htmlFor={id}\n >\n {props.children}\n </label>\n );\n };\n\n return (\n <CheckboxField\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n aria-labelledby={hasLabel ? labelledBy : undefined}\n className={optionClassNames.field}\n id={id}\n isDisabled={disabled}\n isRequired={false}\n validationBehavior=\"aria\"\n value={option.value}\n >\n <CheckboxButton\n className={classNames.optionBase}\n data-testid={testId}\n render={renderOption}\n >\n {({ isSelected }) => {\n return (\n <>\n <CheckboxIndicator\n className={{\n icon: classNames.optionIcon,\n wrapper: optionClassNames.wrapper,\n }}\n selected={isSelected}\n />\n {hasLabel ? (\n <CheckboxLabel\n className={{\n base: optionClassNames.label,\n label: classNames.optionLabel,\n subline: classNames.optionLabelSubline,\n }}\n id={id}\n label={option.label}\n labelSubline={option.labelSubline}\n />\n ) : null}\n </>\n );\n }}\n </CheckboxButton>\n </CheckboxField>\n );\n};\n\nexport default CheckboxControl;\n","import type { CheckboxGroupProps } from 'react-aria-components';\nimport type { UniformField } from '../../hooks/useUniformField/types';\nimport type { CheckboxesProps } from '../Checkboxes';\n\nimport { CheckboxGroup, Label } from 'react-aria-components';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldLayout from '../../partials/FieldLayout/FieldLayout';\nimport { checkboxesVariants } from '../checkboxesVariants';\nimport CheckboxControl from './CheckboxControl';\n\ninterface CheckboxesControlProps extends Pick<\n CheckboxesProps,\n 'children' | 'className' | 'color' | 'inline' | 'lineThrough' | 'options'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, string[]>;\n}\n\n/**\n * Checkbox group presentation with option composition and focus routing\n *\n * @see https://react-aria.adobe.com/CheckboxGroup\n */\nconst CheckboxesControl = ({\n field,\n children,\n className,\n color = 'primary',\n inline = false,\n lineThrough,\n options,\n}: CheckboxesControlProps) => {\n const {\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label,\n name,\n onBlur,\n onChange: onValueChange,\n required,\n testId,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n\n // treat non-array form values as an empty selection\n const value = Array.isArray(field.value) ? field.value : [];\n\n // classNames from slots\n const variants = styling.resolve(checkboxesVariants, {\n lineThrough,\n invalid,\n });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n const associations = controlProps;\n const describedBy =\n [\n associations['aria-describedby'],\n required ? `${ids.control}-required` : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const renderedOptions = options?.map((option) => {\n const optionDisabled = !!disabled || !!option.disabled;\n\n return {\n option,\n state: {\n checked: value.includes(option.value),\n disabled: optionDisabled,\n invalid: !!invalid,\n },\n checkbox: (\n <CheckboxControl\n key={`index_${option.value}`}\n className={classNames}\n color={color === 'info' ? 'primary' : color}\n describedBy={describedBy}\n disabled={optionDisabled}\n invalid={invalid}\n option={option}\n testId={slugify(`${testId}_option_${option.testId ?? option.value}`, {\n replaceDots: true,\n })}\n />\n ),\n };\n });\n\n // route form focus to the first enabled checkbox\n const handleControlRef = (node: HTMLDivElement | null) => {\n inputRef(\n node\n ? {\n focus: () => {\n node\n .querySelector<HTMLInputElement>('input:not(:disabled)')\n ?.focus();\n },\n }\n : null,\n );\n };\n\n // keep the group styling state on its root\n const renderGroup: NonNullable<CheckboxGroupProps['render']> = (props) => {\n return (\n <div\n {...props}\n aria-invalid={invalid || undefined}\n data-invalid={invalid}\n data-required={required}\n >\n {props.children}\n </div>\n );\n };\n\n return (\n <FieldLayout\n baseAs={CheckboxGroup}\n baseProps={{\n 'aria-describedby': describedBy,\n 'aria-label': associations['aria-label'],\n 'data-component': 'checkboxes',\n 'data-slot': 'base',\n 'data-testid': testId,\n id: associations.id,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n name,\n onBlur,\n onChange: onValueChange,\n ref: handleControlRef,\n render: renderGroup,\n validationBehavior: 'aria',\n value,\n }}\n className={classNames}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n label={label}\n labelAs={Label}\n required={required}\n >\n {required ? (\n <span className=\"sr-only\" id={`${ids.control}-required`}>\n Required selection.\n </span>\n ) : null}\n <div\n className={classNames.wrapper}\n data-orientation={inline ? 'horizontal' : 'vertical'}\n data-slot=\"wrapper\"\n >\n {children\n ? children(renderedOptions ?? [])\n : renderedOptions?.map(({ checkbox }) => {\n return checkbox;\n })}\n </div>\n </FieldLayout>\n );\n};\n\nexport default CheckboxesControl;\n","import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { ClassName, VariantProps } from './checkboxesVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport CheckboxesControl from './subcomponents/CheckboxesControl';\n\nexport { checkboxesVariants } from './checkboxesVariants';\n\nexport interface CheckboxOption {\n /** Disables the field */\n disabled?: boolean;\n /** Field label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** Arbitrary option metadata for custom render logic. */\n meta?: Record<string, unknown>;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** option value */\n value: string;\n}\n\ninterface ChildRenderOption {\n /** Prebuilt checkbox element for custom option layouts */\n checkbox: ReactNode;\n /** Option data as provided in `options` */\n option: CheckboxOption;\n /** Render-state flags for this option */\n state: {\n /** Whether this option is currently selected */\n checked: boolean;\n /** Disables the field */\n disabled: boolean;\n /** Whether the checkbox group is invalid */\n invalid: boolean;\n };\n}\n\nexport interface CheckboxesProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** Optional child render function for custom full-list layout rendering. */\n children?: (options: ChildRenderOption[]) => ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** Arranges options horizontally */\n inline?: boolean;\n /** Field label */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Field name */\n name: string;\n /** Available options */\n options: CheckboxOption[];\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string[]>;\n}\n\n/** Form selection field for multiple checkbox options */\nconst Checkboxes = ({\n children = undefined,\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n name,\n options,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const { field } = useUniformField({\n ...uniformFieldProps,\n isArrayValue: true,\n name,\n });\n\n return (\n <CheckboxesControl\n className={className}\n color={color}\n field={field}\n inline={inline}\n lineThrough={lineThrough}\n options={options}\n >\n {children}\n </CheckboxesControl>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { checkboxesVariants } from './Checkboxes';\n\nexport default Checkboxes;\n"],"mappings":";;;;;;;;;AAIA,MAAM,wBAAwB,GAAG;CAC/B,OAAO,EAAE,SAAS,GAAG;CACrB,UAAU,EACR,OAAO;EACL,QAAQ,EACN,SACE,sEACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,MAAM,EACJ,SACE,gEACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,WAAW,EACT,SACE,+EACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,SAAS,EACP,SACE,yEACJ;CACF,EACF;AACF,CAAC;AACD,MAAa,qBAAqB,GAAG;CACnC,QAAQ;CACR,OAAO;;EAEL,MAAM,CAAC,wCAAwC,UAAU;;EAEzD,aAAa;;EAEb,cAAc,CAAC,aAAa,wBAAwB;;EAEpD,eAAe;;EAEf,OAAO,CACL,kHACA,UACF;;EAEA,YAAY;GACV;GAEA;GAEA;EACF;;EAEA,YAAY;GACV;GAEA;GAEA;GAEA;EACF;;EAEA,aAAa;;EAEb,oBAAoB;;EAEpB,eAAe;GACb;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;EACF;;EAEA,SAAS,CACP,IACA,sEACF;CACF;CACA,UAAU;EACR,aAAa,EACX,MAAM;GACJ,aAAa;IAEX;IAEA;IAEA;IACA;GACF;GACA,oBAAoB;EACtB,EACF;EACA,SAAS,EACP,MAAM;GACJ,aAAa;GACb,eAAe;EACjB,EACF;CACF;AACF,CAAC;AAKD,MAAa,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;GACR,oBAAoB;GACpB;EACF;EACA,WAAW;EACE;EACC;EACT;EACI;EACF;EACP,SAAS;EACC;EA3BZ,UAAA,CA6BG,WACC,oBAAC,QAAD;GAAM,WAAU;GAAU,IAAI,GAAG,IAAI,QAAQ;GAAY,UAAA;EAEnD,CAAA,IACJ,MACJ,oBAAC,OAAD;GACE,WAAW,WAAW;GACtB,oBAAkB,SAAS,eAAe;GAC1C,aAAU;GAET,UAAA,WACG,SAAS,mBAAmB,CAAC,CAAC,IAC9B,iBAAiB,KAAK,EAAE,eAAe;IACrC,OAAO;GACT,CAAC;EACF,CAAA,CACM;;AAEjB;;;;AC7GA,MAAM,cAAc,EAClB,WAAW,KAAA,GACX,YAAY,KAAA,GACZ,QAAQ,WACR,SAAS,OACT,cAAc,OACd,MACA,SACA,GAAG,wBACkB;CACrB,MAAM,EAAE,UAAU,gBAAgB;EAChC,GAAG;EACH,cAAc;EACd;CACF,CAAC;CAED,OACE,oBAAC,mBAAD;EACa;EACJ;EACA;EACC;EACK;EACJ;EAER;CACgB,CAAA;AAEvB;;;AC5FA,IAAA,qBAAe"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/Checkboxes/checkboxesVariants.ts","../../src/Checkboxes/subcomponents/CheckboxIndicator.tsx","../../src/Checkboxes/subcomponents/CheckboxLabel.tsx","../../src/Checkboxes/subcomponents/CheckboxControl.tsx","../../src/Checkboxes/subcomponents/CheckboxesControl.tsx","../../src/Checkboxes/Checkboxes.tsx","../../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nconst checkboxColorVariants = tv({\n slots: { wrapper: '' },\n variants: {\n color: {\n danger: {\n wrapper:\n 'text-danger-foreground after:bg-danger after:text-danger-foreground',\n },\n default: {\n wrapper:\n 'text-default-foreground after:bg-default after:text-default-foreground',\n },\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n primary: {\n wrapper:\n 'text-primary-foreground after:bg-primary after:text-primary-foreground',\n },\n secondary: {\n wrapper:\n 'text-secondary-foreground after:bg-secondary after:text-secondary-foreground',\n },\n success: {\n wrapper:\n 'text-success-foreground after:bg-success after:text-success-foreground',\n },\n warning: {\n wrapper:\n 'text-warning-foreground after:bg-warning after:text-warning-foreground',\n },\n },\n },\n});\nexport const checkboxesVariants = tv({\n extend: checkboxColorVariants,\n slots: {\n /** Container for the field control and supporting text */\n base: ['group flex w-full flex-col gap-y-1.5', 'relative'],\n /** Supporting text for the field */\n description: 'text-foreground-400 text-small',\n /** Container for validation messages */\n errorMessage: ['text-tiny', 'text-danger text-small'],\n /** Container for help text and validation messages */\n helperWrapper: 'relative block p-0',\n /** Visible field label */\n label: [\n 'inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n 'relative',\n ],\n /** Clickable checkbox option */\n optionBase: [\n '',\n // option layout and pointer behavior\n 'group relative -m-2 inline-flex max-w-fit cursor-pointer select-none items-center justify-start p-2 tap-highlight-transparent',\n // disabled cursor and opacity, the native input covers the option\n 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-disabled data-[disabled=true]:**:cursor-not-allowed',\n ],\n /** Checkmark inside the selection indicator */\n optionIcon: [\n '',\n // checkmark dimensions and fade transition\n 'pointer-events-none z-10 h-3 w-4 opacity-0 transition-opacity',\n // selected visibility\n 'group-data-[selected=true]:opacity-100',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Primary option text */\n optionLabel: '',\n /** Additional text below the option label */\n optionLabelSubline: 'text-foreground-400 !text-small',\n /** Outline and fill around the checkmark */\n optionWrapper: [\n '',\n // checkbox dimensions and layout\n 'relative me-2 inline-flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-[calc(var(--pixel-radius-medium)*0.6)] transition-transform',\n // unselected border layer\n \"before:absolute before:inset-0 before:box-border before:rounded-[inherit] before:border-2 before:border-solid before:border-default before:transition-colors before:content-['']\",\n // animated selection layer\n \"after:absolute after:inset-0 after:origin-center after:scale-50 after:rounded-[inherit] after:opacity-0 after:duration-200 after:ease-linear after:content-[''] after:transition-transform-opacity\",\n // pressed scale\n 'group-data-[pressed=true]:scale-95',\n // keyboard focus ring\n 'group-data-[focus-visible=true]:ring-2 group-data-[focus-visible=true]:ring-focus group-data-[focus-visible=true]:ring-offset-2 group-data-[focus-visible=true]:ring-offset-background',\n // hover and selected states\n 'group-data-[hover=true]:before:bg-default-100 group-data-[selected=true]:after:scale-100 group-data-[selected=true]:after:opacity-100',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Container arranging the selectable content */\n wrapper: [\n '',\n 'flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row',\n ],\n },\n variants: {\n lineThrough: {\n true: {\n optionLabel: [\n // label layout\n 'inline-flex items-center justify-center',\n // strikethrough line\n \"before:absolute before:h-0.5 before:w-0 before:bg-foreground before:content-['']\",\n // selected strikethrough state\n 'group-data-[selected=true]:opacity-60 group-data-[selected=true]:before:w-full',\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n invalid: {\n true: {\n optionLabel: 'text-danger',\n optionWrapper: 'before:border-danger',\n },\n },\n readOnly: {\n true: {\n // inner controls set their own cursors, override every descendant\n base: 'cursor-not-allowed opacity-disabled **:cursor-not-allowed',\n optionWrapper: 'group-data-[hover=true]:before:bg-transparent',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof checkboxesVariants>;\n\nexport type ClassName = TVClassName<typeof checkboxesVariants>;\nexport const checkboxOptionVariants = tv({\n extend: checkboxColorVariants,\n slots: {\n /** Option field context without an additional layout box */\n field: 'contents',\n /** Container for the option label and optional subline */\n label:\n 'relative select-none text-foreground transition-colors-opacity text-medium before:transition-width motion-reduce:transition-none',\n },\n variants: { invalid: { true: { label: 'text-danger' } } },\n});\n\n/** Resolved checkbox group and option slot classes */\nexport type CheckboxClassNames = Record<\n keyof ReturnType<typeof checkboxesVariants>,\n string\n>;\n","interface CheckboxIndicatorProps {\n /** CSS class name */\n className: {\n /** Animated checkmark */\n icon: string;\n /** Selection indicator surface */\n wrapper: string;\n };\n /** Whether the option is selected */\n selected: boolean;\n}\n\n/** Checkbox selection indicator with an animated checkmark */\nconst CheckboxIndicator = ({ className, selected }: CheckboxIndicatorProps) => {\n return (\n <span aria-hidden className={className.wrapper} data-slot=\"wrapper\">\n <svg\n aria-hidden\n className={className.icon}\n data-slot=\"icon\"\n fill=\"none\"\n role=\"presentation\"\n stroke=\"currentColor\"\n strokeDasharray={22}\n strokeDashoffset={selected ? 44 : 66}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n viewBox=\"0 0 17 18\"\n >\n <polyline\n className=\"transition-[stroke-dashoffset] delay-200 duration-250 ease-linear motion-reduce:transition-none\"\n points=\"1 9 7 14 15 4\"\n />\n </svg>\n </span>\n );\n};\n\nexport default CheckboxIndicator;\n","import type { CheckboxOption } from '../Checkboxes';\n\ninterface CheckboxLabelProps extends Pick<\n CheckboxOption,\n 'label' | 'labelSubline'\n> {\n /** CSS class name */\n className: {\n /** Container for the option text */\n base: string;\n /** Primary option text */\n label: string;\n /** Supporting option text */\n subline: string;\n };\n /** Option ID used by the control's accessible-name associations */\n id: string;\n}\n\n/** Checkbox option text with an optional supporting line and accessible-name IDs */\nconst CheckboxLabel = ({\n className,\n id,\n label,\n labelSubline,\n}: CheckboxLabelProps) => {\n return (\n <span className={className.base} data-slot=\"label\" id={`${id}-label`}>\n {labelSubline ? (\n <div className=\"flex grow flex-col items-start\">\n <span className={className.label} id={`${id}-label-text`}>\n {label}\n </span>\n <span className={className.subline} id={`${id}-subline`}>\n {labelSubline}\n </span>\n </div>\n ) : (\n label\n )}\n </span>\n );\n};\n\nexport default CheckboxLabel;\n","import type { CheckboxButtonProps } from 'react-aria-components';\nimport type { CheckboxesProps, CheckboxOption } from '../Checkboxes';\nimport type { CheckboxClassNames } from '../checkboxesVariants';\n\nimport { useId } from 'react';\nimport { CheckboxButton, CheckboxField } from 'react-aria-components';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { checkboxOptionVariants } from '../checkboxesVariants';\nimport CheckboxIndicator from './CheckboxIndicator';\nimport CheckboxLabel from './CheckboxLabel';\n\ninterface CheckboxControlProps {\n /** CSS class name */\n className: CheckboxClassNames;\n /** Color scheme for the selection indicator */\n color: NonNullable<CheckboxesProps['color']>;\n /** Supporting description and error IDs */\n describedBy: string | undefined;\n /** Disables the field */\n disabled: boolean;\n /** Shows validation failure */\n invalid: boolean;\n /** Option label, subline and value */\n option: CheckboxOption;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Checkbox option with an animated indicator, label and optional subline\n *\n * @see https://react-aria.adobe.com/Checkbox\n */\nconst CheckboxControl = ({\n className: classNames,\n color,\n describedBy,\n disabled,\n invalid,\n option,\n testId,\n}: CheckboxControlProps) => {\n const id = useId();\n const styling = useStyling();\n\n const hasSubline = !!option.labelSubline;\n const hasLabel = !!option.label || hasSubline;\n const labelledBy = hasSubline\n ? `${id}-label-text ${id}-subline`\n : `${id}-label`;\n\n // classNames from slots\n const variants = styling.resolve(checkboxOptionVariants, { color, invalid });\n const optionClassNames = styling.variantsToClassNames(variants, {\n label: hasSubline ? undefined : classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n });\n\n // preserve option interaction selectors on the clickable label\n const renderOption: NonNullable<CheckboxButtonProps['render']> = (\n props,\n state,\n ) => {\n return (\n <label\n {...props}\n data-focus={state.isFocused || undefined}\n data-hover={state.isHovered || undefined}\n data-invalid={invalid}\n htmlFor={id}\n >\n {props.children}\n </label>\n );\n };\n\n return (\n <CheckboxField\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n aria-labelledby={hasLabel ? labelledBy : undefined}\n className={optionClassNames.field}\n id={id}\n isDisabled={disabled}\n isRequired={false}\n validationBehavior=\"aria\"\n value={option.value}\n >\n <CheckboxButton\n className={classNames.optionBase}\n data-testid={testId}\n render={renderOption}\n >\n {({ isSelected }) => {\n return (\n <>\n <CheckboxIndicator\n className={{\n icon: classNames.optionIcon,\n wrapper: optionClassNames.wrapper,\n }}\n selected={isSelected}\n />\n {hasLabel ? (\n <CheckboxLabel\n className={{\n base: optionClassNames.label,\n label: classNames.optionLabel,\n subline: classNames.optionLabelSubline,\n }}\n id={id}\n label={option.label}\n labelSubline={option.labelSubline}\n />\n ) : null}\n </>\n );\n }}\n </CheckboxButton>\n </CheckboxField>\n );\n};\n\nexport default CheckboxControl;\n","import type { CheckboxGroupProps } from 'react-aria-components';\nimport type { UniformField } from '../../hooks/useUniformField/types';\nimport type { CheckboxesProps } from '../Checkboxes';\n\nimport { CheckboxGroup, Label } from 'react-aria-components';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldLayout from '../../partials/FieldLayout/FieldLayout';\nimport { checkboxesVariants } from '../checkboxesVariants';\nimport CheckboxControl from './CheckboxControl';\n\ninterface CheckboxesControlProps extends Pick<\n CheckboxesProps,\n 'children' | 'className' | 'color' | 'inline' | 'lineThrough' | 'options'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, string[]>;\n}\n\n/**\n * Checkbox group presentation with option composition and focus routing\n *\n * @see https://react-aria.adobe.com/CheckboxGroup\n */\nconst CheckboxesControl = ({\n field,\n children,\n className,\n color = 'primary',\n inline = false,\n lineThrough,\n options,\n}: CheckboxesControlProps) => {\n const {\n description,\n disabled,\n errorMessage,\n ids,\n ref: inputRef,\n invalid,\n label,\n name,\n onBlur,\n onChange: onValueChange,\n readOnly,\n required,\n testId,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const styling = useStyling();\n\n // treat non-array form values as an empty selection\n const value = Array.isArray(field.value) ? field.value : [];\n\n // classNames from slots\n const variants = styling.resolve(checkboxesVariants, {\n lineThrough,\n invalid,\n readOnly,\n });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n const associations = controlProps;\n const describedBy =\n [\n associations['aria-describedby'],\n required ? `${ids.control}-required` : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const renderedOptions = options?.map((option) => {\n const optionDisabled = !!disabled || !!option.disabled;\n\n return {\n option,\n state: {\n checked: value.includes(option.value),\n disabled: optionDisabled,\n invalid: !!invalid,\n },\n checkbox: (\n <CheckboxControl\n key={`index_${option.value}`}\n className={classNames}\n color={color === 'info' ? 'primary' : color}\n describedBy={describedBy}\n disabled={optionDisabled}\n invalid={invalid}\n option={option}\n testId={slugify(`${testId}_option_${option.testId ?? option.value}`, {\n replaceDots: true,\n })}\n />\n ),\n };\n });\n\n // route form focus to the first enabled checkbox\n const handleControlRef = (node: HTMLDivElement | null) => {\n inputRef(\n node\n ? {\n focus: () => {\n node\n .querySelector<HTMLInputElement>('input:not(:disabled)')\n ?.focus();\n },\n }\n : null,\n );\n };\n\n // keep the group styling state on its root\n const renderGroup: NonNullable<CheckboxGroupProps['render']> = (props) => {\n return (\n <div\n {...props}\n aria-invalid={invalid || undefined}\n data-invalid={invalid}\n data-required={required}\n >\n {props.children}\n </div>\n );\n };\n\n return (\n <FieldLayout\n baseAs={CheckboxGroup}\n baseProps={{\n 'aria-describedby': describedBy,\n 'aria-label': associations['aria-label'],\n 'data-component': 'checkboxes',\n 'data-slot': 'base',\n 'data-testid': testId,\n id: associations.id,\n isDisabled: disabled,\n isInvalid: invalid,\n isReadOnly: readOnly,\n isRequired: required,\n name,\n onBlur,\n onChange: onValueChange,\n ref: handleControlRef,\n render: renderGroup,\n validationBehavior: 'aria',\n value,\n }}\n className={classNames}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n label={label}\n labelAs={Label}\n required={required}\n >\n {required ? (\n <span className=\"sr-only\" id={`${ids.control}-required`}>\n Required selection.\n </span>\n ) : null}\n <div\n className={classNames.wrapper}\n data-orientation={inline ? 'horizontal' : 'vertical'}\n data-slot=\"wrapper\"\n >\n {children\n ? children(renderedOptions ?? [])\n : renderedOptions?.map(({ checkbox }) => {\n return checkbox;\n })}\n </div>\n </FieldLayout>\n );\n};\n\nexport default CheckboxesControl;\n","import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { ClassName, VariantProps } from './checkboxesVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport CheckboxesControl from './subcomponents/CheckboxesControl';\n\nexport { checkboxesVariants } from './checkboxesVariants';\n\nexport interface CheckboxOption {\n /** Disables the field */\n disabled?: boolean;\n /** Field label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** Arbitrary option metadata for custom render logic. */\n meta?: Record<string, unknown>;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** option value */\n value: string;\n}\n\ninterface ChildRenderOption {\n /** Prebuilt checkbox element for custom option layouts */\n checkbox: ReactNode;\n /** Option data as provided in `options` */\n option: CheckboxOption;\n /** Render-state flags for this option */\n state: {\n /** Whether this option is currently selected */\n checked: boolean;\n /** Disables the field */\n disabled: boolean;\n /** Whether the checkbox group is invalid */\n invalid: boolean;\n };\n}\n\nexport interface CheckboxesProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** Optional child render function for custom full-list layout rendering. */\n children?: (options: ChildRenderOption[]) => ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** Arranges options horizontally */\n inline?: boolean;\n /** Field label */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Field name */\n name: string;\n /** Available options */\n options: CheckboxOption[];\n /** Prevents changes while keeping the selection in validation and submission */\n readOnly?: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string[]>;\n}\n\n/** Form selection field for multiple checkbox options */\nconst Checkboxes = ({\n children = undefined,\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n name,\n options,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const { field } = useUniformField({\n ...uniformFieldProps,\n isArrayValue: true,\n name,\n });\n\n return (\n <CheckboxesControl\n className={className}\n color={color}\n field={field}\n inline={inline}\n lineThrough={lineThrough}\n options={options}\n >\n {children}\n </CheckboxesControl>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { checkboxesVariants } from './Checkboxes';\n\nexport default Checkboxes;\n"],"mappings":";;;;;;;;;AAIA,MAAM,wBAAwB,GAAG;CAC/B,OAAO,EAAE,SAAS,GAAG;CACrB,UAAU,EACR,OAAO;EACL,QAAQ,EACN,SACE,sEACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,MAAM,EACJ,SACE,gEACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,WAAW,EACT,SACE,+EACJ;EACA,SAAS,EACP,SACE,yEACJ;EACA,SAAS,EACP,SACE,yEACJ;CACF,EACF;AACF,CAAC;AACD,MAAa,qBAAqB,GAAG;CACnC,QAAQ;CACR,OAAO;;EAEL,MAAM,CAAC,wCAAwC,UAAU;;EAEzD,aAAa;;EAEb,cAAc,CAAC,aAAa,wBAAwB;;EAEpD,eAAe;;EAEf,OAAO,CACL,kHACA,UACF;;EAEA,YAAY;GACV;GAEA;GAEA;EACF;;EAEA,YAAY;GACV;GAEA;GAEA;GAEA;EACF;;EAEA,aAAa;;EAEb,oBAAoB;;EAEpB,eAAe;GACb;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;EACF;;EAEA,SAAS,CACP,IACA,sEACF;CACF;CACA,UAAU;EACR,aAAa,EACX,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