@pageboard/html 0.14.33 → 0.14.35
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/elements/form.js +1 -1
- package/elements/link.js +2 -3
- package/elements/menu.js +1 -1
- package/elements/pagination.js +1 -1
- package/package.json +1 -1
- package/ui/fieldset-list.js +19 -5
- package/ui/form.js +7 -9
- package/ui/pagination.js +7 -6
- package/ui/transition.js +3 -3
package/elements/form.js
CHANGED
package/elements/link.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.link = {
|
|
|
44
44
|
inline: true,
|
|
45
45
|
group: "inline",
|
|
46
46
|
tag: 'a:not([block-type]),a[block-type="link"]',
|
|
47
|
-
html: '<a href="[url]" hreflang="[lang]" class="[button|alt:ui button]" id="[id]"></a>',
|
|
47
|
+
html: '<a href="[url|lang:[lang]]" hreflang="[lang]" class="[button|alt:ui button]" id="[id]"></a>',
|
|
48
48
|
stylesheets: [
|
|
49
49
|
'../ui/components/button.css'
|
|
50
50
|
]
|
|
@@ -110,8 +110,7 @@ exports.link_button = {
|
|
|
110
110
|
},
|
|
111
111
|
contents: "text*",
|
|
112
112
|
group: "block",
|
|
113
|
-
|
|
114
|
-
html: '<a href="[url]" hreflang="[lang]" class="ui [full|alt:fluid:] [icon] [compact] [float|post:%20floated] button"></a>',
|
|
113
|
+
html: '<a href="[url|lang:[lang]]" hreflang="[lang]" class="ui [full|alt:fluid:] [icon] [compact] [float|post:%20floated] button"></a>',
|
|
115
114
|
stylesheets: [
|
|
116
115
|
'../ui/components/button.css'
|
|
117
116
|
]
|
package/elements/menu.js
CHANGED
|
@@ -120,7 +120,7 @@ exports.menu_item_link = {
|
|
|
120
120
|
marks: "nolink"
|
|
121
121
|
},
|
|
122
122
|
group: 'menu_item',
|
|
123
|
-
html: '<a class="[labeled] item" href="[url]" hreflang="[lang]">Link</a>'
|
|
123
|
+
html: '<a class="[labeled] item" href="[url|lang:[lang]]" hreflang="[lang]">Link</a>'
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
exports.menu_item_block = { ...exports.menu_item_link,
|
package/elements/pagination.js
CHANGED
package/package.json
CHANGED
package/ui/fieldset-list.js
CHANGED
|
@@ -224,14 +224,28 @@ class HTMLElementFieldsetList extends Page.Element {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
#findIndex(btn) {
|
|
227
|
+
#findIndex(btn, add) {
|
|
228
228
|
let node = btn;
|
|
229
229
|
const sel = `[name^="${this.#prefixStr}"]`;
|
|
230
230
|
while ((node = node.parentNode)) {
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
231
|
+
const list = Array.from(node.querySelectorAll(sel));
|
|
232
|
+
if (!list.length) continue;
|
|
233
|
+
const first = list[0];
|
|
234
|
+
const last = list.pop();
|
|
235
|
+
let offset = 0;
|
|
236
|
+
let input;
|
|
237
|
+
if (btn.compareDocumentPosition(last) & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
238
|
+
// after last
|
|
239
|
+
if (add) offset += 1;
|
|
240
|
+
input = last;
|
|
241
|
+
} else if (first.compareDocumentPosition(btn) & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
242
|
+
input = first;
|
|
243
|
+
}
|
|
244
|
+
|
|
233
245
|
const { index } = this.#parseName(input.name);
|
|
234
|
-
if (index >= 0 && index < this.#list.length)
|
|
246
|
+
if (index >= 0 && index < this.#list.length) {
|
|
247
|
+
return index + offset;
|
|
248
|
+
}
|
|
235
249
|
}
|
|
236
250
|
}
|
|
237
251
|
|
|
@@ -246,7 +260,7 @@ class HTMLElementFieldsetList extends Page.Element {
|
|
|
246
260
|
|
|
247
261
|
switch (action) {
|
|
248
262
|
case "add":
|
|
249
|
-
list.splice((this.#findIndex(btn) ?? 0), 0, { ...this.#model });
|
|
263
|
+
list.splice((this.#findIndex(btn, true) ?? 0), 0, { ...this.#model });
|
|
250
264
|
break;
|
|
251
265
|
case "del":
|
|
252
266
|
list.splice(this.#findIndex(btn) ?? 0, 1);
|
package/ui/form.js
CHANGED
|
@@ -82,10 +82,9 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
82
82
|
if (masked) toggles.push(submit);
|
|
83
83
|
state.vars.submit = true;
|
|
84
84
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
85
|
+
const actionLoc = Page.parse(this.getAttribute('action'));
|
|
86
|
+
Object.assign(actionLoc.query, state.templatesQuery(this));
|
|
87
|
+
this.setAttribute('action', Page.format(actionLoc));
|
|
89
88
|
this.restore(state.scope);
|
|
90
89
|
} else {
|
|
91
90
|
for (const name of this.fill(state.query)) {
|
|
@@ -324,10 +323,9 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
324
323
|
scope.$request = form.read(true, e.submitter);
|
|
325
324
|
form.disable();
|
|
326
325
|
form.classList.add('loading');
|
|
327
|
-
scope.$response = await state.fetch(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}), scope.$request);
|
|
326
|
+
scope.$response = await state.fetch(
|
|
327
|
+
form.method, form.getAttribute('action'), scope.$request
|
|
328
|
+
);
|
|
331
329
|
} catch (err) {
|
|
332
330
|
scope.$response = err;
|
|
333
331
|
}
|
|
@@ -359,7 +357,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
359
357
|
form.backup();
|
|
360
358
|
}
|
|
361
359
|
|
|
362
|
-
const loc = Page.parse(redirect
|
|
360
|
+
const loc = Page.parse(redirect.fuse({}, scope));
|
|
363
361
|
let vary = false;
|
|
364
362
|
if (loc.samePathname(state)) {
|
|
365
363
|
if (res.granted) {
|
package/ui/pagination.js
CHANGED
|
@@ -7,28 +7,29 @@ class HTMLElementPagination extends Page.create(HTMLAnchorElement) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
#update(state) {
|
|
10
|
+
const { fetch } = this.dataset;
|
|
10
11
|
const node = this.ownerDocument.querySelector(
|
|
11
|
-
`element-template[action="/.api/query/${
|
|
12
|
+
`element-template[action="/.api/query/${fetch}"]`
|
|
12
13
|
);
|
|
13
14
|
if (!node) {
|
|
14
|
-
console.warn("pagination does not find fetch node",
|
|
15
|
+
console.warn("pagination does not find fetch node", fetch);
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
+
const { offsetName } = node.dataset;
|
|
18
19
|
const offset = parseInt(node.dataset.offset) || 0;
|
|
19
20
|
const limit = parseInt(node.dataset.limit) || 10;
|
|
20
21
|
const count = parseInt(node.dataset.count) || 0;
|
|
21
22
|
const sign = this.dataset.dir == "-" ? -1 : +1;
|
|
22
|
-
const cur = sign > 0 ? offset :
|
|
23
|
+
const cur = sign > 0 ? offset + limit : offset - limit;
|
|
23
24
|
|
|
24
25
|
this.setAttribute('href', Page.format({
|
|
25
26
|
pathname: state.pathname,
|
|
26
27
|
query: {
|
|
27
28
|
...state.query,
|
|
28
|
-
[
|
|
29
|
+
[offsetName]: cur
|
|
29
30
|
}
|
|
30
31
|
}));
|
|
31
|
-
this.disabled = sign < 0 &&
|
|
32
|
+
this.disabled = sign < 0 && cur < 0 || sign > 0 && cur >= count;
|
|
32
33
|
}
|
|
33
34
|
handleClick(e) {
|
|
34
35
|
if (this.disabled) {
|
package/ui/transition.js
CHANGED
|
@@ -26,11 +26,11 @@ const loader = new class {
|
|
|
26
26
|
update(state) {
|
|
27
27
|
document.documentElement.dataset.stage = state.stage;
|
|
28
28
|
}
|
|
29
|
-
setup(state) {
|
|
29
|
+
async setup(state) {
|
|
30
30
|
const tr = state.scope.transition;
|
|
31
|
+
await document.fonts?.ready;
|
|
32
|
+
document.body.hidden = false;
|
|
31
33
|
state.finish(async () => {
|
|
32
|
-
await document.fonts?.ready;
|
|
33
|
-
document.body.hidden = false;
|
|
34
34
|
if (tr?.ok) return tr.start();
|
|
35
35
|
});
|
|
36
36
|
tr?.end();
|