@gravity-ui/dynamic-forms 5.13.2 → 5.14.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 (38) hide show
  1. package/build/cjs/lib/kit/components/Inputs/RangeInputPicker/RangeInputPicker.css +42 -0
  2. package/build/cjs/lib/kit/components/Inputs/RangeInputPicker/RangeInputPicker.js +64 -0
  3. package/build/cjs/lib/kit/components/Inputs/RangeInputPicker/RangeInputPickerNumber.js +43 -0
  4. package/build/cjs/lib/kit/components/Inputs/RangeInputPicker/index.js +6 -0
  5. package/build/cjs/lib/kit/components/Inputs/RangeInputPicker/types.js +2 -0
  6. package/build/cjs/lib/kit/components/Inputs/index.js +1 -0
  7. package/build/cjs/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerNumberView.js +14 -0
  8. package/build/cjs/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerView.js +28 -0
  9. package/build/cjs/lib/kit/components/Views/RangeInputPickerView/index.js +5 -0
  10. package/build/cjs/lib/kit/components/Views/index.js +1 -0
  11. package/build/cjs/lib/kit/constants/common.js +8 -1
  12. package/build/cjs/lib/kit/constants/config.js +4 -0
  13. package/build/cjs/lib/kit/utils/common.js +13 -1
  14. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/RangeInputPicker.css +42 -0
  15. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/RangeInputPicker.d.ts +5 -0
  16. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/RangeInputPicker.js +60 -0
  17. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/RangeInputPickerNumber.d.ts +5 -0
  18. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/RangeInputPickerNumber.js +39 -0
  19. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/index.d.ts +3 -0
  20. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/index.js +3 -0
  21. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/types.d.ts +15 -0
  22. package/build/esm/lib/kit/components/Inputs/RangeInputPicker/types.js +1 -0
  23. package/build/esm/lib/kit/components/Inputs/index.d.ts +1 -0
  24. package/build/esm/lib/kit/components/Inputs/index.js +1 -0
  25. package/build/esm/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerNumberView.d.ts +2 -0
  26. package/build/esm/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerNumberView.js +9 -0
  27. package/build/esm/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerView.d.ts +2 -0
  28. package/build/esm/lib/kit/components/Views/RangeInputPickerView/RangeInputPickerView.js +23 -0
  29. package/build/esm/lib/kit/components/Views/RangeInputPickerView/index.d.ts +2 -0
  30. package/build/esm/lib/kit/components/Views/RangeInputPickerView/index.js +2 -0
  31. package/build/esm/lib/kit/components/Views/index.d.ts +1 -0
  32. package/build/esm/lib/kit/components/Views/index.js +1 -0
  33. package/build/esm/lib/kit/constants/common.d.ts +7 -0
  34. package/build/esm/lib/kit/constants/common.js +7 -0
  35. package/build/esm/lib/kit/constants/config.js +5 -1
  36. package/build/esm/lib/kit/utils/common.d.ts +2 -0
  37. package/build/esm/lib/kit/utils/common.js +10 -0
  38. package/package.json +1 -1
@@ -0,0 +1,42 @@
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-range-input-picker {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: var(--g-spacing-3);
24
+ width: 100%;
25
+ }
26
+ .df-range-input-picker__slider {
27
+ padding: 0 var(--g-spacing-2);
28
+ }
29
+ .df-range-input-picker__inputs {
30
+ display: flex;
31
+ flex-direction: row;
32
+ align-items: center;
33
+ gap: var(--g-spacing-2);
34
+ }
35
+ .df-range-input-picker__input {
36
+ flex: 1 1 0;
37
+ min-width: 0;
38
+ }
39
+ .df-range-input-picker__separator {
40
+ flex: 0 0 auto;
41
+ color: var(--g-color-text-secondary);
42
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RangeInputPicker = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
7
+ const isNil_1 = tslib_1.__importDefault(require("lodash/isNil"));
8
+ const set_1 = tslib_1.__importDefault(require("lodash/set"));
9
+ const core_1 = require("../../../../core");
10
+ const common_1 = require("../../../constants/common");
11
+ const utils_1 = require("../../../utils");
12
+ const b = (0, utils_1.block)('range-input-picker');
13
+ const RangeInputPicker = (props) => {
14
+ var _a, _b, _c, _d, _e, _f;
15
+ const { spec, input, name } = props;
16
+ const { disabled, inputProps } = spec.viewSpec;
17
+ const sliderParams = inputProps === null || inputProps === void 0 ? void 0 : inputProps.sliderParams;
18
+ const showSlider = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showSlider) !== null && _a !== void 0 ? _a : true;
19
+ const showInputs = (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showInputs) !== null && _b !== void 0 ? _b : true;
20
+ const [fromSpec, toSpec] = react_1.default.useMemo(() => [common_1.FROM, common_1.TO].map((key) => {
21
+ var _a, _b;
22
+ return (0, core_1.isNumberSpec)((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[key])
23
+ ? (_b = spec.properties) === null || _b === void 0 ? void 0 : _b[key]
24
+ : undefined;
25
+ }), [spec.properties]);
26
+ const sliderMin = (0, utils_1.resolveRangeInputPickerBound)(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.min, fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.minimum, common_1.RANGE_INPUT_PICKER_DEFAULT_MIN);
27
+ const sliderMax = (0, utils_1.resolveRangeInputPickerBound)(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.max, toSpec === null || toSpec === void 0 ? void 0 : toSpec.maximum, common_1.RANGE_INPUT_PICKER_DEFAULT_MAX);
28
+ const sliderStep = (_c = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.step) !== null && _c !== void 0 ? _c : common_1.RANGE_INPUT_PICKER_DEFAULT_STEP;
29
+ const sliderMarks = (_d = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.marks) !== null && _d !== void 0 ? _d : common_1.RANGE_INPUT_PICKER_DEFAULT_MARKS;
30
+ const value = (_e = input.value) !== null && _e !== void 0 ? _e : {};
31
+ const fromValue = (0, isNil_1.default)(value.from) ? undefined : Number(value.from);
32
+ const toValue = (0, isNil_1.default)(value.to) ? undefined : Number(value.to);
33
+ const sliderValue = [
34
+ (0, isNil_1.default)(fromValue) ? sliderMin : fromValue,
35
+ (0, isNil_1.default)(toValue) ? sliderMax : toValue,
36
+ ];
37
+ const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => (0, set_1.default)(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input, name]);
38
+ const handleSliderUpdate = react_1.default.useCallback((next) => {
39
+ if (!Array.isArray(next)) {
40
+ return;
41
+ }
42
+ input.onChange(() => (Object.assign(Object.assign({}, value), { [common_1.FROM]: next[0], [common_1.TO]: next[1] })));
43
+ }, [input, value]);
44
+ const handleFromUpdate = react_1.default.useCallback((next) => {
45
+ const safe = next === null
46
+ ? undefined
47
+ : (0, utils_1.clampRangeInputPickerValue)(next, sliderMin, (0, isNil_1.default)(toValue) ? sliderMax : toValue);
48
+ parentOnChange(`${name}.${common_1.FROM}`, safe);
49
+ }, [name, parentOnChange, sliderMin, sliderMax, toValue]);
50
+ const handleToUpdate = react_1.default.useCallback((next) => {
51
+ const safe = next === null
52
+ ? undefined
53
+ : (0, utils_1.clampRangeInputPickerValue)(next, (0, isNil_1.default)(fromValue) ? sliderMin : fromValue, sliderMax);
54
+ parentOnChange(`${name}.${common_1.TO}`, safe);
55
+ }, [name, parentOnChange, sliderMin, sliderMax, fromValue]);
56
+ return (react_1.default.createElement("div", { className: b() },
57
+ showSlider ? (react_1.default.createElement("div", { className: b('slider') },
58
+ react_1.default.createElement(uikit_1.Slider, { value: sliderValue, min: sliderMin, max: sliderMax, step: sliderStep, marks: sliderMarks, disabled: disabled, onUpdate: handleSliderUpdate, onBlur: input.onBlur, onFocus: input.onFocus, qa: `${name}-slider`, tooltipDisplay: "off" }))) : null,
59
+ showInputs ? (react_1.default.createElement("div", { className: b('inputs') },
60
+ react_1.default.createElement(uikit_1.NumberInput, { className: b('input'), value: (0, isNil_1.default)(fromValue) ? null : fromValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled || (fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.viewSpec.disabled), placeholder: fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.viewSpec.placeholder, onUpdate: handleFromUpdate, onBlur: input.onBlur, onFocus: input.onFocus, hasClear: true, allowDecimal: true, qa: `${name}-from` }),
61
+ react_1.default.createElement("span", { className: b('separator') }, (_f = inputProps === null || inputProps === void 0 ? void 0 : inputProps.separator) !== null && _f !== void 0 ? _f : common_1.RANGE_INPUT_PICKER_DEFAULT_SEPARATOR),
62
+ react_1.default.createElement(uikit_1.NumberInput, { className: b('input'), value: (0, isNil_1.default)(toValue) ? null : toValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled || (toSpec === null || toSpec === void 0 ? void 0 : toSpec.viewSpec.disabled), placeholder: toSpec === null || toSpec === void 0 ? void 0 : toSpec.viewSpec.placeholder, onUpdate: handleToUpdate, onBlur: input.onBlur, onFocus: input.onFocus, hasClear: true, allowDecimal: true, qa: `${name}-to` }))) : null));
63
+ };
64
+ exports.RangeInputPicker = RangeInputPicker;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RangeInputPickerNumber = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
7
+ const isNil_1 = tslib_1.__importDefault(require("lodash/isNil"));
8
+ const common_1 = require("../../../constants/common");
9
+ const utils_1 = require("../../../utils");
10
+ const b = (0, utils_1.block)('range-input-picker');
11
+ const RangeInputPickerNumber = ({ name, input: { value, onBlur, onChange, onFocus }, spec, }) => {
12
+ var _a, _b, _c, _d;
13
+ const { disabled, placeholder, inputProps } = spec.viewSpec;
14
+ const sliderParams = inputProps === null || inputProps === void 0 ? void 0 : inputProps.sliderParams;
15
+ const showSlider = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showSlider) !== null && _a !== void 0 ? _a : true;
16
+ const showInputs = (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showInputs) !== null && _b !== void 0 ? _b : true;
17
+ const sliderMin = (0, utils_1.resolveRangeInputPickerBound)(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.min, spec.minimum, common_1.RANGE_INPUT_PICKER_DEFAULT_MIN);
18
+ const sliderMax = (0, utils_1.resolveRangeInputPickerBound)(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.max, spec.maximum, common_1.RANGE_INPUT_PICKER_DEFAULT_MAX);
19
+ const sliderStep = (_c = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.step) !== null && _c !== void 0 ? _c : common_1.RANGE_INPUT_PICKER_DEFAULT_STEP;
20
+ const sliderMarks = (_d = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.marks) !== null && _d !== void 0 ? _d : common_1.RANGE_INPUT_PICKER_DEFAULT_MARKS;
21
+ const numericValue = (0, isNil_1.default)(value) ? undefined : Number(value);
22
+ const sliderValue = (0, isNil_1.default)(numericValue) ? sliderMin : numericValue;
23
+ const onChangeAllowUndefined = onChange;
24
+ const handleSliderUpdate = react_1.default.useCallback((next) => {
25
+ if (Array.isArray(next)) {
26
+ return;
27
+ }
28
+ onChangeAllowUndefined(next);
29
+ }, [onChangeAllowUndefined]);
30
+ const handleInputUpdate = react_1.default.useCallback((next) => {
31
+ if (next === null) {
32
+ onChangeAllowUndefined(undefined);
33
+ return;
34
+ }
35
+ onChangeAllowUndefined((0, utils_1.clampRangeInputPickerValue)(next, sliderMin, sliderMax));
36
+ }, [onChangeAllowUndefined, sliderMin, sliderMax]);
37
+ return (react_1.default.createElement("div", { className: b() },
38
+ showSlider ? (react_1.default.createElement("div", { className: b('slider') },
39
+ react_1.default.createElement(uikit_1.Slider, { value: sliderValue, min: sliderMin, max: sliderMax, step: sliderStep, marks: sliderMarks, disabled: disabled, onUpdate: handleSliderUpdate, onBlur: onBlur, onFocus: onFocus, qa: `${name}-slider`, tooltipDisplay: "off" }))) : null,
40
+ showInputs ? (react_1.default.createElement("div", { className: b('inputs') },
41
+ react_1.default.createElement(uikit_1.NumberInput, { className: b('input'), value: (0, isNil_1.default)(numericValue) ? null : numericValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled, placeholder: placeholder, onUpdate: handleInputUpdate, onBlur: onBlur, onFocus: onFocus, hasClear: true, allowDecimal: true, qa: name }))) : null));
42
+ };
43
+ exports.RangeInputPickerNumber = RangeInputPickerNumber;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./RangeInputPicker"), exports);
5
+ tslib_1.__exportStar(require("./RangeInputPickerNumber"), exports);
6
+ tslib_1.__exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -15,6 +15,7 @@ tslib_1.__exportStar(require("./ObjectBase"), exports);
15
15
  tslib_1.__exportStar(require("./ObjectValueInput"), exports);
16
16
  tslib_1.__exportStar(require("./OneOf"), exports);
17
17
  tslib_1.__exportStar(require("./RadioGroup"), exports);
18
+ tslib_1.__exportStar(require("./RangeInputPicker"), exports);
18
19
  tslib_1.__exportStar(require("./Secret"), exports);
19
20
  tslib_1.__exportStar(require("./Select"), exports);
20
21
  tslib_1.__exportStar(require("./Switch"), exports);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RangeInputPickerNumberView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
7
+ const isNil_1 = tslib_1.__importDefault(require("lodash/isNil"));
8
+ const RangeInputPickerNumberView = ({ value }) => {
9
+ if ((0, isNil_1.default)(value)) {
10
+ return null;
11
+ }
12
+ return react_1.default.createElement(uikit_1.Text, null, String(value));
13
+ };
14
+ exports.RangeInputPickerNumberView = RangeInputPickerNumberView;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RangeInputPickerView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
7
+ const isNil_1 = tslib_1.__importDefault(require("lodash/isNil"));
8
+ const common_1 = require("../../../constants/common");
9
+ const RangeInputPickerView = ({ value, spec }) => {
10
+ var _a, _b;
11
+ const separator = (_b = (_a = spec.viewSpec.inputProps) === null || _a === void 0 ? void 0 : _a.separator) !== null && _b !== void 0 ? _b : common_1.RANGE_INPUT_PICKER_DEFAULT_SEPARATOR;
12
+ const from = value === null || value === void 0 ? void 0 : value.from;
13
+ const to = value === null || value === void 0 ? void 0 : value.to;
14
+ const formatted = (() => {
15
+ if ((0, isNil_1.default)(from) && (0, isNil_1.default)(to)) {
16
+ return '';
17
+ }
18
+ if ((0, isNil_1.default)(from)) {
19
+ return `${separator} ${to}`;
20
+ }
21
+ if ((0, isNil_1.default)(to)) {
22
+ return `${from} ${separator}`;
23
+ }
24
+ return `${from} ${separator} ${to}`;
25
+ })();
26
+ return react_1.default.createElement(uikit_1.Text, null, formatted);
27
+ };
28
+ exports.RangeInputPickerView = RangeInputPickerView;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./RangeInputPickerNumberView"), exports);
5
+ tslib_1.__exportStar(require("./RangeInputPickerView"), exports);
@@ -13,6 +13,7 @@ tslib_1.__exportStar(require("./NumberWithScaleView"), exports);
13
13
  tslib_1.__exportStar(require("./ObjectBaseView"), exports);
14
14
  tslib_1.__exportStar(require("./ObjectValueInputView"), exports);
15
15
  tslib_1.__exportStar(require("./OneOfView"), exports);
16
+ tslib_1.__exportStar(require("./RangeInputPickerView"), exports);
16
17
  tslib_1.__exportStar(require("./TableArrayView"), exports);
17
18
  tslib_1.__exportStar(require("./TextAreaView"), exports);
18
19
  tslib_1.__exportStar(require("./TextContentView"), exports);
@@ -1,8 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.END_TIME = exports.START_TIME = exports.OBJECT_VALUE_PROPERTY_NAME = exports.COMMON_TITLE_MAX_WIDTH = exports.COMMON_POPOVER_PLACEMENT = void 0;
3
+ exports.RANGE_INPUT_PICKER_DEFAULT_SEPARATOR = exports.RANGE_INPUT_PICKER_DEFAULT_MARKS = exports.RANGE_INPUT_PICKER_DEFAULT_STEP = exports.RANGE_INPUT_PICKER_DEFAULT_MAX = exports.RANGE_INPUT_PICKER_DEFAULT_MIN = exports.TO = exports.FROM = exports.END_TIME = exports.START_TIME = exports.OBJECT_VALUE_PROPERTY_NAME = exports.COMMON_TITLE_MAX_WIDTH = exports.COMMON_POPOVER_PLACEMENT = void 0;
4
4
  exports.COMMON_POPOVER_PLACEMENT = ['bottom', 'top'];
5
5
  exports.COMMON_TITLE_MAX_WIDTH = 523;
6
6
  exports.OBJECT_VALUE_PROPERTY_NAME = 'value';
7
7
  exports.START_TIME = 'start';
8
8
  exports.END_TIME = 'end';
9
+ exports.FROM = 'from';
10
+ exports.TO = 'to';
11
+ exports.RANGE_INPUT_PICKER_DEFAULT_MIN = 0;
12
+ exports.RANGE_INPUT_PICKER_DEFAULT_MAX = 100;
13
+ exports.RANGE_INPUT_PICKER_DEFAULT_STEP = 1;
14
+ exports.RANGE_INPUT_PICKER_DEFAULT_MARKS = 2;
15
+ exports.RANGE_INPUT_PICKER_DEFAULT_SEPARATOR = '–';
@@ -49,6 +49,7 @@ exports.dynamicConfig = {
49
49
  number: {
50
50
  inputs: {
51
51
  base: { Component: components_1.NumInput },
52
+ range_input_picker: { Component: components_1.RangeInputPickerNumber },
52
53
  },
53
54
  layouts: {
54
55
  row: components_1.Row,
@@ -74,6 +75,7 @@ exports.dynamicConfig = {
74
75
  multi_oneof_flat: { Component: components_1.MultiOneOfFlat, independent: true },
75
76
  inline: { Component: components_1.ObjectInline, independent: true },
76
77
  time_range_selector: { Component: components_1.TimeRangeSelector, independent: true },
78
+ range_input_picker: { Component: components_1.RangeInputPicker },
77
79
  },
78
80
  layouts: {
79
81
  row: components_1.Row,
@@ -164,6 +166,7 @@ exports.dynamicViewConfig = {
164
166
  number: {
165
167
  views: {
166
168
  base: { Component: components_1.BaseView },
169
+ range_input_picker: { Component: components_1.RangeInputPickerNumberView },
167
170
  },
168
171
  layouts: {
169
172
  row: components_1.ViewRow,
@@ -186,6 +189,7 @@ exports.dynamicViewConfig = {
186
189
  multi_oneof_flat: { Component: components_1.MultiOneOfFlatView, independent: true },
187
190
  inline: { Component: components_1.ObjectInlineView, independent: true },
188
191
  time_range_selector: { Component: components_1.TimeRangeSelectorView, independent: true },
192
+ range_input_picker: { Component: components_1.RangeInputPickerView },
189
193
  },
190
194
  layouts: {
191
195
  row: components_1.ViewRow,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCorrectSizeParams = exports.prepareSpec = exports.isNotEmptyValue = void 0;
3
+ exports.isCorrectSizeParams = exports.resolveRangeInputPickerBound = exports.clampRangeInputPickerValue = exports.prepareSpec = exports.isNotEmptyValue = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
6
6
  const isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
@@ -141,6 +141,18 @@ const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) => {
141
141
  return spec;
142
142
  };
143
143
  exports.prepareSpec = prepareSpec;
144
+ const clampRangeInputPickerValue = (value, min, max) => Math.min(Math.max(value, min), max);
145
+ exports.clampRangeInputPickerValue = clampRangeInputPickerValue;
146
+ const resolveRangeInputPickerBound = (inputBound, specBound, fallback) => {
147
+ if (!(0, isNil_1.default)(inputBound)) {
148
+ return inputBound;
149
+ }
150
+ if (!(0, isNil_1.default)(specBound)) {
151
+ return specBound;
152
+ }
153
+ return fallback;
154
+ };
155
+ exports.resolveRangeInputPickerBound = resolveRangeInputPickerBound;
144
156
  const isCorrectSizeParams = (spec) => {
145
157
  const { sizeParams } = spec.viewSpec;
146
158
  if (!sizeParams ||
@@ -0,0 +1,42 @@
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-range-input-picker {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: var(--g-spacing-3);
24
+ width: 100%;
25
+ }
26
+ .df-range-input-picker__slider {
27
+ padding: 0 var(--g-spacing-2);
28
+ }
29
+ .df-range-input-picker__inputs {
30
+ display: flex;
31
+ flex-direction: row;
32
+ align-items: center;
33
+ gap: var(--g-spacing-2);
34
+ }
35
+ .df-range-input-picker__input {
36
+ flex: 1 1 0;
37
+ min-width: 0;
38
+ }
39
+ .df-range-input-picker__separator {
40
+ flex: 0 0 auto;
41
+ color: var(--g-color-text-secondary);
42
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { ObjectInputProps } from '../../../../core';
3
+ import type { RangeInputPickerInputProps } from './types';
4
+ import './RangeInputPicker.css';
5
+ export declare const RangeInputPicker: (props: ObjectInputProps<RangeInputPickerInputProps>) => React.JSX.Element;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { NumberInput, Slider } from '@gravity-ui/uikit';
3
+ import isNil from 'lodash/isNil';
4
+ import set from 'lodash/set';
5
+ import { isNumberSpec } from '../../../../core';
6
+ import { FROM, RANGE_INPUT_PICKER_DEFAULT_MARKS, RANGE_INPUT_PICKER_DEFAULT_MAX, RANGE_INPUT_PICKER_DEFAULT_MIN, RANGE_INPUT_PICKER_DEFAULT_SEPARATOR, RANGE_INPUT_PICKER_DEFAULT_STEP, TO, } from '../../../constants/common';
7
+ import { block, clampRangeInputPickerValue, resolveRangeInputPickerBound } from '../../../utils';
8
+ import './RangeInputPicker.css';
9
+ const b = block('range-input-picker');
10
+ export const RangeInputPicker = (props) => {
11
+ var _a, _b, _c, _d, _e, _f;
12
+ const { spec, input, name } = props;
13
+ const { disabled, inputProps } = spec.viewSpec;
14
+ const sliderParams = inputProps === null || inputProps === void 0 ? void 0 : inputProps.sliderParams;
15
+ const showSlider = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showSlider) !== null && _a !== void 0 ? _a : true;
16
+ const showInputs = (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showInputs) !== null && _b !== void 0 ? _b : true;
17
+ const [fromSpec, toSpec] = React.useMemo(() => [FROM, TO].map((key) => {
18
+ var _a, _b;
19
+ return isNumberSpec((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[key])
20
+ ? (_b = spec.properties) === null || _b === void 0 ? void 0 : _b[key]
21
+ : undefined;
22
+ }), [spec.properties]);
23
+ const sliderMin = resolveRangeInputPickerBound(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.min, fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.minimum, RANGE_INPUT_PICKER_DEFAULT_MIN);
24
+ const sliderMax = resolveRangeInputPickerBound(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.max, toSpec === null || toSpec === void 0 ? void 0 : toSpec.maximum, RANGE_INPUT_PICKER_DEFAULT_MAX);
25
+ const sliderStep = (_c = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.step) !== null && _c !== void 0 ? _c : RANGE_INPUT_PICKER_DEFAULT_STEP;
26
+ const sliderMarks = (_d = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.marks) !== null && _d !== void 0 ? _d : RANGE_INPUT_PICKER_DEFAULT_MARKS;
27
+ const value = (_e = input.value) !== null && _e !== void 0 ? _e : {};
28
+ const fromValue = isNil(value.from) ? undefined : Number(value.from);
29
+ const toValue = isNil(value.to) ? undefined : Number(value.to);
30
+ const sliderValue = [
31
+ isNil(fromValue) ? sliderMin : fromValue,
32
+ isNil(toValue) ? sliderMax : toValue,
33
+ ];
34
+ const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => set(Object.assign({}, currentValue), childName.split(`${name}.`).join(''), childValue), childErrors), [input, name]);
35
+ const handleSliderUpdate = React.useCallback((next) => {
36
+ if (!Array.isArray(next)) {
37
+ return;
38
+ }
39
+ input.onChange(() => (Object.assign(Object.assign({}, value), { [FROM]: next[0], [TO]: next[1] })));
40
+ }, [input, value]);
41
+ const handleFromUpdate = React.useCallback((next) => {
42
+ const safe = next === null
43
+ ? undefined
44
+ : clampRangeInputPickerValue(next, sliderMin, isNil(toValue) ? sliderMax : toValue);
45
+ parentOnChange(`${name}.${FROM}`, safe);
46
+ }, [name, parentOnChange, sliderMin, sliderMax, toValue]);
47
+ const handleToUpdate = React.useCallback((next) => {
48
+ const safe = next === null
49
+ ? undefined
50
+ : clampRangeInputPickerValue(next, isNil(fromValue) ? sliderMin : fromValue, sliderMax);
51
+ parentOnChange(`${name}.${TO}`, safe);
52
+ }, [name, parentOnChange, sliderMin, sliderMax, fromValue]);
53
+ return (React.createElement("div", { className: b() },
54
+ showSlider ? (React.createElement("div", { className: b('slider') },
55
+ React.createElement(Slider, { value: sliderValue, min: sliderMin, max: sliderMax, step: sliderStep, marks: sliderMarks, disabled: disabled, onUpdate: handleSliderUpdate, onBlur: input.onBlur, onFocus: input.onFocus, qa: `${name}-slider`, tooltipDisplay: "off" }))) : null,
56
+ showInputs ? (React.createElement("div", { className: b('inputs') },
57
+ React.createElement(NumberInput, { className: b('input'), value: isNil(fromValue) ? null : fromValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled || (fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.viewSpec.disabled), placeholder: fromSpec === null || fromSpec === void 0 ? void 0 : fromSpec.viewSpec.placeholder, onUpdate: handleFromUpdate, onBlur: input.onBlur, onFocus: input.onFocus, hasClear: true, allowDecimal: true, qa: `${name}-from` }),
58
+ React.createElement("span", { className: b('separator') }, (_f = inputProps === null || inputProps === void 0 ? void 0 : inputProps.separator) !== null && _f !== void 0 ? _f : RANGE_INPUT_PICKER_DEFAULT_SEPARATOR),
59
+ React.createElement(NumberInput, { className: b('input'), value: isNil(toValue) ? null : toValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled || (toSpec === null || toSpec === void 0 ? void 0 : toSpec.viewSpec.disabled), placeholder: toSpec === null || toSpec === void 0 ? void 0 : toSpec.viewSpec.placeholder, onUpdate: handleToUpdate, onBlur: input.onBlur, onFocus: input.onFocus, hasClear: true, allowDecimal: true, qa: `${name}-to` }))) : null));
60
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { NumberInputProps } from '../../../../core';
3
+ import type { RangeInputPickerInputProps } from './types';
4
+ import './RangeInputPicker.css';
5
+ export declare const RangeInputPickerNumber: ({ name, input: { value, onBlur, onChange, onFocus }, spec, }: NumberInputProps<RangeInputPickerInputProps>) => React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { NumberInput, Slider } from '@gravity-ui/uikit';
3
+ import isNil from 'lodash/isNil';
4
+ import { RANGE_INPUT_PICKER_DEFAULT_MARKS, RANGE_INPUT_PICKER_DEFAULT_MAX, RANGE_INPUT_PICKER_DEFAULT_MIN, RANGE_INPUT_PICKER_DEFAULT_STEP, } from '../../../constants/common';
5
+ import { block, clampRangeInputPickerValue, resolveRangeInputPickerBound } from '../../../utils';
6
+ import './RangeInputPicker.css';
7
+ const b = block('range-input-picker');
8
+ export const RangeInputPickerNumber = ({ name, input: { value, onBlur, onChange, onFocus }, spec, }) => {
9
+ var _a, _b, _c, _d;
10
+ const { disabled, placeholder, inputProps } = spec.viewSpec;
11
+ const sliderParams = inputProps === null || inputProps === void 0 ? void 0 : inputProps.sliderParams;
12
+ const showSlider = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showSlider) !== null && _a !== void 0 ? _a : true;
13
+ const showInputs = (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.showInputs) !== null && _b !== void 0 ? _b : true;
14
+ const sliderMin = resolveRangeInputPickerBound(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.min, spec.minimum, RANGE_INPUT_PICKER_DEFAULT_MIN);
15
+ const sliderMax = resolveRangeInputPickerBound(sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.max, spec.maximum, RANGE_INPUT_PICKER_DEFAULT_MAX);
16
+ const sliderStep = (_c = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.step) !== null && _c !== void 0 ? _c : RANGE_INPUT_PICKER_DEFAULT_STEP;
17
+ const sliderMarks = (_d = sliderParams === null || sliderParams === void 0 ? void 0 : sliderParams.marks) !== null && _d !== void 0 ? _d : RANGE_INPUT_PICKER_DEFAULT_MARKS;
18
+ const numericValue = isNil(value) ? undefined : Number(value);
19
+ const sliderValue = isNil(numericValue) ? sliderMin : numericValue;
20
+ const onChangeAllowUndefined = onChange;
21
+ const handleSliderUpdate = React.useCallback((next) => {
22
+ if (Array.isArray(next)) {
23
+ return;
24
+ }
25
+ onChangeAllowUndefined(next);
26
+ }, [onChangeAllowUndefined]);
27
+ const handleInputUpdate = React.useCallback((next) => {
28
+ if (next === null) {
29
+ onChangeAllowUndefined(undefined);
30
+ return;
31
+ }
32
+ onChangeAllowUndefined(clampRangeInputPickerValue(next, sliderMin, sliderMax));
33
+ }, [onChangeAllowUndefined, sliderMin, sliderMax]);
34
+ return (React.createElement("div", { className: b() },
35
+ showSlider ? (React.createElement("div", { className: b('slider') },
36
+ React.createElement(Slider, { value: sliderValue, min: sliderMin, max: sliderMax, step: sliderStep, marks: sliderMarks, disabled: disabled, onUpdate: handleSliderUpdate, onBlur: onBlur, onFocus: onFocus, qa: `${name}-slider`, tooltipDisplay: "off" }))) : null,
37
+ showInputs ? (React.createElement("div", { className: b('inputs') },
38
+ React.createElement(NumberInput, { className: b('input'), value: isNil(numericValue) ? null : numericValue, min: sliderMin, max: sliderMax, step: sliderStep, disabled: disabled, placeholder: placeholder, onUpdate: handleInputUpdate, onBlur: onBlur, onFocus: onFocus, hasClear: true, allowDecimal: true, qa: name }))) : null));
39
+ };
@@ -0,0 +1,3 @@
1
+ export * from './RangeInputPicker';
2
+ export * from './RangeInputPickerNumber';
3
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ export * from './RangeInputPicker';
2
+ export * from './RangeInputPickerNumber';
3
+ export * from './types';
@@ -0,0 +1,15 @@
1
+ export interface RangeInputPickerInputProps {
2
+ sliderParams?: {
3
+ min: number;
4
+ max: number;
5
+ step?: number;
6
+ marks?: number | number[];
7
+ };
8
+ showSlider?: boolean;
9
+ showInputs?: boolean;
10
+ separator?: string;
11
+ }
12
+ export interface RangeInputPickerValue {
13
+ from?: number;
14
+ to?: number;
15
+ }
@@ -12,6 +12,7 @@ export * from './ObjectBase';
12
12
  export * from './ObjectValueInput';
13
13
  export * from './OneOf';
14
14
  export * from './RadioGroup';
15
+ export * from './RangeInputPicker';
15
16
  export * from './Secret';
16
17
  export * from './Select';
17
18
  export * from './Switch';
@@ -12,6 +12,7 @@ export * from './ObjectBase';
12
12
  export * from './ObjectValueInput';
13
13
  export * from './OneOf';
14
14
  export * from './RadioGroup';
15
+ export * from './RangeInputPicker';
15
16
  export * from './Secret';
16
17
  export * from './Select';
17
18
  export * from './Switch';
@@ -0,0 +1,2 @@
1
+ import type { NumberView } from '../../../../core';
2
+ export declare const RangeInputPickerNumberView: NumberView;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Text } from '@gravity-ui/uikit';
3
+ import isNil from 'lodash/isNil';
4
+ export const RangeInputPickerNumberView = ({ value }) => {
5
+ if (isNil(value)) {
6
+ return null;
7
+ }
8
+ return React.createElement(Text, null, String(value));
9
+ };
@@ -0,0 +1,2 @@
1
+ import type { ObjectView } from '../../../../core';
2
+ export declare const RangeInputPickerView: ObjectView;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Text } from '@gravity-ui/uikit';
3
+ import isNil from 'lodash/isNil';
4
+ import { RANGE_INPUT_PICKER_DEFAULT_SEPARATOR } from '../../../constants/common';
5
+ export const RangeInputPickerView = ({ value, spec }) => {
6
+ var _a, _b;
7
+ const separator = (_b = (_a = spec.viewSpec.inputProps) === null || _a === void 0 ? void 0 : _a.separator) !== null && _b !== void 0 ? _b : RANGE_INPUT_PICKER_DEFAULT_SEPARATOR;
8
+ const from = value === null || value === void 0 ? void 0 : value.from;
9
+ const to = value === null || value === void 0 ? void 0 : value.to;
10
+ const formatted = (() => {
11
+ if (isNil(from) && isNil(to)) {
12
+ return '';
13
+ }
14
+ if (isNil(from)) {
15
+ return `${separator} ${to}`;
16
+ }
17
+ if (isNil(to)) {
18
+ return `${from} ${separator}`;
19
+ }
20
+ return `${from} ${separator} ${to}`;
21
+ })();
22
+ return React.createElement(Text, null, formatted);
23
+ };
@@ -0,0 +1,2 @@
1
+ export * from './RangeInputPickerNumberView';
2
+ export * from './RangeInputPickerView';
@@ -0,0 +1,2 @@
1
+ export * from './RangeInputPickerNumberView';
2
+ export * from './RangeInputPickerView';
@@ -10,6 +10,7 @@ export * from './NumberWithScaleView';
10
10
  export * from './ObjectBaseView';
11
11
  export * from './ObjectValueInputView';
12
12
  export * from './OneOfView';
13
+ export * from './RangeInputPickerView';
13
14
  export * from './TableArrayView';
14
15
  export * from './TextAreaView';
15
16
  export * from './TextContentView';
@@ -10,6 +10,7 @@ export * from './NumberWithScaleView';
10
10
  export * from './ObjectBaseView';
11
11
  export * from './ObjectValueInputView';
12
12
  export * from './OneOfView';
13
+ export * from './RangeInputPickerView';
13
14
  export * from './TableArrayView';
14
15
  export * from './TextAreaView';
15
16
  export * from './TextContentView';
@@ -4,3 +4,10 @@ export declare const COMMON_TITLE_MAX_WIDTH = 523;
4
4
  export declare const OBJECT_VALUE_PROPERTY_NAME = "value";
5
5
  export declare const START_TIME = "start";
6
6
  export declare const END_TIME = "end";
7
+ export declare const FROM = "from";
8
+ export declare const TO = "to";
9
+ export declare const RANGE_INPUT_PICKER_DEFAULT_MIN = 0;
10
+ export declare const RANGE_INPUT_PICKER_DEFAULT_MAX = 100;
11
+ export declare const RANGE_INPUT_PICKER_DEFAULT_STEP = 1;
12
+ export declare const RANGE_INPUT_PICKER_DEFAULT_MARKS = 2;
13
+ export declare const RANGE_INPUT_PICKER_DEFAULT_SEPARATOR = "\u2013";
@@ -3,3 +3,10 @@ export const COMMON_TITLE_MAX_WIDTH = 523;
3
3
  export const OBJECT_VALUE_PROPERTY_NAME = 'value';
4
4
  export const START_TIME = 'start';
5
5
  export const END_TIME = 'end';
6
+ export const FROM = 'from';
7
+ export const TO = 'to';
8
+ export const RANGE_INPUT_PICKER_DEFAULT_MIN = 0;
9
+ export const RANGE_INPUT_PICKER_DEFAULT_MAX = 100;
10
+ export const RANGE_INPUT_PICKER_DEFAULT_STEP = 1;
11
+ export const RANGE_INPUT_PICKER_DEFAULT_MARKS = 2;
12
+ export const RANGE_INPUT_PICKER_DEFAULT_SEPARATOR = '–';
@@ -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, 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, 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, getObjectValidator, getStringValidator, } from '../validators';
3
3
  export const dynamicConfig = {
4
4
  array: {
@@ -46,6 +46,7 @@ export const dynamicConfig = {
46
46
  number: {
47
47
  inputs: {
48
48
  base: { Component: NumInput },
49
+ range_input_picker: { Component: RangeInputPickerNumber },
49
50
  },
50
51
  layouts: {
51
52
  row: Row,
@@ -71,6 +72,7 @@ export const dynamicConfig = {
71
72
  multi_oneof_flat: { Component: MultiOneOfFlat, independent: true },
72
73
  inline: { Component: ObjectInline, independent: true },
73
74
  time_range_selector: { Component: TimeRangeSelector, independent: true },
75
+ range_input_picker: { Component: RangeInputPicker },
74
76
  },
75
77
  layouts: {
76
78
  row: Row,
@@ -161,6 +163,7 @@ export const dynamicViewConfig = {
161
163
  number: {
162
164
  views: {
163
165
  base: { Component: BaseView },
166
+ range_input_picker: { Component: RangeInputPickerNumberView },
164
167
  },
165
168
  layouts: {
166
169
  row: ViewRow,
@@ -183,6 +186,7 @@ export const dynamicViewConfig = {
183
186
  multi_oneof_flat: { Component: MultiOneOfFlatView, independent: true },
184
187
  inline: { Component: ObjectInlineView, independent: true },
185
188
  time_range_selector: { Component: TimeRangeSelectorView, independent: true },
189
+ range_input_picker: { Component: RangeInputPickerView },
186
190
  },
187
191
  layouts: {
188
192
  row: ViewRow,
@@ -1,4 +1,6 @@
1
1
  import type { FormValue, Spec, StringSpec } from '../../core';
2
2
  export declare const isNotEmptyValue: (value: FormValue | undefined, spec: Spec | undefined) => boolean;
3
3
  export declare const prepareSpec: <Type extends Spec>(spec: Type, parseJsonDefaultValue?: boolean, overridePatternError?: (pattern?: string) => string) => Type;
4
+ export declare const clampRangeInputPickerValue: (value: number, min: number, max: number) => number;
5
+ export declare const resolveRangeInputPickerBound: (inputBound: number | undefined, specBound: number | undefined, fallback: number) => number;
4
6
  export declare const isCorrectSizeParams: (spec: StringSpec) => boolean;
@@ -135,6 +135,16 @@ export const prepareSpec = (spec, parseJsonDefaultValue, overridePatternError) =
135
135
  }
136
136
  return spec;
137
137
  };
138
+ export const clampRangeInputPickerValue = (value, min, max) => Math.min(Math.max(value, min), max);
139
+ export const resolveRangeInputPickerBound = (inputBound, specBound, fallback) => {
140
+ if (!isNil(inputBound)) {
141
+ return inputBound;
142
+ }
143
+ if (!isNil(specBound)) {
144
+ return specBound;
145
+ }
146
+ return fallback;
147
+ };
138
148
  export const isCorrectSizeParams = (spec) => {
139
149
  const { sizeParams } = spec.viewSpec;
140
150
  if (!sizeParams ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "5.13.2",
3
+ "version": "5.14.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",