@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
|
+
|
|
3
|
+
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
4
|
+
|
|
5
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
6
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
7
|
+
var _reacthookform = require('react-hook-form');
|
|
8
|
+
|
|
9
|
+
// src/Form/subcomponents/FormContext.tsx
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
13
|
+
var ValidationSchemaContext = _react2.default.createContext(void 0);
|
|
14
|
+
var FormProvider = ({
|
|
15
|
+
children,
|
|
16
|
+
validation = void 0,
|
|
17
|
+
...hookFormProps
|
|
18
|
+
}) => {
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ValidationSchemaContext.Provider, { value: validation, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacthookform.FormProvider, { ...hookFormProps, children }) });
|
|
20
|
+
};
|
|
21
|
+
var FormContext_default = FormProvider;
|
|
22
|
+
|
|
23
|
+
// src/hooks/useFormContext/useFormContext.ts
|
|
24
|
+
var recursiveSearchInnerType = (schema) => {
|
|
25
|
+
if (_optionalChain([schema, 'optionalAccess', _ => _._def, 'optionalAccess', _2 => _2.innerType])) {
|
|
26
|
+
if (_optionalChain([schema, 'optionalAccess', _3 => _3._def, 'optionalAccess', _4 => _4.innerType, 'optionalAccess', _5 => _5._def, 'optionalAccess', _6 => _6.typeName]) === "ZodOptional") {
|
|
27
|
+
return _optionalChain([schema, 'optionalAccess', _7 => _7._def, 'optionalAccess', _8 => _8.innerType, 'optionalAccess', _9 => _9._def, 'optionalAccess', _10 => _10.typeName]) !== "ZodOptional";
|
|
28
|
+
}
|
|
29
|
+
return recursiveSearchInnerType(_optionalChain([schema, 'optionalAccess', _11 => _11._def, 'optionalAccess', _12 => _12.innerType]));
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
var recursiveFieldKeySearch = (schema, path) => {
|
|
34
|
+
const [current, ...rest] = path;
|
|
35
|
+
let currentSchema = schema;
|
|
36
|
+
if (_optionalChain([schema, 'optionalAccess', _13 => _13._def, 'optionalAccess', _14 => _14.typeName]) === "ZodOptional") {
|
|
37
|
+
currentSchema = schema.unwrap();
|
|
38
|
+
} else if (_optionalChain([schema, 'optionalAccess', _15 => _15._def, 'optionalAccess', _16 => _16.typeName]) === "ZodEffects") {
|
|
39
|
+
return recursiveFieldKeySearch(_optionalChain([schema, 'access', _17 => _17._def, 'optionalAccess', _18 => _18.schema]), path);
|
|
40
|
+
}
|
|
41
|
+
if (_optionalChain([currentSchema, 'optionalAccess', _19 => _19._def, 'optionalAccess', _20 => _20.typeName]) === "ZodIntersection") {
|
|
42
|
+
return (_optionalChain([currentSchema, 'access', _21 => _21._def, 'access', _22 => _22.left, 'optionalAccess', _23 => _23.schema]) ? recursiveFieldKeySearch(currentSchema._def.left.schema, path) : recursiveFieldKeySearch(currentSchema._def.left, path)) || (_optionalChain([currentSchema, 'access', _24 => _24._def, 'access', _25 => _25.right, 'optionalAccess', _26 => _26.schema]) ? recursiveFieldKeySearch(currentSchema._def.right.schema, path) : recursiveFieldKeySearch(currentSchema._def.right, path));
|
|
43
|
+
}
|
|
44
|
+
const shape = _nullishCoalesce(_optionalChain([currentSchema, 'optionalAccess', _27 => _27.shape]), () => ( _optionalChain([currentSchema, 'optionalAccess', _28 => _28.element, 'optionalAccess', _29 => _29.shape])));
|
|
45
|
+
if (shape && shape[current]) {
|
|
46
|
+
if (rest.length === 0) {
|
|
47
|
+
return _optionalChain([shape, 'access', _30 => _30[current], 'optionalAccess', _31 => _31._def, 'optionalAccess', _32 => _32.typeName]) !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
48
|
+
}
|
|
49
|
+
return recursiveFieldKeySearch(shape[current], rest);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
var useFormContext = () => {
|
|
54
|
+
const {
|
|
55
|
+
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
56
|
+
// for getFieldState a subscription to formState properties is needed!
|
|
57
|
+
formState,
|
|
58
|
+
getFieldState: getFieldStateOrig,
|
|
59
|
+
...otherMethods
|
|
60
|
+
} = _reacthookform.useFormContext.call(void 0, );
|
|
61
|
+
const validation = _react.useContext.call(void 0, ValidationSchemaContext);
|
|
62
|
+
const getFieldState = (name, testId) => {
|
|
63
|
+
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
64
|
+
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
65
|
+
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
66
|
+
return {
|
|
67
|
+
...rest,
|
|
68
|
+
error,
|
|
69
|
+
// TODO: change to correct type @Hannes ;)
|
|
70
|
+
required,
|
|
71
|
+
testId: _chunkBBB4FEY6cjs.slugify.call(void 0, testId || name)
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
...otherMethods,
|
|
76
|
+
getFieldState,
|
|
77
|
+
validation,
|
|
78
|
+
formState
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
exports.FormContext_default = FormContext_default; exports.recursiveFieldKeySearch = recursiveFieldKeySearch; exports.useFormContext = useFormContext;
|
|
87
|
+
//# sourceMappingURL=chunk-WQRM7G4C.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx"],"names":[],"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","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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,129 +1,10 @@
|
|
|
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/hooks/index.ts
|
|
31
|
-
var hooks_exports = {};
|
|
32
|
-
__export(hooks_exports, {
|
|
33
|
-
recursiveFieldKeySearch: () => recursiveFieldKeySearch,
|
|
34
|
-
useFormContext: () => useFormContext
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
37
3
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var import_react_hook_form2 = require("react-hook-form");
|
|
4
|
+
var _chunkWQRM7G4Ccjs = require('../chunk-WQRM7G4C.cjs');
|
|
5
|
+
require('../chunk-BBB4FEY6.cjs');
|
|
41
6
|
|
|
42
|
-
// src/Form/subcomponents/FormContext.tsx
|
|
43
|
-
var import_react = __toESM(require("react"), 1);
|
|
44
|
-
var import_react_hook_form = require("react-hook-form");
|
|
45
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
-
var ValidationSchemaContext = import_react.default.createContext(void 0);
|
|
47
7
|
|
|
48
|
-
// src/helpers/slugify.ts
|
|
49
|
-
var import_slug = __toESM(require("slug"), 1);
|
|
50
|
-
var slugify_default = (string, options) => {
|
|
51
|
-
const replacement = options?.replacement || "_";
|
|
52
|
-
return (0, import_slug.default)(string, {
|
|
53
|
-
...import_slug.default.defaults.modes.rfc3986,
|
|
54
|
-
charmap: {
|
|
55
|
-
...import_slug.default.defaults.modes.rfc3986.charmap,
|
|
56
|
-
// allow dots by default
|
|
57
|
-
".": ".",
|
|
58
|
-
// convert hyphens to underscores (when replacement is not hyphen)
|
|
59
|
-
...replacement !== "-" ? { "-": "_" } : {}
|
|
60
|
-
},
|
|
61
|
-
replacement,
|
|
62
|
-
...options || {}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
8
|
|
|
66
|
-
|
|
67
|
-
var recursiveSearchInnerType = (schema) => {
|
|
68
|
-
if (schema?._def?.innerType) {
|
|
69
|
-
if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
|
|
70
|
-
return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
|
|
71
|
-
}
|
|
72
|
-
return recursiveSearchInnerType(schema?._def?.innerType);
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
};
|
|
76
|
-
var recursiveFieldKeySearch = (schema, path) => {
|
|
77
|
-
const [current, ...rest] = path;
|
|
78
|
-
let currentSchema = schema;
|
|
79
|
-
if (schema?._def?.typeName === "ZodOptional") {
|
|
80
|
-
currentSchema = schema.unwrap();
|
|
81
|
-
} else if (schema?._def?.typeName === "ZodEffects") {
|
|
82
|
-
return recursiveFieldKeySearch(schema._def?.schema, path);
|
|
83
|
-
}
|
|
84
|
-
if (currentSchema?._def?.typeName === "ZodIntersection") {
|
|
85
|
-
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));
|
|
86
|
-
}
|
|
87
|
-
const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
|
|
88
|
-
if (shape && shape[current]) {
|
|
89
|
-
if (rest.length === 0) {
|
|
90
|
-
return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
91
|
-
}
|
|
92
|
-
return recursiveFieldKeySearch(shape[current], rest);
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
};
|
|
96
|
-
var useFormContext = () => {
|
|
97
|
-
const {
|
|
98
|
-
// https://react-hook-form.com/docs/useform/getfieldstate
|
|
99
|
-
// for getFieldState a subscription to formState properties is needed!
|
|
100
|
-
formState,
|
|
101
|
-
getFieldState: getFieldStateOrig,
|
|
102
|
-
...otherMethods
|
|
103
|
-
} = (0, import_react_hook_form2.useFormContext)();
|
|
104
|
-
const validation = (0, import_react2.useContext)(ValidationSchemaContext);
|
|
105
|
-
const getFieldState = (name, testId) => {
|
|
106
|
-
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
107
|
-
const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
|
|
108
|
-
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
109
|
-
return {
|
|
110
|
-
...rest,
|
|
111
|
-
error,
|
|
112
|
-
// TODO: change to correct type @Hannes ;)
|
|
113
|
-
required,
|
|
114
|
-
testId: slugify_default(testId || name)
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
...otherMethods,
|
|
119
|
-
getFieldState,
|
|
120
|
-
validation,
|
|
121
|
-
formState
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
-
0 && (module.exports = {
|
|
126
|
-
recursiveFieldKeySearch,
|
|
127
|
-
useFormContext
|
|
128
|
-
});
|
|
9
|
+
exports.recursiveFieldKeySearch = _chunkWQRM7G4Ccjs.recursiveFieldKeySearch; exports.useFormContext = _chunkWQRM7G4Ccjs.useFormContext;
|
|
129
10
|
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react-hook-form';
|
|
3
|
-
import '@fuf-stack/veto';
|
|
4
|
-
import '
|
|
1
|
+
import * as react_hook_form from 'react-hook-form';
|
|
2
|
+
import { FieldError } from 'react-hook-form';
|
|
3
|
+
import * as _fuf_stack_veto from '@fuf-stack/veto';
|
|
4
|
+
import { VetoSchema } from '@fuf-stack/veto';
|
|
5
|
+
import * as zod from 'zod';
|
|
6
|
+
|
|
7
|
+
declare const recursiveFieldKeySearch: (schema: VetoSchema, path: string[]) => boolean | null;
|
|
8
|
+
/** TODO: add description */
|
|
9
|
+
declare const useFormContext: () => {
|
|
10
|
+
getFieldState: (name: string, testId?: string) => {
|
|
11
|
+
error: FieldError[] | undefined;
|
|
12
|
+
required: boolean;
|
|
13
|
+
testId: string;
|
|
14
|
+
invalid: boolean;
|
|
15
|
+
isDirty: boolean;
|
|
16
|
+
isTouched: boolean;
|
|
17
|
+
isValidating: boolean;
|
|
18
|
+
};
|
|
19
|
+
validation: {
|
|
20
|
+
schema: zod.ZodTypeAny;
|
|
21
|
+
validate: <InputType extends _fuf_stack_veto.VetoInput>(input: InputType) => _fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>;
|
|
22
|
+
validateAsync: <InputType_1 extends _fuf_stack_veto.VetoInput>(input: InputType_1) => Promise<_fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>>;
|
|
23
|
+
} | undefined;
|
|
24
|
+
formState: react_hook_form.FormState<react_hook_form.FieldValues>;
|
|
25
|
+
watch: react_hook_form.UseFormWatch<react_hook_form.FieldValues>;
|
|
26
|
+
getValues: react_hook_form.UseFormGetValues<react_hook_form.FieldValues>;
|
|
27
|
+
setError: react_hook_form.UseFormSetError<react_hook_form.FieldValues>;
|
|
28
|
+
clearErrors: react_hook_form.UseFormClearErrors<react_hook_form.FieldValues>;
|
|
29
|
+
setValue: react_hook_form.UseFormSetValue<react_hook_form.FieldValues>;
|
|
30
|
+
trigger: react_hook_form.UseFormTrigger<react_hook_form.FieldValues>;
|
|
31
|
+
resetField: react_hook_form.UseFormResetField<react_hook_form.FieldValues>;
|
|
32
|
+
reset: react_hook_form.UseFormReset<react_hook_form.FieldValues>;
|
|
33
|
+
handleSubmit: react_hook_form.UseFormHandleSubmit<react_hook_form.FieldValues, undefined>;
|
|
34
|
+
unregister: react_hook_form.UseFormUnregister<react_hook_form.FieldValues>;
|
|
35
|
+
control: react_hook_form.Control<react_hook_form.FieldValues, any>;
|
|
36
|
+
register: react_hook_form.UseFormRegister<react_hook_form.FieldValues>;
|
|
37
|
+
setFocus: react_hook_form.UseFormSetFocus<react_hook_form.FieldValues>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { recursiveFieldKeySearch, useFormContext };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react-hook-form';
|
|
3
|
-
import '@fuf-stack/veto';
|
|
4
|
-
import '
|
|
1
|
+
import * as react_hook_form from 'react-hook-form';
|
|
2
|
+
import { FieldError } from 'react-hook-form';
|
|
3
|
+
import * as _fuf_stack_veto from '@fuf-stack/veto';
|
|
4
|
+
import { VetoSchema } from '@fuf-stack/veto';
|
|
5
|
+
import * as zod from 'zod';
|
|
6
|
+
|
|
7
|
+
declare const recursiveFieldKeySearch: (schema: VetoSchema, path: string[]) => boolean | null;
|
|
8
|
+
/** TODO: add description */
|
|
9
|
+
declare const useFormContext: () => {
|
|
10
|
+
getFieldState: (name: string, testId?: string) => {
|
|
11
|
+
error: FieldError[] | undefined;
|
|
12
|
+
required: boolean;
|
|
13
|
+
testId: string;
|
|
14
|
+
invalid: boolean;
|
|
15
|
+
isDirty: boolean;
|
|
16
|
+
isTouched: boolean;
|
|
17
|
+
isValidating: boolean;
|
|
18
|
+
};
|
|
19
|
+
validation: {
|
|
20
|
+
schema: zod.ZodTypeAny;
|
|
21
|
+
validate: <InputType extends _fuf_stack_veto.VetoInput>(input: InputType) => _fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>;
|
|
22
|
+
validateAsync: <InputType_1 extends _fuf_stack_veto.VetoInput>(input: InputType_1) => Promise<_fuf_stack_veto.VetoError | _fuf_stack_veto.VetoSuccess<any>>;
|
|
23
|
+
} | undefined;
|
|
24
|
+
formState: react_hook_form.FormState<react_hook_form.FieldValues>;
|
|
25
|
+
watch: react_hook_form.UseFormWatch<react_hook_form.FieldValues>;
|
|
26
|
+
getValues: react_hook_form.UseFormGetValues<react_hook_form.FieldValues>;
|
|
27
|
+
setError: react_hook_form.UseFormSetError<react_hook_form.FieldValues>;
|
|
28
|
+
clearErrors: react_hook_form.UseFormClearErrors<react_hook_form.FieldValues>;
|
|
29
|
+
setValue: react_hook_form.UseFormSetValue<react_hook_form.FieldValues>;
|
|
30
|
+
trigger: react_hook_form.UseFormTrigger<react_hook_form.FieldValues>;
|
|
31
|
+
resetField: react_hook_form.UseFormResetField<react_hook_form.FieldValues>;
|
|
32
|
+
reset: react_hook_form.UseFormReset<react_hook_form.FieldValues>;
|
|
33
|
+
handleSubmit: react_hook_form.UseFormHandleSubmit<react_hook_form.FieldValues, undefined>;
|
|
34
|
+
unregister: react_hook_form.UseFormUnregister<react_hook_form.FieldValues>;
|
|
35
|
+
control: react_hook_form.Control<react_hook_form.FieldValues, any>;
|
|
36
|
+
register: react_hook_form.UseFormRegister<react_hook_form.FieldValues>;
|
|
37
|
+
setFocus: react_hook_form.UseFormSetFocus<react_hook_form.FieldValues>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { recursiveFieldKeySearch, useFormContext };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import "../chunk-GATZOHQ6.js";
|
|
2
1
|
import {
|
|
3
2
|
recursiveFieldKeySearch,
|
|
4
3
|
useFormContext
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-WIY7KIHU.js";
|
|
4
|
+
} from "../chunk-BCMPSLSG.js";
|
|
5
|
+
import "../chunk-V46BHM2U.js";
|
|
8
6
|
export {
|
|
9
7
|
recursiveFieldKeySearch,
|
|
10
8
|
useFormContext
|
|
@@ -1,48 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
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/partials/FieldCopyTestIdButton/index.ts
|
|
31
|
-
var FieldCopyTestIdButton_exports = {};
|
|
32
|
-
__export(FieldCopyTestIdButton_exports, {
|
|
33
|
-
default: () => FieldCopyTestIdButton_default2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(FieldCopyTestIdButton_exports);
|
|
36
|
-
|
|
37
|
-
// src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
38
|
-
var import_fa6 = require("react-icons/fa6");
|
|
39
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
40
|
-
var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
|
|
41
|
-
var import_useLocalStorage = __toESM(require("@fuf-stack/pixels/hooks/useLocalStorage"), 1);
|
|
42
|
-
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/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
2
|
+
var _fa6 = require('react-icons/fa6');
|
|
3
|
+
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
4
|
+
var _Button = require('@fuf-stack/pixels/Button'); var _Button2 = _interopRequireDefault(_Button);
|
|
5
|
+
var _useLocalStorage = require('@fuf-stack/pixels/hooks/useLocalStorage'); var _useLocalStorage2 = _interopRequireDefault(_useLocalStorage);
|
|
6
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
43
7
|
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
44
8
|
var TestIdDebug = ({ className = void 0, testId }) => {
|
|
45
|
-
const [debug] = (0,
|
|
9
|
+
const [debug] = _useLocalStorage2.default.call(void 0, LOCALSTORAGE_DEBUG_KEY, false);
|
|
46
10
|
const copyToClipboard = () => {
|
|
47
11
|
navigator.clipboard.writeText(testId).catch((err) => {
|
|
48
12
|
console.error("Error copying TestId to clipboard", err);
|
|
@@ -51,13 +15,13 @@ var TestIdDebug = ({ className = void 0, testId }) => {
|
|
|
51
15
|
if (!debug) {
|
|
52
16
|
return null;
|
|
53
17
|
}
|
|
54
|
-
return /* @__PURE__ */ (0,
|
|
55
|
-
|
|
18
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
19
|
+
_Button2.default,
|
|
56
20
|
{
|
|
57
|
-
className: (0,
|
|
21
|
+
className: _classnames2.default.call(void 0, className, "pointer-events-auto"),
|
|
58
22
|
variant: "light",
|
|
59
23
|
onClick: copyToClipboard,
|
|
60
|
-
icon: /* @__PURE__ */ (0,
|
|
24
|
+
icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _fa6.FaBullseye, {}),
|
|
61
25
|
size: "sm"
|
|
62
26
|
}
|
|
63
27
|
);
|
|
@@ -66,4 +30,7 @@ var FieldCopyTestIdButton_default = TestIdDebug;
|
|
|
66
30
|
|
|
67
31
|
// src/partials/FieldCopyTestIdButton/index.ts
|
|
68
32
|
var FieldCopyTestIdButton_default2 = FieldCopyTestIdButton_default;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.default = FieldCopyTestIdButton_default2;
|
|
69
36
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/partials/FieldCopyTestIdButton/
|
|
1
|
+
{"version":3,"sources":["../../../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../../../src/partials/FieldCopyTestIdButton/index.ts"],"names":["FieldCopyTestIdButton_default"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,OAAO,QAAQ;AAEf,OAAO,YAAY;AACnB,OAAO,qBAAqB;AA2BhB;AApBZ,IAAM,yBAAyB;AAE/B,IAAM,cAAc,CAAC,EAAE,YAAY,QAAW,OAAO,MAAsB;AACzE,QAAM,CAAC,KAAK,IAAI,gBAAgB,wBAAwB,KAAK;AAE7D,QAAM,kBAAkB,MAAM;AAC5B,cAAU,UAAU,UAAU,MAAM,EAAE,MAAM,CAAC,QAAQ;AACnD,cAAQ,MAAM,qCAAqC,GAAG;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,qBAAqB;AAAA,MAC9C,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,oBAAC,cAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;;;ACnCf,IAAOA,iCAAQ","sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport useLocalStorage from '@fuf-stack/pixels/hooks/useLocalStorage';\n\ninterface FormDebugProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst TestIdDebug = ({ className = undefined, testId }: FormDebugProps) => {\n const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n if (!debug) {\n return null;\n }\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n variant=\"light\"\n onClick={copyToClipboard}\n icon={<FaBullseye />}\n size=\"sm\"\n />\n );\n};\nexport default TestIdDebug;\n","import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport default FieldCopyTestIdButton;\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'react/jsx-runtime';
|
|
3
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
2
|
|
|
3
|
+
interface FormDebugProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
testId: string;
|
|
6
|
+
}
|
|
7
|
+
declare const TestIdDebug: ({ className, testId }: FormDebugProps) => react_jsx_runtime.JSX.Element | null;
|
|
5
8
|
|
|
6
9
|
export { TestIdDebug as default };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'react/jsx-runtime';
|
|
3
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
2
|
|
|
3
|
+
interface FormDebugProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
testId: string;
|
|
6
|
+
}
|
|
7
|
+
declare const TestIdDebug: ({ className, testId }: FormDebugProps) => react_jsx_runtime.JSX.Element | null;
|
|
5
8
|
|
|
6
9
|
export { TestIdDebug as default };
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
2
|
+
import { FaBullseye } from "react-icons/fa6";
|
|
3
|
+
import cn from "classnames";
|
|
4
|
+
import Button from "@fuf-stack/pixels/Button";
|
|
5
|
+
import useLocalStorage from "@fuf-stack/pixels/hooks/useLocalStorage";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
8
|
+
var TestIdDebug = ({ className = void 0, testId }) => {
|
|
9
|
+
const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);
|
|
10
|
+
const copyToClipboard = () => {
|
|
11
|
+
navigator.clipboard.writeText(testId).catch((err) => {
|
|
12
|
+
console.error("Error copying TestId to clipboard", err);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
if (!debug) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
Button,
|
|
20
|
+
{
|
|
21
|
+
className: cn(className, "pointer-events-auto"),
|
|
22
|
+
variant: "light",
|
|
23
|
+
onClick: copyToClipboard,
|
|
24
|
+
icon: /* @__PURE__ */ jsx(FaBullseye, {}),
|
|
25
|
+
size: "sm"
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var FieldCopyTestIdButton_default = TestIdDebug;
|
|
4
30
|
|
|
5
31
|
// src/partials/FieldCopyTestIdButton/index.ts
|
|
6
32
|
var FieldCopyTestIdButton_default2 = FieldCopyTestIdButton_default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/partials/FieldCopyTestIdButton/index.ts"],"sourcesContent":["import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport default FieldCopyTestIdButton;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../../../src/partials/FieldCopyTestIdButton/index.ts"],"sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport useLocalStorage from '@fuf-stack/pixels/hooks/useLocalStorage';\n\ninterface FormDebugProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst TestIdDebug = ({ className = undefined, testId }: FormDebugProps) => {\n const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n if (!debug) {\n return null;\n }\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n variant=\"light\"\n onClick={copyToClipboard}\n icon={<FaBullseye />}\n size=\"sm\"\n />\n );\n};\nexport default TestIdDebug;\n","import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport default FieldCopyTestIdButton;\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,OAAO,QAAQ;AAEf,OAAO,YAAY;AACnB,OAAO,qBAAqB;AA2BhB;AApBZ,IAAM,yBAAyB;AAE/B,IAAM,cAAc,CAAC,EAAE,YAAY,QAAW,OAAO,MAAsB;AACzE,QAAM,CAAC,KAAK,IAAI,gBAAgB,wBAAwB,KAAK;AAE7D,QAAM,kBAAkB,MAAM;AAC5B,cAAU,UAAU,UAAU,MAAM,EAAE,MAAM,CAAC,QAAQ;AACnD,cAAQ,MAAM,qCAAqC,GAAG;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,qBAAqB;AAAA,MAC9C,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,oBAAC,cAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;;;ACnCf,IAAOA,iCAAQ;","names":["FieldCopyTestIdButton_default"]}
|