@topthink/components 1.0.56 → 1.0.57
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/es/form-74ef0417.js +2 -0
- package/es/form-74ef0417.js.map +1 -0
- package/es/form-8925a750.js +231 -0
- package/es/form-8925a750.js.map +1 -0
- package/es/form-9c0e638a.js +230 -1
- package/es/form-9c0e638a.js.map +1 -1
- package/es/index-303e1845.js +560 -0
- package/es/index-303e1845.js.map +1 -0
- package/es/index-4f51cece.js +1304 -19
- package/es/index-4f51cece.js.map +1 -1
- package/es/index-6ae8237d.js +67 -0
- package/es/index-6ae8237d.js.map +1 -0
- package/es/index-7a7c06a9.js +40 -0
- package/es/index-7a7c06a9.js.map +1 -0
- package/es/index-9869b1c6.js +1350 -0
- package/es/index-9869b1c6.js.map +1 -0
- package/es/index-d964165a.js +529 -9
- package/es/index-d964165a.js.map +1 -1
- package/es/index.js +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/utils/is-record.d.ts +1 -0
- package/types/errors/unauthorized.d.ts +0 -4
package/es/index-d964165a.js
CHANGED
|
@@ -1,12 +1,308 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import RcTable from 'rc-table';
|
|
3
|
+
import { unstable_batchedUpdates } from 'react-dom';
|
|
4
|
+
import { FormControl, Table as Table$1 } from 'react-bootstrap';
|
|
5
|
+
import { useUrlSearchParams } from 'use-url-search-params';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { useState, useCallback, useRef, useEffect, memo, forwardRef, useImperativeHandle, useMemo } from 'react';
|
|
8
|
+
import { B as Button, a as useDebounce, P as Pagination, b as useControllableState, r as request, N as NumberFormat, L as Loader, T as TableContext, C as Card, S as Space } from './index-4f51cece.js';
|
|
9
|
+
import styled from 'styled-components';
|
|
10
|
+
import Form from './form-9c0e638a.js';
|
|
11
|
+
import 'sweetalert2/dist/sweetalert2.js';
|
|
12
|
+
import 'sweetalert2-react-content';
|
|
13
|
+
import 'lodash';
|
|
14
|
+
import 'axios';
|
|
15
|
+
import 'query-string';
|
|
16
|
+
import 'retry-axios';
|
|
17
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
18
|
+
import 'rc-notification';
|
|
19
|
+
import 'classnames';
|
|
20
|
+
import 'react-async-hook';
|
|
21
|
+
import '@topthink/json-form';
|
|
22
|
+
|
|
23
|
+
const Checkbox = function (_ref) {
|
|
24
|
+
let {
|
|
25
|
+
indeterminate = false,
|
|
26
|
+
...props
|
|
27
|
+
} = _ref;
|
|
28
|
+
const ref = useRef(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (ref.current) {
|
|
31
|
+
ref.current.indeterminate = indeterminate;
|
|
32
|
+
}
|
|
33
|
+
}, [indeterminate]);
|
|
34
|
+
return jsx("input", {
|
|
35
|
+
ref: ref,
|
|
36
|
+
...props,
|
|
37
|
+
className: 'form-check-input',
|
|
38
|
+
type: 'checkbox'
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
function useSelection(rowSelection, rowKey, data) {
|
|
42
|
+
const [keys, setKeys] = useState(() => new Set(rowSelection?.selectedRowKeys || []));
|
|
43
|
+
const getRowKey = record => {
|
|
44
|
+
if (typeof rowKey === 'string') {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return record[rowKey];
|
|
47
|
+
} else {
|
|
48
|
+
return rowKey(record);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const getRecordByKey = key => {
|
|
52
|
+
return data.find(record => {
|
|
53
|
+
return getRowKey(record) === key;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const setSelectedKeys = useCallback(keys => {
|
|
57
|
+
if (!(keys instanceof Set)) {
|
|
58
|
+
keys = new Set(keys);
|
|
59
|
+
}
|
|
60
|
+
setKeys(keys);
|
|
61
|
+
const changedKeys = Array.from(keys);
|
|
62
|
+
const records = changedKeys.map(function (key) {
|
|
63
|
+
return getRecordByKey(key);
|
|
64
|
+
});
|
|
65
|
+
if (rowSelection?.onChange) {
|
|
66
|
+
rowSelection?.onChange(changedKeys, records);
|
|
67
|
+
}
|
|
68
|
+
}, [getRecordByKey]);
|
|
69
|
+
const transformColumns = useCallback(columns => {
|
|
70
|
+
if (!rowSelection) {
|
|
71
|
+
return columns;
|
|
72
|
+
}
|
|
73
|
+
const recordKeys = data.map(getRowKey);
|
|
74
|
+
const checkedCurrentAll = recordKeys.every(function (key) {
|
|
75
|
+
return keys.has(key);
|
|
76
|
+
});
|
|
77
|
+
const checkedCurrentSome = recordKeys.some(function (key) {
|
|
78
|
+
return keys.has(key);
|
|
79
|
+
});
|
|
80
|
+
return [{
|
|
81
|
+
key: 'selection',
|
|
82
|
+
title: jsx(Checkbox, {
|
|
83
|
+
checked: checkedCurrentAll && data.length > 0,
|
|
84
|
+
indeterminate: !checkedCurrentAll && checkedCurrentSome,
|
|
85
|
+
onChange: () => {
|
|
86
|
+
if (checkedCurrentAll) {
|
|
87
|
+
recordKeys.forEach(function (key) {
|
|
88
|
+
keys.delete(key);
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
recordKeys.forEach(function (key) {
|
|
92
|
+
keys.add(key);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
setSelectedKeys(new Set(keys));
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
width: 30,
|
|
99
|
+
align: 'center',
|
|
100
|
+
render(_ref2) {
|
|
101
|
+
let {
|
|
102
|
+
record
|
|
103
|
+
} = _ref2;
|
|
104
|
+
const key = getRowKey(record);
|
|
105
|
+
const checked = keys.has(key);
|
|
106
|
+
return jsx(Checkbox, {
|
|
107
|
+
checked: checked,
|
|
108
|
+
onChange: () => {
|
|
109
|
+
if (checked) {
|
|
110
|
+
keys.delete(key);
|
|
111
|
+
} else {
|
|
112
|
+
keys.add(key);
|
|
113
|
+
}
|
|
114
|
+
setSelectedKeys(new Set(keys));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, ...columns];
|
|
119
|
+
}, [data, rowSelection, keys]);
|
|
120
|
+
return [transformColumns, setSelectedKeys];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var _path$1;
|
|
124
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
125
|
+
const SvgPlusSquare = props => /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
126
|
+
viewBox: "0 0 1024 1024",
|
|
127
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
128
|
+
width: 16,
|
|
129
|
+
height: 16,
|
|
130
|
+
fill: "currentColor"
|
|
131
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
132
|
+
d: "M252.069 906.496h520.283c89.582 0 134.144-44.562 134.144-132.846V250.331c0-88.283-44.562-132.845-134.144-132.845H252.069c-89.143 0-134.583 44.141-134.583 132.845V773.67c0 88.704 45.44 132.845 134.583 132.845zm1.28-68.992c-42.844 0-66.853-22.71-66.853-67.291V253.806c0-44.58 24.01-67.292 66.853-67.292h517.723c42.423 0 66.432 22.711 66.432 67.292v516.388c0 44.58-24.01 67.292-66.432 67.292zM511.78 714.496c22.71 0 36.425-15.854 36.425-40.704V547.365H682.35c24.009 0 40.722-12.874 40.722-35.584 0-23.132-15.854-36.426-40.722-36.426H548.206V340.773c0-24.85-13.715-40.704-36.425-40.704s-35.566 16.713-35.566 40.722v134.583H342.49c-24.85 0-41.142 13.275-41.142 36.407 0 22.71 17.152 35.584 41.142 35.584h133.724v126.427c0 23.99 12.855 40.704 35.566 40.704z"
|
|
133
|
+
})));
|
|
134
|
+
|
|
135
|
+
var _path;
|
|
136
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
137
|
+
const SvgMinusSquare = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
138
|
+
viewBox: "0 0 1024 1024",
|
|
139
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
140
|
+
width: 16,
|
|
141
|
+
height: 16,
|
|
142
|
+
fill: "currentColor"
|
|
143
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
144
|
+
d: "M252.069 906.496h520.283c89.582 0 134.144-44.562 134.144-132.846V250.331c0-88.283-44.562-132.845-134.144-132.845H252.069c-89.143 0-134.583 44.141-134.583 132.845V773.67c0 88.704 45.44 132.845 134.583 132.845zm1.28-68.992c-42.844 0-66.853-22.71-66.853-67.291V253.806c0-44.58 24.01-67.292 66.853-67.292h517.723c42.423 0 66.432 22.711 66.432 67.292v516.388c0 44.58-24.01 67.292-66.432 67.292zm86.582-289.719h344.576c23.991 0 40.704-12.855 40.704-35.566 0-23.15-15.433-36.425-40.704-36.425H339.931c-24.868 0-40.722 13.276-40.722 36.425 0 22.711 16.713 35.566 40.722 35.566z"
|
|
145
|
+
})));
|
|
146
|
+
|
|
147
|
+
function Search(_ref) {
|
|
148
|
+
let {
|
|
149
|
+
data,
|
|
150
|
+
options,
|
|
151
|
+
columns,
|
|
152
|
+
onSearch
|
|
153
|
+
} = _ref;
|
|
154
|
+
const [key, setKey] = useState(0);
|
|
155
|
+
const uiSchema = {
|
|
156
|
+
'ui:col': 10,
|
|
157
|
+
'ui:order': options.order
|
|
158
|
+
};
|
|
159
|
+
const properties = {};
|
|
160
|
+
options.fields.forEach(field => {
|
|
161
|
+
const column = columns.find(column => column.dataIndex === field);
|
|
162
|
+
if (column) {
|
|
163
|
+
const title = column.title;
|
|
164
|
+
if (typeof title === 'string') {
|
|
165
|
+
uiSchema[field] = {
|
|
166
|
+
'ui:col': 4,
|
|
167
|
+
'ui:labelCol': 3,
|
|
168
|
+
'ui:placeholder': '请输入',
|
|
169
|
+
...options.ui?.[field]
|
|
170
|
+
};
|
|
171
|
+
if (column.valueEnum) {
|
|
172
|
+
const valueEnum = column.valueEnum;
|
|
173
|
+
uiSchema[field]['ui:placeholder'] = '请选择';
|
|
174
|
+
return properties[field] = {
|
|
175
|
+
title,
|
|
176
|
+
type: 'string',
|
|
177
|
+
enum: Object.keys(valueEnum).flatMap(key => {
|
|
178
|
+
const text = valueEnum[key].text;
|
|
179
|
+
if (typeof text === 'string') {
|
|
180
|
+
return [key];
|
|
181
|
+
}
|
|
182
|
+
return [];
|
|
183
|
+
}),
|
|
184
|
+
enumNames: Object.keys(valueEnum).flatMap(key => {
|
|
185
|
+
const text = valueEnum[key].text;
|
|
186
|
+
if (typeof text === 'string') {
|
|
187
|
+
return [text];
|
|
188
|
+
}
|
|
189
|
+
return [];
|
|
190
|
+
})
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return properties[field] = {
|
|
194
|
+
title,
|
|
195
|
+
type: 'string'
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
if (options.extraFields) {
|
|
201
|
+
Object.entries(options.extraFields).forEach(_ref2 => {
|
|
202
|
+
let [field, title] = _ref2;
|
|
203
|
+
uiSchema[field] = {
|
|
204
|
+
'ui:col': 4,
|
|
205
|
+
'ui:labelCol': 3,
|
|
206
|
+
'ui:placeholder': '请输入',
|
|
207
|
+
...options.ui?.[field]
|
|
208
|
+
};
|
|
209
|
+
properties[field] = {
|
|
210
|
+
title,
|
|
211
|
+
type: 'string'
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const schema = {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties
|
|
218
|
+
};
|
|
219
|
+
const onSubmit = useCallback(_ref3 => {
|
|
220
|
+
let {
|
|
221
|
+
formData
|
|
222
|
+
} = _ref3;
|
|
223
|
+
onSearch(formData);
|
|
224
|
+
}, [onSearch]);
|
|
225
|
+
const onReset = useCallback(() => {
|
|
226
|
+
setKey(key => key + 1);
|
|
227
|
+
onSearch({});
|
|
228
|
+
}, []);
|
|
229
|
+
return jsx(Container, {
|
|
230
|
+
children: jsx(Form, {
|
|
231
|
+
formContext: {
|
|
232
|
+
layout: 'horizontal'
|
|
233
|
+
},
|
|
234
|
+
schema: schema,
|
|
235
|
+
uiSchema: uiSchema,
|
|
236
|
+
onSubmit: onSubmit,
|
|
237
|
+
formData: data,
|
|
238
|
+
children: jsx("div", {
|
|
239
|
+
className: 'col-2 ms-auto mt-auto',
|
|
240
|
+
children: jsxs("div", {
|
|
241
|
+
className: 'justify-content-end d-flex gap-2 ',
|
|
242
|
+
children: [jsx(Button, {
|
|
243
|
+
className: 'px-4',
|
|
244
|
+
onClick: onReset,
|
|
245
|
+
variant: 'secondary',
|
|
246
|
+
children: "\u91CD\u7F6E"
|
|
247
|
+
}), jsx(Button, {
|
|
248
|
+
className: 'px-4',
|
|
249
|
+
type: 'submit',
|
|
250
|
+
variant: 'primary',
|
|
251
|
+
children: "\u67E5\u8BE2"
|
|
252
|
+
})]
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
}, key);
|
|
257
|
+
}
|
|
258
|
+
const Container = styled.div`
|
|
2
259
|
margin-bottom: 1rem;
|
|
3
|
-
`;
|
|
260
|
+
`;
|
|
261
|
+
function LightSearch(_ref4) {
|
|
262
|
+
let {
|
|
263
|
+
keyword,
|
|
264
|
+
onKeywordChange
|
|
265
|
+
} = _ref4;
|
|
266
|
+
const [value, setValue] = useState(keyword);
|
|
267
|
+
const debouncedOnKeywordChange = useDebounce(onKeywordChange, 500);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
setValue(keyword);
|
|
270
|
+
}, [keyword]);
|
|
271
|
+
const onChange = useCallback(e => {
|
|
272
|
+
setValue(e.target.value);
|
|
273
|
+
debouncedOnKeywordChange(e.target.value);
|
|
274
|
+
}, [debouncedOnKeywordChange, setValue]);
|
|
275
|
+
return jsx(FormControl, {
|
|
276
|
+
value: value,
|
|
277
|
+
onChange: onChange,
|
|
278
|
+
type: 'search',
|
|
279
|
+
placeholder: 'Search...'
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const CustomTHead = styled.thead`
|
|
4
284
|
th {
|
|
5
285
|
padding: 0.5rem 0.5rem;
|
|
6
286
|
border-bottom-width: 1px;
|
|
7
287
|
border-color: var(--bs-border-color);
|
|
8
288
|
}
|
|
9
|
-
|
|
289
|
+
`;
|
|
290
|
+
const components = {
|
|
291
|
+
table: props => {
|
|
292
|
+
return jsx(Table$1, {
|
|
293
|
+
...props,
|
|
294
|
+
className: 'mb-0 align-middle table-hover'
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
header: {
|
|
298
|
+
wrapper(props) {
|
|
299
|
+
return jsx(CustomTHead, {
|
|
300
|
+
...props
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const ExpandIconContainer = styled.a`
|
|
10
306
|
cursor: pointer;
|
|
11
307
|
width: 28px;
|
|
12
308
|
height: 28px;
|
|
@@ -14,21 +310,243 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc
|
|
|
14
310
|
align-items: center;
|
|
15
311
|
justify-content: center;
|
|
16
312
|
vertical-align: middle;
|
|
17
|
-
|
|
313
|
+
`;
|
|
314
|
+
const ExpandIcon = function (_ref) {
|
|
315
|
+
let {
|
|
316
|
+
record,
|
|
317
|
+
expanded,
|
|
318
|
+
expandable,
|
|
319
|
+
onExpand
|
|
320
|
+
} = _ref;
|
|
321
|
+
if (!expandable) return jsx(ExpandIconContainer, {});
|
|
322
|
+
return jsx(ExpandIconContainer, {
|
|
323
|
+
onClick: e => onExpand(record, e),
|
|
324
|
+
children: expanded ? jsx(SvgMinusSquare, {}) : jsx(SvgPlusSquare, {})
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
const CustomPagination = styled(Pagination)`
|
|
18
328
|
margin-bottom: 0;
|
|
19
329
|
justify-content: flex-end;
|
|
20
330
|
margin-top: 1rem;
|
|
21
|
-
`;
|
|
331
|
+
`;
|
|
332
|
+
function isPagination(data) {
|
|
333
|
+
return 'current_page' in data;
|
|
334
|
+
}
|
|
335
|
+
const Table = forwardRef((_ref2, ref) => {
|
|
336
|
+
let {
|
|
337
|
+
source,
|
|
338
|
+
rowKey = 'id',
|
|
339
|
+
paginate = true,
|
|
340
|
+
toolBarRender,
|
|
341
|
+
columns = [],
|
|
342
|
+
search,
|
|
343
|
+
rowSelection,
|
|
344
|
+
card = true,
|
|
345
|
+
expandable = {},
|
|
346
|
+
sync = false,
|
|
347
|
+
...props
|
|
348
|
+
} = _ref2;
|
|
349
|
+
const [data, setData] = useState([]);
|
|
350
|
+
const [pagination, setPagination] = useState(paginate ? {
|
|
351
|
+
total: 0,
|
|
352
|
+
current: 1,
|
|
353
|
+
pageSize: 10
|
|
354
|
+
} : null);
|
|
355
|
+
const [loading, setLoading] = useState(true);
|
|
356
|
+
const [params, setParams] = useUrlSearchParams({});
|
|
357
|
+
//多选
|
|
358
|
+
const [transformColumns, setSelectionRowKeys] = useSelection(rowSelection, rowKey, data);
|
|
359
|
+
const [filters, setFilters] = useControllableState({
|
|
360
|
+
value: sync ? params || {} : undefined,
|
|
361
|
+
defaultValue: {},
|
|
362
|
+
onChange: value => {
|
|
363
|
+
if (sync) {
|
|
364
|
+
setParams(value);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
const [keyword, setKeyword] = useControllableState({
|
|
369
|
+
value: sync ? params.q || '' : undefined,
|
|
370
|
+
defaultValue: '',
|
|
371
|
+
onChange: value => {
|
|
372
|
+
if (sync) {
|
|
373
|
+
setParams({
|
|
374
|
+
q: value || undefined
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
const [page, setPage] = useControllableState({
|
|
380
|
+
value: sync ? params.page || 1 : undefined,
|
|
381
|
+
defaultValue: 1,
|
|
382
|
+
onChange: value => {
|
|
383
|
+
if (sync) {
|
|
384
|
+
setParams({
|
|
385
|
+
page: value || undefined
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
const fetchData = useCallback(async () => {
|
|
391
|
+
setLoading(true);
|
|
392
|
+
setSelectionRowKeys([]);
|
|
393
|
+
try {
|
|
394
|
+
let result;
|
|
395
|
+
const params = {
|
|
396
|
+
...filters,
|
|
397
|
+
q: keyword,
|
|
398
|
+
page: page > 1 ? page : undefined
|
|
399
|
+
};
|
|
400
|
+
if (typeof source === 'string') {
|
|
401
|
+
result = await request({
|
|
402
|
+
url: source,
|
|
403
|
+
params
|
|
404
|
+
});
|
|
405
|
+
} else {
|
|
406
|
+
result = await source(params);
|
|
407
|
+
}
|
|
408
|
+
if (paginate && isPagination(result)) {
|
|
409
|
+
setPagination({
|
|
410
|
+
total: result.total,
|
|
411
|
+
current: result.current_page,
|
|
412
|
+
pageSize: result.per_page
|
|
413
|
+
});
|
|
414
|
+
result = result.data;
|
|
415
|
+
}
|
|
416
|
+
setData(result);
|
|
417
|
+
} catch (e) {} finally {
|
|
418
|
+
setLoading(false);
|
|
419
|
+
}
|
|
420
|
+
}, [source, setData, keyword, page, filters]);
|
|
421
|
+
useEffect(() => {
|
|
422
|
+
fetchData();
|
|
423
|
+
}, [keyword, page, filters]);
|
|
424
|
+
const action = useRef({
|
|
425
|
+
reload: fetchData
|
|
426
|
+
});
|
|
427
|
+
useEffect(() => {
|
|
428
|
+
action.current = {
|
|
429
|
+
reload: fetchData
|
|
430
|
+
};
|
|
431
|
+
}, [fetchData]);
|
|
432
|
+
useImperativeHandle(ref, () => action.current);
|
|
433
|
+
const customColumns = useMemo(() => {
|
|
434
|
+
return transformColumns(columns).map(_ref3 => {
|
|
435
|
+
let {
|
|
436
|
+
render,
|
|
437
|
+
valueType,
|
|
438
|
+
valueEnum,
|
|
439
|
+
...column
|
|
440
|
+
} = _ref3;
|
|
441
|
+
const customColumn = {
|
|
442
|
+
...column
|
|
443
|
+
};
|
|
444
|
+
if (render) {
|
|
445
|
+
customColumn.render = (value, record, index) => {
|
|
446
|
+
return render({
|
|
447
|
+
value,
|
|
448
|
+
record,
|
|
449
|
+
index,
|
|
450
|
+
action: action.current
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
} else if (valueType === 'currency') {
|
|
454
|
+
customColumn.render = value => {
|
|
455
|
+
return jsx(NumberFormat, {
|
|
456
|
+
value: value
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
} else if (valueEnum) {
|
|
460
|
+
customColumn.render = value => {
|
|
461
|
+
if (valueEnum[value]) {
|
|
462
|
+
if (valueEnum[value].status) {
|
|
463
|
+
return jsx("span", {
|
|
464
|
+
className: `text-${valueEnum[value].status}`,
|
|
465
|
+
children: valueEnum[value].text
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return valueEnum[value].text;
|
|
469
|
+
}
|
|
470
|
+
return value;
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
return customColumn;
|
|
474
|
+
});
|
|
475
|
+
}, [columns, transformColumns, action]);
|
|
476
|
+
const children = jsxs(Fragment, {
|
|
477
|
+
children: [jsx(Loader, {
|
|
478
|
+
loading: loading
|
|
479
|
+
}), typeof search === 'object' && jsx(Search, {
|
|
480
|
+
data: filters,
|
|
481
|
+
columns: columns,
|
|
482
|
+
options: search,
|
|
483
|
+
onSearch: data => {
|
|
484
|
+
unstable_batchedUpdates(() => {
|
|
485
|
+
setPage(1);
|
|
486
|
+
setFilters(data);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}), toolBarRender !== false && jsxs(Header, {
|
|
490
|
+
children: [jsx(LeftTools, {
|
|
491
|
+
size: 12,
|
|
492
|
+
children: toolBarRender && toolBarRender(action.current)
|
|
493
|
+
}), jsxs(RightTools, {
|
|
494
|
+
size: 12,
|
|
495
|
+
children: [search === true && jsx(LightSearch, {
|
|
496
|
+
keyword: keyword,
|
|
497
|
+
onKeywordChange: value => {
|
|
498
|
+
unstable_batchedUpdates(() => {
|
|
499
|
+
setPage(1);
|
|
500
|
+
setKeyword(value);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}), jsx(Action, {
|
|
504
|
+
onClick: action.current.reload,
|
|
505
|
+
children: jsx("i", {
|
|
506
|
+
className: 'bi bi-arrow-repeat'
|
|
507
|
+
})
|
|
508
|
+
})]
|
|
509
|
+
})]
|
|
510
|
+
}), jsx(TableContext.Provider, {
|
|
511
|
+
value: true,
|
|
512
|
+
children: jsx(RcTable, {
|
|
513
|
+
...props,
|
|
514
|
+
expandable: {
|
|
515
|
+
expandIcon: ExpandIcon,
|
|
516
|
+
...expandable
|
|
517
|
+
},
|
|
518
|
+
rowKey: rowKey,
|
|
519
|
+
columns: customColumns,
|
|
520
|
+
components: components,
|
|
521
|
+
data: data
|
|
522
|
+
})
|
|
523
|
+
}), pagination && jsx(CustomPagination, {
|
|
524
|
+
...pagination,
|
|
525
|
+
onChange: setPage
|
|
526
|
+
})]
|
|
527
|
+
});
|
|
528
|
+
if (card) {
|
|
529
|
+
return jsx(Card, {
|
|
530
|
+
children: children
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
return children;
|
|
534
|
+
});
|
|
535
|
+
var index = memo(Table);
|
|
536
|
+
const Header = styled.div`
|
|
22
537
|
display: flex;
|
|
23
538
|
justify-content: space-between;
|
|
24
539
|
padding-bottom: 1rem;
|
|
25
540
|
height: 48px;
|
|
26
541
|
border-bottom: 2px solid #212529;
|
|
27
|
-
|
|
542
|
+
`;
|
|
543
|
+
const RightTools = styled(Space)`
|
|
28
544
|
|
|
29
|
-
|
|
545
|
+
`;
|
|
546
|
+
const LeftTools = styled(Space)`
|
|
30
547
|
|
|
31
|
-
|
|
548
|
+
`;
|
|
549
|
+
const Action = styled.span`
|
|
32
550
|
cursor: pointer;
|
|
33
551
|
font-size: 20px;
|
|
34
552
|
line-height: 1;
|
|
@@ -36,5 +554,7 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc
|
|
|
36
554
|
&:hover {
|
|
37
555
|
color: var(--bs-primary);
|
|
38
556
|
}
|
|
39
|
-
`;
|
|
557
|
+
`;
|
|
558
|
+
|
|
559
|
+
export { index as default };
|
|
40
560
|
//# sourceMappingURL=index-d964165a.js.map
|