@fuf-stack/uniform 1.5.7 → 1.6.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 +12 -6
- package/dist/Checkboxes/index.cjs.map +1 -1
- package/dist/Checkboxes/index.js +11 -5
- package/dist/FieldArray/index.cjs +12 -6
- package/dist/FieldArray/index.cjs.map +1 -1
- package/dist/FieldArray/index.js +11 -5
- package/dist/Form/index.cjs +12 -6
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +11 -5
- package/dist/Input/index.cjs +12 -6
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.js +11 -5
- package/dist/RadioBoxes/index.cjs +12 -6
- package/dist/RadioBoxes/index.cjs.map +1 -1
- package/dist/RadioBoxes/index.js +11 -5
- package/dist/RadioTabs/index.cjs +12 -6
- package/dist/RadioTabs/index.cjs.map +1 -1
- package/dist/RadioTabs/index.js +11 -5
- package/dist/Radios/index.cjs +12 -6
- package/dist/Radios/index.cjs.map +1 -1
- package/dist/Radios/index.js +11 -5
- package/dist/Select/index.cjs +12 -6
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.js +11 -5
- package/dist/SubmitButton/index.cjs +12 -6
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +11 -5
- package/dist/Switch/index.cjs +12 -6
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.js +11 -5
- package/dist/TextArea/index.cjs +12 -6
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +11 -5
- package/dist/{chunk-KORRVEJL.cjs → chunk-345LYO4H.cjs} +3 -3
- package/dist/{chunk-KORRVEJL.cjs.map → chunk-345LYO4H.cjs.map} +1 -1
- package/dist/chunk-35V726MB.js +1 -0
- package/dist/chunk-35V726MB.js.map +1 -0
- package/dist/{chunk-RBQP2VHW.js → chunk-6C6YW5TM.js} +2 -2
- package/dist/{chunk-MLAU2DYU.cjs → chunk-A5Z75X7M.cjs} +3 -3
- package/dist/{chunk-MLAU2DYU.cjs.map → chunk-A5Z75X7M.cjs.map} +1 -1
- package/dist/chunk-AACO4OEK.cjs +100 -0
- package/dist/chunk-AACO4OEK.cjs.map +1 -0
- package/dist/chunk-AHJJIANM.js +7 -0
- package/dist/chunk-AHJJIANM.js.map +1 -0
- package/dist/{chunk-DFDZFIQN.js → chunk-BXGILW5C.js} +4 -4
- package/dist/chunk-CHNYQVWO.js +59 -0
- package/dist/chunk-CHNYQVWO.js.map +1 -0
- package/dist/chunk-CK362NWK.js +34 -0
- package/dist/chunk-CK362NWK.js.map +1 -0
- package/dist/chunk-D3NAUOYG.js +122 -0
- package/dist/chunk-D3NAUOYG.js.map +1 -0
- package/dist/{chunk-EALQ3KNW.cjs → chunk-E4DCVJS5.cjs} +3 -3
- package/dist/{chunk-EALQ3KNW.cjs.map → chunk-E4DCVJS5.cjs.map} +1 -1
- package/dist/{chunk-GE2QRIOE.cjs → chunk-F6JQYB53.cjs} +4 -4
- package/dist/{chunk-GE2QRIOE.cjs.map → chunk-F6JQYB53.cjs.map} +1 -1
- package/dist/{chunk-2ZM4P4G3.js → chunk-GUPJNFEX.js} +10 -6
- package/dist/{chunk-2ZM4P4G3.js.map → chunk-GUPJNFEX.js.map} +1 -1
- package/dist/{chunk-TCJK6IYV.js → chunk-H24QXVUI.js} +2 -2
- package/dist/{chunk-7FTSMHFL.js → chunk-HQGTCSHK.js} +2 -2
- package/dist/{chunk-CSTA3NED.cjs → chunk-IYULWK4H.cjs} +7 -5
- package/dist/chunk-IYULWK4H.cjs.map +1 -0
- package/dist/{chunk-LEEWUHKX.js → chunk-JKWNYLNS.js} +4 -4
- package/dist/chunk-JMFDNTVC.cjs +34 -0
- package/dist/chunk-JMFDNTVC.cjs.map +1 -0
- package/dist/chunk-LTKRK3OS.cjs +1 -0
- package/dist/chunk-LTKRK3OS.cjs.map +1 -0
- package/dist/{chunk-QIIMEQS3.js → chunk-MXUKW3PZ.js} +2 -2
- package/dist/{chunk-3UIFEC4R.cjs → chunk-NZBO4N3S.cjs} +3 -260
- package/dist/chunk-NZBO4N3S.cjs.map +1 -0
- package/dist/{chunk-UO52HWMC.cjs → chunk-NZIAIYPS.cjs} +4 -4
- package/dist/{chunk-UO52HWMC.cjs.map → chunk-NZIAIYPS.cjs.map} +1 -1
- package/dist/{chunk-P7Z25LOZ.cjs → chunk-OJHD2XHD.cjs} +3 -3
- package/dist/{chunk-P7Z25LOZ.cjs.map → chunk-OJHD2XHD.cjs.map} +1 -1
- package/dist/chunk-PCTYJUY7.cjs +7 -0
- package/dist/chunk-PCTYJUY7.cjs.map +1 -0
- package/dist/{chunk-47MZU3WD.js → chunk-PO5UQAU6.js} +2 -259
- package/dist/chunk-PO5UQAU6.js.map +1 -0
- package/dist/{chunk-UB44OT6Q.js → chunk-QRCV7JVB.js} +2 -2
- package/dist/{chunk-A5MP4JAG.cjs → chunk-RMCPVDAC.cjs} +3 -3
- package/dist/{chunk-A5MP4JAG.cjs.map → chunk-RMCPVDAC.cjs.map} +1 -1
- package/dist/{chunk-B5OTVY3W.js → chunk-SJZ7UUEE.js} +5 -3
- package/dist/{chunk-B5OTVY3W.js.map → chunk-SJZ7UUEE.js.map} +1 -1
- package/dist/chunk-TEIXBRF5.cjs +59 -0
- package/dist/chunk-TEIXBRF5.cjs.map +1 -0
- package/dist/chunk-TGJJZEHB.cjs +122 -0
- package/dist/chunk-TGJJZEHB.cjs.map +1 -0
- package/dist/{chunk-33X26MSK.js → chunk-TKFODQWI.js} +2 -2
- package/dist/{chunk-X5WF3MEZ.cjs → chunk-VPUMTPD3.cjs} +3 -3
- package/dist/{chunk-X5WF3MEZ.cjs.map → chunk-VPUMTPD3.cjs.map} +1 -1
- package/dist/{chunk-JABO2635.cjs → chunk-WFO4XPA3.cjs} +4 -4
- package/dist/{chunk-JABO2635.cjs.map → chunk-WFO4XPA3.cjs.map} +1 -1
- package/dist/{chunk-4XTUP7W7.cjs → chunk-XJBGXFVX.cjs} +10 -6
- package/dist/chunk-XJBGXFVX.cjs.map +1 -0
- package/dist/chunk-Z7FVILDT.js +100 -0
- package/dist/chunk-Z7FVILDT.js.map +1 -0
- package/dist/{chunk-LKBR2JGT.js → chunk-Z7NI5347.js} +2 -2
- package/dist/hooks/index.cjs +20 -7
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +10 -240
- package/dist/hooks/index.d.ts +10 -240
- package/dist/hooks/index.js +25 -12
- package/dist/hooks/useClientValidation/index.cjs +12 -0
- package/dist/hooks/useClientValidation/index.cjs.map +1 -0
- package/dist/hooks/useClientValidation/index.d.cts +78 -0
- package/dist/hooks/useClientValidation/index.d.ts +78 -0
- package/dist/hooks/useClientValidation/index.js +12 -0
- package/dist/hooks/useClientValidation/index.js.map +1 -0
- package/dist/hooks/useController/index.cjs +9 -0
- package/dist/hooks/useController/index.cjs.map +1 -0
- package/dist/hooks/useController/index.d.cts +28 -0
- package/dist/hooks/useController/index.d.ts +28 -0
- package/dist/hooks/useController/index.js +9 -0
- package/dist/hooks/useController/index.js.map +1 -0
- package/dist/hooks/useFormContext/index.cjs +11 -0
- package/dist/hooks/useFormContext/index.cjs.map +1 -0
- package/dist/hooks/useFormContext/index.d.cts +50 -0
- package/dist/hooks/useFormContext/index.d.ts +50 -0
- package/dist/hooks/useFormContext/index.js +11 -0
- package/dist/hooks/useFormContext/index.js.map +1 -0
- package/dist/hooks/useInput/index.cjs +8 -0
- package/dist/hooks/useInput/index.cjs.map +1 -0
- package/dist/hooks/useInput/index.d.cts +1 -0
- package/dist/hooks/useInput/index.d.ts +1 -0
- package/dist/hooks/useInput/index.js +8 -0
- package/dist/hooks/useInput/index.js.map +1 -0
- package/dist/hooks/useUniformField/index.cjs +14 -0
- package/dist/hooks/useUniformField/index.cjs.map +1 -0
- package/dist/hooks/useUniformField/index.d.cts +83 -0
- package/dist/hooks/useUniformField/index.d.ts +83 -0
- package/dist/hooks/useUniformField/index.js +14 -0
- package/dist/hooks/useUniformField/index.js.map +1 -0
- package/dist/hooks/useUniformFieldArray/index.cjs +15 -0
- package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -0
- package/dist/hooks/useUniformFieldArray/index.d.cts +70 -0
- package/dist/hooks/useUniformFieldArray/index.d.ts +70 -0
- package/dist/hooks/useUniformFieldArray/index.js +15 -0
- package/dist/hooks/useUniformFieldArray/index.js.map +1 -0
- package/dist/index.cjs +30 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +39 -26
- package/package.json +33 -3
- package/dist/chunk-3UIFEC4R.cjs.map +0 -1
- package/dist/chunk-47MZU3WD.js.map +0 -1
- package/dist/chunk-4XTUP7W7.cjs.map +0 -1
- package/dist/chunk-CSTA3NED.cjs.map +0 -1
- /package/dist/{chunk-RBQP2VHW.js.map → chunk-6C6YW5TM.js.map} +0 -0
- /package/dist/{chunk-DFDZFIQN.js.map → chunk-BXGILW5C.js.map} +0 -0
- /package/dist/{chunk-TCJK6IYV.js.map → chunk-H24QXVUI.js.map} +0 -0
- /package/dist/{chunk-7FTSMHFL.js.map → chunk-HQGTCSHK.js.map} +0 -0
- /package/dist/{chunk-LEEWUHKX.js.map → chunk-JKWNYLNS.js.map} +0 -0
- /package/dist/{chunk-QIIMEQS3.js.map → chunk-MXUKW3PZ.js.map} +0 -0
- /package/dist/{chunk-UB44OT6Q.js.map → chunk-QRCV7JVB.js.map} +0 -0
- /package/dist/{chunk-33X26MSK.js.map → chunk-TKFODQWI.js.map} +0 -0
- /package/dist/{chunk-LKBR2JGT.js.map → chunk-Z7NI5347.js.map} +0 -0
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
|
|
4
|
+
|
|
3
5
|
|
|
6
|
+
var _chunkJMFDNTVCcjs = require('./chunk-JMFDNTVC.cjs');
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
|
|
9
|
+
var _chunkPCTYJUY7cjs = require('./chunk-PCTYJUY7.cjs');
|
|
6
10
|
|
|
7
11
|
|
|
8
12
|
var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
|
|
9
13
|
|
|
10
14
|
|
|
11
|
-
var
|
|
15
|
+
var _chunkNZBO4N3Scjs = require('./chunk-NZBO4N3S.cjs');
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
|
|
@@ -44,11 +48,11 @@ var Switch = ({
|
|
|
44
48
|
testId: _testId = void 0,
|
|
45
49
|
thumbIcon = void 0
|
|
46
50
|
}) => {
|
|
47
|
-
const { control, debugMode, getFieldState } =
|
|
51
|
+
const { control, debugMode, getFieldState } = _chunkNZBO4N3Scjs.useFormContext.call(void 0, );
|
|
48
52
|
const { error, required, testId, invalid } = getFieldState(name, _testId);
|
|
49
|
-
const { field } =
|
|
53
|
+
const { field } = _chunkJMFDNTVCcjs.useController.call(void 0, { name, control, disabled });
|
|
50
54
|
const { disabled: isDisabled, value, ref, onBlur, onChange } = field;
|
|
51
|
-
const { label, getInputProps, getErrorMessageProps } =
|
|
55
|
+
const { label, getInputProps, getErrorMessageProps } = _chunkPCTYJUY7cjs.useInput.call(void 0, {
|
|
52
56
|
errorMessage: JSON.stringify(error),
|
|
53
57
|
isInvalid: invalid,
|
|
54
58
|
isRequired: required,
|
|
@@ -98,4 +102,4 @@ var Switch_default2 = Switch_default;
|
|
|
98
102
|
|
|
99
103
|
|
|
100
104
|
exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-XJBGXFVX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-XJBGXFVX.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":["Switch_default"],"mappings":"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","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-XJBGXFVX.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInput } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-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-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label: _label = undefined,\n name,\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n thumbIcon = undefined,\n}: SwitchProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { field } = useController<FieldValues>({ name, control, disabled });\n const { disabled: isDisabled, value, ref, onBlur, onChange } = field;\n\n const { label, getInputProps, getErrorMessageProps } = useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n <HeroSwitch\n ref={ref}\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 aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n endContent={endContent}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n required={required}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n value={value}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </HeroSwitch>\n {error ? (\n <div className={classNames.errorMessage}>\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-D3NAUOYG.js";
|
|
4
|
+
import {
|
|
5
|
+
useFormContext
|
|
6
|
+
} from "./chunk-PO5UQAU6.js";
|
|
7
|
+
import {
|
|
8
|
+
flatArrayKey
|
|
9
|
+
} from "./chunk-76KOVUDN.js";
|
|
10
|
+
import {
|
|
11
|
+
__spreadValues
|
|
12
|
+
} from "./chunk-K2V4ULA2.js";
|
|
13
|
+
|
|
14
|
+
// src/hooks/useUniformFieldArray/useUniformFieldArray.ts
|
|
15
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
16
|
+
import { useFieldArray as useRHFFieldArray } from "react-hook-form";
|
|
17
|
+
import { useReducedMotion } from "@fuf-stack/pixel-motion";
|
|
18
|
+
var useUniformFieldArray = ({
|
|
19
|
+
name,
|
|
20
|
+
flat = false,
|
|
21
|
+
elementInitialValue: _elementInitialValue = null,
|
|
22
|
+
lastElementNotRemovable = false,
|
|
23
|
+
disabled,
|
|
24
|
+
testId: explicitTestId,
|
|
25
|
+
label
|
|
26
|
+
}) => {
|
|
27
|
+
const uniformField = useUniformField({
|
|
28
|
+
name,
|
|
29
|
+
disabled,
|
|
30
|
+
testId: explicitTestId,
|
|
31
|
+
label
|
|
32
|
+
});
|
|
33
|
+
const { control } = uniformField;
|
|
34
|
+
const { fields, append, remove, insert, move } = useRHFFieldArray({
|
|
35
|
+
control,
|
|
36
|
+
name
|
|
37
|
+
});
|
|
38
|
+
const { trigger, setValue } = useFormContext();
|
|
39
|
+
const needsInitialize = lastElementNotRemovable && fields.length === 0;
|
|
40
|
+
const hasInitialized = useRef(!needsInitialize);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (needsInitialize) {
|
|
43
|
+
hasInitialized.current = false;
|
|
44
|
+
}
|
|
45
|
+
}, [needsInitialize]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (hasInitialized.current) {
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
trigger(name);
|
|
50
|
+
}, 200);
|
|
51
|
+
}
|
|
52
|
+
}, [fields.length]);
|
|
53
|
+
const [disableAnimation, setDisableAnimation] = useState(true);
|
|
54
|
+
const prefersReducedMotion = useReducedMotion();
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (hasInitialized.current) {
|
|
57
|
+
setDisableAnimation(!!prefersReducedMotion);
|
|
58
|
+
}
|
|
59
|
+
}, [prefersReducedMotion]);
|
|
60
|
+
const elementInitialValue = useMemo(() => {
|
|
61
|
+
return flat ? { [flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
|
|
62
|
+
}, [flat, _elementInitialValue]);
|
|
63
|
+
useEffect(
|
|
64
|
+
() => {
|
|
65
|
+
if (needsInitialize) {
|
|
66
|
+
if (!disableAnimation) {
|
|
67
|
+
setDisableAnimation(true);
|
|
68
|
+
}
|
|
69
|
+
setValue(name, [elementInitialValue], {
|
|
70
|
+
shouldDirty: false,
|
|
71
|
+
shouldTouch: false
|
|
72
|
+
});
|
|
73
|
+
hasInitialized.current = true;
|
|
74
|
+
if (!prefersReducedMotion) {
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
setDisableAnimation(false);
|
|
77
|
+
}, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
// Run when needsInitialize changes (initial mount or reset)
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
[needsInitialize]
|
|
84
|
+
);
|
|
85
|
+
return __spreadValues({
|
|
86
|
+
// Field array methods and state
|
|
87
|
+
fields,
|
|
88
|
+
append,
|
|
89
|
+
remove,
|
|
90
|
+
insert,
|
|
91
|
+
move,
|
|
92
|
+
disableAnimation,
|
|
93
|
+
elementInitialValue
|
|
94
|
+
}, uniformField);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
useUniformFieldArray
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=chunk-Z7FVILDT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,iBAAiB,wBAAwB;AAElD,SAAS,wBAAwB;AAqC1B,IAAM,uBAAuB,CAElC;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,qBAAqB,uBAAuB;AAAA,EAC5C,0BAA0B;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAA+C;AAE7C,QAAM,eAAe,gBAA8B;AAAA,IACjD;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACF,CAAC;AAED,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,IAAI,iBAAiB;AAAA,IAChE;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,EAAE,SAAS,SAAS,IAAI,eAA6B;AAO3D,QAAM,kBAAkB,2BAA2B,OAAO,WAAW;AASrE,QAAM,iBAAiB,OAAO,CAAC,eAAe;AAK9C,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAIpB,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,iBAAW,MAAM;AAEf,gBAAQ,IAA0B;AAAA,MACpC,GAAG,GAAG;AAAA,IACR;AAAA,EAEF,GAAG,CAAC,OAAO,MAAM,CAAC;AAIlB,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,IAAI;AAI7D,QAAM,uBAAuB,iBAAiB;AAC9C,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,0BAAoB,CAAC,CAAC,oBAAoB;AAAA,IAC5C;AAAA,EACF,GAAG,CAAC,oBAAoB,CAAC;AAKzB,QAAM,sBAAsB,QAAQ,MAAM;AACxC,WAAO,OACH,EAAE,CAAC,YAAY,GAAG,sDAAwB,KAAK,IAC9C,sDAAwB,CAAC;AAAA,EAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;AAU/B;AAAA,IACE,MAAM;AACJ,UAAI,iBAAiB;AAInB,YAAI,CAAC,kBAAkB;AACrB,8BAAoB,IAAI;AAAA,QAC1B;AAIA,iBAAS,MAA4B,CAAC,mBAAmB,GAAU;AAAA,UACjE,aAAa;AAAA,UACb,aAAa;AAAA,QACf,CAAC;AAGD,uBAAe,UAAU;AAKzB,YAAI,CAAC,sBAAsB;AACzB,qBAAW,MAAM;AACf,gCAAoB,KAAK;AAAA,UAC3B,GAAG,CAAC;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEG;AAEP;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D3NAUOYG.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
6
|
} from "./chunk-ELYGQTXB.js";
|
|
@@ -178,4 +178,4 @@ export {
|
|
|
178
178
|
Checkboxes_default,
|
|
179
179
|
Checkboxes_default2
|
|
180
180
|
};
|
|
181
|
-
//# sourceMappingURL=chunk-
|
|
181
|
+
//# sourceMappingURL=chunk-Z7NI5347.js.map
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-LTKRK3OS.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
var _chunkBZ5OMN4Ycjs = require('../chunk-BZ5OMN4Y.cjs');
|
|
5
|
+
|
|
4
6
|
|
|
7
|
+
var _chunk4WYC2RBEcjs = require('../chunk-4WYC2RBE.cjs');
|
|
5
8
|
|
|
6
9
|
|
|
10
|
+
var _chunkAACO4OEKcjs = require('../chunk-AACO4OEK.cjs');
|
|
7
11
|
|
|
8
12
|
|
|
9
|
-
var
|
|
10
|
-
require('../chunk-OE5BOGGX.cjs');
|
|
13
|
+
var _chunkTGJJZEHBcjs = require('../chunk-TGJJZEHB.cjs');
|
|
11
14
|
require('../chunk-NHEZXA4H.cjs');
|
|
12
|
-
require('../chunk-Z353BLWI.cjs');
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
var
|
|
17
|
+
var _chunkJMFDNTVCcjs = require('../chunk-JMFDNTVC.cjs');
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _chunkPCTYJUY7cjs = require('../chunk-PCTYJUY7.cjs');
|
|
21
|
+
require('../chunk-OE5BOGGX.cjs');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _chunkTEIXBRF5cjs = require('../chunk-TEIXBRF5.cjs');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var _chunkNZBO4N3Scjs = require('../chunk-NZBO4N3S.cjs');
|
|
30
|
+
require('../chunk-Z353BLWI.cjs');
|
|
19
31
|
require('../chunk-555JRYCS.cjs');
|
|
20
32
|
|
|
21
33
|
|
|
@@ -27,5 +39,6 @@ require('../chunk-555JRYCS.cjs');
|
|
|
27
39
|
|
|
28
40
|
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
|
|
43
|
+
exports.checkFieldIsRequired = _chunkNZBO4N3Scjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkTEIXBRF5cjs.clientValidationSchemaByName; exports.useClientValidation = _chunkTEIXBRF5cjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunkNZBO4N3Scjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkTGJJZEHBcjs.useUniformField; exports.useUniformFieldArray = _chunkAACO4OEKcjs.useUniformFieldArray;
|
|
31
44
|
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA;AACE;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA,0GAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,6pBAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"}
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,243 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import * as _heroui_input from '@heroui/input';
|
|
6
|
-
import { useInput } from '@heroui/input';
|
|
1
|
+
export { clientValidationSchemaByName, useClientValidation } from './useClientValidation/index.cjs';
|
|
2
|
+
export { UseControllerProps, UseControllerReturn, useController } from './useController/index.cjs';
|
|
3
|
+
export { UseUniformFieldArrayProps, useUniformFieldArray } from './useUniformFieldArray/index.cjs';
|
|
4
|
+
export { checkFieldIsRequired, useFormContext } from './useFormContext/index.cjs';
|
|
7
5
|
export { useInput } from '@heroui/input';
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import { ReactNode } from 'react';
|
|
10
|
-
import { D as DebugModeSettings } from '../FormContext-LRho0tno.cjs';
|
|
11
6
|
export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce } from './useInputValueDebounce/index.cjs';
|
|
12
7
|
export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform } from './useInputValueTransform/index.cjs';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* When the client validation schema changes, automatically re-validates all touched
|
|
21
|
-
* fields to ensure they are validated against the new schema.
|
|
22
|
-
*
|
|
23
|
-
* @param data - Data to create validation schema from (or null/undefined to clear validation)
|
|
24
|
-
* @param schemaFactory - Function that creates a validation schema from the data.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* const { data: teamData } = useTeamQuery(teamId);
|
|
29
|
-
*
|
|
30
|
-
* useClientValidation(teamData, (data) =>
|
|
31
|
-
* vt.object({
|
|
32
|
-
* username: vt.string().refine(
|
|
33
|
-
* (value) => !data.existingUsers.includes(value),
|
|
34
|
-
* { message: 'Username already exists' }
|
|
35
|
-
* )
|
|
36
|
-
* })
|
|
37
|
-
* );
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
|
|
41
|
-
|
|
42
|
-
type UseControllerProps<TFieldValues extends object = object> = UseControllerProps$1<TFieldValues>;
|
|
43
|
-
interface UseControllerReturn<TFieldValues extends object = object> {
|
|
44
|
-
field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {
|
|
45
|
-
onChange: (...event: any[]) => void;
|
|
46
|
-
value: string;
|
|
47
|
-
};
|
|
48
|
-
formState: UseFormStateReturn<TFieldValues>;
|
|
49
|
-
fieldState: ControllerFieldState;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* A wrapper around react-hook-form's useController that transparently handles nullish string conversions.
|
|
53
|
-
*
|
|
54
|
-
* Key features:
|
|
55
|
-
* 1. Empty strings ('') in the UI are stored as null in form state
|
|
56
|
-
* 2. Null/undefined values in form state are displayed as empty strings in the UI
|
|
57
|
-
* 3. Handles both direct value changes and React synthetic events
|
|
58
|
-
* 4. Maintains the same API as react-hook-form's useController
|
|
59
|
-
*
|
|
60
|
-
* This enables consistent handling of empty/null values while keeping a clean API
|
|
61
|
-
* for form inputs that expect string values.
|
|
62
|
-
*
|
|
63
|
-
* @see https://react-hook-form.com/docs/usecontroller
|
|
64
|
-
*/
|
|
65
|
-
declare const useController: <TFieldValues extends object = object>(props: UseControllerProps<TFieldValues>) => UseControllerReturn<TFieldValues>;
|
|
66
|
-
|
|
67
|
-
/** Schema check whether a field is required or optional */
|
|
68
|
-
declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) => boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Custom hook that extends react-hook-form's useFormContext to add validation and state management.
|
|
71
|
-
*/
|
|
72
|
-
declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
|
|
73
|
-
formState: react_hook_form.FormState<TFieldValues>;
|
|
74
|
-
getFieldState: (name: Path<TFieldValues>, testId?: string) => {
|
|
75
|
-
error: FieldError[] | undefined;
|
|
76
|
-
invalid: boolean;
|
|
77
|
-
required: boolean;
|
|
78
|
-
testId: string;
|
|
79
|
-
isDirty: boolean;
|
|
80
|
-
isTouched: boolean;
|
|
81
|
-
isValidating: boolean;
|
|
82
|
-
};
|
|
83
|
-
getValues: react_hook_form.UseFormGetValues<TFieldValues>;
|
|
84
|
-
subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
|
|
85
|
-
watch: react_hook_form.UseFormWatch<TFieldValues>;
|
|
86
|
-
debugMode: "debug" | "debug-testids" | "off" | "disabled";
|
|
87
|
-
debugModeSettings?: DebugModeSettings;
|
|
88
|
-
preventSubmit: (prevent: boolean) => void;
|
|
89
|
-
setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
|
|
90
|
-
triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
|
|
91
|
-
validation: {
|
|
92
|
-
instance?: VetoInstance;
|
|
93
|
-
errors?: VetoFormattedError;
|
|
94
|
-
setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
|
|
95
|
-
};
|
|
96
|
-
setError: react_hook_form.UseFormSetError<TFieldValues>;
|
|
97
|
-
clearErrors: react_hook_form.UseFormClearErrors<TFieldValues>;
|
|
98
|
-
setValue: react_hook_form.UseFormSetValue<TFieldValues>;
|
|
99
|
-
trigger: react_hook_form.UseFormTrigger<TFieldValues>;
|
|
100
|
-
resetField: react_hook_form.UseFormResetField<TFieldValues>;
|
|
101
|
-
reset: react_hook_form.UseFormReset<TFieldValues>;
|
|
102
|
-
handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
|
|
103
|
-
unregister: react_hook_form.UseFormUnregister<TFieldValues>;
|
|
104
|
-
control: react_hook_form.Control<TFieldValues, TContext, TTransformedValues>;
|
|
105
|
-
register: react_hook_form.UseFormRegister<TFieldValues>;
|
|
106
|
-
setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
interface UseUniformFieldArrayProps<TFieldValues extends FieldValues = FieldValues> {
|
|
110
|
-
/** Field name for the array */
|
|
111
|
-
name: ArrayPath<TFieldValues>;
|
|
112
|
-
/** Whether this is a flat array (array of primitives) */
|
|
113
|
-
flat?: boolean;
|
|
114
|
-
/** Initial value for new array elements */
|
|
115
|
-
elementInitialValue?: unknown;
|
|
116
|
-
/** Whether the last element cannot be removed (always maintain at least one element) */
|
|
117
|
-
lastElementNotRemovable?: boolean;
|
|
118
|
-
/** Disable the field */
|
|
119
|
-
disabled?: boolean;
|
|
120
|
-
/** Optional explicit test id used to build stable test ids */
|
|
121
|
-
testId?: string;
|
|
122
|
-
/** Optional label content; pass false to suppress label entirely */
|
|
123
|
-
label?: ReactNode | false;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Enhanced useFieldArray hook with initialization and animation logic.
|
|
127
|
-
* Based on React Hook Form's useFieldArray with additional features:
|
|
128
|
-
* - Automatic initialization when lastElementNotRemovable is set
|
|
129
|
-
* - Animation control (disabled during initialization)
|
|
130
|
-
* - Support for flat arrays (arrays of primitives)
|
|
131
|
-
*
|
|
132
|
-
* Note: Automatic validation triggering on length change is disabled to prevent
|
|
133
|
-
* triggering form-wide validation. Array validation still runs on form submission.
|
|
134
|
-
*
|
|
135
|
-
* @see https://react-hook-form.com/docs/usefieldarray
|
|
136
|
-
*/
|
|
137
|
-
declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldValues>({ name, flat, elementInitialValue: _elementInitialValue, lastElementNotRemovable, disabled, testId: explicitTestId, label, }: UseUniformFieldArrayProps<TFieldValues>) => {
|
|
138
|
-
control: react_hook_form.Control<TFieldValues, any, TFieldValues>;
|
|
139
|
-
debugMode: ReturnType<typeof useFormContext<TFieldValues_1>>["debugMode"];
|
|
140
|
-
defaultValue: unknown;
|
|
141
|
-
disabled: boolean | undefined;
|
|
142
|
-
error: react_hook_form.FieldError[] | undefined;
|
|
143
|
-
errorMessage: ReactNode | null;
|
|
144
|
-
field: Omit<react_hook_form.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
|
|
145
|
-
onChange: (... /** Initial value for new array elements */event: any[]) => void;
|
|
146
|
-
value: string;
|
|
147
|
-
};
|
|
148
|
-
getErrorMessageProps: ReturnType<typeof _heroui_input.useInput>["getErrorMessageProps"];
|
|
149
|
-
getHelperWrapperProps: ReturnType<typeof _heroui_input.useInput>["getHelperWrapperProps"];
|
|
150
|
-
getLabelProps: ReturnType<typeof _heroui_input.useInput>["getLabelProps"];
|
|
151
|
-
getValues: react_hook_form.UseFormGetValues<TFieldValues>;
|
|
152
|
-
invalid: boolean;
|
|
153
|
-
label: ReactNode | null;
|
|
154
|
-
onBlur: ReturnType<typeof useController>["field"]["onBlur"];
|
|
155
|
-
onChange: ReturnType<typeof useController>["field"]["onChange"];
|
|
156
|
-
ref: ReturnType<typeof useController>["field"]["ref"];
|
|
157
|
-
required: boolean;
|
|
158
|
-
resetField: react_hook_form.UseFormResetField<TFieldValues>;
|
|
159
|
-
testId: string;
|
|
160
|
-
fields: react_hook_form.FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>, "id">[];
|
|
161
|
-
append: react_hook_form.UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
|
|
162
|
-
remove: react_hook_form.UseFieldArrayRemove;
|
|
163
|
-
insert: react_hook_form.UseFieldArrayInsert<TFieldValues, ArrayPath<TFieldValues>>;
|
|
164
|
-
move: react_hook_form.UseFieldArrayMove;
|
|
165
|
-
disableAnimation: boolean;
|
|
166
|
-
elementInitialValue: {};
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues> {
|
|
170
|
-
/** Form field name */
|
|
171
|
-
name: Path<TFieldValues> & string;
|
|
172
|
-
/** Disable the field */
|
|
173
|
-
disabled?: boolean;
|
|
174
|
-
/** Optional explicit test id used to build stable test ids */
|
|
175
|
-
testId?: string;
|
|
176
|
-
/** Optional label content; pass false to suppress label entirely */
|
|
177
|
-
label?: ReactNode | false;
|
|
178
|
-
}
|
|
179
|
-
interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues> {
|
|
180
|
-
/** react-hook-form control instance for advanced integrations */
|
|
181
|
-
control: ReturnType<typeof useFormContext<TFieldValues>>['control'];
|
|
182
|
-
/** Debug mode from Uniform provider */
|
|
183
|
-
debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];
|
|
184
|
-
/** Current value used to initialize uncontrolled components */
|
|
185
|
-
defaultValue: unknown;
|
|
186
|
-
/** Whether the field is currently disabled (from RHF) */
|
|
187
|
-
disabled: boolean | undefined;
|
|
188
|
-
/** Validation error(s) for the field */
|
|
189
|
-
error: FieldError[] | undefined;
|
|
190
|
-
/** Pre-built errorMessage node to plug into components */
|
|
191
|
-
errorMessage: ReactNode | null;
|
|
192
|
-
/** RHF controller field with nullish conversions applied */
|
|
193
|
-
field: ReturnType<typeof useController<TFieldValues>>['field'];
|
|
194
|
-
/** Helper to spread standardized error message props to underlying components */
|
|
195
|
-
getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];
|
|
196
|
-
/** Helper to spread standardized helper wrapper props (for spacing/animation) */
|
|
197
|
-
getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];
|
|
198
|
-
/** Helper to spread standardized label props to underlying components */
|
|
199
|
-
getLabelProps: ReturnType<typeof useInput>['getLabelProps'];
|
|
200
|
-
/** Access current form values (converted to validation-friendly format) */
|
|
201
|
-
getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];
|
|
202
|
-
/** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */
|
|
203
|
-
invalid: boolean;
|
|
204
|
-
/** Computed label node including optional test id copy button */
|
|
205
|
-
label: ReactNode | null;
|
|
206
|
-
/** onBlur handler from controller */
|
|
207
|
-
onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];
|
|
208
|
-
/** onChange handler from controller (with nullish handling) */
|
|
209
|
-
onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];
|
|
210
|
-
/** Ref to forward to underlying control */
|
|
211
|
-
ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];
|
|
212
|
-
/** Whether the field is required according to validation schema */
|
|
213
|
-
required: boolean;
|
|
214
|
-
/** Reset a specific field in the form */
|
|
215
|
-
resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];
|
|
216
|
-
/** Generated HTML data-testid for the field */
|
|
217
|
-
testId: string;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Combines frequently used form field logic into a single hook.
|
|
221
|
-
*
|
|
222
|
-
* Provides:
|
|
223
|
-
* - Enhanced form context (validation-aware state, `testId`, value transforms)
|
|
224
|
-
* - Controller field with nullish conversion handling
|
|
225
|
-
* - Debounced `invalid` state with smart timing:
|
|
226
|
-
* • `true` (field becomes invalid): applies immediately so errors show right away
|
|
227
|
-
* • `false` (field becomes valid): delayed 200ms to allow smooth exit animations
|
|
228
|
-
* • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion
|
|
229
|
-
* - Smart `invalid` visibility (via `showInvalid`):
|
|
230
|
-
* • Shows errors when field is dirty OR touched OR form has been submitted
|
|
231
|
-
* • Prevents showing errors on pristine/untouched fields for better UX
|
|
232
|
-
* • Works well for all field types (text inputs, checkboxes, radios, arrays)
|
|
233
|
-
* - Prebuilt `errorMessage` React node using `FieldValidationError`
|
|
234
|
-
* - Computed `label` node which appends a `FieldCopyTestIdButton` in
|
|
235
|
-
* `debug-testids` mode
|
|
236
|
-
* - `defaultValue` for uncontrolled defaults and all usual field handlers
|
|
237
|
-
* - Access to form utilities: `control`, `getValues`, `resetField`
|
|
238
|
-
* - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,
|
|
239
|
-
* `getHelperWrapperProps` for consistent wiring to underlying UI components
|
|
240
|
-
*/
|
|
241
|
-
declare function useUniformField<TFieldValues extends FieldValues = FieldValues>(params: UseUniformFieldParams<TFieldValues>): UseUniformFieldReturn<TFieldValues>;
|
|
242
|
-
|
|
243
|
-
export { type UseControllerProps, type UseControllerReturn, type UseUniformFieldArrayProps, type UseUniformFieldParams, type UseUniformFieldReturn, checkFieldIsRequired, useClientValidation, useController, useFormContext, useUniformField, useUniformFieldArray };
|
|
8
|
+
export { UseUniformFieldParams, UseUniformFieldReturn, useUniformField } from './useUniformField/index.cjs';
|
|
9
|
+
import '@fuf-stack/veto/dist/types.d-CNPgNK-V';
|
|
10
|
+
import '@fuf-stack/veto';
|
|
11
|
+
import 'react-hook-form';
|
|
12
|
+
import 'react';
|
|
13
|
+
import '../FormContext-LRho0tno.cjs';
|