@teamias/rex-design 0.0.35 → 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.
- package/dist/components/base-descriptions/base-descriptions.d.ts +7 -1
- package/dist/components/base-descriptions/base-descriptions.js +63 -40
- package/dist/components/base-descriptions/style.d.ts +2 -0
- package/dist/components/base-descriptions/style.js +5 -0
- package/dist/components/base-form/core/descriptions-model.js +19 -10
- package/dist/components/base-form/style/index.js +1 -1
- package/dist/components/base-form/types/base-form.d.ts +8 -3
- package/package.json +1 -1
|
@@ -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 = ["
|
|
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
|
|
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(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 = ["
|
|
3
|
-
_excluded2 = ["
|
|
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,17 +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
|
|
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
27
|
_ref$labelWidth = _ref.labelWidth,
|
|
20
28
|
labelWidth = _ref$labelWidth === void 0 ? '120px' : _ref$labelWidth,
|
|
21
|
-
baseFormProps = _objectWithoutProperties(_ref,
|
|
22
|
-
var column = (descriptionsProps === null || descriptionsProps === void 0 ? void 0 : descriptionsProps.column) || 3;
|
|
29
|
+
baseFormProps = _objectWithoutProperties(_ref, _excluded2);
|
|
23
30
|
var descriptionsItems = useMemo(function () {
|
|
24
31
|
/** 检查field或其subItems是否包含rules */
|
|
25
32
|
var hasRules = function hasRules(field) {
|
|
@@ -41,7 +48,7 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
|
|
|
41
48
|
tooltip = field.tooltip,
|
|
42
49
|
formItemProps = field.formItemProps,
|
|
43
50
|
rules = field.rules,
|
|
44
|
-
otherData = _objectWithoutProperties(field,
|
|
51
|
+
otherData = _objectWithoutProperties(field, _excluded3);
|
|
45
52
|
return {
|
|
46
53
|
label: /*#__PURE__*/_jsx(Form.Item, {
|
|
47
54
|
label: label,
|
|
@@ -79,20 +86,22 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
|
|
|
79
86
|
}, [fields]);
|
|
80
87
|
return /*#__PURE__*/_jsx(DescriptionsStyle, {
|
|
81
88
|
style: {
|
|
89
|
+
'--table-layout': isFixed ? 'fixed' : 'auto',
|
|
82
90
|
'--label-width': labelWidth,
|
|
83
91
|
'--content-width': "".concat(100 / column, "%")
|
|
84
92
|
},
|
|
85
93
|
children: /*#__PURE__*/_jsx(Descriptions, _objectSpread(_objectSpread({
|
|
86
|
-
bordered: true
|
|
87
|
-
|
|
94
|
+
bordered: true
|
|
95
|
+
}, descriptionsProps), {}, {
|
|
96
|
+
styles: merge({}, {
|
|
88
97
|
content: {
|
|
89
98
|
padding: '24px 12px'
|
|
90
99
|
},
|
|
91
100
|
label: {
|
|
92
101
|
padding: '12px'
|
|
93
102
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
103
|
+
}, styles),
|
|
104
|
+
column: column,
|
|
96
105
|
items: descriptionsItems
|
|
97
106
|
}))
|
|
98
107
|
});
|
|
@@ -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
|
-
})(["table{table-layout:
|
|
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,7 +26,12 @@ export interface IBaseFormProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* Descriptions 组件属性
|
|
28
28
|
*/
|
|
29
|
-
descriptionsProps?:
|
|
30
|
-
column?: number;
|
|
31
|
-
};
|
|
29
|
+
descriptionsProps?: IDescriptionsProps;
|
|
32
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 {};
|