@gravity-ui/dynamic-forms 3.4.0 → 3.5.0
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 -31
- 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 +0 -9
- package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +10 -3
- package/build/cjs/lib/kit/components/Card/Card.css +0 -6
- package/build/cjs/lib/kit/components/Card/Card.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
- package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
- package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
- package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/cjs/lib/kit/components/Layouts/Row/Row.css +1 -0
- package/build/cjs/lib/kit/components/Layouts/Row/Row.js +2 -2
- package/build/cjs/lib/kit/components/Layouts/Section/Section.js +1 -1
- package/build/cjs/lib/kit/components/LongValue/LongValue.css +0 -6
- package/build/cjs/lib/kit/components/LongValue/LongValue.js +12 -1
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
- package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +14 -3
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
- package/build/cjs/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +1 -3
- package/build/cjs/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
- package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
- package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.js +1 -1
- package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
- 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 -31
- 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 +0 -9
- package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +11 -4
- package/build/esm/lib/kit/components/Card/Card.css +0 -6
- package/build/esm/lib/kit/components/Card/Card.js +2 -2
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
- package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.js +2 -2
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
- package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +2 -2
- package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
- package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
- package/build/esm/lib/kit/components/Layouts/Row/Row.css +1 -0
- package/build/esm/lib/kit/components/Layouts/Row/Row.js +3 -3
- package/build/esm/lib/kit/components/Layouts/Section/Section.js +2 -2
- package/build/esm/lib/kit/components/LongValue/LongValue.css +0 -6
- package/build/esm/lib/kit/components/LongValue/LongValue.js +12 -1
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +1 -0
- package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +15 -4
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
- package/build/esm/lib/kit/components/Views/CardOneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +2 -4
- package/build/esm/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
- package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
- package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.js +2 -2
- package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
- package/package.json +4 -3
|
@@ -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,16 +281,16 @@ 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,
|
|
284
288
|
parentOnChange,
|
|
285
289
|
parentOnUnmount,
|
|
286
290
|
})), { state: store.state });
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
292
|
+
? { errorMutator: errorMutator.value }
|
|
293
|
+
: {})));
|
|
290
294
|
setStore(nextStore);
|
|
291
295
|
}
|
|
292
296
|
else if (updateNonCritical) {
|
|
@@ -294,12 +298,16 @@ const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, paren
|
|
|
294
298
|
parentOnUnmount,
|
|
295
299
|
tools });
|
|
296
300
|
if (updateState) {
|
|
297
|
-
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated
|
|
301
|
+
nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
302
|
+
? { errorMutator: errorMutator.value }
|
|
303
|
+
: {})));
|
|
298
304
|
}
|
|
299
305
|
setStore(nextStore);
|
|
300
306
|
}
|
|
301
307
|
else if (updateState) {
|
|
302
|
-
setStore(methodOnChange(store, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated
|
|
308
|
+
setStore(methodOnChange(Object.assign(Object.assign({}, store), { mutatorsStore }), Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
|
|
309
|
+
? { errorMutator: errorMutator.value }
|
|
310
|
+
: {}))));
|
|
303
311
|
}
|
|
304
312
|
};
|
|
305
313
|
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;
|
|
@@ -47,15 +47,6 @@
|
|
|
47
47
|
justify-content: center;
|
|
48
48
|
order: -1;
|
|
49
49
|
}
|
|
50
|
-
.df-accordeon-card__header-content-title {
|
|
51
|
-
font-weight: 700;
|
|
52
|
-
}
|
|
53
|
-
.df-accordeon-card__header-content-title_size_s {
|
|
54
|
-
font-size: 13px;
|
|
55
|
-
}
|
|
56
|
-
.df-accordeon-card__header-content-title_size_m {
|
|
57
|
-
font-size: 16px;
|
|
58
|
-
}
|
|
59
50
|
.df-accordeon-card__header-content-description {
|
|
60
51
|
margin-top: 12px;
|
|
61
52
|
color: var(--g-color-text-complementary);
|
|
@@ -31,15 +31,22 @@ const AccordeonCard = ({ className, name, header, description, open: propsOpen,
|
|
|
31
31
|
accordeonRef.current.classList.add('df-accordeon-card_empty');
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
+
const currentHeaderVariant = react_1.default.useMemo(() => {
|
|
35
|
+
if (!lodash_1.default.isString(header)) {
|
|
36
|
+
return 'body-1';
|
|
37
|
+
}
|
|
38
|
+
if (titleSize === 'm') {
|
|
39
|
+
return 'subheader-2';
|
|
40
|
+
}
|
|
41
|
+
return 'subheader-1';
|
|
42
|
+
}, [titleSize]);
|
|
34
43
|
return (react_1.default.createElement("div", { ref: accordeonRef, className: b({ empty: Boolean(emptyBody) }, className) },
|
|
35
44
|
react_1.default.createElement("div", { className: b('header', {
|
|
36
45
|
open: open && !emptyBody,
|
|
37
46
|
'without-action': ignoreHeaderToggle || alwaysOpen,
|
|
38
47
|
}), onClick: !ignoreHeaderToggle && !alwaysOpen ? handleToggle : undefined },
|
|
39
48
|
react_1.default.createElement("div", { className: b('header-content') },
|
|
40
|
-
react_1.default.createElement(
|
|
41
|
-
? b('header-content-title', { size: titleSize })
|
|
42
|
-
: undefined }, header),
|
|
49
|
+
react_1.default.createElement(uikit_1.Text, { variant: currentHeaderVariant }, header),
|
|
43
50
|
description ? (react_1.default.createElement("span", { className: b('header-content-description'), dangerouslySetInnerHTML: { __html: description } })) : null),
|
|
44
51
|
!emptyBody && !alwaysOpen ? (react_1.default.createElement("div", { className: b('header-toggle-btn'), onClick: preventEvent },
|
|
45
52
|
headerActionsTemplate ? (react_1.default.createElement("div", { className: b('interal-actions') }, headerActionsTemplate)) : null,
|
|
@@ -48,12 +48,6 @@
|
|
|
48
48
|
margin-left: 10px;
|
|
49
49
|
}
|
|
50
50
|
.df-card__title {
|
|
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
|
-
white-space: nowrap;
|
|
55
|
-
overflow: hidden;
|
|
56
|
-
text-overflow: ellipsis;
|
|
57
51
|
max-width: 533px;
|
|
58
52
|
}
|
|
59
53
|
.df-card__note {
|
|
@@ -38,7 +38,7 @@ const Card = ({ name, title: propsTitle, description, actions, open: propsOpen,
|
|
|
38
38
|
if (lodash_1.default.isString(propsTitle)) {
|
|
39
39
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
40
40
|
react_1.default.createElement(uikit_1.Popover, { content: propsTitle, disabled: titlePopoverDisabled, placement: common_1.COMMON_POPOVER_PLACEMENT },
|
|
41
|
-
react_1.default.createElement(
|
|
41
|
+
react_1.default.createElement(uikit_1.Text, { className: b('title'), ellipsis: true, ref: titleRef, variant: "subheader-2" }, propsTitle)),
|
|
42
42
|
description ? (react_1.default.createElement("div", { className: b('note') },
|
|
43
43
|
react_1.default.createElement(components_1.HelpPopover, { htmlContent: description, placement: common_1.COMMON_POPOVER_PLACEMENT }))) : null));
|
|
44
44
|
}
|
|
@@ -43,7 +43,7 @@ const FileInput = ({ name, input, spec }) => {
|
|
|
43
43
|
return (react_1.default.createElement("div", { className: b() },
|
|
44
44
|
react_1.default.createElement(uikit_1.Button, { disabled: spec.viewSpec.disabled, onClick: handleClick, qa: `${name}-file-upload` }, (0, i18n_1.default)('button-upload_file')),
|
|
45
45
|
react_1.default.createElement("input", { type: "file", ref: inputRef, autoComplete: "off", disabled: spec.viewSpec.disabled, onChange: handleInputChange, className: b('input'), tabIndex: -1, accept: (_b = spec.viewSpec.fileInput) === null || _b === void 0 ? void 0 : _b.accept }),
|
|
46
|
-
react_1.default.createElement(
|
|
46
|
+
react_1.default.createElement(uikit_1.Text, { className: b('file-name'), ellipsis: true, color: "secondary" }, fileNameContent),
|
|
47
47
|
value ? (react_1.default.createElement(uikit_1.Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled, qa: `${name}-file-remove` },
|
|
48
48
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Xmark, size: 16 }))) : null));
|
|
49
49
|
};
|
|
@@ -10,5 +10,5 @@ const b = (0, utils_1.block)('monaco-header');
|
|
|
10
10
|
const MonacoHeader = ({ language, editButton }) => (react_1.default.createElement("div", { className: b() },
|
|
11
11
|
react_1.default.createElement("div", null,
|
|
12
12
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.File, size: 18 }),
|
|
13
|
-
react_1.default.createElement(
|
|
13
|
+
react_1.default.createElement(uikit_1.Text, { variant: "body-3" }, language)), editButton !== null && editButton !== void 0 ? editButton : null));
|
|
14
14
|
exports.MonacoHeader = MonacoHeader;
|
|
@@ -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;
|
|
@@ -27,7 +27,7 @@ const TextContent = (_a) => {
|
|
|
27
27
|
iconLib ? (react_1.default.createElement(uikit_1.Text, { color: (_b = spec.viewSpec.textContentParams) === null || _b === void 0 ? void 0 : _b.iconColor, className: b('icon') }, iconLib)) : null,
|
|
28
28
|
content,
|
|
29
29
|
input.value ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
30
|
-
react_1.default.createElement(
|
|
30
|
+
react_1.default.createElement(uikit_1.Text, { className: b('separator') }, ":"),
|
|
31
31
|
react_1.default.createElement(uikit_1.Text, { color: "secondary" }, input.value))) : null));
|
|
32
32
|
}
|
|
33
33
|
if (Layout) {
|
|
@@ -16,9 +16,9 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
|
|
|
16
16
|
return (react_1.default.createElement("div", { className: b() },
|
|
17
17
|
react_1.default.createElement("div", { className: b('left') },
|
|
18
18
|
react_1.default.createElement("div", { className: b('left-inner') },
|
|
19
|
-
react_1.default.createElement(
|
|
19
|
+
react_1.default.createElement(uikit_1.Text, { className: b('title', { required: spec.required }) }, spec.viewSpec.layoutTitle),
|
|
20
20
|
!verboseDescription && spec.viewSpec.layoutDescription ? (react_1.default.createElement("span", { className: b('note') },
|
|
21
|
-
react_1.default.createElement(
|
|
21
|
+
react_1.default.createElement(uikit_1.Text, { className: b('note-inner') },
|
|
22
22
|
react_1.default.createElement(components_1.HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })))) : null)),
|
|
23
23
|
react_1.default.createElement("div", { className: b('right') },
|
|
24
24
|
react_1.default.createElement("div", { className: b('right-inner') },
|
|
@@ -31,7 +31,7 @@ const SectionBase = (_a) => {
|
|
|
31
31
|
} }));
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
description = (react_1.default.createElement(
|
|
34
|
+
description = (react_1.default.createElement(uikit_1.Text, { className: b('note') },
|
|
35
35
|
react_1.default.createElement(components_1.HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LongValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
7
8
|
const b = (0, utils_1.block)('long-value');
|
|
8
9
|
const LongValue = ({ value, className }) => {
|
|
@@ -11,6 +12,15 @@ const LongValue = ({ value, className }) => {
|
|
|
11
12
|
const [open, setOpen] = react_1.default.useState(false);
|
|
12
13
|
const [long, setLong] = react_1.default.useState(false);
|
|
13
14
|
const handleClick = react_1.default.useCallback(() => setOpen((f) => !f), [setOpen]);
|
|
15
|
+
const currentTextProperies = react_1.default.useMemo(() => {
|
|
16
|
+
let wordBreak;
|
|
17
|
+
let whiteSpace;
|
|
18
|
+
if (open) {
|
|
19
|
+
wordBreak = 'break-all';
|
|
20
|
+
whiteSpace = 'break-spaces';
|
|
21
|
+
}
|
|
22
|
+
return { wordBreak, whiteSpace };
|
|
23
|
+
}, [open]);
|
|
14
24
|
react_1.default.useEffect(() => {
|
|
15
25
|
if (ref.current) {
|
|
16
26
|
if (value !== prevValue.current) {
|
|
@@ -32,6 +42,7 @@ const LongValue = ({ value, className }) => {
|
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
});
|
|
35
|
-
return (react_1.default.createElement("div", { ref: ref,
|
|
45
|
+
return (react_1.default.createElement("div", { ref: ref, onClick: long ? handleClick : undefined },
|
|
46
|
+
react_1.default.createElement(uikit_1.Text, Object.assign({ className: b({ long }, className), ellipsis: true }, currentTextProperies), value)));
|
|
36
47
|
};
|
|
37
48
|
exports.LongValue = LongValue;
|
|
@@ -17,21 +17,6 @@
|
|
|
17
17
|
margin-left: -13px;
|
|
18
18
|
max-width: 533px;
|
|
19
19
|
}
|
|
20
|
-
.df-simple-vertical-accordeon__title {
|
|
21
|
-
font-weight: 500;
|
|
22
|
-
}
|
|
23
|
-
.df-simple-vertical-accordeon__title_size_s {
|
|
24
|
-
margin-bottom: 0;
|
|
25
|
-
font-size: var(--g-text-body-1-font-size);
|
|
26
|
-
}
|
|
27
|
-
.df-simple-vertical-accordeon__title_size_m {
|
|
28
|
-
margin-bottom: 1px;
|
|
29
|
-
font-size: var(--g-text-body2-font-size);
|
|
30
|
-
}
|
|
31
|
-
.df-simple-vertical-accordeon__title_size_l {
|
|
32
|
-
margin-bottom: 2px;
|
|
33
|
-
font-size: var(--g-text-body3-font-size);
|
|
34
|
-
}
|
|
35
20
|
.df-simple-vertical-accordeon__tooltip {
|
|
36
21
|
margin: 0px 5px;
|
|
37
22
|
}
|
|
@@ -52,7 +52,7 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
52
52
|
}
|
|
53
53
|
render() {
|
|
54
54
|
var _a;
|
|
55
|
-
const {
|
|
55
|
+
const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
|
|
56
56
|
const { open, hidden, isFirstRender } = this.state;
|
|
57
57
|
const content = hideInsteadOfDestroy ? (react_1.default.createElement("div", { ref: this.componentRef, className: b('body', { hidden: !open }) }, children)) : (open && (react_1.default.createElement("div", { ref: this.componentRef, className: b('body', contentClassName) }, children)));
|
|
58
58
|
if (viewLayout && !isFirstRender && hidden) {
|
|
@@ -60,11 +60,12 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
60
60
|
}
|
|
61
61
|
const title = this.getTitle();
|
|
62
62
|
const titlePopoverDisabled = (((_a = this.titleRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) <= TITLE_TEXT_MAX_WIDTH;
|
|
63
|
+
const currentTitleVariant = this.getCurrentTitleVariant();
|
|
63
64
|
return (Boolean(react_1.default.Children.count(children)) && (react_1.default.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
|
|
64
65
|
react_1.default.createElement("div", { className: b('header') },
|
|
65
66
|
react_1.default.createElement(uikit_1.Popover, { content: title, disabled: titlePopoverDisabled, placement: common_1.COMMON_POPOVER_PLACEMENT },
|
|
66
67
|
react_1.default.createElement(uikit_1.Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick, qa: `${name}-accordeon-toggler`, width: "auto" },
|
|
67
|
-
react_1.default.createElement(
|
|
68
|
+
react_1.default.createElement(uikit_1.Text, { variant: currentTitleVariant }, title),
|
|
68
69
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ChevronDown, className: b('chevron', { open }), size: 16 }))),
|
|
69
70
|
this.getTooltip(),
|
|
70
71
|
headerActionsTemplate ? headerActionsTemplate : null),
|
|
@@ -77,9 +78,19 @@ class SimpleVerticalAccordeon extends react_1.default.Component {
|
|
|
77
78
|
}
|
|
78
79
|
return this.state.open ? openTitle : title;
|
|
79
80
|
}
|
|
81
|
+
getCurrentTitleVariant() {
|
|
82
|
+
const { titleSize } = this.props;
|
|
83
|
+
if (titleSize === 'm') {
|
|
84
|
+
return 'body-2';
|
|
85
|
+
}
|
|
86
|
+
if (titleSize === 'l') {
|
|
87
|
+
return 'body-3';
|
|
88
|
+
}
|
|
89
|
+
return 'body-1';
|
|
90
|
+
}
|
|
80
91
|
getTooltip() {
|
|
81
92
|
const { note } = this.props;
|
|
82
|
-
return note ? (react_1.default.createElement(
|
|
93
|
+
return note ? (react_1.default.createElement(uikit_1.Text, { className: b('tooltip') },
|
|
83
94
|
react_1.default.createElement(components_1.HelpPopover, { htmlContent: note, placement: ['bottom', 'top'] }))) : null;
|
|
84
95
|
}
|
|
85
96
|
}
|
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
align-items: baseline;
|
|
15
15
|
overflow: hidden;
|
|
16
16
|
}
|
|
17
|
-
.df-view-row__title {
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
text-overflow: ellipsis;
|
|
21
|
-
color: var(--g-color-text-secondary);
|
|
22
|
-
}
|
|
23
17
|
.df-view-row__dots {
|
|
24
18
|
min-width: 40px;
|
|
25
19
|
flex-grow: 1;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ViewRow = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
7
|
const kit_1 = require("../../../../kit");
|
|
7
8
|
const utils_1 = require("../../../utils");
|
|
8
9
|
const b = (0, utils_1.block)('view-row');
|
|
@@ -12,7 +13,7 @@ const ViewRow = ({ value, spec, children, }) => {
|
|
|
12
13
|
}
|
|
13
14
|
return (react_1.default.createElement("div", { className: b() },
|
|
14
15
|
react_1.default.createElement("div", { className: b('left') },
|
|
15
|
-
react_1.default.createElement(
|
|
16
|
+
react_1.default.createElement(uikit_1.Text, { whiteSpace: "nowrap", color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
|
|
16
17
|
react_1.default.createElement("div", { className: b('dots') })),
|
|
17
18
|
react_1.default.createElement("div", { className: b('right') }, children),
|
|
18
19
|
react_1.default.createElement(kit_1.CopyButton, { spec: spec, value: value })));
|
|
@@ -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 })));
|
|
@@ -12,9 +12,7 @@ const NumberWithScaleViewBase = ({ spec, value }) => {
|
|
|
12
12
|
const { scale } = spec.viewSpec.sizeParams;
|
|
13
13
|
return (react_1.default.createElement("div", { className: b() },
|
|
14
14
|
react_1.default.createElement(uikit_1.Popover, { placement: ['bottom', 'top'], content: initialValue, className: b('tooltip-container'), contentClassName: b('tooltip'), disabled: initialValue.length < 26 }, initialValue),
|
|
15
|
-
react_1.default.createElement(
|
|
16
|
-
" ",
|
|
17
|
-
scale[initialType].title)));
|
|
15
|
+
react_1.default.createElement(uikit_1.Text, { className: b('size') }, scale[initialType].title)));
|
|
18
16
|
};
|
|
19
17
|
const NumberWithScaleView = (props) => (0, utils_1.isCorrectSizeParams)(props.spec) && props.value ? react_1.default.createElement(NumberWithScaleViewBase, Object.assign({}, props)) : null;
|
|
20
18
|
exports.NumberWithScaleView = NumberWithScaleView;
|
|
@@ -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 })));
|