@gravity-ui/dynamic-forms 3.7.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/build/cjs/lib/core/components/Form/Controller/Controller.js +2 -2
  2. package/build/cjs/lib/core/components/Form/Controller/utils.js +45 -34
  3. package/build/cjs/lib/core/components/Form/DynamicField.js +6 -4
  4. package/build/cjs/lib/core/components/Form/hooks/useCreateContext.js +2 -2
  5. package/build/cjs/lib/core/components/Form/hooks/useCreateSearchContext.js +2 -2
  6. package/build/cjs/lib/core/components/Form/hooks/useIntegrationFF.js +6 -4
  7. package/build/cjs/lib/core/components/Form/hooks/useMutators.js +11 -7
  8. package/build/cjs/lib/core/components/Form/hooks/useSearchStore.js +4 -3
  9. package/build/cjs/lib/core/components/Form/hooks/useStore.js +15 -11
  10. package/build/cjs/lib/core/components/Form/utils/common.js +14 -11
  11. package/build/cjs/lib/core/components/View/helpers.js +5 -5
  12. package/build/cjs/lib/core/components/View/hooks/useComponents.js +2 -2
  13. package/build/cjs/lib/core/components/View/hooks/useCreateContext.js +2 -2
  14. package/build/cjs/lib/core/components/View/hooks/useRender.js +4 -3
  15. package/build/cjs/lib/core/helpers.js +5 -4
  16. package/build/cjs/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
  17. package/build/cjs/lib/kit/components/Card/Card.css +3 -2
  18. package/build/cjs/lib/kit/components/Card/Card.js +2 -2
  19. package/build/cjs/lib/kit/components/CopyButton/CopyButton.js +1 -1
  20. package/build/cjs/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -1
  21. package/build/cjs/lib/kit/components/GenerateRandomValueButton/GenerateRandomValueButton.js +2 -2
  22. package/build/cjs/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
  23. package/build/cjs/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
  24. package/build/cjs/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +2 -2
  25. package/build/cjs/lib/kit/components/Inputs/MultiOneOf/MultiOneOf.js +4 -3
  26. package/build/cjs/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +4 -3
  27. package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +4 -3
  28. package/build/cjs/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
  29. package/build/cjs/lib/kit/components/Inputs/Secret/Secret.js +4 -3
  30. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +8 -2
  31. package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -3
  32. package/build/cjs/lib/kit/components/Inputs/Text/Text.js +2 -2
  33. package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.css +2 -2
  34. package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
  35. package/build/cjs/lib/kit/components/Inputs/TextLink/TextLink.js +4 -3
  36. package/build/cjs/lib/kit/components/Layouts/Row/Row.css +2 -2
  37. package/build/cjs/lib/kit/components/Layouts/Row/Row.js +2 -2
  38. package/build/cjs/lib/kit/components/Layouts/Section/Section.css +2 -2
  39. package/build/cjs/lib/kit/components/LazyLoader/LazyLoader.js +2 -2
  40. package/build/cjs/lib/kit/components/LongValue/LongValue.css +3 -0
  41. package/build/cjs/lib/kit/components/LongValue/LongValue.js +1 -1
  42. package/build/cjs/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +2 -2
  43. package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
  44. package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
  45. package/build/cjs/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
  46. package/build/cjs/lib/kit/components/Views/ArrayBaseView/ArrayBaseView.js +2 -2
  47. package/build/cjs/lib/kit/components/Views/BaseView/BaseView.js +2 -2
  48. package/build/cjs/lib/kit/components/Views/CardOneOfView.js +2 -2
  49. package/build/cjs/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
  50. package/build/cjs/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +2 -2
  51. package/build/cjs/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.js +2 -2
  52. package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +2 -2
  53. package/build/cjs/lib/kit/components/Views/OneOfView/OneOfView.js +2 -2
  54. package/build/cjs/lib/kit/components/Views/TextLinkView/TextLinkView.js +2 -2
  55. package/build/cjs/lib/kit/hooks/useOneOf/useOneOf.js +5 -4
  56. package/build/cjs/lib/kit/utils/common.js +30 -25
  57. package/build/cjs/lib/kit/validators/validators.js +9 -7
  58. package/build/esm/lib/core/components/Form/Controller/Controller.d.ts +1 -1
  59. package/build/esm/lib/core/components/Form/Controller/Controller.js +2 -2
  60. package/build/esm/lib/core/components/Form/Controller/types.d.ts +6 -6
  61. package/build/esm/lib/core/components/Form/Controller/utils.d.ts +10 -10
  62. package/build/esm/lib/core/components/Form/Controller/utils.js +45 -34
  63. package/build/esm/lib/core/components/Form/DynamicField.js +6 -4
  64. package/build/esm/lib/core/components/Form/hooks/useCreateContext.js +2 -2
  65. package/build/esm/lib/core/components/Form/hooks/useCreateSearchContext.js +2 -2
  66. package/build/esm/lib/core/components/Form/hooks/useGenerateRandomValue.d.ts +1 -1
  67. package/build/esm/lib/core/components/Form/hooks/useIntegrationFF.js +6 -4
  68. package/build/esm/lib/core/components/Form/hooks/useMutators.js +11 -7
  69. package/build/esm/lib/core/components/Form/hooks/useSearchStore.js +4 -3
  70. package/build/esm/lib/core/components/Form/hooks/useStore.js +15 -11
  71. package/build/esm/lib/core/components/Form/types/array.d.ts +12 -12
  72. package/build/esm/lib/core/components/Form/types/boolean.d.ts +12 -12
  73. package/build/esm/lib/core/components/Form/types/config.d.ts +1 -1
  74. package/build/esm/lib/core/components/Form/types/input.d.ts +13 -13
  75. package/build/esm/lib/core/components/Form/types/layout.d.ts +5 -5
  76. package/build/esm/lib/core/components/Form/types/number.d.ts +12 -12
  77. package/build/esm/lib/core/components/Form/types/object.d.ts +12 -12
  78. package/build/esm/lib/core/components/Form/types/string.d.ts +12 -12
  79. package/build/esm/lib/core/components/Form/utils/common.js +14 -11
  80. package/build/esm/lib/core/components/View/ViewController.d.ts +1 -1
  81. package/build/esm/lib/core/components/View/helpers.js +5 -5
  82. package/build/esm/lib/core/components/View/hooks/useComponents.d.ts +1 -1
  83. package/build/esm/lib/core/components/View/hooks/useComponents.js +2 -2
  84. package/build/esm/lib/core/components/View/hooks/useCreateContext.js +2 -2
  85. package/build/esm/lib/core/components/View/hooks/useRender.d.ts +1 -1
  86. package/build/esm/lib/core/components/View/hooks/useRender.js +4 -3
  87. package/build/esm/lib/core/helpers.d.ts +5 -5
  88. package/build/esm/lib/core/helpers.js +5 -4
  89. package/build/esm/lib/core/types/specs.d.ts +6 -6
  90. package/build/esm/lib/kit/components/AccordeonCard/AccordeonCard.js +2 -2
  91. package/build/esm/lib/kit/components/Card/Card.css +3 -2
  92. package/build/esm/lib/kit/components/Card/Card.js +2 -2
  93. package/build/esm/lib/kit/components/CopyButton/CopyButton.js +1 -1
  94. package/build/esm/lib/kit/components/ErrorWrapper/ErrorWrapper.css +4 -1
  95. package/build/esm/lib/kit/components/GenerateRandomValueButton/GenerateRandomValueButton.js +2 -2
  96. package/build/esm/lib/kit/components/Inputs/ArrayBase/ArrayBase.js +2 -2
  97. package/build/esm/lib/kit/components/Inputs/CardOneOf/CardOneOf.js +2 -2
  98. package/build/esm/lib/kit/components/Inputs/MonacoInput/MonacoInputDialog.css +2 -2
  99. package/build/esm/lib/kit/components/Inputs/MultiOneOf/MultiOneOf.js +4 -3
  100. package/build/esm/lib/kit/components/Inputs/ObjectBase/ObjectBase.js +4 -3
  101. package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +4 -3
  102. package/build/esm/lib/kit/components/Inputs/OneOf/OneOf.js +2 -2
  103. package/build/esm/lib/kit/components/Inputs/Secret/Secret.js +4 -3
  104. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.css +8 -2
  105. package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +4 -3
  106. package/build/esm/lib/kit/components/Inputs/Text/Text.js +2 -2
  107. package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.css +2 -2
  108. package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
  109. package/build/esm/lib/kit/components/Inputs/TextLink/TextLink.js +4 -3
  110. package/build/esm/lib/kit/components/Layouts/Accordeon/Accordeon.d.ts +1 -1
  111. package/build/esm/lib/kit/components/Layouts/AccordeonCard/AccordeonCardForm.d.ts +1 -1
  112. package/build/esm/lib/kit/components/Layouts/CardAccordeon.d.ts +1 -1
  113. package/build/esm/lib/kit/components/Layouts/CardSection.d.ts +1 -1
  114. package/build/esm/lib/kit/components/Layouts/Row/Row.css +2 -2
  115. package/build/esm/lib/kit/components/Layouts/Row/Row.d.ts +2 -2
  116. package/build/esm/lib/kit/components/Layouts/Row/Row.js +2 -2
  117. package/build/esm/lib/kit/components/Layouts/Section/Section.css +2 -2
  118. package/build/esm/lib/kit/components/Layouts/Section/Section.d.ts +6 -6
  119. package/build/esm/lib/kit/components/Layouts/TableCell/TableCell.d.ts +1 -1
  120. package/build/esm/lib/kit/components/Layouts/Transparent/Transparent.d.ts +1 -1
  121. package/build/esm/lib/kit/components/LazyLoader/LazyLoader.js +2 -2
  122. package/build/esm/lib/kit/components/LongValue/LongValue.css +3 -0
  123. package/build/esm/lib/kit/components/LongValue/LongValue.js +1 -1
  124. package/build/esm/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.css +2 -2
  125. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +2 -2
  126. package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeonCard/ViewAccordeonCard.js +2 -2
  127. package/build/esm/lib/kit/components/ViewLayouts/ViewCardAccordeon.js +2 -2
  128. package/build/esm/lib/kit/components/ViewLayouts/ViewCardSection.d.ts +1 -1
  129. package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.d.ts +1 -1
  130. package/build/esm/lib/kit/components/ViewLayouts/ViewSection/ViewSection.d.ts +4 -4
  131. package/build/esm/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.d.ts +1 -1
  132. package/build/esm/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.d.ts +1 -1
  133. package/build/esm/lib/kit/components/Views/ArrayBaseView/ArrayBaseView.js +2 -2
  134. package/build/esm/lib/kit/components/Views/BaseView/BaseView.js +2 -2
  135. package/build/esm/lib/kit/components/Views/CardOneOfView.js +2 -2
  136. package/build/esm/lib/kit/components/Views/MonacoInputView/MonacoViewDialog.css +1 -1
  137. package/build/esm/lib/kit/components/Views/MultiOneOfView/MultiOneOfView.js +2 -2
  138. package/build/esm/lib/kit/components/Views/ObjectBaseView/ObjectBaseView.js +2 -2
  139. package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +2 -2
  140. package/build/esm/lib/kit/components/Views/OneOfView/OneOfView.js +2 -2
  141. package/build/esm/lib/kit/components/Views/TextLinkView/TextLinkView.js +2 -2
  142. package/build/esm/lib/kit/hooks/useOneOf/useOneOf.d.ts +1 -1
  143. package/build/esm/lib/kit/hooks/useOneOf/useOneOf.js +5 -4
  144. package/build/esm/lib/kit/utils/common.d.ts +1 -1
  145. package/build/esm/lib/kit/utils/common.js +30 -25
  146. package/build/esm/lib/kit/utils/objectInline.d.ts +1 -1
  147. package/build/esm/lib/kit/validators/validators.js +9 -7
  148. package/package.json +11 -11
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import _ from 'lodash';
2
+ import isBoolean from 'lodash/isBoolean';
3
3
  import { Card } from '../';
4
4
  import { isNotEmptyValue } from '../../utils';
5
5
  export const ViewCardAccordeon = ({ name, value, spec, children, }) => {
6
- const [open, setOpen] = React.useState(_.isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true);
6
+ const [open, setOpen] = React.useState(isBoolean(spec.viewSpec.layoutOpen) ? spec.viewSpec.layoutOpen : true);
7
7
  const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
8
8
  if (!isNotEmptyValue(value, spec)) {
9
9
  return null;
@@ -1,2 +1,2 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../core';
2
- export declare const ViewCardSection: <T extends FormValue, S extends Spec>({ name, value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
2
+ export declare const ViewCardSection: <T extends FormValue, S extends Spec<any, undefined, undefined>>({ name, value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
@@ -1,3 +1,3 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../../core';
2
2
  import './ViewRow.css';
3
- export declare const ViewRow: <T extends FormValue, S extends Spec>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
3
+ export declare const ViewRow: <T extends FormValue, S extends Spec<any, undefined, undefined>>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
@@ -1,5 +1,5 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../../core';
2
- export declare const ViewSection: <T extends FormValue, S extends Spec>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
3
- export declare const ViewSection2: <T extends FormValue, S extends Spec>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
4
- export declare const ViewGroup: <T extends FormValue, S extends Spec>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
5
- export declare const ViewGroup2: <T extends FormValue, S extends Spec>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
2
+ export declare const ViewSection: <T extends FormValue, S extends Spec<any, undefined, undefined>>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
3
+ export declare const ViewSection2: <T extends FormValue, S extends Spec<any, undefined, undefined>>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
4
+ export declare const ViewGroup: <T extends FormValue, S extends Spec<any, undefined, undefined>>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
5
+ export declare const ViewGroup2: <T extends FormValue, S extends Spec<any, undefined, undefined>>(props: ViewLayoutProps<T, S>) => JSX.Element | null;
@@ -1,3 +1,3 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../../core';
2
2
  import './ViewTableCell.css';
3
- export declare const ViewTableCell: <T extends FormValue, S extends Spec>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element;
3
+ export declare const ViewTableCell: <T extends FormValue, S extends Spec<any, undefined, undefined>>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import { FormValue, Spec, ViewLayoutProps } from '../../../../core';
2
2
  import './ViewTransparent.css';
3
- export declare const ViewTransparent: <T extends FormValue, S extends Spec>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
3
+ export declare const ViewTransparent: <T extends FormValue, S extends Spec<any, undefined, undefined>>({ value, spec, children, }: ViewLayoutProps<T, S>) => JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Label } from '@gravity-ui/uikit';
3
- import _ from 'lodash';
3
+ import map from 'lodash/map';
4
4
  import { ViewController, isCorrectSpec } from '../../../../core';
5
5
  import { block } from '../../../utils';
6
6
  import './ArrayBaseView.css';
@@ -17,7 +17,7 @@ export const ArrayBaseView = ({ spec, name, value = [] }) => {
17
17
  : `${idx + 1}` });
18
18
  return itemSpec;
19
19
  }, [spec.items, itemSpecCorrect]);
20
- const items = React.useMemo(() => _.map(value, (__, idx) => {
20
+ const items = React.useMemo(() => map(value, (__, idx) => {
21
21
  const itemSpec = getItemSpec(idx);
22
22
  if (!itemSpec) {
23
23
  return null;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import _ from 'lodash';
2
+ import isString from 'lodash/isString';
3
3
  import { LongValue } from '../../../components';
4
4
  export const BaseView = ({ value, spec, linkValue, }) => {
5
5
  var _a;
6
- if (_.isString(value) && linkValue) {
6
+ if (isString(value) && linkValue) {
7
7
  return React.createElement(React.Fragment, null, linkValue);
8
8
  }
9
9
  return (React.createElement(LongValue, { value: ((_a = spec === null || spec === void 0 ? void 0 : spec.description) === null || _a === void 0 ? void 0 : _a[String(value)]) || String(value) }));
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
- import _ from 'lodash';
2
+ import isObjectLike from 'lodash/isObjectLike';
3
3
  import { Card, ViewRow } from '../';
4
4
  import { ViewController } from '../../../core';
5
5
  export const CardOneOfView = (props) => {
6
6
  const { value = {}, spec, name } = props;
7
7
  const [open, setOpen] = React.useState(true);
8
8
  const onToggle = React.useCallback(() => setOpen((f) => !f), [setOpen]);
9
- const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
9
+ const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
10
10
  const valueKey = React.useMemo(() => Object.keys(value)[0], [value]);
11
11
  const valueName = React.useMemo(() => {
12
12
  var _a, _b;
@@ -1,4 +1,4 @@
1
- .df-monaco-view-dialog .yc-dialog-footer {
1
+ .df-monaco-view-dialog .g-dialog-footer {
2
2
  padding: 10px 32px 32px;
3
3
  }
4
4
  .df-monaco-view-dialog__container {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Popover } from '@gravity-ui/uikit';
3
- import _ from 'lodash';
3
+ import isObjectLike from 'lodash/isObjectLike';
4
4
  import { ViewController } from '../../../../core';
5
5
  import { block } from '../../../utils';
6
6
  import { GroupIndent } from '../../GroupIndent';
@@ -8,7 +8,7 @@ import './MultiOneOfView.css';
8
8
  const b = block('multi-oneof-view');
9
9
  export const MultiOneOfView = (props) => {
10
10
  const { name, value, Layout, spec, withoutIndent } = props;
11
- const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
11
+ const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
12
12
  const values = React.useMemo(() => Object.keys(value || []), [value]);
13
13
  const items = React.useMemo(() => values.map((value) => {
14
14
  var _a, _b;
@@ -1,13 +1,13 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
- import _ from 'lodash';
3
+ import isObjectLike from 'lodash/isObjectLike';
4
4
  import { ViewController } from '../../../../core';
5
5
  import { block, filterPropertiesForObjectInline } from '../../../utils';
6
6
  import './ObjectBaseView.css';
7
7
  const b = block('object-base-view');
8
8
  export const ObjectBaseView = (_a) => {
9
9
  var { inline, spec, name, Layout } = _a, restProps = __rest(_a, ["inline", "spec", "name", "Layout"]);
10
- if (!spec.properties || !_.isObjectLike(spec.properties)) {
10
+ if (!spec.properties || !isObjectLike(spec.properties)) {
11
11
  return null;
12
12
  }
13
13
  const specProperties = inline
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
- import _ from 'lodash';
3
+ import cloneDeep from 'lodash/cloneDeep';
4
4
  import { ViewController } from '../../../../core';
5
5
  const OBJECT_VALUE_PROPERTY_NAME = 'value';
6
6
  export const ObjectValueInputView = (_a) => {
@@ -8,7 +8,7 @@ export const ObjectValueInputView = (_a) => {
8
8
  const childSpec = React.useMemo(() => {
9
9
  var _a;
10
10
  if ((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME]) {
11
- const childSpec = _.cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
11
+ const childSpec = cloneDeep(spec.properties[OBJECT_VALUE_PROPERTY_NAME]);
12
12
  childSpec.viewSpec.layout = '';
13
13
  return childSpec;
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import _ from 'lodash';
2
+ import isObjectLike from 'lodash/isObjectLike';
3
3
  import { GroupIndent } from '../../';
4
4
  import { ViewController } from '../../../../core';
5
5
  import { block } from '../../../utils';
@@ -7,7 +7,7 @@ import './OneOfView.css';
7
7
  const b = block('oneof-view');
8
8
  const OneOfViewComponent = (props) => {
9
9
  const { value = {}, spec, Layout, name } = props;
10
- const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
10
+ const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
11
11
  const valueKey = React.useMemo(() => Object.keys(value)[0], [value]);
12
12
  const valueName = React.useMemo(() => {
13
13
  var _a, _b;
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
- import _ from 'lodash';
3
+ import cloneDeep from 'lodash/cloneDeep';
4
4
  import { ViewController, isStringSpec } from '../../../../core';
5
5
  const TEXT_LINK_PROPERTY_NAME = 'text';
6
6
  export const TextLinkView = (_a) => {
@@ -9,7 +9,7 @@ export const TextLinkView = (_a) => {
9
9
  var _a;
10
10
  if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[TEXT_LINK_PROPERTY_NAME]) &&
11
11
  isStringSpec(spec.properties[TEXT_LINK_PROPERTY_NAME])) {
12
- const childSpec = _.cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
12
+ const childSpec = cloneDeep(spec.properties[TEXT_LINK_PROPERTY_NAME]);
13
13
  childSpec.viewSpec.layout = '';
14
14
  childSpec.viewSpec.link = value === null || value === void 0 ? void 0 : value.link;
15
15
  return childSpec;
@@ -6,7 +6,7 @@ export interface UseOneOfParams {
6
6
  }
7
7
  export declare const useOneOf: ({ props, onTogglerChange }: UseOneOfParams) => {
8
8
  oneOfValue: string;
9
- specProperties: Record<string, import("../../../core").Spec>;
9
+ specProperties: Record<string, import("../../../core").Spec<any, undefined, undefined>>;
10
10
  toggler: JSX.Element;
11
11
  togglerInput: JSX.Element;
12
12
  };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { RadioButton, Select } from '@gravity-ui/uikit';
3
- import _ from 'lodash';
3
+ import isObjectLike from 'lodash/isObjectLike';
4
+ import some from 'lodash/some';
4
5
  import { TogglerCard } from '../../components';
5
6
  import { block } from '../../utils';
6
7
  import './useOneOf.css';
@@ -9,10 +10,10 @@ const MAX_TAB_TITLE_LENGTH = 20;
9
10
  export const useOneOf = ({ props, onTogglerChange }) => {
10
11
  var _a;
11
12
  const { name, input, spec, Layout } = props;
12
- const specProperties = React.useMemo(() => (_.isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
13
+ const specProperties = React.useMemo(() => (isObjectLike(spec.properties) ? spec.properties : {}), [spec.properties]);
13
14
  const [oneOfValue, setOneOfValue] = React.useState(() => {
14
15
  let valueKeys;
15
- if (_.isObjectLike(input.value)) {
16
+ if (isObjectLike(input.value)) {
16
17
  const keys = Object.keys(input.value);
17
18
  if (keys.length) {
18
19
  valueKeys = keys;
@@ -47,7 +48,7 @@ export const useOneOf = ({ props, onTogglerChange }) => {
47
48
  if (((_b = spec.viewSpec.oneOfParams) === null || _b === void 0 ? void 0 : _b.toggler) !== 'radio' &&
48
49
  (((_c = spec.viewSpec.oneOfParams) === null || _c === void 0 ? void 0 : _c.toggler) === 'select' ||
49
50
  options.length > 3 ||
50
- _.some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
51
+ some(options, ({ title }) => title.length > MAX_TAB_TITLE_LENGTH))) {
51
52
  return 'select';
52
53
  }
53
54
  return 'radio';
@@ -1,4 +1,4 @@
1
1
  import { FormValue, Spec, StringSpec } from '../../core';
2
2
  export declare const isNotEmptyValue: (value: FormValue | undefined, spec: Spec | undefined) => boolean;
3
- export declare const prepareSpec: <Type extends Spec>(spec: Type, parseJsonDefaultValue?: boolean) => Type;
3
+ export declare const prepareSpec: <Type extends Spec<any, undefined, undefined>>(spec: Type, parseJsonDefaultValue?: boolean) => Type;
4
4
  export declare const isCorrectSizeParams: (spec: StringSpec) => boolean;
@@ -1,13 +1,18 @@
1
- import _ from 'lodash';
1
+ import cloneDeep from 'lodash/cloneDeep';
2
+ import isArray from 'lodash/isArray';
3
+ import isNil from 'lodash/isNil';
4
+ import isObject from 'lodash/isObject';
5
+ import isObjectLike from 'lodash/isObjectLike';
6
+ import isString from 'lodash/isString';
2
7
  import { SpecTypes, isArraySpec, isObjectSpec, isStringSpec, } from '../../core';
3
8
  import { isFloat } from '../validators/helpers';
4
9
  import { divide } from './bigIntMath';
5
10
  export const isNotEmptyValue = (value, spec) => {
6
11
  var _a;
7
- if (_.isNil(value)) {
12
+ if (isNil(value)) {
8
13
  return false;
9
14
  }
10
- if (_.isString(value)) {
15
+ if (isString(value)) {
11
16
  if (!value) {
12
17
  return false;
13
18
  }
@@ -15,7 +20,7 @@ export const isNotEmptyValue = (value, spec) => {
15
20
  return false;
16
21
  }
17
22
  }
18
- if (_.isObject(value) && isObjectSpec(spec)) {
23
+ if (isObject(value) && isObjectSpec(spec)) {
19
24
  const keys = Object.keys(value);
20
25
  // the only case when an empty object is considered a non-empty value is when it is a stub for oneof
21
26
  if (!keys.filter((key) => { var _a; return isNotEmptyValue(value[key], (_a = spec.properties) === null || _a === void 0 ? void 0 : _a[key]); }).length &&
@@ -23,7 +28,7 @@ export const isNotEmptyValue = (value, spec) => {
23
28
  return false;
24
29
  }
25
30
  }
26
- if (_.isArray(value) &&
31
+ if (isArray(value) &&
27
32
  isArraySpec(spec) &&
28
33
  !value.filter((item) => isNotEmptyValue(item, spec.items)).length) {
29
34
  return false;
@@ -32,12 +37,12 @@ export const isNotEmptyValue = (value, spec) => {
32
37
  };
33
38
  export const prepareSpec = (spec, parseJsonDefaultValue) => {
34
39
  var _a, _b, _c, _d, _e, _f, _g, _h;
35
- if (_.isObjectLike(spec)) {
36
- const result = _.cloneDeep(spec);
37
- if (_.isString(result.type)) {
40
+ if (isObjectLike(spec)) {
41
+ const result = cloneDeep(spec);
42
+ if (isString(result.type)) {
38
43
  result.type = result.type.toLowerCase();
39
44
  }
40
- if (!_.isNil(result.defaultValue)) {
45
+ if (!isNil(result.defaultValue)) {
41
46
  let _defaultValue = result.defaultValue;
42
47
  if (parseJsonDefaultValue) {
43
48
  try {
@@ -48,33 +53,33 @@ export const prepareSpec = (spec, parseJsonDefaultValue) => {
48
53
  }
49
54
  }
50
55
  if (typeof _defaultValue === result.type ||
51
- (_.isArray(_defaultValue) && result.type === SpecTypes.Array)) {
56
+ (isArray(_defaultValue) && result.type === SpecTypes.Array)) {
52
57
  result.defaultValue = _defaultValue;
53
58
  }
54
59
  else {
55
60
  result.defaultValue = undefined;
56
61
  }
57
62
  }
58
- if (_.isString((_a = result.viewSpec) === null || _a === void 0 ? void 0 : _a.type)) {
63
+ if (isString((_a = result.viewSpec) === null || _a === void 0 ? void 0 : _a.type)) {
59
64
  result.viewSpec.type = result.viewSpec.type.toLowerCase();
60
65
  }
61
- if (_.isString((_b = result.viewSpec) === null || _b === void 0 ? void 0 : _b.layout)) {
66
+ if (isString((_b = result.viewSpec) === null || _b === void 0 ? void 0 : _b.layout)) {
62
67
  result.viewSpec.layout = result.viewSpec.layout.toLowerCase();
63
68
  }
64
- if (_.isString((_c = result.viewSpec) === null || _c === void 0 ? void 0 : _c.addButtonPosition)) {
69
+ if (isString((_c = result.viewSpec) === null || _c === void 0 ? void 0 : _c.addButtonPosition)) {
65
70
  result.viewSpec.addButtonPosition = result.viewSpec.addButtonPosition.toLowerCase();
66
71
  }
67
- if (_.isString((_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.themeLabel)) {
72
+ if (isString((_d = result.viewSpec) === null || _d === void 0 ? void 0 : _d.themeLabel)) {
68
73
  result.viewSpec.textContentParams = Object.assign(Object.assign({}, result.viewSpec.textContentParams), { themeLabel: result.viewSpec.themeLabel.toLowerCase() });
69
74
  }
70
- if (_.isString((_f = (_e = result.viewSpec) === null || _e === void 0 ? void 0 : _e.oneOfParams) === null || _f === void 0 ? void 0 : _f.toggler)) {
75
+ if (isString((_f = (_e = result.viewSpec) === null || _e === void 0 ? void 0 : _e.oneOfParams) === null || _f === void 0 ? void 0 : _f.toggler)) {
71
76
  result.viewSpec.oneOfParams.toggler = result.viewSpec.oneOfParams.toggler.toLowerCase();
72
77
  }
73
- if (_.isString((_h = (_g = result.viewSpec) === null || _g === void 0 ? void 0 : _g.textContentParams) === null || _h === void 0 ? void 0 : _h.themeLabel)) {
78
+ if (isString((_h = (_g = result.viewSpec) === null || _g === void 0 ? void 0 : _g.textContentParams) === null || _h === void 0 ? void 0 : _h.themeLabel)) {
74
79
  result.viewSpec.textContentParams.themeLabel =
75
80
  result.viewSpec.textContentParams.themeLabel.toLowerCase();
76
81
  }
77
- if (_.isString(result.validator)) {
82
+ if (isString(result.validator)) {
78
83
  result.validator = result.validator.toLowerCase();
79
84
  }
80
85
  if (result.maxLength === '0' &&
@@ -83,10 +88,10 @@ export const prepareSpec = (spec, parseJsonDefaultValue) => {
83
88
  result.minLength = undefined;
84
89
  }
85
90
  else {
86
- if (!_.isNil(result.maxLength) && isFloat(`${result.maxLength}`)) {
91
+ if (!isNil(result.maxLength) && isFloat(`${result.maxLength}`)) {
87
92
  result.maxLength = BigInt(result.maxLength);
88
93
  }
89
- if (!_.isNil(result.minLength) && isFloat(`${result.minLength}`)) {
94
+ if (!isNil(result.minLength) && isFloat(`${result.minLength}`)) {
90
95
  result.minLength = BigInt(result.minLength);
91
96
  }
92
97
  }
@@ -98,17 +103,17 @@ export const prepareSpec = (spec, parseJsonDefaultValue) => {
98
103
  result.minimum = undefined;
99
104
  }
100
105
  else {
101
- if (!_.isNil(result.maximum) && isFloat(`${result.maximum}`)) {
106
+ if (!isNil(result.maximum) && isFloat(`${result.maximum}`)) {
102
107
  result.maximum = Number(result.maximum);
103
108
  }
104
- if (!_.isNil(result.minimum) && isFloat(`${result.minimum}`)) {
109
+ if (!isNil(result.minimum) && isFloat(`${result.minimum}`)) {
105
110
  result.minimum = Number(result.minimum);
106
111
  }
107
112
  }
108
- if (_.isString(result.format)) {
113
+ if (isString(result.format)) {
109
114
  result.format = result.format.toLowerCase();
110
115
  }
111
- if (_.isObjectLike(result.properties)) {
116
+ if (isObjectLike(result.properties)) {
112
117
  Object.keys(result.properties).forEach((key) => {
113
118
  result.properties[key] = prepareSpec(result.properties[key], parseJsonDefaultValue);
114
119
  });
@@ -120,8 +125,8 @@ export const prepareSpec = (spec, parseJsonDefaultValue) => {
120
125
  export const isCorrectSizeParams = (spec) => {
121
126
  const { sizeParams } = spec.viewSpec;
122
127
  if (!sizeParams ||
123
- !_.isString(sizeParams.defaultType) ||
124
- !_.isObject(sizeParams.scale) ||
128
+ !isString(sizeParams.defaultType) ||
129
+ !isObject(sizeParams.scale) ||
125
130
  !sizeParams.scale[sizeParams.defaultType] ||
126
131
  Object.values(sizeParams.scale).some(({ factor }) => !divide(factor, factor))) {
127
132
  return false;
@@ -1,4 +1,4 @@
1
1
  import { Spec } from '../../core';
2
2
  export declare const filterPropertiesForObjectInline: (properties: Record<string, Spec>) => {
3
- [k: string]: Spec;
3
+ [k: string]: Spec<any, undefined, undefined>;
4
4
  };
@@ -1,4 +1,6 @@
1
- import _ from 'lodash';
1
+ import isArray from 'lodash/isArray';
2
+ import isNumber from 'lodash/isNumber';
3
+ import isString from 'lodash/isString';
2
4
  import { ErrorMessages } from '../validators';
3
5
  import { isFloat, isInt } from './helpers';
4
6
  export const getArrayValidator = (params = {}) => {
@@ -6,7 +8,7 @@ export const getArrayValidator = (params = {}) => {
6
8
  return (spec, value) => {
7
9
  const errorMessages = Object.assign(Object.assign({}, ErrorMessages), customErrorMessages);
8
10
  const valueLength = (value === null || value === void 0 ? void 0 : value.length) || 0;
9
- if (!ignoreRequiredCheck && spec.required && !_.isArray(value)) {
11
+ if (!ignoreRequiredCheck && spec.required && !isArray(value)) {
10
12
  return errorMessages.REQUIRED;
11
13
  }
12
14
  if (!ignoreMaxLengthCheck &&
@@ -63,18 +65,18 @@ export const getNumberValidator = (params = {}) => {
63
65
  }
64
66
  }
65
67
  if (!ignoreMaximumCheck &&
66
- _.isNumber(spec.maximum) &&
68
+ isNumber(spec.maximum) &&
67
69
  stringValue.length &&
68
70
  Number(stringValue) > spec.maximum) {
69
71
  return errorMessages.maxNumber(spec.maximum);
70
72
  }
71
73
  if (!ignoreMinimumCheck &&
72
- _.isNumber(spec.minimum) &&
74
+ isNumber(spec.minimum) &&
73
75
  stringValue.length &&
74
76
  spec.minimum > Number(stringValue)) {
75
77
  return errorMessages.minNumber(spec.minimum);
76
78
  }
77
- if (_.isString(spec.format) && stringValue.length) {
79
+ if (isString(spec.format) && stringValue.length) {
78
80
  if (!ignoreIntCheck && spec.format === 'int64' && !isInt(stringValue)) {
79
81
  return errorMessages.INT;
80
82
  }
@@ -119,10 +121,10 @@ export const getStringValidator = (params = {}) => {
119
121
  valueLength < spec.minLength) {
120
122
  return errorMessages.minLength(spec.minLength);
121
123
  }
122
- if (_.isString(spec.pattern) && spec.pattern.length) {
124
+ if (isString(spec.pattern) && spec.pattern.length) {
123
125
  const regex = new RegExp(spec.pattern);
124
126
  if (!ignoreRegExpCheck && !regex.test(value)) {
125
- return _.isString(spec.patternError) && spec.patternError.length
127
+ return isString(spec.patternError) && spec.patternError.length
126
128
  ? spec.patternError
127
129
  : errorMessages.INVALID;
128
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "3.7.0",
3
+ "version": "4.0.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@bem-react/classname": "^1.6.0",
47
- "@gravity-ui/components": "^2.8.0",
48
- "@gravity-ui/i18n": "^1.1.0",
47
+ "@gravity-ui/components": "^3.0.0",
48
+ "@gravity-ui/i18n": "^1.2.0",
49
49
  "@gravity-ui/icons": "^2.8.1",
50
50
  "lodash": "^4.17.20"
51
51
  },
@@ -54,11 +54,11 @@
54
54
  "@babel/preset-typescript": "^7.18.6",
55
55
  "@commitlint/cli": "^17.0.0",
56
56
  "@commitlint/config-conventional": "^17.0.0",
57
- "@gravity-ui/eslint-config": "^2.2.0",
57
+ "@gravity-ui/eslint-config": "^3.1.1",
58
58
  "@gravity-ui/prettier-config": "^1.1.0",
59
- "@gravity-ui/stylelint-config": "^2.0.0",
59
+ "@gravity-ui/stylelint-config": "^4.0.1",
60
60
  "@gravity-ui/tsconfig": "^1.0.0",
61
- "@gravity-ui/uikit": "^5.19.1",
61
+ "@gravity-ui/uikit": "^6.0.0",
62
62
  "@playwright/experimental-ct-react": "^1.40.0",
63
63
  "@playwright/test": "^1.40.0",
64
64
  "@storybook/addon-essentials": "^7.0.27",
@@ -76,7 +76,7 @@
76
76
  "@types/uuid": "^9.0.4",
77
77
  "@vitejs/plugin-react": "^4.2.0",
78
78
  "css-loader": "^5.2.6",
79
- "eslint": "^8.27.0",
79
+ "eslint": "^8.49.0",
80
80
  "final-form": "^4.20.2",
81
81
  "gulp": "^4.0.2",
82
82
  "gulp-cli": "^2.3.0",
@@ -91,7 +91,7 @@
91
91
  "monaco-editor-webpack-plugin": "^6.0.0",
92
92
  "npm-run-all": "^4.1.5",
93
93
  "postcss": "^8.4.19",
94
- "prettier": "^2.7.1",
94
+ "prettier": "^3.0.3",
95
95
  "randexp": "^0.5.3",
96
96
  "react": "^18.2.0",
97
97
  "react-dom": "^18.2.0",
@@ -103,14 +103,14 @@
103
103
  "sass-loader": "^10.1.1",
104
104
  "storybook": "^7.0.27",
105
105
  "style-loader": "^2.0.0",
106
- "stylelint": "^14.15.0",
107
- "stylelint-scss": "^4.2.0",
106
+ "stylelint": "^15.10.3",
107
+ "stylelint-scss": "^5.1.0",
108
108
  "ts-jest": "^29.0.5",
109
109
  "typescript": "^4.9.5",
110
110
  "uuid": "^9.0.1"
111
111
  },
112
112
  "peerDependencies": {
113
- "@gravity-ui/uikit": "^5.0.0",
113
+ "@gravity-ui/uikit": "^6.0.0",
114
114
  "final-form": "^4.20.2",
115
115
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
116
116
  "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0",