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,283 @@
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.Banner = Banner;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ var _index = require("../button/index.js");
13
+
14
+ var _overrides = require("../helpers/overrides.js");
15
+
16
+ var _index2 = require("../styles/index.js");
17
+
18
+ var _constants = require("./constants.js");
19
+
20
+ var _styledComponents = require("./styled-components.js");
21
+
22
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
+
24
+ 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; }
25
+
26
+ 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); }
27
+
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
30
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
+
32
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
33
+
34
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
35
+
36
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
37
+
38
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
40
+ function low(theme, kind) {
41
+ switch (kind) {
42
+ case _constants.KIND.negative:
43
+ return {
44
+ actionBackgroundColor: theme.colors.bannerActionLowNegative,
45
+ backgroundColor: theme.colors.backgroundLightNegative,
46
+ color: theme.colors.contentPrimary
47
+ };
48
+
49
+ case _constants.KIND.positive:
50
+ return {
51
+ actionBackgroundColor: theme.colors.bannerActionLowPositive,
52
+ backgroundColor: theme.colors.backgroundLightPositive,
53
+ color: theme.colors.contentPrimary
54
+ };
55
+
56
+ case _constants.KIND.warning:
57
+ return {
58
+ actionBackgroundColor: theme.colors.bannerActionLowWarning,
59
+ backgroundColor: theme.colors.backgroundLightWarning,
60
+ color: theme.colors.contentPrimary
61
+ };
62
+
63
+ case _constants.KIND.info:
64
+ default:
65
+ return {
66
+ actionBackgroundColor: theme.colors.bannerActionLowInfo,
67
+ backgroundColor: theme.colors.backgroundLightAccent,
68
+ color: theme.colors.contentPrimary
69
+ };
70
+ }
71
+ }
72
+
73
+ function high(theme, kind) {
74
+ switch (kind) {
75
+ case _constants.KIND.negative:
76
+ return {
77
+ actionBackgroundColor: theme.colors.bannerActionHighNegative,
78
+ backgroundColor: theme.colors.backgroundNegative,
79
+ color: theme.colors.contentOnColor
80
+ };
81
+
82
+ case _constants.KIND.positive:
83
+ return {
84
+ actionBackgroundColor: theme.colors.bannerActionHighPositive,
85
+ backgroundColor: theme.colors.backgroundPositive,
86
+ color: theme.colors.contentOnColor
87
+ };
88
+
89
+ case _constants.KIND.warning:
90
+ return {
91
+ actionBackgroundColor: theme.colors.bannerActionHighWarning,
92
+ backgroundColor: theme.colors.backgroundWarning,
93
+ color: theme.colors.contentPrimary
94
+ };
95
+
96
+ case _constants.KIND.info:
97
+ default:
98
+ return {
99
+ actionBackgroundColor: theme.colors.bannerActionHighInfo,
100
+ backgroundColor: theme.colors.backgroundAccent,
101
+ color: theme.colors.contentOnColor
102
+ };
103
+ }
104
+ }
105
+
106
+ function Leading(_ref) {
107
+ var artwork = _ref.artwork;
108
+
109
+ var _useStyletron = (0, _index2.useStyletron)(),
110
+ _useStyletron2 = _slicedToArray(_useStyletron, 2),
111
+ theme = _useStyletron2[1];
112
+
113
+ if (!artwork) {
114
+ return null;
115
+ }
116
+
117
+ var size = artwork.type === _constants.ARTWORK_TYPE.badge ? theme.sizing.scale1000 : theme.sizing.scale800;
118
+ return artwork.icon({
119
+ size: size
120
+ });
121
+ }
122
+
123
+ function Below(_ref2) {
124
+ var action = _ref2.action,
125
+ backgroundColor = _ref2.backgroundColor,
126
+ color = _ref2.color;
127
+
128
+ if (!action || action.position !== _constants.ACTION_POSITION.below) {
129
+ return null;
130
+ }
131
+
132
+ if (process.env.NODE_ENV !== "production") {
133
+ if (action.icon) {
134
+ console.error('Banner ACTION_POSITION.below must not have an icon.');
135
+ return null;
136
+ }
137
+ }
138
+
139
+ if (action.label) {
140
+ return /*#__PURE__*/React.createElement(_index.Button, {
141
+ colors: {
142
+ backgroundColor: backgroundColor,
143
+ color: color
144
+ },
145
+ onClick: action.onClick,
146
+ size: _index.SIZE.compact,
147
+ shape: _index.SHAPE.pill
148
+ }, action.label);
149
+ }
150
+
151
+ return null;
152
+ }
153
+
154
+ function Trailing(_ref3) {
155
+ var action = _ref3.action,
156
+ backgroundColor = _ref3.backgroundColor,
157
+ color = _ref3.color,
158
+ overrides = _ref3.overrides,
159
+ nested = _ref3.nested;
160
+
161
+ var _useStyletron3 = (0, _index2.useStyletron)(),
162
+ _useStyletron4 = _slicedToArray(_useStyletron3, 2),
163
+ theme = _useStyletron4[1];
164
+
165
+ if (!action || action.position && action.position !== _constants.ACTION_POSITION.trailing) {
166
+ return null;
167
+ }
168
+
169
+ var _getOverrides = (0, _overrides.getOverrides)(overrides.TrailingIconButton, _styledComponents.StyledTrailingIconButton),
170
+ _getOverrides2 = _slicedToArray(_getOverrides, 2),
171
+ TrailingIconButton = _getOverrides2[0],
172
+ trailingIconButtonProps = _getOverrides2[1];
173
+
174
+ if (action.icon) {
175
+ return /*#__PURE__*/React.createElement(TrailingIconButton, _extends({
176
+ "aria-label": action.label,
177
+ onClick: action.onClick,
178
+ $nested: nested
179
+ }, trailingIconButtonProps), action.icon({
180
+ size: theme.sizing.scale650
181
+ }));
182
+ }
183
+
184
+ var _getOverrides3 = (0, _overrides.getOverrides)(overrides.TrailingButtonContainer, _styledComponents.StyledTrailingButtonContainer),
185
+ _getOverrides4 = _slicedToArray(_getOverrides3, 2),
186
+ TrailingButtonContainer = _getOverrides4[0],
187
+ trailingButtonContainerProps = _getOverrides4[1];
188
+
189
+ if (action.label) {
190
+ return /*#__PURE__*/React.createElement(TrailingButtonContainer, trailingButtonContainerProps, /*#__PURE__*/React.createElement(_index.Button, {
191
+ colors: {
192
+ backgroundColor: backgroundColor,
193
+ color: color
194
+ },
195
+ onClick: action.onClick,
196
+ size: _index.SIZE.compact,
197
+ shape: _index.SHAPE.pill
198
+ }, action.label));
199
+ }
200
+
201
+ return null;
202
+ }
203
+
204
+ function Banner(_ref4) {
205
+ var action = _ref4.action,
206
+ artwork = _ref4.artwork,
207
+ children = _ref4.children,
208
+ _ref4$hierarchy = _ref4.hierarchy,
209
+ hierarchy = _ref4$hierarchy === void 0 ? _constants.HIERARCHY.low : _ref4$hierarchy,
210
+ _ref4$kind = _ref4.kind,
211
+ kind = _ref4$kind === void 0 ? _constants.KIND.info : _ref4$kind,
212
+ _ref4$overrides = _ref4.overrides,
213
+ overrides = _ref4$overrides === void 0 ? {} : _ref4$overrides,
214
+ _ref4$nested = _ref4.nested,
215
+ nested = _ref4$nested === void 0 ? false : _ref4$nested,
216
+ title = _ref4.title;
217
+
218
+ var _useStyletron5 = (0, _index2.useStyletron)(),
219
+ _useStyletron6 = _slicedToArray(_useStyletron5, 2),
220
+ theme = _useStyletron6[1];
221
+
222
+ var styles = hierarchy === _constants.HIERARCHY.high ? high(theme, kind) : low(theme, kind);
223
+ var actionPosition = action && action.position ? action.position : _constants.ACTION_POSITION.trailing;
224
+
225
+ var _getOverrides5 = (0, _overrides.getOverrides)(overrides.Root, _styledComponents.StyledRoot),
226
+ _getOverrides6 = _slicedToArray(_getOverrides5, 2),
227
+ Root = _getOverrides6[0],
228
+ rootProps = _getOverrides6[1];
229
+
230
+ var _getOverrides7 = (0, _overrides.getOverrides)(overrides.LeadingContent, _styledComponents.StyledLeadingContent),
231
+ _getOverrides8 = _slicedToArray(_getOverrides7, 2),
232
+ LeadingContent = _getOverrides8[0],
233
+ leadingContentProps = _getOverrides8[1];
234
+
235
+ var _getOverrides9 = (0, _overrides.getOverrides)(overrides.MessageContent, _styledComponents.StyledMessageContent),
236
+ _getOverrides10 = _slicedToArray(_getOverrides9, 2),
237
+ MessageContent = _getOverrides10[0],
238
+ messageContentProps = _getOverrides10[1];
239
+
240
+ var _getOverrides11 = (0, _overrides.getOverrides)(overrides.TrailingContent, _styledComponents.StyledTrailingContent),
241
+ _getOverrides12 = _slicedToArray(_getOverrides11, 2),
242
+ TrailingContent = _getOverrides12[0],
243
+ trailingContentProps = _getOverrides12[1];
244
+
245
+ var _getOverrides13 = (0, _overrides.getOverrides)(overrides.BelowContent, _styledComponents.StyledBelowContent),
246
+ _getOverrides14 = _slicedToArray(_getOverrides13, 2),
247
+ BelowContent = _getOverrides14[0],
248
+ belowContentProps = _getOverrides14[1];
249
+
250
+ var _getOverrides15 = (0, _overrides.getOverrides)(overrides.Title, _styledComponents.StyledTitle),
251
+ _getOverrides16 = _slicedToArray(_getOverrides15, 2),
252
+ Title = _getOverrides16[0],
253
+ titleProps = _getOverrides16[1];
254
+
255
+ var _getOverrides17 = (0, _overrides.getOverrides)(overrides.Message, _styledComponents.StyledMessage),
256
+ _getOverrides18 = _slicedToArray(_getOverrides17, 2),
257
+ Message = _getOverrides18[0],
258
+ messageProps = _getOverrides18[1];
259
+
260
+ return /*#__PURE__*/React.createElement(Root, _extends({
261
+ $backgroundColor: styles.backgroundColor,
262
+ $color: styles.color,
263
+ $nested: nested
264
+ }, rootProps), /*#__PURE__*/React.createElement(LeadingContent, _extends({
265
+ $includesArtwork: Boolean(artwork)
266
+ }, leadingContentProps), /*#__PURE__*/React.createElement(Leading, {
267
+ artwork: artwork
268
+ })), /*#__PURE__*/React.createElement(MessageContent, _extends({
269
+ $actionPosition: actionPosition
270
+ }, 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, {
271
+ action: action,
272
+ backgroundColor: styles.actionBackgroundColor,
273
+ color: styles.color,
274
+ overrides: overrides,
275
+ nested: nested
276
+ })), /*#__PURE__*/React.createElement(BelowContent, _extends({
277
+ $actionPosition: actionPosition
278
+ }, belowContentProps), /*#__PURE__*/React.createElement(Below, {
279
+ action: action,
280
+ backgroundColor: styles.actionBackgroundColor,
281
+ color: styles.color
282
+ })));
283
+ }
@@ -0,0 +1,253 @@
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
+
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 {
15
+ StyledRoot,
16
+ StyledLeadingContent,
17
+ StyledMessageContent,
18
+ StyledTitle,
19
+ StyledMessage,
20
+ StyledBelowContent,
21
+ StyledTrailingContent,
22
+ StyledTrailingButtonContainer,
23
+ StyledTrailingIconButton,
24
+ } from './styled-components.js';
25
+ import type { PropsT } from './types.js';
26
+
27
+ function low(theme, kind) {
28
+ switch (kind) {
29
+ case KIND.negative:
30
+ return {
31
+ actionBackgroundColor: theme.colors.bannerActionLowNegative,
32
+ backgroundColor: theme.colors.backgroundLightNegative,
33
+ color: theme.colors.contentPrimary,
34
+ };
35
+
36
+ case KIND.positive:
37
+ return {
38
+ actionBackgroundColor: theme.colors.bannerActionLowPositive,
39
+ backgroundColor: theme.colors.backgroundLightPositive,
40
+ color: theme.colors.contentPrimary,
41
+ };
42
+
43
+ case KIND.warning:
44
+ return {
45
+ actionBackgroundColor: theme.colors.bannerActionLowWarning,
46
+ backgroundColor: theme.colors.backgroundLightWarning,
47
+ color: theme.colors.contentPrimary,
48
+ };
49
+
50
+ case KIND.info:
51
+ default:
52
+ return {
53
+ actionBackgroundColor: theme.colors.bannerActionLowInfo,
54
+ backgroundColor: theme.colors.backgroundLightAccent,
55
+ color: theme.colors.contentPrimary,
56
+ };
57
+ }
58
+ }
59
+
60
+ function high(theme, kind) {
61
+ switch (kind) {
62
+ case KIND.negative:
63
+ return {
64
+ actionBackgroundColor: theme.colors.bannerActionHighNegative,
65
+ backgroundColor: theme.colors.backgroundNegative,
66
+ color: theme.colors.contentOnColor,
67
+ };
68
+
69
+ case KIND.positive:
70
+ return {
71
+ actionBackgroundColor: theme.colors.bannerActionHighPositive,
72
+ backgroundColor: theme.colors.backgroundPositive,
73
+ color: theme.colors.contentOnColor,
74
+ };
75
+
76
+ case KIND.warning:
77
+ return {
78
+ actionBackgroundColor: theme.colors.bannerActionHighWarning,
79
+ backgroundColor: theme.colors.backgroundWarning,
80
+ color: theme.colors.contentPrimary,
81
+ };
82
+
83
+ case KIND.info:
84
+ default:
85
+ return {
86
+ actionBackgroundColor: theme.colors.bannerActionHighInfo,
87
+ backgroundColor: theme.colors.backgroundAccent,
88
+ color: theme.colors.contentOnColor,
89
+ };
90
+ }
91
+ }
92
+
93
+ function Leading({ artwork }) {
94
+ const [, theme] = useStyletron();
95
+
96
+ if (!artwork) {
97
+ return null;
98
+ }
99
+
100
+ const size = artwork.type === ARTWORK_TYPE.badge ? theme.sizing.scale1000 : theme.sizing.scale800;
101
+ return artwork.icon({ size });
102
+ }
103
+
104
+ function Below({ action, backgroundColor, color }) {
105
+ if (!action || action.position !== ACTION_POSITION.below) {
106
+ return null;
107
+ }
108
+
109
+ if (__DEV__) {
110
+ if (action.icon) {
111
+ console.error('Banner ACTION_POSITION.below must not have an icon.');
112
+ return null;
113
+ }
114
+ }
115
+
116
+ if (action.label) {
117
+ return (
118
+ <Button
119
+ colors={{ backgroundColor, color }}
120
+ onClick={action.onClick}
121
+ size={BUTTON_SIZE.compact}
122
+ shape={BUTTON_SHAPE.pill}
123
+ >
124
+ {action.label}
125
+ </Button>
126
+ );
127
+ }
128
+
129
+ return null;
130
+ }
131
+
132
+ function Trailing({ action, backgroundColor, color, overrides, nested }) {
133
+ const [, theme] = useStyletron();
134
+
135
+ if (!action || (action.position && action.position !== ACTION_POSITION.trailing)) {
136
+ return null;
137
+ }
138
+
139
+ const [TrailingIconButton, trailingIconButtonProps] = getOverrides(
140
+ overrides.TrailingIconButton,
141
+ StyledTrailingIconButton
142
+ );
143
+
144
+ if (action.icon) {
145
+ return (
146
+ <TrailingIconButton
147
+ aria-label={action.label}
148
+ onClick={action.onClick}
149
+ $nested={nested}
150
+ {...trailingIconButtonProps}
151
+ >
152
+ {action.icon({ size: theme.sizing.scale650 })}
153
+ </TrailingIconButton>
154
+ );
155
+ }
156
+
157
+ const [TrailingButtonContainer, trailingButtonContainerProps] = getOverrides(
158
+ overrides.TrailingButtonContainer,
159
+ StyledTrailingButtonContainer
160
+ );
161
+
162
+ if (action.label) {
163
+ return (
164
+ <TrailingButtonContainer {...trailingButtonContainerProps}>
165
+ <Button
166
+ colors={{ backgroundColor, color }}
167
+ onClick={action.onClick}
168
+ size={BUTTON_SIZE.compact}
169
+ shape={BUTTON_SHAPE.pill}
170
+ >
171
+ {action.label}
172
+ </Button>
173
+ </TrailingButtonContainer>
174
+ );
175
+ }
176
+
177
+ return null;
178
+ }
179
+
180
+ export function Banner({
181
+ action,
182
+ artwork,
183
+ children,
184
+ hierarchy = HIERARCHY.low,
185
+ kind = KIND.info,
186
+ overrides = {},
187
+ nested = false,
188
+ title,
189
+ }: PropsT) {
190
+ const [, theme] = useStyletron();
191
+ const styles = hierarchy === HIERARCHY.high ? high(theme, kind) : low(theme, kind);
192
+ const actionPosition = action && action.position ? action.position : ACTION_POSITION.trailing;
193
+
194
+ const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
195
+ const [LeadingContent, leadingContentProps] = getOverrides(
196
+ overrides.LeadingContent,
197
+ StyledLeadingContent
198
+ );
199
+ const [MessageContent, messageContentProps] = getOverrides(
200
+ overrides.MessageContent,
201
+ StyledMessageContent
202
+ );
203
+ const [TrailingContent, trailingContentProps] = getOverrides(
204
+ overrides.TrailingContent,
205
+ StyledTrailingContent
206
+ );
207
+ const [BelowContent, belowContentProps] = getOverrides(
208
+ overrides.BelowContent,
209
+ StyledBelowContent
210
+ );
211
+ const [Title, titleProps] = getOverrides(overrides.Title, StyledTitle);
212
+ const [Message, messageProps] = getOverrides(overrides.Message, StyledMessage);
213
+
214
+ return (
215
+ <Root
216
+ $backgroundColor={styles.backgroundColor}
217
+ $color={styles.color}
218
+ $nested={nested}
219
+ {...rootProps}
220
+ >
221
+ <LeadingContent $includesArtwork={Boolean(artwork)} {...leadingContentProps}>
222
+ <Leading artwork={artwork} />
223
+ </LeadingContent>
224
+
225
+ <MessageContent $actionPosition={actionPosition} {...messageContentProps}>
226
+ {Boolean(title) && <Title {...titleProps}>{title}</Title>}
227
+ {Boolean(children) && <Message {...messageProps}>{children}</Message>}
228
+ </MessageContent>
229
+
230
+ <TrailingContent {...trailingContentProps}>
231
+ <Trailing
232
+ action={action}
233
+ backgroundColor={styles.actionBackgroundColor}
234
+ color={styles.color}
235
+ overrides={overrides}
236
+ nested={nested}
237
+ />
238
+ </TrailingContent>
239
+
240
+ <BelowContent $actionPosition={actionPosition} {...belowContentProps}>
241
+ <Below
242
+ action={action}
243
+ backgroundColor={styles.actionBackgroundColor}
244
+ color={styles.color}
245
+ />
246
+ </BelowContent>
247
+ </Root>
248
+ );
249
+ }
250
+
251
+ declare var __DEV__: boolean;
252
+ declare var __NODE__: boolean;
253
+ declare var __BROWSER__: boolean;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.KIND = exports.HIERARCHY = exports.ARTWORK_TYPE = exports.ACTION_POSITION = void 0;
7
+
8
+ /*
9
+ Copyright (c) Uber Technologies, Inc.
10
+
11
+ This source code is licensed under the MIT license found in the
12
+ LICENSE file in the root directory of this source tree.
13
+ */
14
+ var ACTION_POSITION = Object.freeze({
15
+ below: 'below',
16
+ trailing: 'trailing'
17
+ });
18
+ exports.ACTION_POSITION = ACTION_POSITION;
19
+ var ARTWORK_TYPE = Object.freeze({
20
+ icon: 'icon',
21
+ badge: 'badge'
22
+ });
23
+ exports.ARTWORK_TYPE = ARTWORK_TYPE;
24
+ var HIERARCHY = Object.freeze({
25
+ low: 'low',
26
+ high: 'high'
27
+ });
28
+ exports.HIERARCHY = HIERARCHY;
29
+ var KIND = Object.freeze({
30
+ info: 'info',
31
+ negative: 'negative',
32
+ positive: 'positive',
33
+ warning: 'warning'
34
+ });
35
+ exports.KIND = KIND;
@@ -0,0 +1,33 @@
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
+
9
+ export const ACTION_POSITION = Object.freeze({
10
+ below: 'below',
11
+ trailing: 'trailing',
12
+ });
13
+
14
+ export const ARTWORK_TYPE = Object.freeze({
15
+ icon: 'icon',
16
+ badge: 'badge',
17
+ });
18
+
19
+ export const HIERARCHY = Object.freeze({
20
+ low: 'low',
21
+ high: 'high',
22
+ });
23
+
24
+ export const KIND = Object.freeze({
25
+ info: 'info',
26
+ negative: 'negative',
27
+ positive: 'positive',
28
+ warning: 'warning',
29
+ });
30
+
31
+ declare var __DEV__: boolean;
32
+ declare var __NODE__: boolean;
33
+ declare var __BROWSER__: boolean;
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { StyletronComponent } from 'styletron-react';
3
+ import { Override } from '../overrides';
4
+
5
+ export interface ACTION_POSITION {
6
+ below: 'below';
7
+ trailing: 'trailing';
8
+ }
9
+
10
+ export interface ARTWORK_TYPE {
11
+ badge: 'badge';
12
+ icon: 'icon';
13
+ }
14
+
15
+ export interface HIERARCHY {
16
+ high: 'high';
17
+ low: 'low';
18
+ }
19
+
20
+ export interface KIND {
21
+ info: 'info';
22
+ negative: 'negative';
23
+ positive: 'positive';
24
+ warning: 'warning';
25
+ }
26
+
27
+ export interface ActionContentT {
28
+ label: string;
29
+ icon?: (iconProps: { size: string }) => React.ReactNode;
30
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => any;
31
+ position?: ACTION_POSITION[keyof ACTION_POSITION];
32
+ }
33
+
34
+ export interface ArtworkContentT {
35
+ icon: (iconProps: { size: string }) => React.ReactNode;
36
+ type?: ARTWORK_TYPE[keyof ARTWORK_TYPE];
37
+ }
38
+
39
+ export interface PropsT {
40
+ action?: ActionContentT;
41
+ artwork?: ArtworkContentT;
42
+ children: React.ReactNode;
43
+ hierarchy?: HIERARCHY[keyof HIERARCHY];
44
+ kind?: KIND[keyof KIND];
45
+ overrides?: {
46
+ BelowContent?: Override<any>;
47
+ LeadingContent?: Override<any>;
48
+ Message?: Override<any>;
49
+ MessageContent?: Override<any>;
50
+ Root?: Override<any>;
51
+ Title?: Override<any>;
52
+ TrailingContent?: Override<any>;
53
+ TrailingButtonContainer?: Override<any>;
54
+ TrailingIconButton?: Override<any>;
55
+ };
56
+ nested?: boolean;
57
+ title?: React.ReactNode;
58
+ }
59
+
60
+ export const StyledBelowContent: StyletronComponent<any>;
61
+ export const StyledLeadingContent: StyletronComponent<any>;
62
+ export const StyledMessage: StyletronComponent<any>;
63
+ export const StyledMessageContent: StyletronComponent<any>;
64
+ export const StyledRoot: StyletronComponent<any>;
65
+ export const StyledTitle: StyletronComponent<any>;
66
+ export const StyledTrailingContent: StyletronComponent<any>;
67
+ export const StyledTrailingButtonContainer: StyletronComponent<any>;
68
+ export const StyledTrailingIconButton: StyletronComponent<any>;
69
+
70
+ export const ACTION_POSITION: ACTION_POSITION;
71
+ export const ARTWORK_TYPE: ARTWORK_TYPE;
72
+ export const HIERARCHY: HIERARCHY;
73
+ export const KIND: KIND;
74
+
75
+ export const Banner: React.FC<PropsT>;