@fuf-stack/uniform 1.28.0 → 2.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +6 -35
  2. package/dist/Checkboxes/index.d.mts +192 -263
  3. package/dist/Checkboxes/index.d.mts.map +1 -1
  4. package/dist/Checkboxes/index.mjs +294 -90
  5. package/dist/Checkboxes/index.mjs.map +1 -1
  6. package/dist/DatePicker/index.d.mts +1278 -496
  7. package/dist/DatePicker/index.d.mts.map +1 -1
  8. package/dist/DatePicker/index.mjs +403 -83
  9. package/dist/DatePicker/index.mjs.map +1 -1
  10. package/dist/FieldArray/index.d.mts +105 -98
  11. package/dist/FieldArray/index.d.mts.map +1 -1
  12. package/dist/FieldArray/index.mjs +344 -195
  13. package/dist/FieldArray/index.mjs.map +1 -1
  14. package/dist/FieldCard/index.d.mts +37 -35
  15. package/dist/FieldCard/index.d.mts.map +1 -1
  16. package/dist/FieldCard/index.mjs +187 -128
  17. package/dist/FieldCard/index.mjs.map +1 -1
  18. package/dist/{FieldCopyTestIdButton-9xTF-DBW.mjs → FieldCopyTestIdButton-DV0tkdh2.mjs} +4 -2
  19. package/dist/FieldCopyTestIdButton-DV0tkdh2.mjs.map +1 -0
  20. package/dist/FieldDescription-C4l0HKGL.mjs +36 -0
  21. package/dist/FieldDescription-C4l0HKGL.mjs.map +1 -0
  22. package/dist/FieldLabel-DKzqkuY1.mjs +125 -0
  23. package/dist/FieldLabel-DKzqkuY1.mjs.map +1 -0
  24. package/dist/FieldLayout-BLW5S-Jm.mjs +46 -0
  25. package/dist/FieldLayout-BLW5S-Jm.mjs.map +1 -0
  26. package/dist/FieldValidationError-DgkCL3cC.mjs +77 -0
  27. package/dist/FieldValidationError-DgkCL3cC.mjs.map +1 -0
  28. package/dist/Form/index.d.mts +12 -12
  29. package/dist/Form/index.d.mts.map +1 -1
  30. package/dist/Form/index.mjs +9 -7
  31. package/dist/Form/index.mjs.map +1 -1
  32. package/dist/{FormContext-CB7Glm02.mjs → FormContext-CHctWFAP.mjs} +51 -8
  33. package/dist/FormContext-CHctWFAP.mjs.map +1 -0
  34. package/dist/FormContext-CsFiNvuJ.d.mts.map +1 -1
  35. package/dist/Grid/index.mjs +1 -2
  36. package/dist/{Grid-CTs-Rb9G.mjs → Grid-DfcZeuib.mjs} +4 -2
  37. package/dist/Grid-DfcZeuib.mjs.map +1 -0
  38. package/dist/Input/index.d.mts +638 -394
  39. package/dist/Input/index.d.mts.map +1 -1
  40. package/dist/Input/index.mjs +414 -165
  41. package/dist/Input/index.mjs.map +1 -1
  42. package/dist/RadioBoxes/index.d.mts +1588 -125
  43. package/dist/RadioBoxes/index.d.mts.map +1 -1
  44. package/dist/RadioBoxes/index.mjs +159 -114
  45. package/dist/RadioBoxes/index.mjs.map +1 -1
  46. package/dist/RadioTabs/index.d.mts +300 -81
  47. package/dist/RadioTabs/index.d.mts.map +1 -1
  48. package/dist/RadioTabs/index.mjs +277 -86
  49. package/dist/RadioTabs/index.mjs.map +1 -1
  50. package/dist/Radios/index.d.mts +1354 -109
  51. package/dist/Radios/index.d.mts.map +1 -1
  52. package/dist/Radios/index.mjs +105 -54
  53. package/dist/Radios/index.mjs.map +1 -1
  54. package/dist/Select/index.d.mts +554 -3009
  55. package/dist/Select/index.d.mts.map +1 -1
  56. package/dist/Select/index.mjs +319 -177
  57. package/dist/Select/index.mjs.map +1 -1
  58. package/dist/Slider/index.d.mts +416 -1328
  59. package/dist/Slider/index.d.mts.map +1 -1
  60. package/dist/Slider/index.mjs +276 -94
  61. package/dist/Slider/index.mjs.map +1 -1
  62. package/dist/SubmitButton/index.d.mts.map +1 -1
  63. package/dist/SubmitButton/index.mjs +4 -1
  64. package/dist/SubmitButton/index.mjs.map +1 -1
  65. package/dist/Switch/index.d.mts +2 -1248
  66. package/dist/Switch/index.mjs +167 -68
  67. package/dist/Switch/index.mjs.map +1 -1
  68. package/dist/Switch-CvPO8IF9.d.mts +601 -0
  69. package/dist/Switch-CvPO8IF9.d.mts.map +1 -0
  70. package/dist/SwitchBox/index.d.mts +135 -39
  71. package/dist/SwitchBox/index.d.mts.map +1 -1
  72. package/dist/SwitchBox/index.mjs +142 -87
  73. package/dist/SwitchBox/index.mjs.map +1 -1
  74. package/dist/TextArea/index.d.mts +295 -411
  75. package/dist/TextArea/index.d.mts.map +1 -1
  76. package/dist/TextArea/index.mjs +200 -48
  77. package/dist/TextArea/index.mjs.map +1 -1
  78. package/dist/Time/index.d.mts +1170 -601
  79. package/dist/Time/index.d.mts.map +1 -1
  80. package/dist/Time/index.mjs +162 -74
  81. package/dist/Time/index.mjs.map +1 -1
  82. package/dist/helpers/index.d.mts +1 -1
  83. package/dist/helpers/index.mjs +1 -1
  84. package/dist/helpers/index.mjs.map +1 -1
  85. package/dist/hooks/useClientValidation/index.mjs +1 -1
  86. package/dist/hooks/useController/index.d.mts +31 -3
  87. package/dist/hooks/useController/index.d.mts.map +1 -0
  88. package/dist/hooks/useController/index.mjs +1 -2
  89. package/dist/hooks/useFormContext/index.d.mts +65 -3
  90. package/dist/hooks/useFormContext/index.d.mts.map +1 -0
  91. package/dist/hooks/useFormContext/index.mjs +1 -2
  92. package/dist/hooks/useInputValueDebounce/index.d.mts +11 -5
  93. package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
  94. package/dist/hooks/useInputValueDebounce/index.mjs +27 -5
  95. package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
  96. package/dist/hooks/useInputValueTransform/index.d.mts +1 -2
  97. package/dist/hooks/useInputValueTransform/index.mjs +1 -2
  98. package/dist/hooks/useWatchFormReset/index.mjs +1 -1
  99. package/dist/hooks/useWatchUserChange/index.d.mts +2 -2
  100. package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
  101. package/dist/hooks/useWatchUserChange/index.mjs +1 -1
  102. package/dist/hooks/useWatchUserChange/index.mjs.map +1 -1
  103. package/dist/{useInputValueTransform-LOaEim7k.d.mts → index-BS8IoBOn.d.mts} +3 -3
  104. package/dist/index-BS8IoBOn.d.mts.map +1 -0
  105. package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -2
  106. package/dist/partials/FieldValidationError/index.d.mts +637 -3
  107. package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
  108. package/dist/partials/FieldValidationError/index.mjs +1 -2
  109. package/dist/radioControlVariants-Cm6WufWo.mjs +188 -0
  110. package/dist/radioControlVariants-Cm6WufWo.mjs.map +1 -0
  111. package/dist/switchVariants-BaQw2DA7.mjs +67 -0
  112. package/dist/switchVariants-BaQw2DA7.mjs.map +1 -0
  113. package/dist/timeVariants-B9HDfNYt.mjs +58 -0
  114. package/dist/timeVariants-B9HDfNYt.mjs.map +1 -0
  115. package/dist/{useController-BBSbeKbn.mjs → useController-BCFeZbBZ.mjs} +2 -2
  116. package/dist/{useController-BBSbeKbn.mjs.map → useController-BCFeZbBZ.mjs.map} +1 -1
  117. package/dist/{useFormContext-DNb_B8LQ.mjs → useFormContext-BPjJjNnM.mjs} +2 -2
  118. package/dist/{useFormContext-DNb_B8LQ.mjs.map → useFormContext-BPjJjNnM.mjs.map} +1 -1
  119. package/dist/{useInputValueTransform-DJ5zkqSy.mjs → useInputValueTransform-Mw8YEOXT.mjs} +2 -2
  120. package/dist/{useInputValueTransform-DJ5zkqSy.mjs.map → useInputValueTransform-Mw8YEOXT.mjs.map} +1 -1
  121. package/package.json +17 -29
  122. package/dist/FieldCopyTestIdButton-9xTF-DBW.mjs.map +0 -1
  123. package/dist/FieldValidationError-ByRoIxaM.mjs +0 -50
  124. package/dist/FieldValidationError-ByRoIxaM.mjs.map +0 -1
  125. package/dist/FormContext-CB7Glm02.mjs.map +0 -1
  126. package/dist/Grid-CTs-Rb9G.mjs.map +0 -1
  127. package/dist/Switch/index.d.mts.map +0 -1
  128. package/dist/hooks/useInput/index.d.mts +0 -2
  129. package/dist/hooks/useInput/index.mjs +0 -7
  130. package/dist/hooks/useInput/index.mjs.map +0 -1
  131. package/dist/hooks/useUniformField/index.d.mts +0 -100
  132. package/dist/hooks/useUniformField/index.d.mts.map +0 -1
  133. package/dist/hooks/useUniformField/index.mjs +0 -139
  134. package/dist/hooks/useUniformField/index.mjs.map +0 -1
  135. package/dist/hooks/useUniformFieldArray/index.d.mts +0 -73
  136. package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
  137. package/dist/hooks/useUniformFieldArray/index.mjs +0 -101
  138. package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
  139. package/dist/index-CAdGtKE_.d.mts +0 -1
  140. package/dist/index-CaxrMD1A.d.mts +0 -1
  141. package/dist/index-CwJo1b4Z.d.mts +0 -1
  142. package/dist/useController-DcK2YHbw.d.mts +0 -32
  143. package/dist/useController-DcK2YHbw.d.mts.map +0 -1
  144. package/dist/useFormContext-BegmYvGA.d.mts +0 -66
  145. package/dist/useFormContext-BegmYvGA.d.mts.map +0 -1
  146. package/dist/useInput-C0aJaAGe.mjs +0 -2
  147. package/dist/useInput-ClpHDPdr.d.mts +0 -2
  148. package/dist/useInputValueTransform-LOaEim7k.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/RadioBox.tsx"],"mappings":";;;;cAaa,sBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCnB,eAAe,eAAe;KAE9B,YAAY,mBAAmB;;;UCjC1B;;EAEf,cAAc;;EAEd;;EAEA,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;UAGe,wBAAwB;;EAEvC;;EAEA,YAAY;;EAEZ,cAAc;;EAEd;;EAEA;;EAEA,QAAQ;;EAER;;EAEA,SAAS;;EAET;;;cAII,eAAc,WAAA,QAAA,MAAA,YAAA,qBAMjB,oCAAe,IAAA;;;qBC7CL,oBAAgB"}
@@ -1,144 +1,189 @@
1
1
  import { createOptionValueConverter } from "../helpers/index.mjs";
2
- import { useUniformField } from "../hooks/useUniformField/index.mjs";
3
- import { cn, slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- import { RadioGroup, useRadio } from "@heroui/radio";
6
- import { VisuallyHidden } from "@react-aria/visually-hidden";
7
- //#region src/RadioBoxes/RadioBox.tsx
2
+ import { n as useUniformField } from "../FieldLabel-DKzqkuY1.mjs";
3
+ import { n as getFieldControlProps } from "../FieldDescription-C4l0HKGL.mjs";
4
+ import { t as FieldLayout } from "../FieldLayout-BLW5S-Jm.mjs";
5
+ import { i as RadioGroupField, n as RadioControl, r as radioGroupFieldVariants, t as radioControlVariants } from "../radioControlVariants-Cm6WufWo.mjs";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { slugify, tv } from "@fuf-stack/pixel-utils";
8
+ import { useStyling } from "@fuf-stack/pixels/StylingProvider";
9
+ import { Label } from "react-aria-components";
10
+ //#region src/RadioBoxes/radioBoxesVariants.ts
11
+ const radioBoxesVariants = tv({
12
+ extend: radioGroupFieldVariants,
13
+ slots: {
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
+ ],
20
+ /** Clickable option box */
21
+ boxBase: "",
22
+ /** Indicator marking the selected box */
23
+ boxControl: "",
24
+ /** Supporting text inside an option box */
25
+ boxDescription: "",
26
+ /** Primary option text */
27
+ boxLabel: "",
28
+ /** Container grouping option text */
29
+ 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
+ /** Container arranging the selectable content */
35
+ wrapper: "flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row"
36
+ }
37
+ });
38
+ //#endregion
39
+ //#region src/RadioBoxes/subcomponents/radioBoxVariants.ts
8
40
  const radioBoxVariants = tv({
9
41
  slots: {
10
- base: "group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus",
11
- control: "",
42
+ /** Container for the field control and supporting text */
43
+ base: [
44
+ "group inline-flex flex-auto cursor-pointer items-center justify-between gap-4",
45
+ "rounded-lg border-2 border-default p-4",
46
+ "hover:bg-content2 data-[selected=true]:border-focus"
47
+ ],
48
+ /** Dot marking the selected option */
49
+ control: radioControlVariants.slots.control,
50
+ /** Supporting text for the field */
12
51
  description: "text-foreground opacity-70 text-small",
52
+ /** Option state boundary without an additional layout box */
53
+ field: radioControlVariants.slots.field,
54
+ /** Decorative icon beside the option text */
13
55
  icon: "",
14
- label: "",
15
- labelWrapper: "grow"
56
+ /** Visible field label */
57
+ label: radioControlVariants.slots.label,
58
+ /** Container grouping the option label and description */
59
+ labelWrapper: [radioControlVariants.slots.labelWrapper, "grow"],
60
+ /** Circular outline around the selection indicator */
61
+ wrapper: radioControlVariants.slots.wrapper
16
62
  },
17
63
  variants: {
18
64
  isDisabled: { true: { base: "pointer-events-none opacity-disabled" } },
19
- isInvalid: { true: { base: "!border-danger" } }
65
+ isInvalid: { true: {
66
+ base: "!border-danger",
67
+ control: radioControlVariants.variants.invalid.true.control,
68
+ label: radioControlVariants.variants.invalid.true.label,
69
+ wrapper: radioControlVariants.variants.invalid.true.wrapper
70
+ } }
20
71
  }
21
72
  });
22
- const RadioBox = ({ classNames: _classNames = void 0, icon = void 0, isInvalid = false, ...props }) => {
23
- const { children, Component, description, getBaseProps, getControlProps, getInputProps, getLabelProps, getLabelWrapperProps, getWrapperProps, isDisabled } = useRadio(props);
24
- const variants = radioBoxVariants({
73
+ //#endregion
74
+ //#region src/RadioBoxes/subcomponents/RadioBox.tsx
75
+ /**
76
+ * Selectable radio box with an icon, supporting text and selection indicator
77
+ *
78
+ * @see https://react-aria.adobe.com/RadioGroup
79
+ */
80
+ const RadioBox = ({ className = void 0, classNames: _classNames = void 0, icon = void 0, isInvalid = false, isDisabled = false, description = void 0, children = void 0, value, ...props }) => {
81
+ const styling = useStyling();
82
+ const variants = styling.resolve(radioBoxVariants, {
25
83
  isDisabled,
26
84
  isInvalid
27
85
  });
28
- const classNames = variantsToClassNames(variants, _classNames, "base");
29
- return /* @__PURE__ */ jsxs(Component, {
30
- ...getBaseProps(),
31
- className: classNames.base,
32
- children: [
33
- /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...getInputProps() }) }),
34
- !icon ? /* @__PURE__ */ jsx("span", {
35
- ...getWrapperProps(),
36
- children: /* @__PURE__ */ jsx("span", {
37
- ...getControlProps(),
38
- className: cn(getControlProps().className, classNames.control)
39
- })
40
- }) : null,
41
- icon ? /* @__PURE__ */ jsx("div", {
42
- className: classNames.icon,
43
- children: icon
44
- }) : null,
45
- /* @__PURE__ */ jsxs("div", {
46
- ...getLabelWrapperProps(),
47
- className: cn(getLabelWrapperProps().className, classNames.labelWrapper),
48
- children: [children ? /* @__PURE__ */ jsx("span", {
49
- ...getLabelProps(),
50
- className: cn(getLabelProps().className, classNames.label),
51
- children
52
- }) : null, description ? /* @__PURE__ */ jsx("div", {
53
- className: classNames.description,
54
- children: description
55
- }) : null]
56
- }),
57
- icon ? /* @__PURE__ */ jsx("span", {
58
- ...getWrapperProps(),
59
- children: /* @__PURE__ */ jsx("span", {
60
- ...getControlProps(),
61
- className: cn(getControlProps().className, classNames.control)
62
- })
63
- }) : null
64
- ]
86
+ const classNames = styling.variantsToClassNames(variants, _classNames ?? className, "base");
87
+ return /* @__PURE__ */ jsx(RadioControl, {
88
+ className: classNames,
89
+ description,
90
+ disabled: isDisabled,
91
+ icon,
92
+ invalid: isInvalid,
93
+ testId: props["data-testid"],
94
+ value,
95
+ children
65
96
  });
66
97
  };
67
98
  //#endregion
68
- //#region src/RadioBoxes/RadioBoxes.tsx
69
- const radioBoxesVariants = tv({ slots: {
70
- base: [
71
- "group",
72
- "flex w-full flex-col",
73
- "gap-y-1.5"
74
- ],
75
- boxBase: "",
76
- boxControl: "",
77
- boxDescription: "",
78
- boxLabel: "",
79
- boxLabelWrapper: "",
80
- label: "mb-2 inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
81
- wrapper: ""
82
- } });
99
+ //#region src/RadioBoxes/subcomponents/RadioBoxesControl.tsx
83
100
  /**
84
- * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)
101
+ * Radio boxes with shared group layout and focus routing
102
+ *
103
+ * @see https://react-aria.adobe.com/RadioGroup
85
104
  */
86
- const RadioBoxes = ({ className = void 0, inline = false, name, options, ...uniformFieldProps }) => {
87
- const { ariaLabel, errorMessage, invalid, disabled, label, field: { onBlur, onChange, ref, value }, required, testId } = useUniformField({
88
- name,
89
- ...uniformFieldProps
90
- });
105
+ const RadioBoxesControl = ({ field, className, inline = false, options }) => {
106
+ const { description, disabled, errorMessage, ids, ref: inputRef, invalid, label, name, onBlur, onChange: onValueChange, required, testId, value } = field;
107
+ const controlProps = getFieldControlProps(field);
108
+ const styling = useStyling();
91
109
  const { convertToOriginalType } = createOptionValueConverter(options);
92
- const variants = radioBoxesVariants();
93
- const classNames = variantsToClassNames(variants, className, "base");
94
- const boxClassNames = {
95
- base: classNames.boxBase,
96
- control: classNames.boxControl,
97
- description: classNames.boxDescription,
98
- label: classNames.boxLabel,
99
- labelWrapper: classNames.boxLabelWrapper
110
+ const variants = styling.resolve(radioBoxesVariants);
111
+ const classNames = styling.variantsToClassNames(variants, className, "base");
112
+ const handleChange = (nextValue) => {
113
+ onValueChange(convertToOriginalType(nextValue));
100
114
  };
101
- return /* @__PURE__ */ jsx(RadioGroup, {
102
- ref,
103
- "aria-label": ariaLabel,
104
- classNames,
105
- "data-invalid": invalid,
106
- "data-required": required,
107
- "data-testid": testId,
108
- errorMessage,
109
- isDisabled: disabled,
110
- isInvalid: invalid,
111
- isRequired: required,
112
- label: label ? /* @__PURE__ */ jsx("legend", { children: label }) : null,
113
- name,
114
- onBlur,
115
- onValueChange: (newValue) => {
116
- onChange(convertToOriginalType(newValue));
115
+ return /* @__PURE__ */ jsx(FieldLayout, {
116
+ baseAs: RadioGroupField,
117
+ baseProps: {
118
+ controlProps,
119
+ dataComponent: "radio-boxes",
120
+ disabled,
121
+ inline,
122
+ inputRef,
123
+ invalid,
124
+ name,
125
+ onBlur,
126
+ onChange: handleChange,
127
+ required,
128
+ testId,
129
+ value
117
130
  },
118
- orientation: inline ? "horizontal" : "vertical",
119
- value: value != null ? String(value) : "",
120
- children: options.map((option) => {
121
- if ("value" in option) {
122
- const optionTestId = slugify(`${testId}_option_${option.testId ?? option.value}`, { replaceDots: true });
123
- return /* @__PURE__ */ jsx(RadioBox, {
124
- classNames: boxClassNames,
125
- "data-testid": optionTestId,
126
- description: option.description,
127
- icon: option.icon,
128
- isDisabled: !!disabled || option.disabled,
129
- isInvalid: invalid,
130
- value: String(option.value),
131
- children: option.label ?? option.value
132
- }, String(option.value));
133
- }
134
- return null;
131
+ className: classNames,
132
+ description,
133
+ errorMessage,
134
+ ids,
135
+ invalid,
136
+ label,
137
+ labelAs: Label,
138
+ required,
139
+ children: /* @__PURE__ */ jsx("div", {
140
+ className: classNames.wrapper,
141
+ "data-orientation": inline ? "horizontal" : "vertical",
142
+ "data-slot": "wrapper",
143
+ children: options.map((option) => {
144
+ if ("value" in option) {
145
+ const optionTestId = slugify(`${testId}_option_${option.testId ?? option.value}`, { replaceDots: true });
146
+ return /* @__PURE__ */ jsx(RadioBox, {
147
+ className: {
148
+ base: classNames.boxBase,
149
+ control: classNames.boxControl,
150
+ description: classNames.boxDescription,
151
+ label: classNames.boxLabel,
152
+ labelWrapper: classNames.boxLabelWrapper
153
+ },
154
+ "data-testid": optionTestId,
155
+ description: option.description,
156
+ icon: option.icon,
157
+ isDisabled: !!disabled || option.disabled,
158
+ isInvalid: invalid,
159
+ value: String(option.value),
160
+ children: option.label ?? option.value
161
+ }, String(option.value));
162
+ }
163
+ return null;
164
+ })
135
165
  })
136
166
  });
137
167
  };
138
168
  //#endregion
169
+ //#region src/RadioBoxes/RadioBoxes.tsx
170
+ /** Form selection field for one option displayed as a box */
171
+ const RadioBoxes = ({ className = void 0, inline = false, name, options, ...uniformFieldProps }) => {
172
+ const { field } = useUniformField({
173
+ ...uniformFieldProps,
174
+ name
175
+ });
176
+ return /* @__PURE__ */ jsx(RadioBoxesControl, {
177
+ className,
178
+ field,
179
+ inline,
180
+ options
181
+ });
182
+ };
183
+ //#endregion
139
184
  //#region src/RadioBoxes/index.ts
140
185
  var RadioBoxes_default = RadioBoxes;
141
186
  //#endregion
142
- export { RadioBoxes_default as default, radioBoxVariants };
187
+ export { RadioBoxes_default as default, radioBoxVariants, radioBoxesVariants };
143
188
 
144
189
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["HeroRadioGroup"],"sources":["../../src/RadioBoxes/RadioBox.tsx","../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\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 boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n errorMessage,\n invalid,\n disabled,\n label,\n field: { onBlur, onChange, ref, value },\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={(newValue) => {\n onChange(convertToOriginalType(newValue));\n }}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value != null ? String(value) : ''}\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 classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps, RadioBoxOption } from './RadioBoxes';\n\nexport { radioBoxVariants } from './RadioBox';\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;CAChB;CACA,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,uCACR,EACF;EACA,WAAW,EACT,MAAM,EACJ,MAAM,iBACR,EACF;CACF;AACF,CAAC;AAaD,MAAa,YAAY,EACvB,YAAY,cAAc,KAAA,GAC1B,OAAO,KAAA,GACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,KAAuB;CAGpC,MAAM,WAAW,iBAAiB;EAChC;EACA;CACF,CAAC;CACD,MAAM,aAAa,qBACjB,UAEA,aACA,MACF;CAE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A,WACE,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,EAAE,0BAA0B,2BAA2B,OAAO;CAGpE,MAAM,WAAW,mBAAmB;CACpC,MAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;CACnE,MAAM,gBAA6C;EACjD,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;CAC3B;CAEA,OACE,oBAACA,YAAD;EACO;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,oBAAC,UAAD,EAAA,UAAS,MAAc,CAAA,IAAI;EACpC;EACE;EACR,gBAAgB,aAAa;GAC3B,SAAS,sBAAsB,QAAQ,CAAC;EAC1C;EACA,aAAa,SAAS,eAAe;EACrC,OAAO,SAAS,OAAO,OAAO,KAAK,IAAI;EAEtC,UAAA,QAAQ,KAAK,WAAW;GACvB,IAAI,WAAW,QAAQ;IACrB,MAAM,eAAe,QACnB,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,KAAK,CACtB;IACA,OACE,oBAAC,UAAD;KAEE,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO,OAAO,KAAK;KAEzB,UAAA,OAAO,SAAS,OAAO;IAChB,GAVH,OAAO,OAAO,KAAK,CAUhB;GAEd;GACA,OAAO;EACT,CAAC;CACa,CAAA;AAEpB;;;ACzJA,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 // 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});\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 isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\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 /** icon for the option */\n icon?: ReactNode;\n /** Whether the option is disabled. */\n isDisabled?: boolean;\n /** whether the radio is invalid */\n isInvalid?: 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 isInvalid = false,\n isDisabled = 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, { isDisabled, isInvalid });\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={isDisabled}\n icon={icon}\n invalid={isInvalid}\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 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);\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 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 icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={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 /** 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;AACF,CAAC;;;AC/BD,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,YAAY,EACV,MAAM,EACJ,MAAM,uCACR,EACF;EACA,WAAW,EACT,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;;;;;;;;ACbD,MAAa,YAAY,EACvB,YAAY,KAAA,GACZ,YAAY,cAAc,KAAA,GAC1B,OAAO,KAAA,GACP,YAAY,OACZ,aAAa,OACb,cAAc,KAAA,GACd,WAAW,KAAA,GACX,OACA,GAAG,YACgB;CACnB,MAAM,UAAU,WAAW;CAG3B,MAAM,WAAW,QAAQ,QAAQ,kBAAkB;EAAE;EAAY;CAAU,CAAC;CAC5E,MAAM,a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