@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.
Files changed (121) hide show
  1. package/dist/Form/index.cjs +45 -165
  2. package/dist/Form/index.cjs.map +1 -1
  3. package/dist/Form/index.d.cts +26 -6
  4. package/dist/Form/index.d.ts +26 -6
  5. package/dist/Form/index.js +141 -7
  6. package/dist/Form/index.js.map +1 -1
  7. package/dist/Grid/index.cjs +7 -40
  8. package/dist/Grid/index.cjs.map +1 -1
  9. package/dist/Grid/index.d.cts +14 -4
  10. package/dist/Grid/index.d.ts +14 -4
  11. package/dist/Grid/index.js +11 -3
  12. package/dist/Grid/index.js.map +1 -1
  13. package/dist/SubmitButton/index.cjs +14 -129
  14. package/dist/SubmitButton/index.cjs.map +1 -1
  15. package/dist/SubmitButton/index.d.cts +21 -5
  16. package/dist/SubmitButton/index.d.ts +21 -5
  17. package/dist/SubmitButton/index.js +36 -6
  18. package/dist/SubmitButton/index.js.map +1 -1
  19. package/dist/chunk-BBB4FEY6.cjs +22 -0
  20. package/dist/chunk-BBB4FEY6.cjs.map +1 -0
  21. package/dist/{chunk-PMNBGDEZ.js → chunk-BCMPSLSG.js} +21 -7
  22. package/dist/chunk-BCMPSLSG.js.map +1 -0
  23. package/dist/{chunk-WIY7KIHU.js → chunk-V46BHM2U.js} +4 -4
  24. package/dist/chunk-V46BHM2U.js.map +1 -0
  25. package/dist/chunk-WQRM7G4C.cjs +87 -0
  26. package/dist/chunk-WQRM7G4C.cjs.map +1 -0
  27. package/dist/helpers/index.cjs +7 -0
  28. package/dist/helpers/index.cjs.map +1 -0
  29. package/dist/helpers/index.d.cts +5 -0
  30. package/dist/helpers/index.d.ts +5 -0
  31. package/dist/helpers/index.js +7 -0
  32. package/dist/hooks/index.cjs +4 -123
  33. package/dist/hooks/index.cjs.map +1 -1
  34. package/dist/hooks/index.d.cts +40 -4
  35. package/dist/hooks/index.d.ts +40 -4
  36. package/dist/hooks/index.js +2 -4
  37. package/dist/partials/FieldCopyTestIdButton/index.cjs +14 -47
  38. package/dist/partials/FieldCopyTestIdButton/index.cjs.map +1 -1
  39. package/dist/partials/FieldCopyTestIdButton/index.d.cts +6 -3
  40. package/dist/partials/FieldCopyTestIdButton/index.d.ts +6 -3
  41. package/dist/partials/FieldCopyTestIdButton/index.js +29 -3
  42. package/dist/partials/FieldCopyTestIdButton/index.js.map +1 -1
  43. package/dist/partials/FieldValidationError/index.cjs +9 -56
  44. package/dist/partials/FieldValidationError/index.cjs.map +1 -1
  45. package/dist/partials/FieldValidationError/index.d.cts +10 -4
  46. package/dist/partials/FieldValidationError/index.d.ts +10 -4
  47. package/dist/partials/FieldValidationError/index.js +35 -3
  48. package/dist/partials/FieldValidationError/index.js.map +1 -1
  49. package/package.json +35 -8
  50. package/dist/Form/Form.cjs +0 -269
  51. package/dist/Form/Form.cjs.map +0 -1
  52. package/dist/Form/Form.d.cts +0 -34
  53. package/dist/Form/Form.d.ts +0 -34
  54. package/dist/Form/Form.js +0 -14
  55. package/dist/Form/subcomponents/FormContext.cjs +0 -53
  56. package/dist/Form/subcomponents/FormContext.cjs.map +0 -1
  57. package/dist/Form/subcomponents/FormContext.d.cts +0 -20
  58. package/dist/Form/subcomponents/FormContext.d.ts +0 -20
  59. package/dist/Form/subcomponents/FormContext.js +0 -9
  60. package/dist/Form/subcomponents/FormContext.js.map +0 -1
  61. package/dist/Form/subcomponents/FormDebugViewer.cjs +0 -197
  62. package/dist/Form/subcomponents/FormDebugViewer.cjs.map +0 -1
  63. package/dist/Form/subcomponents/FormDebugViewer.d.cts +0 -10
  64. package/dist/Form/subcomponents/FormDebugViewer.d.ts +0 -10
  65. package/dist/Form/subcomponents/FormDebugViewer.js +0 -11
  66. package/dist/Form/subcomponents/FormDebugViewer.js.map +0 -1
  67. package/dist/Grid/Grid.cjs +0 -46
  68. package/dist/Grid/Grid.cjs.map +0 -1
  69. package/dist/Grid/Grid.d.cts +0 -17
  70. package/dist/Grid/Grid.d.ts +0 -17
  71. package/dist/Grid/Grid.js +0 -7
  72. package/dist/Grid/Grid.js.map +0 -1
  73. package/dist/SubmitButton/SubmitButton.cjs +0 -154
  74. package/dist/SubmitButton/SubmitButton.cjs.map +0 -1
  75. package/dist/SubmitButton/SubmitButton.d.cts +0 -24
  76. package/dist/SubmitButton/SubmitButton.d.ts +0 -24
  77. package/dist/SubmitButton/SubmitButton.js +0 -11
  78. package/dist/SubmitButton/SubmitButton.js.map +0 -1
  79. package/dist/chunk-AV26PIKH.js +0 -82
  80. package/dist/chunk-AV26PIKH.js.map +0 -1
  81. package/dist/chunk-BJ36HK7L.js +0 -42
  82. package/dist/chunk-BJ36HK7L.js.map +0 -1
  83. package/dist/chunk-EDUZKOTL.js +0 -41
  84. package/dist/chunk-EDUZKOTL.js.map +0 -1
  85. package/dist/chunk-GATZOHQ6.js +0 -1
  86. package/dist/chunk-GATZOHQ6.js.map +0 -1
  87. package/dist/chunk-IQVKBQ7W.js +0 -19
  88. package/dist/chunk-IQVKBQ7W.js.map +0 -1
  89. package/dist/chunk-KY2KCXOO.js +0 -16
  90. package/dist/chunk-KY2KCXOO.js.map +0 -1
  91. package/dist/chunk-PMNBGDEZ.js.map +0 -1
  92. package/dist/chunk-UMTFPEVF.js +0 -34
  93. package/dist/chunk-UMTFPEVF.js.map +0 -1
  94. package/dist/chunk-WIY7KIHU.js.map +0 -1
  95. package/dist/chunk-X4VXTRJB.js +0 -74
  96. package/dist/chunk-X4VXTRJB.js.map +0 -1
  97. package/dist/helpers/slugify.cjs +0 -52
  98. package/dist/helpers/slugify.cjs.map +0 -1
  99. package/dist/helpers/slugify.d.cts +0 -5
  100. package/dist/helpers/slugify.d.ts +0 -5
  101. package/dist/helpers/slugify.js +0 -7
  102. package/dist/helpers/slugify.js.map +0 -1
  103. package/dist/hooks/useFormContext/useFormContext.cjs +0 -127
  104. package/dist/hooks/useFormContext/useFormContext.cjs.map +0 -1
  105. package/dist/hooks/useFormContext/useFormContext.d.cts +0 -40
  106. package/dist/hooks/useFormContext/useFormContext.d.ts +0 -40
  107. package/dist/hooks/useFormContext/useFormContext.js +0 -11
  108. package/dist/hooks/useFormContext/useFormContext.js.map +0 -1
  109. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs +0 -64
  110. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.cjs.map +0 -1
  111. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.cts +0 -9
  112. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.ts +0 -9
  113. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js +0 -7
  114. package/dist/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.js.map +0 -1
  115. package/dist/partials/FieldValidationError/FieldValidationError.cjs +0 -87
  116. package/dist/partials/FieldValidationError/FieldValidationError.cjs.map +0 -1
  117. package/dist/partials/FieldValidationError/FieldValidationError.d.cts +0 -13
  118. package/dist/partials/FieldValidationError/FieldValidationError.d.ts +0 -13
  119. package/dist/partials/FieldValidationError/FieldValidationError.js +0 -8
  120. package/dist/partials/FieldValidationError/FieldValidationError.js.map +0 -1
  121. /package/dist/{Form/Form.js.map → helpers/index.js.map} +0 -0
@@ -1,127 +0,0 @@
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/hooks/useFormContext/useFormContext.ts
31
- var useFormContext_exports = {};
32
- __export(useFormContext_exports, {
33
- recursiveFieldKeySearch: () => recursiveFieldKeySearch,
34
- useFormContext: () => useFormContext
35
- });
36
- module.exports = __toCommonJS(useFormContext_exports);
37
- var import_react2 = require("react");
38
- var import_react_hook_form2 = require("react-hook-form");
39
-
40
- // src/Form/subcomponents/FormContext.tsx
41
- var import_react = __toESM(require("react"), 1);
42
- var import_react_hook_form = require("react-hook-form");
43
- var import_jsx_runtime = require("react/jsx-runtime");
44
- var ValidationSchemaContext = import_react.default.createContext(void 0);
45
-
46
- // src/helpers/slugify.ts
47
- var import_slug = __toESM(require("slug"), 1);
48
- var slugify_default = (string, options) => {
49
- const replacement = options?.replacement || "_";
50
- return (0, import_slug.default)(string, {
51
- ...import_slug.default.defaults.modes.rfc3986,
52
- charmap: {
53
- ...import_slug.default.defaults.modes.rfc3986.charmap,
54
- // allow dots by default
55
- ".": ".",
56
- // convert hyphens to underscores (when replacement is not hyphen)
57
- ...replacement !== "-" ? { "-": "_" } : {}
58
- },
59
- replacement,
60
- ...options || {}
61
- });
62
- };
63
-
64
- // src/hooks/useFormContext/useFormContext.ts
65
- var recursiveSearchInnerType = (schema) => {
66
- if (schema?._def?.innerType) {
67
- if (schema?._def?.innerType?._def?.typeName === "ZodOptional") {
68
- return schema?._def?.innerType?._def?.typeName !== "ZodOptional";
69
- }
70
- return recursiveSearchInnerType(schema?._def?.innerType);
71
- }
72
- return true;
73
- };
74
- var recursiveFieldKeySearch = (schema, path) => {
75
- const [current, ...rest] = path;
76
- let currentSchema = schema;
77
- if (schema?._def?.typeName === "ZodOptional") {
78
- currentSchema = schema.unwrap();
79
- } else if (schema?._def?.typeName === "ZodEffects") {
80
- return recursiveFieldKeySearch(schema._def?.schema, path);
81
- }
82
- if (currentSchema?._def?.typeName === "ZodIntersection") {
83
- 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));
84
- }
85
- const shape = currentSchema?.shape ?? currentSchema?.element?.shape;
86
- if (shape && shape[current]) {
87
- if (rest.length === 0) {
88
- return shape[current]?._def?.typeName !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
89
- }
90
- return recursiveFieldKeySearch(shape[current], rest);
91
- }
92
- return null;
93
- };
94
- var useFormContext = () => {
95
- const {
96
- // https://react-hook-form.com/docs/useform/getfieldstate
97
- // for getFieldState a subscription to formState properties is needed!
98
- formState,
99
- getFieldState: getFieldStateOrig,
100
- ...otherMethods
101
- } = (0, import_react_hook_form2.useFormContext)();
102
- const validation = (0, import_react2.useContext)(ValidationSchemaContext);
103
- const getFieldState = (name, testId) => {
104
- const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
105
- const required = validation && recursiveFieldKeySearch(validation.schema, fieldPath) || false;
106
- const { error, ...rest } = getFieldStateOrig(name, formState);
107
- return {
108
- ...rest,
109
- error,
110
- // TODO: change to correct type @Hannes ;)
111
- required,
112
- testId: slugify_default(testId || name)
113
- };
114
- };
115
- return {
116
- ...otherMethods,
117
- getFieldState,
118
- validation,
119
- formState
120
- };
121
- };
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- recursiveFieldKeySearch,
125
- useFormContext
126
- });
127
- //# sourceMappingURL=useFormContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/hooks/useFormContext/useFormContext.ts","../../../src/Form/subcomponents/FormContext.tsx","../../../src/helpers/slugify.ts"],"sourcesContent":["import type { VetoSchema } from '@fuf-stack/veto';\nimport type { FieldError } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { ValidationSchemaContext } from '../../Form/subcomponents/FormContext';\nimport slugify from '../../helpers/slugify';\n\n// FIX: This fixes the problem that the innerType is not checked for optionals...\nconst recursiveSearchInnerType = (schema: VetoSchema): boolean => {\n if (schema?._def?.innerType) {\n if (schema?._def?.innerType?._def?.typeName === 'ZodOptional') {\n return schema?._def?.innerType?._def?.typeName !== 'ZodOptional';\n }\n return recursiveSearchInnerType(schema?._def?.innerType);\n }\n return true;\n};\n\n// TODO: Fix problem \".optional().nullable()\" is required, \".nullable().optional()\" is not required...\nexport const recursiveFieldKeySearch = (\n schema: VetoSchema,\n path: string[],\n): boolean | null => {\n const [current, ...rest] = path;\n // ignore optionals on the path to the desired field\n\n let currentSchema = schema;\n\n if (schema?._def?.typeName === 'ZodOptional') {\n // @ts-expect-error not sure here\n currentSchema = schema.unwrap();\n } else if (schema?._def?.typeName === 'ZodEffects') {\n // in case of an effect, unwrap the effect and call with schema (clould be optional) and complete path.\n return recursiveFieldKeySearch(schema._def?.schema, path);\n }\n\n // TODO: This needs further investigation. It is nor yet completely clear how to handle intersections!\n if (currentSchema?._def?.typeName === 'ZodIntersection') {\n return (\n (currentSchema._def.left?.schema\n ? recursiveFieldKeySearch(currentSchema._def.left.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.left, path)) ||\n (currentSchema._def.right?.schema\n ? recursiveFieldKeySearch(currentSchema._def.right.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.right, path))\n );\n }\n\n // get shape of an object or objects of an array\n // @ts-expect-error not sure here\n const shape = currentSchema?.shape ?? currentSchema?.element?.shape; // ??\n\n if (shape && shape[current]) {\n // currentSchema?._def.schema.unwrap()?.shape;\n if (rest.length === 0) {\n // At the end of the path check if the field is optional or required\n return (\n shape[current]?._def?.typeName !== 'ZodOptional' &&\n recursiveSearchInnerType(shape[current])\n );\n }\n return recursiveFieldKeySearch(shape[current], rest);\n }\n\n return null; // field not found\n};\n\n/** TODO: add description */\nexport const useFormContext = () => {\n const {\n // https://react-hook-form.com/docs/useform/getfieldstate\n // for getFieldState a subscription to formState properties is needed!\n formState,\n getFieldState: getFieldStateOrig,\n ...otherMethods\n } = useHookFormContext();\n const validation = useContext(ValidationSchemaContext);\n\n // update getFieldState\n const getFieldState = (name: string, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n const required =\n (validation && recursiveFieldKeySearch(validation.schema, fieldPath)) ||\n false;\n const { error, ...rest } = getFieldStateOrig(name, formState);\n return {\n ...rest,\n error: error as FieldError[] | undefined, // TODO: change to correct type @Hannes ;)\n required,\n testId: slugify(testId || name),\n };\n };\n\n return {\n ...otherMethods,\n getFieldState,\n validation,\n formState,\n };\n};\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { FormProviderProps as HookFormProviderProps } from 'react-hook-form';\n\nimport React from 'react';\nimport { FormProvider as HookFormProvider } from 'react-hook-form';\n\nexport const ValidationSchemaContext = React.createContext<\n VetoInstance | undefined\n>(undefined);\n\ninterface FormProviderProps\n extends HookFormProviderProps<Record<string, any>, any, undefined> {\n /** veto validation schema */\n validation?: VetoInstance;\n}\n\n/** Provides the veto validation context to the form */\nconst FormProvider = ({\n children,\n validation = undefined,\n ...hookFormProps\n}: FormProviderProps) => {\n return (\n <ValidationSchemaContext.Provider value={validation}>\n <HookFormProvider {...hookFormProps}>{children}</HookFormProvider>\n </ValidationSchemaContext.Provider>\n );\n};\n\nexport default FormProvider;\n","import type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\nexport default (string: string, options?: SlugOptions) => {\n const replacement = options?.replacement || '_';\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // allow dots by default\n '.': '.',\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,gBAA2B;AAC3B,IAAAC,0BAAqD;;;ACDrD,mBAAkB;AAClB,6BAAiD;AAoB3C;AAlBC,IAAM,0BAA0B,aAAAC,QAAM,cAE3C,MAAS;;;ACNX,kBAAiB;AAEjB,IAAO,kBAAQ,CAAC,QAAgB,YAA0B;AACxD,QAAM,cAAc,SAAS,eAAe;AAC5C,aAAO,YAAAC,SAAK,QAAQ;AAAA,IAClB,GAAG,YAAAA,QAAK,SAAS,MAAM;AAAA,IACvB,SAAS;AAAA,MACP,GAAG,YAAAA,QAAK,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;;;AFRA,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,a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AA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_react","import_react_hook_form","React","slug","useHookFormContext"]}
@@ -1,40 +0,0 @@
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 };
@@ -1,40 +0,0 @@
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 };
@@ -1,11 +0,0 @@
1
- import {
2
- recursiveFieldKeySearch,
3
- useFormContext
4
- } from "../../chunk-PMNBGDEZ.js";
5
- import "../../chunk-IQVKBQ7W.js";
6
- import "../../chunk-WIY7KIHU.js";
7
- export {
8
- recursiveFieldKeySearch,
9
- useFormContext
10
- };
11
- //# sourceMappingURL=useFormContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,64 +0,0 @@
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/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
31
- var FieldCopyTestIdButton_exports = {};
32
- __export(FieldCopyTestIdButton_exports, {
33
- default: () => FieldCopyTestIdButton_default
34
- });
35
- module.exports = __toCommonJS(FieldCopyTestIdButton_exports);
36
- var import_fa6 = require("react-icons/fa6");
37
- var import_classnames = __toESM(require("classnames"), 1);
38
- var import_Button = __toESM(require("@fuf-stack/pixels/Button"), 1);
39
- var import_useLocalStorage = __toESM(require("@fuf-stack/pixels/hooks/useLocalStorage"), 1);
40
- var import_jsx_runtime = require("react/jsx-runtime");
41
- var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
42
- var TestIdDebug = ({ className = void 0, testId }) => {
43
- const [debug] = (0, import_useLocalStorage.default)(LOCALSTORAGE_DEBUG_KEY, false);
44
- const copyToClipboard = () => {
45
- navigator.clipboard.writeText(testId).catch((err) => {
46
- console.error("Error copying TestId to clipboard", err);
47
- });
48
- };
49
- if (!debug) {
50
- return null;
51
- }
52
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
53
- import_Button.default,
54
- {
55
- className: (0, import_classnames.default)(className, "pointer-events-auto"),
56
- variant: "light",
57
- onClick: copyToClipboard,
58
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa6.FaBullseye, {}),
59
- size: "sm"
60
- }
61
- );
62
- };
63
- var FieldCopyTestIdButton_default = TestIdDebug;
64
- //# sourceMappingURL=FieldCopyTestIdButton.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx"],"sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport cn from 'classnames';\n\nimport Button from '@fuf-stack/pixels/Button';\nimport useLocalStorage from '@fuf-stack/pixels/hooks/useLocalStorage';\n\ninterface FormDebugProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst TestIdDebug = ({ className = undefined, testId }: FormDebugProps) => {\n const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n if (!debug) {\n return null;\n }\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n variant=\"light\"\n onClick={copyToClipboard}\n icon={<FaBullseye />}\n size=\"sm\"\n />\n );\n};\nexport default TestIdDebug;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA2B;AAE3B,wBAAe;AAEf,oBAAmB;AACnB,6BAA4B;AA2BhB;AApBZ,IAAM,yBAAyB;AAE/B,IAAM,cAAc,CAAC,EAAE,YAAY,QAAW,OAAO,MAAsB;AACzE,QAAM,CAAC,KAAK,QAAI,uBAAAA,SAAgB,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,cAAAC;AAAA,IAAA;AAAA,MACC,eAAW,kBAAAC,SAAG,WAAW,qBAAqB;AAAA,MAC9C,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,4CAAC,yBAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;","names":["useLocalStorage","Button","cn"]}
@@ -1,9 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface FormDebugProps {
4
- className?: string;
5
- testId: string;
6
- }
7
- declare const TestIdDebug: ({ className, testId }: FormDebugProps) => react_jsx_runtime.JSX.Element | null;
8
-
9
- export { TestIdDebug as default };
@@ -1,9 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface FormDebugProps {
4
- className?: string;
5
- testId: string;
6
- }
7
- declare const TestIdDebug: ({ className, testId }: FormDebugProps) => react_jsx_runtime.JSX.Element | null;
8
-
9
- export { TestIdDebug as default };
@@ -1,7 +0,0 @@
1
- import {
2
- FieldCopyTestIdButton_default
3
- } from "../../chunk-UMTFPEVF.js";
4
- export {
5
- FieldCopyTestIdButton_default as default
6
- };
7
- //# sourceMappingURL=FieldCopyTestIdButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,87 +0,0 @@
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/partials/FieldValidationError/FieldValidationError.tsx
31
- var FieldValidationError_exports = {};
32
- __export(FieldValidationError_exports, {
33
- default: () => FieldValidationError_default
34
- });
35
- module.exports = __toCommonJS(FieldValidationError_exports);
36
-
37
- // src/helpers/slugify.ts
38
- var import_slug = __toESM(require("slug"), 1);
39
- var slugify_default = (string, options) => {
40
- const replacement = options?.replacement || "_";
41
- return (0, import_slug.default)(string, {
42
- ...import_slug.default.defaults.modes.rfc3986,
43
- charmap: {
44
- ...import_slug.default.defaults.modes.rfc3986.charmap,
45
- // allow dots by default
46
- ".": ".",
47
- // convert hyphens to underscores (when replacement is not hyphen)
48
- ...replacement !== "-" ? { "-": "_" } : {}
49
- },
50
- replacement,
51
- ...options || {}
52
- });
53
- };
54
-
55
- // src/partials/FieldValidationError/FieldValidationError.tsx
56
- var import_jsx_runtime = require("react/jsx-runtime");
57
- var FieldValidationError = ({
58
- error,
59
- testId = void 0
60
- }) => {
61
- if (!error) {
62
- return null;
63
- }
64
- let tmp_errors = [];
65
- if (typeof error === "object" && !(error instanceof Array)) {
66
- const error_object = error;
67
- Object.keys(error).forEach((key) => {
68
- tmp_errors = [...tmp_errors, ...error_object[key]];
69
- });
70
- }
71
- const errorArray = JSON.stringify(tmp_errors) !== "[]" ? tmp_errors : error;
72
- const errorStrings = errorArray.map((e) => e.message);
73
- const ariaString = `Error: ${errorStrings.join("\n")}`;
74
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
- "ul",
76
- {
77
- "data-testid": slugify_default(testId || errorStrings.join()),
78
- "aria-label": ariaString,
79
- children: errorStrings.map((errorString, i) => (
80
- // eslint-disable-next-line react/no-array-index-key
81
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: errorString }) }, `error_${i}`)
82
- ))
83
- }
84
- );
85
- };
86
- var FieldValidationError_default = FieldValidationError;
87
- //# sourceMappingURL=FieldValidationError.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/partials/FieldValidationError/FieldValidationError.tsx","../../../src/helpers/slugify.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport slugify from '../../helpers/slugify';\n\ninterface FieldValidationErrorProps {\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmp_errors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const error_object = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmp_errors = [...tmp_errors, ...error_object[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmp_errors) !== '[]' ? tmp_errors : (error as FieldError[]);\n const errorStrings: string[] = errorArray.map((e) => e.message) as string[];\n const ariaString = `Error: ${errorStrings.join('\\n')}`;\n\n return (\n <ul\n data-testid={slugify(testId || errorStrings.join())}\n aria-label={ariaString} // TODO: ist das richtig @Hannes?\n >\n {errorStrings.map((errorString: string, i: number) => (\n // eslint-disable-next-line react/no-array-index-key\n <li key={`error_${i}`}>\n <div>{errorString}</div>\n </li>\n ))}\n </ul>\n );\n};\n\nexport default FieldValidationError;\n","import type { Options as SlugOptions } from 'slug';\n\nimport slug from 'slug';\n\nexport default (string: string, options?: SlugOptions) => {\n const replacement = options?.replacement || '_';\n return slug(string, {\n ...slug.defaults.modes.rfc3986,\n charmap: {\n ...slug.defaults.modes.rfc3986.charmap,\n // allow dots by default\n '.': '.',\n // convert hyphens to underscores (when replacement is not hyphen)\n ...(replacement !== '-' ? { '-': '_' } : {}),\n },\n replacement,\n ...(options || {}),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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@@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { FieldError } from 'react-hook-form';
3
-
4
- interface FieldValidationErrorProps {
5
- error: FieldError[] | Record<string, FieldError[]>;
6
- testId?: string;
7
- }
8
- /**
9
- * Renders a validation error of a field
10
- */
11
- declare const FieldValidationError: ({ error, testId, }: FieldValidationErrorProps) => react_jsx_runtime.JSX.Element | null;
12
-
13
- export { FieldValidationError as default };
@@ -1,13 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { FieldError } from 'react-hook-form';
3
-
4
- interface FieldValidationErrorProps {
5
- error: FieldError[] | Record<string, FieldError[]>;
6
- testId?: string;
7
- }
8
- /**
9
- * Renders a validation error of a field
10
- */
11
- declare const FieldValidationError: ({ error, testId, }: FieldValidationErrorProps) => react_jsx_runtime.JSX.Element | null;
12
-
13
- export { FieldValidationError as default };
@@ -1,8 +0,0 @@
1
- import {
2
- FieldValidationError_default
3
- } from "../../chunk-EDUZKOTL.js";
4
- import "../../chunk-WIY7KIHU.js";
5
- export {
6
- FieldValidationError_default as default
7
- };
8
- //# sourceMappingURL=FieldValidationError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
File without changes