@topthink/components 1.0.58 → 1.0.59
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/{editor-widget-ebec8493.js → editor-widget-CQ3zv-Xu.js} +0 -1
- package/es/{image-zoom-912e2b3b.js → image-zoom-OrIPGqh0.js} +0 -1
- package/es/index-PGfJO0Bp.js +39 -0
- package/es/index-PvFKqXZL.js +1 -0
- package/es/{index-563b11c6.js → index-XkUorbN_.js} +13 -14
- package/es/index.js +1 -2
- package/es/{steps-afba29a7.js → steps-b_BcYIwk.js} +1 -2
- package/package.json +15 -15
- package/types/components/button.d.ts +9 -9
- package/types/components/card.d.ts +7 -7
- package/types/components/dimmer.d.ts +7 -7
- package/types/components/error.d.ts +5 -5
- package/types/components/form.d.ts +4 -4
- package/types/components/image-zoom.d.ts +4 -4
- package/types/components/lazy/form/index.d.ts +19 -19
- package/types/components/lazy/form/widgets/editor-widget.d.ts +6 -5
- package/types/components/lazy/image-zoom.d.ts +3 -3
- package/types/components/lazy/steps.d.ts +9 -9
- package/types/components/lazy/table/context.d.ts +2 -2
- package/types/components/lazy/table/index.d.ts +45 -45
- package/types/components/lazy/table/search.d.ts +23 -23
- package/types/components/lazy/table/use-selection.d.ts +3 -3
- package/types/components/loader.d.ts +9 -9
- package/types/components/loading-button.d.ts +7 -7
- package/types/components/modal/confirm.d.ts +8 -8
- package/types/components/modal/index.d.ts +32 -32
- package/types/components/modal/message.d.ts +26 -26
- package/types/components/modal/show.d.ts +3 -3
- package/types/components/modal-button.d.ts +17 -17
- package/types/components/modal-form.d.ts +10 -10
- package/types/components/number-format.d.ts +10 -10
- package/types/components/pagination.d.ts +11 -11
- package/types/components/request-button.d.ts +13 -13
- package/types/components/result.d.ts +15 -15
- package/types/components/space.d.ts +9 -9
- package/types/components/statistic.d.ts +7 -7
- package/types/components/steps.d.ts +10 -10
- package/types/components/table.d.ts +4 -4
- package/types/components/tooltip.d.ts +9 -9
- package/types/hooks/use-callback-ref.d.ts +2 -2
- package/types/hooks/use-controllable-state.d.ts +8 -8
- package/types/hooks/use-debounce.d.ts +2 -2
- package/types/hooks/use-overlay-state.d.ts +16 -16
- package/types/hooks/use-request.d.ts +21 -21
- package/types/hooks/use-safe-state.d.ts +4 -4
- package/types/hooks/use-state-with-callback.d.ts +2 -2
- package/types/hooks/use-unmounted-ref.d.ts +3 -3
- package/types/index.d.ts +33 -33
- package/types/request.d.ts +32 -32
- package/types/utils/is-record.d.ts +1 -1
- package/types/utils/message.d.ts +11 -11
- package/types/utils/toast.d.ts +11 -11
- package/types/utils/types.d.ts +7 -7
- package/types/utils/wait-pay-complete.d.ts +11 -11
- package/es/editor-widget-ebec8493.js.map +0 -1
- package/es/form-01bf45e9.js +0 -233
- package/es/form-01bf45e9.js.map +0 -1
- package/es/form-0a372a24.js +0 -2
- package/es/form-0a372a24.js.map +0 -1
- package/es/form-1791ea39.js +0 -236
- package/es/form-1791ea39.js.map +0 -1
- package/es/form-74ef0417.js +0 -2
- package/es/form-74ef0417.js.map +0 -1
- package/es/form-8925a750.js +0 -231
- package/es/form-8925a750.js.map +0 -1
- package/es/form-95db7eac.js +0 -2
- package/es/form-95db7eac.js.map +0 -1
- package/es/form-9c0e638a.js +0 -231
- package/es/form-9c0e638a.js.map +0 -1
- package/es/image-zoom-912e2b3b.js.map +0 -1
- package/es/index-1930b692.js +0 -67
- package/es/index-1930b692.js.map +0 -1
- package/es/index-1d379f3a.js +0 -562
- package/es/index-1d379f3a.js.map +0 -1
- package/es/index-2b97b70d.js +0 -2
- package/es/index-2b97b70d.js.map +0 -1
- package/es/index-303e1845.js +0 -560
- package/es/index-303e1845.js.map +0 -1
- package/es/index-4f51cece.js +0 -1352
- package/es/index-4f51cece.js.map +0 -1
- package/es/index-5142110c.js +0 -67
- package/es/index-5142110c.js.map +0 -1
- package/es/index-563b11c6.js.map +0 -1
- package/es/index-6ae8237d.js +0 -67
- package/es/index-6ae8237d.js.map +0 -1
- package/es/index-7a7c06a9.js +0 -40
- package/es/index-7a7c06a9.js.map +0 -1
- package/es/index-9869b1c6.js +0 -1350
- package/es/index-9869b1c6.js.map +0 -1
- package/es/index-a214613e.js +0 -40
- package/es/index-a214613e.js.map +0 -1
- package/es/index-a48179db.js +0 -1382
- package/es/index-a48179db.js.map +0 -1
- package/es/index-b34ecf90.js +0 -40
- package/es/index-b34ecf90.js.map +0 -1
- package/es/index-d964165a.js +0 -560
- package/es/index-d964165a.js.map +0 -1
- package/es/index-e17dc6f0.js +0 -40
- package/es/index-e17dc6f0.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/steps-afba29a7.js.map +0 -1
- package/es/steps-c27a3885.js +0 -34
- package/es/steps-c27a3885.js.map +0 -1
package/es/index-a48179db.js
DELETED
|
@@ -1,1382 +0,0 @@
|
|
|
1
|
-
import Swal from 'sweetalert2/dist/sweetalert2.js';
|
|
2
|
-
import withReactContent from 'sweetalert2-react-content';
|
|
3
|
-
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { useRef, useState, useEffect, createContext, Fragment, useContext, useCallback, useMemo, forwardRef, Children, lazy, Suspense, createElement, useImperativeHandle } from 'react';
|
|
6
|
-
import { OverlayTrigger, Tooltip as Tooltip$1, Spinner, Button as Button$1, Modal as Modal$1, Alert, Card as Card$1, Pagination as Pagination$1 } from 'react-bootstrap';
|
|
7
|
-
import { uniqueId, values, debounce } from 'lodash';
|
|
8
|
-
import axios from 'axios';
|
|
9
|
-
import queryString from 'query-string';
|
|
10
|
-
import * as rax from 'retry-axios';
|
|
11
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
12
|
-
import Notification from 'rc-notification';
|
|
13
|
-
import styled, { css } from 'styled-components';
|
|
14
|
-
import classNames from 'classnames';
|
|
15
|
-
import RcSteps from 'rc-steps';
|
|
16
|
-
import 'rc-steps/assets/index.css';
|
|
17
|
-
import { useAsyncCallback } from 'react-async-hook';
|
|
18
|
-
|
|
19
|
-
const CustomSwal = withReactContent(Swal);
|
|
20
|
-
const defaultOptions$1 = {
|
|
21
|
-
confirmButtonText: '确定',
|
|
22
|
-
cancelButtonText: '取消'
|
|
23
|
-
};
|
|
24
|
-
const Message$1 = {
|
|
25
|
-
confirm: async options => {
|
|
26
|
-
const {
|
|
27
|
-
isConfirmed
|
|
28
|
-
} = await CustomSwal.fire({
|
|
29
|
-
...defaultOptions$1,
|
|
30
|
-
icon: 'warning',
|
|
31
|
-
showCancelButton: true,
|
|
32
|
-
...options,
|
|
33
|
-
async preConfirm(data) {
|
|
34
|
-
if (options.preConfirm) {
|
|
35
|
-
try {
|
|
36
|
-
return await options.preConfirm(data);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
if (e instanceof Error) {
|
|
39
|
-
CustomSwal.showValidationMessage(e.message);
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return isConfirmed;
|
|
48
|
-
},
|
|
49
|
-
success: options => {
|
|
50
|
-
CustomSwal.fire({
|
|
51
|
-
...defaultOptions$1,
|
|
52
|
-
toast: true,
|
|
53
|
-
position: 'top',
|
|
54
|
-
icon: 'success',
|
|
55
|
-
timer: 2000,
|
|
56
|
-
showConfirmButton: false,
|
|
57
|
-
...options
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
error: options => {
|
|
61
|
-
CustomSwal.fire({
|
|
62
|
-
...defaultOptions$1,
|
|
63
|
-
toast: true,
|
|
64
|
-
position: 'top',
|
|
65
|
-
icon: 'error',
|
|
66
|
-
timer: 5000,
|
|
67
|
-
showConfirmButton: false,
|
|
68
|
-
...options
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
close: result => {
|
|
72
|
-
CustomSwal.close(result);
|
|
73
|
-
},
|
|
74
|
-
defaults: defaultOptions$1
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
function useStateWithCallback(initState) {
|
|
78
|
-
const callbackRef = useRef(null);
|
|
79
|
-
const [state, setState] = useState(initState);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (callbackRef.current) {
|
|
82
|
-
callbackRef.current();
|
|
83
|
-
callbackRef.current = null;
|
|
84
|
-
}
|
|
85
|
-
}, [state]);
|
|
86
|
-
const setCallbackState = (value, callback) => {
|
|
87
|
-
callbackRef.current = typeof callback === 'function' ? callback : null;
|
|
88
|
-
setState(value);
|
|
89
|
-
};
|
|
90
|
-
return [state, setCallbackState];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const MessageContext = createContext({});
|
|
94
|
-
function wrapMessage(Component) {
|
|
95
|
-
return _ref => {
|
|
96
|
-
let {
|
|
97
|
-
resolve,
|
|
98
|
-
destroy,
|
|
99
|
-
message
|
|
100
|
-
} = _ref;
|
|
101
|
-
const [show, setShow] = useStateWithCallback(true);
|
|
102
|
-
const context = useContext(MessageContext);
|
|
103
|
-
const handleResolve = useCallback(value => {
|
|
104
|
-
setShow(false, () => {
|
|
105
|
-
resolve(value);
|
|
106
|
-
});
|
|
107
|
-
}, [setShow, resolve]);
|
|
108
|
-
const state = useMemo(() => {
|
|
109
|
-
return {
|
|
110
|
-
show,
|
|
111
|
-
onHide: () => handleResolve(),
|
|
112
|
-
onExited: () => destroy(),
|
|
113
|
-
container: context.container
|
|
114
|
-
};
|
|
115
|
-
}, [show, handleResolve, destroy]);
|
|
116
|
-
return jsx(Component, {
|
|
117
|
-
resolve: handleResolve,
|
|
118
|
-
state: state,
|
|
119
|
-
message: message
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function createMessage(Component) {
|
|
124
|
-
return message => {
|
|
125
|
-
return new Promise(resolve => {
|
|
126
|
-
const component = jsx(Component, {
|
|
127
|
-
resolve: resolve,
|
|
128
|
-
destroy: () => {
|
|
129
|
-
hide(component);
|
|
130
|
-
},
|
|
131
|
-
message: message
|
|
132
|
-
});
|
|
133
|
-
show$1(component);
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
let listener = () => void 0;
|
|
138
|
-
let memoryState = new Set();
|
|
139
|
-
const show$1 = modal => {
|
|
140
|
-
memoryState = new Set(memoryState);
|
|
141
|
-
memoryState.add(modal);
|
|
142
|
-
listener(memoryState);
|
|
143
|
-
};
|
|
144
|
-
const hide = modal => {
|
|
145
|
-
memoryState = new Set(memoryState);
|
|
146
|
-
memoryState.delete(modal);
|
|
147
|
-
listener(memoryState);
|
|
148
|
-
};
|
|
149
|
-
function Message(props) {
|
|
150
|
-
const [state, setState] = useState(memoryState);
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
listener = setState;
|
|
153
|
-
}, []);
|
|
154
|
-
return jsx(MessageContext.Provider, {
|
|
155
|
-
value: props,
|
|
156
|
-
children: Array.from(state).map((message, index) => jsx(Fragment, {
|
|
157
|
-
children: message
|
|
158
|
-
}, `message-${index}`))
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function show(Component, options) {
|
|
163
|
-
return createMessage(wrapMessage(Component))(options);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function Tooltip(_ref) {
|
|
167
|
-
let {
|
|
168
|
-
tooltip,
|
|
169
|
-
children,
|
|
170
|
-
placement = 'bottom'
|
|
171
|
-
} = _ref;
|
|
172
|
-
return jsx(OverlayTrigger, {
|
|
173
|
-
placement: placement,
|
|
174
|
-
overlay: jsx(Tooltip$1, {
|
|
175
|
-
id: uniqueId(),
|
|
176
|
-
children: tooltip
|
|
177
|
-
}),
|
|
178
|
-
children: children
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const TableContext = createContext(false);
|
|
183
|
-
|
|
184
|
-
const Button = forwardRef((_ref, ref) => {
|
|
185
|
-
let {
|
|
186
|
-
loading,
|
|
187
|
-
percent,
|
|
188
|
-
disabled,
|
|
189
|
-
children,
|
|
190
|
-
tooltip,
|
|
191
|
-
variant,
|
|
192
|
-
...props
|
|
193
|
-
} = _ref;
|
|
194
|
-
const inTable = useContext(TableContext);
|
|
195
|
-
if (inTable && !variant) {
|
|
196
|
-
variant = 'link';
|
|
197
|
-
}
|
|
198
|
-
if (loading) {
|
|
199
|
-
disabled = true;
|
|
200
|
-
children = jsxs(Fragment$1, {
|
|
201
|
-
children: [jsx(Spinner, {
|
|
202
|
-
ref: ref,
|
|
203
|
-
as: 'span',
|
|
204
|
-
size: 'sm',
|
|
205
|
-
role: 'status',
|
|
206
|
-
"aria-hidden": 'true',
|
|
207
|
-
animation: 'border'
|
|
208
|
-
}), percent ? jsxs("span", {
|
|
209
|
-
className: 'ms-2',
|
|
210
|
-
children: [percent, "%"]
|
|
211
|
-
}) : null]
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const button = jsx(Button$1, {
|
|
215
|
-
ref: ref,
|
|
216
|
-
...props,
|
|
217
|
-
variant: variant,
|
|
218
|
-
disabled: disabled,
|
|
219
|
-
children: children
|
|
220
|
-
});
|
|
221
|
-
if (tooltip) {
|
|
222
|
-
return jsx(Tooltip, {
|
|
223
|
-
tooltip: tooltip,
|
|
224
|
-
children: jsx("span", {
|
|
225
|
-
className: 'd-inline-block',
|
|
226
|
-
children: button
|
|
227
|
-
})
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
return button;
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
const Confirm = function (_ref) {
|
|
234
|
-
let {
|
|
235
|
-
state,
|
|
236
|
-
message: {
|
|
237
|
-
title,
|
|
238
|
-
message,
|
|
239
|
-
okText,
|
|
240
|
-
cancelText
|
|
241
|
-
},
|
|
242
|
-
resolve
|
|
243
|
-
} = _ref;
|
|
244
|
-
return jsxs(Modal$1, {
|
|
245
|
-
centered: true,
|
|
246
|
-
...state,
|
|
247
|
-
children: [jsx(Modal$1.Header, {
|
|
248
|
-
children: jsx(Modal$1.Title, {
|
|
249
|
-
as: 'h5',
|
|
250
|
-
children: title || '确认'
|
|
251
|
-
})
|
|
252
|
-
}), jsx(Modal$1.Body, {
|
|
253
|
-
children: message
|
|
254
|
-
}), jsxs(Modal$1.Footer, {
|
|
255
|
-
children: [jsx(Button, {
|
|
256
|
-
variant: 'secondary',
|
|
257
|
-
onClick: () => resolve(),
|
|
258
|
-
children: cancelText || '取消'
|
|
259
|
-
}), jsx(Button, {
|
|
260
|
-
onClick: () => resolve(true),
|
|
261
|
-
children: okText || '确定'
|
|
262
|
-
})]
|
|
263
|
-
})]
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
function confirm(options) {
|
|
267
|
-
return createMessage(wrapMessage(Confirm))(options);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const Modal = _ref => {
|
|
271
|
-
let {
|
|
272
|
-
header,
|
|
273
|
-
children,
|
|
274
|
-
footer,
|
|
275
|
-
closable = true,
|
|
276
|
-
show,
|
|
277
|
-
cancelText = '取消',
|
|
278
|
-
okText = '确定',
|
|
279
|
-
onOk,
|
|
280
|
-
onCancel,
|
|
281
|
-
onHide,
|
|
282
|
-
okButtonProps,
|
|
283
|
-
bodyAs,
|
|
284
|
-
headerAs = 'h5',
|
|
285
|
-
confirmLoading = false,
|
|
286
|
-
...rest
|
|
287
|
-
} = _ref;
|
|
288
|
-
const [loading, setLoading] = useState(false);
|
|
289
|
-
const okButton = useMemo(() => {
|
|
290
|
-
return jsx(Button, {
|
|
291
|
-
loading: loading || confirmLoading,
|
|
292
|
-
variant: 'primary',
|
|
293
|
-
onClick: async e => {
|
|
294
|
-
setLoading(true);
|
|
295
|
-
try {
|
|
296
|
-
await onOk?.(e);
|
|
297
|
-
if (!e.defaultPrevented) {
|
|
298
|
-
onHide?.();
|
|
299
|
-
}
|
|
300
|
-
} finally {
|
|
301
|
-
setLoading(false);
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
...okButtonProps,
|
|
305
|
-
children: okText
|
|
306
|
-
});
|
|
307
|
-
}, [okButtonProps, okText, onOk, onHide, loading, confirmLoading]);
|
|
308
|
-
const cancelButton = useMemo(() => {
|
|
309
|
-
return jsx(Button, {
|
|
310
|
-
variant: 'secondary',
|
|
311
|
-
onClick: e => {
|
|
312
|
-
onCancel?.(e);
|
|
313
|
-
if (!e.defaultPrevented) {
|
|
314
|
-
onHide?.();
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
children: cancelText
|
|
318
|
-
});
|
|
319
|
-
}, [onCancel, onHide, cancelText]);
|
|
320
|
-
switch (typeof footer) {
|
|
321
|
-
case 'undefined':
|
|
322
|
-
footer = jsxs(Fragment$1, {
|
|
323
|
-
children: [cancelButton, okButton]
|
|
324
|
-
});
|
|
325
|
-
break;
|
|
326
|
-
case 'function':
|
|
327
|
-
footer = footer({
|
|
328
|
-
okButton,
|
|
329
|
-
cancelButton
|
|
330
|
-
});
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
return jsxs(Modal$1, {
|
|
334
|
-
...rest,
|
|
335
|
-
onHide: onHide,
|
|
336
|
-
show: show,
|
|
337
|
-
children: [header && jsx(Modal$1.Header, {
|
|
338
|
-
closeButton: closable,
|
|
339
|
-
children: jsx(Modal$1.Title, {
|
|
340
|
-
as: headerAs,
|
|
341
|
-
children: header
|
|
342
|
-
})
|
|
343
|
-
}), jsx(Modal$1.Body, {
|
|
344
|
-
as: bodyAs,
|
|
345
|
-
children: children
|
|
346
|
-
}), footer && jsx(Modal$1.Footer, {
|
|
347
|
-
children: footer
|
|
348
|
-
})]
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
Modal.Message = Message;
|
|
352
|
-
Modal.confirm = confirm;
|
|
353
|
-
Modal.show = show;
|
|
354
|
-
|
|
355
|
-
class Unauthorized extends Error {
|
|
356
|
-
constructor(url) {
|
|
357
|
-
super('Unauthorized');
|
|
358
|
-
_defineProperty(this, "url", void 0);
|
|
359
|
-
this.url = url;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
let noticeInstance;
|
|
364
|
-
const defaultOptions = {};
|
|
365
|
-
function getNoticeInstance(callback) {
|
|
366
|
-
if (noticeInstance) {
|
|
367
|
-
return callback(noticeInstance);
|
|
368
|
-
}
|
|
369
|
-
Notification.newInstance({
|
|
370
|
-
...defaultOptions,
|
|
371
|
-
prefixCls: 'notification',
|
|
372
|
-
maxCount: 5,
|
|
373
|
-
style: {
|
|
374
|
-
top: 20,
|
|
375
|
-
right: 20
|
|
376
|
-
}
|
|
377
|
-
}, instance => {
|
|
378
|
-
if (noticeInstance) {
|
|
379
|
-
callback(noticeInstance);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
noticeInstance = instance;
|
|
383
|
-
callback(instance);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
const notice = _ref => {
|
|
387
|
-
let {
|
|
388
|
-
type,
|
|
389
|
-
...options
|
|
390
|
-
} = _ref;
|
|
391
|
-
getNoticeInstance(instance => {
|
|
392
|
-
options.duration = 3;
|
|
393
|
-
let variant = type;
|
|
394
|
-
switch (type) {
|
|
395
|
-
case 'error':
|
|
396
|
-
variant = 'danger';
|
|
397
|
-
options.duration = options.closable ? 0 : 5;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
options.content = jsx(Alert, {
|
|
401
|
-
variant: variant,
|
|
402
|
-
children: options.content
|
|
403
|
-
});
|
|
404
|
-
instance.notice(options);
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
const types = ['error', 'success', 'info'];
|
|
408
|
-
const Toast = types.reduce((toast, type) => {
|
|
409
|
-
toast[type] = (content, options) => {
|
|
410
|
-
notice({
|
|
411
|
-
...options,
|
|
412
|
-
type,
|
|
413
|
-
content
|
|
414
|
-
});
|
|
415
|
-
};
|
|
416
|
-
return toast;
|
|
417
|
-
}, {});
|
|
418
|
-
Toast.defaults = defaultOptions;
|
|
419
|
-
|
|
420
|
-
rax.attach();
|
|
421
|
-
axios.defaults.raxConfig = {
|
|
422
|
-
retryDelay: 2000,
|
|
423
|
-
backoffType: 'static',
|
|
424
|
-
shouldRetry: _ref => {
|
|
425
|
-
let {
|
|
426
|
-
config,
|
|
427
|
-
response
|
|
428
|
-
} = _ref;
|
|
429
|
-
if (config.raxConfig?.retryDecider && !config.raxConfig.retryDecider()) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
return config.method?.toUpperCase() === 'GET' && response?.status === 449;
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
axios.defaults.maxContentLength = Infinity;
|
|
436
|
-
axios.defaults.maxBodyLength = Infinity;
|
|
437
|
-
axios.defaults.baseURL = '/api';
|
|
438
|
-
axios.defaults.authTokenName = 'authorization';
|
|
439
|
-
axios.interceptors.request.use(config => {
|
|
440
|
-
const key = config.authTokenName;
|
|
441
|
-
if (key) {
|
|
442
|
-
const token = localStorage.getItem(key);
|
|
443
|
-
if (token) {
|
|
444
|
-
config.headers = {
|
|
445
|
-
Authorization: `Bearer ${token}`,
|
|
446
|
-
...config.headers
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return config;
|
|
451
|
-
}, error => {
|
|
452
|
-
return Promise.reject(error);
|
|
453
|
-
});
|
|
454
|
-
const isRecord = data => {
|
|
455
|
-
return data && typeof data === 'object';
|
|
456
|
-
};
|
|
457
|
-
axios.interceptors.response.use(response => {
|
|
458
|
-
if (response.status === 201 && response.data.location) {
|
|
459
|
-
window.location.href = response.data.location;
|
|
460
|
-
response.data = undefined; //防止多次跳转
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return response;
|
|
464
|
-
}, e => {
|
|
465
|
-
if (axios.isAxiosError(e)) {
|
|
466
|
-
if (e.response) {
|
|
467
|
-
const {
|
|
468
|
-
data,
|
|
469
|
-
status
|
|
470
|
-
} = e.response;
|
|
471
|
-
if (status === 401) {
|
|
472
|
-
e.errors = 'Unauthorized';
|
|
473
|
-
if (isRecord(data) && data.url) {
|
|
474
|
-
e = new Unauthorized(data.url);
|
|
475
|
-
}
|
|
476
|
-
Toast.error('Unauthorized');
|
|
477
|
-
} else {
|
|
478
|
-
if (isRecord(data)) {
|
|
479
|
-
if (status === 422) {
|
|
480
|
-
e.errors = data;
|
|
481
|
-
} else if ('message' in data) {
|
|
482
|
-
e.errors = data['message'];
|
|
483
|
-
}
|
|
484
|
-
} else {
|
|
485
|
-
e.errors = data;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
return Promise.reject(e);
|
|
491
|
-
});
|
|
492
|
-
const isRequestError = axios.isAxiosError;
|
|
493
|
-
const showRequestError = e => {
|
|
494
|
-
if (axios.isAxiosError(e)) {
|
|
495
|
-
let errors = e.errors;
|
|
496
|
-
if (typeof e.errors !== 'string') {
|
|
497
|
-
errors = Object.values(e.errors).join('<br />');
|
|
498
|
-
}
|
|
499
|
-
Toast.error(errors);
|
|
500
|
-
} else {
|
|
501
|
-
throw e;
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
const request = async function (config) {
|
|
505
|
-
config = typeof config === 'string' ? {
|
|
506
|
-
url: config
|
|
507
|
-
} : config;
|
|
508
|
-
const {
|
|
509
|
-
data
|
|
510
|
-
} = await axios.request({
|
|
511
|
-
paramsSerializer: function (params) {
|
|
512
|
-
return queryString.stringify(params, {
|
|
513
|
-
sort: false,
|
|
514
|
-
skipNull: true,
|
|
515
|
-
skipEmptyString: true,
|
|
516
|
-
arrayFormat: 'bracket'
|
|
517
|
-
});
|
|
518
|
-
},
|
|
519
|
-
...config
|
|
520
|
-
});
|
|
521
|
-
return data;
|
|
522
|
-
};
|
|
523
|
-
request.defaults = axios.defaults;
|
|
524
|
-
request.interceptors = axios.interceptors;
|
|
525
|
-
|
|
526
|
-
const useUnmountedRef = () => {
|
|
527
|
-
const unmountedRef = useRef(false);
|
|
528
|
-
useEffect(() => {
|
|
529
|
-
unmountedRef.current = false;
|
|
530
|
-
return () => {
|
|
531
|
-
unmountedRef.current = true;
|
|
532
|
-
};
|
|
533
|
-
}, []);
|
|
534
|
-
return unmountedRef;
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
function useSafeState(initialState) {
|
|
538
|
-
const unmountedRef = useUnmountedRef();
|
|
539
|
-
const [state, setState] = useState(initialState);
|
|
540
|
-
const setCurrentState = useCallback(currentState => {
|
|
541
|
-
/** if component is unmounted, stop update */
|
|
542
|
-
if (unmountedRef.current) return;
|
|
543
|
-
setState(currentState);
|
|
544
|
-
}, []);
|
|
545
|
-
return [state, setCurrentState];
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
const WaitModal = function (_ref) {
|
|
549
|
-
let {
|
|
550
|
-
state,
|
|
551
|
-
message,
|
|
552
|
-
resolve
|
|
553
|
-
} = _ref;
|
|
554
|
-
const open = useRef(true);
|
|
555
|
-
const {
|
|
556
|
-
result,
|
|
557
|
-
checkUrl,
|
|
558
|
-
onComplete
|
|
559
|
-
} = message;
|
|
560
|
-
const [checking, setChecking] = useSafeState(false);
|
|
561
|
-
useEffect(() => {
|
|
562
|
-
request({
|
|
563
|
-
url: checkUrl,
|
|
564
|
-
method: 'post',
|
|
565
|
-
data: {
|
|
566
|
-
order_no: result.order_no
|
|
567
|
-
},
|
|
568
|
-
raxConfig: {
|
|
569
|
-
shouldRetry(err) {
|
|
570
|
-
return open.current && err.response?.status === 449;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}).then(() => {
|
|
574
|
-
onComplete?.();
|
|
575
|
-
resolve();
|
|
576
|
-
}).catch(() => null);
|
|
577
|
-
}, []);
|
|
578
|
-
return jsx(Modal, {
|
|
579
|
-
...state,
|
|
580
|
-
centered: true,
|
|
581
|
-
onHide: () => {
|
|
582
|
-
open.current = false;
|
|
583
|
-
state.onHide();
|
|
584
|
-
},
|
|
585
|
-
backdrop: 'static',
|
|
586
|
-
header: '\u652F\u4ED8\u7ED3\u679C',
|
|
587
|
-
okText: '\u5DF2\u5B8C\u6210\u652F\u4ED8',
|
|
588
|
-
okButtonProps: {
|
|
589
|
-
loading: checking
|
|
590
|
-
},
|
|
591
|
-
onOk: async e => {
|
|
592
|
-
e.preventDefault();
|
|
593
|
-
try {
|
|
594
|
-
setChecking(true);
|
|
595
|
-
await request({
|
|
596
|
-
url: checkUrl,
|
|
597
|
-
method: 'post',
|
|
598
|
-
data: {
|
|
599
|
-
order_no: result.order_no
|
|
600
|
-
},
|
|
601
|
-
raxConfig: {
|
|
602
|
-
shouldRetry() {
|
|
603
|
-
return false;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
onComplete?.();
|
|
608
|
-
resolve();
|
|
609
|
-
} catch {
|
|
610
|
-
// ignore
|
|
611
|
-
} finally {
|
|
612
|
-
setChecking(false);
|
|
613
|
-
}
|
|
614
|
-
},
|
|
615
|
-
cancelText: '\u53D6\u6D88',
|
|
616
|
-
children: "\u8BF7\u5728\u65B0\u6253\u5F00\u7684\u9875\u9762\u4E0A\u8FDB\u884C\u652F\u4ED8\uFF0C\u652F\u4ED8\u5B8C\u6210\u540E\u518D\u5173\u95ED\u6B64\u7A97\u53E3"
|
|
617
|
-
});
|
|
618
|
-
};
|
|
619
|
-
function waitPayComplete(options) {
|
|
620
|
-
const {
|
|
621
|
-
result
|
|
622
|
-
} = options;
|
|
623
|
-
window.open(result.pay_url);
|
|
624
|
-
show(WaitModal, options);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
const Container$1 = styled.div`
|
|
628
|
-
padding: 48px 32px;
|
|
629
|
-
`;
|
|
630
|
-
const Icon = styled.div`
|
|
631
|
-
margin-bottom: 24px;
|
|
632
|
-
text-align: center;
|
|
633
|
-
font-size: 72px;
|
|
634
|
-
`;
|
|
635
|
-
const Title$1 = styled.div`
|
|
636
|
-
color: rgba(0, 0, 0, .85);
|
|
637
|
-
font-size: 24px;
|
|
638
|
-
line-height: 1.8;
|
|
639
|
-
text-align: center;
|
|
640
|
-
`;
|
|
641
|
-
const Extra = styled.div`
|
|
642
|
-
margin-top: 32px;
|
|
643
|
-
text-align: center;
|
|
644
|
-
`;
|
|
645
|
-
const IconMap = {
|
|
646
|
-
success: jsx("i", {
|
|
647
|
-
className: 'bi bi-check-circle-fill text-success'
|
|
648
|
-
}),
|
|
649
|
-
error: jsx("i", {
|
|
650
|
-
className: 'bi bi-exclamation-circle-fill text-danger'
|
|
651
|
-
}),
|
|
652
|
-
info: jsx("i", {
|
|
653
|
-
className: 'bi bi-info-circle-fill text-info'
|
|
654
|
-
}),
|
|
655
|
-
warning: jsx("i", {
|
|
656
|
-
className: 'bi bi-exclamation-triangle-fill text-warning'
|
|
657
|
-
})
|
|
658
|
-
};
|
|
659
|
-
function Result(_ref) {
|
|
660
|
-
let {
|
|
661
|
-
status,
|
|
662
|
-
title,
|
|
663
|
-
icon,
|
|
664
|
-
extra
|
|
665
|
-
} = _ref;
|
|
666
|
-
if (!icon && status) {
|
|
667
|
-
icon = IconMap[status];
|
|
668
|
-
}
|
|
669
|
-
return jsxs(Container$1, {
|
|
670
|
-
children: [icon && jsx(Icon, {
|
|
671
|
-
children: icon
|
|
672
|
-
}), title && jsx(Title$1, {
|
|
673
|
-
children: title
|
|
674
|
-
}), extra && jsx(Extra, {
|
|
675
|
-
children: extra
|
|
676
|
-
})]
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
styled.div`
|
|
681
|
-
position: relative;
|
|
682
|
-
`;
|
|
683
|
-
const Dimmer = styled.div`
|
|
684
|
-
display: ${props => props.active ? 'flex' : 'none'};
|
|
685
|
-
position: absolute;
|
|
686
|
-
top: 0 !important;
|
|
687
|
-
left: 0 !important;
|
|
688
|
-
width: 100%;
|
|
689
|
-
height: 100%;
|
|
690
|
-
text-align: center;
|
|
691
|
-
vertical-align: middle;
|
|
692
|
-
padding: 1em;
|
|
693
|
-
background-color: ${props => props.inverted ? 'rgba(255, 255, 255, .85)' : 'rgba(0, 0, 0, .85)'};
|
|
694
|
-
opacity: ${props => props.active ? 1 : 0};
|
|
695
|
-
line-height: 1;
|
|
696
|
-
animation-fill-mode: both;
|
|
697
|
-
animation-duration: .5s;
|
|
698
|
-
transition: background-color .5s linear;
|
|
699
|
-
flex-direction: column;
|
|
700
|
-
align-items: center;
|
|
701
|
-
justify-content: center;
|
|
702
|
-
user-select: none;
|
|
703
|
-
will-change: opacity;
|
|
704
|
-
z-index: 990;
|
|
705
|
-
`;
|
|
706
|
-
|
|
707
|
-
function Loader(_ref) {
|
|
708
|
-
let {
|
|
709
|
-
loading = true,
|
|
710
|
-
children,
|
|
711
|
-
variant = 'primary',
|
|
712
|
-
animation = 'border',
|
|
713
|
-
wrap,
|
|
714
|
-
...props
|
|
715
|
-
} = _ref;
|
|
716
|
-
if (!loading) {
|
|
717
|
-
return null;
|
|
718
|
-
}
|
|
719
|
-
if (children) {
|
|
720
|
-
children = jsx("p", {
|
|
721
|
-
className: 'mt-3 text-secondary',
|
|
722
|
-
children: children
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
children = jsxs(Dimmer, {
|
|
726
|
-
inverted: true,
|
|
727
|
-
active: true,
|
|
728
|
-
children: [jsx(Spinner, {
|
|
729
|
-
animation: animation,
|
|
730
|
-
variant: variant,
|
|
731
|
-
...props
|
|
732
|
-
}), children]
|
|
733
|
-
});
|
|
734
|
-
if (wrap) {
|
|
735
|
-
return jsx(Wrap, {
|
|
736
|
-
"$height": typeof wrap === 'number' ? wrap : 150,
|
|
737
|
-
children: children
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
return children;
|
|
741
|
-
}
|
|
742
|
-
const Wrap = styled.div`
|
|
743
|
-
position: relative;
|
|
744
|
-
height: ${props => `${props.$height}px`};
|
|
745
|
-
`;
|
|
746
|
-
|
|
747
|
-
function Card(_ref) {
|
|
748
|
-
let {
|
|
749
|
-
children,
|
|
750
|
-
title,
|
|
751
|
-
className,
|
|
752
|
-
...props
|
|
753
|
-
} = _ref;
|
|
754
|
-
return jsx(Card$1, {
|
|
755
|
-
className: classNames('border-0 shadow-sm mb-3', className),
|
|
756
|
-
...props,
|
|
757
|
-
children: jsxs("div", {
|
|
758
|
-
className: 'card-body',
|
|
759
|
-
children: [title && jsxs(Fragment$1, {
|
|
760
|
-
children: [jsx("h5", {
|
|
761
|
-
children: title
|
|
762
|
-
}), jsx("hr", {})]
|
|
763
|
-
}), children]
|
|
764
|
-
})
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
function Error$1(_ref) {
|
|
769
|
-
let {
|
|
770
|
-
errors
|
|
771
|
-
} = _ref;
|
|
772
|
-
if (!errors) {
|
|
773
|
-
return null;
|
|
774
|
-
}
|
|
775
|
-
return jsx(Alert, {
|
|
776
|
-
variant: 'danger',
|
|
777
|
-
children: jsx("ul", {
|
|
778
|
-
className: 'mb-0',
|
|
779
|
-
children: typeof errors === 'string' ? jsx("li", {
|
|
780
|
-
children: errors
|
|
781
|
-
}) : Object.entries(errors).map(_ref2 => {
|
|
782
|
-
let [name, error] = _ref2;
|
|
783
|
-
return jsx("li", {
|
|
784
|
-
children: error
|
|
785
|
-
}, name);
|
|
786
|
-
})
|
|
787
|
-
})
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
function Space(_ref) {
|
|
792
|
-
let {
|
|
793
|
-
children,
|
|
794
|
-
className,
|
|
795
|
-
size = 'small',
|
|
796
|
-
direction = 'horizontal'
|
|
797
|
-
} = _ref;
|
|
798
|
-
if (typeof size === 'string') {
|
|
799
|
-
size = {
|
|
800
|
-
small: 8,
|
|
801
|
-
middle: 16,
|
|
802
|
-
large: 24
|
|
803
|
-
}[size];
|
|
804
|
-
}
|
|
805
|
-
const items = Children.map(children, child => {
|
|
806
|
-
if (child) {
|
|
807
|
-
return jsx(Item, {
|
|
808
|
-
children: child
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
return jsx(Container, {
|
|
813
|
-
className: className,
|
|
814
|
-
"$direction": direction,
|
|
815
|
-
"$size": size,
|
|
816
|
-
children: items
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
const Container = styled.div`
|
|
820
|
-
display: inline-flex;
|
|
821
|
-
align-items: center;
|
|
822
|
-
gap: ${props => props.$size}px;
|
|
823
|
-
|
|
824
|
-
${props => props.$direction === 'vertical' && css`
|
|
825
|
-
display: flex;
|
|
826
|
-
flex-direction: column;
|
|
827
|
-
align-items: inherit;
|
|
828
|
-
`}
|
|
829
|
-
`;
|
|
830
|
-
const Item = styled.div`
|
|
831
|
-
|
|
832
|
-
`;
|
|
833
|
-
|
|
834
|
-
var _path;
|
|
835
|
-
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); }
|
|
836
|
-
const SvgStepCheck = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
837
|
-
viewBox: "0 0 1024 1024",
|
|
838
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
839
|
-
width: 16,
|
|
840
|
-
height: 16,
|
|
841
|
-
fill: "currentColor"
|
|
842
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
843
|
-
d: "M887.904 298.208c-12.864-12.064-33.152-11.488-45.216 1.408L415.936 753.984l-233.12-229.696c-12.608-12.416-32.864-12.288-45.28.32-12.416 12.576-12.256 32.864.352 45.248l256.48 252.672c.096.096.224.128.32.224s.128.224.224.32c2.016 1.92 4.448 3.008 6.784 4.288 1.152.672 2.144 1.664 3.36 2.144 3.776 1.472 7.776 2.24 11.744 2.24 4.192 0 8.384-.832 12.288-2.496 1.312-.544 2.336-1.664 3.552-2.368 2.4-1.408 4.896-2.592 6.944-4.672.096-.096.128-.256.224-.352.064-.096.192-.128.288-.224L889.28 343.424c12.16-12.832 11.488-33.088-1.376-45.216z"
|
|
844
|
-
})));
|
|
845
|
-
|
|
846
|
-
function Steps(props) {
|
|
847
|
-
return jsx(CustomRcSteps, {
|
|
848
|
-
icons: {
|
|
849
|
-
finish: jsx(SvgStepCheck, {}),
|
|
850
|
-
error: jsx(Fragment$1, {})
|
|
851
|
-
},
|
|
852
|
-
...props
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
Steps.Step = RcSteps.Step;
|
|
856
|
-
const CustomRcSteps = styled(RcSteps)`
|
|
857
|
-
.rc-steps-item-icon {
|
|
858
|
-
display: inline-flex;
|
|
859
|
-
align-items: center;
|
|
860
|
-
justify-content: center;
|
|
861
|
-
|
|
862
|
-
& > .rc-steps-icon {
|
|
863
|
-
top: 0;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
.rc-steps-item-process {
|
|
868
|
-
.rc-steps-item-icon {
|
|
869
|
-
background: var(--bs-primary);
|
|
870
|
-
border-color: var(--bs-primary);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
.rc-steps-item-finish {
|
|
875
|
-
.rc-steps-item-icon {
|
|
876
|
-
border-color: var(--bs-primary);
|
|
877
|
-
|
|
878
|
-
& > .rc-steps-icon {
|
|
879
|
-
color: var(--bs-primary);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
.rc-steps-item-title:after {
|
|
884
|
-
background-color: var(--bs-primary);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
`;
|
|
889
|
-
|
|
890
|
-
function Statistic(_ref) {
|
|
891
|
-
let {
|
|
892
|
-
title,
|
|
893
|
-
content,
|
|
894
|
-
footer
|
|
895
|
-
} = _ref;
|
|
896
|
-
return jsxs(Card, {
|
|
897
|
-
children: [jsx(Title, {
|
|
898
|
-
children: title
|
|
899
|
-
}), jsx(Content, {
|
|
900
|
-
children: content
|
|
901
|
-
}), footer && jsx(Footer, {
|
|
902
|
-
children: footer
|
|
903
|
-
})]
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
const Footer = styled.div`
|
|
907
|
-
margin-top: 9px;
|
|
908
|
-
padding-top: 10px;
|
|
909
|
-
border-top: 1px solid #f0f0f0;
|
|
910
|
-
color: rgba(0, 0, 0, .65);
|
|
911
|
-
`;
|
|
912
|
-
const Content = styled.div`
|
|
913
|
-
color: rgba(0, 0, 0, .85);
|
|
914
|
-
font-size: 24px;
|
|
915
|
-
`;
|
|
916
|
-
const Title = styled.div`
|
|
917
|
-
margin-bottom: 4px;
|
|
918
|
-
color: rgba(0, 0, 0, .45);
|
|
919
|
-
font-size: 1.1rem;
|
|
920
|
-
`;
|
|
921
|
-
|
|
922
|
-
function noop() {}
|
|
923
|
-
function isInteger(value) {
|
|
924
|
-
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
|
|
925
|
-
}
|
|
926
|
-
function Pagination(_ref) {
|
|
927
|
-
let {
|
|
928
|
-
total = 0,
|
|
929
|
-
onChange = noop,
|
|
930
|
-
defaultCurrent = 1,
|
|
931
|
-
defaultPageSize = 10,
|
|
932
|
-
className,
|
|
933
|
-
...props
|
|
934
|
-
} = _ref;
|
|
935
|
-
const [current, setCurrent] = useState(defaultCurrent);
|
|
936
|
-
const [pageSize, setPageSize] = useState(defaultPageSize);
|
|
937
|
-
useEffect(() => {
|
|
938
|
-
if (isInteger(props.current)) {
|
|
939
|
-
setCurrent(props.current);
|
|
940
|
-
}
|
|
941
|
-
}, [props.current]);
|
|
942
|
-
useEffect(() => {
|
|
943
|
-
if (isInteger(props.pageSize)) {
|
|
944
|
-
setPageSize(props.pageSize);
|
|
945
|
-
}
|
|
946
|
-
}, [props.pageSize]);
|
|
947
|
-
const allPages = useMemo(() => {
|
|
948
|
-
return Math.floor((total - 1) / pageSize) + 1;
|
|
949
|
-
}, [total, pageSize]);
|
|
950
|
-
const handleChange = useCallback(p => {
|
|
951
|
-
return () => {
|
|
952
|
-
if (p !== current) {
|
|
953
|
-
setCurrent(p);
|
|
954
|
-
onChange(p, pageSize);
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
}, [onChange, current, pageSize]);
|
|
958
|
-
const pageBufferSize = 2;
|
|
959
|
-
const prevPage = current - 1 > 0 ? current - 1 : 0;
|
|
960
|
-
const nextPage = current + 1 < allPages ? current + 1 : allPages;
|
|
961
|
-
const pagerList = [];
|
|
962
|
-
let jumpPrev = null;
|
|
963
|
-
let jumpNext = null;
|
|
964
|
-
let firstPager = null;
|
|
965
|
-
let lastPager = null;
|
|
966
|
-
if (allPages <= 3 + pageBufferSize * 2) {
|
|
967
|
-
for (let i = 1; i <= allPages; i += 1) {
|
|
968
|
-
const active = current === i;
|
|
969
|
-
pagerList.push(jsx(Pagination$1.Item, {
|
|
970
|
-
active: active,
|
|
971
|
-
onClick: handleChange(i),
|
|
972
|
-
children: i
|
|
973
|
-
}, i));
|
|
974
|
-
}
|
|
975
|
-
} else {
|
|
976
|
-
lastPager = jsx(Pagination$1.Last, {
|
|
977
|
-
onClick: handleChange(allPages)
|
|
978
|
-
}, 'last');
|
|
979
|
-
firstPager = jsx(Pagination$1.First, {
|
|
980
|
-
onClick: handleChange(1)
|
|
981
|
-
}, 'first');
|
|
982
|
-
jumpPrev = jsx(Pagination$1.Prev, {
|
|
983
|
-
onClick: handleChange(prevPage)
|
|
984
|
-
}, 'prev');
|
|
985
|
-
jumpNext = jsx(Pagination$1.Next, {
|
|
986
|
-
onClick: handleChange(nextPage)
|
|
987
|
-
}, 'next');
|
|
988
|
-
let left = Math.max(1, current - pageBufferSize);
|
|
989
|
-
let right = Math.min(current + pageBufferSize, allPages);
|
|
990
|
-
if (current - 1 <= pageBufferSize) {
|
|
991
|
-
right = 1 + pageBufferSize * 2;
|
|
992
|
-
}
|
|
993
|
-
if (allPages - current <= pageBufferSize) {
|
|
994
|
-
left = allPages - pageBufferSize * 2;
|
|
995
|
-
}
|
|
996
|
-
for (let i = left; i <= right; i += 1) {
|
|
997
|
-
const active = current === i;
|
|
998
|
-
pagerList.push(jsx(Pagination$1.Item, {
|
|
999
|
-
active: active,
|
|
1000
|
-
onClick: handleChange(i),
|
|
1001
|
-
children: i
|
|
1002
|
-
}, i));
|
|
1003
|
-
}
|
|
1004
|
-
if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) {
|
|
1005
|
-
pagerList.unshift(jumpPrev);
|
|
1006
|
-
}
|
|
1007
|
-
if (allPages - current >= pageBufferSize * 2 && current !== allPages - 2) {
|
|
1008
|
-
pagerList.push(jumpNext);
|
|
1009
|
-
}
|
|
1010
|
-
if (left !== 1) {
|
|
1011
|
-
pagerList.unshift(firstPager);
|
|
1012
|
-
}
|
|
1013
|
-
if (right !== allPages) {
|
|
1014
|
-
pagerList.push(lastPager);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
return jsx(Pagination$1, {
|
|
1018
|
-
className: className,
|
|
1019
|
-
children: pagerList
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
function NumberFormat(_ref) {
|
|
1024
|
-
let {
|
|
1025
|
-
className,
|
|
1026
|
-
value,
|
|
1027
|
-
locale = 'zh-CN',
|
|
1028
|
-
currency = true,
|
|
1029
|
-
options = {}
|
|
1030
|
-
} = _ref;
|
|
1031
|
-
const formatter = useMemo(() => {
|
|
1032
|
-
let opt;
|
|
1033
|
-
if (currency) {
|
|
1034
|
-
opt = {
|
|
1035
|
-
style: 'currency',
|
|
1036
|
-
currency: 'CNY'
|
|
1037
|
-
};
|
|
1038
|
-
} else {
|
|
1039
|
-
opt = {
|
|
1040
|
-
minimumFractionDigits: 2
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
return new Intl.NumberFormat(locale, {
|
|
1044
|
-
...opt,
|
|
1045
|
-
...options
|
|
1046
|
-
});
|
|
1047
|
-
}, [currency, locale, options]);
|
|
1048
|
-
if (className) {
|
|
1049
|
-
return jsx("span", {
|
|
1050
|
-
className: className,
|
|
1051
|
-
children: formatter.format(value)
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
return jsx(Fragment$1, {
|
|
1055
|
-
children: formatter.format(value)
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
function LoadingButton(_ref) {
|
|
1060
|
-
let {
|
|
1061
|
-
loading,
|
|
1062
|
-
disabled,
|
|
1063
|
-
children,
|
|
1064
|
-
...props
|
|
1065
|
-
} = _ref;
|
|
1066
|
-
return jsx(Button$1, {
|
|
1067
|
-
...props,
|
|
1068
|
-
disabled: loading || disabled,
|
|
1069
|
-
children: loading ? 'Loading…' : children
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
const LazyImageZoom = lazy(() => import('./image-zoom-912e2b3b.js'));
|
|
1074
|
-
function ImageZoom(props) {
|
|
1075
|
-
return jsx(Suspense, {
|
|
1076
|
-
fallback: null,
|
|
1077
|
-
children: jsx(LazyImageZoom, {
|
|
1078
|
-
...props
|
|
1079
|
-
})
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function RequestButton(_ref) {
|
|
1084
|
-
let {
|
|
1085
|
-
url,
|
|
1086
|
-
method,
|
|
1087
|
-
confirm,
|
|
1088
|
-
onSuccess,
|
|
1089
|
-
children,
|
|
1090
|
-
disabled,
|
|
1091
|
-
as = Button,
|
|
1092
|
-
...props
|
|
1093
|
-
} = _ref;
|
|
1094
|
-
const [fetching, setFetching] = useSafeState(false);
|
|
1095
|
-
const handleClick = useCallback(async e => {
|
|
1096
|
-
e.preventDefault();
|
|
1097
|
-
try {
|
|
1098
|
-
setFetching(true);
|
|
1099
|
-
if (confirm) {
|
|
1100
|
-
if (!(await Modal.confirm({
|
|
1101
|
-
message: confirm
|
|
1102
|
-
}))) {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
const config = typeof url === 'string' ? {
|
|
1107
|
-
url,
|
|
1108
|
-
method
|
|
1109
|
-
} : {
|
|
1110
|
-
method,
|
|
1111
|
-
...url
|
|
1112
|
-
};
|
|
1113
|
-
const result = await request(config);
|
|
1114
|
-
if (onSuccess) {
|
|
1115
|
-
onSuccess(result);
|
|
1116
|
-
}
|
|
1117
|
-
} catch (e) {
|
|
1118
|
-
showRequestError(e);
|
|
1119
|
-
} finally {
|
|
1120
|
-
setFetching(false);
|
|
1121
|
-
}
|
|
1122
|
-
}, [url, method, setFetching]);
|
|
1123
|
-
return createElement(as, {
|
|
1124
|
-
...props,
|
|
1125
|
-
disabled: disabled || fetching,
|
|
1126
|
-
onClick: handleClick
|
|
1127
|
-
}, children);
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
const LazyForm = lazy(() => import('./form-01bf45e9.js'));
|
|
1131
|
-
function Form(props) {
|
|
1132
|
-
return jsx(Suspense, {
|
|
1133
|
-
fallback: null,
|
|
1134
|
-
children: jsx(LazyForm, {
|
|
1135
|
-
...props
|
|
1136
|
-
})
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
const LazyTable = lazy(() => import('./index-1d379f3a.js'));
|
|
1141
|
-
function Table(props) {
|
|
1142
|
-
return jsx(Suspense, {
|
|
1143
|
-
fallback: null,
|
|
1144
|
-
children: jsx(LazyTable, {
|
|
1145
|
-
...props
|
|
1146
|
-
})
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
let id = 0;
|
|
1151
|
-
function useOverlayState() {
|
|
1152
|
-
let {
|
|
1153
|
-
onHide,
|
|
1154
|
-
onShow
|
|
1155
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1156
|
-
const [visible, setVisible] = useState(false);
|
|
1157
|
-
const [key, setKey] = useState(`visible-${id}`);
|
|
1158
|
-
const hide = useCallback(() => {
|
|
1159
|
-
setVisible(false);
|
|
1160
|
-
if (onHide) {
|
|
1161
|
-
onHide();
|
|
1162
|
-
}
|
|
1163
|
-
}, [setVisible, onHide]);
|
|
1164
|
-
const exit = useCallback(() => {
|
|
1165
|
-
setKey(`visible-${++id}`);
|
|
1166
|
-
}, [setKey, id]);
|
|
1167
|
-
const show = useCallback(() => {
|
|
1168
|
-
setVisible(true);
|
|
1169
|
-
if (onShow) {
|
|
1170
|
-
onShow();
|
|
1171
|
-
}
|
|
1172
|
-
}, [setVisible, onShow]);
|
|
1173
|
-
const state = {
|
|
1174
|
-
show: visible,
|
|
1175
|
-
onHide: hide,
|
|
1176
|
-
onExited: exit,
|
|
1177
|
-
key
|
|
1178
|
-
};
|
|
1179
|
-
return {
|
|
1180
|
-
visible,
|
|
1181
|
-
show,
|
|
1182
|
-
hide,
|
|
1183
|
-
state
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
const ModalButton = forwardRef((_ref, ref) => {
|
|
1188
|
-
let {
|
|
1189
|
-
text,
|
|
1190
|
-
onOk,
|
|
1191
|
-
modalProps,
|
|
1192
|
-
children,
|
|
1193
|
-
onShow,
|
|
1194
|
-
confirmLoading,
|
|
1195
|
-
as = Button,
|
|
1196
|
-
...props
|
|
1197
|
-
} = _ref;
|
|
1198
|
-
const {
|
|
1199
|
-
state,
|
|
1200
|
-
show,
|
|
1201
|
-
hide
|
|
1202
|
-
} = useOverlayState({
|
|
1203
|
-
onShow
|
|
1204
|
-
});
|
|
1205
|
-
useImperativeHandle(ref, () => ({
|
|
1206
|
-
close: hide
|
|
1207
|
-
}));
|
|
1208
|
-
const handleOk = async e => {
|
|
1209
|
-
if (onOk) {
|
|
1210
|
-
const result = await onOk();
|
|
1211
|
-
if (result === false) {
|
|
1212
|
-
e.preventDefault();
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
const button = createElement(as, {
|
|
1217
|
-
...props,
|
|
1218
|
-
onClick: show
|
|
1219
|
-
}, text);
|
|
1220
|
-
return jsxs(Fragment$1, {
|
|
1221
|
-
children: [button, jsx(Modal, {
|
|
1222
|
-
header: text,
|
|
1223
|
-
...modalProps,
|
|
1224
|
-
...state,
|
|
1225
|
-
confirmLoading: confirmLoading,
|
|
1226
|
-
onOk: handleOk,
|
|
1227
|
-
children: children
|
|
1228
|
-
})]
|
|
1229
|
-
});
|
|
1230
|
-
});
|
|
1231
|
-
|
|
1232
|
-
function ModalForm(_ref) {
|
|
1233
|
-
let {
|
|
1234
|
-
text,
|
|
1235
|
-
onSuccess,
|
|
1236
|
-
buttonProps,
|
|
1237
|
-
modalProps,
|
|
1238
|
-
children,
|
|
1239
|
-
...props
|
|
1240
|
-
} = _ref;
|
|
1241
|
-
const [loading, setLoading] = useState(false);
|
|
1242
|
-
const ref = useRef(null);
|
|
1243
|
-
const form = useRef(null);
|
|
1244
|
-
const handleOk = useCallback(() => {
|
|
1245
|
-
form.current?.submit();
|
|
1246
|
-
return false;
|
|
1247
|
-
}, []);
|
|
1248
|
-
const handleSuccess = useCallback(data => {
|
|
1249
|
-
if (onSuccess) {
|
|
1250
|
-
onSuccess(data);
|
|
1251
|
-
}
|
|
1252
|
-
ref.current?.close();
|
|
1253
|
-
}, [onSuccess]);
|
|
1254
|
-
return jsx(ModalButton, {
|
|
1255
|
-
ref: ref,
|
|
1256
|
-
text: text,
|
|
1257
|
-
...buttonProps,
|
|
1258
|
-
modalProps: modalProps,
|
|
1259
|
-
onOk: handleOk,
|
|
1260
|
-
confirmLoading: loading,
|
|
1261
|
-
children: jsxs(Form, {
|
|
1262
|
-
...props,
|
|
1263
|
-
onSubmitting: setLoading,
|
|
1264
|
-
ref: form,
|
|
1265
|
-
onSuccess: handleSuccess,
|
|
1266
|
-
children: [children, jsx("input", {
|
|
1267
|
-
type: 'submit',
|
|
1268
|
-
hidden: true
|
|
1269
|
-
})]
|
|
1270
|
-
})
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
function useRequest(config) {
|
|
1275
|
-
let {
|
|
1276
|
-
manual,
|
|
1277
|
-
refreshDeps,
|
|
1278
|
-
...options
|
|
1279
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1280
|
-
let {
|
|
1281
|
-
execute,
|
|
1282
|
-
currentParams,
|
|
1283
|
-
error,
|
|
1284
|
-
...others
|
|
1285
|
-
} = useAsyncCallback(async params => {
|
|
1286
|
-
config = typeof config === 'string' ? {
|
|
1287
|
-
url: config
|
|
1288
|
-
} : config;
|
|
1289
|
-
return await request({
|
|
1290
|
-
...config,
|
|
1291
|
-
...params
|
|
1292
|
-
});
|
|
1293
|
-
}, options);
|
|
1294
|
-
useEffect(() => {
|
|
1295
|
-
if (!manual && !refreshDeps) {
|
|
1296
|
-
try {
|
|
1297
|
-
execute();
|
|
1298
|
-
} catch {}
|
|
1299
|
-
}
|
|
1300
|
-
}, []);
|
|
1301
|
-
useEffect(() => {
|
|
1302
|
-
if (refreshDeps) {
|
|
1303
|
-
refresh();
|
|
1304
|
-
}
|
|
1305
|
-
}, refreshDeps);
|
|
1306
|
-
const refresh = useCallback(async () => {
|
|
1307
|
-
try {
|
|
1308
|
-
if (currentParams) {
|
|
1309
|
-
await execute(...currentParams);
|
|
1310
|
-
} else {
|
|
1311
|
-
await execute();
|
|
1312
|
-
}
|
|
1313
|
-
} catch {}
|
|
1314
|
-
}, [execute, currentParams]);
|
|
1315
|
-
if (error && isRequestError(error)) {
|
|
1316
|
-
const errors = error.errors;
|
|
1317
|
-
error = new Error(typeof errors === 'string' ? errors : values(errors).join(''));
|
|
1318
|
-
}
|
|
1319
|
-
return {
|
|
1320
|
-
refresh,
|
|
1321
|
-
execute,
|
|
1322
|
-
error,
|
|
1323
|
-
...others
|
|
1324
|
-
};
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
function useCallbackRef(callback) {
|
|
1328
|
-
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1329
|
-
const callbackRef = useRef(callback);
|
|
1330
|
-
useEffect(() => {
|
|
1331
|
-
callbackRef.current = callback;
|
|
1332
|
-
});
|
|
1333
|
-
return useCallback(function () {
|
|
1334
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1335
|
-
args[_key] = arguments[_key];
|
|
1336
|
-
}
|
|
1337
|
-
return callbackRef.current?.(...args);
|
|
1338
|
-
}, deps);
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
function useControllableState(props) {
|
|
1342
|
-
const {
|
|
1343
|
-
value: valueProp,
|
|
1344
|
-
defaultValue,
|
|
1345
|
-
onChange,
|
|
1346
|
-
shouldUpdate = (prev, next) => prev !== next
|
|
1347
|
-
} = props;
|
|
1348
|
-
const onChangeProp = useCallbackRef(onChange);
|
|
1349
|
-
const shouldUpdateProp = useCallbackRef(shouldUpdate);
|
|
1350
|
-
const [uncontrolledState, setUncontrolledState] = useState(defaultValue);
|
|
1351
|
-
const controlled = valueProp !== undefined;
|
|
1352
|
-
const value = controlled ? valueProp : uncontrolledState;
|
|
1353
|
-
const setValue = useCallbackRef(next => {
|
|
1354
|
-
const setter = next;
|
|
1355
|
-
const nextValue = typeof next === 'function' ? setter(value) : next;
|
|
1356
|
-
if (!shouldUpdateProp(value, nextValue)) {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
if (!controlled) {
|
|
1360
|
-
setUncontrolledState(nextValue);
|
|
1361
|
-
}
|
|
1362
|
-
onChangeProp(nextValue);
|
|
1363
|
-
}, [controlled, onChangeProp, value, shouldUpdateProp]);
|
|
1364
|
-
return [value, setValue];
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
function useDebounce(callback, wait, options) {
|
|
1368
|
-
const callbackRef = useRef(callback);
|
|
1369
|
-
const debouncedCallbackRef = useRef(debounce(callback, wait, options));
|
|
1370
|
-
useEffect(() => {
|
|
1371
|
-
callbackRef.current = callback;
|
|
1372
|
-
});
|
|
1373
|
-
useEffect(() => {
|
|
1374
|
-
debouncedCallbackRef.current = debounce(function () {
|
|
1375
|
-
callbackRef.current(...arguments);
|
|
1376
|
-
}, wait, options);
|
|
1377
|
-
}, [wait, options]);
|
|
1378
|
-
return debouncedCallbackRef.current;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
export { Button as B, Card as C, Error$1 as E, Form as F, ImageZoom as I, Loader as L, Message$1 as M, NumberFormat as N, Pagination as P, Result as R, Space as S, TableContext as T, Unauthorized as U, useDebounce as a, useControllableState as b, Toast as c, Steps as d, Statistic as e, LoadingButton as f, RequestButton as g, Table as h, ModalForm as i, ModalButton as j, Modal as k, Tooltip as l, useRequest as m, useOverlayState as n, isRequestError as o, request as r, showRequestError as s, useSafeState as u, waitPayComplete as w };
|
|
1382
|
-
//# sourceMappingURL=index-a48179db.js.map
|