@itrocks/list 0.26.0 → 0.27.1
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 +7 -0
- package/build.d.ts +2 -0
- package/build.js +2 -0
- package/cjs/filter-summary.d.ts +10 -0
- package/cjs/filter-summary.html +5 -0
- package/cjs/filter-summary.js +53 -0
- package/cjs/filter.d.ts +5 -1
- package/cjs/filter.js +51 -33
- package/cjs/list.d.ts +3 -1
- package/cjs/list.html +16 -9
- package/cjs/list.js +12 -3
- package/cjs/projection.d.ts +1 -0
- package/cjs/projection.js +4 -0
- package/cjs/search-expression.d.ts +2 -0
- package/cjs/session-state.d.ts +6 -0
- package/cjs/session-state.js +7 -1
- package/column-filter.d.ts +1 -0
- package/column-filter.js +26 -0
- package/filter.svg +1 -0
- package/list.css +122 -27
- package/package.json +5 -1
- package/property-select.js +2 -2
- package/search-focus.d.ts +1 -0
- package/search-focus.js +39 -0
- package/search-menu.js +4 -0
- package/toolbar.d.ts +1 -0
- package/toolbar.js +92 -0
package/README.md
CHANGED
|
@@ -30,6 +30,13 @@ JSON payload depending on the requested format.
|
|
|
30
30
|
HTML rendering provides columns, filters, ordered sorting and session preferences. The JSON action exposes
|
|
31
31
|
business objects for API consumers. See the public methods below for their shared contracts.
|
|
32
32
|
|
|
33
|
+
Column filter values use the same text highlight as the toolbar summary.
|
|
34
|
+
After applying column filters, the toolbar shows a decorative filter icon and a read-only summary.
|
|
35
|
+
The summary uses unique single-word column labels when available.
|
|
36
|
+
Applying a search from a column filter returns focus to that field and selects its full value.
|
|
37
|
+
When the toolbar runs out of space, the filter and add-column button move to a second row.
|
|
38
|
+
Use [@itrocks/list-filter](https://github.com/itrocks-ts/list-filter) to make the summary editable.
|
|
39
|
+
|
|
33
40
|
## API
|
|
34
41
|
|
|
35
42
|
### `class List<T extends object = object> extends Action<T>`
|
package/build.d.ts
CHANGED
package/build.js
CHANGED
|
@@ -9,7 +9,9 @@ import { TableFreezeInheritBorder } from '@itrocks/table/freeze/inherit-border.j
|
|
|
9
9
|
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
|
+
import './column-filter.js';
|
|
12
13
|
import './search-menu.js';
|
|
14
|
+
import './toolbar.js';
|
|
13
15
|
build('article[data-action="list"] > form > table.objects', table => {
|
|
14
16
|
let persistedColumns = [...table.querySelectorAll('thead th[data-property]')]
|
|
15
17
|
.map(header => header.dataset.property).join(',');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Type } from '@itrocks/class-type';
|
|
2
|
+
import type { ListView } from './access';
|
|
3
|
+
import type { ListColumn } from './projection';
|
|
4
|
+
export declare function escapeFilterText(text: string): string;
|
|
5
|
+
export declare function filterAliases(type: Type, columns: Iterable<Pick<ListColumn, 'label' | 'name'>>): Map<string, string>;
|
|
6
|
+
export declare function filterEntries(search: Record<string, string>, aliases: ReadonlyMap<string, string>): {
|
|
7
|
+
field: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare function filterSummary(search: Record<string, string>, aliases: ReadonlyMap<string, string>): ListView;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<!--criteria-->
|
|
2
|
+
<span class="list-filter-icon" aria-hidden="true"></span>
|
|
3
|
+
<span aria-label="Active list filters" class="list-filter-text" role="group"
|
|
4
|
+
><!--items--><code>{caption}</code><code class="list-filter-value">{value}</code>{space}<!--end--></span>
|
|
5
|
+
<!--end-->
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeFilterText = escapeFilterText;
|
|
4
|
+
exports.filterAliases = filterAliases;
|
|
5
|
+
exports.filterEntries = filterEntries;
|
|
6
|
+
exports.filterSummary = filterSummary;
|
|
7
|
+
const reflect_path_1 = require("@itrocks/reflect-path");
|
|
8
|
+
const fieldPart = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
|
|
9
|
+
const quotedValue = /[\s"]|^(?:!=|<>|[!=<>]=?)?'/;
|
|
10
|
+
function escapeFilterText(text) {
|
|
11
|
+
return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
12
|
+
}
|
|
13
|
+
function filterAliases(type, columns) {
|
|
14
|
+
const labels = new Map();
|
|
15
|
+
for (const { label, name } of columns) {
|
|
16
|
+
const alias = label.toLowerCase();
|
|
17
|
+
if (!alias.split('.').every(part => fieldPart.test(part)))
|
|
18
|
+
continue;
|
|
19
|
+
labels.set(alias, [...(labels.get(alias) ?? []), name]);
|
|
20
|
+
}
|
|
21
|
+
const aliases = new Map();
|
|
22
|
+
for (const [alias, names] of labels) {
|
|
23
|
+
if ((names.length !== 1) || (alias === names[0]))
|
|
24
|
+
continue;
|
|
25
|
+
try {
|
|
26
|
+
// A real property path always takes precedence over a translated label.
|
|
27
|
+
(0, reflect_path_1.resolvePropertyPath)(type, alias);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
aliases.set(alias, names[0]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return aliases;
|
|
34
|
+
}
|
|
35
|
+
function filterEntries(search, aliases) {
|
|
36
|
+
const labels = new Map([...aliases].map(([alias, path]) => [path, alias]));
|
|
37
|
+
return Object.entries(search)
|
|
38
|
+
.filter(([, value]) => value !== '')
|
|
39
|
+
.map(([path, value]) => ({
|
|
40
|
+
field: labels.get(path) ?? path,
|
|
41
|
+
value: quotedValue.test(value) ? '"' + value.replace(/[\\"]/g, '\\$&') + '"' : value
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function filterSummary(search, aliases) {
|
|
45
|
+
const entries = filterEntries(search, aliases);
|
|
46
|
+
const items = entries.map(({ field, value }, index) => ({
|
|
47
|
+
caption: escapeFilterText(field + ':'),
|
|
48
|
+
space: (index + 1 < entries.length) ? ' ' : '',
|
|
49
|
+
value: escapeFilterText(value)
|
|
50
|
+
}));
|
|
51
|
+
return { criteria: items.length ? { items } : undefined, template: './filter-summary.html' };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=filter-summary.js.map
|
package/cjs/filter.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Type } from '@itrocks/class-type';
|
|
2
2
|
import { Request } from '@itrocks/request-response';
|
|
3
3
|
import { Option } from '@itrocks/storage';
|
|
4
|
+
import { SearchType } from '@itrocks/storage';
|
|
4
5
|
import { Columns } from './columns';
|
|
5
6
|
import { Parameter } from './parameter';
|
|
7
|
+
import { SearchExpression } from './search-expression';
|
|
6
8
|
type Search = {
|
|
7
9
|
[property: string]: string;
|
|
8
10
|
};
|
|
@@ -10,7 +12,9 @@ export declare class Filter<T extends object> extends Parameter {
|
|
|
10
12
|
columns: Columns<T>;
|
|
11
13
|
search: Search;
|
|
12
14
|
constructor(columns: Columns<T>);
|
|
13
|
-
|
|
15
|
+
protected columnCondition(type: Type, property: string, value: string): SearchType;
|
|
16
|
+
protected condition(type: Type, property: string, expression: SearchExpression, ancestors?: readonly Type[]): SearchType;
|
|
17
|
+
getParams(request: Request, _type?: Type): void;
|
|
14
18
|
readOptions(options?: Option[]): Option[];
|
|
15
19
|
searchObject(type: Type): any;
|
|
16
20
|
serialize(): Search;
|
package/cjs/filter.js
CHANGED
|
@@ -30,11 +30,23 @@ const operators = {
|
|
|
30
30
|
'>': sql_functions_6.greater,
|
|
31
31
|
'>=': sql_functions_7.greaterOrEqual
|
|
32
32
|
};
|
|
33
|
+
function explicitSearchValue(propertyType, operator, value) {
|
|
34
|
+
if (propertyType === Date)
|
|
35
|
+
return (0, date_search_1.dateSearch)(value, operator === ':' ? '=' : operator);
|
|
36
|
+
if (operator !== ':')
|
|
37
|
+
return operators[operator](value);
|
|
38
|
+
if (propertyType !== String)
|
|
39
|
+
return value;
|
|
40
|
+
return (0, sql_functions_10.like)(value.replace(/[\\%_]/g, '\\$&') + '%');
|
|
41
|
+
}
|
|
33
42
|
function searchValue(propertyType, expression) {
|
|
34
43
|
if (!('value' in expression)) {
|
|
35
44
|
const combine = (expression.operator === 'AND') ? sql_functions_3.and : sql_functions_13.or;
|
|
36
45
|
return combine(...expression.operands.map(operand => searchValue(propertyType, operand) ?? (0, sql_functions_13.or)()));
|
|
37
46
|
}
|
|
47
|
+
if (expression.comparison !== undefined) {
|
|
48
|
+
return explicitSearchValue(propertyType, expression.comparison, expression.value);
|
|
49
|
+
}
|
|
38
50
|
let value = expression.value;
|
|
39
51
|
const alias = value.trim().match(/^(!=|<>|!)?\s*(.+)$/s);
|
|
40
52
|
if (alias && ((0, translate_1.trReverse)(alias[2].toLowerCase()) === 'empty')) {
|
|
@@ -74,7 +86,41 @@ class Filter extends parameter_1.Parameter {
|
|
|
74
86
|
super();
|
|
75
87
|
this.columns = columns;
|
|
76
88
|
}
|
|
77
|
-
|
|
89
|
+
columnCondition(type, property, value) {
|
|
90
|
+
let expression;
|
|
91
|
+
try {
|
|
92
|
+
expression = (0, search_expression_1.searchExpression)(value);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (!(error instanceof SyntaxError))
|
|
96
|
+
throw error;
|
|
97
|
+
return { [property]: (0, sql_functions_13.or)() };
|
|
98
|
+
}
|
|
99
|
+
const resolved = (0, reflect_path_1.resolvePropertyPath)(type, property);
|
|
100
|
+
if (resolved.target)
|
|
101
|
+
return this.condition(type, property, expression);
|
|
102
|
+
const criterion = searchValue(resolved.property.type.type, expression);
|
|
103
|
+
return (criterion === undefined) ? {} : { [property]: criterion };
|
|
104
|
+
}
|
|
105
|
+
condition(type, property, expression, ancestors = []) {
|
|
106
|
+
const resolved = (0, reflect_path_1.resolvePropertyPath)(type, property);
|
|
107
|
+
if (!resolved.target) {
|
|
108
|
+
const value = searchValue(resolved.property.type.type, expression);
|
|
109
|
+
return { [property]: value ?? (0, sql_functions_13.or)() };
|
|
110
|
+
}
|
|
111
|
+
if (!('value' in expression)) {
|
|
112
|
+
const operator = (expression.operator === 'AND') ? sql_functions_1.AND : sql_functions_2.OR;
|
|
113
|
+
return { [operator]: expression.operands.map(operand => this.condition(type, property, operand, ancestors)) };
|
|
114
|
+
}
|
|
115
|
+
if (ancestors.includes(resolved.target))
|
|
116
|
+
throw new Error(`Cyclic search representation: ${property}`);
|
|
117
|
+
const branch = [...ancestors, resolved.target];
|
|
118
|
+
return {
|
|
119
|
+
[sql_functions_2.OR]: (0, class_view_1.representativeOf)(resolved.target)
|
|
120
|
+
.map(name => this.condition(type, `${property}.${String(name)}`, expression, branch))
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
getParams(request, _type) {
|
|
78
124
|
for (const property of this.columns.map(property => property.name)) {
|
|
79
125
|
this.search[property] ??= '';
|
|
80
126
|
}
|
|
@@ -111,43 +157,15 @@ class Filter extends parameter_1.Parameter {
|
|
|
111
157
|
searchObject(type) {
|
|
112
158
|
const search = {};
|
|
113
159
|
const groups = [];
|
|
114
|
-
const expand = (property, expression, ancestors = []) => {
|
|
115
|
-
const resolved = (0, reflect_path_1.resolvePropertyPath)(type, property);
|
|
116
|
-
if (!resolved.target) {
|
|
117
|
-
const value = searchValue(resolved.property.type.type, expression);
|
|
118
|
-
return { [property]: value ?? (0, sql_functions_13.or)() };
|
|
119
|
-
}
|
|
120
|
-
if (!('value' in expression)) {
|
|
121
|
-
const operator = (expression.operator === 'AND') ? sql_functions_1.AND : sql_functions_2.OR;
|
|
122
|
-
return { [operator]: expression.operands.map(operand => expand(property, operand, ancestors)) };
|
|
123
|
-
}
|
|
124
|
-
if (ancestors.includes(resolved.target))
|
|
125
|
-
throw new Error(`Cyclic search representation: ${property}`);
|
|
126
|
-
const branch = [...ancestors, resolved.target];
|
|
127
|
-
return {
|
|
128
|
-
[sql_functions_2.OR]: (0, class_view_1.representativeOf)(resolved.target).map(name => expand(`${property}.${String(name)}`, expression, branch))
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
160
|
for (const [property, value] of Object.entries(this.search)) {
|
|
132
161
|
if (value === '')
|
|
133
162
|
continue;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
if (!(error instanceof SyntaxError))
|
|
140
|
-
throw error;
|
|
141
|
-
search[property] = (0, sql_functions_13.or)();
|
|
142
|
-
continue;
|
|
163
|
+
const condition = this.columnCondition(type, property, value);
|
|
164
|
+
if (Object.hasOwn(condition, sql_functions_1.AND) || Object.hasOwn(condition, sql_functions_2.OR)) {
|
|
165
|
+
groups.push(condition);
|
|
143
166
|
}
|
|
144
|
-
const resolved = (0, reflect_path_1.resolvePropertyPath)(type, property);
|
|
145
|
-
if (resolved.target)
|
|
146
|
-
groups.push(expand(property, expression));
|
|
147
167
|
else {
|
|
148
|
-
|
|
149
|
-
if (criterion !== undefined)
|
|
150
|
-
search[property] = criterion;
|
|
168
|
+
Object.assign(search, condition);
|
|
151
169
|
}
|
|
152
170
|
}
|
|
153
171
|
if (groups.length)
|
package/cjs/list.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Action } from '@itrocks/action';
|
|
2
2
|
import { Request } from '@itrocks/action-request';
|
|
3
3
|
import { SearchType } from '@itrocks/storage';
|
|
4
|
+
import { ListView } from './access';
|
|
4
5
|
import { Columns } from './columns';
|
|
5
6
|
import { Feed } from './feed';
|
|
6
7
|
import { Filter } from './filter';
|
|
7
8
|
import { Sort } from './sort';
|
|
8
|
-
export { listDependsOn } from './access';
|
|
9
|
+
export { listAccess, listDependsOn } from './access';
|
|
9
10
|
export type { ListAccess, ListDependencies, ListView } from './access';
|
|
10
11
|
export declare class List<T extends object = object> extends Action<T> {
|
|
11
12
|
columns: Columns<object>;
|
|
12
13
|
feed: Feed;
|
|
13
14
|
filter: Filter<object>;
|
|
14
15
|
sort: Sort<object>;
|
|
16
|
+
protected filterBar(request: Request<T>): ListView;
|
|
15
17
|
html(request: Request<T>, scope?: SearchType<T>): Promise<import("@itrocks/request-response").Response>;
|
|
16
18
|
json(request: Request<T>, scope?: SearchType<T>): Promise<import("@itrocks/core-responses").JsonResponse>;
|
|
17
19
|
}
|
package/cjs/list.html
CHANGED
|
@@ -19,15 +19,22 @@
|
|
|
19
19
|
<!--view-->{{template}}<!--end-->
|
|
20
20
|
<header>
|
|
21
21
|
<h2>{type.@output.ucFirst} list</h2>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
<div class="list-toolbar">
|
|
23
|
+
<ul class="general actions">
|
|
24
|
+
<!--generalActions-->
|
|
25
|
+
<li class="{action}">{{template}}</li>
|
|
26
|
+
<!--end-->
|
|
27
|
+
</ul>
|
|
28
|
+
<div class="list-filter">
|
|
29
|
+
<!--filterBar-->{{template}}<!--end-->
|
|
30
|
+
</div>
|
|
31
|
+
<div class="summary">{count} elements</div>
|
|
32
|
+
<button class="add-column" hidden type="button" aria-label="Add column">+</button>
|
|
33
|
+
</div>
|
|
29
34
|
</header>
|
|
30
|
-
<form action="app://(type.@route)/list" autocomplete="off"
|
|
35
|
+
<form action="app://(type.@route)/list" autocomplete="off" data-focus-column="{focusColumn}"
|
|
36
|
+
method="post" target="main">
|
|
37
|
+
<!--filterBar--><!--formFields-->{{template}}<!--end--><!--end-->
|
|
31
38
|
<table class="objects" data-link="{type.@route}">
|
|
32
39
|
<thead>
|
|
33
40
|
<tr class="properties">
|
|
@@ -37,7 +44,7 @@
|
|
|
37
44
|
<!--columns-->
|
|
38
45
|
<th data-property="{name}" data-reverse="{?reverse}" data-sort="{?sort}"
|
|
39
46
|
data-sortable="{sortable}">{label}
|
|
40
|
-
<input aria-label="Filter {label}" data-property-filter="{name}" name="search.{field}" value="{
|
|
47
|
+
<input aria-label="Filter {label}" data-property-filter="{name}" name="search.{field}" value="{escapedSearch}">
|
|
41
48
|
</th>
|
|
42
49
|
<!--end-->
|
|
43
50
|
</tr>
|
package/cjs/list.js
CHANGED
|
@@ -34,7 +34,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
34
34
|
return useValue ? value : void 0;
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.List = exports.listDependsOn = void 0;
|
|
37
|
+
exports.List = exports.listDependsOn = exports.listAccess = void 0;
|
|
38
38
|
const action_1 = require("@itrocks/action");
|
|
39
39
|
const action_2 = require("@itrocks/action");
|
|
40
40
|
const action_3 = require("@itrocks/action");
|
|
@@ -50,6 +50,8 @@ const columns_1 = require("./columns");
|
|
|
50
50
|
const columns_2 = require("./columns");
|
|
51
51
|
const feed_1 = require("./feed");
|
|
52
52
|
const filter_1 = require("./filter");
|
|
53
|
+
const filter_summary_1 = require("./filter-summary");
|
|
54
|
+
const filter_summary_2 = require("./filter-summary");
|
|
53
55
|
const persist_1 = require("./persist");
|
|
54
56
|
const persist_2 = require("./persist");
|
|
55
57
|
const projection_1 = require("./projection");
|
|
@@ -60,6 +62,7 @@ const selector_state_2 = require("./selector-state");
|
|
|
60
62
|
const session_state_1 = require("./session-state");
|
|
61
63
|
const sort_1 = require("./sort");
|
|
62
64
|
var access_4 = require("./access");
|
|
65
|
+
Object.defineProperty(exports, "listAccess", { enumerable: true, get: function () { return access_4.listAccess; } });
|
|
63
66
|
Object.defineProperty(exports, "listDependsOn", { enumerable: true, get: function () { return access_4.listDependsOn; } });
|
|
64
67
|
let List = (() => {
|
|
65
68
|
let _classDecorators = [(0, action_3.Need)('Store', 'new'), (0, route_1.Route)('/list')];
|
|
@@ -80,6 +83,9 @@ let List = (() => {
|
|
|
80
83
|
feed = new feed_1.Feed;
|
|
81
84
|
filter = new filter_1.Filter(this.columns);
|
|
82
85
|
sort = new sort_1.Sort(this.columns);
|
|
86
|
+
filterBar(request) {
|
|
87
|
+
return (0, filter_summary_2.filterSummary)(this.filter.search, (0, filter_summary_1.filterAliases)(request.type, this.columns));
|
|
88
|
+
}
|
|
83
89
|
async html(request, scope) {
|
|
84
90
|
const columns = this.columns;
|
|
85
91
|
const feed = this.feed;
|
|
@@ -107,7 +113,7 @@ let List = (() => {
|
|
|
107
113
|
return this.htmlResponse('', 204);
|
|
108
114
|
}
|
|
109
115
|
feed.getParams(request.request);
|
|
110
|
-
filter.getParams(request.request);
|
|
116
|
+
filter.getParams(request.request, type);
|
|
111
117
|
for (const column of columns)
|
|
112
118
|
column.search = filter.search[column.name] ?? '';
|
|
113
119
|
sort.getParams(request.request, type);
|
|
@@ -195,8 +201,11 @@ let List = (() => {
|
|
|
195
201
|
const metadata = await access.bootstrap([...columns].map(column => column.name), state.record);
|
|
196
202
|
selectorBootstrap = encodeURIComponent(JSON.stringify({ ...state, ...metadata }));
|
|
197
203
|
}
|
|
204
|
+
const focus = request.request.method === 'POST' ? request.request.data.focusListColumn : undefined;
|
|
205
|
+
const focusColumn = [...columns].find(column => column.field === focus)?.field ?? '';
|
|
198
206
|
return this.htmlTemplateResponse({
|
|
199
|
-
columns, count,
|
|
207
|
+
columns, count, filterBar: this.filterBar(request), focusColumn, generalActions, objects,
|
|
208
|
+
root: access.root, search: filter.search,
|
|
200
209
|
selectionActions, selectorBootstrap, selectorKey: (0, selector_state_2.selectorStateKey)(request), type,
|
|
201
210
|
selection: selectionActions.length ? await selection?.view(request, activeSearch, count) : undefined,
|
|
202
211
|
view: await (0, access_3.listView)(request)
|
package/cjs/projection.d.ts
CHANGED
package/cjs/projection.js
CHANGED
|
@@ -22,6 +22,7 @@ const transformer_1 = require("@itrocks/transformer");
|
|
|
22
22
|
const transformer_2 = require("@itrocks/transformer");
|
|
23
23
|
const transformer_3 = require("@itrocks/transformer");
|
|
24
24
|
const transformer_4 = require("@itrocks/transformer");
|
|
25
|
+
const filter_summary_1 = require("./filter-summary");
|
|
25
26
|
const multiple_output_1 = require("./multiple-output");
|
|
26
27
|
const dependencies = {};
|
|
27
28
|
function listRepresentationDependsOn(overrides) {
|
|
@@ -96,6 +97,9 @@ class ListColumn {
|
|
|
96
97
|
if (resolved.target && !this.multiple)
|
|
97
98
|
this.fields = representationFields(resolved.target, [], resolved.property);
|
|
98
99
|
}
|
|
100
|
+
get escapedSearch() {
|
|
101
|
+
return (0, filter_summary_1.escapeFilterText)(this.search);
|
|
102
|
+
}
|
|
99
103
|
async output(cell) {
|
|
100
104
|
if (cell.kind === 'absent')
|
|
101
105
|
return '';
|
package/cjs/session-state.d.ts
CHANGED
|
@@ -2,9 +2,15 @@ import { Request } from '@itrocks/action-request';
|
|
|
2
2
|
import { Type } from '@itrocks/class-type';
|
|
3
3
|
import { Request as ServerRequest } from '@itrocks/request-response';
|
|
4
4
|
import { Response } from '@itrocks/request-response';
|
|
5
|
+
export type ListQueryState = {
|
|
6
|
+
fields: Record<string, string>;
|
|
7
|
+
syntax?: 'logical';
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
5
10
|
export type ListState = {
|
|
6
11
|
columns?: string[];
|
|
7
12
|
filter?: Record<string, string>;
|
|
13
|
+
listQuery?: ListQueryState;
|
|
8
14
|
sort?: [string, boolean][];
|
|
9
15
|
};
|
|
10
16
|
export type ListSessionDependencies = {
|
package/cjs/session-state.js
CHANGED
|
@@ -16,7 +16,12 @@ function listSessionDependsOn(overrides) {
|
|
|
16
16
|
}
|
|
17
17
|
function listState(request, type) {
|
|
18
18
|
const state = request.session.list?.[(0, route_1.routeOf)(type)] ?? {};
|
|
19
|
-
return structuredClone({
|
|
19
|
+
return structuredClone({
|
|
20
|
+
columns: state.columns,
|
|
21
|
+
filter: state.filter,
|
|
22
|
+
...(state.listQuery ? { listQuery: state.listQuery } : {}),
|
|
23
|
+
sort: state.sort
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
26
|
function replaceListState(request, type, state) {
|
|
22
27
|
request.session.list ??= {};
|
|
@@ -35,6 +40,7 @@ function comparableListState(state) {
|
|
|
35
40
|
filter: Object.entries(state.filter ?? {})
|
|
36
41
|
.filter(([, value]) => value !== '')
|
|
37
42
|
.sort(([left], [right]) => left.localeCompare(right)),
|
|
43
|
+
listQuery: state.listQuery || undefined,
|
|
38
44
|
sort: state.sort
|
|
39
45
|
});
|
|
40
46
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function highlightColumnFilter(input: HTMLInputElement): void;
|
package/column-filter.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { build } from '@itrocks/build/build.js';
|
|
2
|
+
const bound = new WeakSet();
|
|
3
|
+
const selector = 'article[data-action="list"] > form input[data-property-filter]';
|
|
4
|
+
const measure = document.createElement('canvas').getContext('2d');
|
|
5
|
+
export function highlightColumnFilter(input) {
|
|
6
|
+
input.toggleAttribute('data-filter-value', !!input.value);
|
|
7
|
+
if (!input.value || !measure)
|
|
8
|
+
return;
|
|
9
|
+
measure.font = getComputedStyle(input).font;
|
|
10
|
+
input.style.setProperty('--list-filter-text-width', `${measure.measureText(input.value).width}px`);
|
|
11
|
+
positionHighlight(input);
|
|
12
|
+
}
|
|
13
|
+
function positionHighlight(input) {
|
|
14
|
+
input.style.setProperty('--list-filter-text-offset', `${-Math.abs(input.scrollLeft)}px`);
|
|
15
|
+
}
|
|
16
|
+
build(selector, input => {
|
|
17
|
+
if (!bound.has(input)) {
|
|
18
|
+
bound.add(input);
|
|
19
|
+
input.addEventListener('input', () => highlightColumnFilter(input));
|
|
20
|
+
input.addEventListener('scroll', () => positionHighlight(input));
|
|
21
|
+
}
|
|
22
|
+
highlightColumnFilter(input);
|
|
23
|
+
});
|
|
24
|
+
document.fonts.addEventListener('loadingdone', () => {
|
|
25
|
+
document.querySelectorAll(selector).forEach(highlightColumnFilter);
|
|
26
|
+
});
|
package/filter.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><path d="M2.25 3h13.5l-5.25 6v4.5l-3 1.5V9z" fill="none" stroke="#444" stroke-linejoin="round" stroke-width="1.5"/></svg>
|
package/list.css
CHANGED
|
@@ -3,15 +3,6 @@ html.column-reorder * {
|
|
|
3
3
|
cursor: grabbing !important;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
main > article[data-action=list] > header {
|
|
7
|
-
position: relative;
|
|
8
|
-
}
|
|
9
|
-
main > article[data-action=list] > header > .summary {
|
|
10
|
-
padding: 13px 10px 12px;
|
|
11
|
-
position: absolute;
|
|
12
|
-
right: 48px;
|
|
13
|
-
white-space: nowrap;
|
|
14
|
-
}
|
|
15
6
|
main > article[data-action=list] > form {
|
|
16
7
|
display: grid;
|
|
17
8
|
grid-template-areas: "table" "footer";
|
|
@@ -193,24 +184,6 @@ table.objects > thead + tbody > tr:hover {
|
|
|
193
184
|
border-left: 1px solid #d8d8d8;
|
|
194
185
|
}
|
|
195
186
|
|
|
196
|
-
main > article[data-action=list] > header > .add-column {
|
|
197
|
-
background: white;
|
|
198
|
-
border: 0;
|
|
199
|
-
border-bottom: 1px solid #ccc;
|
|
200
|
-
border-left: 1px solid #ccc;
|
|
201
|
-
border-radius: 0;
|
|
202
|
-
bottom: 0;
|
|
203
|
-
cursor: pointer;
|
|
204
|
-
font-size: 16px;
|
|
205
|
-
position: absolute;
|
|
206
|
-
right: 0;
|
|
207
|
-
top: 0;
|
|
208
|
-
width: 44px;
|
|
209
|
-
}
|
|
210
|
-
main > article[data-action=list] > header > .add-column:hover {
|
|
211
|
-
background-color: #f4f4f4;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
187
|
table.objects > thead > tr.properties > th {
|
|
215
188
|
line-height: 28px;
|
|
216
189
|
padding-block: 0;
|
|
@@ -252,6 +225,18 @@ table.objects > thead > tr.properties > th > input[data-property-filter] {
|
|
|
252
225
|
margin-left: -0.6em;
|
|
253
226
|
width: calc(100% + 1.2em);
|
|
254
227
|
}
|
|
228
|
+
table.objects > thead > tr.properties > th > input[data-property-filter][data-filter-value] {
|
|
229
|
+
background-clip: content-box, border-box;
|
|
230
|
+
background-image: linear-gradient(#d5edff, #d5edff), none;
|
|
231
|
+
background-origin: content-box;
|
|
232
|
+
background-position: left var(--list-filter-text-offset, 0px) center;
|
|
233
|
+
background-repeat: no-repeat;
|
|
234
|
+
background-size: var(--list-filter-text-width, 0px) 1.2em;
|
|
235
|
+
color: #12365b;
|
|
236
|
+
}
|
|
237
|
+
table.objects > thead > tr.properties > th > input[data-property-filter][data-filter-value]:dir(rtl) {
|
|
238
|
+
background-position: right var(--list-filter-text-offset, 0px) center;
|
|
239
|
+
}
|
|
255
240
|
table.objects > thead > tr.properties > th[data-sort] > input[data-property-filter] {
|
|
256
241
|
width: calc(100% + 1.2em + 16px);
|
|
257
242
|
}
|
|
@@ -301,3 +286,113 @@ article[data-action=list] > form > .search-menu > button.reset::before {
|
|
|
301
286
|
article[data-action=list] > form > .search-menu > button:focus-visible, article[data-action=list] > form > .search-menu > button:hover {
|
|
302
287
|
background: #eee;
|
|
303
288
|
}
|
|
289
|
+
|
|
290
|
+
main > article[data-action=list] > header > .list-toolbar {
|
|
291
|
+
--list-toolbar-gap: 5px;
|
|
292
|
+
align-items: center;
|
|
293
|
+
border-bottom: 1px solid #ccc;
|
|
294
|
+
display: grid;
|
|
295
|
+
gap: var(--list-toolbar-gap);
|
|
296
|
+
grid-template-areas: "actions filter count add";
|
|
297
|
+
grid-template-columns: auto minmax(0, 1fr) auto max-content;
|
|
298
|
+
}
|
|
299
|
+
main > article[data-action=list] > header > .list-toolbar:has(> .add-column[hidden]) {
|
|
300
|
+
grid-template-areas: "actions filter count";
|
|
301
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
302
|
+
}
|
|
303
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] {
|
|
304
|
+
gap: 0;
|
|
305
|
+
grid-template-areas: "actions count count" "filter filter add";
|
|
306
|
+
grid-template-columns: minmax(0, 1fr) auto max-content;
|
|
307
|
+
}
|
|
308
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row]:has(> .add-column[hidden]) {
|
|
309
|
+
grid-template-areas: "actions count" "filter filter";
|
|
310
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
311
|
+
}
|
|
312
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > :is(.general.actions, .summary) {
|
|
313
|
+
align-self: stretch;
|
|
314
|
+
border-bottom: 1px solid #ccc;
|
|
315
|
+
}
|
|
316
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .general.actions {
|
|
317
|
+
flex-wrap: wrap;
|
|
318
|
+
overflow-x: auto;
|
|
319
|
+
}
|
|
320
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .list-filter {
|
|
321
|
+
align-self: stretch;
|
|
322
|
+
}
|
|
323
|
+
main > article[data-action=list] > header > .list-toolbar[data-filter-row] > .summary {
|
|
324
|
+
align-content: center;
|
|
325
|
+
justify-self: stretch;
|
|
326
|
+
text-align: end;
|
|
327
|
+
}
|
|
328
|
+
main > article[data-action=list] > header > .list-toolbar > .add-column {
|
|
329
|
+
align-self: stretch;
|
|
330
|
+
background: white;
|
|
331
|
+
border: 0;
|
|
332
|
+
border-left: 1px solid #ccc;
|
|
333
|
+
border-radius: 0;
|
|
334
|
+
cursor: pointer;
|
|
335
|
+
font-size: 16px;
|
|
336
|
+
grid-area: add;
|
|
337
|
+
justify-self: end;
|
|
338
|
+
min-width: 44px;
|
|
339
|
+
white-space: nowrap;
|
|
340
|
+
}
|
|
341
|
+
main > article[data-action=list] > header > .list-toolbar > .add-column:hover {
|
|
342
|
+
background-color: #f4f4f4;
|
|
343
|
+
}
|
|
344
|
+
main > article[data-action=list] > header > .list-toolbar > .list-filter {
|
|
345
|
+
grid-area: filter;
|
|
346
|
+
padding-inline: 5px;
|
|
347
|
+
}
|
|
348
|
+
main > article[data-action=list] > header > .list-toolbar > .general.actions {
|
|
349
|
+
border-bottom: 0;
|
|
350
|
+
flex-wrap: nowrap;
|
|
351
|
+
grid-area: actions;
|
|
352
|
+
min-width: 0;
|
|
353
|
+
}
|
|
354
|
+
main > article[data-action=list] > header > .list-toolbar > .general.actions > li {
|
|
355
|
+
flex: none;
|
|
356
|
+
white-space: nowrap;
|
|
357
|
+
}
|
|
358
|
+
main > article[data-action=list] > header > .list-toolbar > .summary {
|
|
359
|
+
display: inline-block;
|
|
360
|
+
grid-area: count;
|
|
361
|
+
justify-self: end;
|
|
362
|
+
padding: 5px 10px;
|
|
363
|
+
white-space: nowrap;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.list-filter {
|
|
367
|
+
align-items: center;
|
|
368
|
+
display: flex;
|
|
369
|
+
flex: 1;
|
|
370
|
+
gap: 0.4em;
|
|
371
|
+
min-width: 0;
|
|
372
|
+
}
|
|
373
|
+
.list-filter .list-filter-icon {
|
|
374
|
+
background: url("filter.svg") center/contain no-repeat;
|
|
375
|
+
border: 0;
|
|
376
|
+
display: inline-block;
|
|
377
|
+
flex: none;
|
|
378
|
+
height: 18px;
|
|
379
|
+
padding: 0;
|
|
380
|
+
width: 18px;
|
|
381
|
+
}
|
|
382
|
+
.list-filter button.list-filter-icon {
|
|
383
|
+
cursor: pointer;
|
|
384
|
+
}
|
|
385
|
+
.list-filter .list-filter-text {
|
|
386
|
+
border-bottom: 1px dotted #888;
|
|
387
|
+
flex: 1;
|
|
388
|
+
min-width: 0;
|
|
389
|
+
overflow-x: auto;
|
|
390
|
+
white-space: pre;
|
|
391
|
+
}
|
|
392
|
+
.list-filter code {
|
|
393
|
+
font: inherit;
|
|
394
|
+
}
|
|
395
|
+
.list-filter .list-filter-value {
|
|
396
|
+
background: #d5edff;
|
|
397
|
+
color: #12365b;
|
|
398
|
+
}
|
package/package.json
CHANGED
|
@@ -41,7 +41,11 @@
|
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": "./cjs/list.js",
|
|
44
|
+
"./column-filter.js": "./column-filter.js",
|
|
45
|
+
"./filter": "./cjs/filter.js",
|
|
46
|
+
"./filter-summary": "./cjs/filter-summary.js",
|
|
44
47
|
"./multiple-output": "./cjs/multiple-output.js",
|
|
48
|
+
"./parameter": "./cjs/parameter.js",
|
|
45
49
|
"./projection": "./cjs/projection.js",
|
|
46
50
|
"./property-select.js": "./property-select.js",
|
|
47
51
|
"./search": "./cjs/search.js",
|
|
@@ -98,5 +102,5 @@
|
|
|
98
102
|
"build:front": "tsc -p src/front/tsconfig.json",
|
|
99
103
|
"test": "npm run build:cjs && node --test \"test/**/*.test.mjs\""
|
|
100
104
|
},
|
|
101
|
-
"version": "0.
|
|
105
|
+
"version": "0.27.1"
|
|
102
106
|
}
|
package/property-select.js
CHANGED
|
@@ -20,8 +20,8 @@ export class ListPropertySelect {
|
|
|
20
20
|
constructor(article, options) {
|
|
21
21
|
this.article = article;
|
|
22
22
|
this.options = options;
|
|
23
|
+
this.button = article.querySelector(':scope > header .add-column');
|
|
23
24
|
const content = this.content;
|
|
24
|
-
this.button = article.querySelector('.add-column');
|
|
25
25
|
const initial = article.dataset.selectorBootstrap
|
|
26
26
|
? JSON.parse(decodeURIComponent(article.dataset.selectorBootstrap)) : undefined;
|
|
27
27
|
const translate = (text) => initial?.translations?.[text] ?? text;
|
|
@@ -50,7 +50,7 @@ export class ListPropertySelect {
|
|
|
50
50
|
return (await this.loadColumns([path], this.paths(), signal, true)).get(path);
|
|
51
51
|
}
|
|
52
52
|
async loadColumns(paths, columns, signal, single = false) {
|
|
53
|
-
const form = this.article.querySelector('form');
|
|
53
|
+
const form = this.article.querySelector(':scope > form');
|
|
54
54
|
const table = this.article.querySelector('table.objects');
|
|
55
55
|
const rows = [...table.tBodies[0].rows];
|
|
56
56
|
const ids = rows.map(row => row.querySelector('input[name=id]').value);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function focusedColumn(form: HTMLFormElement): HTMLInputElement | undefined;
|
package/search-focus.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { build } from '@itrocks/build/build.js';
|
|
2
|
+
const bound = new WeakSet();
|
|
3
|
+
export function focusedColumn(form) {
|
|
4
|
+
const active = document.activeElement;
|
|
5
|
+
if (active instanceof HTMLInputElement && active.form === form && active.hasAttribute('data-property-filter')) {
|
|
6
|
+
return active;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
build({
|
|
10
|
+
callback: form => {
|
|
11
|
+
if (bound.has(form))
|
|
12
|
+
return;
|
|
13
|
+
bound.add(form);
|
|
14
|
+
let column;
|
|
15
|
+
form.addEventListener('submit', event => {
|
|
16
|
+
const submitter = event.submitter;
|
|
17
|
+
column = (!submitter || submitter.matches('.search-submit, .search-menu .search'))
|
|
18
|
+
? focusedColumn(form)?.name.slice('search.'.length)
|
|
19
|
+
: undefined;
|
|
20
|
+
}, { capture: true });
|
|
21
|
+
form.addEventListener('formdata', event => {
|
|
22
|
+
if (column) {
|
|
23
|
+
event.formData.set('focusListColumn', column);
|
|
24
|
+
column = undefined;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const field = form.dataset.focusColumn;
|
|
28
|
+
delete form.dataset.focusColumn;
|
|
29
|
+
if (!field)
|
|
30
|
+
return;
|
|
31
|
+
const input = form.elements.namedItem('search.' + field);
|
|
32
|
+
if (!(input instanceof HTMLInputElement))
|
|
33
|
+
return;
|
|
34
|
+
input.focus();
|
|
35
|
+
input.select();
|
|
36
|
+
},
|
|
37
|
+
priority: 2000,
|
|
38
|
+
selector: 'article[data-action="list"] > form'
|
|
39
|
+
});
|
package/search-menu.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { build } from '@itrocks/build/build.js';
|
|
2
|
+
import { focusedColumn } from './search-focus.js';
|
|
2
3
|
const bound = new WeakSet();
|
|
3
4
|
build('article[data-action="list"] > form', form => {
|
|
4
5
|
if (bound.has(form))
|
|
@@ -111,6 +112,9 @@ build('article[data-action="list"] > form', form => {
|
|
|
111
112
|
suppressClick = false;
|
|
112
113
|
if (!event.isPrimary || (event.button !== 0))
|
|
113
114
|
return;
|
|
115
|
+
if (focusedColumn(form)) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
}
|
|
114
118
|
pointer = { id: event.pointerId, x: event.clientX, y: event.clientY };
|
|
115
119
|
trigger.setPointerCapture(event.pointerId);
|
|
116
120
|
timer = setTimeout(() => {
|
package/toolbar.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/toolbar.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { build } from '@itrocks/build/build.js';
|
|
2
|
+
const toolbars = new Map();
|
|
3
|
+
function actionsWidth(actions) {
|
|
4
|
+
const items = [...actions.children].filter(item => item.getClientRects().length);
|
|
5
|
+
const style = getComputedStyle(actions);
|
|
6
|
+
return inlineEdges(style)
|
|
7
|
+
+ gapWidth(style, items.length)
|
|
8
|
+
+ items.reduce((width, item) => width + item.getBoundingClientRect().width, 0);
|
|
9
|
+
}
|
|
10
|
+
function contentWidth(element, style) {
|
|
11
|
+
const range = document.createRange();
|
|
12
|
+
range.selectNodeContents(element);
|
|
13
|
+
return range.getBoundingClientRect().width + inlineEdges(style);
|
|
14
|
+
}
|
|
15
|
+
function filterWidth(filter) {
|
|
16
|
+
const icon = filter.querySelector('.list-filter-icon');
|
|
17
|
+
let width = inlineEdges(getComputedStyle(filter));
|
|
18
|
+
if (!icon)
|
|
19
|
+
return width;
|
|
20
|
+
const text = filter.querySelector('.list-filter-text');
|
|
21
|
+
const row = icon.parentElement;
|
|
22
|
+
width += icon.getBoundingClientRect().width;
|
|
23
|
+
const rowStyle = getComputedStyle(row);
|
|
24
|
+
if (row !== filter) {
|
|
25
|
+
width += inlineEdges(rowStyle);
|
|
26
|
+
}
|
|
27
|
+
if (text) {
|
|
28
|
+
const textStyle = getComputedStyle(text);
|
|
29
|
+
width += gapWidth(rowStyle, 2) + Math.max(contentWidth(text, textStyle), pixels(textStyle.minWidth));
|
|
30
|
+
}
|
|
31
|
+
return width;
|
|
32
|
+
}
|
|
33
|
+
function gapWidth(style, items) {
|
|
34
|
+
return Math.max(0, items - 1) * pixels(style.columnGap);
|
|
35
|
+
}
|
|
36
|
+
function inlineEdges(style) {
|
|
37
|
+
return pixels(style.paddingInlineStart) + pixels(style.paddingInlineEnd)
|
|
38
|
+
+ pixels(style.borderInlineStartWidth) + pixels(style.borderInlineEndWidth);
|
|
39
|
+
}
|
|
40
|
+
function pixels(value) {
|
|
41
|
+
return Number.parseFloat(value) || 0;
|
|
42
|
+
}
|
|
43
|
+
function watchToolbar(toolbar) {
|
|
44
|
+
if (toolbars.has(toolbar))
|
|
45
|
+
return;
|
|
46
|
+
const actions = toolbar.querySelector(':scope > .general.actions');
|
|
47
|
+
const add = toolbar.querySelector(':scope > .add-column');
|
|
48
|
+
const count = toolbar.querySelector(':scope > .summary');
|
|
49
|
+
const filter = toolbar.querySelector(':scope > .list-filter');
|
|
50
|
+
const abort = new AbortController();
|
|
51
|
+
let frame;
|
|
52
|
+
function update() {
|
|
53
|
+
frame = undefined;
|
|
54
|
+
const style = getComputedStyle(toolbar);
|
|
55
|
+
const available = toolbar.getBoundingClientRect().width - inlineEdges(style);
|
|
56
|
+
const gaps = (add.hidden ? 2 : 3) * pixels(style.getPropertyValue('--list-toolbar-gap'));
|
|
57
|
+
const required = actionsWidth(actions) + filterWidth(filter) + contentWidth(count, getComputedStyle(count))
|
|
58
|
+
+ add.getBoundingClientRect().width + gaps;
|
|
59
|
+
toolbar.toggleAttribute('data-filter-row', required > available);
|
|
60
|
+
}
|
|
61
|
+
function schedule() {
|
|
62
|
+
frame ??= requestAnimationFrame(update);
|
|
63
|
+
}
|
|
64
|
+
const resize = new ResizeObserver(schedule);
|
|
65
|
+
for (const element of [toolbar, add, count, ...actions.children]) {
|
|
66
|
+
resize.observe(element);
|
|
67
|
+
}
|
|
68
|
+
const mutations = new MutationObserver(schedule);
|
|
69
|
+
mutations.observe(toolbar, { attributeFilter: ['hidden'], characterData: true, childList: true, subtree: true });
|
|
70
|
+
for (const event of ['focusin', 'focusout', 'input']) {
|
|
71
|
+
toolbar.addEventListener(event, schedule, { signal: abort.signal });
|
|
72
|
+
}
|
|
73
|
+
document.fonts.addEventListener('loadingdone', schedule, { signal: abort.signal });
|
|
74
|
+
toolbars.set(toolbar, () => {
|
|
75
|
+
if (frame !== undefined) {
|
|
76
|
+
cancelAnimationFrame(frame);
|
|
77
|
+
}
|
|
78
|
+
abort.abort();
|
|
79
|
+
mutations.disconnect();
|
|
80
|
+
resize.disconnect();
|
|
81
|
+
});
|
|
82
|
+
update();
|
|
83
|
+
}
|
|
84
|
+
build('article[data-action="list"] > header > .list-toolbar', watchToolbar);
|
|
85
|
+
new MutationObserver(() => {
|
|
86
|
+
for (const [toolbar, dispose] of toolbars) {
|
|
87
|
+
if (toolbar.isConnected)
|
|
88
|
+
continue;
|
|
89
|
+
dispose();
|
|
90
|
+
toolbars.delete(toolbar);
|
|
91
|
+
}
|
|
92
|
+
}).observe(document.body, { childList: true, subtree: true });
|