@bigbinary/neeto-commons-frontend 2.0.99 → 2.0.101

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
@@ -93,20 +93,6 @@ type OptionsType = {
93
93
  *
94
94
  * on the screen.
95
95
  *
96
- * This hook will accept two arguments an element and an options object. Passing an
97
- *
98
- * element using ref requires you to pass ref.current as an argument or pass an
99
- *
100
- * element that you accessed via getElementById/querySelector etc. Since it uses
101
- *
102
- * Intersection Observer API you can pass observer options such as root,
103
- *
104
- * rootMargin, threshold, etc as the second argument. You can read more about
105
- *
106
- * Intersection Observer API and the supported options from
107
- *
108
- * MDN Intersection Observer API.
109
- *
110
96
  * @example
111
97
  *
112
98
  * const ref = useRef(null);
@@ -133,9 +119,7 @@ export function useIsElementVisibleInDom(target: Element | null, options?: Optio
133
119
  *
134
120
  * until the updates are stopped. We can use this to limit the number of API calls
135
121
  *
136
- * triggered from a user input like search box.
137
- *
138
- * This hook accepts a value and a delay as an argument. The value returned by the
122
+ * triggered from a user input like search box. The value returned by the
139
123
  *
140
124
  * hook will only reflect the latest value when the hook has not been called for
141
125
  *
@@ -162,9 +146,7 @@ export function useDebounce<T>(value: T, delay?: number): T;
162
146
  *
163
147
  * function will be executed only when the dependencies stops changing for a while.
164
148
  *
165
- * This hook accepts a function as an argument. It will return a debounced version
166
- *
167
- * of that function. The debounced function comes with a cancel method which can
149
+ * The debounced function comes with a cancel method which can
168
150
  *
169
151
  * be used to cancel the delayed function invocation.
170
152
  *
@@ -196,12 +178,6 @@ export function useFuncDebounce<F extends Function>(func: F, delay?: number): F
196
178
  *
197
179
  * operations on the localStorage, prefer the vanilla localStorage API functions.
198
180
  *
199
- * This hook is very similar to useState. The only difference is that you must
200
- *
201
- * pass the storage key in the 1st parameter so that we can default to that value
202
- *
203
- * on page load instead of specified initial value.
204
- *
205
181
  * @example
206
182
  *
207
183
  * // here "theme" is the storage key and "light" is the initial value
@@ -228,12 +204,6 @@ export function useLocalStorage<T>(key: string, initialValue?: T): [T, (value: T
228
204
  *
229
205
  * A hook used to detect clicks outside of a specified element.
230
206
  *
231
- * This hook will accept two arguments: a ref and a handler. The ref is a reference
232
- *
233
- * to the element for which we want to detect outside clicks and handler is the
234
- *
235
- * action we want to perform when we click outside the element.
236
- *
237
207
  * @example
238
208
  *
239
209
  * const ref = useRef();
@@ -278,6 +248,12 @@ export function usePrevious<T>(value: T): T;
278
248
  *
279
249
  * if the dependencies change.
280
250
  *
251
+ * @example
252
+ *
253
+ * useUpdateEffect(() => {
254
+ * setTitle(value)
255
+ * }, [value]);
256
+ * @endexample
281
257
  */
282
258
  export function useUpdateEffect(effect: () => void, deps: any[]): void;
283
259
  /**
@@ -292,6 +268,18 @@ export function useUpdateEffect(effect: () => void, deps: any[]): void;
292
268
  *
293
269
  * for more details.
294
270
  *
271
+ * @example
272
+ *
273
+ * const App = () => {
274
+ * const isError = useDisplayErrorPage();
275
+ *
276
+ * if (isError) {
277
+ * return <ErrorPage />;
278
+ * }
279
+ *
280
+ * return <Main />;
281
+ * };
282
+ * @endexample
295
283
  */
296
284
  export function useDisplayErrorPage(): boolean;
297
285
  /**
@@ -325,12 +313,6 @@ type TimerType = {
325
313
  *
326
314
  * application to be manually refreshed.
327
315
  *
328
- * This hook accepts a single argument timerIntervalInSeconds, which is the
329
- *
330
- * number of seconds after which the component will re-render. The default value is
331
- *
332
- * 60 seconds.
333
- *
334
316
  * All invocations of useTimer hooks are attached to a single setInterval call
335
317
  *
336
318
  * which ticks every 1 second. So using that hook in multiple components won't
@@ -362,8 +344,6 @@ type ZustandConfigType = (set: (data: any) => void, get: () => any, api: any) =>
362
344
  *
363
345
  * overwritten.
364
346
  *
365
- * Usage:
366
- *
367
347
  * @example
368
348
  *
369
349
  * const useStore = create(
@@ -414,15 +394,9 @@ export declare type ZustandStoreHook = UseBoundStore<StoreApi<any>> & {
414
394
  *
415
395
  * will not submit when Shift + Enter is pressed. Shift + Enter can be used to
416
396
  *
417
- * add new lines to text area in the form.
418
- *
419
- * The hook accepts a callback, onSubmit, which will be called with no arguments
420
- *
421
- * when Enter key press is detected.
397
+ * add new lines to text area in the form. The hook returns a ref. This need to be
422
398
  *
423
- * The hook returns a ref. This need to be attached to the input element to be
424
- *
425
- * listened to.
399
+ * attached to the input element to be listened to.
426
400
  *
427
401
  * @example
428
402
  *
@@ -460,6 +434,8 @@ export function withTitle(Component: () => JSX.Element, title?: string): (props)
460
434
  *
461
435
  * send notifications and then register the browser with the notification service.
462
436
  *
437
+ * The VAPID public key.
438
+ *
463
439
  * After the user logs in, we need to ask the user permissions to send
464
440
  *
465
441
  * notifications and then register the browser with the notification service.
@@ -550,14 +526,12 @@ export async function destroyBrowserSubscription(): Promise<void>;
550
526
  *
551
527
  * This function can be used to handle onClick actions that redirects to a URL.
552
528
  *
553
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
529
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
554
530
  *
555
531
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
556
532
  *
557
533
  * passed as string or a history location object can be passed instead.
558
534
  *
559
- * Usage:
560
- *
561
535
  * @example
562
536
  *
563
537
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -571,14 +545,12 @@ export function handleMetaClick(history: History, params: string | object, event
571
545
  *
572
546
  * This function can be used to handle onClick actions that redirects to a URL.
573
547
  *
574
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
548
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
575
549
  *
576
550
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
577
551
  *
578
552
  * passed as string or a history location object can be passed instead.
579
553
  *
580
- * Usage:
581
- *
582
554
  * @example
583
555
  *
584
556
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -592,14 +564,12 @@ export function handleMetaClick(history: History, params: string | object): (eve
592
564
  *
593
565
  * This function can be used to handle onClick actions that redirects to a URL.
594
566
  *
595
- * It opens up the URL in a new tab if ctrl/cmd + click event is recieved.
567
+ * It opens up the URL in a new tab if ctrl/cmd + click event is received.
596
568
  *
597
569
  * Otherwise, simply redirects to the provided URL in the same tab. URL can be
598
570
  *
599
571
  * passed as string or a history location object can be passed instead.
600
572
  *
601
- * Usage:
602
- *
603
573
  * @example
604
574
  *
605
575
  * handleMetaClick(history, "/dashboard", e); //Opens "/dashboard" in a new tab if metaKey/CtrlKey is pressed. Otherwise simply redirects to "/dashboard".
@@ -615,8 +585,6 @@ export function handleMetaClick(history: History): (params: string | object, eve
615
585
  *
616
586
  * ctrlKey pressed.
617
587
  *
618
- * Usage:
619
- *
620
588
  * @example
621
589
  *
622
590
  * isMetaKeyPressed(event); //returns true if "event.metaKey || event.ctrlKey" is true, otherwise returns false.
@@ -636,8 +604,6 @@ type ConfigType = {
636
604
  *
637
605
  * corresponding handler will be invoked.
638
606
  *
639
- * This hook accepts 3 arguments hotkey, handler & config.
640
- *
641
607
  * @example
642
608
  *
643
609
  * // openSidebar function will only be called if the user is focused inside the textarea and performs the key combination.
@@ -662,8 +628,6 @@ export function useHotKeys(hotkey: string | string[], handler: (event: React.Key
662
628
  *
663
629
  * listen to other variable changes.
664
630
  *
665
- * This hook accepts a defaultValue and an optional array called dependencies.
666
- *
667
631
  * If dependencies is passed, the hook returns a state variable whose value will
668
632
  *
669
633
  * be updated to defaultValue in a useEffect that depends on the dependencies
@@ -713,10 +677,6 @@ export function useRegisterNavigationCheckpoint(): (key: string, path: string) =
713
677
  *
714
678
  * This hook returns the registered navigation checkpoint.
715
679
  *
716
- * This hook accepts key and will return the checkpoint path corresponding to the
717
- *
718
- * key from a Zustand store.
719
- *
720
680
  * @example
721
681
  *
722
682
  * const navigationCheckpoint = useRegisterNavigationCheckpoint(CHECK_POINT_KEY);
package/utils.d.ts CHANGED
@@ -10,8 +10,6 @@ export function resetAuthTokens(): void;
10
10
  *
11
11
  * event as the second, and executes the given function with event.target.value
12
12
  *
13
- * Usage:
14
- *
15
13
  * @example
16
14
  *
17
15
  * const onChange = val => console.log(`Value = ${val}`);
@@ -30,8 +28,6 @@ export function withEventTargetValue(func: (value: string) => void, event: React
30
28
  *
31
29
  * event as the second, and executes the given function with event.target.value
32
30
  *
33
- * Usage:
34
- *
35
31
  * @example
36
32
  *
37
33
  * const onChange = val => console.log(`Value = ${val}`);
@@ -48,8 +44,6 @@ export function withEventTargetValue(func: (value: string) => void): (event: Rea
48
44
  *
49
45
  * This function returns the subdomain of the current URL.
50
46
  *
51
- * Usage:
52
- *
53
47
  * @example
54
48
  *
55
49
  * // Let the current url be "https://spinkart.example.com".
@@ -63,10 +57,6 @@ export function getSubdomain(): string;
63
57
  *
64
58
  * Curried: false
65
59
  *
66
- * Returns the specified hardcoded data after some delay for simulating an API
67
- *
68
- * call.
69
- *
70
60
  * This function will simulate an API call and retrieve the hardcoded success/error
71
61
  *
72
62
  * responses after some delay based on the given error probability. This function
@@ -85,18 +75,6 @@ export function simulateApiCall<T>(result: T, error?: any, errorProbability?: nu
85
75
  *
86
76
  * Copies the given string to clipboard and shows a success toaster message.
87
77
  *
88
- * This function accepts a string as an argument and copies it to the clipboard.
89
- *
90
- * Also, it accepts two optional arguments: a boolean flag to indicate whether a
91
- *
92
- * toaster should be shown and a message to be shown in the toaster. By default the
93
- *
94
- * show toaster flag is set to true and the toaster message is set to "Copied to
95
- *
96
- * clipboard!". You can override these defaults by passing the appropriate values
97
- *
98
- * to the function.
99
- *
100
78
  * @example
101
79
  *
102
80
  * copyToClipboard("https://spinkart.example.com", {
@@ -162,12 +140,6 @@ export const dateFormat: typeof timeFormat;
162
140
  *
163
141
  * locale.
164
142
  *
165
- * The function also accepts options, which will be forwarded to
166
- *
167
- * Number.prototype.toLocaleString, which can be used for additional
168
- *
169
- * configurations like rounding, currency, units etc.
170
- *
171
143
  * @example
172
144
  *
173
145
  * toLocale(1000000); // "1,000,000" when locale is "en-US"
@@ -207,8 +179,6 @@ type QueryParamsType = {
207
179
  *
208
180
  * This function returns all the query parameters of the current URL as an object.
209
181
  *
210
- * Usage:
211
- *
212
182
  * @example
213
183
  *
214
184
  * // Let the current url be "https://example.com?search=something&sort=date".
@@ -224,7 +194,7 @@ export function getQueryParams(options?: qsOptionsType): QueryParamsType;
224
194
  *
225
195
  * This function joins the given strings with hyphen.
226
196
  *
227
- * Usage:
197
+ * Any number of string arguments.
228
198
  *
229
199
  * @example
230
200
  *
@@ -240,12 +210,6 @@ export function joinHyphenCase(...args: string[]): string;
240
210
  *
241
211
  * stated wait time in milliseconds has elapsed since the last time it was invoked.
242
212
  *
243
- * It accepts the function to be debounced as the first argument, the delay in
244
- *
245
- * milliseconds as the second argument.
246
- *
247
- * Usage:
248
- *
249
213
  * @example
250
214
  *
251
215
  * const searchForProducts = debounce(async key => {
@@ -263,8 +227,6 @@ export function debounce<F extends Function>(func: F, delay?: number): F;
263
227
  *
264
228
  * This function will return true if the current user has the given permission.
265
229
  *
266
- * Usage:
267
- *
268
230
  * @example
269
231
  *
270
232
  * hasPermission("user.view_settings");
@@ -279,7 +241,7 @@ export function hasPermission(permission: string): boolean;
279
241
  *
280
242
  * permissions.
281
243
  *
282
- * Usage:
244
+ * permissions: Any number of permission strings.
283
245
  *
284
246
  * @example
285
247
  *
@@ -295,7 +257,7 @@ export function hasAnyPermission(...permissions: string[]): boolean;
295
257
  *
296
258
  * permissions.
297
259
  *
298
- * Usage:
260
+ * permissions: Any number of permission strings.
299
261
  *
300
262
  * @example
301
263
  *
@@ -311,12 +273,10 @@ type ChannelNameWithParams = {
311
273
  *
312
274
  * Curried: false
313
275
  *
314
- * This function will create subscription were consumer is subscribed to rails
276
+ * This function will create subscription where consumer is subscribed to rails
315
277
  *
316
278
  * action cable channel.
317
279
  *
318
- * Usage:
319
- *
320
280
  * @example
321
281
  *
322
282
  * const subscription = createSubscription(