@gravity-ui/dynamic-forms 3.3.0 → 3.4.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 +4 -4
- package/build/cjs/lib/core/components/Form/Controller/utils.js +39 -29
- package/build/cjs/lib/core/components/Form/DynamicField.js +3 -3
- package/build/cjs/lib/core/components/Form/hooks/useMutators.js +21 -7
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.css +6 -6
- package/build/cjs/lib/kit/components/Card/Card.css +3 -3
- package/build/cjs/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -4
- package/build/cjs/lib/kit/components/GroupIndent/GroupIndent.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +1 -1
- package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Row/Row.css +4 -3
- package/build/cjs/lib/kit/components/LongValue/LongValue.css +1 -1
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +4 -4
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +2 -2
- package/build/cjs/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/MonacoInputView/MonacoBaseView.css +1 -1
- package/build/cjs/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
- package/build/cjs/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +1 -1
- package/build/cjs/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
- package/build/cjs/lib/kit/validators/types.js +2 -0
- package/build/cjs/lib/kit/validators/validators.js +32 -25
- package/build/esm/lib/core/components/Form/Controller/Controller.js +4 -4
- package/build/esm/lib/core/components/Form/Controller/types.d.ts +6 -6
- package/build/esm/lib/core/components/Form/Controller/utils.d.ts +6 -6
- package/build/esm/lib/core/components/Form/Controller/utils.js +39 -29
- package/build/esm/lib/core/components/Form/DynamicField.js +3 -3
- package/build/esm/lib/core/components/Form/hooks/useMutators.d.ts +2 -2
- package/build/esm/lib/core/components/Form/hooks/useMutators.js +21 -7
- package/build/esm/lib/core/components/Form/types/context.d.ts +2 -2
- package/build/esm/lib/core/components/Form/types/mutators.d.ts +11 -0
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.css +6 -6
- package/build/esm/lib/kit/components/Card/Card.css +3 -3
- package/build/esm/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -4
- package/build/esm/lib/kit/components/GroupIndent/GroupIndent.css +1 -1
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.css +1 -1
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +1 -1
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputBase.css +1 -1
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +1 -1
- package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.css +1 -1
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +1 -1
- package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Row/Row.css +4 -3
- package/build/esm/lib/kit/components/LongValue/LongValue.css +1 -1
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +4 -4
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +2 -2
- package/build/esm/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/MonacoInputView/MonacoBaseView.css +1 -1
- package/build/esm/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
- package/build/esm/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +1 -1
- package/build/esm/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
- package/build/esm/lib/kit/validators/messages.d.ts +2 -16
- package/build/esm/lib/kit/validators/types.d.ts +16 -0
- package/build/esm/lib/kit/validators/types.js +1 -0
- package/build/esm/lib/kit/validators/validators.d.ts +10 -9
- package/build/esm/lib/kit/validators/validators.js +32 -25
- package/package.json +11 -2
|
@@ -7,12 +7,12 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
|
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, }) => {
|
|
10
|
-
const { config, tools,
|
|
10
|
+
const { config, tools, mutatorsStore, __mirror } = (0, hooks_1.useDynamicFormsCtx)();
|
|
11
11
|
const firstRenderRef = react_1.default.useRef(true);
|
|
12
12
|
const [store, setStore] = react_1.default.useState((0, utils_1.initializeStore)({
|
|
13
13
|
name,
|
|
14
14
|
spec: _spec,
|
|
15
|
-
|
|
15
|
+
mutatorsStore,
|
|
16
16
|
config,
|
|
17
17
|
valueFromParent,
|
|
18
18
|
tools,
|
|
@@ -92,7 +92,7 @@ const Controller = ({ spec: _spec, name, value: valueFromParent, parentOnChange,
|
|
|
92
92
|
name,
|
|
93
93
|
parentOnChange,
|
|
94
94
|
parentOnUnmount,
|
|
95
|
-
|
|
95
|
+
mutatorsStore,
|
|
96
96
|
config,
|
|
97
97
|
tools,
|
|
98
98
|
methodOnChange: fieldMethods.onChange,
|
|
@@ -104,7 +104,7 @@ const Controller = ({ spec: _spec, name, value: valueFromParent, parentOnChange,
|
|
|
104
104
|
name,
|
|
105
105
|
parentOnChange,
|
|
106
106
|
parentOnUnmount,
|
|
107
|
-
|
|
107
|
+
mutatorsStore,
|
|
108
108
|
config,
|
|
109
109
|
tools.onChange,
|
|
110
110
|
tools.onUnmount,
|
|
@@ -9,10 +9,14 @@ const constants_1 = require("../../../constants");
|
|
|
9
9
|
const helpers_1 = require("../../../helpers");
|
|
10
10
|
const constants_2 = require("../constants");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
-
const isErrorMutatorCorrect = (errorMutator) => errorMutator !== constants_2.EMPTY_MUTATOR &&
|
|
12
|
+
const isErrorMutatorCorrect = (errorMutator) => errorMutator !== constants_2.EMPTY_MUTATOR &&
|
|
13
|
+
(lodash_1.default.isString(errorMutator.value) ||
|
|
14
|
+
lodash_1.default.isBoolean(errorMutator.value) ||
|
|
15
|
+
lodash_1.default.isUndefined(errorMutator.value));
|
|
13
16
|
const isValueMutatorCorrect = (valueMutator, spec) => valueMutator !== constants_2.EMPTY_MUTATOR &&
|
|
14
|
-
(typeof valueMutator === spec.type ||
|
|
15
|
-
(lodash_1.default.isArray(valueMutator) && spec.type === constants_1.SpecTypes.Array)
|
|
17
|
+
(typeof valueMutator.value === spec.type ||
|
|
18
|
+
(lodash_1.default.isArray(valueMutator.value) && spec.type === constants_1.SpecTypes.Array) ||
|
|
19
|
+
valueMutator.value === undefined);
|
|
16
20
|
const updateParentStore = (store) => {
|
|
17
21
|
(store.parentOnChange ? store.parentOnChange : store.tools.onChange)(store.name, store.state.value, Object.assign(Object.assign({}, store.state.childErrors), { [store.name]: store.state.error }));
|
|
18
22
|
};
|
|
@@ -21,10 +25,10 @@ const callUnmout = (store) => {
|
|
|
21
25
|
(store.parentOnUnmount ? store.parentOnUnmount : store.tools.onUnmount)(store.name);
|
|
22
26
|
};
|
|
23
27
|
exports.callUnmout = callUnmout;
|
|
24
|
-
const getSpec = ({ name, spec,
|
|
25
|
-
const mutator = lodash_1.default.get(
|
|
28
|
+
const getSpec = ({ name, spec, mutatorsStore, }) => {
|
|
29
|
+
const mutator = lodash_1.default.get(mutatorsStore.spec, name, constants_2.EMPTY_MUTATOR);
|
|
26
30
|
if (mutator !== constants_2.EMPTY_MUTATOR) {
|
|
27
|
-
const mutatedSpec = lodash_1.default.merge(lodash_1.default.cloneDeep(spec), mutator);
|
|
31
|
+
const mutatedSpec = lodash_1.default.merge(lodash_1.default.cloneDeep(spec), mutator.value);
|
|
28
32
|
if ((0, helpers_1.isCorrectSpec)(mutatedSpec)) {
|
|
29
33
|
return mutatedSpec;
|
|
30
34
|
}
|
|
@@ -90,11 +94,11 @@ const getValidate = ({ spec, config, }) => {
|
|
|
90
94
|
return validate;
|
|
91
95
|
};
|
|
92
96
|
exports.getValidate = getValidate;
|
|
93
|
-
const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate,
|
|
94
|
-
const valueMutator = (0, utils_1.transformArrIn)(lodash_1.default.get(
|
|
97
|
+
const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate, mutatorsStore, }) => {
|
|
98
|
+
const valueMutator = (0, utils_1.transformArrIn)(lodash_1.default.get(mutatorsStore.values, name, constants_2.EMPTY_MUTATOR));
|
|
95
99
|
let value = lodash_1.default.cloneDeep(valueFromParent);
|
|
96
100
|
if (isValueMutatorCorrect(valueMutator, spec)) {
|
|
97
|
-
value = valueMutator;
|
|
101
|
+
value = valueMutator.value;
|
|
98
102
|
}
|
|
99
103
|
if (lodash_1.default.isNil(value)) {
|
|
100
104
|
if (spec.defaultValue) {
|
|
@@ -111,11 +115,11 @@ const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate,
|
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
|
-
let errorMutator = lodash_1.default.get(
|
|
118
|
+
let errorMutator = lodash_1.default.get(mutatorsStore.errors, name, constants_2.EMPTY_MUTATOR);
|
|
115
119
|
if (!isErrorMutatorCorrect(errorMutator)) {
|
|
116
|
-
errorMutator = undefined;
|
|
120
|
+
errorMutator = { value: undefined };
|
|
117
121
|
}
|
|
118
|
-
const error = (validate === null || validate === void 0 ? void 0 : validate((0, utils_1.transformArrOut)(value))) || errorMutator;
|
|
122
|
+
const error = (validate === null || validate === void 0 ? void 0 : validate((0, utils_1.transformArrOut)(value))) || (errorMutator === null || errorMutator === void 0 ? void 0 : errorMutator.value);
|
|
119
123
|
const dirty = !lodash_1.default.isEqual(value, initialValue);
|
|
120
124
|
return {
|
|
121
125
|
initialValue,
|
|
@@ -209,8 +213,8 @@ const getFieldMethods = () => {
|
|
|
209
213
|
};
|
|
210
214
|
};
|
|
211
215
|
exports.getFieldMethods = getFieldMethods;
|
|
212
|
-
const initializeStore = ({ name, spec: _spec,
|
|
213
|
-
const spec = (0, exports.getSpec)({ name, spec: _spec,
|
|
216
|
+
const initializeStore = ({ name, spec: _spec, mutatorsStore, config, valueFromParent, tools, parentOnChange, parentOnUnmount, }) => {
|
|
217
|
+
const spec = (0, exports.getSpec)({ name, spec: _spec, mutatorsStore });
|
|
214
218
|
const components = (0, exports.getComponents)({ spec, config });
|
|
215
219
|
const render = (0, exports.getRender)(Object.assign({ name, spec }, components));
|
|
216
220
|
const validate = (0, exports.getValidate)({ spec, config });
|
|
@@ -219,7 +223,7 @@ const initializeStore = ({ name, spec: _spec, mutators, config, valueFromParent,
|
|
|
219
223
|
spec,
|
|
220
224
|
valueFromParent,
|
|
221
225
|
validate,
|
|
222
|
-
|
|
226
|
+
mutatorsStore,
|
|
223
227
|
initialValue: lodash_1.default.get(tools.initialValue, name),
|
|
224
228
|
});
|
|
225
229
|
const initialsStore = {
|
|
@@ -228,7 +232,7 @@ const initializeStore = ({ name, spec: _spec, mutators, config, valueFromParent,
|
|
|
228
232
|
initialSpec: _spec,
|
|
229
233
|
config,
|
|
230
234
|
tools,
|
|
231
|
-
|
|
235
|
+
mutatorsStore,
|
|
232
236
|
render,
|
|
233
237
|
validate,
|
|
234
238
|
parentOnChange,
|
|
@@ -241,14 +245,14 @@ const initializeStore = ({ name, spec: _spec, mutators, config, valueFromParent,
|
|
|
241
245
|
return initialsStore;
|
|
242
246
|
};
|
|
243
247
|
exports.initializeStore = initializeStore;
|
|
244
|
-
const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount,
|
|
245
|
-
const storeSpecMutator = lodash_1.default.get(store.
|
|
246
|
-
const storeValueMutator = lodash_1.default.get(store.
|
|
247
|
-
const storeErrorMutator = lodash_1.default.get(store.
|
|
248
|
-
const specMutator = lodash_1.default.get(
|
|
249
|
-
const valueMutator = lodash_1.default.get(
|
|
250
|
-
const errorMutator = lodash_1.default.get(
|
|
251
|
-
const valueMutatorUpdated = isValueMutatorCorrect(valueMutator, (0, exports.getSpec)({ name, spec: _spec,
|
|
248
|
+
const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutatorsStore, valueFromParent, config, tools, methodOnChange, }) => {
|
|
249
|
+
const storeSpecMutator = lodash_1.default.get(store.mutatorsStore.spec, store.name, constants_2.EMPTY_MUTATOR);
|
|
250
|
+
const storeValueMutator = lodash_1.default.get(store.mutatorsStore.values, store.name, constants_2.EMPTY_MUTATOR);
|
|
251
|
+
const storeErrorMutator = lodash_1.default.get(store.mutatorsStore.errors, store.name, constants_2.EMPTY_MUTATOR);
|
|
252
|
+
const specMutator = lodash_1.default.get(mutatorsStore.spec, name, constants_2.EMPTY_MUTATOR);
|
|
253
|
+
const valueMutator = lodash_1.default.get(mutatorsStore.values, name, constants_2.EMPTY_MUTATOR);
|
|
254
|
+
const errorMutator = lodash_1.default.get(mutatorsStore.errors, name, constants_2.EMPTY_MUTATOR);
|
|
255
|
+
const valueMutatorUpdated = isValueMutatorCorrect(valueMutator, (0, exports.getSpec)({ name, spec: _spec, mutatorsStore })) &&
|
|
252
256
|
valueMutator !== storeValueMutator;
|
|
253
257
|
const errorMutatorUpdated = isErrorMutatorCorrect(errorMutator) && errorMutator !== storeErrorMutator;
|
|
254
258
|
const updateState = valueMutatorUpdated || errorMutatorUpdated;
|
|
@@ -265,7 +269,7 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
265
269
|
setStore((0, exports.initializeStore)({
|
|
266
270
|
name,
|
|
267
271
|
spec: _spec,
|
|
268
|
-
|
|
272
|
+
mutatorsStore,
|
|
269
273
|
config,
|
|
270
274
|
valueFromParent,
|
|
271
275
|
tools,
|
|
@@ -277,7 +281,7 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
277
281
|
let nextStore = Object.assign(Object.assign({}, (0, exports.initializeStore)({
|
|
278
282
|
name,
|
|
279
283
|
spec: _spec,
|
|
280
|
-
|
|
284
|
+
mutatorsStore,
|
|
281
285
|
config,
|
|
282
286
|
valueFromParent,
|
|
283
287
|
tools,
|
|
@@ -285,7 +289,9 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
285
289
|
parentOnUnmount,
|
|
286
290
|
})), { state: store.state });
|
|
287
291
|
if (updateState) {
|
|
288
|
-
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated
|
|
292
|
+
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
293
|
+
? { errorMutator: errorMutator.value }
|
|
294
|
+
: {})));
|
|
289
295
|
}
|
|
290
296
|
setStore(nextStore);
|
|
291
297
|
}
|
|
@@ -294,12 +300,16 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
294
300
|
parentOnUnmount,
|
|
295
301
|
tools });
|
|
296
302
|
if (updateState) {
|
|
297
|
-
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated
|
|
303
|
+
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
304
|
+
? { errorMutator: errorMutator.value }
|
|
305
|
+
: {})));
|
|
298
306
|
}
|
|
299
307
|
setStore(nextStore);
|
|
300
308
|
}
|
|
301
309
|
else if (updateState) {
|
|
302
|
-
setStore(methodOnChange(store, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated
|
|
310
|
+
setStore(methodOnChange(Object.assign(Object.assign({}, store), { mutatorsStore }), Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
311
|
+
? { errorMutator: errorMutator.value }
|
|
312
|
+
: {}))));
|
|
303
313
|
}
|
|
304
314
|
};
|
|
305
315
|
exports.updateStore = updateStore;
|
|
@@ -14,7 +14,7 @@ const DynamicField = ({ name, spec, config, Monaco, generateRandomValue, search,
|
|
|
14
14
|
const SearchContext = (0, hooks_1.useCreateSearchContext)();
|
|
15
15
|
const { tools, store } = (0, hooks_1.useStore)(name);
|
|
16
16
|
const watcher = (0, hooks_1.useIntegrationFF)(store, withoutInsertFFDebounce);
|
|
17
|
-
const {
|
|
17
|
+
const { mutatorsStore, mutateDFState } = (0, hooks_1.useMutators)(externalMutators);
|
|
18
18
|
const { store: searchStore, setField, removeField, isHiddenField } = (0, hooks_1.useSearchStore)();
|
|
19
19
|
const context = react_1.default.useMemo(() => ({
|
|
20
20
|
config,
|
|
@@ -22,9 +22,9 @@ const DynamicField = ({ name, spec, config, Monaco, generateRandomValue, search,
|
|
|
22
22
|
generateRandomValue,
|
|
23
23
|
tools: Object.assign(Object.assign({}, tools), { mutateDFState }),
|
|
24
24
|
store,
|
|
25
|
-
|
|
25
|
+
mutatorsStore,
|
|
26
26
|
__mirror,
|
|
27
|
-
}), [tools, config, Monaco, __mirror, generateRandomValue,
|
|
27
|
+
}), [tools, config, Monaco, __mirror, generateRandomValue, mutatorsStore, mutateDFState, store]);
|
|
28
28
|
const searchContext = react_1.default.useMemo(() => ({
|
|
29
29
|
setField,
|
|
30
30
|
removeField,
|
|
@@ -5,10 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
7
|
const useMutators = (externalMutators) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const mutateDFState = react_1.default.useCallback((mutators) => {
|
|
11
|
-
const mergeSpec = (a, b) => {
|
|
8
|
+
const merge = react_1.default.useCallback((mutators, store) => {
|
|
9
|
+
const mergeSpec = (a = {}, b) => {
|
|
12
10
|
const result = lodash_1.default.cloneDeep(a);
|
|
13
11
|
const getKeys = (parent) => {
|
|
14
12
|
if (lodash_1.default.isObjectLike(parent)) {
|
|
@@ -24,11 +22,27 @@ const useMutators = (externalMutators) => {
|
|
|
24
22
|
return [];
|
|
25
23
|
};
|
|
26
24
|
getKeys(b).forEach((key) => {
|
|
27
|
-
lodash_1.default.set(result, key, lodash_1.default.get(b, key));
|
|
25
|
+
lodash_1.default.set(result, [key[0], 'value', ...key.slice(1)], lodash_1.default.get(b, key));
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
const mergeValuesOrErrors = (a = {}, b) => {
|
|
30
|
+
const result = lodash_1.default.cloneDeep(a);
|
|
31
|
+
Object.keys(b).forEach((key) => {
|
|
32
|
+
lodash_1.default.set(result, [key, 'value'], b[key]);
|
|
28
33
|
});
|
|
29
34
|
return result;
|
|
30
35
|
};
|
|
31
|
-
|
|
36
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, store), (mutators.errors
|
|
37
|
+
? { errors: mergeValuesOrErrors(store.errors, mutators.errors) }
|
|
38
|
+
: {})), (mutators.values
|
|
39
|
+
? { values: mergeValuesOrErrors(store.values, mutators.values) }
|
|
40
|
+
: {})), (mutators.spec ? { spec: mergeSpec(store.spec, mutators.spec) } : {}));
|
|
41
|
+
}, []);
|
|
42
|
+
const firstRenderRef = react_1.default.useRef(true);
|
|
43
|
+
const [store, setStore] = react_1.default.useState(merge(externalMutators || {}, {}));
|
|
44
|
+
const mutateDFState = react_1.default.useCallback((mutators) => {
|
|
45
|
+
setStore((store) => merge(mutators, store));
|
|
32
46
|
}, [setStore]);
|
|
33
47
|
react_1.default.useEffect(() => {
|
|
34
48
|
if (firstRenderRef.current) {
|
|
@@ -38,6 +52,6 @@ const useMutators = (externalMutators) => {
|
|
|
38
52
|
mutateDFState(externalMutators);
|
|
39
53
|
}
|
|
40
54
|
}, [externalMutators]);
|
|
41
|
-
return {
|
|
55
|
+
return { mutatorsStore: store, mutateDFState };
|
|
42
56
|
};
|
|
43
57
|
exports.useMutators = useMutators;
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
justify-content: space-between;
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
max-width: 750px;
|
|
7
|
-
box-shadow: 0 1px 5px var(--
|
|
7
|
+
box-shadow: 0 1px 5px var(--g-color-sfx-shadow);
|
|
8
8
|
border-radius: 5px;
|
|
9
|
-
color: var(--
|
|
10
|
-
background-color: var(--
|
|
9
|
+
color: var(--g-color-text-primary);
|
|
10
|
+
background-color: var(--g-color-base-float);
|
|
11
11
|
}
|
|
12
12
|
.df-accordeon-card:hover {
|
|
13
|
-
box-shadow: 0 3px 10px var(--
|
|
13
|
+
box-shadow: 0 3px 10px var(--g-color-sfx-shadow);
|
|
14
14
|
}
|
|
15
15
|
.df-accordeon-card:last-child {
|
|
16
16
|
margin-bottom: 0;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
cursor: pointer;
|
|
34
34
|
}
|
|
35
35
|
.df-accordeon-card__header_open {
|
|
36
|
-
border-bottom: 1px solid var(--
|
|
36
|
+
border-bottom: 1px solid var(--g-color-line-generic);
|
|
37
37
|
}
|
|
38
38
|
.df-accordeon-card__header_without-action:hover {
|
|
39
39
|
cursor: default;
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
}
|
|
59
59
|
.df-accordeon-card__header-content-description {
|
|
60
60
|
margin-top: 12px;
|
|
61
|
-
color: var(--
|
|
61
|
+
color: var(--g-color-text-complementary);
|
|
62
62
|
}
|
|
63
63
|
.df-accordeon-card__header-toggle-btn {
|
|
64
64
|
flex-grow: 0;
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
margin-left: 10px;
|
|
49
49
|
}
|
|
50
50
|
.df-card__title {
|
|
51
|
-
font-size: var(--
|
|
52
|
-
font-weight: var(--
|
|
53
|
-
line-height: var(--
|
|
51
|
+
font-size: var(--g-text-subheader-2-font-size);
|
|
52
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
53
|
+
line-height: var(--g-text-subheader-2-line-height);
|
|
54
54
|
white-space: nowrap;
|
|
55
55
|
overflow: hidden;
|
|
56
56
|
text-overflow: ellipsis;
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
.df-error-wrapper_error .yc-text-input_view_normal:not(.df-error-wrapper-ignore) .yc-text-input__control,
|
|
18
18
|
.df-error-wrapper_error .yc-text-input_view_normal:not(.df-error-wrapper-ignore) .yc-text-input__content,
|
|
19
19
|
.df-error-wrapper_error .yc-checkbox__indicator:not(.df-error-wrapper-ignore)::before {
|
|
20
|
-
border-color: var(--
|
|
20
|
+
border-color: var(--g-color-text-danger);
|
|
21
21
|
}
|
|
22
22
|
.df-error-wrapper__error-text {
|
|
23
|
-
color: var(--
|
|
23
|
+
color: var(--g-color-text-danger);
|
|
24
24
|
margin-top: 2px;
|
|
25
|
-
font-size: var(--
|
|
26
|
-
line-height: var(--
|
|
25
|
+
font-size: var(--g-text-body-1-font-size);
|
|
26
|
+
line-height: var(--g-text-body-1-line-height);
|
|
27
27
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
margin-top: 4px;
|
|
15
15
|
margin-bottom: 20px;
|
|
16
16
|
margin-left: 5px;
|
|
17
|
-
border-left: 1px solid var(--
|
|
17
|
+
border-left: 1px solid var(--g-color-line-generic-accent);
|
|
18
18
|
}
|
|
19
19
|
.df-oneof_base > .df-group-indent > .df-use-search:empty {
|
|
20
20
|
display: none;
|
|
@@ -6,6 +6,6 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const TextArea = ({ name, input, spec }) => {
|
|
8
8
|
const { value, onBlur, onChange, onFocus } = input;
|
|
9
|
-
return (react_1.default.createElement(uikit_1.TextArea, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name }));
|
|
9
|
+
return (react_1.default.createElement(uikit_1.TextArea, { value: value || '', onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name }));
|
|
10
10
|
};
|
|
11
11
|
exports.TextArea = TextArea;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
.df-row__title_required::after {
|
|
33
33
|
content: "*";
|
|
34
|
-
color: var(--
|
|
34
|
+
color: var(--g-color-text-danger);
|
|
35
35
|
}
|
|
36
36
|
.df-row__note {
|
|
37
37
|
padding-right: 16px;
|
|
@@ -55,17 +55,18 @@
|
|
|
55
55
|
}
|
|
56
56
|
.df-row__right-inner {
|
|
57
57
|
display: flex;
|
|
58
|
+
justify-content: space-around;
|
|
58
59
|
}
|
|
59
60
|
.df-row__description {
|
|
60
61
|
margin-top: 10px;
|
|
61
|
-
color: var(--
|
|
62
|
+
color: var(--g-color-text-secondary);
|
|
62
63
|
word-break: break-word;
|
|
63
64
|
}
|
|
64
65
|
.df-row__remove-button {
|
|
65
66
|
margin-left: 5px;
|
|
66
67
|
}
|
|
67
68
|
.df-row__required-mark {
|
|
68
|
-
color: var(--
|
|
69
|
+
color: var(--g-color-text-danger);
|
|
69
70
|
}
|
|
70
71
|
.df-row__error-wrapper {
|
|
71
72
|
min-width: 100%;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
.df-simple-vertical-accordeon_branch .df-simple-vertical-accordeon__body {
|
|
8
8
|
padding-left: 20px;
|
|
9
9
|
margin-left: 5px;
|
|
10
|
-
border-left: 1px solid var(--
|
|
10
|
+
border-left: 1px solid var(--g-color-line-generic-accent);
|
|
11
11
|
}
|
|
12
12
|
.df-simple-vertical-accordeon__header {
|
|
13
13
|
display: flex;
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
}
|
|
23
23
|
.df-simple-vertical-accordeon__title_size_s {
|
|
24
24
|
margin-bottom: 0;
|
|
25
|
-
font-size: var(--
|
|
25
|
+
font-size: var(--g-text-body-1-font-size);
|
|
26
26
|
}
|
|
27
27
|
.df-simple-vertical-accordeon__title_size_m {
|
|
28
28
|
margin-bottom: 1px;
|
|
29
|
-
font-size: var(--
|
|
29
|
+
font-size: var(--g-text-body2-font-size);
|
|
30
30
|
}
|
|
31
31
|
.df-simple-vertical-accordeon__title_size_l {
|
|
32
32
|
margin-bottom: 2px;
|
|
33
|
-
font-size: var(--
|
|
33
|
+
font-size: var(--g-text-body3-font-size);
|
|
34
34
|
}
|
|
35
35
|
.df-simple-vertical-accordeon__tooltip {
|
|
36
36
|
margin: 0px 5px;
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
white-space: nowrap;
|
|
19
19
|
overflow: hidden;
|
|
20
20
|
text-overflow: ellipsis;
|
|
21
|
-
color: var(--
|
|
21
|
+
color: var(--g-color-text-secondary);
|
|
22
22
|
}
|
|
23
23
|
.df-view-row__dots {
|
|
24
24
|
min-width: 40px;
|
|
25
25
|
flex-grow: 1;
|
|
26
26
|
margin: 0 2px;
|
|
27
|
-
border-bottom: 1px dotted var(--
|
|
27
|
+
border-bottom: 1px dotted var(--g-color-text-secondary);
|
|
28
28
|
}
|
|
29
29
|
.df-view-row__right {
|
|
30
30
|
max-width: 480px;
|
|
@@ -23,6 +23,6 @@ const CardOneOfView = (props) => {
|
|
|
23
23
|
if (!value || !Object.keys(value).length) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
return (react_1.default.createElement(__1.Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}
|
|
26
|
+
return (react_1.default.createElement(__1.Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name ? name + '.' : ''}${valueKey}`, key: `${name ? name + '.' : ''}${valueKey}` })) : null));
|
|
27
27
|
};
|
|
28
28
|
exports.CardOneOfView = CardOneOfView;
|
|
@@ -36,7 +36,7 @@ const MultiOneOfView = (props) => {
|
|
|
36
36
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
37
|
selectView,
|
|
38
38
|
react_1.default.createElement("div", { className: b('content', { flat: withoutIndent, 'multiple-values': items.length > 1 }) },
|
|
39
|
-
react_1.default.createElement(GroupIndent_1.GroupIndent, null, values.map((value) => (react_1.default.createElement(react_1.default.Fragment, { key: value }, specProperties && specProperties[value] ? (react_1.default.createElement(core_1.ViewController, { name: `${name}
|
|
39
|
+
react_1.default.createElement(GroupIndent_1.GroupIndent, null, values.map((value) => (react_1.default.createElement(react_1.default.Fragment, { key: value }, specProperties && specProperties[value] ? (react_1.default.createElement(core_1.ViewController, { name: `${name ? name + '.' : ''}${value}`, spec: specProperties[value] })) : null)))))));
|
|
40
40
|
};
|
|
41
41
|
exports.MultiOneOfView = MultiOneOfView;
|
|
42
42
|
const MultiOneOfFlatView = (props) => (react_1.default.createElement(exports.MultiOneOfView, Object.assign({}, props, { withoutIndent: true })));
|
|
@@ -20,7 +20,7 @@ const ObjectValueInputView = (_a) => {
|
|
|
20
20
|
if (!childSpec) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
const content = (react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name}
|
|
23
|
+
const content = (react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name ? name + '.' : ''}${OBJECT_VALUE_PROPERTY_NAME}` }));
|
|
24
24
|
if (Layout) {
|
|
25
25
|
return (react_1.default.createElement(Layout, Object.assign({ spec: spec, name: name }, restProps), content));
|
|
26
26
|
}
|
|
@@ -31,7 +31,7 @@ const OneOfViewComponent = (props) => {
|
|
|
31
31
|
return (react_1.default.createElement("div", { className: b({ flat: props.withoutIndent }) },
|
|
32
32
|
wrappedValue,
|
|
33
33
|
specProperties[valueKey] ? (react_1.default.createElement(__1.GroupIndent, null,
|
|
34
|
-
react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name}
|
|
34
|
+
react_1.default.createElement(core_1.ViewController, { spec: specProperties[valueKey], name: `${name ? name + '.' : ''}${valueKey}`, key: `${name ? name + '.' : ''}${valueKey}` }))) : null));
|
|
35
35
|
};
|
|
36
36
|
exports.OneOfView = OneOfViewComponent;
|
|
37
37
|
const OneOfFlatView = (props) => (react_1.default.createElement(OneOfViewComponent, Object.assign({}, props, { withoutIndent: true })));
|
|
@@ -22,7 +22,7 @@ const TextLinkView = (_a) => {
|
|
|
22
22
|
if (!childSpec || !(value === null || value === void 0 ? void 0 : value.text)) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
const content = react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name}
|
|
25
|
+
const content = (react_1.default.createElement(core_1.ViewController, { spec: childSpec, name: `${name ? name + '.' : ''}${TEXT_LINK_PROPERTY_NAME}` }));
|
|
26
26
|
if (Layout) {
|
|
27
27
|
return (react_1.default.createElement(Layout, Object.assign({ spec: spec, name: name, value: value }, restProps), content));
|
|
28
28
|
}
|