@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
package/dist/Grid/index.cjs
CHANGED
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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/index.ts
|
|
31
|
-
var Grid_exports = {};
|
|
32
|
-
__export(Grid_exports, {
|
|
33
|
-
default: () => Grid_default2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(Grid_exports);
|
|
36
|
-
|
|
37
|
-
// src/Grid/Grid.tsx
|
|
38
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/Grid/Grid.tsx
|
|
2
|
+
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
3
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
40
4
|
var Grid = ({
|
|
41
5
|
children = null,
|
|
42
6
|
className = void 0,
|
|
43
7
|
testId = void 0
|
|
44
8
|
}) => {
|
|
45
|
-
return /* @__PURE__ */ (0,
|
|
9
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _classnames2.default.call(void 0, "grid gap-6", className), "data-testid": testId, children });
|
|
46
10
|
};
|
|
47
11
|
var Grid_default = Grid;
|
|
48
12
|
|
|
49
13
|
// src/Grid/index.ts
|
|
50
14
|
var Grid_default2 = Grid_default;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
exports.default = Grid_default2;
|
|
51
18
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Grid/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Grid/
|
|
1
|
+
{"version":3,"sources":["../../src/Grid/Grid.tsx","../../src/Grid/index.ts"],"names":["Grid_default"],"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;;;AC1Bf,IAAOA,gBAAQ","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","import Grid from './Grid';\n\nexport default Grid;\n"]}
|
package/dist/Grid/index.d.cts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'react
|
|
3
|
-
import 'react';
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
5
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;
|
|
6
16
|
|
|
7
17
|
export { Grid as default };
|
package/dist/Grid/index.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'react
|
|
3
|
-
import 'react';
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
5
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;
|
|
6
16
|
|
|
7
17
|
export { Grid as default };
|
package/dist/Grid/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from "
|
|
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;
|
|
4
12
|
|
|
5
13
|
// src/Grid/index.ts
|
|
6
14
|
var Grid_default2 = Grid_default;
|
package/dist/Grid/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Grid/index.ts"],"sourcesContent":["import Grid from './Grid';\n\nexport default Grid;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Grid/Grid.tsx","../../src/Grid/index.ts"],"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","import Grid from './Grid';\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;;;AC1Bf,IAAOA,gBAAQ;","names":["Grid_default"]}
|
|
@@ -1,132 +1,14 @@
|
|
|
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
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
2
|
|
|
59
|
-
|
|
60
|
-
var import_react2 = require("react");
|
|
61
|
-
var import_react_hook_form2 = require("react-hook-form");
|
|
3
|
+
var _chunkWQRM7G4Ccjs = require('../chunk-WQRM7G4C.cjs');
|
|
62
4
|
|
|
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
5
|
|
|
69
|
-
|
|
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
|
-
};
|
|
6
|
+
var _chunkBBB4FEY6cjs = require('../chunk-BBB4FEY6.cjs');
|
|
127
7
|
|
|
128
8
|
// src/SubmitButton/SubmitButton.tsx
|
|
129
|
-
var
|
|
9
|
+
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
10
|
+
var _Button = require('@fuf-stack/pixels/Button'); var _Button2 = _interopRequireDefault(_Button);
|
|
11
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
130
12
|
var SubmitButton = ({
|
|
131
13
|
children = "Submit",
|
|
132
14
|
className = void 0,
|
|
@@ -137,13 +19,13 @@ var SubmitButton = ({
|
|
|
137
19
|
}) => {
|
|
138
20
|
const {
|
|
139
21
|
formState: { isValid, isSubmitting, isValidating }
|
|
140
|
-
} = useFormContext();
|
|
141
|
-
return /* @__PURE__ */ (0,
|
|
142
|
-
|
|
22
|
+
} = _chunkWQRM7G4Ccjs.useFormContext.call(void 0, );
|
|
23
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
24
|
+
_Button2.default,
|
|
143
25
|
{
|
|
144
|
-
className: (0,
|
|
26
|
+
className: _classnames2.default.call(void 0, className),
|
|
145
27
|
color,
|
|
146
|
-
testId:
|
|
28
|
+
testId: _chunkBBB4FEY6cjs.slugify.call(void 0, testId),
|
|
147
29
|
disabled: !isValid || isSubmitting || isValidating,
|
|
148
30
|
loading,
|
|
149
31
|
onClick,
|
|
@@ -156,4 +38,7 @@ var SubmitButton_default = SubmitButton;
|
|
|
156
38
|
|
|
157
39
|
// src/SubmitButton/index.ts
|
|
158
40
|
var SubmitButton_default2 = SubmitButton_default;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
exports.default = SubmitButton_default2;
|
|
159
44
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/SubmitButton/
|
|
1
|
+
{"version":3,"sources":["../../src/SubmitButton/SubmitButton.tsx","../../src/SubmitButton/index.ts"],"names":["SubmitButton_default"],"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,QAAQ,MAAM;AAAA,MACtB,UAAU,CAAC,WAAW,gBAAgB;AAAA,MACtC;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,uBAAQ;;;ACrDf,IAAOA,wBAAQ","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';\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 SubmitButton from './SubmitButton';\n\nexport default SubmitButton;\n"]}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'react';
|
|
5
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@fuf-stack/pixels/Button';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
6
4
|
|
|
5
|
+
interface SubmitButtonProps {
|
|
6
|
+
/** child components */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/** CSS class name */
|
|
9
|
+
className?: string | string[];
|
|
10
|
+
/** color of the button */
|
|
11
|
+
color?: ButtonProps['color'];
|
|
12
|
+
/** If set loading animation is shown */
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/** function called when the button is pressed. */
|
|
15
|
+
onClick?: ButtonProps['onClick'];
|
|
16
|
+
/** HTML data-testid attribute used in e2e tests */
|
|
17
|
+
testId?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* From SubmitButton
|
|
21
|
+
*/
|
|
22
|
+
declare const SubmitButton: ({ children, className, color, loading, onClick, testId, }: SubmitButtonProps) => react_jsx_runtime.JSX.Element;
|
|
7
23
|
|
|
8
24
|
export { SubmitButton as default };
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'react';
|
|
5
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@fuf-stack/pixels/Button';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
6
4
|
|
|
5
|
+
interface SubmitButtonProps {
|
|
6
|
+
/** child components */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/** CSS class name */
|
|
9
|
+
className?: string | string[];
|
|
10
|
+
/** color of the button */
|
|
11
|
+
color?: ButtonProps['color'];
|
|
12
|
+
/** If set loading animation is shown */
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/** function called when the button is pressed. */
|
|
15
|
+
onClick?: ButtonProps['onClick'];
|
|
16
|
+
/** HTML data-testid attribute used in e2e tests */
|
|
17
|
+
testId?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* From SubmitButton
|
|
21
|
+
*/
|
|
22
|
+
declare const SubmitButton: ({ children, className, color, loading, onClick, testId, }: SubmitButtonProps) => react_jsx_runtime.JSX.Element;
|
|
7
23
|
|
|
8
24
|
export { SubmitButton as default };
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
useFormContext
|
|
3
|
+
} from "../chunk-BCMPSLSG.js";
|
|
4
|
+
import {
|
|
5
|
+
slugify
|
|
6
|
+
} from "../chunk-V46BHM2U.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(testId),
|
|
29
|
+
disabled: !isValid || isSubmitting || isValidating,
|
|
30
|
+
loading,
|
|
31
|
+
onClick,
|
|
32
|
+
type: "submit",
|
|
33
|
+
children
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
var SubmitButton_default = SubmitButton;
|
|
8
38
|
|
|
9
39
|
// src/SubmitButton/index.ts
|
|
10
40
|
var SubmitButton_default2 = SubmitButton_default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/SubmitButton/index.ts"],"sourcesContent":["import SubmitButton from './SubmitButton';\n\nexport default SubmitButton;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/SubmitButton/SubmitButton.tsx","../../src/SubmitButton/index.ts"],"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';\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 SubmitButton from './SubmitButton';\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,QAAQ,MAAM;AAAA,MACtB,UAAU,CAAC,WAAW,gBAAgB;AAAA,MACtC;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,uBAAQ;;;ACrDf,IAAOA,wBAAQ;","names":["SubmitButton_default"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/slugify/slugify.ts
|
|
2
|
+
var _slug = require('slug'); var _slug2 = _interopRequireDefault(_slug);
|
|
3
|
+
var slugify = (string, options) => {
|
|
4
|
+
const replacement = _optionalChain([options, 'optionalAccess', _ => _.replacement]) || "_";
|
|
5
|
+
return _slug2.default.call(void 0, string, {
|
|
6
|
+
..._slug2.default.defaults.modes.rfc3986,
|
|
7
|
+
charmap: {
|
|
8
|
+
..._slug2.default.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
|
+
|
|
20
|
+
|
|
21
|
+
exports.slugify = slugify;
|
|
22
|
+
//# sourceMappingURL=chunk-BBB4FEY6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/slugify/slugify.ts"],"names":[],"mappings":";AAIA,OAAO,UAAU;AAEV,IAAM,UAAU,CAAC,QAAgB,YAA0B;AAChE,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","sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\nexport const slugify = (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"]}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
slugify_default
|
|
6
|
-
} from "./chunk-WIY7KIHU.js";
|
|
2
|
+
slugify
|
|
3
|
+
} from "./chunk-V46BHM2U.js";
|
|
7
4
|
|
|
8
5
|
// src/hooks/useFormContext/useFormContext.ts
|
|
9
6
|
import { useContext } from "react";
|
|
10
7
|
import { useFormContext as useHookFormContext } from "react-hook-form";
|
|
8
|
+
|
|
9
|
+
// src/Form/subcomponents/FormContext.tsx
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { FormProvider as HookFormProvider } from "react-hook-form";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
var ValidationSchemaContext = React.createContext(void 0);
|
|
14
|
+
var FormProvider = ({
|
|
15
|
+
children,
|
|
16
|
+
validation = void 0,
|
|
17
|
+
...hookFormProps
|
|
18
|
+
}) => {
|
|
19
|
+
return /* @__PURE__ */ jsx(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(HookFormProvider, { ...hookFormProps, children }) });
|
|
20
|
+
};
|
|
21
|
+
var FormContext_default = FormProvider;
|
|
22
|
+
|
|
23
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
11
24
|
var recursiveSearchInnerType = (schema) => {
|
|
12
25
|
if (schema?._def?.innerType) {
|
|
13
26
|
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
@@ -55,7 +68,7 @@ var useFormContext = () => {
|
|
|
55
68
|
error,
|
|
56
69
|
// TODO: change to correct type @Hannes ;)
|
|
57
70
|
required,
|
|
58
|
-
testId:
|
|
71
|
+
testId: slugify(testId || name)
|
|
59
72
|
};
|
|
60
73
|
};
|
|
61
74
|
return {
|
|
@@ -67,7 +80,8 @@ var useFormContext = () => {
|
|
|
67
80
|
};
|
|
68
81
|
|
|
69
82
|
export {
|
|
83
|
+
FormContext_default,
|
|
70
84
|
recursiveFieldKeySearch,
|
|
71
85
|
useFormContext
|
|
72
86
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-BCMPSLSG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx"],"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';\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":";;;;;AAGA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;;;ACDrD,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;;;ADnBf,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,QAAQ,UAAU,IAAI;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// src/helpers/slugify.ts
|
|
1
|
+
// src/helpers/slugify/slugify.ts
|
|
2
2
|
import slug from "slug";
|
|
3
|
-
var
|
|
3
|
+
var slugify = (string, options) => {
|
|
4
4
|
const replacement = options?.replacement || "_";
|
|
5
5
|
return slug(string, {
|
|
6
6
|
...slug.defaults.modes.rfc3986,
|
|
@@ -17,6 +17,6 @@ var slugify_default = (string, options) => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
slugify
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-V46BHM2U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/slugify/slugify.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\nexport const slugify = (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":";AAIA,OAAO,UAAU;AAEV,IAAM,UAAU,CAAC,QAAgB,YAA0B;AAChE,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":[]}
|