@gravity-ui/dynamic-forms 1.4.1 → 1.5.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/CHANGELOG.md +7 -0
- package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +19 -0
- package/build/cjs/lib/kit/components/Inputs/ObjectValueInput/index.js +4 -0
- package/build/cjs/lib/kit/components/Inputs/index.js +1 -0
- package/build/cjs/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +15 -0
- package/build/cjs/lib/kit/components/Views/ObjectValueInputView/index.js +4 -0
- package/build/cjs/lib/kit/components/Views/index.js +1 -0
- package/build/cjs/lib/kit/constants/config.js +4 -0
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.d.ts +2 -0
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/ObjectValueInput.js +14 -0
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/ObjectValueInput/index.js +1 -0
- package/build/esm/lib/kit/components/Inputs/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Inputs/index.js +1 -0
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.d.ts +2 -0
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/ObjectValueInputView.js +10 -0
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Views/ObjectValueInputView/index.js +1 -0
- package/build/esm/lib/kit/components/Views/index.d.ts +1 -0
- package/build/esm/lib/kit/components/Views/index.js +1 -0
- package/build/esm/lib/kit/constants/config.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.5.0](https://github.com/gravity-ui/dynamic-forms/compare/v1.4.1...v1.5.0) (2023-04-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **ObjectValue:** added new input object value ([#28](https://github.com/gravity-ui/dynamic-forms/issues/28)) ([67214a1](https://github.com/gravity-ui/dynamic-forms/commit/67214a13f5ed67dd46071caf0d0ad0bee1a4d071))
|
|
9
|
+
|
|
3
10
|
## [1.4.1](https://github.com/gravity-ui/dynamic-forms/compare/v1.4.0...v1.4.1) (2023-04-13)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectValueInput = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
7
|
+
const core_1 = require("../../../../core");
|
|
8
|
+
const OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
9
|
+
const ObjectValueInput = ({ spec, input, name }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const parentOnChange = react_1.default.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => lodash_1.default.set(Object.assign({}, (currentValue || {})), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
|
|
12
|
+
const parentOnUnmount = react_1.default.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
13
|
+
const specProperties = Object.assign({}, spec.properties);
|
|
14
|
+
if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (react_1.default.createElement(core_1.Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME], spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, key: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
|
|
18
|
+
};
|
|
19
|
+
exports.ObjectValueInput = ObjectValueInput;
|
|
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./Checkbox"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./FileInput"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./MultiSelect"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./ObjectBase"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./ObjectValueInput"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./OneOf"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./OneOfCard"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./Secret"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectValueInputView = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const core_1 = require("../../../../core");
|
|
7
|
+
const OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
8
|
+
const ObjectValueInputView = ({ spec, name }) => {
|
|
9
|
+
const specProperties = Object.assign({}, spec.properties);
|
|
10
|
+
if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (react_1.default.createElement(core_1.ViewController, { spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}` }));
|
|
14
|
+
};
|
|
15
|
+
exports.ObjectValueInputView = ObjectValueInputView;
|
|
@@ -9,6 +9,7 @@ tslib_1.__exportStar(require("./MonacoInputView"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./MultiSelectView"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./NumberWithScaleView"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./ObjectBaseView"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./ObjectValueInputView"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./OneOfCardView"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./OneOfView"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./TableArrayView"), exports);
|
|
@@ -61,6 +61,7 @@ exports.dynamicConfig = {
|
|
|
61
61
|
secret: { Component: components_1.Secret, independent: true },
|
|
62
62
|
base: { Component: components_1.ObjectBase, independent: true },
|
|
63
63
|
text_link: { Component: components_1.TextLink, independent: true },
|
|
64
|
+
object_value: { Component: components_1.ObjectValueInput, independent: true },
|
|
64
65
|
},
|
|
65
66
|
layouts: {
|
|
66
67
|
row: components_1.Row,
|
|
@@ -158,6 +159,7 @@ exports.dynamicCardConfig = {
|
|
|
158
159
|
secret: { Component: components_1.Secret, independent: true },
|
|
159
160
|
base: { Component: components_1.ObjectBase, independent: true },
|
|
160
161
|
text_link: { Component: components_1.TextLink, independent: true },
|
|
162
|
+
object_value: { Component: components_1.ObjectValueInput, independent: true },
|
|
161
163
|
},
|
|
162
164
|
layouts: {
|
|
163
165
|
row: components_1.Row2,
|
|
@@ -244,6 +246,7 @@ exports.dynamicViewConfig = {
|
|
|
244
246
|
secret: undefined,
|
|
245
247
|
base: { Component: components_1.ObjectBaseView, independent: true },
|
|
246
248
|
text_link: { Component: components_1.TextLinkView, independent: true },
|
|
249
|
+
object_value: { Component: components_1.ObjectValueInputView, independent: true },
|
|
247
250
|
},
|
|
248
251
|
layouts: {
|
|
249
252
|
row: components_1.ViewRow,
|
|
@@ -323,6 +326,7 @@ exports.dynamicViewCardConfig = {
|
|
|
323
326
|
secret: undefined,
|
|
324
327
|
base: { Component: components_1.ObjectBaseView, independent: true },
|
|
325
328
|
text_link: { Component: components_1.TextLinkView, independent: true },
|
|
329
|
+
object_value: { Component: components_1.ObjectValueInputView, independent: true },
|
|
326
330
|
},
|
|
327
331
|
layouts: {
|
|
328
332
|
row: components_1.ViewRow2,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { Controller } from '../../../../core';
|
|
4
|
+
const OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
5
|
+
export const ObjectValueInput = ({ spec, input, name }) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const parentOnChange = React.useCallback((childName, childValue, childErrors) => input.onChange((currentValue) => _.set(Object.assign({}, (currentValue || {})), childName.split(`${name}.`).join(''), childValue), childErrors), [input.onChange, input.name]);
|
|
8
|
+
const parentOnUnmount = React.useCallback((childName) => input.onChange((currentValue) => currentValue, { [childName]: false }), [input.onChange]);
|
|
9
|
+
const specProperties = Object.assign({}, spec.properties);
|
|
10
|
+
if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (React.createElement(Controller, { initialValue: (_a = input.value) === null || _a === void 0 ? void 0 : _a[OBJECT_VALUE_PROPERTY_NAME], spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, key: `${name}.${OBJECT_VALUE_PROPERTY_NAME}`, parentOnChange: parentOnChange, parentOnUnmount: parentOnUnmount }));
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ObjectValueInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ObjectValueInput';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewController } from '../../../../core';
|
|
3
|
+
const OBJECT_VALUE_PROPERTY_NAME = 'value';
|
|
4
|
+
export const ObjectValueInputView = ({ spec, name }) => {
|
|
5
|
+
const specProperties = Object.assign({}, spec.properties);
|
|
6
|
+
if (!specProperties[OBJECT_VALUE_PROPERTY_NAME]) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (React.createElement(ViewController, { spec: specProperties[OBJECT_VALUE_PROPERTY_NAME], name: `${name}.${OBJECT_VALUE_PROPERTY_NAME}` }));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ObjectValueInputView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ObjectValueInputView';
|
|
@@ -6,6 +6,7 @@ export * from './MonacoInputView';
|
|
|
6
6
|
export * from './MultiSelectView';
|
|
7
7
|
export * from './NumberWithScaleView';
|
|
8
8
|
export * from './ObjectBaseView';
|
|
9
|
+
export * from './ObjectValueInputView';
|
|
9
10
|
export * from './OneOfCardView';
|
|
10
11
|
export * from './OneOfView';
|
|
11
12
|
export * from './TableArrayView';
|
|
@@ -6,6 +6,7 @@ export * from './MonacoInputView';
|
|
|
6
6
|
export * from './MultiSelectView';
|
|
7
7
|
export * from './NumberWithScaleView';
|
|
8
8
|
export * from './ObjectBaseView';
|
|
9
|
+
export * from './ObjectValueInputView';
|
|
9
10
|
export * from './OneOfCardView';
|
|
10
11
|
export * from './OneOfView';
|
|
11
12
|
export * from './TableArrayView';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Accordeon, AccordeonCardLayout, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoInputCard, MonacoView, MonacoViewCard, MultiSelect, MultiSelectView, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, OneOf, OneOfCard, OneOfCardView, OneOfView, Row, Row2, RowVerbose, Secret, Section, Section2, SectionCard, SectionCard2, SectionWithSubtitle, SectionWithSubtitle2, Select, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextLink, TextLinkView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewGroup, ViewGroup2, ViewRow, ViewRow2, ViewSection, ViewSection2, ViewSectionCard, ViewSectionCard2, ViewTableCell, ViewTransparent, } from '../components';
|
|
1
|
+
import { Accordeon, AccordeonCardLayout, ArrayBase, ArrayBaseView, BaseView, CardAccordeon, CardOneOf, CardOneOfView, CardSection, Checkbox, FileInput, FileInputView, Group, Group2, MonacoInput, MonacoInputCard, MonacoView, MonacoViewCard, MultiSelect, MultiSelectView, NumberWithScale, NumberWithScaleView, ObjectBase, ObjectBaseView, ObjectValueInput, ObjectValueInputView, OneOf, OneOfCard, OneOfCardView, OneOfView, Row, Row2, RowVerbose, Secret, Section, Section2, SectionCard, SectionCard2, SectionWithSubtitle, SectionWithSubtitle2, Select, TableArrayInput, TableArrayView, TableCell, Text, TextArea, TextAreaView, TextContent, TextLink, TextLinkView, Transparent, ViewAccordeon, ViewAccordeonCard, ViewCardAccordeon, ViewCardSection, ViewGroup, ViewGroup2, ViewRow, ViewRow2, ViewSection, ViewSection2, ViewSectionCard, ViewSectionCard2, ViewTableCell, ViewTransparent, } from '../components';
|
|
2
2
|
import { getArrayValidator, getBooleanValidator, getNumberValidator, getObjectValidator, getStringValidator, } from '../validators';
|
|
3
3
|
export const dynamicConfig = {
|
|
4
4
|
array: {
|
|
@@ -58,6 +58,7 @@ export const dynamicConfig = {
|
|
|
58
58
|
secret: { Component: Secret, independent: true },
|
|
59
59
|
base: { Component: ObjectBase, independent: true },
|
|
60
60
|
text_link: { Component: TextLink, independent: true },
|
|
61
|
+
object_value: { Component: ObjectValueInput, independent: true },
|
|
61
62
|
},
|
|
62
63
|
layouts: {
|
|
63
64
|
row: Row,
|
|
@@ -155,6 +156,7 @@ export const dynamicCardConfig = {
|
|
|
155
156
|
secret: { Component: Secret, independent: true },
|
|
156
157
|
base: { Component: ObjectBase, independent: true },
|
|
157
158
|
text_link: { Component: TextLink, independent: true },
|
|
159
|
+
object_value: { Component: ObjectValueInput, independent: true },
|
|
158
160
|
},
|
|
159
161
|
layouts: {
|
|
160
162
|
row: Row2,
|
|
@@ -241,6 +243,7 @@ export const dynamicViewConfig = {
|
|
|
241
243
|
secret: undefined,
|
|
242
244
|
base: { Component: ObjectBaseView, independent: true },
|
|
243
245
|
text_link: { Component: TextLinkView, independent: true },
|
|
246
|
+
object_value: { Component: ObjectValueInputView, independent: true },
|
|
244
247
|
},
|
|
245
248
|
layouts: {
|
|
246
249
|
row: ViewRow,
|
|
@@ -320,6 +323,7 @@ export const dynamicViewCardConfig = {
|
|
|
320
323
|
secret: undefined,
|
|
321
324
|
base: { Component: ObjectBaseView, independent: true },
|
|
322
325
|
text_link: { Component: TextLinkView, independent: true },
|
|
326
|
+
object_value: { Component: ObjectValueInputView, independent: true },
|
|
323
327
|
},
|
|
324
328
|
layouts: {
|
|
325
329
|
row: ViewRow2,
|