@baleada/logic 0.20.33 → 0.21.1
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/lib/index.cjs +41 -325
- package/lib/index.d.ts +152 -313
- package/lib/index.js +42 -326
- package/package.json +5 -6
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reduce, pipe, filter, toArray,
|
|
1
|
+
import { reduce, pipe, filter, toArray, slice, concat, unique, map, find, findIndex, some, join, every } from 'lazy-collections';
|
|
2
2
|
import slugify from '@sindresorhus/slugify';
|
|
3
3
|
import BezierEasing from 'bezier-easing';
|
|
4
4
|
import { mix } from '@snigo.dev/color';
|
|
@@ -39,34 +39,30 @@ function createFilterAsync(condition) {
|
|
|
39
39
|
return createFilter((_, index) => transformedAsync[index])(array);
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
function createDelete(
|
|
42
|
+
function createDelete(index) {
|
|
43
43
|
return (array) => {
|
|
44
|
-
|
|
45
|
-
return createConcat(createSlice({ from: 0, to: deleteIndex })(array), createSlice({ from: deleteIndex + 1 })(array))([]);
|
|
44
|
+
return createConcat(createSlice(0, index)(array), createSlice(index + 1)(array))([]);
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
|
-
function createInsert(
|
|
47
|
+
function createInsert(item, index) {
|
|
49
48
|
return (array) => {
|
|
50
|
-
const
|
|
51
|
-
return createReorder({
|
|
52
|
-
from: { start: array.length, itemCount: itemsToInsert.length },
|
|
53
|
-
to: required.index
|
|
54
|
-
})(withItems);
|
|
49
|
+
const withItems = createConcat(array, [item])([]);
|
|
50
|
+
return createReorder({ start: array.length, itemCount: 1 }, index)(withItems);
|
|
55
51
|
};
|
|
56
52
|
}
|
|
57
|
-
function createReorder(
|
|
53
|
+
function createReorder(from, to) {
|
|
58
54
|
return (array) => {
|
|
59
55
|
const [itemsToMoveStartIndex, itemsToMoveCount] = isObject(from) ? [from.start, from.itemCount] : [from, 1], insertIndex = to;
|
|
60
56
|
if (insertIndex > itemsToMoveStartIndex && insertIndex < itemsToMoveStartIndex + itemsToMoveCount) {
|
|
61
57
|
return array;
|
|
62
58
|
}
|
|
63
|
-
const itemsToMove = createSlice(
|
|
59
|
+
const itemsToMove = createSlice(itemsToMoveStartIndex, itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
64
60
|
if (itemsToMoveStartIndex < insertIndex) {
|
|
65
|
-
const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(
|
|
61
|
+
const beforeItemsToMove = itemsToMoveStartIndex === 0 ? [] : createSlice(0, itemsToMoveStartIndex)(array), betweenItemsToMoveAndInsertIndex = createSlice(itemsToMoveStartIndex + itemsToMoveCount, insertIndex + 1)(array), afterInsertIndex = createSlice(insertIndex + 1)(array);
|
|
66
62
|
return createConcat(beforeItemsToMove, betweenItemsToMoveAndInsertIndex, itemsToMove, afterInsertIndex)([]);
|
|
67
63
|
}
|
|
68
64
|
if (itemsToMoveStartIndex > insertIndex) {
|
|
69
|
-
const beforeInsertion = insertIndex === 0 ? [] : createSlice(
|
|
65
|
+
const beforeInsertion = insertIndex === 0 ? [] : createSlice(0, insertIndex)(array), betweenInsertionAndItemsToMove = createSlice(insertIndex, itemsToMoveStartIndex)(array), afterItemsToMove = createSlice(itemsToMoveStartIndex + itemsToMoveCount)(array);
|
|
70
66
|
return createConcat(beforeInsertion, itemsToMove, betweenInsertionAndItemsToMove, afterItemsToMove)([]);
|
|
71
67
|
}
|
|
72
68
|
return array;
|
|
@@ -75,19 +71,19 @@ function createReorder({ from, to }) {
|
|
|
75
71
|
function isObject(value) {
|
|
76
72
|
return typeof value === "object";
|
|
77
73
|
}
|
|
78
|
-
function createSwap(
|
|
74
|
+
function createSwap(indices) {
|
|
79
75
|
return (array) => {
|
|
80
76
|
const { 0: from, 1: to } = indices, { reorderFrom, reorderTo } = (() => {
|
|
81
77
|
if (from < to) {
|
|
82
78
|
return {
|
|
83
|
-
reorderFrom: createReorder(
|
|
84
|
-
reorderTo: createReorder(
|
|
79
|
+
reorderFrom: createReorder(from, to),
|
|
80
|
+
reorderTo: createReorder(to - 1, from)
|
|
85
81
|
};
|
|
86
82
|
}
|
|
87
83
|
if (from > to) {
|
|
88
84
|
return {
|
|
89
|
-
reorderFrom: createReorder(
|
|
90
|
-
reorderTo: createReorder(
|
|
85
|
+
reorderFrom: createReorder(from, to),
|
|
86
|
+
reorderTo: createReorder(to + 1, from)
|
|
91
87
|
};
|
|
92
88
|
}
|
|
93
89
|
return {
|
|
@@ -98,15 +94,15 @@ function createSwap({ indices }) {
|
|
|
98
94
|
return new Pipeable(array).pipe(reorderFrom, reorderTo);
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
|
-
function createReplace(
|
|
97
|
+
function createReplace(index, item) {
|
|
102
98
|
return (array) => {
|
|
103
|
-
return createConcat(createSlice(
|
|
99
|
+
return createConcat(createSlice(0, index)(array), [item], createSlice(index + 1)(array))([]);
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
102
|
function createUnique() {
|
|
107
103
|
return (array) => pipe(unique(), toArray())(array);
|
|
108
104
|
}
|
|
109
|
-
function createSlice(
|
|
105
|
+
function createSlice(from, to) {
|
|
110
106
|
return (array) => {
|
|
111
107
|
return from === to ? [] : pipe(slice(from, to - 1), toArray())(array);
|
|
112
108
|
};
|
|
@@ -129,6 +125,11 @@ function createReverse() {
|
|
|
129
125
|
return reversed;
|
|
130
126
|
};
|
|
131
127
|
}
|
|
128
|
+
function createSort(compare) {
|
|
129
|
+
return (array) => {
|
|
130
|
+
return new Pipeable(array).pipe(createSlice(0), (sliced) => sliced.sort(compare));
|
|
131
|
+
};
|
|
132
|
+
}
|
|
132
133
|
function createSlug(options) {
|
|
133
134
|
return (string) => {
|
|
134
135
|
return slugify(string, options);
|
|
@@ -139,7 +140,7 @@ function createClip(required) {
|
|
|
139
140
|
return string.replace(required, "");
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
|
-
function createClamp(
|
|
143
|
+
function createClamp(min, max) {
|
|
143
144
|
return (number) => {
|
|
144
145
|
const maxed = Math.max(number, min);
|
|
145
146
|
return Math.min(maxed, max);
|
|
@@ -155,9 +156,9 @@ function createDetermine(potentialities) {
|
|
|
155
156
|
})(potentialities);
|
|
156
157
|
return (determinant) => find(({ predicate }) => predicate(determinant))(predicates).outcome;
|
|
157
158
|
}
|
|
158
|
-
function createRename(
|
|
159
|
+
function createRename(from, to) {
|
|
159
160
|
return (map2) => {
|
|
160
|
-
const keys = [...map2.keys()], keyToRenameIndex = findIndex((k) => k === from)(keys), newKeys = createReplace(
|
|
161
|
+
const keys = [...map2.keys()], keyToRenameIndex = findIndex((k) => k === from)(keys), newKeys = createReplace(keyToRenameIndex, to)(keys), values = [...map2.values()];
|
|
161
162
|
return createReduce((renamed, key, index) => renamed.set(key, values[index]), /* @__PURE__ */ new Map())(newKeys);
|
|
162
163
|
};
|
|
163
164
|
}
|
|
@@ -182,239 +183,6 @@ class Pipeable {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
function toEvent(eventType, options) {
|
|
186
|
-
const implementation = toImplementation(eventType);
|
|
187
|
-
switch (implementation) {
|
|
188
|
-
case "keycombo": {
|
|
189
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
190
|
-
return new KeyboardEvent("keyDirection" in options ? `key${options.keyDirection}` : "keydown", {
|
|
191
|
-
...options.init || {},
|
|
192
|
-
key: toKey(name),
|
|
193
|
-
...createReduce((flags, alias) => {
|
|
194
|
-
flags[toModifierFlag(alias)] = true;
|
|
195
|
-
return flags;
|
|
196
|
-
}, {})(modifiers)
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
case "leftclickcombo":
|
|
200
|
-
case "rightclickcombo": {
|
|
201
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
202
|
-
return new MouseEvent(name === "rightclick" ? "contextmenu" : name, {
|
|
203
|
-
...options.init || {},
|
|
204
|
-
...createReduce((flags, alias) => {
|
|
205
|
-
flags[toModifierFlag(alias)] = true;
|
|
206
|
-
return flags;
|
|
207
|
-
}, {})(modifiers)
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
case "pointercombo": {
|
|
211
|
-
const combo = toCombo(eventType), modifiers = createSlice({ from: 0, to: combo.length - 1 })(combo), { 0: name } = createSlice({ from: combo.length - 1 })(combo);
|
|
212
|
-
return new PointerEvent(name === "rightclick" ? "contextmenu" : name, {
|
|
213
|
-
...options.init || {},
|
|
214
|
-
...createReduce((flags, alias) => {
|
|
215
|
-
flags[toModifierFlag(alias)] = true;
|
|
216
|
-
return flags;
|
|
217
|
-
}, {})(modifiers)
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
case "documentevent":
|
|
221
|
-
case "event":
|
|
222
|
-
if (eventType === "abort")
|
|
223
|
-
return new UIEvent(eventType, options.init);
|
|
224
|
-
if (eventType === "animationcancel")
|
|
225
|
-
return new AnimationEvent(eventType, options.init);
|
|
226
|
-
if (eventType === "animationend")
|
|
227
|
-
return new AnimationEvent(eventType, options.init);
|
|
228
|
-
if (eventType === "animationiteration")
|
|
229
|
-
return new AnimationEvent(eventType, options.init);
|
|
230
|
-
if (eventType === "animationstart")
|
|
231
|
-
return new AnimationEvent(eventType, options.init);
|
|
232
|
-
if (eventType === "auxclick")
|
|
233
|
-
return new MouseEvent(eventType, options.init);
|
|
234
|
-
if (eventType === "beforeinput")
|
|
235
|
-
return new InputEvent(eventType, options.init);
|
|
236
|
-
if (eventType === "blur")
|
|
237
|
-
return new FocusEvent(eventType, options.init);
|
|
238
|
-
if (eventType === "canplay")
|
|
239
|
-
return new Event(eventType, options.init);
|
|
240
|
-
if (eventType === "canplaythrough")
|
|
241
|
-
return new Event(eventType, options.init);
|
|
242
|
-
if (eventType === "change")
|
|
243
|
-
return new Event(eventType, options.init);
|
|
244
|
-
if (eventType === "click")
|
|
245
|
-
return new MouseEvent(eventType, options.init);
|
|
246
|
-
if (eventType === "close")
|
|
247
|
-
return new Event(eventType, options.init);
|
|
248
|
-
if (eventType === "compositionend")
|
|
249
|
-
return new CompositionEvent(eventType, options.init);
|
|
250
|
-
if (eventType === "compositionstart")
|
|
251
|
-
return new CompositionEvent(eventType, options.init);
|
|
252
|
-
if (eventType === "compositionupdate")
|
|
253
|
-
return new CompositionEvent(eventType, options.init);
|
|
254
|
-
if (eventType === "contextmenu")
|
|
255
|
-
return new MouseEvent(eventType, options.init);
|
|
256
|
-
if (eventType === "cuechange")
|
|
257
|
-
return new Event(eventType, options.init);
|
|
258
|
-
if (eventType === "dblclick")
|
|
259
|
-
return new MouseEvent(eventType, options.init);
|
|
260
|
-
if (eventType === "drag")
|
|
261
|
-
return new DragEvent(eventType, options.init);
|
|
262
|
-
if (eventType === "dragend")
|
|
263
|
-
return new DragEvent(eventType, options.init);
|
|
264
|
-
if (eventType === "dragenter")
|
|
265
|
-
return new DragEvent(eventType, options.init);
|
|
266
|
-
if (eventType === "dragleave")
|
|
267
|
-
return new DragEvent(eventType, options.init);
|
|
268
|
-
if (eventType === "dragover")
|
|
269
|
-
return new DragEvent(eventType, options.init);
|
|
270
|
-
if (eventType === "dragstart")
|
|
271
|
-
return new DragEvent(eventType, options.init);
|
|
272
|
-
if (eventType === "drop")
|
|
273
|
-
return new DragEvent(eventType, options.init);
|
|
274
|
-
if (eventType === "durationchange")
|
|
275
|
-
return new Event(eventType, options.init);
|
|
276
|
-
if (eventType === "emptied")
|
|
277
|
-
return new Event(eventType, options.init);
|
|
278
|
-
if (eventType === "ended")
|
|
279
|
-
return new Event(eventType, options.init);
|
|
280
|
-
if (eventType === "error")
|
|
281
|
-
return new ErrorEvent(eventType, options.init);
|
|
282
|
-
if (eventType === "focus")
|
|
283
|
-
return new FocusEvent(eventType, options.init);
|
|
284
|
-
if (eventType === "focusin")
|
|
285
|
-
return new FocusEvent(eventType, options.init);
|
|
286
|
-
if (eventType === "focusout")
|
|
287
|
-
return new FocusEvent(eventType, options.init);
|
|
288
|
-
if (eventType === "gotpointercapture")
|
|
289
|
-
return new PointerEvent(eventType, options.init);
|
|
290
|
-
if (eventType === "input")
|
|
291
|
-
return new Event(eventType, options.init);
|
|
292
|
-
if (eventType === "invalid")
|
|
293
|
-
return new Event(eventType, options.init);
|
|
294
|
-
if (eventType === "keydown")
|
|
295
|
-
return new KeyboardEvent(eventType, options.init);
|
|
296
|
-
if (eventType === "keypress")
|
|
297
|
-
return new KeyboardEvent(eventType, options.init);
|
|
298
|
-
if (eventType === "keyup")
|
|
299
|
-
return new KeyboardEvent(eventType, options.init);
|
|
300
|
-
if (eventType === "load")
|
|
301
|
-
return new Event(eventType, options.init);
|
|
302
|
-
if (eventType === "loadeddata")
|
|
303
|
-
return new Event(eventType, options.init);
|
|
304
|
-
if (eventType === "loadedmetadata")
|
|
305
|
-
return new Event(eventType, options.init);
|
|
306
|
-
if (eventType === "loadstart")
|
|
307
|
-
return new Event(eventType, options.init);
|
|
308
|
-
if (eventType === "lostpointercapture")
|
|
309
|
-
return new PointerEvent(eventType, options.init);
|
|
310
|
-
if (eventType === "mousedown")
|
|
311
|
-
return new MouseEvent(eventType, options.init);
|
|
312
|
-
if (eventType === "mouseenter")
|
|
313
|
-
return new MouseEvent(eventType, options.init);
|
|
314
|
-
if (eventType === "mouseleave")
|
|
315
|
-
return new MouseEvent(eventType, options.init);
|
|
316
|
-
if (eventType === "mousemove")
|
|
317
|
-
return new MouseEvent(eventType, options.init);
|
|
318
|
-
if (eventType === "mouseout")
|
|
319
|
-
return new MouseEvent(eventType, options.init);
|
|
320
|
-
if (eventType === "mouseover")
|
|
321
|
-
return new MouseEvent(eventType, options.init);
|
|
322
|
-
if (eventType === "mouseup")
|
|
323
|
-
return new MouseEvent(eventType, options.init);
|
|
324
|
-
if (eventType === "pause")
|
|
325
|
-
return new Event(eventType, options.init);
|
|
326
|
-
if (eventType === "play")
|
|
327
|
-
return new Event(eventType, options.init);
|
|
328
|
-
if (eventType === "playing")
|
|
329
|
-
return new Event(eventType, options.init);
|
|
330
|
-
if (eventType === "pointercancel")
|
|
331
|
-
return new PointerEvent(eventType, options.init);
|
|
332
|
-
if (eventType === "pointerdown")
|
|
333
|
-
return new PointerEvent(eventType, options.init);
|
|
334
|
-
if (eventType === "pointerenter")
|
|
335
|
-
return new PointerEvent(eventType, options.init);
|
|
336
|
-
if (eventType === "pointerleave")
|
|
337
|
-
return new PointerEvent(eventType, options.init);
|
|
338
|
-
if (eventType === "pointermove")
|
|
339
|
-
return new PointerEvent(eventType, options.init);
|
|
340
|
-
if (eventType === "pointerout")
|
|
341
|
-
return new PointerEvent(eventType, options.init);
|
|
342
|
-
if (eventType === "pointerover")
|
|
343
|
-
return new PointerEvent(eventType, options.init);
|
|
344
|
-
if (eventType === "pointerup")
|
|
345
|
-
return new PointerEvent(eventType, options.init);
|
|
346
|
-
if (eventType === "progress")
|
|
347
|
-
return new ProgressEvent(eventType, options.init);
|
|
348
|
-
if (eventType === "ratechange")
|
|
349
|
-
return new Event(eventType, options.init);
|
|
350
|
-
if (eventType === "reset")
|
|
351
|
-
return new Event(eventType, options.init);
|
|
352
|
-
if (eventType === "scroll")
|
|
353
|
-
return new Event(eventType, options.init);
|
|
354
|
-
if (eventType === "securitypolicyviolation")
|
|
355
|
-
return new SecurityPolicyViolationEvent(eventType, options.init);
|
|
356
|
-
if (eventType === "seeked")
|
|
357
|
-
return new Event(eventType, options.init);
|
|
358
|
-
if (eventType === "seeking")
|
|
359
|
-
return new Event(eventType, options.init);
|
|
360
|
-
if (eventType === "select")
|
|
361
|
-
return new Event(eventType, options.init);
|
|
362
|
-
if (eventType === "selectionchange")
|
|
363
|
-
return new Event(eventType, options.init);
|
|
364
|
-
if (eventType === "selectstart")
|
|
365
|
-
return new Event(eventType, options.init);
|
|
366
|
-
if (eventType === "stalled")
|
|
367
|
-
return new Event(eventType, options.init);
|
|
368
|
-
if (eventType === "submit")
|
|
369
|
-
return new Event(eventType, options.init);
|
|
370
|
-
if (eventType === "suspend")
|
|
371
|
-
return new Event(eventType, options.init);
|
|
372
|
-
if (eventType === "timeupdate")
|
|
373
|
-
return new Event(eventType, options.init);
|
|
374
|
-
if (eventType === "toggle")
|
|
375
|
-
return new Event(eventType, options.init);
|
|
376
|
-
if (eventType === "touchcancel")
|
|
377
|
-
return new TouchEvent(eventType, options.init);
|
|
378
|
-
if (eventType === "touchend")
|
|
379
|
-
return new TouchEvent(eventType, options.init);
|
|
380
|
-
if (eventType === "touchmove")
|
|
381
|
-
return new TouchEvent(eventType, options.init);
|
|
382
|
-
if (eventType === "touchstart")
|
|
383
|
-
return new TouchEvent(eventType, options.init);
|
|
384
|
-
if (eventType === "transitioncancel")
|
|
385
|
-
return new TransitionEvent(eventType, options.init);
|
|
386
|
-
if (eventType === "transitionend")
|
|
387
|
-
return new TransitionEvent(eventType, options.init);
|
|
388
|
-
if (eventType === "transitionrun")
|
|
389
|
-
return new TransitionEvent(eventType, options.init);
|
|
390
|
-
if (eventType === "transitionstart")
|
|
391
|
-
return new TransitionEvent(eventType, options.init);
|
|
392
|
-
if (eventType === "volumechange")
|
|
393
|
-
return new Event(eventType, options.init);
|
|
394
|
-
if (eventType === "waiting")
|
|
395
|
-
return new Event(eventType, options.init);
|
|
396
|
-
if (eventType === "wheel")
|
|
397
|
-
return new WheelEvent(eventType, options.init);
|
|
398
|
-
if (eventType === "copy")
|
|
399
|
-
return new ClipboardEvent(eventType, options.init);
|
|
400
|
-
if (eventType === "cut")
|
|
401
|
-
return new ClipboardEvent(eventType, options.init);
|
|
402
|
-
if (eventType === "paste")
|
|
403
|
-
return new ClipboardEvent(eventType, options.init);
|
|
404
|
-
if (eventType === "fullscreenchange")
|
|
405
|
-
return new Event(eventType, options.init);
|
|
406
|
-
if (eventType === "fullscreenerror")
|
|
407
|
-
return new Event(eventType, options.init);
|
|
408
|
-
if (eventType === "pointerlockchange")
|
|
409
|
-
return new Event(eventType, options.init);
|
|
410
|
-
if (eventType === "pointerlockerror")
|
|
411
|
-
return new Event(eventType, options.init);
|
|
412
|
-
if (eventType === "readystatechange")
|
|
413
|
-
return new Event(eventType, options.init);
|
|
414
|
-
if (eventType === "visibilitychange")
|
|
415
|
-
return new Event(eventType, options.init);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
186
|
function toKey(name) {
|
|
419
187
|
return name in keysByName ? keysByName[name] : name;
|
|
420
188
|
}
|
|
@@ -512,20 +280,6 @@ const modifiersByAlias = {
|
|
|
512
280
|
opt: "alt",
|
|
513
281
|
option: "alt"
|
|
514
282
|
};
|
|
515
|
-
function toModifierFlag(modifierOrAlias) {
|
|
516
|
-
return flagsByModifierOrAlias[modifierOrAlias];
|
|
517
|
-
}
|
|
518
|
-
const flagsByModifierOrAlias = {
|
|
519
|
-
shift: "shiftKey",
|
|
520
|
-
cmd: "metaKey",
|
|
521
|
-
command: "metaKey",
|
|
522
|
-
meta: "metaKey",
|
|
523
|
-
ctrl: "ctrlKey",
|
|
524
|
-
control: "ctrlKey",
|
|
525
|
-
alt: "altKey",
|
|
526
|
-
opt: "altKey",
|
|
527
|
-
option: "altKey"
|
|
528
|
-
};
|
|
529
283
|
function createExceptAndOnlyEffect(effect, options) {
|
|
530
284
|
const { except = [], only = [] } = options;
|
|
531
285
|
return (event) => {
|
|
@@ -641,7 +395,7 @@ class Recognizeable {
|
|
|
641
395
|
}
|
|
642
396
|
recognize(sequenceItem, { onRecognized } = {}) {
|
|
643
397
|
this.recognizing();
|
|
644
|
-
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(
|
|
398
|
+
const type = this.toType(sequenceItem), excess = isNumber(this.maxSequenceLength) ? Math.max(0, this.sequence.length - this.maxSequenceLength) : 0, newSequence = createConcat(createSlice(excess)(this.sequence), [sequenceItem])([]);
|
|
645
399
|
this.effectApi.sequenceItem = sequenceItem;
|
|
646
400
|
this.effectApi.getSequence = () => newSequence;
|
|
647
401
|
this.effectApi.onRecognized = onRecognized || (() => {
|
|
@@ -1846,7 +1600,7 @@ function toInterpolated({ previous, next, progress }, options = {}) {
|
|
|
1846
1600
|
}
|
|
1847
1601
|
if (isArray(previous) && isArray(next)) {
|
|
1848
1602
|
const exactSliceEnd = (next.length - previous.length) * progress + previous.length, nextIsLonger = next.length > previous.length, sliceEnd = nextIsLonger ? Math.floor(exactSliceEnd) : Math.ceil(exactSliceEnd), sliceTarget = nextIsLonger ? next : previous;
|
|
1849
|
-
return createSlice(
|
|
1603
|
+
return createSlice(0, sliceEnd)(sliceTarget);
|
|
1850
1604
|
}
|
|
1851
1605
|
}
|
|
1852
1606
|
const linear = [
|
|
@@ -2246,10 +2000,10 @@ class Copyable {
|
|
|
2246
2000
|
}
|
|
2247
2001
|
computedResponse;
|
|
2248
2002
|
computedError;
|
|
2249
|
-
async copy(options = {
|
|
2003
|
+
async copy(options = { kind: "clipboard" }) {
|
|
2250
2004
|
this.copying();
|
|
2251
|
-
const {
|
|
2252
|
-
switch (
|
|
2005
|
+
const { kind } = options;
|
|
2006
|
+
switch (kind) {
|
|
2253
2007
|
case "clipboard":
|
|
2254
2008
|
try {
|
|
2255
2009
|
this.computedResponse = await navigator.clipboard.writeText(this.string);
|
|
@@ -2437,44 +2191,6 @@ class Delayable {
|
|
|
2437
2191
|
}
|
|
2438
2192
|
}
|
|
2439
2193
|
|
|
2440
|
-
class Dispatchable {
|
|
2441
|
-
constructor(type, options = {}) {
|
|
2442
|
-
this.setType(type);
|
|
2443
|
-
this.ready();
|
|
2444
|
-
}
|
|
2445
|
-
computedStatus;
|
|
2446
|
-
ready() {
|
|
2447
|
-
this.computedStatus = "ready";
|
|
2448
|
-
}
|
|
2449
|
-
get type() {
|
|
2450
|
-
return this.computedType;
|
|
2451
|
-
}
|
|
2452
|
-
set type(type) {
|
|
2453
|
-
this.setType(type);
|
|
2454
|
-
}
|
|
2455
|
-
get cancelled() {
|
|
2456
|
-
return this.computedCancelled;
|
|
2457
|
-
}
|
|
2458
|
-
get status() {
|
|
2459
|
-
return this.computedStatus;
|
|
2460
|
-
}
|
|
2461
|
-
computedType;
|
|
2462
|
-
setType(type) {
|
|
2463
|
-
this.computedType = type;
|
|
2464
|
-
return this;
|
|
2465
|
-
}
|
|
2466
|
-
computedCancelled;
|
|
2467
|
-
dispatch(options = {}) {
|
|
2468
|
-
const { target = window, ...rest } = options, event = toEvent(this.type, rest);
|
|
2469
|
-
this.computedCancelled = !target.dispatchEvent(event);
|
|
2470
|
-
this.dispatched();
|
|
2471
|
-
return this;
|
|
2472
|
-
}
|
|
2473
|
-
dispatched() {
|
|
2474
|
-
this.computedStatus = "dispatched";
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2478
2194
|
const defaultOptions$3 = {
|
|
2479
2195
|
toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
|
|
2480
2196
|
};
|
|
@@ -3052,9 +2768,9 @@ class Pickable {
|
|
|
3052
2768
|
return possibleWithoutDuplicates;
|
|
3053
2769
|
}
|
|
3054
2770
|
if (possibleWithoutDuplicates.length > this.picks.length) {
|
|
3055
|
-
return createSlice(
|
|
2771
|
+
return createSlice(possibleWithoutDuplicates.length - this.picks.length)(possibleWithoutDuplicates);
|
|
3056
2772
|
}
|
|
3057
|
-
return new Pipeable(this.picks).pipe(createSlice(
|
|
2773
|
+
return new Pipeable(this.picks).pipe(createSlice(possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
|
|
3058
2774
|
case "lifo":
|
|
3059
2775
|
if (possibleWithoutDuplicates.length === 0) {
|
|
3060
2776
|
return this.picks;
|
|
@@ -3063,9 +2779,9 @@ class Pickable {
|
|
|
3063
2779
|
return possibleWithoutDuplicates;
|
|
3064
2780
|
}
|
|
3065
2781
|
if (possibleWithoutDuplicates.length > this.picks.length) {
|
|
3066
|
-
return createSlice(
|
|
2782
|
+
return createSlice(0, possibleWithoutDuplicates.length - this.picks.length + 1)(possibleWithoutDuplicates);
|
|
3067
2783
|
}
|
|
3068
|
-
return new Pipeable(this.picks).pipe(createSlice(
|
|
2784
|
+
return new Pipeable(this.picks).pipe(createSlice(0, this.picks.length - possibleWithoutDuplicates.length), createConcat(possibleWithoutDuplicates));
|
|
3069
2785
|
}
|
|
3070
2786
|
});
|
|
3071
2787
|
this.computedFirst = Math.min(...this.picks);
|
|
@@ -3076,7 +2792,7 @@ class Pickable {
|
|
|
3076
2792
|
picked() {
|
|
3077
2793
|
this.computedStatus = "picked";
|
|
3078
2794
|
}
|
|
3079
|
-
omit(indexOrIndices) {
|
|
2795
|
+
omit(indexOrIndices, options = { reference: "array" }) {
|
|
3080
2796
|
if (isUndefined(indexOrIndices)) {
|
|
3081
2797
|
this.computedPicks = [];
|
|
3082
2798
|
this.computedFirst = void 0;
|
|
@@ -3085,7 +2801,7 @@ class Pickable {
|
|
|
3085
2801
|
return this;
|
|
3086
2802
|
}
|
|
3087
2803
|
const omits = ensureIndices(indexOrIndices);
|
|
3088
|
-
this.computedPicks = createFilter((pick) => isUndefined(find((omit) => pick === omit)(omits)))(this.computedPicks);
|
|
2804
|
+
this.computedPicks = createFilter((pick, index) => options.reference === "array" ? isUndefined(find((omit) => pick === omit)(omits)) : isUndefined(find((omit) => index === omit)(omits)))(this.computedPicks);
|
|
3089
2805
|
this.computedFirst = Math.min(...this.picks);
|
|
3090
2806
|
this.computedLast = Math.max(...this.picks);
|
|
3091
2807
|
this.omitted();
|
|
@@ -3193,15 +2909,15 @@ class Searchable {
|
|
|
3193
2909
|
}
|
|
3194
2910
|
|
|
3195
2911
|
const defaultOptions = {
|
|
3196
|
-
|
|
2912
|
+
kind: "local",
|
|
3197
2913
|
statusKeySuffix: " status"
|
|
3198
2914
|
};
|
|
3199
2915
|
class Storeable {
|
|
3200
|
-
|
|
2916
|
+
kind;
|
|
3201
2917
|
statusKeySuffix;
|
|
3202
2918
|
constructor(key, options = {}) {
|
|
3203
2919
|
this.constructing();
|
|
3204
|
-
this.
|
|
2920
|
+
this.kind = options.kind ?? defaultOptions.kind;
|
|
3205
2921
|
this.statusKeySuffix = options.statusKeySuffix ?? defaultOptions.statusKeySuffix;
|
|
3206
2922
|
this.setKey(key);
|
|
3207
2923
|
this.ready();
|
|
@@ -3234,7 +2950,7 @@ class Storeable {
|
|
|
3234
2950
|
return this.computedStatus;
|
|
3235
2951
|
}
|
|
3236
2952
|
get storage() {
|
|
3237
|
-
switch (this.
|
|
2953
|
+
switch (this.kind) {
|
|
3238
2954
|
case "local":
|
|
3239
2955
|
return localStorage;
|
|
3240
2956
|
case "session":
|
|
@@ -3313,4 +3029,4 @@ class Storeable {
|
|
|
3313
3029
|
}
|
|
3314
3030
|
}
|
|
3315
3031
|
|
|
3316
|
-
export { Animateable, Completeable, Copyable, Delayable,
|
|
3032
|
+
export { Animateable, Completeable, Copyable, Delayable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pickable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSort, createSwap, createToEntries, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, ensureKeycombo, eventMatchesKeycombo, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baleada/logic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "UI logic for the Baleada toolkit",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -43,17 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://baleada.netlify.com",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@baleada/animateable-utils": "^0.0.2",
|
|
47
46
|
"@baleada/prepare": "^0.5.20",
|
|
48
47
|
"@types/node": "^14.14.41",
|
|
49
48
|
"@vue/compiler-sfc": "^3.2.9",
|
|
50
49
|
"esbuild": "^0.9.7",
|
|
51
50
|
"esbuild-register": "^2.6.0",
|
|
52
|
-
"rollup": "^2.
|
|
51
|
+
"rollup": "^2.70.1",
|
|
53
52
|
"tailwindcss": "^2.1.1",
|
|
54
|
-
"typescript": "^4.
|
|
53
|
+
"typescript": "^4.6.2",
|
|
55
54
|
"uvu": "^0.5.1",
|
|
56
|
-
"vite": "^2.
|
|
55
|
+
"vite": "^2.8.6",
|
|
57
56
|
"vue": "^3.2.12",
|
|
58
57
|
"vue-router": "^4.0.3"
|
|
59
58
|
},
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
"@snigo.dev/color": "^0.0.6",
|
|
64
63
|
"@types/dompurify": "^2.2.3",
|
|
65
64
|
"@types/requestidlecallback": "^0.3.1",
|
|
66
|
-
"@types/resize-observer-browser": "^0.1.
|
|
65
|
+
"@types/resize-observer-browser": "^0.1.7",
|
|
67
66
|
"bezier-easing": "^2.1.0",
|
|
68
67
|
"dompurify": "^2.2.6",
|
|
69
68
|
"fast-fuzzy": "^1.11.1",
|