@gravity-ui/dynamic-forms 5.12.1 → 5.13.1
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.
- package/build/cjs/lib/core/components/Form/Controller/utils.js +3 -0
- package/build/cjs/lib/kit/components/Views/BaseView/BaseView.js +7 -2
- package/build/esm/lib/core/components/Form/Controller/utils.js +3 -0
- package/build/esm/lib/core/types/specs.d.ts +4 -0
- package/build/esm/lib/kit/components/Views/BaseView/BaseView.d.ts +1 -1
- package/build/esm/lib/kit/components/Views/BaseView/BaseView.js +7 -2
- package/package.json +1 -1
|
@@ -127,6 +127,9 @@ const getFieldInitials = ({ name, spec, valueFromParent, initialValue, validate,
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
if ((0, helpers_1.isNumberSpec)(spec)) {
|
|
131
|
+
value = ((0, isNil_1.default)(value) || value === '' ? undefined : Number(value));
|
|
132
|
+
}
|
|
130
133
|
let errorMutator = (0, get_1.default)(mutatorsStore.errors, name, constants_2.EMPTY_MUTATOR);
|
|
131
134
|
if (!isErrorMutatorCorrect(errorMutator)) {
|
|
132
135
|
errorMutator = { value: undefined };
|
|
@@ -4,12 +4,17 @@ exports.BaseView = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const isString_1 = tslib_1.__importDefault(require("lodash/isString"));
|
|
7
|
+
const core_1 = require("../../../../core");
|
|
7
8
|
const components_1 = require("../../../components");
|
|
8
9
|
const BaseView = ({ value, spec, linkValue, }) => {
|
|
9
|
-
var _a;
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const stringValue = String(value);
|
|
12
|
+
const color = ((0, core_1.isBooleanSpec)(spec) &&
|
|
13
|
+
((_a = spec.viewSpec.viewColor) === null || _a === void 0 ? void 0 : _a[stringValue])) ||
|
|
14
|
+
undefined;
|
|
10
15
|
if ((0, isString_1.default)(value) && linkValue) {
|
|
11
16
|
return react_1.default.createElement(react_1.default.Fragment, null, linkValue);
|
|
12
17
|
}
|
|
13
|
-
return (react_1.default.createElement(components_1.LongValue, { value: ((
|
|
18
|
+
return (react_1.default.createElement(components_1.LongValue, { value: ((_b = spec === null || spec === void 0 ? void 0 : spec.description) === null || _b === void 0 ? void 0 : _b[stringValue]) || stringValue, color: color }));
|
|
14
19
|
};
|
|
15
20
|
exports.BaseView = BaseView;
|
|
@@ -117,6 +117,9 @@ export const getFieldInitials = ({ name, spec, valueFromParent, initialValue, va
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
if (isNumberSpec(spec)) {
|
|
121
|
+
value = (isNil(value) || value === '' ? undefined : Number(value));
|
|
122
|
+
}
|
|
120
123
|
let errorMutator = get(mutatorsStore.errors, name, EMPTY_MUTATOR);
|
|
121
124
|
if (!isErrorMutatorCorrect(errorMutator)) {
|
|
122
125
|
errorMutator = { value: undefined };
|
|
@@ -58,6 +58,10 @@ export interface BooleanSpec<LinkType = any, InputComponentProps extends Record<
|
|
|
58
58
|
hidden?: boolean;
|
|
59
59
|
inputProps?: InputComponentProps;
|
|
60
60
|
layoutProps?: LayoutComponentProps;
|
|
61
|
+
viewColor?: {
|
|
62
|
+
true: TextProps['color'];
|
|
63
|
+
false: TextProps['color'];
|
|
64
|
+
};
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
67
|
export interface NumberSpec<LinkType = any, InputComponentProps extends Record<string, any> | undefined = undefined, LayoutComponentProps extends Record<string, any> | undefined = undefined> {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type BooleanViewProps, type NumberViewProps, type StringViewProps } from '../../../../core';
|
|
3
3
|
export declare const BaseView: <T extends BooleanViewProps | NumberViewProps | StringViewProps>({ value, spec, linkValue, }: React.PropsWithChildren<T>) => React.JSX.Element;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isString from 'lodash/isString';
|
|
3
|
+
import { isBooleanSpec, } from '../../../../core';
|
|
3
4
|
import { LongValue } from '../../../components';
|
|
4
5
|
export const BaseView = ({ value, spec, linkValue, }) => {
|
|
5
|
-
var _a;
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const stringValue = String(value);
|
|
8
|
+
const color = (isBooleanSpec(spec) &&
|
|
9
|
+
((_a = spec.viewSpec.viewColor) === null || _a === void 0 ? void 0 : _a[stringValue])) ||
|
|
10
|
+
undefined;
|
|
6
11
|
if (isString(value) && linkValue) {
|
|
7
12
|
return React.createElement(React.Fragment, null, linkValue);
|
|
8
13
|
}
|
|
9
|
-
return (React.createElement(LongValue, { value: ((
|
|
14
|
+
return (React.createElement(LongValue, { value: ((_b = spec === null || spec === void 0 ? void 0 : spec.description) === null || _b === void 0 ? void 0 : _b[stringValue]) || stringValue, color: color }));
|
|
10
15
|
};
|