@zendeskgarden/react-theming 8.57.1 → 8.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +153 -325
- package/dist/index.esm.js +153 -325
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -19,170 +19,22 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
|
|
20
20
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
21
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) {
|
|
23
|
-
var keys = Object.keys(object);
|
|
24
|
-
|
|
25
|
-
if (Object.getOwnPropertySymbols) {
|
|
26
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
27
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
28
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
29
|
-
})), keys.push.apply(keys, symbols);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return keys;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _objectSpread2(target) {
|
|
36
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
37
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
38
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
39
|
-
_defineProperty(target, key, source[key]);
|
|
40
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
41
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return target;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _typeof(obj) {
|
|
49
|
-
"@babel/helpers - typeof";
|
|
50
|
-
|
|
51
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
52
|
-
return typeof obj;
|
|
53
|
-
} : function (obj) {
|
|
54
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
55
|
-
}, _typeof(obj);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _defineProperty(obj, key, value) {
|
|
59
|
-
if (key in obj) {
|
|
60
|
-
Object.defineProperty(obj, key, {
|
|
61
|
-
value: value,
|
|
62
|
-
enumerable: true,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true
|
|
65
|
-
});
|
|
66
|
-
} else {
|
|
67
|
-
obj[key] = value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return obj;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
22
|
function _extends() {
|
|
74
23
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
75
24
|
for (var i = 1; i < arguments.length; i++) {
|
|
76
25
|
var source = arguments[i];
|
|
77
|
-
|
|
78
26
|
for (var key in source) {
|
|
79
27
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
80
28
|
target[key] = source[key];
|
|
81
29
|
}
|
|
82
30
|
}
|
|
83
31
|
}
|
|
84
|
-
|
|
85
32
|
return target;
|
|
86
33
|
};
|
|
87
34
|
return _extends.apply(this, arguments);
|
|
88
35
|
}
|
|
89
36
|
|
|
90
|
-
|
|
91
|
-
if (source == null) return {};
|
|
92
|
-
var target = {};
|
|
93
|
-
var sourceKeys = Object.keys(source);
|
|
94
|
-
var key, i;
|
|
95
|
-
|
|
96
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
97
|
-
key = sourceKeys[i];
|
|
98
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
99
|
-
target[key] = source[key];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return target;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function _objectWithoutProperties(source, excluded) {
|
|
106
|
-
if (source == null) return {};
|
|
107
|
-
|
|
108
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
109
|
-
|
|
110
|
-
var key, i;
|
|
111
|
-
|
|
112
|
-
if (Object.getOwnPropertySymbols) {
|
|
113
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
114
|
-
|
|
115
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
116
|
-
key = sourceSymbolKeys[i];
|
|
117
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
118
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
119
|
-
target[key] = source[key];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return target;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function _slicedToArray(arr, i) {
|
|
127
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function _arrayWithHoles(arr) {
|
|
131
|
-
if (Array.isArray(arr)) return arr;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function _iterableToArrayLimit(arr, i) {
|
|
135
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
136
|
-
|
|
137
|
-
if (_i == null) return;
|
|
138
|
-
var _arr = [];
|
|
139
|
-
var _n = true;
|
|
140
|
-
var _d = false;
|
|
141
|
-
|
|
142
|
-
var _s, _e;
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
146
|
-
_arr.push(_s.value);
|
|
147
|
-
|
|
148
|
-
if (i && _arr.length === i) break;
|
|
149
|
-
}
|
|
150
|
-
} catch (err) {
|
|
151
|
-
_d = true;
|
|
152
|
-
_e = err;
|
|
153
|
-
} finally {
|
|
154
|
-
try {
|
|
155
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
156
|
-
} finally {
|
|
157
|
-
if (_d) throw _e;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return _arr;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
165
|
-
if (!o) return;
|
|
166
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
167
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
168
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
169
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
170
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function _arrayLikeToArray(arr, len) {
|
|
174
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
175
|
-
|
|
176
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
177
|
-
|
|
178
|
-
return arr2;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function _nonIterableRest() {
|
|
182
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
var PALETTE = {
|
|
37
|
+
const PALETTE = {
|
|
186
38
|
black: '#000',
|
|
187
39
|
white: '#fff',
|
|
188
40
|
product: {
|
|
@@ -324,30 +176,30 @@ var PALETTE = {
|
|
|
324
176
|
}
|
|
325
177
|
};
|
|
326
178
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
sm:
|
|
330
|
-
md:
|
|
179
|
+
const BASE = 4;
|
|
180
|
+
const borderRadii = {
|
|
181
|
+
sm: `${BASE / 2}px`,
|
|
182
|
+
md: `${BASE}px`
|
|
331
183
|
};
|
|
332
|
-
|
|
184
|
+
const borderStyles = {
|
|
333
185
|
solid: 'solid'
|
|
334
186
|
};
|
|
335
|
-
|
|
187
|
+
const borderWidths = {
|
|
336
188
|
sm: '1px',
|
|
337
189
|
md: '3px'
|
|
338
190
|
};
|
|
339
|
-
|
|
340
|
-
sm:
|
|
341
|
-
md:
|
|
191
|
+
const borders = {
|
|
192
|
+
sm: `${borderWidths.sm} ${borderStyles.solid}`,
|
|
193
|
+
md: `${borderWidths.md} ${borderStyles.solid}`
|
|
342
194
|
};
|
|
343
|
-
|
|
195
|
+
const breakpoints = {
|
|
344
196
|
xs: '0px',
|
|
345
|
-
sm:
|
|
346
|
-
md:
|
|
347
|
-
lg:
|
|
348
|
-
xl:
|
|
197
|
+
sm: `${BASE * 144}px`,
|
|
198
|
+
md: `${BASE * 192}px`,
|
|
199
|
+
lg: `${BASE * 248}px`,
|
|
200
|
+
xl: `${BASE * 300}px`
|
|
349
201
|
};
|
|
350
|
-
|
|
202
|
+
const colors = {
|
|
351
203
|
background: PALETTE.white,
|
|
352
204
|
foreground: PALETTE.grey[800],
|
|
353
205
|
primaryHue: 'blue',
|
|
@@ -357,22 +209,11 @@ var colors = {
|
|
|
357
209
|
neutralHue: 'grey',
|
|
358
210
|
chromeHue: 'kale'
|
|
359
211
|
};
|
|
360
|
-
|
|
361
|
-
mono: ['SFMono-Regular'
|
|
362
|
-
, '
|
|
363
|
-
, '"Liberation Mono"'
|
|
364
|
-
, 'Menlo', 'Courier', 'monospace'].join(','),
|
|
365
|
-
system: ['system-ui'
|
|
366
|
-
, '-apple-system'
|
|
367
|
-
, 'BlinkMacSystemFont'
|
|
368
|
-
, '"Segoe UI"'
|
|
369
|
-
, 'Roboto'
|
|
370
|
-
, 'Oxygen-Sans'
|
|
371
|
-
, 'Ubuntu'
|
|
372
|
-
, 'Cantarell'
|
|
373
|
-
, '"Helvetica Neue"', 'Arial', 'sans-serif'].join(',')
|
|
212
|
+
const fonts = {
|
|
213
|
+
mono: ['SFMono-Regular' , 'Consolas' , '"Liberation Mono"' , 'Menlo', 'Courier', 'monospace'].join(','),
|
|
214
|
+
system: ['system-ui' , '-apple-system' , 'BlinkMacSystemFont' , '"Segoe UI"' , 'Roboto' , 'Oxygen-Sans' , 'Ubuntu' , 'Cantarell' , '"Helvetica Neue"', 'Arial', 'sans-serif'].join(',')
|
|
374
215
|
};
|
|
375
|
-
|
|
216
|
+
const fontSizes = {
|
|
376
217
|
xs: '10px',
|
|
377
218
|
sm: '12px',
|
|
378
219
|
md: '14px',
|
|
@@ -381,7 +222,7 @@ var fontSizes = {
|
|
|
381
222
|
xxl: '26px',
|
|
382
223
|
xxxl: '36px'
|
|
383
224
|
};
|
|
384
|
-
|
|
225
|
+
const fontWeights = {
|
|
385
226
|
thin: 100,
|
|
386
227
|
extralight: 200,
|
|
387
228
|
light: 300,
|
|
@@ -392,74 +233,68 @@ var fontWeights = {
|
|
|
392
233
|
extrabold: 800,
|
|
393
234
|
black: 900
|
|
394
235
|
};
|
|
395
|
-
|
|
236
|
+
const iconSizes = {
|
|
396
237
|
sm: '12px',
|
|
397
238
|
md: '16px',
|
|
398
239
|
lg: '26px'
|
|
399
240
|
};
|
|
400
|
-
|
|
401
|
-
sm:
|
|
402
|
-
md:
|
|
403
|
-
lg:
|
|
404
|
-
xl:
|
|
405
|
-
xxl:
|
|
406
|
-
xxxl:
|
|
241
|
+
const lineHeights = {
|
|
242
|
+
sm: `${BASE * 4}px`,
|
|
243
|
+
md: `${BASE * 5}px`,
|
|
244
|
+
lg: `${BASE * 6}px`,
|
|
245
|
+
xl: `${BASE * 7}px`,
|
|
246
|
+
xxl: `${BASE * 8}px`,
|
|
247
|
+
xxxl: `${BASE * 11}px`
|
|
248
|
+
};
|
|
249
|
+
const palette = {
|
|
250
|
+
...PALETTE
|
|
407
251
|
};
|
|
408
|
-
var palette = _objectSpread2({}, PALETTE);
|
|
409
252
|
delete palette.product;
|
|
410
|
-
|
|
253
|
+
const shadowWidths = {
|
|
411
254
|
sm: '2px',
|
|
412
255
|
md: '3px'
|
|
413
256
|
};
|
|
414
|
-
|
|
415
|
-
sm:
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
md: function md(color) {
|
|
419
|
-
return "0 0 0 ".concat(shadowWidths.md, " ").concat(color);
|
|
420
|
-
},
|
|
421
|
-
lg: function lg(offsetY, blurRadius, color) {
|
|
422
|
-
return "0 ".concat(offsetY, " ").concat(blurRadius, " 0 ").concat(color);
|
|
423
|
-
}
|
|
257
|
+
const shadows = {
|
|
258
|
+
sm: color => `0 0 0 ${shadowWidths.sm} ${color}`,
|
|
259
|
+
md: color => `0 0 0 ${shadowWidths.md} ${color}`,
|
|
260
|
+
lg: (offsetY, blurRadius, color) => `0 ${offsetY} ${blurRadius} 0 ${color}`
|
|
424
261
|
};
|
|
425
|
-
|
|
262
|
+
const space = {
|
|
426
263
|
base: BASE,
|
|
427
|
-
xxs:
|
|
428
|
-
xs:
|
|
429
|
-
sm:
|
|
430
|
-
md:
|
|
431
|
-
lg:
|
|
432
|
-
xl:
|
|
433
|
-
xxl:
|
|
264
|
+
xxs: `${BASE}px`,
|
|
265
|
+
xs: `${BASE * 2}px`,
|
|
266
|
+
sm: `${BASE * 3}px`,
|
|
267
|
+
md: `${BASE * 5}px`,
|
|
268
|
+
lg: `${BASE * 8}px`,
|
|
269
|
+
xl: `${BASE * 10}px`,
|
|
270
|
+
xxl: `${BASE * 12}px`
|
|
434
271
|
};
|
|
435
|
-
|
|
436
|
-
borders
|
|
437
|
-
borderRadii
|
|
438
|
-
borderStyles
|
|
439
|
-
borderWidths
|
|
440
|
-
breakpoints
|
|
441
|
-
colors:
|
|
442
|
-
base: 'light'
|
|
443
|
-
|
|
272
|
+
const DEFAULT_THEME = {
|
|
273
|
+
borders,
|
|
274
|
+
borderRadii,
|
|
275
|
+
borderStyles,
|
|
276
|
+
borderWidths,
|
|
277
|
+
breakpoints,
|
|
278
|
+
colors: {
|
|
279
|
+
base: 'light',
|
|
280
|
+
...colors
|
|
281
|
+
},
|
|
444
282
|
components: {},
|
|
445
|
-
fonts
|
|
446
|
-
fontSizes
|
|
447
|
-
fontWeights
|
|
448
|
-
iconSizes
|
|
449
|
-
lineHeights
|
|
450
|
-
palette
|
|
283
|
+
fonts,
|
|
284
|
+
fontSizes,
|
|
285
|
+
fontWeights,
|
|
286
|
+
iconSizes,
|
|
287
|
+
lineHeights,
|
|
288
|
+
palette,
|
|
451
289
|
rtl: false,
|
|
452
|
-
shadowWidths
|
|
453
|
-
shadows
|
|
454
|
-
space
|
|
290
|
+
shadowWidths,
|
|
291
|
+
shadows,
|
|
292
|
+
space
|
|
455
293
|
};
|
|
456
294
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
controlledDocument = _useState2[0],
|
|
461
|
-
setControlledDocument = _useState2[1];
|
|
462
|
-
React.useEffect(function () {
|
|
295
|
+
const useDocument = theme => {
|
|
296
|
+
const [controlledDocument, setControlledDocument] = React.useState();
|
|
297
|
+
React.useEffect(() => {
|
|
463
298
|
if (theme && theme.document) {
|
|
464
299
|
setControlledDocument(theme.document);
|
|
465
300
|
} else {
|
|
@@ -469,18 +304,19 @@ var useDocument = function useDocument(theme) {
|
|
|
469
304
|
return controlledDocument;
|
|
470
305
|
};
|
|
471
306
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
307
|
+
const ThemeProvider = _ref => {
|
|
308
|
+
let {
|
|
309
|
+
theme,
|
|
310
|
+
focusVisibleRef,
|
|
311
|
+
children,
|
|
312
|
+
...other
|
|
313
|
+
} = _ref;
|
|
314
|
+
const scopeRef = React.useRef(null);
|
|
315
|
+
const relativeDocument = useDocument(theme);
|
|
316
|
+
const controlledScopeRef = focusVisibleRef === null ? React__default["default"].createRef() : containerUtilities.getControlledValue(focusVisibleRef, scopeRef);
|
|
481
317
|
containerFocusvisible.useFocusVisible({
|
|
482
318
|
scope: controlledScopeRef,
|
|
483
|
-
relativeDocument
|
|
319
|
+
relativeDocument
|
|
484
320
|
});
|
|
485
321
|
return React__default["default"].createElement(styledComponents.ThemeProvider, _extends({
|
|
486
322
|
theme: theme
|
|
@@ -493,17 +329,18 @@ ThemeProvider.defaultProps = {
|
|
|
493
329
|
};
|
|
494
330
|
|
|
495
331
|
function isRtl() {
|
|
496
|
-
|
|
497
|
-
|
|
332
|
+
let {
|
|
333
|
+
theme
|
|
334
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
498
335
|
return Boolean(theme && theme.rtl);
|
|
499
336
|
}
|
|
500
337
|
|
|
501
338
|
function retrieveComponentStyles(componentId, props) {
|
|
502
|
-
|
|
339
|
+
const components = props.theme && props.theme.components;
|
|
503
340
|
if (!components) {
|
|
504
341
|
return undefined;
|
|
505
342
|
}
|
|
506
|
-
|
|
343
|
+
const componentStyles = components[componentId];
|
|
507
344
|
if (typeof componentStyles === 'function') {
|
|
508
345
|
return componentStyles(props);
|
|
509
346
|
}
|
|
@@ -515,30 +352,31 @@ function withTheme(WrappedComponent) {
|
|
|
515
352
|
}
|
|
516
353
|
|
|
517
354
|
function getDocument() {
|
|
518
|
-
|
|
519
|
-
|
|
355
|
+
let {
|
|
356
|
+
theme
|
|
357
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
520
358
|
return theme && theme.document || document;
|
|
521
359
|
}
|
|
522
360
|
|
|
523
|
-
|
|
524
|
-
|
|
361
|
+
const DEFAULT_SHADE = 600;
|
|
362
|
+
const adjust = (color, expected, actual) => {
|
|
525
363
|
if (expected !== actual) {
|
|
526
|
-
|
|
364
|
+
const amount = Math.abs(expected - actual) / 100 * 0.05;
|
|
527
365
|
return expected > actual ? polished.darken(amount, color) : polished.lighten(amount, color);
|
|
528
366
|
}
|
|
529
367
|
return color;
|
|
530
368
|
};
|
|
531
369
|
function getColor(hue) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
370
|
+
let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
|
|
371
|
+
let theme = arguments.length > 2 ? arguments[2] : undefined;
|
|
372
|
+
let transparency = arguments.length > 3 ? arguments[3] : undefined;
|
|
373
|
+
let retVal;
|
|
536
374
|
if (isNaN(shade)) {
|
|
537
375
|
return undefined;
|
|
538
376
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
377
|
+
const palette = theme && theme.palette ? theme.palette : DEFAULT_THEME.palette;
|
|
378
|
+
const colors = theme && theme.colors ? theme.colors : DEFAULT_THEME.colors;
|
|
379
|
+
let _hue;
|
|
542
380
|
if (typeof hue === 'string') {
|
|
543
381
|
_hue = colors[hue] || hue;
|
|
544
382
|
} else {
|
|
@@ -547,12 +385,10 @@ function getColor(hue) {
|
|
|
547
385
|
if (Object.prototype.hasOwnProperty.call(palette, _hue)) {
|
|
548
386
|
_hue = palette[_hue];
|
|
549
387
|
}
|
|
550
|
-
if (
|
|
388
|
+
if (typeof _hue === 'object') {
|
|
551
389
|
retVal = _hue[shade];
|
|
552
390
|
if (!retVal) {
|
|
553
|
-
|
|
554
|
-
return parseInt(hueKey, 10);
|
|
555
|
-
}).reduce(function (previous, current) {
|
|
391
|
+
const _shade = Object.keys(_hue).map(hueKey => parseInt(hueKey, 10)).reduce((previous, current) => {
|
|
556
392
|
return Math.abs(current - shade) < Math.abs(previous - shade) ? current : previous;
|
|
557
393
|
});
|
|
558
394
|
retVal = adjust(_hue[_shade], shade, _shade);
|
|
@@ -567,40 +403,34 @@ function getColor(hue) {
|
|
|
567
403
|
}
|
|
568
404
|
|
|
569
405
|
function getLineHeight(height, fontSize) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
heightUnit = _getValueAndUnit2[1];
|
|
574
|
-
var _getValueAndUnit3 = polished.getValueAndUnit(fontSize.toString()),
|
|
575
|
-
_getValueAndUnit4 = _slicedToArray(_getValueAndUnit3, 2),
|
|
576
|
-
fontSizeValue = _getValueAndUnit4[0],
|
|
577
|
-
fontSizeUnit = _getValueAndUnit4[1];
|
|
578
|
-
var PIXELS = 'px';
|
|
406
|
+
const [heightValue, heightUnit] = polished.getValueAndUnit(height.toString());
|
|
407
|
+
const [fontSizeValue, fontSizeUnit] = polished.getValueAndUnit(fontSize.toString());
|
|
408
|
+
const PIXELS = 'px';
|
|
579
409
|
if (heightUnit && heightUnit !== PIXELS) {
|
|
580
|
-
throw new Error(
|
|
410
|
+
throw new Error(`Unexpected \`height\` with '${heightUnit}' units.`);
|
|
581
411
|
}
|
|
582
412
|
if (fontSizeUnit && fontSizeUnit !== PIXELS) {
|
|
583
|
-
throw new Error(
|
|
413
|
+
throw new Error(`Unexpected \`fontSize\` with '${fontSizeUnit}' units.`);
|
|
584
414
|
}
|
|
585
415
|
return heightValue / fontSizeValue;
|
|
586
416
|
}
|
|
587
417
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
418
|
+
const maxWidth = (breakpoints, breakpoint) => {
|
|
419
|
+
const keys = Object.keys(breakpoints);
|
|
420
|
+
const index = keys.indexOf(breakpoint) + 1;
|
|
591
421
|
if (keys[index]) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
return
|
|
422
|
+
const dimension = polished.getValueAndUnit(breakpoints[keys[index]]);
|
|
423
|
+
const value = dimension[0] - 0.02;
|
|
424
|
+
const unit = dimension[1];
|
|
425
|
+
return `${value}${unit}`;
|
|
596
426
|
}
|
|
597
427
|
return undefined;
|
|
598
428
|
};
|
|
599
429
|
function mediaQuery(query, breakpoint, theme) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
430
|
+
let retVal;
|
|
431
|
+
let min;
|
|
432
|
+
let max;
|
|
433
|
+
const breakpoints = theme && theme.breakpoints ? theme.breakpoints : DEFAULT_THEME.breakpoints;
|
|
604
434
|
if (typeof breakpoint === 'string') {
|
|
605
435
|
if (query === 'up') {
|
|
606
436
|
min = breakpoints[breakpoint];
|
|
@@ -619,26 +449,24 @@ function mediaQuery(query, breakpoint, theme) {
|
|
|
619
449
|
max = maxWidth(breakpoints, breakpoint[1]);
|
|
620
450
|
}
|
|
621
451
|
if (min) {
|
|
622
|
-
retVal =
|
|
452
|
+
retVal = `@media (min-width: ${min})`;
|
|
623
453
|
if (max) {
|
|
624
|
-
retVal =
|
|
454
|
+
retVal = `${retVal} and (max-width: ${max})`;
|
|
625
455
|
}
|
|
626
456
|
} else if (max) {
|
|
627
|
-
retVal =
|
|
457
|
+
retVal = `@media (max-width: ${max})`;
|
|
628
458
|
} else {
|
|
629
|
-
throw new Error(
|
|
459
|
+
throw new Error(`Unexpected query and breakpoint combination: '${query}', '${breakpoint}'.`);
|
|
630
460
|
}
|
|
631
461
|
return retVal;
|
|
632
462
|
}
|
|
633
463
|
|
|
634
|
-
|
|
464
|
+
const exponentialSymbols = {
|
|
635
465
|
symbols: {
|
|
636
466
|
sqrt: {
|
|
637
467
|
func: {
|
|
638
468
|
symbol: 'sqrt',
|
|
639
|
-
f:
|
|
640
|
-
return Math.sqrt(a);
|
|
641
|
-
},
|
|
469
|
+
f: a => Math.sqrt(a),
|
|
642
470
|
notation: 'func',
|
|
643
471
|
precedence: 0,
|
|
644
472
|
rightToLeft: 0,
|
|
@@ -649,17 +477,17 @@ var exponentialSymbols = {
|
|
|
649
477
|
}
|
|
650
478
|
}
|
|
651
479
|
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
480
|
+
const animationStyles$1 = (position, modifier) => {
|
|
481
|
+
const property = position.split('-')[0];
|
|
482
|
+
const animationName = styledComponents.keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
|
|
655
483
|
return styledComponents.css(["&", "::before,&", "::after{animation:0.3s ease-in-out ", ";}"], modifier, modifier, animationName);
|
|
656
484
|
};
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
485
|
+
const positionStyles = (position, size, inset) => {
|
|
486
|
+
const margin = polished.math(`${size} / -2`);
|
|
487
|
+
const placement = polished.math(`${margin} + ${inset}`);
|
|
488
|
+
let clipPath;
|
|
489
|
+
let positionCss;
|
|
490
|
+
let propertyRadius;
|
|
663
491
|
if (position.startsWith('top')) {
|
|
664
492
|
propertyRadius = 'border-bottom-right-radius';
|
|
665
493
|
clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
|
|
@@ -680,23 +508,23 @@ var positionStyles = function positionStyles(position, size, inset) {
|
|
|
680
508
|
return styledComponents.css(["&::before{", ":100%;clip-path:", ";}&::before,&::after{", "}"], propertyRadius, clipPath, positionCss);
|
|
681
509
|
};
|
|
682
510
|
function arrowStyles(position) {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
511
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
512
|
+
const size = options.size || '6px';
|
|
513
|
+
const inset = options.inset || '0';
|
|
514
|
+
const squareSize = polished.math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
|
|
687
515
|
return styledComponents.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));
|
|
688
516
|
}
|
|
689
517
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
return React.useMemo(
|
|
518
|
+
const useText = (component, props, name, text) => {
|
|
519
|
+
const value = props[name];
|
|
520
|
+
return React.useMemo(() => {
|
|
693
521
|
if (name === 'children') {
|
|
694
522
|
throw new Error('Error: `children` is not a valid `getText` prop.');
|
|
695
523
|
} else if (value === null || value === '') {
|
|
696
|
-
throw new Error(component.displayName ?
|
|
524
|
+
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.`);
|
|
697
525
|
} else if (value === undefined) {
|
|
698
526
|
if (process.env.NODE_ENV === 'development') {
|
|
699
|
-
console.warn(component.displayName ?
|
|
527
|
+
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.`);
|
|
700
528
|
}
|
|
701
529
|
return text;
|
|
702
530
|
}
|
|
@@ -704,32 +532,32 @@ var useText = function useText(component, props, name, text) {
|
|
|
704
532
|
}, [component.displayName, value, name, text]);
|
|
705
533
|
};
|
|
706
534
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
535
|
+
const animationStyles = (position, options) => {
|
|
536
|
+
const theme = options.theme || DEFAULT_THEME;
|
|
537
|
+
let translateValue = `${theme.space.base * 5}px`;
|
|
538
|
+
let transformFunction;
|
|
711
539
|
if (position === 'top') {
|
|
712
540
|
transformFunction = 'translateY';
|
|
713
541
|
} else if (position === 'right') {
|
|
714
542
|
transformFunction = 'translateX';
|
|
715
|
-
translateValue =
|
|
543
|
+
translateValue = `-${translateValue}`;
|
|
716
544
|
} else if (position === 'bottom') {
|
|
717
545
|
transformFunction = 'translateY';
|
|
718
|
-
translateValue =
|
|
546
|
+
translateValue = `-${translateValue}`;
|
|
719
547
|
} else {
|
|
720
548
|
transformFunction = 'translateX';
|
|
721
549
|
}
|
|
722
|
-
|
|
550
|
+
const animationName = styledComponents.keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
|
|
723
551
|
return styledComponents.css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
|
|
724
552
|
};
|
|
725
|
-
|
|
726
|
-
|
|
553
|
+
const hiddenStyles = options => {
|
|
554
|
+
const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
|
|
727
555
|
return styledComponents.css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
|
|
728
556
|
};
|
|
729
557
|
function menuStyles(position) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
558
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
559
|
+
const theme = options.theme || DEFAULT_THEME;
|
|
560
|
+
let marginProperty;
|
|
733
561
|
if (position === 'top') {
|
|
734
562
|
marginProperty = 'margin-bottom';
|
|
735
563
|
} else if (position === 'right') {
|
|
@@ -739,11 +567,11 @@ function menuStyles(position) {
|
|
|
739
567
|
} else {
|
|
740
568
|
marginProperty = 'margin-right';
|
|
741
569
|
}
|
|
742
|
-
return styledComponents.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, getColor('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(
|
|
570
|
+
return styledComponents.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, getColor('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor('chromeHue', 600, theme, 0.15)), theme.colors.background, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
|
|
743
571
|
}
|
|
744
572
|
|
|
745
|
-
|
|
746
|
-
|
|
573
|
+
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
574
|
+
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
747
575
|
|
|
748
576
|
exports.ARRAY_ARROW_POSITION = ARROW_POSITION;
|
|
749
577
|
exports.ARRAY_MENU_POSITION = MENU_POSITION;
|