baseui 11.0.1 → 11.1.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 (266) 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 +49 -29
  7. package/app-nav-bar/styled-components.js.flow +25 -8
  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/calendar.js +16 -11
  54. package/datepicker/calendar.js.flow +12 -9
  55. package/datepicker/datepicker.js +58 -58
  56. package/datepicker/datepicker.js.flow +51 -34
  57. package/datepicker/index.d.ts +42 -63
  58. package/datepicker/stateful-calendar.js +6 -1
  59. package/datepicker/stateful-calendar.js.flow +8 -1
  60. package/datepicker/stateful-container.js +23 -2
  61. package/datepicker/stateful-container.js.flow +17 -4
  62. package/datepicker/stateful-datepicker.js +6 -1
  63. package/datepicker/stateful-datepicker.js.flow +7 -1
  64. package/datepicker/types.js.flow +21 -43
  65. package/datepicker/utils/date-helpers.js +1 -1
  66. package/datepicker/utils/date-helpers.js.flow +1 -1
  67. package/dnd-list/index.d.ts +22 -35
  68. package/drawer/index.d.ts +22 -27
  69. package/es/app-nav-bar/app-nav-bar.js +9 -19
  70. package/es/app-nav-bar/styled-components.js +32 -13
  71. package/es/badge/badge.js +70 -0
  72. package/es/badge/constants.js +42 -0
  73. package/es/badge/hint-dot.js +55 -0
  74. package/es/badge/index.js +11 -0
  75. package/es/badge/notification-circle.js +65 -0
  76. package/es/badge/styled-components.js +296 -0
  77. package/es/badge/types.js +8 -0
  78. package/es/badge/utils.js +17 -0
  79. package/es/banner/banner.js +213 -0
  80. package/es/banner/constants.js +24 -0
  81. package/es/banner/index.js +9 -0
  82. package/es/banner/styled-components.js +122 -0
  83. package/es/banner/types.js +8 -0
  84. package/es/breadcrumbs/breadcrumbs.js +5 -1
  85. package/es/button/button.js +1 -0
  86. package/es/datepicker/calendar.js +15 -10
  87. package/es/datepicker/datepicker.js +52 -52
  88. package/es/datepicker/stateful-calendar.js +6 -1
  89. package/es/datepicker/stateful-container.js +22 -2
  90. package/es/datepicker/stateful-datepicker.js +6 -1
  91. package/es/datepicker/utils/date-helpers.js +1 -1
  92. package/es/helper/helper-steps.js +3 -1
  93. package/es/input/base-input.js +18 -11
  94. package/es/input/input.js +15 -10
  95. package/es/input/masked-input.js +5 -2
  96. package/es/input/utils.js +4 -2
  97. package/es/locale/tr_TR.js +115 -0
  98. package/es/notification/notification.js +16 -1
  99. package/es/payment-card/custom-cards.config.js +22 -0
  100. package/es/payment-card/icons/uatp.js +52 -0
  101. package/es/payment-card/payment-card.js +8 -3
  102. package/es/popover/popover.js +2 -1
  103. package/es/popover/stateful-container.js +2 -0
  104. package/es/popover/styled-components.js +2 -1
  105. package/es/progress-steps/numbered-step.js +2 -2
  106. package/es/select/select-component.js +48 -23
  107. package/es/select/utils/default-filter-options.js +1 -1
  108. package/es/snackbar/snackbar-context.js +1 -1
  109. package/es/table-semantic/styled-components.js +14 -0
  110. package/es/table-semantic/table-builder.js +12 -5
  111. package/es/textarea/textarea.js +15 -9
  112. package/es/themes/dark-theme/color-component-tokens.js +8 -0
  113. package/es/themes/light-theme/color-component-tokens.js +8 -0
  114. package/es/tree-view/tree-label.js +9 -1
  115. package/esm/app-nav-bar/app-nav-bar.js +32 -38
  116. package/esm/app-nav-bar/styled-components.js +46 -28
  117. package/esm/badge/badge.js +97 -0
  118. package/esm/badge/constants.js +42 -0
  119. package/esm/badge/hint-dot.js +83 -0
  120. package/esm/badge/index.js +11 -0
  121. package/esm/badge/notification-circle.js +91 -0
  122. package/esm/badge/styled-components.js +235 -0
  123. package/esm/badge/types.js +8 -0
  124. package/esm/badge/utils.js +17 -0
  125. package/esm/banner/banner.js +271 -0
  126. package/esm/banner/constants.js +24 -0
  127. package/esm/banner/index.js +9 -0
  128. package/esm/banner/styled-components.js +113 -0
  129. package/esm/banner/types.js +8 -0
  130. package/esm/breadcrumbs/breadcrumbs.js +5 -1
  131. package/esm/button/button.js +2 -1
  132. package/esm/datepicker/calendar.js +16 -11
  133. package/esm/datepicker/datepicker.js +58 -58
  134. package/esm/datepicker/stateful-calendar.js +6 -1
  135. package/esm/datepicker/stateful-container.js +23 -2
  136. package/esm/datepicker/stateful-datepicker.js +6 -1
  137. package/esm/datepicker/utils/date-helpers.js +1 -1
  138. package/esm/helper/helper-steps.js +3 -1
  139. package/esm/input/base-input.js +18 -11
  140. package/esm/input/input.js +15 -10
  141. package/esm/input/masked-input.js +6 -3
  142. package/esm/input/utils.js +4 -2
  143. package/esm/locale/tr_TR.js +115 -0
  144. package/esm/notification/notification.js +17 -1
  145. package/esm/payment-card/custom-cards.config.js +22 -0
  146. package/esm/payment-card/icons/uatp.js +53 -0
  147. package/esm/payment-card/payment-card.js +9 -7
  148. package/esm/popover/popover.js +2 -1
  149. package/esm/popover/stateful-container.js +2 -0
  150. package/esm/popover/styled-components.js +3 -2
  151. package/esm/progress-steps/numbered-step.js +2 -2
  152. package/esm/select/select-component.js +85 -59
  153. package/esm/select/utils/default-filter-options.js +1 -1
  154. package/esm/snackbar/snackbar-context.js +1 -1
  155. package/esm/table-semantic/styled-components.js +31 -18
  156. package/esm/table-semantic/table-builder.js +34 -23
  157. package/esm/textarea/textarea.js +15 -9
  158. package/esm/themes/dark-theme/color-component-tokens.js +8 -0
  159. package/esm/themes/light-theme/color-component-tokens.js +8 -0
  160. package/esm/tree-view/tree-label.js +10 -2
  161. package/file-uploader/index.d.ts +11 -11
  162. package/flex-grid/index.d.ts +3 -3
  163. package/form-control/index.d.ts +7 -19
  164. package/header-navigation/index.d.ts +8 -9
  165. package/heading/index.d.ts +3 -4
  166. package/helper/helper-steps.js +19 -13
  167. package/helper/helper-steps.js.flow +3 -1
  168. package/helper/index.d.ts +7 -7
  169. package/helpers/base-provider.d.ts +16 -0
  170. package/helpers/overrides.d.ts +23 -0
  171. package/icon/index.d.ts +32 -32
  172. package/index.d.ts +34 -114
  173. package/input/base-input.js +18 -11
  174. package/input/base-input.js.flow +18 -6
  175. package/input/index.d.ts +29 -32
  176. package/input/input.js +15 -10
  177. package/input/input.js.flow +10 -5
  178. package/input/masked-input.js +6 -3
  179. package/input/masked-input.js.flow +3 -0
  180. package/input/types.js.flow +4 -0
  181. package/input/utils.js +4 -2
  182. package/input/utils.js.flow +2 -1
  183. package/layer/index.d.ts +6 -11
  184. package/layout-grid/index.d.ts +25 -7
  185. package/link/index.d.ts +2 -2
  186. package/list/index.d.ts +26 -31
  187. package/{locale.ts → locale/index.d.ts} +8 -0
  188. package/locale/tr_TR.js +123 -0
  189. package/locale/tr_TR.js.flow +124 -0
  190. package/map-marker/index.d.ts +41 -47
  191. package/menu/index.d.ts +27 -37
  192. package/modal/index.d.ts +28 -38
  193. package/notification/index.d.ts +2 -3
  194. package/notification/notification.js +18 -1
  195. package/notification/notification.js.flow +15 -1
  196. package/overrides.ts +2 -22
  197. package/package.json +26 -17
  198. package/pagination/index.d.ts +22 -26
  199. package/payment-card/custom-cards.config.js +30 -0
  200. package/payment-card/custom-cards.config.js.flow +29 -0
  201. package/payment-card/icons/uatp.js +67 -0
  202. package/payment-card/icons/uatp.js.flow +62 -0
  203. package/payment-card/index.d.ts +8 -8
  204. package/payment-card/payment-card.js +12 -7
  205. package/payment-card/payment-card.js.flow +12 -0
  206. package/phone-input/index.d.ts +261 -269
  207. package/pin-code/index.d.ts +11 -18
  208. package/popover/index.d.ts +39 -55
  209. package/popover/popover.js +2 -1
  210. package/popover/popover.js.flow +2 -1
  211. package/popover/stateful-container.js +2 -0
  212. package/popover/stateful-container.js.flow +2 -0
  213. package/popover/styled-components.js +3 -2
  214. package/popover/styled-components.js.flow +2 -1
  215. package/popover/types.js.flow +1 -0
  216. package/progress-bar/index.d.ts +11 -12
  217. package/progress-steps/index.d.ts +16 -16
  218. package/progress-steps/numbered-step.js.flow +2 -2
  219. package/radio/index.d.ts +12 -15
  220. package/rating/index.d.ts +9 -12
  221. package/select/index.d.ts +34 -36
  222. package/select/select-component.js +82 -56
  223. package/select/select-component.js.flow +46 -34
  224. package/select/types.js.flow +1 -0
  225. package/select/utils/default-filter-options.js +1 -1
  226. package/select/utils/default-filter-options.js.flow +1 -1
  227. package/side-navigation/index.d.ts +11 -13
  228. package/skeleton/index.d.ts +1 -1
  229. package/slider/index.d.ts +17 -26
  230. package/snackbar/index.d.ts +8 -8
  231. package/snackbar/snackbar-context.js +1 -1
  232. package/snackbar/snackbar-context.js.flow +1 -1
  233. package/spinner/index.d.ts +4 -3
  234. package/styles/index.d.ts +82 -2
  235. package/table/index.d.ts +16 -16
  236. package/table-grid/index.d.ts +6 -8
  237. package/table-semantic/index.d.ts +26 -32
  238. package/table-semantic/styled-components.js +33 -19
  239. package/table-semantic/styled-components.js.flow +12 -0
  240. package/table-semantic/table-builder.js +38 -22
  241. package/table-semantic/table-builder.js.flow +32 -17
  242. package/table-semantic/types.js.flow +1 -0
  243. package/tabs/index.d.ts +20 -23
  244. package/tabs-motion/index.d.ts +23 -23
  245. package/tag/index.d.ts +14 -18
  246. package/tag/types.js.flow +1 -1
  247. package/textarea/index.d.ts +11 -14
  248. package/textarea/textarea.js +15 -9
  249. package/textarea/textarea.js.flow +11 -5
  250. package/textarea/types.js.flow +1 -0
  251. package/theme.ts +36 -777
  252. package/themes/dark-theme/color-component-tokens.js +8 -0
  253. package/themes/dark-theme/color-component-tokens.js.flow +9 -0
  254. package/themes/index.d.ts +765 -0
  255. package/themes/light-theme/color-component-tokens.js +8 -0
  256. package/themes/light-theme/color-component-tokens.js.flow +9 -0
  257. package/themes/types.js.flow +9 -0
  258. package/timepicker/index.d.ts +5 -8
  259. package/timezonepicker/index.d.ts +5 -8
  260. package/toast/index.d.ts +26 -40
  261. package/tokens/index.d.ts +1 -1
  262. package/tooltip/index.d.ts +7 -9
  263. package/tree-view/index.d.ts +15 -19
  264. package/tree-view/tree-label.js +10 -2
  265. package/tree-view/tree-label.js.flow +4 -4
  266. package/typography/index.d.ts +37 -37
@@ -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;
@@ -0,0 +1,23 @@
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
+
10
+ export const getAnchorFromChildren = (children: ?React.Node) => {
11
+ const childArray = React.Children.toArray(children);
12
+ if (childArray.length !== 1) {
13
+ // eslint-disable-next-line no-console
14
+ console.error(
15
+ `[baseui] No more than 1 child may be passed to Badge, found ${childArray.length} children`
16
+ );
17
+ }
18
+ return childArray[0];
19
+ };
20
+
21
+ declare var __DEV__: boolean;
22
+ declare var __NODE__: boolean;
23
+ declare var __BROWSER__: boolean;