@bigbinary/neeto-commons-frontend 2.0.96 → 2.0.97

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
@@ -456,13 +456,25 @@ export function useFieldSubmit(onSubmit: () => any): {
456
456
  export function withTitle(Component: () => JSX.Element, title?: string): (props) => JSX.Element;
457
457
  /**
458
458
  *
459
- * A browser push notifications utility function which asks the user permissions to send notifications and then register the browser with the notification service.
459
+ * A browser push notifications utility function which asks the user permissions to
460
460
  *
461
- * After the user logs in, we need to ask the user permissions to send notifications and then register the browser with the notification service.
461
+ * send notifications and then register the browser with the notification service.
462
462
  *
463
- * You can use the registerBrowserNotifications utility function to do this. It can be called on any event after login based on the application's logic and requirement.
463
+ * After the user logs in, we need to ask the user permissions to send
464
464
  *
465
- * Here as an example, we are calling registerBrowserNotifications method inside the Login component after the Authentication API request. This helps to associate the browser for that particular user.
465
+ * notifications and then register the browser with the notification service.
466
+ *
467
+ * You can use the registerBrowserNotifications utility function to do this. It
468
+ *
469
+ * can be called on any event after login based on the application's logic and
470
+ *
471
+ * requirement.
472
+ *
473
+ * Here as an example, we are calling registerBrowserNotifications method inside
474
+ *
475
+ * the Login component after the Authentication API request. This helps to
476
+ *
477
+ * associate the browser for that particular user.
466
478
  *
467
479
  * @example
468
480
  *
@@ -478,7 +490,7 @@ export function withTitle(Component: () => JSX.Element, title?: string): (props)
478
490
  * @endexample
479
491
  * The above mentioned feature is currently supported for chromium-based browsers.
480
492
  *
481
- * Safari (iOS) is currently WIP.
493
+ * Safari (iOS) is currently WIP.
482
494
  *
483
495
  * Any other browser which is not mentioned in above will be considered as
484
496
  *
@@ -488,19 +500,31 @@ export function withTitle(Component: () => JSX.Element, title?: string): (props)
488
500
  export async function registerBrowserNotifications(): Promise<void>;
489
501
  /**
490
502
  *
491
- * A browser push notifications utility function which destroys the browser subscriptions from the user's devices. This helps in unsubscribing from browser push notifications.
503
+ * A browser push notifications utility function which destroys the browser
504
+ *
505
+ * subscriptions from the user's devices. This helps in unsubscribing from browser
506
+ *
507
+ * push notifications.
508
+ *
509
+ * When the browser subscriptions expires for the user's devices or when the user
492
510
  *
493
- * When the browser subscriptions expires for the user's devices or when the user decides to logout,then destroy the generated browser subscription for the user.
511
+ * decides to logout,then destroy the generated browser subscription for the user.
494
512
  *
495
- * You can use the destroyBrowserSubscription utility function to do this. It can be called on any event before logout based on the application's logic and requirement.
513
+ * You can use the destroyBrowserSubscription utility function to do this. It can
496
514
  *
497
- * Here as an example:
515
+ * be called on any event before logout based on the application's logic and
498
516
  *
499
- * In the Logout component, we are calling destroyBrowserSubscription method before the Logout API request. This helps to destroy the browser subscription from the user's devices.
517
+ * requirement.
518
+ *
519
+ * Here as an example: In the Logout component, we are calling
520
+ *
521
+ * destroyBrowserSubscription method before the Logout API request. This
522
+ *
523
+ * helps to destroy the browser subscription from the user's devices.
500
524
  *
501
525
  * @example
502
526
  *
503
- * import {destroyBrowserSubscription } from "neetocommons/react-utils";
527
+ * import { destroyBrowserSubscription } from "neetocommons/react-utils";
504
528
  *
505
529
  * const handleLogout = async () => {
506
530
  * try {
@@ -512,7 +536,7 @@ export async function registerBrowserNotifications(): Promise<void>;
512
536
  * @endexample
513
537
  * The above mentioned feature is currently supported for chromium-based browsers.
514
538
  *
515
- * Safari (iOS) is currently WIP.
539
+ * Safari (iOS) is currently WIP.
516
540
  *
517
541
  * Any other browser which is not mentioned in above will be considered as
518
542
  *
@@ -524,15 +548,20 @@ export async function destroyBrowserSubscription(): Promise<void>;
524
548
  *
525
549
  * Curried: true
526
550
  *
527
- * This function can be used to handle onClick actions that redirects to a URL. It opens up the URL in a new tab if ctrl/cmd + click event is recieved. Otherwise, simply redirects to the provided URL in the same tab. URL can be passed as string or a history location object can be passed instead.
551
+ * This function can be used to handle onClick actions that redirects to a URL.
552
+ *
553
+ * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
554
+ *
555
+ * Otherwise, simply redirects to the provided URL in the same tab. URL can be
556
+ *
557
+ * passed as string or a history location object can be passed instead.
528
558
  *
529
559
  * Usage:
530
560
  *
531
561
  * @example
532
562
  *
533
563
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
534
- * handleMetaClick(history, {pathname: "/dashboard", state: "abc"}, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
535
- *
564
+ * handleMetaClick(history, { pathname: "/dashboard", state: "abc" }, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
536
565
  * @endexample
537
566
  */
538
567
  export function handleMetaClick(history: History, params: string | object, event: React.MouseEvent<HTMLElement, MouseEvent>): void;
@@ -540,15 +569,20 @@ export function handleMetaClick(history: History, params: string | object, event
540
569
  *
541
570
  * Curried: true
542
571
  *
543
- * This function can be used to handle onClick actions that redirects to a URL. It opens up the URL in a new tab if ctrl/cmd + click event is recieved. Otherwise, simply redirects to the provided URL in the same tab. URL can be passed as string or a history location object can be passed instead.
572
+ * This function can be used to handle onClick actions that redirects to a URL.
573
+ *
574
+ * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
575
+ *
576
+ * Otherwise, simply redirects to the provided URL in the same tab. URL can be
577
+ *
578
+ * passed as string or a history location object can be passed instead.
544
579
  *
545
580
  * Usage:
546
581
  *
547
582
  * @example
548
583
  *
549
584
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
550
- * handleMetaClick(history, {pathname: "/dashboard", state: "abc"}, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
551
- *
585
+ * handleMetaClick(history, { pathname: "/dashboard", state: "abc" }, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
552
586
  * @endexample
553
587
  */
554
588
  export function handleMetaClick(history: History, params: string | object): (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
@@ -556,15 +590,20 @@ export function handleMetaClick(history: History, params: string | object): (eve
556
590
  *
557
591
  * Curried: true
558
592
  *
559
- * This function can be used to handle onClick actions that redirects to a URL. It opens up the URL in a new tab if ctrl/cmd + click event is recieved. Otherwise, simply redirects to the provided URL in the same tab. URL can be passed as string or a history location object can be passed instead.
593
+ * This function can be used to handle onClick actions that redirects to a URL.
594
+ *
595
+ * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
596
+ *
597
+ * Otherwise, simply redirects to the provided URL in the same tab. URL can be
598
+ *
599
+ * passed as string or a history location object can be passed instead.
560
600
  *
561
601
  * Usage:
562
602
  *
563
603
  * @example
564
604
  *
565
605
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
566
- * handleMetaClick(history, {pathname: "/dashboard", state: "abc"}, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
567
- *
606
+ * handleMetaClick(history, { pathname: "/dashboard", state: "abc" }, e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise, redirects to "/dashboard" by preserving the state.
568
607
  * @endexample
569
608
  */
570
609
  export function handleMetaClick(history: History): (params: string | object, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
@@ -572,14 +611,15 @@ export function handleMetaClick(history: History): (params: string | object, eve
572
611
  *
573
612
  * Curried: false
574
613
  *
575
- * This function can be used to check whether an onClick event has metaKey or ctrlKey pressed.
614
+ * This function can be used to check whether an onClick event has metaKey or
615
+ *
616
+ * ctrlKey pressed.
576
617
  *
577
618
  * Usage:
578
619
  *
579
620
  * @example
580
621
  *
581
622
  * isMetaKeyPressed(event); //returns true if "event.metaKey || event.ctrlKey" is true, otherwise returns false.
582
- *
583
623
  * @endexample
584
624
  */
585
625
  export function isMetaKeyPressed(event: React.MouseEvent<HTMLElement, MouseEvent>): boolean;
@@ -688,4 +728,16 @@ export function useRegisterNavigationCheckpoint(): (key: string, path: string) =
688
728
  * );
689
729
  * @endexample
690
730
  */
691
- export function useNavigationCheckpoint(key: string): string;
731
+ export function useNavigationCheckpoint(key: string): string;
732
+ /**
733
+ *
734
+ * An HOC which provides the t function from react-i18next to the wrapped
735
+ *
736
+ * component as a prop.
737
+ *
738
+ * @example
739
+ *
740
+ * const Component = withT(({ t }) => <div>{t("some.key")}</div>);
741
+ * @endexample
742
+ */
743
+ export const withT: <P extends object>(Component: React.ComponentType<P>) => React.FC<Omit<P, "t">>;
package/react-utils.js CHANGED
@@ -3,7 +3,7 @@ import React__default, { useEffect, useState, useDebugValue, useRef, useMemo } f
3
3
  import { Honeybadger, HoneybadgerErrorBoundary as HoneybadgerErrorBoundary$1 } from '@honeybadger-io/react';
4
4
  import { Typography, Button } from '@bigbinary/neetoui';
5
5
  import { isNil, includes, __, prop, toPairs, mergeLeft, curry, keys, isEmpty, mergeDeepLeft, path, omit } from 'ramda';
6
- import { useTranslation, Trans } from 'react-i18next';
6
+ import { useTranslation, Trans, withTranslation } from 'react-i18next';
7
7
  import ErrorPage from '@bigbinary/neeto-molecules/ErrorPage';
8
8
  import { Route, Redirect } from 'react-router-dom';
9
9
  import axios from 'axios';
@@ -4119,6 +4119,8 @@ var isMetaKeyPressed = function isMetaKeyPressed(event) {
4119
4119
  return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
4120
4120
  };
4121
4121
 
4122
+ var withT = withTranslation();
4123
+
4122
4124
  var withTitle = function withTitle(Component) {
4123
4125
  var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
4124
4126
  var PageTitle = function PageTitle(props) {
@@ -4707,5 +4709,5 @@ var useUpdateEffect = function useUpdateEffect(callback) {
4707
4709
  }, dependencies);
4708
4710
  };
4709
4711
 
4710
- export { HoneybadgerErrorBoundary, PrivateRoute, destroyBrowserSubscription, handleMetaClick, isMetaKeyPressed, registerBrowserNotifications, useDebounce, useDisplayErrorPage, useErrorDisplayStore, useFuncDebounce, useHotKeys, useIsElementVisibleInDom, useKeyboardShortcutsPaneState, useLocalStorage, useNavigationCheckpoint, useOnClickOutside, usePrevious, useRegisterNavigationCheckpoint, useStateWithDependency, useTimer, useUpdateEffect, withImmutableActions, withTitle };
4712
+ export { HoneybadgerErrorBoundary, PrivateRoute, destroyBrowserSubscription, handleMetaClick, isMetaKeyPressed, registerBrowserNotifications, useDebounce, useDisplayErrorPage, useErrorDisplayStore, useFuncDebounce, useHotKeys, useIsElementVisibleInDom, useKeyboardShortcutsPaneState, useLocalStorage, useNavigationCheckpoint, useOnClickOutside, usePrevious, useRegisterNavigationCheckpoint, useStateWithDependency, useTimer, useUpdateEffect, withImmutableActions, withT, withTitle };
4711
4713
  //# sourceMappingURL=react-utils.js.map