@robr0/design-system 0.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/LICENSE +21 -0
- package/README.md +127 -0
- package/charts.d.ts +14 -0
- package/charts.js +20 -0
- package/components/Accordion/Accordion.css +119 -0
- package/components/Accordion/Accordion.d.ts +24 -0
- package/components/Accordion/Accordion.js +76 -0
- package/components/Alert/Alert.css +252 -0
- package/components/Alert/Alert.d.ts +24 -0
- package/components/Alert/Alert.js +53 -0
- package/components/AlertDialog/AlertDialog.css +131 -0
- package/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/components/AlertDialog/AlertDialog.js +143 -0
- package/components/AppLayout/AppLayout.css +52 -0
- package/components/AppLayout/AppLayout.d.ts +27 -0
- package/components/AppLayout/AppLayout.js +45 -0
- package/components/AppSidebar/AppSidebar.css +434 -0
- package/components/AppSidebar/AppSidebar.d.ts +67 -0
- package/components/AppSidebar/AppSidebar.js +272 -0
- package/components/Avatar/Avatar.css +133 -0
- package/components/Avatar/Avatar.d.ts +20 -0
- package/components/Avatar/Avatar.js +56 -0
- package/components/Avatar/demoAvatars.d.ts +14 -0
- package/components/Avatar/demoAvatars.js +16 -0
- package/components/Badge/Badge.css +68 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.js +15 -0
- package/components/Breadcrumb/Breadcrumb.css +92 -0
- package/components/Breadcrumb/Breadcrumb.d.ts +19 -0
- package/components/Breadcrumb/Breadcrumb.js +39 -0
- package/components/Button/Button.css +381 -0
- package/components/Button/Button.d.ts +39 -0
- package/components/Button/Button.js +71 -0
- package/components/ButtonGroup/ButtonGroup.css +39 -0
- package/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/components/ButtonGroup/ButtonGroup.js +37 -0
- package/components/Card/Card.css +169 -0
- package/components/Card/Card.d.ts +30 -0
- package/components/Card/Card.js +90 -0
- package/components/Carousel/Carousel.css +112 -0
- package/components/Carousel/Carousel.d.ts +25 -0
- package/components/Carousel/Carousel.js +126 -0
- package/components/Chart/AreaChart.d.ts +36 -0
- package/components/Chart/AreaChart.js +99 -0
- package/components/Chart/BarChart.d.ts +34 -0
- package/components/Chart/BarChart.js +107 -0
- package/components/Chart/Chart.css +176 -0
- package/components/Chart/LineChart.d.ts +34 -0
- package/components/Chart/LineChart.js +90 -0
- package/components/Chart/PieChart.d.ts +34 -0
- package/components/Chart/PieChart.js +106 -0
- package/components/Chart/RadarChart.d.ts +34 -0
- package/components/Chart/RadarChart.js +91 -0
- package/components/Chart/RadialChart.d.ts +37 -0
- package/components/Chart/RadialChart.js +119 -0
- package/components/Chart/ScatterChart.d.ts +36 -0
- package/components/Chart/ScatterChart.js +109 -0
- package/components/Chart/StackedBarChart.d.ts +34 -0
- package/components/Chart/StackedBarChart.js +111 -0
- package/components/Chart/Treemap.d.ts +33 -0
- package/components/Chart/Treemap.js +109 -0
- package/components/Checkbox/Checkbox.css +164 -0
- package/components/Checkbox/Checkbox.d.ts +45 -0
- package/components/Checkbox/Checkbox.js +125 -0
- package/components/Chip/Chip.css +195 -0
- package/components/Chip/Chip.d.ts +27 -0
- package/components/Chip/Chip.js +80 -0
- package/components/CircularButton/CircularButton.css +206 -0
- package/components/CircularButton/CircularButton.d.ts +30 -0
- package/components/CircularButton/CircularButton.js +54 -0
- package/components/CodeBlock/CodeBlock.css +180 -0
- package/components/CodeBlock/CodeBlock.d.ts +23 -0
- package/components/CodeBlock/CodeBlock.js +85 -0
- package/components/ColourSwatch/ColourSwatch.css +88 -0
- package/components/ColourSwatch/ColourSwatch.d.ts +34 -0
- package/components/ColourSwatch/ColourSwatch.js +42 -0
- package/components/Combobox/Combobox.css +411 -0
- package/components/Combobox/Combobox.d.ts +73 -0
- package/components/Combobox/Combobox.js +312 -0
- package/components/CommandPalette/CommandPalette.css +310 -0
- package/components/CommandPalette/CommandPalette.d.ts +60 -0
- package/components/CommandPalette/CommandPalette.js +263 -0
- package/components/ContactCard/ContactCard.css +123 -0
- package/components/ContactCard/ContactCard.d.ts +23 -0
- package/components/ContactCard/ContactCard.js +78 -0
- package/components/ContributionGraph/ContributionGraph.css +142 -0
- package/components/ContributionGraph/ContributionGraph.d.ts +26 -0
- package/components/ContributionGraph/ContributionGraph.js +125 -0
- package/components/DateInput/DateInput.css +163 -0
- package/components/DateInput/DateInput.d.ts +43 -0
- package/components/DateInput/DateInput.js +69 -0
- package/components/DatePicker/DatePicker.css +198 -0
- package/components/DatePicker/DatePicker.d.ts +22 -0
- package/components/DatePicker/DatePicker.js +170 -0
- package/components/Dialog/Dialog.css +176 -0
- package/components/Dialog/Dialog.d.ts +28 -0
- package/components/Dialog/Dialog.js +132 -0
- package/components/Divider/Divider.css +100 -0
- package/components/Divider/Divider.d.ts +18 -0
- package/components/Divider/Divider.js +31 -0
- package/components/Drawer/Drawer.css +262 -0
- package/components/Drawer/Drawer.d.ts +30 -0
- package/components/Drawer/Drawer.js +134 -0
- package/components/Dropdown/Dropdown.css +300 -0
- package/components/Dropdown/Dropdown.d.ts +48 -0
- package/components/Dropdown/Dropdown.js +196 -0
- package/components/DropdownMenu/DropdownMenu.css +303 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +42 -0
- package/components/DropdownMenu/DropdownMenu.js +322 -0
- package/components/EmptyState/EmptyState.css +115 -0
- package/components/EmptyState/EmptyState.d.ts +27 -0
- package/components/EmptyState/EmptyState.js +32 -0
- package/components/EntityCard/EntityCard.css +69 -0
- package/components/EntityCard/EntityCard.d.ts +18 -0
- package/components/EntityCard/EntityCard.js +26 -0
- package/components/Figure/Figure.css +61 -0
- package/components/Figure/Figure.d.ts +17 -0
- package/components/Figure/Figure.js +35 -0
- package/components/FileInput/FileInput.css +308 -0
- package/components/FileInput/FileInput.d.ts +54 -0
- package/components/FileInput/FileInput.js +177 -0
- package/components/Input/Input.css +193 -0
- package/components/Input/Input.d.ts +40 -0
- package/components/Input/Input.js +71 -0
- package/components/Instructions/Instructions.css +216 -0
- package/components/Instructions/Instructions.d.ts +28 -0
- package/components/Instructions/Instructions.js +32 -0
- package/components/LinkList/LinkList.css +71 -0
- package/components/LinkList/LinkList.d.ts +20 -0
- package/components/LinkList/LinkList.js +41 -0
- package/components/MotionSwatch/MotionSwatch.css +176 -0
- package/components/MotionSwatch/MotionSwatch.d.ts +25 -0
- package/components/MotionSwatch/MotionSwatch.js +74 -0
- package/components/Nav/Nav.css +51 -0
- package/components/Nav/Nav.d.ts +19 -0
- package/components/Nav/Nav.js +26 -0
- package/components/Pagination/Pagination.css +126 -0
- package/components/Pagination/Pagination.d.ts +22 -0
- package/components/Pagination/Pagination.js +83 -0
- package/components/Popover/Popover.css +99 -0
- package/components/Popover/Popover.d.ts +28 -0
- package/components/Popover/Popover.js +102 -0
- package/components/ProgressBar/ProgressBar.css +60 -0
- package/components/ProgressBar/ProgressBar.d.ts +16 -0
- package/components/ProgressBar/ProgressBar.js +27 -0
- package/components/Quote/Quote.css +79 -0
- package/components/Quote/Quote.d.ts +18 -0
- package/components/Quote/Quote.js +26 -0
- package/components/RadioButton/RadioButton.css +132 -0
- package/components/RadioButton/RadioButton.d.ts +43 -0
- package/components/RadioButton/RadioButton.js +77 -0
- package/components/SectionTitle/SectionTitle.css +37 -0
- package/components/SectionTitle/SectionTitle.d.ts +10 -0
- package/components/SectionTitle/SectionTitle.js +17 -0
- package/components/SegmentedControl/SegmentedControl.css +129 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +33 -0
- package/components/SegmentedControl/SegmentedControl.js +91 -0
- package/components/SelectionCard/SelectionCard.css +251 -0
- package/components/SelectionCard/SelectionCard.d.ts +26 -0
- package/components/SelectionCard/SelectionCard.js +85 -0
- package/components/Skeleton/Skeleton.css +79 -0
- package/components/Skeleton/Skeleton.d.ts +16 -0
- package/components/Skeleton/Skeleton.js +30 -0
- package/components/Slider/Slider.css +86 -0
- package/components/Slider/Slider.d.ts +25 -0
- package/components/Slider/Slider.js +46 -0
- package/components/SpacingSwatch/SpacingSwatch.css +108 -0
- package/components/SpacingSwatch/SpacingSwatch.d.ts +20 -0
- package/components/SpacingSwatch/SpacingSwatch.js +50 -0
- package/components/Spinner/Spinner.css +73 -0
- package/components/Spinner/Spinner.d.ts +14 -0
- package/components/Spinner/Spinner.js +42 -0
- package/components/Stat/Stat.css +78 -0
- package/components/Stat/Stat.d.ts +19 -0
- package/components/Stat/Stat.js +30 -0
- package/components/Table/Table.css +186 -0
- package/components/Table/Table.d.ts +45 -0
- package/components/Table/Table.js +65 -0
- package/components/Tabs/Tabs.css +140 -0
- package/components/Tabs/Tabs.d.ts +28 -0
- package/components/Tabs/Tabs.js +77 -0
- package/components/Textarea/Textarea.css +152 -0
- package/components/Textarea/Textarea.d.ts +40 -0
- package/components/Textarea/Textarea.js +74 -0
- package/components/Timeline/Timeline.css +339 -0
- package/components/Timeline/Timeline.d.ts +63 -0
- package/components/Timeline/Timeline.js +69 -0
- package/components/Toast/Toast.css +342 -0
- package/components/Toast/Toast.d.ts +63 -0
- package/components/Toast/Toast.js +213 -0
- package/components/ToggleGroup/ToggleGroup.css +84 -0
- package/components/ToggleGroup/ToggleGroup.d.ts +30 -0
- package/components/ToggleGroup/ToggleGroup.js +53 -0
- package/components/ToggleSwitch/ToggleSwitch.css +139 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +23 -0
- package/components/ToggleSwitch/ToggleSwitch.js +50 -0
- package/components/Tooltip/Tooltip.css +122 -0
- package/components/Tooltip/Tooltip.d.ts +21 -0
- package/components/Tooltip/Tooltip.js +63 -0
- package/components/TypographySwatch/TypographySwatch.css +81 -0
- package/components/TypographySwatch/TypographySwatch.d.ts +24 -0
- package/components/TypographySwatch/TypographySwatch.js +40 -0
- package/components/registry.d.ts +20 -0
- package/components/registry.js +7 -0
- package/components/registry.json +67 -0
- package/components/registry.json.d.ts +70 -0
- package/components/registry.json.js +8 -0
- package/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
- package/fonts/material-symbols.css +94 -0
- package/index.d.ts +62 -0
- package/index.js +123 -0
- package/package.json +63 -0
- package/tokens/registry.d.ts +22 -0
- package/tokens/registry.js +14 -0
- package/tokens/registry.json +203 -0
- package/tokens/registry.json.d.ts +206 -0
- package/tokens/registry.json.js +8 -0
- package/tokens/tokens-dark.css +119 -0
- package/tokens/tokens-light.css +159 -0
- package/tokens/tokens-motion.css +68 -0
- package/tokens/tokens-primitives.css +176 -0
- package/tokens/tokens-typography.css +116 -0
- package/tokens/tokens.css +11 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DROPDOWN MENU COMPONENT
|
|
3
|
+
Contextual menu with sections, sub-menus,
|
|
4
|
+
keyboard shortcuts, and inset-gap hover.
|
|
5
|
+
Tokens aligned to Figma spec.
|
|
6
|
+
============================================ */
|
|
7
|
+
|
|
8
|
+
.ds-dropdown-menu {
|
|
9
|
+
position: relative;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* ============================================
|
|
14
|
+
TRIGGER
|
|
15
|
+
============================================ */
|
|
16
|
+
|
|
17
|
+
.ds-dropdown-menu__trigger {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ds-dropdown-menu__trigger:focus-visible {
|
|
24
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
25
|
+
outline-offset: 2px;
|
|
26
|
+
border-radius: var(--radius-sm);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ============================================
|
|
30
|
+
PANEL
|
|
31
|
+
The floating menu container
|
|
32
|
+
============================================ */
|
|
33
|
+
|
|
34
|
+
.ds-dropdown-menu__panel {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 100%;
|
|
37
|
+
left: 0;
|
|
38
|
+
z-index: 50;
|
|
39
|
+
min-width: 200px;
|
|
40
|
+
margin-top: var(--gap-xxs); /* 4px offset from trigger */
|
|
41
|
+
|
|
42
|
+
/* Appearance — Figma: page/primary bg, input/border/primary, radius/md */
|
|
43
|
+
background: var(--color-bg-page-primary);
|
|
44
|
+
border: var(--border-xs) solid var(--color-input-border-primary);
|
|
45
|
+
border-radius: var(--radius-md); /* 12px */
|
|
46
|
+
box-shadow: var(--shadow-floating);
|
|
47
|
+
|
|
48
|
+
/* Inset gap — Figma: padding/xxs (4px) all sides */
|
|
49
|
+
padding: var(--padding-xxs);
|
|
50
|
+
|
|
51
|
+
/* Reset list */
|
|
52
|
+
list-style: none;
|
|
53
|
+
margin-block: 0;
|
|
54
|
+
|
|
55
|
+
/* Animation */
|
|
56
|
+
animation: ds-dropdown-menu-appear var(--motion-duration-fast) var(--motion-ease-entrance);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ds-dropdown-menu__panel--align-end {
|
|
60
|
+
left: auto;
|
|
61
|
+
right: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Compact items: paragraph-sm-em (14/20), padding xs sm-md (6px 12px), radius-sm (8px) */
|
|
65
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__item {
|
|
66
|
+
padding: var(--padding-xs) var(--padding-sm-md); /* 6px 12px */
|
|
67
|
+
border-radius: var(--radius-sm); /* 8px */
|
|
68
|
+
font-family: var(--font-paragraph-sm-em-family);
|
|
69
|
+
font-size: var(--font-paragraph-sm-em-size);
|
|
70
|
+
font-weight: var(--font-paragraph-sm-em-weight);
|
|
71
|
+
line-height: var(--font-paragraph-sm-em-line-height);
|
|
72
|
+
letter-spacing: var(--font-paragraph-sm-em-letter-spacing);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Compact icons: 20px (vs 24px default) */
|
|
76
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__item-icon {
|
|
77
|
+
--icon-size: var(--icon-size-sm);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Compact submenu chevron: 20px */
|
|
81
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__submenu-icon {
|
|
82
|
+
--icon-size: var(--icon-size-sm);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Compact group label: same padding as compact items so heights match */
|
|
86
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__group-label {
|
|
87
|
+
min-height: auto;
|
|
88
|
+
padding: var(--padding-xs) var(--padding-sm-md); /* matches compact item padding */
|
|
89
|
+
font-size: var(--font-paragraph-sm-em-size);
|
|
90
|
+
line-height: var(--font-paragraph-sm-em-line-height);
|
|
91
|
+
letter-spacing: var(--font-paragraph-sm-em-letter-spacing);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Compact separator margin matches compact item padding */
|
|
95
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__separator {
|
|
96
|
+
margin: var(--padding-xxs) var(--padding-sm-md);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Compact shortcuts */
|
|
100
|
+
.ds-dropdown-menu__panel--compact .ds-dropdown-menu__shortcut {
|
|
101
|
+
font-size: var(--font-caption-size);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* ============================================
|
|
105
|
+
SUB-MENU PANEL
|
|
106
|
+
============================================ */
|
|
107
|
+
|
|
108
|
+
.ds-dropdown-menu__submenu {
|
|
109
|
+
position: absolute;
|
|
110
|
+
left: 100%;
|
|
111
|
+
top: 0;
|
|
112
|
+
margin-left: var(--gap-xxs); /* 4px offset from parent */
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* ============================================
|
|
116
|
+
MENU ITEM
|
|
117
|
+
Figma: Button/secondary internally —
|
|
118
|
+
padding/sm (8px) vertical, padding/md (16px) horizontal,
|
|
119
|
+
radius/md (12px), paragraph-em typography.
|
|
120
|
+
============================================ */
|
|
121
|
+
|
|
122
|
+
.ds-dropdown-menu__item {
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: space-between;
|
|
126
|
+
gap: var(--gap-md); /* 16px between label and shortcut */
|
|
127
|
+
padding: var(--padding-sm) var(--padding-md); /* Figma: 8px 16px */
|
|
128
|
+
border-radius: var(--radius-md); /* Figma: 12px */
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
position: relative;
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
list-style: none;
|
|
133
|
+
|
|
134
|
+
/* Typography — paragraph em (medium weight, matches Figma Button secondary) */
|
|
135
|
+
font-family: var(--font-paragraph-em-family);
|
|
136
|
+
font-size: var(--font-paragraph-em-size);
|
|
137
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
138
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
139
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
140
|
+
color: var(--color-action-passive-text);
|
|
141
|
+
|
|
142
|
+
transition: background-color var(--motion-duration-fast) var(--motion-ease-standard), color var(--motion-duration-fast) var(--motion-ease-standard);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ds-dropdown-menu__item:hover,
|
|
146
|
+
.ds-dropdown-menu__item--focused {
|
|
147
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* ============================================
|
|
151
|
+
DISABLED ITEM
|
|
152
|
+
============================================ */
|
|
153
|
+
|
|
154
|
+
.ds-dropdown-menu__item--disabled {
|
|
155
|
+
opacity: 0.4;
|
|
156
|
+
cursor: not-allowed;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ds-dropdown-menu__item--disabled:hover,
|
|
160
|
+
.ds-dropdown-menu__item--disabled.ds-dropdown-menu__item--focused {
|
|
161
|
+
background-color: transparent;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* ============================================
|
|
165
|
+
ITEM LABEL (text + optional icon)
|
|
166
|
+
============================================ */
|
|
167
|
+
|
|
168
|
+
.ds-dropdown-menu__item-label {
|
|
169
|
+
display: flex;
|
|
170
|
+
align-items: center;
|
|
171
|
+
gap: var(--gap-sm); /* Figma: 8px between icon and text */
|
|
172
|
+
line-height: 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Figma: icons are 24px within menu items */
|
|
176
|
+
.ds-dropdown-menu__item-icon {
|
|
177
|
+
--icon-size: var(--icon-size-md);
|
|
178
|
+
color: var(--color-icon-secondary);
|
|
179
|
+
flex-shrink: 0;
|
|
180
|
+
display: flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
justify-content: center;
|
|
183
|
+
line-height: 1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* ============================================
|
|
187
|
+
KEYBOARD SHORTCUT
|
|
188
|
+
============================================ */
|
|
189
|
+
|
|
190
|
+
.ds-dropdown-menu__shortcut {
|
|
191
|
+
font-family: var(--font-paragraph-sm-family);
|
|
192
|
+
font-size: var(--font-paragraph-sm-size);
|
|
193
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
194
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
195
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
196
|
+
color: var(--color-text-tertiary);
|
|
197
|
+
margin-left: auto;
|
|
198
|
+
flex-shrink: 0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* ============================================
|
|
202
|
+
SUB-MENU INDICATOR
|
|
203
|
+
Figma: 24px chevron icon
|
|
204
|
+
============================================ */
|
|
205
|
+
|
|
206
|
+
.ds-dropdown-menu__submenu-icon {
|
|
207
|
+
--icon-size: var(--icon-size-md);
|
|
208
|
+
color: var(--color-text-tertiary);
|
|
209
|
+
margin-left: auto;
|
|
210
|
+
flex-shrink: 0;
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
justify-content: center;
|
|
214
|
+
line-height: 1;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* ============================================
|
|
218
|
+
SEPARATOR
|
|
219
|
+
============================================ */
|
|
220
|
+
|
|
221
|
+
.ds-dropdown-menu__separator {
|
|
222
|
+
height: 1px;
|
|
223
|
+
background: var(--color-input-border-primary);
|
|
224
|
+
margin: var(--padding-xxs) var(--padding-md);
|
|
225
|
+
list-style: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ============================================
|
|
229
|
+
GROUP
|
|
230
|
+
============================================ */
|
|
231
|
+
|
|
232
|
+
.ds-dropdown-menu__group {
|
|
233
|
+
list-style: none;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Figma: section label is paragraph-em at text/tertiary,
|
|
237
|
+
40px height container, padding-left aligns with item text */
|
|
238
|
+
.ds-dropdown-menu__group-label {
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
min-height: 40px;
|
|
242
|
+
font-family: var(--font-paragraph-em-family);
|
|
243
|
+
font-size: var(--font-paragraph-em-size);
|
|
244
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
245
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
246
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
247
|
+
color: var(--color-text-tertiary);
|
|
248
|
+
padding-left: var(--padding-md);
|
|
249
|
+
padding-right: var(--padding-md);
|
|
250
|
+
user-select: none;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.ds-dropdown-menu__group-list {
|
|
254
|
+
list-style: none;
|
|
255
|
+
margin: 0;
|
|
256
|
+
padding: 0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* ============================================
|
|
260
|
+
HAS-SUBMENU ITEM
|
|
261
|
+
============================================ */
|
|
262
|
+
|
|
263
|
+
.ds-dropdown-menu__item--has-submenu {
|
|
264
|
+
padding-right: var(--padding-sm-md); /* Slightly less right padding for chevron */
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* ============================================
|
|
268
|
+
DESTRUCTIVE ITEM
|
|
269
|
+
Red text/icon for dangerous actions (delete, remove…)
|
|
270
|
+
============================================ */
|
|
271
|
+
|
|
272
|
+
.ds-dropdown-menu__item--destructive {
|
|
273
|
+
color: var(--color-core-accent-coral);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.ds-dropdown-menu__item--destructive .ds-dropdown-menu__item-icon {
|
|
277
|
+
color: var(--color-core-accent-coral);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.ds-dropdown-menu__item--destructive .ds-dropdown-menu__shortcut {
|
|
281
|
+
color: var(--color-core-accent-coral);
|
|
282
|
+
opacity: 0.7;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.ds-dropdown-menu__item--destructive:hover,
|
|
286
|
+
.ds-dropdown-menu__item--destructive.ds-dropdown-menu__item--focused {
|
|
287
|
+
background-color: var(--color-status-error-bg);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* ============================================
|
|
291
|
+
APPEAR ANIMATION
|
|
292
|
+
============================================ */
|
|
293
|
+
|
|
294
|
+
@keyframes ds-dropdown-menu-appear {
|
|
295
|
+
from {
|
|
296
|
+
opacity: 0;
|
|
297
|
+
transform: scale(0.96);
|
|
298
|
+
}
|
|
299
|
+
to {
|
|
300
|
+
opacity: 1;
|
|
301
|
+
transform: scale(1);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface DropdownMenuItem {
|
|
3
|
+
type?: 'item';
|
|
4
|
+
/** Display label */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Keyboard shortcut hint (e.g. "⇧ ⌘ P") */
|
|
7
|
+
shortcut?: string;
|
|
8
|
+
/** Material Symbol icon name */
|
|
9
|
+
icon?: string;
|
|
10
|
+
/** Disabled state */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Destructive / danger styling (red text) for delete, remove, etc. */
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
/** Click handler */
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
/** Nested sub-menu items */
|
|
17
|
+
children?: DropdownMenuEntry[];
|
|
18
|
+
}
|
|
19
|
+
export interface DropdownMenuSeparator {
|
|
20
|
+
type: 'separator';
|
|
21
|
+
}
|
|
22
|
+
export interface DropdownMenuGroup {
|
|
23
|
+
type: 'group';
|
|
24
|
+
/** Section heading */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Items within the group */
|
|
27
|
+
items: DropdownMenuEntry[];
|
|
28
|
+
}
|
|
29
|
+
export type DropdownMenuEntry = DropdownMenuItem | DropdownMenuSeparator | DropdownMenuGroup;
|
|
30
|
+
export interface DropdownMenuProps {
|
|
31
|
+
/** Trigger element that opens the menu */
|
|
32
|
+
trigger: React.ReactNode;
|
|
33
|
+
/** Menu entries (items, groups, separators) */
|
|
34
|
+
items: DropdownMenuEntry[];
|
|
35
|
+
/** Horizontal alignment of the panel */
|
|
36
|
+
align?: 'start' | 'end';
|
|
37
|
+
/** Component size */
|
|
38
|
+
size?: 'default' | 'compact';
|
|
39
|
+
/** Additional CSS classes */
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare const DropdownMenu: ({ trigger, items, align, size, className, }: DropdownMenuProps) => React.JSX.Element;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
3
|
+
import "./DropdownMenu.css";
|
|
4
|
+
import "../../fonts/material-symbols.css";
|
|
5
|
+
function collectItems(entries) {
|
|
6
|
+
const result = [];
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
if (entry.type === "separator") continue;
|
|
9
|
+
if (entry.type === "group") {
|
|
10
|
+
result.push(...collectItems(entry.items));
|
|
11
|
+
} else {
|
|
12
|
+
result.push(entry);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
const SubMenuItem = ({ item, baseClass, focused, size, onActivate }) => {
|
|
18
|
+
const [subOpen, setSubOpen] = useState(false);
|
|
19
|
+
const timeoutRef = useRef(null);
|
|
20
|
+
const handleMouseEnter = () => {
|
|
21
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
22
|
+
setSubOpen(true);
|
|
23
|
+
};
|
|
24
|
+
const handleMouseLeave = () => {
|
|
25
|
+
timeoutRef.current = setTimeout(() => setSubOpen(false), 150);
|
|
26
|
+
};
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
return () => {
|
|
29
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (focused && item.children && item.children.length > 0) {
|
|
34
|
+
setSubOpen(true);
|
|
35
|
+
}
|
|
36
|
+
}, [focused, item.children]);
|
|
37
|
+
const classes = [
|
|
38
|
+
`${baseClass}__item`,
|
|
39
|
+
focused ? `${baseClass}__item--focused` : "",
|
|
40
|
+
item.disabled ? `${baseClass}__item--disabled` : "",
|
|
41
|
+
item.destructive ? `${baseClass}__item--destructive` : "",
|
|
42
|
+
`${baseClass}__item--has-submenu`
|
|
43
|
+
].filter(Boolean).join(" ");
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
"li",
|
|
46
|
+
{
|
|
47
|
+
className: classes,
|
|
48
|
+
role: "menuitem",
|
|
49
|
+
"aria-haspopup": "menu",
|
|
50
|
+
"aria-expanded": subOpen,
|
|
51
|
+
"aria-disabled": item.disabled || void 0,
|
|
52
|
+
onMouseEnter: handleMouseEnter,
|
|
53
|
+
onMouseLeave: handleMouseLeave,
|
|
54
|
+
onClick: (e) => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
if (!item.disabled) setSubOpen((prev) => !prev);
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsxs("span", { className: `${baseClass}__item-label`, children: [
|
|
60
|
+
item.icon && /* @__PURE__ */ jsx("span", { className: `${baseClass}__item-icon material-symbols-rounded`, "aria-hidden": "true", children: item.icon }),
|
|
61
|
+
item.label
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__submenu-icon material-symbols-rounded`, "aria-hidden": "true", children: "chevron_right" }),
|
|
64
|
+
subOpen && item.children && /* @__PURE__ */ jsx(
|
|
65
|
+
MenuPanel,
|
|
66
|
+
{
|
|
67
|
+
entries: item.children,
|
|
68
|
+
baseClass,
|
|
69
|
+
size,
|
|
70
|
+
isSubmenu: true,
|
|
71
|
+
onItemActivate: onActivate
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
const MenuPanel = ({
|
|
79
|
+
entries,
|
|
80
|
+
baseClass,
|
|
81
|
+
size,
|
|
82
|
+
isSubmenu = false,
|
|
83
|
+
onItemActivate
|
|
84
|
+
}) => {
|
|
85
|
+
const panelClasses = [
|
|
86
|
+
`${baseClass}__panel`,
|
|
87
|
+
isSubmenu ? `${baseClass}__submenu` : "",
|
|
88
|
+
size === "compact" ? `${baseClass}__panel--compact` : ""
|
|
89
|
+
].filter(Boolean).join(" ");
|
|
90
|
+
const renderEntry = (entry, index) => {
|
|
91
|
+
if (entry.type === "separator") {
|
|
92
|
+
return /* @__PURE__ */ jsx("li", { className: `${baseClass}__separator`, role: "separator" }, `sep-${index}`);
|
|
93
|
+
}
|
|
94
|
+
if (entry.type === "group") {
|
|
95
|
+
return /* @__PURE__ */ jsxs("li", { className: `${baseClass}__group`, role: "group", "aria-label": entry.label, children: [
|
|
96
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__group-label`, children: entry.label }),
|
|
97
|
+
/* @__PURE__ */ jsx("ul", { className: `${baseClass}__group-list`, role: "group", children: entry.items.map((subEntry, subIndex) => renderEntry(subEntry, subIndex)) })
|
|
98
|
+
] }, `group-${index}`);
|
|
99
|
+
}
|
|
100
|
+
if (entry.children && entry.children.length > 0) {
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
SubMenuItem,
|
|
103
|
+
{
|
|
104
|
+
item: entry,
|
|
105
|
+
baseClass,
|
|
106
|
+
focused: false,
|
|
107
|
+
size,
|
|
108
|
+
onActivate: onItemActivate
|
|
109
|
+
},
|
|
110
|
+
`submenu-${index}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
const itemClasses = [
|
|
114
|
+
`${baseClass}__item`,
|
|
115
|
+
entry.disabled ? `${baseClass}__item--disabled` : "",
|
|
116
|
+
entry.destructive ? `${baseClass}__item--destructive` : ""
|
|
117
|
+
].filter(Boolean).join(" ");
|
|
118
|
+
return /* @__PURE__ */ jsxs(
|
|
119
|
+
"li",
|
|
120
|
+
{
|
|
121
|
+
className: itemClasses,
|
|
122
|
+
role: "menuitem",
|
|
123
|
+
"aria-disabled": entry.disabled || void 0,
|
|
124
|
+
onClick: (e) => {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
if (!entry.disabled) {
|
|
127
|
+
entry.onClick?.();
|
|
128
|
+
onItemActivate();
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsxs("span", { className: `${baseClass}__item-label`, children: [
|
|
133
|
+
entry.icon && /* @__PURE__ */ jsx("span", { className: `${baseClass}__item-icon material-symbols-rounded`, "aria-hidden": "true", children: entry.icon }),
|
|
134
|
+
entry.label
|
|
135
|
+
] }),
|
|
136
|
+
entry.shortcut && /* @__PURE__ */ jsx("span", { className: `${baseClass}__shortcut`, children: entry.shortcut })
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
`item-${index}`
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
return /* @__PURE__ */ jsx("ul", { className: panelClasses, role: "menu", children: entries.map((entry, index) => renderEntry(entry, index)) });
|
|
143
|
+
};
|
|
144
|
+
const DropdownMenu = ({
|
|
145
|
+
trigger,
|
|
146
|
+
items,
|
|
147
|
+
align = "start",
|
|
148
|
+
size = "default",
|
|
149
|
+
className = ""
|
|
150
|
+
}) => {
|
|
151
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
152
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
153
|
+
const rootRef = useRef(null);
|
|
154
|
+
const panelRef = useRef(null);
|
|
155
|
+
const baseClass = "ds-dropdown-menu";
|
|
156
|
+
const classes = [baseClass, className].filter(Boolean).join(" ");
|
|
157
|
+
const flatItems = collectItems(items);
|
|
158
|
+
const handleToggle = () => {
|
|
159
|
+
setIsOpen((prev) => {
|
|
160
|
+
if (!prev) setFocusedIndex(-1);
|
|
161
|
+
return !prev;
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const handleClose = useCallback(() => {
|
|
165
|
+
setIsOpen(false);
|
|
166
|
+
setFocusedIndex(-1);
|
|
167
|
+
}, []);
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
const handler = (e) => {
|
|
170
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
171
|
+
handleClose();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
document.addEventListener("mousedown", handler);
|
|
175
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
176
|
+
}, [handleClose]);
|
|
177
|
+
const handleKeyDown = (e) => {
|
|
178
|
+
switch (e.key) {
|
|
179
|
+
case "Enter":
|
|
180
|
+
case " ":
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
if (!isOpen) {
|
|
183
|
+
setIsOpen(true);
|
|
184
|
+
setFocusedIndex(0);
|
|
185
|
+
} else if (focusedIndex >= 0) {
|
|
186
|
+
const item = flatItems[focusedIndex];
|
|
187
|
+
if (item && !item.disabled && !item.children) {
|
|
188
|
+
item.onClick?.();
|
|
189
|
+
handleClose();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case "ArrowDown":
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
if (!isOpen) {
|
|
196
|
+
setIsOpen(true);
|
|
197
|
+
setFocusedIndex(0);
|
|
198
|
+
} else {
|
|
199
|
+
setFocusedIndex((prev) => {
|
|
200
|
+
let next = prev + 1;
|
|
201
|
+
while (next < flatItems.length && flatItems[next].disabled) next++;
|
|
202
|
+
return next < flatItems.length ? next : prev;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case "ArrowUp":
|
|
207
|
+
e.preventDefault();
|
|
208
|
+
if (isOpen) {
|
|
209
|
+
setFocusedIndex((prev) => {
|
|
210
|
+
let next = prev - 1;
|
|
211
|
+
while (next >= 0 && flatItems[next].disabled) next--;
|
|
212
|
+
return next >= 0 ? next : prev;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
case "Escape":
|
|
217
|
+
case "Tab":
|
|
218
|
+
handleClose();
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
if (isOpen && focusedIndex >= 0 && panelRef.current) {
|
|
224
|
+
const allItems = panelRef.current.querySelectorAll(`[role="menuitem"]`);
|
|
225
|
+
const el = allItems[focusedIndex];
|
|
226
|
+
el?.scrollIntoView({ block: "nearest" });
|
|
227
|
+
}
|
|
228
|
+
}, [focusedIndex, isOpen]);
|
|
229
|
+
const renderPanelEntry = (entry, index, itemCounter2) => {
|
|
230
|
+
if (entry.type === "separator") {
|
|
231
|
+
return /* @__PURE__ */ jsx("li", { className: `${baseClass}__separator`, role: "separator" }, `sep-${index}`);
|
|
232
|
+
}
|
|
233
|
+
if (entry.type === "group") {
|
|
234
|
+
return /* @__PURE__ */ jsxs("li", { className: `${baseClass}__group`, role: "none", children: [
|
|
235
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__group-label`, role: "presentation", children: entry.label }),
|
|
236
|
+
/* @__PURE__ */ jsx("ul", { className: `${baseClass}__group-list`, role: "group", "aria-label": entry.label, children: entry.items.map(
|
|
237
|
+
(subEntry, subIndex) => renderPanelEntry(subEntry, subIndex, itemCounter2)
|
|
238
|
+
) })
|
|
239
|
+
] }, `group-${index}`);
|
|
240
|
+
}
|
|
241
|
+
const myIndex = itemCounter2.count;
|
|
242
|
+
itemCounter2.count++;
|
|
243
|
+
const isFocused = myIndex === focusedIndex;
|
|
244
|
+
if (entry.children && entry.children.length > 0) {
|
|
245
|
+
return /* @__PURE__ */ jsx(
|
|
246
|
+
SubMenuItem,
|
|
247
|
+
{
|
|
248
|
+
item: entry,
|
|
249
|
+
baseClass,
|
|
250
|
+
focused: isFocused,
|
|
251
|
+
size,
|
|
252
|
+
onActivate: handleClose
|
|
253
|
+
},
|
|
254
|
+
`submenu-${index}`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const itemClasses = [
|
|
258
|
+
`${baseClass}__item`,
|
|
259
|
+
isFocused ? `${baseClass}__item--focused` : "",
|
|
260
|
+
entry.disabled ? `${baseClass}__item--disabled` : "",
|
|
261
|
+
entry.destructive ? `${baseClass}__item--destructive` : ""
|
|
262
|
+
].filter(Boolean).join(" ");
|
|
263
|
+
return /* @__PURE__ */ jsxs(
|
|
264
|
+
"li",
|
|
265
|
+
{
|
|
266
|
+
className: itemClasses,
|
|
267
|
+
role: "menuitem",
|
|
268
|
+
"aria-disabled": entry.disabled || void 0,
|
|
269
|
+
onClick: (e) => {
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
if (!entry.disabled) {
|
|
272
|
+
entry.onClick?.();
|
|
273
|
+
handleClose();
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsxs("span", { className: `${baseClass}__item-label`, children: [
|
|
278
|
+
entry.icon && /* @__PURE__ */ jsx("span", { className: `${baseClass}__item-icon material-symbols-rounded`, "aria-hidden": "true", children: entry.icon }),
|
|
279
|
+
entry.label
|
|
280
|
+
] }),
|
|
281
|
+
entry.shortcut && /* @__PURE__ */ jsx("span", { className: `${baseClass}__shortcut`, children: entry.shortcut })
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
`item-${index}`
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
const panelClasses = [
|
|
288
|
+
`${baseClass}__panel`,
|
|
289
|
+
align === "end" ? `${baseClass}__panel--align-end` : "",
|
|
290
|
+
size === "compact" ? `${baseClass}__panel--compact` : ""
|
|
291
|
+
].filter(Boolean).join(" ");
|
|
292
|
+
const itemCounter = { count: 0 };
|
|
293
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, ref: rootRef, children: [
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
"div",
|
|
296
|
+
{
|
|
297
|
+
className: `${baseClass}__trigger`,
|
|
298
|
+
role: "button",
|
|
299
|
+
tabIndex: 0,
|
|
300
|
+
"aria-haspopup": "menu",
|
|
301
|
+
"aria-expanded": isOpen,
|
|
302
|
+
onClick: handleToggle,
|
|
303
|
+
onKeyDown: handleKeyDown,
|
|
304
|
+
children: trigger
|
|
305
|
+
}
|
|
306
|
+
),
|
|
307
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
308
|
+
"ul",
|
|
309
|
+
{
|
|
310
|
+
className: panelClasses,
|
|
311
|
+
role: "menu",
|
|
312
|
+
ref: (el) => {
|
|
313
|
+
panelRef.current = el;
|
|
314
|
+
},
|
|
315
|
+
children: items.map((entry, index) => renderPanelEntry(entry, index, itemCounter))
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] });
|
|
319
|
+
};
|
|
320
|
+
export {
|
|
321
|
+
DropdownMenu
|
|
322
|
+
};
|