@fuf-stack/uniform 1.28.1 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/Checkboxes/index.d.mts +57 -10
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +8 -3
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +129 -1120
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +38 -32
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.mjs +2 -2
- package/dist/FieldCard/index.mjs +1 -1
- package/dist/FieldReset/index.d.mts +415 -0
- package/dist/FieldReset/index.d.mts.map +1 -0
- package/dist/FieldReset/index.mjs +241 -0
- package/dist/FieldReset/index.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.mjs +2 -2
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-BnNJYZOo.d.mts → FormContext-Dvt3MiKq.d.mts} +3 -3
- package/dist/{FormContext-BnNJYZOo.d.mts.map → FormContext-Dvt3MiKq.d.mts.map} +1 -1
- package/dist/Input/index.d.mts +63 -452
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +20 -15
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +163 -894
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +27 -20
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +93 -43
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +8 -5
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +122 -1027
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +22 -18
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +440 -3028
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +79 -45
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +162 -1325
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +41 -28
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +125 -944
- package/dist/Switch/index.d.mts.map +1 -1
- package/dist/Switch/index.mjs +18 -14
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/SwitchBox/index.d.mts +140 -99
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +9 -6
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +63 -452
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +17 -13
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +82 -729
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +22 -18
- package/dist/Time/index.mjs.map +1 -1
- package/dist/hooks/useFormContext/index.d.mts +1 -1
- package/dist/hooks/useUniformField/index.d.mts +1 -1
- package/dist/hooks/useUniformField/index.mjs +5 -1
- package/dist/hooks/useUniformField/index.mjs.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +1 -1
- package/dist/{index-DaiTW5Bl.d.mts → index-DsB0_365.d.mts} +9 -2
- package/dist/index-DsB0_365.d.mts.map +1 -0
- package/dist/{useFormContext-BhPzFXwF.d.mts → useFormContext-BSSUZ0Md.d.mts} +2 -2
- package/dist/{useFormContext-BhPzFXwF.d.mts.map → useFormContext-BSSUZ0Md.d.mts.map} +1 -1
- package/package.json +5 -4
- package/dist/index-DaiTW5Bl.d.mts.map +0 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { toFormFormat, toNullishString, toSubmitFormat } from "../helpers/index.mjs";
|
|
2
|
+
import { n as useFormContext$1 } from "../useFormContext-BEjPBdzb.mjs";
|
|
3
|
+
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { useIsInitialRenderCycle } from "@fuf-stack/pixels";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
8
|
+
import { FaUndoAlt } from "react-icons/fa";
|
|
9
|
+
// src/FieldReset/helpers/fieldResetValues.ts
|
|
10
|
+
const WRAPPER_KEY = "value";
|
|
11
|
+
/**
|
|
12
|
+
* Converts an original value to the format React Hook Form stores, so it can
|
|
13
|
+
* be written to the form. Empty values (null, '', []) become `null`.
|
|
14
|
+
*/
|
|
15
|
+
const toFormFieldValue = (original) => {
|
|
16
|
+
const formValue = toFormFormat({ [WRAPPER_KEY]: original })[WRAPPER_KEY];
|
|
17
|
+
return formValue === void 0 ? null : formValue;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Normalizes a value stored in the form to the format used for submission,
|
|
21
|
+
* which removes empty values and unwraps flat array entries.
|
|
22
|
+
*/
|
|
23
|
+
const normalizeFormValue = (formValue) => {
|
|
24
|
+
return toSubmitFormat({ [WRAPPER_KEY]: formValue })?.[WRAPPER_KEY];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Compares two normalized values. Primitives are compared by their string
|
|
28
|
+
* representation because inputs such as NumberInput store `'8'` for `8`.
|
|
29
|
+
*/
|
|
30
|
+
const isEquivalent = (a, b) => {
|
|
31
|
+
if (a === b) return true;
|
|
32
|
+
if (a === void 0 || a === null || b === void 0 || b === null) return false;
|
|
33
|
+
if (typeof b === "number" && typeof a === "string" && a.trim() !== "") return Number(a) === b;
|
|
34
|
+
if (typeof a !== "object" && typeof b !== "object") return String(a) === String(b);
|
|
35
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
36
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((entry, index) => {
|
|
37
|
+
return isEquivalent(entry, b[index]);
|
|
38
|
+
});
|
|
39
|
+
const recordA = a;
|
|
40
|
+
const recordB = b;
|
|
41
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(recordA), ...Object.keys(recordB)])].every((key) => {
|
|
42
|
+
return isEquivalent(recordA[key], recordB[key]);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether a value stored in the form differs from an original value.
|
|
47
|
+
*
|
|
48
|
+
* Both values are normalized first, so empty values (undefined, null, '', [])
|
|
49
|
+
* are equal and a stored `'8'` equals an original `8`.
|
|
50
|
+
*
|
|
51
|
+
* @param formValue - The raw value stored in React Hook Form
|
|
52
|
+
* @param original - The original value passed to FieldReset
|
|
53
|
+
* @returns true if the field value differs from the original value
|
|
54
|
+
*/
|
|
55
|
+
const isFieldValueChanged = (formValue, original) => {
|
|
56
|
+
return !isEquivalent(normalizeFormValue(formValue), normalizeFormValue(toFormFieldValue(original)));
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Checks whether two original values are equivalent, so a re-rendered parent
|
|
60
|
+
* that creates a new array or object does not count as a new original value.
|
|
61
|
+
*/
|
|
62
|
+
const isOriginalEqual = (a, b) => {
|
|
63
|
+
return !isFieldValueChanged(toFormFieldValue(a), b);
|
|
64
|
+
};
|
|
65
|
+
// src/FieldReset/helpers/createFieldResetTransform.ts
|
|
66
|
+
/** Creates the display/update mapping without changing form state */
|
|
67
|
+
const createFieldResetTransform = ({ resetValue, include, storedValue }) => {
|
|
68
|
+
return {
|
|
69
|
+
toDisplayValue: (current) => {
|
|
70
|
+
return storedValue === toNullishString(null) || storedValue === void 0 ? resetValue : current ?? "";
|
|
71
|
+
},
|
|
72
|
+
toFormValue: (nextValue) => {
|
|
73
|
+
let formValue = nextValue;
|
|
74
|
+
if (typeof resetValue === "number" && typeof nextValue === "string" && nextValue.trim() !== "") {
|
|
75
|
+
const numericValue = Number(nextValue);
|
|
76
|
+
formValue = Number.isNaN(numericValue) ? nextValue : numericValue;
|
|
77
|
+
}
|
|
78
|
+
if (include === "changed" && !isFieldValueChanged(formValue, resetValue)) return null;
|
|
79
|
+
return formValue ?? "";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
// src/FieldReset/subcomponents/FieldResetAction.tsx
|
|
84
|
+
const fieldResetActionVariants = tv({ slots: {
|
|
85
|
+
base: [
|
|
86
|
+
"inline-flex size-6 shrink-0 items-center justify-center",
|
|
87
|
+
"rounded-sm text-warning",
|
|
88
|
+
"enabled:hover:bg-warning/15",
|
|
89
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-focus",
|
|
90
|
+
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
91
|
+
],
|
|
92
|
+
icon: "size-3.5"
|
|
93
|
+
} });
|
|
94
|
+
const FieldResetAction = ({ className: _className = void 0, disabled, isChanged, name, onReset, resetLabel }) => {
|
|
95
|
+
if (!isChanged) return null;
|
|
96
|
+
const variants = fieldResetActionVariants();
|
|
97
|
+
const className = variantsToClassNames(variants, _className, "base");
|
|
98
|
+
return /* @__PURE__ */ jsx("button", {
|
|
99
|
+
"aria-label": `${resetLabel}: ${name}`,
|
|
100
|
+
className: className.base,
|
|
101
|
+
disabled,
|
|
102
|
+
onClick: onReset,
|
|
103
|
+
onMouseDown: (event) => {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
},
|
|
106
|
+
title: resetLabel,
|
|
107
|
+
type: "button",
|
|
108
|
+
children: /* @__PURE__ */ jsx(FaUndoAlt, {
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
className: className.icon
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
// src/FieldReset/FieldReset.tsx
|
|
115
|
+
const fieldResetVariants = tv({ slots: {
|
|
116
|
+
base: "min-w-0",
|
|
117
|
+
announcement: "sr-only"
|
|
118
|
+
} });
|
|
119
|
+
/** Tracks a field against its original value, shows reset, and controls payload inclusion */
|
|
120
|
+
const FieldReset = ({ children, className: _className = void 0, disabled = false, resetLabel = "Reset to original", changedLabel = "Changed", name, resetValue, include = "changed" }) => {
|
|
121
|
+
const { control, formReset, register, resetField, setValue, setFocus, trigger } = useFormContext$1();
|
|
122
|
+
const { getValues } = useFormContext();
|
|
123
|
+
const storedValue = useWatch({
|
|
124
|
+
control,
|
|
125
|
+
name
|
|
126
|
+
});
|
|
127
|
+
const previous = useRef(null);
|
|
128
|
+
const [baseline, setBaseline] = useState(() => {
|
|
129
|
+
return resetValue;
|
|
130
|
+
});
|
|
131
|
+
if (!isOriginalEqual(baseline, resetValue)) setBaseline(() => {
|
|
132
|
+
return resetValue;
|
|
133
|
+
});
|
|
134
|
+
const omittedValue = toNullishString(null);
|
|
135
|
+
const transform = useMemo(() => {
|
|
136
|
+
return createFieldResetTransform({
|
|
137
|
+
resetValue: baseline,
|
|
138
|
+
include,
|
|
139
|
+
storedValue
|
|
140
|
+
});
|
|
141
|
+
}, [
|
|
142
|
+
baseline,
|
|
143
|
+
include,
|
|
144
|
+
storedValue
|
|
145
|
+
]);
|
|
146
|
+
const registerValueConversion = useCallback(() => {
|
|
147
|
+
register(name, { setValueAs: (nextValue) => {
|
|
148
|
+
return include === "changed" && !isFieldValueChanged(nextValue, baseline) ? omittedValue : nextValue;
|
|
149
|
+
} });
|
|
150
|
+
}, [
|
|
151
|
+
baseline,
|
|
152
|
+
include,
|
|
153
|
+
name,
|
|
154
|
+
omittedValue,
|
|
155
|
+
register
|
|
156
|
+
]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
registerValueConversion();
|
|
159
|
+
return () => {
|
|
160
|
+
register(name, { setValueAs: void 0 });
|
|
161
|
+
};
|
|
162
|
+
}, [
|
|
163
|
+
name,
|
|
164
|
+
register,
|
|
165
|
+
registerValueConversion
|
|
166
|
+
]);
|
|
167
|
+
const restoreOriginal = useCallback(() => {
|
|
168
|
+
resetField(name, { defaultValue: include === "always" ? toFormFieldValue(baseline) : omittedValue });
|
|
169
|
+
}, [
|
|
170
|
+
baseline,
|
|
171
|
+
include,
|
|
172
|
+
name,
|
|
173
|
+
omittedValue,
|
|
174
|
+
resetField
|
|
175
|
+
]);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
const prior = previous.current;
|
|
178
|
+
const current = getValues(name);
|
|
179
|
+
const keepEdit = prior?.name === name && current !== omittedValue && current !== void 0 && isFieldValueChanged(current, prior.original) && isFieldValueChanged(current, baseline);
|
|
180
|
+
restoreOriginal();
|
|
181
|
+
if (keepEdit) setValue(name, current, {
|
|
182
|
+
shouldDirty: true,
|
|
183
|
+
shouldValidate: true
|
|
184
|
+
});
|
|
185
|
+
previous.current = {
|
|
186
|
+
name,
|
|
187
|
+
original: baseline
|
|
188
|
+
};
|
|
189
|
+
trigger();
|
|
190
|
+
}, [
|
|
191
|
+
baseline,
|
|
192
|
+
getValues,
|
|
193
|
+
name,
|
|
194
|
+
omittedValue,
|
|
195
|
+
restoreOriginal,
|
|
196
|
+
setValue,
|
|
197
|
+
trigger
|
|
198
|
+
]);
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
return formReset.subscribe(registerValueConversion);
|
|
201
|
+
}, [formReset, registerValueConversion]);
|
|
202
|
+
const reset = useCallback(() => {
|
|
203
|
+
restoreOriginal();
|
|
204
|
+
setFocus(name);
|
|
205
|
+
trigger(name);
|
|
206
|
+
}, [
|
|
207
|
+
name,
|
|
208
|
+
restoreOriginal,
|
|
209
|
+
setFocus,
|
|
210
|
+
trigger
|
|
211
|
+
]);
|
|
212
|
+
const isInitialRender = useIsInitialRenderCycle();
|
|
213
|
+
const value = storedValue === omittedValue || storedValue === void 0 ? toFormFieldValue(baseline) : storedValue;
|
|
214
|
+
const isChanged = !isInitialRender && isFieldValueChanged(value, baseline);
|
|
215
|
+
const resetAction = /* @__PURE__ */ jsx(FieldResetAction, {
|
|
216
|
+
disabled,
|
|
217
|
+
isChanged,
|
|
218
|
+
name,
|
|
219
|
+
onReset: reset,
|
|
220
|
+
resetLabel
|
|
221
|
+
});
|
|
222
|
+
const variants = fieldResetVariants();
|
|
223
|
+
const className = variantsToClassNames(variants, _className, "base");
|
|
224
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
225
|
+
className: className.base,
|
|
226
|
+
"data-changed": isChanged || void 0,
|
|
227
|
+
children: [children({
|
|
228
|
+
transform,
|
|
229
|
+
resetAction
|
|
230
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
231
|
+
"aria-live": "polite",
|
|
232
|
+
className: className.announcement,
|
|
233
|
+
children: isChanged ? changedLabel : ""
|
|
234
|
+
})]
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
// src/FieldReset/index.ts
|
|
238
|
+
var FieldReset_default = FieldReset;
|
|
239
|
+
export { FieldReset_default as default };
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["useFormContext","useRHFContext","useRHFWatch"],"sources":["../../src/FieldReset/helpers/fieldResetValues.ts","../../src/FieldReset/helpers/createFieldResetTransform.ts","../../src/FieldReset/subcomponents/FieldResetAction.tsx","../../src/FieldReset/FieldReset.tsx","../../src/FieldReset/index.ts"],"sourcesContent":["import {\n toFormFormat,\n toSubmitFormat,\n} from '../../helpers/nullishFields/nullishFields';\n\n/** Controls when a FieldReset field is included in the submitted data */\nexport type FieldResetInclude = 'always' | 'changed';\n\n// Wrap a single value so the object-based format helpers can process it.\nconst WRAPPER_KEY = 'value';\n\n/**\n * Converts an original value to the format React Hook Form stores, so it can\n * be written to the form. Empty values (null, '', []) become `null`.\n */\nexport const toFormFieldValue = (original: unknown): unknown => {\n const formValue = toFormFormat({ [WRAPPER_KEY]: original })[WRAPPER_KEY];\n return formValue === undefined ? null : formValue;\n};\n\n/**\n * Normalizes a value stored in the form to the format used for submission,\n * which removes empty values and unwraps flat array entries.\n */\nconst normalizeFormValue = (formValue: unknown): unknown => {\n return toSubmitFormat({ [WRAPPER_KEY]: formValue })?.[WRAPPER_KEY];\n};\n\n/**\n * Compares two normalized values. Primitives are compared by their string\n * representation because inputs such as NumberInput store `'8'` for `8`.\n */\nconst isEquivalent = (a: unknown, b: unknown): boolean => {\n if (a === b) {\n return true;\n }\n if (a === undefined || a === null || b === undefined || b === null) {\n return false;\n }\n // Match numeric input spellings to numeric baselines without treating blanks\n // as zero or converting string-valued baselines.\n if (typeof b === 'number' && typeof a === 'string' && a.trim() !== '') {\n return Number(a) === b;\n }\n if (typeof a !== 'object' && typeof b !== 'object') {\n return String(a) === String(b);\n }\n if (typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((entry, index) => {\n return isEquivalent(entry, b[index]);\n })\n );\n }\n const recordA = a as Record<string, unknown>;\n const recordB = b as Record<string, unknown>;\n const keys = new Set([...Object.keys(recordA), ...Object.keys(recordB)]);\n return [...keys].every((key) => {\n return isEquivalent(recordA[key], recordB[key]);\n });\n};\n\n/**\n * Checks whether a value stored in the form differs from an original value.\n *\n * Both values are normalized first, so empty values (undefined, null, '', [])\n * are equal and a stored `'8'` equals an original `8`.\n *\n * @param formValue - The raw value stored in React Hook Form\n * @param original - The original value passed to FieldReset\n * @returns true if the field value differs from the original value\n */\nexport const isFieldValueChanged = (\n formValue: unknown,\n original: unknown,\n): boolean => {\n return !isEquivalent(\n normalizeFormValue(formValue),\n normalizeFormValue(toFormFieldValue(original)),\n );\n};\n\n/**\n * Checks whether two original values are equivalent, so a re-rendered parent\n * that creates a new array or object does not count as a new original value.\n */\nexport const isOriginalEqual = (a: unknown, b: unknown): boolean => {\n return !isFieldValueChanged(toFormFieldValue(a), b);\n};\n","import type { InputValueTransform } from '../../hooks/useInputValueTransform';\nimport type { FieldResetInclude } from './fieldResetValues';\n\nimport { toNullishString } from '../../helpers';\nimport { isFieldValueChanged } from './fieldResetValues';\n\ninterface FieldResetTransformOptions {\n /** Omits unchanged values in changed mode or retains them in always mode */\n include: FieldResetInclude;\n /** Supplies the display fallback and comparison value; numeric values enable number conversion */\n resetValue: NonNullable<unknown>;\n /** Supplies the raw form value to distinguish omitted updates from explicit clears */\n storedValue: unknown;\n}\n\n/** Creates the display/update mapping without changing form state */\nconst createFieldResetTransform = <TDisplay = string>({\n resetValue,\n include,\n storedValue,\n}: FieldResetTransformOptions): InputValueTransform<TDisplay> => {\n return {\n toDisplayValue: (current) => {\n // The null marker means unchanged; a real null is an explicit clear.\n return (\n storedValue === toNullishString(null) || storedValue === undefined\n ? resetValue\n : (current ?? '')\n ) as TDisplay;\n },\n toFormValue: (nextValue) => {\n // Custom transforms replace Input's built-in number conversion. Normalize\n // before comparing, but preserve invalid text for schema validation.\n let formValue: unknown = nextValue;\n if (\n typeof resetValue === 'number' &&\n typeof nextValue === 'string' &&\n nextValue.trim() !== ''\n ) {\n const numericValue = Number(nextValue);\n formValue = Number.isNaN(numericValue) ? nextValue : numericValue;\n }\n if (\n include === 'changed' &&\n !isFieldValueChanged(formValue, resetValue)\n ) {\n return null;\n }\n // Keep clears distinct from the omitted-update marker.\n return formValue ?? '';\n },\n };\n};\n\nexport default createFieldResetTransform;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { FaUndoAlt } from 'react-icons/fa';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nconst fieldResetActionVariants = tv({\n slots: {\n base: [\n // Layout and clickable area\n 'inline-flex size-6 shrink-0 items-center justify-center',\n // Shape and warning color\n 'rounded-sm text-warning',\n // Show the clickable area on hover without dimming the icon\n 'enabled:hover:bg-warning/15',\n // Keyboard focus indicator\n 'outline-none focus-visible:ring-2 focus-visible:ring-focus',\n // Disabled state\n 'disabled:cursor-not-allowed disabled:opacity-50',\n ],\n // Icon size within the clickable area\n icon: 'size-3.5',\n },\n});\n\ntype ClassName = TVClassName<typeof fieldResetActionVariants>;\n\ninterface FieldResetActionProps {\n /** Applies CSS classes to the reset button and icon slots */\n className?: ClassName;\n /** Disables the reset button */\n disabled: boolean;\n /** Shows the reset button when the field has changed */\n isChanged: boolean;\n /** Identifies the field in the button's accessible label */\n name: string;\n /** Callback invoked when the reset button is pressed */\n onReset: () => void;\n /** Labels the reset button and its tooltip */\n resetLabel: string;\n}\n\nconst FieldResetAction = ({\n className: _className = undefined,\n disabled,\n isChanged,\n name,\n onReset,\n resetLabel,\n}: FieldResetActionProps) => {\n if (!isChanged) {\n return null;\n }\n\n // className from slots\n const variants = fieldResetActionVariants();\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <button\n aria-label={`${resetLabel}: ${name}`}\n className={className.base}\n disabled={disabled}\n onClick={onReset}\n onMouseDown={(event) => {\n event.preventDefault();\n }}\n title={resetLabel}\n type=\"button\"\n >\n <FaUndoAlt aria-hidden=\"true\" className={className.icon} />\n </button>\n );\n};\n\nexport default FieldResetAction;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { FieldResetInclude } from './helpers/fieldResetValues';\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n useFormContext as useRHFContext,\n useWatch as useRHFWatch,\n} from 'react-hook-form';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport { useIsInitialRenderCycle } from '@fuf-stack/pixels';\n\nimport { toNullishString } from '../helpers';\nimport { useFormContext } from '../hooks/useFormContext';\nimport createFieldResetTransform from './helpers/createFieldResetTransform';\nimport {\n isFieldValueChanged,\n isOriginalEqual,\n toFormFieldValue,\n} from './helpers/fieldResetValues';\nimport FieldResetAction from './subcomponents/FieldResetAction';\n\nconst fieldResetVariants = tv({\n slots: {\n // Allow the field wrapper to shrink within flex and grid layouts\n base: 'min-w-0',\n // Announce changes without displaying additional text\n announcement: 'sr-only',\n },\n});\n\ntype ClassName = TVClassName<typeof fieldResetVariants>;\n\nexport interface FieldResetRenderProps<TDisplay = string> {\n /** Supplies the reset action for endContent or another field slot */\n resetAction: ReactNode;\n /** Converts between displayed values and submitted updates */\n transform: InputValueTransform<TDisplay>;\n}\n\nexport interface FieldResetProps<TDisplay = string> {\n /** Announces the changed state to assistive technology; defaults to Changed */\n changedLabel?: string;\n /** Callback invoked to render the field with its transform and reset action */\n children: (props: FieldResetRenderProps<TDisplay>) => ReactNode;\n /** Applies CSS classes to the field wrapper and announcement slots */\n className?: ClassName;\n /** Disables the reset action without changing the child field's disabled state */\n disabled?: boolean;\n /** Includes only changed values by default, or always includes the field */\n include?: FieldResetInclude;\n /** Identifies the field to initialize, compare, and reset */\n name: string;\n /** Labels the reset icon button and its tooltip; defaults to Reset to original */\n resetLabel?: string;\n /** Supplies the non-null reset destination and comparison value for changed-only inclusion */\n resetValue: NonNullable<unknown>;\n}\n\n/** Tracks a field against its original value, shows reset, and controls payload inclusion */\nconst FieldReset = <TDisplay = string,>({\n children,\n className: _className = undefined,\n disabled = false,\n resetLabel = 'Reset to original',\n changedLabel = 'Changed',\n name,\n resetValue,\n include = 'changed',\n}: FieldResetProps<TDisplay>) => {\n const {\n control,\n formReset,\n register,\n resetField,\n setValue,\n setFocus,\n trigger,\n } = useFormContext();\n\n // Read raw values to distinguish the omitted marker from explicit clears and\n // preserve stored array wrappers; Uniform's getValues normalizes these away.\n const { getValues } = useRHFContext();\n const storedValue = useRHFWatch({ control, name });\n const previous = useRef<{ name: string; original: typeof resetValue } | null>(\n null,\n );\n\n // Keep equivalent object props stable without requiring callers to memoize them.\n const [baseline, setBaseline] = useState(() => {\n return resetValue;\n });\n if (!isOriginalEqual(baseline, resetValue)) {\n setBaseline(() => {\n return resetValue;\n });\n }\n\n // Use Uniform's existing null marker for an unchanged update. A real null\n // remains a clear (e.g. Input's clear button), rather than showing the original.\n const omittedValue = toNullishString(null);\n const transform = useMemo(() => {\n return createFieldResetTransform<TDisplay>({\n resetValue: baseline,\n include,\n storedValue,\n });\n }, [baseline, include, storedValue]);\n\n // Apply omission to imperative setValue calls before validation or submission,\n // including calls that submit immediately without waiting for a render.\n const registerValueConversion = useCallback(() => {\n register(name, {\n setValueAs: (nextValue: unknown) => {\n return include === 'changed' &&\n !isFieldValueChanged(nextValue, baseline)\n ? omittedValue\n : nextValue;\n },\n });\n }, [baseline, include, name, omittedValue, register]);\n\n // Install the field-local conversion and release it when this wrapper changes\n // or unmounts, leaving ordinary controllers free of the omission policy.\n useEffect(() => {\n registerValueConversion();\n return () => {\n // Remove the conversion even when the current value is undefined.\n // The controller remains responsible for its own unregistration.\n register(name, { setValueAs: undefined });\n };\n }, [name, register, registerValueConversion]);\n\n // Reset the field and its default to the baseline in always mode, or to the\n // omitted marker in changed mode so the transform displays the baseline.\n const restoreOriginal = useCallback(() => {\n resetField(name, {\n defaultValue:\n include === 'always' ? toFormFieldValue(baseline) : omittedValue,\n });\n }, [baseline, include, name, omittedValue, resetField]);\n\n // Initialize the field and synchronize changes to its reset value or inclusion\n // mode. Preserve edits unless they match the new baseline, then revalidate.\n useEffect(() => {\n const prior = previous.current;\n const current = getValues(name);\n const keepEdit =\n prior?.name === name &&\n current !== omittedValue &&\n current !== undefined &&\n isFieldValueChanged(current, prior.original) &&\n isFieldValueChanged(current, baseline);\n restoreOriginal();\n if (keepEdit) {\n setValue(name, current, { shouldDirty: true, shouldValidate: true });\n }\n previous.current = { name, original: baseline };\n trigger();\n }, [\n baseline,\n getValues,\n name,\n omittedValue,\n restoreOriginal,\n setValue,\n trigger,\n ]);\n\n // RHF clears registration on a form reset. Reinstall conversion while letting\n // the supplied reset values and defaults remain owned by the form.\n useEffect(() => {\n return formReset.subscribe(registerValueConversion);\n }, [formReset, registerValueConversion]);\n\n // Handle the reset action: restore the baseline, return focus to the field,\n // and refresh its validation result.\n const reset = useCallback(() => {\n restoreOriginal();\n setFocus(name);\n trigger(name);\n }, [name, restoreOriginal, setFocus, trigger]);\n\n // The original is installed after mount. Do not briefly render a reset action\n // for the pre-initialized RHF value.\n const isInitialRender = useIsInitialRenderCycle();\n const value =\n storedValue === omittedValue || storedValue === undefined\n ? toFormFieldValue(baseline)\n : storedValue;\n const isChanged = !isInitialRender && isFieldValueChanged(value, baseline);\n const resetAction = (\n <FieldResetAction\n disabled={disabled}\n isChanged={isChanged}\n name={name}\n onReset={reset}\n resetLabel={resetLabel}\n />\n );\n\n // className from slots\n const variants = fieldResetVariants();\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base} data-changed={isChanged || undefined}>\n {children({ transform, resetAction })}\n <span aria-live=\"polite\" className={className.announcement}>\n {isChanged ? changedLabel : ''}\n </span>\n </div>\n );\n};\n\nexport default FieldReset;\n","import FieldReset from './FieldReset';\n\nexport type { FieldResetProps, FieldResetRenderProps } from './FieldReset';\nexport type { FieldResetInclude } from './helpers/fieldResetValues';\n\nexport default FieldReset;\n"],"mappings":";;;;;;;;;AASA,MAAM,cAAc;;;;;AAMpB,MAAa,oBAAoB,aAA+B;CAC9D,MAAM,YAAY,aAAa,GAAG,cAAc,SAAS,CAAC,CAAC,CAAC;CAC5D,OAAO,cAAc,KAAA,IAAY,OAAO;AAC1C;;;;;AAMA,MAAM,sBAAsB,cAAgC;CAC1D,OAAO,eAAe,GAAG,cAAc,UAAU,CAAC,CAAC,GAAG;AACxD;;;;;AAMA,MAAM,gBAAgB,GAAY,MAAwB;CACxD,IAAI,MAAM,GACR,OAAO;CAET,IAAI,MAAM,KAAA,KAAa,MAAM,QAAQ,MAAM,KAAA,KAAa,MAAM,MAC5D,OAAO;CAIT,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,IACjE,OAAO,OAAO,CAAC,MAAM;CAEvB,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UACxC,OAAO,OAAO,CAAC,MAAM,OAAO,CAAC;CAE/B,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UACxC,OAAO;CAET,IAAI,MAAM,QAAQ,CAAC,KAAK,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AK,WAAW,UAAU;EAAM,gBAAc,aAAa,KAAA;EAA3D,UAAA,CACG,SAAS;GAAE;GAAW;EAAY,CAAC,GACpC,oBAAC,QAAD;GAAM,aAAU;GAAS,WAAW,UAAU;GAC3C,UAAA,YAAY,eAAe;EACxB,CAAA,CACH;;AAET;;AClNA,IAAA,qBAAe"}
|
package/dist/Form/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DebugModeSettings } from "../FormContext-
|
|
1
|
+
import { t as DebugModeSettings } from "../FormContext-Dvt3MiKq.mjs";
|
|
2
2
|
import { TVClassName, TVProps } from "@fuf-stack/pixel-utils";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import { FieldValues, SubmitHandler } from "react-hook-form";
|
|
@@ -991,7 +991,7 @@ export declare const formVariants: ((props?: ({
|
|
|
991
991
|
class?: never;
|
|
992
992
|
className?: string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | /*elided*/ any | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined;
|
|
993
993
|
}))))[];
|
|
994
|
-
variantKeys: (string | number)[]
|
|
994
|
+
variantKeys: never[] | (string | number)[];
|
|
995
995
|
};
|
|
996
996
|
type VariantProps = TVProps<typeof formVariants>;
|
|
997
997
|
type ClassName = TVClassName<typeof formVariants>;
|
package/dist/Form/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as useSensitiveDebug, r as redactDebugData, t as FormProvider } from "../FormContext-B8G_Xxd6.mjs";
|
|
2
2
|
import { n as useFormContext } from "../useFormContext-BEjPBdzb.mjs";
|
|
3
3
|
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
|
-
import {
|
|
4
|
+
import { useLayoutEffect, useState } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { FaBug, FaBullseye } from "react-icons/fa6";
|
|
7
7
|
import { FaTimes } from "react-icons/fa";
|
|
@@ -37,7 +37,7 @@ const FormDebugViewer = ({ className = void 0 }) => {
|
|
|
37
37
|
const [values, setValues] = useState(() => {
|
|
38
38
|
return getValues() ?? {};
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
41
|
if (!showDebugCard) return;
|
|
42
42
|
const subscription = subscribe({
|
|
43
43
|
formState: { values: true },
|
package/dist/Form/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/Form/subcomponents/FormDebugViewer.tsx","../../src/Form/Form.tsx","../../src/Form/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { CardProps } from '@fuf-stack/pixels/Card';\n\nimport { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { tv, variantsToClassNames } 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/useFormContext';\nimport { redactDebugData, useSensitiveDebug } from './SensitiveFields';\n\n// form debug viewer styling variants\nexport const formDebugViewerVariants = tv({\n slots: {\n /** class of the debug card */\n base: '',\n /** class of the button that toggles the field copy testid buttons */\n copyButtonToggle: 'mb-4 ml-auto mr-auto',\n /** class of the debug card header */\n header: 'justify-between',\n /** class of the json viewer */\n json: '',\n /** class of the button that enables debug mode */\n triggerButton: 'fixed bottom-2.5 right-2.5 w-5 text-default-400',\n },\n});\n\ntype VariantProps = TVProps<typeof formDebugViewerVariants>;\ntype ClassName = TVClassName<typeof formDebugViewerVariants>;\n\nexport interface FormDebugViewerProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\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, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const { paths: sensitivePaths, ready: sensitiveFieldsReady } =\n useSensitiveDebug();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = formDebugViewerVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const cardClassNames: CardProps['className'] = {\n base: classNames.base,\n header: classNames.header,\n };\n\n // We intentionally keep the local state + subscription approach here.\n // A previous useSyncExternalStore refactor caused unstable runtime behavior\n // in consuming wizard apps (max update depth loops inside react-json-view).\n // Keeping this explicit state bridge is the currently stable baseline.\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>(() => {\n return getValues() ?? {};\n });\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n // handle show debug mode\n const handleShowDebugMode = () => {\n // Seed current values on open from an event handler (not effect body)\n // to avoid cascading-render lint warnings for sync setState in effects.\n setValues(getValues() ?? {});\n // set debug mode to debug\n setDebugMode('debug');\n };\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className={classNames.triggerButton}\n icon={<FaBug />}\n onClick={handleShowDebugMode}\n variant=\"light\"\n />\n );\n }\n\n // do not show card\n if (!showDebugCard || !sensitiveFieldsReady) {\n return null;\n }\n\n return (\n <Card\n className={cardClassNames}\n header={\n <>\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n onClick={() => {\n setDebugMode('off');\n }}\n size=\"sm\"\n variant=\"light\"\n />\n </>\n }\n >\n <Button\n className={classNames.copyButtonToggle}\n icon={<FaBullseye />}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n variant={showDebugTestIds ? 'solid' : 'light'}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n className={classNames.json}\n value={{\n values: redactDebugData(values, sensitivePaths),\n errors: redactDebugData(errors ?? null, sensitivePaths),\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport 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';\nimport type { FormDebugViewerProps } from './subcomponents/FormDebugViewer';\n\nimport { slugify, tv, variantsToClassNames } 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\n// form styling variants\nexport const formVariants = tv({\n slots: {\n /** class of the wrapper around form and debug viewer */\n base: 'flex w-full flex-row justify-between gap-6',\n /** class of the debug viewer card */\n debugViewer: 'w-96 shrink',\n /** class of the debug viewer button that toggles the field copy testid buttons */\n debugViewerCopyButtonToggle: '',\n /** class of the debug viewer card header */\n debugViewerHeader: '',\n /** class of the debug viewer json viewer */\n debugViewerJson: '',\n /** class of the debug viewer trigger button */\n debugViewerTriggerButton: '',\n /** class of the HTML form element */\n form: 'grow',\n },\n});\n\ntype VariantProps = TVProps<typeof formVariants>;\ntype ClassName = TVClassName<typeof formVariants>;\n\nexport interface FormProps extends VariantProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: ClassName;\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 /** id set as the form's HTML `id`, so a SubmitButton rendered OUTSIDE this\n * form (e.g. a modal footer) can be associated with it via its own\n * `remoteFormId` prop (native HTML `form` attribute) */\n remoteFormId?: string;\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 remoteFormId = undefined,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n // classNames from slots\n const variants = formVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const debugViewerClassNames: FormDebugViewerProps['className'] = {\n base: classNames.debugViewer,\n copyButtonToggle: classNames.debugViewerCopyButtonToggle,\n header: classNames.debugViewerHeader,\n json: classNames.debugViewerJson,\n triggerButton: classNames.debugViewerTriggerButton,\n };\n\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={classNames.base}>\n <form\n className={classNames.form}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n id={remoteFormId}\n name={name}\n // disable native HTML constraint validation so an invalid submit\n // (e.g. pressing Enter with empty required fields) still fires the\n // submit event and lets react-hook-form/veto validate and show\n // field errors, instead of the browser blocking the submit.\n noValidate\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={debugViewerClassNames} />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { formVariants } from './Form';\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,0BAA0B,GAAG,EACxC,OAAO;;CAEL,MAAM;;CAEN,kBAAkB;;CAElB,QAAQ;;CAER,MAAM;;CAEN,eAAe;AACjB,EACF,CAAC;;AAWD,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACE,eAAe;CAEnB,MAAM,EAAE,OAAO,gBAAgB,OAAO,yBACpC,kBAAkB;CAEpB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAGvC,MAAM,WAAW,wBAAwB;CACzC,MAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;CACnE,MAAM,iBAAyC;EAC7C,MAAM,WAAW;EACjB,QAAQ,WAAW;CACrB;CAQA,MAAM,CAAC,QAAQ,aAAa,eAAwC;EAClE,OAAO,UAAU,KAAK,CAAC;CACzB,CAAC;CAED,gBAAgB;EAEd,IAAI,CAAC,eACH;EAGF,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa;GACX,aAAa;EACf;CAEF,GAAG,CAAC,aAA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,GAChB,OAAO,KAAA,GACP,UACA,eAAe,KAAA,GACf,SAAS,KAAA,GACT,aAAa,KAAA,GACb,oBAAoB,YACL;CAEf,MAAM,WAAW,aAAa;CAC9B,MAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;CACnE,MAAM,wBAA2D;EAC/D,MAAM,WAAW;EACjB,kBAAkB,WAAW;EAC7B,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,eAAe,WAAW;CAC5B;CAEA,OACE,oBAAC,cAAD;EACE,mBAAmB;EACJ;EACL;EACE;EACO;EAEjB,WAAA,EAAE,cAAc,cAAc;GAC9B,OACE,qBAAC,OAAD;IAAK,WAAW,WAAW;IAA3B,UAAA,CACE,oBAAC,QAAD;KACE,WAAW,WAAW;KACtB,sBAAoB;KACpB,eAAa,QAAQ,UAAU,QAAQ,EAAE;KACzC,IAAI;KACE;KAKN,YAAA;KACA,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,oBAAC,iBAAD,EAAiB,WAAW,sBAAwB,CAAA,CAEnD;;EAET;CACY,CAAA;AAElB;;ACrHA,IAAA,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/Form/subcomponents/FormDebugViewer.tsx","../../src/Form/Form.tsx","../../src/Form/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { CardProps } from '@fuf-stack/pixels/Card';\n\nimport { useLayoutEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { tv, variantsToClassNames } 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/useFormContext';\nimport { redactDebugData, useSensitiveDebug } from './SensitiveFields';\n\n// form debug viewer styling variants\nexport const formDebugViewerVariants = tv({\n slots: {\n /** class of the debug card */\n base: '',\n /** class of the button that toggles the field copy testid buttons */\n copyButtonToggle: 'mb-4 ml-auto mr-auto',\n /** class of the debug card header */\n header: 'justify-between',\n /** class of the json viewer */\n json: '',\n /** class of the button that enables debug mode */\n triggerButton: 'fixed bottom-2.5 right-2.5 w-5 text-default-400',\n },\n});\n\ntype VariantProps = TVProps<typeof formDebugViewerVariants>;\ntype ClassName = TVClassName<typeof formDebugViewerVariants>;\n\nexport interface FormDebugViewerProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\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, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const { paths: sensitivePaths, ready: sensitiveFieldsReady } =\n useSensitiveDebug();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = formDebugViewerVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const cardClassNames: CardProps['className'] = {\n base: classNames.base,\n header: classNames.header,\n };\n\n // We intentionally keep the local state + subscription approach here.\n // A previous useSyncExternalStore refactor caused unstable runtime behavior\n // in consuming wizard apps (max update depth loops inside react-json-view).\n // Keeping this explicit state bridge is the currently stable baseline.\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>(() => {\n return getValues() ?? {};\n });\n\n // Subscribe before sibling fields initialize values in passive effects.\n useLayoutEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n // handle show debug mode\n const handleShowDebugMode = () => {\n // Seed current values on open from an event handler (not effect body)\n // to avoid cascading-render lint warnings for sync setState in effects.\n setValues(getValues() ?? {});\n // set debug mode to debug\n setDebugMode('debug');\n };\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className={classNames.triggerButton}\n icon={<FaBug />}\n onClick={handleShowDebugMode}\n variant=\"light\"\n />\n );\n }\n\n // do not show card\n if (!showDebugCard || !sensitiveFieldsReady) {\n return null;\n }\n\n return (\n <Card\n className={cardClassNames}\n header={\n <>\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n onClick={() => {\n setDebugMode('off');\n }}\n size=\"sm\"\n variant=\"light\"\n />\n </>\n }\n >\n <Button\n className={classNames.copyButtonToggle}\n icon={<FaBullseye />}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n variant={showDebugTestIds ? 'solid' : 'light'}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n className={classNames.json}\n value={{\n values: redactDebugData(values, sensitivePaths),\n errors: redactDebugData(errors ?? null, sensitivePaths),\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport 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';\nimport type { FormDebugViewerProps } from './subcomponents/FormDebugViewer';\n\nimport { slugify, tv, variantsToClassNames } 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\n// form styling variants\nexport const formVariants = tv({\n slots: {\n /** class of the wrapper around form and debug viewer */\n base: 'flex w-full flex-row justify-between gap-6',\n /** class of the debug viewer card */\n debugViewer: 'w-96 shrink',\n /** class of the debug viewer button that toggles the field copy testid buttons */\n debugViewerCopyButtonToggle: '',\n /** class of the debug viewer card header */\n debugViewerHeader: '',\n /** class of the debug viewer json viewer */\n debugViewerJson: '',\n /** class of the debug viewer trigger button */\n debugViewerTriggerButton: '',\n /** class of the HTML form element */\n form: 'grow',\n },\n});\n\ntype VariantProps = TVProps<typeof formVariants>;\ntype ClassName = TVClassName<typeof formVariants>;\n\nexport interface FormProps extends VariantProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: ClassName;\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 /** id set as the form's HTML `id`, so a SubmitButton rendered OUTSIDE this\n * form (e.g. a modal footer) can be associated with it via its own\n * `remoteFormId` prop (native HTML `form` attribute) */\n remoteFormId?: string;\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 remoteFormId = undefined,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n // classNames from slots\n const variants = formVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const debugViewerClassNames: FormDebugViewerProps['className'] = {\n base: classNames.debugViewer,\n copyButtonToggle: classNames.debugViewerCopyButtonToggle,\n header: classNames.debugViewerHeader,\n json: classNames.debugViewerJson,\n triggerButton: classNames.debugViewerTriggerButton,\n };\n\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={classNames.base}>\n <form\n className={classNames.form}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n id={remoteFormId}\n name={name}\n // disable native HTML constraint validation so an invalid submit\n // (e.g. pressing Enter with empty required fields) still fires the\n // submit event and lets react-hook-form/veto validate and show\n // field errors, instead of the browser blocking the submit.\n noValidate\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={debugViewerClassNames} />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { formVariants } from './Form';\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,0BAA0B,GAAG,EACxC,OAAO;;CAEL,MAAM;;CAEN,kBAAkB;;CAElB,QAAQ;;CAER,MAAM;;CAEN,eAAe;AACjB,EACF,CAAC;;AAWD,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACE,eAAe;CAEnB,MAAM,EAAE,OAAO,gBAAgB,OAAO,yBACpC,kBAAkB;CAEpB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAGvC,MAAM,WAAW,wBAAwB;CACzC,MAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;CACnE,MAAM,iBAAyC;EAC7C,MAAM,WAAW;EACjB,QAAQ,WAAW;CACrB;CAQA,MAAM,CAAC,QAAQ,aAAa,eAAwC;EAClE,OAAO,UAAU,KAAK,CAAC;CACzB,CAAC;CAGD,sBAAsB;EAEpB,IAAI,CAAC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Aa;;CAEb,6BAA6B;;CAE7B,mBAAmB;;CAEnB,iBAAiB;;CAEjB,0BAA0B;;CAE1B,MAAM;AACR,EACF,CAAC;;;;AAiCD,MAAM,QAAQ,EACZ,UACA,YAAY,KAAA,GACZ,QAAQ,KAAA,GACR,gBAAgB,KAAA,GAChB,OAAO,KAAA,GACP,UACA,eAAe,KAAA,GACf,SAAS,KAAA,GACT,aAAa,KAAA,GACb,oBAAoB,YACL;CAEf,MAAM,WAAW,aAAa;CAC9B,MAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;CACnE,MAAM,wBAA2D;EAC/D,MAAM,WAAW;EACjB,kBAAkB,WAAW;EAC7B,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,eAAe,WAAW;CAC5B;CAEA,OACE,oBAAC,cAAD;EACE,mBAAmB;EACJ;EACL;EACE;EACO;EAEjB,WAAA,EAAE,cAAc,cAAc;GAC9B,OACE,qBAAC,OAAD;IAAK,WAAW,WAAW;IAA3B,UAAA,CACE,oBAAC,QAAD;KACE,WAAW,WAAW;KACtB,sBAAoB;KACpB,eAAa,QAAQ,UAAU,QAAQ,EAAE;KACzC,IAAI;KACE;KAKN,YAAA;KACA,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,oBAAC,iBAAD,EAAiB,WAAW,sBAAwB,CAAA,CAEnD;;EAET;CACY,CAAA;AAElB;;ACrHA,IAAA,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { BaseSyntheticEvent
|
|
2
|
-
import {
|
|
1
|
+
import React, { BaseSyntheticEvent } from "react";
|
|
2
|
+
import { Path } from "react-hook-form";
|
|
3
3
|
import { VetoFormattedError, VetoInstance, VetoTypeAny } from "@fuf-stack/veto";
|
|
4
4
|
type DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';
|
|
5
5
|
interface DebugModeSettings {
|
|
@@ -121,4 +121,4 @@ interface UniformContextType {
|
|
|
121
121
|
}
|
|
122
122
|
declare const UniformContext: React.Context<UniformContextType>;
|
|
123
123
|
export { UniformContext as n, DebugModeSettings as t };
|
|
124
|
-
//# sourceMappingURL=FormContext-
|
|
124
|
+
//# sourceMappingURL=FormContext-Dvt3MiKq.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormContext-
|
|
1
|
+
{"version":3,"file":"FormContext-Dvt3MiKq.d.mts","names":[],"sources":["../src/Form/subcomponents/FormContext.tsx"],"mappings":";;;KA8BK;UAEY;;EAEf;;EAEA;;;KAIU;;;;KAKA,mBAAmB,yCAC7B,WAAW,KAAK,eAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+DQ;;EAER,WAAW;;EAEX,oBAAoB;;EAEpB;;;;;IAKE,YAAY,UAAU;;;;;IAKtB;;;EAGF,gBAAgB;;EAEhB,eAAe,WAAW;;EAE1B,gBAAgB,IAAI,uBAAuB;;EAE3C;;;;;IAKE,YAAY,UAAU;;;;;IAKtB,SAAS,mBAAmB;;;EAG9B;;IAEE,eAAe;;IAEf,WAAW;;IAEX,SAAS;;IAET,4BACE,aACA,QAAQ;;;cAyDD,gBACa,MAAM,QAAQ"}
|