@fuf-stack/uniform 0.0.2 → 0.0.4
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 +5 -263
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.d.cts +3 -2
- package/dist/Form/index.d.ts +3 -2
- package/dist/Form/index.js +6 -10
- package/dist/Form/index.js.map +1 -1
- package/dist/{Form/Form.d.cts → Form-Bv0R3QNk.d.cts} +1 -6
- package/dist/{Form/Form.d.ts → Form-Bv0R3QNk.d.ts} +1 -6
- package/dist/Grid/index.cjs +5 -47
- package/dist/Grid/index.cjs.map +1 -1
- package/dist/Grid/index.d.cts +3 -2
- package/dist/Grid/index.d.ts +3 -2
- package/dist/Grid/index.js +4 -5
- package/dist/Grid/index.js.map +1 -1
- package/dist/{Grid/Grid.d.cts → Grid-DF3L9NF3.d.cts} +1 -1
- package/dist/{Grid/Grid.d.ts → Grid-DF3L9NF3.d.ts} +1 -1
- package/dist/SubmitButton/index.cjs +15 -129
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.d.cts +22 -6
- package/dist/SubmitButton/index.d.ts +22 -6
- package/dist/SubmitButton/index.js +37 -6
- package/dist/SubmitButton/index.js.map +1 -1
- package/dist/{chunk-KY2KCXOO.js → chunk-4MEKDDB2.js} +6 -2
- package/dist/chunk-4MEKDDB2.js.map +1 -0
- 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-AV26PIKH.js → chunk-BQUVQMFA.js} +79 -3
- package/dist/chunk-BQUVQMFA.js.map +1 -0
- package/dist/chunk-II57W3V2.cjs +158 -0
- package/dist/chunk-II57W3V2.cjs.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/chunk-ZPFKVKGV.cjs +20 -0
- package/dist/chunk-ZPFKVKGV.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/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -0
- 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 +45 -10
- package/dist/Form/Form.cjs +0 -269
- package/dist/Form/Form.cjs.map +0 -1
- 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/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.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.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.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
- /package/dist/{Form/subcomponents/FormContext.js.map → index.js.map} +0 -0
package/dist/Form/index.cjs
CHANGED
|
@@ -1,269 +1,11 @@
|
|
|
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);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
29
2
|
|
|
30
|
-
// src/Form/index.ts
|
|
31
|
-
var Form_exports = {};
|
|
32
|
-
__export(Form_exports, {
|
|
33
|
-
default: () => Form_default2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(Form_exports);
|
|
36
3
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var import_classnames2 = __toESM(require("classnames"), 1);
|
|
4
|
+
var _chunkII57W3V2cjs = require('../chunk-II57W3V2.cjs');
|
|
5
|
+
require('../chunk-WQRM7G4C.cjs');
|
|
6
|
+
require('../chunk-BBB4FEY6.cjs');
|
|
41
7
|
|
|
42
|
-
// src/helpers/slugify.ts
|
|
43
|
-
var import_slug = __toESM(require("slug"), 1);
|
|
44
|
-
var slugify_default = (string, options) => {
|
|
45
|
-
const replacement = options?.replacement || "_";
|
|
46
|
-
return (0, import_slug.default)(string, {
|
|
47
|
-
...import_slug.default.defaults.modes.rfc3986,
|
|
48
|
-
charmap: {
|
|
49
|
-
...import_slug.default.defaults.modes.rfc3986.charmap,
|
|
50
|
-
// allow dots by default
|
|
51
|
-
".": ".",
|
|
52
|
-
// convert hyphens to underscores (when replacement is not hyphen)
|
|
53
|
-
...replacement !== "-" ? { "-": "_" } : {}
|
|
54
|
-
},
|
|
55
|
-
replacement,
|
|
56
|
-
...options || {}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
8
|
|
|
60
|
-
// src/Form/subcomponents/FormContext.tsx
|
|
61
|
-
var import_react = __toESM(require("react"), 1);
|
|
62
|
-
var import_react_hook_form = require("react-hook-form");
|
|
63
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
64
|
-
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
65
|
-
var FormProvider = ({
|
|
66
|
-
children,
|
|
67
|
-
validation = void 0,
|
|
68
|
-
...hookFormProps
|
|
69
|
-
}) => {
|
|
70
|
-
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 }) });
|
|
71
|
-
};
|
|
72
|
-
var FormContext_default = FormProvider;
|
|
73
9
|
|
|
74
|
-
|
|
75
|
-
var import_react3 = require("react");
|
|
76
|
-
var import_fa = require("react-icons/fa");
|
|
77
|
-
var import_fa6 = require("react-icons/fa6");
|
|
78
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
79
|
-
var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
|
|
80
|
-
var import_Card = __toESM(require("@fuf-stack/pixels/Card"), 1);
|
|
81
|
-
var import_useLocalStorage = __toESM(require("@fuf-stack/pixels/hooks/useLocalStorage"), 1);
|
|
82
|
-
var import_Json = __toESM(require("@fuf-stack/pixels/Json"), 1);
|
|
83
|
-
|
|
84
|
-
// src/hooks/useFormContext/useFormContext.ts
|
|
85
|
-
var import_react2 = require("react");
|
|
86
|
-
var import_react_hook_form2 = require("react-hook-form");
|
|
87
|
-
var recursiveSearchInnerType = (schema) => {
|
|
88
|
-
if (schema?._def?.innerType) {
|
|
89
|
-
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
90
|
-
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
91
|
-
}
|
|
92
|
-
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
93
|
-
}
|
|
94
|
-
return true;
|
|
95
|
-
};
|
|
96
|
-
var recursiveFieldKeySearch = (schema, path) => {
|
|
97
|
-
const [current, ...rest] = path;
|
|
98
|
-
let currentSchema = schema;
|
|
99
|
-
if (schema?._def?.typeName === "ZodOptional") {
|
|
100
|
-
currentSchema = schema.unwrap();
|
|
101
|
-
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
102
|
-
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
103
|
-
}
|
|
104
|
-
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
105
|
-
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));
|
|
106
|
-
}
|
|
107
|
-
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
108
|
-
if (shape && shape[current]) {
|
|
109
|
-
if (rest.length === 0) {
|
|
110
|
-
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
111
|
-
}
|
|
112
|
-
return recursiveFieldKeySearch(shape[current], rest);
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
};
|
|
116
|
-
var useFormContext = () => {
|
|
117
|
-
const {
|
|
118
|
-
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
119
|
-
// for getFieldState a subscription to formState properties is needed!
|
|
120
|
-
formState,
|
|
121
|
-
getFieldState: getFieldStateOrig,
|
|
122
|
-
...otherMethods
|
|
123
|
-
} = (0, import_react_hook_form2.useFormContext)();
|
|
124
|
-
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
125
|
-
const getFieldState = (name, testId) => {
|
|
126
|
-
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
127
|
-
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
128
|
-
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
129
|
-
return {
|
|
130
|
-
...rest,
|
|
131
|
-
error,
|
|
132
|
-
// TODO: change to correct type @Hannes ;)
|
|
133
|
-
required,
|
|
134
|
-
testId: slugify_default(testId || name)
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
return {
|
|
138
|
-
...otherMethods,
|
|
139
|
-
getFieldState,
|
|
140
|
-
validation,
|
|
141
|
-
formState
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
146
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
147
|
-
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
148
|
-
var FormDebugViewer = ({ className = void 0 }) => {
|
|
149
|
-
const {
|
|
150
|
-
watch,
|
|
151
|
-
formState: { dirtyFields, isValid, isSubmitting },
|
|
152
|
-
validation
|
|
153
|
-
} = useFormContext();
|
|
154
|
-
const [debug, setDebug] = (0, import_useLocalStorage.default)(LOCALSTORAGE_DEBUG_KEY, false);
|
|
155
|
-
const [validationErrors, setValidationErrors] = (0, import_react3.useState)(null);
|
|
156
|
-
const formValues = watch();
|
|
157
|
-
(0, import_react3.useEffect)(() => {
|
|
158
|
-
const updateValidationErrors = async () => {
|
|
159
|
-
if (validation) {
|
|
160
|
-
const validateResult = await validation?.validateAsync(formValues);
|
|
161
|
-
setValidationErrors(validateResult?.errors);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
updateValidationErrors();
|
|
165
|
-
}, [JSON.stringify(formValues)]);
|
|
166
|
-
if (!debug) {
|
|
167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
168
|
-
import_Button.default,
|
|
169
|
-
{
|
|
170
|
-
ariaLabel: "Enable form debug mode",
|
|
171
|
-
onClick: () => setDebug(!debug),
|
|
172
|
-
className: "absolute bottom-2.5 right-2.5 w-5 text-default-400",
|
|
173
|
-
variant: "light",
|
|
174
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa6.FaBug, {})
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
179
|
-
import_Card.default,
|
|
180
|
-
{
|
|
181
|
-
className: (0, import_classnames.default)(className),
|
|
182
|
-
header: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex w-full flex-row justify-between", children: [
|
|
183
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-lg", children: "Debug Mode" }),
|
|
184
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
185
|
-
import_Button.default,
|
|
186
|
-
{
|
|
187
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa.FaTimes, { className: "text-danger" }),
|
|
188
|
-
onClick: () => setDebug(false),
|
|
189
|
-
size: "sm",
|
|
190
|
-
variant: "flat"
|
|
191
|
-
}
|
|
192
|
-
)
|
|
193
|
-
] }),
|
|
194
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
195
|
-
import_Json.default,
|
|
196
|
-
{
|
|
197
|
-
value: {
|
|
198
|
-
values: formValues,
|
|
199
|
-
errors: validationErrors,
|
|
200
|
-
dirtyFields,
|
|
201
|
-
isValid,
|
|
202
|
-
isSubmitting
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
};
|
|
209
|
-
var FormDebugViewer_default = FormDebugViewer;
|
|
210
|
-
|
|
211
|
-
// src/Form/Form.tsx
|
|
212
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
213
|
-
var removeNullishFields = (obj) => {
|
|
214
|
-
return JSON.parse(
|
|
215
|
-
JSON.stringify(obj, (_key, value) => {
|
|
216
|
-
return value === null ? void 0 : value;
|
|
217
|
-
})
|
|
218
|
-
);
|
|
219
|
-
};
|
|
220
|
-
var Form = ({
|
|
221
|
-
children,
|
|
222
|
-
className = void 0,
|
|
223
|
-
initialValues = void 0,
|
|
224
|
-
name = void 0,
|
|
225
|
-
onSubmit,
|
|
226
|
-
testId = void 0,
|
|
227
|
-
validation = void 0,
|
|
228
|
-
validationTrigger = "all"
|
|
229
|
-
}) => {
|
|
230
|
-
const methods = (0, import_react_hook_form3.useForm)(
|
|
231
|
-
validation ? {
|
|
232
|
-
defaultValues: initialValues,
|
|
233
|
-
resolver: async (values) => {
|
|
234
|
-
const { data, errors, ...rest } = await validation.validateAsync(
|
|
235
|
-
removeNullishFields(values)
|
|
236
|
-
);
|
|
237
|
-
return { values: data || {}, errors: errors || {}, ...rest };
|
|
238
|
-
},
|
|
239
|
-
// set rhf mode
|
|
240
|
-
// see: https://react-hook-form.com/docs/useform#mode
|
|
241
|
-
mode: validationTrigger === "all-instant" ? "all" : validationTrigger
|
|
242
|
-
} : {
|
|
243
|
-
defaultValues: initialValues
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
(0, import_react4.useEffect)(() => {
|
|
247
|
-
if (validationTrigger === "all-instant") {
|
|
248
|
-
methods.trigger();
|
|
249
|
-
}
|
|
250
|
-
}, []);
|
|
251
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FormContext_default, { ...methods, validation, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex w-full flex-row justify-between gap-6", children: [
|
|
252
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
253
|
-
"form",
|
|
254
|
-
{
|
|
255
|
-
className: (0, import_classnames2.default)("flex-grow", className),
|
|
256
|
-
"data-testid": slugify_default(testId || name || ""),
|
|
257
|
-
name,
|
|
258
|
-
onSubmit: methods.handleSubmit(onSubmit),
|
|
259
|
-
children
|
|
260
|
-
}
|
|
261
|
-
),
|
|
262
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FormDebugViewer_default, { className: "w-96 flex-shrink" })
|
|
263
|
-
] }) });
|
|
264
|
-
};
|
|
265
|
-
var Form_default = Form;
|
|
266
|
-
|
|
267
|
-
// src/Form/index.ts
|
|
268
|
-
var Form_default2 = Form_default;
|
|
10
|
+
exports.Form = _chunkII57W3V2cjs.Form_default; exports.default = _chunkII57W3V2cjs.Form_default2;
|
|
269
11
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Form/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Form/index.ts","../../src/Form/Form.tsx","../../src/helpers/slugify.ts","../../src/Form/subcomponents/FormContext.tsx","../../src/Form/subcomponents/FormDebugViewer.tsx","../../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["import Form from './Form';\n\nexport default Form;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport { useEffect } from 'react';\nimport { useForm } from 'react-hook-form';\n\nimport cn from 'classnames';\n\nimport slugify from '../helpers/slugify';\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\n/**\n * recursively removes all fields that are null or undefined before\n * the form data is passed to the veto validation function\n */\nexport const removeNullishFields = (obj: Record<string, unknown>) => {\n return JSON.parse(\n JSON.stringify(obj, (_key, value) => {\n return value === null ? undefined : value;\n }),\n );\n};\n\ninterface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?:\n | 'onChange'\n | 'onBlur'\n | 'onSubmit'\n | 'onTouched'\n | 'all'\n | 'all-instant';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n const methods = useForm(\n validation\n ? {\n defaultValues: initialValues,\n resolver: async (values) => {\n const { data, errors, ...rest } = await validation.validateAsync(\n removeNullishFields(values),\n );\n // https://github.com/react-hook-form/resolvers/blob/master/zod/src/zod.ts\n return { values: data || {}, errors: errors || {}, ...rest };\n },\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger === 'all-instant' ? 'all' : validationTrigger,\n }\n : {\n defaultValues: initialValues,\n },\n );\n\n useEffect(() => {\n if (validationTrigger === 'all-instant') {\n methods.trigger();\n }\n }, []);\n\n return (\n <FormProvider {...methods} validation={validation}>\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('flex-grow', className)}\n data-testid={slugify(testId || name || '')}\n name={name}\n onSubmit={methods.handleSubmit(onSubmit)}\n >\n {children}\n </form>\n <FormDebugViewer className=\"w-96 flex-shrink\" />\n </div>\n </FormProvider>\n );\n};\n\nexport default Form;\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 { 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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,MAAC;AAAA;AAAA,QACC,eAAW,mBAAAC,SAAG,aAAa,SAAS;AAAA,QACpC,eAAa,gBAAQ,UAAU,QAAQ,EAAE;AAAA,QACzC;AAAA,QACA,UAAU,QAAQ,aAAa,QAAQ;AAAA,QAEtC;AAAA;AAAA,IACH;AAAA,IACA,6CAAC,2BAAgB,WAAU,oBAAmB;AAAA,KAChD,GACF;AAEJ;AAEA,IAAO,eAAQ;;;ADxGf,IAAOC,gBAAQ;","names":["Form_default","import_react","import_react_hook_form","import_classnames","slug","React","HookFormProvider","import_react","import_react","import_react_hook_form","useHookFormContext","import_jsx_runtime","useLocalStorage","Button","Card","cn","Json","import_jsx_runtime","cn","Form_default"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/Form/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Form from '
|
|
1
|
+
import { F as Form } from '../Form-Bv0R3QNk.cjs';
|
|
2
|
+
export { a as FormProps } from '../Form-Bv0R3QNk.cjs';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
3
4
|
import '@fuf-stack/veto';
|
|
4
5
|
import 'react';
|
|
@@ -6,4 +7,4 @@ import 'react-hook-form';
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
export { Form as default };
|
|
10
|
+
export { Form, Form as default };
|
package/dist/Form/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Form from '
|
|
1
|
+
import { F as Form } from '../Form-Bv0R3QNk.js';
|
|
2
|
+
export { a as FormProps } from '../Form-Bv0R3QNk.js';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
3
4
|
import '@fuf-stack/veto';
|
|
4
5
|
import 'react';
|
|
@@ -6,4 +7,4 @@ import 'react-hook-form';
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
export { Form as default };
|
|
10
|
+
export { Form, Form as default };
|
package/dist/Form/index.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Form_default
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-IQVKBQ7W.js";
|
|
8
|
-
import "../chunk-WIY7KIHU.js";
|
|
9
|
-
|
|
10
|
-
// src/Form/index.ts
|
|
11
|
-
var Form_default2 = Form_default;
|
|
2
|
+
Form_default,
|
|
3
|
+
Form_default2
|
|
4
|
+
} from "../chunk-BQUVQMFA.js";
|
|
5
|
+
import "../chunk-BCMPSLSG.js";
|
|
6
|
+
import "../chunk-V46BHM2U.js";
|
|
12
7
|
export {
|
|
8
|
+
Form_default as Form,
|
|
13
9
|
Form_default2 as default
|
|
14
10
|
};
|
|
15
11
|
//# sourceMappingURL=index.js.map
|
package/dist/Form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -3,11 +3,6 @@ import { VetoInstance } from '@fuf-stack/veto';
|
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { FieldValues, SubmitHandler } from 'react-hook-form';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* recursively removes all fields that are null or undefined before
|
|
8
|
-
* the form data is passed to the veto validation function
|
|
9
|
-
*/
|
|
10
|
-
declare const removeNullishFields: (obj: Record<string, unknown>) => any;
|
|
11
6
|
interface FormProps {
|
|
12
7
|
/** form children */
|
|
13
8
|
children: ReactNode | ReactNode[];
|
|
@@ -31,4 +26,4 @@ interface FormProps {
|
|
|
31
26
|
*/
|
|
32
27
|
declare const Form: ({ children, className, initialValues, name, onSubmit, testId, validation, validationTrigger, }: FormProps) => react_jsx_runtime.JSX.Element;
|
|
33
28
|
|
|
34
|
-
export { Form as
|
|
29
|
+
export { Form as F, type FormProps as a };
|
|
@@ -3,11 +3,6 @@ import { VetoInstance } from '@fuf-stack/veto';
|
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { FieldValues, SubmitHandler } from 'react-hook-form';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* recursively removes all fields that are null or undefined before
|
|
8
|
-
* the form data is passed to the veto validation function
|
|
9
|
-
*/
|
|
10
|
-
declare const removeNullishFields: (obj: Record<string, unknown>) => any;
|
|
11
6
|
interface FormProps {
|
|
12
7
|
/** form children */
|
|
13
8
|
children: ReactNode | ReactNode[];
|
|
@@ -31,4 +26,4 @@ interface FormProps {
|
|
|
31
26
|
*/
|
|
32
27
|
declare const Form: ({ children, className, initialValues, name, onSubmit, testId, validation, validationTrigger, }: FormProps) => react_jsx_runtime.JSX.Element;
|
|
33
28
|
|
|
34
|
-
export { Form as
|
|
29
|
+
export { Form as F, type FormProps as a };
|
package/dist/Grid/index.cjs
CHANGED
|
@@ -1,51 +1,9 @@
|
|
|
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);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
29
2
|
|
|
30
|
-
// src/Grid/index.ts
|
|
31
|
-
var Grid_exports = {};
|
|
32
|
-
__export(Grid_exports, {
|
|
33
|
-
default: () => Grid_default2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(Grid_exports);
|
|
36
3
|
|
|
37
|
-
|
|
38
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
var Grid = ({
|
|
41
|
-
children = null,
|
|
42
|
-
className = void 0,
|
|
43
|
-
testId = void 0
|
|
44
|
-
}) => {
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_classnames.default)("grid gap-6", className), "data-testid": testId, children });
|
|
46
|
-
};
|
|
47
|
-
var Grid_default = Grid;
|
|
4
|
+
var _chunkZPFKVKGVcjs = require('../chunk-ZPFKVKGV.cjs');
|
|
48
5
|
|
|
49
|
-
|
|
50
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.Grid = _chunkZPFKVKGVcjs.Grid_default; exports.default = _chunkZPFKVKGVcjs.Grid_default2;
|
|
51
9
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Grid/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/Grid/index.d.cts
CHANGED
package/dist/Grid/index.d.ts
CHANGED
package/dist/Grid/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Grid_default
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// src/Grid/index.ts
|
|
6
|
-
var Grid_default2 = Grid_default;
|
|
2
|
+
Grid_default,
|
|
3
|
+
Grid_default2
|
|
4
|
+
} from "../chunk-4MEKDDB2.js";
|
|
7
5
|
export {
|
|
6
|
+
Grid_default as Grid,
|
|
8
7
|
Grid_default2 as default
|
|
9
8
|
};
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/dist/Grid/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|