@fuf-stack/uniform 0.2.2 → 0.2.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 +5 -3
- package/dist/Form/index.js +4 -2
- package/dist/Grid/index.cjs +4 -2
- package/dist/Grid/index.js +3 -1
- package/dist/SubmitButton/index.cjs +5 -3
- package/dist/SubmitButton/index.js +4 -2
- package/dist/{chunk-TEJGV6NC.js → chunk-73CQ3KWD.js} +10 -4
- package/dist/{chunk-TEJGV6NC.js.map → chunk-73CQ3KWD.js.map} +1 -1
- package/dist/{chunk-WQRM7G4C.cjs → chunk-AAESGATO.cjs} +15 -8
- package/dist/chunk-AAESGATO.cjs.map +1 -0
- package/dist/chunk-AT5DS6MS.cjs +31 -0
- package/dist/chunk-AT5DS6MS.cjs.map +1 -0
- package/dist/{chunk-BCMPSLSG.js → chunk-BQTJHSDU.js} +14 -7
- package/dist/{chunk-BCMPSLSG.js.map → chunk-BQTJHSDU.js.map} +1 -1
- package/dist/{chunk-22AA557I.cjs → chunk-DBNZWU3T.cjs} +12 -5
- package/dist/chunk-DBNZWU3T.cjs.map +1 -0
- package/dist/{chunk-QTL5FREE.cjs → chunk-HW65ROPB.cjs} +10 -4
- package/dist/chunk-HW65ROPB.cjs.map +1 -0
- package/dist/chunk-LAHYQUKQ.cjs +27 -0
- package/dist/chunk-LAHYQUKQ.cjs.map +1 -0
- package/dist/chunk-LMMDXQ4L.cjs +3170 -0
- package/dist/chunk-LMMDXQ4L.cjs.map +1 -0
- package/dist/chunk-LQ2VYIYD.js +31 -0
- package/dist/chunk-LQ2VYIYD.js.map +1 -0
- package/dist/chunk-RBXONCYN.js +3170 -0
- package/dist/chunk-RBXONCYN.js.map +1 -0
- package/dist/{chunk-XUKBLFTR.cjs → chunk-RU72JRAY.cjs} +11 -5
- package/dist/chunk-RU72JRAY.cjs.map +1 -0
- package/dist/{chunk-4BELEHDQ.cjs → chunk-UFEO2WD4.cjs} +28 -21
- package/dist/chunk-UFEO2WD4.cjs.map +1 -0
- package/dist/{chunk-FNVT6LS4.js → chunk-WT2BR5B5.js} +11 -4
- package/dist/{chunk-FNVT6LS4.js.map → chunk-WT2BR5B5.js.map} +1 -1
- package/dist/{chunk-6XKDXQ4A.js → chunk-YMSVB2DX.js} +27 -20
- package/dist/{chunk-6XKDXQ4A.js.map → chunk-YMSVB2DX.js.map} +1 -1
- package/dist/chunk-YNN5AVDW.js +27 -0
- package/dist/{chunk-4MEKDDB2.js.map → chunk-YNN5AVDW.js.map} +1 -1
- package/dist/{chunk-DBLODROX.js → chunk-ZWSYKQT7.js} +10 -4
- package/dist/{chunk-DBLODROX.js.map → chunk-ZWSYKQT7.js.map} +1 -1
- package/dist/helpers/index.cjs +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/hooks/index.cjs +4 -2
- package/dist/hooks/index.js +3 -1
- package/dist/index.cjs +9 -7
- package/dist/index.js +8 -6
- package/dist/partials/FieldCopyTestIdButton/index.cjs +4 -2
- package/dist/partials/FieldCopyTestIdButton/index.js +3 -1
- package/dist/partials/FieldValidationError/index.cjs +4 -2
- package/dist/partials/FieldValidationError/index.js +3 -1
- package/package.json +4 -4
- package/dist/chunk-22AA557I.cjs.map +0 -1
- package/dist/chunk-4BELEHDQ.cjs.map +0 -1
- package/dist/chunk-4MEKDDB2.js +0 -20
- package/dist/chunk-QTL5FREE.cjs.map +0 -1
- package/dist/chunk-WQRM7G4C.cjs.map +0 -1
- package/dist/chunk-XUKBLFTR.cjs.map +0 -1
- package/dist/chunk-ZPFKVKGV.cjs +0 -20
- package/dist/chunk-ZPFKVKGV.cjs.map +0 -1
package/dist/Form/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
4
|
+
var _chunkUFEO2WD4cjs = require('../chunk-UFEO2WD4.cjs');
|
|
5
|
+
require('../chunk-AAESGATO.cjs');
|
|
6
6
|
require('../chunk-BBB4FEY6.cjs');
|
|
7
|
+
require('../chunk-LMMDXQ4L.cjs');
|
|
8
|
+
require('../chunk-AT5DS6MS.cjs');
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
exports.Form =
|
|
12
|
+
exports.Form = _chunkUFEO2WD4cjs.Form_default; exports.default = _chunkUFEO2WD4cjs.Form_default2;
|
|
11
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Form/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Form_default,
|
|
3
3
|
Form_default2
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-YMSVB2DX.js";
|
|
5
|
+
import "../chunk-BQTJHSDU.js";
|
|
6
6
|
import "../chunk-V46BHM2U.js";
|
|
7
|
+
import "../chunk-RBXONCYN.js";
|
|
8
|
+
import "../chunk-LQ2VYIYD.js";
|
|
7
9
|
export {
|
|
8
10
|
Form_default as Form,
|
|
9
11
|
Form_default2 as default
|
package/dist/Grid/index.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkLAHYQUKQcjs = require('../chunk-LAHYQUKQ.cjs');
|
|
5
|
+
require('../chunk-LMMDXQ4L.cjs');
|
|
6
|
+
require('../chunk-AT5DS6MS.cjs');
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
exports.Grid =
|
|
10
|
+
exports.Grid = _chunkLAHYQUKQcjs.Grid_default; exports.default = _chunkLAHYQUKQcjs.Grid_default2;
|
|
9
11
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Grid/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
4
|
+
var _chunkRU72JRAYcjs = require('../chunk-RU72JRAY.cjs');
|
|
5
|
+
require('../chunk-AAESGATO.cjs');
|
|
6
6
|
require('../chunk-BBB4FEY6.cjs');
|
|
7
|
+
require('../chunk-LMMDXQ4L.cjs');
|
|
8
|
+
require('../chunk-AT5DS6MS.cjs');
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
exports.SubmitButton =
|
|
12
|
+
exports.SubmitButton = _chunkRU72JRAYcjs.SubmitButton_default; exports.default = _chunkRU72JRAYcjs.SubmitButton_default2;
|
|
11
13
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SubmitButton_default,
|
|
3
3
|
SubmitButton_default2
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-73CQ3KWD.js";
|
|
5
|
+
import "../chunk-BQTJHSDU.js";
|
|
6
6
|
import "../chunk-V46BHM2U.js";
|
|
7
|
+
import "../chunk-RBXONCYN.js";
|
|
8
|
+
import "../chunk-LQ2VYIYD.js";
|
|
7
9
|
export {
|
|
8
10
|
SubmitButton_default as SubmitButton,
|
|
9
11
|
SubmitButton_default2 as default
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFormContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BQTJHSDU.js";
|
|
4
4
|
import {
|
|
5
5
|
slugify
|
|
6
6
|
} from "./chunk-V46BHM2U.js";
|
|
7
|
+
import {
|
|
8
|
+
require_jsx_runtime
|
|
9
|
+
} from "./chunk-RBXONCYN.js";
|
|
10
|
+
import {
|
|
11
|
+
__toESM
|
|
12
|
+
} from "./chunk-LQ2VYIYD.js";
|
|
7
13
|
|
|
8
14
|
// src/SubmitButton/SubmitButton.tsx
|
|
9
15
|
import cn from "classnames";
|
|
10
16
|
import { Button } from "@fuf-stack/pixels";
|
|
11
|
-
|
|
17
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
12
18
|
var SubmitButton = ({
|
|
13
19
|
children = "Submit",
|
|
14
20
|
className = void 0,
|
|
@@ -21,7 +27,7 @@ var SubmitButton = ({
|
|
|
21
27
|
const {
|
|
22
28
|
formState: { isValid, isSubmitting, isValidating }
|
|
23
29
|
} = useFormContext();
|
|
24
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
25
31
|
Button,
|
|
26
32
|
{
|
|
27
33
|
className: cn(className),
|
|
@@ -45,4 +51,4 @@ export {
|
|
|
45
51
|
SubmitButton_default,
|
|
46
52
|
SubmitButton_default2
|
|
47
53
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-73CQ3KWD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/SubmitButton/SubmitButton.tsx","../src/SubmitButton/index.ts"],"sourcesContent":["import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\nimport { Button } from '@fuf-stack/pixels';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\n\nexport interface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: 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 /** size of the button */\n size?: ButtonProps['size'];\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 size = 'md',\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 size={size}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n","import SubmitButton from './SubmitButton';\n\nexport type { SubmitButtonProps } from './SubmitButton';\n\nexport { 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';\nimport type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\nimport { Button } from '@fuf-stack/pixels';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\n\nexport interface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: 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 /** size of the button */\n size?: ButtonProps['size'];\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 size = 'md',\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 size={size}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n","import SubmitButton from './SubmitButton';\n\nexport type { SubmitButtonProps } from './SubmitButton';\n\nexport { SubmitButton };\n\nexport default SubmitButton;\n"],"mappings":";;;;;;;;;;;;;;AAGA,OAAO,QAAQ;AAEf,SAAS,cAAc;AAuCnB;AAdJ,IAAM,eAAe,CAAC;AAAA,EACpB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,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;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,uBAAQ;;;ACrDf,IAAOA,wBAAQ;","names":["SubmitButton_default"]}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
2
2
|
|
|
3
3
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkLMMDXQ4Lcjs = require('./chunk-LMMDXQ4L.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkAT5DS6MScjs = require('./chunk-AT5DS6MS.cjs');
|
|
11
|
+
|
|
5
12
|
// src/hooks/useFormContext/useFormContext.ts
|
|
6
|
-
var
|
|
13
|
+
var import_react2 = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_react.call(void 0, ), 1);
|
|
7
14
|
var _reacthookform = require('react-hook-form');
|
|
8
15
|
|
|
9
16
|
// src/Form/subcomponents/FormContext.tsx
|
|
17
|
+
var import_react = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_react.call(void 0, ), 1);
|
|
18
|
+
var import_jsx_runtime = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
13
|
-
var ValidationSchemaContext = _react2.default.createContext(void 0);
|
|
20
|
+
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
14
21
|
var FormProvider = ({
|
|
15
22
|
children,
|
|
16
23
|
validation = void 0,
|
|
17
24
|
...hookFormProps
|
|
18
25
|
}) => {
|
|
19
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_reacthookform.FormProvider, { ...hookFormProps, children }) });
|
|
20
27
|
};
|
|
21
28
|
var FormContext_default = FormProvider;
|
|
22
29
|
|
|
@@ -58,7 +65,7 @@ var useFormContext = () => {
|
|
|
58
65
|
getFieldState: getFieldStateOrig,
|
|
59
66
|
...otherMethods
|
|
60
67
|
} = _reacthookform.useFormContext.call(void 0, );
|
|
61
|
-
const validation =
|
|
68
|
+
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
62
69
|
const getFieldState = (name, testId) => {
|
|
63
70
|
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
64
71
|
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
@@ -84,4 +91,4 @@ var useFormContext = () => {
|
|
|
84
91
|
|
|
85
92
|
|
|
86
93
|
exports.FormContext_default = FormContext_default; exports.recursiveFieldKeySearch = recursiveFieldKeySearch; exports.useFormContext = useFormContext;
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-AAESGATO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx"],"names":["import_react","React"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,gBAA2B;AAC3B,SAAS,kBAAkB,0BAA0B;;;ACDrD,mBAAkB;AAqBZ;AApBN,SAAS,gBAAgB,wBAAwB;AAE1C,IAAM,0BAA0B,aAAAC,QAAM,cAE3C,MAAS;AASX,IAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,MAAyB;AACvB,SACE,4CAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACvC,sDAAC,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,iBAAa,0BAAW,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","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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.__commonJS = __commonJS; exports.__toESM = __toESM;
|
|
31
|
+
//# sourceMappingURL=chunk-AT5DS6MS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
slugify
|
|
3
3
|
} from "./chunk-V46BHM2U.js";
|
|
4
|
+
import {
|
|
5
|
+
require_jsx_runtime,
|
|
6
|
+
require_react
|
|
7
|
+
} from "./chunk-RBXONCYN.js";
|
|
8
|
+
import {
|
|
9
|
+
__toESM
|
|
10
|
+
} from "./chunk-LQ2VYIYD.js";
|
|
4
11
|
|
|
5
12
|
// src/hooks/useFormContext/useFormContext.ts
|
|
6
|
-
|
|
13
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
7
14
|
import { useFormContext as useHookFormContext } from "react-hook-form";
|
|
8
15
|
|
|
9
16
|
// src/Form/subcomponents/FormContext.tsx
|
|
10
|
-
|
|
17
|
+
var import_react = __toESM(require_react(), 1);
|
|
18
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
11
19
|
import { FormProvider as HookFormProvider } from "react-hook-form";
|
|
12
|
-
|
|
13
|
-
var ValidationSchemaContext = React.createContext(void 0);
|
|
20
|
+
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
14
21
|
var FormProvider = ({
|
|
15
22
|
children,
|
|
16
23
|
validation = void 0,
|
|
17
24
|
...hookFormProps
|
|
18
25
|
}) => {
|
|
19
|
-
return /* @__PURE__ */ jsx(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ jsx(HookFormProvider, { ...hookFormProps, children }) });
|
|
26
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HookFormProvider, { ...hookFormProps, children }) });
|
|
20
27
|
};
|
|
21
28
|
var FormContext_default = FormProvider;
|
|
22
29
|
|
|
@@ -58,7 +65,7 @@ var useFormContext = () => {
|
|
|
58
65
|
getFieldState: getFieldStateOrig,
|
|
59
66
|
...otherMethods
|
|
60
67
|
} = useHookFormContext();
|
|
61
|
-
const validation = useContext(ValidationSchemaContext);
|
|
68
|
+
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
62
69
|
const getFieldState = (name, testId) => {
|
|
63
70
|
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
64
71
|
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
@@ -84,4 +91,4 @@ export {
|
|
|
84
91
|
recursiveFieldKeySearch,
|
|
85
92
|
useFormContext
|
|
86
93
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-BQTJHSDU.js.map
|
|
@@ -1 +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":"
|
|
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,IAAAA,gBAA2B;AAC3B,SAAS,kBAAkB,0BAA0B;;;ACDrD,mBAAkB;AAqBZ;AApBN,SAAS,gBAAgB,wBAAwB;AAE1C,IAAM,0BAA0B,aAAAC,QAAM,cAE3C,MAAS;AASX,IAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,MAAyB;AACvB,SACE,4CAAC,wBAAwB,UAAxB,EAAiC,OAAO,YACvC,sDAAC,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,iBAAa,0BAAW,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":["import_react","React"]}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkLMMDXQ4Lcjs = require('./chunk-LMMDXQ4L.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkAT5DS6MScjs = require('./chunk-AT5DS6MS.cjs');
|
|
7
|
+
|
|
8
|
+
// src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
9
|
+
var import_jsx_runtime = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
2
10
|
var _fa6 = require('react-icons/fa6');
|
|
3
11
|
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
4
12
|
var _pixels = require('@fuf-stack/pixels');
|
|
5
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
6
13
|
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
7
14
|
var FieldCopyTestIdButton = ({
|
|
8
15
|
className = void 0,
|
|
@@ -17,13 +24,13 @@ var FieldCopyTestIdButton = ({
|
|
|
17
24
|
if (!debug) {
|
|
18
25
|
return null;
|
|
19
26
|
}
|
|
20
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
21
28
|
_pixels.Button,
|
|
22
29
|
{
|
|
23
30
|
className: _classnames2.default.call(void 0, className, "pointer-events-auto"),
|
|
24
31
|
variant: "light",
|
|
25
32
|
onClick: copyToClipboard,
|
|
26
|
-
icon: /* @__PURE__ */
|
|
33
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_fa6.FaBullseye, {}),
|
|
27
34
|
size: "sm"
|
|
28
35
|
}
|
|
29
36
|
);
|
|
@@ -37,4 +44,4 @@ var FieldCopyTestIdButton_default2 = FieldCopyTestIdButton_default;
|
|
|
37
44
|
|
|
38
45
|
|
|
39
46
|
exports.FieldCopyTestIdButton_default = FieldCopyTestIdButton_default; exports.FieldCopyTestIdButton_default2 = FieldCopyTestIdButton_default2;
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-DBNZWU3T.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../src/partials/FieldCopyTestIdButton/index.ts"],"names":["FieldCopyTestIdButton_default"],"mappings":";;;;;;;;AAkCY;AAlCZ,SAAS,kBAAkB;AAE3B,OAAO,QAAQ;AAEf,SAAS,QAAQ,uBAAuB;AAOxC,IAAM,yBAAyB;AAE/B,IAAM,wBAAwB,CAAC;AAAA,EAC7B,YAAY;AAAA,EACZ;AACF,MAAkC;AAChC,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,4CAAC,cAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;;;ACjCf,IAAOA,iCAAQ","sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport { Button, useLocalStorage } from '@fuf-stack/pixels';\n\nexport interface FieldCopyTestIdButtonProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst FieldCopyTestIdButton = ({\n className = undefined,\n testId,\n}: FieldCopyTestIdButtonProps) => {\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 FieldCopyTestIdButton;\n","import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport type { FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton';\n\nexport { FieldCopyTestIdButton };\n\nexport default FieldCopyTestIdButton;\n"]}
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
var _chunkLMMDXQ4Lcjs = require('./chunk-LMMDXQ4L.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkAT5DS6MScjs = require('./chunk-AT5DS6MS.cjs');
|
|
10
|
+
|
|
5
11
|
// src/partials/FieldValidationError/FieldValidationError.tsx
|
|
6
|
-
var
|
|
12
|
+
var import_jsx_runtime = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
7
13
|
var FieldValidationError = ({
|
|
8
14
|
error,
|
|
9
15
|
testId = void 0
|
|
@@ -21,14 +27,14 @@ var FieldValidationError = ({
|
|
|
21
27
|
const errorArray = JSON.stringify(tmp_errors) !== "[]" ? tmp_errors : error;
|
|
22
28
|
const errorStrings = errorArray.map((e) => e.message);
|
|
23
29
|
const ariaString = `Error: ${errorStrings.join("\n")}`;
|
|
24
|
-
return /* @__PURE__ */
|
|
30
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
25
31
|
"ul",
|
|
26
32
|
{
|
|
27
33
|
"data-testid": _chunkBBB4FEY6cjs.slugify.call(void 0, testId || errorStrings.join()),
|
|
28
34
|
"aria-label": ariaString,
|
|
29
35
|
children: errorStrings.map((errorString, i) => (
|
|
30
36
|
// eslint-disable-next-line react/no-array-index-key
|
|
31
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: errorString }) }, `error_${i}`)
|
|
32
38
|
))
|
|
33
39
|
}
|
|
34
40
|
);
|
|
@@ -42,4 +48,4 @@ var FieldValidationError_default2 = FieldValidationError_default;
|
|
|
42
48
|
|
|
43
49
|
|
|
44
50
|
exports.FieldValidationError_default = FieldValidationError_default; exports.FieldValidationError_default2 = FieldValidationError_default2;
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-HW65ROPB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"names":["FieldValidationError_default"],"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,QAAQ,UAAU,aAAa,KAAK,CAAC;AAAA,MAClD,cAAY;AAAA,MAEX,uBAAa,IAAI,CAAC,aAAqB;AAAA;AAAA,QAEtC,4CAAC,QACC,sDAAC,SAAK,uBAAY,KADX,SAAS,CAAC,EAEnB;AAAA,OACD;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,+BAAQ;;;AC3Cf,IAAOA,gCAAQ","sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport { slugify } from '../../helpers';\n\nexport interface 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","import FieldValidationError from './FieldValidationError';\n\nexport type { FieldValidationErrorProps } from './FieldValidationError';\n\nexport { FieldValidationError };\n\nexport default FieldValidationError;\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkLMMDXQ4Lcjs = require('./chunk-LMMDXQ4L.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkAT5DS6MScjs = require('./chunk-AT5DS6MS.cjs');
|
|
7
|
+
|
|
8
|
+
// src/Grid/Grid.tsx
|
|
9
|
+
var import_jsx_runtime = _chunkAT5DS6MScjs.__toESM.call(void 0, _chunkLMMDXQ4Lcjs.require_jsx_runtime.call(void 0, ), 1);
|
|
10
|
+
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
11
|
+
var Grid = ({
|
|
12
|
+
children = null,
|
|
13
|
+
className = void 0,
|
|
14
|
+
testId = void 0
|
|
15
|
+
}) => {
|
|
16
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: _classnames2.default.call(void 0, "grid gap-6", className), "data-testid": testId, children });
|
|
17
|
+
};
|
|
18
|
+
var Grid_default = Grid;
|
|
19
|
+
|
|
20
|
+
// src/Grid/index.ts
|
|
21
|
+
var Grid_default2 = Grid_default;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.Grid_default = Grid_default; exports.Grid_default2 = Grid_default2;
|
|
27
|
+
//# sourceMappingURL=chunk-LAHYQUKQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Grid/Grid.tsx","../src/Grid/index.ts"],"names":["Grid_default"],"mappings":";;;;;;;;AAsBI;AApBJ,OAAO,QAAQ;AAcf,IAAM,OAAO,CAAC;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,SAAS;AACX,MAAiB;AACf,SACE,4CAAC,SAAI,WAAW,GAAG,cAAc,SAAS,GAAG,eAAa,QACvD,UACH;AAEJ;AAEA,IAAO,eAAQ;;;ACtBf,IAAOA,gBAAQ","sourcesContent":["import type { ReactNode } from 'react';\n\nimport cn from 'classnames';\n\nexport interface 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 type { GridProps } from './Grid';\n\nexport { Grid };\n\nexport default Grid;\n"]}
|