@zendeskgarden/react-theming 9.0.0-next.7 → 9.0.0-next.8
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/dist/esm/elements/ThemeProvider.js +24 -0
- package/dist/esm/elements/palette/index.js +283 -0
- package/dist/esm/elements/palette/v8.js +149 -0
- package/dist/esm/elements/theme/index.js +209 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/types/index.js +11 -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/getColor.js +148 -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 +107 -39
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/types/index.d.ts +35 -1
- package/dist/typings/utils/focusStyles.d.ts +1 -8
- package/dist/typings/utils/getColor.d.ts +1 -22
- package/dist/typings/utils/getFocusBoxShadow.d.ts +6 -20
- package/package.json +3 -3
- package/dist/index.esm.js +0 -1145
package/dist/index.esm.js
DELETED
|
@@ -1,1145 +0,0 @@
|
|
|
1
|
-
/**
|
|
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
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { useState, useEffect, useMemo } from 'react';
|
|
9
|
-
import { ThemeProvider as ThemeProvider$1, css, keyframes } from 'styled-components';
|
|
10
|
-
import { valid, scale } from 'chroma-js';
|
|
11
|
-
import { rgba, darken, lighten, getValueAndUnit, math } from 'polished';
|
|
12
|
-
import get from 'lodash.get';
|
|
13
|
-
import memoize from 'lodash.memoize';
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const PALETTE = {
|
|
31
|
-
black: '#000',
|
|
32
|
-
white: '#fff',
|
|
33
|
-
product: {
|
|
34
|
-
support: '#00a656',
|
|
35
|
-
message: '#37b8af',
|
|
36
|
-
explore: '#30aabc',
|
|
37
|
-
gather: '#f6c8be',
|
|
38
|
-
guide: '#eb4962',
|
|
39
|
-
connect: '#ff6224',
|
|
40
|
-
chat: '#f79a3e',
|
|
41
|
-
talk: '#efc93d',
|
|
42
|
-
sell: '#c38f00'
|
|
43
|
-
},
|
|
44
|
-
grey: {
|
|
45
|
-
100: '#f4f6f6',
|
|
46
|
-
200: '#e4e7e9',
|
|
47
|
-
300: '#c7cdd0',
|
|
48
|
-
400: '#afb7bd',
|
|
49
|
-
500: '#88929d',
|
|
50
|
-
600: '#7f8a95',
|
|
51
|
-
700: '#65707a',
|
|
52
|
-
800: '#4b565f',
|
|
53
|
-
900: '#2e373f',
|
|
54
|
-
1000: '#1e252a',
|
|
55
|
-
1100: '#171b1f',
|
|
56
|
-
1200: '#101316'
|
|
57
|
-
},
|
|
58
|
-
blue: {
|
|
59
|
-
100: '#edf7ff',
|
|
60
|
-
200: '#d9eaf7',
|
|
61
|
-
300: '#b3d0e7',
|
|
62
|
-
400: '#92bbdb',
|
|
63
|
-
500: '#5896c9',
|
|
64
|
-
600: '#4b8ec5',
|
|
65
|
-
700: '#1f73b7',
|
|
66
|
-
800: '#18578b',
|
|
67
|
-
900: '#103859',
|
|
68
|
-
1000: '#0b253b',
|
|
69
|
-
1100: '#081c2d',
|
|
70
|
-
1200: '#061420'
|
|
71
|
-
},
|
|
72
|
-
red: {
|
|
73
|
-
100: '#fff2f3',
|
|
74
|
-
200: '#fde1e3',
|
|
75
|
-
300: '#f5bfc4',
|
|
76
|
-
400: '#f2a0a6',
|
|
77
|
-
500: '#e76973',
|
|
78
|
-
600: '#e35c67',
|
|
79
|
-
700: '#cd3642',
|
|
80
|
-
800: '#9d2933',
|
|
81
|
-
900: '#6c1219',
|
|
82
|
-
1000: '#431418',
|
|
83
|
-
1100: '#2d1315',
|
|
84
|
-
1200: '#1b1011'
|
|
85
|
-
},
|
|
86
|
-
yellow: {
|
|
87
|
-
100: '#fff3e4',
|
|
88
|
-
200: '#ffe2c2',
|
|
89
|
-
300: '#ffc079',
|
|
90
|
-
400: '#fba246',
|
|
91
|
-
500: '#d87916',
|
|
92
|
-
600: '#ce7117',
|
|
93
|
-
700: '#ac5918',
|
|
94
|
-
800: '#874114',
|
|
95
|
-
900: '#512d17',
|
|
96
|
-
1000: '#312016',
|
|
97
|
-
1100: '#221913',
|
|
98
|
-
1200: '#17120f'
|
|
99
|
-
},
|
|
100
|
-
green: {
|
|
101
|
-
100: '#eef8f4',
|
|
102
|
-
200: '#d7ede4',
|
|
103
|
-
300: '#b4d3c6',
|
|
104
|
-
400: '#91bfae',
|
|
105
|
-
500: '#3fa17e',
|
|
106
|
-
600: '#329974',
|
|
107
|
-
700: '#037f52',
|
|
108
|
-
800: '#186045',
|
|
109
|
-
900: '#0b3e2b',
|
|
110
|
-
1000: '#0c291e',
|
|
111
|
-
1100: '#0b1e17',
|
|
112
|
-
1200: '#0a1511'
|
|
113
|
-
},
|
|
114
|
-
kale: {
|
|
115
|
-
100: '#ecf9f9',
|
|
116
|
-
200: '#d8ebeb',
|
|
117
|
-
300: '#b3d2d0',
|
|
118
|
-
400: '#94bebd',
|
|
119
|
-
500: '#5e9b9c',
|
|
120
|
-
600: '#579394',
|
|
121
|
-
700: '#40787a',
|
|
122
|
-
800: '#275c5f',
|
|
123
|
-
900: '#0a3c42',
|
|
124
|
-
1000: '#02282d',
|
|
125
|
-
1100: '#041e22',
|
|
126
|
-
1200: '#061517'
|
|
127
|
-
},
|
|
128
|
-
fuschia: {
|
|
129
|
-
100: '#fbf3f8',
|
|
130
|
-
200: '#f6e2ef',
|
|
131
|
-
300: '#ecc0dc',
|
|
132
|
-
400: '#e3a2cc',
|
|
133
|
-
500: '#d36faf',
|
|
134
|
-
600: '#cf63a8',
|
|
135
|
-
700: '#b34496',
|
|
136
|
-
800: '#971688',
|
|
137
|
-
900: '#640e59',
|
|
138
|
-
1000: '#430a3d',
|
|
139
|
-
1100: '#34072f',
|
|
140
|
-
1200: '#260523',
|
|
141
|
-
M400: '#cf62a8',
|
|
142
|
-
M600: '#a8458c'
|
|
143
|
-
},
|
|
144
|
-
pink: {
|
|
145
|
-
100: '#fcf4f5',
|
|
146
|
-
200: '#f7e3e8',
|
|
147
|
-
300: '#edc1ca',
|
|
148
|
-
400: '#e4a5b3',
|
|
149
|
-
500: '#d57388',
|
|
150
|
-
600: '#e35b72',
|
|
151
|
-
700: '#d62054',
|
|
152
|
-
800: '#94304e',
|
|
153
|
-
900: '#611f32',
|
|
154
|
-
1000: '#401522',
|
|
155
|
-
1100: '#31101a',
|
|
156
|
-
1200: '#230b12',
|
|
157
|
-
M400: '#d57287',
|
|
158
|
-
M600: '#b23a5d'
|
|
159
|
-
},
|
|
160
|
-
crimson: {
|
|
161
|
-
100: '#fbf4f3',
|
|
162
|
-
200: '#f6e4e1',
|
|
163
|
-
300: '#eac3bc',
|
|
164
|
-
400: '#e1a89e',
|
|
165
|
-
500: '#d1796a',
|
|
166
|
-
600: '#cd6e5d',
|
|
167
|
-
700: '#be4938',
|
|
168
|
-
800: '#a32217',
|
|
169
|
-
900: '#6b160f',
|
|
170
|
-
1000: '#480f0a',
|
|
171
|
-
1100: '#370c08',
|
|
172
|
-
1200: '#280806',
|
|
173
|
-
M400: '#cc6c5b',
|
|
174
|
-
M600: '#b24a3c'
|
|
175
|
-
},
|
|
176
|
-
orange: {
|
|
177
|
-
100: '#fdf3ed',
|
|
178
|
-
200: '#f9e3d3',
|
|
179
|
-
300: '#f2c39f',
|
|
180
|
-
400: '#eda671',
|
|
181
|
-
500: '#e2721e',
|
|
182
|
-
600: '#d26e20',
|
|
183
|
-
700: '#af5626',
|
|
184
|
-
800: '#85421d',
|
|
185
|
-
900: '#562b13',
|
|
186
|
-
1000: '#3a1c0d',
|
|
187
|
-
1100: '#2c150a',
|
|
188
|
-
1200: '#1f0f07',
|
|
189
|
-
M400: '#d4772c',
|
|
190
|
-
M600: '#b35827'
|
|
191
|
-
},
|
|
192
|
-
lemon: {
|
|
193
|
-
100: '#fff6cf',
|
|
194
|
-
200: '#ffe682',
|
|
195
|
-
300: '#ffc417',
|
|
196
|
-
400: '#eda900',
|
|
197
|
-
500: '#ba8900',
|
|
198
|
-
600: '#b08100',
|
|
199
|
-
700: '#8f6900',
|
|
200
|
-
800: '#6d5000',
|
|
201
|
-
900: '#463300',
|
|
202
|
-
1000: '#2f2200',
|
|
203
|
-
1100: '#231a00',
|
|
204
|
-
1200: '#191200',
|
|
205
|
-
M400: '#e7a500',
|
|
206
|
-
M600: '#c38f00'
|
|
207
|
-
},
|
|
208
|
-
lime: {
|
|
209
|
-
100: '#ebfae6',
|
|
210
|
-
200: '#c9f2bd',
|
|
211
|
-
300: '#88e270',
|
|
212
|
-
400: '#4ecf2a',
|
|
213
|
-
500: '#4da42a',
|
|
214
|
-
600: '#489b20',
|
|
215
|
-
700: '#3d7e19',
|
|
216
|
-
800: '#385f23',
|
|
217
|
-
900: '#243c16',
|
|
218
|
-
1000: '#18280f',
|
|
219
|
-
1100: '#121e0b',
|
|
220
|
-
1200: '#0d1508',
|
|
221
|
-
M400: '#519e2d',
|
|
222
|
-
M600: '#47782c'
|
|
223
|
-
},
|
|
224
|
-
mint: {
|
|
225
|
-
100: '#d6ffeb',
|
|
226
|
-
200: '#83ffc3',
|
|
227
|
-
300: '#00ea79',
|
|
228
|
-
400: '#00d16d',
|
|
229
|
-
500: '#00a756',
|
|
230
|
-
600: '#279b65',
|
|
231
|
-
700: '#2d7d55',
|
|
232
|
-
800: '#225f41',
|
|
233
|
-
900: '#163d2a',
|
|
234
|
-
1000: '#0f291c',
|
|
235
|
-
1100: '#0b1e15',
|
|
236
|
-
1200: '#08150f',
|
|
237
|
-
M400: '#299c66',
|
|
238
|
-
M600: '#2e8057'
|
|
239
|
-
},
|
|
240
|
-
teal: {
|
|
241
|
-
100: '#d6fefa',
|
|
242
|
-
200: '#70fdef',
|
|
243
|
-
300: '#03e5ce',
|
|
244
|
-
400: '#03ccb8',
|
|
245
|
-
500: '#02a392',
|
|
246
|
-
600: '#1f998b',
|
|
247
|
-
700: '#367a74',
|
|
248
|
-
800: '#2e5c59',
|
|
249
|
-
900: '#1e3b39',
|
|
250
|
-
1000: '#142726',
|
|
251
|
-
1100: '#0f1d1c',
|
|
252
|
-
1200: '#0a1514',
|
|
253
|
-
M400: '#2d9e8f',
|
|
254
|
-
M600: '#3c7873'
|
|
255
|
-
},
|
|
256
|
-
azure: {
|
|
257
|
-
100: '#f0f7fe',
|
|
258
|
-
200: '#d7eafb',
|
|
259
|
-
300: '#a8d1f7',
|
|
260
|
-
400: '#7fbbf3',
|
|
261
|
-
500: '#3795ed',
|
|
262
|
-
600: '#598ad0',
|
|
263
|
-
700: '#2770c4',
|
|
264
|
-
800: '#2c5689',
|
|
265
|
-
900: '#1d3758',
|
|
266
|
-
1000: '#13253a',
|
|
267
|
-
1100: '#0e1b2c',
|
|
268
|
-
1200: '#0a131f',
|
|
269
|
-
M400: '#5f8dcf',
|
|
270
|
-
M600: '#3a70b2'
|
|
271
|
-
},
|
|
272
|
-
royal: {
|
|
273
|
-
100: '#f5f6fc',
|
|
274
|
-
200: '#e3e6f7',
|
|
275
|
-
300: '#c5cbee',
|
|
276
|
-
400: '#abb3e7',
|
|
277
|
-
500: '#7f8cda',
|
|
278
|
-
600: '#7182e1',
|
|
279
|
-
700: '#4d67d3',
|
|
280
|
-
800: '#1f40d8',
|
|
281
|
-
900: '#142a8d',
|
|
282
|
-
1000: '#0e1c5f',
|
|
283
|
-
1100: '#0a1548',
|
|
284
|
-
1200: '#070f34',
|
|
285
|
-
M400: '#7986d8',
|
|
286
|
-
M600: '#4b61c3'
|
|
287
|
-
},
|
|
288
|
-
purple: {
|
|
289
|
-
100: '#f9f4fb',
|
|
290
|
-
200: '#efe3f5',
|
|
291
|
-
300: '#ddc3e9',
|
|
292
|
-
400: '#cea8e0',
|
|
293
|
-
500: '#b57acf',
|
|
294
|
-
600: '#b16ecf',
|
|
295
|
-
700: '#9256b1',
|
|
296
|
-
800: '#722eb8',
|
|
297
|
-
900: '#491b7f',
|
|
298
|
-
1000: '#311256',
|
|
299
|
-
1100: '#250e41',
|
|
300
|
-
1200: '#1b0a2e',
|
|
301
|
-
M400: '#b072cc',
|
|
302
|
-
M600: '#9358b0'
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const BASE = 4;
|
|
307
|
-
const borderRadii = {
|
|
308
|
-
sm: `${BASE / 2}px`,
|
|
309
|
-
md: `${BASE}px`
|
|
310
|
-
};
|
|
311
|
-
const borderStyles = {
|
|
312
|
-
solid: 'solid'
|
|
313
|
-
};
|
|
314
|
-
const borderWidths = {
|
|
315
|
-
sm: '1px',
|
|
316
|
-
md: '3px'
|
|
317
|
-
};
|
|
318
|
-
const borders = {
|
|
319
|
-
sm: `${borderWidths.sm} ${borderStyles.solid}`,
|
|
320
|
-
md: `${borderWidths.md} ${borderStyles.solid}`
|
|
321
|
-
};
|
|
322
|
-
const breakpoints = {
|
|
323
|
-
xs: '0px',
|
|
324
|
-
sm: `${BASE * 144}px`,
|
|
325
|
-
md: `${BASE * 192}px`,
|
|
326
|
-
lg: `${BASE * 248}px`,
|
|
327
|
-
xl: `${BASE * 300}px`
|
|
328
|
-
};
|
|
329
|
-
const colors = {
|
|
330
|
-
primaryHue: 'blue',
|
|
331
|
-
dangerHue: 'red',
|
|
332
|
-
warningHue: 'yellow',
|
|
333
|
-
successHue: 'green',
|
|
334
|
-
neutralHue: 'grey',
|
|
335
|
-
chromeHue: 'kale',
|
|
336
|
-
variables: {
|
|
337
|
-
dark: {
|
|
338
|
-
background: {
|
|
339
|
-
default: 'neutralHue.1100'
|
|
340
|
-
},
|
|
341
|
-
border: {
|
|
342
|
-
default: 'neutralHue.700'
|
|
343
|
-
},
|
|
344
|
-
foreground: {
|
|
345
|
-
default: 'neutralHue.300'
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
light: {
|
|
349
|
-
background: {
|
|
350
|
-
default: 'palette.white'
|
|
351
|
-
},
|
|
352
|
-
border: {
|
|
353
|
-
default: 'neutralHue.400'
|
|
354
|
-
},
|
|
355
|
-
foreground: {
|
|
356
|
-
default: 'neutralHue.900'
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
const fonts = {
|
|
362
|
-
mono: ['SFMono-Regular' , 'Consolas' , '"Liberation Mono"' , 'Menlo', 'Courier', 'monospace'].join(','),
|
|
363
|
-
system: ['system-ui' , '-apple-system' , 'BlinkMacSystemFont' , '"Segoe UI"' , 'Roboto' , 'Oxygen-Sans' , 'Ubuntu' , 'Cantarell' , '"Helvetica Neue"', 'Arial', 'sans-serif'].join(',')
|
|
364
|
-
};
|
|
365
|
-
const fontSizes = {
|
|
366
|
-
xs: '10px',
|
|
367
|
-
sm: '12px',
|
|
368
|
-
md: '14px',
|
|
369
|
-
lg: '18px',
|
|
370
|
-
xl: '22px',
|
|
371
|
-
xxl: '26px',
|
|
372
|
-
xxxl: '36px'
|
|
373
|
-
};
|
|
374
|
-
const fontWeights = {
|
|
375
|
-
thin: 100,
|
|
376
|
-
extralight: 200,
|
|
377
|
-
light: 300,
|
|
378
|
-
regular: 400,
|
|
379
|
-
medium: 500,
|
|
380
|
-
semibold: 600,
|
|
381
|
-
bold: 700,
|
|
382
|
-
extrabold: 800,
|
|
383
|
-
black: 900
|
|
384
|
-
};
|
|
385
|
-
const iconSizes = {
|
|
386
|
-
sm: '12px',
|
|
387
|
-
md: '16px',
|
|
388
|
-
lg: '26px'
|
|
389
|
-
};
|
|
390
|
-
const lineHeights = {
|
|
391
|
-
sm: `${BASE * 4}px`,
|
|
392
|
-
md: `${BASE * 5}px`,
|
|
393
|
-
lg: `${BASE * 6}px`,
|
|
394
|
-
xl: `${BASE * 7}px`,
|
|
395
|
-
xxl: `${BASE * 8}px`,
|
|
396
|
-
xxxl: `${BASE * 11}px`
|
|
397
|
-
};
|
|
398
|
-
const palette = {
|
|
399
|
-
...PALETTE
|
|
400
|
-
};
|
|
401
|
-
delete palette.product;
|
|
402
|
-
const shadowWidths = {
|
|
403
|
-
xs: '1px',
|
|
404
|
-
sm: '2px',
|
|
405
|
-
md: '3px'
|
|
406
|
-
};
|
|
407
|
-
const shadows = {
|
|
408
|
-
xs: color => `0 0 0 ${shadowWidths.xs} ${color}`,
|
|
409
|
-
sm: color => `0 0 0 ${shadowWidths.sm} ${color}`,
|
|
410
|
-
md: color => `0 0 0 ${shadowWidths.md} ${color}`,
|
|
411
|
-
lg: (offsetY, blurRadius, color) => `0 ${offsetY} ${blurRadius} 0 ${color}`
|
|
412
|
-
};
|
|
413
|
-
const space = {
|
|
414
|
-
base: BASE,
|
|
415
|
-
xxs: `${BASE}px`,
|
|
416
|
-
xs: `${BASE * 2}px`,
|
|
417
|
-
sm: `${BASE * 3}px`,
|
|
418
|
-
md: `${BASE * 5}px`,
|
|
419
|
-
lg: `${BASE * 8}px`,
|
|
420
|
-
xl: `${BASE * 10}px`,
|
|
421
|
-
xxl: `${BASE * 12}px`
|
|
422
|
-
};
|
|
423
|
-
const DEFAULT_THEME = {
|
|
424
|
-
borders,
|
|
425
|
-
borderRadii,
|
|
426
|
-
borderStyles,
|
|
427
|
-
borderWidths,
|
|
428
|
-
breakpoints,
|
|
429
|
-
colors: {
|
|
430
|
-
base: 'light',
|
|
431
|
-
...colors
|
|
432
|
-
},
|
|
433
|
-
components: {},
|
|
434
|
-
fonts,
|
|
435
|
-
fontSizes,
|
|
436
|
-
fontWeights,
|
|
437
|
-
iconSizes,
|
|
438
|
-
lineHeights,
|
|
439
|
-
palette,
|
|
440
|
-
rtl: false,
|
|
441
|
-
shadowWidths,
|
|
442
|
-
shadows,
|
|
443
|
-
space
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
const ThemeProvider = _ref => {
|
|
447
|
-
let {
|
|
448
|
-
theme,
|
|
449
|
-
...other
|
|
450
|
-
} = _ref;
|
|
451
|
-
return React.createElement(ThemeProvider$1, _extends({
|
|
452
|
-
theme: theme
|
|
453
|
-
}, other));
|
|
454
|
-
};
|
|
455
|
-
ThemeProvider.defaultProps = {
|
|
456
|
-
theme: DEFAULT_THEME
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
const PALETTE_V8 = {
|
|
460
|
-
black: '#000',
|
|
461
|
-
white: '#fff',
|
|
462
|
-
product: {
|
|
463
|
-
support: '#00a656',
|
|
464
|
-
message: '#37b8af',
|
|
465
|
-
explore: '#30aabc',
|
|
466
|
-
gather: '#f6c8be',
|
|
467
|
-
guide: '#eb4962',
|
|
468
|
-
connect: '#ff6224',
|
|
469
|
-
chat: '#f79a3e',
|
|
470
|
-
talk: '#efc93d',
|
|
471
|
-
sell: '#c38f00'
|
|
472
|
-
},
|
|
473
|
-
grey: {
|
|
474
|
-
100: '#f8f9f9',
|
|
475
|
-
200: '#e9ebed',
|
|
476
|
-
300: '#d8dcde',
|
|
477
|
-
400: '#c2c8cc',
|
|
478
|
-
500: '#87929d',
|
|
479
|
-
600: '#68737d',
|
|
480
|
-
700: '#49545c',
|
|
481
|
-
800: '#2f3941'
|
|
482
|
-
},
|
|
483
|
-
blue: {
|
|
484
|
-
100: '#edf7ff',
|
|
485
|
-
200: '#cee2f2',
|
|
486
|
-
300: '#adcce4',
|
|
487
|
-
400: '#5293c7',
|
|
488
|
-
500: '#337fbd',
|
|
489
|
-
600: '#1f73b7',
|
|
490
|
-
700: '#144a75',
|
|
491
|
-
800: '#0f3554'
|
|
492
|
-
},
|
|
493
|
-
red: {
|
|
494
|
-
100: '#fff0f1',
|
|
495
|
-
200: '#f5d5d8',
|
|
496
|
-
300: '#f5b5ba',
|
|
497
|
-
400: '#e35b66',
|
|
498
|
-
500: '#d93f4c',
|
|
499
|
-
600: '#cc3340',
|
|
500
|
-
700: '#8c232c',
|
|
501
|
-
800: '#681219'
|
|
502
|
-
},
|
|
503
|
-
yellow: {
|
|
504
|
-
100: '#fff7ed',
|
|
505
|
-
200: '#ffeedb',
|
|
506
|
-
300: '#fed6a8',
|
|
507
|
-
400: '#ffb057',
|
|
508
|
-
500: '#f79a3e',
|
|
509
|
-
600: '#ed8f1c',
|
|
510
|
-
700: '#ad5918',
|
|
511
|
-
800: '#703815'
|
|
512
|
-
},
|
|
513
|
-
green: {
|
|
514
|
-
100: '#edf8f4',
|
|
515
|
-
200: '#d1e8df',
|
|
516
|
-
300: '#aecfc2',
|
|
517
|
-
400: '#5eae91',
|
|
518
|
-
500: '#228f67',
|
|
519
|
-
600: '#038153',
|
|
520
|
-
700: '#186146',
|
|
521
|
-
800: '#0b3b29'
|
|
522
|
-
},
|
|
523
|
-
kale: {
|
|
524
|
-
100: '#f5fcfc',
|
|
525
|
-
200: '#daeded',
|
|
526
|
-
300: '#bdd9d7',
|
|
527
|
-
400: '#90bbbb',
|
|
528
|
-
500: '#498283',
|
|
529
|
-
600: '#17494d',
|
|
530
|
-
700: '#03363d',
|
|
531
|
-
800: '#012b30'
|
|
532
|
-
},
|
|
533
|
-
fuschia: {
|
|
534
|
-
400: '#d653c2',
|
|
535
|
-
600: '#a81897',
|
|
536
|
-
M400: '#cf62a8',
|
|
537
|
-
M600: '#a8458c'
|
|
538
|
-
},
|
|
539
|
-
pink: {
|
|
540
|
-
400: '#ec4d63',
|
|
541
|
-
600: '#d42054',
|
|
542
|
-
M400: '#d57287',
|
|
543
|
-
M600: '#b23a5d'
|
|
544
|
-
},
|
|
545
|
-
crimson: {
|
|
546
|
-
400: '#e34f32',
|
|
547
|
-
600: '#c72a1c',
|
|
548
|
-
M400: '#cc6c5b',
|
|
549
|
-
M600: '#b24a3c'
|
|
550
|
-
},
|
|
551
|
-
orange: {
|
|
552
|
-
400: '#de701d',
|
|
553
|
-
600: '#bf5000',
|
|
554
|
-
M400: '#d4772c',
|
|
555
|
-
M600: '#b35827'
|
|
556
|
-
},
|
|
557
|
-
lemon: {
|
|
558
|
-
400: '#ffd424',
|
|
559
|
-
600: '#ffbb10',
|
|
560
|
-
M400: '#e7a500',
|
|
561
|
-
M600: '#c38f00'
|
|
562
|
-
},
|
|
563
|
-
lime: {
|
|
564
|
-
400: '#43b324',
|
|
565
|
-
600: '#2e8200',
|
|
566
|
-
M400: '#519e2d',
|
|
567
|
-
M600: '#47782c'
|
|
568
|
-
},
|
|
569
|
-
mint: {
|
|
570
|
-
400: '#00a656',
|
|
571
|
-
600: '#058541',
|
|
572
|
-
M400: '#299c66',
|
|
573
|
-
M600: '#2e8057'
|
|
574
|
-
},
|
|
575
|
-
teal: {
|
|
576
|
-
400: '#02a191',
|
|
577
|
-
600: '#028079',
|
|
578
|
-
M400: '#2d9e8f',
|
|
579
|
-
M600: '#3c7873'
|
|
580
|
-
},
|
|
581
|
-
azure: {
|
|
582
|
-
400: '#3091ec',
|
|
583
|
-
600: '#1371d6',
|
|
584
|
-
M400: '#5f8dcf',
|
|
585
|
-
M600: '#3a70b2'
|
|
586
|
-
},
|
|
587
|
-
royal: {
|
|
588
|
-
400: '#5d7df5',
|
|
589
|
-
600: '#3353e2',
|
|
590
|
-
M400: '#7986d8',
|
|
591
|
-
M600: '#4b61c3'
|
|
592
|
-
},
|
|
593
|
-
purple: {
|
|
594
|
-
400: '#b552e2',
|
|
595
|
-
600: '#6a27b8',
|
|
596
|
-
M400: '#b072cc',
|
|
597
|
-
M600: '#9358b0'
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
function retrieveComponentStyles(componentId, props) {
|
|
602
|
-
const components = props.theme && props.theme.components;
|
|
603
|
-
if (!components) {
|
|
604
|
-
return undefined;
|
|
605
|
-
}
|
|
606
|
-
const componentStyles = components[componentId];
|
|
607
|
-
if (typeof componentStyles === 'function') {
|
|
608
|
-
return componentStyles(props);
|
|
609
|
-
}
|
|
610
|
-
return componentStyles;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
const POSITION_MAP = {
|
|
614
|
-
top: 'bottom',
|
|
615
|
-
'top-start': 'bottom-left',
|
|
616
|
-
'top-end': 'bottom-right',
|
|
617
|
-
right: 'left',
|
|
618
|
-
'right-start': 'left-top',
|
|
619
|
-
'right-end': 'left-bottom',
|
|
620
|
-
bottom: 'top',
|
|
621
|
-
'bottom-start': 'top-left',
|
|
622
|
-
'bottom-end': 'top-right',
|
|
623
|
-
left: 'right',
|
|
624
|
-
'left-start': 'right-top',
|
|
625
|
-
'left-end': 'right-bottom'
|
|
626
|
-
};
|
|
627
|
-
const RTL_POSITION_MAP = {
|
|
628
|
-
'bottom-left': 'bottom-right',
|
|
629
|
-
'bottom-right': 'bottom-left',
|
|
630
|
-
'top-left': 'top-right',
|
|
631
|
-
'top-right': 'top-left'
|
|
632
|
-
};
|
|
633
|
-
const getArrowPosition = (theme, placement) => {
|
|
634
|
-
let retVal = POSITION_MAP[placement];
|
|
635
|
-
if (theme.rtl) {
|
|
636
|
-
retVal = RTL_POSITION_MAP[retVal] || retVal;
|
|
637
|
-
}
|
|
638
|
-
return retVal;
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
const PALETTE_SIZE = Object.keys(PALETTE.blue).length;
|
|
642
|
-
const adjust$1 = (color, expected, actual) => {
|
|
643
|
-
if (expected !== actual) {
|
|
644
|
-
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
645
|
-
return expected > actual ? darken(amount, color) : lighten(amount, color);
|
|
646
|
-
}
|
|
647
|
-
return color;
|
|
648
|
-
};
|
|
649
|
-
const toShade = (shade, offset, scheme) => {
|
|
650
|
-
let _shade;
|
|
651
|
-
if (shade === undefined) {
|
|
652
|
-
_shade = scheme === 'dark' ? 500 : 700;
|
|
653
|
-
} else {
|
|
654
|
-
_shade = parseInt(shade.toString(), 10);
|
|
655
|
-
if (isNaN(_shade)) {
|
|
656
|
-
throw new TypeError(`Error: unexpected '${typeof shade}' type for color shade "${shade}"`);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return _shade + (offset || 0);
|
|
660
|
-
};
|
|
661
|
-
const toHex = (hue, shade, offset, scheme) => {
|
|
662
|
-
const _shade = toShade(shade, offset, scheme);
|
|
663
|
-
let retVal = hue[_shade];
|
|
664
|
-
if (!retVal) {
|
|
665
|
-
const closestShade = Object.keys(hue).map(hueShade => parseInt(hueShade, 10)).reduce((previous, current) => {
|
|
666
|
-
return Math.abs(current - _shade) < Math.abs(previous - _shade) ? current : previous;
|
|
667
|
-
});
|
|
668
|
-
retVal = adjust$1(hue[closestShade], _shade, closestShade);
|
|
669
|
-
}
|
|
670
|
-
return retVal;
|
|
671
|
-
};
|
|
672
|
-
const toColor = (colors, palette, scheme, hue, shade, offset, transparency) => {
|
|
673
|
-
let retVal;
|
|
674
|
-
let _hue = colors[hue] || hue;
|
|
675
|
-
if (Object.hasOwn(palette, _hue)) {
|
|
676
|
-
_hue = palette[_hue];
|
|
677
|
-
}
|
|
678
|
-
if (typeof _hue === 'object') {
|
|
679
|
-
retVal = toHex(_hue, shade, offset, scheme);
|
|
680
|
-
} else if (valid(_hue)) {
|
|
681
|
-
if (shade === undefined) {
|
|
682
|
-
retVal = _hue;
|
|
683
|
-
} else {
|
|
684
|
-
const _colors = scale([PALETTE.white, _hue, PALETTE.black]).correctLightness().colors(PALETTE_SIZE + 2);
|
|
685
|
-
_hue = _colors.reduce((_retVal, color, index) => {
|
|
686
|
-
if (index > 0 && index <= PALETTE_SIZE) {
|
|
687
|
-
_retVal[index * 100] = color;
|
|
688
|
-
}
|
|
689
|
-
return _retVal;
|
|
690
|
-
}, {});
|
|
691
|
-
retVal = toHex(_hue, shade, offset, scheme);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
if (retVal && transparency) {
|
|
695
|
-
retVal = rgba(retVal, transparency);
|
|
696
|
-
}
|
|
697
|
-
return retVal;
|
|
698
|
-
};
|
|
699
|
-
const toProperty = (object, path) => {
|
|
700
|
-
const retVal = get(object, path);
|
|
701
|
-
if (typeof retVal === 'string') {
|
|
702
|
-
return retVal;
|
|
703
|
-
} else if (retVal === undefined) {
|
|
704
|
-
throw new ReferenceError(`Error: color variable '${path}' is not defined`);
|
|
705
|
-
} else {
|
|
706
|
-
throw new TypeError(`Error: unexpected '${typeof retVal}' type for color variable "${path}"`);
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
const getColor = memoize(_ref => {
|
|
710
|
-
let {
|
|
711
|
-
dark,
|
|
712
|
-
hue,
|
|
713
|
-
light,
|
|
714
|
-
offset,
|
|
715
|
-
shade,
|
|
716
|
-
theme,
|
|
717
|
-
transparency,
|
|
718
|
-
variable
|
|
719
|
-
} = _ref;
|
|
720
|
-
let retVal;
|
|
721
|
-
const palette = theme.palette && Object.keys(theme.palette).length > 0 ? theme.palette : DEFAULT_THEME.palette;
|
|
722
|
-
const {
|
|
723
|
-
base,
|
|
724
|
-
variables,
|
|
725
|
-
...colors
|
|
726
|
-
} = theme.colors && Object.keys(theme.colors).length > 0 ? theme.colors : DEFAULT_THEME.colors;
|
|
727
|
-
const scheme = base === 'dark' ? 'dark' : 'light';
|
|
728
|
-
const mode = scheme === 'dark' ? dark : light;
|
|
729
|
-
let _hue = mode?.hue || hue;
|
|
730
|
-
let _shade = mode?.shade === undefined ? shade : mode.shade;
|
|
731
|
-
const _offset = mode?.offset === undefined ? offset : mode.offset;
|
|
732
|
-
const _transparency = mode?.transparency === undefined ? transparency : mode.transparency;
|
|
733
|
-
if (variable) {
|
|
734
|
-
const _variables = variables?.[scheme] ? variables[scheme] : DEFAULT_THEME.colors.variables[scheme];
|
|
735
|
-
const property = toProperty(_variables, variable);
|
|
736
|
-
const [key, value] = property.split(/\.(?<value>.*)/u);
|
|
737
|
-
if (key === 'palette') {
|
|
738
|
-
_hue = toProperty(palette, value);
|
|
739
|
-
} else {
|
|
740
|
-
_hue = key;
|
|
741
|
-
_shade = parseInt(value, 10);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
if (_hue) {
|
|
745
|
-
retVal = toColor(colors, palette, scheme, _hue, _shade, _offset, _transparency);
|
|
746
|
-
}
|
|
747
|
-
if (retVal === undefined) {
|
|
748
|
-
throw new Error('Error: invalid `getColor` parameters');
|
|
749
|
-
}
|
|
750
|
-
return retVal;
|
|
751
|
-
}, _ref2 => {
|
|
752
|
-
let {
|
|
753
|
-
dark,
|
|
754
|
-
hue,
|
|
755
|
-
light,
|
|
756
|
-
offset,
|
|
757
|
-
shade,
|
|
758
|
-
theme,
|
|
759
|
-
transparency,
|
|
760
|
-
variable
|
|
761
|
-
} = _ref2;
|
|
762
|
-
return JSON.stringify({
|
|
763
|
-
dark,
|
|
764
|
-
hue,
|
|
765
|
-
light,
|
|
766
|
-
offset,
|
|
767
|
-
shade,
|
|
768
|
-
colors: theme.colors,
|
|
769
|
-
palette: theme.palette,
|
|
770
|
-
transparency,
|
|
771
|
-
variable
|
|
772
|
-
});
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
const DEFAULT_SHADE = 600;
|
|
776
|
-
const adjust = (color, expected, actual) => {
|
|
777
|
-
if (expected !== actual) {
|
|
778
|
-
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
779
|
-
return expected > actual ? darken(amount, color) : lighten(amount, color);
|
|
780
|
-
}
|
|
781
|
-
return color;
|
|
782
|
-
};
|
|
783
|
-
const getColorV8 = memoize(function (hue) {
|
|
784
|
-
let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
|
|
785
|
-
let theme = arguments.length > 2 ? arguments[2] : undefined;
|
|
786
|
-
let transparency = arguments.length > 3 ? arguments[3] : undefined;
|
|
787
|
-
let retVal;
|
|
788
|
-
if (isNaN(shade)) {
|
|
789
|
-
return undefined;
|
|
790
|
-
}
|
|
791
|
-
const palette = {
|
|
792
|
-
background: PALETTE_V8.white,
|
|
793
|
-
foreground: PALETTE_V8.grey[800],
|
|
794
|
-
...(theme && theme.palette ? {
|
|
795
|
-
...theme.palette,
|
|
796
|
-
...PALETTE_V8
|
|
797
|
-
} : {
|
|
798
|
-
...DEFAULT_THEME.palette,
|
|
799
|
-
...PALETTE_V8
|
|
800
|
-
})
|
|
801
|
-
};
|
|
802
|
-
const colors = theme && theme.colors ? theme.colors : DEFAULT_THEME.colors;
|
|
803
|
-
let _hue;
|
|
804
|
-
if (typeof hue === 'string') {
|
|
805
|
-
_hue = colors[hue] || hue;
|
|
806
|
-
} else {
|
|
807
|
-
_hue = hue;
|
|
808
|
-
}
|
|
809
|
-
if (Object.prototype.hasOwnProperty.call(palette, _hue)) {
|
|
810
|
-
_hue = palette[_hue];
|
|
811
|
-
}
|
|
812
|
-
if (typeof _hue === 'object') {
|
|
813
|
-
retVal = _hue[shade];
|
|
814
|
-
if (!retVal) {
|
|
815
|
-
const _shade = Object.keys(_hue).map(hueKey => parseInt(hueKey, 10)).reduce((previous, current) => {
|
|
816
|
-
return Math.abs(current - shade) < Math.abs(previous - shade) ? current : previous;
|
|
817
|
-
});
|
|
818
|
-
retVal = adjust(_hue[_shade], shade, _shade);
|
|
819
|
-
}
|
|
820
|
-
} else {
|
|
821
|
-
retVal = adjust(_hue, shade, DEFAULT_SHADE);
|
|
822
|
-
}
|
|
823
|
-
if (transparency) {
|
|
824
|
-
retVal = rgba(retVal, transparency);
|
|
825
|
-
}
|
|
826
|
-
return retVal;
|
|
827
|
-
}, (hue, shade, theme, transparency) => JSON.stringify({
|
|
828
|
-
hue,
|
|
829
|
-
shade,
|
|
830
|
-
palette: theme?.palette,
|
|
831
|
-
colors: theme?.colors,
|
|
832
|
-
transparency
|
|
833
|
-
}));
|
|
834
|
-
|
|
835
|
-
const PLACEMENT_MAP = {
|
|
836
|
-
end: 'right',
|
|
837
|
-
'end-top': 'right-start',
|
|
838
|
-
'end-bottom': 'right-end',
|
|
839
|
-
start: 'left',
|
|
840
|
-
'start-top': 'left-start',
|
|
841
|
-
'start-bottom': 'left-end'
|
|
842
|
-
};
|
|
843
|
-
const RTL_PLACEMENT_MAP = {
|
|
844
|
-
left: 'right',
|
|
845
|
-
'left-start': 'right-start',
|
|
846
|
-
'left-end': 'right-end',
|
|
847
|
-
right: 'left',
|
|
848
|
-
'right-start': 'left-start',
|
|
849
|
-
'right-end': 'left-end'
|
|
850
|
-
};
|
|
851
|
-
const toFloatingPlacement = (placement, theme) => {
|
|
852
|
-
let retVal = PLACEMENT_MAP[placement] || placement;
|
|
853
|
-
if (theme.rtl) {
|
|
854
|
-
retVal = RTL_PLACEMENT_MAP[retVal] || retVal;
|
|
855
|
-
}
|
|
856
|
-
return retVal;
|
|
857
|
-
};
|
|
858
|
-
const SIDE_FALLBACKS_MAP = {
|
|
859
|
-
top: ['top-start', 'top', 'top-end'],
|
|
860
|
-
right: ['right-start', 'right', 'right-end'],
|
|
861
|
-
bottom: ['bottom-start', 'bottom', 'bottom-end'],
|
|
862
|
-
left: ['left-start', 'left', 'left-end']
|
|
863
|
-
};
|
|
864
|
-
const SIDE_OPPOSITE_MAP = {
|
|
865
|
-
top: 'bottom',
|
|
866
|
-
right: 'left',
|
|
867
|
-
bottom: 'top',
|
|
868
|
-
left: 'right'
|
|
869
|
-
};
|
|
870
|
-
const toFallbackPlacements = (primaryPlacement, theme, fallbackPlacements) => {
|
|
871
|
-
if (Array.isArray(fallbackPlacements) && fallbackPlacements.length > 0) {
|
|
872
|
-
return fallbackPlacements.map(fallbackPlacement => toFloatingPlacement(fallbackPlacement, theme));
|
|
873
|
-
}
|
|
874
|
-
const side = primaryPlacement.split('-')[0];
|
|
875
|
-
const sameSideFallbackPlacements = [...SIDE_FALLBACKS_MAP[side]];
|
|
876
|
-
const oppositeSideFallbackPlacements = SIDE_FALLBACKS_MAP[SIDE_OPPOSITE_MAP[side]];
|
|
877
|
-
sameSideFallbackPlacements.splice(sameSideFallbackPlacements.indexOf(primaryPlacement), 1);
|
|
878
|
-
return [...sameSideFallbackPlacements, ...oppositeSideFallbackPlacements];
|
|
879
|
-
};
|
|
880
|
-
const getFloatingPlacements = (theme, placement, fallbackPlacements) => {
|
|
881
|
-
const floatingPlacement = toFloatingPlacement(placement, theme);
|
|
882
|
-
const floatingFallbackPlacements = toFallbackPlacements(floatingPlacement, theme, fallbackPlacements);
|
|
883
|
-
return [floatingPlacement, floatingFallbackPlacements];
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
const getFocusBoxShadow = _ref => {
|
|
887
|
-
let {
|
|
888
|
-
boxShadow,
|
|
889
|
-
inset = false,
|
|
890
|
-
hue = 'primaryHue',
|
|
891
|
-
shade = DEFAULT_SHADE,
|
|
892
|
-
shadowWidth = 'md',
|
|
893
|
-
spacerHue = 'background',
|
|
894
|
-
spacerShade = DEFAULT_SHADE,
|
|
895
|
-
spacerWidth = 'xs',
|
|
896
|
-
theme = DEFAULT_THEME
|
|
897
|
-
} = _ref;
|
|
898
|
-
const color = getColorV8(hue, shade, theme);
|
|
899
|
-
const shadow = theme.shadows[shadowWidth](color);
|
|
900
|
-
if (spacerWidth === null) {
|
|
901
|
-
return `${inset ? 'inset' : ''} ${shadow}`;
|
|
902
|
-
}
|
|
903
|
-
const spacerColor = getColorV8(spacerHue, spacerShade, theme);
|
|
904
|
-
const retVal = `
|
|
905
|
-
${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](spacerColor)},
|
|
906
|
-
${inset ? 'inset' : ''} ${shadow}`;
|
|
907
|
-
return boxShadow ? `${retVal}, ${boxShadow}` : retVal;
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
function getLineHeight(height, fontSize) {
|
|
911
|
-
const [heightValue, heightUnit] = getValueAndUnit(height.toString());
|
|
912
|
-
const [fontSizeValue, fontSizeUnit] = getValueAndUnit(fontSize.toString());
|
|
913
|
-
const PIXELS = 'px';
|
|
914
|
-
if (heightUnit && heightUnit !== PIXELS) {
|
|
915
|
-
throw new Error(`Unexpected \`height\` with '${heightUnit}' units.`);
|
|
916
|
-
}
|
|
917
|
-
if (fontSizeUnit && fontSizeUnit !== PIXELS) {
|
|
918
|
-
throw new Error(`Unexpected \`fontSize\` with '${fontSizeUnit}' units.`);
|
|
919
|
-
}
|
|
920
|
-
return heightValue / fontSizeValue;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
const getMenuPosition = placement => {
|
|
924
|
-
return placement.split('-')[0];
|
|
925
|
-
};
|
|
926
|
-
|
|
927
|
-
const maxWidth = (breakpoints, breakpoint) => {
|
|
928
|
-
const keys = Object.keys(breakpoints);
|
|
929
|
-
const index = keys.indexOf(breakpoint) + 1;
|
|
930
|
-
if (keys[index]) {
|
|
931
|
-
const dimension = getValueAndUnit(breakpoints[keys[index]]);
|
|
932
|
-
const value = dimension[0] - 0.02;
|
|
933
|
-
const unit = dimension[1];
|
|
934
|
-
return `${value}${unit}`;
|
|
935
|
-
}
|
|
936
|
-
return undefined;
|
|
937
|
-
};
|
|
938
|
-
function mediaQuery(query, breakpoint, theme) {
|
|
939
|
-
let retVal;
|
|
940
|
-
let min;
|
|
941
|
-
let max;
|
|
942
|
-
const breakpoints = theme && theme.breakpoints ? theme.breakpoints : DEFAULT_THEME.breakpoints;
|
|
943
|
-
if (typeof breakpoint === 'string') {
|
|
944
|
-
if (query === 'up') {
|
|
945
|
-
min = breakpoints[breakpoint];
|
|
946
|
-
} else if (query === 'down') {
|
|
947
|
-
if (breakpoint === 'xl') {
|
|
948
|
-
min = DEFAULT_THEME.breakpoints.xs;
|
|
949
|
-
} else {
|
|
950
|
-
max = maxWidth(breakpoints, breakpoint);
|
|
951
|
-
}
|
|
952
|
-
} else if (query === 'only') {
|
|
953
|
-
min = breakpoints[breakpoint];
|
|
954
|
-
max = maxWidth(breakpoints, breakpoint);
|
|
955
|
-
}
|
|
956
|
-
} else if (query === 'between') {
|
|
957
|
-
min = breakpoints[breakpoint[0]];
|
|
958
|
-
max = maxWidth(breakpoints, breakpoint[1]);
|
|
959
|
-
}
|
|
960
|
-
if (min) {
|
|
961
|
-
retVal = `@media (min-width: ${min})`;
|
|
962
|
-
if (max) {
|
|
963
|
-
retVal = `${retVal} and (max-width: ${max})`;
|
|
964
|
-
}
|
|
965
|
-
} else if (max) {
|
|
966
|
-
retVal = `@media (max-width: ${max})`;
|
|
967
|
-
} else {
|
|
968
|
-
throw new Error(`Unexpected query and breakpoint combination: '${query}', '${breakpoint}'.`);
|
|
969
|
-
}
|
|
970
|
-
return retVal;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
const exponentialSymbols = {
|
|
974
|
-
symbols: {
|
|
975
|
-
sqrt: {
|
|
976
|
-
func: {
|
|
977
|
-
symbol: 'sqrt',
|
|
978
|
-
f: a => Math.sqrt(a),
|
|
979
|
-
notation: 'func',
|
|
980
|
-
precedence: 0,
|
|
981
|
-
rightToLeft: 0,
|
|
982
|
-
argCount: 1
|
|
983
|
-
},
|
|
984
|
-
symbol: 'sqrt',
|
|
985
|
-
regSymbol: 'sqrt\\b'
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
};
|
|
989
|
-
const animationStyles$1 = (position, modifier) => {
|
|
990
|
-
const property = position.split('-')[0];
|
|
991
|
-
const animationName = keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
992
|
-
return css(["&", "::before,&", "::after{animation:0.3s ease-in-out ", ";}"], modifier, modifier, animationName);
|
|
993
|
-
};
|
|
994
|
-
const positionStyles = (position, size, inset) => {
|
|
995
|
-
const margin = math(`${size} / -2`);
|
|
996
|
-
const placement = math(`${margin} + ${inset}`);
|
|
997
|
-
let clipPath;
|
|
998
|
-
let positionCss;
|
|
999
|
-
let propertyRadius;
|
|
1000
|
-
if (position.startsWith('top')) {
|
|
1001
|
-
propertyRadius = 'border-bottom-right-radius';
|
|
1002
|
-
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
1003
|
-
positionCss = css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
|
|
1004
|
-
} else if (position.startsWith('right')) {
|
|
1005
|
-
propertyRadius = 'border-bottom-left-radius';
|
|
1006
|
-
clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
|
|
1007
|
-
positionCss = css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
|
|
1008
|
-
} else if (position.startsWith('bottom')) {
|
|
1009
|
-
propertyRadius = 'border-top-left-radius';
|
|
1010
|
-
clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
|
|
1011
|
-
positionCss = css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
|
|
1012
|
-
} else if (position.startsWith('left')) {
|
|
1013
|
-
propertyRadius = 'border-top-right-radius';
|
|
1014
|
-
clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
|
|
1015
|
-
positionCss = css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
|
|
1016
|
-
}
|
|
1017
|
-
return css(["&::before{", ":100%;clip-path:", ";}&::before,&::after{", "}"], propertyRadius, clipPath, positionCss);
|
|
1018
|
-
};
|
|
1019
|
-
function arrowStyles(position) {
|
|
1020
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1021
|
-
const size = options.size || '6px';
|
|
1022
|
-
const inset = options.inset || '0';
|
|
1023
|
-
const squareSize = math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
|
|
1024
|
-
return 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));
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
const useDocument = theme => {
|
|
1028
|
-
const [controlledDocument, setControlledDocument] = useState();
|
|
1029
|
-
useEffect(() => {
|
|
1030
|
-
if (theme && theme.document) {
|
|
1031
|
-
setControlledDocument(theme.document);
|
|
1032
|
-
} else {
|
|
1033
|
-
setControlledDocument(document);
|
|
1034
|
-
}
|
|
1035
|
-
}, [theme]);
|
|
1036
|
-
return controlledDocument;
|
|
1037
|
-
};
|
|
1038
|
-
|
|
1039
|
-
const useWindow = theme => {
|
|
1040
|
-
const [controlledWindow, setControlledWindow] = useState();
|
|
1041
|
-
useEffect(() => {
|
|
1042
|
-
if (theme && theme.window) {
|
|
1043
|
-
setControlledWindow(theme.window);
|
|
1044
|
-
} else {
|
|
1045
|
-
setControlledWindow(window);
|
|
1046
|
-
}
|
|
1047
|
-
}, [theme]);
|
|
1048
|
-
return controlledWindow;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
const useText = function (component, props, name, text) {
|
|
1052
|
-
let condition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1053
|
-
const value = condition ? props[name] : undefined;
|
|
1054
|
-
return useMemo(() => {
|
|
1055
|
-
if (condition) {
|
|
1056
|
-
if (name === 'children') {
|
|
1057
|
-
throw new Error('Error: `children` is not a valid `useText` prop.');
|
|
1058
|
-
} else if (value === null || value === '') {
|
|
1059
|
-
throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
|
|
1060
|
-
} else if (value === undefined) {
|
|
1061
|
-
if (process.env.NODE_ENV === 'development') {
|
|
1062
|
-
console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
|
|
1063
|
-
}
|
|
1064
|
-
return text;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
return value;
|
|
1068
|
-
}, [component.displayName, value, name, text, condition]);
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
const animationStyles = (position, options) => {
|
|
1072
|
-
const theme = options.theme || DEFAULT_THEME;
|
|
1073
|
-
let translateValue = `${theme.space.base * 5}px`;
|
|
1074
|
-
let transformFunction;
|
|
1075
|
-
if (position === 'top') {
|
|
1076
|
-
transformFunction = 'translateY';
|
|
1077
|
-
} else if (position === 'right') {
|
|
1078
|
-
transformFunction = 'translateX';
|
|
1079
|
-
translateValue = `-${translateValue}`;
|
|
1080
|
-
} else if (position === 'bottom') {
|
|
1081
|
-
transformFunction = 'translateY';
|
|
1082
|
-
translateValue = `-${translateValue}`;
|
|
1083
|
-
} else {
|
|
1084
|
-
transformFunction = 'translateX';
|
|
1085
|
-
}
|
|
1086
|
-
const animationName = keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
1087
|
-
return css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
1088
|
-
};
|
|
1089
|
-
const hiddenStyles = options => {
|
|
1090
|
-
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
1091
|
-
return css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
1092
|
-
};
|
|
1093
|
-
function menuStyles(position) {
|
|
1094
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1095
|
-
const theme = options.theme || DEFAULT_THEME;
|
|
1096
|
-
let marginProperty;
|
|
1097
|
-
if (position === 'top') {
|
|
1098
|
-
marginProperty = 'margin-bottom';
|
|
1099
|
-
} else if (position === 'right') {
|
|
1100
|
-
marginProperty = 'margin-left';
|
|
1101
|
-
} else if (position === 'bottom') {
|
|
1102
|
-
marginProperty = 'margin-top';
|
|
1103
|
-
} else {
|
|
1104
|
-
marginProperty = 'margin-right';
|
|
1105
|
-
}
|
|
1106
|
-
return 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;font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColorV8('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColorV8('chromeHue', 600, theme, 0.15)), getColorV8('background', 600 , theme), theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
const SELECTOR_FOCUS_VISIBLE = '&:focus-visible';
|
|
1110
|
-
const focusStyles = _ref => {
|
|
1111
|
-
let {
|
|
1112
|
-
condition = true,
|
|
1113
|
-
selector = SELECTOR_FOCUS_VISIBLE,
|
|
1114
|
-
shadowWidth = 'md',
|
|
1115
|
-
spacerWidth = 'xs',
|
|
1116
|
-
styles: {
|
|
1117
|
-
boxShadow,
|
|
1118
|
-
...styles
|
|
1119
|
-
} = {},
|
|
1120
|
-
theme,
|
|
1121
|
-
...options
|
|
1122
|
-
} = _ref;
|
|
1123
|
-
const _boxShadow = condition ? getFocusBoxShadow({
|
|
1124
|
-
boxShadow,
|
|
1125
|
-
shadowWidth,
|
|
1126
|
-
spacerWidth,
|
|
1127
|
-
theme,
|
|
1128
|
-
...options
|
|
1129
|
-
}) : boxShadow;
|
|
1130
|
-
let outline;
|
|
1131
|
-
let outlineOffset;
|
|
1132
|
-
if (spacerWidth === null) {
|
|
1133
|
-
outline = theme.shadowWidths[shadowWidth];
|
|
1134
|
-
} else {
|
|
1135
|
-
outline = `${math(`${theme.shadowWidths[shadowWidth]} - ${theme.shadowWidths[spacerWidth]}`)} solid transparent`;
|
|
1136
|
-
outlineOffset = theme.shadowWidths[spacerWidth];
|
|
1137
|
-
}
|
|
1138
|
-
return css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, _boxShadow, styles);
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
1142
|
-
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
1143
|
-
const PLACEMENT = ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
1144
|
-
|
|
1145
|
-
export { ARROW_POSITION, DEFAULT_THEME, MENU_POSITION, PALETTE, PALETTE_V8, PLACEMENT, SELECTOR_FOCUS_VISIBLE, ThemeProvider, arrowStyles, focusStyles, getArrowPosition, getColor, getColorV8, getFloatingPlacements, getFocusBoxShadow, getLineHeight, getMenuPosition, mediaQuery, menuStyles, retrieveComponentStyles, useDocument, useText, useWindow };
|