haori 0.4.3 → 0.4.5
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 +4 -1
- package/README.md +4 -1
- package/dist/haori.cjs.js +12 -10
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +997 -856
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +13 -11
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +66 -3
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts +17 -0
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +75 -22
- package/dist/src/core.js.map +1 -1
- package/dist/src/event_dispatcher.d.ts +10 -2
- package/dist/src/event_dispatcher.d.ts.map +1 -1
- package/dist/src/event_dispatcher.js +21 -3
- package/dist/src/event_dispatcher.js.map +1 -1
- package/dist/src/form.d.ts +12 -1
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +20 -3
- package/dist/src/form.js.map +1 -1
- package/dist/src/fragment.d.ts +27 -0
- package/dist/src/fragment.d.ts.map +1 -1
- package/dist/src/fragment.js +62 -8
- package/dist/src/fragment.js.map +1 -1
- package/dist/src/haori.d.ts +10 -2
- package/dist/src/haori.d.ts.map +1 -1
- package/dist/src/haori.js +23 -11
- package/dist/src/haori.js.map +1 -1
- package/dist/src/observer.d.ts.map +1 -1
- package/dist/src/observer.js +4 -0
- package/dist/src/observer.js.map +1 -1
- package/dist/src/procedure.d.ts +18 -3
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +78 -27
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/core.test.js +40 -0
- package/dist/tests/core.test.js.map +1 -1
- package/dist/tests/fetch-and-procedure-scenarios.test.js +54 -0
- package/dist/tests/fetch-and-procedure-scenarios.test.js.map +1 -1
- package/dist/tests/haori.test.d.ts +2 -0
- package/dist/tests/haori.test.d.ts.map +1 -0
- package/dist/tests/haori.test.js +149 -0
- package/dist/tests/haori.test.js.map +1 -0
- package/dist/tests/helpers/async.d.ts.map +1 -1
- package/dist/tests/helpers/async.js +1 -0
- package/dist/tests/helpers/async.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +273 -4
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/procedure.test.js +3 -2
- package/dist/tests/procedure.test.js.map +1 -1
- package/dist/tests/row-operations.test.js +21 -1
- package/dist/tests/row-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -30,21 +30,21 @@ const O = class O {
|
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
32
|
let B = O;
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const z = "embedded";
|
|
34
|
+
function rt(F) {
|
|
35
35
|
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return F === null ? null :
|
|
37
|
+
function it(F) {
|
|
38
|
+
return F === null ? null : rt(F) ? F : z;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const D = class D {
|
|
41
41
|
/**
|
|
42
42
|
* 実行モードを取得します。
|
|
43
43
|
*
|
|
44
44
|
* @returns 実行モード。
|
|
45
45
|
*/
|
|
46
46
|
static get runtime() {
|
|
47
|
-
return
|
|
47
|
+
return D._runtime;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 実行モードを設定します。
|
|
@@ -53,7 +53,7 @@ const M = class M {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
|
|
56
|
+
D._runtime = rt(t) ? t : z;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -65,14 +65,14 @@ const M = class M {
|
|
|
65
65
|
try {
|
|
66
66
|
const t = document.currentScript || document.querySelector('script[src*="haori"]');
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
|
-
const r = t.getAttribute("data-prefix") ||
|
|
69
|
-
|
|
70
|
-
const i =
|
|
68
|
+
const r = t.getAttribute("data-prefix") || D._prefix;
|
|
69
|
+
D._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
+
const i = it(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
|
-
i !== null && (
|
|
73
|
+
i !== null && (D._runtime = i);
|
|
74
74
|
}
|
|
75
|
-
if (t instanceof HTMLScriptElement && t.hasAttribute(`${
|
|
75
|
+
if (t instanceof HTMLScriptElement && t.hasAttribute(`${D._prefix}dev`)) {
|
|
76
76
|
B.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
@@ -91,13 +91,13 @@ const M = class M {
|
|
|
91
91
|
* @returns プレフィックス
|
|
92
92
|
*/
|
|
93
93
|
static get prefix() {
|
|
94
|
-
return
|
|
94
|
+
return D._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
let c =
|
|
97
|
+
D._prefix = "data-", D._runtime = z;
|
|
98
|
+
let c = D;
|
|
99
99
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
100
|
-
class
|
|
100
|
+
class d {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -126,7 +126,7 @@ class h {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class st {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -139,16 +139,16 @@ class rt {
|
|
|
139
139
|
*/
|
|
140
140
|
enqueue(t, e = !1) {
|
|
141
141
|
let r, i;
|
|
142
|
-
const
|
|
142
|
+
const n = new Promise((a, o) => {
|
|
143
143
|
r = a, i = o;
|
|
144
|
-
}),
|
|
144
|
+
}), s = {
|
|
145
145
|
task: t,
|
|
146
146
|
timestamp: performance.now(),
|
|
147
|
-
promise:
|
|
147
|
+
promise: n,
|
|
148
148
|
resolve: r,
|
|
149
149
|
reject: i
|
|
150
150
|
};
|
|
151
|
-
return e ? this.queue.unshift(
|
|
151
|
+
return e ? this.queue.unshift(s) : this.queue.push(s), this.scheduleProcessing(), n;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* キューを処理します。
|
|
@@ -168,13 +168,13 @@ class rt {
|
|
|
168
168
|
const r = await e.task();
|
|
169
169
|
e.resolve(r);
|
|
170
170
|
} catch (r) {
|
|
171
|
-
e.reject(r),
|
|
171
|
+
e.reject(r), d.error("[Haori]", `Task ${e.timestamp} failed:`, r);
|
|
172
172
|
}
|
|
173
173
|
if (performance.now() - t > this.MAX_BUDGET)
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
176
|
} catch (t) {
|
|
177
|
-
|
|
177
|
+
d.error("[Haori]", "Error processing queue:", t);
|
|
178
178
|
} finally {
|
|
179
179
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
180
180
|
}
|
|
@@ -202,7 +202,7 @@ class rt {
|
|
|
202
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const _ = class _ {
|
|
206
206
|
/**
|
|
207
207
|
* タスクをキューに追加します。
|
|
208
208
|
*
|
|
@@ -220,9 +220,9 @@ const z = class z {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
let P =
|
|
225
|
-
class
|
|
223
|
+
_.ASYNC_QUEUE = new st();
|
|
224
|
+
let P = _;
|
|
225
|
+
class J {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
@@ -255,12 +255,12 @@ class tt {
|
|
|
255
255
|
* 通知トーストを表示します。
|
|
256
256
|
*
|
|
257
257
|
* @param message 表示メッセージ
|
|
258
|
-
* @param level
|
|
258
|
+
* @param level メッセージのレベル(省略時は 'info')
|
|
259
259
|
* @return 通知が表示されると解決されるPromise
|
|
260
260
|
*/
|
|
261
|
-
static async toast(t, e) {
|
|
261
|
+
static async toast(t, e = "info") {
|
|
262
262
|
const r = document.createElement("div");
|
|
263
|
-
r.className = `haori-toast haori-toast-${e}`, r.textContent = t, r.setAttribute("popover", "manual"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), document.body.appendChild(r), r.showPopover(), setTimeout(() => {
|
|
263
|
+
r.className = `haori-toast haori-toast-${e}`, r.textContent = t, r.setAttribute("popover", "manual"), r.setAttribute("role", "status"), r.setAttribute("aria-live", e === "error" ? "assertive" : "polite"), document.body.appendChild(r), r.showPopover(), setTimeout(() => {
|
|
264
264
|
try {
|
|
265
265
|
r.hidePopover();
|
|
266
266
|
} finally {
|
|
@@ -284,7 +284,7 @@ class tt {
|
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
286
|
return P.enqueue(() => {
|
|
287
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
287
|
+
t instanceof HTMLDialogElement ? t.showModal() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -294,7 +294,7 @@ class tt {
|
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
296
|
return P.enqueue(() => {
|
|
297
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
297
|
+
t instanceof HTMLDialogElement ? t.close() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -304,16 +304,19 @@ class tt {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
+
return J.addMessage(t, e, "error");
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* メッセージをレベル付きで追加します。
|
|
311
|
+
*
|
|
312
|
+
* @param target メッセージを表示する要素
|
|
313
|
+
* @param message メッセージ
|
|
314
|
+
* @param level メッセージのレベル(省略可能)
|
|
315
|
+
*/
|
|
316
|
+
static addMessage(t, e, r) {
|
|
307
317
|
return P.enqueue(() => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
if (t.parentElement) {
|
|
313
|
-
t.parentElement.setAttribute("data-message", e);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
t.setAttribute("data-message", e);
|
|
318
|
+
const i = t instanceof HTMLFormElement ? t : t.parentElement ?? t;
|
|
319
|
+
i.setAttribute("data-message", e), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
317
320
|
}, !0);
|
|
318
321
|
}
|
|
319
322
|
/**
|
|
@@ -323,20 +326,20 @@ class tt {
|
|
|
323
326
|
*/
|
|
324
327
|
static clearMessages(t) {
|
|
325
328
|
return P.enqueue(() => {
|
|
326
|
-
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
327
|
-
e.removeAttribute("data-message");
|
|
329
|
+
t.removeAttribute("data-message"), t.removeAttribute("data-message-level"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
330
|
+
e.removeAttribute("data-message"), e.removeAttribute("data-message-level");
|
|
328
331
|
});
|
|
329
332
|
}, !0);
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
|
-
const
|
|
333
|
-
function
|
|
335
|
+
const nt = ["addErrorMessage", "clearMessages"];
|
|
336
|
+
function et() {
|
|
334
337
|
const t = globalThis.window?.Haori;
|
|
335
|
-
return
|
|
338
|
+
return nt.every(
|
|
336
339
|
(r) => typeof t?.[r] == "function"
|
|
337
|
-
) ? t :
|
|
340
|
+
) ? t : J;
|
|
338
341
|
}
|
|
339
|
-
class
|
|
342
|
+
class b {
|
|
340
343
|
/**
|
|
341
344
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
342
345
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -347,7 +350,7 @@ class m {
|
|
|
347
350
|
*/
|
|
348
351
|
static getValues(t) {
|
|
349
352
|
const e = {};
|
|
350
|
-
return
|
|
353
|
+
return b.getPartValues(t, e);
|
|
351
354
|
}
|
|
352
355
|
/**
|
|
353
356
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -358,32 +361,32 @@ class m {
|
|
|
358
361
|
* @returns values と同じオブジェクト
|
|
359
362
|
*/
|
|
360
363
|
static getPartValues(t, e) {
|
|
361
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`),
|
|
364
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`), n = t.getAttribute(`${c.prefix}form-list`);
|
|
362
365
|
if (r) {
|
|
363
|
-
|
|
366
|
+
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && d.warn(
|
|
364
367
|
"Haori",
|
|
365
368
|
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
366
369
|
);
|
|
367
|
-
for (const
|
|
368
|
-
|
|
370
|
+
for (const s of t.getChildElementFragments())
|
|
371
|
+
b.getPartValues(s, e);
|
|
369
372
|
} else if (i) {
|
|
370
|
-
const
|
|
373
|
+
const s = {};
|
|
371
374
|
for (const a of t.getChildElementFragments())
|
|
372
|
-
|
|
373
|
-
Object.keys(
|
|
375
|
+
b.getPartValues(a, s);
|
|
376
|
+
Object.keys(s).length > 0 && (e[String(i)] = s), n && d.warn(
|
|
374
377
|
"Haori",
|
|
375
378
|
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
376
379
|
);
|
|
377
|
-
} else if (
|
|
378
|
-
const
|
|
380
|
+
} else if (n) {
|
|
381
|
+
const s = [];
|
|
379
382
|
for (const a of t.getChildElementFragments()) {
|
|
380
383
|
const o = {};
|
|
381
|
-
|
|
384
|
+
b.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
382
385
|
}
|
|
383
|
-
|
|
386
|
+
s.length > 0 && (e[String(n)] = s);
|
|
384
387
|
} else
|
|
385
|
-
for (const
|
|
386
|
-
|
|
388
|
+
for (const s of t.getChildElementFragments())
|
|
389
|
+
b.getPartValues(s, e);
|
|
387
390
|
return e;
|
|
388
391
|
}
|
|
389
392
|
/**
|
|
@@ -396,7 +399,7 @@ class m {
|
|
|
396
399
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
397
400
|
*/
|
|
398
401
|
static setValues(t, e, r = !1) {
|
|
399
|
-
return
|
|
402
|
+
return b.setPartValues(t, e, null, r, !0);
|
|
400
403
|
}
|
|
401
404
|
/**
|
|
402
405
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -408,7 +411,7 @@ class m {
|
|
|
408
411
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
409
412
|
*/
|
|
410
413
|
static syncValues(t, e, r = !1) {
|
|
411
|
-
return
|
|
414
|
+
return b.setPartValues(t, e, null, r, !1);
|
|
412
415
|
}
|
|
413
416
|
/**
|
|
414
417
|
* 単一フラグメントへ値を設定します。
|
|
@@ -430,53 +433,53 @@ class m {
|
|
|
430
433
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
431
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
432
435
|
*/
|
|
433
|
-
static setPartValues(t, e, r = null, i = !1,
|
|
434
|
-
const
|
|
436
|
+
static setPartValues(t, e, r = null, i = !1, n = !0) {
|
|
437
|
+
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${c.prefix}form-object`), u = t.getAttribute(`${c.prefix}form-list`), m = t.getAttribute(`${c.prefix}form-detach`);
|
|
435
438
|
if (a) {
|
|
436
|
-
if (!
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
) : typeof
|
|
441
|
-
|
|
439
|
+
if (!m || i) {
|
|
440
|
+
const y = e[String(a)];
|
|
441
|
+
u && Array.isArray(y) && r !== null ? s.push(
|
|
442
|
+
b.applyFragmentValue(t, y[r] ?? null, n)
|
|
443
|
+
) : typeof y > "u" || (typeof y == "string" || typeof y == "number" || typeof y == "boolean" || y === null ? s.push(b.applyFragmentValue(t, y, n)) : s.push(
|
|
444
|
+
b.applyFragmentValue(t, String(y), n)
|
|
442
445
|
));
|
|
443
446
|
}
|
|
444
447
|
} else if (o) {
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
for (const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
const y = e[String(o)];
|
|
449
|
+
if (y && typeof y == "object")
|
|
450
|
+
for (const E of t.getChildElementFragments())
|
|
451
|
+
s.push(
|
|
452
|
+
b.setPartValues(
|
|
453
|
+
E,
|
|
454
|
+
y,
|
|
452
455
|
null,
|
|
453
456
|
i,
|
|
454
|
-
|
|
457
|
+
n
|
|
455
458
|
)
|
|
456
459
|
);
|
|
457
|
-
} else if (
|
|
458
|
-
const
|
|
459
|
-
if (Array.isArray(
|
|
460
|
-
const
|
|
461
|
-
for (let S = 0; S <
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
460
|
+
} else if (u) {
|
|
461
|
+
const y = e[String(u)];
|
|
462
|
+
if (Array.isArray(y)) {
|
|
463
|
+
const E = t.getChildElementFragments();
|
|
464
|
+
for (let S = 0; S < E.length; S++) {
|
|
465
|
+
const h = E[S];
|
|
466
|
+
y.length > S ? s.push(
|
|
467
|
+
b.setPartValues(
|
|
468
|
+
h,
|
|
469
|
+
y[S],
|
|
467
470
|
S,
|
|
468
471
|
i,
|
|
469
|
-
|
|
472
|
+
n
|
|
470
473
|
)
|
|
471
|
-
) :
|
|
474
|
+
) : s.push(b.setPartValues(h, {}, S, i, n));
|
|
472
475
|
}
|
|
473
476
|
}
|
|
474
477
|
} else
|
|
475
|
-
for (const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
+
for (const y of t.getChildElementFragments())
|
|
479
|
+
s.push(
|
|
480
|
+
b.setPartValues(y, e, null, i, n)
|
|
478
481
|
);
|
|
479
|
-
return Promise.all(
|
|
482
|
+
return Promise.all(s).then(() => {
|
|
480
483
|
});
|
|
481
484
|
}
|
|
482
485
|
/**
|
|
@@ -487,9 +490,9 @@ class m {
|
|
|
487
490
|
* @returns すべての初期化処理が完了するPromise
|
|
488
491
|
*/
|
|
489
492
|
static async reset(t) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
b.clearValues(t), await Promise.all([
|
|
494
|
+
b.clearMessages(t),
|
|
495
|
+
b.clearEachClones(t)
|
|
493
496
|
]), await P.enqueue(() => {
|
|
494
497
|
const e = t.getTarget();
|
|
495
498
|
if (e instanceof HTMLFormElement)
|
|
@@ -497,11 +500,11 @@ class m {
|
|
|
497
500
|
else {
|
|
498
501
|
const r = e.parentElement;
|
|
499
502
|
if (r) {
|
|
500
|
-
const i = e.nextElementSibling,
|
|
501
|
-
|
|
503
|
+
const i = e.nextElementSibling, n = document.createElement("form");
|
|
504
|
+
n.appendChild(e), n.reset(), r.insertBefore(e, i);
|
|
502
505
|
}
|
|
503
506
|
}
|
|
504
|
-
}), await
|
|
507
|
+
}), await R.evaluateAll(t);
|
|
505
508
|
}
|
|
506
509
|
/**
|
|
507
510
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -510,20 +513,20 @@ class m {
|
|
|
510
513
|
* 対象エレメント自体は削除しません。
|
|
511
514
|
*/
|
|
512
515
|
static clearEachClones(t) {
|
|
513
|
-
const e = [], r = (
|
|
514
|
-
if (
|
|
515
|
-
for (const
|
|
516
|
-
const a =
|
|
517
|
-
!a && !o && e.push(
|
|
516
|
+
const e = [], r = (n) => {
|
|
517
|
+
if (n.hasAttribute(`${c.prefix}each`))
|
|
518
|
+
for (const s of n.getChildElementFragments()) {
|
|
519
|
+
const a = s.hasAttribute(`${c.prefix}each-before`), o = s.hasAttribute(`${c.prefix}each-after`);
|
|
520
|
+
!a && !o && e.push(s.remove());
|
|
518
521
|
}
|
|
519
|
-
}, i = (
|
|
520
|
-
r(
|
|
521
|
-
for (const
|
|
522
|
-
i(
|
|
522
|
+
}, i = (n) => {
|
|
523
|
+
r(n);
|
|
524
|
+
for (const s of n.getChildElementFragments())
|
|
525
|
+
i(s);
|
|
523
526
|
};
|
|
524
527
|
r(t);
|
|
525
|
-
for (const
|
|
526
|
-
i(
|
|
528
|
+
for (const n of t.getChildElementFragments())
|
|
529
|
+
i(n);
|
|
527
530
|
return Promise.all(e).then(() => {
|
|
528
531
|
});
|
|
529
532
|
}
|
|
@@ -535,7 +538,7 @@ class m {
|
|
|
535
538
|
static clearValues(t) {
|
|
536
539
|
t.clearValue();
|
|
537
540
|
for (const e of t.getChildElementFragments())
|
|
538
|
-
|
|
541
|
+
b.clearValues(e);
|
|
539
542
|
}
|
|
540
543
|
/**
|
|
541
544
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -544,7 +547,7 @@ class m {
|
|
|
544
547
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
545
548
|
*/
|
|
546
549
|
static clearMessages(t) {
|
|
547
|
-
return
|
|
550
|
+
return et().clearMessages(
|
|
548
551
|
t.getTarget()
|
|
549
552
|
);
|
|
550
553
|
}
|
|
@@ -554,18 +557,27 @@ class m {
|
|
|
554
557
|
*
|
|
555
558
|
* @param fragment 対象フラグメント
|
|
556
559
|
* @param key キー(ドット区切りの文字列)
|
|
557
|
-
* @param message 追加するエラーメッセージ
|
|
560
|
+
* @param message 追加するエラーメッセージ
|
|
558
561
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
559
562
|
*/
|
|
560
563
|
static addErrorMessage(t, e, r) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
564
|
+
return b.addMessage(t, e, r, "error");
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
568
|
+
* キーに一致するフラグメントが見つからない場合は、指定されたフラグメントにメッセージを追加します。
|
|
569
|
+
*
|
|
570
|
+
* @param fragment 対象フラグメント
|
|
571
|
+
* @param key キー(ドット区切りの文字列)
|
|
572
|
+
* @param message 追加するメッセージ
|
|
573
|
+
* @param level メッセージのレベル(省略可能)
|
|
574
|
+
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
|
+
*/
|
|
576
|
+
static addMessage(t, e, r, i) {
|
|
577
|
+
const n = [], s = et(), a = s.addMessage, o = (m) => typeof a == "function" ? a.call(s, m, r, i) : s.addErrorMessage(m, r), u = b.findFragmentsByKey(t, e);
|
|
578
|
+
return u.forEach((m) => {
|
|
579
|
+
n.push(o(m.getTarget()));
|
|
580
|
+
}), u.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
569
581
|
});
|
|
570
582
|
}
|
|
571
583
|
/**
|
|
@@ -576,7 +588,7 @@ class m {
|
|
|
576
588
|
* @returns 一致するフラグメントの配列
|
|
577
589
|
*/
|
|
578
590
|
static findFragmentsByKey(t, e) {
|
|
579
|
-
return
|
|
591
|
+
return b.findFragmentByKeyParts(t, e.split("."));
|
|
580
592
|
}
|
|
581
593
|
/**
|
|
582
594
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -589,30 +601,30 @@ class m {
|
|
|
589
601
|
static findFragmentByKeyParts(t, e) {
|
|
590
602
|
const r = [], i = e[0];
|
|
591
603
|
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((
|
|
593
|
-
r.push(...
|
|
604
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === i && t.getChildElementFragments().forEach((s) => {
|
|
605
|
+
r.push(...b.findFragmentByKeyParts(s, e.slice(1)));
|
|
594
606
|
});
|
|
595
607
|
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
596
608
|
if (e.length > 1) {
|
|
597
|
-
const
|
|
598
|
-
if (
|
|
599
|
-
const o = i.substring(0,
|
|
600
|
-
if (
|
|
601
|
-
const
|
|
602
|
-
if (isNaN(
|
|
603
|
-
|
|
609
|
+
const n = t.getAttribute(`${c.prefix}form-list`), s = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
610
|
+
if (s !== -1 && a !== -1 && s < a) {
|
|
611
|
+
const o = i.substring(0, s);
|
|
612
|
+
if (n === o) {
|
|
613
|
+
const u = i.substring(s + 1, a), m = Number(u);
|
|
614
|
+
if (isNaN(m))
|
|
615
|
+
d.error("Haori", `Invalid index: ${i}`);
|
|
604
616
|
else {
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
...
|
|
617
|
+
const y = t.getChildElementFragments().filter((E) => E.hasAttribute(`${c.prefix}row`));
|
|
618
|
+
m < y.length && r.push(
|
|
619
|
+
...b.findFragmentByKeyParts(y[m], e.slice(1))
|
|
608
620
|
);
|
|
609
621
|
}
|
|
610
622
|
}
|
|
611
623
|
}
|
|
612
624
|
}
|
|
613
625
|
} else
|
|
614
|
-
t.getChildElementFragments().forEach((
|
|
615
|
-
r.push(...
|
|
626
|
+
t.getChildElementFragments().forEach((n) => {
|
|
627
|
+
r.push(...b.findFragmentByKeyParts(n, e));
|
|
616
628
|
});
|
|
617
629
|
return r;
|
|
618
630
|
}
|
|
@@ -629,7 +641,7 @@ class m {
|
|
|
629
641
|
return r ? this.getFormFragment(r) : null;
|
|
630
642
|
}
|
|
631
643
|
}
|
|
632
|
-
const
|
|
644
|
+
const M = class M {
|
|
633
645
|
/**
|
|
634
646
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
635
647
|
*
|
|
@@ -674,28 +686,28 @@ const R = class R {
|
|
|
674
686
|
*/
|
|
675
687
|
static evaluate(t, e = {}) {
|
|
676
688
|
if (t.trim() === "")
|
|
677
|
-
return
|
|
689
|
+
return d.warn("[Haori]", t, "Expression is empty"), null;
|
|
678
690
|
if (this.containsDangerousPatterns(t))
|
|
679
|
-
return
|
|
691
|
+
return d.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
680
692
|
if (this.containsForbiddenKeys(e))
|
|
681
|
-
return
|
|
693
|
+
return d.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
682
694
|
if (this.containsForbiddenBindingValues(e))
|
|
683
|
-
return
|
|
695
|
+
return d.warn(
|
|
684
696
|
"[Haori]",
|
|
685
697
|
e,
|
|
686
698
|
"Binded values contain forbidden values"
|
|
687
699
|
), null;
|
|
688
|
-
const r = Object.keys(e).filter((
|
|
689
|
-
let
|
|
690
|
-
if (!
|
|
691
|
-
const
|
|
692
|
-
${
|
|
700
|
+
const r = Object.keys(e).filter((s) => !this.FORBIDDEN_BINDING_NAMES.has(s)).sort(), i = `${t}:${r.join(",")}`;
|
|
701
|
+
let n = this.EXPRESSION_CACHE.get(i);
|
|
702
|
+
if (!n) {
|
|
703
|
+
const s = this.buildAssignments(r), a = s ? `"use strict";
|
|
704
|
+
${s};
|
|
693
705
|
return (${t});` : `"use strict";
|
|
694
706
|
return (${t});`;
|
|
695
707
|
try {
|
|
696
|
-
|
|
708
|
+
n = new Function(...r, a), this.EXPRESSION_CACHE.set(i, n);
|
|
697
709
|
} catch (o) {
|
|
698
|
-
return
|
|
710
|
+
return d.error(
|
|
699
711
|
"[Haori]",
|
|
700
712
|
"Failed to compile expression:",
|
|
701
713
|
t,
|
|
@@ -704,12 +716,12 @@ return (${t});`;
|
|
|
704
716
|
}
|
|
705
717
|
}
|
|
706
718
|
try {
|
|
707
|
-
const
|
|
719
|
+
const s = [], a = this.wrapBoundValues(e);
|
|
708
720
|
return r.forEach((o) => {
|
|
709
|
-
|
|
710
|
-
}), this.withBlockedPropertyAccess(() =>
|
|
711
|
-
} catch (
|
|
712
|
-
return
|
|
721
|
+
s.push(a[o]);
|
|
722
|
+
}), this.withBlockedPropertyAccess(() => n(...s));
|
|
723
|
+
} catch (s) {
|
|
724
|
+
return d.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
713
725
|
}
|
|
714
726
|
}
|
|
715
727
|
/**
|
|
@@ -740,13 +752,13 @@ return (${t});`;
|
|
|
740
752
|
return !1;
|
|
741
753
|
const r = [];
|
|
742
754
|
let i = null;
|
|
743
|
-
for (let
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
this.decodeStringLiteral(
|
|
747
|
-
) ||
|
|
755
|
+
for (let n = 0; n < e.length; n++) {
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null;
|
|
757
|
+
if (s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
758
|
+
this.decodeStringLiteral(s.value)
|
|
759
|
+
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
748
760
|
return !1;
|
|
749
|
-
switch (
|
|
761
|
+
switch (s.value) {
|
|
750
762
|
case "(":
|
|
751
763
|
r.push("paren");
|
|
752
764
|
break;
|
|
@@ -756,8 +768,8 @@ return (${t});`;
|
|
|
756
768
|
break;
|
|
757
769
|
}
|
|
758
770
|
case "[": {
|
|
759
|
-
const
|
|
760
|
-
r.push(
|
|
771
|
+
const u = this.startsMemberAccess(i) ? "member" : "array";
|
|
772
|
+
r.push(u);
|
|
761
773
|
break;
|
|
762
774
|
}
|
|
763
775
|
case "]": {
|
|
@@ -766,7 +778,7 @@ return (${t});`;
|
|
|
766
778
|
break;
|
|
767
779
|
}
|
|
768
780
|
}
|
|
769
|
-
i =
|
|
781
|
+
i = s;
|
|
770
782
|
}
|
|
771
783
|
return r.length === 0;
|
|
772
784
|
}
|
|
@@ -807,41 +819,41 @@ return (${t});`;
|
|
|
807
819
|
">",
|
|
808
820
|
"<"
|
|
809
821
|
]);
|
|
810
|
-
let
|
|
811
|
-
for (;
|
|
812
|
-
const
|
|
813
|
-
if (/\s/.test(
|
|
814
|
-
|
|
822
|
+
let n = 0;
|
|
823
|
+
for (; n < t.length; ) {
|
|
824
|
+
const s = t[n];
|
|
825
|
+
if (/\s/.test(s)) {
|
|
826
|
+
n += 1;
|
|
815
827
|
continue;
|
|
816
828
|
}
|
|
817
|
-
if (
|
|
829
|
+
if (s === "/" && (t[n + 1] === "/" || t[n + 1] === "*"))
|
|
818
830
|
return null;
|
|
819
|
-
if (
|
|
820
|
-
const o = this.readStringToken(t,
|
|
831
|
+
if (s === '"' || s === "'") {
|
|
832
|
+
const o = this.readStringToken(t, n);
|
|
821
833
|
if (o === null)
|
|
822
834
|
return null;
|
|
823
|
-
e.push(o.token),
|
|
835
|
+
e.push(o.token), n = o.nextIndex;
|
|
824
836
|
continue;
|
|
825
837
|
}
|
|
826
838
|
const a = r.find(
|
|
827
|
-
(o) => t.startsWith(o,
|
|
839
|
+
(o) => t.startsWith(o, n)
|
|
828
840
|
);
|
|
829
841
|
if (a) {
|
|
830
|
-
e.push({ type: "operator", value: a, position:
|
|
842
|
+
e.push({ type: "operator", value: a, position: n }), n += a.length;
|
|
831
843
|
continue;
|
|
832
844
|
}
|
|
833
|
-
if (/[0-9]/.test(
|
|
834
|
-
const o = this.readNumberToken(t,
|
|
835
|
-
e.push(o.token),
|
|
845
|
+
if (/[0-9]/.test(s)) {
|
|
846
|
+
const o = this.readNumberToken(t, n);
|
|
847
|
+
e.push(o.token), n = o.nextIndex;
|
|
836
848
|
continue;
|
|
837
849
|
}
|
|
838
|
-
if (/[A-Za-z_$]/.test(
|
|
839
|
-
const o = this.readIdentifierToken(t,
|
|
840
|
-
e.push(o.token),
|
|
850
|
+
if (/[A-Za-z_$]/.test(s)) {
|
|
851
|
+
const o = this.readIdentifierToken(t, n);
|
|
852
|
+
e.push(o.token), n = o.nextIndex;
|
|
841
853
|
continue;
|
|
842
854
|
}
|
|
843
|
-
if (i.has(
|
|
844
|
-
e.push({ type: "operator", value:
|
|
855
|
+
if (i.has(s)) {
|
|
856
|
+
e.push({ type: "operator", value: s, position: n }), n += 1;
|
|
845
857
|
continue;
|
|
846
858
|
}
|
|
847
859
|
return null;
|
|
@@ -859,12 +871,12 @@ return (${t});`;
|
|
|
859
871
|
const r = t[e];
|
|
860
872
|
let i = e + 1;
|
|
861
873
|
for (; i < t.length; ) {
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
874
|
+
const n = t[i];
|
|
875
|
+
if (n === "\\") {
|
|
864
876
|
i += 2;
|
|
865
877
|
continue;
|
|
866
878
|
}
|
|
867
|
-
if (
|
|
879
|
+
if (n === r)
|
|
868
880
|
return {
|
|
869
881
|
token: {
|
|
870
882
|
type: "string",
|
|
@@ -972,8 +984,8 @@ return (${t});`;
|
|
|
972
984
|
*/
|
|
973
985
|
static wrapBoundValues(t) {
|
|
974
986
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
975
|
-
return Object.entries(t).forEach(([i,
|
|
976
|
-
r[i] = this.wrapBoundValue(
|
|
987
|
+
return Object.entries(t).forEach(([i, n]) => {
|
|
988
|
+
r[i] = this.wrapBoundValue(n, e);
|
|
977
989
|
}), r;
|
|
978
990
|
}
|
|
979
991
|
/**
|
|
@@ -989,39 +1001,39 @@ return (${t});`;
|
|
|
989
1001
|
const r = t, i = e.get(r);
|
|
990
1002
|
if (i !== void 0)
|
|
991
1003
|
return i;
|
|
992
|
-
const
|
|
993
|
-
get: (
|
|
1004
|
+
const n = new Proxy(r, {
|
|
1005
|
+
get: (s, a, o) => {
|
|
994
1006
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
995
1007
|
return;
|
|
996
|
-
const
|
|
997
|
-
return typeof a == "symbol" ?
|
|
998
|
-
|
|
1008
|
+
const u = Reflect.get(s, a, o);
|
|
1009
|
+
return typeof a == "symbol" ? u : this.wrapBoundValue(
|
|
1010
|
+
u,
|
|
999
1011
|
e
|
|
1000
1012
|
);
|
|
1001
1013
|
},
|
|
1002
|
-
has: (
|
|
1003
|
-
getOwnPropertyDescriptor: (
|
|
1014
|
+
has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
|
|
1015
|
+
getOwnPropertyDescriptor: (s, a) => {
|
|
1004
1016
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
1005
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
1017
|
+
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1006
1018
|
},
|
|
1007
|
-
apply: (
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1019
|
+
apply: (s, a, o) => {
|
|
1020
|
+
const u = Reflect.apply(
|
|
1021
|
+
s,
|
|
1010
1022
|
a,
|
|
1011
1023
|
o
|
|
1012
1024
|
);
|
|
1013
|
-
return this.isIteratorLike(
|
|
1025
|
+
return this.isIteratorLike(u) ? u : this.wrapBoundValue(u, e);
|
|
1014
1026
|
},
|
|
1015
|
-
construct: (
|
|
1027
|
+
construct: (s, a, o) => this.wrapBoundValue(
|
|
1016
1028
|
Reflect.construct(
|
|
1017
|
-
|
|
1029
|
+
s,
|
|
1018
1030
|
a,
|
|
1019
1031
|
o
|
|
1020
1032
|
),
|
|
1021
1033
|
e
|
|
1022
1034
|
)
|
|
1023
1035
|
});
|
|
1024
|
-
return e.set(r,
|
|
1036
|
+
return e.set(r, n), n;
|
|
1025
1037
|
}
|
|
1026
1038
|
/**
|
|
1027
1039
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -1054,8 +1066,8 @@ return (${t});`;
|
|
|
1054
1066
|
...i,
|
|
1055
1067
|
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
1056
1068
|
})).filter((i) => i.descriptor?.configurable === !0);
|
|
1057
|
-
r.forEach(({ target: i, property:
|
|
1058
|
-
Object.defineProperty(i,
|
|
1069
|
+
r.forEach(({ target: i, property: n }) => {
|
|
1070
|
+
Object.defineProperty(i, n, {
|
|
1059
1071
|
configurable: !0,
|
|
1060
1072
|
enumerable: !1,
|
|
1061
1073
|
get: () => {
|
|
@@ -1067,8 +1079,8 @@ return (${t});`;
|
|
|
1067
1079
|
try {
|
|
1068
1080
|
return t();
|
|
1069
1081
|
} finally {
|
|
1070
|
-
r.forEach(({ target: i, property:
|
|
1071
|
-
|
|
1082
|
+
r.forEach(({ target: i, property: n, descriptor: s }) => {
|
|
1083
|
+
s !== void 0 && Object.defineProperty(i, n, s);
|
|
1072
1084
|
});
|
|
1073
1085
|
}
|
|
1074
1086
|
}
|
|
@@ -1122,7 +1134,7 @@ return (${t});`;
|
|
|
1122
1134
|
return !1;
|
|
1123
1135
|
}
|
|
1124
1136
|
};
|
|
1125
|
-
|
|
1137
|
+
M.FORBIDDEN_NAMES = [
|
|
1126
1138
|
// グローバルオブジェクト
|
|
1127
1139
|
"window",
|
|
1128
1140
|
"self",
|
|
@@ -1154,19 +1166,19 @@ R.FORBIDDEN_NAMES = [
|
|
|
1154
1166
|
"sessionStorage",
|
|
1155
1167
|
"IndexedDB",
|
|
1156
1168
|
"history"
|
|
1157
|
-
],
|
|
1158
|
-
...
|
|
1159
|
-
(t) => !
|
|
1169
|
+
], M.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], M.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), M.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1170
|
+
...M.FORBIDDEN_NAMES.filter(
|
|
1171
|
+
(t) => !M.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1160
1172
|
),
|
|
1161
1173
|
"constructor",
|
|
1162
1174
|
"__proto__",
|
|
1163
1175
|
"prototype",
|
|
1164
|
-
...
|
|
1165
|
-
]),
|
|
1176
|
+
...M.STRICT_FORBIDDEN_NAMES
|
|
1177
|
+
]), M.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1166
1178
|
"constructor",
|
|
1167
1179
|
"__proto__",
|
|
1168
1180
|
"prototype"
|
|
1169
|
-
]),
|
|
1181
|
+
]), M.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1170
1182
|
"await",
|
|
1171
1183
|
"break",
|
|
1172
1184
|
"case",
|
|
@@ -1200,8 +1212,8 @@ R.FORBIDDEN_NAMES = [
|
|
|
1200
1212
|
"while",
|
|
1201
1213
|
"with",
|
|
1202
1214
|
"yield"
|
|
1203
|
-
]),
|
|
1204
|
-
let j =
|
|
1215
|
+
]), M.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1216
|
+
let j = M;
|
|
1205
1217
|
const C = class C {
|
|
1206
1218
|
/**
|
|
1207
1219
|
* フラグメントのコンストラクタ。
|
|
@@ -1219,16 +1231,16 @@ const C = class C {
|
|
|
1219
1231
|
let e;
|
|
1220
1232
|
switch (t.nodeType) {
|
|
1221
1233
|
case Node.ELEMENT_NODE:
|
|
1222
|
-
e = new
|
|
1234
|
+
e = new x(t);
|
|
1223
1235
|
break;
|
|
1224
1236
|
case Node.TEXT_NODE:
|
|
1225
|
-
e = new
|
|
1237
|
+
e = new H(t);
|
|
1226
1238
|
break;
|
|
1227
1239
|
case Node.COMMENT_NODE:
|
|
1228
|
-
e = new
|
|
1240
|
+
e = new Z(t);
|
|
1229
1241
|
break;
|
|
1230
1242
|
default:
|
|
1231
|
-
return
|
|
1243
|
+
return d.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1232
1244
|
}
|
|
1233
1245
|
return e;
|
|
1234
1246
|
}
|
|
@@ -1334,8 +1346,8 @@ const C = class C {
|
|
|
1334
1346
|
}
|
|
1335
1347
|
};
|
|
1336
1348
|
C.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1337
|
-
let
|
|
1338
|
-
class
|
|
1349
|
+
let T = C;
|
|
1350
|
+
class x extends T {
|
|
1339
1351
|
/**
|
|
1340
1352
|
* エレメントフラグメントのコンストラクタ。
|
|
1341
1353
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1365,7 +1377,7 @@ class D extends N {
|
|
|
1365
1377
|
this.attributeMap.set(e, i);
|
|
1366
1378
|
}
|
|
1367
1379
|
}), t.childNodes.forEach((e) => {
|
|
1368
|
-
const r =
|
|
1380
|
+
const r = T.get(e);
|
|
1369
1381
|
r.setParent(this), this.children.push(r);
|
|
1370
1382
|
});
|
|
1371
1383
|
}
|
|
@@ -1384,7 +1396,7 @@ class D extends N {
|
|
|
1384
1396
|
*/
|
|
1385
1397
|
getChildElementFragments() {
|
|
1386
1398
|
return this.children.filter(
|
|
1387
|
-
(t) => t instanceof
|
|
1399
|
+
(t) => t instanceof x
|
|
1388
1400
|
);
|
|
1389
1401
|
}
|
|
1390
1402
|
/**
|
|
@@ -1405,7 +1417,7 @@ class D extends N {
|
|
|
1405
1417
|
removeChild(t) {
|
|
1406
1418
|
const e = this.children.indexOf(t);
|
|
1407
1419
|
if (e < 0) {
|
|
1408
|
-
|
|
1420
|
+
d.warn("[Haori]", "Child fragment not found.", t);
|
|
1409
1421
|
return;
|
|
1410
1422
|
}
|
|
1411
1423
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1416,7 +1428,7 @@ class D extends N {
|
|
|
1416
1428
|
* @returns クローンされたフラグメント
|
|
1417
1429
|
*/
|
|
1418
1430
|
clone() {
|
|
1419
|
-
const t = new
|
|
1431
|
+
const t = new x(
|
|
1420
1432
|
this.target.cloneNode(!1)
|
|
1421
1433
|
);
|
|
1422
1434
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1484,7 +1496,7 @@ class D extends N {
|
|
|
1484
1496
|
*/
|
|
1485
1497
|
clearBindingDataCache() {
|
|
1486
1498
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1487
|
-
t instanceof
|
|
1499
|
+
t instanceof x && t.clearBindingDataCache();
|
|
1488
1500
|
});
|
|
1489
1501
|
}
|
|
1490
1502
|
/**
|
|
@@ -1552,10 +1564,10 @@ class D extends N {
|
|
|
1552
1564
|
return Promise.resolve();
|
|
1553
1565
|
const r = this.getTarget();
|
|
1554
1566
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1555
|
-
const i = this.getAttribute("value"),
|
|
1556
|
-
let
|
|
1557
|
-
return
|
|
1558
|
-
r.checked =
|
|
1567
|
+
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1568
|
+
let s;
|
|
1569
|
+
return n ? s = t === !0 || t === "true" : i === "false" ? s = t === !1 : s = i === String(t), this.value = n ? s : s ? t : null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, P.enqueue(() => {
|
|
1570
|
+
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1559
1571
|
}).finally(() => {
|
|
1560
1572
|
this.skipChangeValue = !1;
|
|
1561
1573
|
}));
|
|
@@ -1563,7 +1575,7 @@ class D extends N {
|
|
|
1563
1575
|
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
1576
|
}).finally(() => {
|
|
1565
1577
|
this.skipChangeValue = !1;
|
|
1566
|
-
})) : (
|
|
1578
|
+
})) : (d.warn(
|
|
1567
1579
|
"[Haori]",
|
|
1568
1580
|
"setValue is not supported for this element type.",
|
|
1569
1581
|
r
|
|
@@ -1614,19 +1626,60 @@ class D extends N {
|
|
|
1614
1626
|
* @returns 属性の更新のPromise
|
|
1615
1627
|
*/
|
|
1616
1628
|
setAttribute(t, e) {
|
|
1629
|
+
return this.setAttributeInternal(t, t, e, !0);
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* data-attr-* の生値を保持しつつ、別名の属性へ評価結果を反映します。
|
|
1633
|
+
*
|
|
1634
|
+
* @param rawName 生の属性名
|
|
1635
|
+
* @param targetName 反映先の属性名
|
|
1636
|
+
* @param value 生の属性値
|
|
1637
|
+
* @returns 属性更新の Promise
|
|
1638
|
+
*/
|
|
1639
|
+
setAliasedAttribute(t, e, r) {
|
|
1640
|
+
return this.setAttributeInternal(t, e, r, !1);
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* data-attr-* の生属性と反映先属性を同時に削除します。
|
|
1644
|
+
*
|
|
1645
|
+
* @param rawName 生の属性名
|
|
1646
|
+
* @param targetName 反映先の属性名
|
|
1647
|
+
* @returns 属性削除の Promise
|
|
1648
|
+
*/
|
|
1649
|
+
removeAliasedAttribute(t, e) {
|
|
1617
1650
|
if (this.skipMutationAttributes)
|
|
1618
1651
|
return Promise.resolve();
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
const r = new U(t, e);
|
|
1622
|
-
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1623
|
-
const i = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1652
|
+
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1653
|
+
const r = this.getTarget();
|
|
1624
1654
|
return P.enqueue(() => {
|
|
1625
|
-
|
|
1626
|
-
|
|
1655
|
+
r.removeAttribute(t), e !== t && r.removeAttribute(e);
|
|
1656
|
+
}).finally(() => {
|
|
1657
|
+
this.skipMutationAttributes = !1;
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* 生の属性値を保持しつつ、必要に応じて別名属性へ評価結果を反映します。
|
|
1662
|
+
*
|
|
1663
|
+
* @param rawName 生の属性名
|
|
1664
|
+
* @param targetName 反映先の属性名
|
|
1665
|
+
* @param value 生の属性値
|
|
1666
|
+
* @param syncValueProperty value 属性更新時に DOM property も同期するかどうか
|
|
1667
|
+
* @returns 属性更新の Promise
|
|
1668
|
+
*/
|
|
1669
|
+
setAttributeInternal(t, e, r, i) {
|
|
1670
|
+
if (this.skipMutationAttributes)
|
|
1671
|
+
return Promise.resolve();
|
|
1672
|
+
if (r === null)
|
|
1673
|
+
return t === e ? this.removeAttribute(t) : this.removeAliasedAttribute(t, e);
|
|
1674
|
+
const n = new U(t, r);
|
|
1675
|
+
this.attributeMap.set(t, n), this.skipMutationAttributes = !0;
|
|
1676
|
+
const s = this.getTarget(), a = n.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1677
|
+
return P.enqueue(() => {
|
|
1678
|
+
if (s.getAttribute(t) !== r && s.setAttribute(t, r), a === null || a === !1)
|
|
1679
|
+
s.removeAttribute(e);
|
|
1627
1680
|
else {
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1681
|
+
const o = String(a);
|
|
1682
|
+
s.getAttribute(e) !== o && s.setAttribute(e, o), i && n.isEvaluate && e === "value" && (s instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(s.type) || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (this.value = o, s.value !== o && (s.value = o));
|
|
1630
1683
|
}
|
|
1631
1684
|
}).finally(() => {
|
|
1632
1685
|
this.skipMutationAttributes = !1;
|
|
@@ -1661,7 +1714,7 @@ class D extends N {
|
|
|
1661
1714
|
if (e === void 0)
|
|
1662
1715
|
return null;
|
|
1663
1716
|
const r = e.evaluate(this.getBindingData());
|
|
1664
|
-
return r.length === 1 ? r[0] :
|
|
1717
|
+
return r.length === 1 ? r[0] : L.joinEvaluateResults(r);
|
|
1665
1718
|
}
|
|
1666
1719
|
/**
|
|
1667
1720
|
* 属性の生の値を取得します。
|
|
@@ -1702,15 +1755,15 @@ class D extends N {
|
|
|
1702
1755
|
if (r.parentNode !== this.target)
|
|
1703
1756
|
return null;
|
|
1704
1757
|
const i = e ? r.nextSibling : r;
|
|
1705
|
-
let
|
|
1706
|
-
for (;
|
|
1707
|
-
const
|
|
1708
|
-
if (
|
|
1709
|
-
const a = this.children.indexOf(
|
|
1758
|
+
let n = e ? r.nextSibling : r;
|
|
1759
|
+
for (; n !== null; ) {
|
|
1760
|
+
const s = T.get(n);
|
|
1761
|
+
if (s !== null) {
|
|
1762
|
+
const a = this.children.indexOf(s);
|
|
1710
1763
|
if (a !== -1)
|
|
1711
1764
|
return { index: a, referenceNode: i };
|
|
1712
1765
|
}
|
|
1713
|
-
|
|
1766
|
+
n = n.nextSibling;
|
|
1714
1767
|
}
|
|
1715
1768
|
return { index: this.children.length, referenceNode: i };
|
|
1716
1769
|
}
|
|
@@ -1726,42 +1779,42 @@ class D extends N {
|
|
|
1726
1779
|
if (this.skipMutationNodes)
|
|
1727
1780
|
return Promise.resolve();
|
|
1728
1781
|
if (t === this)
|
|
1729
|
-
return
|
|
1782
|
+
return d.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1730
1783
|
const i = /* @__PURE__ */ new Set();
|
|
1731
|
-
let
|
|
1732
|
-
for (;
|
|
1733
|
-
i.add(
|
|
1784
|
+
let n = this.parent;
|
|
1785
|
+
for (; n; )
|
|
1786
|
+
i.add(n), n = n.getParent();
|
|
1734
1787
|
if (i.has(t))
|
|
1735
|
-
return
|
|
1736
|
-
const
|
|
1788
|
+
return d.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1789
|
+
const s = t.getParent() === this;
|
|
1737
1790
|
let a = -1, o = -1;
|
|
1738
|
-
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1741
|
-
let
|
|
1791
|
+
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1792
|
+
const u = t.getParent();
|
|
1793
|
+
u !== null && u.removeChild(t);
|
|
1794
|
+
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1742
1795
|
if (e === null)
|
|
1743
1796
|
this.children.push(t);
|
|
1744
1797
|
else {
|
|
1745
|
-
let
|
|
1746
|
-
if (
|
|
1798
|
+
let E;
|
|
1799
|
+
if (s ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1747
1800
|
const S = this.resolveInsertionPointFromDom(
|
|
1748
1801
|
e,
|
|
1749
1802
|
!1
|
|
1750
1803
|
);
|
|
1751
|
-
S === null ? (
|
|
1804
|
+
S === null ? (d.warn(
|
|
1752
1805
|
"[Haori]",
|
|
1753
1806
|
"Reference child not found in children.",
|
|
1754
1807
|
e
|
|
1755
|
-
), this.children.push(t)) : (this.children.splice(S.index, 0, t),
|
|
1808
|
+
), this.children.push(t)) : (this.children.splice(S.index, 0, t), m = S.referenceNode);
|
|
1756
1809
|
} else
|
|
1757
|
-
this.children.splice(
|
|
1810
|
+
this.children.splice(E, 0, t);
|
|
1758
1811
|
}
|
|
1759
1812
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1760
|
-
const
|
|
1813
|
+
const y = this.skipMutationNodes;
|
|
1761
1814
|
return this.skipMutationNodes = !0, P.enqueue(() => {
|
|
1762
|
-
this.target.insertBefore(t.getTarget(),
|
|
1815
|
+
this.target.insertBefore(t.getTarget(), m);
|
|
1763
1816
|
}).finally(() => {
|
|
1764
|
-
this.skipMutationNodes =
|
|
1817
|
+
this.skipMutationNodes = y;
|
|
1765
1818
|
});
|
|
1766
1819
|
}
|
|
1767
1820
|
/**
|
|
@@ -1780,7 +1833,7 @@ class D extends N {
|
|
|
1780
1833
|
e,
|
|
1781
1834
|
!0
|
|
1782
1835
|
);
|
|
1783
|
-
return i === null ? (
|
|
1836
|
+
return i === null ? (d.warn(
|
|
1784
1837
|
"[Haori]",
|
|
1785
1838
|
"Reference child not found in children.",
|
|
1786
1839
|
e
|
|
@@ -1856,7 +1909,7 @@ class D extends N {
|
|
|
1856
1909
|
return e === null ? null : e.closestByAttribute(t);
|
|
1857
1910
|
}
|
|
1858
1911
|
}
|
|
1859
|
-
class
|
|
1912
|
+
class H extends T {
|
|
1860
1913
|
/**
|
|
1861
1914
|
* テキストフラグメントのコンストラクタ。
|
|
1862
1915
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1864,7 +1917,7 @@ class L extends N {
|
|
|
1864
1917
|
* @param target 対象テキストノード
|
|
1865
1918
|
*/
|
|
1866
1919
|
constructor(t) {
|
|
1867
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1920
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new L(this.text);
|
|
1868
1921
|
}
|
|
1869
1922
|
/**
|
|
1870
1923
|
* フラグメントをクローンします。
|
|
@@ -1872,7 +1925,7 @@ class L extends N {
|
|
|
1872
1925
|
* @returns クローンされたフラグメント
|
|
1873
1926
|
*/
|
|
1874
1927
|
clone() {
|
|
1875
|
-
const t = new
|
|
1928
|
+
const t = new H(this.target.cloneNode(!0));
|
|
1876
1929
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1877
1930
|
}
|
|
1878
1931
|
/**
|
|
@@ -1890,7 +1943,7 @@ class L extends N {
|
|
|
1890
1943
|
* @returns 更新のPromise
|
|
1891
1944
|
*/
|
|
1892
1945
|
setContent(t) {
|
|
1893
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1946
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new L(t), this.evaluate());
|
|
1894
1947
|
}
|
|
1895
1948
|
/**
|
|
1896
1949
|
* フラグメントを評価します。
|
|
@@ -1903,7 +1956,7 @@ class L extends N {
|
|
|
1903
1956
|
) : P.enqueue(() => {
|
|
1904
1957
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1905
1958
|
this.parent.getBindingData()
|
|
1906
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1959
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = L.joinEvaluateResults(
|
|
1907
1960
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1908
1961
|
) : this.target.textContent = this.text;
|
|
1909
1962
|
}).finally(() => {
|
|
@@ -1911,7 +1964,7 @@ class L extends N {
|
|
|
1911
1964
|
});
|
|
1912
1965
|
}
|
|
1913
1966
|
}
|
|
1914
|
-
class
|
|
1967
|
+
class Z extends T {
|
|
1915
1968
|
/**
|
|
1916
1969
|
* コメントフラグメントのコンストラクタ。
|
|
1917
1970
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1927,7 +1980,7 @@ class Y extends N {
|
|
|
1927
1980
|
* @returns クローンされたフラグメント
|
|
1928
1981
|
*/
|
|
1929
1982
|
clone() {
|
|
1930
|
-
const t = new
|
|
1983
|
+
const t = new Z(this.target.cloneNode(!0));
|
|
1931
1984
|
return t.mounted = !1, t.text = this.text, t;
|
|
1932
1985
|
}
|
|
1933
1986
|
/**
|
|
@@ -1952,7 +2005,7 @@ class Y extends N {
|
|
|
1952
2005
|
}));
|
|
1953
2006
|
}
|
|
1954
2007
|
}
|
|
1955
|
-
const
|
|
2008
|
+
const K = class K {
|
|
1956
2009
|
/**
|
|
1957
2010
|
* コンストラクタ。
|
|
1958
2011
|
*
|
|
@@ -1960,26 +2013,26 @@ const G = class G {
|
|
|
1960
2013
|
*/
|
|
1961
2014
|
constructor(t) {
|
|
1962
2015
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1963
|
-
const e = [...t.matchAll(
|
|
1964
|
-
let r = 0, i = !1,
|
|
1965
|
-
for (const
|
|
1966
|
-
|
|
1967
|
-
text: t.slice(r,
|
|
2016
|
+
const e = [...t.matchAll(K.PLACEHOLDER_REGEX)];
|
|
2017
|
+
let r = 0, i = !1, n = !1;
|
|
2018
|
+
for (const s of e) {
|
|
2019
|
+
s.index > r && this.contents.push({
|
|
2020
|
+
text: t.slice(r, s.index),
|
|
1968
2021
|
type: 0
|
|
1969
2022
|
/* TEXT */
|
|
1970
2023
|
});
|
|
1971
2024
|
const a = {
|
|
1972
|
-
text:
|
|
1973
|
-
type:
|
|
2025
|
+
text: s[1] ?? s[2],
|
|
2026
|
+
type: s[1] ? 2 : 1
|
|
1974
2027
|
/* EXPRESSION */
|
|
1975
2028
|
};
|
|
1976
|
-
i = !0,
|
|
2029
|
+
i = !0, n = n || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
|
|
1977
2030
|
}
|
|
1978
2031
|
r < t.length && this.contents.push({
|
|
1979
2032
|
text: t.slice(r),
|
|
1980
2033
|
type: 0
|
|
1981
2034
|
/* TEXT */
|
|
1982
|
-
}), this.isEvaluate = i, this.isRawEvaluate =
|
|
2035
|
+
}), this.isEvaluate = i, this.isRawEvaluate = n, this.checkRawExpressions();
|
|
1983
2036
|
}
|
|
1984
2037
|
/**
|
|
1985
2038
|
* 評価結果を結合して文字列にします。
|
|
@@ -2003,7 +2056,7 @@ const G = class G {
|
|
|
2003
2056
|
*/
|
|
2004
2057
|
checkRawExpressions() {
|
|
2005
2058
|
for (let t = 0; t < this.contents.length; t++)
|
|
2006
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
2059
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (d.error(
|
|
2007
2060
|
"[Haori]",
|
|
2008
2061
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2009
2062
|
), this.contents[t].type = 1);
|
|
@@ -2026,7 +2079,7 @@ const G = class G {
|
|
|
2026
2079
|
} else
|
|
2027
2080
|
e.push(r.text);
|
|
2028
2081
|
} catch (i) {
|
|
2029
|
-
|
|
2082
|
+
d.error(
|
|
2030
2083
|
"[Haori]",
|
|
2031
2084
|
`Error evaluating text expression: ${r.text}`,
|
|
2032
2085
|
i
|
|
@@ -2035,9 +2088,9 @@ const G = class G {
|
|
|
2035
2088
|
}), e;
|
|
2036
2089
|
}
|
|
2037
2090
|
};
|
|
2038
|
-
|
|
2039
|
-
let
|
|
2040
|
-
const
|
|
2091
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2092
|
+
let L = K;
|
|
2093
|
+
const G = class G extends L {
|
|
2041
2094
|
/**
|
|
2042
2095
|
* コンストラクタ。
|
|
2043
2096
|
*
|
|
@@ -2045,7 +2098,7 @@ const K = class K extends I {
|
|
|
2045
2098
|
* @param text 属性値
|
|
2046
2099
|
*/
|
|
2047
2100
|
constructor(t, e) {
|
|
2048
|
-
super(e), this.forceEvaluation =
|
|
2101
|
+
super(e), this.forceEvaluation = G.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2049
2102
|
}
|
|
2050
2103
|
/**
|
|
2051
2104
|
* 強制評価フラグを取得します。
|
|
@@ -2073,27 +2126,27 @@ const K = class K extends I {
|
|
|
2073
2126
|
} else
|
|
2074
2127
|
e.push(r.text);
|
|
2075
2128
|
} catch (i) {
|
|
2076
|
-
|
|
2129
|
+
d.error(
|
|
2077
2130
|
"[Haori]",
|
|
2078
2131
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2079
2132
|
i
|
|
2080
2133
|
), e.push("");
|
|
2081
2134
|
}
|
|
2082
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
2135
|
+
}), this.forceEvaluation && e.length > 1 ? (d.error(
|
|
2083
2136
|
"[Haori]",
|
|
2084
2137
|
"each or if expressions must have a single content.",
|
|
2085
2138
|
e
|
|
2086
2139
|
), [e[0]]) : e;
|
|
2087
2140
|
}
|
|
2088
2141
|
};
|
|
2089
|
-
|
|
2142
|
+
G.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2090
2143
|
"data-if",
|
|
2091
2144
|
"hor-if",
|
|
2092
2145
|
"data-each",
|
|
2093
2146
|
"hor-each"
|
|
2094
2147
|
];
|
|
2095
|
-
let U =
|
|
2096
|
-
class
|
|
2148
|
+
let U = G;
|
|
2149
|
+
class w {
|
|
2097
2150
|
/**
|
|
2098
2151
|
* カスタムイベントを発火します。
|
|
2099
2152
|
*
|
|
@@ -2103,13 +2156,13 @@ class v {
|
|
|
2103
2156
|
* @param options イベントオプション
|
|
2104
2157
|
*/
|
|
2105
2158
|
static dispatch(t, e, r, i) {
|
|
2106
|
-
const
|
|
2159
|
+
const n = new CustomEvent(`haori:${e}`, {
|
|
2107
2160
|
bubbles: i?.bubbles ?? !0,
|
|
2108
2161
|
cancelable: i?.cancelable ?? !1,
|
|
2109
2162
|
composed: i?.composed ?? !0,
|
|
2110
2163
|
detail: r
|
|
2111
2164
|
});
|
|
2112
|
-
return t.dispatchEvent(
|
|
2165
|
+
return t.dispatchEvent(n);
|
|
2113
2166
|
}
|
|
2114
2167
|
/**
|
|
2115
2168
|
* readyイベントを発火します。
|
|
@@ -2117,7 +2170,7 @@ class v {
|
|
|
2117
2170
|
* @param version ライブラリバージョン
|
|
2118
2171
|
*/
|
|
2119
2172
|
static ready(t) {
|
|
2120
|
-
|
|
2173
|
+
w.dispatch(document, "ready", { version: t });
|
|
2121
2174
|
}
|
|
2122
2175
|
/**
|
|
2123
2176
|
* renderイベントを発火します。
|
|
@@ -2125,7 +2178,7 @@ class v {
|
|
|
2125
2178
|
* @param target 評価対象要素
|
|
2126
2179
|
*/
|
|
2127
2180
|
static render(t) {
|
|
2128
|
-
|
|
2181
|
+
w.dispatch(t, "render", { target: t });
|
|
2129
2182
|
}
|
|
2130
2183
|
/**
|
|
2131
2184
|
* importstartイベントを発火します。
|
|
@@ -2134,7 +2187,7 @@ class v {
|
|
|
2134
2187
|
* @param url インポート対象URL
|
|
2135
2188
|
*/
|
|
2136
2189
|
static importStart(t, e) {
|
|
2137
|
-
|
|
2190
|
+
w.dispatch(t, "importstart", {
|
|
2138
2191
|
url: e,
|
|
2139
2192
|
startedAt: performance.now()
|
|
2140
2193
|
});
|
|
@@ -2148,7 +2201,7 @@ class v {
|
|
|
2148
2201
|
* @param startedAt 開始時刻
|
|
2149
2202
|
*/
|
|
2150
2203
|
static importEnd(t, e, r, i) {
|
|
2151
|
-
|
|
2204
|
+
w.dispatch(t, "importend", {
|
|
2152
2205
|
url: e,
|
|
2153
2206
|
bytes: r,
|
|
2154
2207
|
durationMs: performance.now() - i
|
|
@@ -2162,7 +2215,7 @@ class v {
|
|
|
2162
2215
|
* @param error エラー内容
|
|
2163
2216
|
*/
|
|
2164
2217
|
static importError(t, e, r) {
|
|
2165
|
-
|
|
2218
|
+
w.dispatch(t, "importerror", { url: e, error: r });
|
|
2166
2219
|
}
|
|
2167
2220
|
/**
|
|
2168
2221
|
* bindchangeイベントを発火します。
|
|
@@ -2173,15 +2226,15 @@ class v {
|
|
|
2173
2226
|
* @param reason 変更理由
|
|
2174
2227
|
*/
|
|
2175
2228
|
static bindChange(t, e, r, i = "other") {
|
|
2176
|
-
const
|
|
2177
|
-
for (const
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2229
|
+
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2230
|
+
for (const u of o) {
|
|
2231
|
+
const m = e?.[u], y = r[u];
|
|
2232
|
+
m !== y && n.push(u);
|
|
2180
2233
|
}
|
|
2181
|
-
|
|
2234
|
+
w.dispatch(t, "bindchange", {
|
|
2182
2235
|
previous: e || {},
|
|
2183
2236
|
next: r,
|
|
2184
|
-
changedKeys:
|
|
2237
|
+
changedKeys: n,
|
|
2185
2238
|
reason: i
|
|
2186
2239
|
});
|
|
2187
2240
|
}
|
|
@@ -2194,7 +2247,7 @@ class v {
|
|
|
2194
2247
|
* @param order 現在の順序
|
|
2195
2248
|
*/
|
|
2196
2249
|
static eachUpdate(t, e, r, i) {
|
|
2197
|
-
|
|
2250
|
+
w.dispatch(t, "eachupdate", {
|
|
2198
2251
|
added: e,
|
|
2199
2252
|
removed: r,
|
|
2200
2253
|
order: i,
|
|
@@ -2210,7 +2263,7 @@ class v {
|
|
|
2210
2263
|
* @param item 行データ
|
|
2211
2264
|
*/
|
|
2212
2265
|
static rowAdd(t, e, r, i) {
|
|
2213
|
-
|
|
2266
|
+
w.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2214
2267
|
}
|
|
2215
2268
|
/**
|
|
2216
2269
|
* rowremoveイベントを発火します。
|
|
@@ -2220,7 +2273,7 @@ class v {
|
|
|
2220
2273
|
* @param index インデックス
|
|
2221
2274
|
*/
|
|
2222
2275
|
static rowRemove(t, e, r) {
|
|
2223
|
-
|
|
2276
|
+
w.dispatch(t, "rowremove", { key: e, index: r });
|
|
2224
2277
|
}
|
|
2225
2278
|
/**
|
|
2226
2279
|
* rowmoveイベントを発火します。
|
|
@@ -2231,7 +2284,7 @@ class v {
|
|
|
2231
2284
|
* @param to 移動後インデックス
|
|
2232
2285
|
*/
|
|
2233
2286
|
static rowMove(t, e, r, i) {
|
|
2234
|
-
|
|
2287
|
+
w.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2235
2288
|
}
|
|
2236
2289
|
/**
|
|
2237
2290
|
* showイベントを発火します。
|
|
@@ -2239,7 +2292,7 @@ class v {
|
|
|
2239
2292
|
* @param target data-if要素
|
|
2240
2293
|
*/
|
|
2241
2294
|
static show(t) {
|
|
2242
|
-
|
|
2295
|
+
w.dispatch(t, "show", { visible: !0 });
|
|
2243
2296
|
}
|
|
2244
2297
|
/**
|
|
2245
2298
|
* hideイベントを発火します。
|
|
@@ -2247,7 +2300,7 @@ class v {
|
|
|
2247
2300
|
* @param target data-if要素
|
|
2248
2301
|
*/
|
|
2249
2302
|
static hide(t) {
|
|
2250
|
-
|
|
2303
|
+
w.dispatch(t, "hide", { visible: !1 });
|
|
2251
2304
|
}
|
|
2252
2305
|
/**
|
|
2253
2306
|
* fetchstartイベントを発火します。
|
|
@@ -2259,13 +2312,13 @@ class v {
|
|
|
2259
2312
|
* @param metadata runtime とメソッド変換情報。
|
|
2260
2313
|
* @return 戻り値はありません。
|
|
2261
2314
|
*/
|
|
2262
|
-
static fetchStart(t, e, r, i,
|
|
2263
|
-
|
|
2315
|
+
static fetchStart(t, e, r, i, n) {
|
|
2316
|
+
w.dispatch(t, "fetchstart", {
|
|
2264
2317
|
url: e,
|
|
2265
2318
|
options: r || {},
|
|
2266
2319
|
payload: i,
|
|
2267
2320
|
startedAt: performance.now(),
|
|
2268
|
-
...
|
|
2321
|
+
...n
|
|
2269
2322
|
});
|
|
2270
2323
|
}
|
|
2271
2324
|
/**
|
|
@@ -2277,7 +2330,7 @@ class v {
|
|
|
2277
2330
|
* @param startedAt 開始時刻
|
|
2278
2331
|
*/
|
|
2279
2332
|
static fetchEnd(t, e, r, i) {
|
|
2280
|
-
|
|
2333
|
+
w.dispatch(t, "fetchend", {
|
|
2281
2334
|
url: e,
|
|
2282
2335
|
status: r,
|
|
2283
2336
|
durationMs: performance.now() - i
|
|
@@ -2292,44 +2345,44 @@ class v {
|
|
|
2292
2345
|
* @param status HTTPステータス(存在する場合)
|
|
2293
2346
|
* @param startedAt 開始時刻(存在する場合)
|
|
2294
2347
|
*/
|
|
2295
|
-
static fetchError(t, e, r, i,
|
|
2296
|
-
|
|
2348
|
+
static fetchError(t, e, r, i, n) {
|
|
2349
|
+
w.dispatch(t, "fetcherror", {
|
|
2297
2350
|
url: e,
|
|
2298
2351
|
status: i,
|
|
2299
2352
|
error: r,
|
|
2300
|
-
durationMs:
|
|
2353
|
+
durationMs: n ? performance.now() - n : void 0
|
|
2301
2354
|
});
|
|
2302
2355
|
}
|
|
2303
2356
|
}
|
|
2304
|
-
const
|
|
2357
|
+
const at = [
|
|
2305
2358
|
"addErrorMessage",
|
|
2306
2359
|
"closeDialog",
|
|
2307
2360
|
"confirm",
|
|
2308
2361
|
"dialog",
|
|
2309
2362
|
"openDialog",
|
|
2310
2363
|
"toast"
|
|
2311
|
-
];
|
|
2312
|
-
function
|
|
2364
|
+
], ot = "__haoriHistoryState__";
|
|
2365
|
+
function Y() {
|
|
2313
2366
|
const t = globalThis.window?.Haori;
|
|
2314
|
-
return
|
|
2367
|
+
return at.every(
|
|
2315
2368
|
(r) => typeof t?.[r] == "function"
|
|
2316
|
-
) ? t :
|
|
2369
|
+
) ? t : J;
|
|
2317
2370
|
}
|
|
2318
|
-
const
|
|
2319
|
-
function
|
|
2320
|
-
return
|
|
2371
|
+
const lt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2372
|
+
function ct(F) {
|
|
2373
|
+
return lt.has(F.toUpperCase());
|
|
2321
2374
|
}
|
|
2322
|
-
function
|
|
2375
|
+
function ut(F, t) {
|
|
2323
2376
|
for (const [e, r] of Object.entries(t))
|
|
2324
2377
|
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2325
2378
|
F.append(e, String(i));
|
|
2326
2379
|
}) : typeof r == "object" || typeof r == "function" ? F.append(e, JSON.stringify(r)) : F.append(e, String(r)));
|
|
2327
2380
|
}
|
|
2328
|
-
function
|
|
2381
|
+
function ht(F, t) {
|
|
2329
2382
|
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2330
|
-
return
|
|
2383
|
+
return ut(r, t), e.search = r.toString(), e.toString();
|
|
2331
2384
|
}
|
|
2332
|
-
const
|
|
2385
|
+
const l = class l {
|
|
2333
2386
|
/**
|
|
2334
2387
|
* イベント属性名を正しく生成します。
|
|
2335
2388
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2349,13 +2402,13 @@ const u = class u {
|
|
|
2349
2402
|
*/
|
|
2350
2403
|
static resolveDataParamString(t, e) {
|
|
2351
2404
|
return t.replace(
|
|
2352
|
-
|
|
2353
|
-
(r, i,
|
|
2354
|
-
const
|
|
2355
|
-
i ??
|
|
2405
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2406
|
+
(r, i, n) => {
|
|
2407
|
+
const s = j.evaluate(
|
|
2408
|
+
i ?? n ?? "",
|
|
2356
2409
|
e
|
|
2357
2410
|
);
|
|
2358
|
-
return
|
|
2411
|
+
return s == null || Number.isNaN(s) ? "" : encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s));
|
|
2359
2412
|
}
|
|
2360
2413
|
);
|
|
2361
2414
|
}
|
|
@@ -2368,17 +2421,17 @@ const u = class u {
|
|
|
2368
2421
|
*/
|
|
2369
2422
|
static isJsonStringContext(t, e) {
|
|
2370
2423
|
let r = !1, i = !1;
|
|
2371
|
-
for (let
|
|
2372
|
-
const
|
|
2424
|
+
for (let n = 0; n < e; n += 1) {
|
|
2425
|
+
const s = t[n];
|
|
2373
2426
|
if (i) {
|
|
2374
2427
|
i = !1;
|
|
2375
2428
|
continue;
|
|
2376
2429
|
}
|
|
2377
|
-
if (
|
|
2430
|
+
if (s === "\\") {
|
|
2378
2431
|
i = !0;
|
|
2379
2432
|
continue;
|
|
2380
2433
|
}
|
|
2381
|
-
|
|
2434
|
+
s === '"' && (r = !r);
|
|
2382
2435
|
}
|
|
2383
2436
|
return r;
|
|
2384
2437
|
}
|
|
@@ -2406,7 +2459,7 @@ const u = class u {
|
|
|
2406
2459
|
static stringifyJsonTemplateStringContent(t) {
|
|
2407
2460
|
if (t == null || Number.isNaN(t))
|
|
2408
2461
|
return "";
|
|
2409
|
-
const e = typeof t == "object" ?
|
|
2462
|
+
const e = typeof t == "object" ? l.stringifyJsonTemplateValue(t) : String(t);
|
|
2410
2463
|
return JSON.stringify(e).slice(1, -1);
|
|
2411
2464
|
}
|
|
2412
2465
|
/**
|
|
@@ -2418,13 +2471,13 @@ const u = class u {
|
|
|
2418
2471
|
*/
|
|
2419
2472
|
static resolveDataJsonString(t, e) {
|
|
2420
2473
|
return t.replace(
|
|
2421
|
-
|
|
2422
|
-
(r, i,
|
|
2474
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2475
|
+
(r, i, n, s) => {
|
|
2423
2476
|
const a = j.evaluate(
|
|
2424
|
-
i ??
|
|
2477
|
+
i ?? n ?? "",
|
|
2425
2478
|
e
|
|
2426
2479
|
);
|
|
2427
|
-
return
|
|
2480
|
+
return l.isJsonStringContext(t, s) ? l.stringifyJsonTemplateStringContent(a) : l.stringifyJsonTemplateValue(a);
|
|
2428
2481
|
}
|
|
2429
2482
|
);
|
|
2430
2483
|
}
|
|
@@ -2441,14 +2494,14 @@ const u = class u {
|
|
|
2441
2494
|
return i;
|
|
2442
2495
|
if (typeof i != "string" || r === null)
|
|
2443
2496
|
return null;
|
|
2444
|
-
const
|
|
2445
|
-
return
|
|
2446
|
-
|
|
2497
|
+
const n = r.trim();
|
|
2498
|
+
return l.SINGLE_PLACEHOLDER_REGEX.test(n) ? R.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? R.parseDataBind(
|
|
2499
|
+
l.resolveDataJsonString(
|
|
2447
2500
|
r,
|
|
2448
2501
|
t.getBindingData()
|
|
2449
2502
|
)
|
|
2450
|
-
) :
|
|
2451
|
-
|
|
2503
|
+
) : R.parseDataBind(
|
|
2504
|
+
l.resolveDataParamString(r, t.getBindingData())
|
|
2452
2505
|
);
|
|
2453
2506
|
}
|
|
2454
2507
|
/**
|
|
@@ -2463,28 +2516,29 @@ const u = class u {
|
|
|
2463
2516
|
targetFragment: t
|
|
2464
2517
|
};
|
|
2465
2518
|
if (e) {
|
|
2466
|
-
if (t.hasAttribute(
|
|
2467
|
-
|
|
2468
|
-
)
|
|
2519
|
+
if (t.hasAttribute(l.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(l.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2520
|
+
l.attrName(e, "confirm")
|
|
2521
|
+
).replace(/\\n/g, `
|
|
2522
|
+
`)), t.hasAttribute(l.attrName(e, "data")) && (r.data = l.resolveDataAttribute(
|
|
2469
2523
|
t,
|
|
2470
|
-
|
|
2471
|
-
)), t.hasAttribute(
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2524
|
+
l.attrName(e, "data")
|
|
2525
|
+
)), t.hasAttribute(l.attrName(e, "form"))) {
|
|
2526
|
+
const h = t.getRawAttribute(
|
|
2527
|
+
l.attrName(e, "form")
|
|
2474
2528
|
);
|
|
2475
|
-
if (
|
|
2476
|
-
const f = document.body.querySelector(
|
|
2477
|
-
f !== null ? r.formFragment =
|
|
2478
|
-
|
|
2479
|
-
) :
|
|
2529
|
+
if (h) {
|
|
2530
|
+
const f = document.body.querySelector(h);
|
|
2531
|
+
f !== null ? r.formFragment = b.getFormFragment(
|
|
2532
|
+
T.get(f)
|
|
2533
|
+
) : d.error(
|
|
2480
2534
|
"Haori",
|
|
2481
|
-
`Form element not found: ${
|
|
2535
|
+
`Form element not found: ${h} (${l.attrName(e, "form")})`
|
|
2482
2536
|
);
|
|
2483
2537
|
} else
|
|
2484
|
-
r.formFragment =
|
|
2485
|
-
} else e === "change" && (r.formFragment =
|
|
2538
|
+
r.formFragment = b.getFormFragment(t);
|
|
2539
|
+
} else e === "change" && (r.formFragment = b.getFormFragment(t));
|
|
2486
2540
|
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
2487
|
-
const
|
|
2541
|
+
const h = t.getRawAttribute(
|
|
2488
2542
|
`${c.prefix}${e}-before-run`
|
|
2489
2543
|
);
|
|
2490
2544
|
try {
|
|
@@ -2493,166 +2547,166 @@ const u = class u {
|
|
|
2493
2547
|
"fetchOptions",
|
|
2494
2548
|
`
|
|
2495
2549
|
"use strict";
|
|
2496
|
-
${
|
|
2550
|
+
${h}
|
|
2497
2551
|
`
|
|
2498
2552
|
);
|
|
2499
2553
|
} catch (f) {
|
|
2500
|
-
|
|
2554
|
+
d.error("Haori", `Invalid before script: ${f}`);
|
|
2501
2555
|
}
|
|
2502
2556
|
}
|
|
2503
2557
|
}
|
|
2504
|
-
const i =
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2558
|
+
const i = l.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2559
|
+
n && (r.fetchUrl = t.getAttribute(i));
|
|
2560
|
+
const s = {};
|
|
2507
2561
|
if (e) {
|
|
2508
|
-
const
|
|
2509
|
-
t.hasAttribute(
|
|
2510
|
-
|
|
2562
|
+
const h = l.attrName(e, "fetch-method");
|
|
2563
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2564
|
+
h
|
|
2511
2565
|
));
|
|
2512
2566
|
} else {
|
|
2513
|
-
const
|
|
2514
|
-
t.hasAttribute(
|
|
2515
|
-
|
|
2567
|
+
const h = l.attrName(null, "method", !0);
|
|
2568
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2569
|
+
h
|
|
2516
2570
|
));
|
|
2517
2571
|
}
|
|
2518
2572
|
if (e) {
|
|
2519
|
-
const
|
|
2520
|
-
if (t.hasAttribute(
|
|
2573
|
+
const h = l.attrName(e, "fetch-headers");
|
|
2574
|
+
if (t.hasAttribute(h)) {
|
|
2521
2575
|
const f = t.getRawAttribute(
|
|
2522
|
-
|
|
2576
|
+
h
|
|
2523
2577
|
);
|
|
2524
2578
|
try {
|
|
2525
|
-
|
|
2526
|
-
} catch (
|
|
2527
|
-
|
|
2579
|
+
s.headers = R.parseDataBind(f);
|
|
2580
|
+
} catch (g) {
|
|
2581
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2528
2582
|
}
|
|
2529
2583
|
}
|
|
2530
2584
|
} else {
|
|
2531
|
-
const
|
|
2585
|
+
const h = l.attrName(
|
|
2532
2586
|
null,
|
|
2533
2587
|
"headers",
|
|
2534
2588
|
!0
|
|
2535
2589
|
);
|
|
2536
|
-
if (t.hasAttribute(
|
|
2590
|
+
if (t.hasAttribute(h)) {
|
|
2537
2591
|
const f = t.getRawAttribute(
|
|
2538
|
-
|
|
2592
|
+
h
|
|
2539
2593
|
);
|
|
2540
2594
|
try {
|
|
2541
|
-
|
|
2542
|
-
} catch (
|
|
2543
|
-
|
|
2595
|
+
s.headers = R.parseDataBind(f);
|
|
2596
|
+
} catch (g) {
|
|
2597
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2544
2598
|
}
|
|
2545
2599
|
}
|
|
2546
2600
|
}
|
|
2547
2601
|
if (e) {
|
|
2548
|
-
const
|
|
2602
|
+
const h = l.attrName(
|
|
2549
2603
|
e,
|
|
2550
2604
|
"fetch-content-type"
|
|
2551
2605
|
);
|
|
2552
|
-
if (t.hasAttribute(
|
|
2553
|
-
|
|
2554
|
-
...
|
|
2555
|
-
"Content-Type": t.getAttribute(
|
|
2606
|
+
if (t.hasAttribute(h))
|
|
2607
|
+
s.headers = {
|
|
2608
|
+
...s.headers,
|
|
2609
|
+
"Content-Type": t.getAttribute(h)
|
|
2556
2610
|
};
|
|
2557
|
-
else if (
|
|
2611
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2558
2612
|
let f = !1;
|
|
2559
|
-
|
|
2560
|
-
...
|
|
2613
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2614
|
+
...s.headers,
|
|
2561
2615
|
"Content-Type": "application/json"
|
|
2562
2616
|
});
|
|
2563
|
-
} else
|
|
2564
|
-
...
|
|
2617
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2618
|
+
...s.headers,
|
|
2565
2619
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2566
2620
|
});
|
|
2567
2621
|
} else {
|
|
2568
|
-
const
|
|
2622
|
+
const h = l.attrName(
|
|
2569
2623
|
null,
|
|
2570
2624
|
"content-type",
|
|
2571
2625
|
!0
|
|
2572
2626
|
);
|
|
2573
|
-
if (t.hasAttribute(
|
|
2574
|
-
|
|
2575
|
-
...
|
|
2576
|
-
"Content-Type": t.getAttribute(
|
|
2627
|
+
if (t.hasAttribute(h))
|
|
2628
|
+
s.headers = {
|
|
2629
|
+
...s.headers,
|
|
2630
|
+
"Content-Type": t.getAttribute(h)
|
|
2577
2631
|
};
|
|
2578
|
-
else if (
|
|
2632
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2579
2633
|
let f = !1;
|
|
2580
|
-
|
|
2581
|
-
...
|
|
2634
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2635
|
+
...s.headers,
|
|
2582
2636
|
"Content-Type": "application/json"
|
|
2583
2637
|
});
|
|
2584
|
-
} else
|
|
2585
|
-
...
|
|
2638
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2639
|
+
...s.headers,
|
|
2586
2640
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2587
2641
|
});
|
|
2588
2642
|
}
|
|
2589
|
-
Object.keys(
|
|
2590
|
-
const a = e ?
|
|
2643
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2644
|
+
const a = e ? l.attrName(e, "bind") : l.attrName(null, "bind", !0);
|
|
2591
2645
|
if (t.hasAttribute(a)) {
|
|
2592
|
-
const
|
|
2593
|
-
if (
|
|
2594
|
-
const f = document.body.querySelectorAll(
|
|
2595
|
-
f.length > 0 ? (r.bindFragments = [], f.forEach((
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
})) :
|
|
2646
|
+
const h = t.getRawAttribute(a);
|
|
2647
|
+
if (h) {
|
|
2648
|
+
const f = document.body.querySelectorAll(h);
|
|
2649
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((g) => {
|
|
2650
|
+
const A = T.get(g);
|
|
2651
|
+
A && r.bindFragments.push(A);
|
|
2652
|
+
})) : d.error(
|
|
2599
2653
|
"Haori",
|
|
2600
|
-
`Bind element not found: ${
|
|
2654
|
+
`Bind element not found: ${h} (${a})`
|
|
2601
2655
|
);
|
|
2602
2656
|
}
|
|
2603
2657
|
}
|
|
2604
|
-
const o =
|
|
2658
|
+
const o = l.attrName(e, "bind-arg"), u = l.attrName(
|
|
2605
2659
|
null,
|
|
2606
2660
|
"arg",
|
|
2607
2661
|
!0
|
|
2608
|
-
),
|
|
2662
|
+
), m = l.attrName(
|
|
2609
2663
|
null,
|
|
2610
2664
|
"bind-arg",
|
|
2611
2665
|
!0
|
|
2612
2666
|
);
|
|
2613
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2614
|
-
|
|
2615
|
-
) : t.hasAttribute(
|
|
2616
|
-
const
|
|
2617
|
-
if (t.hasAttribute(
|
|
2618
|
-
const
|
|
2619
|
-
r.bindParams =
|
|
2667
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(u) ? r.bindArg = t.getRawAttribute(
|
|
2668
|
+
u
|
|
2669
|
+
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2670
|
+
const y = e ? l.attrName(e, "bind-params") : l.attrName(null, "bind-params", !0);
|
|
2671
|
+
if (t.hasAttribute(y)) {
|
|
2672
|
+
const h = t.getRawAttribute(y);
|
|
2673
|
+
r.bindParams = h.split("&").map((f) => f.trim());
|
|
2620
2674
|
}
|
|
2621
|
-
const
|
|
2622
|
-
if (t.hasAttribute(
|
|
2623
|
-
const
|
|
2624
|
-
r.bindAppendParams =
|
|
2675
|
+
const E = e ? l.attrName(e, "bind-append") : l.attrName(null, "bind-append", !0);
|
|
2676
|
+
if (t.hasAttribute(E)) {
|
|
2677
|
+
const h = t.getRawAttribute(E);
|
|
2678
|
+
r.bindAppendParams = h.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2625
2679
|
}
|
|
2626
|
-
const S = e ?
|
|
2680
|
+
const S = e ? l.attrName(e, "copy-params") : null;
|
|
2627
2681
|
if (S && t.hasAttribute(S)) {
|
|
2628
|
-
const
|
|
2682
|
+
const h = t.getRawAttribute(
|
|
2629
2683
|
S
|
|
2630
2684
|
);
|
|
2631
|
-
r.copyParams =
|
|
2685
|
+
r.copyParams = h.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2632
2686
|
}
|
|
2633
2687
|
if (e) {
|
|
2634
|
-
if (t.hasAttribute(
|
|
2688
|
+
if (t.hasAttribute(l.attrName(e, "adjust"))) {
|
|
2635
2689
|
const f = t.getRawAttribute(
|
|
2636
|
-
|
|
2690
|
+
l.attrName(e, "adjust")
|
|
2637
2691
|
);
|
|
2638
2692
|
if (f) {
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
const
|
|
2642
|
-
|
|
2643
|
-
})) :
|
|
2693
|
+
const g = document.body.querySelectorAll(f);
|
|
2694
|
+
g.length > 0 ? (r.adjustFragments = [], g.forEach((A) => {
|
|
2695
|
+
const v = T.get(A);
|
|
2696
|
+
v && r.adjustFragments.push(v);
|
|
2697
|
+
})) : d.error(
|
|
2644
2698
|
"Haori",
|
|
2645
|
-
`Adjust element not found: ${f} (${
|
|
2699
|
+
`Adjust element not found: ${f} (${l.attrName(e, "adjust")})`
|
|
2646
2700
|
);
|
|
2647
2701
|
}
|
|
2648
|
-
if (t.hasAttribute(
|
|
2649
|
-
const
|
|
2650
|
-
|
|
2651
|
-
),
|
|
2652
|
-
isNaN(
|
|
2702
|
+
if (t.hasAttribute(l.attrName(e, "adjust-value"))) {
|
|
2703
|
+
const g = t.getRawAttribute(
|
|
2704
|
+
l.attrName(e, "adjust-value")
|
|
2705
|
+
), A = Number(g);
|
|
2706
|
+
isNaN(A) || (r.adjustValue = A);
|
|
2653
2707
|
}
|
|
2654
2708
|
}
|
|
2655
|
-
if (t.hasAttribute(
|
|
2709
|
+
if (t.hasAttribute(l.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(l.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(l.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(l.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${c.prefix}${e}-after-run`)) {
|
|
2656
2710
|
const f = t.getRawAttribute(
|
|
2657
2711
|
`${c.prefix}${e}-after-run`
|
|
2658
2712
|
);
|
|
@@ -2664,35 +2718,45 @@ ${l}
|
|
|
2664
2718
|
${f}
|
|
2665
2719
|
`
|
|
2666
2720
|
);
|
|
2667
|
-
} catch (
|
|
2668
|
-
|
|
2721
|
+
} catch (g) {
|
|
2722
|
+
d.error("Haori", `Invalid after script: ${g}`);
|
|
2669
2723
|
}
|
|
2670
2724
|
}
|
|
2671
|
-
if (t.hasAttribute(
|
|
2672
|
-
|
|
2673
|
-
)
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2725
|
+
if (t.hasAttribute(l.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2726
|
+
l.attrName(e, "dialog")
|
|
2727
|
+
).replace(/\\n/g, `
|
|
2728
|
+
`)), t.hasAttribute(l.attrName(e, "toast"))) {
|
|
2729
|
+
r.toastMessage = t.getAttribute(
|
|
2730
|
+
l.attrName(e, "toast")
|
|
2731
|
+
);
|
|
2732
|
+
const f = t.getRawAttribute(
|
|
2733
|
+
l.attrName(e, "toast-level")
|
|
2734
|
+
), A = ["info", "warning", "error", "success"].includes(f);
|
|
2735
|
+
r.toastLevel = A ? f : null;
|
|
2736
|
+
}
|
|
2737
|
+
if (t.hasAttribute(l.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2738
|
+
l.attrName(e, "redirect")
|
|
2739
|
+
)), t.hasAttribute(l.attrName(e, "scroll-error")) && (r.scrollOnError = !0), t.hasAttribute(l.attrName(e, "scroll")) && (r.scrollTarget = t.getAttribute(
|
|
2740
|
+
l.attrName(e, "scroll")
|
|
2741
|
+
)), t.hasAttribute(l.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2742
|
+
l.attrName(e, "history")
|
|
2743
|
+
)), t.hasAttribute(l.attrName(e, "history-data")) && (r.historyData = l.resolveDataAttribute(
|
|
2680
2744
|
t,
|
|
2681
|
-
|
|
2682
|
-
)), t.hasAttribute(
|
|
2745
|
+
l.attrName(e, "history-data")
|
|
2746
|
+
)), t.hasAttribute(l.attrName(e, "history-form"))) {
|
|
2683
2747
|
const f = t.getRawAttribute(
|
|
2684
|
-
|
|
2748
|
+
l.attrName(e, "history-form")
|
|
2685
2749
|
);
|
|
2686
2750
|
if (f) {
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
) :
|
|
2751
|
+
const g = document.body.querySelector(f);
|
|
2752
|
+
g !== null ? r.historyFormFragment = b.getFormFragment(
|
|
2753
|
+
T.get(g)
|
|
2754
|
+
) : d.error(
|
|
2691
2755
|
"Haori",
|
|
2692
|
-
`Form element not found: ${f} (${
|
|
2756
|
+
`Form element not found: ${f} (${l.attrName(e, "history-form")})`
|
|
2693
2757
|
);
|
|
2694
2758
|
} else
|
|
2695
|
-
r.historyFormFragment =
|
|
2759
|
+
r.historyFormFragment = b.getFormFragment(t);
|
|
2696
2760
|
}
|
|
2697
2761
|
[
|
|
2698
2762
|
"reset",
|
|
@@ -2702,55 +2766,55 @@ ${f}
|
|
|
2702
2766
|
"open",
|
|
2703
2767
|
"close"
|
|
2704
2768
|
].forEach((f) => {
|
|
2705
|
-
const
|
|
2706
|
-
if (!t.hasAttribute(
|
|
2769
|
+
const g = l.attrName(e, f);
|
|
2770
|
+
if (!t.hasAttribute(g))
|
|
2707
2771
|
return;
|
|
2708
|
-
const
|
|
2709
|
-
if (
|
|
2710
|
-
const
|
|
2711
|
-
|
|
2712
|
-
}),
|
|
2772
|
+
const A = t.getRawAttribute(g), v = [];
|
|
2773
|
+
if (A ? (document.body.querySelectorAll(A).forEach((W) => {
|
|
2774
|
+
const tt = T.get(W);
|
|
2775
|
+
tt && v.push(tt);
|
|
2776
|
+
}), v.length === 0 && d.error("Haori", `Element not found: ${A} (${g})`)) : v.push(t), v.length > 0)
|
|
2713
2777
|
switch (f) {
|
|
2714
2778
|
case "reset":
|
|
2715
|
-
r.resetFragments =
|
|
2779
|
+
r.resetFragments = v;
|
|
2716
2780
|
break;
|
|
2717
2781
|
case "refetch":
|
|
2718
|
-
r.refetchFragments =
|
|
2782
|
+
r.refetchFragments = v;
|
|
2719
2783
|
break;
|
|
2720
2784
|
case "click":
|
|
2721
|
-
r.clickFragments =
|
|
2785
|
+
r.clickFragments = v;
|
|
2722
2786
|
break;
|
|
2723
2787
|
case "copy":
|
|
2724
|
-
r.copyFragments =
|
|
2788
|
+
r.copyFragments = v;
|
|
2725
2789
|
break;
|
|
2726
2790
|
case "open":
|
|
2727
|
-
r.openFragments =
|
|
2791
|
+
r.openFragments = v;
|
|
2728
2792
|
break;
|
|
2729
2793
|
case "close":
|
|
2730
|
-
r.closeFragments =
|
|
2794
|
+
r.closeFragments = v;
|
|
2731
2795
|
break;
|
|
2732
2796
|
}
|
|
2733
2797
|
});
|
|
2734
2798
|
}
|
|
2735
|
-
if (!e && (t.hasAttribute(
|
|
2799
|
+
if (!e && (t.hasAttribute(l.attrName(null, "data", !0)) && (r.data = l.resolveDataAttribute(
|
|
2736
2800
|
t,
|
|
2737
|
-
|
|
2738
|
-
)), t.hasAttribute(
|
|
2739
|
-
const
|
|
2740
|
-
|
|
2801
|
+
l.attrName(null, "data", !0)
|
|
2802
|
+
)), t.hasAttribute(l.attrName(null, "form", !0)))) {
|
|
2803
|
+
const h = t.getRawAttribute(
|
|
2804
|
+
l.attrName(null, "form", !0)
|
|
2741
2805
|
);
|
|
2742
|
-
if (
|
|
2743
|
-
const f = document.body.querySelector(
|
|
2744
|
-
f !== null ? r.formFragment =
|
|
2745
|
-
|
|
2746
|
-
) :
|
|
2806
|
+
if (h) {
|
|
2807
|
+
const f = document.body.querySelector(h);
|
|
2808
|
+
f !== null ? r.formFragment = b.getFormFragment(
|
|
2809
|
+
T.get(f)
|
|
2810
|
+
) : d.error(
|
|
2747
2811
|
"Haori",
|
|
2748
|
-
`Form element not found: ${
|
|
2812
|
+
`Form element not found: ${h} (${l.attrName(null, "fetch-form", !0)})`
|
|
2749
2813
|
);
|
|
2750
2814
|
} else
|
|
2751
|
-
r.formFragment =
|
|
2815
|
+
r.formFragment = b.getFormFragment(t);
|
|
2752
2816
|
}
|
|
2753
|
-
return
|
|
2817
|
+
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2754
2818
|
}
|
|
2755
2819
|
/**
|
|
2756
2820
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2771,7 +2835,7 @@ ${f}
|
|
|
2771
2835
|
* @param arg2 イベント名
|
|
2772
2836
|
*/
|
|
2773
2837
|
constructor(t, e = null) {
|
|
2774
|
-
|
|
2838
|
+
l.isElementFragment(t) ? this.options = l.buildOptions(t, e) : this.options = t;
|
|
2775
2839
|
}
|
|
2776
2840
|
/**
|
|
2777
2841
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2812,81 +2876,81 @@ ${f}
|
|
|
2812
2876
|
}
|
|
2813
2877
|
const i = {};
|
|
2814
2878
|
if (this.options.formFragment) {
|
|
2815
|
-
const o =
|
|
2879
|
+
const o = b.getValues(this.options.formFragment);
|
|
2816
2880
|
Object.assign(i, o);
|
|
2817
2881
|
}
|
|
2818
2882
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2819
|
-
const
|
|
2883
|
+
const n = Object.keys(i).length > 0;
|
|
2820
2884
|
if (e) {
|
|
2821
|
-
const o = { ...r || {} },
|
|
2885
|
+
const o = { ...r || {} }, u = new Headers(
|
|
2822
2886
|
o.headers || void 0
|
|
2823
|
-
),
|
|
2824
|
-
if (o.method =
|
|
2825
|
-
|
|
2826
|
-
else if (
|
|
2827
|
-
const
|
|
2828
|
-
if (/multipart\/form-data/i.test(
|
|
2829
|
-
|
|
2887
|
+
), m = (o.method || "GET").toUpperCase(), y = c.runtime === "demo" && !ct(m), E = y ? "GET" : m;
|
|
2888
|
+
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2889
|
+
n && (e = ht(e, i));
|
|
2890
|
+
else if (n) {
|
|
2891
|
+
const h = u.get("Content-Type") || "";
|
|
2892
|
+
if (/multipart\/form-data/i.test(h)) {
|
|
2893
|
+
u.delete("Content-Type");
|
|
2830
2894
|
const f = new FormData();
|
|
2831
|
-
for (const [
|
|
2832
|
-
|
|
2895
|
+
for (const [g, A] of Object.entries(i))
|
|
2896
|
+
A == null ? f.append(g, "") : A instanceof Blob ? f.append(g, A) : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A));
|
|
2833
2897
|
o.body = f;
|
|
2834
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2898
|
+
} else if (/application\/x-www-form-urlencoded/i.test(h)) {
|
|
2835
2899
|
const f = new URLSearchParams();
|
|
2836
|
-
for (const [
|
|
2837
|
-
|
|
2900
|
+
for (const [g, A] of Object.entries(i))
|
|
2901
|
+
A !== void 0 && (A === null ? f.append(g, "") : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A)));
|
|
2838
2902
|
o.body = f;
|
|
2839
2903
|
} else
|
|
2840
|
-
|
|
2904
|
+
u.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2841
2905
|
}
|
|
2842
|
-
o.headers =
|
|
2906
|
+
o.headers = u;
|
|
2843
2907
|
let S;
|
|
2844
|
-
if (
|
|
2908
|
+
if (y && (S = e && new URL(e, window.location.href).search || void 0, u.delete("Content-Type"), d.info("Haori demo fetch normalization", {
|
|
2845
2909
|
runtime: c.runtime,
|
|
2846
|
-
requestedMethod:
|
|
2847
|
-
effectiveMethod:
|
|
2910
|
+
requestedMethod: m,
|
|
2911
|
+
effectiveMethod: E,
|
|
2848
2912
|
transportMode: "query-get",
|
|
2849
2913
|
url: e,
|
|
2850
|
-
payload:
|
|
2914
|
+
payload: n ? i : void 0,
|
|
2851
2915
|
queryString: S
|
|
2852
2916
|
})), this.options.targetFragment && e) {
|
|
2853
|
-
const
|
|
2917
|
+
const h = performance.now(), f = {
|
|
2854
2918
|
runtime: c.runtime,
|
|
2855
|
-
requestedMethod:
|
|
2856
|
-
effectiveMethod:
|
|
2857
|
-
transportMode:
|
|
2858
|
-
...
|
|
2919
|
+
requestedMethod: m,
|
|
2920
|
+
effectiveMethod: E,
|
|
2921
|
+
transportMode: y ? "query-get" : "http",
|
|
2922
|
+
...y ? { queryString: S } : {}
|
|
2859
2923
|
};
|
|
2860
|
-
return
|
|
2924
|
+
return w.fetchStart(
|
|
2861
2925
|
this.options.targetFragment.getTarget(),
|
|
2862
2926
|
e,
|
|
2863
2927
|
o,
|
|
2864
|
-
|
|
2928
|
+
n ? i : void 0,
|
|
2865
2929
|
f
|
|
2866
|
-
), fetch(e, o).then((
|
|
2867
|
-
|
|
2930
|
+
), fetch(e, o).then((g) => this.handleFetchResult(
|
|
2931
|
+
g,
|
|
2868
2932
|
e || void 0,
|
|
2869
|
-
|
|
2870
|
-
)).catch((
|
|
2871
|
-
throw e &&
|
|
2933
|
+
h
|
|
2934
|
+
)).catch((g) => {
|
|
2935
|
+
throw e && w.fetchError(
|
|
2872
2936
|
this.options.targetFragment.getTarget(),
|
|
2873
2937
|
e,
|
|
2874
|
-
|
|
2875
|
-
),
|
|
2938
|
+
g
|
|
2939
|
+
), g;
|
|
2876
2940
|
});
|
|
2877
2941
|
}
|
|
2878
|
-
return fetch(e, o).then((
|
|
2942
|
+
return fetch(e, o).then((h) => this.handleFetchResult(h, e || void 0));
|
|
2879
2943
|
}
|
|
2880
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2881
|
-
const o = this.options.formFragment,
|
|
2882
|
-
|
|
2944
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && n) {
|
|
2945
|
+
const o = this.options.formFragment, u = o.getTarget();
|
|
2946
|
+
u.setAttribute(
|
|
2883
2947
|
`${c.prefix}bind`,
|
|
2884
2948
|
JSON.stringify(i)
|
|
2885
2949
|
);
|
|
2886
|
-
const
|
|
2887
|
-
Object.assign(
|
|
2950
|
+
const m = o.getBindingData();
|
|
2951
|
+
Object.assign(m, i), await R.setBindingData(u, m);
|
|
2888
2952
|
}
|
|
2889
|
-
const
|
|
2953
|
+
const s = n ? i : {}, a = new Response(JSON.stringify(s), {
|
|
2890
2954
|
headers: { "Content-Type": "application/json" }
|
|
2891
2955
|
});
|
|
2892
2956
|
return this.handleFetchResult(a);
|
|
@@ -2895,16 +2959,16 @@ ${f}
|
|
|
2895
2959
|
* フェッチ後の処理を実行します。
|
|
2896
2960
|
*/
|
|
2897
2961
|
async handleFetchResult(t, e, r) {
|
|
2898
|
-
const i =
|
|
2962
|
+
const i = Y();
|
|
2899
2963
|
if (!t.ok)
|
|
2900
|
-
return this.options.targetFragment && e &&
|
|
2964
|
+
return this.options.targetFragment && e && w.fetchError(
|
|
2901
2965
|
this.options.targetFragment.getTarget(),
|
|
2902
2966
|
e,
|
|
2903
2967
|
new Error(`${t.status} ${t.statusText}`),
|
|
2904
2968
|
t.status,
|
|
2905
2969
|
r
|
|
2906
2970
|
), await this.handleFetchError(t), !1;
|
|
2907
|
-
if (this.options.targetFragment && e && r &&
|
|
2971
|
+
if (this.options.targetFragment && e && r && w.fetchEnd(
|
|
2908
2972
|
this.options.targetFragment.getTarget(),
|
|
2909
2973
|
e,
|
|
2910
2974
|
t.status,
|
|
@@ -2917,13 +2981,13 @@ ${f}
|
|
|
2917
2981
|
typeof a == "object" && "response" in a && (t = "response" in a ? a.response : t);
|
|
2918
2982
|
}
|
|
2919
2983
|
}
|
|
2920
|
-
const s = [];
|
|
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
2984
|
const n = [];
|
|
2985
|
+
n.push(this.bindResult(t)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
2986
|
+
this.options.resetFragments.map((a) => b.reset(a))
|
|
2987
|
+
), await this.copy();
|
|
2988
|
+
const s = [];
|
|
2925
2989
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2926
|
-
|
|
2990
|
+
s.push(new l(a, null).run());
|
|
2927
2991
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2928
2992
|
const o = a.getTarget();
|
|
2929
2993
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -2931,11 +2995,14 @@ ${f}
|
|
|
2931
2995
|
);
|
|
2932
2996
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2933
2997
|
const o = a.getTarget();
|
|
2934
|
-
o instanceof HTMLElement ?
|
|
2998
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
2935
2999
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2936
3000
|
const o = a.getTarget();
|
|
2937
|
-
o instanceof HTMLElement ?
|
|
2938
|
-
}), await Promise.all(
|
|
3001
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
3002
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3003
|
+
this.options.toastMessage,
|
|
3004
|
+
this.options.toastLevel ?? "info"
|
|
3005
|
+
), this.pushHistory(), this.options.scrollTarget && document.querySelector(this.options.scrollTarget)?.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
2939
3006
|
}
|
|
2940
3007
|
/**
|
|
2941
3008
|
* history.pushState を実行します。
|
|
@@ -2948,26 +3015,30 @@ ${f}
|
|
|
2948
3015
|
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.options.historyData !== void 0 && this.options.historyData !== null, r = this.options.historyFormFragment !== void 0 && this.options.historyFormFragment !== null;
|
|
2949
3016
|
if (!(!t && !e && !r))
|
|
2950
3017
|
try {
|
|
2951
|
-
const i = t ? this.options.historyUrl : window.location.pathname,
|
|
2952
|
-
if (
|
|
2953
|
-
const a = "history.pushState: cross-origin URL is not allowed: " +
|
|
2954
|
-
|
|
3018
|
+
const i = t ? this.options.historyUrl : window.location.pathname, n = new URL(i, window.location.href);
|
|
3019
|
+
if (n.origin !== window.location.origin) {
|
|
3020
|
+
const a = "history.pushState: cross-origin URL is not allowed: " + n.toString();
|
|
3021
|
+
d.error(
|
|
2955
3022
|
"Haori",
|
|
2956
3023
|
a
|
|
2957
3024
|
);
|
|
2958
3025
|
return;
|
|
2959
3026
|
}
|
|
2960
|
-
const
|
|
2961
|
-
for (const [o,
|
|
2962
|
-
|
|
3027
|
+
const s = (a) => {
|
|
3028
|
+
for (const [o, u] of Object.entries(a))
|
|
3029
|
+
u != null && (Array.isArray(u) ? u.forEach((m) => n.searchParams.append(o, String(m))) : typeof u == "object" ? n.searchParams.set(o, JSON.stringify(u)) : n.searchParams.set(o, String(u)));
|
|
2963
3030
|
};
|
|
2964
|
-
e &&
|
|
2965
|
-
|
|
3031
|
+
e && s(this.options.historyData), r && s(
|
|
3032
|
+
b.getValues(
|
|
2966
3033
|
this.options.historyFormFragment
|
|
2967
3034
|
)
|
|
2968
|
-
), history.pushState(
|
|
3035
|
+
), history.pushState(
|
|
3036
|
+
{ [ot]: !0 },
|
|
3037
|
+
"",
|
|
3038
|
+
n.toString()
|
|
3039
|
+
);
|
|
2969
3040
|
} catch (i) {
|
|
2970
|
-
|
|
3041
|
+
d.error("Haori", `history.pushState failed: ${i}`);
|
|
2971
3042
|
}
|
|
2972
3043
|
}
|
|
2973
3044
|
/**
|
|
@@ -2975,32 +3046,37 @@ ${f}
|
|
|
2975
3046
|
*/
|
|
2976
3047
|
async handleFetchError(t) {
|
|
2977
3048
|
let e = null;
|
|
2978
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
3049
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = b.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2979
3050
|
const r = async (s) => {
|
|
2980
|
-
const
|
|
2981
|
-
await
|
|
3051
|
+
const a = e ? e.getTarget() : document.body;
|
|
3052
|
+
await Y().addErrorMessage(a, s);
|
|
3053
|
+
}, i = () => {
|
|
3054
|
+
if (!this.options.scrollOnError)
|
|
3055
|
+
return;
|
|
3056
|
+
const s = e ? e.getTarget() : document.body;
|
|
3057
|
+
(s.getAttribute("data-message-level") === "error" ? s : s.parentElement?.getAttribute("data-message-level") === "error" ? s.parentElement : s.querySelector('[data-message-level="error"]'))?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2982
3058
|
};
|
|
2983
3059
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2984
3060
|
try {
|
|
2985
|
-
const s = await t.json(),
|
|
3061
|
+
const s = await t.json(), a = [];
|
|
2986
3062
|
if (s && typeof s == "object") {
|
|
2987
|
-
if (typeof s.message == "string" &&
|
|
2988
|
-
for (const
|
|
2989
|
-
typeof
|
|
3063
|
+
if (typeof s.message == "string" && a.push({ message: s.message }), Array.isArray(s.messages))
|
|
3064
|
+
for (const o of s.messages)
|
|
3065
|
+
typeof o == "string" && a.push({ message: o });
|
|
2990
3066
|
if (s.errors && typeof s.errors == "object")
|
|
2991
|
-
for (const [
|
|
2992
|
-
Array.isArray(
|
|
2993
|
-
`) }) : typeof
|
|
2994
|
-
if (
|
|
2995
|
-
for (const [
|
|
2996
|
-
|
|
2997
|
-
`) }) : typeof
|
|
3067
|
+
for (const [o, u] of Object.entries(s.errors))
|
|
3068
|
+
Array.isArray(u) ? a.push({ key: o, message: u.join(`
|
|
3069
|
+
`) }) : typeof u == "string" ? a.push({ key: o, message: u }) : u != null && a.push({ key: o, message: String(u) });
|
|
3070
|
+
if (a.length === 0)
|
|
3071
|
+
for (const [o, u] of Object.entries(s))
|
|
3072
|
+
o === "message" || o === "messages" || o === "errors" || (Array.isArray(u) ? a.push({ key: o, message: u.join(`
|
|
3073
|
+
`) }) : typeof u == "string" && a.push({ key: o, message: u }));
|
|
2998
3074
|
}
|
|
2999
|
-
if (
|
|
3000
|
-
return await r(`${t.status} ${t.statusText}`), !1;
|
|
3001
|
-
for (const
|
|
3002
|
-
|
|
3003
|
-
return !1;
|
|
3075
|
+
if (a.length === 0)
|
|
3076
|
+
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3077
|
+
for (const o of a)
|
|
3078
|
+
o.key && e ? await b.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3079
|
+
return i(), !1;
|
|
3004
3080
|
} catch {
|
|
3005
3081
|
}
|
|
3006
3082
|
try {
|
|
@@ -3009,7 +3085,7 @@ ${f}
|
|
|
3009
3085
|
} catch {
|
|
3010
3086
|
await r(`${t.status} ${t.statusText}`);
|
|
3011
3087
|
}
|
|
3012
|
-
return !1;
|
|
3088
|
+
return i(), !1;
|
|
3013
3089
|
}
|
|
3014
3090
|
/**
|
|
3015
3091
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -3021,21 +3097,34 @@ ${f}
|
|
|
3021
3097
|
validate(t) {
|
|
3022
3098
|
if (this.options.valid !== !0)
|
|
3023
3099
|
return !0;
|
|
3024
|
-
const e =
|
|
3025
|
-
|
|
3026
|
-
return r || e.focus(), t.getChildElementFragments().reverse().forEach((i) => {
|
|
3027
|
-
r &&= this.validate(i);
|
|
3028
|
-
}), r;
|
|
3100
|
+
const e = this.findFirstInvalid(t);
|
|
3101
|
+
return e === null ? !0 : (e.reportValidity(), e.focus(), this.options.scrollOnError && e.scrollIntoView({ behavior: "smooth", block: "nearest" }), !1);
|
|
3029
3102
|
}
|
|
3030
3103
|
/**
|
|
3031
|
-
*
|
|
3104
|
+
* 対象フラグメント以下で DOM 順の最上部にある invalid 要素を返します。
|
|
3105
|
+
* 副作用のない checkValidity のみを使用し、検出のみを行います。
|
|
3032
3106
|
*
|
|
3033
3107
|
* @param fragment 対象のフラグメント
|
|
3034
|
-
* @returns
|
|
3108
|
+
* @returns 最初の invalid 要素、なければ null
|
|
3035
3109
|
*/
|
|
3036
|
-
|
|
3110
|
+
findFirstInvalid(t) {
|
|
3111
|
+
let e = null;
|
|
3112
|
+
for (const r of t.getChildElementFragments().reverse()) {
|
|
3113
|
+
const i = this.findFirstInvalid(r);
|
|
3114
|
+
i !== null && (e = i);
|
|
3115
|
+
}
|
|
3116
|
+
return this.checkOne(t) ? e : t.getTarget();
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* 対象のフラグメントに対して、副作用なく有効性を検査します。
|
|
3120
|
+
* reportValidity は使わず checkValidity のみ呼び出します。
|
|
3121
|
+
*
|
|
3122
|
+
* @param fragment 対象のフラグメント
|
|
3123
|
+
* @returns 有効なら true、無効なら false
|
|
3124
|
+
*/
|
|
3125
|
+
checkOne(t) {
|
|
3037
3126
|
const e = t.getTarget();
|
|
3038
|
-
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.
|
|
3127
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.checkValidity() : !0;
|
|
3039
3128
|
}
|
|
3040
3129
|
/**
|
|
3041
3130
|
* 確認メッセージを表示し、ユーザーの確認を求めます。
|
|
@@ -3045,7 +3134,7 @@ ${f}
|
|
|
3045
3134
|
*/
|
|
3046
3135
|
confirm() {
|
|
3047
3136
|
const t = this.options.confirmMessage;
|
|
3048
|
-
return t == null ? Promise.resolve(!0) :
|
|
3137
|
+
return t == null ? Promise.resolve(!0) : Y().confirm(t);
|
|
3049
3138
|
}
|
|
3050
3139
|
/**
|
|
3051
3140
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3055,40 +3144,40 @@ ${f}
|
|
|
3055
3144
|
bindResult(t) {
|
|
3056
3145
|
return !this.options.bindFragments || this.options.bindFragments.length === 0 ? Promise.resolve() : (t.headers.get("Content-Type")?.includes("application/json") ? t.json() : t.text()).then((r) => {
|
|
3057
3146
|
if (this.options.bindParams) {
|
|
3058
|
-
const
|
|
3059
|
-
this.options.bindParams.forEach((
|
|
3060
|
-
r && typeof r == "object" &&
|
|
3061
|
-
}), r =
|
|
3147
|
+
const n = {};
|
|
3148
|
+
this.options.bindParams.forEach((s) => {
|
|
3149
|
+
r && typeof r == "object" && s in r && (n[s] = r[s]);
|
|
3150
|
+
}), r = n;
|
|
3062
3151
|
}
|
|
3063
3152
|
const i = [];
|
|
3064
3153
|
if (this.options.bindArg)
|
|
3065
|
-
this.options.bindFragments.forEach((
|
|
3066
|
-
const
|
|
3154
|
+
this.options.bindFragments.forEach((n) => {
|
|
3155
|
+
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3067
3156
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3068
|
-
const o =
|
|
3069
|
-
|
|
3070
|
-
|
|
3157
|
+
const o = s[a], u = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3158
|
+
s[a] = this.mergeAppendBindingData(
|
|
3159
|
+
n,
|
|
3071
3160
|
r,
|
|
3072
|
-
|
|
3161
|
+
u
|
|
3073
3162
|
);
|
|
3074
3163
|
} else
|
|
3075
|
-
|
|
3076
|
-
i.push(
|
|
3164
|
+
s[a] = r;
|
|
3165
|
+
i.push(R.setBindingData(n.getTarget(), s));
|
|
3077
3166
|
});
|
|
3078
3167
|
else {
|
|
3079
3168
|
if (typeof r == "string")
|
|
3080
|
-
return
|
|
3169
|
+
return d.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3081
3170
|
new Error("string data cannot be bound without a bindArg.")
|
|
3082
3171
|
);
|
|
3083
|
-
this.options.bindFragments.forEach((
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3172
|
+
this.options.bindFragments.forEach((n) => {
|
|
3173
|
+
const s = this.mergeAppendBindingData(
|
|
3174
|
+
n,
|
|
3086
3175
|
r
|
|
3087
3176
|
);
|
|
3088
3177
|
i.push(
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3178
|
+
R.setBindingData(
|
|
3179
|
+
n.getTarget(),
|
|
3180
|
+
s
|
|
3092
3181
|
)
|
|
3093
3182
|
);
|
|
3094
3183
|
});
|
|
@@ -3103,10 +3192,10 @@ ${f}
|
|
|
3103
3192
|
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3104
3193
|
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3105
3194
|
return e;
|
|
3106
|
-
const i = { ...e },
|
|
3107
|
-
for (const
|
|
3108
|
-
const a = i[
|
|
3109
|
-
Array.isArray(o) && Array.isArray(a) && (i[
|
|
3195
|
+
const i = { ...e }, n = r;
|
|
3196
|
+
for (const s of this.options.bindAppendParams) {
|
|
3197
|
+
const a = i[s], o = n[s];
|
|
3198
|
+
Array.isArray(o) && Array.isArray(a) && (i[s] = o.concat(a));
|
|
3110
3199
|
}
|
|
3111
3200
|
return i;
|
|
3112
3201
|
}
|
|
@@ -3117,11 +3206,11 @@ ${f}
|
|
|
3117
3206
|
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3118
3207
|
return Promise.resolve();
|
|
3119
3208
|
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3120
|
-
const
|
|
3209
|
+
const n = {
|
|
3121
3210
|
...i.getBindingData(),
|
|
3122
3211
|
...e
|
|
3123
3212
|
};
|
|
3124
|
-
return
|
|
3213
|
+
return R.setBindingData(i.getTarget(), n);
|
|
3125
3214
|
});
|
|
3126
3215
|
return Promise.all(r).then(() => {
|
|
3127
3216
|
});
|
|
@@ -3130,7 +3219,7 @@ ${f}
|
|
|
3130
3219
|
* copy のコピー元データを取得します。
|
|
3131
3220
|
*/
|
|
3132
3221
|
resolveCopySourceData() {
|
|
3133
|
-
return this.options.formFragment ?
|
|
3222
|
+
return this.options.formFragment ? b.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3134
3223
|
}
|
|
3135
3224
|
/**
|
|
3136
3225
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
@@ -3153,8 +3242,8 @@ ${f}
|
|
|
3153
3242
|
for (const r of this.options.adjustFragments) {
|
|
3154
3243
|
let i = r.getValue();
|
|
3155
3244
|
(i == null || i === "") && (i = "0");
|
|
3156
|
-
let
|
|
3157
|
-
isNaN(
|
|
3245
|
+
let n = Number(i);
|
|
3246
|
+
isNaN(n) && (n = 0), n += t, e.push(r.setValue(String(n)));
|
|
3158
3247
|
}
|
|
3159
3248
|
return Promise.all(e).then(() => {
|
|
3160
3249
|
});
|
|
@@ -3166,11 +3255,11 @@ ${f}
|
|
|
3166
3255
|
*/
|
|
3167
3256
|
getRowFragment() {
|
|
3168
3257
|
if (!this.options.targetFragment)
|
|
3169
|
-
return
|
|
3258
|
+
return d.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3170
3259
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3171
3260
|
`${c.prefix}row`
|
|
3172
3261
|
);
|
|
3173
|
-
return t || (
|
|
3262
|
+
return t || (d.error("Haori", "Row fragment not found."), null);
|
|
3174
3263
|
}
|
|
3175
3264
|
/**
|
|
3176
3265
|
* 行を追加します。
|
|
@@ -3186,7 +3275,7 @@ ${f}
|
|
|
3186
3275
|
const e = [], r = t.clone();
|
|
3187
3276
|
return e.push(
|
|
3188
3277
|
t.getParent().insertAfter(r, t)
|
|
3189
|
-
), e.push(
|
|
3278
|
+
), e.push(R.evaluateAll(r)), e.push(b.reset(r)), Promise.all(e).then(() => {
|
|
3190
3279
|
});
|
|
3191
3280
|
}
|
|
3192
3281
|
/**
|
|
@@ -3238,9 +3327,9 @@ ${f}
|
|
|
3238
3327
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3239
3328
|
}
|
|
3240
3329
|
};
|
|
3241
|
-
|
|
3242
|
-
let V =
|
|
3243
|
-
class
|
|
3330
|
+
l.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, l.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3331
|
+
let V = l;
|
|
3332
|
+
class ft {
|
|
3244
3333
|
/**
|
|
3245
3334
|
* URLのクエリパラメータを取得します。
|
|
3246
3335
|
*
|
|
@@ -3248,12 +3337,12 @@ class ct {
|
|
|
3248
3337
|
*/
|
|
3249
3338
|
static readParams() {
|
|
3250
3339
|
const t = {}, e = window.location.search;
|
|
3251
|
-
return new URLSearchParams(e).forEach((i,
|
|
3252
|
-
t[
|
|
3340
|
+
return new URLSearchParams(e).forEach((i, n) => {
|
|
3341
|
+
t[n] = i;
|
|
3253
3342
|
}), t;
|
|
3254
3343
|
}
|
|
3255
3344
|
}
|
|
3256
|
-
class
|
|
3345
|
+
class dt {
|
|
3257
3346
|
/**
|
|
3258
3347
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3259
3348
|
*
|
|
@@ -3270,28 +3359,28 @@ class ut {
|
|
|
3270
3359
|
let r;
|
|
3271
3360
|
try {
|
|
3272
3361
|
r = await fetch(t, e);
|
|
3273
|
-
} catch (
|
|
3274
|
-
throw
|
|
3362
|
+
} catch (n) {
|
|
3363
|
+
throw d.error("[Haori]", "Failed to fetch import source:", t, n), new Error(`Failed to fetch: ${t}`);
|
|
3275
3364
|
}
|
|
3276
3365
|
if (!r.ok) {
|
|
3277
|
-
const
|
|
3278
|
-
throw
|
|
3366
|
+
const n = `${r.status} ${r.statusText}`;
|
|
3367
|
+
throw d.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3279
3368
|
}
|
|
3280
3369
|
let i;
|
|
3281
3370
|
try {
|
|
3282
3371
|
i = await r.text();
|
|
3283
|
-
} catch (
|
|
3284
|
-
throw
|
|
3372
|
+
} catch (n) {
|
|
3373
|
+
throw d.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3285
3374
|
}
|
|
3286
3375
|
try {
|
|
3287
|
-
const
|
|
3288
|
-
return
|
|
3289
|
-
} catch (
|
|
3290
|
-
return
|
|
3376
|
+
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3377
|
+
return s && s.body ? s.body.innerHTML : (d.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3378
|
+
} catch (n) {
|
|
3379
|
+
return d.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3291
3380
|
}
|
|
3292
3381
|
}
|
|
3293
3382
|
}
|
|
3294
|
-
const
|
|
3383
|
+
const p = class p {
|
|
3295
3384
|
/**
|
|
3296
3385
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
3297
3386
|
*
|
|
@@ -3299,7 +3388,7 @@ const g = class g {
|
|
|
3299
3388
|
* @returns 遅延属性かどうか
|
|
3300
3389
|
*/
|
|
3301
3390
|
static isDeferredAttributeName(t) {
|
|
3302
|
-
return
|
|
3391
|
+
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3303
3392
|
(e) => t === `${c.prefix}${e}`
|
|
3304
3393
|
);
|
|
3305
3394
|
}
|
|
@@ -3310,7 +3399,7 @@ const g = class g {
|
|
|
3310
3399
|
* @returns 除外対象かどうか
|
|
3311
3400
|
*/
|
|
3312
3401
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3313
|
-
return
|
|
3402
|
+
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3314
3403
|
(e) => t === `${c.prefix}${e}`
|
|
3315
3404
|
);
|
|
3316
3405
|
}
|
|
@@ -3322,7 +3411,30 @@ const g = class g {
|
|
|
3322
3411
|
* @returns 再評価する場合は true
|
|
3323
3412
|
*/
|
|
3324
3413
|
static shouldReevaluateAttribute(t, e) {
|
|
3325
|
-
return e !== null && !
|
|
3414
|
+
return e !== null && !p.isEvaluateAllExcludedAttributeName(t) && p.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* data-attr-* 形式の属性名から実際に更新する属性名を取得します。
|
|
3418
|
+
*
|
|
3419
|
+
* @param name 属性名
|
|
3420
|
+
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3421
|
+
*/
|
|
3422
|
+
static getAliasedAttributeName(t) {
|
|
3423
|
+
const e = `${c.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3424
|
+
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3425
|
+
}
|
|
3426
|
+
/**
|
|
3427
|
+
* 実属性の変更が data-attr-* の内部反映かどうかを判定します。
|
|
3428
|
+
*
|
|
3429
|
+
* @param element 対象要素
|
|
3430
|
+
* @param name 変更された属性名
|
|
3431
|
+
* @returns data-attr-* の内部反映なら true
|
|
3432
|
+
*/
|
|
3433
|
+
static isAliasedAttributeReflection(t, e) {
|
|
3434
|
+
const r = T.get(t);
|
|
3435
|
+
return r instanceof x ? r.hasAttribute(
|
|
3436
|
+
`${c.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3437
|
+
) : !1;
|
|
3326
3438
|
}
|
|
3327
3439
|
/**
|
|
3328
3440
|
* プレースホルダを含む通常属性を再評価します。
|
|
@@ -3335,7 +3447,9 @@ const g = class g {
|
|
|
3335
3447
|
let e = Promise.resolve();
|
|
3336
3448
|
for (const r of t.getAttributeNames()) {
|
|
3337
3449
|
const i = t.getRawAttribute(r);
|
|
3338
|
-
|
|
3450
|
+
p.shouldReevaluateAttribute(r, i) && (e = e.then(
|
|
3451
|
+
() => p.setAttribute(t.getTarget(), r, i)
|
|
3452
|
+
));
|
|
3339
3453
|
}
|
|
3340
3454
|
return e.then(() => {
|
|
3341
3455
|
});
|
|
@@ -3347,40 +3461,47 @@ const g = class g {
|
|
|
3347
3461
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
3348
3462
|
*/
|
|
3349
3463
|
static scan(t) {
|
|
3350
|
-
const e =
|
|
3464
|
+
const e = T.get(t);
|
|
3351
3465
|
if (!e)
|
|
3352
3466
|
return Promise.resolve();
|
|
3353
|
-
t.parentNode && (
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3467
|
+
t.parentNode && (T.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3468
|
+
let r = Promise.resolve();
|
|
3469
|
+
const i = /* @__PURE__ */ new Set();
|
|
3470
|
+
for (const n of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3471
|
+
const s = c.prefix + n;
|
|
3472
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3473
|
+
() => p.setAttribute(
|
|
3359
3474
|
e.getTarget(),
|
|
3360
|
-
|
|
3361
|
-
e.getRawAttribute(
|
|
3475
|
+
s,
|
|
3476
|
+
e.getRawAttribute(s)
|
|
3362
3477
|
)
|
|
3363
|
-
), i.add(
|
|
3478
|
+
), i.add(s));
|
|
3364
3479
|
}
|
|
3365
|
-
for (const
|
|
3366
|
-
if (i.has(
|
|
3480
|
+
for (const n of e.getAttributeNames()) {
|
|
3481
|
+
if (i.has(n) || p.isDeferredAttributeName(n))
|
|
3367
3482
|
continue;
|
|
3368
|
-
const
|
|
3369
|
-
|
|
3483
|
+
const s = e.getRawAttribute(n);
|
|
3484
|
+
s !== null && (r = r.then(
|
|
3485
|
+
() => p.setAttribute(e.getTarget(), n, s)
|
|
3486
|
+
));
|
|
3370
3487
|
}
|
|
3371
|
-
for (const
|
|
3372
|
-
const
|
|
3373
|
-
e.hasAttribute(
|
|
3374
|
-
|
|
3488
|
+
for (const n of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3489
|
+
const s = c.prefix + n;
|
|
3490
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3491
|
+
() => p.setAttribute(
|
|
3375
3492
|
e.getTarget(),
|
|
3376
|
-
|
|
3377
|
-
e.getRawAttribute(
|
|
3493
|
+
s,
|
|
3494
|
+
e.getRawAttribute(s)
|
|
3378
3495
|
)
|
|
3379
|
-
), i.add(
|
|
3496
|
+
), i.add(s));
|
|
3380
3497
|
}
|
|
3381
|
-
return
|
|
3382
|
-
|
|
3383
|
-
|
|
3498
|
+
return r.then(() => {
|
|
3499
|
+
const n = [];
|
|
3500
|
+
return e.getChildren().forEach((s) => {
|
|
3501
|
+
s instanceof x ? n.push(p.scan(s.getTarget())) : s instanceof H && n.push(p.evaluateText(s));
|
|
3502
|
+
}), Promise.all(n).then(() => {
|
|
3503
|
+
});
|
|
3504
|
+
}).then(() => {
|
|
3384
3505
|
});
|
|
3385
3506
|
}
|
|
3386
3507
|
/**
|
|
@@ -3393,17 +3514,20 @@ const g = class g {
|
|
|
3393
3514
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3394
3515
|
*/
|
|
3395
3516
|
static setAttribute(t, e, r) {
|
|
3396
|
-
const i =
|
|
3517
|
+
const i = T.get(t), n = p.getAliasedAttributeName(e);
|
|
3518
|
+
if (n !== null)
|
|
3519
|
+
return r === null ? i.removeAliasedAttribute(e, n) : i.setAliasedAttribute(e, n, r);
|
|
3520
|
+
const s = [];
|
|
3397
3521
|
switch (e) {
|
|
3398
3522
|
case `${c.prefix}bind`: {
|
|
3399
|
-
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(
|
|
3523
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3400
3524
|
break;
|
|
3401
3525
|
}
|
|
3402
3526
|
case `${c.prefix}if`:
|
|
3403
|
-
s.push(
|
|
3527
|
+
s.push(p.evaluateIf(i));
|
|
3404
3528
|
break;
|
|
3405
3529
|
case `${c.prefix}each`:
|
|
3406
|
-
s.push(
|
|
3530
|
+
s.push(p.evaluateEach(i));
|
|
3407
3531
|
break;
|
|
3408
3532
|
case `${c.prefix}fetch`:
|
|
3409
3533
|
s.push(
|
|
@@ -3413,29 +3537,29 @@ const g = class g {
|
|
|
3413
3537
|
break;
|
|
3414
3538
|
case `${c.prefix}import`: {
|
|
3415
3539
|
if (typeof r == "string") {
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
const
|
|
3540
|
+
const a = i.getTarget(), o = performance.now();
|
|
3541
|
+
w.importStart(a, r), s.push(
|
|
3542
|
+
dt.load(r).then((u) => {
|
|
3543
|
+
const m = new TextEncoder().encode(u).length;
|
|
3420
3544
|
return P.enqueue(() => {
|
|
3421
|
-
|
|
3545
|
+
a.innerHTML = u;
|
|
3422
3546
|
}).then(() => {
|
|
3423
|
-
|
|
3547
|
+
w.importEnd(a, r, m, o);
|
|
3424
3548
|
});
|
|
3425
|
-
}).catch((
|
|
3426
|
-
|
|
3549
|
+
}).catch((u) => {
|
|
3550
|
+
w.importError(a, r, u), d.error("[Haori]", "Failed to import HTML:", r, u);
|
|
3427
3551
|
})
|
|
3428
3552
|
);
|
|
3429
3553
|
}
|
|
3430
3554
|
break;
|
|
3431
3555
|
}
|
|
3432
3556
|
case `${c.prefix}url-param`: {
|
|
3433
|
-
const
|
|
3434
|
-
if (
|
|
3435
|
-
|
|
3557
|
+
const a = i.getAttribute(`${c.prefix}url-arg`), o = ft.readParams();
|
|
3558
|
+
if (a === null)
|
|
3559
|
+
s.push(p.setBindingData(t, o));
|
|
3436
3560
|
else {
|
|
3437
|
-
const
|
|
3438
|
-
|
|
3561
|
+
const u = i.getRawBindingData() || {};
|
|
3562
|
+
u[String(a)] = o, s.push(p.setBindingData(t, u));
|
|
3439
3563
|
}
|
|
3440
3564
|
break;
|
|
3441
3565
|
}
|
|
@@ -3452,16 +3576,17 @@ const g = class g {
|
|
|
3452
3576
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3453
3577
|
*/
|
|
3454
3578
|
static setBindingData(t, e) {
|
|
3455
|
-
const r =
|
|
3579
|
+
const r = T.get(t), i = r.getRawBindingData();
|
|
3456
3580
|
r.setBindingData(e);
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
)
|
|
3461
|
-
|
|
3462
|
-
s.
|
|
3581
|
+
let n = r.setAttribute(
|
|
3582
|
+
`${c.prefix}bind`,
|
|
3583
|
+
JSON.stringify(e)
|
|
3584
|
+
);
|
|
3585
|
+
if (t.tagName === "FORM") {
|
|
3586
|
+
const s = r.getAttribute(`${c.prefix}form-arg`), a = s && e[String(s)] && typeof e[String(s)] == "object" && !Array.isArray(e[String(s)]) ? e[String(s)] : s ? {} : e;
|
|
3587
|
+
n = n.then(() => b.syncValues(r, a));
|
|
3463
3588
|
}
|
|
3464
|
-
return
|
|
3589
|
+
return n = n.then(() => p.evaluateAll(r)), w.bindChange(t, i, e, "manual"), n.then(() => {
|
|
3465
3590
|
});
|
|
3466
3591
|
}
|
|
3467
3592
|
/**
|
|
@@ -3475,12 +3600,12 @@ const g = class g {
|
|
|
3475
3600
|
try {
|
|
3476
3601
|
return JSON.parse(t);
|
|
3477
3602
|
} catch (e) {
|
|
3478
|
-
return
|
|
3603
|
+
return d.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3479
3604
|
}
|
|
3480
3605
|
else {
|
|
3481
3606
|
const e = new URLSearchParams(t), r = {};
|
|
3482
|
-
for (const [i,
|
|
3483
|
-
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(
|
|
3607
|
+
for (const [i, n] of e.entries())
|
|
3608
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(n) : r[i] = [r[i], n] : r[i] = n;
|
|
3484
3609
|
return r;
|
|
3485
3610
|
}
|
|
3486
3611
|
}
|
|
@@ -3491,11 +3616,11 @@ const g = class g {
|
|
|
3491
3616
|
* @param node 追加するノード
|
|
3492
3617
|
*/
|
|
3493
3618
|
static addNode(t, e) {
|
|
3494
|
-
const r =
|
|
3619
|
+
const r = T.get(t);
|
|
3495
3620
|
if (r.isSkipMutationNodes())
|
|
3496
3621
|
return;
|
|
3497
|
-
const i =
|
|
3498
|
-
|
|
3622
|
+
const i = T.get(e.nextSibling), n = T.get(e);
|
|
3623
|
+
n && (r.insertBefore(n, i), n instanceof x ? p.scan(n.getTarget()) : n instanceof H && p.evaluateText(n));
|
|
3499
3624
|
}
|
|
3500
3625
|
/**
|
|
3501
3626
|
* ノードを親要素から削除します。
|
|
@@ -3503,7 +3628,7 @@ const g = class g {
|
|
|
3503
3628
|
* @param node 削除するノード
|
|
3504
3629
|
*/
|
|
3505
3630
|
static removeNode(t) {
|
|
3506
|
-
const e =
|
|
3631
|
+
const e = T.get(t);
|
|
3507
3632
|
if (e) {
|
|
3508
3633
|
const r = e.getParent();
|
|
3509
3634
|
if (r && r.isSkipMutationNodes())
|
|
@@ -3518,7 +3643,7 @@ const g = class g {
|
|
|
3518
3643
|
* @param text 新しいテキスト
|
|
3519
3644
|
*/
|
|
3520
3645
|
static changeText(t, e) {
|
|
3521
|
-
const r =
|
|
3646
|
+
const r = T.get(t);
|
|
3522
3647
|
r && r.setContent(e);
|
|
3523
3648
|
}
|
|
3524
3649
|
/**
|
|
@@ -3530,16 +3655,16 @@ const g = class g {
|
|
|
3530
3655
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3531
3656
|
*/
|
|
3532
3657
|
static changeValue(t, e) {
|
|
3533
|
-
const r =
|
|
3658
|
+
const r = T.get(t);
|
|
3534
3659
|
if (r.getValue() === e)
|
|
3535
3660
|
return Promise.resolve();
|
|
3536
3661
|
const i = [];
|
|
3537
3662
|
i.push(r.setValue(e));
|
|
3538
|
-
const
|
|
3539
|
-
if (
|
|
3540
|
-
const
|
|
3663
|
+
const n = p.getFormFragment(r);
|
|
3664
|
+
if (n) {
|
|
3665
|
+
const s = b.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
|
|
3541
3666
|
let o;
|
|
3542
|
-
a ? (o =
|
|
3667
|
+
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(p.setBindingData(n.getTarget(), o));
|
|
3543
3668
|
}
|
|
3544
3669
|
return Promise.all(i).then(() => {
|
|
3545
3670
|
});
|
|
@@ -3554,7 +3679,7 @@ const g = class g {
|
|
|
3554
3679
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
3555
3680
|
return t;
|
|
3556
3681
|
const e = t.getParent();
|
|
3557
|
-
return e ?
|
|
3682
|
+
return e ? p.getFormFragment(e) : null;
|
|
3558
3683
|
}
|
|
3559
3684
|
/**
|
|
3560
3685
|
* フラグメントとその子要素を評価します。
|
|
@@ -3564,10 +3689,16 @@ const g = class g {
|
|
|
3564
3689
|
*/
|
|
3565
3690
|
static evaluateAll(t) {
|
|
3566
3691
|
const e = [];
|
|
3567
|
-
return e.push(
|
|
3568
|
-
|
|
3692
|
+
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${c.prefix}if`) && e.push(p.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) ? Promise.all(e).then(() => p.evaluateEach(t)).then(() => {
|
|
3693
|
+
const r = [];
|
|
3694
|
+
return t.getChildren().forEach((i) => {
|
|
3695
|
+
i instanceof x ? r.push(p.evaluateAll(i)) : i instanceof H && r.push(p.evaluateText(i));
|
|
3696
|
+
}), Promise.all(r).then(() => {
|
|
3697
|
+
});
|
|
3698
|
+
}) : (t.getChildren().forEach((r) => {
|
|
3699
|
+
r instanceof x ? e.push(p.evaluateAll(r)) : r instanceof H && e.push(p.evaluateText(r));
|
|
3569
3700
|
}), Promise.all(e).then(() => {
|
|
3570
|
-
});
|
|
3701
|
+
}));
|
|
3571
3702
|
}
|
|
3572
3703
|
/**
|
|
3573
3704
|
* テキストフラグメントを評価します。
|
|
@@ -3589,13 +3720,13 @@ const g = class g {
|
|
|
3589
3720
|
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3590
3721
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3591
3722
|
t.hide().then(() => {
|
|
3592
|
-
|
|
3723
|
+
w.hide(t.getTarget());
|
|
3593
3724
|
})
|
|
3594
3725
|
) : t.isVisible() || (e.push(
|
|
3595
3726
|
t.show().then(() => {
|
|
3596
|
-
|
|
3727
|
+
w.show(t.getTarget());
|
|
3597
3728
|
})
|
|
3598
|
-
), e.push(
|
|
3729
|
+
), e.push(p.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3599
3730
|
});
|
|
3600
3731
|
}
|
|
3601
3732
|
/**
|
|
@@ -3610,20 +3741,20 @@ const g = class g {
|
|
|
3610
3741
|
let e = t.getTemplate();
|
|
3611
3742
|
if (e === null) {
|
|
3612
3743
|
let i = !1;
|
|
3613
|
-
t.getChildren().forEach((
|
|
3614
|
-
if (!i &&
|
|
3615
|
-
if (
|
|
3744
|
+
t.getChildren().forEach((s) => {
|
|
3745
|
+
if (!i && s instanceof x) {
|
|
3746
|
+
if (s.hasAttribute(`${c.prefix}each-before`) || s.hasAttribute(`${c.prefix}each-after`))
|
|
3616
3747
|
return;
|
|
3617
|
-
e =
|
|
3618
|
-
const a =
|
|
3619
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3748
|
+
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3749
|
+
const a = s.getTarget();
|
|
3750
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3620
3751
|
}
|
|
3621
3752
|
});
|
|
3622
|
-
const
|
|
3623
|
-
return Array.isArray(
|
|
3753
|
+
const n = t.getAttribute(`${c.prefix}each`);
|
|
3754
|
+
return Array.isArray(n) ? this.updateDiff(t, n) : (d.error("[Haori]", "Invalid each attribute:", n), Promise.reject(new Error("Invalid each attribute.")));
|
|
3624
3755
|
}
|
|
3625
3756
|
const r = t.getAttribute(`${c.prefix}each`);
|
|
3626
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3757
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (d.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3627
3758
|
}
|
|
3628
3759
|
/**
|
|
3629
3760
|
* 差分を更新します。
|
|
@@ -3634,73 +3765,73 @@ const g = class g {
|
|
|
3634
3765
|
static updateDiff(t, e) {
|
|
3635
3766
|
const r = t.getTemplate();
|
|
3636
3767
|
if (r === null)
|
|
3637
|
-
return
|
|
3768
|
+
return d.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3638
3769
|
let i = t.getAttribute(`${c.prefix}each-index`);
|
|
3639
3770
|
i && (i = String(i));
|
|
3640
|
-
const
|
|
3641
|
-
e.forEach((
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3644
|
-
|
|
3771
|
+
const n = t.getAttribute(`${c.prefix}each-key`), s = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3772
|
+
e.forEach((h, f) => {
|
|
3773
|
+
const g = p.createListKey(
|
|
3774
|
+
h,
|
|
3775
|
+
n ? String(n) : null,
|
|
3645
3776
|
f
|
|
3646
3777
|
);
|
|
3647
|
-
o.push(
|
|
3778
|
+
o.push(g), a.set(g, { item: h, itemIndex: f });
|
|
3648
3779
|
});
|
|
3649
|
-
const
|
|
3650
|
-
let
|
|
3651
|
-
(
|
|
3780
|
+
const u = [];
|
|
3781
|
+
let m = t.getChildren().filter((h) => h instanceof x).filter(
|
|
3782
|
+
(h) => !h.hasAttribute(`${c.prefix}each-before`) && !h.hasAttribute(`${c.prefix}each-after`)
|
|
3652
3783
|
);
|
|
3653
|
-
|
|
3654
|
-
const
|
|
3784
|
+
m = m.filter((h) => o.indexOf(String(h.getListKey())) === -1 ? (u.push(h.remove()), !1) : !0);
|
|
3785
|
+
const y = m.map((h) => h.getListKey()), E = t.getChildren().filter((h) => h instanceof x).filter((h) => h.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3655
3786
|
let S = Promise.resolve();
|
|
3656
|
-
return o.forEach((
|
|
3657
|
-
const
|
|
3787
|
+
return o.forEach((h, f) => {
|
|
3788
|
+
const g = y.indexOf(h), { item: A, itemIndex: v } = a.get(h);
|
|
3658
3789
|
let k;
|
|
3659
|
-
if (
|
|
3660
|
-
k =
|
|
3661
|
-
() =>
|
|
3790
|
+
if (g !== -1)
|
|
3791
|
+
k = m[g], S = S.then(
|
|
3792
|
+
() => p.updateRowFragment(
|
|
3662
3793
|
k,
|
|
3663
|
-
|
|
3794
|
+
A,
|
|
3664
3795
|
i,
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
).then(() =>
|
|
3796
|
+
v,
|
|
3797
|
+
s ? String(s) : null,
|
|
3798
|
+
h
|
|
3799
|
+
).then(() => p.evaluateAll(k))
|
|
3669
3800
|
);
|
|
3670
3801
|
else {
|
|
3671
3802
|
k = r.clone();
|
|
3672
|
-
const
|
|
3803
|
+
const W = E + f;
|
|
3673
3804
|
S = S.then(
|
|
3674
|
-
() =>
|
|
3805
|
+
() => p.updateRowFragment(
|
|
3675
3806
|
k,
|
|
3676
|
-
|
|
3807
|
+
A,
|
|
3677
3808
|
i,
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3809
|
+
v,
|
|
3810
|
+
s ? String(s) : null,
|
|
3811
|
+
h
|
|
3681
3812
|
).then(
|
|
3682
3813
|
() => t.insertBefore(
|
|
3683
3814
|
k,
|
|
3684
|
-
t.getChildren()[
|
|
3685
|
-
).then(() =>
|
|
3815
|
+
t.getChildren()[W] || null
|
|
3816
|
+
).then(() => p.evaluateAll(k))
|
|
3686
3817
|
)
|
|
3687
3818
|
);
|
|
3688
3819
|
}
|
|
3689
|
-
}), Promise.all(
|
|
3690
|
-
const
|
|
3691
|
-
(
|
|
3692
|
-
), f =
|
|
3693
|
-
(
|
|
3694
|
-
),
|
|
3695
|
-
(
|
|
3696
|
-
),
|
|
3697
|
-
(
|
|
3820
|
+
}), Promise.all(u).then(() => S).then(() => {
|
|
3821
|
+
const h = o.filter(
|
|
3822
|
+
(v) => v !== null
|
|
3823
|
+
), f = y.filter(
|
|
3824
|
+
(v) => v !== null
|
|
3825
|
+
), g = h.filter(
|
|
3826
|
+
(v) => !f.includes(v)
|
|
3827
|
+
), A = f.filter(
|
|
3828
|
+
(v) => !h.includes(v)
|
|
3698
3829
|
);
|
|
3699
|
-
|
|
3830
|
+
w.eachUpdate(
|
|
3700
3831
|
t.getTarget(),
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3832
|
+
g,
|
|
3833
|
+
A,
|
|
3834
|
+
h
|
|
3704
3835
|
);
|
|
3705
3836
|
});
|
|
3706
3837
|
}
|
|
@@ -3716,8 +3847,8 @@ const g = class g {
|
|
|
3716
3847
|
let i;
|
|
3717
3848
|
if (typeof t == "object" && t !== null)
|
|
3718
3849
|
if (e) {
|
|
3719
|
-
const
|
|
3720
|
-
|
|
3850
|
+
const n = t[e];
|
|
3851
|
+
n == null ? i = `__index_${r}` : typeof n == "object" ? i = JSON.stringify(n) : i = String(n);
|
|
3721
3852
|
} else
|
|
3722
3853
|
i = `__index_${r}`;
|
|
3723
3854
|
else
|
|
@@ -3735,34 +3866,34 @@ const g = class g {
|
|
|
3735
3866
|
* @param listKey リストキー
|
|
3736
3867
|
* @returns 行メタデータの更新完了 Promise
|
|
3737
3868
|
*/
|
|
3738
|
-
static updateRowFragment(t, e, r, i,
|
|
3869
|
+
static updateRowFragment(t, e, r, i, n, s) {
|
|
3739
3870
|
let a = e;
|
|
3740
3871
|
if (typeof e == "object" && e !== null)
|
|
3741
|
-
a = { ...e }, r && (a[r] = i),
|
|
3742
|
-
[
|
|
3872
|
+
a = { ...e }, r && (a[r] = i), n && (a = {
|
|
3873
|
+
[n]: a
|
|
3743
3874
|
});
|
|
3744
|
-
else if (
|
|
3875
|
+
else if (n)
|
|
3745
3876
|
a = {
|
|
3746
|
-
[
|
|
3877
|
+
[n]: e
|
|
3747
3878
|
}, r && (a[r] = i);
|
|
3748
3879
|
else
|
|
3749
|
-
return
|
|
3880
|
+
return d.error(
|
|
3750
3881
|
"[Haori]",
|
|
3751
3882
|
`Primitive value requires '${c.prefix}each-arg' attribute: ${e}`
|
|
3752
3883
|
), Promise.resolve();
|
|
3753
|
-
return t.setListKey(
|
|
3884
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${c.prefix}row`, s);
|
|
3754
3885
|
}
|
|
3755
3886
|
};
|
|
3756
|
-
|
|
3887
|
+
p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], p.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
3757
3888
|
"bind",
|
|
3758
3889
|
"if",
|
|
3759
3890
|
"each",
|
|
3760
3891
|
"fetch",
|
|
3761
3892
|
"import",
|
|
3762
3893
|
"url-param"
|
|
3763
|
-
],
|
|
3764
|
-
let
|
|
3765
|
-
class
|
|
3894
|
+
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3895
|
+
let R = p;
|
|
3896
|
+
const X = class X {
|
|
3766
3897
|
/**
|
|
3767
3898
|
* コンストラクタ。
|
|
3768
3899
|
*
|
|
@@ -3770,22 +3901,25 @@ class ht {
|
|
|
3770
3901
|
*/
|
|
3771
3902
|
constructor(t = document) {
|
|
3772
3903
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3773
|
-
const e = document.documentElement, r =
|
|
3904
|
+
const e = document.documentElement, r = T.get(e);
|
|
3774
3905
|
r && new V(r, "load").run();
|
|
3906
|
+
}, this.onPopstate = (e) => {
|
|
3907
|
+
const r = e.state;
|
|
3908
|
+
!r || r[X.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
3775
3909
|
}, this.root = t;
|
|
3776
3910
|
}
|
|
3777
3911
|
/**
|
|
3778
3912
|
* イベントリスナーの登録を開始します。
|
|
3779
|
-
*
|
|
3913
|
+
* クリック、変更、ロード、popstate イベントを監視し、対応するProcedureを実行します。
|
|
3780
3914
|
*/
|
|
3781
3915
|
start() {
|
|
3782
|
-
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 });
|
|
3916
|
+
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 }), window.addEventListener("popstate", this.onPopstate);
|
|
3783
3917
|
}
|
|
3784
3918
|
/**
|
|
3785
3919
|
* イベントリスナーの登録を停止します。
|
|
3786
3920
|
*/
|
|
3787
3921
|
stop() {
|
|
3788
|
-
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad);
|
|
3922
|
+
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad), window.removeEventListener("popstate", this.onPopstate);
|
|
3789
3923
|
}
|
|
3790
3924
|
/**
|
|
3791
3925
|
* イベントを処理し、対応するProcedureを実行します。
|
|
@@ -3797,9 +3931,9 @@ class ht {
|
|
|
3797
3931
|
const r = this.getElementFromTarget(t.target);
|
|
3798
3932
|
if (!r)
|
|
3799
3933
|
return;
|
|
3800
|
-
const i =
|
|
3801
|
-
i && (e === "change" && i instanceof
|
|
3802
|
-
|
|
3934
|
+
const i = T.get(r);
|
|
3935
|
+
i && (e === "change" && i instanceof x && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
3936
|
+
d.error("[Haori]", "Procedure execution error:", n);
|
|
3803
3937
|
}));
|
|
3804
3938
|
}
|
|
3805
3939
|
/**
|
|
@@ -3811,55 +3945,57 @@ class ht {
|
|
|
3811
3945
|
getElementFromTarget(t) {
|
|
3812
3946
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3813
3947
|
}
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3948
|
+
};
|
|
3949
|
+
X.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
3950
|
+
let Q = X;
|
|
3951
|
+
const N = class N {
|
|
3816
3952
|
static syncTree(t) {
|
|
3817
|
-
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement &&
|
|
3818
|
-
|
|
3953
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && N.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
3954
|
+
N.syncElement(e);
|
|
3819
3955
|
}));
|
|
3820
3956
|
}
|
|
3821
3957
|
static syncElement(t) {
|
|
3822
|
-
const e =
|
|
3823
|
-
if (!r || !
|
|
3824
|
-
e && (e.observer.disconnect(),
|
|
3958
|
+
const e = N.registrations.get(t), r = T.get(t);
|
|
3959
|
+
if (!r || !N.shouldObserve(r)) {
|
|
3960
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3825
3961
|
return;
|
|
3826
3962
|
}
|
|
3827
3963
|
if (typeof IntersectionObserver > "u")
|
|
3828
3964
|
return;
|
|
3829
|
-
const i =
|
|
3830
|
-
if (e && e.observer.root === i && e.observer.rootMargin ===
|
|
3965
|
+
const i = N.resolveRoot(r), n = N.resolveRootMargin(r), s = N.resolveThreshold(r), a = r.hasAttribute(`${c.prefix}intersect-once`);
|
|
3966
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && N.sameThreshold(
|
|
3831
3967
|
e.observer.thresholds,
|
|
3832
|
-
|
|
3968
|
+
s
|
|
3833
3969
|
) && e.once === a) {
|
|
3834
3970
|
e.fragment = r;
|
|
3835
3971
|
return;
|
|
3836
3972
|
}
|
|
3837
|
-
e && (e.observer.disconnect(),
|
|
3973
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3838
3974
|
const o = new IntersectionObserver(
|
|
3839
|
-
(
|
|
3840
|
-
const
|
|
3841
|
-
|
|
3842
|
-
!
|
|
3843
|
-
|
|
3844
|
-
}).catch((
|
|
3845
|
-
|
|
3975
|
+
(u) => {
|
|
3976
|
+
const m = N.registrations.get(t);
|
|
3977
|
+
m && u.forEach((y) => {
|
|
3978
|
+
!y.isIntersecting || m.running || N.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((E) => {
|
|
3979
|
+
E && m.once && (m.observer.disconnect(), N.registrations.delete(t));
|
|
3980
|
+
}).catch((E) => {
|
|
3981
|
+
d.error(
|
|
3846
3982
|
"[Haori]",
|
|
3847
3983
|
"Intersect procedure execution error:",
|
|
3848
|
-
|
|
3984
|
+
E
|
|
3849
3985
|
);
|
|
3850
3986
|
}).finally(() => {
|
|
3851
|
-
const
|
|
3852
|
-
|
|
3987
|
+
const E = N.registrations.get(t);
|
|
3988
|
+
E && (E.running = !1);
|
|
3853
3989
|
}));
|
|
3854
3990
|
});
|
|
3855
3991
|
},
|
|
3856
3992
|
{
|
|
3857
3993
|
root: i,
|
|
3858
|
-
rootMargin:
|
|
3859
|
-
threshold:
|
|
3994
|
+
rootMargin: n,
|
|
3995
|
+
threshold: s
|
|
3860
3996
|
}
|
|
3861
3997
|
);
|
|
3862
|
-
o.observe(t),
|
|
3998
|
+
o.observe(t), N.registrations.set(t, {
|
|
3863
3999
|
fragment: r,
|
|
3864
4000
|
observer: o,
|
|
3865
4001
|
once: a,
|
|
@@ -3868,25 +4004,25 @@ const T = class T {
|
|
|
3868
4004
|
}
|
|
3869
4005
|
static cleanupTree(t) {
|
|
3870
4006
|
if (t instanceof HTMLElement) {
|
|
3871
|
-
const e =
|
|
3872
|
-
e && (e.observer.disconnect(),
|
|
4007
|
+
const e = N.registrations.get(t);
|
|
4008
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3873
4009
|
}
|
|
3874
4010
|
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
3875
|
-
const r =
|
|
3876
|
-
r && (r.observer.disconnect(),
|
|
4011
|
+
const r = N.registrations.get(e);
|
|
4012
|
+
r && (r.observer.disconnect(), N.registrations.delete(e));
|
|
3877
4013
|
});
|
|
3878
4014
|
}
|
|
3879
4015
|
static disconnectAll() {
|
|
3880
|
-
|
|
4016
|
+
N.registrations.forEach((t) => {
|
|
3881
4017
|
t.observer.disconnect();
|
|
3882
|
-
}),
|
|
4018
|
+
}), N.registrations.clear();
|
|
3883
4019
|
}
|
|
3884
4020
|
static shouldObserve(t) {
|
|
3885
4021
|
return t.getAttributeNames().some((e) => {
|
|
3886
4022
|
if (!e.startsWith(`${c.prefix}intersect-`))
|
|
3887
4023
|
return !1;
|
|
3888
4024
|
const r = e.slice(`${c.prefix}intersect-`.length);
|
|
3889
|
-
return !
|
|
4025
|
+
return !N.CONFIG_KEYS.has(r);
|
|
3890
4026
|
});
|
|
3891
4027
|
}
|
|
3892
4028
|
static resolveRoot(t) {
|
|
@@ -3897,7 +4033,7 @@ const T = class T {
|
|
|
3897
4033
|
if (typeof r != "string" || r.trim() === "")
|
|
3898
4034
|
return null;
|
|
3899
4035
|
const i = document.querySelector(r);
|
|
3900
|
-
return i instanceof HTMLElement ? i : (
|
|
4036
|
+
return i instanceof HTMLElement ? i : (d.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
3901
4037
|
}
|
|
3902
4038
|
static resolveRootMargin(t) {
|
|
3903
4039
|
const e = `${c.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
@@ -3920,28 +4056,28 @@ const T = class T {
|
|
|
3920
4056
|
return t.length === 1 && t[0] === e;
|
|
3921
4057
|
}
|
|
3922
4058
|
};
|
|
3923
|
-
|
|
4059
|
+
N.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
3924
4060
|
"root",
|
|
3925
4061
|
"root-margin",
|
|
3926
4062
|
"threshold",
|
|
3927
4063
|
"disabled",
|
|
3928
4064
|
"once"
|
|
3929
|
-
]),
|
|
3930
|
-
let $ =
|
|
3931
|
-
const
|
|
4065
|
+
]), N.registrations = /* @__PURE__ */ new Map();
|
|
4066
|
+
let $ = N;
|
|
4067
|
+
const I = class I {
|
|
3932
4068
|
/**
|
|
3933
4069
|
* 初期化メソッド。
|
|
3934
4070
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
3935
4071
|
*/
|
|
3936
4072
|
static async init() {
|
|
3937
|
-
if (
|
|
4073
|
+
if (I._initialized)
|
|
3938
4074
|
return;
|
|
3939
|
-
|
|
4075
|
+
I._initialized = !0;
|
|
3940
4076
|
const t = await Promise.allSettled([
|
|
3941
|
-
|
|
3942
|
-
|
|
4077
|
+
R.scan(document.head),
|
|
4078
|
+
R.scan(document.body)
|
|
3943
4079
|
]), [e, r] = t;
|
|
3944
|
-
e.status !== "fulfilled" &&
|
|
4080
|
+
e.status !== "fulfilled" && d.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && d.error("[Haori]", "Failed to build body fragment:", r.reason), I.observe(document.head), I.observe(document.body), new Q().start(), $.syncTree(document.body);
|
|
3945
4081
|
}
|
|
3946
4082
|
/**
|
|
3947
4083
|
* 指定された要素を監視します。
|
|
@@ -3954,40 +4090,45 @@ const H = class H {
|
|
|
3954
4090
|
try {
|
|
3955
4091
|
switch (i.type) {
|
|
3956
4092
|
case "attributes": {
|
|
3957
|
-
|
|
4093
|
+
d.info(
|
|
3958
4094
|
"[Haori]",
|
|
3959
4095
|
"Attribute changed:",
|
|
3960
4096
|
i.target,
|
|
3961
4097
|
i.attributeName
|
|
3962
4098
|
);
|
|
3963
|
-
const
|
|
3964
|
-
|
|
3965
|
-
|
|
4099
|
+
const n = i.target;
|
|
4100
|
+
if (i.attributeName && R.isAliasedAttributeReflection(
|
|
4101
|
+
n,
|
|
4102
|
+
i.attributeName
|
|
4103
|
+
))
|
|
4104
|
+
break;
|
|
4105
|
+
R.setAttribute(
|
|
4106
|
+
n,
|
|
3966
4107
|
i.attributeName,
|
|
3967
|
-
|
|
3968
|
-
), $.syncElement(
|
|
4108
|
+
n.getAttribute(i.attributeName)
|
|
4109
|
+
), $.syncElement(n);
|
|
3969
4110
|
break;
|
|
3970
4111
|
}
|
|
3971
4112
|
case "childList": {
|
|
3972
|
-
|
|
4113
|
+
d.info(
|
|
3973
4114
|
"[Haori]",
|
|
3974
4115
|
"Child list changed:",
|
|
3975
|
-
Array.from(i.removedNodes).map((
|
|
3976
|
-
Array.from(i.addedNodes).map((
|
|
3977
|
-
), Array.from(i.removedNodes).forEach((
|
|
3978
|
-
$.cleanupTree(
|
|
3979
|
-
}), Array.from(i.addedNodes).forEach((
|
|
3980
|
-
|
|
4116
|
+
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4117
|
+
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4118
|
+
), Array.from(i.removedNodes).forEach((n) => {
|
|
4119
|
+
$.cleanupTree(n), R.removeNode(n);
|
|
4120
|
+
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4121
|
+
n.parentElement instanceof HTMLElement && (R.addNode(n.parentElement, n), $.syncTree(n));
|
|
3981
4122
|
});
|
|
3982
4123
|
break;
|
|
3983
4124
|
}
|
|
3984
4125
|
case "characterData": {
|
|
3985
|
-
|
|
4126
|
+
d.info(
|
|
3986
4127
|
"[Haori]",
|
|
3987
4128
|
"Character data changed:",
|
|
3988
4129
|
i.target,
|
|
3989
4130
|
i.target.textContent
|
|
3990
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
4131
|
+
), i.target instanceof Text || i.target instanceof Comment ? R.changeText(i.target, i.target.textContent) : d.warn(
|
|
3991
4132
|
"[Haori]",
|
|
3992
4133
|
"Unsupported character data type:",
|
|
3993
4134
|
i.target
|
|
@@ -3995,33 +4136,33 @@ const H = class H {
|
|
|
3995
4136
|
break;
|
|
3996
4137
|
}
|
|
3997
4138
|
default:
|
|
3998
|
-
|
|
4139
|
+
d.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
3999
4140
|
continue;
|
|
4000
4141
|
}
|
|
4001
|
-
} catch (
|
|
4002
|
-
|
|
4142
|
+
} catch (n) {
|
|
4143
|
+
d.error("[Haori]", "Error processing mutation:", n);
|
|
4003
4144
|
}
|
|
4004
4145
|
}).observe(t, {
|
|
4005
4146
|
childList: !0,
|
|
4006
4147
|
subtree: !0,
|
|
4007
4148
|
attributes: !0,
|
|
4008
4149
|
characterData: !0
|
|
4009
|
-
}),
|
|
4150
|
+
}), d.info("[Haori]", "Observer initialized for", t);
|
|
4010
4151
|
}
|
|
4011
4152
|
};
|
|
4012
|
-
|
|
4013
|
-
let q =
|
|
4153
|
+
I._initialized = !1;
|
|
4154
|
+
let q = I;
|
|
4014
4155
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4015
|
-
const
|
|
4156
|
+
const pt = "0.4.3";
|
|
4016
4157
|
export {
|
|
4017
|
-
|
|
4158
|
+
R as Core,
|
|
4018
4159
|
c as Env,
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4160
|
+
b as Form,
|
|
4161
|
+
T as Fragment,
|
|
4162
|
+
J as Haori,
|
|
4163
|
+
d as Log,
|
|
4023
4164
|
P as Queue,
|
|
4024
|
-
|
|
4025
|
-
|
|
4165
|
+
J as default,
|
|
4166
|
+
pt as version
|
|
4026
4167
|
};
|
|
4027
4168
|
//# sourceMappingURL=haori.es.js.map
|