baseui 11.0.3 → 11.1.2

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 (240) hide show
  1. package/a11y/index.d.ts +1 -1
  2. package/accordion/index.d.ts +25 -28
  3. package/app-nav-bar/app-nav-bar.js +33 -40
  4. package/app-nav-bar/app-nav-bar.js.flow +46 -62
  5. package/app-nav-bar/index.d.ts +9 -8
  6. package/app-nav-bar/styled-components.js +83 -29
  7. package/app-nav-bar/styled-components.js.flow +59 -9
  8. package/app-nav-bar/types.js.flow +2 -0
  9. package/aspect-ratio-box/index.d.ts +2 -4
  10. package/avatar/index.d.ts +6 -12
  11. package/badge/badge.js +109 -0
  12. package/badge/badge.js.flow +91 -0
  13. package/badge/constants.js +54 -0
  14. package/badge/constants.js.flow +52 -0
  15. package/badge/hint-dot.js +96 -0
  16. package/badge/hint-dot.js.flow +68 -0
  17. package/badge/index.d.ts +97 -0
  18. package/badge/index.js +80 -0
  19. package/badge/index.js.flow +20 -0
  20. package/badge/notification-circle.js +103 -0
  21. package/badge/notification-circle.js.flow +81 -0
  22. package/badge/package.json +4 -0
  23. package/badge/styled-components.js +242 -0
  24. package/badge/styled-components.js.flow +325 -0
  25. package/badge/types.js +11 -0
  26. package/badge/types.js.flow +59 -0
  27. package/badge/utils.js +33 -0
  28. package/badge/utils.js.flow +23 -0
  29. package/banner/banner.js +283 -0
  30. package/banner/banner.js.flow +253 -0
  31. package/banner/constants.js +35 -0
  32. package/banner/constants.js.flow +33 -0
  33. package/banner/index.d.ts +75 -0
  34. package/banner/index.js +44 -0
  35. package/banner/index.js.flow +16 -0
  36. package/banner/package.json +4 -0
  37. package/banner/styled-components.js +131 -0
  38. package/banner/styled-components.js.flow +119 -0
  39. package/banner/types.js +11 -0
  40. package/banner/types.js.flow +66 -0
  41. package/block/index.d.ts +4 -4
  42. package/breadcrumbs/breadcrumbs.js +5 -1
  43. package/breadcrumbs/breadcrumbs.js.flow +2 -2
  44. package/breadcrumbs/index.d.ts +5 -5
  45. package/button/button.js +2 -1
  46. package/button/button.js.flow +1 -0
  47. package/button/index.d.ts +19 -29
  48. package/button-group/index.d.ts +18 -24
  49. package/card/index.d.ts +16 -14
  50. package/checkbox/index.d.ts +17 -21
  51. package/combobox/index.d.ts +7 -11
  52. package/data-table/index.d.ts +7 -10
  53. package/datepicker/index.d.ts +42 -63
  54. package/datepicker/utils/date-helpers.js +1 -1
  55. package/datepicker/utils/date-helpers.js.flow +1 -1
  56. package/dnd-list/index.d.ts +22 -35
  57. package/drawer/index.d.ts +22 -27
  58. package/es/app-nav-bar/app-nav-bar.js +9 -19
  59. package/es/app-nav-bar/styled-components.js +64 -13
  60. package/es/badge/badge.js +70 -0
  61. package/es/badge/constants.js +42 -0
  62. package/es/badge/hint-dot.js +55 -0
  63. package/es/badge/index.js +11 -0
  64. package/es/badge/notification-circle.js +65 -0
  65. package/es/badge/styled-components.js +296 -0
  66. package/es/badge/types.js +8 -0
  67. package/es/badge/utils.js +17 -0
  68. package/es/banner/banner.js +213 -0
  69. package/es/banner/constants.js +24 -0
  70. package/es/banner/index.js +9 -0
  71. package/es/banner/styled-components.js +122 -0
  72. package/es/banner/types.js +8 -0
  73. package/es/breadcrumbs/breadcrumbs.js +5 -1
  74. package/es/button/button.js +1 -0
  75. package/es/datepicker/utils/date-helpers.js +1 -1
  76. package/es/file-uploader/file-uploader.js +8 -5
  77. package/es/helper/helper-steps.js +3 -1
  78. package/es/input/base-input.js +18 -11
  79. package/es/input/input.js +15 -10
  80. package/es/input/masked-input.js +5 -2
  81. package/es/input/utils.js +4 -2
  82. package/es/locale/tr_TR.js +115 -0
  83. package/es/notification/notification.js +16 -1
  84. package/es/payment-card/custom-cards.config.js +22 -0
  85. package/es/payment-card/icons/uatp.js +52 -0
  86. package/es/payment-card/payment-card.js +8 -3
  87. package/es/popover/popover.js +2 -1
  88. package/es/popover/stateful-container.js +2 -0
  89. package/es/popover/styled-components.js +2 -1
  90. package/es/progress-steps/numbered-step.js +2 -2
  91. package/es/select/select-component.js +38 -21
  92. package/es/table-semantic/styled-components.js +14 -0
  93. package/es/table-semantic/table-builder.js +12 -5
  94. package/es/textarea/textarea.js +15 -9
  95. package/es/themes/dark-theme/color-component-tokens.js +8 -0
  96. package/es/themes/light-theme/color-component-tokens.js +8 -0
  97. package/es/tree-view/tree-label.js +9 -1
  98. package/esm/app-nav-bar/app-nav-bar.js +32 -38
  99. package/esm/app-nav-bar/styled-components.js +79 -28
  100. package/esm/badge/badge.js +97 -0
  101. package/esm/badge/constants.js +42 -0
  102. package/esm/badge/hint-dot.js +83 -0
  103. package/esm/badge/index.js +11 -0
  104. package/esm/badge/notification-circle.js +91 -0
  105. package/esm/badge/styled-components.js +235 -0
  106. package/esm/badge/types.js +8 -0
  107. package/esm/badge/utils.js +17 -0
  108. package/esm/banner/banner.js +271 -0
  109. package/esm/banner/constants.js +24 -0
  110. package/esm/banner/index.js +9 -0
  111. package/esm/banner/styled-components.js +113 -0
  112. package/esm/banner/types.js +8 -0
  113. package/esm/breadcrumbs/breadcrumbs.js +5 -1
  114. package/esm/button/button.js +2 -1
  115. package/esm/datepicker/utils/date-helpers.js +1 -1
  116. package/esm/file-uploader/file-uploader.js +23 -8
  117. package/esm/helper/helper-steps.js +3 -1
  118. package/esm/input/base-input.js +18 -11
  119. package/esm/input/input.js +15 -10
  120. package/esm/input/masked-input.js +6 -3
  121. package/esm/input/utils.js +4 -2
  122. package/esm/locale/tr_TR.js +115 -0
  123. package/esm/notification/notification.js +17 -1
  124. package/esm/payment-card/custom-cards.config.js +22 -0
  125. package/esm/payment-card/icons/uatp.js +53 -0
  126. package/esm/payment-card/payment-card.js +9 -7
  127. package/esm/popover/popover.js +2 -1
  128. package/esm/popover/stateful-container.js +2 -0
  129. package/esm/popover/styled-components.js +3 -2
  130. package/esm/progress-steps/numbered-step.js +2 -2
  131. package/esm/select/select-component.js +75 -57
  132. package/esm/table-semantic/styled-components.js +31 -18
  133. package/esm/table-semantic/table-builder.js +34 -23
  134. package/esm/textarea/textarea.js +15 -9
  135. package/esm/themes/dark-theme/color-component-tokens.js +8 -0
  136. package/esm/themes/light-theme/color-component-tokens.js +8 -0
  137. package/esm/tree-view/tree-label.js +10 -2
  138. package/file-uploader/file-uploader.js +23 -8
  139. package/file-uploader/file-uploader.js.flow +18 -5
  140. package/file-uploader/index.d.ts +11 -11
  141. package/file-uploader/types.js.flow +3 -0
  142. package/flex-grid/index.d.ts +3 -3
  143. package/form-control/index.d.ts +7 -19
  144. package/header-navigation/index.d.ts +8 -9
  145. package/heading/index.d.ts +3 -4
  146. package/helper/helper-steps.js +19 -13
  147. package/helper/helper-steps.js.flow +3 -1
  148. package/helper/index.d.ts +7 -7
  149. package/helpers/base-provider.d.ts +16 -0
  150. package/helpers/overrides.d.ts +23 -0
  151. package/icon/index.d.ts +32 -32
  152. package/index.d.ts +34 -99
  153. package/input/base-input.js +18 -11
  154. package/input/base-input.js.flow +18 -6
  155. package/input/index.d.ts +29 -32
  156. package/input/input.js +15 -10
  157. package/input/input.js.flow +10 -5
  158. package/input/masked-input.js +6 -3
  159. package/input/masked-input.js.flow +3 -0
  160. package/input/types.js.flow +4 -0
  161. package/input/utils.js +4 -2
  162. package/input/utils.js.flow +2 -1
  163. package/layer/index.d.ts +6 -11
  164. package/layout-grid/index.d.ts +25 -7
  165. package/link/index.d.ts +2 -2
  166. package/list/index.d.ts +26 -31
  167. package/{locale.ts → locale/index.d.ts} +8 -0
  168. package/locale/tr_TR.js +123 -0
  169. package/locale/tr_TR.js.flow +124 -0
  170. package/map-marker/index.d.ts +41 -47
  171. package/menu/index.d.ts +27 -37
  172. package/modal/index.d.ts +28 -38
  173. package/notification/index.d.ts +2 -3
  174. package/notification/notification.js +18 -1
  175. package/notification/notification.js.flow +15 -1
  176. package/overrides.ts +2 -22
  177. package/package.json +26 -17
  178. package/pagination/index.d.ts +22 -26
  179. package/payment-card/custom-cards.config.js +30 -0
  180. package/payment-card/custom-cards.config.js.flow +29 -0
  181. package/payment-card/icons/uatp.js +67 -0
  182. package/payment-card/icons/uatp.js.flow +62 -0
  183. package/payment-card/index.d.ts +8 -8
  184. package/payment-card/payment-card.js +12 -7
  185. package/payment-card/payment-card.js.flow +12 -0
  186. package/phone-input/index.d.ts +261 -269
  187. package/pin-code/index.d.ts +11 -18
  188. package/popover/index.d.ts +39 -55
  189. package/popover/popover.js +2 -1
  190. package/popover/popover.js.flow +2 -1
  191. package/popover/stateful-container.js +2 -0
  192. package/popover/stateful-container.js.flow +2 -0
  193. package/popover/styled-components.js +3 -2
  194. package/popover/styled-components.js.flow +2 -1
  195. package/popover/types.js.flow +1 -0
  196. package/progress-bar/index.d.ts +11 -12
  197. package/progress-steps/index.d.ts +16 -16
  198. package/progress-steps/numbered-step.js.flow +2 -2
  199. package/radio/index.d.ts +12 -15
  200. package/rating/index.d.ts +9 -12
  201. package/select/index.d.ts +33 -36
  202. package/select/select-component.js +72 -54
  203. package/select/select-component.js.flow +35 -30
  204. package/side-navigation/index.d.ts +11 -13
  205. package/skeleton/index.d.ts +1 -1
  206. package/slider/index.d.ts +17 -26
  207. package/snackbar/index.d.ts +8 -8
  208. package/spinner/index.d.ts +2 -2
  209. package/styles/index.d.ts +82 -2
  210. package/table/index.d.ts +16 -16
  211. package/table-grid/index.d.ts +6 -8
  212. package/table-semantic/index.d.ts +26 -32
  213. package/table-semantic/styled-components.js +33 -19
  214. package/table-semantic/styled-components.js.flow +12 -0
  215. package/table-semantic/table-builder.js +38 -22
  216. package/table-semantic/table-builder.js.flow +32 -17
  217. package/table-semantic/types.js.flow +1 -0
  218. package/tabs/index.d.ts +20 -23
  219. package/tabs-motion/index.d.ts +23 -23
  220. package/tag/index.d.ts +14 -18
  221. package/textarea/index.d.ts +11 -14
  222. package/textarea/textarea.js +15 -9
  223. package/textarea/textarea.js.flow +11 -5
  224. package/textarea/types.js.flow +1 -0
  225. package/theme.ts +36 -777
  226. package/themes/dark-theme/color-component-tokens.js +8 -0
  227. package/themes/dark-theme/color-component-tokens.js.flow +9 -0
  228. package/themes/index.d.ts +765 -0
  229. package/themes/light-theme/color-component-tokens.js +8 -0
  230. package/themes/light-theme/color-component-tokens.js.flow +9 -0
  231. package/themes/types.js.flow +9 -0
  232. package/timepicker/index.d.ts +5 -8
  233. package/timezonepicker/index.d.ts +5 -8
  234. package/toast/index.d.ts +26 -40
  235. package/tokens/index.d.ts +1 -1
  236. package/tooltip/index.d.ts +7 -9
  237. package/tree-view/index.d.ts +15 -19
  238. package/tree-view/tree-label.js +10 -2
  239. package/tree-view/tree-label.js.flow +4 -4
  240. package/typography/index.d.ts +37 -37
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledHintDot = exports.StyledNotificationCircle = exports.StyledBadge = exports.StyledPositioner = exports.StyledRoot = void 0;
7
+
8
+ var _index = require("../styles/index.js");
9
+
10
+ var _constants = require("./constants.js");
11
+
12
+ var _ROLE$badge, _ROLE$notificationCir, _ROLE$hintDot, _Object$freeze;
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
20
+ function getColorStyles(_ref) {
21
+ var _HIERARCHY$primary, _HIERARCHY$secondary, _COLOR_STYLES;
22
+
23
+ var $theme = _ref.$theme,
24
+ $hierarchy = _ref.$hierarchy,
25
+ $color = _ref.$color;
26
+ var COLOR_STYLES = (_COLOR_STYLES = {}, _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.primary, (_HIERARCHY$primary = {}, _defineProperty(_HIERARCHY$primary, _constants.COLOR.accent, {
27
+ color: $theme.colors.contentInversePrimary,
28
+ backgroundColor: $theme.colors.backgroundAccent
29
+ }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.primary, {
30
+ color: $theme.colors.contentInversePrimary,
31
+ backgroundColor: $theme.colors.backgroundInversePrimary
32
+ }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.positive, {
33
+ color: $theme.colors.contentInversePrimary,
34
+ backgroundColor: $theme.colors.backgroundPositive
35
+ }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.negative, {
36
+ color: $theme.colors.contentInversePrimary,
37
+ backgroundColor: $theme.colors.backgroundNegative
38
+ }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.warning, {
39
+ color: $theme.colors.primaryA,
40
+ backgroundColor: $theme.colors.backgroundWarning
41
+ }), _HIERARCHY$primary)), _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.secondary, (_HIERARCHY$secondary = {}, _defineProperty(_HIERARCHY$secondary, _constants.COLOR.accent, {
42
+ color: $theme.colors.contentAccent,
43
+ backgroundColor: $theme.colors.backgroundLightAccent
44
+ }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.primary, {
45
+ color: $theme.colors.primaryA,
46
+ backgroundColor: $theme.colors.backgroundSecondary
47
+ }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.positive, {
48
+ color: $theme.colors.contentPositive,
49
+ backgroundColor: $theme.colors.backgroundLightPositive
50
+ }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.negative, {
51
+ color: $theme.colors.contentNegative,
52
+ backgroundColor: $theme.colors.backgroundLightNegative
53
+ }), _defineProperty(_HIERARCHY$secondary, _constants.COLOR.warning, {
54
+ color: $theme.colors.contentWarning,
55
+ backgroundColor: $theme.colors.backgroundLightWarning
56
+ }), _HIERARCHY$secondary)), _COLOR_STYLES);
57
+ return COLOR_STYLES[$hierarchy][$color];
58
+ }
59
+
60
+ var DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
61
+ top: '-10px',
62
+ right: '-10px'
63
+ };
64
+ var DEFAULT_HINT_DOT_PLACEMENT = {
65
+ top: '-4px',
66
+ right: '-4px'
67
+ };
68
+ var POSITION_STYLES = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, _constants.ROLE.badge, (_ROLE$badge = {}, _defineProperty(_ROLE$badge, _constants.PLACEMENT.topEdge, {
69
+ top: '-8px',
70
+ left: '50%',
71
+ transform: 'translateX(-50%)'
72
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomEdge, {
73
+ bottom: '-8px',
74
+ left: '50%',
75
+ transform: 'translateX(-50%)'
76
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topLeft, {
77
+ top: '16px',
78
+ left: '16px'
79
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topRight, {
80
+ top: '16px',
81
+ right: '16px'
82
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomRight, {
83
+ bottom: '16px',
84
+ right: '16px'
85
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomLeft, {
86
+ bottom: '16px',
87
+ left: '16px'
88
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topLeftEdge, {
89
+ top: '-8px',
90
+ left: '16px'
91
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.topRightEdge, {
92
+ top: '-8px',
93
+ right: '16px'
94
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomRightEdge, {
95
+ bottom: '-8px',
96
+ right: '16px'
97
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.bottomLeftEdge, {
98
+ bottom: '-8px',
99
+ left: '16px'
100
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.leftTopEdge, {
101
+ top: '16px',
102
+ left: '-8px'
103
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.rightTopEdge, {
104
+ top: '16px',
105
+ right: '-8px'
106
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.rightBottomEdge, {
107
+ bottom: '16px',
108
+ right: '-8px'
109
+ }), _defineProperty(_ROLE$badge, _constants.PLACEMENT.leftBottomEdge, {
110
+ bottom: '16px',
111
+ left: '-8px'
112
+ }), _ROLE$badge)), _defineProperty(_Object$freeze, _constants.ROLE.notificationCircle, (_ROLE$notificationCir = {}, _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topLeft, {
113
+ top: '-10px',
114
+ left: '-10px'
115
+ }), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topRight, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomRight, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomLeft, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topLeftEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.topRightEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomRightEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.bottomLeftEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.leftTopEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.rightTopEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.rightBottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _defineProperty(_ROLE$notificationCir, _constants.PLACEMENT.leftBottomEdge, DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT), _ROLE$notificationCir)), _defineProperty(_Object$freeze, _constants.ROLE.hintDot, (_ROLE$hintDot = {}, _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topLeft, {
116
+ top: '-4px',
117
+ left: '-4px'
118
+ }), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topRight, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomRight, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomLeft, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topLeftEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.topRightEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomRightEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.bottomLeftEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.leftTopEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.rightTopEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.rightBottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _defineProperty(_ROLE$hintDot, _constants.PLACEMENT.leftBottomEdge, DEFAULT_HINT_DOT_PLACEMENT), _ROLE$hintDot)), _Object$freeze));
119
+ var StyledRoot = (0, _index.styled)('div', function () {
120
+ return {
121
+ position: 'relative',
122
+ display: 'inline-block',
123
+ lineHeight: 'initial'
124
+ };
125
+ });
126
+ exports.StyledRoot = StyledRoot;
127
+ StyledRoot.displayName = "StyledRoot";
128
+ var TOP_PLACEMENTS = [_constants.PLACEMENT.topLeft, _constants.PLACEMENT.topRight, _constants.PLACEMENT.topLeftEdge, _constants.PLACEMENT.topEdge, _constants.PLACEMENT.topRightEdge, _constants.PLACEMENT.leftTopEdge, _constants.PLACEMENT.rightTopEdge];
129
+ var BOTTOM_PLACEMENTS = [_constants.PLACEMENT.bottomLeft, _constants.PLACEMENT.bottomRight, _constants.PLACEMENT.bottomLeftEdge, _constants.PLACEMENT.bottomEdge, _constants.PLACEMENT.bottomRightEdge, _constants.PLACEMENT.leftBottomEdge, _constants.PLACEMENT.rightBottomEdge];
130
+ var LEFT_PLACEMENTS = [_constants.PLACEMENT.topLeft, _constants.PLACEMENT.topLeftEdge, _constants.PLACEMENT.topEdge, _constants.PLACEMENT.bottomLeft, _constants.PLACEMENT.bottomLeftEdge, _constants.PLACEMENT.bottomEdge, _constants.PLACEMENT.leftTopEdge, _constants.PLACEMENT.leftBottomEdge];
131
+ var RIGHT_PLACEMENTS = [_constants.PLACEMENT.topRight, _constants.PLACEMENT.topRightEdge, _constants.PLACEMENT.bottomRight, _constants.PLACEMENT.bottomRightEdge, _constants.PLACEMENT.rightTopEdge, _constants.PLACEMENT.rightBottomEdge];
132
+ var StyledPositioner = (0, _index.styled)('div', function (_ref2) {
133
+ var $theme = _ref2.$theme,
134
+ $role = _ref2.$role,
135
+ $placement = _ref2.$placement,
136
+ $horizontalOffset = _ref2.$horizontalOffset,
137
+ $verticalOffset = _ref2.$verticalOffset;
138
+ var positionStyle = POSITION_STYLES[$role][$placement];
139
+
140
+ if ($verticalOffset) {
141
+ if (TOP_PLACEMENTS.includes($placement)) {
142
+ positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
143
+ top: $verticalOffset
144
+ });
145
+ }
146
+
147
+ if (BOTTOM_PLACEMENTS.includes($placement)) {
148
+ positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
149
+ bottom: $verticalOffset
150
+ });
151
+ }
152
+ }
153
+
154
+ if ($horizontalOffset) {
155
+ if (LEFT_PLACEMENTS.includes($placement)) {
156
+ positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
157
+ left: $horizontalOffset
158
+ });
159
+ }
160
+
161
+ if (RIGHT_PLACEMENTS.includes($placement)) {
162
+ positionStyle = _objectSpread(_objectSpread({}, positionStyle), {}, {
163
+ right: $horizontalOffset
164
+ });
165
+ }
166
+ }
167
+
168
+ return _objectSpread(_objectSpread({}, positionStyle), {}, {
169
+ position: 'absolute',
170
+ lineHeight: 'initial'
171
+ });
172
+ });
173
+ exports.StyledPositioner = StyledPositioner;
174
+ StyledPositioner.displayName = "StyledPositioner";
175
+ var StyledBadge = (0, _index.styled)('div', function (_ref3) {
176
+ var $theme = _ref3.$theme,
177
+ _ref3$$shape = _ref3.$shape,
178
+ $shape = _ref3$$shape === void 0 ? _constants.SHAPE.rectangle : _ref3$$shape,
179
+ _ref3$$color = _ref3.$color,
180
+ $color = _ref3$$color === void 0 ? _constants.COLOR.accent : _ref3$$color,
181
+ _ref3$$hierarchy = _ref3.$hierarchy,
182
+ $hierarchy = _ref3$$hierarchy === void 0 ? _constants.HIERARCHY.primary : _ref3$$hierarchy,
183
+ $hidden = _ref3.$hidden;
184
+ return _objectSpread(_objectSpread({
185
+ visibility: $hidden ? 'hidden' : 'inherit',
186
+ boxSizing: 'border-box',
187
+ height: $theme.sizing.scale700,
188
+ borderRadius: $shape === _constants.SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
189
+ paddingRight: $shape === _constants.SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
190
+ paddingLeft: $shape === _constants.SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
191
+ display: 'inline-flex',
192
+ alignItems: 'center'
193
+ }, getColorStyles({
194
+ $theme: $theme,
195
+ $hierarchy: $hierarchy,
196
+ $color: $color
197
+ })), $hierarchy === _constants.HIERARCHY.primary ? $theme.typography.LabelSmall : $theme.typography.ParagraphSmall);
198
+ });
199
+ exports.StyledBadge = StyledBadge;
200
+ StyledBadge.displayName = "StyledBadge";
201
+ var StyledNotificationCircle = (0, _index.styled)('div', function (_ref4) {
202
+ var $theme = _ref4.$theme,
203
+ _ref4$$color = _ref4.$color,
204
+ $color = _ref4$$color === void 0 ? _constants.COLOR.accent : _ref4$$color,
205
+ $hidden = _ref4.$hidden;
206
+ return _objectSpread(_objectSpread({
207
+ visibility: $hidden ? 'hidden' : 'inherit',
208
+ height: $theme.sizing.scale700,
209
+ width: $theme.sizing.scale700,
210
+ borderRadius: '20px',
211
+ display: 'inline-flex',
212
+ alignItems: 'center',
213
+ justifyContent: 'center'
214
+ }, getColorStyles({
215
+ $theme: $theme,
216
+ $hierarchy: _constants.HIERARCHY.primary,
217
+ $color: $color
218
+ })), $theme.typography.LabelXSmall);
219
+ });
220
+ exports.StyledNotificationCircle = StyledNotificationCircle;
221
+ StyledNotificationCircle.displayName = "StyledNotificationCircle";
222
+ var StyledHintDot = (0, _index.styled)('div', function (_ref5) {
223
+ var $theme = _ref5.$theme,
224
+ _ref5$$color = _ref5.$color,
225
+ $color = _ref5$$color === void 0 ? _constants.COLOR.accent : _ref5$$color,
226
+ $hidden = _ref5.$hidden;
227
+ return _objectSpread({
228
+ visibility: $hidden ? 'hidden' : 'inherit',
229
+ backgroundColor: $theme.colors[$color],
230
+ boxSizing: 'content-box',
231
+ height: '8px',
232
+ width: '8px',
233
+ borderRadius: '50%',
234
+ border: "4px solid ".concat($theme.colors.backgroundPrimary)
235
+ }, getColorStyles({
236
+ $theme: $theme,
237
+ $hierarchy: _constants.HIERARCHY.primary,
238
+ $color: $color
239
+ }));
240
+ });
241
+ exports.StyledHintDot = StyledHintDot;
242
+ StyledHintDot.displayName = "StyledHintDot";
@@ -0,0 +1,325 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ // @flow
8
+ import { styled } from '../styles/index.js';
9
+ import type { PlacementT, ColorT, ShapeT, RoleT, HierarchyT } from './types.js';
10
+ import { COLOR, SHAPE, ROLE, PLACEMENT, HIERARCHY } from './constants.js';
11
+
12
+ function getColorStyles({ $theme, $hierarchy, $color }): {|
13
+ color: string,
14
+ backgroundColor: string,
15
+ |} {
16
+ const COLOR_STYLES = {
17
+ [HIERARCHY.primary]: {
18
+ [COLOR.accent]: {
19
+ color: $theme.colors.contentInversePrimary,
20
+ backgroundColor: $theme.colors.backgroundAccent,
21
+ },
22
+ [COLOR.primary]: {
23
+ color: $theme.colors.contentInversePrimary,
24
+ backgroundColor: $theme.colors.backgroundInversePrimary,
25
+ },
26
+ [COLOR.positive]: {
27
+ color: $theme.colors.contentInversePrimary,
28
+ backgroundColor: $theme.colors.backgroundPositive,
29
+ },
30
+ [COLOR.negative]: {
31
+ color: $theme.colors.contentInversePrimary,
32
+ backgroundColor: $theme.colors.backgroundNegative,
33
+ },
34
+ [COLOR.warning]: {
35
+ color: $theme.colors.primaryA,
36
+ backgroundColor: $theme.colors.backgroundWarning,
37
+ },
38
+ },
39
+ [HIERARCHY.secondary]: {
40
+ [COLOR.accent]: {
41
+ color: $theme.colors.contentAccent,
42
+ backgroundColor: $theme.colors.backgroundLightAccent,
43
+ },
44
+ [COLOR.primary]: {
45
+ color: $theme.colors.primaryA,
46
+ backgroundColor: $theme.colors.backgroundSecondary,
47
+ },
48
+ [COLOR.positive]: {
49
+ color: $theme.colors.contentPositive,
50
+ backgroundColor: $theme.colors.backgroundLightPositive,
51
+ },
52
+ [COLOR.negative]: {
53
+ color: $theme.colors.contentNegative,
54
+ backgroundColor: $theme.colors.backgroundLightNegative,
55
+ },
56
+ [COLOR.warning]: {
57
+ color: $theme.colors.contentWarning,
58
+ backgroundColor: $theme.colors.backgroundLightWarning,
59
+ },
60
+ },
61
+ };
62
+
63
+ return COLOR_STYLES[$hierarchy][$color];
64
+ }
65
+
66
+ const DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
67
+ top: '-10px',
68
+ right: '-10px',
69
+ };
70
+
71
+ const DEFAULT_HINT_DOT_PLACEMENT = {
72
+ top: '-4px',
73
+ right: '-4px',
74
+ };
75
+
76
+ const POSITION_STYLES = Object.freeze({
77
+ [ROLE.badge]: {
78
+ [PLACEMENT.topEdge]: {
79
+ top: '-8px',
80
+ left: '50%',
81
+ transform: 'translateX(-50%)',
82
+ },
83
+ [PLACEMENT.bottomEdge]: {
84
+ bottom: '-8px',
85
+ left: '50%',
86
+ transform: 'translateX(-50%)',
87
+ },
88
+ [PLACEMENT.topLeft]: {
89
+ top: '16px',
90
+ left: '16px',
91
+ },
92
+ [PLACEMENT.topRight]: {
93
+ top: '16px',
94
+ right: '16px',
95
+ },
96
+ [PLACEMENT.bottomRight]: {
97
+ bottom: '16px',
98
+ right: '16px',
99
+ },
100
+
101
+ [PLACEMENT.bottomLeft]: {
102
+ bottom: '16px',
103
+ left: '16px',
104
+ },
105
+ [PLACEMENT.topLeftEdge]: {
106
+ top: '-8px',
107
+ left: '16px',
108
+ },
109
+ [PLACEMENT.topRightEdge]: {
110
+ top: '-8px',
111
+ right: '16px',
112
+ },
113
+ [PLACEMENT.bottomRightEdge]: {
114
+ bottom: '-8px',
115
+ right: '16px',
116
+ },
117
+ [PLACEMENT.bottomLeftEdge]: {
118
+ bottom: '-8px',
119
+ left: '16px',
120
+ },
121
+ [PLACEMENT.leftTopEdge]: {
122
+ top: '16px',
123
+ left: '-8px',
124
+ },
125
+ [PLACEMENT.rightTopEdge]: {
126
+ top: '16px',
127
+ right: '-8px',
128
+ },
129
+ [PLACEMENT.rightBottomEdge]: {
130
+ bottom: '16px',
131
+ right: '-8px',
132
+ },
133
+ [PLACEMENT.leftBottomEdge]: {
134
+ bottom: '16px',
135
+ left: '-8px',
136
+ },
137
+ },
138
+ [ROLE.notificationCircle]: {
139
+ [PLACEMENT.topLeft]: {
140
+ top: '-10px',
141
+ left: '-10px',
142
+ },
143
+ [PLACEMENT.topRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
144
+ // NotificationCircle can only be placed topLeft or topRight, other values fall back to topRight
145
+ [PLACEMENT.topEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
146
+ [PLACEMENT.bottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
147
+ [PLACEMENT.bottomRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
148
+ [PLACEMENT.bottomLeft]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
149
+ [PLACEMENT.topLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
150
+ [PLACEMENT.topRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
151
+ [PLACEMENT.bottomRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
152
+ [PLACEMENT.bottomLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
153
+ [PLACEMENT.leftTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
154
+ [PLACEMENT.rightTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
155
+ [PLACEMENT.rightBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
156
+ [PLACEMENT.leftBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
157
+ },
158
+ [ROLE.hintDot]: {
159
+ [PLACEMENT.topLeft]: {
160
+ top: '-4px',
161
+ left: '-4px',
162
+ },
163
+ [PLACEMENT.topRight]: DEFAULT_HINT_DOT_PLACEMENT,
164
+ // HintDot can only be placed topLeft or topRight, other values fall back to topRight
165
+ [PLACEMENT.topEdge]: DEFAULT_HINT_DOT_PLACEMENT,
166
+ [PLACEMENT.bottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
167
+ [PLACEMENT.bottomRight]: DEFAULT_HINT_DOT_PLACEMENT,
168
+ [PLACEMENT.bottomLeft]: DEFAULT_HINT_DOT_PLACEMENT,
169
+ [PLACEMENT.topLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
170
+ [PLACEMENT.topRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
171
+ [PLACEMENT.bottomRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
172
+ [PLACEMENT.bottomLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
173
+ [PLACEMENT.leftTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
174
+ [PLACEMENT.rightTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
175
+ [PLACEMENT.rightBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
176
+ [PLACEMENT.leftBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
177
+ },
178
+ });
179
+
180
+ export const StyledRoot = styled<{}>('div', () => {
181
+ return {
182
+ position: 'relative',
183
+ display: 'inline-block',
184
+ lineHeight: 'initial',
185
+ };
186
+ });
187
+
188
+ const TOP_PLACEMENTS = [
189
+ PLACEMENT.topLeft,
190
+ PLACEMENT.topRight,
191
+ PLACEMENT.topLeftEdge,
192
+ PLACEMENT.topEdge,
193
+ PLACEMENT.topRightEdge,
194
+ PLACEMENT.leftTopEdge,
195
+ PLACEMENT.rightTopEdge,
196
+ ];
197
+ const BOTTOM_PLACEMENTS = [
198
+ PLACEMENT.bottomLeft,
199
+ PLACEMENT.bottomRight,
200
+ PLACEMENT.bottomLeftEdge,
201
+ PLACEMENT.bottomEdge,
202
+ PLACEMENT.bottomRightEdge,
203
+ PLACEMENT.leftBottomEdge,
204
+ PLACEMENT.rightBottomEdge,
205
+ ];
206
+ const LEFT_PLACEMENTS = [
207
+ PLACEMENT.topLeft,
208
+ PLACEMENT.topLeftEdge,
209
+ PLACEMENT.topEdge,
210
+ PLACEMENT.bottomLeft,
211
+ PLACEMENT.bottomLeftEdge,
212
+ PLACEMENT.bottomEdge,
213
+ PLACEMENT.leftTopEdge,
214
+ PLACEMENT.leftBottomEdge,
215
+ ];
216
+ const RIGHT_PLACEMENTS = [
217
+ PLACEMENT.topRight,
218
+ PLACEMENT.topRightEdge,
219
+ PLACEMENT.bottomRight,
220
+ PLACEMENT.bottomRightEdge,
221
+ PLACEMENT.rightTopEdge,
222
+ PLACEMENT.rightBottomEdge,
223
+ ];
224
+
225
+ export const StyledPositioner = styled<{
226
+ $role: RoleT,
227
+ $placement: PlacementT,
228
+ $horizontalOffset?: ?string,
229
+ $verticalOffset?: ?string,
230
+ }>('div', ({ $theme, $role, $placement, $horizontalOffset, $verticalOffset }) => {
231
+ let positionStyle = POSITION_STYLES[$role][$placement];
232
+
233
+ if ($verticalOffset) {
234
+ if (TOP_PLACEMENTS.includes($placement)) {
235
+ positionStyle = { ...positionStyle, top: $verticalOffset };
236
+ }
237
+ if (BOTTOM_PLACEMENTS.includes($placement)) {
238
+ positionStyle = { ...positionStyle, bottom: $verticalOffset };
239
+ }
240
+ }
241
+
242
+ if ($horizontalOffset) {
243
+ if (LEFT_PLACEMENTS.includes($placement)) {
244
+ positionStyle = { ...positionStyle, left: $horizontalOffset };
245
+ }
246
+ if (RIGHT_PLACEMENTS.includes($placement)) {
247
+ positionStyle = { ...positionStyle, right: $horizontalOffset };
248
+ }
249
+ }
250
+
251
+ return {
252
+ ...positionStyle,
253
+ position: 'absolute',
254
+ lineHeight: 'initial',
255
+ };
256
+ });
257
+
258
+ export const StyledBadge = styled<{
259
+ $shape?: ShapeT,
260
+ $color?: ColorT,
261
+ $hierarchy?: HierarchyT,
262
+ $hidden?: boolean,
263
+ }>(
264
+ 'div',
265
+ ({
266
+ $theme,
267
+ $shape = SHAPE.rectangle,
268
+ $color = COLOR.accent,
269
+ $hierarchy = HIERARCHY.primary,
270
+ $hidden,
271
+ }) => {
272
+ return {
273
+ visibility: $hidden ? 'hidden' : 'inherit',
274
+ boxSizing: 'border-box',
275
+ height: $theme.sizing.scale700,
276
+ borderRadius:
277
+ $shape === SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
278
+ paddingRight: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
279
+ paddingLeft: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
280
+ display: 'inline-flex',
281
+ alignItems: 'center',
282
+ ...getColorStyles({ $theme, $hierarchy, $color }),
283
+ ...($hierarchy === HIERARCHY.primary
284
+ ? $theme.typography.LabelSmall
285
+ : $theme.typography.ParagraphSmall),
286
+ };
287
+ }
288
+ );
289
+
290
+ export const StyledNotificationCircle = styled<{
291
+ $color?: ColorT,
292
+ $hidden?: boolean,
293
+ }>('div', ({ $theme, $color = COLOR.accent, $hidden }) => {
294
+ return {
295
+ visibility: $hidden ? 'hidden' : 'inherit',
296
+ height: $theme.sizing.scale700,
297
+ width: $theme.sizing.scale700,
298
+ borderRadius: '20px',
299
+ display: 'inline-flex',
300
+ alignItems: 'center',
301
+ justifyContent: 'center',
302
+ ...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
303
+ ...$theme.typography.LabelXSmall,
304
+ };
305
+ });
306
+
307
+ export const StyledHintDot = styled<{ $color: ColorT, $hidden?: boolean }>(
308
+ 'div',
309
+ ({ $theme, $color = COLOR.accent, $hidden }) => {
310
+ return {
311
+ visibility: $hidden ? 'hidden' : 'inherit',
312
+ backgroundColor: $theme.colors[$color],
313
+ boxSizing: 'content-box',
314
+ height: '8px',
315
+ width: '8px',
316
+ borderRadius: '50%',
317
+ border: `4px solid ${$theme.colors.backgroundPrimary}`,
318
+ ...getColorStyles({ $theme, $hierarchy: HIERARCHY.primary, $color }),
319
+ };
320
+ }
321
+ );
322
+
323
+ declare var __DEV__: boolean;
324
+ declare var __NODE__: boolean;
325
+ declare var __BROWSER__: boolean;
package/badge/types.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ var React = _interopRequireWildcard(require("react"));
6
+
7
+ var _constants = require("./constants.js");
8
+
9
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
10
+
11
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,59 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ // @flow
8
+ import * as React from 'react';
9
+ import { HIERARCHY, SHAPE, COLOR, PLACEMENT, ROLE } from './constants.js';
10
+ import type { OverrideT } from '../helpers/overrides.js';
11
+
12
+ export type HierarchyT = $Values<typeof HIERARCHY>;
13
+ export type ShapeT = $Values<typeof SHAPE>;
14
+ export type ColorT = $Values<typeof COLOR>;
15
+ export type PlacementT = $Values<typeof PLACEMENT>;
16
+ export type RoleT = $Values<typeof ROLE>;
17
+
18
+ export type BadgeOverridesT = {
19
+ Root?: OverrideT,
20
+ Positioner?: OverrideT,
21
+ Badge?: OverrideT,
22
+ };
23
+
24
+ export type BadgePropsT = {
25
+ content: React.Node,
26
+ hierarchy?: HierarchyT,
27
+ shape?: ShapeT,
28
+ color?: ColorT,
29
+ placement?: PlacementT,
30
+ hidden?: boolean,
31
+ horizontalOffset?: string,
32
+ verticalOffset?: string,
33
+ overrides?: BadgeOverridesT,
34
+ children?: React.Node,
35
+ };
36
+
37
+ export type NotificationCirclePropsT = {
38
+ content: React.Node,
39
+ color?: ColorT,
40
+ placement?: PlacementT,
41
+ hidden?: boolean,
42
+ horizontalOffset?: string,
43
+ verticalOffset?: string,
44
+ overrides?: BadgeOverridesT,
45
+ children?: React.Node,
46
+ };
47
+
48
+ export type HintDotPropsT = {
49
+ color?: ColorT,
50
+ hidden?: boolean,
51
+ horizontalOffset?: string,
52
+ verticalOffset?: string,
53
+ overrides?: BadgeOverridesT,
54
+ children?: React.Node,
55
+ };
56
+
57
+ declare var __DEV__: boolean;
58
+ declare var __NODE__: boolean;
59
+ declare var __BROWSER__: boolean;
package/badge/utils.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getAnchorFromChildren = void 0;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
13
+
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ /*
17
+ Copyright (c) Uber Technologies, Inc.
18
+
19
+ This source code is licensed under the MIT license found in the
20
+ LICENSE file in the root directory of this source tree.
21
+ */
22
+ var getAnchorFromChildren = function getAnchorFromChildren(children) {
23
+ var childArray = React.Children.toArray(children);
24
+
25
+ if (childArray.length !== 1) {
26
+ // eslint-disable-next-line no-console
27
+ console.error("[baseui] No more than 1 child may be passed to Badge, found ".concat(childArray.length, " children"));
28
+ }
29
+
30
+ return childArray[0];
31
+ };
32
+
33
+ exports.getAnchorFromChildren = getAnchorFromChildren;