@spaced-out/ui-design-system 0.1.26 → 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 +22 -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/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/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
package/.cspell/custom-words.txt
CHANGED
package/.storybook/main.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
3
2
|
module.exports = {
|
|
4
3
|
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.jsx'],
|
|
5
|
-
features: {
|
|
4
|
+
features: {
|
|
5
|
+
buildStoriesJson: true,
|
|
6
|
+
storyStoreV7: false, // 👈 Opt out of on-demand story loading
|
|
7
|
+
},
|
|
6
8
|
// Add any Storybook addons you want here: https://storybook.js.org/addons/
|
|
7
9
|
addons: [
|
|
8
|
-
{
|
|
9
|
-
name: '@storybook/addon-postcss',
|
|
10
|
-
options: {
|
|
11
|
-
postcssLoaderOptions: {
|
|
12
|
-
implementation: require('postcss'),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
10
|
{
|
|
17
11
|
name: '@storybook/addon-docs',
|
|
18
12
|
options: {
|
|
@@ -26,8 +20,30 @@ module.exports = {
|
|
|
26
20
|
'@storybook/addon-a11y',
|
|
27
21
|
'@storybook/addon-essentials',
|
|
28
22
|
'@storybook/testing-react',
|
|
29
|
-
'storybook-vscode-component/register',
|
|
23
|
+
// 'storybook-vscode-component/register', This is not supported in storybook 7
|
|
24
|
+
'@storybook/addon-mdx-gfm',
|
|
30
25
|
],
|
|
26
|
+
babel: async (options) => ({
|
|
27
|
+
...options,
|
|
28
|
+
sourceType: 'unambiguous',
|
|
29
|
+
presets: [
|
|
30
|
+
[
|
|
31
|
+
'@babel/preset-env',
|
|
32
|
+
{
|
|
33
|
+
targets: [
|
|
34
|
+
'last 2 Chrome versions',
|
|
35
|
+
'last 2 Safari versions',
|
|
36
|
+
'last 2 Firefox versions',
|
|
37
|
+
'last 2 Edge versions',
|
|
38
|
+
'last 3 iOS Major versions',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
'@babel/preset-react',
|
|
43
|
+
'@babel/preset-flow',
|
|
44
|
+
],
|
|
45
|
+
plugins: ['macros'],
|
|
46
|
+
}),
|
|
31
47
|
webpackFinal: async (config) => {
|
|
32
48
|
config.module.rules = config.module.rules.map((rule) => {
|
|
33
49
|
if (rule.test && rule.test.toString().includes('woff')) {
|
|
@@ -38,37 +54,33 @@ module.exports = {
|
|
|
38
54
|
}
|
|
39
55
|
return rule;
|
|
40
56
|
});
|
|
41
|
-
|
|
42
57
|
config.module.rules.push({
|
|
43
58
|
test: /\.scss$/,
|
|
44
59
|
use: ['style-loader', 'css-loader?modules=true', 'sass-loader'],
|
|
45
60
|
include: path.resolve(__dirname, '../'),
|
|
46
61
|
});
|
|
47
|
-
|
|
48
62
|
config.module.rules.push({
|
|
49
63
|
test: /\.(js|jsx)$/,
|
|
50
64
|
loader: require.resolve('babel-loader'),
|
|
51
65
|
options: {
|
|
52
|
-
presets: [
|
|
66
|
+
presets: [
|
|
67
|
+
[
|
|
68
|
+
'react-app',
|
|
69
|
+
{
|
|
70
|
+
flow: true,
|
|
71
|
+
typescript: false,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
],
|
|
53
75
|
},
|
|
54
76
|
});
|
|
55
77
|
|
|
56
|
-
// fonts
|
|
57
|
-
config.module.rules.push({
|
|
58
|
-
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
|
|
59
|
-
use: [
|
|
60
|
-
{
|
|
61
|
-
loader: 'file-loader',
|
|
62
|
-
query: {
|
|
63
|
-
name: '[name].[ext]',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
include: path.resolve(__dirname, '../'),
|
|
68
|
-
});
|
|
69
78
|
config.resolve.extensions.push('.js', '.jsx');
|
|
70
|
-
|
|
71
79
|
return config;
|
|
72
80
|
},
|
|
73
81
|
staticDirs: ['public'],
|
|
82
|
+
framework: {
|
|
83
|
+
name: '@storybook/react-webpack5',
|
|
84
|
+
options: {},
|
|
85
|
+
},
|
|
74
86
|
};
|
package/.storybook/manager.js
CHANGED
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
body {
|
|
31
31
|
display: flex;
|
|
32
32
|
width: 100%;
|
|
33
|
-
height: 100%;
|
|
33
|
+
min-height: 100%;
|
|
34
|
+
height: auto;
|
|
34
35
|
margin: 0px;
|
|
35
36
|
padding: 0px;
|
|
36
37
|
background: white;
|
|
@@ -108,11 +109,7 @@
|
|
|
108
109
|
font-family: 'Centra No 2';
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
font-family: 'Centra No 2' !important;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
[class*='docblock'] {
|
|
112
|
+
.sbdocs *:not(i) {
|
|
116
113
|
font-family: 'Centra No 2' !important;
|
|
117
114
|
}
|
|
118
115
|
|
|
@@ -128,4 +125,16 @@
|
|
|
128
125
|
#root div {
|
|
129
126
|
display: flex;
|
|
130
127
|
}
|
|
128
|
+
|
|
129
|
+
div:has(> .docblock-argstable) {
|
|
130
|
+
overflow: auto !important;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.docblock-argstable {
|
|
134
|
+
max-width: 98%;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
code {
|
|
138
|
+
white-space: pre-wrap !important;
|
|
139
|
+
}
|
|
131
140
|
</style>
|
package/.storybook/preview.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.27](https://github.com/spaced-out/ui-design-system/compare/v0.1.26...v0.1.27) (2023-05-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* [@floating-ui](https://github.com/floating-ui) bump to `v0.24.0` ([#115](https://github.com/spaced-out/ui-design-system/issues/115)) ([3c44db3](https://github.com/spaced-out/ui-design-system/commit/3c44db3c0e12b8483fef08881fe6efc1e94ee721))
|
|
11
|
+
* **accessibility:** last tab out should close the menu for all composite components using menu ([#111](https://github.com/spaced-out/ui-design-system/issues/111)) ([b76a823](https://github.com/spaced-out/ui-design-system/commit/b76a82340478371de87b4cf02a58f9fdae30068f))
|
|
12
|
+
* floating ui migration ([#112](https://github.com/spaced-out/ui-design-system/issues/112)) ([85a1769](https://github.com/spaced-out/ui-design-system/commit/85a17695d4c54e091f8b77efbbd02b0b21444e60))
|
|
13
|
+
* moved [@floating-ui](https://github.com/floating-ui) to stable version 0.16.0 ([b287e6d](https://github.com/spaced-out/ui-design-system/commit/b287e6d526e9fe01e8e65702ccb79f6af1b3e230))
|
|
14
|
+
* storybook upgrade tokens revamp and menu changes to include search ([#114](https://github.com/spaced-out/ui-design-system/issues/114)) ([2e8a9df](https://github.com/spaced-out/ui-design-system/commit/2e8a9df5dd79eedc6490256083720dbbf2b56f6a))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add classnames support for tablerow and checkbox ([#116](https://github.com/spaced-out/ui-design-system/issues/116)) ([a159563](https://github.com/spaced-out/ui-design-system/commit/a159563a3c80e7244fb8240c5cf2ae2f0ce9fc37))
|
|
20
|
+
* changed modal styles ([892d328](https://github.com/spaced-out/ui-design-system/commit/892d3284dc2531df0744e9db95684f53a6740af1))
|
|
21
|
+
* chip icon external classnames support ([#113](https://github.com/spaced-out/ui-design-system/issues/113)) ([4ff43e4](https://github.com/spaced-out/ui-design-system/commit/4ff43e402e0937f9c137cb92ff6d3dba44998b63))
|
|
22
|
+
* collapsible card isopen bug ([#117](https://github.com/spaced-out/ui-design-system/issues/117)) ([0d31766](https://github.com/spaced-out/ui-design-system/commit/0d31766bb2164096e8d33985cb56acb5b2758ed9))
|
|
23
|
+
* tooltip fixes for [@floating-ui](https://github.com/floating-ui) bump ([7c16c44](https://github.com/spaced-out/ui-design-system/commit/7c16c44fd15fed26236da11007d678cabf58d1f0))
|
|
24
|
+
* updated docs ([3718bb8](https://github.com/spaced-out/ui-design-system/commit/3718bb8918549a194b941e85d4782ded75270451))
|
|
25
|
+
* updated dropdown docs ([4597dee](https://github.com/spaced-out/ui-design-system/commit/4597dee9a13cfd6f794871e83c69d7774bb0ad63))
|
|
26
|
+
|
|
5
27
|
### [0.1.26](https://github.com/spaced-out/ui-design-system/compare/v0.1.25...v0.1.26) (2023-05-03)
|
|
6
28
|
|
|
7
29
|
|
package/babel.config.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ButtonDropdown = exports.ANCHOR_POSITION_TYPE = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _react2 = require("@floating-ui/react");
|
|
9
9
|
var _size = require("../../styles/variables/_size");
|
|
10
10
|
var _space = require("../../styles/variables/_space");
|
|
11
11
|
var _classify = require("../../utils/classify");
|
|
@@ -51,14 +51,14 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
51
51
|
const {
|
|
52
52
|
x,
|
|
53
53
|
y,
|
|
54
|
-
|
|
55
|
-
floating,
|
|
54
|
+
refs,
|
|
56
55
|
strategy
|
|
57
|
-
} = (0,
|
|
56
|
+
} = (0, _react2.useFloating)({
|
|
57
|
+
open: true,
|
|
58
58
|
strategy: 'absolute',
|
|
59
59
|
placement: anchorPosition,
|
|
60
|
-
whileElementsMounted:
|
|
61
|
-
middleware: [(0,
|
|
60
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
61
|
+
middleware: [(0, _react2.shift)(), (0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
62
62
|
});
|
|
63
63
|
const onMenuToggle = isOpen => {
|
|
64
64
|
if (isOpen) {
|
|
@@ -94,7 +94,7 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
94
94
|
iconRightType: iconRightType,
|
|
95
95
|
disabled: disabled,
|
|
96
96
|
size: size,
|
|
97
|
-
ref:
|
|
97
|
+
ref: refs.setReference,
|
|
98
98
|
onClick: e => {
|
|
99
99
|
e.stopPropagation();
|
|
100
100
|
onOpen();
|
|
@@ -106,7 +106,7 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
106
106
|
}
|
|
107
107
|
}), children)), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
108
108
|
onClickCapture: cancelNext,
|
|
109
|
-
ref:
|
|
109
|
+
ref: refs.setFloating,
|
|
110
110
|
style: {
|
|
111
111
|
display: 'flex',
|
|
112
112
|
position: strategy,
|
|
@@ -123,7 +123,8 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
123
123
|
clickAway();
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
|
-
size: menu.size || size
|
|
126
|
+
size: menu.size || size,
|
|
127
|
+
onTabOut: clickAway
|
|
127
128
|
}))));
|
|
128
129
|
});
|
|
129
130
|
});
|
|
@@ -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 {sizeFluid} from '../../styles/variables/_size';
|
|
18
18
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
@@ -83,7 +83,8 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
83
83
|
const menuBtnRef = React.useRef(null);
|
|
84
84
|
const [isMenuOpen, setIsMenuOpen] = React.useState(false);
|
|
85
85
|
React.useImperativeHandle(forwardRef, () => menuBtnRef.current);
|
|
86
|
-
const {x, y,
|
|
86
|
+
const {x, y, refs, strategy} = useFloating({
|
|
87
|
+
open: true,
|
|
87
88
|
strategy: 'absolute',
|
|
88
89
|
placement: anchorPosition,
|
|
89
90
|
whileElementsMounted: autoUpdate,
|
|
@@ -135,7 +136,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
135
136
|
iconRightType={iconRightType}
|
|
136
137
|
disabled={disabled}
|
|
137
138
|
size={size}
|
|
138
|
-
ref={
|
|
139
|
+
ref={refs.setReference}
|
|
139
140
|
onClick={(e) => {
|
|
140
141
|
e.stopPropagation();
|
|
141
142
|
onOpen();
|
|
@@ -153,7 +154,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
153
154
|
{isOpen && menu && (
|
|
154
155
|
<div
|
|
155
156
|
onClickCapture={cancelNext}
|
|
156
|
-
ref={
|
|
157
|
+
ref={refs.setFloating}
|
|
157
158
|
style={{
|
|
158
159
|
display: 'flex',
|
|
159
160
|
position: strategy,
|
|
@@ -174,6 +175,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
174
175
|
}
|
|
175
176
|
}}
|
|
176
177
|
size={menu.size || size}
|
|
178
|
+
onTabOut={clickAway}
|
|
177
179
|
/>
|
|
178
180
|
</div>
|
|
179
181
|
)}
|
|
@@ -55,7 +55,7 @@ const Chip = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
55
55
|
}, classNames?.wrapper),
|
|
56
56
|
onClick: onClick
|
|
57
57
|
}), iconName && size !== 'small' && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
58
|
-
className: _ChipModule.default.chipIcon,
|
|
58
|
+
className: (0, _classify.classify)(_ChipModule.default.chipIcon, classNames?.icon),
|
|
59
59
|
name: iconName,
|
|
60
60
|
type: iconType,
|
|
61
61
|
size: "small"
|
|
@@ -10,7 +10,7 @@ import {Truncate} from '../Truncate';
|
|
|
10
10
|
import css from './Chip.module.css';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
13
|
+
type ClassNames = $ReadOnly<{wrapper?: string, icon?: string}>;
|
|
14
14
|
|
|
15
15
|
export const CHIP_SEMANTIC = Object.freeze({
|
|
16
16
|
primary: 'primary',
|
|
@@ -91,7 +91,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
|
|
|
91
91
|
>
|
|
92
92
|
{iconName && size !== 'small' && (
|
|
93
93
|
<Icon
|
|
94
|
-
className={css.chipIcon}
|
|
94
|
+
className={classify(css.chipIcon, classNames?.icon)}
|
|
95
95
|
name={iconName}
|
|
96
96
|
type={iconType}
|
|
97
97
|
size="small"
|
|
@@ -55,6 +55,9 @@ const CollapsibleCard = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
55
55
|
headerIconType = 'solid'
|
|
56
56
|
} = _ref3;
|
|
57
57
|
const [collapsibleCardIsOpen, setCollapsibleCardIsOpen] = React.useState(Boolean(isOpen));
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
setCollapsibleCardIsOpen(Boolean(isOpen));
|
|
60
|
+
}, [isOpen]);
|
|
58
61
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
62
|
"data-testid": "CollapsibleCard",
|
|
60
63
|
className: (0, _classify.default)(_CollapsibleCardModule.default.wrapper, classNames?.wrapper),
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.DialogHeader = exports.DialogFooter = exports.DialogBody = exports.Dialog = exports.DIALOG_SEMANTIC = void 0;
|
|
6
|
+
exports.DialogHeader = exports.DialogFooter = exports.DialogBody = exports.Dialog = exports.DIALOG_SEMANTIC = exports.BasicDialog = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _typography = require("../../types/typography");
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
+
var _Button = require("../Button");
|
|
10
11
|
var _Icon = require("../Icon");
|
|
11
12
|
var _Modal = require("../Modal");
|
|
12
13
|
var _DialogModule = _interopRequireDefault(require("./Dialog.module.css"));
|
|
@@ -138,4 +139,24 @@ const Dialog = _ref5 => {
|
|
|
138
139
|
iconName: iconName
|
|
139
140
|
}))), children);
|
|
140
141
|
};
|
|
141
|
-
exports.Dialog = Dialog;
|
|
142
|
+
exports.Dialog = Dialog;
|
|
143
|
+
const BasicDialog = _ref6 => {
|
|
144
|
+
let {
|
|
145
|
+
heading,
|
|
146
|
+
body,
|
|
147
|
+
confirmText,
|
|
148
|
+
abortText,
|
|
149
|
+
handleConfirm,
|
|
150
|
+
handleAbort,
|
|
151
|
+
...restDialogProps
|
|
152
|
+
} = _ref6;
|
|
153
|
+
return /*#__PURE__*/React.createElement(Dialog, restDialogProps, !!heading && /*#__PURE__*/React.createElement(DialogHeader, null, heading), !!body && /*#__PURE__*/React.createElement(DialogBody, null, body), /*#__PURE__*/React.createElement(DialogFooter, null, !!abortText && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
154
|
+
isFluid: true,
|
|
155
|
+
type: "tertiary",
|
|
156
|
+
onClick: handleAbort
|
|
157
|
+
}, abortText), !!confirmText && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
158
|
+
isFluid: true,
|
|
159
|
+
onClick: handleConfirm
|
|
160
|
+
}, confirmText)));
|
|
161
|
+
};
|
|
162
|
+
exports.BasicDialog = BasicDialog;
|
|
@@ -4,6 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
|
|
5
5
|
import {TEXT_COLORS} from '../../types/typography';
|
|
6
6
|
import classify from '../../utils/classify';
|
|
7
|
+
import {Button} from '../Button';
|
|
7
8
|
import {Icon} from '../Icon';
|
|
8
9
|
import type {ModalProps} from '../Modal';
|
|
9
10
|
import {Modal} from '../Modal';
|
|
@@ -51,6 +52,16 @@ export type DialogProps = {
|
|
|
51
52
|
iconName?: string,
|
|
52
53
|
};
|
|
53
54
|
|
|
55
|
+
export type BasicDialogProps = {
|
|
56
|
+
...DialogProps,
|
|
57
|
+
heading?: React.Node,
|
|
58
|
+
body?: React.Node,
|
|
59
|
+
confirmText?: string,
|
|
60
|
+
abortText?: string,
|
|
61
|
+
handleConfirm?: (event: SyntheticEvent<>) => mixed,
|
|
62
|
+
handleAbort?: (event: SyntheticEvent<>) => mixed,
|
|
63
|
+
};
|
|
64
|
+
|
|
54
65
|
const DialogIcon = ({
|
|
55
66
|
semantic,
|
|
56
67
|
iconName,
|
|
@@ -188,3 +199,30 @@ export const Dialog = ({
|
|
|
188
199
|
{children}
|
|
189
200
|
</Modal>
|
|
190
201
|
);
|
|
202
|
+
|
|
203
|
+
export const BasicDialog = ({
|
|
204
|
+
heading,
|
|
205
|
+
body,
|
|
206
|
+
confirmText,
|
|
207
|
+
abortText,
|
|
208
|
+
handleConfirm,
|
|
209
|
+
handleAbort,
|
|
210
|
+
...restDialogProps
|
|
211
|
+
}: BasicDialogProps): React.Node => (
|
|
212
|
+
<Dialog {...restDialogProps}>
|
|
213
|
+
{!!heading && <DialogHeader>{heading}</DialogHeader>}
|
|
214
|
+
{!!body && <DialogBody>{body}</DialogBody>}
|
|
215
|
+
<DialogFooter>
|
|
216
|
+
{!!abortText && (
|
|
217
|
+
<Button isFluid type="tertiary" onClick={handleAbort}>
|
|
218
|
+
{abortText}
|
|
219
|
+
</Button>
|
|
220
|
+
)}
|
|
221
|
+
{!!confirmText && (
|
|
222
|
+
<Button isFluid onClick={handleConfirm}>
|
|
223
|
+
{confirmText}
|
|
224
|
+
</Button>
|
|
225
|
+
)}
|
|
226
|
+
</DialogFooter>
|
|
227
|
+
</Dialog>
|
|
228
|
+
);
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Dropdown = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _react2 = require("@floating-ui/react");
|
|
9
9
|
var _color = require("../../styles/variables/_color");
|
|
10
10
|
var _size = require("../../styles/variables/_size");
|
|
11
11
|
var _space = require("../../styles/variables/_space");
|
|
@@ -34,14 +34,14 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
34
34
|
const {
|
|
35
35
|
x,
|
|
36
36
|
y,
|
|
37
|
-
|
|
38
|
-
floating,
|
|
37
|
+
refs,
|
|
39
38
|
strategy
|
|
40
|
-
} = (0,
|
|
39
|
+
} = (0, _react2.useFloating)({
|
|
40
|
+
open: true,
|
|
41
41
|
strategy: 'absolute',
|
|
42
42
|
placement: 'bottom-start',
|
|
43
|
-
whileElementsMounted:
|
|
44
|
-
middleware: [(0,
|
|
43
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
44
|
+
middleware: [(0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
45
45
|
});
|
|
46
46
|
const onMenuToggle = isOpen => {
|
|
47
47
|
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
@@ -60,7 +60,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
60
60
|
className: (0, _classify.classify)(_DropdownModule.default.dropdownContainer, classNames?.wrapper),
|
|
61
61
|
ref: dropdownRef
|
|
62
62
|
}, /*#__PURE__*/React.createElement(_Input.Input, _extends({}, inputProps, {
|
|
63
|
-
boxRef:
|
|
63
|
+
boxRef: refs.setReference,
|
|
64
64
|
size: size,
|
|
65
65
|
placeholder: placeholder,
|
|
66
66
|
value: dropdownInputText,
|
|
@@ -76,7 +76,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
76
76
|
ref: ref
|
|
77
77
|
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
78
78
|
onClickCapture: cancelNext,
|
|
79
|
-
ref:
|
|
79
|
+
ref: refs.setFloating,
|
|
80
80
|
style: {
|
|
81
81
|
position: strategy,
|
|
82
82
|
top: y ?? _space.spaceNone,
|
|
@@ -91,7 +91,8 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
91
91
|
clickAway();
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
size: menu.size || size
|
|
94
|
+
size: menu.size || size,
|
|
95
|
+
onTabOut: clickAway
|
|
95
96
|
}))));
|
|
96
97
|
});
|
|
97
98
|
});
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
offset,
|
|
11
11
|
// $FlowFixMe[untyped-import]
|
|
12
12
|
useFloating,
|
|
13
|
-
} from '@floating-ui/react
|
|
13
|
+
} from '@floating-ui/react';
|
|
14
14
|
|
|
15
15
|
import {colorBackgroundTertiary} from '../../styles/variables/_color';
|
|
16
16
|
import {sizeFluid} from '../../styles/variables/_size';
|
|
@@ -57,7 +57,8 @@ export const Dropdown: React$AbstractComponent<
|
|
|
57
57
|
ref,
|
|
58
58
|
): React.Node => {
|
|
59
59
|
const dropdownRef = React.useRef();
|
|
60
|
-
const {x, y,
|
|
60
|
+
const {x, y, refs, strategy} = useFloating({
|
|
61
|
+
open: true,
|
|
61
62
|
strategy: 'absolute',
|
|
62
63
|
placement: 'bottom-start',
|
|
63
64
|
whileElementsMounted: autoUpdate,
|
|
@@ -78,7 +79,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
78
79
|
>
|
|
79
80
|
<Input
|
|
80
81
|
{...inputProps}
|
|
81
|
-
boxRef={
|
|
82
|
+
boxRef={refs.setReference}
|
|
82
83
|
size={size}
|
|
83
84
|
placeholder={placeholder}
|
|
84
85
|
value={dropdownInputText}
|
|
@@ -95,7 +96,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
95
96
|
{isOpen && menu && (
|
|
96
97
|
<div
|
|
97
98
|
onClickCapture={cancelNext}
|
|
98
|
-
ref={
|
|
99
|
+
ref={refs.setFloating}
|
|
99
100
|
style={{
|
|
100
101
|
position: strategy,
|
|
101
102
|
top: y ?? spaceNone,
|
|
@@ -116,6 +117,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
116
117
|
}
|
|
117
118
|
}}
|
|
118
119
|
size={menu.size || size}
|
|
120
|
+
onTabOut={clickAway}
|
|
119
121
|
/>
|
|
120
122
|
</div>
|
|
121
123
|
)}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FocusManager = 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 _FocusManagerModule = _interopRequireDefault(require("./FocusManager.module.css"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -14,20 +14,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
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); }
|
|
15
15
|
const FocusManager = props => {
|
|
16
16
|
const {
|
|
17
|
-
|
|
17
|
+
refs,
|
|
18
18
|
context
|
|
19
|
-
} = (0,
|
|
19
|
+
} = (0, _react2.useFloating)({
|
|
20
|
+
open: true
|
|
21
|
+
});
|
|
20
22
|
const {
|
|
21
23
|
classNames,
|
|
22
24
|
children,
|
|
23
25
|
initialFocus = -1,
|
|
24
26
|
...restFloatingFocusManagerProps
|
|
25
27
|
} = props;
|
|
26
|
-
return /*#__PURE__*/React.createElement(
|
|
28
|
+
return /*#__PURE__*/React.createElement(_react2.FloatingFocusManager, _extends({
|
|
27
29
|
context: context,
|
|
28
30
|
initialFocus: initialFocus
|
|
29
31
|
}, restFloatingFocusManagerProps), /*#__PURE__*/React.createElement("div", {
|
|
30
|
-
ref:
|
|
32
|
+
ref: refs.setFloating,
|
|
31
33
|
"data-testid": "FocusManager",
|
|
32
34
|
className: (0, _classify.default)(_FocusManagerModule.default.wrapper, classNames?.wrapper)
|
|
33
35
|
}, children));
|
|
@@ -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
|
|
|
@@ -24,7 +24,7 @@ export type FocusManagerProps = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const FocusManager = (props: FocusManagerProps): React.Node => {
|
|
27
|
-
const {
|
|
27
|
+
const {refs, context} = useFloating({open: true});
|
|
28
28
|
const {
|
|
29
29
|
classNames,
|
|
30
30
|
children,
|
|
@@ -39,7 +39,7 @@ export const FocusManager = (props: FocusManagerProps): React.Node => {
|
|
|
39
39
|
{...restFloatingFocusManagerProps}
|
|
40
40
|
>
|
|
41
41
|
<div
|
|
42
|
-
ref={
|
|
42
|
+
ref={refs.setFloating}
|
|
43
43
|
data-testid="FocusManager"
|
|
44
44
|
className={classify(css.wrapper, classNames?.wrapper)}
|
|
45
45
|
>
|