baseui 0.0.0-next-e90bd38 → 0.0.0-next-a48c2fd

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 (41) hide show
  1. package/banner/types.d.ts +12 -11
  2. package/banner/types.js.flow +13 -11
  3. package/es/layer/layer.js +24 -0
  4. package/es/layer/layers-manager.js +90 -1
  5. package/es/message-card/constants.js +19 -0
  6. package/es/message-card/index.js +10 -0
  7. package/es/message-card/message-card.js +112 -0
  8. package/es/message-card/styled-components.js +108 -0
  9. package/es/message-card/types.js +1 -0
  10. package/es/message-card/utils.js +27 -0
  11. package/esm/layer/layer.js +24 -0
  12. package/esm/layer/layers-manager.js +96 -1
  13. package/esm/message-card/constants.js +20 -0
  14. package/esm/message-card/index.js +10 -0
  15. package/esm/message-card/message-card.js +166 -0
  16. package/esm/message-card/styled-components.js +116 -0
  17. package/esm/message-card/types.js +1 -0
  18. package/esm/message-card/utils.js +26 -0
  19. package/layer/layer.js +24 -0
  20. package/layer/layer.js.flow +25 -0
  21. package/layer/layers-manager.d.ts +8 -0
  22. package/layer/layers-manager.js +96 -1
  23. package/layer/layers-manager.js.flow +84 -1
  24. package/layer/types.d.ts +21 -0
  25. package/layer/types.js.flow +22 -1
  26. package/message-card/constants.d.ts +12 -0
  27. package/message-card/constants.js +25 -0
  28. package/message-card/index.d.ts +4 -0
  29. package/message-card/index.js +60 -0
  30. package/message-card/index.js.flow +72 -0
  31. package/message-card/message-card.d.ts +4 -0
  32. package/message-card/message-card.js +182 -0
  33. package/message-card/package.json +4 -0
  34. package/message-card/styled-components.d.ts +14 -0
  35. package/message-card/styled-components.js +124 -0
  36. package/message-card/types.d.ts +27 -0
  37. package/message-card/types.js +5 -0
  38. package/message-card/utils.d.ts +1 -0
  39. package/message-card/utils.js +36 -0
  40. package/package.json +2 -2
  41. package/tokens/types.js.flow +27 -0
package/banner/types.d.ts CHANGED
@@ -20,23 +20,24 @@ export declare type ArtworkContent = {
20
20
  }) => React.ReactNode;
21
21
  type?: ArtworkType;
22
22
  };
23
+ export declare type BannerOverrides = {
24
+ BelowContent?: Override;
25
+ LeadingContent?: Override;
26
+ Message?: Override;
27
+ MessageContent?: Override;
28
+ Root?: Override;
29
+ Title?: Override;
30
+ TrailingContent?: Override;
31
+ TrailingButtonContainer?: Override;
32
+ TrailingIconButton?: Override;
33
+ };
23
34
  export declare type BannerProps = {
24
35
  action?: ActionContent;
25
36
  artwork?: ArtworkContent;
26
37
  children: React.ReactNode;
27
38
  hierarchy?: Hierarchy;
28
39
  kind?: Kind;
29
- overrides?: {
30
- BelowContent?: Override;
31
- LeadingContent?: Override;
32
- Message?: Override;
33
- MessageContent?: Override;
34
- Root?: Override;
35
- Title?: Override;
36
- TrailingContent?: Override;
37
- TrailingButtonContainer?: Override;
38
- TrailingIconButton?: Override;
39
- };
40
+ overrides?: BannerOverrides;
40
41
  nested?: boolean;
41
42
  title?: React.ReactNode;
42
43
  };
@@ -33,6 +33,18 @@ export type ArtworkContentT = {|
33
33
  type?: ArtworkTypeT,
34
34
  |};
35
35
 
36
+ export type OverridesT = {|
37
+ BelowContent?: OverrideT,
38
+ LeadingContent?: OverrideT,
39
+ Message?: OverrideT,
40
+ MessageContent?: OverrideT,
41
+ Root?: OverrideT,
42
+ Title?: OverrideT,
43
+ TrailingContent?: OverrideT,
44
+ TrailingButtonContainer?: OverrideT,
45
+ TrailingIconButton?: OverrideT,
46
+ |};
47
+
36
48
  export type PropsT = {|
37
49
  // Provide a method to "accept", "dismiss", or otherwise interact with the message shown.
38
50
  action?: ActionContentT,
@@ -44,17 +56,7 @@ export type PropsT = {|
44
56
  hierarchy?: HierarchyT,
45
57
  // Determines color scheme and conveys message intent.
46
58
  kind?: KindT,
47
- overrides?: {|
48
- BelowContent?: OverrideT,
49
- LeadingContent?: OverrideT,
50
- Message?: OverrideT,
51
- MessageContent?: OverrideT,
52
- Root?: OverrideT,
53
- Title?: OverrideT,
54
- TrailingContent?: OverrideT,
55
- TrailingButtonContainer?: OverrideT,
56
- TrailingIconButton?: OverrideT,
57
- |},
59
+ overrides?: OverridesT,
58
60
  // Used to make the banner visually distinct from its container element.
59
61
  nested?: boolean,
60
62
  // Bold text displayed when message content should be separated to two lines.
package/es/layer/layer.js CHANGED
@@ -39,6 +39,24 @@ class LayerComponent extends React.Component {
39
39
  }
40
40
  });
41
41
 
42
+ _defineProperty(this, "onKeyDown", event => {
43
+ if (this.props.onKeyDown) {
44
+ this.props.onKeyDown(event);
45
+ }
46
+ });
47
+
48
+ _defineProperty(this, "onKeyUp", event => {
49
+ if (this.props.onKeyUp) {
50
+ this.props.onKeyUp(event);
51
+ }
52
+ });
53
+
54
+ _defineProperty(this, "onKeyPress", event => {
55
+ if (this.props.onKeyPress) {
56
+ this.props.onKeyPress(event);
57
+ }
58
+ });
59
+
42
60
  _defineProperty(this, "onDocumentClick", event => {
43
61
  if (this.props.onDocumentClick) {
44
62
  this.props.onDocumentClick(event);
@@ -48,6 +66,9 @@ class LayerComponent extends React.Component {
48
66
 
49
67
  componentDidMount() {
50
68
  this.context.addEscapeHandler(this.onEscape);
69
+ this.context.addKeyDownHandler(this.onKeyDown);
70
+ this.context.addKeyUpHandler(this.onKeyUp);
71
+ this.context.addKeyPressHandler(this.onKeyPress);
51
72
 
52
73
  if (!this.props.isHoverLayer) {
53
74
  this.context.addDocClickHandler(this.onDocumentClick);
@@ -106,6 +127,9 @@ class LayerComponent extends React.Component {
106
127
 
107
128
  componentWillUnmount() {
108
129
  this.context.removeEscapeHandler(this.onEscape);
130
+ this.context.removeKeyDownHandler(this.onKeyDown);
131
+ this.context.removeKeyUpHandler(this.onKeyUp);
132
+ this.context.removeKeyPressHandler(this.onKeyPress);
109
133
  this.context.removeDocClickHandler(this.onDocumentClick);
110
134
 
111
135
  if (this.props.onUnmount) {
@@ -26,6 +26,12 @@ function defaultEventHandlerFn() {
26
26
  export const LayersContext = /*#__PURE__*/React.createContext({
27
27
  addEscapeHandler: defaultEventHandlerFn,
28
28
  removeEscapeHandler: defaultEventHandlerFn,
29
+ addKeyDownHandler: defaultEventHandlerFn,
30
+ removeKeyDownHandler: defaultEventHandlerFn,
31
+ addKeyUpHandler: defaultEventHandlerFn,
32
+ removeKeyUpHandler: defaultEventHandlerFn,
33
+ addKeyPressHandler: defaultEventHandlerFn,
34
+ removeKeyPressHandler: defaultEventHandlerFn,
29
35
  addDocClickHandler: defaultEventHandlerFn,
30
36
  removeDocClickHandler: defaultEventHandlerFn,
31
37
  host: undefined,
@@ -50,6 +56,14 @@ export default class LayersManager extends React.Component {
50
56
  }
51
57
  });
52
58
 
59
+ _defineProperty(this, "onKeyDown", event => {
60
+ const keyDownHandler = this.state.keyDownHandlers[this.state.keyDownHandlers.length - 1];
61
+
62
+ if (keyDownHandler) {
63
+ keyDownHandler(event);
64
+ }
65
+ });
66
+
53
67
  _defineProperty(this, "onKeyUp", event => {
54
68
  if (event.key === 'Escape') {
55
69
  const escapeKeyHandler = this.state.escapeKeyHandlers[this.state.escapeKeyHandlers.length - 1];
@@ -58,6 +72,20 @@ export default class LayersManager extends React.Component {
58
72
  escapeKeyHandler();
59
73
  }
60
74
  }
75
+
76
+ const keyUpHandler = this.state.keyUpHandlers[this.state.keyUpHandlers.length - 1];
77
+
78
+ if (keyUpHandler) {
79
+ keyUpHandler(event);
80
+ }
81
+ });
82
+
83
+ _defineProperty(this, "onKeyPress", event => {
84
+ const keyPressHandler = this.state.keyPressHandlers[this.state.keyPressHandlers.length - 1];
85
+
86
+ if (keyPressHandler) {
87
+ keyPressHandler(event);
88
+ }
61
89
  });
62
90
 
63
91
  _defineProperty(this, "onAddEscapeHandler", escapeKeyHandler => {
@@ -76,6 +104,54 @@ export default class LayersManager extends React.Component {
76
104
  });
77
105
  });
78
106
 
107
+ _defineProperty(this, "onAddKeyDownHandler", keyDownHandler => {
108
+ this.setState(prev => {
109
+ return {
110
+ keyDownHandlers: [...prev.keyDownHandlers, keyDownHandler]
111
+ };
112
+ });
113
+ });
114
+
115
+ _defineProperty(this, "onRemoveKeyDownHandler", keyDownHandler => {
116
+ this.setState(prev => {
117
+ return {
118
+ keyDownHandlers: prev.keyDownHandlers.filter(handler => handler !== keyDownHandler)
119
+ };
120
+ });
121
+ });
122
+
123
+ _defineProperty(this, "onAddKeyUpHandler", keyUpHandler => {
124
+ this.setState(prev => {
125
+ return {
126
+ keyUpHandlers: [...prev.keyUpHandlers, keyUpHandler]
127
+ };
128
+ });
129
+ });
130
+
131
+ _defineProperty(this, "onRemoveKeyUpHandler", keyUpHandler => {
132
+ this.setState(prev => {
133
+ return {
134
+ keyUpHandlers: prev.keyUpHandlers.filter(handler => handler !== keyUpHandler)
135
+ };
136
+ });
137
+ });
138
+
139
+ _defineProperty(this, "onAddKeyPressHandler", keyPressHandler => {
140
+ this.setState(prev => {
141
+ return {
142
+ keyPressHandlers: [...prev.keyPressHandlers, keyPressHandler]
143
+ };
144
+ });
145
+ });
146
+
147
+ _defineProperty(this, "onRemoveKeyPressHandler", keyPressHandler => {
148
+ this.setState(prev => {
149
+ return {
150
+ keyPressHandlers: prev.keyPressHandlers.filter(handler => handler !== keyPressHandler)
151
+ };
152
+ });
153
+ });
154
+
79
155
  _defineProperty(this, "onAddDocClickHandler", docClickHandler => {
80
156
  this.setState(prev => {
81
157
  return {
@@ -94,6 +170,9 @@ export default class LayersManager extends React.Component {
94
170
 
95
171
  this.state = {
96
172
  escapeKeyHandlers: [],
173
+ keyDownHandlers: [],
174
+ keyUpHandlers: [],
175
+ keyPressHandlers: [],
97
176
  docClickHandlers: []
98
177
  };
99
178
  }
@@ -103,7 +182,9 @@ export default class LayersManager extends React.Component {
103
182
  initFocusVisible(this.containerRef.current);
104
183
 
105
184
  if (typeof document !== 'undefined') {
106
- document.addEventListener('keyup', this.onKeyUp); // using mousedown event so that callback runs before events on children inside of the layer
185
+ document.addEventListener('keydown', this.onKeyDown);
186
+ document.addEventListener('keyup', this.onKeyUp);
187
+ document.addEventListener('keypress', this.onKeyPress); // using mousedown event so that callback runs before events on children inside of the layer
107
188
 
108
189
  document.addEventListener('mousedown', this.onDocumentClick);
109
190
  }
@@ -111,7 +192,9 @@ export default class LayersManager extends React.Component {
111
192
 
112
193
  componentWillUnmount() {
113
194
  if (typeof document !== 'undefined') {
195
+ document.removeEventListener('keydown', this.onKeyDown);
114
196
  document.removeEventListener('keyup', this.onKeyUp);
197
+ document.removeEventListener('keypress', this.onKeyPress);
115
198
  document.removeEventListener('mousedown', this.onDocumentClick);
116
199
  }
117
200
  }
@@ -138,6 +221,12 @@ export default class LayersManager extends React.Component {
138
221
  zIndex: this.props.zIndex,
139
222
  addEscapeHandler: this.onAddEscapeHandler,
140
223
  removeEscapeHandler: this.onRemoveEscapeHandler,
224
+ addKeyDownHandler: this.onAddKeyDownHandler,
225
+ removeKeyDownHandler: this.onRemoveKeyDownHandler,
226
+ addKeyUpHandler: this.onAddKeyUpHandler,
227
+ removeKeyUpHandler: this.onRemoveKeyUpHandler,
228
+ addKeyPressHandler: this.onAddKeyPressHandler,
229
+ removeKeyPressHandler: this.onRemoveKeyPressHandler,
141
230
  addDocClickHandler: this.onAddDocClickHandler,
142
231
  removeDocClickHandler: this.onRemoveDocClickHandler
143
232
  }
@@ -0,0 +1,19 @@
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 { KIND } from '../button';
8
+ export const BACKGROUND_COLOR_TYPE = Object.freeze({
9
+ light: 'light',
10
+ dark: 'dark'
11
+ });
12
+ export const IMAGE_LAYOUT = Object.freeze({
13
+ top: 'top',
14
+ trailing: 'trailing'
15
+ });
16
+ export const BUTTON_KIND = Object.freeze({
17
+ [KIND.secondary]: KIND.secondary,
18
+ [KIND.tertiary]: KIND.tertiary
19
+ });
@@ -0,0 +1,10 @@
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 MessageCard } from './message-card';
8
+ export * from './constants';
9
+ export * from './styled-components';
10
+ export * from './types';
@@ -0,0 +1,112 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 { StyledRoot, StyledImage, StyledContentContainer, StyledHeadingContainer, StyledParagraphContainer } from './styled-components';
11
+ import { Button as DefaultButton, SHAPE, SIZE } from '../button';
12
+ import { useStyletron } from '../styles/index.js';
13
+ import { ThemeProvider, LightTheme } from '../';
14
+ import { getBackgroundColorType } from './utils';
15
+ import { colors } from '../tokens';
16
+ import { getOverrides } from '../helpers/overrides';
17
+ import { IMAGE_LAYOUT, BACKGROUND_COLOR_TYPE, BUTTON_KIND } from './constants';
18
+
19
+ const ButtonAlwaysLightTheme = ({
20
+ children,
21
+ ...restProps
22
+ }) => /*#__PURE__*/React.createElement(ThemeProvider, {
23
+ theme: LightTheme
24
+ }, /*#__PURE__*/React.createElement(DefaultButton, restProps, children));
25
+
26
+ const MessageCard = ({
27
+ backgroundColor = colors.white,
28
+ backgroundColorType: backgroundColorTypeProp,
29
+ buttonKind = BUTTON_KIND.secondary,
30
+ buttonLabel,
31
+ heading,
32
+ image,
33
+ onClick,
34
+ overrides = {},
35
+ paragraph
36
+ }) => {
37
+ const {
38
+ src,
39
+ layout = IMAGE_LAYOUT.top,
40
+ backgroundPosition,
41
+ ariaLabel
42
+ } = image || {};
43
+ const [Root, RootProps] = getOverrides(overrides.Root, StyledRoot);
44
+ const [ContentContainer, ContentContainerProps] = getOverrides(overrides.ContentContainer, StyledContentContainer);
45
+ const [HeadingContainer, HeadingContainerProps] = getOverrides(overrides.HeadingContainer, StyledHeadingContainer);
46
+ const [ParagraphContainer, ParagraphContainerProps] = getOverrides(overrides.ParagraphContainer, StyledParagraphContainer);
47
+ const [Image, ImageProps] = getOverrides(overrides.Image, StyledImage);
48
+ const [Button, ButtonProps] = getOverrides(overrides.Button, ButtonAlwaysLightTheme);
49
+ const [, theme] = useStyletron();
50
+ let backgroundColorType = backgroundColorTypeProp || getBackgroundColorType(backgroundColor);
51
+
52
+ if (!backgroundColorType) {
53
+ backgroundColorType = BACKGROUND_COLOR_TYPE.dark;
54
+
55
+ if (process.env.NODE_ENV !== "production") {
56
+ console.warn(`The provided value for 'backgroundColor', ${backgroundColor}, is not recognized as a \
57
+ Base Web primitive color. Please use the 'backgroundColorType' prop to indicate whether\
58
+ this color is light or dark so the rest of the component can be styled accordingly.`);
59
+ }
60
+ }
61
+
62
+ let buttonColors;
63
+
64
+ if (buttonKind === BUTTON_KIND.tertiary && backgroundColorType === BACKGROUND_COLOR_TYPE.dark) {
65
+ buttonColors = {
66
+ color: theme.colors.contentOnColor,
67
+ backgroundColor: theme.colors.buttonTertiaryFill
68
+ };
69
+ }
70
+
71
+ if (buttonKind !== BUTTON_KIND.tertiary && backgroundColor !== colors.white) {
72
+ buttonColors = {
73
+ color: theme.colors.contentOnColorInverse,
74
+ backgroundColor: theme.colors.backgroundAlwaysLight
75
+ };
76
+ }
77
+
78
+ return /*#__PURE__*/React.createElement(Root, _extends({
79
+ onClick: onClick,
80
+ $backgroundColor: backgroundColor,
81
+ $backgroundColorType: backgroundColorType,
82
+ $imageLayout: layout
83
+ }, RootProps), image && /*#__PURE__*/React.createElement(Image, _extends({
84
+ role: "img",
85
+ ariaLabel: ariaLabel,
86
+ $src: src,
87
+ $imageLayout: layout,
88
+ $backgroundPosition: backgroundPosition
89
+ }, ImageProps)), /*#__PURE__*/React.createElement(ContentContainer, ContentContainerProps, heading && /*#__PURE__*/React.createElement(HeadingContainer, HeadingContainerProps, heading), paragraph && /*#__PURE__*/React.createElement(ParagraphContainer, ParagraphContainerProps, paragraph), buttonLabel && /*#__PURE__*/React.createElement(Button, _extends({
90
+ kind: buttonKind,
91
+ shape: SHAPE.pill,
92
+ size: SIZE.compact,
93
+ role: "none",
94
+ tabIndex: -1,
95
+ colors: buttonColors,
96
+ overrides: {
97
+ BaseButton: {
98
+ style: {
99
+ pointerEvents: 'none',
100
+ ...(buttonKind === BUTTON_KIND.tertiary ? {
101
+ marginTop: theme.sizing.scale100,
102
+ transform: theme.direction === 'rtl' ? `translateX(${theme.sizing.scale500})` : `translateX(-${theme.sizing.scale500})`
103
+ } : {
104
+ marginTop: theme.sizing.scale500
105
+ })
106
+ }
107
+ }
108
+ }
109
+ }, ButtonProps), buttonLabel)));
110
+ };
111
+
112
+ export default MessageCard;
@@ -0,0 +1,108 @@
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';
8
+ import { IMAGE_LAYOUT, BACKGROUND_COLOR_TYPE } from './constants';
9
+ export const StyledRoot = styled('button', ({
10
+ $theme,
11
+ $backgroundColor,
12
+ $backgroundColorType,
13
+ $imageLayout = IMAGE_LAYOUT.top
14
+ }) => {
15
+ const lightBackgroundStyle = {
16
+ color: $theme.colors.contentOnColorInverse,
17
+ borderStyle: 'solid',
18
+ borderWidth: $theme.sizing.scale0,
19
+ borderColor: $theme.colors.borderOpaque
20
+ };
21
+ const darkBackgroundStyle = {
22
+ color: $theme.colors.contentOnColor,
23
+ border: 'none'
24
+ };
25
+ return {
26
+ alignItems: 'stretch',
27
+ backgroundColor: $backgroundColor,
28
+ borderRadius: $theme.borders.radius400,
29
+ cursor: 'pointer',
30
+ display: 'flex',
31
+ flexDirection: $imageLayout === IMAGE_LAYOUT.top ? 'column' : 'row',
32
+ overflow: 'hidden',
33
+ padding: '0',
34
+ position: 'relative',
35
+ textAlign: 'start',
36
+ width: '100%',
37
+ boxShadow: `inset 999px 999px 0px ${$theme.colors.backgroundOverlayArt}`,
38
+ ...($backgroundColorType === BACKGROUND_COLOR_TYPE.light ? lightBackgroundStyle : darkBackgroundStyle),
39
+ ':focus': {
40
+ outlineWidth: '3px',
41
+ outlineStyle: 'solid',
42
+ outlineColor: $theme.colors.borderAccent,
43
+ outlineOffset: '-3px'
44
+ },
45
+ ':hover:after': {
46
+ content: '""',
47
+ width: '100%',
48
+ height: '100%',
49
+ zIndex: '1',
50
+ position: 'absolute',
51
+ top: '0',
52
+ left: '0',
53
+ backgroundColor: $backgroundColorType === BACKGROUND_COLOR_TYPE.light ? 'rgba(0, 0, 0, 0.04)' : 'rgba(255, 255, 255, 0.10)'
54
+ },
55
+ ':active:after': {
56
+ content: '""',
57
+ width: '100%',
58
+ height: '100%',
59
+ zIndex: '1',
60
+ position: 'absolute',
61
+ top: '0',
62
+ left: '0',
63
+ backgroundColor: $backgroundColorType === BACKGROUND_COLOR_TYPE.light ? 'rgba(0, 0, 0, 0.08)' : 'rgba(255, 255, 255, 0.20)'
64
+ }
65
+ };
66
+ });
67
+ StyledRoot.displayName = "StyledRoot";
68
+ export const StyledImage = styled('div', ({
69
+ $imageLayout = IMAGE_LAYOUT.top,
70
+ $backgroundPosition = 'center',
71
+ $src
72
+ }) => {
73
+ return {
74
+ backgroundImage: `url(${$src})`,
75
+ backgroundSize: 'cover',
76
+ backgroundPosition: $backgroundPosition,
77
+ ...($imageLayout === IMAGE_LAYOUT.top ? {
78
+ height: '132px',
79
+ width: '100%'
80
+ } : {
81
+ width: '112px',
82
+ order: '1'
83
+ })
84
+ };
85
+ });
86
+ StyledImage.displayName = "StyledImage";
87
+ export const StyledContentContainer = styled('div', ({
88
+ $theme
89
+ }) => ({
90
+ width: '100%',
91
+ boxSizing: 'border-box',
92
+ paddingTop: $theme.sizing.scale600,
93
+ paddingRight: $theme.sizing.scale300,
94
+ paddingBottom: $theme.sizing.scale600,
95
+ paddingLeft: $theme.sizing.scale600
96
+ }));
97
+ StyledContentContainer.displayName = "StyledContentContainer";
98
+ export const StyledHeadingContainer = styled('div', ({
99
+ $theme
100
+ }) => ({ ...$theme.typography.HeadingXSmall
101
+ }));
102
+ StyledHeadingContainer.displayName = "StyledHeadingContainer";
103
+ export const StyledParagraphContainer = styled('div', ({
104
+ $theme
105
+ }) => ({ ...$theme.typography.ParagraphSmall,
106
+ marginTop: $theme.sizing.scale100
107
+ }));
108
+ StyledParagraphContainer.displayName = "StyledParagraphContainer";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
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 { colors } from '../tokens';
8
+ import { BACKGROUND_COLOR_TYPE } from './constants';
9
+ const LIGHT_COLORS = new Set([colors.red50, colors.red100, colors.red200, colors.red300, colors.green50, colors.green100, colors.green200, colors.green300, colors.teal50, colors.teal100, colors.teal200, colors.teal300, colors.blue50, colors.blue100, colors.blue200, colors.blue300, colors.cobalt50, colors.cobalt100, colors.cobalt200, colors.purple50, colors.purple100, colors.purple200, colors.purple300, colors.magenta50, colors.magenta100, colors.magenta200, colors.magenta300, colors.brown50, colors.brown100, colors.brown200, colors.brown300, colors.orange50, colors.orange100, colors.orange200, colors.orange300, colors.orange400, colors.lime50, colors.lime100, colors.lime200, colors.lime300, colors.lime400, colors.platinum50, colors.platinum100, colors.platinum200, colors.platinum300, colors.platinum400, colors.yellow50, colors.yellow100, colors.yellow200, colors.yellow300, colors.yellow400, colors.yellow500, colors.white, colors.gray50, colors.gray100, colors.gray200, colors.gray300, colors.gray400]);
10
+ const DARK_COLORS = new Set([colors.red400, colors.red500, colors.red600, colors.red700, colors.green400, colors.green500, colors.green600, colors.green700, colors.teal400, colors.teal500, colors.teal600, colors.teal700, colors.blue400, colors.blue500, colors.blue600, colors.blue700, colors.cobalt300, colors.cobalt400, colors.cobalt500, colors.cobalt600, colors.cobalt700, colors.purple400, colors.purple500, colors.purple600, colors.purple700, colors.magenta400, colors.magenta500, colors.magenta600, colors.magenta700, colors.brown400, colors.brown500, colors.brown600, colors.brown700, colors.orange500, colors.orange600, colors.orange700, colors.lime500, colors.lime600, colors.lime700, colors.platinum500, colors.platinum600, colors.platinum700, colors.platinum800, colors.yellow600, colors.yellow700, colors.gray500, colors.gray600, colors.gray700, colors.gray800, colors.gray900, colors.black]);
11
+ const POOR_CONTRAST_COLORS = new Set([colors.red300, colors.gray500, colors.yellow600]);
12
+ export function getBackgroundColorType(backgroundColor) {
13
+ if (process.env.NODE_ENV !== "production" && POOR_CONTRAST_COLORS.has(backgroundColor)) {
14
+ console.warn(`The provided value for backgroundColor, ${backgroundColor}, is not supported because \
15
+ it does not pass accessibility contrast tests for either white or black text.`);
16
+ }
17
+
18
+ if (LIGHT_COLORS.has(backgroundColor)) {
19
+ return BACKGROUND_COLOR_TYPE.light;
20
+ }
21
+
22
+ if (DARK_COLORS.has(backgroundColor)) {
23
+ return BACKGROUND_COLOR_TYPE.dark;
24
+ }
25
+
26
+ return null;
27
+ }
@@ -74,6 +74,24 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
74
74
  }
75
75
  });
76
76
 
77
+ _defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
78
+ if (_this.props.onKeyDown) {
79
+ _this.props.onKeyDown(event);
80
+ }
81
+ });
82
+
83
+ _defineProperty(_assertThisInitialized(_this), "onKeyUp", function (event) {
84
+ if (_this.props.onKeyUp) {
85
+ _this.props.onKeyUp(event);
86
+ }
87
+ });
88
+
89
+ _defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
90
+ if (_this.props.onKeyPress) {
91
+ _this.props.onKeyPress(event);
92
+ }
93
+ });
94
+
77
95
  _defineProperty(_assertThisInitialized(_this), "onDocumentClick", function (event) {
78
96
  if (_this.props.onDocumentClick) {
79
97
  _this.props.onDocumentClick(event);
@@ -87,6 +105,9 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
87
105
  key: "componentDidMount",
88
106
  value: function componentDidMount() {
89
107
  this.context.addEscapeHandler(this.onEscape);
108
+ this.context.addKeyDownHandler(this.onKeyDown);
109
+ this.context.addKeyUpHandler(this.onKeyUp);
110
+ this.context.addKeyPressHandler(this.onKeyPress);
90
111
 
91
112
  if (!this.props.isHoverLayer) {
92
113
  this.context.addDocClickHandler(this.onDocumentClick);
@@ -145,6 +166,9 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
145
166
  key: "componentWillUnmount",
146
167
  value: function componentWillUnmount() {
147
168
  this.context.removeEscapeHandler(this.onEscape);
169
+ this.context.removeKeyDownHandler(this.onKeyDown);
170
+ this.context.removeKeyUpHandler(this.onKeyUp);
171
+ this.context.removeKeyPressHandler(this.onKeyPress);
148
172
  this.context.removeDocClickHandler(this.onDocumentClick);
149
173
 
150
174
  if (this.props.onUnmount) {