@fuf-stack/uniform 1.30.0 → 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.
- package/README.md +0 -6
- package/dist/Checkboxes/index.d.mts +178 -274
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +294 -94
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +1963 -148
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +401 -82
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +102 -97
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +340 -195
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +34 -34
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +181 -127
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-Y9SfvaM9.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +4 -2
- package/dist/FieldCopyTestIdButton-D3_jZYJ1.mjs.map +1 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs +35 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
- package/dist/FieldLabel-DrNWJIVh.mjs +128 -0
- package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
- package/dist/FieldLayout-DcvQU0zN.mjs +45 -0
- package/dist/FieldLayout-DcvQU0zN.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +17 -12
- package/dist/FieldReset/index.d.mts.map +1 -1
- package/dist/FieldReset/index.mjs +50 -33
- package/dist/FieldReset/index.mjs.map +1 -1
- package/dist/FieldValidationError-iAayfTEw.mjs +75 -0
- package/dist/FieldValidationError-iAayfTEw.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +9 -7
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-Dvt3MiKq.d.mts → FormContext-BnNJYZOo.d.mts} +3 -3
- package/dist/{FormContext-Dvt3MiKq.d.mts.map → FormContext-BnNJYZOo.d.mts.map} +1 -1
- package/dist/{FormContext-B8G_Xxd6.mjs → FormContext-PXkVlBdU.mjs} +6 -2
- package/dist/FormContext-PXkVlBdU.mjs.map +1 -0
- package/dist/Grid/index.mjs +1 -1
- package/dist/{Grid-Us2JFczS.mjs → Grid-DBL29Kwb.mjs} +4 -2
- package/dist/Grid-DBL29Kwb.mjs.map +1 -0
- package/dist/Input/index.d.mts +734 -47
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +411 -168
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +300 -98
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +156 -119
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +302 -76
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +274 -87
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +314 -78
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +90 -44
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +410 -142
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +284 -157
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +382 -63
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +269 -90
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +4 -1
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +2 -427
- package/dist/Switch/index.mjs +167 -72
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-Db2dpGz7.d.mts +648 -0
- package/dist/Switch-Db2dpGz7.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +191 -91
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +142 -88
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +347 -29
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +195 -47
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +1373 -139
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +160 -77
- package/dist/Time/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.d.mts +29 -2
- package/dist/hooks/useController/index.d.mts.map +1 -0
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +44 -2
- package/dist/hooks/useFormContext/index.d.mts.map +1 -0
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.mts +9 -3
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +27 -5
- package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -2
- package/dist/hooks/useInputValueTransform/index.mjs +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{useInputValueTransform-cevZBrIN.d.mts → index-cevZBrIN.d.mts} +1 -1
- package/dist/index-cevZBrIN.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
- package/dist/partials/FieldValidationError/index.d.mts +637 -3
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs +187 -0
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
- package/dist/switchVariants-D16b2VaT.mjs +67 -0
- package/dist/switchVariants-D16b2VaT.mjs.map +1 -0
- package/dist/timeVariants-CtXyNKmW.mjs +58 -0
- package/dist/timeVariants-CtXyNKmW.mjs.map +1 -0
- package/dist/{useController-CJjMqXU5.mjs → useController-JtIeurpw.mjs} +2 -2
- package/dist/{useController-CJjMqXU5.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
- package/dist/{useFormContext-BEjPBdzb.mjs → useFormContext-piqnN2L-.mjs} +2 -2
- package/dist/{useFormContext-BEjPBdzb.mjs.map → useFormContext-piqnN2L-.mjs.map} +1 -1
- package/dist/{useInputValueTransform-D44BLp1Z.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -2
- package/dist/{useInputValueTransform-D44BLp1Z.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
- package/package.json +13 -25
- package/dist/FieldCopyTestIdButton-Y9SfvaM9.mjs.map +0 -1
- package/dist/FieldValidationError-BcUV0r1I.mjs +0 -48
- package/dist/FieldValidationError-BcUV0r1I.mjs.map +0 -1
- package/dist/FormContext-B8G_Xxd6.mjs.map +0 -1
- package/dist/Grid-Us2JFczS.mjs.map +0 -1
- package/dist/Switch/index.d.mts.map +0 -1
- package/dist/hooks/useInput/index.d.mts +0 -2
- package/dist/hooks/useInput/index.mjs +0 -5
- package/dist/hooks/useInput/index.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts +0 -2
- package/dist/hooks/useUniformField/index.mjs +0 -141
- package/dist/hooks/useUniformField/index.mjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +0 -47
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +0 -99
- package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
- package/dist/index-CaxrMD1A.d.mts +0 -1
- package/dist/index-DsB0_365.d.mts +0 -106
- package/dist/index-DsB0_365.d.mts.map +0 -1
- package/dist/useController-CdFEp-Wa.d.mts +0 -30
- package/dist/useController-CdFEp-Wa.d.mts.map +0 -1
- package/dist/useFormContext-BSSUZ0Md.d.mts +0 -45
- package/dist/useFormContext-BSSUZ0Md.d.mts.map +0 -1
- package/dist/useInput-ClpHDPdr.d.mts +0 -2
- package/dist/useInput-NPbS4w_n.mjs +0 -1
- package/dist/useInputValueTransform-cevZBrIN.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/RadioBoxes/RadioBoxes.tsx","../../src/RadioBoxes/
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyCnB,eAAe,eAAe;KAE9B,YAAY,mBAAmB;UCzC1B;;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,148 +1,185 @@
|
|
|
1
|
+
import { n as useUniformField } from "../FieldLabel-DrNWJIVh.mjs";
|
|
1
2
|
import { createOptionValueConverter } from "../helpers/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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: "",
|
|
12
|
-
description: "text-foreground opacity-70 text-small",
|
|
13
|
-
icon: "",
|
|
14
|
-
label: "",
|
|
15
|
-
labelWrapper: "grow"
|
|
16
|
-
},
|
|
17
|
-
variants: {
|
|
18
|
-
disabled: { true: { base: "**:cursor-not-allowed cursor-not-allowed opacity-disabled hover:bg-transparent" } },
|
|
19
|
-
invalid: { true: { base: "!border-danger" } }
|
|
20
|
-
}
|
|
21
|
-
});
|
|
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({
|
|
25
|
-
disabled: isDisabled,
|
|
26
|
-
invalid: isInvalid
|
|
27
|
-
});
|
|
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
|
-
]
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
// src/RadioBoxes/RadioBoxes.tsx
|
|
3
|
+
import { n as getFieldControlProps } from "../FieldDescription-X_0s1Lhu.mjs";
|
|
4
|
+
import { t as FieldLayout } from "../FieldLayout-DcvQU0zN.mjs";
|
|
5
|
+
import { i as RadioGroupField, n as RadioControl, r as radioGroupFieldVariants, t as radioControlVariants } from "../radioControlVariants-BYRfaD6y.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
|
+
// src/RadioBoxes/radioBoxesVariants.ts
|
|
68
11
|
const radioBoxesVariants = tv({
|
|
12
|
+
extend: radioGroupFieldVariants,
|
|
69
13
|
slots: {
|
|
14
|
+
/** Container for the field control and supporting text */
|
|
70
15
|
base: [
|
|
71
16
|
"group",
|
|
72
17
|
"flex w-full flex-col",
|
|
73
18
|
"gap-y-1.5"
|
|
74
19
|
],
|
|
20
|
+
/** Clickable option box */
|
|
75
21
|
boxBase: "",
|
|
22
|
+
/** Indicator marking the selected box */
|
|
76
23
|
boxControl: "",
|
|
24
|
+
/** Supporting text inside an option box */
|
|
77
25
|
boxDescription: "",
|
|
26
|
+
/** Primary option text */
|
|
78
27
|
boxLabel: "",
|
|
28
|
+
/** Container grouping option text */
|
|
79
29
|
boxLabelWrapper: "",
|
|
30
|
+
/** Container for validation messages */
|
|
31
|
+
errorMessage: "text-danger text-tiny",
|
|
32
|
+
/** Visible field label */
|
|
80
33
|
label: "mb-2 inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
|
|
81
|
-
|
|
34
|
+
/** Container arranging the selectable content */
|
|
35
|
+
wrapper: "flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row"
|
|
36
|
+
},
|
|
37
|
+
variants: { readOnly: { true: { boxBase: "hover:bg-transparent" } } }
|
|
38
|
+
});
|
|
39
|
+
// src/RadioBoxes/subcomponents/radioBoxVariants.ts
|
|
40
|
+
const radioBoxVariants = tv({
|
|
41
|
+
slots: {
|
|
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 */
|
|
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 */
|
|
55
|
+
icon: "",
|
|
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
|
|
82
62
|
},
|
|
83
|
-
variants: {
|
|
84
|
-
base: "
|
|
85
|
-
|
|
86
|
-
|
|
63
|
+
variants: {
|
|
64
|
+
disabled: { true: { base: "cursor-not-allowed opacity-disabled **:cursor-not-allowed hover:bg-transparent" } },
|
|
65
|
+
invalid: { 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
|
+
} }
|
|
71
|
+
}
|
|
87
72
|
});
|
|
73
|
+
// src/RadioBoxes/subcomponents/RadioBox.tsx
|
|
88
74
|
/**
|
|
89
|
-
*
|
|
75
|
+
* Selectable radio box with an icon, supporting text and selection indicator
|
|
76
|
+
*
|
|
77
|
+
* @see https://react-aria.adobe.com/RadioGroup
|
|
90
78
|
*/
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
const RadioBox = ({ className = void 0, classNames: _classNames = void 0, icon = void 0, invalid = false, disabled = false, description = void 0, children = void 0, value, ...props }) => {
|
|
80
|
+
const styling = useStyling();
|
|
81
|
+
const variants = styling.resolve(radioBoxVariants, {
|
|
82
|
+
disabled,
|
|
83
|
+
invalid
|
|
84
|
+
});
|
|
85
|
+
const classNames = styling.variantsToClassNames(variants, _classNames ?? className, "base");
|
|
86
|
+
return /* @__PURE__ */ jsx(RadioControl, {
|
|
87
|
+
className: classNames,
|
|
88
|
+
description,
|
|
89
|
+
disabled,
|
|
90
|
+
icon,
|
|
91
|
+
invalid,
|
|
92
|
+
testId: props["data-testid"],
|
|
93
|
+
value,
|
|
94
|
+
children
|
|
95
95
|
});
|
|
96
|
+
};
|
|
97
|
+
// src/RadioBoxes/subcomponents/RadioBoxesControl.tsx
|
|
98
|
+
/**
|
|
99
|
+
* Radio boxes with shared group layout and focus routing
|
|
100
|
+
*
|
|
101
|
+
* @see https://react-aria.adobe.com/RadioGroup
|
|
102
|
+
*/
|
|
103
|
+
const RadioBoxesControl = ({ field, className, inline = false, options }) => {
|
|
104
|
+
const { description, disabled, errorMessage, ids, ref: inputRef, invalid, label, name, onBlur, onChange: onValueChange, readOnly, required, testId, value } = field;
|
|
105
|
+
const controlProps = getFieldControlProps(field);
|
|
106
|
+
const styling = useStyling();
|
|
96
107
|
const { convertToOriginalType } = createOptionValueConverter(options);
|
|
97
|
-
const variants = radioBoxesVariants
|
|
98
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
control: classNames.boxControl,
|
|
102
|
-
description: classNames.boxDescription,
|
|
103
|
-
label: classNames.boxLabel,
|
|
104
|
-
labelWrapper: classNames.boxLabelWrapper
|
|
108
|
+
const variants = styling.resolve(radioBoxesVariants, { readOnly });
|
|
109
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
110
|
+
const handleChange = (nextValue) => {
|
|
111
|
+
onValueChange(convertToOriginalType(nextValue));
|
|
105
112
|
};
|
|
106
|
-
return /* @__PURE__ */ jsx(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
onChange(convertToOriginalType(newValue));
|
|
113
|
+
return /* @__PURE__ */ jsx(FieldLayout, {
|
|
114
|
+
baseAs: RadioGroupField,
|
|
115
|
+
baseProps: {
|
|
116
|
+
controlProps,
|
|
117
|
+
dataComponent: "radio-boxes",
|
|
118
|
+
disabled,
|
|
119
|
+
inline,
|
|
120
|
+
inputRef,
|
|
121
|
+
invalid,
|
|
122
|
+
name,
|
|
123
|
+
onBlur,
|
|
124
|
+
onChange: handleChange,
|
|
125
|
+
readOnly,
|
|
126
|
+
required,
|
|
127
|
+
testId,
|
|
128
|
+
value
|
|
123
129
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
className: classNames,
|
|
131
|
+
description,
|
|
132
|
+
errorMessage,
|
|
133
|
+
ids,
|
|
134
|
+
invalid,
|
|
135
|
+
label,
|
|
136
|
+
labelAs: Label,
|
|
137
|
+
required,
|
|
138
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
139
|
+
className: classNames.wrapper,
|
|
140
|
+
"data-orientation": inline ? "horizontal" : "vertical",
|
|
141
|
+
"data-slot": "wrapper",
|
|
142
|
+
children: options.map((option) => {
|
|
143
|
+
if ("value" in option) {
|
|
144
|
+
const optionTestId = slugify(`${testId}_option_${option.testId ?? option.value}`, { replaceDots: true });
|
|
145
|
+
return /* @__PURE__ */ jsx(RadioBox, {
|
|
146
|
+
className: {
|
|
147
|
+
base: classNames.boxBase,
|
|
148
|
+
control: classNames.boxControl,
|
|
149
|
+
description: classNames.boxDescription,
|
|
150
|
+
label: classNames.boxLabel,
|
|
151
|
+
labelWrapper: classNames.boxLabelWrapper
|
|
152
|
+
},
|
|
153
|
+
"data-testid": optionTestId,
|
|
154
|
+
description: option.description,
|
|
155
|
+
disabled: !!disabled || option.disabled,
|
|
156
|
+
icon: option.icon,
|
|
157
|
+
invalid,
|
|
158
|
+
value: String(option.value),
|
|
159
|
+
children: option.label ?? option.value
|
|
160
|
+
}, String(option.value));
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
})
|
|
141
164
|
})
|
|
142
165
|
});
|
|
143
166
|
};
|
|
167
|
+
// src/RadioBoxes/RadioBoxes.tsx
|
|
168
|
+
/** Form selection field for one option displayed as a box */
|
|
169
|
+
const RadioBoxes = ({ className = void 0, inline = false, name, options, ...uniformFieldProps }) => {
|
|
170
|
+
const { field } = useUniformField({
|
|
171
|
+
...uniformFieldProps,
|
|
172
|
+
name
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */ jsx(RadioBoxesControl, {
|
|
175
|
+
className,
|
|
176
|
+
field,
|
|
177
|
+
inline,
|
|
178
|
+
options
|
|
179
|
+
});
|
|
180
|
+
};
|
|
144
181
|
// src/RadioBoxes/index.ts
|
|
145
182
|
var RadioBoxes_default = RadioBoxes;
|
|
146
|
-
export { RadioBoxes_default as default, radioBoxVariants };
|
|
183
|
+
export { RadioBoxes_default as default, radioBoxVariants, radioBoxesVariants };
|
|
147
184
|
|
|
148
185
|
//# 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 disabled: {\n true: {\n // Keep pointer events so the not-allowed cursor shows; the disabled\n // input still blocks changes.\n base: '**:cursor-not-allowed cursor-not-allowed opacity-disabled hover:bg-transparent',\n },\n },\n invalid: {\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 disabled: isDisabled,\n invalid: 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 variants: {\n readOnly: {\n true: {\n // Inner controls set their own cursors, so override every descendant.\n base: '**:cursor-not-allowed cursor-not-allowed opacity-disabled',\n boxBase: 'hover:bg-transparent',\n },\n },\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 icon */\n icon?: ReactNode;\n /** option label */\n label?: 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 /** Prevents changes while keeping the radio boxes focusable and its value in validation and submission */\n readOnly?: boolean;\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 readOnly,\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({ readOnly });\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 isReadOnly={readOnly}\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":"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"}
|
|
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":"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"}
|