@elliemae/ds-utilities 2.0.0-alpha.1 → 2.0.0-alpha.13
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/cjs/capitalize.js +7 -0
- package/cjs/compose.js +13 -2
- package/cjs/getComponentFromProps.js +10 -3
- package/cjs/hooks/index.js +31 -33
- package/cjs/hooks/useCancellableDelayedCallback.js +6 -1
- package/cjs/hooks/useDerivedStateFromProps.js +16 -6
- package/cjs/hooks/useExecutionTimer.js +11 -2
- package/cjs/hooks/useExpandState.js +31 -18
- package/cjs/hooks/useHotkeys.js +10 -7
- package/cjs/hooks/useHoverHandlersDelay.js +7 -6
- package/cjs/hooks/useOnElementResize.js +37 -0
- package/cjs/hooks/useParentElement.js +16 -0
- package/cjs/hooks/useResizeObserver.js +3 -2
- package/cjs/hooks/useSetRef.js +15 -0
- package/cjs/hooks/useWindowScrollerList.js +10 -8
- package/cjs/hooks/useWindowSize.js +1 -0
- package/cjs/index.js +236 -0
- package/cjs/operators.js +3 -0
- package/cjs/reactTypesUtility.js +1 -1
- package/cjs/scrollingTimer.js +5 -1
- package/cjs/system.js +14 -2
- package/cjs/timeUtils.js +8 -0
- package/cjs/utils.js +76 -122
- package/cjs/validations.js +24 -19
- package/esm/capitalize.js +3 -0
- package/esm/compose.js +13 -2
- package/esm/getComponentFromProps.js +8 -1
- package/esm/hooks/index.js +11 -18
- package/esm/hooks/useCancellableDelayedCallback.js +6 -1
- package/esm/hooks/useDerivedStateFromProps.js +16 -6
- package/esm/hooks/useExecutionTimer.js +11 -2
- package/esm/hooks/useExpandState.js +27 -14
- package/esm/hooks/useHotkeys.js +8 -5
- package/esm/hooks/useHoverHandlersDelay.js +7 -6
- package/esm/hooks/useOnElementResize.js +33 -0
- package/esm/hooks/useParentElement.js +12 -0
- package/esm/hooks/useResizeObserver.js +1 -0
- package/esm/hooks/useSetRef.js +11 -0
- package/esm/hooks/useWindowScrollerList.js +10 -8
- package/esm/hooks/useWindowSize.js +1 -0
- package/esm/index.js +27 -0
- package/esm/operators.js +3 -0
- package/esm/scrollingTimer.js +5 -1
- package/esm/system.js +14 -2
- package/esm/timeUtils.js +8 -0
- package/esm/utils.js +37 -8
- package/esm/validations.js +24 -19
- package/package.json +17 -1
- package/types/capitalize.d.ts +1 -0
- package/types/hooks/index.d.ts +11 -3
- package/types/hooks/useOnElementResize.d.ts +2 -0
- package/types/hooks/useParentElement.d.ts +1 -0
- package/types/hooks/useSetRef.d.ts +2 -0
- package/types/index.d.ts +9 -0
- package/types/utils.d.ts +1 -2
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/utils.js
CHANGED
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
9
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
14
|
var lodash = require('lodash');
|
|
7
|
-
var compose = require('./compose.js');
|
|
8
15
|
|
|
9
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
17
|
|
|
@@ -12,14 +19,20 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
12
19
|
|
|
13
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
14
21
|
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default[
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
23
|
/**
|
|
17
24
|
* Concatenates classNames from arguments
|
|
18
25
|
*
|
|
19
26
|
* @param {...any} classnames
|
|
20
27
|
*/
|
|
21
28
|
|
|
22
|
-
const cx =
|
|
29
|
+
const cx = function () {
|
|
30
|
+
for (var _len = arguments.length, classnames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
classnames[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return classnames.reduce((result, cn) => "".concat(result, " ").concat(cn || ''), '');
|
|
35
|
+
}; // if entry exists, remove it, if not, add it
|
|
23
36
|
|
|
24
37
|
const toggleInObject = (obj, key, value) => obj[key] !== undefined ? lodash.omit(obj, [key]) : _objectSpread(_objectSpread({}, obj), {}, {
|
|
25
38
|
[key]: value
|
|
@@ -39,7 +52,8 @@ const arrayMove = (array, from, to) => {
|
|
|
39
52
|
|
|
40
53
|
const accessorDefault = item => item;
|
|
41
54
|
|
|
42
|
-
const addOrRemove = (array, item
|
|
55
|
+
const addOrRemove = function (array, item) {
|
|
56
|
+
let accessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : accessorDefault;
|
|
43
57
|
const index = array.findIndex(iItem => accessor(iItem) === accessor(item));
|
|
44
58
|
|
|
45
59
|
if (index !== -1) {
|
|
@@ -51,18 +65,33 @@ const addOrRemove = (array, item, accessor = accessorDefault) => {
|
|
|
51
65
|
return [...array, item];
|
|
52
66
|
};
|
|
53
67
|
|
|
54
|
-
function runAll(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
68
|
+
function runAll() {
|
|
69
|
+
for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
70
|
+
fns[_key2] = arguments[_key2];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return function () {
|
|
74
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
75
|
+
args[_key3] = arguments[_key3];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return fns.forEach(fn => {
|
|
79
|
+
if (Array.isArray(fn)) runAll(fn);
|
|
80
|
+
if (lodash.isFunction(fn)) fn(...args);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
58
83
|
}
|
|
59
84
|
function hashArray(arr, fieldName) {
|
|
60
85
|
return arr.reduce((result, item) => _objectSpread(_objectSpread({}, result), {}, {
|
|
61
86
|
[fieldName ? item[fieldName] : item]: true
|
|
62
87
|
}), {});
|
|
63
88
|
}
|
|
64
|
-
function safeCall(fun
|
|
89
|
+
function safeCall(fun) {
|
|
65
90
|
if (lodash.isFunction(fun)) {
|
|
91
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
92
|
+
args[_key4 - 1] = arguments[_key4];
|
|
93
|
+
}
|
|
94
|
+
|
|
66
95
|
fun(...args);
|
|
67
96
|
}
|
|
68
97
|
}
|
|
@@ -76,231 +105,156 @@ var utils = {};
|
|
|
76
105
|
|
|
77
106
|
Object.defineProperty(exports, 'cloneDeep', {
|
|
78
107
|
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return lodash.cloneDeep;
|
|
81
|
-
}
|
|
108
|
+
get: function () { return lodash.cloneDeep; }
|
|
82
109
|
});
|
|
83
110
|
Object.defineProperty(exports, 'curry', {
|
|
84
111
|
enumerable: true,
|
|
85
|
-
get: function () {
|
|
86
|
-
return lodash.curry;
|
|
87
|
-
}
|
|
112
|
+
get: function () { return lodash.curry; }
|
|
88
113
|
});
|
|
89
114
|
Object.defineProperty(exports, 'debounce', {
|
|
90
115
|
enumerable: true,
|
|
91
|
-
get: function () {
|
|
92
|
-
return lodash.debounce;
|
|
93
|
-
}
|
|
116
|
+
get: function () { return lodash.debounce; }
|
|
94
117
|
});
|
|
95
118
|
Object.defineProperty(exports, 'differenceBy', {
|
|
96
119
|
enumerable: true,
|
|
97
|
-
get: function () {
|
|
98
|
-
return lodash.differenceBy;
|
|
99
|
-
}
|
|
120
|
+
get: function () { return lodash.differenceBy; }
|
|
100
121
|
});
|
|
101
122
|
Object.defineProperty(exports, 'differenceWith', {
|
|
102
123
|
enumerable: true,
|
|
103
|
-
get: function () {
|
|
104
|
-
return lodash.differenceWith;
|
|
105
|
-
}
|
|
124
|
+
get: function () { return lodash.differenceWith; }
|
|
106
125
|
});
|
|
107
126
|
Object.defineProperty(exports, 'filter', {
|
|
108
127
|
enumerable: true,
|
|
109
|
-
get: function () {
|
|
110
|
-
return lodash.filter;
|
|
111
|
-
}
|
|
128
|
+
get: function () { return lodash.filter; }
|
|
112
129
|
});
|
|
113
130
|
Object.defineProperty(exports, 'findIndex', {
|
|
114
131
|
enumerable: true,
|
|
115
|
-
get: function () {
|
|
116
|
-
return lodash.findIndex;
|
|
117
|
-
}
|
|
132
|
+
get: function () { return lodash.findIndex; }
|
|
118
133
|
});
|
|
119
134
|
Object.defineProperty(exports, 'get', {
|
|
120
135
|
enumerable: true,
|
|
121
|
-
get: function () {
|
|
122
|
-
return lodash.get;
|
|
123
|
-
}
|
|
136
|
+
get: function () { return lodash.get; }
|
|
124
137
|
});
|
|
125
138
|
Object.defineProperty(exports, 'groupBy', {
|
|
126
139
|
enumerable: true,
|
|
127
|
-
get: function () {
|
|
128
|
-
return lodash.groupBy;
|
|
129
|
-
}
|
|
140
|
+
get: function () { return lodash.groupBy; }
|
|
130
141
|
});
|
|
131
142
|
Object.defineProperty(exports, 'isBoolean', {
|
|
132
143
|
enumerable: true,
|
|
133
|
-
get: function () {
|
|
134
|
-
return lodash.isBoolean;
|
|
135
|
-
}
|
|
144
|
+
get: function () { return lodash.isBoolean; }
|
|
136
145
|
});
|
|
137
146
|
Object.defineProperty(exports, 'isEmpty', {
|
|
138
147
|
enumerable: true,
|
|
139
|
-
get: function () {
|
|
140
|
-
return lodash.isEmpty;
|
|
141
|
-
}
|
|
148
|
+
get: function () { return lodash.isEmpty; }
|
|
142
149
|
});
|
|
143
150
|
Object.defineProperty(exports, 'isEqual', {
|
|
144
151
|
enumerable: true,
|
|
145
|
-
get: function () {
|
|
146
|
-
return lodash.isEqual;
|
|
147
|
-
}
|
|
152
|
+
get: function () { return lodash.isEqual; }
|
|
148
153
|
});
|
|
149
154
|
Object.defineProperty(exports, 'isEqualWith', {
|
|
150
155
|
enumerable: true,
|
|
151
|
-
get: function () {
|
|
152
|
-
return lodash.isEqualWith;
|
|
153
|
-
}
|
|
156
|
+
get: function () { return lodash.isEqualWith; }
|
|
154
157
|
});
|
|
155
158
|
Object.defineProperty(exports, 'isFunction', {
|
|
156
159
|
enumerable: true,
|
|
157
|
-
get: function () {
|
|
158
|
-
return lodash.isFunction;
|
|
159
|
-
}
|
|
160
|
+
get: function () { return lodash.isFunction; }
|
|
160
161
|
});
|
|
161
162
|
Object.defineProperty(exports, 'isNaN', {
|
|
162
163
|
enumerable: true,
|
|
163
|
-
get: function () {
|
|
164
|
-
return lodash.isNaN;
|
|
165
|
-
}
|
|
164
|
+
get: function () { return lodash.isNaN; }
|
|
166
165
|
});
|
|
167
166
|
Object.defineProperty(exports, 'isObject', {
|
|
168
167
|
enumerable: true,
|
|
169
|
-
get: function () {
|
|
170
|
-
return lodash.isObject;
|
|
171
|
-
}
|
|
168
|
+
get: function () { return lodash.isObject; }
|
|
172
169
|
});
|
|
173
170
|
Object.defineProperty(exports, 'isString', {
|
|
174
171
|
enumerable: true,
|
|
175
|
-
get: function () {
|
|
176
|
-
return lodash.isString;
|
|
177
|
-
}
|
|
172
|
+
get: function () { return lodash.isString; }
|
|
178
173
|
});
|
|
179
174
|
Object.defineProperty(exports, 'maxBy', {
|
|
180
175
|
enumerable: true,
|
|
181
|
-
get: function () {
|
|
182
|
-
return lodash.maxBy;
|
|
183
|
-
}
|
|
176
|
+
get: function () { return lodash.maxBy; }
|
|
184
177
|
});
|
|
185
178
|
Object.defineProperty(exports, 'meanBy', {
|
|
186
179
|
enumerable: true,
|
|
187
|
-
get: function () {
|
|
188
|
-
return lodash.meanBy;
|
|
189
|
-
}
|
|
180
|
+
get: function () { return lodash.meanBy; }
|
|
190
181
|
});
|
|
191
182
|
Object.defineProperty(exports, 'noop', {
|
|
192
183
|
enumerable: true,
|
|
193
|
-
get: function () {
|
|
194
|
-
return lodash.noop;
|
|
195
|
-
}
|
|
184
|
+
get: function () { return lodash.noop; }
|
|
196
185
|
});
|
|
197
186
|
Object.defineProperty(exports, 'omit', {
|
|
198
187
|
enumerable: true,
|
|
199
|
-
get: function () {
|
|
200
|
-
return lodash.omit;
|
|
201
|
-
}
|
|
188
|
+
get: function () { return lodash.omit; }
|
|
202
189
|
});
|
|
203
190
|
Object.defineProperty(exports, 'orderBy', {
|
|
204
191
|
enumerable: true,
|
|
205
|
-
get: function () {
|
|
206
|
-
return lodash.orderBy;
|
|
207
|
-
}
|
|
192
|
+
get: function () { return lodash.orderBy; }
|
|
208
193
|
});
|
|
209
194
|
Object.defineProperty(exports, 'padStart', {
|
|
210
195
|
enumerable: true,
|
|
211
|
-
get: function () {
|
|
212
|
-
return lodash.padStart;
|
|
213
|
-
}
|
|
196
|
+
get: function () { return lodash.padStart; }
|
|
214
197
|
});
|
|
215
198
|
Object.defineProperty(exports, 'parseInt', {
|
|
216
199
|
enumerable: true,
|
|
217
|
-
get: function () {
|
|
218
|
-
return lodash.parseInt;
|
|
219
|
-
}
|
|
200
|
+
get: function () { return lodash.parseInt; }
|
|
220
201
|
});
|
|
221
202
|
Object.defineProperty(exports, 'pick', {
|
|
222
203
|
enumerable: true,
|
|
223
|
-
get: function () {
|
|
224
|
-
return lodash.pick;
|
|
225
|
-
}
|
|
204
|
+
get: function () { return lodash.pick; }
|
|
226
205
|
});
|
|
227
206
|
Object.defineProperty(exports, 'pickBy', {
|
|
228
207
|
enumerable: true,
|
|
229
|
-
get: function () {
|
|
230
|
-
return lodash.pickBy;
|
|
231
|
-
}
|
|
208
|
+
get: function () { return lodash.pickBy; }
|
|
232
209
|
});
|
|
233
210
|
Object.defineProperty(exports, 'property', {
|
|
234
211
|
enumerable: true,
|
|
235
|
-
get: function () {
|
|
236
|
-
return lodash.property;
|
|
237
|
-
}
|
|
212
|
+
get: function () { return lodash.property; }
|
|
238
213
|
});
|
|
239
214
|
Object.defineProperty(exports, 'pull', {
|
|
240
215
|
enumerable: true,
|
|
241
|
-
get: function () {
|
|
242
|
-
return lodash.pull;
|
|
243
|
-
}
|
|
216
|
+
get: function () { return lodash.pull; }
|
|
244
217
|
});
|
|
245
218
|
Object.defineProperty(exports, 'range', {
|
|
246
219
|
enumerable: true,
|
|
247
|
-
get: function () {
|
|
248
|
-
return lodash.range;
|
|
249
|
-
}
|
|
220
|
+
get: function () { return lodash.range; }
|
|
250
221
|
});
|
|
251
222
|
Object.defineProperty(exports, 'set', {
|
|
252
223
|
enumerable: true,
|
|
253
|
-
get: function () {
|
|
254
|
-
return lodash.set;
|
|
255
|
-
}
|
|
224
|
+
get: function () { return lodash.set; }
|
|
256
225
|
});
|
|
257
226
|
Object.defineProperty(exports, 'sortBy', {
|
|
258
227
|
enumerable: true,
|
|
259
|
-
get: function () {
|
|
260
|
-
return lodash.sortBy;
|
|
261
|
-
}
|
|
228
|
+
get: function () { return lodash.sortBy; }
|
|
262
229
|
});
|
|
263
230
|
Object.defineProperty(exports, 'sumBy', {
|
|
264
231
|
enumerable: true,
|
|
265
|
-
get: function () {
|
|
266
|
-
return lodash.sumBy;
|
|
267
|
-
}
|
|
232
|
+
get: function () { return lodash.sumBy; }
|
|
268
233
|
});
|
|
269
234
|
Object.defineProperty(exports, 'throttle', {
|
|
270
235
|
enumerable: true,
|
|
271
|
-
get: function () {
|
|
272
|
-
return lodash.throttle;
|
|
273
|
-
}
|
|
236
|
+
get: function () { return lodash.throttle; }
|
|
274
237
|
});
|
|
275
238
|
Object.defineProperty(exports, 'transform', {
|
|
276
239
|
enumerable: true,
|
|
277
|
-
get: function () {
|
|
278
|
-
return lodash.transform;
|
|
279
|
-
}
|
|
240
|
+
get: function () { return lodash.transform; }
|
|
280
241
|
});
|
|
281
242
|
Object.defineProperty(exports, 'uniq', {
|
|
282
243
|
enumerable: true,
|
|
283
|
-
get: function () {
|
|
284
|
-
return lodash.uniq;
|
|
285
|
-
}
|
|
244
|
+
get: function () { return lodash.uniq; }
|
|
286
245
|
});
|
|
287
246
|
Object.defineProperty(exports, 'uniqBy', {
|
|
288
247
|
enumerable: true,
|
|
289
|
-
get: function () {
|
|
290
|
-
return lodash.uniqBy;
|
|
291
|
-
}
|
|
248
|
+
get: function () { return lodash.uniqBy; }
|
|
292
249
|
});
|
|
293
250
|
Object.defineProperty(exports, 'values', {
|
|
294
251
|
enumerable: true,
|
|
295
|
-
get: function () {
|
|
296
|
-
return lodash.values;
|
|
297
|
-
}
|
|
252
|
+
get: function () { return lodash.values; }
|
|
298
253
|
});
|
|
299
|
-
exports.compose = compose.compose;
|
|
300
254
|
exports.addOrRemove = addOrRemove;
|
|
301
255
|
exports.arrayMove = arrayMove;
|
|
302
256
|
exports.cx = cx;
|
|
303
|
-
exports[
|
|
257
|
+
exports["default"] = utils;
|
|
304
258
|
exports.hashArray = hashArray;
|
|
305
259
|
exports.removeUndefinedProperties = removeUndefinedProperties;
|
|
306
260
|
exports.runAll = runAll;
|
package/cjs/validations.js
CHANGED
|
@@ -4,30 +4,35 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var operators = require('./operators.js');
|
|
6
6
|
|
|
7
|
-
const isRequired =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const isRequired = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
value,
|
|
10
|
+
help = 'Field is Required'
|
|
11
|
+
} = _ref;
|
|
12
|
+
return {
|
|
13
|
+
payload: help,
|
|
14
|
+
error: operators.checkNotEmpty(value)
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const isGreaterThan = _ref2 => {
|
|
18
|
+
let {
|
|
19
|
+
value,
|
|
20
|
+
help,
|
|
21
|
+
comparator = 0
|
|
22
|
+
} = _ref2;
|
|
23
|
+
if (!help) help = "Max value ".concat(comparator);
|
|
20
24
|
return {
|
|
21
25
|
payload: help,
|
|
22
26
|
error: operators.greaterThan(value, comparator)
|
|
23
27
|
};
|
|
24
28
|
};
|
|
25
|
-
const isValidDate =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const isValidDate = _ref3 => {
|
|
30
|
+
let {
|
|
31
|
+
value,
|
|
32
|
+
help,
|
|
33
|
+
format = 'MM/DD/AAA'
|
|
34
|
+
} = _ref3;
|
|
35
|
+
if (!help) help = "Valid Date is required ".concat(format);
|
|
31
36
|
return {
|
|
32
37
|
payload: help,
|
|
33
38
|
error: !operators.validDate(value)
|
package/esm/compose.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Composes single-argument functions from right to left. The rightmost
|
|
3
8
|
* function can take multiple arguments as it provides the signature for
|
|
@@ -8,7 +13,11 @@
|
|
|
8
13
|
* from right to left. For example, compose(f, g, h) is identical to doing
|
|
9
14
|
* (...args) => f(g(h(...args))).
|
|
10
15
|
*/
|
|
11
|
-
function compose(
|
|
16
|
+
function compose() {
|
|
17
|
+
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
funcs[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
if (funcs.length === 0) {
|
|
13
22
|
return arg => arg;
|
|
14
23
|
}
|
|
@@ -17,7 +26,9 @@ function compose(...funcs) {
|
|
|
17
26
|
return funcs[0];
|
|
18
27
|
}
|
|
19
28
|
|
|
20
|
-
return funcs.reduce((a, b) => (
|
|
29
|
+
return funcs.reduce((a, b) => function () {
|
|
30
|
+
return a(b(...arguments));
|
|
31
|
+
});
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
export { compose };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
8
|
import React from 'react';
|
|
3
9
|
import { jsx } from 'react/jsx-runtime';
|
|
4
10
|
|
|
5
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
12
|
|
|
7
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
-
function getComponentFromProps(Component, props
|
|
14
|
+
function getComponentFromProps(Component, props) {
|
|
15
|
+
let children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
9
16
|
if (!Component) return null;
|
|
10
17
|
const componentChildren = Component.props ? Array.isArray(Component.props.children) ? Component.props.children : [Component.props.children] : null;
|
|
11
18
|
return typeof Component === 'function' ? /*#__PURE__*/jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
1
|
export { default as useMeasure } from 'use-measure';
|
|
3
2
|
export { default as useExecutionTimer } from './useExecutionTimer.js';
|
|
3
|
+
export { default as useExpandState } from './useExpandState.js';
|
|
4
|
+
export { default as useHotkeys } from './useHotkeys.js';
|
|
5
|
+
export { default as useHoverHandlersDelay } from './useHoverHandlersDelay.js';
|
|
6
|
+
export { default as useResizeObserver } from './useResizeObserver.js';
|
|
7
|
+
export { default as useShouldRecalculate } from './useShouldRecalculate.js';
|
|
8
|
+
export { default as useWindowScrollerList } from './useWindowScrollerList.js';
|
|
9
|
+
export { default as useWindowSize } from './useWindowSize.js';
|
|
4
10
|
export { default as useForceUpdate } from 'use-force-update';
|
|
5
11
|
export { default as useOnClickOutside } from 'use-onclickoutside';
|
|
6
12
|
export { useUncontrolled } from 'uncontrollable';
|
|
7
13
|
export { default as usePrevious } from './usePrevious.js';
|
|
8
14
|
export { default as useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (ref.current) setParent(ref.current.parentNode);
|
|
14
|
-
});
|
|
15
|
-
return parent;
|
|
16
|
-
}
|
|
17
|
-
function useSetRef(initial) {
|
|
18
|
-
const ref = useRef(initial);
|
|
19
|
-
const setRef = useCallback(node => {
|
|
20
|
-
ref.current = node;
|
|
21
|
-
}, []);
|
|
22
|
-
return [ref, setRef];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { useParentElement, useSetRef };
|
|
15
|
+
export { default as useDerivedStateFromProps } from './useDerivedStateFromProps.js';
|
|
16
|
+
export { useSetRef } from './useSetRef.js';
|
|
17
|
+
export { useParentElement } from './useParentElement.js';
|
|
18
|
+
export { useOnElementResize } from './useOnElementResize.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import { useRef, useCallback } from 'react';
|
|
2
3
|
|
|
3
4
|
function useCancellableDelayedCallback(cb, delay) {
|
|
@@ -10,7 +11,11 @@ function useCancellableDelayedCallback(cb, delay) {
|
|
|
10
11
|
clearTimeout(timeoutId);
|
|
11
12
|
}
|
|
12
13
|
}, [timeoutRef]);
|
|
13
|
-
const delayedCb = useCallback((
|
|
14
|
+
const delayedCb = useCallback(function () {
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
timeoutRef.current = setTimeout(() => cb(...args), delay);
|
|
15
20
|
}, [cb, delay]);
|
|
16
21
|
return [delayedCb, cancel];
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import { useState, useRef } from 'react';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
2
5
|
import '@babel/runtime/helpers/esm/defineProperty';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
11
|
import { isFunction, isEqual } from 'lodash';
|
|
4
12
|
|
|
5
13
|
const defaultPropUpdateOnChange = prop => prop;
|
|
6
14
|
|
|
7
|
-
function defaultShouldUpdate({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
function defaultShouldUpdate(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
prop,
|
|
18
|
+
prevProp,
|
|
19
|
+
stateValue
|
|
20
|
+
} = _ref;
|
|
12
21
|
return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);
|
|
13
22
|
}
|
|
14
23
|
|
|
@@ -18,7 +27,8 @@ function setStateWithUpdate(onUpdate, setState) {
|
|
|
18
27
|
};
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
function useDerivedStateFromProp(prop
|
|
30
|
+
function useDerivedStateFromProp(prop) {
|
|
31
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
22
32
|
const {
|
|
23
33
|
onUpdate = defaultPropUpdateOnChange,
|
|
24
34
|
shouldUpdate = defaultShouldUpdate,
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import { useRef } from 'react';
|
|
2
3
|
|
|
3
4
|
function useExecutionDelay(startFn, cleanFn, delayTime) {
|
|
4
5
|
const startTimer = useRef();
|
|
5
6
|
const closeTimer = useRef();
|
|
6
7
|
|
|
7
|
-
const startFunction = (
|
|
8
|
+
const startFunction = function () {
|
|
9
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
+
args[_key] = arguments[_key];
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
clearTimeout(closeTimer.current);
|
|
9
14
|
startTimer.current = setTimeout(() => startFn(...args), delayTime);
|
|
10
15
|
};
|
|
11
16
|
|
|
12
|
-
const cleanFunction = (
|
|
17
|
+
const cleanFunction = function () {
|
|
18
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
19
|
+
args[_key2] = arguments[_key2];
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
clearTimeout(startTimer.current);
|
|
14
23
|
closeTimer.current = setTimeout(() => cleanFn(...args), 30);
|
|
15
24
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
1
3
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
2
8
|
import { useMemo } from 'react';
|
|
3
|
-
import
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
|
+
import { isFunction } from 'lodash';
|
|
4
12
|
import useDerivedStateFromProp from './useDerivedStateFromProps.js';
|
|
5
13
|
|
|
6
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -21,20 +29,22 @@ const toggleStateInObject = (obj, key, value) => {
|
|
|
21
29
|
|
|
22
30
|
const noop = () => null;
|
|
23
31
|
|
|
24
|
-
function useExpandState({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
function useExpandState(_ref) {
|
|
33
|
+
let {
|
|
34
|
+
items = [],
|
|
35
|
+
itemKey = 'id',
|
|
36
|
+
expanded: expandedProp = {},
|
|
37
|
+
onExpand,
|
|
38
|
+
onExpandChange = noop,
|
|
39
|
+
onExpandAll = noop,
|
|
40
|
+
onToggleExpand,
|
|
41
|
+
onCollapse
|
|
42
|
+
} = _ref;
|
|
34
43
|
const [expanded, setExpanded] = useDerivedStateFromProp(expandedProp);
|
|
35
44
|
const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
|
|
36
45
|
|
|
37
|
-
const toggleExpandAll = (
|
|
46
|
+
const toggleExpandAll = function () {
|
|
47
|
+
let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
38
48
|
setExpanded(() => {
|
|
39
49
|
const nextState = {};
|
|
40
50
|
|
|
@@ -50,7 +60,8 @@ function useExpandState({
|
|
|
50
60
|
});
|
|
51
61
|
};
|
|
52
62
|
|
|
53
|
-
const expand = (item
|
|
63
|
+
const expand = function (item) {
|
|
64
|
+
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
54
65
|
if (!item) return;
|
|
55
66
|
|
|
56
67
|
if (isFunction(onExpand)) {
|
|
@@ -69,7 +80,9 @@ function useExpandState({
|
|
|
69
80
|
});
|
|
70
81
|
};
|
|
71
82
|
|
|
72
|
-
const toggleExpand = (item
|
|
83
|
+
const toggleExpand = function (item) {
|
|
84
|
+
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
85
|
+
|
|
73
86
|
if (isFunction(onToggleExpand)) {
|
|
74
87
|
onToggleExpand(item);
|
|
75
88
|
}
|