zmdms-webui 0.0.76 → 0.0.78

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.
Files changed (81) hide show
  1. package/dist/es/_virtual/Draggable.js +3 -0
  2. package/dist/es/_virtual/DraggableCore.js +3 -0
  3. package/dist/es/_virtual/Resizable.js +3 -0
  4. package/dist/es/_virtual/ResizableBox.js +3 -0
  5. package/dist/es/_virtual/_commonjsHelpers.js +29 -1
  6. package/dist/es/_virtual/cjs.js +3 -0
  7. package/dist/es/_virtual/clsx.m.js +6 -0
  8. package/dist/es/_virtual/domFns.js +3 -0
  9. package/dist/es/_virtual/getPrefix.js +3 -0
  10. package/dist/es/_virtual/index3.js +3 -0
  11. package/dist/es/_virtual/index4.js +3 -0
  12. package/dist/es/_virtual/index5.js +3 -0
  13. package/dist/es/_virtual/log.js +3 -0
  14. package/dist/es/_virtual/positionFns.js +3 -0
  15. package/dist/es/_virtual/propTypes.js +3 -0
  16. package/dist/es/_virtual/react-is.development.js +3 -0
  17. package/dist/es/_virtual/react-is.production.min.js +3 -0
  18. package/dist/es/_virtual/shims.js +3 -0
  19. package/dist/es/_virtual/utils.js +3 -0
  20. package/dist/es/button/button.js +14 -9
  21. package/dist/es/button/interface.d.ts +2 -0
  22. package/dist/es/dynamicsetting/dynamicDrawer.js +88 -5
  23. package/dist/es/dynamicsetting/dynamicSetting.js +7 -2
  24. package/dist/es/dynamicsetting/interface.d.ts +4 -0
  25. package/dist/es/dynamicsetting/moreConfig.js +36 -0
  26. package/dist/es/dynamicsetting/useDynamic.js +65 -25
  27. package/dist/es/form/form.d.ts +1 -1
  28. package/dist/es/form/form.js +18 -6
  29. package/dist/es/form/hooks.js +37 -5
  30. package/dist/es/form/interface.d.ts +7 -0
  31. package/dist/es/form/toggle.js +16 -0
  32. package/dist/es/node_modules/@ant-design/icons/es/icons/MenuOutlined.js +15 -0
  33. package/dist/es/node_modules/@ant-design/icons/es/utils.js +3 -1
  34. package/dist/es/node_modules/@ant-design/icons-svg/es/asn/MenuOutlined.js +5 -0
  35. package/dist/es/node_modules/@ant-design/icons-svg/es/asn/PlusOutlined.js +1 -1
  36. package/dist/es/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +19 -19
  37. package/dist/es/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +15 -15
  38. package/dist/es/node_modules/@babel/runtime/helpers/esm/typeof.js +6 -6
  39. package/dist/es/node_modules/antd-img-crop/dist/antd-img-crop.esm.js +7 -7
  40. package/dist/es/node_modules/clsx/dist/clsx.m.js +3 -0
  41. package/dist/es/node_modules/compare-versions/lib/esm/compareVersions.js +31 -0
  42. package/dist/es/node_modules/compare-versions/lib/esm/{index.js → utils.js} +1 -28
  43. package/dist/es/node_modules/object-assign/index.js +99 -0
  44. package/dist/es/node_modules/prop-types/checkPropTypes.js +115 -0
  45. package/dist/es/node_modules/prop-types/factoryWithThrowingShims.js +74 -0
  46. package/dist/es/node_modules/prop-types/factoryWithTypeCheckers.js +625 -0
  47. package/dist/es/node_modules/prop-types/index.js +28 -0
  48. package/dist/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +21 -0
  49. package/dist/es/node_modules/prop-types/lib/has.js +11 -0
  50. package/dist/es/node_modules/react-draggable/build/cjs/Draggable.js +474 -0
  51. package/dist/es/node_modules/react-draggable/build/cjs/DraggableCore.js +580 -0
  52. package/dist/es/node_modules/react-draggable/build/cjs/cjs.js +18 -0
  53. package/dist/es/node_modules/react-draggable/build/cjs/utils/domFns.js +361 -0
  54. package/dist/es/node_modules/react-draggable/build/cjs/utils/getPrefix.js +85 -0
  55. package/dist/es/node_modules/react-draggable/build/cjs/utils/log.js +10 -0
  56. package/dist/es/node_modules/react-draggable/build/cjs/utils/positionFns.js +214 -0
  57. package/dist/es/node_modules/react-draggable/build/cjs/utils/shims.js +64 -0
  58. package/dist/es/node_modules/react-easy-crop/index.module.js +51 -18
  59. package/dist/es/node_modules/react-is/cjs/react-is.development.js +190 -0
  60. package/dist/es/node_modules/react-is/cjs/react-is.production.min.js +26 -0
  61. package/dist/es/node_modules/react-is/index.js +19 -0
  62. package/dist/es/node_modules/react-resizable/build/Resizable.js +262 -0
  63. package/dist/es/node_modules/react-resizable/build/ResizableBox.js +117 -0
  64. package/dist/es/node_modules/react-resizable/build/propTypes.js +120 -0
  65. package/dist/es/node_modules/react-resizable/build/utils.js +24 -0
  66. package/dist/es/node_modules/react-resizable/index.js +14 -0
  67. package/dist/es/node_modules/virtuallist-antd/dist/index.es.js +942 -0
  68. package/dist/es/table/components/EnhanceBodyRow.js +24 -0
  69. package/dist/es/table/components/EnhanceHeaderCell.js +41 -0
  70. package/dist/es/table/components/TitleOperation.js +1 -1
  71. package/dist/es/table/components/useDragRef.js +10 -11
  72. package/dist/es/table/interface.d.ts +14 -0
  73. package/dist/es/table/table.js +72 -25
  74. package/dist/es/table/useColumns.js +144 -66
  75. package/dist/es/table/useDynamicListByColumns.js +63 -20
  76. package/dist/es/table/utils.js +59 -21
  77. package/dist/index.dark.css +1 -1
  78. package/dist/index.default.css +1 -1
  79. package/package.json +5 -4
  80. package/dist/es/table/components/EnhanceRow.js +0 -21
  81. /package/dist/es/table/components/{EnhanceCell.js → EnhanceBodyCell.js} +0 -0
@@ -0,0 +1,942 @@
1
+ import React__default, { createContext, useContext, useRef, useEffect, useMemo, useReducer, useState } from 'react';
2
+
3
+ /*! *****************************************************************************
4
+ Copyright (c) Microsoft Corporation. All rights reserved.
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12
+ MERCHANTABLITY OR NON-INFRINGEMENT.
13
+
14
+ See the Apache Version 2.0 License for specific language governing permissions
15
+ and limitations under the License.
16
+ ***************************************************************************** */
17
+
18
+ var __assign = function() {
19
+ __assign = Object.assign || function __assign(t) {
20
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
21
+ s = arguments[i];
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+
29
+ function __rest(s, e) {
30
+ var t = {};
31
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
32
+ t[p] = s[p];
33
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
34
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
35
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
36
+ t[p[i]] = s[p[i]];
37
+ }
38
+ return t;
39
+ }
40
+
41
+ /** Detect free variable `global` from Node.js. */
42
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
43
+
44
+ var freeGlobal$1 = freeGlobal;
45
+
46
+ /** Detect free variable `self`. */
47
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
48
+
49
+ /** Used as a reference to the global object. */
50
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
51
+
52
+ var root$1 = root;
53
+
54
+ /** Built-in value references. */
55
+ var Symbol = root$1.Symbol;
56
+
57
+ var Symbol$1 = Symbol;
58
+
59
+ /** Used for built-in method references. */
60
+ var objectProto$1 = Object.prototype;
61
+
62
+ /** Used to check objects for own properties. */
63
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
64
+
65
+ /**
66
+ * Used to resolve the
67
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
68
+ * of values.
69
+ */
70
+ var nativeObjectToString$1 = objectProto$1.toString;
71
+
72
+ /** Built-in value references. */
73
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
74
+
75
+ /**
76
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
77
+ *
78
+ * @private
79
+ * @param {*} value The value to query.
80
+ * @returns {string} Returns the raw `toStringTag`.
81
+ */
82
+ function getRawTag(value) {
83
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
84
+ tag = value[symToStringTag$1];
85
+
86
+ try {
87
+ value[symToStringTag$1] = undefined;
88
+ var unmasked = true;
89
+ } catch (e) {}
90
+
91
+ var result = nativeObjectToString$1.call(value);
92
+ if (unmasked) {
93
+ if (isOwn) {
94
+ value[symToStringTag$1] = tag;
95
+ } else {
96
+ delete value[symToStringTag$1];
97
+ }
98
+ }
99
+ return result;
100
+ }
101
+
102
+ /** Used for built-in method references. */
103
+ var objectProto = Object.prototype;
104
+
105
+ /**
106
+ * Used to resolve the
107
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
108
+ * of values.
109
+ */
110
+ var nativeObjectToString = objectProto.toString;
111
+
112
+ /**
113
+ * Converts `value` to a string using `Object.prototype.toString`.
114
+ *
115
+ * @private
116
+ * @param {*} value The value to convert.
117
+ * @returns {string} Returns the converted string.
118
+ */
119
+ function objectToString(value) {
120
+ return nativeObjectToString.call(value);
121
+ }
122
+
123
+ /** `Object#toString` result references. */
124
+ var nullTag = '[object Null]',
125
+ undefinedTag = '[object Undefined]';
126
+
127
+ /** Built-in value references. */
128
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
129
+
130
+ /**
131
+ * The base implementation of `getTag` without fallbacks for buggy environments.
132
+ *
133
+ * @private
134
+ * @param {*} value The value to query.
135
+ * @returns {string} Returns the `toStringTag`.
136
+ */
137
+ function baseGetTag(value) {
138
+ if (value == null) {
139
+ return value === undefined ? undefinedTag : nullTag;
140
+ }
141
+ return (symToStringTag && symToStringTag in Object(value))
142
+ ? getRawTag(value)
143
+ : objectToString(value);
144
+ }
145
+
146
+ /**
147
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
148
+ * and has a `typeof` result of "object".
149
+ *
150
+ * @static
151
+ * @memberOf _
152
+ * @since 4.0.0
153
+ * @category Lang
154
+ * @param {*} value The value to check.
155
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
156
+ * @example
157
+ *
158
+ * _.isObjectLike({});
159
+ * // => true
160
+ *
161
+ * _.isObjectLike([1, 2, 3]);
162
+ * // => true
163
+ *
164
+ * _.isObjectLike(_.noop);
165
+ * // => false
166
+ *
167
+ * _.isObjectLike(null);
168
+ * // => false
169
+ */
170
+ function isObjectLike(value) {
171
+ return value != null && typeof value == 'object';
172
+ }
173
+
174
+ /** `Object#toString` result references. */
175
+ var symbolTag = '[object Symbol]';
176
+
177
+ /**
178
+ * Checks if `value` is classified as a `Symbol` primitive or object.
179
+ *
180
+ * @static
181
+ * @memberOf _
182
+ * @since 4.0.0
183
+ * @category Lang
184
+ * @param {*} value The value to check.
185
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
186
+ * @example
187
+ *
188
+ * _.isSymbol(Symbol.iterator);
189
+ * // => true
190
+ *
191
+ * _.isSymbol('abc');
192
+ * // => false
193
+ */
194
+ function isSymbol(value) {
195
+ return typeof value == 'symbol' ||
196
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
197
+ }
198
+
199
+ /** Used to match a single whitespace character. */
200
+ var reWhitespace = /\s/;
201
+
202
+ /**
203
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
204
+ * character of `string`.
205
+ *
206
+ * @private
207
+ * @param {string} string The string to inspect.
208
+ * @returns {number} Returns the index of the last non-whitespace character.
209
+ */
210
+ function trimmedEndIndex(string) {
211
+ var index = string.length;
212
+
213
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
214
+ return index;
215
+ }
216
+
217
+ /** Used to match leading whitespace. */
218
+ var reTrimStart = /^\s+/;
219
+
220
+ /**
221
+ * The base implementation of `_.trim`.
222
+ *
223
+ * @private
224
+ * @param {string} string The string to trim.
225
+ * @returns {string} Returns the trimmed string.
226
+ */
227
+ function baseTrim(string) {
228
+ return string
229
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
230
+ : string;
231
+ }
232
+
233
+ /**
234
+ * Checks if `value` is the
235
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
236
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
237
+ *
238
+ * @static
239
+ * @memberOf _
240
+ * @since 0.1.0
241
+ * @category Lang
242
+ * @param {*} value The value to check.
243
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
244
+ * @example
245
+ *
246
+ * _.isObject({});
247
+ * // => true
248
+ *
249
+ * _.isObject([1, 2, 3]);
250
+ * // => true
251
+ *
252
+ * _.isObject(_.noop);
253
+ * // => true
254
+ *
255
+ * _.isObject(null);
256
+ * // => false
257
+ */
258
+ function isObject(value) {
259
+ var type = typeof value;
260
+ return value != null && (type == 'object' || type == 'function');
261
+ }
262
+
263
+ /** Used as references for various `Number` constants. */
264
+ var NAN = 0 / 0;
265
+
266
+ /** Used to detect bad signed hexadecimal string values. */
267
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
268
+
269
+ /** Used to detect binary string values. */
270
+ var reIsBinary = /^0b[01]+$/i;
271
+
272
+ /** Used to detect octal string values. */
273
+ var reIsOctal = /^0o[0-7]+$/i;
274
+
275
+ /** Built-in method references without a dependency on `root`. */
276
+ var freeParseInt = parseInt;
277
+
278
+ /**
279
+ * Converts `value` to a number.
280
+ *
281
+ * @static
282
+ * @memberOf _
283
+ * @since 4.0.0
284
+ * @category Lang
285
+ * @param {*} value The value to process.
286
+ * @returns {number} Returns the number.
287
+ * @example
288
+ *
289
+ * _.toNumber(3.2);
290
+ * // => 3.2
291
+ *
292
+ * _.toNumber(Number.MIN_VALUE);
293
+ * // => 5e-324
294
+ *
295
+ * _.toNumber(Infinity);
296
+ * // => Infinity
297
+ *
298
+ * _.toNumber('3.2');
299
+ * // => 3.2
300
+ */
301
+ function toNumber(value) {
302
+ if (typeof value == 'number') {
303
+ return value;
304
+ }
305
+ if (isSymbol(value)) {
306
+ return NAN;
307
+ }
308
+ if (isObject(value)) {
309
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
310
+ value = isObject(other) ? (other + '') : other;
311
+ }
312
+ if (typeof value != 'string') {
313
+ return value === 0 ? value : +value;
314
+ }
315
+ value = baseTrim(value);
316
+ var isBinary = reIsBinary.test(value);
317
+ return (isBinary || reIsOctal.test(value))
318
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
319
+ : (reIsBadHex.test(value) ? NAN : +value);
320
+ }
321
+
322
+ /**
323
+ * Gets the timestamp of the number of milliseconds that have elapsed since
324
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
325
+ *
326
+ * @static
327
+ * @memberOf _
328
+ * @since 2.4.0
329
+ * @category Date
330
+ * @returns {number} Returns the timestamp.
331
+ * @example
332
+ *
333
+ * _.defer(function(stamp) {
334
+ * console.log(_.now() - stamp);
335
+ * }, _.now());
336
+ * // => Logs the number of milliseconds it took for the deferred invocation.
337
+ */
338
+ var now = function() {
339
+ return root$1.Date.now();
340
+ };
341
+
342
+ var now$1 = now;
343
+
344
+ /** Error message constants. */
345
+ var FUNC_ERROR_TEXT$1 = 'Expected a function';
346
+
347
+ /* Built-in method references for those with the same name as other `lodash` methods. */
348
+ var nativeMax = Math.max,
349
+ nativeMin = Math.min;
350
+
351
+ /**
352
+ * Creates a debounced function that delays invoking `func` until after `wait`
353
+ * milliseconds have elapsed since the last time the debounced function was
354
+ * invoked. The debounced function comes with a `cancel` method to cancel
355
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
356
+ * Provide `options` to indicate whether `func` should be invoked on the
357
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
358
+ * with the last arguments provided to the debounced function. Subsequent
359
+ * calls to the debounced function return the result of the last `func`
360
+ * invocation.
361
+ *
362
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
363
+ * invoked on the trailing edge of the timeout only if the debounced function
364
+ * is invoked more than once during the `wait` timeout.
365
+ *
366
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
367
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
368
+ *
369
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
370
+ * for details over the differences between `_.debounce` and `_.throttle`.
371
+ *
372
+ * @static
373
+ * @memberOf _
374
+ * @since 0.1.0
375
+ * @category Function
376
+ * @param {Function} func The function to debounce.
377
+ * @param {number} [wait=0] The number of milliseconds to delay.
378
+ * @param {Object} [options={}] The options object.
379
+ * @param {boolean} [options.leading=false]
380
+ * Specify invoking on the leading edge of the timeout.
381
+ * @param {number} [options.maxWait]
382
+ * The maximum time `func` is allowed to be delayed before it's invoked.
383
+ * @param {boolean} [options.trailing=true]
384
+ * Specify invoking on the trailing edge of the timeout.
385
+ * @returns {Function} Returns the new debounced function.
386
+ * @example
387
+ *
388
+ * // Avoid costly calculations while the window size is in flux.
389
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
390
+ *
391
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
392
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
393
+ * 'leading': true,
394
+ * 'trailing': false
395
+ * }));
396
+ *
397
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
398
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
399
+ * var source = new EventSource('/stream');
400
+ * jQuery(source).on('message', debounced);
401
+ *
402
+ * // Cancel the trailing debounced invocation.
403
+ * jQuery(window).on('popstate', debounced.cancel);
404
+ */
405
+ function debounce(func, wait, options) {
406
+ var lastArgs,
407
+ lastThis,
408
+ maxWait,
409
+ result,
410
+ timerId,
411
+ lastCallTime,
412
+ lastInvokeTime = 0,
413
+ leading = false,
414
+ maxing = false,
415
+ trailing = true;
416
+
417
+ if (typeof func != 'function') {
418
+ throw new TypeError(FUNC_ERROR_TEXT$1);
419
+ }
420
+ wait = toNumber(wait) || 0;
421
+ if (isObject(options)) {
422
+ leading = !!options.leading;
423
+ maxing = 'maxWait' in options;
424
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
425
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
426
+ }
427
+
428
+ function invokeFunc(time) {
429
+ var args = lastArgs,
430
+ thisArg = lastThis;
431
+
432
+ lastArgs = lastThis = undefined;
433
+ lastInvokeTime = time;
434
+ result = func.apply(thisArg, args);
435
+ return result;
436
+ }
437
+
438
+ function leadingEdge(time) {
439
+ // Reset any `maxWait` timer.
440
+ lastInvokeTime = time;
441
+ // Start the timer for the trailing edge.
442
+ timerId = setTimeout(timerExpired, wait);
443
+ // Invoke the leading edge.
444
+ return leading ? invokeFunc(time) : result;
445
+ }
446
+
447
+ function remainingWait(time) {
448
+ var timeSinceLastCall = time - lastCallTime,
449
+ timeSinceLastInvoke = time - lastInvokeTime,
450
+ timeWaiting = wait - timeSinceLastCall;
451
+
452
+ return maxing
453
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
454
+ : timeWaiting;
455
+ }
456
+
457
+ function shouldInvoke(time) {
458
+ var timeSinceLastCall = time - lastCallTime,
459
+ timeSinceLastInvoke = time - lastInvokeTime;
460
+
461
+ // Either this is the first call, activity has stopped and we're at the
462
+ // trailing edge, the system time has gone backwards and we're treating
463
+ // it as the trailing edge, or we've hit the `maxWait` limit.
464
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
465
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
466
+ }
467
+
468
+ function timerExpired() {
469
+ var time = now$1();
470
+ if (shouldInvoke(time)) {
471
+ return trailingEdge(time);
472
+ }
473
+ // Restart the timer.
474
+ timerId = setTimeout(timerExpired, remainingWait(time));
475
+ }
476
+
477
+ function trailingEdge(time) {
478
+ timerId = undefined;
479
+
480
+ // Only invoke if we have `lastArgs` which means `func` has been
481
+ // debounced at least once.
482
+ if (trailing && lastArgs) {
483
+ return invokeFunc(time);
484
+ }
485
+ lastArgs = lastThis = undefined;
486
+ return result;
487
+ }
488
+
489
+ function cancel() {
490
+ if (timerId !== undefined) {
491
+ clearTimeout(timerId);
492
+ }
493
+ lastInvokeTime = 0;
494
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
495
+ }
496
+
497
+ function flush() {
498
+ return timerId === undefined ? result : trailingEdge(now$1());
499
+ }
500
+
501
+ function debounced() {
502
+ var time = now$1(),
503
+ isInvoking = shouldInvoke(time);
504
+
505
+ lastArgs = arguments;
506
+ lastThis = this;
507
+ lastCallTime = time;
508
+
509
+ if (isInvoking) {
510
+ if (timerId === undefined) {
511
+ return leadingEdge(lastCallTime);
512
+ }
513
+ if (maxing) {
514
+ // Handle invocations in a tight loop.
515
+ clearTimeout(timerId);
516
+ timerId = setTimeout(timerExpired, wait);
517
+ return invokeFunc(lastCallTime);
518
+ }
519
+ }
520
+ if (timerId === undefined) {
521
+ timerId = setTimeout(timerExpired, wait);
522
+ }
523
+ return result;
524
+ }
525
+ debounced.cancel = cancel;
526
+ debounced.flush = flush;
527
+ return debounced;
528
+ }
529
+
530
+ /** Error message constants. */
531
+ var FUNC_ERROR_TEXT = 'Expected a function';
532
+
533
+ /**
534
+ * Creates a throttled function that only invokes `func` at most once per
535
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
536
+ * method to cancel delayed `func` invocations and a `flush` method to
537
+ * immediately invoke them. Provide `options` to indicate whether `func`
538
+ * should be invoked on the leading and/or trailing edge of the `wait`
539
+ * timeout. The `func` is invoked with the last arguments provided to the
540
+ * throttled function. Subsequent calls to the throttled function return the
541
+ * result of the last `func` invocation.
542
+ *
543
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
544
+ * invoked on the trailing edge of the timeout only if the throttled function
545
+ * is invoked more than once during the `wait` timeout.
546
+ *
547
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
548
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
549
+ *
550
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
551
+ * for details over the differences between `_.throttle` and `_.debounce`.
552
+ *
553
+ * @static
554
+ * @memberOf _
555
+ * @since 0.1.0
556
+ * @category Function
557
+ * @param {Function} func The function to throttle.
558
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
559
+ * @param {Object} [options={}] The options object.
560
+ * @param {boolean} [options.leading=true]
561
+ * Specify invoking on the leading edge of the timeout.
562
+ * @param {boolean} [options.trailing=true]
563
+ * Specify invoking on the trailing edge of the timeout.
564
+ * @returns {Function} Returns the new throttled function.
565
+ * @example
566
+ *
567
+ * // Avoid excessively updating the position while scrolling.
568
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
569
+ *
570
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
571
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
572
+ * jQuery(element).on('click', throttled);
573
+ *
574
+ * // Cancel the trailing throttled invocation.
575
+ * jQuery(window).on('popstate', throttled.cancel);
576
+ */
577
+ function throttle(func, wait, options) {
578
+ var leading = true,
579
+ trailing = true;
580
+
581
+ if (typeof func != 'function') {
582
+ throw new TypeError(FUNC_ERROR_TEXT);
583
+ }
584
+ if (isObject(options)) {
585
+ leading = 'leading' in options ? !!options.leading : leading;
586
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
587
+ }
588
+ return debounce(func, wait, {
589
+ 'leading': leading,
590
+ 'maxWait': wait,
591
+ 'trailing': trailing
592
+ });
593
+ }
594
+
595
+ function styleInject(css, ref) {
596
+ if ( ref === void 0 ) ref = {};
597
+ var insertAt = ref.insertAt;
598
+
599
+ if (!css || typeof document === 'undefined') { return; }
600
+
601
+ var head = document.head || document.getElementsByTagName('head')[0];
602
+ var style = document.createElement('style');
603
+ style.type = 'text/css';
604
+
605
+ if (insertAt === 'top') {
606
+ if (head.firstChild) {
607
+ head.insertBefore(style, head.firstChild);
608
+ } else {
609
+ head.appendChild(style);
610
+ }
611
+ } else {
612
+ head.appendChild(style);
613
+ }
614
+
615
+ if (style.styleSheet) {
616
+ style.styleSheet.cssText = css;
617
+ } else {
618
+ style.appendChild(document.createTextNode(css));
619
+ }
620
+ }
621
+
622
+ var css_248z = ".virtuallist .ant-table-tbody>tr>td>div{-webkit-box-sizing:border-box;box-sizing:border-box;white-space:nowrap;vertical-align:middle;overflow:hidden;text-overflow:ellipsis;width:100%}.virtuallist .ant-table-tbody>tr>td.ant-table-row-expand-icon-cell>div{overflow:inherit}.ant-table-bordered .virtuallist>table>.ant-table-tbody>tr>td{border-right:1px solid #f0f0f0}";
623
+ styleInject(css_248z);
624
+
625
+ // ==============全局常量 ================== //
626
+ var DEFAULT_VID = 'vtable';
627
+ var vidMap = new Map();
628
+ var debounceListRender;
629
+ // ===============reducer ============== //
630
+ var initialState = {
631
+ // 行高度
632
+ rowHeight: 0,
633
+ // 当前的scrollTop
634
+ curScrollTop: 0,
635
+ // 总行数
636
+ totalLen: 0,
637
+ };
638
+ function reducer(state, action) {
639
+ var curScrollTop = action.curScrollTop, rowHeight = action.rowHeight, totalLen = action.totalLen, ifScrollTopClear = action.ifScrollTopClear;
640
+ var stateScrollTop = state.curScrollTop;
641
+ switch (action.type) {
642
+ // 改变trs 即 改变渲染的列表trs
643
+ case 'changeTrs':
644
+ return __assign(__assign({}, state), { curScrollTop: curScrollTop });
645
+ // 初始化每行的高度, 表格总高度, 渲染的条数
646
+ case 'initHeight':
647
+ return __assign(__assign({}, state), { rowHeight: rowHeight });
648
+ // 更改totalLen
649
+ case 'changeTotalLen':
650
+ if (totalLen === 0) {
651
+ stateScrollTop = 0;
652
+ }
653
+ return __assign(__assign({}, state), { totalLen: totalLen, curScrollTop: stateScrollTop });
654
+ case 'reset':
655
+ return __assign(__assign({}, state), { curScrollTop: ifScrollTopClear ? 0 : state.curScrollTop });
656
+ default:
657
+ throw new Error();
658
+ }
659
+ }
660
+ // ===============context ============== //
661
+ var ScrollContext = createContext({
662
+ dispatch: undefined,
663
+ renderLen: 1,
664
+ start: 0,
665
+ offsetStart: 0,
666
+ // =============
667
+ rowHeight: initialState.rowHeight,
668
+ totalLen: 0,
669
+ vid: DEFAULT_VID,
670
+ });
671
+ // =============组件 =================== //
672
+ function VCell(props) {
673
+ var children = props.children, restProps = __rest(props, ["children"]);
674
+ return (React__default.createElement("td", __assign({}, restProps),
675
+ React__default.createElement("div", null, children)));
676
+ }
677
+ function VRow(props, ref) {
678
+ var _a = useContext(ScrollContext), dispatch = _a.dispatch, rowHeight = _a.rowHeight, totalLen = _a.totalLen, vid = _a.vid;
679
+ var children = props.children, style = props.style, restProps = __rest(props, ["children", "style"]);
680
+ var trRef = useRef(null);
681
+ useEffect(function () {
682
+ var initHeight = function (tempRef) {
683
+ var _a, _b, _c;
684
+ if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
685
+ var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
686
+ vidMap.set(vid, __assign(__assign({}, vidMap.get(vid)), { rowItemHeight: tempRowHeight }));
687
+ dispatch({
688
+ type: 'initHeight',
689
+ rowHeight: tempRowHeight,
690
+ });
691
+ }
692
+ };
693
+ initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
694
+ }, [trRef, dispatch, rowHeight, totalLen, ref, vid]);
695
+ return (React__default.createElement("tr", __assign({}, restProps, { ref: Object.prototype.hasOwnProperty.call(ref, 'current')
696
+ ? ref
697
+ : trRef, style: __assign(__assign({}, style), { height: rowHeight || 'auto', boxSizing: 'border-box' }) }), children));
698
+ }
699
+ function VWrapper(props) {
700
+ var children = props.children, restProps = __rest(props, ["children"]);
701
+ var _a = useContext(ScrollContext), renderLen = _a.renderLen, start = _a.start, dispatch = _a.dispatch, vid = _a.vid, totalLen = _a.totalLen;
702
+ var contents = useMemo(function () {
703
+ return children[1];
704
+ }, [children]);
705
+ var contentsLen = useMemo(function () {
706
+ var _a;
707
+ return (_a = contents === null || contents === void 0 ? void 0 : contents.length) !== null && _a !== void 0 ? _a : 0;
708
+ }, [contents]);
709
+ useEffect(function () {
710
+ if (totalLen !== contentsLen) {
711
+ dispatch({
712
+ type: 'changeTotalLen',
713
+ totalLen: contentsLen !== null && contentsLen !== void 0 ? contentsLen : 0,
714
+ });
715
+ }
716
+ }, [contentsLen, dispatch, vid, totalLen]);
717
+ var tempNode = null;
718
+ if (Array.isArray(contents) && contents.length) {
719
+ tempNode = [
720
+ children[0],
721
+ contents.slice(start, start + (renderLen !== null && renderLen !== void 0 ? renderLen : 1)).map(function (item) {
722
+ if (Array.isArray(item)) {
723
+ // 兼容antd v4.3.5 --- rc-table 7.8.1及以下
724
+ return item[0];
725
+ }
726
+ // 处理antd ^v4.4.0 --- rc-table ^7.8.2
727
+ return item;
728
+ }),
729
+ ];
730
+ }
731
+ else {
732
+ tempNode = children;
733
+ }
734
+ return React__default.createElement("tbody", __assign({}, restProps), tempNode);
735
+ }
736
+ function VTable(props, otherParams) {
737
+ var _a, _b, _c, _d, _e;
738
+ var style = props.style, children = props.children, rest = __rest(props, ["style", "children"]);
739
+ var width = style.width, rest_style = __rest(style, ["width"]);
740
+ var _f = otherParams !== null && otherParams !== void 0 ? otherParams : {}, vid = _f.vid, scrollY = _f.scrollY, reachEnd = _f.reachEnd, onScroll = _f.onScroll, resetScrollTopWhenDataChange = _f.resetScrollTopWhenDataChange;
741
+ var _g = useReducer(reducer, initialState), state = _g[0], dispatch = _g[1];
742
+ var wrap_tableRef = useRef(null);
743
+ var tableRef = useRef(null);
744
+ // 数据的总条数
745
+ var _h = useState((_d = (_c = (_b = (_a = children[1]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0), totalLen = _h[0], setTotalLen = _h[1];
746
+ useEffect(function () {
747
+ setTotalLen(state.totalLen);
748
+ }, [state.totalLen]);
749
+ // 组件卸载的清除操作
750
+ useEffect(function () {
751
+ return function () {
752
+ vidMap.delete(vid);
753
+ };
754
+ }, [vid]);
755
+ // table总高度
756
+ var tableHeight = useMemo(function () {
757
+ var temp = 'auto';
758
+ if (state.rowHeight && totalLen) {
759
+ temp = state.rowHeight * totalLen;
760
+ }
761
+ return temp;
762
+ }, [state.rowHeight, totalLen]);
763
+ // table的scrollY值
764
+ var _j = useState(0), tableScrollY = _j[0], setTableScrollY = _j[1];
765
+ // tableScrollY 随scrollY / tableHeight 进行变更
766
+ useEffect(function () {
767
+ var _a, _b, _c;
768
+ var temp = 0;
769
+ if (typeof scrollY === 'string') {
770
+ temp = (_c = (_b = (_a = wrap_tableRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
771
+ }
772
+ else {
773
+ temp = scrollY;
774
+ }
775
+ // if (isNumber(tableHeight) && tableHeight < temp) {
776
+ // temp = tableHeight;
777
+ // }
778
+ // 处理tableScrollY <= 0的情况
779
+ if (temp <= 0) {
780
+ temp = 0;
781
+ }
782
+ setTableScrollY(temp);
783
+ }, [scrollY, tableHeight]);
784
+ // 渲染的条数
785
+ var renderLen = useMemo(function () {
786
+ var temp = 1;
787
+ if (state.rowHeight && totalLen && tableScrollY) {
788
+ if (tableScrollY <= 0) {
789
+ temp = 0;
790
+ }
791
+ else {
792
+ var tempRenderLen = ((tableScrollY / state.rowHeight) | 0) + 1 + 2;
793
+ // console.log('tempRenderLen', tempRenderLen)
794
+ // temp = tempRenderLen > totalLen ? totalLen : tempRenderLen;
795
+ temp = tempRenderLen;
796
+ }
797
+ }
798
+ return temp;
799
+ }, [state.rowHeight, totalLen, tableScrollY]);
800
+ // 渲染中的第一条
801
+ var start = state.rowHeight ? (state.curScrollTop / state.rowHeight) | 0 : 0;
802
+ // 偏移量
803
+ var offsetStart = state.rowHeight ? state.curScrollTop % state.rowHeight : 0;
804
+ // 用来优化向上滚动出现的空白
805
+ if (state.curScrollTop &&
806
+ state.rowHeight &&
807
+ state.curScrollTop > state.rowHeight) {
808
+ start -= 1;
809
+ offsetStart += state.rowHeight;
810
+ }
811
+ else {
812
+ start = 0;
813
+ }
814
+ // 数据变更 操作scrollTop
815
+ useEffect(function () {
816
+ var _a;
817
+ var scrollNode = (_a = wrap_tableRef.current) === null || _a === void 0 ? void 0 : _a.parentNode;
818
+ if (resetScrollTopWhenDataChange) {
819
+ // 重置scrollTop
820
+ if (scrollNode) {
821
+ scrollNode.scrollTop = 0;
822
+ }
823
+ dispatch({ type: 'reset', ifScrollTopClear: true });
824
+ }
825
+ else {
826
+ // 不重置scrollTop 不清空curScrollTop
827
+ dispatch({ type: 'reset', ifScrollTopClear: false });
828
+ }
829
+ if (vidMap.has(vid)) {
830
+ vidMap.set(vid, __assign(__assign({}, vidMap.get(vid)), { scrollNode: scrollNode }));
831
+ }
832
+ }, [totalLen, resetScrollTopWhenDataChange, vid, children]);
833
+ useEffect(function () {
834
+ var _a;
835
+ var throttleScroll = throttle(function (e) {
836
+ var _a, _b, _c, _d, _e, _f, _g;
837
+ var historyScrollHeight = (_a = vidMap.get(vid)) === null || _a === void 0 ? void 0 : _a.scrollHeight;
838
+ var scrollTop = (_c = (_b = e === null || e === void 0 ? void 0 : e.target) === null || _b === void 0 ? void 0 : _b.scrollTop) !== null && _c !== void 0 ? _c : 0;
839
+ var scrollHeight = (_e = (_d = e === null || e === void 0 ? void 0 : e.target) === null || _d === void 0 ? void 0 : _d.scrollHeight) !== null && _e !== void 0 ? _e : 0;
840
+ var clientHeight = (_g = (_f = e === null || e === void 0 ? void 0 : e.target) === null || _f === void 0 ? void 0 : _f.clientHeight) !== null && _g !== void 0 ? _g : 0;
841
+ // 到底了 没有滚动条就不会触发reachEnd. 建议设置scrolly高度少点或者数据量多点.
842
+ if (scrollTop === scrollHeight) ;
843
+ else if (scrollTop + clientHeight >= scrollHeight &&
844
+ historyScrollHeight !== scrollHeight) {
845
+ // 相同的tableData情况下, 上次reachEnd执行后, scrollHeight不变, 则不会再次请求reachEnd
846
+ vidMap.set(vid, __assign(__assign({}, vidMap.get(vid)), { scrollHeight: scrollHeight }));
847
+ // 有滚动条的情况
848
+ // eslint-disable-next-line no-unused-expressions
849
+ reachEnd && reachEnd();
850
+ }
851
+ // eslint-disable-next-line no-unused-expressions
852
+ onScroll && onScroll();
853
+ // 若renderLen大于totalLen, 置空curScrollTop. => table paddingTop会置空.
854
+ dispatch({
855
+ type: 'changeTrs',
856
+ curScrollTop: renderLen <= totalLen ? scrollTop : 0,
857
+ vid: vid,
858
+ });
859
+ }, 60);
860
+ var ref = (_a = wrap_tableRef === null || wrap_tableRef === void 0 ? void 0 : wrap_tableRef.current) === null || _a === void 0 ? void 0 : _a.parentNode;
861
+ if (ref) {
862
+ ref.addEventListener('scroll', throttleScroll);
863
+ }
864
+ return function () {
865
+ ref.removeEventListener('scroll', throttleScroll);
866
+ };
867
+ }, [onScroll, reachEnd, renderLen, totalLen, vid]);
868
+ debounceListRender(start, renderLen);
869
+ return (React__default.createElement("div", { className: "virtuallist", ref: wrap_tableRef, style: {
870
+ width: '100%',
871
+ position: 'relative',
872
+ height: tableHeight,
873
+ boxSizing: 'border-box',
874
+ paddingTop: state.curScrollTop,
875
+ } },
876
+ React__default.createElement(ScrollContext.Provider, { value: {
877
+ dispatch: dispatch,
878
+ rowHeight: (_e = vidMap === null || vidMap === void 0 ? void 0 : vidMap.get(vid)) === null || _e === void 0 ? void 0 : _e.rowItemHeight,
879
+ start: start,
880
+ offsetStart: offsetStart,
881
+ renderLen: renderLen,
882
+ totalLen: totalLen,
883
+ vid: vid,
884
+ } },
885
+ React__default.createElement("table", __assign({}, rest, { ref: tableRef, style: __assign(__assign({}, rest_style), { width: width, position: 'relative', transform: "translateY(-" + offsetStart + "px)" }) }), children))));
886
+ }
887
+ // ================导出===================
888
+ function VList(props) {
889
+ var _a = props.vid, vid = _a === void 0 ? DEFAULT_VID : _a, height = props.height, onReachEnd = props.onReachEnd, onScroll = props.onScroll, onListRender = props.onListRender, debounceListRenderMS = props.debounceListRenderMS, _b = props.resetTopWhenDataChange, resetTopWhenDataChange = _b === void 0 ? true : _b;
890
+ var resetScrollTopWhenDataChange = onReachEnd
891
+ ? false
892
+ : resetTopWhenDataChange;
893
+ if (!vidMap.has(vid)) {
894
+ vidMap.set(vid, { _id: vid });
895
+ }
896
+ debounceListRender = onListRender
897
+ ? debounce(function (_start, _renderLen) {
898
+ onListRender({ start: _start, renderLen: _renderLen });
899
+ }, debounceListRenderMS !== null && debounceListRenderMS !== void 0 ? debounceListRenderMS : 300)
900
+ : function () { };
901
+ return {
902
+ table: function (p) {
903
+ return VTable(p, {
904
+ vid: vid,
905
+ scrollY: height,
906
+ reachEnd: onReachEnd,
907
+ onScroll: onScroll,
908
+ onListRender: onListRender,
909
+ resetScrollTopWhenDataChange: resetScrollTopWhenDataChange,
910
+ });
911
+ },
912
+ body: {
913
+ wrapper: VWrapper,
914
+ row: VRow,
915
+ cell: VCell,
916
+ },
917
+ };
918
+ }
919
+ function scrollTo(option) {
920
+ var row = option.row, y = option.y, _a = option.vid, vid = _a === void 0 ? DEFAULT_VID : _a;
921
+ try {
922
+ var _b = vidMap.get(vid), scrollNode = _b.scrollNode, rowItemHeight = _b.rowItemHeight;
923
+ if (row) {
924
+ if (row - 1 > 0) {
925
+ scrollNode.scrollTop = (row - 1) * (rowItemHeight !== null && rowItemHeight !== void 0 ? rowItemHeight : 0);
926
+ }
927
+ else {
928
+ scrollNode.scrollTop = 0;
929
+ }
930
+ }
931
+ else {
932
+ scrollNode.scrollTop = y !== null && y !== void 0 ? y : 0;
933
+ }
934
+ return { vid: vid, rowItemHeight: rowItemHeight };
935
+ }
936
+ catch (e) {
937
+ console.error('dont call scrollTo before init table');
938
+ return { vid: vid, rowItemHeight: -1 };
939
+ }
940
+ }
941
+
942
+ export { VList, scrollTo };