@gravity-ui/dynamic-forms 5.9.4 → 5.10.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.
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumInput = 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 NumInput = ({ name, input: { value, onBlur, onChange, onFocus }, spec, inputProps, }) => {
9
+ const props = Object.assign(Object.assign({ hasClear: true }, inputProps), { value: (0, isNil_1.default)(value) ? null : Number(value), defaultValue: (0, isNil_1.default)(inputProps === null || inputProps === void 0 ? void 0 : inputProps.defaultValue) ? null : Number(inputProps === null || inputProps === void 0 ? void 0 : inputProps.defaultValue), onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name });
10
+ const handleUpdate = (value) => {
11
+ props.onUpdate(value !== null ? value : undefined);
12
+ };
13
+ return react_1.default.createElement(uikit_1.NumberInput, Object.assign({}, props, { onUpdate: handleUpdate, allowDecimal: true }));
14
+ };
15
+ exports.NumInput = NumInput;
@@ -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("./Number"), exports);
@@ -24,3 +24,4 @@ tslib_1.__exportStar(require("./TextArea"), exports);
24
24
  tslib_1.__exportStar(require("./TextContent"), exports);
25
25
  tslib_1.__exportStar(require("./TextLink"), exports);
26
26
  tslib_1.__exportStar(require("./TimeRangeSelector"), exports);
27
+ tslib_1.__exportStar(require("./Number"), exports);
@@ -48,7 +48,7 @@ exports.dynamicConfig = {
48
48
  },
49
49
  number: {
50
50
  inputs: {
51
- base: { Component: components_1.Text },
51
+ base: { Component: components_1.NumInput },
52
52
  },
53
53
  layouts: {
54
54
  row: components_1.Row,
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { NumberInputProps as NumberInputBaseProps } from '@gravity-ui/uikit';
3
+ import type { NumberInputProps } from '../../../../core';
4
+ export interface NumberProps extends Omit<NumberInputBaseProps, 'value' | 'onBlur' | 'onFocus' | 'onUpdate' | 'disabled' | 'placeholder' | 'qa'> {
5
+ }
6
+ export declare const NumInput: ({ name, input: { value, onBlur, onChange, onFocus }, spec, inputProps, }: NumberInputProps<NumberProps>) => React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { NumberInput as CommonNumberInput } from '@gravity-ui/uikit';
3
+ import isNil from 'lodash/isNil';
4
+ export const NumInput = ({ name, input: { value, onBlur, onChange, onFocus }, spec, inputProps, }) => {
5
+ const props = Object.assign(Object.assign({ hasClear: true }, inputProps), { value: isNil(value) ? null : Number(value), defaultValue: isNil(inputProps === null || inputProps === void 0 ? void 0 : inputProps.defaultValue) ? null : Number(inputProps === null || inputProps === void 0 ? void 0 : inputProps.defaultValue), onBlur: onBlur, onFocus: onFocus, onUpdate: onChange, disabled: spec.viewSpec.disabled, placeholder: spec.viewSpec.placeholder, qa: name });
6
+ const handleUpdate = (value) => {
7
+ props.onUpdate(value !== null ? value : undefined);
8
+ };
9
+ return React.createElement(CommonNumberInput, Object.assign({}, props, { onUpdate: handleUpdate, allowDecimal: true }));
10
+ };
@@ -0,0 +1 @@
1
+ export * from './Number';
@@ -0,0 +1 @@
1
+ export * from './Number';
@@ -21,3 +21,4 @@ export * from './TextArea';
21
21
  export * from './TextContent';
22
22
  export * from './TextLink';
23
23
  export * from './TimeRangeSelector';
24
+ export * from './Number';
@@ -21,3 +21,4 @@ export * from './TextArea';
21
21
  export * from './TextContent';
22
22
  export * from './TextLink';
23
23
  export * from './TimeRangeSelector';
24
+ export * from './Number';
@@ -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, 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, 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: {
@@ -45,7 +45,7 @@ export const dynamicConfig = {
45
45
  },
46
46
  number: {
47
47
  inputs: {
48
- base: { Component: Text },
48
+ base: { Component: NumInput },
49
49
  },
50
50
  layouts: {
51
51
  row: Row,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "5.9.4",
3
+ "version": "5.10.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",