@fuf-stack/uniform 1.0.1 → 1.0.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/dist/CheckboxGroup/index.cjs +7 -7
- package/dist/CheckboxGroup/index.d.cts +2 -2
- package/dist/CheckboxGroup/index.d.ts +2 -2
- package/dist/CheckboxGroup/index.js +6 -6
- package/dist/{CheckboxGroup-D45rOACY.d.cts → CheckboxGroup-B1g42iP0.d.cts} +2 -2
- package/dist/{CheckboxGroup-D45rOACY.d.ts → CheckboxGroup-B1g42iP0.d.ts} +2 -2
- package/dist/FieldArray/index.cjs +7 -7
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +6 -6
- package/dist/{FieldArray-DAzf9zE2.d.cts → FieldArray-DVQka7Bh.d.cts} +2 -2
- package/dist/{FieldArray-DAzf9zE2.d.ts → FieldArray-DVQka7Bh.d.ts} +2 -2
- package/dist/Form/index.cjs +5 -5
- package/dist/Form/index.d.cts +3 -3
- package/dist/Form/index.d.ts +3 -3
- package/dist/Form/index.js +4 -4
- package/dist/{Form-DX5NTR-H.d.ts → Form-C_11i6PA.d.ts} +1 -1
- package/dist/{Form-D0grgL6G.d.cts → Form-Cu0lWRDN.d.cts} +1 -1
- package/dist/{FormContext-ldCpxKnY.d.cts → FormContext-LRho0tno.d.cts} +2 -2
- package/dist/{FormContext-ldCpxKnY.d.ts → FormContext-LRho0tno.d.ts} +2 -2
- package/dist/Input/index.cjs +7 -7
- package/dist/Input/index.js +6 -6
- package/dist/RadioBoxes/index.cjs +7 -7
- package/dist/RadioBoxes/index.js +6 -6
- package/dist/RadioGroup/index.cjs +7 -7
- package/dist/RadioGroup/index.js +6 -6
- package/dist/RadioTabs/index.cjs +7 -7
- package/dist/RadioTabs/index.js +6 -6
- package/dist/Select/index.cjs +7 -7
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +6 -6
- package/dist/{Select-CY5fJfiS.d.cts → Select-CTRWinmO.d.cts} +2 -2
- package/dist/{Select-CY5fJfiS.d.ts → Select-CTRWinmO.d.ts} +2 -2
- package/dist/SubmitButton/index.cjs +5 -5
- package/dist/SubmitButton/index.js +4 -4
- package/dist/Switch/index.cjs +7 -7
- package/dist/Switch/index.js +6 -6
- package/dist/TextArea/index.cjs +7 -7
- package/dist/TextArea/index.js +6 -6
- package/dist/{chunk-TKQYWIHG.js → chunk-3NZYJNO4.js} +3 -3
- package/dist/{chunk-TKQYWIHG.js.map → chunk-3NZYJNO4.js.map} +1 -1
- package/dist/{chunk-SIGL6TME.cjs → chunk-3WZBQHQM.cjs} +34 -26
- package/dist/chunk-3WZBQHQM.cjs.map +1 -0
- package/dist/{chunk-3HR3BI7P.js → chunk-5BKLAK23.js} +10 -10
- package/dist/{chunk-3HR3BI7P.js.map → chunk-5BKLAK23.js.map} +1 -1
- package/dist/{chunk-LHB7I6NY.js → chunk-5GBO2FHU.js} +24 -22
- package/dist/chunk-5GBO2FHU.js.map +1 -0
- package/dist/{chunk-U5WBLGZV.js → chunk-6IU7IYYB.js} +4 -2
- package/dist/{chunk-U5WBLGZV.js.map → chunk-6IU7IYYB.js.map} +1 -1
- package/dist/{chunk-K2IHP7JJ.cjs → chunk-6NSYLHQW.cjs} +68 -45
- package/dist/chunk-6NSYLHQW.cjs.map +1 -0
- package/dist/{chunk-UTFZRBBS.js → chunk-CQWA2DFV.js} +7 -5
- package/dist/chunk-CQWA2DFV.js.map +1 -0
- package/dist/{chunk-UIBHEN65.js → chunk-CWXROORZ.js} +16 -16
- package/dist/{chunk-UIBHEN65.js.map → chunk-CWXROORZ.js.map} +1 -1
- package/dist/{chunk-5QXF7YXD.js → chunk-EKJOEK5I.js} +14 -14
- package/dist/chunk-EKJOEK5I.js.map +1 -0
- package/dist/{chunk-LLO7FMR7.js → chunk-F3DDS4YF.js} +15 -15
- package/dist/chunk-F3DDS4YF.js.map +1 -0
- package/dist/{chunk-OWWUTKGY.cjs → chunk-FLK6OPFY.cjs} +4 -2
- package/dist/chunk-FLK6OPFY.cjs.map +1 -0
- package/dist/{chunk-H7EXCZKM.cjs → chunk-FWIJ3N3I.cjs} +62 -54
- package/dist/chunk-FWIJ3N3I.cjs.map +1 -0
- package/dist/{chunk-XKX22KIM.cjs → chunk-FZD7GFAE.cjs} +4 -4
- package/dist/{chunk-XKX22KIM.cjs.map → chunk-FZD7GFAE.cjs.map} +1 -1
- package/dist/{chunk-CDQ3ATPY.js → chunk-GVLFSVUO.js} +16 -14
- package/dist/chunk-GVLFSVUO.js.map +1 -0
- package/dist/{chunk-EBZGHHRW.js → chunk-HQTHUBVB.js} +43 -44
- package/dist/chunk-HQTHUBVB.js.map +1 -0
- package/dist/{chunk-63OL6DEM.js → chunk-HZKEIJP5.js} +32 -24
- package/dist/chunk-HZKEIJP5.js.map +1 -0
- package/dist/{chunk-L4YPB7MU.cjs → chunk-LTQCM5VQ.cjs} +9 -5
- package/dist/chunk-LTQCM5VQ.cjs.map +1 -0
- package/dist/{chunk-UHMJOD2X.js → chunk-M52AKWAI.js} +61 -38
- package/dist/chunk-M52AKWAI.js.map +1 -0
- package/dist/{chunk-E2ZEMRKR.cjs → chunk-NATEKPMG.cjs} +19 -19
- package/dist/{chunk-E2ZEMRKR.cjs.map → chunk-NATEKPMG.cjs.map} +1 -1
- package/dist/{chunk-BQGN3JTU.js → chunk-NTDKZW4E.js} +4 -4
- package/dist/{chunk-BQGN3JTU.js.map → chunk-NTDKZW4E.js.map} +1 -1
- package/dist/{chunk-WHW6WMII.js → chunk-OC76RMHG.js} +56 -48
- package/dist/chunk-OC76RMHG.js.map +1 -0
- package/dist/{chunk-PA2DQCBY.cjs → chunk-OE5BOGGX.cjs} +4 -4
- package/dist/{chunk-PA2DQCBY.cjs.map → chunk-OE5BOGGX.cjs.map} +1 -1
- package/dist/{chunk-7HFQGL4U.cjs → chunk-OTZNGYQZ.cjs} +20 -18
- package/dist/chunk-OTZNGYQZ.cjs.map +1 -0
- package/dist/{chunk-CFV3GEQW.cjs → chunk-P5DV3Y52.cjs} +17 -17
- package/dist/chunk-P5DV3Y52.cjs.map +1 -0
- package/dist/{chunk-RCPQS5EN.cjs → chunk-T6SB5UO2.cjs} +13 -18
- package/dist/chunk-T6SB5UO2.cjs.map +1 -0
- package/dist/{chunk-PK3BPMH4.cjs → chunk-TQAF2PJG.cjs} +27 -25
- package/dist/chunk-TQAF2PJG.cjs.map +1 -0
- package/dist/{chunk-W5DZ2NIX.js → chunk-TRJOEV3R.js} +10 -15
- package/dist/{chunk-W5DZ2NIX.js.map → chunk-TRJOEV3R.js.map} +1 -1
- package/dist/{chunk-57WY5GAE.js → chunk-V7QZNDTY.js} +9 -5
- package/dist/chunk-V7QZNDTY.js.map +1 -0
- package/dist/{chunk-3QCNVEUD.cjs → chunk-WIAZMOAH.cjs} +18 -18
- package/dist/chunk-WIAZMOAH.cjs.map +1 -0
- package/dist/{chunk-U6PPZEDR.cjs → chunk-XQAN6TTP.cjs} +13 -13
- package/dist/{chunk-U6PPZEDR.cjs.map → chunk-XQAN6TTP.cjs.map} +1 -1
- package/dist/{chunk-GNYQC5IJ.cjs → chunk-Y3AB4GV6.cjs} +7 -5
- package/dist/chunk-Y3AB4GV6.cjs.map +1 -0
- package/dist/{chunk-YSJU3CB3.cjs → chunk-YOMV7IQD.cjs} +45 -46
- package/dist/chunk-YOMV7IQD.cjs.map +1 -0
- package/dist/helpers/index.cjs +2 -2
- package/dist/helpers/index.js +1 -1
- package/dist/hooks/index.cjs +4 -4
- package/dist/hooks/index.d.cts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -2
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +16 -16
- package/dist/partials/FieldCopyTestIdButton/index.cjs +2 -2
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +2 -2
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-3QCNVEUD.cjs.map +0 -1
- package/dist/chunk-57WY5GAE.js.map +0 -1
- package/dist/chunk-5QXF7YXD.js.map +0 -1
- package/dist/chunk-63OL6DEM.js.map +0 -1
- package/dist/chunk-7HFQGL4U.cjs.map +0 -1
- package/dist/chunk-CDQ3ATPY.js.map +0 -1
- package/dist/chunk-CFV3GEQW.cjs.map +0 -1
- package/dist/chunk-EBZGHHRW.js.map +0 -1
- package/dist/chunk-GNYQC5IJ.cjs.map +0 -1
- package/dist/chunk-H7EXCZKM.cjs.map +0 -1
- package/dist/chunk-K2IHP7JJ.cjs.map +0 -1
- package/dist/chunk-L4YPB7MU.cjs.map +0 -1
- package/dist/chunk-LHB7I6NY.js.map +0 -1
- package/dist/chunk-LLO7FMR7.js.map +0 -1
- package/dist/chunk-OWWUTKGY.cjs.map +0 -1
- package/dist/chunk-PK3BPMH4.cjs.map +0 -1
- package/dist/chunk-RCPQS5EN.cjs.map +0 -1
- package/dist/chunk-SIGL6TME.cjs.map +0 -1
- package/dist/chunk-UHMJOD2X.js.map +0 -1
- package/dist/chunk-UTFZRBBS.js.map +0 -1
- package/dist/chunk-WHW6WMII.js.map +0 -1
- package/dist/chunk-YSJU3CB3.cjs.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FieldCopyTestIdButton_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NTDKZW4E.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CQWA2DFV.js";
|
|
7
7
|
import {
|
|
8
8
|
useController,
|
|
9
9
|
useFormContext
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OC76RMHG.js";
|
|
11
11
|
import {
|
|
12
12
|
__spreadProps,
|
|
13
13
|
__spreadValues
|
|
@@ -22,36 +22,36 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
22
22
|
var selectVariants = tv({
|
|
23
23
|
slots: {
|
|
24
24
|
base: "group leading-normal",
|
|
25
|
-
clearIndicator: "
|
|
26
|
-
control: "
|
|
25
|
+
clearIndicator: "text-foreground-500 hover:bg-default-200 hover:text-foreground-800 rounded-md p-1 hover:cursor-pointer",
|
|
26
|
+
control: "border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger rounded-lg border-2 duration-150! motion-reduce:transition-none",
|
|
27
27
|
control_focused: "border-focus",
|
|
28
28
|
crossIcon: "",
|
|
29
29
|
downChevron: "",
|
|
30
|
-
dropdownIndicator: "rounded-md p-1
|
|
30
|
+
dropdownIndicator: "text-foreground-500 hover:bg-default-200 rounded-md p-1 hover:cursor-pointer hover:text-black",
|
|
31
31
|
group: "",
|
|
32
|
-
groupHeading: "mb-1 ml-3
|
|
32
|
+
groupHeading: "text-foreground-500 mt-2 mb-1 ml-3 text-sm",
|
|
33
33
|
indicatorsContainer: "gap-1 p-1",
|
|
34
34
|
indicatorSeparator: "bg-default-300",
|
|
35
35
|
input: "py-0.5 pl-1",
|
|
36
36
|
// see HeroUI styles for group-data condition,
|
|
37
37
|
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
38
|
-
label: '
|
|
38
|
+
label: 'text-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:text-danger pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:content-["*"]',
|
|
39
39
|
loadingIndicator: "",
|
|
40
|
-
loadingMessage: "rounded-sm p-2
|
|
41
|
-
menu: "mt-2 rounded-xl border
|
|
40
|
+
loadingMessage: "text-foreground-500 rounded-sm p-2",
|
|
41
|
+
menu: "border-default-200 bg-content1 mt-2 rounded-xl border p-1 shadow-lg",
|
|
42
42
|
menuList: "",
|
|
43
43
|
// ensure menu has same z-index as modal so it is visible when rendered in modal
|
|
44
44
|
// see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
|
|
45
45
|
menuPortal: "z-50!",
|
|
46
|
-
multiValue: "items-center gap-1.5 rounded
|
|
46
|
+
multiValue: "bg-default-100 items-center gap-1.5 rounded py-0.5 pr-1 pl-2",
|
|
47
47
|
multiValueContainer: "",
|
|
48
48
|
multiValueLabel: "py-0.5 leading-6",
|
|
49
|
-
multiValueRemove: "
|
|
50
|
-
noOptionsMessage: "rounded-sm p-2
|
|
49
|
+
multiValueRemove: "text-default-500 hover:border-default-300 hover:text-default-800 rounded hover:cursor-pointer",
|
|
50
|
+
noOptionsMessage: "text-foreground-500 rounded-sm p-2",
|
|
51
51
|
option_focused: "bg-default-100 active:bg-default-200",
|
|
52
52
|
option_selected: "bg-default-300",
|
|
53
53
|
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
54
|
-
placeholder: "ml-1 py-0.5 pl-1 text-sm
|
|
54
|
+
placeholder: "text-foreground-500 ml-1 py-0.5 pl-1 text-sm",
|
|
55
55
|
selectContainer: "",
|
|
56
56
|
singleValue: "ml-1! leading-7!",
|
|
57
57
|
valueContainer: "gap-1 p-1"
|
|
@@ -127,7 +127,7 @@ var Select = ({
|
|
|
127
127
|
"data-testid": `${testId}_wrapper`,
|
|
128
128
|
"data-required": required,
|
|
129
129
|
children: [
|
|
130
|
-
showLabel
|
|
130
|
+
showLabel ? /* @__PURE__ */ jsxs(
|
|
131
131
|
"label",
|
|
132
132
|
{
|
|
133
133
|
className: classNames.label,
|
|
@@ -136,16 +136,38 @@ var Select = ({
|
|
|
136
136
|
id: getLabelProps().id,
|
|
137
137
|
children: [
|
|
138
138
|
label,
|
|
139
|
-
showTestIdCopyButton
|
|
139
|
+
showTestIdCopyButton ? /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId }) : null
|
|
140
140
|
]
|
|
141
141
|
}
|
|
142
|
-
),
|
|
142
|
+
) : null,
|
|
143
143
|
/* @__PURE__ */ jsx(
|
|
144
144
|
ReactSelect,
|
|
145
145
|
{
|
|
146
|
+
menuShouldBlockScroll: true,
|
|
147
|
+
unstyled: true,
|
|
146
148
|
"aria-errormessage": "",
|
|
147
|
-
"aria-labelledby": (_a = getTriggerProps()["aria-labelledby"]) == null ? void 0 : _a.split(" ")[1],
|
|
148
149
|
"aria-invalid": invalid,
|
|
150
|
+
components: {
|
|
151
|
+
Input: InputComponent,
|
|
152
|
+
Option: OptionComponent,
|
|
153
|
+
DropdownIndicator: DropdownIndicatorComponent,
|
|
154
|
+
Control: ControlComponent
|
|
155
|
+
},
|
|
156
|
+
"aria-labelledby": (_a = getTriggerProps()["aria-labelledby"]) == null ? void 0 : _a.split(" ")[1],
|
|
157
|
+
"data-testid": testId,
|
|
158
|
+
filterOption,
|
|
159
|
+
formatOptionLabel: renderOptionLabel,
|
|
160
|
+
inputValue,
|
|
161
|
+
instanceId: name,
|
|
162
|
+
isClearable: clearable,
|
|
163
|
+
isDisabled: disabled,
|
|
164
|
+
isLoading: loading,
|
|
165
|
+
name,
|
|
166
|
+
isMulti: multiSelect,
|
|
167
|
+
menuPosition: "fixed",
|
|
168
|
+
onInputChange,
|
|
169
|
+
options,
|
|
170
|
+
placeholder,
|
|
149
171
|
classNames: {
|
|
150
172
|
control: () => cn(classNames.control, {
|
|
151
173
|
[classNames.control_focused]: isFocused && !invalid
|
|
@@ -176,26 +198,6 @@ var Select = ({
|
|
|
176
198
|
singleValue: () => cn(classNames.singleValue, `${getValueProps().className}`),
|
|
177
199
|
valueContainer: () => classNames.valueContainer
|
|
178
200
|
},
|
|
179
|
-
components: {
|
|
180
|
-
Input: InputComponent,
|
|
181
|
-
Option: OptionComponent,
|
|
182
|
-
DropdownIndicator: DropdownIndicatorComponent,
|
|
183
|
-
Control: ControlComponent
|
|
184
|
-
},
|
|
185
|
-
"data-testid": testId,
|
|
186
|
-
filterOption,
|
|
187
|
-
formatOptionLabel: renderOptionLabel,
|
|
188
|
-
inputValue,
|
|
189
|
-
instanceId: name,
|
|
190
|
-
isClearable: clearable,
|
|
191
|
-
isDisabled: disabled,
|
|
192
|
-
isLoading: loading,
|
|
193
|
-
isMulti: multiSelect,
|
|
194
|
-
name,
|
|
195
|
-
menuPosition: "fixed",
|
|
196
|
-
menuShouldBlockScroll: true,
|
|
197
|
-
options,
|
|
198
|
-
placeholder,
|
|
199
201
|
onBlur: (_e) => {
|
|
200
202
|
setIsFocused(false);
|
|
201
203
|
return onBlur();
|
|
@@ -212,14 +214,11 @@ var Select = ({
|
|
|
212
214
|
onFocus: (_e) => {
|
|
213
215
|
setIsFocused(true);
|
|
214
216
|
},
|
|
215
|
-
onInputChange,
|
|
216
217
|
ref,
|
|
217
|
-
value: options.find((option) => option.value === value)
|
|
218
|
-
unstyled: true
|
|
218
|
+
value: options.find((option) => option.value === value)
|
|
219
219
|
}
|
|
220
220
|
),
|
|
221
|
-
error
|
|
222
|
-
/* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx(FieldValidationError_default, { error, testId }) })) }))
|
|
221
|
+
error ? /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx(FieldValidationError_default, { error, testId }) })) })) : null
|
|
223
222
|
]
|
|
224
223
|
})
|
|
225
224
|
);
|
|
@@ -233,4 +232,4 @@ export {
|
|
|
233
232
|
Select_default,
|
|
234
233
|
Select_default2
|
|
235
234
|
};
|
|
236
|
-
//# sourceMappingURL=chunk-
|
|
235
|
+
//# sourceMappingURL=chunk-HQTHUBVB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, 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 selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'text-foreground-500 hover:bg-default-200 hover:text-foreground-800 rounded-md p-1 hover:cursor-pointer',\n control:\n 'border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger rounded-lg border-2 duration-150! motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'text-foreground-500 hover:bg-default-200 rounded-md p-1 hover:cursor-pointer hover:text-black',\n group: '',\n groupHeading: 'text-foreground-500 mt-2 mb-1 ml-3 text-sm',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\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-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:text-danger pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: 'text-foreground-500 rounded-sm p-2',\n menu: 'border-default-200 bg-content1 mt-2 rounded-xl border p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'bg-default-100 items-center gap-1.5 rounded py-0.5 pr-1 pl-2',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'text-default-500 hover:border-default-300 hover:text-default-800 rounded hover:cursor-pointer',\n noOptionsMessage: 'text-foreground-500 rounded-sm p-2',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'text-foreground-500 ml-1 py-0.5 pl-1 text-sm',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface SelectOption {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n}\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value, { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { onChange, value, ref, onBlur } = field;\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\n data-testid={`${testId}_wrapper`}\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-required={required}\n >\n {showLabel ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </label>\n ) : null}\n <ReactSelect\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n aria-labelledby={getTriggerProps()['aria-labelledby']?.split(' ')[1]}\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n isMulti={multiSelect}\n menuPosition=\"fixed\"\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n loadingIndicator: () => classNames.loadingIndicator,\n loadingMessage: () => classNames.loadingMessage,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(classNames.multiValueLabel, `${getValueProps().className}`),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => _option.value),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n />\n {error ? (\n <div {...getHelperWrapperProps()}>\n {}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,SAAS,IAAI,4BAA4B;AAkG7C,cAuGD,YAvGC;AA5FF,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,gBACE;AAAA,IACF,SACE;AAAA,IACF,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,mBACE;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,oBAAoB;AAAA,IACpB,OAAO;AAAA;AAAA;AAAA,IAGP,OACE;AAAA,IACF,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,MAAM;AAAA,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AW,cAAc,GAAG;AAAA,gBAC7B,CAAC,WAAW,eAAe,GAAG;AAAA,cAChC,CAAC;AAAA,cACH,aAAa,MAAM,WAAW;AAAA,cAC9B,aAAa,MACX,GAAG,WAAW,aAAa,GAAG,cAAc,EAAE,SAAS,EAAE;AAAA,cAC3D,gBAAgB,MAAM,WAAW;AAAA,YACnC;AAAA,YACA,QAAQ,CAAC,OAAO;AACd,2BAAa,KAAK;AAClB,qBAAO,OAAO;AAAA,YAChB;AAAA,YACA,UAAU,CAAC,WAAW;AACpB,kBAAI,aAAa;AACf;AAAA,kBACG,iCAA2B,IAAI,CAAC,YAAY,QAAQ;AAAA,gBACvD;AAAA,cACF,OAAO;AACL,yBAAU,iCAAyB,KAAK;AAAA,cAC1C;AAAA,YACF;AAAA,YACA,SAAS,CAAC,OAAO;AACf,2BAAa,IAAI;AAAA,YACnB;AAAA,YACA;AAAA,YAEA,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA;AAAA,QACxD;AAAA,QACC,QACC,oBAAC,wCAAQ,sBAAsB,IAA9B,EAEC,8BAAC,wCAAQ,qBAAqB,IAA7B,EACC,8BAAC,gCAAqB,OAAc,QAAgB,IACtD,IACF,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;AAEA,IAAO,iBAAQ;;;ACvTf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FormContext_default,
|
|
3
3
|
useFormContext
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OC76RMHG.js";
|
|
5
5
|
|
|
6
6
|
// src/Form/Form.tsx
|
|
7
7
|
import { cn as cn2, slugify } from "@fuf-stack/pixel-utils";
|
|
@@ -46,10 +46,12 @@ var FormDebugViewer = ({ className = void 0 }) => {
|
|
|
46
46
|
Button,
|
|
47
47
|
{
|
|
48
48
|
ariaLabel: "Enable form debug mode",
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
className: "text-default-400 fixed right-2.5 bottom-2.5 w-5",
|
|
50
|
+
icon: /* @__PURE__ */ jsx(FaBug, {}),
|
|
51
51
|
variant: "light",
|
|
52
|
-
|
|
52
|
+
onClick: () => {
|
|
53
|
+
setDebugMode("debug");
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
);
|
|
55
57
|
}
|
|
@@ -67,9 +69,11 @@ var FormDebugViewer = ({ className = void 0 }) => {
|
|
|
67
69
|
{
|
|
68
70
|
color: "danger",
|
|
69
71
|
icon: /* @__PURE__ */ jsx(FaTimes, {}),
|
|
70
|
-
onClick: () => setDebugMode("off"),
|
|
71
72
|
size: "sm",
|
|
72
|
-
variant: "light"
|
|
73
|
+
variant: "light",
|
|
74
|
+
onClick: () => {
|
|
75
|
+
setDebugMode("off");
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
)
|
|
75
79
|
] }),
|
|
@@ -77,10 +81,12 @@ var FormDebugViewer = ({ className = void 0 }) => {
|
|
|
77
81
|
/* @__PURE__ */ jsx(
|
|
78
82
|
Button,
|
|
79
83
|
{
|
|
80
|
-
|
|
84
|
+
className: "mr-auto mb-4 ml-auto",
|
|
81
85
|
icon: /* @__PURE__ */ jsx(FaBullseye, {}),
|
|
82
|
-
|
|
83
|
-
onClick: () =>
|
|
86
|
+
variant: showDebugTestIds ? "solid" : "light",
|
|
87
|
+
onClick: () => {
|
|
88
|
+
setDebugMode(debugMode === "debug" ? "debug-testids" : "debug");
|
|
89
|
+
},
|
|
84
90
|
children: showDebugTestIds ? "Hide CopyButton" : "Show CopyButton"
|
|
85
91
|
}
|
|
86
92
|
),
|
|
@@ -123,20 +129,22 @@ var Form = ({
|
|
|
123
129
|
onSubmit,
|
|
124
130
|
validation,
|
|
125
131
|
validationTrigger,
|
|
126
|
-
children: ({ handleSubmit, isValid }) =>
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
children: ({ handleSubmit, isValid }) => {
|
|
133
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-row justify-between gap-6", children: [
|
|
134
|
+
/* @__PURE__ */ jsx2(
|
|
135
|
+
"form",
|
|
136
|
+
{
|
|
137
|
+
className: cn2("grow", className),
|
|
138
|
+
"data-form-is-valid": isValid,
|
|
139
|
+
"data-testid": slugify(testId || name || ""),
|
|
140
|
+
name,
|
|
141
|
+
onSubmit: handleSubmit,
|
|
142
|
+
children
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
!IS_TEST && !(debug == null ? void 0 : debug.disable) && /* @__PURE__ */ jsx2(FormDebugViewer_default, { className: "w-96 shrink" })
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
140
148
|
}
|
|
141
149
|
);
|
|
142
150
|
};
|
|
@@ -149,4 +157,4 @@ export {
|
|
|
149
157
|
Form_default,
|
|
150
158
|
Form_default2
|
|
151
159
|
};
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-HZKEIJP5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"sourcesContent":["import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId || name || '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting },\n getValues,\n setDebugMode,\n subscribe,\n validation: { errors },\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n const [validationValues, setValidationValues] = useState<Record<\n string,\n unknown\n > | null>(getValues() || null);\n\n // Subscribe to value updates only when needed and cleanup properly\n useEffect(() => {\n if (!showDebugCard) {\n return undefined;\n }\n\n const unsubscribe = subscribe({\n formState: { values: true },\n callback: ({ values }) => {\n setValidationValues(values);\n },\n });\n\n return unsubscribe;\n }, [showDebugCard, subscribe]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"text-default-400 fixed right-2.5 bottom-2.5 w-5\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mr-auto mb-4 ml-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values: validationValues,\n errors: errors || null,\n isValid,\n isSubmitting,\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;AAKA,SAAS,MAAAA,KAAI,eAAe;;;ACL5B,SAAS,WAAW,gBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,OAAO,kBAAkB;AAElC,SAAS,UAAU;AACnB,SAAS,cAAc;AACv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AA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,eAAQ;;;AExEf,IAAOG,gBAAQ;","names":["cn","jsx","jsxs","cn","Form_default"]}
|
|
@@ -29,7 +29,9 @@ var toFormFormat = (fields) => {
|
|
|
29
29
|
}
|
|
30
30
|
if (value && typeof value === "object") {
|
|
31
31
|
return Object.fromEntries(
|
|
32
|
-
Object.entries(value).filter(([_key, v]) =>
|
|
32
|
+
Object.entries(value).filter(([_key, v]) => {
|
|
33
|
+
return v !== "" && v !== null;
|
|
34
|
+
})
|
|
33
35
|
);
|
|
34
36
|
}
|
|
35
37
|
return value;
|
|
@@ -47,9 +49,11 @@ var toValidationFormat = (formState) => {
|
|
|
47
49
|
}
|
|
48
50
|
if (value && typeof value === "object") {
|
|
49
51
|
return Object.fromEntries(
|
|
50
|
-
Object.entries(value).filter(
|
|
51
|
-
|
|
52
|
-
).map(([k, v]) =>
|
|
52
|
+
Object.entries(value).filter(([_key, v]) => {
|
|
53
|
+
return fromNullishString(v) !== "" && fromNullishString(v) !== null;
|
|
54
|
+
}).map(([k, v]) => {
|
|
55
|
+
return [k, fromNullishString(v)];
|
|
56
|
+
})
|
|
53
57
|
);
|
|
54
58
|
}
|
|
55
59
|
return value;
|
|
@@ -63,4 +67,4 @@ var toValidationFormat = (formState) => {
|
|
|
63
67
|
|
|
64
68
|
|
|
65
69
|
exports.fromNullishString = fromNullishString; exports.toNullishString = toNullishString; exports.toFormFormat = toFormFormat; exports.toValidationFormat = toValidationFormat;
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
70
|
+
//# sourceMappingURL=chunk-LTQCM5VQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-LTQCM5VQ.cjs","../src/helpers/nullishFields/nullishFields.ts"],"names":[],"mappings":"AAAA;ACGA,IAAM,WAAA,EAAa,UAAA;AACnB,IAAM,YAAA,EAAc,WAAA;AACpB,IAA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/chunk-LTQCM5VQ.cjs","sourcesContent":[null,"/**\n * String markers used to preserve null, false, and 0 values during JSON processing\n */\nconst nullString = '__NULL__';\nconst falseString = '__FALSE__';\nconst zeroString = '__ZERO__';\n\n/**\n * Converts marker strings back to their original values when processing arrays\n */\nexport const fromNullishString = (value: unknown): unknown => {\n if (typeof value !== 'string') return value;\n\n switch (value) {\n case nullString:\n return null;\n case falseString:\n return false;\n case zeroString:\n return 0;\n default:\n return value;\n }\n};\n\n/**\n * Converts null/falsy values to marker strings for JSON processing\n */\nexport const toNullishString = (value: unknown): unknown => {\n if (value === null || value === '') return nullString;\n if (value === false) return falseString;\n if (value === 0) return zeroString;\n return value;\n};\n\n/**\n * Converts field values to a format suitable for forms by:\n * - Converting array values to their string markers to preserve null/falsy values\n * - Removing empty strings and null values from objects\n *\n * This conversion is required because React Hook Form does not support arrays with\n * flat values (string, number, boolean, null). Array fields must contain objects.\n * We work around this by converting array values to string markers.\n *\n * @example\n * const fields = {\n * name: 'John',\n * scores: [0, null, 75, false],\n * contact: {\n * email: '',\n * phone: null,\n * address: '123 Main St'\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: ['__ZERO__', '__NULL__', 75, '__FALSE__'],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toFormFormat = (\n fields: Record<string, unknown>,\n): Record<string, unknown> => {\n return JSON.parse(\n JSON.stringify(fields, (_, value) => {\n if (Array.isArray(value)) {\n return value.map(toNullishString);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).filter(([_key, v]) => {\n return v !== '' && v !== null;\n }),\n );\n }\n\n return value;\n }),\n );\n};\n\n/**\n * Converts form state to a format suitable for validation by:\n * - Converting array string markers (__NULL__, __FALSE__, __ZERO__) back to their original values\n * - Converting _NULL__ to null\n * - Removing fields that contain empty strings, null, or any string markers representing null/empty values\n *\n * @example\n * const formState = {\n * name: 'John',\n * scores: [75, '__ZERO__', '_NULL__', '__FALSE__'],\n * email: null,\n * phone: '__NULL__',\n * contact: {\n * address: '123 Main St',\n * fax: null\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: [75, 0, null, false],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toValidationFormat = (\n formState: Record<string, unknown> | null | undefined,\n): Record<string, unknown> | null | undefined => {\n // Handle null or undefined input\n if (formState === undefined || formState === null) {\n return formState;\n }\n\n return JSON.parse(\n JSON.stringify(formState, (_, value) => {\n if (Array.isArray(value)) {\n return value.map(fromNullishString);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value)\n .filter(([_key, v]) => {\n return (\n fromNullishString(v) !== '' && fromNullishString(v) !== null\n );\n })\n .map(([k, v]) => {\n return [k, fromNullishString(v)];\n }),\n );\n }\n\n return value;\n }),\n );\n};\n"]}
|
|
@@ -3,19 +3,20 @@ import {
|
|
|
3
3
|
} from "./chunk-B62HKKMS.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldCopyTestIdButton_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NTDKZW4E.js";
|
|
7
7
|
import {
|
|
8
8
|
FieldValidationError_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CQWA2DFV.js";
|
|
10
10
|
import {
|
|
11
11
|
useFieldArray,
|
|
12
12
|
useFormContext,
|
|
13
13
|
useInput
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OC76RMHG.js";
|
|
15
15
|
import {
|
|
16
16
|
toNullishString
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-V7QZNDTY.js";
|
|
18
18
|
import {
|
|
19
|
+
__async,
|
|
19
20
|
__spreadProps,
|
|
20
21
|
__spreadValues
|
|
21
22
|
} from "./chunk-K2V4ULA2.js";
|
|
@@ -136,18 +137,18 @@ var FieldArrayElement = ({
|
|
|
136
137
|
/* @__PURE__ */ jsxs(
|
|
137
138
|
"li",
|
|
138
139
|
{
|
|
139
|
-
className: cn4(className.listItem),
|
|
140
140
|
ref: setNodeRef,
|
|
141
|
+
className: cn4(className.listItem),
|
|
141
142
|
style: sortingStyle,
|
|
142
143
|
children: [
|
|
143
|
-
sortable
|
|
144
|
+
sortable ? /* @__PURE__ */ jsx4(
|
|
144
145
|
SortDragHandle_default,
|
|
145
146
|
{
|
|
146
147
|
className: className.sortDragHandle,
|
|
147
148
|
id,
|
|
148
149
|
testId: `${testId}_sort_drag_handle`
|
|
149
150
|
}
|
|
150
|
-
),
|
|
151
|
+
) : null,
|
|
151
152
|
/* @__PURE__ */ jsx4(
|
|
152
153
|
"div",
|
|
153
154
|
{
|
|
@@ -160,22 +161,26 @@ var FieldArrayElement = ({
|
|
|
160
161
|
ElementRemoveButton_default,
|
|
161
162
|
{
|
|
162
163
|
className: className.removeButton,
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
testId: `${testId}_remove_button`,
|
|
165
|
+
onClick: () => {
|
|
166
|
+
methods.remove();
|
|
167
|
+
}
|
|
165
168
|
}
|
|
166
169
|
),
|
|
167
|
-
insertAfter && index !== fields.length - 1
|
|
170
|
+
insertAfter && index !== fields.length - 1 ? /* @__PURE__ */ jsx4(
|
|
168
171
|
ElementInsertAfterButton_default,
|
|
169
172
|
{
|
|
170
173
|
className: className.insertAfterButton,
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
testId: `${testId}_insert_after_button`,
|
|
175
|
+
onClick: () => {
|
|
176
|
+
methods.insert();
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
|
-
)
|
|
179
|
+
) : null
|
|
175
180
|
]
|
|
176
181
|
}
|
|
177
182
|
),
|
|
178
|
-
error
|
|
183
|
+
typeof (error == null ? void 0 : error[index]) !== "undefined" && /* @__PURE__ */ jsx4("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx4("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx4(
|
|
179
184
|
FieldValidationError_default,
|
|
180
185
|
{
|
|
181
186
|
error: (_a = error[Number(index)]) == null ? void 0 : _a._errors,
|
|
@@ -220,8 +225,12 @@ var SortContext = ({
|
|
|
220
225
|
const handleDragEnd = (event) => {
|
|
221
226
|
const { active, over } = event;
|
|
222
227
|
if (active.id !== (over == null ? void 0 : over.id)) {
|
|
223
|
-
const oldIndex = fields.findIndex((field) =>
|
|
224
|
-
|
|
228
|
+
const oldIndex = fields.findIndex((field) => {
|
|
229
|
+
return field.id === active.id;
|
|
230
|
+
});
|
|
231
|
+
const newIndex = fields.findIndex((field) => {
|
|
232
|
+
return field.id === (over == null ? void 0 : over.id);
|
|
233
|
+
});
|
|
225
234
|
move(oldIndex, newIndex);
|
|
226
235
|
}
|
|
227
236
|
};
|
|
@@ -235,8 +244,10 @@ var SortContext = ({
|
|
|
235
244
|
children: /* @__PURE__ */ jsx5(
|
|
236
245
|
SortableContext,
|
|
237
246
|
{
|
|
238
|
-
items: fields.map((field) => field.id),
|
|
239
247
|
strategy: verticalListSortingStrategy,
|
|
248
|
+
items: fields.map((field) => {
|
|
249
|
+
return field.id;
|
|
250
|
+
}),
|
|
240
251
|
children
|
|
241
252
|
}
|
|
242
253
|
)
|
|
@@ -303,45 +314,55 @@ var FieldArray = ({
|
|
|
303
314
|
}
|
|
304
315
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
305
316
|
const showLabel = label || showTestIdCopyButton;
|
|
306
|
-
return /* @__PURE__ */ jsx6(SortContext_default, {
|
|
317
|
+
return /* @__PURE__ */ jsx6(SortContext_default, { fields, move, sortable, children: /* @__PURE__ */ jsxs2(
|
|
307
318
|
"ul",
|
|
308
319
|
{
|
|
309
320
|
className: className.list,
|
|
310
321
|
"data-testid": testId,
|
|
311
|
-
onBlur: () =>
|
|
322
|
+
onBlur: () => __async(null, null, function* () {
|
|
323
|
+
return trigger(name);
|
|
324
|
+
}),
|
|
312
325
|
children: [
|
|
313
|
-
showLabel
|
|
314
|
-
label
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
326
|
+
showLabel ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
327
|
+
label ? (
|
|
328
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
329
|
+
/* @__PURE__ */ jsx6(
|
|
330
|
+
"label",
|
|
331
|
+
__spreadProps(__spreadValues({}, getLabelProps()), {
|
|
332
|
+
className: cn5((_a = getLabelProps()) == null ? void 0 : _a.className, className.label),
|
|
333
|
+
children: label
|
|
334
|
+
})
|
|
335
|
+
)
|
|
336
|
+
) : null,
|
|
337
|
+
showTestIdCopyButton ? /* @__PURE__ */ jsx6(FieldCopyTestIdButton_default, { testId }) : null
|
|
338
|
+
] }) : null,
|
|
324
339
|
fields.map((field, index) => {
|
|
325
340
|
const elementName = `${name}.${index}`;
|
|
326
341
|
const elementTestId = `${testId}_${index}`;
|
|
327
342
|
const elementMethods = {
|
|
328
|
-
append: () =>
|
|
343
|
+
append: () => {
|
|
344
|
+
append(elementInitialValue);
|
|
345
|
+
},
|
|
329
346
|
duplicate: () => {
|
|
330
347
|
const values = getValues(name);
|
|
331
348
|
insert(index + 1, values[index]);
|
|
332
349
|
},
|
|
333
|
-
insert: () =>
|
|
334
|
-
|
|
350
|
+
insert: () => {
|
|
351
|
+
insert(index + 1, elementInitialValue);
|
|
352
|
+
},
|
|
353
|
+
remove: () => {
|
|
354
|
+
remove(index);
|
|
355
|
+
}
|
|
335
356
|
};
|
|
336
357
|
return /* @__PURE__ */ jsx6(
|
|
337
358
|
FieldArrayElement_default,
|
|
338
359
|
{
|
|
339
360
|
arrayFieldName: name,
|
|
340
361
|
className,
|
|
362
|
+
duplicate,
|
|
341
363
|
fields,
|
|
342
364
|
id: field.id,
|
|
343
365
|
index,
|
|
344
|
-
duplicate,
|
|
345
366
|
insertAfter,
|
|
346
367
|
lastNotDeletable: lastElementNotRemovable,
|
|
347
368
|
methods: elementMethods,
|
|
@@ -361,15 +382,17 @@ var FieldArray = ({
|
|
|
361
382
|
/* @__PURE__ */ jsx6(
|
|
362
383
|
Button3,
|
|
363
384
|
{
|
|
364
|
-
className: className.appendButton,
|
|
365
385
|
disableAnimation: true,
|
|
366
|
-
|
|
386
|
+
className: className.appendButton,
|
|
367
387
|
size: "sm",
|
|
368
388
|
testId: `${testId}_append_button`,
|
|
389
|
+
onClick: () => {
|
|
390
|
+
append(elementInitialValue);
|
|
391
|
+
},
|
|
369
392
|
children: appendButtonText
|
|
370
393
|
}
|
|
371
394
|
),
|
|
372
|
-
(error == null ? void 0 : error._errors)
|
|
395
|
+
(error == null ? void 0 : error._errors) ? /* @__PURE__ */ jsx6("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx6("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx6(FieldValidationError_default, { error: error == null ? void 0 : error._errors, testId }) })) })) : null
|
|
373
396
|
]
|
|
374
397
|
}
|
|
375
398
|
) });
|
|
@@ -383,4 +406,4 @@ export {
|
|
|
383
406
|
FieldArray_default,
|
|
384
407
|
FieldArray_default2
|
|
385
408
|
};
|
|
386
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-M52AKWAI.js.map
|