@spaced-out/ui-design-system 0.1.25 → 0.1.27
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/.cspell/custom-words.txt +3 -0
- package/.storybook/main.js +40 -28
- package/.storybook/manager.js +0 -4
- package/.storybook/preview-head.html +15 -6
- package/.storybook/preview.js +0 -5
- package/CHANGELOG.md +31 -0
- package/babel.config.js +1 -0
- package/lib/components/Badge/Badge.module.css +1 -0
- package/lib/components/ButtonDropdown/ButtonDropdown.js +10 -9
- package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +6 -4
- package/lib/components/ButtonTabs/ButtonTabs.js +4 -1
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +2 -1
- package/lib/components/Chip/Chip.js +1 -1
- package/lib/components/Chip/Chip.js.flow +2 -2
- package/lib/components/CollapsibleCard/CollapsibleCard.js +3 -0
- package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +4 -0
- package/lib/components/Dialog/Dialog.js +23 -2
- package/lib/components/Dialog/Dialog.js.flow +38 -0
- package/lib/components/Dropdown/Dropdown.js +10 -9
- package/lib/components/Dropdown/Dropdown.js.flow +6 -4
- package/lib/components/FocusManager/FocusManager.js +7 -5
- package/lib/components/FocusManager/FocusManager.js.flow +3 -3
- package/lib/components/InlineDropdown/InlineDropdown.js +10 -9
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +6 -4
- package/lib/components/Menu/Menu.js +48 -12
- package/lib/components/Menu/Menu.js.flow +102 -9
- package/lib/components/Menu/Menu.module.css +10 -0
- package/lib/components/Menu/MenuOptionButton.js +21 -4
- package/lib/components/Menu/MenuOptionButton.js.flow +21 -0
- package/lib/components/Modal/Modal.js +35 -8
- package/lib/components/Modal/Modal.js.flow +52 -7
- package/lib/components/Modal/Modal.module.css +1 -3
- package/lib/components/Panel/Panel.js +21 -1
- package/lib/components/Panel/Panel.js.flow +30 -1
- package/lib/components/Panel/Panel.module.css +0 -1
- package/lib/components/Table/DefaultRow.js +5 -5
- package/lib/components/Table/DefaultRow.js.flow +14 -11
- package/lib/components/Table/StaticTable.js +5 -1
- package/lib/components/Table/StaticTable.js.flow +4 -0
- package/lib/components/Table/Table.js.flow +2 -0
- package/lib/components/Tabs/TabList/TabDropdown.js +10 -9
- package/lib/components/Tabs/TabList/TabDropdown.js.flow +6 -4
- package/lib/components/Toast/Toast.js +7 -5
- package/lib/components/Toast/Toast.js.flow +5 -3
- package/lib/components/Toggle/Toggle.js +2 -1
- package/lib/components/Toggle/Toggle.js.flow +2 -1
- package/lib/components/Tooltip/Tooltip.js +22 -25
- package/lib/components/Tooltip/Tooltip.js.flow +25 -22
- package/lib/components/Typeahead/Typeahead.js +10 -9
- package/lib/components/Typeahead/Typeahead.js.flow +6 -4
- package/lib/hooks/index.js +55 -0
- package/lib/hooks/index.js.flow +5 -0
- package/lib/hooks/useCopyToClipboard.js +31 -0
- package/lib/hooks/useCopyToClipboard.js.flow +31 -0
- package/lib/hooks/useInputState.js +23 -0
- package/lib/hooks/useInputState.js.flow +28 -0
- package/lib/hooks/useLockedBody.js +54 -0
- package/lib/hooks/useLockedBody.js.flow +55 -0
- package/lib/hooks/useToggle.js +18 -0
- package/lib/hooks/useToggle.js.flow +17 -0
- package/lib/hooks/useWindowSize.js +32 -0
- package/lib/hooks/useWindowSize.js.flow +37 -0
- package/lib/styles/typography.module.css +1 -0
- package/lib/types/common.js +0 -1
- package/lib/utils/index.js +11 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/menu.js +57 -2
- package/lib/utils/menu.js.flow +109 -1
- package/lib/utils/string.js +4 -2
- package/lib/utils/string.js.flow +3 -0
- package/lib/utils/tokens.js +74 -0
- package/lib/utils/tokens.js.flow +82 -0
- package/package.json +18 -16
- package/.storybook/public/favicon.svg +0 -6
|
@@ -8,10 +8,16 @@ import {
|
|
|
8
8
|
FloatingFocusManager,
|
|
9
9
|
// $FlowFixMe[untyped-import]
|
|
10
10
|
useFloating,
|
|
11
|
-
|
|
11
|
+
// $FlowFixMe[untyped-import]
|
|
12
|
+
useTransitionStyles,
|
|
13
|
+
} from '@floating-ui/react';
|
|
12
14
|
|
|
13
15
|
import useMountTransition from '../../hooks/useMountTransition';
|
|
14
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
motionDurationNormal,
|
|
18
|
+
motionDurationSlow,
|
|
19
|
+
} from '../../styles/variables/_motion';
|
|
20
|
+
import {spaceNegHalfFluid} from '../../styles/variables/_space';
|
|
15
21
|
import classify from '../../utils/classify';
|
|
16
22
|
import {uuid} from '../../utils/helpers';
|
|
17
23
|
import {Button} from '../Button/Button';
|
|
@@ -26,6 +32,14 @@ type ClassNames = $ReadOnly<{
|
|
|
26
32
|
backdrop?: string,
|
|
27
33
|
}>;
|
|
28
34
|
|
|
35
|
+
export type UseTransitionStylesProps = {
|
|
36
|
+
duration?: number | {open: number, close: number},
|
|
37
|
+
initial?: {+[key: string]: mixed},
|
|
38
|
+
open?: {+[key: string]: mixed},
|
|
39
|
+
close?: {+[key: string]: mixed},
|
|
40
|
+
common?: {+[key: string]: mixed},
|
|
41
|
+
};
|
|
42
|
+
|
|
29
43
|
type FooterClassNames = $ReadOnly<{
|
|
30
44
|
wrapper?: string,
|
|
31
45
|
actions?: string,
|
|
@@ -41,6 +55,7 @@ export type ModalProps = {
|
|
|
41
55
|
removeWhenClosed?: boolean,
|
|
42
56
|
tapOutsideToClose?: boolean,
|
|
43
57
|
initialFocus?: number,
|
|
58
|
+
customAnimation?: UseTransitionStylesProps,
|
|
44
59
|
};
|
|
45
60
|
|
|
46
61
|
export type ModalHeaderProps = {
|
|
@@ -60,6 +75,22 @@ export type ModalBodyProps = {
|
|
|
60
75
|
className?: string,
|
|
61
76
|
};
|
|
62
77
|
|
|
78
|
+
const DEFAULT_MODAL_ANIMATION = {
|
|
79
|
+
duration: {
|
|
80
|
+
open: parseInt(motionDurationSlow),
|
|
81
|
+
close: parseInt(motionDurationNormal),
|
|
82
|
+
},
|
|
83
|
+
initial: {
|
|
84
|
+
transform: `translate(${spaceNegHalfFluid}, ${spaceNegHalfFluid}) scale(0.95)`,
|
|
85
|
+
},
|
|
86
|
+
open: {
|
|
87
|
+
transform: `translate(${spaceNegHalfFluid}, ${spaceNegHalfFluid}) scale(1)`,
|
|
88
|
+
},
|
|
89
|
+
close: {
|
|
90
|
+
transform: `translate(${spaceNegHalfFluid}, ${spaceNegHalfFluid}) scale(0.95)`,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
63
94
|
export const ModalHeader = ({
|
|
64
95
|
children,
|
|
65
96
|
hideCloseBtn,
|
|
@@ -157,8 +188,13 @@ export const Modal = ({
|
|
|
157
188
|
hideBackdrop = false,
|
|
158
189
|
tapOutsideToClose = true,
|
|
159
190
|
initialFocus = -1,
|
|
191
|
+
customAnimation,
|
|
160
192
|
}: ModalProps): React.Node => {
|
|
161
|
-
const {
|
|
193
|
+
const {refs, context} = useFloating({open: isOpen});
|
|
194
|
+
const {isMounted, styles} = useTransitionStyles(
|
|
195
|
+
context,
|
|
196
|
+
customAnimation || DEFAULT_MODAL_ANIMATION,
|
|
197
|
+
);
|
|
162
198
|
const modalId = uuid();
|
|
163
199
|
|
|
164
200
|
const bodyRef = React.useRef(document.querySelector('body'));
|
|
@@ -242,7 +278,7 @@ export const Modal = ({
|
|
|
242
278
|
return createPortal(
|
|
243
279
|
<FloatingFocusManager context={context} initialFocus={initialFocus}>
|
|
244
280
|
<div
|
|
245
|
-
ref={
|
|
281
|
+
ref={refs.setFloating}
|
|
246
282
|
aria-hidden={isOpen ? 'false' : 'true'}
|
|
247
283
|
className={classify(
|
|
248
284
|
css.modalContainer,
|
|
@@ -263,9 +299,18 @@ export const Modal = ({
|
|
|
263
299
|
)}
|
|
264
300
|
onClick={onBackdropClick}
|
|
265
301
|
/>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
302
|
+
{isMounted && (
|
|
303
|
+
<div
|
|
304
|
+
className={classify(css.modal, classNames?.content)}
|
|
305
|
+
role="dialog"
|
|
306
|
+
style={{
|
|
307
|
+
// Transition styles
|
|
308
|
+
...styles,
|
|
309
|
+
}}
|
|
310
|
+
>
|
|
311
|
+
{children}
|
|
312
|
+
</div>
|
|
313
|
+
)}
|
|
269
314
|
</div>
|
|
270
315
|
</FloatingFocusManager>,
|
|
271
316
|
portalRootRef.current,
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
position: fixed;
|
|
17
17
|
top: spaceHalfFluid;
|
|
18
18
|
left: spaceHalfFluid;
|
|
19
|
-
transform: translate(spaceNegHalfFluid, spaceNegHalfFluid)
|
|
20
|
-
opacity: opacity0;
|
|
19
|
+
transform: translate(spaceNegHalfFluid, spaceNegHalfFluid);
|
|
21
20
|
composes: boxShadow4 from '../../styles/shadow.module.css';
|
|
22
21
|
display: flex;
|
|
23
22
|
max-height: sizeFluid;
|
|
@@ -25,7 +24,6 @@
|
|
|
25
24
|
background: colorBackgroundTertiary;
|
|
26
25
|
overflow: auto;
|
|
27
26
|
z-index: elevationModal;
|
|
28
|
-
transition: opacity motionDurationNormal, transform motionDurationNormal;
|
|
29
27
|
border-radius: borderRadiusMedium;
|
|
30
28
|
}
|
|
31
29
|
|
|
@@ -7,6 +7,7 @@ exports.PanelHeader = exports.PanelFooter = exports.PanelBody = exports.Panel =
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _useMountTransition = _interopRequireDefault(require("../../hooks/useMountTransition"));
|
|
9
9
|
var _motion = require("../../styles/variables/_motion");
|
|
10
|
+
var _space = require("../../styles/variables/_space");
|
|
10
11
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
12
|
var _Button = require("../Button");
|
|
12
13
|
var _Modal = require("../Modal");
|
|
@@ -16,6 +17,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
20
|
+
const getDefaultPanelAnimation = anchor => ({
|
|
21
|
+
// Configure both open and close durations:
|
|
22
|
+
duration: {
|
|
23
|
+
open: parseInt(_motion.motionDurationSlow),
|
|
24
|
+
close: parseInt(_motion.motionDurationNormal)
|
|
25
|
+
},
|
|
26
|
+
initial: {
|
|
27
|
+
transform: `translateX(${anchor === 'right' ? _space.spaceFluid : _space.spaceNegFluid})`
|
|
28
|
+
},
|
|
29
|
+
open: {
|
|
30
|
+
transform: `translateX(${_space.spaceNone})`
|
|
31
|
+
},
|
|
32
|
+
close: {
|
|
33
|
+
transform: `translateX(${anchor === 'right' ? _space.spaceFluid : _space.spaceNegFluid})`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
19
36
|
const PanelHeader = _ref => {
|
|
20
37
|
let {
|
|
21
38
|
children,
|
|
@@ -68,9 +85,11 @@ const Panel = _ref4 => {
|
|
|
68
85
|
onClose,
|
|
69
86
|
hideBackdrop = true,
|
|
70
87
|
classNames,
|
|
88
|
+
customAnimation,
|
|
71
89
|
...restPanelProps
|
|
72
90
|
} = _ref4;
|
|
73
91
|
const isTransitioning = (0, _useMountTransition.default)(isOpen, parseInt(_motion.motionDurationNormal));
|
|
92
|
+
const defaultPanelAnimation = getDefaultPanelAnimation(anchor);
|
|
74
93
|
return /*#__PURE__*/React.createElement(_Modal.Modal, _extends({
|
|
75
94
|
isOpen: isOpen,
|
|
76
95
|
onClose: onClose,
|
|
@@ -87,7 +106,8 @@ const Panel = _ref4 => {
|
|
|
87
106
|
[_PanelModule.default.large]: size === 'large'
|
|
88
107
|
}, classNames?.content),
|
|
89
108
|
backdrop: (0, _classify.default)(classNames?.backdrop)
|
|
90
|
-
}
|
|
109
|
+
},
|
|
110
|
+
customAnimation: customAnimation || defaultPanelAnimation
|
|
91
111
|
}), children);
|
|
92
112
|
};
|
|
93
113
|
exports.Panel = Panel;
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import useMountTransition from '../../hooks/useMountTransition';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
motionDurationNormal,
|
|
8
|
+
motionDurationSlow,
|
|
9
|
+
} from '../../styles/variables/_motion';
|
|
10
|
+
import {
|
|
11
|
+
spaceFluid,
|
|
12
|
+
spaceNegFluid,
|
|
13
|
+
spaceNone,
|
|
14
|
+
} from '../../styles/variables/_space';
|
|
7
15
|
import classify from '../../utils/classify';
|
|
8
16
|
import {Button} from '../Button';
|
|
9
17
|
import type {ModalProps} from '../Modal';
|
|
@@ -45,6 +53,23 @@ export type PanelProps = {
|
|
|
45
53
|
anchor?: PanelAnchor,
|
|
46
54
|
};
|
|
47
55
|
|
|
56
|
+
const getDefaultPanelAnimation = (anchor: PanelAnchor) => ({
|
|
57
|
+
// Configure both open and close durations:
|
|
58
|
+
duration: {
|
|
59
|
+
open: parseInt(motionDurationSlow),
|
|
60
|
+
close: parseInt(motionDurationNormal),
|
|
61
|
+
},
|
|
62
|
+
initial: {
|
|
63
|
+
transform: `translateX(${anchor === 'right' ? spaceFluid : spaceNegFluid})`,
|
|
64
|
+
},
|
|
65
|
+
open: {
|
|
66
|
+
transform: `translateX(${spaceNone})`,
|
|
67
|
+
},
|
|
68
|
+
close: {
|
|
69
|
+
transform: `translateX(${anchor === 'right' ? spaceFluid : spaceNegFluid})`,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
48
73
|
export const PanelHeader = ({
|
|
49
74
|
children,
|
|
50
75
|
hideCloseBtn,
|
|
@@ -102,6 +127,7 @@ export const Panel = ({
|
|
|
102
127
|
onClose,
|
|
103
128
|
hideBackdrop = true,
|
|
104
129
|
classNames,
|
|
130
|
+
customAnimation,
|
|
105
131
|
...restPanelProps
|
|
106
132
|
}: PanelProps): React.Node => {
|
|
107
133
|
const isTransitioning = useMountTransition(
|
|
@@ -109,6 +135,8 @@ export const Panel = ({
|
|
|
109
135
|
parseInt(motionDurationNormal),
|
|
110
136
|
);
|
|
111
137
|
|
|
138
|
+
const defaultPanelAnimation = getDefaultPanelAnimation(anchor);
|
|
139
|
+
|
|
112
140
|
return (
|
|
113
141
|
<Modal
|
|
114
142
|
isOpen={isOpen}
|
|
@@ -136,6 +164,7 @@ export const Panel = ({
|
|
|
136
164
|
),
|
|
137
165
|
backdrop: classify(classNames?.backdrop),
|
|
138
166
|
}}
|
|
167
|
+
customAnimation={customAnimation || defaultPanelAnimation}
|
|
139
168
|
>
|
|
140
169
|
{children}
|
|
141
170
|
</Modal>
|
|
@@ -58,18 +58,18 @@ function DefaultRow(_ref2) {
|
|
|
58
58
|
headers,
|
|
59
59
|
selected,
|
|
60
60
|
onSelect,
|
|
61
|
-
|
|
61
|
+
classNames,
|
|
62
62
|
disabled
|
|
63
63
|
} = _ref2;
|
|
64
64
|
return /*#__PURE__*/React.createElement(BasicRow, {
|
|
65
|
-
className: (0, _classify.default)(
|
|
66
|
-
}, selected != null && /*#__PURE__*/React.createElement(_Cell.PaddedContentCell,
|
|
67
|
-
className: _TableModule.default.checkbox
|
|
65
|
+
className: (0, _classify.default)(selected ? _TableModule.default.defaultSelectedBodyRow : _TableModule.default.defaultBodyRow, classNames?.tableRow)
|
|
66
|
+
}, selected != null && /*#__PURE__*/React.createElement(_Cell.PaddedContentCell, {
|
|
67
|
+
className: (0, _classify.default)(_TableModule.default.checkbox, classNames?.checkbox)
|
|
68
68
|
}, /*#__PURE__*/React.createElement(_Checkbox.Checkbox, {
|
|
69
69
|
checked: selected ? true : false,
|
|
70
70
|
onChange: onSelect,
|
|
71
71
|
disabled: disabled
|
|
72
|
-
}))
|
|
72
|
+
})), headers.map((item, index) => {
|
|
73
73
|
const {
|
|
74
74
|
key,
|
|
75
75
|
render: Renderer,
|
|
@@ -15,6 +15,9 @@ import type {GenericObject} from './Table';
|
|
|
15
15
|
|
|
16
16
|
import css from './Table.module.css';
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
type ClassNames = $ReadOnly<{tableRow?: string, checkbox?: string}>;
|
|
20
|
+
|
|
18
21
|
// When using a custom Row prop, you need to create a component that looks like
|
|
19
22
|
// MyRow = (props: TableRowProps<Entries, Extras>): React.Node => {...}
|
|
20
23
|
// otherwise flow will complain.
|
|
@@ -91,7 +94,7 @@ export function DefaultRow<T: GenericObject, U: GenericObject>({
|
|
|
91
94
|
headers,
|
|
92
95
|
selected,
|
|
93
96
|
onSelect,
|
|
94
|
-
|
|
97
|
+
classNames,
|
|
95
98
|
disabled,
|
|
96
99
|
}: {
|
|
97
100
|
data: T,
|
|
@@ -100,25 +103,25 @@ export function DefaultRow<T: GenericObject, U: GenericObject>({
|
|
|
100
103
|
selected?: boolean,
|
|
101
104
|
// value dependent on checkbox checked value
|
|
102
105
|
onSelect?: ({value: string, checked: boolean}) => mixed,
|
|
103
|
-
|
|
106
|
+
classNames?: ClassNames,
|
|
104
107
|
disabled?: boolean,
|
|
105
108
|
}): React.Node {
|
|
106
109
|
return (
|
|
107
110
|
<BasicRow
|
|
108
111
|
className={classify(
|
|
109
|
-
className,
|
|
110
112
|
selected ? css.defaultSelectedBodyRow : css.defaultBodyRow,
|
|
113
|
+
classNames?.tableRow,
|
|
111
114
|
)}
|
|
112
115
|
>
|
|
113
116
|
{selected != null && (
|
|
114
|
-
<PaddedContentCell
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
<PaddedContentCell
|
|
118
|
+
className={classify(css.checkbox, classNames?.checkbox)}
|
|
119
|
+
>
|
|
120
|
+
<Checkbox
|
|
121
|
+
checked={selected ? true : false}
|
|
122
|
+
onChange={onSelect}
|
|
123
|
+
disabled={disabled}
|
|
124
|
+
/>
|
|
122
125
|
</PaddedContentCell>
|
|
123
126
|
)}
|
|
124
127
|
{headers.map((item, index) => {
|
|
@@ -128,7 +128,11 @@ function StaticTable(props) {
|
|
|
128
128
|
headers: headers,
|
|
129
129
|
selected: selected,
|
|
130
130
|
onSelect: selectedKeys != null ? _v => onSelect?.((0, _xor.default)(selectedKeys ?? [], [key])) : undefined,
|
|
131
|
-
disabled: disabled
|
|
131
|
+
disabled: disabled,
|
|
132
|
+
classNames: {
|
|
133
|
+
tableRow: classNames?.tableRow,
|
|
134
|
+
checkbox: classNames?.checkbox
|
|
135
|
+
}
|
|
132
136
|
});
|
|
133
137
|
}))));
|
|
134
138
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TabDropdown = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _react2 = require("@floating-ui/react");
|
|
9
9
|
var _space = require("../../../styles/variables/_space");
|
|
10
10
|
var _classify = require("../../../utils/classify");
|
|
11
11
|
var _clickAway = require("../../../utils/click-away");
|
|
@@ -28,14 +28,14 @@ const TabDropdown = _ref => {
|
|
|
28
28
|
const {
|
|
29
29
|
x,
|
|
30
30
|
y,
|
|
31
|
-
|
|
32
|
-
floating,
|
|
31
|
+
refs,
|
|
33
32
|
strategy
|
|
34
|
-
} = (0,
|
|
33
|
+
} = (0, _react2.useFloating)({
|
|
34
|
+
open: true,
|
|
35
35
|
strategy: 'absolute',
|
|
36
36
|
placement: anchorPosition,
|
|
37
|
-
whileElementsMounted:
|
|
38
|
-
middleware: [(0,
|
|
37
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
38
|
+
middleware: [(0, _react2.shift)(), (0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
39
39
|
});
|
|
40
40
|
return /*#__PURE__*/React.createElement(_clickAway.ClickAway, null, _ref2 => {
|
|
41
41
|
let {
|
|
@@ -50,7 +50,7 @@ const TabDropdown = _ref => {
|
|
|
50
50
|
ref: menuBtnRef
|
|
51
51
|
}, /*#__PURE__*/React.createElement(_Tab.Tab, _extends({}, props?.tab, {
|
|
52
52
|
size: size,
|
|
53
|
-
ref:
|
|
53
|
+
ref: refs.setReference,
|
|
54
54
|
onClick: e => {
|
|
55
55
|
e.stopPropagation();
|
|
56
56
|
onOpen();
|
|
@@ -61,7 +61,7 @@ const TabDropdown = _ref => {
|
|
|
61
61
|
}
|
|
62
62
|
})), isOpen && props?.menu && /*#__PURE__*/React.createElement("div", {
|
|
63
63
|
onClickCapture: cancelNext,
|
|
64
|
-
ref:
|
|
64
|
+
ref: refs.setFloating,
|
|
65
65
|
style: {
|
|
66
66
|
display: 'flex',
|
|
67
67
|
position: strategy,
|
|
@@ -73,7 +73,8 @@ const TabDropdown = _ref => {
|
|
|
73
73
|
onOptionSelect && onOptionSelect(option);
|
|
74
74
|
clickAway();
|
|
75
75
|
},
|
|
76
|
-
size: props.menu.size || size
|
|
76
|
+
size: props.menu.size || size,
|
|
77
|
+
onTabOut: clickAway
|
|
77
78
|
}))));
|
|
78
79
|
});
|
|
79
80
|
};
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
shift,
|
|
13
13
|
// $FlowFixMe[untyped-import]
|
|
14
14
|
useFloating,
|
|
15
|
-
} from '@floating-ui/react
|
|
15
|
+
} from '@floating-ui/react';
|
|
16
16
|
|
|
17
17
|
import {spaceNone, spaceXXSmall} from '../../../styles/variables/_space';
|
|
18
18
|
import {classify} from '../../../utils/classify';
|
|
@@ -49,7 +49,8 @@ export const TabDropdown = ({
|
|
|
49
49
|
classNames,
|
|
50
50
|
}: TabDropdownProps): React.Node => {
|
|
51
51
|
const menuBtnRef = React.useRef();
|
|
52
|
-
const {x, y,
|
|
52
|
+
const {x, y, refs, strategy} = useFloating({
|
|
53
|
+
open: true,
|
|
53
54
|
strategy: 'absolute',
|
|
54
55
|
placement: anchorPosition,
|
|
55
56
|
whileElementsMounted: autoUpdate,
|
|
@@ -67,7 +68,7 @@ export const TabDropdown = ({
|
|
|
67
68
|
<Tab
|
|
68
69
|
{...props?.tab}
|
|
69
70
|
size={size}
|
|
70
|
-
ref={
|
|
71
|
+
ref={refs.setReference}
|
|
71
72
|
onClick={(e) => {
|
|
72
73
|
e.stopPropagation();
|
|
73
74
|
onOpen();
|
|
@@ -80,7 +81,7 @@ export const TabDropdown = ({
|
|
|
80
81
|
{isOpen && props?.menu && (
|
|
81
82
|
<div
|
|
82
83
|
onClickCapture={cancelNext}
|
|
83
|
-
ref={
|
|
84
|
+
ref={refs.setFloating}
|
|
84
85
|
style={{
|
|
85
86
|
display: 'flex',
|
|
86
87
|
position: strategy,
|
|
@@ -95,6 +96,7 @@ export const TabDropdown = ({
|
|
|
95
96
|
clickAway();
|
|
96
97
|
}}
|
|
97
98
|
size={props.menu.size || size}
|
|
99
|
+
onTabOut={clickAway}
|
|
98
100
|
/>
|
|
99
101
|
</div>
|
|
100
102
|
)}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ToastTitle = exports.ToastFooter = exports.ToastBody = exports.Toast = exports.TOAST_SEMANTIC = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _react2 = require("@floating-ui/react");
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
10
|
var _Icon = require("../Icon");
|
|
11
11
|
var _Text = require("../Text");
|
|
@@ -145,9 +145,11 @@ const Toast = _ref5 => {
|
|
|
145
145
|
customIcon
|
|
146
146
|
} = _ref5;
|
|
147
147
|
const {
|
|
148
|
-
|
|
148
|
+
refs,
|
|
149
149
|
context
|
|
150
|
-
} = (0,
|
|
150
|
+
} = (0, _react2.useFloating)({
|
|
151
|
+
open: true
|
|
152
|
+
});
|
|
151
153
|
const getComp = comp => {
|
|
152
154
|
const childrenArray = React.Children.toArray(children);
|
|
153
155
|
if (childrenArray.length) {
|
|
@@ -168,12 +170,12 @@ const Toast = _ref5 => {
|
|
|
168
170
|
const footerWithClose = footer ? /*#__PURE__*/React.cloneElement(footer, {
|
|
169
171
|
onClose
|
|
170
172
|
}) : null;
|
|
171
|
-
return /*#__PURE__*/React.createElement(
|
|
173
|
+
return /*#__PURE__*/React.createElement(_react2.FloatingFocusManager, {
|
|
172
174
|
context: context,
|
|
173
175
|
initialFocus: initialFocus
|
|
174
176
|
}, /*#__PURE__*/React.createElement("div", {
|
|
175
177
|
className: (0, _classify.default)(_ToastModule.default.toastContainer, classNames?.wrapper),
|
|
176
|
-
ref:
|
|
178
|
+
ref: refs.setFloating
|
|
177
179
|
}, customIcon || /*#__PURE__*/React.createElement(ToastIcon, {
|
|
178
180
|
semantic: semantic
|
|
179
181
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
FloatingFocusManager,
|
|
7
7
|
// $FlowFixMe[untyped-import]
|
|
8
8
|
useFloating,
|
|
9
|
-
} from '@floating-ui/react
|
|
9
|
+
} from '@floating-ui/react';
|
|
10
10
|
|
|
11
11
|
import classify from '../../utils/classify';
|
|
12
12
|
import {CloseIcon, Icon} from '../Icon';
|
|
@@ -191,7 +191,9 @@ export const Toast = ({
|
|
|
191
191
|
initialFocus = -1,
|
|
192
192
|
customIcon,
|
|
193
193
|
}: ToastProps): React.Node => {
|
|
194
|
-
const {
|
|
194
|
+
const {refs, context} = useFloating({
|
|
195
|
+
open: true,
|
|
196
|
+
});
|
|
195
197
|
|
|
196
198
|
const getComp = (comp: string) => {
|
|
197
199
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -215,7 +217,7 @@ export const Toast = ({
|
|
|
215
217
|
<FloatingFocusManager context={context} initialFocus={initialFocus}>
|
|
216
218
|
<div
|
|
217
219
|
className={classify(css.toastContainer, classNames?.wrapper)}
|
|
218
|
-
ref={
|
|
220
|
+
ref={refs.setFloating}
|
|
219
221
|
>
|
|
220
222
|
{customIcon || <ToastIcon semantic={semantic} />}
|
|
221
223
|
<div className={css.toastMidSection}>
|
|
@@ -34,7 +34,8 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const onWrapClickHandler =
|
|
37
|
+
const onWrapClickHandler = e => {
|
|
38
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
38
39
|
toggleInput.current?.click();
|
|
39
40
|
};
|
|
40
41
|
React.useEffect(() => {
|
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Tooltip = exports.DELAY_MOTION_DURATION_TYPES = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
9
|
-
var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
|
|
8
|
+
var _react2 = require("@floating-ui/react");
|
|
10
9
|
var ELEVATION = _interopRequireWildcard(require("../../styles/variables/_elevation"));
|
|
11
10
|
var MOTION = _interopRequireWildcard(require("../../styles/variables/_motion"));
|
|
12
11
|
var _space = require("../../styles/variables/_space");
|
|
13
12
|
var _classify = require("../../utils/classify");
|
|
14
|
-
var _mergeRefs = require("../../utils/merge-refs");
|
|
15
13
|
var _string = require("../../utils/string");
|
|
16
14
|
var _Truncate = require("../Truncate");
|
|
17
15
|
var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
|
|
@@ -41,48 +39,47 @@ const Tooltip = _ref => {
|
|
|
41
39
|
elevation = ELEVATION['elevationTooltip'],
|
|
42
40
|
hidden
|
|
43
41
|
} = _ref;
|
|
44
|
-
const
|
|
45
|
-
const [open, setOpen] = React.useState(false);
|
|
42
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
46
43
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
refs,
|
|
45
|
+
floatingStyles,
|
|
46
|
+
context,
|
|
47
|
+
strategy
|
|
48
|
+
} = (0, _react2.useFloating)({
|
|
49
|
+
open: isOpen,
|
|
50
|
+
onOpenChange: setIsOpen,
|
|
54
51
|
placement,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
middleware: [(0,
|
|
58
|
-
|
|
52
|
+
// Make sure the tooltip stays on the screen
|
|
53
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
54
|
+
middleware: [(0, _react2.offset)(parseInt(_space.spaceXXSmall)), (0, _react2.flip)({
|
|
55
|
+
fallbackAxisSideDirection: 'start'
|
|
56
|
+
}), (0, _react2.shift)()]
|
|
59
57
|
});
|
|
60
58
|
const motionDurationToken = 'motionDuration' + (0, _string.capitalize)(delayMotionDuration);
|
|
61
59
|
const hoverDelay = parseInt(MOTION[motionDurationToken]) === NaN ? 0 : parseInt(MOTION[motionDurationToken]);
|
|
62
60
|
const {
|
|
63
61
|
getReferenceProps,
|
|
64
62
|
getFloatingProps
|
|
65
|
-
} = (0,
|
|
63
|
+
} = (0, _react2.useInteractions)([(0, _react2.useHover)(context, {
|
|
66
64
|
delay: {
|
|
67
65
|
open: hoverDelay,
|
|
68
66
|
close: 0
|
|
69
67
|
}
|
|
70
|
-
}), (0,
|
|
68
|
+
}), (0, _react2.useFocus)(context), (0, _react2.useRole)(context, {
|
|
71
69
|
role: 'tooltip'
|
|
72
|
-
}), (0,
|
|
70
|
+
}), (0, _react2.useDismiss)(context)]);
|
|
73
71
|
|
|
74
72
|
// Note(Nishant) Preserve the consumer's ref
|
|
75
|
-
const ref =
|
|
73
|
+
const ref = (0, _react2.useMergeRefs)([refs.setReference, children.ref]);
|
|
76
74
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(children, getReferenceProps({
|
|
77
75
|
ref,
|
|
78
76
|
...children.props
|
|
79
|
-
})),
|
|
80
|
-
ref:
|
|
77
|
+
})), /*#__PURE__*/React.createElement(_react2.FloatingPortal, null, isOpen && /*#__PURE__*/React.createElement(React.Fragment, null, !hidden && /*#__PURE__*/React.createElement("div", _extends({
|
|
78
|
+
ref: refs.setFloating,
|
|
81
79
|
className: (0, _classify.classify)(_TooltipModule.default.tooltip, classNames?.tooltip),
|
|
82
80
|
style: {
|
|
83
81
|
position: strategy,
|
|
84
|
-
|
|
85
|
-
left: x ?? _space.spaceNone,
|
|
82
|
+
...floatingStyles,
|
|
86
83
|
'--tooltip-elevation': elevation
|
|
87
84
|
}
|
|
88
85
|
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
@@ -97,6 +94,6 @@ const Tooltip = _ref => {
|
|
|
97
94
|
className: (0, _classify.classify)(_TooltipModule.default.body, {
|
|
98
95
|
[_TooltipModule.default.hasTitle]: !!title
|
|
99
96
|
}, classNames?.body)
|
|
100
|
-
}, body))))
|
|
97
|
+
}, body))))));
|
|
101
98
|
};
|
|
102
99
|
exports.Tooltip = Tooltip;
|