@gravity-ui/dynamic-forms 3.7.0 → 4.0.1
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/build/cjs/lib/core/components/Form/Controller/Controller.js +2 -2
- package/build/cjs/lib/core/components/Form/Controller/utils.js +45 -34
- package/build/cjs/lib/core/components/Form/DynamicField.js +6 -4
- package/build/cjs/lib/core/components/Form/hooks/useCreateContext.js +2 -2
- package/build/cjs/lib/core/components/Form/hooks/useCreateSearchContext.js +2 -2
- package/build/cjs/lib/core/components/Form/hooks/useIntegrationFF.js +6 -4
- package/build/cjs/lib/core/components/Form/hooks/useMutators.js +11 -7
- package/build/cjs/lib/core/components/Form/hooks/useSearchStore.js +4 -3
- package/build/cjs/lib/core/components/Form/hooks/useStore.js +15 -11
- package/build/cjs/lib/core/components/Form/utils/common.js +14 -11
- package/build/cjs/lib/core/components/View/helpers.js +5 -5
- package/build/cjs/lib/core/components/View/hooks/useComponents.js +2 -2
- package/build/cjs/lib/core/components/View/hooks/useCreateContext.js +2 -2
- package/build/cjs/lib/core/components/View/hooks/useRender.js +4 -3
- package/build/cjs/lib/core/helpers.js +5 -4
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
- package/build/cjs/lib/kit/components/Card/Card.css +3 -2
- package/build/cjs/lib/kit/components/Card/Card.js +2 -2
- package/build/cjs/lib/kit/components/CopyButton/CopyButton.js +1 -1
- package/build/cjs/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -1
- package/build/cjs/lib/kit/components/GenerateRandomValueButton/GenerateRandomValueButton.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +2 -2
- package/build/cjs/lib/kit/components/Inputs/MultiOneOf/MultiOneOf.js +4 -3
- package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +4 -3
- package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +4 -3
- package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +4 -3
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +8 -2
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -3
- package/build/cjs/lib/kit/components/Inputs/Text/Text.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.css +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
- package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +4 -3
- package/build/cjs/lib/kit/components/Layouts/Row/Row.css +2 -2
- package/build/cjs/lib/kit/components/Layouts/Row/Row.js +2 -2
- package/build/cjs/lib/kit/components/Layouts/Section/Section.css +2 -2
- package/build/cjs/lib/kit/components/LazyLoader/LazyLoader.js +2 -2
- package/build/cjs/lib/kit/components/LongValue/LongValue.css +3 -0
- package/build/cjs/lib/kit/components/LongValue/LongValue.js +1 -1
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
- package/build/cjs/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
- package/build/cjs/lib/kit/components/Views/ArrayBaseView/ArrayBaseView.js +2 -2
- package/build/cjs/lib/kit/components/Views/BaseView/BaseView.js +2 -2
- package/build/cjs/lib/kit/components/Views/CardOneOfView.js +2 -2
- package/build/cjs/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
- package/build/cjs/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +2 -2
- package/build/cjs/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.js +2 -2
- package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +2 -2
- package/build/cjs/lib/kit/components/Views/OneOfView/OneOfView.js +2 -2
- package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +2 -2
- package/build/cjs/lib/kit/hooks/useOneOf/useOneOf.js +5 -4
- package/build/cjs/lib/kit/utils/common.js +30 -25
- package/build/cjs/lib/kit/validators/validators.js +9 -7
- package/build/esm/lib/core/components/Form/Controller/Controller.d.ts +1 -1
- package/build/esm/lib/core/components/Form/Controller/Controller.js +2 -2
- package/build/esm/lib/core/components/Form/Controller/types.d.ts +6 -6
- package/build/esm/lib/core/components/Form/Controller/utils.d.ts +10 -10
- package/build/esm/lib/core/components/Form/Controller/utils.js +45 -34
- package/build/esm/lib/core/components/Form/DynamicField.js +6 -4
- package/build/esm/lib/core/components/Form/hooks/useCreateContext.js +2 -2
- package/build/esm/lib/core/components/Form/hooks/useCreateSearchContext.js +2 -2
- package/build/esm/lib/core/components/Form/hooks/useGenerateRandomValue.d.ts +1 -1
- package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.js +6 -4
- package/build/esm/lib/core/components/Form/hooks/useMutators.js +11 -7
- package/build/esm/lib/core/components/Form/hooks/useSearchStore.js +4 -3
- package/build/esm/lib/core/components/Form/hooks/useStore.js +15 -11
- package/build/esm/lib/core/components/Form/types/array.d.ts +12 -12
- package/build/esm/lib/core/components/Form/types/boolean.d.ts +12 -12
- package/build/esm/lib/core/components/Form/types/config.d.ts +1 -1
- package/build/esm/lib/core/components/Form/types/input.d.ts +13 -13
- package/build/esm/lib/core/components/Form/types/layout.d.ts +5 -5
- package/build/esm/lib/core/components/Form/types/number.d.ts +12 -12
- package/build/esm/lib/core/components/Form/types/object.d.ts +12 -12
- package/build/esm/lib/core/components/Form/types/string.d.ts +12 -12
- package/build/esm/lib/core/components/Form/utils/common.js +14 -11
- package/build/esm/lib/core/components/View/ViewController.d.ts +1 -1
- package/build/esm/lib/core/components/View/helpers.js +5 -5
- package/build/esm/lib/core/components/View/hooks/useComponents.d.ts +1 -1
- package/build/esm/lib/core/components/View/hooks/useComponents.js +2 -2
- package/build/esm/lib/core/components/View/hooks/useCreateContext.js +2 -2
- package/build/esm/lib/core/components/View/hooks/useRender.d.ts +1 -1
- package/build/esm/lib/core/components/View/hooks/useRender.js +4 -3
- package/build/esm/lib/core/helpers.d.ts +5 -5
- package/build/esm/lib/core/helpers.js +5 -4
- package/build/esm/lib/core/types/specs.d.ts +6 -6
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
- package/build/esm/lib/kit/components/Card/Card.css +3 -2
- package/build/esm/lib/kit/components/Card/Card.js +2 -2
- package/build/esm/lib/kit/components/CopyButton/CopyButton.js +1 -1
- package/build/esm/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -1
- package/build/esm/lib/kit/components/GenerateRandomValueButton/GenerateRandomValueButton.js +2 -2
- package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
- package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +2 -2
- package/build/esm/lib/kit/components/Inputs/MultiOneOf/MultiOneOf.js +4 -3
- package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +4 -3
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +4 -3
- package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
- package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +4 -3
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +8 -2
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -3
- package/build/esm/lib/kit/components/Inputs/Text/Text.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.css +2 -2
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +4 -3
- package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/CardAccordeon.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/CardSection.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/Row/Row.css +2 -2
- package/build/esm/lib/kit/components/Layouts/Row/Row.d.ts +2 -2
- package/build/esm/lib/kit/components/Layouts/Row/Row.js +2 -2
- package/build/esm/lib/kit/components/Layouts/Section/Section.css +2 -2
- package/build/esm/lib/kit/components/Layouts/Section/Section.d.ts +6 -6
- package/build/esm/lib/kit/components/Layouts/TableCell/TableCell.d.ts +1 -1
- package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.d.ts +1 -1
- package/build/esm/lib/kit/components/LazyLoader/LazyLoader.js +2 -2
- package/build/esm/lib/kit/components/LongValue/LongValue.css +3 -0
- package/build/esm/lib/kit/components/LongValue/LongValue.js +1 -1
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
- package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewSection/ViewSection.d.ts +4 -4
- package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.d.ts +1 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.d.ts +1 -1
- package/build/esm/lib/kit/components/Views/ArrayBaseView/ArrayBaseView.js +2 -2
- package/build/esm/lib/kit/components/Views/BaseView/BaseView.js +2 -2
- package/build/esm/lib/kit/components/Views/CardOneOfView.js +2 -2
- package/build/esm/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
- package/build/esm/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +2 -2
- package/build/esm/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.js +2 -2
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +2 -2
- package/build/esm/lib/kit/components/Views/OneOfView/OneOfView.js +2 -2
- package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +2 -2
- package/build/esm/lib/kit/hooks/useOneOf/useOneOf.d.ts +1 -1
- package/build/esm/lib/kit/hooks/useOneOf/useOneOf.js +5 -4
- package/build/esm/lib/kit/utils/common.d.ts +1 -1
- package/build/esm/lib/kit/utils/common.js +30 -25
- package/build/esm/lib/kit/utils/objectInline.d.ts +1 -1
- package/build/esm/lib/kit/validators/validators.js +9 -7
- package/package.json +11 -11
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import _ from 'lodash';
|
|
3
2
|
import debounce from 'lodash/debounce';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import isFunction from 'lodash/isFunction';
|
|
5
|
+
import values from 'lodash/values';
|
|
4
6
|
import { Field as FinalFormField, useForm } from 'react-final-form';
|
|
5
7
|
import { transformArrOut } from '../utils';
|
|
6
8
|
export const useIntegrationFF = (store, withoutDebounce) => {
|
|
@@ -13,9 +15,9 @@ export const useIntegrationFF = (store, withoutDebounce) => {
|
|
|
13
15
|
validate: () => {
|
|
14
16
|
const asyncErrors = [];
|
|
15
17
|
let error;
|
|
16
|
-
|
|
18
|
+
values(store.errors).forEach((err) => {
|
|
17
19
|
if (err) {
|
|
18
|
-
if (
|
|
20
|
+
if (isFunction(err === null || err === void 0 ? void 0 : err.then)) {
|
|
19
21
|
asyncErrors.push(err);
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
@@ -34,7 +36,7 @@ export const useIntegrationFF = (store, withoutDebounce) => {
|
|
|
34
36
|
const change = React.useMemo(() => {
|
|
35
37
|
const cb = (value) => {
|
|
36
38
|
if (store.name) {
|
|
37
|
-
form.change(store.name,
|
|
39
|
+
form.change(store.name, get(transformArrOut(value), store.name));
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
42
|
if (withoutDebounce) {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
5
|
+
import keys from 'lodash/keys';
|
|
6
|
+
import set from 'lodash/set';
|
|
3
7
|
export const useMutators = (externalMutators) => {
|
|
4
8
|
const merge = React.useCallback((mutators, store) => {
|
|
5
9
|
const mergeSpec = (a = {}, b) => {
|
|
6
|
-
const result =
|
|
10
|
+
const result = cloneDeep(a);
|
|
7
11
|
const getKeys = (parent) => {
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
12
|
+
if (isObjectLike(parent)) {
|
|
13
|
+
return keys(parent).reduce((acc, parentKey) => {
|
|
10
14
|
const childKeys = getKeys(parent[parentKey]);
|
|
11
15
|
return [
|
|
12
16
|
...acc,
|
|
@@ -18,14 +22,14 @@ export const useMutators = (externalMutators) => {
|
|
|
18
22
|
return [];
|
|
19
23
|
};
|
|
20
24
|
getKeys(b).forEach((key) => {
|
|
21
|
-
|
|
25
|
+
set(result, [key[0], 'value', ...key.slice(1)], get(b, key));
|
|
22
26
|
});
|
|
23
27
|
return result;
|
|
24
28
|
};
|
|
25
29
|
const mergeValuesOrErrors = (a = {}, b) => {
|
|
26
|
-
const result =
|
|
30
|
+
const result = cloneDeep(a);
|
|
27
31
|
Object.keys(b).forEach((key) => {
|
|
28
|
-
|
|
32
|
+
set(result, [key, 'value'], b[key]);
|
|
29
33
|
});
|
|
30
34
|
return result;
|
|
31
35
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import isUndefined from 'lodash/isUndefined';
|
|
3
|
+
import omit from 'lodash/omit';
|
|
3
4
|
import { getParentName } from '../';
|
|
4
5
|
export const useSearchStore = () => {
|
|
5
6
|
const [store, setStore] = React.useState({});
|
|
@@ -20,7 +21,7 @@ export const useSearchStore = () => {
|
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
+
if (isUndefined(selfFlag)) {
|
|
24
25
|
return false;
|
|
25
26
|
}
|
|
26
27
|
return true;
|
|
@@ -29,7 +30,7 @@ export const useSearchStore = () => {
|
|
|
29
30
|
store,
|
|
30
31
|
setField: (name, search) => setStore((store) => (Object.assign(Object.assign({}, store), { [name]: search }))),
|
|
31
32
|
removeField: (name) => {
|
|
32
|
-
setStore((store) =>
|
|
33
|
+
setStore((store) => omit(store, name));
|
|
33
34
|
},
|
|
34
35
|
isHiddenField,
|
|
35
36
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import clone from 'lodash/clone';
|
|
3
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import omit from 'lodash/omit';
|
|
6
|
+
import set from 'lodash/set';
|
|
3
7
|
import { useFormState } from 'react-final-form';
|
|
4
8
|
import { transformArrIn } from '../utils';
|
|
5
9
|
export const useStore = (name) => {
|
|
@@ -7,37 +11,37 @@ export const useStore = (name) => {
|
|
|
7
11
|
const firstRenderRef = React.useRef(true);
|
|
8
12
|
const [store, setStore] = React.useState(() => {
|
|
9
13
|
const values = transformArrIn({
|
|
10
|
-
[name]:
|
|
14
|
+
[name]: get(formState.values, name),
|
|
11
15
|
});
|
|
12
16
|
const initialValue = transformArrIn({
|
|
13
|
-
[name]:
|
|
17
|
+
[name]: get(formState.initialValues, name),
|
|
14
18
|
});
|
|
15
19
|
return {
|
|
16
20
|
name,
|
|
17
|
-
initialValue:
|
|
18
|
-
values:
|
|
21
|
+
initialValue: cloneDeep(initialValue),
|
|
22
|
+
values: cloneDeep(values),
|
|
19
23
|
errors: {},
|
|
20
24
|
};
|
|
21
25
|
});
|
|
22
26
|
const submitFailed = formState.submitFailed;
|
|
23
27
|
const tools = React.useMemo(() => ({
|
|
24
28
|
initialValue: store.initialValue,
|
|
25
|
-
onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values:
|
|
26
|
-
onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { values:
|
|
29
|
+
onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values: set(Object.assign({}, store.values), name, clone(value)), errors: errors || {} }))),
|
|
30
|
+
onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { values: omit(store.values, name), errors: omit(store.errors, Object.keys(store.errors).filter((key) => key.startsWith(name))) }))),
|
|
27
31
|
submitFailed,
|
|
28
32
|
}), [store.initialValue, setStore, submitFailed]);
|
|
29
33
|
React.useEffect(() => {
|
|
30
34
|
if (!firstRenderRef.current) {
|
|
31
35
|
const values = transformArrIn({
|
|
32
|
-
[name]:
|
|
36
|
+
[name]: get(formState.values, name),
|
|
33
37
|
});
|
|
34
38
|
const initialValue = transformArrIn({
|
|
35
|
-
[name]:
|
|
39
|
+
[name]: get(formState.initialValues, name),
|
|
36
40
|
});
|
|
37
41
|
setStore({
|
|
38
42
|
name: name,
|
|
39
|
-
initialValue:
|
|
40
|
-
values:
|
|
43
|
+
initialValue: cloneDeep(initialValue),
|
|
44
|
+
values: cloneDeep(values),
|
|
41
45
|
errors: {},
|
|
42
46
|
});
|
|
43
47
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ArraySpec, ArrayValue } from '../../../types';
|
|
2
2
|
import { FieldArrayValue, IndependentInputEntity, IndependentInputProps, IndependentInputType, InputEntity, InputProps, InputType, InputsMap, LayoutProps, LayoutType, LayoutsMap, TypeConfig, ValidatorsMap } from './';
|
|
3
|
-
export type ArrayInputProps<InputComponentProps extends Record<string, any> =
|
|
4
|
-
export type ArrayIndependentInputProps<InputComponentProps extends Record<string, any> =
|
|
5
|
-
export type ArrayLayoutProps<LayoutComponentProps extends Record<string, any> =
|
|
6
|
-
export type ArrayInput<InputComponentProps extends Record<string, any> =
|
|
7
|
-
export type ArrayIndependentInput<InputComponentProps extends Record<string, any> =
|
|
8
|
-
export type ArrayLayout<LayoutComponentProps extends Record<string, any> =
|
|
9
|
-
export type ArrayInputEntity = InputEntity<FieldArrayValue, ArraySpec
|
|
10
|
-
export type ArrayIndependentInputEntity = IndependentInputEntity<FieldArrayValue, ArraySpec
|
|
11
|
-
export type ArrayInputsMap = InputsMap<FieldArrayValue, ArraySpec
|
|
12
|
-
export type ArrayLayoutsMap = LayoutsMap<FieldArrayValue, ArraySpec
|
|
13
|
-
export type ArrayValidatorsMap = ValidatorsMap<ArrayValue, ArraySpec
|
|
14
|
-
export type ArrayConfig = TypeConfig<FieldArrayValue, ArrayValue, ArraySpec
|
|
3
|
+
export type ArrayInputProps<InputComponentProps extends Record<string, any> | undefined = undefined> = InputProps<FieldArrayValue, InputComponentProps, undefined, ArraySpec<undefined, InputComponentProps, undefined>>;
|
|
4
|
+
export type ArrayIndependentInputProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputProps<FieldArrayValue, InputComponentProps, LayoutComponentProps, ArraySpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
5
|
+
export type ArrayLayoutProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutProps<FieldArrayValue, InputComponentProps, LayoutComponentProps, ArraySpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
6
|
+
export type ArrayInput<InputComponentProps extends Record<string, any> | undefined = undefined> = InputType<FieldArrayValue, InputComponentProps, undefined, ArraySpec<undefined, InputComponentProps, undefined>>;
|
|
7
|
+
export type ArrayIndependentInput<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputType<FieldArrayValue, InputComponentProps, LayoutComponentProps, ArraySpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
8
|
+
export type ArrayLayout<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutType<FieldArrayValue, InputComponentProps, LayoutComponentProps, ArraySpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
9
|
+
export type ArrayInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined> = InputEntity<FieldArrayValue, InputComponentProps, undefined, ArraySpec<undefined, InputComponentProps, undefined>>;
|
|
10
|
+
export type ArrayIndependentInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputEntity<FieldArrayValue, InputComponentProps, LayoutComponentProps, ArraySpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
11
|
+
export type ArrayInputsMap = InputsMap<FieldArrayValue, ArraySpec<undefined, any, any>>;
|
|
12
|
+
export type ArrayLayoutsMap = LayoutsMap<FieldArrayValue, ArraySpec<undefined, any, any>>;
|
|
13
|
+
export type ArrayValidatorsMap = ValidatorsMap<ArrayValue, ArraySpec<undefined, any, any>>;
|
|
14
|
+
export type ArrayConfig = TypeConfig<FieldArrayValue, ArrayValue, ArraySpec<undefined, any, any>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BooleanSpec } from '../../../types';
|
|
2
2
|
import { IndependentInputEntity, IndependentInputProps, IndependentInputType, InputEntity, InputProps, InputType, InputsMap, LayoutProps, LayoutType, LayoutsMap, TypeConfig, ValidatorsMap } from './';
|
|
3
|
-
export type BooleanInputProps<InputComponentProps extends Record<string, any> =
|
|
4
|
-
export type BooleanIndependentInputProps<InputComponentProps extends Record<string, any> =
|
|
5
|
-
export type BooleanLayoutProps<LayoutComponentProps extends Record<string, any> =
|
|
6
|
-
export type BooleanInput<InputComponentProps extends Record<string, any> =
|
|
7
|
-
export type BooleanIndependentInput<InputComponentProps extends Record<string, any> =
|
|
8
|
-
export type BooleanLayout<LayoutComponentProps extends Record<string, any> =
|
|
9
|
-
export type BooleanInputEntity = InputEntity<boolean, BooleanSpec
|
|
10
|
-
export type BooleanIndependentInputEntity = IndependentInputEntity<boolean, BooleanSpec
|
|
11
|
-
export type BooleanInputsMap = InputsMap<boolean, BooleanSpec
|
|
12
|
-
export type BooleanLayoutsMap = LayoutsMap<boolean, BooleanSpec
|
|
13
|
-
export type BooleanValidatorsMap = ValidatorsMap<boolean, BooleanSpec
|
|
14
|
-
export type BooleanConfig = TypeConfig<boolean, boolean, BooleanSpec
|
|
3
|
+
export type BooleanInputProps<InputComponentProps extends Record<string, any> | undefined = undefined> = InputProps<boolean, InputComponentProps, undefined, BooleanSpec<undefined, InputComponentProps, undefined>>;
|
|
4
|
+
export type BooleanIndependentInputProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputProps<boolean, InputComponentProps, LayoutComponentProps, BooleanSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
5
|
+
export type BooleanLayoutProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutProps<boolean, InputComponentProps, LayoutComponentProps, BooleanSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
6
|
+
export type BooleanInput<InputComponentProps extends Record<string, any> | undefined = undefined> = InputType<boolean, InputComponentProps, undefined, BooleanSpec<undefined, InputComponentProps, undefined>>;
|
|
7
|
+
export type BooleanIndependentInput<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputType<boolean, InputComponentProps, LayoutComponentProps, BooleanSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
8
|
+
export type BooleanLayout<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutType<boolean, InputComponentProps, LayoutComponentProps, BooleanSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
9
|
+
export type BooleanInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined> = InputEntity<boolean, InputComponentProps, undefined, BooleanSpec<undefined, InputComponentProps, undefined>>;
|
|
10
|
+
export type BooleanIndependentInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputEntity<boolean, InputComponentProps, LayoutComponentProps, BooleanSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
11
|
+
export type BooleanInputsMap = InputsMap<boolean, BooleanSpec<undefined, any, any>>;
|
|
12
|
+
export type BooleanLayoutsMap = LayoutsMap<boolean, BooleanSpec<undefined, any, any>>;
|
|
13
|
+
export type BooleanValidatorsMap = ValidatorsMap<boolean, BooleanSpec<undefined, any, any>>;
|
|
14
|
+
export type BooleanConfig = TypeConfig<boolean, boolean, BooleanSpec<undefined, any, any>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormValue, Spec } from '../../../types';
|
|
2
2
|
import { ArrayConfig, BooleanConfig, FieldValue, InputsMap, LayoutsMap, NumberConfig, ObjectConfig, StringConfig, ValidatorsMap } from './';
|
|
3
|
-
export interface TypeConfig<DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec
|
|
3
|
+
export interface TypeConfig<DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec<undefined, any, any>> {
|
|
4
4
|
inputs: InputsMap<DirtyValue, SpecType>;
|
|
5
5
|
layouts: LayoutsMap<DirtyValue, SpecType>;
|
|
6
6
|
validators: ValidatorsMap<Value, SpecType>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Spec } from '../../../types';
|
|
3
3
|
import { FieldRenderProps, FieldValue, LayoutType } from './';
|
|
4
|
-
export type InputProps<Value extends FieldValue, SpecType extends Spec> = {
|
|
4
|
+
export type InputProps<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = {
|
|
5
5
|
spec: SpecType;
|
|
6
6
|
name: string;
|
|
7
|
-
inputProps?:
|
|
7
|
+
inputProps?: InputComponentProps;
|
|
8
8
|
} & FieldRenderProps<Value>;
|
|
9
|
-
export type IndependentInputProps<Value extends FieldValue, SpecType extends Spec> = {
|
|
10
|
-
Layout: LayoutType<Value, SpecType> | undefined;
|
|
11
|
-
layoutProps?:
|
|
12
|
-
} & InputProps<Value, SpecType>;
|
|
13
|
-
export type InputType<Value extends FieldValue, SpecType extends Spec> = (props: InputProps<Value, SpecType>) => React.ReactElement | null;
|
|
14
|
-
export type IndependentInputType<Value extends FieldValue, SpecType extends Spec> = (props: IndependentInputProps<Value, SpecType>) => React.ReactElement | null;
|
|
15
|
-
export type InputEntity<Value extends FieldValue, SpecType extends Spec> = {
|
|
16
|
-
Component: InputType<Value, SpecType>;
|
|
9
|
+
export type IndependentInputProps<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = {
|
|
10
|
+
Layout: LayoutType<Value, InputComponentProps, LayoutComponentProps, SpecType> | undefined;
|
|
11
|
+
layoutProps?: LayoutComponentProps;
|
|
12
|
+
} & InputProps<Value, InputComponentProps, LayoutComponentProps, SpecType>;
|
|
13
|
+
export type InputType<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = (props: InputProps<Value, InputComponentProps, LayoutComponentProps, SpecType>) => React.ReactElement | null;
|
|
14
|
+
export type IndependentInputType<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = (props: IndependentInputProps<Value, InputComponentProps, LayoutComponentProps, SpecType>) => React.ReactElement | null;
|
|
15
|
+
export type InputEntity<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = {
|
|
16
|
+
Component: InputType<Value, InputComponentProps, LayoutComponentProps, SpecType>;
|
|
17
17
|
independent?: false;
|
|
18
18
|
};
|
|
19
|
-
export type IndependentInputEntity<Value extends FieldValue, SpecType extends Spec> = {
|
|
20
|
-
Component: IndependentInputType<Value, SpecType>;
|
|
19
|
+
export type IndependentInputEntity<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = {
|
|
20
|
+
Component: IndependentInputType<Value, InputComponentProps, LayoutComponentProps, SpecType>;
|
|
21
21
|
independent: true;
|
|
22
22
|
};
|
|
23
|
-
export type InputsMap<Value extends FieldValue, SpecType extends Spec> = Record<string, InputEntity<Value, SpecType> | IndependentInputEntity<Value, SpecType> | undefined>;
|
|
23
|
+
export type InputsMap<Value extends FieldValue, SpecType extends Spec<undefined, any, any> = Spec> = Record<string, InputEntity<Value, any, any, SpecType> | IndependentInputEntity<Value, any, any, SpecType> | undefined>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Spec } from '../../../types';
|
|
3
3
|
import { FieldValue, InputProps } from './';
|
|
4
|
-
export type LayoutProps<Value extends FieldValue, SpecType extends Spec> = {
|
|
4
|
+
export type LayoutProps<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = {
|
|
5
5
|
children: React.ReactElement;
|
|
6
|
-
layoutProps?:
|
|
7
|
-
} & InputProps<Value, SpecType>;
|
|
8
|
-
export type LayoutType<Value extends FieldValue, SpecType extends Spec> = (props: LayoutProps<Value, SpecType>) => React.ReactElement | null;
|
|
9
|
-
export type LayoutsMap<Value extends FieldValue, SpecType extends Spec> = Record<string, LayoutType<Value, SpecType> | undefined>;
|
|
6
|
+
layoutProps?: LayoutComponentProps;
|
|
7
|
+
} & Omit<InputProps<Value, InputComponentProps, LayoutComponentProps, SpecType>, 'inputProps'>;
|
|
8
|
+
export type LayoutType<Value extends FieldValue, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined, SpecType extends Spec<undefined, InputComponentProps, LayoutComponentProps> = Spec> = (props: LayoutProps<Value, InputComponentProps, LayoutComponentProps, SpecType>) => React.ReactElement | null;
|
|
9
|
+
export type LayoutsMap<Value extends FieldValue, SpecType extends Spec<undefined, any, any> = Spec> = Record<string, LayoutType<Value, any, any, SpecType> | undefined>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { NumberSpec } from '../../../types';
|
|
2
2
|
import { IndependentInputEntity, IndependentInputProps, IndependentInputType, InputEntity, InputProps, InputType, InputsMap, LayoutProps, LayoutType, LayoutsMap, TypeConfig, ValidatorsMap } from './';
|
|
3
|
-
export type NumberInputProps<InputComponentProps extends Record<string, any> =
|
|
4
|
-
export type NumberIndependentInputProps<InputComponentProps extends Record<string, any> =
|
|
5
|
-
export type NumberLayoutProps<LayoutComponentProps extends Record<string, any> =
|
|
6
|
-
export type NumberInput<InputComponentProps extends Record<string, any> =
|
|
7
|
-
export type NumberIndependentInput<InputComponentProps extends Record<string, any> =
|
|
8
|
-
export type NumberLayout<LayoutComponentProps extends Record<string, any> =
|
|
9
|
-
export type NumberInputEntity = InputEntity<number, NumberSpec
|
|
10
|
-
export type NumberIndependentInputEntity = IndependentInputEntity<number, NumberSpec
|
|
11
|
-
export type NumberInputsMap = InputsMap<number, NumberSpec
|
|
12
|
-
export type NumberLayoutsMap = LayoutsMap<number, NumberSpec
|
|
13
|
-
export type NumberValidatorsMap = ValidatorsMap<number, NumberSpec
|
|
14
|
-
export type NumberConfig = TypeConfig<number, number, NumberSpec
|
|
3
|
+
export type NumberInputProps<InputComponentProps extends Record<string, any> | undefined = undefined> = InputProps<number, InputComponentProps, undefined, NumberSpec<undefined, InputComponentProps, undefined>>;
|
|
4
|
+
export type NumberIndependentInputProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputProps<number, InputComponentProps, LayoutComponentProps, NumberSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
5
|
+
export type NumberLayoutProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutProps<number, InputComponentProps, LayoutComponentProps, NumberSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
6
|
+
export type NumberInput<InputComponentProps extends Record<string, any> | undefined = undefined> = InputType<number, InputComponentProps, undefined, NumberSpec<undefined, InputComponentProps, undefined>>;
|
|
7
|
+
export type NumberIndependentInput<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputType<number, InputComponentProps, LayoutComponentProps, NumberSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
8
|
+
export type NumberLayout<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutType<number, InputComponentProps, LayoutComponentProps, NumberSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
9
|
+
export type NumberInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined> = InputEntity<number, InputComponentProps, undefined, NumberSpec<undefined, InputComponentProps, undefined>>;
|
|
10
|
+
export type NumberIndependentInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputEntity<number, InputComponentProps, LayoutComponentProps, NumberSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
11
|
+
export type NumberInputsMap = InputsMap<number, NumberSpec<undefined, any, any>>;
|
|
12
|
+
export type NumberLayoutsMap = LayoutsMap<number, NumberSpec<undefined, any, any>>;
|
|
13
|
+
export type NumberValidatorsMap = ValidatorsMap<number, NumberSpec<undefined, any, any>>;
|
|
14
|
+
export type NumberConfig = TypeConfig<number, number, NumberSpec<undefined, any, any>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ObjectSpec, ObjectValue } from '../../../types';
|
|
2
2
|
import { FieldObjectValue, IndependentInputEntity, IndependentInputProps, IndependentInputType, InputEntity, InputProps, InputType, InputsMap, LayoutProps, LayoutType, LayoutsMap, TypeConfig, ValidatorsMap } from './';
|
|
3
|
-
export type ObjectInputProps<InputComponentProps extends Record<string, any> =
|
|
4
|
-
export type ObjectIndependentInputProps<InputComponentProps extends Record<string, any> =
|
|
5
|
-
export type ObjectLayoutProps<LayoutComponentProps extends Record<string, any> =
|
|
6
|
-
export type ObjectInput<InputComponentProps extends Record<string, any> =
|
|
7
|
-
export type ObjectIndependentInput<InputComponentProps extends Record<string, any> =
|
|
8
|
-
export type ObjectLayout<LayoutComponentProps extends Record<string, any> =
|
|
9
|
-
export type ObjectInputEntity = InputEntity<FieldObjectValue, ObjectSpec
|
|
10
|
-
export type ObjectIndependentInputEntity = IndependentInputEntity<FieldObjectValue, ObjectSpec
|
|
11
|
-
export type ObjectInputsMap = InputsMap<FieldObjectValue, ObjectSpec
|
|
12
|
-
export type ObjectLayoutsMap = LayoutsMap<FieldObjectValue, ObjectSpec
|
|
13
|
-
export type ObjectValidatorsMap = ValidatorsMap<ObjectValue, ObjectSpec
|
|
14
|
-
export type ObjectConfig = TypeConfig<FieldObjectValue, ObjectValue, ObjectSpec
|
|
3
|
+
export type ObjectInputProps<InputComponentProps extends Record<string, any> | undefined = undefined> = InputProps<FieldObjectValue, InputComponentProps, undefined, ObjectSpec<undefined, InputComponentProps, undefined>>;
|
|
4
|
+
export type ObjectIndependentInputProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputProps<FieldObjectValue, InputComponentProps, LayoutComponentProps, ObjectSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
5
|
+
export type ObjectLayoutProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutProps<FieldObjectValue, InputComponentProps, LayoutComponentProps, ObjectSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
6
|
+
export type ObjectInput<InputComponentProps extends Record<string, any> | undefined = undefined> = InputType<FieldObjectValue, InputComponentProps, undefined, ObjectSpec<undefined, InputComponentProps, undefined>>;
|
|
7
|
+
export type ObjectIndependentInput<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputType<FieldObjectValue, InputComponentProps, LayoutComponentProps, ObjectSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
8
|
+
export type ObjectLayout<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutType<FieldObjectValue, InputComponentProps, LayoutComponentProps, ObjectSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
9
|
+
export type ObjectInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined> = InputEntity<FieldObjectValue, InputComponentProps, undefined, ObjectSpec<undefined, InputComponentProps, undefined>>;
|
|
10
|
+
export type ObjectIndependentInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputEntity<FieldObjectValue, InputComponentProps, LayoutComponentProps, ObjectSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
11
|
+
export type ObjectInputsMap = InputsMap<FieldObjectValue, ObjectSpec<undefined, any, any>>;
|
|
12
|
+
export type ObjectLayoutsMap = LayoutsMap<FieldObjectValue, ObjectSpec<undefined, any, any>>;
|
|
13
|
+
export type ObjectValidatorsMap = ValidatorsMap<ObjectValue, ObjectSpec<undefined, any, any>>;
|
|
14
|
+
export type ObjectConfig = TypeConfig<FieldObjectValue, ObjectValue, ObjectSpec<undefined, any, any>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { StringSpec } from '../../../types';
|
|
2
2
|
import { IndependentInputEntity, IndependentInputProps, IndependentInputType, InputEntity, InputProps, InputType, InputsMap, LayoutProps, LayoutType, LayoutsMap, TypeConfig, ValidatorsMap } from './';
|
|
3
|
-
export type StringInputProps<InputComponentProps extends Record<string, any> =
|
|
4
|
-
export type StringIndependentInputProps<InputComponentProps extends Record<string, any> =
|
|
5
|
-
export type StringLayoutProps<LayoutComponentProps extends Record<string, any> =
|
|
6
|
-
export type StringInput<InputComponentProps extends Record<string, any> =
|
|
7
|
-
export type StringIndependentInput<InputComponentProps extends Record<string, any> =
|
|
8
|
-
export type StringLayout<LayoutComponentProps extends Record<string, any> =
|
|
9
|
-
export type StringInputEntity = InputEntity<string, StringSpec
|
|
10
|
-
export type StringIndependentInputEntity = IndependentInputEntity<string, StringSpec
|
|
11
|
-
export type StringInputsMap = InputsMap<string, StringSpec
|
|
12
|
-
export type StringLayoutsMap = LayoutsMap<string, StringSpec
|
|
13
|
-
export type StringValidatorsMap = ValidatorsMap<string, StringSpec
|
|
14
|
-
export type StringConfig = TypeConfig<string, string, StringSpec
|
|
3
|
+
export type StringInputProps<InputComponentProps extends Record<string, any> | undefined = undefined> = InputProps<string, InputComponentProps, undefined, StringSpec<undefined, InputComponentProps, undefined>>;
|
|
4
|
+
export type StringIndependentInputProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputProps<string, InputComponentProps, LayoutComponentProps, StringSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
5
|
+
export type StringLayoutProps<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutProps<string, InputComponentProps, LayoutComponentProps, StringSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
6
|
+
export type StringInput<InputComponentProps extends Record<string, any> | undefined = undefined> = InputType<string, InputComponentProps, undefined, StringSpec<undefined, InputComponentProps, undefined>>;
|
|
7
|
+
export type StringIndependentInput<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputType<string, InputComponentProps, LayoutComponentProps, StringSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
8
|
+
export type StringLayout<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = LayoutType<string, InputComponentProps, LayoutComponentProps, StringSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
9
|
+
export type StringInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined> = InputEntity<string, InputComponentProps, undefined, StringSpec<undefined, InputComponentProps, undefined>>;
|
|
10
|
+
export type StringIndependentInputEntity<InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> = IndependentInputEntity<string, InputComponentProps, LayoutComponentProps, StringSpec<undefined, InputComponentProps, LayoutComponentProps>>;
|
|
11
|
+
export type StringInputsMap = InputsMap<string, StringSpec<undefined, any, any>>;
|
|
12
|
+
export type StringLayoutsMap = LayoutsMap<string, StringSpec<undefined, any, any>>;
|
|
13
|
+
export type StringValidatorsMap = ValidatorsMap<string, StringSpec<undefined, any, any>>;
|
|
14
|
+
export type StringConfig = TypeConfig<string, string, StringSpec<undefined, any, any>>;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import forEach from 'lodash/forEach';
|
|
2
|
+
import isArray from 'lodash/isArray';
|
|
3
|
+
import isObject from 'lodash/isObject';
|
|
4
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
2
5
|
import { SpecTypes } from '../../../constants';
|
|
3
6
|
import { isStringSpec } from '../../../helpers';
|
|
4
7
|
import { OBJECT_ARRAY_CNT, OBJECT_ARRAY_FLAG, SPEC_TYPE_FOR_GENERATE_BUTTON } from '../constants';
|
|
5
|
-
export const isCorrectConfig = (candidate) => Object.values(SpecTypes).every((type) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export const isCorrectConfig = (candidate) => Object.values(SpecTypes).every((type) => isObjectLike(candidate) &&
|
|
9
|
+
isObjectLike(candidate[type]) &&
|
|
10
|
+
isObjectLike(candidate[type].inputs) &&
|
|
11
|
+
isObjectLike(candidate[type].layouts) &&
|
|
12
|
+
isObjectLike(candidate[type].validators));
|
|
10
13
|
export const transformArrIn = (value) => {
|
|
11
|
-
if (
|
|
14
|
+
if (isArray(value)) {
|
|
12
15
|
return value.reduce((arrObj, item, idx) => {
|
|
13
16
|
arrObj[`<${idx}>`] = transformArrIn(item);
|
|
14
17
|
return arrObj;
|
|
15
18
|
}, { [OBJECT_ARRAY_FLAG]: true, [OBJECT_ARRAY_CNT]: value.length });
|
|
16
19
|
}
|
|
17
|
-
if (
|
|
20
|
+
if (isObject(value)) {
|
|
18
21
|
const _value = Object.assign({}, value);
|
|
19
|
-
|
|
22
|
+
forEach(_value, (item, key) => {
|
|
20
23
|
_value[key] = transformArrIn(item);
|
|
21
24
|
});
|
|
22
25
|
return _value;
|
|
@@ -24,7 +27,7 @@ export const transformArrIn = (value) => {
|
|
|
24
27
|
return value;
|
|
25
28
|
};
|
|
26
29
|
export const transformArrOut = (value) => {
|
|
27
|
-
if (
|
|
30
|
+
if (isObject(value) && !isArray(value)) {
|
|
28
31
|
if (value[OBJECT_ARRAY_FLAG]) {
|
|
29
32
|
const _value = Object.keys(value)
|
|
30
33
|
.filter((key) => key !== OBJECT_ARRAY_FLAG && key !== OBJECT_ARRAY_CNT)
|
|
@@ -34,7 +37,7 @@ export const transformArrOut = (value) => {
|
|
|
34
37
|
return _value;
|
|
35
38
|
}
|
|
36
39
|
const _value = Object.assign({}, value);
|
|
37
|
-
|
|
40
|
+
forEach(_value, (item, key) => {
|
|
38
41
|
_value[key] = transformArrOut(item);
|
|
39
42
|
});
|
|
40
43
|
return _value;
|
|
@@ -3,4 +3,4 @@ export interface ViewControllerProps<SpecType extends Spec> {
|
|
|
3
3
|
spec: SpecType;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
|
-
export declare const ViewController: <SpecType extends Spec
|
|
6
|
+
export declare const ViewController: <SpecType extends Spec<any, undefined, undefined>>({ spec, name, }: ViewControllerProps<SpecType>) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
2
2
|
import { SpecTypes } from '../../constants';
|
|
3
|
-
export const isCorrectViewConfig = (candidate) => Object.values(SpecTypes).every((type) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export const isCorrectViewConfig = (candidate) => Object.values(SpecTypes).every((type) => isObjectLike(candidate) &&
|
|
4
|
+
isObjectLike(candidate[type]) &&
|
|
5
|
+
isObjectLike(candidate[type].views) &&
|
|
6
|
+
isObjectLike(candidate[type].layouts));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormValue, Spec } from '../../../types';
|
|
2
2
|
import { DynamicViewConfig, IndependentViewEntity, ViewEntity, ViewLayoutType } from '../types';
|
|
3
|
-
export declare const useComponents: <Value extends FormValue, SpecType extends Spec
|
|
3
|
+
export declare const useComponents: <Value extends FormValue, SpecType extends Spec<any, undefined, undefined>>(spec: SpecType, config: DynamicViewConfig) => {
|
|
4
4
|
viewEntity: ViewEntity<Value, SpecType> | IndependentViewEntity<Value, SpecType> | undefined;
|
|
5
5
|
Layout: ViewLayoutType<Value, SpecType> | undefined;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import isString from 'lodash/isString';
|
|
3
3
|
import { isValidElementType } from 'react-is';
|
|
4
4
|
import { isCorrectSpec } from '../../../helpers';
|
|
5
5
|
import { isCorrectViewConfig } from '../helpers';
|
|
@@ -21,7 +21,7 @@ export const useComponents = (spec, config) => {
|
|
|
21
21
|
return;
|
|
22
22
|
}, [views, (_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type]);
|
|
23
23
|
const Layout = React.useMemo(() => {
|
|
24
|
-
if (layouts &&
|
|
24
|
+
if (layouts && isString(spec.viewSpec.layout)) {
|
|
25
25
|
const Component = layouts[spec.viewSpec.layout];
|
|
26
26
|
if (isValidElementType(Component)) {
|
|
27
27
|
return Component;
|
|
@@ -12,4 +12,4 @@ export interface UseRenderParams<Value extends FormValue, SpecType extends Spec>
|
|
|
12
12
|
link: SpecType['viewSpec']['link'];
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
|
-
export declare const useRender: <Value extends FormValue, SpecType extends Spec
|
|
15
|
+
export declare const useRender: <Value extends FormValue, SpecType extends Spec<any, undefined, undefined>>({ value, name, spec, viewEntity, Layout, Link, }: UseRenderParams<Value, SpecType>) => JSX.Element | null;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import isString from 'lodash/isString';
|
|
3
4
|
import { isValidElementType } from 'react-is';
|
|
4
5
|
import { isCorrectSpec } from '../../../helpers';
|
|
5
6
|
export const useRender = ({ value, name, spec, viewEntity, Layout, Link, }) => {
|
|
6
7
|
const render = React.useMemo(() => {
|
|
7
8
|
var _a;
|
|
8
|
-
if (viewEntity && isCorrectSpec(spec) &&
|
|
9
|
+
if (viewEntity && isCorrectSpec(spec) && isString(name)) {
|
|
9
10
|
if (!spec.viewSpec.hidden) {
|
|
10
|
-
const currentValue = name ?
|
|
11
|
+
const currentValue = name ? get(value, name) : value;
|
|
11
12
|
const linkValue = isValidElementType(Link) && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.link) ? (React.createElement(Link, { value: currentValue, link: spec.viewSpec.link })) : undefined;
|
|
12
13
|
if (viewEntity.independent) {
|
|
13
14
|
const InputComponent = viewEntity.Component;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArraySpec, BooleanSpec, NumberSpec, ObjectSpec, StringSpec } from './types';
|
|
2
2
|
export declare const isCorrectSpec: (candidate: any) => boolean;
|
|
3
|
-
export declare const isArraySpec: (candidate: any) => candidate is ArraySpec<any,
|
|
4
|
-
export declare const isBooleanSpec: (candidate: any) => candidate is BooleanSpec<any,
|
|
5
|
-
export declare const isNumberSpec: (candidate: any) => candidate is NumberSpec<any,
|
|
6
|
-
export declare const isObjectSpec: (candidate: any) => candidate is ObjectSpec<any,
|
|
7
|
-
export declare const isStringSpec: (candidate: any) => candidate is StringSpec<any,
|
|
3
|
+
export declare const isArraySpec: (candidate: any) => candidate is ArraySpec<any, undefined, undefined>;
|
|
4
|
+
export declare const isBooleanSpec: (candidate: any) => candidate is BooleanSpec<any, undefined, undefined>;
|
|
5
|
+
export declare const isNumberSpec: (candidate: any) => candidate is NumberSpec<any, undefined, undefined>;
|
|
6
|
+
export declare const isObjectSpec: (candidate: any) => candidate is ObjectSpec<any, undefined, undefined>;
|
|
7
|
+
export declare const isStringSpec: (candidate: any) => candidate is StringSpec<any, undefined, undefined>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
2
|
+
import isString from 'lodash/isString';
|
|
2
3
|
import { SpecTypes } from './constants';
|
|
3
|
-
export const isCorrectSpec = (candidate) =>
|
|
4
|
+
export const isCorrectSpec = (candidate) => isObjectLike(candidate) &&
|
|
4
5
|
(candidate.type === SpecTypes.Array ||
|
|
5
6
|
candidate.type === SpecTypes.Boolean ||
|
|
6
7
|
candidate.type === SpecTypes.Number ||
|
|
7
8
|
candidate.type === SpecTypes.Object ||
|
|
8
9
|
candidate.type === SpecTypes.String) &&
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
isObjectLike(candidate.viewSpec) &&
|
|
11
|
+
isString(candidate.viewSpec.type);
|
|
11
12
|
export const isArraySpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.Array;
|
|
12
13
|
export const isBooleanSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.Boolean;
|
|
13
14
|
export const isNumberSpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === SpecTypes.Number;
|