@gravity-ui/dynamic-forms 4.10.0 → 4.12.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextContent = void 0;
3
+ exports.TextContent = exports.TextContentComponent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const uikit_1 = require("@gravity-ui/uikit");
@@ -9,9 +9,8 @@ const utils_1 = require("../../../utils");
9
9
  const LazyLoader_1 = require("../../LazyLoader");
10
10
  const utils_2 = require("./utils");
11
11
  const b = (0, utils_1.block)('text-content');
12
- const TextContent = (_a) => {
13
- var _b;
14
- var { spec, Layout, input } = _a, restProps = tslib_1.__rest(_a, ["spec", "Layout", "input"]);
12
+ const TextContentComponent = ({ spec, value, Layout, }) => {
13
+ var _a;
15
14
  const { textContentParams, layoutDescription } = spec.viewSpec;
16
15
  const text = react_1.default.useMemo(() => ((textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text) ? textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text : layoutDescription), [layoutDescription, textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text]);
17
16
  if (!text) {
@@ -20,23 +19,36 @@ const TextContent = (_a) => {
20
19
  const iconLib = (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.icon) ? (react_1.default.createElement(LazyLoader_1.LazyLoader, { component: (0, utils_2.loadIcon)(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.icon) })) : null;
21
20
  let content = react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: text } });
22
21
  if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeLabel) {
23
- content = (react_1.default.createElement(uikit_1.Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: input.value, icon: iconLib }, content));
22
+ content = (react_1.default.createElement(uikit_1.Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: value, icon: iconLib }, content));
24
23
  }
25
24
  else {
26
25
  content = (react_1.default.createElement("div", { className: b('wrapper') },
27
- iconLib ? (react_1.default.createElement(uikit_1.Text, { color: (_b = spec.viewSpec.textContentParams) === null || _b === void 0 ? void 0 : _b.iconColor, className: b('icon') }, iconLib)) : null,
26
+ iconLib ? (react_1.default.createElement(uikit_1.Text, { color: (_a = spec.viewSpec.textContentParams) === null || _a === void 0 ? void 0 : _a.iconColor, className: b('icon') }, iconLib)) : null,
28
27
  content,
29
- input.value ? (react_1.default.createElement(react_1.default.Fragment, null,
28
+ value ? (react_1.default.createElement(react_1.default.Fragment, null,
30
29
  react_1.default.createElement(uikit_1.Text, { className: b('separator') }, ":"),
31
- react_1.default.createElement(uikit_1.Text, { color: "secondary" }, input.value))) : null));
30
+ react_1.default.createElement(uikit_1.Text, { color: "secondary" }, value))) : null));
32
31
  }
33
32
  if (Layout) {
34
33
  const _spec = (0, cloneDeep_1.default)(spec);
35
34
  if (!(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text)) {
36
35
  _spec.viewSpec.layoutDescription = undefined;
37
36
  }
38
- return (react_1.default.createElement(Layout, Object.assign({ spec: _spec, input: input }, restProps), content));
37
+ return react_1.default.createElement(Layout, { spec: _spec }, content);
39
38
  }
40
39
  return content;
41
40
  };
41
+ exports.TextContentComponent = TextContentComponent;
42
+ const TextContent = ({ name, spec, Layout, input, arrayInput, meta, layoutProps, }) => {
43
+ const WrappedLayout = react_1.default.useMemo(() => {
44
+ if (Layout) {
45
+ const Component = (props) => {
46
+ return (react_1.default.createElement(Layout, Object.assign({ name: name, input: input, layoutProps: layoutProps, arrayInput: arrayInput, meta: meta }, props)));
47
+ };
48
+ return Component;
49
+ }
50
+ return undefined;
51
+ }, [Layout, layoutProps, input, arrayInput, meta, name]);
52
+ return react_1.default.createElement(exports.TextContentComponent, { spec: spec, value: input.value, Layout: WrappedLayout });
53
+ };
42
54
  exports.TextContent = TextContent;
@@ -2,6 +2,7 @@
2
2
  max-width: 100%;
3
3
  overflow: hidden;
4
4
  text-overflow: ellipsis;
5
+ white-space: nowrap;
5
6
  }
6
7
  .df-long-value_open {
7
8
  white-space: pre-wrap;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextContentView = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const Inputs_1 = require("../Inputs");
7
+ const TextContentView = ({ name, spec, Layout, value }) => {
8
+ const WrappedLayout = react_1.default.useMemo(() => {
9
+ if (Layout) {
10
+ const Component = (props) => {
11
+ const VALUE_STUB = 'if u see this, please create issue about it here: https://github.com/gravity-ui/dynamic-forms/issues/new';
12
+ return react_1.default.createElement(Layout, Object.assign({ name: name, value: VALUE_STUB }, props));
13
+ };
14
+ return Component;
15
+ }
16
+ return undefined;
17
+ }, [Layout, name]);
18
+ return react_1.default.createElement(Inputs_1.TextContentComponent, { spec: spec, value: value, Layout: WrappedLayout });
19
+ };
20
+ exports.TextContentView = TextContentView;
@@ -15,6 +15,7 @@ tslib_1.__exportStar(require("./ObjectValueInputView"), exports);
15
15
  tslib_1.__exportStar(require("./OneOfView"), exports);
16
16
  tslib_1.__exportStar(require("./TableArrayView"), exports);
17
17
  tslib_1.__exportStar(require("./TextAreaView"), exports);
18
+ tslib_1.__exportStar(require("./TextContentView"), exports);
18
19
  tslib_1.__exportStar(require("./TextLinkView"), exports);
19
20
  tslib_1.__exportStar(require("./TimeRangeSelectorView"), exports);
20
21
  tslib_1.__exportStar(require("./DateView"), exports);
@@ -202,7 +202,7 @@ exports.dynamicViewConfig = {
202
202
  file_input: { Component: components_1.FileInputView },
203
203
  number_with_scale: { Component: components_1.NumberWithScaleView },
204
204
  monaco_input: { Component: components_1.MonacoView },
205
- text_content: undefined,
205
+ text_content: { Component: components_1.TextContentView, independent: true },
206
206
  },
207
207
  layouts: {
208
208
  row: components_1.ViewRow,
@@ -1,4 +1,13 @@
1
1
  import React from 'react';
2
- import { StringIndependentInputProps } from '../../../../core';
2
+ import { StringIndependentInput, StringSpec } from '../../../../core';
3
3
  import './TextContent.css';
4
- export declare const TextContent: React.FC<StringIndependentInputProps>;
4
+ export interface TextContentComponentProps {
5
+ spec: StringSpec;
6
+ value?: string;
7
+ Layout?: React.FC<{
8
+ spec: StringSpec;
9
+ children: React.ReactElement;
10
+ }>;
11
+ }
12
+ export declare const TextContentComponent: React.FC<TextContentComponentProps>;
13
+ export declare const TextContent: StringIndependentInput;
@@ -1,4 +1,3 @@
1
- import { __rest } from "tslib";
2
1
  import React from 'react';
3
2
  import { Label, Text } from '@gravity-ui/uikit';
4
3
  import cloneDeep from 'lodash/cloneDeep';
@@ -7,9 +6,8 @@ import { LazyLoader } from '../../LazyLoader';
7
6
  import { loadIcon } from './utils';
8
7
  import './TextContent.css';
9
8
  const b = block('text-content');
10
- export const TextContent = (_a) => {
11
- var _b;
12
- var { spec, Layout, input } = _a, restProps = __rest(_a, ["spec", "Layout", "input"]);
9
+ export const TextContentComponent = ({ spec, value, Layout, }) => {
10
+ var _a;
13
11
  const { textContentParams, layoutDescription } = spec.viewSpec;
14
12
  const text = React.useMemo(() => ((textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text) ? textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text : layoutDescription), [layoutDescription, textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text]);
15
13
  if (!text) {
@@ -18,22 +16,34 @@ export const TextContent = (_a) => {
18
16
  const iconLib = (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.icon) ? (React.createElement(LazyLoader, { component: loadIcon(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.icon) })) : null;
19
17
  let content = React.createElement("span", { dangerouslySetInnerHTML: { __html: text } });
20
18
  if (textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.themeLabel) {
21
- content = (React.createElement(Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: input.value, icon: iconLib }, content));
19
+ content = (React.createElement(Label, { size: "m", theme: textContentParams.themeLabel, className: b(), value: value, icon: iconLib }, content));
22
20
  }
23
21
  else {
24
22
  content = (React.createElement("div", { className: b('wrapper') },
25
- iconLib ? (React.createElement(Text, { color: (_b = spec.viewSpec.textContentParams) === null || _b === void 0 ? void 0 : _b.iconColor, className: b('icon') }, iconLib)) : null,
23
+ iconLib ? (React.createElement(Text, { color: (_a = spec.viewSpec.textContentParams) === null || _a === void 0 ? void 0 : _a.iconColor, className: b('icon') }, iconLib)) : null,
26
24
  content,
27
- input.value ? (React.createElement(React.Fragment, null,
25
+ value ? (React.createElement(React.Fragment, null,
28
26
  React.createElement(Text, { className: b('separator') }, ":"),
29
- React.createElement(Text, { color: "secondary" }, input.value))) : null));
27
+ React.createElement(Text, { color: "secondary" }, value))) : null));
30
28
  }
31
29
  if (Layout) {
32
30
  const _spec = cloneDeep(spec);
33
31
  if (!(textContentParams === null || textContentParams === void 0 ? void 0 : textContentParams.text)) {
34
32
  _spec.viewSpec.layoutDescription = undefined;
35
33
  }
36
- return (React.createElement(Layout, Object.assign({ spec: _spec, input: input }, restProps), content));
34
+ return React.createElement(Layout, { spec: _spec }, content);
37
35
  }
38
36
  return content;
39
37
  };
38
+ export const TextContent = ({ name, spec, Layout, input, arrayInput, meta, layoutProps, }) => {
39
+ const WrappedLayout = React.useMemo(() => {
40
+ if (Layout) {
41
+ const Component = (props) => {
42
+ return (React.createElement(Layout, Object.assign({ name: name, input: input, layoutProps: layoutProps, arrayInput: arrayInput, meta: meta }, props)));
43
+ };
44
+ return Component;
45
+ }
46
+ return undefined;
47
+ }, [Layout, layoutProps, input, arrayInput, meta, name]);
48
+ return React.createElement(TextContentComponent, { spec: spec, value: input.value, Layout: WrappedLayout });
49
+ };
@@ -2,6 +2,7 @@
2
2
  max-width: 100%;
3
3
  overflow: hidden;
4
4
  text-overflow: ellipsis;
5
+ white-space: nowrap;
5
6
  }
6
7
  .df-long-value_open {
7
8
  white-space: pre-wrap;
@@ -0,0 +1,2 @@
1
+ import { StringIndependentView } from '../../../core';
2
+ export declare const TextContentView: StringIndependentView;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { TextContentComponent } from '../Inputs';
3
+ export const TextContentView = ({ name, spec, Layout, value }) => {
4
+ const WrappedLayout = React.useMemo(() => {
5
+ if (Layout) {
6
+ const Component = (props) => {
7
+ const VALUE_STUB = 'if u see this, please create issue about it here: https://github.com/gravity-ui/dynamic-forms/issues/new';
8
+ return React.createElement(Layout, Object.assign({ name: name, value: VALUE_STUB }, props));
9
+ };
10
+ return Component;
11
+ }
12
+ return undefined;
13
+ }, [Layout, name]);
14
+ return React.createElement(TextContentComponent, { spec: spec, value: value, Layout: WrappedLayout });
15
+ };
@@ -12,6 +12,7 @@ export * from './ObjectValueInputView';
12
12
  export * from './OneOfView';
13
13
  export * from './TableArrayView';
14
14
  export * from './TextAreaView';
15
+ export * from './TextContentView';
15
16
  export * from './TextLinkView';
16
17
  export * from './TimeRangeSelectorView';
17
18
  export * from './DateView';
@@ -12,6 +12,7 @@ export * from './ObjectValueInputView';
12
12
  export * from './OneOfView';
13
13
  export * from './TableArrayView';
14
14
  export * from './TextAreaView';
15
+ export * from './TextContentView';
15
16
  export * from './TextLinkView';
16
17
  export * from './TimeRangeSelectorView';
17
18
  export * from './DateView';
@@ -1,4 +1,4 @@
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';
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, TextContentView, 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: {
@@ -199,7 +199,7 @@ export const dynamicViewConfig = {
199
199
  file_input: { Component: FileInputView },
200
200
  number_with_scale: { Component: NumberWithScaleView },
201
201
  monaco_input: { Component: MonacoView },
202
- text_content: undefined,
202
+ text_content: { Component: TextContentView, independent: true },
203
203
  },
204
204
  layouts: {
205
205
  row: ViewRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/dynamic-forms",
3
- "version": "4.10.0",
3
+ "version": "4.12.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/cjs/index.js",