@fuf-stack/uniform 1.30.0 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/dist/Checkboxes/index.d.mts +178 -274
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +294 -94
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +1963 -148
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +401 -82
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +102 -97
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +340 -195
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +34 -34
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +181 -127
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-Y9SfvaM9.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +4 -2
- package/dist/FieldCopyTestIdButton-D3_jZYJ1.mjs.map +1 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs +35 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
- package/dist/FieldLabel-DrNWJIVh.mjs +128 -0
- package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
- package/dist/FieldLayout-DcvQU0zN.mjs +45 -0
- package/dist/FieldLayout-DcvQU0zN.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +17 -12
- package/dist/FieldReset/index.d.mts.map +1 -1
- package/dist/FieldReset/index.mjs +50 -33
- package/dist/FieldReset/index.mjs.map +1 -1
- package/dist/FieldValidationError-iAayfTEw.mjs +75 -0
- package/dist/FieldValidationError-iAayfTEw.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +9 -7
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-Dvt3MiKq.d.mts → FormContext-BnNJYZOo.d.mts} +3 -3
- package/dist/{FormContext-Dvt3MiKq.d.mts.map → FormContext-BnNJYZOo.d.mts.map} +1 -1
- package/dist/{FormContext-B8G_Xxd6.mjs → FormContext-PXkVlBdU.mjs} +6 -2
- package/dist/FormContext-PXkVlBdU.mjs.map +1 -0
- package/dist/Grid/index.mjs +1 -1
- package/dist/{Grid-Us2JFczS.mjs → Grid-DBL29Kwb.mjs} +4 -2
- package/dist/Grid-DBL29Kwb.mjs.map +1 -0
- package/dist/Input/index.d.mts +734 -47
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +411 -168
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +300 -98
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +156 -119
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +302 -76
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +274 -87
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +314 -78
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +90 -44
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +410 -142
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +284 -157
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +382 -63
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +269 -90
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +4 -1
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +2 -427
- package/dist/Switch/index.mjs +167 -72
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-Db2dpGz7.d.mts +648 -0
- package/dist/Switch-Db2dpGz7.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +191 -91
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +142 -88
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +347 -29
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +195 -47
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +1373 -139
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +160 -77
- package/dist/Time/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.d.mts +29 -2
- package/dist/hooks/useController/index.d.mts.map +1 -0
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +44 -2
- package/dist/hooks/useFormContext/index.d.mts.map +1 -0
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.mts +9 -3
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +27 -5
- package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -2
- package/dist/hooks/useInputValueTransform/index.mjs +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{useInputValueTransform-cevZBrIN.d.mts → index-cevZBrIN.d.mts} +1 -1
- package/dist/index-cevZBrIN.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
- package/dist/partials/FieldValidationError/index.d.mts +637 -3
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs +187 -0
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
- package/dist/switchVariants-D16b2VaT.mjs +67 -0
- package/dist/switchVariants-D16b2VaT.mjs.map +1 -0
- package/dist/timeVariants-CtXyNKmW.mjs +58 -0
- package/dist/timeVariants-CtXyNKmW.mjs.map +1 -0
- package/dist/{useController-CJjMqXU5.mjs → useController-JtIeurpw.mjs} +2 -2
- package/dist/{useController-CJjMqXU5.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
- package/dist/{useFormContext-BEjPBdzb.mjs → useFormContext-piqnN2L-.mjs} +2 -2
- package/dist/{useFormContext-BEjPBdzb.mjs.map → useFormContext-piqnN2L-.mjs.map} +1 -1
- package/dist/{useInputValueTransform-D44BLp1Z.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -2
- package/dist/{useInputValueTransform-D44BLp1Z.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
- package/package.json +13 -25
- package/dist/FieldCopyTestIdButton-Y9SfvaM9.mjs.map +0 -1
- package/dist/FieldValidationError-BcUV0r1I.mjs +0 -48
- package/dist/FieldValidationError-BcUV0r1I.mjs.map +0 -1
- package/dist/FormContext-B8G_Xxd6.mjs.map +0 -1
- package/dist/Grid-Us2JFczS.mjs.map +0 -1
- package/dist/Switch/index.d.mts.map +0 -1
- package/dist/hooks/useInput/index.d.mts +0 -2
- package/dist/hooks/useInput/index.mjs +0 -5
- package/dist/hooks/useInput/index.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts +0 -2
- package/dist/hooks/useUniformField/index.mjs +0 -141
- package/dist/hooks/useUniformField/index.mjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +0 -47
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +0 -99
- package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
- package/dist/index-CaxrMD1A.d.mts +0 -1
- package/dist/index-DsB0_365.d.mts +0 -106
- package/dist/index-DsB0_365.d.mts.map +0 -1
- package/dist/useController-CdFEp-Wa.d.mts +0 -30
- package/dist/useController-CdFEp-Wa.d.mts.map +0 -1
- package/dist/useFormContext-BSSUZ0Md.d.mts +0 -45
- package/dist/useFormContext-BSSUZ0Md.d.mts.map +0 -1
- package/dist/useInput-ClpHDPdr.d.mts +0 -2
- package/dist/useInput-NPbS4w_n.mjs +0 -1
- package/dist/useInputValueTransform-cevZBrIN.d.mts.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { a as useSensitiveField } from "./FormContext-PXkVlBdU.mjs";
|
|
2
|
+
import { flattenFieldErrors, isValueEmpty } from "./helpers/index.mjs";
|
|
3
|
+
import { t as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-D3_jZYJ1.mjs";
|
|
4
|
+
import { t as FieldValidationError_default } from "./FieldValidationError-iAayfTEw.mjs";
|
|
5
|
+
import { t as useController } from "./useController-JtIeurpw.mjs";
|
|
6
|
+
import { n as useFormContext } from "./useFormContext-piqnN2L-.mjs";
|
|
7
|
+
import { t as useInputValueTransform } from "./useInputValueTransform-CXWWFhy_.mjs";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { useDebounce } from "@fuf-stack/pixels";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/hooks/useUniformField/useUniformField.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Binds a form field's value, interactions, validation and label metadata
|
|
14
|
+
*
|
|
15
|
+
* Converts stored values for display and edited values back to form values
|
|
16
|
+
* through `transform`, with automatic number conversion for numeric inputs
|
|
17
|
+
*
|
|
18
|
+
* Reveals validation errors after editing a nonempty value, blur or submission,
|
|
19
|
+
* keeping pristine fields quiet. Debounces invalid-state changes to avoid
|
|
20
|
+
* flickering during validation updates
|
|
21
|
+
*
|
|
22
|
+
* Returns a bound `field` with callbacks, a focus ref, rendered validation
|
|
23
|
+
* messages and label content, including the test ID action in debug mode
|
|
24
|
+
* Stable IDs and accessible-name metadata support associations in controls
|
|
25
|
+
* Form operations remain separate from the field bundle
|
|
26
|
+
*
|
|
27
|
+
* Only `disabled` reaches the form controller, so disabled values are omitted
|
|
28
|
+
* from validation and submission. Read-only fields stay registered, controls
|
|
29
|
+
* prevent changes while their value is still validated and submitted
|
|
30
|
+
*/
|
|
31
|
+
const useUniformField = (params) => {
|
|
32
|
+
const { name, ariaLabel: customAriaLabel, disabled = false, description, isArrayValue = false, testId: explicitTestId, label, placeholder, readOnly = false, sensitive = false, type, transform } = params;
|
|
33
|
+
useSensitiveField(name, type === "password" || sensitive);
|
|
34
|
+
const associationId = React.useId();
|
|
35
|
+
const ids = {
|
|
36
|
+
control: `uniform-${associationId}`,
|
|
37
|
+
label: `uniform-${associationId}-label`,
|
|
38
|
+
description: `uniform-${associationId}-description`,
|
|
39
|
+
error: `uniform-${associationId}-error`
|
|
40
|
+
};
|
|
41
|
+
const { control, debugMode, formState: { submitCount }, formReset, getFieldState, getValues, resetField } = useFormContext();
|
|
42
|
+
const { error: rawError, invalid: rawInvalid, isDirty, isTouched, required, testId } = getFieldState(name, explicitTestId);
|
|
43
|
+
const { field: controllerField } = useController({
|
|
44
|
+
control,
|
|
45
|
+
disabled,
|
|
46
|
+
name
|
|
47
|
+
});
|
|
48
|
+
const { onChange: fieldOnChange, value: fieldValue, disabled: isDisabled, onBlur, ref } = controllerField;
|
|
49
|
+
const { toDisplayValue, toFormValue } = useInputValueTransform({
|
|
50
|
+
transform,
|
|
51
|
+
type
|
|
52
|
+
});
|
|
53
|
+
const transformedValue = toDisplayValue(fieldValue);
|
|
54
|
+
const transformedOnChange = (eventOrValue) => {
|
|
55
|
+
const displayValue = eventOrValue?.target?.value ?? eventOrValue;
|
|
56
|
+
const formValue = toFormValue(displayValue);
|
|
57
|
+
fieldOnChange(formValue);
|
|
58
|
+
};
|
|
59
|
+
const defaultValue = getValues()?.[name];
|
|
60
|
+
const hasValue = !isValueEmpty(fieldValue);
|
|
61
|
+
const invalid = useDebounce(rawInvalid && (isDirty && hasValue || isTouched || submitCount > 0), 200);
|
|
62
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
63
|
+
const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ jsxs(Fragment, { children: [label !== false ? label : null, showTestIdCopyButton ? /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId }) : null] }) : null;
|
|
64
|
+
const error = isArrayValue ? flattenFieldErrors(rawError) : rawError;
|
|
65
|
+
const normalizedError = flattenFieldErrors(rawError);
|
|
66
|
+
const errorMessage = /* @__PURE__ */ jsx(FieldValidationError_default, {
|
|
67
|
+
error: normalizedError,
|
|
68
|
+
testId
|
|
69
|
+
});
|
|
70
|
+
const fallbackLabel = !label && placeholder?.trim() ? placeholder : name;
|
|
71
|
+
return {
|
|
72
|
+
control,
|
|
73
|
+
debugMode,
|
|
74
|
+
field: {
|
|
75
|
+
ariaLabel: customAriaLabel ?? (label && typeof label === "string" ? label : fallbackLabel),
|
|
76
|
+
customAriaLabel,
|
|
77
|
+
defaultValue,
|
|
78
|
+
description,
|
|
79
|
+
disabled: isDisabled,
|
|
80
|
+
error,
|
|
81
|
+
errorMessage,
|
|
82
|
+
hasErrors: normalizedError.length > 0,
|
|
83
|
+
hasLabel: !!label,
|
|
84
|
+
ids,
|
|
85
|
+
invalid,
|
|
86
|
+
label: labelNode,
|
|
87
|
+
name: controllerField.name,
|
|
88
|
+
onBlur,
|
|
89
|
+
onChange: transformedOnChange,
|
|
90
|
+
readOnly,
|
|
91
|
+
ref,
|
|
92
|
+
required,
|
|
93
|
+
testId,
|
|
94
|
+
value: transformedValue
|
|
95
|
+
},
|
|
96
|
+
formReset,
|
|
97
|
+
getValues,
|
|
98
|
+
resetField
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
// src/partials/FieldLabel/FieldLabel.tsx
|
|
102
|
+
/**
|
|
103
|
+
* Shared field label and required indicator
|
|
104
|
+
*
|
|
105
|
+
* Uses a native label by default, with span/div hosts for nested labels and
|
|
106
|
+
* headings, or React Aria Label for fields that supply label context
|
|
107
|
+
*
|
|
108
|
+
* @see https://react-aria.adobe.com/TextField
|
|
109
|
+
* @see https://react-aria.adobe.com/CheckboxGroup
|
|
110
|
+
*/
|
|
111
|
+
const FieldLabel = ({ as: Component = "label", children, className = void 0, htmlFor = void 0, id = void 0, required = false, requiredClassName = "ml-0.5 text-danger", ...props }) => {
|
|
112
|
+
if (!children) return null;
|
|
113
|
+
return /* @__PURE__ */ jsxs(Component, {
|
|
114
|
+
...props,
|
|
115
|
+
className,
|
|
116
|
+
"data-slot": "label",
|
|
117
|
+
htmlFor,
|
|
118
|
+
id,
|
|
119
|
+
children: [children, required ? /* @__PURE__ */ jsx("span", {
|
|
120
|
+
"aria-hidden": true,
|
|
121
|
+
className: requiredClassName,
|
|
122
|
+
children: "*"
|
|
123
|
+
}) : null]
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
export { useUniformField as n, FieldLabel as t };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=FieldLabel-DrNWJIVh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldLabel-DrNWJIVh.mjs","names":["FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/partials/FieldLabel/FieldLabel.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\nimport type { UniformFieldState, UseUniformFieldParams } from './types';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { useSensitiveField } from '../../Form/subcomponents/SensitiveFields';\nimport { flattenFieldErrors, isValueEmpty } from '../../helpers';\nimport FieldCopyTestIdButton from '../../partials/FieldCopyTestIdButton';\nimport FieldValidationError from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Binds a form field's value, interactions, validation and label metadata\n *\n * Converts stored values for display and edited values back to form values\n * through `transform`, with automatic number conversion for numeric inputs\n *\n * Reveals validation errors after editing a nonempty value, blur or submission,\n * keeping pristine fields quiet. Debounces invalid-state changes to avoid\n * flickering during validation updates\n *\n * Returns a bound `field` with callbacks, a focus ref, rendered validation\n * messages and label content, including the test ID action in debug mode\n * Stable IDs and accessible-name metadata support associations in controls\n * Form operations remain separate from the field bundle\n *\n * Only `disabled` reaches the form controller, so disabled values are omitted\n * from validation and submission. Read-only fields stay registered, controls\n * prevent changes while their value is still validated and submitted\n */\nconst useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UniformFieldState<TFieldValues, TDisplay> => {\n // field configuration\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n description,\n isArrayValue = false,\n testId: explicitTestId,\n label,\n placeholder,\n readOnly = false,\n sensitive = false,\n type,\n transform,\n } = params;\n\n // revealing a password never changes its diagnostic redaction\n useSensitiveField(name, type === 'password' || sensitive);\n\n // stable associations between the control, label and messages\n const associationId = React.useId();\n const ids = {\n control: `uniform-${associationId}`,\n label: `uniform-${associationId}-label`,\n description: `uniform-${associationId}-description`,\n error: `uniform-${associationId}-error`,\n };\n\n // form operations and submission state\n const {\n control,\n debugMode,\n formState: { submitCount },\n formReset,\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n // validation and interaction state\n const {\n error: rawError,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n // register the field and connect its value and callbacks\n const { field: controllerField } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = controllerField;\n\n // convert between stored form values and displayed values\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n transform,\n type,\n });\n\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // accept native events as well as direct values\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n // show errors after editing a nonempty value, blur or submission\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid =\n rawInvalid && ((isDirty && hasValue) || isTouched || submitCount > 0);\n\n // allow validation messages to finish their exit animation\n const invalid = useDebounce(showInvalid, 200);\n\n // include the test ID action when debugging fields\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // preserve nested errors for groups, flatten messages for rendering\n const error = isArrayValue ? flattenFieldErrors(rawError) : rawError;\n const normalizedError = flattenFieldErrors(rawError);\n const errorMessage = (\n <FieldValidationError error={normalizedError} testId={testId} />\n );\n\n // prefer a visible label, use placeholder text only when the field has no label\n const fallbackLabel = !label && placeholder?.trim() ? placeholder : name;\n const ariaLabel =\n customAriaLabel ??\n (label && typeof label === 'string' ? label : fallbackLabel);\n\n // collect the bound field without exposing controller internals\n const field = {\n ariaLabel,\n customAriaLabel,\n defaultValue,\n description,\n disabled: isDisabled,\n error,\n errorMessage,\n hasErrors: normalizedError.length > 0,\n hasLabel: !!label,\n ids,\n invalid,\n label: labelNode,\n name: controllerField.name,\n onBlur,\n onChange: transformedOnChange,\n readOnly,\n ref,\n required,\n testId,\n value: transformedValue,\n };\n\n return {\n control,\n debugMode,\n field,\n formReset,\n getValues,\n resetField,\n };\n};\n\nexport default useUniformField;\n","import type { HTMLAttributes, ReactNode } from 'react';\nimport type { Label as AriaLabel } from 'react-aria-components';\n\ninterface FieldLabelProps extends Pick<\n HTMLAttributes<HTMLElement>,\n 'aria-level' | 'role'\n> {\n /** Label element, React Aria Label preserves the surrounding field context */\n as?: 'label' | 'div' | 'span' | typeof AriaLabel;\n /** Label content */\n children: ReactNode;\n /** CSS class name */\n className?: string;\n /** ID of the labeled control */\n htmlFor?: string;\n /** Label ID */\n id?: string;\n /** Shows the required indicator */\n required?: boolean;\n /** Required indicator CSS class name */\n requiredClassName?: string;\n}\n\n/**\n * Shared field label and required indicator\n *\n * Uses a native label by default, with span/div hosts for nested labels and\n * headings, or React Aria Label for fields that supply label context\n *\n * @see https://react-aria.adobe.com/TextField\n * @see https://react-aria.adobe.com/CheckboxGroup\n */\nconst FieldLabel = ({\n as: Component = 'label',\n children,\n className = undefined,\n htmlFor = undefined,\n id = undefined,\n required = false,\n requiredClassName = 'ml-0.5 text-danger',\n ...props\n}: FieldLabelProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <Component\n {...props}\n className={className}\n data-slot=\"label\"\n htmlFor={htmlFor}\n id={id}\n >\n {children}\n {required ? (\n <span aria-hidden className={requiredClassName}>\n *\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default FieldLabel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,mBAIJ,WAC8C;CAE9C,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,aACA,eAAe,OACf,QAAQ,gBACR,OACA,aACA,WAAW,OACX,YAAY,OACZ,MACA,cACE;CAGJ,kBAAkB,MAAM,SAAS,cAAc,SAAS;CAGxD,MAAM,gBAAgB,MAAM,MAAM;CAClC,MAAM,MAAM;EACV,SAAS,WAAW;EACpB,OAAO,WAAW,cAAc;EAChC,aAAa,WAAW,cAAc;EACtC,OAAO,WAAW,cAAc;CAClC;CAGA,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,WACA,eACA,WACA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ACA;GACA,OAAO;EAMH;EACJ;EACA;EACA;CACF;AACF;;;;;;;;;;;AC9JA,MAAM,cAAc,EAClB,IAAI,YAAY,SAChB,UACA,YAAY,KAAA,GACZ,UAAU,KAAA,GACV,KAAK,KAAA,GACL,WAAW,OACX,oBAAoB,sBACpB,GAAG,YACkB;CACrB,IAAI,CAAC,UACH,OAAO;CAGT,OACE,qBAAC,WAAD;EACE,GAAI;EACO;EACX,aAAU;EACD;EACL;EALN,UAAA,CAOG,UACA,WACC,oBAAC,QAAD;GAAM,eAAA;GAAY,WAAW;GAAmB,UAAA;EAE1C,CAAA,IACJ,IACK;;AAEf"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as FieldDescription } from "./FieldDescription-X_0s1Lhu.mjs";
|
|
2
|
+
import { t as FieldLabel } from "./FieldLabel-DrNWJIVh.mjs";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/partials/FieldLayout/FieldLayout.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Default arrangement of a field label, editable content and supporting messages
|
|
7
|
+
*
|
|
8
|
+
* Renders the base component around the label, content and messages
|
|
9
|
+
* Receives IDs, resolved classes and validation state
|
|
10
|
+
*/
|
|
11
|
+
const FieldLayout = ({ baseAs = void 0, baseProps = void 0, children, className, description = void 0, errorMessage, ids, invalid, label = void 0, labelAs = "label", required = false }) => {
|
|
12
|
+
return /* @__PURE__ */ jsxs(baseAs ?? "div", {
|
|
13
|
+
...baseProps,
|
|
14
|
+
className: className.base,
|
|
15
|
+
"data-slot": "base",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
18
|
+
as: labelAs,
|
|
19
|
+
className: className.label,
|
|
20
|
+
htmlFor: labelAs === "label" ? ids.control : void 0,
|
|
21
|
+
id: ids.label,
|
|
22
|
+
required,
|
|
23
|
+
children: label
|
|
24
|
+
}),
|
|
25
|
+
children,
|
|
26
|
+
description || invalid ? /* @__PURE__ */ jsxs("div", {
|
|
27
|
+
className: className.helperWrapper,
|
|
28
|
+
"data-slot": "helper-wrapper",
|
|
29
|
+
children: [/* @__PURE__ */ jsx(FieldDescription, {
|
|
30
|
+
className: className.description,
|
|
31
|
+
id: ids.description,
|
|
32
|
+
children: description
|
|
33
|
+
}), invalid ? /* @__PURE__ */ jsx("div", {
|
|
34
|
+
className: className.errorMessage,
|
|
35
|
+
"data-slot": "error-message",
|
|
36
|
+
id: ids.error,
|
|
37
|
+
children: errorMessage
|
|
38
|
+
}) : null]
|
|
39
|
+
}) : null
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export { FieldLayout as t };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=FieldLayout-DcvQU0zN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldLayout-DcvQU0zN.mjs","names":[],"sources":["../src/partials/FieldLayout/FieldLayout.tsx"],"sourcesContent":["import type {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n} from 'react';\nimport type { FieldIds } from '../types';\n\nimport FieldDescription from '../FieldDescription/FieldDescription';\nimport FieldLabel from '../FieldLabel/FieldLabel';\n\ntype ClassName = Partial<\n Record<\n 'base' | 'description' | 'errorMessage' | 'helperWrapper' | 'label',\n string\n >\n>;\n\ntype BaseProps<TBase extends ElementType> = Omit<\n ComponentPropsWithRef<TBase>,\n 'children' | 'className' | 'dangerouslySetInnerHTML'\n> &\n Record<`data-${string}`, string | number | boolean | undefined>;\n\n// require the configuration when the base has props the layout cannot supply\ntype BaseConfiguration<TBase extends ElementType> =\n Record<never, never> extends BaseProps<TBase>\n ? { baseProps?: BaseProps<TBase> }\n : { baseProps: BaseProps<TBase> };\n\ninterface FieldLayoutProps<TBase extends ElementType> {\n /** Component or element used for the base slot */\n baseAs?: TBase;\n /** Attributes, interactions and ref for the base element */\n baseProps?: BaseProps<NoInfer<TBase>>;\n /** Editable field content */\n children: ReactNode;\n /** CSS class name */\n className: ClassName;\n /** Help text */\n description?: ReactNode;\n /** Rendered validation messages */\n errorMessage: ReactNode;\n /** IDs shared with the editable control */\n ids: FieldIds;\n /** Shows the validation message */\n invalid: boolean;\n /** Field label */\n label?: ReactNode;\n /** Label element, use React Aria Label inside group engines */\n labelAs?: ComponentProps<typeof FieldLabel>['as'];\n /** Shows the required indicator */\n required?: boolean;\n}\n\n/**\n * Default arrangement of a field label, editable content and supporting messages\n *\n * Renders the base component around the label, content and messages\n * Receives IDs, resolved classes and validation state\n */\nconst FieldLayout = <TBase extends ElementType = 'div'>({\n baseAs = undefined,\n baseProps = undefined,\n children,\n className,\n description = undefined,\n errorMessage,\n ids,\n invalid,\n label = undefined,\n labelAs = 'label',\n required = false,\n}: FieldLayoutProps<TBase> & BaseConfiguration<NoInfer<TBase>>) => {\n const Base = baseAs ?? 'div';\n\n return (\n <Base {...baseProps} className={className.base} data-slot=\"base\">\n {/* field label */}\n <FieldLabel\n as={labelAs}\n className={className.label}\n htmlFor={labelAs === 'label' ? ids.control : undefined}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n\n {/* editable content */}\n {children}\n\n {/* help text and validation messages */}\n {description || invalid ? (\n <div className={className.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldDescription\n className={className.description}\n id={ids.description}\n >\n {description}\n </FieldDescription>\n {invalid ? (\n <div\n className={className.errorMessage}\n data-slot=\"error-message\"\n id={ids.error}\n >\n {errorMessage}\n </div>\n ) : null}\n </div>\n ) : null}\n </Base>\n );\n};\n\nexport default FieldLayout;\n"],"mappings":";;;;;;;;;;AA6DA,MAAM,eAAkD,EACtD,SAAS,KAAA,GACT,YAAY,KAAA,GACZ,UACA,WACA,cAAc,KAAA,GACd,cACA,KACA,SACA,QAAQ,KAAA,GACR,UAAU,SACV,WAAW,YACsD;CAGjE,OACE,qBAHW,UAAU,OAGrB;EAAM,GAAI;EAAW,WAAW,UAAU;EAAM,aAAU;EAA1D,UAAA;GAEE,oBAAC,YAAD;IACE,IAAI;IACJ,WAAW,UAAU;IACrB,SAAS,YAAY,UAAU,IAAI,UAAU,KAAA;IAC7C,IAAI,IAAI;IACE;IAET,UAAA;GACS,CAAA;GAGX;GAGA,eAAe,UACd,qBAAC,OAAD;IAAK,WAAW,UAAU;IAAe,aAAU;IAAnD,UAAA,CACE,oBAAC,kBAAD;KACE,WAAW,UAAU;KACrB,IAAI,IAAI;KAEP,UAAA;IACe,CAAA,GACjB,UACC,oBAAC,OAAD;KACE,WAAW,UAAU;KACrB,aAAU;KACV,IAAI,IAAI;KAEP,UAAA;IACE,CAAA,IACH,IACD;GACH,CAAA,IAAA;EACA;;AAEV"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as InputValueTransform } from "../
|
|
2
|
-
import { TVClassName } from "@fuf-stack/pixel-utils";
|
|
1
|
+
import { t as InputValueTransform } from "../index-cevZBrIN.mjs";
|
|
3
2
|
import { ReactNode } from "react";
|
|
3
|
+
import { TVClassName } from "@fuf-stack/pixel-utils";
|
|
4
4
|
/** Controls when a FieldReset field is included in the submitted data */
|
|
5
5
|
type FieldResetInclude = 'always' | 'changed';
|
|
6
|
-
|
|
6
|
+
/** Styles the field wrapper and its change announcement */
|
|
7
|
+
export declare const fieldResetVariants: ((props?: ({
|
|
7
8
|
[x: string]: string | number | undefined;
|
|
8
9
|
[x: number]: string | number | undefined;
|
|
9
10
|
} & ({
|
|
@@ -55,7 +56,7 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
55
56
|
class?: never;
|
|
56
57
|
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;
|
|
57
58
|
})) | undefined) => {
|
|
58
|
-
|
|
59
|
+
announcement: (slotProps?: ({
|
|
59
60
|
[x: string]: string | number | undefined;
|
|
60
61
|
[x: number]: string | number | undefined;
|
|
61
62
|
} & ({
|
|
@@ -107,7 +108,7 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
107
108
|
class?: never;
|
|
108
109
|
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;
|
|
109
110
|
})) | undefined) => string;
|
|
110
|
-
|
|
111
|
+
base: (slotProps?: ({
|
|
111
112
|
[x: string]: string | number | undefined;
|
|
112
113
|
[x: number]: string | number | undefined;
|
|
113
114
|
} & ({
|
|
@@ -160,7 +161,7 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
160
161
|
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;
|
|
161
162
|
})) | undefined) => string;
|
|
162
163
|
} & {
|
|
163
|
-
|
|
164
|
+
announcement: (slotProps?: ({
|
|
164
165
|
[x: string]: string | number | undefined;
|
|
165
166
|
[x: number]: string | number | undefined;
|
|
166
167
|
} & ({
|
|
@@ -212,7 +213,7 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
212
213
|
class?: never;
|
|
213
214
|
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;
|
|
214
215
|
})) | undefined) => string;
|
|
215
|
-
|
|
216
|
+
base: (slotProps?: ({
|
|
216
217
|
[x: string]: string | number | undefined;
|
|
217
218
|
[x: number]: string | number | undefined;
|
|
218
219
|
} & ({
|
|
@@ -272,14 +273,14 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
272
273
|
class?: never;
|
|
273
274
|
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;
|
|
274
275
|
})) | undefined) => {} & {
|
|
275
|
-
|
|
276
|
+
announcement: (slotProps?: ({} & ({
|
|
276
277
|
class?: 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;
|
|
277
278
|
className?: never;
|
|
278
279
|
} | {
|
|
279
280
|
class?: never;
|
|
280
281
|
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;
|
|
281
282
|
})) | undefined) => string;
|
|
282
|
-
|
|
283
|
+
base: (slotProps?: ({} & ({
|
|
283
284
|
class?: 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;
|
|
284
285
|
className?: never;
|
|
285
286
|
} | {
|
|
@@ -290,8 +291,10 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
290
291
|
extend: undefined;
|
|
291
292
|
base: undefined;
|
|
292
293
|
slots: {
|
|
293
|
-
|
|
294
|
+
/** Screen-reader announcement of a changed value */
|
|
294
295
|
announcement: string;
|
|
296
|
+
/** Container around the field and its reset action */
|
|
297
|
+
base: string;
|
|
295
298
|
};
|
|
296
299
|
variants: unknown;
|
|
297
300
|
defaultVariants: {};
|
|
@@ -321,8 +324,10 @@ declare const fieldResetVariants: ((props?: ({
|
|
|
321
324
|
};
|
|
322
325
|
base: undefined;
|
|
323
326
|
slots: {
|
|
324
|
-
|
|
327
|
+
/** Screen-reader announcement of a changed value */
|
|
325
328
|
announcement: string;
|
|
329
|
+
/** Container around the field and its reset action */
|
|
330
|
+
base: string;
|
|
326
331
|
};
|
|
327
332
|
variants: {
|
|
328
333
|
[key: string]: {
|
|
@@ -410,6 +415,6 @@ interface FieldResetProps<TDisplay = string> {
|
|
|
410
415
|
resetValue: NonNullable<unknown>;
|
|
411
416
|
}
|
|
412
417
|
/** Tracks a field against its original value, shows reset, and controls payload inclusion */
|
|
413
|
-
declare const FieldReset: <TDisplay = string>({ children, className
|
|
418
|
+
declare const FieldReset: <TDisplay = string>({ changedLabel, children, className, disabled, include, name, resetLabel, resetValue }: FieldResetProps<TDisplay>) => import("react").JSX.Element;
|
|
414
419
|
export { type FieldResetInclude, type FieldResetProps, type FieldResetRenderProps, FieldReset as default };
|
|
415
420
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/FieldReset/helpers/fieldResetValues.ts","../../src/FieldReset/FieldReset.tsx"],"mappings":";;;;KAMY
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/FieldReset/helpers/fieldResetValues.ts","../../src/FieldReset/FieldReset.tsx"],"mappings":";;;;KAMY;;qBCoBC,sBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAS1B,YAAY,mBAAmB;UAEnB,sBAAsB;;EAErC,aAAa;;EAEb,WAAW,oBAAoB;;UAGhB,gBAAgB;;EAE/B;;EAEA,WAAW,OAAO,sBAAsB,cAAc;;EAEtD,YAAY;;EAEZ;;EAEA,UAAU;;EAEV;;EAEA;;EAEA,YAAY;;;cAIR,aAAc,qBAAoB,cAAA,UAAA,WAAA,UAAA,SAAA,MAAA,YAAA,cASrC,gBAAgB,8BAAS,IAAA"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { toFormFormat, toNullishString, toSubmitFormat } from "../helpers/index.mjs";
|
|
2
|
-
import { n as useFormContext$1 } from "../useFormContext-
|
|
3
|
-
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
2
|
+
import { n as useFormContext$1 } from "../useFormContext-piqnN2L-.mjs";
|
|
4
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
4
|
import { useIsInitialRenderCycle } from "@fuf-stack/pixels";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { tv } from "@fuf-stack/pixel-utils";
|
|
7
|
+
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
7
8
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
9
|
+
import { Button as Button$1 } from "react-aria-components";
|
|
8
10
|
import { FaUndoAlt } from "react-icons/fa";
|
|
11
|
+
import Tooltip from "@fuf-stack/pixels/Tooltip";
|
|
9
12
|
// src/FieldReset/helpers/fieldResetValues.ts
|
|
10
13
|
const WRAPPER_KEY = "value";
|
|
11
14
|
/**
|
|
@@ -82,42 +85,53 @@ const createFieldResetTransform = ({ resetValue, include, storedValue }) => {
|
|
|
82
85
|
};
|
|
83
86
|
// src/FieldReset/subcomponents/FieldResetAction.tsx
|
|
84
87
|
const fieldResetActionVariants = tv({ slots: {
|
|
88
|
+
/** Compact button that restores the field value */
|
|
85
89
|
base: [
|
|
86
90
|
"inline-flex size-6 shrink-0 items-center justify-center",
|
|
87
91
|
"rounded-sm text-warning",
|
|
88
|
-
"
|
|
89
|
-
"outline-none focus-visible:ring-2 focus-visible:ring-focus",
|
|
90
|
-
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
92
|
+
"data-[hovered=true]:bg-warning/15",
|
|
93
|
+
"outline-none data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-focus",
|
|
94
|
+
"data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50"
|
|
91
95
|
],
|
|
96
|
+
/** Icon indicating the reset action */
|
|
92
97
|
icon: "size-3.5"
|
|
93
98
|
} });
|
|
94
|
-
|
|
99
|
+
/** Restores the field without taking focus or inheriting number stepper actions */
|
|
100
|
+
const FieldResetAction = ({ className = void 0, disabled, isChanged, name, onReset, resetLabel }) => {
|
|
101
|
+
const styling = useStyling();
|
|
95
102
|
if (!isChanged) return null;
|
|
96
|
-
const variants = fieldResetActionVariants
|
|
97
|
-
const
|
|
98
|
-
return /* @__PURE__ */ jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
const variants = styling.resolve(fieldResetActionVariants);
|
|
104
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
105
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
106
|
+
content: resetLabel,
|
|
107
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
108
|
+
"aria-label": `${resetLabel}: ${name}`,
|
|
109
|
+
className: classNames.base,
|
|
110
|
+
"data-slot": "reset-action",
|
|
111
|
+
isDisabled: disabled,
|
|
112
|
+
onPress: onReset,
|
|
113
|
+
preventFocusOnPress: true,
|
|
114
|
+
slot: null,
|
|
115
|
+
type: "button",
|
|
116
|
+
children: /* @__PURE__ */ jsx(FaUndoAlt, {
|
|
117
|
+
"aria-hidden": "true",
|
|
118
|
+
className: classNames.icon,
|
|
119
|
+
"data-slot": "icon"
|
|
120
|
+
})
|
|
111
121
|
})
|
|
112
122
|
});
|
|
113
123
|
};
|
|
114
124
|
// src/FieldReset/FieldReset.tsx
|
|
125
|
+
/** Styles the field wrapper and its change announcement */
|
|
115
126
|
const fieldResetVariants = tv({ slots: {
|
|
116
|
-
|
|
117
|
-
announcement: "sr-only"
|
|
127
|
+
/** Screen-reader announcement of a changed value */
|
|
128
|
+
announcement: "sr-only",
|
|
129
|
+
/** Container around the field and its reset action */
|
|
130
|
+
base: "min-w-0"
|
|
118
131
|
} });
|
|
119
132
|
/** Tracks a field against its original value, shows reset, and controls payload inclusion */
|
|
120
|
-
const FieldReset = ({ children, className
|
|
133
|
+
const FieldReset = ({ changedLabel = "Changed", children, className = void 0, disabled = false, include = "changed", name, resetLabel = "Reset to original", resetValue }) => {
|
|
134
|
+
const styling = useStyling();
|
|
121
135
|
const { control, formReset, register, resetField, setValue, setFocus, trigger } = useFormContext$1();
|
|
122
136
|
const { getValues } = useFormContext();
|
|
123
137
|
const storedValue = useWatch({
|
|
@@ -199,7 +213,7 @@ const FieldReset = ({ children, className: _className = void 0, disabled = false
|
|
|
199
213
|
useEffect(() => {
|
|
200
214
|
return formReset.subscribe(registerValueConversion);
|
|
201
215
|
}, [formReset, registerValueConversion]);
|
|
202
|
-
const
|
|
216
|
+
const handleReset = useCallback(() => {
|
|
203
217
|
restoreOriginal();
|
|
204
218
|
setFocus(name);
|
|
205
219
|
trigger(name);
|
|
@@ -216,26 +230,29 @@ const FieldReset = ({ children, className: _className = void 0, disabled = false
|
|
|
216
230
|
disabled,
|
|
217
231
|
isChanged,
|
|
218
232
|
name,
|
|
219
|
-
onReset:
|
|
233
|
+
onReset: handleReset,
|
|
220
234
|
resetLabel
|
|
221
235
|
});
|
|
222
|
-
const variants = fieldResetVariants
|
|
223
|
-
const
|
|
236
|
+
const variants = styling.resolve(fieldResetVariants);
|
|
237
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
224
238
|
return /* @__PURE__ */ jsxs("div", {
|
|
225
|
-
className:
|
|
239
|
+
className: classNames.base,
|
|
226
240
|
"data-changed": isChanged || void 0,
|
|
241
|
+
"data-component": "field-reset",
|
|
242
|
+
"data-slot": "base",
|
|
227
243
|
children: [children({
|
|
228
|
-
|
|
229
|
-
|
|
244
|
+
resetAction,
|
|
245
|
+
transform
|
|
230
246
|
}), /* @__PURE__ */ jsx("span", {
|
|
231
247
|
"aria-live": "polite",
|
|
232
|
-
className:
|
|
248
|
+
className: classNames.announcement,
|
|
249
|
+
"data-slot": "announcement",
|
|
233
250
|
children: isChanged ? changedLabel : ""
|
|
234
251
|
})]
|
|
235
252
|
});
|
|
236
253
|
};
|
|
237
254
|
// src/FieldReset/index.ts
|
|
238
255
|
var FieldReset_default = FieldReset;
|
|
239
|
-
export { FieldReset_default as default };
|
|
256
|
+
export { FieldReset_default as default, fieldResetVariants };
|
|
240
257
|
|
|
241
258
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +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":";;;;;;;;;A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EAAK,CAAC;EAErE,SAAS,UAAU;GAAE;GAAM,UAAU;EAAS;EAC9C,QAAQ;CACV,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAID,gBAAgB;EACd,OAAO,UAAU,UAAU,uBAAuB;CACpD,GAAG,CAAC,WAAW,uBAAuB,CAAC;CAIvC,MAAM,QAAQ,kBAAkB;EAC9B,gBAAgB;EAChB,SAAS,IAAI;EACb,QAAQ,IAAI;CACd,GAAG;EAAC;EAAM;EAAiB;EAAU;CAAO,CAAC;CAI7C,MAAM,kBAAkB,wBAAwB;CAChD,MAAM,QACJ,gBAAgB,gBAAgB,gBAAgB,KAAA,IAC5C,iBAAiB,QAAQ,IACzB;CACN,MAAM,YAAY,CAAC,mBAAmB,oBAAoB,OAAO,QAAQ;CACzE,MAAM,cACJ,oBAAC,kBAAD;EACY;EACC;EACL;EACN,SAAS;EACG;CACb,CAAA;CAIH,MAAM,WAAW,mBAAmB;CACpC,MAAM,YAAY,qBAAqB,UAAU,YAAY,MAAM;CAEnE,OACE,qBAAC,OAAD;EAAK,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"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Button","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 { Button } from 'react-aria-components';\nimport { FaUndoAlt } from 'react-icons/fa';\n\nimport { tv } from '@fuf-stack/pixel-utils';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\nimport Tooltip from '@fuf-stack/pixels/Tooltip';\n\nconst fieldResetActionVariants = tv({\n slots: {\n /** Compact button that restores the field value */\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 'data-[hovered=true]:bg-warning/15',\n // keyboard focus indicator\n 'outline-none data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-focus',\n // disabled state\n 'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50',\n ],\n /** Icon indicating the reset action */\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\n/** Restores the field without taking focus or inheriting number stepper actions */\nconst FieldResetAction = ({\n className = undefined,\n disabled,\n isChanged,\n name,\n onReset,\n resetLabel,\n}: FieldResetActionProps) => {\n const styling = useStyling();\n\n if (!isChanged) {\n return null;\n }\n\n // classNames from slots\n const variants = styling.resolve(fieldResetActionVariants);\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <Tooltip content={resetLabel}>\n <Button\n aria-label={`${resetLabel}: ${name}`}\n className={classNames.base}\n data-slot=\"reset-action\"\n isDisabled={disabled}\n onPress={onReset}\n preventFocusOnPress\n slot={null}\n type=\"button\"\n >\n <FaUndoAlt\n aria-hidden=\"true\"\n className={classNames.icon}\n data-slot=\"icon\"\n />\n </Button>\n </Tooltip>\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 } from '@fuf-stack/pixel-utils';\nimport { useIsInitialRenderCycle } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\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\n/** Styles the field wrapper and its change announcement */\nexport const fieldResetVariants = tv({\n slots: {\n /** Screen-reader announcement of a changed value */\n announcement: 'sr-only',\n /** Container around the field and its reset action */\n base: 'min-w-0',\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 changedLabel = 'Changed',\n children,\n className = undefined,\n disabled = false,\n include = 'changed',\n name,\n resetLabel = 'Reset to original',\n resetValue,\n}: FieldResetProps<TDisplay>) => {\n const styling = useStyling();\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 handleReset = 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={handleReset}\n resetLabel={resetLabel}\n />\n );\n\n // classNames from slots\n const variants = styling.resolve(fieldResetVariants);\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n className={classNames.base}\n data-changed={isChanged || undefined}\n data-component=\"field-reset\"\n data-slot=\"base\"\n >\n {children({ resetAction, transform })}\n <span\n aria-live=\"polite\"\n className={classNames.announcement}\n data-slot=\"announcement\"\n >\n {isChanged ? changedLabel : ''}\n </span>\n </div>\n );\n};\n\nexport default FieldReset;\n","import FieldReset from './FieldReset';\n\nexport { fieldResetVariants } from './FieldReset';\n\nexport type { FieldResetProps, FieldResetRenderProps } from './FieldReset';\nexport type { FieldResetInclude } from './helpers/fieldResetValues';\n\nexport default FieldReset;\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