@baleada/logic 0.20.26 → 0.20.30
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 +25 -9
- package/lib/index.d.ts +13 -10
- package/lib/index.js +25 -10
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -172,6 +172,15 @@ function createRename({ from, to }) {
|
|
|
172
172
|
return createReduce((renamed, key, index) => renamed.set(key, values[index]), new Map())(newKeys);
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
+
function createToEntries() {
|
|
176
|
+
return (object) => {
|
|
177
|
+
const entries = [];
|
|
178
|
+
for (const key in object) {
|
|
179
|
+
entries.push([key, object[key]]);
|
|
180
|
+
}
|
|
181
|
+
return entries;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
175
184
|
class Pipeable {
|
|
176
185
|
constructor(state) {
|
|
177
186
|
this.state = state;
|
|
@@ -2719,6 +2728,7 @@ class Grantable {
|
|
|
2719
2728
|
const defaultOptions$2 = {
|
|
2720
2729
|
initialLocation: 0
|
|
2721
2730
|
};
|
|
2731
|
+
const defaultNavigateOptions = { allow: "possible" };
|
|
2722
2732
|
const defaultNextAndPreviousOptions = {
|
|
2723
2733
|
distance: 1,
|
|
2724
2734
|
loops: true
|
|
@@ -2758,28 +2768,33 @@ class Navigateable {
|
|
|
2758
2768
|
this.navigate(location);
|
|
2759
2769
|
return this;
|
|
2760
2770
|
}
|
|
2761
|
-
navigate(location) {
|
|
2762
|
-
|
|
2771
|
+
navigate(location, options = {}) {
|
|
2772
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2773
|
+
this._navigate(location, { allow });
|
|
2763
2774
|
this.navigated();
|
|
2764
2775
|
return this;
|
|
2765
2776
|
}
|
|
2766
2777
|
navigated() {
|
|
2767
2778
|
this.computedStatus = "navigated";
|
|
2768
2779
|
}
|
|
2769
|
-
_navigate(location) {
|
|
2780
|
+
_navigate(location, options = {}) {
|
|
2781
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2770
2782
|
const ensuredLocation = (() => {
|
|
2771
|
-
if (
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2783
|
+
if (allow === "possible") {
|
|
2784
|
+
if (location < 0 && allow === "possible") {
|
|
2785
|
+
return 0;
|
|
2786
|
+
}
|
|
2787
|
+
if (location > this.array.length - 1) {
|
|
2788
|
+
return Math.max(this.array.length - 1, 0);
|
|
2789
|
+
}
|
|
2776
2790
|
}
|
|
2777
2791
|
return location;
|
|
2778
2792
|
})();
|
|
2779
2793
|
this.computedLocation = ensuredLocation;
|
|
2780
2794
|
}
|
|
2781
2795
|
next(options = {}) {
|
|
2782
|
-
const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options },
|
|
2796
|
+
const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
|
|
2797
|
+
const lastLocation = this.array.length - 1;
|
|
2783
2798
|
if (this.location + distance <= lastLocation) {
|
|
2784
2799
|
return this.location + distance;
|
|
2785
2800
|
}
|
|
@@ -3206,6 +3221,7 @@ exports.createReverse = createReverse;
|
|
|
3206
3221
|
exports.createSlice = createSlice;
|
|
3207
3222
|
exports.createSlug = createSlug;
|
|
3208
3223
|
exports.createSwap = createSwap;
|
|
3224
|
+
exports.createToEntries = createToEntries;
|
|
3209
3225
|
exports.createUnique = createUnique;
|
|
3210
3226
|
exports.easingsNetInBack = easingsNetInBack;
|
|
3211
3227
|
exports.easingsNetInCirc = easingsNetInCirc;
|
package/lib/index.d.ts
CHANGED
|
@@ -704,6 +704,13 @@ declare type NavigateableOptions = {
|
|
|
704
704
|
initialLocation?: number;
|
|
705
705
|
};
|
|
706
706
|
declare type NavigateableStatus = 'ready' | 'navigated' | 'navigated to next' | 'navigated to previous' | 'navigated to random' | 'navigated to first' | 'navigated to last';
|
|
707
|
+
declare type NavigateOptions = {
|
|
708
|
+
allow?: 'possible' | 'any';
|
|
709
|
+
};
|
|
710
|
+
declare type NextAndPreviousOptions = {
|
|
711
|
+
distance?: number;
|
|
712
|
+
loops?: boolean;
|
|
713
|
+
};
|
|
707
714
|
declare class Navigateable<Item> {
|
|
708
715
|
constructor(array: Item[], options?: NavigateableOptions);
|
|
709
716
|
private computedStatus;
|
|
@@ -718,18 +725,12 @@ declare class Navigateable<Item> {
|
|
|
718
725
|
get item(): Item;
|
|
719
726
|
setArray(array: Item[]): this;
|
|
720
727
|
setLocation(location: number): this;
|
|
721
|
-
navigate(location: number): this;
|
|
728
|
+
navigate(location: number, options?: NavigateOptions): this;
|
|
722
729
|
private navigated;
|
|
723
730
|
private _navigate;
|
|
724
|
-
next(options?:
|
|
725
|
-
distance?: number;
|
|
726
|
-
loops?: boolean;
|
|
727
|
-
}): this;
|
|
731
|
+
next(options?: NextAndPreviousOptions): this;
|
|
728
732
|
private nexted;
|
|
729
|
-
previous(options?:
|
|
730
|
-
distance?: number;
|
|
731
|
-
loops?: boolean;
|
|
732
|
-
}): this;
|
|
733
|
+
previous(options?: NextAndPreviousOptions): this;
|
|
733
734
|
private previoused;
|
|
734
735
|
random(): this;
|
|
735
736
|
private randomed;
|
|
@@ -904,6 +905,8 @@ declare function createRename<Key, Value>({ from, to }: {
|
|
|
904
905
|
from: Key;
|
|
905
906
|
to: Key;
|
|
906
907
|
}): MapFunction<Key, Value, Map<Key, Value>>;
|
|
908
|
+
declare type ObjectFunction<Key extends string | number | symbol, Value, Returned> = (transform: Record<Key, Value>) => Returned;
|
|
909
|
+
declare function createToEntries<Key extends string | number | symbol, Value>(): ObjectFunction<Key, Value, [Key, Value][]>;
|
|
907
910
|
declare class Pipeable {
|
|
908
911
|
private state;
|
|
909
912
|
constructor(state: any);
|
|
@@ -911,4 +914,4 @@ declare class Pipeable {
|
|
|
911
914
|
pipeAsync(...fns: ((...args: any[]) => Promise<any>)[]): Promise<any>;
|
|
912
915
|
}
|
|
913
916
|
|
|
914
|
-
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, DispatchOptions, Dispatchable, DispatchableOptions, DispatchableStatus, Drawable, DrawableOptions, DrawableState, DrawableStatus, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableClickcombo, ListenableKeycombo, ListenableKeycomboItem, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MapFunction, Navigateable, NavigateableOptions, NavigateableStatus, NumberFunction, Pickable, PickableOptions, PickableStatus, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffectApi, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSwap, 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 };
|
|
917
|
+
export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, DispatchOptions, Dispatchable, DispatchableOptions, DispatchableStatus, Drawable, DrawableOptions, DrawableState, DrawableStatus, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableClickcombo, ListenableKeycombo, ListenableKeycomboItem, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MapFunction, Navigateable, NavigateableOptions, NavigateableStatus, NumberFunction, ObjectFunction, Pickable, PickableOptions, PickableStatus, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffectApi, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDelete, createDetermine, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, 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/lib/index.js
CHANGED
|
@@ -161,6 +161,15 @@ function createRename({ from, to }) {
|
|
|
161
161
|
return createReduce((renamed, key, index) => renamed.set(key, values[index]), new Map())(newKeys);
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
+
function createToEntries() {
|
|
165
|
+
return (object) => {
|
|
166
|
+
const entries = [];
|
|
167
|
+
for (const key in object) {
|
|
168
|
+
entries.push([key, object[key]]);
|
|
169
|
+
}
|
|
170
|
+
return entries;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
164
173
|
class Pipeable {
|
|
165
174
|
constructor(state) {
|
|
166
175
|
this.state = state;
|
|
@@ -2708,6 +2717,7 @@ class Grantable {
|
|
|
2708
2717
|
const defaultOptions$2 = {
|
|
2709
2718
|
initialLocation: 0
|
|
2710
2719
|
};
|
|
2720
|
+
const defaultNavigateOptions = { allow: "possible" };
|
|
2711
2721
|
const defaultNextAndPreviousOptions = {
|
|
2712
2722
|
distance: 1,
|
|
2713
2723
|
loops: true
|
|
@@ -2747,28 +2757,33 @@ class Navigateable {
|
|
|
2747
2757
|
this.navigate(location);
|
|
2748
2758
|
return this;
|
|
2749
2759
|
}
|
|
2750
|
-
navigate(location) {
|
|
2751
|
-
|
|
2760
|
+
navigate(location, options = {}) {
|
|
2761
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2762
|
+
this._navigate(location, { allow });
|
|
2752
2763
|
this.navigated();
|
|
2753
2764
|
return this;
|
|
2754
2765
|
}
|
|
2755
2766
|
navigated() {
|
|
2756
2767
|
this.computedStatus = "navigated";
|
|
2757
2768
|
}
|
|
2758
|
-
_navigate(location) {
|
|
2769
|
+
_navigate(location, options = {}) {
|
|
2770
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2759
2771
|
const ensuredLocation = (() => {
|
|
2760
|
-
if (
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2772
|
+
if (allow === "possible") {
|
|
2773
|
+
if (location < 0 && allow === "possible") {
|
|
2774
|
+
return 0;
|
|
2775
|
+
}
|
|
2776
|
+
if (location > this.array.length - 1) {
|
|
2777
|
+
return Math.max(this.array.length - 1, 0);
|
|
2778
|
+
}
|
|
2765
2779
|
}
|
|
2766
2780
|
return location;
|
|
2767
2781
|
})();
|
|
2768
2782
|
this.computedLocation = ensuredLocation;
|
|
2769
2783
|
}
|
|
2770
2784
|
next(options = {}) {
|
|
2771
|
-
const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options },
|
|
2785
|
+
const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
|
|
2786
|
+
const lastLocation = this.array.length - 1;
|
|
2772
2787
|
if (this.location + distance <= lastLocation) {
|
|
2773
2788
|
return this.location + distance;
|
|
2774
2789
|
}
|
|
@@ -3157,4 +3172,4 @@ class Storeable {
|
|
|
3157
3172
|
}
|
|
3158
3173
|
}
|
|
3159
3174
|
|
|
3160
|
-
export { Animateable, Completeable, Copyable, Delayable, Dispatchable, 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, createSwap, 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 };
|
|
3175
|
+
export { Animateable, Completeable, Copyable, Delayable, Dispatchable, 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, 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.20.
|
|
3
|
+
"version": "0.20.30",
|
|
4
4
|
"description": "UI logic for the Baleada toolkit",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@types/resize-observer-browser": "^0.1.5",
|
|
67
67
|
"bezier-easing": "^2.1.0",
|
|
68
68
|
"dompurify": "^2.2.6",
|
|
69
|
-
"fast-fuzzy": "^1.11.
|
|
69
|
+
"fast-fuzzy": "^1.11.1",
|
|
70
70
|
"lazy-collections": "^0.8.0",
|
|
71
71
|
"perfect-freehand": "^1.0.4",
|
|
72
72
|
"polygon-clipping": "^0.15.3"
|