crud-page-react 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +80 -1503
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +100 -1541
- package/dist/index.js.map +1 -1
- package/dist/types/schema.d.ts +10 -0
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,1512 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var antd = require('antd');
|
|
6
|
+
var icons = require('@ant-design/icons');
|
|
6
7
|
var dayjs = require('dayjs');
|
|
7
8
|
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
8
9
|
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
|
-
|
|
28
|
-
var IconContext = /*#__PURE__*/React.createContext({});
|
|
29
|
-
|
|
30
|
-
function _extends() {
|
|
31
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
32
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
33
|
-
var t = arguments[e];
|
|
34
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
35
|
-
}
|
|
36
|
-
return n;
|
|
37
|
-
}, _extends.apply(null, arguments);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _arrayWithHoles(r) {
|
|
41
|
-
if (Array.isArray(r)) return r;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _iterableToArrayLimit(r, l) {
|
|
45
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
46
|
-
if (null != t) {
|
|
47
|
-
var e,
|
|
48
|
-
n,
|
|
49
|
-
i,
|
|
50
|
-
u,
|
|
51
|
-
a = [],
|
|
52
|
-
f = true,
|
|
53
|
-
o = false;
|
|
54
|
-
try {
|
|
55
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
56
|
-
} catch (r) {
|
|
57
|
-
o = true, n = r;
|
|
58
|
-
} finally {
|
|
59
|
-
try {
|
|
60
|
-
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
61
|
-
} finally {
|
|
62
|
-
if (o) throw n;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return a;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function _arrayLikeToArray(r, a) {
|
|
70
|
-
(null == a || a > r.length) && (a = r.length);
|
|
71
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
72
|
-
return n;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function _unsupportedIterableToArray(r, a) {
|
|
76
|
-
if (r) {
|
|
77
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
78
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
79
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function _nonIterableRest() {
|
|
84
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function _slicedToArray(r, e) {
|
|
88
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function _typeof(o) {
|
|
92
|
-
"@babel/helpers - typeof";
|
|
93
|
-
|
|
94
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
95
|
-
return typeof o;
|
|
96
|
-
} : function (o) {
|
|
97
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
98
|
-
}, _typeof(o);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function toPrimitive(t, r) {
|
|
102
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
103
|
-
var e = t[Symbol.toPrimitive];
|
|
104
|
-
if (void 0 !== e) {
|
|
105
|
-
var i = e.call(t, r);
|
|
106
|
-
if ("object" != _typeof(i)) return i;
|
|
107
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
108
|
-
}
|
|
109
|
-
return ("string" === r ? String : Number)(t);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function toPropertyKey(t) {
|
|
113
|
-
var i = toPrimitive(t, "string");
|
|
114
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function _defineProperty(e, r, t) {
|
|
118
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
119
|
-
value: t,
|
|
120
|
-
enumerable: true,
|
|
121
|
-
configurable: true,
|
|
122
|
-
writable: true
|
|
123
|
-
}) : e[r] = t, e;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
127
|
-
if (null == r) return {};
|
|
128
|
-
var t = {};
|
|
129
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
130
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
131
|
-
t[n] = r[n];
|
|
132
|
-
}
|
|
133
|
-
return t;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function _objectWithoutProperties(e, t) {
|
|
137
|
-
if (null == e) return {};
|
|
138
|
-
var o,
|
|
139
|
-
r,
|
|
140
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
141
|
-
if (Object.getOwnPropertySymbols) {
|
|
142
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
143
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
144
|
-
}
|
|
145
|
-
return i;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function getDefaultExportFromCjs (x) {
|
|
149
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
var classnames = {exports: {}};
|
|
153
|
-
|
|
154
|
-
/*!
|
|
155
|
-
Copyright (c) 2018 Jed Watson.
|
|
156
|
-
Licensed under the MIT License (MIT), see
|
|
157
|
-
http://jedwatson.github.io/classnames
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
(function (module) {
|
|
161
|
-
/* global define */
|
|
162
|
-
|
|
163
|
-
(function () {
|
|
164
|
-
|
|
165
|
-
var hasOwn = {}.hasOwnProperty;
|
|
166
|
-
|
|
167
|
-
function classNames () {
|
|
168
|
-
var classes = '';
|
|
169
|
-
|
|
170
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
171
|
-
var arg = arguments[i];
|
|
172
|
-
if (arg) {
|
|
173
|
-
classes = appendClass(classes, parseValue(arg));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return classes;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function parseValue (arg) {
|
|
181
|
-
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
182
|
-
return arg;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (typeof arg !== 'object') {
|
|
186
|
-
return '';
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (Array.isArray(arg)) {
|
|
190
|
-
return classNames.apply(null, arg);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
194
|
-
return arg.toString();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var classes = '';
|
|
198
|
-
|
|
199
|
-
for (var key in arg) {
|
|
200
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
201
|
-
classes = appendClass(classes, key);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return classes;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function appendClass (value, newClass) {
|
|
209
|
-
if (!newClass) {
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (value) {
|
|
214
|
-
return value + ' ' + newClass;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return value + newClass;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (module.exports) {
|
|
221
|
-
classNames.default = classNames;
|
|
222
|
-
module.exports = classNames;
|
|
223
|
-
} else {
|
|
224
|
-
window.classNames = classNames;
|
|
225
|
-
}
|
|
226
|
-
}());
|
|
227
|
-
} (classnames));
|
|
228
|
-
|
|
229
|
-
var classnamesExports = classnames.exports;
|
|
230
|
-
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
231
|
-
|
|
232
|
-
const round = Math.round;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Support format, alpha unit will check the % mark:
|
|
236
|
-
* - rgba(102, 204, 255, .5) -> [102, 204, 255, 0.5]
|
|
237
|
-
* - rgb(102 204 255 / .5) -> [102, 204, 255, 0.5]
|
|
238
|
-
* - rgb(100%, 50%, 0% / 50%) -> [255, 128, 0, 0.5]
|
|
239
|
-
* - hsl(270, 60, 40, .5) -> [270, 60, 40, 0.5]
|
|
240
|
-
* - hsl(270deg 60% 40% / 50%) -> [270, 60, 40, 0.5]
|
|
241
|
-
*
|
|
242
|
-
* When `base` is provided, the percentage value will be divided by `base`.
|
|
243
|
-
*/
|
|
244
|
-
function splitColorStr(str, parseNum) {
|
|
245
|
-
const match = str
|
|
246
|
-
// Remove str before `(`
|
|
247
|
-
.replace(/^[^(]*\((.*)/, '$1')
|
|
248
|
-
// Remove str after `)`
|
|
249
|
-
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || [];
|
|
250
|
-
const numList = match.map(item => parseFloat(item));
|
|
251
|
-
for (let i = 0; i < 3; i += 1) {
|
|
252
|
-
numList[i] = parseNum(numList[i] || 0, match[i] || '', i);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// For alpha. 50% should be 0.5
|
|
256
|
-
if (match[3]) {
|
|
257
|
-
numList[3] = match[3].includes('%') ? numList[3] / 100 : numList[3];
|
|
258
|
-
} else {
|
|
259
|
-
// By default, alpha is 1
|
|
260
|
-
numList[3] = 1;
|
|
261
|
-
}
|
|
262
|
-
return numList;
|
|
263
|
-
}
|
|
264
|
-
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100;
|
|
265
|
-
|
|
266
|
-
/** round and limit number to integer between 0-255 */
|
|
267
|
-
function limitRange(value, max) {
|
|
268
|
-
const mergedMax = max || 255;
|
|
269
|
-
if (value > mergedMax) {
|
|
270
|
-
return mergedMax;
|
|
271
|
-
}
|
|
272
|
-
if (value < 0) {
|
|
273
|
-
return 0;
|
|
274
|
-
}
|
|
275
|
-
return value;
|
|
276
|
-
}
|
|
277
|
-
class FastColor {
|
|
278
|
-
constructor(input) {
|
|
279
|
-
/**
|
|
280
|
-
* All FastColor objects are valid. So isValid is always true. This property is kept to be compatible with TinyColor.
|
|
281
|
-
*/
|
|
282
|
-
_defineProperty(this, "isValid", true);
|
|
283
|
-
/**
|
|
284
|
-
* Red, R in RGB
|
|
285
|
-
*/
|
|
286
|
-
_defineProperty(this, "r", 0);
|
|
287
|
-
/**
|
|
288
|
-
* Green, G in RGB
|
|
289
|
-
*/
|
|
290
|
-
_defineProperty(this, "g", 0);
|
|
291
|
-
/**
|
|
292
|
-
* Blue, B in RGB
|
|
293
|
-
*/
|
|
294
|
-
_defineProperty(this, "b", 0);
|
|
295
|
-
/**
|
|
296
|
-
* Alpha/Opacity, A in RGBA/HSLA
|
|
297
|
-
*/
|
|
298
|
-
_defineProperty(this, "a", 1);
|
|
299
|
-
// HSV privates
|
|
300
|
-
_defineProperty(this, "_h", void 0);
|
|
301
|
-
_defineProperty(this, "_s", void 0);
|
|
302
|
-
_defineProperty(this, "_l", void 0);
|
|
303
|
-
_defineProperty(this, "_v", void 0);
|
|
304
|
-
// intermediate variables to calculate HSL/HSV
|
|
305
|
-
_defineProperty(this, "_max", void 0);
|
|
306
|
-
_defineProperty(this, "_min", void 0);
|
|
307
|
-
_defineProperty(this, "_brightness", void 0);
|
|
308
|
-
/**
|
|
309
|
-
* Always check 3 char in the object to determine the format.
|
|
310
|
-
* We not use function in check to save bundle size.
|
|
311
|
-
* e.g. 'rgb' -> { r: 0, g: 0, b: 0 }.
|
|
312
|
-
*/
|
|
313
|
-
function matchFormat(str) {
|
|
314
|
-
return str[0] in input && str[1] in input && str[2] in input;
|
|
315
|
-
}
|
|
316
|
-
if (!input) ; else if (typeof input === 'string') {
|
|
317
|
-
const trimStr = input.trim();
|
|
318
|
-
function matchPrefix(prefix) {
|
|
319
|
-
return trimStr.startsWith(prefix);
|
|
320
|
-
}
|
|
321
|
-
if (/^#?[A-F\d]{3,8}$/i.test(trimStr)) {
|
|
322
|
-
this.fromHexString(trimStr);
|
|
323
|
-
} else if (matchPrefix('rgb')) {
|
|
324
|
-
this.fromRgbString(trimStr);
|
|
325
|
-
} else if (matchPrefix('hsl')) {
|
|
326
|
-
this.fromHslString(trimStr);
|
|
327
|
-
} else if (matchPrefix('hsv') || matchPrefix('hsb')) {
|
|
328
|
-
this.fromHsvString(trimStr);
|
|
329
|
-
}
|
|
330
|
-
} else if (input instanceof FastColor) {
|
|
331
|
-
this.r = input.r;
|
|
332
|
-
this.g = input.g;
|
|
333
|
-
this.b = input.b;
|
|
334
|
-
this.a = input.a;
|
|
335
|
-
this._h = input._h;
|
|
336
|
-
this._s = input._s;
|
|
337
|
-
this._l = input._l;
|
|
338
|
-
this._v = input._v;
|
|
339
|
-
} else if (matchFormat('rgb')) {
|
|
340
|
-
this.r = limitRange(input.r);
|
|
341
|
-
this.g = limitRange(input.g);
|
|
342
|
-
this.b = limitRange(input.b);
|
|
343
|
-
this.a = typeof input.a === 'number' ? limitRange(input.a, 1) : 1;
|
|
344
|
-
} else if (matchFormat('hsl')) {
|
|
345
|
-
this.fromHsl(input);
|
|
346
|
-
} else if (matchFormat('hsv')) {
|
|
347
|
-
this.fromHsv(input);
|
|
348
|
-
} else {
|
|
349
|
-
throw new Error('@ant-design/fast-color: unsupported input ' + JSON.stringify(input));
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// ======================= Setter =======================
|
|
354
|
-
|
|
355
|
-
setR(value) {
|
|
356
|
-
return this._sc('r', value);
|
|
357
|
-
}
|
|
358
|
-
setG(value) {
|
|
359
|
-
return this._sc('g', value);
|
|
360
|
-
}
|
|
361
|
-
setB(value) {
|
|
362
|
-
return this._sc('b', value);
|
|
363
|
-
}
|
|
364
|
-
setA(value) {
|
|
365
|
-
return this._sc('a', value, 1);
|
|
366
|
-
}
|
|
367
|
-
setHue(value) {
|
|
368
|
-
const hsv = this.toHsv();
|
|
369
|
-
hsv.h = value;
|
|
370
|
-
return this._c(hsv);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// ======================= Getter =======================
|
|
374
|
-
/**
|
|
375
|
-
* Returns the perceived luminance of a color, from 0-1.
|
|
376
|
-
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
377
|
-
*/
|
|
378
|
-
getLuminance() {
|
|
379
|
-
function adjustGamma(raw) {
|
|
380
|
-
const val = raw / 255;
|
|
381
|
-
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
|
|
382
|
-
}
|
|
383
|
-
const R = adjustGamma(this.r);
|
|
384
|
-
const G = adjustGamma(this.g);
|
|
385
|
-
const B = adjustGamma(this.b);
|
|
386
|
-
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
387
|
-
}
|
|
388
|
-
getHue() {
|
|
389
|
-
if (typeof this._h === 'undefined') {
|
|
390
|
-
const delta = this.getMax() - this.getMin();
|
|
391
|
-
if (delta === 0) {
|
|
392
|
-
this._h = 0;
|
|
393
|
-
} else {
|
|
394
|
-
this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return this._h;
|
|
398
|
-
}
|
|
399
|
-
getSaturation() {
|
|
400
|
-
if (typeof this._s === 'undefined') {
|
|
401
|
-
const delta = this.getMax() - this.getMin();
|
|
402
|
-
if (delta === 0) {
|
|
403
|
-
this._s = 0;
|
|
404
|
-
} else {
|
|
405
|
-
this._s = delta / this.getMax();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return this._s;
|
|
409
|
-
}
|
|
410
|
-
getLightness() {
|
|
411
|
-
if (typeof this._l === 'undefined') {
|
|
412
|
-
this._l = (this.getMax() + this.getMin()) / 510;
|
|
413
|
-
}
|
|
414
|
-
return this._l;
|
|
415
|
-
}
|
|
416
|
-
getValue() {
|
|
417
|
-
if (typeof this._v === 'undefined') {
|
|
418
|
-
this._v = this.getMax() / 255;
|
|
419
|
-
}
|
|
420
|
-
return this._v;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Returns the perceived brightness of the color, from 0-255.
|
|
425
|
-
* Note: this is not the b of HSB
|
|
426
|
-
* @see http://www.w3.org/TR/AERT#color-contrast
|
|
427
|
-
*/
|
|
428
|
-
getBrightness() {
|
|
429
|
-
if (typeof this._brightness === 'undefined') {
|
|
430
|
-
this._brightness = (this.r * 299 + this.g * 587 + this.b * 114) / 1000;
|
|
431
|
-
}
|
|
432
|
-
return this._brightness;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// ======================== Func ========================
|
|
436
|
-
|
|
437
|
-
darken(amount = 10) {
|
|
438
|
-
const h = this.getHue();
|
|
439
|
-
const s = this.getSaturation();
|
|
440
|
-
let l = this.getLightness() - amount / 100;
|
|
441
|
-
if (l < 0) {
|
|
442
|
-
l = 0;
|
|
443
|
-
}
|
|
444
|
-
return this._c({
|
|
445
|
-
h,
|
|
446
|
-
s,
|
|
447
|
-
l,
|
|
448
|
-
a: this.a
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
lighten(amount = 10) {
|
|
452
|
-
const h = this.getHue();
|
|
453
|
-
const s = this.getSaturation();
|
|
454
|
-
let l = this.getLightness() + amount / 100;
|
|
455
|
-
if (l > 1) {
|
|
456
|
-
l = 1;
|
|
457
|
-
}
|
|
458
|
-
return this._c({
|
|
459
|
-
h,
|
|
460
|
-
s,
|
|
461
|
-
l,
|
|
462
|
-
a: this.a
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Mix the current color a given amount with another color, from 0 to 100.
|
|
468
|
-
* 0 means no mixing (return current color).
|
|
469
|
-
*/
|
|
470
|
-
mix(input, amount = 50) {
|
|
471
|
-
const color = this._c(input);
|
|
472
|
-
const p = amount / 100;
|
|
473
|
-
const calc = key => (color[key] - this[key]) * p + this[key];
|
|
474
|
-
const rgba = {
|
|
475
|
-
r: round(calc('r')),
|
|
476
|
-
g: round(calc('g')),
|
|
477
|
-
b: round(calc('b')),
|
|
478
|
-
a: round(calc('a') * 100) / 100
|
|
479
|
-
};
|
|
480
|
-
return this._c(rgba);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Mix the color with pure white, from 0 to 100.
|
|
485
|
-
* Providing 0 will do nothing, providing 100 will always return white.
|
|
486
|
-
*/
|
|
487
|
-
tint(amount = 10) {
|
|
488
|
-
return this.mix({
|
|
489
|
-
r: 255,
|
|
490
|
-
g: 255,
|
|
491
|
-
b: 255,
|
|
492
|
-
a: 1
|
|
493
|
-
}, amount);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Mix the color with pure black, from 0 to 100.
|
|
498
|
-
* Providing 0 will do nothing, providing 100 will always return black.
|
|
499
|
-
*/
|
|
500
|
-
shade(amount = 10) {
|
|
501
|
-
return this.mix({
|
|
502
|
-
r: 0,
|
|
503
|
-
g: 0,
|
|
504
|
-
b: 0,
|
|
505
|
-
a: 1
|
|
506
|
-
}, amount);
|
|
507
|
-
}
|
|
508
|
-
onBackground(background) {
|
|
509
|
-
const bg = this._c(background);
|
|
510
|
-
const alpha = this.a + bg.a * (1 - this.a);
|
|
511
|
-
const calc = key => {
|
|
512
|
-
return round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
|
|
513
|
-
};
|
|
514
|
-
return this._c({
|
|
515
|
-
r: calc('r'),
|
|
516
|
-
g: calc('g'),
|
|
517
|
-
b: calc('b'),
|
|
518
|
-
a: alpha
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// ======================= Status =======================
|
|
523
|
-
isDark() {
|
|
524
|
-
return this.getBrightness() < 128;
|
|
525
|
-
}
|
|
526
|
-
isLight() {
|
|
527
|
-
return this.getBrightness() >= 128;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// ======================== MISC ========================
|
|
531
|
-
equals(other) {
|
|
532
|
-
return this.r === other.r && this.g === other.g && this.b === other.b && this.a === other.a;
|
|
533
|
-
}
|
|
534
|
-
clone() {
|
|
535
|
-
return this._c(this);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// ======================= Format =======================
|
|
539
|
-
toHexString() {
|
|
540
|
-
let hex = '#';
|
|
541
|
-
const rHex = (this.r || 0).toString(16);
|
|
542
|
-
hex += rHex.length === 2 ? rHex : '0' + rHex;
|
|
543
|
-
const gHex = (this.g || 0).toString(16);
|
|
544
|
-
hex += gHex.length === 2 ? gHex : '0' + gHex;
|
|
545
|
-
const bHex = (this.b || 0).toString(16);
|
|
546
|
-
hex += bHex.length === 2 ? bHex : '0' + bHex;
|
|
547
|
-
if (typeof this.a === 'number' && this.a >= 0 && this.a < 1) {
|
|
548
|
-
const aHex = round(this.a * 255).toString(16);
|
|
549
|
-
hex += aHex.length === 2 ? aHex : '0' + aHex;
|
|
550
|
-
}
|
|
551
|
-
return hex;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/** CSS support color pattern */
|
|
555
|
-
toHsl() {
|
|
556
|
-
return {
|
|
557
|
-
h: this.getHue(),
|
|
558
|
-
s: this.getSaturation(),
|
|
559
|
-
l: this.getLightness(),
|
|
560
|
-
a: this.a
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/** CSS support color pattern */
|
|
565
|
-
toHslString() {
|
|
566
|
-
const h = this.getHue();
|
|
567
|
-
const s = round(this.getSaturation() * 100);
|
|
568
|
-
const l = round(this.getLightness() * 100);
|
|
569
|
-
return this.a !== 1 ? `hsla(${h},${s}%,${l}%,${this.a})` : `hsl(${h},${s}%,${l}%)`;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/** Same as toHsb */
|
|
573
|
-
toHsv() {
|
|
574
|
-
return {
|
|
575
|
-
h: this.getHue(),
|
|
576
|
-
s: this.getSaturation(),
|
|
577
|
-
v: this.getValue(),
|
|
578
|
-
a: this.a
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
toRgb() {
|
|
582
|
-
return {
|
|
583
|
-
r: this.r,
|
|
584
|
-
g: this.g,
|
|
585
|
-
b: this.b,
|
|
586
|
-
a: this.a
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
toRgbString() {
|
|
590
|
-
return this.a !== 1 ? `rgba(${this.r},${this.g},${this.b},${this.a})` : `rgb(${this.r},${this.g},${this.b})`;
|
|
591
|
-
}
|
|
592
|
-
toString() {
|
|
593
|
-
return this.toRgbString();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
// ====================== Privates ======================
|
|
597
|
-
/** Return a new FastColor object with one channel changed */
|
|
598
|
-
_sc(rgb, value, max) {
|
|
599
|
-
const clone = this.clone();
|
|
600
|
-
clone[rgb] = limitRange(value, max);
|
|
601
|
-
return clone;
|
|
602
|
-
}
|
|
603
|
-
_c(input) {
|
|
604
|
-
return new this.constructor(input);
|
|
605
|
-
}
|
|
606
|
-
getMax() {
|
|
607
|
-
if (typeof this._max === 'undefined') {
|
|
608
|
-
this._max = Math.max(this.r, this.g, this.b);
|
|
609
|
-
}
|
|
610
|
-
return this._max;
|
|
611
|
-
}
|
|
612
|
-
getMin() {
|
|
613
|
-
if (typeof this._min === 'undefined') {
|
|
614
|
-
this._min = Math.min(this.r, this.g, this.b);
|
|
615
|
-
}
|
|
616
|
-
return this._min;
|
|
617
|
-
}
|
|
618
|
-
fromHexString(trimStr) {
|
|
619
|
-
const withoutPrefix = trimStr.replace('#', '');
|
|
620
|
-
function connectNum(index1, index2) {
|
|
621
|
-
return parseInt(withoutPrefix[index1] + withoutPrefix[index2 || index1], 16);
|
|
622
|
-
}
|
|
623
|
-
if (withoutPrefix.length < 6) {
|
|
624
|
-
// #rgb or #rgba
|
|
625
|
-
this.r = connectNum(0);
|
|
626
|
-
this.g = connectNum(1);
|
|
627
|
-
this.b = connectNum(2);
|
|
628
|
-
this.a = withoutPrefix[3] ? connectNum(3) / 255 : 1;
|
|
629
|
-
} else {
|
|
630
|
-
// #rrggbb or #rrggbbaa
|
|
631
|
-
this.r = connectNum(0, 1);
|
|
632
|
-
this.g = connectNum(2, 3);
|
|
633
|
-
this.b = connectNum(4, 5);
|
|
634
|
-
this.a = withoutPrefix[6] ? connectNum(6, 7) / 255 : 1;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
fromHsl({
|
|
638
|
-
h,
|
|
639
|
-
s,
|
|
640
|
-
l,
|
|
641
|
-
a
|
|
642
|
-
}) {
|
|
643
|
-
this._h = h % 360;
|
|
644
|
-
this._s = s;
|
|
645
|
-
this._l = l;
|
|
646
|
-
this.a = typeof a === 'number' ? a : 1;
|
|
647
|
-
if (s <= 0) {
|
|
648
|
-
const rgb = round(l * 255);
|
|
649
|
-
this.r = rgb;
|
|
650
|
-
this.g = rgb;
|
|
651
|
-
this.b = rgb;
|
|
652
|
-
}
|
|
653
|
-
let r = 0,
|
|
654
|
-
g = 0,
|
|
655
|
-
b = 0;
|
|
656
|
-
const huePrime = h / 60;
|
|
657
|
-
const chroma = (1 - Math.abs(2 * l - 1)) * s;
|
|
658
|
-
const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
659
|
-
if (huePrime >= 0 && huePrime < 1) {
|
|
660
|
-
r = chroma;
|
|
661
|
-
g = secondComponent;
|
|
662
|
-
} else if (huePrime >= 1 && huePrime < 2) {
|
|
663
|
-
r = secondComponent;
|
|
664
|
-
g = chroma;
|
|
665
|
-
} else if (huePrime >= 2 && huePrime < 3) {
|
|
666
|
-
g = chroma;
|
|
667
|
-
b = secondComponent;
|
|
668
|
-
} else if (huePrime >= 3 && huePrime < 4) {
|
|
669
|
-
g = secondComponent;
|
|
670
|
-
b = chroma;
|
|
671
|
-
} else if (huePrime >= 4 && huePrime < 5) {
|
|
672
|
-
r = secondComponent;
|
|
673
|
-
b = chroma;
|
|
674
|
-
} else if (huePrime >= 5 && huePrime < 6) {
|
|
675
|
-
r = chroma;
|
|
676
|
-
b = secondComponent;
|
|
677
|
-
}
|
|
678
|
-
const lightnessModification = l - chroma / 2;
|
|
679
|
-
this.r = round((r + lightnessModification) * 255);
|
|
680
|
-
this.g = round((g + lightnessModification) * 255);
|
|
681
|
-
this.b = round((b + lightnessModification) * 255);
|
|
682
|
-
}
|
|
683
|
-
fromHsv({
|
|
684
|
-
h,
|
|
685
|
-
s,
|
|
686
|
-
v,
|
|
687
|
-
a
|
|
688
|
-
}) {
|
|
689
|
-
this._h = h % 360;
|
|
690
|
-
this._s = s;
|
|
691
|
-
this._v = v;
|
|
692
|
-
this.a = typeof a === 'number' ? a : 1;
|
|
693
|
-
const vv = round(v * 255);
|
|
694
|
-
this.r = vv;
|
|
695
|
-
this.g = vv;
|
|
696
|
-
this.b = vv;
|
|
697
|
-
if (s <= 0) {
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
const hh = h / 60;
|
|
701
|
-
const i = Math.floor(hh);
|
|
702
|
-
const ff = hh - i;
|
|
703
|
-
const p = round(v * (1.0 - s) * 255);
|
|
704
|
-
const q = round(v * (1.0 - s * ff) * 255);
|
|
705
|
-
const t = round(v * (1.0 - s * (1.0 - ff)) * 255);
|
|
706
|
-
switch (i) {
|
|
707
|
-
case 0:
|
|
708
|
-
this.g = t;
|
|
709
|
-
this.b = p;
|
|
710
|
-
break;
|
|
711
|
-
case 1:
|
|
712
|
-
this.r = q;
|
|
713
|
-
this.b = p;
|
|
714
|
-
break;
|
|
715
|
-
case 2:
|
|
716
|
-
this.r = p;
|
|
717
|
-
this.b = t;
|
|
718
|
-
break;
|
|
719
|
-
case 3:
|
|
720
|
-
this.r = p;
|
|
721
|
-
this.g = q;
|
|
722
|
-
break;
|
|
723
|
-
case 4:
|
|
724
|
-
this.r = t;
|
|
725
|
-
this.g = p;
|
|
726
|
-
break;
|
|
727
|
-
case 5:
|
|
728
|
-
default:
|
|
729
|
-
this.g = p;
|
|
730
|
-
this.b = q;
|
|
731
|
-
break;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
fromHsvString(trimStr) {
|
|
735
|
-
const cells = splitColorStr(trimStr, parseHSVorHSL);
|
|
736
|
-
this.fromHsv({
|
|
737
|
-
h: cells[0],
|
|
738
|
-
s: cells[1],
|
|
739
|
-
v: cells[2],
|
|
740
|
-
a: cells[3]
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
fromHslString(trimStr) {
|
|
744
|
-
const cells = splitColorStr(trimStr, parseHSVorHSL);
|
|
745
|
-
this.fromHsl({
|
|
746
|
-
h: cells[0],
|
|
747
|
-
s: cells[1],
|
|
748
|
-
l: cells[2],
|
|
749
|
-
a: cells[3]
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
fromRgbString(trimStr) {
|
|
753
|
-
const cells = splitColorStr(trimStr, (num, txt) =>
|
|
754
|
-
// Convert percentage to number. e.g. 50% -> 128
|
|
755
|
-
txt.includes('%') ? round(num / 100 * 255) : num);
|
|
756
|
-
this.r = cells[0];
|
|
757
|
-
this.g = cells[1];
|
|
758
|
-
this.b = cells[2];
|
|
759
|
-
this.a = cells[3];
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
var hueStep = 2; // 色相阶梯
|
|
764
|
-
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
765
|
-
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
766
|
-
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
767
|
-
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
768
|
-
var lightColorCount = 5; // 浅色数量,主色上
|
|
769
|
-
var darkColorCount = 4; // 深色数量,主色下
|
|
770
|
-
|
|
771
|
-
// 暗色主题颜色映射关系表
|
|
772
|
-
var darkColorMap = [{
|
|
773
|
-
index: 7,
|
|
774
|
-
amount: 15
|
|
775
|
-
}, {
|
|
776
|
-
index: 6,
|
|
777
|
-
amount: 25
|
|
778
|
-
}, {
|
|
779
|
-
index: 5,
|
|
780
|
-
amount: 30
|
|
781
|
-
}, {
|
|
782
|
-
index: 5,
|
|
783
|
-
amount: 45
|
|
784
|
-
}, {
|
|
785
|
-
index: 5,
|
|
786
|
-
amount: 65
|
|
787
|
-
}, {
|
|
788
|
-
index: 5,
|
|
789
|
-
amount: 85
|
|
790
|
-
}, {
|
|
791
|
-
index: 4,
|
|
792
|
-
amount: 90
|
|
793
|
-
}, {
|
|
794
|
-
index: 3,
|
|
795
|
-
amount: 95
|
|
796
|
-
}, {
|
|
797
|
-
index: 2,
|
|
798
|
-
amount: 97
|
|
799
|
-
}, {
|
|
800
|
-
index: 1,
|
|
801
|
-
amount: 98
|
|
802
|
-
}];
|
|
803
|
-
function getHue(hsv, i, light) {
|
|
804
|
-
var hue;
|
|
805
|
-
// 根据色相不同,色相转向不同
|
|
806
|
-
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
807
|
-
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
808
|
-
} else {
|
|
809
|
-
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
810
|
-
}
|
|
811
|
-
if (hue < 0) {
|
|
812
|
-
hue += 360;
|
|
813
|
-
} else if (hue >= 360) {
|
|
814
|
-
hue -= 360;
|
|
815
|
-
}
|
|
816
|
-
return hue;
|
|
817
|
-
}
|
|
818
|
-
function getSaturation(hsv, i, light) {
|
|
819
|
-
// grey color don't change saturation
|
|
820
|
-
if (hsv.h === 0 && hsv.s === 0) {
|
|
821
|
-
return hsv.s;
|
|
822
|
-
}
|
|
823
|
-
var saturation;
|
|
824
|
-
if (light) {
|
|
825
|
-
saturation = hsv.s - saturationStep * i;
|
|
826
|
-
} else if (i === darkColorCount) {
|
|
827
|
-
saturation = hsv.s + saturationStep;
|
|
828
|
-
} else {
|
|
829
|
-
saturation = hsv.s + saturationStep2 * i;
|
|
830
|
-
}
|
|
831
|
-
// 边界值修正
|
|
832
|
-
if (saturation > 1) {
|
|
833
|
-
saturation = 1;
|
|
834
|
-
}
|
|
835
|
-
// 第一格的 s 限制在 0.06-0.1 之间
|
|
836
|
-
if (light && i === lightColorCount && saturation > 0.1) {
|
|
837
|
-
saturation = 0.1;
|
|
838
|
-
}
|
|
839
|
-
if (saturation < 0.06) {
|
|
840
|
-
saturation = 0.06;
|
|
841
|
-
}
|
|
842
|
-
return Math.round(saturation * 100) / 100;
|
|
843
|
-
}
|
|
844
|
-
function getValue(hsv, i, light) {
|
|
845
|
-
var value;
|
|
846
|
-
if (light) {
|
|
847
|
-
value = hsv.v + brightnessStep1 * i;
|
|
848
|
-
} else {
|
|
849
|
-
value = hsv.v - brightnessStep2 * i;
|
|
850
|
-
}
|
|
851
|
-
// Clamp value between 0 and 1
|
|
852
|
-
value = Math.max(0, Math.min(1, value));
|
|
853
|
-
return Math.round(value * 100) / 100;
|
|
854
|
-
}
|
|
855
|
-
function generate$1(color) {
|
|
856
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
857
|
-
var patterns = [];
|
|
858
|
-
var pColor = new FastColor(color);
|
|
859
|
-
var hsv = pColor.toHsv();
|
|
860
|
-
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
861
|
-
var c = new FastColor({
|
|
862
|
-
h: getHue(hsv, i, true),
|
|
863
|
-
s: getSaturation(hsv, i, true),
|
|
864
|
-
v: getValue(hsv, i, true)
|
|
865
|
-
});
|
|
866
|
-
patterns.push(c);
|
|
867
|
-
}
|
|
868
|
-
patterns.push(pColor);
|
|
869
|
-
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
870
|
-
var _c = new FastColor({
|
|
871
|
-
h: getHue(hsv, _i),
|
|
872
|
-
s: getSaturation(hsv, _i),
|
|
873
|
-
v: getValue(hsv, _i)
|
|
874
|
-
});
|
|
875
|
-
patterns.push(_c);
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
// dark theme patterns
|
|
879
|
-
if (opts.theme === 'dark') {
|
|
880
|
-
return darkColorMap.map(function (_ref) {
|
|
881
|
-
var index = _ref.index,
|
|
882
|
-
amount = _ref.amount;
|
|
883
|
-
return new FastColor(opts.backgroundColor || '#141414').mix(patterns[index], amount).toHexString();
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
return patterns.map(function (c) {
|
|
887
|
-
return c.toHexString();
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// Generated by script. Do NOT modify!
|
|
892
|
-
|
|
893
|
-
var blue = ["#e6f4ff", "#bae0ff", "#91caff", "#69b1ff", "#4096ff", "#1677ff", "#0958d9", "#003eb3", "#002c8c", "#001d66"];
|
|
894
|
-
blue.primary = blue[5];
|
|
895
|
-
|
|
896
|
-
function ownKeys(e, r) {
|
|
897
|
-
var t = Object.keys(e);
|
|
898
|
-
if (Object.getOwnPropertySymbols) {
|
|
899
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
900
|
-
r && (o = o.filter(function (r) {
|
|
901
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
902
|
-
})), t.push.apply(t, o);
|
|
903
|
-
}
|
|
904
|
-
return t;
|
|
905
|
-
}
|
|
906
|
-
function _objectSpread2(e) {
|
|
907
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
908
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
909
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
910
|
-
_defineProperty(e, r, t[r]);
|
|
911
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
912
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
return e;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
function canUseDom() {
|
|
919
|
-
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
function contains(root, n) {
|
|
923
|
-
if (!root) {
|
|
924
|
-
return false;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
// Use native if support
|
|
928
|
-
if (root.contains) {
|
|
929
|
-
return root.contains(n);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
// `document.contains` not support with IE11
|
|
933
|
-
var node = n;
|
|
934
|
-
while (node) {
|
|
935
|
-
if (node === root) {
|
|
936
|
-
return true;
|
|
937
|
-
}
|
|
938
|
-
node = node.parentNode;
|
|
939
|
-
}
|
|
940
|
-
return false;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
var APPEND_ORDER = 'data-rc-order';
|
|
944
|
-
var APPEND_PRIORITY = 'data-rc-priority';
|
|
945
|
-
var MARK_KEY = "rc-util-key";
|
|
946
|
-
var containerCache = new Map();
|
|
947
|
-
function getMark() {
|
|
948
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
949
|
-
mark = _ref.mark;
|
|
950
|
-
if (mark) {
|
|
951
|
-
return mark.startsWith('data-') ? mark : "data-".concat(mark);
|
|
952
|
-
}
|
|
953
|
-
return MARK_KEY;
|
|
954
|
-
}
|
|
955
|
-
function getContainer(option) {
|
|
956
|
-
if (option.attachTo) {
|
|
957
|
-
return option.attachTo;
|
|
958
|
-
}
|
|
959
|
-
var head = document.querySelector('head');
|
|
960
|
-
return head || document.body;
|
|
961
|
-
}
|
|
962
|
-
function getOrder(prepend) {
|
|
963
|
-
if (prepend === 'queue') {
|
|
964
|
-
return 'prependQueue';
|
|
965
|
-
}
|
|
966
|
-
return prepend ? 'prepend' : 'append';
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* Find style which inject by rc-util
|
|
971
|
-
*/
|
|
972
|
-
function findStyles(container) {
|
|
973
|
-
return Array.from((containerCache.get(container) || container).children).filter(function (node) {
|
|
974
|
-
return node.tagName === 'STYLE';
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
function injectCSS(css) {
|
|
978
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
979
|
-
if (!canUseDom()) {
|
|
980
|
-
return null;
|
|
981
|
-
}
|
|
982
|
-
var csp = option.csp,
|
|
983
|
-
prepend = option.prepend,
|
|
984
|
-
_option$priority = option.priority,
|
|
985
|
-
priority = _option$priority === void 0 ? 0 : _option$priority;
|
|
986
|
-
var mergedOrder = getOrder(prepend);
|
|
987
|
-
var isPrependQueue = mergedOrder === 'prependQueue';
|
|
988
|
-
var styleNode = document.createElement('style');
|
|
989
|
-
styleNode.setAttribute(APPEND_ORDER, mergedOrder);
|
|
990
|
-
if (isPrependQueue && priority) {
|
|
991
|
-
styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
|
|
992
|
-
}
|
|
993
|
-
if (csp !== null && csp !== void 0 && csp.nonce) {
|
|
994
|
-
styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
|
|
995
|
-
}
|
|
996
|
-
styleNode.innerHTML = css;
|
|
997
|
-
var container = getContainer(option);
|
|
998
|
-
var firstChild = container.firstChild;
|
|
999
|
-
if (prepend) {
|
|
1000
|
-
// If is queue `prepend`, it will prepend first style and then append rest style
|
|
1001
|
-
if (isPrependQueue) {
|
|
1002
|
-
var existStyle = (option.styles || findStyles(container)).filter(function (node) {
|
|
1003
|
-
// Ignore style which not injected by rc-util with prepend
|
|
1004
|
-
if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
|
|
1005
|
-
return false;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
// Ignore style which priority less then new style
|
|
1009
|
-
var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
|
|
1010
|
-
return priority >= nodePriority;
|
|
1011
|
-
});
|
|
1012
|
-
if (existStyle.length) {
|
|
1013
|
-
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
|
|
1014
|
-
return styleNode;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
// Use `insertBefore` as `prepend`
|
|
1019
|
-
container.insertBefore(styleNode, firstChild);
|
|
1020
|
-
} else {
|
|
1021
|
-
container.appendChild(styleNode);
|
|
1022
|
-
}
|
|
1023
|
-
return styleNode;
|
|
1024
|
-
}
|
|
1025
|
-
function findExistNode(key) {
|
|
1026
|
-
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1027
|
-
var container = getContainer(option);
|
|
1028
|
-
return (option.styles || findStyles(container)).find(function (node) {
|
|
1029
|
-
return node.getAttribute(getMark(option)) === key;
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* qiankun will inject `appendChild` to insert into other
|
|
1035
|
-
*/
|
|
1036
|
-
function syncRealContainer(container, option) {
|
|
1037
|
-
var cachedRealContainer = containerCache.get(container);
|
|
1038
|
-
|
|
1039
|
-
// Find real container when not cached or cached container removed
|
|
1040
|
-
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
|
|
1041
|
-
var placeholderStyle = injectCSS('', option);
|
|
1042
|
-
var parentNode = placeholderStyle.parentNode;
|
|
1043
|
-
containerCache.set(container, parentNode);
|
|
1044
|
-
container.removeChild(placeholderStyle);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
function updateCSS(css, key) {
|
|
1048
|
-
var originOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1049
|
-
var container = getContainer(originOption);
|
|
1050
|
-
var styles = findStyles(container);
|
|
1051
|
-
var option = _objectSpread2(_objectSpread2({}, originOption), {}, {
|
|
1052
|
-
styles: styles
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
// Sync real parent
|
|
1056
|
-
syncRealContainer(container, option);
|
|
1057
|
-
var existNode = findExistNode(key, option);
|
|
1058
|
-
if (existNode) {
|
|
1059
|
-
var _option$csp, _option$csp2;
|
|
1060
|
-
if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {
|
|
1061
|
-
var _option$csp3;
|
|
1062
|
-
existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;
|
|
1063
|
-
}
|
|
1064
|
-
if (existNode.innerHTML !== css) {
|
|
1065
|
-
existNode.innerHTML = css;
|
|
1066
|
-
}
|
|
1067
|
-
return existNode;
|
|
1068
|
-
}
|
|
1069
|
-
var newNode = injectCSS(css, option);
|
|
1070
|
-
newNode.setAttribute(getMark(option), key);
|
|
1071
|
-
return newNode;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
function getRoot(ele) {
|
|
1075
|
-
var _ele$getRootNode;
|
|
1076
|
-
return ele === null || ele === void 0 || (_ele$getRootNode = ele.getRootNode) === null || _ele$getRootNode === void 0 ? void 0 : _ele$getRootNode.call(ele);
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
/**
|
|
1080
|
-
* Check if is in shadowRoot
|
|
1081
|
-
*/
|
|
1082
|
-
function inShadow(ele) {
|
|
1083
|
-
return getRoot(ele) instanceof ShadowRoot;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
/**
|
|
1087
|
-
* Return shadowRoot if possible
|
|
1088
|
-
*/
|
|
1089
|
-
function getShadowRoot(ele) {
|
|
1090
|
-
return inShadow(ele) ? getRoot(ele) : null;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
/* eslint-disable no-console */
|
|
1094
|
-
var warned = {};
|
|
1095
|
-
var preWarningFns = [];
|
|
1096
|
-
|
|
1097
|
-
/**
|
|
1098
|
-
* Pre warning enable you to parse content before console.error.
|
|
1099
|
-
* Modify to null will prevent warning.
|
|
1100
|
-
*/
|
|
1101
|
-
var preMessage = function preMessage(fn) {
|
|
1102
|
-
preWarningFns.push(fn);
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
/**
|
|
1106
|
-
* Warning if condition not match.
|
|
1107
|
-
* @param valid Condition
|
|
1108
|
-
* @param message Warning message
|
|
1109
|
-
* @example
|
|
1110
|
-
* ```js
|
|
1111
|
-
* warning(false, 'some error'); // print some error
|
|
1112
|
-
* warning(true, 'some error'); // print nothing
|
|
1113
|
-
* warning(1 === 2, 'some error'); // print some error
|
|
1114
|
-
* ```
|
|
1115
|
-
*/
|
|
1116
|
-
function warning$1(valid, message) {
|
|
1117
|
-
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
1118
|
-
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
1119
|
-
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
|
|
1120
|
-
}, message);
|
|
1121
|
-
if (finalMessage) {
|
|
1122
|
-
console.error("Warning: ".concat(finalMessage));
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
/** @see Similar to {@link warning} */
|
|
1128
|
-
function note(valid, message) {
|
|
1129
|
-
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
1130
|
-
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
1131
|
-
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
|
|
1132
|
-
}, message);
|
|
1133
|
-
if (finalMessage) {
|
|
1134
|
-
console.warn("Note: ".concat(finalMessage));
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
function resetWarned() {
|
|
1139
|
-
warned = {};
|
|
1140
|
-
}
|
|
1141
|
-
function call(method, valid, message) {
|
|
1142
|
-
if (!valid && !warned[message]) {
|
|
1143
|
-
method(false, message);
|
|
1144
|
-
warned[message] = true;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
1149
|
-
function warningOnce(valid, message) {
|
|
1150
|
-
call(warning$1, valid, message);
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
1154
|
-
function noteOnce(valid, message) {
|
|
1155
|
-
call(note, valid, message);
|
|
1156
|
-
}
|
|
1157
|
-
warningOnce.preMessage = preMessage;
|
|
1158
|
-
warningOnce.resetWarned = resetWarned;
|
|
1159
|
-
warningOnce.noteOnce = noteOnce;
|
|
1160
|
-
|
|
1161
|
-
function camelCase(input) {
|
|
1162
|
-
return input.replace(/-(.)/g, function (match, g) {
|
|
1163
|
-
return g.toUpperCase();
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
function warning(valid, message) {
|
|
1167
|
-
warningOnce(valid, "[@ant-design/icons] ".concat(message));
|
|
1168
|
-
}
|
|
1169
|
-
function isIconDefinition(target) {
|
|
1170
|
-
return _typeof(target) === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (_typeof(target.icon) === 'object' || typeof target.icon === 'function');
|
|
1171
|
-
}
|
|
1172
|
-
function normalizeAttrs() {
|
|
1173
|
-
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1174
|
-
return Object.keys(attrs).reduce(function (acc, key) {
|
|
1175
|
-
var val = attrs[key];
|
|
1176
|
-
switch (key) {
|
|
1177
|
-
case 'class':
|
|
1178
|
-
acc.className = val;
|
|
1179
|
-
delete acc.class;
|
|
1180
|
-
break;
|
|
1181
|
-
default:
|
|
1182
|
-
delete acc[key];
|
|
1183
|
-
acc[camelCase(key)] = val;
|
|
1184
|
-
}
|
|
1185
|
-
return acc;
|
|
1186
|
-
}, {});
|
|
1187
|
-
}
|
|
1188
|
-
function generate(node, key, rootProps) {
|
|
1189
|
-
if (!rootProps) {
|
|
1190
|
-
return /*#__PURE__*/React.createElement(node.tag, _objectSpread2({
|
|
1191
|
-
key: key
|
|
1192
|
-
}, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) {
|
|
1193
|
-
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
1194
|
-
}));
|
|
1195
|
-
}
|
|
1196
|
-
return /*#__PURE__*/React.createElement(node.tag, _objectSpread2(_objectSpread2({
|
|
1197
|
-
key: key
|
|
1198
|
-
}, normalizeAttrs(node.attrs)), rootProps), (node.children || []).map(function (child, index) {
|
|
1199
|
-
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
1200
|
-
}));
|
|
1201
|
-
}
|
|
1202
|
-
function getSecondaryColor(primaryColor) {
|
|
1203
|
-
// choose the second color
|
|
1204
|
-
return generate$1(primaryColor)[0];
|
|
1205
|
-
}
|
|
1206
|
-
function normalizeTwoToneColors(twoToneColor) {
|
|
1207
|
-
if (!twoToneColor) {
|
|
1208
|
-
return [];
|
|
1209
|
-
}
|
|
1210
|
-
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
|
|
1211
|
-
}
|
|
1212
|
-
var iconStyles = "\n.anticon {\n display: inline-flex;\n align-items: center;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";
|
|
1213
|
-
var useInsertStyles = function useInsertStyles(eleRef) {
|
|
1214
|
-
var _useContext = React.useContext(IconContext),
|
|
1215
|
-
csp = _useContext.csp,
|
|
1216
|
-
prefixCls = _useContext.prefixCls,
|
|
1217
|
-
layer = _useContext.layer;
|
|
1218
|
-
var mergedStyleStr = iconStyles;
|
|
1219
|
-
if (prefixCls) {
|
|
1220
|
-
mergedStyleStr = mergedStyleStr.replace(/anticon/g, prefixCls);
|
|
1221
|
-
}
|
|
1222
|
-
if (layer) {
|
|
1223
|
-
mergedStyleStr = "@layer ".concat(layer, " {\n").concat(mergedStyleStr, "\n}");
|
|
1224
|
-
}
|
|
1225
|
-
React.useEffect(function () {
|
|
1226
|
-
var ele = eleRef.current;
|
|
1227
|
-
var shadowRoot = getShadowRoot(ele);
|
|
1228
|
-
updateCSS(mergedStyleStr, '@ant-design-icons', {
|
|
1229
|
-
prepend: !layer,
|
|
1230
|
-
csp: csp,
|
|
1231
|
-
attachTo: shadowRoot
|
|
1232
|
-
});
|
|
1233
|
-
}, []);
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
|
-
var _excluded$1 = ["icon", "className", "onClick", "style", "primaryColor", "secondaryColor"];
|
|
1237
|
-
var twoToneColorPalette = {
|
|
1238
|
-
primaryColor: '#333',
|
|
1239
|
-
secondaryColor: '#E6E6E6',
|
|
1240
|
-
calculated: false
|
|
1241
|
-
};
|
|
1242
|
-
function setTwoToneColors(_ref) {
|
|
1243
|
-
var primaryColor = _ref.primaryColor,
|
|
1244
|
-
secondaryColor = _ref.secondaryColor;
|
|
1245
|
-
twoToneColorPalette.primaryColor = primaryColor;
|
|
1246
|
-
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
|
|
1247
|
-
twoToneColorPalette.calculated = !!secondaryColor;
|
|
1248
|
-
}
|
|
1249
|
-
function getTwoToneColors() {
|
|
1250
|
-
return _objectSpread2({}, twoToneColorPalette);
|
|
1251
|
-
}
|
|
1252
|
-
var IconBase = function IconBase(props) {
|
|
1253
|
-
var icon = props.icon,
|
|
1254
|
-
className = props.className,
|
|
1255
|
-
onClick = props.onClick,
|
|
1256
|
-
style = props.style,
|
|
1257
|
-
primaryColor = props.primaryColor,
|
|
1258
|
-
secondaryColor = props.secondaryColor,
|
|
1259
|
-
restProps = _objectWithoutProperties(props, _excluded$1);
|
|
1260
|
-
var svgRef = React__namespace.useRef();
|
|
1261
|
-
var colors = twoToneColorPalette;
|
|
1262
|
-
if (primaryColor) {
|
|
1263
|
-
colors = {
|
|
1264
|
-
primaryColor: primaryColor,
|
|
1265
|
-
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
|
|
1266
|
-
};
|
|
1267
|
-
}
|
|
1268
|
-
useInsertStyles(svgRef);
|
|
1269
|
-
warning(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
|
|
1270
|
-
if (!isIconDefinition(icon)) {
|
|
1271
|
-
return null;
|
|
1272
|
-
}
|
|
1273
|
-
var target = icon;
|
|
1274
|
-
if (target && typeof target.icon === 'function') {
|
|
1275
|
-
target = _objectSpread2(_objectSpread2({}, target), {}, {
|
|
1276
|
-
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
return generate(target.icon, "svg-".concat(target.name), _objectSpread2(_objectSpread2({
|
|
1280
|
-
className: className,
|
|
1281
|
-
onClick: onClick,
|
|
1282
|
-
style: style,
|
|
1283
|
-
'data-icon': target.name,
|
|
1284
|
-
width: '1em',
|
|
1285
|
-
height: '1em',
|
|
1286
|
-
fill: 'currentColor',
|
|
1287
|
-
'aria-hidden': 'true'
|
|
1288
|
-
}, restProps), {}, {
|
|
1289
|
-
ref: svgRef
|
|
1290
|
-
}));
|
|
1291
|
-
};
|
|
1292
|
-
IconBase.displayName = 'IconReact';
|
|
1293
|
-
IconBase.getTwoToneColors = getTwoToneColors;
|
|
1294
|
-
IconBase.setTwoToneColors = setTwoToneColors;
|
|
1295
|
-
|
|
1296
|
-
function setTwoToneColor(twoToneColor) {
|
|
1297
|
-
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1298
|
-
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
|
|
1299
|
-
primaryColor = _normalizeTwoToneColo2[0],
|
|
1300
|
-
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1301
|
-
return IconBase.setTwoToneColors({
|
|
1302
|
-
primaryColor: primaryColor,
|
|
1303
|
-
secondaryColor: secondaryColor
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
function getTwoToneColor() {
|
|
1307
|
-
var colors = IconBase.getTwoToneColors();
|
|
1308
|
-
if (!colors.calculated) {
|
|
1309
|
-
return colors.primaryColor;
|
|
1310
|
-
}
|
|
1311
|
-
return [colors.primaryColor, colors.secondaryColor];
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
var _excluded = ["className", "icon", "spin", "rotate", "tabIndex", "onClick", "twoToneColor"];
|
|
1315
|
-
// Initial setting
|
|
1316
|
-
// should move it to antd main repo?
|
|
1317
|
-
setTwoToneColor(blue.primary);
|
|
1318
|
-
|
|
1319
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757#issuecomment-488848720
|
|
1320
|
-
|
|
1321
|
-
var Icon = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
|
|
1322
|
-
var className = props.className,
|
|
1323
|
-
icon = props.icon,
|
|
1324
|
-
spin = props.spin,
|
|
1325
|
-
rotate = props.rotate,
|
|
1326
|
-
tabIndex = props.tabIndex,
|
|
1327
|
-
onClick = props.onClick,
|
|
1328
|
-
twoToneColor = props.twoToneColor,
|
|
1329
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
1330
|
-
var _React$useContext = React__namespace.useContext(IconContext),
|
|
1331
|
-
_React$useContext$pre = _React$useContext.prefixCls,
|
|
1332
|
-
prefixCls = _React$useContext$pre === void 0 ? 'anticon' : _React$useContext$pre,
|
|
1333
|
-
rootClassName = _React$useContext.rootClassName;
|
|
1334
|
-
var classString = classNames(rootClassName, prefixCls, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-").concat(icon.name), !!icon.name), "".concat(prefixCls, "-spin"), !!spin || icon.name === 'loading'), className);
|
|
1335
|
-
var iconTabIndex = tabIndex;
|
|
1336
|
-
if (iconTabIndex === undefined && onClick) {
|
|
1337
|
-
iconTabIndex = -1;
|
|
1338
|
-
}
|
|
1339
|
-
var svgStyle = rotate ? {
|
|
1340
|
-
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
1341
|
-
transform: "rotate(".concat(rotate, "deg)")
|
|
1342
|
-
} : undefined;
|
|
1343
|
-
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1344
|
-
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
|
|
1345
|
-
primaryColor = _normalizeTwoToneColo2[0],
|
|
1346
|
-
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1347
|
-
return /*#__PURE__*/React__namespace.createElement("span", _extends({
|
|
1348
|
-
role: "img",
|
|
1349
|
-
"aria-label": icon.name
|
|
1350
|
-
}, restProps, {
|
|
1351
|
-
ref: ref,
|
|
1352
|
-
tabIndex: iconTabIndex,
|
|
1353
|
-
onClick: onClick,
|
|
1354
|
-
className: classString
|
|
1355
|
-
}), /*#__PURE__*/React__namespace.createElement(IconBase, {
|
|
1356
|
-
icon: icon,
|
|
1357
|
-
primaryColor: primaryColor,
|
|
1358
|
-
secondaryColor: secondaryColor,
|
|
1359
|
-
style: svgStyle
|
|
1360
|
-
}));
|
|
1361
|
-
});
|
|
1362
|
-
Icon.displayName = 'AntdIcon';
|
|
1363
|
-
Icon.getTwoToneColor = getTwoToneColor;
|
|
1364
|
-
Icon.setTwoToneColor = setTwoToneColor;
|
|
1365
|
-
|
|
1366
|
-
// This icon file is generated automatically.
|
|
1367
|
-
var CodeOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M516 673c0 4.4 3.4 8 7.5 8h185c4.1 0 7.5-3.6 7.5-8v-48c0-4.4-3.4-8-7.5-8h-185c-4.1 0-7.5 3.6-7.5 8v48zm-194.9 6.1l192-161c3.8-3.2 3.8-9.1 0-12.3l-192-160.9A7.95 7.95 0 00308 351v62.7c0 2.4 1 4.6 2.9 6.1L420.7 512l-109.8 92.2a8.1 8.1 0 00-2.9 6.1V673c0 6.8 7.9 10.5 13.1 6.1zM880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z" } }] }, "name": "code", "theme": "outlined" };
|
|
1368
|
-
|
|
1369
|
-
var CodeOutlined = function CodeOutlined(props, ref) {
|
|
1370
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1371
|
-
ref: ref,
|
|
1372
|
-
icon: CodeOutlined$1
|
|
1373
|
-
}));
|
|
1374
|
-
};
|
|
1375
|
-
|
|
1376
|
-
/** */
|
|
1377
|
-
var RefIcon$8 = /*#__PURE__*/React__namespace.forwardRef(CodeOutlined);
|
|
1378
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1379
|
-
RefIcon$8.displayName = 'CodeOutlined';
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
// This icon file is generated automatically.
|
|
1383
|
-
var CopyOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z" } }] }, "name": "copy", "theme": "outlined" };
|
|
1384
|
-
|
|
1385
|
-
var CopyOutlined = function CopyOutlined(props, ref) {
|
|
1386
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1387
|
-
ref: ref,
|
|
1388
|
-
icon: CopyOutlined$1
|
|
1389
|
-
}));
|
|
1390
|
-
};
|
|
1391
|
-
|
|
1392
|
-
/** */
|
|
1393
|
-
var RefIcon$7 = /*#__PURE__*/React__namespace.forwardRef(CopyOutlined);
|
|
1394
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1395
|
-
RefIcon$7.displayName = 'CopyOutlined';
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
// This icon file is generated automatically.
|
|
1399
|
-
var DeleteOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z" } }] }, "name": "delete", "theme": "outlined" };
|
|
1400
|
-
|
|
1401
|
-
var DeleteOutlined = function DeleteOutlined(props, ref) {
|
|
1402
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1403
|
-
ref: ref,
|
|
1404
|
-
icon: DeleteOutlined$1
|
|
1405
|
-
}));
|
|
1406
|
-
};
|
|
1407
|
-
|
|
1408
|
-
/** */
|
|
1409
|
-
var RefIcon$6 = /*#__PURE__*/React__namespace.forwardRef(DeleteOutlined);
|
|
1410
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1411
|
-
RefIcon$6.displayName = 'DeleteOutlined';
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
// This icon file is generated automatically.
|
|
1415
|
-
var EditOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z" } }] }, "name": "edit", "theme": "outlined" };
|
|
1416
|
-
|
|
1417
|
-
var EditOutlined = function EditOutlined(props, ref) {
|
|
1418
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1419
|
-
ref: ref,
|
|
1420
|
-
icon: EditOutlined$1
|
|
1421
|
-
}));
|
|
1422
|
-
};
|
|
1423
|
-
|
|
1424
|
-
/** */
|
|
1425
|
-
var RefIcon$5 = /*#__PURE__*/React__namespace.forwardRef(EditOutlined);
|
|
1426
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1427
|
-
RefIcon$5.displayName = 'EditOutlined';
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
// This icon file is generated automatically.
|
|
1431
|
-
var EyeOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z" } }] }, "name": "eye", "theme": "outlined" };
|
|
1432
|
-
|
|
1433
|
-
var EyeOutlined = function EyeOutlined(props, ref) {
|
|
1434
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1435
|
-
ref: ref,
|
|
1436
|
-
icon: EyeOutlined$1
|
|
1437
|
-
}));
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
|
-
/** */
|
|
1441
|
-
var RefIcon$4 = /*#__PURE__*/React__namespace.forwardRef(EyeOutlined);
|
|
1442
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1443
|
-
RefIcon$4.displayName = 'EyeOutlined';
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
// This icon file is generated automatically.
|
|
1447
|
-
var FormOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M904 512h-56c-4.4 0-8 3.6-8 8v320H184V184h320c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V520c0-4.4-3.6-8-8-8z" } }, { "tag": "path", "attrs": { "d": "M355.9 534.9L354 653.8c-.1 8.9 7.1 16.2 16 16.2h.4l118-2.9c2-.1 4-.9 5.4-2.3l415.9-415c3.1-3.1 3.1-8.2 0-11.3L785.4 114.3c-1.6-1.6-3.6-2.3-5.7-2.3s-4.1.8-5.7 2.3l-415.8 415a8.3 8.3 0 00-2.3 5.6zm63.5 23.6L779.7 199l45.2 45.1-360.5 359.7-45.7 1.1.7-46.4z" } }] }, "name": "form", "theme": "outlined" };
|
|
1448
|
-
|
|
1449
|
-
var FormOutlined = function FormOutlined(props, ref) {
|
|
1450
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1451
|
-
ref: ref,
|
|
1452
|
-
icon: FormOutlined$1
|
|
1453
|
-
}));
|
|
1454
|
-
};
|
|
1455
|
-
|
|
1456
|
-
/** */
|
|
1457
|
-
var RefIcon$3 = /*#__PURE__*/React__namespace.forwardRef(FormOutlined);
|
|
1458
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1459
|
-
RefIcon$3.displayName = 'FormOutlined';
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
// This icon file is generated automatically.
|
|
1463
|
-
var PlusOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z" } }, { "tag": "path", "attrs": { "d": "M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z" } }] }, "name": "plus", "theme": "outlined" };
|
|
1464
|
-
|
|
1465
|
-
var PlusOutlined = function PlusOutlined(props, ref) {
|
|
1466
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1467
|
-
ref: ref,
|
|
1468
|
-
icon: PlusOutlined$1
|
|
1469
|
-
}));
|
|
1470
|
-
};
|
|
1471
|
-
|
|
1472
|
-
/** */
|
|
1473
|
-
var RefIcon$2 = /*#__PURE__*/React__namespace.forwardRef(PlusOutlined);
|
|
1474
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1475
|
-
RefIcon$2.displayName = 'PlusOutlined';
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
// This icon file is generated automatically.
|
|
1479
|
-
var ReloadOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z" } }] }, "name": "reload", "theme": "outlined" };
|
|
1480
|
-
|
|
1481
|
-
var ReloadOutlined = function ReloadOutlined(props, ref) {
|
|
1482
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1483
|
-
ref: ref,
|
|
1484
|
-
icon: ReloadOutlined$1
|
|
1485
|
-
}));
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
|
-
/** */
|
|
1489
|
-
var RefIcon$1 = /*#__PURE__*/React__namespace.forwardRef(ReloadOutlined);
|
|
1490
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1491
|
-
RefIcon$1.displayName = 'ReloadOutlined';
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
// This icon file is generated automatically.
|
|
1495
|
-
var SearchOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z" } }] }, "name": "search", "theme": "outlined" };
|
|
1496
|
-
|
|
1497
|
-
var SearchOutlined = function SearchOutlined(props, ref) {
|
|
1498
|
-
return /*#__PURE__*/React__namespace.createElement(Icon, _extends({}, props, {
|
|
1499
|
-
ref: ref,
|
|
1500
|
-
icon: SearchOutlined$1
|
|
1501
|
-
}));
|
|
1502
|
-
};
|
|
1503
|
-
|
|
1504
|
-
/** */
|
|
1505
|
-
var RefIcon = /*#__PURE__*/React__namespace.forwardRef(SearchOutlined);
|
|
1506
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1507
|
-
RefIcon.displayName = 'SearchOutlined';
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
10
|
/* ─── 工具函数 ──────────────────────────────────────── */
|
|
1511
11
|
/**
|
|
1512
12
|
* 根据数据类型推导默认 UI 组件
|
|
@@ -1621,7 +121,7 @@ function renderFilterInput(field, cfg) {
|
|
|
1621
121
|
}
|
|
1622
122
|
function DynamicFilter({ schema, onSearch, onReset }) {
|
|
1623
123
|
const [form] = antd.Form.useForm();
|
|
1624
|
-
const [expanded, setExpanded] =
|
|
124
|
+
const [expanded, setExpanded] = react.useState(false);
|
|
1625
125
|
const filterFields = schema.fields.filter((f) => f.filter !== false && f.filter !== undefined && f.type !== 'objectArray');
|
|
1626
126
|
const handleFinish = (values) => {
|
|
1627
127
|
onSearch(values);
|
|
@@ -1638,7 +138,7 @@ function DynamicFilter({ schema, onSearch, onReset }) {
|
|
|
1638
138
|
// inputNumber 数字范围:name 不放在 Form.Item 上,由内部子 Form.Item 承载
|
|
1639
139
|
const isNumberRange = widget === 'inputNumber' && (cfg === null || cfg === void 0 ? void 0 : cfg.range);
|
|
1640
140
|
return (jsxRuntime.jsx(antd.Col, Object.assign({}, colSpan, { children: jsxRuntime.jsx(antd.Form.Item, { label: field.label, name: isNumberRange ? undefined : field.key, valuePropName: widget === 'switch' ? 'checked' : 'value', children: renderFilterInput(field, cfg) }) }), field.key));
|
|
1641
|
-
}), jsxRuntime.jsx(antd.Col, Object.assign({}, colSpan, { children: jsxRuntime.jsx(antd.Form.Item, { label: " ", children: jsxRuntime.jsxs(antd.Space, { children: [jsxRuntime.jsx(antd.Button, { type: "primary", htmlType: "submit", icon: jsxRuntime.jsx(
|
|
141
|
+
}), jsxRuntime.jsx(antd.Col, Object.assign({}, colSpan, { children: jsxRuntime.jsx(antd.Form.Item, { label: " ", children: jsxRuntime.jsxs(antd.Space, { children: [jsxRuntime.jsx(antd.Button, { type: "primary", htmlType: "submit", icon: jsxRuntime.jsx(icons.SearchOutlined, {}), children: "\u641C\u7D22" }), jsxRuntime.jsx(antd.Button, { onClick: handleReset, icon: jsxRuntime.jsx(icons.ReloadOutlined, {}), children: "\u91CD\u7F6E" }), filterFields.length > 4 && (jsxRuntime.jsx(antd.Button, { type: "link", onClick: () => setExpanded(!expanded), children: expanded ? '收起' : '展开' }))] }) }) }))] }) }));
|
|
1642
142
|
}
|
|
1643
143
|
|
|
1644
144
|
function getTableConfig(field) {
|
|
@@ -1752,16 +252,16 @@ function DynamicTable({ schema, data, loading, pagination, onView, onEdit, onDel
|
|
|
1752
252
|
return (jsxRuntime.jsxs(antd.Space, { size: 4, children: [((_a = schema.actions) !== null && _a !== void 0 ? _a : []).map((action) => {
|
|
1753
253
|
var _a, _b, _c;
|
|
1754
254
|
if (action.type === 'view') {
|
|
1755
|
-
return (jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(
|
|
255
|
+
return (jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(icons.EyeOutlined, {}), onClick: () => onView(record) }) }, action.key));
|
|
1756
256
|
}
|
|
1757
257
|
if (action.type === 'edit') {
|
|
1758
|
-
return (jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(
|
|
258
|
+
return (jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(icons.EditOutlined, {}), onClick: () => onEdit(record) }) }, action.key));
|
|
1759
259
|
}
|
|
1760
260
|
if (action.type === 'delete') {
|
|
1761
|
-
return (jsxRuntime.jsx(antd.Popconfirm, { title: (_b = (_a = action.confirm) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : '确定删除?', description: (_c = action.confirm) === null || _c === void 0 ? void 0 : _c.content, onConfirm: () => onDelete(record), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", okButtonProps: { danger: true }, children: jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", danger: true, icon: jsxRuntime.jsx(
|
|
261
|
+
return (jsxRuntime.jsx(antd.Popconfirm, { title: (_b = (_a = action.confirm) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : '确定删除?', description: (_c = action.confirm) === null || _c === void 0 ? void 0 : _c.content, onConfirm: () => onDelete(record), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", okButtonProps: { danger: true }, children: jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", danger: true, icon: jsxRuntime.jsx(icons.DeleteOutlined, {}) }) }) }, action.key));
|
|
1762
262
|
}
|
|
1763
263
|
return (jsxRuntime.jsx(antd.Tooltip, { title: action.label, children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", onClick: () => onCustomAction === null || onCustomAction === void 0 ? void 0 : onCustomAction(action.key, record), children: action.label }) }, action.key));
|
|
1764
|
-
}), jsxRuntime.jsx(antd.Tooltip, { title: "\u590D\u5236 JSON", children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(
|
|
264
|
+
}), jsxRuntime.jsx(antd.Tooltip, { title: "\u590D\u5236 JSON", children: jsxRuntime.jsx(antd.Button, { type: "link", size: "small", icon: jsxRuntime.jsx(icons.CopyOutlined, {}), onClick: () => copyJson(record) }) })] }));
|
|
1765
265
|
},
|
|
1766
266
|
});
|
|
1767
267
|
return (jsxRuntime.jsx(antd.Table, { rowKey: (_c = schema.rowKey) !== null && _c !== void 0 ? _c : 'id', columns: columns, dataSource: data, loading: loading, scroll: { x: 'max-content' }, pagination: {
|
|
@@ -2083,11 +583,11 @@ function renderFormInput(field, cfg, disabled) {
|
|
|
2083
583
|
? [{
|
|
2084
584
|
title: '',
|
|
2085
585
|
width: 50,
|
|
2086
|
-
render: (_, record) => (jsxRuntime.jsx(antd.Button, { type: "text", danger: true, icon: jsxRuntime.jsx(
|
|
586
|
+
render: (_, record) => (jsxRuntime.jsx(antd.Button, { type: "text", danger: true, icon: jsxRuntime.jsx(icons.DeleteOutlined, {}), onClick: () => remove(record.name) })),
|
|
2087
587
|
}]
|
|
2088
588
|
: []),
|
|
2089
589
|
];
|
|
2090
|
-
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(antd.Table, { size: "small", dataSource: listFields.map((f) => (Object.assign(Object.assign({}, f), { _key: f.key }))), rowKey: "_key", columns: columns, pagination: false, style: { marginBottom: 8 } }), !disabled && (jsxRuntime.jsx(antd.Button, { type: "dashed", icon: jsxRuntime.jsx(
|
|
590
|
+
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(antd.Table, { size: "small", dataSource: listFields.map((f) => (Object.assign(Object.assign({}, f), { _key: f.key }))), rowKey: "_key", columns: columns, pagination: false, style: { marginBottom: 8 } }), !disabled && (jsxRuntime.jsx(antd.Button, { type: "dashed", icon: jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => add({}), block: true, children: "\u6DFB\u52A0\u4E00\u884C" }))] }));
|
|
2091
591
|
} }));
|
|
2092
592
|
}
|
|
2093
593
|
default:
|
|
@@ -2189,9 +689,9 @@ function renderField(field, disabled) {
|
|
|
2189
689
|
}
|
|
2190
690
|
function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel, }) {
|
|
2191
691
|
const [form] = antd.Form.useForm();
|
|
2192
|
-
const [rawJsonMode, setRawJsonMode] =
|
|
2193
|
-
const [rawJsonText, setRawJsonText] =
|
|
2194
|
-
const [rawJsonError, setRawJsonError] =
|
|
692
|
+
const [rawJsonMode, setRawJsonMode] = react.useState(false);
|
|
693
|
+
const [rawJsonText, setRawJsonText] = react.useState('');
|
|
694
|
+
const [rawJsonError, setRawJsonError] = react.useState('');
|
|
2195
695
|
const disabled = mode === 'view';
|
|
2196
696
|
const entityName = schema.title.replace(/管理$/, '');
|
|
2197
697
|
const titleMap = {
|
|
@@ -2204,7 +704,7 @@ function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel,
|
|
|
2204
704
|
return f.table !== false && f.table !== undefined;
|
|
2205
705
|
return f.form !== false && f.form !== undefined;
|
|
2206
706
|
});
|
|
2207
|
-
|
|
707
|
+
react.useEffect(() => {
|
|
2208
708
|
if (!visible) {
|
|
2209
709
|
form.resetFields();
|
|
2210
710
|
setRawJsonMode(false);
|
|
@@ -2216,7 +716,10 @@ function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel,
|
|
|
2216
716
|
if (mode === 'create') {
|
|
2217
717
|
// 新增模式:清空表单并确保没有残留数据
|
|
2218
718
|
form.resetFields();
|
|
2219
|
-
|
|
719
|
+
// 延迟一下确保resetFields完成
|
|
720
|
+
setTimeout(() => {
|
|
721
|
+
form.setFieldsValue({});
|
|
722
|
+
}, 0);
|
|
2220
723
|
}
|
|
2221
724
|
else {
|
|
2222
725
|
// 编辑/查看模式设置初始值
|
|
@@ -2224,7 +727,7 @@ function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel,
|
|
|
2224
727
|
form.setFieldsValue(normalized);
|
|
2225
728
|
}
|
|
2226
729
|
}
|
|
2227
|
-
}, [visible, mode, initialValues]);
|
|
730
|
+
}, [visible, mode, initialValues, form, formFields]);
|
|
2228
731
|
const switchToRaw = () => {
|
|
2229
732
|
// getFieldsValue(true) 返回 store 全量数据(含 id 等非 Form.Item 字段)
|
|
2230
733
|
const rawValues = disabled
|
|
@@ -2304,14 +807,17 @@ function DynamicForm({ schema, mode, visible, initialValues, onSubmit, onCancel,
|
|
|
2304
807
|
.then(() => void antd.message.success('已复制 JSON'))
|
|
2305
808
|
.catch(() => void antd.message.error('复制失败'));
|
|
2306
809
|
};
|
|
2307
|
-
const modalTitle = (jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', paddingRight: 32 }, children: [jsxRuntime.jsx("span", { children: titleMap[mode] }), jsxRuntime.jsx(antd.Space, { size: 8, children: jsxRuntime.jsx(antd.Button, { size: "small", type: "text", icon: rawJsonMode ? jsxRuntime.jsx(
|
|
2308
|
-
return (jsxRuntime.jsxs(antd.Modal, { title: modalTitle, open: visible, onOk: handleOk, onCancel: onCancel, okText: disabled ? '关闭' : '确认', cancelText: "\u53D6\u6D88", cancelButtonProps: disabled ? { style: { display: 'none' } } : {}, width: 720, destroyOnClose: true, children: [jsxRuntime.jsx("div", { style: { display: rawJsonMode ? 'none' : undefined }, children: jsxRuntime.jsx(antd.Form, { form: form, layout: "vertical", initialValues:
|
|
810
|
+
const modalTitle = (jsxRuntime.jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', paddingRight: 32 }, children: [jsxRuntime.jsx("span", { children: titleMap[mode] }), jsxRuntime.jsx(antd.Space, { size: 8, children: jsxRuntime.jsx(antd.Button, { size: "small", type: "text", icon: rawJsonMode ? jsxRuntime.jsx(icons.FormOutlined, {}) : jsxRuntime.jsx(icons.CodeOutlined, {}), onClick: rawJsonMode ? switchToForm : switchToRaw, children: rawJsonMode ? '表单视图' : 'Raw JSON' }) })] }));
|
|
811
|
+
return (jsxRuntime.jsxs(antd.Modal, { title: modalTitle, open: visible, onOk: handleOk, onCancel: onCancel, okText: disabled ? '关闭' : '确认', cancelText: "\u53D6\u6D88", cancelButtonProps: disabled ? { style: { display: 'none' } } : {}, width: 720, destroyOnClose: true, children: [jsxRuntime.jsx("div", { style: { display: rawJsonMode ? 'none' : undefined }, children: jsxRuntime.jsx(antd.Form, { form: form, layout: "vertical", initialValues: {}, children: renderFieldGroups() }) }), rawJsonMode && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(antd.Input.TextArea, { value: rawJsonText, onChange: disabled ? undefined : (e) => { setRawJsonText(e.target.value); setRawJsonError(''); }, readOnly: disabled, rows: 20, style: { fontFamily: 'monospace', fontSize: 12, resize: 'vertical' }, status: rawJsonError ? 'error' : undefined }), rawJsonError && (jsxRuntime.jsx("div", { style: { color: '#ff4d4f', fontSize: 12, marginTop: 4 }, children: rawJsonError })), !disabled && (jsxRuntime.jsx("div", { style: { marginTop: 8, textAlign: 'right' }, children: jsxRuntime.jsx(antd.Button, { size: "small", icon: jsxRuntime.jsx(icons.CodeOutlined, {}), onClick: copyRawJson, children: "\u590D\u5236 JSON" }) }))] }))] }));
|
|
2309
812
|
}
|
|
2310
813
|
|
|
2311
814
|
const { Title } = antd.Typography;
|
|
2312
|
-
/**
|
|
2313
|
-
function buildUrl(template,
|
|
2314
|
-
return template.replace(/:
|
|
815
|
+
/** 动态替换 URL 模板中的占位符 */
|
|
816
|
+
function buildUrl(template, record) {
|
|
817
|
+
return template.replace(/:(\w+)/g, (match, fieldName) => {
|
|
818
|
+
const value = record[fieldName];
|
|
819
|
+
return value !== undefined ? String(value) : match;
|
|
820
|
+
});
|
|
2315
821
|
}
|
|
2316
822
|
/** 通用请求封装 */
|
|
2317
823
|
async function apiRequest(url, options) {
|
|
@@ -2343,17 +849,17 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2343
849
|
// 使用传入的apiRequest或默认的
|
|
2344
850
|
const request = customApiRequest || apiRequest;
|
|
2345
851
|
// 本地兜底数据(API 失败时使用)
|
|
2346
|
-
const localDataRef =
|
|
2347
|
-
const [data, setData] =
|
|
2348
|
-
const [loading, setLoading] =
|
|
2349
|
-
const [total, setTotal] =
|
|
2350
|
-
const [filterParams, setFilterParams] =
|
|
2351
|
-
const [page, setPage] =
|
|
2352
|
-
const [pageSize, setPageSize] =
|
|
2353
|
-
const [modalState, setModalState] =
|
|
852
|
+
const localDataRef = react.useRef(initialData);
|
|
853
|
+
const [data, setData] = react.useState([]);
|
|
854
|
+
const [loading, setLoading] = react.useState(false);
|
|
855
|
+
const [total, setTotal] = react.useState(0);
|
|
856
|
+
const [filterParams, setFilterParams] = react.useState({});
|
|
857
|
+
const [page, setPage] = react.useState(1);
|
|
858
|
+
const [pageSize, setPageSize] = react.useState(((_a = schema.pagination) === null || _a === void 0 ? void 0 : _a.pageSize) || 10);
|
|
859
|
+
const [modalState, setModalState] = react.useState({ open: false, mode: 'create' });
|
|
2354
860
|
const [messageApi, contextHolder] = antd.message.useMessage();
|
|
2355
861
|
// ---------- 本地过滤(API 失败时兜底) ----------
|
|
2356
|
-
const localFilter =
|
|
862
|
+
const localFilter = react.useCallback((params, p, ps) => {
|
|
2357
863
|
const filtered = localDataRef.current.filter(row => {
|
|
2358
864
|
return Object.entries(params).every(([key, val]) => {
|
|
2359
865
|
if (val === undefined || val === null || val === '')
|
|
@@ -2378,7 +884,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2378
884
|
setTotal(filtered.length);
|
|
2379
885
|
}, []);
|
|
2380
886
|
// ---------- 获取列表 ----------
|
|
2381
|
-
const fetchList =
|
|
887
|
+
const fetchList = react.useCallback(async (params = filterParams, p = page, ps = pageSize) => {
|
|
2382
888
|
setLoading(true);
|
|
2383
889
|
try {
|
|
2384
890
|
const query = new URLSearchParams({ page: String(p), pageSize: String(ps) });
|
|
@@ -2400,26 +906,26 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2400
906
|
}
|
|
2401
907
|
}, [request, schema.api.list, filterParams, page, pageSize, localFilter]);
|
|
2402
908
|
// 初始加载 & 参数变化时重新请求
|
|
2403
|
-
|
|
909
|
+
react.useEffect(() => {
|
|
2404
910
|
fetchList(filterParams, page, pageSize);
|
|
2405
911
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2406
912
|
}, [filterParams, page, pageSize]);
|
|
2407
913
|
// ---------- 搜索 ----------
|
|
2408
|
-
const handleSearch =
|
|
914
|
+
const handleSearch = react.useCallback((params) => {
|
|
2409
915
|
setFilterParams(params);
|
|
2410
916
|
setPage(1);
|
|
2411
917
|
}, []);
|
|
2412
918
|
// ---------- 翻页 ----------
|
|
2413
|
-
const handlePageChange =
|
|
919
|
+
const handlePageChange = react.useCallback((p, ps) => {
|
|
2414
920
|
setPage(p);
|
|
2415
921
|
setPageSize(ps);
|
|
2416
922
|
}, []);
|
|
2417
923
|
// ---------- 删除 ----------
|
|
2418
|
-
const handleDelete =
|
|
924
|
+
const handleDelete = react.useCallback(async (record) => {
|
|
2419
925
|
const id = record[rowKey];
|
|
2420
926
|
if (schema.api.delete) {
|
|
2421
927
|
try {
|
|
2422
|
-
await request(buildUrl(schema.api.delete,
|
|
928
|
+
await request(buildUrl(schema.api.delete, record), { method: 'DELETE' });
|
|
2423
929
|
messageApi.success('删除成功');
|
|
2424
930
|
fetchList();
|
|
2425
931
|
return;
|
|
@@ -2433,7 +939,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2433
939
|
messageApi.success('删除成功(演示模式)');
|
|
2434
940
|
}, [request, schema.api.delete, rowKey, fetchList, localFilter, filterParams, page, pageSize, messageApi]);
|
|
2435
941
|
// ---------- 操作列点击 ----------
|
|
2436
|
-
const handleAction =
|
|
942
|
+
const handleAction = react.useCallback(async (action, record) => {
|
|
2437
943
|
if (action.type === 'view') {
|
|
2438
944
|
setModalState({ open: true, mode: 'view', record });
|
|
2439
945
|
}
|
|
@@ -2443,9 +949,62 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2443
949
|
else if (action.type === 'delete') {
|
|
2444
950
|
handleDelete(record);
|
|
2445
951
|
}
|
|
2446
|
-
|
|
952
|
+
else if (action.type === 'custom' && action.api) {
|
|
953
|
+
// 处理自定义 action 的 API 调用
|
|
954
|
+
try {
|
|
955
|
+
// 构建 URL,动态替换占位符
|
|
956
|
+
let url = action.api.url;
|
|
957
|
+
// 替换所有 :fieldName 格式的占位符
|
|
958
|
+
url = url.replace(/:(\w+)/g, (match, fieldName) => {
|
|
959
|
+
const value = record[fieldName];
|
|
960
|
+
return value !== undefined ? String(value) : match;
|
|
961
|
+
});
|
|
962
|
+
// 构建请求选项
|
|
963
|
+
const options = {
|
|
964
|
+
method: action.api.method,
|
|
965
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, action.api.headers)
|
|
966
|
+
};
|
|
967
|
+
// 添加请求体数据
|
|
968
|
+
if (action.api.data && ['POST', 'PUT', 'PATCH'].includes(action.api.method)) {
|
|
969
|
+
options.body = JSON.stringify(Object.assign(Object.assign({}, action.api.data), {
|
|
970
|
+
// 可以添加动态数据
|
|
971
|
+
recordId: record[rowKey], timestamp: new Date().toISOString() }));
|
|
972
|
+
}
|
|
973
|
+
// 调用 API
|
|
974
|
+
const response = await request(url, options);
|
|
975
|
+
// 处理特殊响应类型
|
|
976
|
+
if (action.api.responseType === 'blob') {
|
|
977
|
+
// 处理文件下载
|
|
978
|
+
const blob = new Blob([response]);
|
|
979
|
+
const downloadUrl = URL.createObjectURL(blob);
|
|
980
|
+
const a = document.createElement('a');
|
|
981
|
+
a.href = downloadUrl;
|
|
982
|
+
a.download = `${action.key}.pdf`;
|
|
983
|
+
a.click();
|
|
984
|
+
URL.revokeObjectURL(downloadUrl);
|
|
985
|
+
messageApi.success(`${action.label}成功`);
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
// 处理 JSON 响应
|
|
989
|
+
const result = response;
|
|
990
|
+
if (result.success !== false) {
|
|
991
|
+
messageApi.success(`${action.label}成功`);
|
|
992
|
+
// 刷新数据
|
|
993
|
+
await fetchList();
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
messageApi.error(result.message || `${action.label}失败`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
catch (error) {
|
|
1001
|
+
console.error(`Action ${action.key} failed:`, error);
|
|
1002
|
+
messageApi.error(`${action.label}失败`);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}, [handleDelete, rowKey, request, messageApi, fetchList]);
|
|
2447
1006
|
// ---------- 新增 / 编辑提交 ----------
|
|
2448
|
-
const handleFormOk =
|
|
1007
|
+
const handleFormOk = react.useCallback(async (values) => {
|
|
2449
1008
|
const isCreate = modalState.mode === 'create';
|
|
2450
1009
|
if (isCreate) {
|
|
2451
1010
|
if (schema.api.create) {
|
|
@@ -2473,7 +1032,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2473
1032
|
const id = values[rowKey];
|
|
2474
1033
|
if (schema.api.update) {
|
|
2475
1034
|
try {
|
|
2476
|
-
await request(buildUrl(schema.api.update,
|
|
1035
|
+
await request(buildUrl(schema.api.update, values), {
|
|
2477
1036
|
method: 'PUT',
|
|
2478
1037
|
body: JSON.stringify(values),
|
|
2479
1038
|
});
|
|
@@ -2495,7 +1054,7 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
2495
1054
|
request, modalState.mode, schema.api, rowKey,
|
|
2496
1055
|
fetchList, localFilter, filterParams, page, pageSize, messageApi,
|
|
2497
1056
|
]);
|
|
2498
|
-
return (jsxRuntime.jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsxRuntime.jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsxRuntime.jsx(antd.Button, { type: "primary", icon: jsxRuntime.jsx(
|
|
1057
|
+
return (jsxRuntime.jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsxRuntime.jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsxRuntime.jsx(antd.Button, { type: "primary", icon: jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => setModalState({ open: true, mode: 'create', record: undefined }), children: schema.createButtonLabel || '新增' }))] }), jsxRuntime.jsx(DynamicFilter, { schema: schema, onSearch: handleSearch, onReset: () => handleSearch({}) }), jsxRuntime.jsx(DynamicTable, { schema: schema, data: data, loading: loading, pagination: {
|
|
2499
1058
|
current: page,
|
|
2500
1059
|
pageSize,
|
|
2501
1060
|
total,
|