@cscfi/csc-ui 4.0.0-alpha.2 → 4.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/csc-ui.js +10192 -7248
- package/dist/custom-elements.json +2278 -257
- package/dist/docs/c-alert/usage.md +24 -0
- package/dist/docs/c-autocomplete/usage.md +152 -0
- package/dist/docs/c-button-group/usage.md +14 -1
- package/dist/docs/c-checkbox/usage.md +53 -0
- package/dist/docs/c-main/usage.md +21 -1
- package/dist/docs/c-menu/usage.md +15 -0
- package/dist/docs/c-menu-item/usage.md +6 -0
- package/dist/docs/c-option-value/usage.md +1 -0
- package/dist/docs/c-popover/usage.md +33 -0
- package/dist/docs/c-progress-bar/usage.md +23 -0
- package/dist/docs/c-progress-circle/usage.md +25 -0
- package/dist/docs/c-radio/usage.md +45 -0
- package/dist/docs/c-radio-group/usage.md +67 -0
- package/dist/docs/c-select/usage.md +127 -0
- package/dist/docs/c-side-navigation/usage.md +21 -0
- package/dist/docs/c-spinner/usage.md +21 -0
- package/dist/docs/c-switch/usage.md +36 -0
- package/dist/docs/c-tab-buttons/usage.md +7 -0
- package/dist/docs/c-table/usage.md +14 -0
- package/dist/docs/c-toolbar/usage.md +17 -0
- package/dist/docs/c-tooltip/usage.md +30 -0
- package/dist/docs/c-tree-select/usage.md +156 -0
- package/dist/styles/css/tailwind-theme.css +32 -0
- package/dist/styles/css/tokens.css +707 -197
- package/dist/vscode.css-custom-data.json +286 -19
- package/dist/vscode.html-custom-data.json +334 -51
- package/dist/web-types.json +1200 -190
- package/dist-types/components/c-alert/CAlert.vue.d.ts +18 -4
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +118 -18
- package/dist-types/components/c-button/CButton.vue.d.ts +1 -1
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +1 -1
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +3 -3
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +6 -2
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +48 -5
- package/dist-types/components/c-icon/CIcon.vue.d.ts +1 -1
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +1 -1
- package/dist-types/components/c-input/CInput.vue.d.ts +6 -2
- package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +4 -2
- package/dist-types/components/c-main/CMain.vue.d.ts +9 -2
- package/dist-types/components/c-menu/CMenu.vue.d.ts +14 -4
- package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +30 -3
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +1 -1
- package/dist-types/components/c-pagination/CPagination.vue.d.ts +1 -1
- package/dist-types/components/c-popover/CPopover.vue.d.ts +43 -0
- package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +32 -0
- package/dist-types/components/c-radio/CRadio.vue.d.ts +7 -11
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +9 -47
- package/dist-types/components/c-select/CSelect.vue.d.ts +115 -24
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +1 -1
- package/dist-types/components/c-spinner/CSpinner.vue.d.ts +1 -1
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +1 -1
- package/dist-types/components/c-table/CTable.vue.d.ts +11 -1
- package/dist-types/components/c-table/injectTableStyles.d.ts +1 -0
- package/dist-types/components/c-tag/CTag.vue.d.ts +8 -1
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +15 -4
- package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +49 -0
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +261 -0
- package/dist-types/index.d.ts +14 -2
- package/dist-types/shared/FieldMessage.vue.d.ts +21 -0
- package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/appDefaults.d.ts +75 -0
- package/dist-types/shared/defineElement.d.ts +1 -0
- package/dist-types/shared/lightDismiss.d.ts +35 -0
- package/dist-types/shared/modalStack.d.ts +4 -3
- package/dist-types/shared/optionLabel.d.ts +18 -0
- package/dist-types/shared/pageLock.d.ts +26 -0
- package/dist-types/shared/peekCap.d.ts +35 -0
- package/dist-types/shared/popoverChain.d.ts +65 -0
- package/dist-types/shared/positionArea.d.ts +13 -0
- package/dist-types/shared/selectAll.d.ts +29 -0
- package/dist-types/shared/splitMatches.d.ts +18 -0
- package/dist-types/shared/useAnchoredPanel.d.ts +98 -0
- package/dist-types/shared/useDesignatedTrigger.d.ts +40 -0
- package/dist-types/shared/useHostStates.d.ts +25 -0
- package/dist-types/shared/useNarrowViewport.d.ts +19 -0
- package/dist-types/shared/useScrollStrip.d.ts +39 -0
- package/dist-types/shared/useStatusAnnouncer.d.ts +33 -0
- package/dist-types/shared/visualViewport.d.ts +51 -0
- package/dist-types/tag-name-map.d.ts +440 -51
- package/dist-types/theme/chart-data.d.ts +51 -0
- package/dist-types/theme/ramp.d.ts +38 -0
- package/dist-types/theme/themeMode.d.ts +51 -0
- package/dist-types/types.d.ts +13 -0
- package/package.json +19 -8
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
A persistent, in-flow status message: a tinted box whose type carries a status family's colours through the icon, heading and accent edge, while the body copy stays neutral.
|
|
2
|
+
|
|
3
|
+
Give the alert a `heading` with the prop for plain text; the `heading` slot overrides the prop when rich content (links, emphasis) is needed. The message goes in the default slot.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- Persistent status that belongs to the page or a section: a maintenance notice, a failed validation summary, a quota warning.
|
|
8
|
+
- Not for transient feedback on an action — use `c-toasts`, which overlays and dismisses itself; the alert stays in the layout until the consumer removes it.
|
|
9
|
+
|
|
10
|
+
## Types
|
|
11
|
+
|
|
12
|
+
The four status types (`error`, `info`, `success`, `warning`) carry their status family's colours and icon; `default` — equivalently, omitting the attribute — renders the brand-primary look. Severity is signalled by the icon, the heading's ink and the accent edge, never by colouring the body text.
|
|
13
|
+
|
|
14
|
+
## Dismissal
|
|
15
|
+
|
|
16
|
+
`dismissible` renders a dismiss button, but pressing it only emits the `dismiss` event — removing the alert from the page stays the consumer's job.
|
|
17
|
+
|
|
18
|
+
## Accessibility
|
|
19
|
+
|
|
20
|
+
The alert manages its own live-region role: `warning` and `error` interrupt (`role="alert"`), while the other types announce politely (`role="status"`). Content that is present at page load is not announced — live regions only announce changes.
|
|
21
|
+
|
|
22
|
+
## Customization
|
|
23
|
+
|
|
24
|
+
Structural styling via `::part(root)`, `::part(icon)`, `::part(content)`, `::part(heading)` and `::part(dismiss)`. Colours come from the status-family semantic tokens; override the tokens to re-theme.
|
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
A filterable value-selection component: a readonly value field that opens a popover panel with a search input above the matching options.
|
|
2
2
|
|
|
3
|
+
## Options
|
|
4
|
+
|
|
5
|
+
Options are slotted `c-option` elements or an `items` array of
|
|
6
|
+
`{ name, value }` entries. A slotted option's label — the text shown in the
|
|
7
|
+
closed field and in its tag, and the text the filter matches — is its `name`
|
|
8
|
+
attribute, else the text of a `c-option-value` inside it, else the option's
|
|
9
|
+
whole text. Wrap the label in `c-option-value` when an option carries more
|
|
10
|
+
than its label, such as a description; the rest of the option's markup still
|
|
11
|
+
renders in the row:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<c-option value="ts">
|
|
15
|
+
<c-option-value>TypeScript</c-option-value>
|
|
16
|
+
<small>JavaScript with static types</small>
|
|
17
|
+
</c-option>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The row shows a copy of the option's markup, re-created from its HTML inside
|
|
21
|
+
the panel. A component nested in an option — a `c-icon`, say — is therefore
|
|
22
|
+
configured through attributes, or props with an attribute form (strings,
|
|
23
|
+
numbers, booleans); object props and event listeners on option content do not
|
|
24
|
+
carry over. Page CSS does not reach the copy either: give the content a `part`
|
|
25
|
+
and style it through the field:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<c-option value="ts">
|
|
29
|
+
<div part="language">
|
|
30
|
+
<c-option-value>TypeScript</c-option-value>
|
|
31
|
+
<c-icon path="…"></c-icon>
|
|
32
|
+
</div>
|
|
33
|
+
</c-option>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
c-autocomplete::part(language) {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 0.5rem;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
While a query is typed, the runs of each option's label that equal it are
|
|
45
|
+
marked: inside the `c-option-value` of a slotted option, or in the plain
|
|
46
|
+
label of an `items` entry. A slotted option without the wrapper is rendered
|
|
47
|
+
exactly as authored and never marked. Every occurrence of the literal query
|
|
48
|
+
is marked, whatever the filter did — a fuzzy `filter`, or a `name` that
|
|
49
|
+
differs from the wrapper's text, can leave a row unmarked — and the wrapper's
|
|
50
|
+
content is treated as plain text while a query is active. The marks are the
|
|
51
|
+
`match` part:
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
c-autocomplete::part(match) {
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
3
59
|
## Filtering
|
|
4
60
|
|
|
5
61
|
By default the component filters its options itself: the query typed into the
|
|
@@ -26,3 +82,99 @@ label even when a later fetch no longer includes it: the label is remembered
|
|
|
26
82
|
when the option is committed, and a programmatically set value resolves its
|
|
27
83
|
label from the current options, or from the object's `name` when
|
|
28
84
|
`return-object` is used.
|
|
85
|
+
|
|
86
|
+
## Multiple selection
|
|
87
|
+
|
|
88
|
+
Set `multiple` to let the user pick several options. The value is then an
|
|
89
|
+
array of the picked options' values in the order they were picked (an array
|
|
90
|
+
of `{ name, value }` items with `return-object`), and `[]` when nothing is
|
|
91
|
+
picked. Arrays have no attribute form — bind `value` as a DOM property
|
|
92
|
+
(`v-model` or `:value="…"` in Vue; the React wrapper and property
|
|
93
|
+
assignment do this naturally). Picking an option toggles it and keeps the
|
|
94
|
+
panel open; the search input keeps its query after a pick, so several
|
|
95
|
+
matches can be picked in a row. `clearable` clears the whole selection.
|
|
96
|
+
|
|
97
|
+
Each picked option shows as a tag inside the field, and the field grows as
|
|
98
|
+
the tags wrap. A tag's close button removes that option; Backspace in the
|
|
99
|
+
closed field removes the last one. Set `max-tags` to show only that many
|
|
100
|
+
tags and fold the rest into a single "+N more" tag, or `max-tags="0"` to
|
|
101
|
+
show no tags at all — the field then reads "N selected". Assistive
|
|
102
|
+
technology always hears the full selection as the field's value. With
|
|
103
|
+
`external`, a pick's label is remembered when it is made, so a later fetch
|
|
104
|
+
that no longer lists it keeps its tag readable.
|
|
105
|
+
|
|
106
|
+
Set `select-all` to pin a select-all row at the top of the list. It acts on
|
|
107
|
+
the options currently listed — the matches while a query is typed, or the
|
|
108
|
+
`items` you supply with `external`: activating it selects every enabled one
|
|
109
|
+
of them, or unselects them all when they already are, and options outside
|
|
110
|
+
the list keep their state. Disabled options are left alone, and the row only
|
|
111
|
+
appears while there is something to select. Its label is `texts.selectAll`,
|
|
112
|
+
a function receiving the number of listed options.
|
|
113
|
+
|
|
114
|
+
The row checkboxes recolour like c-checkbox's (`::part(indicator)`,
|
|
115
|
+
`::part(mark)`), the select-all row is the `select-all` part, and the tags are
|
|
116
|
+
stylable through the `tags`, `tag` and `tag-root` parts:
|
|
117
|
+
|
|
118
|
+
```css
|
|
119
|
+
c-autocomplete::part(tag-root) {
|
|
120
|
+
background: var(--c-primary-subtle);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Texts
|
|
125
|
+
|
|
126
|
+
Every built-in string — the clear and toggle button labels, the search
|
|
127
|
+
input's placeholder and accessible label, the loading and no-results rows,
|
|
128
|
+
the select-all row's label, a tag's remove label, the overflow and count
|
|
129
|
+
texts — can be replaced for another language through the `texts` object,
|
|
130
|
+
merged over the English defaults. Count and label texts are functions, so the object must be bound
|
|
131
|
+
as a DOM property; the `placeholder` prop still wins over
|
|
132
|
+
`texts.searchPlaceholder` when both are set:
|
|
133
|
+
|
|
134
|
+
```vue
|
|
135
|
+
<c-autocomplete
|
|
136
|
+
:texts="{
|
|
137
|
+
noResults: 'Ei osumia',
|
|
138
|
+
remove: (label) => `Poista ${label}`,
|
|
139
|
+
}"
|
|
140
|
+
multiple
|
|
141
|
+
/>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
To translate every autocomplete at once, set `texts` app-wide with
|
|
145
|
+
`applyDefaults({ 'c-autocomplete': { texts } })` (Customization → App-wide
|
|
146
|
+
prop defaults); a per-instance `texts` still wins key by key.
|
|
147
|
+
|
|
148
|
+
## Scrolling
|
|
149
|
+
|
|
150
|
+
The panel shows `items-per-page` full rows (six by default) and then a
|
|
151
|
+
half-visible row instead of a scrollbar: the cut row is the cue that more
|
|
152
|
+
options follow, and the wheel, touch and arrow keys scroll as usual. Set
|
|
153
|
+
`items-per-page="0"` to let the list grow to the space the panel allows; it
|
|
154
|
+
still ends on a half row when it overflows. To bring the native scrollbar
|
|
155
|
+
back:
|
|
156
|
+
|
|
157
|
+
```css
|
|
158
|
+
c-autocomplete::part(list) {
|
|
159
|
+
scrollbar-width: auto;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Narrow viewports
|
|
164
|
+
|
|
165
|
+
On a viewport narrower than 760px the panel opens as a **fullscreen panel**
|
|
166
|
+
instead of anchoring under the field: a heading row with the field's `label` and
|
|
167
|
+
a close button, the search input beneath it, then the options filling the rest
|
|
168
|
+
of the screen. The panel keeps covering the screen and the rows above the
|
|
169
|
+
options stay in view while the on-screen keyboard is open; the close button and
|
|
170
|
+
Escape both return focus to the field; the page behind the panel is inert until
|
|
171
|
+
it closes, and the list has no half-row cut — the screen edge is the cue. The
|
|
172
|
+
threshold is the viewport's width, never the field's, so a narrow field on a
|
|
173
|
+
desktop keeps its anchored panel. The close button's label is the `closePanel`
|
|
174
|
+
text, and the row's parts are `heading-row`, `heading` and `close`:
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
c-autocomplete::part(heading-row) {
|
|
178
|
+
border-bottom-color: var(--c-primary);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
@@ -26,7 +26,7 @@ toggles it off (value `null`) unless `mandatory` is set.
|
|
|
26
26
|
|
|
27
27
|
With `multiple` the value is an array of the active buttons' values in DOM
|
|
28
28
|
order. Arrays have no attribute form — bind `value` as a DOM property
|
|
29
|
-
(`:value
|
|
29
|
+
(`:value="…"` in Vue; the React wrapper and property assignment do this
|
|
30
30
|
naturally).
|
|
31
31
|
|
|
32
32
|
In both modes every active button paints its own fill. The sliding
|
|
@@ -49,6 +49,19 @@ A group can be `mandatory` without being `required` (a view switcher that
|
|
|
49
49
|
always has a selection) or `required` without being `mandatory` (the user
|
|
50
50
|
must answer, but may retract while deciding).
|
|
51
51
|
|
|
52
|
+
## Placement
|
|
53
|
+
|
|
54
|
+
The track keeps an opaque fill under its labels and a hairline frame that
|
|
55
|
+
reads on any surface, so the group can sit on a card, a muted panel, or
|
|
56
|
+
directly on the page canvas with no extra styling.
|
|
57
|
+
|
|
58
|
+
The buttons are equal columns as wide as the longest label. Given room, the
|
|
59
|
+
group is one row — its natural width in a flex row, the full width of a
|
|
60
|
+
block container. Narrower than one row of its buttons, the group wraps them
|
|
61
|
+
onto further rows inside the same frame rather than letting them overflow.
|
|
62
|
+
Keep the labels short (see above): a group that wraps on a phone is fine, a
|
|
63
|
+
group that wraps on a laptop wants `c-select`.
|
|
64
|
+
|
|
52
65
|
## Accessibility
|
|
53
66
|
|
|
54
67
|
Setting `label` names the group for assistive technology (`role="group"` +
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
A form control for a single on/off choice: a native checkbox with a label,
|
|
2
|
+
an optional hint, and validation messaging.
|
|
3
|
+
|
|
4
|
+
Bind the state with a plain `v-model` (or the `checked` prop); `true-value` /
|
|
5
|
+
`false-value` map the checked state onto custom values. Set `indeterminate`
|
|
6
|
+
for the mixed "some but not all" state of a parent checkbox.
|
|
7
|
+
|
|
8
|
+
```html
|
|
9
|
+
<c-checkbox v-model="accepted" label="I accept the terms" />
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Set `hint` for a persistent helper line below the control; while `valid` is
|
|
13
|
+
`false`, `error-message` replaces it. `hide-details` removes the message area
|
|
14
|
+
entirely.
|
|
15
|
+
|
|
16
|
+
## When to use
|
|
17
|
+
|
|
18
|
+
- A single independent yes/no choice (consent, feature toggle in a form).
|
|
19
|
+
- A list where several options can be selected at once.
|
|
20
|
+
|
|
21
|
+
## When not to use
|
|
22
|
+
|
|
23
|
+
- Choosing exactly one of several options — use `c-radio-group`.
|
|
24
|
+
- Switching a setting that takes effect immediately — use `c-switch`.
|
|
25
|
+
|
|
26
|
+
## Customization
|
|
27
|
+
|
|
28
|
+
Restyle via CSS parts from your own stylesheet. The `indicator` part is the
|
|
29
|
+
checkbox box and `mark` is the check glyph inside it. The indicator's border,
|
|
30
|
+
its checked fill and its keyboard focus ring all draw with `currentColor`, so
|
|
31
|
+
one `color` recolours the three together; the host exposes the `checked` and
|
|
32
|
+
`indeterminate` custom states, so the box is also stylable per state:
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
/* Border, checked fill and focus ring follow `color`. */
|
|
36
|
+
c-checkbox::part(indicator) {
|
|
37
|
+
color: var(--my-green);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* The mark draws with currentColor too — recolour it via `color`. */
|
|
41
|
+
c-checkbox:state(checked)::part(mark) {
|
|
42
|
+
color: black;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Finer control still works per property and per state (the focus ring
|
|
46
|
+
keeps following `color`, not these). */
|
|
47
|
+
c-checkbox:not(:state(checked))::part(indicator) {
|
|
48
|
+
border-color: gray;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For app-wide recolouring prefer the design tokens (`--c-primary` seed) over
|
|
53
|
+
per-component rules.
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
The page shell of an application: it paints the page canvas and lays out the toolbar, the side navigation and the page in the dashboard layout. It is at least a viewport tall and grows with its content, so the document — not a component — is what scrolls.
|
|
2
|
+
|
|
3
|
+
## Dashboard layout
|
|
4
|
+
|
|
5
|
+
Slot the layout components as direct children and `c-main` places them: `c-toolbar` spans the top, `c-side-navigation` takes the left column and `c-page` fills the rest. The toolbar pins itself to the top of the viewport; `c-main` pins the desktop side navigation beneath it and moves its pin to the top edge when the toolbar is `static`. The drawer is sized to the pinned height: a short menu fills the column, a long one scrolls inside the drawer, and the side navigation's bottom slot stays at the bottom edge of the viewport — also while a banner or a static toolbar is still above the drawer. The 3.x `autoheight` host class is ignored here, and the mobile drawer is not touched.
|
|
6
|
+
|
|
7
|
+
## Banner
|
|
8
|
+
|
|
9
|
+
A full-width message strip above the toolbar — a service notice, an environment warning — goes in the `banner` slot. Slot a `c-alert` or your own markup; `c-main` only places it. The banner scrolls away with the page and the toolbar pins in its place. This is a message strip, not the ARIA `banner` landmark.
|
|
10
|
+
|
|
11
|
+
## Disabling the layout
|
|
12
|
+
|
|
13
|
+
`disable-layout` turns the grid into a plain column, still at least a viewport tall, for pages that arrange their own chrome. The banner slot renders first in the column.
|
|
14
|
+
|
|
15
|
+
## Scrolling
|
|
16
|
+
|
|
17
|
+
The document scrolls, so browser scroll restoration, anchors, find-in-page and mobile browser chrome all behave natively, and a modal inside `c-main` stops the page behind it. `c-page` has no fixed height and no scrollbar of its own; its `scroll-indicator` tracks the document. Set `html { scroll-behavior: smooth }` for smooth anchor scrolling.
|
|
18
|
+
|
|
19
|
+
## Customization
|
|
20
|
+
|
|
21
|
+
Structural styling via `::part(root)`. To show the layout inside a bounded box — a demo, a preview — give the part a height together with `min-height: 0` and `overflow-y: auto`, and set `--c-main-viewport-height` to the same height so the pinned side navigation is sized to the box instead of the viewport; the toolbar and side navigation then pin inside that box.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
A command menu: a transient panel of actions or navigation choices opened from a trigger (the WAI-ARIA menu-button pattern), authored declaratively with slotted `c-menu-item`, `c-menu-label` and `c-divider` elements. Activating an item fires a one-off `select` event and closes the menu; the menu holds no selected value — that is `c-select`'s job.
|
|
2
|
+
|
|
3
|
+
## Scrolling
|
|
4
|
+
|
|
5
|
+
A menu taller than the viewport allows scrolls without a scrollbar: the panel
|
|
6
|
+
ends on a half-visible item, which is the cue that more items follow, and the
|
|
7
|
+
wheel, touch and arrow keys scroll as usual. Submenu panels behave the same.
|
|
8
|
+
To bring the native scrollbar back:
|
|
9
|
+
|
|
10
|
+
```css
|
|
11
|
+
c-menu::part(list),
|
|
12
|
+
c-menu-item::part(submenu) {
|
|
13
|
+
scrollbar-width: auto;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The label region of a `c-option`: wraps the text that c-select and c-autocomplete use as the option's label — in the closed field, its tag and the autocomplete filter — so the option can carry a description or an icon beside its label, and the region in which c-autocomplete marks the runs equal to the query (`::part(match)`).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
A click-opened, non-modal surface anchored to its trigger, floating in the top layer; its content may be interactive.
|
|
2
|
+
|
|
3
|
+
Put the element that opens the popover in the `trigger` slot and the content in the default slot. An optional `heading` prop renders a heading and doubles as the panel's accessible name (it is not called `title` — a `title` attribute would trigger the browser's native tooltip). The popover is deliberately minimal: compose footers, actions, or a close button from existing components (e.g. `c-button`) inside the body.
|
|
4
|
+
|
|
5
|
+
## Designated trigger
|
|
6
|
+
|
|
7
|
+
When the opener cannot be slotted — a button living elsewhere in the layout — point the `trigger` prop at it instead: the ID of the element, or the element itself via property binding. The two routes are the same concept: the popover wires click-to-toggle onto the designated element, mirrors `aria-haspopup`/`aria-expanded`, returns focus to it on Escape, anchors the panel to it, and clicking it never counts as a light dismiss. Supplying both routes is a misuse: the prop wins, the slotted element gets no wiring, and a console warning flags it.
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
- Contextual, dismissable UI attached to a control: a small settings panel, a confirm-lite prompt, help content with links.
|
|
12
|
+
- Not for a plain text hint — use `c-tooltip`.
|
|
13
|
+
- Not for blocking flows the user must complete — the popover never traps focus or blocks the page; use `c-modal`.
|
|
14
|
+
|
|
15
|
+
## Dismissal
|
|
16
|
+
|
|
17
|
+
Clicking outside the popover or pressing Escape closes it. Escape returns focus to the trigger when focus was inside the panel; light dismiss leaves focus where the user clicked. Focus is not moved into the panel on open — Tab reaches the content naturally from the trigger.
|
|
18
|
+
|
|
19
|
+
## Nesting
|
|
20
|
+
|
|
21
|
+
Popovers nest: a control inside one popover's panel can open another. The open popovers form a popover chain — each nested in the previous one; opening a popover whose trigger is not inside the open one closes it first, so sibling popovers never coexist. Escape closes only the innermost popover, one press per layer; clicking outside closes every popover that does not contain the click (clicking in a parent panel closes just its child); closing a popover closes everything nested inside it. Nesting follows the trigger, not the markup — a popover opened from a designated trigger inside another popover's panel chains under it even though its host element lives elsewhere.
|
|
22
|
+
|
|
23
|
+
## Accessibility
|
|
24
|
+
|
|
25
|
+
The panel is a non-modal `role="dialog"` and needs an accessible name: the `heading` prop provides one, or set `aria-label` on the `c-popover` element (`aria-labelledby` cannot reference slotted content across the shadow boundary). The component warns in the console when it opens unnamed. `aria-haspopup="dialog"` and `aria-expanded` are mirrored onto the slotted trigger.
|
|
26
|
+
|
|
27
|
+
## Layering
|
|
28
|
+
|
|
29
|
+
The panel is a native popover in the top layer: it is never clipped by ancestor overflow and needs no z-index management, even when opened from inside a modal.
|
|
30
|
+
|
|
31
|
+
## Customization
|
|
32
|
+
|
|
33
|
+
Structural styling via `::part(trigger)`, `::part(panel)` and `::part(heading)`. Colours come from the overlay-surface semantic tokens (`--c-surface-overlay`, `--c-on-surface`); override the tokens to re-theme.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
A horizontal progress bar that fills a track to a known completion percentage, with an optional details line showing the value and a label.
|
|
2
|
+
|
|
3
|
+
Bind the completion percentage to `value` (0–100; out-of-range values are clamped for the fill). By default a details line renders below the bar — the percentage plus whatever the `label` prop supplies (e.g. "57 % Uploading files"). Hide it with `hide-details`, or place it beside the bar with `single-line`.
|
|
4
|
+
|
|
5
|
+
For work of unknown duration the `indeterminate` prop replaces the fill with a looping sweep and hides the details line.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- For progress whose completion percentage is known — uploads, batch jobs, multi-step processing — or, with `indeterminate`, for an unknown-duration wait that should still read as a full-width bar.
|
|
10
|
+
- When space is tight or each item in a set needs its own compact indicator, `c-progress-circle` is the circular determinate counterpart.
|
|
11
|
+
- For a plain inline activity indicator use `c-spinner`; to cover a whole region while it loads, use `c-loader`.
|
|
12
|
+
|
|
13
|
+
## Details line
|
|
14
|
+
|
|
15
|
+
The details line shows the raw `value` even when the fill clamps it, and a negative value renders the line in the error role — a hook for signalling a failed transfer while keeping the bar itself empty.
|
|
16
|
+
|
|
17
|
+
## Accessibility
|
|
18
|
+
|
|
19
|
+
The bar is a native `<progress>` element exposing `role="progressbar"` with `aria-valuenow` while determinate; in indeterminate mode no value is exposed. The host mirrors `aria-busy` (true while indeterminate) and a `title` tooltip with the current percentage.
|
|
20
|
+
|
|
21
|
+
## Customization
|
|
22
|
+
|
|
23
|
+
Restyle via the parts: `::part(root)` (the outer wrapper), `::part(bar)` (the visible track around the native `<progress>`), and `::part(details)` (the percentage/label line). Colours default to the primary fill on a muted surface track.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
A circular progress indicator that draws a known completion percentage as an arc around a track — the circular counterpart of `c-progress-bar`.
|
|
2
|
+
|
|
3
|
+
Bind the completion percentage to `value` (0–100; out-of-range values are clamped). The circle's diameter comes from `size` and the track thickness from `width` — both in pixels, both props rather than styles because the arc geometry is computed from them. The value arc draws at half the track's width, inset within it, mirroring `c-progress-bar`'s fill-inside-track anatomy.
|
|
4
|
+
|
|
5
|
+
Nothing renders in the center by default. To show the percentage (or an icon), slot it in yourself; at the default 32 px size, center text is rarely legible, so pair slotted text with a larger `size`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- For progress whose completion percentage is known — uploads, batch jobs, quota consumption.
|
|
10
|
+
- **Not for unknown-duration waiting**: `c-progress-circle` is determinate-only and has no indeterminate mode. Use `c-spinner` for pure activity indication, or `c-loader` to cover a whole region while it loads.
|
|
11
|
+
- When vertical space is tight or many items each need their own compact indicator; otherwise `c-progress-bar` with its built-in details line is usually the better default.
|
|
12
|
+
|
|
13
|
+
## Accessibility
|
|
14
|
+
|
|
15
|
+
The component exposes `role="progressbar"` with `aria-valuemin`/`aria-valuemax`/`aria-valuenow`, so assistive technology always gets the value even when the center is empty. Name the progressbar by setting `aria-label` on the element:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<c-progress-circle aria-label="Upload progress" value="72"></c-progress-circle>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Slotted center content is presentational to assistive technology (the value is announced from `aria-valuenow`), so duplicating the percentage as slotted text is fine.
|
|
22
|
+
|
|
23
|
+
## Customization
|
|
24
|
+
|
|
25
|
+
Restyle via the parts: `::part(track)` and `::part(bar)` accept any stroke colour (the defaults are the muted surface track and the primary arc), and `::part(content)` styles the centered slot wrapper. Keep stroke *width* on the `width` prop — the radius math depends on it.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
A single radio option inside a `c-radio-group`: a native radio input whose
|
|
2
|
+
default slot is its clickable, announced label.
|
|
3
|
+
|
|
4
|
+
Author one `c-radio` per option, with a unique `value` and the option's
|
|
5
|
+
label content in the default slot. Selection state belongs to the group —
|
|
6
|
+
a radio has no checked prop; set the group's `value` (or `v-model`)
|
|
7
|
+
instead.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<c-radio value="paid">Paid</c-radio>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Set `disabled` to exclude a single option while the rest of the group stays
|
|
14
|
+
operable.
|
|
15
|
+
|
|
16
|
+
## Events
|
|
17
|
+
|
|
18
|
+
Selecting a radio fires a `change` event carrying its `value`. The event
|
|
19
|
+
bubbles (composed) so it can be heard on the radio, on the surrounding
|
|
20
|
+
`c-radio-group`, or further up — with the radio as the event target.
|
|
21
|
+
|
|
22
|
+
## Standalone
|
|
23
|
+
|
|
24
|
+
Outside a group a radio still renders and operates — it can be selected but
|
|
25
|
+
never unselected, like a native radio without siblings. Grouping behavior
|
|
26
|
+
(exclusivity, arrow-key navigation, form value) requires the parent
|
|
27
|
+
`c-radio-group`.
|
|
28
|
+
|
|
29
|
+
## Customization
|
|
30
|
+
|
|
31
|
+
Restyle via CSS parts from your own stylesheet. The `indicator` part is the
|
|
32
|
+
radio ring; the selection dot is its `::after` pseudo-element and the keyboard
|
|
33
|
+
focus ring its `::before`. Ring, dot and focus ring all draw with
|
|
34
|
+
`currentColor`, so `color` recolours the whole indicator, focus ring included.
|
|
35
|
+
The host exposes the `checked` and `disabled` custom states (both also cover
|
|
36
|
+
group-driven selection and disabling):
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
c-radio:state(checked)::part(indicator) {
|
|
40
|
+
color: var(--my-green);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For app-wide recolouring prefer the design tokens (`--c-primary` seed) over
|
|
45
|
+
per-component rules.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
A radio group is a set of mutually exclusive choices where exactly one can
|
|
2
|
+
be selected, authored as slotted `c-radio` children. Give the group a
|
|
3
|
+
`label` so the choice it represents is named for every user, and a `hint`
|
|
4
|
+
describing how to answer.
|
|
5
|
+
|
|
6
|
+
## Authoring the options
|
|
7
|
+
|
|
8
|
+
Each option is a `<c-radio value="...">` whose default slot is its label —
|
|
9
|
+
keep the label text (or richer markup) inside the radio so it stays
|
|
10
|
+
clickable and is announced with the control:
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<c-radio-group label="Subscription plan" value="free">
|
|
14
|
+
<c-radio value="free">Free</c-radio>
|
|
15
|
+
<c-radio value="paid">Paid</c-radio>
|
|
16
|
+
</c-radio-group>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The radios may sit at any depth inside the default slot, so custom layouts
|
|
20
|
+
are plain markup — wrap each radio in whatever layout element the design
|
|
21
|
+
needs:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<c-radio-group label="Subscription plan" value="free">
|
|
25
|
+
<div class="card"><c-radio value="free">Free</c-radio></div>
|
|
26
|
+
<div class="card"><c-radio value="paid">Paid</c-radio></div>
|
|
27
|
+
</c-radio-group>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Text placed *next to* a radio instead of inside it renders, but is not
|
|
31
|
+
click-associated or announced — put the label content in the radio's slot.
|
|
32
|
+
|
|
33
|
+
## Value
|
|
34
|
+
|
|
35
|
+
The group's `value` is the selected radio's `value`, matched by strict
|
|
36
|
+
string equality; the group holds string values only. Selection is expressed
|
|
37
|
+
solely through the group — radios carry no checked state of their own.
|
|
38
|
+
Giving two radios the same `value` is a consumer error: every matching
|
|
39
|
+
radio will show as checked.
|
|
40
|
+
|
|
41
|
+
In Vue, bind with a plain `v-model`. The group also emits its radios'
|
|
42
|
+
bubbling `change` events onward, with the selected `c-radio` as the
|
|
43
|
+
event target.
|
|
44
|
+
|
|
45
|
+
## Label
|
|
46
|
+
|
|
47
|
+
The `label` prop names the group; when richer label content is needed, use
|
|
48
|
+
the `label` slot instead (the prop wins when both are set). The default
|
|
49
|
+
slot is exclusively the radios' home — loose text there is not treated as a
|
|
50
|
+
label.
|
|
51
|
+
|
|
52
|
+
## Validation
|
|
53
|
+
|
|
54
|
+
Validation is your job: set `valid` to `false` and supply an
|
|
55
|
+
`error-message` explaining why. While invalid without an `error-message`,
|
|
56
|
+
the `hint` keeps rendering as a hint. The message area reserves its height
|
|
57
|
+
(unless `hide-details`), so an error appearing at runtime doesn't shift the
|
|
58
|
+
layout.
|
|
59
|
+
|
|
60
|
+
## Accessibility
|
|
61
|
+
|
|
62
|
+
The group is announced as a `radiogroup` named by its label. Keyboard
|
|
63
|
+
behavior follows the native pattern: Tab moves into the group (onto the
|
|
64
|
+
checked radio, or the first enabled one) and out of it in one stop; the
|
|
65
|
+
arrow keys move between radios, selecting as they go, wrapping at the ends
|
|
66
|
+
and skipping disabled radios; Space selects the focused radio. Enter is
|
|
67
|
+
left to the surrounding form.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
A value-selection field: a readonly field that opens a listbox of options — slotted `c-option` elements or an `items` array — and holds the picked value, emitting the value events that back `v-model`.
|
|
2
|
+
|
|
3
|
+
## Options
|
|
4
|
+
|
|
5
|
+
Options are slotted `c-option` elements or an `items` array of
|
|
6
|
+
`{ name, value }` entries. A slotted option's label — the text shown in the
|
|
7
|
+
closed field and, in `multiple` mode, in its tag — is its `name` attribute,
|
|
8
|
+
else the text of a `c-option-value` inside it, else the option's whole text.
|
|
9
|
+
Wrap the label in `c-option-value` when an option carries more than its
|
|
10
|
+
label, such as a description; the rest of the option's markup still renders
|
|
11
|
+
in the list row.
|
|
12
|
+
|
|
13
|
+
The row shows a copy of the option's markup, re-created from its HTML inside
|
|
14
|
+
the list. A component nested in an option — a `c-icon`, say — is therefore
|
|
15
|
+
configured through attributes, or props with an attribute form (strings,
|
|
16
|
+
numbers, booleans); object props and event listeners on option content do not
|
|
17
|
+
carry over. Page CSS does not reach the copy either: give the content a `part`
|
|
18
|
+
and style it through the field, which forwards every `part` named inside its
|
|
19
|
+
options:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<c-option value="ts">
|
|
23
|
+
<div part="language">
|
|
24
|
+
<c-option-value>TypeScript</c-option-value>
|
|
25
|
+
<c-icon path="…"></c-icon>
|
|
26
|
+
</div>
|
|
27
|
+
</c-option>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
c-select::part(language) {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 0.5rem;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Multiple selection
|
|
39
|
+
|
|
40
|
+
Set `multiple` to let the user pick several options. The value is then an
|
|
41
|
+
array of the picked options' values in the order they were picked (an array
|
|
42
|
+
of `{ name, value }` items with `return-object`), and `[]` when nothing is
|
|
43
|
+
picked. Arrays have no attribute form — bind `value` as a DOM property
|
|
44
|
+
(`v-model` or `:value="…"` in Vue; the React wrapper and property
|
|
45
|
+
assignment do this naturally). Picking an option toggles it and keeps the
|
|
46
|
+
list open; `clearable` clears the whole selection. `option-as-selection`
|
|
47
|
+
has no effect in this mode.
|
|
48
|
+
|
|
49
|
+
Each picked option shows as a tag inside the field, and the field grows as
|
|
50
|
+
the tags wrap. A tag's close button removes that option; Backspace in the
|
|
51
|
+
closed field removes the last one. Set `max-tags` to show only that many
|
|
52
|
+
tags and fold the rest into a single "+N more" tag, or `max-tags="0"` to
|
|
53
|
+
show no tags at all — the field then reads "N selected". Assistive
|
|
54
|
+
technology always hears the full selection as the field's value.
|
|
55
|
+
|
|
56
|
+
Set `select-all` to pin a select-all row at the top of the list. Its checkbox
|
|
57
|
+
shows whether none, some or all enabled options are selected; activating it
|
|
58
|
+
selects every enabled option, or unselects them all when they already are.
|
|
59
|
+
Disabled options are left alone, and the row only appears while there is
|
|
60
|
+
something to select. Its label is `texts.selectAll`, a function receiving the
|
|
61
|
+
number of listed options.
|
|
62
|
+
|
|
63
|
+
The row checkboxes recolour like c-checkbox's (`::part(indicator)`,
|
|
64
|
+
`::part(mark)`), the select-all row is the `select-all` part, and the tags are
|
|
65
|
+
stylable through the `tags`, `tag` and `tag-root` parts:
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
c-select::part(tag-root) {
|
|
69
|
+
background: var(--c-primary-subtle);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Texts
|
|
74
|
+
|
|
75
|
+
Every built-in string — the clear and toggle button labels, a tag's remove
|
|
76
|
+
label, the overflow and count texts, the select-all row's label — can be
|
|
77
|
+
replaced for another language
|
|
78
|
+
through the `texts` object, merged over the English defaults. Count and
|
|
79
|
+
label texts are functions, so the object must be bound as a DOM property:
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<c-select
|
|
83
|
+
:texts="{
|
|
84
|
+
more: (n) => `+${n} lisää`,
|
|
85
|
+
remove: (label) => `Poista ${label}`,
|
|
86
|
+
}"
|
|
87
|
+
multiple
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To translate every select at once, set `texts` app-wide with
|
|
92
|
+
`applyDefaults({ 'c-select': { texts } })` (Customization → App-wide prop
|
|
93
|
+
defaults); a per-instance `texts` still wins key by key.
|
|
94
|
+
|
|
95
|
+
## Scrolling
|
|
96
|
+
|
|
97
|
+
The list shows `items-per-page` full rows (six by default) and then a
|
|
98
|
+
half-visible row instead of a scrollbar: the cut row is the cue that more
|
|
99
|
+
options follow, and the wheel, touch and arrow keys scroll as usual. Set
|
|
100
|
+
`items-per-page="0"` to let the list grow to the space the viewport allows;
|
|
101
|
+
it still ends on a half row when it overflows. To bring the native scrollbar
|
|
102
|
+
back:
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
c-select::part(list) {
|
|
106
|
+
scrollbar-width: auto;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Narrow viewports
|
|
111
|
+
|
|
112
|
+
On a viewport narrower than 760px the panel opens as a **fullscreen panel**
|
|
113
|
+
instead of dropping under the field: a heading row with the field's `label` and
|
|
114
|
+
a close button, then the options filling the rest of the screen — the field
|
|
115
|
+
itself stays where it is in the page. The panel keeps covering the screen and
|
|
116
|
+
the heading row stays in view while the on-screen keyboard is open; the close button and
|
|
117
|
+
Escape both return focus to the field; the page behind the panel is inert until
|
|
118
|
+
it closes, and the list has no half-row cut — the screen edge is the cue. The
|
|
119
|
+
threshold is the viewport's width, never the field's, so a narrow field on a
|
|
120
|
+
desktop keeps its anchored panel. The close button's label is the `closePanel`
|
|
121
|
+
text, and the row's parts are `heading-row`, `heading` and `close`:
|
|
122
|
+
|
|
123
|
+
```css
|
|
124
|
+
c-select::part(heading-row) {
|
|
125
|
+
border-bottom-color: var(--c-primary);
|
|
126
|
+
}
|
|
127
|
+
```
|