@cscfi/csc-ui 4.0.0-alpha.9 → 4.0.0-rc.2

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.
Files changed (203) hide show
  1. package/README.md +36 -2
  2. package/dist/csc-ui.js +22771 -14908
  3. package/dist/custom-elements.json +8943 -5632
  4. package/dist/docs/c-accordion/usage.md +60 -0
  5. package/dist/docs/c-accordion-item/usage.md +1 -0
  6. package/dist/docs/c-alert/usage.md +5 -5
  7. package/dist/docs/c-autocomplete/usage.md +156 -0
  8. package/dist/docs/c-badge/usage.md +50 -0
  9. package/dist/docs/c-breadcrumb/usage.md +104 -0
  10. package/dist/docs/c-breadcrumb-item/usage.md +1 -0
  11. package/dist/docs/c-button/usage.md +13 -0
  12. package/dist/docs/c-button-group/usage.md +16 -2
  13. package/dist/docs/c-card/usage.md +55 -0
  14. package/dist/docs/c-card-actions/usage.md +1 -0
  15. package/dist/docs/c-card-content/usage.md +1 -0
  16. package/dist/docs/c-card-title/usage.md +3 -0
  17. package/dist/docs/c-checkbox/usage.md +37 -5
  18. package/dist/docs/c-color-picker/usage.md +160 -0
  19. package/dist/docs/c-csc-logo/usage.md +25 -0
  20. package/dist/docs/c-data-table/usage.md +180 -0
  21. package/dist/docs/c-date-picker/usage.md +224 -0
  22. package/dist/docs/c-divider/usage.md +36 -0
  23. package/dist/docs/c-file-upload/usage.md +189 -0
  24. package/dist/docs/c-icon/usage.md +51 -0
  25. package/dist/docs/c-icon-button/usage.md +80 -0
  26. package/dist/docs/c-link/usage.md +45 -1
  27. package/dist/docs/c-list/usage.md +50 -0
  28. package/dist/docs/c-list-item/usage.md +1 -0
  29. package/dist/docs/c-list-item-title/usage.md +1 -0
  30. package/dist/docs/c-loader/usage.md +52 -1
  31. package/dist/docs/c-login-button/usage.md +1 -0
  32. package/dist/docs/c-login-buttons/usage.md +48 -0
  33. package/dist/docs/c-login-card/usage.md +45 -0
  34. package/dist/docs/c-login-card-actions/usage.md +1 -0
  35. package/dist/docs/c-login-card-content/usage.md +1 -0
  36. package/dist/docs/c-login-card-title/usage.md +3 -0
  37. package/dist/docs/c-main/usage.md +21 -1
  38. package/dist/docs/c-menu/usage.md +15 -0
  39. package/dist/docs/c-menu-item/usage.md +11 -0
  40. package/dist/docs/c-message/usage.md +56 -0
  41. package/dist/docs/c-modal/usage.md +18 -12
  42. package/dist/docs/c-navigation-button/usage.md +32 -0
  43. package/dist/docs/c-number-field/usage.md +114 -0
  44. package/dist/docs/c-option/usage.md +1 -0
  45. package/dist/docs/c-option-value/usage.md +1 -0
  46. package/dist/docs/c-otp-input/usage.md +95 -0
  47. package/dist/docs/c-page/usage.md +44 -0
  48. package/dist/docs/c-pagination/usage.md +69 -0
  49. package/dist/docs/c-popover/usage.md +1 -1
  50. package/dist/docs/c-progress-bar/usage.md +1 -1
  51. package/dist/docs/c-progress-circle/usage.md +1 -1
  52. package/dist/docs/c-radio/usage.md +9 -6
  53. package/dist/docs/c-radio-group/usage.md +5 -6
  54. package/dist/docs/c-select/usage.md +131 -0
  55. package/dist/docs/c-side-navigation/usage.md +70 -0
  56. package/dist/docs/c-side-navigation-item/usage.md +1 -0
  57. package/dist/docs/c-side-navigation-title/usage.md +1 -0
  58. package/dist/docs/c-slider/usage.md +78 -0
  59. package/dist/docs/c-spinner/usage.md +1 -1
  60. package/dist/docs/c-status/usage.md +46 -0
  61. package/dist/docs/c-step/usage.md +1 -0
  62. package/dist/docs/c-steps/usage.md +35 -0
  63. package/dist/docs/c-sub-navigation-item/usage.md +1 -0
  64. package/dist/docs/c-switch/usage.md +10 -3
  65. package/dist/docs/c-tab/usage.md +1 -0
  66. package/dist/docs/c-tab-buttons/usage.md +15 -0
  67. package/dist/docs/c-tab-item/usage.md +1 -0
  68. package/dist/docs/c-tab-items/usage.md +1 -0
  69. package/dist/docs/c-table/usage.md +1 -1
  70. package/dist/docs/c-tabs/usage.md +77 -0
  71. package/dist/docs/c-tag/usage.md +1 -0
  72. package/dist/docs/c-tags/usage.md +85 -0
  73. package/dist/docs/c-text-field/usage.md +109 -0
  74. package/dist/docs/c-time-picker/usage.md +170 -0
  75. package/dist/docs/c-toasts/usage.md +27 -3
  76. package/dist/docs/c-toolbar/usage.md +17 -0
  77. package/dist/docs/c-tree-select/usage.md +156 -0
  78. package/dist/floating-ui.dom-DvzxEaDJ.js +1292 -0
  79. package/dist/styles/css/tailwind-theme.css +2 -1
  80. package/dist/styles/css/tokens.css +609 -178
  81. package/dist/vscode.css-custom-data.json +556 -99
  82. package/dist/vscode.html-custom-data.json +1050 -480
  83. package/dist/web-types.json +3303 -1707
  84. package/dist-types/components/c-accordion/CAccordion.vue.d.ts +21 -25
  85. package/dist-types/components/c-accordion-item/CAccordionItem.vue.d.ts +13 -12
  86. package/dist-types/components/c-alert/CAlert.vue.d.ts +12 -17
  87. package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +124 -31
  88. package/dist-types/components/c-breadcrumb/CBreadcrumb.vue.d.ts +35 -0
  89. package/dist-types/components/c-breadcrumb/fit.d.ts +29 -0
  90. package/dist-types/components/c-breadcrumb-item/CBreadcrumbItem.vue.d.ts +31 -0
  91. package/dist-types/components/c-button/CButton.vue.d.ts +52 -63
  92. package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +16 -14
  93. package/dist-types/components/c-card/CCard.vue.d.ts +2 -3
  94. package/dist-types/components/c-card-actions/CCardActions.vue.d.ts +5 -7
  95. package/dist-types/components/c-card-title/CCardTitle.vue.d.ts +11 -1
  96. package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +33 -52
  97. package/dist-types/components/c-color-picker/CColorPicker.vue.d.ts +189 -0
  98. package/dist-types/components/c-color-picker/colors.d.ts +66 -0
  99. package/dist-types/components/c-csc-logo/CCscLogo.vue.d.ts +1 -3
  100. package/dist-types/components/c-data-table/CDataTable.vue.d.ts +75 -51
  101. package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +277 -0
  102. package/dist-types/components/c-date-picker/dates.d.ts +119 -0
  103. package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +51 -8
  104. package/dist-types/components/c-file-upload/CFileUpload.vue.d.ts +204 -0
  105. package/dist-types/components/c-file-upload/files.d.ts +99 -0
  106. package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +23 -36
  107. package/dist-types/components/c-input/CInput.vue.d.ts +21 -43
  108. package/dist-types/components/c-link/CLink.vue.d.ts +6 -14
  109. package/dist-types/components/c-list/CList.vue.d.ts +4 -6
  110. package/dist-types/components/c-list-item/CListItem.vue.d.ts +14 -19
  111. package/dist-types/components/c-list-item-title/CListItemTitle.vue.d.ts +3 -2
  112. package/dist-types/components/c-loader/CLoader.vue.d.ts +13 -29
  113. package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +9 -9
  114. package/dist-types/components/c-login-card/CLoginCard.vue.d.ts +11 -16
  115. package/dist-types/components/c-login-card-actions/CLoginCardActions.vue.d.ts +5 -7
  116. package/dist-types/components/c-login-card-title/CLoginCardTitle.vue.d.ts +11 -1
  117. package/dist-types/components/c-main/CMain.vue.d.ts +12 -5
  118. package/dist-types/components/c-menu/CMenu.vue.d.ts +17 -16
  119. package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +27 -35
  120. package/dist-types/components/c-message/CMessage.vue.d.ts +5 -15
  121. package/dist-types/components/c-modal/CModal.vue.d.ts +3 -3
  122. package/dist-types/components/c-navigation-button/CNavigationButton.vue.d.ts +20 -1
  123. package/dist-types/components/c-number-field/CNumberField.vue.d.ts +169 -0
  124. package/dist-types/components/c-number-field/numbers.d.ts +58 -0
  125. package/dist-types/components/c-option/COption.vue.d.ts +1 -1
  126. package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +16 -30
  127. package/dist-types/components/c-page/CPage.vue.d.ts +2 -3
  128. package/dist-types/components/c-pagination/CPagination.vue.d.ts +56 -26
  129. package/dist-types/components/c-popover/CPopover.vue.d.ts +11 -7
  130. package/dist-types/components/c-progress-bar/CProgressBar.vue.d.ts +10 -14
  131. package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +7 -7
  132. package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +11 -8
  133. package/dist-types/components/c-select/CSelect.vue.d.ts +119 -35
  134. package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +10 -18
  135. package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +22 -14
  136. package/dist-types/components/c-slider/CSlider.vue.d.ts +29 -73
  137. package/dist-types/components/c-spinner/CSpinner.vue.d.ts +4 -8
  138. package/dist-types/components/c-status/CStatus.vue.d.ts +8 -9
  139. package/dist-types/components/c-step/CStep.vue.d.ts +6 -4
  140. package/dist-types/components/c-steps/CSteps.vue.d.ts +3 -7
  141. package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +23 -17
  142. package/dist-types/components/c-switch/CSwitch.vue.d.ts +17 -30
  143. package/dist-types/components/c-tab/CTab.vue.d.ts +11 -28
  144. package/dist-types/components/c-tab-buttons/CTabButtons.vue.d.ts +11 -13
  145. package/dist-types/components/c-tab-item/CTabItem.vue.d.ts +4 -5
  146. package/dist-types/components/c-tab-items/CTabItems.vue.d.ts +5 -4
  147. package/dist-types/components/c-table/CTable.vue.d.ts +7 -7
  148. package/dist-types/components/c-tabs/CTabs.vue.d.ts +13 -20
  149. package/dist-types/components/c-tag/CTag.vue.d.ts +22 -21
  150. package/dist-types/components/c-tags/CTags.vue.d.ts +9 -10
  151. package/dist-types/components/c-text-field/CTextField.vue.d.ts +74 -77
  152. package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +205 -0
  153. package/dist-types/components/c-time-picker/times.d.ts +82 -0
  154. package/dist-types/components/c-toast/CToast.vue.d.ts +3 -4
  155. package/dist-types/components/c-toast/swipe.d.ts +40 -0
  156. package/dist-types/components/c-toasts/CToasts.vue.d.ts +14 -16
  157. package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
  158. package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +12 -8
  159. package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +257 -0
  160. package/dist-types/index.d.ts +41 -32
  161. package/dist-types/registry.d.ts +9 -0
  162. package/dist-types/shared/FieldMessage.vue.d.ts +8 -5
  163. package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
  164. package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
  165. package/dist-types/shared/TypedField.vue.d.ts +48 -0
  166. package/dist-types/shared/appDefaults.d.ts +75 -0
  167. package/dist-types/shared/defineElement.d.ts +1 -0
  168. package/dist-types/shared/inputMask.d.ts +106 -0
  169. package/dist-types/shared/lightDismiss.d.ts +35 -0
  170. package/dist-types/shared/modalStack.d.ts +4 -3
  171. package/dist-types/shared/navigationDrawer.d.ts +4 -0
  172. package/dist-types/shared/optionLabel.d.ts +18 -0
  173. package/dist-types/shared/pageLock.d.ts +26 -0
  174. package/dist-types/shared/peekCap.d.ts +35 -0
  175. package/dist-types/shared/popoverChain.d.ts +13 -10
  176. package/dist-types/shared/positionArea.d.ts +9 -4
  177. package/dist-types/shared/reducedMotion.d.ts +10 -0
  178. package/dist-types/shared/selectAll.d.ts +29 -0
  179. package/dist-types/shared/splitMatches.d.ts +18 -0
  180. package/dist-types/shared/useAnchoredPanel.d.ts +107 -0
  181. package/dist-types/shared/useControlAttrs.d.ts +8 -0
  182. package/dist-types/shared/useDesignatedTrigger.d.ts +5 -4
  183. package/dist-types/shared/useFallbackPosition.d.ts +71 -0
  184. package/dist-types/shared/useHostEmit.d.ts +38 -0
  185. package/dist-types/shared/useIdReferences.d.ts +39 -0
  186. package/dist-types/shared/useKeyboardModality.d.ts +7 -0
  187. package/dist-types/shared/useNarrowViewport.d.ts +19 -0
  188. package/dist-types/shared/useScrollStrip.d.ts +39 -0
  189. package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
  190. package/dist-types/shared/useTypedField.d.ts +108 -0
  191. package/dist-types/shared/valueEvents.d.ts +41 -0
  192. package/dist-types/shared/visualViewport.d.ts +51 -0
  193. package/dist-types/tag-name-map.d.ts +1572 -672
  194. package/dist-types/theme/applyTheme.d.ts +6 -6
  195. package/dist-types/theme/chart-data.d.ts +51 -0
  196. package/dist-types/theme/ramp.d.ts +38 -0
  197. package/dist-types/theme/themeMode.d.ts +51 -0
  198. package/dist-types/types.d.ts +7 -11
  199. package/package.json +32 -21
  200. package/dist/css-anchor-positioning-fn-RTxo68pt.js +0 -6447
  201. package/dist/docs/c-toast/usage.md +0 -1
  202. package/dist-types/shared/anchorPolyfill.d.ts +0 -24
  203. package/dist-types/shared/emitModelValue.d.ts +0 -37
@@ -0,0 +1,109 @@
1
+ A text field for a single line of text, or several lines under `rows`, with a label, a hint and an error message.
2
+
3
+ ## Value
4
+
5
+ The value is the text in the field as a string. Bind it with `v-model`, or
6
+ listen for `update:value`, which fires on every keystroke:
7
+
8
+ ```vue
9
+ <c-text-field v-model="name" label="Name" />
10
+ ```
11
+
12
+ `change` fires when the text is committed — Enter, or leaving the field after
13
+ an edit — so save or validate there rather than on every keystroke.
14
+
15
+ `type` maps to the native input type: `password` adds a toggle that reveals
16
+ the text, and `number` honours `min`, `max` and `step`. Setting `rows` above
17
+ `1` renders a textarea.
18
+
19
+ ## Input mask
20
+
21
+ `mask` makes the typed text follow a pattern, such as a phone number, a postal
22
+ code or an account number. In the pattern, `#` stands for a digit, `A` for a
23
+ letter and `*` for a letter or a digit; every other character is a literal the
24
+ field inserts itself, and `\` makes the next character a literal (`\#`).
25
+
26
+ ```vue
27
+ <c-text-field v-model="phone" label="Phone" mask="+358 ## ### ####" />
28
+ ```
29
+
30
+ | Token | Takes |
31
+ | ----- | ----------------- |
32
+ | `#` | A digit |
33
+ | `A` | A letter |
34
+ | `*` | A letter or digit |
35
+ | `\x` | `x` as a literal |
36
+ | `[…]` | Optional section |
37
+
38
+ Characters a token does not take are dropped as they are typed or pasted.
39
+ A literal appears only once the next character arrives, so typing `40` into
40
+ the mask above shows `+358 40`, an empty field stays empty, and Backspace
41
+ never gets stuck on a separator. Typing or pasting the literals yourself
42
+ works too: `+358401234567` fills the field the same way. A mask of digits
43
+ only brings up the numeric keyboard.
44
+
45
+ While the user types, a faint **mask guide** behind the text shows the rest
46
+ of the pattern — `+358 __ ___ ____` in an empty field, `_ ___ ____` once
47
+ `4` is typed — so it is clear what is still asked for. It is never part of
48
+ the value and screen readers do not announce it; describe the format in the
49
+ `hint` for them. It shows wherever a placeholder would: while the field is
50
+ focused or holds text, and always with `label-on-top` or without a `label`.
51
+ A `placeholder` replaces the guide — set one to write your own example
52
+ (`placeholder="+358 40 123 4567"`); the `mask-guide` part styles the guide.
53
+
54
+ ### Optional sections
55
+
56
+ A pattern may end in **optional sections** in square brackets for formats of
57
+ varying length. Every token inside may be left unfilled, one by one, and the
58
+ literals inside appear only when a character after them is typed:
59
+
60
+ ```vue
61
+ <!-- 5 to 12 digits after the country code -->
62
+ <c-text-field v-model="phone" label="Phone" mask="+358 #####[#######]" />
63
+
64
+ <!-- A ZIP code with an optional -#### -->
65
+ <c-text-field v-model="zip" label="ZIP code" mask="#####[-####]" />
66
+ ```
67
+
68
+ The field is complete once every token outside the sections is filled, and
69
+ the guide draws only those: `+358 _____` in the empty phone field, nothing
70
+ once five digits are in. A section may stop part-way (`12345-67` is complete),
71
+ so check the length of `unmaskedValue` where an all-or-nothing part matters.
72
+
73
+ Sections come last — after the first one only further sections may follow
74
+ (`## ###[ ####][###]`) — and do not nest. A mask that breaks these rules is
75
+ ignored with a console warning, and the field takes any text. Write `\[` and
76
+ `\]` for literal brackets.
77
+
78
+ A phone mask with fixed groups fits only some numbers: Finnish numbers group
79
+ differently by area code (`+358 9 …`, `+358 40 …`), so an ungrouped run
80
+ like `+358 #####[#######]` suits them all.
81
+
82
+ The value is the text as shown, literals included — `'+358 40 123 4567'`.
83
+ The read-only `unmaskedValue` property holds only the characters that fill
84
+ the tokens (`'401234567'`). Give the field masked values: a value set from
85
+ code is shown through the mask, but the field does not rewrite or emit it.
86
+
87
+ Text that leaves some token unfilled is kept as typed. The read-only
88
+ `maskComplete` property tells whether every token is filled, and a field
89
+ holding such partial text exposes the `incomplete` custom state. The field
90
+ shows no error of its own; whether an incomplete value is an error is the
91
+ consumer's validation:
92
+
93
+ ```vue
94
+ <c-text-field
95
+ v-model="phone"
96
+ :error-message="error"
97
+ :invalid="!!error"
98
+ label="Phone"
99
+ mask="+358 ## ### ####"
100
+ @change="
101
+ error = $event.target.matches(':state(incomplete)')
102
+ ? 'Enter the whole number'
103
+ : ''
104
+ "
105
+ />
106
+ ```
107
+
108
+ A mask applies to a single-line field of type `text`, `tel` or `search`;
109
+ other types (and a textarea) ignore it.
@@ -0,0 +1,170 @@
1
+ A time field that takes a typed time, or opens hour and minute columns for picking one, or a start and end time under `range`.
2
+
3
+ ## Value
4
+
5
+ The value is a time of day as an ISO `HH:mm` string on a 24-hour clock —
6
+ `'14:05'` — or `null` when the field is empty. It carries no seconds, no date
7
+ and no timezone, and whatever the displayed `format` it keeps this one shape:
8
+ a field showing `14.05` or `2:05 PM` holds `'14:05'`. Bind it with `v-model`,
9
+ or listen for `change`:
10
+
11
+ ```vue
12
+ <c-time-picker v-model="time" label="Start time" />
13
+ ```
14
+
15
+ Under `range` the value becomes `{ start, end }`. Either end may be `null`
16
+ while only one is set — `{ start: '09:00', end: null }` — and a range with
17
+ neither end is `null`.
18
+
19
+ ## Typing
20
+
21
+ The field is typeable first: clicking into it or focusing it never opens the
22
+ columns. Text is read when the user presses Enter or leaves the input, never
23
+ per keystroke. The `format` prop sets how times are shown and read — a pattern
24
+ of the tokens `H` or `HH` (a 24-hour hour), `h` or `hh` (a 12-hour hour, which
25
+ needs the period `a`) and `mm`, with any separators. The default is `HH.mm`;
26
+ `HH:mm` and `h:mm a` are common alternatives. The format is an app default, so
27
+ an app can set it once with `applyDefaults({ 'c-time-picker': { format: 'HH:mm' } })`.
28
+
29
+ Typing follows the format as it goes: the separator appears on its own (`930`
30
+ shows `9.30`), an hour closes early when its first digit can start no
31
+ two-digit hour, any of `.`, `:` or a space typed in place of the separator
32
+ shows as the format's own, and in a 12-hour format a typed `a` or `p` fills in
33
+ the whole AM or PM text. Reading is lenient:
34
+
35
+ | Typed | Reads as |
36
+ | ------- | -------------------------------------------- |
37
+ | `9` | `09:00` — a bare hour is on the hour |
38
+ | `930` | `09:30` — three or four digits split |
39
+ | `9.3` | `09:03` — one minute digit is that minute |
40
+ | `2 pm` | `14:00` — a period makes the hour 12-hour |
41
+ | `14.00` | `14:00`, also in a 12-hour field (`2:00 PM`) |
42
+
43
+ In a 12-hour field an hour typed without a period reads as AM.
44
+
45
+ Text that names no time that can be picked — `25.00`, a time outside `min`
46
+ and `max` — is **bad input**: the text stays as the user typed it, the value
47
+ becomes `null`, and the host exposes the `bad-input` custom state and a
48
+ read-only `badInput` property. The component never shows an error of its own;
49
+ deciding whether bad input is an error, and saying so, is the consumer's
50
+ validation:
51
+
52
+ ```vue
53
+ <c-time-picker
54
+ v-model="time"
55
+ :error-message="error"
56
+ :invalid="!!error"
57
+ label="Start time"
58
+ @change:text="error = $event.target.badInput ? 'Enter a time as hh.mm' : ''"
59
+ />
60
+ ```
61
+
62
+ Every commit of typed text fires `change:text` with the text as typed
63
+ (`{ start, end }` under `range`), whether or not it changed the value.
64
+
65
+ ## The columns
66
+
67
+ The clock button at the field's trailing edge, or Alt+ArrowDown in the input,
68
+ opens the columns: hours and minutes side by side, and an AM/PM column in a
69
+ 12-hour format. The panel is a dialog: focus moves onto the hour column —
70
+ the value's hour, or the current hour when the field is empty — and Tab
71
+ cycles through the columns and the Now button (`show-now`) until the panel
72
+ closes.
73
+
74
+ Every pick commits at once and the panel stays open, so the hour can be fixed
75
+ after the minutes are picked (on a narrow viewport picks wait for a Done
76
+ button instead; see [Narrow viewports](#narrow-viewports)). The selected row rests at the top of its column:
77
+ it opens there and returns there after each pick, and so does a minute a pick
78
+ fills in. Scrolling a column only looks; it never picks. Picking into an empty field fills in the rest:
79
+ minute `00`, and the hour the hour column rests on. Moving in a column is
80
+ picking — each arrow key press commits, so a `change` handler doing network
81
+ work should debounce.
82
+
83
+ | Key | In a column |
84
+ | ------------------- | ------------------------------------------ |
85
+ | ArrowUp / ArrowDown | Previous / next row |
86
+ | Home / End | First / last row |
87
+ | PageUp / PageDown | Five rows up / down |
88
+ | Space | Pick the focused row |
89
+ | Enter | Pick the focused row and close |
90
+ | Escape | Close; what was picked stays |
91
+ | Tab | Next column (the end switch under `range`) |
92
+
93
+ Focus returns to the input when the panel closes.
94
+
95
+ ## Minute step
96
+
97
+ `minute-step` spaces the minute column's rows: `15` lists `00`, `15`, `30`
98
+ and `45`. It only shapes the column — a typed `14.07` commits as `14:07` and
99
+ shows as an extra row between `00` and `15`. Require a step with your own
100
+ validation if it matters.
101
+
102
+ ## Min and max
103
+
104
+ `min` and `max` are ISO `HH:mm` times. Rows outside them are disabled — an
105
+ hour only when none of its minutes fit — and a typed time outside them is bad
106
+ input. A pick never leaves them: picking hour 9 at `10:15` with `min="09:30"`
107
+ commits `09:30`. A `min` later than `max` is not a range across midnight; it
108
+ is ignored with a console warning.
109
+
110
+ ## Ranges
111
+
112
+ With `range` the field holds two inputs, the start and the end, in one field
113
+ box, and the panel shows a Start | End switch above the columns. It opens on
114
+ the end last typed in; each end commits on its own as it is picked.
115
+
116
+ An end earlier than the start is an **overnight range** — `22:00` to `06:00`
117
+ spans midnight — and is kept as it is, never swapped or flagged. Where a range
118
+ must stay within one day, check it in your validation; ISO times compare
119
+ correctly as strings:
120
+
121
+ ```ts
122
+ const sameDay =
123
+ !value || !value.start || !value.end || value.start <= value.end;
124
+ ```
125
+
126
+ ## Now
127
+
128
+ `show-now` adds a Now button under the columns. Pressing it commits the
129
+ current time and closes the panel, unlike a pick in the columns, which leaves
130
+ it open. The time is the exact minute whatever `minute-step`: at 14:07 with a
131
+ step of 15 it commits `14:07`. Under `range` it sets the end the Start | End
132
+ switch shows.
133
+
134
+ ```vue
135
+ <c-time-picker v-model="arrival" label="Arrival" show-now />
136
+ ```
137
+
138
+ The button is disabled, never hidden, while the current time is outside
139
+ `min` and `max`. Turn it on app-wide with
140
+ `applyDefaults({ 'c-time-picker': { showNow: true } })`.
141
+
142
+ ## Texts
143
+
144
+ The AM and PM texts come from `texts` when given, then from the browser's
145
+ `Intl` data for the page's `lang`, then from the English built-ins — so a page
146
+ with `<html lang="fi">` shows `ap.` and `ip.` without any configuration. The
147
+ button, column and range labels are English unless `texts` replaces them. Set
148
+ them app-wide with `applyDefaults({ 'c-time-picker': { texts } })`.
149
+
150
+ ## Narrow viewports
151
+
152
+ On a viewport narrower than 760px the columns open as a **fullscreen panel**:
153
+ a heading row with the field's `label` and a close button above the columns.
154
+ There the selected row rests in the middle of its column instead of the top,
155
+ in every column, so the selections line up even when a column fits.
156
+
157
+ The fullscreen panel ends in a Done button, and there picks wait in the
158
+ panel instead of committing: nothing is emitted until Done commits the time
159
+ — under `range` both ends at once — and closes the panel. The close button
160
+ and Escape close the panel without a change, discarding what was picked, and
161
+ so does the window growing past 760px while it is open. The Now button moves
162
+ the columns to the current time the same way, and Enter picks the focused
163
+ row and presses Done at once. Pressing Done before picking anything closes
164
+ the panel and changes nothing. The field stays typeable at every width.
165
+
166
+ ## Related
167
+
168
+ `c-date-picker` is the same field for calendar dates. `c-text-field
169
+ type="time"` remains the browser's own time input — no columns, the browser's
170
+ format, and no ranges.
@@ -1,6 +1,8 @@
1
1
  Toasts are passive, transient notifications — operation results, background
2
2
  progress — stacked and managed by a single `c-toasts` container via its
3
- `addToast` / `removeToast` methods.
3
+ `addToast` / `removeToast` methods. `addToast` returns the message's `id` (its
4
+ own, or a generated one), which `removeToast` takes; `close` fires on the
5
+ container with the message once a toast has left.
4
6
 
5
7
  ## When to use
6
8
 
@@ -10,7 +12,18 @@ progress — stacked and managed by a single `c-toasts` container via its
10
12
  ## When not to use
11
13
 
12
14
  - Anything requiring a decision before continuing — use `c-modal`.
13
- - Persistent page-level status — use `c-alert` or `c-message`.
15
+ - Persistent page-level status — use `c-alert`. A field's hint or error message belongs to the field (`c-message` under a control of your own).
16
+
17
+ ## Closing
18
+
19
+ A toast with a close button can also be swiped away: drag it left or right
20
+ and let go past a third of its width, or flick it. A shorter drag springs back,
21
+ and a vertical drag scrolls the page as usual. Custom and indeterminate toasts
22
+ have no close button and can't be swiped.
23
+
24
+ A timed toast waits while the pointer hovers over it or presses it, and
25
+ carries on with the time it had left. When a toast arrives or leaves, the
26
+ others glide to their new places.
14
27
 
15
28
  ## Placement and modals
16
29
 
@@ -27,4 +40,15 @@ so it does **not** carry the above-modal guarantee.
27
40
 
28
41
  Each toast is a `role="alert"` live region announced assertively when it
29
42
  appears. Keep messages short; use `persistent` for messages the user must
30
- dismiss themselves.
43
+ close themselves.
44
+
45
+ Swiping is a shortcut, never the only way: every swipeable toast has its
46
+ close button. On a touch screen, pressing and holding a toast keeps it up
47
+ for as long as the user needs to read it.
48
+
49
+ ## Styling
50
+
51
+ Each toast's parts are forwarded from the container as `toast-*`:
52
+ `c-toasts::part(toast-root)` is a toast's box, and `toast-item`,
53
+ `toast-badge`, `toast-content`, `toast-close`, `toast-custom` and
54
+ `toast-progress` its pieces.
@@ -0,0 +1,17 @@
1
+ The app-wide bar at the top of the dashboard layout: the logo, the service name and global actions such as the user menu or log out. It is pinned to the top of the viewport by default and stays there while the page scrolls; `static` keeps it in the page flow so it scrolls away with the content.
2
+
3
+ ## Pinned or static
4
+
5
+ Pinned is the default: the bar sticks to the top edge of its scroll container — the document in the dashboard layout — as soon as the page scrolls past it. Set `static` to leave the bar in flow instead; it then scrolls away with the page and returns when the user scrolls back to the top. The 3.x `class="relative"` switch is gone; `static` replaces it.
6
+
7
+ ## Inside c-main
8
+
9
+ In `c-main`'s dashboard layout the toolbar spans both columns above the side navigation and the page, below an optional banner. `c-main` follows the toolbar's mode: the desktop side navigation is pinned beneath a pinned toolbar, or to the top edge once a static toolbar has scrolled away. No extra markup is needed.
10
+
11
+ ## Content
12
+
13
+ The bar is a horizontal flex row with a small gap. Push trailing actions to the right with `margin-inline-start: auto` on the first of them.
14
+
15
+ ## Customization
16
+
17
+ Structural styling via `::part(root)`. The height is the library's layout value shared with `c-main`, so changing it on the part does not move the pinned side navigation.
@@ -0,0 +1,156 @@
1
+ A hierarchical value-selection component: a readonly value field that opens a panel for browsing a tree one level at a time, or searching it as a whole, to commit one item.
2
+
3
+ ## Items
4
+
5
+ The tree is the `items` property: an array of `{ value, name }` entries where
6
+ an entry with a non-empty `children` array is a branch and any other entry is
7
+ a leaf. Values must be unique across the whole tree. An optional `code` — a
8
+ classification number, say — is shown before the name in a muted column and
9
+ is matched by the search. Arrays have no attribute form, so bind `items` as a
10
+ DOM property (`:items="…"` in Vue; the React wrapper and property assignment
11
+ do this naturally):
12
+
13
+ ```ts
14
+ const items: CTreeSelectItem[] = [
15
+ {
16
+ value: '1',
17
+ code: '1',
18
+ name: 'Natural sciences',
19
+ children: [
20
+ {
21
+ value: '111',
22
+ code: '111',
23
+ name: 'Mathematics',
24
+ children: [{ value: '1111', code: '1111', name: 'Pure mathematics' }],
25
+ },
26
+ ],
27
+ },
28
+ ];
29
+ ```
30
+
31
+ A `disabled` branch cannot be entered and a `disabled` leaf cannot be
32
+ committed; both render as disabled rows, and the items below a disabled
33
+ branch are listed disabled in search results.
34
+
35
+ The value is the committed item's `value`, or `null` when nothing is
36
+ committed. With `return-object` the value is a fresh `{ value, name, code,
37
+ path }` object instead — `path` holds the item's ancestors root-first, each
38
+ as `{ value, name, code }` — never the `items` entry itself, and never its
39
+ children. The closed field shows the committed item's path on a muted line
40
+ above its code and name.
41
+
42
+ ## Browsing and searching
43
+
44
+ The panel lists one level at a time: the top-level items first, then the
45
+ children of whichever branch is picked, with a breadcrumb above the list —
46
+ the root crumb ("All") followed by one crumb per ancestor — for climbing
47
+ back. The header names the level being chosen: give `level-labels` an array
48
+ of names, top level first ("Main field", "Field", "Subfield"), and it reads
49
+ "Choose Field"; a level without a name reads "Choose Level 2". While the
50
+ tree is evenly deep — every leaf at the same level — the header also counts
51
+ the levels ("Step 2 of 3"); in an unevenly deep tree the counter is left out,
52
+ and a level made only of leaves says "Final level" instead. Reopening the
53
+ panel returns to the committed item's level with its row selected, so its
54
+ siblings are one click away.
55
+
56
+ Typing into the search input switches the panel to a flat list of matches
57
+ from the whole tree, each with its path on a second line. The query is
58
+ matched case-insensitively anywhere in the name or code of an item and of
59
+ every ancestor above it, so a query matching a branch lists all of its
60
+ leaves. Supply a `filter` predicate to change the matching — it receives the
61
+ item, the query and the item's ancestors, and lists the item when it returns
62
+ `true`. Because `filter` is a function, it must be bound as a DOM property.
63
+ Deleting the query, or the "Browse instead" control in the header, returns to
64
+ the level the user was browsing.
65
+
66
+ While a query is typed, the runs of each row's code, label and path that
67
+ equal it are marked. The marks are the `match` part, the path line the `path`
68
+ part and the code column the `code` part:
69
+
70
+ ```css
71
+ c-tree-select::part(match) {
72
+ font-weight: 600;
73
+ }
74
+ ```
75
+
76
+ From the keyboard, ArrowDown and ArrowUp move through the rows and Enter
77
+ activates one: a branch descends, a leaf commits. ArrowRight descends into a
78
+ highlighted branch and ArrowLeft — or Backspace with nothing left to delete —
79
+ climbs one level. Escape closes the panel and returns focus to the field; Tab
80
+ closes it and moves on.
81
+
82
+ ## Committing a branch
83
+
84
+ By default only a leaf can be committed; a branch always opens its children.
85
+ Set `allow-branch` to let a branch be the value as well: every level below
86
+ the root then starts with a pinned select-branch row ("Select Natural
87
+ sciences") that commits the branch the user is in, and branches matching a
88
+ query are listed as search results and commit directly. The pinned row is the
89
+ `select-branch` part.
90
+
91
+ ## Texts
92
+
93
+ Every built-in string — the root crumb, the header texts, a branch row's
94
+ child count, the select-branch row's label, the "Browse instead" control, the
95
+ no-results row, the search input's placeholder and accessible label, the
96
+ clear and toggle button labels — can be replaced for another language through
97
+ the `texts` object, merged over the English defaults. Interpolated texts are
98
+ functions, so the object must be bound as a DOM property; the `placeholder`
99
+ prop still wins over `texts.searchPlaceholder` when both are set:
100
+
101
+ ```vue
102
+ <c-tree-select
103
+ :texts="{
104
+ root: 'Kaikki',
105
+ choose: (level) => `Valitse ${level}`,
106
+ children: (count) => `${count} alakohtaa`,
107
+ }"
108
+ />
109
+ ```
110
+
111
+ To translate every tree select at once, set `texts` app-wide with
112
+ `applyDefaults({ 'c-tree-select': { texts } })` (Customization → App-wide
113
+ prop defaults); a per-instance `texts` still wins key by key.
114
+
115
+ ## Scrolling
116
+
117
+ The panel shows `items-per-page` full rows (six by default) and then a
118
+ half-visible row instead of a scrollbar: the cut row is the cue that more
119
+ items follow, and the wheel, touch and arrow keys scroll as usual. Set
120
+ `items-per-page="0"` to let the list grow to the space the panel allows; it
121
+ still ends on a half row when it overflows. To bring the native scrollbar
122
+ back:
123
+
124
+ ```css
125
+ c-tree-select::part(list) {
126
+ scrollbar-width: auto;
127
+ }
128
+ ```
129
+
130
+ ## Narrow viewports
131
+
132
+ On a viewport narrower than 760px the panel opens as a **fullscreen panel**
133
+ instead of anchoring under the field: a heading row with the field's `label` and
134
+ a close button, the search input beneath it, then the items filling the rest of
135
+ the screen. The panel keeps covering the screen and the rows above the items
136
+ stay in view while the on-screen keyboard is open; the close button and Escape
137
+ both return focus to the field; the page behind the panel is inert until it
138
+ closes, and the list has no half-row cut — the screen edge is the cue. The
139
+ threshold is the viewport's width, never the field's, so a narrow field on a
140
+ desktop keeps its anchored panel. The close button's label is the `closePanel`
141
+ text, and the row's parts are `heading-row`, `heading` and `close`:
142
+
143
+ ```css
144
+ c-tree-select::part(heading-row) {
145
+ border-bottom-color: var(--c-primary);
146
+ }
147
+ ```
148
+
149
+ ## Lazily loaded trees
150
+
151
+ The component walks the `items` you give it and has no loading state of its
152
+ own: there is no `external` mode and no per-branch fetch event yet. A tree
153
+ that arrives in pieces can still be shown by re-assigning `items` with the
154
+ fetched `children` filled in — the panel keeps its level and re-homes the
155
+ highlight when the tree changes. A branch must already list its children to
156
+ be enterable, so load at least one level ahead of the user.