fluent-svelte-extra 1.9.5 → 1.9.6
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/Acrylic/AcrylicSurface.scss +6 -6
- package/Acrylic/AcrylicSurface.svelte +26 -26
- package/AutoSuggestBox/AutoSuggestBox.scss +44 -44
- package/AutoSuggestBox/AutoSuggestBox.svelte +85 -85
- package/Button/Button.scss +94 -94
- package/Button/Button.svelte +25 -25
- package/CalendarDatePicker/CalendarDatePicker.scss +15 -15
- package/CalendarDatePicker/CalendarDatePicker.svelte +45 -45
- package/CalendarView/CalendarView.scss +156 -156
- package/CalendarView/CalendarView.svelte +269 -269
- package/CalendarView/CalendarViewItem.scss +130 -130
- package/CalendarView/CalendarViewItem.svelte +23 -23
- package/Checkbox/Checkbox.scss +117 -117
- package/Checkbox/Checkbox.svelte +52 -52
- package/ComboBox/ComboBox.scss +152 -152
- package/ComboBox/ComboBox.svelte +155 -155
- package/ComboBox/ComboBoxItem.scss +80 -80
- package/ComboBox/ComboBoxItem.svelte +17 -17
- package/ContentDialog/ContentDialog.scss +98 -98
- package/ContentDialog/ContentDialog.svelte +76 -76
- package/ContextMenu/ContextMenu.scss +11 -11
- package/ContextMenu/ContextMenu.svelte +37 -37
- package/ExpandMenu/ExpandMenu.svelte +9 -9
- package/Expander/Expander.scss +136 -136
- package/Expander/Expander.svelte +95 -95
- package/Flipper/Flipper.svelte +37 -37
- package/Flyout/FlyoutSurface.scss +14 -14
- package/Flyout/FlyoutSurface.svelte +7 -7
- package/Flyout/FlyoutWrapper.scss +86 -86
- package/Flyout/FlyoutWrapper.svelte +60 -60
- package/GridView/GridViewItem.scss +20 -20
- package/GridView/GridViewItem.svelte +33 -25
- package/IconButton/IconButton.scss +32 -32
- package/IconButton/IconButton.svelte +28 -28
- package/InfoBadge/InfoBadge.scss +39 -39
- package/InfoBadge/InfoBadge.svelte +59 -59
- package/InfoBar/InfoBar.scss +122 -122
- package/InfoBar/InfoBar.svelte +76 -76
- package/ListItem/ListItem.scss +76 -76
- package/ListItem/ListItem.svelte +49 -49
- package/MenuBar/MenuBar.scss +10 -10
- package/MenuBar/MenuBar.svelte +7 -7
- package/MenuBar/MenuBarItem.scss +38 -38
- package/MenuBar/MenuBarItem.svelte +38 -38
- package/MenuFlyout/MenuFlyoutDivider.scss +7 -7
- package/MenuFlyout/MenuFlyoutDivider.svelte +5 -5
- package/MenuFlyout/MenuFlyoutItem.scss +146 -146
- package/MenuFlyout/MenuFlyoutItem.svelte +136 -136
- package/MenuFlyout/MenuFlyoutSurface.scss +79 -79
- package/MenuFlyout/MenuFlyoutSurface.svelte +22 -22
- package/MenuFlyout/MenuFlyoutWrapper.scss +64 -64
- package/MenuFlyout/MenuFlyoutWrapper.svelte +37 -37
- package/NavigationView/NavigationView.svelte +29 -29
- package/NumberBox/NumberBox.scss +31 -31
- package/NumberBox/NumberBox.svelte +166 -166
- package/PersonPicture/PersonPicture.scss +35 -35
- package/PersonPicture/PersonPicture.svelte +37 -37
- package/ProgressBar/ProgressBar.scss +83 -83
- package/ProgressBar/ProgressBar.svelte +36 -36
- package/ProgressRing/ProgressRing.scss +37 -37
- package/ProgressRing/ProgressRing.svelte +37 -37
- package/README.md +19 -19
- package/RadioButton/RadioButton.scss +114 -114
- package/RadioButton/RadioButton.svelte +38 -38
- package/RangeSlider/RangeSlider.svelte +26 -26
- package/ScrollView/ScrollView.svelte +3 -3
- package/Slider/Slider.scss +281 -281
- package/Slider/Slider.svelte +121 -121
- package/TeachingTip/TeachingTipSurface.scss +14 -14
- package/TeachingTip/TeachingTipSurface.svelte +7 -7
- package/TeachingTip/TeachingTipWrapper.scss +181 -79
- package/TeachingTip/TeachingTipWrapper.svelte +196 -73
- package/TeachingTip/TeachingTipWrapper.svelte.d.ts +6 -0
- package/TextArea/TextArea.scss +115 -115
- package/TextArea/TextArea.svelte +65 -65
- package/TextBlock/TextBlock.scss +66 -66
- package/TextBlock/TextBlock.svelte +12 -12
- package/TextBox/TextBox.scss +108 -108
- package/TextBox/TextBox.svelte +121 -121
- package/TextBox/TextBox.svelte.d.ts +7 -0
- package/TextBox/TextBoxButton.scss +34 -34
- package/TextBox/TextBoxButton.svelte +13 -13
- package/ToggleSwitch/ToggleSwitch.scss +118 -118
- package/ToggleSwitch/ToggleSwitch.svelte +29 -29
- package/Tooltip/TooltipSurface.scss +16 -16
- package/Tooltip/TooltipSurface.svelte +13 -13
- package/Tooltip/TooltipWrapper.scss +66 -66
- package/Tooltip/TooltipWrapper.svelte +37 -37
- package/_mixins.scss +130 -130
- package/package.json +1 -1
- package/svelte-jsx.d.ts +14 -14
- package/switchable.css +401 -401
- package/theme.css +744 -744
package/ComboBox/ComboBox.scss
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
@use "../mixins" as *;
|
|
2
|
-
|
|
3
|
-
@keyframes menu-in {
|
|
4
|
-
0% {
|
|
5
|
-
clip-path: var(--grow-clip-path);
|
|
6
|
-
}
|
|
7
|
-
100% {
|
|
8
|
-
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@keyframes shadow-in {
|
|
13
|
-
0% {
|
|
14
|
-
box-shadow: none;
|
|
15
|
-
}
|
|
16
|
-
100% {
|
|
17
|
-
box-shadow: var(--flyout-shadow);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.combo-box {
|
|
22
|
-
position: relative;
|
|
23
|
-
display: inline-flex;
|
|
24
|
-
user-select: none;
|
|
25
|
-
|
|
26
|
-
:global {
|
|
27
|
-
.button,
|
|
28
|
-
.text-box {
|
|
29
|
-
flex: 1 1 auto;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.text-box {
|
|
33
|
-
border-color: var(--control-border-default);
|
|
34
|
-
&-underline::after {
|
|
35
|
-
border-color: transparent;
|
|
36
|
-
}
|
|
37
|
-
&-container {
|
|
38
|
-
cursor: default;
|
|
39
|
-
&:focus-visible {
|
|
40
|
-
cursor: text;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&.editable {
|
|
47
|
-
:global {
|
|
48
|
-
.combo-box-textbox:not(:focus-within) {
|
|
49
|
-
cursor: default;
|
|
50
|
-
border-color: var(--control-border-default);
|
|
51
|
-
.text-box-underline::after {
|
|
52
|
-
content: none;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
&.combo-box-textbox.disabled {
|
|
56
|
-
border-color: var(--control-stroke-default);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
&.open {
|
|
60
|
-
:global {
|
|
61
|
-
.combo-box-textbox {
|
|
62
|
-
cursor: text;
|
|
63
|
-
background-color: var(--control-fill-input-active);
|
|
64
|
-
.text-box-underline::after {
|
|
65
|
-
content: "";
|
|
66
|
-
border-bottom: 2px solid var(--fds-accent-default);
|
|
67
|
-
}
|
|
68
|
-
input::placeholder {
|
|
69
|
-
color: var(--text-tertiary);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
.text-box-underline {
|
|
73
|
-
border-end-start-radius: 0;
|
|
74
|
-
border-end-end-radius: 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
.combo-box-dropdown {
|
|
79
|
-
margin: 0;
|
|
80
|
-
inset-inline-start: 0;
|
|
81
|
-
inset-block-start: 100%;
|
|
82
|
-
inline-size: 100%;
|
|
83
|
-
border-radius: var(--overlay-corner-radius);
|
|
84
|
-
border-start-start-radius: 0;
|
|
85
|
-
border-start-end-radius: 0;
|
|
86
|
-
}
|
|
87
|
-
.combo-box-icon {
|
|
88
|
-
margin: 0;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&-label {
|
|
93
|
-
flex: 1 1 auto;
|
|
94
|
-
text-align: start;
|
|
95
|
-
min-block-size: 20px;
|
|
96
|
-
|
|
97
|
-
&.placeholder {
|
|
98
|
-
color: var(--text-secondary);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&.disabled .placeholder {
|
|
103
|
-
color: var(--text-disabled);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
&-icon {
|
|
107
|
-
margin-inline-start: 8px;
|
|
108
|
-
inline-size: 12px;
|
|
109
|
-
block-size: 12px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&-dropdown {
|
|
113
|
-
z-index: 100;
|
|
114
|
-
position: absolute;
|
|
115
|
-
box-sizing: border-box;
|
|
116
|
-
margin: 0;
|
|
117
|
-
margin-block-start: -6px;
|
|
118
|
-
margin-inline-start: -5px;
|
|
119
|
-
padding: 1px;
|
|
120
|
-
border: 1px solid var(--surface-stroke-flyout);
|
|
121
|
-
border-radius: var(--overlay-corner-radius);
|
|
122
|
-
background-color: var(--solid-background-quarternary);
|
|
123
|
-
background-clip: padding-box;
|
|
124
|
-
box-shadow: var(--flyout-shadow);
|
|
125
|
-
animation: menu-in var(--control-normal-duration) var(--control-fast-out-slow-in-easing),
|
|
126
|
-
shadow-in var(--control-normal-duration) var(--control-fast-out-slow-in-easing)
|
|
127
|
-
var(--control-normal-duration);
|
|
128
|
-
overflow: auto;
|
|
129
|
-
inline-size: calc(100% + 8px);
|
|
130
|
-
max-block-size: 504px;
|
|
131
|
-
inset-block-start: var(--menu-offset, 0);
|
|
132
|
-
inset-inline-start: 0;
|
|
133
|
-
|
|
134
|
-
@supports (overflow: overlay) {
|
|
135
|
-
overflow: overlay;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
&.direction- {
|
|
139
|
-
&top {
|
|
140
|
-
--grow-clip-path: polygon(0 0, 100% 0, 100% 25%, 0 25%);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
¢er {
|
|
144
|
-
--grow-clip-path: polygon(0 25%, 100% 24%, 100% 75%, 0 75%);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&bottom {
|
|
148
|
-
--grow-clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
1
|
+
@use "../mixins" as *;
|
|
2
|
+
|
|
3
|
+
@keyframes menu-in {
|
|
4
|
+
0% {
|
|
5
|
+
clip-path: var(--grow-clip-path);
|
|
6
|
+
}
|
|
7
|
+
100% {
|
|
8
|
+
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@keyframes shadow-in {
|
|
13
|
+
0% {
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
}
|
|
16
|
+
100% {
|
|
17
|
+
box-shadow: var(--flyout-shadow);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.combo-box {
|
|
22
|
+
position: relative;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
user-select: none;
|
|
25
|
+
|
|
26
|
+
:global {
|
|
27
|
+
.button,
|
|
28
|
+
.text-box {
|
|
29
|
+
flex: 1 1 auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.text-box {
|
|
33
|
+
border-color: var(--control-border-default);
|
|
34
|
+
&-underline::after {
|
|
35
|
+
border-color: transparent;
|
|
36
|
+
}
|
|
37
|
+
&-container {
|
|
38
|
+
cursor: default;
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
cursor: text;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.editable {
|
|
47
|
+
:global {
|
|
48
|
+
.combo-box-textbox:not(:focus-within) {
|
|
49
|
+
cursor: default;
|
|
50
|
+
border-color: var(--control-border-default);
|
|
51
|
+
.text-box-underline::after {
|
|
52
|
+
content: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
&.combo-box-textbox.disabled {
|
|
56
|
+
border-color: var(--control-stroke-default);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
&.open {
|
|
60
|
+
:global {
|
|
61
|
+
.combo-box-textbox {
|
|
62
|
+
cursor: text;
|
|
63
|
+
background-color: var(--control-fill-input-active);
|
|
64
|
+
.text-box-underline::after {
|
|
65
|
+
content: "";
|
|
66
|
+
border-bottom: 2px solid var(--fds-accent-default);
|
|
67
|
+
}
|
|
68
|
+
input::placeholder {
|
|
69
|
+
color: var(--text-tertiary);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
.text-box-underline {
|
|
73
|
+
border-end-start-radius: 0;
|
|
74
|
+
border-end-end-radius: 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.combo-box-dropdown {
|
|
79
|
+
margin: 0;
|
|
80
|
+
inset-inline-start: 0;
|
|
81
|
+
inset-block-start: 100%;
|
|
82
|
+
inline-size: 100%;
|
|
83
|
+
border-radius: var(--overlay-corner-radius);
|
|
84
|
+
border-start-start-radius: 0;
|
|
85
|
+
border-start-end-radius: 0;
|
|
86
|
+
}
|
|
87
|
+
.combo-box-icon {
|
|
88
|
+
margin: 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&-label {
|
|
93
|
+
flex: 1 1 auto;
|
|
94
|
+
text-align: start;
|
|
95
|
+
min-block-size: 20px;
|
|
96
|
+
|
|
97
|
+
&.placeholder {
|
|
98
|
+
color: var(--text-secondary);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&.disabled .placeholder {
|
|
103
|
+
color: var(--text-disabled);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&-icon {
|
|
107
|
+
margin-inline-start: 8px;
|
|
108
|
+
inline-size: 12px;
|
|
109
|
+
block-size: 12px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&-dropdown {
|
|
113
|
+
z-index: 100;
|
|
114
|
+
position: absolute;
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
margin: 0;
|
|
117
|
+
margin-block-start: -6px;
|
|
118
|
+
margin-inline-start: -5px;
|
|
119
|
+
padding: 1px;
|
|
120
|
+
border: 1px solid var(--surface-stroke-flyout);
|
|
121
|
+
border-radius: var(--overlay-corner-radius);
|
|
122
|
+
background-color: var(--solid-background-quarternary);
|
|
123
|
+
background-clip: padding-box;
|
|
124
|
+
box-shadow: var(--flyout-shadow);
|
|
125
|
+
animation: menu-in var(--control-normal-duration) var(--control-fast-out-slow-in-easing),
|
|
126
|
+
shadow-in var(--control-normal-duration) var(--control-fast-out-slow-in-easing)
|
|
127
|
+
var(--control-normal-duration);
|
|
128
|
+
overflow: auto;
|
|
129
|
+
inline-size: calc(100% + 8px);
|
|
130
|
+
max-block-size: 504px;
|
|
131
|
+
inset-block-start: var(--menu-offset, 0);
|
|
132
|
+
inset-inline-start: 0;
|
|
133
|
+
|
|
134
|
+
@supports (overflow: overlay) {
|
|
135
|
+
overflow: overlay;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&.direction- {
|
|
139
|
+
&top {
|
|
140
|
+
--grow-clip-path: polygon(0 0, 100% 0, 100% 25%, 0 25%);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
¢er {
|
|
144
|
+
--grow-clip-path: polygon(0 25%, 100% 24%, 100% 75%, 0 75%);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&bottom {
|
|
148
|
+
--grow-clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
package/ComboBox/ComboBox.svelte
CHANGED
|
@@ -168,158 +168,158 @@ function handleInput(event) {
|
|
|
168
168
|
value = match.value;
|
|
169
169
|
searchValue = searchInputElement.value;
|
|
170
170
|
}
|
|
171
|
-
</script>
|
|
172
|
-
|
|
173
|
-
<!--
|
|
174
|
-
@component
|
|
175
|
-
Use a combo box (also known as a drop-down list) to present a list of items that a user can select from. A combo box starts in a compact state and expands to show a list of selectable items.
|
|
176
|
-
|
|
177
|
-
When the combo box is closed, it either displays the current selection or is empty if there is no selected item. When the user expands the combo box, it displays the list of selectable items.
|
|
178
|
-
[Docs](https://fluent-svelte.vercel.app/docs/components/combobox)
|
|
179
|
-
|
|
180
|
-
- Usage:
|
|
181
|
-
```tsx
|
|
182
|
-
<ComboBox items={[
|
|
183
|
-
{ name: "Item 0", value: 0 },
|
|
184
|
-
{ name: "Item 1", value: 1 },
|
|
185
|
-
{ name: "Item 2", value: 2 },
|
|
186
|
-
]} />
|
|
187
|
-
```
|
|
188
|
-
-->
|
|
189
|
-
<div
|
|
190
|
-
use:forwardEvents
|
|
191
|
-
use:externalMouseEvents={{ type: "mousedown" }}
|
|
192
|
-
class="combo-box {className}"
|
|
193
|
-
class:disabled
|
|
194
|
-
class:editable
|
|
195
|
-
class:open
|
|
196
|
-
on:outermousedown={() => {
|
|
197
|
-
if (open) open = false;
|
|
198
|
-
}}
|
|
199
|
-
bind:this={containerElement}
|
|
200
|
-
{...$$restProps}
|
|
201
|
-
>
|
|
202
|
-
{#if editable}
|
|
203
|
-
<TextBox
|
|
204
|
-
clearButton={false}
|
|
205
|
-
class="combo-box-text-box"
|
|
206
|
-
role="combobox"
|
|
207
|
-
aria-activedescendant={inputFocused}
|
|
208
|
-
aria-autocomplete="both"
|
|
209
|
-
aria-controls={dropdownId}
|
|
210
|
-
aria-expanded={open}
|
|
211
|
-
aria-haspopup={open ? "listbox" : undefined}
|
|
212
|
-
bind:value={searchValue}
|
|
213
|
-
bind:inputElement={searchInputElement}
|
|
214
|
-
on:keydown={handleKeyboardNavigation}
|
|
215
|
-
on:input={handleInput}
|
|
216
|
-
on:focus={handleInputFocus}
|
|
217
|
-
on:blur={handleInputBlur}
|
|
218
|
-
on:change
|
|
219
|
-
on:input
|
|
220
|
-
on:beforeinput
|
|
221
|
-
on:keydown
|
|
222
|
-
{placeholder}
|
|
223
|
-
{disabled}
|
|
224
|
-
>
|
|
225
|
-
<TextBoxButton
|
|
226
|
-
aria-expanded={open}
|
|
227
|
-
aria-label="Open dropdown"
|
|
228
|
-
aria-controls={dropdownId}
|
|
229
|
-
class="combo-box-dropdown-button"
|
|
230
|
-
on:click={openMenu}
|
|
231
|
-
bind:element={buttonElement}
|
|
232
|
-
slot="buttons"
|
|
233
|
-
>
|
|
234
|
-
<svg
|
|
235
|
-
aria-hidden="true"
|
|
236
|
-
class="combo-box-icon"
|
|
237
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
238
|
-
width="48"
|
|
239
|
-
height="48"
|
|
240
|
-
viewBox="0 0 48 48"
|
|
241
|
-
>
|
|
242
|
-
<path
|
|
243
|
-
fill="currentColor"
|
|
244
|
-
d="M8.36612 16.1161C7.87796 16.6043 7.87796 17.3957 8.36612 17.8839L23.1161 32.6339C23.6043 33.122 24.3957 33.122 24.8839 32.6339L39.6339 17.8839C40.122 17.3957 40.122 16.6043 39.6339 16.1161C39.1457 15.628 38.3543 15.628 37.8661 16.1161L24 29.9822L10.1339 16.1161C9.64573 15.628 8.85427 15.628 8.36612 16.1161Z"
|
|
245
|
-
/>
|
|
246
|
-
</svg>
|
|
247
|
-
</TextBoxButton>
|
|
248
|
-
</TextBox>
|
|
249
|
-
{:else}
|
|
250
|
-
<Button
|
|
251
|
-
type="button"
|
|
252
|
-
class="combo-box-button"
|
|
253
|
-
id={buttonId}
|
|
254
|
-
aria-labelledby={buttonId}
|
|
255
|
-
aria-haspopup={open ? "listbox" : undefined}
|
|
256
|
-
aria-controls={dropdownId}
|
|
257
|
-
on:keydown={handleKeyboardNavigation}
|
|
258
|
-
on:keydown
|
|
259
|
-
on:click={openMenu}
|
|
260
|
-
bind:element={buttonElement}
|
|
261
|
-
{disabled}
|
|
262
|
-
>
|
|
263
|
-
<span class="combo-box-label" class:placeholder={!selection}>
|
|
264
|
-
{selection?.name || placeholder}
|
|
265
|
-
</span>
|
|
266
|
-
<svg
|
|
267
|
-
aria-hidden="true"
|
|
268
|
-
class="combo-box-icon"
|
|
269
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
270
|
-
width="48"
|
|
271
|
-
height="48"
|
|
272
|
-
viewBox="0 0 48 48"
|
|
273
|
-
>
|
|
274
|
-
<path
|
|
275
|
-
fill="currentColor"
|
|
276
|
-
d="M8.36612 16.1161C7.87796 16.6043 7.87796 17.3957 8.36612 17.8839L23.1161 32.6339C23.6043 33.122 24.3957 33.122 24.8839 32.6339L39.6339 17.8839C40.122 17.3957 40.122 16.6043 39.6339 16.1161C39.1457 15.628 38.3543 15.628 37.8661 16.1161L24 29.9822L10.1339 16.1161C9.64573 15.628 8.85427 15.628 8.36612 16.1161Z"
|
|
277
|
-
/>
|
|
278
|
-
</svg>
|
|
279
|
-
</Button>
|
|
280
|
-
{/if}
|
|
281
|
-
{#if !disabled && items.length > 0}
|
|
282
|
-
{#if open}
|
|
283
|
-
<ul
|
|
284
|
-
bind:this={menuElement}
|
|
285
|
-
on:blur={() => (open = false)}
|
|
286
|
-
id={dropdownId}
|
|
287
|
-
aria-labelledby={buttonId}
|
|
288
|
-
aria-activedescendant={editable
|
|
289
|
-
? undefined
|
|
290
|
-
: `${dropdownId}-item-${items.indexOf(selection)}`}
|
|
291
|
-
role="listbox"
|
|
292
|
-
class="combo-box-dropdown direction-{!editable
|
|
293
|
-
? menuGrowDirection ?? 'center'
|
|
294
|
-
: 'top'}"
|
|
295
|
-
style="--fds-menu-offset: {menuOffset}px;"
|
|
296
|
-
>
|
|
297
|
-
{#each items as item, i}
|
|
298
|
-
<ComboBoxItem
|
|
299
|
-
role="option"
|
|
300
|
-
selected={item.value === value}
|
|
301
|
-
disabled={item.disabled}
|
|
302
|
-
id="{dropdownId}-item-{i}"
|
|
303
|
-
on:keydown={handleKeyboardNavigation}
|
|
304
|
-
on:click={() => selectItem(item)}
|
|
305
|
-
>
|
|
306
|
-
{item.name}
|
|
307
|
-
</ComboBoxItem>
|
|
308
|
-
{/each}
|
|
309
|
-
</ul>
|
|
310
|
-
{/if}
|
|
311
|
-
|
|
312
|
-
<input
|
|
313
|
-
type="hidden"
|
|
314
|
-
aria-hidden="true"
|
|
315
|
-
bind:this={inputElement}
|
|
316
|
-
bind:value
|
|
317
|
-
on:change
|
|
318
|
-
on:input
|
|
319
|
-
on:beforeinput
|
|
320
|
-
/>
|
|
321
|
-
<slot />
|
|
322
|
-
{/if}
|
|
323
|
-
</div>
|
|
324
|
-
|
|
325
|
-
<style >@-webkit-keyframes menu-in{0%{-webkit-clip-path:var(--fds-grow-clip-path);clip-path:var(--fds-grow-clip-path)}to{-webkit-clip-path:polygon(0 0,100% 0,100% 100%,0 100%);clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}}@keyframes menu-in{0%{-webkit-clip-path:var(--fds-grow-clip-path);clip-path:var(--fds-grow-clip-path)}to{-webkit-clip-path:polygon(0 0,100% 0,100% 100%,0 100%);clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}}@-webkit-keyframes shadow-in{0%{box-shadow:none}to{box-shadow:var(--fds-flyout-shadow)}}@keyframes shadow-in{0%{box-shadow:none}to{box-shadow:var(--fds-flyout-shadow)}}.combo-box{display:inline-flex;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.combo-box :global(.button),.combo-box :global(.text-box){flex:1 1 auto}.combo-box :global(.text-box){border-color:var(--fds-control-border-default)}.combo-box :global(.text-box-underline:after){border-color:transparent}.combo-box :global(.text-box-container){cursor:default}.combo-box :global(.text-box-container:focus-visible){cursor:text}.combo-box.editable :global(.combo-box-textbox:not(:focus-within)){border-color:var(--fds-control-border-default);cursor:default}.combo-box.editable :global(.combo-box-textbox:not(:focus-within)) :global(.text-box-underline:after){content:none}.combo-box.editable :global(.combo-box-textbox.disabled){border-color:var(--fds-control-stroke-default)}.combo-box.editable.open :global(.combo-box-textbox){background-color:var(--fds-control-fill-input-active);cursor:text}.combo-box.editable.open :global(.combo-box-textbox) :global(.text-box-underline:after){border-bottom:2px solid var(--fds-accent-default);content:""}.combo-box.editable.open :global(.combo-box-textbox) :global(input::-moz-placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.combo-box-textbox) :global(input:-ms-input-placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.combo-box-textbox) :global(input::placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.text-box-underline){border-end-end-radius:0;border-end-start-radius:0}.combo-box.editable .combo-box-dropdown{border-radius:var(--fds-overlay-corner-radius);border-start-end-radius:0;border-start-start-radius:0;inline-size:100%;inset-block-start:100%;inset-inline-start:0;margin:0}.combo-box.editable .combo-box-icon{margin:0}.combo-box-label{flex:1 1 auto;min-block-size:20px;text-align:start}.combo-box-label.placeholder{color:var(--fds-text-secondary)}.combo-box.disabled .placeholder{color:var(--fds-text-disabled)}.combo-box-icon{-webkit-margin-start:8px;block-size:12px;inline-size:12px;margin-inline-start:8px}.combo-box-dropdown{-webkit-margin-before:-6px;-webkit-margin-start:-5px;-webkit-animation:menu-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing),shadow-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing) var(--fds-control-normal-duration);animation:menu-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing),shadow-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing) var(--fds-control-normal-duration);background-clip:padding-box;background-color:var(--fds-solid-background-quarternary);border:1px solid var(--fds-surface-stroke-flyout);border-radius:var(--fds-overlay-corner-radius);box-shadow:var(--fds-flyout-shadow);box-sizing:border-box;inline-size:calc(100% + 8px);inset-block-start:var(--fds-menu-offset,0);inset-inline-start:0;margin:0;margin-block-start:-6px;margin-inline-start:-5px;max-block-size:504px;overflow:auto;padding:1px;position:absolute;z-index:100}@supports (overflow:overlay){.combo-box-dropdown{overflow:overlay}}.combo-box-dropdown.direction-top{--fds-grow-clip-path:polygon(0 0,100% 0,100% 25%,0 25%)}.combo-box-dropdown.direction-center{--fds-grow-clip-path:polygon(0 25%,100% 24%,100% 75%,0 75%)}.combo-box-dropdown.direction-bottom{--fds-grow-clip-path:polygon(0 75%,100% 75%,100% 100%,0 100%)}</style>
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<!--
|
|
174
|
+
@component
|
|
175
|
+
Use a combo box (also known as a drop-down list) to present a list of items that a user can select from. A combo box starts in a compact state and expands to show a list of selectable items.
|
|
176
|
+
|
|
177
|
+
When the combo box is closed, it either displays the current selection or is empty if there is no selected item. When the user expands the combo box, it displays the list of selectable items.
|
|
178
|
+
[Docs](https://fluent-svelte.vercel.app/docs/components/combobox)
|
|
179
|
+
|
|
180
|
+
- Usage:
|
|
181
|
+
```tsx
|
|
182
|
+
<ComboBox items={[
|
|
183
|
+
{ name: "Item 0", value: 0 },
|
|
184
|
+
{ name: "Item 1", value: 1 },
|
|
185
|
+
{ name: "Item 2", value: 2 },
|
|
186
|
+
]} />
|
|
187
|
+
```
|
|
188
|
+
-->
|
|
189
|
+
<div
|
|
190
|
+
use:forwardEvents
|
|
191
|
+
use:externalMouseEvents={{ type: "mousedown" }}
|
|
192
|
+
class="combo-box {className}"
|
|
193
|
+
class:disabled
|
|
194
|
+
class:editable
|
|
195
|
+
class:open
|
|
196
|
+
on:outermousedown={() => {
|
|
197
|
+
if (open) open = false;
|
|
198
|
+
}}
|
|
199
|
+
bind:this={containerElement}
|
|
200
|
+
{...$$restProps}
|
|
201
|
+
>
|
|
202
|
+
{#if editable}
|
|
203
|
+
<TextBox
|
|
204
|
+
clearButton={false}
|
|
205
|
+
class="combo-box-text-box"
|
|
206
|
+
role="combobox"
|
|
207
|
+
aria-activedescendant={inputFocused}
|
|
208
|
+
aria-autocomplete="both"
|
|
209
|
+
aria-controls={dropdownId}
|
|
210
|
+
aria-expanded={open}
|
|
211
|
+
aria-haspopup={open ? "listbox" : undefined}
|
|
212
|
+
bind:value={searchValue}
|
|
213
|
+
bind:inputElement={searchInputElement}
|
|
214
|
+
on:keydown={handleKeyboardNavigation}
|
|
215
|
+
on:input={handleInput}
|
|
216
|
+
on:focus={handleInputFocus}
|
|
217
|
+
on:blur={handleInputBlur}
|
|
218
|
+
on:change
|
|
219
|
+
on:input
|
|
220
|
+
on:beforeinput
|
|
221
|
+
on:keydown
|
|
222
|
+
{placeholder}
|
|
223
|
+
{disabled}
|
|
224
|
+
>
|
|
225
|
+
<TextBoxButton
|
|
226
|
+
aria-expanded={open}
|
|
227
|
+
aria-label="Open dropdown"
|
|
228
|
+
aria-controls={dropdownId}
|
|
229
|
+
class="combo-box-dropdown-button"
|
|
230
|
+
on:click={openMenu}
|
|
231
|
+
bind:element={buttonElement}
|
|
232
|
+
slot="buttons"
|
|
233
|
+
>
|
|
234
|
+
<svg
|
|
235
|
+
aria-hidden="true"
|
|
236
|
+
class="combo-box-icon"
|
|
237
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
238
|
+
width="48"
|
|
239
|
+
height="48"
|
|
240
|
+
viewBox="0 0 48 48"
|
|
241
|
+
>
|
|
242
|
+
<path
|
|
243
|
+
fill="currentColor"
|
|
244
|
+
d="M8.36612 16.1161C7.87796 16.6043 7.87796 17.3957 8.36612 17.8839L23.1161 32.6339C23.6043 33.122 24.3957 33.122 24.8839 32.6339L39.6339 17.8839C40.122 17.3957 40.122 16.6043 39.6339 16.1161C39.1457 15.628 38.3543 15.628 37.8661 16.1161L24 29.9822L10.1339 16.1161C9.64573 15.628 8.85427 15.628 8.36612 16.1161Z"
|
|
245
|
+
/>
|
|
246
|
+
</svg>
|
|
247
|
+
</TextBoxButton>
|
|
248
|
+
</TextBox>
|
|
249
|
+
{:else}
|
|
250
|
+
<Button
|
|
251
|
+
type="button"
|
|
252
|
+
class="combo-box-button"
|
|
253
|
+
id={buttonId}
|
|
254
|
+
aria-labelledby={buttonId}
|
|
255
|
+
aria-haspopup={open ? "listbox" : undefined}
|
|
256
|
+
aria-controls={dropdownId}
|
|
257
|
+
on:keydown={handleKeyboardNavigation}
|
|
258
|
+
on:keydown
|
|
259
|
+
on:click={openMenu}
|
|
260
|
+
bind:element={buttonElement}
|
|
261
|
+
{disabled}
|
|
262
|
+
>
|
|
263
|
+
<span class="combo-box-label" class:placeholder={!selection}>
|
|
264
|
+
{selection?.name || placeholder}
|
|
265
|
+
</span>
|
|
266
|
+
<svg
|
|
267
|
+
aria-hidden="true"
|
|
268
|
+
class="combo-box-icon"
|
|
269
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
270
|
+
width="48"
|
|
271
|
+
height="48"
|
|
272
|
+
viewBox="0 0 48 48"
|
|
273
|
+
>
|
|
274
|
+
<path
|
|
275
|
+
fill="currentColor"
|
|
276
|
+
d="M8.36612 16.1161C7.87796 16.6043 7.87796 17.3957 8.36612 17.8839L23.1161 32.6339C23.6043 33.122 24.3957 33.122 24.8839 32.6339L39.6339 17.8839C40.122 17.3957 40.122 16.6043 39.6339 16.1161C39.1457 15.628 38.3543 15.628 37.8661 16.1161L24 29.9822L10.1339 16.1161C9.64573 15.628 8.85427 15.628 8.36612 16.1161Z"
|
|
277
|
+
/>
|
|
278
|
+
</svg>
|
|
279
|
+
</Button>
|
|
280
|
+
{/if}
|
|
281
|
+
{#if !disabled && items.length > 0}
|
|
282
|
+
{#if open}
|
|
283
|
+
<ul
|
|
284
|
+
bind:this={menuElement}
|
|
285
|
+
on:blur={() => (open = false)}
|
|
286
|
+
id={dropdownId}
|
|
287
|
+
aria-labelledby={buttonId}
|
|
288
|
+
aria-activedescendant={editable
|
|
289
|
+
? undefined
|
|
290
|
+
: `${dropdownId}-item-${items.indexOf(selection)}`}
|
|
291
|
+
role="listbox"
|
|
292
|
+
class="combo-box-dropdown direction-{!editable
|
|
293
|
+
? menuGrowDirection ?? 'center'
|
|
294
|
+
: 'top'}"
|
|
295
|
+
style="--fds-menu-offset: {menuOffset}px;"
|
|
296
|
+
>
|
|
297
|
+
{#each items as item, i}
|
|
298
|
+
<ComboBoxItem
|
|
299
|
+
role="option"
|
|
300
|
+
selected={item.value === value}
|
|
301
|
+
disabled={item.disabled}
|
|
302
|
+
id="{dropdownId}-item-{i}"
|
|
303
|
+
on:keydown={handleKeyboardNavigation}
|
|
304
|
+
on:click={() => selectItem(item)}
|
|
305
|
+
>
|
|
306
|
+
{item.name}
|
|
307
|
+
</ComboBoxItem>
|
|
308
|
+
{/each}
|
|
309
|
+
</ul>
|
|
310
|
+
{/if}
|
|
311
|
+
|
|
312
|
+
<input
|
|
313
|
+
type="hidden"
|
|
314
|
+
aria-hidden="true"
|
|
315
|
+
bind:this={inputElement}
|
|
316
|
+
bind:value
|
|
317
|
+
on:change
|
|
318
|
+
on:input
|
|
319
|
+
on:beforeinput
|
|
320
|
+
/>
|
|
321
|
+
<slot />
|
|
322
|
+
{/if}
|
|
323
|
+
</div>
|
|
324
|
+
|
|
325
|
+
<style >@-webkit-keyframes menu-in{0%{-webkit-clip-path:var(--fds-grow-clip-path);clip-path:var(--fds-grow-clip-path)}to{-webkit-clip-path:polygon(0 0,100% 0,100% 100%,0 100%);clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}}@keyframes menu-in{0%{-webkit-clip-path:var(--fds-grow-clip-path);clip-path:var(--fds-grow-clip-path)}to{-webkit-clip-path:polygon(0 0,100% 0,100% 100%,0 100%);clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}}@-webkit-keyframes shadow-in{0%{box-shadow:none}to{box-shadow:var(--fds-flyout-shadow)}}@keyframes shadow-in{0%{box-shadow:none}to{box-shadow:var(--fds-flyout-shadow)}}.combo-box{display:inline-flex;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.combo-box :global(.button),.combo-box :global(.text-box){flex:1 1 auto}.combo-box :global(.text-box){border-color:var(--fds-control-border-default)}.combo-box :global(.text-box-underline:after){border-color:transparent}.combo-box :global(.text-box-container){cursor:default}.combo-box :global(.text-box-container:focus-visible){cursor:text}.combo-box.editable :global(.combo-box-textbox:not(:focus-within)){border-color:var(--fds-control-border-default);cursor:default}.combo-box.editable :global(.combo-box-textbox:not(:focus-within)) :global(.text-box-underline:after){content:none}.combo-box.editable :global(.combo-box-textbox.disabled){border-color:var(--fds-control-stroke-default)}.combo-box.editable.open :global(.combo-box-textbox){background-color:var(--fds-control-fill-input-active);cursor:text}.combo-box.editable.open :global(.combo-box-textbox) :global(.text-box-underline:after){border-bottom:2px solid var(--fds-accent-default);content:""}.combo-box.editable.open :global(.combo-box-textbox) :global(input::-moz-placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.combo-box-textbox) :global(input:-ms-input-placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.combo-box-textbox) :global(input::placeholder){color:var(--fds-text-tertiary)}.combo-box.editable.open :global(.text-box-underline){border-end-end-radius:0;border-end-start-radius:0}.combo-box.editable .combo-box-dropdown{border-radius:var(--fds-overlay-corner-radius);border-start-end-radius:0;border-start-start-radius:0;inline-size:100%;inset-block-start:100%;inset-inline-start:0;margin:0}.combo-box.editable .combo-box-icon{margin:0}.combo-box-label{flex:1 1 auto;min-block-size:20px;text-align:start}.combo-box-label.placeholder{color:var(--fds-text-secondary)}.combo-box.disabled .placeholder{color:var(--fds-text-disabled)}.combo-box-icon{-webkit-margin-start:8px;block-size:12px;inline-size:12px;margin-inline-start:8px}.combo-box-dropdown{-webkit-margin-before:-6px;-webkit-margin-start:-5px;-webkit-animation:menu-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing),shadow-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing) var(--fds-control-normal-duration);animation:menu-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing),shadow-in var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing) var(--fds-control-normal-duration);background-clip:padding-box;background-color:var(--fds-solid-background-quarternary);border:1px solid var(--fds-surface-stroke-flyout);border-radius:var(--fds-overlay-corner-radius);box-shadow:var(--fds-flyout-shadow);box-sizing:border-box;inline-size:calc(100% + 8px);inset-block-start:var(--fds-menu-offset,0);inset-inline-start:0;margin:0;margin-block-start:-6px;margin-inline-start:-5px;max-block-size:504px;overflow:auto;padding:1px;position:absolute;z-index:100}@supports (overflow:overlay){.combo-box-dropdown{overflow:overlay}}.combo-box-dropdown.direction-top{--fds-grow-clip-path:polygon(0 0,100% 0,100% 25%,0 25%)}.combo-box-dropdown.direction-center{--fds-grow-clip-path:polygon(0 25%,100% 24%,100% 75%,0 75%)}.combo-box-dropdown.direction-bottom{--fds-grow-clip-path:polygon(0 75%,100% 75%,100% 100%,0 100%)}</style>
|