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.
- package/banner/types.d.ts +12 -11
- package/banner/types.js.flow +13 -11
- package/es/layer/layer.js +24 -0
- package/es/layer/layers-manager.js +90 -1
- package/es/message-card/constants.js +19 -0
- package/es/message-card/index.js +10 -0
- package/es/message-card/message-card.js +112 -0
- package/es/message-card/styled-components.js +108 -0
- package/es/message-card/types.js +1 -0
- package/es/message-card/utils.js +27 -0
- package/esm/layer/layer.js +24 -0
- package/esm/layer/layers-manager.js +96 -1
- package/esm/message-card/constants.js +20 -0
- package/esm/message-card/index.js +10 -0
- package/esm/message-card/message-card.js +166 -0
- package/esm/message-card/styled-components.js +116 -0
- package/esm/message-card/types.js +1 -0
- package/esm/message-card/utils.js +26 -0
- package/layer/layer.js +24 -0
- package/layer/layer.js.flow +25 -0
- package/layer/layers-manager.d.ts +8 -0
- package/layer/layers-manager.js +96 -1
- package/layer/layers-manager.js.flow +84 -1
- package/layer/types.d.ts +21 -0
- package/layer/types.js.flow +22 -1
- package/message-card/constants.d.ts +12 -0
- package/message-card/constants.js +25 -0
- package/message-card/index.d.ts +4 -0
- package/message-card/index.js +60 -0
- package/message-card/index.js.flow +72 -0
- package/message-card/message-card.d.ts +4 -0
- package/message-card/message-card.js +182 -0
- package/message-card/package.json +4 -0
- package/message-card/styled-components.d.ts +14 -0
- package/message-card/styled-components.js +124 -0
- package/message-card/types.d.ts +27 -0
- package/message-card/types.js +5 -0
- package/message-card/utils.d.ts +1 -0
- package/message-card/utils.js +36 -0
- package/package.json +2 -2
- package/tokens/types.js.flow +27 -0
|
@@ -68,6 +68,12 @@ function defaultEventHandlerFn() {
|
|
|
68
68
|
export var LayersContext = /*#__PURE__*/React.createContext({
|
|
69
69
|
addEscapeHandler: defaultEventHandlerFn,
|
|
70
70
|
removeEscapeHandler: defaultEventHandlerFn,
|
|
71
|
+
addKeyDownHandler: defaultEventHandlerFn,
|
|
72
|
+
removeKeyDownHandler: defaultEventHandlerFn,
|
|
73
|
+
addKeyUpHandler: defaultEventHandlerFn,
|
|
74
|
+
removeKeyUpHandler: defaultEventHandlerFn,
|
|
75
|
+
addKeyPressHandler: defaultEventHandlerFn,
|
|
76
|
+
removeKeyPressHandler: defaultEventHandlerFn,
|
|
71
77
|
addDocClickHandler: defaultEventHandlerFn,
|
|
72
78
|
removeDocClickHandler: defaultEventHandlerFn,
|
|
73
79
|
host: undefined,
|
|
@@ -101,6 +107,14 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
101
107
|
}
|
|
102
108
|
});
|
|
103
109
|
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
111
|
+
var keyDownHandler = _this.state.keyDownHandlers[_this.state.keyDownHandlers.length - 1];
|
|
112
|
+
|
|
113
|
+
if (keyDownHandler) {
|
|
114
|
+
keyDownHandler(event);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
104
118
|
_defineProperty(_assertThisInitialized(_this), "onKeyUp", function (event) {
|
|
105
119
|
if (event.key === 'Escape') {
|
|
106
120
|
var escapeKeyHandler = _this.state.escapeKeyHandlers[_this.state.escapeKeyHandlers.length - 1];
|
|
@@ -109,6 +123,20 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
109
123
|
escapeKeyHandler();
|
|
110
124
|
}
|
|
111
125
|
}
|
|
126
|
+
|
|
127
|
+
var keyUpHandler = _this.state.keyUpHandlers[_this.state.keyUpHandlers.length - 1];
|
|
128
|
+
|
|
129
|
+
if (keyUpHandler) {
|
|
130
|
+
keyUpHandler(event);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
|
|
135
|
+
var keyPressHandler = _this.state.keyPressHandlers[_this.state.keyPressHandlers.length - 1];
|
|
136
|
+
|
|
137
|
+
if (keyPressHandler) {
|
|
138
|
+
keyPressHandler(event);
|
|
139
|
+
}
|
|
112
140
|
});
|
|
113
141
|
|
|
114
142
|
_defineProperty(_assertThisInitialized(_this), "onAddEscapeHandler", function (escapeKeyHandler) {
|
|
@@ -129,6 +157,60 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
129
157
|
});
|
|
130
158
|
});
|
|
131
159
|
|
|
160
|
+
_defineProperty(_assertThisInitialized(_this), "onAddKeyDownHandler", function (keyDownHandler) {
|
|
161
|
+
_this.setState(function (prev) {
|
|
162
|
+
return {
|
|
163
|
+
keyDownHandlers: [].concat(_toConsumableArray(prev.keyDownHandlers), [keyDownHandler])
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
_defineProperty(_assertThisInitialized(_this), "onRemoveKeyDownHandler", function (keyDownHandler) {
|
|
169
|
+
_this.setState(function (prev) {
|
|
170
|
+
return {
|
|
171
|
+
keyDownHandlers: prev.keyDownHandlers.filter(function (handler) {
|
|
172
|
+
return handler !== keyDownHandler;
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
_defineProperty(_assertThisInitialized(_this), "onAddKeyUpHandler", function (keyUpHandler) {
|
|
179
|
+
_this.setState(function (prev) {
|
|
180
|
+
return {
|
|
181
|
+
keyUpHandlers: [].concat(_toConsumableArray(prev.keyUpHandlers), [keyUpHandler])
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
_defineProperty(_assertThisInitialized(_this), "onRemoveKeyUpHandler", function (keyUpHandler) {
|
|
187
|
+
_this.setState(function (prev) {
|
|
188
|
+
return {
|
|
189
|
+
keyUpHandlers: prev.keyUpHandlers.filter(function (handler) {
|
|
190
|
+
return handler !== keyUpHandler;
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
_defineProperty(_assertThisInitialized(_this), "onAddKeyPressHandler", function (keyPressHandler) {
|
|
197
|
+
_this.setState(function (prev) {
|
|
198
|
+
return {
|
|
199
|
+
keyPressHandlers: [].concat(_toConsumableArray(prev.keyPressHandlers), [keyPressHandler])
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
_defineProperty(_assertThisInitialized(_this), "onRemoveKeyPressHandler", function (keyPressHandler) {
|
|
205
|
+
_this.setState(function (prev) {
|
|
206
|
+
return {
|
|
207
|
+
keyPressHandlers: prev.keyPressHandlers.filter(function (handler) {
|
|
208
|
+
return handler !== keyPressHandler;
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
132
214
|
_defineProperty(_assertThisInitialized(_this), "onAddDocClickHandler", function (docClickHandler) {
|
|
133
215
|
_this.setState(function (prev) {
|
|
134
216
|
return {
|
|
@@ -149,6 +231,9 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
149
231
|
|
|
150
232
|
_this.state = {
|
|
151
233
|
escapeKeyHandlers: [],
|
|
234
|
+
keyDownHandlers: [],
|
|
235
|
+
keyUpHandlers: [],
|
|
236
|
+
keyPressHandlers: [],
|
|
152
237
|
docClickHandlers: []
|
|
153
238
|
};
|
|
154
239
|
return _this;
|
|
@@ -161,7 +246,9 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
161
246
|
initFocusVisible(this.containerRef.current);
|
|
162
247
|
|
|
163
248
|
if (typeof document !== 'undefined') {
|
|
164
|
-
document.addEventListener('
|
|
249
|
+
document.addEventListener('keydown', this.onKeyDown);
|
|
250
|
+
document.addEventListener('keyup', this.onKeyUp);
|
|
251
|
+
document.addEventListener('keypress', this.onKeyPress); // using mousedown event so that callback runs before events on children inside of the layer
|
|
165
252
|
|
|
166
253
|
document.addEventListener('mousedown', this.onDocumentClick);
|
|
167
254
|
}
|
|
@@ -170,7 +257,9 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
170
257
|
key: "componentWillUnmount",
|
|
171
258
|
value: function componentWillUnmount() {
|
|
172
259
|
if (typeof document !== 'undefined') {
|
|
260
|
+
document.removeEventListener('keydown', this.onKeyDown);
|
|
173
261
|
document.removeEventListener('keyup', this.onKeyUp);
|
|
262
|
+
document.removeEventListener('keypress', this.onKeyPress);
|
|
174
263
|
document.removeEventListener('mousedown', this.onDocumentClick);
|
|
175
264
|
}
|
|
176
265
|
}
|
|
@@ -208,6 +297,12 @@ var LayersManager = /*#__PURE__*/function (_React$Component) {
|
|
|
208
297
|
zIndex: _this2.props.zIndex,
|
|
209
298
|
addEscapeHandler: _this2.onAddEscapeHandler,
|
|
210
299
|
removeEscapeHandler: _this2.onRemoveEscapeHandler,
|
|
300
|
+
addKeyDownHandler: _this2.onAddKeyDownHandler,
|
|
301
|
+
removeKeyDownHandler: _this2.onRemoveKeyDownHandler,
|
|
302
|
+
addKeyUpHandler: _this2.onAddKeyUpHandler,
|
|
303
|
+
removeKeyUpHandler: _this2.onRemoveKeyUpHandler,
|
|
304
|
+
addKeyPressHandler: _this2.onAddKeyPressHandler,
|
|
305
|
+
removeKeyPressHandler: _this2.onRemoveKeyPressHandler,
|
|
211
306
|
addDocClickHandler: _this2.onAddDocClickHandler,
|
|
212
307
|
removeDocClickHandler: _this2.onRemoveDocClickHandler
|
|
213
308
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var _Object$freeze;
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Copyright (c) Uber Technologies, Inc.
|
|
7
|
+
|
|
8
|
+
This source code is licensed under the MIT license found in the
|
|
9
|
+
LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
import { KIND } from '../button';
|
|
12
|
+
export var BACKGROUND_COLOR_TYPE = Object.freeze({
|
|
13
|
+
light: 'light',
|
|
14
|
+
dark: 'dark'
|
|
15
|
+
});
|
|
16
|
+
export var IMAGE_LAYOUT = Object.freeze({
|
|
17
|
+
top: 'top',
|
|
18
|
+
trailing: 'trailing'
|
|
19
|
+
});
|
|
20
|
+
export var BUTTON_KIND = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, KIND.secondary, KIND.secondary), _defineProperty(_Object$freeze, KIND.tertiary, KIND.tertiary), _Object$freeze));
|
|
@@ -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,166 @@
|
|
|
1
|
+
var _excluded = ["children"];
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
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); }
|
|
10
|
+
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
|
|
13
|
+
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."); }
|
|
14
|
+
|
|
15
|
+
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); }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
|
|
20
|
+
|
|
21
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
|
|
25
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
Copyright (c) Uber Technologies, Inc.
|
|
29
|
+
|
|
30
|
+
This source code is licensed under the MIT license found in the
|
|
31
|
+
LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
|
33
|
+
import * as React from 'react';
|
|
34
|
+
import { StyledRoot, StyledImage, StyledContentContainer, StyledHeadingContainer, StyledParagraphContainer } from './styled-components';
|
|
35
|
+
import { Button as DefaultButton, SHAPE, SIZE } from '../button';
|
|
36
|
+
import { useStyletron } from '../styles/index.js';
|
|
37
|
+
import { ThemeProvider, LightTheme } from '../';
|
|
38
|
+
import { getBackgroundColorType } from './utils';
|
|
39
|
+
import { colors } from '../tokens';
|
|
40
|
+
import { getOverrides } from '../helpers/overrides';
|
|
41
|
+
import { IMAGE_LAYOUT, BACKGROUND_COLOR_TYPE, BUTTON_KIND } from './constants';
|
|
42
|
+
|
|
43
|
+
var ButtonAlwaysLightTheme = function ButtonAlwaysLightTheme(_ref) {
|
|
44
|
+
var children = _ref.children,
|
|
45
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
48
|
+
theme: LightTheme
|
|
49
|
+
}, /*#__PURE__*/React.createElement(DefaultButton, restProps, children));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var MessageCard = function MessageCard(_ref2) {
|
|
53
|
+
var _ref2$backgroundColor = _ref2.backgroundColor,
|
|
54
|
+
backgroundColor = _ref2$backgroundColor === void 0 ? colors.white : _ref2$backgroundColor,
|
|
55
|
+
backgroundColorTypeProp = _ref2.backgroundColorType,
|
|
56
|
+
_ref2$buttonKind = _ref2.buttonKind,
|
|
57
|
+
buttonKind = _ref2$buttonKind === void 0 ? BUTTON_KIND.secondary : _ref2$buttonKind,
|
|
58
|
+
buttonLabel = _ref2.buttonLabel,
|
|
59
|
+
heading = _ref2.heading,
|
|
60
|
+
image = _ref2.image,
|
|
61
|
+
onClick = _ref2.onClick,
|
|
62
|
+
_ref2$overrides = _ref2.overrides,
|
|
63
|
+
overrides = _ref2$overrides === void 0 ? {} : _ref2$overrides,
|
|
64
|
+
paragraph = _ref2.paragraph;
|
|
65
|
+
|
|
66
|
+
var _ref3 = image || {},
|
|
67
|
+
src = _ref3.src,
|
|
68
|
+
_ref3$layout = _ref3.layout,
|
|
69
|
+
layout = _ref3$layout === void 0 ? IMAGE_LAYOUT.top : _ref3$layout,
|
|
70
|
+
backgroundPosition = _ref3.backgroundPosition,
|
|
71
|
+
ariaLabel = _ref3.ariaLabel;
|
|
72
|
+
|
|
73
|
+
var _getOverrides = getOverrides(overrides.Root, StyledRoot),
|
|
74
|
+
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
75
|
+
Root = _getOverrides2[0],
|
|
76
|
+
RootProps = _getOverrides2[1];
|
|
77
|
+
|
|
78
|
+
var _getOverrides3 = getOverrides(overrides.ContentContainer, StyledContentContainer),
|
|
79
|
+
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
80
|
+
ContentContainer = _getOverrides4[0],
|
|
81
|
+
ContentContainerProps = _getOverrides4[1];
|
|
82
|
+
|
|
83
|
+
var _getOverrides5 = getOverrides(overrides.HeadingContainer, StyledHeadingContainer),
|
|
84
|
+
_getOverrides6 = _slicedToArray(_getOverrides5, 2),
|
|
85
|
+
HeadingContainer = _getOverrides6[0],
|
|
86
|
+
HeadingContainerProps = _getOverrides6[1];
|
|
87
|
+
|
|
88
|
+
var _getOverrides7 = getOverrides(overrides.ParagraphContainer, StyledParagraphContainer),
|
|
89
|
+
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
90
|
+
ParagraphContainer = _getOverrides8[0],
|
|
91
|
+
ParagraphContainerProps = _getOverrides8[1];
|
|
92
|
+
|
|
93
|
+
var _getOverrides9 = getOverrides(overrides.Image, StyledImage),
|
|
94
|
+
_getOverrides10 = _slicedToArray(_getOverrides9, 2),
|
|
95
|
+
Image = _getOverrides10[0],
|
|
96
|
+
ImageProps = _getOverrides10[1];
|
|
97
|
+
|
|
98
|
+
var _getOverrides11 = getOverrides(overrides.Button, ButtonAlwaysLightTheme),
|
|
99
|
+
_getOverrides12 = _slicedToArray(_getOverrides11, 2),
|
|
100
|
+
Button = _getOverrides12[0],
|
|
101
|
+
ButtonProps = _getOverrides12[1];
|
|
102
|
+
|
|
103
|
+
var _useStyletron = useStyletron(),
|
|
104
|
+
_useStyletron2 = _slicedToArray(_useStyletron, 2),
|
|
105
|
+
theme = _useStyletron2[1];
|
|
106
|
+
|
|
107
|
+
var backgroundColorType = backgroundColorTypeProp || getBackgroundColorType(backgroundColor);
|
|
108
|
+
|
|
109
|
+
if (!backgroundColorType) {
|
|
110
|
+
backgroundColorType = BACKGROUND_COLOR_TYPE.dark;
|
|
111
|
+
|
|
112
|
+
if (process.env.NODE_ENV !== "production") {
|
|
113
|
+
console.warn("The provided value for 'backgroundColor', ".concat(backgroundColor, ", is not recognized as a Base Web primitive color. Please use the 'backgroundColorType' prop to indicate whether this color is light or dark so the rest of the component can be styled accordingly."));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var buttonColors;
|
|
118
|
+
|
|
119
|
+
if (buttonKind === BUTTON_KIND.tertiary && backgroundColorType === BACKGROUND_COLOR_TYPE.dark) {
|
|
120
|
+
buttonColors = {
|
|
121
|
+
color: theme.colors.contentOnColor,
|
|
122
|
+
backgroundColor: theme.colors.buttonTertiaryFill
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (buttonKind !== BUTTON_KIND.tertiary && backgroundColor !== colors.white) {
|
|
127
|
+
buttonColors = {
|
|
128
|
+
color: theme.colors.contentOnColorInverse,
|
|
129
|
+
backgroundColor: theme.colors.backgroundAlwaysLight
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
134
|
+
onClick: onClick,
|
|
135
|
+
$backgroundColor: backgroundColor,
|
|
136
|
+
$backgroundColorType: backgroundColorType,
|
|
137
|
+
$imageLayout: layout
|
|
138
|
+
}, RootProps), image && /*#__PURE__*/React.createElement(Image, _extends({
|
|
139
|
+
role: "img",
|
|
140
|
+
ariaLabel: ariaLabel,
|
|
141
|
+
$src: src,
|
|
142
|
+
$imageLayout: layout,
|
|
143
|
+
$backgroundPosition: backgroundPosition
|
|
144
|
+
}, 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({
|
|
145
|
+
kind: buttonKind,
|
|
146
|
+
shape: SHAPE.pill,
|
|
147
|
+
size: SIZE.compact,
|
|
148
|
+
role: "none",
|
|
149
|
+
tabIndex: -1,
|
|
150
|
+
colors: buttonColors,
|
|
151
|
+
overrides: {
|
|
152
|
+
BaseButton: {
|
|
153
|
+
style: _objectSpread({
|
|
154
|
+
pointerEvents: 'none'
|
|
155
|
+
}, buttonKind === BUTTON_KIND.tertiary ? {
|
|
156
|
+
marginTop: theme.sizing.scale100,
|
|
157
|
+
transform: theme.direction === 'rtl' ? "translateX(".concat(theme.sizing.scale500, ")") : "translateX(-".concat(theme.sizing.scale500, ")")
|
|
158
|
+
} : {
|
|
159
|
+
marginTop: theme.sizing.scale500
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, ButtonProps), buttonLabel)));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default MessageCard;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright (c) Uber Technologies, Inc.
|
|
9
|
+
|
|
10
|
+
This source code is licensed under the MIT license found in the
|
|
11
|
+
LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
import { styled } from '../styles';
|
|
14
|
+
import { IMAGE_LAYOUT, BACKGROUND_COLOR_TYPE } from './constants';
|
|
15
|
+
export var StyledRoot = styled('button', function (_ref) {
|
|
16
|
+
var $theme = _ref.$theme,
|
|
17
|
+
$backgroundColor = _ref.$backgroundColor,
|
|
18
|
+
$backgroundColorType = _ref.$backgroundColorType,
|
|
19
|
+
_ref$$imageLayout = _ref.$imageLayout,
|
|
20
|
+
$imageLayout = _ref$$imageLayout === void 0 ? IMAGE_LAYOUT.top : _ref$$imageLayout;
|
|
21
|
+
var lightBackgroundStyle = {
|
|
22
|
+
color: $theme.colors.contentOnColorInverse,
|
|
23
|
+
borderStyle: 'solid',
|
|
24
|
+
borderWidth: $theme.sizing.scale0,
|
|
25
|
+
borderColor: $theme.colors.borderOpaque
|
|
26
|
+
};
|
|
27
|
+
var darkBackgroundStyle = {
|
|
28
|
+
color: $theme.colors.contentOnColor,
|
|
29
|
+
border: 'none'
|
|
30
|
+
};
|
|
31
|
+
return _objectSpread(_objectSpread({
|
|
32
|
+
alignItems: 'stretch',
|
|
33
|
+
backgroundColor: $backgroundColor,
|
|
34
|
+
borderRadius: $theme.borders.radius400,
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
display: 'flex',
|
|
37
|
+
flexDirection: $imageLayout === IMAGE_LAYOUT.top ? 'column' : 'row',
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
padding: '0',
|
|
40
|
+
position: 'relative',
|
|
41
|
+
textAlign: 'start',
|
|
42
|
+
width: '100%',
|
|
43
|
+
boxShadow: "inset 999px 999px 0px ".concat($theme.colors.backgroundOverlayArt)
|
|
44
|
+
}, $backgroundColorType === BACKGROUND_COLOR_TYPE.light ? lightBackgroundStyle : darkBackgroundStyle), {}, {
|
|
45
|
+
':focus': {
|
|
46
|
+
outlineWidth: '3px',
|
|
47
|
+
outlineStyle: 'solid',
|
|
48
|
+
outlineColor: $theme.colors.borderAccent,
|
|
49
|
+
outlineOffset: '-3px'
|
|
50
|
+
},
|
|
51
|
+
':hover:after': {
|
|
52
|
+
content: '""',
|
|
53
|
+
width: '100%',
|
|
54
|
+
height: '100%',
|
|
55
|
+
zIndex: '1',
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
top: '0',
|
|
58
|
+
left: '0',
|
|
59
|
+
backgroundColor: $backgroundColorType === BACKGROUND_COLOR_TYPE.light ? 'rgba(0, 0, 0, 0.04)' : 'rgba(255, 255, 255, 0.10)'
|
|
60
|
+
},
|
|
61
|
+
':active:after': {
|
|
62
|
+
content: '""',
|
|
63
|
+
width: '100%',
|
|
64
|
+
height: '100%',
|
|
65
|
+
zIndex: '1',
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
top: '0',
|
|
68
|
+
left: '0',
|
|
69
|
+
backgroundColor: $backgroundColorType === BACKGROUND_COLOR_TYPE.light ? 'rgba(0, 0, 0, 0.08)' : 'rgba(255, 255, 255, 0.20)'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
StyledRoot.displayName = "StyledRoot";
|
|
74
|
+
export var StyledImage = styled('div', function (_ref2) {
|
|
75
|
+
var _ref2$$imageLayout = _ref2.$imageLayout,
|
|
76
|
+
$imageLayout = _ref2$$imageLayout === void 0 ? IMAGE_LAYOUT.top : _ref2$$imageLayout,
|
|
77
|
+
_ref2$$backgroundPosi = _ref2.$backgroundPosition,
|
|
78
|
+
$backgroundPosition = _ref2$$backgroundPosi === void 0 ? 'center' : _ref2$$backgroundPosi,
|
|
79
|
+
$src = _ref2.$src;
|
|
80
|
+
return _objectSpread({
|
|
81
|
+
backgroundImage: "url(".concat($src, ")"),
|
|
82
|
+
backgroundSize: 'cover',
|
|
83
|
+
backgroundPosition: $backgroundPosition
|
|
84
|
+
}, $imageLayout === IMAGE_LAYOUT.top ? {
|
|
85
|
+
height: '132px',
|
|
86
|
+
width: '100%'
|
|
87
|
+
} : {
|
|
88
|
+
width: '112px',
|
|
89
|
+
order: '1'
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
StyledImage.displayName = "StyledImage";
|
|
93
|
+
export var StyledContentContainer = styled('div', function (_ref3) {
|
|
94
|
+
var $theme = _ref3.$theme;
|
|
95
|
+
return {
|
|
96
|
+
width: '100%',
|
|
97
|
+
boxSizing: 'border-box',
|
|
98
|
+
paddingTop: $theme.sizing.scale600,
|
|
99
|
+
paddingRight: $theme.sizing.scale300,
|
|
100
|
+
paddingBottom: $theme.sizing.scale600,
|
|
101
|
+
paddingLeft: $theme.sizing.scale600
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
StyledContentContainer.displayName = "StyledContentContainer";
|
|
105
|
+
export var StyledHeadingContainer = styled('div', function (_ref4) {
|
|
106
|
+
var $theme = _ref4.$theme;
|
|
107
|
+
return _objectSpread({}, $theme.typography.HeadingXSmall);
|
|
108
|
+
});
|
|
109
|
+
StyledHeadingContainer.displayName = "StyledHeadingContainer";
|
|
110
|
+
export var StyledParagraphContainer = styled('div', function (_ref5) {
|
|
111
|
+
var $theme = _ref5.$theme;
|
|
112
|
+
return _objectSpread(_objectSpread({}, $theme.typography.ParagraphSmall), {}, {
|
|
113
|
+
marginTop: $theme.sizing.scale100
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
StyledParagraphContainer.displayName = "StyledParagraphContainer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
var 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
|
+
var 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
|
+
var 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, ".concat(backgroundColor, ", is not supported because it does not pass accessibility contrast tests for either white or black text."));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (LIGHT_COLORS.has(backgroundColor)) {
|
|
18
|
+
return BACKGROUND_COLOR_TYPE.light;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (DARK_COLORS.has(backgroundColor)) {
|
|
22
|
+
return BACKGROUND_COLOR_TYPE.dark;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
package/layer/layer.js
CHANGED
|
@@ -83,6 +83,24 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
87
|
+
if (_this.props.onKeyDown) {
|
|
88
|
+
_this.props.onKeyDown(event);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyUp", function (event) {
|
|
93
|
+
if (_this.props.onKeyUp) {
|
|
94
|
+
_this.props.onKeyUp(event);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
|
|
99
|
+
if (_this.props.onKeyPress) {
|
|
100
|
+
_this.props.onKeyPress(event);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
86
104
|
_defineProperty(_assertThisInitialized(_this), "onDocumentClick", function (event) {
|
|
87
105
|
if (_this.props.onDocumentClick) {
|
|
88
106
|
_this.props.onDocumentClick(event);
|
|
@@ -96,6 +114,9 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
96
114
|
key: "componentDidMount",
|
|
97
115
|
value: function componentDidMount() {
|
|
98
116
|
this.context.addEscapeHandler(this.onEscape);
|
|
117
|
+
this.context.addKeyDownHandler(this.onKeyDown);
|
|
118
|
+
this.context.addKeyUpHandler(this.onKeyUp);
|
|
119
|
+
this.context.addKeyPressHandler(this.onKeyPress);
|
|
99
120
|
|
|
100
121
|
if (!this.props.isHoverLayer) {
|
|
101
122
|
this.context.addDocClickHandler(this.onDocumentClick);
|
|
@@ -154,6 +175,9 @@ var LayerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
154
175
|
key: "componentWillUnmount",
|
|
155
176
|
value: function componentWillUnmount() {
|
|
156
177
|
this.context.removeEscapeHandler(this.onEscape);
|
|
178
|
+
this.context.removeKeyDownHandler(this.onKeyDown);
|
|
179
|
+
this.context.removeKeyUpHandler(this.onKeyUp);
|
|
180
|
+
this.context.removeKeyPressHandler(this.onKeyPress);
|
|
157
181
|
this.context.removeDocClickHandler(this.onDocumentClick);
|
|
158
182
|
|
|
159
183
|
if (this.props.onUnmount) {
|
package/layer/layer.js.flow
CHANGED
|
@@ -27,6 +27,10 @@ class LayerComponent extends React.Component<LayerComponentPropsT, LayerStateT>
|
|
|
27
27
|
|
|
28
28
|
componentDidMount() {
|
|
29
29
|
this.context.addEscapeHandler(this.onEscape);
|
|
30
|
+
this.context.addKeyDownHandler(this.onKeyDown);
|
|
31
|
+
this.context.addKeyUpHandler(this.onKeyUp);
|
|
32
|
+
this.context.addKeyPressHandler(this.onKeyPress);
|
|
33
|
+
|
|
30
34
|
if (!this.props.isHoverLayer) {
|
|
31
35
|
this.context.addDocClickHandler(this.onDocumentClick);
|
|
32
36
|
}
|
|
@@ -74,6 +78,9 @@ class LayerComponent extends React.Component<LayerComponentPropsT, LayerStateT>
|
|
|
74
78
|
|
|
75
79
|
componentWillUnmount() {
|
|
76
80
|
this.context.removeEscapeHandler(this.onEscape);
|
|
81
|
+
this.context.removeKeyDownHandler(this.onKeyDown);
|
|
82
|
+
this.context.removeKeyUpHandler(this.onKeyUp);
|
|
83
|
+
this.context.removeKeyPressHandler(this.onKeyPress);
|
|
77
84
|
this.context.removeDocClickHandler(this.onDocumentClick);
|
|
78
85
|
|
|
79
86
|
if (this.props.onUnmount) {
|
|
@@ -95,6 +102,24 @@ class LayerComponent extends React.Component<LayerComponentPropsT, LayerStateT>
|
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
104
|
|
|
105
|
+
onKeyDown = (event: KeyboardEvent) => {
|
|
106
|
+
if (this.props.onKeyDown) {
|
|
107
|
+
this.props.onKeyDown(event);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
onKeyUp = (event: KeyboardEvent) => {
|
|
112
|
+
if (this.props.onKeyUp) {
|
|
113
|
+
this.props.onKeyUp(event);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
onKeyPress = (event: KeyboardEvent) => {
|
|
118
|
+
if (this.props.onKeyPress) {
|
|
119
|
+
this.props.onKeyPress(event);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
98
123
|
onDocumentClick = (event: MouseEvent) => {
|
|
99
124
|
if (this.props.onDocumentClick) {
|
|
100
125
|
this.props.onDocumentClick(event);
|
|
@@ -10,9 +10,17 @@ export default class LayersManager extends React.Component<LayersManagerProps, L
|
|
|
10
10
|
componentDidMount(): void;
|
|
11
11
|
componentWillUnmount(): void;
|
|
12
12
|
onDocumentClick: (event: MouseEvent) => void;
|
|
13
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
13
14
|
onKeyUp: (event: KeyboardEvent) => void;
|
|
15
|
+
onKeyPress: (event: KeyboardEvent) => void;
|
|
14
16
|
onAddEscapeHandler: (escapeKeyHandler: () => unknown) => void;
|
|
15
17
|
onRemoveEscapeHandler: (escapeKeyHandler: () => unknown) => void;
|
|
18
|
+
onAddKeyDownHandler: (keyDownHandler: () => unknown) => void;
|
|
19
|
+
onRemoveKeyDownHandler: (keyDownHandler: () => unknown) => void;
|
|
20
|
+
onAddKeyUpHandler: (keyUpHandler: () => unknown) => void;
|
|
21
|
+
onRemoveKeyUpHandler: (keyUpHandler: () => unknown) => void;
|
|
22
|
+
onAddKeyPressHandler: (keyPressHandler: () => unknown) => void;
|
|
23
|
+
onRemoveKeyPressHandler: (keyPressHandler: () => unknown) => void;
|
|
16
24
|
onAddDocClickHandler: (docClickHandler: (event: MouseEvent) => unknown) => void;
|
|
17
25
|
onRemoveDocClickHandler: (docClickHandler: (event: MouseEvent) => unknown) => void;
|
|
18
26
|
render(): JSX.Element;
|