@gravity-ui/dynamic-forms 5.12.1 → 5.13.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.
|
@@ -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;
|
|
@@ -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
|
};
|