haori 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -1
- package/README.md +2 -1
- package/dist/haori.cjs.js +8 -8
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +671 -568
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +8 -8
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +37 -1
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +12 -0
- package/dist/src/core.js.map +1 -1
- package/dist/src/form.d.ts +19 -0
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +37 -9
- package/dist/src/form.js.map +1 -1
- package/dist/src/fragment.d.ts +17 -0
- package/dist/src/fragment.d.ts.map +1 -1
- package/dist/src/fragment.js +42 -11
- package/dist/src/fragment.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/procedure.d.ts +16 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +68 -8
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/data-fetch-form-input-binding.test.js +71 -0
- package/dist/tests/data-fetch-form-input-binding.test.js.map +1 -1
- package/dist/tests/form.test.js +27 -0
- package/dist/tests/form.test.js.map +1 -1
- package/dist/tests/fragment.test.js +1 -1
- package/dist/tests/fragment.test.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +148 -3
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -29,13 +29,13 @@ const O = class O {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
|
-
let
|
|
32
|
+
let B = O;
|
|
33
33
|
const W = "embedded";
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function _(F) {
|
|
35
|
+
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
37
|
+
function et(F) {
|
|
38
|
+
return F === null ? null : _(F) ? F : W;
|
|
39
39
|
}
|
|
40
40
|
const M = class M {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const M = class M {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
M._runtime =
|
|
56
|
+
M._runtime = _(t) ? t : W;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,21 +67,21 @@ const M = class M {
|
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
68
|
const r = t.getAttribute("data-prefix") || M._prefix;
|
|
69
69
|
M._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const i =
|
|
70
|
+
const i = et(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
73
|
i !== null && (M._runtime = i);
|
|
74
74
|
}
|
|
75
75
|
if (t instanceof HTMLScriptElement && t.hasAttribute(`${M._prefix}dev`)) {
|
|
76
|
-
|
|
76
|
+
B.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const e = window.location.hostname;
|
|
80
80
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
81
|
-
|
|
81
|
+
B.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
B.set(!1);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -95,8 +95,8 @@ const M = class M {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
M._prefix = "data-", M._runtime = W;
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
98
|
+
let c = M;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
100
100
|
class h {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
@@ -105,7 +105,7 @@ class h {
|
|
|
105
105
|
* @param args 追加の引数
|
|
106
106
|
*/
|
|
107
107
|
static info(t, ...e) {
|
|
108
|
-
|
|
108
|
+
B.isEnabled() && console.log && console.log(t, ...e);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -114,7 +114,7 @@ class h {
|
|
|
114
114
|
* @param args 追加の引数
|
|
115
115
|
*/
|
|
116
116
|
static warn(t, ...e) {
|
|
117
|
-
|
|
117
|
+
B.isEnabled() && console.warn && console.warn(t, ...e);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -126,7 +126,7 @@ class h {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class rt {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -220,16 +220,16 @@ const z = class z {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
z.ASYNC_QUEUE = new
|
|
224
|
-
let
|
|
225
|
-
class
|
|
223
|
+
z.ASYNC_QUEUE = new rt();
|
|
224
|
+
let P = z;
|
|
225
|
+
class tt {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return c.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class _ {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
c.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -247,7 +247,7 @@ class _ {
|
|
|
247
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
248
248
|
*/
|
|
249
249
|
static dialog(t) {
|
|
250
|
-
return
|
|
250
|
+
return P.enqueue(() => {
|
|
251
251
|
window.alert(t);
|
|
252
252
|
}, !0);
|
|
253
253
|
}
|
|
@@ -275,7 +275,7 @@ class _ {
|
|
|
275
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
276
276
|
*/
|
|
277
277
|
static confirm(t) {
|
|
278
|
-
return
|
|
278
|
+
return P.enqueue(() => window.confirm(t), !0);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* ダイアログを開きます。
|
|
@@ -283,7 +283,7 @@ class _ {
|
|
|
283
283
|
* @param element 開くダイアログのHTML要素
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
|
-
return
|
|
286
|
+
return P.enqueue(() => {
|
|
287
287
|
t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
@@ -293,7 +293,7 @@ class _ {
|
|
|
293
293
|
* @param element 閉じるダイアログのHTML要素
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
|
-
return
|
|
296
|
+
return P.enqueue(() => {
|
|
297
297
|
t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
@@ -304,7 +304,7 @@ class _ {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
-
return
|
|
307
|
+
return P.enqueue(() => {
|
|
308
308
|
if (t instanceof HTMLFormElement) {
|
|
309
309
|
t.setAttribute("data-message", e);
|
|
310
310
|
return;
|
|
@@ -322,21 +322,21 @@ class _ {
|
|
|
322
322
|
* @param parent メッセージをクリアする親要素
|
|
323
323
|
*/
|
|
324
324
|
static clearMessages(t) {
|
|
325
|
-
return
|
|
325
|
+
return P.enqueue(() => {
|
|
326
326
|
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
327
327
|
e.removeAttribute("data-message");
|
|
328
328
|
});
|
|
329
329
|
}, !0);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
const
|
|
333
|
-
function
|
|
332
|
+
const it = ["addErrorMessage", "clearMessages"];
|
|
333
|
+
function Z() {
|
|
334
334
|
const t = globalThis.window?.Haori;
|
|
335
|
-
return
|
|
335
|
+
return it.every(
|
|
336
336
|
(r) => typeof t?.[r] == "function"
|
|
337
|
-
) ? t :
|
|
337
|
+
) ? t : tt;
|
|
338
338
|
}
|
|
339
|
-
class
|
|
339
|
+
class m {
|
|
340
340
|
/**
|
|
341
341
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
342
342
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -347,7 +347,7 @@ class A {
|
|
|
347
347
|
*/
|
|
348
348
|
static getValues(t) {
|
|
349
349
|
const e = {};
|
|
350
|
-
return
|
|
350
|
+
return m.getPartValues(t, e);
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -358,32 +358,32 @@ class A {
|
|
|
358
358
|
* @returns values と同じオブジェクト
|
|
359
359
|
*/
|
|
360
360
|
static getPartValues(t, e) {
|
|
361
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${
|
|
361
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`), s = t.getAttribute(`${c.prefix}form-list`);
|
|
362
362
|
if (r) {
|
|
363
363
|
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && h.warn(
|
|
364
364
|
"Haori",
|
|
365
|
-
`Element cannot have both ${
|
|
365
|
+
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
366
366
|
);
|
|
367
367
|
for (const n of t.getChildElementFragments())
|
|
368
|
-
|
|
368
|
+
m.getPartValues(n, e);
|
|
369
369
|
} else if (i) {
|
|
370
370
|
const n = {};
|
|
371
371
|
for (const a of t.getChildElementFragments())
|
|
372
|
-
|
|
372
|
+
m.getPartValues(a, n);
|
|
373
373
|
Object.keys(n).length > 0 && (e[String(i)] = n), s && h.warn(
|
|
374
374
|
"Haori",
|
|
375
|
-
`Element cannot have both ${
|
|
375
|
+
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
376
376
|
);
|
|
377
377
|
} else if (s) {
|
|
378
378
|
const n = [];
|
|
379
379
|
for (const a of t.getChildElementFragments()) {
|
|
380
380
|
const o = {};
|
|
381
|
-
|
|
381
|
+
m.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
382
382
|
}
|
|
383
383
|
n.length > 0 && (e[String(s)] = n);
|
|
384
384
|
} else
|
|
385
385
|
for (const n of t.getChildElementFragments())
|
|
386
|
-
|
|
386
|
+
m.getPartValues(n, e);
|
|
387
387
|
return e;
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
@@ -396,7 +396,30 @@ class A {
|
|
|
396
396
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
397
397
|
*/
|
|
398
398
|
static setValues(t, e, r = !1) {
|
|
399
|
-
return
|
|
399
|
+
return m.setPartValues(t, e, null, r, !0);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
403
|
+
* フォーム bindingData からの内部同期に利用します。
|
|
404
|
+
*
|
|
405
|
+
* @param form フォームのElementFragment
|
|
406
|
+
* @param values フォームに設定する値のオブジェクト
|
|
407
|
+
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
408
|
+
* @returns Promise(DOMの更新が完了したら解決される)
|
|
409
|
+
*/
|
|
410
|
+
static syncValues(t, e, r = !1) {
|
|
411
|
+
return m.setPartValues(t, e, null, r, !1);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* 単一フラグメントへ値を設定します。
|
|
415
|
+
*
|
|
416
|
+
* @param fragment 対象フラグメント
|
|
417
|
+
* @param value 設定する値
|
|
418
|
+
* @param emitEvents input/change イベントを発火するかどうか
|
|
419
|
+
* @returns Promise(DOMの更新が完了したら解決される)
|
|
420
|
+
*/
|
|
421
|
+
static applyFragmentValue(t, e, r) {
|
|
422
|
+
return r ? t.setValue(e) : t.syncBindingValue(e);
|
|
400
423
|
}
|
|
401
424
|
/**
|
|
402
425
|
* フラグメント内にある各入力エレメントに値を設定します。
|
|
@@ -407,45 +430,53 @@ class A {
|
|
|
407
430
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
408
431
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
409
432
|
*/
|
|
410
|
-
static setPartValues(t, e, r = null, i = !1) {
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
if (!
|
|
414
|
-
const
|
|
415
|
-
|
|
433
|
+
static setPartValues(t, e, r = null, i = !1, s = !0) {
|
|
434
|
+
const n = [], a = t.getAttribute("name"), o = t.getAttribute(`${c.prefix}form-object`), d = t.getAttribute(`${c.prefix}form-list`), y = t.getAttribute(`${c.prefix}form-detach`);
|
|
435
|
+
if (a) {
|
|
436
|
+
if (!y || i) {
|
|
437
|
+
const b = e[String(a)];
|
|
438
|
+
d && Array.isArray(b) && r !== null ? n.push(
|
|
439
|
+
m.applyFragmentValue(t, b[r] ?? null, s)
|
|
440
|
+
) : typeof b > "u" || (typeof b == "string" || typeof b == "number" || typeof b == "boolean" || b === null ? n.push(m.applyFragmentValue(t, b, s)) : n.push(
|
|
441
|
+
m.applyFragmentValue(t, String(b), s)
|
|
442
|
+
));
|
|
416
443
|
}
|
|
417
|
-
} else if (
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
for (const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
444
|
+
} else if (o) {
|
|
445
|
+
const b = e[String(o)];
|
|
446
|
+
if (b && typeof b == "object")
|
|
447
|
+
for (const A of t.getChildElementFragments())
|
|
448
|
+
n.push(
|
|
449
|
+
m.setPartValues(
|
|
450
|
+
A,
|
|
451
|
+
b,
|
|
425
452
|
null,
|
|
426
|
-
i
|
|
453
|
+
i,
|
|
454
|
+
s
|
|
427
455
|
)
|
|
428
456
|
);
|
|
429
|
-
} else if (
|
|
430
|
-
const
|
|
431
|
-
if (Array.isArray(
|
|
432
|
-
const
|
|
433
|
-
for (let
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
i
|
|
457
|
+
} else if (d) {
|
|
458
|
+
const b = e[String(d)];
|
|
459
|
+
if (Array.isArray(b)) {
|
|
460
|
+
const A = t.getChildElementFragments();
|
|
461
|
+
for (let S = 0; S < A.length; S++) {
|
|
462
|
+
const l = A[S];
|
|
463
|
+
b.length > S ? n.push(
|
|
464
|
+
m.setPartValues(
|
|
465
|
+
l,
|
|
466
|
+
b[S],
|
|
467
|
+
S,
|
|
468
|
+
i,
|
|
469
|
+
s
|
|
441
470
|
)
|
|
442
|
-
) :
|
|
471
|
+
) : n.push(m.setPartValues(l, {}, S, i, s));
|
|
443
472
|
}
|
|
444
473
|
}
|
|
445
474
|
} else
|
|
446
|
-
for (const
|
|
447
|
-
|
|
448
|
-
|
|
475
|
+
for (const b of t.getChildElementFragments())
|
|
476
|
+
n.push(
|
|
477
|
+
m.setPartValues(b, e, null, i, s)
|
|
478
|
+
);
|
|
479
|
+
return Promise.all(n).then(() => {
|
|
449
480
|
});
|
|
450
481
|
}
|
|
451
482
|
/**
|
|
@@ -456,10 +487,10 @@ class A {
|
|
|
456
487
|
* @returns すべての初期化処理が完了するPromise
|
|
457
488
|
*/
|
|
458
489
|
static async reset(t) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
]), await
|
|
490
|
+
m.clearValues(t), await Promise.all([
|
|
491
|
+
m.clearMessages(t),
|
|
492
|
+
m.clearEachClones(t)
|
|
493
|
+
]), await P.enqueue(() => {
|
|
463
494
|
const e = t.getTarget();
|
|
464
495
|
if (e instanceof HTMLFormElement)
|
|
465
496
|
e.reset();
|
|
@@ -470,7 +501,7 @@ class A {
|
|
|
470
501
|
s.appendChild(e), s.reset(), r.insertBefore(e, i);
|
|
471
502
|
}
|
|
472
503
|
}
|
|
473
|
-
}), await
|
|
504
|
+
}), await x.evaluateAll(t);
|
|
474
505
|
}
|
|
475
506
|
/**
|
|
476
507
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -480,9 +511,9 @@ class A {
|
|
|
480
511
|
*/
|
|
481
512
|
static clearEachClones(t) {
|
|
482
513
|
const e = [], r = (s) => {
|
|
483
|
-
if (s.hasAttribute(`${
|
|
514
|
+
if (s.hasAttribute(`${c.prefix}each`))
|
|
484
515
|
for (const n of s.getChildElementFragments()) {
|
|
485
|
-
const a = n.hasAttribute(`${
|
|
516
|
+
const a = n.hasAttribute(`${c.prefix}each-before`), o = n.hasAttribute(`${c.prefix}each-after`);
|
|
486
517
|
!a && !o && e.push(n.remove());
|
|
487
518
|
}
|
|
488
519
|
}, i = (s) => {
|
|
@@ -504,7 +535,7 @@ class A {
|
|
|
504
535
|
static clearValues(t) {
|
|
505
536
|
t.clearValue();
|
|
506
537
|
for (const e of t.getChildElementFragments())
|
|
507
|
-
|
|
538
|
+
m.clearValues(e);
|
|
508
539
|
}
|
|
509
540
|
/**
|
|
510
541
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -513,7 +544,7 @@ class A {
|
|
|
513
544
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
514
545
|
*/
|
|
515
546
|
static clearMessages(t) {
|
|
516
|
-
return
|
|
547
|
+
return Z().clearMessages(
|
|
517
548
|
t.getTarget()
|
|
518
549
|
);
|
|
519
550
|
}
|
|
@@ -527,7 +558,7 @@ class A {
|
|
|
527
558
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
528
559
|
*/
|
|
529
560
|
static addErrorMessage(t, e, r) {
|
|
530
|
-
const i = [], s =
|
|
561
|
+
const i = [], s = Z(), n = m.findFragmentsByKey(t, e);
|
|
531
562
|
return n.forEach((a) => {
|
|
532
563
|
i.push(
|
|
533
564
|
s.addErrorMessage(a.getTarget(), r)
|
|
@@ -545,7 +576,7 @@ class A {
|
|
|
545
576
|
* @returns 一致するフラグメントの配列
|
|
546
577
|
*/
|
|
547
578
|
static findFragmentsByKey(t, e) {
|
|
548
|
-
return
|
|
579
|
+
return m.findFragmentByKeyParts(t, e.split("."));
|
|
549
580
|
}
|
|
550
581
|
/**
|
|
551
582
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -557,23 +588,23 @@ class A {
|
|
|
557
588
|
*/
|
|
558
589
|
static findFragmentByKeyParts(t, e) {
|
|
559
590
|
const r = [], i = e[0];
|
|
560
|
-
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${
|
|
561
|
-
e.length > 1 && t.getAttribute(`${
|
|
562
|
-
r.push(...
|
|
591
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${c.prefix}form-object`))
|
|
592
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
593
|
+
r.push(...m.findFragmentByKeyParts(n, e.slice(1)));
|
|
563
594
|
});
|
|
564
|
-
else if (t.hasAttribute(`${
|
|
595
|
+
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
565
596
|
if (e.length > 1) {
|
|
566
|
-
const s = t.getAttribute(`${
|
|
597
|
+
const s = t.getAttribute(`${c.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
567
598
|
if (n !== -1 && a !== -1 && n < a) {
|
|
568
599
|
const o = i.substring(0, n);
|
|
569
600
|
if (s === o) {
|
|
570
|
-
const
|
|
571
|
-
if (isNaN(
|
|
601
|
+
const d = i.substring(n + 1, a), y = Number(d);
|
|
602
|
+
if (isNaN(y))
|
|
572
603
|
h.error("Haori", `Invalid index: ${i}`);
|
|
573
604
|
else {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
...
|
|
605
|
+
const b = t.getChildElementFragments().filter((A) => A.hasAttribute(`${c.prefix}row`));
|
|
606
|
+
y < b.length && r.push(
|
|
607
|
+
...m.findFragmentByKeyParts(b[y], e.slice(1))
|
|
577
608
|
);
|
|
578
609
|
}
|
|
579
610
|
}
|
|
@@ -581,7 +612,7 @@ class A {
|
|
|
581
612
|
}
|
|
582
613
|
} else
|
|
583
614
|
t.getChildElementFragments().forEach((s) => {
|
|
584
|
-
r.push(...
|
|
615
|
+
r.push(...m.findFragmentByKeyParts(s, e));
|
|
585
616
|
});
|
|
586
617
|
return r;
|
|
587
618
|
}
|
|
@@ -598,7 +629,7 @@ class A {
|
|
|
598
629
|
return r ? this.getFormFragment(r) : null;
|
|
599
630
|
}
|
|
600
631
|
}
|
|
601
|
-
const
|
|
632
|
+
const R = class R {
|
|
602
633
|
/**
|
|
603
634
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
604
635
|
*
|
|
@@ -725,8 +756,8 @@ return (${t});`;
|
|
|
725
756
|
break;
|
|
726
757
|
}
|
|
727
758
|
case "[": {
|
|
728
|
-
const
|
|
729
|
-
r.push(
|
|
759
|
+
const d = this.startsMemberAccess(i) ? "member" : "array";
|
|
760
|
+
r.push(d);
|
|
730
761
|
break;
|
|
731
762
|
}
|
|
732
763
|
case "]": {
|
|
@@ -962,9 +993,9 @@ return (${t});`;
|
|
|
962
993
|
get: (n, a, o) => {
|
|
963
994
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
964
995
|
return;
|
|
965
|
-
const
|
|
966
|
-
return typeof a == "symbol" ?
|
|
967
|
-
|
|
996
|
+
const d = Reflect.get(n, a, o);
|
|
997
|
+
return typeof a == "symbol" ? d : this.wrapBoundValue(
|
|
998
|
+
d,
|
|
968
999
|
e
|
|
969
1000
|
);
|
|
970
1001
|
},
|
|
@@ -974,12 +1005,12 @@ return (${t});`;
|
|
|
974
1005
|
return Reflect.getOwnPropertyDescriptor(n, a);
|
|
975
1006
|
},
|
|
976
1007
|
apply: (n, a, o) => {
|
|
977
|
-
const
|
|
1008
|
+
const d = Reflect.apply(
|
|
978
1009
|
n,
|
|
979
1010
|
a,
|
|
980
1011
|
o
|
|
981
1012
|
);
|
|
982
|
-
return this.isIteratorLike(
|
|
1013
|
+
return this.isIteratorLike(d) ? d : this.wrapBoundValue(d, e);
|
|
983
1014
|
},
|
|
984
1015
|
construct: (n, a, o) => this.wrapBoundValue(
|
|
985
1016
|
Reflect.construct(
|
|
@@ -1091,7 +1122,7 @@ return (${t});`;
|
|
|
1091
1122
|
return !1;
|
|
1092
1123
|
}
|
|
1093
1124
|
};
|
|
1094
|
-
|
|
1125
|
+
R.FORBIDDEN_NAMES = [
|
|
1095
1126
|
// グローバルオブジェクト
|
|
1096
1127
|
"window",
|
|
1097
1128
|
"self",
|
|
@@ -1123,19 +1154,19 @@ P.FORBIDDEN_NAMES = [
|
|
|
1123
1154
|
"sessionStorage",
|
|
1124
1155
|
"IndexedDB",
|
|
1125
1156
|
"history"
|
|
1126
|
-
],
|
|
1127
|
-
...
|
|
1128
|
-
(t) => !
|
|
1157
|
+
], R.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], R.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), R.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1158
|
+
...R.FORBIDDEN_NAMES.filter(
|
|
1159
|
+
(t) => !R.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1129
1160
|
),
|
|
1130
1161
|
"constructor",
|
|
1131
1162
|
"__proto__",
|
|
1132
1163
|
"prototype",
|
|
1133
|
-
...
|
|
1134
|
-
]),
|
|
1164
|
+
...R.STRICT_FORBIDDEN_NAMES
|
|
1165
|
+
]), R.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1135
1166
|
"constructor",
|
|
1136
1167
|
"__proto__",
|
|
1137
1168
|
"prototype"
|
|
1138
|
-
]),
|
|
1169
|
+
]), R.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1139
1170
|
"await",
|
|
1140
1171
|
"break",
|
|
1141
1172
|
"case",
|
|
@@ -1169,8 +1200,8 @@ P.FORBIDDEN_NAMES = [
|
|
|
1169
1200
|
"while",
|
|
1170
1201
|
"with",
|
|
1171
1202
|
"yield"
|
|
1172
|
-
]),
|
|
1173
|
-
let j =
|
|
1203
|
+
]), R.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1204
|
+
let j = R;
|
|
1174
1205
|
const C = class C {
|
|
1175
1206
|
/**
|
|
1176
1207
|
* フラグメントのコンストラクタ。
|
|
@@ -1219,7 +1250,7 @@ const C = class C {
|
|
|
1219
1250
|
return Promise.resolve();
|
|
1220
1251
|
if (this.parent) {
|
|
1221
1252
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1222
|
-
return
|
|
1253
|
+
return P.enqueue(() => {
|
|
1223
1254
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1224
1255
|
}).finally(() => {
|
|
1225
1256
|
t.skipMutationNodes = e;
|
|
@@ -1227,7 +1258,7 @@ const C = class C {
|
|
|
1227
1258
|
} else {
|
|
1228
1259
|
const t = this.target.parentNode;
|
|
1229
1260
|
if (t)
|
|
1230
|
-
return
|
|
1261
|
+
return P.enqueue(() => {
|
|
1231
1262
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1232
1263
|
});
|
|
1233
1264
|
this.mounted = !1;
|
|
@@ -1244,7 +1275,7 @@ const C = class C {
|
|
|
1244
1275
|
return Promise.resolve();
|
|
1245
1276
|
if (this.parent) {
|
|
1246
1277
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1247
|
-
return
|
|
1278
|
+
return P.enqueue(() => {
|
|
1248
1279
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1249
1280
|
}).finally(() => {
|
|
1250
1281
|
t.skipMutationNodes = e;
|
|
@@ -1303,8 +1334,8 @@ const C = class C {
|
|
|
1303
1334
|
}
|
|
1304
1335
|
};
|
|
1305
1336
|
C.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1306
|
-
let
|
|
1307
|
-
class D extends
|
|
1337
|
+
let N = C;
|
|
1338
|
+
class D extends N {
|
|
1308
1339
|
/**
|
|
1309
1340
|
* エレメントフラグメントのコンストラクタ。
|
|
1310
1341
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1330,11 +1361,11 @@ class D extends T {
|
|
|
1330
1361
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
|
|
1331
1362
|
const r = t.getAttribute(e);
|
|
1332
1363
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1333
|
-
const i = new
|
|
1364
|
+
const i = new U(e, r);
|
|
1334
1365
|
this.attributeMap.set(e, i);
|
|
1335
1366
|
}
|
|
1336
1367
|
}), t.childNodes.forEach((e) => {
|
|
1337
|
-
const r =
|
|
1368
|
+
const r = N.get(e);
|
|
1338
1369
|
r.setParent(this), this.children.push(r);
|
|
1339
1370
|
});
|
|
1340
1371
|
}
|
|
@@ -1496,25 +1527,46 @@ class D extends T {
|
|
|
1496
1527
|
* @returns エレメントの更新のPromise
|
|
1497
1528
|
*/
|
|
1498
1529
|
setValue(t) {
|
|
1530
|
+
return this.applyValue(t, !0);
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* 入力エレメントに値をイベントなしで設定します。
|
|
1534
|
+
* フォームの bindingData 反映時に内部同期として利用します。
|
|
1535
|
+
*
|
|
1536
|
+
* @param value 値
|
|
1537
|
+
* @returns エレメントの更新のPromise
|
|
1538
|
+
*/
|
|
1539
|
+
syncBindingValue(t) {
|
|
1540
|
+
return this.applyValue(t, !1);
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* 入力エレメントに値を設定します。
|
|
1544
|
+
* 必要に応じて入力系イベントも発火します。
|
|
1545
|
+
*
|
|
1546
|
+
* @param value 値
|
|
1547
|
+
* @param dispatchEvents input/change イベントを発火するかどうか
|
|
1548
|
+
* @returns エレメントの更新のPromise
|
|
1549
|
+
*/
|
|
1550
|
+
applyValue(t, e) {
|
|
1499
1551
|
if (this.skipChangeValue || this.value === t)
|
|
1500
1552
|
return Promise.resolve();
|
|
1501
|
-
const
|
|
1502
|
-
if (
|
|
1503
|
-
const
|
|
1504
|
-
let
|
|
1505
|
-
return
|
|
1506
|
-
|
|
1553
|
+
const r = this.getTarget();
|
|
1554
|
+
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1555
|
+
const i = this.getAttribute("value"), s = r.type === "checkbox" && i === "true";
|
|
1556
|
+
let n;
|
|
1557
|
+
return s ? n = t === !0 || t === "true" : i === "false" ? n = t === !1 : n = i === String(t), this.value = s ? n : n ? t : null, r.checked === n ? Promise.resolve() : (this.skipChangeValue = !0, P.enqueue(() => {
|
|
1558
|
+
r.checked = n, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1507
1559
|
}).finally(() => {
|
|
1508
1560
|
this.skipChangeValue = !1;
|
|
1509
1561
|
}));
|
|
1510
|
-
} else return
|
|
1511
|
-
|
|
1562
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, P.enqueue(() => {
|
|
1563
|
+
r.value = t === null ? "" : String(t), e && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
1512
1564
|
}).finally(() => {
|
|
1513
1565
|
this.skipChangeValue = !1;
|
|
1514
1566
|
})) : (h.warn(
|
|
1515
1567
|
"[Haori]",
|
|
1516
1568
|
"setValue is not supported for this element type.",
|
|
1517
|
-
|
|
1569
|
+
r
|
|
1518
1570
|
), Promise.resolve());
|
|
1519
1571
|
}
|
|
1520
1572
|
/**
|
|
@@ -1539,15 +1591,16 @@ class D extends T {
|
|
|
1539
1591
|
syncValue() {
|
|
1540
1592
|
const t = this.getTarget();
|
|
1541
1593
|
if (t instanceof HTMLInputElement)
|
|
1542
|
-
if (t.type === "checkbox" || t.type === "radio")
|
|
1594
|
+
if (t.type === "checkbox" || t.type === "radio") {
|
|
1595
|
+
const e = t.type === "checkbox" && t.value === "true";
|
|
1543
1596
|
if (t.checked) {
|
|
1544
|
-
const
|
|
1545
|
-
e
|
|
1597
|
+
const r = t.value;
|
|
1598
|
+
e ? this.value = !0 : r === "false" ? this.value = !1 : this.value = r;
|
|
1546
1599
|
} else {
|
|
1547
|
-
const
|
|
1548
|
-
e
|
|
1600
|
+
const r = t.value;
|
|
1601
|
+
e ? this.value = !1 : r === "false" ? this.value = !0 : this.value = null;
|
|
1549
1602
|
}
|
|
1550
|
-
else
|
|
1603
|
+
} else
|
|
1551
1604
|
this.value = t.value;
|
|
1552
1605
|
else t instanceof HTMLTextAreaElement ? this.value = t.value : t instanceof HTMLSelectElement && (this.value = t.value);
|
|
1553
1606
|
}
|
|
@@ -1565,10 +1618,10 @@ class D extends T {
|
|
|
1565
1618
|
return Promise.resolve();
|
|
1566
1619
|
if (e === null)
|
|
1567
1620
|
return this.removeAttribute(t);
|
|
1568
|
-
const r = new
|
|
1621
|
+
const r = new U(t, e);
|
|
1569
1622
|
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1570
1623
|
const i = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1571
|
-
return
|
|
1624
|
+
return P.enqueue(() => {
|
|
1572
1625
|
if (s === null || s === !1)
|
|
1573
1626
|
i.removeAttribute(t);
|
|
1574
1627
|
else {
|
|
@@ -1590,7 +1643,7 @@ class D extends T {
|
|
|
1590
1643
|
return Promise.resolve();
|
|
1591
1644
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1592
1645
|
const e = this.getTarget();
|
|
1593
|
-
return
|
|
1646
|
+
return P.enqueue(() => {
|
|
1594
1647
|
e.removeAttribute(t);
|
|
1595
1648
|
}).finally(() => {
|
|
1596
1649
|
this.skipMutationAttributes = !1;
|
|
@@ -1608,7 +1661,7 @@ class D extends T {
|
|
|
1608
1661
|
if (e === void 0)
|
|
1609
1662
|
return null;
|
|
1610
1663
|
const r = e.evaluate(this.getBindingData());
|
|
1611
|
-
return r.length === 1 ? r[0] :
|
|
1664
|
+
return r.length === 1 ? r[0] : I.joinEvaluateResults(r);
|
|
1612
1665
|
}
|
|
1613
1666
|
/**
|
|
1614
1667
|
* 属性の生の値を取得します。
|
|
@@ -1651,7 +1704,7 @@ class D extends T {
|
|
|
1651
1704
|
const i = e ? r.nextSibling : r;
|
|
1652
1705
|
let s = e ? r.nextSibling : r;
|
|
1653
1706
|
for (; s !== null; ) {
|
|
1654
|
-
const n =
|
|
1707
|
+
const n = N.get(s);
|
|
1655
1708
|
if (n !== null) {
|
|
1656
1709
|
const a = this.children.indexOf(n);
|
|
1657
1710
|
if (a !== -1)
|
|
@@ -1683,32 +1736,32 @@ class D extends T {
|
|
|
1683
1736
|
const n = t.getParent() === this;
|
|
1684
1737
|
let a = -1, o = -1;
|
|
1685
1738
|
n && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1688
|
-
let
|
|
1739
|
+
const d = t.getParent();
|
|
1740
|
+
d !== null && d.removeChild(t);
|
|
1741
|
+
let y = r === void 0 ? e?.getTarget() || null : r;
|
|
1689
1742
|
if (e === null)
|
|
1690
1743
|
this.children.push(t);
|
|
1691
1744
|
else {
|
|
1692
|
-
let
|
|
1693
|
-
if (n ? a !== -1 && a < o ?
|
|
1694
|
-
const
|
|
1745
|
+
let A;
|
|
1746
|
+
if (n ? a !== -1 && a < o ? A = o - 1 : A = o : A = this.children.indexOf(e), A === -1) {
|
|
1747
|
+
const S = this.resolveInsertionPointFromDom(
|
|
1695
1748
|
e,
|
|
1696
1749
|
!1
|
|
1697
1750
|
);
|
|
1698
|
-
|
|
1751
|
+
S === null ? (h.warn(
|
|
1699
1752
|
"[Haori]",
|
|
1700
1753
|
"Reference child not found in children.",
|
|
1701
1754
|
e
|
|
1702
|
-
), this.children.push(t)) : (this.children.splice(
|
|
1755
|
+
), this.children.push(t)) : (this.children.splice(S.index, 0, t), y = S.referenceNode);
|
|
1703
1756
|
} else
|
|
1704
|
-
this.children.splice(
|
|
1757
|
+
this.children.splice(A, 0, t);
|
|
1705
1758
|
}
|
|
1706
1759
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1707
|
-
const
|
|
1708
|
-
return this.skipMutationNodes = !0,
|
|
1709
|
-
this.target.insertBefore(t.getTarget(),
|
|
1760
|
+
const b = this.skipMutationNodes;
|
|
1761
|
+
return this.skipMutationNodes = !0, P.enqueue(() => {
|
|
1762
|
+
this.target.insertBefore(t.getTarget(), y);
|
|
1710
1763
|
}).finally(() => {
|
|
1711
|
-
this.skipMutationNodes =
|
|
1764
|
+
this.skipMutationNodes = b;
|
|
1712
1765
|
});
|
|
1713
1766
|
}
|
|
1714
1767
|
/**
|
|
@@ -1779,7 +1832,7 @@ class D extends T {
|
|
|
1779
1832
|
* @returns エレメントの非表示のPromise
|
|
1780
1833
|
*/
|
|
1781
1834
|
hide() {
|
|
1782
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1835
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${c.prefix}if-false`, ""), Promise.resolve();
|
|
1783
1836
|
}
|
|
1784
1837
|
/**
|
|
1785
1838
|
* エレメントを表示します。
|
|
@@ -1787,7 +1840,7 @@ class D extends T {
|
|
|
1787
1840
|
* @return エレメントの表示のPromise
|
|
1788
1841
|
*/
|
|
1789
1842
|
show() {
|
|
1790
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1843
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${c.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1791
1844
|
}
|
|
1792
1845
|
/**
|
|
1793
1846
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1803,7 +1856,7 @@ class D extends T {
|
|
|
1803
1856
|
return e === null ? null : e.closestByAttribute(t);
|
|
1804
1857
|
}
|
|
1805
1858
|
}
|
|
1806
|
-
class L extends
|
|
1859
|
+
class L extends N {
|
|
1807
1860
|
/**
|
|
1808
1861
|
* テキストフラグメントのコンストラクタ。
|
|
1809
1862
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1811,7 +1864,7 @@ class L extends T {
|
|
|
1811
1864
|
* @param target 対象テキストノード
|
|
1812
1865
|
*/
|
|
1813
1866
|
constructor(t) {
|
|
1814
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1867
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new I(this.text);
|
|
1815
1868
|
}
|
|
1816
1869
|
/**
|
|
1817
1870
|
* フラグメントをクローンします。
|
|
@@ -1837,7 +1890,7 @@ class L extends T {
|
|
|
1837
1890
|
* @returns 更新のPromise
|
|
1838
1891
|
*/
|
|
1839
1892
|
setContent(t) {
|
|
1840
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1893
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new I(t), this.evaluate());
|
|
1841
1894
|
}
|
|
1842
1895
|
/**
|
|
1843
1896
|
* フラグメントを評価します。
|
|
@@ -1847,10 +1900,10 @@ class L extends T {
|
|
|
1847
1900
|
evaluate() {
|
|
1848
1901
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1849
1902
|
new Error("Parent fragment is required for raw evaluation")
|
|
1850
|
-
) :
|
|
1903
|
+
) : P.enqueue(() => {
|
|
1851
1904
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1852
1905
|
this.parent.getBindingData()
|
|
1853
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1906
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = I.joinEvaluateResults(
|
|
1854
1907
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1855
1908
|
) : this.target.textContent = this.text;
|
|
1856
1909
|
}).finally(() => {
|
|
@@ -1858,7 +1911,7 @@ class L extends T {
|
|
|
1858
1911
|
});
|
|
1859
1912
|
}
|
|
1860
1913
|
}
|
|
1861
|
-
class Y extends
|
|
1914
|
+
class Y extends N {
|
|
1862
1915
|
/**
|
|
1863
1916
|
* コメントフラグメントのコンストラクタ。
|
|
1864
1917
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1892,14 +1945,14 @@ class Y extends T {
|
|
|
1892
1945
|
* @return 更新のPromise
|
|
1893
1946
|
*/
|
|
1894
1947
|
setContent(t) {
|
|
1895
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
1948
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, P.enqueue(() => {
|
|
1896
1949
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
1897
1950
|
}).finally(() => {
|
|
1898
1951
|
this.skipMutation = !1;
|
|
1899
1952
|
}));
|
|
1900
1953
|
}
|
|
1901
1954
|
}
|
|
1902
|
-
const
|
|
1955
|
+
const G = class G {
|
|
1903
1956
|
/**
|
|
1904
1957
|
* コンストラクタ。
|
|
1905
1958
|
*
|
|
@@ -1907,7 +1960,7 @@ const K = class K {
|
|
|
1907
1960
|
*/
|
|
1908
1961
|
constructor(t) {
|
|
1909
1962
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1910
|
-
const e = [...t.matchAll(
|
|
1963
|
+
const e = [...t.matchAll(G.PLACEHOLDER_REGEX)];
|
|
1911
1964
|
let r = 0, i = !1, s = !1;
|
|
1912
1965
|
for (const n of e) {
|
|
1913
1966
|
n.index > r && this.contents.push({
|
|
@@ -1982,9 +2035,9 @@ const K = class K {
|
|
|
1982
2035
|
}), e;
|
|
1983
2036
|
}
|
|
1984
2037
|
};
|
|
1985
|
-
|
|
1986
|
-
let
|
|
1987
|
-
const
|
|
2038
|
+
G.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2039
|
+
let I = G;
|
|
2040
|
+
const K = class K extends I {
|
|
1988
2041
|
/**
|
|
1989
2042
|
* コンストラクタ。
|
|
1990
2043
|
*
|
|
@@ -1992,7 +2045,7 @@ const J = class J extends $ {
|
|
|
1992
2045
|
* @param text 属性値
|
|
1993
2046
|
*/
|
|
1994
2047
|
constructor(t, e) {
|
|
1995
|
-
super(e), this.forceEvaluation =
|
|
2048
|
+
super(e), this.forceEvaluation = K.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
1996
2049
|
}
|
|
1997
2050
|
/**
|
|
1998
2051
|
* 強制評価フラグを取得します。
|
|
@@ -2033,13 +2086,13 @@ const J = class J extends $ {
|
|
|
2033
2086
|
), [e[0]]) : e;
|
|
2034
2087
|
}
|
|
2035
2088
|
};
|
|
2036
|
-
|
|
2089
|
+
K.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2037
2090
|
"data-if",
|
|
2038
2091
|
"hor-if",
|
|
2039
2092
|
"data-each",
|
|
2040
2093
|
"hor-each"
|
|
2041
2094
|
];
|
|
2042
|
-
let
|
|
2095
|
+
let U = K;
|
|
2043
2096
|
class v {
|
|
2044
2097
|
/**
|
|
2045
2098
|
* カスタムイベントを発火します。
|
|
@@ -2121,9 +2174,9 @@ class v {
|
|
|
2121
2174
|
*/
|
|
2122
2175
|
static bindChange(t, e, r, i = "other") {
|
|
2123
2176
|
const s = [], n = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...n, ...a]);
|
|
2124
|
-
for (const
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2177
|
+
for (const d of o) {
|
|
2178
|
+
const y = e?.[d], b = r[d];
|
|
2179
|
+
y !== b && s.push(d);
|
|
2127
2180
|
}
|
|
2128
2181
|
v.dispatch(t, "bindchange", {
|
|
2129
2182
|
previous: e || {},
|
|
@@ -2248,7 +2301,7 @@ class v {
|
|
|
2248
2301
|
});
|
|
2249
2302
|
}
|
|
2250
2303
|
}
|
|
2251
|
-
const
|
|
2304
|
+
const st = [
|
|
2252
2305
|
"addErrorMessage",
|
|
2253
2306
|
"closeDialog",
|
|
2254
2307
|
"confirm",
|
|
@@ -2258,25 +2311,25 @@ const it = [
|
|
|
2258
2311
|
];
|
|
2259
2312
|
function X() {
|
|
2260
2313
|
const t = globalThis.window?.Haori;
|
|
2261
|
-
return
|
|
2314
|
+
return st.every(
|
|
2262
2315
|
(r) => typeof t?.[r] == "function"
|
|
2263
|
-
) ? t :
|
|
2316
|
+
) ? t : tt;
|
|
2264
2317
|
}
|
|
2265
|
-
const
|
|
2266
|
-
function
|
|
2267
|
-
return
|
|
2318
|
+
const nt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2319
|
+
function at(F) {
|
|
2320
|
+
return nt.has(F.toUpperCase());
|
|
2268
2321
|
}
|
|
2269
|
-
function
|
|
2322
|
+
function ot(F, t) {
|
|
2270
2323
|
for (const [e, r] of Object.entries(t))
|
|
2271
|
-
r !== void 0 && (r === null ?
|
|
2272
|
-
|
|
2273
|
-
}) : typeof r == "object" || typeof r == "function" ?
|
|
2324
|
+
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2325
|
+
F.append(e, String(i));
|
|
2326
|
+
}) : typeof r == "object" || typeof r == "function" ? F.append(e, JSON.stringify(r)) : F.append(e, String(r)));
|
|
2274
2327
|
}
|
|
2275
|
-
function
|
|
2276
|
-
const e = new URL(
|
|
2277
|
-
return
|
|
2328
|
+
function lt(F, t) {
|
|
2329
|
+
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2330
|
+
return ot(r, t), e.search = r.toString(), e.toString();
|
|
2278
2331
|
}
|
|
2279
|
-
const
|
|
2332
|
+
const u = class u {
|
|
2280
2333
|
/**
|
|
2281
2334
|
* イベント属性名を正しく生成します。
|
|
2282
2335
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2285,7 +2338,7 @@ const c = class c {
|
|
|
2285
2338
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2286
2339
|
*/
|
|
2287
2340
|
static attrName(t, e, r = !1) {
|
|
2288
|
-
return t ? `${
|
|
2341
|
+
return t ? `${c.prefix}${t}-${e}` : r ? `${c.prefix}fetch-${e}` : `${c.prefix}${e}`;
|
|
2289
2342
|
}
|
|
2290
2343
|
/**
|
|
2291
2344
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2296,7 +2349,7 @@ const c = class c {
|
|
|
2296
2349
|
*/
|
|
2297
2350
|
static resolveDataParamString(t, e) {
|
|
2298
2351
|
return t.replace(
|
|
2299
|
-
|
|
2352
|
+
u.DATA_PLACEHOLDER_REGEX,
|
|
2300
2353
|
(r, i, s) => {
|
|
2301
2354
|
const n = j.evaluate(
|
|
2302
2355
|
i ?? s ?? "",
|
|
@@ -2353,7 +2406,7 @@ const c = class c {
|
|
|
2353
2406
|
static stringifyJsonTemplateStringContent(t) {
|
|
2354
2407
|
if (t == null || Number.isNaN(t))
|
|
2355
2408
|
return "";
|
|
2356
|
-
const e = typeof t == "object" ?
|
|
2409
|
+
const e = typeof t == "object" ? u.stringifyJsonTemplateValue(t) : String(t);
|
|
2357
2410
|
return JSON.stringify(e).slice(1, -1);
|
|
2358
2411
|
}
|
|
2359
2412
|
/**
|
|
@@ -2365,13 +2418,13 @@ const c = class c {
|
|
|
2365
2418
|
*/
|
|
2366
2419
|
static resolveDataJsonString(t, e) {
|
|
2367
2420
|
return t.replace(
|
|
2368
|
-
|
|
2421
|
+
u.DATA_PLACEHOLDER_REGEX,
|
|
2369
2422
|
(r, i, s, n) => {
|
|
2370
2423
|
const a = j.evaluate(
|
|
2371
2424
|
i ?? s ?? "",
|
|
2372
2425
|
e
|
|
2373
2426
|
);
|
|
2374
|
-
return
|
|
2427
|
+
return u.isJsonStringContext(t, n) ? u.stringifyJsonTemplateStringContent(a) : u.stringifyJsonTemplateValue(a);
|
|
2375
2428
|
}
|
|
2376
2429
|
);
|
|
2377
2430
|
}
|
|
@@ -2389,13 +2442,13 @@ const c = class c {
|
|
|
2389
2442
|
if (typeof i != "string" || r === null)
|
|
2390
2443
|
return null;
|
|
2391
2444
|
const s = r.trim();
|
|
2392
|
-
return
|
|
2393
|
-
|
|
2445
|
+
return u.SINGLE_PLACEHOLDER_REGEX.test(s) ? x.parseDataBind(i) : s.startsWith("{") || s.startsWith("[") ? x.parseDataBind(
|
|
2446
|
+
u.resolveDataJsonString(
|
|
2394
2447
|
r,
|
|
2395
2448
|
t.getBindingData()
|
|
2396
2449
|
)
|
|
2397
|
-
) :
|
|
2398
|
-
|
|
2450
|
+
) : x.parseDataBind(
|
|
2451
|
+
u.resolveDataParamString(r, t.getBindingData())
|
|
2399
2452
|
);
|
|
2400
2453
|
}
|
|
2401
2454
|
/**
|
|
@@ -2410,29 +2463,29 @@ const c = class c {
|
|
|
2410
2463
|
targetFragment: t
|
|
2411
2464
|
};
|
|
2412
2465
|
if (e) {
|
|
2413
|
-
if (t.hasAttribute(
|
|
2414
|
-
|
|
2415
|
-
)), t.hasAttribute(
|
|
2466
|
+
if (t.hasAttribute(u.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(u.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2467
|
+
u.attrName(e, "confirm")
|
|
2468
|
+
)), t.hasAttribute(u.attrName(e, "data")) && (r.data = u.resolveDataAttribute(
|
|
2416
2469
|
t,
|
|
2417
|
-
|
|
2418
|
-
)), t.hasAttribute(
|
|
2419
|
-
const
|
|
2420
|
-
|
|
2470
|
+
u.attrName(e, "data")
|
|
2471
|
+
)), t.hasAttribute(u.attrName(e, "form"))) {
|
|
2472
|
+
const l = t.getRawAttribute(
|
|
2473
|
+
u.attrName(e, "form")
|
|
2421
2474
|
);
|
|
2422
|
-
if (
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2425
|
-
|
|
2475
|
+
if (l) {
|
|
2476
|
+
const f = document.body.querySelector(l);
|
|
2477
|
+
f !== null ? r.formFragment = m.getFormFragment(
|
|
2478
|
+
N.get(f)
|
|
2426
2479
|
) : h.error(
|
|
2427
2480
|
"Haori",
|
|
2428
|
-
`Form element not found: ${
|
|
2481
|
+
`Form element not found: ${l} (${u.attrName(e, "form")})`
|
|
2429
2482
|
);
|
|
2430
2483
|
} else
|
|
2431
|
-
r.formFragment =
|
|
2432
|
-
} else e === "change" && (r.formFragment =
|
|
2433
|
-
if (t.hasAttribute(`${
|
|
2434
|
-
const
|
|
2435
|
-
`${
|
|
2484
|
+
r.formFragment = m.getFormFragment(t);
|
|
2485
|
+
} else e === "change" && (r.formFragment = m.getFormFragment(t));
|
|
2486
|
+
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
2487
|
+
const l = t.getRawAttribute(
|
|
2488
|
+
`${c.prefix}${e}-before-run`
|
|
2436
2489
|
);
|
|
2437
2490
|
try {
|
|
2438
2491
|
r.beforeCallback = new Function(
|
|
@@ -2440,70 +2493,70 @@ const c = class c {
|
|
|
2440
2493
|
"fetchOptions",
|
|
2441
2494
|
`
|
|
2442
2495
|
"use strict";
|
|
2443
|
-
${
|
|
2496
|
+
${l}
|
|
2444
2497
|
`
|
|
2445
2498
|
);
|
|
2446
|
-
} catch (
|
|
2447
|
-
h.error("Haori", `Invalid before script: ${
|
|
2499
|
+
} catch (f) {
|
|
2500
|
+
h.error("Haori", `Invalid before script: ${f}`);
|
|
2448
2501
|
}
|
|
2449
2502
|
}
|
|
2450
2503
|
}
|
|
2451
|
-
const i =
|
|
2504
|
+
const i = u.attrName(e, "fetch"), s = t.hasAttribute(i);
|
|
2452
2505
|
s && (r.fetchUrl = t.getAttribute(i));
|
|
2453
2506
|
const n = {};
|
|
2454
2507
|
if (e) {
|
|
2455
|
-
const
|
|
2456
|
-
t.hasAttribute(
|
|
2457
|
-
|
|
2508
|
+
const l = u.attrName(e, "fetch-method");
|
|
2509
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2510
|
+
l
|
|
2458
2511
|
));
|
|
2459
2512
|
} else {
|
|
2460
|
-
const
|
|
2461
|
-
t.hasAttribute(
|
|
2462
|
-
|
|
2513
|
+
const l = u.attrName(null, "method", !0);
|
|
2514
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2515
|
+
l
|
|
2463
2516
|
));
|
|
2464
2517
|
}
|
|
2465
2518
|
if (e) {
|
|
2466
|
-
const
|
|
2467
|
-
if (t.hasAttribute(
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2519
|
+
const l = u.attrName(e, "fetch-headers");
|
|
2520
|
+
if (t.hasAttribute(l)) {
|
|
2521
|
+
const f = t.getRawAttribute(
|
|
2522
|
+
l
|
|
2470
2523
|
);
|
|
2471
2524
|
try {
|
|
2472
|
-
n.headers =
|
|
2473
|
-
} catch (
|
|
2474
|
-
h.error("Haori", `Invalid fetch headers: ${
|
|
2525
|
+
n.headers = x.parseDataBind(f);
|
|
2526
|
+
} catch (p) {
|
|
2527
|
+
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2475
2528
|
}
|
|
2476
2529
|
}
|
|
2477
2530
|
} else {
|
|
2478
|
-
const
|
|
2531
|
+
const l = u.attrName(
|
|
2479
2532
|
null,
|
|
2480
2533
|
"headers",
|
|
2481
2534
|
!0
|
|
2482
2535
|
);
|
|
2483
|
-
if (t.hasAttribute(
|
|
2484
|
-
const
|
|
2485
|
-
|
|
2536
|
+
if (t.hasAttribute(l)) {
|
|
2537
|
+
const f = t.getRawAttribute(
|
|
2538
|
+
l
|
|
2486
2539
|
);
|
|
2487
2540
|
try {
|
|
2488
|
-
n.headers =
|
|
2489
|
-
} catch (
|
|
2490
|
-
h.error("Haori", `Invalid fetch headers: ${
|
|
2541
|
+
n.headers = x.parseDataBind(f);
|
|
2542
|
+
} catch (p) {
|
|
2543
|
+
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2491
2544
|
}
|
|
2492
2545
|
}
|
|
2493
2546
|
}
|
|
2494
2547
|
if (e) {
|
|
2495
|
-
const
|
|
2548
|
+
const l = u.attrName(
|
|
2496
2549
|
e,
|
|
2497
2550
|
"fetch-content-type"
|
|
2498
2551
|
);
|
|
2499
|
-
if (t.hasAttribute(
|
|
2552
|
+
if (t.hasAttribute(l))
|
|
2500
2553
|
n.headers = {
|
|
2501
2554
|
...n.headers,
|
|
2502
|
-
"Content-Type": t.getAttribute(
|
|
2555
|
+
"Content-Type": t.getAttribute(l)
|
|
2503
2556
|
};
|
|
2504
2557
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2505
|
-
let
|
|
2506
|
-
n.headers && typeof n.headers == "object" && (
|
|
2558
|
+
let f = !1;
|
|
2559
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
2507
2560
|
...n.headers,
|
|
2508
2561
|
"Content-Type": "application/json"
|
|
2509
2562
|
});
|
|
@@ -2512,19 +2565,19 @@ ${d}
|
|
|
2512
2565
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2513
2566
|
});
|
|
2514
2567
|
} else {
|
|
2515
|
-
const
|
|
2568
|
+
const l = u.attrName(
|
|
2516
2569
|
null,
|
|
2517
2570
|
"content-type",
|
|
2518
2571
|
!0
|
|
2519
2572
|
);
|
|
2520
|
-
if (t.hasAttribute(
|
|
2573
|
+
if (t.hasAttribute(l))
|
|
2521
2574
|
n.headers = {
|
|
2522
2575
|
...n.headers,
|
|
2523
|
-
"Content-Type": t.getAttribute(
|
|
2576
|
+
"Content-Type": t.getAttribute(l)
|
|
2524
2577
|
};
|
|
2525
2578
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2526
|
-
let
|
|
2527
|
-
n.headers && typeof n.headers == "object" && (
|
|
2579
|
+
let f = !1;
|
|
2580
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
2528
2581
|
...n.headers,
|
|
2529
2582
|
"Content-Type": "application/json"
|
|
2530
2583
|
});
|
|
@@ -2534,157 +2587,168 @@ ${d}
|
|
|
2534
2587
|
});
|
|
2535
2588
|
}
|
|
2536
2589
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2537
|
-
const a = e ?
|
|
2590
|
+
const a = e ? u.attrName(e, "bind") : u.attrName(null, "bind", !0);
|
|
2538
2591
|
if (t.hasAttribute(a)) {
|
|
2539
|
-
const
|
|
2540
|
-
if (
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2592
|
+
const l = t.getRawAttribute(a);
|
|
2593
|
+
if (l) {
|
|
2594
|
+
const f = document.body.querySelectorAll(l);
|
|
2595
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((p) => {
|
|
2596
|
+
const E = N.get(p);
|
|
2597
|
+
E && r.bindFragments.push(E);
|
|
2545
2598
|
})) : h.error(
|
|
2546
2599
|
"Haori",
|
|
2547
|
-
`Bind element not found: ${
|
|
2600
|
+
`Bind element not found: ${l} (${a})`
|
|
2548
2601
|
);
|
|
2549
2602
|
}
|
|
2550
2603
|
}
|
|
2551
|
-
const o =
|
|
2604
|
+
const o = u.attrName(e, "bind-arg"), d = u.attrName(
|
|
2552
2605
|
null,
|
|
2553
2606
|
"arg",
|
|
2554
2607
|
!0
|
|
2555
|
-
),
|
|
2608
|
+
), y = u.attrName(
|
|
2556
2609
|
null,
|
|
2557
2610
|
"bind-arg",
|
|
2558
2611
|
!0
|
|
2559
2612
|
);
|
|
2560
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2561
|
-
|
|
2562
|
-
) : t.hasAttribute(
|
|
2563
|
-
const
|
|
2564
|
-
if (t.hasAttribute(
|
|
2565
|
-
const
|
|
2566
|
-
r.bindParams =
|
|
2613
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(d) ? r.bindArg = t.getRawAttribute(
|
|
2614
|
+
d
|
|
2615
|
+
) : t.hasAttribute(y) && (r.bindArg = t.getRawAttribute(y));
|
|
2616
|
+
const b = e ? u.attrName(e, "bind-params") : u.attrName(null, "bind-params", !0);
|
|
2617
|
+
if (t.hasAttribute(b)) {
|
|
2618
|
+
const l = t.getRawAttribute(b);
|
|
2619
|
+
r.bindParams = l.split("&").map((f) => f.trim());
|
|
2567
2620
|
}
|
|
2568
|
-
const
|
|
2569
|
-
if (t.hasAttribute(
|
|
2570
|
-
const
|
|
2571
|
-
r.bindAppendParams =
|
|
2621
|
+
const A = e ? u.attrName(e, "bind-append") : u.attrName(null, "bind-append", !0);
|
|
2622
|
+
if (t.hasAttribute(A)) {
|
|
2623
|
+
const l = t.getRawAttribute(A);
|
|
2624
|
+
r.bindAppendParams = l.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2625
|
+
}
|
|
2626
|
+
const S = e ? u.attrName(e, "copy-params") : null;
|
|
2627
|
+
if (S && t.hasAttribute(S)) {
|
|
2628
|
+
const l = t.getRawAttribute(
|
|
2629
|
+
S
|
|
2630
|
+
);
|
|
2631
|
+
r.copyParams = l.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2572
2632
|
}
|
|
2573
2633
|
if (e) {
|
|
2574
|
-
if (t.hasAttribute(
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2634
|
+
if (t.hasAttribute(u.attrName(e, "adjust"))) {
|
|
2635
|
+
const f = t.getRawAttribute(
|
|
2636
|
+
u.attrName(e, "adjust")
|
|
2577
2637
|
);
|
|
2578
|
-
if (
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2638
|
+
if (f) {
|
|
2639
|
+
const p = document.body.querySelectorAll(f);
|
|
2640
|
+
p.length > 0 ? (r.adjustFragments = [], p.forEach((E) => {
|
|
2641
|
+
const w = N.get(E);
|
|
2642
|
+
w && r.adjustFragments.push(w);
|
|
2583
2643
|
})) : h.error(
|
|
2584
2644
|
"Haori",
|
|
2585
|
-
`Adjust element not found: ${
|
|
2645
|
+
`Adjust element not found: ${f} (${u.attrName(e, "adjust")})`
|
|
2586
2646
|
);
|
|
2587
2647
|
}
|
|
2588
|
-
if (t.hasAttribute(
|
|
2589
|
-
const
|
|
2590
|
-
|
|
2591
|
-
),
|
|
2592
|
-
isNaN(
|
|
2648
|
+
if (t.hasAttribute(u.attrName(e, "adjust-value"))) {
|
|
2649
|
+
const p = t.getRawAttribute(
|
|
2650
|
+
u.attrName(e, "adjust-value")
|
|
2651
|
+
), E = Number(p);
|
|
2652
|
+
isNaN(E) || (r.adjustValue = E);
|
|
2593
2653
|
}
|
|
2594
2654
|
}
|
|
2595
|
-
if (t.hasAttribute(
|
|
2596
|
-
const
|
|
2597
|
-
`${
|
|
2655
|
+
if (t.hasAttribute(u.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(u.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(u.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(u.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${c.prefix}${e}-after-run`)) {
|
|
2656
|
+
const f = t.getRawAttribute(
|
|
2657
|
+
`${c.prefix}${e}-after-run`
|
|
2598
2658
|
);
|
|
2599
2659
|
try {
|
|
2600
2660
|
r.afterCallback = new Function(
|
|
2601
2661
|
"response",
|
|
2602
2662
|
`
|
|
2603
2663
|
"use strict";
|
|
2604
|
-
${
|
|
2664
|
+
${f}
|
|
2605
2665
|
`
|
|
2606
2666
|
);
|
|
2607
|
-
} catch (
|
|
2608
|
-
h.error("Haori", `Invalid after script: ${
|
|
2667
|
+
} catch (p) {
|
|
2668
|
+
h.error("Haori", `Invalid after script: ${p}`);
|
|
2609
2669
|
}
|
|
2610
2670
|
}
|
|
2611
|
-
if (t.hasAttribute(
|
|
2612
|
-
|
|
2613
|
-
)), t.hasAttribute(
|
|
2614
|
-
|
|
2615
|
-
)), t.hasAttribute(
|
|
2616
|
-
|
|
2617
|
-
)), t.hasAttribute(
|
|
2618
|
-
|
|
2619
|
-
)), t.hasAttribute(
|
|
2671
|
+
if (t.hasAttribute(u.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2672
|
+
u.attrName(e, "dialog")
|
|
2673
|
+
)), t.hasAttribute(u.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
|
|
2674
|
+
u.attrName(e, "toast")
|
|
2675
|
+
)), t.hasAttribute(u.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2676
|
+
u.attrName(e, "redirect")
|
|
2677
|
+
)), t.hasAttribute(u.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2678
|
+
u.attrName(e, "history")
|
|
2679
|
+
)), t.hasAttribute(u.attrName(e, "history-data")) && (r.historyData = u.resolveDataAttribute(
|
|
2620
2680
|
t,
|
|
2621
|
-
|
|
2622
|
-
)), t.hasAttribute(
|
|
2623
|
-
const
|
|
2624
|
-
|
|
2681
|
+
u.attrName(e, "history-data")
|
|
2682
|
+
)), t.hasAttribute(u.attrName(e, "history-form"))) {
|
|
2683
|
+
const f = t.getRawAttribute(
|
|
2684
|
+
u.attrName(e, "history-form")
|
|
2625
2685
|
);
|
|
2626
|
-
if (
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2629
|
-
|
|
2686
|
+
if (f) {
|
|
2687
|
+
const p = document.body.querySelector(f);
|
|
2688
|
+
p !== null ? r.historyFormFragment = m.getFormFragment(
|
|
2689
|
+
N.get(p)
|
|
2630
2690
|
) : h.error(
|
|
2631
2691
|
"Haori",
|
|
2632
|
-
`Form element not found: ${
|
|
2692
|
+
`Form element not found: ${f} (${u.attrName(e, "history-form")})`
|
|
2633
2693
|
);
|
|
2634
2694
|
} else
|
|
2635
|
-
r.historyFormFragment =
|
|
2695
|
+
r.historyFormFragment = m.getFormFragment(t);
|
|
2636
2696
|
}
|
|
2637
2697
|
[
|
|
2638
2698
|
"reset",
|
|
2639
2699
|
"refetch",
|
|
2640
2700
|
"click",
|
|
2701
|
+
"copy",
|
|
2641
2702
|
"open",
|
|
2642
2703
|
"close"
|
|
2643
|
-
].forEach((
|
|
2644
|
-
const
|
|
2645
|
-
if (!t.hasAttribute(
|
|
2704
|
+
].forEach((f) => {
|
|
2705
|
+
const p = u.attrName(e, f);
|
|
2706
|
+
if (!t.hasAttribute(p))
|
|
2646
2707
|
return;
|
|
2647
|
-
const
|
|
2648
|
-
if (
|
|
2649
|
-
const
|
|
2650
|
-
|
|
2651
|
-
}),
|
|
2652
|
-
switch (
|
|
2708
|
+
const E = t.getRawAttribute(p), w = [];
|
|
2709
|
+
if (E ? (document.body.querySelectorAll(E).forEach((J) => {
|
|
2710
|
+
const Q = N.get(J);
|
|
2711
|
+
Q && w.push(Q);
|
|
2712
|
+
}), w.length === 0 && h.error("Haori", `Element not found: ${E} (${p})`)) : w.push(t), w.length > 0)
|
|
2713
|
+
switch (f) {
|
|
2653
2714
|
case "reset":
|
|
2654
|
-
r.resetFragments =
|
|
2715
|
+
r.resetFragments = w;
|
|
2655
2716
|
break;
|
|
2656
2717
|
case "refetch":
|
|
2657
|
-
r.refetchFragments =
|
|
2718
|
+
r.refetchFragments = w;
|
|
2658
2719
|
break;
|
|
2659
2720
|
case "click":
|
|
2660
|
-
r.clickFragments =
|
|
2721
|
+
r.clickFragments = w;
|
|
2722
|
+
break;
|
|
2723
|
+
case "copy":
|
|
2724
|
+
r.copyFragments = w;
|
|
2661
2725
|
break;
|
|
2662
2726
|
case "open":
|
|
2663
|
-
r.openFragments =
|
|
2727
|
+
r.openFragments = w;
|
|
2664
2728
|
break;
|
|
2665
2729
|
case "close":
|
|
2666
|
-
r.closeFragments =
|
|
2730
|
+
r.closeFragments = w;
|
|
2667
2731
|
break;
|
|
2668
2732
|
}
|
|
2669
2733
|
});
|
|
2670
2734
|
}
|
|
2671
|
-
if (!e && (t.hasAttribute(
|
|
2735
|
+
if (!e && (t.hasAttribute(u.attrName(null, "data", !0)) && (r.data = u.resolveDataAttribute(
|
|
2672
2736
|
t,
|
|
2673
|
-
|
|
2674
|
-
)), t.hasAttribute(
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2737
|
+
u.attrName(null, "data", !0)
|
|
2738
|
+
)), t.hasAttribute(u.attrName(null, "form", !0)))) {
|
|
2739
|
+
const l = t.getRawAttribute(
|
|
2740
|
+
u.attrName(null, "form", !0)
|
|
2677
2741
|
);
|
|
2678
|
-
if (
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
|
|
2742
|
+
if (l) {
|
|
2743
|
+
const f = document.body.querySelector(l);
|
|
2744
|
+
f !== null ? r.formFragment = m.getFormFragment(
|
|
2745
|
+
N.get(f)
|
|
2682
2746
|
) : h.error(
|
|
2683
2747
|
"Haori",
|
|
2684
|
-
`Form element not found: ${
|
|
2748
|
+
`Form element not found: ${l} (${u.attrName(null, "fetch-form", !0)})`
|
|
2685
2749
|
);
|
|
2686
2750
|
} else
|
|
2687
|
-
r.formFragment =
|
|
2751
|
+
r.formFragment = m.getFormFragment(t);
|
|
2688
2752
|
}
|
|
2689
2753
|
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2690
2754
|
}
|
|
@@ -2707,7 +2771,7 @@ ${u}
|
|
|
2707
2771
|
* @param arg2 イベント名
|
|
2708
2772
|
*/
|
|
2709
2773
|
constructor(t, e = null) {
|
|
2710
|
-
|
|
2774
|
+
u.isElementFragment(t) ? this.options = u.buildOptions(t, e) : this.options = t;
|
|
2711
2775
|
}
|
|
2712
2776
|
/**
|
|
2713
2777
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2748,79 +2812,79 @@ ${u}
|
|
|
2748
2812
|
}
|
|
2749
2813
|
const i = {};
|
|
2750
2814
|
if (this.options.formFragment) {
|
|
2751
|
-
const o =
|
|
2815
|
+
const o = m.getValues(this.options.formFragment);
|
|
2752
2816
|
Object.assign(i, o);
|
|
2753
2817
|
}
|
|
2754
2818
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2755
2819
|
const s = Object.keys(i).length > 0;
|
|
2756
2820
|
if (e) {
|
|
2757
|
-
const o = { ...r || {} },
|
|
2821
|
+
const o = { ...r || {} }, d = new Headers(
|
|
2758
2822
|
o.headers || void 0
|
|
2759
|
-
),
|
|
2760
|
-
if (o.method =
|
|
2761
|
-
s && (e =
|
|
2823
|
+
), y = (o.method || "GET").toUpperCase(), b = c.runtime === "demo" && !at(y), A = b ? "GET" : y;
|
|
2824
|
+
if (o.method = A, A === "GET" || A === "HEAD" || A === "OPTIONS")
|
|
2825
|
+
s && (e = lt(e, i));
|
|
2762
2826
|
else if (s) {
|
|
2763
|
-
const
|
|
2764
|
-
if (/multipart\/form-data/i.test(
|
|
2765
|
-
|
|
2766
|
-
const
|
|
2767
|
-
for (const [
|
|
2768
|
-
|
|
2769
|
-
o.body =
|
|
2770
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2771
|
-
const
|
|
2772
|
-
for (const [
|
|
2773
|
-
|
|
2774
|
-
o.body =
|
|
2827
|
+
const l = d.get("Content-Type") || "";
|
|
2828
|
+
if (/multipart\/form-data/i.test(l)) {
|
|
2829
|
+
d.delete("Content-Type");
|
|
2830
|
+
const f = new FormData();
|
|
2831
|
+
for (const [p, E] of Object.entries(i))
|
|
2832
|
+
E == null ? f.append(p, "") : E instanceof Blob ? f.append(p, E) : Array.isArray(E) ? E.forEach((w) => f.append(p, String(w))) : typeof E == "object" ? f.append(p, JSON.stringify(E)) : f.append(p, String(E));
|
|
2833
|
+
o.body = f;
|
|
2834
|
+
} else if (/application\/x-www-form-urlencoded/i.test(l)) {
|
|
2835
|
+
const f = new URLSearchParams();
|
|
2836
|
+
for (const [p, E] of Object.entries(i))
|
|
2837
|
+
E !== void 0 && (E === null ? f.append(p, "") : Array.isArray(E) ? E.forEach((w) => f.append(p, String(w))) : typeof E == "object" ? f.append(p, JSON.stringify(E)) : f.append(p, String(E)));
|
|
2838
|
+
o.body = f;
|
|
2775
2839
|
} else
|
|
2776
|
-
|
|
2840
|
+
d.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2777
2841
|
}
|
|
2778
|
-
o.headers =
|
|
2779
|
-
let
|
|
2780
|
-
if (
|
|
2781
|
-
runtime:
|
|
2782
|
-
requestedMethod:
|
|
2783
|
-
effectiveMethod:
|
|
2842
|
+
o.headers = d;
|
|
2843
|
+
let S;
|
|
2844
|
+
if (b && (S = e && new URL(e, window.location.href).search || void 0, d.delete("Content-Type"), h.info("Haori demo fetch normalization", {
|
|
2845
|
+
runtime: c.runtime,
|
|
2846
|
+
requestedMethod: y,
|
|
2847
|
+
effectiveMethod: A,
|
|
2784
2848
|
transportMode: "query-get",
|
|
2785
2849
|
url: e,
|
|
2786
2850
|
payload: s ? i : void 0,
|
|
2787
|
-
queryString:
|
|
2851
|
+
queryString: S
|
|
2788
2852
|
})), this.options.targetFragment && e) {
|
|
2789
|
-
const
|
|
2790
|
-
runtime:
|
|
2791
|
-
requestedMethod:
|
|
2792
|
-
effectiveMethod:
|
|
2793
|
-
transportMode:
|
|
2794
|
-
...
|
|
2853
|
+
const l = performance.now(), f = {
|
|
2854
|
+
runtime: c.runtime,
|
|
2855
|
+
requestedMethod: y,
|
|
2856
|
+
effectiveMethod: A,
|
|
2857
|
+
transportMode: b ? "query-get" : "http",
|
|
2858
|
+
...b ? { queryString: S } : {}
|
|
2795
2859
|
};
|
|
2796
2860
|
return v.fetchStart(
|
|
2797
2861
|
this.options.targetFragment.getTarget(),
|
|
2798
2862
|
e,
|
|
2799
2863
|
o,
|
|
2800
2864
|
s ? i : void 0,
|
|
2801
|
-
|
|
2802
|
-
), fetch(e, o).then((
|
|
2803
|
-
|
|
2865
|
+
f
|
|
2866
|
+
), fetch(e, o).then((p) => this.handleFetchResult(
|
|
2867
|
+
p,
|
|
2804
2868
|
e || void 0,
|
|
2805
|
-
|
|
2806
|
-
)).catch((
|
|
2869
|
+
l
|
|
2870
|
+
)).catch((p) => {
|
|
2807
2871
|
throw e && v.fetchError(
|
|
2808
2872
|
this.options.targetFragment.getTarget(),
|
|
2809
2873
|
e,
|
|
2810
|
-
|
|
2811
|
-
),
|
|
2874
|
+
p
|
|
2875
|
+
), p;
|
|
2812
2876
|
});
|
|
2813
2877
|
}
|
|
2814
|
-
return fetch(e, o).then((
|
|
2878
|
+
return fetch(e, o).then((l) => this.handleFetchResult(l, e || void 0));
|
|
2815
2879
|
}
|
|
2816
2880
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2817
|
-
const o = this.options.formFragment,
|
|
2818
|
-
|
|
2819
|
-
`${
|
|
2881
|
+
const o = this.options.formFragment, d = o.getTarget();
|
|
2882
|
+
d.setAttribute(
|
|
2883
|
+
`${c.prefix}bind`,
|
|
2820
2884
|
JSON.stringify(i)
|
|
2821
2885
|
);
|
|
2822
|
-
const
|
|
2823
|
-
|
|
2886
|
+
const y = o.getBindingData();
|
|
2887
|
+
Object.assign(y, i), await x.setBindingData(d, y);
|
|
2824
2888
|
}
|
|
2825
2889
|
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2826
2890
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2846,30 +2910,32 @@ ${u}
|
|
|
2846
2910
|
t.status,
|
|
2847
2911
|
r
|
|
2848
2912
|
), this.options.afterCallback) {
|
|
2849
|
-
const
|
|
2850
|
-
if (
|
|
2851
|
-
if (
|
|
2913
|
+
const a = this.options.afterCallback(t);
|
|
2914
|
+
if (a != null) {
|
|
2915
|
+
if (a === !1 || typeof a == "object" && a.stop)
|
|
2852
2916
|
return !1;
|
|
2853
|
-
typeof
|
|
2917
|
+
typeof a == "object" && "response" in a && (t = "response" in a ? a.response : t);
|
|
2854
2918
|
}
|
|
2855
2919
|
}
|
|
2856
2920
|
const s = [];
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2921
|
+
s.push(this.bindResult(t)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), await Promise.all(s), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
2922
|
+
this.options.resetFragments.map((a) => m.reset(a))
|
|
2923
|
+
), await this.copy();
|
|
2924
|
+
const n = [];
|
|
2925
|
+
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2926
|
+
n.push(new u(a, null).run());
|
|
2927
|
+
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2928
|
+
const o = a.getTarget();
|
|
2929
|
+
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
2864
2930
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2865
2931
|
);
|
|
2866
|
-
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((
|
|
2870
|
-
const
|
|
2871
|
-
|
|
2872
|
-
}), await Promise.all(
|
|
2932
|
+
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2933
|
+
const o = a.getTarget();
|
|
2934
|
+
o instanceof HTMLElement ? n.push(i.openDialog(o)) : h.error("Haori", "Element is not an HTML element: ", o);
|
|
2935
|
+
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2936
|
+
const o = a.getTarget();
|
|
2937
|
+
o instanceof HTMLElement ? n.push(i.closeDialog(o)) : h.error("Haori", "Element is not an HTML element: ", o);
|
|
2938
|
+
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(this.options.toastMessage, "info"), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
2873
2939
|
}
|
|
2874
2940
|
/**
|
|
2875
2941
|
* history.pushState を実行します。
|
|
@@ -2892,11 +2958,11 @@ ${u}
|
|
|
2892
2958
|
return;
|
|
2893
2959
|
}
|
|
2894
2960
|
const n = (a) => {
|
|
2895
|
-
for (const [o,
|
|
2896
|
-
|
|
2961
|
+
for (const [o, d] of Object.entries(a))
|
|
2962
|
+
d != null && (Array.isArray(d) ? d.forEach((y) => s.searchParams.append(o, String(y))) : typeof d == "object" ? s.searchParams.set(o, JSON.stringify(d)) : s.searchParams.set(o, String(d)));
|
|
2897
2963
|
};
|
|
2898
2964
|
e && n(this.options.historyData), r && n(
|
|
2899
|
-
|
|
2965
|
+
m.getValues(
|
|
2900
2966
|
this.options.historyFormFragment
|
|
2901
2967
|
)
|
|
2902
2968
|
), history.pushState({}, "", s.toString());
|
|
@@ -2909,7 +2975,7 @@ ${u}
|
|
|
2909
2975
|
*/
|
|
2910
2976
|
async handleFetchError(t) {
|
|
2911
2977
|
let e = null;
|
|
2912
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
2978
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = m.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2913
2979
|
const r = async (s) => {
|
|
2914
2980
|
const n = e ? e.getTarget() : document.body;
|
|
2915
2981
|
await X().addErrorMessage(n, s);
|
|
@@ -2933,7 +2999,7 @@ ${u}
|
|
|
2933
2999
|
if (n.length === 0)
|
|
2934
3000
|
return await r(`${t.status} ${t.statusText}`), !1;
|
|
2935
3001
|
for (const a of n)
|
|
2936
|
-
a.key && e ? await
|
|
3002
|
+
a.key && e ? await m.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2937
3003
|
return !1;
|
|
2938
3004
|
} catch {
|
|
2939
3005
|
}
|
|
@@ -2999,15 +3065,15 @@ ${u}
|
|
|
2999
3065
|
this.options.bindFragments.forEach((s) => {
|
|
3000
3066
|
const n = s.getBindingData(), a = this.options.bindArg;
|
|
3001
3067
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3002
|
-
const o = n[a],
|
|
3068
|
+
const o = n[a], d = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3003
3069
|
n[a] = this.mergeAppendBindingData(
|
|
3004
3070
|
s,
|
|
3005
3071
|
r,
|
|
3006
|
-
|
|
3072
|
+
d
|
|
3007
3073
|
);
|
|
3008
3074
|
} else
|
|
3009
3075
|
n[a] = r;
|
|
3010
|
-
i.push(
|
|
3076
|
+
i.push(x.setBindingData(s.getTarget(), n));
|
|
3011
3077
|
});
|
|
3012
3078
|
else {
|
|
3013
3079
|
if (typeof r == "string")
|
|
@@ -3020,7 +3086,7 @@ ${u}
|
|
|
3020
3086
|
r
|
|
3021
3087
|
);
|
|
3022
3088
|
i.push(
|
|
3023
|
-
|
|
3089
|
+
x.setBindingData(
|
|
3024
3090
|
s.getTarget(),
|
|
3025
3091
|
n
|
|
3026
3092
|
)
|
|
@@ -3044,6 +3110,39 @@ ${u}
|
|
|
3044
3110
|
}
|
|
3045
3111
|
return i;
|
|
3046
3112
|
}
|
|
3113
|
+
/**
|
|
3114
|
+
* 指定されたフラグメントへバインディングデータをコピーします。
|
|
3115
|
+
*/
|
|
3116
|
+
copy() {
|
|
3117
|
+
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3118
|
+
return Promise.resolve();
|
|
3119
|
+
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3120
|
+
const s = {
|
|
3121
|
+
...i.getBindingData(),
|
|
3122
|
+
...e
|
|
3123
|
+
};
|
|
3124
|
+
return x.setBindingData(i.getTarget(), s);
|
|
3125
|
+
});
|
|
3126
|
+
return Promise.all(r).then(() => {
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
/**
|
|
3130
|
+
* copy のコピー元データを取得します。
|
|
3131
|
+
*/
|
|
3132
|
+
resolveCopySourceData() {
|
|
3133
|
+
return this.options.formFragment ? m.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
3137
|
+
*/
|
|
3138
|
+
pickCopyData(t) {
|
|
3139
|
+
if (!this.options.copyParams || this.options.copyParams.length === 0)
|
|
3140
|
+
return t;
|
|
3141
|
+
const e = {};
|
|
3142
|
+
return this.options.copyParams.forEach((r) => {
|
|
3143
|
+
r in t && (e[r] = t[r]);
|
|
3144
|
+
}), e;
|
|
3145
|
+
}
|
|
3047
3146
|
/**
|
|
3048
3147
|
* 値の増減を行います。
|
|
3049
3148
|
*/
|
|
@@ -3069,7 +3168,7 @@ ${u}
|
|
|
3069
3168
|
if (!this.options.targetFragment)
|
|
3070
3169
|
return h.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3071
3170
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3072
|
-
`${
|
|
3171
|
+
`${c.prefix}row`
|
|
3073
3172
|
);
|
|
3074
3173
|
return t || (h.error("Haori", "Row fragment not found."), null);
|
|
3075
3174
|
}
|
|
@@ -3087,7 +3186,7 @@ ${u}
|
|
|
3087
3186
|
const e = [], r = t.clone();
|
|
3088
3187
|
return e.push(
|
|
3089
3188
|
t.getParent().insertAfter(r, t)
|
|
3090
|
-
), e.push(
|
|
3189
|
+
), e.push(x.evaluateAll(r)), e.push(m.reset(r)), Promise.all(e).then(() => {
|
|
3091
3190
|
});
|
|
3092
3191
|
}
|
|
3093
3192
|
/**
|
|
@@ -3102,7 +3201,7 @@ ${u}
|
|
|
3102
3201
|
if (!t)
|
|
3103
3202
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3104
3203
|
const e = t.getParent();
|
|
3105
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3204
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${c.prefix}each-before`) && !i.hasAttribute(`${c.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3106
3205
|
}
|
|
3107
3206
|
/**
|
|
3108
3207
|
* 前の行へ移動します。
|
|
@@ -3139,9 +3238,9 @@ ${u}
|
|
|
3139
3238
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3140
3239
|
}
|
|
3141
3240
|
};
|
|
3142
|
-
|
|
3143
|
-
let V =
|
|
3144
|
-
class
|
|
3241
|
+
u.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, u.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3242
|
+
let V = u;
|
|
3243
|
+
class ct {
|
|
3145
3244
|
/**
|
|
3146
3245
|
* URLのクエリパラメータを取得します。
|
|
3147
3246
|
*
|
|
@@ -3154,7 +3253,7 @@ class lt {
|
|
|
3154
3253
|
}), t;
|
|
3155
3254
|
}
|
|
3156
3255
|
}
|
|
3157
|
-
class
|
|
3256
|
+
class ut {
|
|
3158
3257
|
/**
|
|
3159
3258
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3160
3259
|
*
|
|
@@ -3192,7 +3291,7 @@ class ct {
|
|
|
3192
3291
|
}
|
|
3193
3292
|
}
|
|
3194
3293
|
}
|
|
3195
|
-
const
|
|
3294
|
+
const g = class g {
|
|
3196
3295
|
/**
|
|
3197
3296
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
3198
3297
|
*
|
|
@@ -3200,8 +3299,8 @@ const m = class m {
|
|
|
3200
3299
|
* @returns 遅延属性かどうか
|
|
3201
3300
|
*/
|
|
3202
3301
|
static isDeferredAttributeName(t) {
|
|
3203
|
-
return
|
|
3204
|
-
(e) => t === `${
|
|
3302
|
+
return g.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3303
|
+
(e) => t === `${c.prefix}${e}`
|
|
3205
3304
|
);
|
|
3206
3305
|
}
|
|
3207
3306
|
/**
|
|
@@ -3211,8 +3310,8 @@ const m = class m {
|
|
|
3211
3310
|
* @returns 除外対象かどうか
|
|
3212
3311
|
*/
|
|
3213
3312
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3214
|
-
return
|
|
3215
|
-
(e) => t === `${
|
|
3313
|
+
return g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3314
|
+
(e) => t === `${c.prefix}${e}`
|
|
3216
3315
|
);
|
|
3217
3316
|
}
|
|
3218
3317
|
/**
|
|
@@ -3223,7 +3322,7 @@ const m = class m {
|
|
|
3223
3322
|
* @returns 再評価する場合は true
|
|
3224
3323
|
*/
|
|
3225
3324
|
static shouldReevaluateAttribute(t, e) {
|
|
3226
|
-
return e !== null && !
|
|
3325
|
+
return e !== null && !g.isEvaluateAllExcludedAttributeName(t) && g.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
|
|
3227
3326
|
}
|
|
3228
3327
|
/**
|
|
3229
3328
|
* プレースホルダを含む通常属性を再評価します。
|
|
@@ -3236,7 +3335,7 @@ const m = class m {
|
|
|
3236
3335
|
let e = Promise.resolve();
|
|
3237
3336
|
for (const r of t.getAttributeNames()) {
|
|
3238
3337
|
const i = t.getRawAttribute(r);
|
|
3239
|
-
|
|
3338
|
+
g.shouldReevaluateAttribute(r, i) && (e = e.then(() => t.setAttribute(r, i)));
|
|
3240
3339
|
}
|
|
3241
3340
|
return e.then(() => {
|
|
3242
3341
|
});
|
|
@@ -3248,15 +3347,15 @@ const m = class m {
|
|
|
3248
3347
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
3249
3348
|
*/
|
|
3250
3349
|
static scan(t) {
|
|
3251
|
-
const e =
|
|
3350
|
+
const e = N.get(t);
|
|
3252
3351
|
if (!e)
|
|
3253
3352
|
return Promise.resolve();
|
|
3254
|
-
t.parentNode && (
|
|
3353
|
+
t.parentNode && (N.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3255
3354
|
const r = [], i = /* @__PURE__ */ new Set();
|
|
3256
|
-
for (const s of
|
|
3257
|
-
const n =
|
|
3355
|
+
for (const s of g.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3356
|
+
const n = c.prefix + s;
|
|
3258
3357
|
e.hasAttribute(n) && (r.push(
|
|
3259
|
-
|
|
3358
|
+
g.setAttribute(
|
|
3260
3359
|
e.getTarget(),
|
|
3261
3360
|
n,
|
|
3262
3361
|
e.getRawAttribute(n)
|
|
@@ -3264,15 +3363,15 @@ const m = class m {
|
|
|
3264
3363
|
), i.add(n));
|
|
3265
3364
|
}
|
|
3266
3365
|
for (const s of e.getAttributeNames()) {
|
|
3267
|
-
if (i.has(s) ||
|
|
3366
|
+
if (i.has(s) || g.isDeferredAttributeName(s))
|
|
3268
3367
|
continue;
|
|
3269
3368
|
const n = e.getRawAttribute(s);
|
|
3270
|
-
n !== null && r.push(
|
|
3369
|
+
n !== null && r.push(g.setAttribute(e.getTarget(), s, n));
|
|
3271
3370
|
}
|
|
3272
|
-
for (const s of
|
|
3273
|
-
const n =
|
|
3371
|
+
for (const s of g.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3372
|
+
const n = c.prefix + s;
|
|
3274
3373
|
e.hasAttribute(n) && (r.push(
|
|
3275
|
-
|
|
3374
|
+
g.setAttribute(
|
|
3276
3375
|
e.getTarget(),
|
|
3277
3376
|
n,
|
|
3278
3377
|
e.getRawAttribute(n)
|
|
@@ -3280,7 +3379,7 @@ const m = class m {
|
|
|
3280
3379
|
), i.add(n));
|
|
3281
3380
|
}
|
|
3282
3381
|
return e.getChildren().forEach((s) => {
|
|
3283
|
-
s instanceof D ? r.push(
|
|
3382
|
+
s instanceof D ? r.push(g.scan(s.getTarget())) : s instanceof L && r.push(g.evaluateText(s));
|
|
3284
3383
|
}), Promise.all(r).then(() => {
|
|
3285
3384
|
});
|
|
3286
3385
|
}
|
|
@@ -3294,34 +3393,34 @@ const m = class m {
|
|
|
3294
3393
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3295
3394
|
*/
|
|
3296
3395
|
static setAttribute(t, e, r) {
|
|
3297
|
-
const i =
|
|
3396
|
+
const i = N.get(t), s = [];
|
|
3298
3397
|
switch (e) {
|
|
3299
|
-
case `${
|
|
3300
|
-
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(
|
|
3398
|
+
case `${c.prefix}bind`: {
|
|
3399
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(g.parseDataBind(r));
|
|
3301
3400
|
break;
|
|
3302
3401
|
}
|
|
3303
|
-
case `${
|
|
3304
|
-
s.push(
|
|
3402
|
+
case `${c.prefix}if`:
|
|
3403
|
+
s.push(g.evaluateIf(i));
|
|
3305
3404
|
break;
|
|
3306
|
-
case `${
|
|
3307
|
-
s.push(
|
|
3405
|
+
case `${c.prefix}each`:
|
|
3406
|
+
s.push(g.evaluateEach(i));
|
|
3308
3407
|
break;
|
|
3309
|
-
case `${
|
|
3408
|
+
case `${c.prefix}fetch`:
|
|
3310
3409
|
s.push(
|
|
3311
3410
|
new V(i, null).run().then(() => {
|
|
3312
3411
|
})
|
|
3313
3412
|
);
|
|
3314
3413
|
break;
|
|
3315
|
-
case `${
|
|
3414
|
+
case `${c.prefix}import`: {
|
|
3316
3415
|
if (typeof r == "string") {
|
|
3317
3416
|
const n = i.getTarget(), a = performance.now();
|
|
3318
3417
|
v.importStart(n, r), s.push(
|
|
3319
|
-
|
|
3320
|
-
const
|
|
3321
|
-
return
|
|
3418
|
+
ut.load(r).then((o) => {
|
|
3419
|
+
const d = new TextEncoder().encode(o).length;
|
|
3420
|
+
return P.enqueue(() => {
|
|
3322
3421
|
n.innerHTML = o;
|
|
3323
3422
|
}).then(() => {
|
|
3324
|
-
v.importEnd(n, r,
|
|
3423
|
+
v.importEnd(n, r, d, a);
|
|
3325
3424
|
});
|
|
3326
3425
|
}).catch((o) => {
|
|
3327
3426
|
v.importError(n, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
@@ -3330,13 +3429,13 @@ const m = class m {
|
|
|
3330
3429
|
}
|
|
3331
3430
|
break;
|
|
3332
3431
|
}
|
|
3333
|
-
case `${
|
|
3334
|
-
const n = i.getAttribute(`${
|
|
3432
|
+
case `${c.prefix}url-param`: {
|
|
3433
|
+
const n = i.getAttribute(`${c.prefix}url-arg`), a = ct.readParams();
|
|
3335
3434
|
if (n === null)
|
|
3336
|
-
|
|
3435
|
+
g.setBindingData(t, a);
|
|
3337
3436
|
else {
|
|
3338
3437
|
const o = i.getRawBindingData() || {};
|
|
3339
|
-
o[String(n)] = a,
|
|
3438
|
+
o[String(n)] = a, g.setBindingData(t, o);
|
|
3340
3439
|
}
|
|
3341
3440
|
break;
|
|
3342
3441
|
}
|
|
@@ -3353,12 +3452,16 @@ const m = class m {
|
|
|
3353
3452
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3354
3453
|
*/
|
|
3355
3454
|
static setBindingData(t, e) {
|
|
3356
|
-
const r =
|
|
3455
|
+
const r = N.get(t), i = r.getRawBindingData();
|
|
3357
3456
|
r.setBindingData(e);
|
|
3358
3457
|
const s = [];
|
|
3359
|
-
|
|
3360
|
-
r.setAttribute(`${
|
|
3361
|
-
),
|
|
3458
|
+
if (s.push(
|
|
3459
|
+
r.setAttribute(`${c.prefix}bind`, JSON.stringify(e))
|
|
3460
|
+
), t.tagName === "FORM") {
|
|
3461
|
+
const n = r.getAttribute(`${c.prefix}form-arg`), a = n && e[String(n)] && typeof e[String(n)] == "object" && !Array.isArray(e[String(n)]) ? e[String(n)] : n ? {} : e;
|
|
3462
|
+
s.push(m.syncValues(r, a));
|
|
3463
|
+
}
|
|
3464
|
+
return s.push(g.evaluateAll(r)), v.bindChange(t, i, e, "manual"), Promise.all(s).then(() => {
|
|
3362
3465
|
});
|
|
3363
3466
|
}
|
|
3364
3467
|
/**
|
|
@@ -3388,11 +3491,11 @@ const m = class m {
|
|
|
3388
3491
|
* @param node 追加するノード
|
|
3389
3492
|
*/
|
|
3390
3493
|
static addNode(t, e) {
|
|
3391
|
-
const r =
|
|
3494
|
+
const r = N.get(t);
|
|
3392
3495
|
if (r.isSkipMutationNodes())
|
|
3393
3496
|
return;
|
|
3394
|
-
const i =
|
|
3395
|
-
s && (r.insertBefore(s, i), s instanceof D ?
|
|
3497
|
+
const i = N.get(e.nextSibling), s = N.get(e);
|
|
3498
|
+
s && (r.insertBefore(s, i), s instanceof D ? g.scan(s.getTarget()) : s instanceof L && g.evaluateText(s));
|
|
3396
3499
|
}
|
|
3397
3500
|
/**
|
|
3398
3501
|
* ノードを親要素から削除します。
|
|
@@ -3400,7 +3503,7 @@ const m = class m {
|
|
|
3400
3503
|
* @param node 削除するノード
|
|
3401
3504
|
*/
|
|
3402
3505
|
static removeNode(t) {
|
|
3403
|
-
const e =
|
|
3506
|
+
const e = N.get(t);
|
|
3404
3507
|
if (e) {
|
|
3405
3508
|
const r = e.getParent();
|
|
3406
3509
|
if (r && r.isSkipMutationNodes())
|
|
@@ -3415,7 +3518,7 @@ const m = class m {
|
|
|
3415
3518
|
* @param text 新しいテキスト
|
|
3416
3519
|
*/
|
|
3417
3520
|
static changeText(t, e) {
|
|
3418
|
-
const r =
|
|
3521
|
+
const r = N.get(t);
|
|
3419
3522
|
r && r.setContent(e);
|
|
3420
3523
|
}
|
|
3421
3524
|
/**
|
|
@@ -3427,16 +3530,16 @@ const m = class m {
|
|
|
3427
3530
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3428
3531
|
*/
|
|
3429
3532
|
static changeValue(t, e) {
|
|
3430
|
-
const r =
|
|
3533
|
+
const r = N.get(t);
|
|
3431
3534
|
if (r.getValue() === e)
|
|
3432
3535
|
return Promise.resolve();
|
|
3433
3536
|
const i = [];
|
|
3434
3537
|
i.push(r.setValue(e));
|
|
3435
|
-
const s =
|
|
3538
|
+
const s = g.getFormFragment(r);
|
|
3436
3539
|
if (s) {
|
|
3437
|
-
const n =
|
|
3540
|
+
const n = m.getValues(s), a = s.getAttribute(`${c.prefix}form-arg`);
|
|
3438
3541
|
let o;
|
|
3439
|
-
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(
|
|
3542
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(g.setBindingData(s.getTarget(), o));
|
|
3440
3543
|
}
|
|
3441
3544
|
return Promise.all(i).then(() => {
|
|
3442
3545
|
});
|
|
@@ -3451,7 +3554,7 @@ const m = class m {
|
|
|
3451
3554
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
3452
3555
|
return t;
|
|
3453
3556
|
const e = t.getParent();
|
|
3454
|
-
return e ?
|
|
3557
|
+
return e ? g.getFormFragment(e) : null;
|
|
3455
3558
|
}
|
|
3456
3559
|
/**
|
|
3457
3560
|
* フラグメントとその子要素を評価します。
|
|
@@ -3461,8 +3564,8 @@ const m = class m {
|
|
|
3461
3564
|
*/
|
|
3462
3565
|
static evaluateAll(t) {
|
|
3463
3566
|
const e = [];
|
|
3464
|
-
return e.push(
|
|
3465
|
-
r instanceof D ? e.push(
|
|
3567
|
+
return e.push(g.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${c.prefix}if`) && e.push(g.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) && e.push(g.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3568
|
+
r instanceof D ? e.push(g.evaluateAll(r)) : r instanceof L && e.push(g.evaluateText(r));
|
|
3466
3569
|
}), Promise.all(e).then(() => {
|
|
3467
3570
|
});
|
|
3468
3571
|
}
|
|
@@ -3483,7 +3586,7 @@ const m = class m {
|
|
|
3483
3586
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3484
3587
|
*/
|
|
3485
3588
|
static evaluateIf(t) {
|
|
3486
|
-
const e = [], r = t.getAttribute(`${
|
|
3589
|
+
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3487
3590
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3488
3591
|
t.hide().then(() => {
|
|
3489
3592
|
v.hide(t.getTarget());
|
|
@@ -3492,7 +3595,7 @@ const m = class m {
|
|
|
3492
3595
|
t.show().then(() => {
|
|
3493
3596
|
v.show(t.getTarget());
|
|
3494
3597
|
})
|
|
3495
|
-
), e.push(
|
|
3598
|
+
), e.push(g.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3496
3599
|
});
|
|
3497
3600
|
}
|
|
3498
3601
|
/**
|
|
@@ -3509,17 +3612,17 @@ const m = class m {
|
|
|
3509
3612
|
let i = !1;
|
|
3510
3613
|
t.getChildren().forEach((n) => {
|
|
3511
3614
|
if (!i && n instanceof D) {
|
|
3512
|
-
if (n.hasAttribute(`${
|
|
3615
|
+
if (n.hasAttribute(`${c.prefix}each-before`) || n.hasAttribute(`${c.prefix}each-after`))
|
|
3513
3616
|
return;
|
|
3514
3617
|
e = n.clone(), t.setTemplate(e), i = !0, t.removeChild(n);
|
|
3515
3618
|
const a = n.getTarget();
|
|
3516
3619
|
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
3517
3620
|
}
|
|
3518
3621
|
});
|
|
3519
|
-
const s = t.getAttribute(`${
|
|
3622
|
+
const s = t.getAttribute(`${c.prefix}each`);
|
|
3520
3623
|
return Array.isArray(s) ? this.updateDiff(t, s) : (h.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
3521
3624
|
}
|
|
3522
|
-
const r = t.getAttribute(`${
|
|
3625
|
+
const r = t.getAttribute(`${c.prefix}each`);
|
|
3523
3626
|
return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3524
3627
|
}
|
|
3525
3628
|
/**
|
|
@@ -3532,72 +3635,72 @@ const m = class m {
|
|
|
3532
3635
|
const r = t.getTemplate();
|
|
3533
3636
|
if (r === null)
|
|
3534
3637
|
return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3535
|
-
let i = t.getAttribute(`${
|
|
3638
|
+
let i = t.getAttribute(`${c.prefix}each-index`);
|
|
3536
3639
|
i && (i = String(i));
|
|
3537
|
-
const s = t.getAttribute(`${
|
|
3538
|
-
e.forEach((
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3640
|
+
const s = t.getAttribute(`${c.prefix}each-key`), n = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3641
|
+
e.forEach((l, f) => {
|
|
3642
|
+
const p = g.createListKey(
|
|
3643
|
+
l,
|
|
3541
3644
|
s ? String(s) : null,
|
|
3542
|
-
|
|
3645
|
+
f
|
|
3543
3646
|
);
|
|
3544
|
-
o.push(
|
|
3647
|
+
o.push(p), a.set(p, { item: l, itemIndex: f });
|
|
3545
3648
|
});
|
|
3546
|
-
const
|
|
3547
|
-
let
|
|
3548
|
-
(
|
|
3649
|
+
const d = [];
|
|
3650
|
+
let y = t.getChildren().filter((l) => l instanceof D).filter(
|
|
3651
|
+
(l) => !l.hasAttribute(`${c.prefix}each-before`) && !l.hasAttribute(`${c.prefix}each-after`)
|
|
3549
3652
|
);
|
|
3550
|
-
|
|
3551
|
-
const
|
|
3552
|
-
let
|
|
3553
|
-
return o.forEach((
|
|
3554
|
-
const
|
|
3653
|
+
y = y.filter((l) => o.indexOf(String(l.getListKey())) === -1 ? (d.push(l.remove()), !1) : !0);
|
|
3654
|
+
const b = y.map((l) => l.getListKey()), A = t.getChildren().filter((l) => l instanceof D).filter((l) => l.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3655
|
+
let S = Promise.resolve();
|
|
3656
|
+
return o.forEach((l, f) => {
|
|
3657
|
+
const p = b.indexOf(l), { item: E, itemIndex: w } = a.get(l);
|
|
3555
3658
|
let k;
|
|
3556
|
-
if (
|
|
3557
|
-
k =
|
|
3558
|
-
() =>
|
|
3659
|
+
if (p !== -1)
|
|
3660
|
+
k = y[p], S = S.then(
|
|
3661
|
+
() => g.updateRowFragment(
|
|
3559
3662
|
k,
|
|
3560
|
-
|
|
3663
|
+
E,
|
|
3561
3664
|
i,
|
|
3562
|
-
|
|
3665
|
+
w,
|
|
3563
3666
|
n ? String(n) : null,
|
|
3564
|
-
|
|
3565
|
-
).then(() =>
|
|
3667
|
+
l
|
|
3668
|
+
).then(() => g.evaluateAll(k))
|
|
3566
3669
|
);
|
|
3567
3670
|
else {
|
|
3568
3671
|
k = r.clone();
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3571
|
-
() =>
|
|
3672
|
+
const J = A + f;
|
|
3673
|
+
S = S.then(
|
|
3674
|
+
() => g.updateRowFragment(
|
|
3572
3675
|
k,
|
|
3573
|
-
|
|
3676
|
+
E,
|
|
3574
3677
|
i,
|
|
3575
|
-
|
|
3678
|
+
w,
|
|
3576
3679
|
n ? String(n) : null,
|
|
3577
|
-
|
|
3680
|
+
l
|
|
3578
3681
|
).then(
|
|
3579
3682
|
() => t.insertBefore(
|
|
3580
3683
|
k,
|
|
3581
|
-
t.getChildren()[
|
|
3582
|
-
).then(() =>
|
|
3684
|
+
t.getChildren()[J] || null
|
|
3685
|
+
).then(() => g.evaluateAll(k))
|
|
3583
3686
|
)
|
|
3584
3687
|
);
|
|
3585
3688
|
}
|
|
3586
|
-
}), Promise.all(
|
|
3587
|
-
const
|
|
3588
|
-
(
|
|
3589
|
-
),
|
|
3590
|
-
(
|
|
3591
|
-
),
|
|
3592
|
-
(
|
|
3593
|
-
),
|
|
3594
|
-
(
|
|
3689
|
+
}), Promise.all(d).then(() => S).then(() => {
|
|
3690
|
+
const l = o.filter(
|
|
3691
|
+
(w) => w !== null
|
|
3692
|
+
), f = b.filter(
|
|
3693
|
+
(w) => w !== null
|
|
3694
|
+
), p = l.filter(
|
|
3695
|
+
(w) => !f.includes(w)
|
|
3696
|
+
), E = f.filter(
|
|
3697
|
+
(w) => !l.includes(w)
|
|
3595
3698
|
);
|
|
3596
3699
|
v.eachUpdate(
|
|
3597
3700
|
t.getTarget(),
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3701
|
+
p,
|
|
3702
|
+
E,
|
|
3703
|
+
l
|
|
3601
3704
|
);
|
|
3602
3705
|
});
|
|
3603
3706
|
}
|
|
@@ -3645,21 +3748,21 @@ const m = class m {
|
|
|
3645
3748
|
else
|
|
3646
3749
|
return h.error(
|
|
3647
3750
|
"[Haori]",
|
|
3648
|
-
`Primitive value requires '${
|
|
3751
|
+
`Primitive value requires '${c.prefix}each-arg' attribute: ${e}`
|
|
3649
3752
|
), Promise.resolve();
|
|
3650
|
-
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${
|
|
3753
|
+
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${c.prefix}row`, n);
|
|
3651
3754
|
}
|
|
3652
3755
|
};
|
|
3653
|
-
|
|
3756
|
+
g.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], g.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
3654
3757
|
"bind",
|
|
3655
3758
|
"if",
|
|
3656
3759
|
"each",
|
|
3657
3760
|
"fetch",
|
|
3658
3761
|
"import",
|
|
3659
3762
|
"url-param"
|
|
3660
|
-
],
|
|
3661
|
-
let
|
|
3662
|
-
class
|
|
3763
|
+
], g.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3764
|
+
let x = g;
|
|
3765
|
+
class ht {
|
|
3663
3766
|
/**
|
|
3664
3767
|
* コンストラクタ。
|
|
3665
3768
|
*
|
|
@@ -3667,7 +3770,7 @@ class ut {
|
|
|
3667
3770
|
*/
|
|
3668
3771
|
constructor(t = document) {
|
|
3669
3772
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3670
|
-
const e = document.documentElement, r =
|
|
3773
|
+
const e = document.documentElement, r = N.get(e);
|
|
3671
3774
|
r && new V(r, "load").run();
|
|
3672
3775
|
}, this.root = t;
|
|
3673
3776
|
}
|
|
@@ -3694,7 +3797,7 @@ class ut {
|
|
|
3694
3797
|
const r = this.getElementFromTarget(t.target);
|
|
3695
3798
|
if (!r)
|
|
3696
3799
|
return;
|
|
3697
|
-
const i =
|
|
3800
|
+
const i = N.get(r);
|
|
3698
3801
|
i && (e === "change" && i instanceof D && i.syncValue(), new V(i, e).run().catch((s) => {
|
|
3699
3802
|
h.error("[Haori]", "Procedure execution error:", s);
|
|
3700
3803
|
}));
|
|
@@ -3709,44 +3812,44 @@ class ut {
|
|
|
3709
3812
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3710
3813
|
}
|
|
3711
3814
|
}
|
|
3712
|
-
const
|
|
3815
|
+
const T = class T {
|
|
3713
3816
|
static syncTree(t) {
|
|
3714
|
-
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement &&
|
|
3715
|
-
|
|
3817
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && T.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
3818
|
+
T.syncElement(e);
|
|
3716
3819
|
}));
|
|
3717
3820
|
}
|
|
3718
3821
|
static syncElement(t) {
|
|
3719
|
-
const e =
|
|
3720
|
-
if (!r || !
|
|
3721
|
-
e && (e.observer.disconnect(),
|
|
3822
|
+
const e = T.registrations.get(t), r = N.get(t);
|
|
3823
|
+
if (!r || !T.shouldObserve(r)) {
|
|
3824
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3722
3825
|
return;
|
|
3723
3826
|
}
|
|
3724
3827
|
if (typeof IntersectionObserver > "u")
|
|
3725
3828
|
return;
|
|
3726
|
-
const i =
|
|
3727
|
-
if (e && e.observer.root === i && e.observer.rootMargin === s &&
|
|
3829
|
+
const i = T.resolveRoot(r), s = T.resolveRootMargin(r), n = T.resolveThreshold(r), a = r.hasAttribute(`${c.prefix}intersect-once`);
|
|
3830
|
+
if (e && e.observer.root === i && e.observer.rootMargin === s && T.sameThreshold(
|
|
3728
3831
|
e.observer.thresholds,
|
|
3729
3832
|
n
|
|
3730
3833
|
) && e.once === a) {
|
|
3731
3834
|
e.fragment = r;
|
|
3732
3835
|
return;
|
|
3733
3836
|
}
|
|
3734
|
-
e && (e.observer.disconnect(),
|
|
3837
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3735
3838
|
const o = new IntersectionObserver(
|
|
3736
|
-
(
|
|
3737
|
-
const
|
|
3738
|
-
|
|
3739
|
-
!
|
|
3740
|
-
|
|
3741
|
-
}).catch((
|
|
3839
|
+
(d) => {
|
|
3840
|
+
const y = T.registrations.get(t);
|
|
3841
|
+
y && d.forEach((b) => {
|
|
3842
|
+
!b.isIntersecting || y.running || T.isDisabled(y.fragment) || (y.running = !0, new V(y.fragment, "intersect").runWithResult().then((A) => {
|
|
3843
|
+
A && y.once && (y.observer.disconnect(), T.registrations.delete(t));
|
|
3844
|
+
}).catch((A) => {
|
|
3742
3845
|
h.error(
|
|
3743
3846
|
"[Haori]",
|
|
3744
3847
|
"Intersect procedure execution error:",
|
|
3745
|
-
|
|
3848
|
+
A
|
|
3746
3849
|
);
|
|
3747
3850
|
}).finally(() => {
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3851
|
+
const A = T.registrations.get(t);
|
|
3852
|
+
A && (A.running = !1);
|
|
3750
3853
|
}));
|
|
3751
3854
|
});
|
|
3752
3855
|
},
|
|
@@ -3756,7 +3859,7 @@ const w = class w {
|
|
|
3756
3859
|
threshold: n
|
|
3757
3860
|
}
|
|
3758
3861
|
);
|
|
3759
|
-
o.observe(t),
|
|
3862
|
+
o.observe(t), T.registrations.set(t, {
|
|
3760
3863
|
fragment: r,
|
|
3761
3864
|
observer: o,
|
|
3762
3865
|
once: a,
|
|
@@ -3765,29 +3868,29 @@ const w = class w {
|
|
|
3765
3868
|
}
|
|
3766
3869
|
static cleanupTree(t) {
|
|
3767
3870
|
if (t instanceof HTMLElement) {
|
|
3768
|
-
const e =
|
|
3769
|
-
e && (e.observer.disconnect(),
|
|
3871
|
+
const e = T.registrations.get(t);
|
|
3872
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3770
3873
|
}
|
|
3771
3874
|
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
3772
|
-
const r =
|
|
3773
|
-
r && (r.observer.disconnect(),
|
|
3875
|
+
const r = T.registrations.get(e);
|
|
3876
|
+
r && (r.observer.disconnect(), T.registrations.delete(e));
|
|
3774
3877
|
});
|
|
3775
3878
|
}
|
|
3776
3879
|
static disconnectAll() {
|
|
3777
|
-
|
|
3880
|
+
T.registrations.forEach((t) => {
|
|
3778
3881
|
t.observer.disconnect();
|
|
3779
|
-
}),
|
|
3882
|
+
}), T.registrations.clear();
|
|
3780
3883
|
}
|
|
3781
3884
|
static shouldObserve(t) {
|
|
3782
3885
|
return t.getAttributeNames().some((e) => {
|
|
3783
|
-
if (!e.startsWith(`${
|
|
3886
|
+
if (!e.startsWith(`${c.prefix}intersect-`))
|
|
3784
3887
|
return !1;
|
|
3785
|
-
const r = e.slice(`${
|
|
3786
|
-
return !
|
|
3888
|
+
const r = e.slice(`${c.prefix}intersect-`.length);
|
|
3889
|
+
return !T.CONFIG_KEYS.has(r);
|
|
3787
3890
|
});
|
|
3788
3891
|
}
|
|
3789
3892
|
static resolveRoot(t) {
|
|
3790
|
-
const e = `${
|
|
3893
|
+
const e = `${c.prefix}intersect-root`;
|
|
3791
3894
|
if (!t.hasAttribute(e))
|
|
3792
3895
|
return null;
|
|
3793
3896
|
const r = t.getAttribute(e);
|
|
@@ -3797,15 +3900,15 @@ const w = class w {
|
|
|
3797
3900
|
return i instanceof HTMLElement ? i : (h.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
3798
3901
|
}
|
|
3799
3902
|
static resolveRootMargin(t) {
|
|
3800
|
-
const e = `${
|
|
3903
|
+
const e = `${c.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
3801
3904
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
3802
3905
|
}
|
|
3803
3906
|
static resolveThreshold(t) {
|
|
3804
|
-
const e = `${
|
|
3907
|
+
const e = `${c.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
3805
3908
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
3806
3909
|
}
|
|
3807
3910
|
static isDisabled(t) {
|
|
3808
|
-
const e = `${
|
|
3911
|
+
const e = `${c.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
3809
3912
|
if (r === null || r === !1)
|
|
3810
3913
|
return !1;
|
|
3811
3914
|
if (typeof r == "boolean")
|
|
@@ -3817,14 +3920,14 @@ const w = class w {
|
|
|
3817
3920
|
return t.length === 1 && t[0] === e;
|
|
3818
3921
|
}
|
|
3819
3922
|
};
|
|
3820
|
-
|
|
3923
|
+
T.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
3821
3924
|
"root",
|
|
3822
3925
|
"root-margin",
|
|
3823
3926
|
"threshold",
|
|
3824
3927
|
"disabled",
|
|
3825
3928
|
"once"
|
|
3826
|
-
]),
|
|
3827
|
-
let
|
|
3929
|
+
]), T.registrations = /* @__PURE__ */ new Map();
|
|
3930
|
+
let $ = T;
|
|
3828
3931
|
const H = class H {
|
|
3829
3932
|
/**
|
|
3830
3933
|
* 初期化メソッド。
|
|
@@ -3835,10 +3938,10 @@ const H = class H {
|
|
|
3835
3938
|
return;
|
|
3836
3939
|
H._initialized = !0;
|
|
3837
3940
|
const t = await Promise.allSettled([
|
|
3838
|
-
|
|
3839
|
-
|
|
3941
|
+
x.scan(document.head),
|
|
3942
|
+
x.scan(document.body)
|
|
3840
3943
|
]), [e, r] = t;
|
|
3841
|
-
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), H.observe(document.head), H.observe(document.body), new
|
|
3944
|
+
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), H.observe(document.head), H.observe(document.body), new ht().start(), $.syncTree(document.body);
|
|
3842
3945
|
}
|
|
3843
3946
|
/**
|
|
3844
3947
|
* 指定された要素を監視します。
|
|
@@ -3858,11 +3961,11 @@ const H = class H {
|
|
|
3858
3961
|
i.attributeName
|
|
3859
3962
|
);
|
|
3860
3963
|
const s = i.target;
|
|
3861
|
-
|
|
3964
|
+
x.setAttribute(
|
|
3862
3965
|
s,
|
|
3863
3966
|
i.attributeName,
|
|
3864
3967
|
s.getAttribute(i.attributeName)
|
|
3865
|
-
),
|
|
3968
|
+
), $.syncElement(s);
|
|
3866
3969
|
break;
|
|
3867
3970
|
}
|
|
3868
3971
|
case "childList": {
|
|
@@ -3872,9 +3975,9 @@ const H = class H {
|
|
|
3872
3975
|
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3873
3976
|
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3874
3977
|
), Array.from(i.removedNodes).forEach((s) => {
|
|
3875
|
-
|
|
3978
|
+
$.cleanupTree(s), x.removeNode(s);
|
|
3876
3979
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3877
|
-
s.parentElement instanceof HTMLElement && (
|
|
3980
|
+
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s), $.syncTree(s));
|
|
3878
3981
|
});
|
|
3879
3982
|
break;
|
|
3880
3983
|
}
|
|
@@ -3884,7 +3987,7 @@ const H = class H {
|
|
|
3884
3987
|
"Character data changed:",
|
|
3885
3988
|
i.target,
|
|
3886
3989
|
i.target.textContent
|
|
3887
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
3990
|
+
), i.target instanceof Text || i.target instanceof Comment ? x.changeText(i.target, i.target.textContent) : h.warn(
|
|
3888
3991
|
"[Haori]",
|
|
3889
3992
|
"Unsupported character data type:",
|
|
3890
3993
|
i.target
|
|
@@ -3907,18 +4010,18 @@ const H = class H {
|
|
|
3907
4010
|
}
|
|
3908
4011
|
};
|
|
3909
4012
|
H._initialized = !1;
|
|
3910
|
-
let
|
|
3911
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
3912
|
-
const
|
|
4013
|
+
let q = H;
|
|
4014
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4015
|
+
const ft = "0.4.3";
|
|
3913
4016
|
export {
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
4017
|
+
x as Core,
|
|
4018
|
+
c as Env,
|
|
4019
|
+
m as Form,
|
|
4020
|
+
N as Fragment,
|
|
4021
|
+
tt as Haori,
|
|
3919
4022
|
h as Log,
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4023
|
+
P as Queue,
|
|
4024
|
+
tt as default,
|
|
4025
|
+
ft as version
|
|
3923
4026
|
};
|
|
3924
4027
|
//# sourceMappingURL=haori.es.js.map
|