@unframed/cli 0.7.0 → 0.9.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Unframed 0.
|
|
1
|
+
# Unframed 0.9.0 components
|
|
2
2
|
|
|
3
3
|
## Accordion
|
|
4
4
|
|
|
@@ -233,6 +233,92 @@ Six colors by meaning, in three appearances: `soft` (the default), `solid` and `
|
|
|
233
233
|
| `--uf-badge-border-color` | Border color. |
|
|
234
234
|
| `--uf-badge-radius` | Corner radius. Use `999px` for a pill. |
|
|
235
235
|
|
|
236
|
+
## Breadcrumbs
|
|
237
|
+
|
|
238
|
+
Shows where the current page sits in the site: a trail of links, from the
|
|
239
|
+
top level to here. It's a navigation landmark with a list inside, and the
|
|
240
|
+
last item is marked as the current page.
|
|
241
|
+
|
|
242
|
+
Tags: `<uf-breadcrumbs>`, `<uf-breadcrumb-item>`. Import: `import '@unframed/core/breadcrumbs';` (or `npx @unframed/cli add breadcrumbs` to copy the source).
|
|
243
|
+
|
|
244
|
+
### Basic
|
|
245
|
+
|
|
246
|
+
The last item is the current page: it is not a link, and screen readers announce it as the current page.
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<uf-breadcrumbs>
|
|
250
|
+
<uf-breadcrumb-item href="/">Home</uf-breadcrumb-item>
|
|
251
|
+
<uf-breadcrumb-item href="/docs">Docs</uf-breadcrumb-item>
|
|
252
|
+
<uf-breadcrumb-item>Theming</uf-breadcrumb-item>
|
|
253
|
+
</uf-breadcrumbs>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
- It is a navigation landmark named "Breadcrumb" (translatable), or `label`. Name it differently if a page has two.
|
|
257
|
+
- Separators are hidden from screen readers, which announce the trail as a list.
|
|
258
|
+
|
|
259
|
+
### Custom separator and an icon
|
|
260
|
+
|
|
261
|
+
Put any element in the `separator` slot: it is copied between the items.
|
|
262
|
+
|
|
263
|
+
```html
|
|
264
|
+
<uf-breadcrumbs>
|
|
265
|
+
<span slot="separator">/</span>
|
|
266
|
+
<uf-breadcrumb-item href="/people/john-smith">
|
|
267
|
+
<uf-icon slot="prefix" name="user"></uf-icon>John Smith
|
|
268
|
+
</uf-breadcrumb-item>
|
|
269
|
+
<uf-breadcrumb-item href="/people/john-smith/projects">Projects</uf-breadcrumb-item>
|
|
270
|
+
<uf-breadcrumb-item>Website redesign</uf-breadcrumb-item>
|
|
271
|
+
</uf-breadcrumbs>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### `<uf-breadcrumbs>` API
|
|
275
|
+
|
|
276
|
+
#### Attributes and properties
|
|
277
|
+
|
|
278
|
+
| Attribute | Property | Type | Default | Description |
|
|
279
|
+
|---|---|---|---|---|
|
|
280
|
+
| `label` | | `string \| undefined` | | Accessible name of the navigation. Defaults to "Breadcrumb", in the page's language. |
|
|
281
|
+
|
|
282
|
+
#### Slots
|
|
283
|
+
|
|
284
|
+
| Slot | Description |
|
|
285
|
+
|---|---|
|
|
286
|
+
| (default) | `<uf-breadcrumb-item>` elements. |
|
|
287
|
+
| `separator` | A custom separator, e.g. `<span slot="separator">/</span>`. Copied between the items. |
|
|
288
|
+
|
|
289
|
+
#### CSS parts
|
|
290
|
+
|
|
291
|
+
| Part | Description |
|
|
292
|
+
|---|---|
|
|
293
|
+
| `base` | The `<nav>` element. |
|
|
294
|
+
| `list` | The list of items. |
|
|
295
|
+
|
|
296
|
+
### `<uf-breadcrumb-item>` API
|
|
297
|
+
|
|
298
|
+
#### Attributes and properties
|
|
299
|
+
|
|
300
|
+
| Attribute | Property | Type | Default | Description |
|
|
301
|
+
|---|---|---|---|---|
|
|
302
|
+
| `href` | | `string \| undefined` | | Link to this step. |
|
|
303
|
+
| `target` | | `string \| undefined` | | Link target, used with `href`. |
|
|
304
|
+
| `current` | | `boolean` | `false` | The current page. `<uf-breadcrumbs>` sets it on the last item. |
|
|
305
|
+
|
|
306
|
+
#### Slots
|
|
307
|
+
|
|
308
|
+
| Slot | Description |
|
|
309
|
+
|---|---|
|
|
310
|
+
| (default) | The label. |
|
|
311
|
+
| `prefix` | An icon before the label. |
|
|
312
|
+
| `separator` | Set by `<uf-breadcrumbs>`; you don't need it yourself. |
|
|
313
|
+
|
|
314
|
+
#### CSS parts
|
|
315
|
+
|
|
316
|
+
| Part | Description |
|
|
317
|
+
|---|---|
|
|
318
|
+
| `link` | The link, for items with `href`. |
|
|
319
|
+
| `label` | The current page's label, or an item without `href`. |
|
|
320
|
+
| `separator` | The separator after the item. |
|
|
321
|
+
|
|
236
322
|
## Button
|
|
237
323
|
|
|
238
324
|
A button that works like a native `<button>`, inside or outside a form,
|
|
@@ -785,6 +871,9 @@ Type a date in the page language's format, or open the calendar. The value is al
|
|
|
785
871
|
| `min` | | `string \| undefined` | | The earliest date that can be picked, as `YYYY-MM-DD`. |
|
|
786
872
|
| `max` | | `string \| undefined` | | The latest date that can be picked, as `YYYY-MM-DD`. |
|
|
787
873
|
| `first-day-of-week` | `firstDayOfWeek` | `number \| undefined` | | First day of the week: 0 Sunday … 6 Saturday. Defaults to the language's. |
|
|
874
|
+
| `range` | | `boolean` | `false` | Picks a range, from `start` to `end`, instead of one date. |
|
|
875
|
+
| `start` | | `string` | `''` | With `range`, the first date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
876
|
+
| `end` | | `string` | `''` | With `range`, the last date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
788
877
|
|
|
789
878
|
#### Properties only
|
|
790
879
|
|
|
@@ -802,7 +891,7 @@ Type a date in the page language's format, or open the calendar. The value is al
|
|
|
802
891
|
|
|
803
892
|
| Event | Type | Description |
|
|
804
893
|
|---|---|---|
|
|
805
|
-
| `change` | `Event` | The user picked a date
|
|
894
|
+
| `change` | `Event` | The user picked a date (read `value`), or, with `range`, completed a range (read `start` and `end`). |
|
|
806
895
|
|
|
807
896
|
#### CSS parts
|
|
808
897
|
|
|
@@ -817,6 +906,188 @@ Type a date in the page language's format, or open the calendar. The value is al
|
|
|
817
906
|
| `day` | Every day. |
|
|
818
907
|
| `selected` | The selected day. |
|
|
819
908
|
| `today` | Today. |
|
|
909
|
+
| `range-start` | With `range`, the start date. |
|
|
910
|
+
| `range-end` | With `range`, the end date. |
|
|
911
|
+
| `in-range` | With `range`, a day between the start and the end. |
|
|
912
|
+
|
|
913
|
+
#### CSS custom properties
|
|
914
|
+
|
|
915
|
+
| Property | Description |
|
|
916
|
+
|---|---|
|
|
917
|
+
| `--uf-calendar-day-size` | Width and height of a day. |
|
|
918
|
+
|
|
919
|
+
## Date range picker
|
|
920
|
+
|
|
921
|
+
A date range field: type the start and end dates in the page language's
|
|
922
|
+
format, or pick both from a calendar. The value is an ISO 8601 interval,
|
|
923
|
+
`YYYY-MM-DD/YYYY-MM-DD`, the same in every language, and it submits with the
|
|
924
|
+
form; `start` and `end` hold the two dates.
|
|
925
|
+
|
|
926
|
+
Alt + Down Arrow opens the calendar; Escape closes it.
|
|
927
|
+
|
|
928
|
+
Tags: `<uf-date-range-picker>`, `<uf-calendar>`. Import: `import '@unframed/core/date-range-picker';`, `import '@unframed/core/calendar';` (or `npx @unframed/cli add date-range-picker calendar` to copy the source).
|
|
929
|
+
|
|
930
|
+
### Basic
|
|
931
|
+
|
|
932
|
+
Type the two dates, or pick them in the calendar: the first click sets the start, the second the end.
|
|
933
|
+
|
|
934
|
+
```html
|
|
935
|
+
<uf-date-range-picker name="stay" label="Stay" hint="Check-in from 3 pm"></uf-date-range-picker>
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
- The value is an ISO 8601 interval, `2026-10-14/2026-10-18`, the same in every language; `start` and `end` hold the two dates.
|
|
939
|
+
- The format, month names and first day of the week follow the nearest `lang`.
|
|
940
|
+
|
|
941
|
+
### Limits and validation
|
|
942
|
+
|
|
943
|
+
`min`, `max` and `isDateDisabled`, as in the date picker. A missing or reversed date gets its own message.
|
|
944
|
+
|
|
945
|
+
```html
|
|
946
|
+
<uf-date-range-picker name="leave" label="Leave" required min="2026-10-20" max="2027-01-18"></uf-date-range-picker>
|
|
947
|
+
<script>
|
|
948
|
+
// A function, so it's set as a property.
|
|
949
|
+
document.querySelector('uf-date-range-picker').isDateDisabled = (iso) => [0, 6].includes(new Date(iso).getUTCDay());
|
|
950
|
+
</script>
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### Calendar on its own
|
|
954
|
+
|
|
955
|
+
`<uf-calendar range>` picks a range inline, e.g. on a booking page. `change` fires when both dates are picked.
|
|
956
|
+
|
|
957
|
+
```html
|
|
958
|
+
<uf-calendar range start="2026-10-22" end="2026-10-26"></uf-calendar>
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
### `<uf-date-range-picker>` API
|
|
962
|
+
|
|
963
|
+
#### Attributes and properties
|
|
964
|
+
|
|
965
|
+
| Attribute | Property | Type | Default | Description |
|
|
966
|
+
|---|---|---|---|---|
|
|
967
|
+
| `value` | `defaultValue` | `string` | `''` | Initial range, restored on form reset. Set with the `value` attribute, as `YYYY-MM-DD/YYYY-MM-DD`. |
|
|
968
|
+
| `label` | | `string \| undefined` | | The field's label, also its accessible name. |
|
|
969
|
+
| `hint` | | `string \| undefined` | | Help text below the field. |
|
|
970
|
+
| `placeholder` | | `string \| undefined` | | Shown in both inputs when empty. Defaults to the date format, e.g. dd/mm/yyyy. |
|
|
971
|
+
| `size` | | `FieldSize` | `'md'` | Size: `sm`, `md` or `lg`. |
|
|
972
|
+
| `min` | | `string \| undefined` | | The earliest allowed date, as `YYYY-MM-DD`. |
|
|
973
|
+
| `max` | | `string \| undefined` | | The latest allowed date, as `YYYY-MM-DD`. |
|
|
974
|
+
| `readonly` | | `boolean` | `false` | Lets the user select the text but not change the dates. |
|
|
975
|
+
| `open` | | `boolean` | `false` | Whether the calendar is open. |
|
|
976
|
+
| `name` | | `string` | `''` | Name submitted with the form. |
|
|
977
|
+
| `disabled` | | `boolean` | `false` | Disables the control. |
|
|
978
|
+
| `required` | | `boolean` | `false` | Makes the control required for form submission. |
|
|
979
|
+
|
|
980
|
+
#### Properties only
|
|
981
|
+
|
|
982
|
+
| Property | Type | Description |
|
|
983
|
+
|---|---|---|
|
|
984
|
+
| `start` | `string` | The first date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
985
|
+
| `end` | `string` | The last date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
986
|
+
| `isDateDisabled` | `((date: string) => boolean) \| undefined` | Rules out dates, e.g. weekends: called with each date as `YYYY-MM-DD`, returns true to disable it. |
|
|
987
|
+
| `value` | `string` | The range as an ISO 8601 interval, `YYYY-MM-DD/YYYY-MM-DD`, or an empty string until both dates are set. |
|
|
988
|
+
| `form` | `HTMLFormElement \| null` | Read-only. The form this control belongs to, if any. |
|
|
989
|
+
| `validity` | `ValidityState` | Read-only. The control's validity state, like a native input's. |
|
|
990
|
+
| `validationMessage` | `string` | Read-only. The error message shown when the value is invalid. |
|
|
991
|
+
| `willValidate` | `boolean` | Read-only. Whether the control takes part in form validation. |
|
|
992
|
+
|
|
993
|
+
#### Methods
|
|
994
|
+
|
|
995
|
+
| Method | Description |
|
|
996
|
+
|---|---|
|
|
997
|
+
| `show()` | Opens the calendar. |
|
|
998
|
+
| `hide()` | Closes the calendar. |
|
|
999
|
+
| `checkValidity()` | Returns whether the value is valid, without showing an error. |
|
|
1000
|
+
| `reportValidity()` | Returns whether the value is valid, and shows the error if not. |
|
|
1001
|
+
| `setCustomValidity(message: string)` | Sets a custom error message. Pass an empty string to clear it. |
|
|
1002
|
+
|
|
1003
|
+
#### Events
|
|
1004
|
+
|
|
1005
|
+
| Event | Type | Description |
|
|
1006
|
+
|---|---|---|
|
|
1007
|
+
| `input` | `Event` | The range changed (a date was typed and committed, or both were picked). |
|
|
1008
|
+
| `change` | `Event` | The range changed (a date was typed and committed, or both were picked). |
|
|
1009
|
+
| `uf-show` | | The calendar opened. |
|
|
1010
|
+
| `uf-hide` | | The calendar closed. |
|
|
1011
|
+
|
|
1012
|
+
#### Slots
|
|
1013
|
+
|
|
1014
|
+
| Slot | Description |
|
|
1015
|
+
|---|---|
|
|
1016
|
+
| `label` | The label, when you need markup. Overrides `label`. |
|
|
1017
|
+
| `hint` | Help text below the field. Overrides `hint`. |
|
|
1018
|
+
|
|
1019
|
+
#### CSS parts
|
|
1020
|
+
|
|
1021
|
+
| Part | Description |
|
|
1022
|
+
|---|---|
|
|
1023
|
+
| `field` | The wrapper around label, control, hint and error. |
|
|
1024
|
+
| `form-label` | The label. |
|
|
1025
|
+
| `box` | The bordered box around the inputs. |
|
|
1026
|
+
| `start-input` | The start date input. |
|
|
1027
|
+
| `end-input` | The end date input. |
|
|
1028
|
+
| `separator` | The dash between the two inputs. |
|
|
1029
|
+
| `toggle` | The calendar button. |
|
|
1030
|
+
| `popup` | The floating panel around the calendar. |
|
|
1031
|
+
| `calendar` | The `<uf-calendar>`. |
|
|
1032
|
+
| `hint` | The hint text. |
|
|
1033
|
+
| `error` | The validation message. |
|
|
1034
|
+
|
|
1035
|
+
#### CSS custom properties
|
|
1036
|
+
|
|
1037
|
+
| Property | Description |
|
|
1038
|
+
|---|---|
|
|
1039
|
+
| `--uf-field-bg` | Background of the box. |
|
|
1040
|
+
| `--uf-field-border-color` | Border color of the box. |
|
|
1041
|
+
| `--uf-field-radius` | Corner radius of the box. |
|
|
1042
|
+
|
|
1043
|
+
### `<uf-calendar>` API
|
|
1044
|
+
|
|
1045
|
+
#### Attributes and properties
|
|
1046
|
+
|
|
1047
|
+
| Attribute | Property | Type | Default | Description |
|
|
1048
|
+
|---|---|---|---|---|
|
|
1049
|
+
| `value` | | `string` | `''` | The selected date, as `YYYY-MM-DD`, or an empty string. |
|
|
1050
|
+
| `min` | | `string \| undefined` | | The earliest date that can be picked, as `YYYY-MM-DD`. |
|
|
1051
|
+
| `max` | | `string \| undefined` | | The latest date that can be picked, as `YYYY-MM-DD`. |
|
|
1052
|
+
| `first-day-of-week` | `firstDayOfWeek` | `number \| undefined` | | First day of the week: 0 Sunday … 6 Saturday. Defaults to the language's. |
|
|
1053
|
+
| `range` | | `boolean` | `false` | Picks a range, from `start` to `end`, instead of one date. |
|
|
1054
|
+
| `start` | | `string` | `''` | With `range`, the first date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
1055
|
+
| `end` | | `string` | `''` | With `range`, the last date of the range, as `YYYY-MM-DD`, or an empty string. |
|
|
1056
|
+
|
|
1057
|
+
#### Properties only
|
|
1058
|
+
|
|
1059
|
+
| Property | Type | Description |
|
|
1060
|
+
|---|---|---|
|
|
1061
|
+
| `isDateDisabled` | `((date: string) => boolean) \| undefined` | Rules out dates, e.g. weekends: called with each date as `YYYY-MM-DD`, returns true to disable it. |
|
|
1062
|
+
|
|
1063
|
+
#### Methods
|
|
1064
|
+
|
|
1065
|
+
| Method | Description |
|
|
1066
|
+
|---|---|
|
|
1067
|
+
| `focus(options: FocusOptions)` | Moves keyboard focus to the selected day, or today. |
|
|
1068
|
+
|
|
1069
|
+
#### Events
|
|
1070
|
+
|
|
1071
|
+
| Event | Type | Description |
|
|
1072
|
+
|---|---|---|
|
|
1073
|
+
| `change` | `Event` | The user picked a date (read `value`), or, with `range`, completed a range (read `start` and `end`). |
|
|
1074
|
+
|
|
1075
|
+
#### CSS parts
|
|
1076
|
+
|
|
1077
|
+
| Part | Description |
|
|
1078
|
+
|---|---|
|
|
1079
|
+
| `base` | The calendar. |
|
|
1080
|
+
| `header` | The month title and the previous and next buttons. |
|
|
1081
|
+
| `title` | The month and year. |
|
|
1082
|
+
| `nav-button` | The previous and next month buttons. |
|
|
1083
|
+
| `grid` | The `<table>` of days. |
|
|
1084
|
+
| `weekday` | A weekday heading. |
|
|
1085
|
+
| `day` | Every day. |
|
|
1086
|
+
| `selected` | The selected day. |
|
|
1087
|
+
| `today` | Today. |
|
|
1088
|
+
| `range-start` | With `range`, the start date. |
|
|
1089
|
+
| `range-end` | With `range`, the end date. |
|
|
1090
|
+
| `in-range` | With `range`, a day between the start and the end. |
|
|
820
1091
|
|
|
821
1092
|
#### CSS custom properties
|
|
822
1093
|
|
|
@@ -902,6 +1173,103 @@ Escape, the close button and any element with `data-dialog="close"` close it.
|
|
|
902
1173
|
| `--uf-dialog-radius` | Corner radius. |
|
|
903
1174
|
| `--uf-dialog-backdrop` | Backdrop color. |
|
|
904
1175
|
|
|
1176
|
+
## Drawer
|
|
1177
|
+
|
|
1178
|
+
A panel that slides in from an edge of the screen, for navigation, filters or
|
|
1179
|
+
details. It is a modal dialog, so it behaves like `<uf-dialog>`: it traps
|
|
1180
|
+
focus, makes the page inert, closes with Escape, and returns focus to the
|
|
1181
|
+
opener. Any element inside with `data-dialog="close"` closes it.
|
|
1182
|
+
|
|
1183
|
+
Tags: `<uf-drawer>`. Import: `import '@unframed/core/drawer';` (or `npx @unframed/cli add drawer` to copy the source).
|
|
1184
|
+
|
|
1185
|
+
### Filters
|
|
1186
|
+
|
|
1187
|
+
A modal panel from the end edge. Escape, the close button and any element with `data-dialog="close"` close it.
|
|
1188
|
+
|
|
1189
|
+
```html
|
|
1190
|
+
<uf-button variant="outline" onclick="this.nextElementSibling.show()">Filters</uf-button>
|
|
1191
|
+
<uf-drawer label="Filters" light-dismiss>
|
|
1192
|
+
<uf-checkbox-group label="Status">
|
|
1193
|
+
<uf-checkbox value="open">Open</uf-checkbox>
|
|
1194
|
+
<uf-checkbox value="closed">Closed</uf-checkbox>
|
|
1195
|
+
</uf-checkbox-group>
|
|
1196
|
+
<uf-button slot="footer" variant="ghost" data-dialog="close">Cancel</uf-button>
|
|
1197
|
+
<uf-button slot="footer" data-dialog="close">Apply</uf-button>
|
|
1198
|
+
</uf-drawer>
|
|
1199
|
+
```
|
|
1200
|
+
|
|
1201
|
+
- It is a modal dialog: focus stays inside, the page behind is inert and does not scroll, and focus returns to the button on close.
|
|
1202
|
+
|
|
1203
|
+
### Placement
|
|
1204
|
+
|
|
1205
|
+
`start`, `end` (the default), `top` or `bottom`. Start and end follow the page direction. `--uf-drawer-size` sets the width, or the height for top and bottom.
|
|
1206
|
+
|
|
1207
|
+
```html
|
|
1208
|
+
<uf-drawer label="Menu" placement="start">…</uf-drawer>
|
|
1209
|
+
<uf-drawer label="Cart" placement="end" style="--uf-drawer-size: 28rem">…</uf-drawer>
|
|
1210
|
+
<uf-drawer label="Cookies" placement="bottom">…</uf-drawer>
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
### `<uf-drawer>` API
|
|
1214
|
+
|
|
1215
|
+
#### Attributes and properties
|
|
1216
|
+
|
|
1217
|
+
| Attribute | Property | Type | Default | Description |
|
|
1218
|
+
|---|---|---|---|---|
|
|
1219
|
+
| `placement` | | `DrawerPlacement` | `'end'` | The edge it slides in from: `start` (left, in left-to-right pages), `end`, `top` or `bottom`. |
|
|
1220
|
+
| `open` | | `boolean` | `false` | Whether the dialog is open. |
|
|
1221
|
+
| `label` | | `string \| undefined` | | Title of the dialog, also its accessible name. |
|
|
1222
|
+
| `light-dismiss` | `lightDismiss` | `boolean` | `false` | Closes the dialog when the backdrop is clicked. |
|
|
1223
|
+
| `without-header` | `withoutHeader` | `boolean` | `false` | Hides the header. Set `label` anyway, so the dialog keeps an accessible name. |
|
|
1224
|
+
|
|
1225
|
+
#### Methods
|
|
1226
|
+
|
|
1227
|
+
| Method | Description |
|
|
1228
|
+
|---|---|
|
|
1229
|
+
| `show()` | Opens the dialog. |
|
|
1230
|
+
| `hide()` | Closes the dialog, without firing `uf-request-close`. |
|
|
1231
|
+
| `requestClose(source?: DialogCloseSource)` | Asks to close, as a user action would. Listeners can cancel it. |
|
|
1232
|
+
|
|
1233
|
+
#### Events
|
|
1234
|
+
|
|
1235
|
+
| Event | Type | Description |
|
|
1236
|
+
|---|---|---|
|
|
1237
|
+
| `uf-show` | `Event` | The drawer opened. |
|
|
1238
|
+
| `uf-hide` | `Event` | The drawer closed. |
|
|
1239
|
+
| `uf-request-close` | `CustomEvent<DialogRequestCloseDetail>` | The user tried to close the drawer. Call `preventDefault()` to keep it open. |
|
|
1240
|
+
|
|
1241
|
+
#### Slots
|
|
1242
|
+
|
|
1243
|
+
| Slot | Description |
|
|
1244
|
+
|---|---|
|
|
1245
|
+
| (default) | The drawer content. |
|
|
1246
|
+
| `label` | The title, when you need markup. Overrides `label`. |
|
|
1247
|
+
| `header-actions` | Extra buttons next to the close button. |
|
|
1248
|
+
| `footer` | Actions at the bottom, usually buttons. |
|
|
1249
|
+
|
|
1250
|
+
#### CSS parts
|
|
1251
|
+
|
|
1252
|
+
| Part | Description |
|
|
1253
|
+
|---|---|
|
|
1254
|
+
| `dialog` | The native `<dialog>`. |
|
|
1255
|
+
| `header` | The header with title and close button. |
|
|
1256
|
+
| `title` | The title. |
|
|
1257
|
+
| `close-button` | The close button. |
|
|
1258
|
+
| `body` | The content area. |
|
|
1259
|
+
| `footer` | The footer. |
|
|
1260
|
+
|
|
1261
|
+
#### CSS custom properties
|
|
1262
|
+
|
|
1263
|
+
| Property | Description |
|
|
1264
|
+
|---|---|
|
|
1265
|
+
| `--uf-drawer-size` | Width of a side drawer, or height of a top or bottom one. Defaults to `24rem`. |
|
|
1266
|
+
| `--uf-drawer-radius` | Corner radius of the corners on the open side; the side against the screen edge stays square. |
|
|
1267
|
+
| `--uf-dialog-bg` | Background of the drawer. |
|
|
1268
|
+
| `--uf-dialog-padding` | Padding of header, body and footer. |
|
|
1269
|
+
| `--uf-dialog-backdrop` | Backdrop color. |
|
|
1270
|
+
| `--uf-dialog-width` | Width of the dialog. Defaults to `32rem`. |
|
|
1271
|
+
| `--uf-dialog-radius` | Corner radius. |
|
|
1272
|
+
|
|
905
1273
|
## Dropdown menu
|
|
906
1274
|
|
|
907
1275
|
A button that opens a `<uf-menu>`, following the WAI-ARIA menu button
|
|
@@ -1032,6 +1400,109 @@ Arrow keys move, typing a letter jumps to an item, Escape closes.
|
|
|
1032
1400
|
| `checkmark` | The check shown for checked checkbox items. |
|
|
1033
1401
|
| `label` | The label wrapper. |
|
|
1034
1402
|
|
|
1403
|
+
## File upload
|
|
1404
|
+
|
|
1405
|
+
Picks files to send with a form: from a button, or by dragging them onto the
|
|
1406
|
+
drop zone. The chosen files are listed with their size and a remove button.
|
|
1407
|
+
Files that don't match `accept` or are larger than `max-size` are refused,
|
|
1408
|
+
with a message saying why. It submits like a native `<input type="file">`.
|
|
1409
|
+
|
|
1410
|
+
Tags: `<uf-file-upload>`. Import: `import '@unframed/core/file-upload';` (or `npx @unframed/cli add file-upload` to copy the source).
|
|
1411
|
+
|
|
1412
|
+
### Basic
|
|
1413
|
+
|
|
1414
|
+
A button and a drop zone. The chosen files are listed with their size and a remove button.
|
|
1415
|
+
|
|
1416
|
+
```html
|
|
1417
|
+
<uf-file-upload name="attachments" label="Attachments" hint="PDF or images, up to 5 MB each" multiple accept=".pdf, image/*" max-size="5000000"></uf-file-upload>
|
|
1418
|
+
```
|
|
1419
|
+
|
|
1420
|
+
- Files that `accept` rules out, or larger than `max-size` (in bytes), are refused, with a message saying why.
|
|
1421
|
+
- It submits with its form like a native file input: `new FormData(form).getAll("attachments")` returns the files.
|
|
1422
|
+
|
|
1423
|
+
### One file, required
|
|
1424
|
+
|
|
1425
|
+
Without `multiple`, a new pick replaces the file. `required` makes the form ask for one.
|
|
1426
|
+
|
|
1427
|
+
```html
|
|
1428
|
+
<form>
|
|
1429
|
+
<uf-file-upload name="cv" label="Your CV" accept=".pdf" required></uf-file-upload>
|
|
1430
|
+
<uf-button type="submit">Apply</uf-button>
|
|
1431
|
+
</form>
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
### `<uf-file-upload>` API
|
|
1435
|
+
|
|
1436
|
+
#### Attributes and properties
|
|
1437
|
+
|
|
1438
|
+
| Attribute | Property | Type | Default | Description |
|
|
1439
|
+
|---|---|---|---|---|
|
|
1440
|
+
| `label` | | `string \| undefined` | | Visible label. |
|
|
1441
|
+
| `hint` | | `string \| undefined` | | Help text, e.g. the accepted types and size. |
|
|
1442
|
+
| `accept` | | `string \| undefined` | | Accepted files, as in a native file input: extensions (`.pdf`), MIME types (`image/png`) or wildcards (`image/*`), comma-separated. |
|
|
1443
|
+
| `multiple` | | `boolean` | `false` | Lets users choose more than one file. |
|
|
1444
|
+
| `max-size` | `maxSize` | `number \| undefined` | | Largest accepted file, in bytes, e.g. `5000000` for 5 MB. |
|
|
1445
|
+
| `name` | | `string` | `''` | Name submitted with the form. |
|
|
1446
|
+
| `disabled` | | `boolean` | `false` | Disables the control. |
|
|
1447
|
+
| `required` | | `boolean` | `false` | Makes the control required for form submission. |
|
|
1448
|
+
|
|
1449
|
+
#### Properties only
|
|
1450
|
+
|
|
1451
|
+
| Property | Type | Description |
|
|
1452
|
+
|---|---|---|
|
|
1453
|
+
| `files` | `File[]` | The chosen files. Set it to `[]` to clear them. |
|
|
1454
|
+
| `form` | `HTMLFormElement \| null` | Read-only. The form this control belongs to, if any. |
|
|
1455
|
+
| `validity` | `ValidityState` | Read-only. The control's validity state, like a native input's. |
|
|
1456
|
+
| `validationMessage` | `string` | Read-only. The error message shown when the value is invalid. |
|
|
1457
|
+
| `willValidate` | `boolean` | Read-only. Whether the control takes part in form validation. |
|
|
1458
|
+
|
|
1459
|
+
#### Methods
|
|
1460
|
+
|
|
1461
|
+
| Method | Description |
|
|
1462
|
+
|---|---|
|
|
1463
|
+
| `showPicker()` | Opens the file picker. |
|
|
1464
|
+
| `checkValidity()` | Returns whether the value is valid, without showing an error. |
|
|
1465
|
+
| `reportValidity()` | Returns whether the value is valid, and shows the error if not. |
|
|
1466
|
+
| `setCustomValidity(message: string)` | Sets a custom error message. Pass an empty string to clear it. |
|
|
1467
|
+
|
|
1468
|
+
#### Events
|
|
1469
|
+
|
|
1470
|
+
| Event | Type | Description |
|
|
1471
|
+
|---|---|---|
|
|
1472
|
+
| `input` | `Event` | Fired when files are added or removed. |
|
|
1473
|
+
| `change` | `Event` | Fired when files are added or removed. |
|
|
1474
|
+
|
|
1475
|
+
#### Slots
|
|
1476
|
+
|
|
1477
|
+
| Slot | Description |
|
|
1478
|
+
|---|---|
|
|
1479
|
+
| `label` | The label, when you need markup. Overrides `label`. |
|
|
1480
|
+
| `hint` | Help text below the label. Overrides `hint`. |
|
|
1481
|
+
|
|
1482
|
+
#### CSS parts
|
|
1483
|
+
|
|
1484
|
+
| Part | Description |
|
|
1485
|
+
|---|---|
|
|
1486
|
+
| `field` | The wrapper around label, drop zone, files, hint and error. |
|
|
1487
|
+
| `form-label` | The label. |
|
|
1488
|
+
| `dropzone` | The area files can be dropped on. |
|
|
1489
|
+
| `button` | The button that opens the file picker. |
|
|
1490
|
+
| `files` | The list of chosen files. |
|
|
1491
|
+
| `file` | A chosen file. |
|
|
1492
|
+
| `remove-button` | A file's remove button. |
|
|
1493
|
+
| `rejected` | Why files were refused. |
|
|
1494
|
+
| `hint` | The hint text. |
|
|
1495
|
+
| `error` | The validation message. |
|
|
1496
|
+
|
|
1497
|
+
#### CSS custom properties
|
|
1498
|
+
|
|
1499
|
+
| Property | Description |
|
|
1500
|
+
|---|---|
|
|
1501
|
+
| `--uf-file-upload-border-color` | Border color of the drop zone. |
|
|
1502
|
+
| `--uf-file-upload-bg` | Background of the drop zone. |
|
|
1503
|
+
| `--uf-file-upload-radius` | Corner radius of the drop zone. Defaults to the theme's control radius. |
|
|
1504
|
+
| `--uf-file-upload-active-color` | Border and background tint while files are dragged over. |
|
|
1505
|
+
|
|
1035
1506
|
## Icon
|
|
1036
1507
|
|
|
1037
1508
|
An icon from the built-in set, or one added with `registerIcons()`.
|
|
@@ -1322,6 +1793,72 @@ Tags: `<uf-popover>`. Import: `import '@unframed/core/popover';` (or `npx @unfra
|
|
|
1322
1793
|
| `--uf-popover-padding` | Padding of the panel. |
|
|
1323
1794
|
| `--uf-popover-width` | Width of the panel. Defaults to its content. |
|
|
1324
1795
|
|
|
1796
|
+
## Progress
|
|
1797
|
+
|
|
1798
|
+
A bar that shows how far a task has got. Without a `value` it's
|
|
1799
|
+
indeterminate: an animated bar for work whose length isn't known, like a
|
|
1800
|
+
native `<progress>`.
|
|
1801
|
+
|
|
1802
|
+
Tags: `<uf-progress>`. Import: `import '@unframed/core/progress';` (or `npx @unframed/cli add progress` to copy the source).
|
|
1803
|
+
|
|
1804
|
+
### Value
|
|
1805
|
+
|
|
1806
|
+
`value` out of `max` (100 by default). `show-value` adds the percentage.
|
|
1807
|
+
|
|
1808
|
+
```html
|
|
1809
|
+
<uf-progress label="Uploading report.pdf" value="45" show-value></uf-progress>
|
|
1810
|
+
<uf-progress label="Storage" value="92" variant="warning" show-value></uf-progress>
|
|
1811
|
+
<uf-progress label="Profile complete" value="5" max="5" variant="success" size="sm"></uf-progress>
|
|
1812
|
+
```
|
|
1813
|
+
|
|
1814
|
+
- Screen readers announce it as a progress bar with its label and percentage. Without a `label`, it is named "Progress" (translatable).
|
|
1815
|
+
|
|
1816
|
+
### Indeterminate
|
|
1817
|
+
|
|
1818
|
+
Leave out `value` when the length of the work is not known.
|
|
1819
|
+
|
|
1820
|
+
```html
|
|
1821
|
+
<uf-progress label="Preparing your export"></uf-progress>
|
|
1822
|
+
```
|
|
1823
|
+
|
|
1824
|
+
### `<uf-progress>` API
|
|
1825
|
+
|
|
1826
|
+
#### Attributes and properties
|
|
1827
|
+
|
|
1828
|
+
| Attribute | Property | Type | Default | Description |
|
|
1829
|
+
|---|---|---|---|---|
|
|
1830
|
+
| `value` | | `number \| undefined` | | Progress so far, from 0 to `max`. Leave it out for an indeterminate bar. |
|
|
1831
|
+
| `max` | | `number` | `100` | The value that means done. |
|
|
1832
|
+
| `label` | | `string \| undefined` | | Visible label, also the bar's accessible name. Without one, it's named "Progress". |
|
|
1833
|
+
| `show-value` | `showValue` | `boolean` | `false` | Shows the percentage next to the label. |
|
|
1834
|
+
| `variant` | | `ProgressVariant` | `'accent'` | Color, by meaning: `accent`, `success`, `warning` or `danger`. |
|
|
1835
|
+
| `size` | | `ProgressSize` | `'md'` | Height of the bar: `sm` or `md`. |
|
|
1836
|
+
|
|
1837
|
+
#### Slots
|
|
1838
|
+
|
|
1839
|
+
| Slot | Description |
|
|
1840
|
+
|---|---|
|
|
1841
|
+
| `label` | The label, when you need markup. Overrides `label`. |
|
|
1842
|
+
|
|
1843
|
+
#### CSS parts
|
|
1844
|
+
|
|
1845
|
+
| Part | Description |
|
|
1846
|
+
|---|---|
|
|
1847
|
+
| `base` | The wrapper around label and bar. |
|
|
1848
|
+
| `label` | The label. |
|
|
1849
|
+
| `value` | The percentage, when `show-value` is set. |
|
|
1850
|
+
| `track` | The bar's background. |
|
|
1851
|
+
| `indicator` | The filled part of the bar. |
|
|
1852
|
+
|
|
1853
|
+
#### CSS custom properties
|
|
1854
|
+
|
|
1855
|
+
| Property | Description |
|
|
1856
|
+
|---|---|
|
|
1857
|
+
| `--uf-progress-height` | Height of the bar. |
|
|
1858
|
+
| `--uf-progress-radius` | Corner radius of the bar. Use `999px` for a pill. |
|
|
1859
|
+
| `--uf-progress-track-color` | Color of the bar's background. |
|
|
1860
|
+
| `--uf-progress-indicator-color` | Color of the filled part. |
|
|
1861
|
+
|
|
1325
1862
|
## Radio group
|
|
1326
1863
|
|
|
1327
1864
|
A group of `<uf-radio>` options with one selected value. Arrow keys move
|
|
@@ -1523,6 +2060,154 @@ Built on the native `<select>`: write plain `<option>` and `<optgroup>` children
|
|
|
1523
2060
|
| `--uf-field-border-color` | Border color of the box. |
|
|
1524
2061
|
| `--uf-field-radius` | Corner radius of the box. |
|
|
1525
2062
|
|
|
2063
|
+
## Slider
|
|
2064
|
+
|
|
2065
|
+
Picks a number in a range by dragging a handle, or with the arrow keys. Built
|
|
2066
|
+
on the native range input, so keyboard, touch and screen readers work as
|
|
2067
|
+
they do everywhere; it submits its value with the form.
|
|
2068
|
+
|
|
2069
|
+
Tags: `<uf-slider>`. Import: `import '@unframed/core/slider';` (or `npx @unframed/cli add slider` to copy the source).
|
|
2070
|
+
|
|
2071
|
+
### Basic
|
|
2072
|
+
|
|
2073
|
+
A native range input underneath: arrow keys, Page Up/Down, Home and End, touch, and screen readers work as everywhere.
|
|
2074
|
+
|
|
2075
|
+
```html
|
|
2076
|
+
<uf-slider name="volume" label="Volume" hint="Applies to every device" value="40" show-value></uf-slider>
|
|
2077
|
+
```
|
|
2078
|
+
|
|
2079
|
+
- The value is a number. It submits with its form, and `input` fires while dragging, `change` when the user lets go.
|
|
2080
|
+
|
|
2081
|
+
### Range and step
|
|
2082
|
+
|
|
2083
|
+
`min`, `max` and `step`. The value always lands on a step within the range.
|
|
2084
|
+
|
|
2085
|
+
```html
|
|
2086
|
+
<uf-slider label="Maximum price (€)" min="0" max="500" step="10" value="250" show-value></uf-slider>
|
|
2087
|
+
<uf-slider label="Rating" min="1" max="5" value="4" show-value disabled></uf-slider>
|
|
2088
|
+
```
|
|
2089
|
+
|
|
2090
|
+
### `<uf-slider>` API
|
|
2091
|
+
|
|
2092
|
+
#### Attributes and properties
|
|
2093
|
+
|
|
2094
|
+
| Attribute | Property | Type | Default | Description |
|
|
2095
|
+
|---|---|---|---|---|
|
|
2096
|
+
| `value` | `defaultValue` | `number \| undefined` | | Initial value, restored on form reset. Set with the `value` attribute. Defaults to the middle of the range, like a native slider. |
|
|
2097
|
+
| `min` | | `number` | `0` | Lowest value. |
|
|
2098
|
+
| `max` | | `number` | `100` | Highest value. |
|
|
2099
|
+
| `step` | | `number` | `1` | Granularity: the value moves in steps of this size. |
|
|
2100
|
+
| `label` | | `string \| undefined` | | Visible label, also the slider's accessible name. |
|
|
2101
|
+
| `hint` | | `string \| undefined` | | Help text below the slider. |
|
|
2102
|
+
| `show-value` | `showValue` | `boolean` | `false` | Shows the current value next to the label. |
|
|
2103
|
+
| `name` | | `string` | `''` | Name submitted with the form. |
|
|
2104
|
+
| `disabled` | | `boolean` | `false` | Disables the control. |
|
|
2105
|
+
| `required` | | `boolean` | `false` | Makes the control required for form submission. |
|
|
2106
|
+
|
|
2107
|
+
#### Properties only
|
|
2108
|
+
|
|
2109
|
+
| Property | Type | Description |
|
|
2110
|
+
|---|---|---|
|
|
2111
|
+
| `value` | `number` | Current value. |
|
|
2112
|
+
| `form` | `HTMLFormElement \| null` | Read-only. The form this control belongs to, if any. |
|
|
2113
|
+
| `validity` | `ValidityState` | Read-only. The control's validity state, like a native input's. |
|
|
2114
|
+
| `validationMessage` | `string` | Read-only. The error message shown when the value is invalid. |
|
|
2115
|
+
| `willValidate` | `boolean` | Read-only. Whether the control takes part in form validation. |
|
|
2116
|
+
|
|
2117
|
+
#### Methods
|
|
2118
|
+
|
|
2119
|
+
| Method | Description |
|
|
2120
|
+
|---|---|
|
|
2121
|
+
| `checkValidity()` | Returns whether the value is valid, without showing an error. |
|
|
2122
|
+
| `reportValidity()` | Returns whether the value is valid, and shows the error if not. |
|
|
2123
|
+
| `setCustomValidity(message: string)` | Sets a custom error message. Pass an empty string to clear it. |
|
|
2124
|
+
|
|
2125
|
+
#### Events
|
|
2126
|
+
|
|
2127
|
+
| Event | Type | Description |
|
|
2128
|
+
|---|---|---|
|
|
2129
|
+
| `input` | | Fired while the handle moves. |
|
|
2130
|
+
| `change` | `Event` | Fired when the user lets go, or after a key press. |
|
|
2131
|
+
|
|
2132
|
+
#### Slots
|
|
2133
|
+
|
|
2134
|
+
| Slot | Description |
|
|
2135
|
+
|---|---|
|
|
2136
|
+
| `label` | The label, when you need markup. Overrides `label`. |
|
|
2137
|
+
| `hint` | Help text below the slider. Overrides `hint`. |
|
|
2138
|
+
|
|
2139
|
+
#### CSS parts
|
|
2140
|
+
|
|
2141
|
+
| Part | Description |
|
|
2142
|
+
|---|---|
|
|
2143
|
+
| `field` | The wrapper around label, slider, hint and error. |
|
|
2144
|
+
| `form-label` | The label. |
|
|
2145
|
+
| `value` | The current value, when `show-value` is set. |
|
|
2146
|
+
| `input` | The native range `<input>`. |
|
|
2147
|
+
| `hint` | The hint text. |
|
|
2148
|
+
| `error` | The validation message. |
|
|
2149
|
+
|
|
2150
|
+
#### CSS custom properties
|
|
2151
|
+
|
|
2152
|
+
| Property | Description |
|
|
2153
|
+
|---|---|
|
|
2154
|
+
| `--uf-slider-track-height` | Height of the track. |
|
|
2155
|
+
| `--uf-slider-track-color` | Color of the track's empty part. |
|
|
2156
|
+
| `--uf-slider-fill-color` | Color of the track up to the handle. |
|
|
2157
|
+
| `--uf-slider-thumb-size` | Diameter of the handle. |
|
|
2158
|
+
|
|
2159
|
+
## Spinner
|
|
2160
|
+
|
|
2161
|
+
A spinning circle for work in progress whose length isn't known. Screen
|
|
2162
|
+
readers announce it as "Loading" (translatable), or as its `label`.
|
|
2163
|
+
|
|
2164
|
+
Tags: `<uf-spinner>`. Import: `import '@unframed/core/spinner';` (or `npx @unframed/cli add spinner` to copy the source).
|
|
2165
|
+
|
|
2166
|
+
### Sizes
|
|
2167
|
+
|
|
2168
|
+
`sm`, `md` (the default) or `lg`, or any size with `--uf-spinner-size`.
|
|
2169
|
+
|
|
2170
|
+
```html
|
|
2171
|
+
<uf-spinner size="sm"></uf-spinner>
|
|
2172
|
+
<uf-spinner></uf-spinner>
|
|
2173
|
+
<uf-spinner size="lg"></uf-spinner>
|
|
2174
|
+
<uf-spinner style="--uf-spinner-size: 3.5rem"></uf-spinner>
|
|
2175
|
+
```
|
|
2176
|
+
|
|
2177
|
+
### Label and color
|
|
2178
|
+
|
|
2179
|
+
Screen readers announce "Loading" (translatable), or `label`. Colors come from the theme, or `--uf-spinner-indicator-color`.
|
|
2180
|
+
|
|
2181
|
+
```html
|
|
2182
|
+
<uf-spinner label="Loading John Smith's orders"></uf-spinner>
|
|
2183
|
+
<uf-spinner label="Saving" style="--uf-spinner-indicator-color: var(--uf-color-success)"></uf-spinner>
|
|
2184
|
+
```
|
|
2185
|
+
|
|
2186
|
+
- For a button that is busy, use the button's `loading` instead: it keeps the button focusable and its label for screen readers.
|
|
2187
|
+
|
|
2188
|
+
### `<uf-spinner>` API
|
|
2189
|
+
|
|
2190
|
+
#### Attributes and properties
|
|
2191
|
+
|
|
2192
|
+
| Attribute | Property | Type | Default | Description |
|
|
2193
|
+
|---|---|---|---|---|
|
|
2194
|
+
| `label` | | `string \| undefined` | | Accessible name. Defaults to "Loading", in the page's language. |
|
|
2195
|
+
| `size` | | `SpinnerSize` | `'md'` | Size: `sm`, `md` or `lg`. |
|
|
2196
|
+
|
|
2197
|
+
#### CSS parts
|
|
2198
|
+
|
|
2199
|
+
| Part | Description |
|
|
2200
|
+
|---|---|
|
|
2201
|
+
| `base` | The spinner. |
|
|
2202
|
+
|
|
2203
|
+
#### CSS custom properties
|
|
2204
|
+
|
|
2205
|
+
| Property | Description |
|
|
2206
|
+
|---|---|
|
|
2207
|
+
| `--uf-spinner-size` | Diameter. Overrides `size`. |
|
|
2208
|
+
| `--uf-spinner-track-color` | Color of the circle. |
|
|
2209
|
+
| `--uf-spinner-indicator-color` | Color of the moving arc. |
|
|
2210
|
+
|
|
1526
2211
|
## Switch
|
|
1527
2212
|
|
|
1528
2213
|
An on/off switch with its label as content. Use it for settings that apply
|
|
@@ -2006,3 +2691,4 @@ Tags: `<uf-tooltip>`. Import: `import '@unframed/core/tooltip';` (or `npx @unfra
|
|
|
2006
2691
|
| `--uf-tooltip-bg` | Background color. |
|
|
2007
2692
|
| `--uf-tooltip-color` | Text color. |
|
|
2008
2693
|
| `--uf-tooltip-max-width` | Maximum width. |
|
|
2694
|
+
| `--uf-tooltip-radius` | Corner radius. Square by default. |
|