@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
@@ -1,11 +1,5 @@
1
1
  .df-long-value {
2
2
  max-width: 100%;
3
- overflow: hidden;
4
- text-overflow: ellipsis;
5
- }
6
- .df-long-value_open {
7
- white-space: pre-wrap;
8
- word-wrap: break-word;
9
3
  }
10
4
  .df-long-value_long {
11
5
  cursor: pointer;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Text } from '@gravity-ui/uikit';
2
3
  import { block } from '../../utils';
3
4
  import './LongValue.css';
4
5
  const b = block('long-value');
@@ -8,6 +9,15 @@ export const LongValue = ({ value, className }) => {
8
9
  const [open, setOpen] = React.useState(false);
9
10
  const [long, setLong] = React.useState(false);
10
11
  const handleClick = React.useCallback(() => setOpen((f) => !f), [setOpen]);
12
+ const currentTextProperies = React.useMemo(() => {
13
+ let wordBreak;
14
+ let whiteSpace;
15
+ if (open) {
16
+ wordBreak = 'break-all';
17
+ whiteSpace = 'break-spaces';
18
+ }
19
+ return { wordBreak, whiteSpace };
20
+ }, [open]);
11
21
  React.useEffect(() => {
12
22
  if (ref.current) {
13
23
  if (value !== prevValue.current) {
@@ -29,5 +39,6 @@ export const LongValue = ({ value, className }) => {
29
39
  }
30
40
  }
31
41
  });
32
- return (React.createElement("div", { ref: ref, className: b({ open, long }, className), onClick: long ? handleClick : undefined }, value));
42
+ return (React.createElement("div", { ref: ref, onClick: long ? handleClick : undefined },
43
+ React.createElement(Text, Object.assign({ className: b({ long }, className), ellipsis: true }, currentTextProperies), value)));
33
44
  };
@@ -17,21 +17,6 @@
17
17
  margin-left: -13px;
18
18
  max-width: 533px;
19
19
  }
20
- .df-simple-vertical-accordeon__title {
21
- font-weight: 500;
22
- }
23
- .df-simple-vertical-accordeon__title_size_s {
24
- margin-bottom: 0;
25
- font-size: var(--g-text-body-1-font-size);
26
- }
27
- .df-simple-vertical-accordeon__title_size_m {
28
- margin-bottom: 1px;
29
- font-size: var(--g-text-body2-font-size);
30
- }
31
- .df-simple-vertical-accordeon__title_size_l {
32
- margin-bottom: 2px;
33
- font-size: var(--g-text-body3-font-size);
34
- }
35
20
  .df-simple-vertical-accordeon__tooltip {
36
21
  margin: 0px 5px;
37
22
  }
@@ -37,6 +37,7 @@ export declare class SimpleVerticalAccordeon extends React.Component<SimpleVerti
37
37
  checkVisibility: () => void;
38
38
  private handleClick;
39
39
  private getTitle;
40
+ private getCurrentTitleVariant;
40
41
  private getTooltip;
41
42
  }
42
43
  export {};
@@ -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, Icon, Popover } from '@gravity-ui/uikit';
4
+ import { Button, Icon, Popover, Text } from '@gravity-ui/uikit';
5
5
  import { COMMON_POPOVER_PLACEMENT } from '../../constants/common';
6
6
  import { block } from '../../utils';
7
7
  import './SimpleVerticalAccordeon.css';
@@ -49,7 +49,7 @@ export class SimpleVerticalAccordeon extends React.Component {
49
49
  }
50
50
  render() {
51
51
  var _a;
52
- const { titleSize, children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
52
+ const { children, headerActionsTemplate, className, contentClassName, buttonClassName, hideInsteadOfDestroy, withBranchView, viewLayout, name, } = this.props;
53
53
  const { open, hidden, isFirstRender } = this.state;
54
54
  const content = hideInsteadOfDestroy ? (React.createElement("div", { ref: this.componentRef, className: b('body', { hidden: !open }) }, children)) : (open && (React.createElement("div", { ref: this.componentRef, className: b('body', contentClassName) }, children)));
55
55
  if (viewLayout && !isFirstRender && hidden) {
@@ -57,11 +57,12 @@ export class SimpleVerticalAccordeon extends React.Component {
57
57
  }
58
58
  const title = this.getTitle();
59
59
  const titlePopoverDisabled = (((_a = this.titleRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) <= TITLE_TEXT_MAX_WIDTH;
60
+ const currentTitleVariant = this.getCurrentTitleVariant();
60
61
  return (Boolean(React.Children.count(children)) && (React.createElement("div", { className: b({ branch: withBranchView, view: viewLayout }, className) },
61
62
  React.createElement("div", { className: b('header') },
62
63
  React.createElement(Popover, { content: title, disabled: titlePopoverDisabled, placement: COMMON_POPOVER_PLACEMENT },
63
64
  React.createElement(Button, { view: "flat", className: b('header-inner', buttonClassName), onClick: this.handleClick, qa: `${name}-accordeon-toggler`, width: "auto" },
64
- React.createElement("b", { ref: this.titleRef, className: b('title', { size: titleSize }) }, title),
65
+ React.createElement(Text, { variant: currentTitleVariant }, title),
65
66
  React.createElement(Icon, { data: ChevronDown, className: b('chevron', { open }), size: 16 }))),
66
67
  this.getTooltip(),
67
68
  headerActionsTemplate ? headerActionsTemplate : null),
@@ -74,9 +75,19 @@ export class SimpleVerticalAccordeon extends React.Component {
74
75
  }
75
76
  return this.state.open ? openTitle : title;
76
77
  }
78
+ getCurrentTitleVariant() {
79
+ const { titleSize } = this.props;
80
+ if (titleSize === 'm') {
81
+ return 'body-2';
82
+ }
83
+ if (titleSize === 'l') {
84
+ return 'body-3';
85
+ }
86
+ return 'body-1';
87
+ }
77
88
  getTooltip() {
78
89
  const { note } = this.props;
79
- return note ? (React.createElement("span", { className: b('tooltip') },
90
+ return note ? (React.createElement(Text, { className: b('tooltip') },
80
91
  React.createElement(HelpPopover, { htmlContent: note, placement: ['bottom', 'top'] }))) : null;
81
92
  }
82
93
  }
@@ -14,12 +14,6 @@
14
14
  align-items: baseline;
15
15
  overflow: hidden;
16
16
  }
17
- .df-view-row__title {
18
- white-space: nowrap;
19
- overflow: hidden;
20
- text-overflow: ellipsis;
21
- color: var(--g-color-text-secondary);
22
- }
23
17
  .df-view-row__dots {
24
18
  min-width: 40px;
25
19
  flex-grow: 1;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Text } from '@gravity-ui/uikit';
2
3
  import { CopyButton } from '../../../../kit';
3
4
  import { block, isNotEmptyValue } from '../../../utils';
4
5
  import './ViewRow.css';
@@ -9,7 +10,7 @@ export const ViewRow = ({ value, spec, children, }) => {
9
10
  }
10
11
  return (React.createElement("div", { className: b() },
11
12
  React.createElement("div", { className: b('left') },
12
- React.createElement("div", { className: b('title'), title: spec.viewSpec.layoutTitle }, spec.viewSpec.layoutTitle),
13
+ React.createElement(Text, { whiteSpace: "nowrap", color: "secondary", ellipsis: true }, spec.viewSpec.layoutTitle),
13
14
  React.createElement("div", { className: b('dots') })),
14
15
  React.createElement("div", { className: b('right') }, children),
15
16
  React.createElement(CopyButton, { spec: spec, value: value })));
@@ -19,5 +19,5 @@ export const CardOneOfView = (props) => {
19
19
  if (!value || !Object.keys(value).length) {
20
20
  return null;
21
21
  }
22
- return (React.createElement(Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` })) : null));
22
+ return (React.createElement(Card, { name: name, title: title, open: open, onToggle: onToggle, disableHeaderToggle: true, checkEmptyBody: true }, specProperties[valueKey] ? (React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name ? name + '.' : ''}${valueKey}`, key: `${name ? name + '.' : ''}${valueKey}` })) : null));
23
23
  };
@@ -33,6 +33,6 @@ export const MultiOneOfView = (props) => {
33
33
  return (React.createElement(React.Fragment, null,
34
34
  selectView,
35
35
  React.createElement("div", { className: b('content', { flat: withoutIndent, 'multiple-values': items.length > 1 }) },
36
- React.createElement(GroupIndent, null, values.map((value) => (React.createElement(React.Fragment, { key: value }, specProperties && specProperties[value] ? (React.createElement(ViewController, { name: `${name}.${value}`, spec: specProperties[value] })) : null)))))));
36
+ React.createElement(GroupIndent, null, values.map((value) => (React.createElement(React.Fragment, { key: value }, specProperties && specProperties[value] ? (React.createElement(ViewController, { name: `${name ? name + '.' : ''}${value}`, spec: specProperties[value] })) : null)))))));
37
37
  };
38
38
  export const MultiOneOfFlatView = (props) => (React.createElement(MultiOneOfView, Object.assign({}, props, { withoutIndent: true })));
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Popover } from '@gravity-ui/uikit';
2
+ import { Popover, Text } from '@gravity-ui/uikit';
3
3
  import { block, isCorrectSizeParams } from '../../../utils';
4
4
  import { useInitial } from '../../Inputs/NumberWithScale/useInitial';
5
5
  import './NumberWithScaleView.css';
@@ -9,8 +9,6 @@ const NumberWithScaleViewBase = ({ spec, value }) => {
9
9
  const { scale } = spec.viewSpec.sizeParams;
10
10
  return (React.createElement("div", { className: b() },
11
11
  React.createElement(Popover, { placement: ['bottom', 'top'], content: initialValue, className: b('tooltip-container'), contentClassName: b('tooltip'), disabled: initialValue.length < 26 }, initialValue),
12
- React.createElement("span", { className: b('size') },
13
- " ",
14
- scale[initialType].title)));
12
+ React.createElement(Text, { className: b('size') }, scale[initialType].title)));
15
13
  };
16
14
  export const NumberWithScaleView = (props) => isCorrectSizeParams(props.spec) && props.value ? React.createElement(NumberWithScaleViewBase, Object.assign({}, props)) : null;
@@ -28,7 +28,7 @@ const OneOfViewComponent = (props) => {
28
28
  return (React.createElement("div", { className: b({ flat: props.withoutIndent }) },
29
29
  wrappedValue,
30
30
  specProperties[valueKey] ? (React.createElement(GroupIndent, null,
31
- React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name}.${valueKey}`, key: `${name}.${valueKey}` }))) : null));
31
+ React.createElement(ViewController, { spec: specProperties[valueKey], name: `${name ? name + '.' : ''}${valueKey}`, key: `${name ? name + '.' : ''}${valueKey}` }))) : null));
32
32
  };
33
33
  export const OneOfView = OneOfViewComponent;
34
34
  export const OneOfFlatView = (props) => (React.createElement(OneOfViewComponent, Object.assign({}, props, { withoutIndent: true })));
@@ -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
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ChevronDown } 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 './TextAreaView.css';
6
6
  const b = block('text-area-view');
@@ -11,7 +11,7 @@ export const TextAreaView = ({ value = '' }) => {
11
11
  setIsOpen(!isOpen);
12
12
  }, [isOpen]);
13
13
  return (React.createElement("div", { className: b({ active: isValueLong }), onClick: isValueLong ? handleClick : undefined },
14
- React.createElement("div", { className: b('text-view', { open: isOpen }) }, value),
14
+ React.createElement(Text, { ellipsis: true, whiteSpace: isOpen ? 'break-spaces' : undefined }, value),
15
15
  isValueLong ? (React.createElement("div", null,
16
16
  React.createElement(Icon, { data: ChevronDown, className: b('chevron', { open: isOpen }), size: 16 }))) : null));
17
17
  };
@@ -19,7 +19,7 @@ export const TextLinkView = (_a) => {
19
19
  if (!childSpec || !(value === null || value === void 0 ? void 0 : value.text)) {
20
20
  return null;
21
21
  }
22
- const content = React.createElement(ViewController, { spec: childSpec, name: `${name}.${TEXT_LINK_PROPERTY_NAME}` });
22
+ const content = (React.createElement(ViewController, { spec: childSpec, name: `${name ? name + '.' : ''}${TEXT_LINK_PROPERTY_NAME}` }));
23
23
  if (Layout) {
24
24
  return (React.createElement(Layout, Object.assign({ spec: spec, name: name, value: value }, restProps), content));
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",
@@ -38,8 +38,9 @@
38
38
  "playwright:install": "playwright install --with-deps",
39
39
  "playwright": "playwright test --config=playwright/playwright.config.ts",
40
40
  "playwright:update": "npm run playwright -- -u",
41
- "playwright:docker": "docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.39.0-jammy /bin/bash -c 'npm ci && npx playwright install && npm run playwright'",
42
- "playwright:docker:update": " docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.39.0-jammy /bin/bash -c 'npm ci && npx playwright install && npm run playwright:update'"
41
+ "playwright:docker": "./scripts/playwright-docker.sh 'npm run playwright'",
42
+ "playwright:docker:update": "./scripts/playwright-docker.sh 'npm run playwright:update'",
43
+ "playwright:docker:clear-cache": "./scripts/playwright-docker.sh clear-cache"
43
44
  },
44
45
  "dependencies": {
45
46
  "@bem-react/classname": "^1.6.0",