@fuf-stack/uniform 0.0.2 → 0.0.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/dist/Form/index.cjs +45 -165
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.d.cts +26 -6
- package/dist/Form/index.d.ts +26 -6
- package/dist/Form/index.js +141 -7
- package/dist/Form/index.js.map +1 -1
- package/dist/Grid/index.cjs +7 -40
- package/dist/Grid/index.cjs.map +1 -1
- package/dist/Grid/index.d.cts +14 -4
- package/dist/Grid/index.d.ts +14 -4
- package/dist/Grid/index.js +11 -3
- package/dist/Grid/index.js.map +1 -1
- package/dist/SubmitButton/index.cjs +14 -129
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.d.cts +21 -5
- package/dist/SubmitButton/index.d.ts +21 -5
- package/dist/SubmitButton/index.js +36 -6
- package/dist/SubmitButton/index.js.map +1 -1
- package/dist/chunk-BBB4FEY6.cjs +22 -0
- package/dist/chunk-BBB4FEY6.cjs.map +1 -0
- package/dist/{chunk-PMNBGDEZ.js → chunk-BCMPSLSG.js} +21 -7
- package/dist/chunk-BCMPSLSG.js.map +1 -0
- package/dist/{chunk-WIY7KIHU.js → chunk-V46BHM2U.js} +4 -4
- package/dist/chunk-V46BHM2U.js.map +1 -0
- package/dist/chunk-WQRM7G4C.cjs +87 -0
- package/dist/chunk-WQRM7G4C.cjs.map +1 -0
- package/dist/helpers/index.cjs +7 -0
- package/dist/helpers/index.cjs.map +1 -0
- package/dist/helpers/index.d.cts +5 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.js +7 -0
- package/dist/hooks/index.cjs +4 -123
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +40 -4
- package/dist/hooks/index.d.ts +40 -4
- package/dist/hooks/index.js +2 -4
- package/dist/partials/FieldCopyTestIdButton/index.cjs +14 -47
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +6 -3
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +6 -3
- package/dist/partials/FieldCopyTestIdButton/index.js +29 -3
- package/dist/partials/FieldCopyTestIdButton/index.js.map +1 -1
- package/dist/partials/FieldValidationError/index.cjs +9 -56
- package/dist/partials/FieldValidationError/index.cjs.map +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +10 -4
- package/dist/partials/FieldValidationError/index.d.ts +10 -4
- package/dist/partials/FieldValidationError/index.js +35 -3
- package/dist/partials/FieldValidationError/index.js.map +1 -1
- package/package.json +35 -8
- package/dist/Form/Form.cjs +0 -269
- package/dist/Form/Form.cjs.map +0 -1
- package/dist/Form/Form.d.cts +0 -34
- package/dist/Form/Form.d.ts +0 -34
- package/dist/Form/Form.js +0 -14
- package/dist/Form/subcomponents/FormContext.cjs +0 -53
- package/dist/Form/subcomponents/FormContext.cjs.map +0 -1
- package/dist/Form/subcomponents/FormContext.d.cts +0 -20
- package/dist/Form/subcomponents/FormContext.d.ts +0 -20
- package/dist/Form/subcomponents/FormContext.js +0 -9
- package/dist/Form/subcomponents/FormContext.js.map +0 -1
- package/dist/Form/subcomponents/FormDebugViewer.cjs +0 -197
- package/dist/Form/subcomponents/FormDebugViewer.cjs.map +0 -1
- package/dist/Form/subcomponents/FormDebugViewer.d.cts +0 -10
- package/dist/Form/subcomponents/FormDebugViewer.d.ts +0 -10
- package/dist/Form/subcomponents/FormDebugViewer.js +0 -11
- package/dist/Form/subcomponents/FormDebugViewer.js.map +0 -1
- package/dist/Grid/Grid.cjs +0 -46
- package/dist/Grid/Grid.cjs.map +0 -1
- package/dist/Grid/Grid.d.cts +0 -17
- package/dist/Grid/Grid.d.ts +0 -17
- package/dist/Grid/Grid.js +0 -7
- package/dist/Grid/Grid.js.map +0 -1
- package/dist/SubmitButton/SubmitButton.cjs +0 -154
- package/dist/SubmitButton/SubmitButton.cjs.map +0 -1
- package/dist/SubmitButton/SubmitButton.d.cts +0 -24
- package/dist/SubmitButton/SubmitButton.d.ts +0 -24
- package/dist/SubmitButton/SubmitButton.js +0 -11
- package/dist/SubmitButton/SubmitButton.js.map +0 -1
- package/dist/chunk-AV26PIKH.js +0 -82
- package/dist/chunk-AV26PIKH.js.map +0 -1
- package/dist/chunk-BJ36HK7L.js +0 -42
- package/dist/chunk-BJ36HK7L.js.map +0 -1
- package/dist/chunk-EDUZKOTL.js +0 -41
- package/dist/chunk-EDUZKOTL.js.map +0 -1
- package/dist/chunk-GATZOHQ6.js +0 -1
- package/dist/chunk-GATZOHQ6.js.map +0 -1
- package/dist/chunk-IQVKBQ7W.js +0 -19
- package/dist/chunk-IQVKBQ7W.js.map +0 -1
- package/dist/chunk-KY2KCXOO.js +0 -16
- package/dist/chunk-KY2KCXOO.js.map +0 -1
- package/dist/chunk-PMNBGDEZ.js.map +0 -1
- package/dist/chunk-UMTFPEVF.js +0 -34
- package/dist/chunk-UMTFPEVF.js.map +0 -1
- package/dist/chunk-WIY7KIHU.js.map +0 -1
- package/dist/chunk-X4VXTRJB.js +0 -74
- package/dist/chunk-X4VXTRJB.js.map +0 -1
- package/dist/helpers/slugify.cjs +0 -52
- package/dist/helpers/slugify.cjs.map +0 -1
- package/dist/helpers/slugify.d.cts +0 -5
- package/dist/helpers/slugify.d.ts +0 -5
- package/dist/helpers/slugify.js +0 -7
- package/dist/helpers/slugify.js.map +0 -1
- package/dist/hooks/useFormContext/useFormContext.cjs +0 -127
- package/dist/hooks/useFormContext/useFormContext.cjs.map +0 -1
- package/dist/hooks/useFormContext/useFormContext.d.cts +0 -40
- package/dist/hooks/useFormContext/useFormContext.d.ts +0 -40
- package/dist/hooks/useFormContext/useFormContext.js +0 -11
- package/dist/hooks/useFormContext/useFormContext.js.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs +0 -64
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.cts +0 -9
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.ts +0 -9
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js +0 -7
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js.map +0 -1
- package/dist/partials/FieldValidationError/FieldValidationError.cjs +0 -87
- package/dist/partials/FieldValidationError/FieldValidationError.cjs.map +0 -1
- package/dist/partials/FieldValidationError/FieldValidationError.d.cts +0 -13
- package/dist/partials/FieldValidationError/FieldValidationError.d.ts +0 -13
- package/dist/partials/FieldValidationError/FieldValidationError.js +0 -8
- package/dist/partials/FieldValidationError/FieldValidationError.js.map +0 -1
- /package/dist/{Form/Form.js.map → helpers/index.js.map} +0 -0
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Form/subcomponents/FormContext.tsx
|
|
31
|
-
var FormContext_exports = {};
|
|
32
|
-
__export(FormContext_exports, {
|
|
33
|
-
ValidationSchemaContext: () => ValidationSchemaContext,
|
|
34
|
-
default: () => FormContext_default
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(FormContext_exports);
|
|
37
|
-
var import_react = __toESM(require("react"), 1);
|
|
38
|
-
var import_react_hook_form = require("react-hook-form");
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
41
|
-
var FormProvider = ({
|
|
42
|
-
children,
|
|
43
|
-
validation = void 0,
|
|
44
|
-
...hookFormProps
|
|
45
|
-
}) => {
|
|
46
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_hook_form.FormProvider, { ...hookFormProps, children }) });
|
|
47
|
-
};
|
|
48
|
-
var FormContext_default = FormProvider;
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
ValidationSchemaContext
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=FormContext.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["import type { VetoInstance } from '@fuf-stack/veto';\nimport type { FormProviderProps as HookFormProviderProps } from 'react-hook-form';\n\nimport React from 'react';\nimport { FormProvider as HookFormProvider } from 'react-hook-form';\n\nexport const ValidationSchemaContext = React.createContext<\n VetoInstance | undefined\n>(undefined);\n\ninterface FormProviderProps\n extends HookFormProviderProps<Record<string, any>, any, undefined> {\n /** veto validation schema */\n validation?: VetoInstance;\n}\n\n/** Provides the veto validation context to the form */\nconst FormProvider = ({\n children,\n validation = undefined,\n ...hookFormProps\n}: FormProviderProps) => {\n return (\n <ValidationSchemaContext.Provider value={validation}>\n <HookFormProvider {...hookFormProps}>{children}</HookFormProvider>\n </ValidationSchemaContext.Provider>\n );\n};\n\nexport default FormProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAkB;AAClB,6BAAiD;AAoB3C;AAlBC,IAAM,0BAA0B,aAAAA,QAAM,cAE3C,MAAS;AASX,IAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,MAAyB;AACvB,SACE,4CAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACvC,sDAAC,uBAAAC,cAAA,EAAkB,GAAG,eAAgB,UAAS,GACjD;AAEJ;AAEA,IAAO,sBAAQ;","names":["React","HookFormProvider"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as _fuf_stack_veto from '@fuf-stack/veto';
|
|
3
|
-
import { VetoInstance } from '@fuf-stack/veto';
|
|
4
|
-
import * as zod from 'zod';
|
|
5
|
-
import { FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
declare const ValidationSchemaContext: React.Context<{
|
|
9
|
-
schema: zod.ZodTypeAny;
|
|
10
|
-
validate: <InputType extends _fuf_stack_veto.VetoInput>(input: InputType) => _fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>;
|
|
11
|
-
validateAsync: <InputType_1 extends _fuf_stack_veto.VetoInput>(input: InputType_1) => Promise<_fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>>;
|
|
12
|
-
} | undefined>;
|
|
13
|
-
interface FormProviderProps extends FormProviderProps$1<Record<string, any>, any, undefined> {
|
|
14
|
-
/** veto validation schema */
|
|
15
|
-
validation?: VetoInstance;
|
|
16
|
-
}
|
|
17
|
-
/** Provides the veto validation context to the form */
|
|
18
|
-
declare const FormProvider: ({ children, validation, ...hookFormProps }: FormProviderProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
-
|
|
20
|
-
export { ValidationSchemaContext, FormProvider as default };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as _fuf_stack_veto from '@fuf-stack/veto';
|
|
3
|
-
import { VetoInstance } from '@fuf-stack/veto';
|
|
4
|
-
import * as zod from 'zod';
|
|
5
|
-
import { FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
declare const ValidationSchemaContext: React.Context<{
|
|
9
|
-
schema: zod.ZodTypeAny;
|
|
10
|
-
validate: <InputType extends _fuf_stack_veto.VetoInput>(input: InputType) => _fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>;
|
|
11
|
-
validateAsync: <InputType_1 extends _fuf_stack_veto.VetoInput>(input: InputType_1) => Promise<_fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>>;
|
|
12
|
-
} | undefined>;
|
|
13
|
-
interface FormProviderProps extends FormProviderProps$1<Record<string, any>, any, undefined> {
|
|
14
|
-
/** veto validation schema */
|
|
15
|
-
validation?: VetoInstance;
|
|
16
|
-
}
|
|
17
|
-
/** Provides the veto validation context to the form */
|
|
18
|
-
declare const FormProvider: ({ children, validation, ...hookFormProps }: FormProviderProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
-
|
|
20
|
-
export { ValidationSchemaContext, FormProvider as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
31
|
-
var FormDebugViewer_exports = {};
|
|
32
|
-
__export(FormDebugViewer_exports, {
|
|
33
|
-
default: () => FormDebugViewer_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(FormDebugViewer_exports);
|
|
36
|
-
var import_react3 = require("react");
|
|
37
|
-
var import_fa = require("react-icons/fa");
|
|
38
|
-
var import_fa6 = require("react-icons/fa6");
|
|
39
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
40
|
-
var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
|
|
41
|
-
var import_Card = __toESM(require("@fuf-stack/pixels/Card"), 1);
|
|
42
|
-
var import_useLocalStorage = __toESM(require("@fuf-stack/pixels/hooks/useLocalStorage"), 1);
|
|
43
|
-
var import_Json = __toESM(require("@fuf-stack/pixels/Json"), 1);
|
|
44
|
-
|
|
45
|
-
// src/hooks/useFormContext/useFormContext.ts
|
|
46
|
-
var import_react2 = require("react");
|
|
47
|
-
var import_react_hook_form2 = require("react-hook-form");
|
|
48
|
-
|
|
49
|
-
// src/Form/subcomponents/FormContext.tsx
|
|
50
|
-
var import_react = __toESM(require("react"), 1);
|
|
51
|
-
var import_react_hook_form = require("react-hook-form");
|
|
52
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
|
-
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
54
|
-
|
|
55
|
-
// src/helpers/slugify.ts
|
|
56
|
-
var import_slug = __toESM(require("slug"), 1);
|
|
57
|
-
var slugify_default = (string, options) => {
|
|
58
|
-
const replacement = options?.replacement || "_";
|
|
59
|
-
return (0, import_slug.default)(string, {
|
|
60
|
-
...import_slug.default.defaults.modes.rfc3986,
|
|
61
|
-
charmap: {
|
|
62
|
-
...import_slug.default.defaults.modes.rfc3986.charmap,
|
|
63
|
-
// allow dots by default
|
|
64
|
-
".": ".",
|
|
65
|
-
// convert hyphens to underscores (when replacement is not hyphen)
|
|
66
|
-
...replacement !== "-" ? { "-": "_" } : {}
|
|
67
|
-
},
|
|
68
|
-
replacement,
|
|
69
|
-
...options || {}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// src/hooks/useFormContext/useFormContext.ts
|
|
74
|
-
var recursiveSearchInnerType = (schema) => {
|
|
75
|
-
if (schema?._def?.innerType) {
|
|
76
|
-
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
77
|
-
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
78
|
-
}
|
|
79
|
-
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
80
|
-
}
|
|
81
|
-
return true;
|
|
82
|
-
};
|
|
83
|
-
var recursiveFieldKeySearch = (schema, path) => {
|
|
84
|
-
const [current, ...rest] = path;
|
|
85
|
-
let currentSchema = schema;
|
|
86
|
-
if (schema?._def?.typeName === "ZodOptional") {
|
|
87
|
-
currentSchema = schema.unwrap();
|
|
88
|
-
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
89
|
-
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
90
|
-
}
|
|
91
|
-
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
92
|
-
return (currentSchema._def.left?.schema ? recursiveFieldKeySearch(currentSchema._def.left.schema, path) : recursiveFieldKeySearch(currentSchema._def.left, path)) || (currentSchema._def.right?.schema ? recursiveFieldKeySearch(currentSchema._def.right.schema, path) : recursiveFieldKeySearch(currentSchema._def.right, path));
|
|
93
|
-
}
|
|
94
|
-
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
95
|
-
if (shape && shape[current]) {
|
|
96
|
-
if (rest.length === 0) {
|
|
97
|
-
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
98
|
-
}
|
|
99
|
-
return recursiveFieldKeySearch(shape[current], rest);
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
};
|
|
103
|
-
var useFormContext = () => {
|
|
104
|
-
const {
|
|
105
|
-
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
106
|
-
// for getFieldState a subscription to formState properties is needed!
|
|
107
|
-
formState,
|
|
108
|
-
getFieldState: getFieldStateOrig,
|
|
109
|
-
...otherMethods
|
|
110
|
-
} = (0, import_react_hook_form2.useFormContext)();
|
|
111
|
-
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
112
|
-
const getFieldState = (name, testId) => {
|
|
113
|
-
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
114
|
-
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
115
|
-
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
116
|
-
return {
|
|
117
|
-
...rest,
|
|
118
|
-
error,
|
|
119
|
-
// TODO: change to correct type @Hannes ;)
|
|
120
|
-
required,
|
|
121
|
-
testId: slugify_default(testId || name)
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
return {
|
|
125
|
-
...otherMethods,
|
|
126
|
-
getFieldState,
|
|
127
|
-
validation,
|
|
128
|
-
formState
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
133
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
134
|
-
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
135
|
-
var FormDebugViewer = ({ className = void 0 }) => {
|
|
136
|
-
const {
|
|
137
|
-
watch,
|
|
138
|
-
formState: { dirtyFields, isValid, isSubmitting },
|
|
139
|
-
validation
|
|
140
|
-
} = useFormContext();
|
|
141
|
-
const [debug, setDebug] = (0, import_useLocalStorage.default)(LOCALSTORAGE_DEBUG_KEY, false);
|
|
142
|
-
const [validationErrors, setValidationErrors] = (0, import_react3.useState)(null);
|
|
143
|
-
const formValues = watch();
|
|
144
|
-
(0, import_react3.useEffect)(() => {
|
|
145
|
-
const updateValidationErrors = async () => {
|
|
146
|
-
if (validation) {
|
|
147
|
-
const validateResult = await validation?.validateAsync(formValues);
|
|
148
|
-
setValidationErrors(validateResult?.errors);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
updateValidationErrors();
|
|
152
|
-
}, [JSON.stringify(formValues)]);
|
|
153
|
-
if (!debug) {
|
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
155
|
-
import_Button.default,
|
|
156
|
-
{
|
|
157
|
-
ariaLabel: "Enable form debug mode",
|
|
158
|
-
onClick: () => setDebug(!debug),
|
|
159
|
-
className: "absolute bottom-2.5 right-2.5 w-5 text-default-400",
|
|
160
|
-
variant: "light",
|
|
161
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa6.FaBug, {})
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
166
|
-
import_Card.default,
|
|
167
|
-
{
|
|
168
|
-
className: (0, import_classnames.default)(className),
|
|
169
|
-
header: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex w-full flex-row justify-between", children: [
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-lg", children: "Debug Mode" }),
|
|
171
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
172
|
-
import_Button.default,
|
|
173
|
-
{
|
|
174
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa.FaTimes, { className: "text-danger" }),
|
|
175
|
-
onClick: () => setDebug(false),
|
|
176
|
-
size: "sm",
|
|
177
|
-
variant: "flat"
|
|
178
|
-
}
|
|
179
|
-
)
|
|
180
|
-
] }),
|
|
181
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
182
|
-
import_Json.default,
|
|
183
|
-
{
|
|
184
|
-
value: {
|
|
185
|
-
values: formValues,
|
|
186
|
-
errors: validationErrors,
|
|
187
|
-
dirtyFields,
|
|
188
|
-
isValid,
|
|
189
|
-
isSubmitting
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
var FormDebugViewer_default = FormDebugViewer;
|
|
197
|
-
//# sourceMappingURL=FormDebugViewer.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Form/subcomponents/FormDebugViewer.tsx","../../../src/hooks/useFormContext/useFormContext.ts","../../../src/Form/subcomponents/FormContext.tsx","../../../src/helpers/slugify.ts"],"sourcesContent":["import type { VetoError } from '@fuf-stack/veto';\n\nimport { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport Card from '@fuf-stack/pixels/Card';\nimport useLocalStorage from '@fuf-stack/pixels/hooks/useLocalStorage';\nimport Json from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n watch,\n formState: { dirtyFields, isValid, isSubmitting },\n validation,\n } = useFormContext();\n\n const [debug, setDebug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const [validationErrors, setValidationErrors] = useState<\n VetoError['errors'] | null\n >(null);\n\n const formValues = watch();\n\n useEffect(() => {\n const updateValidationErrors = async () => {\n if (validation) {\n const validateResult = await validation?.validateAsync(formValues);\n setValidationErrors(validateResult?.errors);\n }\n };\n updateValidationErrors();\n }, [JSON.stringify(formValues)]);\n\n if (!debug) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n onClick={() => setDebug(!debug)}\n className=\"absolute bottom-2.5 right-2.5 w-5 text-default-400\"\n variant=\"light\"\n icon={<FaBug />}\n />\n );\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n icon={<FaTimes className=\"text-danger\" />}\n onClick={() => setDebug(false)}\n size=\"sm\"\n variant=\"flat\"\n />\n </div>\n }\n >\n <Json\n value={{\n values: formValues,\n errors: validationErrors,\n dirtyFields,\n isValid,\n isSubmitting,\n }}\n />\n </Card>\n );\n};\nexport default FormDebugViewer;\n","import type { VetoSchema } from '@fuf-stack/veto';\nimport type { FieldError } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { ValidationSchemaContext } from '../../Form/subcomponents/FormContext';\nimport slugify from '../../helpers/slugify';\n\n// FIX: This fixes the problem that the innerType is not checked for optionals...\nconst recursiveSearchInnerType = (schema: VetoSchema): boolean => {\n if (schema?._def?.innerType) {\n if (schema?._def?.innerType?._def?.typeName === 'ZodOptional') {\n return schema?._def?.innerType?._def?.typeName !== 'ZodOptional';\n }\n return recursiveSearchInnerType(schema?._def?.innerType);\n }\n return true;\n};\n\n// TODO: Fix problem \".optional().nullable()\" is required, \".nullable().optional()\" is not required...\nexport const recursiveFieldKeySearch = (\n schema: VetoSchema,\n path: string[],\n): boolean | null => {\n const [current, ...rest] = path;\n // ignore optionals on the path to the desired field\n\n let currentSchema = schema;\n\n if (schema?._def?.typeName === 'ZodOptional') {\n // @ts-expect-error not sure here\n currentSchema = schema.unwrap();\n } else if (schema?._def?.typeName === 'ZodEffects') {\n // in case of an effect, unwrap the effect and call with schema (clould be optional) and complete path.\n return recursiveFieldKeySearch(schema._def?.schema, path);\n }\n\n // TODO: This needs further investigation. It is nor yet completely clear how to handle intersections!\n if (currentSchema?._def?.typeName === 'ZodIntersection') {\n return (\n (currentSchema._def.left?.schema\n ? recursiveFieldKeySearch(currentSchema._def.left.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.left, path)) ||\n (currentSchema._def.right?.schema\n ? recursiveFieldKeySearch(currentSchema._def.right.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.right, path))\n );\n }\n\n // get shape of an object or objects of an array\n // @ts-expect-error not sure here\n const shape = currentSchema?.shape ?? currentSchema?.element?.shape; // ??\n\n if (shape && shape[current]) {\n // currentSchema?._def.schema.unwrap()?.shape;\n if (rest.length === 0) {\n // At the end of the path check if the field is optional or required\n return (\n shape[current]?._def?.typeName !== 'ZodOptional' &&\n recursiveSearchInnerType(shape[current])\n );\n }\n return recursiveFieldKeySearch(shape[current], rest);\n }\n\n return null; // field not found\n};\n\n/** TODO: add description */\nexport const useFormContext = () => {\n const {\n // https://react-hook-form.com/docs/useform/getfieldstate\n // for getFieldState a subscription to formState properties is needed!\n formState,\n getFieldState: getFieldStateOrig,\n ...otherMethods\n } = useHookFormContext();\n const validation = useContext(ValidationSchemaContext);\n\n // update getFieldState\n const getFieldState = (name: string, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n const required =\n (validation && recursiveFieldKeySearch(validation.schema, fieldPath)) ||\n false;\n const { error, ...rest } = getFieldStateOrig(name, formState);\n return {\n ...rest,\n error: error as FieldError[] | undefined, // TODO: change to correct type @Hannes ;)\n required,\n testId: slugify(testId || name),\n };\n };\n\n return {\n ...otherMethods,\n getFieldState,\n validation,\n formState,\n };\n};\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { FormProviderProps as HookFormProviderProps } from 'react-hook-form';\n\nimport React from 'react';\nimport { FormProvider as HookFormProvider } from 'react-hook-form';\n\nexport const ValidationSchemaContext = React.createContext<\n VetoInstance | undefined\n>(undefined);\n\ninterface FormProviderProps\n extends HookFormProviderProps<Record<string, any>, any, undefined> {\n /** veto validation schema */\n validation?: VetoInstance;\n}\n\n/** Provides the veto validation context to the form */\nconst FormProvider = ({\n children,\n validation = undefined,\n ...hookFormProps\n}: FormProviderProps) => {\n return (\n <ValidationSchemaContext.Provider value={validation}>\n <HookFormProvider {...hookFormProps}>{children}</HookFormProvider>\n </ValidationSchemaContext.Provider>\n );\n};\n\nexport default FormProvider;\n","import type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\nexport default (string: string, options?: SlugOptions) => {\n const replacement = options?.replacement || '_';\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // allow dots by default\n '.': '.',\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"],"mappings":"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","names":["import_react","import_react","import_react_hook_form","React","slug","useHookFormContext","import_jsx_runtime","useLocalStorage","Button","Card","cn","Json"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
interface FormDebugViewerProps {
|
|
4
|
-
/** CSS class name */
|
|
5
|
-
className?: string;
|
|
6
|
-
}
|
|
7
|
-
/** Renders a form debug panel with information about the current form state */
|
|
8
|
-
declare const FormDebugViewer: ({ className }: FormDebugViewerProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
-
|
|
10
|
-
export { FormDebugViewer as default };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
interface FormDebugViewerProps {
|
|
4
|
-
/** CSS class name */
|
|
5
|
-
className?: string;
|
|
6
|
-
}
|
|
7
|
-
/** Renders a form debug panel with information about the current form state */
|
|
8
|
-
declare const FormDebugViewer: ({ className }: FormDebugViewerProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
-
|
|
10
|
-
export { FormDebugViewer as default };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FormDebugViewer_default
|
|
3
|
-
} from "../../chunk-AV26PIKH.js";
|
|
4
|
-
import "../../chunk-GATZOHQ6.js";
|
|
5
|
-
import "../../chunk-PMNBGDEZ.js";
|
|
6
|
-
import "../../chunk-IQVKBQ7W.js";
|
|
7
|
-
import "../../chunk-WIY7KIHU.js";
|
|
8
|
-
export {
|
|
9
|
-
FormDebugViewer_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=FormDebugViewer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/Grid/Grid.cjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Grid/Grid.tsx
|
|
31
|
-
var Grid_exports = {};
|
|
32
|
-
__export(Grid_exports, {
|
|
33
|
-
default: () => Grid_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(Grid_exports);
|
|
36
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
37
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
-
var Grid = ({
|
|
39
|
-
children = null,
|
|
40
|
-
className = void 0,
|
|
41
|
-
testId = void 0
|
|
42
|
-
}) => {
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_classnames.default)("grid gap-6", className), "data-testid": testId, children });
|
|
44
|
-
};
|
|
45
|
-
var Grid_default = Grid;
|
|
46
|
-
//# sourceMappingURL=Grid.cjs.map
|
package/dist/Grid/Grid.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Grid/Grid.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\ninterface GridProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Defines the default grid for form components\n */\nconst Grid = ({\n children = null,\n className = undefined,\n testId = undefined,\n}: GridProps) => {\n return (\n <div className={cn('grid gap-6', className)} data-testid={testId}>\n {children}\n </div>\n );\n};\n\nexport default Grid;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAAe;AAoBX;AANJ,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AACX,MAAiB;AACf,SACE,4CAAC,SAAI,eAAW,kBAAAA,SAAG,cAAc,SAAS,GAAG,eAAa,QACvD,UACH;AAEJ;AAEA,IAAO,eAAQ;","names":["cn"]}
|
package/dist/Grid/Grid.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
interface GridProps {
|
|
5
|
-
/** child components */
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
/** CSS class name */
|
|
8
|
-
className?: string;
|
|
9
|
-
/** HTML data-testid attribute used in e2e tests */
|
|
10
|
-
testId?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Defines the default grid for form components
|
|
14
|
-
*/
|
|
15
|
-
declare const Grid: ({ children, className, testId, }: GridProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
-
|
|
17
|
-
export { Grid as default };
|
package/dist/Grid/Grid.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
interface GridProps {
|
|
5
|
-
/** child components */
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
/** CSS class name */
|
|
8
|
-
className?: string;
|
|
9
|
-
/** HTML data-testid attribute used in e2e tests */
|
|
10
|
-
testId?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Defines the default grid for form components
|
|
14
|
-
*/
|
|
15
|
-
declare const Grid: ({ children, className, testId, }: GridProps) => react_jsx_runtime.JSX.Element;
|
|
16
|
-
|
|
17
|
-
export { Grid as default };
|
package/dist/Grid/Grid.js
DELETED
package/dist/Grid/Grid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/SubmitButton/SubmitButton.tsx
|
|
31
|
-
var SubmitButton_exports = {};
|
|
32
|
-
__export(SubmitButton_exports, {
|
|
33
|
-
default: () => SubmitButton_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(SubmitButton_exports);
|
|
36
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
37
|
-
var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
|
|
38
|
-
|
|
39
|
-
// src/helpers/slugify.ts
|
|
40
|
-
var import_slug = __toESM(require("slug"), 1);
|
|
41
|
-
var slugify_default = (string, options) => {
|
|
42
|
-
const replacement = options?.replacement || "_";
|
|
43
|
-
return (0, import_slug.default)(string, {
|
|
44
|
-
...import_slug.default.defaults.modes.rfc3986,
|
|
45
|
-
charmap: {
|
|
46
|
-
...import_slug.default.defaults.modes.rfc3986.charmap,
|
|
47
|
-
// allow dots by default
|
|
48
|
-
".": ".",
|
|
49
|
-
// convert hyphens to underscores (when replacement is not hyphen)
|
|
50
|
-
...replacement !== "-" ? { "-": "_" } : {}
|
|
51
|
-
},
|
|
52
|
-
replacement,
|
|
53
|
-
...options || {}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/hooks/useFormContext/useFormContext.ts
|
|
58
|
-
var import_react2 = require("react");
|
|
59
|
-
var import_react_hook_form2 = require("react-hook-form");
|
|
60
|
-
|
|
61
|
-
// src/Form/subcomponents/FormContext.tsx
|
|
62
|
-
var import_react = __toESM(require("react"), 1);
|
|
63
|
-
var import_react_hook_form = require("react-hook-form");
|
|
64
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
-
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
66
|
-
|
|
67
|
-
// src/hooks/useFormContext/useFormContext.ts
|
|
68
|
-
var recursiveSearchInnerType = (schema) => {
|
|
69
|
-
if (schema?._def?.innerType) {
|
|
70
|
-
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
71
|
-
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
72
|
-
}
|
|
73
|
-
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
};
|
|
77
|
-
var recursiveFieldKeySearch = (schema, path) => {
|
|
78
|
-
const [current, ...rest] = path;
|
|
79
|
-
let currentSchema = schema;
|
|
80
|
-
if (schema?._def?.typeName === "ZodOptional") {
|
|
81
|
-
currentSchema = schema.unwrap();
|
|
82
|
-
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
83
|
-
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
84
|
-
}
|
|
85
|
-
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
86
|
-
return (currentSchema._def.left?.schema ? recursiveFieldKeySearch(currentSchema._def.left.schema, path) : recursiveFieldKeySearch(currentSchema._def.left, path)) || (currentSchema._def.right?.schema ? recursiveFieldKeySearch(currentSchema._def.right.schema, path) : recursiveFieldKeySearch(currentSchema._def.right, path));
|
|
87
|
-
}
|
|
88
|
-
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
89
|
-
if (shape && shape[current]) {
|
|
90
|
-
if (rest.length === 0) {
|
|
91
|
-
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
92
|
-
}
|
|
93
|
-
return recursiveFieldKeySearch(shape[current], rest);
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
};
|
|
97
|
-
var useFormContext = () => {
|
|
98
|
-
const {
|
|
99
|
-
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
100
|
-
// for getFieldState a subscription to formState properties is needed!
|
|
101
|
-
formState,
|
|
102
|
-
getFieldState: getFieldStateOrig,
|
|
103
|
-
...otherMethods
|
|
104
|
-
} = (0, import_react_hook_form2.useFormContext)();
|
|
105
|
-
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
106
|
-
const getFieldState = (name, testId) => {
|
|
107
|
-
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
108
|
-
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
109
|
-
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
110
|
-
return {
|
|
111
|
-
...rest,
|
|
112
|
-
error,
|
|
113
|
-
// TODO: change to correct type @Hannes ;)
|
|
114
|
-
required,
|
|
115
|
-
testId: slugify_default(testId || name)
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
...otherMethods,
|
|
120
|
-
getFieldState,
|
|
121
|
-
validation,
|
|
122
|
-
formState
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/SubmitButton/SubmitButton.tsx
|
|
127
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
128
|
-
var SubmitButton = ({
|
|
129
|
-
children = "Submit",
|
|
130
|
-
className = void 0,
|
|
131
|
-
color = "success",
|
|
132
|
-
loading = false,
|
|
133
|
-
onClick = void 0,
|
|
134
|
-
testId = "form_submit_button"
|
|
135
|
-
}) => {
|
|
136
|
-
const {
|
|
137
|
-
formState: { isValid, isSubmitting, isValidating }
|
|
138
|
-
} = useFormContext();
|
|
139
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
140
|
-
import_Button.default,
|
|
141
|
-
{
|
|
142
|
-
className: (0, import_classnames.default)(className),
|
|
143
|
-
color,
|
|
144
|
-
testId: slugify_default(testId),
|
|
145
|
-
disabled: !isValid || isSubmitting || isValidating,
|
|
146
|
-
loading,
|
|
147
|
-
onClick,
|
|
148
|
-
type: "submit",
|
|
149
|
-
children
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
var SubmitButton_default = SubmitButton;
|
|
154
|
-
//# sourceMappingURL=SubmitButton.cjs.map
|