@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
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Controller = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
7
7
|
const hooks_1 = require("../hooks");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const Controller = ({ spec: _spec, name, value: valueFromParent, parentOnChange, parentOnUnmount, }) => {
|
|
@@ -72,7 +72,7 @@ const Controller = ({ spec: _spec, name, value: valueFromParent, parentOnChange,
|
|
|
72
72
|
onItemRemove: methods.onItemRemove,
|
|
73
73
|
onDrop: methods.onDrop,
|
|
74
74
|
},
|
|
75
|
-
meta: Object.assign(Object.assign({},
|
|
75
|
+
meta: Object.assign(Object.assign({}, (0, omit_1.default)(store.state, 'value')), { submitFailed: store.tools.submitFailed }),
|
|
76
76
|
}), [methods, store.name, store.state, store.tools.submitFailed]);
|
|
77
77
|
const withSearch = (0, hooks_1.useSearch)(store.spec, store.state.value, store.name);
|
|
78
78
|
(0, hooks_1.useControllerMirror)(store.name, {
|
|
@@ -3,19 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateStore = exports.initializeStore = exports.getFieldMethods = exports.getFieldInitials = exports.getValidate = exports.getRender = exports.getComponents = exports.getSpec = exports.callUnmout = exports.updateParentStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
7
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
8
|
+
const isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
|
|
9
|
+
const isBoolean_1 = tslib_1.__importDefault(require("lodash/isBoolean"));
|
|
10
|
+
const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
|
|
11
|
+
const isFunction_1 = tslib_1.__importDefault(require("lodash/isFunction"));
|
|
12
|
+
const isNil_1 = tslib_1.__importDefault(require("lodash/isNil"));
|
|
13
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
14
|
+
const isUndefined_1 = tslib_1.__importDefault(require("lodash/isUndefined"));
|
|
15
|
+
const keys_1 = tslib_1.__importDefault(require("lodash/keys"));
|
|
16
|
+
const merge_1 = tslib_1.__importDefault(require("lodash/merge"));
|
|
17
|
+
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
7
18
|
const react_is_1 = require("react-is");
|
|
8
19
|
const constants_1 = require("../../../constants");
|
|
9
20
|
const helpers_1 = require("../../../helpers");
|
|
10
21
|
const constants_2 = require("../constants");
|
|
11
22
|
const utils_1 = require("../utils");
|
|
12
23
|
const isErrorMutatorCorrect = (errorMutator) => errorMutator !== constants_2.EMPTY_MUTATOR &&
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
((0, isString_1.default)(errorMutator.value) ||
|
|
25
|
+
(0, isBoolean_1.default)(errorMutator.value) ||
|
|
26
|
+
(0, isUndefined_1.default)(errorMutator.value));
|
|
16
27
|
const isValueMutatorCorrect = (valueMutator, spec) => valueMutator !== constants_2.EMPTY_MUTATOR &&
|
|
17
28
|
(typeof valueMutator.value === spec.type ||
|
|
18
|
-
(
|
|
29
|
+
((0, isArray_1.default)(valueMutator.value) && spec.type === constants_1.SpecTypes.Array) ||
|
|
19
30
|
valueMutator.value === undefined);
|
|
20
31
|
const updateParentStore = (store) => {
|
|
21
32
|
(store.parentOnChange ? store.parentOnChange : store.tools.onChange)(store.name, store.state.value, Object.assign(Object.assign({}, store.state.childErrors), { [store.name]: store.state.error }));
|
|
@@ -26,9 +37,9 @@ const callUnmout = (store) => {
|
|
|
26
37
|
};
|
|
27
38
|
exports.callUnmout = callUnmout;
|
|
28
39
|
const getSpec = ({ name, spec, mutatorsStore, }) => {
|
|
29
|
-
const mutator =
|
|
40
|
+
const mutator = (0, get_1.default)(mutatorsStore.spec, name, constants_2.EMPTY_MUTATOR);
|
|
30
41
|
if (mutator !== constants_2.EMPTY_MUTATOR) {
|
|
31
|
-
const mutatedSpec =
|
|
42
|
+
const mutatedSpec = (0, merge_1.default)((0, cloneDeep_1.default)(spec), mutator.value);
|
|
32
43
|
if ((0, helpers_1.isCorrectSpec)(mutatedSpec)) {
|
|
33
44
|
return mutatedSpec;
|
|
34
45
|
}
|
|
@@ -46,7 +57,7 @@ const getComponents = ({ spec, config, }) => {
|
|
|
46
57
|
result.inputEntity = entity;
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
|
-
if (layouts &&
|
|
60
|
+
if (layouts && (0, isString_1.default)(spec.viewSpec.layout)) {
|
|
50
61
|
const Component = layouts[spec.viewSpec.layout];
|
|
51
62
|
if ((0, react_is_1.isValidElementType)(Component)) {
|
|
52
63
|
result.Layout = Component;
|
|
@@ -58,7 +69,7 @@ const getComponents = ({ spec, config, }) => {
|
|
|
58
69
|
exports.getComponents = getComponents;
|
|
59
70
|
const getRender = ({ name, spec, inputEntity, Layout, }) => {
|
|
60
71
|
const render = (props) => {
|
|
61
|
-
if (inputEntity && (0, helpers_1.isCorrectSpec)(spec) &&
|
|
72
|
+
if (inputEntity && (0, helpers_1.isCorrectSpec)(spec) && (0, isString_1.default)(name)) {
|
|
62
73
|
if (!spec.viewSpec.hidden) {
|
|
63
74
|
const { layoutProps, inputProps } = spec.viewSpec;
|
|
64
75
|
if (inputEntity.independent) {
|
|
@@ -80,14 +91,14 @@ const getRender = ({ name, spec, inputEntity, Layout, }) => {
|
|
|
80
91
|
exports.getRender = getRender;
|
|
81
92
|
const getValidate = ({ spec, config, }) => {
|
|
82
93
|
let validate = () => undefined;
|
|
83
|
-
if ((0, utils_1.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec)) {
|
|
94
|
+
if ((0, utils_1.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec) && !spec.viewSpec.hidden) {
|
|
84
95
|
const { validators } = config[spec.type];
|
|
85
96
|
if (validators) {
|
|
86
|
-
if ((!
|
|
87
|
-
|
|
97
|
+
if ((!(0, isString_1.default)(spec.validator) || !spec.validator.length) &&
|
|
98
|
+
(0, isFunction_1.default)(validators.base)) {
|
|
88
99
|
validate = (value) => validators.base(spec, value);
|
|
89
100
|
}
|
|
90
|
-
if (
|
|
101
|
+
if ((0, isString_1.default)(spec.validator) && (0, isFunction_1.default)(validators[spec.validator])) {
|
|
91
102
|
validate = (value) => validators[spec.validator](spec, value);
|
|
92
103
|
}
|
|
93
104
|
}
|
|
@@ -96,12 +107,12 @@ const getValidate = ({ spec, config, }) => {
|
|
|
96
107
|
};
|
|
97
108
|
exports.getValidate = getValidate;
|
|
98
109
|
const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate, mutatorsStore, }) => {
|
|
99
|
-
const valueMutator = (0, utils_1.transformArrIn)(
|
|
100
|
-
let value =
|
|
110
|
+
const valueMutator = (0, utils_1.transformArrIn)((0, get_1.default)(mutatorsStore.values, name, constants_2.EMPTY_MUTATOR));
|
|
111
|
+
let value = (0, cloneDeep_1.default)(valueFromParent);
|
|
101
112
|
if (isValueMutatorCorrect(valueMutator, spec)) {
|
|
102
113
|
value = valueMutator.value;
|
|
103
114
|
}
|
|
104
|
-
if (
|
|
115
|
+
if ((0, isNil_1.default)(value)) {
|
|
105
116
|
if (spec.defaultValue) {
|
|
106
117
|
value = (0, utils_1.transformArrIn)(spec.defaultValue);
|
|
107
118
|
}
|
|
@@ -116,12 +127,12 @@ const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate,
|
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
|
-
let errorMutator =
|
|
130
|
+
let errorMutator = (0, get_1.default)(mutatorsStore.errors, name, constants_2.EMPTY_MUTATOR);
|
|
120
131
|
if (!isErrorMutatorCorrect(errorMutator)) {
|
|
121
132
|
errorMutator = { value: undefined };
|
|
122
133
|
}
|
|
123
134
|
const error = (validate === null || validate === void 0 ? void 0 : validate((0, utils_1.transformArrOut)(value))) || (errorMutator === null || errorMutator === void 0 ? void 0 : errorMutator.value);
|
|
124
|
-
const dirty = !
|
|
135
|
+
const dirty = !(0, isEqual_1.default)(value, initialValue);
|
|
125
136
|
return {
|
|
126
137
|
initialValue,
|
|
127
138
|
active: false,
|
|
@@ -141,7 +152,7 @@ exports.getFieldInitials = getFieldInitials;
|
|
|
141
152
|
const getFieldMethods = () => {
|
|
142
153
|
const onChange = (store, { valOrSetter, childErrors, errorMutator }) => {
|
|
143
154
|
const { state, validate, spec } = store;
|
|
144
|
-
const _value =
|
|
155
|
+
const _value = (0, isFunction_1.default)(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
|
|
145
156
|
const error = (validate === null || validate === void 0 ? void 0 : validate((0, utils_1.transformArrOut)(_value))) || errorMutator;
|
|
146
157
|
let value = (0, utils_1.transformArrIn)(_value);
|
|
147
158
|
if ((0, helpers_1.isNumberSpec)(spec) && !error) {
|
|
@@ -149,13 +160,13 @@ const getFieldMethods = () => {
|
|
|
149
160
|
}
|
|
150
161
|
let newChildErrors = Object.assign({}, state.childErrors);
|
|
151
162
|
if (childErrors) {
|
|
152
|
-
const nearestChildName =
|
|
163
|
+
const nearestChildName = (0, keys_1.default)(childErrors).sort((a, b) => a.length - b.length)[0];
|
|
153
164
|
if (nearestChildName) {
|
|
154
|
-
const existingСhildNames =
|
|
155
|
-
newChildErrors = Object.assign(Object.assign({},
|
|
165
|
+
const existingСhildNames = (0, keys_1.default)(newChildErrors).filter((childName) => childName.startsWith(nearestChildName));
|
|
166
|
+
newChildErrors = Object.assign(Object.assign({}, (0, omit_1.default)(newChildErrors, existingСhildNames)), childErrors);
|
|
156
167
|
}
|
|
157
168
|
}
|
|
158
|
-
const nextStore = Object.assign(Object.assign({}, store), { state: Object.assign(Object.assign({}, store.state), { dirty: !
|
|
169
|
+
const nextStore = Object.assign(Object.assign({}, store), { state: Object.assign(Object.assign({}, store.state), { dirty: !(0, isEqual_1.default)(value, state.initialValue), error, invalid: Boolean(error), modified: true, pristine: value === state.initialValue, touched: true, valid: !error, value, visited: true, childErrors: newChildErrors }) });
|
|
159
170
|
nextStore.afterStoreUpdateCB = () => (0, exports.updateParentStore)(nextStore);
|
|
160
171
|
return nextStore;
|
|
161
172
|
};
|
|
@@ -181,7 +192,7 @@ const getFieldMethods = () => {
|
|
|
181
192
|
if ((0, helpers_1.isArraySpec)(spec) || (0, helpers_1.isObjectSpec)(spec)) {
|
|
182
193
|
return onChange(store, {
|
|
183
194
|
valOrSetter: (currentValue) => currentValue
|
|
184
|
-
?
|
|
195
|
+
? (0, omit_1.default)(currentValue, childName.split(`${name}.`)[1])
|
|
185
196
|
: currentValue,
|
|
186
197
|
childErrors: { [childName]: false },
|
|
187
198
|
});
|
|
@@ -196,7 +207,7 @@ const getFieldMethods = () => {
|
|
|
196
207
|
});
|
|
197
208
|
const value = Object.assign(Object.assign({}, stateValue), { [`<${stateValue[constants_2.OBJECT_ARRAY_CNT]}>`]: (0, utils_1.transformArrIn)(_value), [constants_2.OBJECT_ARRAY_CNT]: stateValue[constants_2.OBJECT_ARRAY_CNT] + 1 });
|
|
198
209
|
const error = validate === null || validate === void 0 ? void 0 : validate((0, utils_1.transformArrOut)(value));
|
|
199
|
-
const nextStore = Object.assign(Object.assign({}, store), { state: Object.assign(Object.assign({}, store.state), { dirty: !
|
|
210
|
+
const nextStore = Object.assign(Object.assign({}, store), { state: Object.assign(Object.assign({}, store.state), { dirty: !(0, isEqual_1.default)(value, store.state.initialValue), error, invalid: Boolean(error), modified: true, pristine: value === store.state.initialValue, touched: true, valid: !error, value, visited: true }) });
|
|
200
211
|
nextStore.afterStoreUpdateCB = () => (0, exports.updateParentStore)(nextStore);
|
|
201
212
|
return nextStore;
|
|
202
213
|
};
|
|
@@ -225,7 +236,7 @@ const initializeStore = ({ name, spec: _spec, mutatorsStore, config, valueFromPa
|
|
|
225
236
|
valueFromParent,
|
|
226
237
|
validate,
|
|
227
238
|
mutatorsStore,
|
|
228
|
-
initialValue:
|
|
239
|
+
initialValue: (0, get_1.default)(tools.initialValue, name),
|
|
229
240
|
});
|
|
230
241
|
const initialsStore = {
|
|
231
242
|
name,
|
|
@@ -240,19 +251,19 @@ const initializeStore = ({ name, spec: _spec, mutatorsStore, config, valueFromPa
|
|
|
240
251
|
parentOnUnmount,
|
|
241
252
|
state,
|
|
242
253
|
};
|
|
243
|
-
if (!
|
|
254
|
+
if (!(0, isEqual_1.default)(valueFromParent, state.value) || state.error) {
|
|
244
255
|
initialsStore.afterStoreUpdateCB = () => (0, exports.updateParentStore)(initialsStore);
|
|
245
256
|
}
|
|
246
257
|
return initialsStore;
|
|
247
258
|
};
|
|
248
259
|
exports.initializeStore = initializeStore;
|
|
249
260
|
const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutatorsStore, valueFromParent, config, tools, methodOnChange, }) => {
|
|
250
|
-
const storeSpecMutator =
|
|
251
|
-
const storeValueMutator =
|
|
252
|
-
const storeErrorMutator =
|
|
253
|
-
const specMutator =
|
|
254
|
-
const valueMutator =
|
|
255
|
-
const errorMutator =
|
|
261
|
+
const storeSpecMutator = (0, get_1.default)(store.mutatorsStore.spec, store.name, constants_2.EMPTY_MUTATOR);
|
|
262
|
+
const storeValueMutator = (0, get_1.default)(store.mutatorsStore.values, store.name, constants_2.EMPTY_MUTATOR);
|
|
263
|
+
const storeErrorMutator = (0, get_1.default)(store.mutatorsStore.errors, store.name, constants_2.EMPTY_MUTATOR);
|
|
264
|
+
const specMutator = (0, get_1.default)(mutatorsStore.spec, name, constants_2.EMPTY_MUTATOR);
|
|
265
|
+
const valueMutator = (0, get_1.default)(mutatorsStore.values, name, constants_2.EMPTY_MUTATOR);
|
|
266
|
+
const errorMutator = (0, get_1.default)(mutatorsStore.errors, name, constants_2.EMPTY_MUTATOR);
|
|
256
267
|
const valueMutatorUpdated = isValueMutatorCorrect(valueMutator, (0, exports.getSpec)({ name, spec: _spec, mutatorsStore })) &&
|
|
257
268
|
valueMutator !== storeValueMutator;
|
|
258
269
|
const errorMutatorUpdated = isErrorMutatorCorrect(errorMutator) && errorMutator !== storeErrorMutator;
|
|
@@ -261,7 +272,7 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
261
272
|
parentOnUnmount !== store.parentOnUnmount ||
|
|
262
273
|
tools.onChange !== store.tools.onChange ||
|
|
263
274
|
tools.onUnmount !== store.tools.onUnmount;
|
|
264
|
-
const updateAllStore = !
|
|
275
|
+
const updateAllStore = !(0, isEqual_1.default)(_spec, store.initialSpec) ||
|
|
265
276
|
config !== store.config ||
|
|
266
277
|
(specMutator !== constants_2.EMPTY_MUTATOR && specMutator !== storeSpecMutator);
|
|
267
278
|
const updateAllStoreAndClearParentValues = name !== store.name;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DynamicField = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const isFunction_1 = tslib_1.__importDefault(require("lodash/isFunction"));
|
|
7
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
8
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
7
9
|
const react_is_1 = require("react-is");
|
|
8
10
|
const helpers_1 = require("../../helpers");
|
|
9
11
|
const Controller_1 = require("./Controller");
|
|
@@ -29,9 +31,9 @@ const DynamicField = ({ name, spec, config, Monaco, generateRandomValue, search,
|
|
|
29
31
|
setField,
|
|
30
32
|
removeField,
|
|
31
33
|
isHiddenField,
|
|
32
|
-
searchFunction:
|
|
34
|
+
searchFunction: (0, isFunction_1.default)(search) ? search : (0, utils_1.getDefaultSearchFunction)(search),
|
|
33
35
|
}), [isHiddenField, removeField, search, setField]);
|
|
34
|
-
const correctParams = react_1.default.useMemo(() =>
|
|
36
|
+
const correctParams = react_1.default.useMemo(() => (0, isString_1.default)(name) && (0, helpers_1.isCorrectSpec)(spec) && (0, utils_1.isCorrectConfig)(config), [name, spec, config]);
|
|
35
37
|
(0, hooks_1.useDynamicFieldMirror)({
|
|
36
38
|
useStore: { tools, store },
|
|
37
39
|
useIntegrationFF: watcher,
|
|
@@ -40,7 +42,7 @@ const DynamicField = ({ name, spec, config, Monaco, generateRandomValue, search,
|
|
|
40
42
|
if (correctParams) {
|
|
41
43
|
return (react_1.default.createElement(DynamicFormsCtx.Provider, { value: context },
|
|
42
44
|
react_1.default.createElement(SearchContext.Provider, { value: searchContext },
|
|
43
|
-
react_1.default.createElement(Controller_1.Controller, { spec: spec, name: name, parentOnChange: null, parentOnUnmount: null, value:
|
|
45
|
+
react_1.default.createElement(Controller_1.Controller, { spec: spec, name: name, parentOnChange: null, parentOnUnmount: null, value: (0, get_1.default)(store.values, name) }),
|
|
44
46
|
watcher)));
|
|
45
47
|
}
|
|
46
48
|
return null;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCreateContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
7
|
-
const createContext =
|
|
6
|
+
const once_1 = tslib_1.__importDefault(require("lodash/once"));
|
|
7
|
+
const createContext = (0, once_1.default)(() => react_1.default.createContext({}));
|
|
8
8
|
const useCreateContext = () => createContext();
|
|
9
9
|
exports.useCreateContext = useCreateContext;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCreateSearchContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
7
|
-
const createContext =
|
|
6
|
+
const once_1 = tslib_1.__importDefault(require("lodash/once"));
|
|
7
|
+
const createContext = (0, once_1.default)(() => react_1.default.createContext({}));
|
|
8
8
|
const useCreateSearchContext = () => createContext();
|
|
9
9
|
exports.useCreateSearchContext = useCreateSearchContext;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useIntegrationFF = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
6
|
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
|
|
7
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
8
|
+
const isFunction_1 = tslib_1.__importDefault(require("lodash/isFunction"));
|
|
9
|
+
const values_1 = tslib_1.__importDefault(require("lodash/values"));
|
|
8
10
|
const react_final_form_1 = require("react-final-form");
|
|
9
11
|
const utils_1 = require("../utils");
|
|
10
12
|
const useIntegrationFF = (store, withoutDebounce) => {
|
|
@@ -17,9 +19,9 @@ const useIntegrationFF = (store, withoutDebounce) => {
|
|
|
17
19
|
validate: () => {
|
|
18
20
|
const asyncErrors = [];
|
|
19
21
|
let error;
|
|
20
|
-
|
|
22
|
+
(0, values_1.default)(store.errors).forEach((err) => {
|
|
21
23
|
if (err) {
|
|
22
|
-
if (
|
|
24
|
+
if ((0, isFunction_1.default)(err === null || err === void 0 ? void 0 : err.then)) {
|
|
23
25
|
asyncErrors.push(err);
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
@@ -38,7 +40,7 @@ const useIntegrationFF = (store, withoutDebounce) => {
|
|
|
38
40
|
const change = react_1.default.useMemo(() => {
|
|
39
41
|
const cb = (value) => {
|
|
40
42
|
if (store.name) {
|
|
41
|
-
form.change(store.name,
|
|
43
|
+
form.change(store.name, (0, get_1.default)((0, utils_1.transformArrOut)(value), store.name));
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
if (withoutDebounce) {
|
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMutators = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
7
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
8
|
+
const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
|
|
9
|
+
const keys_1 = tslib_1.__importDefault(require("lodash/keys"));
|
|
10
|
+
const set_1 = tslib_1.__importDefault(require("lodash/set"));
|
|
7
11
|
const useMutators = (externalMutators) => {
|
|
8
12
|
const merge = react_1.default.useCallback((mutators, store) => {
|
|
9
13
|
const mergeSpec = (a = {}, b) => {
|
|
10
|
-
const result =
|
|
14
|
+
const result = (0, cloneDeep_1.default)(a);
|
|
11
15
|
const getKeys = (parent) => {
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
16
|
+
if ((0, isObjectLike_1.default)(parent)) {
|
|
17
|
+
return (0, keys_1.default)(parent).reduce((acc, parentKey) => {
|
|
14
18
|
const childKeys = getKeys(parent[parentKey]);
|
|
15
19
|
return [
|
|
16
20
|
...acc,
|
|
@@ -22,14 +26,14 @@ const useMutators = (externalMutators) => {
|
|
|
22
26
|
return [];
|
|
23
27
|
};
|
|
24
28
|
getKeys(b).forEach((key) => {
|
|
25
|
-
|
|
29
|
+
(0, set_1.default)(result, [key[0], 'value', ...key.slice(1)], (0, get_1.default)(b, key));
|
|
26
30
|
});
|
|
27
31
|
return result;
|
|
28
32
|
};
|
|
29
33
|
const mergeValuesOrErrors = (a = {}, b) => {
|
|
30
|
-
const result =
|
|
34
|
+
const result = (0, cloneDeep_1.default)(a);
|
|
31
35
|
Object.keys(b).forEach((key) => {
|
|
32
|
-
|
|
36
|
+
(0, set_1.default)(result, [key, 'value'], b[key]);
|
|
33
37
|
});
|
|
34
38
|
return result;
|
|
35
39
|
};
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useSearchStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const isUndefined_1 = tslib_1.__importDefault(require("lodash/isUndefined"));
|
|
7
|
+
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
7
8
|
const __1 = require("../");
|
|
8
9
|
const useSearchStore = () => {
|
|
9
10
|
const [store, setStore] = react_1.default.useState({});
|
|
@@ -24,7 +25,7 @@ const useSearchStore = () => {
|
|
|
24
25
|
return false;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
if (
|
|
28
|
+
if ((0, isUndefined_1.default)(selfFlag)) {
|
|
28
29
|
return false;
|
|
29
30
|
}
|
|
30
31
|
return true;
|
|
@@ -33,7 +34,7 @@ const useSearchStore = () => {
|
|
|
33
34
|
store,
|
|
34
35
|
setField: (name, search) => setStore((store) => (Object.assign(Object.assign({}, store), { [name]: search }))),
|
|
35
36
|
removeField: (name) => {
|
|
36
|
-
setStore((store) =>
|
|
37
|
+
setStore((store) => (0, omit_1.default)(store, name));
|
|
37
38
|
},
|
|
38
39
|
isHiddenField,
|
|
39
40
|
};
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const clone_1 = tslib_1.__importDefault(require("lodash/clone"));
|
|
7
|
+
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
8
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
9
|
+
const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
|
|
10
|
+
const set_1 = tslib_1.__importDefault(require("lodash/set"));
|
|
7
11
|
const react_final_form_1 = require("react-final-form");
|
|
8
12
|
const utils_1 = require("../utils");
|
|
9
13
|
const useStore = (name) => {
|
|
@@ -11,37 +15,37 @@ const useStore = (name) => {
|
|
|
11
15
|
const firstRenderRef = react_1.default.useRef(true);
|
|
12
16
|
const [store, setStore] = react_1.default.useState(() => {
|
|
13
17
|
const values = (0, utils_1.transformArrIn)({
|
|
14
|
-
[name]:
|
|
18
|
+
[name]: (0, get_1.default)(formState.values, name),
|
|
15
19
|
});
|
|
16
20
|
const initialValue = (0, utils_1.transformArrIn)({
|
|
17
|
-
[name]:
|
|
21
|
+
[name]: (0, get_1.default)(formState.initialValues, name),
|
|
18
22
|
});
|
|
19
23
|
return {
|
|
20
24
|
name,
|
|
21
|
-
initialValue:
|
|
22
|
-
values:
|
|
25
|
+
initialValue: (0, cloneDeep_1.default)(initialValue),
|
|
26
|
+
values: (0, cloneDeep_1.default)(values),
|
|
23
27
|
errors: {},
|
|
24
28
|
};
|
|
25
29
|
});
|
|
26
30
|
const submitFailed = formState.submitFailed;
|
|
27
31
|
const tools = react_1.default.useMemo(() => ({
|
|
28
32
|
initialValue: store.initialValue,
|
|
29
|
-
onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values:
|
|
30
|
-
onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { values:
|
|
33
|
+
onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values: (0, set_1.default)(Object.assign({}, store.values), name, (0, clone_1.default)(value)), errors: errors || {} }))),
|
|
34
|
+
onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { values: (0, omit_1.default)(store.values, name), errors: (0, omit_1.default)(store.errors, Object.keys(store.errors).filter((key) => key.startsWith(name))) }))),
|
|
31
35
|
submitFailed,
|
|
32
36
|
}), [store.initialValue, setStore, submitFailed]);
|
|
33
37
|
react_1.default.useEffect(() => {
|
|
34
38
|
if (!firstRenderRef.current) {
|
|
35
39
|
const values = (0, utils_1.transformArrIn)({
|
|
36
|
-
[name]:
|
|
40
|
+
[name]: (0, get_1.default)(formState.values, name),
|
|
37
41
|
});
|
|
38
42
|
const initialValue = (0, utils_1.transformArrIn)({
|
|
39
|
-
[name]:
|
|
43
|
+
[name]: (0, get_1.default)(formState.initialValues, name),
|
|
40
44
|
});
|
|
41
45
|
setStore({
|
|
42
46
|
name: name,
|
|
43
|
-
initialValue:
|
|
44
|
-
values:
|
|
47
|
+
initialValue: (0, cloneDeep_1.default)(initialValue),
|
|
48
|
+
values: (0, cloneDeep_1.default)(values),
|
|
45
49
|
errors: {},
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -2,26 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withGenerateButton = exports.isArrayItem = exports.transformArrOut = exports.transformArrIn = exports.isCorrectConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const forEach_1 = tslib_1.__importDefault(require("lodash/forEach"));
|
|
6
|
+
const isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
|
|
7
|
+
const isObject_1 = tslib_1.__importDefault(require("lodash/isObject"));
|
|
8
|
+
const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
|
|
6
9
|
const constants_1 = require("../../../constants");
|
|
7
10
|
const helpers_1 = require("../../../helpers");
|
|
8
11
|
const constants_2 = require("../constants");
|
|
9
|
-
const isCorrectConfig = (candidate) => Object.values(constants_1.SpecTypes).every((type) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const isCorrectConfig = (candidate) => Object.values(constants_1.SpecTypes).every((type) => (0, isObjectLike_1.default)(candidate) &&
|
|
13
|
+
(0, isObjectLike_1.default)(candidate[type]) &&
|
|
14
|
+
(0, isObjectLike_1.default)(candidate[type].inputs) &&
|
|
15
|
+
(0, isObjectLike_1.default)(candidate[type].layouts) &&
|
|
16
|
+
(0, isObjectLike_1.default)(candidate[type].validators));
|
|
14
17
|
exports.isCorrectConfig = isCorrectConfig;
|
|
15
18
|
const transformArrIn = (value) => {
|
|
16
|
-
if (
|
|
19
|
+
if ((0, isArray_1.default)(value)) {
|
|
17
20
|
return value.reduce((arrObj, item, idx) => {
|
|
18
21
|
arrObj[`<${idx}>`] = (0, exports.transformArrIn)(item);
|
|
19
22
|
return arrObj;
|
|
20
23
|
}, { [constants_2.OBJECT_ARRAY_FLAG]: true, [constants_2.OBJECT_ARRAY_CNT]: value.length });
|
|
21
24
|
}
|
|
22
|
-
if (
|
|
25
|
+
if ((0, isObject_1.default)(value)) {
|
|
23
26
|
const _value = Object.assign({}, value);
|
|
24
|
-
|
|
27
|
+
(0, forEach_1.default)(_value, (item, key) => {
|
|
25
28
|
_value[key] = (0, exports.transformArrIn)(item);
|
|
26
29
|
});
|
|
27
30
|
return _value;
|
|
@@ -30,7 +33,7 @@ const transformArrIn = (value) => {
|
|
|
30
33
|
};
|
|
31
34
|
exports.transformArrIn = transformArrIn;
|
|
32
35
|
const transformArrOut = (value) => {
|
|
33
|
-
if (
|
|
36
|
+
if ((0, isObject_1.default)(value) && !(0, isArray_1.default)(value)) {
|
|
34
37
|
if (value[constants_2.OBJECT_ARRAY_FLAG]) {
|
|
35
38
|
const _value = Object.keys(value)
|
|
36
39
|
.filter((key) => key !== constants_2.OBJECT_ARRAY_FLAG && key !== constants_2.OBJECT_ARRAY_CNT)
|
|
@@ -40,7 +43,7 @@ const transformArrOut = (value) => {
|
|
|
40
43
|
return _value;
|
|
41
44
|
}
|
|
42
45
|
const _value = Object.assign({}, value);
|
|
43
|
-
|
|
46
|
+
(0, forEach_1.default)(_value, (item, key) => {
|
|
44
47
|
_value[key] = (0, exports.transformArrOut)(item);
|
|
45
48
|
});
|
|
46
49
|
return _value;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCorrectViewConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
|
|
6
6
|
const constants_1 = require("../../constants");
|
|
7
|
-
const isCorrectViewConfig = (candidate) => Object.values(constants_1.SpecTypes).every((type) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const isCorrectViewConfig = (candidate) => Object.values(constants_1.SpecTypes).every((type) => (0, isObjectLike_1.default)(candidate) &&
|
|
8
|
+
(0, isObjectLike_1.default)(candidate[type]) &&
|
|
9
|
+
(0, isObjectLike_1.default)(candidate[type].views) &&
|
|
10
|
+
(0, isObjectLike_1.default)(candidate[type].layouts));
|
|
11
11
|
exports.isCorrectViewConfig = isCorrectViewConfig;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useComponents = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
7
7
|
const react_is_1 = require("react-is");
|
|
8
8
|
const helpers_1 = require("../../../helpers");
|
|
9
9
|
const helpers_2 = require("../helpers");
|
|
@@ -25,7 +25,7 @@ const useComponents = (spec, config) => {
|
|
|
25
25
|
return;
|
|
26
26
|
}, [views, (_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.type]);
|
|
27
27
|
const Layout = react_1.default.useMemo(() => {
|
|
28
|
-
if (layouts &&
|
|
28
|
+
if (layouts && (0, isString_1.default)(spec.viewSpec.layout)) {
|
|
29
29
|
const Component = layouts[spec.viewSpec.layout];
|
|
30
30
|
if ((0, react_is_1.isValidElementType)(Component)) {
|
|
31
31
|
return Component;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCreateContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
7
|
-
const createContext =
|
|
6
|
+
const once_1 = tslib_1.__importDefault(require("lodash/once"));
|
|
7
|
+
const createContext = (0, once_1.default)(() => react_1.default.createContext({}));
|
|
8
8
|
const useCreateContext = () => createContext();
|
|
9
9
|
exports.useCreateContext = useCreateContext;
|
|
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useRender = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
7
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
7
8
|
const react_is_1 = require("react-is");
|
|
8
9
|
const helpers_1 = require("../../../helpers");
|
|
9
10
|
const useRender = ({ value, name, spec, viewEntity, Layout, Link, }) => {
|
|
10
11
|
const render = react_1.default.useMemo(() => {
|
|
11
12
|
var _a;
|
|
12
|
-
if (viewEntity && (0, helpers_1.isCorrectSpec)(spec) &&
|
|
13
|
+
if (viewEntity && (0, helpers_1.isCorrectSpec)(spec) && (0, isString_1.default)(name)) {
|
|
13
14
|
if (!spec.viewSpec.hidden) {
|
|
14
|
-
const currentValue = name ?
|
|
15
|
+
const currentValue = name ? (0, get_1.default)(value, name) : value;
|
|
15
16
|
const linkValue = (0, react_is_1.isValidElementType)(Link) && ((_a = spec === null || spec === void 0 ? void 0 : spec.viewSpec) === null || _a === void 0 ? void 0 : _a.link) ? (react_1.default.createElement(Link, { value: currentValue, link: spec.viewSpec.link })) : undefined;
|
|
16
17
|
if (viewEntity.independent) {
|
|
17
18
|
const InputComponent = viewEntity.Component;
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isStringSpec = exports.isObjectSpec = exports.isNumberSpec = exports.isBooleanSpec = exports.isArraySpec = exports.isCorrectSpec = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const isObjectLike_1 = tslib_1.__importDefault(require("lodash/isObjectLike"));
|
|
6
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
6
7
|
const constants_1 = require("./constants");
|
|
7
|
-
const isCorrectSpec = (candidate) =>
|
|
8
|
+
const isCorrectSpec = (candidate) => (0, isObjectLike_1.default)(candidate) &&
|
|
8
9
|
(candidate.type === constants_1.SpecTypes.Array ||
|
|
9
10
|
candidate.type === constants_1.SpecTypes.Boolean ||
|
|
10
11
|
candidate.type === constants_1.SpecTypes.Number ||
|
|
11
12
|
candidate.type === constants_1.SpecTypes.Object ||
|
|
12
13
|
candidate.type === constants_1.SpecTypes.String) &&
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
(0, isObjectLike_1.default)(candidate.viewSpec) &&
|
|
15
|
+
(0, isString_1.default)(candidate.viewSpec.type);
|
|
15
16
|
exports.isCorrectSpec = isCorrectSpec;
|
|
16
17
|
const isArraySpec = (candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.type) === constants_1.SpecTypes.Array;
|
|
17
18
|
exports.isArraySpec = isArraySpec;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const icons_1 = require("@gravity-ui/icons");
|
|
7
7
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
-
const
|
|
8
|
+
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const b = (0, utils_1.block)('accordeon-card');
|
|
11
11
|
const AccordeonCard = ({ className, name, header, description, open: propsOpen, onToggle, headerActionsTemplate, ignoreHeaderToggle, titleSize = 'm', alwaysOpen, children, classNameBody, }) => {
|
|
@@ -32,7 +32,7 @@ const AccordeonCard = ({ className, name, header, description, open: propsOpen,
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const currentHeaderVariant = react_1.default.useMemo(() => {
|
|
35
|
-
if (!
|
|
35
|
+
if (!(0, isString_1.default)(header)) {
|
|
36
36
|
return 'body-1';
|
|
37
37
|
}
|
|
38
38
|
if (titleSize === 'm') {
|