@common-origin/design-system 2.23.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/client.js +2219 -1026
- package/dist/client.js.map +1 -1
- package/dist/components/atoms/Badge/Badge.d.mts +5 -12
- package/dist/components/atoms/Badge/Badge.d.ts +5 -12
- package/dist/components/atoms/Badge/Badge.mjs +0 -7
- package/dist/components/atoms/Badge/index.d.mts +1 -1
- package/dist/components/atoms/Badge/index.d.ts +1 -1
- package/dist/components/atoms/Box/Box.d.mts +22 -34
- package/dist/components/atoms/Box/Box.d.ts +22 -34
- package/dist/components/atoms/Box/Box.mjs +8 -11
- package/dist/components/atoms/Button/Button.d.mts +1 -4
- package/dist/components/atoms/Button/Button.d.ts +1 -4
- package/dist/components/atoms/Button/Button.mjs +3 -10
- package/dist/components/atoms/CategoryLabel/CategoryLabel.d.mts +4 -12
- package/dist/components/atoms/CategoryLabel/CategoryLabel.d.ts +4 -12
- package/dist/components/atoms/CategoryLabel/CategoryLabel.mjs +5 -16
- package/dist/components/atoms/Chip/Chip.d.mts +8 -20
- package/dist/components/atoms/Chip/Chip.d.ts +8 -20
- package/dist/components/atoms/Chip/Chip.mjs +20 -46
- package/dist/components/atoms/Chip/Chip.mjs.map +1 -1
- package/dist/components/atoms/Chip/FilterChip.d.mts +22 -10
- package/dist/components/atoms/Chip/FilterChip.d.ts +22 -10
- package/dist/components/atoms/Chip/FilterChip.mjs +66 -6
- package/dist/components/atoms/Chip/FilterChip.mjs.map +1 -1
- package/dist/components/atoms/Chip/InputChip.mjs +4 -6
- package/dist/components/atoms/Chip/InputChip.mjs.map +1 -1
- package/dist/components/atoms/Chip/index.d.mts +0 -1
- package/dist/components/atoms/Chip/index.d.ts +0 -1
- package/dist/components/atoms/Chip/shared/types.d.mts +9 -19
- package/dist/components/atoms/Chip/shared/types.d.ts +9 -19
- package/dist/components/atoms/Chip/shared/utils.d.mts +3 -3
- package/dist/components/atoms/Chip/shared/utils.d.ts +3 -3
- package/dist/components/atoms/Chip/shared/utils.mjs +4 -8
- package/dist/components/atoms/Chip/shared/utils.mjs.map +1 -1
- package/dist/components/atoms/DateFormatter/DateFormatter.d.mts +2 -5
- package/dist/components/atoms/DateFormatter/DateFormatter.d.ts +2 -5
- package/dist/components/atoms/DateFormatter/DateFormatter.mjs +0 -1
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs +1 -4
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs.map +1 -1
- package/dist/components/atoms/StatusLabel/StatusLabelBase.d.mts +5 -7
- package/dist/components/atoms/StatusLabel/StatusLabelBase.d.ts +5 -7
- package/dist/components/atoms/StatusLabel/StatusLabelBase.mjs +10 -12
- package/dist/components/atoms/Tag/Tag.d.mts +2 -4
- package/dist/components/atoms/Tag/Tag.d.ts +2 -4
- package/dist/components/atoms/Tag/Tag.mjs +0 -24
- package/dist/components/atoms/Tooltip/Tooltip.d.mts +41 -0
- package/dist/components/atoms/Tooltip/Tooltip.d.ts +41 -0
- package/dist/components/atoms/Tooltip/Tooltip.mjs +204 -0
- package/dist/components/atoms/Tooltip/Tooltip.mjs.map +1 -0
- package/dist/components/atoms/Tooltip/index.d.mts +2 -0
- package/dist/components/atoms/Tooltip/index.d.ts +2 -0
- package/dist/components/atoms/index.d.mts +1 -2
- package/dist/components/atoms/index.d.ts +1 -2
- package/dist/components/index.d.mts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/layout/GridSystem/GridSystem.d.mts +23 -18
- package/dist/components/layout/GridSystem/GridSystem.d.ts +23 -18
- package/dist/components/layout/GridSystem/GridSystem.mjs +7 -5
- package/dist/components/molecules/ActionSheet/ActionSheet.mjs +1 -0
- package/dist/components/molecules/AgentInput/AgentInput.d.mts +5 -0
- package/dist/components/molecules/AgentInput/AgentInput.d.ts +5 -0
- package/dist/components/molecules/AgentInput/AgentInput.mjs +1 -1
- package/dist/components/molecules/Alert/Alert.d.mts +1 -9
- package/dist/components/molecules/Alert/Alert.d.ts +1 -9
- package/dist/components/molecules/Alert/Alert.mjs +14 -27
- package/dist/components/molecules/ChipGroup/ChipGroup.d.mts +0 -1
- package/dist/components/molecules/ChipGroup/ChipGroup.d.ts +0 -1
- package/dist/components/molecules/ChipGroup/ChipGroup.mjs +2 -6
- package/dist/components/molecules/DateGroup/DateGroup.d.mts +1 -2
- package/dist/components/molecules/DateGroup/DateGroup.d.ts +1 -2
- package/dist/components/molecules/List/List.d.mts +2 -0
- package/dist/components/molecules/List/List.d.ts +2 -0
- package/dist/components/molecules/List/ListItem.d.mts +2 -0
- package/dist/components/molecules/List/ListItem.d.ts +2 -0
- package/dist/components/molecules/List/ListItem.mjs +5 -5
- package/dist/components/molecules/Menu/Menu.d.mts +117 -0
- package/dist/components/molecules/Menu/Menu.d.ts +117 -0
- package/dist/components/molecules/Menu/Menu.mjs +473 -0
- package/dist/components/molecules/Menu/Menu.mjs.map +1 -0
- package/dist/components/molecules/Menu/index.d.mts +2 -0
- package/dist/components/molecules/Menu/index.d.ts +2 -0
- package/dist/components/molecules/Modal/Modal.d.mts +0 -1
- package/dist/components/molecules/Modal/Modal.d.ts +0 -1
- package/dist/components/molecules/SearchField/SearchField.mjs +2 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavContext.d.mts +13 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavContext.d.ts +13 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavContext.mjs +13 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavContext.mjs.map +1 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavItem.d.mts +43 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavItem.d.ts +43 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavItem.mjs +148 -0
- package/dist/components/molecules/SidebarNavItem/SidebarNavItem.mjs.map +1 -0
- package/dist/components/molecules/SidebarNavItem/index.d.mts +2 -0
- package/dist/components/molecules/SidebarNavItem/index.d.ts +2 -0
- package/dist/components/molecules/SidebarNavSection/SidebarNavSection.d.mts +36 -0
- package/dist/components/molecules/SidebarNavSection/SidebarNavSection.d.ts +36 -0
- package/dist/components/molecules/SidebarNavSection/SidebarNavSection.mjs +188 -0
- package/dist/components/molecules/SidebarNavSection/SidebarNavSection.mjs.map +1 -0
- package/dist/components/molecules/SidebarNavSection/index.d.mts +2 -0
- package/dist/components/molecules/SidebarNavSection/index.d.ts +2 -0
- package/dist/components/molecules/TabBar/TabBar.d.mts +0 -13
- package/dist/components/molecules/TabBar/TabBar.d.ts +0 -13
- package/dist/components/molecules/TabBar/TabBar.mjs +2 -4
- package/dist/components/molecules/TabBar/index.d.mts +1 -1
- package/dist/components/molecules/TabBar/index.d.ts +1 -1
- package/dist/components/molecules/TransactionListItem/TransactionListItem.mjs +1 -1
- package/dist/components/molecules/WorkspaceSwitcher/WorkspaceSwitcher.d.mts +39 -0
- package/dist/components/molecules/WorkspaceSwitcher/WorkspaceSwitcher.d.ts +39 -0
- package/dist/components/molecules/WorkspaceSwitcher/WorkspaceSwitcher.mjs +131 -0
- package/dist/components/molecules/WorkspaceSwitcher/WorkspaceSwitcher.mjs.map +1 -0
- package/dist/components/molecules/WorkspaceSwitcher/index.d.mts +2 -0
- package/dist/components/molecules/WorkspaceSwitcher/index.d.ts +2 -0
- package/dist/components/molecules/index.d.mts +4 -1
- package/dist/components/molecules/index.d.ts +4 -1
- package/dist/components/organisms/SidebarNav/SidebarNav.d.mts +52 -0
- package/dist/components/organisms/SidebarNav/SidebarNav.d.ts +52 -0
- package/dist/components/organisms/SidebarNav/SidebarNav.mjs +235 -0
- package/dist/components/organisms/SidebarNav/SidebarNav.mjs.map +1 -0
- package/dist/components/organisms/SidebarNav/index.d.mts +2 -0
- package/dist/components/organisms/SidebarNav/index.d.ts +2 -0
- package/dist/components/organisms/index.d.mts +1 -0
- package/dist/components/organisms/index.d.ts +1 -0
- package/dist/data.js +72 -565
- package/dist/data.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/lib/floatingPosition.d.mts +43 -0
- package/dist/lib/floatingPosition.d.ts +43 -0
- package/dist/lib/floatingPosition.mjs +86 -0
- package/dist/lib/floatingPosition.mjs.map +1 -0
- package/dist/lib/keyboardFocus.d.mts +6 -0
- package/dist/lib/keyboardFocus.d.ts +6 -0
- package/dist/lib/keyboardFocus.mjs +17 -0
- package/dist/lib/keyboardFocus.mjs.map +1 -0
- package/dist/lib/tokenAliases.d.mts +11 -11
- package/dist/lib/tokenAliases.d.ts +11 -11
- package/dist/lib/tokenAliases.mjs +13 -88
- package/dist/lib/tokenAliases.mjs.map +1 -1
- package/dist/lib/useFloatingLayer.d.mts +25 -0
- package/dist/lib/useFloatingLayer.d.ts +25 -0
- package/dist/lib/useFloatingLayer.mjs +86 -0
- package/dist/lib/useFloatingLayer.mjs.map +1 -0
- package/dist/styles/icons.json +30 -1
- package/dist/styles/icons.json.mjs +34 -3
- package/dist/styles/icons.json.mjs.map +1 -1
- package/dist/styles/tokens.d.mts +179 -2485
- package/dist/styles/tokens.d.ts +179 -2485
- package/dist/styles/tokens.json +39 -563
- package/dist/styles/tokens.json.mjs +39 -563
- package/dist/styles/tokens.json.mjs.map +1 -1
- package/dist/tokens/index.js +39 -563
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/index.mjs +39 -563
- package/dist/tokens/index.mjs.map +1 -1
- package/dist/tokens/styles/tokens.d.mts +179 -2485
- package/dist/tokens/styles/tokens.d.ts +179 -2485
- package/dist/tokens.css +41 -493
- package/dist/types/icons.d.mts +1 -1
- package/dist/types/icons.d.ts +1 -1
- package/dist/types/icons.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/components/atoms/CategoryBadge/CategoryBadge.d.mts +0 -29
- package/dist/components/atoms/CategoryBadge/CategoryBadge.d.ts +0 -29
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs +0 -29
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs.map +0 -1
- package/dist/components/atoms/CategoryBadge/index.d.mts +0 -2
- package/dist/components/atoms/CategoryBadge/index.d.ts +0 -2
- package/dist/components/atoms/Chip/BooleanChip.d.mts +0 -28
- package/dist/components/atoms/Chip/BooleanChip.d.ts +0 -28
- package/dist/components/atoms/Chip/BooleanChip.mjs +0 -76
- package/dist/components/atoms/Chip/BooleanChip.mjs.map +0 -1
- package/dist/components/atoms/StatusBadge/StatusBadge.d.mts +0 -24
- package/dist/components/atoms/StatusBadge/StatusBadge.d.ts +0 -24
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs +0 -18
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs.map +0 -1
- package/dist/components/atoms/StatusBadge/index.d.mts +0 -2
- package/dist/components/atoms/StatusBadge/index.d.ts +0 -2
- package/dist/components/molecules/PageTitle/PageTitle.d.mts +0 -21
- package/dist/components/molecules/PageTitle/PageTitle.d.ts +0 -21
- package/dist/components/molecules/PageTitle/PageTitle.mjs +0 -77
- package/dist/components/molecules/PageTitle/PageTitle.mjs.map +0 -1
- package/dist/components/molecules/PageTitle/index.d.mts +0 -1
- package/dist/components/molecules/PageTitle/index.d.ts +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FloatingAlign, type FloatingSide } from '../../../lib/floatingPosition';
|
|
3
|
+
export type MenuSide = FloatingSide;
|
|
4
|
+
export type MenuAlign = FloatingAlign;
|
|
5
|
+
export interface MenuProps {
|
|
6
|
+
/**
|
|
7
|
+
* The element that opens the menu, such as a Button or IconButton. Menu gives it
|
|
8
|
+
* `aria-haspopup`, `aria-expanded` and `aria-controls`, and the menu takes its name from it.
|
|
9
|
+
*/
|
|
10
|
+
trigger: React.ReactElement;
|
|
11
|
+
/** `MenuItem`, `MenuItemRadio`, `MenuItemCheckbox`, `MenuGroup` and `MenuDivider` */
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/** Whether the menu is open (controlled). Use with `onOpenChange`. */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the menu starts open (uncontrolled).
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
/** Called when the menu opens or closes */
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* The side of the trigger it opens on. It flips when there's no room.
|
|
24
|
+
* @default 'bottom'
|
|
25
|
+
*/
|
|
26
|
+
side?: MenuSide;
|
|
27
|
+
/**
|
|
28
|
+
* Where it lines up along the trigger's edge.
|
|
29
|
+
* @default 'start'
|
|
30
|
+
*/
|
|
31
|
+
align?: MenuAlign;
|
|
32
|
+
/** Test identifier for the menu */
|
|
33
|
+
'data-testid'?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A menu of actions and choices that opens from a trigger (#329), following the WAI-ARIA menu
|
|
37
|
+
* button pattern. Not a select: for choosing a form value, use Dropdown.
|
|
38
|
+
*/
|
|
39
|
+
export declare const Menu: {
|
|
40
|
+
({ trigger, children, open: openProp, defaultOpen, onOpenChange, side, align, "data-testid": dataTestId, }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
interface ItemBaseProps {
|
|
44
|
+
/** The item's label */
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
/** A leading Icon or Avatar. Decorative: the label names the item (decision 0028). */
|
|
47
|
+
icon?: React.ReactNode;
|
|
48
|
+
/** Secondary text under the label, such as a workspace's plan */
|
|
49
|
+
description?: React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* A keyboard shortcut shown at the end of the item: `label` is shown (such as "⌘K") and `keys` is
|
|
52
|
+
* exposed as `aria-keyshortcuts` (such as "Meta+K"). Display only: Menu doesn't bind the keys.
|
|
53
|
+
*/
|
|
54
|
+
shortcut?: {
|
|
55
|
+
label: string;
|
|
56
|
+
keys: string;
|
|
57
|
+
};
|
|
58
|
+
/** Whether the item can be activated. A disabled item can still be focused (WAI-ARIA). */
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/** Text for typeahead, when the label isn't plain text */
|
|
61
|
+
textValue?: string;
|
|
62
|
+
/** Test identifier for the item */
|
|
63
|
+
'data-testid'?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface MenuItemProps extends ItemBaseProps {
|
|
66
|
+
/** Called when the item is activated. The menu then closes. */
|
|
67
|
+
onSelect?: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* A destructive action, shown in the danger colour as ActionSheet's are.
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
destructive?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface MenuItemRadioProps extends ItemBaseProps {
|
|
75
|
+
/** Whether this is the chosen item of its group */
|
|
76
|
+
checked: boolean;
|
|
77
|
+
/** Called when the item is chosen. The menu then closes. */
|
|
78
|
+
onSelect?: () => void;
|
|
79
|
+
}
|
|
80
|
+
export interface MenuItemCheckboxProps extends ItemBaseProps {
|
|
81
|
+
/** Whether the item is on */
|
|
82
|
+
checked: boolean;
|
|
83
|
+
/** Called with the new state when the item is toggled. The menu stays open. */
|
|
84
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
85
|
+
}
|
|
86
|
+
/** An action. Activating it closes the menu. */
|
|
87
|
+
export declare const MenuItem: {
|
|
88
|
+
({ onSelect, ...props }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
displayName: string;
|
|
90
|
+
};
|
|
91
|
+
/** One choice of a set, inside a MenuGroup. Choosing it closes the menu. */
|
|
92
|
+
export declare const MenuItemRadio: {
|
|
93
|
+
({ onSelect, checked, ...props }: MenuItemRadioProps): import("react/jsx-runtime").JSX.Element;
|
|
94
|
+
displayName: string;
|
|
95
|
+
};
|
|
96
|
+
/** An on/off option, inside a MenuGroup. Toggling it keeps the menu open. */
|
|
97
|
+
export declare const MenuItemCheckbox: {
|
|
98
|
+
({ onCheckedChange, checked, ...props }: MenuItemCheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
99
|
+
displayName: string;
|
|
100
|
+
};
|
|
101
|
+
export interface MenuGroupProps {
|
|
102
|
+
/** A visible label for the group, which also names it for assistive technology */
|
|
103
|
+
label?: string;
|
|
104
|
+
/** The group's items */
|
|
105
|
+
children: React.ReactNode;
|
|
106
|
+
}
|
|
107
|
+
/** Groups related items. Radio and checkbox items always sit in a group. */
|
|
108
|
+
export declare const MenuGroup: {
|
|
109
|
+
({ label, children }: MenuGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
110
|
+
displayName: string;
|
|
111
|
+
};
|
|
112
|
+
/** Separates groups */
|
|
113
|
+
export declare const MenuDivider: {
|
|
114
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
115
|
+
displayName: string;
|
|
116
|
+
};
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { __makeTemplateObject, __rest, __assign, __spreadArray } from '../../../vendor/tslib/tslib.es6.mjs';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { useId, useRef, useState, useCallback, useEffect, createContext, useContext } from 'react';
|
|
5
|
+
import styled$module, { keyframes, css } from 'styled-components';
|
|
6
|
+
const styled = styled$module.default || styled$module;
|
|
7
|
+
import tokens from '../../../lib/cssTokens.mjs';
|
|
8
|
+
import { exitAnimation, reducedMotion, forcedColorsEdge, interactiveRow } from '../../../lib/styleUtils.mjs';
|
|
9
|
+
import { usePresence } from '../../../lib/usePresence.mjs';
|
|
10
|
+
import { laidOutElement } from '../../../lib/floatingPosition.mjs';
|
|
11
|
+
import { useIsomorphicLayoutEffect, useFloatingLayer } from '../../../lib/useFloatingLayer.mjs';
|
|
12
|
+
import { Icon } from '../../atoms/Icon/Icon.mjs';
|
|
13
|
+
|
|
14
|
+
var semantic = tokens.semantic;
|
|
15
|
+
var space = semantic.space,
|
|
16
|
+
color = semantic.color,
|
|
17
|
+
motion = semantic.motion,
|
|
18
|
+
radius = semantic.radius,
|
|
19
|
+
size = semantic.size,
|
|
20
|
+
elevation = semantic.elevation,
|
|
21
|
+
border = semantic.border,
|
|
22
|
+
typography = semantic.typography;
|
|
23
|
+
// Typeahead keeps typed characters together for this long. An input timing, not a motion value.
|
|
24
|
+
var TYPEAHEAD_RESET_MS = 500;
|
|
25
|
+
var ITEM_SELECTOR = '[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';
|
|
26
|
+
var MenuContext = /*#__PURE__*/createContext(null);
|
|
27
|
+
var useMenu = function useMenu(component) {
|
|
28
|
+
var context = useContext(MenuContext);
|
|
29
|
+
if (!context) throw new Error("".concat(component, " must be used inside a Menu"));
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
var enter = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n from {\n opacity: 0;\n transform: translateY(calc(-1 * ", "));\n }\n"], ["\n from {\n opacity: 0;\n transform: translateY(calc(-1 * ", "));\n }\n"])), motion.distance.sm);
|
|
33
|
+
var fade = keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n from { opacity: 0; }\n"], ["\n from { opacity: 0; }\n"
|
|
34
|
+
// Dropdown's panel (P5): the raised surface with a decorative outline and floating elevation,
|
|
35
|
+
// dropping in over duration.fast (0037); under reduced motion it only fades (0015)
|
|
36
|
+
])));
|
|
37
|
+
// Dropdown's panel (P5): the raised surface with a decorative outline and floating elevation,
|
|
38
|
+
// dropping in over duration.fast (0037); under reduced motion it only fades (0015)
|
|
39
|
+
var Panel = /*#__PURE__*/styled.div.withConfig({
|
|
40
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
41
|
+
return !prop.startsWith('$');
|
|
42
|
+
},
|
|
43
|
+
displayName: "Menu__Panel",
|
|
44
|
+
componentId: "sc-13mple2-0"
|
|
45
|
+
})(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n position: fixed;\n inset: auto;\n top: 0;\n left: 0;\n margin: 0;\n box-sizing: border-box;\n min-width: ", ";\n max-width: ", ";\n max-height: ", ";\n overflow-y: auto;\n padding: ", " 0;\n background-color: ", ";\n color: ", ";\n border: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n animation: ", " ", " ", "\n ", ";\n\n ", " {\n animation: ", " ", " ", "\n ", ";\n }\n\n ", "\n\n &:focus {\n outline: none;\n }\n"], ["\n position: fixed;\n inset: auto;\n top: 0;\n left: 0;\n margin: 0;\n box-sizing: border-box;\n min-width: ", ";\n max-width: ", ";\n max-height: ", ";\n overflow-y: auto;\n padding: ", " 0;\n background-color: ", ";\n color: ", ";\n border: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n animation: ", " ", " ", "\n ", ";\n\n ", " {\n animation: ", " ", " ", "\n ", ";\n }\n\n ", "\n\n &:focus {\n outline: none;\n }\n"
|
|
46
|
+
// The trigger's wrapper takes no box of its own
|
|
47
|
+
])), size[4500], size[7500], size.menu.maxHeight, space[100], semantic.surface.raised, color.text["default"], border["default"], radius.md, elevation.floating, enter, motion.duration.fast, motion.easing.decelerate, function (_a) {
|
|
48
|
+
var $exiting = _a.$exiting;
|
|
49
|
+
return $exiting ? exitAnimation : css(templateObject_3 || (templateObject_3 = __makeTemplateObject([""], [""])));
|
|
50
|
+
}, reducedMotion, fade, motion.duration.fast, motion.easing.decelerate, function (_a) {
|
|
51
|
+
var $exiting = _a.$exiting;
|
|
52
|
+
return $exiting ? exitAnimation : css(templateObject_4 || (templateObject_4 = __makeTemplateObject([""], [""])));
|
|
53
|
+
}, forcedColorsEdge);
|
|
54
|
+
// The trigger's wrapper takes no box of its own
|
|
55
|
+
var Anchor = /*#__PURE__*/styled.span.withConfig({
|
|
56
|
+
displayName: "Menu__Anchor",
|
|
57
|
+
componentId: "sc-13mple2-1"
|
|
58
|
+
})(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: contents;\n"], ["\n display: contents;\n"])));
|
|
59
|
+
var focusItem = function focusItem(menu, which) {
|
|
60
|
+
var _a;
|
|
61
|
+
var items = menu ? Array.from(menu.querySelectorAll(ITEM_SELECTOR)) : [];
|
|
62
|
+
(_a = which === 'first' ? items[0] : items[items.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A menu of actions and choices that opens from a trigger (#329), following the WAI-ARIA menu
|
|
66
|
+
* button pattern. Not a select: for choosing a form value, use Dropdown.
|
|
67
|
+
*/
|
|
68
|
+
var Menu = function Menu(_a) {
|
|
69
|
+
var trigger = _a.trigger,
|
|
70
|
+
children = _a.children,
|
|
71
|
+
openProp = _a.open,
|
|
72
|
+
_b = _a.defaultOpen,
|
|
73
|
+
defaultOpen = _b === void 0 ? false : _b,
|
|
74
|
+
onOpenChange = _a.onOpenChange,
|
|
75
|
+
_c = _a.side,
|
|
76
|
+
side = _c === void 0 ? 'bottom' : _c,
|
|
77
|
+
_d = _a.align,
|
|
78
|
+
align = _d === void 0 ? 'start' : _d,
|
|
79
|
+
dataTestId = _a["data-testid"];
|
|
80
|
+
var menuId = useId();
|
|
81
|
+
var triggerId = useId();
|
|
82
|
+
var anchorRef = useRef(null);
|
|
83
|
+
var panelRef = useRef(null);
|
|
84
|
+
// Which item to focus once the menu has opened
|
|
85
|
+
var initialFocus = useRef('first');
|
|
86
|
+
var openedFromTrigger = useRef(false);
|
|
87
|
+
var typeahead = useRef({
|
|
88
|
+
text: '',
|
|
89
|
+
timer: undefined
|
|
90
|
+
});
|
|
91
|
+
var _e = useState(defaultOpen),
|
|
92
|
+
uncontrolledOpen = _e[0],
|
|
93
|
+
setUncontrolledOpen = _e[1];
|
|
94
|
+
var isControlled = openProp !== undefined;
|
|
95
|
+
var isOpen = isControlled ? openProp : uncontrolledOpen;
|
|
96
|
+
var _f = usePresence(isOpen),
|
|
97
|
+
isPresent = _f.isPresent,
|
|
98
|
+
isExiting = _f.isExiting;
|
|
99
|
+
var triggerElement = function triggerElement() {
|
|
100
|
+
return laidOutElement(anchorRef.current);
|
|
101
|
+
};
|
|
102
|
+
var setOpen = useCallback(function (next) {
|
|
103
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
104
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
105
|
+
}, [isControlled, onOpenChange]);
|
|
106
|
+
var close = useCallback(function (_a) {
|
|
107
|
+
var _b;
|
|
108
|
+
var _c = _a === void 0 ? {} : _a,
|
|
109
|
+
_d = _c.returnFocus,
|
|
110
|
+
returnFocus = _d === void 0 ? true : _d;
|
|
111
|
+
setOpen(false);
|
|
112
|
+
if (returnFocus) (_b = triggerElement()) === null || _b === void 0 ? void 0 : _b.focus();
|
|
113
|
+
}, [setOpen]);
|
|
114
|
+
var openWith = function openWith(focus) {
|
|
115
|
+
initialFocus.current = focus;
|
|
116
|
+
openedFromTrigger.current = true;
|
|
117
|
+
setOpen(true);
|
|
118
|
+
};
|
|
119
|
+
// The trigger's ARIA is set on the element itself, so it reaches the real control even when the
|
|
120
|
+
// trigger is wrapped (a Tooltip inside the trigger, for example)
|
|
121
|
+
useEffect(function () {
|
|
122
|
+
var element = triggerElement();
|
|
123
|
+
if (!element) return;
|
|
124
|
+
if (!element.id) element.id = triggerId;
|
|
125
|
+
element.setAttribute('aria-haspopup', 'menu');
|
|
126
|
+
element.setAttribute('aria-expanded', String(isOpen));
|
|
127
|
+
if (isOpen) element.setAttribute('aria-controls', menuId);else element.removeAttribute('aria-controls');
|
|
128
|
+
});
|
|
129
|
+
// The menu is named by its trigger, whose own id is kept if it has one
|
|
130
|
+
useIsomorphicLayoutEffect(function () {
|
|
131
|
+
var panel = panelRef.current;
|
|
132
|
+
var element = triggerElement();
|
|
133
|
+
if (!isPresent || !panel || !element) return;
|
|
134
|
+
if (!element.id) element.id = triggerId;
|
|
135
|
+
panel.setAttribute('aria-labelledby', element.id);
|
|
136
|
+
}, [isPresent]);
|
|
137
|
+
// In the top layer beside the trigger; scrolling or resizing closes it, since the trigger moves
|
|
138
|
+
var detach = useCallback(function () {
|
|
139
|
+
return close({
|
|
140
|
+
returnFocus: false
|
|
141
|
+
});
|
|
142
|
+
}, [close]);
|
|
143
|
+
useFloatingLayer({
|
|
144
|
+
isPresent: isPresent,
|
|
145
|
+
floatingRef: panelRef,
|
|
146
|
+
anchorRef: anchorRef,
|
|
147
|
+
side: side,
|
|
148
|
+
align: align,
|
|
149
|
+
onDetach: detach
|
|
150
|
+
});
|
|
151
|
+
// Opening from the trigger focuses the first or last item. An open that didn't come from the
|
|
152
|
+
// trigger (defaultOpen, or a controlled open) leaves focus where it is
|
|
153
|
+
useEffect(function () {
|
|
154
|
+
if (!isOpen || !openedFromTrigger.current) return;
|
|
155
|
+
openedFromTrigger.current = false;
|
|
156
|
+
focusItem(panelRef.current, initialFocus.current);
|
|
157
|
+
}, [isOpen]);
|
|
158
|
+
// A press outside the trigger and the menu closes it, leaving focus where the press put it
|
|
159
|
+
useEffect(function () {
|
|
160
|
+
if (!isOpen) return;
|
|
161
|
+
var onPointerDown = function onPointerDown(event) {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
var target = event.target;
|
|
164
|
+
if (((_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.contains(target)) || ((_b = anchorRef.current) === null || _b === void 0 ? void 0 : _b.contains(target))) return;
|
|
165
|
+
close({
|
|
166
|
+
returnFocus: false
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
170
|
+
return function () {
|
|
171
|
+
return document.removeEventListener('pointerdown', onPointerDown, true);
|
|
172
|
+
};
|
|
173
|
+
}, [isOpen, close]);
|
|
174
|
+
useEffect(function () {
|
|
175
|
+
return function () {
|
|
176
|
+
return clearTimeout(typeahead.current.timer);
|
|
177
|
+
};
|
|
178
|
+
}, []);
|
|
179
|
+
var onTriggerKeyDown = function onTriggerKeyDown(event) {
|
|
180
|
+
var _a;
|
|
181
|
+
if ((_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) return;
|
|
182
|
+
if (event.key === 'ArrowDown' || event.key === 'Enter' || event.key === ' ') {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
openWith('first');
|
|
185
|
+
} else if (event.key === 'ArrowUp') {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
openWith('last');
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var onTriggerClick = function onTriggerClick(event) {
|
|
191
|
+
var _a;
|
|
192
|
+
if ((_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) return;
|
|
193
|
+
// A keyboard click (Enter, Space) is handled on keydown
|
|
194
|
+
if (event.detail === 0) return;
|
|
195
|
+
if (isOpen) close({
|
|
196
|
+
returnFocus: false
|
|
197
|
+
});else openWith('first');
|
|
198
|
+
};
|
|
199
|
+
var onMenuKeyDown = function onMenuKeyDown(event) {
|
|
200
|
+
var _a;
|
|
201
|
+
var items = Array.from(event.currentTarget.querySelectorAll(ITEM_SELECTOR));
|
|
202
|
+
var current = items.indexOf(document.activeElement);
|
|
203
|
+
var move = function move(index) {
|
|
204
|
+
var _a;
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
(_a = items[(index + items.length) % items.length]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
207
|
+
};
|
|
208
|
+
switch (event.key) {
|
|
209
|
+
case 'ArrowDown':
|
|
210
|
+
return move(current + 1);
|
|
211
|
+
case 'ArrowUp':
|
|
212
|
+
return move(current - 1);
|
|
213
|
+
case 'Home':
|
|
214
|
+
return move(0);
|
|
215
|
+
case 'End':
|
|
216
|
+
return move(items.length - 1);
|
|
217
|
+
case 'Escape':
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
event.stopPropagation();
|
|
220
|
+
return close();
|
|
221
|
+
case 'Tab':
|
|
222
|
+
// Focus moves on to the next element after the trigger, and the menu closes
|
|
223
|
+
return close({
|
|
224
|
+
returnFocus: false
|
|
225
|
+
});
|
|
226
|
+
default:
|
|
227
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && event.key !== ' ') {
|
|
228
|
+
var state_1 = typeahead.current;
|
|
229
|
+
clearTimeout(state_1.timer);
|
|
230
|
+
state_1.text += event.key.toLowerCase();
|
|
231
|
+
state_1.timer = setTimeout(function () {
|
|
232
|
+
state_1.text = '';
|
|
233
|
+
}, TYPEAHEAD_RESET_MS);
|
|
234
|
+
// The label alone: not a leading Avatar's initials, the description or the shortcut
|
|
235
|
+
var label_1 = function label_1(item) {
|
|
236
|
+
var _a, _b, _c;
|
|
237
|
+
return ((_c = (_a = item.dataset.label) !== null && _a !== void 0 ? _a : (_b = item.querySelector('[data-menu-label]')) === null || _b === void 0 ? void 0 : _b.textContent) !== null && _c !== void 0 ? _c : '').trim().toLowerCase();
|
|
238
|
+
};
|
|
239
|
+
var ordered = __spreadArray(__spreadArray([], items.slice(current + 1), true), items.slice(0, current + 1), true);
|
|
240
|
+
var search = state_1.text.length > 1 ? __spreadArray([items[current]], ordered, true) : ordered;
|
|
241
|
+
(_a = search.find(function (item) {
|
|
242
|
+
return item && label_1(item).startsWith(state_1.text);
|
|
243
|
+
})) === null || _a === void 0 ? void 0 : _a.focus();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
return jsx(MenuContext.Provider, {
|
|
248
|
+
value: {
|
|
249
|
+
close: close
|
|
250
|
+
},
|
|
251
|
+
children: jsxs(Anchor, {
|
|
252
|
+
ref: anchorRef,
|
|
253
|
+
onKeyDown: onTriggerKeyDown,
|
|
254
|
+
onClick: onTriggerClick,
|
|
255
|
+
children: [trigger, isPresent && jsx(Panel, {
|
|
256
|
+
ref: panelRef,
|
|
257
|
+
id: menuId,
|
|
258
|
+
role: "menu",
|
|
259
|
+
tabIndex: -1,
|
|
260
|
+
"$exiting": isExiting,
|
|
261
|
+
onKeyDown: onMenuKeyDown,
|
|
262
|
+
"data-testid": dataTestId,
|
|
263
|
+
children: children
|
|
264
|
+
})]
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
Menu.displayName = 'Menu';
|
|
269
|
+
var Row = /*#__PURE__*/styled.div.withConfig({
|
|
270
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
271
|
+
return !prop.startsWith('$');
|
|
272
|
+
},
|
|
273
|
+
displayName: "Menu__Row",
|
|
274
|
+
componentId: "sc-13mple2-2"
|
|
275
|
+
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n gap: ", ";\n box-sizing: border-box;\n min-height: ", ";\n padding: ", " ", ";\n font: ", ";\n color: ", ";\n cursor: ", ";\n user-select: none;\n transition: background-color ", " ", ",\n color ", " ", ";\n\n /* The shared row states (0030): focus shows the hover state (0029); only checked items are\n light blue, with the checkmark so the state isn't colour alone */\n ", "\n\n ", "\n\n &:focus {\n outline: none;\n }\n\n &:focus-visible {\n outline: ", ";\n outline-offset: calc(-1 * ", ");\n }\n"], ["\n display: flex;\n align-items: center;\n gap: ", ";\n box-sizing: border-box;\n min-height: ", ";\n padding: ", " ", ";\n font: ", ";\n color: ", ";\n cursor: ", ";\n user-select: none;\n transition: background-color ", " ", ",\n color ", " ", ";\n\n /* The shared row states (0030): focus shows the hover state (0029); only checked items are\n light blue, with the checkmark so the state isn't colour alone */\n ", "\n\n ", "\n\n &:focus {\n outline: none;\n }\n\n &:focus-visible {\n outline: ", ";\n outline-offset: calc(-1 * ", ");\n }\n"])), space[200], size.row.sm, space.inset.xs, space.inset.md, typography.small, function (_a) {
|
|
276
|
+
var $destructive = _a.$destructive;
|
|
277
|
+
return $destructive ? color.text.danger : color.text["default"];
|
|
278
|
+
}, function (_a) {
|
|
279
|
+
var $disabled = _a.$disabled;
|
|
280
|
+
return $disabled ? 'not-allowed' : 'pointer';
|
|
281
|
+
}, motion.duration.fast, motion.easing.decelerate, motion.duration.fast, motion.easing.decelerate, function (_a) {
|
|
282
|
+
var $checked = _a.$checked,
|
|
283
|
+
$focused = _a.$focused,
|
|
284
|
+
$disabled = _a.$disabled;
|
|
285
|
+
return interactiveRow({
|
|
286
|
+
selected: $checked,
|
|
287
|
+
focused: $focused,
|
|
288
|
+
disabled: $disabled
|
|
289
|
+
});
|
|
290
|
+
}, function (_a) {
|
|
291
|
+
var $disabled = _a.$disabled;
|
|
292
|
+
return $disabled && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["color: ", ";"], ["color: ", ";"])), color.text.disabled);
|
|
293
|
+
}, border.focus, border.focusOffset);
|
|
294
|
+
var Leading = /*#__PURE__*/styled.span.withConfig({
|
|
295
|
+
displayName: "Menu__Leading",
|
|
296
|
+
componentId: "sc-13mple2-3"
|
|
297
|
+
})(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: inline-flex;\n flex-shrink: 0;\n"], ["\n display: inline-flex;\n flex-shrink: 0;\n"])));
|
|
298
|
+
var Text = /*#__PURE__*/styled.span.withConfig({
|
|
299
|
+
displayName: "Menu__Text",
|
|
300
|
+
componentId: "sc-13mple2-4"
|
|
301
|
+
})(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n"], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n"])));
|
|
302
|
+
var Description = /*#__PURE__*/styled.span.withConfig({
|
|
303
|
+
displayName: "Menu__Description",
|
|
304
|
+
componentId: "sc-13mple2-5"
|
|
305
|
+
})(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font: ", ";\n color: ", ";\n"], ["\n font: ", ";\n color: ", ";\n"])), typography.caption, color.text.muted);
|
|
306
|
+
var Shortcut = /*#__PURE__*/styled.span.withConfig({
|
|
307
|
+
displayName: "Menu__Shortcut",
|
|
308
|
+
componentId: "sc-13mple2-6"
|
|
309
|
+
})(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n flex-shrink: 0;\n font: ", ";\n color: ", ";\n"], ["\n flex-shrink: 0;\n font: ", ";\n color: ", ";\n"])), typography.caption, color.text.muted);
|
|
310
|
+
var Check = /*#__PURE__*/styled.span.withConfig({
|
|
311
|
+
displayName: "Menu__Check",
|
|
312
|
+
componentId: "sc-13mple2-7"
|
|
313
|
+
})(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n display: inline-flex;\n flex-shrink: 0;\n color: inherit;\n"], ["\n display: inline-flex;\n flex-shrink: 0;\n color: inherit;\n"])));
|
|
314
|
+
var RowItem = function RowItem(_a) {
|
|
315
|
+
var role = _a.role,
|
|
316
|
+
children = _a.children,
|
|
317
|
+
icon = _a.icon,
|
|
318
|
+
description = _a.description,
|
|
319
|
+
shortcut = _a.shortcut,
|
|
320
|
+
_b = _a.disabled,
|
|
321
|
+
disabled = _b === void 0 ? false : _b,
|
|
322
|
+
_c = _a.destructive,
|
|
323
|
+
destructive = _c === void 0 ? false : _c,
|
|
324
|
+
checked = _a.checked,
|
|
325
|
+
textValue = _a.textValue,
|
|
326
|
+
onActivate = _a.onActivate,
|
|
327
|
+
dataTestId = _a["data-testid"];
|
|
328
|
+
var _d = useState(false),
|
|
329
|
+
focused = _d[0],
|
|
330
|
+
setFocused = _d[1];
|
|
331
|
+
var checkable = role !== 'menuitem';
|
|
332
|
+
var activate = function activate() {
|
|
333
|
+
if (!disabled) onActivate();
|
|
334
|
+
};
|
|
335
|
+
return jsxs(Row, {
|
|
336
|
+
role: role,
|
|
337
|
+
tabIndex: -1,
|
|
338
|
+
"aria-disabled": disabled || undefined,
|
|
339
|
+
"aria-checked": checkable ? Boolean(checked) : undefined,
|
|
340
|
+
"aria-keyshortcuts": shortcut === null || shortcut === void 0 ? void 0 : shortcut.keys,
|
|
341
|
+
"data-label": textValue,
|
|
342
|
+
"data-testid": dataTestId,
|
|
343
|
+
"$checked": Boolean(checked),
|
|
344
|
+
"$focused": focused,
|
|
345
|
+
"$disabled": disabled,
|
|
346
|
+
"$destructive": destructive,
|
|
347
|
+
onFocus: function onFocus() {
|
|
348
|
+
return setFocused(true);
|
|
349
|
+
},
|
|
350
|
+
onBlur: function onBlur() {
|
|
351
|
+
return setFocused(false);
|
|
352
|
+
},
|
|
353
|
+
onPointerMove: function onPointerMove(event) {
|
|
354
|
+
// The pointer moves focus, so hover and keyboard share one highlighted item
|
|
355
|
+
if (document.activeElement !== event.currentTarget) event.currentTarget.focus();
|
|
356
|
+
},
|
|
357
|
+
onClick: activate,
|
|
358
|
+
onKeyDown: function onKeyDown(event) {
|
|
359
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
360
|
+
event.preventDefault();
|
|
361
|
+
activate();
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
children: [icon && jsx(Leading, {
|
|
365
|
+
"aria-hidden": "true",
|
|
366
|
+
children: icon
|
|
367
|
+
}), jsxs(Text, {
|
|
368
|
+
children: [jsx("span", {
|
|
369
|
+
"data-menu-label": "",
|
|
370
|
+
children: children
|
|
371
|
+
}), description && jsx(Description, {
|
|
372
|
+
children: description
|
|
373
|
+
})]
|
|
374
|
+
}), shortcut && jsx(Shortcut, {
|
|
375
|
+
"aria-hidden": "true",
|
|
376
|
+
children: shortcut.label
|
|
377
|
+
}), checkable && checked && jsx(Check, {
|
|
378
|
+
children: jsx(Icon, {
|
|
379
|
+
name: "check",
|
|
380
|
+
size: "sm",
|
|
381
|
+
iconColor: "inherit"
|
|
382
|
+
})
|
|
383
|
+
})]
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
/** An action. Activating it closes the menu. */
|
|
387
|
+
var MenuItem = function MenuItem(_a) {
|
|
388
|
+
var onSelect = _a.onSelect,
|
|
389
|
+
props = __rest(_a, ["onSelect"]);
|
|
390
|
+
var close = useMenu('MenuItem').close;
|
|
391
|
+
return jsx(RowItem, __assign({
|
|
392
|
+
role: "menuitem"
|
|
393
|
+
}, props, {
|
|
394
|
+
onActivate: function onActivate() {
|
|
395
|
+
close();
|
|
396
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
397
|
+
}
|
|
398
|
+
}));
|
|
399
|
+
};
|
|
400
|
+
/** One choice of a set, inside a MenuGroup. Choosing it closes the menu. */
|
|
401
|
+
var MenuItemRadio = function MenuItemRadio(_a) {
|
|
402
|
+
var onSelect = _a.onSelect,
|
|
403
|
+
checked = _a.checked,
|
|
404
|
+
props = __rest(_a, ["onSelect", "checked"]);
|
|
405
|
+
var close = useMenu('MenuItemRadio').close;
|
|
406
|
+
return jsx(RowItem, __assign({
|
|
407
|
+
role: "menuitemradio",
|
|
408
|
+
checked: checked
|
|
409
|
+
}, props, {
|
|
410
|
+
onActivate: function onActivate() {
|
|
411
|
+
close();
|
|
412
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
413
|
+
}
|
|
414
|
+
}));
|
|
415
|
+
};
|
|
416
|
+
/** An on/off option, inside a MenuGroup. Toggling it keeps the menu open. */
|
|
417
|
+
var MenuItemCheckbox = function MenuItemCheckbox(_a) {
|
|
418
|
+
var onCheckedChange = _a.onCheckedChange,
|
|
419
|
+
checked = _a.checked,
|
|
420
|
+
props = __rest(_a, ["onCheckedChange", "checked"]);
|
|
421
|
+
useMenu('MenuItemCheckbox');
|
|
422
|
+
return jsx(RowItem, __assign({
|
|
423
|
+
role: "menuitemcheckbox",
|
|
424
|
+
checked: checked
|
|
425
|
+
}, props, {
|
|
426
|
+
onActivate: function onActivate() {
|
|
427
|
+
return onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(!checked);
|
|
428
|
+
}
|
|
429
|
+
}));
|
|
430
|
+
};
|
|
431
|
+
var GroupLabel = /*#__PURE__*/styled.div.withConfig({
|
|
432
|
+
displayName: "Menu__GroupLabel",
|
|
433
|
+
componentId: "sc-13mple2-8"
|
|
434
|
+
})(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n padding: ", " ", ";\n font: ", ";\n color: ", ";\n"], ["\n padding: ", " ", ";\n font: ", ";\n color: ", ";\n"
|
|
435
|
+
/** Groups related items. Radio and checkbox items always sit in a group. */])), space.inset.xs, space.inset.md, typography.caption, color.text.muted);
|
|
436
|
+
/** Groups related items. Radio and checkbox items always sit in a group. */
|
|
437
|
+
var MenuGroup = function MenuGroup(_a) {
|
|
438
|
+
var label = _a.label,
|
|
439
|
+
children = _a.children;
|
|
440
|
+
var labelId = useId();
|
|
441
|
+
return jsxs("div", {
|
|
442
|
+
role: "group",
|
|
443
|
+
"aria-labelledby": label ? labelId : undefined,
|
|
444
|
+
children: [label && jsx(GroupLabel, {
|
|
445
|
+
id: labelId,
|
|
446
|
+
"aria-hidden": "true",
|
|
447
|
+
children: label
|
|
448
|
+
}), children]
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
// Divider's smallest spacing (16px each side) is too loose between dense rows, so the menu draws
|
|
452
|
+
// its own 1px rule with the decorative border
|
|
453
|
+
var Separator = /*#__PURE__*/styled.div.withConfig({
|
|
454
|
+
displayName: "Menu__Separator",
|
|
455
|
+
componentId: "sc-13mple2-9"
|
|
456
|
+
})(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n margin: ", " 0;\n border-top: ", ";\n"], ["\n margin: ", " 0;\n border-top: ", ";\n"
|
|
457
|
+
/** Separates groups */])), space[100], border["default"]);
|
|
458
|
+
/** Separates groups */
|
|
459
|
+
var MenuDivider = function MenuDivider() {
|
|
460
|
+
return jsx(Separator, {
|
|
461
|
+
role: "separator",
|
|
462
|
+
"aria-orientation": "horizontal"
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
MenuItem.displayName = 'MenuItem';
|
|
466
|
+
MenuItemRadio.displayName = 'MenuItemRadio';
|
|
467
|
+
MenuItemCheckbox.displayName = 'MenuItemCheckbox';
|
|
468
|
+
MenuGroup.displayName = 'MenuGroup';
|
|
469
|
+
MenuDivider.displayName = 'MenuDivider';
|
|
470
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15;
|
|
471
|
+
|
|
472
|
+
export { Menu, MenuDivider, MenuGroup, MenuItem, MenuItemCheckbox, MenuItemRadio };
|
|
473
|
+
//# sourceMappingURL=Menu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Menu.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -9,7 +9,6 @@ export interface ModalAction {
|
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
/**
|
|
11
11
|
* Button variant. `accent` is the blue call to action (at most one per view).
|
|
12
|
-
* `emphasis` is a deprecated alias for `accent` and will be removed in 3.0.
|
|
13
12
|
*/
|
|
14
13
|
variant?: ButtonVariant;
|
|
15
14
|
/** Optional leading icon */
|
|
@@ -9,7 +9,6 @@ export interface ModalAction {
|
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
/**
|
|
11
11
|
* Button variant. `accent` is the blue call to action (at most one per view).
|
|
12
|
-
* `emphasis` is a deprecated alias for `accent` and will be removed in 3.0.
|
|
13
12
|
*/
|
|
14
13
|
variant?: ButtonVariant;
|
|
15
14
|
/** Optional leading icon */
|
|
@@ -296,6 +296,7 @@ var SearchField = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
296
296
|
role: "option",
|
|
297
297
|
primary: "Clear recent searches",
|
|
298
298
|
interactive: true,
|
|
299
|
+
// Deprecated prop (0051), kept for this padding until 4.0 removes it
|
|
299
300
|
spacing: "compact",
|
|
300
301
|
onClick: function onClick() {
|
|
301
302
|
return handleSuggestionClick(item);
|
|
@@ -324,6 +325,7 @@ var SearchField = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
324
325
|
}) : undefined,
|
|
325
326
|
interactive: true,
|
|
326
327
|
"data-highlighted": index === highlightedIndex || undefined,
|
|
328
|
+
// Deprecated prop (0051), kept for this padding until 4.0 removes it
|
|
327
329
|
spacing: "compact",
|
|
328
330
|
onClick: function onClick() {
|
|
329
331
|
return handleSuggestionClick(item);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
export interface SidebarNavContextValue {
|
|
3
|
+
/** The nav is the icon rail: rows show their icon only */
|
|
4
|
+
collapsed: boolean;
|
|
5
|
+
/** A router's link component for internal URLs, set once on SidebarNav (decision 0008) */
|
|
6
|
+
linkComponent?: ComponentType<any>;
|
|
7
|
+
/** SidebarNav draws one gliding hover highlight, so rows don't colour their own hover (0053) */
|
|
8
|
+
glide: boolean;
|
|
9
|
+
/** Inside a SidebarNav, whose body is one list: a section is one of its items */
|
|
10
|
+
inNav?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const SidebarNavContext: import("react").Context<SidebarNavContextValue>;
|
|
13
|
+
export declare const useSidebarNav: () => SidebarNavContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
export interface SidebarNavContextValue {
|
|
3
|
+
/** The nav is the icon rail: rows show their icon only */
|
|
4
|
+
collapsed: boolean;
|
|
5
|
+
/** A router's link component for internal URLs, set once on SidebarNav (decision 0008) */
|
|
6
|
+
linkComponent?: ComponentType<any>;
|
|
7
|
+
/** SidebarNav draws one gliding hover highlight, so rows don't colour their own hover (0053) */
|
|
8
|
+
glide: boolean;
|
|
9
|
+
/** Inside a SidebarNav, whose body is one list: a section is one of its items */
|
|
10
|
+
inNav?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const SidebarNavContext: import("react").Context<SidebarNavContextValue>;
|
|
13
|
+
export declare const useSidebarNav: () => SidebarNavContextValue;
|