@hanwenbo/x-web-pro-components 0.0.1
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/LICENSE +21 -0
- package/es/blocks/index.d.ts +1 -0
- package/es/blocks/index.js +2 -0
- package/es/blocks/shared.d.ts +24 -0
- package/es/blocks/shared.js +77 -0
- package/es/components/card/index.d.ts +82 -0
- package/es/components/card/index.js +361 -0
- package/es/components/descriptions/index.d.ts +31 -0
- package/es/components/descriptions/index.js +434 -0
- package/es/components/field/index.d.ts +75 -0
- package/es/components/field/index.js +761 -0
- package/es/components/form/captcha.d.ts +19 -0
- package/es/components/form/captcha.js +165 -0
- package/es/components/form/colorPicker.d.ts +7 -0
- package/es/components/form/colorPicker.js +73 -0
- package/es/components/form/fieldControls.d.ts +43 -0
- package/es/components/form/fieldControls.js +282 -0
- package/es/components/form/index.d.ts +285 -0
- package/es/components/form/index.js +2268 -0
- package/es/components/form/loginForm.d.ts +22 -0
- package/es/components/form/loginForm.js +159 -0
- package/es/components/form/schemaForm.d.ts +30 -0
- package/es/components/form/schemaForm.js +644 -0
- package/es/components/form/stepsForm.d.ts +26 -0
- package/es/components/form/stepsForm.js +183 -0
- package/es/components/form/uploadButton.d.ts +20 -0
- package/es/components/form/uploadButton.js +134 -0
- package/es/components/form/uploadDragger.d.ts +13 -0
- package/es/components/form/uploadDragger.js +144 -0
- package/es/components/index.d.ts +9 -0
- package/es/components/index.js +9 -0
- package/es/components/layout/components/Help/index.d.ts +72 -0
- package/es/components/layout/components/Help/index.js +350 -0
- package/es/components/layout/index.d.ts +182 -0
- package/es/components/layout/index.js +892 -0
- package/es/components/list/index.d.ts +80 -0
- package/es/components/list/index.js +431 -0
- package/es/components/provider/context.d.ts +7 -0
- package/es/components/provider/context.js +21 -0
- package/es/components/provider/index.d.ts +28 -0
- package/es/components/provider/index.js +117 -0
- package/es/components/provider/intl.d.ts +38 -0
- package/es/components/provider/intl.js +112 -0
- package/es/components/provider/types.d.ts +37 -0
- package/es/components/provider/types.js +1 -0
- package/es/components/provider/useStyle/index.d.ts +28 -0
- package/es/components/provider/useStyle/index.js +208 -0
- package/es/components/skeleton/index.d.ts +61 -0
- package/es/components/skeleton/index.js +388 -0
- package/es/components/table/dragSortTable.d.ts +8 -0
- package/es/components/table/dragSortTable.js +229 -0
- package/es/components/table/editableTable.d.ts +31 -0
- package/es/components/table/editableTable.js +507 -0
- package/es/components/table/index.d.ts +52 -0
- package/es/components/table/index.js +1554 -0
- package/es/components/table/listToolBar.d.ts +48 -0
- package/es/components/table/listToolBar.js +194 -0
- package/es/components/table/search.d.ts +5 -0
- package/es/components/table/search.js +13 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/types.d.ts +219 -0
- package/es/types.js +1 -0
- package/es/utils/attachPropertiesToComponent.d.ts +1 -0
- package/es/utils/attachPropertiesToComponent.js +6 -0
- package/es/utils/getRequestParams.d.ts +19 -0
- package/es/utils/getRequestParams.js +57 -0
- package/es/utils/getTableListColumns.d.ts +20 -0
- package/es/utils/getTableListColumns.js +36 -0
- package/es/utils/index.d.ts +4 -0
- package/es/utils/index.js +4 -0
- package/es/utils/loading.d.ts +3 -0
- package/es/utils/loading.js +25 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +2 -0
- package/lib/blocks/index.d.ts +1 -0
- package/lib/blocks/index.js +5 -0
- package/lib/blocks/shared.d.ts +24 -0
- package/lib/blocks/shared.js +83 -0
- package/lib/components/card/index.d.ts +82 -0
- package/lib/components/card/index.js +368 -0
- package/lib/components/descriptions/index.d.ts +31 -0
- package/lib/components/descriptions/index.js +440 -0
- package/lib/components/field/index.d.ts +75 -0
- package/lib/components/field/index.js +767 -0
- package/lib/components/form/captcha.d.ts +19 -0
- package/lib/components/form/captcha.js +172 -0
- package/lib/components/form/colorPicker.d.ts +7 -0
- package/lib/components/form/colorPicker.js +79 -0
- package/lib/components/form/fieldControls.d.ts +43 -0
- package/lib/components/form/fieldControls.js +288 -0
- package/lib/components/form/index.d.ts +285 -0
- package/lib/components/form/index.js +2332 -0
- package/lib/components/form/loginForm.d.ts +22 -0
- package/lib/components/form/loginForm.js +165 -0
- package/lib/components/form/schemaForm.d.ts +30 -0
- package/lib/components/form/schemaForm.js +651 -0
- package/lib/components/form/stepsForm.d.ts +26 -0
- package/lib/components/form/stepsForm.js +189 -0
- package/lib/components/form/uploadButton.d.ts +20 -0
- package/lib/components/form/uploadButton.js +141 -0
- package/lib/components/form/uploadDragger.d.ts +13 -0
- package/lib/components/form/uploadDragger.js +151 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +104 -0
- package/lib/components/layout/components/Help/index.d.ts +72 -0
- package/lib/components/layout/components/Help/index.js +356 -0
- package/lib/components/layout/index.d.ts +182 -0
- package/lib/components/layout/index.js +930 -0
- package/lib/components/list/index.d.ts +80 -0
- package/lib/components/list/index.js +438 -0
- package/lib/components/provider/context.d.ts +7 -0
- package/lib/components/provider/context.js +27 -0
- package/lib/components/provider/index.d.ts +28 -0
- package/lib/components/provider/index.js +174 -0
- package/lib/components/provider/intl.d.ts +38 -0
- package/lib/components/provider/intl.js +118 -0
- package/lib/components/provider/types.d.ts +37 -0
- package/lib/components/provider/types.js +5 -0
- package/lib/components/provider/useStyle/index.d.ts +28 -0
- package/lib/components/provider/useStyle/index.js +217 -0
- package/lib/components/skeleton/index.d.ts +61 -0
- package/lib/components/skeleton/index.js +394 -0
- package/lib/components/table/dragSortTable.d.ts +8 -0
- package/lib/components/table/dragSortTable.js +236 -0
- package/lib/components/table/editableTable.d.ts +31 -0
- package/lib/components/table/editableTable.js +514 -0
- package/lib/components/table/index.d.ts +52 -0
- package/lib/components/table/index.js +1699 -0
- package/lib/components/table/listToolBar.d.ts +48 -0
- package/lib/components/table/listToolBar.js +200 -0
- package/lib/components/table/search.d.ts +5 -0
- package/lib/components/table/search.js +20 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +49 -0
- package/lib/types.d.ts +219 -0
- package/lib/types.js +5 -0
- package/lib/utils/attachPropertiesToComponent.d.ts +1 -0
- package/lib/utils/attachPropertiesToComponent.js +12 -0
- package/lib/utils/getRequestParams.d.ts +19 -0
- package/lib/utils/getRequestParams.js +63 -0
- package/lib/utils/getTableListColumns.d.ts +20 -0
- package/lib/utils/getTableListColumns.js +42 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +49 -0
- package/lib/utils/loading.d.ts +3 -0
- package/lib/utils/loading.js +31 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +8 -0
- package/package.json +68 -0
|
@@ -0,0 +1,388 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Card } from '@hanwenbo/x-web-ui/card';
|
|
9
|
+
import { Skeleton, SkeletonAvatar, SkeletonImage, SkeletonInput, SkeletonParagraph, SkeletonTitle } from '@hanwenbo/x-web-ui/skeleton';
|
|
10
|
+
import { cn } from '@hanwenbo/x-web-ui/utils/cn';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export var PageHeaderSkeleton = function PageHeaderSkeleton(_ref) {
|
|
14
|
+
var _ref$active = _ref.active,
|
|
15
|
+
active = _ref$active === void 0 ? true : _ref$active,
|
|
16
|
+
className = _ref.className;
|
|
17
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
18
|
+
className: cn('rounded-2xl border border-border bg-card p-5', className),
|
|
19
|
+
"data-pro-skeleton": "page-header",
|
|
20
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
21
|
+
animated: active,
|
|
22
|
+
width: "32%",
|
|
23
|
+
className: "mb-3"
|
|
24
|
+
}), /*#__PURE__*/_jsx(SkeletonParagraph, {
|
|
25
|
+
animated: active,
|
|
26
|
+
lineCount: 2
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export var ListToolbarSkeleton = function ListToolbarSkeleton(_ref2) {
|
|
31
|
+
var _ref2$active = _ref2.active,
|
|
32
|
+
active = _ref2$active === void 0 ? true : _ref2$active,
|
|
33
|
+
className = _ref2.className;
|
|
34
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
35
|
+
className: cn('flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-border bg-card p-4', className),
|
|
36
|
+
"data-pro-skeleton": "list-toolbar",
|
|
37
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
38
|
+
animated: active,
|
|
39
|
+
width: 180,
|
|
40
|
+
className: "mb-0"
|
|
41
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
42
|
+
className: "flex items-center gap-3",
|
|
43
|
+
children: [/*#__PURE__*/_jsx(SkeletonInput, {
|
|
44
|
+
animated: active,
|
|
45
|
+
width: 200
|
|
46
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
47
|
+
animated: active,
|
|
48
|
+
width: 96,
|
|
49
|
+
height: 40,
|
|
50
|
+
borderRadius: 10
|
|
51
|
+
})]
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export var ListSkeletonItem = function ListSkeletonItem(_ref3) {
|
|
56
|
+
var _ref3$active = _ref3.active,
|
|
57
|
+
active = _ref3$active === void 0 ? true : _ref3$active,
|
|
58
|
+
className = _ref3.className;
|
|
59
|
+
return /*#__PURE__*/_jsx("div", {
|
|
60
|
+
className: cn('rounded-2xl border border-border bg-card p-4', className),
|
|
61
|
+
"data-pro-skeleton": "list-item",
|
|
62
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
63
|
+
className: "flex items-start gap-4",
|
|
64
|
+
children: [/*#__PURE__*/_jsx(SkeletonAvatar, {
|
|
65
|
+
animated: active,
|
|
66
|
+
size: 48
|
|
67
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
68
|
+
className: "min-w-0 flex-1 space-y-3",
|
|
69
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
70
|
+
animated: active,
|
|
71
|
+
width: "28%",
|
|
72
|
+
className: "mb-0 block"
|
|
73
|
+
}), /*#__PURE__*/_jsx(SkeletonParagraph, {
|
|
74
|
+
animated: active,
|
|
75
|
+
lineCount: 2
|
|
76
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
77
|
+
className: "flex items-center gap-2",
|
|
78
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
79
|
+
animated: active,
|
|
80
|
+
width: 72,
|
|
81
|
+
height: 28,
|
|
82
|
+
borderRadius: 999
|
|
83
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
84
|
+
animated: active,
|
|
85
|
+
width: 72,
|
|
86
|
+
height: 28,
|
|
87
|
+
borderRadius: 999
|
|
88
|
+
})]
|
|
89
|
+
})]
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
export var ListSkeleton = function ListSkeleton(_ref4) {
|
|
95
|
+
var _ref4$active = _ref4.active,
|
|
96
|
+
active = _ref4$active === void 0 ? true : _ref4$active,
|
|
97
|
+
_ref4$itemCount = _ref4.itemCount,
|
|
98
|
+
itemCount = _ref4$itemCount === void 0 ? 3 : _ref4$itemCount,
|
|
99
|
+
className = _ref4.className;
|
|
100
|
+
return /*#__PURE__*/_jsx("div", {
|
|
101
|
+
className: cn('space-y-4', className),
|
|
102
|
+
"data-pro-skeleton": "list",
|
|
103
|
+
children: Array.from({
|
|
104
|
+
length: itemCount
|
|
105
|
+
}).map(function (_, index) {
|
|
106
|
+
return /*#__PURE__*/_jsx(ListSkeletonItem, {
|
|
107
|
+
active: active
|
|
108
|
+
}, index);
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
export var TableItemSkeleton = function TableItemSkeleton(_ref5) {
|
|
113
|
+
var _ref5$active = _ref5.active,
|
|
114
|
+
active = _ref5$active === void 0 ? true : _ref5$active,
|
|
115
|
+
_ref5$rowCount = _ref5.rowCount,
|
|
116
|
+
rowCount = _ref5$rowCount === void 0 ? 5 : _ref5$rowCount,
|
|
117
|
+
_ref5$columnCount = _ref5.columnCount,
|
|
118
|
+
columnCount = _ref5$columnCount === void 0 ? 4 : _ref5$columnCount,
|
|
119
|
+
className = _ref5.className;
|
|
120
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
121
|
+
className: cn('overflow-hidden rounded-2xl border border-border bg-card', className),
|
|
122
|
+
"data-pro-skeleton": "table",
|
|
123
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
124
|
+
className: "bg-muted/20 grid gap-3 border-b border-border px-4 py-3",
|
|
125
|
+
style: {
|
|
126
|
+
gridTemplateColumns: "repeat(".concat(columnCount, ", minmax(0, 1fr))")
|
|
127
|
+
},
|
|
128
|
+
children: Array.from({
|
|
129
|
+
length: columnCount
|
|
130
|
+
}).map(function (_, index) {
|
|
131
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
132
|
+
animated: active,
|
|
133
|
+
height: 14,
|
|
134
|
+
width: "72%"
|
|
135
|
+
}, index);
|
|
136
|
+
})
|
|
137
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
138
|
+
className: "space-y-3 px-4 py-4",
|
|
139
|
+
children: Array.from({
|
|
140
|
+
length: rowCount
|
|
141
|
+
}).map(function (_, rowIndex) {
|
|
142
|
+
return /*#__PURE__*/_jsx("div", {
|
|
143
|
+
className: "grid gap-3",
|
|
144
|
+
style: {
|
|
145
|
+
gridTemplateColumns: "repeat(".concat(columnCount, ", minmax(0, 1fr))")
|
|
146
|
+
},
|
|
147
|
+
children: Array.from({
|
|
148
|
+
length: columnCount
|
|
149
|
+
}).map(function (__, columnIndex) {
|
|
150
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
151
|
+
animated: active,
|
|
152
|
+
height: 14,
|
|
153
|
+
width: columnIndex === columnCount - 1 ? '54%' : '88%'
|
|
154
|
+
}, columnIndex);
|
|
155
|
+
})
|
|
156
|
+
}, rowIndex);
|
|
157
|
+
})
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
export var TableSkeleton = TableItemSkeleton;
|
|
162
|
+
export var DescriptionsSkeleton = function DescriptionsSkeleton(_ref6) {
|
|
163
|
+
var _ref6$active = _ref6.active,
|
|
164
|
+
active = _ref6$active === void 0 ? true : _ref6$active,
|
|
165
|
+
_ref6$column = _ref6.column,
|
|
166
|
+
column = _ref6$column === void 0 ? 3 : _ref6$column,
|
|
167
|
+
className = _ref6.className;
|
|
168
|
+
return /*#__PURE__*/_jsx("div", {
|
|
169
|
+
className: cn('grid gap-4', className),
|
|
170
|
+
style: {
|
|
171
|
+
gridTemplateColumns: "repeat(".concat(Math.max(1, column), ", minmax(0, 1fr))")
|
|
172
|
+
},
|
|
173
|
+
"data-pro-skeleton": "descriptions",
|
|
174
|
+
children: Array.from({
|
|
175
|
+
length: Math.max(column, 3)
|
|
176
|
+
}).map(function (_, index) {
|
|
177
|
+
return /*#__PURE__*/_jsxs(Card, {
|
|
178
|
+
bodyClassName: "space-y-3",
|
|
179
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
180
|
+
animated: active,
|
|
181
|
+
height: 14,
|
|
182
|
+
width: "32%",
|
|
183
|
+
className: "block"
|
|
184
|
+
}), /*#__PURE__*/_jsx(SkeletonTitle, {
|
|
185
|
+
animated: active,
|
|
186
|
+
width: "56%",
|
|
187
|
+
className: "mb-0 block"
|
|
188
|
+
}), /*#__PURE__*/_jsx(SkeletonParagraph, {
|
|
189
|
+
animated: active,
|
|
190
|
+
lineCount: 2
|
|
191
|
+
})]
|
|
192
|
+
}, index);
|
|
193
|
+
})
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
var ResultPageSkeletonView = function ResultPageSkeletonView(_ref7) {
|
|
197
|
+
var _ref7$active = _ref7.active,
|
|
198
|
+
active = _ref7$active === void 0 ? true : _ref7$active,
|
|
199
|
+
className = _ref7.className,
|
|
200
|
+
_ref7$pageHeader = _ref7.pageHeader,
|
|
201
|
+
pageHeader = _ref7$pageHeader === void 0 ? true : _ref7$pageHeader;
|
|
202
|
+
return /*#__PURE__*/_jsxs(Card, {
|
|
203
|
+
className: cn('flex min-h-[320px] flex-col items-center justify-center gap-5', className),
|
|
204
|
+
"data-pro-skeleton": "result",
|
|
205
|
+
children: [pageHeader !== false ? /*#__PURE__*/_jsxs("div", {
|
|
206
|
+
className: "self-stretch",
|
|
207
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
208
|
+
animated: active,
|
|
209
|
+
width: "32%",
|
|
210
|
+
className: "mb-3"
|
|
211
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
212
|
+
animated: active,
|
|
213
|
+
width: 200,
|
|
214
|
+
height: 14
|
|
215
|
+
})]
|
|
216
|
+
}) : null, /*#__PURE__*/_jsx(Skeleton, {
|
|
217
|
+
animated: active,
|
|
218
|
+
width: 72,
|
|
219
|
+
height: 72,
|
|
220
|
+
borderRadius: 999
|
|
221
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
222
|
+
className: "flex w-full max-w-[420px] flex-col items-center gap-3",
|
|
223
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
224
|
+
animated: active,
|
|
225
|
+
width: "44%",
|
|
226
|
+
className: "mb-0"
|
|
227
|
+
}), /*#__PURE__*/_jsx(SkeletonParagraph, {
|
|
228
|
+
animated: active,
|
|
229
|
+
lineCount: 2,
|
|
230
|
+
className: "w-full"
|
|
231
|
+
})]
|
|
232
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
233
|
+
className: "flex items-center gap-3",
|
|
234
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
235
|
+
animated: active,
|
|
236
|
+
width: 108,
|
|
237
|
+
height: 40,
|
|
238
|
+
borderRadius: 10
|
|
239
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
240
|
+
animated: active,
|
|
241
|
+
width: 108,
|
|
242
|
+
height: 40,
|
|
243
|
+
borderRadius: 10
|
|
244
|
+
})]
|
|
245
|
+
})]
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
export var ProSkeleton = function ProSkeleton(_ref8) {
|
|
249
|
+
var _ref8$type = _ref8.type,
|
|
250
|
+
type = _ref8$type === void 0 ? 'list' : _ref8$type,
|
|
251
|
+
_ref8$active = _ref8.active,
|
|
252
|
+
active = _ref8$active === void 0 ? true : _ref8$active,
|
|
253
|
+
_ref8$pageHeader = _ref8.pageHeader,
|
|
254
|
+
pageHeader = _ref8$pageHeader === void 0 ? true : _ref8$pageHeader,
|
|
255
|
+
_ref8$toolbar = _ref8.toolbar,
|
|
256
|
+
toolbar = _ref8$toolbar === void 0 ? true : _ref8$toolbar,
|
|
257
|
+
_ref8$itemCount = _ref8.itemCount,
|
|
258
|
+
itemCount = _ref8$itemCount === void 0 ? 5 : _ref8$itemCount,
|
|
259
|
+
_ref8$rowCount = _ref8.rowCount,
|
|
260
|
+
rowCount = _ref8$rowCount === void 0 ? 5 : _ref8$rowCount,
|
|
261
|
+
_ref8$columnCount = _ref8.columnCount,
|
|
262
|
+
columnCount = _ref8$columnCount === void 0 ? 4 : _ref8$columnCount,
|
|
263
|
+
_ref8$column = _ref8.column,
|
|
264
|
+
column = _ref8$column === void 0 ? 3 : _ref8$column,
|
|
265
|
+
_ref8$statistic = _ref8.statistic,
|
|
266
|
+
statistic = _ref8$statistic === void 0 ? false : _ref8$statistic,
|
|
267
|
+
actionButton = _ref8.actionButton,
|
|
268
|
+
className = _ref8.className,
|
|
269
|
+
list = _ref8.list;
|
|
270
|
+
var normalizeListCount = function normalizeListCount(size, fallback) {
|
|
271
|
+
if (size === false) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (typeof size === 'number' && Number.isFinite(size) && size >= 0) {
|
|
275
|
+
return size;
|
|
276
|
+
}
|
|
277
|
+
return fallback;
|
|
278
|
+
};
|
|
279
|
+
var listCount = normalizeListCount(list, itemCount);
|
|
280
|
+
if (type === 'result') {
|
|
281
|
+
return /*#__PURE__*/_jsx(ResultPageSkeletonView, {
|
|
282
|
+
active: active,
|
|
283
|
+
className: className,
|
|
284
|
+
pageHeader: pageHeader
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (type === 'descriptions') {
|
|
288
|
+
var descriptionsListCount = normalizeListCount(list, 4);
|
|
289
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
290
|
+
className: cn('space-y-4', className),
|
|
291
|
+
children: [pageHeader !== false ? /*#__PURE__*/_jsx(PageHeaderSkeleton, {
|
|
292
|
+
active: active
|
|
293
|
+
}) : null, /*#__PURE__*/_jsx(DescriptionsSkeleton, {
|
|
294
|
+
active: active,
|
|
295
|
+
column: column
|
|
296
|
+
}), descriptionsListCount !== false ? /*#__PURE__*/_jsx(TableSkeleton, {
|
|
297
|
+
active: active,
|
|
298
|
+
rowCount: descriptionsListCount
|
|
299
|
+
}) : null]
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (type === 'table') {
|
|
303
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
304
|
+
className: cn('space-y-4', className),
|
|
305
|
+
children: [pageHeader !== false ? /*#__PURE__*/_jsx(PageHeaderSkeleton, {
|
|
306
|
+
active: active
|
|
307
|
+
}) : null, toolbar !== false ? /*#__PURE__*/_jsx(ListToolbarSkeleton, {
|
|
308
|
+
active: active
|
|
309
|
+
}) : null, /*#__PURE__*/_jsx(TableSkeleton, {
|
|
310
|
+
active: active,
|
|
311
|
+
rowCount: rowCount,
|
|
312
|
+
columnCount: columnCount
|
|
313
|
+
})]
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (type === 'pageHeader') {
|
|
317
|
+
return /*#__PURE__*/_jsx(PageHeaderSkeleton, {
|
|
318
|
+
active: active,
|
|
319
|
+
className: className
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
323
|
+
className: cn('space-y-4', className),
|
|
324
|
+
children: [pageHeader !== false ? /*#__PURE__*/_jsx(PageHeaderSkeleton, {
|
|
325
|
+
active: active
|
|
326
|
+
}) : null, statistic !== false ? /*#__PURE__*/_jsx("div", {
|
|
327
|
+
className: "grid gap-4 sm:grid-cols-2 xl:grid-cols-3",
|
|
328
|
+
children: Array.from({
|
|
329
|
+
length: typeof statistic === 'number' ? statistic : 3
|
|
330
|
+
}).map(function (_, index) {
|
|
331
|
+
return /*#__PURE__*/_jsxs(Card, {
|
|
332
|
+
bodyClassName: "space-y-3",
|
|
333
|
+
children: [/*#__PURE__*/_jsx(SkeletonTitle, {
|
|
334
|
+
animated: active,
|
|
335
|
+
width: "24%",
|
|
336
|
+
className: "mb-0 block"
|
|
337
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
338
|
+
animated: active,
|
|
339
|
+
width: "60%",
|
|
340
|
+
height: 28,
|
|
341
|
+
className: "block"
|
|
342
|
+
})]
|
|
343
|
+
}, index);
|
|
344
|
+
})
|
|
345
|
+
}) : null, toolbar !== false ? /*#__PURE__*/_jsx(ListToolbarSkeleton, {
|
|
346
|
+
active: active
|
|
347
|
+
}) : null, actionButton !== false ? /*#__PURE__*/_jsx("div", {
|
|
348
|
+
className: "flex items-center justify-end",
|
|
349
|
+
children: actionButton || /*#__PURE__*/_jsx(Skeleton, {
|
|
350
|
+
animated: active,
|
|
351
|
+
width: 96,
|
|
352
|
+
height: 40
|
|
353
|
+
})
|
|
354
|
+
}) : null, listCount !== false ? /*#__PURE__*/_jsxs("div", {
|
|
355
|
+
className: "grid gap-4 xl:grid-cols-[1.2fr_0.8fr]",
|
|
356
|
+
children: [/*#__PURE__*/_jsx(ListSkeleton, {
|
|
357
|
+
active: active,
|
|
358
|
+
itemCount: listCount
|
|
359
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
360
|
+
className: "space-y-4",
|
|
361
|
+
children: [/*#__PURE__*/_jsx(SkeletonImage, {
|
|
362
|
+
animated: active,
|
|
363
|
+
height: 180
|
|
364
|
+
}), /*#__PURE__*/_jsx(TableSkeleton, {
|
|
365
|
+
active: active,
|
|
366
|
+
rowCount: rowCount,
|
|
367
|
+
columnCount: columnCount
|
|
368
|
+
})]
|
|
369
|
+
})]
|
|
370
|
+
}) : null]
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
export var ListPageSkeleton = function ListPageSkeleton(props) {
|
|
374
|
+
return /*#__PURE__*/_jsx(ProSkeleton, _objectSpread(_objectSpread({}, props), {}, {
|
|
375
|
+
type: "list"
|
|
376
|
+
}));
|
|
377
|
+
};
|
|
378
|
+
export var DescriptionsPageSkeleton = function DescriptionsPageSkeleton(props) {
|
|
379
|
+
return /*#__PURE__*/_jsx(ProSkeleton, _objectSpread(_objectSpread({}, props), {}, {
|
|
380
|
+
type: "descriptions"
|
|
381
|
+
}));
|
|
382
|
+
};
|
|
383
|
+
export var ResultPageSkeleton = function ResultPageSkeleton(props) {
|
|
384
|
+
return /*#__PURE__*/_jsx(ProSkeleton, _objectSpread(_objectSpread({}, props), {}, {
|
|
385
|
+
type: "result"
|
|
386
|
+
}));
|
|
387
|
+
};
|
|
388
|
+
export default ProSkeleton;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ProTableProps } from '../../types';
|
|
3
|
+
export interface DragSortTableProps<RecordType extends Record<string, any> = Record<string, any>> extends Omit<ProTableProps<RecordType>, 'request'> {
|
|
4
|
+
dragSortKey?: string;
|
|
5
|
+
onDragSortEnd?: (beforeIndex: number, afterIndex: number, newDataSource: RecordType[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const DragSortTable: <RecordType extends Record<string, any> = Record<string, any>>({ rowKey, dataSource: controlledDataSource, columns, dragSortKey, onDataSourceChange, onDragSortEnd, headerTitle, toolBarRender, className, ...tableProps }: DragSortTableProps<RecordType>) => React.JSX.Element;
|
|
8
|
+
export default DragSortTable;
|
|
@@ -0,0 +1,229 @@
|
|
|
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 = ["rowKey", "dataSource", "columns", "dragSortKey", "onDataSourceChange", "onDragSortEnd", "headerTitle", "toolBarRender", "className"];
|
|
3
|
+
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
4
|
+
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
|
+
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
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
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
|
+
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
22
|
+
import { GripVertical } from 'lucide-react';
|
|
23
|
+
import { Card } from '@hanwenbo/x-web-ui/card';
|
|
24
|
+
import { Table } from '@hanwenbo/x-web-ui/table';
|
|
25
|
+
import { cn } from '@hanwenbo/x-web-ui/utils/cn';
|
|
26
|
+
import { ProField } from "../field";
|
|
27
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
var getValueByDataIndex = function getValueByDataIndex(record, dataIndex) {
|
|
30
|
+
if (!dataIndex) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
var path = Array.isArray(dataIndex) ? dataIndex : [dataIndex];
|
|
34
|
+
return path.reduce(function (current, key) {
|
|
35
|
+
return current == null ? current : current[key];
|
|
36
|
+
}, record);
|
|
37
|
+
};
|
|
38
|
+
var move = function move(list, from, to) {
|
|
39
|
+
var next = _toConsumableArray(list);
|
|
40
|
+
var _next$splice = next.splice(from, 1),
|
|
41
|
+
_next$splice2 = _slicedToArray(_next$splice, 1),
|
|
42
|
+
item = _next$splice2[0];
|
|
43
|
+
next.splice(to, 0, item);
|
|
44
|
+
return next;
|
|
45
|
+
};
|
|
46
|
+
export var DragSortTable = function DragSortTable(_ref) {
|
|
47
|
+
var _ref$rowKey = _ref.rowKey,
|
|
48
|
+
rowKey = _ref$rowKey === void 0 ? 'id' : _ref$rowKey,
|
|
49
|
+
controlledDataSource = _ref.dataSource,
|
|
50
|
+
columns = _ref.columns,
|
|
51
|
+
dragSortKey = _ref.dragSortKey,
|
|
52
|
+
onDataSourceChange = _ref.onDataSourceChange,
|
|
53
|
+
onDragSortEnd = _ref.onDragSortEnd,
|
|
54
|
+
headerTitle = _ref.headerTitle,
|
|
55
|
+
toolBarRender = _ref.toolBarRender,
|
|
56
|
+
className = _ref.className,
|
|
57
|
+
tableProps = _objectWithoutProperties(_ref, _excluded);
|
|
58
|
+
var _useState = useState(controlledDataSource || []),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
rows = _useState2[0],
|
|
61
|
+
setRows = _useState2[1];
|
|
62
|
+
var _useState3 = useState(null),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
draggingKey = _useState4[0],
|
|
65
|
+
setDraggingKey = _useState4[1];
|
|
66
|
+
var _useState5 = useState(null),
|
|
67
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
68
|
+
dragOverKey = _useState6[0],
|
|
69
|
+
setDragOverKey = _useState6[1];
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
setRows(controlledDataSource || []);
|
|
72
|
+
}, [controlledDataSource]);
|
|
73
|
+
var resolveRowKey = function resolveRowKey(record, index) {
|
|
74
|
+
var _rowKey;
|
|
75
|
+
return typeof rowKey === 'function' ? rowKey(record) : (_rowKey = record[rowKey]) !== null && _rowKey !== void 0 ? _rowKey : index;
|
|
76
|
+
};
|
|
77
|
+
var handleDrop = function handleDrop(targetKey) {
|
|
78
|
+
if (draggingKey == null || draggingKey === targetKey) {
|
|
79
|
+
setDragOverKey(null);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var fromIndex = rows.findIndex(function (item, index) {
|
|
83
|
+
return resolveRowKey(item, index) === draggingKey;
|
|
84
|
+
});
|
|
85
|
+
var toIndex = rows.findIndex(function (item, index) {
|
|
86
|
+
return resolveRowKey(item, index) === targetKey;
|
|
87
|
+
});
|
|
88
|
+
if (fromIndex < 0 || toIndex < 0) {
|
|
89
|
+
setDragOverKey(null);
|
|
90
|
+
setDraggingKey(null);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var nextRows = move(rows, fromIndex, toIndex);
|
|
94
|
+
if (!controlledDataSource) {
|
|
95
|
+
setRows(nextRows);
|
|
96
|
+
}
|
|
97
|
+
onDataSourceChange === null || onDataSourceChange === void 0 || onDataSourceChange(nextRows);
|
|
98
|
+
onDragSortEnd === null || onDragSortEnd === void 0 || onDragSortEnd(fromIndex, toIndex, nextRows);
|
|
99
|
+
setDragOverKey(null);
|
|
100
|
+
setDraggingKey(null);
|
|
101
|
+
};
|
|
102
|
+
var loading = useMemo(function () {
|
|
103
|
+
var _tableProps$loading$s;
|
|
104
|
+
if (tableProps.loading == null) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (typeof tableProps.loading === 'boolean') {
|
|
108
|
+
return tableProps.loading;
|
|
109
|
+
}
|
|
110
|
+
var hasLoadingConfig = Object.keys(tableProps.loading).length > 0;
|
|
111
|
+
if (!hasLoadingConfig) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return _objectSpread(_objectSpread({}, tableProps.loading), {}, {
|
|
115
|
+
spinning: (_tableProps$loading$s = tableProps.loading.spinning) !== null && _tableProps$loading$s !== void 0 ? _tableProps$loading$s : true
|
|
116
|
+
});
|
|
117
|
+
}, [tableProps.loading]);
|
|
118
|
+
var tableColumns = useMemo(function () {
|
|
119
|
+
var mappedColumns = columns.filter(function (column) {
|
|
120
|
+
return !column.hideInTable;
|
|
121
|
+
}).map(function (column) {
|
|
122
|
+
var _column$key, _column$dataIndex;
|
|
123
|
+
var columnKey = String((_column$key = column.key) !== null && _column$key !== void 0 ? _column$key : Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : (_column$dataIndex = column.dataIndex) !== null && _column$dataIndex !== void 0 ? _column$dataIndex : '');
|
|
124
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
125
|
+
render: function render(value, record, index) {
|
|
126
|
+
var rawValue = getValueByDataIndex(record, column.dataIndex);
|
|
127
|
+
var nextValue = column.renderText ? column.renderText(rawValue, record, index) : rawValue;
|
|
128
|
+
var content = column.render ? column.render(value, record, index) : /*#__PURE__*/_jsx(ProField, {
|
|
129
|
+
text: nextValue,
|
|
130
|
+
valueType: column.valueType,
|
|
131
|
+
valueEnum: column.valueEnum
|
|
132
|
+
});
|
|
133
|
+
if (!dragSortKey || columnKey !== dragSortKey) {
|
|
134
|
+
return content;
|
|
135
|
+
}
|
|
136
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
137
|
+
className: "flex items-center gap-2",
|
|
138
|
+
children: [/*#__PURE__*/_jsx(GripVertical, {
|
|
139
|
+
className: "h-4 w-4 text-muted-foreground"
|
|
140
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
141
|
+
className: "min-w-0 flex-1",
|
|
142
|
+
children: content
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
if (!dragSortKey && mappedColumns.length) {
|
|
149
|
+
var _mappedColumns = _toArray(mappedColumns),
|
|
150
|
+
first = _mappedColumns[0],
|
|
151
|
+
rest = _mappedColumns.slice(1);
|
|
152
|
+
return [_objectSpread(_objectSpread({}, first), {}, {
|
|
153
|
+
render: function render(value, record, index) {
|
|
154
|
+
var rawValue = getValueByDataIndex(record, first.dataIndex);
|
|
155
|
+
var nextValue = first.renderText ? first.renderText(rawValue, record, index) : rawValue;
|
|
156
|
+
var content = first.render ? first.render(value, record, index) : /*#__PURE__*/_jsx(ProField, {
|
|
157
|
+
text: nextValue,
|
|
158
|
+
valueType: first.valueType,
|
|
159
|
+
valueEnum: first.valueEnum
|
|
160
|
+
});
|
|
161
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
162
|
+
className: "flex items-center gap-2",
|
|
163
|
+
children: [/*#__PURE__*/_jsx(GripVertical, {
|
|
164
|
+
className: "h-4 w-4 text-muted-foreground"
|
|
165
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
166
|
+
className: "min-w-0 flex-1",
|
|
167
|
+
children: content
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
})].concat(_toConsumableArray(rest));
|
|
172
|
+
}
|
|
173
|
+
return mappedColumns;
|
|
174
|
+
}, [columns, dragSortKey]);
|
|
175
|
+
var actions = toolBarRender === null || toolBarRender === void 0 ? void 0 : toolBarRender(undefined, []);
|
|
176
|
+
return /*#__PURE__*/_jsxs(Card, {
|
|
177
|
+
className: cn('overflow-visible', className),
|
|
178
|
+
children: [headerTitle || actions !== null && actions !== void 0 && actions.length ? /*#__PURE__*/_jsxs("div", {
|
|
179
|
+
className: "mb-4 flex flex-wrap items-center justify-between gap-3",
|
|
180
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
181
|
+
className: "text-lg text-foreground",
|
|
182
|
+
children: headerTitle
|
|
183
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
184
|
+
className: "flex flex-wrap items-center gap-2",
|
|
185
|
+
children: actions
|
|
186
|
+
})]
|
|
187
|
+
}) : null, /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({}, tableProps), {}, {
|
|
188
|
+
loading: loading,
|
|
189
|
+
rowKey: rowKey,
|
|
190
|
+
columns: tableColumns,
|
|
191
|
+
dataSource: rows,
|
|
192
|
+
rowClassName: function rowClassName(record, index) {
|
|
193
|
+
var _tableProps$rowClassN;
|
|
194
|
+
return cn(draggingKey === resolveRowKey(record) && 'opacity-50', dragOverKey === resolveRowKey(record) && 'ring-2 ring-primary/30', (_tableProps$rowClassN = tableProps.rowClassName) === null || _tableProps$rowClassN === void 0 ? void 0 : _tableProps$rowClassN.call(tableProps, record, index));
|
|
195
|
+
},
|
|
196
|
+
onRow: function onRow(record, index) {
|
|
197
|
+
var _tableProps$onRow;
|
|
198
|
+
return _objectSpread(_objectSpread({}, (_tableProps$onRow = tableProps.onRow) === null || _tableProps$onRow === void 0 ? void 0 : _tableProps$onRow.call(tableProps, record, index !== null && index !== void 0 ? index : 0)), {}, {
|
|
199
|
+
draggable: true,
|
|
200
|
+
'data-testid': "drag-row-".concat(resolveRowKey(record)),
|
|
201
|
+
onDragStart: function onDragStart(event) {
|
|
202
|
+
var _tableProps$onRow2, _tableProps$onRow2$on;
|
|
203
|
+
setDraggingKey(resolveRowKey(record));
|
|
204
|
+
(_tableProps$onRow2 = tableProps.onRow) === null || _tableProps$onRow2 === void 0 || (_tableProps$onRow2 = _tableProps$onRow2.call(tableProps, record, index !== null && index !== void 0 ? index : 0)) === null || _tableProps$onRow2 === void 0 || (_tableProps$onRow2$on = _tableProps$onRow2.onDragStart) === null || _tableProps$onRow2$on === void 0 || _tableProps$onRow2$on.call(_tableProps$onRow2, event);
|
|
205
|
+
},
|
|
206
|
+
onDragOver: function onDragOver(event) {
|
|
207
|
+
var _tableProps$onRow3, _tableProps$onRow3$on;
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
setDragOverKey(resolveRowKey(record));
|
|
210
|
+
(_tableProps$onRow3 = tableProps.onRow) === null || _tableProps$onRow3 === void 0 || (_tableProps$onRow3 = _tableProps$onRow3.call(tableProps, record, index !== null && index !== void 0 ? index : 0)) === null || _tableProps$onRow3 === void 0 || (_tableProps$onRow3$on = _tableProps$onRow3.onDragOver) === null || _tableProps$onRow3$on === void 0 || _tableProps$onRow3$on.call(_tableProps$onRow3, event);
|
|
211
|
+
},
|
|
212
|
+
onDrop: function onDrop(event) {
|
|
213
|
+
var _tableProps$onRow4, _tableProps$onRow4$on;
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
handleDrop(resolveRowKey(record));
|
|
216
|
+
(_tableProps$onRow4 = tableProps.onRow) === null || _tableProps$onRow4 === void 0 || (_tableProps$onRow4 = _tableProps$onRow4.call(tableProps, record, index !== null && index !== void 0 ? index : 0)) === null || _tableProps$onRow4 === void 0 || (_tableProps$onRow4$on = _tableProps$onRow4.onDrop) === null || _tableProps$onRow4$on === void 0 || _tableProps$onRow4$on.call(_tableProps$onRow4, event);
|
|
217
|
+
},
|
|
218
|
+
onDragEnd: function onDragEnd(event) {
|
|
219
|
+
var _tableProps$onRow5, _tableProps$onRow5$on;
|
|
220
|
+
setDraggingKey(null);
|
|
221
|
+
setDragOverKey(null);
|
|
222
|
+
(_tableProps$onRow5 = tableProps.onRow) === null || _tableProps$onRow5 === void 0 || (_tableProps$onRow5 = _tableProps$onRow5.call(tableProps, record, index !== null && index !== void 0 ? index : 0)) === null || _tableProps$onRow5 === void 0 || (_tableProps$onRow5$on = _tableProps$onRow5.onDragEnd) === null || _tableProps$onRow5$on === void 0 || _tableProps$onRow5$on.call(_tableProps$onRow5, event);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}))]
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
export default DragSortTable;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ProTableProps } from '../../types';
|
|
3
|
+
declare type EditableType = 'single' | 'multiple';
|
|
4
|
+
export interface EditableTableAction<RecordType = any> {
|
|
5
|
+
save: () => void;
|
|
6
|
+
cancel: () => void;
|
|
7
|
+
delete: () => void;
|
|
8
|
+
edit: () => void;
|
|
9
|
+
record: RecordType;
|
|
10
|
+
}
|
|
11
|
+
export interface EditableConfig<RecordType = any> {
|
|
12
|
+
type?: EditableType;
|
|
13
|
+
editableKeys?: React.Key[];
|
|
14
|
+
onChange?: (editableKeys: React.Key[], editableRows: RecordType[]) => void;
|
|
15
|
+
onSave?: (key: React.Key, record: RecordType, originRow: RecordType, newLine?: boolean) => Promise<void> | void;
|
|
16
|
+
onDelete?: (key: React.Key, record: RecordType) => Promise<void> | void;
|
|
17
|
+
onCancel?: (key: React.Key, record: RecordType) => void;
|
|
18
|
+
onValuesChange?: (record: RecordType, dataSource: RecordType[]) => void;
|
|
19
|
+
actionRender?: (row: RecordType, action: EditableTableAction<RecordType>, defaultDom: React.ReactNode[]) => React.ReactNode[];
|
|
20
|
+
}
|
|
21
|
+
export interface RecordCreatorProps<RecordType = any> {
|
|
22
|
+
record: RecordType | (() => RecordType);
|
|
23
|
+
creatorButtonText?: React.ReactNode;
|
|
24
|
+
position?: 'top' | 'bottom';
|
|
25
|
+
}
|
|
26
|
+
export interface EditableTableProps<RecordType extends Record<string, any> = Record<string, any>> extends Omit<ProTableProps<RecordType>, 'request'> {
|
|
27
|
+
editable?: EditableConfig<RecordType> | false;
|
|
28
|
+
recordCreatorProps?: RecordCreatorProps<RecordType> | false;
|
|
29
|
+
}
|
|
30
|
+
export declare const EditableTable: <RecordType extends Record<string, any> = Record<string, any>>({ rowKey, columns, dataSource: controlledDataSource, editable, recordCreatorProps, headerTitle, toolBarRender, pagination, className, onDataSourceChange, ...tableProps }: EditableTableProps<RecordType>) => React.JSX.Element;
|
|
31
|
+
export default EditableTable;
|