@syware/jlib 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +5 -3
- package/dist/base/jl-combobox-base.css.js +3 -0
- package/dist/base/jl-combobox-base.d.ts +202 -0
- package/dist/base/jl-combobox-base.js +632 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/lib/combobox.d.ts +12 -0
- package/dist/lib/combobox.js +22 -0
- package/dist/lib/table.d.ts +24 -3
- package/dist/lib/table.js +58 -2
- package/dist/lib/texts-de.d.ts +3 -0
- package/dist/lib/texts-de.js +3 -0
- package/dist/lib/texts-fr.d.ts +3 -0
- package/dist/lib/texts-fr.js +3 -0
- package/dist/lib/texts.d.ts +3 -0
- package/dist/lib/texts.js +3 -0
- package/dist/molecules/jl-combobox.d.ts +15 -123
- package/dist/molecules/jl-combobox.js +24 -461
- package/dist/molecules/jl-multi-combobox.css.js +3 -0
- package/dist/molecules/jl-multi-combobox.d.ts +50 -0
- package/dist/molecules/jl-multi-combobox.js +176 -0
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +77 -5
- package/dist/organisms/jl-table.js +223 -23
- package/dist/types/jl-combobox.types.d.ts +5 -0
- package/dist/types/jl-table.types.d.ts +22 -0
- package/package.json +2 -1
- package/dist/molecules/jl-combobox.css.js +0 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/lib/combobox.ts
|
|
2
|
+
/** The values a combobox holds, as a list: none, one, or several with `multiple`. */
|
|
3
|
+
function heldValues(value) {
|
|
4
|
+
if (typeof value !== "string") return [...value];
|
|
5
|
+
return value === "" ? [] : [value];
|
|
6
|
+
}
|
|
7
|
+
/** The values with one taken out when it was held, or added at the end when it was not. */
|
|
8
|
+
var toggledValue = (values, value) => values.includes(value) ? values.filter((held) => held !== value) : [...values, value];
|
|
9
|
+
/** Whether two lists hold the same values in the same order. */
|
|
10
|
+
var sameValues = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
11
|
+
/**
|
|
12
|
+
* The label of each value held: its option's among the options given, else the one kept before, so a value chosen
|
|
13
|
+
* among options the page has since replaced keeps its label. A value no longer held is forgotten.
|
|
14
|
+
*/
|
|
15
|
+
function keptLabels(kept, values, options) {
|
|
16
|
+
const given = new Map(options.map((option) => [option.value, option.label]));
|
|
17
|
+
return new Map(values.flatMap((value) => {
|
|
18
|
+
const label = given.get(value) ?? kept.get(value);
|
|
19
|
+
return label === void 0 ? [] : [[value, label]];
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
export { heldValues, keptLabels, sameValues, toggledValue };
|
package/dist/lib/table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableAlign, TableCellFormat, TableCellRenderer, TableColumn, TableExpansion, TableRowKey, TableSelectionState, TableSortDirection, TableToggle } from '../types/jl-table.types';
|
|
1
|
+
import type { TableAlign, TableCellFormat, TableCellRenderer, TableColumn, TableColumnChoice, TableExpansion, TableFrozen, TableRowKey, TableSelectionState, TableSortDirection, TableToggle } from '../types/jl-table.types';
|
|
2
2
|
export declare const nextSortDirection: (direction: TableSortDirection) => TableSortDirection;
|
|
3
3
|
/** A cell's value as a number, `NaN` when it is not one. */
|
|
4
4
|
export declare function toNumber(value: unknown): number;
|
|
@@ -42,14 +42,35 @@ export declare function rowKeyOf(row: object, keyField: string, index: number):
|
|
|
42
42
|
export declare function selectionState(keys: readonly TableRowKey[], selected: ReadonlySet<TableRowKey>): TableSelectionState;
|
|
43
43
|
/** The selection after the select-all box is pressed: every row when not all were selected, else none of them. */
|
|
44
44
|
export declare function toggleAll(keys: readonly TableRowKey[], selected: ReadonlySet<TableRowKey>): TableRowKey[];
|
|
45
|
-
/** The selection with one row added or taken out. */
|
|
46
|
-
export declare function toggleKey(selected: readonly
|
|
45
|
+
/** The selection with one row added or taken out; the hidden columns with one column added or taken out. */
|
|
46
|
+
export declare function toggleKey<Key extends TableRowKey>(selected: readonly Key[], key: Key, on: boolean): Key[];
|
|
47
|
+
/** The columns drawn: those `hidden` does not name, and every column that cannot be hidden. */
|
|
48
|
+
export declare function shownColumns<Column extends Pick<TableColumn, 'hideable' | 'key'>>(columns: readonly Column[], hidden: readonly string[]): Column[];
|
|
49
|
+
/**
|
|
50
|
+
* The column chooser's lines, in the columns' order: each column shown or not, and locked when it cannot be hidden
|
|
51
|
+
* or is the last one shown, so a table never hides all its columns from its chooser.
|
|
52
|
+
*/
|
|
53
|
+
export declare function columnChoices<Column extends Pick<TableColumn, 'hideable' | 'key' | 'label'>>(columns: readonly Column[], hidden: readonly string[]): TableColumnChoice<Column['key']>[];
|
|
47
54
|
/** The rows shown open: none when rows do not open, the last one opened when they open one at a time. */
|
|
48
55
|
export declare const openRows: (expanded: readonly TableRowKey[], expansion: TableExpansion) => TableRowKey[];
|
|
49
56
|
/** The open rows after one opens or closes: one at a time, opening a row closes the one that was open. */
|
|
50
57
|
export declare const withRowOpen: (expanded: readonly TableRowKey[], key: TableRowKey, open: boolean, expansion: TableExpansion) => TableRowKey[];
|
|
51
58
|
/** What changed between two sets of open rows, as the `toggle` events to emit: the rows closed, then those opened. */
|
|
52
59
|
export declare function rowToggles(before: Iterable<TableRowKey>, after: Iterable<TableRowKey>): TableToggle[];
|
|
60
|
+
/**
|
|
61
|
+
* The cells that stay in view at each side: as many columns as asked among those shown, the end giving way to the
|
|
62
|
+
* start when they would overlap, and at the start the checkbox and chevron cells before them.
|
|
63
|
+
*/
|
|
64
|
+
export declare function frozenCells(shown: number, lead: number, asked: TableFrozen): TableFrozen;
|
|
65
|
+
/** Where each of some cells side by side stands from their edge: the widths of the cells before it, added up. */
|
|
66
|
+
export declare const stickyOffsets: (widths: readonly number[]) => number[];
|
|
67
|
+
/**
|
|
68
|
+
* The rules that keep the frozen cells in view, by their place in the row, so that rows drawn later need nothing:
|
|
69
|
+
* each cell's offset is a custom property the table measures (`--frozen-start-0`…, `--frozen-end-0`…, counted from
|
|
70
|
+
* the edge), the cells take the surface under the rows' shades, and a line marks each frozen side while the rows
|
|
71
|
+
* scroll sideways (`scrolls-sideways` on the host).
|
|
72
|
+
*/
|
|
73
|
+
export declare function frozenCss({ end, start }: TableFrozen): string;
|
|
53
74
|
/**
|
|
54
75
|
* A renderer of `renderers` written for the page's own type of row, for a table that does not say its type of row:
|
|
55
76
|
* the table hands each renderer back a row the page gave it, so
|
package/dist/lib/table.js
CHANGED
|
@@ -136,11 +136,29 @@ function toggleAll(keys, selected) {
|
|
|
136
136
|
const others = [...selected].filter((key) => !shown.has(key));
|
|
137
137
|
return selectionState(keys, selected) === "all" ? others : [...others, ...keys];
|
|
138
138
|
}
|
|
139
|
-
/** The selection with one row added or taken out. */
|
|
139
|
+
/** The selection with one row added or taken out; the hidden columns with one column added or taken out. */
|
|
140
140
|
function toggleKey(selected, key, on) {
|
|
141
141
|
const without = selected.filter((candidate) => candidate !== key);
|
|
142
142
|
return on ? [...without, key] : without;
|
|
143
143
|
}
|
|
144
|
+
/** The columns drawn: those `hidden` does not name, and every column that cannot be hidden. */
|
|
145
|
+
function shownColumns(columns, hidden) {
|
|
146
|
+
const hiddenKeys = new Set(hidden);
|
|
147
|
+
return columns.filter((column) => column.hideable === false || !hiddenKeys.has(column.key));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The column chooser's lines, in the columns' order: each column shown or not, and locked when it cannot be hidden
|
|
151
|
+
* or is the last one shown, so a table never hides all its columns from its chooser.
|
|
152
|
+
*/
|
|
153
|
+
function columnChoices(columns, hidden) {
|
|
154
|
+
const shown = new Set(shownColumns(columns, hidden).map((column) => column.key));
|
|
155
|
+
return columns.map((column) => ({
|
|
156
|
+
key: column.key,
|
|
157
|
+
label: column.label,
|
|
158
|
+
locked: column.hideable === false || shown.size === 1 && shown.has(column.key),
|
|
159
|
+
shown: shown.has(column.key)
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
144
162
|
var OPEN_ROWS = {
|
|
145
163
|
multiple: (expanded) => [...expanded],
|
|
146
164
|
none: () => [],
|
|
@@ -169,6 +187,44 @@ function rowToggles(before, after) {
|
|
|
169
187
|
}));
|
|
170
188
|
return [...closed, ...opened];
|
|
171
189
|
}
|
|
190
|
+
/** A row of data or of headings: not an open row's detail nor the empty row, whose one cell spans them all. */
|
|
191
|
+
var FROZEN_ROW = "tr:not(.detail, .empty)";
|
|
192
|
+
/**
|
|
193
|
+
* The cells that stay in view at each side: as many columns as asked among those shown, the end giving way to the
|
|
194
|
+
* start when they would overlap, and at the start the checkbox and chevron cells before them.
|
|
195
|
+
*/
|
|
196
|
+
function frozenCells(shown, lead, asked) {
|
|
197
|
+
const start = Math.min(Math.max(asked.start, 0), shown);
|
|
198
|
+
return {
|
|
199
|
+
end: Math.min(Math.max(asked.end, 0), shown - start),
|
|
200
|
+
start: start === 0 ? 0 : lead + start
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** Where each of some cells side by side stands from their edge: the widths of the cells before it, added up. */
|
|
204
|
+
var stickyOffsets = (widths) => widths.map((_, index) => widths.slice(0, index).reduce((sum, width) => sum + width, 0));
|
|
205
|
+
/**
|
|
206
|
+
* The rules that keep the frozen cells in view, by their place in the row, so that rows drawn later need nothing:
|
|
207
|
+
* each cell's offset is a custom property the table measures (`--frozen-start-0`…, `--frozen-end-0`…, counted from
|
|
208
|
+
* the edge), the cells take the surface under the rows' shades, and a line marks each frozen side while the rows
|
|
209
|
+
* scroll sideways (`scrolls-sideways` on the host).
|
|
210
|
+
*/
|
|
211
|
+
function frozenCss({ end, start }) {
|
|
212
|
+
const sides = [start > 0 ? `:nth-child(-n + ${start})` : "", end > 0 ? `:nth-last-child(-n + ${end})` : ""].filter((side) => side !== "");
|
|
213
|
+
if (sides.length === 0) return "";
|
|
214
|
+
const frozen = `${FROZEN_ROW} > :is(${sides.join(", ")})`;
|
|
215
|
+
const starts = Array.from({ length: start }, (_, index) => `${FROZEN_ROW} > :nth-child(${index + 1}) { left: var(--frozen-start-${index}); }`);
|
|
216
|
+
const ends = Array.from({ length: end }, (_, index) => `${FROZEN_ROW} > :nth-last-child(${index + 1}) { right: var(--frozen-end-${index}); }`);
|
|
217
|
+
const lines = [start > 0 ? `:host([scrolls-sideways]) ${FROZEN_ROW} > :nth-child(${start}) { border-right: 1px solid var(--jl-line); }` : "", end > 0 ? `:host([scrolls-sideways]) ${FROZEN_ROW} > :nth-last-child(${end}) { border-left: 1px solid var(--jl-line); }` : ""].filter((line) => line !== "");
|
|
218
|
+
return [
|
|
219
|
+
`${frozen} { position: sticky; }`,
|
|
220
|
+
`thead ${frozen} { z-index: 3; }`,
|
|
221
|
+
`tbody ${frozen} { z-index: 1; }`,
|
|
222
|
+
`:where(tbody ${frozen}) { background: var(--jl-surface); }`,
|
|
223
|
+
...starts,
|
|
224
|
+
...ends,
|
|
225
|
+
...lines
|
|
226
|
+
].join("\n");
|
|
227
|
+
}
|
|
172
228
|
/**
|
|
173
229
|
* A renderer of `renderers` written for the page's own type of row, for a table that does not say its type of row:
|
|
174
230
|
* the table hands each renderer back a row the page gave it, so
|
|
@@ -176,4 +232,4 @@ function rowToggles(before, after) {
|
|
|
176
232
|
* rows (`JlTable<Order>`) hands its renderers an order already.
|
|
177
233
|
*/
|
|
178
234
|
var cellOf = (draw) => (row) => draw(row);
|
|
179
|
-
export { cellOf, columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortBy, toNumber, toTime, toggleAll, toggleKey, withRowOpen };
|
|
235
|
+
export { cellOf, columnAlign, columnChoices, columnWidth, fieldOf, formatCell, frozenCells, frozenCss, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, shownColumns, sortBy, stickyOffsets, toNumber, toTime, toggleAll, toggleKey, withRowOpen };
|
package/dist/lib/texts-de.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare const _default: {
|
|
|
23
23
|
readonly close: "Schließen";
|
|
24
24
|
readonly closeMenu: "Menü schließen";
|
|
25
25
|
readonly collapseMenu: "Menü einklappen";
|
|
26
|
+
readonly columns: "Spalten";
|
|
26
27
|
readonly commandClose: "zum Schließen";
|
|
27
28
|
readonly commandMove: "zum Navigieren";
|
|
28
29
|
readonly commandPalette: "Befehlspalette";
|
|
@@ -81,6 +82,7 @@ declare const _default: {
|
|
|
81
82
|
readonly noRating: "Keine Bewertung";
|
|
82
83
|
readonly noResults: "Keine Ergebnisse";
|
|
83
84
|
readonly notifications: "Benachrichtigungen";
|
|
85
|
+
readonly oneResult: "1 Ergebnis";
|
|
84
86
|
readonly opensInNewTab: "(öffnet in neuem Tab)";
|
|
85
87
|
readonly page: "Seite";
|
|
86
88
|
readonly pageNumber: "Seite {page}";
|
|
@@ -97,6 +99,7 @@ declare const _default: {
|
|
|
97
99
|
readonly removeNamed: "{name} entfernen";
|
|
98
100
|
readonly removeValue: "Diesen Wert entfernen";
|
|
99
101
|
readonly resizePanes: "Größe der Bereiche ändern";
|
|
102
|
+
readonly resultCount: "{count} Ergebnisse";
|
|
100
103
|
readonly retry: "Erneut versuchen";
|
|
101
104
|
readonly search: "Suchen";
|
|
102
105
|
readonly selectAllRows: "Alle Zeilen auswählen";
|
package/dist/lib/texts-de.js
CHANGED
|
@@ -26,6 +26,7 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
26
26
|
close: "Schließen",
|
|
27
27
|
closeMenu: "Menü schließen",
|
|
28
28
|
collapseMenu: "Menü einklappen",
|
|
29
|
+
columns: "Spalten",
|
|
29
30
|
commandClose: "zum Schließen",
|
|
30
31
|
commandMove: "zum Navigieren",
|
|
31
32
|
commandPalette: "Befehlspalette",
|
|
@@ -84,6 +85,7 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
84
85
|
noRating: "Keine Bewertung",
|
|
85
86
|
noResults: "Keine Ergebnisse",
|
|
86
87
|
notifications: "Benachrichtigungen",
|
|
88
|
+
oneResult: "1 Ergebnis",
|
|
87
89
|
opensInNewTab: "(öffnet in neuem Tab)",
|
|
88
90
|
page: "Seite",
|
|
89
91
|
pageNumber: "Seite {page}",
|
|
@@ -100,6 +102,7 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
100
102
|
removeNamed: "{name} entfernen",
|
|
101
103
|
removeValue: "Diesen Wert entfernen",
|
|
102
104
|
resizePanes: "Größe der Bereiche ändern",
|
|
105
|
+
resultCount: "{count} Ergebnisse",
|
|
103
106
|
retry: "Erneut versuchen",
|
|
104
107
|
search: "Suchen",
|
|
105
108
|
selectAllRows: "Alle Zeilen auswählen",
|
package/dist/lib/texts-fr.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare const _default: {
|
|
|
23
23
|
readonly close: "Fermer";
|
|
24
24
|
readonly closeMenu: "Fermer le menu";
|
|
25
25
|
readonly collapseMenu: "Replier le menu";
|
|
26
|
+
readonly columns: "Colonnes";
|
|
26
27
|
readonly commandClose: "pour fermer";
|
|
27
28
|
readonly commandMove: "pour naviguer";
|
|
28
29
|
readonly commandPalette: "Palette de commandes";
|
|
@@ -81,6 +82,7 @@ declare const _default: {
|
|
|
81
82
|
readonly noRating: "Aucune note";
|
|
82
83
|
readonly noResults: "Aucun résultat";
|
|
83
84
|
readonly notifications: "Notifications";
|
|
85
|
+
readonly oneResult: "1 résultat";
|
|
84
86
|
readonly opensInNewTab: "(s'ouvre dans un nouvel onglet)";
|
|
85
87
|
readonly page: "Page";
|
|
86
88
|
readonly pageNumber: "Page {page}";
|
|
@@ -97,6 +99,7 @@ declare const _default: {
|
|
|
97
99
|
readonly removeNamed: "Retirer {name}";
|
|
98
100
|
readonly removeValue: "Retirer cette valeur";
|
|
99
101
|
readonly resizePanes: "Redimensionner les panneaux";
|
|
102
|
+
readonly resultCount: "{count} résultats";
|
|
100
103
|
readonly retry: "Réessayer";
|
|
101
104
|
readonly search: "Rechercher";
|
|
102
105
|
readonly selectAllRows: "Sélectionner toutes les lignes";
|
package/dist/lib/texts-fr.js
CHANGED
|
@@ -26,6 +26,7 @@ var texts_fr_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
26
26
|
close: "Fermer",
|
|
27
27
|
closeMenu: "Fermer le menu",
|
|
28
28
|
collapseMenu: "Replier le menu",
|
|
29
|
+
columns: "Colonnes",
|
|
29
30
|
commandClose: "pour fermer",
|
|
30
31
|
commandMove: "pour naviguer",
|
|
31
32
|
commandPalette: "Palette de commandes",
|
|
@@ -84,6 +85,7 @@ var texts_fr_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
84
85
|
noRating: "Aucune note",
|
|
85
86
|
noResults: "Aucun résultat",
|
|
86
87
|
notifications: "Notifications",
|
|
88
|
+
oneResult: "1 résultat",
|
|
87
89
|
opensInNewTab: "(s'ouvre dans un nouvel onglet)",
|
|
88
90
|
page: "Page",
|
|
89
91
|
pageNumber: "Page {page}",
|
|
@@ -100,6 +102,7 @@ var texts_fr_default = defineTranslations(DEFAULT_TEXTS, {
|
|
|
100
102
|
removeNamed: "Retirer {name}",
|
|
101
103
|
removeValue: "Retirer cette valeur",
|
|
102
104
|
resizePanes: "Redimensionner les panneaux",
|
|
105
|
+
resultCount: "{count} résultats",
|
|
103
106
|
retry: "Réessayer",
|
|
104
107
|
search: "Rechercher",
|
|
105
108
|
selectAllRows: "Sélectionner toutes les lignes",
|
package/dist/lib/texts.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare const DEFAULT_TEXTS: {
|
|
|
31
31
|
readonly close: "Close";
|
|
32
32
|
readonly closeMenu: "Close the menu";
|
|
33
33
|
readonly collapseMenu: "Collapse the menu";
|
|
34
|
+
readonly columns: "Columns";
|
|
34
35
|
readonly commandClose: "to close";
|
|
35
36
|
readonly commandMove: "to move";
|
|
36
37
|
readonly commandPalette: "Command palette";
|
|
@@ -89,6 +90,7 @@ export declare const DEFAULT_TEXTS: {
|
|
|
89
90
|
readonly noRating: "No rating";
|
|
90
91
|
readonly noResults: "No results";
|
|
91
92
|
readonly notifications: "Notifications";
|
|
93
|
+
readonly oneResult: "1 result";
|
|
92
94
|
readonly opensInNewTab: "(opens in a new tab)";
|
|
93
95
|
readonly page: "Page";
|
|
94
96
|
readonly pageNumber: "Page {page}";
|
|
@@ -105,6 +107,7 @@ export declare const DEFAULT_TEXTS: {
|
|
|
105
107
|
readonly removeNamed: "Remove {name}";
|
|
106
108
|
readonly removeValue: "Remove this value";
|
|
107
109
|
readonly resizePanes: "Resize the panes";
|
|
110
|
+
readonly resultCount: "{count} results";
|
|
108
111
|
readonly retry: "Try again";
|
|
109
112
|
readonly search: "Search";
|
|
110
113
|
readonly selectAllRows: "Select all rows";
|
package/dist/lib/texts.js
CHANGED
|
@@ -38,6 +38,7 @@ var DEFAULT_TEXTS = defineTranslations({
|
|
|
38
38
|
close: "Close",
|
|
39
39
|
closeMenu: "Close the menu",
|
|
40
40
|
collapseMenu: "Collapse the menu",
|
|
41
|
+
columns: "Columns",
|
|
41
42
|
commandClose: "to close",
|
|
42
43
|
commandMove: "to move",
|
|
43
44
|
commandPalette: "Command palette",
|
|
@@ -96,6 +97,7 @@ var DEFAULT_TEXTS = defineTranslations({
|
|
|
96
97
|
noRating: "No rating",
|
|
97
98
|
noResults: "No results",
|
|
98
99
|
notifications: "Notifications",
|
|
100
|
+
oneResult: "1 result",
|
|
99
101
|
opensInNewTab: "(opens in a new tab)",
|
|
100
102
|
page: "Page",
|
|
101
103
|
pageNumber: "Page {page}",
|
|
@@ -112,6 +114,7 @@ var DEFAULT_TEXTS = defineTranslations({
|
|
|
112
114
|
removeNamed: "Remove {name}",
|
|
113
115
|
removeValue: "Remove this value",
|
|
114
116
|
resizePanes: "Resize the panes",
|
|
117
|
+
resultCount: "{count} results",
|
|
115
118
|
retry: "Try again",
|
|
116
119
|
search: "Search",
|
|
117
120
|
selectAllRows: "Select all rows",
|
|
@@ -1,130 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JlComboboxBase } from '../base/jl-combobox-base';
|
|
2
2
|
import type { ComboboxOption } from '../types/jl-combobox.types';
|
|
3
|
-
|
|
3
|
+
export { COMBOBOX_FILTERS } from '../base/jl-combobox-base';
|
|
4
4
|
/**
|
|
5
5
|
* A text field with a list of options that narrows as people type; they choose with the arrows and Enter, or with
|
|
6
6
|
* the pointer. The field shows the option's label, `value` and the form hold its value. With `allow-custom`, the
|
|
7
|
-
* text people type becomes the value when no option matches it.
|
|
7
|
+
* text people type becomes the value when no option matches it. With `filter="none"` the page finds the options
|
|
8
|
+
* (on `input`, which `debounce` holds back while people type) and shows `loading` meanwhile. For several values,
|
|
9
|
+
* `jl-multi-combobox`.
|
|
8
10
|
*/
|
|
9
|
-
export declare class JlCombobox extends
|
|
11
|
+
export declare class JlCombobox extends JlComboboxBase<string> {
|
|
10
12
|
static readonly selector = "jl-combobox";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly value: Readonly<Readonly<{
|
|
21
|
-
get(): string;
|
|
22
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
23
|
-
}>>;
|
|
24
|
-
readonly placeholder: Readonly<Readonly<{
|
|
25
|
-
get(): string;
|
|
26
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
27
|
-
}>>;
|
|
28
|
-
/** The field's name for screen readers, when no visible label names it. */
|
|
29
|
-
readonly label: Readonly<Readonly<{
|
|
30
|
-
get(): string;
|
|
31
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
32
|
-
}>>;
|
|
33
|
-
/** Takes the typed text as the value when no option has it as its label. */
|
|
34
|
-
readonly allowCustom: Readonly<Readonly<{
|
|
35
|
-
get(): boolean;
|
|
36
|
-
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
37
|
-
}>>;
|
|
38
|
-
/** Shows a button that empties the field while it holds text. */
|
|
39
|
-
readonly clearable: Readonly<Readonly<{
|
|
40
|
-
get(): boolean;
|
|
41
|
-
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
42
|
-
}>>;
|
|
43
|
-
/** What the list says when no option matches; jlib's own when empty. */
|
|
44
|
-
readonly emptyText: Readonly<Readonly<{
|
|
45
|
-
get(): string;
|
|
46
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
47
|
-
}>>;
|
|
48
|
-
readonly required: Readonly<Readonly<{
|
|
49
|
-
get(): boolean;
|
|
50
|
-
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
51
|
-
}>>;
|
|
52
|
-
readonly disabled: Readonly<Readonly<{
|
|
53
|
-
get(): boolean;
|
|
54
|
-
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
55
|
-
}>>;
|
|
56
|
-
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
57
|
-
readonly invalid: Readonly<Readonly<{
|
|
58
|
-
get(): boolean;
|
|
59
|
-
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
60
|
-
}>>;
|
|
61
|
-
readonly size: Readonly<Readonly<{
|
|
62
|
-
get(): ControlSize;
|
|
63
|
-
set(setter: ((prevState: ControlSize) => ControlSize) | ControlSize): void;
|
|
64
|
-
}>>;
|
|
65
|
-
private readonly _listId;
|
|
66
|
-
private readonly _state;
|
|
67
|
-
private readonly _items;
|
|
68
|
-
private readonly _refs;
|
|
69
|
-
focus(options?: FocusOptions): void;
|
|
70
|
-
templateHtml(): Node;
|
|
71
|
-
templateCss(): string;
|
|
72
|
-
onConnect(): void;
|
|
73
|
-
onDisconnect(): void;
|
|
74
|
-
protected resetValue(): void;
|
|
75
|
-
protected setDisabledByForm(disabled: boolean): void;
|
|
76
|
-
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
77
|
-
private isOff;
|
|
78
|
-
protected drawTexts(): void;
|
|
79
|
-
private renderEmptyText;
|
|
80
|
-
private isOpen;
|
|
81
|
-
private onType;
|
|
82
|
-
private onKey;
|
|
83
|
-
/** Down opens the list or moves down it; Alt + Down opens it as it is, Alt + Up closes it. */
|
|
84
|
-
private onArrow;
|
|
85
|
-
private toggleWithAlt;
|
|
86
|
-
/** Enter chooses the active option; with free text allowed, it takes the text. It submits the form otherwise. */
|
|
87
|
-
private onEnter;
|
|
88
|
-
/** Escape closes the list, then a second one brings back the chosen option's label over unfinished typing. */
|
|
89
|
-
private onEscape;
|
|
90
|
-
/** Tab takes the option the arrows reached, and lets the focus move on. */
|
|
91
|
-
private onTab;
|
|
92
|
-
private toggleList;
|
|
93
|
-
/**
|
|
94
|
-
* Opens the list, or refreshes it, for what was typed. While typing, the first match is active, so Enter takes
|
|
95
|
-
* it; otherwise the chosen option is. With free text allowed and nothing matching, the list stays closed.
|
|
96
|
-
*/
|
|
97
|
-
private openList;
|
|
98
|
-
private showPopup;
|
|
99
|
-
private closeList;
|
|
100
|
-
private chosenIndex;
|
|
101
|
-
private activateEdgeIfNone;
|
|
102
|
-
private moveActive;
|
|
103
|
-
private optionAt;
|
|
104
|
-
private hover;
|
|
105
|
-
private choose;
|
|
106
|
-
/** Leaving the field, or Enter on typed text: an option with that label, free text, nothing, or back as it was. */
|
|
107
|
-
private commitText;
|
|
108
|
-
private optionWithLabel;
|
|
109
|
-
/** Sets the value as people chose it, and says so when it changed. */
|
|
110
|
-
private commit;
|
|
111
|
-
private clearValue;
|
|
112
|
-
/** New options: the field may now show the value's label, and an open list (or one being typed in) refreshes. */
|
|
113
|
-
private renderOptionsChange;
|
|
114
|
-
/** The options that match what was typed, in their order: elements already made are moved, not made again. */
|
|
115
|
-
private renderOptions;
|
|
116
|
-
/** The option's element, made once, with where it now sits, whether it is chosen, and the typed text marked. */
|
|
117
|
-
private drawOption;
|
|
118
|
-
private optionNode;
|
|
119
|
-
/** The active option is the one the arrows reached: aria-selected and aria-activedescendant follow it. */
|
|
120
|
-
private renderActive;
|
|
121
|
-
private revealActive;
|
|
122
|
-
/** The label of the value's option (or the value itself, as free text), unless people are typing. */
|
|
123
|
-
private renderValue;
|
|
124
|
-
private displayOf;
|
|
125
|
-
private renderValidity;
|
|
126
|
-
private renderClear;
|
|
127
|
-
private renderDisabled;
|
|
128
|
-
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
129
|
-
private drawDisabled;
|
|
13
|
+
protected shaped(values: string[]): string;
|
|
14
|
+
protected parseValue(text: string | null): string;
|
|
15
|
+
/** A choice closes the list, and the field shows the option's label. */
|
|
16
|
+
protected chooseOption(option: ComboboxOption): void;
|
|
17
|
+
/** Typed text: an option with that label, free text, nothing, or back as it was. */
|
|
18
|
+
protected commitTyped(text: string): void;
|
|
19
|
+
/** The label of the value's option, the one kept from when it was chosen, or the free text. */
|
|
20
|
+
protected fieldText(): string;
|
|
21
|
+
protected renderFormValue(): void;
|
|
130
22
|
}
|