@zendeskgarden/react-theming 9.0.0-next.0 → 9.0.0-next.10
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/README.md +0 -17
- package/dist/esm/elements/ThemeProvider.js +24 -0
- package/dist/esm/elements/palette/index.js +259 -0
- package/dist/esm/elements/palette/v8.js +149 -0
- package/dist/esm/elements/theme/index.js +224 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/types/index.js +11 -0
- package/dist/esm/utils/StyledBaseIcon.js +22 -0
- package/dist/esm/utils/arrowStyles.js +64 -0
- package/dist/esm/utils/focusStyles.js +43 -0
- package/dist/esm/utils/getArrowPosition.js +35 -0
- package/dist/esm/utils/getCheckeredBackground.js +40 -0
- package/dist/esm/utils/getColor.js +153 -0
- package/dist/esm/utils/getColorV8.js +72 -0
- package/dist/esm/utils/getFloatingPlacements.js +58 -0
- package/dist/esm/utils/getFocusBoxShadow.js +45 -0
- package/dist/esm/utils/getLineHeight.js +22 -0
- package/dist/esm/utils/getMenuPosition.js +11 -0
- package/dist/esm/utils/mediaQuery.js +56 -0
- package/dist/esm/utils/menuStyles.js +63 -0
- package/dist/esm/utils/retrieveComponentStyles.js +19 -0
- package/dist/esm/utils/useDocument.js +21 -0
- package/dist/esm/utils/useText.js +29 -0
- package/dist/esm/utils/useWindow.js +21 -0
- package/dist/index.cjs.js +797 -187
- package/dist/typings/elements/ThemeProvider.d.ts +1 -1
- package/dist/typings/elements/palette/index.d.ts +134 -26
- package/dist/typings/elements/palette/v8.d.ts +149 -0
- package/dist/typings/elements/theme/index.d.ts +0 -1
- package/dist/typings/index.d.ts +9 -7
- package/dist/typings/types/index.d.ts +61 -16
- package/dist/typings/utils/StyledBaseIcon.d.ts +8 -0
- package/dist/typings/utils/focusStyles.d.ts +3 -11
- package/dist/typings/utils/getArrowPosition.d.ts +19 -0
- package/dist/typings/utils/getCheckeredBackground.d.ts +20 -0
- package/dist/typings/utils/getColor.d.ts +14 -9
- package/dist/typings/utils/getColorV8.d.ts +27 -0
- package/dist/typings/utils/getFloatingPlacements.d.ts +20 -0
- package/dist/typings/utils/getFocusBoxShadow.d.ts +6 -21
- package/dist/typings/utils/getMenuPosition.d.ts +16 -0
- package/dist/typings/utils/menuStyles.d.ts +2 -2
- package/package.json +9 -6
- package/dist/index.esm.js +0 -648
- package/dist/typings/utils/getDocument.d.ts +0 -9
- package/dist/typings/utils/isRtl.d.ts +0 -9
- package/dist/typings/utils/withTheme.d.ts +0 -8
package/dist/index.cjs.js
CHANGED
|
@@ -1,178 +1,274 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
8
7
|
'use strict';
|
|
9
8
|
|
|
10
9
|
var React = require('react');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
10
|
+
var styled = require('styled-components');
|
|
11
|
+
var chromaJs = require('chroma-js');
|
|
14
12
|
var polished = require('polished');
|
|
13
|
+
var get = require('lodash.get');
|
|
15
14
|
var memoize = require('lodash.memoize');
|
|
16
15
|
|
|
17
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
17
|
|
|
19
18
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
19
|
+
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
20
|
+
var get__default = /*#__PURE__*/_interopDefault(get);
|
|
20
21
|
var memoize__default = /*#__PURE__*/_interopDefault(memoize);
|
|
21
22
|
|
|
22
|
-
function _extends() {
|
|
23
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
24
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
25
|
-
var source = arguments[i];
|
|
26
|
-
for (var key in source) {
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
28
|
-
target[key] = source[key];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
|
-
return _extends.apply(this, arguments);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
23
|
const PALETTE = {
|
|
38
24
|
black: '#000',
|
|
39
25
|
white: '#fff',
|
|
40
26
|
product: {
|
|
41
27
|
support: '#00a656',
|
|
42
|
-
message: '#37b8af',
|
|
43
28
|
explore: '#30aabc',
|
|
44
29
|
gather: '#f6c8be',
|
|
45
30
|
guide: '#eb4962',
|
|
46
|
-
connect: '#ff6224',
|
|
47
31
|
chat: '#f79a3e',
|
|
48
32
|
talk: '#efc93d',
|
|
49
33
|
sell: '#c38f00'
|
|
50
34
|
},
|
|
51
35
|
grey: {
|
|
52
36
|
100: '#f8f9f9',
|
|
53
|
-
200: '#
|
|
37
|
+
200: '#e8eaec',
|
|
54
38
|
300: '#d8dcde',
|
|
55
|
-
400: '#
|
|
56
|
-
500: '#
|
|
57
|
-
600: '#
|
|
58
|
-
700: '#
|
|
59
|
-
800: '#
|
|
39
|
+
400: '#b0b8be',
|
|
40
|
+
500: '#919ca5',
|
|
41
|
+
600: '#848f99',
|
|
42
|
+
700: '#5c6970',
|
|
43
|
+
800: '#39434b',
|
|
44
|
+
900: '#293239',
|
|
45
|
+
1000: '#1c2227',
|
|
46
|
+
1100: '#151a1e',
|
|
47
|
+
1200: '#0a0d0e'
|
|
60
48
|
},
|
|
61
49
|
blue: {
|
|
62
50
|
100: '#edf7ff',
|
|
63
|
-
200: '#
|
|
64
|
-
300: '#
|
|
65
|
-
400: '#
|
|
66
|
-
500: '#
|
|
67
|
-
600: '#
|
|
68
|
-
700: '#
|
|
69
|
-
800: '#
|
|
51
|
+
200: '#ddecf8',
|
|
52
|
+
300: '#cce0f1',
|
|
53
|
+
400: '#93bcdc',
|
|
54
|
+
500: '#66a0cd',
|
|
55
|
+
600: '#2694d6',
|
|
56
|
+
700: '#1f73b7',
|
|
57
|
+
800: '#13456d',
|
|
58
|
+
900: '#0f3655',
|
|
59
|
+
1000: '#0a2338',
|
|
60
|
+
1100: '#061420',
|
|
61
|
+
1200: '#040d15'
|
|
70
62
|
},
|
|
71
63
|
red: {
|
|
72
|
-
100: '#
|
|
73
|
-
200: '#
|
|
74
|
-
300: '#
|
|
75
|
-
400: '#
|
|
76
|
-
500: '#
|
|
77
|
-
600: '#
|
|
78
|
-
700: '#
|
|
79
|
-
800: '#
|
|
64
|
+
100: '#fff2f3',
|
|
65
|
+
200: '#fee3e5',
|
|
66
|
+
300: '#f5d5d8',
|
|
67
|
+
400: '#f2a1a8',
|
|
68
|
+
500: '#ea7881',
|
|
69
|
+
600: '#eb5c69',
|
|
70
|
+
700: '#cd3642',
|
|
71
|
+
800: '#7e1d25',
|
|
72
|
+
900: '#671219',
|
|
73
|
+
1000: '#3d1418',
|
|
74
|
+
1100: '#1d1011',
|
|
75
|
+
1200: '#100b0c'
|
|
80
76
|
},
|
|
81
77
|
yellow: {
|
|
82
|
-
100: '#
|
|
83
|
-
200: '#
|
|
84
|
-
300: '#
|
|
85
|
-
400: '#
|
|
86
|
-
500: '#
|
|
87
|
-
600: '#
|
|
88
|
-
700: '#
|
|
89
|
-
800: '#
|
|
78
|
+
100: '#fff3e4',
|
|
79
|
+
200: '#ffe6cb',
|
|
80
|
+
300: '#fed6a9',
|
|
81
|
+
400: '#fca347',
|
|
82
|
+
500: '#e38215',
|
|
83
|
+
600: '#d67305',
|
|
84
|
+
700: '#ac5918',
|
|
85
|
+
800: '#673515',
|
|
86
|
+
900: '#4c2c17',
|
|
87
|
+
1000: '#2d1e15',
|
|
88
|
+
1100: '#18120f',
|
|
89
|
+
1200: '#0e0c0b'
|
|
90
90
|
},
|
|
91
91
|
green: {
|
|
92
|
-
100: '#
|
|
93
|
-
200: '#
|
|
94
|
-
300: '#
|
|
95
|
-
400: '#
|
|
96
|
-
500: '#
|
|
97
|
-
600: '#
|
|
98
|
-
700: '#
|
|
99
|
-
800: '#
|
|
92
|
+
100: '#eef8f4',
|
|
93
|
+
200: '#daeee6',
|
|
94
|
+
300: '#cae3d9',
|
|
95
|
+
400: '#94c1b0',
|
|
96
|
+
500: '#4eab89',
|
|
97
|
+
600: '#26a178',
|
|
98
|
+
700: '#037f52',
|
|
99
|
+
800: '#104b35',
|
|
100
|
+
900: '#0b3b29',
|
|
101
|
+
1000: '#0c261c',
|
|
102
|
+
1100: '#0a1511',
|
|
103
|
+
1200: '#080d0c'
|
|
100
104
|
},
|
|
101
105
|
kale: {
|
|
102
|
-
100: '#
|
|
106
|
+
100: '#ecf9f9',
|
|
103
107
|
200: '#daeded',
|
|
104
|
-
300: '#
|
|
105
|
-
400: '#
|
|
106
|
-
500: '#
|
|
107
|
-
600: '#
|
|
108
|
-
700: '#
|
|
109
|
-
800: '#
|
|
108
|
+
300: '#cbe2e1',
|
|
109
|
+
400: '#97bfbf',
|
|
110
|
+
500: '#6ba4a5',
|
|
111
|
+
600: '#4a9999',
|
|
112
|
+
700: '#40787a',
|
|
113
|
+
800: '#16494f',
|
|
114
|
+
900: '#063940',
|
|
115
|
+
1000: '#03252a',
|
|
116
|
+
1100: '#061517',
|
|
117
|
+
1200: '#060e0e'
|
|
110
118
|
},
|
|
111
119
|
fuschia: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
100: '#fbf3f8',
|
|
121
|
+
200: '#f7e6f1',
|
|
122
|
+
300: '#f2d5e7',
|
|
123
|
+
400: '#e3a4cc',
|
|
124
|
+
500: '#d77db7',
|
|
125
|
+
600: '#d16aac',
|
|
126
|
+
700: '#b34496',
|
|
127
|
+
800: '#78116c',
|
|
128
|
+
900: '#5a0d51',
|
|
129
|
+
1000: '#3f0939',
|
|
130
|
+
1100: '#31072c',
|
|
131
|
+
1200: '#1b0418'
|
|
116
132
|
},
|
|
117
133
|
pink: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
100: '#fcf3f4',
|
|
135
|
+
200: '#f7e5e8',
|
|
136
|
+
300: '#f3d6dc',
|
|
137
|
+
400: '#e5a6b4',
|
|
138
|
+
500: '#d98193',
|
|
139
|
+
600: '#d96b81',
|
|
140
|
+
700: '#d62054',
|
|
141
|
+
800: '#75263d',
|
|
142
|
+
900: '#561d2e',
|
|
143
|
+
1000: '#3c141f',
|
|
144
|
+
1100: '#2e0f18',
|
|
145
|
+
1200: '#17080c'
|
|
122
146
|
},
|
|
123
147
|
crimson: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
148
|
+
100: '#fbf3f2',
|
|
149
|
+
200: '#f7e7e4',
|
|
150
|
+
300: '#f1d7d2',
|
|
151
|
+
400: '#e2aaa0',
|
|
152
|
+
500: '#d58678',
|
|
153
|
+
600: '#cf7464',
|
|
154
|
+
700: '#be4938',
|
|
155
|
+
800: '#811b12',
|
|
156
|
+
900: '#61140d',
|
|
157
|
+
1000: '#440e09',
|
|
158
|
+
1100: '#340b07',
|
|
159
|
+
1200: '#1c0604'
|
|
128
160
|
},
|
|
129
161
|
orange: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
162
|
+
100: '#fdf3ed',
|
|
163
|
+
200: '#fae7d8',
|
|
164
|
+
300: '#f7d7be',
|
|
165
|
+
400: '#eda875',
|
|
166
|
+
500: '#e58035',
|
|
167
|
+
600: '#d57428',
|
|
168
|
+
700: '#af5626',
|
|
169
|
+
800: '#693317',
|
|
170
|
+
900: '#4d2711',
|
|
171
|
+
1000: '#361a0c',
|
|
172
|
+
1100: '#291409',
|
|
173
|
+
1200: '#150a04'
|
|
134
174
|
},
|
|
135
175
|
lemon: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
176
|
+
100: '#fff7d4',
|
|
177
|
+
200: '#ffea97',
|
|
178
|
+
300: '#ffdc4f',
|
|
179
|
+
400: '#efab00',
|
|
180
|
+
500: '#c79100',
|
|
181
|
+
600: '#b68500',
|
|
182
|
+
700: '#8f6900',
|
|
183
|
+
800: '#563e00',
|
|
184
|
+
900: '#3f2e00',
|
|
185
|
+
1000: '#2b2000',
|
|
186
|
+
1100: '#221800',
|
|
187
|
+
1200: '#110c00'
|
|
140
188
|
},
|
|
141
189
|
lime: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
190
|
+
100: '#ecfae7',
|
|
191
|
+
200: '#d1f3c7',
|
|
192
|
+
300: '#b3eda3',
|
|
193
|
+
400: '#4fd12b',
|
|
194
|
+
500: '#45b025',
|
|
195
|
+
600: '#509f2d',
|
|
196
|
+
700: '#3d7e19',
|
|
197
|
+
800: '#2c491b',
|
|
198
|
+
900: '#203614',
|
|
199
|
+
1000: '#16250e',
|
|
200
|
+
1100: '#111d0a',
|
|
201
|
+
1200: '#090e05'
|
|
146
202
|
},
|
|
147
203
|
mint: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
204
|
+
100: '#d6ffeb',
|
|
205
|
+
200: '#9affce',
|
|
206
|
+
300: '#0afe89',
|
|
207
|
+
400: '#00d26d',
|
|
208
|
+
500: '#01b15c',
|
|
209
|
+
600: '#16a260',
|
|
210
|
+
700: '#2d7e55',
|
|
211
|
+
800: '#1b4b33',
|
|
212
|
+
900: '#143726',
|
|
213
|
+
1000: '#0e261a',
|
|
214
|
+
1100: '#0b1d14',
|
|
215
|
+
1200: '#050e0a'
|
|
152
216
|
},
|
|
153
217
|
teal: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
218
|
+
100: '#d4fefa',
|
|
219
|
+
200: '#88fdf1',
|
|
220
|
+
300: '#0bf8e1',
|
|
221
|
+
400: '#03cdb8',
|
|
222
|
+
500: '#02ad9c',
|
|
223
|
+
600: '#2a9d8f',
|
|
224
|
+
700: '#367a74',
|
|
225
|
+
800: '#254846',
|
|
226
|
+
900: '#1b3534',
|
|
227
|
+
1000: '#122423',
|
|
228
|
+
1100: '#0e1c1a',
|
|
229
|
+
1200: '#070d0d'
|
|
158
230
|
},
|
|
159
231
|
azure: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
232
|
+
100: '#eff7fe',
|
|
233
|
+
200: '#d9ecfc',
|
|
234
|
+
300: '#c4e0fa',
|
|
235
|
+
400: '#82bcf4',
|
|
236
|
+
500: '#4b9fee',
|
|
237
|
+
600: '#3191ea',
|
|
238
|
+
700: '#2770c3',
|
|
239
|
+
800: '#23446b',
|
|
240
|
+
900: '#1a3250',
|
|
241
|
+
1000: '#122238',
|
|
242
|
+
1100: '#0e1a2a',
|
|
243
|
+
1200: '#070d14'
|
|
164
244
|
},
|
|
165
245
|
royal: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
246
|
+
100: '#f4f5fc',
|
|
247
|
+
200: '#e7e9f8',
|
|
248
|
+
300: '#d8dcf4',
|
|
249
|
+
400: '#acb4e7',
|
|
250
|
+
500: '#8a96dd',
|
|
251
|
+
600: '#7a88d9',
|
|
252
|
+
700: '#4c67d3',
|
|
253
|
+
800: '#1833ab',
|
|
254
|
+
900: '#122680',
|
|
255
|
+
1000: '#0d1a5a',
|
|
256
|
+
1100: '#0a1445',
|
|
257
|
+
1200: '#050a25'
|
|
170
258
|
},
|
|
171
259
|
purple: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
260
|
+
100: '#f9f3fb',
|
|
261
|
+
200: '#f2e7f6',
|
|
262
|
+
300: '#e9d8f1',
|
|
263
|
+
400: '#d0a9e0',
|
|
264
|
+
500: '#bb86d3',
|
|
265
|
+
600: '#b276cd',
|
|
266
|
+
700: '#9256b1',
|
|
267
|
+
800: '#58209a',
|
|
268
|
+
900: '#411973',
|
|
269
|
+
1000: '#2e1150',
|
|
270
|
+
1100: '#230d3f',
|
|
271
|
+
1200: '#120720'
|
|
176
272
|
}
|
|
177
273
|
};
|
|
178
274
|
|
|
@@ -200,14 +296,96 @@ const breakpoints = {
|
|
|
200
296
|
xl: `${BASE * 300}px`
|
|
201
297
|
};
|
|
202
298
|
const colors = {
|
|
203
|
-
background: PALETTE.white,
|
|
204
|
-
foreground: PALETTE.grey[800],
|
|
205
299
|
primaryHue: 'blue',
|
|
206
300
|
dangerHue: 'red',
|
|
207
301
|
warningHue: 'yellow',
|
|
208
302
|
successHue: 'green',
|
|
209
303
|
neutralHue: 'grey',
|
|
210
|
-
chromeHue: 'kale'
|
|
304
|
+
chromeHue: 'kale',
|
|
305
|
+
variables: {
|
|
306
|
+
dark: {
|
|
307
|
+
background: {
|
|
308
|
+
default: 'neutralHue.1100',
|
|
309
|
+
raised: 'neutralHue.1000',
|
|
310
|
+
recessed: 'neutralHue.1200',
|
|
311
|
+
subtle: 'neutralHue.1000',
|
|
312
|
+
emphasis: 'neutralHue.600',
|
|
313
|
+
primary: 'primaryHue.900',
|
|
314
|
+
success: 'successHue.1000',
|
|
315
|
+
warning: 'warningHue.1000',
|
|
316
|
+
danger: 'dangerHue.1000',
|
|
317
|
+
primaryEmphasis: 'primaryHue.600',
|
|
318
|
+
successEmphasis: 'successHue.600',
|
|
319
|
+
warningEmphasis: 'warningHue.600',
|
|
320
|
+
dangerEmphasis: 'dangerHue.600'
|
|
321
|
+
},
|
|
322
|
+
border: {
|
|
323
|
+
default: 'neutralHue.800',
|
|
324
|
+
emphasis: 'neutralHue.600',
|
|
325
|
+
subtle: 'neutralHue.900',
|
|
326
|
+
success: 'successHue.800',
|
|
327
|
+
warning: 'warningHue.800',
|
|
328
|
+
danger: 'dangerHue.800',
|
|
329
|
+
primaryEmphasis: 'primaryHue.600',
|
|
330
|
+
successEmphasis: 'successHue.600',
|
|
331
|
+
warningEmphasis: 'warningHue.600',
|
|
332
|
+
dangerEmphasis: 'dangerHue.600'
|
|
333
|
+
},
|
|
334
|
+
foreground: {
|
|
335
|
+
default: 'neutralHue.300',
|
|
336
|
+
subtle: 'neutralHue.500',
|
|
337
|
+
onEmphasis: 'neutralHue.1100',
|
|
338
|
+
primary: 'primaryHue.600',
|
|
339
|
+
success: 'successHue.400',
|
|
340
|
+
warning: 'warningHue.400',
|
|
341
|
+
danger: 'dangerHue.400',
|
|
342
|
+
successEmphasis: 'successHue.300',
|
|
343
|
+
warningEmphasis: 'warningHue.300',
|
|
344
|
+
dangerEmphasis: 'dangerHue.300'
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
light: {
|
|
348
|
+
background: {
|
|
349
|
+
default: 'palette.white',
|
|
350
|
+
raised: 'palette.white',
|
|
351
|
+
recessed: 'neutralHue.100',
|
|
352
|
+
subtle: 'neutralHue.100',
|
|
353
|
+
emphasis: 'neutralHue.700',
|
|
354
|
+
primary: 'primaryHue.100',
|
|
355
|
+
success: 'successHue.100',
|
|
356
|
+
warning: 'warningHue.100',
|
|
357
|
+
danger: 'dangerHue.100',
|
|
358
|
+
primaryEmphasis: 'primaryHue.700',
|
|
359
|
+
successEmphasis: 'successHue.700',
|
|
360
|
+
warningEmphasis: 'warningHue.700',
|
|
361
|
+
dangerEmphasis: 'dangerHue.700'
|
|
362
|
+
},
|
|
363
|
+
border: {
|
|
364
|
+
default: 'neutralHue.300',
|
|
365
|
+
emphasis: 'neutralHue.600',
|
|
366
|
+
subtle: 'neutralHue.200',
|
|
367
|
+
success: 'successHue.300',
|
|
368
|
+
warning: 'warningHue.300',
|
|
369
|
+
danger: 'dangerHue.300',
|
|
370
|
+
primaryEmphasis: 'primaryHue.700',
|
|
371
|
+
successEmphasis: 'successHue.700',
|
|
372
|
+
warningEmphasis: 'warningHue.700',
|
|
373
|
+
dangerEmphasis: 'dangerHue.700'
|
|
374
|
+
},
|
|
375
|
+
foreground: {
|
|
376
|
+
default: 'neutralHue.900',
|
|
377
|
+
subtle: 'neutralHue.700',
|
|
378
|
+
onEmphasis: 'palette.white',
|
|
379
|
+
primary: 'primaryHue.700',
|
|
380
|
+
success: 'successHue.700',
|
|
381
|
+
warning: 'warningHue.700',
|
|
382
|
+
danger: 'dangerHue.700',
|
|
383
|
+
successEmphasis: 'successHue.900',
|
|
384
|
+
warningEmphasis: 'warningHue.900',
|
|
385
|
+
dangerEmphasis: 'dangerHue.900'
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
211
389
|
};
|
|
212
390
|
const fonts = {
|
|
213
391
|
mono: ['SFMono-Regular' , 'Consolas' , '"Liberation Mono"' , 'Menlo', 'Courier', 'monospace'].join(','),
|
|
@@ -246,6 +424,20 @@ const lineHeights = {
|
|
|
246
424
|
xxl: `${BASE * 8}px`,
|
|
247
425
|
xxxl: `${BASE * 11}px`
|
|
248
426
|
};
|
|
427
|
+
const opacity = {
|
|
428
|
+
100: 0.08,
|
|
429
|
+
200: 0.16,
|
|
430
|
+
300: 0.24,
|
|
431
|
+
400: 0.32,
|
|
432
|
+
500: 0.4,
|
|
433
|
+
600: 0.48,
|
|
434
|
+
700: 0.56,
|
|
435
|
+
800: 0.64,
|
|
436
|
+
900: 0.72,
|
|
437
|
+
1000: 0.8,
|
|
438
|
+
1100: 0.88,
|
|
439
|
+
1200: 0.96
|
|
440
|
+
};
|
|
249
441
|
const palette = {
|
|
250
442
|
...PALETTE
|
|
251
443
|
};
|
|
@@ -287,6 +479,7 @@ const DEFAULT_THEME = {
|
|
|
287
479
|
fontWeights,
|
|
288
480
|
iconSizes,
|
|
289
481
|
lineHeights,
|
|
482
|
+
opacity,
|
|
290
483
|
palette,
|
|
291
484
|
rtl: false,
|
|
292
485
|
shadowWidths,
|
|
@@ -294,48 +487,160 @@ const DEFAULT_THEME = {
|
|
|
294
487
|
space
|
|
295
488
|
};
|
|
296
489
|
|
|
297
|
-
const useDocument = theme => {
|
|
298
|
-
const [controlledDocument, setControlledDocument] = React.useState();
|
|
299
|
-
React.useEffect(() => {
|
|
300
|
-
if (theme && theme.document) {
|
|
301
|
-
setControlledDocument(theme.document);
|
|
302
|
-
} else {
|
|
303
|
-
setControlledDocument(document);
|
|
304
|
-
}
|
|
305
|
-
}, [theme]);
|
|
306
|
-
return controlledDocument;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
490
|
const ThemeProvider = _ref => {
|
|
310
491
|
let {
|
|
311
492
|
theme,
|
|
312
|
-
focusVisibleRef,
|
|
313
|
-
children,
|
|
314
493
|
...other
|
|
315
494
|
} = _ref;
|
|
316
|
-
|
|
317
|
-
const relativeDocument = useDocument(theme);
|
|
318
|
-
const controlledScopeRef = focusVisibleRef === null ? React__default.default.createRef() : containerUtilities.getControlledValue(focusVisibleRef, scopeRef);
|
|
319
|
-
containerFocusvisible.useFocusVisible({
|
|
320
|
-
scope: controlledScopeRef,
|
|
321
|
-
relativeDocument
|
|
322
|
-
});
|
|
323
|
-
return React__default.default.createElement(styledComponents.ThemeProvider, _extends({
|
|
495
|
+
return React__default.default.createElement(styled.ThemeProvider, Object.assign({
|
|
324
496
|
theme: theme
|
|
325
|
-
}, other)
|
|
326
|
-
ref: scopeRef
|
|
327
|
-
}, children) : children);
|
|
497
|
+
}, other));
|
|
328
498
|
};
|
|
329
499
|
ThemeProvider.defaultProps = {
|
|
330
500
|
theme: DEFAULT_THEME
|
|
331
501
|
};
|
|
332
502
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
503
|
+
const PALETTE_V8 = {
|
|
504
|
+
black: '#000',
|
|
505
|
+
white: '#fff',
|
|
506
|
+
product: {
|
|
507
|
+
support: '#00a656',
|
|
508
|
+
message: '#37b8af',
|
|
509
|
+
explore: '#30aabc',
|
|
510
|
+
gather: '#f6c8be',
|
|
511
|
+
guide: '#eb4962',
|
|
512
|
+
connect: '#ff6224',
|
|
513
|
+
chat: '#f79a3e',
|
|
514
|
+
talk: '#efc93d',
|
|
515
|
+
sell: '#c38f00'
|
|
516
|
+
},
|
|
517
|
+
grey: {
|
|
518
|
+
100: '#f8f9f9',
|
|
519
|
+
200: '#e9ebed',
|
|
520
|
+
300: '#d8dcde',
|
|
521
|
+
400: '#c2c8cc',
|
|
522
|
+
500: '#87929d',
|
|
523
|
+
600: '#68737d',
|
|
524
|
+
700: '#49545c',
|
|
525
|
+
800: '#2f3941'
|
|
526
|
+
},
|
|
527
|
+
blue: {
|
|
528
|
+
100: '#edf7ff',
|
|
529
|
+
200: '#cee2f2',
|
|
530
|
+
300: '#adcce4',
|
|
531
|
+
400: '#5293c7',
|
|
532
|
+
500: '#337fbd',
|
|
533
|
+
600: '#1f73b7',
|
|
534
|
+
700: '#144a75',
|
|
535
|
+
800: '#0f3554'
|
|
536
|
+
},
|
|
537
|
+
red: {
|
|
538
|
+
100: '#fff0f1',
|
|
539
|
+
200: '#f5d5d8',
|
|
540
|
+
300: '#f5b5ba',
|
|
541
|
+
400: '#e35b66',
|
|
542
|
+
500: '#d93f4c',
|
|
543
|
+
600: '#cc3340',
|
|
544
|
+
700: '#8c232c',
|
|
545
|
+
800: '#681219'
|
|
546
|
+
},
|
|
547
|
+
yellow: {
|
|
548
|
+
100: '#fff7ed',
|
|
549
|
+
200: '#ffeedb',
|
|
550
|
+
300: '#fed6a8',
|
|
551
|
+
400: '#ffb057',
|
|
552
|
+
500: '#f79a3e',
|
|
553
|
+
600: '#ed8f1c',
|
|
554
|
+
700: '#ad5918',
|
|
555
|
+
800: '#703815'
|
|
556
|
+
},
|
|
557
|
+
green: {
|
|
558
|
+
100: '#edf8f4',
|
|
559
|
+
200: '#d1e8df',
|
|
560
|
+
300: '#aecfc2',
|
|
561
|
+
400: '#5eae91',
|
|
562
|
+
500: '#228f67',
|
|
563
|
+
600: '#038153',
|
|
564
|
+
700: '#186146',
|
|
565
|
+
800: '#0b3b29'
|
|
566
|
+
},
|
|
567
|
+
kale: {
|
|
568
|
+
100: '#f5fcfc',
|
|
569
|
+
200: '#daeded',
|
|
570
|
+
300: '#bdd9d7',
|
|
571
|
+
400: '#90bbbb',
|
|
572
|
+
500: '#498283',
|
|
573
|
+
600: '#17494d',
|
|
574
|
+
700: '#03363d',
|
|
575
|
+
800: '#012b30'
|
|
576
|
+
},
|
|
577
|
+
fuschia: {
|
|
578
|
+
400: '#d653c2',
|
|
579
|
+
600: '#a81897',
|
|
580
|
+
M400: '#cf62a8',
|
|
581
|
+
M600: '#a8458c'
|
|
582
|
+
},
|
|
583
|
+
pink: {
|
|
584
|
+
400: '#ec4d63',
|
|
585
|
+
600: '#d42054',
|
|
586
|
+
M400: '#d57287',
|
|
587
|
+
M600: '#b23a5d'
|
|
588
|
+
},
|
|
589
|
+
crimson: {
|
|
590
|
+
400: '#e34f32',
|
|
591
|
+
600: '#c72a1c',
|
|
592
|
+
M400: '#cc6c5b',
|
|
593
|
+
M600: '#b24a3c'
|
|
594
|
+
},
|
|
595
|
+
orange: {
|
|
596
|
+
400: '#de701d',
|
|
597
|
+
600: '#bf5000',
|
|
598
|
+
M400: '#d4772c',
|
|
599
|
+
M600: '#b35827'
|
|
600
|
+
},
|
|
601
|
+
lemon: {
|
|
602
|
+
400: '#ffd424',
|
|
603
|
+
600: '#ffbb10',
|
|
604
|
+
M400: '#e7a500',
|
|
605
|
+
M600: '#c38f00'
|
|
606
|
+
},
|
|
607
|
+
lime: {
|
|
608
|
+
400: '#43b324',
|
|
609
|
+
600: '#2e8200',
|
|
610
|
+
M400: '#519e2d',
|
|
611
|
+
M600: '#47782c'
|
|
612
|
+
},
|
|
613
|
+
mint: {
|
|
614
|
+
400: '#00a656',
|
|
615
|
+
600: '#058541',
|
|
616
|
+
M400: '#299c66',
|
|
617
|
+
M600: '#2e8057'
|
|
618
|
+
},
|
|
619
|
+
teal: {
|
|
620
|
+
400: '#02a191',
|
|
621
|
+
600: '#028079',
|
|
622
|
+
M400: '#2d9e8f',
|
|
623
|
+
M600: '#3c7873'
|
|
624
|
+
},
|
|
625
|
+
azure: {
|
|
626
|
+
400: '#3091ec',
|
|
627
|
+
600: '#1371d6',
|
|
628
|
+
M400: '#5f8dcf',
|
|
629
|
+
M600: '#3a70b2'
|
|
630
|
+
},
|
|
631
|
+
royal: {
|
|
632
|
+
400: '#5d7df5',
|
|
633
|
+
600: '#3353e2',
|
|
634
|
+
M400: '#7986d8',
|
|
635
|
+
M600: '#4b61c3'
|
|
636
|
+
},
|
|
637
|
+
purple: {
|
|
638
|
+
400: '#b552e2',
|
|
639
|
+
600: '#6a27b8',
|
|
640
|
+
M400: '#b072cc',
|
|
641
|
+
M600: '#9358b0'
|
|
642
|
+
}
|
|
643
|
+
};
|
|
339
644
|
|
|
340
645
|
function retrieveComponentStyles(componentId, props) {
|
|
341
646
|
const components = props.theme && props.theme.components;
|
|
@@ -349,16 +654,203 @@ function retrieveComponentStyles(componentId, props) {
|
|
|
349
654
|
return componentStyles;
|
|
350
655
|
}
|
|
351
656
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
657
|
+
const POSITION_MAP = {
|
|
658
|
+
top: 'bottom',
|
|
659
|
+
'top-start': 'bottom-left',
|
|
660
|
+
'top-end': 'bottom-right',
|
|
661
|
+
right: 'left',
|
|
662
|
+
'right-start': 'left-top',
|
|
663
|
+
'right-end': 'left-bottom',
|
|
664
|
+
bottom: 'top',
|
|
665
|
+
'bottom-start': 'top-left',
|
|
666
|
+
'bottom-end': 'top-right',
|
|
667
|
+
left: 'right',
|
|
668
|
+
'left-start': 'right-top',
|
|
669
|
+
'left-end': 'right-bottom'
|
|
670
|
+
};
|
|
671
|
+
const RTL_POSITION_MAP = {
|
|
672
|
+
'bottom-left': 'bottom-right',
|
|
673
|
+
'bottom-right': 'bottom-left',
|
|
674
|
+
'top-left': 'top-right',
|
|
675
|
+
'top-right': 'top-left'
|
|
676
|
+
};
|
|
677
|
+
const getArrowPosition = (theme, placement) => {
|
|
678
|
+
let retVal = POSITION_MAP[placement];
|
|
679
|
+
if (theme.rtl) {
|
|
680
|
+
retVal = RTL_POSITION_MAP[retVal] || retVal;
|
|
681
|
+
}
|
|
682
|
+
return retVal;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
const PALETTE_SIZE = Object.keys(PALETTE.blue).length;
|
|
686
|
+
const adjust$1 = (color, expected, actual) => {
|
|
687
|
+
if (expected !== actual) {
|
|
688
|
+
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
689
|
+
return expected > actual ? polished.darken(amount, color) : polished.lighten(amount, color);
|
|
690
|
+
}
|
|
691
|
+
return color;
|
|
692
|
+
};
|
|
693
|
+
const toShade = (shade, offset, scheme) => {
|
|
694
|
+
let _shade;
|
|
695
|
+
if (shade === undefined) {
|
|
696
|
+
_shade = scheme === 'dark' ? 500 : 700;
|
|
697
|
+
} else {
|
|
698
|
+
_shade = parseInt(shade.toString(), 10);
|
|
699
|
+
if (isNaN(_shade)) {
|
|
700
|
+
throw new TypeError(`Error: unexpected '${typeof shade}' type for color shade "${shade}"`);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return _shade + (offset || 0);
|
|
704
|
+
};
|
|
705
|
+
const toHex = (hue, shade, offset, scheme) => {
|
|
706
|
+
const _shade = toShade(shade, offset, scheme);
|
|
707
|
+
let retVal = hue[_shade];
|
|
708
|
+
if (!retVal) {
|
|
709
|
+
const closestShade = Object.keys(hue).map(hueShade => parseInt(hueShade, 10)).reduce((previous, current) => {
|
|
710
|
+
return Math.abs(current - _shade) < Math.abs(previous - _shade) ? current : previous;
|
|
711
|
+
});
|
|
712
|
+
retVal = adjust$1(hue[closestShade], _shade, closestShade);
|
|
713
|
+
}
|
|
714
|
+
return retVal;
|
|
715
|
+
};
|
|
716
|
+
const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transparency) => {
|
|
717
|
+
let retVal;
|
|
718
|
+
let _hue = colors[hue] || hue;
|
|
719
|
+
if (Object.hasOwn(palette, _hue)) {
|
|
720
|
+
_hue = palette[_hue];
|
|
721
|
+
}
|
|
722
|
+
if (typeof _hue === 'object') {
|
|
723
|
+
retVal = toHex(_hue, shade, offset, scheme);
|
|
724
|
+
} else if (_hue === 'transparent' || chromaJs.valid(_hue)) {
|
|
725
|
+
if (shade === undefined) {
|
|
726
|
+
retVal = _hue;
|
|
727
|
+
} else {
|
|
728
|
+
const _colors = chromaJs.scale([PALETTE.white, _hue, PALETTE.black]).correctLightness().colors(PALETTE_SIZE + 2);
|
|
729
|
+
_hue = _colors.reduce((_retVal, color, index) => {
|
|
730
|
+
if (index > 0 && index <= PALETTE_SIZE) {
|
|
731
|
+
_retVal[index * 100] = color;
|
|
732
|
+
}
|
|
733
|
+
return _retVal;
|
|
734
|
+
}, {});
|
|
735
|
+
retVal = toHex(_hue, shade, offset, scheme);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (retVal && transparency) {
|
|
739
|
+
const alpha = transparency > 1 ? opacity[transparency] : transparency;
|
|
740
|
+
if (alpha === undefined) {
|
|
741
|
+
throw new Error('Error: invalid `transparency` parameter');
|
|
742
|
+
}
|
|
743
|
+
retVal = polished.rgba(retVal, alpha);
|
|
744
|
+
}
|
|
745
|
+
return retVal;
|
|
746
|
+
};
|
|
747
|
+
const toProperty = (object, path) => {
|
|
748
|
+
const retVal = get__default.default(object, path);
|
|
749
|
+
if (typeof retVal === 'string') {
|
|
750
|
+
return retVal;
|
|
751
|
+
} else if (retVal === undefined) {
|
|
752
|
+
throw new ReferenceError(`Error: color variable '${path}' is not defined`);
|
|
753
|
+
} else {
|
|
754
|
+
throw new TypeError(`Error: unexpected '${typeof retVal}' type for color variable "${path}"`);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
const getColor = memoize__default.default(_ref => {
|
|
758
|
+
let {
|
|
759
|
+
dark,
|
|
760
|
+
hue,
|
|
761
|
+
light,
|
|
762
|
+
offset,
|
|
763
|
+
shade,
|
|
764
|
+
theme,
|
|
765
|
+
transparency,
|
|
766
|
+
variable
|
|
767
|
+
} = _ref;
|
|
768
|
+
let retVal;
|
|
769
|
+
const palette = theme.palette && Object.keys(theme.palette).length > 0 ? theme.palette : DEFAULT_THEME.palette;
|
|
770
|
+
const {
|
|
771
|
+
base,
|
|
772
|
+
variables,
|
|
773
|
+
...colors
|
|
774
|
+
} = theme.colors && Object.keys(theme.colors).length > 0 ? theme.colors : DEFAULT_THEME.colors;
|
|
775
|
+
const scheme = base === 'dark' ? 'dark' : 'light';
|
|
776
|
+
const mode = scheme === 'dark' ? dark : light;
|
|
777
|
+
let _hue = mode?.hue || hue;
|
|
778
|
+
let _shade = mode?.shade === undefined ? shade : mode.shade;
|
|
779
|
+
const _offset = mode?.offset === undefined ? offset : mode.offset;
|
|
780
|
+
const _transparency = mode?.transparency === undefined ? transparency : mode.transparency;
|
|
781
|
+
if (variable) {
|
|
782
|
+
const _variables = variables?.[scheme] ? variables[scheme] : DEFAULT_THEME.colors.variables[scheme];
|
|
783
|
+
const property = toProperty(_variables, variable);
|
|
784
|
+
const [key, value] = property.split(/\.(?<value>.*)/u);
|
|
785
|
+
if (key === 'palette') {
|
|
786
|
+
_hue = toProperty(palette, value);
|
|
787
|
+
} else {
|
|
788
|
+
_hue = key;
|
|
789
|
+
_shade = parseInt(value, 10);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (_hue) {
|
|
793
|
+
const opacity = theme.opacity && Object.keys(theme.opacity).length > 0 ? theme.opacity : DEFAULT_THEME.opacity;
|
|
794
|
+
retVal = toColor(colors, palette, opacity, scheme, _hue, _shade, _offset, _transparency);
|
|
795
|
+
}
|
|
796
|
+
if (retVal === undefined) {
|
|
797
|
+
throw new Error('Error: invalid `getColor` parameters');
|
|
798
|
+
}
|
|
799
|
+
return retVal;
|
|
800
|
+
}, _ref2 => {
|
|
801
|
+
let {
|
|
802
|
+
dark,
|
|
803
|
+
hue,
|
|
804
|
+
light,
|
|
805
|
+
offset,
|
|
806
|
+
shade,
|
|
807
|
+
theme,
|
|
808
|
+
transparency,
|
|
809
|
+
variable
|
|
810
|
+
} = _ref2;
|
|
811
|
+
return JSON.stringify({
|
|
812
|
+
dark,
|
|
813
|
+
hue,
|
|
814
|
+
light,
|
|
815
|
+
offset,
|
|
816
|
+
shade,
|
|
817
|
+
colors: theme.colors,
|
|
818
|
+
palette: theme.palette,
|
|
819
|
+
transparency,
|
|
820
|
+
variable
|
|
821
|
+
});
|
|
822
|
+
});
|
|
355
823
|
|
|
356
|
-
|
|
824
|
+
const getCheckeredBackground = _ref => {
|
|
357
825
|
let {
|
|
358
|
-
theme
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
826
|
+
theme,
|
|
827
|
+
size,
|
|
828
|
+
overlay,
|
|
829
|
+
positionY = 0,
|
|
830
|
+
repeat = 'repeat'
|
|
831
|
+
} = _ref;
|
|
832
|
+
const color = getColor({
|
|
833
|
+
theme,
|
|
834
|
+
variable: 'border.default'
|
|
835
|
+
});
|
|
836
|
+
const dimensions = `${size}px ${size}px`;
|
|
837
|
+
const positionX1 = theme.rtl ? '100%' : '0';
|
|
838
|
+
const positionX2 = theme.rtl ? `calc(100% - ${size / 2}px)` : `${size / 2}px`;
|
|
839
|
+
const position1 = `${positionX1} ${positionY}px`;
|
|
840
|
+
const position2 = `${positionX2} ${size / 2 + positionY}px`;
|
|
841
|
+
const position3 = `${positionX2} ${positionY}px`;
|
|
842
|
+
const position4 = `${positionX1} ${size / -2 + positionY}px`;
|
|
843
|
+
let retVal = `
|
|
844
|
+
linear-gradient(45deg, ${color} 25%, transparent 25%) ${position1} / ${dimensions} ${repeat},
|
|
845
|
+
linear-gradient(45deg, transparent 75%, ${color} 75%) ${position2} / ${dimensions} ${repeat},
|
|
846
|
+
linear-gradient(135deg, ${color} 25%, transparent 25%) ${position3} / ${dimensions} ${repeat},
|
|
847
|
+
linear-gradient(135deg, transparent 75%, ${color} 75%) ${position4} / ${dimensions} ${repeat}
|
|
848
|
+
`;
|
|
849
|
+
if (overlay) {
|
|
850
|
+
retVal = overlay.startsWith('linear-gradient') ? `${overlay}, ${retVal}` : `linear-gradient(${overlay}, ${overlay}), ${retVal}`;
|
|
851
|
+
}
|
|
852
|
+
return retVal;
|
|
853
|
+
};
|
|
362
854
|
|
|
363
855
|
const DEFAULT_SHADE = 600;
|
|
364
856
|
const adjust = (color, expected, actual) => {
|
|
@@ -368,7 +860,7 @@ const adjust = (color, expected, actual) => {
|
|
|
368
860
|
}
|
|
369
861
|
return color;
|
|
370
862
|
};
|
|
371
|
-
const
|
|
863
|
+
const getColorV8 = memoize__default.default(function (hue) {
|
|
372
864
|
let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
|
|
373
865
|
let theme = arguments.length > 2 ? arguments[2] : undefined;
|
|
374
866
|
let transparency = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -376,7 +868,17 @@ const getColor = memoize__default.default(function (hue) {
|
|
|
376
868
|
if (isNaN(shade)) {
|
|
377
869
|
return undefined;
|
|
378
870
|
}
|
|
379
|
-
const palette =
|
|
871
|
+
const palette = {
|
|
872
|
+
background: PALETTE_V8.white,
|
|
873
|
+
foreground: PALETTE_V8.grey[800],
|
|
874
|
+
...(theme && theme.palette ? {
|
|
875
|
+
...theme.palette,
|
|
876
|
+
...PALETTE_V8
|
|
877
|
+
} : {
|
|
878
|
+
...DEFAULT_THEME.palette,
|
|
879
|
+
...PALETTE_V8
|
|
880
|
+
})
|
|
881
|
+
};
|
|
380
882
|
const colors = theme && theme.colors ? theme.colors : DEFAULT_THEME.colors;
|
|
381
883
|
let _hue;
|
|
382
884
|
if (typeof hue === 'string') {
|
|
@@ -410,26 +912,87 @@ const getColor = memoize__default.default(function (hue) {
|
|
|
410
912
|
transparency
|
|
411
913
|
}));
|
|
412
914
|
|
|
915
|
+
const PLACEMENT_MAP = {
|
|
916
|
+
end: 'right',
|
|
917
|
+
'end-top': 'right-start',
|
|
918
|
+
'end-bottom': 'right-end',
|
|
919
|
+
start: 'left',
|
|
920
|
+
'start-top': 'left-start',
|
|
921
|
+
'start-bottom': 'left-end'
|
|
922
|
+
};
|
|
923
|
+
const RTL_PLACEMENT_MAP = {
|
|
924
|
+
left: 'right',
|
|
925
|
+
'left-start': 'right-start',
|
|
926
|
+
'left-end': 'right-end',
|
|
927
|
+
right: 'left',
|
|
928
|
+
'right-start': 'left-start',
|
|
929
|
+
'right-end': 'left-end'
|
|
930
|
+
};
|
|
931
|
+
const toFloatingPlacement = (placement, theme) => {
|
|
932
|
+
let retVal = PLACEMENT_MAP[placement] || placement;
|
|
933
|
+
if (theme.rtl) {
|
|
934
|
+
retVal = RTL_PLACEMENT_MAP[retVal] || retVal;
|
|
935
|
+
}
|
|
936
|
+
return retVal;
|
|
937
|
+
};
|
|
938
|
+
const SIDE_FALLBACKS_MAP = {
|
|
939
|
+
top: ['top-start', 'top', 'top-end'],
|
|
940
|
+
right: ['right-start', 'right', 'right-end'],
|
|
941
|
+
bottom: ['bottom-start', 'bottom', 'bottom-end'],
|
|
942
|
+
left: ['left-start', 'left', 'left-end']
|
|
943
|
+
};
|
|
944
|
+
const SIDE_OPPOSITE_MAP = {
|
|
945
|
+
top: 'bottom',
|
|
946
|
+
right: 'left',
|
|
947
|
+
bottom: 'top',
|
|
948
|
+
left: 'right'
|
|
949
|
+
};
|
|
950
|
+
const toFallbackPlacements = (primaryPlacement, theme, fallbackPlacements) => {
|
|
951
|
+
if (Array.isArray(fallbackPlacements) && fallbackPlacements.length > 0) {
|
|
952
|
+
return fallbackPlacements.map(fallbackPlacement => toFloatingPlacement(fallbackPlacement, theme));
|
|
953
|
+
}
|
|
954
|
+
const side = primaryPlacement.split('-')[0];
|
|
955
|
+
const sameSideFallbackPlacements = [...SIDE_FALLBACKS_MAP[side]];
|
|
956
|
+
const oppositeSideFallbackPlacements = SIDE_FALLBACKS_MAP[SIDE_OPPOSITE_MAP[side]];
|
|
957
|
+
sameSideFallbackPlacements.splice(sameSideFallbackPlacements.indexOf(primaryPlacement), 1);
|
|
958
|
+
return [...sameSideFallbackPlacements, ...oppositeSideFallbackPlacements];
|
|
959
|
+
};
|
|
960
|
+
const getFloatingPlacements = (theme, placement, fallbackPlacements) => {
|
|
961
|
+
const floatingPlacement = toFloatingPlacement(placement, theme);
|
|
962
|
+
const floatingFallbackPlacements = toFallbackPlacements(floatingPlacement, theme, fallbackPlacements);
|
|
963
|
+
return [floatingPlacement, floatingFallbackPlacements];
|
|
964
|
+
};
|
|
965
|
+
|
|
413
966
|
const getFocusBoxShadow = _ref => {
|
|
414
967
|
let {
|
|
415
968
|
boxShadow,
|
|
416
969
|
inset = false,
|
|
417
|
-
|
|
418
|
-
|
|
970
|
+
color = {
|
|
971
|
+
variable: 'border.primaryEmphasis'
|
|
972
|
+
},
|
|
419
973
|
shadowWidth = 'md',
|
|
420
|
-
|
|
421
|
-
|
|
974
|
+
spacerColor = {
|
|
975
|
+
variable: 'background.default'
|
|
976
|
+
},
|
|
422
977
|
spacerWidth = 'xs',
|
|
423
|
-
theme = DEFAULT_THEME
|
|
978
|
+
theme = DEFAULT_THEME,
|
|
979
|
+
...args
|
|
424
980
|
} = _ref;
|
|
425
|
-
const
|
|
426
|
-
const
|
|
981
|
+
const _args = args;
|
|
982
|
+
const _color = _args.hue ? getColorV8(_args.hue, _args.shade, theme) : getColor({
|
|
983
|
+
...color,
|
|
984
|
+
theme
|
|
985
|
+
});
|
|
986
|
+
const shadow = theme.shadows[shadowWidth](_color);
|
|
427
987
|
if (spacerWidth === null) {
|
|
428
988
|
return `${inset ? 'inset' : ''} ${shadow}`;
|
|
429
989
|
}
|
|
430
|
-
const
|
|
990
|
+
const _spacerColor = _args.spacerHue ? getColorV8(_args.spacerHue, _args.spacerShade, theme) : getColor({
|
|
991
|
+
...spacerColor,
|
|
992
|
+
theme
|
|
993
|
+
});
|
|
431
994
|
const retVal = `
|
|
432
|
-
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](
|
|
995
|
+
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](_spacerColor)},
|
|
433
996
|
${inset ? 'inset' : ''} ${shadow}`;
|
|
434
997
|
return boxShadow ? `${retVal}, ${boxShadow}` : retVal;
|
|
435
998
|
};
|
|
@@ -447,6 +1010,10 @@ function getLineHeight(height, fontSize) {
|
|
|
447
1010
|
return heightValue / fontSizeValue;
|
|
448
1011
|
}
|
|
449
1012
|
|
|
1013
|
+
const getMenuPosition = placement => {
|
|
1014
|
+
return placement.split('-')[0];
|
|
1015
|
+
};
|
|
1016
|
+
|
|
450
1017
|
const maxWidth = (breakpoints, breakpoint) => {
|
|
451
1018
|
const keys = Object.keys(breakpoints);
|
|
452
1019
|
const index = keys.indexOf(breakpoint) + 1;
|
|
@@ -511,8 +1078,8 @@ const exponentialSymbols = {
|
|
|
511
1078
|
};
|
|
512
1079
|
const animationStyles$1 = (position, modifier) => {
|
|
513
1080
|
const property = position.split('-')[0];
|
|
514
|
-
const animationName =
|
|
515
|
-
return
|
|
1081
|
+
const animationName = styled.keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
1082
|
+
return styled.css(["&", "::before,&", "::after{animation:0.3s ease-in-out ", ";}"], modifier, modifier, animationName);
|
|
516
1083
|
};
|
|
517
1084
|
const positionStyles = (position, size, inset) => {
|
|
518
1085
|
const margin = polished.math(`${size} / -2`);
|
|
@@ -523,30 +1090,42 @@ const positionStyles = (position, size, inset) => {
|
|
|
523
1090
|
if (position.startsWith('top')) {
|
|
524
1091
|
propertyRadius = 'border-bottom-right-radius';
|
|
525
1092
|
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
526
|
-
positionCss =
|
|
1093
|
+
positionCss = styled.css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
|
|
527
1094
|
} else if (position.startsWith('right')) {
|
|
528
1095
|
propertyRadius = 'border-bottom-left-radius';
|
|
529
1096
|
clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
|
|
530
|
-
positionCss =
|
|
1097
|
+
positionCss = styled.css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
|
|
531
1098
|
} else if (position.startsWith('bottom')) {
|
|
532
1099
|
propertyRadius = 'border-top-left-radius';
|
|
533
1100
|
clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
|
|
534
|
-
positionCss =
|
|
1101
|
+
positionCss = styled.css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
|
|
535
1102
|
} else if (position.startsWith('left')) {
|
|
536
1103
|
propertyRadius = 'border-top-right-radius';
|
|
537
1104
|
clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
|
|
538
|
-
positionCss =
|
|
1105
|
+
positionCss = styled.css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
|
|
539
1106
|
}
|
|
540
|
-
return
|
|
1107
|
+
return styled.css(["&::before{", ":100%;clip-path:", ";}&::before,&::after{", "}"], propertyRadius, clipPath, positionCss);
|
|
541
1108
|
};
|
|
542
1109
|
function arrowStyles(position) {
|
|
543
1110
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
544
1111
|
const size = options.size || '6px';
|
|
545
1112
|
const inset = options.inset || '0';
|
|
546
1113
|
const squareSize = polished.math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
|
|
547
|
-
return
|
|
1114
|
+
return styled.css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
|
|
548
1115
|
}
|
|
549
1116
|
|
|
1117
|
+
const useDocument = theme => {
|
|
1118
|
+
const [controlledDocument, setControlledDocument] = React.useState();
|
|
1119
|
+
React.useEffect(() => {
|
|
1120
|
+
if (theme && theme.document) {
|
|
1121
|
+
setControlledDocument(theme.document);
|
|
1122
|
+
} else {
|
|
1123
|
+
setControlledDocument(document);
|
|
1124
|
+
}
|
|
1125
|
+
}, [theme]);
|
|
1126
|
+
return controlledDocument;
|
|
1127
|
+
};
|
|
1128
|
+
|
|
550
1129
|
const useWindow = theme => {
|
|
551
1130
|
const [controlledWindow, setControlledWindow] = React.useState();
|
|
552
1131
|
React.useEffect(() => {
|
|
@@ -594,12 +1173,12 @@ const animationStyles = (position, options) => {
|
|
|
594
1173
|
} else {
|
|
595
1174
|
transformFunction = 'translateX';
|
|
596
1175
|
}
|
|
597
|
-
const animationName =
|
|
598
|
-
return
|
|
1176
|
+
const animationName = styled.keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
1177
|
+
return styled.css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
599
1178
|
};
|
|
600
1179
|
const hiddenStyles = options => {
|
|
601
1180
|
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
602
|
-
return
|
|
1181
|
+
return styled.css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
603
1182
|
};
|
|
604
1183
|
function menuStyles(position) {
|
|
605
1184
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -614,10 +1193,24 @@ function menuStyles(position) {
|
|
|
614
1193
|
} else {
|
|
615
1194
|
marginProperty = 'margin-right';
|
|
616
1195
|
}
|
|
617
|
-
return
|
|
1196
|
+
return styled.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", " ", ";border-radius:", ";box-shadow:", ";background-color:", ";cursor:default;padding:0;text-align:", ";white-space:normal;color:", ";font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor({
|
|
1197
|
+
theme,
|
|
1198
|
+
variable: 'border.default'
|
|
1199
|
+
}), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
|
|
1200
|
+
theme,
|
|
1201
|
+
hue: 'chromeHue',
|
|
1202
|
+
shade: 600,
|
|
1203
|
+
transparency: 0.15
|
|
1204
|
+
})), getColor({
|
|
1205
|
+
theme,
|
|
1206
|
+
variable: 'background.raised'
|
|
1207
|
+
}), theme.rtl ? 'right' : 'left', getColor({
|
|
1208
|
+
theme,
|
|
1209
|
+
variable: 'foreground.default'
|
|
1210
|
+
}), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
618
1211
|
}
|
|
619
1212
|
|
|
620
|
-
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible
|
|
1213
|
+
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible';
|
|
621
1214
|
const focusStyles = _ref => {
|
|
622
1215
|
let {
|
|
623
1216
|
condition = true,
|
|
@@ -646,30 +1239,47 @@ const focusStyles = _ref => {
|
|
|
646
1239
|
outline = `${polished.math(`${theme.shadowWidths[shadowWidth]} - ${theme.shadowWidths[spacerWidth]}`)} solid transparent`;
|
|
647
1240
|
outlineOffset = theme.shadowWidths[spacerWidth];
|
|
648
1241
|
}
|
|
649
|
-
return
|
|
1242
|
+
return styled.css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, _boxShadow, styles);
|
|
650
1243
|
};
|
|
651
1244
|
|
|
1245
|
+
const StyledBaseIcon = styled__default.default(_ref => {
|
|
1246
|
+
let {
|
|
1247
|
+
children,
|
|
1248
|
+
theme,
|
|
1249
|
+
...props
|
|
1250
|
+
} = _ref;
|
|
1251
|
+
return React__default.default.cloneElement(React.Children.only(children), props);
|
|
1252
|
+
}).withConfig({
|
|
1253
|
+
displayName: "StyledBaseIcon",
|
|
1254
|
+
componentId: "sc-1moykgb-0"
|
|
1255
|
+
})([""]);
|
|
1256
|
+
|
|
652
1257
|
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
653
1258
|
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
1259
|
+
const PLACEMENT = ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
654
1260
|
|
|
655
|
-
exports.
|
|
656
|
-
exports.ARRAY_MENU_POSITION = MENU_POSITION;
|
|
1261
|
+
exports.ARROW_POSITION = ARROW_POSITION;
|
|
657
1262
|
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
1263
|
+
exports.MENU_POSITION = MENU_POSITION;
|
|
658
1264
|
exports.PALETTE = PALETTE;
|
|
1265
|
+
exports.PALETTE_V8 = PALETTE_V8;
|
|
1266
|
+
exports.PLACEMENT = PLACEMENT;
|
|
659
1267
|
exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
|
|
1268
|
+
exports.StyledBaseIcon = StyledBaseIcon;
|
|
660
1269
|
exports.ThemeProvider = ThemeProvider;
|
|
661
1270
|
exports.arrowStyles = arrowStyles;
|
|
662
1271
|
exports.focusStyles = focusStyles;
|
|
1272
|
+
exports.getArrowPosition = getArrowPosition;
|
|
1273
|
+
exports.getCheckeredBackground = getCheckeredBackground;
|
|
663
1274
|
exports.getColor = getColor;
|
|
664
|
-
exports.
|
|
1275
|
+
exports.getColorV8 = getColorV8;
|
|
1276
|
+
exports.getFloatingPlacements = getFloatingPlacements;
|
|
665
1277
|
exports.getFocusBoxShadow = getFocusBoxShadow;
|
|
666
1278
|
exports.getLineHeight = getLineHeight;
|
|
667
|
-
exports.
|
|
1279
|
+
exports.getMenuPosition = getMenuPosition;
|
|
668
1280
|
exports.mediaQuery = mediaQuery;
|
|
669
1281
|
exports.menuStyles = menuStyles;
|
|
670
1282
|
exports.retrieveComponentStyles = retrieveComponentStyles;
|
|
671
|
-
exports.retrieveTheme = retrieveComponentStyles;
|
|
672
1283
|
exports.useDocument = useDocument;
|
|
673
1284
|
exports.useText = useText;
|
|
674
1285
|
exports.useWindow = useWindow;
|
|
675
|
-
exports.withTheme = withTheme;
|