@revolist/revogrid 3.2.13 → 3.2.14
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/custom-element/_baseIteratee.js +2070 -0
- package/custom-element/columnService.js +743 -0
- package/custom-element/consts.js +46 -0
- package/custom-element/data.store.js +545 -0
- package/custom-element/debounce.js +217 -0
- package/custom-element/dimension.helpers.js +340 -0
- package/custom-element/each.js +180 -0
- package/custom-element/filter.button.js +36 -0
- package/custom-element/identity.js +26 -0
- package/custom-element/index.d.ts +15 -98
- package/custom-element/index.js +15 -29221
- package/custom-element/isSymbol.js +220 -0
- package/custom-element/keys.js +561 -0
- package/custom-element/localScrollService.js +86 -0
- package/custom-element/revo-grid.d.ts +11 -0
- package/custom-element/revo-grid.js +3662 -0
- package/custom-element/revogr-clipboard.d.ts +11 -0
- package/custom-element/revogr-clipboard.js +72 -0
- package/custom-element/revogr-data.d.ts +11 -0
- package/custom-element/revogr-data.js +9 -0
- package/custom-element/revogr-data2.js +171 -0
- package/custom-element/revogr-edit.d.ts +11 -0
- package/custom-element/revogr-edit.js +9 -0
- package/custom-element/revogr-edit2.js +402 -0
- package/custom-element/revogr-filter-panel.d.ts +11 -0
- package/custom-element/revogr-filter-panel.js +308 -0
- package/custom-element/revogr-focus.d.ts +11 -0
- package/custom-element/revogr-focus.js +9 -0
- package/custom-element/revogr-focus2.js +64 -0
- package/custom-element/revogr-header.d.ts +11 -0
- package/custom-element/revogr-header.js +9 -0
- package/custom-element/revogr-header2.js +591 -0
- package/custom-element/revogr-order-editor.d.ts +11 -0
- package/custom-element/revogr-order-editor.js +9 -0
- package/custom-element/revogr-order-editor2.js +190 -0
- package/custom-element/revogr-overlay-selection.d.ts +11 -0
- package/custom-element/revogr-overlay-selection.js +9 -0
- package/custom-element/revogr-overlay-selection2.js +741 -0
- package/custom-element/revogr-row-headers.d.ts +11 -0
- package/custom-element/revogr-row-headers.js +9 -0
- package/custom-element/revogr-row-headers2.js +403 -0
- package/custom-element/revogr-scroll-virtual.d.ts +11 -0
- package/custom-element/revogr-scroll-virtual.js +9 -0
- package/custom-element/revogr-scroll-virtual2.js +135 -0
- package/custom-element/revogr-temp-range.d.ts +11 -0
- package/custom-element/revogr-temp-range.js +9 -0
- package/custom-element/revogr-temp-range2.js +17275 -0
- package/custom-element/revogr-viewport-scroll.d.ts +11 -0
- package/custom-element/revogr-viewport-scroll.js +9 -0
- package/custom-element/revogr-viewport-scroll2.js +367 -0
- package/custom-element/selection.utils.js +106 -0
- package/custom-element/toInteger.js +107 -0
- package/custom-element/toNumber.js +105 -0
- package/custom-element/utils.js +69 -0
- package/package.json +2 -2
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built by Revolist
|
|
3
|
+
*/
|
|
4
|
+
import { e as _root, b as isObject_1 } from './isSymbol.js';
|
|
5
|
+
import { t as toNumber_1 } from './toNumber.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
9
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
10
|
+
*
|
|
11
|
+
* @static
|
|
12
|
+
* @memberOf _
|
|
13
|
+
* @since 2.4.0
|
|
14
|
+
* @category Date
|
|
15
|
+
* @returns {number} Returns the timestamp.
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* _.defer(function(stamp) {
|
|
19
|
+
* console.log(_.now() - stamp);
|
|
20
|
+
* }, _.now());
|
|
21
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
22
|
+
*/
|
|
23
|
+
var now = function() {
|
|
24
|
+
return _root.Date.now();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var now_1 = now;
|
|
28
|
+
|
|
29
|
+
/** Error message constants. */
|
|
30
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
31
|
+
|
|
32
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
33
|
+
var nativeMax = Math.max,
|
|
34
|
+
nativeMin = Math.min;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
38
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
39
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
40
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
41
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
42
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
43
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
44
|
+
* calls to the debounced function return the result of the last `func`
|
|
45
|
+
* invocation.
|
|
46
|
+
*
|
|
47
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
48
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
49
|
+
* is invoked more than once during the `wait` timeout.
|
|
50
|
+
*
|
|
51
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
52
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
53
|
+
*
|
|
54
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
55
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
56
|
+
*
|
|
57
|
+
* @static
|
|
58
|
+
* @memberOf _
|
|
59
|
+
* @since 0.1.0
|
|
60
|
+
* @category Function
|
|
61
|
+
* @param {Function} func The function to debounce.
|
|
62
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
63
|
+
* @param {Object} [options={}] The options object.
|
|
64
|
+
* @param {boolean} [options.leading=false]
|
|
65
|
+
* Specify invoking on the leading edge of the timeout.
|
|
66
|
+
* @param {number} [options.maxWait]
|
|
67
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
68
|
+
* @param {boolean} [options.trailing=true]
|
|
69
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
70
|
+
* @returns {Function} Returns the new debounced function.
|
|
71
|
+
* @example
|
|
72
|
+
*
|
|
73
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
74
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
75
|
+
*
|
|
76
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
77
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
78
|
+
* 'leading': true,
|
|
79
|
+
* 'trailing': false
|
|
80
|
+
* }));
|
|
81
|
+
*
|
|
82
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
83
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
84
|
+
* var source = new EventSource('/stream');
|
|
85
|
+
* jQuery(source).on('message', debounced);
|
|
86
|
+
*
|
|
87
|
+
* // Cancel the trailing debounced invocation.
|
|
88
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
89
|
+
*/
|
|
90
|
+
function debounce(func, wait, options) {
|
|
91
|
+
var lastArgs,
|
|
92
|
+
lastThis,
|
|
93
|
+
maxWait,
|
|
94
|
+
result,
|
|
95
|
+
timerId,
|
|
96
|
+
lastCallTime,
|
|
97
|
+
lastInvokeTime = 0,
|
|
98
|
+
leading = false,
|
|
99
|
+
maxing = false,
|
|
100
|
+
trailing = true;
|
|
101
|
+
|
|
102
|
+
if (typeof func != 'function') {
|
|
103
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
104
|
+
}
|
|
105
|
+
wait = toNumber_1(wait) || 0;
|
|
106
|
+
if (isObject_1(options)) {
|
|
107
|
+
leading = !!options.leading;
|
|
108
|
+
maxing = 'maxWait' in options;
|
|
109
|
+
maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait;
|
|
110
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function invokeFunc(time) {
|
|
114
|
+
var args = lastArgs,
|
|
115
|
+
thisArg = lastThis;
|
|
116
|
+
|
|
117
|
+
lastArgs = lastThis = undefined;
|
|
118
|
+
lastInvokeTime = time;
|
|
119
|
+
result = func.apply(thisArg, args);
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function leadingEdge(time) {
|
|
124
|
+
// Reset any `maxWait` timer.
|
|
125
|
+
lastInvokeTime = time;
|
|
126
|
+
// Start the timer for the trailing edge.
|
|
127
|
+
timerId = setTimeout(timerExpired, wait);
|
|
128
|
+
// Invoke the leading edge.
|
|
129
|
+
return leading ? invokeFunc(time) : result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function remainingWait(time) {
|
|
133
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
134
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
135
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
136
|
+
|
|
137
|
+
return maxing
|
|
138
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
139
|
+
: timeWaiting;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function shouldInvoke(time) {
|
|
143
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
144
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
145
|
+
|
|
146
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
147
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
148
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
149
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
150
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function timerExpired() {
|
|
154
|
+
var time = now_1();
|
|
155
|
+
if (shouldInvoke(time)) {
|
|
156
|
+
return trailingEdge(time);
|
|
157
|
+
}
|
|
158
|
+
// Restart the timer.
|
|
159
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function trailingEdge(time) {
|
|
163
|
+
timerId = undefined;
|
|
164
|
+
|
|
165
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
166
|
+
// debounced at least once.
|
|
167
|
+
if (trailing && lastArgs) {
|
|
168
|
+
return invokeFunc(time);
|
|
169
|
+
}
|
|
170
|
+
lastArgs = lastThis = undefined;
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function cancel() {
|
|
175
|
+
if (timerId !== undefined) {
|
|
176
|
+
clearTimeout(timerId);
|
|
177
|
+
}
|
|
178
|
+
lastInvokeTime = 0;
|
|
179
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function flush() {
|
|
183
|
+
return timerId === undefined ? result : trailingEdge(now_1());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function debounced() {
|
|
187
|
+
var time = now_1(),
|
|
188
|
+
isInvoking = shouldInvoke(time);
|
|
189
|
+
|
|
190
|
+
lastArgs = arguments;
|
|
191
|
+
lastThis = this;
|
|
192
|
+
lastCallTime = time;
|
|
193
|
+
|
|
194
|
+
if (isInvoking) {
|
|
195
|
+
if (timerId === undefined) {
|
|
196
|
+
return leadingEdge(lastCallTime);
|
|
197
|
+
}
|
|
198
|
+
if (maxing) {
|
|
199
|
+
// Handle invocations in a tight loop.
|
|
200
|
+
clearTimeout(timerId);
|
|
201
|
+
timerId = setTimeout(timerExpired, wait);
|
|
202
|
+
return invokeFunc(lastCallTime);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (timerId === undefined) {
|
|
206
|
+
timerId = setTimeout(timerExpired, wait);
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
debounced.cancel = cancel;
|
|
211
|
+
debounced.flush = flush;
|
|
212
|
+
return debounced;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
var debounce_1 = debounce;
|
|
216
|
+
|
|
217
|
+
export { debounce_1 as d };
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built by Revolist
|
|
3
|
+
*/
|
|
4
|
+
import { _ as _baseEach, e as each } from './each.js';
|
|
5
|
+
import { d as isSymbol_1 } from './isSymbol.js';
|
|
6
|
+
import { i as identity_1 } from './identity.js';
|
|
7
|
+
import { _ as _baseIteratee } from './_baseIteratee.js';
|
|
8
|
+
import { a as isArray_1 } from './keys.js';
|
|
9
|
+
import { m as mergeSortedArray } from './utils.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A specialized version of `_.reduce` for arrays without support for
|
|
13
|
+
* iteratee shorthands.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @param {Array} [array] The array to iterate over.
|
|
17
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
18
|
+
* @param {*} [accumulator] The initial value.
|
|
19
|
+
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|
20
|
+
* the initial value.
|
|
21
|
+
* @returns {*} Returns the accumulated value.
|
|
22
|
+
*/
|
|
23
|
+
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|
24
|
+
var index = -1,
|
|
25
|
+
length = array == null ? 0 : array.length;
|
|
26
|
+
|
|
27
|
+
if (initAccum && length) {
|
|
28
|
+
accumulator = array[++index];
|
|
29
|
+
}
|
|
30
|
+
while (++index < length) {
|
|
31
|
+
accumulator = iteratee(accumulator, array[index], index, array);
|
|
32
|
+
}
|
|
33
|
+
return accumulator;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var _arrayReduce = arrayReduce;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
|
40
|
+
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
|
41
|
+
*
|
|
42
|
+
* @private
|
|
43
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
44
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
45
|
+
* @param {*} accumulator The initial value.
|
|
46
|
+
* @param {boolean} initAccum Specify using the first or last element of
|
|
47
|
+
* `collection` as the initial value.
|
|
48
|
+
* @param {Function} eachFunc The function to iterate over `collection`.
|
|
49
|
+
* @returns {*} Returns the accumulated value.
|
|
50
|
+
*/
|
|
51
|
+
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
|
52
|
+
eachFunc(collection, function(value, index, collection) {
|
|
53
|
+
accumulator = initAccum
|
|
54
|
+
? (initAccum = false, value)
|
|
55
|
+
: iteratee(accumulator, value, index, collection);
|
|
56
|
+
});
|
|
57
|
+
return accumulator;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var _baseReduce = baseReduce;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reduces `collection` to a value which is the accumulated result of running
|
|
64
|
+
* each element in `collection` thru `iteratee`, where each successive
|
|
65
|
+
* invocation is supplied the return value of the previous. If `accumulator`
|
|
66
|
+
* is not given, the first element of `collection` is used as the initial
|
|
67
|
+
* value. The iteratee is invoked with four arguments:
|
|
68
|
+
* (accumulator, value, index|key, collection).
|
|
69
|
+
*
|
|
70
|
+
* Many lodash methods are guarded to work as iteratees for methods like
|
|
71
|
+
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
|
72
|
+
*
|
|
73
|
+
* The guarded methods are:
|
|
74
|
+
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
|
|
75
|
+
* and `sortBy`
|
|
76
|
+
*
|
|
77
|
+
* @static
|
|
78
|
+
* @memberOf _
|
|
79
|
+
* @since 0.1.0
|
|
80
|
+
* @category Collection
|
|
81
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
82
|
+
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
83
|
+
* @param {*} [accumulator] The initial value.
|
|
84
|
+
* @returns {*} Returns the accumulated value.
|
|
85
|
+
* @see _.reduceRight
|
|
86
|
+
* @example
|
|
87
|
+
*
|
|
88
|
+
* _.reduce([1, 2], function(sum, n) {
|
|
89
|
+
* return sum + n;
|
|
90
|
+
* }, 0);
|
|
91
|
+
* // => 3
|
|
92
|
+
*
|
|
93
|
+
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
|
94
|
+
* (result[value] || (result[value] = [])).push(key);
|
|
95
|
+
* return result;
|
|
96
|
+
* }, {});
|
|
97
|
+
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
|
|
98
|
+
*/
|
|
99
|
+
function reduce(collection, iteratee, accumulator) {
|
|
100
|
+
var func = isArray_1(collection) ? _arrayReduce : _baseReduce,
|
|
101
|
+
initAccum = arguments.length < 3;
|
|
102
|
+
|
|
103
|
+
return func(collection, _baseIteratee(iteratee), accumulator, initAccum, _baseEach);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var reduce_1 = reduce;
|
|
107
|
+
|
|
108
|
+
/** Used as references for the maximum length and index of an array. */
|
|
109
|
+
var MAX_ARRAY_LENGTH$1 = 4294967295,
|
|
110
|
+
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH$1 - 1;
|
|
111
|
+
|
|
112
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
113
|
+
var nativeFloor = Math.floor,
|
|
114
|
+
nativeMin = Math.min;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
|
|
118
|
+
* which invokes `iteratee` for `value` and each element of `array` to compute
|
|
119
|
+
* their sort ranking. The iteratee is invoked with one argument; (value).
|
|
120
|
+
*
|
|
121
|
+
* @private
|
|
122
|
+
* @param {Array} array The sorted array to inspect.
|
|
123
|
+
* @param {*} value The value to evaluate.
|
|
124
|
+
* @param {Function} iteratee The iteratee invoked per element.
|
|
125
|
+
* @param {boolean} [retHighest] Specify returning the highest qualified index.
|
|
126
|
+
* @returns {number} Returns the index at which `value` should be inserted
|
|
127
|
+
* into `array`.
|
|
128
|
+
*/
|
|
129
|
+
function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
|
130
|
+
var low = 0,
|
|
131
|
+
high = array == null ? 0 : array.length;
|
|
132
|
+
if (high === 0) {
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
value = iteratee(value);
|
|
137
|
+
var valIsNaN = value !== value,
|
|
138
|
+
valIsNull = value === null,
|
|
139
|
+
valIsSymbol = isSymbol_1(value),
|
|
140
|
+
valIsUndefined = value === undefined;
|
|
141
|
+
|
|
142
|
+
while (low < high) {
|
|
143
|
+
var mid = nativeFloor((low + high) / 2),
|
|
144
|
+
computed = iteratee(array[mid]),
|
|
145
|
+
othIsDefined = computed !== undefined,
|
|
146
|
+
othIsNull = computed === null,
|
|
147
|
+
othIsReflexive = computed === computed,
|
|
148
|
+
othIsSymbol = isSymbol_1(computed);
|
|
149
|
+
|
|
150
|
+
if (valIsNaN) {
|
|
151
|
+
var setLow = retHighest || othIsReflexive;
|
|
152
|
+
} else if (valIsUndefined) {
|
|
153
|
+
setLow = othIsReflexive && (retHighest || othIsDefined);
|
|
154
|
+
} else if (valIsNull) {
|
|
155
|
+
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
|
|
156
|
+
} else if (valIsSymbol) {
|
|
157
|
+
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
|
|
158
|
+
} else if (othIsNull || othIsSymbol) {
|
|
159
|
+
setLow = false;
|
|
160
|
+
} else {
|
|
161
|
+
setLow = retHighest ? (computed <= value) : (computed < value);
|
|
162
|
+
}
|
|
163
|
+
if (setLow) {
|
|
164
|
+
low = mid + 1;
|
|
165
|
+
} else {
|
|
166
|
+
high = mid;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return nativeMin(high, MAX_ARRAY_INDEX);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var _baseSortedIndexBy = baseSortedIndexBy;
|
|
173
|
+
|
|
174
|
+
/** Used as references for the maximum length and index of an array. */
|
|
175
|
+
var MAX_ARRAY_LENGTH = 4294967295,
|
|
176
|
+
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
|
|
180
|
+
* performs a binary search of `array` to determine the index at which `value`
|
|
181
|
+
* should be inserted into `array` in order to maintain its sort order.
|
|
182
|
+
*
|
|
183
|
+
* @private
|
|
184
|
+
* @param {Array} array The sorted array to inspect.
|
|
185
|
+
* @param {*} value The value to evaluate.
|
|
186
|
+
* @param {boolean} [retHighest] Specify returning the highest qualified index.
|
|
187
|
+
* @returns {number} Returns the index at which `value` should be inserted
|
|
188
|
+
* into `array`.
|
|
189
|
+
*/
|
|
190
|
+
function baseSortedIndex(array, value, retHighest) {
|
|
191
|
+
var low = 0,
|
|
192
|
+
high = array == null ? low : array.length;
|
|
193
|
+
|
|
194
|
+
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
|
|
195
|
+
while (low < high) {
|
|
196
|
+
var mid = (low + high) >>> 1,
|
|
197
|
+
computed = array[mid];
|
|
198
|
+
|
|
199
|
+
if (computed !== null && !isSymbol_1(computed) &&
|
|
200
|
+
(retHighest ? (computed <= value) : (computed < value))) {
|
|
201
|
+
low = mid + 1;
|
|
202
|
+
} else {
|
|
203
|
+
high = mid;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return high;
|
|
207
|
+
}
|
|
208
|
+
return _baseSortedIndexBy(array, value, identity_1, retHighest);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var _baseSortedIndex = baseSortedIndex;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Uses a binary search to determine the lowest index at which `value`
|
|
215
|
+
* should be inserted into `array` in order to maintain its sort order.
|
|
216
|
+
*
|
|
217
|
+
* @static
|
|
218
|
+
* @memberOf _
|
|
219
|
+
* @since 0.1.0
|
|
220
|
+
* @category Array
|
|
221
|
+
* @param {Array} array The sorted array to inspect.
|
|
222
|
+
* @param {*} value The value to evaluate.
|
|
223
|
+
* @returns {number} Returns the index at which `value` should be inserted
|
|
224
|
+
* into `array`.
|
|
225
|
+
* @example
|
|
226
|
+
*
|
|
227
|
+
* _.sortedIndex([30, 50], 40);
|
|
228
|
+
* // => 1
|
|
229
|
+
*/
|
|
230
|
+
function sortedIndex(array, value) {
|
|
231
|
+
return _baseSortedIndex(array, value);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var sortedIndex_1 = sortedIndex;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Pre-calculation
|
|
238
|
+
* Dimension sizes for each cell
|
|
239
|
+
*/
|
|
240
|
+
function calculateDimensionData(state, newSizes) {
|
|
241
|
+
let positionIndexes = [];
|
|
242
|
+
const positionIndexToItem = {};
|
|
243
|
+
const indexToItem = {};
|
|
244
|
+
// to compare how real width changed
|
|
245
|
+
let newTotal = 0;
|
|
246
|
+
// combine all sizes
|
|
247
|
+
const sizes = Object.assign(Object.assign({}, state.sizes), newSizes);
|
|
248
|
+
// prepare order sorted new sizes and calculate changed real size
|
|
249
|
+
let newIndexes = [];
|
|
250
|
+
each(newSizes, (size, index) => {
|
|
251
|
+
// if first introduced custom size
|
|
252
|
+
if (!state.sizes[index]) {
|
|
253
|
+
newTotal += size - (state.realSize ? state.originItemSize : 0);
|
|
254
|
+
newIndexes.splice(sortedIndex_1(newIndexes, parseInt(index, 10)), 0, parseInt(index, 10));
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
newTotal += size - state.sizes[index];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
// add order to cached order collection for faster linking
|
|
261
|
+
const updatedIndexesCache = mergeSortedArray(state.indexes, newIndexes);
|
|
262
|
+
// fill new coordinates
|
|
263
|
+
reduce_1(updatedIndexesCache, (previous, itemIndex, i) => {
|
|
264
|
+
const newItem = {
|
|
265
|
+
itemIndex,
|
|
266
|
+
start: 0,
|
|
267
|
+
end: 0,
|
|
268
|
+
};
|
|
269
|
+
if (previous) {
|
|
270
|
+
newItem.start = (itemIndex - previous.itemIndex - 1) * state.originItemSize + previous.end;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
newItem.start = itemIndex * state.originItemSize;
|
|
274
|
+
}
|
|
275
|
+
newItem.end = newItem.start + sizes[itemIndex];
|
|
276
|
+
positionIndexes.push(newItem.start);
|
|
277
|
+
indexToItem[itemIndex] = positionIndexToItem[i] = newItem;
|
|
278
|
+
return newItem;
|
|
279
|
+
}, undefined);
|
|
280
|
+
return {
|
|
281
|
+
indexes: updatedIndexesCache,
|
|
282
|
+
positionIndexes: [...positionIndexes],
|
|
283
|
+
positionIndexToItem: Object.assign({}, positionIndexToItem),
|
|
284
|
+
indexToItem,
|
|
285
|
+
realSize: state.realSize + newTotal,
|
|
286
|
+
sizes,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function getItemByPosition({ indexes, positionIndexes, originItemSize, positionIndexToItem }, pos) {
|
|
290
|
+
const item = {
|
|
291
|
+
itemIndex: 0,
|
|
292
|
+
start: 0,
|
|
293
|
+
end: 0,
|
|
294
|
+
};
|
|
295
|
+
const currentPlace = indexes.length ? sortedIndex_1(positionIndexes, pos) : 0;
|
|
296
|
+
// not found or first index
|
|
297
|
+
if (!currentPlace) {
|
|
298
|
+
item.itemIndex = Math.floor(pos / originItemSize);
|
|
299
|
+
item.start = item.itemIndex * originItemSize;
|
|
300
|
+
item.end = item.start + originItemSize;
|
|
301
|
+
return item;
|
|
302
|
+
}
|
|
303
|
+
const positionItem = positionIndexToItem[currentPlace - 1];
|
|
304
|
+
// if item has specified size
|
|
305
|
+
if (positionItem.end > pos) {
|
|
306
|
+
return positionItem;
|
|
307
|
+
}
|
|
308
|
+
// special size item was present before
|
|
309
|
+
const relativePos = pos - positionItem.end;
|
|
310
|
+
const relativeIndex = Math.floor(relativePos / originItemSize);
|
|
311
|
+
item.itemIndex = positionItem.itemIndex + 1 + relativeIndex;
|
|
312
|
+
item.start = positionItem.end + relativeIndex * originItemSize;
|
|
313
|
+
item.end = item.start + originItemSize;
|
|
314
|
+
return item;
|
|
315
|
+
}
|
|
316
|
+
function getItemByIndex(dimension, index) {
|
|
317
|
+
let item = {
|
|
318
|
+
itemIndex: index,
|
|
319
|
+
start: 0,
|
|
320
|
+
end: 0,
|
|
321
|
+
};
|
|
322
|
+
// if item has specified size
|
|
323
|
+
if (dimension.indexToItem[index]) {
|
|
324
|
+
return dimension.indexToItem[index];
|
|
325
|
+
}
|
|
326
|
+
const currentPlace = dimension.indexes.length ? sortedIndex_1(dimension.indexes, index) : 0;
|
|
327
|
+
// not found or first index
|
|
328
|
+
if (!currentPlace) {
|
|
329
|
+
item.start = item.itemIndex * dimension.originItemSize;
|
|
330
|
+
item.end = item.start + dimension.originItemSize;
|
|
331
|
+
return item;
|
|
332
|
+
}
|
|
333
|
+
// special size item was present before
|
|
334
|
+
const positionItem = dimension.indexToItem[dimension.indexes[currentPlace - 1]];
|
|
335
|
+
item.start = positionItem.end + (index - positionItem.itemIndex - 1) * dimension.originItemSize;
|
|
336
|
+
item.end = item.start + dimension.originItemSize;
|
|
337
|
+
return item;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { getItemByPosition as a, calculateDimensionData as c, getItemByIndex as g, reduce_1 as r };
|