@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.
- package/README.md +36 -2
- package/dist/csc-ui.js +22771 -14908
- package/dist/custom-elements.json +8943 -5632
- package/dist/docs/c-accordion/usage.md +60 -0
- package/dist/docs/c-accordion-item/usage.md +1 -0
- package/dist/docs/c-alert/usage.md +5 -5
- package/dist/docs/c-autocomplete/usage.md +156 -0
- package/dist/docs/c-badge/usage.md +50 -0
- package/dist/docs/c-breadcrumb/usage.md +104 -0
- package/dist/docs/c-breadcrumb-item/usage.md +1 -0
- package/dist/docs/c-button/usage.md +13 -0
- package/dist/docs/c-button-group/usage.md +16 -2
- package/dist/docs/c-card/usage.md +55 -0
- package/dist/docs/c-card-actions/usage.md +1 -0
- package/dist/docs/c-card-content/usage.md +1 -0
- package/dist/docs/c-card-title/usage.md +3 -0
- package/dist/docs/c-checkbox/usage.md +37 -5
- package/dist/docs/c-color-picker/usage.md +160 -0
- package/dist/docs/c-csc-logo/usage.md +25 -0
- package/dist/docs/c-data-table/usage.md +180 -0
- package/dist/docs/c-date-picker/usage.md +224 -0
- package/dist/docs/c-divider/usage.md +36 -0
- package/dist/docs/c-file-upload/usage.md +189 -0
- package/dist/docs/c-icon/usage.md +51 -0
- package/dist/docs/c-icon-button/usage.md +80 -0
- package/dist/docs/c-link/usage.md +45 -1
- package/dist/docs/c-list/usage.md +50 -0
- package/dist/docs/c-list-item/usage.md +1 -0
- package/dist/docs/c-list-item-title/usage.md +1 -0
- package/dist/docs/c-loader/usage.md +52 -1
- package/dist/docs/c-login-button/usage.md +1 -0
- package/dist/docs/c-login-buttons/usage.md +48 -0
- package/dist/docs/c-login-card/usage.md +45 -0
- package/dist/docs/c-login-card-actions/usage.md +1 -0
- package/dist/docs/c-login-card-content/usage.md +1 -0
- package/dist/docs/c-login-card-title/usage.md +3 -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 +11 -0
- package/dist/docs/c-message/usage.md +56 -0
- package/dist/docs/c-modal/usage.md +18 -12
- package/dist/docs/c-navigation-button/usage.md +32 -0
- package/dist/docs/c-number-field/usage.md +114 -0
- package/dist/docs/c-option/usage.md +1 -0
- package/dist/docs/c-option-value/usage.md +1 -0
- package/dist/docs/c-otp-input/usage.md +95 -0
- package/dist/docs/c-page/usage.md +44 -0
- package/dist/docs/c-pagination/usage.md +69 -0
- package/dist/docs/c-popover/usage.md +1 -1
- package/dist/docs/c-progress-bar/usage.md +1 -1
- package/dist/docs/c-progress-circle/usage.md +1 -1
- package/dist/docs/c-radio/usage.md +9 -6
- package/dist/docs/c-radio-group/usage.md +5 -6
- package/dist/docs/c-select/usage.md +131 -0
- package/dist/docs/c-side-navigation/usage.md +70 -0
- package/dist/docs/c-side-navigation-item/usage.md +1 -0
- package/dist/docs/c-side-navigation-title/usage.md +1 -0
- package/dist/docs/c-slider/usage.md +78 -0
- package/dist/docs/c-spinner/usage.md +1 -1
- package/dist/docs/c-status/usage.md +46 -0
- package/dist/docs/c-step/usage.md +1 -0
- package/dist/docs/c-steps/usage.md +35 -0
- package/dist/docs/c-sub-navigation-item/usage.md +1 -0
- package/dist/docs/c-switch/usage.md +10 -3
- package/dist/docs/c-tab/usage.md +1 -0
- package/dist/docs/c-tab-buttons/usage.md +15 -0
- package/dist/docs/c-tab-item/usage.md +1 -0
- package/dist/docs/c-tab-items/usage.md +1 -0
- package/dist/docs/c-table/usage.md +1 -1
- package/dist/docs/c-tabs/usage.md +77 -0
- package/dist/docs/c-tag/usage.md +1 -0
- package/dist/docs/c-tags/usage.md +85 -0
- package/dist/docs/c-text-field/usage.md +109 -0
- package/dist/docs/c-time-picker/usage.md +170 -0
- package/dist/docs/c-toasts/usage.md +27 -3
- package/dist/docs/c-toolbar/usage.md +17 -0
- package/dist/docs/c-tree-select/usage.md +156 -0
- package/dist/floating-ui.dom-DvzxEaDJ.js +1292 -0
- package/dist/styles/css/tailwind-theme.css +2 -1
- package/dist/styles/css/tokens.css +609 -178
- package/dist/vscode.css-custom-data.json +556 -99
- package/dist/vscode.html-custom-data.json +1050 -480
- package/dist/web-types.json +3303 -1707
- package/dist-types/components/c-accordion/CAccordion.vue.d.ts +21 -25
- package/dist-types/components/c-accordion-item/CAccordionItem.vue.d.ts +13 -12
- package/dist-types/components/c-alert/CAlert.vue.d.ts +12 -17
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +124 -31
- package/dist-types/components/c-breadcrumb/CBreadcrumb.vue.d.ts +35 -0
- package/dist-types/components/c-breadcrumb/fit.d.ts +29 -0
- package/dist-types/components/c-breadcrumb-item/CBreadcrumbItem.vue.d.ts +31 -0
- package/dist-types/components/c-button/CButton.vue.d.ts +52 -63
- package/dist-types/components/c-button-group/CButtonGroup.vue.d.ts +16 -14
- package/dist-types/components/c-card/CCard.vue.d.ts +2 -3
- package/dist-types/components/c-card-actions/CCardActions.vue.d.ts +5 -7
- package/dist-types/components/c-card-title/CCardTitle.vue.d.ts +11 -1
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +33 -52
- package/dist-types/components/c-color-picker/CColorPicker.vue.d.ts +189 -0
- package/dist-types/components/c-color-picker/colors.d.ts +66 -0
- package/dist-types/components/c-csc-logo/CCscLogo.vue.d.ts +1 -3
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +75 -51
- package/dist-types/components/c-date-picker/CDatePicker.vue.d.ts +277 -0
- package/dist-types/components/c-date-picker/dates.d.ts +119 -0
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +51 -8
- package/dist-types/components/c-file-upload/CFileUpload.vue.d.ts +204 -0
- package/dist-types/components/c-file-upload/files.d.ts +99 -0
- package/dist-types/components/c-icon-button/CIconButton.vue.d.ts +23 -36
- package/dist-types/components/c-input/CInput.vue.d.ts +21 -43
- package/dist-types/components/c-link/CLink.vue.d.ts +6 -14
- package/dist-types/components/c-list/CList.vue.d.ts +4 -6
- package/dist-types/components/c-list-item/CListItem.vue.d.ts +14 -19
- package/dist-types/components/c-list-item-title/CListItemTitle.vue.d.ts +3 -2
- package/dist-types/components/c-loader/CLoader.vue.d.ts +13 -29
- package/dist-types/components/c-login-button/CLoginButton.vue.d.ts +9 -9
- package/dist-types/components/c-login-card/CLoginCard.vue.d.ts +11 -16
- package/dist-types/components/c-login-card-actions/CLoginCardActions.vue.d.ts +5 -7
- package/dist-types/components/c-login-card-title/CLoginCardTitle.vue.d.ts +11 -1
- package/dist-types/components/c-main/CMain.vue.d.ts +12 -5
- package/dist-types/components/c-menu/CMenu.vue.d.ts +17 -16
- package/dist-types/components/c-menu-item/CMenuItem.vue.d.ts +27 -35
- package/dist-types/components/c-message/CMessage.vue.d.ts +5 -15
- package/dist-types/components/c-modal/CModal.vue.d.ts +3 -3
- package/dist-types/components/c-navigation-button/CNavigationButton.vue.d.ts +20 -1
- package/dist-types/components/c-number-field/CNumberField.vue.d.ts +169 -0
- package/dist-types/components/c-number-field/numbers.d.ts +58 -0
- package/dist-types/components/c-option/COption.vue.d.ts +1 -1
- package/dist-types/components/c-otp-input/COtpInput.vue.d.ts +16 -30
- package/dist-types/components/c-page/CPage.vue.d.ts +2 -3
- package/dist-types/components/c-pagination/CPagination.vue.d.ts +56 -26
- package/dist-types/components/c-popover/CPopover.vue.d.ts +11 -7
- package/dist-types/components/c-progress-bar/CProgressBar.vue.d.ts +10 -14
- package/dist-types/components/c-progress-circle/CProgressCircle.vue.d.ts +7 -7
- package/dist-types/components/c-radio-group/CRadioGroup.vue.d.ts +11 -8
- package/dist-types/components/c-select/CSelect.vue.d.ts +119 -35
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +10 -18
- package/dist-types/components/c-side-navigation-item/CSideNavigationItem.vue.d.ts +22 -14
- package/dist-types/components/c-slider/CSlider.vue.d.ts +29 -73
- package/dist-types/components/c-spinner/CSpinner.vue.d.ts +4 -8
- package/dist-types/components/c-status/CStatus.vue.d.ts +8 -9
- package/dist-types/components/c-step/CStep.vue.d.ts +6 -4
- package/dist-types/components/c-steps/CSteps.vue.d.ts +3 -7
- package/dist-types/components/c-sub-navigation-item/CSubNavigationItem.vue.d.ts +23 -17
- package/dist-types/components/c-switch/CSwitch.vue.d.ts +17 -30
- package/dist-types/components/c-tab/CTab.vue.d.ts +11 -28
- package/dist-types/components/c-tab-buttons/CTabButtons.vue.d.ts +11 -13
- package/dist-types/components/c-tab-item/CTabItem.vue.d.ts +4 -5
- package/dist-types/components/c-tab-items/CTabItems.vue.d.ts +5 -4
- package/dist-types/components/c-table/CTable.vue.d.ts +7 -7
- package/dist-types/components/c-tabs/CTabs.vue.d.ts +13 -20
- package/dist-types/components/c-tag/CTag.vue.d.ts +22 -21
- package/dist-types/components/c-tags/CTags.vue.d.ts +9 -10
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +74 -77
- package/dist-types/components/c-time-picker/CTimePicker.vue.d.ts +205 -0
- package/dist-types/components/c-time-picker/times.d.ts +82 -0
- package/dist-types/components/c-toast/CToast.vue.d.ts +3 -4
- package/dist-types/components/c-toast/swipe.d.ts +40 -0
- package/dist-types/components/c-toasts/CToasts.vue.d.ts +14 -16
- package/dist-types/components/c-toolbar/CToolbar.vue.d.ts +10 -1
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +12 -8
- package/dist-types/components/c-tree-select/CTreeSelect.vue.d.ts +257 -0
- package/dist-types/index.d.ts +41 -32
- package/dist-types/registry.d.ts +9 -0
- package/dist-types/shared/FieldMessage.vue.d.ts +8 -5
- package/dist-types/shared/PanelHeadingRow.vue.d.ts +13 -0
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/TypedField.vue.d.ts +48 -0
- package/dist-types/shared/appDefaults.d.ts +75 -0
- package/dist-types/shared/defineElement.d.ts +1 -0
- package/dist-types/shared/inputMask.d.ts +106 -0
- package/dist-types/shared/lightDismiss.d.ts +35 -0
- package/dist-types/shared/modalStack.d.ts +4 -3
- package/dist-types/shared/navigationDrawer.d.ts +4 -0
- 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 +13 -10
- package/dist-types/shared/positionArea.d.ts +9 -4
- package/dist-types/shared/reducedMotion.d.ts +10 -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 +107 -0
- package/dist-types/shared/useControlAttrs.d.ts +8 -0
- package/dist-types/shared/useDesignatedTrigger.d.ts +5 -4
- package/dist-types/shared/useFallbackPosition.d.ts +71 -0
- package/dist-types/shared/useHostEmit.d.ts +38 -0
- package/dist-types/shared/useIdReferences.d.ts +39 -0
- package/dist-types/shared/useKeyboardModality.d.ts +7 -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/useTypedField.d.ts +108 -0
- package/dist-types/shared/valueEvents.d.ts +41 -0
- package/dist-types/shared/visualViewport.d.ts +51 -0
- package/dist-types/tag-name-map.d.ts +1572 -672
- package/dist-types/theme/applyTheme.d.ts +6 -6
- 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 +7 -11
- package/package.json +32 -21
- package/dist/css-anchor-positioning-fn-RTxo68pt.js +0 -6447
- package/dist/docs/c-toast/usage.md +0 -1
- package/dist-types/shared/anchorPolyfill.d.ts +0 -24
- package/dist-types/shared/emitModelValue.d.ts +0 -37
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
A colour field that takes any typed CSS colour, or opens a panel for picking one: a colour area, hue and alpha sliders, per-channel inputs and swatches — or swatches alone under `swatches-only`.
|
|
2
|
+
|
|
3
|
+
## Value
|
|
4
|
+
|
|
5
|
+
The value is a CSS colour string in the field's notation — `'#1f6feb'` by
|
|
6
|
+
default — or `null` when the field is empty. Bind it with `v-model`, or listen
|
|
7
|
+
for `change`:
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<c-color-picker v-model="color" label="Colour" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Notation
|
|
14
|
+
|
|
15
|
+
`format` sets the notation the value is written in, and every emission with
|
|
16
|
+
it: `hex` (the default) gives `#1f6feb`, `rgb` gives `rgb(31 111 235)` and
|
|
17
|
+
`oklch` gives `oklch(0.5686 0.202 259.7)`. Whichever notation a colour arrives
|
|
18
|
+
in — typed, picked or set from outside — the field shows it, and the value
|
|
19
|
+
carries it, in this one. The notation is an app default, so an app can set it
|
|
20
|
+
once with `applyDefaults({ 'c-color-picker': { format: 'oklch' } })`.
|
|
21
|
+
|
|
22
|
+
Every colour the picker holds is an 8-bit sRGB colour — what `#rrggbb` can
|
|
23
|
+
write — and each notation spells it at the fewest decimals that read back to
|
|
24
|
+
the same colour. Switching `format` therefore never moves the colour, and an
|
|
25
|
+
`oklch()` typed with four decimals can come back with fewer.
|
|
26
|
+
|
|
27
|
+
The HEX | RGB | OKLCH switch inside the panel only chooses which channel
|
|
28
|
+
inputs show. It never changes the value or its notation.
|
|
29
|
+
|
|
30
|
+
## Typing
|
|
31
|
+
|
|
32
|
+
The field is typeable first: clicking into it or focusing it never opens the
|
|
33
|
+
panel. Text is read when the user presses Enter or leaves the input, never per
|
|
34
|
+
keystroke, and any CSS colour reads: `#fff`, `1f6feb` without its `#`, `red`,
|
|
35
|
+
`hsl(210 80% 50%)`, `rgba(31, 111, 235, 0.5)`, `color(display-p3 1 0 0)`.
|
|
36
|
+
The field then shows the colour in its notation.
|
|
37
|
+
|
|
38
|
+
A colour outside sRGB — `oklch(0.7 0.3 150)`, `rgb(300 0 0)` — is brought into
|
|
39
|
+
it as it is read, keeping its lightness and hue and lowering its chroma, the
|
|
40
|
+
way a browser paints it on an ordinary screen. It is not an error.
|
|
41
|
+
|
|
42
|
+
Text that names no colour — `blurple`, `var(--brand)` — is **bad input**: the
|
|
43
|
+
text stays as the user typed it, the value becomes `null`, and the host
|
|
44
|
+
exposes the `bad-input` custom state and a read-only `badInput` property. The
|
|
45
|
+
component never shows an error of its own; deciding whether bad input is an
|
|
46
|
+
error, and saying so, is the consumer's validation:
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<c-color-picker
|
|
50
|
+
v-model="color"
|
|
51
|
+
:error-message="error"
|
|
52
|
+
:invalid="!!error"
|
|
53
|
+
label="Colour"
|
|
54
|
+
@change:text="error = $event.target.badInput ? 'Enter a colour' : ''"
|
|
55
|
+
/>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Every commit of typed text fires `change:text` with the text as typed.
|
|
59
|
+
|
|
60
|
+
## Alpha
|
|
61
|
+
|
|
62
|
+
Colours are opaque unless `alpha` is set. With it the panel gains an alpha
|
|
63
|
+
slider and an A channel, and the value carries alpha whenever it is below 1:
|
|
64
|
+
`#1f6feb80`, `rgb(31 111 235 / 0.5)`. An opaque colour is written the same
|
|
65
|
+
with or without `alpha`. Without it, alpha in typed text is dropped.
|
|
66
|
+
|
|
67
|
+
## The panel
|
|
68
|
+
|
|
69
|
+
The colour button at the field's trailing edge — painted with the current
|
|
70
|
+
colour — or Alt+ArrowDown in the input opens the panel. It is a dialog: focus
|
|
71
|
+
moves onto the colour area, and Tab cycles through the area, the sliders, the
|
|
72
|
+
original colour, the notation switch, the channel inputs and the swatches until
|
|
73
|
+
the panel closes. Focus returns to the input when it does.
|
|
74
|
+
|
|
75
|
+
| Key | In the colour area |
|
|
76
|
+
| ---------------------- | -------------------------------------------------------------- |
|
|
77
|
+
| ArrowLeft / ArrowRight | Less / more saturation |
|
|
78
|
+
| ArrowUp / ArrowDown | More / less brightness |
|
|
79
|
+
| Shift + arrow | Ten steps |
|
|
80
|
+
| PageUp / PageDown | Ten steps of brightness |
|
|
81
|
+
| Home / End | No / full saturation |
|
|
82
|
+
| Enter | Close |
|
|
83
|
+
| Escape | Close; what was picked stays (the original colour restores it) |
|
|
84
|
+
|
|
85
|
+
A channel input commits on Enter or when it is left, clamped to its range;
|
|
86
|
+
text that is no number reverts. ArrowUp and ArrowDown nudge the channel by one
|
|
87
|
+
step, Shift by ten, and each nudge commits.
|
|
88
|
+
|
|
89
|
+
Every pick commits at once and the panel stays open, so a colour can be
|
|
90
|
+
tuned in several moves (on a narrow viewport picks wait for a Done button
|
|
91
|
+
instead; see [Narrow viewports](#narrow-viewports)). An empty field's panel
|
|
92
|
+
opens on the first swatch, or on white, without committing anything.
|
|
93
|
+
|
|
94
|
+
## Comparing with the original
|
|
95
|
+
|
|
96
|
+
When the panel opens on a colour, a strip under the sliders shows that
|
|
97
|
+
original colour on the left beside the colour being picked on the right, so
|
|
98
|
+
every change can be judged against where it started. Clicking the original —
|
|
99
|
+
or Enter or Space on it — restores it: in the anchored panel it commits like
|
|
100
|
+
any pick, and in the fullscreen panel it becomes the colour Done commits. An
|
|
101
|
+
empty field's panel has no comparison, and neither has a swatch-only panel.
|
|
102
|
+
|
|
103
|
+
## Drag events
|
|
104
|
+
|
|
105
|
+
A drag on the colour area or a slider updates the value as it moves: every
|
|
106
|
+
move fires `update:value` and `input`, so `v-model` follows the pointer, and
|
|
107
|
+
`change` fires once, when the pointer is released. Save on `change` to avoid
|
|
108
|
+
work on every move. A click, a key press, a channel entry and a swatch pick
|
|
109
|
+
fire all three at once.
|
|
110
|
+
|
|
111
|
+
## Swatches
|
|
112
|
+
|
|
113
|
+
`swatches` offers predefined colours under the picker. Each is a CSS colour,
|
|
114
|
+
or a `{ value, name }` object whose name is what assistive technology reads —
|
|
115
|
+
otherwise it reads the colour's spelling. Bind the array as a property:
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<c-color-picker
|
|
119
|
+
v-model="color"
|
|
120
|
+
:swatches="[
|
|
121
|
+
{ value: '#1f6feb', name: 'Ocean' },
|
|
122
|
+
{ value: '#e5534b', name: 'Coral' },
|
|
123
|
+
]"
|
|
124
|
+
label="Tag colour"
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The swatches are one Tab stop: the arrow keys move between them without
|
|
129
|
+
picking, and Enter, Space or a click picks. A swatch that names no colour is
|
|
130
|
+
skipped with a console warning.
|
|
131
|
+
|
|
132
|
+
## Swatches only
|
|
133
|
+
|
|
134
|
+
`swatches-only` limits the choice to the swatches. The field becomes readonly
|
|
135
|
+
and shows the picked swatch's colour and name; a click, Enter or Alt+ArrowDown
|
|
136
|
+
opens a panel of the swatches alone, and a pick commits and closes it, as in
|
|
137
|
+
`c-select`. Name every swatch in this mode — the name is what the field shows,
|
|
138
|
+
and a console warning says so when one is missing. A value set from outside
|
|
139
|
+
that matches no swatch is shown spelled in its notation.
|
|
140
|
+
|
|
141
|
+
## Texts
|
|
142
|
+
|
|
143
|
+
The panel's labels are English unless `texts` replaces them. Set them app-wide
|
|
144
|
+
with `applyDefaults({ 'c-color-picker': { texts } })`.
|
|
145
|
+
|
|
146
|
+
## Narrow viewports
|
|
147
|
+
|
|
148
|
+
On a viewport narrower than 760px the panel opens as a **fullscreen panel**: a
|
|
149
|
+
heading row with the field's `label` and a close button above the picker. The
|
|
150
|
+
panel ends in a Done button, and there picks wait in the panel instead of
|
|
151
|
+
committing: nothing is emitted until Done commits the colour and closes the
|
|
152
|
+
panel. The close button and Escape close the panel without a change, and so
|
|
153
|
+
does the window growing past 760px while it is open. Under `swatches-only`
|
|
154
|
+
there is no Done button: a pick commits and closes, as everywhere else.
|
|
155
|
+
|
|
156
|
+
## Related
|
|
157
|
+
|
|
158
|
+
`c-select` lists named choices of any kind; reach for it when the options are
|
|
159
|
+
not colours. The browser's own `<input type="color">` has no notation, alpha,
|
|
160
|
+
swatches or keyboard-operable panel.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
The CSC logo without its tagline, drawn as an inline SVG in the colours of the
|
|
2
|
+
current theme mode.
|
|
3
|
+
|
|
4
|
+
Set its width in pixels with `width` (60 by default); the height follows the
|
|
5
|
+
logo's proportions. It typically sits at the start of a `c-toolbar`.
|
|
6
|
+
|
|
7
|
+
## Theme modes
|
|
8
|
+
|
|
9
|
+
In light mode the wordmark is dark grey and the two marks keep the fixed CSC
|
|
10
|
+
brand teal and magenta; re-seeding a family with `applyTheme` never recolours
|
|
11
|
+
them. In dark mode the whole logo turns white. To show the white logo on a
|
|
12
|
+
dark or brand-coloured backdrop in a light page, make the backdrop a dark
|
|
13
|
+
mode scope with `data-theme="dark"`.
|
|
14
|
+
|
|
15
|
+
## Accessibility
|
|
16
|
+
|
|
17
|
+
The logo is an image named "CSC"; an `aria-label` on the element names it
|
|
18
|
+
instead. When the logo is the content of a link to the home page, give the
|
|
19
|
+
link its own name, for example `aria-label="CSC home"` on the `<a>`, and hide
|
|
20
|
+
the logo with `aria-hidden="true"`, so the link is not read as just "CSC".
|
|
21
|
+
|
|
22
|
+
## Customization
|
|
23
|
+
|
|
24
|
+
`::part(root)` is the `<svg>` element, a block with a small top margin;
|
|
25
|
+
adjust its spacing there. Leave its colours alone: it is a brand mark.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
A data-driven table that renders the rows of a `data` array through a set of `columns` definitions, with built-in sorting, pagination, row selection and expandable rows. Rows are your own plain objects; each column reads one of their properties and may render its header, cells and footer through render functions.
|
|
2
|
+
|
|
3
|
+
`columns` and `data` hold arrays and functions, which have no attribute form: bind them as DOM properties — `:columns` and `:data` in Vue, props of the React wrapper, property assignment in plain JavaScript. The same goes for `sort`, `selected`, `expanded`, `texts`, `pageSizes`, `getRowId` and `expandedContent`, while scalars such as `page-size`, `selection` and `autohide` also work as attributes. A plain Vue binding already sets the property; do not add the `.prop` modifier.
|
|
4
|
+
|
|
5
|
+
```vue
|
|
6
|
+
<c-data-table :columns="columns" :data="projects" page-size="25" />
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Sorting, the page, the page size, the selection and the expanded rows are optionally controlled: the table keeps each in its own state, so a user action takes effect and fires its `change:*` event whether or not you bind the matching prop, and a value you set replaces the table's state.
|
|
10
|
+
|
|
11
|
+
## When to use
|
|
12
|
+
|
|
13
|
+
- Tabular data held as an array of objects, especially when users sort, page, select or expand rows: the table does that work for you, or hands it to your server with `external`.
|
|
14
|
+
- For a table whose markup you write yourself — rows rendered by your framework, cells styled by your page CSS, a card layout on narrow screens — use `c-table`, which wraps your own `<table>`. Pair it with `c-pagination` when it needs paging.
|
|
15
|
+
|
|
16
|
+
## Columns
|
|
17
|
+
|
|
18
|
+
Each entry of `columns` is a `CDataTableColumn`:
|
|
19
|
+
|
|
20
|
+
- `key` (required) — the row property the column reads. It is also the column's id, so it must be unique.
|
|
21
|
+
- `header` — the header text, or a render function for richer content. Defaults to the `key`.
|
|
22
|
+
- `cell` — a render function for the column's cells. Without one a cell shows the value as text, `null` and `undefined` as empty.
|
|
23
|
+
- `footer` — a render function for the column's footer cell (see Caption, footer and sticky rows).
|
|
24
|
+
- `align` — `start`, `center` or `end`, for the header, cells and footer alike. Unset is `start`.
|
|
25
|
+
- `width` — a fixed width, any CSS width value.
|
|
26
|
+
- `sortable` — lets the user sort by the column.
|
|
27
|
+
- `pinned` and `expansion` — see Narrow containers.
|
|
28
|
+
|
|
29
|
+
Render functions return Vue VNodes, in React and plain JavaScript too: build them with the `h` re-exported by `@cscfi/csc-ui` (no `vue` dependency needed), or return a string or number, which renders as text, never as HTML. A `cell` function receives `{ column, row, rowId, rowIndex, value }`:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { h, type CDataTableColumn } from '@cscfi/csc-ui';
|
|
33
|
+
|
|
34
|
+
const columns: CDataTableColumn[] = [
|
|
35
|
+
{ header: 'Project', key: 'name', sortable: true },
|
|
36
|
+
{
|
|
37
|
+
cell: ({ value }) =>
|
|
38
|
+
h('c-tag', { active: value === 'active' }, String(value)),
|
|
39
|
+
header: 'Status',
|
|
40
|
+
key: 'status',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
align: 'end',
|
|
44
|
+
cell: ({ row }) =>
|
|
45
|
+
h(
|
|
46
|
+
'c-button',
|
|
47
|
+
{ onClick: () => open(row), size: 'small', text: true },
|
|
48
|
+
'Open',
|
|
49
|
+
),
|
|
50
|
+
header: 'Actions',
|
|
51
|
+
key: 'actions',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Cell content renders inside the table's shadow root, so page stylesheets, and `::part()` rules for components nested in cells, do not reach it. Style it in the render function: through a component's own props or an inline `style`.
|
|
57
|
+
|
|
58
|
+
Sorting and the `query` filter read the raw `row[key]` value, never what a `cell` function renders.
|
|
59
|
+
|
|
60
|
+
## Row ids
|
|
61
|
+
|
|
62
|
+
Selection and expansion track rows by id. Supply `getRowId`, a function returning a unique string for a row (`(row) => String(row.id)`); without it a row's id is its index in `data`. The table's own sorting, paging and filtering keep index ids stable, but they point at other rows once your code replaces, reorders or filters `data`, and with `external` paging every page starts again at `0`. Set `getRowId` whenever selection or expansion meets data that changes.
|
|
63
|
+
|
|
64
|
+
## Sorting
|
|
65
|
+
|
|
66
|
+
Mark a column `sortable: true` to make its header a sort button; other columns never sort. The first click on a header sorts its column ascending, each further click flips the direction, and clicking another sortable header starts that column ascending. A click never returns the table to unsorted: set `sort` to `null` for that. By default nothing is sorted and rows keep their order in `data`.
|
|
67
|
+
|
|
68
|
+
`sort` holds the state as `{ column, direction }`: the sorted column's `key`, and `asc` or `desc`. Each user sort fires `change:sort` with the new state:
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<c-data-table
|
|
72
|
+
:columns="columns"
|
|
73
|
+
:data="projects"
|
|
74
|
+
:sort="sort"
|
|
75
|
+
@change:sort="sort = $event.detail"
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Client-side, the table sorts all rows, then pages them; with `external` it only reports the new state.
|
|
80
|
+
|
|
81
|
+
## Filtering
|
|
82
|
+
|
|
83
|
+
`query` narrows the rows client-side: a row stays when any column's value contains the query, ignoring case. Only columns holding strings or numbers are searched (judged by the first row), and the match runs on the raw value. A new query returns the table to page 1. With `external`, `query` is ignored: filter on your side and pass the result as `data`.
|
|
84
|
+
|
|
85
|
+
## Pagination
|
|
86
|
+
|
|
87
|
+
The table paginates only while `page-size` is set; without it every row renders and there is no pager. With it, a `c-pagination` bar below the table shows the page buttons, the range of rows shown and a page-size menu offering `pageSizes` (default `[5, 25, 50, 100]`). `page` is the current page, counting from 1.
|
|
88
|
+
|
|
89
|
+
The user's picks fire `change:page` with the new page and `change:page-size` with the new size. A new size also returns to the first page, firing `change:page` with `1` when the table was on a later page. The table moves the page itself as well, again firing `change:page`: back to 1 when `query` changes, and to the last page when the rows shrink beneath the current one.
|
|
90
|
+
|
|
91
|
+
## External data
|
|
92
|
+
|
|
93
|
+
Set `external` when your code, typically a server, sorts, pages and filters the rows. The table then renders `data` verbatim, so pass only the current page's rows, and its `change:sort`, `change:page` and `change:page-size` events become your signal to fetch. Set `item-count` to the total number of rows so the pager knows how many pages there are (without it the pager counts `data`), and `loading` while a request is in flight. On `change:page-size`, fetch the first page at the new size. See the external data example.
|
|
94
|
+
|
|
95
|
+
With `external`, `query` is ignored and the select-all banner never shows: the table cannot know the ids of rows it has not been given.
|
|
96
|
+
|
|
97
|
+
## Selection
|
|
98
|
+
|
|
99
|
+
`selection="multiple"` adds a checkbox column: a row's checkbox toggles that row, and the header checkbox selects or clears every row on the current page, reading as partly checked when only some are selected. `selection="single"` gives each row a checkbox that replaces the selection, and no header checkbox. Clicking a row does not select it.
|
|
100
|
+
|
|
101
|
+
`selected` holds the selected row ids, and each user change fires `change:selected` with the new array. Ids stay selected while their rows are sorted, paged or filtered out of view. The read-only `selectedRows` property returns the row objects behind the ids, in selection order — only those the current `data` holds, so with `external` paging it lists the current page's selected rows while `selected` keeps the ids from every page.
|
|
102
|
+
|
|
103
|
+
```vue
|
|
104
|
+
<c-data-table
|
|
105
|
+
:columns="columns"
|
|
106
|
+
:data="datasets"
|
|
107
|
+
:get-row-id="getRowId"
|
|
108
|
+
:selected="selected"
|
|
109
|
+
selection="multiple"
|
|
110
|
+
@change:selected="selected = $event.detail"
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
With client-side data and pagination, selecting a whole page in `multiple` mode shows a banner above the table: "All 25 rows on this page are selected", with a button that selects every row matching `query`. Once every row is selected, the banner offers to clear the selection instead.
|
|
115
|
+
|
|
116
|
+
## Expandable rows
|
|
117
|
+
|
|
118
|
+
A row becomes expandable as soon as there is something to show beneath it: a column whose cells live in the expansion row (see Narrow containers), or an `expandedContent` render function. An expander column then appears at the table's right edge. Its button, or a click anywhere on the row other than on a link, button, form control or menu, opens the row's expansion row: the cells of the columns living there, each under its header, followed by `expandedContent`, which receives `{ expansionColumns, row, rowId, rowIndex }`.
|
|
119
|
+
|
|
120
|
+
`expanded` holds the expanded row ids, and toggling a row fires `change:expanded` with the new array. `single-expansion` keeps at most one row open, closing the previous one as another opens. Should the table grow until no column is left in the expansion row and there is no `expandedContent`, the expander column goes away and every row closes, firing `change:expanded` with `[]`.
|
|
121
|
+
|
|
122
|
+
## Narrow containers
|
|
123
|
+
|
|
124
|
+
A column's expansion policy decides where its cells live: `expansion: 'auto'` (the default) keeps it a real column unless autohide moves it, `'never'` always keeps it a column, and `'always'` never renders it as a column — its cells appear only in the expansion row, for detail that does not need a column of its own.
|
|
125
|
+
|
|
126
|
+
When the columns are wider than the container, the table scrolls sideways inside `::part(viewport)` by default. With `autohide` it instead moves `auto` columns into the expansion row, rightmost first, until the rest fit, and brings them back as the container grows. If the table still overflows once every `auto` column is hidden, it scrolls.
|
|
127
|
+
|
|
128
|
+
Pin a column with `pinned: 'left'` or `pinned: 'right'` to keep it at that edge while the table scrolls sideways. Pinned columns move to their edge, in the order you list them, and are never autohidden. The selection column is always pinned at the left edge and the expander column at the right. A pinned column cannot also have `expansion: 'always'`: the pin is ignored, with a console warning.
|
|
129
|
+
|
|
130
|
+
## Caption, footer and sticky rows
|
|
131
|
+
|
|
132
|
+
The `caption` slot fills the table's native `<caption>`, which is also its accessible name.
|
|
133
|
+
|
|
134
|
+
A column's `footer` render function adds a footer row, rendered once any column defines one. It receives `{ column, rows }`, where `rows` are the rows on the current page — for page totals:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
footer: ({ rows }) => `${rows.reduce((sum, row) => sum + (row.size as number), 0)} GB`,
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`sticky-header` and `sticky-footer` keep the header and footer rows in view while the table scrolls vertically. The table scrolls inside `::part(viewport)`, which grows with its rows, so cap the viewport's height for the rows to scroll there:
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
c-data-table::part(viewport) {
|
|
144
|
+
max-height: 480px;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Loading and empty states
|
|
149
|
+
|
|
150
|
+
`loading` runs a thin progress bar under the header row; rows already shown stay in place. A table with no rows shows "No data", or "Loading data" while `loading` is set. The `empty` slot replaces both texts with your own content — switch that content yourself if it should differ while loading.
|
|
151
|
+
|
|
152
|
+
## Texts
|
|
153
|
+
|
|
154
|
+
The built-in strings are translated through `texts`, merged key by key over the English defaults: `noData`, `loading` and `selectPage`; `selectRow` and `expandRow`, functions receiving the row's value in the first visible column (or one string for every row); the banner's `pageSelected`, `allSelected` and `selectAllRows`, functions receiving a row count, and `clearSelection`; and the pager's `pagination`, `pageSize`, `previousPage`, `nextPage`, `page` and `range`, which the table hands to its `c-pagination` (see the `c-pagination` texts). Since some keys are functions, bind the object as a DOM property:
|
|
155
|
+
|
|
156
|
+
```vue
|
|
157
|
+
<c-data-table
|
|
158
|
+
:columns="columns"
|
|
159
|
+
:data="projects"
|
|
160
|
+
:texts="{
|
|
161
|
+
noData: 'Ei tietoja',
|
|
162
|
+
pageSelected: (count) => `Kaikki tämän sivun ${count} riviä on valittu`,
|
|
163
|
+
}"
|
|
164
|
+
/>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
To translate every data table at once, set `texts` app-wide with `applyDefaults({ 'c-data-table': { texts } })` (Customization → App-wide prop defaults); a per-instance `texts` still wins key by key. Pager keys the table's texts leave unset fall through to `c-pagination`'s own, so an app-wide `c-pagination` translation covers the table's pager too.
|
|
168
|
+
|
|
169
|
+
## Accessibility
|
|
170
|
+
|
|
171
|
+
- The table is a native `<table>` with column headers, so screen readers' table navigation works. Name it through the `caption` slot: an `aria-label` on the element does not reach the table. To keep the caption for screen readers only, hide it visually through `::part(caption)`.
|
|
172
|
+
- Sortable headers are buttons in the tab order, operated with Enter or Space; the sorted column's header carries `aria-sort`.
|
|
173
|
+
- The checkboxes and expander buttons are named by `texts.selectRow`, `texts.selectPage` and `texts.expandRow`; a row's checkbox and expander carry the row's first-column value ("Select Aurora", "Details of Aurora"), so each is told apart. The expander reports its state with `aria-expanded`. Clicking a row to expand it is a pointer shortcut; keyboard users reach the expander button.
|
|
174
|
+
- The select-all banner's message is announced through a polite status region.
|
|
175
|
+
- While `loading` the table is `aria-busy`; the loading bar itself is decorative.
|
|
176
|
+
- Give every column a header — an empty `header` leaves its cells without one in screen-reader table navigation — and give icon-only controls you render in cells an `aria-label`.
|
|
177
|
+
|
|
178
|
+
## Customization
|
|
179
|
+
|
|
180
|
+
Restyle through the parts: `::part(root)` (the wrapper), `::part(viewport)` (the scroll container), `::part(table)`, `::part(caption)`, `::part(header)` and `::part(header-cell)` (the `<thead>` and a data column's `<th>`), `::part(body)`, `::part(row)` and `::part(cell)` (the `<tbody>`, a data row and a data column's `<td>`), `::part(expansion-row)`, `::part(footer)` (the `<tfoot>`), `::part(empty)` (the empty-state content), `::part(banner)` (the select-all banner) and `::part(pagination)` (the bar holding the pager). The selection and expander cells carry no part, and the pager's own parts are not forwarded. Colours come from the semantic tokens; override the tokens to re-theme.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
A date field that takes a typed date, or opens a calendar panel for picking one, or a start and end date under `range`.
|
|
2
|
+
|
|
3
|
+
## Value
|
|
4
|
+
|
|
5
|
+
The value is a calendar date as an ISO `YYYY-MM-DD` string — `'2026-09-28'` —
|
|
6
|
+
or `null` when the field is empty. It carries no time and no timezone, so it
|
|
7
|
+
round-trips through attributes, JSON and forms unchanged, and whatever the
|
|
8
|
+
displayed `format`, the value keeps this one shape. Bind it with `v-model`, or
|
|
9
|
+
listen for `change`:
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<c-date-picker v-model="date" label="Start date" />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Under `range` the value becomes `{ start, end }`. Picking in the calendar
|
|
16
|
+
always yields a complete range; typing can commit one end before the other, so
|
|
17
|
+
either end may be `null` — `{ start: '2026-09-01', end: null }` — and a range
|
|
18
|
+
with neither end is `null`.
|
|
19
|
+
|
|
20
|
+
## Typing
|
|
21
|
+
|
|
22
|
+
The field is typeable first: clicking into it or focusing it never opens the
|
|
23
|
+
calendar. Text is read when the user presses Enter or leaves the input, never
|
|
24
|
+
per keystroke. The `format` prop sets how dates are shown and read — a pattern
|
|
25
|
+
of the tokens `d`, `dd`, `M`, `MM` and `yyyy` with any separators, `dd.MM.yyyy`
|
|
26
|
+
by default. Reading is lenient: a day or a month may have one or two digits
|
|
27
|
+
whatever the token, and any of `.`, `/`, `-` or a space separates the parts,
|
|
28
|
+
so `1.9.2026` and `1/9/2026` both commit as `01.09.2026` under the default. The
|
|
29
|
+
year needs all four digits. The format is an app default, so an app can set it
|
|
30
|
+
once with `applyDefaults({ 'c-date-picker': { format: 'yyyy-MM-dd' } })`.
|
|
31
|
+
|
|
32
|
+
Typing follows the format as it goes: the separators appear on their own
|
|
33
|
+
(`01012031` shows `01.01.2031`), a day or month closes early when a separator
|
|
34
|
+
is typed or when its first digit can start no two-digit value (`4` for a day,
|
|
35
|
+
`2` for a month), any of `.`, `/`, `-` or a space typed in place of a
|
|
36
|
+
separator shows as the format's own, and other characters are dropped. Pasted
|
|
37
|
+
text is kept as it is and read when committed.
|
|
38
|
+
|
|
39
|
+
Text that names no date that can be picked — `31.02.2026`, a disabled date, a
|
|
40
|
+
date outside `min` and `max` — is **bad input**: the text stays as the user
|
|
41
|
+
typed it, the value becomes `null`, and the host exposes the `bad-input` custom
|
|
42
|
+
state and a read-only `badInput` property. The component never shows an error
|
|
43
|
+
of its own; deciding whether bad input is an error, and saying so, is the
|
|
44
|
+
consumer's validation:
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<c-date-picker
|
|
48
|
+
v-model="date"
|
|
49
|
+
:error-message="error"
|
|
50
|
+
:invalid="!!error"
|
|
51
|
+
label="Start date"
|
|
52
|
+
@change:text="
|
|
53
|
+
error = $event.target.badInput ? 'Enter a date as dd.mm.yyyy' : ''
|
|
54
|
+
"
|
|
55
|
+
/>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Every commit of typed text fires `change:text` with the text as typed
|
|
59
|
+
(`{ start, end }` under `range`), whether or not it changed the value — the
|
|
60
|
+
moment to read `badInput`, as above.
|
|
61
|
+
|
|
62
|
+
## The calendar
|
|
63
|
+
|
|
64
|
+
The calendar button at the field's trailing edge, or Alt+ArrowDown in the
|
|
65
|
+
input, opens the calendar panel. It is a dialog: focus moves onto the selected
|
|
66
|
+
day, else today, else the nearest day that can be picked, and Tab cycles
|
|
67
|
+
through the month and year controls, the grid and the Today button
|
|
68
|
+
(`show-today`) until the panel closes.
|
|
69
|
+
Picking a day commits it and closes the panel; Escape closes it without a
|
|
70
|
+
change. Focus returns to the input either way. On a narrow viewport a pick
|
|
71
|
+
waits for a Done button instead (see [Narrow viewports](#narrow-viewports)).
|
|
72
|
+
|
|
73
|
+
| Key | In the day grid |
|
|
74
|
+
| ----------------------- | ------------------------------------- |
|
|
75
|
+
| ArrowLeft / ArrowRight | Previous / next day |
|
|
76
|
+
| ArrowUp / ArrowDown | Same day of the previous / next week |
|
|
77
|
+
| Home / End | First / last day of the week |
|
|
78
|
+
| PageUp / PageDown | Same day of the previous / next month |
|
|
79
|
+
| Shift+PageUp / PageDown | Same day of the previous / next year |
|
|
80
|
+
| Enter / Space | Pick the day |
|
|
81
|
+
|
|
82
|
+
The month and year buttons in the header swap the grid for a list of months
|
|
83
|
+
or years; picking one returns to the grid. The year list reaches a hundred
|
|
84
|
+
years either side of today unless `min` and `max` narrow it. The displayed
|
|
85
|
+
month is announced to the consumer as `change:month` (`'YYYY-MM'`) whenever it
|
|
86
|
+
changes and when the panel opens.
|
|
87
|
+
|
|
88
|
+
The week starts on Monday; set `first-day-of-week` to another day, numbered
|
|
89
|
+
like `Date.getDay()` (`0` for Sunday). `show-week-numbers` adds ISO 8601 week
|
|
90
|
+
numbers beside the rows. With a week start other than Monday a row spans two
|
|
91
|
+
ISO weeks and shows the one holding most of its days, so a week split across
|
|
92
|
+
two months carries the same number in both.
|
|
93
|
+
|
|
94
|
+
## Ranges
|
|
95
|
+
|
|
96
|
+
With `range` the field holds two inputs, the start and the end, in one field
|
|
97
|
+
box. In the calendar the first day picked is only pending — it is shown and
|
|
98
|
+
announced, the band follows the pointer or the focused day, and nothing is
|
|
99
|
+
emitted — until the second pick completes the range and closes the panel.
|
|
100
|
+
Dismissing the panel in between discards the pending day. Picking the end
|
|
101
|
+
before the start swaps them, and so does typing a start later than the end.
|
|
102
|
+
|
|
103
|
+
## Disabling dates
|
|
104
|
+
|
|
105
|
+
Three rules decide which dates cannot be picked; a date any of them rules out
|
|
106
|
+
is disabled:
|
|
107
|
+
|
|
108
|
+
- `min` and `max` — ISO dates bounding the calendar itself: the arrows and the
|
|
109
|
+
keyboard stop there.
|
|
110
|
+
- `disabled-dates` — a list of ISO dates and inclusive `{ start, end }` spans.
|
|
111
|
+
- `is-date-disabled` — a predicate receiving an ISO date, for rules such as
|
|
112
|
+
"no weekends".
|
|
113
|
+
|
|
114
|
+
The list and the predicate have no attribute form, so bind them as DOM
|
|
115
|
+
properties. A disabled day can still be focused in the grid — the arrows keep
|
|
116
|
+
their meaning — and is announced as unavailable, but it cannot be picked. A
|
|
117
|
+
range may span disabled days: only its start and end must be enabled.
|
|
118
|
+
|
|
119
|
+
Availability that comes from a server can follow the calendar: load the
|
|
120
|
+
disabled dates of the month `change:month` names and assign `disabled-dates`
|
|
121
|
+
again.
|
|
122
|
+
|
|
123
|
+
## Months
|
|
124
|
+
|
|
125
|
+
With `type="month"` the field picks a year and a month instead of a day. The
|
|
126
|
+
value is an ISO `YYYY-MM` string — `'2026-03'` — or `{ start, end }` of them
|
|
127
|
+
under `range`, like the native `<input type="month">`:
|
|
128
|
+
|
|
129
|
+
```vue
|
|
130
|
+
<c-date-picker v-model="billing" label="Billing month" type="month" />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The format is the `format` with its day left out, so one app default serves
|
|
134
|
+
both kinds of field: `dd.MM.yyyy` shows months as `MM.yyyy`, `yyyy-MM-dd` as
|
|
135
|
+
`yyyy-MM`. A `format` with no day, such as `MM/yyyy`, is used as given.
|
|
136
|
+
Typing is as lenient as for dates: `3.2026` and `032026` both commit as
|
|
137
|
+
`03.2026`. A full date bound as the value is shown as its month and emits
|
|
138
|
+
nothing; the next pick or commit emits the month.
|
|
139
|
+
|
|
140
|
+
The panel asks for the month first, then the year. It opens on the twelve
|
|
141
|
+
months under a "Month" label, with the selected month marked and focused.
|
|
142
|
+
Picking one collapses it to a summary row and the years unroll beneath it,
|
|
143
|
+
focused on the selected year — else this year, else the nearest year that can
|
|
144
|
+
be picked. Picking a year commits the month and closes the panel; pressing the
|
|
145
|
+
summary row goes back to the months. Both lists take the arrows, Home and End,
|
|
146
|
+
and Enter or Space to pick.
|
|
147
|
+
|
|
148
|
+
Under `range` the steps run twice, labelled "Start month", "Start year", "End
|
|
149
|
+
month" and "End year". The finished start shows as a summary row and is only
|
|
150
|
+
pending, as in the day grid: nothing is emitted until the end's year completes
|
|
151
|
+
the range, a range picked backwards is swapped, and dismissing the panel
|
|
152
|
+
discards the start.
|
|
153
|
+
|
|
154
|
+
`min` and `max` may be months or full dates; a full date counts by its month,
|
|
155
|
+
so `min="2026-03-15"` still allows March. A month is disabled only when every
|
|
156
|
+
one of its days is — by `min` and `max`, `disabled-dates` or
|
|
157
|
+
`is-date-disabled` — so a "no weekends" predicate disables no month, and a
|
|
158
|
+
span covering all of July disables July. In the month list a month is disabled
|
|
159
|
+
when no allowed year takes it; in the year list a year is disabled when the
|
|
160
|
+
picked month is disabled in it, so no pick leads to an empty list. The
|
|
161
|
+
predicate is asked about each day until one is enabled, so in most months it
|
|
162
|
+
runs once; one that disables nearly every day is asked many times when the
|
|
163
|
+
months open.
|
|
164
|
+
|
|
165
|
+
`change:month` names the displayed month of the day grid, so it is never
|
|
166
|
+
fired in month mode.
|
|
167
|
+
|
|
168
|
+
## Today
|
|
169
|
+
|
|
170
|
+
`show-today` adds a Today button under the calendar. Pressing it does what
|
|
171
|
+
pressing today in the grid would: it commits today and closes the panel.
|
|
172
|
+
Under `range` the first press makes today the pending start and moves focus
|
|
173
|
+
onto it in the grid; a press while a start is pending completes the range.
|
|
174
|
+
Under `type="month"` the button reads "This month" and picks the current
|
|
175
|
+
month, its month and year at once.
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<c-date-picker v-model="due" label="Due date" show-today />
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The button is disabled, never hidden, while today cannot be picked: outside
|
|
182
|
+
`min` and `max`, in `disabled-dates`, or ruled out by `is-date-disabled`. It
|
|
183
|
+
goes by the rules assigned at that moment, as typed text does, so when
|
|
184
|
+
`disabled-dates` is loaded per displayed month, keep today's dates in the
|
|
185
|
+
list or express the rule as `is-date-disabled`. Leave the button off where
|
|
186
|
+
today is never the answer, such as a birthdate, or turn it on app-wide with
|
|
187
|
+
`applyDefaults({ 'c-date-picker': { showToday: true } })`.
|
|
188
|
+
|
|
189
|
+
## Texts
|
|
190
|
+
|
|
191
|
+
Month and weekday names and each day's accessible name come from `texts` when
|
|
192
|
+
given, then from the browser's `Intl` data for the page's `lang`, then from
|
|
193
|
+
the English built-ins — so a page with `<html lang="fi">` gets Finnish names
|
|
194
|
+
without any configuration. The labels of the buttons and the range inputs are
|
|
195
|
+
English unless `texts` replaces them. Weekday arrays are indexed like
|
|
196
|
+
`Date.getDay()`, Sunday first. Set them app-wide with
|
|
197
|
+
`applyDefaults({ 'c-date-picker': { texts } })`.
|
|
198
|
+
|
|
199
|
+
## Narrow viewports
|
|
200
|
+
|
|
201
|
+
On a viewport narrower than 760px the calendar opens as a **fullscreen
|
|
202
|
+
panel**: a heading row with the field's `label` and a close button above the
|
|
203
|
+
calendar, and a Done button below it. There a pick only selects: the day, the
|
|
204
|
+
range or the month waits in the panel, and nothing is emitted until Done
|
|
205
|
+
commits it and closes the panel. The close button and Escape close the panel
|
|
206
|
+
without a change, discarding what was picked, and so does the window growing
|
|
207
|
+
past 760px while it is open.
|
|
208
|
+
|
|
209
|
+
The Today button selects today the same way. Enter on a day picks it and
|
|
210
|
+
presses Done at once. Under `range` Done stays disabled until the second pick
|
|
211
|
+
completes the range, and under `type="month"` the panel stays on the year
|
|
212
|
+
step, the year checked, until Done. Pressing Done before picking anything
|
|
213
|
+
closes the panel and changes nothing. The field stays typeable at every
|
|
214
|
+
width.
|
|
215
|
+
|
|
216
|
+
## Native date input
|
|
217
|
+
|
|
218
|
+
`c-text-field type="date"` remains the browser's own date input — no custom
|
|
219
|
+
calendar, the browser's format, and no ranges or disabled dates. Reach for
|
|
220
|
+
`c-date-picker` when the format, the calendar's look or those features matter.
|
|
221
|
+
`c-text-field` has no month type: for a year and a month, use
|
|
222
|
+
`type="month"` here.
|
|
223
|
+
|
|
224
|
+
`c-time-picker` is the same typeable field for times of day.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
A separator: a thin line dividing groups of content, horizontal by default or
|
|
2
|
+
vertical with `vertical`.
|
|
3
|
+
|
|
4
|
+
## When to use
|
|
5
|
+
|
|
6
|
+
- Between groups of items in a `c-menu`, slotted among its `c-menu-item`
|
|
7
|
+
elements. A `c-menu-label` heads a group; the separator is the line between
|
|
8
|
+
groups.
|
|
9
|
+
- Between sections of a card or panel, or between items in a row.
|
|
10
|
+
- Not for spacing alone: it always draws a line.
|
|
11
|
+
|
|
12
|
+
## Orientation
|
|
13
|
+
|
|
14
|
+
A horizontal separator is a block spanning the full width of its container,
|
|
15
|
+
with a small margin above and below. A `vertical` one is an inline-block with
|
|
16
|
+
a small margin on each side: in a flex row it stretches to the row's height,
|
|
17
|
+
and in running text it is at least 1em tall.
|
|
18
|
+
|
|
19
|
+
## Accessibility
|
|
20
|
+
|
|
21
|
+
The line is a `role="separator"` element whose `aria-orientation` follows
|
|
22
|
+
`vertical`. It is not focusable; screen readers may announce it, which in a
|
|
23
|
+
menu marks the boundary between groups.
|
|
24
|
+
|
|
25
|
+
## Customization
|
|
26
|
+
|
|
27
|
+
`::part(root)` is the line itself. It paints the `divider` token, a
|
|
28
|
+
translucent ink that reads on every surface in both theme modes, as its
|
|
29
|
+
background colour, so set `background-color` to recolour it and `margin` to
|
|
30
|
+
change its spacing:
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
c-divider::part(root) {
|
|
34
|
+
margin-block: 16px;
|
|
35
|
+
}
|
|
36
|
+
```
|