@zendeskgarden/react-theming 9.0.0-next.0 → 9.0.0-next.2
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/index.cjs.js +87 -20
- package/dist/index.esm.js +85 -19
- package/dist/typings/index.d.ts +4 -4
- package/dist/typings/types/index.d.ts +2 -0
- package/dist/typings/utils/getArrowPosition.d.ts +19 -0
- package/dist/typings/utils/getFloatingPlacements.d.ts +20 -0
- package/dist/typings/utils/getMenuPosition.d.ts +16 -0
- package/dist/typings/utils/menuStyles.d.ts +2 -2
- package/package.json +4 -3
- 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/README.md
CHANGED
|
@@ -52,20 +52,3 @@ import { Notification } from '@zendeskgarden/react-notifications';
|
|
|
52
52
|
<Notification>This notification content will render with RTL layout.</Notification>
|
|
53
53
|
</ThemeProvider>;
|
|
54
54
|
```
|
|
55
|
-
|
|
56
|
-
The `withTheme` [HOC](https://reactjs.org/docs/higher-order-components.html)
|
|
57
|
-
utility allows any component to interact with its `ThemeProvider`.
|
|
58
|
-
|
|
59
|
-
```jsx
|
|
60
|
-
import { withTheme } from '@zendeskgarden/react-theming';
|
|
61
|
-
|
|
62
|
-
const Div = ({ theme, children }) => (
|
|
63
|
-
<div style={{ direction: theme.rtl ? 'rtl' : 'ltr' }}>{children}</div>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const LocalizedComponent = withTheme(Div);
|
|
67
|
-
|
|
68
|
-
<ThemeProvider theme={{ ...DEFAULT_THEME, rtl: true }}>
|
|
69
|
-
<LocalizedComponent>RTL localizable</LocalizedComponent>
|
|
70
|
-
</ThemeProvider>;
|
|
71
|
-
```
|
package/dist/index.cjs.js
CHANGED
|
@@ -330,13 +330,6 @@ ThemeProvider.defaultProps = {
|
|
|
330
330
|
theme: DEFAULT_THEME
|
|
331
331
|
};
|
|
332
332
|
|
|
333
|
-
function isRtl() {
|
|
334
|
-
let {
|
|
335
|
-
theme
|
|
336
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
337
|
-
return Boolean(theme && theme.rtl);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
333
|
function retrieveComponentStyles(componentId, props) {
|
|
341
334
|
const components = props.theme && props.theme.components;
|
|
342
335
|
if (!components) {
|
|
@@ -349,16 +342,33 @@ function retrieveComponentStyles(componentId, props) {
|
|
|
349
342
|
return componentStyles;
|
|
350
343
|
}
|
|
351
344
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
345
|
+
const POSITION_MAP = {
|
|
346
|
+
top: 'bottom',
|
|
347
|
+
'top-start': 'bottom-left',
|
|
348
|
+
'top-end': 'bottom-right',
|
|
349
|
+
right: 'left',
|
|
350
|
+
'right-start': 'left-top',
|
|
351
|
+
'right-end': 'left-bottom',
|
|
352
|
+
bottom: 'top',
|
|
353
|
+
'bottom-start': 'top-left',
|
|
354
|
+
'bottom-end': 'top-right',
|
|
355
|
+
left: 'right',
|
|
356
|
+
'left-start': 'right-top',
|
|
357
|
+
'left-end': 'right-bottom'
|
|
358
|
+
};
|
|
359
|
+
const RTL_POSITION_MAP = {
|
|
360
|
+
'bottom-left': 'bottom-right',
|
|
361
|
+
'bottom-right': 'bottom-left',
|
|
362
|
+
'top-left': 'top-right',
|
|
363
|
+
'top-right': 'top-left'
|
|
364
|
+
};
|
|
365
|
+
const getArrowPosition = (theme, placement) => {
|
|
366
|
+
let retVal = POSITION_MAP[placement];
|
|
367
|
+
if (theme.rtl) {
|
|
368
|
+
retVal = RTL_POSITION_MAP[retVal] || retVal;
|
|
369
|
+
}
|
|
370
|
+
return retVal;
|
|
371
|
+
};
|
|
362
372
|
|
|
363
373
|
const DEFAULT_SHADE = 600;
|
|
364
374
|
const adjust = (color, expected, actual) => {
|
|
@@ -410,6 +420,57 @@ const getColor = memoize__default.default(function (hue) {
|
|
|
410
420
|
transparency
|
|
411
421
|
}));
|
|
412
422
|
|
|
423
|
+
const PLACEMENT_MAP = {
|
|
424
|
+
end: 'right',
|
|
425
|
+
'end-top': 'right-start',
|
|
426
|
+
'end-bottom': 'right-end',
|
|
427
|
+
start: 'left',
|
|
428
|
+
'start-top': 'left-start',
|
|
429
|
+
'start-bottom': 'left-end'
|
|
430
|
+
};
|
|
431
|
+
const RTL_PLACEMENT_MAP = {
|
|
432
|
+
left: 'right',
|
|
433
|
+
'left-start': 'right-start',
|
|
434
|
+
'left-end': 'right-end',
|
|
435
|
+
right: 'left',
|
|
436
|
+
'right-start': 'left-start',
|
|
437
|
+
'right-end': 'left-end'
|
|
438
|
+
};
|
|
439
|
+
const toFloatingPlacement = (placement, theme) => {
|
|
440
|
+
let retVal = PLACEMENT_MAP[placement] || placement;
|
|
441
|
+
if (theme.rtl) {
|
|
442
|
+
retVal = RTL_PLACEMENT_MAP[retVal] || retVal;
|
|
443
|
+
}
|
|
444
|
+
return retVal;
|
|
445
|
+
};
|
|
446
|
+
const SIDE_FALLBACKS_MAP = {
|
|
447
|
+
top: ['top-start', 'top', 'top-end'],
|
|
448
|
+
right: ['right-start', 'right', 'right-end'],
|
|
449
|
+
bottom: ['bottom-start', 'bottom', 'bottom-end'],
|
|
450
|
+
left: ['left-start', 'left', 'left-end']
|
|
451
|
+
};
|
|
452
|
+
const SIDE_OPPOSITE_MAP = {
|
|
453
|
+
top: 'bottom',
|
|
454
|
+
right: 'left',
|
|
455
|
+
bottom: 'top',
|
|
456
|
+
left: 'right'
|
|
457
|
+
};
|
|
458
|
+
const toFallbackPlacements = (primaryPlacement, theme, fallbackPlacements) => {
|
|
459
|
+
if (Array.isArray(fallbackPlacements) && fallbackPlacements.length > 0) {
|
|
460
|
+
return fallbackPlacements.map(fallbackPlacement => toFloatingPlacement(fallbackPlacement, theme));
|
|
461
|
+
}
|
|
462
|
+
const side = primaryPlacement.split('-')[0];
|
|
463
|
+
const sameSideFallbackPlacements = [...SIDE_FALLBACKS_MAP[side]];
|
|
464
|
+
const oppositeSideFallbackPlacements = SIDE_FALLBACKS_MAP[SIDE_OPPOSITE_MAP[side]];
|
|
465
|
+
sameSideFallbackPlacements.splice(sameSideFallbackPlacements.indexOf(primaryPlacement), 1);
|
|
466
|
+
return [...sameSideFallbackPlacements, ...oppositeSideFallbackPlacements];
|
|
467
|
+
};
|
|
468
|
+
const getFloatingPlacements = (theme, placement, fallbackPlacements) => {
|
|
469
|
+
const floatingPlacement = toFloatingPlacement(placement, theme);
|
|
470
|
+
const floatingFallbackPlacements = toFallbackPlacements(floatingPlacement, theme, fallbackPlacements);
|
|
471
|
+
return [floatingPlacement, floatingFallbackPlacements];
|
|
472
|
+
};
|
|
473
|
+
|
|
413
474
|
const getFocusBoxShadow = _ref => {
|
|
414
475
|
let {
|
|
415
476
|
boxShadow,
|
|
@@ -447,6 +508,10 @@ function getLineHeight(height, fontSize) {
|
|
|
447
508
|
return heightValue / fontSizeValue;
|
|
448
509
|
}
|
|
449
510
|
|
|
511
|
+
const getMenuPosition = placement => {
|
|
512
|
+
return placement.split('-')[0];
|
|
513
|
+
};
|
|
514
|
+
|
|
450
515
|
const maxWidth = (breakpoints, breakpoint) => {
|
|
451
516
|
const keys = Object.keys(breakpoints);
|
|
452
517
|
const index = keys.indexOf(breakpoint) + 1;
|
|
@@ -651,20 +716,23 @@ const focusStyles = _ref => {
|
|
|
651
716
|
|
|
652
717
|
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
653
718
|
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
719
|
+
const PLACEMENT = ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
654
720
|
|
|
655
721
|
exports.ARRAY_ARROW_POSITION = ARROW_POSITION;
|
|
656
722
|
exports.ARRAY_MENU_POSITION = MENU_POSITION;
|
|
657
723
|
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
658
724
|
exports.PALETTE = PALETTE;
|
|
725
|
+
exports.PLACEMENT = PLACEMENT;
|
|
659
726
|
exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
|
|
660
727
|
exports.ThemeProvider = ThemeProvider;
|
|
661
728
|
exports.arrowStyles = arrowStyles;
|
|
662
729
|
exports.focusStyles = focusStyles;
|
|
730
|
+
exports.getArrowPosition = getArrowPosition;
|
|
663
731
|
exports.getColor = getColor;
|
|
664
|
-
exports.
|
|
732
|
+
exports.getFloatingPlacements = getFloatingPlacements;
|
|
665
733
|
exports.getFocusBoxShadow = getFocusBoxShadow;
|
|
666
734
|
exports.getLineHeight = getLineHeight;
|
|
667
|
-
exports.
|
|
735
|
+
exports.getMenuPosition = getMenuPosition;
|
|
668
736
|
exports.mediaQuery = mediaQuery;
|
|
669
737
|
exports.menuStyles = menuStyles;
|
|
670
738
|
exports.retrieveComponentStyles = retrieveComponentStyles;
|
|
@@ -672,4 +740,3 @@ exports.retrieveTheme = retrieveComponentStyles;
|
|
|
672
740
|
exports.useDocument = useDocument;
|
|
673
741
|
exports.useText = useText;
|
|
674
742
|
exports.useWindow = useWindow;
|
|
675
|
-
exports.withTheme = withTheme;
|
package/dist/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
|
9
|
-
import { ThemeProvider as ThemeProvider$1,
|
|
9
|
+
import { ThemeProvider as ThemeProvider$1, css, keyframes } from 'styled-components';
|
|
10
10
|
import { useFocusVisible } from '@zendeskgarden/container-focusvisible';
|
|
11
11
|
import { getControlledValue } from '@zendeskgarden/container-utilities';
|
|
12
12
|
import { rgba, darken, lighten, getValueAndUnit, math } from 'polished';
|
|
@@ -323,13 +323,6 @@ ThemeProvider.defaultProps = {
|
|
|
323
323
|
theme: DEFAULT_THEME
|
|
324
324
|
};
|
|
325
325
|
|
|
326
|
-
function isRtl() {
|
|
327
|
-
let {
|
|
328
|
-
theme
|
|
329
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
330
|
-
return Boolean(theme && theme.rtl);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
326
|
function retrieveComponentStyles(componentId, props) {
|
|
334
327
|
const components = props.theme && props.theme.components;
|
|
335
328
|
if (!components) {
|
|
@@ -342,16 +335,33 @@ function retrieveComponentStyles(componentId, props) {
|
|
|
342
335
|
return componentStyles;
|
|
343
336
|
}
|
|
344
337
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
338
|
+
const POSITION_MAP = {
|
|
339
|
+
top: 'bottom',
|
|
340
|
+
'top-start': 'bottom-left',
|
|
341
|
+
'top-end': 'bottom-right',
|
|
342
|
+
right: 'left',
|
|
343
|
+
'right-start': 'left-top',
|
|
344
|
+
'right-end': 'left-bottom',
|
|
345
|
+
bottom: 'top',
|
|
346
|
+
'bottom-start': 'top-left',
|
|
347
|
+
'bottom-end': 'top-right',
|
|
348
|
+
left: 'right',
|
|
349
|
+
'left-start': 'right-top',
|
|
350
|
+
'left-end': 'right-bottom'
|
|
351
|
+
};
|
|
352
|
+
const RTL_POSITION_MAP = {
|
|
353
|
+
'bottom-left': 'bottom-right',
|
|
354
|
+
'bottom-right': 'bottom-left',
|
|
355
|
+
'top-left': 'top-right',
|
|
356
|
+
'top-right': 'top-left'
|
|
357
|
+
};
|
|
358
|
+
const getArrowPosition = (theme, placement) => {
|
|
359
|
+
let retVal = POSITION_MAP[placement];
|
|
360
|
+
if (theme.rtl) {
|
|
361
|
+
retVal = RTL_POSITION_MAP[retVal] || retVal;
|
|
362
|
+
}
|
|
363
|
+
return retVal;
|
|
364
|
+
};
|
|
355
365
|
|
|
356
366
|
const DEFAULT_SHADE = 600;
|
|
357
367
|
const adjust = (color, expected, actual) => {
|
|
@@ -403,6 +413,57 @@ const getColor = memoize(function (hue) {
|
|
|
403
413
|
transparency
|
|
404
414
|
}));
|
|
405
415
|
|
|
416
|
+
const PLACEMENT_MAP = {
|
|
417
|
+
end: 'right',
|
|
418
|
+
'end-top': 'right-start',
|
|
419
|
+
'end-bottom': 'right-end',
|
|
420
|
+
start: 'left',
|
|
421
|
+
'start-top': 'left-start',
|
|
422
|
+
'start-bottom': 'left-end'
|
|
423
|
+
};
|
|
424
|
+
const RTL_PLACEMENT_MAP = {
|
|
425
|
+
left: 'right',
|
|
426
|
+
'left-start': 'right-start',
|
|
427
|
+
'left-end': 'right-end',
|
|
428
|
+
right: 'left',
|
|
429
|
+
'right-start': 'left-start',
|
|
430
|
+
'right-end': 'left-end'
|
|
431
|
+
};
|
|
432
|
+
const toFloatingPlacement = (placement, theme) => {
|
|
433
|
+
let retVal = PLACEMENT_MAP[placement] || placement;
|
|
434
|
+
if (theme.rtl) {
|
|
435
|
+
retVal = RTL_PLACEMENT_MAP[retVal] || retVal;
|
|
436
|
+
}
|
|
437
|
+
return retVal;
|
|
438
|
+
};
|
|
439
|
+
const SIDE_FALLBACKS_MAP = {
|
|
440
|
+
top: ['top-start', 'top', 'top-end'],
|
|
441
|
+
right: ['right-start', 'right', 'right-end'],
|
|
442
|
+
bottom: ['bottom-start', 'bottom', 'bottom-end'],
|
|
443
|
+
left: ['left-start', 'left', 'left-end']
|
|
444
|
+
};
|
|
445
|
+
const SIDE_OPPOSITE_MAP = {
|
|
446
|
+
top: 'bottom',
|
|
447
|
+
right: 'left',
|
|
448
|
+
bottom: 'top',
|
|
449
|
+
left: 'right'
|
|
450
|
+
};
|
|
451
|
+
const toFallbackPlacements = (primaryPlacement, theme, fallbackPlacements) => {
|
|
452
|
+
if (Array.isArray(fallbackPlacements) && fallbackPlacements.length > 0) {
|
|
453
|
+
return fallbackPlacements.map(fallbackPlacement => toFloatingPlacement(fallbackPlacement, theme));
|
|
454
|
+
}
|
|
455
|
+
const side = primaryPlacement.split('-')[0];
|
|
456
|
+
const sameSideFallbackPlacements = [...SIDE_FALLBACKS_MAP[side]];
|
|
457
|
+
const oppositeSideFallbackPlacements = SIDE_FALLBACKS_MAP[SIDE_OPPOSITE_MAP[side]];
|
|
458
|
+
sameSideFallbackPlacements.splice(sameSideFallbackPlacements.indexOf(primaryPlacement), 1);
|
|
459
|
+
return [...sameSideFallbackPlacements, ...oppositeSideFallbackPlacements];
|
|
460
|
+
};
|
|
461
|
+
const getFloatingPlacements = (theme, placement, fallbackPlacements) => {
|
|
462
|
+
const floatingPlacement = toFloatingPlacement(placement, theme);
|
|
463
|
+
const floatingFallbackPlacements = toFallbackPlacements(floatingPlacement, theme, fallbackPlacements);
|
|
464
|
+
return [floatingPlacement, floatingFallbackPlacements];
|
|
465
|
+
};
|
|
466
|
+
|
|
406
467
|
const getFocusBoxShadow = _ref => {
|
|
407
468
|
let {
|
|
408
469
|
boxShadow,
|
|
@@ -440,6 +501,10 @@ function getLineHeight(height, fontSize) {
|
|
|
440
501
|
return heightValue / fontSizeValue;
|
|
441
502
|
}
|
|
442
503
|
|
|
504
|
+
const getMenuPosition = placement => {
|
|
505
|
+
return placement.split('-')[0];
|
|
506
|
+
};
|
|
507
|
+
|
|
443
508
|
const maxWidth = (breakpoints, breakpoint) => {
|
|
444
509
|
const keys = Object.keys(breakpoints);
|
|
445
510
|
const index = keys.indexOf(breakpoint) + 1;
|
|
@@ -644,5 +709,6 @@ const focusStyles = _ref => {
|
|
|
644
709
|
|
|
645
710
|
const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
646
711
|
const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
712
|
+
const PLACEMENT = ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
647
713
|
|
|
648
|
-
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, DEFAULT_THEME, PALETTE, SELECTOR_FOCUS_VISIBLE, ThemeProvider, arrowStyles, focusStyles, getColor,
|
|
714
|
+
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, DEFAULT_THEME, PALETTE, PLACEMENT, SELECTOR_FOCUS_VISIBLE, ThemeProvider, arrowStyles, focusStyles, getArrowPosition, getColor, getFloatingPlacements, getFocusBoxShadow, getLineHeight, getMenuPosition, mediaQuery, menuStyles, retrieveComponentStyles, retrieveComponentStyles as retrieveTheme, useDocument, useText, useWindow };
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
export { ThemeProvider } from './elements/ThemeProvider';
|
|
8
8
|
export { default as DEFAULT_THEME } from './elements/theme';
|
|
9
9
|
export { default as PALETTE } from './elements/palette';
|
|
10
|
-
export { default as isRtl } from './utils/isRtl';
|
|
11
10
|
export { default as retrieveComponentStyles,
|
|
12
11
|
/** `retrieveTheme` is a deprecated usage for v7 compatability */
|
|
13
12
|
default as retrieveTheme } from './utils/retrieveComponentStyles';
|
|
14
|
-
export {
|
|
15
|
-
export { default as getDocument } from './utils/getDocument';
|
|
13
|
+
export { getArrowPosition } from './utils/getArrowPosition';
|
|
16
14
|
export { getColor } from './utils/getColor';
|
|
15
|
+
export { getFloatingPlacements } from './utils/getFloatingPlacements';
|
|
17
16
|
export { getFocusBoxShadow } from './utils/getFocusBoxShadow';
|
|
18
17
|
export { default as getLineHeight } from './utils/getLineHeight';
|
|
18
|
+
export { getMenuPosition } from './utils/getMenuPosition';
|
|
19
19
|
export { default as mediaQuery } from './utils/mediaQuery';
|
|
20
20
|
export { default as arrowStyles } from './utils/arrowStyles';
|
|
21
21
|
export { useDocument } from './utils/useDocument';
|
|
@@ -23,4 +23,4 @@ export { useWindow } from './utils/useWindow';
|
|
|
23
23
|
export { useText } from './utils/useText';
|
|
24
24
|
export { default as menuStyles } from './utils/menuStyles';
|
|
25
25
|
export { focusStyles, SELECTOR_FOCUS_VISIBLE } from './utils/focusStyles';
|
|
26
|
-
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, type IGardenTheme, type IThemeProviderProps, type ArrowPosition as ARROW_POSITION, type MenuPosition as MENU_POSITION } from './types';
|
|
26
|
+
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, PLACEMENT, type IGardenTheme, type IThemeProviderProps, type ArrowPosition as ARROW_POSITION, type MenuPosition as MENU_POSITION, type Placement } from './types';
|
|
@@ -10,6 +10,8 @@ export declare const ARROW_POSITION: readonly ["top", "top-left", "top-right", "
|
|
|
10
10
|
export type ArrowPosition = (typeof ARROW_POSITION)[number];
|
|
11
11
|
export declare const MENU_POSITION: readonly ["top", "right", "bottom", "left"];
|
|
12
12
|
export type MenuPosition = (typeof MENU_POSITION)[number];
|
|
13
|
+
export declare const PLACEMENT: readonly ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "end", "end-top", "end-bottom", "start", "start-top", "start-bottom"];
|
|
14
|
+
export type Placement = (typeof PLACEMENT)[number];
|
|
13
15
|
type Hue = Record<number | string, string> | string;
|
|
14
16
|
export interface IGardenTheme {
|
|
15
17
|
rtl: boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { Placement } from '@floating-ui/react-dom';
|
|
8
|
+
import { ArrowPosition, IGardenTheme } from '../types';
|
|
9
|
+
export declare const POSITION_MAP: Record<Placement, ArrowPosition>;
|
|
10
|
+
export declare const RTL_POSITION_MAP: Record<string, ArrowPosition>;
|
|
11
|
+
/**
|
|
12
|
+
* Convert Floating-UI placement to a valid `arrowStyles` position.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} theme Context `theme` object used to determine if layout is right-to-left.
|
|
15
|
+
* @param {string} placement A Floating-UI placement.
|
|
16
|
+
*
|
|
17
|
+
* @returns An `arrowStyles` position.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getArrowPosition: (theme: IGardenTheme, placement: Placement) => ArrowPosition;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import { Placement as FloatingPlacement } from '@floating-ui/react-dom';
|
|
8
|
+
import { IGardenTheme, Placement } from '../types';
|
|
9
|
+
export declare const PLACEMENT_MAP: Record<string, FloatingPlacement>;
|
|
10
|
+
export declare const RTL_PLACEMENT_MAP: Record<string, FloatingPlacement>;
|
|
11
|
+
/**
|
|
12
|
+
* Convert Garden placements to valid placements for Floating-UI.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} theme Context `theme` object used to determine if layout is right-to-left.
|
|
15
|
+
* @param {string} placement A Garden placement.
|
|
16
|
+
* @param {Array} fallbackPlacements Optional list of Garden fallback placements.
|
|
17
|
+
*
|
|
18
|
+
* @returns A Floating-UI (placement, fallbackPlacements) tuple.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getFloatingPlacements: (theme: IGardenTheme, placement: Placement, fallbackPlacements?: Placement[]) => [FloatingPlacement, FloatingPlacement[]];
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import { Placement } from '@floating-ui/react-dom';
|
|
8
|
+
import { MenuPosition } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Convert Floating-UI placement to a valid `menuStyles` position.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} placement A Floating-UI placement.
|
|
13
|
+
*
|
|
14
|
+
* @returns A `menuStyles` position.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getMenuPosition: (placement: Placement) => MenuPosition;
|
|
@@ -16,8 +16,8 @@ type MenuOptions = {
|
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* CSS for a `wrapper > menu` at the given position. The wrapper provides
|
|
19
|
-
* absolute positioning (e.g. via
|
|
20
|
-
* optional animation.
|
|
19
|
+
* absolute positioning (e.g. via Floating-UI). The menu provides basic styling
|
|
20
|
+
* and optional animation.
|
|
21
21
|
*
|
|
22
22
|
* @param {string} position One of:
|
|
23
23
|
* - `'top'`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.2",
|
|
4
4
|
"description": "Theming utilities and components within the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@floating-ui/react-dom": "^2.0.0",
|
|
24
25
|
"@zendeskgarden/container-focusvisible": "^2.0.0",
|
|
25
26
|
"@zendeskgarden/container-utilities": "^2.0.0",
|
|
26
27
|
"lodash.memoize": "^4.1.2",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"peerDependencies": {
|
|
31
32
|
"react": ">=16.8.0",
|
|
32
33
|
"react-dom": ">=16.8.0",
|
|
33
|
-
"styled-components": "^4.2.0 || ^5.
|
|
34
|
+
"styled-components": "^4.2.0 || ^5.1.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/lodash.memoize": "4.1.9"
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
48
|
"zendeskgarden:src": "src/index.ts",
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e47dd011fedf130106acdb485a023340564171af"
|
|
49
50
|
}
|
|
@@ -1,9 +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
|
-
import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
8
|
-
/** @component */
|
|
9
|
-
export default function getDocument({ theme }?: Partial<ThemeProps<Partial<DefaultTheme>>>): any;
|
|
@@ -1,9 +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
|
-
import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
8
|
-
/** @component */
|
|
9
|
-
export default function isRtl({ theme }?: Partial<ThemeProps<Partial<DefaultTheme>>>): boolean;
|