@itrocks/list 0.27.1 → 0.28.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 +3 -7
- package/build.d.ts +1 -1
- package/build.js +1 -1
- package/cjs/filter-summary.html +2 -1
- package/cjs/list.html +3 -8
- package/list.css +47 -64
- package/package.json +1 -1
- package/search-focus.js +15 -1
- package/toolbar.js +11 -5
- package/search-menu.d.ts +0 -1
- package/search-menu.js +0 -140
package/README.md
CHANGED
|
@@ -102,13 +102,9 @@ For `json()`, the scope is passed directly to `dataSource().search()`.
|
|
|
102
102
|
|
|
103
103
|
## Search filters
|
|
104
104
|
|
|
105
|
-
The
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Reset clears all filters, including saved filters for hidden columns, and reloads the list without changing its sorting
|
|
109
|
-
or column configuration. The menu does not change the selection column's width.
|
|
110
|
-
Arrow Down, the context-menu key or Shift+F10 on the button also opens the menu. Use arrow keys to select an action,
|
|
111
|
-
Enter or Space to activate it, and Escape to close it. Clicking outside dismisses the menu.
|
|
105
|
+
The filter button in the first column submits the column filters, as does Enter in a filter field.
|
|
106
|
+
When the toolbar shows a filter, the reset button appears immediately to its right.
|
|
107
|
+
Reset clears all filters, including saved filters for hidden columns, and reloads the list with its current sorting and columns.
|
|
112
108
|
|
|
113
109
|
HTML list filters interpret the first hyphen as an interval separator. Spaces around the bounds are ignored:
|
|
114
110
|
|
package/build.d.ts
CHANGED
package/build.js
CHANGED
|
@@ -10,7 +10,7 @@ import { TableLink } from '@itrocks/table/link.js';
|
|
|
10
10
|
import { tableByElement } from '@itrocks/table/table.js';
|
|
11
11
|
import { xTargetCall } from '@itrocks/xtarget/xtarget.js';
|
|
12
12
|
import './column-filter.js';
|
|
13
|
-
import './search-
|
|
13
|
+
import './search-focus.js';
|
|
14
14
|
import './toolbar.js';
|
|
15
15
|
build('article[data-action="list"] > form > table.objects', table => {
|
|
16
16
|
let persistedColumns = [...table.querySelectorAll('thead th[data-property]')]
|
package/cjs/filter-summary.html
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<!--criteria-->
|
|
2
2
|
<span class="list-filter-icon" aria-hidden="true"></span>
|
|
3
3
|
<span aria-label="Active list filters" class="list-filter-text" role="group"
|
|
4
|
-
><!--items--><code
|
|
4
|
+
><!--items--><code class="list-filter-criterion"
|
|
5
|
+
>{caption}<span class="list-filter-value">{value}</span></code>{space}<!--end--></span>
|
|
5
6
|
<!--end-->
|
package/cjs/list.html
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
</ul>
|
|
28
28
|
<div class="list-filter">
|
|
29
29
|
<!--filterBar-->{{template}}<!--end-->
|
|
30
|
+
<button aria-label="Reset search filters" class="list-filter-reset" title="Reset search filters"
|
|
31
|
+
type="button">×</button>
|
|
30
32
|
</div>
|
|
31
33
|
<div class="summary">{count} elements</div>
|
|
32
34
|
<button class="add-column" hidden type="button" aria-label="Add column">+</button>
|
|
@@ -53,14 +55,7 @@
|
|
|
53
55
|
{./feed.html}
|
|
54
56
|
</tbody>
|
|
55
57
|
</table>
|
|
56
|
-
<
|
|
57
|
-
<button class="search" role="menuitem" tabindex="-1" type="submit">
|
|
58
|
-
Search
|
|
59
|
-
</button>
|
|
60
|
-
<button class="reset" name="reset" role="menuitem" tabindex="-1" type="submit" value="reset">
|
|
61
|
-
Reset search filters
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
58
|
+
<button hidden name="reset" type="submit" value="reset">Reset search filters</button>
|
|
64
59
|
<footer>
|
|
65
60
|
<ul class="selection actions">
|
|
66
61
|
<!--selection--><!--footer-->{{template}}<!--end--><!--end-->
|
package/list.css
CHANGED
|
@@ -211,15 +211,26 @@ table.objects > thead > tr.properties > th > input:not([type=checkbox]) {
|
|
|
211
211
|
width: 100%;
|
|
212
212
|
}
|
|
213
213
|
table.objects > thead > tr.properties > th > input.search-submit {
|
|
214
|
-
background: url("
|
|
214
|
+
background: url("filter.svg") center/18px no-repeat;
|
|
215
215
|
color: transparent;
|
|
216
216
|
cursor: pointer;
|
|
217
217
|
font-size: 0;
|
|
218
218
|
padding: 0;
|
|
219
219
|
touch-action: manipulation;
|
|
220
|
+
-webkit-tap-highlight-color: transparent;
|
|
220
221
|
-webkit-touch-callout: none;
|
|
221
222
|
width: 28px;
|
|
222
223
|
}
|
|
224
|
+
table.objects > thead > tr.properties > th > input.search-submit:hover, table.objects > thead > tr.properties > th > input.search-submit:focus, table.objects > thead > tr.properties > th > input.search-submit:active {
|
|
225
|
+
background-color: #e3e3e3;
|
|
226
|
+
}
|
|
227
|
+
table.objects > thead > tr.properties > th > input.search-submit:focus {
|
|
228
|
+
outline: none;
|
|
229
|
+
}
|
|
230
|
+
table.objects > thead > tr.properties > th > input.search-submit:focus-visible {
|
|
231
|
+
outline: 1px solid #808080;
|
|
232
|
+
outline-offset: -1px;
|
|
233
|
+
}
|
|
223
234
|
table.objects > thead > tr.properties > th > input[data-property-filter] {
|
|
224
235
|
border-left: 1px solid #d8d8d8;
|
|
225
236
|
margin-left: -0.6em;
|
|
@@ -240,59 +251,15 @@ table.objects > thead > tr.properties > th > input[data-property-filter][data-fi
|
|
|
240
251
|
table.objects > thead > tr.properties > th[data-sort] > input[data-property-filter] {
|
|
241
252
|
width: calc(100% + 1.2em + 16px);
|
|
242
253
|
}
|
|
243
|
-
table.objects > thead > tr.properties > th > input:focus {
|
|
254
|
+
table.objects > thead > tr.properties > th > input:focus:not(.search-submit) {
|
|
244
255
|
box-shadow: inset 0 0 0 2px Highlight, var(--column-reorder-tint, 0 0 transparent);
|
|
245
256
|
outline: none;
|
|
246
257
|
}
|
|
247
258
|
|
|
248
|
-
article[data-action=list] > form > .search-menu {
|
|
249
|
-
background: white;
|
|
250
|
-
border: 1px solid #ccc;
|
|
251
|
-
border-radius: 4px;
|
|
252
|
-
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
|
|
253
|
-
color: #333;
|
|
254
|
-
inset: auto;
|
|
255
|
-
margin: 0;
|
|
256
|
-
max-height: calc(100dvh - 8px);
|
|
257
|
-
max-width: calc(100vw - 8px);
|
|
258
|
-
padding: 4px;
|
|
259
|
-
position: fixed;
|
|
260
|
-
}
|
|
261
|
-
article[data-action=list] > form > .search-menu > button {
|
|
262
|
-
align-items: center;
|
|
263
|
-
background: none;
|
|
264
|
-
border: 0;
|
|
265
|
-
border-radius: 2px;
|
|
266
|
-
color: inherit;
|
|
267
|
-
cursor: pointer;
|
|
268
|
-
display: flex;
|
|
269
|
-
font: inherit;
|
|
270
|
-
gap: 10px;
|
|
271
|
-
min-height: 44px;
|
|
272
|
-
padding: 8px 12px;
|
|
273
|
-
text-align: left;
|
|
274
|
-
width: 100%;
|
|
275
|
-
}
|
|
276
|
-
article[data-action=list] > form > .search-menu > button::before {
|
|
277
|
-
background: currentColor;
|
|
278
|
-
content: "";
|
|
279
|
-
flex: 0 0 24px;
|
|
280
|
-
height: 24px;
|
|
281
|
-
mask: url("search.svg") center/contain no-repeat;
|
|
282
|
-
}
|
|
283
|
-
article[data-action=list] > form > .search-menu > button.reset::before {
|
|
284
|
-
mask-image: url("filter-reset.svg");
|
|
285
|
-
}
|
|
286
|
-
article[data-action=list] > form > .search-menu > button:focus-visible, article[data-action=list] > form > .search-menu > button:hover {
|
|
287
|
-
background: #eee;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
259
|
main > article[data-action=list] > header > .list-toolbar {
|
|
291
|
-
--list-toolbar-gap: 5px;
|
|
292
260
|
align-items: center;
|
|
293
261
|
border-bottom: 1px solid #ccc;
|
|
294
262
|
display: grid;
|
|
295
|
-
gap: var(--list-toolbar-gap);
|
|
296
263
|
grid-template-areas: "actions filter count add";
|
|
297
264
|
grid-template-columns: auto minmax(0, 1fr) auto max-content;
|
|
298
265
|
}
|
|
@@ -301,7 +268,6 @@ main > article[data-action=list] > header > .list-toolbar:has(> .add-column[hidd
|
|
|
301
268
|
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
302
269
|
}
|
|
303
270
|
main > article[data-action=list] > header > .list-toolbar[data-filter-row] {
|
|
304
|
-
gap: 0;
|
|
305
271
|
grid-template-areas: "actions count count" "filter filter add";
|
|
306
272
|
grid-template-columns: minmax(0, 1fr) auto max-content;
|
|
307
273
|
}
|
|
@@ -309,11 +275,9 @@ main > article[data-action=list] > header > .list-toolbar[data-filter-row]:has(>
|
|
|
309
275
|
grid-template-areas: "actions count" "filter filter";
|
|
310
276
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
311
277
|
}
|
|
312
|
-
main > article[data-action=list] > header > .list-toolbar[data-filter-row] >
|
|
278
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .general.actions {
|
|
313
279
|
align-self: stretch;
|
|
314
280
|
border-bottom: 1px solid #ccc;
|
|
315
|
-
}
|
|
316
|
-
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .general.actions {
|
|
317
281
|
flex-wrap: wrap;
|
|
318
282
|
overflow-x: auto;
|
|
319
283
|
}
|
|
@@ -321,9 +285,7 @@ main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .li
|
|
|
321
285
|
align-self: stretch;
|
|
322
286
|
}
|
|
323
287
|
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .summary {
|
|
324
|
-
|
|
325
|
-
justify-self: stretch;
|
|
326
|
-
text-align: end;
|
|
288
|
+
border-bottom: 1px solid #ccc;
|
|
327
289
|
}
|
|
328
290
|
main > article[data-action=list] > header > .list-toolbar > .add-column {
|
|
329
291
|
align-self: stretch;
|
|
@@ -343,23 +305,24 @@ main > article[data-action=list] > header > .list-toolbar > .add-column:hover {
|
|
|
343
305
|
}
|
|
344
306
|
main > article[data-action=list] > header > .list-toolbar > .list-filter {
|
|
345
307
|
grid-area: filter;
|
|
346
|
-
padding-inline: 5px;
|
|
347
308
|
}
|
|
348
309
|
main > article[data-action=list] > header > .list-toolbar > .general.actions {
|
|
349
310
|
border-bottom: 0;
|
|
350
311
|
flex-wrap: nowrap;
|
|
351
312
|
grid-area: actions;
|
|
352
313
|
min-width: 0;
|
|
314
|
+
padding-inline-end: 0;
|
|
353
315
|
}
|
|
354
316
|
main > article[data-action=list] > header > .list-toolbar > .general.actions > li {
|
|
355
317
|
flex: none;
|
|
356
318
|
white-space: nowrap;
|
|
357
319
|
}
|
|
358
320
|
main > article[data-action=list] > header > .list-toolbar > .summary {
|
|
359
|
-
|
|
321
|
+
align-content: center;
|
|
322
|
+
align-self: stretch;
|
|
360
323
|
grid-area: count;
|
|
361
|
-
|
|
362
|
-
|
|
324
|
+
padding-inline: 4px 10px;
|
|
325
|
+
text-align: end;
|
|
363
326
|
white-space: nowrap;
|
|
364
327
|
}
|
|
365
328
|
|
|
@@ -367,23 +330,40 @@ main > article[data-action=list] > header > .list-toolbar > .summary {
|
|
|
367
330
|
align-items: center;
|
|
368
331
|
display: flex;
|
|
369
332
|
flex: 1;
|
|
370
|
-
gap: 0.4em;
|
|
371
333
|
min-width: 0;
|
|
372
334
|
}
|
|
373
335
|
.list-filter .list-filter-icon {
|
|
374
|
-
background: url("filter.svg") center/
|
|
375
|
-
|
|
376
|
-
|
|
336
|
+
background: url("filter.svg") center/18px no-repeat;
|
|
337
|
+
}
|
|
338
|
+
.list-filter span.list-filter-icon {
|
|
377
339
|
flex: none;
|
|
378
340
|
height: 18px;
|
|
379
|
-
padding: 0;
|
|
380
341
|
width: 18px;
|
|
381
342
|
}
|
|
382
|
-
.list-filter button.list-filter-icon {
|
|
343
|
+
.list-filter button.list-filter-icon, .list-filter > .list-filter-reset {
|
|
344
|
+
border: 0;
|
|
345
|
+
border-radius: 2px;
|
|
383
346
|
cursor: pointer;
|
|
347
|
+
flex: none;
|
|
348
|
+
height: 36px;
|
|
349
|
+
padding: 0;
|
|
350
|
+
touch-action: manipulation;
|
|
351
|
+
width: 32px;
|
|
352
|
+
}
|
|
353
|
+
.list-filter button.list-filter-icon:hover, .list-filter > .list-filter-reset:hover {
|
|
354
|
+
background-color: #eee;
|
|
355
|
+
}
|
|
356
|
+
.list-filter > .list-filter-reset {
|
|
357
|
+
background: transparent;
|
|
358
|
+
color: #666;
|
|
359
|
+
display: none;
|
|
360
|
+
font-size: 22px;
|
|
361
|
+
line-height: 1;
|
|
362
|
+
}
|
|
363
|
+
.list-filter:has(.list-filter-text:not([data-filled=false])) > .list-filter-reset {
|
|
364
|
+
display: block;
|
|
384
365
|
}
|
|
385
366
|
.list-filter .list-filter-text {
|
|
386
|
-
border-bottom: 1px dotted #888;
|
|
387
367
|
flex: 1;
|
|
388
368
|
min-width: 0;
|
|
389
369
|
overflow-x: auto;
|
|
@@ -392,6 +372,9 @@ main > article[data-action=list] > header > .list-toolbar > .summary {
|
|
|
392
372
|
.list-filter code {
|
|
393
373
|
font: inherit;
|
|
394
374
|
}
|
|
375
|
+
.list-filter .list-filter-criterion {
|
|
376
|
+
text-decoration: underline dotted #888;
|
|
377
|
+
}
|
|
395
378
|
.list-filter .list-filter-value {
|
|
396
379
|
background: #d5edff;
|
|
397
380
|
color: #12365b;
|
package/package.json
CHANGED
package/search-focus.js
CHANGED
|
@@ -12,9 +12,14 @@ build({
|
|
|
12
12
|
return;
|
|
13
13
|
bound.add(form);
|
|
14
14
|
let column;
|
|
15
|
+
form.querySelector('.search-submit')?.addEventListener('pointerdown', event => {
|
|
16
|
+
if (event.isPrimary && event.button === 0 && focusedColumn(form)) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
15
20
|
form.addEventListener('submit', event => {
|
|
16
21
|
const submitter = event.submitter;
|
|
17
|
-
column = (!submitter || submitter.matches('.search-submit
|
|
22
|
+
column = (!submitter || submitter.matches('.search-submit'))
|
|
18
23
|
? focusedColumn(form)?.name.slice('search.'.length)
|
|
19
24
|
: undefined;
|
|
20
25
|
}, { capture: true });
|
|
@@ -37,3 +42,12 @@ build({
|
|
|
37
42
|
priority: 2000,
|
|
38
43
|
selector: 'article[data-action="list"] > form'
|
|
39
44
|
});
|
|
45
|
+
build('.list-filter > .list-filter-reset', 'click', function () {
|
|
46
|
+
const form = this.closest('article[data-action="list"]')?.querySelector(':scope > form');
|
|
47
|
+
if (!form)
|
|
48
|
+
return;
|
|
49
|
+
const reset = form.querySelector('button[name="reset"]');
|
|
50
|
+
if (reset) {
|
|
51
|
+
form.requestSubmit(reset);
|
|
52
|
+
}
|
|
53
|
+
});
|
package/toolbar.js
CHANGED
|
@@ -14,13 +14,14 @@ function contentWidth(element, style) {
|
|
|
14
14
|
}
|
|
15
15
|
function filterWidth(filter) {
|
|
16
16
|
const icon = filter.querySelector('.list-filter-icon');
|
|
17
|
-
|
|
17
|
+
const filterStyle = getComputedStyle(filter);
|
|
18
|
+
let width = inlineEdges(filterStyle);
|
|
18
19
|
if (!icon)
|
|
19
20
|
return width;
|
|
20
21
|
const text = filter.querySelector('.list-filter-text');
|
|
21
22
|
const row = icon.parentElement;
|
|
22
23
|
width += icon.getBoundingClientRect().width;
|
|
23
|
-
const rowStyle = getComputedStyle(row);
|
|
24
|
+
const rowStyle = row === filter ? filterStyle : getComputedStyle(row);
|
|
24
25
|
if (row !== filter) {
|
|
25
26
|
width += inlineEdges(rowStyle);
|
|
26
27
|
}
|
|
@@ -28,6 +29,10 @@ function filterWidth(filter) {
|
|
|
28
29
|
const textStyle = getComputedStyle(text);
|
|
29
30
|
width += gapWidth(rowStyle, 2) + Math.max(contentWidth(text, textStyle), pixels(textStyle.minWidth));
|
|
30
31
|
}
|
|
32
|
+
const resetWidth = filter.querySelector('.list-filter-reset')?.getBoundingClientRect().width ?? 0;
|
|
33
|
+
if (resetWidth) {
|
|
34
|
+
width += gapWidth(filterStyle, 2) + resetWidth;
|
|
35
|
+
}
|
|
31
36
|
return width;
|
|
32
37
|
}
|
|
33
38
|
function gapWidth(style, items) {
|
|
@@ -53,9 +58,8 @@ function watchToolbar(toolbar) {
|
|
|
53
58
|
frame = undefined;
|
|
54
59
|
const style = getComputedStyle(toolbar);
|
|
55
60
|
const available = toolbar.getBoundingClientRect().width - inlineEdges(style);
|
|
56
|
-
const gaps = (add.hidden ? 2 : 3) * pixels(style.getPropertyValue('--list-toolbar-gap'));
|
|
57
61
|
const required = actionsWidth(actions) + filterWidth(filter) + contentWidth(count, getComputedStyle(count))
|
|
58
|
-
+ add.getBoundingClientRect().width
|
|
62
|
+
+ add.getBoundingClientRect().width;
|
|
59
63
|
toolbar.toggleAttribute('data-filter-row', required > available);
|
|
60
64
|
}
|
|
61
65
|
function schedule() {
|
|
@@ -66,7 +70,9 @@ function watchToolbar(toolbar) {
|
|
|
66
70
|
resize.observe(element);
|
|
67
71
|
}
|
|
68
72
|
const mutations = new MutationObserver(schedule);
|
|
69
|
-
mutations.observe(toolbar, {
|
|
73
|
+
mutations.observe(toolbar, {
|
|
74
|
+
attributeFilter: ['data-filled', 'hidden'], characterData: true, childList: true, subtree: true
|
|
75
|
+
});
|
|
70
76
|
for (const event of ['focusin', 'focusout', 'input']) {
|
|
71
77
|
toolbar.addEventListener(event, schedule, { signal: abort.signal });
|
|
72
78
|
}
|
package/search-menu.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/search-menu.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { build } from '@itrocks/build/build.js';
|
|
2
|
-
import { focusedColumn } from './search-focus.js';
|
|
3
|
-
const bound = new WeakSet();
|
|
4
|
-
build('article[data-action="list"] > form', form => {
|
|
5
|
-
if (bound.has(form))
|
|
6
|
-
return;
|
|
7
|
-
const trigger = form.querySelector('.search-submit');
|
|
8
|
-
const menu = form.querySelector('.search-menu');
|
|
9
|
-
if (!trigger || !menu)
|
|
10
|
-
return;
|
|
11
|
-
bound.add(form);
|
|
12
|
-
const items = Array.from(menu.querySelectorAll('[role="menuitem"]'));
|
|
13
|
-
let listeners;
|
|
14
|
-
let pointer;
|
|
15
|
-
let suppressClick = false;
|
|
16
|
-
let timer;
|
|
17
|
-
const cancel = () => {
|
|
18
|
-
clearTimeout(timer);
|
|
19
|
-
pointer = undefined;
|
|
20
|
-
};
|
|
21
|
-
const dismiss = () => {
|
|
22
|
-
if (!menu.matches(':popover-open'))
|
|
23
|
-
return;
|
|
24
|
-
menu.hidePopover();
|
|
25
|
-
trigger.setAttribute('aria-expanded', 'false');
|
|
26
|
-
listeners?.abort();
|
|
27
|
-
};
|
|
28
|
-
const close = () => {
|
|
29
|
-
dismiss();
|
|
30
|
-
trigger.focus();
|
|
31
|
-
};
|
|
32
|
-
const open = () => {
|
|
33
|
-
cancel();
|
|
34
|
-
if (!trigger.isConnected || menu.matches(':popover-open'))
|
|
35
|
-
return;
|
|
36
|
-
// A manual popover stays open when the opening right-click or long press is released.
|
|
37
|
-
menu.showPopover();
|
|
38
|
-
const rect = trigger.getBoundingClientRect();
|
|
39
|
-
menu.style.left = `${Math.max(4, Math.min(rect.left, innerWidth - menu.offsetWidth - 4))}px`;
|
|
40
|
-
menu.style.top = `${Math.max(4, rect.bottom + menu.offsetHeight <= innerHeight - 4
|
|
41
|
-
? rect.bottom : rect.top - menu.offsetHeight)}px`;
|
|
42
|
-
trigger.setAttribute('aria-expanded', 'true');
|
|
43
|
-
items[0].focus();
|
|
44
|
-
listeners?.abort();
|
|
45
|
-
listeners = new AbortController();
|
|
46
|
-
const { signal } = listeners;
|
|
47
|
-
document.addEventListener('scroll', close, { capture: true, signal });
|
|
48
|
-
window.addEventListener('resize', close, { signal });
|
|
49
|
-
document.addEventListener('pointerdown', event => {
|
|
50
|
-
if ((event.target instanceof Node) && !menu.contains(event.target) && !trigger.contains(event.target))
|
|
51
|
-
dismiss();
|
|
52
|
-
}, { signal });
|
|
53
|
-
document.addEventListener('keydown', event => {
|
|
54
|
-
if ((event.key !== 'Escape') || event.defaultPrevented)
|
|
55
|
-
return;
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
close();
|
|
58
|
-
}, { signal });
|
|
59
|
-
};
|
|
60
|
-
menu.addEventListener('toggle', () => {
|
|
61
|
-
if (menu.matches(':popover-open'))
|
|
62
|
-
return;
|
|
63
|
-
trigger.setAttribute('aria-expanded', 'false');
|
|
64
|
-
listeners?.abort();
|
|
65
|
-
});
|
|
66
|
-
menu.addEventListener('click', event => {
|
|
67
|
-
if ((event.target instanceof Element) && event.target.closest('button'))
|
|
68
|
-
dismiss();
|
|
69
|
-
});
|
|
70
|
-
menu.addEventListener('keydown', event => {
|
|
71
|
-
const index = items.indexOf(document.activeElement);
|
|
72
|
-
let next;
|
|
73
|
-
switch (event.key) {
|
|
74
|
-
case 'ArrowDown':
|
|
75
|
-
next = (index + 1) % items.length;
|
|
76
|
-
break;
|
|
77
|
-
case 'ArrowUp':
|
|
78
|
-
next = (index + items.length - 1) % items.length;
|
|
79
|
-
break;
|
|
80
|
-
case 'Home':
|
|
81
|
-
next = 0;
|
|
82
|
-
break;
|
|
83
|
-
case 'End':
|
|
84
|
-
next = items.length - 1;
|
|
85
|
-
break;
|
|
86
|
-
case 'Escape':
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
close();
|
|
89
|
-
return;
|
|
90
|
-
case 'Tab':
|
|
91
|
-
close();
|
|
92
|
-
return;
|
|
93
|
-
default: return;
|
|
94
|
-
}
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
items[next].focus();
|
|
97
|
-
});
|
|
98
|
-
trigger.addEventListener('contextmenu', event => {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
suppressClick = true;
|
|
101
|
-
open();
|
|
102
|
-
});
|
|
103
|
-
trigger.addEventListener('keydown', event => {
|
|
104
|
-
if ((event.key !== 'ArrowDown') && (event.key !== 'ContextMenu')
|
|
105
|
-
&& !((event.key === 'F10') && event.shiftKey))
|
|
106
|
-
return;
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
open();
|
|
109
|
-
});
|
|
110
|
-
trigger.addEventListener('pointerdown', event => {
|
|
111
|
-
cancel();
|
|
112
|
-
suppressClick = false;
|
|
113
|
-
if (!event.isPrimary || (event.button !== 0))
|
|
114
|
-
return;
|
|
115
|
-
if (focusedColumn(form)) {
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
}
|
|
118
|
-
pointer = { id: event.pointerId, x: event.clientX, y: event.clientY };
|
|
119
|
-
trigger.setPointerCapture(event.pointerId);
|
|
120
|
-
timer = setTimeout(() => {
|
|
121
|
-
suppressClick = true;
|
|
122
|
-
open();
|
|
123
|
-
}, 500);
|
|
124
|
-
});
|
|
125
|
-
trigger.addEventListener('pointermove', event => {
|
|
126
|
-
if (pointer && (pointer.id === event.pointerId)
|
|
127
|
-
&& (Math.hypot(event.clientX - pointer.x, event.clientY - pointer.y) > 10)) {
|
|
128
|
-
suppressClick = true;
|
|
129
|
-
cancel();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
for (const type of ['pointercancel', 'pointerup', 'lostpointercapture'])
|
|
133
|
-
trigger.addEventListener(type, cancel);
|
|
134
|
-
trigger.addEventListener('click', event => {
|
|
135
|
-
if (!suppressClick || (event.detail === 0))
|
|
136
|
-
return;
|
|
137
|
-
event.preventDefault();
|
|
138
|
-
event.stopImmediatePropagation();
|
|
139
|
-
}, { capture: true });
|
|
140
|
-
});
|