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,55 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ /*
4
+ Copyright (c) Uber Technologies, Inc.
5
+
6
+ This source code is licensed under the MIT license found in the
7
+ LICENSE file in the root directory of this source tree.
8
+ */
9
+ import * as React from 'react';
10
+ import { useStyletron } from '../styles/index.js';
11
+ import { getOverrides } from '../helpers/overrides.js';
12
+ import { StyledHintDot, StyledRoot, StyledPositioner } from './styled-components.js';
13
+ import { PLACEMENT, ROLE } from './constants.js';
14
+ import { getAnchorFromChildren } from './utils.js';
15
+
16
+ const HintDot = ({
17
+ children,
18
+ color,
19
+ horizontalOffset: horizontalOffsetProp,
20
+ verticalOffset: verticalOffsetProp,
21
+ hidden,
22
+ overrides = {}
23
+ }) => {
24
+ const [HintDot, hintDotProps] = getOverrides(overrides.Badge, StyledHintDot);
25
+ const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
26
+ const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
27
+ const [, theme] = useStyletron();
28
+ const anchor = getAnchorFromChildren(children); // if the anchor is a string, we supply default offsets
29
+
30
+ let horizontalOffset = horizontalOffsetProp;
31
+ let verticalOffset = verticalOffsetProp;
32
+
33
+ if (typeof anchor === 'string') {
34
+ if (!horizontalOffset) {
35
+ horizontalOffset = '-14px';
36
+ }
37
+
38
+ if (!verticalOffset) {
39
+ verticalOffset = '-4px';
40
+ }
41
+ }
42
+
43
+ return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
44
+ $horizontalOffset: horizontalOffset,
45
+ $verticalOffset: verticalOffset,
46
+ $placement: theme.direction === 'rtl' ? PLACEMENT.topLeft : PLACEMENT.topRight,
47
+ $role: ROLE.hintDot
48
+ }, positionerProps), /*#__PURE__*/React.createElement(HintDot, _extends({}, hintDotProps, {
49
+ $color: color,
50
+ $horizontalOffset: horizontalOffset,
51
+ $hidden: hidden
52
+ }))));
53
+ };
54
+
55
+ export default HintDot;
@@ -0,0 +1,11 @@
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
+ export { default as Badge } from './badge.js';
8
+ export { default as NotificationCircle } from './notification-circle.js';
9
+ export { default as HintDot } from './hint-dot.js';
10
+ export { HIERARCHY, SHAPE, COLOR, PLACEMENT } from './constants.js';
11
+ export * from './styled-components.js';
@@ -0,0 +1,65 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ /*
4
+ Copyright (c) Uber Technologies, Inc.
5
+
6
+ This source code is licensed under the MIT license found in the
7
+ LICENSE file in the root directory of this source tree.
8
+ */
9
+ import * as React from 'react';
10
+ import { getOverrides } from '../helpers/overrides.js';
11
+ import { StyledNotificationCircle, StyledRoot, StyledPositioner } from './styled-components.js';
12
+ import { PLACEMENT, ROLE } from './constants.js';
13
+ import { getAnchorFromChildren } from './utils.js';
14
+
15
+ const NotificationCircle = ({
16
+ children,
17
+ content: contentProp,
18
+ color,
19
+ placement = PLACEMENT.topRight,
20
+ horizontalOffset,
21
+ verticalOffset,
22
+ hidden,
23
+ overrides = {}
24
+ }) => {
25
+ const [NotificationCircle, NotificationCircleProps] = getOverrides(overrides.Badge, StyledNotificationCircle);
26
+ const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
27
+ const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
28
+ const anchor = getAnchorFromChildren(children);
29
+
30
+ if (process.env.NODE_ENV !== "production") {
31
+ if (typeof contentProp === 'string') {
32
+ console.error(`[baseui] NotificationCircle child must be number or icon, found string`);
33
+ }
34
+
35
+ if (placement && placement !== PLACEMENT.topLeft && placement !== PLACEMENT.topRight) {
36
+ console.error(`[baseui] NotificationCircle must be placed topLeft or topRight, found ${placement}`);
37
+ }
38
+ }
39
+
40
+ let content = contentProp;
41
+
42
+ if (typeof content === 'number' && content > 9) {
43
+ content = '9+';
44
+ } // If there's no anchor, render the badge inline
45
+
46
+
47
+ if (!anchor) {
48
+ return /*#__PURE__*/React.createElement(NotificationCircle, _extends({
49
+ $color: color,
50
+ $hidden: hidden
51
+ }, NotificationCircleProps), content);
52
+ }
53
+
54
+ return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
55
+ $horizontalOffset: horizontalOffset,
56
+ $verticalOffset: verticalOffset,
57
+ $placement: placement,
58
+ $role: ROLE.notificationCircle
59
+ }, positionerProps), /*#__PURE__*/React.createElement(NotificationCircle, _extends({}, NotificationCircleProps, {
60
+ $color: color,
61
+ $hidden: hidden
62
+ }), content)));
63
+ };
64
+
65
+ export default NotificationCircle;
@@ -0,0 +1,296 @@
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
+ import { styled } from '../styles/index.js';
8
+ import { COLOR, SHAPE, ROLE, PLACEMENT, HIERARCHY } from './constants.js';
9
+
10
+ function getColorStyles({
11
+ $theme,
12
+ $hierarchy,
13
+ $color
14
+ }) {
15
+ const COLOR_STYLES = {
16
+ [HIERARCHY.primary]: {
17
+ [COLOR.accent]: {
18
+ color: $theme.colors.contentInversePrimary,
19
+ backgroundColor: $theme.colors.backgroundAccent
20
+ },
21
+ [COLOR.primary]: {
22
+ color: $theme.colors.contentInversePrimary,
23
+ backgroundColor: $theme.colors.backgroundInversePrimary
24
+ },
25
+ [COLOR.positive]: {
26
+ color: $theme.colors.contentInversePrimary,
27
+ backgroundColor: $theme.colors.backgroundPositive
28
+ },
29
+ [COLOR.negative]: {
30
+ color: $theme.colors.contentInversePrimary,
31
+ backgroundColor: $theme.colors.backgroundNegative
32
+ },
33
+ [COLOR.warning]: {
34
+ color: $theme.colors.primaryA,
35
+ backgroundColor: $theme.colors.backgroundWarning
36
+ }
37
+ },
38
+ [HIERARCHY.secondary]: {
39
+ [COLOR.accent]: {
40
+ color: $theme.colors.contentAccent,
41
+ backgroundColor: $theme.colors.backgroundLightAccent
42
+ },
43
+ [COLOR.primary]: {
44
+ color: $theme.colors.primaryA,
45
+ backgroundColor: $theme.colors.backgroundSecondary
46
+ },
47
+ [COLOR.positive]: {
48
+ color: $theme.colors.contentPositive,
49
+ backgroundColor: $theme.colors.backgroundLightPositive
50
+ },
51
+ [COLOR.negative]: {
52
+ color: $theme.colors.contentNegative,
53
+ backgroundColor: $theme.colors.backgroundLightNegative
54
+ },
55
+ [COLOR.warning]: {
56
+ color: $theme.colors.contentWarning,
57
+ backgroundColor: $theme.colors.backgroundLightWarning
58
+ }
59
+ }
60
+ };
61
+ return COLOR_STYLES[$hierarchy][$color];
62
+ }
63
+
64
+ const DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
65
+ top: '-10px',
66
+ right: '-10px'
67
+ };
68
+ const DEFAULT_HINT_DOT_PLACEMENT = {
69
+ top: '-4px',
70
+ right: '-4px'
71
+ };
72
+ const POSITION_STYLES = Object.freeze({
73
+ [ROLE.badge]: {
74
+ [PLACEMENT.topEdge]: {
75
+ top: '-8px',
76
+ left: '50%',
77
+ transform: 'translateX(-50%)'
78
+ },
79
+ [PLACEMENT.bottomEdge]: {
80
+ bottom: '-8px',
81
+ left: '50%',
82
+ transform: 'translateX(-50%)'
83
+ },
84
+ [PLACEMENT.topLeft]: {
85
+ top: '16px',
86
+ left: '16px'
87
+ },
88
+ [PLACEMENT.topRight]: {
89
+ top: '16px',
90
+ right: '16px'
91
+ },
92
+ [PLACEMENT.bottomRight]: {
93
+ bottom: '16px',
94
+ right: '16px'
95
+ },
96
+ [PLACEMENT.bottomLeft]: {
97
+ bottom: '16px',
98
+ left: '16px'
99
+ },
100
+ [PLACEMENT.topLeftEdge]: {
101
+ top: '-8px',
102
+ left: '16px'
103
+ },
104
+ [PLACEMENT.topRightEdge]: {
105
+ top: '-8px',
106
+ right: '16px'
107
+ },
108
+ [PLACEMENT.bottomRightEdge]: {
109
+ bottom: '-8px',
110
+ right: '16px'
111
+ },
112
+ [PLACEMENT.bottomLeftEdge]: {
113
+ bottom: '-8px',
114
+ left: '16px'
115
+ },
116
+ [PLACEMENT.leftTopEdge]: {
117
+ top: '16px',
118
+ left: '-8px'
119
+ },
120
+ [PLACEMENT.rightTopEdge]: {
121
+ top: '16px',
122
+ right: '-8px'
123
+ },
124
+ [PLACEMENT.rightBottomEdge]: {
125
+ bottom: '16px',
126
+ right: '-8px'
127
+ },
128
+ [PLACEMENT.leftBottomEdge]: {
129
+ bottom: '16px',
130
+ left: '-8px'
131
+ }
132
+ },
133
+ [ROLE.notificationCircle]: {
134
+ [PLACEMENT.topLeft]: {
135
+ top: '-10px',
136
+ left: '-10px'
137
+ },
138
+ [PLACEMENT.topRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
139
+ // NotificationCircle can only be placed topLeft or topRight, other values fall back to topRight
140
+ [PLACEMENT.topEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
141
+ [PLACEMENT.bottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
142
+ [PLACEMENT.bottomRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
143
+ [PLACEMENT.bottomLeft]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
144
+ [PLACEMENT.topLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
145
+ [PLACEMENT.topRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
146
+ [PLACEMENT.bottomRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
147
+ [PLACEMENT.bottomLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
148
+ [PLACEMENT.leftTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
149
+ [PLACEMENT.rightTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
150
+ [PLACEMENT.rightBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
151
+ [PLACEMENT.leftBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT
152
+ },
153
+ [ROLE.hintDot]: {
154
+ [PLACEMENT.topLeft]: {
155
+ top: '-4px',
156
+ left: '-4px'
157
+ },
158
+ [PLACEMENT.topRight]: DEFAULT_HINT_DOT_PLACEMENT,
159
+ // HintDot can only be placed topLeft or topRight, other values fall back to topRight
160
+ [PLACEMENT.topEdge]: DEFAULT_HINT_DOT_PLACEMENT,
161
+ [PLACEMENT.bottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
162
+ [PLACEMENT.bottomRight]: DEFAULT_HINT_DOT_PLACEMENT,
163
+ [PLACEMENT.bottomLeft]: DEFAULT_HINT_DOT_PLACEMENT,
164
+ [PLACEMENT.topLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
165
+ [PLACEMENT.topRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
166
+ [PLACEMENT.bottomRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
167
+ [PLACEMENT.bottomLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
168
+ [PLACEMENT.leftTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
169
+ [PLACEMENT.rightTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
170
+ [PLACEMENT.rightBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
171
+ [PLACEMENT.leftBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT
172
+ }
173
+ });
174
+ export const StyledRoot = styled('div', () => {
175
+ return {
176
+ position: 'relative',
177
+ display: 'inline-block',
178
+ lineHeight: 'initial'
179
+ };
180
+ });
181
+ StyledRoot.displayName = "StyledRoot";
182
+ const TOP_PLACEMENTS = [PLACEMENT.topLeft, PLACEMENT.topRight, PLACEMENT.topLeftEdge, PLACEMENT.topEdge, PLACEMENT.topRightEdge, PLACEMENT.leftTopEdge, PLACEMENT.rightTopEdge];
183
+ const BOTTOM_PLACEMENTS = [PLACEMENT.bottomLeft, PLACEMENT.bottomRight, PLACEMENT.bottomLeftEdge, PLACEMENT.bottomEdge, PLACEMENT.bottomRightEdge, PLACEMENT.leftBottomEdge, PLACEMENT.rightBottomEdge];
184
+ const LEFT_PLACEMENTS = [PLACEMENT.topLeft, PLACEMENT.topLeftEdge, PLACEMENT.topEdge, PLACEMENT.bottomLeft, PLACEMENT.bottomLeftEdge, PLACEMENT.bottomEdge, PLACEMENT.leftTopEdge, PLACEMENT.leftBottomEdge];
185
+ const RIGHT_PLACEMENTS = [PLACEMENT.topRight, PLACEMENT.topRightEdge, PLACEMENT.bottomRight, PLACEMENT.bottomRightEdge, PLACEMENT.rightTopEdge, PLACEMENT.rightBottomEdge];
186
+ export const StyledPositioner = styled('div', ({
187
+ $theme,
188
+ $role,
189
+ $placement,
190
+ $horizontalOffset,
191
+ $verticalOffset
192
+ }) => {
193
+ let positionStyle = POSITION_STYLES[$role][$placement];
194
+
195
+ if ($verticalOffset) {
196
+ if (TOP_PLACEMENTS.includes($placement)) {
197
+ positionStyle = { ...positionStyle,
198
+ top: $verticalOffset
199
+ };
200
+ }
201
+
202
+ if (BOTTOM_PLACEMENTS.includes($placement)) {
203
+ positionStyle = { ...positionStyle,
204
+ bottom: $verticalOffset
205
+ };
206
+ }
207
+ }
208
+
209
+ if ($horizontalOffset) {
210
+ if (LEFT_PLACEMENTS.includes($placement)) {
211
+ positionStyle = { ...positionStyle,
212
+ left: $horizontalOffset
213
+ };
214
+ }
215
+
216
+ if (RIGHT_PLACEMENTS.includes($placement)) {
217
+ positionStyle = { ...positionStyle,
218
+ right: $horizontalOffset
219
+ };
220
+ }
221
+ }
222
+
223
+ return { ...positionStyle,
224
+ position: 'absolute',
225
+ lineHeight: 'initial'
226
+ };
227
+ });
228
+ StyledPositioner.displayName = "StyledPositioner";
229
+ export const StyledBadge = styled('div', ({
230
+ $theme,
231
+ $shape = SHAPE.rectangle,
232
+ $color = COLOR.accent,
233
+ $hierarchy = HIERARCHY.primary,
234
+ $hidden
235
+ }) => {
236
+ return {
237
+ visibility: $hidden ? 'hidden' : 'inherit',
238
+ boxSizing: 'border-box',
239
+ height: $theme.sizing.scale700,
240
+ borderRadius: $shape === SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
241
+ paddingRight: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
242
+ paddingLeft: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
243
+ display: 'inline-flex',
244
+ alignItems: 'center',
245
+ ...getColorStyles({
246
+ $theme,
247
+ $hierarchy,
248
+ $color
249
+ }),
250
+ ...($hierarchy === HIERARCHY.primary ? $theme.typography.LabelSmall : $theme.typography.ParagraphSmall)
251
+ };
252
+ });
253
+ StyledBadge.displayName = "StyledBadge";
254
+ export const StyledNotificationCircle = styled('div', ({
255
+ $theme,
256
+ $color = COLOR.accent,
257
+ $hidden
258
+ }) => {
259
+ return {
260
+ visibility: $hidden ? 'hidden' : 'inherit',
261
+ height: $theme.sizing.scale700,
262
+ width: $theme.sizing.scale700,
263
+ borderRadius: '20px',
264
+ display: 'inline-flex',
265
+ alignItems: 'center',
266
+ justifyContent: 'center',
267
+ ...getColorStyles({
268
+ $theme,
269
+ $hierarchy: HIERARCHY.primary,
270
+ $color
271
+ }),
272
+ ...$theme.typography.LabelXSmall
273
+ };
274
+ });
275
+ StyledNotificationCircle.displayName = "StyledNotificationCircle";
276
+ export const StyledHintDot = styled('div', ({
277
+ $theme,
278
+ $color = COLOR.accent,
279
+ $hidden
280
+ }) => {
281
+ return {
282
+ visibility: $hidden ? 'hidden' : 'inherit',
283
+ backgroundColor: $theme.colors[$color],
284
+ boxSizing: 'content-box',
285
+ height: '8px',
286
+ width: '8px',
287
+ borderRadius: '50%',
288
+ border: `4px solid ${$theme.colors.backgroundPrimary}`,
289
+ ...getColorStyles({
290
+ $theme,
291
+ $hierarchy: HIERARCHY.primary,
292
+ $color
293
+ })
294
+ };
295
+ });
296
+ StyledHintDot.displayName = "StyledHintDot";
@@ -0,0 +1,8 @@
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
+ import * as React from 'react';
8
+ import { HIERARCHY, SHAPE, COLOR, PLACEMENT, ROLE } from './constants.js';
@@ -0,0 +1,17 @@
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
+ import * as React from 'react';
8
+ export const getAnchorFromChildren = children => {
9
+ const childArray = React.Children.toArray(children);
10
+
11
+ if (childArray.length !== 1) {
12
+ // eslint-disable-next-line no-console
13
+ console.error(`[baseui] No more than 1 child may be passed to Badge, found ${childArray.length} children`);
14
+ }
15
+
16
+ return childArray[0];
17
+ };
@@ -0,0 +1,213 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ /*
4
+ Copyright (c) Uber Technologies, Inc.
5
+
6
+ This source code is licensed under the MIT license found in the
7
+ LICENSE file in the root directory of this source tree.
8
+ */
9
+ import * as React from 'react';
10
+ import { Button, SIZE as BUTTON_SIZE, SHAPE as BUTTON_SHAPE } from '../button/index.js';
11
+ import { getOverrides } from '../helpers/overrides.js';
12
+ import { useStyletron } from '../styles/index.js';
13
+ import { ACTION_POSITION, ARTWORK_TYPE, HIERARCHY, KIND } from './constants.js';
14
+ import { StyledRoot, StyledLeadingContent, StyledMessageContent, StyledTitle, StyledMessage, StyledBelowContent, StyledTrailingContent, StyledTrailingButtonContainer, StyledTrailingIconButton } from './styled-components.js';
15
+
16
+ function low(theme, kind) {
17
+ switch (kind) {
18
+ case KIND.negative:
19
+ return {
20
+ actionBackgroundColor: theme.colors.bannerActionLowNegative,
21
+ backgroundColor: theme.colors.backgroundLightNegative,
22
+ color: theme.colors.contentPrimary
23
+ };
24
+
25
+ case KIND.positive:
26
+ return {
27
+ actionBackgroundColor: theme.colors.bannerActionLowPositive,
28
+ backgroundColor: theme.colors.backgroundLightPositive,
29
+ color: theme.colors.contentPrimary
30
+ };
31
+
32
+ case KIND.warning:
33
+ return {
34
+ actionBackgroundColor: theme.colors.bannerActionLowWarning,
35
+ backgroundColor: theme.colors.backgroundLightWarning,
36
+ color: theme.colors.contentPrimary
37
+ };
38
+
39
+ case KIND.info:
40
+ default:
41
+ return {
42
+ actionBackgroundColor: theme.colors.bannerActionLowInfo,
43
+ backgroundColor: theme.colors.backgroundLightAccent,
44
+ color: theme.colors.contentPrimary
45
+ };
46
+ }
47
+ }
48
+
49
+ function high(theme, kind) {
50
+ switch (kind) {
51
+ case KIND.negative:
52
+ return {
53
+ actionBackgroundColor: theme.colors.bannerActionHighNegative,
54
+ backgroundColor: theme.colors.backgroundNegative,
55
+ color: theme.colors.contentOnColor
56
+ };
57
+
58
+ case KIND.positive:
59
+ return {
60
+ actionBackgroundColor: theme.colors.bannerActionHighPositive,
61
+ backgroundColor: theme.colors.backgroundPositive,
62
+ color: theme.colors.contentOnColor
63
+ };
64
+
65
+ case KIND.warning:
66
+ return {
67
+ actionBackgroundColor: theme.colors.bannerActionHighWarning,
68
+ backgroundColor: theme.colors.backgroundWarning,
69
+ color: theme.colors.contentPrimary
70
+ };
71
+
72
+ case KIND.info:
73
+ default:
74
+ return {
75
+ actionBackgroundColor: theme.colors.bannerActionHighInfo,
76
+ backgroundColor: theme.colors.backgroundAccent,
77
+ color: theme.colors.contentOnColor
78
+ };
79
+ }
80
+ }
81
+
82
+ function Leading({
83
+ artwork
84
+ }) {
85
+ const [, theme] = useStyletron();
86
+
87
+ if (!artwork) {
88
+ return null;
89
+ }
90
+
91
+ const size = artwork.type === ARTWORK_TYPE.badge ? theme.sizing.scale1000 : theme.sizing.scale800;
92
+ return artwork.icon({
93
+ size
94
+ });
95
+ }
96
+
97
+ function Below({
98
+ action,
99
+ backgroundColor,
100
+ color
101
+ }) {
102
+ if (!action || action.position !== ACTION_POSITION.below) {
103
+ return null;
104
+ }
105
+
106
+ if (process.env.NODE_ENV !== "production") {
107
+ if (action.icon) {
108
+ console.error('Banner ACTION_POSITION.below must not have an icon.');
109
+ return null;
110
+ }
111
+ }
112
+
113
+ if (action.label) {
114
+ return /*#__PURE__*/React.createElement(Button, {
115
+ colors: {
116
+ backgroundColor,
117
+ color
118
+ },
119
+ onClick: action.onClick,
120
+ size: BUTTON_SIZE.compact,
121
+ shape: BUTTON_SHAPE.pill
122
+ }, action.label);
123
+ }
124
+
125
+ return null;
126
+ }
127
+
128
+ function Trailing({
129
+ action,
130
+ backgroundColor,
131
+ color,
132
+ overrides,
133
+ nested
134
+ }) {
135
+ const [, theme] = useStyletron();
136
+
137
+ if (!action || action.position && action.position !== ACTION_POSITION.trailing) {
138
+ return null;
139
+ }
140
+
141
+ const [TrailingIconButton, trailingIconButtonProps] = getOverrides(overrides.TrailingIconButton, StyledTrailingIconButton);
142
+
143
+ if (action.icon) {
144
+ return /*#__PURE__*/React.createElement(TrailingIconButton, _extends({
145
+ "aria-label": action.label,
146
+ onClick: action.onClick,
147
+ $nested: nested
148
+ }, trailingIconButtonProps), action.icon({
149
+ size: theme.sizing.scale650
150
+ }));
151
+ }
152
+
153
+ const [TrailingButtonContainer, trailingButtonContainerProps] = getOverrides(overrides.TrailingButtonContainer, StyledTrailingButtonContainer);
154
+
155
+ if (action.label) {
156
+ return /*#__PURE__*/React.createElement(TrailingButtonContainer, trailingButtonContainerProps, /*#__PURE__*/React.createElement(Button, {
157
+ colors: {
158
+ backgroundColor,
159
+ color
160
+ },
161
+ onClick: action.onClick,
162
+ size: BUTTON_SIZE.compact,
163
+ shape: BUTTON_SHAPE.pill
164
+ }, action.label));
165
+ }
166
+
167
+ return null;
168
+ }
169
+
170
+ export function Banner({
171
+ action,
172
+ artwork,
173
+ children,
174
+ hierarchy = HIERARCHY.low,
175
+ kind = KIND.info,
176
+ overrides = {},
177
+ nested = false,
178
+ title
179
+ }) {
180
+ const [, theme] = useStyletron();
181
+ const styles = hierarchy === HIERARCHY.high ? high(theme, kind) : low(theme, kind);
182
+ const actionPosition = action && action.position ? action.position : ACTION_POSITION.trailing;
183
+ const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
184
+ const [LeadingContent, leadingContentProps] = getOverrides(overrides.LeadingContent, StyledLeadingContent);
185
+ const [MessageContent, messageContentProps] = getOverrides(overrides.MessageContent, StyledMessageContent);
186
+ const [TrailingContent, trailingContentProps] = getOverrides(overrides.TrailingContent, StyledTrailingContent);
187
+ const [BelowContent, belowContentProps] = getOverrides(overrides.BelowContent, StyledBelowContent);
188
+ const [Title, titleProps] = getOverrides(overrides.Title, StyledTitle);
189
+ const [Message, messageProps] = getOverrides(overrides.Message, StyledMessage);
190
+ return /*#__PURE__*/React.createElement(Root, _extends({
191
+ $backgroundColor: styles.backgroundColor,
192
+ $color: styles.color,
193
+ $nested: nested
194
+ }, rootProps), /*#__PURE__*/React.createElement(LeadingContent, _extends({
195
+ $includesArtwork: Boolean(artwork)
196
+ }, leadingContentProps), /*#__PURE__*/React.createElement(Leading, {
197
+ artwork: artwork
198
+ })), /*#__PURE__*/React.createElement(MessageContent, _extends({
199
+ $actionPosition: actionPosition
200
+ }, messageContentProps), Boolean(title) && /*#__PURE__*/React.createElement(Title, titleProps, title), Boolean(children) && /*#__PURE__*/React.createElement(Message, messageProps, children)), /*#__PURE__*/React.createElement(TrailingContent, trailingContentProps, /*#__PURE__*/React.createElement(Trailing, {
201
+ action: action,
202
+ backgroundColor: styles.actionBackgroundColor,
203
+ color: styles.color,
204
+ overrides: overrides,
205
+ nested: nested
206
+ })), /*#__PURE__*/React.createElement(BelowContent, _extends({
207
+ $actionPosition: actionPosition
208
+ }, belowContentProps), /*#__PURE__*/React.createElement(Below, {
209
+ action: action,
210
+ backgroundColor: styles.actionBackgroundColor,
211
+ color: styles.color
212
+ })));
213
+ }
@@ -0,0 +1,24 @@
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
+ export const ACTION_POSITION = Object.freeze({
8
+ below: 'below',
9
+ trailing: 'trailing'
10
+ });
11
+ export const ARTWORK_TYPE = Object.freeze({
12
+ icon: 'icon',
13
+ badge: 'badge'
14
+ });
15
+ export const HIERARCHY = Object.freeze({
16
+ low: 'low',
17
+ high: 'high'
18
+ });
19
+ export const KIND = Object.freeze({
20
+ info: 'info',
21
+ negative: 'negative',
22
+ positive: 'positive',
23
+ warning: 'warning'
24
+ });