haori 0.4.2 → 0.4.3
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.ja.md +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +7 -7
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +448 -402
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +7 -7
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +3 -0
- package/dist/src/form.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/procedure.d.ts +16 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +68 -8
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/form.test.js +27 -0
- package/dist/tests/form.test.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +148 -3
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -29,13 +29,13 @@ const O = class O {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
|
-
let
|
|
32
|
+
let B = O;
|
|
33
33
|
const W = "embedded";
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function _(F) {
|
|
35
|
+
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
37
|
+
function et(F) {
|
|
38
|
+
return F === null ? null : _(F) ? F : W;
|
|
39
39
|
}
|
|
40
40
|
const M = class M {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const M = class M {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
M._runtime =
|
|
56
|
+
M._runtime = _(t) ? t : W;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,21 +67,21 @@ const M = class M {
|
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
68
|
const r = t.getAttribute("data-prefix") || M._prefix;
|
|
69
69
|
M._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const i =
|
|
70
|
+
const i = et(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
73
|
i !== null && (M._runtime = i);
|
|
74
74
|
}
|
|
75
75
|
if (t instanceof HTMLScriptElement && t.hasAttribute(`${M._prefix}dev`)) {
|
|
76
|
-
|
|
76
|
+
B.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const e = window.location.hostname;
|
|
80
80
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
81
|
-
|
|
81
|
+
B.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
B.set(!1);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -95,8 +95,8 @@ const M = class M {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
M._prefix = "data-", M._runtime = W;
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
98
|
+
let c = M;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
100
100
|
class h {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
@@ -105,7 +105,7 @@ class h {
|
|
|
105
105
|
* @param args 追加の引数
|
|
106
106
|
*/
|
|
107
107
|
static info(t, ...e) {
|
|
108
|
-
|
|
108
|
+
B.isEnabled() && console.log && console.log(t, ...e);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -114,7 +114,7 @@ class h {
|
|
|
114
114
|
* @param args 追加の引数
|
|
115
115
|
*/
|
|
116
116
|
static warn(t, ...e) {
|
|
117
|
-
|
|
117
|
+
B.isEnabled() && console.warn && console.warn(t, ...e);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -126,7 +126,7 @@ class h {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class rt {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -220,16 +220,16 @@ const z = class z {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
z.ASYNC_QUEUE = new
|
|
224
|
-
let
|
|
225
|
-
class
|
|
223
|
+
z.ASYNC_QUEUE = new rt();
|
|
224
|
+
let P = z;
|
|
225
|
+
class tt {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return c.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class _ {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
c.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -247,7 +247,7 @@ class _ {
|
|
|
247
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
248
248
|
*/
|
|
249
249
|
static dialog(t) {
|
|
250
|
-
return
|
|
250
|
+
return P.enqueue(() => {
|
|
251
251
|
window.alert(t);
|
|
252
252
|
}, !0);
|
|
253
253
|
}
|
|
@@ -275,7 +275,7 @@ class _ {
|
|
|
275
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
276
276
|
*/
|
|
277
277
|
static confirm(t) {
|
|
278
|
-
return
|
|
278
|
+
return P.enqueue(() => window.confirm(t), !0);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* ダイアログを開きます。
|
|
@@ -283,7 +283,7 @@ class _ {
|
|
|
283
283
|
* @param element 開くダイアログのHTML要素
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
|
-
return
|
|
286
|
+
return P.enqueue(() => {
|
|
287
287
|
t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
@@ -293,7 +293,7 @@ class _ {
|
|
|
293
293
|
* @param element 閉じるダイアログのHTML要素
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
|
-
return
|
|
296
|
+
return P.enqueue(() => {
|
|
297
297
|
t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
@@ -304,7 +304,7 @@ class _ {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
-
return
|
|
307
|
+
return P.enqueue(() => {
|
|
308
308
|
if (t instanceof HTMLFormElement) {
|
|
309
309
|
t.setAttribute("data-message", e);
|
|
310
310
|
return;
|
|
@@ -322,19 +322,19 @@ class _ {
|
|
|
322
322
|
* @param parent メッセージをクリアする親要素
|
|
323
323
|
*/
|
|
324
324
|
static clearMessages(t) {
|
|
325
|
-
return
|
|
325
|
+
return P.enqueue(() => {
|
|
326
326
|
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
327
327
|
e.removeAttribute("data-message");
|
|
328
328
|
});
|
|
329
329
|
}, !0);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
const
|
|
333
|
-
function
|
|
332
|
+
const it = ["addErrorMessage", "clearMessages"];
|
|
333
|
+
function Z() {
|
|
334
334
|
const t = globalThis.window?.Haori;
|
|
335
|
-
return
|
|
335
|
+
return it.every(
|
|
336
336
|
(r) => typeof t?.[r] == "function"
|
|
337
|
-
) ? t :
|
|
337
|
+
) ? t : tt;
|
|
338
338
|
}
|
|
339
339
|
class m {
|
|
340
340
|
/**
|
|
@@ -358,11 +358,11 @@ class m {
|
|
|
358
358
|
* @returns values と同じオブジェクト
|
|
359
359
|
*/
|
|
360
360
|
static getPartValues(t, e) {
|
|
361
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${
|
|
361
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`), s = t.getAttribute(`${c.prefix}form-list`);
|
|
362
362
|
if (r) {
|
|
363
363
|
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && h.warn(
|
|
364
364
|
"Haori",
|
|
365
|
-
`Element cannot have both ${
|
|
365
|
+
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
366
366
|
);
|
|
367
367
|
for (const n of t.getChildElementFragments())
|
|
368
368
|
m.getPartValues(n, e);
|
|
@@ -372,7 +372,7 @@ class m {
|
|
|
372
372
|
m.getPartValues(a, n);
|
|
373
373
|
Object.keys(n).length > 0 && (e[String(i)] = n), s && h.warn(
|
|
374
374
|
"Haori",
|
|
375
|
-
`Element cannot have both ${
|
|
375
|
+
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
376
376
|
);
|
|
377
377
|
} else if (s) {
|
|
378
378
|
const n = [];
|
|
@@ -431,23 +431,23 @@ class m {
|
|
|
431
431
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
432
432
|
*/
|
|
433
433
|
static setPartValues(t, e, r = null, i = !1, s = !0) {
|
|
434
|
-
const n = [], a = t.getAttribute("name"), o = t.getAttribute(`${
|
|
434
|
+
const n = [], a = t.getAttribute("name"), o = t.getAttribute(`${c.prefix}form-object`), d = t.getAttribute(`${c.prefix}form-list`), y = t.getAttribute(`${c.prefix}form-detach`);
|
|
435
435
|
if (a) {
|
|
436
436
|
if (!y || i) {
|
|
437
437
|
const b = e[String(a)];
|
|
438
438
|
d && Array.isArray(b) && r !== null ? n.push(
|
|
439
439
|
m.applyFragmentValue(t, b[r] ?? null, s)
|
|
440
|
-
) : typeof b == "string" || typeof b == "number" || typeof b == "boolean" || b === null ? n.push(m.applyFragmentValue(t, b, s)) : n.push(
|
|
440
|
+
) : typeof b > "u" || (typeof b == "string" || typeof b == "number" || typeof b == "boolean" || b === null ? n.push(m.applyFragmentValue(t, b, s)) : n.push(
|
|
441
441
|
m.applyFragmentValue(t, String(b), s)
|
|
442
|
-
);
|
|
442
|
+
));
|
|
443
443
|
}
|
|
444
444
|
} else if (o) {
|
|
445
445
|
const b = e[String(o)];
|
|
446
446
|
if (b && typeof b == "object")
|
|
447
|
-
for (const
|
|
447
|
+
for (const A of t.getChildElementFragments())
|
|
448
448
|
n.push(
|
|
449
449
|
m.setPartValues(
|
|
450
|
-
|
|
450
|
+
A,
|
|
451
451
|
b,
|
|
452
452
|
null,
|
|
453
453
|
i,
|
|
@@ -457,18 +457,18 @@ class m {
|
|
|
457
457
|
} else if (d) {
|
|
458
458
|
const b = e[String(d)];
|
|
459
459
|
if (Array.isArray(b)) {
|
|
460
|
-
const
|
|
461
|
-
for (let
|
|
462
|
-
const
|
|
463
|
-
b.length >
|
|
460
|
+
const A = t.getChildElementFragments();
|
|
461
|
+
for (let S = 0; S < A.length; S++) {
|
|
462
|
+
const l = A[S];
|
|
463
|
+
b.length > S ? n.push(
|
|
464
464
|
m.setPartValues(
|
|
465
|
-
|
|
466
|
-
b[
|
|
467
|
-
|
|
465
|
+
l,
|
|
466
|
+
b[S],
|
|
467
|
+
S,
|
|
468
468
|
i,
|
|
469
469
|
s
|
|
470
470
|
)
|
|
471
|
-
) : n.push(m.setPartValues(
|
|
471
|
+
) : n.push(m.setPartValues(l, {}, S, i, s));
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
} else
|
|
@@ -490,7 +490,7 @@ class m {
|
|
|
490
490
|
m.clearValues(t), await Promise.all([
|
|
491
491
|
m.clearMessages(t),
|
|
492
492
|
m.clearEachClones(t)
|
|
493
|
-
]), await
|
|
493
|
+
]), await P.enqueue(() => {
|
|
494
494
|
const e = t.getTarget();
|
|
495
495
|
if (e instanceof HTMLFormElement)
|
|
496
496
|
e.reset();
|
|
@@ -511,9 +511,9 @@ class m {
|
|
|
511
511
|
*/
|
|
512
512
|
static clearEachClones(t) {
|
|
513
513
|
const e = [], r = (s) => {
|
|
514
|
-
if (s.hasAttribute(`${
|
|
514
|
+
if (s.hasAttribute(`${c.prefix}each`))
|
|
515
515
|
for (const n of s.getChildElementFragments()) {
|
|
516
|
-
const a = n.hasAttribute(`${
|
|
516
|
+
const a = n.hasAttribute(`${c.prefix}each-before`), o = n.hasAttribute(`${c.prefix}each-after`);
|
|
517
517
|
!a && !o && e.push(n.remove());
|
|
518
518
|
}
|
|
519
519
|
}, i = (s) => {
|
|
@@ -544,7 +544,7 @@ class m {
|
|
|
544
544
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
545
545
|
*/
|
|
546
546
|
static clearMessages(t) {
|
|
547
|
-
return
|
|
547
|
+
return Z().clearMessages(
|
|
548
548
|
t.getTarget()
|
|
549
549
|
);
|
|
550
550
|
}
|
|
@@ -558,7 +558,7 @@ class m {
|
|
|
558
558
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
559
559
|
*/
|
|
560
560
|
static addErrorMessage(t, e, r) {
|
|
561
|
-
const i = [], s =
|
|
561
|
+
const i = [], s = Z(), n = m.findFragmentsByKey(t, e);
|
|
562
562
|
return n.forEach((a) => {
|
|
563
563
|
i.push(
|
|
564
564
|
s.addErrorMessage(a.getTarget(), r)
|
|
@@ -588,13 +588,13 @@ class m {
|
|
|
588
588
|
*/
|
|
589
589
|
static findFragmentByKeyParts(t, e) {
|
|
590
590
|
const r = [], i = e[0];
|
|
591
|
-
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${
|
|
592
|
-
e.length > 1 && t.getAttribute(`${
|
|
591
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${c.prefix}form-object`))
|
|
592
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
593
593
|
r.push(...m.findFragmentByKeyParts(n, e.slice(1)));
|
|
594
594
|
});
|
|
595
|
-
else if (t.hasAttribute(`${
|
|
595
|
+
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
596
596
|
if (e.length > 1) {
|
|
597
|
-
const s = t.getAttribute(`${
|
|
597
|
+
const s = t.getAttribute(`${c.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
598
598
|
if (n !== -1 && a !== -1 && n < a) {
|
|
599
599
|
const o = i.substring(0, n);
|
|
600
600
|
if (s === o) {
|
|
@@ -602,7 +602,7 @@ class m {
|
|
|
602
602
|
if (isNaN(y))
|
|
603
603
|
h.error("Haori", `Invalid index: ${i}`);
|
|
604
604
|
else {
|
|
605
|
-
const b = t.getChildElementFragments().filter((
|
|
605
|
+
const b = t.getChildElementFragments().filter((A) => A.hasAttribute(`${c.prefix}row`));
|
|
606
606
|
y < b.length && r.push(
|
|
607
607
|
...m.findFragmentByKeyParts(b[y], e.slice(1))
|
|
608
608
|
);
|
|
@@ -629,7 +629,7 @@ class m {
|
|
|
629
629
|
return r ? this.getFormFragment(r) : null;
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
|
-
const
|
|
632
|
+
const R = class R {
|
|
633
633
|
/**
|
|
634
634
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
635
635
|
*
|
|
@@ -1122,7 +1122,7 @@ return (${t});`;
|
|
|
1122
1122
|
return !1;
|
|
1123
1123
|
}
|
|
1124
1124
|
};
|
|
1125
|
-
|
|
1125
|
+
R.FORBIDDEN_NAMES = [
|
|
1126
1126
|
// グローバルオブジェクト
|
|
1127
1127
|
"window",
|
|
1128
1128
|
"self",
|
|
@@ -1154,19 +1154,19 @@ P.FORBIDDEN_NAMES = [
|
|
|
1154
1154
|
"sessionStorage",
|
|
1155
1155
|
"IndexedDB",
|
|
1156
1156
|
"history"
|
|
1157
|
-
],
|
|
1158
|
-
...
|
|
1159
|
-
(t) => !
|
|
1157
|
+
], R.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], R.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), R.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1158
|
+
...R.FORBIDDEN_NAMES.filter(
|
|
1159
|
+
(t) => !R.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1160
1160
|
),
|
|
1161
1161
|
"constructor",
|
|
1162
1162
|
"__proto__",
|
|
1163
1163
|
"prototype",
|
|
1164
|
-
...
|
|
1165
|
-
]),
|
|
1164
|
+
...R.STRICT_FORBIDDEN_NAMES
|
|
1165
|
+
]), R.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1166
1166
|
"constructor",
|
|
1167
1167
|
"__proto__",
|
|
1168
1168
|
"prototype"
|
|
1169
|
-
]),
|
|
1169
|
+
]), R.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1170
1170
|
"await",
|
|
1171
1171
|
"break",
|
|
1172
1172
|
"case",
|
|
@@ -1200,8 +1200,8 @@ P.FORBIDDEN_NAMES = [
|
|
|
1200
1200
|
"while",
|
|
1201
1201
|
"with",
|
|
1202
1202
|
"yield"
|
|
1203
|
-
]),
|
|
1204
|
-
let j =
|
|
1203
|
+
]), R.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1204
|
+
let j = R;
|
|
1205
1205
|
const C = class C {
|
|
1206
1206
|
/**
|
|
1207
1207
|
* フラグメントのコンストラクタ。
|
|
@@ -1250,7 +1250,7 @@ const C = class C {
|
|
|
1250
1250
|
return Promise.resolve();
|
|
1251
1251
|
if (this.parent) {
|
|
1252
1252
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1253
|
-
return
|
|
1253
|
+
return P.enqueue(() => {
|
|
1254
1254
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1255
1255
|
}).finally(() => {
|
|
1256
1256
|
t.skipMutationNodes = e;
|
|
@@ -1258,7 +1258,7 @@ const C = class C {
|
|
|
1258
1258
|
} else {
|
|
1259
1259
|
const t = this.target.parentNode;
|
|
1260
1260
|
if (t)
|
|
1261
|
-
return
|
|
1261
|
+
return P.enqueue(() => {
|
|
1262
1262
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1263
1263
|
});
|
|
1264
1264
|
this.mounted = !1;
|
|
@@ -1275,7 +1275,7 @@ const C = class C {
|
|
|
1275
1275
|
return Promise.resolve();
|
|
1276
1276
|
if (this.parent) {
|
|
1277
1277
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1278
|
-
return
|
|
1278
|
+
return P.enqueue(() => {
|
|
1279
1279
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1280
1280
|
}).finally(() => {
|
|
1281
1281
|
t.skipMutationNodes = e;
|
|
@@ -1361,7 +1361,7 @@ class D extends N {
|
|
|
1361
1361
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
|
|
1362
1362
|
const r = t.getAttribute(e);
|
|
1363
1363
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1364
|
-
const i = new
|
|
1364
|
+
const i = new U(e, r);
|
|
1365
1365
|
this.attributeMap.set(e, i);
|
|
1366
1366
|
}
|
|
1367
1367
|
}), t.childNodes.forEach((e) => {
|
|
@@ -1554,12 +1554,12 @@ class D extends N {
|
|
|
1554
1554
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1555
1555
|
const i = this.getAttribute("value"), s = r.type === "checkbox" && i === "true";
|
|
1556
1556
|
let n;
|
|
1557
|
-
return s ? n = t === !0 || t === "true" : i === "false" ? n = t === !1 : n = i === String(t), this.value = s ? n : n ? t : null, r.checked === n ? Promise.resolve() : (this.skipChangeValue = !0,
|
|
1557
|
+
return s ? n = t === !0 || t === "true" : i === "false" ? n = t === !1 : n = i === String(t), this.value = s ? n : n ? t : null, r.checked === n ? Promise.resolve() : (this.skipChangeValue = !0, P.enqueue(() => {
|
|
1558
1558
|
r.checked = n, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1559
1559
|
}).finally(() => {
|
|
1560
1560
|
this.skipChangeValue = !1;
|
|
1561
1561
|
}));
|
|
1562
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1562
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, P.enqueue(() => {
|
|
1563
1563
|
r.value = t === null ? "" : String(t), e && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
1564
1564
|
}).finally(() => {
|
|
1565
1565
|
this.skipChangeValue = !1;
|
|
@@ -1618,10 +1618,10 @@ class D extends N {
|
|
|
1618
1618
|
return Promise.resolve();
|
|
1619
1619
|
if (e === null)
|
|
1620
1620
|
return this.removeAttribute(t);
|
|
1621
|
-
const r = new
|
|
1621
|
+
const r = new U(t, e);
|
|
1622
1622
|
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1623
1623
|
const i = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1624
|
-
return
|
|
1624
|
+
return P.enqueue(() => {
|
|
1625
1625
|
if (s === null || s === !1)
|
|
1626
1626
|
i.removeAttribute(t);
|
|
1627
1627
|
else {
|
|
@@ -1643,7 +1643,7 @@ class D extends N {
|
|
|
1643
1643
|
return Promise.resolve();
|
|
1644
1644
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1645
1645
|
const e = this.getTarget();
|
|
1646
|
-
return
|
|
1646
|
+
return P.enqueue(() => {
|
|
1647
1647
|
e.removeAttribute(t);
|
|
1648
1648
|
}).finally(() => {
|
|
1649
1649
|
this.skipMutationAttributes = !1;
|
|
@@ -1661,7 +1661,7 @@ class D extends N {
|
|
|
1661
1661
|
if (e === void 0)
|
|
1662
1662
|
return null;
|
|
1663
1663
|
const r = e.evaluate(this.getBindingData());
|
|
1664
|
-
return r.length === 1 ? r[0] :
|
|
1664
|
+
return r.length === 1 ? r[0] : I.joinEvaluateResults(r);
|
|
1665
1665
|
}
|
|
1666
1666
|
/**
|
|
1667
1667
|
* 属性の生の値を取得します。
|
|
@@ -1742,23 +1742,23 @@ class D extends N {
|
|
|
1742
1742
|
if (e === null)
|
|
1743
1743
|
this.children.push(t);
|
|
1744
1744
|
else {
|
|
1745
|
-
let
|
|
1746
|
-
if (n ? a !== -1 && a < o ?
|
|
1747
|
-
const
|
|
1745
|
+
let A;
|
|
1746
|
+
if (n ? a !== -1 && a < o ? A = o - 1 : A = o : A = this.children.indexOf(e), A === -1) {
|
|
1747
|
+
const S = this.resolveInsertionPointFromDom(
|
|
1748
1748
|
e,
|
|
1749
1749
|
!1
|
|
1750
1750
|
);
|
|
1751
|
-
|
|
1751
|
+
S === null ? (h.warn(
|
|
1752
1752
|
"[Haori]",
|
|
1753
1753
|
"Reference child not found in children.",
|
|
1754
1754
|
e
|
|
1755
|
-
), this.children.push(t)) : (this.children.splice(
|
|
1755
|
+
), this.children.push(t)) : (this.children.splice(S.index, 0, t), y = S.referenceNode);
|
|
1756
1756
|
} else
|
|
1757
|
-
this.children.splice(
|
|
1757
|
+
this.children.splice(A, 0, t);
|
|
1758
1758
|
}
|
|
1759
1759
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1760
1760
|
const b = this.skipMutationNodes;
|
|
1761
|
-
return this.skipMutationNodes = !0,
|
|
1761
|
+
return this.skipMutationNodes = !0, P.enqueue(() => {
|
|
1762
1762
|
this.target.insertBefore(t.getTarget(), y);
|
|
1763
1763
|
}).finally(() => {
|
|
1764
1764
|
this.skipMutationNodes = b;
|
|
@@ -1832,7 +1832,7 @@ class D extends N {
|
|
|
1832
1832
|
* @returns エレメントの非表示のPromise
|
|
1833
1833
|
*/
|
|
1834
1834
|
hide() {
|
|
1835
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1835
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${c.prefix}if-false`, ""), Promise.resolve();
|
|
1836
1836
|
}
|
|
1837
1837
|
/**
|
|
1838
1838
|
* エレメントを表示します。
|
|
@@ -1840,7 +1840,7 @@ class D extends N {
|
|
|
1840
1840
|
* @return エレメントの表示のPromise
|
|
1841
1841
|
*/
|
|
1842
1842
|
show() {
|
|
1843
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1843
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${c.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1844
1844
|
}
|
|
1845
1845
|
/**
|
|
1846
1846
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1864,7 +1864,7 @@ class L extends N {
|
|
|
1864
1864
|
* @param target 対象テキストノード
|
|
1865
1865
|
*/
|
|
1866
1866
|
constructor(t) {
|
|
1867
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1867
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new I(this.text);
|
|
1868
1868
|
}
|
|
1869
1869
|
/**
|
|
1870
1870
|
* フラグメントをクローンします。
|
|
@@ -1890,7 +1890,7 @@ class L extends N {
|
|
|
1890
1890
|
* @returns 更新のPromise
|
|
1891
1891
|
*/
|
|
1892
1892
|
setContent(t) {
|
|
1893
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1893
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new I(t), this.evaluate());
|
|
1894
1894
|
}
|
|
1895
1895
|
/**
|
|
1896
1896
|
* フラグメントを評価します。
|
|
@@ -1900,10 +1900,10 @@ class L extends N {
|
|
|
1900
1900
|
evaluate() {
|
|
1901
1901
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1902
1902
|
new Error("Parent fragment is required for raw evaluation")
|
|
1903
|
-
) :
|
|
1903
|
+
) : P.enqueue(() => {
|
|
1904
1904
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1905
1905
|
this.parent.getBindingData()
|
|
1906
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1906
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = I.joinEvaluateResults(
|
|
1907
1907
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1908
1908
|
) : this.target.textContent = this.text;
|
|
1909
1909
|
}).finally(() => {
|
|
@@ -1945,14 +1945,14 @@ class Y extends N {
|
|
|
1945
1945
|
* @return 更新のPromise
|
|
1946
1946
|
*/
|
|
1947
1947
|
setContent(t) {
|
|
1948
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
1948
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, P.enqueue(() => {
|
|
1949
1949
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
1950
1950
|
}).finally(() => {
|
|
1951
1951
|
this.skipMutation = !1;
|
|
1952
1952
|
}));
|
|
1953
1953
|
}
|
|
1954
1954
|
}
|
|
1955
|
-
const
|
|
1955
|
+
const G = class G {
|
|
1956
1956
|
/**
|
|
1957
1957
|
* コンストラクタ。
|
|
1958
1958
|
*
|
|
@@ -1960,7 +1960,7 @@ const K = class K {
|
|
|
1960
1960
|
*/
|
|
1961
1961
|
constructor(t) {
|
|
1962
1962
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1963
|
-
const e = [...t.matchAll(
|
|
1963
|
+
const e = [...t.matchAll(G.PLACEHOLDER_REGEX)];
|
|
1964
1964
|
let r = 0, i = !1, s = !1;
|
|
1965
1965
|
for (const n of e) {
|
|
1966
1966
|
n.index > r && this.contents.push({
|
|
@@ -2035,9 +2035,9 @@ const K = class K {
|
|
|
2035
2035
|
}), e;
|
|
2036
2036
|
}
|
|
2037
2037
|
};
|
|
2038
|
-
|
|
2039
|
-
let
|
|
2040
|
-
const
|
|
2038
|
+
G.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2039
|
+
let I = G;
|
|
2040
|
+
const K = class K extends I {
|
|
2041
2041
|
/**
|
|
2042
2042
|
* コンストラクタ。
|
|
2043
2043
|
*
|
|
@@ -2045,7 +2045,7 @@ const J = class J extends $ {
|
|
|
2045
2045
|
* @param text 属性値
|
|
2046
2046
|
*/
|
|
2047
2047
|
constructor(t, e) {
|
|
2048
|
-
super(e), this.forceEvaluation =
|
|
2048
|
+
super(e), this.forceEvaluation = K.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2049
2049
|
}
|
|
2050
2050
|
/**
|
|
2051
2051
|
* 強制評価フラグを取得します。
|
|
@@ -2086,14 +2086,14 @@ const J = class J extends $ {
|
|
|
2086
2086
|
), [e[0]]) : e;
|
|
2087
2087
|
}
|
|
2088
2088
|
};
|
|
2089
|
-
|
|
2089
|
+
K.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2090
2090
|
"data-if",
|
|
2091
2091
|
"hor-if",
|
|
2092
2092
|
"data-each",
|
|
2093
2093
|
"hor-each"
|
|
2094
2094
|
];
|
|
2095
|
-
let
|
|
2096
|
-
class
|
|
2095
|
+
let U = K;
|
|
2096
|
+
class v {
|
|
2097
2097
|
/**
|
|
2098
2098
|
* カスタムイベントを発火します。
|
|
2099
2099
|
*
|
|
@@ -2117,7 +2117,7 @@ class w {
|
|
|
2117
2117
|
* @param version ライブラリバージョン
|
|
2118
2118
|
*/
|
|
2119
2119
|
static ready(t) {
|
|
2120
|
-
|
|
2120
|
+
v.dispatch(document, "ready", { version: t });
|
|
2121
2121
|
}
|
|
2122
2122
|
/**
|
|
2123
2123
|
* renderイベントを発火します。
|
|
@@ -2125,7 +2125,7 @@ class w {
|
|
|
2125
2125
|
* @param target 評価対象要素
|
|
2126
2126
|
*/
|
|
2127
2127
|
static render(t) {
|
|
2128
|
-
|
|
2128
|
+
v.dispatch(t, "render", { target: t });
|
|
2129
2129
|
}
|
|
2130
2130
|
/**
|
|
2131
2131
|
* importstartイベントを発火します。
|
|
@@ -2134,7 +2134,7 @@ class w {
|
|
|
2134
2134
|
* @param url インポート対象URL
|
|
2135
2135
|
*/
|
|
2136
2136
|
static importStart(t, e) {
|
|
2137
|
-
|
|
2137
|
+
v.dispatch(t, "importstart", {
|
|
2138
2138
|
url: e,
|
|
2139
2139
|
startedAt: performance.now()
|
|
2140
2140
|
});
|
|
@@ -2148,7 +2148,7 @@ class w {
|
|
|
2148
2148
|
* @param startedAt 開始時刻
|
|
2149
2149
|
*/
|
|
2150
2150
|
static importEnd(t, e, r, i) {
|
|
2151
|
-
|
|
2151
|
+
v.dispatch(t, "importend", {
|
|
2152
2152
|
url: e,
|
|
2153
2153
|
bytes: r,
|
|
2154
2154
|
durationMs: performance.now() - i
|
|
@@ -2162,7 +2162,7 @@ class w {
|
|
|
2162
2162
|
* @param error エラー内容
|
|
2163
2163
|
*/
|
|
2164
2164
|
static importError(t, e, r) {
|
|
2165
|
-
|
|
2165
|
+
v.dispatch(t, "importerror", { url: e, error: r });
|
|
2166
2166
|
}
|
|
2167
2167
|
/**
|
|
2168
2168
|
* bindchangeイベントを発火します。
|
|
@@ -2178,7 +2178,7 @@ class w {
|
|
|
2178
2178
|
const y = e?.[d], b = r[d];
|
|
2179
2179
|
y !== b && s.push(d);
|
|
2180
2180
|
}
|
|
2181
|
-
|
|
2181
|
+
v.dispatch(t, "bindchange", {
|
|
2182
2182
|
previous: e || {},
|
|
2183
2183
|
next: r,
|
|
2184
2184
|
changedKeys: s,
|
|
@@ -2194,7 +2194,7 @@ class w {
|
|
|
2194
2194
|
* @param order 現在の順序
|
|
2195
2195
|
*/
|
|
2196
2196
|
static eachUpdate(t, e, r, i) {
|
|
2197
|
-
|
|
2197
|
+
v.dispatch(t, "eachupdate", {
|
|
2198
2198
|
added: e,
|
|
2199
2199
|
removed: r,
|
|
2200
2200
|
order: i,
|
|
@@ -2210,7 +2210,7 @@ class w {
|
|
|
2210
2210
|
* @param item 行データ
|
|
2211
2211
|
*/
|
|
2212
2212
|
static rowAdd(t, e, r, i) {
|
|
2213
|
-
|
|
2213
|
+
v.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2214
2214
|
}
|
|
2215
2215
|
/**
|
|
2216
2216
|
* rowremoveイベントを発火します。
|
|
@@ -2220,7 +2220,7 @@ class w {
|
|
|
2220
2220
|
* @param index インデックス
|
|
2221
2221
|
*/
|
|
2222
2222
|
static rowRemove(t, e, r) {
|
|
2223
|
-
|
|
2223
|
+
v.dispatch(t, "rowremove", { key: e, index: r });
|
|
2224
2224
|
}
|
|
2225
2225
|
/**
|
|
2226
2226
|
* rowmoveイベントを発火します。
|
|
@@ -2231,7 +2231,7 @@ class w {
|
|
|
2231
2231
|
* @param to 移動後インデックス
|
|
2232
2232
|
*/
|
|
2233
2233
|
static rowMove(t, e, r, i) {
|
|
2234
|
-
|
|
2234
|
+
v.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2235
2235
|
}
|
|
2236
2236
|
/**
|
|
2237
2237
|
* showイベントを発火します。
|
|
@@ -2239,7 +2239,7 @@ class w {
|
|
|
2239
2239
|
* @param target data-if要素
|
|
2240
2240
|
*/
|
|
2241
2241
|
static show(t) {
|
|
2242
|
-
|
|
2242
|
+
v.dispatch(t, "show", { visible: !0 });
|
|
2243
2243
|
}
|
|
2244
2244
|
/**
|
|
2245
2245
|
* hideイベントを発火します。
|
|
@@ -2247,7 +2247,7 @@ class w {
|
|
|
2247
2247
|
* @param target data-if要素
|
|
2248
2248
|
*/
|
|
2249
2249
|
static hide(t) {
|
|
2250
|
-
|
|
2250
|
+
v.dispatch(t, "hide", { visible: !1 });
|
|
2251
2251
|
}
|
|
2252
2252
|
/**
|
|
2253
2253
|
* fetchstartイベントを発火します。
|
|
@@ -2260,7 +2260,7 @@ class w {
|
|
|
2260
2260
|
* @return 戻り値はありません。
|
|
2261
2261
|
*/
|
|
2262
2262
|
static fetchStart(t, e, r, i, s) {
|
|
2263
|
-
|
|
2263
|
+
v.dispatch(t, "fetchstart", {
|
|
2264
2264
|
url: e,
|
|
2265
2265
|
options: r || {},
|
|
2266
2266
|
payload: i,
|
|
@@ -2277,7 +2277,7 @@ class w {
|
|
|
2277
2277
|
* @param startedAt 開始時刻
|
|
2278
2278
|
*/
|
|
2279
2279
|
static fetchEnd(t, e, r, i) {
|
|
2280
|
-
|
|
2280
|
+
v.dispatch(t, "fetchend", {
|
|
2281
2281
|
url: e,
|
|
2282
2282
|
status: r,
|
|
2283
2283
|
durationMs: performance.now() - i
|
|
@@ -2293,7 +2293,7 @@ class w {
|
|
|
2293
2293
|
* @param startedAt 開始時刻(存在する場合)
|
|
2294
2294
|
*/
|
|
2295
2295
|
static fetchError(t, e, r, i, s) {
|
|
2296
|
-
|
|
2296
|
+
v.dispatch(t, "fetcherror", {
|
|
2297
2297
|
url: e,
|
|
2298
2298
|
status: i,
|
|
2299
2299
|
error: r,
|
|
@@ -2301,7 +2301,7 @@ class w {
|
|
|
2301
2301
|
});
|
|
2302
2302
|
}
|
|
2303
2303
|
}
|
|
2304
|
-
const
|
|
2304
|
+
const st = [
|
|
2305
2305
|
"addErrorMessage",
|
|
2306
2306
|
"closeDialog",
|
|
2307
2307
|
"confirm",
|
|
@@ -2311,25 +2311,25 @@ const it = [
|
|
|
2311
2311
|
];
|
|
2312
2312
|
function X() {
|
|
2313
2313
|
const t = globalThis.window?.Haori;
|
|
2314
|
-
return
|
|
2314
|
+
return st.every(
|
|
2315
2315
|
(r) => typeof t?.[r] == "function"
|
|
2316
|
-
) ? t :
|
|
2316
|
+
) ? t : tt;
|
|
2317
2317
|
}
|
|
2318
|
-
const
|
|
2319
|
-
function
|
|
2320
|
-
return
|
|
2318
|
+
const nt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2319
|
+
function at(F) {
|
|
2320
|
+
return nt.has(F.toUpperCase());
|
|
2321
2321
|
}
|
|
2322
|
-
function
|
|
2322
|
+
function ot(F, t) {
|
|
2323
2323
|
for (const [e, r] of Object.entries(t))
|
|
2324
|
-
r !== void 0 && (r === null ?
|
|
2325
|
-
|
|
2326
|
-
}) : typeof r == "object" || typeof r == "function" ?
|
|
2324
|
+
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2325
|
+
F.append(e, String(i));
|
|
2326
|
+
}) : typeof r == "object" || typeof r == "function" ? F.append(e, JSON.stringify(r)) : F.append(e, String(r)));
|
|
2327
2327
|
}
|
|
2328
|
-
function
|
|
2329
|
-
const e = new URL(
|
|
2330
|
-
return
|
|
2328
|
+
function lt(F, t) {
|
|
2329
|
+
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2330
|
+
return ot(r, t), e.search = r.toString(), e.toString();
|
|
2331
2331
|
}
|
|
2332
|
-
const
|
|
2332
|
+
const u = class u {
|
|
2333
2333
|
/**
|
|
2334
2334
|
* イベント属性名を正しく生成します。
|
|
2335
2335
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2338,7 +2338,7 @@ const c = class c {
|
|
|
2338
2338
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2339
2339
|
*/
|
|
2340
2340
|
static attrName(t, e, r = !1) {
|
|
2341
|
-
return t ? `${
|
|
2341
|
+
return t ? `${c.prefix}${t}-${e}` : r ? `${c.prefix}fetch-${e}` : `${c.prefix}${e}`;
|
|
2342
2342
|
}
|
|
2343
2343
|
/**
|
|
2344
2344
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2349,7 +2349,7 @@ const c = class c {
|
|
|
2349
2349
|
*/
|
|
2350
2350
|
static resolveDataParamString(t, e) {
|
|
2351
2351
|
return t.replace(
|
|
2352
|
-
|
|
2352
|
+
u.DATA_PLACEHOLDER_REGEX,
|
|
2353
2353
|
(r, i, s) => {
|
|
2354
2354
|
const n = j.evaluate(
|
|
2355
2355
|
i ?? s ?? "",
|
|
@@ -2406,7 +2406,7 @@ const c = class c {
|
|
|
2406
2406
|
static stringifyJsonTemplateStringContent(t) {
|
|
2407
2407
|
if (t == null || Number.isNaN(t))
|
|
2408
2408
|
return "";
|
|
2409
|
-
const e = typeof t == "object" ?
|
|
2409
|
+
const e = typeof t == "object" ? u.stringifyJsonTemplateValue(t) : String(t);
|
|
2410
2410
|
return JSON.stringify(e).slice(1, -1);
|
|
2411
2411
|
}
|
|
2412
2412
|
/**
|
|
@@ -2418,13 +2418,13 @@ const c = class c {
|
|
|
2418
2418
|
*/
|
|
2419
2419
|
static resolveDataJsonString(t, e) {
|
|
2420
2420
|
return t.replace(
|
|
2421
|
-
|
|
2421
|
+
u.DATA_PLACEHOLDER_REGEX,
|
|
2422
2422
|
(r, i, s, n) => {
|
|
2423
2423
|
const a = j.evaluate(
|
|
2424
2424
|
i ?? s ?? "",
|
|
2425
2425
|
e
|
|
2426
2426
|
);
|
|
2427
|
-
return
|
|
2427
|
+
return u.isJsonStringContext(t, n) ? u.stringifyJsonTemplateStringContent(a) : u.stringifyJsonTemplateValue(a);
|
|
2428
2428
|
}
|
|
2429
2429
|
);
|
|
2430
2430
|
}
|
|
@@ -2442,13 +2442,13 @@ const c = class c {
|
|
|
2442
2442
|
if (typeof i != "string" || r === null)
|
|
2443
2443
|
return null;
|
|
2444
2444
|
const s = r.trim();
|
|
2445
|
-
return
|
|
2446
|
-
|
|
2445
|
+
return u.SINGLE_PLACEHOLDER_REGEX.test(s) ? x.parseDataBind(i) : s.startsWith("{") || s.startsWith("[") ? x.parseDataBind(
|
|
2446
|
+
u.resolveDataJsonString(
|
|
2447
2447
|
r,
|
|
2448
2448
|
t.getBindingData()
|
|
2449
2449
|
)
|
|
2450
2450
|
) : x.parseDataBind(
|
|
2451
|
-
|
|
2451
|
+
u.resolveDataParamString(r, t.getBindingData())
|
|
2452
2452
|
);
|
|
2453
2453
|
}
|
|
2454
2454
|
/**
|
|
@@ -2463,29 +2463,29 @@ const c = class c {
|
|
|
2463
2463
|
targetFragment: t
|
|
2464
2464
|
};
|
|
2465
2465
|
if (e) {
|
|
2466
|
-
if (t.hasAttribute(
|
|
2467
|
-
|
|
2468
|
-
)), t.hasAttribute(
|
|
2466
|
+
if (t.hasAttribute(u.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(u.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2467
|
+
u.attrName(e, "confirm")
|
|
2468
|
+
)), t.hasAttribute(u.attrName(e, "data")) && (r.data = u.resolveDataAttribute(
|
|
2469
2469
|
t,
|
|
2470
|
-
|
|
2471
|
-
)), t.hasAttribute(
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2470
|
+
u.attrName(e, "data")
|
|
2471
|
+
)), t.hasAttribute(u.attrName(e, "form"))) {
|
|
2472
|
+
const l = t.getRawAttribute(
|
|
2473
|
+
u.attrName(e, "form")
|
|
2474
2474
|
);
|
|
2475
|
-
if (
|
|
2476
|
-
const
|
|
2477
|
-
|
|
2478
|
-
N.get(
|
|
2475
|
+
if (l) {
|
|
2476
|
+
const f = document.body.querySelector(l);
|
|
2477
|
+
f !== null ? r.formFragment = m.getFormFragment(
|
|
2478
|
+
N.get(f)
|
|
2479
2479
|
) : h.error(
|
|
2480
2480
|
"Haori",
|
|
2481
|
-
`Form element not found: ${
|
|
2481
|
+
`Form element not found: ${l} (${u.attrName(e, "form")})`
|
|
2482
2482
|
);
|
|
2483
2483
|
} else
|
|
2484
2484
|
r.formFragment = m.getFormFragment(t);
|
|
2485
2485
|
} else e === "change" && (r.formFragment = m.getFormFragment(t));
|
|
2486
|
-
if (t.hasAttribute(`${
|
|
2487
|
-
const
|
|
2488
|
-
`${
|
|
2486
|
+
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
2487
|
+
const l = t.getRawAttribute(
|
|
2488
|
+
`${c.prefix}${e}-before-run`
|
|
2489
2489
|
);
|
|
2490
2490
|
try {
|
|
2491
2491
|
r.beforeCallback = new Function(
|
|
@@ -2493,70 +2493,70 @@ const c = class c {
|
|
|
2493
2493
|
"fetchOptions",
|
|
2494
2494
|
`
|
|
2495
2495
|
"use strict";
|
|
2496
|
-
${
|
|
2496
|
+
${l}
|
|
2497
2497
|
`
|
|
2498
2498
|
);
|
|
2499
|
-
} catch (
|
|
2500
|
-
h.error("Haori", `Invalid before script: ${
|
|
2499
|
+
} catch (f) {
|
|
2500
|
+
h.error("Haori", `Invalid before script: ${f}`);
|
|
2501
2501
|
}
|
|
2502
2502
|
}
|
|
2503
2503
|
}
|
|
2504
|
-
const i =
|
|
2504
|
+
const i = u.attrName(e, "fetch"), s = t.hasAttribute(i);
|
|
2505
2505
|
s && (r.fetchUrl = t.getAttribute(i));
|
|
2506
2506
|
const n = {};
|
|
2507
2507
|
if (e) {
|
|
2508
|
-
const
|
|
2509
|
-
t.hasAttribute(
|
|
2510
|
-
|
|
2508
|
+
const l = u.attrName(e, "fetch-method");
|
|
2509
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2510
|
+
l
|
|
2511
2511
|
));
|
|
2512
2512
|
} else {
|
|
2513
|
-
const
|
|
2514
|
-
t.hasAttribute(
|
|
2515
|
-
|
|
2513
|
+
const l = u.attrName(null, "method", !0);
|
|
2514
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2515
|
+
l
|
|
2516
2516
|
));
|
|
2517
2517
|
}
|
|
2518
2518
|
if (e) {
|
|
2519
|
-
const
|
|
2520
|
-
if (t.hasAttribute(
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2519
|
+
const l = u.attrName(e, "fetch-headers");
|
|
2520
|
+
if (t.hasAttribute(l)) {
|
|
2521
|
+
const f = t.getRawAttribute(
|
|
2522
|
+
l
|
|
2523
2523
|
);
|
|
2524
2524
|
try {
|
|
2525
|
-
n.headers = x.parseDataBind(
|
|
2525
|
+
n.headers = x.parseDataBind(f);
|
|
2526
2526
|
} catch (p) {
|
|
2527
2527
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2528
2528
|
}
|
|
2529
2529
|
}
|
|
2530
2530
|
} else {
|
|
2531
|
-
const
|
|
2531
|
+
const l = u.attrName(
|
|
2532
2532
|
null,
|
|
2533
2533
|
"headers",
|
|
2534
2534
|
!0
|
|
2535
2535
|
);
|
|
2536
|
-
if (t.hasAttribute(
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2536
|
+
if (t.hasAttribute(l)) {
|
|
2537
|
+
const f = t.getRawAttribute(
|
|
2538
|
+
l
|
|
2539
2539
|
);
|
|
2540
2540
|
try {
|
|
2541
|
-
n.headers = x.parseDataBind(
|
|
2541
|
+
n.headers = x.parseDataBind(f);
|
|
2542
2542
|
} catch (p) {
|
|
2543
2543
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2544
2544
|
}
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
2547
2547
|
if (e) {
|
|
2548
|
-
const
|
|
2548
|
+
const l = u.attrName(
|
|
2549
2549
|
e,
|
|
2550
2550
|
"fetch-content-type"
|
|
2551
2551
|
);
|
|
2552
|
-
if (t.hasAttribute(
|
|
2552
|
+
if (t.hasAttribute(l))
|
|
2553
2553
|
n.headers = {
|
|
2554
2554
|
...n.headers,
|
|
2555
|
-
"Content-Type": t.getAttribute(
|
|
2555
|
+
"Content-Type": t.getAttribute(l)
|
|
2556
2556
|
};
|
|
2557
2557
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2558
|
-
let
|
|
2559
|
-
n.headers && typeof n.headers == "object" && (
|
|
2558
|
+
let f = !1;
|
|
2559
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
2560
2560
|
...n.headers,
|
|
2561
2561
|
"Content-Type": "application/json"
|
|
2562
2562
|
});
|
|
@@ -2565,19 +2565,19 @@ ${f}
|
|
|
2565
2565
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2566
2566
|
});
|
|
2567
2567
|
} else {
|
|
2568
|
-
const
|
|
2568
|
+
const l = u.attrName(
|
|
2569
2569
|
null,
|
|
2570
2570
|
"content-type",
|
|
2571
2571
|
!0
|
|
2572
2572
|
);
|
|
2573
|
-
if (t.hasAttribute(
|
|
2573
|
+
if (t.hasAttribute(l))
|
|
2574
2574
|
n.headers = {
|
|
2575
2575
|
...n.headers,
|
|
2576
|
-
"Content-Type": t.getAttribute(
|
|
2576
|
+
"Content-Type": t.getAttribute(l)
|
|
2577
2577
|
};
|
|
2578
2578
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2579
|
-
let
|
|
2580
|
-
n.headers && typeof n.headers == "object" && (
|
|
2579
|
+
let f = !1;
|
|
2580
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
2581
2581
|
...n.headers,
|
|
2582
2582
|
"Content-Type": "application/json"
|
|
2583
2583
|
});
|
|
@@ -2587,25 +2587,25 @@ ${f}
|
|
|
2587
2587
|
});
|
|
2588
2588
|
}
|
|
2589
2589
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2590
|
-
const a = e ?
|
|
2590
|
+
const a = e ? u.attrName(e, "bind") : u.attrName(null, "bind", !0);
|
|
2591
2591
|
if (t.hasAttribute(a)) {
|
|
2592
|
-
const
|
|
2593
|
-
if (
|
|
2594
|
-
const
|
|
2595
|
-
|
|
2592
|
+
const l = t.getRawAttribute(a);
|
|
2593
|
+
if (l) {
|
|
2594
|
+
const f = document.body.querySelectorAll(l);
|
|
2595
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((p) => {
|
|
2596
2596
|
const E = N.get(p);
|
|
2597
2597
|
E && r.bindFragments.push(E);
|
|
2598
2598
|
})) : h.error(
|
|
2599
2599
|
"Haori",
|
|
2600
|
-
`Bind element not found: ${
|
|
2600
|
+
`Bind element not found: ${l} (${a})`
|
|
2601
2601
|
);
|
|
2602
2602
|
}
|
|
2603
2603
|
}
|
|
2604
|
-
const o =
|
|
2604
|
+
const o = u.attrName(e, "bind-arg"), d = u.attrName(
|
|
2605
2605
|
null,
|
|
2606
2606
|
"arg",
|
|
2607
2607
|
!0
|
|
2608
|
-
), y =
|
|
2608
|
+
), y = u.attrName(
|
|
2609
2609
|
null,
|
|
2610
2610
|
"bind-arg",
|
|
2611
2611
|
!0
|
|
@@ -2613,76 +2613,83 @@ ${f}
|
|
|
2613
2613
|
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(d) ? r.bindArg = t.getRawAttribute(
|
|
2614
2614
|
d
|
|
2615
2615
|
) : t.hasAttribute(y) && (r.bindArg = t.getRawAttribute(y));
|
|
2616
|
-
const b = e ?
|
|
2616
|
+
const b = e ? u.attrName(e, "bind-params") : u.attrName(null, "bind-params", !0);
|
|
2617
2617
|
if (t.hasAttribute(b)) {
|
|
2618
|
-
const
|
|
2619
|
-
r.bindParams =
|
|
2618
|
+
const l = t.getRawAttribute(b);
|
|
2619
|
+
r.bindParams = l.split("&").map((f) => f.trim());
|
|
2620
2620
|
}
|
|
2621
|
-
const
|
|
2622
|
-
if (t.hasAttribute(
|
|
2623
|
-
const
|
|
2624
|
-
r.bindAppendParams =
|
|
2621
|
+
const A = e ? u.attrName(e, "bind-append") : u.attrName(null, "bind-append", !0);
|
|
2622
|
+
if (t.hasAttribute(A)) {
|
|
2623
|
+
const l = t.getRawAttribute(A);
|
|
2624
|
+
r.bindAppendParams = l.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2625
|
+
}
|
|
2626
|
+
const S = e ? u.attrName(e, "copy-params") : null;
|
|
2627
|
+
if (S && t.hasAttribute(S)) {
|
|
2628
|
+
const l = t.getRawAttribute(
|
|
2629
|
+
S
|
|
2630
|
+
);
|
|
2631
|
+
r.copyParams = l.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2625
2632
|
}
|
|
2626
2633
|
if (e) {
|
|
2627
|
-
if (t.hasAttribute(
|
|
2628
|
-
const
|
|
2629
|
-
|
|
2634
|
+
if (t.hasAttribute(u.attrName(e, "adjust"))) {
|
|
2635
|
+
const f = t.getRawAttribute(
|
|
2636
|
+
u.attrName(e, "adjust")
|
|
2630
2637
|
);
|
|
2631
|
-
if (
|
|
2632
|
-
const p = document.body.querySelectorAll(
|
|
2638
|
+
if (f) {
|
|
2639
|
+
const p = document.body.querySelectorAll(f);
|
|
2633
2640
|
p.length > 0 ? (r.adjustFragments = [], p.forEach((E) => {
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2641
|
+
const w = N.get(E);
|
|
2642
|
+
w && r.adjustFragments.push(w);
|
|
2636
2643
|
})) : h.error(
|
|
2637
2644
|
"Haori",
|
|
2638
|
-
`Adjust element not found: ${
|
|
2645
|
+
`Adjust element not found: ${f} (${u.attrName(e, "adjust")})`
|
|
2639
2646
|
);
|
|
2640
2647
|
}
|
|
2641
|
-
if (t.hasAttribute(
|
|
2648
|
+
if (t.hasAttribute(u.attrName(e, "adjust-value"))) {
|
|
2642
2649
|
const p = t.getRawAttribute(
|
|
2643
|
-
|
|
2650
|
+
u.attrName(e, "adjust-value")
|
|
2644
2651
|
), E = Number(p);
|
|
2645
2652
|
isNaN(E) || (r.adjustValue = E);
|
|
2646
2653
|
}
|
|
2647
2654
|
}
|
|
2648
|
-
if (t.hasAttribute(
|
|
2649
|
-
const
|
|
2650
|
-
`${
|
|
2655
|
+
if (t.hasAttribute(u.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(u.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(u.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(u.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${c.prefix}${e}-after-run`)) {
|
|
2656
|
+
const f = t.getRawAttribute(
|
|
2657
|
+
`${c.prefix}${e}-after-run`
|
|
2651
2658
|
);
|
|
2652
2659
|
try {
|
|
2653
2660
|
r.afterCallback = new Function(
|
|
2654
2661
|
"response",
|
|
2655
2662
|
`
|
|
2656
2663
|
"use strict";
|
|
2657
|
-
${
|
|
2664
|
+
${f}
|
|
2658
2665
|
`
|
|
2659
2666
|
);
|
|
2660
2667
|
} catch (p) {
|
|
2661
2668
|
h.error("Haori", `Invalid after script: ${p}`);
|
|
2662
2669
|
}
|
|
2663
2670
|
}
|
|
2664
|
-
if (t.hasAttribute(
|
|
2665
|
-
|
|
2666
|
-
)), t.hasAttribute(
|
|
2667
|
-
|
|
2668
|
-
)), t.hasAttribute(
|
|
2669
|
-
|
|
2670
|
-
)), t.hasAttribute(
|
|
2671
|
-
|
|
2672
|
-
)), t.hasAttribute(
|
|
2671
|
+
if (t.hasAttribute(u.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2672
|
+
u.attrName(e, "dialog")
|
|
2673
|
+
)), t.hasAttribute(u.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
|
|
2674
|
+
u.attrName(e, "toast")
|
|
2675
|
+
)), t.hasAttribute(u.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2676
|
+
u.attrName(e, "redirect")
|
|
2677
|
+
)), t.hasAttribute(u.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2678
|
+
u.attrName(e, "history")
|
|
2679
|
+
)), t.hasAttribute(u.attrName(e, "history-data")) && (r.historyData = u.resolveDataAttribute(
|
|
2673
2680
|
t,
|
|
2674
|
-
|
|
2675
|
-
)), t.hasAttribute(
|
|
2676
|
-
const
|
|
2677
|
-
|
|
2681
|
+
u.attrName(e, "history-data")
|
|
2682
|
+
)), t.hasAttribute(u.attrName(e, "history-form"))) {
|
|
2683
|
+
const f = t.getRawAttribute(
|
|
2684
|
+
u.attrName(e, "history-form")
|
|
2678
2685
|
);
|
|
2679
|
-
if (
|
|
2680
|
-
const p = document.body.querySelector(
|
|
2686
|
+
if (f) {
|
|
2687
|
+
const p = document.body.querySelector(f);
|
|
2681
2688
|
p !== null ? r.historyFormFragment = m.getFormFragment(
|
|
2682
2689
|
N.get(p)
|
|
2683
2690
|
) : h.error(
|
|
2684
2691
|
"Haori",
|
|
2685
|
-
`Form element not found: ${
|
|
2692
|
+
`Form element not found: ${f} (${u.attrName(e, "history-form")})`
|
|
2686
2693
|
);
|
|
2687
2694
|
} else
|
|
2688
2695
|
r.historyFormFragment = m.getFormFragment(t);
|
|
@@ -2691,50 +2698,54 @@ ${u}
|
|
|
2691
2698
|
"reset",
|
|
2692
2699
|
"refetch",
|
|
2693
2700
|
"click",
|
|
2701
|
+
"copy",
|
|
2694
2702
|
"open",
|
|
2695
2703
|
"close"
|
|
2696
|
-
].forEach((
|
|
2697
|
-
const p =
|
|
2704
|
+
].forEach((f) => {
|
|
2705
|
+
const p = u.attrName(e, f);
|
|
2698
2706
|
if (!t.hasAttribute(p))
|
|
2699
2707
|
return;
|
|
2700
|
-
const E = t.getRawAttribute(p),
|
|
2701
|
-
if (E ? (document.body.querySelectorAll(E).forEach((
|
|
2702
|
-
const
|
|
2703
|
-
|
|
2704
|
-
}),
|
|
2705
|
-
switch (
|
|
2708
|
+
const E = t.getRawAttribute(p), w = [];
|
|
2709
|
+
if (E ? (document.body.querySelectorAll(E).forEach((J) => {
|
|
2710
|
+
const Q = N.get(J);
|
|
2711
|
+
Q && w.push(Q);
|
|
2712
|
+
}), w.length === 0 && h.error("Haori", `Element not found: ${E} (${p})`)) : w.push(t), w.length > 0)
|
|
2713
|
+
switch (f) {
|
|
2706
2714
|
case "reset":
|
|
2707
|
-
r.resetFragments =
|
|
2715
|
+
r.resetFragments = w;
|
|
2708
2716
|
break;
|
|
2709
2717
|
case "refetch":
|
|
2710
|
-
r.refetchFragments =
|
|
2718
|
+
r.refetchFragments = w;
|
|
2711
2719
|
break;
|
|
2712
2720
|
case "click":
|
|
2713
|
-
r.clickFragments =
|
|
2721
|
+
r.clickFragments = w;
|
|
2722
|
+
break;
|
|
2723
|
+
case "copy":
|
|
2724
|
+
r.copyFragments = w;
|
|
2714
2725
|
break;
|
|
2715
2726
|
case "open":
|
|
2716
|
-
r.openFragments =
|
|
2727
|
+
r.openFragments = w;
|
|
2717
2728
|
break;
|
|
2718
2729
|
case "close":
|
|
2719
|
-
r.closeFragments =
|
|
2730
|
+
r.closeFragments = w;
|
|
2720
2731
|
break;
|
|
2721
2732
|
}
|
|
2722
2733
|
});
|
|
2723
2734
|
}
|
|
2724
|
-
if (!e && (t.hasAttribute(
|
|
2735
|
+
if (!e && (t.hasAttribute(u.attrName(null, "data", !0)) && (r.data = u.resolveDataAttribute(
|
|
2725
2736
|
t,
|
|
2726
|
-
|
|
2727
|
-
)), t.hasAttribute(
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2737
|
+
u.attrName(null, "data", !0)
|
|
2738
|
+
)), t.hasAttribute(u.attrName(null, "form", !0)))) {
|
|
2739
|
+
const l = t.getRawAttribute(
|
|
2740
|
+
u.attrName(null, "form", !0)
|
|
2730
2741
|
);
|
|
2731
|
-
if (
|
|
2732
|
-
const
|
|
2733
|
-
|
|
2734
|
-
N.get(
|
|
2742
|
+
if (l) {
|
|
2743
|
+
const f = document.body.querySelector(l);
|
|
2744
|
+
f !== null ? r.formFragment = m.getFormFragment(
|
|
2745
|
+
N.get(f)
|
|
2735
2746
|
) : h.error(
|
|
2736
2747
|
"Haori",
|
|
2737
|
-
`Form element not found: ${
|
|
2748
|
+
`Form element not found: ${l} (${u.attrName(null, "fetch-form", !0)})`
|
|
2738
2749
|
);
|
|
2739
2750
|
} else
|
|
2740
2751
|
r.formFragment = m.getFormFragment(t);
|
|
@@ -2760,7 +2771,7 @@ ${u}
|
|
|
2760
2771
|
* @param arg2 イベント名
|
|
2761
2772
|
*/
|
|
2762
2773
|
constructor(t, e = null) {
|
|
2763
|
-
|
|
2774
|
+
u.isElementFragment(t) ? this.options = u.buildOptions(t, e) : this.options = t;
|
|
2764
2775
|
}
|
|
2765
2776
|
/**
|
|
2766
2777
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2809,71 +2820,71 @@ ${u}
|
|
|
2809
2820
|
if (e) {
|
|
2810
2821
|
const o = { ...r || {} }, d = new Headers(
|
|
2811
2822
|
o.headers || void 0
|
|
2812
|
-
), y = (o.method || "GET").toUpperCase(), b =
|
|
2813
|
-
if (o.method =
|
|
2814
|
-
s && (e =
|
|
2823
|
+
), y = (o.method || "GET").toUpperCase(), b = c.runtime === "demo" && !at(y), A = b ? "GET" : y;
|
|
2824
|
+
if (o.method = A, A === "GET" || A === "HEAD" || A === "OPTIONS")
|
|
2825
|
+
s && (e = lt(e, i));
|
|
2815
2826
|
else if (s) {
|
|
2816
|
-
const
|
|
2817
|
-
if (/multipart\/form-data/i.test(
|
|
2827
|
+
const l = d.get("Content-Type") || "";
|
|
2828
|
+
if (/multipart\/form-data/i.test(l)) {
|
|
2818
2829
|
d.delete("Content-Type");
|
|
2819
|
-
const
|
|
2820
|
-
for (const [
|
|
2821
|
-
|
|
2822
|
-
o.body =
|
|
2823
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2824
|
-
const
|
|
2825
|
-
for (const [
|
|
2826
|
-
|
|
2827
|
-
o.body =
|
|
2830
|
+
const f = new FormData();
|
|
2831
|
+
for (const [p, E] of Object.entries(i))
|
|
2832
|
+
E == null ? f.append(p, "") : E instanceof Blob ? f.append(p, E) : Array.isArray(E) ? E.forEach((w) => f.append(p, String(w))) : typeof E == "object" ? f.append(p, JSON.stringify(E)) : f.append(p, String(E));
|
|
2833
|
+
o.body = f;
|
|
2834
|
+
} else if (/application\/x-www-form-urlencoded/i.test(l)) {
|
|
2835
|
+
const f = new URLSearchParams();
|
|
2836
|
+
for (const [p, E] of Object.entries(i))
|
|
2837
|
+
E !== void 0 && (E === null ? f.append(p, "") : Array.isArray(E) ? E.forEach((w) => f.append(p, String(w))) : typeof E == "object" ? f.append(p, JSON.stringify(E)) : f.append(p, String(E)));
|
|
2838
|
+
o.body = f;
|
|
2828
2839
|
} else
|
|
2829
2840
|
d.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2830
2841
|
}
|
|
2831
2842
|
o.headers = d;
|
|
2832
|
-
let
|
|
2833
|
-
if (b && (
|
|
2834
|
-
runtime:
|
|
2843
|
+
let S;
|
|
2844
|
+
if (b && (S = e && new URL(e, window.location.href).search || void 0, d.delete("Content-Type"), h.info("Haori demo fetch normalization", {
|
|
2845
|
+
runtime: c.runtime,
|
|
2835
2846
|
requestedMethod: y,
|
|
2836
|
-
effectiveMethod:
|
|
2847
|
+
effectiveMethod: A,
|
|
2837
2848
|
transportMode: "query-get",
|
|
2838
2849
|
url: e,
|
|
2839
2850
|
payload: s ? i : void 0,
|
|
2840
|
-
queryString:
|
|
2851
|
+
queryString: S
|
|
2841
2852
|
})), this.options.targetFragment && e) {
|
|
2842
|
-
const
|
|
2843
|
-
runtime:
|
|
2853
|
+
const l = performance.now(), f = {
|
|
2854
|
+
runtime: c.runtime,
|
|
2844
2855
|
requestedMethod: y,
|
|
2845
|
-
effectiveMethod:
|
|
2856
|
+
effectiveMethod: A,
|
|
2846
2857
|
transportMode: b ? "query-get" : "http",
|
|
2847
|
-
...b ? { queryString:
|
|
2858
|
+
...b ? { queryString: S } : {}
|
|
2848
2859
|
};
|
|
2849
|
-
return
|
|
2860
|
+
return v.fetchStart(
|
|
2850
2861
|
this.options.targetFragment.getTarget(),
|
|
2851
2862
|
e,
|
|
2852
2863
|
o,
|
|
2853
2864
|
s ? i : void 0,
|
|
2854
|
-
|
|
2855
|
-
), fetch(e, o).then((
|
|
2856
|
-
|
|
2865
|
+
f
|
|
2866
|
+
), fetch(e, o).then((p) => this.handleFetchResult(
|
|
2867
|
+
p,
|
|
2857
2868
|
e || void 0,
|
|
2858
|
-
|
|
2859
|
-
)).catch((
|
|
2860
|
-
throw e &&
|
|
2869
|
+
l
|
|
2870
|
+
)).catch((p) => {
|
|
2871
|
+
throw e && v.fetchError(
|
|
2861
2872
|
this.options.targetFragment.getTarget(),
|
|
2862
2873
|
e,
|
|
2863
|
-
|
|
2864
|
-
),
|
|
2874
|
+
p
|
|
2875
|
+
), p;
|
|
2865
2876
|
});
|
|
2866
2877
|
}
|
|
2867
|
-
return fetch(e, o).then((
|
|
2878
|
+
return fetch(e, o).then((l) => this.handleFetchResult(l, e || void 0));
|
|
2868
2879
|
}
|
|
2869
2880
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2870
2881
|
const o = this.options.formFragment, d = o.getTarget();
|
|
2871
2882
|
d.setAttribute(
|
|
2872
|
-
`${
|
|
2883
|
+
`${c.prefix}bind`,
|
|
2873
2884
|
JSON.stringify(i)
|
|
2874
2885
|
);
|
|
2875
2886
|
const y = o.getBindingData();
|
|
2876
|
-
|
|
2887
|
+
Object.assign(y, i), await x.setBindingData(d, y);
|
|
2877
2888
|
}
|
|
2878
2889
|
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2879
2890
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2886,43 +2897,45 @@ ${u}
|
|
|
2886
2897
|
async handleFetchResult(t, e, r) {
|
|
2887
2898
|
const i = X();
|
|
2888
2899
|
if (!t.ok)
|
|
2889
|
-
return this.options.targetFragment && e &&
|
|
2900
|
+
return this.options.targetFragment && e && v.fetchError(
|
|
2890
2901
|
this.options.targetFragment.getTarget(),
|
|
2891
2902
|
e,
|
|
2892
2903
|
new Error(`${t.status} ${t.statusText}`),
|
|
2893
2904
|
t.status,
|
|
2894
2905
|
r
|
|
2895
2906
|
), await this.handleFetchError(t), !1;
|
|
2896
|
-
if (this.options.targetFragment && e && r &&
|
|
2907
|
+
if (this.options.targetFragment && e && r && v.fetchEnd(
|
|
2897
2908
|
this.options.targetFragment.getTarget(),
|
|
2898
2909
|
e,
|
|
2899
2910
|
t.status,
|
|
2900
2911
|
r
|
|
2901
2912
|
), this.options.afterCallback) {
|
|
2902
|
-
const
|
|
2903
|
-
if (
|
|
2904
|
-
if (
|
|
2913
|
+
const a = this.options.afterCallback(t);
|
|
2914
|
+
if (a != null) {
|
|
2915
|
+
if (a === !1 || typeof a == "object" && a.stop)
|
|
2905
2916
|
return !1;
|
|
2906
|
-
typeof
|
|
2917
|
+
typeof a == "object" && "response" in a && (t = "response" in a ? a.response : t);
|
|
2907
2918
|
}
|
|
2908
2919
|
}
|
|
2909
2920
|
const s = [];
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2921
|
+
s.push(this.bindResult(t)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), await Promise.all(s), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
2922
|
+
this.options.resetFragments.map((a) => m.reset(a))
|
|
2923
|
+
), await this.copy();
|
|
2924
|
+
const n = [];
|
|
2925
|
+
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2926
|
+
n.push(new u(a, null).run());
|
|
2927
|
+
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2928
|
+
const o = a.getTarget();
|
|
2929
|
+
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
2917
2930
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2918
2931
|
);
|
|
2919
|
-
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((
|
|
2920
|
-
const
|
|
2921
|
-
|
|
2922
|
-
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((
|
|
2923
|
-
const
|
|
2924
|
-
|
|
2925
|
-
}), await Promise.all(
|
|
2932
|
+
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2933
|
+
const o = a.getTarget();
|
|
2934
|
+
o instanceof HTMLElement ? n.push(i.openDialog(o)) : h.error("Haori", "Element is not an HTML element: ", o);
|
|
2935
|
+
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2936
|
+
const o = a.getTarget();
|
|
2937
|
+
o instanceof HTMLElement ? n.push(i.closeDialog(o)) : h.error("Haori", "Element is not an HTML element: ", o);
|
|
2938
|
+
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(this.options.toastMessage, "info"), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
2926
2939
|
}
|
|
2927
2940
|
/**
|
|
2928
2941
|
* history.pushState を実行します。
|
|
@@ -3097,6 +3110,39 @@ ${u}
|
|
|
3097
3110
|
}
|
|
3098
3111
|
return i;
|
|
3099
3112
|
}
|
|
3113
|
+
/**
|
|
3114
|
+
* 指定されたフラグメントへバインディングデータをコピーします。
|
|
3115
|
+
*/
|
|
3116
|
+
copy() {
|
|
3117
|
+
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3118
|
+
return Promise.resolve();
|
|
3119
|
+
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3120
|
+
const s = {
|
|
3121
|
+
...i.getBindingData(),
|
|
3122
|
+
...e
|
|
3123
|
+
};
|
|
3124
|
+
return x.setBindingData(i.getTarget(), s);
|
|
3125
|
+
});
|
|
3126
|
+
return Promise.all(r).then(() => {
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
/**
|
|
3130
|
+
* copy のコピー元データを取得します。
|
|
3131
|
+
*/
|
|
3132
|
+
resolveCopySourceData() {
|
|
3133
|
+
return this.options.formFragment ? m.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
3137
|
+
*/
|
|
3138
|
+
pickCopyData(t) {
|
|
3139
|
+
if (!this.options.copyParams || this.options.copyParams.length === 0)
|
|
3140
|
+
return t;
|
|
3141
|
+
const e = {};
|
|
3142
|
+
return this.options.copyParams.forEach((r) => {
|
|
3143
|
+
r in t && (e[r] = t[r]);
|
|
3144
|
+
}), e;
|
|
3145
|
+
}
|
|
3100
3146
|
/**
|
|
3101
3147
|
* 値の増減を行います。
|
|
3102
3148
|
*/
|
|
@@ -3122,7 +3168,7 @@ ${u}
|
|
|
3122
3168
|
if (!this.options.targetFragment)
|
|
3123
3169
|
return h.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3124
3170
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3125
|
-
`${
|
|
3171
|
+
`${c.prefix}row`
|
|
3126
3172
|
);
|
|
3127
3173
|
return t || (h.error("Haori", "Row fragment not found."), null);
|
|
3128
3174
|
}
|
|
@@ -3155,7 +3201,7 @@ ${u}
|
|
|
3155
3201
|
if (!t)
|
|
3156
3202
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3157
3203
|
const e = t.getParent();
|
|
3158
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3204
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${c.prefix}each-before`) && !i.hasAttribute(`${c.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3159
3205
|
}
|
|
3160
3206
|
/**
|
|
3161
3207
|
* 前の行へ移動します。
|
|
@@ -3192,9 +3238,9 @@ ${u}
|
|
|
3192
3238
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3193
3239
|
}
|
|
3194
3240
|
};
|
|
3195
|
-
|
|
3196
|
-
let V =
|
|
3197
|
-
class
|
|
3241
|
+
u.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, u.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3242
|
+
let V = u;
|
|
3243
|
+
class ct {
|
|
3198
3244
|
/**
|
|
3199
3245
|
* URLのクエリパラメータを取得します。
|
|
3200
3246
|
*
|
|
@@ -3254,7 +3300,7 @@ const g = class g {
|
|
|
3254
3300
|
*/
|
|
3255
3301
|
static isDeferredAttributeName(t) {
|
|
3256
3302
|
return g.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3257
|
-
(e) => t === `${
|
|
3303
|
+
(e) => t === `${c.prefix}${e}`
|
|
3258
3304
|
);
|
|
3259
3305
|
}
|
|
3260
3306
|
/**
|
|
@@ -3265,7 +3311,7 @@ const g = class g {
|
|
|
3265
3311
|
*/
|
|
3266
3312
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3267
3313
|
return g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3268
|
-
(e) => t === `${
|
|
3314
|
+
(e) => t === `${c.prefix}${e}`
|
|
3269
3315
|
);
|
|
3270
3316
|
}
|
|
3271
3317
|
/**
|
|
@@ -3307,7 +3353,7 @@ const g = class g {
|
|
|
3307
3353
|
t.parentNode && (N.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3308
3354
|
const r = [], i = /* @__PURE__ */ new Set();
|
|
3309
3355
|
for (const s of g.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3310
|
-
const n =
|
|
3356
|
+
const n = c.prefix + s;
|
|
3311
3357
|
e.hasAttribute(n) && (r.push(
|
|
3312
3358
|
g.setAttribute(
|
|
3313
3359
|
e.getTarget(),
|
|
@@ -3323,7 +3369,7 @@ const g = class g {
|
|
|
3323
3369
|
n !== null && r.push(g.setAttribute(e.getTarget(), s, n));
|
|
3324
3370
|
}
|
|
3325
3371
|
for (const s of g.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3326
|
-
const n =
|
|
3372
|
+
const n = c.prefix + s;
|
|
3327
3373
|
e.hasAttribute(n) && (r.push(
|
|
3328
3374
|
g.setAttribute(
|
|
3329
3375
|
e.getTarget(),
|
|
@@ -3349,42 +3395,42 @@ const g = class g {
|
|
|
3349
3395
|
static setAttribute(t, e, r) {
|
|
3350
3396
|
const i = N.get(t), s = [];
|
|
3351
3397
|
switch (e) {
|
|
3352
|
-
case `${
|
|
3398
|
+
case `${c.prefix}bind`: {
|
|
3353
3399
|
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(g.parseDataBind(r));
|
|
3354
3400
|
break;
|
|
3355
3401
|
}
|
|
3356
|
-
case `${
|
|
3402
|
+
case `${c.prefix}if`:
|
|
3357
3403
|
s.push(g.evaluateIf(i));
|
|
3358
3404
|
break;
|
|
3359
|
-
case `${
|
|
3405
|
+
case `${c.prefix}each`:
|
|
3360
3406
|
s.push(g.evaluateEach(i));
|
|
3361
3407
|
break;
|
|
3362
|
-
case `${
|
|
3408
|
+
case `${c.prefix}fetch`:
|
|
3363
3409
|
s.push(
|
|
3364
3410
|
new V(i, null).run().then(() => {
|
|
3365
3411
|
})
|
|
3366
3412
|
);
|
|
3367
3413
|
break;
|
|
3368
|
-
case `${
|
|
3414
|
+
case `${c.prefix}import`: {
|
|
3369
3415
|
if (typeof r == "string") {
|
|
3370
3416
|
const n = i.getTarget(), a = performance.now();
|
|
3371
|
-
|
|
3417
|
+
v.importStart(n, r), s.push(
|
|
3372
3418
|
ut.load(r).then((o) => {
|
|
3373
3419
|
const d = new TextEncoder().encode(o).length;
|
|
3374
|
-
return
|
|
3420
|
+
return P.enqueue(() => {
|
|
3375
3421
|
n.innerHTML = o;
|
|
3376
3422
|
}).then(() => {
|
|
3377
|
-
|
|
3423
|
+
v.importEnd(n, r, d, a);
|
|
3378
3424
|
});
|
|
3379
3425
|
}).catch((o) => {
|
|
3380
|
-
|
|
3426
|
+
v.importError(n, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
3381
3427
|
})
|
|
3382
3428
|
);
|
|
3383
3429
|
}
|
|
3384
3430
|
break;
|
|
3385
3431
|
}
|
|
3386
|
-
case `${
|
|
3387
|
-
const n = i.getAttribute(`${
|
|
3432
|
+
case `${c.prefix}url-param`: {
|
|
3433
|
+
const n = i.getAttribute(`${c.prefix}url-arg`), a = ct.readParams();
|
|
3388
3434
|
if (n === null)
|
|
3389
3435
|
g.setBindingData(t, a);
|
|
3390
3436
|
else {
|
|
@@ -3410,12 +3456,12 @@ const g = class g {
|
|
|
3410
3456
|
r.setBindingData(e);
|
|
3411
3457
|
const s = [];
|
|
3412
3458
|
if (s.push(
|
|
3413
|
-
r.setAttribute(`${
|
|
3459
|
+
r.setAttribute(`${c.prefix}bind`, JSON.stringify(e))
|
|
3414
3460
|
), t.tagName === "FORM") {
|
|
3415
|
-
const n = r.getAttribute(`${
|
|
3461
|
+
const n = r.getAttribute(`${c.prefix}form-arg`), a = n && e[String(n)] && typeof e[String(n)] == "object" && !Array.isArray(e[String(n)]) ? e[String(n)] : n ? {} : e;
|
|
3416
3462
|
s.push(m.syncValues(r, a));
|
|
3417
3463
|
}
|
|
3418
|
-
return s.push(g.evaluateAll(r)),
|
|
3464
|
+
return s.push(g.evaluateAll(r)), v.bindChange(t, i, e, "manual"), Promise.all(s).then(() => {
|
|
3419
3465
|
});
|
|
3420
3466
|
}
|
|
3421
3467
|
/**
|
|
@@ -3491,7 +3537,7 @@ const g = class g {
|
|
|
3491
3537
|
i.push(r.setValue(e));
|
|
3492
3538
|
const s = g.getFormFragment(r);
|
|
3493
3539
|
if (s) {
|
|
3494
|
-
const n = m.getValues(s), a = s.getAttribute(`${
|
|
3540
|
+
const n = m.getValues(s), a = s.getAttribute(`${c.prefix}form-arg`);
|
|
3495
3541
|
let o;
|
|
3496
3542
|
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(g.setBindingData(s.getTarget(), o));
|
|
3497
3543
|
}
|
|
@@ -3518,7 +3564,7 @@ const g = class g {
|
|
|
3518
3564
|
*/
|
|
3519
3565
|
static evaluateAll(t) {
|
|
3520
3566
|
const e = [];
|
|
3521
|
-
return e.push(g.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3567
|
+
return e.push(g.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${c.prefix}if`) && e.push(g.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) && e.push(g.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3522
3568
|
r instanceof D ? e.push(g.evaluateAll(r)) : r instanceof L && e.push(g.evaluateText(r));
|
|
3523
3569
|
}), Promise.all(e).then(() => {
|
|
3524
3570
|
});
|
|
@@ -3540,14 +3586,14 @@ const g = class g {
|
|
|
3540
3586
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3541
3587
|
*/
|
|
3542
3588
|
static evaluateIf(t) {
|
|
3543
|
-
const e = [], r = t.getAttribute(`${
|
|
3589
|
+
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3544
3590
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3545
3591
|
t.hide().then(() => {
|
|
3546
|
-
|
|
3592
|
+
v.hide(t.getTarget());
|
|
3547
3593
|
})
|
|
3548
3594
|
) : t.isVisible() || (e.push(
|
|
3549
3595
|
t.show().then(() => {
|
|
3550
|
-
|
|
3596
|
+
v.show(t.getTarget());
|
|
3551
3597
|
})
|
|
3552
3598
|
), e.push(g.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3553
3599
|
});
|
|
@@ -3566,17 +3612,17 @@ const g = class g {
|
|
|
3566
3612
|
let i = !1;
|
|
3567
3613
|
t.getChildren().forEach((n) => {
|
|
3568
3614
|
if (!i && n instanceof D) {
|
|
3569
|
-
if (n.hasAttribute(`${
|
|
3615
|
+
if (n.hasAttribute(`${c.prefix}each-before`) || n.hasAttribute(`${c.prefix}each-after`))
|
|
3570
3616
|
return;
|
|
3571
3617
|
e = n.clone(), t.setTemplate(e), i = !0, t.removeChild(n);
|
|
3572
3618
|
const a = n.getTarget();
|
|
3573
3619
|
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
3574
3620
|
}
|
|
3575
3621
|
});
|
|
3576
|
-
const s = t.getAttribute(`${
|
|
3622
|
+
const s = t.getAttribute(`${c.prefix}each`);
|
|
3577
3623
|
return Array.isArray(s) ? this.updateDiff(t, s) : (h.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
3578
3624
|
}
|
|
3579
|
-
const r = t.getAttribute(`${
|
|
3625
|
+
const r = t.getAttribute(`${c.prefix}each`);
|
|
3580
3626
|
return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3581
3627
|
}
|
|
3582
3628
|
/**
|
|
@@ -3589,72 +3635,72 @@ const g = class g {
|
|
|
3589
3635
|
const r = t.getTemplate();
|
|
3590
3636
|
if (r === null)
|
|
3591
3637
|
return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3592
|
-
let i = t.getAttribute(`${
|
|
3638
|
+
let i = t.getAttribute(`${c.prefix}each-index`);
|
|
3593
3639
|
i && (i = String(i));
|
|
3594
|
-
const s = t.getAttribute(`${
|
|
3595
|
-
e.forEach((
|
|
3596
|
-
const
|
|
3597
|
-
|
|
3640
|
+
const s = t.getAttribute(`${c.prefix}each-key`), n = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3641
|
+
e.forEach((l, f) => {
|
|
3642
|
+
const p = g.createListKey(
|
|
3643
|
+
l,
|
|
3598
3644
|
s ? String(s) : null,
|
|
3599
|
-
|
|
3645
|
+
f
|
|
3600
3646
|
);
|
|
3601
|
-
o.push(
|
|
3647
|
+
o.push(p), a.set(p, { item: l, itemIndex: f });
|
|
3602
3648
|
});
|
|
3603
3649
|
const d = [];
|
|
3604
|
-
let y = t.getChildren().filter((
|
|
3605
|
-
(
|
|
3650
|
+
let y = t.getChildren().filter((l) => l instanceof D).filter(
|
|
3651
|
+
(l) => !l.hasAttribute(`${c.prefix}each-before`) && !l.hasAttribute(`${c.prefix}each-after`)
|
|
3606
3652
|
);
|
|
3607
|
-
y = y.filter((
|
|
3608
|
-
const b = y.map((
|
|
3609
|
-
let
|
|
3610
|
-
return o.forEach((
|
|
3611
|
-
const
|
|
3653
|
+
y = y.filter((l) => o.indexOf(String(l.getListKey())) === -1 ? (d.push(l.remove()), !1) : !0);
|
|
3654
|
+
const b = y.map((l) => l.getListKey()), A = t.getChildren().filter((l) => l instanceof D).filter((l) => l.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3655
|
+
let S = Promise.resolve();
|
|
3656
|
+
return o.forEach((l, f) => {
|
|
3657
|
+
const p = b.indexOf(l), { item: E, itemIndex: w } = a.get(l);
|
|
3612
3658
|
let k;
|
|
3613
|
-
if (
|
|
3614
|
-
k = y[
|
|
3659
|
+
if (p !== -1)
|
|
3660
|
+
k = y[p], S = S.then(
|
|
3615
3661
|
() => g.updateRowFragment(
|
|
3616
3662
|
k,
|
|
3617
|
-
|
|
3663
|
+
E,
|
|
3618
3664
|
i,
|
|
3619
|
-
|
|
3665
|
+
w,
|
|
3620
3666
|
n ? String(n) : null,
|
|
3621
|
-
|
|
3667
|
+
l
|
|
3622
3668
|
).then(() => g.evaluateAll(k))
|
|
3623
3669
|
);
|
|
3624
3670
|
else {
|
|
3625
3671
|
k = r.clone();
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3672
|
+
const J = A + f;
|
|
3673
|
+
S = S.then(
|
|
3628
3674
|
() => g.updateRowFragment(
|
|
3629
3675
|
k,
|
|
3630
|
-
|
|
3676
|
+
E,
|
|
3631
3677
|
i,
|
|
3632
|
-
|
|
3678
|
+
w,
|
|
3633
3679
|
n ? String(n) : null,
|
|
3634
|
-
|
|
3680
|
+
l
|
|
3635
3681
|
).then(
|
|
3636
3682
|
() => t.insertBefore(
|
|
3637
3683
|
k,
|
|
3638
|
-
t.getChildren()[
|
|
3684
|
+
t.getChildren()[J] || null
|
|
3639
3685
|
).then(() => g.evaluateAll(k))
|
|
3640
3686
|
)
|
|
3641
3687
|
);
|
|
3642
3688
|
}
|
|
3643
|
-
}), Promise.all(d).then(() =>
|
|
3644
|
-
const
|
|
3645
|
-
(
|
|
3646
|
-
),
|
|
3647
|
-
(
|
|
3648
|
-
),
|
|
3649
|
-
(
|
|
3650
|
-
),
|
|
3651
|
-
(
|
|
3689
|
+
}), Promise.all(d).then(() => S).then(() => {
|
|
3690
|
+
const l = o.filter(
|
|
3691
|
+
(w) => w !== null
|
|
3692
|
+
), f = b.filter(
|
|
3693
|
+
(w) => w !== null
|
|
3694
|
+
), p = l.filter(
|
|
3695
|
+
(w) => !f.includes(w)
|
|
3696
|
+
), E = f.filter(
|
|
3697
|
+
(w) => !l.includes(w)
|
|
3652
3698
|
);
|
|
3653
|
-
|
|
3699
|
+
v.eachUpdate(
|
|
3654
3700
|
t.getTarget(),
|
|
3701
|
+
p,
|
|
3655
3702
|
E,
|
|
3656
|
-
|
|
3657
|
-
u
|
|
3703
|
+
l
|
|
3658
3704
|
);
|
|
3659
3705
|
});
|
|
3660
3706
|
}
|
|
@@ -3702,9 +3748,9 @@ const g = class g {
|
|
|
3702
3748
|
else
|
|
3703
3749
|
return h.error(
|
|
3704
3750
|
"[Haori]",
|
|
3705
|
-
`Primitive value requires '${
|
|
3751
|
+
`Primitive value requires '${c.prefix}each-arg' attribute: ${e}`
|
|
3706
3752
|
), Promise.resolve();
|
|
3707
|
-
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${
|
|
3753
|
+
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${c.prefix}row`, n);
|
|
3708
3754
|
}
|
|
3709
3755
|
};
|
|
3710
3756
|
g.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], g.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
@@ -3716,7 +3762,7 @@ g.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], g.DEFERRED_ATTRIBUTE_SUF
|
|
|
3716
3762
|
"url-param"
|
|
3717
3763
|
], g.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3718
3764
|
let x = g;
|
|
3719
|
-
class
|
|
3765
|
+
class ht {
|
|
3720
3766
|
/**
|
|
3721
3767
|
* コンストラクタ。
|
|
3722
3768
|
*
|
|
@@ -3780,7 +3826,7 @@ const T = class T {
|
|
|
3780
3826
|
}
|
|
3781
3827
|
if (typeof IntersectionObserver > "u")
|
|
3782
3828
|
return;
|
|
3783
|
-
const i = T.resolveRoot(r), s = T.resolveRootMargin(r), n = T.resolveThreshold(r), a = r.hasAttribute(`${
|
|
3829
|
+
const i = T.resolveRoot(r), s = T.resolveRootMargin(r), n = T.resolveThreshold(r), a = r.hasAttribute(`${c.prefix}intersect-once`);
|
|
3784
3830
|
if (e && e.observer.root === i && e.observer.rootMargin === s && T.sameThreshold(
|
|
3785
3831
|
e.observer.thresholds,
|
|
3786
3832
|
n
|
|
@@ -3793,17 +3839,17 @@ const T = class T {
|
|
|
3793
3839
|
(d) => {
|
|
3794
3840
|
const y = T.registrations.get(t);
|
|
3795
3841
|
y && d.forEach((b) => {
|
|
3796
|
-
!b.isIntersecting || y.running || T.isDisabled(y.fragment) || (y.running = !0, new V(y.fragment, "intersect").runWithResult().then((
|
|
3797
|
-
|
|
3798
|
-
}).catch((
|
|
3842
|
+
!b.isIntersecting || y.running || T.isDisabled(y.fragment) || (y.running = !0, new V(y.fragment, "intersect").runWithResult().then((A) => {
|
|
3843
|
+
A && y.once && (y.observer.disconnect(), T.registrations.delete(t));
|
|
3844
|
+
}).catch((A) => {
|
|
3799
3845
|
h.error(
|
|
3800
3846
|
"[Haori]",
|
|
3801
3847
|
"Intersect procedure execution error:",
|
|
3802
|
-
|
|
3848
|
+
A
|
|
3803
3849
|
);
|
|
3804
3850
|
}).finally(() => {
|
|
3805
|
-
const
|
|
3806
|
-
|
|
3851
|
+
const A = T.registrations.get(t);
|
|
3852
|
+
A && (A.running = !1);
|
|
3807
3853
|
}));
|
|
3808
3854
|
});
|
|
3809
3855
|
},
|
|
@@ -3837,14 +3883,14 @@ const T = class T {
|
|
|
3837
3883
|
}
|
|
3838
3884
|
static shouldObserve(t) {
|
|
3839
3885
|
return t.getAttributeNames().some((e) => {
|
|
3840
|
-
if (!e.startsWith(`${
|
|
3886
|
+
if (!e.startsWith(`${c.prefix}intersect-`))
|
|
3841
3887
|
return !1;
|
|
3842
|
-
const r = e.slice(`${
|
|
3888
|
+
const r = e.slice(`${c.prefix}intersect-`.length);
|
|
3843
3889
|
return !T.CONFIG_KEYS.has(r);
|
|
3844
3890
|
});
|
|
3845
3891
|
}
|
|
3846
3892
|
static resolveRoot(t) {
|
|
3847
|
-
const e = `${
|
|
3893
|
+
const e = `${c.prefix}intersect-root`;
|
|
3848
3894
|
if (!t.hasAttribute(e))
|
|
3849
3895
|
return null;
|
|
3850
3896
|
const r = t.getAttribute(e);
|
|
@@ -3854,15 +3900,15 @@ const T = class T {
|
|
|
3854
3900
|
return i instanceof HTMLElement ? i : (h.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
3855
3901
|
}
|
|
3856
3902
|
static resolveRootMargin(t) {
|
|
3857
|
-
const e = `${
|
|
3903
|
+
const e = `${c.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
3858
3904
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
3859
3905
|
}
|
|
3860
3906
|
static resolveThreshold(t) {
|
|
3861
|
-
const e = `${
|
|
3907
|
+
const e = `${c.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
3862
3908
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
3863
3909
|
}
|
|
3864
3910
|
static isDisabled(t) {
|
|
3865
|
-
const e = `${
|
|
3911
|
+
const e = `${c.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
3866
3912
|
if (r === null || r === !1)
|
|
3867
3913
|
return !1;
|
|
3868
3914
|
if (typeof r == "boolean")
|
|
@@ -3881,7 +3927,7 @@ T.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
3881
3927
|
"disabled",
|
|
3882
3928
|
"once"
|
|
3883
3929
|
]), T.registrations = /* @__PURE__ */ new Map();
|
|
3884
|
-
let
|
|
3930
|
+
let $ = T;
|
|
3885
3931
|
const H = class H {
|
|
3886
3932
|
/**
|
|
3887
3933
|
* 初期化メソッド。
|
|
@@ -3895,7 +3941,7 @@ const H = class H {
|
|
|
3895
3941
|
x.scan(document.head),
|
|
3896
3942
|
x.scan(document.body)
|
|
3897
3943
|
]), [e, r] = t;
|
|
3898
|
-
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), H.observe(document.head), H.observe(document.body), new
|
|
3944
|
+
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), H.observe(document.head), H.observe(document.body), new ht().start(), $.syncTree(document.body);
|
|
3899
3945
|
}
|
|
3900
3946
|
/**
|
|
3901
3947
|
* 指定された要素を監視します。
|
|
@@ -3919,7 +3965,7 @@ const H = class H {
|
|
|
3919
3965
|
s,
|
|
3920
3966
|
i.attributeName,
|
|
3921
3967
|
s.getAttribute(i.attributeName)
|
|
3922
|
-
),
|
|
3968
|
+
), $.syncElement(s);
|
|
3923
3969
|
break;
|
|
3924
3970
|
}
|
|
3925
3971
|
case "childList": {
|
|
@@ -3929,9 +3975,9 @@ const H = class H {
|
|
|
3929
3975
|
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3930
3976
|
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3931
3977
|
), Array.from(i.removedNodes).forEach((s) => {
|
|
3932
|
-
|
|
3978
|
+
$.cleanupTree(s), x.removeNode(s);
|
|
3933
3979
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3934
|
-
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s),
|
|
3980
|
+
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s), $.syncTree(s));
|
|
3935
3981
|
});
|
|
3936
3982
|
break;
|
|
3937
3983
|
}
|
|
@@ -3964,18 +4010,18 @@ const H = class H {
|
|
|
3964
4010
|
}
|
|
3965
4011
|
};
|
|
3966
4012
|
H._initialized = !1;
|
|
3967
|
-
let
|
|
3968
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
3969
|
-
const
|
|
4013
|
+
let q = H;
|
|
4014
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4015
|
+
const ft = "0.4.3";
|
|
3970
4016
|
export {
|
|
3971
4017
|
x as Core,
|
|
3972
|
-
|
|
4018
|
+
c as Env,
|
|
3973
4019
|
m as Form,
|
|
3974
4020
|
N as Fragment,
|
|
3975
|
-
|
|
4021
|
+
tt as Haori,
|
|
3976
4022
|
h as Log,
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
4023
|
+
P as Queue,
|
|
4024
|
+
tt as default,
|
|
4025
|
+
ft as version
|
|
3980
4026
|
};
|
|
3981
4027
|
//# sourceMappingURL=haori.es.js.map
|