@gravity-ui/dynamic-forms 5.16.0 → 5.18.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 (25) hide show
  1. package/build/cjs/lib/kit/components/Inputs/ColorPicker/ColorPicker.js +28 -0
  2. package/build/cjs/lib/kit/components/Inputs/ColorPicker/index.js +4 -0
  3. package/build/cjs/lib/kit/components/Inputs/TextContent/TextContent.js +2 -2
  4. package/build/cjs/lib/kit/components/Inputs/index.js +1 -0
  5. package/build/cjs/lib/kit/components/Views/ColorPickerView/ColorPickerView.css +31 -0
  6. package/build/cjs/lib/kit/components/Views/ColorPickerView/ColorPickerView.js +12 -0
  7. package/build/cjs/lib/kit/components/Views/ColorPickerView/index.js +4 -0
  8. package/build/cjs/lib/kit/components/Views/index.js +1 -0
  9. package/build/cjs/lib/kit/constants/config.js +2 -0
  10. package/build/esm/lib/kit/components/Inputs/ColorPicker/ColorPicker.d.ts +21 -0
  11. package/build/esm/lib/kit/components/Inputs/ColorPicker/ColorPicker.js +23 -0
  12. package/build/esm/lib/kit/components/Inputs/ColorPicker/index.d.ts +1 -0
  13. package/build/esm/lib/kit/components/Inputs/ColorPicker/index.js +1 -0
  14. package/build/esm/lib/kit/components/Inputs/TextContent/TextContent.js +1 -1
  15. package/build/esm/lib/kit/components/Inputs/index.d.ts +1 -0
  16. package/build/esm/lib/kit/components/Inputs/index.js +1 -0
  17. package/build/esm/lib/kit/components/Views/ColorPickerView/ColorPickerView.css +31 -0
  18. package/build/esm/lib/kit/components/Views/ColorPickerView/ColorPickerView.d.ts +3 -0
  19. package/build/esm/lib/kit/components/Views/ColorPickerView/ColorPickerView.js +8 -0
  20. package/build/esm/lib/kit/components/Views/ColorPickerView/index.d.ts +1 -0
  21. package/build/esm/lib/kit/components/Views/ColorPickerView/index.js +1 -0
  22. package/build/esm/lib/kit/components/Views/index.d.ts +1 -0
  23. package/build/esm/lib/kit/components/Views/index.js +1 -0
  24. package/build/esm/lib/kit/constants/config.js +3 -1
  25. package/package.json +3 -3
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorPicker = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const unstable_1 = require("@gravity-ui/uikit/unstable");
7
+ /**
8
+ * Dynamic-forms input that renders a color picker for `StringSpec`.
9
+ *
10
+ * Wraps `unstable_ColorPicker` from `@gravity-ui/uikit/unstable`. Because the underlying
11
+ * uikit component is **unstable**, the visual appearance, available `inputProps`, and
12
+ * supported color formats may change between uikit releases.
13
+ */
14
+ const ColorPicker = ({ input, spec, inputProps }) => {
15
+ const { value, onChange, onBlur, onFocus } = input;
16
+ const handleOpenChange = react_1.default.useCallback((open) => {
17
+ var _a;
18
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(inputProps, open);
19
+ if (open) {
20
+ onFocus();
21
+ }
22
+ else {
23
+ onBlur();
24
+ }
25
+ }, [inputProps, onBlur, onFocus]);
26
+ return (react_1.default.createElement(unstable_1.unstable_ColorPicker, Object.assign({}, inputProps, { value: value || '', onUpdate: onChange, onOpenChange: handleOpenChange, disabled: spec.viewSpec.disabled })));
27
+ };
28
+ exports.ColorPicker = ColorPicker;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./ColorPicker"), exports);
@@ -4,8 +4,8 @@ exports.TextContent = exports.TextContentComponent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
7
- const lodash_1 = require("lodash");
8
7
  const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
8
+ const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
9
9
  const utils_1 = require("../../../utils");
10
10
  const LazyLoader_1 = require("../../LazyLoader");
11
11
  const utils_2 = require("./utils");
@@ -25,7 +25,7 @@ const TextContentComponent = ({ spec, value, Layout, }) => {
25
25
  }
26
26
  let content = react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: text } });
27
27
  if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeAlert) {
28
- const titleAlert = (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.titleAlert) || !(0, lodash_1.isEmpty)(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.titleAlert)
28
+ const titleAlert = (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.titleAlert) || !(0, isEmpty_1.default)(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.titleAlert)
29
29
  ? textContentParams.titleAlert
30
30
  : undefined;
31
31
  content = (react_1.default.createElement(uikit_1.Alert, Object.assign({}, (alertIcon || hasIconParam ? { icon: alertIcon } : {}), { message: content,
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./Checkbox"), exports);
7
7
  tslib_1.__exportStar(require("./CheckboxGroup"), exports);
8
8
  tslib_1.__exportStar(require("./FileInput"), exports);
9
9
  tslib_1.__exportStar(require("./DateInput"), exports);
10
+ tslib_1.__exportStar(require("./ColorPicker"), exports);
10
11
  tslib_1.__exportStar(require("./MonacoInput"), exports);
11
12
  tslib_1.__exportStar(require("./MultiOneOf"), exports);
12
13
  tslib_1.__exportStar(require("./MultiSelect"), exports);
@@ -0,0 +1,31 @@
1
+ /*
2
+ @mixin variables {
3
+ --g-spacing-base: 4px;
4
+
5
+ --g-spacing-0: calc(var(--g-spacing-base) * 0); //0px
6
+ --g-spacing-half: calc(var(--g-spacing-base) * 0.5); //2px
7
+ --g-spacing-1: var(--g-spacing-base); // 4px
8
+ --g-spacing-2: calc(var(--g-spacing-base) * 2); // 8px
9
+ --g-spacing-3: calc(var(--g-spacing-base) * 3); // 12px
10
+ --g-spacing-4: calc(var(--g-spacing-base) * 4); // 16px
11
+ --g-spacing-5: calc(var(--g-spacing-base) * 5); // 20px
12
+ --g-spacing-6: calc(var(--g-spacing-base) * 6); // 24px
13
+ --g-spacing-7: calc(var(--g-spacing-base) * 7); // 28px
14
+ --g-spacing-8: calc(var(--g-spacing-base) * 8); // 32px
15
+ --g-spacing-9: calc(var(--g-spacing-base) * 9); // 36px
16
+ --g-spacing-10: calc(var(--g-spacing-base) * 10); // 40px
17
+ }
18
+ */
19
+ /* Border-radius */
20
+ .df-color-picker-view {
21
+ display: flex;
22
+ align-items: center;
23
+ gap: var(--g-spacing-2);
24
+ }
25
+ .df-color-picker-view__preview {
26
+ width: 16px;
27
+ height: 16px;
28
+ flex-shrink: 0;
29
+ border: 1px solid var(--g-color-line-generic);
30
+ border-radius: var(--g-border-radius-xs);
31
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorPickerView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const components_1 = require("../../../components");
7
+ const utils_1 = require("../../../utils");
8
+ const b = (0, utils_1.block)('color-picker-view');
9
+ const ColorPickerView = ({ value = '' }) => (react_1.default.createElement("div", { className: b() },
10
+ value ? react_1.default.createElement("div", { className: b('preview'), style: { backgroundColor: value } }) : null,
11
+ react_1.default.createElement(components_1.LongValue, { value: value })));
12
+ exports.ColorPickerView = ColorPickerView;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./ColorPickerView"), exports);
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./BaseView"), exports);
6
6
  tslib_1.__exportStar(require("./CheckboxGroupView"), exports);
7
7
  tslib_1.__exportStar(require("./CardOneOfView"), exports);
8
8
  tslib_1.__exportStar(require("./FileInputView"), exports);
9
+ tslib_1.__exportStar(require("./ColorPickerView"), exports);
9
10
  tslib_1.__exportStar(require("./MonacoInputView"), exports);
10
11
  tslib_1.__exportStar(require("./MultiOneOfView"), exports);
11
12
  tslib_1.__exportStar(require("./MultiSelectView"), exports);
@@ -103,6 +103,7 @@ exports.dynamicConfig = {
103
103
  base: { Component: components_1.Text },
104
104
  file_input: { Component: components_1.FileInput },
105
105
  date_input: { Component: components_1.DateInput },
106
+ color_picker: { Component: components_1.ColorPicker },
106
107
  number_with_scale: { Component: components_1.NumberWithScale },
107
108
  monaco_input: { Component: components_1.MonacoInput },
108
109
  text_content: { Component: components_1.TextContent, independent: true },
@@ -214,6 +215,7 @@ exports.dynamicViewConfig = {
214
215
  select: { Component: components_1.BaseView },
215
216
  base: { Component: components_1.BaseView },
216
217
  date_input: { Component: components_1.DateView },
218
+ color_picker: { Component: components_1.ColorPickerView },
217
219
  file_input: { Component: components_1.FileInputView },
218
220
  number_with_scale: { Component: components_1.NumberWithScaleView },
219
221
  monaco_input: { Component: components_1.MonacoView },
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { unstable_ColorPicker as ColorPickerBase } from '@gravity-ui/uikit/unstable';
3
+ import type { StringInput } from '../../../../core';
4
+ /**
5
+ * Props forwarded to the underlying `unstable_ColorPicker` from `@gravity-ui/uikit/unstable`.
6
+ *
7
+ * NOTE: The underlying uikit component is marked as **unstable** — its API and behavior
8
+ * may change in future uikit releases without following semver. Use with that in mind.
9
+ *
10
+ * @see https://preview.gravity-ui.com/uikit/?path=/docs/lab-colorpicker--docs
11
+ */
12
+ export interface ColorPickerProps extends Omit<React.ComponentProps<typeof ColorPickerBase>, 'value' | 'onUpdate' | 'disabled'> {
13
+ }
14
+ /**
15
+ * Dynamic-forms input that renders a color picker for `StringSpec`.
16
+ *
17
+ * Wraps `unstable_ColorPicker` from `@gravity-ui/uikit/unstable`. Because the underlying
18
+ * uikit component is **unstable**, the visual appearance, available `inputProps`, and
19
+ * supported color formats may change between uikit releases.
20
+ */
21
+ export declare const ColorPicker: StringInput<ColorPickerProps>;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { unstable_ColorPicker as ColorPickerBase } from '@gravity-ui/uikit/unstable';
3
+ /**
4
+ * Dynamic-forms input that renders a color picker for `StringSpec`.
5
+ *
6
+ * Wraps `unstable_ColorPicker` from `@gravity-ui/uikit/unstable`. Because the underlying
7
+ * uikit component is **unstable**, the visual appearance, available `inputProps`, and
8
+ * supported color formats may change between uikit releases.
9
+ */
10
+ export const ColorPicker = ({ input, spec, inputProps }) => {
11
+ const { value, onChange, onBlur, onFocus } = input;
12
+ const handleOpenChange = React.useCallback((open) => {
13
+ var _a;
14
+ (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(inputProps, open);
15
+ if (open) {
16
+ onFocus();
17
+ }
18
+ else {
19
+ onBlur();
20
+ }
21
+ }, [inputProps, onBlur, onFocus]);
22
+ return (React.createElement(ColorPickerBase, Object.assign({}, inputProps, { value: value || '', onUpdate: onChange, onOpenChange: handleOpenChange, disabled: spec.viewSpec.disabled })));
23
+ };
@@ -0,0 +1 @@
1
+ export * from './ColorPicker';
@@ -0,0 +1 @@
1
+ export * from './ColorPicker';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Alert, Label, Text } from '@gravity-ui/uikit';
3
- import { isEmpty } from 'lodash';
4
3
  import cloneDeep from 'lodash/cloneDeep';
4
+ import isEmpty from 'lodash/isEmpty';
5
5
  import { block } from '../../../utils';
6
6
  import { LazyLoader } from '../../LazyLoader';
7
7
  import { isAlertView, loadIcon } from './utils';
@@ -4,6 +4,7 @@ export * from './Checkbox';
4
4
  export * from './CheckboxGroup';
5
5
  export * from './FileInput';
6
6
  export * from './DateInput';
7
+ export * from './ColorPicker';
7
8
  export * from './MonacoInput';
8
9
  export * from './MultiOneOf';
9
10
  export * from './MultiSelect';
@@ -4,6 +4,7 @@ export * from './Checkbox';
4
4
  export * from './CheckboxGroup';
5
5
  export * from './FileInput';
6
6
  export * from './DateInput';
7
+ export * from './ColorPicker';
7
8
  export * from './MonacoInput';
8
9
  export * from './MultiOneOf';
9
10
  export * from './MultiSelect';
@@ -0,0 +1,31 @@
1
+ /*
2
+ @mixin variables {
3
+ --g-spacing-base: 4px;
4
+
5
+ --g-spacing-0: calc(var(--g-spacing-base) * 0); //0px
6
+ --g-spacing-half: calc(var(--g-spacing-base) * 0.5); //2px
7
+ --g-spacing-1: var(--g-spacing-base); // 4px
8
+ --g-spacing-2: calc(var(--g-spacing-base) * 2); // 8px
9
+ --g-spacing-3: calc(var(--g-spacing-base) * 3); // 12px
10
+ --g-spacing-4: calc(var(--g-spacing-base) * 4); // 16px
11
+ --g-spacing-5: calc(var(--g-spacing-base) * 5); // 20px
12
+ --g-spacing-6: calc(var(--g-spacing-base) * 6); // 24px
13
+ --g-spacing-7: calc(var(--g-spacing-base) * 7); // 28px
14
+ --g-spacing-8: calc(var(--g-spacing-base) * 8); // 32px
15
+ --g-spacing-9: calc(var(--g-spacing-base) * 9); // 36px
16
+ --g-spacing-10: calc(var(--g-spacing-base) * 10); // 40px
17
+ }
18
+ */
19
+ /* Border-radius */
20
+ .df-color-picker-view {
21
+ display: flex;
22
+ align-items: center;
23
+ gap: var(--g-spacing-2);
24
+ }
25
+ .df-color-picker-view__preview {
26
+ width: 16px;
27
+ height: 16px;
28
+ flex-shrink: 0;
29
+ border: 1px solid var(--g-color-line-generic);
30
+ border-radius: var(--g-border-radius-xs);
31
+ }
@@ -0,0 +1,3 @@
1
+ import type { StringView } from '../../../../core';
2
+ import './ColorPickerView.css';
3
+ export declare const ColorPickerView: StringView;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { LongValue } from '../../../components';
3
+ import { block } from '../../../utils';
4
+ import './ColorPickerView.css';
5
+ const b = block('color-picker-view');
6
+ export const ColorPickerView = ({ value = '' }) => (React.createElement("div", { className: b() },
7
+ value ? React.createElement("div", { className: b('preview'), style: { backgroundColor: value } }) : null,
8
+ React.createElement(LongValue, { value: value })));
@@ -0,0 +1 @@
1
+ export * from './ColorPickerView';
@@ -0,0 +1 @@
1
+ export * from './ColorPickerView';
@@ -3,6 +3,7 @@ export * from './BaseView';
3
3
  export * from './CheckboxGroupView';
4
4
  export * from './CardOneOfView';
5
5
  export * from './FileInputView';
6
+ export * from './ColorPickerView';
6
7
  export * from './MonacoInputView';
7
8
  export * from './MultiOneOfView';
8
9
  export * from './MultiSelectView';
@@ -3,6 +3,7 @@ export * from './BaseView';
3
3
  export * from './CheckboxGroupView';
4
4
  export * from './CardOneOfView';
5
5
  export * from './FileInputView';
6
+ export * from './ColorPickerView';
6
7
  export * from './MonacoInputView';
7
8
  export * from './MultiOneOfView';
8
9
  export * from './MultiSelectView';
@@ -1,4 +1,4 @@
1
- import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, CheckboxGroup, CheckboxGroupView, Column, DateInput, DateView, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoView, MultiOneOf, MultiOneOfFlat, MultiOneOfFlatView, MultiOneOfView, MultiSelect, MultiSelectView, NumInput, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectInline, ObjectInlineView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfFlat, OneOfFlatView, OneOfView, RadioGroup, RangeInputPicker, RangeInputPickerNumber, RangeInputPickerNumberView, RangeInputPickerView, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextContentView, TextLink, TextLinkView, TimeRangeSelector, TimeRangeSelectorView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewColumn, ViewGroup, ViewGroup2, ViewRow, ViewSection, ViewSection2, ViewTableCell, ViewTransparent, } from '../components';
1
+ import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, CheckboxGroup, CheckboxGroupView, ColorPicker, ColorPickerView, Column, DateInput, DateView, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoView, MultiOneOf, MultiOneOfFlat, MultiOneOfFlatView, MultiOneOfView, MultiSelect, MultiSelectView, NumInput, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectInline, ObjectInlineView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfFlat, OneOfFlatView, OneOfView, RadioGroup, RangeInputPicker, RangeInputPickerNumber, RangeInputPickerNumberView, RangeInputPickerView, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextContentView, TextLink, TextLinkView, TimeRangeSelector, TimeRangeSelectorView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewColumn, ViewGroup, ViewGroup2, ViewRow, ViewSection, ViewSection2, ViewTableCell, ViewTransparent, } from '../components';
2
2
  import { getArrayValidator, getBooleanValidator, getNumberValidator, getNumberWithScaleValidator, getObjectValidator, getStringValidator, } from '../validators';
3
3
  export const dynamicConfig = {
4
4
  array: {
@@ -100,6 +100,7 @@ export const dynamicConfig = {
100
100
  base: { Component: Text },
101
101
  file_input: { Component: FileInput },
102
102
  date_input: { Component: DateInput },
103
+ color_picker: { Component: ColorPicker },
103
104
  number_with_scale: { Component: NumberWithScale },
104
105
  monaco_input: { Component: MonacoInput },
105
106
  text_content: { Component: TextContent, independent: true },
@@ -211,6 +212,7 @@ export const dynamicViewConfig = {
211
212
  select: { Component: BaseView },
212
213
  base: { Component: BaseView },
213
214
  date_input: { Component: DateView },
215
+ color_picker: { Component: ColorPickerView },
214
216
  file_input: { Component: FileInputView },
215
217
  number_with_scale: { Component: NumberWithScaleView },
216
218
  monaco_input: { Component: MonacoView },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "5.16.0",
3
+ "version": "5.18.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",
@@ -60,7 +60,7 @@
60
60
  "@gravity-ui/prettier-config": "^1.1.0",
61
61
  "@gravity-ui/stylelint-config": "^4.0.1",
62
62
  "@gravity-ui/tsconfig": "^1.0.0",
63
- "@gravity-ui/uikit": "^7.25.0",
63
+ "@gravity-ui/uikit": "^7.41.0",
64
64
  "@playwright/experimental-ct-react": "^1.40.0",
65
65
  "@playwright/test": "^1.40.0",
66
66
  "@storybook/addon-essentials": "^8.6.4",
@@ -80,7 +80,7 @@
80
80
  "@types/react-is": "^17.0.3",
81
81
  "@types/uuid": "^9.0.4",
82
82
  "@vitejs/plugin-react": "^4.2.0",
83
- "ajv": "^8.17.1",
83
+ "ajv": "^8.20.0",
84
84
  "css-loader": "^5.2.6",
85
85
  "eslint": "^8.49.0",
86
86
  "final-form": "^4.20.2",