@fuf-stack/uniform 1.27.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/Checkboxes/index.d.mts +11 -13
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +2 -4
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +14 -16
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +3 -6
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +2 -8
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +12 -22
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +0 -2
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +5 -8
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-CRJBix9D.mjs → FieldCopyTestIdButton-Y9SfvaM9.mjs} +4 -6
- package/dist/{FieldCopyTestIdButton-CRJBix9D.mjs.map → FieldCopyTestIdButton-Y9SfvaM9.mjs.map} +1 -1
- package/dist/{FieldValidationError-ByRoIxaM.mjs → FieldValidationError-BcUV0r1I.mjs} +3 -5
- package/dist/{FieldValidationError-ByRoIxaM.mjs.map → FieldValidationError-BcUV0r1I.mjs.map} +1 -1
- package/dist/Form/index.d.mts +1 -3
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +10 -12
- package/dist/Form/index.mjs.map +1 -1
- package/dist/FormContext-B8G_Xxd6.mjs +512 -0
- package/dist/FormContext-B8G_Xxd6.mjs.map +1 -0
- package/dist/FormContext-BnNJYZOo.d.mts +124 -0
- package/dist/FormContext-BnNJYZOo.d.mts.map +1 -0
- package/dist/Grid/index.d.mts +0 -2
- package/dist/Grid/index.d.mts.map +1 -1
- package/dist/Grid/index.mjs +1 -2
- package/dist/{Grid-CTs-Rb9G.mjs → Grid-Us2JFczS.mjs} +3 -5
- package/dist/{Grid-CTs-Rb9G.mjs.map → Grid-Us2JFczS.mjs.map} +1 -1
- package/dist/Input/index.d.mts +21 -19
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +106 -13
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +2 -6
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +3 -6
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +46 -48
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +2 -4
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +14 -16
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +2 -4
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +5 -7
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +4 -7
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +31 -33
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +2 -4
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts +0 -2
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +2 -4
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +16 -18
- package/dist/Switch/index.d.mts.map +1 -1
- package/dist/Switch/index.mjs +2 -4
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/SwitchBox/index.d.mts +35 -37
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +2 -4
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +0 -2
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +2 -4
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +0 -2
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +3 -6
- package/dist/Time/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +0 -6
- package/dist/helpers/index.d.mts.map +1 -1
- package/dist/helpers/index.mjs +3 -6
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.d.mts +0 -2
- package/dist/hooks/useClientValidation/index.d.mts.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +3 -5
- package/dist/hooks/useController/index.d.mts +1 -2
- package/dist/hooks/useController/index.mjs +2 -4
- package/dist/hooks/useFormContext/index.d.mts +2 -3
- package/dist/hooks/useFormContext/index.mjs +2 -4
- package/dist/hooks/useInput/index.mjs +2 -4
- package/dist/hooks/useInputValueDebounce/index.d.mts +2 -4
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +3 -5
- package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -1
- package/dist/hooks/useInputValueTransform/index.mjs +2 -4
- package/dist/hooks/useUniformField/index.d.mts +2 -98
- package/dist/hooks/useUniformField/index.mjs +11 -11
- package/dist/hooks/useUniformField/index.mjs.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +23 -49
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +3 -5
- package/dist/hooks/useUniformFieldArray/index.mjs.map +1 -1
- package/dist/hooks/useWatchFormReset/index.d.mts +0 -2
- package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +3 -5
- package/dist/hooks/useWatchUserChange/index.d.mts +2 -4
- package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +3 -5
- package/dist/hooks/useWatchUserChange/index.mjs.map +1 -1
- package/dist/index-DaiTW5Bl.d.mts +99 -0
- package/dist/index-DaiTW5Bl.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.d.mts +0 -2
- package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -2
- package/dist/partials/FieldValidationError/index.d.mts +0 -2
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -2
- package/dist/{useController-CK39i6HI.mjs → useController-CJjMqXU5.mjs} +3 -4
- package/dist/{useController-CK39i6HI.mjs.map → useController-CJjMqXU5.mjs.map} +1 -1
- package/dist/{useController-DcK2YHbw.d.mts → useController-CdFEp-Wa.d.mts} +2 -4
- package/dist/useController-CdFEp-Wa.d.mts.map +1 -0
- package/dist/{useFormContext-fYWtlnpE.mjs → useFormContext-BEjPBdzb.mjs} +3 -4
- package/dist/useFormContext-BEjPBdzb.mjs.map +1 -0
- package/dist/useFormContext-BhPzFXwF.d.mts +45 -0
- package/dist/useFormContext-BhPzFXwF.d.mts.map +1 -0
- package/dist/useInput-NPbS4w_n.mjs +1 -0
- package/dist/{useInputValueTransform-DJ5zkqSy.mjs → useInputValueTransform-D44BLp1Z.mjs} +2 -3
- package/dist/{useInputValueTransform-DJ5zkqSy.mjs.map → useInputValueTransform-D44BLp1Z.mjs.map} +1 -1
- package/dist/{useInputValueTransform-LOaEim7k.d.mts → useInputValueTransform-cevZBrIN.d.mts} +3 -5
- package/dist/useInputValueTransform-cevZBrIN.d.mts.map +1 -0
- package/package.json +10 -10
- package/dist/FormContext-CsFiNvuJ.d.mts +0 -19
- package/dist/FormContext-CsFiNvuJ.d.mts.map +0 -1
- package/dist/FormContext-gHSwOlcy.mjs +0 -278
- package/dist/FormContext-gHSwOlcy.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts.map +0 -1
- package/dist/index-CAdGtKE_.d.mts +0 -1
- package/dist/index-D5HVU2jP.d.mts +0 -1
- package/dist/useController-DcK2YHbw.d.mts.map +0 -1
- package/dist/useFormContext-B3QGVVaO.d.mts +0 -66
- package/dist/useFormContext-B3QGVVaO.d.mts.map +0 -1
- package/dist/useFormContext-fYWtlnpE.mjs.map +0 -1
- package/dist/useInput-C0aJaAGe.mjs +0 -2
- package/dist/useInputValueTransform-LOaEim7k.d.mts.map +0 -1
package/dist/{FieldCopyTestIdButton-CRJBix9D.mjs.map → FieldCopyTestIdButton-Y9SfvaM9.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldCopyTestIdButton-
|
|
1
|
+
{"version":3,"file":"FieldCopyTestIdButton-Y9SfvaM9.mjs","names":[],"sources":["../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../src/partials/FieldCopyTestIdButton/index.ts"],"sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\nexport interface FieldCopyTestIdButtonProps {\n /** CSS class name */\n className?: string;\n /** HTML data-testid attribute used in e2e tests */\n testId: string;\n}\n\nconst FieldCopyTestIdButton = ({\n className = undefined,\n testId,\n}: FieldCopyTestIdButtonProps) => {\n const copyToClipboard = () => {\n // This component runs in the browser; the Node compatibility rule cannot\n // distinguish the DOM Clipboard API from Node's global navigator.\n // eslint-disable-next-line n/no-unsupported-features/node-builtins\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n icon={<FaBullseye />}\n onClick={copyToClipboard}\n size=\"sm\"\n variant=\"light\"\n />\n );\n};\nexport default FieldCopyTestIdButton;\n","import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport type { FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton';\n\nexport default FieldCopyTestIdButton;\n"],"mappings":";;;;;AAYA,MAAM,yBAAyB,EAC7B,YAAY,KAAA,GACZ,aACgC;CAChC,MAAM,wBAAwB;EAI5B,UAAU,UAAU,UAAU,MAAM,CAAC,CAAC,OAAO,QAAQ;GACnD,QAAQ,MAAM,qCAAqC,GAAG;EACxD,CAAC;CACH;CAEA,OACE,oBAAC,QAAD;EACE,WAAW,GAAG,WAAW,qBAAqB;EAC9C,MAAM,oBAAC,YAAD,CAAa,CAAA;EACnB,SAAS;EACT,MAAK;EACL,SAAQ;CACT,CAAA;AAEL;;AC9BA,IAAA,gCAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { slugify } from "@fuf-stack/pixel-utils";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { AnimatePresence, motion, useReducedMotion } from "@fuf-stack/pixel-motion";
|
|
4
|
-
|
|
4
|
+
// src/partials/FieldValidationError/FieldValidationError.tsx
|
|
5
5
|
/**
|
|
6
6
|
* Renders a validation error of a field
|
|
7
7
|
*/
|
|
@@ -41,10 +41,8 @@ const FieldValidationError = ({ className = void 0, error = void 0, testId }) =>
|
|
|
41
41
|
})
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
//#region src/partials/FieldValidationError/index.ts
|
|
44
|
+
// src/partials/FieldValidationError/index.ts
|
|
46
45
|
var FieldValidationError_default = FieldValidationError;
|
|
47
|
-
//#endregion
|
|
48
46
|
export { FieldValidationError as n, FieldValidationError_default as t };
|
|
49
47
|
|
|
50
|
-
//# sourceMappingURL=FieldValidationError-
|
|
48
|
+
//# sourceMappingURL=FieldValidationError-BcUV0r1I.mjs.map
|
package/dist/{FieldValidationError-ByRoIxaM.mjs.map → FieldValidationError-BcUV0r1I.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldValidationError-
|
|
1
|
+
{"version":3,"file":"FieldValidationError-BcUV0r1I.mjs","names":[],"sources":["../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { slugify } from '@fuf-stack/pixel-utils';\n\nexport interface FieldValidationErrorProps {\n /** CSS class name */\n className?: string;\n /** Field errors */\n error?: FieldError[];\n /** HTML data-testid attribute used in e2e tests */\n testId: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n className = undefined,\n error = undefined,\n testId,\n}: FieldValidationErrorProps) => {\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n return (\n <ul\n aria-label={`Validation errors of field ${testId}`}\n className={className}\n data-testid={slugify(`${testId}_error`)}\n >\n <AnimatePresence initial={!disableAnimation}>\n {error?.map(({ message }, i) => {\n return (\n <motion.li\n key={slugify(`${testId}_error_${i}`)}\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.2, ease: 'circOut' }}\n >\n {/* wrap in div to apply padding and animation does not jump */}\n <div className=\"px-1 pt-1\">{message}</div>\n </motion.li>\n );\n })}\n </AnimatePresence>\n </ul>\n );\n};\n\nexport default FieldValidationError;\n","import FieldValidationError from './FieldValidationError';\n\nexport type { FieldValidationErrorProps } from './FieldValidationError';\n\nexport default FieldValidationError;\n"],"mappings":";;;;;;;AAqBA,MAAM,wBAAwB,EAC5B,YAAY,KAAA,GACZ,QAAQ,KAAA,GACR,aAC+B;CAE/B,MAAM,mBAAmB,iBAAiB;CAE1C,OACE,oBAAC,MAAD;EACE,cAAY,8BAA8B;EAC/B;EACX,eAAa,QAAQ,GAAG,OAAO,OAAO;EAEtC,UAAA,oBAAC,iBAAD;GAAiB,SAAS,CAAC;GACxB,UAAA,OAAO,KAAK,EAAE,WAAW,MAAM;IAC9B,OACE,oBAAC,OAAO,IAAR;KAEE,SACE,mBAAmB,KAAA,IAAY;MAAE,SAAS;MAAG,QAAQ;KAAO;KAE9D,MAAM,mBAAmB,KAAA,IAAY;MAAE,SAAS;MAAG,QAAQ;KAAE;KAC7D,SAAS,mBAAmB,QAAQ;MAAE,QAAQ;MAAG,SAAS;KAAE;KAC5D,OAAO,EAAE,UAAU,SAAS;KAC5B,YAAY;MAAE,UAAU;MAAK,MAAM;KAAU;KAG7C,UAAA,oBAAC,OAAD;MAAK,WAAU;MAAa,UAAA;KAAa,CAAA;IAChC,GAXJ,QAAQ,GAAG,OAAO,SAAS,GAAG,CAW1B;GAEf,CAAC;EACc,CAAA;CACf,CAAA;AAER;;ACpDA,IAAA,+BAAe"}
|
package/dist/Form/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as DebugModeSettings } from "../FormContext-
|
|
1
|
+
import { t as DebugModeSettings } from "../FormContext-BnNJYZOo.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";
|
|
5
5
|
import { VetoInstance } from "@fuf-stack/veto";
|
|
6
|
-
//#region src/Form/Form.d.ts
|
|
7
6
|
export declare const formVariants: ((props?: ({
|
|
8
7
|
[x: string]: string | number | undefined;
|
|
9
8
|
[x: number]: string | number | undefined;
|
|
@@ -1024,6 +1023,5 @@ interface FormProps extends VariantProps {
|
|
|
1024
1023
|
* Form component that has to wrap every uniform
|
|
1025
1024
|
*/
|
|
1026
1025
|
declare const Form: ({ children, className, debug, initialValues, name, onSubmit, remoteFormId, testId, validation, validationTrigger }: FormProps) => import("react").JSX.Element;
|
|
1027
|
-
//#endregion
|
|
1028
1026
|
export { type FormProps, Form as default };
|
|
1029
1027
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmBpB,eAAe,eAAe;KAC9B,YAAY,mBAAmB;UAEnB,kBAAkB;;EAEjC,UAAU,YAAY;;EAEtB,YAAY;;EAEZ,QAAQ;;EAER,gBAAgB;;EAEhB;;EAEA,UAAU,cAAc;;;;EAIxB;;EAEA;;EAEA,aAAa;;EAEb;;;;;cAMI,SAAQ,UAAA,WAAA,OAAA,eAAA,MAAA,UAAA,cAAA,QAAA,YAAA,qBAWX,8BAAS,IAAA"}
|
package/dist/Form/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as FormProvider } from "../FormContext-
|
|
2
|
-
import { n as useFormContext } from "../useFormContext-
|
|
1
|
+
import { i as useSensitiveDebug, r as redactDebugData, t as FormProvider } from "../FormContext-B8G_Xxd6.mjs";
|
|
2
|
+
import { n as useFormContext } from "../useFormContext-BEjPBdzb.mjs";
|
|
3
3
|
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
-
import { FaBug, FaBullseye } from "react-icons/fa6";
|
|
6
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { FaBug, FaBullseye } from "react-icons/fa6";
|
|
7
7
|
import { FaTimes } from "react-icons/fa";
|
|
8
8
|
import { Button } from "@fuf-stack/pixels/Button";
|
|
9
9
|
import { Card } from "@fuf-stack/pixels/Card";
|
|
10
10
|
import { Json } from "@fuf-stack/pixels/Json";
|
|
11
|
-
|
|
11
|
+
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
12
12
|
const formDebugViewerVariants = tv({ slots: {
|
|
13
13
|
/** class of the debug card */
|
|
14
14
|
base: "",
|
|
@@ -24,6 +24,7 @@ const formDebugViewerVariants = tv({ slots: {
|
|
|
24
24
|
/** Renders a form debug panel with information about the current form state */
|
|
25
25
|
const FormDebugViewer = ({ className = void 0 }) => {
|
|
26
26
|
const { debugMode, formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful }, getValues, setDebugMode, validation: { errors }, subscribe } = useFormContext();
|
|
27
|
+
const { paths: sensitivePaths, ready: sensitiveFieldsReady } = useSensitiveDebug();
|
|
27
28
|
const showDebugButton = debugMode === "off";
|
|
28
29
|
const showDebugCard = debugMode === "debug" || debugMode === "debug-testids";
|
|
29
30
|
const showDebugTestIds = debugMode === "debug-testids";
|
|
@@ -59,7 +60,7 @@ const FormDebugViewer = ({ className = void 0 }) => {
|
|
|
59
60
|
onClick: handleShowDebugMode,
|
|
60
61
|
variant: "light"
|
|
61
62
|
});
|
|
62
|
-
if (!showDebugCard) return null;
|
|
63
|
+
if (!showDebugCard || !sensitiveFieldsReady) return null;
|
|
63
64
|
return /* @__PURE__ */ jsxs(Card, {
|
|
64
65
|
className: cardClassNames,
|
|
65
66
|
header: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -85,8 +86,8 @@ const FormDebugViewer = ({ className = void 0 }) => {
|
|
|
85
86
|
}), /* @__PURE__ */ jsx(Json, {
|
|
86
87
|
className: classNames.json,
|
|
87
88
|
value: {
|
|
88
|
-
values,
|
|
89
|
-
errors: errors ?? null,
|
|
89
|
+
values: redactDebugData(values, sensitivePaths),
|
|
90
|
+
errors: redactDebugData(errors ?? null, sensitivePaths),
|
|
90
91
|
submit: {
|
|
91
92
|
isValid,
|
|
92
93
|
isSubmitting,
|
|
@@ -97,8 +98,7 @@ const FormDebugViewer = ({ className = void 0 }) => {
|
|
|
97
98
|
})]
|
|
98
99
|
});
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
-
//#region src/Form/Form.tsx
|
|
101
|
+
// src/Form/Form.tsx
|
|
102
102
|
const IS_TEST = process.env.NODE_ENV === "test";
|
|
103
103
|
const formVariants = tv({ slots: {
|
|
104
104
|
/** class of the wrapper around form and debug viewer */
|
|
@@ -152,10 +152,8 @@ const Form = ({ children, className = void 0, debug = void 0, initialValues = vo
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
-
|
|
156
|
-
//#region src/Form/index.ts
|
|
155
|
+
// src/Form/index.ts
|
|
157
156
|
var Form_default = Form;
|
|
158
|
-
//#endregion
|
|
159
157
|
export { Form_default as default, formVariants };
|
|
160
158
|
|
|
161
159
|
//# sourceMappingURL=index.mjs.map
|
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';\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 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) {\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,\n errors: errors ?? null,\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":";;;;;;;;;;;AAeA,MAAa,0BAA0B,GAAG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I;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 { 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":";;;;;;;;;;;AAgB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