@bigbinary/neeto-commons-frontend 2.0.87 → 2.0.89

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/react-utils.d.ts CHANGED
@@ -616,17 +616,76 @@ type ConfigType = {
616
616
  export function useHotKeys(hotkey: string | string[], handler: (event: React.KeyboardEvent) => void, config?: ConfigType): React.MutableRefObject | null;
617
617
  /**
618
618
  *
619
- * This hook returns a state that automatically updates its value to defaultValue whenever defaultValue changes. We can also specify a dependencies array to listen to other variable changes.
619
+ * This hook returns a state that automatically updates its value to defaultValue
620
620
  *
621
- * This hook accepts a defaultValue and an optional array called dependencies. If dependencies is passed, the hook returns a state variable whose value will be updated to defaultValue in a useEffect that depends on the dependencies array. Otherwise, the useEffect will depend only on the defaultValue.
621
+ * whenever defaultValue changes. We can also specify a dependencies array to
622
+ *
623
+ * listen to other variable changes.
624
+ *
625
+ * This hook accepts a defaultValue and an optional array called dependencies.
626
+ *
627
+ * If dependencies is passed, the hook returns a state variable whose value will
628
+ *
629
+ * be updated to defaultValue in a useEffect that depends on the dependencies
630
+ *
631
+ * array. Otherwise, the useEffect will depend only on the defaultValue.
622
632
  *
623
633
  * @example
624
634
  *
625
- * const [value, setValue] = useStateWithDependency(defaultValue);// reset state to `defaultValue` whenever `defaultValue` changes.
626
- * const [value, setValue] = useStateWithDependency(defaultValue, [value1, value2]); // reset state to `defaultValue` only when `value1` or `value2` changes.
635
+ * const [value, setValue] = useStateWithDependency(defaultValue); // reset state to `defaultValue` whenever `defaultValue` changes.
636
+ * const [value, setValue] = useStateWithDependency(defaultValue, [
637
+ * value1,
638
+ * value2,
639
+ * ]); // reset state to `defaultValue` only when `value1` or `value2` changes.
627
640
  *
628
641
  * // In a case, where the value needs to be reset when defaultValue changes too, defaultValue can be passed with the dependencies, as shown below.
629
- * const [value, setValue] = useStateWithDependency(defaultValue, [ value1, value2, defaultValue ]);
642
+ * const [value, setValue] = useStateWithDependency(defaultValue, [
643
+ * value1,
644
+ * value2,
645
+ * defaultValue,
646
+ * ]);
647
+ * @endexample
648
+ */
649
+ export function useStateWithDependency<T>(defaultValue: T, dependencies?: any[]): T;
650
+ /**
651
+ *
652
+ * This hook returns a function that can be used to register navigation checkpoint
653
+ *
654
+ * to a Zustand store.
655
+ *
656
+ * The function returned by this hook accepts key and path as arguments. It
657
+ *
658
+ * will store the path as the value for the key in a Zustand store. This
659
+ *
660
+ * registered checkpoint can be retrieved using the useNavigationCheckpoint hook.
661
+ *
662
+ * @example
663
+ *
664
+ * const registerNavigationCheckpoint = useRegisterNavigationCheckpoint();
665
+ *
666
+ * useEffect(() => {
667
+ * registerNavigationCheckpoint(CHECKPOINT_KEY, CHECKPOINT_PATH);
668
+ * }, []);
669
+ * @endexample
670
+ */
671
+ export function useRegisterNavigationCheckpoint(): (key: string, path: string) => void;
672
+ /**
673
+ *
674
+ * This hook returns the registered navigation checkpoint.
675
+ *
676
+ * This hook accepts key and will return the checkpoint path corresponding to the
677
+ *
678
+ * key from a Zustand store.
679
+ *
680
+ * @example
681
+ *
682
+ * const navigationCheckpoint = useRegisterNavigationCheckpoint(CHECK_POINT_KEY);
683
+ *
684
+ * return (
685
+ * <>
686
+ * <Link to={navigationCheckpoint}>Navigate</Link>
687
+ * </>
688
+ * );
630
689
  * @endexample
631
690
  */
632
- export function useStateWithDependency<T>(defaultValue: T, dependencies?: any[]): T;
691
+ export function useNavigationCheckpoint(key: string): string;