@ecoding/components.antd 0.4.1 → 0.4.3
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,11 +5,11 @@ import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from
|
|
|
5
5
|
import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
6
6
|
import { CSS } from '@dnd-kit/utilities';
|
|
7
7
|
const SortableItem = (props) => {
|
|
8
|
-
const { columns, i18n, field, index, add, remove, afterRemove, enableSort } = props;
|
|
8
|
+
const { columns, i18n, field, index, add, remove, afterRemove, enableSort, disabled } = props;
|
|
9
9
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
10
10
|
id: props.id
|
|
11
11
|
});
|
|
12
|
-
const trStyle = enableSort ? {
|
|
12
|
+
const trStyle = enableSort && !disabled ? {
|
|
13
13
|
borderBottom: '1px solid #eee',
|
|
14
14
|
transform: CSS.Transform.toString(transform),
|
|
15
15
|
transition,
|
|
@@ -30,8 +30,8 @@ const SortableItem = (props) => {
|
|
|
30
30
|
}, []);
|
|
31
31
|
return (React.createElement("tr", { style: trStyle, ref: setNodeRef },
|
|
32
32
|
React.createElement("td", { style: tdStyle },
|
|
33
|
-
React.createElement("div", { style: enableSort ? { paddingLeft: 20, position: "relative", height: '32px', lineHeight: '32px' } : { height: '32px', lineHeight: '32px' } },
|
|
34
|
-
enableSort ? (React.createElement("span", Object.assign({}, attributes, listeners, { style: {
|
|
33
|
+
React.createElement("div", { style: enableSort && !disabled ? { paddingLeft: 20, position: "relative", height: '32px', lineHeight: '32px' } : { height: '32px', lineHeight: '32px' } },
|
|
34
|
+
enableSort && !disabled ? (React.createElement("span", Object.assign({}, attributes, listeners, { style: {
|
|
35
35
|
position: 'absolute',
|
|
36
36
|
top: '6px',
|
|
37
37
|
left: '-4px',
|
|
@@ -49,7 +49,10 @@ const SortableItem = (props) => {
|
|
|
49
49
|
return (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, position: "sticky", backgroundColor: "#fff" }) },
|
|
50
50
|
React.createElement(Space, null,
|
|
51
51
|
column.render && column.render(field, index, { add, remove }),
|
|
52
|
-
(typeof column.hideRemove == "function" && column.hideRemove(field, index)) || (typeof column.hideRemove == "boolean" && column.hideRemove) ? (React.createElement(Typography.Text, { disabled: true }, i18n ? i18n.$t("global.del", '删除') : '删除')) : (React.createElement(Typography.Text, { style: { cursor: 'pointer' }, type: "danger", onClick: () => {
|
|
52
|
+
(typeof column.hideRemove == "function" && column.hideRemove(field, index)) || (typeof column.hideRemove == "boolean" && column.hideRemove) ? (React.createElement(Typography.Text, { style: { cursor: 'no-drop', 'color': '#ccc' }, disabled: true }, i18n ? i18n.$t("global.del", '删除') : '删除')) : (React.createElement(Typography.Text, { style: disabled ? { cursor: 'no-drop', 'color': '#ccc' } : { cursor: 'pointer' }, type: disabled ? undefined : "danger", disabled: disabled, onClick: () => {
|
|
53
|
+
if (disabled) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
53
56
|
remove(field.name);
|
|
54
57
|
afterRemove && afterRemove(field.name);
|
|
55
58
|
} }, i18n ? i18n.$t("global.del", '删除') : '删除')))));
|
|
@@ -60,12 +63,15 @@ const SortableItem = (props) => {
|
|
|
60
63
|
}
|
|
61
64
|
}),
|
|
62
65
|
needDefaultOperation ? (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, position: "sticky", backgroundColor: "#fff" }) },
|
|
63
|
-
React.createElement(Typography.Text, { style: { cursor: 'pointer' }, type: "danger", onClick: () => {
|
|
66
|
+
React.createElement(Typography.Text, { style: disabled ? { cursor: 'no-drop', 'color': '#ccc' } : { cursor: 'pointer' }, type: disabled ? undefined : "danger", onClick: () => {
|
|
67
|
+
if (disabled) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
64
70
|
remove(field.name);
|
|
65
71
|
afterRemove && afterRemove(field.name);
|
|
66
72
|
} }, i18n ? i18n.$t("global.del", '删除') : '删除'))) : null));
|
|
67
73
|
};
|
|
68
|
-
const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i18n, afterRemove, afterAdd, enableSort, max }) => {
|
|
74
|
+
const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i18n, afterRemove, afterAdd, enableSort, max, disabled }) => {
|
|
69
75
|
const sensors = useSensors(useSensor(PointerSensor));
|
|
70
76
|
const tbodyRef = useRef(null);
|
|
71
77
|
const thStyle = {
|
|
@@ -92,7 +98,7 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
|
|
|
92
98
|
return (React.createElement(Form.List, { name: name, rules: rules || [] }, (fields, { add, remove, move }, { errors }) => {
|
|
93
99
|
return (React.createElement("div", { className: 'm-form-list' },
|
|
94
100
|
React.createElement("div", { ref: tbodyRef, className: "m-form-list-table", style: Object.assign({}, { marginBottom: '4px', paddingBottom: '12px', overflow: "auto", position: 'relative' }, tStyle) },
|
|
95
|
-
React.createElement("table", { style: { width: widths } },
|
|
101
|
+
React.createElement("table", { style: { width: widths || '100%' } },
|
|
96
102
|
React.createElement("colgroup", null,
|
|
97
103
|
React.createElement("col", { style: Object.assign({}, { width: 60 }) }),
|
|
98
104
|
columns.map((column) => {
|
|
@@ -130,9 +136,9 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
|
|
|
130
136
|
}
|
|
131
137
|
} },
|
|
132
138
|
React.createElement(SortableContext, { items: fields.map(field => field.key), strategy: verticalListSortingStrategy }, fields.map((field, index) => {
|
|
133
|
-
return (React.createElement(SortableItem, { columns: columns, index: index, key: field.key, id: field.key, i18n: i18n, field: field, add: add, remove: remove, afterRemove: afterRemove, enableSort: enableSort }));
|
|
139
|
+
return (React.createElement(SortableItem, { columns: columns, index: index, key: field.key, disabled: disabled, id: field.key, i18n: i18n, field: field, add: add, remove: remove, afterRemove: afterRemove, enableSort: enableSort }));
|
|
134
140
|
})))))),
|
|
135
|
-
hideBottom ? null : (React.createElement("div", null,
|
|
141
|
+
hideBottom || disabled ? null : (React.createElement("div", null,
|
|
136
142
|
React.createElement(Button, { icon: React.createElement(PlusCircleOutlined, null), type: "dashed", onClick: () => {
|
|
137
143
|
if (max && fields.length >= max) {
|
|
138
144
|
message.error(i18n ? `i18n.$t("global.max.add", "最多添加条数为:") ${max}` : `最多添加条数为: ${max}`);
|
|
@@ -15,6 +15,7 @@ const NumberInput = (props) => {
|
|
|
15
15
|
return (React.createElement(InputNumber, Object.assign({ style: style, formatter: precision ? (value) => formatter(value, precision) : undefined }, props)));
|
|
16
16
|
};
|
|
17
17
|
NumberInput.defaultProps = {
|
|
18
|
-
max:
|
|
18
|
+
max: 9007199254740992,
|
|
19
|
+
min: -9007199254740992
|
|
19
20
|
};
|
|
20
21
|
export default NumberInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"antd": "5.27.0",
|
|
48
48
|
"axios": "^1.1.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2722154aca74c3d98d413d923c7bab0f94db4b5b"
|
|
51
51
|
}
|