@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.
Files changed (67) hide show
  1. package/build/cjs/lib/core/components/Form/Controller/Controller.js +4 -4
  2. package/build/cjs/lib/core/components/Form/Controller/utils.js +39 -31
  3. package/build/cjs/lib/core/components/Form/DynamicField.js +3 -3
  4. package/build/cjs/lib/core/components/Form/hooks/useMutators.js +21 -7
  5. package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.css +0 -9
  6. package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +10 -3
  7. package/build/cjs/lib/kit/components/Card/Card.css +0 -6
  8. package/build/cjs/lib/kit/components/Card/Card.js +1 -1
  9. package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
  10. package/build/cjs/lib/kit/components/Inputs/FileInput/FileInput.js +1 -1
  11. package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
  12. package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +1 -1
  13. package/build/cjs/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
  14. package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
  15. package/build/cjs/lib/kit/components/Layouts/Row/Row.css +1 -0
  16. package/build/cjs/lib/kit/components/Layouts/Row/Row.js +2 -2
  17. package/build/cjs/lib/kit/components/Layouts/Section/Section.js +1 -1
  18. package/build/cjs/lib/kit/components/LongValue/LongValue.css +0 -6
  19. package/build/cjs/lib/kit/components/LongValue/LongValue.js +12 -1
  20. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
  21. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +14 -3
  22. package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
  23. package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
  24. package/build/cjs/lib/kit/components/Views/CardOneOfView.js +1 -1
  25. package/build/cjs/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
  26. package/build/cjs/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +1 -3
  27. package/build/cjs/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
  28. package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
  29. package/build/cjs/lib/kit/components/Views/TextAreaView/TextAreaView.js +1 -1
  30. package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
  31. package/build/esm/lib/core/components/Form/Controller/Controller.js +4 -4
  32. package/build/esm/lib/core/components/Form/Controller/types.d.ts +6 -6
  33. package/build/esm/lib/core/components/Form/Controller/utils.d.ts +6 -6
  34. package/build/esm/lib/core/components/Form/Controller/utils.js +39 -31
  35. package/build/esm/lib/core/components/Form/DynamicField.js +3 -3
  36. package/build/esm/lib/core/components/Form/hooks/useMutators.d.ts +2 -2
  37. package/build/esm/lib/core/components/Form/hooks/useMutators.js +21 -7
  38. package/build/esm/lib/core/components/Form/types/context.d.ts +2 -2
  39. package/build/esm/lib/core/components/Form/types/mutators.d.ts +11 -0
  40. package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.css +0 -9
  41. package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +11 -4
  42. package/build/esm/lib/kit/components/Card/Card.css +0 -6
  43. package/build/esm/lib/kit/components/Card/Card.js +2 -2
  44. package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.css +0 -4
  45. package/build/esm/lib/kit/components/Inputs/FileInput/FileInput.js +2 -2
  46. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.css +0 -5
  47. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoHeader.js +2 -2
  48. package/build/esm/lib/kit/components/Inputs/TextArea/TextArea.js +1 -1
  49. package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
  50. package/build/esm/lib/kit/components/Layouts/Row/Row.css +1 -0
  51. package/build/esm/lib/kit/components/Layouts/Row/Row.js +3 -3
  52. package/build/esm/lib/kit/components/Layouts/Section/Section.js +2 -2
  53. package/build/esm/lib/kit/components/LongValue/LongValue.css +0 -6
  54. package/build/esm/lib/kit/components/LongValue/LongValue.js +12 -1
  55. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +0 -15
  56. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.d.ts +1 -0
  57. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.js +15 -4
  58. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +0 -6
  59. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +2 -1
  60. package/build/esm/lib/kit/components/Views/CardOneOfView.js +1 -1
  61. package/build/esm/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +1 -1
  62. package/build/esm/lib/kit/components/Views/NumberWithScaleView/NumberWithScaleView.js +2 -4
  63. package/build/esm/lib/kit/components/Views/OneOfView/OneOfView.js +1 -1
  64. package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.css +0 -8
  65. package/build/esm/lib/kit/components/Views/TextAreaView/TextAreaView.js +2 -2
  66. package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +1 -1
  67. package/package.json +4 -3
@@ -4,14 +4,6 @@
4
4
  .df-text-area-view_active {
5
5
  cursor: pointer;
6
6
  }
7
- .df-text-area-view__text-view {
8
- overflow: hidden;
9
- text-overflow: ellipsis;
10
- }
11
- .df-text-area-view__text-view_open {
12
- white-space: pre-wrap;
13
- overflow-wrap: break-word;
14
- }
15
7
  .df-text-area-view__chevron {
16
8
  margin: 3px;
17
9
  }
@@ -14,7 +14,7 @@ const TextAreaView = ({ value = '' }) => {
14
14
  setIsOpen(!isOpen);
15
15
  }, [isOpen]);
16
16
  return (react_1.default.createElement("div", { className: b({ active: isValueLong }), onClick: isValueLong ? handleClick : undefined },
17
- react_1.default.createElement("div", { className: b('text-view', { open: isOpen }) }, value),
17
+ react_1.default.createElement(uikit_1.Text, { ellipsis: true, whiteSpace: isOpen ? 'break-spaces' : undefined }, value),
18
18
  isValueLong ? (react_1.default.createElement("div", null,
19
19
  react_1.default.createElement(uikit_1.Icon, { data: icons_1.ChevronDown, className: b('chevron', { open: isOpen }), size: 16 }))) : null));
20
20
  };
@@ -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}.${TEXT_LINK_PROPERTY_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
  }
@@ -3,12 +3,12 @@ import _ from 'lodash';
3
3
  import { useControllerMirror, useDynamicFormsCtx, useSearch } from '../hooks';
4
4
  import { callUnmout, getFieldMethods, initializeStore, updateStore } from './utils';
5
5
  export const Controller = ({ spec: _spec, name, value: valueFromParent, parentOnChange, parentOnUnmount, }) => {
6
- const { config, tools, mutators, __mirror } = useDynamicFormsCtx();
6
+ const { config, tools, mutatorsStore, __mirror } = useDynamicFormsCtx();
7
7
  const firstRenderRef = React.useRef(true);
8
8
  const [store, setStore] = React.useState(initializeStore({
9
9
  name,
10
10
  spec: _spec,
11
- mutators,
11
+ mutatorsStore,
12
12
  config,
13
13
  valueFromParent,
14
14
  tools,
@@ -88,7 +88,7 @@ export const Controller = ({ spec: _spec, name, value: valueFromParent, parentOn
88
88
  name,
89
89
  parentOnChange,
90
90
  parentOnUnmount,
91
- mutators,
91
+ mutatorsStore,
92
92
  config,
93
93
  tools,
94
94
  methodOnChange: fieldMethods.onChange,
@@ -100,7 +100,7 @@ export const Controller = ({ spec: _spec, name, value: valueFromParent, parentOn
100
100
  name,
101
101
  parentOnChange,
102
102
  parentOnUnmount,
103
- mutators,
103
+ mutatorsStore,
104
104
  config,
105
105
  tools.onChange,
106
106
  tools.onUnmount,
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { FormValue, Spec } from '../../../types';
3
- import { DynamicFormConfig, DynamicFormMutators, DynamicFormsContext, FieldRenderProps, FieldValue, IndependentInputEntity, InputEntity, LayoutType, ValidateError } from '../types';
3
+ import { DynamicFormConfig, DynamicFormMutatorsStore, DynamicFormsContext, FieldRenderProps, FieldValue, IndependentInputEntity, InputEntity, LayoutType, ValidateError } from '../types';
4
4
  export interface GetSpecParams<SpecType extends Spec> {
5
5
  name: string;
6
6
  spec: SpecType;
7
- mutators: DynamicFormMutators;
7
+ mutatorsStore: DynamicFormMutatorsStore;
8
8
  }
9
9
  export interface GetComponentsParams<SpecType extends Spec> {
10
10
  spec: SpecType;
@@ -30,7 +30,7 @@ export interface GetFieldInitialsParams<DirtyValue extends FieldValue, Value ext
30
30
  valueFromParent: DirtyValue;
31
31
  initialValue: DirtyValue;
32
32
  validate: (value?: Value) => ValidateError;
33
- mutators: DynamicFormMutators;
33
+ mutatorsStore: DynamicFormMutatorsStore;
34
34
  }
35
35
  export type FieldMethod<DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec, Params extends any = undefined> = (store: ControllerStore<DirtyValue, Value, SpecType>, params: Params) => ControllerStore<DirtyValue, Value, SpecType>;
36
36
  export interface GetFieldMethodsReturn<DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec> {
@@ -49,7 +49,7 @@ export interface GetFieldMethodsReturn<DirtyValue extends FieldValue, Value exte
49
49
  export interface InitializeStoreParams<DirtyValue extends FieldValue, SpecType extends Spec> {
50
50
  name: string;
51
51
  spec: SpecType;
52
- mutators: DynamicFormMutators;
52
+ mutatorsStore: DynamicFormMutatorsStore;
53
53
  config: DynamicFormConfig;
54
54
  valueFromParent: DirtyValue;
55
55
  tools: DynamicFormsContext['tools'];
@@ -62,7 +62,7 @@ export interface ControllerStore<DirtyValue extends FieldValue, Value extends Fo
62
62
  initialSpec: SpecType;
63
63
  config: DynamicFormConfig;
64
64
  tools: DynamicFormsContext['tools'];
65
- mutators: DynamicFormMutators;
65
+ mutatorsStore: DynamicFormMutatorsStore;
66
66
  render: (props: FieldRenderProps<DirtyValue>) => JSX.Element | null;
67
67
  validate: (value?: Value) => ValidateError;
68
68
  parentOnChange: ((childName: string, childValue: FieldValue, childErrors: Record<string, ValidateError>) => void) | null;
@@ -90,7 +90,7 @@ export interface UpdateStoreParams<DirtyValue extends FieldValue, Value extends
90
90
  name: string;
91
91
  parentOnChange: ((childName: string, childValue: FieldValue, childErrors: Record<string, ValidateError>) => void) | null;
92
92
  parentOnUnmount: ((childName: string) => void) | null;
93
- mutators: DynamicFormMutators;
93
+ mutatorsStore: DynamicFormMutatorsStore;
94
94
  valueFromParent: DirtyValue;
95
95
  config: DynamicFormConfig;
96
96
  tools: DynamicFormsContext['tools'];
@@ -1,17 +1,17 @@
1
1
  import { FormValue, Spec } from '../../../types';
2
- import { FieldRenderProps, FieldValue, ValidateError } from '../types';
2
+ import { BaseValidateError, FieldRenderProps, FieldValue, ValidateError } from '../types';
3
3
  import { ControllerStore, GetComponentsParams, GetComponentsReturn, GetFieldInitialsParams, GetFieldMethodsReturn, GetRenderParams, GetSpecParams, GetValidateParams, InitializeStoreParams, UpdateStoreParams } from './types';
4
4
  export declare const updateParentStore: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>(store: ControllerStore<DirtyValue, Value, SpecType>) => void;
5
5
  export declare const callUnmout: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>(store: ControllerStore<DirtyValue, Value, SpecType>) => void;
6
- export declare const getSpec: <SpecType extends Spec>({ name, spec, mutators, }: GetSpecParams<SpecType>) => SpecType;
6
+ export declare const getSpec: <SpecType extends Spec>({ name, spec, mutatorsStore, }: GetSpecParams<SpecType>) => SpecType;
7
7
  export declare const getComponents: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ spec, config, }: GetComponentsParams<SpecType>) => GetComponentsReturn<DirtyValue, SpecType>;
8
8
  export declare const getRender: <DirtyValue extends FieldValue, SpecType extends Spec>({ name, spec, inputEntity, Layout, }: GetRenderParams<DirtyValue, SpecType>) => (props: FieldRenderProps<DirtyValue>) => JSX.Element | null;
9
9
  export declare const getValidate: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ spec, config, }: GetValidateParams<SpecType>) => (value?: Value | undefined) => ValidateError;
10
- export declare const getFieldInitials: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ name, spec, valueFromParent, initialValue, validate, mutators, }: GetFieldInitialsParams<DirtyValue, Value, SpecType>) => {
10
+ export declare const getFieldInitials: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ name, spec, valueFromParent, initialValue, validate, mutatorsStore, }: GetFieldInitialsParams<DirtyValue, Value, SpecType>) => {
11
11
  initialValue: DirtyValue;
12
12
  active: boolean;
13
13
  dirty: boolean;
14
- error: string | boolean | import("../types").AsyncValidateError | undefined;
14
+ error: BaseValidateError | import("../types").AsyncValidateError;
15
15
  invalid: boolean;
16
16
  modified: boolean;
17
17
  pristine: boolean;
@@ -22,5 +22,5 @@ export declare const getFieldInitials: <DirtyValue extends FieldValue, Value ext
22
22
  childErrors: {};
23
23
  };
24
24
  export declare const getFieldMethods: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>() => GetFieldMethodsReturn<DirtyValue, Value, SpecType>;
25
- export declare const initializeStore: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ name, spec: _spec, mutators, config, valueFromParent, tools, parentOnChange, parentOnUnmount, }: InitializeStoreParams<DirtyValue, SpecType>) => ControllerStore<DirtyValue, Value, SpecType>;
26
- export declare const updateStore: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutators, valueFromParent, config, tools, methodOnChange, }: UpdateStoreParams<DirtyValue, Value, SpecType>) => void;
25
+ export declare const initializeStore: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ name, spec: _spec, mutatorsStore, config, valueFromParent, tools, parentOnChange, parentOnUnmount, }: InitializeStoreParams<DirtyValue, SpecType>) => ControllerStore<DirtyValue, Value, SpecType>;
26
+ export declare const updateStore: <DirtyValue extends FieldValue, Value extends FormValue, SpecType extends Spec>({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutatorsStore, valueFromParent, config, tools, methodOnChange, }: UpdateStoreParams<DirtyValue, Value, SpecType>) => void;
@@ -5,20 +5,24 @@ import { SpecTypes } from '../../../constants';
5
5
  import { isArraySpec, isCorrectSpec, isNumberSpec, isObjectSpec } from '../../../helpers';
6
6
  import { EMPTY_MUTATOR, OBJECT_ARRAY_CNT, OBJECT_ARRAY_FLAG } from '../constants';
7
7
  import { isArrayItem, isCorrectConfig, transformArrIn, transformArrOut } from '../utils';
8
- const isErrorMutatorCorrect = (errorMutator) => errorMutator !== EMPTY_MUTATOR && (_.isString(errorMutator) || _.isBoolean(errorMutator));
8
+ const isErrorMutatorCorrect = (errorMutator) => errorMutator !== EMPTY_MUTATOR &&
9
+ (_.isString(errorMutator.value) ||
10
+ _.isBoolean(errorMutator.value) ||
11
+ _.isUndefined(errorMutator.value));
9
12
  const isValueMutatorCorrect = (valueMutator, spec) => valueMutator !== EMPTY_MUTATOR &&
10
- (typeof valueMutator === spec.type ||
11
- (_.isArray(valueMutator) && spec.type === SpecTypes.Array));
13
+ (typeof valueMutator.value === spec.type ||
14
+ (_.isArray(valueMutator.value) && spec.type === SpecTypes.Array) ||
15
+ valueMutator.value === undefined);
12
16
  export const updateParentStore = (store) => {
13
17
  (store.parentOnChange ? store.parentOnChange : store.tools.onChange)(store.name, store.state.value, Object.assign(Object.assign({}, store.state.childErrors), { [store.name]: store.state.error }));
14
18
  };
15
19
  export const callUnmout = (store) => {
16
20
  (store.parentOnUnmount ? store.parentOnUnmount : store.tools.onUnmount)(store.name);
17
21
  };
18
- export const getSpec = ({ name, spec, mutators, }) => {
19
- const mutator = _.get(mutators.spec, name, EMPTY_MUTATOR);
22
+ export const getSpec = ({ name, spec, mutatorsStore, }) => {
23
+ const mutator = _.get(mutatorsStore.spec, name, EMPTY_MUTATOR);
20
24
  if (mutator !== EMPTY_MUTATOR) {
21
- const mutatedSpec = _.merge(_.cloneDeep(spec), mutator);
25
+ const mutatedSpec = _.merge(_.cloneDeep(spec), mutator.value);
22
26
  if (isCorrectSpec(mutatedSpec)) {
23
27
  return mutatedSpec;
24
28
  }
@@ -80,11 +84,11 @@ export const getValidate = ({ spec, config, }) => {
80
84
  }
81
85
  return validate;
82
86
  };
83
- export const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate, mutators, }) => {
84
- const valueMutator = transformArrIn(_.get(mutators.values, name, EMPTY_MUTATOR));
87
+ export const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate, mutatorsStore, }) => {
88
+ const valueMutator = transformArrIn(_.get(mutatorsStore.values, name, EMPTY_MUTATOR));
85
89
  let value = _.cloneDeep(valueFromParent);
86
90
  if (isValueMutatorCorrect(valueMutator, spec)) {
87
- value = valueMutator;
91
+ value = valueMutator.value;
88
92
  }
89
93
  if (_.isNil(value)) {
90
94
  if (spec.defaultValue) {
@@ -101,11 +105,11 @@ export const getFieldInitials = ({ name, spec, valueFromParent, initialValue, va
101
105
  }
102
106
  }
103
107
  }
104
- let errorMutator = _.get(mutators.errors, name, EMPTY_MUTATOR);
108
+ let errorMutator = _.get(mutatorsStore.errors, name, EMPTY_MUTATOR);
105
109
  if (!isErrorMutatorCorrect(errorMutator)) {
106
- errorMutator = undefined;
110
+ errorMutator = { value: undefined };
107
111
  }
108
- const error = (validate === null || validate === void 0 ? void 0 : validate(transformArrOut(value))) || errorMutator;
112
+ const error = (validate === null || validate === void 0 ? void 0 : validate(transformArrOut(value))) || (errorMutator === null || errorMutator === void 0 ? void 0 : errorMutator.value);
109
113
  const dirty = !_.isEqual(value, initialValue);
110
114
  return {
111
115
  initialValue,
@@ -197,8 +201,8 @@ export const getFieldMethods = () => {
197
201
  onItemRemove,
198
202
  };
199
203
  };
200
- export const initializeStore = ({ name, spec: _spec, mutators, config, valueFromParent, tools, parentOnChange, parentOnUnmount, }) => {
201
- const spec = getSpec({ name, spec: _spec, mutators });
204
+ export const initializeStore = ({ name, spec: _spec, mutatorsStore, config, valueFromParent, tools, parentOnChange, parentOnUnmount, }) => {
205
+ const spec = getSpec({ name, spec: _spec, mutatorsStore });
202
206
  const components = getComponents({ spec, config });
203
207
  const render = getRender(Object.assign({ name, spec }, components));
204
208
  const validate = getValidate({ spec, config });
@@ -207,7 +211,7 @@ export const initializeStore = ({ name, spec: _spec, mutators, config, valueFrom
207
211
  spec,
208
212
  valueFromParent,
209
213
  validate,
210
- mutators,
214
+ mutatorsStore,
211
215
  initialValue: _.get(tools.initialValue, name),
212
216
  });
213
217
  const initialsStore = {
@@ -216,7 +220,7 @@ export const initializeStore = ({ name, spec: _spec, mutators, config, valueFrom
216
220
  initialSpec: _spec,
217
221
  config,
218
222
  tools,
219
- mutators,
223
+ mutatorsStore,
220
224
  render,
221
225
  validate,
222
226
  parentOnChange,
@@ -228,14 +232,14 @@ export const initializeStore = ({ name, spec: _spec, mutators, config, valueFrom
228
232
  }
229
233
  return initialsStore;
230
234
  };
231
- export const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutators, valueFromParent, config, tools, methodOnChange, }) => {
232
- const storeSpecMutator = _.get(store.mutators.spec, store.name, EMPTY_MUTATOR);
233
- const storeValueMutator = _.get(store.mutators.values, store.name, EMPTY_MUTATOR);
234
- const storeErrorMutator = _.get(store.mutators.errors, store.name, EMPTY_MUTATOR);
235
- const specMutator = _.get(mutators.spec, name, EMPTY_MUTATOR);
236
- const valueMutator = _.get(mutators.values, name, EMPTY_MUTATOR);
237
- const errorMutator = _.get(mutators.errors, name, EMPTY_MUTATOR);
238
- const valueMutatorUpdated = isValueMutatorCorrect(valueMutator, getSpec({ name, spec: _spec, mutators })) &&
235
+ export const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange, parentOnUnmount, mutatorsStore, valueFromParent, config, tools, methodOnChange, }) => {
236
+ const storeSpecMutator = _.get(store.mutatorsStore.spec, store.name, EMPTY_MUTATOR);
237
+ const storeValueMutator = _.get(store.mutatorsStore.values, store.name, EMPTY_MUTATOR);
238
+ const storeErrorMutator = _.get(store.mutatorsStore.errors, store.name, EMPTY_MUTATOR);
239
+ const specMutator = _.get(mutatorsStore.spec, name, EMPTY_MUTATOR);
240
+ const valueMutator = _.get(mutatorsStore.values, name, EMPTY_MUTATOR);
241
+ const errorMutator = _.get(mutatorsStore.errors, name, EMPTY_MUTATOR);
242
+ const valueMutatorUpdated = isValueMutatorCorrect(valueMutator, getSpec({ name, spec: _spec, mutatorsStore })) &&
239
243
  valueMutator !== storeValueMutator;
240
244
  const errorMutatorUpdated = isErrorMutatorCorrect(errorMutator) && errorMutator !== storeErrorMutator;
241
245
  const updateState = valueMutatorUpdated || errorMutatorUpdated;
@@ -252,7 +256,7 @@ export const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange
252
256
  setStore(initializeStore({
253
257
  name,
254
258
  spec: _spec,
255
- mutators,
259
+ mutatorsStore,
256
260
  config,
257
261
  valueFromParent,
258
262
  tools,
@@ -264,16 +268,16 @@ export const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange
264
268
  let nextStore = Object.assign(Object.assign({}, initializeStore({
265
269
  name,
266
270
  spec: _spec,
267
- mutators,
271
+ mutatorsStore,
268
272
  config,
269
273
  valueFromParent,
270
274
  tools,
271
275
  parentOnChange,
272
276
  parentOnUnmount,
273
277
  })), { state: store.state });
274
- if (updateState) {
275
- nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated ? { errorMutator } : {})));
276
- }
278
+ nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
279
+ ? { errorMutator: errorMutator.value }
280
+ : {})));
277
281
  setStore(nextStore);
278
282
  }
279
283
  else if (updateNonCritical) {
@@ -281,11 +285,15 @@ export const updateStore = ({ store, setStore, spec: _spec, name, parentOnChange
281
285
  parentOnUnmount,
282
286
  tools });
283
287
  if (updateState) {
284
- nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated ? { errorMutator } : {})));
288
+ nextStore = methodOnChange(nextStore, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
289
+ ? { errorMutator: errorMutator.value }
290
+ : {})));
285
291
  }
286
292
  setStore(nextStore);
287
293
  }
288
294
  else if (updateState) {
289
- setStore(methodOnChange(store, Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator : value }, (errorMutatorUpdated ? { errorMutator } : {}))));
295
+ setStore(methodOnChange(Object.assign(Object.assign({}, store), { mutatorsStore }), Object.assign({ valOrSetter: (value) => valueMutatorUpdated ? valueMutator.value : value }, (errorMutatorUpdated
296
+ ? { errorMutator: errorMutator.value }
297
+ : {}))));
290
298
  }
291
299
  };
@@ -10,7 +10,7 @@ export const DynamicField = ({ name, spec, config, Monaco, generateRandomValue,
10
10
  const SearchContext = useCreateSearchContext();
11
11
  const { tools, store } = useStore(name);
12
12
  const watcher = useIntegrationFF(store, withoutInsertFFDebounce);
13
- const { mutators, mutateDFState } = useMutators(externalMutators);
13
+ const { mutatorsStore, mutateDFState } = useMutators(externalMutators);
14
14
  const { store: searchStore, setField, removeField, isHiddenField } = useSearchStore();
15
15
  const context = React.useMemo(() => ({
16
16
  config,
@@ -18,9 +18,9 @@ export const DynamicField = ({ name, spec, config, Monaco, generateRandomValue,
18
18
  generateRandomValue,
19
19
  tools: Object.assign(Object.assign({}, tools), { mutateDFState }),
20
20
  store,
21
- mutators,
21
+ mutatorsStore,
22
22
  __mirror,
23
- }), [tools, config, Monaco, __mirror, generateRandomValue, mutators, mutateDFState, store]);
23
+ }), [tools, config, Monaco, __mirror, generateRandomValue, mutatorsStore, mutateDFState, store]);
24
24
  const searchContext = React.useMemo(() => ({
25
25
  setField,
26
26
  removeField,
@@ -1,5 +1,5 @@
1
- import { DynamicFormMutators } from '../types';
1
+ import { DynamicFormMutators, DynamicFormMutatorsStore } from '../types';
2
2
  export declare const useMutators: (externalMutators?: DynamicFormMutators) => {
3
- mutators: DynamicFormMutators;
3
+ mutatorsStore: DynamicFormMutatorsStore;
4
4
  mutateDFState: (mutators: DynamicFormMutators) => void;
5
5
  };
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
2
  import _ from 'lodash';
3
3
  export const useMutators = (externalMutators) => {
4
- const firstRenderRef = React.useRef(true);
5
- const [store, setStore] = React.useState(externalMutators || {});
6
- const mutateDFState = React.useCallback((mutators) => {
7
- const mergeSpec = (a, b) => {
4
+ const merge = React.useCallback((mutators, store) => {
5
+ const mergeSpec = (a = {}, b) => {
8
6
  const result = _.cloneDeep(a);
9
7
  const getKeys = (parent) => {
10
8
  if (_.isObjectLike(parent)) {
@@ -20,11 +18,27 @@ export const useMutators = (externalMutators) => {
20
18
  return [];
21
19
  };
22
20
  getKeys(b).forEach((key) => {
23
- _.set(result, key, _.get(b, key));
21
+ _.set(result, [key[0], 'value', ...key.slice(1)], _.get(b, key));
22
+ });
23
+ return result;
24
+ };
25
+ const mergeValuesOrErrors = (a = {}, b) => {
26
+ const result = _.cloneDeep(a);
27
+ Object.keys(b).forEach((key) => {
28
+ _.set(result, [key, 'value'], b[key]);
24
29
  });
25
30
  return result;
26
31
  };
27
- setStore((store) => (Object.assign(Object.assign(Object.assign(Object.assign({}, store), (mutators.errors ? { errors: _.merge(store.errors, mutators.errors) } : {})), (mutators.values ? { values: _.merge(store.values, mutators.values) } : {})), (mutators.spec ? { spec: mergeSpec(store.spec || {}, mutators.spec) } : {}))));
32
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, store), (mutators.errors
33
+ ? { errors: mergeValuesOrErrors(store.errors, mutators.errors) }
34
+ : {})), (mutators.values
35
+ ? { values: mergeValuesOrErrors(store.values, mutators.values) }
36
+ : {})), (mutators.spec ? { spec: mergeSpec(store.spec, mutators.spec) } : {}));
37
+ }, []);
38
+ const firstRenderRef = React.useRef(true);
39
+ const [store, setStore] = React.useState(merge(externalMutators || {}, {}));
40
+ const mutateDFState = React.useCallback((mutators) => {
41
+ setStore((store) => merge(mutators, store));
28
42
  }, [setStore]);
29
43
  React.useEffect(() => {
30
44
  if (firstRenderRef.current) {
@@ -34,5 +48,5 @@ export const useMutators = (externalMutators) => {
34
48
  mutateDFState(externalMutators);
35
49
  }
36
50
  }, [externalMutators]);
37
- return { mutators: store, mutateDFState };
51
+ return { mutatorsStore: store, mutateDFState };
38
52
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { MonacoEditorProps } from 'react-monaco-editor/lib/types';
3
3
  import { StringSpec } from '../../../types';
4
- import { DynamicFieldStore, DynamicFormConfig, DynamicFormMutators, FieldValue, ValidateError, WonderMirror } from './';
4
+ import { DynamicFieldStore, DynamicFormConfig, DynamicFormMutators, DynamicFormMutatorsStore, FieldValue, ValidateError, WonderMirror } from './';
5
5
  export interface DynamicFormsContext {
6
6
  config: DynamicFormConfig;
7
7
  Monaco?: React.ComponentType<MonacoEditorProps>;
@@ -14,6 +14,6 @@ export interface DynamicFormsContext {
14
14
  mutateDFState: (mutators: DynamicFormMutators) => void;
15
15
  };
16
16
  store: DynamicFieldStore;
17
- mutators: DynamicFormMutators;
17
+ mutatorsStore: DynamicFormMutatorsStore;
18
18
  __mirror?: WonderMirror;
19
19
  }
@@ -16,3 +16,14 @@ export interface DynamicFormMutators {
16
16
  values?: Record<string, FormValue>;
17
17
  spec?: Record<string, SpecMutator>;
18
18
  }
19
+ export interface DynamicFormMutatorsStore {
20
+ errors?: Record<string, {
21
+ value: BaseValidateError;
22
+ }>;
23
+ values?: Record<string, {
24
+ value: FormValue;
25
+ }>;
26
+ spec?: Record<string, {
27
+ value: SpecMutator;
28
+ }>;
29
+ }
@@ -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);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ChevronDown } from '@gravity-ui/icons';
3
- import { Button, Icon } from '@gravity-ui/uikit';
3
+ import { Button, Icon, Text } from '@gravity-ui/uikit';
4
4
  import _ from 'lodash';
5
5
  import { block } from '../../utils';
6
6
  import './AccordeonCard.css';
@@ -28,15 +28,22 @@ export const AccordeonCard = ({ className, name, header, description, open: prop
28
28
  accordeonRef.current.classList.add('df-accordeon-card_empty');
29
29
  }
30
30
  });
31
+ const currentHeaderVariant = React.useMemo(() => {
32
+ if (!_.isString(header)) {
33
+ return 'body-1';
34
+ }
35
+ if (titleSize === 'm') {
36
+ return 'subheader-2';
37
+ }
38
+ return 'subheader-1';
39
+ }, [titleSize]);
31
40
  return (React.createElement("div", { ref: accordeonRef, className: b({ empty: Boolean(emptyBody) }, className) },
32
41
  React.createElement("div", { className: b('header', {
33
42
  open: open && !emptyBody,
34
43
  'without-action': ignoreHeaderToggle || alwaysOpen,
35
44
  }), onClick: !ignoreHeaderToggle && !alwaysOpen ? handleToggle : undefined },
36
45
  React.createElement("div", { className: b('header-content') },
37
- React.createElement("span", { className: _.isString(header)
38
- ? b('header-content-title', { size: titleSize })
39
- : undefined }, header),
46
+ React.createElement(Text, { variant: currentHeaderVariant }, header),
40
47
  description ? (React.createElement("span", { className: b('header-content-description'), dangerouslySetInnerHTML: { __html: description } })) : null),
41
48
  !emptyBody && !alwaysOpen ? (React.createElement("div", { className: b('header-toggle-btn'), onClick: preventEvent },
42
49
  headerActionsTemplate ? (React.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 {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { HelpPopover } from '@gravity-ui/components';
3
3
  import { ChevronDown } from '@gravity-ui/icons';
4
- import { Button, Card as CardBase, Icon, Popover } from '@gravity-ui/uikit';
4
+ import { Button, Card as CardBase, Icon, Popover, Text } from '@gravity-ui/uikit';
5
5
  import _ from 'lodash';
6
6
  import { COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH } from '../../constants/common';
7
7
  import { block } from '../../utils';
@@ -35,7 +35,7 @@ export const Card = ({ name, title: propsTitle, description, actions, open: prop
35
35
  if (_.isString(propsTitle)) {
36
36
  return (React.createElement(React.Fragment, null,
37
37
  React.createElement(Popover, { content: propsTitle, disabled: titlePopoverDisabled, placement: COMMON_POPOVER_PLACEMENT },
38
- React.createElement("div", { ref: titleRef, className: b('title') }, propsTitle)),
38
+ React.createElement(Text, { className: b('title'), ellipsis: true, ref: titleRef, variant: "subheader-2" }, propsTitle)),
39
39
  description ? (React.createElement("div", { className: b('note') },
40
40
  React.createElement(HelpPopover, { htmlContent: description, placement: COMMON_POPOVER_PLACEMENT }))) : null));
41
41
  }
@@ -8,8 +8,4 @@
8
8
  display: block;
9
9
  margin: auto 10px;
10
10
  max-width: 160px;
11
- text-overflow: ellipsis;
12
- overflow: hidden;
13
- white-space: nowrap;
14
- color: var(--g-color-text-secondary);
15
11
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Xmark } from '@gravity-ui/icons';
3
- import { Button, Icon, Label } from '@gravity-ui/uikit';
3
+ import { Button, Icon, Label, Text } from '@gravity-ui/uikit';
4
4
  import i18n from '../../../../kit/i18n';
5
5
  import { block } from '../../../utils';
6
6
  import { readFile } from './utils';
@@ -40,7 +40,7 @@ export const FileInput = ({ name, input, spec }) => {
40
40
  return (React.createElement("div", { className: b() },
41
41
  React.createElement(Button, { disabled: spec.viewSpec.disabled, onClick: handleClick, qa: `${name}-file-upload` }, i18n('button-upload_file')),
42
42
  React.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 }),
43
- React.createElement("span", { className: b('file-name') }, fileNameContent),
43
+ React.createElement(Text, { className: b('file-name'), ellipsis: true, color: "secondary" }, fileNameContent),
44
44
  value ? (React.createElement(Button, { view: "flat", onClick: handleReset, disabled: spec.viewSpec.disabled, qa: `${name}-file-remove` },
45
45
  React.createElement(Icon, { data: Xmark, size: 16 }))) : null));
46
46
  };
@@ -5,9 +5,4 @@
5
5
  padding: 15px;
6
6
  align-items: center;
7
7
  background-color: var(--g-color-base-float-hover);
8
- }
9
- .df-monaco-header__language {
10
- margin-top: 2px;
11
- margin-left: 10px;
12
- font-size: 16px;
13
8
  }
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { File } from '@gravity-ui/icons';
3
- import { Icon } from '@gravity-ui/uikit';
3
+ import { Icon, Text } from '@gravity-ui/uikit';
4
4
  import { block } from '../../../utils';
5
5
  import './MonacoHeader.css';
6
6
  const b = block('monaco-header');
7
7
  export const MonacoHeader = ({ language, editButton }) => (React.createElement("div", { className: b() },
8
8
  React.createElement("div", null,
9
9
  React.createElement(Icon, { data: File, size: 18 }),
10
- React.createElement("span", { className: b('language') }, language)), editButton !== null && editButton !== void 0 ? editButton : null));
10
+ React.createElement(Text, { variant: "body-3" }, language)), editButton !== null && editButton !== void 0 ? editButton : null));
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  import { TextArea as TextAreaBase } from '@gravity-ui/uikit';
3
3
  export const TextArea = ({ name, input, spec }) => {
4
4
  const { value, onBlur, onChange, onFocus } = input;
5
- return (React.createElement(TextAreaBase, { value: value, onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name }));
5
+ return (React.createElement(TextAreaBase, { value: value || '', onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, maxRows: 20, minRows: 8, hasClear: true, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name }));
6
6
  };
@@ -25,7 +25,7 @@ export const TextContent = (_a) => {
25
25
  iconLib ? (React.createElement(Text, { color: (_b = spec.viewSpec.textContentParams) === null || _b === void 0 ? void 0 : _b.iconColor, className: b('icon') }, iconLib)) : null,
26
26
  content,
27
27
  input.value ? (React.createElement(React.Fragment, null,
28
- React.createElement("span", { className: b('separator') }, ":"),
28
+ React.createElement(Text, { className: b('separator') }, ":"),
29
29
  React.createElement(Text, { color: "secondary" }, input.value))) : null));
30
30
  }
31
31
  if (Layout) {
@@ -55,6 +55,7 @@
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;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { HelpPopover } from '@gravity-ui/components';
3
3
  import { TrashBin } from '@gravity-ui/icons';
4
- import { Button, Icon } from '@gravity-ui/uikit';
4
+ import { Button, Icon, Text } from '@gravity-ui/uikit';
5
5
  import { isArrayItem, isArraySpec, isObjectSpec, withGenerateButton, } from '../../../../core';
6
6
  import { ErrorWrapper, GenerateRandomValueButton } from '../../../components';
7
7
  import { block } from '../../../utils';
@@ -13,9 +13,9 @@ const RowBase = ({ name, spec, input, meta, verboseDescription, children, }) =>
13
13
  return (React.createElement("div", { className: b() },
14
14
  React.createElement("div", { className: b('left') },
15
15
  React.createElement("div", { className: b('left-inner') },
16
- React.createElement("span", { className: b('title', { required: spec.required }) }, spec.viewSpec.layoutTitle),
16
+ React.createElement(Text, { className: b('title', { required: spec.required }) }, spec.viewSpec.layoutTitle),
17
17
  !verboseDescription && spec.viewSpec.layoutDescription ? (React.createElement("span", { className: b('note') },
18
- React.createElement("span", { className: b('note-inner') },
18
+ React.createElement(Text, { className: b('note-inner') },
19
19
  React.createElement(HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })))) : null)),
20
20
  React.createElement("div", { className: b('right') },
21
21
  React.createElement("div", { className: b('right-inner') },
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import { HelpPopover } from '@gravity-ui/components';
4
- import { Popover } from '@gravity-ui/uikit';
4
+ import { Popover, Text } from '@gravity-ui/uikit';
5
5
  import { GroupIndent } from '../../';
6
6
  import { COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH, ErrorWrapper } from '../../../';
7
7
  import { isArraySpec, isObjectSpec, } from '../../../../core';
@@ -29,7 +29,7 @@ const SectionBase = (_a) => {
29
29
  } }));
30
30
  }
31
31
  else {
32
- description = (React.createElement("div", { className: b('note') },
32
+ description = (React.createElement(Text, { className: b('note') },
33
33
  React.createElement(HelpPopover, { htmlContent: spec.viewSpec.layoutDescription, placement: ['bottom', 'top'] })));
34
34
  }
35
35
  }