@guardian/stand 0.0.15 → 0.0.17
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 +1 -0
- package/dist/TopBar.cjs +9 -3
- package/dist/TopBar.js +4 -1
- package/dist/components/avatar/Avatar.cjs +2 -2
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/button/styles.cjs +7 -4
- package/dist/components/button/styles.js +7 -4
- package/dist/components/byline/Byline.cjs +15 -15
- package/dist/components/favicon/Favicon.cjs +2 -2
- package/dist/components/icon-button/IconButton.cjs +4 -4
- package/dist/components/icon-button/IconButton.js +1 -1
- package/dist/components/icon-link-button/IconLinkButton.cjs +4 -4
- package/dist/components/icon-link-button/IconLinkButton.js +1 -1
- package/dist/components/link-button/LinkButton.cjs +1 -1
- package/dist/components/link-button/LinkButton.js +1 -1
- package/dist/components/menu/Menu.cjs +204 -0
- package/dist/components/menu/Menu.js +77 -0
- package/dist/components/menu/styles.cjs +104 -0
- package/dist/components/menu/styles.js +89 -0
- package/dist/components/tag-picker/TagTable.cjs +11 -11
- package/dist/components/topbar/TopBar.cjs +101 -0
- package/dist/components/topbar/TopBar.js +63 -0
- package/dist/components/topbar/styles.cjs +30 -0
- package/dist/components/topbar/styles.js +25 -0
- package/dist/components/topbar/topBarItem/TopBarItem.cjs +28 -0
- package/dist/components/topbar/topBarItem/TopBarItem.js +10 -0
- package/dist/components/topbar/topBarItem/styles.cjs +20 -0
- package/dist/components/topbar/topBarItem/styles.js +17 -0
- package/dist/components/topbar/topBarNavigation/TopBarNavigation.cjs +70 -0
- package/dist/components/topbar/topBarNavigation/TopBarNavigation.js +23 -0
- package/dist/components/topbar/topBarNavigation/styles.cjs +68 -0
- package/dist/components/topbar/topBarNavigation/styles.js +61 -0
- package/dist/components/topbar/{toolName → topBarToolName}/TopBarToolName.cjs +3 -2
- package/dist/components/topbar/topBarToolName/TopBarToolName.js +13 -0
- package/dist/index.cjs +4 -0
- package/dist/index.js +2 -0
- package/dist/menu.cjs +13 -0
- package/dist/menu.js +2 -0
- package/dist/styleD/build/css/base/typography.css +3 -3
- package/dist/styleD/build/css/component/TopBar.css +55 -1
- package/dist/styleD/build/css/component/avatar.css +1 -1
- package/dist/styleD/build/css/component/button.css +177 -255
- package/dist/styleD/build/css/component/favicon.css +1 -1
- package/dist/styleD/build/css/component/menu.css +83 -0
- package/dist/styleD/build/css/component/tagAutocomplete.css +1 -1
- package/dist/styleD/build/css/component/tagTable.css +1 -1
- package/dist/styleD/build/css/component/topBarItem.css +7 -0
- package/dist/styleD/build/css/component/userMenu.css +6 -6
- package/dist/styleD/build/css/semantic/colors.css +45 -46
- package/dist/styleD/build/css/semantic/shadow.css +7 -0
- package/dist/styleD/build/css/semantic/sizing.css +1 -0
- package/dist/styleD/build/css/semantic/typography.css +30 -30
- package/dist/styleD/build/typescript/base/typography.cjs +3 -3
- package/dist/styleD/build/typescript/base/typography.js +3 -3
- package/dist/styleD/build/typescript/component/TopBar.cjs +94 -0
- package/dist/styleD/build/typescript/component/TopBar.js +94 -0
- package/dist/styleD/build/typescript/component/button.cjs +5 -130
- package/dist/styleD/build/typescript/component/button.js +5 -130
- package/dist/styleD/build/typescript/component/menu.cjs +141 -0
- package/dist/styleD/build/typescript/component/menu.js +139 -0
- package/dist/styleD/build/typescript/semantic/colors.cjs +47 -52
- package/dist/styleD/build/typescript/semantic/colors.js +47 -52
- package/dist/styleD/build/typescript/semantic/shadow.cjs +7 -0
- package/dist/styleD/build/typescript/semantic/shadow.js +5 -0
- package/dist/styleD/build/typescript/semantic/sizing.cjs +1 -0
- package/dist/styleD/build/typescript/semantic/sizing.js +1 -0
- package/dist/types/TopBar.d.ts +12 -3
- package/dist/types/avatar.d.ts +1 -1
- package/dist/types/button.d.ts +1 -1
- package/dist/types/byline.d.ts +1 -1
- package/dist/types/components/avatar/styles.d.ts +2 -1
- package/dist/types/components/button/sandbox.d.ts +4 -4
- package/dist/types/components/button/styles.d.ts +2 -1
- package/dist/types/components/button/types.d.ts +1 -1
- package/dist/types/components/favicon/styles.d.ts +2 -1
- package/dist/types/components/icon/styles.d.ts +2 -1
- package/dist/types/components/icon-button/sandbox.d.ts +4 -4
- package/dist/types/components/icon-button/styles.d.ts +5 -129
- package/dist/types/components/icon-button/types.d.ts +1 -1
- package/dist/types/components/icon-link-button/sandbox.d.ts +4 -4
- package/dist/types/components/icon-link-button/styles.d.ts +5 -129
- package/dist/types/components/icon-link-button/types.d.ts +1 -1
- package/dist/types/components/link-button/sandbox.d.ts +4 -4
- package/dist/types/components/link-button/styles.d.ts +5 -129
- package/dist/types/components/link-button/types.d.ts +1 -1
- package/dist/types/components/menu/Menu.d.ts +7 -0
- package/dist/types/components/menu/sandbox.d.ts +5 -0
- package/dist/types/components/menu/styles.d.ts +28 -0
- package/dist/types/components/menu/types.d.ts +63 -0
- package/dist/types/components/topbar/TopBar.d.ts +8 -0
- package/dist/types/components/topbar/sandbox.d.ts +5 -0
- package/dist/types/components/topbar/styles.d.ts +9 -0
- package/dist/types/components/topbar/topBarItem/TopBarItem.d.ts +2 -0
- package/dist/types/components/topbar/topBarItem/sandbox.d.ts +5 -0
- package/dist/types/components/topbar/topBarItem/styles.d.ts +8 -0
- package/dist/types/components/topbar/topBarItem/types.d.ts +14 -0
- package/dist/types/components/topbar/topBarNavigation/TopBarNavigation.d.ts +2 -0
- package/dist/types/components/topbar/topBarNavigation/sandbox.d.ts +5 -0
- package/dist/types/components/topbar/topBarNavigation/styles.d.ts +12 -0
- package/dist/types/components/topbar/topBarNavigation/types.d.ts +44 -0
- package/dist/types/components/topbar/{toolName → topBarToolName}/styles.d.ts +2 -1
- package/dist/types/components/topbar/types.d.ts +3 -0
- package/dist/types/components/typography/styles.d.ts +2 -1
- package/dist/types/favicon.d.ts +1 -1
- package/dist/types/icon-button.d.ts +1 -1
- package/dist/types/icon-link-button.d.ts +1 -1
- package/dist/types/icon.d.ts +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/link-button.d.ts +1 -1
- package/dist/types/menu.d.ts +21 -0
- package/dist/types/styleD/build/typescript/base/typography.d.ts +3 -3
- package/dist/types/styleD/build/typescript/component/TopBar.d.ts +94 -0
- package/dist/types/styleD/build/typescript/component/button.d.ts +3 -128
- package/dist/types/styleD/build/typescript/component/menu.d.ts +141 -0
- package/dist/types/styleD/build/typescript/semantic/colors.d.ts +44 -49
- package/dist/types/styleD/build/typescript/semantic/shadow.d.ts +7 -0
- package/dist/types/styleD/build/typescript/semantic/sizing.d.ts +1 -0
- package/dist/types/styleD/stories/semantic/Shadow.d.ts +1 -0
- package/dist/types/typography.d.ts +1 -1
- package/dist/util/css/reset.css +10 -0
- package/dist/util/reset.css.cjs +1 -1
- package/dist/util/reset.css.js +1 -1
- package/package.json +30 -17
- package/dist/components/topbar/toolName/TopBarToolName.js +0 -12
- /package/dist/components/topbar/{toolName → topBarToolName}/styles.cjs +0 -0
- /package/dist/components/topbar/{toolName → topBarToolName}/styles.js +0 -0
- /package/dist/types/components/topbar/{toolName → topBarToolName}/TopBarToolName.d.ts +0 -0
- /package/dist/types/components/topbar/{toolName → topBarToolName}/sandbox.d.ts +0 -0
- /package/dist/types/components/topbar/{toolName → topBarToolName}/types.d.ts +0 -0
package/README.md
CHANGED
|
@@ -181,3 +181,4 @@ Matrix generation in CI uses the same JSON file in the workflow `../.github/work
|
|
|
181
181
|
- [Style Dictionary](https://guardian.github.io/stand/?path=/docs/style-dictionary--docs)
|
|
182
182
|
- [Architecture Decision Records](https://guardian.github.io/stand/?path=/docs/architecture-decision-records--docs)
|
|
183
183
|
- [Changelog](https://guardian.github.io/stand/?path=/docs/changelog--docs)
|
|
184
|
+
- [Vision](https://guardian.github.io/stand/?path=/docs/vision--docs)
|
package/dist/TopBar.cjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var TopBar$1 = require('./styleD/build/typescript/component/TopBar.cjs');
|
|
4
|
+
var TopBarToolName = require('./components/topbar/topBarToolName/TopBarToolName.cjs');
|
|
5
|
+
var TopBarNavigation = require('./components/topbar/topBarNavigation/TopBarNavigation.cjs');
|
|
6
|
+
var TopBarItem = require('./components/topbar/topBarItem/TopBarItem.cjs');
|
|
7
|
+
var TopBar = require('./components/topbar/TopBar.cjs');
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
|
|
11
|
+
exports.componentTopBar = TopBar$1.componentTopBar;
|
|
8
12
|
exports.TopBarToolName = TopBarToolName.TopBarToolName;
|
|
9
|
-
exports.
|
|
13
|
+
exports.TopBarNavigation = TopBarNavigation.TopBarNavigation;
|
|
14
|
+
exports.TopBarItem = TopBarItem.TopBarItem;
|
|
15
|
+
exports.TopBar = TopBar.TopBar;
|
package/dist/TopBar.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { TopBarToolName } from './components/topbar/toolName/TopBarToolName.js';
|
|
2
1
|
export { componentTopBar } from './styleD/build/typescript/component/TopBar.js';
|
|
2
|
+
export { TopBarToolName } from './components/topbar/topBarToolName/TopBarToolName.js';
|
|
3
|
+
export { TopBarNavigation } from './components/topbar/topBarNavigation/TopBarNavigation.js';
|
|
4
|
+
export { TopBarItem } from './components/topbar/topBarItem/TopBarItem.js';
|
|
5
|
+
export { TopBar } from './components/topbar/TopBar.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
6
6
|
var styles = require('./styles.cjs');
|
|
7
7
|
var types = require('./types.cjs');
|
|
@@ -22,7 +22,7 @@ function Avatar({
|
|
|
22
22
|
...props
|
|
23
23
|
}) {
|
|
24
24
|
const mergedTheme = mergeDeep.mergeDeep(styles.defaultAvatarTheme, theme);
|
|
25
|
-
const [imageError, setImageError] =
|
|
25
|
+
const [imageError, setImageError] = React.useState(false);
|
|
26
26
|
const handleImageError = () => {
|
|
27
27
|
setImageError(true);
|
|
28
28
|
};
|
|
@@ -4,7 +4,7 @@ import { mergeDeep } from '../../util/mergeDeep.js';
|
|
|
4
4
|
import { Icon } from '../icon/Icon.js';
|
|
5
5
|
import { buttonStyles, defaultButtonTheme } from './styles.js';
|
|
6
6
|
|
|
7
|
-
function Button({ variant = "
|
|
7
|
+
function Button({ variant = "primary", size = "md", theme = {}, cssOverrides, icon, ...props }) {
|
|
8
8
|
const mergedTheme = mergeDeep(defaultButtonTheme, theme);
|
|
9
9
|
const iconSize = size === "xs" ? "sm" : size;
|
|
10
10
|
return jsx(Button$1, { ...props, css: [buttonStyles(mergedTheme, { variant, size }, !!icon), cssOverrides], children: composeRenderProps(props.children, (children) => (
|
|
@@ -38,22 +38,25 @@ const buttonStyles = (theme, { size, variant }, hasIcon = false, isIconButton =
|
|
|
38
38
|
padding: 0;
|
|
39
39
|
`}
|
|
40
40
|
|
|
41
|
-
&[data-hovered] {
|
|
41
|
+
&[data-hovered], &:hover {
|
|
42
42
|
background: ${theme[variant].shared[":hover"].backgroundColor};
|
|
43
43
|
border: ${theme[variant].shared[":hover"].border};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
&[data-pressed]
|
|
46
|
+
&[data-pressed],
|
|
47
|
+
&:active {
|
|
47
48
|
background: ${theme[variant].shared[":active"].backgroundColor};
|
|
48
49
|
border: ${theme[variant].shared[":active"].border};
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
&[data-focus-visible]
|
|
52
|
+
&[data-focus-visible],
|
|
53
|
+
&:focus-visible {
|
|
52
54
|
outline: ${theme.shared[":focus-visible"].outline};
|
|
53
55
|
outline-offset: ${theme.shared[":focus-visible"]["outline-offset"]};
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
&[data-disabled]
|
|
58
|
+
&[data-disabled],
|
|
59
|
+
&:disabled {
|
|
57
60
|
cursor: ${theme.shared[":disabled"].cursor};
|
|
58
61
|
color: ${theme[variant].shared[":disabled"].color};
|
|
59
62
|
background: ${theme[variant].shared[":disabled"].backgroundColor};
|
|
@@ -36,22 +36,25 @@ const buttonStyles = (theme, { size, variant }, hasIcon = false, isIconButton =
|
|
|
36
36
|
padding: 0;
|
|
37
37
|
`}
|
|
38
38
|
|
|
39
|
-
&[data-hovered] {
|
|
39
|
+
&[data-hovered], &:hover {
|
|
40
40
|
background: ${theme[variant].shared[":hover"].backgroundColor};
|
|
41
41
|
border: ${theme[variant].shared[":hover"].border};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
&[data-pressed]
|
|
44
|
+
&[data-pressed],
|
|
45
|
+
&:active {
|
|
45
46
|
background: ${theme[variant].shared[":active"].backgroundColor};
|
|
46
47
|
border: ${theme[variant].shared[":active"].border};
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
&[data-focus-visible]
|
|
50
|
+
&[data-focus-visible],
|
|
51
|
+
&:focus-visible {
|
|
50
52
|
outline: ${theme.shared[":focus-visible"].outline};
|
|
51
53
|
outline-offset: ${theme.shared[":focus-visible"]["outline-offset"]};
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
&[data-disabled]
|
|
56
|
+
&[data-disabled],
|
|
57
|
+
&:disabled {
|
|
55
58
|
cursor: ${theme.shared[":disabled"].cursor};
|
|
56
59
|
color: ${theme[variant].shared[":disabled"].color};
|
|
57
60
|
background: ${theme[variant].shared[":disabled"].backgroundColor};
|
|
@@ -6,7 +6,7 @@ var prosemirrorDropcursor = require('prosemirror-dropcursor');
|
|
|
6
6
|
var prosemirrorHistory = require('prosemirror-history');
|
|
7
7
|
var prosemirrorState = require('prosemirror-state');
|
|
8
8
|
var prosemirrorView = require('prosemirror-view');
|
|
9
|
-
var
|
|
9
|
+
var React = require('react');
|
|
10
10
|
var lib = require('./lib.cjs');
|
|
11
11
|
var placeholder = require('./placeholder.cjs');
|
|
12
12
|
var plugins = require('./plugins.cjs');
|
|
@@ -26,15 +26,15 @@ const Byline = ({
|
|
|
26
26
|
searchContributors,
|
|
27
27
|
onBlur
|
|
28
28
|
}) => {
|
|
29
|
-
const editorRef =
|
|
30
|
-
const viewRef =
|
|
31
|
-
const dropdownRef =
|
|
32
|
-
const [currentText, setCurrentText] =
|
|
33
|
-
const [currentOptionIndex, setCurrentOptionIndex] =
|
|
34
|
-
const [taggedContributors, setTaggedContributors] =
|
|
35
|
-
const [currentDoc, setCurrentDoc] =
|
|
36
|
-
const [showDropdown, setShowDropdown] =
|
|
37
|
-
const isTypingFromStartRange =
|
|
29
|
+
const editorRef = React.useRef(null);
|
|
30
|
+
const viewRef = React.useRef(null);
|
|
31
|
+
const dropdownRef = React.useRef(null);
|
|
32
|
+
const [currentText, setCurrentText] = React.useState("");
|
|
33
|
+
const [currentOptionIndex, setCurrentOptionIndex] = React.useState(0);
|
|
34
|
+
const [taggedContributors, setTaggedContributors] = React.useState([]);
|
|
35
|
+
const [currentDoc, setCurrentDoc] = React.useState(null);
|
|
36
|
+
const [showDropdown, setShowDropdown] = React.useState(false);
|
|
37
|
+
const isTypingFromStartRange = React.useRef(
|
|
38
38
|
void 0
|
|
39
39
|
);
|
|
40
40
|
const trackTypingFromStart = (tr) => {
|
|
@@ -82,7 +82,7 @@ const Byline = ({
|
|
|
82
82
|
}
|
|
83
83
|
return selectedText.trim() !== "" && showDropdownBasedOnProps;
|
|
84
84
|
};
|
|
85
|
-
const [enterHit, setEnterHit] =
|
|
85
|
+
const [enterHit, setEnterHit] = React.useState(false);
|
|
86
86
|
const checkDropdownVisibility = () => {
|
|
87
87
|
if (dropdownRef.current?.checkVisibility) {
|
|
88
88
|
return dropdownRef.current.checkVisibility();
|
|
@@ -90,7 +90,7 @@ const Byline = ({
|
|
|
90
90
|
return dropdownRef.current?.offsetParent !== null;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
React.useEffect(() => {
|
|
94
94
|
if (!editorRef.current) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
@@ -219,7 +219,7 @@ const Byline = ({
|
|
|
219
219
|
viewRef.current?.destroy();
|
|
220
220
|
};
|
|
221
221
|
}, []);
|
|
222
|
-
|
|
222
|
+
React.useEffect(() => {
|
|
223
223
|
const numberOfOptions = taggedContributors.length + (allowUntaggedContributors ? 1 : 0);
|
|
224
224
|
if (numberOfOptions) {
|
|
225
225
|
if (currentOptionIndex < 0) {
|
|
@@ -242,7 +242,7 @@ const Byline = ({
|
|
|
242
242
|
taggedContributors.length,
|
|
243
243
|
allowUntaggedContributors
|
|
244
244
|
]);
|
|
245
|
-
|
|
245
|
+
React.useEffect(() => {
|
|
246
246
|
if (showDropdown && currentOptionIndex >= 0) {
|
|
247
247
|
const selectedOption = document.getElementById(
|
|
248
248
|
`contributor-option-${currentOptionIndex}`
|
|
@@ -255,7 +255,7 @@ const Byline = ({
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
}, [currentOptionIndex, showDropdown]);
|
|
258
|
-
|
|
258
|
+
React.useEffect(() => {
|
|
259
259
|
if (enterHit) {
|
|
260
260
|
if (allowUntaggedContributors && currentOptionIndex === taggedContributors.length) {
|
|
261
261
|
lib.addUntaggedContributor(
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
6
6
|
var Icon = require('../icon/Icon.cjs');
|
|
7
7
|
var styles = require('./styles.cjs');
|
|
8
8
|
|
|
9
9
|
const Favicon = (props) => {
|
|
10
10
|
const mergedTheme = mergeDeep.mergeDeep(styles.defaultFaviconTheme, props.theme ?? {});
|
|
11
|
-
const [imageError, setImageError] =
|
|
11
|
+
const [imageError, setImageError] = React.useState(false);
|
|
12
12
|
const handleImageError = () => {
|
|
13
13
|
setImageError(true);
|
|
14
14
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
7
7
|
var Icon = require('../icon/Icon.cjs');
|
|
8
8
|
var styles = require('./styles.cjs');
|
|
9
9
|
|
|
10
10
|
function IconButton({
|
|
11
|
-
variant = "
|
|
11
|
+
variant = "primary",
|
|
12
12
|
size = "md",
|
|
13
13
|
symbol,
|
|
14
14
|
ariaLabel,
|
|
@@ -17,8 +17,8 @@ function IconButton({
|
|
|
17
17
|
...props
|
|
18
18
|
}) {
|
|
19
19
|
const mergedTheme = mergeDeep.mergeDeep(styles.defaultIconButtonTheme, theme);
|
|
20
|
-
const buttonRef =
|
|
21
|
-
|
|
20
|
+
const buttonRef = React.useRef(null);
|
|
21
|
+
React.useEffect(() => {
|
|
22
22
|
if (buttonRef.current) {
|
|
23
23
|
buttonRef.current.title = ariaLabel;
|
|
24
24
|
}
|
|
@@ -5,7 +5,7 @@ import { mergeDeep } from '../../util/mergeDeep.js';
|
|
|
5
5
|
import { Icon } from '../icon/Icon.js';
|
|
6
6
|
import { iconButtonStyles, defaultIconButtonTheme } from './styles.js';
|
|
7
7
|
|
|
8
|
-
function IconButton({ variant = "
|
|
8
|
+
function IconButton({ variant = "primary", size = "md", symbol, ariaLabel, theme = {}, cssOverrides, ...props }) {
|
|
9
9
|
const mergedTheme = mergeDeep(defaultIconButtonTheme, theme);
|
|
10
10
|
const buttonRef = useRef(null);
|
|
11
11
|
useEffect(() => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
7
7
|
var Icon = require('../icon/Icon.cjs');
|
|
8
8
|
var styles = require('./styles.cjs');
|
|
9
9
|
|
|
10
10
|
function IconLinkButton({
|
|
11
|
-
variant = "
|
|
11
|
+
variant = "primary",
|
|
12
12
|
size = "md",
|
|
13
13
|
symbol,
|
|
14
14
|
ariaLabel,
|
|
@@ -17,8 +17,8 @@ function IconLinkButton({
|
|
|
17
17
|
...props
|
|
18
18
|
}) {
|
|
19
19
|
const mergedTheme = mergeDeep.mergeDeep(styles.defaultIconLinkButtonTheme, theme);
|
|
20
|
-
const linkRef =
|
|
21
|
-
|
|
20
|
+
const linkRef = React.useRef(null);
|
|
21
|
+
React.useEffect(() => {
|
|
22
22
|
if (linkRef.current) {
|
|
23
23
|
linkRef.current.title = ariaLabel;
|
|
24
24
|
}
|
|
@@ -5,7 +5,7 @@ import { mergeDeep } from '../../util/mergeDeep.js';
|
|
|
5
5
|
import { Icon } from '../icon/Icon.js';
|
|
6
6
|
import { iconLinkButtonStyles, defaultIconLinkButtonTheme } from './styles.js';
|
|
7
7
|
|
|
8
|
-
function IconLinkButton({ variant = "
|
|
8
|
+
function IconLinkButton({ variant = "primary", size = "md", symbol, ariaLabel, theme = {}, cssOverrides, ...props }) {
|
|
9
9
|
const mergedTheme = mergeDeep(defaultIconLinkButtonTheme, theme);
|
|
10
10
|
const linkRef = useRef(null);
|
|
11
11
|
useEffect(() => {
|
|
@@ -4,7 +4,7 @@ import { mergeDeep } from '../../util/mergeDeep.js';
|
|
|
4
4
|
import { Icon } from '../icon/Icon.js';
|
|
5
5
|
import { linkButtonStyles, defaultLinkButtonTheme } from './styles.js';
|
|
6
6
|
|
|
7
|
-
function LinkButton({ variant = "
|
|
7
|
+
function LinkButton({ variant = "primary", size = "md", theme = {}, cssOverrides, icon, ...props }) {
|
|
8
8
|
const mergedTheme = mergeDeep(defaultLinkButtonTheme, theme);
|
|
9
9
|
const iconSize = size === "xs" ? "sm" : size;
|
|
10
10
|
return jsx(Link, { ...props, css: [
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
4
|
+
var focus = require('@react-aria/focus');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var mergeDeep = require('../../util/mergeDeep.cjs');
|
|
8
|
+
var styles = require('./styles.cjs');
|
|
9
|
+
var Icon = require('../icon/Icon.cjs');
|
|
10
|
+
|
|
11
|
+
function Popover({
|
|
12
|
+
size = "md",
|
|
13
|
+
children,
|
|
14
|
+
theme = {},
|
|
15
|
+
cssOverrides,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultMenuPopoverTheme, theme);
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
20
|
+
reactAriaComponents.Popover,
|
|
21
|
+
{
|
|
22
|
+
css: [styles.menuPopoverStyles(mergedTheme, { size }), cssOverrides],
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function MenuSeparator({
|
|
29
|
+
theme = {},
|
|
30
|
+
cssOverrides,
|
|
31
|
+
...props
|
|
32
|
+
}) {
|
|
33
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultMenuSeparatorTheme, theme);
|
|
34
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
35
|
+
reactAriaComponents.Separator,
|
|
36
|
+
{
|
|
37
|
+
orientation: "horizontal",
|
|
38
|
+
css: [styles.menuSeparatorStyles(mergedTheme), cssOverrides],
|
|
39
|
+
...props
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function MenuToggle({ children }) {
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
45
|
+
}
|
|
46
|
+
function MenuSection({
|
|
47
|
+
name,
|
|
48
|
+
size = "md",
|
|
49
|
+
theme = {},
|
|
50
|
+
cssOverrides,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}) {
|
|
54
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultMenuSectionTheme, theme);
|
|
55
|
+
const items = [];
|
|
56
|
+
React.Children.forEach(children, (child, i) => {
|
|
57
|
+
if (!React.isValidElement(child)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (child.type === MenuItem) {
|
|
61
|
+
items.push(
|
|
62
|
+
React.cloneElement(child, {
|
|
63
|
+
size,
|
|
64
|
+
key: `${child.key}-${i}`
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.MenuSection, { css: [cssOverrides], ...props, children: [
|
|
70
|
+
name && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Header, { css: styles.menuSectionHeaderStyles(mergedTheme, { size }), children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: name }) }),
|
|
71
|
+
items
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
function MenuItem({
|
|
75
|
+
label,
|
|
76
|
+
description,
|
|
77
|
+
aside,
|
|
78
|
+
icon,
|
|
79
|
+
size = "md",
|
|
80
|
+
theme = {},
|
|
81
|
+
cssOverrides,
|
|
82
|
+
...props
|
|
83
|
+
}) {
|
|
84
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultMenuItemTheme, theme);
|
|
85
|
+
const textValue = props.textValue ?? (typeof label === "string" ? label : void 0);
|
|
86
|
+
const { isFocusVisible, focusProps } = focus.useFocusRing();
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
reactAriaComponents.MenuItem,
|
|
89
|
+
{
|
|
90
|
+
...focusProps,
|
|
91
|
+
css: [
|
|
92
|
+
styles.menuItemStyles(mergedTheme, { description }, isFocusVisible),
|
|
93
|
+
cssOverrides
|
|
94
|
+
],
|
|
95
|
+
...props,
|
|
96
|
+
textValue,
|
|
97
|
+
children: ({ isSelected, selectionMode }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
98
|
+
icon && selectionMode === "none" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
+
Icon.Icon,
|
|
100
|
+
{
|
|
101
|
+
size,
|
|
102
|
+
cssOverrides: styles.menuItemIconStyles(mergedTheme, { size }),
|
|
103
|
+
children: icon
|
|
104
|
+
}
|
|
105
|
+
) : null,
|
|
106
|
+
isSelected && selectionMode === "multiple" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
Icon.Icon,
|
|
108
|
+
{
|
|
109
|
+
size,
|
|
110
|
+
symbol: "check_box",
|
|
111
|
+
cssOverrides: styles.menuItemIconStyles(mergedTheme, { size })
|
|
112
|
+
}
|
|
113
|
+
) : null,
|
|
114
|
+
!isSelected && selectionMode === "multiple" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
115
|
+
Icon.Icon,
|
|
116
|
+
{
|
|
117
|
+
size,
|
|
118
|
+
symbol: "check_box_outline_blank",
|
|
119
|
+
cssOverrides: styles.menuItemIconStyles(mergedTheme, { size })
|
|
120
|
+
}
|
|
121
|
+
) : null,
|
|
122
|
+
isSelected && selectionMode === "single" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
123
|
+
Icon.Icon,
|
|
124
|
+
{
|
|
125
|
+
size,
|
|
126
|
+
symbol: "radio_button_checked",
|
|
127
|
+
cssOverrides: styles.menuItemIconStyles(mergedTheme, { size })
|
|
128
|
+
}
|
|
129
|
+
) : null,
|
|
130
|
+
!isSelected && selectionMode === "single" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
+
Icon.Icon,
|
|
132
|
+
{
|
|
133
|
+
size,
|
|
134
|
+
symbol: "radio_button_unchecked",
|
|
135
|
+
cssOverrides: styles.menuItemIconStyles(mergedTheme, { size })
|
|
136
|
+
}
|
|
137
|
+
) : null,
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.menuItemLabelStyles(mergedTheme), children: label }),
|
|
139
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.menuItemDescriptionStyles(mergedTheme), children: description }),
|
|
140
|
+
aside && /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.menuItemAsideStyles(mergedTheme), children: aside })
|
|
141
|
+
] })
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
function Menu({
|
|
146
|
+
theme = {},
|
|
147
|
+
size = "md",
|
|
148
|
+
popoverProps,
|
|
149
|
+
menuTriggerProps,
|
|
150
|
+
children,
|
|
151
|
+
cssOverrides,
|
|
152
|
+
...props
|
|
153
|
+
}) {
|
|
154
|
+
const mergedTheme = mergeDeep.mergeDeep(styles.defaultMenuTheme, theme);
|
|
155
|
+
let trigger = null;
|
|
156
|
+
const menu = [];
|
|
157
|
+
React.Children.forEach(children, (child, i) => {
|
|
158
|
+
if (!React.isValidElement(child)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (child.type === MenuToggle) {
|
|
162
|
+
trigger ?? (trigger = child);
|
|
163
|
+
} else if (child.type === MenuItem) {
|
|
164
|
+
menu.push(
|
|
165
|
+
React.cloneElement(child, {
|
|
166
|
+
size,
|
|
167
|
+
key: `${child.key}-${i}`
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
} else if (child.type === MenuSection) {
|
|
171
|
+
menu.push(
|
|
172
|
+
React.cloneElement(child, {
|
|
173
|
+
size,
|
|
174
|
+
key: `${child.key}-${i}`
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
} else if (child.type === MenuSeparator) {
|
|
178
|
+
menu.push(
|
|
179
|
+
React.cloneElement(child, {
|
|
180
|
+
key: `${child.key}-${i}`
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.MenuTrigger, { ...menuTriggerProps, children: [
|
|
186
|
+
trigger,
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
+
Popover,
|
|
189
|
+
{
|
|
190
|
+
containerPadding: 0,
|
|
191
|
+
placement: "bottom start",
|
|
192
|
+
size,
|
|
193
|
+
...popoverProps,
|
|
194
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Menu, { css: [styles.menuStyles(mergedTheme), cssOverrides], ...props, children: menu })
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
] });
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exports.Menu = Menu;
|
|
201
|
+
exports.MenuItem = MenuItem;
|
|
202
|
+
exports.MenuSection = MenuSection;
|
|
203
|
+
exports.MenuSeparator = MenuSeparator;
|
|
204
|
+
exports.MenuToggle = MenuToggle;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import { useFocusRing } from '@react-aria/focus';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { MenuTrigger, Menu as Menu$1, MenuItem as MenuItem$1, MenuSection as MenuSection$1, Header, Separator, Popover as Popover$1 } from 'react-aria-components';
|
|
5
|
+
import { mergeDeep } from '../../util/mergeDeep.js';
|
|
6
|
+
import { menuStyles, menuItemIconStyles, menuItemLabelStyles, menuItemDescriptionStyles, menuItemAsideStyles, menuItemStyles, menuSectionHeaderStyles, menuSeparatorStyles, defaultMenuPopoverTheme, menuPopoverStyles, defaultMenuSeparatorTheme, defaultMenuSectionTheme, defaultMenuItemTheme, defaultMenuTheme } from './styles.js';
|
|
7
|
+
import { Icon } from '../icon/Icon.js';
|
|
8
|
+
|
|
9
|
+
function Popover({ size = "md", children, theme = {}, cssOverrides, ...props }) {
|
|
10
|
+
const mergedTheme = mergeDeep(defaultMenuPopoverTheme, theme);
|
|
11
|
+
return jsx(Popover$1, { css: [menuPopoverStyles(mergedTheme, { size }), cssOverrides], ...props, children });
|
|
12
|
+
}
|
|
13
|
+
function MenuSeparator({ theme = {}, cssOverrides, ...props }) {
|
|
14
|
+
const mergedTheme = mergeDeep(defaultMenuSeparatorTheme, theme);
|
|
15
|
+
return jsx(Separator, { orientation: "horizontal", css: [menuSeparatorStyles(mergedTheme), cssOverrides], ...props });
|
|
16
|
+
}
|
|
17
|
+
function MenuToggle({ children }) {
|
|
18
|
+
return jsx(Fragment, { children });
|
|
19
|
+
}
|
|
20
|
+
function MenuSection({ name, size = "md", theme = {}, cssOverrides, children, ...props }) {
|
|
21
|
+
const mergedTheme = mergeDeep(defaultMenuSectionTheme, theme);
|
|
22
|
+
const items = [];
|
|
23
|
+
React.Children.forEach(children, (child, i) => {
|
|
24
|
+
if (!React.isValidElement(child)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (child.type === MenuItem) {
|
|
28
|
+
items.push(React.cloneElement(child, {
|
|
29
|
+
size,
|
|
30
|
+
key: `${child.key}-${i}`
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return jsxs(MenuSection$1, { css: [cssOverrides], ...props, children: [name && jsx(Header, { css: menuSectionHeaderStyles(mergedTheme, { size }), children: jsx("span", { children: name }) }), items] });
|
|
35
|
+
}
|
|
36
|
+
function MenuItem({ label, description, aside, icon, size = "md", theme = {}, cssOverrides, ...props }) {
|
|
37
|
+
const mergedTheme = mergeDeep(defaultMenuItemTheme, theme);
|
|
38
|
+
const textValue = props.textValue ?? (typeof label === "string" ? label : void 0);
|
|
39
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
40
|
+
return jsx(
|
|
41
|
+
MenuItem$1,
|
|
42
|
+
{ ...focusProps, css: [
|
|
43
|
+
menuItemStyles(mergedTheme, { description }, isFocusVisible),
|
|
44
|
+
cssOverrides
|
|
45
|
+
], ...props, textValue, children: ({ isSelected, selectionMode }) => jsxs(Fragment, { children: [icon && selectionMode === "none" ? jsx(Icon, { size, cssOverrides: menuItemIconStyles(mergedTheme, { size }), children: icon }) : null, isSelected && selectionMode === "multiple" ? jsx(Icon, { size, symbol: "check_box", cssOverrides: menuItemIconStyles(mergedTheme, { size }) }) : null, !isSelected && selectionMode === "multiple" ? jsx(Icon, { size, symbol: "check_box_outline_blank", cssOverrides: menuItemIconStyles(mergedTheme, { size }) }) : null, isSelected && selectionMode === "single" ? jsx(Icon, { size, symbol: "radio_button_checked", cssOverrides: menuItemIconStyles(mergedTheme, { size }) }) : null, !isSelected && selectionMode === "single" ? jsx(Icon, { size, symbol: "radio_button_unchecked", cssOverrides: menuItemIconStyles(mergedTheme, { size }) }) : null, jsx("div", { css: menuItemLabelStyles(mergedTheme), children: label }), description && jsx("div", { css: menuItemDescriptionStyles(mergedTheme), children: description }), aside && jsx("div", { css: menuItemAsideStyles(mergedTheme), children: aside })] }) }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function Menu({ theme = {}, size = "md", popoverProps, menuTriggerProps, children, cssOverrides, ...props }) {
|
|
49
|
+
const mergedTheme = mergeDeep(defaultMenuTheme, theme);
|
|
50
|
+
let trigger = null;
|
|
51
|
+
const menu = [];
|
|
52
|
+
React.Children.forEach(children, (child, i) => {
|
|
53
|
+
if (!React.isValidElement(child)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (child.type === MenuToggle) {
|
|
57
|
+
trigger ?? (trigger = child);
|
|
58
|
+
} else if (child.type === MenuItem) {
|
|
59
|
+
menu.push(React.cloneElement(child, {
|
|
60
|
+
size,
|
|
61
|
+
key: `${child.key}-${i}`
|
|
62
|
+
}));
|
|
63
|
+
} else if (child.type === MenuSection) {
|
|
64
|
+
menu.push(React.cloneElement(child, {
|
|
65
|
+
size,
|
|
66
|
+
key: `${child.key}-${i}`
|
|
67
|
+
}));
|
|
68
|
+
} else if (child.type === MenuSeparator) {
|
|
69
|
+
menu.push(React.cloneElement(child, {
|
|
70
|
+
key: `${child.key}-${i}`
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return jsxs(MenuTrigger, { ...menuTriggerProps, children: [trigger, jsx(Popover, { containerPadding: 0, placement: "bottom start", size, ...popoverProps, children: jsx(Menu$1, { css: [menuStyles(mergedTheme), cssOverrides], ...props, children: menu }) })] });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { Menu, MenuItem, MenuSection, MenuSeparator, MenuToggle };
|