@cscfi/csc-ui 4.0.0-alpha.11 → 4.0.0-alpha.13
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 +7677 -7042
- package/dist/custom-elements.json +337 -58
- package/dist/docs/c-autocomplete/usage.md +129 -0
- 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-select/usage.md +104 -0
- package/dist/vscode.css-custom-data.json +65 -0
- package/dist/vscode.html-custom-data.json +50 -20
- package/dist/web-types.json +210 -53
- package/dist-types/components/c-autocomplete/CAutocomplete.vue.d.ts +84 -11
- package/dist-types/components/c-checkbox/CCheckbox.vue.d.ts +2 -2
- package/dist-types/components/c-data-table/CDataTable.vue.d.ts +1 -1
- package/dist-types/components/c-dropdown/CDropdown.vue.d.ts +32 -4
- package/dist-types/components/c-input/CInput.vue.d.ts +1 -1
- package/dist-types/components/c-menu/CMenu.vue.d.ts +1 -1
- package/dist-types/components/c-popover/CPopover.vue.d.ts +1 -1
- package/dist-types/components/c-select/CSelect.vue.d.ts +81 -17
- package/dist-types/components/c-side-navigation/CSideNavigation.vue.d.ts +1 -1
- package/dist-types/components/c-tag/CTag.vue.d.ts +7 -0
- package/dist-types/components/c-text-field/CTextField.vue.d.ts +3 -3
- package/dist-types/components/c-tooltip/CTooltip.vue.d.ts +1 -1
- package/dist-types/index.d.ts +2 -1
- package/dist-types/shared/FormLabel.vue.d.ts +1 -1
- package/dist-types/shared/SelectionIndicator.vue.d.ts +21 -0
- package/dist-types/shared/optionLabel.d.ts +18 -0
- package/dist-types/shared/peekCap.d.ts +35 -0
- package/dist-types/shared/selectAll.d.ts +29 -0
- package/dist-types/shared/splitMatches.d.ts +18 -0
- package/dist-types/tag-name-map.d.ts +110 -18
- package/package.json +1 -1
|
@@ -7,15 +7,22 @@
|
|
|
7
7
|
* `document.createElement('c-button')` and `querySelector('c-button')`
|
|
8
8
|
* return the typed element.
|
|
9
9
|
*/
|
|
10
|
-
import type { CAutocompleteFilter, CAutocompleteItem } from './components/c-autocomplete/CAutocomplete.vue';
|
|
10
|
+
import type { CAutocompleteFilter, CAutocompleteItem, CAutocompleteTexts, CAutocompleteValue } from './components/c-autocomplete/CAutocomplete.vue';
|
|
11
11
|
import type { CButtonGroupValue } from './components/c-button-group/CButtonGroup.vue';
|
|
12
12
|
import type { CDataTableCellContent, CDataTableColumn, CDataTableExpandedContext, CDataTableRow, CDataTableSort, CDataTableTexts } from './components/c-data-table/CDataTable.vue';
|
|
13
13
|
import type { CPaginationOptions } from './components/c-pagination/CPagination.vue';
|
|
14
|
+
import type { CSelectTexts, CSelectValue } from './components/c-select/CSelect.vue';
|
|
14
15
|
import type { CSelectItem, CToastMessage } from './types';
|
|
15
16
|
type AccordionPrimitive = number | string;
|
|
16
17
|
type AccordionValue = AccordionPrimitive | AccordionPrimitive[] | null;
|
|
18
|
+
interface CDropdownSelectAllRow {
|
|
19
|
+
label: string;
|
|
20
|
+
selected: number;
|
|
21
|
+
state: 'all' | 'none' | 'some';
|
|
22
|
+
total: number;
|
|
23
|
+
}
|
|
17
24
|
type DropdownItem = {
|
|
18
|
-
disabled?: boolean;
|
|
25
|
+
disabled?: boolean | string;
|
|
19
26
|
name: string;
|
|
20
27
|
outerHTML?: string;
|
|
21
28
|
selected?: boolean;
|
|
@@ -133,9 +140,10 @@ export interface CAutocompleteElementEventMap {
|
|
|
133
140
|
* Fired when the selected value changes (an option is committed or the
|
|
134
141
|
* selection is cleared), carrying the new value — the option's value, or
|
|
135
142
|
* the whole `{ name, value }` item when `return-object` is set; `null`
|
|
136
|
-
* when cleared.
|
|
143
|
+
* when cleared. In `multiple` mode the whole array of picked values, in
|
|
144
|
+
* pick order (`[]` when cleared).
|
|
137
145
|
*/
|
|
138
|
-
changeValue: CustomEvent<
|
|
146
|
+
changeValue: CustomEvent<CAutocompleteValue>;
|
|
139
147
|
/**
|
|
140
148
|
* Native bubbling input event dispatched alongside every value change so a
|
|
141
149
|
* plain `v-model` stays in sync. Carries no detail.
|
|
@@ -145,10 +153,10 @@ export interface CAutocompleteElementEventMap {
|
|
|
145
153
|
* Fired alongside `changeValue` with the same detail — the `v-model`
|
|
146
154
|
* contract.
|
|
147
155
|
*/
|
|
148
|
-
'update:value': CustomEvent<
|
|
156
|
+
'update:value': CustomEvent<CAutocompleteValue>;
|
|
149
157
|
}
|
|
150
158
|
/** A filterable value-selection component: a readonly value field that opens a popover panel with a search input above the matching options. */
|
|
151
|
-
export interface CAutocompleteElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'errorMessage' | 'external' | 'filter' | 'hideDetails' | 'hint' | 'hostId' | 'items' | 'itemsPerPage' | 'label' | 'labelOnTop' | 'loading' | '
|
|
159
|
+
export interface CAutocompleteElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'errorMessage' | 'external' | 'filter' | 'hideDetails' | 'hint' | 'hostId' | 'items' | 'itemsPerPage' | 'label' | 'labelOnTop' | 'loading' | 'maxTags' | 'multiple' | 'name' | 'placeholder' | 'required' | 'returnObject' | 'selectAll' | 'shadow' | 'size' | 'texts' | 'valid' | 'value'> {
|
|
152
160
|
/** Make the selected value clearable */
|
|
153
161
|
clearable?: boolean;
|
|
154
162
|
/** Disable the input */
|
|
@@ -179,24 +187,52 @@ export interface CAutocompleteElement extends Omit<HTMLElement, 'clearable' | 'd
|
|
|
179
187
|
labelOnTop?: boolean;
|
|
180
188
|
/** Show loading state */
|
|
181
189
|
loading?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* In `multiple` mode, show at most this many selected-value tags and fold
|
|
192
|
+
* the rest into one "+N more" tag; `0` shows no tags and reads "N selected"
|
|
193
|
+
* instead; unset shows every tag
|
|
194
|
+
*/
|
|
195
|
+
maxTags?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Allow selecting several options: rows toggle, the panel stays open and
|
|
198
|
+
* keeps its query, `value` becomes an array of the selected values (items
|
|
199
|
+
* with `return-object`) in the order they were picked, and the picks show
|
|
200
|
+
* as tags inside the field. Arrays have no attribute form — bind `value` as
|
|
201
|
+
* a DOM property
|
|
202
|
+
*/
|
|
203
|
+
multiple?: boolean;
|
|
182
204
|
/** Input field name */
|
|
183
205
|
name?: string;
|
|
184
|
-
/** Message shown when the query matches no options */
|
|
185
|
-
noResultsText?: string;
|
|
186
206
|
/** Placeholder for the in-panel search input */
|
|
187
207
|
placeholder?: string;
|
|
188
208
|
/** Set the autocomplete as required */
|
|
189
209
|
required?: boolean;
|
|
190
210
|
/** Return object instead of value */
|
|
191
211
|
returnObject?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* In `multiple` mode, pin a select-all row at the top of the list. Its
|
|
214
|
+
* checkbox shows whether none, some or all enabled options currently listed
|
|
215
|
+
* — the matches while a query is typed, the given `items` with `external` —
|
|
216
|
+
* are selected; activating it selects them all, or, when all are selected,
|
|
217
|
+
* unselects them. Ignored in single mode
|
|
218
|
+
*/
|
|
219
|
+
selectAll?: boolean;
|
|
192
220
|
/** Shadow variant */
|
|
193
221
|
shadow?: boolean;
|
|
194
222
|
/** Field height: the 44px default or the 36px `small` box */
|
|
195
223
|
size?: 'default' | 'small';
|
|
224
|
+
/**
|
|
225
|
+
* UI text overrides (i18n), merged over the English defaults. Objects have
|
|
226
|
+
* no attribute form — bind as a DOM property (`:texts.prop` in Vue)
|
|
227
|
+
*/
|
|
228
|
+
texts?: CAutocompleteTexts;
|
|
196
229
|
/** Set the validity of the input */
|
|
197
230
|
valid?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Selected value: the option's value, or the whole item with
|
|
233
|
+
* `return-object`; an array of them in `multiple` mode
|
|
234
|
+
*/
|
|
235
|
+
value?: CAutocompleteValue;
|
|
200
236
|
/** Reset autocomplete state */
|
|
201
237
|
reset(): void;
|
|
202
238
|
addEventListener<K extends keyof CAutocompleteElementEventMap>(type: K, listener: (this: CAutocompleteElement, ev: CAutocompleteElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -494,20 +530,40 @@ export interface CDropdownElementEventMap {
|
|
|
494
530
|
name: string;
|
|
495
531
|
value: number | string;
|
|
496
532
|
}>;
|
|
533
|
+
/**
|
|
534
|
+
* Fired when the select-all row is activated; the parent (c-select) toggles
|
|
535
|
+
* every listed enabled option.
|
|
536
|
+
*/
|
|
537
|
+
selectall: CustomEvent<void>;
|
|
497
538
|
}
|
|
498
|
-
export interface CDropdownElement extends Omit<HTMLElement, 'dropdownItemType' | 'hostId' | 'index' | 'items' | 'itemsPerPage' | 'parent' | 'type'> {
|
|
539
|
+
export interface CDropdownElement extends Omit<HTMLElement, 'dropdownItemType' | 'hostId' | 'index' | 'items' | 'itemsPerPage' | 'multiple' | 'parent' | 'selectAllRow' | 'selected' | 'type'> {
|
|
499
540
|
/** Whether items are <c-option> elements or plain objects */
|
|
500
541
|
dropdownItemType?: 'item' | 'option';
|
|
501
542
|
/** Id used to build option/announce element ids */
|
|
502
543
|
hostId?: string;
|
|
503
|
-
/** Current highlighted index */
|
|
544
|
+
/** Current highlighted index; `-1` (`SELECT_ALL_INDEX`) is the select-all row */
|
|
504
545
|
index?: null | number;
|
|
505
546
|
/** Dropdown options: a NodeList of <c-option> or an array of items */
|
|
506
547
|
items?: ArrayLike<DropdownItem>;
|
|
507
548
|
/** Items per page before adding scroll */
|
|
508
549
|
itemsPerPage?: number;
|
|
550
|
+
/**
|
|
551
|
+
* Multi-select mode: rows toggle instead of committing, each carries a
|
|
552
|
+
* decorative checkbox indicator, and the listbox is `aria-multiselectable`
|
|
553
|
+
*/
|
|
554
|
+
multiple?: boolean;
|
|
509
555
|
/** Dropdown parent (the c-select / c-autocomplete host element) */
|
|
510
556
|
parent?: HTMLElement | null;
|
|
557
|
+
/**
|
|
558
|
+
* The select-all row in `multiple` mode, as the parent computes it (label,
|
|
559
|
+
* tri-state, counts for the live region); `null` renders no row
|
|
560
|
+
*/
|
|
561
|
+
selectAllRow?: CDropdownSelectAllRow | null;
|
|
562
|
+
/**
|
|
563
|
+
* Values of the currently selected items in `multiple` mode; drives each
|
|
564
|
+
* row's `aria-selected` and its indicator
|
|
565
|
+
*/
|
|
566
|
+
selected?: (number | string)[];
|
|
511
567
|
/** Parent type — drives autocomplete-only behaviour (highlight, messages) */
|
|
512
568
|
type?: 'autocomplete' | 'select';
|
|
513
569
|
/** Close dropdown */
|
|
@@ -703,6 +759,7 @@ export interface CMenuElementEventMap {
|
|
|
703
759
|
value: unknown;
|
|
704
760
|
}>;
|
|
705
761
|
}
|
|
762
|
+
/** 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. */
|
|
706
763
|
export interface CMenuElement extends Omit<HTMLElement, 'distance' | 'open' | 'position' | 'trigger'> {
|
|
707
764
|
/** Distance from the trigger to the panel, in pixels. Defaults to `0`. */
|
|
708
765
|
distance?: number | string;
|
|
@@ -816,6 +873,7 @@ export interface COptionElement extends Omit<HTMLElement, 'disabled' | 'name' |
|
|
|
816
873
|
/** Option value */
|
|
817
874
|
value?: number | string;
|
|
818
875
|
}
|
|
876
|
+
/** 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)`). */
|
|
819
877
|
export interface COptionValueElement extends HTMLElement {
|
|
820
878
|
}
|
|
821
879
|
/** Events dispatched by `<c-otp-input>`. */
|
|
@@ -1041,8 +1099,10 @@ export interface CSelectElementEventMap {
|
|
|
1041
1099
|
* Fired when the selection changes (an option is picked or the value is
|
|
1042
1100
|
* cleared), carrying the new value — the option's value, or the whole
|
|
1043
1101
|
* `{ name, value }` item when `return-object` is set; `null` when cleared.
|
|
1102
|
+
* In `multiple` mode the whole array of picked values, in pick order
|
|
1103
|
+
* (`[]` when cleared).
|
|
1044
1104
|
*/
|
|
1045
|
-
changeValue: CustomEvent<
|
|
1105
|
+
changeValue: CustomEvent<CSelectValue>;
|
|
1046
1106
|
/**
|
|
1047
1107
|
* Native bubbling input event dispatched alongside every value change so a
|
|
1048
1108
|
* plain `v-model` stays in sync. Carries no detail.
|
|
@@ -1052,9 +1112,10 @@ export interface CSelectElementEventMap {
|
|
|
1052
1112
|
* Fired alongside `changeValue` with the same detail — the `v-model`
|
|
1053
1113
|
* contract.
|
|
1054
1114
|
*/
|
|
1055
|
-
'update:value': CustomEvent<
|
|
1115
|
+
'update:value': CustomEvent<CSelectValue>;
|
|
1056
1116
|
}
|
|
1057
|
-
|
|
1117
|
+
/** 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`. */
|
|
1118
|
+
export interface CSelectElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'errorMessage' | 'hideDetails' | 'hint' | 'hostId' | 'items' | 'itemsPerPage' | 'label' | 'labelOnTop' | 'loading' | 'maxTags' | 'multiple' | 'name' | 'optionAsSelection' | 'placeholder' | 'required' | 'returnObject' | 'selectAll' | 'shadow' | 'size' | 'texts' | 'valid' | 'value'> {
|
|
1058
1119
|
/** Make the selected value clearable */
|
|
1059
1120
|
clearable?: boolean;
|
|
1060
1121
|
/** Disable the input */
|
|
@@ -1077,6 +1138,20 @@ export interface CSelectElement extends Omit<HTMLElement, 'clearable' | 'disable
|
|
|
1077
1138
|
labelOnTop?: boolean;
|
|
1078
1139
|
/** Show loading state */
|
|
1079
1140
|
loading?: boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* In `multiple` mode, show at most this many selected-value tags and fold
|
|
1143
|
+
* the rest into one "+N more" tag; `0` shows no tags and reads "N selected"
|
|
1144
|
+
* instead; unset shows every tag
|
|
1145
|
+
*/
|
|
1146
|
+
maxTags?: number;
|
|
1147
|
+
/**
|
|
1148
|
+
* Allow selecting several options: rows toggle and the list stays open,
|
|
1149
|
+
* `value` becomes an array of the selected values (items with
|
|
1150
|
+
* `return-object`) in the order they were picked, and the picks show as
|
|
1151
|
+
* tags inside the field. `option-as-selection` is ignored in this mode.
|
|
1152
|
+
* Arrays have no attribute form — bind `value` as a DOM property
|
|
1153
|
+
*/
|
|
1154
|
+
multiple?: boolean;
|
|
1080
1155
|
/** Input field name */
|
|
1081
1156
|
name?: string;
|
|
1082
1157
|
/** Display the option as selection (only with <c-option> elements) */
|
|
@@ -1087,14 +1162,29 @@ export interface CSelectElement extends Omit<HTMLElement, 'clearable' | 'disable
|
|
|
1087
1162
|
required?: boolean;
|
|
1088
1163
|
/** Return object instead of value */
|
|
1089
1164
|
returnObject?: boolean;
|
|
1165
|
+
/**
|
|
1166
|
+
* In `multiple` mode, pin a select-all row at the top of the list. Its
|
|
1167
|
+
* checkbox shows whether none, some or all enabled options are selected;
|
|
1168
|
+
* activating it selects every enabled option — or, when all are selected,
|
|
1169
|
+
* unselects them. Ignored in single mode
|
|
1170
|
+
*/
|
|
1171
|
+
selectAll?: boolean;
|
|
1090
1172
|
/** Shadow variant */
|
|
1091
1173
|
shadow?: boolean;
|
|
1092
1174
|
/** Field height: the 44px default or the 36px `small` box */
|
|
1093
1175
|
size?: 'default' | 'small';
|
|
1176
|
+
/**
|
|
1177
|
+
* UI text overrides (i18n), merged over the English defaults. Objects have
|
|
1178
|
+
* no attribute form — bind as a DOM property (`:texts.prop` in Vue)
|
|
1179
|
+
*/
|
|
1180
|
+
texts?: CSelectTexts;
|
|
1094
1181
|
/** Set the validity of the input */
|
|
1095
1182
|
valid?: boolean;
|
|
1096
|
-
/**
|
|
1097
|
-
|
|
1183
|
+
/**
|
|
1184
|
+
* Selected value: the option's value, or the whole item with
|
|
1185
|
+
* `return-object`; an array of them in `multiple` mode
|
|
1186
|
+
*/
|
|
1187
|
+
value?: CSelectValue;
|
|
1098
1188
|
/** Reset select state */
|
|
1099
1189
|
reset(): void;
|
|
1100
1190
|
addEventListener<K extends keyof CSelectElementEventMap>(type: K, listener: (this: CSelectElement, ev: CSelectElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -1431,13 +1521,15 @@ export interface CTagElementEventMap {
|
|
|
1431
1521
|
/** Fired when the tag's close button is activated. */
|
|
1432
1522
|
close: CustomEvent<void>;
|
|
1433
1523
|
}
|
|
1434
|
-
export interface CTagElement extends Omit<HTMLElement, 'active' | 'badge' | 'closeable' | 'flat' | 'size'> {
|
|
1524
|
+
export interface CTagElement extends Omit<HTMLElement, 'active' | 'badge' | 'closeable' | 'closeLabel' | 'flat' | 'size'> {
|
|
1435
1525
|
/** Mark tag as active */
|
|
1436
1526
|
active?: boolean;
|
|
1437
1527
|
/** Display an optional badge at the start of the tag */
|
|
1438
1528
|
badge?: null | number | string;
|
|
1439
1529
|
/** Mark tag as closeable */
|
|
1440
1530
|
closeable?: boolean;
|
|
1531
|
+
/** Accessible name of the close button rendered when `closeable` */
|
|
1532
|
+
closeLabel?: string;
|
|
1441
1533
|
/** Remove the hover effect */
|
|
1442
1534
|
flat?: boolean;
|
|
1443
1535
|
/** Size of the tag */
|
package/package.json
CHANGED