@fuf-stack/uniform 0.0.2
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/LICENSE +21 -0
- package/dist/Form/Form.cjs +269 -0
- package/dist/Form/Form.cjs.map +1 -0
- package/dist/Form/Form.d.cts +34 -0
- package/dist/Form/Form.d.ts +34 -0
- package/dist/Form/Form.js +14 -0
- package/dist/Form/Form.js.map +1 -0
- package/dist/Form/index.cjs +269 -0
- package/dist/Form/index.cjs.map +1 -0
- package/dist/Form/index.d.cts +9 -0
- package/dist/Form/index.d.ts +9 -0
- package/dist/Form/index.js +15 -0
- package/dist/Form/index.js.map +1 -0
- package/dist/Form/subcomponents/FormContext.cjs +53 -0
- package/dist/Form/subcomponents/FormContext.cjs.map +1 -0
- package/dist/Form/subcomponents/FormContext.d.cts +20 -0
- package/dist/Form/subcomponents/FormContext.d.ts +20 -0
- package/dist/Form/subcomponents/FormContext.js +9 -0
- package/dist/Form/subcomponents/FormContext.js.map +1 -0
- package/dist/Form/subcomponents/FormDebugViewer.cjs +197 -0
- package/dist/Form/subcomponents/FormDebugViewer.cjs.map +1 -0
- package/dist/Form/subcomponents/FormDebugViewer.d.cts +10 -0
- package/dist/Form/subcomponents/FormDebugViewer.d.ts +10 -0
- package/dist/Form/subcomponents/FormDebugViewer.js +11 -0
- package/dist/Form/subcomponents/FormDebugViewer.js.map +1 -0
- package/dist/Grid/Grid.cjs +46 -0
- package/dist/Grid/Grid.cjs.map +1 -0
- package/dist/Grid/Grid.d.cts +17 -0
- package/dist/Grid/Grid.d.ts +17 -0
- package/dist/Grid/Grid.js +7 -0
- package/dist/Grid/Grid.js.map +1 -0
- package/dist/Grid/index.cjs +51 -0
- package/dist/Grid/index.cjs.map +1 -0
- package/dist/Grid/index.d.cts +7 -0
- package/dist/Grid/index.d.ts +7 -0
- package/dist/Grid/index.js +10 -0
- package/dist/Grid/index.js.map +1 -0
- package/dist/SubmitButton/SubmitButton.cjs +154 -0
- package/dist/SubmitButton/SubmitButton.cjs.map +1 -0
- package/dist/SubmitButton/SubmitButton.d.cts +24 -0
- package/dist/SubmitButton/SubmitButton.d.ts +24 -0
- package/dist/SubmitButton/SubmitButton.js +11 -0
- package/dist/SubmitButton/SubmitButton.js.map +1 -0
- package/dist/SubmitButton/index.cjs +159 -0
- package/dist/SubmitButton/index.cjs.map +1 -0
- package/dist/SubmitButton/index.d.cts +8 -0
- package/dist/SubmitButton/index.d.ts +8 -0
- package/dist/SubmitButton/index.js +14 -0
- package/dist/SubmitButton/index.js.map +1 -0
- package/dist/chunk-AV26PIKH.js +82 -0
- package/dist/chunk-AV26PIKH.js.map +1 -0
- package/dist/chunk-BJ36HK7L.js +42 -0
- package/dist/chunk-BJ36HK7L.js.map +1 -0
- package/dist/chunk-EDUZKOTL.js +41 -0
- package/dist/chunk-EDUZKOTL.js.map +1 -0
- package/dist/chunk-GATZOHQ6.js +1 -0
- package/dist/chunk-GATZOHQ6.js.map +1 -0
- package/dist/chunk-IQVKBQ7W.js +19 -0
- package/dist/chunk-IQVKBQ7W.js.map +1 -0
- package/dist/chunk-KY2KCXOO.js +16 -0
- package/dist/chunk-KY2KCXOO.js.map +1 -0
- package/dist/chunk-PMNBGDEZ.js +73 -0
- package/dist/chunk-PMNBGDEZ.js.map +1 -0
- package/dist/chunk-UMTFPEVF.js +34 -0
- package/dist/chunk-UMTFPEVF.js.map +1 -0
- package/dist/chunk-WIY7KIHU.js +22 -0
- package/dist/chunk-WIY7KIHU.js.map +1 -0
- package/dist/chunk-X4VXTRJB.js +74 -0
- package/dist/chunk-X4VXTRJB.js.map +1 -0
- package/dist/helpers/slugify.cjs +52 -0
- package/dist/helpers/slugify.cjs.map +1 -0
- package/dist/helpers/slugify.d.cts +5 -0
- package/dist/helpers/slugify.d.ts +5 -0
- package/dist/helpers/slugify.js +7 -0
- package/dist/helpers/slugify.js.map +1 -0
- package/dist/hooks/index.cjs +129 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +4 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useFormContext/useFormContext.cjs +127 -0
- package/dist/hooks/useFormContext/useFormContext.cjs.map +1 -0
- package/dist/hooks/useFormContext/useFormContext.d.cts +40 -0
- package/dist/hooks/useFormContext/useFormContext.d.ts +40 -0
- package/dist/hooks/useFormContext/useFormContext.js +11 -0
- package/dist/hooks/useFormContext/useFormContext.js.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs +64 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.cts +9 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.ts +9 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js +7 -0
- package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.cjs +69 -0
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +6 -0
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +6 -0
- package/dist/partials/FieldCopyTestIdButton/index.js +10 -0
- package/dist/partials/FieldCopyTestIdButton/index.js.map +1 -0
- package/dist/partials/FieldValidationError/FieldValidationError.cjs +87 -0
- package/dist/partials/FieldValidationError/FieldValidationError.cjs.map +1 -0
- package/dist/partials/FieldValidationError/FieldValidationError.d.cts +13 -0
- package/dist/partials/FieldValidationError/FieldValidationError.d.ts +13 -0
- package/dist/partials/FieldValidationError/FieldValidationError.js +8 -0
- package/dist/partials/FieldValidationError/FieldValidationError.js.map +1 -0
- package/dist/partials/FieldValidationError/index.cjs +90 -0
- package/dist/partials/FieldValidationError/index.cjs.map +1 -0
- package/dist/partials/FieldValidationError/index.d.cts +7 -0
- package/dist/partials/FieldValidationError/index.d.ts +7 -0
- package/dist/partials/FieldValidationError/index.js +11 -0
- package/dist/partials/FieldValidationError/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,159 @@
|
|
|
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/index.ts
|
|
31
|
+
var SubmitButton_exports = {};
|
|
32
|
+
__export(SubmitButton_exports, {
|
|
33
|
+
default: () => SubmitButton_default2
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(SubmitButton_exports);
|
|
36
|
+
|
|
37
|
+
// src/SubmitButton/SubmitButton.tsx
|
|
38
|
+
var import_classnames = __toESM(require("classnames"), 1);
|
|
39
|
+
var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
|
|
40
|
+
|
|
41
|
+
// src/helpers/slugify.ts
|
|
42
|
+
var import_slug = __toESM(require("slug"), 1);
|
|
43
|
+
var slugify_default = (string, options) => {
|
|
44
|
+
const replacement = options?.replacement || "_";
|
|
45
|
+
return (0, import_slug.default)(string, {
|
|
46
|
+
...import_slug.default.defaults.modes.rfc3986,
|
|
47
|
+
charmap: {
|
|
48
|
+
...import_slug.default.defaults.modes.rfc3986.charmap,
|
|
49
|
+
// allow dots by default
|
|
50
|
+
".": ".",
|
|
51
|
+
// convert hyphens to underscores (when replacement is not hyphen)
|
|
52
|
+
...replacement !== "-" ? { "-": "_" } : {}
|
|
53
|
+
},
|
|
54
|
+
replacement,
|
|
55
|
+
...options || {}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
60
|
+
var import_react2 = require("react");
|
|
61
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
62
|
+
|
|
63
|
+
// src/Form/subcomponents/FormContext.tsx
|
|
64
|
+
var import_react = __toESM(require("react"), 1);
|
|
65
|
+
var import_react_hook_form = require("react-hook-form");
|
|
66
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
|
+
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
68
|
+
|
|
69
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
70
|
+
var recursiveSearchInnerType = (schema) => {
|
|
71
|
+
if (schema?._def?.innerType) {
|
|
72
|
+
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
73
|
+
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
74
|
+
}
|
|
75
|
+
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
};
|
|
79
|
+
var recursiveFieldKeySearch = (schema, path) => {
|
|
80
|
+
const [current, ...rest] = path;
|
|
81
|
+
let currentSchema = schema;
|
|
82
|
+
if (schema?._def?.typeName === "ZodOptional") {
|
|
83
|
+
currentSchema = schema.unwrap();
|
|
84
|
+
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
85
|
+
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
86
|
+
}
|
|
87
|
+
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
88
|
+
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));
|
|
89
|
+
}
|
|
90
|
+
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
91
|
+
if (shape && shape[current]) {
|
|
92
|
+
if (rest.length === 0) {
|
|
93
|
+
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
94
|
+
}
|
|
95
|
+
return recursiveFieldKeySearch(shape[current], rest);
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
};
|
|
99
|
+
var useFormContext = () => {
|
|
100
|
+
const {
|
|
101
|
+
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
102
|
+
// for getFieldState a subscription to formState properties is needed!
|
|
103
|
+
formState,
|
|
104
|
+
getFieldState: getFieldStateOrig,
|
|
105
|
+
...otherMethods
|
|
106
|
+
} = (0, import_react_hook_form2.useFormContext)();
|
|
107
|
+
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
108
|
+
const getFieldState = (name, testId) => {
|
|
109
|
+
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
110
|
+
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
111
|
+
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
112
|
+
return {
|
|
113
|
+
...rest,
|
|
114
|
+
error,
|
|
115
|
+
// TODO: change to correct type @Hannes ;)
|
|
116
|
+
required,
|
|
117
|
+
testId: slugify_default(testId || name)
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
...otherMethods,
|
|
122
|
+
getFieldState,
|
|
123
|
+
validation,
|
|
124
|
+
formState
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/SubmitButton/SubmitButton.tsx
|
|
129
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
130
|
+
var SubmitButton = ({
|
|
131
|
+
children = "Submit",
|
|
132
|
+
className = void 0,
|
|
133
|
+
color = "success",
|
|
134
|
+
loading = false,
|
|
135
|
+
onClick = void 0,
|
|
136
|
+
testId = "form_submit_button"
|
|
137
|
+
}) => {
|
|
138
|
+
const {
|
|
139
|
+
formState: { isValid, isSubmitting, isValidating }
|
|
140
|
+
} = useFormContext();
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
142
|
+
import_Button.default,
|
|
143
|
+
{
|
|
144
|
+
className: (0, import_classnames.default)(className),
|
|
145
|
+
color,
|
|
146
|
+
testId: slugify_default(testId),
|
|
147
|
+
disabled: !isValid || isSubmitting || isValidating,
|
|
148
|
+
loading,
|
|
149
|
+
onClick,
|
|
150
|
+
type: "submit",
|
|
151
|
+
children
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
var SubmitButton_default = SubmitButton;
|
|
156
|
+
|
|
157
|
+
// src/SubmitButton/index.ts
|
|
158
|
+
var SubmitButton_default2 = SubmitButton_default;
|
|
159
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SubmitButton/index.ts","../../src/SubmitButton/SubmitButton.tsx","../../src/helpers/slugify.ts","../../src/hooks/useFormContext/useFormContext.ts","../../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["import SubmitButton from './SubmitButton';\n\nexport default SubmitButton;\n","import type { ButtonProps } from '@fuf-stack/pixels/Button';\nimport type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\n\nimport slugify from '../helpers/slugify';\nimport { useFormContext } from '../hooks';\n\ninterface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** color of the button */\n color?: ButtonProps['color'];\n /** If set loading animation is shown */\n loading?: boolean;\n /** function called when the button is pressed. */\n onClick?: ButtonProps['onClick'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * From SubmitButton\n */\nconst SubmitButton = ({\n children = 'Submit',\n className = undefined,\n color = 'success',\n loading = false,\n onClick = undefined,\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const {\n formState: { isValid, isSubmitting, isValidating },\n } = useFormContext();\n\n return (\n <Button\n className={cn(className)}\n color={color}\n testId={slugify(testId)}\n disabled={!isValid || isSubmitting || isValidating}\n loading={loading}\n onClick={onClick}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\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","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"],"mappings":"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","names":["SubmitButton_default","slug","import_react","import_react_hook_form","React","useHookFormContext","import_jsx_runtime","Button","cn","SubmitButton_default"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SubmitButton_default
|
|
3
|
+
} from "../chunk-BJ36HK7L.js";
|
|
4
|
+
import "../chunk-GATZOHQ6.js";
|
|
5
|
+
import "../chunk-PMNBGDEZ.js";
|
|
6
|
+
import "../chunk-IQVKBQ7W.js";
|
|
7
|
+
import "../chunk-WIY7KIHU.js";
|
|
8
|
+
|
|
9
|
+
// src/SubmitButton/index.ts
|
|
10
|
+
var SubmitButton_default2 = SubmitButton_default;
|
|
11
|
+
export {
|
|
12
|
+
SubmitButton_default2 as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SubmitButton/index.ts"],"sourcesContent":["import SubmitButton from './SubmitButton';\n\nexport default SubmitButton;\n"],"mappings":";;;;;;;;;AAEA,IAAOA,wBAAQ;","names":["SubmitButton_default"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormContext
|
|
3
|
+
} from "./chunk-PMNBGDEZ.js";
|
|
4
|
+
|
|
5
|
+
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { FaTimes } from "react-icons/fa";
|
|
8
|
+
import { FaBug } from "react-icons/fa6";
|
|
9
|
+
import cn from "classnames";
|
|
10
|
+
import Button from "@fuf-stack/pixels/Button";
|
|
11
|
+
import Card from "@fuf-stack/pixels/Card";
|
|
12
|
+
import useLocalStorage from "@fuf-stack/pixels/hooks/useLocalStorage";
|
|
13
|
+
import Json from "@fuf-stack/pixels/Json";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
16
|
+
var FormDebugViewer = ({ className = void 0 }) => {
|
|
17
|
+
const {
|
|
18
|
+
watch,
|
|
19
|
+
formState: { dirtyFields, isValid, isSubmitting },
|
|
20
|
+
validation
|
|
21
|
+
} = useFormContext();
|
|
22
|
+
const [debug, setDebug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);
|
|
23
|
+
const [validationErrors, setValidationErrors] = useState(null);
|
|
24
|
+
const formValues = watch();
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const updateValidationErrors = async () => {
|
|
27
|
+
if (validation) {
|
|
28
|
+
const validateResult = await validation?.validateAsync(formValues);
|
|
29
|
+
setValidationErrors(validateResult?.errors);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
updateValidationErrors();
|
|
33
|
+
}, [JSON.stringify(formValues)]);
|
|
34
|
+
if (!debug) {
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
Button,
|
|
37
|
+
{
|
|
38
|
+
ariaLabel: "Enable form debug mode",
|
|
39
|
+
onClick: () => setDebug(!debug),
|
|
40
|
+
className: "absolute bottom-2.5 right-2.5 w-5 text-default-400",
|
|
41
|
+
variant: "light",
|
|
42
|
+
icon: /* @__PURE__ */ jsx(FaBug, {})
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
Card,
|
|
48
|
+
{
|
|
49
|
+
className: cn(className),
|
|
50
|
+
header: /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-row justify-between", children: [
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: "text-lg", children: "Debug Mode" }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
Button,
|
|
54
|
+
{
|
|
55
|
+
icon: /* @__PURE__ */ jsx(FaTimes, { className: "text-danger" }),
|
|
56
|
+
onClick: () => setDebug(false),
|
|
57
|
+
size: "sm",
|
|
58
|
+
variant: "flat"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }),
|
|
62
|
+
children: /* @__PURE__ */ jsx(
|
|
63
|
+
Json,
|
|
64
|
+
{
|
|
65
|
+
value: {
|
|
66
|
+
values: formValues,
|
|
67
|
+
errors: validationErrors,
|
|
68
|
+
dirtyFields,
|
|
69
|
+
isValid,
|
|
70
|
+
isSubmitting
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
var FormDebugViewer_default = FormDebugViewer;
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
FormDebugViewer_default
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=chunk-AV26PIKH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Form/subcomponents/FormDebugViewer.tsx"],"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"],"mappings":";;;;;AAEA,SAAS,WAAW,gBAAgB;AACpC,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,OAAO,QAAQ;AAEf,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,qBAAqB;AAC5B,OAAO,UAAU;AA4CH,cASN,YATM;AAnCd,IAAM,yBAAyB;AAG/B,IAAM,kBAAkB,CAAC,EAAE,YAAY,OAAU,MAA4B;AAC3E,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,aAAa,SAAS,aAAa;AAAA,IAChD;AAAA,EACF,IAAI,eAAe;AAEnB,QAAM,CAAC,OAAO,QAAQ,IAAI,gBAAgB,wBAAwB,KAAK;AAEvE,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAE9C,IAAI;AAEN,QAAM,aAAa,MAAM;AAEzB,YAAU,MAAM;AACd,UAAM,yBAAyB,YAAY;AACzC,UAAI,YAAY;AACd,cAAM,iBAAiB,MAAM,YAAY,cAAc,UAAU;AACjE,4BAAoB,gBAAgB,MAAM;AAAA,MAC5C;AAAA,IACF;AACA,2BAAuB;AAAA,EACzB,GAAG,CAAC,KAAK,UAAU,UAAU,CAAC,CAAC;AAE/B,MAAI,CAAC,OAAO;AACV,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,SAAS,MAAM,SAAS,CAAC,KAAK;AAAA,QAC9B,WAAU;AAAA,QACV,SAAQ;AAAA,QACR,MAAM,oBAAC,SAAM;AAAA;AAAA,IACf;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,SAAS;AAAA,MACvB,QACE,qBAAC,SAAI,WAAU,wCACb;AAAA,4BAAC,UAAK,WAAU,WAAU,wBAAU;AAAA,QACpC;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,oBAAC,WAAQ,WAAU,eAAc;AAAA,YACvC,SAAS,MAAM,SAAS,KAAK;AAAA,YAC7B,MAAK;AAAA,YACL,SAAQ;AAAA;AAAA,QACV;AAAA,SACF;AAAA,MAGF;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,QAAQ;AAAA,YACR,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AACA,IAAO,0BAAQ;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormContext
|
|
3
|
+
} from "./chunk-PMNBGDEZ.js";
|
|
4
|
+
import {
|
|
5
|
+
slugify_default
|
|
6
|
+
} from "./chunk-WIY7KIHU.js";
|
|
7
|
+
|
|
8
|
+
// src/SubmitButton/SubmitButton.tsx
|
|
9
|
+
import cn from "classnames";
|
|
10
|
+
import Button from "@fuf-stack/pixels/Button";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var SubmitButton = ({
|
|
13
|
+
children = "Submit",
|
|
14
|
+
className = void 0,
|
|
15
|
+
color = "success",
|
|
16
|
+
loading = false,
|
|
17
|
+
onClick = void 0,
|
|
18
|
+
testId = "form_submit_button"
|
|
19
|
+
}) => {
|
|
20
|
+
const {
|
|
21
|
+
formState: { isValid, isSubmitting, isValidating }
|
|
22
|
+
} = useFormContext();
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Button,
|
|
25
|
+
{
|
|
26
|
+
className: cn(className),
|
|
27
|
+
color,
|
|
28
|
+
testId: slugify_default(testId),
|
|
29
|
+
disabled: !isValid || isSubmitting || isValidating,
|
|
30
|
+
loading,
|
|
31
|
+
onClick,
|
|
32
|
+
type: "submit",
|
|
33
|
+
children
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
var SubmitButton_default = SubmitButton;
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
SubmitButton_default
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=chunk-BJ36HK7L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SubmitButton/SubmitButton.tsx"],"sourcesContent":["import type { ButtonProps } from '@fuf-stack/pixels/Button';\nimport type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\n\nimport slugify from '../helpers/slugify';\nimport { useFormContext } from '../hooks';\n\ninterface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string | string[];\n /** color of the button */\n color?: ButtonProps['color'];\n /** If set loading animation is shown */\n loading?: boolean;\n /** function called when the button is pressed. */\n onClick?: ButtonProps['onClick'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * From SubmitButton\n */\nconst SubmitButton = ({\n children = 'Submit',\n className = undefined,\n color = 'success',\n loading = false,\n onClick = undefined,\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const {\n formState: { isValid, isSubmitting, isValidating },\n } = useFormContext();\n\n return (\n <Button\n className={cn(className)}\n color={color}\n testId={slugify(testId)}\n disabled={!isValid || isSubmitting || isValidating}\n loading={loading}\n onClick={onClick}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n"],"mappings":";;;;;;;;AAGA,OAAO,QAAQ;AAEf,OAAO,YAAY;AAoCf;AAbJ,IAAM,eAAe,CAAC;AAAA,EACpB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AACX,MAAyB;AACvB,QAAM;AAAA,IACJ,WAAW,EAAE,SAAS,cAAc,aAAa;AAAA,EACnD,IAAI,eAAe;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,SAAS;AAAA,MACvB;AAAA,MACA,QAAQ,gBAAQ,MAAM;AAAA,MACtB,UAAU,CAAC,WAAW,gBAAgB;AAAA,MACtC;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,uBAAQ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
slugify_default
|
|
3
|
+
} from "./chunk-WIY7KIHU.js";
|
|
4
|
+
|
|
5
|
+
// src/partials/FieldValidationError/FieldValidationError.tsx
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var FieldValidationError = ({
|
|
8
|
+
error,
|
|
9
|
+
testId = void 0
|
|
10
|
+
}) => {
|
|
11
|
+
if (!error) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
let tmp_errors = [];
|
|
15
|
+
if (typeof error === "object" && !(error instanceof Array)) {
|
|
16
|
+
const error_object = error;
|
|
17
|
+
Object.keys(error).forEach((key) => {
|
|
18
|
+
tmp_errors = [...tmp_errors, ...error_object[key]];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const errorArray = JSON.stringify(tmp_errors) !== "[]" ? tmp_errors : error;
|
|
22
|
+
const errorStrings = errorArray.map((e) => e.message);
|
|
23
|
+
const ariaString = `Error: ${errorStrings.join("\n")}`;
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
"ul",
|
|
26
|
+
{
|
|
27
|
+
"data-testid": slugify_default(testId || errorStrings.join()),
|
|
28
|
+
"aria-label": ariaString,
|
|
29
|
+
children: errorStrings.map((errorString, i) => (
|
|
30
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
31
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("div", { children: errorString }) }, `error_${i}`)
|
|
32
|
+
))
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
var FieldValidationError_default = FieldValidationError;
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
FieldValidationError_default
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-EDUZKOTL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldValidationError/FieldValidationError.tsx"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport slugify from '../../helpers/slugify';\n\ninterface FieldValidationErrorProps {\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmp_errors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const error_object = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmp_errors = [...tmp_errors, ...error_object[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmp_errors) !== '[]' ? tmp_errors : (error as FieldError[]);\n const errorStrings: string[] = errorArray.map((e) => e.message) as string[];\n const ariaString = `Error: ${errorStrings.join('\\n')}`;\n\n return (\n <ul\n data-testid={slugify(testId || errorStrings.join())}\n aria-label={ariaString} // TODO: ist das richtig @Hannes?\n >\n {errorStrings.map((errorString: string, i: number) => (\n // eslint-disable-next-line react/no-array-index-key\n <li key={`error_${i}`}>\n <div>{errorString}</div>\n </li>\n ))}\n </ul>\n );\n};\n\nexport default FieldValidationError;\n"],"mappings":";;;;;AA0CU;AA9BV,IAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA,SAAS;AACX,MAAiC;AAC/B,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,aAA2B,CAAC;AAEhC,MAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,QAAQ;AAC1D,UAAM,eAAe;AACrB,WAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,mBAAa,CAAC,GAAG,YAAY,GAAG,aAAa,GAAG,CAAC;AAAA,IACnD,CAAC;AAAA,EACH;AAEA,QAAM,aACJ,KAAK,UAAU,UAAU,MAAM,OAAO,aAAc;AACtD,QAAM,eAAyB,WAAW,IAAI,CAAC,MAAM,EAAE,OAAO;AAC9D,QAAM,aAAa,UAAU,aAAa,KAAK,IAAI,CAAC;AAEpD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAa,gBAAQ,UAAU,aAAa,KAAK,CAAC;AAAA,MAClD,cAAY;AAAA,MAEX,uBAAa,IAAI,CAAC,aAAqB;AAAA;AAAA,QAEtC,oBAAC,QACC,8BAAC,SAAK,uBAAY,KADX,SAAS,CAAC,EAEnB;AAAA,OACD;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,+BAAQ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-GATZOHQ6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/Form/subcomponents/FormContext.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FormProvider as HookFormProvider } from "react-hook-form";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var ValidationSchemaContext = React.createContext(void 0);
|
|
6
|
+
var FormProvider = ({
|
|
7
|
+
children,
|
|
8
|
+
validation = void 0,
|
|
9
|
+
...hookFormProps
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(HookFormProvider, { ...hookFormProps, children }) });
|
|
12
|
+
};
|
|
13
|
+
var FormContext_default = FormProvider;
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
ValidationSchemaContext,
|
|
17
|
+
FormContext_default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-IQVKBQ7W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";AAGA,OAAO,WAAW;AAClB,SAAS,gBAAgB,wBAAwB;AAoB3C;AAlBC,IAAM,0BAA0B,MAAM,cAE3C,MAAS;AASX,IAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,MAAyB;AACvB,SACE,oBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACvC,8BAAC,oBAAkB,GAAG,eAAgB,UAAS,GACjD;AAEJ;AAEA,IAAO,sBAAQ;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/Grid/Grid.tsx
|
|
2
|
+
import cn from "classnames";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var Grid = ({
|
|
5
|
+
children = null,
|
|
6
|
+
className = void 0,
|
|
7
|
+
testId = void 0
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ jsx("div", { className: cn("grid gap-6", className), "data-testid": testId, children });
|
|
10
|
+
};
|
|
11
|
+
var Grid_default = Grid;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
Grid_default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-KY2KCXOO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";AAEA,OAAO,QAAQ;AAoBX;AANJ,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AACX,MAAiB;AACf,SACE,oBAAC,SAAI,WAAW,GAAG,cAAc,SAAS,GAAG,eAAa,QACvD,UACH;AAEJ;AAEA,IAAO,eAAQ;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ValidationSchemaContext
|
|
3
|
+
} from "./chunk-IQVKBQ7W.js";
|
|
4
|
+
import {
|
|
5
|
+
slugify_default
|
|
6
|
+
} from "./chunk-WIY7KIHU.js";
|
|
7
|
+
|
|
8
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
9
|
+
import { useContext } from "react";
|
|
10
|
+
import { useFormContext as useHookFormContext } from "react-hook-form";
|
|
11
|
+
var recursiveSearchInnerType = (schema) => {
|
|
12
|
+
if (schema?._def?.innerType) {
|
|
13
|
+
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
14
|
+
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
15
|
+
}
|
|
16
|
+
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
var recursiveFieldKeySearch = (schema, path) => {
|
|
21
|
+
const [current, ...rest] = path;
|
|
22
|
+
let currentSchema = schema;
|
|
23
|
+
if (schema?._def?.typeName === "ZodOptional") {
|
|
24
|
+
currentSchema = schema.unwrap();
|
|
25
|
+
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
26
|
+
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
27
|
+
}
|
|
28
|
+
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
29
|
+
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));
|
|
30
|
+
}
|
|
31
|
+
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
32
|
+
if (shape && shape[current]) {
|
|
33
|
+
if (rest.length === 0) {
|
|
34
|
+
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
35
|
+
}
|
|
36
|
+
return recursiveFieldKeySearch(shape[current], rest);
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
40
|
+
var useFormContext = () => {
|
|
41
|
+
const {
|
|
42
|
+
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
43
|
+
// for getFieldState a subscription to formState properties is needed!
|
|
44
|
+
formState,
|
|
45
|
+
getFieldState: getFieldStateOrig,
|
|
46
|
+
...otherMethods
|
|
47
|
+
} = useHookFormContext();
|
|
48
|
+
const validation = useContext(ValidationSchemaContext);
|
|
49
|
+
const getFieldState = (name, testId) => {
|
|
50
|
+
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
51
|
+
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
52
|
+
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
53
|
+
return {
|
|
54
|
+
...rest,
|
|
55
|
+
error,
|
|
56
|
+
// TODO: change to correct type @Hannes ;)
|
|
57
|
+
required,
|
|
58
|
+
testId: slugify_default(testId || name)
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
...otherMethods,
|
|
63
|
+
getFieldState,
|
|
64
|
+
validation,
|
|
65
|
+
formState
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
recursiveFieldKeySearch,
|
|
71
|
+
useFormContext
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-PMNBGDEZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;AAGA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;AAMrD,IAAM,2BAA2B,CAAC,WAAgC;AAChE,MAAI,QAAQ,MAAM,WAAW;AAC3B,QAAI,QAAQ,MAAM,WAAW,MAAM,aAAa,eAAe;AAC7D,aAAO,QAAQ,MAAM,WAAW,MAAM,aAAa;AAAA,IACrD;AACA,WAAO,yBAAyB,QAAQ,MAAM,SAAS;AAAA,EACzD;AACA,SAAO;AACT;AAGO,IAAM,0BAA0B,CACrC,QACA,SACmB;AACnB,QAAM,CAAC,SAAS,GAAG,IAAI,IAAI;AAG3B,MAAI,gBAAgB;AAEpB,MAAI,QAAQ,MAAM,aAAa,eAAe;AAE5C,oBAAgB,OAAO,OAAO;AAAA,EAChC,WAAW,QAAQ,MAAM,aAAa,cAAc;AAElD,WAAO,wBAAwB,OAAO,MAAM,QAAQ,IAAI;AAAA,EAC1D;AAGA,MAAI,eAAe,MAAM,aAAa,mBAAmB;AACvD,YACG,cAAc,KAAK,MAAM,SACtB,wBAAwB,cAAc,KAAK,KAAK,QAAQ,IAAI,IAC5D,wBAAwB,cAAc,KAAK,MAAM,IAAI,OACxD,cAAc,KAAK,OAAO,SACvB,wBAAwB,cAAc,KAAK,MAAM,QAAQ,IAAI,IAC7D,wBAAwB,cAAc,KAAK,OAAO,IAAI;AAAA,EAE9D;AAIA,QAAM,QAAQ,eAAe,SAAS,eAAe,SAAS;AAE9D,MAAI,SAAS,MAAM,OAAO,GAAG;AAE3B,QAAI,KAAK,WAAW,GAAG;AAErB,aACE,MAAM,OAAO,GAAG,MAAM,aAAa,iBACnC,yBAAyB,MAAM,OAAO,CAAC;AAAA,IAE3C;AACA,WAAO,wBAAwB,MAAM,OAAO,GAAG,IAAI;AAAA,EACrD;AAEA,SAAO;AACT;AAGO,IAAM,iBAAiB,MAAM;AAClC,QAAM;AAAA;AAAA;AAAA,IAGJ;AAAA,IACA,eAAe;AAAA,IACf,GAAG;AAAA,EACL,IAAI,mBAAmB;AACvB,QAAM,aAAa,WAAW,uBAAuB;AAGrD,QAAM,gBAAgB,CAAC,MAAc,WAAoB;AACvD,UAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,EAAE,EAAE,MAAM,GAAG,IAAI;AACvE,UAAM,WACH,cAAc,wBAAwB,WAAW,QAAQ,SAAS,KACnE;AACF,UAAM,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,MAAM,SAAS;AAC5D,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA;AAAA,MACA;AAAA,MACA,QAAQ,gBAAQ,UAAU,IAAI;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
2
|
+
import { FaBullseye } from "react-icons/fa6";
|
|
3
|
+
import cn from "classnames";
|
|
4
|
+
import Button from "@fuf-stack/pixels/Button";
|
|
5
|
+
import useLocalStorage from "@fuf-stack/pixels/hooks/useLocalStorage";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
8
|
+
var TestIdDebug = ({ className = void 0, testId }) => {
|
|
9
|
+
const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);
|
|
10
|
+
const copyToClipboard = () => {
|
|
11
|
+
navigator.clipboard.writeText(testId).catch((err) => {
|
|
12
|
+
console.error("Error copying TestId to clipboard", err);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
if (!debug) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
Button,
|
|
20
|
+
{
|
|
21
|
+
className: cn(className, "pointer-events-auto"),
|
|
22
|
+
variant: "light",
|
|
23
|
+
onClick: copyToClipboard,
|
|
24
|
+
icon: /* @__PURE__ */ jsx(FaBullseye, {}),
|
|
25
|
+
size: "sm"
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var FieldCopyTestIdButton_default = TestIdDebug;
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
FieldCopyTestIdButton_default
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-UMTFPEVF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx"],"sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport useLocalStorage from '@fuf-stack/pixels/hooks/useLocalStorage';\n\ninterface FormDebugProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst TestIdDebug = ({ className = undefined, testId }: FormDebugProps) => {\n const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n if (!debug) {\n return null;\n }\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n variant=\"light\"\n onClick={copyToClipboard}\n icon={<FaBullseye />}\n size=\"sm\"\n />\n );\n};\nexport default TestIdDebug;\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,OAAO,QAAQ;AAEf,OAAO,YAAY;AACnB,OAAO,qBAAqB;AA2BhB;AApBZ,IAAM,yBAAyB;AAE/B,IAAM,cAAc,CAAC,EAAE,YAAY,QAAW,OAAO,MAAsB;AACzE,QAAM,CAAC,KAAK,IAAI,gBAAgB,wBAAwB,KAAK;AAE7D,QAAM,kBAAkB,MAAM;AAC5B,cAAU,UAAU,UAAU,MAAM,EAAE,MAAM,CAAC,QAAQ;AACnD,cAAQ,MAAM,qCAAqC,GAAG;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,qBAAqB;AAAA,MAC9C,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,oBAAC,cAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/helpers/slugify.ts
|
|
2
|
+
import slug from "slug";
|
|
3
|
+
var slugify_default = (string, options) => {
|
|
4
|
+
const replacement = options?.replacement || "_";
|
|
5
|
+
return slug(string, {
|
|
6
|
+
...slug.defaults.modes.rfc3986,
|
|
7
|
+
charmap: {
|
|
8
|
+
...slug.defaults.modes.rfc3986.charmap,
|
|
9
|
+
// allow dots by default
|
|
10
|
+
".": ".",
|
|
11
|
+
// convert hyphens to underscores (when replacement is not hyphen)
|
|
12
|
+
...replacement !== "-" ? { "-": "_" } : {}
|
|
13
|
+
},
|
|
14
|
+
replacement,
|
|
15
|
+
...options || {}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
slugify_default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-WIY7KIHU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/slugify.ts"],"sourcesContent":["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":";AAEA,OAAO,UAAU;AAEjB,IAAO,kBAAQ,CAAC,QAAgB,YAA0B;AACxD,QAAM,cAAc,SAAS,eAAe;AAC5C,SAAO,KAAK,QAAQ;AAAA,IAClB,GAAG,KAAK,SAAS,MAAM;AAAA,IACvB,SAAS;AAAA,MACP,GAAG,KAAK,SAAS,MAAM,QAAQ;AAAA;AAAA,MAE/B,KAAK;AAAA;AAAA,MAEL,GAAI,gBAAgB,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AAAA,IAC5C;AAAA,IACA;AAAA,IACA,GAAI,WAAW,CAAC;AAAA,EAClB,CAAC;AACH;","names":[]}
|