@baleada/logic 0.20.12 → 0.20.16

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 CHANGED
@@ -156,6 +156,16 @@ function createClamp({ min, max }) {
156
156
  return Math.min(maxed, max);
157
157
  };
158
158
  }
159
+ function createDetermine(potentialities) {
160
+ const predicates = createMap(({ outcome, probability }, index) => {
161
+ const lowerBound = index === 0 ? 0 : lazyCollections.pipe(lazyCollections.slice(0, index - 1), lazyCollections.reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0))(potentialities), upperBound = lowerBound + probability;
162
+ return {
163
+ outcome,
164
+ predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
165
+ };
166
+ })(potentialities);
167
+ return (determinant) => lazyCollections.find(({ predicate }) => predicate(determinant))(predicates).outcome;
168
+ }
159
169
  function createRename({ from, to }) {
160
170
  return (map) => {
161
171
  const keys = [...map.keys()], keyToRenameIndex = lazyCollections.findIndex((k) => k === from)(keys), newKeys = createReplace({ index: keyToRenameIndex, item: to })(keys), values = [...map.values()];
@@ -1089,7 +1099,7 @@ const observerAssertionsByType = {
1089
1099
  resize: (observer) => observer instanceof ResizeObserver
1090
1100
  };
1091
1101
 
1092
- const defaultOptions$5 = {
1102
+ const defaultOptions$6 = {
1093
1103
  duration: 0,
1094
1104
  timing: [
1095
1105
  0,
@@ -1102,10 +1112,10 @@ const defaultOptions$5 = {
1102
1112
  };
1103
1113
  class Animateable {
1104
1114
  constructor(keyframes, options = {}) {
1105
- this.initialDuration = options?.duration || defaultOptions$5.duration;
1106
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$5.timing);
1107
- this.iterationLimit = options?.iterations || defaultOptions$5.iterations;
1108
- this.alternates = options?.alternates || defaultOptions$5.alternates;
1115
+ this.initialDuration = options?.duration || defaultOptions$6.duration;
1116
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$6.timing);
1117
+ this.iterationLimit = options?.iterations || defaultOptions$6.iterations;
1118
+ this.alternates = options?.alternates || defaultOptions$6.alternates;
1109
1119
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
1110
1120
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
1111
1121
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -1951,7 +1961,7 @@ const easingsNetInOutBack = [
1951
1961
  1.6
1952
1962
  ];
1953
1963
 
1954
- const defaultOptions$4 = {
1964
+ const defaultOptions$5 = {
1955
1965
  segment: {
1956
1966
  from: "start",
1957
1967
  to: "end"
@@ -1964,9 +1974,9 @@ const defaultCompleteOptions = {
1964
1974
  class Completeable {
1965
1975
  constructor(string, options = {}) {
1966
1976
  this.constructing();
1967
- this.segmentFrom = options?.segment?.from || defaultOptions$4.segment.from;
1968
- this.segmentTo = options?.segment?.to || defaultOptions$4.segment.to;
1969
- this.divider = options?.divider || defaultOptions$4.divider;
1977
+ this.segmentFrom = options?.segment?.from || defaultOptions$5.segment.from;
1978
+ this.segmentTo = options?.segment?.to || defaultOptions$5.segment.to;
1979
+ this.divider = options?.divider || defaultOptions$5.divider;
1970
1980
  this.computedDividerIndices = { before: 0, after: 0 };
1971
1981
  this.setString(string);
1972
1982
  this.setSelection(options?.initialSelection || { start: string.length, end: string.length, direction: "none" });
@@ -2196,7 +2206,7 @@ class Copyable {
2196
2206
  }
2197
2207
  }
2198
2208
 
2199
- const defaultOptions$3 = {
2209
+ const defaultOptions$4 = {
2200
2210
  delay: 0,
2201
2211
  executions: 1
2202
2212
  };
@@ -2206,8 +2216,8 @@ class Delayable {
2206
2216
  { progress: 0, properties: { progress: 0 } },
2207
2217
  { progress: 1, properties: { progress: 1 } }
2208
2218
  ], {
2209
- duration: options?.delay ?? defaultOptions$3.delay,
2210
- iterations: options?.executions ?? defaultOptions$3.executions
2219
+ duration: options?.delay ?? defaultOptions$4.delay,
2220
+ iterations: options?.executions ?? defaultOptions$4.executions
2211
2221
  });
2212
2222
  this.setEffect(effect);
2213
2223
  this.ready();
@@ -2371,12 +2381,12 @@ class Dispatchable {
2371
2381
  }
2372
2382
  }
2373
2383
 
2374
- const defaultOptions$2 = {
2384
+ const defaultOptions$3 = {
2375
2385
  toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
2376
2386
  };
2377
2387
  class Drawable {
2378
2388
  constructor(stroke, options = {}) {
2379
- this.toD = options?.toD || defaultOptions$2.toD;
2389
+ this.toD = options?.toD || defaultOptions$3.toD;
2380
2390
  this.setStroke(stroke);
2381
2391
  this.ready();
2382
2392
  }
@@ -2703,7 +2713,7 @@ class Grantable {
2703
2713
  }
2704
2714
  }
2705
2715
 
2706
- const defaultOptions$1 = {
2716
+ const defaultOptions$2 = {
2707
2717
  initialLocation: 0
2708
2718
  };
2709
2719
  const defaultNextAndPreviousOptions = {
@@ -2713,7 +2723,7 @@ const defaultNextAndPreviousOptions = {
2713
2723
  class Navigateable {
2714
2724
  constructor(array, options = {}) {
2715
2725
  this.setArray(array);
2716
- this.navigate(options?.initialLocation ?? defaultOptions$1.initialLocation);
2726
+ this.navigate(options?.initialLocation ?? defaultOptions$2.initialLocation);
2717
2727
  this.ready();
2718
2728
  }
2719
2729
  ready() {
@@ -2815,6 +2825,76 @@ class Navigateable {
2815
2825
  }
2816
2826
  }
2817
2827
 
2828
+ const defaultOptions$1 = {
2829
+ initialPicks: []
2830
+ };
2831
+ class Pickable {
2832
+ constructor(array, options = {}) {
2833
+ this.toItems = createMap((index) => this.array[index]);
2834
+ this.setArray(array);
2835
+ this.pick(options.initialPicks ?? defaultOptions$1.initialPicks);
2836
+ this.ready();
2837
+ }
2838
+ ready() {
2839
+ this.computedStatus = "ready";
2840
+ }
2841
+ get array() {
2842
+ return this.computedArray;
2843
+ }
2844
+ set array(array) {
2845
+ this.setArray(array);
2846
+ }
2847
+ get picks() {
2848
+ return this.computedPicks;
2849
+ }
2850
+ set picks(indices) {
2851
+ this.pick(indices);
2852
+ }
2853
+ get status() {
2854
+ return this.computedStatus;
2855
+ }
2856
+ get items() {
2857
+ return this.toItems(this.picks);
2858
+ }
2859
+ get multiple() {
2860
+ return this.picks.length > 1;
2861
+ }
2862
+ setArray(array) {
2863
+ this.computedArray = array;
2864
+ this.toPossiblePicks = createFilter((index) => index >= 0 && index < array.length);
2865
+ return this;
2866
+ }
2867
+ setPicks(indexOrIndices) {
2868
+ return this.pick(indexOrIndices);
2869
+ }
2870
+ pick(indexOrIndices) {
2871
+ const newPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks);
2872
+ this.computedPicks = createConcat(newPicks)(this.computedPicks || []);
2873
+ this.picked();
2874
+ return this;
2875
+ }
2876
+ picked() {
2877
+ this.computedStatus = "picked";
2878
+ }
2879
+ omit(indexOrIndices) {
2880
+ if (isUndefined(indexOrIndices)) {
2881
+ this.computedPicks = [];
2882
+ this.omitted();
2883
+ return this;
2884
+ }
2885
+ const omits = ensureIndices(indexOrIndices), filter = createFilter((pick) => !lazyCollections.find((omit) => pick === omit)(omits));
2886
+ this.computedPicks = filter(this.computedPicks);
2887
+ this.omitted();
2888
+ return this;
2889
+ }
2890
+ omitted() {
2891
+ this.computedStatus = "omitted";
2892
+ }
2893
+ }
2894
+ function ensureIndices(indexOrIndices) {
2895
+ return Array.isArray(indexOrIndices) ? indexOrIndices : [indexOrIndices];
2896
+ }
2897
+
2818
2898
  class Sanitizeable {
2819
2899
  constructor(html, options) {
2820
2900
  this.computedHtml = html;
@@ -2900,7 +2980,7 @@ class Searchable {
2900
2980
 
2901
2981
  const defaultOptions = {
2902
2982
  type: "local",
2903
- statusKeySuffix: "_status"
2983
+ statusKeySuffix: " status"
2904
2984
  };
2905
2985
  class Storeable {
2906
2986
  constructor(key, options = {}) {
@@ -3023,6 +3103,7 @@ exports.Fullscreenable = Fullscreenable;
3023
3103
  exports.Grantable = Grantable;
3024
3104
  exports.Listenable = Listenable;
3025
3105
  exports.Navigateable = Navigateable;
3106
+ exports.Pickable = Pickable;
3026
3107
  exports.Pipeable = Pipeable;
3027
3108
  exports.Recognizeable = Recognizeable;
3028
3109
  exports.Resolveable = Resolveable;
@@ -3033,6 +3114,7 @@ exports.createClamp = createClamp;
3033
3114
  exports.createClip = createClip;
3034
3115
  exports.createConcat = createConcat;
3035
3116
  exports.createDelete = createDelete;
3117
+ exports.createDetermine = createDetermine;
3036
3118
  exports.createFilter = createFilter;
3037
3119
  exports.createFilterAsync = createFilterAsync;
3038
3120
  exports.createForEachAsync = createForEachAsync;
package/lib/index.d.ts CHANGED
@@ -565,14 +565,15 @@ declare type DocumentEventInitMap = {
565
565
  "visibilitychange": EventInit;
566
566
  };
567
567
 
568
+ declare type DrawableState = ReturnType<typeof getStroke>;
568
569
  declare type DrawableOptions = {
569
- toD?: (stroke: ReturnType<typeof getStroke>) => string;
570
+ toD?: (stroke: DrawableState) => string;
570
571
  };
571
572
  declare type DrawableStatus = 'ready' | 'drawing' | 'drawn';
572
573
  declare class Drawable {
573
574
  private computedD;
574
575
  private toD;
575
- constructor(stroke: ReturnType<typeof getStroke>, options?: DrawableOptions);
576
+ constructor(stroke: DrawableState, options?: DrawableOptions);
576
577
  computedStatus: DrawableStatus;
577
578
  private ready;
578
579
  get stroke(): number[][];
@@ -580,7 +581,7 @@ declare class Drawable {
580
581
  get status(): DrawableStatus;
581
582
  get d(): string;
582
583
  private computedStroke;
583
- setStroke(stroke: ReturnType<typeof getStroke>): this;
584
+ setStroke(stroke: DrawableState): this;
584
585
  draw(points: Parameters<typeof getStroke>[0], options?: StrokeOptions): this;
585
586
  private drawing;
586
587
  private drawn;
@@ -730,6 +731,33 @@ declare class Navigateable<Item> {
730
731
  last(): this;
731
732
  }
732
733
 
734
+ declare type PickableOptions = {
735
+ initialPicks?: number | number[];
736
+ };
737
+ declare type PickableStatus = 'ready' | 'picked' | 'omitted';
738
+ declare class Pickable<Item> {
739
+ constructor(array: Item[], options?: PickableOptions);
740
+ private computedStatus;
741
+ private ready;
742
+ private computedArray;
743
+ get array(): Item[];
744
+ set array(array: Item[]);
745
+ private computedPicks;
746
+ get picks(): number[];
747
+ set picks(indices: number[]);
748
+ get status(): PickableStatus;
749
+ get items(): Item[];
750
+ private toItems;
751
+ get multiple(): boolean;
752
+ private toPossiblePicks;
753
+ setArray(array: Item[]): this;
754
+ setPicks(indexOrIndices: number | number[]): this;
755
+ pick(indexOrIndices: number | number[]): this;
756
+ private picked;
757
+ omit(indexOrIndices?: number | number[]): this;
758
+ private omitted;
759
+ }
760
+
733
761
  declare type SanitizeableOptions = Config;
734
762
  declare type SanitizeableStatus = 'ready' | 'sanitized';
735
763
  declare class Sanitizeable {
@@ -850,6 +878,11 @@ declare function createClamp({ min, max }: {
850
878
  min: number;
851
879
  max: number;
852
880
  }): NumberFunction<number>;
881
+ declare type Potentiality<Outcome> = {
882
+ outcome: Outcome;
883
+ probability: number;
884
+ };
885
+ declare function createDetermine<Outcome>(potentialities: Potentiality<Outcome>[]): NumberFunction<Outcome>;
853
886
  declare type MapFunction<Key, Value, Returned> = (map: Map<Key, Value>) => Returned;
854
887
  declare function createRename<Key, Value>({ from, to }: {
855
888
  from: Key;
@@ -862,4 +895,4 @@ declare class Pipeable {
862
895
  pipeAsync(...fns: ((...args: any[]) => Promise<any>)[]): Promise<any>;
863
896
  }
864
897
 
865
- 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, 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, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffectApi, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDelete, 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 };
898
+ 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 };
package/lib/index.js CHANGED
@@ -145,6 +145,16 @@ function createClamp({ min, max }) {
145
145
  return Math.min(maxed, max);
146
146
  };
147
147
  }
148
+ function createDetermine(potentialities) {
149
+ const predicates = createMap(({ outcome, probability }, index) => {
150
+ const lowerBound = index === 0 ? 0 : pipe(slice(0, index - 1), reduce((lowerBound2, { probability: probability2 }) => lowerBound2 + probability2, 0))(potentialities), upperBound = lowerBound + probability;
151
+ return {
152
+ outcome,
153
+ predicate: (determinant) => determinant >= lowerBound && determinant < upperBound || determinant < 0 && index === 0 || index === predicates.length - 1
154
+ };
155
+ })(potentialities);
156
+ return (determinant) => find(({ predicate }) => predicate(determinant))(predicates).outcome;
157
+ }
148
158
  function createRename({ from, to }) {
149
159
  return (map) => {
150
160
  const keys = [...map.keys()], keyToRenameIndex = findIndex((k) => k === from)(keys), newKeys = createReplace({ index: keyToRenameIndex, item: to })(keys), values = [...map.values()];
@@ -1078,7 +1088,7 @@ const observerAssertionsByType = {
1078
1088
  resize: (observer) => observer instanceof ResizeObserver
1079
1089
  };
1080
1090
 
1081
- const defaultOptions$5 = {
1091
+ const defaultOptions$6 = {
1082
1092
  duration: 0,
1083
1093
  timing: [
1084
1094
  0,
@@ -1091,10 +1101,10 @@ const defaultOptions$5 = {
1091
1101
  };
1092
1102
  class Animateable {
1093
1103
  constructor(keyframes, options = {}) {
1094
- this.initialDuration = options?.duration || defaultOptions$5.duration;
1095
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$5.timing);
1096
- this.iterationLimit = options?.iterations || defaultOptions$5.iterations;
1097
- this.alternates = options?.alternates || defaultOptions$5.alternates;
1104
+ this.initialDuration = options?.duration || defaultOptions$6.duration;
1105
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$6.timing);
1106
+ this.iterationLimit = options?.iterations || defaultOptions$6.iterations;
1107
+ this.alternates = options?.alternates || defaultOptions$6.alternates;
1098
1108
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
1099
1109
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
1100
1110
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -1940,7 +1950,7 @@ const easingsNetInOutBack = [
1940
1950
  1.6
1941
1951
  ];
1942
1952
 
1943
- const defaultOptions$4 = {
1953
+ const defaultOptions$5 = {
1944
1954
  segment: {
1945
1955
  from: "start",
1946
1956
  to: "end"
@@ -1953,9 +1963,9 @@ const defaultCompleteOptions = {
1953
1963
  class Completeable {
1954
1964
  constructor(string, options = {}) {
1955
1965
  this.constructing();
1956
- this.segmentFrom = options?.segment?.from || defaultOptions$4.segment.from;
1957
- this.segmentTo = options?.segment?.to || defaultOptions$4.segment.to;
1958
- this.divider = options?.divider || defaultOptions$4.divider;
1966
+ this.segmentFrom = options?.segment?.from || defaultOptions$5.segment.from;
1967
+ this.segmentTo = options?.segment?.to || defaultOptions$5.segment.to;
1968
+ this.divider = options?.divider || defaultOptions$5.divider;
1959
1969
  this.computedDividerIndices = { before: 0, after: 0 };
1960
1970
  this.setString(string);
1961
1971
  this.setSelection(options?.initialSelection || { start: string.length, end: string.length, direction: "none" });
@@ -2185,7 +2195,7 @@ class Copyable {
2185
2195
  }
2186
2196
  }
2187
2197
 
2188
- const defaultOptions$3 = {
2198
+ const defaultOptions$4 = {
2189
2199
  delay: 0,
2190
2200
  executions: 1
2191
2201
  };
@@ -2195,8 +2205,8 @@ class Delayable {
2195
2205
  { progress: 0, properties: { progress: 0 } },
2196
2206
  { progress: 1, properties: { progress: 1 } }
2197
2207
  ], {
2198
- duration: options?.delay ?? defaultOptions$3.delay,
2199
- iterations: options?.executions ?? defaultOptions$3.executions
2208
+ duration: options?.delay ?? defaultOptions$4.delay,
2209
+ iterations: options?.executions ?? defaultOptions$4.executions
2200
2210
  });
2201
2211
  this.setEffect(effect);
2202
2212
  this.ready();
@@ -2360,12 +2370,12 @@ class Dispatchable {
2360
2370
  }
2361
2371
  }
2362
2372
 
2363
- const defaultOptions$2 = {
2373
+ const defaultOptions$3 = {
2364
2374
  toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
2365
2375
  };
2366
2376
  class Drawable {
2367
2377
  constructor(stroke, options = {}) {
2368
- this.toD = options?.toD || defaultOptions$2.toD;
2378
+ this.toD = options?.toD || defaultOptions$3.toD;
2369
2379
  this.setStroke(stroke);
2370
2380
  this.ready();
2371
2381
  }
@@ -2692,7 +2702,7 @@ class Grantable {
2692
2702
  }
2693
2703
  }
2694
2704
 
2695
- const defaultOptions$1 = {
2705
+ const defaultOptions$2 = {
2696
2706
  initialLocation: 0
2697
2707
  };
2698
2708
  const defaultNextAndPreviousOptions = {
@@ -2702,7 +2712,7 @@ const defaultNextAndPreviousOptions = {
2702
2712
  class Navigateable {
2703
2713
  constructor(array, options = {}) {
2704
2714
  this.setArray(array);
2705
- this.navigate(options?.initialLocation ?? defaultOptions$1.initialLocation);
2715
+ this.navigate(options?.initialLocation ?? defaultOptions$2.initialLocation);
2706
2716
  this.ready();
2707
2717
  }
2708
2718
  ready() {
@@ -2804,6 +2814,76 @@ class Navigateable {
2804
2814
  }
2805
2815
  }
2806
2816
 
2817
+ const defaultOptions$1 = {
2818
+ initialPicks: []
2819
+ };
2820
+ class Pickable {
2821
+ constructor(array, options = {}) {
2822
+ this.toItems = createMap((index) => this.array[index]);
2823
+ this.setArray(array);
2824
+ this.pick(options.initialPicks ?? defaultOptions$1.initialPicks);
2825
+ this.ready();
2826
+ }
2827
+ ready() {
2828
+ this.computedStatus = "ready";
2829
+ }
2830
+ get array() {
2831
+ return this.computedArray;
2832
+ }
2833
+ set array(array) {
2834
+ this.setArray(array);
2835
+ }
2836
+ get picks() {
2837
+ return this.computedPicks;
2838
+ }
2839
+ set picks(indices) {
2840
+ this.pick(indices);
2841
+ }
2842
+ get status() {
2843
+ return this.computedStatus;
2844
+ }
2845
+ get items() {
2846
+ return this.toItems(this.picks);
2847
+ }
2848
+ get multiple() {
2849
+ return this.picks.length > 1;
2850
+ }
2851
+ setArray(array) {
2852
+ this.computedArray = array;
2853
+ this.toPossiblePicks = createFilter((index) => index >= 0 && index < array.length);
2854
+ return this;
2855
+ }
2856
+ setPicks(indexOrIndices) {
2857
+ return this.pick(indexOrIndices);
2858
+ }
2859
+ pick(indexOrIndices) {
2860
+ const newPicks = new Pipeable(indexOrIndices).pipe(ensureIndices, this.toPossiblePicks);
2861
+ this.computedPicks = createConcat(newPicks)(this.computedPicks || []);
2862
+ this.picked();
2863
+ return this;
2864
+ }
2865
+ picked() {
2866
+ this.computedStatus = "picked";
2867
+ }
2868
+ omit(indexOrIndices) {
2869
+ if (isUndefined(indexOrIndices)) {
2870
+ this.computedPicks = [];
2871
+ this.omitted();
2872
+ return this;
2873
+ }
2874
+ const omits = ensureIndices(indexOrIndices), filter = createFilter((pick) => !find((omit) => pick === omit)(omits));
2875
+ this.computedPicks = filter(this.computedPicks);
2876
+ this.omitted();
2877
+ return this;
2878
+ }
2879
+ omitted() {
2880
+ this.computedStatus = "omitted";
2881
+ }
2882
+ }
2883
+ function ensureIndices(indexOrIndices) {
2884
+ return Array.isArray(indexOrIndices) ? indexOrIndices : [indexOrIndices];
2885
+ }
2886
+
2807
2887
  class Sanitizeable {
2808
2888
  constructor(html, options) {
2809
2889
  this.computedHtml = html;
@@ -2889,7 +2969,7 @@ class Searchable {
2889
2969
 
2890
2970
  const defaultOptions = {
2891
2971
  type: "local",
2892
- statusKeySuffix: "_status"
2972
+ statusKeySuffix: " status"
2893
2973
  };
2894
2974
  class Storeable {
2895
2975
  constructor(key, options = {}) {
@@ -3001,4 +3081,4 @@ class Storeable {
3001
3081
  }
3002
3082
  }
3003
3083
 
3004
- export { Animateable, Completeable, Copyable, Delayable, Dispatchable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, 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 };
3084
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.20.12",
3
+ "version": "0.20.16",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",