@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,300 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DROPDOWN COMPONENT
|
|
3
|
+
Custom select with menu, keyboard navigation
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-dropdown {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--gap-sm); /* 8px */
|
|
10
|
+
width: 100%;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* ============================================
|
|
15
|
+
LABEL
|
|
16
|
+
============================================ */
|
|
17
|
+
|
|
18
|
+
.ds-dropdown__label {
|
|
19
|
+
font-family: var(--font-paragraph-em-family);
|
|
20
|
+
font-size: var(--font-paragraph-em-size);
|
|
21
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
22
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
23
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
24
|
+
color: var(--color-text-primary);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ds-dropdown__required {
|
|
28
|
+
color: var(--color-core-accent-coral);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ============================================
|
|
32
|
+
TRIGGER
|
|
33
|
+
============================================ */
|
|
34
|
+
|
|
35
|
+
.ds-dropdown__trigger {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: var(--gap-sm); /* 8px */
|
|
40
|
+
padding: var(--padding-sm) var(--padding-md); /* 8px 16px */
|
|
41
|
+
border: var(--border-xs) solid var(--color-input-border-primary);
|
|
42
|
+
border-radius: var(--radius-md); /* 12px */
|
|
43
|
+
background-color: var(--color-input-bg-primary);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: border-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
46
|
+
outline: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ds-dropdown__trigger:hover:not(:focus-visible) {
|
|
50
|
+
border-color: var(--color-input-border-hover);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ds-dropdown__trigger:focus-visible {
|
|
54
|
+
border-color: var(--color-input-border-selected);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ds-dropdown--open .ds-dropdown__trigger {
|
|
58
|
+
border-color: var(--color-input-border-selected);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ============================================
|
|
62
|
+
VALUE / PLACEHOLDER
|
|
63
|
+
============================================ */
|
|
64
|
+
|
|
65
|
+
.ds-dropdown__value {
|
|
66
|
+
font-family: var(--font-paragraph-em-family);
|
|
67
|
+
font-size: var(--font-paragraph-em-size);
|
|
68
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
69
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
70
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
71
|
+
color: var(--color-input-text-primary);
|
|
72
|
+
flex: 1;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
text-overflow: ellipsis;
|
|
75
|
+
white-space: nowrap;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.ds-dropdown__value--placeholder {
|
|
79
|
+
color: var(--color-input-text-placeholder);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ============================================
|
|
83
|
+
CHEVRON
|
|
84
|
+
============================================ */
|
|
85
|
+
|
|
86
|
+
.ds-dropdown__chevron {
|
|
87
|
+
--icon-size: var(--icon-size-md);
|
|
88
|
+
color: var(--color-icon-primary);
|
|
89
|
+
transition: transform var(--motion-duration-base) var(--motion-ease-standard);
|
|
90
|
+
flex-shrink: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ds-dropdown--open .ds-dropdown__chevron {
|
|
94
|
+
transform: rotate(180deg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* ============================================
|
|
98
|
+
MENU
|
|
99
|
+
============================================ */
|
|
100
|
+
|
|
101
|
+
.ds-dropdown__menu {
|
|
102
|
+
position: absolute;
|
|
103
|
+
top: 100%;
|
|
104
|
+
left: 0;
|
|
105
|
+
right: 0;
|
|
106
|
+
margin-top: var(--gap-xxs); /* 2px */
|
|
107
|
+
padding: var(--padding-xxs); /* inset gap on all sides */
|
|
108
|
+
border: var(--border-xs) solid var(--color-input-border-primary);
|
|
109
|
+
border-radius: var(--radius-md); /* 12px */
|
|
110
|
+
background-color: var(--color-bg-page-primary);
|
|
111
|
+
list-style: none;
|
|
112
|
+
max-height: 240px;
|
|
113
|
+
overflow-y: auto;
|
|
114
|
+
z-index: 10;
|
|
115
|
+
box-shadow: var(--shadow-floating);
|
|
116
|
+
|
|
117
|
+
/* Animation */
|
|
118
|
+
animation: ds-dropdown-appear var(--motion-duration-fast) var(--motion-ease-entrance);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@keyframes ds-dropdown-appear {
|
|
122
|
+
from {
|
|
123
|
+
opacity: 0;
|
|
124
|
+
transform: scale(0.96);
|
|
125
|
+
}
|
|
126
|
+
to {
|
|
127
|
+
opacity: 1;
|
|
128
|
+
transform: scale(1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* ============================================
|
|
133
|
+
OPTION (with inset-gap hover)
|
|
134
|
+
============================================ */
|
|
135
|
+
|
|
136
|
+
.ds-dropdown__option {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
padding: var(--padding-sm) var(--padding-sm-md); /* 8px 12px */
|
|
141
|
+
border-radius: var(--radius-sm);
|
|
142
|
+
font-family: var(--font-paragraph-em-family);
|
|
143
|
+
font-size: var(--font-paragraph-em-size);
|
|
144
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
145
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
146
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
147
|
+
color: var(--color-text-primary);
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
transition: background-color var(--motion-duration-fast) var(--motion-ease-standard);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ds-dropdown__option:hover {
|
|
153
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.ds-dropdown__option--focused {
|
|
157
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.ds-dropdown__option--selected {
|
|
161
|
+
color: var(--color-action-primary-text-tertiary);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.ds-dropdown__option--disabled {
|
|
165
|
+
opacity: 0.4;
|
|
166
|
+
cursor: not-allowed;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.ds-dropdown__option--disabled:hover {
|
|
170
|
+
background-color: transparent;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* ============================================
|
|
174
|
+
GROUPED MODE
|
|
175
|
+
============================================ */
|
|
176
|
+
|
|
177
|
+
.ds-dropdown__group {
|
|
178
|
+
list-style: none;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.ds-dropdown__group-label {
|
|
182
|
+
display: block;
|
|
183
|
+
font-family: var(--font-paragraph-sm-family);
|
|
184
|
+
font-size: var(--font-paragraph-sm-size);
|
|
185
|
+
font-weight: var(--font-paragraph-sm-em-weight);
|
|
186
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
187
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
188
|
+
color: var(--color-text-tertiary);
|
|
189
|
+
padding: var(--padding-xs) var(--padding-sm-md);
|
|
190
|
+
user-select: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.ds-dropdown__group-list {
|
|
194
|
+
list-style: none;
|
|
195
|
+
margin: 0;
|
|
196
|
+
padding: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.ds-dropdown__separator {
|
|
200
|
+
height: 1px;
|
|
201
|
+
background: var(--color-bg-container-border);
|
|
202
|
+
margin: var(--padding-xxs) var(--padding-sm);
|
|
203
|
+
list-style: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* ============================================
|
|
207
|
+
CHECK ICON
|
|
208
|
+
============================================ */
|
|
209
|
+
|
|
210
|
+
.ds-dropdown__check {
|
|
211
|
+
--icon-size: var(--icon-size-md);
|
|
212
|
+
color: var(--color-action-primary-bg);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* ============================================
|
|
216
|
+
HELPER TEXT
|
|
217
|
+
============================================ */
|
|
218
|
+
|
|
219
|
+
.ds-dropdown__helper {
|
|
220
|
+
font-family: var(--font-paragraph-sm-family);
|
|
221
|
+
font-size: var(--font-paragraph-sm-size);
|
|
222
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
223
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
224
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
225
|
+
color: var(--color-text-tertiary);
|
|
226
|
+
margin: 0;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* ============================================
|
|
230
|
+
ERROR STATE
|
|
231
|
+
============================================ */
|
|
232
|
+
|
|
233
|
+
.ds-dropdown--error .ds-dropdown__trigger {
|
|
234
|
+
border-color: var(--color-status-error-border);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.ds-dropdown--error .ds-dropdown__helper {
|
|
238
|
+
color: var(--color-status-error-border);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* ============================================
|
|
242
|
+
DISABLED STATE
|
|
243
|
+
============================================ */
|
|
244
|
+
|
|
245
|
+
.ds-dropdown--disabled .ds-dropdown__label {
|
|
246
|
+
color: var(--color-input-text-disabled);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.ds-dropdown--disabled .ds-dropdown__trigger {
|
|
250
|
+
background-color: var(--color-input-bg-disabled);
|
|
251
|
+
border-color: var(--color-input-border-disabled);
|
|
252
|
+
cursor: not-allowed;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.ds-dropdown--disabled .ds-dropdown__value {
|
|
256
|
+
color: var(--color-input-text-disabled);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.ds-dropdown--disabled .ds-dropdown__chevron {
|
|
260
|
+
color: var(--color-input-text-disabled);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* ============================================
|
|
264
|
+
SIZE — COMPACT
|
|
265
|
+
============================================ */
|
|
266
|
+
|
|
267
|
+
.ds-dropdown--compact .ds-dropdown__trigger {
|
|
268
|
+
padding: var(--padding-xs) var(--padding-sm-md); /* 6px 12px */
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.ds-dropdown--compact .ds-dropdown__value {
|
|
272
|
+
font-size: var(--font-paragraph-sm-em-size);
|
|
273
|
+
line-height: var(--font-paragraph-sm-em-line-height);
|
|
274
|
+
letter-spacing: var(--font-paragraph-sm-em-letter-spacing);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.ds-dropdown--compact .ds-dropdown__chevron {
|
|
278
|
+
--icon-size: var(--icon-size-sm);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.ds-dropdown--compact .ds-dropdown__label {
|
|
282
|
+
font-size: var(--font-paragraph-sm-size);
|
|
283
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.ds-dropdown--compact .ds-dropdown__option {
|
|
287
|
+
padding: var(--padding-xs) var(--padding-sm); /* 6px 8px */
|
|
288
|
+
font-size: var(--font-paragraph-sm-em-size);
|
|
289
|
+
line-height: var(--font-paragraph-sm-em-line-height);
|
|
290
|
+
letter-spacing: var(--font-paragraph-sm-em-letter-spacing);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.ds-dropdown--compact .ds-dropdown__group-label {
|
|
294
|
+
font-size: var(--font-caption-size);
|
|
295
|
+
line-height: var(--font-caption-line-height);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.ds-dropdown--compact .ds-dropdown__check {
|
|
299
|
+
--icon-size: var(--icon-size-sm);
|
|
300
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface DropdownOption {
|
|
3
|
+
/** Display label */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Option value */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Whether this option is disabled */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DropdownOptionGroup {
|
|
11
|
+
/** Group heading */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Options within the group */
|
|
14
|
+
options: DropdownOption[];
|
|
15
|
+
}
|
|
16
|
+
export interface DropdownProps {
|
|
17
|
+
/** Dropdown label text */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Placeholder when no value selected */
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
/** Currently selected value */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** Available options (flat list) */
|
|
24
|
+
options: DropdownOption[];
|
|
25
|
+
/** Optional grouped options — when provided, renders groups with labels and separators */
|
|
26
|
+
groups?: DropdownOptionGroup[];
|
|
27
|
+
/** Component size */
|
|
28
|
+
size?: 'default' | 'compact';
|
|
29
|
+
/** Whether the dropdown is disabled */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Whether the dropdown is required */
|
|
32
|
+
required?: boolean;
|
|
33
|
+
/** Error state */
|
|
34
|
+
error?: boolean;
|
|
35
|
+
/** Helper or error message */
|
|
36
|
+
helperText?: string;
|
|
37
|
+
/** Callback when selection changes */
|
|
38
|
+
onChange?: (value: string) => void;
|
|
39
|
+
/** Additional CSS classes */
|
|
40
|
+
className?: string;
|
|
41
|
+
/** Accessible label override */
|
|
42
|
+
ariaLabel?: string;
|
|
43
|
+
/** HTML name attribute */
|
|
44
|
+
name?: string;
|
|
45
|
+
/** HTML id attribute */
|
|
46
|
+
id?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const Dropdown: ({ label, placeholder, value, options, groups, size, disabled, required, error, helperText, onChange, className, ariaLabel, name, id, }: DropdownProps) => React.JSX.Element;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
3
|
+
import "./Dropdown.css";
|
|
4
|
+
import "../../fonts/material-symbols.css";
|
|
5
|
+
const Dropdown = ({
|
|
6
|
+
label,
|
|
7
|
+
placeholder = "Select an option",
|
|
8
|
+
value,
|
|
9
|
+
options,
|
|
10
|
+
groups,
|
|
11
|
+
size = "default",
|
|
12
|
+
disabled = false,
|
|
13
|
+
required = false,
|
|
14
|
+
error = false,
|
|
15
|
+
helperText,
|
|
16
|
+
onChange,
|
|
17
|
+
className = "",
|
|
18
|
+
ariaLabel,
|
|
19
|
+
name,
|
|
20
|
+
id
|
|
21
|
+
}) => {
|
|
22
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
23
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
24
|
+
const dropdownRef = useRef(null);
|
|
25
|
+
const listRef = useRef(null);
|
|
26
|
+
const baseClass = "ds-dropdown";
|
|
27
|
+
const isGrouped = groups && groups.length > 0;
|
|
28
|
+
const sizeClass = size === "compact" ? `${baseClass}--compact` : "";
|
|
29
|
+
const openClass = isOpen ? `${baseClass}--open` : "";
|
|
30
|
+
const errorClass = error ? `${baseClass}--error` : "";
|
|
31
|
+
const disabledClass = disabled ? `${baseClass}--disabled` : "";
|
|
32
|
+
const classes = [baseClass, sizeClass, openClass, errorClass, disabledClass, className].filter(Boolean).join(" ");
|
|
33
|
+
const flatOptions = isGrouped ? groups.flatMap((g) => g.options) : options;
|
|
34
|
+
const selectedOption = flatOptions.find((opt) => opt.value === value);
|
|
35
|
+
const inputId = id || name || label?.toLowerCase().replace(/\s+/g, "-");
|
|
36
|
+
const handleToggle = () => {
|
|
37
|
+
if (!disabled) {
|
|
38
|
+
setIsOpen((prev) => !prev);
|
|
39
|
+
setFocusedIndex(-1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleSelect = (optionValue) => {
|
|
43
|
+
if (onChange) {
|
|
44
|
+
onChange(optionValue);
|
|
45
|
+
}
|
|
46
|
+
setIsOpen(false);
|
|
47
|
+
};
|
|
48
|
+
const handleClickOutside = useCallback((e) => {
|
|
49
|
+
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
50
|
+
setIsOpen(false);
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
55
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
56
|
+
}, [handleClickOutside]);
|
|
57
|
+
const handleKeyDown = (e) => {
|
|
58
|
+
if (disabled) return;
|
|
59
|
+
switch (e.key) {
|
|
60
|
+
case "Enter":
|
|
61
|
+
case " ":
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
if (isOpen && focusedIndex >= 0 && !flatOptions[focusedIndex]?.disabled) {
|
|
64
|
+
handleSelect(flatOptions[focusedIndex].value);
|
|
65
|
+
} else {
|
|
66
|
+
setIsOpen((prev) => !prev);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowDown":
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
if (!isOpen) {
|
|
72
|
+
setIsOpen(true);
|
|
73
|
+
} else {
|
|
74
|
+
setFocusedIndex((prev) => {
|
|
75
|
+
let next = prev + 1;
|
|
76
|
+
while (next < flatOptions.length && flatOptions[next].disabled) next++;
|
|
77
|
+
return next < flatOptions.length ? next : prev;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case "ArrowUp":
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
if (isOpen) {
|
|
84
|
+
setFocusedIndex((prev) => {
|
|
85
|
+
let next = prev - 1;
|
|
86
|
+
while (next >= 0 && flatOptions[next].disabled) next--;
|
|
87
|
+
return next >= 0 ? next : prev;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "Escape":
|
|
92
|
+
setIsOpen(false);
|
|
93
|
+
break;
|
|
94
|
+
case "Tab":
|
|
95
|
+
setIsOpen(false);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (isOpen && focusedIndex >= 0 && listRef.current) {
|
|
101
|
+
const focusedEl = listRef.current.children[focusedIndex];
|
|
102
|
+
focusedEl?.scrollIntoView({ block: "nearest" });
|
|
103
|
+
}
|
|
104
|
+
}, [focusedIndex, isOpen]);
|
|
105
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, ref: dropdownRef, children: [
|
|
106
|
+
label && /* @__PURE__ */ jsxs("label", { className: `${baseClass}__label`, id: `${inputId}-label`, children: [
|
|
107
|
+
label,
|
|
108
|
+
required && /* @__PURE__ */ jsx("span", { className: `${baseClass}__required`, "aria-hidden": "true", children: " *" })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ jsxs(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: `${baseClass}__trigger`,
|
|
114
|
+
role: "combobox",
|
|
115
|
+
"aria-expanded": isOpen,
|
|
116
|
+
"aria-haspopup": "listbox",
|
|
117
|
+
"aria-labelledby": label ? `${inputId}-label` : void 0,
|
|
118
|
+
"aria-label": ariaLabel || (!label ? placeholder : void 0),
|
|
119
|
+
"aria-controls": `${inputId}-listbox`,
|
|
120
|
+
tabIndex: disabled ? -1 : 0,
|
|
121
|
+
onClick: handleToggle,
|
|
122
|
+
onKeyDown: handleKeyDown,
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__value ${!selectedOption ? `${baseClass}__value--placeholder` : ""}`, children: selectedOption ? selectedOption.label : placeholder }),
|
|
125
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__chevron material-symbols-rounded`, "aria-hidden": "true", children: "expand_more" })
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
130
|
+
"ul",
|
|
131
|
+
{
|
|
132
|
+
className: [
|
|
133
|
+
`${baseClass}__menu`,
|
|
134
|
+
isGrouped ? `${baseClass}__menu--grouped` : ""
|
|
135
|
+
].filter(Boolean).join(" "),
|
|
136
|
+
role: "listbox",
|
|
137
|
+
id: `${inputId}-listbox`,
|
|
138
|
+
ref: listRef,
|
|
139
|
+
"aria-labelledby": label ? `${inputId}-label` : void 0,
|
|
140
|
+
children: isGrouped ? (() => {
|
|
141
|
+
let flatIndex = 0;
|
|
142
|
+
return groups.map((group, groupIdx) => /* @__PURE__ */ jsxs("li", { className: `${baseClass}__group`, role: "none", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__group-label`, role: "presentation", children: group.label }),
|
|
144
|
+
/* @__PURE__ */ jsx("ul", { className: `${baseClass}__group-list`, role: "group", "aria-label": group.label, children: group.options.map((option) => {
|
|
145
|
+
const myIndex = flatIndex++;
|
|
146
|
+
return /* @__PURE__ */ jsxs(
|
|
147
|
+
"li",
|
|
148
|
+
{
|
|
149
|
+
className: [
|
|
150
|
+
`${baseClass}__option`,
|
|
151
|
+
option.value === value ? `${baseClass}__option--selected` : "",
|
|
152
|
+
option.disabled ? `${baseClass}__option--disabled` : "",
|
|
153
|
+
myIndex === focusedIndex ? `${baseClass}__option--focused` : ""
|
|
154
|
+
].filter(Boolean).join(" "),
|
|
155
|
+
role: "option",
|
|
156
|
+
"aria-selected": option.value === value,
|
|
157
|
+
"aria-disabled": option.disabled,
|
|
158
|
+
onClick: () => !option.disabled && handleSelect(option.value),
|
|
159
|
+
children: [
|
|
160
|
+
option.label,
|
|
161
|
+
option.value === value && /* @__PURE__ */ jsx("span", { className: `${baseClass}__check material-symbols-rounded`, "aria-hidden": "true", children: "check" })
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
option.value
|
|
165
|
+
);
|
|
166
|
+
}) }),
|
|
167
|
+
groupIdx < groups.length - 1 && /* @__PURE__ */ jsx("li", { className: `${baseClass}__separator`, role: "separator" })
|
|
168
|
+
] }, `group-${groupIdx}`));
|
|
169
|
+
})() : options.map((option, index) => /* @__PURE__ */ jsxs(
|
|
170
|
+
"li",
|
|
171
|
+
{
|
|
172
|
+
className: [
|
|
173
|
+
`${baseClass}__option`,
|
|
174
|
+
option.value === value ? `${baseClass}__option--selected` : "",
|
|
175
|
+
option.disabled ? `${baseClass}__option--disabled` : "",
|
|
176
|
+
index === focusedIndex ? `${baseClass}__option--focused` : ""
|
|
177
|
+
].filter(Boolean).join(" "),
|
|
178
|
+
role: "option",
|
|
179
|
+
"aria-selected": option.value === value,
|
|
180
|
+
"aria-disabled": option.disabled,
|
|
181
|
+
onClick: () => !option.disabled && handleSelect(option.value),
|
|
182
|
+
children: [
|
|
183
|
+
option.label,
|
|
184
|
+
option.value === value && /* @__PURE__ */ jsx("span", { className: `${baseClass}__check material-symbols-rounded`, "aria-hidden": "true", children: "check" })
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
option.value
|
|
188
|
+
))
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
helperText && /* @__PURE__ */ jsx("p", { className: `${baseClass}__helper`, id: `${inputId}-helper`, children: helperText })
|
|
192
|
+
] });
|
|
193
|
+
};
|
|
194
|
+
export {
|
|
195
|
+
Dropdown
|
|
196
|
+
};
|