fluent-svelte-extra 1.0.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/.prettierignore +1 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/package.json +83 -0
- package/src/app.html +12 -0
- package/src/global.d.ts +1 -0
- package/src/lib/AutoSuggestBox/AutoSuggestBox.scss +44 -0
- package/src/lib/AutoSuggestBox/AutoSuggestBox.svelte +173 -0
- package/src/lib/Button/Button.scss +94 -0
- package/src/lib/Button/Button.svelte +48 -0
- package/src/lib/CalendarDatePicker/CalendarDatePicker.scss +15 -0
- package/src/lib/CalendarDatePicker/CalendarDatePicker.svelte +86 -0
- package/src/lib/CalendarView/CalendarView.scss +156 -0
- package/src/lib/CalendarView/CalendarView.svelte +753 -0
- package/src/lib/CalendarView/CalendarViewItem.scss +130 -0
- package/src/lib/CalendarView/CalendarViewItem.svelte +33 -0
- package/src/lib/Checkbox/Checkbox.scss +117 -0
- package/src/lib/Checkbox/Checkbox.svelte +81 -0
- package/src/lib/ComboBox/ComboBox.scss +152 -0
- package/src/lib/ComboBox/ComboBox.svelte +360 -0
- package/src/lib/ComboBox/ComboBoxItem.scss +80 -0
- package/src/lib/ComboBox/ComboBoxItem.svelte +30 -0
- package/src/lib/ContentDialog/ContentDialog.scss +68 -0
- package/src/lib/ContentDialog/ContentDialog.svelte +123 -0
- package/src/lib/ContextMenu/ContextMenu.scss +11 -0
- package/src/lib/ContextMenu/ContextMenu.svelte +104 -0
- package/src/lib/Expander/Expander.scss +134 -0
- package/src/lib/Expander/Expander.svelte +123 -0
- package/src/lib/Flipper/Flipper.svelte +49 -0
- package/src/lib/Flyout/FlyoutSurface.scss +14 -0
- package/src/lib/Flyout/FlyoutSurface.svelte +21 -0
- package/src/lib/Flyout/FlyoutWrapper.scss +81 -0
- package/src/lib/Flyout/FlyoutWrapper.svelte +126 -0
- package/src/lib/IconButton/IconButton.scss +31 -0
- package/src/lib/IconButton/IconButton.svelte +49 -0
- package/src/lib/InfoBadge/InfoBadge.scss +39 -0
- package/src/lib/InfoBadge/InfoBadge.svelte +81 -0
- package/src/lib/InfoBar/InfoBar.scss +122 -0
- package/src/lib/InfoBar/InfoBar.svelte +133 -0
- package/src/lib/ListItem/ListItem.scss +74 -0
- package/src/lib/ListItem/ListItem.svelte +88 -0
- package/src/lib/MenuBar/MenuBar.scss +10 -0
- package/src/lib/MenuBar/MenuBar.svelte +49 -0
- package/src/lib/MenuBar/MenuBarItem.scss +38 -0
- package/src/lib/MenuBar/MenuBarItem.svelte +135 -0
- package/src/lib/MenuBar/flyoutState.ts +5 -0
- package/src/lib/MenuFlyout/MenuFlyoutDivider.scss +7 -0
- package/src/lib/MenuFlyout/MenuFlyoutDivider.svelte +14 -0
- package/src/lib/MenuFlyout/MenuFlyoutItem.scss +147 -0
- package/src/lib/MenuFlyout/MenuFlyoutItem.svelte +239 -0
- package/src/lib/MenuFlyout/MenuFlyoutSurface.scss +42 -0
- package/src/lib/MenuFlyout/MenuFlyoutSurface.svelte +28 -0
- package/src/lib/MenuFlyout/MenuFlyoutWrapper.scss +64 -0
- package/src/lib/MenuFlyout/MenuFlyoutWrapper.svelte +114 -0
- package/src/lib/NavigationView/NavigationView.scss +0 -0
- package/src/lib/NavigationView/NavigationView.svelte +82 -0
- package/src/lib/NumberBox/NumberBox.scss +31 -0
- package/src/lib/NumberBox/NumberBox.svelte +267 -0
- package/src/lib/PersonPicture/PersonPicture.scss +35 -0
- package/src/lib/PersonPicture/PersonPicture.svelte +62 -0
- package/src/lib/ProgressBar/ProgressBar.scss +83 -0
- package/src/lib/ProgressBar/ProgressBar.svelte +60 -0
- package/src/lib/ProgressRing/ProgressRing.scss +37 -0
- package/src/lib/ProgressRing/ProgressRing.svelte +73 -0
- package/src/lib/RadioButton/RadioButton.scss +114 -0
- package/src/lib/RadioButton/RadioButton.svelte +67 -0
- package/src/lib/RangeSlider/RangeSlider.svelte +91 -0
- package/src/lib/ScrollView/ScrollView.svelte +9 -0
- package/src/lib/Slider/Slider.scss +263 -0
- package/src/lib/Slider/Slider.svelte +261 -0
- package/src/lib/TextBlock/TextBlock.scss +62 -0
- package/src/lib/TextBlock/TextBlock.svelte +70 -0
- package/src/lib/TextBox/TextBox.scss +108 -0
- package/src/lib/TextBox/TextBox.svelte +225 -0
- package/src/lib/TextBox/TextBoxButton.scss +34 -0
- package/src/lib/TextBox/TextBoxButton.svelte +27 -0
- package/src/lib/ToggleSwitch/ToggleSwitch.scss +118 -0
- package/src/lib/ToggleSwitch/ToggleSwitch.svelte +55 -0
- package/src/lib/Tooltip/TooltipSurface.scss +16 -0
- package/src/lib/Tooltip/TooltipSurface.svelte +27 -0
- package/src/lib/Tooltip/TooltipWrapper.scss +66 -0
- package/src/lib/Tooltip/TooltipWrapper.svelte +117 -0
- package/src/lib/_mixins.scss +130 -0
- package/src/lib/index.ts +33 -0
- package/src/lib/internal.ts +213 -0
- package/src/lib/svelte-jsx.d.ts +14 -0
- package/src/lib/theme.css +414 -0
- package/src/routes/__layout.svelte +48 -0
- package/src/routes/docs/__layout.svelte +122 -0
- package/src/routes/docs/components/button.md +43 -0
- package/src/routes/docs/components/calendarview.md +188 -0
- package/src/routes/docs/components/checkbox.md +87 -0
- package/src/routes/docs/components/contentdialog.md +155 -0
- package/src/routes/docs/components/expander.md +115 -0
- package/src/routes/docs/components/flyout.md +107 -0
- package/src/routes/docs/components/iconbutton.md +39 -0
- package/src/routes/docs/components/infobadge.md +54 -0
- package/src/routes/docs/components/infobar.md +102 -0
- package/src/routes/docs/components/listitem.md +87 -0
- package/src/routes/docs/components/personpicture.md +125 -0
- package/src/routes/docs/components/progressring.md +83 -0
- package/src/routes/docs/components/radiobutton.md +88 -0
- package/src/routes/docs/components/slider.md +165 -0
- package/src/routes/docs/components/textblock.md +46 -0
- package/src/routes/docs/components/textbox.md +124 -0
- package/src/routes/docs/components/toggleswitch.md +73 -0
- package/src/routes/docs/getting-started.md +116 -0
- package/src/routes/docs/index.md +37 -0
- package/src/routes/docs/internals/index.md +0 -0
- package/src/routes/index.svelte +121 -0
- package/src/routes/test/__layout-test.svelte +1 -0
- package/src/routes/test/index.svelte +757 -0
- package/src/routes/test/nav.svelte +7 -0
- package/src/site/data/docs.ts +176 -0
- package/src/site/data/home.ts +12 -0
- package/src/site/lib/APIDocs/APIDocs.svelte +178 -0
- package/src/site/lib/APIDocs/ParsedComponent.d.ts +85 -0
- package/src/site/lib/CopyBox/CopyBox.svelte +23 -0
- package/src/site/lib/Example/Example.scss +33 -0
- package/src/site/lib/Example/Example.svelte +18 -0
- package/src/site/lib/HeroCard/HeroCard.scss +24 -0
- package/src/site/lib/HeroCard/HeroCard.svelte +36 -0
- package/src/site/lib/Metadata/Metadata.svelte +14 -0
- package/src/site/lib/Navbar/Navbar.scss +92 -0
- package/src/site/lib/Navbar/Navbar.svelte +47 -0
- package/src/site/lib/PageSection/PageSection.scss +57 -0
- package/src/site/lib/PageSection/PageSection.svelte +10 -0
- package/src/site/lib/Showcase/Showcase.scss +53 -0
- package/src/site/lib/Showcase/Showcase.svelte +67 -0
- package/src/site/lib/Toc/Toc.scss +18 -0
- package/src/site/lib/Toc/Toc.svelte +59 -0
- package/src/site/lib/TreeView/TreeView.svelte +89 -0
- package/src/site/lib/index.ts +9 -0
- package/src/site/styles/_markdown.scss +260 -0
- package/src/site/styles/_mixins.scss +319 -0
- package/src/site/styles/global.scss +40 -0
- package/src/site/styles/pages/docs.scss +74 -0
- package/src/site/styles/pages/home.scss +134 -0
- package/static/bloom-mica-dark.png +0 -0
- package/static/bloom-mica-light.png +0 -0
- package/static/logo.svg +11 -0
- package/svelte.config.js +57 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CalendarView, ComboBox, InfoBar } from "$lib";
|
|
3
|
+
import { CalendarViewItem } from "$lib/internal";
|
|
4
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
5
|
+
|
|
6
|
+
import data from "$lib/CalendarView/CalendarView.svelte?sveld&raw";
|
|
7
|
+
|
|
8
|
+
let viewExample = "days";
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
A calendar view lets a user view and interact with a calendar that they can navigate by month, year, or decade. A user can select a single date or multiple dates.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { CalendarView } from "fluent-svelte";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
<Showcase style="block-size: 480px">
|
|
18
|
+
<CalendarView on:keydown={e => e.stopPropagation()} on:dblclick={e => e.stopPropagation()} on:mousedown={e => e.stopPropagation()} />
|
|
19
|
+
</Showcase>
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Controlling Value
|
|
24
|
+
|
|
25
|
+
Selections made in the calendar can be controlled using the `value` property, which outputs a `Date` object or array of `Date` objects. When the user clicks an item in the calendar, the `value` property is updated to reflect the selection. `value` can also be `null` or `undefined` to indicate no selection or a selection cleared by the user.
|
|
26
|
+
|
|
27
|
+
This CalendarView will be initialized with a value of March 3, 2020.
|
|
28
|
+
|
|
29
|
+
```svelte hideScript
|
|
30
|
+
<CalendarView value={new Date(2020, 2, 3)} />
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also use two-way binding to programatically work with the value of the calendar.
|
|
34
|
+
|
|
35
|
+
```svelte example
|
|
36
|
+
<script>
|
|
37
|
+
import { Button, CalendarView } from "fluent-svelte";
|
|
38
|
+
|
|
39
|
+
let value = new Date(); // The current date
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<CalendarView bind:value />
|
|
43
|
+
|
|
44
|
+
Current value: {value?.toLocaleDateString()}
|
|
45
|
+
|
|
46
|
+
<Button on:click={() => (value = null)}>Clear Value</Button>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Multiple Selections
|
|
50
|
+
|
|
51
|
+
CalendarView can also accept more than one value. To initially select multiple dates, pass an array of `Date` objects to the `value` property rather than a single `Date`.
|
|
52
|
+
|
|
53
|
+
```svelte
|
|
54
|
+
<CalendarView value={[new Date(2022, 2, 3), new Date(2022, 2, 4)]} />
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This will render the calendar with March 3 and 4 selected, but as soon as the user attempts to choose another date, the previous selections will be cleared and `value` will be set back to a single date that the user chooses.
|
|
58
|
+
|
|
59
|
+
To allow the user to pick multiple dates at once, set the `multiple` property to `true`.
|
|
60
|
+
|
|
61
|
+
```svelte example hideScript
|
|
62
|
+
<script>
|
|
63
|
+
import { CalendarView } from "fluent-svelte";
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<CalendarView multiple value={[new Date(2022, 2, 3), new Date(2022, 2, 4)]} />
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<InfoBar title="Multiple selections will always be arrays." severity="caution">
|
|
70
|
+
In multiple mode, the <code>value</code> property will always be an array of <code>Date</code>s. If you pass a single date into <code>value</code> initially in multiple mode, it will be converted to an array containing that date once a second selection is made.
|
|
71
|
+
</InfoBar>
|
|
72
|
+
|
|
73
|
+
### Minimum and Maximum Values
|
|
74
|
+
|
|
75
|
+
You can limit the range of dates that can be selected by the user using the `min` and `max` properties. These properties are both `Date` objects representing the earliest and latest dates that can be selected. If the user attempts to click a date outside of the range, the calendar will not allow the selection.
|
|
76
|
+
|
|
77
|
+
In this example, the user will only be able to select dates in the year of 2020.
|
|
78
|
+
|
|
79
|
+
```svelte example hideScript
|
|
80
|
+
<script>
|
|
81
|
+
import { CalendarView } from "fluent-svelte";
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<CalendarView min={new Date(2020, 0, 1)} max={new Date(2020, 11, 31)} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Localization
|
|
88
|
+
|
|
89
|
+
Many elements of a calendar need to vary across languages. By default, the calendar automatically localizes itself based on the browser's `navigator.language` using the [`Intl.DateTimeFormat` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat).
|
|
90
|
+
|
|
91
|
+
If you only want the calendar to render in a specific locale, you can pass in a locale string to the `locale` property.
|
|
92
|
+
|
|
93
|
+
```svelte example hideScript
|
|
94
|
+
<script>
|
|
95
|
+
import { CalendarView } from "fluent-svelte";
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<CalendarView locale="ja-JP" />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Many places additionally have different starting days of the week. The JavaScript `Date` object starts it's weeks on Sunday, but you can customize the starting day of the calendar's week using the `weekStart` property. `weekStart` accepts a number between 0 and 6 (zero is sunday, six is saturday).
|
|
102
|
+
|
|
103
|
+
```svelte example hideScript
|
|
104
|
+
<script>
|
|
105
|
+
import { CalendarView } from "fluent-svelte";
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<!-- Week will start on Monday (1) instead of Sunday (0). -->
|
|
109
|
+
<CalendarView weekStart={1} />
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### "Blackout" Dates
|
|
113
|
+
|
|
114
|
+
In some cases, it might be desirable to prevent the user from selecting a specific day (or days) in the calendar. This can be done by passing in an array of dates to the `blackout` property.
|
|
115
|
+
|
|
116
|
+
<InfoBar severity="information" title="This property only affects user interaction.">
|
|
117
|
+
Dates excluded using the <code>blackout</code> property do not affect <i>you</i>, the developer from manually setting values to those dates. This propertly only prevents the user from conventionally picking excluded dates themselves.
|
|
118
|
+
</InfoBar>
|
|
119
|
+
|
|
120
|
+
In this example, the user will be able to select all dates _except_ for March 7, 2022 and March 9, 2022.
|
|
121
|
+
|
|
122
|
+
```svelte example hideScript
|
|
123
|
+
<script>
|
|
124
|
+
import { CalendarView } from "fluent-svelte";
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<CalendarView
|
|
128
|
+
value={new Date(2022, 2, 1)}
|
|
129
|
+
blackout={[new Date(2022, 2, 7), new Date(2022, 2, 9)]}
|
|
130
|
+
/>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Views
|
|
134
|
+
|
|
135
|
+
To aid with navigating long ranges of dates, a user can click the CalendarView's main header to switch the _view_. This lets the user quickly navigate through days, months, or years.
|
|
136
|
+
|
|
137
|
+
<ComboBox style="margin-block-end: 12px; min-inline-size: 100px;" bind:value={viewExample} placeholder="View" items={[
|
|
138
|
+
{
|
|
139
|
+
name: "days",
|
|
140
|
+
value: "days"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "months",
|
|
144
|
+
value: "months"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "years",
|
|
148
|
+
value: "years"
|
|
149
|
+
}
|
|
150
|
+
]} />
|
|
151
|
+
|
|
152
|
+
<br />
|
|
153
|
+
|
|
154
|
+
<CalendarView bind:view={viewExample} />
|
|
155
|
+
|
|
156
|
+
<br /><br />
|
|
157
|
+
|
|
158
|
+
You can control the current view that the calendar is in using the `view` property, which can be set to either `days`, `months`, or `years`. Setting the `view` property will not prevent the user from manually changing the view by clicking the header.
|
|
159
|
+
|
|
160
|
+
For example, this will start the calendar in the `months` view:
|
|
161
|
+
|
|
162
|
+
```svelte
|
|
163
|
+
<CalendarView view="months" />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Item Headers
|
|
167
|
+
|
|
168
|
+
You can choose display indicator labels for the first day of a month, or first month of a year (depending on the current view) by setting the `headers` property.
|
|
169
|
+
|
|
170
|
+
- When in days view, the first day of a given month will have a header with the month's name above it.
|
|
171
|
+
- When in months view, the first month of a given year will have the year labeled above it.
|
|
172
|
+
|
|
173
|
+
```svelte example hideScript
|
|
174
|
+
<script>
|
|
175
|
+
import { CalendarView } from "fluent-svelte";
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<CalendarView headers />
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| No Headers | Headers |
|
|
182
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
+
| <CalendarViewItem current>1</CalendarViewItem> <CalendarViewItem selected>1</CalendarViewItem> | <CalendarViewItem current header="Jan">1</CalendarViewItem> <CalendarViewItem selected header="Jan">1</CalendarViewItem> |
|
|
184
|
+
| <CalendarViewItem current variant="monthYear">Jan</CalendarViewItem> <CalendarViewItem selected variant="monthYear">Jan</CalendarViewItem> | <CalendarViewItem current variant="monthYear" header="2022">Jan</CalendarViewItem> <CalendarViewItem selected variant="monthYear" header="2022">Jan</CalendarViewItem> |
|
|
185
|
+
|
|
186
|
+
## Component API
|
|
187
|
+
|
|
188
|
+
<APIDocs manualForward {data} />
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox, Button, InfoBar } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/Checkbox/Checkbox.svelte?sveld&raw";
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
Checkboxes represent a control that a user can select (check) or clear (uncheck). A Checkbox can also report its value as indeterminate.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { Checkbox } from "fluent-svelte";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
<Showcase columns={3} repl="f749a248f8924ea3a90db238cc2c2415">
|
|
15
|
+
<Checkbox>Checkbox</Checkbox>
|
|
16
|
+
<Checkbox checked>Checkbox</Checkbox>
|
|
17
|
+
<Checkbox checked indeterminate>Checkbox</Checkbox>
|
|
18
|
+
<Checkbox disabled>Checkbox</Checkbox>
|
|
19
|
+
<Checkbox checked disabled>Checkbox</Checkbox>
|
|
20
|
+
<Checkbox checked disabled indeterminate>Checkbox</Checkbox>
|
|
21
|
+
</Showcase>
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
`<Checkbox />` is a wrapper around HTML's `<input />` checkbox type. As such, the APIs share some similarities.
|
|
26
|
+
|
|
27
|
+
### Checking and Unchecking
|
|
28
|
+
|
|
29
|
+
You can programmatically control if the checkbox is in it's checked state by setting the `checked` property.
|
|
30
|
+
|
|
31
|
+
```svelte example hideScript
|
|
32
|
+
<script>
|
|
33
|
+
import { Checkbox } from "fluent-svelte";
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<Checkbox checked />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Additionally, you can use svelte's two-way binding syntax to bind the checked state to a variable.
|
|
40
|
+
|
|
41
|
+
```svelte example
|
|
42
|
+
<script>
|
|
43
|
+
import { Checkbox } from "fluent-svelte";
|
|
44
|
+
|
|
45
|
+
let checked = false;
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<Checkbox bind:checked />
|
|
49
|
+
|
|
50
|
+
Current state: {checked ? "checked" : "unchecked"}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Indeterminate States
|
|
54
|
+
|
|
55
|
+
If the checkbox cannot be represented as either checked or unchecked, it can be marked as _indeterminate_ using the `indeterminate` property.
|
|
56
|
+
|
|
57
|
+
```svelte example hideScript
|
|
58
|
+
<script>
|
|
59
|
+
import { Checkbox } from "fluent-svelte";
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<Checkbox indeterminate />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Labels
|
|
66
|
+
|
|
67
|
+
Passing in content to the checkbox's slot will cause that content to be rendered into a label for the control.
|
|
68
|
+
|
|
69
|
+
```svelte example hideScript
|
|
70
|
+
<script>
|
|
71
|
+
import { Checkbox } from "fluent-svelte";
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<Checkbox>I have a label!</Checkbox>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Value
|
|
78
|
+
|
|
79
|
+
For usage in forms, you can set a `value` property which will set the [value](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value) of the Checkbox's `<input>` element.
|
|
80
|
+
|
|
81
|
+
### Disabled Checkboxes
|
|
82
|
+
|
|
83
|
+
If the checkbox is not meant to be clicked, you can use the `disabled` property to visually indicate this. If a checkbox is disabled, it will be unclickable.
|
|
84
|
+
|
|
85
|
+
## Component API
|
|
86
|
+
|
|
87
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button, ContentDialog, InfoBar } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/ContentDialog/ContentDialog.svelte?raw&sveld";
|
|
6
|
+
|
|
7
|
+
let open = true;
|
|
8
|
+
|
|
9
|
+
const sizes = {
|
|
10
|
+
min: 320,
|
|
11
|
+
standard: 448,
|
|
12
|
+
max: 540
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
Dialog controls are modal UI overlays that provide contextual app information. They block interactions with the app window until being explicitly dismissed. They often request some kind of action from the user.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { ContentDialog } from "fluent-svelte";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<Showcase style="block-size: 360px;" repl="0fde4983fdc841d8b7320143ee3d50d7">
|
|
23
|
+
<Button on:click={() => open = true}>
|
|
24
|
+
Open
|
|
25
|
+
</Button>
|
|
26
|
+
<ContentDialog bind:open trapFocus={false} darken={false} title="Dialog Title">
|
|
27
|
+
Some text
|
|
28
|
+
<svelte:fragment slot="footer">
|
|
29
|
+
<Button variant="accent" on:click={() => open = false}>
|
|
30
|
+
Button 1
|
|
31
|
+
</Button>
|
|
32
|
+
<Button on:click={() => open = false}>
|
|
33
|
+
Button 2
|
|
34
|
+
</Button>
|
|
35
|
+
</svelte:fragment>
|
|
36
|
+
</ContentDialog>
|
|
37
|
+
</Showcase>
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Opening and Closing
|
|
42
|
+
|
|
43
|
+
Dialogs are not rendered into the DOM initially. They need to be _opened_ first, by setting the `open` property.
|
|
44
|
+
|
|
45
|
+
```svelte
|
|
46
|
+
<ContentDialog open>This dialog is open by default.</ContentDialog>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you wish to control a dialog opening from a trigger button, you can two-way bind the `open` property to a variable.
|
|
50
|
+
|
|
51
|
+
```svelte example
|
|
52
|
+
<script>
|
|
53
|
+
import { ContentDialog, Button } from "fluent-svelte";
|
|
54
|
+
|
|
55
|
+
let open = false;
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<Button on:click={() => (open = true)}>Open Dialog</Button>
|
|
59
|
+
|
|
60
|
+
<ContentDialog bind:open>
|
|
61
|
+
I have been opened by a button click.
|
|
62
|
+
<Button on:click={() => (open = false)}>Close</Button>
|
|
63
|
+
</ContentDialog>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Additionally, dialogs can be closed by pressing the escape key. If you wish to disable this behavior, you can set the `closable` property to `false`.
|
|
67
|
+
|
|
68
|
+
### Titles
|
|
69
|
+
|
|
70
|
+
While not strictly required, it is recommended that you give the dialog a title to describe it's purpose using the `title` property. This both visually adds a title at the top of the content area, and adds an accessible label through ARIA attributes for usage with assistive technologies.
|
|
71
|
+
|
|
72
|
+
```svelte
|
|
73
|
+
<ContentDialog title="I have a title." />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<InfoBar title="A11Y Note" severity="caution">
|
|
77
|
+
The ARIA 1.2 specification requires a dialog title in order to comply with the <a href="https://www.w3.org/TR/wai-aria-practices/#dialog_modal" target="_blank" rel="noreferrer noopener">modal dialog pattern</a>.
|
|
78
|
+
</InfoBar>
|
|
79
|
+
|
|
80
|
+
### Footers
|
|
81
|
+
|
|
82
|
+
You can use the `footer` slot to insert various actions at the bottom of the dialog.
|
|
83
|
+
|
|
84
|
+
```svelte
|
|
85
|
+
<script>
|
|
86
|
+
import { ContentDialog, Button } from "fluent-svelte";
|
|
87
|
+
|
|
88
|
+
let open = true;
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<ContentDialog bind:open title="Dialog with action">
|
|
92
|
+
<Button slot="footer" on:click={() => (open = false)}>Close Dialog</Button>
|
|
93
|
+
</ContentDialog>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Size
|
|
97
|
+
|
|
98
|
+
Dialogs come in three sizes - `min`, `standard`, and `max`. You can set the dialog's size using the `size` property. With this in mind, dialogs will always responsively scale down if their width exceeds the viewport size.
|
|
99
|
+
|
|
100
|
+
<div class="dialog-sizes">
|
|
101
|
+
{#each ["min", "standard", "max"] as size}
|
|
102
|
+
<ContentDialog title="This is a {size}-sized dialog." trapFocus={false} {size} open>
|
|
103
|
+
It has a width of {sizes[size]}px.
|
|
104
|
+
<Button slot="footer">Action</Button>
|
|
105
|
+
</ContentDialog>
|
|
106
|
+
{/each}
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
### Dialog Backdrops
|
|
110
|
+
|
|
111
|
+
The default behavior of a dialog is to open with a backdrop ("smoke") layer which prevents user interaction and darkens the contents of the page behind the dialog.
|
|
112
|
+
|
|
113
|
+
- You can disable backdrop darkening by setting the `darken` property to `false`.
|
|
114
|
+
- You can configure the backdrop to close the dialog when it is clicked using the `on:backdropclick` and `on:backdropmousedown` events dispatched from the component.
|
|
115
|
+
|
|
116
|
+
### Focus Behavior
|
|
117
|
+
|
|
118
|
+
In accordance to [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction-7), dialogs utilize a focus trap, which restricts keyboard navigation focus to only the dialog's content. If you wish to disable this behavior, you can set the `trapFocus` property to `false`.
|
|
119
|
+
|
|
120
|
+
### Appending
|
|
121
|
+
|
|
122
|
+
There are some situations where you might want the dialog's elements to open appended to a specific element, separate from your markup structure. This can be useful if you want to trigger the dialog from inside a container element that has `overflow: hidden;` styles set, or if you want a single source of where dialogs should be opened from.
|
|
123
|
+
|
|
124
|
+
To do this, you can set the `append` property to any valid [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement). This will append the dialog to the specified element when opened, rather than the position specified in your markup.
|
|
125
|
+
|
|
126
|
+
```svelte
|
|
127
|
+
<ContentDialog title="Appended Dialog" append={document.body}>
|
|
128
|
+
When opened, I will be appended to this page's <body> tag. </body></ContentDialog
|
|
129
|
+
>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
<InfoBar severity="information" title="Information">
|
|
133
|
+
If you are familliar with React, this is essentially a <a href="https://reactjs.org/docs/portals.html" target="_blank" rel="noreferrer noopener">portal</a>.
|
|
134
|
+
</InfoBar>
|
|
135
|
+
|
|
136
|
+
## Component API
|
|
137
|
+
|
|
138
|
+
<APIDocs {data} />
|
|
139
|
+
|
|
140
|
+
<style lang="scss">
|
|
141
|
+
.dialog-sizes {
|
|
142
|
+
display: grid;
|
|
143
|
+
justify-content: start;
|
|
144
|
+
grid-gap: 24px;
|
|
145
|
+
margin-block-end: 64px;
|
|
146
|
+
:global {
|
|
147
|
+
.content-dialog {
|
|
148
|
+
position: relative;
|
|
149
|
+
&-smoke {
|
|
150
|
+
display: contents;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Expander } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import Circle from "@fluentui/svg-icons/icons/circle_16_regular.svg?raw";
|
|
6
|
+
|
|
7
|
+
import data from "$lib/Expander/Expander.svelte?raw&sveld";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
Expanders are controls that display a header and a collapsable content area. The content area can be expanded clicking on the header.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { Expander } from "fluent-svelte";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
<Showcase style="block-size: 360px;" repl="78aa3269aba34022a958311963520428">
|
|
17
|
+
<Expander>
|
|
18
|
+
Expander
|
|
19
|
+
<svelte:fragment slot="content">
|
|
20
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
21
|
+
</svelte:fragment>
|
|
22
|
+
</Expander>
|
|
23
|
+
<Expander>
|
|
24
|
+
<svelte:fragment slot="icon">
|
|
25
|
+
{@html Circle}
|
|
26
|
+
</svelte:fragment>
|
|
27
|
+
Expander
|
|
28
|
+
<svelte:fragment slot="content">
|
|
29
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
30
|
+
</svelte:fragment>
|
|
31
|
+
</Expander>
|
|
32
|
+
<Expander direction="up">
|
|
33
|
+
Expander
|
|
34
|
+
<svelte:fragment slot="content">
|
|
35
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
36
|
+
</svelte:fragment>
|
|
37
|
+
</Expander>
|
|
38
|
+
</Showcase>
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
A basic expander expects a header and contents. The expander's default slot will be rendered into the header, while content can be rendered into the `content` slot.
|
|
43
|
+
|
|
44
|
+
```svelte example
|
|
45
|
+
<script>
|
|
46
|
+
import { Expander } from "fluent-svelte";
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<Expander>
|
|
50
|
+
Header
|
|
51
|
+
<svelte:fragment slot="content">Content</svelte:fragment>
|
|
52
|
+
</Expander>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Controlling Expansion
|
|
56
|
+
|
|
57
|
+
Expanders can be either expanded or collapsed. This can be controlled by setting the `expanded` property.
|
|
58
|
+
|
|
59
|
+
```svelte example
|
|
60
|
+
<script>
|
|
61
|
+
import { Expander } from "fluent-svelte";
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<Expander expanded>
|
|
65
|
+
I am expanded by default.
|
|
66
|
+
<svelte:fragment slot="content">
|
|
67
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
68
|
+
</svelte:fragment>
|
|
69
|
+
</Expander>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Directions
|
|
73
|
+
|
|
74
|
+
An expander doesn't have to expand downwards. You can control an expander's expansion direction using the `direction` property. To create an upwards-expanding expander, set `direction` to `up`.
|
|
75
|
+
|
|
76
|
+
```svelte example
|
|
77
|
+
<script>
|
|
78
|
+
import { Expander } from "fluent-svelte";
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<Expander direction="up">
|
|
82
|
+
This expander will expand upwards.
|
|
83
|
+
<svelte:fragment slot="content">
|
|
84
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
85
|
+
</svelte:fragment>
|
|
86
|
+
</Expander>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Adding an Icon
|
|
90
|
+
|
|
91
|
+
You can easily add an icon to an expander's header using the `icon` slot. Passing in an SVG element will render it into the header with 16x16 dimensions.
|
|
92
|
+
|
|
93
|
+
```svelte example hideScript
|
|
94
|
+
<script>
|
|
95
|
+
import { Expander } from "fluent-svelte";
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<Expander>
|
|
99
|
+
<!-- https://github.com/microsoft/fluentui-system-icons -->
|
|
100
|
+
<svg slot="icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
|
101
|
+
<path
|
|
102
|
+
d="M7.85355 0.146447C7.65829 -0.0488155 7.34171 -0.0488155 7.14645 0.146447C6.95118 0.341709 6.95118 0.658291 7.14645 0.853553L8.29603 2.00314C4.80056 2.11088 2 4.97839 2 8.5C2 12.0899 4.91015 15 8.5 15C12.0899 15 15 12.0899 15 8.5C15 8.48656 15 8.47313 14.9999 8.45971C14.9983 8.2001 14.7805 8 14.5209 8H14.4782C14.2093 8 14 8.23107 14 8.5C14 11.5376 11.5376 14 8.5 14C5.46243 14 3 11.5376 3 8.5C3 5.53311 5.34917 3.11491 8.28892 3.00398L7.14645 4.14645C6.95118 4.34171 6.95118 4.65829 7.14645 4.85355C7.34171 5.04882 7.65829 5.04882 7.85355 4.85355L9.85355 2.85355C10.0488 2.65829 10.0488 2.34171 9.85355 2.14645L7.85355 0.146447ZM11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355L8.85355 9.85355C8.65829 10.0488 8.34171 10.0488 8.14645 9.85355L6.64645 8.35355C6.45118 8.15829 6.45118 7.84171 6.64645 7.64645C6.84171 7.45118 7.15829 7.45118 7.35355 7.64645L8.5 8.79289L11.1464 6.14645C11.3417 5.95118 11.6583 5.95118 11.8536 6.14645Z"
|
|
103
|
+
fill="currentColor"
|
|
104
|
+
/>
|
|
105
|
+
</svg>
|
|
106
|
+
Expander
|
|
107
|
+
<svelte:fragment slot="content">
|
|
108
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
109
|
+
</svelte:fragment>
|
|
110
|
+
</Expander>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Component API
|
|
114
|
+
|
|
115
|
+
<APIDocs {data} />
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Flyout, Button, ComboBox, Slider } from "$lib";
|
|
3
|
+
import { Showcase, APIDocs } from "$site/lib";
|
|
4
|
+
|
|
5
|
+
import data from "$lib/Flyout/FlyoutWrapper.svelte?raw&sveld";
|
|
6
|
+
|
|
7
|
+
const placements = ["top", "bottom", "left", "right"];
|
|
8
|
+
const alignments = ["start", "center", "end"];
|
|
9
|
+
|
|
10
|
+
const positions = placements.flatMap(placement => alignments.map(alignment => ({ placement, alignment })));
|
|
11
|
+
|
|
12
|
+
let offset = 0;
|
|
13
|
+
let placement = "top";
|
|
14
|
+
let alignment = "center";
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
Flyouts represent a control that displays lightweight UI that is either information, or requires user interaction. Unlike a [ContentDialog](contentdialog), a Flyout can be dismissed by clicking or tapping outside of it, or pressing the <kbd>Esc</kbd> key.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Flyout } from "fluent-svelte";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<Showcase repl="f884a63a8b3349e38c783e86aa4f4d17">
|
|
24
|
+
<Flyout open trapFocus={false}>
|
|
25
|
+
<Button>Open</Button>
|
|
26
|
+
<svelte:fragment slot="flyout">
|
|
27
|
+
Flyout
|
|
28
|
+
</svelte:fragment>
|
|
29
|
+
</Flyout>
|
|
30
|
+
</Showcase>
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
`Flyout` is a wrapper component. Items placed into the default slot will open the flyout when clicked. To insert contents into the flyout itself, you use the `flyout` slot.
|
|
35
|
+
|
|
36
|
+
```svelte example hideScript
|
|
37
|
+
<script>
|
|
38
|
+
import { Flyout, Button } from "fluent-svelte";
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<Flyout>
|
|
42
|
+
<Button>Trigger Button</Button>
|
|
43
|
+
<svelte:fragment slot="flyout">Flyout Contents</svelte:fragment>
|
|
44
|
+
</Flyout>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Opening and Closing
|
|
48
|
+
|
|
49
|
+
Flyouts will not be rendered into the DOM until they are opened. A flyout can be opened by the user either with keyboard navigation or by clicking items in the flyout's wrapper element.
|
|
50
|
+
|
|
51
|
+
You can control if the flyout is open using the `open` property.
|
|
52
|
+
|
|
53
|
+
```svelte
|
|
54
|
+
<Flyout open>
|
|
55
|
+
<svelte:fragment slot="flyout">This flyout is open by default.</svelte:fragment>
|
|
56
|
+
</Flyout>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can also use Svelte's two-way binding syntax to programatically open/close a flyout.
|
|
60
|
+
|
|
61
|
+
```svelte example
|
|
62
|
+
<script>
|
|
63
|
+
import { Flyout, Button } from "fluent-svelte";
|
|
64
|
+
|
|
65
|
+
let open = false;
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<Flyout bind:open>
|
|
69
|
+
<Button>Open</Button>
|
|
70
|
+
<Button on:click={() => (open = false)} slot="flyout">Close</Button>
|
|
71
|
+
</Flyout>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Additionally, flyouts can be closed by pressing the escape key or clicking on contents behind the flyout. If you wish to disable this behavior, you can set the `closable` property to `false`.
|
|
75
|
+
|
|
76
|
+
### Positioning
|
|
77
|
+
|
|
78
|
+
There are three aspects to the positioning system of flyouts - `placement`, `alignment`, and `offset`.
|
|
79
|
+
|
|
80
|
+
- The `offset` property controls the distance between the flyout and the flyout wrapper in pixels. The default offset is `8`.
|
|
81
|
+
- The `placement` property is the direction that the flyout will be opened from. This can be either `top`, `bottom`, `left`, or `right`.
|
|
82
|
+
- The `alignment` property controls either the vertical or horizontal alignment of the flyout along a given placement axis. This can be either `start`, `center`, or `end`.
|
|
83
|
+
|
|
84
|
+
### Focus Behavior
|
|
85
|
+
|
|
86
|
+
Flyouts utilize a focus trap, which restricts keyboard navigation focus to only the flyout's content. If you wish to disable this behavior, you can set the `trapFocus` property to `false`.
|
|
87
|
+
|
|
88
|
+
### Overriding Flyouts
|
|
89
|
+
|
|
90
|
+
For more niche use cases, you can completely override the flyout element with your own container using the `override` slot.
|
|
91
|
+
|
|
92
|
+
```svelte example hideScript
|
|
93
|
+
<script>
|
|
94
|
+
import { Flyout, Button } from "fluent-svelte";
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<Flyout>
|
|
98
|
+
<Button>Open</Button>
|
|
99
|
+
<div slot="override" style="background-color: red; padding: 24px; min-inline-size: 240px;">
|
|
100
|
+
Custom flyout containers! <button>Hello World!</button>
|
|
101
|
+
</div>
|
|
102
|
+
</Flyout>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Component API
|
|
106
|
+
|
|
107
|
+
<APIDocs {data} />
|