@fuf-stack/uniform 2.0.0-next.3 → 2.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checkboxes/index.d.mts +50 -50
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +14 -12
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +27 -90
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +31 -39
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +6 -6
- package/dist/FieldArray/index.mjs +19 -17
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.mjs +10 -13
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/FieldHelper-B1DWl7eu.mjs +38 -0
- package/dist/FieldHelper-B1DWl7eu.mjs.map +1 -0
- package/dist/FieldLabel-DMTqq0Jj.mjs +29 -0
- package/dist/FieldLabel-DMTqq0Jj.mjs.map +1 -0
- package/dist/{FieldLayout-DcvQU0zN.mjs → FieldLayout-C9MEBZAC.mjs} +10 -17
- package/dist/FieldLayout-C9MEBZAC.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +1 -1
- package/dist/FieldReset/index.mjs +1 -1
- package/dist/{FieldValidationError-iAayfTEw.mjs → FieldValidationError-BuLvuRyi.mjs} +3 -3
- package/dist/FieldValidationError-BuLvuRyi.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.mjs +4 -4
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-PXkVlBdU.mjs → FormContext-CVq3glVW.mjs} +5 -5
- package/dist/FormContext-CVq3glVW.mjs.map +1 -0
- package/dist/{FormContext-BnNJYZOo.d.mts → FormContext-Dvt3MiKq.d.mts} +3 -3
- package/dist/{FormContext-BnNJYZOo.d.mts.map → FormContext-Dvt3MiKq.d.mts.map} +1 -1
- package/dist/Input/index.d.mts +583 -418
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +16 -19
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +101 -85
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +6 -14
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +590 -335
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +15 -15
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +52 -49
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +5 -13
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +762 -570
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +14 -15
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +658 -348
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +24 -32
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +1 -1
- package/dist/Switch/index.mjs +12 -17
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-3ujfKWwt.d.mts +990 -0
- package/dist/{Switch-Db2dpGz7.d.mts.map → Switch-3ujfKWwt.d.mts.map} +1 -1
- package/dist/SwitchBox/index.d.mts +583 -221
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +14 -18
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +544 -207
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +13 -16
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +47 -47
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +17 -22
- package/dist/Time/index.mjs.map +1 -1
- package/dist/fieldHelperVariants-ClP8taiS.mjs +20 -0
- package/dist/fieldHelperVariants-ClP8taiS.mjs.map +1 -0
- package/dist/fieldLabelVariants-C4ZqECec.mjs +13 -0
- package/dist/fieldLabelVariants-C4ZqECec.mjs.map +1 -0
- package/dist/{FieldDescription-X_0s1Lhu.mjs → fieldProps-DWfz2jSO.mjs} +2 -13
- package/dist/fieldProps-DWfz2jSO.mjs.map +1 -0
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +1 -1
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{Switch-Db2dpGz7.d.mts → partials/FieldHelper/index.d.mts} +308 -407
- package/dist/partials/FieldHelper/index.d.mts.map +1 -0
- package/dist/partials/FieldHelper/index.mjs +7 -0
- package/dist/partials/FieldHelper/index.mjs.map +1 -0
- package/dist/partials/FieldLabel/index.d.mts +160 -0
- package/dist/partials/FieldLabel/index.d.mts.map +1 -0
- package/dist/partials/FieldLabel/index.mjs +7 -0
- package/dist/partials/FieldLabel/index.mjs.map +1 -0
- package/dist/partials/FieldValidationError/index.d.mts +13 -13
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/{radioControlVariants-BYRfaD6y.mjs → radioControlVariants-CxA0og5-.mjs} +16 -12
- package/dist/radioControlVariants-CxA0og5-.mjs.map +1 -0
- package/dist/{switchVariants-D16b2VaT.mjs → switchVariants-B8dq8DYP.mjs} +12 -15
- package/dist/switchVariants-B8dq8DYP.mjs.map +1 -0
- package/dist/{timeVariants-CtXyNKmW.mjs → timeVariants-CIX6R59-.mjs} +17 -15
- package/dist/timeVariants-CIX6R59-.mjs.map +1 -0
- package/dist/{useController-JtIeurpw.mjs → useController-SEAuP3G4.mjs} +6 -6
- package/dist/useController-SEAuP3G4.mjs.map +1 -0
- package/dist/{useFormContext-piqnN2L-.mjs → useFormContext-CQzJhAU4.mjs} +12 -8
- package/dist/useFormContext-CQzJhAU4.mjs.map +1 -0
- package/dist/{FieldLabel-DrNWJIVh.mjs → useUniformField-BvPoQyLL.mjs} +6 -31
- package/dist/useUniformField-BvPoQyLL.mjs.map +1 -0
- package/package.json +6 -4
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +0 -1
- package/dist/FieldLabel-DrNWJIVh.mjs.map +0 -1
- package/dist/FieldLayout-DcvQU0zN.mjs.map +0 -1
- package/dist/FieldValidationError-iAayfTEw.mjs.map +0 -1
- package/dist/FormContext-PXkVlBdU.mjs.map +0 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +0 -1
- package/dist/switchVariants-D16b2VaT.mjs.map +0 -1
- package/dist/timeVariants-CtXyNKmW.mjs.map +0 -1
- package/dist/useController-JtIeurpw.mjs.map +0 -1
- package/dist/useFormContext-piqnN2L-.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/RadioBoxes/radioBoxesVariants.ts","../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/subcomponents/radioBoxVariants.ts"],"mappings":";;qBAMa,sBAAkB
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/RadioBoxes/radioBoxesVariants.ts","../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/subcomponents/radioBoxVariants.ts"],"mappings":";;qBAMa,sBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkCnB,eAAe,eAAe;KAE9B,YAAY,mBAAmB;UClC1B;;EAEf,cAAc;;EAEd;;EAEA,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;UAGe,wBAAwB;;EAEvC;;EAEA,YAAY;;EAEZ,cAAc;;EAEd;;EAEA;;EAEA,QAAQ;;EAER;;EAEA,SAAS;;EAET;;EAEA;;;cAII,eAAc,WAAA,QAAA,MAAA,YAAA,qBAMjB,oCAAe,IAAA;qBC/CL,oBAAgB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as useUniformField } from "../useUniformField-BvPoQyLL.mjs";
|
|
2
2
|
import { createOptionValueConverter } from "../helpers/index.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as FieldLayout } from "../FieldLayout-
|
|
5
|
-
import { i as RadioGroupField, n as RadioControl, r as radioGroupFieldVariants, t as radioControlVariants } from "../radioControlVariants-
|
|
3
|
+
import { t as getFieldControlProps } from "../fieldProps-DWfz2jSO.mjs";
|
|
4
|
+
import { t as FieldLayout } from "../FieldLayout-C9MEBZAC.mjs";
|
|
5
|
+
import { i as RadioGroupField, n as RadioControl, r as radioGroupFieldVariants, t as radioControlVariants } from "../radioControlVariants-CxA0og5-.mjs";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { slugify, tv } from "@fuf-stack/pixel-utils";
|
|
8
8
|
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
@@ -12,11 +12,7 @@ const radioBoxesVariants = tv({
|
|
|
12
12
|
extend: radioGroupFieldVariants,
|
|
13
13
|
slots: {
|
|
14
14
|
/** Container for the field control and supporting text */
|
|
15
|
-
base: [
|
|
16
|
-
"group",
|
|
17
|
-
"flex w-full flex-col",
|
|
18
|
-
"gap-y-1.5"
|
|
19
|
-
],
|
|
15
|
+
base: ["group", "flex w-full flex-col"],
|
|
20
16
|
/** Clickable option box */
|
|
21
17
|
boxBase: "",
|
|
22
18
|
/** Indicator marking the selected box */
|
|
@@ -27,10 +23,6 @@ const radioBoxesVariants = tv({
|
|
|
27
23
|
boxLabel: "",
|
|
28
24
|
/** Container grouping option text */
|
|
29
25
|
boxLabelWrapper: "",
|
|
30
|
-
/** Container for validation messages */
|
|
31
|
-
errorMessage: "text-danger text-tiny",
|
|
32
|
-
/** Visible field label */
|
|
33
|
-
label: "mb-2 inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
|
|
34
26
|
/** Container arranging the selectable content */
|
|
35
27
|
wrapper: "flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row"
|
|
36
28
|
},
|
|
@@ -48,7 +40,7 @@ const radioBoxVariants = tv({
|
|
|
48
40
|
/** Dot marking the selected option */
|
|
49
41
|
control: radioControlVariants.slots.control,
|
|
50
42
|
/** Supporting text for the field */
|
|
51
|
-
description: "text-foreground opacity-70
|
|
43
|
+
description: "text-small text-foreground opacity-70",
|
|
52
44
|
/** Option state boundary without an additional layout box */
|
|
53
45
|
field: radioControlVariants.slots.field,
|
|
54
46
|
/** Decorative icon beside the option text */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/RadioBoxes/radioBoxesVariants.ts","../../src/RadioBoxes/subcomponents/radioBoxVariants.ts","../../src/RadioBoxes/subcomponents/RadioBox.tsx","../../src/RadioBoxes/subcomponents/RadioBoxesControl.tsx","../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nimport radioGroupFieldVariants from '../partials/RadioGroupField/radioGroupFieldVariants';\n\nexport const radioBoxesVariants = tv({\n extend: radioGroupFieldVariants,\n slots: {\n /** Container for the field control and supporting text */\n base: [\n // Needs group for group-data condition.\n 'group',\n // Match shared field wrapper layout.\n 'flex w-full flex-col',\n // Keep spacing between label/radio boxes consistent.\n 'gap-y-1.5',\n ],\n /** Clickable option box */\n boxBase: '',\n /** Indicator marking the selected box */\n boxControl: '',\n /** Supporting text inside an option box */\n boxDescription: '',\n /** Primary option text */\n boxLabel: '',\n /** Container grouping option text */\n boxLabelWrapper: '',\n /** Container for validation messages */\n errorMessage: 'text-danger text-tiny',\n /** Visible field label */\n label:\n 'mb-2 inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n /** Container arranging the selectable content */\n wrapper:\n 'flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row',\n },\n variants: {\n readOnly: {\n true: {\n // drop hover feedback so read-only boxes do not look clickable\n boxBase: 'hover:bg-transparent',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof radioBoxesVariants>;\n\nexport type ClassName = TVClassName<typeof radioBoxesVariants>;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nimport radioControlVariants from '../../Radios/subcomponents/radioControlVariants';\n\nexport const radioBoxVariants = tv({\n slots: {\n /** Container for the field control and supporting text */\n base: [\n // option box layout\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4',\n // box border and padding\n 'rounded-lg border-2 border-default p-4',\n // hover and selection feedback\n 'hover:bg-content2 data-[selected=true]:border-focus',\n ],\n /** Dot marking the selected option */\n control: radioControlVariants.slots.control,\n /** Supporting text for the field */\n description: 'text-foreground opacity-70 text-small',\n /** Option state boundary without an additional layout box */\n field: radioControlVariants.slots.field,\n /** Decorative icon beside the option text */\n icon: '',\n /** Visible field label */\n label: radioControlVariants.slots.label,\n /** Container grouping the option label and description */\n labelWrapper: [radioControlVariants.slots.labelWrapper, 'grow'],\n /** Circular outline around the selection indicator */\n wrapper: radioControlVariants.slots.wrapper,\n },\n variants: {\n disabled: {\n true: {\n // keep pointer events so the disabled cursor shows, the input blocks changes\n base: 'cursor-not-allowed opacity-disabled **:cursor-not-allowed hover:bg-transparent',\n },\n },\n invalid: {\n true: {\n base: '!border-danger',\n control: radioControlVariants.variants.invalid.true.control,\n label: radioControlVariants.variants.invalid.true.label,\n wrapper: radioControlVariants.variants.invalid.true.wrapper,\n },\n },\n },\n});\n\nexport type ClassName = TVClassName<typeof radioBoxVariants>;\n","import type { ReactNode } from 'react';\nimport type { ClassName } from './radioBoxVariants';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport RadioControl from '../../Radios/subcomponents/RadioControl';\nimport { radioBoxVariants } from './radioBoxVariants';\n\nexport interface RadioBoxProps {\n /** Option label. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Legacy alias for className */\n classNames?: ClassName;\n /** HTML test ID for the option. */\n 'data-testid'?: string;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the option */\n disabled?: boolean;\n /** icon for the option */\n icon?: ReactNode;\n /** Marks the option as invalid */\n invalid?: boolean;\n /** String value managed by the containing radio group. */\n value: string;\n}\n\n/**\n * Selectable radio box with an icon, supporting text and selection indicator\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nexport const RadioBox = ({\n className = undefined,\n classNames: _classNames = undefined,\n icon = undefined,\n invalid = false,\n disabled = false,\n description = undefined,\n children = undefined,\n value,\n ...props\n}: RadioBoxProps) => {\n const styling = useStyling();\n\n // classNames from slots\n const variants = styling.resolve(radioBoxVariants, { disabled, invalid });\n const classNames = styling.variantsToClassNames(\n variants,\n _classNames ?? className,\n 'base',\n );\n\n return (\n <RadioControl\n className={classNames}\n description={description}\n disabled={disabled}\n icon={icon}\n invalid={invalid}\n testId={props['data-testid']}\n value={value}\n >\n {children}\n </RadioControl>\n );\n};\n\nexport default RadioBox;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { RadioBoxesProps } from '../RadioBoxes';\n\nimport { Label } from 'react-aria-components';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { createOptionValueConverter } from '../../helpers';\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldLayout from '../../partials/FieldLayout/FieldLayout';\nimport RadioGroupField from '../../partials/RadioGroupField/RadioGroupField';\nimport { radioBoxesVariants } from '../radioBoxesVariants';\nimport { RadioBox } from './RadioBox';\n\ninterface RadioBoxesControlProps extends Pick<\n RadioBoxesProps,\n 'className' | 'inline' | 'options'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, string | number | boolean>;\n}\n\n/**\n * Radio boxes with shared group layout and focus routing\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nconst RadioBoxesControl = ({\n field,\n className,\n inline = false,\n options,\n}: RadioBoxesControlProps) => {\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 value,\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 const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = styling.resolve(radioBoxesVariants, { readOnly });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n // restore the selected option's original value type\n const handleChange = (nextValue: string) => {\n onValueChange(convertToOriginalType(nextValue));\n };\n\n return (\n <FieldLayout\n baseAs={RadioGroupField}\n baseProps={{\n controlProps,\n dataComponent: 'radio-boxes',\n disabled,\n inline,\n inputRef,\n invalid,\n name,\n onBlur,\n onChange: handleChange,\n readOnly,\n required,\n testId,\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 <div\n className={classNames.wrapper}\n data-orientation={inline ? 'horizontal' : 'vertical'}\n data-slot=\"wrapper\"\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n className={{\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n }}\n data-testid={optionTestId}\n description={option.description}\n disabled={!!disabled || option.disabled}\n icon={option.icon}\n invalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </div>\n </FieldLayout>\n );\n};\n\nexport default RadioBoxesControl;\n","import type { ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './radioBoxesVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport RadioBoxesControl from './subcomponents/RadioBoxesControl';\n\nexport { radioBoxesVariants } from './radioBoxesVariants';\n\nexport interface RadioBoxOption {\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** option icon */\n icon?: ReactNode;\n /** Field label */\n label?: ReactNode;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\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 /** Field name */\n name: string;\n /** Available options */\n options: RadioBoxOption[];\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}\n\n/** Form selection field for one option displayed as a box */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const { field } = useUniformField({ ...uniformFieldProps, name });\n\n return (\n <RadioBoxesControl\n className={className}\n field={field}\n inline={inline}\n options={options}\n />\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps, RadioBoxOption } from './RadioBoxes';\n\nexport { radioBoxesVariants } from './radioBoxesVariants';\n\nexport { radioBoxVariants } from './subcomponents/radioBoxVariants';\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;;AAMA,MAAa,qBAAqB,GAAG;CACnC,QAAQ;CACR,OAAO;;EAEL,MAAM;GAEJ;GAEA;GAEA;EACF;;EAEA,SAAS;;EAET,YAAY;;EAEZ,gBAAgB;;EAEhB,UAAU;;EAEV,iBAAiB;;EAEjB,cAAc;;EAEd,OACE;;EAEF,SACE;CACJ;CACA,UAAU,EACR,UAAU,EACR,MAAM,EAEJ,SAAS,uBACX,EACF,EACF;AACF,CAAC;;ACvCD,MAAa,mBAAmB,GAAG;CACjC,OAAO;;EAEL,MAAM;GAEJ;GAEA;GAEA;EACF;;EAEA,SAAS,qBAAqB,MAAM;;EAEpC,aAAa;;EAEb,OAAO,qBAAqB,MAAM;;EAElC,MAAM;;EAEN,OAAO,qBAAqB,MAAM;;EAElC,cAAc,CAAC,qBAAqB,MAAM,cAAc,MAAM;;EAE9D,SAAS,qBAAqB,MAAM;CACtC;CACA,UAAU;EACR,UAAU,EACR,MAAM,EAEJ,MAAM,iFACR,EACF;EACA,SAAS,EACP,MAAM;GACJ,MAAM;GACN,SAAS,qBAAqB,SAAS,QAAQ,KAAK;GACpD,OAAO,qBAAqB,SAAS,QAAQ,KAAK;GAClD,SAAS,qBAAqB,SAAS,QAAQ,KAAK;EACtD,EACF;CACF;AACF,CAAC;;;;;;;ACdD,MAAa,YAAY,EACvB,YAAY,KAAA,GACZ,YAAY,cAAc,KAAA,GAC1B,OAAO,KAAA,G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,WAAW;OACpB,aAAa,WAAW;OACxB,OAAO,WAAW;OAClB,cAAc,WAAW;MAC3B;MACA,eAAa;MACb,aAAa,OAAO;MACpB,UAAU,CAAC,CAAC,YAAY,OAAO;MAC/B,MAAM,OAAO;MACJ;MACT,OAAO,OAAO,OAAO,KAAK;MAEzB,UAAA,OAAO,SAAS,OAAO;KAChB,GAhBH,OAAO,OAAO,KAAK,CAgBhB;IAEd;IACA,OAAO;GACT,CAAC;EACE,CAAA;CACM,CAAA;AAEjB;;;ACpFA,MAAM,cAAc,EAClB,YAAY,KAAA,GACZ,SAAS,OACT,MACA,SACA,GAAG,wBACkB;CACrB,MAAM,EAAE,UAAU,gBAAgB;EAAE,GAAG;EAAmB;CAAK,CAAC;CAEhE,OACE,oBAAC,mBAAD;EACa;EACJ;EACC;EACC;CACV,CAAA;AAEL;;ACxDA,IAAA,qBAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/RadioBoxes/radioBoxesVariants.ts","../../src/RadioBoxes/subcomponents/radioBoxVariants.ts","../../src/RadioBoxes/subcomponents/RadioBox.tsx","../../src/RadioBoxes/subcomponents/RadioBoxesControl.tsx","../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nimport radioGroupFieldVariants from '../partials/RadioGroupField/radioGroupFieldVariants';\n\nexport const radioBoxesVariants = tv({\n extend: radioGroupFieldVariants,\n slots: {\n /** Container for the field control and supporting text */\n base: [\n // Needs group for group-data condition.\n 'group',\n // Match shared field wrapper layout.\n 'flex w-full flex-col',\n ],\n /** Clickable option box */\n boxBase: '',\n /** Indicator marking the selected box */\n boxControl: '',\n /** Supporting text inside an option box */\n boxDescription: '',\n /** Primary option text */\n boxLabel: '',\n /** Container grouping option text */\n boxLabelWrapper: '',\n /** Container arranging the selectable content */\n wrapper:\n 'flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row',\n },\n variants: {\n readOnly: {\n true: {\n // drop hover feedback so read-only boxes do not look clickable\n boxBase: 'hover:bg-transparent',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof radioBoxesVariants>;\n\nexport type ClassName = TVClassName<typeof radioBoxesVariants>;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nimport radioControlVariants from '../../Radios/subcomponents/radioControlVariants';\n\nexport const radioBoxVariants = tv({\n slots: {\n /** Container for the field control and supporting text */\n base: [\n // option box layout\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4',\n // box border and padding\n 'rounded-lg border-2 border-default p-4',\n // hover and selection feedback\n 'hover:bg-content2 data-[selected=true]:border-focus',\n ],\n /** Dot marking the selected option */\n control: radioControlVariants.slots.control,\n /** Supporting text for the field */\n description: 'text-small text-foreground opacity-70',\n /** Option state boundary without an additional layout box */\n field: radioControlVariants.slots.field,\n /** Decorative icon beside the option text */\n icon: '',\n /** Visible field label */\n label: radioControlVariants.slots.label,\n /** Container grouping the option label and description */\n labelWrapper: [radioControlVariants.slots.labelWrapper, 'grow'],\n /** Circular outline around the selection indicator */\n wrapper: radioControlVariants.slots.wrapper,\n },\n variants: {\n disabled: {\n true: {\n // keep pointer events so the disabled cursor shows, the input blocks changes\n base: 'cursor-not-allowed opacity-disabled **:cursor-not-allowed hover:bg-transparent',\n },\n },\n invalid: {\n true: {\n base: '!border-danger',\n control: radioControlVariants.variants.invalid.true.control,\n label: radioControlVariants.variants.invalid.true.label,\n wrapper: radioControlVariants.variants.invalid.true.wrapper,\n },\n },\n },\n});\n\nexport type ClassName = TVClassName<typeof radioBoxVariants>;\n","import type { ReactNode } from 'react';\nimport type { ClassName } from './radioBoxVariants';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport RadioControl from '../../Radios/subcomponents/RadioControl';\nimport { radioBoxVariants } from './radioBoxVariants';\n\nexport interface RadioBoxProps {\n /** Option label. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Legacy alias for className */\n classNames?: ClassName;\n /** HTML test ID for the option. */\n 'data-testid'?: string;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the option */\n disabled?: boolean;\n /** icon for the option */\n icon?: ReactNode;\n /** Marks the option as invalid */\n invalid?: boolean;\n /** String value managed by the containing radio group. */\n value: string;\n}\n\n/**\n * Selectable radio box with an icon, supporting text and selection indicator\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nexport const RadioBox = ({\n className = undefined,\n classNames: _classNames = undefined,\n icon = undefined,\n invalid = false,\n disabled = false,\n description = undefined,\n children = undefined,\n value,\n ...props\n}: RadioBoxProps) => {\n const styling = useStyling();\n\n // classNames from slots\n const variants = styling.resolve(radioBoxVariants, { disabled, invalid });\n const classNames = styling.variantsToClassNames(\n variants,\n _classNames ?? className,\n 'base',\n );\n\n return (\n <RadioControl\n className={classNames}\n description={description}\n disabled={disabled}\n icon={icon}\n invalid={invalid}\n testId={props['data-testid']}\n value={value}\n >\n {children}\n </RadioControl>\n );\n};\n\nexport default RadioBox;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { RadioBoxesProps } from '../RadioBoxes';\n\nimport { Label } from 'react-aria-components';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { createOptionValueConverter } from '../../helpers';\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport FieldLayout from '../../partials/FieldLayout/FieldLayout';\nimport RadioGroupField from '../../partials/RadioGroupField/RadioGroupField';\nimport { radioBoxesVariants } from '../radioBoxesVariants';\nimport { RadioBox } from './RadioBox';\n\ninterface RadioBoxesControlProps extends Pick<\n RadioBoxesProps,\n 'className' | 'inline' | 'options'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, string | number | boolean>;\n}\n\n/**\n * Radio boxes with shared group layout and focus routing\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nconst RadioBoxesControl = ({\n field,\n className,\n inline = false,\n options,\n}: RadioBoxesControlProps) => {\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 value,\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 const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = styling.resolve(radioBoxesVariants, { readOnly });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n // restore the selected option's original value type\n const handleChange = (nextValue: string) => {\n onValueChange(convertToOriginalType(nextValue));\n };\n\n return (\n <FieldLayout\n baseAs={RadioGroupField}\n baseProps={{\n controlProps,\n dataComponent: 'radio-boxes',\n disabled,\n inline,\n inputRef,\n invalid,\n name,\n onBlur,\n onChange: handleChange,\n readOnly,\n required,\n testId,\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 <div\n className={classNames.wrapper}\n data-orientation={inline ? 'horizontal' : 'vertical'}\n data-slot=\"wrapper\"\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n className={{\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n }}\n data-testid={optionTestId}\n description={option.description}\n disabled={!!disabled || option.disabled}\n icon={option.icon}\n invalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </div>\n </FieldLayout>\n );\n};\n\nexport default RadioBoxesControl;\n","import type { ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './radioBoxesVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport RadioBoxesControl from './subcomponents/RadioBoxesControl';\n\nexport { radioBoxesVariants } from './radioBoxesVariants';\n\nexport interface RadioBoxOption {\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** option icon */\n icon?: ReactNode;\n /** Field label */\n label?: ReactNode;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\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 /** Field name */\n name: string;\n /** Available options */\n options: RadioBoxOption[];\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}\n\n/** Form selection field for one option displayed as a box */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const { field } = useUniformField({ ...uniformFieldProps, name });\n\n return (\n <RadioBoxesControl\n className={className}\n field={field}\n inline={inline}\n options={options}\n />\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps, RadioBoxOption } from './RadioBoxes';\n\nexport { radioBoxesVariants } from './radioBoxesVariants';\n\nexport { radioBoxVariants } from './subcomponents/radioBoxVariants';\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;;AAMA,MAAa,qBAAqB,GAAG;CACnC,QAAQ;CACR,OAAO;;EAEL,MAAM,CAEJ,SAEA,sBACF;;EAEA,SAAS;;EAET,YAAY;;EAEZ,gBAAgB;;EAEhB,UAAU;;EAEV,iBAAiB;;EAEjB,SACE;CACJ;CACA,UAAU,EACR,UAAU,EACR,MAAM,EAEJ,SAAS,uBACX,EACF,EAC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