@gravity-ui/dynamic-forms 1.1.1 → 1.3.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 (101) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/build/cjs/lib/core/components/Form/Controller.js +10 -2
  3. package/build/cjs/lib/core/components/Form/DynamicField.js +23 -7
  4. package/build/cjs/lib/core/components/Form/hooks/index.js +7 -0
  5. package/build/cjs/lib/core/components/Form/hooks/useComponents.js +2 -2
  6. package/build/cjs/lib/core/components/Form/hooks/useControllerMirror.js +19 -0
  7. package/build/cjs/lib/core/components/Form/hooks/useCreateSearchContext.js +9 -0
  8. package/build/cjs/lib/core/components/Form/hooks/useDynamicFieldMirror.js +22 -0
  9. package/build/cjs/lib/core/components/Form/hooks/useField.js +7 -7
  10. package/build/cjs/lib/core/components/Form/hooks/useIntegrationFF.js +46 -0
  11. package/build/cjs/lib/core/components/Form/hooks/useSearch/index.js +4 -0
  12. package/build/cjs/lib/core/components/Form/hooks/useSearch/useSearch.css +9 -0
  13. package/build/cjs/lib/core/components/Form/hooks/useSearch/useSearch.js +22 -0
  14. package/build/cjs/lib/core/components/Form/hooks/useSearchContext.js +12 -0
  15. package/build/cjs/lib/core/components/Form/hooks/useSearchStore.js +41 -0
  16. package/build/cjs/lib/core/components/Form/hooks/useStore.js +6 -38
  17. package/build/cjs/lib/core/components/Form/hooks/useValidate.js +2 -2
  18. package/build/cjs/lib/core/components/Form/index.js +1 -1
  19. package/build/cjs/lib/core/components/Form/types/index.js +3 -0
  20. package/build/cjs/lib/core/components/Form/types/mirror.js +2 -0
  21. package/build/cjs/lib/core/components/Form/types/search.js +2 -0
  22. package/build/cjs/lib/core/components/Form/types/store.js +2 -0
  23. package/build/cjs/lib/core/components/Form/{helpers.js → utils/common.js} +2 -2
  24. package/build/cjs/lib/core/components/Form/utils/index.js +5 -0
  25. package/build/cjs/lib/core/components/Form/utils/search.js +19 -0
  26. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +10 -0
  27. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +20 -9
  28. package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +20 -0
  29. package/build/cjs/lib/kit/components/Inputs/TextLink/index.js +4 -0
  30. package/build/cjs/lib/kit/components/Inputs/index.js +1 -0
  31. package/build/cjs/lib/kit/components/Layouts/Row/Row.css +18 -10
  32. package/build/cjs/lib/kit/components/Layouts/Row/Row.js +4 -5
  33. package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +17 -0
  34. package/build/cjs/lib/kit/components/Views/TextLinkView/index.js +4 -0
  35. package/build/cjs/lib/kit/components/Views/index.js +1 -0
  36. package/build/cjs/lib/kit/constants/config.js +4 -0
  37. package/build/cjs/lib/kit/validators/validators.js +1 -2
  38. package/build/esm/lib/core/components/Form/Controller.js +11 -3
  39. package/build/esm/lib/core/components/Form/DynamicField.d.ts +3 -1
  40. package/build/esm/lib/core/components/Form/DynamicField.js +23 -7
  41. package/build/esm/lib/core/components/Form/hooks/index.d.ts +7 -0
  42. package/build/esm/lib/core/components/Form/hooks/index.js +7 -0
  43. package/build/esm/lib/core/components/Form/hooks/useComponents.js +1 -1
  44. package/build/esm/lib/core/components/Form/hooks/useControllerMirror.d.ts +2 -0
  45. package/build/esm/lib/core/components/Form/hooks/useControllerMirror.js +14 -0
  46. package/build/esm/lib/core/components/Form/hooks/useCreateSearchContext.d.ts +3 -0
  47. package/build/esm/lib/core/components/Form/hooks/useCreateSearchContext.js +4 -0
  48. package/build/esm/lib/core/components/Form/hooks/useDynamicFieldMirror.d.ts +2 -0
  49. package/build/esm/lib/core/components/Form/hooks/useDynamicFieldMirror.js +17 -0
  50. package/build/esm/lib/core/components/Form/hooks/useField.d.ts +2 -2
  51. package/build/esm/lib/core/components/Form/hooks/useField.js +2 -2
  52. package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.d.ts +2 -0
  53. package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.js +41 -0
  54. package/build/esm/lib/core/components/Form/hooks/useSearch/index.d.ts +1 -0
  55. package/build/esm/lib/core/components/Form/hooks/useSearch/index.js +1 -0
  56. package/build/esm/lib/core/components/Form/hooks/useSearch/useSearch.css +9 -0
  57. package/build/esm/lib/core/components/Form/hooks/useSearch/useSearch.d.ts +4 -0
  58. package/build/esm/lib/core/components/Form/hooks/useSearch/useSearch.js +18 -0
  59. package/build/esm/lib/core/components/Form/hooks/useSearchContext.d.ts +1 -0
  60. package/build/esm/lib/core/components/Form/hooks/useSearchContext.js +7 -0
  61. package/build/esm/lib/core/components/Form/hooks/useSearchStore.d.ts +6 -0
  62. package/build/esm/lib/core/components/Form/hooks/useSearchStore.js +36 -0
  63. package/build/esm/lib/core/components/Form/hooks/useStore.d.ts +2 -8
  64. package/build/esm/lib/core/components/Form/hooks/useStore.js +5 -37
  65. package/build/esm/lib/core/components/Form/hooks/useValidate.js +1 -1
  66. package/build/esm/lib/core/components/Form/index.d.ts +1 -1
  67. package/build/esm/lib/core/components/Form/index.js +1 -1
  68. package/build/esm/lib/core/components/Form/types/context.d.ts +2 -1
  69. package/build/esm/lib/core/components/Form/types/index.d.ts +3 -0
  70. package/build/esm/lib/core/components/Form/types/index.js +3 -0
  71. package/build/esm/lib/core/components/Form/types/mirror.d.ts +17 -0
  72. package/build/esm/lib/core/components/Form/types/mirror.js +1 -0
  73. package/build/esm/lib/core/components/Form/types/search.d.ts +8 -0
  74. package/build/esm/lib/core/components/Form/types/search.js +1 -0
  75. package/build/esm/lib/core/components/Form/types/store.d.ts +7 -0
  76. package/build/esm/lib/core/components/Form/types/store.js +1 -0
  77. package/build/esm/lib/core/components/Form/{helpers.d.ts → utils/common.d.ts} +1 -1
  78. package/build/esm/lib/core/components/Form/{helpers.js → utils/common.js} +2 -2
  79. package/build/esm/lib/core/components/Form/utils/index.d.ts +2 -0
  80. package/build/esm/lib/core/components/Form/utils/index.js +2 -0
  81. package/build/esm/lib/core/components/Form/utils/search.d.ts +3 -0
  82. package/build/esm/lib/core/components/Form/utils/search.js +14 -0
  83. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +10 -0
  84. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +20 -9
  85. package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.d.ts +2 -0
  86. package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +15 -0
  87. package/build/esm/lib/kit/components/Inputs/TextLink/index.d.ts +1 -0
  88. package/build/esm/lib/kit/components/Inputs/TextLink/index.js +1 -0
  89. package/build/esm/lib/kit/components/Inputs/index.d.ts +1 -0
  90. package/build/esm/lib/kit/components/Inputs/index.js +1 -0
  91. package/build/esm/lib/kit/components/Layouts/Row/Row.css +18 -10
  92. package/build/esm/lib/kit/components/Layouts/Row/Row.js +4 -5
  93. package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.d.ts +2 -0
  94. package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +12 -0
  95. package/build/esm/lib/kit/components/Views/TextLinkView/index.d.ts +1 -0
  96. package/build/esm/lib/kit/components/Views/TextLinkView/index.js +1 -0
  97. package/build/esm/lib/kit/components/Views/index.d.ts +1 -0
  98. package/build/esm/lib/kit/components/Views/index.js +1 -0
  99. package/build/esm/lib/kit/constants/config.js +5 -1
  100. package/build/esm/lib/kit/validators/validators.js +1 -2
  101. package/package.json +12 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.2.0...v1.3.0) (2023-03-31)
4
+
5
+
6
+ ### Features
7
+
8
+ * update row note position ([#20](https://github.com/gravity-ui/dynamic-forms/issues/20)) ([4f15395](https://github.com/gravity-ui/dynamic-forms/commit/4f153959596d3325ddeb2c2e9b24382e36d2db75))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add fixes + tests ([#15](https://github.com/gravity-ui/dynamic-forms/issues/15)) ([80113dd](https://github.com/gravity-ui/dynamic-forms/commit/80113dd05737b18158865506ed3ac8479d69e8d0))
14
+ * **search:** fixed bug related to form blinking ([#21](https://github.com/gravity-ui/dynamic-forms/issues/21)) ([20bab2f](https://github.com/gravity-ui/dynamic-forms/commit/20bab2f628d698714bcee35993583f2c7712e843))
15
+ * **textArea:** fixed row for text area ([#22](https://github.com/gravity-ui/dynamic-forms/issues/22)) ([d5469e7](https://github.com/gravity-ui/dynamic-forms/commit/d5469e7dd0eee86b26e8daba94e93d2fa9465b96))
16
+
17
+ ## [1.2.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.1.1...v1.2.0) (2023-03-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * search ([#10](https://github.com/gravity-ui/dynamic-forms/issues/10)) ([4ed7d5c](https://github.com/gravity-ui/dynamic-forms/commit/4ed7d5c85dbb890f4c8148d4de43a626917cec0f))
23
+
3
24
  ## [1.1.1](https://github.com/gravity-ui/dynamic-forms/compare/v1.1.0...v1.1.1) (2023-03-21)
4
25
 
5
26
 
@@ -6,7 +6,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
6
  const helpers_1 = require("../../helpers");
7
7
  const hooks_1 = require("./hooks");
8
8
  const Controller = ({ spec, name, initialValue, parentOnChange, parentOnUnmount, }) => {
9
- const { tools } = (0, hooks_1.useDynamicFormsCtx)();
9
+ const { tools, __mirror } = (0, hooks_1.useDynamicFormsCtx)();
10
10
  const { inputEntity, Layout } = (0, hooks_1.useComponents)(spec);
11
11
  const render = (0, hooks_1.useRender)({ name, spec, inputEntity, Layout });
12
12
  const validate = (0, hooks_1.useValidate)(spec);
@@ -19,8 +19,16 @@ const Controller = ({ spec, name, initialValue, parentOnChange, parentOnUnmount,
19
19
  parentOnChange,
20
20
  parentOnUnmount,
21
21
  });
22
+ const withSearch = (0, hooks_1.useSearch)(spec, renderProps.input.value, name);
23
+ (0, hooks_1.useControllerMirror)(name, {
24
+ useComponents: { inputEntity, Layout },
25
+ useRender: render,
26
+ useValidate: validate,
27
+ useField: renderProps,
28
+ useSearch: withSearch,
29
+ }, __mirror);
22
30
  if (lodash_1.default.isString(name) && (0, helpers_1.isCorrectSpec)(spec)) {
23
- return render(renderProps);
31
+ return withSearch(render(renderProps));
24
32
  }
25
33
  return null;
26
34
  };
@@ -7,21 +7,37 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const react_is_1 = require("react-is");
8
8
  const helpers_1 = require("../../helpers");
9
9
  const Controller_1 = require("./Controller");
10
- const helpers_2 = require("./helpers");
11
10
  const hooks_1 = require("./hooks");
12
- const DynamicField = ({ name, spec, config, Monaco }) => {
11
+ const utils_1 = require("./utils");
12
+ const DynamicField = ({ name, spec, config, Monaco, search, __mirror, }) => {
13
13
  const DynamicFormsCtx = (0, hooks_1.useCreateContext)();
14
- const { tools, watcher } = (0, hooks_1.useStore)(name);
14
+ const SearchContext = (0, hooks_1.useCreateSearchContext)();
15
+ const { tools, store } = (0, hooks_1.useStore)(name);
16
+ const watcher = (0, hooks_1.useIntegrationFF)(store);
17
+ const { store: searchStore, setField, removeField, isHiddenField } = (0, hooks_1.useSearchStore)();
15
18
  const context = react_1.default.useMemo(() => ({
16
19
  config,
17
20
  Monaco: (0, react_is_1.isValidElementType)(Monaco) ? Monaco : undefined,
18
21
  tools,
19
- }), [tools, config, Monaco]);
20
- const correctParams = react_1.default.useMemo(() => lodash_1.default.isString(name) && (0, helpers_1.isCorrectSpec)(spec) && (0, helpers_2.isCorrectConfig)(config), [name, spec, config]);
22
+ __mirror,
23
+ }), [tools, config, Monaco, __mirror]);
24
+ const searchContext = react_1.default.useMemo(() => ({
25
+ setField,
26
+ removeField,
27
+ isHiddenField,
28
+ searchFunction: lodash_1.default.isFunction(search) ? search : (0, utils_1.getDefaultSearchFunction)(search),
29
+ }), [isHiddenField, removeField, search, setField]);
30
+ const correctParams = react_1.default.useMemo(() => lodash_1.default.isString(name) && (0, helpers_1.isCorrectSpec)(spec) && (0, utils_1.isCorrectConfig)(config), [name, spec, config]);
31
+ (0, hooks_1.useDynamicFieldMirror)({
32
+ useStore: { tools, store },
33
+ useIntegrationFF: watcher,
34
+ useSearchStore: { store: searchStore, setField, removeField, isHiddenField },
35
+ }, __mirror);
21
36
  if (correctParams) {
22
37
  return (react_1.default.createElement(DynamicFormsCtx.Provider, { value: context },
23
- react_1.default.createElement(Controller_1.Controller, { spec: spec, name: name, parentOnChange: null, parentOnUnmount: null, initialValue: lodash_1.default.get(tools.initialValue, name) }),
24
- watcher));
38
+ react_1.default.createElement(SearchContext.Provider, { value: searchContext },
39
+ react_1.default.createElement(Controller_1.Controller, { spec: spec, name: name, parentOnChange: null, parentOnUnmount: null, initialValue: lodash_1.default.get(tools.initialValue, name) }),
40
+ watcher)));
25
41
  }
26
42
  return null;
27
43
  };
@@ -2,10 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./useComponents"), exports);
5
+ tslib_1.__exportStar(require("./useControllerMirror"), exports);
5
6
  tslib_1.__exportStar(require("./useCreateContext"), exports);
7
+ tslib_1.__exportStar(require("./useDynamicFieldMirror"), exports);
6
8
  tslib_1.__exportStar(require("./useDynamicFormsCtx"), exports);
7
9
  tslib_1.__exportStar(require("./useField"), exports);
10
+ tslib_1.__exportStar(require("./useIntegrationFF"), exports);
8
11
  tslib_1.__exportStar(require("./useRender"), exports);
9
12
  tslib_1.__exportStar(require("./useStore"), exports);
10
13
  tslib_1.__exportStar(require("./useValidate"), exports);
11
14
  tslib_1.__exportStar(require("./useMonaco"), exports);
15
+ tslib_1.__exportStar(require("./useSearchStore"), exports);
16
+ tslib_1.__exportStar(require("./useSearchContext"), exports);
17
+ tslib_1.__exportStar(require("./useSearch"), exports);
18
+ tslib_1.__exportStar(require("./useCreateSearchContext"), exports);
@@ -6,13 +6,13 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const react_is_1 = require("react-is");
8
8
  const helpers_1 = require("../../../helpers");
9
- const helpers_2 = require("../helpers");
9
+ const utils_1 = require("../utils");
10
10
  const _1 = require("./");
11
11
  const useComponents = (spec) => {
12
12
  var _a, _b;
13
13
  const { config } = (0, _1.useDynamicFormsCtx)();
14
14
  const { inputs, layouts } = react_1.default.useMemo(() => {
15
- if ((0, helpers_2.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec)) {
15
+ if ((0, utils_1.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec)) {
16
16
  return config[spec.type];
17
17
  }
18
18
  return {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useControllerMirror = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const useControllerMirror = (name, params, __mirror) => {
7
+ if (__mirror === null || __mirror === void 0 ? void 0 : __mirror.controller) {
8
+ __mirror.controller[name] = params;
9
+ }
10
+ react_1.default.useEffect(() => {
11
+ return () => {
12
+ var _a;
13
+ if ((_a = __mirror === null || __mirror === void 0 ? void 0 : __mirror.controller) === null || _a === void 0 ? void 0 : _a[name]) {
14
+ delete __mirror.controller[name];
15
+ }
16
+ };
17
+ }, []);
18
+ };
19
+ exports.useControllerMirror = useControllerMirror;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCreateSearchContext = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const createContext = lodash_1.default.once(() => react_1.default.createContext({}));
8
+ const useCreateSearchContext = () => createContext();
9
+ exports.useCreateSearchContext = useCreateSearchContext;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDynamicFieldMirror = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const useDynamicFieldMirror = (params, __mirror) => {
7
+ if (__mirror === null || __mirror === void 0 ? void 0 : __mirror.field) {
8
+ __mirror.field.useStore = params.useStore;
9
+ __mirror.field.useIntegrationFF = params.useIntegrationFF;
10
+ __mirror.field.useSearchStore = params.useSearchStore;
11
+ }
12
+ react_1.default.useEffect(() => {
13
+ return () => {
14
+ if (__mirror === null || __mirror === void 0 ? void 0 : __mirror.field) {
15
+ delete __mirror.field.useStore;
16
+ delete __mirror.field.useIntegrationFF;
17
+ delete __mirror.field.useSearchStore;
18
+ }
19
+ };
20
+ }, []);
21
+ };
22
+ exports.useDynamicFieldMirror = useDynamicFieldMirror;
@@ -6,20 +6,20 @@ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const helpers_1 = require("../../../helpers");
8
8
  const constants_1 = require("../constants");
9
- const helpers_2 = require("../helpers");
9
+ const utils_1 = require("../utils");
10
10
  const useField = ({ name, spec, initialValue, validate: propsValidate, tools, parentOnChange, parentOnUnmount, }) => {
11
11
  const firstRenderRef = react_1.default.useRef(true);
12
12
  const validate = react_1.default.useCallback((value) => {
13
13
  if (value === constants_1.REMOVED_ITEM) {
14
14
  return;
15
15
  }
16
- return propsValidate === null || propsValidate === void 0 ? void 0 : propsValidate((0, helpers_2.transformArrOut)(value));
16
+ return propsValidate === null || propsValidate === void 0 ? void 0 : propsValidate((0, utils_1.transformArrOut)(value));
17
17
  }, [propsValidate]);
18
18
  const [state, setState] = react_1.default.useState(() => {
19
19
  let value = lodash_1.default.cloneDeep(initialValue);
20
20
  if (lodash_1.default.isNil(value)) {
21
21
  if (spec.defaultValue) {
22
- value = (0, helpers_2.transformArrIn)(spec.defaultValue);
22
+ value = (0, utils_1.transformArrIn)(spec.defaultValue);
23
23
  }
24
24
  // if the spec with type array or object, and this spec has "required === true",
25
25
  // we immediately exclude empty value
@@ -52,7 +52,7 @@ const useField = ({ name, spec, initialValue, validate: propsValidate, tools, pa
52
52
  setState((state) => {
53
53
  const _value = lodash_1.default.isFunction(valOrSetter) ? valOrSetter(state.value) : valOrSetter;
54
54
  const error = validate === null || validate === void 0 ? void 0 : validate(_value);
55
- const value = (0, helpers_2.transformArrIn)(_value);
55
+ const value = (0, utils_1.transformArrIn)(_value);
56
56
  let newChildErrors = Object.assign({}, state.childErrors);
57
57
  if (childErrors) {
58
58
  const nearestChildName = lodash_1.default.keys(childErrors).sort((a, b) => a.length - b.length)[0];
@@ -65,7 +65,7 @@ const useField = ({ name, spec, initialValue, validate: propsValidate, tools, pa
65
65
  });
66
66
  };
67
67
  const onDrop = () => {
68
- if ((0, helpers_2.isArrayItem)(name)) {
68
+ if ((0, utils_1.isArrayItem)(name)) {
69
69
  onChange(constants_1.REMOVED_ITEM);
70
70
  }
71
71
  else {
@@ -86,7 +86,7 @@ const useField = ({ name, spec, initialValue, validate: propsValidate, tools, pa
86
86
  [constants_1.OBJECT_ARRAY_FLAG]: true,
87
87
  [constants_1.OBJECT_ARRAY_CNT]: 0,
88
88
  });
89
- const value = Object.assign(Object.assign({}, stateValue), { [`<${stateValue[constants_1.OBJECT_ARRAY_CNT]}>`]: (0, helpers_2.transformArrIn)(_value), [constants_1.OBJECT_ARRAY_CNT]: stateValue[constants_1.OBJECT_ARRAY_CNT] + 1 });
89
+ const value = Object.assign(Object.assign({}, stateValue), { [`<${stateValue[constants_1.OBJECT_ARRAY_CNT]}>`]: (0, utils_1.transformArrIn)(_value), [constants_1.OBJECT_ARRAY_CNT]: stateValue[constants_1.OBJECT_ARRAY_CNT] + 1 });
90
90
  const error = validate === null || validate === void 0 ? void 0 : validate(value);
91
91
  setState((state) => (Object.assign(Object.assign({}, state), { dirty: !lodash_1.default.isEqual(value, initialValue), error, invalid: Boolean(error), modified: true, pristine: value === initialValue, touched: true, valid: !error, value, visited: true })));
92
92
  };
@@ -126,7 +126,7 @@ const useField = ({ name, spec, initialValue, validate: propsValidate, tools, pa
126
126
  onDrop,
127
127
  ]);
128
128
  react_1.default.useEffect(() => {
129
- if (!firstRenderRef.current || !lodash_1.default.isEqual(initialValue, state.value)) {
129
+ if (!firstRenderRef.current || !lodash_1.default.isEqual(initialValue, state.value) || state.error) {
130
130
  (parentOnChange ? parentOnChange : tools.onChange)(name, state.value, Object.assign(Object.assign({}, state.childErrors), { [name]: state.error }));
131
131
  }
132
132
  }, [state.value]);
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIntegrationFF = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
8
+ const react_final_form_1 = require("react-final-form");
9
+ const utils_1 = require("../utils");
10
+ const useIntegrationFF = (store) => {
11
+ const form = (0, react_final_form_1.useForm)();
12
+ const watcher = react_1.default.useMemo(() => {
13
+ const props = {
14
+ name: store.name,
15
+ render: () => null,
16
+ subscription: {},
17
+ validate: () => {
18
+ const asyncErrors = [];
19
+ let error;
20
+ lodash_1.default.values(store.errors).forEach((err) => {
21
+ if (err) {
22
+ if (lodash_1.default.isFunction(err === null || err === void 0 ? void 0 : err.then)) {
23
+ asyncErrors.push(err);
24
+ }
25
+ else {
26
+ error = err;
27
+ }
28
+ }
29
+ });
30
+ if (asyncErrors.length) {
31
+ return Promise.all(asyncErrors).then((r) => r[0]);
32
+ }
33
+ return error;
34
+ },
35
+ };
36
+ return react_1.default.createElement(react_final_form_1.Field, Object.assign({}, props));
37
+ }, [store.name, store.errors]);
38
+ const change = react_1.default.useCallback((0, debounce_1.default)((value) => {
39
+ form.change(store.name, lodash_1.default.get((0, utils_1.transformArrOut)(value), store.name));
40
+ }, 100), [form.change, store.name]);
41
+ react_1.default.useEffect(() => {
42
+ change(store.values);
43
+ }, [store.values]);
44
+ return watcher;
45
+ };
46
+ exports.useIntegrationFF = useIntegrationFF;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./useSearch"), exports);
@@ -0,0 +1,9 @@
1
+ .df-use-search {
2
+ margin-bottom: 15px;
3
+ }
4
+ .df-use-search_hidden {
5
+ display: none;
6
+ }
7
+ .df-use-search:last-child {
8
+ margin-bottom: 0;
9
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSearch = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const utils_1 = require("../../../../../kit/utils");
7
+ const useSearchContext_1 = require("../useSearchContext");
8
+ const b = (0, utils_1.block)('use-search');
9
+ const useSearch = (spec, value, name) => {
10
+ const { setField, removeField, isHiddenField, searchFunction } = (0, useSearchContext_1.useSearchContext)();
11
+ const searchResult = react_1.default.useMemo(() => !searchFunction(spec, value, name), [name, searchFunction, spec, value]);
12
+ const hidden = react_1.default.useMemo(() => isHiddenField(name), [isHiddenField, name]);
13
+ const withSearch = react_1.default.useCallback((children) => react_1.default.createElement("div", { className: b({ hidden: hidden }) }, children), [hidden]);
14
+ react_1.default.useEffect(() => {
15
+ setField(name, searchResult);
16
+ }, [searchResult]);
17
+ react_1.default.useEffect(() => {
18
+ return () => removeField(name);
19
+ }, []);
20
+ return withSearch;
21
+ };
22
+ exports.useSearch = useSearch;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSearchContext = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const index_1 = require("./index");
7
+ const useSearchContext = () => {
8
+ const SearchContext = (0, index_1.useCreateSearchContext)();
9
+ const context = react_1.default.useContext(SearchContext);
10
+ return context;
11
+ };
12
+ exports.useSearchContext = useSearchContext;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSearchStore = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const __1 = require("../");
8
+ const useSearchStore = () => {
9
+ const [store, setStore] = react_1.default.useState({});
10
+ const isHiddenField = react_1.default.useCallback((name) => {
11
+ const selfFlag = store[name];
12
+ if (selfFlag === false) {
13
+ return false;
14
+ }
15
+ let parentName = (0, __1.getParentName)(name);
16
+ while (parentName) {
17
+ if (store[parentName] === false) {
18
+ return false;
19
+ }
20
+ parentName = (0, __1.getParentName)(parentName);
21
+ }
22
+ for (const key of Object.keys(store)) {
23
+ if (key.includes(name + '.') && !store[key]) {
24
+ return false;
25
+ }
26
+ }
27
+ if (lodash_1.default.isUndefined(selfFlag)) {
28
+ return false;
29
+ }
30
+ return true;
31
+ }, [store]);
32
+ return {
33
+ store,
34
+ setField: (name, search) => setStore((store) => (Object.assign(Object.assign({}, store), { [name]: search }))),
35
+ removeField: (name) => {
36
+ setStore((store) => lodash_1.default.omit(store, name));
37
+ },
38
+ isHiddenField,
39
+ };
40
+ };
41
+ exports.useSearchStore = useSearchStore;
@@ -5,12 +5,12 @@ 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 react_final_form_1 = require("react-final-form");
8
- const helpers_1 = require("../helpers");
8
+ const utils_1 = require("../utils");
9
9
  const useStore = (name) => {
10
10
  const form = (0, react_final_form_1.useForm)();
11
11
  const firstRenderRef = react_1.default.useRef(true);
12
12
  const [store, setStore] = react_1.default.useState(() => {
13
- const initialValue = (0, helpers_1.transformArrIn)({
13
+ const initialValue = (0, utils_1.transformArrIn)({
14
14
  [name]: lodash_1.default.get(form.getState().values, name),
15
15
  });
16
16
  return {
@@ -21,47 +21,15 @@ const useStore = (name) => {
21
21
  };
22
22
  });
23
23
  const submitFailed = form.getState().submitFailed;
24
- const watcher = react_1.default.useMemo(() => {
25
- const props = {
26
- name: store.name,
27
- render: () => null,
28
- subscription: {},
29
- validate: () => {
30
- const asyncErrors = [];
31
- let error;
32
- lodash_1.default.values(store.errors).forEach((err) => {
33
- if (err) {
34
- if (lodash_1.default.isFunction(err === null || err === void 0 ? void 0 : err.then)) {
35
- asyncErrors.push(err);
36
- }
37
- else {
38
- error = err;
39
- }
40
- }
41
- });
42
- if (asyncErrors.length) {
43
- return Promise.all(asyncErrors).then((r) => r[0]);
44
- }
45
- return error;
46
- },
47
- };
48
- return react_1.default.createElement(react_final_form_1.Field, Object.assign({}, props));
49
- }, [store.name, store.errors]);
50
24
  const tools = react_1.default.useMemo(() => ({
51
25
  initialValue: store.initialValue,
52
- onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values: lodash_1.default.set(Object.assign({}, store.values), name, value), errors: errors || {} }))),
53
- onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { errors: lodash_1.default.omit(store.errors, Object.keys(store.errors).filter((key) => key.startsWith(name))) }))),
26
+ onChange: (name, value, errors) => setStore((store) => (Object.assign(Object.assign({}, store), { values: lodash_1.default.set(Object.assign({}, store.values), name, lodash_1.default.clone(value)), errors: errors || {} }))),
27
+ onUnmount: (name) => setStore((store) => (Object.assign(Object.assign({}, store), { values: lodash_1.default.omit(store.values, name), errors: lodash_1.default.omit(store.errors, Object.keys(store.errors).filter((key) => key.startsWith(name))) }))),
54
28
  submitFailed,
55
29
  }), [store.initialValue, setStore, submitFailed]);
56
- const change = react_1.default.useCallback(lodash_1.default.debounce((value) => {
57
- form.change(store.name, lodash_1.default.get((0, helpers_1.transformArrOut)(value), store.name));
58
- }, 100), [form.change, store.name]);
59
- react_1.default.useEffect(() => {
60
- change(store.values);
61
- }, [store.values]);
62
30
  react_1.default.useEffect(() => {
63
31
  if (!firstRenderRef.current) {
64
- const initialValue = (0, helpers_1.transformArrIn)({
32
+ const initialValue = (0, utils_1.transformArrIn)({
65
33
  [name]: lodash_1.default.get(form.getState().values, name),
66
34
  });
67
35
  setStore({
@@ -75,6 +43,6 @@ const useStore = (name) => {
75
43
  react_1.default.useEffect(() => {
76
44
  firstRenderRef.current = false;
77
45
  }, []);
78
- return { tools, watcher };
46
+ return { tools, store };
79
47
  };
80
48
  exports.useStore = useStore;
@@ -5,12 +5,12 @@ 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 helpers_1 = require("../../../helpers");
8
- const helpers_2 = require("../helpers");
8
+ const utils_1 = require("../utils");
9
9
  const _1 = require("./");
10
10
  const useValidate = (spec) => {
11
11
  const { config } = (0, _1.useDynamicFormsCtx)();
12
12
  const { validators } = react_1.default.useMemo(() => {
13
- if ((0, helpers_2.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec)) {
13
+ if ((0, utils_1.isCorrectConfig)(config) && (0, helpers_1.isCorrectSpec)(spec)) {
14
14
  return config[spec.type];
15
15
  }
16
16
  return {};
@@ -4,5 +4,5 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./constants"), exports);
5
5
  tslib_1.__exportStar(require("./Controller"), exports);
6
6
  tslib_1.__exportStar(require("./DynamicField"), exports);
7
- tslib_1.__exportStar(require("./helpers"), exports);
8
7
  tslib_1.__exportStar(require("./types"), exports);
8
+ tslib_1.__exportStar(require("./utils"), exports);
@@ -8,8 +8,11 @@ tslib_1.__exportStar(require("./context"), exports);
8
8
  tslib_1.__exportStar(require("./field"), exports);
9
9
  tslib_1.__exportStar(require("./input"), exports);
10
10
  tslib_1.__exportStar(require("./layout"), exports);
11
+ tslib_1.__exportStar(require("./mirror"), exports);
11
12
  tslib_1.__exportStar(require("./number"), exports);
12
13
  tslib_1.__exportStar(require("./object"), exports);
14
+ tslib_1.__exportStar(require("./store"), exports);
13
15
  tslib_1.__exportStar(require("./string"), exports);
14
16
  tslib_1.__exportStar(require("./validators"), exports);
15
17
  tslib_1.__exportStar(require("./value"), exports);
18
+ tslib_1.__exportStar(require("./search"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isArrayItem = exports.transformArrOut = exports.transformArrIn = exports.isCorrectConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
- const constants_1 = require("../../constants");
7
- const constants_2 = require("./constants");
6
+ const constants_1 = require("../../../constants");
7
+ const constants_2 = require("../constants");
8
8
  const isCorrectConfig = (candidate) => Object.values(constants_1.SpecTypes).every((type) => lodash_1.default.isObjectLike(candidate) &&
9
9
  lodash_1.default.isObjectLike(candidate[type]) &&
10
10
  lodash_1.default.isObjectLike(candidate[type].inputs) &&
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./common"), exports);
5
+ tslib_1.__exportStar(require("./search"), exports);
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultSearchFunction = exports.getParentName = void 0;
4
+ const getParentName = (name) => {
5
+ const index = name.lastIndexOf('.');
6
+ if (index !== -1) {
7
+ return name.substring(0, index);
8
+ }
9
+ return undefined;
10
+ };
11
+ exports.getParentName = getParentName;
12
+ const getDefaultSearchFunction = (search) => (spec) => {
13
+ var _a;
14
+ if (search) {
15
+ return Boolean((_a = spec.viewSpec.layoutTitle) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search.trim().toLowerCase()));
16
+ }
17
+ return true;
18
+ };
19
+ exports.getDefaultSearchFunction = getDefaultSearchFunction;
@@ -1,6 +1,16 @@
1
1
  .df-table-array__table {
2
2
  margin-bottom: 10px;
3
3
  }
4
+ .df-table-array__table .yc-table__cell {
5
+ border-bottom: 0px transparent;
6
+ }
7
+ .df-table-array__row .yc-table__cell {
8
+ border-bottom: 0px transparent;
9
+ border-top: 1px solid var(--yc-color-line-generic);
10
+ }
11
+ .df-table-array__row_hidden {
12
+ display: none;
13
+ }
4
14
  .df-table-array__cell .yc-text-input,
5
15
  .df-table-array__cell .yc-select-control,
6
16
  .df-table-array__cell .yc-select,