@becklyn/forms 2.0.0 → 2.0.2
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/README.md +31 -7
- package/dist/cjs/components/FormBuilder.d.ts +2 -2
- package/dist/cjs/components/FormBuilder.d.ts.map +1 -1
- package/dist/cjs/components/FormBuilder.js +9 -2
- package/dist/cjs/components/FormCustom.d.ts +3 -3
- package/dist/cjs/components/FormCustom.d.ts.map +1 -1
- package/dist/cjs/components/FormCustom.js +1 -0
- package/dist/cjs/components/FormEntry.d.ts +5 -6
- package/dist/cjs/components/FormEntry.d.ts.map +1 -1
- package/dist/cjs/components/FormEntry.js +3 -2
- package/dist/cjs/components/FormField.d.ts +4 -5
- package/dist/cjs/components/FormField.d.ts.map +1 -1
- package/dist/cjs/components/FormField.js +2 -1
- package/dist/cjs/components/FormRow.d.ts +3 -3
- package/dist/cjs/components/FormRow.d.ts.map +1 -1
- package/dist/cjs/components/FormRow.js +1 -0
- package/dist/cjs/components/FormSection.d.ts +3 -3
- package/dist/cjs/components/FormSection.d.ts.map +1 -1
- package/dist/cjs/components/FormSection.js +1 -0
- package/dist/cjs/condition/index.d.ts +1 -1
- package/dist/cjs/condition/index.d.ts.map +1 -1
- package/dist/cjs/context/FormProvider.d.ts +2 -1
- package/dist/cjs/context/FormProvider.d.ts.map +1 -1
- package/dist/cjs/context/FormProvider.js +1 -0
- package/dist/cjs/context/context.d.ts +7 -5
- package/dist/cjs/context/context.d.ts.map +1 -1
- package/dist/cjs/context/context.js +1 -0
- package/dist/cjs/context/data/FormDataProvider.d.ts +10 -10
- package/dist/cjs/context/data/FormDataProvider.d.ts.map +1 -1
- package/dist/cjs/context/data/FormDataProvider.js +1 -0
- package/dist/cjs/context/data/context.d.ts +8 -8
- package/dist/cjs/context/data/context.d.ts.map +1 -1
- package/dist/cjs/context/data/context.js +1 -0
- package/dist/cjs/guard/index.d.ts +4 -4
- package/dist/cjs/guard/index.d.ts.map +1 -1
- package/dist/cjs/hoc/withForm.d.ts +3 -2
- package/dist/cjs/hoc/withForm.d.ts.map +1 -1
- package/dist/cjs/hoc/withForm.js +4 -1
- package/dist/cjs/hoc/withFormData.d.ts +3 -2
- package/dist/cjs/hoc/withFormData.d.ts.map +1 -1
- package/dist/cjs/hoc/withFormData.js +1 -0
- package/dist/cjs/hook/useFormData.d.ts +2 -2
- package/dist/cjs/hook/useFormData.d.ts.map +1 -1
- package/dist/cjs/hook/useFormData.js +1 -0
- package/dist/cjs/hook/useFormValidations.d.ts +3 -3
- package/dist/cjs/hook/useFormValidations.d.ts.map +1 -1
- package/dist/cjs/hook/useFormValidations.js +1 -0
- package/dist/cjs/type/config.d.ts +5 -5
- package/dist/cjs/type/config.d.ts.map +1 -1
- package/dist/cjs/type/extract.d.ts +5 -8
- package/dist/cjs/type/extract.d.ts.map +1 -1
- package/dist/cjs/type/field.d.ts +9 -9
- package/dist/cjs/type/field.d.ts.map +1 -1
- package/dist/cjs/type/form.d.ts +13 -11
- package/dist/cjs/type/form.d.ts.map +1 -1
- package/dist/cjs/type/form.js +9 -0
- package/dist/cjs/type/validation.d.ts +6 -5
- package/dist/cjs/type/validation.d.ts.map +1 -1
- package/dist/cjs/util/index.d.ts +10 -8
- package/dist/cjs/util/index.d.ts.map +1 -1
- package/dist/cjs/util/index.js +3 -1
- package/dist/cjs/validation/index.d.ts +2 -2
- package/dist/cjs/validation/index.d.ts.map +1 -1
- package/dist/cjs/validation/index.js +2 -1
- package/dist/es/components/FormBuilder.d.ts +2 -2
- package/dist/es/components/FormBuilder.d.ts.map +1 -1
- package/dist/es/components/FormBuilder.js +9 -2
- package/dist/es/components/FormCustom.d.ts +3 -3
- package/dist/es/components/FormCustom.d.ts.map +1 -1
- package/dist/es/components/FormCustom.js +1 -0
- package/dist/es/components/FormEntry.d.ts +5 -6
- package/dist/es/components/FormEntry.d.ts.map +1 -1
- package/dist/es/components/FormEntry.js +3 -2
- package/dist/es/components/FormField.d.ts +4 -5
- package/dist/es/components/FormField.d.ts.map +1 -1
- package/dist/es/components/FormField.js +2 -1
- package/dist/es/components/FormRow.d.ts +3 -3
- package/dist/es/components/FormRow.d.ts.map +1 -1
- package/dist/es/components/FormRow.js +1 -0
- package/dist/es/components/FormSection.d.ts +3 -3
- package/dist/es/components/FormSection.d.ts.map +1 -1
- package/dist/es/components/FormSection.js +1 -0
- package/dist/es/condition/index.d.ts +1 -1
- package/dist/es/condition/index.d.ts.map +1 -1
- package/dist/es/context/FormProvider.d.ts +2 -1
- package/dist/es/context/FormProvider.d.ts.map +1 -1
- package/dist/es/context/FormProvider.js +1 -0
- package/dist/es/context/context.d.ts +7 -5
- package/dist/es/context/context.d.ts.map +1 -1
- package/dist/es/context/context.js +1 -0
- package/dist/es/context/data/FormDataProvider.d.ts +10 -10
- package/dist/es/context/data/FormDataProvider.d.ts.map +1 -1
- package/dist/es/context/data/FormDataProvider.js +1 -0
- package/dist/es/context/data/context.d.ts +8 -8
- package/dist/es/context/data/context.d.ts.map +1 -1
- package/dist/es/context/data/context.js +1 -0
- package/dist/es/guard/index.d.ts +4 -4
- package/dist/es/guard/index.d.ts.map +1 -1
- package/dist/es/hoc/withForm.d.ts +3 -2
- package/dist/es/hoc/withForm.d.ts.map +1 -1
- package/dist/es/hoc/withForm.js +4 -1
- package/dist/es/hoc/withFormData.d.ts +3 -2
- package/dist/es/hoc/withFormData.d.ts.map +1 -1
- package/dist/es/hoc/withFormData.js +1 -0
- package/dist/es/hook/useFormData.d.ts +2 -2
- package/dist/es/hook/useFormData.d.ts.map +1 -1
- package/dist/es/hook/useFormData.js +1 -0
- package/dist/es/hook/useFormValidations.d.ts +3 -3
- package/dist/es/hook/useFormValidations.d.ts.map +1 -1
- package/dist/es/hook/useFormValidations.js +1 -0
- package/dist/es/type/config.d.ts +5 -5
- package/dist/es/type/config.d.ts.map +1 -1
- package/dist/es/type/extract.d.ts +5 -8
- package/dist/es/type/extract.d.ts.map +1 -1
- package/dist/es/type/field.d.ts +9 -9
- package/dist/es/type/field.d.ts.map +1 -1
- package/dist/es/type/form.d.ts +13 -11
- package/dist/es/type/form.d.ts.map +1 -1
- package/dist/es/type/form.js +9 -0
- package/dist/es/type/validation.d.ts +6 -5
- package/dist/es/type/validation.d.ts.map +1 -1
- package/dist/es/util/index.d.ts +10 -8
- package/dist/es/util/index.d.ts.map +1 -1
- package/dist/es/util/index.js +3 -1
- package/dist/es/validation/index.d.ts +2 -2
- package/dist/es/validation/index.d.ts.map +1 -1
- package/dist/es/validation/index.js +2 -1
- package/package.json +1 -1
- package/dist/cjs/type/test.d.ts +0 -14
- package/dist/cjs/type/test.d.ts.map +0 -1
- package/dist/cjs/type/test.js +0 -14
- package/dist/es/type/test.d.ts +0 -14
- package/dist/es/type/test.d.ts.map +0 -1
- package/dist/es/type/test.js +0 -14
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
2
|
import { FormStore } from "../../hook/useFormStore";
|
|
3
|
-
import { FormConfig, FormData, FormInputFunc, FormValidationStrategy } from "../../type";
|
|
4
|
-
export interface FormProviderProps {
|
|
5
|
-
config: FormConfig
|
|
6
|
-
data?: FormStore<FormData
|
|
7
|
-
errors?: FormStore<
|
|
8
|
-
editData?: FormStore<FormData
|
|
9
|
-
initialData?: FormData
|
|
3
|
+
import { FormConfig, FormData, FormErrors, FormFieldConfig, FormInputFunc, FormValidationStrategy } from "../../type";
|
|
4
|
+
export interface FormProviderProps<T extends FormFieldConfig<string, any, any>> {
|
|
5
|
+
config: FormConfig<T>;
|
|
6
|
+
data?: FormStore<FormData<T>>;
|
|
7
|
+
errors?: FormStore<FormErrors>;
|
|
8
|
+
editData?: FormStore<FormData<T>>;
|
|
9
|
+
initialData?: FormData<T>;
|
|
10
10
|
inheritData?: boolean;
|
|
11
11
|
inheritErrors?: boolean;
|
|
12
12
|
validationStrategy?: FormValidationStrategy;
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated Use the field config's 'onInput' callback instead
|
|
15
15
|
*/
|
|
16
|
-
onInput?: FormInputFunc
|
|
16
|
+
onInput?: FormInputFunc<T, any>;
|
|
17
17
|
}
|
|
18
|
-
export declare const FormDataProvider:
|
|
18
|
+
export declare const FormDataProvider: <T extends FormFieldConfig<string, any, any>>({ config, initialData, children, ...props }: PropsWithChildren<FormProviderProps<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
//# sourceMappingURL=FormDataProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormDataProvider.d.ts","sourceRoot":"","sources":["../../../../context/data/FormDataProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormDataProvider.d.ts","sourceRoot":"","sources":["../../../../context/data/FormDataProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAgB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACH,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,sBAAsB,EACzB,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IAC1E,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IAC5C;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,+CAKzE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,4CAiBzC,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormDataProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const useFormStore_1 = require("../../hook/useFormStore");
|
|
7
8
|
const util_1 = require("../../util");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FormStore } from "../../hook/useFormStore";
|
|
2
|
-
import { FormConfig, FormData, FormErrors } from "../../type";
|
|
3
|
-
export type
|
|
4
|
-
config: FormConfig
|
|
2
|
+
import { FormConfig, FormData, FormErrors, FormFieldConfig } from "../../type";
|
|
3
|
+
export type FormConfigContextProps<T extends FormFieldConfig<string, any, any>> = {
|
|
4
|
+
config: FormConfig<T>;
|
|
5
5
|
};
|
|
6
|
-
export declare const FormConfigContext: import("react").Context<
|
|
7
|
-
export interface FormDataContext {
|
|
8
|
-
data: FormStore<FormData
|
|
9
|
-
editData: FormStore<FormData
|
|
6
|
+
export declare const FormConfigContext: import("react").Context<FormConfigContextProps<FormFieldConfig<string, any, any>>>;
|
|
7
|
+
export interface FormDataContext<T extends FormFieldConfig<string, any, any>> {
|
|
8
|
+
data: FormStore<FormData<T>>;
|
|
9
|
+
editData: FormStore<FormData<T>>;
|
|
10
10
|
errors: FormStore<FormErrors>;
|
|
11
11
|
}
|
|
12
|
-
export declare const FormDataContext: import("react").Context<FormDataContext
|
|
12
|
+
export declare const FormDataContext: import("react").Context<FormDataContext<FormFieldConfig<string, any, any>>>;
|
|
13
13
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../context/data/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../context/data/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/E,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI;IAC9E,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oFAEsD,CAAC;AAErF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACxE,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,6EAE3B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormDataContext = exports.FormConfigContext = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
exports.FormConfigContext = (0, react_1.createContext)(undefined);
|
|
6
7
|
exports.FormDataContext = (0, react_1.createContext)(undefined);
|
package/dist/es/guard/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormCustomConfig, FormEntryConfig, FormFieldConfig, FormRowConfig, FormSectionConfig } from "../type";
|
|
2
|
-
export declare const isFormRowConfig: <T extends FormFieldConfig
|
|
3
|
-
export declare const isFormSectionConfig: <T extends FormFieldConfig
|
|
4
|
-
export declare const isFormCustomConfig: <T extends FormFieldConfig
|
|
5
|
-
export declare const isFormFieldConfig: <T extends FormFieldConfig
|
|
2
|
+
export declare const isFormRowConfig: <T extends FormFieldConfig<string, any, any>>(config: FormEntryConfig<T>) => config is FormRowConfig<T>;
|
|
3
|
+
export declare const isFormSectionConfig: <T extends FormFieldConfig<string, any, any>>(config: FormEntryConfig<T>) => config is FormSectionConfig<T>;
|
|
4
|
+
export declare const isFormCustomConfig: <T extends FormFieldConfig<string, any, any>>(config: FormEntryConfig<T>) => config is FormCustomConfig<T>;
|
|
5
|
+
export declare const isFormFieldConfig: <T extends FormFieldConfig<string, any, any>>(config: FormEntryConfig<T>) => config is T;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../guard/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../guard/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,EACb,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAC/D,eAAe,CAAC,CAAC,CAAC,KAC3B,MAAM,IAAI,aAAa,CAAC,CAAC,CAE3B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UACnE,eAAe,CAAC,CAAC,CAAC,KAC3B,MAAM,IAAI,iBAAiB,CAAC,CAAC,CAE/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAClE,eAAe,CAAC,CAAC,CAAC,KAC3B,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAE9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UACjE,eAAe,CAAC,CAAC,CAAC,KAC3B,MAAM,IAAI,CAEZ,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { FormFieldConfig } from "type";
|
|
2
3
|
import { FormProviderProps } from "../context/data/FormDataProvider";
|
|
3
|
-
export declare const withForm: <T>(WrappedComponent: React.ComponentType<FormProviderProps & T>) => {
|
|
4
|
-
(props: FormProviderProps & T): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const withForm: <U extends FormFieldConfig<string, any, any>, T>(WrappedComponent: React.ComponentType<FormProviderProps<U> & T>) => {
|
|
5
|
+
(props: FormProviderProps<U> & T): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
displayName: string;
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=withForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withForm.d.ts","sourceRoot":"","sources":["../../../hoc/withForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"withForm.d.ts","sourceRoot":"","sources":["../../../hoc/withForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,oBACjD,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAIzB,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC;;CAYjE,CAAC"}
|
package/dist/es/hoc/withForm.js
CHANGED
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withForm = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const context_1 = require("../context");
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
const withForm = (WrappedComponent) => {
|
|
7
8
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
8
9
|
const ComponentWithProvider = (props) => {
|
|
9
|
-
return (
|
|
10
|
+
return (
|
|
11
|
+
// @ts-expect-error: ts does not understand this
|
|
12
|
+
(0, jsx_runtime_1.jsx)(context_1.FormProvider, { ...props, children: (0, jsx_runtime_1.jsx)(WrappedComponent, { ...props }) }));
|
|
10
13
|
};
|
|
11
14
|
ComponentWithProvider.displayName = `withForm(${displayName})`;
|
|
12
15
|
return ComponentWithProvider;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { FormFieldConfig } from "type";
|
|
2
3
|
import { FormProviderProps } from "../context/data/FormDataProvider";
|
|
3
|
-
export declare const withFormData: <T>(WrappedComponent: React.ComponentType<FormProviderProps & T>) => {
|
|
4
|
-
(props: FormProviderProps & T): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const withFormData: <U extends FormFieldConfig<string, any, any>, T>(WrappedComponent: React.ComponentType<FormProviderProps<U> & T>) => {
|
|
5
|
+
(props: FormProviderProps<U> & T): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
displayName: string;
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=withFormData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFormData.d.ts","sourceRoot":"","sources":["../../../hoc/withFormData.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAoB,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"withFormData.d.ts","sourceRoot":"","sources":["../../../hoc/withFormData.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGvF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,oBACrD,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAIzB,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC;;CAWjE,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withFormData = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const FormDataProvider_1 = require("../context/data/FormDataProvider");
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
const withFormData = (WrappedComponent) => {
|
|
7
8
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
8
9
|
const ComponentWithProvider = (props) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FormData } from "../type";
|
|
1
|
+
import { FormData, FormFieldConfig } from "../type";
|
|
2
2
|
import { FormStore } from "./useFormStore";
|
|
3
|
-
export declare const useFormData: <SelectorOutput
|
|
3
|
+
export declare const useFormData: <SelectorOutput, T extends FormFieldConfig<string, any, any>>(selector: (store: FormData<T>) => SelectorOutput) => [SelectorOutput, (value: Partial<FormData<T>>) => void, () => FormData<T>];
|
|
4
4
|
export declare const useData: <Store, SelectorOutput>(data: FormStore<Store>, selector: (store: Store) => SelectorOutput) => [SelectorOutput, (value: Partial<Store>) => void, () => Store];
|
|
5
5
|
//# sourceMappingURL=useFormData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormData.d.ts","sourceRoot":"","sources":["../../../hook/useFormData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useFormData.d.ts","sourceRoot":"","sources":["../../../hook/useFormData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,eAAO,MAAM,WAAW,GAAI,cAAc,EAAE,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,YACzE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,cAAc,KACjD,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAQ3E,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,EAAE,cAAc,QACnC,SAAS,CAAC,KAAK,CAAC,YACZ,CAAC,KAAK,EAAE,KAAK,KAAK,cAAc,KAC3C,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,MAAM,KAAK,CAQ/D,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useData = exports.useFormData = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const context_1 = require("../context/data/context");
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
const useFormData = (selector) => {
|
|
7
8
|
const { data } = (0, react_1.useContext)(context_1.FormDataContext);
|
|
8
9
|
if (!data) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FormConfig, FormError, FormErrors, FormFieldConfig } from "../type";
|
|
2
2
|
export type FormValidations = ReturnType<typeof useFormValidations>;
|
|
3
|
-
export declare const useFormValidations: (config: FormConfig
|
|
3
|
+
export declare const useFormValidations: <T extends FormFieldConfig<string, any, any>>(config: FormConfig<T>, fieldConfigs: Record<string, T>) => {
|
|
4
4
|
errors: import("./useFormStore").FormStore<FormErrors>;
|
|
5
|
-
validateField: (field:
|
|
5
|
+
validateField: (field: T, skipUpdate?: boolean) => FormError | null;
|
|
6
6
|
validateCategory: (category: string) => FormErrors;
|
|
7
|
-
validateForm: (input?: FormConfig
|
|
7
|
+
validateForm: (input?: FormConfig<T>, skipUpdate?: boolean) => FormErrors | null;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=useFormValidations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormValidations.d.ts","sourceRoot":"","sources":["../../../hook/useFormValidations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI7E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useFormValidations.d.ts","sourceRoot":"","sources":["../../../hook/useFormValidations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI7E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAGpE,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAClE,UAAU,CAAC,CAAC,CAAC,gBACP,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;;2BAqDnB,CAAC,eAAe,OAAO,KAAG,SAAS,GAAG,IAAI;iCAvBvC,MAAM;2BAvBT,UAAU,CAAC,CAAC,CAAC,eAAmC,OAAO,KAAG,UAAU,GAAG,IAAI;CA2D1F,CAAC"}
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const context_1 = require("../context/data/context");
|
|
6
6
|
const validation_1 = require("../validation");
|
|
7
7
|
const useRefEffect_1 = require("./useRefEffect");
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
const useFormValidations = (config, fieldConfigs) => {
|
|
9
10
|
const configRef = (0, useRefEffect_1.useRefEffect)(config);
|
|
10
11
|
const fieldConfigsRef = (0, useRefEffect_1.useRefEffect)(fieldConfigs);
|
package/dist/es/type/config.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { FormFieldConfig } from "./field";
|
|
3
|
-
export interface FormRowConfig<T extends FormFieldConfig
|
|
3
|
+
export interface FormRowConfig<T extends FormFieldConfig<string, any, any>> {
|
|
4
4
|
type: "row";
|
|
5
5
|
content: readonly FormEntryConfig<T>[];
|
|
6
6
|
}
|
|
7
|
-
export interface FormSectionConfig<T extends FormFieldConfig
|
|
7
|
+
export interface FormSectionConfig<T extends FormFieldConfig<string, any, any>> {
|
|
8
8
|
type: "section";
|
|
9
9
|
content: readonly FormEntryConfig<T>[];
|
|
10
10
|
}
|
|
11
|
-
export interface FormCustomConfig<T extends FormFieldConfig
|
|
11
|
+
export interface FormCustomConfig<T extends FormFieldConfig<string, any, any>> {
|
|
12
12
|
type: "custom";
|
|
13
13
|
wrapper: (children: ReactNode) => ReactNode;
|
|
14
14
|
content: readonly FormEntryConfig<T>[];
|
|
15
15
|
}
|
|
16
|
-
export type FormEntryConfig<T extends FormFieldConfig
|
|
17
|
-
export type FormConfig<T extends FormFieldConfig
|
|
16
|
+
export type FormEntryConfig<T extends FormFieldConfig<string, any, any>> = FormCustomConfig<T> | FormSectionConfig<T> | FormRowConfig<T> | T;
|
|
17
|
+
export type FormConfig<T extends FormFieldConfig<string, any, any>> = readonly FormEntryConfig<T>[];
|
|
18
18
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../type/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../type/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACtE,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IAC1E,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACzE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,CAAC;IAC5C,OAAO,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;CAC1C;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IACjE,gBAAgB,CAAC,CAAC,CAAC,GACnB,iBAAiB,CAAC,CAAC,CAAC,GACpB,aAAa,CAAC,CAAC,CAAC,GAChB,CAAC,CAAC;AAER,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -3,23 +3,20 @@ import { FormFieldConfig } from "./field";
|
|
|
3
3
|
export type Prettify<T> = {
|
|
4
4
|
[K in keyof T]: T[K];
|
|
5
5
|
} & unknown;
|
|
6
|
-
export type FormFieldInfer<Type, Config = FormFieldConfig
|
|
6
|
+
export type FormFieldInfer<Type, Config = FormFieldConfig<string, any, any>> = Config extends {
|
|
7
7
|
type: Type;
|
|
8
8
|
initialValue?: infer InitialValue;
|
|
9
9
|
} ? InitialValue : never;
|
|
10
10
|
export type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
11
|
-
export type FormInfer<Config extends FormConfig, Acc = object> = Config extends readonly [
|
|
12
|
-
infer Entry,
|
|
13
|
-
...infer Rest
|
|
14
|
-
] ? Entry extends {
|
|
11
|
+
export type FormInfer<Config extends FormConfig<AllConfigs>, AllConfigs extends FormFieldConfig<string, any, any>, Acc = object> = Config extends readonly [infer Entry, ...infer Rest] ? Entry extends {
|
|
15
12
|
content: infer Content;
|
|
16
|
-
} ? Prettify<UnionToIntersection<FormInfer<Extract<Content, FormConfig
|
|
13
|
+
} ? Prettify<UnionToIntersection<FormInfer<Extract<Content, FormConfig<AllConfigs>>, AllConfigs, Acc> & FormInfer<Extract<Rest, FormConfig<AllConfigs>>, AllConfigs, Acc>>> : Entry extends {
|
|
17
14
|
type: infer Type;
|
|
18
15
|
name: infer Name;
|
|
19
16
|
onInput?: infer InputFn;
|
|
20
|
-
} ? InputFn extends (...args: any) => infer Input ? FormInfer<Extract<Rest, FormConfig
|
|
17
|
+
} ? InputFn extends (...args: any) => infer Input ? FormInfer<Extract<Rest, FormConfig<AllConfigs>>, AllConfigs, Prettify<UnionToIntersection<{
|
|
21
18
|
[key in keyof Input]?: FormFieldInfer<Type>;
|
|
22
|
-
} & Acc>>> : FormInfer<Extract<Rest, FormConfig
|
|
19
|
+
} & Acc>>> : FormInfer<Extract<Rest, FormConfig<AllConfigs>>, AllConfigs, Prettify<UnionToIntersection<{
|
|
23
20
|
[key in Extract<Name, string>]?: FormFieldInfer<Type>;
|
|
24
21
|
} & Acc>>> : Acc : Acc;
|
|
25
22
|
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../type/extract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../type/extract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvB,GAAG,OAAO,CAAC;AAEZ,MAAM,MAAM,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,SAAS;IAC1F,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,YAAY,CAAC;CACrC,GACK,YAAY,GACZ,KAAK,CAAC;AAEZ,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAClF,CAAC,EAAE,MAAM,CAAC,KACT,IAAI,GACH,CAAC,GACD,KAAK,CAAC;AAEZ,MAAM,MAAM,SAAS,CACjB,MAAM,SAAS,UAAU,CAAC,UAAU,CAAC,EACrC,UAAU,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACpD,GAAG,GAAG,MAAM,IACZ,MAAM,SAAS,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAClD,KAAK,SAAS;IAAE,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,GACpC,QAAQ,CACJ,mBAAmB,CACf,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,GAChE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,CACxE,CACJ,GACD,KAAK,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,GAC3E,OAAO,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,KAAK,GACzC,SAAS,CACL,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,EACrC,UAAU,EACV,QAAQ,CACJ,mBAAmB,CACf;KACK,GAAG,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC;CAC9C,GAAG,GAAG,CACV,CACJ,CACJ,GACD,SAAS,CACL,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,EACrC,UAAU,EACV,QAAQ,CACJ,mBAAmB,CACf;KACK,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC;CACxD,GAAG,GAAG,CACV,CACJ,CACJ,GACL,GAAG,GACT,GAAG,CAAC"}
|
package/dist/es/type/field.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { FormFieldConditions } from "./condition";
|
|
2
2
|
import { FormData, FormInputFunc } from "./form";
|
|
3
3
|
import { FieldValidations, FormValidationStrategy } from "./validation";
|
|
4
|
-
export
|
|
5
|
-
type: Type;
|
|
4
|
+
export type FormFieldConfig<Type extends string, FieldConfig, InitialValue> = {
|
|
5
|
+
type: Type extends infer U ? U : never;
|
|
6
6
|
name: string;
|
|
7
|
-
initialValue?: InitialValue;
|
|
7
|
+
initialValue?: InitialValue extends infer U ? U : never;
|
|
8
8
|
conditions?: FormFieldConditions;
|
|
9
9
|
validationStrategy?: FormValidationStrategy;
|
|
10
|
-
validations?: readonly FieldValidations[];
|
|
10
|
+
validations?: readonly FieldValidations<FormFieldConfig<Type extends infer U ? U : never, FieldConfig extends infer U ? U : never, InitialValue extends infer U ? U : never>>[];
|
|
11
11
|
columns?: number;
|
|
12
12
|
categories?: readonly string[];
|
|
13
|
-
valueFn?: (data: FormData) => any;
|
|
14
|
-
onInput?: FormInputFunc
|
|
13
|
+
valueFn?: (data: FormData<FormFieldConfig<string, any, any>>) => any;
|
|
14
|
+
onInput?: FormInputFunc<FormFieldConfig<Type extends infer U ? U : never, FieldConfig extends infer U ? U : never, InitialValue extends infer U ? U : never>, InitialValue extends infer U ? U : never>;
|
|
15
15
|
fieldConfig: FormFieldConfigFunc<FieldConfig>;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
export type FormFieldConfigFunc<FieldConfig = unknown> = FieldConfig | ((props: {
|
|
18
18
|
value: any;
|
|
19
|
-
data: FormData
|
|
19
|
+
data: FormData<FormFieldConfig<string, any, any>>;
|
|
20
20
|
}) => FieldConfig);
|
|
21
|
-
export type ResolveFieldConfigFunc<T extends FormFieldConfig
|
|
21
|
+
export type ResolveFieldConfigFunc<T extends FormFieldConfig<string, any, any>> = T extends {
|
|
22
22
|
fieldConfig: infer U;
|
|
23
23
|
} ? U extends (...args: any[]) => any ? never : T & {
|
|
24
24
|
fieldConfig: U;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../type/field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../type/field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,MAAM,EAAE,WAAW,EAAE,YAAY,IAAI;IAC1E,IAAI,EAAE,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,YAAY,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxD,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IAC5C,WAAW,CAAC,EAAE,SAAS,gBAAgB,CACnC,eAAe,CACX,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAChC,WAAW,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EACvC,YAAY,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAC3C,CACJ,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;IACrE,OAAO,CAAC,EAAE,aAAa,CACnB,eAAe,CACX,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAChC,WAAW,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EACvC,YAAY,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAC3C,EACD,YAAY,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAC3C,CAAC;IACF,WAAW,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,WAAW,GAAG,OAAO,IAC/C,WAAW,GACX,CAAC,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;CAAE,KAAK,WAAW,CAAC,CAAC;AAElG,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS;IACxF,WAAW,EAAE,MAAM,CAAC,CAAC;CACxB,GACK,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAC7B,KAAK,GACL,CAAC,GAAG;IAAE,WAAW,EAAE,CAAC,CAAA;CAAE,GAC1B,KAAK,CAAC"}
|
package/dist/es/type/form.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { JSXElementConstructor, PropsWithChildren, ReactNode } from "react";
|
|
2
|
-
import { FormFieldConfig
|
|
2
|
+
import { FormFieldConfig } from "./field";
|
|
3
3
|
import { FormError } from "./validation";
|
|
4
|
-
export type FormData = Record<string,
|
|
4
|
+
export type FormData<T extends FormFieldConfig<string, any, any>> = Record<string, T extends {
|
|
5
|
+
initialValue?: infer K;
|
|
6
|
+
} ? K : never>;
|
|
5
7
|
export interface FormBuilderComponents {
|
|
6
8
|
BuilderWrapper: JSXElementConstructor<PropsWithChildren>;
|
|
7
9
|
SectionWrapper: JSXElementConstructor<PropsWithChildren>;
|
|
@@ -10,21 +12,21 @@ export interface FormBuilderComponents {
|
|
|
10
12
|
columns?: number;
|
|
11
13
|
}>>;
|
|
12
14
|
}
|
|
13
|
-
export interface FormBuilderChildrenProps {
|
|
15
|
+
export interface FormBuilderChildrenProps<T extends FormFieldConfig<string, any, any>> {
|
|
14
16
|
value: any;
|
|
15
17
|
error: FormError | undefined;
|
|
16
18
|
onInput: (value: any) => void;
|
|
17
19
|
onBlur: () => void;
|
|
18
|
-
field:
|
|
20
|
+
field: T;
|
|
19
21
|
}
|
|
20
|
-
export interface FormBuilderProps {
|
|
22
|
+
export interface FormBuilderProps<T extends FormFieldConfig<string, any, any>> {
|
|
21
23
|
Components?: Partial<FormBuilderComponents>;
|
|
22
|
-
children(props: FormBuilderChildrenProps): ReactNode;
|
|
24
|
+
children(props: FormBuilderChildrenProps<T>): ReactNode;
|
|
23
25
|
}
|
|
24
|
-
export interface FormInputFuncProps<
|
|
25
|
-
value:
|
|
26
|
-
field:
|
|
27
|
-
previousData: FormData
|
|
26
|
+
export interface FormInputFuncProps<Field extends FormFieldConfig<string, any, any>, InitialValue> {
|
|
27
|
+
value: InitialValue;
|
|
28
|
+
field: Field;
|
|
29
|
+
previousData: FormData<Field>;
|
|
28
30
|
}
|
|
29
|
-
export type FormInputFunc
|
|
31
|
+
export type FormInputFunc<Field extends FormFieldConfig<string, any, any>, InitialValue> = (props: FormInputFuncProps<Field, InitialValue>) => FormData<FormFieldConfig<string, any, any>>;
|
|
30
32
|
//# sourceMappingURL=form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../type/form.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../type/form.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CACtE,MAAM,EACN,CAAC,SAAS;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CACnD,CAAC;AAEF,MAAM,WAAW,qBAAqB;IAClC,cAAc,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACzD,cAAc,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACzD,UAAU,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACrD,YAAY,EAAE,qBAAqB,CAAC,iBAAiB,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CAChF;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACjF,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAC3D;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,YAAY;IAC7F,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,YAAY,IAAI,CACvF,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAAE,YAAY,CAAC,KAC7C,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
package/dist/es/type/form.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Type 'FormFieldText' is not assignable to type 'FormEntryConfig<FormFieldConfig<string, unknown, unknown, FormFieldText | FormFieldNumber>>'.
|
|
4
|
+
// Type 'FormFieldText' is not assignable to type 'FormFieldConfig<string, unknown, unknown, FormFieldText | FormFieldNumber>'.
|
|
5
|
+
// Types of property 'onInput' are incompatible.
|
|
6
|
+
// Type 'FormInputFunc<FormFieldConfig<"text", { label: string; }, string, never>, never, string> | undefined' is not assignable to type 'FormInputFunc<FormFieldConfig<string, unknown, unknown, FormFieldText | FormFieldNumber>, FormFieldText | FormFieldNumber, unknown> | undefined'.
|
|
7
|
+
// Type 'FormInputFunc<FormFieldConfig<"text", { label: string; }, string, never>, never, string>' is not assignable to type 'FormInputFunc<FormFieldConfig<string, unknown, unknown, FormFieldText | FormFieldNumber>, FormFieldText | FormFieldNumber, unknown>'.
|
|
8
|
+
// Types of parameters 'props' and 'props' are incompatible.
|
|
9
|
+
// Type 'FormInputFuncProps<FormFieldConfig<string, unknown, unknown, FormFieldText | FormFieldNumber>, FormFieldText | FormFieldNumber, unknown>' is not assignable to type 'FormInputFuncProps<FormFieldConfig<"text", { label: string; }, string, never>, never, string>'.
|
|
10
|
+
// Types of property 'value' are incompatible.
|
|
11
|
+
// Type 'unknown' is not assignable to type 'string'.ts(2322)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { FormFieldConfig } from "./field";
|
|
1
2
|
import { FormData } from "./form";
|
|
2
3
|
export type FormValidationStrategy = "blur" | "input" | "manual";
|
|
3
4
|
export type FormError = string | boolean;
|
|
4
5
|
export type FormErrors = Record<string, FormError>;
|
|
5
|
-
export type FormFieldValidationFunction = (props: {
|
|
6
|
+
export type FormFieldValidationFunction<T extends FormFieldConfig<string, any, any>> = (props: {
|
|
6
7
|
value: any;
|
|
7
|
-
data: FormData
|
|
8
|
+
data: FormData<T>;
|
|
8
9
|
}) => boolean;
|
|
9
|
-
export type FormFieldValidation = boolean | RegExp | FormFieldValidationFunction
|
|
10
|
-
export interface FieldValidations {
|
|
11
|
-
validation: FormFieldValidation
|
|
10
|
+
export type FormFieldValidation<T extends FormFieldConfig<string, any, any>> = boolean | RegExp | FormFieldValidationFunction<T>;
|
|
11
|
+
export interface FieldValidations<T extends FormFieldConfig<string, any, any>> {
|
|
12
|
+
validation: FormFieldValidation<T>;
|
|
12
13
|
message?: string;
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../type/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../type/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE;IAC3F,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACrB,KAAK,OAAO,CAAC;AAEd,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IACrE,OAAO,GACP,MAAM,GACN,2BAA2B,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IACzE,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/es/util/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { FormConfig, FormData, FormEntryConfig, FormFieldConfig
|
|
1
|
+
import { FormConfig, FormData, FormEntryConfig, FormFieldConfig } from "../type";
|
|
2
2
|
export declare function eitherOr<const T>(config: T | false | undefined | null | 0 | ""): T;
|
|
3
3
|
export declare function eitherOr<const Either, const Or>(condition: boolean, either: Either, or: Or): Either | Or;
|
|
4
|
-
export declare const createFormConfig: <const T extends
|
|
5
|
-
export declare const fieldConfigFromFormField: <T extends FormFieldConfig
|
|
6
|
-
export declare const fieldsFromConfig: (config: FormConfig) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
4
|
+
export declare const createFormConfig: <const T extends FormFieldConfig<string, any, any>>(config: FormConfig<T>) => FormConfig<T>;
|
|
5
|
+
export declare const fieldConfigFromFormField: <T extends FormFieldConfig<string, any, any>>({ name, fieldConfig }: T, data: FormData<T>) => T["fieldConfig"];
|
|
6
|
+
export declare const fieldsFromConfig: <T extends FormFieldConfig<string, any, any>>(config: FormConfig<T>) => { [K in T["name"]]: Extract<T, {
|
|
7
|
+
name: K;
|
|
8
|
+
}>; };
|
|
9
|
+
export declare const initialValuesFromConfig: <T extends FormFieldConfig<string, any, any>>(config: FormConfig<T>) => FormData<T>;
|
|
10
|
+
export declare const mapFieldConfigs: <T extends FormFieldConfig<string, any, any>>(entries: FormConfig<T>, callbackFn: (field: T, index: number) => T) => FormConfig<T>;
|
|
11
|
+
export declare const reduceFieldConfigs: <T extends Record<string | number, any>, U extends FormFieldConfig<string, any, any>>(entries: FormConfig<U>, callbackFn: (acc: T, field: U, index: number) => T) => T;
|
|
12
|
+
export declare const someFieldConfigs: (entries: readonly FormEntryConfig<any>[], callbackFn: <T extends FormFieldConfig<string, any, any>>(field: T, index: number) => boolean) => boolean;
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../util/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../util/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjF,wBAAgB,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACpF,wBAAgB,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAC3C,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,EAAE,GACP,MAAM,GAAG,EAAE,CAAC;AAaf,eAAO,MAAM,gBAAgB,SAAU,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UACtE,UAAU,CAAC,CAAC,CAAC,kBACmB,CAAC;AAE7C,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,yBACzD,CAAC,QAClB,QAAQ,CAAC,CAAC,CAAC,KAClB,CAAC,CAAC,aAAa,CAIjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UAChE,UAAU,CAAC,CAAC,CAAC,KACtB,GACE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,GAY5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,UACvE,UAAU,CAAC,CAAC,CAAC,KACtB,QAAQ,CAAC,CAAC,CAeZ,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,WAC9D,UAAU,CAAC,CAAC,CAAC,cACV,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,KAC3C,UAAU,CAAC,CAAC,CAkBd,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC3B,CAAC,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACtC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,WAElC,UAAU,CAAC,CAAC,CAAC,cACV,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,KACnD,CAeF,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAChB,SAAS,eAAe,CAAC,GAAG,CAAC,EAAE,cAC5B,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,KAC9F,OAWF,CAAC"}
|
package/dist/es/util/index.js
CHANGED
|
@@ -5,8 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.someFieldConfigs = exports.reduceFieldConfigs = exports.mapFieldConfigs = exports.initialValuesFromConfig = exports.fieldsFromConfig = exports.fieldConfigFromFormField = exports.createFormConfig = void 0;
|
|
7
7
|
exports.eitherOr = eitherOr;
|
|
8
|
-
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
9
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
10
|
+
const guard_1 = require("../guard");
|
|
10
11
|
function eitherOr(configOrCondition, either, or) {
|
|
11
12
|
if (typeof configOrCondition === "boolean") {
|
|
12
13
|
return configOrCondition ? either : or;
|
|
@@ -25,6 +26,7 @@ const fieldConfigFromFormField = ({ name, fieldConfig }, data) => {
|
|
|
25
26
|
exports.fieldConfigFromFormField = fieldConfigFromFormField;
|
|
26
27
|
const fieldsFromConfig = (config) => {
|
|
27
28
|
return (0, exports.reduceFieldConfigs)(config, (acc, field) => {
|
|
29
|
+
// @ts-expect-error: ts does not understand this
|
|
28
30
|
acc[field.name] = field;
|
|
29
31
|
return acc;
|
|
30
32
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FormConfig, FormData, FormErrors, FormFieldConfig } from "../type";
|
|
2
|
-
export declare const handleValidateConfig: (config: FormConfig, fieldConfigs: Record<string, FormFieldConfig
|
|
3
|
-
export declare const handleValidateField: ({ name, validations, conditions, valueFn }: FormFieldConfig, fieldConfigs: Record<string, FormFieldConfig
|
|
2
|
+
export declare const handleValidateConfig: (config: FormConfig<FormFieldConfig<string, any, any>>, fieldConfigs: Record<string, FormFieldConfig<string, any, any>>, data: FormData<FormFieldConfig<string, any, any>>) => FormErrors;
|
|
3
|
+
export declare const handleValidateField: ({ name, validations, conditions, valueFn }: FormFieldConfig<string, any, any>, fieldConfigs: Record<string, FormFieldConfig<string, any, any>>, data: FormData<FormFieldConfig<string, any, any>>) => FormErrors;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../validation/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../validation/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAmB,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE7F,eAAO,MAAM,oBAAoB,WACrB,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,gBACvC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QACzD,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAClD,UAYF,CAAC;AAiBF,eAAO,MAAM,mBAAmB,+CACgB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,gBAC/D,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QACzD,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAClD,UA8BF,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleValidateField = exports.handleValidateConfig = void 0;
|
|
4
|
-
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
const condition_1 = require("../condition");
|
|
6
|
+
const guard_1 = require("../guard");
|
|
6
7
|
const handleValidateConfig = (config, fieldConfigs, data) => {
|
|
7
8
|
const errors = {};
|
|
8
9
|
config.forEach(entry => {
|
package/package.json
CHANGED
package/dist/cjs/type/test.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TextConfigProps {
|
|
2
|
-
type: "text";
|
|
3
|
-
placeholder: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
editLabel?: string;
|
|
6
|
-
maxLength?: number;
|
|
7
|
-
info?: string;
|
|
8
|
-
suffix?: string;
|
|
9
|
-
hideValidation?: boolean;
|
|
10
|
-
hasCapsLockDetection?: boolean;
|
|
11
|
-
isSecret?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../type/test.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
package/dist/cjs/type/test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const configAllFields = [
|
|
4
|
-
{
|
|
5
|
-
type: "button",
|
|
6
|
-
name: "text",
|
|
7
|
-
validations: [{ validation: true }],
|
|
8
|
-
fieldConfig: {
|
|
9
|
-
placeholder: "text",
|
|
10
|
-
type: "text",
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
console.log(configAllFields);
|
package/dist/es/type/test.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TextConfigProps {
|
|
2
|
-
type: "text";
|
|
3
|
-
placeholder: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
editLabel?: string;
|
|
6
|
-
maxLength?: number;
|
|
7
|
-
info?: string;
|
|
8
|
-
suffix?: string;
|
|
9
|
-
hideValidation?: boolean;
|
|
10
|
-
hasCapsLockDetection?: boolean;
|
|
11
|
-
isSecret?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=test.d.ts.map
|