@fuf-stack/uniform 0.18.5 → 0.19.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.
- package/dist/CheckboxGroup/index.cjs +5 -6
- package/dist/CheckboxGroup/index.cjs.map +1 -1
- package/dist/CheckboxGroup/index.d.cts +2 -2
- package/dist/CheckboxGroup/index.d.ts +2 -2
- package/dist/CheckboxGroup/index.js +4 -5
- package/dist/FieldArray/index.cjs +5 -5
- package/dist/FieldArray/index.js +4 -4
- package/dist/Form/index.cjs +4 -4
- package/dist/Form/index.js +3 -3
- package/dist/Grid/index.cjs +1 -1
- package/dist/Grid/index.js +1 -1
- package/dist/Input/index.cjs +5 -6
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.js +4 -5
- package/dist/RadioBoxes/index.cjs +5 -6
- package/dist/RadioBoxes/index.cjs.map +1 -1
- package/dist/RadioBoxes/index.d.cts +2 -2
- package/dist/RadioBoxes/index.d.ts +2 -2
- package/dist/RadioBoxes/index.js +4 -5
- package/dist/RadioGroup/index.cjs +5 -6
- package/dist/RadioGroup/index.cjs.map +1 -1
- package/dist/RadioGroup/index.d.cts +2 -2
- package/dist/RadioGroup/index.d.ts +2 -2
- package/dist/RadioGroup/index.js +4 -5
- package/dist/RadioTabs/index.cjs +5 -6
- package/dist/RadioTabs/index.cjs.map +1 -1
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +4 -5
- package/dist/Select/index.cjs +5 -6
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +4 -5
- package/dist/SubmitButton/index.cjs +4 -4
- package/dist/SubmitButton/index.js +3 -3
- package/dist/Switch/index.cjs +5 -6
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.d.cts +2 -2
- package/dist/Switch/index.d.ts +2 -2
- package/dist/Switch/index.js +4 -5
- package/dist/TextArea/index.cjs +5 -6
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +4 -5
- package/dist/chunk-25Y2Q5CX.cjs +110 -0
- package/dist/chunk-25Y2Q5CX.cjs.map +1 -0
- package/dist/{chunk-IOIYK6UC.js → chunk-35I663WR.js} +29 -29
- package/dist/chunk-35I663WR.js.map +1 -0
- package/dist/{chunk-HHENF3BD.js → chunk-3JRZ5YNE.js} +6 -6
- package/dist/chunk-4DVYBP2O.cjs +236 -0
- package/dist/chunk-4DVYBP2O.cjs.map +1 -0
- package/dist/chunk-4IQKCUZC.cjs +145 -0
- package/dist/chunk-4IQKCUZC.cjs.map +1 -0
- package/dist/{chunk-4DAZAO6Y.cjs → chunk-555JRYCS.cjs} +4 -2
- package/dist/chunk-555JRYCS.cjs.map +1 -0
- package/dist/{chunk-R4GZXQFD.cjs → chunk-5NKR4C73.cjs} +14 -14
- package/dist/{chunk-R4GZXQFD.cjs.map → chunk-5NKR4C73.cjs.map} +1 -1
- package/dist/chunk-5W2IWHSE.js +89 -0
- package/dist/chunk-5W2IWHSE.js.map +1 -0
- package/dist/{chunk-WD4ES4JK.cjs → chunk-6GCMM22R.cjs} +35 -47
- package/dist/chunk-6GCMM22R.cjs.map +1 -0
- package/dist/chunk-7BLVIVDU.cjs +281 -0
- package/dist/chunk-7BLVIVDU.cjs.map +1 -0
- package/dist/{chunk-3DWGHDVE.js → chunk-7NZKBUL6.js} +36 -48
- package/dist/chunk-7NZKBUL6.js.map +1 -0
- package/dist/{chunk-EAEW6SOJ.js → chunk-7R2P54VS.js} +37 -49
- package/dist/chunk-7R2P54VS.js.map +1 -0
- package/dist/{chunk-P332MPVH.js → chunk-BXQ3MVNH.js} +5 -5
- package/dist/chunk-BXQ3MVNH.js.map +1 -0
- package/dist/chunk-CN5XEGV4.js +281 -0
- package/dist/chunk-CN5XEGV4.js.map +1 -0
- package/dist/chunk-DBKDDOS2.cjs +89 -0
- package/dist/chunk-DBKDDOS2.cjs.map +1 -0
- package/dist/chunk-E62JDTFS.js +110 -0
- package/dist/chunk-E62JDTFS.js.map +1 -0
- package/dist/chunk-F2LWLSBT.cjs +98 -0
- package/dist/chunk-F2LWLSBT.cjs.map +1 -0
- package/dist/{chunk-4RDTC7R6.cjs → chunk-HECO3HXR.cjs} +31 -31
- package/dist/chunk-HECO3HXR.cjs.map +1 -0
- package/dist/{chunk-CRTRMMJ7.js → chunk-K2V4ULA2.js} +3 -1
- package/dist/{chunk-AEUUTAJB.cjs → chunk-LYI2IDCW.cjs} +6 -6
- package/dist/chunk-LYI2IDCW.cjs.map +1 -0
- package/dist/{chunk-737UQZOW.js → chunk-N2MRIHRX.js} +109 -122
- package/dist/chunk-N2MRIHRX.js.map +1 -0
- package/dist/{chunk-ZPNMTMGE.cjs → chunk-NEHRI4EM.cjs} +60 -70
- package/dist/chunk-NEHRI4EM.cjs.map +1 -0
- package/dist/chunk-UU7SXXNI.cjs +70 -0
- package/dist/chunk-UU7SXXNI.cjs.map +1 -0
- package/dist/chunk-W2K5WX3O.js +145 -0
- package/dist/chunk-W2K5WX3O.js.map +1 -0
- package/dist/chunk-Y4YQH2QB.js +70 -0
- package/dist/chunk-Y4YQH2QB.js.map +1 -0
- package/dist/{chunk-BXZ2SBRA.js → chunk-YK2XHKK2.js} +55 -65
- package/dist/chunk-YK2XHKK2.js.map +1 -0
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/hooks/index.cjs +7 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +47 -6
- package/dist/hooks/index.d.ts +47 -6
- package/dist/hooks/index.js +6 -2
- package/dist/index.cjs +17 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +21 -21
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +4 -9
- package/dist/Controller/index.cjs +0 -11
- package/dist/Controller/index.cjs.map +0 -1
- package/dist/Controller/index.d.cts +0 -8
- package/dist/Controller/index.d.ts +0 -8
- package/dist/Controller/index.js +0 -11
- package/dist/Controller-8Nqugui5.d.cts +0 -37
- package/dist/Controller-8Nqugui5.d.ts +0 -37
- package/dist/chunk-3DWGHDVE.js.map +0 -1
- package/dist/chunk-3MPB726A.cjs +0 -82
- package/dist/chunk-3MPB726A.cjs.map +0 -1
- package/dist/chunk-3WZNMG5K.js +0 -155
- package/dist/chunk-3WZNMG5K.js.map +0 -1
- package/dist/chunk-4DAZAO6Y.cjs.map +0 -1
- package/dist/chunk-4HGNEE2R.js +0 -97
- package/dist/chunk-4HGNEE2R.js.map +0 -1
- package/dist/chunk-4RDTC7R6.cjs.map +0 -1
- package/dist/chunk-737UQZOW.js.map +0 -1
- package/dist/chunk-AEUUTAJB.cjs.map +0 -1
- package/dist/chunk-AT2VVPRD.js +0 -52
- package/dist/chunk-AT2VVPRD.js.map +0 -1
- package/dist/chunk-BXZ2SBRA.js.map +0 -1
- package/dist/chunk-CRTRMMJ7.js.map +0 -1
- package/dist/chunk-DXMJHNP3.cjs +0 -249
- package/dist/chunk-DXMJHNP3.cjs.map +0 -1
- package/dist/chunk-EAEW6SOJ.js.map +0 -1
- package/dist/chunk-EPYFZXEI.cjs +0 -52
- package/dist/chunk-EPYFZXEI.cjs.map +0 -1
- package/dist/chunk-IOIYK6UC.js.map +0 -1
- package/dist/chunk-JH4CPQHA.cjs +0 -120
- package/dist/chunk-JH4CPQHA.cjs.map +0 -1
- package/dist/chunk-JHVW42BW.cjs +0 -97
- package/dist/chunk-JHVW42BW.cjs.map +0 -1
- package/dist/chunk-JS2D6XPO.js +0 -120
- package/dist/chunk-JS2D6XPO.js.map +0 -1
- package/dist/chunk-NBAVP4ER.js +0 -135
- package/dist/chunk-NBAVP4ER.js.map +0 -1
- package/dist/chunk-P332MPVH.js.map +0 -1
- package/dist/chunk-QQW2FHSC.cjs +0 -135
- package/dist/chunk-QQW2FHSC.cjs.map +0 -1
- package/dist/chunk-QX652SHY.cjs +0 -110
- package/dist/chunk-QX652SHY.cjs.map +0 -1
- package/dist/chunk-SCTQXWRU.cjs +0 -155
- package/dist/chunk-SCTQXWRU.cjs.map +0 -1
- package/dist/chunk-WD4ES4JK.cjs.map +0 -1
- package/dist/chunk-YLLUYAY3.js +0 -82
- package/dist/chunk-YLLUYAY3.js.map +0 -1
- package/dist/chunk-ZPNMTMGE.cjs.map +0 -1
- package/dist/{CheckboxGroup-Dq4voRWR.d.cts → CheckboxGroup-Dh0YW4KV.d.cts} +5 -5
- package/dist/{CheckboxGroup-Dq4voRWR.d.ts → CheckboxGroup-Dh0YW4KV.d.ts} +5 -5
- package/dist/{RadioBoxes-DJ49DctW.d.cts → RadioBoxes-C61IRDCU.d.cts} +5 -5
- package/dist/{RadioBoxes-DJ49DctW.d.ts → RadioBoxes-C61IRDCU.d.ts} +5 -5
- package/dist/{RadioGroup-BYfxswoe.d.cts → RadioGroup-C7I27oav.d.cts} +5 -5
- package/dist/{RadioGroup-BYfxswoe.d.ts → RadioGroup-C7I27oav.d.ts} +5 -5
- package/dist/{RadioTabs-BYvYukGt.d.cts → RadioTabs-CT8PT7ky.d.cts} +5 -5
- package/dist/{RadioTabs-BYvYukGt.d.ts → RadioTabs-CT8PT7ky.d.ts} +5 -5
- package/dist/{Select-D2Tn4xBh.d.cts → Select-JRwrSDew.d.cts} +15 -15
- package/dist/{Select-D2Tn4xBh.d.ts → Select-JRwrSDew.d.ts} +15 -15
- package/dist/{Switch-C1H8Kyu7.d.cts → Switch-CLs964dL.d.cts} +5 -5
- package/dist/{Switch-C1H8Kyu7.d.ts → Switch-CLs964dL.d.ts} +5 -5
- /package/dist/{chunk-HHENF3BD.js.map → chunk-3JRZ5YNE.js.map} +0 -0
- /package/dist/{Controller/index.js.map → chunk-K2V4ULA2.js.map} +0 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkGNYQC5IJcjs = require('./chunk-GNYQC5IJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkPA2DQCBYcjs = require('./chunk-PA2DQCBY.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var _chunkGNYQC5IJcjs = require('./chunk-GNYQC5IJ.cjs');
|
|
10
|
-
|
|
11
9
|
|
|
12
|
-
var
|
|
10
|
+
var _chunk7BLVIVDUcjs = require('./chunk-7BLVIVDU.cjs');
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
|
|
17
|
-
var
|
|
15
|
+
var _chunk555JRYCScjs = require('./chunk-555JRYCS.cjs');
|
|
18
16
|
|
|
19
17
|
// src/RadioBoxes/RadioBoxes.tsx
|
|
20
18
|
var _radio = require('@heroui/radio');
|
|
@@ -26,7 +24,7 @@ var _visuallyhidden = require('@react-aria/visually-hidden');
|
|
|
26
24
|
|
|
27
25
|
var _jsxruntime = require('react/jsx-runtime');
|
|
28
26
|
var RadioBox = (_a) => {
|
|
29
|
-
var _b = _a, { icon = void 0 } = _b, props =
|
|
27
|
+
var _b = _a, { icon = void 0 } = _b, props = _chunk555JRYCScjs.__objRest.call(void 0, _b, ["icon"]);
|
|
30
28
|
const {
|
|
31
29
|
children,
|
|
32
30
|
Component,
|
|
@@ -41,7 +39,7 @@ var RadioBox = (_a) => {
|
|
|
41
39
|
} = _radio.useRadio.call(void 0, props);
|
|
42
40
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
43
41
|
Component,
|
|
44
|
-
|
|
42
|
+
_chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getBaseProps()), {
|
|
45
43
|
className: _pixelutils.cn.call(void 0,
|
|
46
44
|
"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",
|
|
47
45
|
{
|
|
@@ -50,15 +48,15 @@ var RadioBox = (_a) => {
|
|
|
50
48
|
}
|
|
51
49
|
),
|
|
52
50
|
children: [
|
|
53
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _visuallyhidden.VisuallyHidden, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input",
|
|
54
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span",
|
|
51
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _visuallyhidden.VisuallyHidden, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getInputProps())) }),
|
|
52
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getWrapperProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getControlProps())) })),
|
|
55
53
|
icon,
|
|
56
54
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
57
55
|
"div",
|
|
58
|
-
|
|
56
|
+
_chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getLabelWrapperProps()), {
|
|
59
57
|
className: _pixelutils.cn.call(void 0, getLabelWrapperProps().className, "grow"),
|
|
60
58
|
children: [
|
|
61
|
-
children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span",
|
|
59
|
+
children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getLabelProps()), { children })),
|
|
62
60
|
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-small text-foreground opacity-70", children: description })
|
|
63
61
|
]
|
|
64
62
|
})
|
|
@@ -96,72 +94,64 @@ var RadioBoxes = ({
|
|
|
96
94
|
options,
|
|
97
95
|
testId: _testId = void 0
|
|
98
96
|
}) => {
|
|
99
|
-
const { control, debugMode, getFieldState, getValues } =
|
|
97
|
+
const { control, debugMode, getFieldState, getValues } = _chunk7BLVIVDUcjs.useFormContext.call(void 0, );
|
|
100
98
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
99
|
+
const { field } = _chunk7BLVIVDUcjs.useController.call(void 0, { control, disabled, name });
|
|
100
|
+
const { onChange, disabled: isDisabled, onBlur, ref } = field;
|
|
101
101
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
102
102
|
const showLabel = label || showTestIdCopyButton;
|
|
103
103
|
const variants = radioBoxesVariants();
|
|
104
104
|
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
105
|
+
const itemClassNames = {
|
|
106
|
+
base: classNames.itemBase,
|
|
107
|
+
control: classNames.itemControl,
|
|
108
|
+
description: classNames.itemDescription,
|
|
109
|
+
label: classNames.itemLabel,
|
|
110
|
+
labelWrapper: classNames.itemLabelWrapper,
|
|
111
|
+
wrapper: classNames.itemWrapper
|
|
112
|
+
};
|
|
105
113
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
106
|
-
|
|
114
|
+
_radio.RadioGroup,
|
|
107
115
|
{
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
classNames,
|
|
117
|
+
"data-invalid": invalid,
|
|
118
|
+
"data-required": required,
|
|
119
|
+
"data-testid": testId,
|
|
120
|
+
defaultValue: getValues()[name],
|
|
121
|
+
errorMessage: error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGNYQC5IJcjs.FieldValidationError_default, { error, testId }),
|
|
122
|
+
isDisabled,
|
|
123
|
+
isInvalid: invalid,
|
|
124
|
+
isRequired: required,
|
|
125
|
+
label: showLabel && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
126
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { children: [
|
|
127
|
+
label,
|
|
128
|
+
showTestIdCopyButton && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default, { testId })
|
|
129
|
+
] }),
|
|
110
130
|
name,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
showTestIdCopyButton && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default, { testId })
|
|
136
|
-
] }),
|
|
137
|
-
name,
|
|
138
|
-
orientation: inline ? "horizontal" : "vertical",
|
|
139
|
-
onBlur,
|
|
140
|
-
ref,
|
|
141
|
-
children: options.map((option) => {
|
|
142
|
-
if ("value" in option) {
|
|
143
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
144
|
-
RadioBox,
|
|
145
|
-
{
|
|
146
|
-
classNames: itemClassNames,
|
|
147
|
-
"data-testid": _pixelutils.slugify.call(void 0,
|
|
148
|
-
`${testId}_option_${option.testId || option.value}`
|
|
149
|
-
),
|
|
150
|
-
description: option.description,
|
|
151
|
-
icon: option.icon,
|
|
152
|
-
isDisabled: isDisabled || option.disabled,
|
|
153
|
-
onChange,
|
|
154
|
-
value: option.value,
|
|
155
|
-
children: option.label ? option.label : option.value
|
|
156
|
-
},
|
|
157
|
-
option.value
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
}
|
|
131
|
+
orientation: inline ? "horizontal" : "vertical",
|
|
132
|
+
onBlur,
|
|
133
|
+
ref,
|
|
134
|
+
children: options.map((option) => {
|
|
135
|
+
if ("value" in option) {
|
|
136
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
137
|
+
RadioBox,
|
|
138
|
+
{
|
|
139
|
+
classNames: itemClassNames,
|
|
140
|
+
"data-testid": _pixelutils.slugify.call(void 0,
|
|
141
|
+
`${testId}_option_${option.testId || option.value}`
|
|
142
|
+
),
|
|
143
|
+
description: option.description,
|
|
144
|
+
icon: option.icon,
|
|
145
|
+
isDisabled: isDisabled || option.disabled,
|
|
146
|
+
onChange,
|
|
147
|
+
value: option.value,
|
|
148
|
+
children: option.label ? option.label : option.value
|
|
149
|
+
},
|
|
150
|
+
option.value
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
})
|
|
165
155
|
}
|
|
166
156
|
);
|
|
167
157
|
};
|
|
@@ -174,4 +164,4 @@ var RadioBoxes_default2 = RadioBoxes_default;
|
|
|
174
164
|
|
|
175
165
|
|
|
176
166
|
exports.RadioBoxes_default = RadioBoxes_default; exports.RadioBoxes_default2 = RadioBoxes_default2;
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
167
|
+
//# sourceMappingURL=chunk-NEHRI4EM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-NEHRI4EM.cjs","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"names":["jsx","jsxs","RadioBoxes_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACbA,sCAA6C;AAE7C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,UAAA;AAAA,sBAEEC,8BAAAA,OAAC,EAAA,EACE,QAAA,EAAA;AAAA,QAAA,KAAA;AAAA,QACA,qBAAA,mBAAwBD,6BAAAA,+CAAC,EAAA,EAAsB,OAAA,CAAgB;AAAA,MAAA,EAAA,CAClE,CAAA;AAAA,MAGJ,IAAA;AAAA,MACA,WAAA,EAAa,OAAA,EAAS,aAAA,EAAe,UAAA;AAAA,MACrC,MAAA;AAAA,MACA,GAAA;AAAA,MAEC,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,GAAW;AACvB,QAAA,GAAA,CAAI,QAAA,GAAW,MAAA,EAAQ;AACrB,UAAA,uBACEA,6BAAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,UAAA,EAAY,cAAA;AAAA,cACZ,aAAA,EAAa,iCAAA;AAAA,gBACX,CAAA,EAAA;AACF,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AAEA,cAAA;AACA,cAAA;AAEC,cAAA;AAAqC,YAAA;AAJjC,YAAA;AAKP,UAAA;AAEJ,QAAA;AACO,QAAA;AACR,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADKU;AACA;AGzJVE;AH2JU;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-NEHRI4EM.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\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 '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 RadioBoxesOption {\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;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\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: RadioBoxesOption[];\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 disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n}: RadioBoxesProps): ReactElement => {\n const { control, debugMode, getFieldState, getValues } = useFormContext();\n\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { onChange, disabled: isDisabled, onBlur, ref } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\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 defaultValue={getValues()[name]}\n errorMessage={\n error && <FieldValidationError error={error} testId={testId} />\n }\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </label>\n )\n }\n name={name}\n orientation={inline ? 'horizontal' : 'vertical'}\n onBlur={onBlur}\n ref={ref}\n >\n {options.map((option) => {\n if ('value' in option) {\n return (\n <RadioBox\n classNames={itemClassNames}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n description={option.description}\n icon={option.icon}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n onChange={onChange}\n value={option.value}\n >\n {option.label ? option.label : option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import 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 } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends HeroRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\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);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(\n '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 {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <input {...getInputProps()} />\n </VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {children && <span {...getLabelProps()}>{children}</span>}\n {description && (\n <span className=\"text-small text-foreground opacity-70\">\n {description}\n </span>\n )}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkGNYQC5IJcjs = require('./chunk-GNYQC5IJ.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkPA2DQCBYcjs = require('./chunk-PA2DQCBY.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk7BLVIVDUcjs = require('./chunk-7BLVIVDU.cjs');
|
|
11
|
+
|
|
12
|
+
// src/TextArea/TextArea.tsx
|
|
13
|
+
var _input = require('@heroui/input');
|
|
14
|
+
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
15
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
16
|
+
var TextArea = ({
|
|
17
|
+
children = null,
|
|
18
|
+
className = void 0,
|
|
19
|
+
disabled = false,
|
|
20
|
+
label = void 0,
|
|
21
|
+
name,
|
|
22
|
+
placeholder = " ",
|
|
23
|
+
testId: _testId = void 0
|
|
24
|
+
}) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const { control, debugMode, getFieldState } = _chunk7BLVIVDUcjs.useFormContext.call(void 0, );
|
|
27
|
+
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
28
|
+
const { field } = _chunk7BLVIVDUcjs.useController.call(void 0, { control, name, disabled });
|
|
29
|
+
const { disabled: isDisabled, onChange, onBlur, value = "", ref } = field;
|
|
30
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
31
|
+
const showLabel = label || showTestIdCopyButton;
|
|
32
|
+
const displayValue = (_a = value == null ? void 0 : value.toString()) != null ? _a : "";
|
|
33
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
34
|
+
_input.Textarea,
|
|
35
|
+
{
|
|
36
|
+
className: _pixelutils.cn.call(void 0, className),
|
|
37
|
+
classNames: {
|
|
38
|
+
inputWrapper: "group-data-[focus=true]:border-focus"
|
|
39
|
+
},
|
|
40
|
+
"data-testid": testId,
|
|
41
|
+
errorMessage: error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkGNYQC5IJcjs.FieldValidationError_default, { error, testId }),
|
|
42
|
+
isDisabled,
|
|
43
|
+
isRequired: required,
|
|
44
|
+
isInvalid: invalid,
|
|
45
|
+
label: showLabel && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
46
|
+
label,
|
|
47
|
+
showTestIdCopyButton && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default, { testId })
|
|
48
|
+
] }),
|
|
49
|
+
labelPlacement: "outside",
|
|
50
|
+
placeholder,
|
|
51
|
+
name,
|
|
52
|
+
value: displayValue,
|
|
53
|
+
onChange,
|
|
54
|
+
onBlur,
|
|
55
|
+
ref,
|
|
56
|
+
variant: "bordered",
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
var TextArea_default = TextArea;
|
|
62
|
+
|
|
63
|
+
// src/TextArea/index.ts
|
|
64
|
+
var TextArea_default2 = TextArea_default;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.TextArea_default = TextArea_default; exports.TextArea_default2 = TextArea_default2;
|
|
70
|
+
//# sourceMappingURL=chunk-UU7SXXNI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-UU7SXXNI.cjs","../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"names":["TextArea_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACTA,sCAAyC;AAEzC,oDAAmB;AA8EF,+CAAA;AApDjB,IAAM,SAAA,EAAW,CAAC;AAAA,EAChB,SAAA,EAAW,IAAA;AAAA,EACX,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,MAAA,EAAQ,KAAA,CAAA;AAAA,EACR,IAAA;AAAA,EACA,YAAA,EAAc,GAAA;AAAA,EACd,MAAA,EAAQ,QAAA,EAAU,KAAA;AACpB,CAAA,EAAA,GAAqB;AAtCrB,EAAA,IAAA,EAAA;AAuCE,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,cAAc,EAAA,EAAI,8CAAA,CAAe;AAC7D,EAAA,MAAM,EAAE,KAAA,EAAO,OAAA,EAAS,QAAA,EAAU,OAAO,EAAA,EAAI,aAAA,CAAc,IAAA,EAAM,OAAO,CAAA;AAExE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,6CAAA,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,iBAAA,EAAQ,QAAA;ADhDf;AACA;AExDA,IAAOA,kBAAAA,EAAQ,gBAAA;AF0Df;AACA;AACE;AACA;AACF,2FAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-UU7SXXNI.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface TextAreaProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className = undefined,\n disabled = false,\n label = undefined,\n name,\n placeholder = ' ',\n testId: _testId = undefined,\n}: TextAreaProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, name, disabled });\n const { disabled: isDisabled, onChange, onBlur, value = '', ref } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n /**\n * Ensures the textarea always has a defined string value to prevent uncontrolled to\n * controlled component warnings:\n *\n * 1. Warning Prevention:\n * - Sets default value to '' in field destructuring\n * - Guarantees the value prop is never undefined/null\n * - Prevents React warning: \"A component is changing from uncontrolled to controlled\"\n *\n * 2. Value Handling:\n * - Converts undefined/null to empty string\n * - Converts non-string values to strings\n * - Maintains existing string values\n *\n * Examples:\n * - undefined → \"\" (prevents uncontrolled warning)\n * - null → \"\" (prevents uncontrolled warning)\n * - \"hello\" → \"hello\" (maintains string value)\n * - 123 → \"123\" (converts to string)\n *\n * Without this handling, the textarea could switch between controlled/uncontrolled\n * states when the form value changes from undefined to defined, causing React warnings\n * and potential rendering issues.\n */\n const displayValue = value?.toString() ?? '';\n\n return (\n <HeroTextArea\n className={cn(className)}\n classNames={{\n inputWrapper: 'group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n errorMessage={\n error && <FieldValidationError error={error} testId={testId} />\n }\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={invalid}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </>\n )\n }\n labelPlacement=\"outside\"\n placeholder={placeholder}\n name={name}\n value={displayValue}\n onChange={onChange}\n onBlur={onBlur}\n ref={ref}\n variant=\"bordered\"\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldValidationError_default
|
|
3
|
+
} from "./chunk-UTFZRBBS.js";
|
|
4
|
+
import {
|
|
5
|
+
FieldCopyTestIdButton_default
|
|
6
|
+
} from "./chunk-BQGN3JTU.js";
|
|
7
|
+
import {
|
|
8
|
+
useController,
|
|
9
|
+
useFormContext
|
|
10
|
+
} from "./chunk-CN5XEGV4.js";
|
|
11
|
+
import {
|
|
12
|
+
__spreadProps,
|
|
13
|
+
__spreadValues
|
|
14
|
+
} from "./chunk-K2V4ULA2.js";
|
|
15
|
+
|
|
16
|
+
// src/CheckboxGroup/CheckboxGroup.tsx
|
|
17
|
+
import { Checkbox, CheckboxGroup as HeroCheckboxGroup } from "@heroui/checkbox";
|
|
18
|
+
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var checkboxGroupVariants = tv({
|
|
21
|
+
slots: {
|
|
22
|
+
base: "group",
|
|
23
|
+
// Needs group for group-data condition
|
|
24
|
+
errorMessage: "text-tiny",
|
|
25
|
+
itemBase: "",
|
|
26
|
+
itemIcon: "",
|
|
27
|
+
itemLabel: "text-sm",
|
|
28
|
+
itemWrapper: "",
|
|
29
|
+
// see HeroUI styles for group-data condition,
|
|
30
|
+
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
31
|
+
label: "text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger",
|
|
32
|
+
wrapper: ""
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var CheckboxGroup = ({
|
|
36
|
+
className = void 0,
|
|
37
|
+
inline = false,
|
|
38
|
+
label = void 0,
|
|
39
|
+
options,
|
|
40
|
+
disabled = false,
|
|
41
|
+
name,
|
|
42
|
+
testId: _testId = void 0
|
|
43
|
+
}) => {
|
|
44
|
+
const { control, debugMode, getFieldState } = useFormContext();
|
|
45
|
+
const {
|
|
46
|
+
error: _error,
|
|
47
|
+
invalid,
|
|
48
|
+
required,
|
|
49
|
+
testId
|
|
50
|
+
} = getFieldState(name, _testId);
|
|
51
|
+
const { field } = useController({ control, name, disabled });
|
|
52
|
+
const { onChange, value = [], ref, onBlur } = field;
|
|
53
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
54
|
+
const showLabel = label || showTestIdCopyButton;
|
|
55
|
+
const variants = checkboxGroupVariants();
|
|
56
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
57
|
+
const itemClassName = {
|
|
58
|
+
base: classNames.itemBase,
|
|
59
|
+
wrapper: classNames.itemWrapper,
|
|
60
|
+
icon: classNames.itemIcon,
|
|
61
|
+
label: classNames.itemLabel
|
|
62
|
+
};
|
|
63
|
+
const itemGroupClassName = {
|
|
64
|
+
base: classNames.base,
|
|
65
|
+
wrapper: classNames.wrapper,
|
|
66
|
+
label: classNames.label
|
|
67
|
+
};
|
|
68
|
+
const errorFlat = _error && Object.values(
|
|
69
|
+
_error
|
|
70
|
+
).flat() || [];
|
|
71
|
+
const getCheckboxValue = (inputValue) => {
|
|
72
|
+
if (Array.isArray(inputValue)) {
|
|
73
|
+
return inputValue;
|
|
74
|
+
}
|
|
75
|
+
if (inputValue) {
|
|
76
|
+
return [inputValue];
|
|
77
|
+
}
|
|
78
|
+
return [];
|
|
79
|
+
};
|
|
80
|
+
const singleCheckboxProps = {
|
|
81
|
+
value: getCheckboxValue(value),
|
|
82
|
+
onChange: (newValue) => onChange(newValue && newValue[0])
|
|
83
|
+
};
|
|
84
|
+
const multipleCheckboxProps = {
|
|
85
|
+
onChange,
|
|
86
|
+
value: getCheckboxValue(value)
|
|
87
|
+
};
|
|
88
|
+
const checkboxGroupProps = options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
HeroCheckboxGroup,
|
|
91
|
+
__spreadProps(__spreadValues({
|
|
92
|
+
name,
|
|
93
|
+
classNames: itemGroupClassName,
|
|
94
|
+
"data-testid": testId,
|
|
95
|
+
"data-invalid": invalid,
|
|
96
|
+
errorMessage: errorFlat.length && /* @__PURE__ */ jsx(
|
|
97
|
+
FieldValidationError_default,
|
|
98
|
+
{
|
|
99
|
+
className: classNames.errorMessage,
|
|
100
|
+
error: errorFlat,
|
|
101
|
+
testId
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
isDisabled: disabled,
|
|
105
|
+
isInvalid: invalid,
|
|
106
|
+
isRequired: required,
|
|
107
|
+
label: showLabel && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
108
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
109
|
+
label,
|
|
110
|
+
showTestIdCopyButton && /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
111
|
+
] }),
|
|
112
|
+
onBlur,
|
|
113
|
+
orientation: inline ? "horizontal" : "vertical",
|
|
114
|
+
ref
|
|
115
|
+
}, checkboxGroupProps), {
|
|
116
|
+
children: options == null ? void 0 : options.map((option) => {
|
|
117
|
+
const optionTestId = slugify(
|
|
118
|
+
`${testId}_option_${(option == null ? void 0 : option.testId) || (option == null ? void 0 : option.value)}`
|
|
119
|
+
);
|
|
120
|
+
return /* @__PURE__ */ jsx(
|
|
121
|
+
Checkbox,
|
|
122
|
+
{
|
|
123
|
+
"data-invalid": invalid,
|
|
124
|
+
classNames: itemClassName,
|
|
125
|
+
isDisabled: disabled || option.disabled,
|
|
126
|
+
value: option == null ? void 0 : option.value,
|
|
127
|
+
"data-testid": optionTestId,
|
|
128
|
+
children: option == null ? void 0 : option.label
|
|
129
|
+
},
|
|
130
|
+
`index_${option.value}`
|
|
131
|
+
);
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
var CheckboxGroup_default = CheckboxGroup;
|
|
137
|
+
|
|
138
|
+
// src/CheckboxGroup/index.ts
|
|
139
|
+
var CheckboxGroup_default2 = CheckboxGroup_default;
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
CheckboxGroup_default,
|
|
143
|
+
CheckboxGroup_default2
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=chunk-W2K5WX3O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/CheckboxGroup/CheckboxGroup.tsx","../src/CheckboxGroup/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { FieldError } from 'react-hook-form';\n\nimport { Checkbox, CheckboxGroup as HeroCheckboxGroup } from '@heroui/checkbox';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const checkboxGroupVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n errorMessage: 'text-tiny',\n itemBase: '',\n itemIcon: '',\n itemLabel: 'text-sm',\n itemWrapper: '',\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 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof checkboxGroupVariants>;\ntype ClassName = TVClassName<typeof checkboxGroupVariants>;\n\nexport type CheckboxGroupOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n};\n\nexport interface CheckboxGroupProps extends VariantProps {\n /** CSS class name. ClassName: string | { buttons?: string | { base?: string; active?: string }; base?: string;} */\n className?: ClassName;\n /** determines orientation of the boxes. */\n inline?: boolean;\n /** label displayed above the Checkboxes */\n label?: React.ReactNode;\n /** Name the Field is registered on the form. */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxGroupOption[];\n /** sets all buttons disabled */\n disabled?: boolean;\n /** id for internal testing. */\n testId?: string;\n}\n\n/**\n * CheckboxGroup component based on [HeroUI CheckboxGroup](https://www.heroui.com//docs/components/checkbox-group)\n */\nconst CheckboxGroup = ({\n className = undefined,\n inline = false,\n label = undefined,\n options,\n disabled = false,\n name,\n testId: _testId = undefined,\n}: CheckboxGroupProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const {\n error: _error,\n invalid,\n required,\n testId,\n } = getFieldState(name, _testId);\n\n const { field } = useController({ control, name, disabled });\n const { onChange, value = [], ref, onBlur } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n const variants = checkboxGroupVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassName = {\n base: classNames.itemBase,\n wrapper: classNames.itemWrapper,\n icon: classNames.itemIcon,\n label: classNames.itemLabel,\n };\n const itemGroupClassName = {\n base: classNames.base,\n wrapper: classNames.wrapper,\n label: classNames.label,\n };\n\n // Convert React Hook Form's nested error object structure to a flat array\n // RHF errors can be nested like: checkboxField.0 (individual checkbox errors)\n // and checkboxField._error (global field errors) - this flattens all\n // error values into a single array for rendering with FieldValidationError\n const errorFlat: FieldError[] =\n (_error &&\n Object.values(\n _error as unknown as Record<string, FieldError[]>,\n ).flat()) ||\n [];\n\n /**\n * Handles the checkbox group value changes based on the number of options:\n * 1. For single checkbox (options.length === 1):\n * - Converts undefined/empty array to [] for consistent controlled behavior\n * - Extracts single value from array for onChange\n *\n * Example: undefined → []\n * [value] → value\n *\n * 2. For multiple checkboxes:\n * - Uses raw value array with fallback to empty array\n * - Passes through onChange directly\n *\n * Example: undefined → []\n * ['value1', 'value2'] → ['value1', 'value2']\n */\n const getCheckboxValue = (inputValue: unknown): string[] => {\n if (Array.isArray(inputValue)) {\n return inputValue;\n }\n if (inputValue) {\n return [inputValue as string];\n }\n return [];\n };\n\n const singleCheckboxProps = {\n value: getCheckboxValue(value),\n onChange: (newValue: string[]) => onChange(newValue && newValue[0]),\n };\n\n const multipleCheckboxProps = {\n onChange,\n value: getCheckboxValue(value),\n };\n\n const checkboxGroupProps =\n options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;\n\n return (\n <HeroCheckboxGroup\n name={name}\n classNames={itemGroupClassName}\n data-testid={testId}\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 errorMessage={\n errorFlat.length && (\n <FieldValidationError\n className={classNames.errorMessage}\n error={errorFlat}\n testId={testId}\n />\n )\n }\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </label>\n )\n }\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n ref={ref}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...checkboxGroupProps}\n >\n {options?.map((option) => {\n const optionTestId = slugify(\n `${testId}_option_${option?.testId || option?.value}`,\n );\n return (\n <Checkbox\n data-invalid={invalid}\n classNames={itemClassName}\n key={`index_${option.value}`}\n isDisabled={disabled || option.disabled}\n value={option?.value}\n data-testid={optionTestId}\n >\n {option?.label}\n </Checkbox>\n );\n })}\n </HeroCheckboxGroup>\n );\n};\n\nexport default CheckboxGroup;\n","import CheckboxGroup from './CheckboxGroup';\n\nexport type { CheckboxGroupProps, CheckboxGroupOption } from './CheckboxGroup';\n\nexport { CheckboxGroup };\n\nexport default CheckboxGroup;\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS,UAAU,iBAAiB,yBAAyB;AAE7D,SAAS,SAAS,IAAI,4BAA4B;AA0JxC,cAaA,YAbA;AApJH,IAAM,wBAAwB,GAAG;AAAA,EACtC,OAAO;AAAA,IACL,MAAM;AAAA;AAAA,IACN,cAAc;AAAA,IACd,UAAU;AAAA,IACV,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA;AAAA;AAAA,IAGb,OACE;AAAA,IACF,SAAS;AAAA,EACX;AACF,CAAC;AAoCD,IAAM,gBAAgB,CAAC;AAAA,EACrB,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,QAAQ,UAAU;AACpB,MAA0B;AACxB,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc,MAAM,OAAO;AAE/B,QAAM,EAAE,MAAM,IAAI,cAAc,EAAE,SAAS,MAAM,SAAS,CAAC;AAC3D,QAAM,EAAE,UAAU,QAAQ,CAAC,GAAG,KAAK,OAAO,IAAI;AA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AGJ;AAAA,MACA,aAAa,SAAS,eAAe;AAAA,MACrC;AAAA,OAEI,qBAhCL;AAAA,MAkCE,6CAAS,IAAI,CAAC,WAAW;AACxB,cAAM,eAAe;AAAA,UACnB,GAAG,MAAM,YAAW,iCAAQ,YAAU,iCAAQ,MAAK;AAAA,QACrD;AACA,eACE;AAAA,UAAC;AAAA;AAAA,YACC,gBAAc;AAAA,YACd,YAAY;AAAA,YAEZ,YAAY,YAAY,OAAO;AAAA,YAC/B,OAAO,iCAAQ;AAAA,YACf,eAAa;AAAA,YAEZ,2CAAQ;AAAA;AAAA,UALJ,SAAS,OAAO,KAAK;AAAA,QAM5B;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,wBAAQ;;;ACvMf,IAAOA,yBAAQ;","names":["CheckboxGroup_default"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldValidationError_default
|
|
3
|
+
} from "./chunk-UTFZRBBS.js";
|
|
4
|
+
import {
|
|
5
|
+
FieldCopyTestIdButton_default
|
|
6
|
+
} from "./chunk-BQGN3JTU.js";
|
|
7
|
+
import {
|
|
8
|
+
useController,
|
|
9
|
+
useFormContext
|
|
10
|
+
} from "./chunk-CN5XEGV4.js";
|
|
11
|
+
|
|
12
|
+
// src/TextArea/TextArea.tsx
|
|
13
|
+
import { Textarea as HeroTextArea } from "@heroui/input";
|
|
14
|
+
import { cn } from "@fuf-stack/pixel-utils";
|
|
15
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var TextArea = ({
|
|
17
|
+
children = null,
|
|
18
|
+
className = void 0,
|
|
19
|
+
disabled = false,
|
|
20
|
+
label = void 0,
|
|
21
|
+
name,
|
|
22
|
+
placeholder = " ",
|
|
23
|
+
testId: _testId = void 0
|
|
24
|
+
}) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const { control, debugMode, getFieldState } = useFormContext();
|
|
27
|
+
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
28
|
+
const { field } = useController({ control, name, disabled });
|
|
29
|
+
const { disabled: isDisabled, onChange, onBlur, value = "", ref } = field;
|
|
30
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
31
|
+
const showLabel = label || showTestIdCopyButton;
|
|
32
|
+
const displayValue = (_a = value == null ? void 0 : value.toString()) != null ? _a : "";
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
HeroTextArea,
|
|
35
|
+
{
|
|
36
|
+
className: cn(className),
|
|
37
|
+
classNames: {
|
|
38
|
+
inputWrapper: "group-data-[focus=true]:border-focus"
|
|
39
|
+
},
|
|
40
|
+
"data-testid": testId,
|
|
41
|
+
errorMessage: error && /* @__PURE__ */ jsx(FieldValidationError_default, { error, testId }),
|
|
42
|
+
isDisabled,
|
|
43
|
+
isRequired: required,
|
|
44
|
+
isInvalid: invalid,
|
|
45
|
+
label: showLabel && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
|
+
label,
|
|
47
|
+
showTestIdCopyButton && /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
48
|
+
] }),
|
|
49
|
+
labelPlacement: "outside",
|
|
50
|
+
placeholder,
|
|
51
|
+
name,
|
|
52
|
+
value: displayValue,
|
|
53
|
+
onChange,
|
|
54
|
+
onBlur,
|
|
55
|
+
ref,
|
|
56
|
+
variant: "bordered",
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
var TextArea_default = TextArea;
|
|
62
|
+
|
|
63
|
+
// src/TextArea/index.ts
|
|
64
|
+
var TextArea_default2 = TextArea_default;
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
TextArea_default,
|
|
68
|
+
TextArea_default2
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-Y4YQH2QB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface TextAreaProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className = undefined,\n disabled = false,\n label = undefined,\n name,\n placeholder = ' ',\n testId: _testId = undefined,\n}: TextAreaProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, name, disabled });\n const { disabled: isDisabled, onChange, onBlur, value = '', ref } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n /**\n * Ensures the textarea always has a defined string value to prevent uncontrolled to\n * controlled component warnings:\n *\n * 1. Warning Prevention:\n * - Sets default value to '' in field destructuring\n * - Guarantees the value prop is never undefined/null\n * - Prevents React warning: \"A component is changing from uncontrolled to controlled\"\n *\n * 2. Value Handling:\n * - Converts undefined/null to empty string\n * - Converts non-string values to strings\n * - Maintains existing string values\n *\n * Examples:\n * - undefined → \"\" (prevents uncontrolled warning)\n * - null → \"\" (prevents uncontrolled warning)\n * - \"hello\" → \"hello\" (maintains string value)\n * - 123 → \"123\" (converts to string)\n *\n * Without this handling, the textarea could switch between controlled/uncontrolled\n * states when the form value changes from undefined to defined, causing React warnings\n * and potential rendering issues.\n */\n const displayValue = value?.toString() ?? '';\n\n return (\n <HeroTextArea\n className={cn(className)}\n classNames={{\n inputWrapper: 'group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n errorMessage={\n error && <FieldValidationError error={error} testId={testId} />\n }\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={invalid}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && <FieldCopyTestIdButton testId={testId} />}\n </>\n )\n }\n labelPlacement=\"outside\"\n placeholder={placeholder}\n name={name}\n value={displayValue}\n onChange={onChange}\n onBlur={onBlur}\n ref={ref}\n variant=\"bordered\"\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"],"mappings":";;;;;;;;;;;;AAEA,SAAS,YAAY,oBAAoB;AAEzC,SAAS,UAAU;AA8EF,SAOP,UAPO,KAOP,YAPO;AApDjB,IAAM,WAAW,CAAC;AAAA,EAChB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR;AAAA,EACA,cAAc;AAAA,EACd,QAAQ,UAAU;AACpB,MAAqB;AAtCrB;AAuCE,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM,EAAE,OAAO,SAAS,UAAU,OAAO,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,MAAM,IAAI,cAAc,EAAE,SAAS,MAAM,SAAS,CAAC;AAC3D,QAAM,EAAE,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,IAAI,IAAI;AAEpE,QAAM,uBAAuB,cAAc;AAC3C,QAAM,YAAY,SAAS;AA0B3B,QAAM,gBAAe,oCAAO,eAAP,YAAqB;AAE1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,SAAS;AAAA,MACvB,YAAY;AAAA,QACV,cAAc;AAAA,MAChB;AAAA,MACA,eAAa;AAAA,MACb,cACE,SAAS,oBAAC,gCAAqB,OAAc,QAAgB;AAAA,MAE/D;AAAA,MACA,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,OACE,aACE,iCACG;AAAA;AAAA,QACA,wBAAwB,oBAAC,iCAAsB,QAAgB;AAAA,SAClE;AAAA,MAGJ,gBAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAQ;AAAA,MAEP;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,mBAAQ;;;ACvGf,IAAOA,oBAAQ;","names":["TextArea_default"]}
|