@fuf-stack/uniform 1.4.2 → 1.5.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/Checkboxes/index.cjs +16 -0
- package/dist/{RadioGroup → Checkboxes}/index.cjs.map +1 -1
- package/dist/Checkboxes/index.d.cts +10 -0
- package/dist/Checkboxes/index.d.ts +10 -0
- package/dist/Checkboxes/index.js +16 -0
- package/dist/{CheckboxGroup-B1g42iP0.d.cts → Checkboxes-CR0Uu2g9.d.cts} +9 -9
- package/dist/{CheckboxGroup-B1g42iP0.d.ts → Checkboxes-CR0Uu2g9.d.ts} +9 -9
- package/dist/FieldArray/index.cjs +5 -5
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +4 -4
- package/dist/FieldArray-EP4otr2x.d.cts +160 -0
- package/dist/FieldArray-EP4otr2x.d.ts +160 -0
- package/dist/{FieldValidationError-CU_xw0BL.d.ts → FieldValidationError-DwtLkGMo.d.cts} +2 -2
- package/dist/{FieldValidationError-CU_xw0BL.d.cts → FieldValidationError-DwtLkGMo.d.ts} +2 -2
- package/dist/Form/index.cjs +6 -4
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +5 -3
- package/dist/Input/index.cjs +5 -5
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +4 -4
- package/dist/{Input-C6ujfEkn.d.ts → Input-CCIEnvIp.d.ts} +1 -1
- package/dist/{Input-BQkZtJx8.d.cts → Input-D7HT_8jf.d.cts} +1 -1
- package/dist/RadioBoxes/index.cjs +5 -5
- package/dist/RadioBoxes/index.d.cts +3 -2
- package/dist/RadioBoxes/index.d.ts +3 -2
- package/dist/RadioBoxes/index.js +4 -4
- package/dist/{RadioBoxes-CE3mYoFk.d.cts → RadioBoxes-DpkI28l0.d.cts} +3 -2
- package/dist/{RadioBoxes-CE3mYoFk.d.ts → RadioBoxes-DpkI28l0.d.ts} +3 -2
- package/dist/RadioTabs/index.cjs +5 -5
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +4 -4
- package/dist/{RadioTabs-BCWW3tru.d.cts → RadioTabs-DTDcAZoH.d.cts} +1 -1
- package/dist/{RadioTabs-BCWW3tru.d.ts → RadioTabs-DTDcAZoH.d.ts} +1 -1
- package/dist/Radios/index.cjs +16 -0
- package/dist/Radios/index.cjs.map +1 -0
- package/dist/Radios/index.d.cts +9 -0
- package/dist/Radios/index.d.ts +9 -0
- package/dist/Radios/index.js +16 -0
- package/dist/{RadioGroup-CAOX80Xx.d.cts → Radios-DprlJhoq.d.cts} +9 -9
- package/dist/{RadioGroup-CAOX80Xx.d.ts → Radios-DprlJhoq.d.ts} +9 -9
- package/dist/Select/index.cjs +5 -5
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +4 -4
- package/dist/{Select-CTRWinmO.d.cts → Select-CDkZmZp2.d.cts} +1 -1
- package/dist/{Select-CTRWinmO.d.ts → Select-CDkZmZp2.d.ts} +1 -1
- package/dist/SubmitButton/index.cjs +6 -4
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +5 -3
- package/dist/Switch/index.cjs +5 -5
- package/dist/Switch/index.js +4 -4
- package/dist/TextArea/index.cjs +5 -5
- package/dist/TextArea/index.d.cts +4 -2
- package/dist/TextArea/index.d.ts +4 -2
- package/dist/TextArea/index.js +4 -4
- package/dist/TextArea-DhxNWYNg.d.cts +86 -0
- package/dist/TextArea-DhxNWYNg.d.ts +86 -0
- package/dist/{chunk-Y3GELCDP.js → chunk-2QLCCB3L.js} +62 -67
- package/dist/chunk-2QLCCB3L.js.map +1 -0
- package/dist/chunk-3YDAYNNB.cjs +683 -0
- package/dist/chunk-3YDAYNNB.cjs.map +1 -0
- package/dist/chunk-4GBNXNCZ.js +683 -0
- package/dist/chunk-4GBNXNCZ.js.map +1 -0
- package/dist/{chunk-ULR4573W.cjs → chunk-4MMOSRT3.cjs} +40 -38
- package/dist/chunk-4MMOSRT3.cjs.map +1 -0
- package/dist/{chunk-FHRMVL6B.js → chunk-62BVHALF.js} +134 -89
- package/dist/chunk-62BVHALF.js.map +1 -0
- package/dist/{chunk-UGCZORU3.cjs → chunk-65BN4MRG.cjs} +9 -9
- package/dist/chunk-65BN4MRG.cjs.map +1 -0
- package/dist/{chunk-2B6CDMOZ.js → chunk-74NPRJVH.js} +16 -25
- package/dist/chunk-74NPRJVH.js.map +1 -0
- package/dist/chunk-76KOVUDN.js +138 -0
- package/dist/chunk-76KOVUDN.js.map +1 -0
- package/dist/{chunk-AYNTZPKL.cjs → chunk-7NWHDCME.cjs} +132 -87
- package/dist/chunk-7NWHDCME.cjs.map +1 -0
- package/dist/{chunk-IYDCKENI.js → chunk-CFH4VPJ4.js} +166 -26
- package/dist/chunk-CFH4VPJ4.js.map +1 -0
- package/dist/{chunk-KG4XCEPW.js → chunk-COLAXULB.js} +42 -40
- package/dist/chunk-COLAXULB.js.map +1 -0
- package/dist/{chunk-N2EEOWEP.cjs → chunk-DHO4HSO7.cjs} +59 -64
- package/dist/chunk-DHO4HSO7.cjs.map +1 -0
- package/dist/{chunk-77C6VN4L.cjs → chunk-EAJFV3AD.cjs} +50 -47
- package/dist/chunk-EAJFV3AD.cjs.map +1 -0
- package/dist/chunk-ELYGQTXB.js +47 -0
- package/dist/chunk-ELYGQTXB.js.map +1 -0
- package/dist/{chunk-FOVP54XP.cjs → chunk-EO4A7QGM.cjs} +18 -27
- package/dist/chunk-EO4A7QGM.cjs.map +1 -0
- package/dist/chunk-GVMEDVT5.cjs +117 -0
- package/dist/chunk-GVMEDVT5.cjs.map +1 -0
- package/dist/chunk-HSKFVCTS.js +103 -0
- package/dist/chunk-HSKFVCTS.js.map +1 -0
- package/dist/{chunk-2GYFDVXX.cjs → chunk-J5FFM7WG.cjs} +173 -33
- package/dist/chunk-J5FFM7WG.cjs.map +1 -0
- package/dist/{chunk-M2DNMSQZ.js → chunk-JLJB4A4K.js} +52 -49
- package/dist/chunk-JLJB4A4K.js.map +1 -0
- package/dist/{chunk-C64RKQEW.cjs → chunk-KBUECB4B.cjs} +3 -3
- package/dist/{chunk-C64RKQEW.cjs.map → chunk-KBUECB4B.cjs.map} +1 -1
- package/dist/chunk-NHEZXA4H.cjs +47 -0
- package/dist/chunk-NHEZXA4H.cjs.map +1 -0
- package/dist/chunk-RTFM4VRY.cjs +103 -0
- package/dist/chunk-RTFM4VRY.cjs.map +1 -0
- package/dist/{chunk-LJQ35BUK.js → chunk-RW35BB4P.js} +2 -2
- package/dist/{chunk-M7VM7XBE.js → chunk-SLTUNYTD.js} +8 -8
- package/dist/chunk-SLTUNYTD.js.map +1 -0
- package/dist/{chunk-YEKHVKS3.cjs → chunk-TFMVYQGN.cjs} +44 -42
- package/dist/chunk-TFMVYQGN.cjs.map +1 -0
- package/dist/chunk-TVMCTUQ4.js +117 -0
- package/dist/chunk-TVMCTUQ4.js.map +1 -0
- package/dist/chunk-Z353BLWI.cjs +138 -0
- package/dist/chunk-Z353BLWI.cjs.map +1 -0
- package/dist/{chunk-C52NGPIF.js → chunk-ZQ64MG7T.js} +48 -46
- package/dist/chunk-ZQ64MG7T.js.map +1 -0
- package/dist/helpers/index.cjs +4 -2
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.d.cts +54 -10
- package/dist/helpers/index.d.ts +54 -10
- package/dist/helpers/index.js +3 -1
- package/dist/hooks/index.cjs +7 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +86 -4
- package/dist/hooks/index.d.ts +86 -4
- package/dist/hooks/index.js +8 -4
- package/dist/index.cjs +20 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +30 -26
- package/dist/partials/FieldValidationError/index.cjs +2 -2
- package/dist/partials/FieldValidationError/index.d.cts +2 -2
- package/dist/partials/FieldValidationError/index.d.ts +2 -2
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +12 -11
- package/dist/CheckboxGroup/index.cjs +0 -16
- package/dist/CheckboxGroup/index.cjs.map +0 -1
- package/dist/CheckboxGroup/index.d.cts +0 -10
- package/dist/CheckboxGroup/index.d.ts +0 -10
- package/dist/CheckboxGroup/index.js +0 -16
- package/dist/FieldArray-DVQka7Bh.d.cts +0 -130
- package/dist/FieldArray-DVQka7Bh.d.ts +0 -130
- package/dist/RadioGroup/index.cjs +0 -16
- package/dist/RadioGroup/index.d.cts +0 -9
- package/dist/RadioGroup/index.d.ts +0 -9
- package/dist/RadioGroup/index.js +0 -16
- package/dist/TextArea-DnFGyl4a.d.cts +0 -27
- package/dist/TextArea-DnFGyl4a.d.ts +0 -27
- package/dist/chunk-2B6CDMOZ.js.map +0 -1
- package/dist/chunk-2GYFDVXX.cjs.map +0 -1
- package/dist/chunk-77C6VN4L.cjs.map +0 -1
- package/dist/chunk-AYNTZPKL.cjs.map +0 -1
- package/dist/chunk-C52NGPIF.js.map +0 -1
- package/dist/chunk-CQWA2DFV.js +0 -37
- package/dist/chunk-CQWA2DFV.js.map +0 -1
- package/dist/chunk-EEBHFSBY.cjs +0 -112
- package/dist/chunk-EEBHFSBY.cjs.map +0 -1
- package/dist/chunk-FHRMVL6B.js.map +0 -1
- package/dist/chunk-FOVP54XP.cjs.map +0 -1
- package/dist/chunk-IYDCKENI.js.map +0 -1
- package/dist/chunk-JZF4HUYO.cjs +0 -409
- package/dist/chunk-JZF4HUYO.cjs.map +0 -1
- package/dist/chunk-KG4XCEPW.js.map +0 -1
- package/dist/chunk-KQN55PEW.js +0 -76
- package/dist/chunk-KQN55PEW.js.map +0 -1
- package/dist/chunk-M2DNMSQZ.js.map +0 -1
- package/dist/chunk-M7VM7XBE.js.map +0 -1
- package/dist/chunk-N2EEOWEP.cjs.map +0 -1
- package/dist/chunk-NAZIH6HV.js +0 -409
- package/dist/chunk-NAZIH6HV.js.map +0 -1
- package/dist/chunk-RDBCJJI7.cjs +0 -88
- package/dist/chunk-RDBCJJI7.cjs.map +0 -1
- package/dist/chunk-RF7KNUCI.js +0 -88
- package/dist/chunk-RF7KNUCI.js.map +0 -1
- package/dist/chunk-UGCZORU3.cjs.map +0 -1
- package/dist/chunk-ULR4573W.cjs.map +0 -1
- package/dist/chunk-XKMLCM5K.js +0 -112
- package/dist/chunk-XKMLCM5K.js.map +0 -1
- package/dist/chunk-Y3AB4GV6.cjs +0 -37
- package/dist/chunk-Y3AB4GV6.cjs.map +0 -1
- package/dist/chunk-Y3GELCDP.js.map +0 -1
- package/dist/chunk-YEKHVKS3.cjs.map +0 -1
- package/dist/chunk-YGNY6CKU.cjs +0 -76
- package/dist/chunk-YGNY6CKU.cjs.map +0 -1
- /package/dist/{CheckboxGroup → Checkboxes}/index.js.map +0 -0
- /package/dist/{RadioGroup → Radios}/index.js.map +0 -0
- /package/dist/{chunk-LJQ35BUK.js.map → chunk-RW35BB4P.js.map} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkJ5FFM7WGcjs = require('./chunk-J5FFM7WG.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk555JRYCScjs = require('./chunk-555JRYCS.cjs');
|
|
8
|
+
|
|
9
|
+
// src/Radios/Radios.tsx
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _radio = require('@heroui/radio');
|
|
14
|
+
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
15
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
16
|
+
var radiosVariants = _pixelutils.tv.call(void 0, {
|
|
17
|
+
slots: {
|
|
18
|
+
// Needs group for group-data condition
|
|
19
|
+
base: "group gap-0",
|
|
20
|
+
itemBase: "",
|
|
21
|
+
itemControl: "bg-focus group-data-[invalid=true]:bg-danger",
|
|
22
|
+
itemDescription: "",
|
|
23
|
+
itemLabel: "text-sm",
|
|
24
|
+
itemLabelWrapper: "",
|
|
25
|
+
itemWrapper: 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid="true"]):not(group-data-[selected="false"])]:border-focus',
|
|
26
|
+
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
27
|
+
label: "text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex text-sm subpixel-antialiased",
|
|
28
|
+
wrapper: ""
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var Radios = (_a) => {
|
|
32
|
+
var _b = _a, {
|
|
33
|
+
className = void 0,
|
|
34
|
+
inline = false,
|
|
35
|
+
name,
|
|
36
|
+
options
|
|
37
|
+
} = _b, uniformFieldProps = _chunk555JRYCScjs.__objRest.call(void 0, _b, [
|
|
38
|
+
"className",
|
|
39
|
+
"inline",
|
|
40
|
+
"name",
|
|
41
|
+
"options"
|
|
42
|
+
]);
|
|
43
|
+
const {
|
|
44
|
+
disabled,
|
|
45
|
+
errorMessage,
|
|
46
|
+
field: { onBlur, onChange, ref },
|
|
47
|
+
invalid,
|
|
48
|
+
label,
|
|
49
|
+
required,
|
|
50
|
+
defaultValue,
|
|
51
|
+
testId
|
|
52
|
+
} = _chunkJ5FFM7WGcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
53
|
+
name,
|
|
54
|
+
showInvalidWhen: "immediate"
|
|
55
|
+
}, uniformFieldProps));
|
|
56
|
+
const variants = radiosVariants();
|
|
57
|
+
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
58
|
+
const itemClassNames = {
|
|
59
|
+
base: classNames.itemBase,
|
|
60
|
+
control: classNames.itemControl,
|
|
61
|
+
description: classNames.itemDescription,
|
|
62
|
+
label: classNames.itemLabel,
|
|
63
|
+
labelWrapper: classNames.itemLabelWrapper,
|
|
64
|
+
wrapper: classNames.itemWrapper
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
67
|
+
_radio.RadioGroup,
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
classNames,
|
|
71
|
+
"data-invalid": invalid,
|
|
72
|
+
"data-required": required,
|
|
73
|
+
"data-testid": testId,
|
|
74
|
+
defaultValue,
|
|
75
|
+
errorMessage,
|
|
76
|
+
isDisabled: disabled,
|
|
77
|
+
isInvalid: invalid,
|
|
78
|
+
isRequired: required,
|
|
79
|
+
label: label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "legend", { children: label }) : null,
|
|
80
|
+
name,
|
|
81
|
+
onBlur,
|
|
82
|
+
orientation: inline ? "horizontal" : "vertical",
|
|
83
|
+
children: options.map((option) => {
|
|
84
|
+
var _a2, _b2;
|
|
85
|
+
if ("value" in option) {
|
|
86
|
+
const optionTestId = _pixelutils.slugify.call(void 0,
|
|
87
|
+
`${testId}_option_${(_a2 = option.testId) != null ? _a2 : option.value}`,
|
|
88
|
+
{ replaceDots: true }
|
|
89
|
+
);
|
|
90
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
91
|
+
_radio.Radio,
|
|
92
|
+
{
|
|
93
|
+
classNames: itemClassNames,
|
|
94
|
+
"data-testid": optionTestId,
|
|
95
|
+
isDisabled: !!disabled || option.disabled,
|
|
96
|
+
onChange,
|
|
97
|
+
value: option.value,
|
|
98
|
+
children: (_b2 = option.label) != null ? _b2 : option.value
|
|
99
|
+
},
|
|
100
|
+
option.value
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
var Radios_default = Radios;
|
|
109
|
+
|
|
110
|
+
// src/Radios/index.ts
|
|
111
|
+
var Radios_default2 = Radios_default;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
exports.Radios_default = Radios_default; exports.Radios_default2 = Radios_default2;
|
|
117
|
+
//# sourceMappingURL=chunk-GVMEDVT5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-GVMEDVT5.cjs","../src/Radios/Radios.tsx","../src/Radios/index.ts"],"names":["_a","_b","Radios_default"],"mappings":"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","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-GVMEDVT5.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\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',\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex text-sm subpixel-antialiased',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\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 ref={ref}\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={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-CFH4VPJ4.js";
|
|
4
|
+
import {
|
|
5
|
+
useInputValueDebounce
|
|
6
|
+
} from "./chunk-6IU7IYYB.js";
|
|
7
|
+
import {
|
|
8
|
+
__objRest,
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "./chunk-K2V4ULA2.js";
|
|
11
|
+
|
|
12
|
+
// src/TextArea/TextArea.tsx
|
|
13
|
+
import { Textarea as HeroTextArea } from "@heroui/input";
|
|
14
|
+
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var textAreaVariants = tv({
|
|
17
|
+
slots: {
|
|
18
|
+
/** wrapper around the whole input */
|
|
19
|
+
base: "",
|
|
20
|
+
/** clear button */
|
|
21
|
+
clearButton: "",
|
|
22
|
+
/** actual input element */
|
|
23
|
+
input: "",
|
|
24
|
+
/** inner wrapper (HeroUI inputWrapper slot) */
|
|
25
|
+
inputWrapper: "bg-content1 group-data-[focus=true]:border-focus"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var TextArea = (_a) => {
|
|
29
|
+
var _b = _a, {
|
|
30
|
+
children = null,
|
|
31
|
+
className: _className = void 0,
|
|
32
|
+
debounceDelay = 300,
|
|
33
|
+
name,
|
|
34
|
+
placeholder = " "
|
|
35
|
+
} = _b, uniformFieldProps = __objRest(_b, [
|
|
36
|
+
"children",
|
|
37
|
+
"className",
|
|
38
|
+
"debounceDelay",
|
|
39
|
+
"name",
|
|
40
|
+
"placeholder"
|
|
41
|
+
]);
|
|
42
|
+
const {
|
|
43
|
+
disabled,
|
|
44
|
+
errorMessage,
|
|
45
|
+
field: {
|
|
46
|
+
onChange: fieldOnChange,
|
|
47
|
+
onBlur: fieldOnBlur,
|
|
48
|
+
value: fieldValue,
|
|
49
|
+
ref
|
|
50
|
+
},
|
|
51
|
+
invalid,
|
|
52
|
+
label,
|
|
53
|
+
required,
|
|
54
|
+
testId
|
|
55
|
+
} = useUniformField(__spreadValues({ name }, uniformFieldProps));
|
|
56
|
+
const { onChange, onBlur, value } = useInputValueDebounce({
|
|
57
|
+
debounceDelay,
|
|
58
|
+
onBlur: fieldOnBlur,
|
|
59
|
+
onChange: fieldOnChange,
|
|
60
|
+
value: fieldValue
|
|
61
|
+
});
|
|
62
|
+
const variants = textAreaVariants();
|
|
63
|
+
const classNames = variantsToClassNames(variants, _className, "base");
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
HeroTextArea,
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
"data-testid": testId,
|
|
69
|
+
errorMessage,
|
|
70
|
+
id: testId,
|
|
71
|
+
isDisabled: disabled,
|
|
72
|
+
isInvalid: invalid,
|
|
73
|
+
isRequired: required,
|
|
74
|
+
label,
|
|
75
|
+
labelPlacement: "outside",
|
|
76
|
+
name,
|
|
77
|
+
onBlur,
|
|
78
|
+
onChange,
|
|
79
|
+
placeholder,
|
|
80
|
+
value,
|
|
81
|
+
variant: "bordered",
|
|
82
|
+
classNames: {
|
|
83
|
+
base: classNames.base,
|
|
84
|
+
clearButton: classNames.clearButton,
|
|
85
|
+
// set padding to 0 for error message exit animation
|
|
86
|
+
helperWrapper: "p-0",
|
|
87
|
+
input: classNames.input,
|
|
88
|
+
inputWrapper: classNames.inputWrapper
|
|
89
|
+
},
|
|
90
|
+
children
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
var TextArea_default = TextArea;
|
|
95
|
+
|
|
96
|
+
// src/TextArea/index.ts
|
|
97
|
+
var TextArea_default2 = TextArea_default;
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
TextArea_default,
|
|
101
|
+
TextArea_default2
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=chunk-HSKFVCTS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce, useUniformField } from '../hooks';\n\n// input variants\nexport const textAreaVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof textAreaVariants>;\ntype ClassName = TVClassName<typeof textAreaVariants>;\n\nexport interface TextAreaProps extends VariantProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\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: _className = undefined,\n debounceDelay = 300,\n name,\n placeholder = ' ',\n ...uniformFieldProps\n}: TextAreaProps) => {\n const {\n disabled,\n errorMessage,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use debounced handlers for form updates\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // classNames from slots\n const variants = textAreaVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroTextArea\n ref={ref}\n data-testid={testId}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n value={value as string}\n variant=\"bordered\"\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\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":";;;;;;;;;;;;AAGA,SAAS,YAAY,oBAAoB;AAEzC,SAAS,IAAI,4BAA4B;AA+ErC;AA1EG,IAAM,mBAAmB,GAAG;AAAA,EACjC,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA;AAAA,IAEN,aAAa;AAAA;AAAA,IAEb,OAAO;AAAA;AAAA,IAEP,cAAc;AAAA,EAChB;AACF,CAAC;AA2BD,IAAM,WAAW,CAAC,OAOG;AAPH,eAChB;AAAA,eAAW;AAAA,IACX,WAAW,aAAa;AAAA,IACxB,gBAAgB;AAAA,IAChB;AAAA,IACA,cAAc;AAAA,EArDhB,IAgDkB,IAMb,8BANa,IAMb;AAAA,IALH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,gBAAgB,iBAAE,QAAS,kBAAmB;AAGlD,QAAM,EAAE,UAAU,QAAQ,MAAM,IAAI,sBAAsB;AAAA,IACxD;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,EACT,CAAC;AAGD,QAAM,WAAW,iBAAiB;AAClC,QAAM,aAAa,qBAAqB,UAAU,YAAY,MAAM;AAEpE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAa;AAAA,MACb;AAAA,MACA,IAAI;AAAA,MACJ,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,YAAY;AAAA,MACZ;AAAA,MACA,gBAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAQ;AAAA,MACR,YAAY;AAAA,QACV,MAAM,WAAW;AAAA,QACjB,aAAa,WAAW;AAAA;AAAA,QAExB,eAAe;AAAA,QACf,OAAO,WAAW;AAAA,QAClB,cAAc,WAAW;AAAA,MAC3B;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,mBAAQ;;;AC5Gf,IAAOA,oBAAQ;","names":["TextArea_default"]}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
+
var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
var
|
|
6
|
+
var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkZ353BLWIcjs = require('./chunk-Z353BLWI.cjs');
|
|
6
14
|
|
|
7
15
|
|
|
8
16
|
|
|
@@ -101,7 +109,7 @@ var useFormResolver = (extendedValidation) => {
|
|
|
101
109
|
}
|
|
102
110
|
return (values) => _chunk555JRYCScjs.__async.call(void 0, null, null, function* () {
|
|
103
111
|
var _a, _b, _c, _d;
|
|
104
|
-
const validationValues = (_a =
|
|
112
|
+
const validationValues = (_a = _chunkZ353BLWIcjs.toValidationFormat.call(void 0, values)) != null ? _a : {};
|
|
105
113
|
const result = yield extendedValidation.validateAsync(validationValues);
|
|
106
114
|
validationErrors.current = (_b = result.errors) != null ? _b : void 0;
|
|
107
115
|
return {
|
|
@@ -121,23 +129,28 @@ var useFormResolver = (extendedValidation) => {
|
|
|
121
129
|
// src/Form/subcomponents/FormContext.tsx
|
|
122
130
|
var _jsxruntime = require('react/jsx-runtime');
|
|
123
131
|
var DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = "uniform:debug-mode";
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
if (!window.__UNIFORM_CONTEXT__) {
|
|
133
|
+
window.__UNIFORM_CONTEXT__ = _react2.default.createContext(
|
|
134
|
+
{
|
|
135
|
+
debugMode: "off",
|
|
136
|
+
preventSubmit: () => {
|
|
137
|
+
return void 0;
|
|
138
|
+
},
|
|
139
|
+
setDebugMode: () => {
|
|
140
|
+
return void 0;
|
|
141
|
+
},
|
|
142
|
+
triggerSubmit: () => {
|
|
143
|
+
return void 0;
|
|
144
|
+
},
|
|
145
|
+
validation: {
|
|
146
|
+
setClientValidationSchema: () => {
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
138
150
|
}
|
|
139
|
-
|
|
140
|
-
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
var UniformContext = window.__UNIFORM_CONTEXT__;
|
|
141
154
|
var FormProvider = ({
|
|
142
155
|
children,
|
|
143
156
|
debugModeSettings = void 0,
|
|
@@ -154,7 +167,7 @@ var FormProvider = ({
|
|
|
154
167
|
const { extendedValidation, setClientValidationSchema } = useExtendedValidation(baseValidation);
|
|
155
168
|
const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation);
|
|
156
169
|
const methods = _reacthookform.useForm.call(void 0, {
|
|
157
|
-
defaultValues: initialValues,
|
|
170
|
+
defaultValues: initialValues ? _chunkZ353BLWIcjs.toFormFormat.call(void 0, initialValues) : initialValues,
|
|
158
171
|
// set rhf mode
|
|
159
172
|
// see: https://react-hook-form.com/docs/useform#mode
|
|
160
173
|
mode: validationTrigger,
|
|
@@ -172,7 +185,7 @@ var FormProvider = ({
|
|
|
172
185
|
}
|
|
173
186
|
const wrappedOnSubmit = (data, event) => {
|
|
174
187
|
var _a2;
|
|
175
|
-
const submitData = (_a2 =
|
|
188
|
+
const submitData = (_a2 = _chunkZ353BLWIcjs.toValidationFormat.call(void 0, data)) != null ? _a2 : {};
|
|
176
189
|
return onSubmit(submitData, event);
|
|
177
190
|
};
|
|
178
191
|
yield methods.handleSubmit(wrappedOnSubmit)(e);
|
|
@@ -206,13 +219,30 @@ var FormContext_default = FormProvider;
|
|
|
206
219
|
// src/hooks/useFormContext/useFormContext.ts
|
|
207
220
|
var checkFieldIsRequired = (validation, path) => {
|
|
208
221
|
const checkRequired = (schema) => {
|
|
209
|
-
if (schema.type === "array"
|
|
222
|
+
if (schema.type === "array") {
|
|
223
|
+
if (schema.isOptional || schema.isNullable) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
210
226
|
return true;
|
|
211
227
|
}
|
|
212
228
|
return !schema.isOptional && !schema.isNullable;
|
|
213
229
|
};
|
|
214
230
|
return validation.checkSchemaPath(checkRequired, path);
|
|
215
231
|
};
|
|
232
|
+
var getValidationErrorsByName = (errors, name) => {
|
|
233
|
+
const keys = name.split(".").filter((k) => {
|
|
234
|
+
return k !== _chunkZ353BLWIcjs.flatArrayKey;
|
|
235
|
+
});
|
|
236
|
+
let current = errors;
|
|
237
|
+
keys.forEach((key) => {
|
|
238
|
+
if (current && typeof current === "object") {
|
|
239
|
+
current = current[key];
|
|
240
|
+
} else {
|
|
241
|
+
current = void 0;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return current;
|
|
245
|
+
};
|
|
216
246
|
var useFormContext = () => {
|
|
217
247
|
const _a = _reacthookform.useFormContext.call(void 0, ), {
|
|
218
248
|
formState,
|
|
@@ -230,23 +260,29 @@ var useFormContext = () => {
|
|
|
230
260
|
]);
|
|
231
261
|
const uniformContext = _react.useContext.call(void 0, UniformContext);
|
|
232
262
|
const getFieldState = (name, testId) => {
|
|
263
|
+
var _a2;
|
|
233
264
|
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
265
|
+
const validationInstance = uniformContext == null ? void 0 : uniformContext.validation.instance;
|
|
266
|
+
const required = validationInstance ? checkFieldIsRequired(validationInstance, fieldPath) : false;
|
|
267
|
+
const error = getValidationErrorsByName(
|
|
268
|
+
(_a2 = uniformContext == null ? void 0 : uniformContext.validation.errors) != null ? _a2 : {},
|
|
269
|
+
name
|
|
270
|
+
);
|
|
271
|
+
const fieldState = getFieldStateOrig(name, formState);
|
|
272
|
+
return _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, fieldState), {
|
|
237
273
|
error,
|
|
238
|
-
|
|
274
|
+
invalid: !!error,
|
|
239
275
|
required,
|
|
240
|
-
testId: _pixelutils.slugify.call(void 0, testId
|
|
276
|
+
testId: _pixelutils.slugify.call(void 0, testId != null ? testId : name, { replaceDots: true })
|
|
241
277
|
});
|
|
242
278
|
};
|
|
243
279
|
const getValues = ((...args) => {
|
|
244
280
|
const result = getValuesOrig(...args);
|
|
245
|
-
return
|
|
281
|
+
return _chunkZ353BLWIcjs.toValidationFormat.call(void 0, result);
|
|
246
282
|
});
|
|
247
283
|
const watch = ((...args) => {
|
|
248
284
|
const result = watchOrig(...args);
|
|
249
|
-
return
|
|
285
|
+
return _chunkZ353BLWIcjs.toValidationFormat.call(void 0, result);
|
|
250
286
|
});
|
|
251
287
|
const subscribe = ((...args) => {
|
|
252
288
|
const [options] = args;
|
|
@@ -255,7 +291,7 @@ var useFormContext = () => {
|
|
|
255
291
|
const wrappedOptions = _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, options), {
|
|
256
292
|
callback: (subscribeFormState) => {
|
|
257
293
|
const convertedFormState = _chunk555JRYCScjs.__spreadValues.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, subscribeFormState), subscribeFormState.values && {
|
|
258
|
-
values:
|
|
294
|
+
values: _chunkZ353BLWIcjs.toValidationFormat.call(void 0, subscribeFormState.values)
|
|
259
295
|
});
|
|
260
296
|
return originalCallback(convertedFormState);
|
|
261
297
|
}
|
|
@@ -312,10 +348,10 @@ var useController = (props) => {
|
|
|
312
348
|
onChange: (...event) => {
|
|
313
349
|
var _a, _b, _c;
|
|
314
350
|
const value = (_c = (_b = (_a = event[0]) == null ? void 0 : _a.target) == null ? void 0 : _b.value) != null ? _c : event[0];
|
|
315
|
-
field.onChange(value === "" ? "" :
|
|
351
|
+
field.onChange(value === "" ? "" : _chunkZ353BLWIcjs.toNullishString.call(void 0, value));
|
|
316
352
|
},
|
|
317
353
|
// Convert null/undefined to empty string for UI display
|
|
318
|
-
value:
|
|
354
|
+
value: _chunkZ353BLWIcjs.fromNullishString.call(void 0, field.value)
|
|
319
355
|
}),
|
|
320
356
|
formState,
|
|
321
357
|
fieldState
|
|
@@ -328,6 +364,110 @@ var useController = (props) => {
|
|
|
328
364
|
// src/hooks/useInput/useInput.ts
|
|
329
365
|
var _input = require('@heroui/input');
|
|
330
366
|
|
|
367
|
+
// src/hooks/useUniformField/useUniformField.tsx
|
|
368
|
+
|
|
369
|
+
var _pixelmotion = require('@fuf-stack/pixel-motion');
|
|
370
|
+
|
|
371
|
+
var useDebouncedInvalid = (value, delayMs) => {
|
|
372
|
+
const [state, setState] = _react.useState.call(void 0, value);
|
|
373
|
+
const timeoutRef = _react.useRef.call(void 0, null);
|
|
374
|
+
const prefersReducedMotion = _pixelmotion.useReducedMotion.call(void 0, );
|
|
375
|
+
_react.useEffect.call(void 0, () => {
|
|
376
|
+
if (prefersReducedMotion) {
|
|
377
|
+
if (timeoutRef.current) {
|
|
378
|
+
clearTimeout(timeoutRef.current);
|
|
379
|
+
timeoutRef.current = null;
|
|
380
|
+
}
|
|
381
|
+
setState(value);
|
|
382
|
+
return void 0;
|
|
383
|
+
}
|
|
384
|
+
if (timeoutRef.current) {
|
|
385
|
+
clearTimeout(timeoutRef.current);
|
|
386
|
+
}
|
|
387
|
+
timeoutRef.current = setTimeout(() => {
|
|
388
|
+
setState(value);
|
|
389
|
+
timeoutRef.current = null;
|
|
390
|
+
}, delayMs);
|
|
391
|
+
return () => {
|
|
392
|
+
if (timeoutRef.current) {
|
|
393
|
+
clearTimeout(timeoutRef.current);
|
|
394
|
+
timeoutRef.current = null;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
}, [value, delayMs, prefersReducedMotion]);
|
|
398
|
+
return state;
|
|
399
|
+
};
|
|
400
|
+
function useUniformField(params) {
|
|
401
|
+
var _a;
|
|
402
|
+
const {
|
|
403
|
+
name,
|
|
404
|
+
disabled = false,
|
|
405
|
+
testId: explicitTestId,
|
|
406
|
+
label,
|
|
407
|
+
showInvalidWhen = "touched"
|
|
408
|
+
} = params;
|
|
409
|
+
const {
|
|
410
|
+
control,
|
|
411
|
+
debugMode,
|
|
412
|
+
formState: { submitCount },
|
|
413
|
+
getFieldState,
|
|
414
|
+
getValues,
|
|
415
|
+
resetField
|
|
416
|
+
} = useFormContext();
|
|
417
|
+
const {
|
|
418
|
+
error,
|
|
419
|
+
invalid: rawInvalid,
|
|
420
|
+
isTouched,
|
|
421
|
+
required,
|
|
422
|
+
testId
|
|
423
|
+
} = getFieldState(name, explicitTestId);
|
|
424
|
+
const { field } = useController({ control, disabled, name });
|
|
425
|
+
const { onChange, disabled: isDisabled, onBlur, ref } = field;
|
|
426
|
+
const defaultValue = (_a = getValues()) == null ? void 0 : _a[name];
|
|
427
|
+
const invalid = useDebouncedInvalid(rawInvalid, 200);
|
|
428
|
+
const showInvalid = showInvalidWhen === "immediate" ? invalid || submitCount > 0 : invalid && (isTouched || submitCount > 0);
|
|
429
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
430
|
+
const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
431
|
+
label !== false ? label : null,
|
|
432
|
+
showTestIdCopyButton ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOE5BOGGXcjs.FieldCopyTestIdButton_default, { testId }) : null
|
|
433
|
+
] }) : null;
|
|
434
|
+
const errorMessage = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNHEZXA4Hcjs.FieldValidationError_default, { error, testId });
|
|
435
|
+
const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } = _input.useInput.call(void 0, {
|
|
436
|
+
ref,
|
|
437
|
+
classNames: {
|
|
438
|
+
// set padding to 0 for error message exit animation
|
|
439
|
+
helperWrapper: "p-0"
|
|
440
|
+
},
|
|
441
|
+
errorMessage: JSON.stringify(error),
|
|
442
|
+
isInvalid: invalid,
|
|
443
|
+
isRequired: required,
|
|
444
|
+
label,
|
|
445
|
+
labelPlacement: "outside"
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
control,
|
|
449
|
+
debugMode,
|
|
450
|
+
defaultValue,
|
|
451
|
+
disabled: isDisabled,
|
|
452
|
+
error,
|
|
453
|
+
errorMessage,
|
|
454
|
+
field,
|
|
455
|
+
getErrorMessageProps,
|
|
456
|
+
getHelperWrapperProps,
|
|
457
|
+
getLabelProps,
|
|
458
|
+
getValues,
|
|
459
|
+
invalid: showInvalid,
|
|
460
|
+
label: labelNode,
|
|
461
|
+
onBlur,
|
|
462
|
+
onChange,
|
|
463
|
+
ref,
|
|
464
|
+
required,
|
|
465
|
+
resetField,
|
|
466
|
+
testId
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
|
|
331
471
|
|
|
332
472
|
|
|
333
473
|
|
|
@@ -336,5 +476,5 @@ var _input = require('@heroui/input');
|
|
|
336
476
|
|
|
337
477
|
|
|
338
478
|
|
|
339
|
-
exports.FormContext_default = FormContext_default; exports.checkFieldIsRequired = checkFieldIsRequired; exports.useFormContext = useFormContext; exports.useClientValidation = useClientValidation; exports.useController = useController; exports.useFieldArray = _reacthookform.useFieldArray; exports.useInput = _input.useInput;
|
|
340
|
-
//# sourceMappingURL=chunk-
|
|
479
|
+
exports.FormContext_default = FormContext_default; exports.checkFieldIsRequired = checkFieldIsRequired; exports.useFormContext = useFormContext; exports.useClientValidation = useClientValidation; exports.useController = useController; exports.useFieldArray = _reacthookform.useFieldArray; exports.useInput = _input.useInput; exports.useUniformField = useUniformField;
|
|
480
|
+
//# sourceMappingURL=chunk-J5FFM7WG.cjs.map
|