@unframed/cli 0.8.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.
@@ -5,7 +5,7 @@ description: Builds UI with Unframed web components (@unframed/core, @unframed/r
5
5
 
6
6
  # Unframed UI
7
7
 
8
- Unframed 0.8.0: accessible UI components as standard custom elements (Lit). Every tag starts with `uf-`. They work in plain HTML and every framework; React, Vue and Angular have wrapper packages for typed props, events and form bindings.
8
+ Unframed 0.9.0: accessible UI components as standard custom elements (Lit). Every tag starts with `uf-`. They work in plain HTML and every framework; React, Vue and Angular have wrapper packages for typed props, events and form bindings.
9
9
 
10
10
  ## Before writing code
11
11
 
@@ -43,9 +43,11 @@ Unframed 0.8.0: accessible UI components as standard custom elements (Lit). Ever
43
43
  | Checkbox: Lets users turn an option on or off, or pick several options. | `<uf-checkbox>` `<uf-checkbox-group>` | `@unframed/core/checkbox` `@unframed/core/checkbox-group` |
44
44
  | Combobox: Lets users search a list and pick one option. | `<uf-combobox>` | `@unframed/core/combobox` |
45
45
  | Date picker: Lets users type or pick a date. | `<uf-date-picker>` `<uf-calendar>` | `@unframed/core/date-picker` `@unframed/core/calendar` |
46
+ | Date range picker: Lets users type or pick a start and an end date. | `<uf-date-range-picker>` `<uf-calendar>` | `@unframed/core/date-range-picker` `@unframed/core/calendar` |
46
47
  | Dialog: Shows content in a modal window on top of the page. | `<uf-dialog>` | `@unframed/core/dialog` |
47
48
  | Drawer: A panel that slides in from an edge of the screen. | `<uf-drawer>` | `@unframed/core/drawer` |
48
49
  | Dropdown menu: Opens a menu of actions from a button. | `<uf-dropdown>` `<uf-menu>` `<uf-menu-item>` | `@unframed/core/dropdown` `@unframed/core/menu` |
50
+ | File upload: Lets users choose files to upload. | `<uf-file-upload>` | `@unframed/core/file-upload` |
49
51
  | Icon: Shows a small symbol. | `<uf-icon>` | `@unframed/core/icon` |
50
52
  | Input: Lets users enter a single line of text. | `<uf-input>` | `@unframed/core/input` |
51
53
  | Pagination: Moves between the pages of a long list. | `<uf-pagination>` | `@unframed/core/pagination` |
@@ -1,4 +1,4 @@
1
- # Unframed 0.8.0 components
1
+ # Unframed 0.9.0 components
2
2
 
3
3
  ## Accordion
4
4
 
@@ -871,6 +871,9 @@ Type a date in the page language's format, or open the calendar. The value is al
871
871
  | `min` | | `string \| undefined` | | The earliest date that can be picked, as `YYYY-MM-DD`. |
872
872
  | `max` | | `string \| undefined` | | The latest date that can be picked, as `YYYY-MM-DD`. |
873
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. |
874
877
 
875
878
  #### Properties only
876
879
 
@@ -888,7 +891,7 @@ Type a date in the page language's format, or open the calendar. The value is al
888
891
 
889
892
  | Event | Type | Description |
890
893
  |---|---|---|
891
- | `change` | `Event` | The user picked a date. Read it from `value`. |
894
+ | `change` | `Event` | The user picked a date (read `value`), or, with `range`, completed a range (read `start` and `end`). |
892
895
 
893
896
  #### CSS parts
894
897
 
@@ -903,6 +906,188 @@ Type a date in the page language's format, or open the calendar. The value is al
903
906
  | `day` | Every day. |
904
907
  | `selected` | The selected day. |
905
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. |
906
1091
 
907
1092
  #### CSS custom properties
908
1093
 
@@ -1078,6 +1263,7 @@ A modal panel from the end edge. Escape, the close button and any element with `
1078
1263
  | Property | Description |
1079
1264
  |---|---|
1080
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. |
1081
1267
  | `--uf-dialog-bg` | Background of the drawer. |
1082
1268
  | `--uf-dialog-padding` | Padding of header, body and footer. |
1083
1269
  | `--uf-dialog-backdrop` | Backdrop color. |
@@ -1214,6 +1400,109 @@ Arrow keys move, typing a letter jumps to an item, Escape closes.
1214
1400
  | `checkmark` | The check shown for checked checkbox items. |
1215
1401
  | `label` | The label wrapper. |
1216
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
+
1217
1506
  ## Icon
1218
1507
 
1219
1508
  An icon from the built-in set, or one added with `registerIcons()`.
@@ -2402,3 +2691,4 @@ Tags: `<uf-tooltip>`. Import: `import '@unframed/core/tooltip';` (or `npx @unfra
2402
2691
  | `--uf-tooltip-bg` | Background color. |
2403
2692
  | `--uf-tooltip-color` | Text color. |
2404
2693
  | `--uf-tooltip-max-width` | Maximum width. |
2694
+ | `--uf-tooltip-radius` | Corner radius. Square by default. |
@@ -1,4 +1,4 @@
1
- # Using Unframed 0.8.0 in each framework
1
+ # Using Unframed 0.9.0 in each framework
2
2
 
3
3
  ## HTML & JavaScript
4
4
 
@@ -68,8 +68,8 @@ dialog.addEventListener('uf-hide', () => toast('Welcome aboard!', { variant: 'su
68
68
  <!doctype html>
69
69
  <html lang="en">
70
70
  <head>
71
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unframed/tokens@0.8/dist/tokens.css" />
72
- <script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@0.8/+esm"></script>
71
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unframed/tokens@0.9/dist/tokens.css" />
72
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@0.9/+esm"></script>
73
73
  </head>
74
74
  <body>
75
75
  <uf-button variant="primary">It works</uf-button>