@availity/hooks 1.0.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,584 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ # 1.0.0 (2024-08-22)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * eslint issues ([bc4d8e9](https://github.com/Availity/availity-react/commit/bc4d8e9252a37c067de3e5b15e583c4a3c06d6c5))
11
+ * **hooks:** moved region fetching into useEffect, and adding trycatch to better handle errors ([e3d8454](https://github.com/Availity/availity-react/commit/e3d845457bb7d5ed7facde0081258d990c1eae6e))
12
+ * **hooks:** remove effect from dependency array in useMount ([a096fa4](https://github.com/Availity/availity-react/commit/a096fa45af7aaa40a09c87254aef0de864fa8ab6))
13
+ * **hooks:** use optional chaining ([ec54426](https://github.com/Availity/availity-react/commit/ec54426b81cb63f4e3ce14ba1fd1fb9c0f208d23))
14
+ * removed npmrc and added config to lerna for now creating locks ([efe82ab](https://github.com/Availity/availity-react/commit/efe82ab5a9a38cc8113d5cc71416f1ef347eb4c4))
15
+ * removed package-locks,added npmrc ignore,fixed react as hoisted dep ([4648319](https://github.com/Availity/availity-react/commit/4648319b1298096de2e3e37bf6246e5f169ace0e))
16
+ * upgrade yup and update sb stories ([68aeafe](https://github.com/Availity/availity-react/commit/68aeafe4fd7d90d7c88dbb24636ba7770fe87aa3))
17
+
18
+
19
+ ### Features
20
+
21
+ * allow for options to be passed in ([1d99a8b](https://github.com/Availity/availity-react/commit/1d99a8b942267c5be69711576ef4f64b8e36bacb))
22
+ * **docs:** updated to use yarn and added readmes ([3b94748](https://github.com/Availity/availity-react/commit/3b947487ef18c6e11486ad39203882a11bc8a1e7))
23
+ * **form:** add currency input ([fa9eea6](https://github.com/Availity/availity-react/commit/fa9eea6a3b3dd2ef741a0658c102e36c6db5288c))
24
+ * **hooks:** add documentation to sidebar, some formatting ([fbd9964](https://github.com/Availity/availity-react/commit/fbd99648c18993394f773d8540c1be023acf6e5b))
25
+ * **hooks:** add usePermissions, useOrganizations, useProviders hook ([458f5e5](https://github.com/Availity/availity-react/commit/458f5e50038c4fdc5a23919daec918a87cdb08e9))
26
+ * **hooks:** add useWindowDimensionsHook ([203d9c0](https://github.com/Availity/availity-react/commit/203d9c0a31362ec084c94c4ae50ab4b6efbc876b))
27
+ * **hooks:** added some common hooks to a new package ([98663fd](https://github.com/Availity/availity-react/commit/98663fd4742b988b0f11ad15236addf3237c9c0d))
28
+ * **hooks:** added storybook story for useCurrentUser ([00277b7](https://github.com/Availity/availity-react/commit/00277b73e15e4f26210d81fdc27a56fb94380838))
29
+ * **hooks:** added useCurrentUser hook ([8cab508](https://github.com/Availity/availity-react/commit/8cab5089074747bd1a970b48427c5ba8918d0db0))
30
+ * **hooks:** added useTimout and useMount hooks, tests, and docs ([e82c81e](https://github.com/Availity/availity-react/commit/e82c81ef840531b4327dcb823d6f3cfdda19fa22))
31
+ * **hooks:** fixed the copy pasta ([d82d5f9](https://github.com/Availity/availity-react/commit/d82d5f93e9c3609fe2142043043d1c01ef7f48e1))
32
+ * **hooks:** upgrade react query to v4 ([9b7b266](https://github.com/Availity/availity-react/commit/9b7b266fbbd880114d162d5a4f89f7a9f34a6a6f))
33
+ * **hooks:** upgrade to react-query v2 ([2da4115](https://github.com/Availity/availity-react/commit/2da411548721cee86be33dd92cf62a99f80e86cf))
34
+ * **hooks:** upgrade to react-query v3 ([351aeff](https://github.com/Availity/availity-react/commit/351aeff7bc6b2c14379b2113bc17624a956dfdd6))
35
+ * move storybook, stories, and fix hmr ([2f65f71](https://github.com/Availity/availity-react/commit/2f65f71769d2d981e22700b87a09516833588f64))
36
+ * **pagination:** pagination components using hooks ([590e5fd](https://github.com/Availity/availity-react/commit/590e5fd05fcf0656d2309ae091938b334fd422ee)), closes [#27](https://github.com/Availity/availity-react/issues/27) [#64](https://github.com/Availity/availity-react/issues/64)
37
+ * update to use react-query ([d762643](https://github.com/Availity/availity-react/commit/d762643e49da3de41922021833ab5bd209d2cbf9))
38
+ * upgrade deps ([eccefc0](https://github.com/Availity/availity-react/commit/eccefc0549ebd5057595f6ac696642789375f48a))
39
+
40
+
41
+ ### BREAKING CHANGES
42
+
43
+ * **hooks:** react query has been upgraded to v4. you must upgrade
44
+ to @tanstack/react-query@^4.36.1 in order to use this package now
45
+ * axios v1 is now required
46
+ * **hooks:** react-query ^3.0.0 is now required
47
+ * **hooks:** the return shapes have changed for most async hooks
48
+
49
+
50
+
51
+ ## [5.0.2](https://github.com/Availity/availity-react/compare/@availity/hooks@5.0.1...@availity/hooks@5.0.2) (2024-04-23)
52
+
53
+
54
+
55
+ ## [5.0.1](https://github.com/Availity/availity-react/compare/@availity/hooks@5.0.0...@availity/hooks@5.0.1) (2024-02-21)
56
+
57
+
58
+
59
+ # [5.0.0](https://github.com/Availity/availity-react/compare/@availity/hooks@4.0.0...@availity/hooks@5.0.0) (2023-10-16)
60
+
61
+
62
+ ### Features
63
+
64
+ * **hooks:** upgrade react query to v4 ([9b7b266](https://github.com/Availity/availity-react/commit/9b7b266fbbd880114d162d5a4f89f7a9f34a6a6f))
65
+
66
+
67
+ ### BREAKING CHANGES
68
+
69
+ * **hooks:** react query has been upgraded to v4. you must upgrade
70
+ to @tanstack/react-query@^4.36.1 in order to use this package now
71
+
72
+
73
+
74
+ # [4.0.0](https://github.com/Availity/availity-react/compare/@availity/hooks@3.3.3...@availity/hooks@4.0.0) (2023-10-09)
75
+
76
+
77
+ ### Features
78
+
79
+ * upgrade deps ([eccefc0](https://github.com/Availity/availity-react/commit/eccefc0549ebd5057595f6ac696642789375f48a))
80
+
81
+
82
+ ### BREAKING CHANGES
83
+
84
+ * axios v1 is now required
85
+
86
+
87
+
88
+ ## [3.3.3](https://github.com/Availity/availity-react/compare/@availity/hooks@3.3.2...@availity/hooks@3.3.3) (2023-01-27)
89
+
90
+
91
+
92
+ ## [3.3.2](https://github.com/Availity/availity-react/compare/@availity/hooks@3.3.1...@availity/hooks@3.3.2) (2023-01-11)
93
+
94
+
95
+
96
+ ## [3.3.1](https://github.com/Availity/availity-react/compare/@availity/hooks@3.3.0...@availity/hooks@3.3.1) (2022-06-14)
97
+
98
+
99
+
100
+ # [3.3.0](https://github.com/Availity/availity-react/compare/@availity/hooks@3.2.2...@availity/hooks@3.3.0) (2022-06-14)
101
+
102
+
103
+ ### Features
104
+
105
+ * **form:** add currency input ([fa9eea6](https://github.com/Availity/availity-react/commit/fa9eea6a3b3dd2ef741a0658c102e36c6db5288c))
106
+
107
+
108
+
109
+ ## [3.2.2](https://github.com/Availity/availity-react/compare/@availity/hooks@3.2.1...@availity/hooks@3.2.2) (2022-06-10)
110
+
111
+
112
+
113
+ ## [3.2.1](https://github.com/Availity/availity-react/compare/@availity/hooks@3.2.0...@availity/hooks@3.2.1) (2022-05-24)
114
+
115
+
116
+ ### Bug Fixes
117
+
118
+ * upgrade yup and update sb stories ([68aeafe](https://github.com/Availity/availity-react/commit/68aeafe4fd7d90d7c88dbb24636ba7770fe87aa3))
119
+
120
+
121
+
122
+ # 3.2.0 (2022-02-18)
123
+
124
+
125
+ ### Features
126
+
127
+ * **hooks:** add documentation to sidebar, some formatting ([fbd9964](https://github.com/Availity/availity-react/commit/fbd99648c18993394f773d8540c1be023acf6e5b))
128
+ * **hooks:** add useWindowDimensionsHook ([203d9c0](https://github.com/Availity/availity-react/commit/203d9c0a31362ec084c94c4ae50ab4b6efbc876b))
129
+
130
+
131
+
132
+
133
+
134
+ ## [3.1.2](https://github.com/Availity/availity-react/compare/@availity/hooks@3.1.1...@availity/hooks@3.1.2) (2021-12-20)
135
+
136
+ **Note:** Version bump only for package @availity/hooks
137
+
138
+
139
+
140
+
141
+
142
+ ## 3.1.1 (2021-12-14)
143
+
144
+ **Note:** Version bump only for package @availity/hooks
145
+
146
+
147
+
148
+
149
+
150
+ # 3.1.0 (2021-11-15)
151
+
152
+
153
+ ### Features
154
+
155
+ * move storybook, stories, and fix hmr ([2f65f71](https://github.com/Availity/availity-react/commit/2f65f71769d2d981e22700b87a09516833588f64))
156
+
157
+
158
+
159
+
160
+
161
+ ## [3.0.6](https://github.com/Availity/availity-react/compare/@availity/hooks@3.0.5...@availity/hooks@3.0.6) (2021-10-28)
162
+
163
+ **Note:** Version bump only for package @availity/hooks
164
+
165
+
166
+
167
+
168
+
169
+ ## 3.0.5 (2021-10-28)
170
+
171
+ **Note:** Version bump only for package @availity/hooks
172
+
173
+
174
+
175
+
176
+
177
+ ## [3.0.4](https://github.com/Availity/availity-react/compare/@availity/hooks@3.0.3...@availity/hooks@3.0.4) (2021-10-01)
178
+
179
+ **Note:** Version bump only for package @availity/hooks
180
+
181
+
182
+
183
+
184
+
185
+ ## 3.0.3 (2021-09-28)
186
+
187
+ **Note:** Version bump only for package @availity/hooks
188
+
189
+
190
+
191
+
192
+
193
+ ## 3.0.2 (2021-06-01)
194
+
195
+ **Note:** Version bump only for package @availity/hooks
196
+
197
+
198
+
199
+
200
+
201
+ ## 3.0.1 (2021-01-06)
202
+
203
+
204
+ ### Bug Fixes
205
+
206
+ * **hooks:** remove effect from dependency array in useMount ([a096fa4](https://github.com/Availity/availity-react/commit/a096fa45af7aaa40a09c87254aef0de864fa8ab6))
207
+
208
+
209
+
210
+
211
+
212
+ # 3.0.0 (2020-12-23)
213
+
214
+
215
+ ### Features
216
+
217
+ * **hooks:** upgrade to react-query v3 ([351aeff](https://github.com/Availity/availity-react/commit/351aeff7bc6b2c14379b2113bc17624a956dfdd6))
218
+
219
+
220
+ ### BREAKING CHANGES
221
+
222
+ * **hooks:** react-query ^3.0.0 is now required
223
+
224
+
225
+
226
+
227
+
228
+ ## 2.0.1 (2020-11-17)
229
+
230
+ **Note:** Version bump only for package @availity/hooks
231
+
232
+
233
+
234
+
235
+
236
+ # 2.0.0 (2020-10-30)
237
+
238
+
239
+ ### Bug Fixes
240
+
241
+ * **hooks:** use optional chaining ([ec54426](https://github.com/Availity/availity-react/commit/ec54426b81cb63f4e3ce14ba1fd1fb9c0f208d23))
242
+
243
+
244
+ ### Features
245
+
246
+ * **hooks:** upgrade to react-query v2 ([2da4115](https://github.com/Availity/availity-react/commit/2da411548721cee86be33dd92cf62a99f80e86cf))
247
+
248
+
249
+ ### BREAKING CHANGES
250
+
251
+ * **hooks:** the return shapes have changed for most async hooks
252
+
253
+
254
+
255
+
256
+
257
+ # 1.8.0 (2020-07-08)
258
+
259
+
260
+ ### Features
261
+
262
+ * allow for options to be passed in ([1d99a8b](https://github.com/Availity/availity-react/commit/1d99a8b942267c5be69711576ef4f64b8e36bacb))
263
+ * update to use react-query ([d762643](https://github.com/Availity/availity-react/commit/d762643e49da3de41922021833ab5bd209d2cbf9))
264
+
265
+
266
+
267
+
268
+
269
+ # 1.7.0 (2020-06-12)
270
+
271
+
272
+ ### Features
273
+
274
+ * **hooks:** add usePermissions, useOrganizations, useProviders hook ([458f5e5](https://github.com/Availity/availity-react/commit/458f5e50038c4fdc5a23919daec918a87cdb08e9))
275
+
276
+
277
+
278
+
279
+
280
+ ## 1.6.23 (2020-04-30)
281
+
282
+ **Note:** Version bump only for package @availity/hooks
283
+
284
+
285
+
286
+
287
+
288
+ ## 1.6.22 (2020-04-30)
289
+
290
+ **Note:** Version bump only for package @availity/hooks
291
+
292
+
293
+
294
+
295
+
296
+ ## 1.6.21 (2020-04-28)
297
+
298
+ **Note:** Version bump only for package @availity/hooks
299
+
300
+
301
+
302
+
303
+
304
+ ## 1.6.20 (2020-04-17)
305
+
306
+ **Note:** Version bump only for package @availity/hooks
307
+
308
+
309
+
310
+
311
+
312
+ ## 1.6.19 (2020-04-09)
313
+
314
+ **Note:** Version bump only for package @availity/hooks
315
+
316
+
317
+
318
+
319
+
320
+ ## 1.6.18 (2020-04-08)
321
+
322
+ **Note:** Version bump only for package @availity/hooks
323
+
324
+
325
+
326
+
327
+
328
+ ## 1.6.17 (2020-04-08)
329
+
330
+ **Note:** Version bump only for package @availity/hooks
331
+
332
+
333
+
334
+
335
+
336
+ ## 1.6.16 (2020-04-07)
337
+
338
+ **Note:** Version bump only for package @availity/hooks
339
+
340
+
341
+
342
+
343
+
344
+ ## 1.6.15 (2020-04-07)
345
+
346
+ **Note:** Version bump only for package @availity/hooks
347
+
348
+
349
+
350
+
351
+
352
+ ## 1.6.14 (2020-04-06)
353
+
354
+ **Note:** Version bump only for package @availity/hooks
355
+
356
+
357
+
358
+
359
+
360
+ ## 1.6.13 (2020-04-06)
361
+
362
+ **Note:** Version bump only for package @availity/hooks
363
+
364
+
365
+
366
+
367
+
368
+ ## 1.6.12 (2020-04-06)
369
+
370
+ **Note:** Version bump only for package @availity/hooks
371
+
372
+
373
+
374
+
375
+
376
+ ## 1.6.11 (2020-04-06)
377
+
378
+ **Note:** Version bump only for package @availity/hooks
379
+
380
+
381
+
382
+
383
+
384
+ ## 1.6.10 (2020-04-03)
385
+
386
+ **Note:** Version bump only for package @availity/hooks
387
+
388
+
389
+
390
+
391
+
392
+ ## 1.6.9 (2020-04-03)
393
+
394
+ **Note:** Version bump only for package @availity/hooks
395
+
396
+
397
+
398
+
399
+
400
+ ## 1.6.8 (2020-04-02)
401
+
402
+ **Note:** Version bump only for package @availity/hooks
403
+
404
+
405
+
406
+
407
+
408
+ ## 1.6.7 (2020-04-02)
409
+
410
+ **Note:** Version bump only for package @availity/hooks
411
+
412
+
413
+
414
+
415
+
416
+ ## [1.6.6](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.5...@availity/hooks@1.6.6) (2020-02-11)
417
+
418
+ **Note:** Version bump only for package @availity/hooks
419
+
420
+
421
+
422
+
423
+
424
+ ## [1.6.5](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.4...@availity/hooks@1.6.5) (2020-02-10)
425
+
426
+ **Note:** Version bump only for package @availity/hooks
427
+
428
+
429
+
430
+
431
+
432
+ ## [1.6.4](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.3...@availity/hooks@1.6.4) (2019-10-24)
433
+
434
+ **Note:** Version bump only for package @availity/hooks
435
+
436
+
437
+
438
+
439
+
440
+ ## [1.6.3](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.2...@availity/hooks@1.6.3) (2019-10-11)
441
+
442
+
443
+ ### Bug Fixes
444
+
445
+ * eslint issues ([bc4d8e9](https://github.com/Availity/availity-react/commit/bc4d8e9))
446
+
447
+
448
+
449
+
450
+
451
+ ## [1.6.2](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.1...@availity/hooks@1.6.2) (2019-09-26)
452
+
453
+
454
+ ### Bug Fixes
455
+
456
+ * **hooks:** moved region fetching into useEffect, and adding trycatch to better handle errors ([e3d8454](https://github.com/Availity/availity-react/commit/e3d8454))
457
+
458
+
459
+
460
+
461
+
462
+ ## [1.6.1](https://github.com/Availity/availity-react/compare/@availity/hooks@1.6.0...@availity/hooks@1.6.1) (2019-09-25)
463
+
464
+ **Note:** Version bump only for package @availity/hooks
465
+
466
+
467
+
468
+
469
+
470
+ # [1.6.0](https://github.com/Availity/availity-react/compare/@availity/hooks@1.5.2...@availity/hooks@1.6.0) (2019-09-04)
471
+
472
+
473
+ ### Features
474
+
475
+ * **docs:** updated to use yarn and added readmes ([3b94748](https://github.com/Availity/availity-react/commit/3b94748))
476
+
477
+
478
+
479
+
480
+
481
+ ## [1.5.2](https://github.com/Availity/availity-react/compare/@availity/hooks@1.5.1...@availity/hooks@1.5.2) (2019-08-19)
482
+
483
+ **Note:** Version bump only for package @availity/hooks
484
+
485
+
486
+
487
+
488
+
489
+ ## [1.5.1](https://github.com/Availity/availity-react/compare/@availity/hooks@1.5.0...@availity/hooks@1.5.1) (2019-08-13)
490
+
491
+ **Note:** Version bump only for package @availity/hooks
492
+
493
+
494
+
495
+
496
+
497
+ # [1.5.0](https://github.com/Availity/availity-react/compare/@availity/hooks@1.4.0...@availity/hooks@1.5.0) (2019-08-11)
498
+
499
+
500
+ ### Features
501
+
502
+ * **hooks:** added storybook story for useCurrentUser ([00277b7](https://github.com/Availity/availity-react/commit/00277b7))
503
+ * **hooks:** added useCurrentUser hook ([8cab508](https://github.com/Availity/availity-react/commit/8cab508))
504
+ * **hooks:** fixed the copy pasta ([d82d5f9](https://github.com/Availity/availity-react/commit/d82d5f9))
505
+
506
+
507
+
508
+
509
+
510
+ # [1.4.0](https://github.com/Availity/availity-react/compare/@availity/hooks@1.3.3...@availity/hooks@1.4.0) (2019-07-23)
511
+
512
+
513
+ ### Features
514
+
515
+ * **hooks:** added useTimout and useMount hooks, tests, and docs ([e82c81e](https://github.com/Availity/availity-react/commit/e82c81e))
516
+
517
+
518
+
519
+
520
+
521
+ ## [1.3.3](https://github.com/Availity/availity-react/compare/@availity/hooks@1.3.2...@availity/hooks@1.3.3) (2019-06-24)
522
+
523
+ **Note:** Version bump only for package @availity/hooks
524
+
525
+
526
+
527
+
528
+
529
+ ## [1.3.2](https://github.com/Availity/availity-react/compare/@availity/hooks@1.3.1...@availity/hooks@1.3.2) (2019-06-03)
530
+
531
+ **Note:** Version bump only for package @availity/hooks
532
+
533
+
534
+
535
+
536
+
537
+ ## [1.3.1](https://github.com/Availity/availity-react/compare/@availity/hooks@1.3.0...@availity/hooks@1.3.1) (2019-05-29)
538
+
539
+ **Note:** Version bump only for package @availity/hooks
540
+
541
+
542
+
543
+
544
+
545
+ # [1.3.0](https://github.com/Availity/availity-react/compare/@availity/hooks@1.1.1...@availity/hooks@1.3.0) (2019-03-04)
546
+
547
+
548
+ ### Features
549
+
550
+ * **pagination:** pagination components using hooks ([590e5fd](https://github.com/Availity/availity-react/commit/590e5fd)), closes [#27](https://github.com/Availity/availity-react/issues/27) [#64](https://github.com/Availity/availity-react/issues/64)
551
+
552
+
553
+
554
+
555
+
556
+ # [1.2.0](https://github.com/Availity/availity-react/compare/@availity/hooks@1.1.1...@availity/hooks@1.2.0) (2019-03-04)
557
+
558
+
559
+ ### Features
560
+
561
+ * **pagination:** pagination components using hooks ([590e5fd](https://github.com/Availity/availity-react/commit/590e5fd)), closes [#27](https://github.com/Availity/availity-react/issues/27) [#64](https://github.com/Availity/availity-react/issues/64)
562
+
563
+
564
+
565
+
566
+
567
+ ## [1.1.1](https://github.com/Availity/availity-react/compare/@availity/hooks@1.1.0...@availity/hooks@1.1.1) (2019-02-25)
568
+
569
+
570
+ ### Bug Fixes
571
+
572
+ * removed npmrc and added config to lerna for now creating locks ([efe82ab](https://github.com/Availity/availity-react/commit/efe82ab))
573
+ * removed package-locks,added npmrc ignore,fixed react as hoisted dep ([4648319](https://github.com/Availity/availity-react/commit/4648319))
574
+
575
+
576
+
577
+
578
+
579
+ # 1.1.0 (2019-02-21)
580
+
581
+
582
+ ### Features
583
+
584
+ * **hooks:** added some common hooks to a new package ([98663fd](https://github.com/Availity/availity-react/commit/98663fd))
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @availity/hooks
2
+
3
+ > Re-usable hooks for components and apps.
4
+
5
+ [![Version](https://img.shields.io/npm/v/@availity/hooks.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/hooks)
6
+ [![NPM Downloads](https://img.shields.io/npm/dt/@availity/hooks.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/hooks)
7
+ [![Dependecy Status](https://img.shields.io/librariesio/release/npm/@availity/hooks?style=for-the-badge)](https://github.com/Availity/availity-react/blob/master/packages/hooks/package.json)
8
+
9
+ ## Installation
10
+
11
+ ### NPM
12
+
13
+ ```bash
14
+ npm install @availity/hooks
15
+ ```
16
+
17
+ ### Yarn
18
+
19
+ ```bash
20
+ yarn add @availity/hooks
21
+ ```
22
+
23
+ ## Documentation
24
+
25
+ Check out more documentation at [availity.github.io](https://availity.github.io/availity-react/components/hooks/index)
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export { default as useEffectAsync } from './types/useEffectAsync';
2
+ export { default as useMount } from './types/useMount';
3
+ export { default as useTimeout } from './types/useTimeout';
4
+ export { default as useToggle } from './types/useToggle';
5
+ export { default as useCurrentRegion } from './types/useCurrentRegion';
6
+ export { default as useCurrentUser } from './types/useCurrentUser';
7
+ export { default as useProviders } from './types/useProviders';
8
+ export { default as usePermissions } from './types/usePermissions';
9
+ export { default as useOrganizations } from './types/useOrganizations';
10
+ export { default as useWindowDimensions } from './types/useWindowDimensions';
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { default as useEffectAsync } from './src/useEffectAsync';
2
+ export { default as useMount } from './src/useMount';
3
+ export { default as useTimeout } from './src/useTimeout';
4
+ export { default as useToggle } from './src/useToggle';
5
+ export { default as useCurrentRegion } from './src/useCurrentRegion';
6
+ export { default as useCurrentUser } from './src/useCurrentUser';
7
+ export { default as useProviders } from './src/useProviders';
8
+ export { default as usePermissions } from './src/usePermissions';
9
+ export { default as useOrganizations } from './src/useOrganizations';
10
+ export { default as useWindowDimensions } from './src/useWindowDimensions';
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest/global-config');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'hooks',
6
+ coverageDirectory: '../../coverage/hooks',
7
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@availity/hooks",
3
+ "version": "1.0.0",
4
+ "description": "A group of pre-built hooks that are common in most apps",
5
+ "keywords": [
6
+ "react",
7
+ "availity",
8
+ "hooks"
9
+ ],
10
+ "homepage": "https://availity.github.io/availity-react/components/hooks/index",
11
+ "bugs": {
12
+ "url": "https://github.com/Availity/availity-react/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/Availity/availity-react.git",
17
+ "directory": "packages/hooks"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Kyle Gray <kyle.gray@availity.com>",
21
+ "main": "index.js",
22
+ "types": "index.d.ts",
23
+ "scripts": {
24
+ "publish": "yarn npm publish --tolerate-republish --access public",
25
+ "publish:canary": "yarn npm publish --access public --tag canary"
26
+ },
27
+ "dependencies": {
28
+ "@tanstack/react-query": "^4.36.1",
29
+ "prop-types": "^15.8.1"
30
+ },
31
+ "devDependencies": {
32
+ "@availity/api-axios": "^9.0.0",
33
+ "axios": "^1.7.4",
34
+ "react": "^18.3.1",
35
+ "react-dom": "^18.3.1"
36
+ },
37
+ "peerDependencies": {
38
+ "@availity/api-axios": "^8.0.0",
39
+ "axios": "^1.7.4",
40
+ "react": ">=16.8.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
45
+ }
package/project.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@availity/hooks",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "projectType": "library",
5
+ "targets": {
6
+ "test": {
7
+ "executor": "@nx/jest:jest",
8
+ "outputs": ["{workspaceRoot}/coverage/hooks"],
9
+ "options": {
10
+ "jestConfig": "packages/hooks/jest.config.js"
11
+ }
12
+ },
13
+ "version": {
14
+ "executor": "@jscutlery/semver:version",
15
+ "options": {
16
+ "preset": "angular",
17
+ "commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
18
+ "tagPrefix": "@availity/{projectName}@",
19
+ "baseBranch": "master"
20
+ }
21
+ },
22
+ "lint": {
23
+ "executor": "@nx/eslint:lint",
24
+ "options": {
25
+ "eslintConfig": ".eslintrc.yaml",
26
+ "silent": false,
27
+ "fix": false,
28
+ "cache": true,
29
+ "cacheLocation": "./node_modules/.cache/hooks/.eslintcache",
30
+ "maxWarnings": -1,
31
+ "quiet": false,
32
+ "noEslintrc": false,
33
+ "hasTypeAwareRules": true,
34
+ "cacheStrategy": "metadata"
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,15 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { avRegionsApi } from '@availity/api-axios';
3
+
4
+ async function fetchRegion() {
5
+ const response = await avRegionsApi.getCurrentRegion();
6
+
7
+ return {
8
+ code: response?.data?.regions?.[0]?.id || '',
9
+ value: response?.data?.regions?.[0]?.value || '',
10
+ };
11
+ }
12
+
13
+ export default function useCurrentRegion(options) {
14
+ return useQuery(['region'], fetchRegion, options);
15
+ }
@@ -0,0 +1,8 @@
1
+ import { avUserApi } from '@availity/api-axios';
2
+ import { useQuery } from '@tanstack/react-query';
3
+
4
+ const fetchUser = async () => avUserApi.me();
5
+
6
+ export default function useCurrentUser(options) {
7
+ return useQuery(['user'], fetchUser, options);
8
+ }
@@ -0,0 +1,8 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export default function useEffectAsync(effect, inputs) {
4
+ useEffect(() => {
5
+ effect();
6
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7
+ }, inputs);
8
+ }
@@ -0,0 +1,6 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export default function useMount(effect) {
4
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5
+ useEffect(effect, []);
6
+ }
@@ -0,0 +1,8 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { avOrganizationsApi } from '@availity/api-axios';
3
+
4
+ const fetchOrganization = async (config) => avOrganizationsApi.getOrganizations(config);
5
+
6
+ export default function useOrganization(config, options) {
7
+ return useQuery(['organizations', config], () => fetchOrganization(config), options);
8
+ }
@@ -0,0 +1,8 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { avPermissionsApi } from '@availity/api-axios';
3
+
4
+ const fetchPermissions = async (config) => avPermissionsApi.getPermissions(config);
5
+
6
+ export default function usePermissions(config, options) {
7
+ return useQuery(['permissions', config], () => fetchPermissions(config), options);
8
+ }
@@ -0,0 +1,8 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { avProvidersApi } from '@availity/api-axios';
3
+
4
+ const fetchProviders = async (config) => avProvidersApi.getProviders(config.customerId, config);
5
+
6
+ export default function useProviders(config, options) {
7
+ return useQuery(['providers', config], () => fetchProviders(config), options);
8
+ }
@@ -0,0 +1,21 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ export default function useTimeout(ms = 0) {
4
+ const [ready, setReady] = useState(false);
5
+
6
+ useEffect(() => {
7
+ let unmounted = false;
8
+ const timer = setTimeout(() => {
9
+ if (!unmounted) {
10
+ setReady(true);
11
+ }
12
+ }, ms);
13
+
14
+ return () => {
15
+ unmounted = true;
16
+ clearTimeout(timer);
17
+ };
18
+ }, [ms]);
19
+
20
+ return ready;
21
+ }
@@ -0,0 +1,14 @@
1
+ import { useState } from 'react';
2
+
3
+ export default function useToggle(initialState = false) {
4
+ const [state, setState] = useState(initialState);
5
+ const toggle = (newState) => {
6
+ if (newState !== undefined && newState !== state) {
7
+ setState(newState);
8
+ } else if (newState === undefined) {
9
+ setState(!state);
10
+ }
11
+ };
12
+
13
+ return [state, toggle];
14
+ }
@@ -0,0 +1,26 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ const getWindowDimensions = () => {
4
+ const { innerWidth: width, innerHeight: height } = window;
5
+ return {
6
+ width,
7
+ height,
8
+ };
9
+ };
10
+
11
+ const useWindowDimensions = () => {
12
+ const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
13
+
14
+ useEffect(() => {
15
+ const handleResize = () => {
16
+ setWindowDimensions(getWindowDimensions());
17
+ };
18
+
19
+ window.addEventListener('resize', handleResize);
20
+ return () => window.removeEventListener('resize', handleResize);
21
+ }, []);
22
+
23
+ return windowDimensions;
24
+ };
25
+
26
+ export default useWindowDimensions;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { Card, CardBody, CardTitle } from 'reactstrap';
3
+
4
+ type Props = {
5
+ data: Record<string, unknown>;
6
+ loading: boolean;
7
+ title?: string;
8
+ };
9
+
10
+ const ResourceComponent = ({ data, loading, title = '' }: Props): JSX.Element => (
11
+ <Card body>
12
+ <CardTitle className="text-center" tag="h4">
13
+ {title}
14
+ </CardTitle>
15
+ <CardBody>{loading ? 'Loading...' : <pre>{JSON.stringify(data, null, 2)}</pre>}</CardBody>
16
+ </Card>
17
+ );
18
+
19
+ export default ResourceComponent;
package/tests/util.js ADDED
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { QueryClientProvider } from '@tanstack/react-query';
4
+
5
+ // Taken from https://github.com/tannerlinsley/react-query/blob/master/src/react/tests/utils.tsx#L6
6
+ export default function renderWithClient(client, ui) {
7
+ return render(<QueryClientProvider client={client}>{ui}</QueryClientProvider>);
8
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["."],
4
+ "exclude": ["dist", "build", "node_modules"]
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node", "@testing-library/jest-dom"],
7
+ "allowJs": true
8
+ },
9
+ "include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
10
+ }
@@ -0,0 +1,12 @@
1
+ export interface AriesHookBase {
2
+ data: {
3
+ totalCount: number;
4
+ count: number;
5
+ offSet: number;
6
+ links: {
7
+ next: { href: string };
8
+ last: { href: string };
9
+ self: { href: string };
10
+ };
11
+ };
12
+ }
@@ -0,0 +1,12 @@
1
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
+
3
+ export type CurrentRegion = {
4
+ code: string;
5
+ value: string;
6
+ };
7
+
8
+ declare function useCurrentRegion(
9
+ options?: UseQueryOptions<CurrentRegion, unknown>
10
+ ): UseQueryResult<CurrentRegion, unknown>;
11
+
12
+ export default useCurrentRegion;
@@ -0,0 +1,21 @@
1
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
+
3
+ export type CurrentUser = {
4
+ akaname: string;
5
+ createDate: string;
6
+ currentRegion: string;
7
+ email: string;
8
+ firstName: string;
9
+ lastName: string;
10
+ id: string;
11
+ jobTitle: string;
12
+ userHasSecurityException: boolean;
13
+ userId: string;
14
+ userValidated: boolean;
15
+ };
16
+
17
+ declare function useCurrentUser(
18
+ options?: UseQueryOptions<CurrentUser, unknown>
19
+ ): UseQueryResult<CurrentUser, unknown>;
20
+
21
+ export default useCurrentUser;
@@ -0,0 +1,3 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export default useEffect;
@@ -0,0 +1,5 @@
1
+ import { EffectCallback } from 'react';
2
+
3
+ declare function useMount(effect: EffectCallback): void;
4
+
5
+ export default useMount;
@@ -0,0 +1,75 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ import { AriesHookBase } from './aries';
4
+
5
+ interface OrganizationsBase {
6
+ data: {
7
+ organizations: [
8
+ {
9
+ links: {
10
+ permissions: { href: string };
11
+ patients: { href: string };
12
+ self: { href: string };
13
+ admin: { href: string };
14
+ businessArrangements: { href: string };
15
+ users: { href: string };
16
+ };
17
+ id: string;
18
+ customerId: string;
19
+ name: string;
20
+ status: string;
21
+ statusCode: string;
22
+ types: [{ code: string; value: string }];
23
+
24
+ primaryControllingAuthority: {
25
+ lastName: string;
26
+ firstName: string;
27
+ primaryPhone: string;
28
+ email: string;
29
+ };
30
+
31
+ physicalAddress: {
32
+ line1: string;
33
+ city: string;
34
+ state: string;
35
+ stateCode: string;
36
+ zipCode: string;
37
+ };
38
+ mailingAddress: {
39
+ line1: string;
40
+ city: string;
41
+ state: string;
42
+ stateCode: string;
43
+ zipCode: string;
44
+ };
45
+ billingAddress: {
46
+ line1: string;
47
+ city: string;
48
+ state: string;
49
+ stateCode: string;
50
+ zipCode: string;
51
+ };
52
+ regions: { code: string; value: string }[];
53
+ npis: { number: string }[];
54
+ taxIds: { number: string; type: string }[];
55
+
56
+ phoneNumber: {
57
+ areaCode: string;
58
+ exchange: string;
59
+ phoneNumber: string;
60
+ };
61
+ numberOfLicensedPhysicians: string;
62
+ numberOfLicensedClinicians: string;
63
+ }
64
+ ];
65
+ };
66
+ }
67
+
68
+ type Organizations = AriesHookBase & OrganizationsBase;
69
+
70
+ export declare function useOrganizations(
71
+ config: AxiosRequestConfig,
72
+ options?: UseQueryOptions<Organizations, unknown>
73
+ ): UseQueryResult<Organizations, unknown>;
74
+
75
+ export default useOrganizations;
@@ -0,0 +1,22 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ import { AriesHookBase } from './aries';
4
+
5
+ export interface PermissionsBase {
6
+ data: {
7
+ permissions: {
8
+ id: string;
9
+ description: string;
10
+ links: { self: { href: string } };
11
+ }[];
12
+ };
13
+ }
14
+
15
+ type Permissions = AriesHookBase & PermissionsBase;
16
+
17
+ declare function usePermissions(
18
+ config: AxiosRequestConfig,
19
+ options?: UseQueryOptions<Permissions, unknown>
20
+ ): UseQueryResult<Permissions, unknown>;
21
+
22
+ export default usePermissions;
@@ -0,0 +1,50 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
3
+ import { AriesHookBase } from './aries';
4
+
5
+ interface ProvidersBase {
6
+ data: {
7
+ providers: [
8
+ {
9
+ id: string;
10
+ lastName: string;
11
+ firstName: string;
12
+ middleName: string;
13
+ uiDisplayName: string;
14
+ atypical: boolean;
15
+ npi: string;
16
+ customerIds: [string];
17
+ roles: [{ code: string; value: string }];
18
+
19
+ primarySpecialty: {
20
+ code: string;
21
+ value: string;
22
+ };
23
+ primaryFax: {
24
+ internationalCellularCode: string;
25
+ areaCode: string;
26
+ phoneNumber: string;
27
+ };
28
+ primaryAddress: {
29
+ line1: string;
30
+ line2: string;
31
+ city: string;
32
+ state: string;
33
+ stateCode: string;
34
+ zip: { code: string; addon: string };
35
+ };
36
+ }
37
+ ];
38
+ };
39
+ }
40
+
41
+ type Providers = AriesHookBase & ProvidersBase;
42
+
43
+ type AvConfig = { customerId: number } & AxiosRequestConfig;
44
+
45
+ declare function useProviders(
46
+ config: AvConfig,
47
+ options?: UseQueryOptions<Providers, unknown>
48
+ ): UseQueryResult<Providers, unknown>;
49
+
50
+ export default useProviders;
@@ -0,0 +1,3 @@
1
+ declare function useTimeout(ms?: number | 0): boolean;
2
+
3
+ export default useTimeout;
@@ -0,0 +1,3 @@
1
+ declare const useToggle: (initialValue?: boolean) => [isToggled: boolean, toggle: (state?: boolean) => void];
2
+
3
+ export default useToggle;
@@ -0,0 +1,8 @@
1
+ export type Dimensions = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+
6
+ declare function useWindowDimensions(): Dimensions;
7
+
8
+ export default useWindowDimensions;