@gravity-ui/dynamic-forms 5.30.0 → 5.33.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 (124) hide show
  1. package/build/cjs/lib/unstable/core/constants.d.ts +1 -0
  2. package/build/cjs/lib/unstable/core/constants.js +1 -0
  3. package/build/cjs/lib/unstable/core/useSchemaRenderer/types/state.d.ts +1 -0
  4. package/build/cjs/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +17 -0
  5. package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +2 -0
  6. package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +6 -7
  7. package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.css +1 -0
  8. package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.d.ts +3 -1
  9. package/build/cjs/lib/unstable/kit/components/CopyButton/CopyButton.js +6 -2
  10. package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.css +3 -0
  11. package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.d.ts +10 -0
  12. package/build/cjs/lib/unstable/kit/components/DropButton/DropButton.js +32 -0
  13. package/build/cjs/lib/unstable/kit/components/DropButton/index.d.ts +1 -0
  14. package/build/cjs/lib/unstable/kit/components/DropButton/index.js +5 -0
  15. package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.css +1 -0
  16. package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.d.ts +1 -0
  17. package/build/cjs/lib/unstable/kit/components/EntityContainer/EntityContainer.js +2 -2
  18. package/build/cjs/lib/unstable/kit/components/LayoutButtons/LayoutButtons.d.ts +10 -0
  19. package/build/cjs/lib/unstable/kit/components/LayoutButtons/LayoutButtons.js +15 -0
  20. package/build/cjs/lib/unstable/kit/components/LayoutButtons/index.d.ts +1 -0
  21. package/build/cjs/lib/unstable/kit/components/LayoutButtons/index.js +5 -0
  22. package/build/cjs/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +30 -1
  23. package/build/cjs/lib/unstable/kit/components/index.d.ts +2 -0
  24. package/build/cjs/lib/unstable/kit/components/index.js +5 -1
  25. package/build/cjs/lib/unstable/kit/constants/config.d.ts +4 -2
  26. package/build/cjs/lib/unstable/kit/constants/config.js +4 -4
  27. package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.css +1 -1
  28. package/build/cjs/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +33 -4
  29. package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.css +13 -3
  30. package/build/cjs/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +47 -15
  31. package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.css +3 -0
  32. package/build/cjs/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.js +40 -5
  33. package/build/cjs/lib/unstable/kit/entities/ObjectInline/ObjectInline.js +1 -1
  34. package/build/cjs/lib/unstable/kit/entities/OneOfNested/OneOfNested.js +1 -1
  35. package/build/cjs/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +1 -1
  36. package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.css +3 -5
  37. package/build/cjs/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +1 -1
  38. package/build/cjs/lib/unstable/kit/form-entities/RangeInput/RangeInput.js +2 -2
  39. package/build/cjs/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +1 -0
  40. package/build/cjs/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +1 -1
  41. package/build/cjs/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +1 -1
  42. package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.css +3 -3
  43. package/build/cjs/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +6 -5
  44. package/build/cjs/lib/unstable/kit/form-layouts/FormRow/FormRow.js +2 -2
  45. package/build/cjs/lib/unstable/kit/hooks/index.d.ts +1 -0
  46. package/build/cjs/lib/unstable/kit/hooks/index.js +5 -0
  47. package/build/cjs/lib/unstable/kit/hooks/useExpanded.d.ts +11 -0
  48. package/build/cjs/lib/unstable/kit/hooks/useExpanded.js +25 -0
  49. package/build/cjs/lib/unstable/kit/index.d.ts +1 -0
  50. package/build/cjs/lib/unstable/kit/index.js +1 -0
  51. package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.css +2 -6
  52. package/build/cjs/lib/unstable/kit/layouts/Accordeon/Accordeon.js +6 -17
  53. package/build/cjs/lib/unstable/kit/layouts/Card/Card.css +0 -6
  54. package/build/cjs/lib/unstable/kit/layouts/Card/Card.js +12 -11
  55. package/build/cjs/lib/unstable/kit/layouts/Section/Section.css +0 -6
  56. package/build/cjs/lib/unstable/kit/layouts/Section/Section.js +2 -3
  57. package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.css +0 -6
  58. package/build/cjs/lib/unstable/kit/layouts/Transparent/Transparent.js +2 -3
  59. package/build/cjs/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +3 -3
  60. package/build/cjs/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +3 -3
  61. package/build/cjs/lib/unstable/kit/utils/transformer.js +18 -3
  62. package/build/esm/lib/unstable/core/constants.d.ts +1 -0
  63. package/build/esm/lib/unstable/core/constants.js +1 -0
  64. package/build/esm/lib/unstable/core/useSchemaRenderer/types/state.d.ts +1 -0
  65. package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +17 -0
  66. package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +2 -0
  67. package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +7 -8
  68. package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.css +1 -0
  69. package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.d.ts +3 -1
  70. package/build/esm/lib/unstable/kit/components/CopyButton/CopyButton.js +6 -2
  71. package/build/esm/lib/unstable/kit/components/DropButton/DropButton.css +3 -0
  72. package/build/esm/lib/unstable/kit/components/DropButton/DropButton.d.ts +11 -0
  73. package/build/esm/lib/unstable/kit/components/DropButton/DropButton.js +28 -0
  74. package/build/esm/lib/unstable/kit/components/DropButton/index.d.ts +1 -0
  75. package/build/esm/lib/unstable/kit/components/DropButton/index.js +1 -0
  76. package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.css +1 -0
  77. package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.d.ts +1 -0
  78. package/build/esm/lib/unstable/kit/components/EntityContainer/EntityContainer.js +2 -2
  79. package/build/esm/lib/unstable/kit/components/LayoutButtons/LayoutButtons.d.ts +10 -0
  80. package/build/esm/lib/unstable/kit/components/LayoutButtons/LayoutButtons.js +10 -0
  81. package/build/esm/lib/unstable/kit/components/LayoutButtons/index.d.ts +1 -0
  82. package/build/esm/lib/unstable/kit/components/LayoutButtons/index.js +1 -0
  83. package/build/esm/lib/unstable/kit/components/LayoutContainer/LayoutContainer.css +30 -1
  84. package/build/esm/lib/unstable/kit/components/index.d.ts +2 -0
  85. package/build/esm/lib/unstable/kit/components/index.js +2 -0
  86. package/build/esm/lib/unstable/kit/constants/config.d.ts +4 -2
  87. package/build/esm/lib/unstable/kit/constants/config.js +4 -4
  88. package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.css +1 -1
  89. package/build/esm/lib/unstable/kit/entities/ArrayEntity/ArrayEntity.js +33 -4
  90. package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.css +13 -3
  91. package/build/esm/lib/unstable/kit/entities/ArrayTable/ArrayTable.js +48 -16
  92. package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.css +3 -0
  93. package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.d.ts +1 -0
  94. package/build/esm/lib/unstable/kit/entities/ObjectEntity/ObjectEntity.js +42 -6
  95. package/build/esm/lib/unstable/kit/entities/ObjectInline/ObjectInline.js +1 -1
  96. package/build/esm/lib/unstable/kit/entities/OneOfNested/OneOfNested.js +1 -1
  97. package/build/esm/lib/unstable/kit/form-entities/NumberWithScaleInput/NumberWithScaleInput.js +1 -1
  98. package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.css +3 -5
  99. package/build/esm/lib/unstable/kit/form-entities/RadioGroupInput/RadioGroupInput.js +1 -1
  100. package/build/esm/lib/unstable/kit/form-entities/RangeInput/RangeInput.js +2 -2
  101. package/build/esm/lib/unstable/kit/form-entities/SegmentedRadioGroupInput/SegmentedRadioGroupInput.css +1 -0
  102. package/build/esm/lib/unstable/kit/form-entities/StringNumberWithScaleInput/StringNumberWithScaleInput.js +1 -1
  103. package/build/esm/lib/unstable/kit/form-entities/TextAreaInput/TextAreaInput.js +1 -1
  104. package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.css +3 -3
  105. package/build/esm/lib/unstable/kit/form-layouts/FormColumn/FormColumn.js +7 -6
  106. package/build/esm/lib/unstable/kit/form-layouts/FormRow/FormRow.js +3 -3
  107. package/build/esm/lib/unstable/kit/hooks/index.d.ts +1 -0
  108. package/build/esm/lib/unstable/kit/hooks/index.js +1 -0
  109. package/build/esm/lib/unstable/kit/hooks/useExpanded.d.ts +11 -0
  110. package/build/esm/lib/unstable/kit/hooks/useExpanded.js +20 -0
  111. package/build/esm/lib/unstable/kit/index.d.ts +1 -0
  112. package/build/esm/lib/unstable/kit/index.js +1 -0
  113. package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.css +2 -6
  114. package/build/esm/lib/unstable/kit/layouts/Accordeon/Accordeon.js +7 -18
  115. package/build/esm/lib/unstable/kit/layouts/Card/Card.css +0 -6
  116. package/build/esm/lib/unstable/kit/layouts/Card/Card.js +13 -12
  117. package/build/esm/lib/unstable/kit/layouts/Section/Section.css +0 -6
  118. package/build/esm/lib/unstable/kit/layouts/Section/Section.js +3 -4
  119. package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.css +0 -6
  120. package/build/esm/lib/unstable/kit/layouts/Transparent/Transparent.js +3 -4
  121. package/build/esm/lib/unstable/kit/overview-layouts/OverviewColumn/OverviewColumn.js +4 -4
  122. package/build/esm/lib/unstable/kit/overview-layouts/OverviewRow/OverviewRow.js +4 -4
  123. package/build/esm/lib/unstable/kit/utils/transformer.js +18 -3
  124. package/package.json +1 -1
@@ -11,6 +11,7 @@ export declare enum SchemaRendererEventType {
11
11
  Patch = "patch",
12
12
  Settings = "settings",
13
13
  Schema = "schema",
14
+ Submit = "submit",
14
15
  UserContext = "userContext"
15
16
  }
16
17
  export declare enum JsonSchemaType {
@@ -13,6 +13,7 @@ export var SchemaRendererEventType;
13
13
  SchemaRendererEventType["Patch"] = "patch";
14
14
  SchemaRendererEventType["Settings"] = "settings";
15
15
  SchemaRendererEventType["Schema"] = "schema";
16
+ SchemaRendererEventType["Submit"] = "submit";
16
17
  SchemaRendererEventType["UserContext"] = "userContext";
17
18
  })(SchemaRendererEventType || (SchemaRendererEventType = {}));
18
19
  export var JsonSchemaType;
@@ -21,6 +21,7 @@ export interface SchemaRendererState<UserContext extends Record<string, unknown>
21
21
  coerceInitialValues: boolean;
22
22
  jsonDefaultValues: boolean;
23
23
  };
24
+ submitCount: number;
24
25
  subscribe: (subscriber: SchemaRendererSubscriber) => string;
25
26
  subscribers: {
26
27
  byId: Record<string, SchemaRendererSubscriber>;
@@ -45,6 +45,7 @@ export const useSchemaRenderer = ({ coerceInitialValues = true, config, connectV
45
45
  runValidate,
46
46
  settings: { coerceInitialValues, jsonDefaultValues },
47
47
  schema: nameUpdated || schemaUpdated ? cloneDeep(originalSchema) : (prevState === null || prevState === void 0 ? void 0 : prevState.schema) || {},
48
+ submitCount: nameUpdated || schemaUpdated || !prevState ? 0 : prevState.submitCount,
48
49
  subscribe,
49
50
  subscribers: (prevState === null || prevState === void 0 ? void 0 : prevState.subscribers) || { byId: {}, byName: new Map(), byPath: new Map() },
50
51
  unsubscribe,
@@ -114,6 +115,22 @@ export const useSchemaRenderer = ({ coerceInitialValues = true, config, connectV
114
115
  initialState.dispatchEvent(initialEvents);
115
116
  }
116
117
  }, [initialEvents, initialState]);
118
+ React.useEffect(() => {
119
+ const originalSubmit = form.submit;
120
+ form.submit = () => {
121
+ var _a;
122
+ const srField = form.getFieldState(getServiceFieldName(SCHEMA_RENDERER_SERVICE_FIELD, headName));
123
+ const srState = (_a = srField === null || srField === void 0 ? void 0 : srField.data) === null || _a === void 0 ? void 0 : _a.state;
124
+ if (srState) {
125
+ srState.submitCount += 1;
126
+ srState.dispatchEvent([{ type: SchemaRendererEventType.Submit, all: true }]);
127
+ }
128
+ return originalSubmit.call(form);
129
+ };
130
+ return () => {
131
+ form.submit = originalSubmit;
132
+ };
133
+ }, [form]);
117
134
  React.useEffect(() => {
118
135
  const strictChecker = strictCheckerRef.current;
119
136
  return () => {
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
+ import { SchemaRendererMode } from '../../../core';
2
3
  export interface ArrayRemoveButtonProps {
4
+ mode: SchemaRendererMode;
3
5
  name: string;
4
6
  headName: string;
5
7
  onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
@@ -2,12 +2,14 @@ import React from 'react';
2
2
  import { TrashBin } from '@gravity-ui/icons';
3
3
  import { Button, Icon } from '@gravity-ui/uikit';
4
4
  import { useForm } from 'react-final-form';
5
- import { getArrayItemIndex, getArrayItemParentName, isArrayItem, isTupleItem } from '../../utils';
6
- export const ArrayRemoveButton = ({ name, headName, onClick }) => {
5
+ import { SchemaRendererMode } from '../../../core';
6
+ import { block, getArrayItemIndex, getArrayItemParentName, isArrayItem, isTupleItem, } from '../../utils';
7
+ const b = block('array-remove-button');
8
+ export const ArrayRemoveButton = ({ mode, name, headName, onClick, }) => {
7
9
  const form = useForm();
8
- const [ready, setReady] = React.useState(false);
9
10
  const arrayItem = isArrayItem(name);
10
11
  const tupleItem = isTupleItem(name, headName, form);
12
+ const overviewFlag = mode === SchemaRendererMode.Overview;
11
13
  const removeItem = React.useCallback((event) => {
12
14
  var _a;
13
15
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
@@ -20,11 +22,8 @@ export const ArrayRemoveButton = ({ name, headName, onClick }) => {
20
22
  form.blur(parentName);
21
23
  }
22
24
  }, [form, name, onClick]);
23
- React.useLayoutEffect(() => {
24
- setReady(true);
25
- }, []);
26
- if (ready && arrayItem && !tupleItem) {
27
- return (React.createElement(Button, { view: "flat-secondary", onClick: removeItem, qa: `${name}-remove-button` },
25
+ if (arrayItem && !tupleItem && !overviewFlag) {
26
+ return (React.createElement(Button, { className: b(), view: "flat-secondary", onClick: removeItem, qa: `${name}-remove-button` },
28
27
  React.createElement(Icon, { data: TrashBin, size: 16 })));
29
28
  }
30
29
  return null;
@@ -1,4 +1,5 @@
1
1
  .sr-copy-button {
2
+ display: none;
2
3
  width: 20px;
3
4
  height: 20px;
4
5
  margin-top: -1px;
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import { type JsonSchema, SchemaRendererMode } from '../../../core';
2
3
  import './CopyButton.css';
3
4
  export interface CopyButtonProps {
4
5
  className?: string;
5
- copy?: boolean;
6
+ mode: SchemaRendererMode;
7
+ schema: JsonSchema;
6
8
  value: unknown;
7
9
  }
8
10
  export declare const CopyButton: React.FC<CopyButtonProps>;
@@ -2,11 +2,15 @@ import React from 'react';
2
2
  import { ClipboardButton } from '@gravity-ui/uikit';
3
3
  import isNumber from 'lodash/isNumber';
4
4
  import isString from 'lodash/isString';
5
+ import { SchemaRendererMode } from '../../../core';
5
6
  import { block } from '../../utils';
6
7
  import './CopyButton.css';
7
8
  const b = block('copy-button');
8
- export const CopyButton = ({ className, copy, value }) => {
9
- if (copy && (isString(value) || isNumber(value))) {
9
+ export const CopyButton = ({ className, mode, schema, value }) => {
10
+ var _a;
11
+ const { copy } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
12
+ const overviewFlag = mode === SchemaRendererMode.Overview;
13
+ if (copy && (isString(value) || isNumber(value)) && overviewFlag) {
10
14
  return (React.createElement("div", { className: b(null, className) },
11
15
  React.createElement(ClipboardButton, { text: String(value), view: "flat", size: "s" })));
12
16
  }
@@ -0,0 +1,3 @@
1
+ .sr-drop-button {
2
+ display: none;
3
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { type FieldValue, type JsonSchema, SchemaRendererMode } from '../../../core';
3
+ import './DropButton.css';
4
+ export interface DropButtonProps {
5
+ mode: SchemaRendererMode;
6
+ name: string;
7
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
8
+ schema?: JsonSchema;
9
+ value: FieldValue;
10
+ }
11
+ export declare const DropButton: React.FC<DropButtonProps>;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { unstable_Menu as Menu, unstable_MenuItem as MenuItem, unstable_MenuTrigger as MenuTrigger, } from '@gravity-ui/uikit/unstable';
3
+ import { useForm } from 'react-final-form';
4
+ import i18n from '../../../../kit/i18n';
5
+ import { SchemaRendererMode } from '../../../core';
6
+ import { block, isArrayItem } from '../../utils';
7
+ import './DropButton.css';
8
+ const b = block('drop-button');
9
+ export const DropButton = ({ mode, name, onClick, schema, value }) => {
10
+ var _a;
11
+ const form = useForm();
12
+ const [open, setOpen] = React.useState(false);
13
+ const { required } = ((_a = schema === null || schema === void 0 ? void 0 : schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
14
+ const arrayItem = isArrayItem(name);
15
+ const overviewFlag = mode === SchemaRendererMode.Overview;
16
+ const removeItem = React.useCallback((event) => {
17
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
18
+ form.focus(name);
19
+ form.change(name, undefined);
20
+ form.blur(name);
21
+ }, [form, name, onClick]);
22
+ if (!required && value !== undefined && !arrayItem && !overviewFlag) {
23
+ return (React.createElement("div", { className: b({ open }) },
24
+ React.createElement(Menu, { trigger: React.createElement(MenuTrigger, { view: "flat-secondary" }), onOpenChange: setOpen, placement: "right" },
25
+ React.createElement(MenuItem, { theme: "danger", onClick: removeItem }, i18n('label_delete')))));
26
+ }
27
+ return null;
28
+ };
@@ -0,0 +1 @@
1
+ export { DropButton, type DropButtonProps } from './DropButton';
@@ -0,0 +1 @@
1
+ export { DropButton } from './DropButton';
@@ -13,6 +13,7 @@
13
13
  flex: 0 1 auto;
14
14
  }
15
15
  .sr-entity-container_stretch_by-child {
16
+ max-width: 100%;
16
17
  width: fit-content;
17
18
  flex: 0 0 auto;
18
19
  }
@@ -3,6 +3,7 @@ import { type FlexProps } from '@gravity-ui/uikit';
3
3
  import './EntityContainer.css';
4
4
  export interface EntityContainerProps extends FlexProps {
5
5
  children: React.ReactNode;
6
+ droppable?: boolean;
6
7
  fill?: 'populated' | 'empty' | 'by-child';
7
8
  ref?: React.ComponentPropsWithRef<'div'>['ref'];
8
9
  stretch: 'max' | 'fit' | 'by-child';
@@ -5,7 +5,7 @@ import { block } from '../../utils';
5
5
  import './EntityContainer.css';
6
6
  const b = block('entity-container');
7
7
  export const EntityContainer = (_a) => {
8
- var { children, fill, stretch } = _a, restFlexProps = __rest(_a, ["children", "fill", "stretch"]);
9
- return (React.createElement("div", { className: b({ stretch }), "data-stretch": stretch, "data-fill": fill },
8
+ var { children, droppable, fill, stretch } = _a, restFlexProps = __rest(_a, ["children", "droppable", "fill", "stretch"]);
9
+ return (React.createElement("div", { className: b({ stretch }), "data-fill": fill, "data-droppable": droppable, "data-stretch": stretch },
10
10
  React.createElement(Flex, Object.assign({ direction: "column", minWidth: 0 }, restFlexProps, { grow: 1 }), children)));
11
11
  };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { FieldValue, JsonSchema, SchemaRendererMode } from '../../../core';
3
+ export interface LayoutButtonsProps {
4
+ name: string;
5
+ headName: string;
6
+ mode: SchemaRendererMode;
7
+ schema: JsonSchema;
8
+ value: FieldValue;
9
+ }
10
+ export declare const LayoutButtons: React.FC<LayoutButtonsProps>;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ArrayRemoveButton } from '../ArrayRemoveButton';
3
+ import { CopyButton } from '../CopyButton';
4
+ import { DropButton } from '../DropButton';
5
+ export const LayoutButtons = ({ mode, name, headName, schema, value, }) => {
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(ArrayRemoveButton, { mode: mode, name: name, headName: headName }),
8
+ React.createElement(CopyButton, { mode: mode, schema: schema, value: value }),
9
+ React.createElement(DropButton, { mode: mode, name: name, schema: schema, value: value })));
10
+ };
@@ -0,0 +1 @@
1
+ export { LayoutButtons, type LayoutButtonsProps } from './LayoutButtons';
@@ -0,0 +1 @@
1
+ export { LayoutButtons } from './LayoutButtons';
@@ -1,6 +1,8 @@
1
1
  .sr-layout-container {
2
+ max-width: 100%;
3
+ min-width: 0;
2
4
  width: fit-content;
3
- flex: 0 0 auto;
5
+ flex: 0 1 auto;
4
6
  }
5
7
  .sr-layout-container:has([data-stretch=max]) {
6
8
  width: 100%;
@@ -11,4 +13,31 @@
11
13
  }
12
14
  .sr-layout-container_hidden {
13
15
  display: none;
16
+ }
17
+
18
+ @scope (.sr-layout-container) to (.sr-layout-container) {
19
+ :scope:has([data-droppable=true]:not(:scope .sr-layout-container *)) .sr-drop-button {
20
+ display: block;
21
+ }
22
+ :scope:has(.sr-drop-button:not(:scope .sr-layout-container *):hover),
23
+ :scope:has(.sr-drop-button_open:not(:scope .sr-layout-container *)),
24
+ :scope:has(.sr-array-remove-button:not(:scope .sr-layout-container *):hover) {
25
+ position: relative;
26
+ }
27
+ :scope:has(.sr-drop-button:not(:scope .sr-layout-container *):hover):before,
28
+ :scope:has(.sr-drop-button_open:not(:scope .sr-layout-container *)):before,
29
+ :scope:has(.sr-array-remove-button:not(:scope .sr-layout-container *):hover):before {
30
+ content: "";
31
+ z-index: -1;
32
+ position: absolute;
33
+ top: -8px;
34
+ left: -8px;
35
+ width: calc(100% + 16px);
36
+ height: calc(100% + 16px);
37
+ background-color: var(--g-color-base-simple-hover);
38
+ border-radius: 6px;
39
+ }
40
+ :scope:hover .sr-copy-button {
41
+ display: block;
42
+ }
14
43
  }
@@ -1,9 +1,11 @@
1
1
  export { ArrayRemoveButton, type ArrayRemoveButtonProps } from './ArrayRemoveButton';
2
2
  export { CopyButton, type CopyButtonProps } from './CopyButton';
3
+ export { DropButton, type DropButtonProps } from './DropButton';
3
4
  export { EmptyEntityValue } from './EmptyEntityValue';
4
5
  export { EntityContainer, type EntityContainerProps } from './EntityContainer';
5
6
  export { EntityError, type EntityErrorProps } from './EntityError';
6
7
  export { HTMLContent, type HTMLContentProps } from './HTMLContent';
7
8
  export { LayoutContainer, type LayoutContainerProps } from './LayoutContainer';
9
+ export { LayoutButtons, type LayoutButtonsProps } from './LayoutButtons';
8
10
  export { LongValue, type LongValueProps } from './LongValue';
9
11
  export { MonacoContainer, type MonacoContainerProps } from './MonacoContainer';
@@ -1,9 +1,11 @@
1
1
  export { ArrayRemoveButton } from './ArrayRemoveButton';
2
2
  export { CopyButton } from './CopyButton';
3
+ export { DropButton } from './DropButton';
3
4
  export { EmptyEntityValue } from './EmptyEntityValue';
4
5
  export { EntityContainer } from './EntityContainer';
5
6
  export { EntityError } from './EntityError';
6
7
  export { HTMLContent } from './HTMLContent';
7
8
  export { LayoutContainer } from './LayoutContainer';
9
+ export { LayoutButtons } from './LayoutButtons';
8
10
  export { LongValue } from './LongValue';
9
11
  export { MonacoContainer } from './MonacoContainer';
@@ -288,6 +288,7 @@ export declare const untypedConfig: {
288
288
  readonly formEntities: {
289
289
  readonly base: {
290
290
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaObject, import("../entities").ObjectEntityProps>;
291
+ readonly independent: true;
291
292
  };
292
293
  readonly dot_value: {
293
294
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaObject, import("../entities").DotValueProps>;
@@ -336,6 +337,7 @@ export declare const untypedConfig: {
336
337
  readonly overviewEntities: {
337
338
  readonly base: {
338
339
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaObject, import("../entities").ObjectEntityProps>;
340
+ readonly independent: true;
339
341
  };
340
342
  readonly dot_value: {
341
343
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaObject, import("../entities").DotValueProps>;
@@ -397,7 +399,7 @@ export declare const untypedConfig: {
397
399
  readonly color_picker: {
398
400
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaString, import("../form-entities").ColorPickerInputProps>;
399
401
  };
400
- readonly file: {
402
+ readonly file_input: {
401
403
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaString, import("../form-entities").FileInputProps>;
402
404
  };
403
405
  readonly label: {
@@ -461,7 +463,7 @@ export declare const untypedConfig: {
461
463
  readonly color_picker: {
462
464
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaString, import("../overview-entities").ColorPickerValueProps>;
463
465
  };
464
- readonly file: {
466
+ readonly file_input: {
465
467
  readonly Component: import("../../core").NodeEntity<import("../../core").JsonSchemaString, import("../overview-entities").StringValueProps>;
466
468
  };
467
469
  readonly label: {
@@ -128,7 +128,7 @@ export const untypedConfig = {
128
128
  },
129
129
  [NodeType.Object]: {
130
130
  formEntities: {
131
- base: { Component: ObjectEntity },
131
+ base: { Component: ObjectEntity, independent: true },
132
132
  dot_value: { Component: DotValue },
133
133
  few_of_nested: { Component: FewOfNested, independent: true },
134
134
  inline: { Component: ObjectInline },
@@ -146,7 +146,7 @@ export const untypedConfig = {
146
146
  transparent: { Component: Transparent },
147
147
  },
148
148
  overviewEntities: {
149
- base: { Component: ObjectEntity },
149
+ base: { Component: ObjectEntity, independent: true },
150
150
  dot_value: { Component: DotValue },
151
151
  few_of_nested: { Component: FewOfNested, independent: true },
152
152
  inline: { Component: ObjectInline },
@@ -170,7 +170,7 @@ export const untypedConfig = {
170
170
  alert: { Component: Alert },
171
171
  base: { Component: StringInput },
172
172
  color_picker: { Component: ColorPickerInput },
173
- file: { Component: FileInput },
173
+ file_input: { Component: FileInput },
174
174
  label: { Component: Label },
175
175
  monaco_input: { Component: Monaco },
176
176
  password: { Component: PasswordInput },
@@ -194,7 +194,7 @@ export const untypedConfig = {
194
194
  alert: { Component: Alert },
195
195
  base: { Component: StringValue },
196
196
  color_picker: { Component: ColorPickerValue },
197
- file: { Component: StringValue },
197
+ file_input: { Component: StringValue },
198
198
  label: { Component: Label },
199
199
  monaco_input: { Component: Monaco },
200
200
  password: { Component: StringValue },
@@ -1,3 +1,3 @@
1
- .sr-array-entity__add-button {
1
+ .sr-array-entity__add-button, .sr-array-entity__init-button {
2
2
  align-self: flex-start;
3
3
  }
@@ -9,8 +9,37 @@ const b = block('array-entity');
9
9
  export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath, }) => {
10
10
  var _a;
11
11
  const { name, onBlur, onChange, onFocus, value } = input;
12
- const { disabled } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
12
+ const { disabled, required } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
13
13
  const overviewFlag = mode === SchemaRendererMode.Overview;
14
+ const initButton = React.useMemo(() => {
15
+ if (required || value !== undefined || overviewFlag) {
16
+ return null;
17
+ }
18
+ const itemsSchema = schema.items;
19
+ const initValue = Array.isArray(itemsSchema)
20
+ ? itemsSchema.map(() => undefined)
21
+ : [undefined];
22
+ const onClick = () => {
23
+ onFocus();
24
+ onChange(initValue);
25
+ onBlur();
26
+ };
27
+ return (React.createElement(Button, { className: b('init-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-init-button` },
28
+ React.createElement(Icon, { data: Plus, size: 14 }),
29
+ props.addButtonText || null));
30
+ }, [
31
+ props.addButtonText,
32
+ disabled,
33
+ name,
34
+ onBlur,
35
+ onChange,
36
+ onFocus,
37
+ overviewFlag,
38
+ required,
39
+ schema.items,
40
+ schema.readOnly,
41
+ value,
42
+ ]);
14
43
  const addButton = React.useMemo(() => {
15
44
  const itemsSchema = schema.items;
16
45
  if (Array.isArray(itemsSchema) || overviewFlag) {
@@ -18,7 +47,7 @@ export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath,
18
47
  }
19
48
  const onClick = () => {
20
49
  onFocus();
21
- onChange([...(value || []), itemsSchema === null || itemsSchema === void 0 ? void 0 : itemsSchema.default]);
50
+ onChange([...(value || []), undefined]);
22
51
  onBlur();
23
52
  };
24
53
  return (React.createElement(Button, { className: b('add-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-add-button` },
@@ -49,7 +78,7 @@ export const ArrayEntity = ({ headName, input, mode, props, schema, schemaPath,
49
78
  if (overviewFlag && !(value === null || value === void 0 ? void 0 : value.length)) {
50
79
  return React.createElement(EmptyEntityValue, null);
51
80
  }
52
- return (React.createElement(EntityContainer, { stretch: "by-child", gap: 4, fill: "by-child" },
81
+ return (React.createElement(EntityContainer, { stretch: "by-child", gap: 4, fill: "by-child", droppable: true }, initButton ? (initButton) : (React.createElement(React.Fragment, null,
53
82
  (items === null || items === void 0 ? void 0 : items.length) ? React.createElement(Flex, { direction: "column" }, items) : null,
54
- addButton));
83
+ addButton))));
55
84
  };
@@ -1,11 +1,21 @@
1
+ .sr-array-table__row-divider {
2
+ width: 100%;
3
+ height: calc(var(--g-spacing-base) * 5 + 1px);
4
+ display: flex;
5
+ align-items: center;
6
+ }
7
+ .sr-array-table__row-divider::before {
8
+ content: "";
9
+ width: 100%;
10
+ height: 1px;
11
+ background-color: var(--g-color-line-generic);
12
+ }
1
13
  .sr-array-table__row {
2
14
  width: 100%;
3
15
  display: grid;
4
16
  align-items: start;
5
17
  grid-template-columns: 28px repeat(var(--columns-count), 1fr);
6
18
  gap: calc(var(--g-spacing-base) * 3);
7
- padding: calc(var(--g-spacing-base) * 2) 0;
8
- border-bottom: 1px solid var(--g-color-line-generic);
9
19
  }
10
20
  .sr-array-table__row_head {
11
21
  align-items: center;
@@ -40,6 +50,6 @@
40
50
  gap: 0 calc(var(--g-spacing-base) * 1);
41
51
  flex-wrap: wrap;
42
52
  }
43
- .sr-array-table__add-button {
53
+ .sr-array-table__add-button, .sr-array-table__init-button {
44
54
  align-self: flex-start;
45
55
  }
@@ -2,15 +2,44 @@ import React from 'react';
2
2
  import { Plus } from '@gravity-ui/icons';
3
3
  import { Button, HelpMark, Icon, Text } from '@gravity-ui/uikit';
4
4
  import { SchemaRendererMode, SchemaRendererNode, } from '../../../core';
5
- import { ArrayRemoveButton, EmptyEntityValue, EntityContainer, HTMLContent } from '../../components';
5
+ import { ArrayRemoveButton, EmptyEntityValue, EntityContainer, HTMLContent, LayoutContainer, } from '../../components';
6
6
  import { block } from '../../utils';
7
7
  import './ArrayTable.css';
8
8
  const b = block('array-table');
9
9
  export const ArrayTable = ({ headName, input, mode, props, schema, schemaPath, }) => {
10
10
  var _a;
11
11
  const { name, onBlur, onChange, onFocus, value } = input;
12
- const { disabled } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
12
+ const { disabled, required } = ((_a = schema.nodeParameters) === null || _a === void 0 ? void 0 : _a.flags) || {};
13
13
  const overviewFlag = mode === SchemaRendererMode.Overview;
14
+ const initButton = React.useMemo(() => {
15
+ if (required || value !== undefined || overviewFlag) {
16
+ return null;
17
+ }
18
+ const itemsSchema = schema.items;
19
+ const initValue = Array.isArray(itemsSchema)
20
+ ? itemsSchema.map(() => undefined)
21
+ : [undefined];
22
+ const onClick = () => {
23
+ onFocus();
24
+ onChange(initValue);
25
+ onBlur();
26
+ };
27
+ return (React.createElement(Button, { className: b('init-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-init-button` },
28
+ React.createElement(Icon, { data: Plus, size: 14 }),
29
+ props.addButtonText || null));
30
+ }, [
31
+ props.addButtonText,
32
+ disabled,
33
+ name,
34
+ onBlur,
35
+ onChange,
36
+ onFocus,
37
+ overviewFlag,
38
+ required,
39
+ schema.items,
40
+ schema.readOnly,
41
+ value,
42
+ ]);
14
43
  const addButton = React.useMemo(() => {
15
44
  const itemsSchema = schema.items;
16
45
  if (Array.isArray(itemsSchema) || overviewFlag) {
@@ -18,7 +47,7 @@ export const ArrayTable = ({ headName, input, mode, props, schema, schemaPath, }
18
47
  }
19
48
  const onClick = () => {
20
49
  onFocus();
21
- onChange([...(value || []), itemsSchema === null || itemsSchema === void 0 ? void 0 : itemsSchema.default]);
50
+ onChange([...(value || []), undefined]);
22
51
  onBlur();
23
52
  };
24
53
  return (React.createElement(Button, { className: b('add-button'), onClick: onClick, disabled: disabled || schema.readOnly, qa: `${name}-add-button` },
@@ -80,21 +109,24 @@ export const ArrayTable = ({ headName, input, mode, props, schema, schemaPath, }
80
109
  wIndex + 1 === array.length && column.schema.description ? (React.createElement(HelpMark, null,
81
110
  React.createElement(HTMLContent, { content: column.schema.description, headName: headName }))) : null))))));
82
111
  })));
83
- const rows = new Array(rowsCount).fill(null).map((_, rIndex) => (React.createElement("div", { className: b('row', { 'with-remove-button': withRemoveButton }), style: { '--columns-count': columns.length }, key: rIndex },
84
- React.createElement("div", { className: b('cell') },
85
- React.createElement(Text, { className: b('index'), variant: "subheader-1" }, rIndex + 1)),
86
- columns.map((column, cIndex) => (React.createElement("div", { className: b('cell'), key: cIndex },
87
- React.createElement(SchemaRendererNode, { headName: headName, name: getItemName(rIndex, column.name), schemaPath: getItemSchemaPath(rIndex, column.name) })))),
88
- withRemoveButton ? (React.createElement("div", { className: b('cell') },
89
- React.createElement(ArrayRemoveButton, { name: `${name}[${rIndex}]`, headName: headName }))) : null)));
112
+ const rows = new Array(rowsCount).fill(null).map((_, rIndex) => (React.createElement(React.Fragment, { key: rIndex },
113
+ React.createElement("div", { className: b('row-divider') }),
114
+ React.createElement(LayoutContainer, null,
115
+ React.createElement("div", { className: b('row', { 'with-remove-button': withRemoveButton }), style: { '--columns-count': columns.length } },
116
+ React.createElement("div", { className: b('cell') },
117
+ React.createElement(Text, { className: b('index'), variant: "subheader-1" }, rIndex + 1)),
118
+ columns.map((column, cIndex) => (React.createElement("div", { className: b('cell'), key: cIndex },
119
+ React.createElement(SchemaRendererNode, { headName: headName, name: getItemName(rIndex, column.name), schemaPath: getItemSchemaPath(rIndex, column.name) })))),
120
+ withRemoveButton ? (React.createElement("div", { className: b('cell') },
121
+ React.createElement(ArrayRemoveButton, { name: `${name}[${rIndex}]`, headName: headName, mode: mode }))) : null)))));
90
122
  return { head, rows };
91
- }, [columns, headName, name, overviewFlag, schema.items, schemaPath, value === null || value === void 0 ? void 0 : value.length]);
123
+ }, [columns, headName, mode, name, overviewFlag, schema.items, schemaPath, value === null || value === void 0 ? void 0 : value.length]);
92
124
  if (overviewFlag && !(value === null || value === void 0 ? void 0 : value.length)) {
93
125
  return React.createElement(EmptyEntityValue, null);
94
126
  }
95
- return (React.createElement(EntityContainer, { stretch: "by-child", gap: 2, fill: "by-child" },
96
- React.createElement("div", null,
97
- rows.length ? head : null,
98
- rows),
99
- addButton));
127
+ return (React.createElement(EntityContainer, { stretch: "by-child", gap: 4, fill: "by-child", droppable: true }, initButton ? (initButton) : (React.createElement(React.Fragment, null,
128
+ rows.length ? (React.createElement("div", null,
129
+ head,
130
+ rows)) : null,
131
+ addButton))));
100
132
  };
@@ -0,0 +1,3 @@
1
+ .sr-object-entity__init-button {
2
+ align-self: flex-start;
3
+ }
@@ -1,4 +1,5 @@
1
1
  import { type JsonSchemaObject, type NodeEntity } from '../../../core';
2
+ import './ObjectEntity.css';
2
3
  export interface ObjectEntityProps {
3
4
  order?: string[];
4
5
  }