@gravity-ui/dynamic-forms 4.5.0 → 4.7.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.
- package/build/cjs/lib/core/components/View/DynamicView.js +8 -2
- package/build/cjs/lib/core/components/View/index.js +3 -0
- package/build/cjs/lib/kit/components/Inputs/CheckboxGroup/CheckboxGroup.css +18 -0
- package/build/cjs/lib/kit/components/Inputs/CheckboxGroup/CheckboxGroup.js +40 -0
- package/build/cjs/lib/kit/components/Inputs/CheckboxGroup/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/DateInput/DateInput.css +3 -0
- package/build/cjs/lib/kit/components/Inputs/DateInput/DateInput.js +50 -0
- package/build/cjs/lib/kit/components/Inputs/DateInput/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +7 -2
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/TimeRangeSelector.js +81 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/TimeRangeSelect.css +6 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/TimeRangeSelect.js +33 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/components/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/TimeRangeSelector/utils.js +26 -0
- package/build/cjs/lib/kit/components/Inputs/index.js +3 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +5 -1
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
- package/build/cjs/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +4 -0
- package/build/cjs/lib/kit/components/Views/CheckboxGroupView/CheckboxGroupView.css +27 -0
- package/build/cjs/lib/kit/components/Views/CheckboxGroupView/CheckboxGroupView.js +19 -0
- package/build/cjs/lib/kit/components/Views/CheckboxGroupView/index.js +4 -0
- package/build/cjs/lib/kit/components/Views/DateView/DateView.js +22 -0
- package/build/cjs/lib/kit/components/Views/DateView/index.js +4 -0
- package/build/cjs/lib/kit/components/Views/TableArrayView/TableArrayView.js +9 -3
- package/build/cjs/lib/kit/components/Views/TimeRangeSelectorView/TimeRangeSelectorView.js +34 -0
- package/build/cjs/lib/kit/components/Views/TimeRangeSelectorView/index.js +4 -0
- package/build/cjs/lib/kit/components/Views/index.js +3 -0
- package/build/cjs/lib/kit/constants/common.js +3 -1
- package/build/cjs/lib/kit/constants/config.js +6 -0
- package/build/esm/lib/core/components/View/DynamicView.d.ts +2 -1
- package/build/esm/lib/core/components/View/DynamicView.js +8 -2
- package/build/esm/lib/core/components/View/index.d.ts +1 -0
- package/build/esm/lib/core/components/View/index.js +1 -0
- package/build/esm/lib/core/components/View/types/context.d.ts +1 -0
- package/build/esm/lib/core/types/specs.d.ts +9 -0
- package/build/esm/lib/kit/components/Inputs/CheckboxGroup/CheckboxGroup.css +18 -0
- package/build/esm/lib/kit/components/Inputs/CheckboxGroup/CheckboxGroup.d.ts +6 -0
- package/build/esm/lib/kit/components/Inputs/CheckboxGroup/CheckboxGroup.js +36 -0
- package/build/esm/lib/kit/components/Inputs/CheckboxGroup/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/CheckboxGroup/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/DateInput/DateInput.css +3 -0
- package/build/esm/lib/kit/components/Inputs/DateInput/DateInput.d.ts +9 -0
- package/build/esm/lib/kit/components/Inputs/DateInput/DateInput.js +46 -0
- package/build/esm/lib/kit/components/Inputs/DateInput/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/DateInput/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.js +8 -3
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/TimeRangeSelector.d.ts +2 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/TimeRangeSelector.js +76 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/TimeRangeSelect.css +6 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/TimeRangeSelect.d.ts +14 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/TimeRangeSelect.js +29 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/TimeRangeSelect/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/components/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/utils.d.ts +15 -0
- package/build/esm/lib/kit/components/Inputs/TimeRangeSelector/utils.js +20 -0
- package/build/esm/lib/kit/components/Inputs/index.d.ts +3 -0
- package/build/esm/lib/kit/components/Inputs/index.js +3 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewAccordeon/ViewAccordeon.js +5 -1
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.css +3 -0
- package/build/esm/lib/kit/components/ViewLayouts/ViewRow/ViewRow.js +4 -0
- package/build/esm/lib/kit/components/Views/CheckboxGroupView/CheckboxGroupView.css +27 -0
- package/build/esm/lib/kit/components/Views/CheckboxGroupView/CheckboxGroupView.d.ts +3 -0
- package/build/esm/lib/kit/components/Views/CheckboxGroupView/CheckboxGroupView.js +15 -0
- package/build/esm/lib/kit/components/Views/CheckboxGroupView/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Views/CheckboxGroupView/index.js +1 -0
- package/build/esm/lib/kit/components/Views/DateView/DateView.d.ts +3 -0
- package/build/esm/lib/kit/components/Views/DateView/DateView.js +18 -0
- package/build/esm/lib/kit/components/Views/DateView/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Views/DateView/index.js +1 -0
- package/build/esm/lib/kit/components/Views/TableArrayView/TableArrayView.js +11 -5
- package/build/esm/lib/kit/components/Views/TimeRangeSelectorView/TimeRangeSelectorView.d.ts +2 -0
- package/build/esm/lib/kit/components/Views/TimeRangeSelectorView/TimeRangeSelectorView.js +30 -0
- package/build/esm/lib/kit/components/Views/TimeRangeSelectorView/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Views/TimeRangeSelectorView/index.js +1 -0
- package/build/esm/lib/kit/components/Views/index.d.ts +3 -0
- package/build/esm/lib/kit/components/Views/index.js +3 -0
- package/build/esm/lib/kit/constants/common.d.ts +2 -0
- package/build/esm/lib/kit/constants/common.js +2 -0
- package/build/esm/lib/kit/constants/config.js +7 -1
- package/package.json +3 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BaseView, DEFAULT_DATE_FORMAT } from '../../../components';
|
|
4
|
+
import { dateTimeParse } from '@gravity-ui/date-utils';
|
|
5
|
+
import isObject from 'lodash/isObject';
|
|
6
|
+
export const DateView = (_a) => {
|
|
7
|
+
var _b, _c, _d;
|
|
8
|
+
var { value, spec } = _a, restProps = __rest(_a, ["value", "spec"]);
|
|
9
|
+
let formatedValue = value && isObject(value) && value.seconds
|
|
10
|
+
? (value === null || value === void 0 ? void 0 : value.seconds) * 1000
|
|
11
|
+
: value;
|
|
12
|
+
const localSpec = spec.viewSpec;
|
|
13
|
+
const format = ((_b = localSpec.inputProps) === null || _b === void 0 ? void 0 : _b.format) || ((_c = localSpec.dateInput) === null || _c === void 0 ? void 0 : _c.printFormat) || DEFAULT_DATE_FORMAT;
|
|
14
|
+
if (formatedValue && format) {
|
|
15
|
+
formatedValue = ((_d = dateTimeParse(formatedValue)) === null || _d === void 0 ? void 0 : _d.format(format)) || formatedValue;
|
|
16
|
+
}
|
|
17
|
+
return React.createElement(BaseView, Object.assign({ spec: spec, value: String(formatedValue) }, restProps));
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateView';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Table } from '@gravity-ui/uikit';
|
|
3
|
-
import { ViewController, isArraySpec, isBooleanSpec, isObjectSpec, } from '../../../../core';
|
|
2
|
+
import { Flex, Table } from '@gravity-ui/uikit';
|
|
3
|
+
import { ViewController, isArraySpec, isBooleanSpec, isObjectSpec, useDynamicFormsCtx, } from '../../../../core';
|
|
4
4
|
import { block } from '../../../utils';
|
|
5
5
|
import './TableArrayView.css';
|
|
6
|
+
import { HelpPopover } from '@gravity-ui/components';
|
|
6
7
|
const b = block('table-array-view');
|
|
7
8
|
export const TableArrayView = ({ value = [], spec, name }) => {
|
|
9
|
+
const { showLayoutDescription } = useDynamicFormsCtx();
|
|
8
10
|
const columns = React.useMemo(() => {
|
|
9
11
|
const { items, viewSpec: { table }, } = spec;
|
|
10
12
|
if (!(table === null || table === void 0 ? void 0 : table.length) || !isObjectSpec(items)) {
|
|
@@ -16,9 +18,13 @@ export const TableArrayView = ({ value = [], spec, name }) => {
|
|
|
16
18
|
sticky: 'left',
|
|
17
19
|
template: (__, idx) => (React.createElement("div", { className: b('idx'), key: `idx-${idx}` }, idx + 1)),
|
|
18
20
|
};
|
|
19
|
-
const columns = table.map(({ property, label }) => ({
|
|
21
|
+
const columns = table.map(({ property, label, description }) => ({
|
|
20
22
|
id: property,
|
|
21
|
-
name:
|
|
23
|
+
name: description && showLayoutDescription
|
|
24
|
+
? () => (React.createElement(Flex, { gap: 0.5, alignItems: "center" },
|
|
25
|
+
label,
|
|
26
|
+
React.createElement(HelpPopover, { htmlContent: description, placement: ['bottom', 'top'] })))
|
|
27
|
+
: label,
|
|
22
28
|
template: (_, idx) => {
|
|
23
29
|
var _a;
|
|
24
30
|
const entitySpec = (_a = items === null || items === void 0 ? void 0 : items.properties) === null || _a === void 0 ? void 0 : _a[property];
|
|
@@ -34,7 +40,7 @@ export const TableArrayView = ({ value = [], spec, name }) => {
|
|
|
34
40
|
},
|
|
35
41
|
}));
|
|
36
42
|
return [idxColumn, ...columns];
|
|
37
|
-
}, [name, spec]);
|
|
43
|
+
}, [name, spec, showLayoutDescription]);
|
|
38
44
|
if (!columns) {
|
|
39
45
|
return null;
|
|
40
46
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
4
|
+
import { ViewController, isStringSpec } from '../../../../core';
|
|
5
|
+
import { END_TIME, START_TIME } from '../../../constants/common';
|
|
6
|
+
export const TimeRangeSelectorView = (_a) => {
|
|
7
|
+
var { value, spec, name, Layout } = _a, restProps = __rest(_a, ["value", "spec", "name", "Layout"]);
|
|
8
|
+
const { startTimeSpec, endTimeSpec } = React.useMemo(() => {
|
|
9
|
+
const [startTimeSpec, endTimeSpec] = [START_TIME, END_TIME].map((key) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (((_a = spec.properties) === null || _a === void 0 ? void 0 : _a[key]) && isStringSpec(spec.properties[key])) {
|
|
12
|
+
const _spec = cloneDeep(spec.properties[key]);
|
|
13
|
+
_spec.viewSpec.layout = 'row';
|
|
14
|
+
return _spec;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
});
|
|
18
|
+
return { startTimeSpec, endTimeSpec };
|
|
19
|
+
}, [spec.properties]);
|
|
20
|
+
if (!startTimeSpec || !endTimeSpec) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const content = (React.createElement(React.Fragment, null,
|
|
24
|
+
React.createElement(ViewController, { spec: startTimeSpec, name: `${name ? name + '.' : ''}${START_TIME}` }),
|
|
25
|
+
React.createElement(ViewController, { spec: endTimeSpec, name: `${name ? name + '.' : ''}${END_TIME}` })));
|
|
26
|
+
if (Layout) {
|
|
27
|
+
return (React.createElement(Layout, Object.assign({ spec: spec, name: name, value: value }, restProps), content));
|
|
28
|
+
}
|
|
29
|
+
return React.createElement(React.Fragment, null, content);
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TimeRangeSelectorView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TimeRangeSelectorView';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './ArrayBaseView';
|
|
2
2
|
export * from './BaseView';
|
|
3
|
+
export * from './CheckboxGroupView';
|
|
3
4
|
export * from './CardOneOfView';
|
|
4
5
|
export * from './FileInputView';
|
|
5
6
|
export * from './MonacoInputView';
|
|
@@ -12,3 +13,5 @@ export * from './OneOfView';
|
|
|
12
13
|
export * from './TableArrayView';
|
|
13
14
|
export * from './TextAreaView';
|
|
14
15
|
export * from './TextLinkView';
|
|
16
|
+
export * from './TimeRangeSelectorView';
|
|
17
|
+
export * from './DateView';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './ArrayBaseView';
|
|
2
2
|
export * from './BaseView';
|
|
3
|
+
export * from './CheckboxGroupView';
|
|
3
4
|
export * from './CardOneOfView';
|
|
4
5
|
export * from './FileInputView';
|
|
5
6
|
export * from './MonacoInputView';
|
|
@@ -12,3 +13,5 @@ export * from './OneOfView';
|
|
|
12
13
|
export * from './TableArrayView';
|
|
13
14
|
export * from './TextAreaView';
|
|
14
15
|
export * from './TextLinkView';
|
|
16
|
+
export * from './TimeRangeSelectorView';
|
|
17
|
+
export * from './DateView';
|
|
@@ -2,3 +2,5 @@ import type { PopoverProps } from '@gravity-ui/uikit';
|
|
|
2
2
|
export declare const COMMON_POPOVER_PLACEMENT: PopoverProps['placement'];
|
|
3
3
|
export declare const COMMON_TITLE_MAX_WIDTH = 533;
|
|
4
4
|
export declare const OBJECT_VALUE_PROPERTY_NAME = "value";
|
|
5
|
+
export declare const START_TIME = "start";
|
|
6
|
+
export declare const END_TIME = "end";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoView, MultiOneOf, MultiOneOfFlat, MultiOneOfFlatView, MultiOneOfView, MultiSelect, MultiSelectView, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectInline, ObjectInlineView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfFlat, OneOfFlatView, OneOfView, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextLink, TextLinkView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewGroup, ViewGroup2, ViewRow, ViewSection, ViewSection2, ViewTableCell, ViewTransparent, } from '../components';
|
|
1
|
+
import { Accordeon, AccordeonCardForm, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, CheckboxGroup, CheckboxGroupView, 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, Row, RowVerbose, Secret, Section, Section2, Select, Switch, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextLink, TextLinkView, TimeRangeSelector, TimeRangeSelectorView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, 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: {
|
|
@@ -6,6 +6,7 @@ export const dynamicConfig = {
|
|
|
6
6
|
select: { Component: MultiSelect },
|
|
7
7
|
table: { Component: TableArrayInput },
|
|
8
8
|
base: { Component: ArrayBase },
|
|
9
|
+
checkbox_group: { Component: CheckboxGroup },
|
|
9
10
|
},
|
|
10
11
|
layouts: {
|
|
11
12
|
row: Row,
|
|
@@ -66,6 +67,7 @@ export const dynamicConfig = {
|
|
|
66
67
|
multi_oneof: { Component: MultiOneOf, independent: true },
|
|
67
68
|
multi_oneof_flat: { Component: MultiOneOfFlat, independent: true },
|
|
68
69
|
inline: { Component: ObjectInline, independent: true },
|
|
70
|
+
time_range_selector: { Component: TimeRangeSelector, independent: true },
|
|
69
71
|
},
|
|
70
72
|
layouts: {
|
|
71
73
|
row: Row,
|
|
@@ -91,6 +93,7 @@ export const dynamicConfig = {
|
|
|
91
93
|
select: { Component: Select },
|
|
92
94
|
base: { Component: Text },
|
|
93
95
|
file_input: { Component: FileInput },
|
|
96
|
+
date_input: { Component: DateInput },
|
|
94
97
|
number_with_scale: { Component: NumberWithScale },
|
|
95
98
|
monaco_input: { Component: MonacoInput },
|
|
96
99
|
text_content: { Component: TextContent, independent: true },
|
|
@@ -118,6 +121,7 @@ export const dynamicViewConfig = {
|
|
|
118
121
|
select: { Component: MultiSelectView },
|
|
119
122
|
table: { Component: TableArrayView },
|
|
120
123
|
base: { Component: ArrayBaseView },
|
|
124
|
+
checkbox_group: { Component: CheckboxGroupView },
|
|
121
125
|
},
|
|
122
126
|
layouts: {
|
|
123
127
|
row: ViewRow,
|
|
@@ -169,6 +173,7 @@ export const dynamicViewConfig = {
|
|
|
169
173
|
multi_oneof: { Component: MultiOneOfView, independent: true },
|
|
170
174
|
multi_oneof_flat: { Component: MultiOneOfFlatView, independent: true },
|
|
171
175
|
inline: { Component: ObjectInlineView, independent: true },
|
|
176
|
+
time_range_selector: { Component: TimeRangeSelectorView, independent: true },
|
|
172
177
|
},
|
|
173
178
|
layouts: {
|
|
174
179
|
row: ViewRow,
|
|
@@ -190,6 +195,7 @@ export const dynamicViewConfig = {
|
|
|
190
195
|
textarea: { Component: TextAreaView },
|
|
191
196
|
select: { Component: BaseView },
|
|
192
197
|
base: { Component: BaseView },
|
|
198
|
+
date_input: { Component: DateView },
|
|
193
199
|
file_input: { Component: FileInputView },
|
|
194
200
|
number_with_scale: { Component: NumberWithScaleView },
|
|
195
201
|
monaco_input: { Component: MonacoView },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/dynamic-forms",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "build/cjs/index.js",
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@bem-react/classname": "^1.6.0",
|
|
47
47
|
"@gravity-ui/components": "^3.0.0",
|
|
48
|
+
"@gravity-ui/date-components": "^2.5.0",
|
|
49
|
+
"@gravity-ui/date-utils": "^2.5.3",
|
|
48
50
|
"@gravity-ui/i18n": "^1.2.0",
|
|
49
51
|
"@gravity-ui/icons": "^2.8.1",
|
|
50
52
|
"lodash": "^4.17.20"
|