@veracity/vui 0.3.2 → 0.5.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.
Files changed (209) hide show
  1. package/avatar/avatar.js +1 -1
  2. package/button/button.d.ts +15 -1
  3. package/button/button.js +3 -3
  4. package/button/button.types.d.ts +4 -4
  5. package/button/consts.js +2 -2
  6. package/button/theme.d.ts +2 -0
  7. package/button/theme.js +3 -2
  8. package/buttonGroup/buttonGroup.d.ts +1 -1
  9. package/buttonGroup/buttonGroup.js +1 -1
  10. package/buttonGroup/helpers.js +3 -1
  11. package/checkbox/checkbox.d.ts +1 -1
  12. package/core/consts.d.ts +7 -0
  13. package/core/consts.js +8 -1
  14. package/core/index.d.ts +1 -0
  15. package/core/index.js +1 -0
  16. package/core/links.d.ts +20 -0
  17. package/core/links.js +173 -0
  18. package/dialog/consts.d.ts +3 -0
  19. package/dialog/consts.js +30 -0
  20. package/dialog/context.d.ts +4 -0
  21. package/dialog/context.js +23 -0
  22. package/dialog/dialog.d.ts +26 -0
  23. package/dialog/dialog.js +122 -0
  24. package/dialog/dialog.types.d.ts +47 -0
  25. package/dialog/dialogBody.d.ts +9 -0
  26. package/dialog/dialogBody.js +85 -0
  27. package/dialog/dialogCancelButton.d.ts +4 -0
  28. package/dialog/dialogCancelButton.js +30 -0
  29. package/dialog/dialogCloseButton.d.ts +4 -0
  30. package/dialog/dialogCloseButton.js +30 -0
  31. package/dialog/dialogFooter.d.ts +4 -0
  32. package/dialog/dialogFooter.js +45 -0
  33. package/dialog/dialogHeader.d.ts +4 -0
  34. package/dialog/dialogHeader.js +53 -0
  35. package/dialog/dialogIcon.d.ts +4 -0
  36. package/dialog/dialogIcon.js +32 -0
  37. package/dialog/dialogSubmitButton.d.ts +4 -0
  38. package/dialog/dialogSubmitButton.js +28 -0
  39. package/dialog/dialogTitle.d.ts +4 -0
  40. package/dialog/dialogTitle.js +30 -0
  41. package/dialog/index.d.ts +13 -0
  42. package/dialog/index.js +30 -0
  43. package/dialog/theme.d.ts +22 -0
  44. package/dialog/theme.js +28 -0
  45. package/footer/context.d.ts +4 -0
  46. package/footer/context.js +23 -0
  47. package/footer/footer.d.ts +2 -0
  48. package/footer/footer.js +11 -29
  49. package/footer/footer.types.d.ts +19 -16
  50. package/footer/footerColumn.d.ts +2 -218
  51. package/footer/footerColumn.js +16 -2
  52. package/footer/footerContent.d.ts +3 -0
  53. package/footer/footerContent.js +28 -0
  54. package/footer/footerHeading.js +2 -1
  55. package/footer/footerLink.js +2 -1
  56. package/footer/footerRow.js +2 -1
  57. package/footer/footerSection.js +4 -3
  58. package/footer/footerTrademark.d.ts +3 -5
  59. package/footer/footerTrademark.js +23 -6
  60. package/footer/helpers.d.ts +7 -10
  61. package/footer/helpers.js +91 -33
  62. package/footer/index.d.ts +1 -1
  63. package/footer/index.js +1 -1
  64. package/footer/theme.js +1 -1
  65. package/grid/grid.d.ts +5 -0
  66. package/{header/headerLink.js → grid/grid.js} +17 -13
  67. package/grid/grid.types.d.ts +3 -0
  68. package/grid/grid.types.js +2 -0
  69. package/grid/index.d.ts +3 -0
  70. package/grid/index.js +20 -0
  71. package/grid/theme.d.ts +7 -0
  72. package/grid/theme.js +12 -0
  73. package/header/context.d.ts +2 -2
  74. package/header/context.js +3 -3
  75. package/header/header.d.ts +11 -10
  76. package/header/header.js +36 -21
  77. package/header/header.types.d.ts +54 -39
  78. package/header/headerAccount.d.ts +8 -0
  79. package/header/{headerProfile.js → headerAccount.js} +32 -45
  80. package/header/headerAccount.types.d.ts +35 -0
  81. package/header/headerAccount.types.js +2 -0
  82. package/header/headerAccountUserInfo.d.ts +4 -0
  83. package/header/headerAccountUserInfo.js +46 -0
  84. package/header/headerContent.d.ts +2 -3
  85. package/header/headerContent.js +3 -3
  86. package/header/headerCreateAccount.js +8 -5
  87. package/header/headerDivider.js +2 -2
  88. package/header/headerLinkItem.d.ts +4 -0
  89. package/header/headerLinkItem.js +53 -0
  90. package/header/headerLogo.js +8 -10
  91. package/header/headerMainLinks.d.ts +4 -0
  92. package/header/{headerLinks.js → headerMainLinks.js} +10 -7
  93. package/header/headerMobileContent.js +4 -3
  94. package/header/headerMobileToggle.d.ts +2 -2
  95. package/header/headerMobileToggle.js +6 -7
  96. package/header/headerNotifications.js +8 -8
  97. package/header/headerServices.d.ts +5 -1
  98. package/header/headerServices.js +23 -14
  99. package/header/headerServicesMessage.d.ts +4 -0
  100. package/header/headerServicesMessage.js +49 -0
  101. package/header/headerSignIn.js +5 -3
  102. package/header/helpers.d.ts +8 -0
  103. package/header/helpers.js +115 -0
  104. package/header/index.d.ts +8 -3
  105. package/header/index.js +8 -3
  106. package/header/loggedInHeader.d.ts +1 -1
  107. package/header/loggedInHeader.js +16 -12
  108. package/header/loggedOutHeader.js +15 -12
  109. package/header/theme.d.ts +62 -7
  110. package/header/theme.js +53 -12
  111. package/icons/baseIcons/fas/fasCalendarAlt.js +1 -1
  112. package/index.d.ts +4 -0
  113. package/index.js +4 -0
  114. package/input/consts.js +2 -2
  115. package/input/input.js +1 -1
  116. package/input/input.types.d.ts +3 -3
  117. package/link/link.types.d.ts +4 -4
  118. package/link/linkText.js +1 -1
  119. package/list/listHeading.js +1 -1
  120. package/list/listItem.js +2 -2
  121. package/list/theme.d.ts +2 -4
  122. package/list/theme.js +2 -4
  123. package/menu/menuItem.js +7 -22
  124. package/menu/menuList.js +1 -1
  125. package/modal/ModalBackdrop.d.ts +4 -0
  126. package/modal/ModalBackdrop.js +37 -0
  127. package/modal/ModalContent.d.ts +4 -0
  128. package/modal/ModalContent.js +38 -0
  129. package/modal/context.d.ts +4 -0
  130. package/modal/context.js +23 -0
  131. package/modal/focusLock.d.ts +9 -0
  132. package/modal/focusLock.js +47 -0
  133. package/modal/focusLock.types.d.ts +28 -0
  134. package/modal/focusLock.types.js +2 -0
  135. package/modal/index.d.ts +9 -0
  136. package/modal/index.js +26 -0
  137. package/modal/modal.d.ts +15 -0
  138. package/modal/modal.js +113 -0
  139. package/modal/modal.types.d.ts +46 -0
  140. package/modal/modal.types.js +2 -0
  141. package/modal/modalManager.d.ts +12 -0
  142. package/modal/modalManager.js +33 -0
  143. package/modal/theme.d.ts +8 -0
  144. package/modal/theme.js +14 -0
  145. package/notification/consts.js +2 -2
  146. package/notification/notification.types.d.ts +1 -2
  147. package/notification/theme.js +1 -1
  148. package/package.json +3 -1
  149. package/popover/popover.d.ts +1 -1
  150. package/popover/popover.js +5 -4
  151. package/popover/popoverContent.js +1 -1
  152. package/popover/popoverTrigger.js +7 -2
  153. package/popover/usePopover.js +7 -9
  154. package/popover/usePopover.types.d.ts +1 -1
  155. package/portal/index.d.ts +3 -0
  156. package/portal/index.js +20 -0
  157. package/portal/portal.d.ts +5 -0
  158. package/portal/portal.js +56 -0
  159. package/portal/portal.types.d.ts +7 -0
  160. package/portal/portal.types.js +2 -0
  161. package/radio/radio.d.ts +1 -1
  162. package/radio/radioGroup.js +1 -1
  163. package/svg/svg.js +9 -7
  164. package/svg/svg.types.d.ts +2 -2
  165. package/system/custom.d.ts +0 -4
  166. package/system/custom.js +1 -15
  167. package/system/effects.d.ts +4 -4
  168. package/system/grids.d.ts +5 -3
  169. package/system/system.d.ts +2 -2
  170. package/system/system.js +1 -1
  171. package/system/transitions.d.ts +1 -1
  172. package/tag/tag.js +1 -2
  173. package/tag/tag.types.d.ts +3 -4
  174. package/tag/theme.d.ts +1 -0
  175. package/tag/theme.js +2 -1
  176. package/textarea/textarea.js +2 -2
  177. package/theme/components.d.ts +101 -11
  178. package/theme/components.js +48 -42
  179. package/theme/defaultTheme.d.ts +130 -12
  180. package/theme/foundations/gridTemplateColumns.d.ts +15 -0
  181. package/theme/foundations/gridTemplateColumns.js +16 -0
  182. package/theme/foundations/gridTemplateRows.d.ts +9 -0
  183. package/theme/foundations/gridTemplateRows.js +10 -0
  184. package/theme/foundations/index.d.ts +29 -1
  185. package/theme/foundations/index.js +6 -0
  186. package/theme/foundations/timingFunctions.d.ts +2 -0
  187. package/theme/foundations/timingFunctions.js +3 -0
  188. package/theme/foundations/zIndices.d.ts +6 -1
  189. package/theme/foundations/zIndices.js +6 -1
  190. package/theme/types.d.ts +9 -1
  191. package/utils/assertion.d.ts +2 -0
  192. package/utils/assertion.js +6 -1
  193. package/utils/function.d.ts +4 -0
  194. package/utils/function.js +19 -1
  195. package/utils/index.d.ts +1 -0
  196. package/utils/index.js +1 -0
  197. package/utils/number.d.ts +2 -0
  198. package/utils/number.js +10 -0
  199. package/utils/object.js +9 -17
  200. package/utils/react.d.ts +12 -5
  201. package/utils/react.js +69 -9
  202. package/utils/types.d.ts +4 -2
  203. package/footer/consts.d.ts +0 -72
  204. package/footer/consts.js +0 -132
  205. package/header/headerLink.d.ts +0 -4
  206. package/header/headerLinks.d.ts +0 -4
  207. package/header/headerProfile.d.ts +0 -4
  208. package/header/headerProfile.types.d.ts +0 -35
  209. /package/{header/headerProfile.types.js → dialog/dialog.types.js} +0 -0
@@ -123,6 +123,28 @@ declare const defaultTheme: {
123
123
  demi: string;
124
124
  bold: string;
125
125
  };
126
+ gridTemplateColumns: {
127
+ 1: string;
128
+ 2: string;
129
+ 3: string;
130
+ 4: string;
131
+ 5: string;
132
+ 6: string;
133
+ 7: string;
134
+ 8: string;
135
+ 9: string;
136
+ 10: string;
137
+ 11: string;
138
+ 12: string;
139
+ };
140
+ gridTemplateRows: {
141
+ 1: string;
142
+ 2: string;
143
+ 3: string;
144
+ 4: string;
145
+ 5: string;
146
+ 6: string;
147
+ };
126
148
  radii: {
127
149
  none: number;
128
150
  sm: number;
@@ -165,7 +187,13 @@ declare const defaultTheme: {
165
187
  };
166
188
  transforms: {};
167
189
  transitions: {};
168
- zIndices: {};
190
+ timingFunctions: {};
191
+ zIndices: {
192
+ drawer: number;
193
+ modal: number;
194
+ toast: number;
195
+ tooltip: number;
196
+ };
169
197
  components: {
170
198
  Avatar: {
171
199
  baseStyle: {};
@@ -285,6 +313,7 @@ declare const defaultTheme: {
285
313
  container: {
286
314
  borderColor: string;
287
315
  hoverBorderColor: string;
316
+ focusRing: number;
288
317
  hoverBg: string;
289
318
  activeBg: string;
290
319
  bg: string;
@@ -323,6 +352,7 @@ declare const defaultTheme: {
323
352
  borderColor: string;
324
353
  borderWidth: number;
325
354
  color: string;
355
+ focusRing: number;
326
356
  };
327
357
  };
328
358
  };
@@ -379,6 +409,27 @@ declare const defaultTheme: {
379
409
  };
380
410
  };
381
411
  };
412
+ Dialog: {
413
+ baseStyle: {};
414
+ defaultProps: {
415
+ size: string;
416
+ };
417
+ parts: string[];
418
+ sizes: {
419
+ md: {
420
+ container: {
421
+ maxW: number;
422
+ };
423
+ };
424
+ lg: {
425
+ container: {
426
+ maxW: number;
427
+ };
428
+ };
429
+ fullWidth: {};
430
+ };
431
+ variants: {};
432
+ };
382
433
  Divider: {
383
434
  baseStyle: {};
384
435
  defaultProps: {};
@@ -392,24 +443,85 @@ declare const defaultTheme: {
392
443
  sizes: {};
393
444
  variants: {};
394
445
  };
446
+ Grid: {
447
+ baseStyle: {};
448
+ defaultProps: {};
449
+ sizes: {};
450
+ variants: {};
451
+ };
395
452
  Header: {
396
453
  baseStyle: {};
397
454
  defaultProps: {};
398
455
  parts: string[];
399
456
  sizes: {};
400
457
  variants: {
401
- test: {
458
+ dark: {
402
459
  container: {
403
460
  bg: string;
404
- color: string;
461
+ borderBottom: number;
405
462
  };
406
- profile: {
407
- content: {
408
- color: string;
409
- };
463
+ account: {
410
464
  trigger: {
465
+ bg: string;
411
466
  color: string;
412
- name: string;
467
+ hoverBg: string;
468
+ activeBg: string;
469
+ };
470
+ };
471
+ createAccount: {
472
+ link: {
473
+ color: {
474
+ xs: string;
475
+ md: string;
476
+ };
477
+ hoverColor: {
478
+ xs: string;
479
+ md: string;
480
+ };
481
+ };
482
+ text: {
483
+ color: {
484
+ md: string;
485
+ };
486
+ };
487
+ };
488
+ divider: {
489
+ borderColor: string;
490
+ };
491
+ linkItem: {
492
+ container: {
493
+ hoverBg: {
494
+ xs: string;
495
+ md: string;
496
+ };
497
+ activeBg: {
498
+ xs: string;
499
+ md: string;
500
+ };
501
+ };
502
+ link: {
503
+ borderColor: string;
504
+ };
505
+ };
506
+ logo: {
507
+ svg: {
508
+ pathFill: string;
509
+ };
510
+ };
511
+ mainLinks: {
512
+ color: {
513
+ md: string;
514
+ };
515
+ };
516
+ mobileContent: {
517
+ top: string;
518
+ };
519
+ mobileToggle: {
520
+ variant: string;
521
+ };
522
+ notifications: {
523
+ container: {
524
+ variant: string;
413
525
  };
414
526
  };
415
527
  services: {
@@ -667,8 +779,7 @@ declare const defaultTheme: {
667
779
  };
668
780
  item: {
669
781
  display: string;
670
- h: undefined;
671
- lineHeight: number;
782
+ h: string;
672
783
  };
673
784
  };
674
785
  unordered: {
@@ -679,8 +790,7 @@ declare const defaultTheme: {
679
790
  };
680
791
  item: {
681
792
  display: string;
682
- h: undefined;
683
- lineHeight: number;
793
+ h: string;
684
794
  };
685
795
  };
686
796
  };
@@ -705,6 +815,13 @@ declare const defaultTheme: {
705
815
  };
706
816
  variants: {};
707
817
  };
818
+ Modal: {
819
+ baseStyle: {};
820
+ defaultProps: {};
821
+ parts: string[];
822
+ sizes: {};
823
+ variants: {};
824
+ };
708
825
  Notification: {
709
826
  baseStyle: {};
710
827
  defaultProps: {
@@ -1074,6 +1191,7 @@ declare const defaultTheme: {
1074
1191
  activeBg: string;
1075
1192
  bg: string;
1076
1193
  color: string;
1194
+ focusRing: number;
1077
1195
  };
1078
1196
  button: {
1079
1197
  hoverBg: string;
@@ -0,0 +1,15 @@
1
+ declare const _default: {
2
+ 1: string;
3
+ 2: string;
4
+ 3: string;
5
+ 4: string;
6
+ 5: string;
7
+ 6: string;
8
+ 7: string;
9
+ 8: string;
10
+ 9: string;
11
+ 10: string;
12
+ 11: string;
13
+ 12: string;
14
+ };
15
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ 1: 'repeat(1, minmax(0, 1fr))',
5
+ 2: 'repeat(2, minmax(0, 1fr))',
6
+ 3: 'repeat(3, minmax(0, 1fr))',
7
+ 4: 'repeat(4, minmax(0, 1fr))',
8
+ 5: 'repeat(5, minmax(0, 1fr))',
9
+ 6: 'repeat(6, minmax(0, 1fr))',
10
+ 7: 'repeat(7, minmax(0, 1fr))',
11
+ 8: 'repeat(8, minmax(0, 1fr))',
12
+ 9: 'repeat(9, minmax(0, 1fr))',
13
+ 10: 'repeat(10, minmax(0, 1fr))',
14
+ 11: 'repeat(11, minmax(0, 1fr))',
15
+ 12: 'repeat(12, minmax(0, 1fr))'
16
+ };
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ 1: string;
3
+ 2: string;
4
+ 3: string;
5
+ 4: string;
6
+ 5: string;
7
+ 6: string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ 1: 'repeat(1, minmax(0, 1fr))',
5
+ 2: 'repeat(2, minmax(0, 1fr))',
6
+ 3: 'repeat(3, minmax(0, 1fr))',
7
+ 4: 'repeat(4, minmax(0, 1fr))',
8
+ 5: 'repeat(5, minmax(0, 1fr))',
9
+ 6: 'repeat(6, minmax(0, 1fr))'
10
+ };
@@ -123,6 +123,28 @@ declare const _default: {
123
123
  demi: string;
124
124
  bold: string;
125
125
  };
126
+ gridTemplateColumns: {
127
+ 1: string;
128
+ 2: string;
129
+ 3: string;
130
+ 4: string;
131
+ 5: string;
132
+ 6: string;
133
+ 7: string;
134
+ 8: string;
135
+ 9: string;
136
+ 10: string;
137
+ 11: string;
138
+ 12: string;
139
+ };
140
+ gridTemplateRows: {
141
+ 1: string;
142
+ 2: string;
143
+ 3: string;
144
+ 4: string;
145
+ 5: string;
146
+ 6: string;
147
+ };
126
148
  radii: {
127
149
  none: number;
128
150
  sm: number;
@@ -165,6 +187,12 @@ declare const _default: {
165
187
  };
166
188
  transforms: {};
167
189
  transitions: {};
168
- zIndices: {};
190
+ timingFunctions: {};
191
+ zIndices: {
192
+ drawer: number;
193
+ modal: number;
194
+ toast: number;
195
+ tooltip: number;
196
+ };
169
197
  };
170
198
  export default _default;
@@ -10,12 +10,15 @@ var durations_1 = __importDefault(require("./durations"));
10
10
  var fonts_1 = __importDefault(require("./fonts"));
11
11
  var fontSizes_1 = __importDefault(require("./fontSizes"));
12
12
  var fontWeights_1 = __importDefault(require("./fontWeights"));
13
+ var gridTemplateColumns_1 = __importDefault(require("./gridTemplateColumns"));
14
+ var gridTemplateRows_1 = __importDefault(require("./gridTemplateRows"));
13
15
  var radii_1 = __importDefault(require("./radii"));
14
16
  var ringWidths_1 = __importDefault(require("./ringWidths"));
15
17
  var screens_1 = __importDefault(require("./screens"));
16
18
  var shadows_1 = __importDefault(require("./shadows"));
17
19
  var sizes_1 = __importDefault(require("./sizes"));
18
20
  var spaces_1 = __importDefault(require("./spaces"));
21
+ var timingFunctions_1 = __importDefault(require("./timingFunctions"));
19
22
  var transformers_1 = __importDefault(require("./transformers"));
20
23
  var transforms_1 = __importDefault(require("./transforms"));
21
24
  var transitions_1 = __importDefault(require("./transitions"));
@@ -28,6 +31,8 @@ exports.default = {
28
31
  fonts: fonts_1.default,
29
32
  fontSizes: fontSizes_1.default,
30
33
  fontWeights: fontWeights_1.default,
34
+ gridTemplateColumns: gridTemplateColumns_1.default,
35
+ gridTemplateRows: gridTemplateRows_1.default,
31
36
  radii: radii_1.default,
32
37
  ringWidths: ringWidths_1.default,
33
38
  screens: screens_1.default,
@@ -37,5 +42,6 @@ exports.default = {
37
42
  transformers: transformers_1.default,
38
43
  transforms: transforms_1.default,
39
44
  transitions: transitions_1.default,
45
+ timingFunctions: timingFunctions_1.default,
40
46
  zIndices: zIndices_1.default
41
47
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {};
@@ -1,2 +1,7 @@
1
- declare const _default: {};
1
+ declare const _default: {
2
+ drawer: number;
3
+ modal: number;
4
+ toast: number;
5
+ tooltip: number;
6
+ };
2
7
  export default _default;
@@ -1,3 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {};
3
+ exports.default = {
4
+ drawer: 1300,
5
+ modal: 1400,
6
+ toast: 1500,
7
+ tooltip: 1600
8
+ };
package/theme/types.d.ts CHANGED
@@ -1,14 +1,22 @@
1
1
  import defaultTheme from './defaultTheme';
2
2
  export declare type Animation = keyof VuiTheme['animations'];
3
+ export declare type Border = keyof VuiTheme['borders'];
3
4
  export declare type Color = keyof VuiTheme['colors'];
4
5
  export declare type Component = keyof VuiTheme['components'];
6
+ export declare type Font = keyof VuiTheme['fonts'];
5
7
  export declare type FontSize = keyof VuiTheme['fontSizes'];
6
8
  export declare type FontWeight = keyof VuiTheme['fontWeights'];
7
- export declare type Font = keyof VuiTheme['fonts'];
9
+ export declare type GridTemplateColumn = keyof VuiTheme['gridTemplateColumns'];
10
+ export declare type GridTemplateRow = keyof VuiTheme['gridTemplateRows'];
8
11
  export declare type Radius = keyof VuiTheme['radii'];
12
+ export declare type RingWidth = keyof VuiTheme['ringWidths'];
9
13
  export declare type Screen = keyof VuiTheme['screens'];
10
14
  export declare type Shadow = keyof VuiTheme['shadows'];
15
+ export declare type Size = keyof VuiTheme['sizes'];
16
+ export declare type Space = keyof VuiTheme['spaces'];
17
+ export declare type Transform = keyof VuiTheme['transforms'];
11
18
  export declare type TransitionDuration = keyof VuiTheme['durations'];
19
+ export declare type ZIndex = keyof VuiTheme['zIndices'];
12
20
  export declare type VuiThemeDefaults = typeof defaultTheme;
13
21
  /** Can be extended to add new properties to the theme or override default ones */
14
22
  export interface VuiThemeExtensions {
@@ -4,6 +4,8 @@ import { Dict } from './types';
4
4
  export declare function isArray<T>(value: any): value is T[];
5
5
  /** Is value a function. */
6
6
  export declare function isFunction<T extends Function = Function>(value: any): value is T;
7
+ /** Is value JSX / React Element */
8
+ export declare function isJsx<T = JSX.Element>(value: any): value is T;
7
9
  /** Is value a number. */
8
10
  export declare function isNumber(value: any): value is number;
9
11
  /** Is value a regular object (functions, arrays and React elements excluded). */
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isString = exports.isReactText = exports.isObject = exports.isNumber = exports.isFunction = exports.isArray = void 0;
6
+ exports.isString = exports.isReactText = exports.isObject = exports.isNumber = exports.isJsx = exports.isFunction = exports.isArray = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  /** Is value an array. */
9
9
  function isArray(value) {
@@ -15,6 +15,11 @@ function isFunction(value) {
15
15
  return typeof value === 'function';
16
16
  }
17
17
  exports.isFunction = isFunction;
18
+ /** Is value JSX / React Element */
19
+ function isJsx(value) {
20
+ return react_1.default.isValidElement(value);
21
+ }
22
+ exports.isJsx = isJsx;
18
23
  /** Is value a number. */
19
24
  function isNumber(value) {
20
25
  return typeof value === 'number';
@@ -1,3 +1,7 @@
1
+ import { AnyFunction } from './types';
2
+ /** Calls each provided function with the same set of arguments. Useful for merging multiple callbacks. */
3
+ export declare function callAll(...fns: (AnyFunction | undefined)[]): (...args: any[]) => void;
4
+ export declare function noop(): void;
1
5
  /**
2
6
  * If given value is a function, it's called with any additional arguments provided.
3
7
  * Otherwise, the provided value is returned directly.
package/utils/function.js CHANGED
@@ -25,8 +25,26 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
25
  return to.concat(ar || Array.prototype.slice.call(from));
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.runIfFn = void 0;
28
+ exports.runIfFn = exports.noop = exports.callAll = void 0;
29
29
  var assertion_1 = require("./assertion");
30
+ /** Calls each provided function with the same set of arguments. Useful for merging multiple callbacks. */
31
+ function callAll() {
32
+ var fns = [];
33
+ for (var _i = 0; _i < arguments.length; _i++) {
34
+ fns[_i] = arguments[_i];
35
+ }
36
+ return function () {
37
+ var args = [];
38
+ for (var _i = 0; _i < arguments.length; _i++) {
39
+ args[_i] = arguments[_i];
40
+ }
41
+ return fns.forEach(function (fn) { return typeof fn === 'function' && fn.apply(void 0, __spreadArray([], __read(args), false)); });
42
+ };
43
+ }
44
+ exports.callAll = callAll;
45
+ // Used as a safe default to be called when no function is provided.
46
+ function noop() { }
47
+ exports.noop = noop;
30
48
  /**
31
49
  * If given value is a function, it's called with any additional arguments provided.
32
50
  * Otherwise, the provided value is returned directly.
package/utils/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './assertion';
2
2
  export * from './function';
3
+ export * from './number';
3
4
  export * from './object';
4
5
  export * from './react';
5
6
  export * from './styles';
package/utils/index.js CHANGED
@@ -12,6 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./assertion"), exports);
14
14
  __exportStar(require("./function"), exports);
15
+ __exportStar(require("./number"), exports);
15
16
  __exportStar(require("./object"), exports);
16
17
  __exportStar(require("./react"), exports);
17
18
  __exportStar(require("./styles"), exports);
@@ -0,0 +1,2 @@
1
+ /** Returns a random integer within the provided range. Default: 0 - 1000000 */
2
+ export declare function random(start?: number, end?: number): number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.random = void 0;
4
+ /** Returns a random integer within the provided range. Default: 0 - 1000000 */
5
+ function random(start, end) {
6
+ if (start === void 0) { start = 0; }
7
+ if (end === void 0) { end = 1000000; }
8
+ return Math.floor(Math.random() * end) + start;
9
+ }
10
+ exports.random = random;
package/utils/object.js CHANGED
@@ -19,25 +19,17 @@ function merge() {
19
19
  Object.keys(source).forEach(function (key) {
20
20
  if (key === '__proto__')
21
21
  return;
22
- if (target[key] === undefined) {
23
- // Key not in target yet, assign source
24
- target[key] = source[key];
22
+ if ((0, assertion_1.isObject)(target[key]) && (0, assertion_1.isObject)(source[key])) {
23
+ // Merge objects
24
+ target[key] = merge(target[key], source[key]);
25
25
  }
26
- else if (typeof target[key] === typeof source[key]) {
27
- // Same types
28
- if ((0, assertion_1.isObject)(source[key])) {
29
- target[key] = merge(target[key], source[key]);
30
- }
31
- else if ((0, assertion_1.isArray)(source[key])) {
32
- target[key] = target[key].concat(source[key]);
33
- }
34
- else {
35
- target[key] = source[key];
36
- }
37
- // Different types
26
+ else if ((0, assertion_1.isArray)(target[key]) && (0, assertion_1.isArray)(source[key])) {
27
+ // Concat arrays
28
+ target[key] = target[key].concat(source[key]);
38
29
  }
39
- else {
40
- return;
30
+ else if (source[key] !== undefined) {
31
+ // Pick source if it exists
32
+ target[key] = source[key];
41
33
  }
42
34
  });
43
35
  });
package/utils/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { CreateContextOptions, CreateContextReturn } from './types';
1
+ import React, { RefObject } from 'react';
2
+ import { AnyFunction, CreateContextOptions, CreateContextReturn } from './types';
3
3
  declare type ReactRef<T> = React.Ref<T> | React.RefObject<T> | React.MutableRefObject<T>;
4
4
  /**
5
5
  * Assigns given value to the provided ref.
@@ -10,9 +10,16 @@ export declare function assignRef<T = any>(ref: ReactRef<T> | undefined, value:
10
10
  export declare function createContext<ContextType>(options?: CreateContextOptions): CreateContextReturn<ContextType>;
11
11
  /** Assigns a node to all provided refs. */
12
12
  export declare function mergeRefs<T>(...refs: (ReactRef<T> | undefined)[]): (node: T | null) => void;
13
+ /** Returns given callback with a stable reference, but keeps it updated internally. */
14
+ export declare function useCallbackRef<T extends AnyFunction>(callback?: T): T;
13
15
  /**
14
- * Saves given function in a ref to ensure stable exported reference.
15
- * When input function changes, ref is updated.
16
+ * Triggers given callback when an event happens outside of a given element.
17
+ * Event listeners are attached to the window object.
18
+ * @param ref - element to check click position for
19
+ * @param callback - function triggered on outside click
20
+ * @param events - array of events listened for (default: ['mousedown', 'touchstart'])
16
21
  */
17
- export declare function useFnRef(fn?: Function): React.MutableRefObject<Function | undefined>;
22
+ export declare function useClickOutside(ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[], callback?: (event: Event) => void, events?: string[]): void;
23
+ /** Returns an array with each prefix added to the id. Useful for aria attributes in compound components. */
24
+ export declare function useIds(id: string, prefixes: string[]): string[];
18
25
  export {};
package/utils/react.js CHANGED
@@ -19,8 +19,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  __setModuleDefault(result, mod);
20
20
  return result;
21
21
  };
22
+ var __read = (this && this.__read) || function (o, n) {
23
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24
+ if (!m) return o;
25
+ var i = m.call(o), r, ar = [], e;
26
+ try {
27
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28
+ }
29
+ catch (error) { e = { error: error }; }
30
+ finally {
31
+ try {
32
+ if (r && !r.done && (m = i["return"])) m.call(i);
33
+ }
34
+ finally { if (e) throw e.error; }
35
+ }
36
+ return ar;
37
+ };
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
22
47
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.useFnRef = exports.mergeRefs = exports.createContext = exports.assignRef = void 0;
48
+ exports.useIds = exports.useClickOutside = exports.useCallbackRef = exports.mergeRefs = exports.createContext = exports.assignRef = void 0;
24
49
  var react_1 = __importStar(require("react"));
25
50
  var assertion_1 = require("./assertion");
26
51
  /**
@@ -69,15 +94,50 @@ function mergeRefs() {
69
94
  };
70
95
  }
71
96
  exports.mergeRefs = mergeRefs;
97
+ // TODO: Bring it from UI-Utils
98
+ /** Returns given callback with a stable reference, but keeps it updated internally. */
99
+ function useCallbackRef(callback) {
100
+ var ref = (0, react_1.useRef)(callback);
101
+ ref.current = callback;
102
+ return (0, react_1.useCallback)((function () {
103
+ var _a;
104
+ var args = [];
105
+ for (var _i = 0; _i < arguments.length; _i++) {
106
+ args[_i] = arguments[_i];
107
+ }
108
+ return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([ref], __read(args), false));
109
+ }), []);
110
+ }
111
+ exports.useCallbackRef = useCallbackRef;
112
+ var defaultEvents = ['mousedown', 'touchstart'];
113
+ // TODO: Bring it from UI-Utils
72
114
  /**
73
- * Saves given function in a ref to ensure stable exported reference.
74
- * When input function changes, ref is updated.
115
+ * Triggers given callback when an event happens outside of a given element.
116
+ * Event listeners are attached to the window object.
117
+ * @param ref - element to check click position for
118
+ * @param callback - function triggered on outside click
119
+ * @param events - array of events listened for (default: ['mousedown', 'touchstart'])
75
120
  */
76
- function useFnRef(fn) {
77
- var fnRef = (0, react_1.useRef)(fn);
121
+ function useClickOutside(ref, callback, events) {
122
+ if (events === void 0) { events = defaultEvents; }
123
+ var eventsString = JSON.stringify(events);
124
+ var listener = useCallbackRef(function (ev) {
125
+ var refs = (0, assertion_1.isArray)(ref) ? ref : [ref];
126
+ var target = ev.target;
127
+ var isClickOutside = refs.every(function (ref) { return ref.current && !ref.current.contains(target); });
128
+ isClickOutside && (callback === null || callback === void 0 ? void 0 : callback(ev));
129
+ });
78
130
  (0, react_1.useEffect)(function () {
79
- fnRef.current = fn;
80
- }, [fn]);
81
- return fnRef;
131
+ var events = JSON.parse(eventsString);
132
+ events.forEach(function (event) { return window.addEventListener(event, listener); });
133
+ return function () {
134
+ events.forEach(function (event) { return window.removeEventListener(event, listener); });
135
+ };
136
+ }, [eventsString, ref]);
137
+ }
138
+ exports.useClickOutside = useClickOutside;
139
+ /** Returns an array with each prefix added to the id. Useful for aria attributes in compound components. */
140
+ function useIds(id, prefixes) {
141
+ return prefixes.map(function (prefix) { return prefix + "-" + id; });
82
142
  }
83
- exports.useFnRef = useFnRef;
143
+ exports.useIds = useIds;