@baleada/logic 0.20.20 → 0.20.21

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
@@ -2759,6 +2759,14 @@ class Navigateable {
2759
2759
  return this;
2760
2760
  }
2761
2761
  navigate(location) {
2762
+ this._navigate(location);
2763
+ this.navigated();
2764
+ return this;
2765
+ }
2766
+ navigated() {
2767
+ this.computedStatus = "navigated";
2768
+ }
2769
+ _navigate(location) {
2762
2770
  const ensuredLocation = (() => {
2763
2771
  if (location < 0) {
2764
2772
  return 0;
@@ -2769,11 +2777,6 @@ class Navigateable {
2769
2777
  return location;
2770
2778
  })();
2771
2779
  this.computedLocation = ensuredLocation;
2772
- this.navigated();
2773
- return this;
2774
- }
2775
- navigated() {
2776
- this.computedStatus = "navigated";
2777
2780
  }
2778
2781
  next(options = {}) {
2779
2782
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, lastLocation = this.array.length - 1, newLocation = (() => {
@@ -2791,9 +2794,13 @@ class Navigateable {
2791
2794
  return newLocation2;
2792
2795
  })();
2793
2796
  })();
2794
- this.navigate(newLocation);
2797
+ this._navigate(newLocation);
2798
+ this.nexted();
2795
2799
  return this;
2796
2800
  }
2801
+ nexted() {
2802
+ this.computedStatus = "navigated to next";
2803
+ }
2797
2804
  previous(options = {}) {
2798
2805
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
2799
2806
  if (this.location - distance >= 0) {
@@ -2810,22 +2817,38 @@ class Navigateable {
2810
2817
  return newLocation2;
2811
2818
  })();
2812
2819
  })();
2813
- this.navigate(newLocation);
2820
+ this._navigate(newLocation);
2821
+ this.previoused();
2814
2822
  return this;
2815
2823
  }
2824
+ previoused() {
2825
+ this.computedStatus = "navigated to previous";
2826
+ }
2816
2827
  random() {
2817
2828
  const newLocation = Math.floor(Math.random() * this.array.length);
2818
- this.navigate(newLocation);
2829
+ this._navigate(newLocation);
2830
+ this.randomed();
2819
2831
  return this;
2820
2832
  }
2833
+ randomed() {
2834
+ this.computedStatus = "navigated to random";
2835
+ }
2821
2836
  first() {
2822
- this.navigate(0);
2837
+ this._navigate(0);
2838
+ this.firsted();
2823
2839
  return this;
2824
2840
  }
2841
+ firsted() {
2842
+ this.computedStatus = "navigated to first";
2843
+ }
2825
2844
  last() {
2826
- this.navigate(this.array.length - 1);
2845
+ this._navigate(this.array.length - 1);
2846
+ this.lasted();
2827
2847
  return this;
2828
2848
  }
2849
+ lasted() {
2850
+ this.computedStatus = "navigated to last";
2851
+ }
2829
2852
  }
2830
2853
 
2831
2854
  const defaultOptions$1 = {
package/lib/index.d.ts CHANGED
@@ -703,7 +703,7 @@ declare class Grantable<DescriptorType extends PermissionDescriptor> {
703
703
  declare type NavigateableOptions = {
704
704
  initialLocation?: number;
705
705
  };
706
- declare type NavigateableStatus = 'ready' | 'navigated';
706
+ declare type NavigateableStatus = 'ready' | 'navigated' | 'navigated to next' | 'navigated to previous' | 'navigated to random' | 'navigated to first' | 'navigated to last';
707
707
  declare class Navigateable<Item> {
708
708
  constructor(array: Item[], options?: NavigateableOptions);
709
709
  private computedStatus;
@@ -720,17 +720,23 @@ declare class Navigateable<Item> {
720
720
  setLocation(location: number): this;
721
721
  navigate(location: number): this;
722
722
  private navigated;
723
+ private _navigate;
723
724
  next(options?: {
724
725
  distance?: number;
725
726
  loops?: boolean;
726
727
  }): this;
728
+ private nexted;
727
729
  previous(options?: {
728
730
  distance?: number;
729
731
  loops?: boolean;
730
732
  }): this;
733
+ private previoused;
731
734
  random(): this;
735
+ private randomed;
732
736
  first(): this;
737
+ private firsted;
733
738
  last(): this;
739
+ private lasted;
734
740
  }
735
741
 
736
742
  declare type PickableOptions = {
package/lib/index.js CHANGED
@@ -2748,6 +2748,14 @@ class Navigateable {
2748
2748
  return this;
2749
2749
  }
2750
2750
  navigate(location) {
2751
+ this._navigate(location);
2752
+ this.navigated();
2753
+ return this;
2754
+ }
2755
+ navigated() {
2756
+ this.computedStatus = "navigated";
2757
+ }
2758
+ _navigate(location) {
2751
2759
  const ensuredLocation = (() => {
2752
2760
  if (location < 0) {
2753
2761
  return 0;
@@ -2758,11 +2766,6 @@ class Navigateable {
2758
2766
  return location;
2759
2767
  })();
2760
2768
  this.computedLocation = ensuredLocation;
2761
- this.navigated();
2762
- return this;
2763
- }
2764
- navigated() {
2765
- this.computedStatus = "navigated";
2766
2769
  }
2767
2770
  next(options = {}) {
2768
2771
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, lastLocation = this.array.length - 1, newLocation = (() => {
@@ -2780,9 +2783,13 @@ class Navigateable {
2780
2783
  return newLocation2;
2781
2784
  })();
2782
2785
  })();
2783
- this.navigate(newLocation);
2786
+ this._navigate(newLocation);
2787
+ this.nexted();
2784
2788
  return this;
2785
2789
  }
2790
+ nexted() {
2791
+ this.computedStatus = "navigated to next";
2792
+ }
2786
2793
  previous(options = {}) {
2787
2794
  const { distance, loops } = { ...defaultNextAndPreviousOptions, ...options }, newLocation = (() => {
2788
2795
  if (this.location - distance >= 0) {
@@ -2799,22 +2806,38 @@ class Navigateable {
2799
2806
  return newLocation2;
2800
2807
  })();
2801
2808
  })();
2802
- this.navigate(newLocation);
2809
+ this._navigate(newLocation);
2810
+ this.previoused();
2803
2811
  return this;
2804
2812
  }
2813
+ previoused() {
2814
+ this.computedStatus = "navigated to previous";
2815
+ }
2805
2816
  random() {
2806
2817
  const newLocation = Math.floor(Math.random() * this.array.length);
2807
- this.navigate(newLocation);
2818
+ this._navigate(newLocation);
2819
+ this.randomed();
2808
2820
  return this;
2809
2821
  }
2822
+ randomed() {
2823
+ this.computedStatus = "navigated to random";
2824
+ }
2810
2825
  first() {
2811
- this.navigate(0);
2826
+ this._navigate(0);
2827
+ this.firsted();
2812
2828
  return this;
2813
2829
  }
2830
+ firsted() {
2831
+ this.computedStatus = "navigated to first";
2832
+ }
2814
2833
  last() {
2815
- this.navigate(this.array.length - 1);
2834
+ this._navigate(this.array.length - 1);
2835
+ this.lasted();
2816
2836
  return this;
2817
2837
  }
2838
+ lasted() {
2839
+ this.computedStatus = "navigated to last";
2840
+ }
2818
2841
  }
2819
2842
 
2820
2843
  const defaultOptions$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.20.20",
3
+ "version": "0.20.21",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",