@teamias/rex-design 0.0.34 → 0.0.36

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.
@@ -5,7 +5,13 @@ export declare const BaseDescriptions: FC<IBaseDescriptionsProps>;
5
5
  type TDataCellItem = GetProps<typeof DataCell>['items'][number];
6
6
  /** 允许自定义参数 */
7
7
  type TDataCellItemExtend = TDataCellItem & Record<string, any>;
8
- export interface IBaseDescriptionsProps extends Omit<GetProps<typeof Descriptions>, 'items'> {
8
+ export interface IBaseDescriptionsProps extends Omit<GetProps<typeof Descriptions>, 'items' | 'column'> {
9
+ /** table layout fixed */
10
+ isFixed?: boolean;
11
+ /** 每个 label 宽度 */
12
+ labelWidth?: string;
13
+ /** 列数 */
14
+ column?: number;
9
15
  /** 主要渲染数据 */
10
16
  items?: Array<{
11
17
  label: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["items", "useDataCellRender", "onDataCellClick"];
2
+ var _excluded = ["column", "labelWidth", "useDataCellRender", "items", "onDataCellClick", "isFixed", "styles"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -8,52 +8,75 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
10
  import { Descriptions } from 'antd';
11
+ import { merge } from 'lodash';
11
12
  import { DataCell } from "../data-cell";
13
+ import { Box } from "./style";
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
13
15
  export var BaseDescriptions = function BaseDescriptions(_ref) {
14
- var items = _ref.items,
16
+ var _ref$column = _ref.column,
17
+ column = _ref$column === void 0 ? 3 : _ref$column,
18
+ _ref$labelWidth = _ref.labelWidth,
19
+ labelWidth = _ref$labelWidth === void 0 ? '120px' : _ref$labelWidth,
15
20
  _ref$useDataCellRende = _ref.useDataCellRender,
16
21
  useDataCellRender = _ref$useDataCellRende === void 0 ? true : _ref$useDataCellRende,
22
+ items = _ref.items,
17
23
  onDataCellClick = _ref.onDataCellClick,
24
+ isFixed = _ref.isFixed,
25
+ styles = _ref.styles,
18
26
  otherProps = _objectWithoutProperties(_ref, _excluded);
19
- return /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({
20
- size: "small"
21
- }, otherProps), {}, {
22
- items: items === null || items === void 0 ? void 0 : items.map(function (item, index) {
23
- try {
24
- var _item$children;
25
- var children = useDataCellRender ? ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map(function (topItem, topIndex) {
26
- return /*#__PURE__*/_jsx(DataCell, {
27
- items: topItem,
28
- onClick: function onClick(cellItem, subItem) {
29
- // console.log(cellItem, subItem);
30
- onDataCellClick === null || onDataCellClick === void 0 || onDataCellClick({
31
- item: topItem,
32
- cellItem: cellItem,
33
- subItem: subItem,
34
- index: index
35
- });
36
- }
37
- }, topIndex);
38
- })) || '-' : item.children || '-';
39
- return _objectSpread(_objectSpread({}, item), {}, {
40
- key: "".concat(index),
41
- children: children
42
- });
43
- } catch (error) {
44
- console.error('BaseDescriptions Error:', error, item, index);
45
- return _objectSpread(_objectSpread({}, item), {}, {
46
- key: "".concat(index),
47
- children: /*#__PURE__*/_jsx("div", {
48
- style: {
49
- color: 'red'
50
- },
51
- children: "\u6570\u636E\u51FA\u73B0\u95EE\u9898,\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\u8F93\u51FA"
52
- })
53
- });
54
- }
55
- })
56
- }));
27
+ return /*#__PURE__*/_jsx(Box, {
28
+ style: {
29
+ '--table-layout': isFixed ? 'fixed' : 'auto',
30
+ '--label-width': labelWidth,
31
+ '--content-width': "".concat(100 / column, "%")
32
+ },
33
+ children: /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({
34
+ size: "small"
35
+ }, otherProps), {}, {
36
+ styles: merge({}, {
37
+ content: {
38
+ padding: '24px 12px'
39
+ },
40
+ label: {
41
+ padding: '12px'
42
+ }
43
+ }, styles),
44
+ items: items === null || items === void 0 ? void 0 : items.map(function (item, index) {
45
+ try {
46
+ var _item$children;
47
+ var children = useDataCellRender ? ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map(function (topItem, topIndex) {
48
+ return /*#__PURE__*/_jsx(DataCell, {
49
+ items: topItem,
50
+ onClick: function onClick(cellItem, subItem) {
51
+ // console.log(cellItem, subItem);
52
+ onDataCellClick === null || onDataCellClick === void 0 || onDataCellClick({
53
+ item: topItem,
54
+ cellItem: cellItem,
55
+ subItem: subItem,
56
+ index: index
57
+ });
58
+ }
59
+ }, topIndex);
60
+ })) || '-' : item.children || '-';
61
+ return _objectSpread(_objectSpread({}, item), {}, {
62
+ key: "".concat(index),
63
+ children: children
64
+ });
65
+ } catch (error) {
66
+ console.error('BaseDescriptions Error:', error, item, index);
67
+ return _objectSpread(_objectSpread({}, item), {}, {
68
+ key: "".concat(index),
69
+ children: /*#__PURE__*/_jsx("div", {
70
+ style: {
71
+ color: 'red'
72
+ },
73
+ children: "\u6570\u636E\u51FA\u73B0\u95EE\u9898,\u8BF7\u67E5\u770B\u63A7\u5236\u53F0\u8F93\u51FA"
74
+ })
75
+ });
76
+ }
77
+ })
78
+ }))
79
+ });
57
80
  };
58
81
 
59
82
  /** 允许自定义参数 */
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Box: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components';
2
+ export var Box = styled.div.withConfig({
3
+ displayName: "Box",
4
+ componentId: "rex-design-aaf4__sc-1bifo7s-0"
5
+ })(["table{table-layout:var(--table-layout) !important;}th.ant-descriptions-item-label{width:var(--label-width);max-width:var(--label-width);min-width:var(--label-width);}td.ant-descriptions-item-content{width:var(--content-width);max-width:var(--content-width);min-width:var(--label-width);}"]);
@@ -1,6 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["descriptionsProps", "fields"],
3
- _excluded2 = ["label", "tooltip", "formItemProps", "rules"];
2
+ var _excluded = ["isFixed", "column", "styles"],
3
+ _excluded2 = ["descriptionsProps", "fields", "labelWidth"],
4
+ _excluded3 = ["label", "tooltip", "formItemProps", "rules"];
4
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -9,14 +10,23 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
9
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
12
  import { Descriptions, Form } from 'antd';
13
+ import { merge } from 'lodash';
12
14
  import { useMemo } from 'react';
13
15
  import { DescriptionsStyle } from "../style";
14
16
  import { BaseForm } from "./base-form";
15
17
  import { jsx as _jsx } from "react/jsx-runtime";
16
18
  export var DescriptionsModel = function DescriptionsModel(_ref) {
17
- var descriptionsProps = _ref.descriptionsProps,
19
+ var _ref$descriptionsProp = _ref.descriptionsProps,
20
+ _ref$descriptionsProp2 = _ref$descriptionsProp === void 0 ? {} : _ref$descriptionsProp,
21
+ isFixed = _ref$descriptionsProp2.isFixed,
22
+ _ref$descriptionsProp3 = _ref$descriptionsProp2.column,
23
+ column = _ref$descriptionsProp3 === void 0 ? 3 : _ref$descriptionsProp3,
24
+ styles = _ref$descriptionsProp2.styles,
25
+ descriptionsProps = _objectWithoutProperties(_ref$descriptionsProp2, _excluded),
18
26
  fields = _ref.fields,
19
- baseFormProps = _objectWithoutProperties(_ref, _excluded);
27
+ _ref$labelWidth = _ref.labelWidth,
28
+ labelWidth = _ref$labelWidth === void 0 ? '120px' : _ref$labelWidth,
29
+ baseFormProps = _objectWithoutProperties(_ref, _excluded2);
20
30
  var descriptionsItems = useMemo(function () {
21
31
  /** 检查field或其subItems是否包含rules */
22
32
  var hasRules = function hasRules(field) {
@@ -38,7 +48,7 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
38
48
  tooltip = field.tooltip,
39
49
  formItemProps = field.formItemProps,
40
50
  rules = field.rules,
41
- otherData = _objectWithoutProperties(field, _excluded2);
51
+ otherData = _objectWithoutProperties(field, _excluded3);
42
52
  return {
43
53
  label: /*#__PURE__*/_jsx(Form.Item, {
44
54
  label: label,
@@ -75,14 +85,23 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
75
85
  })) || [];
76
86
  }, [fields]);
77
87
  return /*#__PURE__*/_jsx(DescriptionsStyle, {
88
+ style: {
89
+ '--table-layout': isFixed ? 'fixed' : 'auto',
90
+ '--label-width': labelWidth,
91
+ '--content-width': "".concat(100 / column, "%")
92
+ },
78
93
  children: /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({
79
- bordered: true,
80
- styles: {
94
+ bordered: true
95
+ }, descriptionsProps), {}, {
96
+ styles: merge({}, {
81
97
  content: {
82
98
  padding: '24px 12px'
99
+ },
100
+ label: {
101
+ padding: '12px'
83
102
  }
84
- }
85
- }, descriptionsProps), {}, {
103
+ }, styles),
104
+ column: column,
86
105
  items: descriptionsItems
87
106
  }))
88
107
  });
@@ -35,9 +35,11 @@ export default (function () {
35
35
  }]
36
36
  }, {
37
37
  field: ['avg_cost_min', 'avg_cost_max'],
38
- valueType: 'inputNumberRangeV2'
38
+ valueType: 'inputNumberRangeV2',
39
+ itemWidth: '100%'
39
40
  }],
40
- hidden: false
41
+ hidden: false,
42
+ span: 3
41
43
  }, {
42
44
  valueType: 'multipleComponents',
43
45
  label: 'multipleComponents',
@@ -8,4 +8,4 @@ export var BaseFormStyle = createGlobalStyle([".base-form-field-group{display:fl
8
8
  export var DescriptionsStyle = styled.div.withConfig({
9
9
  displayName: "DescriptionsStyle",
10
10
  componentId: "rex-design-aaf4__sc-1e1tacy-0"
11
- })([".ant-descriptions-view{overflow:auto;}.ant-form-item-additional{position:absolute;}.ant-descriptions-row{th.ant-descriptions-item-label:has( + td.ant-descriptions-item-content > span:empty ){display:none;}td.ant-descriptions-item-content:has(> span:empty){display:none;}}"]);
11
+ })(["table{table-layout:var(--table-layout) !important;}.ant-descriptions-view{overflow:auto;}th.ant-descriptions-item-label{width:var(--label-width);max-width:var(--label-width);min-width:var(--label-width);}td.ant-descriptions-item-content{width:var(--content-width);max-width:var(--content-width);min-width:var(--label-width);}.ant-form-item-additional{position:absolute;}.ant-descriptions-row{th.ant-descriptions-item-label:has( + td.ant-descriptions-item-content > span:empty ){display:none;}td.ant-descriptions-item-content:has(> span:empty){display:none;}th label.ant-form-item-no-colon{display:block;word-wrap:break-word;&:after{content:initial;}> *{vertical-align:middle;}}}"]);
@@ -26,5 +26,12 @@ export interface IBaseFormProps {
26
26
  /**
27
27
  * Descriptions 组件属性
28
28
  */
29
- descriptionsProps?: Omit<GetProps<typeof Descriptions>, 'items'>;
29
+ descriptionsProps?: IDescriptionsProps;
30
30
  }
31
+ interface IDescriptionsProps extends Omit<GetProps<typeof Descriptions>, 'items' | 'column'> {
32
+ /** 列数 */
33
+ column?: number;
34
+ /** table layout fixed */
35
+ isFixed?: boolean;
36
+ }
37
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",