haori 0.4.0 → 0.4.2
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 +411 -354
- 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 +34 -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 +54 -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/tests/data-fetch-form-input-binding.test.d.ts +2 -0
- package/dist/tests/data-fetch-form-input-binding.test.d.ts.map +1 -0
- package/dist/tests/data-fetch-form-input-binding.test.js +202 -0
- package/dist/tests/data-fetch-form-input-binding.test.js.map +1 -0
- package/dist/tests/fragment.test.js +1 -1
- package/dist/tests/fragment.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -336,7 +336,7 @@ function Q() {
|
|
|
336
336
|
(r) => typeof t?.[r] == "function"
|
|
337
337
|
) ? t : _;
|
|
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
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -365,11 +365,11 @@ class A {
|
|
|
365
365
|
`Element cannot have both ${l.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
375
|
`Element cannot have both ${l.prefix}form-list and ${l.prefix}form-object attributes.`
|
|
@@ -378,12 +378,12 @@ class A {
|
|
|
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(`${l.prefix}form-object`), d = t.getAttribute(`${l.prefix}form-list`), y = t.getAttribute(`${l.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 == "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 v of t.getChildElementFragments())
|
|
448
|
+
n.push(
|
|
449
|
+
m.setPartValues(
|
|
450
|
+
v,
|
|
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
|
-
f
|
|
439
|
-
|
|
440
|
-
i
|
|
457
|
+
} else if (d) {
|
|
458
|
+
const b = e[String(d)];
|
|
459
|
+
if (Array.isArray(b)) {
|
|
460
|
+
const v = t.getChildElementFragments();
|
|
461
|
+
for (let f = 0; f < v.length; f++) {
|
|
462
|
+
const u = v[f];
|
|
463
|
+
b.length > f ? n.push(
|
|
464
|
+
m.setPartValues(
|
|
465
|
+
u,
|
|
466
|
+
b[f],
|
|
467
|
+
f,
|
|
468
|
+
i,
|
|
469
|
+
s
|
|
441
470
|
)
|
|
442
|
-
) :
|
|
471
|
+
) : n.push(m.setPartValues(u, {}, f, 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,9 +487,9 @@ class A {
|
|
|
456
487
|
* @returns すべての初期化処理が完了するPromise
|
|
457
488
|
*/
|
|
458
489
|
static async reset(t) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
490
|
+
m.clearValues(t), await Promise.all([
|
|
491
|
+
m.clearMessages(t),
|
|
492
|
+
m.clearEachClones(t)
|
|
462
493
|
]), await F.enqueue(() => {
|
|
463
494
|
const e = t.getTarget();
|
|
464
495
|
if (e instanceof HTMLFormElement)
|
|
@@ -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 によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -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
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -527,7 +558,7 @@ class A {
|
|
|
527
558
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
528
559
|
*/
|
|
529
560
|
static addErrorMessage(t, e, r) {
|
|
530
|
-
const i = [], s = Q(), n =
|
|
561
|
+
const i = [], s = Q(), 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
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -559,7 +590,7 @@ class A {
|
|
|
559
590
|
const r = [], i = e[0];
|
|
560
591
|
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${l.prefix}form-object`))
|
|
561
592
|
e.length > 1 && t.getAttribute(`${l.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
562
|
-
r.push(...
|
|
593
|
+
r.push(...m.findFragmentByKeyParts(n, e.slice(1)));
|
|
563
594
|
});
|
|
564
595
|
else if (t.hasAttribute(`${l.prefix}form-list`)) {
|
|
565
596
|
if (e.length > 1) {
|
|
@@ -567,13 +598,13 @@ class A {
|
|
|
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((v) => v.hasAttribute(`${l.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
|
}
|
|
@@ -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(
|
|
@@ -1496,25 +1527,46 @@ class D extends N {
|
|
|
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, F.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, F.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 N {
|
|
|
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
|
}
|
|
@@ -1573,7 +1626,7 @@ class D extends N {
|
|
|
1573
1626
|
i.removeAttribute(t);
|
|
1574
1627
|
else {
|
|
1575
1628
|
const n = String(s);
|
|
1576
|
-
i.getAttribute(t) !== n && i.setAttribute(t, n);
|
|
1629
|
+
i.getAttribute(t) !== n && i.setAttribute(t, n), t === "value" && (i instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(i.type) || i instanceof HTMLTextAreaElement || i instanceof HTMLSelectElement) && (this.value = n, i.value !== n && (i.value = n));
|
|
1577
1630
|
}
|
|
1578
1631
|
}).finally(() => {
|
|
1579
1632
|
this.skipMutationAttributes = !1;
|
|
@@ -1683,32 +1736,32 @@ class D extends N {
|
|
|
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 v;
|
|
1746
|
+
if (n ? a !== -1 && a < o ? v = o - 1 : v = o : v = this.children.indexOf(e), v === -1) {
|
|
1747
|
+
const f = this.resolveInsertionPointFromDom(
|
|
1695
1748
|
e,
|
|
1696
1749
|
!1
|
|
1697
1750
|
);
|
|
1698
|
-
|
|
1751
|
+
f === 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(f.index, 0, t), y = f.referenceNode);
|
|
1703
1756
|
} else
|
|
1704
|
-
this.children.splice(
|
|
1757
|
+
this.children.splice(v, 0, t);
|
|
1705
1758
|
}
|
|
1706
1759
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1707
|
-
const
|
|
1760
|
+
const b = this.skipMutationNodes;
|
|
1708
1761
|
return this.skipMutationNodes = !0, F.enqueue(() => {
|
|
1709
|
-
this.target.insertBefore(t.getTarget(),
|
|
1762
|
+
this.target.insertBefore(t.getTarget(), y);
|
|
1710
1763
|
}).finally(() => {
|
|
1711
|
-
this.skipMutationNodes =
|
|
1764
|
+
this.skipMutationNodes = b;
|
|
1712
1765
|
});
|
|
1713
1766
|
}
|
|
1714
1767
|
/**
|
|
@@ -2040,7 +2093,7 @@ J.FORCE_EVALUATION_ATTRIBUTES = [
|
|
|
2040
2093
|
"hor-each"
|
|
2041
2094
|
];
|
|
2042
2095
|
let q = J;
|
|
2043
|
-
class
|
|
2096
|
+
class w {
|
|
2044
2097
|
/**
|
|
2045
2098
|
* カスタムイベントを発火します。
|
|
2046
2099
|
*
|
|
@@ -2064,7 +2117,7 @@ class v {
|
|
|
2064
2117
|
* @param version ライブラリバージョン
|
|
2065
2118
|
*/
|
|
2066
2119
|
static ready(t) {
|
|
2067
|
-
|
|
2120
|
+
w.dispatch(document, "ready", { version: t });
|
|
2068
2121
|
}
|
|
2069
2122
|
/**
|
|
2070
2123
|
* renderイベントを発火します。
|
|
@@ -2072,7 +2125,7 @@ class v {
|
|
|
2072
2125
|
* @param target 評価対象要素
|
|
2073
2126
|
*/
|
|
2074
2127
|
static render(t) {
|
|
2075
|
-
|
|
2128
|
+
w.dispatch(t, "render", { target: t });
|
|
2076
2129
|
}
|
|
2077
2130
|
/**
|
|
2078
2131
|
* importstartイベントを発火します。
|
|
@@ -2081,7 +2134,7 @@ class v {
|
|
|
2081
2134
|
* @param url インポート対象URL
|
|
2082
2135
|
*/
|
|
2083
2136
|
static importStart(t, e) {
|
|
2084
|
-
|
|
2137
|
+
w.dispatch(t, "importstart", {
|
|
2085
2138
|
url: e,
|
|
2086
2139
|
startedAt: performance.now()
|
|
2087
2140
|
});
|
|
@@ -2095,7 +2148,7 @@ class v {
|
|
|
2095
2148
|
* @param startedAt 開始時刻
|
|
2096
2149
|
*/
|
|
2097
2150
|
static importEnd(t, e, r, i) {
|
|
2098
|
-
|
|
2151
|
+
w.dispatch(t, "importend", {
|
|
2099
2152
|
url: e,
|
|
2100
2153
|
bytes: r,
|
|
2101
2154
|
durationMs: performance.now() - i
|
|
@@ -2109,7 +2162,7 @@ class v {
|
|
|
2109
2162
|
* @param error エラー内容
|
|
2110
2163
|
*/
|
|
2111
2164
|
static importError(t, e, r) {
|
|
2112
|
-
|
|
2165
|
+
w.dispatch(t, "importerror", { url: e, error: r });
|
|
2113
2166
|
}
|
|
2114
2167
|
/**
|
|
2115
2168
|
* bindchangeイベントを発火します。
|
|
@@ -2121,11 +2174,11 @@ 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
|
+
w.dispatch(t, "bindchange", {
|
|
2129
2182
|
previous: e || {},
|
|
2130
2183
|
next: r,
|
|
2131
2184
|
changedKeys: s,
|
|
@@ -2141,7 +2194,7 @@ class v {
|
|
|
2141
2194
|
* @param order 現在の順序
|
|
2142
2195
|
*/
|
|
2143
2196
|
static eachUpdate(t, e, r, i) {
|
|
2144
|
-
|
|
2197
|
+
w.dispatch(t, "eachupdate", {
|
|
2145
2198
|
added: e,
|
|
2146
2199
|
removed: r,
|
|
2147
2200
|
order: i,
|
|
@@ -2157,7 +2210,7 @@ class v {
|
|
|
2157
2210
|
* @param item 行データ
|
|
2158
2211
|
*/
|
|
2159
2212
|
static rowAdd(t, e, r, i) {
|
|
2160
|
-
|
|
2213
|
+
w.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2161
2214
|
}
|
|
2162
2215
|
/**
|
|
2163
2216
|
* rowremoveイベントを発火します。
|
|
@@ -2167,7 +2220,7 @@ class v {
|
|
|
2167
2220
|
* @param index インデックス
|
|
2168
2221
|
*/
|
|
2169
2222
|
static rowRemove(t, e, r) {
|
|
2170
|
-
|
|
2223
|
+
w.dispatch(t, "rowremove", { key: e, index: r });
|
|
2171
2224
|
}
|
|
2172
2225
|
/**
|
|
2173
2226
|
* rowmoveイベントを発火します。
|
|
@@ -2178,7 +2231,7 @@ class v {
|
|
|
2178
2231
|
* @param to 移動後インデックス
|
|
2179
2232
|
*/
|
|
2180
2233
|
static rowMove(t, e, r, i) {
|
|
2181
|
-
|
|
2234
|
+
w.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2182
2235
|
}
|
|
2183
2236
|
/**
|
|
2184
2237
|
* showイベントを発火します。
|
|
@@ -2186,7 +2239,7 @@ class v {
|
|
|
2186
2239
|
* @param target data-if要素
|
|
2187
2240
|
*/
|
|
2188
2241
|
static show(t) {
|
|
2189
|
-
|
|
2242
|
+
w.dispatch(t, "show", { visible: !0 });
|
|
2190
2243
|
}
|
|
2191
2244
|
/**
|
|
2192
2245
|
* hideイベントを発火します。
|
|
@@ -2194,7 +2247,7 @@ class v {
|
|
|
2194
2247
|
* @param target data-if要素
|
|
2195
2248
|
*/
|
|
2196
2249
|
static hide(t) {
|
|
2197
|
-
|
|
2250
|
+
w.dispatch(t, "hide", { visible: !1 });
|
|
2198
2251
|
}
|
|
2199
2252
|
/**
|
|
2200
2253
|
* fetchstartイベントを発火します。
|
|
@@ -2207,7 +2260,7 @@ class v {
|
|
|
2207
2260
|
* @return 戻り値はありません。
|
|
2208
2261
|
*/
|
|
2209
2262
|
static fetchStart(t, e, r, i, s) {
|
|
2210
|
-
|
|
2263
|
+
w.dispatch(t, "fetchstart", {
|
|
2211
2264
|
url: e,
|
|
2212
2265
|
options: r || {},
|
|
2213
2266
|
payload: i,
|
|
@@ -2224,7 +2277,7 @@ class v {
|
|
|
2224
2277
|
* @param startedAt 開始時刻
|
|
2225
2278
|
*/
|
|
2226
2279
|
static fetchEnd(t, e, r, i) {
|
|
2227
|
-
|
|
2280
|
+
w.dispatch(t, "fetchend", {
|
|
2228
2281
|
url: e,
|
|
2229
2282
|
status: r,
|
|
2230
2283
|
durationMs: performance.now() - i
|
|
@@ -2240,7 +2293,7 @@ class v {
|
|
|
2240
2293
|
* @param startedAt 開始時刻(存在する場合)
|
|
2241
2294
|
*/
|
|
2242
2295
|
static fetchError(t, e, r, i, s) {
|
|
2243
|
-
|
|
2296
|
+
w.dispatch(t, "fetcherror", {
|
|
2244
2297
|
url: e,
|
|
2245
2298
|
status: i,
|
|
2246
2299
|
error: r,
|
|
@@ -2389,12 +2442,12 @@ const c = class c {
|
|
|
2389
2442
|
if (typeof i != "string" || r === null)
|
|
2390
2443
|
return null;
|
|
2391
2444
|
const s = r.trim();
|
|
2392
|
-
return c.SINGLE_PLACEHOLDER_REGEX.test(s) ?
|
|
2445
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(s) ? x.parseDataBind(i) : s.startsWith("{") || s.startsWith("[") ? x.parseDataBind(
|
|
2393
2446
|
c.resolveDataJsonString(
|
|
2394
2447
|
r,
|
|
2395
2448
|
t.getBindingData()
|
|
2396
2449
|
)
|
|
2397
|
-
) :
|
|
2450
|
+
) : x.parseDataBind(
|
|
2398
2451
|
c.resolveDataParamString(r, t.getBindingData())
|
|
2399
2452
|
);
|
|
2400
2453
|
}
|
|
@@ -2416,22 +2469,22 @@ const c = class c {
|
|
|
2416
2469
|
t,
|
|
2417
2470
|
c.attrName(e, "data")
|
|
2418
2471
|
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2419
|
-
const
|
|
2472
|
+
const f = t.getRawAttribute(
|
|
2420
2473
|
c.attrName(e, "form")
|
|
2421
2474
|
);
|
|
2422
|
-
if (
|
|
2423
|
-
const u = document.body.querySelector(
|
|
2424
|
-
u !== null ? r.formFragment =
|
|
2475
|
+
if (f) {
|
|
2476
|
+
const u = document.body.querySelector(f);
|
|
2477
|
+
u !== null ? r.formFragment = m.getFormFragment(
|
|
2425
2478
|
N.get(u)
|
|
2426
2479
|
) : h.error(
|
|
2427
2480
|
"Haori",
|
|
2428
|
-
`Form element not found: ${
|
|
2481
|
+
`Form element not found: ${f} (${c.attrName(e, "form")})`
|
|
2429
2482
|
);
|
|
2430
2483
|
} else
|
|
2431
|
-
r.formFragment =
|
|
2432
|
-
} else e === "change" && (r.formFragment =
|
|
2484
|
+
r.formFragment = m.getFormFragment(t);
|
|
2485
|
+
} else e === "change" && (r.formFragment = m.getFormFragment(t));
|
|
2433
2486
|
if (t.hasAttribute(`${l.prefix}${e}-before-run`)) {
|
|
2434
|
-
const
|
|
2487
|
+
const f = t.getRawAttribute(
|
|
2435
2488
|
`${l.prefix}${e}-before-run`
|
|
2436
2489
|
);
|
|
2437
2490
|
try {
|
|
@@ -2440,7 +2493,7 @@ const c = class c {
|
|
|
2440
2493
|
"fetchOptions",
|
|
2441
2494
|
`
|
|
2442
2495
|
"use strict";
|
|
2443
|
-
${
|
|
2496
|
+
${f}
|
|
2444
2497
|
`
|
|
2445
2498
|
);
|
|
2446
2499
|
} catch (u) {
|
|
@@ -2452,54 +2505,54 @@ ${d}
|
|
|
2452
2505
|
s && (r.fetchUrl = t.getAttribute(i));
|
|
2453
2506
|
const n = {};
|
|
2454
2507
|
if (e) {
|
|
2455
|
-
const
|
|
2456
|
-
t.hasAttribute(
|
|
2457
|
-
|
|
2508
|
+
const f = c.attrName(e, "fetch-method");
|
|
2509
|
+
t.hasAttribute(f) && (n.method = t.getAttribute(
|
|
2510
|
+
f
|
|
2458
2511
|
));
|
|
2459
2512
|
} else {
|
|
2460
|
-
const
|
|
2461
|
-
t.hasAttribute(
|
|
2462
|
-
|
|
2513
|
+
const f = c.attrName(null, "method", !0);
|
|
2514
|
+
t.hasAttribute(f) && (n.method = t.getAttribute(
|
|
2515
|
+
f
|
|
2463
2516
|
));
|
|
2464
2517
|
}
|
|
2465
2518
|
if (e) {
|
|
2466
|
-
const
|
|
2467
|
-
if (t.hasAttribute(
|
|
2519
|
+
const f = c.attrName(e, "fetch-headers");
|
|
2520
|
+
if (t.hasAttribute(f)) {
|
|
2468
2521
|
const u = t.getRawAttribute(
|
|
2469
|
-
|
|
2522
|
+
f
|
|
2470
2523
|
);
|
|
2471
2524
|
try {
|
|
2472
|
-
n.headers =
|
|
2473
|
-
} catch (
|
|
2474
|
-
h.error("Haori", `Invalid fetch headers: ${
|
|
2525
|
+
n.headers = x.parseDataBind(u);
|
|
2526
|
+
} catch (p) {
|
|
2527
|
+
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2475
2528
|
}
|
|
2476
2529
|
}
|
|
2477
2530
|
} else {
|
|
2478
|
-
const
|
|
2531
|
+
const f = c.attrName(
|
|
2479
2532
|
null,
|
|
2480
2533
|
"headers",
|
|
2481
2534
|
!0
|
|
2482
2535
|
);
|
|
2483
|
-
if (t.hasAttribute(
|
|
2536
|
+
if (t.hasAttribute(f)) {
|
|
2484
2537
|
const u = t.getRawAttribute(
|
|
2485
|
-
|
|
2538
|
+
f
|
|
2486
2539
|
);
|
|
2487
2540
|
try {
|
|
2488
|
-
n.headers =
|
|
2489
|
-
} catch (
|
|
2490
|
-
h.error("Haori", `Invalid fetch headers: ${
|
|
2541
|
+
n.headers = x.parseDataBind(u);
|
|
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 f = c.attrName(
|
|
2496
2549
|
e,
|
|
2497
2550
|
"fetch-content-type"
|
|
2498
2551
|
);
|
|
2499
|
-
if (t.hasAttribute(
|
|
2552
|
+
if (t.hasAttribute(f))
|
|
2500
2553
|
n.headers = {
|
|
2501
2554
|
...n.headers,
|
|
2502
|
-
"Content-Type": t.getAttribute(
|
|
2555
|
+
"Content-Type": t.getAttribute(f)
|
|
2503
2556
|
};
|
|
2504
2557
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2505
2558
|
let u = !1;
|
|
@@ -2512,15 +2565,15 @@ ${d}
|
|
|
2512
2565
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2513
2566
|
});
|
|
2514
2567
|
} else {
|
|
2515
|
-
const
|
|
2568
|
+
const f = c.attrName(
|
|
2516
2569
|
null,
|
|
2517
2570
|
"content-type",
|
|
2518
2571
|
!0
|
|
2519
2572
|
);
|
|
2520
|
-
if (t.hasAttribute(
|
|
2573
|
+
if (t.hasAttribute(f))
|
|
2521
2574
|
n.headers = {
|
|
2522
2575
|
...n.headers,
|
|
2523
|
-
"Content-Type": t.getAttribute(
|
|
2576
|
+
"Content-Type": t.getAttribute(f)
|
|
2524
2577
|
};
|
|
2525
2578
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2526
2579
|
let u = !1;
|
|
@@ -2536,39 +2589,39 @@ ${d}
|
|
|
2536
2589
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2537
2590
|
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2538
2591
|
if (t.hasAttribute(a)) {
|
|
2539
|
-
const
|
|
2540
|
-
if (
|
|
2541
|
-
const u = document.body.querySelectorAll(
|
|
2542
|
-
u.length > 0 ? (r.bindFragments = [], u.forEach((
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2592
|
+
const f = t.getRawAttribute(a);
|
|
2593
|
+
if (f) {
|
|
2594
|
+
const u = document.body.querySelectorAll(f);
|
|
2595
|
+
u.length > 0 ? (r.bindFragments = [], u.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: ${f} (${a})`
|
|
2548
2601
|
);
|
|
2549
2602
|
}
|
|
2550
2603
|
}
|
|
2551
|
-
const o = c.attrName(e, "bind-arg"),
|
|
2604
|
+
const o = c.attrName(e, "bind-arg"), d = c.attrName(
|
|
2552
2605
|
null,
|
|
2553
2606
|
"arg",
|
|
2554
2607
|
!0
|
|
2555
|
-
),
|
|
2608
|
+
), y = c.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 ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2617
|
+
if (t.hasAttribute(b)) {
|
|
2618
|
+
const f = t.getRawAttribute(b);
|
|
2619
|
+
r.bindParams = f.split("&").map((u) => u.trim());
|
|
2567
2620
|
}
|
|
2568
|
-
const
|
|
2569
|
-
if (t.hasAttribute(
|
|
2570
|
-
const
|
|
2571
|
-
r.bindAppendParams =
|
|
2621
|
+
const v = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2622
|
+
if (t.hasAttribute(v)) {
|
|
2623
|
+
const f = t.getRawAttribute(v);
|
|
2624
|
+
r.bindAppendParams = f.split("&").map((u) => u.trim()).filter(Boolean);
|
|
2572
2625
|
}
|
|
2573
2626
|
if (e) {
|
|
2574
2627
|
if (t.hasAttribute(c.attrName(e, "adjust"))) {
|
|
@@ -2576,20 +2629,20 @@ ${d}
|
|
|
2576
2629
|
c.attrName(e, "adjust")
|
|
2577
2630
|
);
|
|
2578
2631
|
if (u) {
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2632
|
+
const p = document.body.querySelectorAll(u);
|
|
2633
|
+
p.length > 0 ? (r.adjustFragments = [], p.forEach((E) => {
|
|
2634
|
+
const A = N.get(E);
|
|
2635
|
+
A && r.adjustFragments.push(A);
|
|
2583
2636
|
})) : h.error(
|
|
2584
2637
|
"Haori",
|
|
2585
2638
|
`Adjust element not found: ${u} (${c.attrName(e, "adjust")})`
|
|
2586
2639
|
);
|
|
2587
2640
|
}
|
|
2588
2641
|
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2589
|
-
const
|
|
2642
|
+
const p = t.getRawAttribute(
|
|
2590
2643
|
c.attrName(e, "adjust-value")
|
|
2591
|
-
),
|
|
2592
|
-
isNaN(
|
|
2644
|
+
), E = Number(p);
|
|
2645
|
+
isNaN(E) || (r.adjustValue = E);
|
|
2593
2646
|
}
|
|
2594
2647
|
}
|
|
2595
2648
|
if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${l.prefix}${e}-after-run`)) {
|
|
@@ -2604,8 +2657,8 @@ ${d}
|
|
|
2604
2657
|
${u}
|
|
2605
2658
|
`
|
|
2606
2659
|
);
|
|
2607
|
-
} catch (
|
|
2608
|
-
h.error("Haori", `Invalid after script: ${
|
|
2660
|
+
} catch (p) {
|
|
2661
|
+
h.error("Haori", `Invalid after script: ${p}`);
|
|
2609
2662
|
}
|
|
2610
2663
|
}
|
|
2611
2664
|
if (t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
@@ -2624,15 +2677,15 @@ ${u}
|
|
|
2624
2677
|
c.attrName(e, "history-form")
|
|
2625
2678
|
);
|
|
2626
2679
|
if (u) {
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2629
|
-
N.get(
|
|
2680
|
+
const p = document.body.querySelector(u);
|
|
2681
|
+
p !== null ? r.historyFormFragment = m.getFormFragment(
|
|
2682
|
+
N.get(p)
|
|
2630
2683
|
) : h.error(
|
|
2631
2684
|
"Haori",
|
|
2632
2685
|
`Form element not found: ${u} (${c.attrName(e, "history-form")})`
|
|
2633
2686
|
);
|
|
2634
2687
|
} else
|
|
2635
|
-
r.historyFormFragment =
|
|
2688
|
+
r.historyFormFragment = m.getFormFragment(t);
|
|
2636
2689
|
}
|
|
2637
2690
|
[
|
|
2638
2691
|
"reset",
|
|
@@ -2641,29 +2694,29 @@ ${u}
|
|
|
2641
2694
|
"open",
|
|
2642
2695
|
"close"
|
|
2643
2696
|
].forEach((u) => {
|
|
2644
|
-
const
|
|
2645
|
-
if (!t.hasAttribute(
|
|
2697
|
+
const p = c.attrName(e, u);
|
|
2698
|
+
if (!t.hasAttribute(p))
|
|
2646
2699
|
return;
|
|
2647
|
-
const
|
|
2648
|
-
if (
|
|
2700
|
+
const E = t.getRawAttribute(p), A = [];
|
|
2701
|
+
if (E ? (document.body.querySelectorAll(E).forEach((k) => {
|
|
2649
2702
|
const U = N.get(k);
|
|
2650
|
-
U &&
|
|
2651
|
-
}),
|
|
2703
|
+
U && A.push(U);
|
|
2704
|
+
}), A.length === 0 && h.error("Haori", `Element not found: ${E} (${p})`)) : A.push(t), A.length > 0)
|
|
2652
2705
|
switch (u) {
|
|
2653
2706
|
case "reset":
|
|
2654
|
-
r.resetFragments =
|
|
2707
|
+
r.resetFragments = A;
|
|
2655
2708
|
break;
|
|
2656
2709
|
case "refetch":
|
|
2657
|
-
r.refetchFragments =
|
|
2710
|
+
r.refetchFragments = A;
|
|
2658
2711
|
break;
|
|
2659
2712
|
case "click":
|
|
2660
|
-
r.clickFragments =
|
|
2713
|
+
r.clickFragments = A;
|
|
2661
2714
|
break;
|
|
2662
2715
|
case "open":
|
|
2663
|
-
r.openFragments =
|
|
2716
|
+
r.openFragments = A;
|
|
2664
2717
|
break;
|
|
2665
2718
|
case "close":
|
|
2666
|
-
r.closeFragments =
|
|
2719
|
+
r.closeFragments = A;
|
|
2667
2720
|
break;
|
|
2668
2721
|
}
|
|
2669
2722
|
});
|
|
@@ -2672,19 +2725,19 @@ ${u}
|
|
|
2672
2725
|
t,
|
|
2673
2726
|
c.attrName(null, "data", !0)
|
|
2674
2727
|
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2675
|
-
const
|
|
2728
|
+
const f = t.getRawAttribute(
|
|
2676
2729
|
c.attrName(null, "form", !0)
|
|
2677
2730
|
);
|
|
2678
|
-
if (
|
|
2679
|
-
const u = document.body.querySelector(
|
|
2680
|
-
u !== null ? r.formFragment =
|
|
2731
|
+
if (f) {
|
|
2732
|
+
const u = document.body.querySelector(f);
|
|
2733
|
+
u !== null ? r.formFragment = m.getFormFragment(
|
|
2681
2734
|
N.get(u)
|
|
2682
2735
|
) : h.error(
|
|
2683
2736
|
"Haori",
|
|
2684
|
-
`Form element not found: ${
|
|
2737
|
+
`Form element not found: ${f} (${c.attrName(null, "fetch-form", !0)})`
|
|
2685
2738
|
);
|
|
2686
2739
|
} else
|
|
2687
|
-
r.formFragment =
|
|
2740
|
+
r.formFragment = m.getFormFragment(t);
|
|
2688
2741
|
}
|
|
2689
2742
|
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2690
2743
|
}
|
|
@@ -2748,79 +2801,79 @@ ${u}
|
|
|
2748
2801
|
}
|
|
2749
2802
|
const i = {};
|
|
2750
2803
|
if (this.options.formFragment) {
|
|
2751
|
-
const o =
|
|
2804
|
+
const o = m.getValues(this.options.formFragment);
|
|
2752
2805
|
Object.assign(i, o);
|
|
2753
2806
|
}
|
|
2754
2807
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2755
2808
|
const s = Object.keys(i).length > 0;
|
|
2756
2809
|
if (e) {
|
|
2757
|
-
const o = { ...r || {} },
|
|
2810
|
+
const o = { ...r || {} }, d = new Headers(
|
|
2758
2811
|
o.headers || void 0
|
|
2759
|
-
),
|
|
2760
|
-
if (o.method =
|
|
2812
|
+
), y = (o.method || "GET").toUpperCase(), b = l.runtime === "demo" && !nt(y), v = b ? "GET" : y;
|
|
2813
|
+
if (o.method = v, v === "GET" || v === "HEAD" || v === "OPTIONS")
|
|
2761
2814
|
s && (e = ot(e, i));
|
|
2762
2815
|
else if (s) {
|
|
2763
|
-
const u =
|
|
2816
|
+
const u = d.get("Content-Type") || "";
|
|
2764
2817
|
if (/multipart\/form-data/i.test(u)) {
|
|
2765
|
-
|
|
2766
|
-
const
|
|
2767
|
-
for (const [
|
|
2768
|
-
|
|
2769
|
-
o.body =
|
|
2818
|
+
d.delete("Content-Type");
|
|
2819
|
+
const p = new FormData();
|
|
2820
|
+
for (const [E, A] of Object.entries(i))
|
|
2821
|
+
A == null ? p.append(E, "") : A instanceof Blob ? p.append(E, A) : Array.isArray(A) ? A.forEach((R) => p.append(E, String(R))) : typeof A == "object" ? p.append(E, JSON.stringify(A)) : p.append(E, String(A));
|
|
2822
|
+
o.body = p;
|
|
2770
2823
|
} else if (/application\/x-www-form-urlencoded/i.test(u)) {
|
|
2771
|
-
const
|
|
2772
|
-
for (const [
|
|
2773
|
-
|
|
2774
|
-
o.body =
|
|
2824
|
+
const p = new URLSearchParams();
|
|
2825
|
+
for (const [E, A] of Object.entries(i))
|
|
2826
|
+
A !== void 0 && (A === null ? p.append(E, "") : Array.isArray(A) ? A.forEach((R) => p.append(E, String(R))) : typeof A == "object" ? p.append(E, JSON.stringify(A)) : p.append(E, String(A)));
|
|
2827
|
+
o.body = p;
|
|
2775
2828
|
} else
|
|
2776
|
-
|
|
2829
|
+
d.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2777
2830
|
}
|
|
2778
|
-
o.headers =
|
|
2779
|
-
let
|
|
2780
|
-
if (
|
|
2831
|
+
o.headers = d;
|
|
2832
|
+
let f;
|
|
2833
|
+
if (b && (f = e && new URL(e, window.location.href).search || void 0, d.delete("Content-Type"), h.info("Haori demo fetch normalization", {
|
|
2781
2834
|
runtime: l.runtime,
|
|
2782
|
-
requestedMethod:
|
|
2783
|
-
effectiveMethod:
|
|
2835
|
+
requestedMethod: y,
|
|
2836
|
+
effectiveMethod: v,
|
|
2784
2837
|
transportMode: "query-get",
|
|
2785
2838
|
url: e,
|
|
2786
2839
|
payload: s ? i : void 0,
|
|
2787
|
-
queryString:
|
|
2840
|
+
queryString: f
|
|
2788
2841
|
})), this.options.targetFragment && e) {
|
|
2789
|
-
const u = performance.now(),
|
|
2842
|
+
const u = performance.now(), p = {
|
|
2790
2843
|
runtime: l.runtime,
|
|
2791
|
-
requestedMethod:
|
|
2792
|
-
effectiveMethod:
|
|
2793
|
-
transportMode:
|
|
2794
|
-
...
|
|
2844
|
+
requestedMethod: y,
|
|
2845
|
+
effectiveMethod: v,
|
|
2846
|
+
transportMode: b ? "query-get" : "http",
|
|
2847
|
+
...b ? { queryString: f } : {}
|
|
2795
2848
|
};
|
|
2796
|
-
return
|
|
2849
|
+
return w.fetchStart(
|
|
2797
2850
|
this.options.targetFragment.getTarget(),
|
|
2798
2851
|
e,
|
|
2799
2852
|
o,
|
|
2800
2853
|
s ? i : void 0,
|
|
2801
|
-
|
|
2802
|
-
), fetch(e, o).then((
|
|
2803
|
-
|
|
2854
|
+
p
|
|
2855
|
+
), fetch(e, o).then((E) => this.handleFetchResult(
|
|
2856
|
+
E,
|
|
2804
2857
|
e || void 0,
|
|
2805
2858
|
u
|
|
2806
|
-
)).catch((
|
|
2807
|
-
throw e &&
|
|
2859
|
+
)).catch((E) => {
|
|
2860
|
+
throw e && w.fetchError(
|
|
2808
2861
|
this.options.targetFragment.getTarget(),
|
|
2809
2862
|
e,
|
|
2810
|
-
|
|
2811
|
-
),
|
|
2863
|
+
E
|
|
2864
|
+
), E;
|
|
2812
2865
|
});
|
|
2813
2866
|
}
|
|
2814
2867
|
return fetch(e, o).then((u) => this.handleFetchResult(u, e || void 0));
|
|
2815
2868
|
}
|
|
2816
2869
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2817
|
-
const o = this.options.formFragment,
|
|
2818
|
-
|
|
2870
|
+
const o = this.options.formFragment, d = o.getTarget();
|
|
2871
|
+
d.setAttribute(
|
|
2819
2872
|
`${l.prefix}bind`,
|
|
2820
2873
|
JSON.stringify(i)
|
|
2821
2874
|
);
|
|
2822
|
-
const
|
|
2823
|
-
return Object.assign(
|
|
2875
|
+
const y = o.getBindingData();
|
|
2876
|
+
return Object.assign(y, i), await x.setBindingData(d, y), !0;
|
|
2824
2877
|
}
|
|
2825
2878
|
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2826
2879
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2833,14 +2886,14 @@ ${u}
|
|
|
2833
2886
|
async handleFetchResult(t, e, r) {
|
|
2834
2887
|
const i = X();
|
|
2835
2888
|
if (!t.ok)
|
|
2836
|
-
return this.options.targetFragment && e &&
|
|
2889
|
+
return this.options.targetFragment && e && w.fetchError(
|
|
2837
2890
|
this.options.targetFragment.getTarget(),
|
|
2838
2891
|
e,
|
|
2839
2892
|
new Error(`${t.status} ${t.statusText}`),
|
|
2840
2893
|
t.status,
|
|
2841
2894
|
r
|
|
2842
2895
|
), await this.handleFetchError(t), !1;
|
|
2843
|
-
if (this.options.targetFragment && e && r &&
|
|
2896
|
+
if (this.options.targetFragment && e && r && w.fetchEnd(
|
|
2844
2897
|
this.options.targetFragment.getTarget(),
|
|
2845
2898
|
e,
|
|
2846
2899
|
t.status,
|
|
@@ -2855,7 +2908,7 @@ ${u}
|
|
|
2855
2908
|
}
|
|
2856
2909
|
const s = [];
|
|
2857
2910
|
return 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()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((n) => {
|
|
2858
|
-
s.push(
|
|
2911
|
+
s.push(m.reset(n));
|
|
2859
2912
|
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((n) => {
|
|
2860
2913
|
s.push(new c(n, null).run());
|
|
2861
2914
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((n) => {
|
|
@@ -2892,11 +2945,11 @@ ${u}
|
|
|
2892
2945
|
return;
|
|
2893
2946
|
}
|
|
2894
2947
|
const n = (a) => {
|
|
2895
|
-
for (const [o,
|
|
2896
|
-
|
|
2948
|
+
for (const [o, d] of Object.entries(a))
|
|
2949
|
+
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
2950
|
};
|
|
2898
2951
|
e && n(this.options.historyData), r && n(
|
|
2899
|
-
|
|
2952
|
+
m.getValues(
|
|
2900
2953
|
this.options.historyFormFragment
|
|
2901
2954
|
)
|
|
2902
2955
|
), history.pushState({}, "", s.toString());
|
|
@@ -2909,7 +2962,7 @@ ${u}
|
|
|
2909
2962
|
*/
|
|
2910
2963
|
async handleFetchError(t) {
|
|
2911
2964
|
let e = null;
|
|
2912
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
2965
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = m.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2913
2966
|
const r = async (s) => {
|
|
2914
2967
|
const n = e ? e.getTarget() : document.body;
|
|
2915
2968
|
await X().addErrorMessage(n, s);
|
|
@@ -2933,7 +2986,7 @@ ${u}
|
|
|
2933
2986
|
if (n.length === 0)
|
|
2934
2987
|
return await r(`${t.status} ${t.statusText}`), !1;
|
|
2935
2988
|
for (const a of n)
|
|
2936
|
-
a.key && e ? await
|
|
2989
|
+
a.key && e ? await m.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2937
2990
|
return !1;
|
|
2938
2991
|
} catch {
|
|
2939
2992
|
}
|
|
@@ -2999,15 +3052,15 @@ ${u}
|
|
|
2999
3052
|
this.options.bindFragments.forEach((s) => {
|
|
3000
3053
|
const n = s.getBindingData(), a = this.options.bindArg;
|
|
3001
3054
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3002
|
-
const o = n[a],
|
|
3055
|
+
const o = n[a], d = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3003
3056
|
n[a] = this.mergeAppendBindingData(
|
|
3004
3057
|
s,
|
|
3005
3058
|
r,
|
|
3006
|
-
|
|
3059
|
+
d
|
|
3007
3060
|
);
|
|
3008
3061
|
} else
|
|
3009
3062
|
n[a] = r;
|
|
3010
|
-
i.push(
|
|
3063
|
+
i.push(x.setBindingData(s.getTarget(), n));
|
|
3011
3064
|
});
|
|
3012
3065
|
else {
|
|
3013
3066
|
if (typeof r == "string")
|
|
@@ -3020,7 +3073,7 @@ ${u}
|
|
|
3020
3073
|
r
|
|
3021
3074
|
);
|
|
3022
3075
|
i.push(
|
|
3023
|
-
|
|
3076
|
+
x.setBindingData(
|
|
3024
3077
|
s.getTarget(),
|
|
3025
3078
|
n
|
|
3026
3079
|
)
|
|
@@ -3087,7 +3140,7 @@ ${u}
|
|
|
3087
3140
|
const e = [], r = t.clone();
|
|
3088
3141
|
return e.push(
|
|
3089
3142
|
t.getParent().insertAfter(r, t)
|
|
3090
|
-
), e.push(
|
|
3143
|
+
), e.push(x.evaluateAll(r)), e.push(m.reset(r)), Promise.all(e).then(() => {
|
|
3091
3144
|
});
|
|
3092
3145
|
}
|
|
3093
3146
|
/**
|
|
@@ -3154,7 +3207,7 @@ class lt {
|
|
|
3154
3207
|
}), t;
|
|
3155
3208
|
}
|
|
3156
3209
|
}
|
|
3157
|
-
class
|
|
3210
|
+
class ut {
|
|
3158
3211
|
/**
|
|
3159
3212
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3160
3213
|
*
|
|
@@ -3192,7 +3245,7 @@ class ct {
|
|
|
3192
3245
|
}
|
|
3193
3246
|
}
|
|
3194
3247
|
}
|
|
3195
|
-
const
|
|
3248
|
+
const g = class g {
|
|
3196
3249
|
/**
|
|
3197
3250
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
3198
3251
|
*
|
|
@@ -3200,7 +3253,7 @@ const m = class m {
|
|
|
3200
3253
|
* @returns 遅延属性かどうか
|
|
3201
3254
|
*/
|
|
3202
3255
|
static isDeferredAttributeName(t) {
|
|
3203
|
-
return
|
|
3256
|
+
return g.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3204
3257
|
(e) => t === `${l.prefix}${e}`
|
|
3205
3258
|
);
|
|
3206
3259
|
}
|
|
@@ -3211,7 +3264,7 @@ const m = class m {
|
|
|
3211
3264
|
* @returns 除外対象かどうか
|
|
3212
3265
|
*/
|
|
3213
3266
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3214
|
-
return
|
|
3267
|
+
return g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3215
3268
|
(e) => t === `${l.prefix}${e}`
|
|
3216
3269
|
);
|
|
3217
3270
|
}
|
|
@@ -3223,7 +3276,7 @@ const m = class m {
|
|
|
3223
3276
|
* @returns 再評価する場合は true
|
|
3224
3277
|
*/
|
|
3225
3278
|
static shouldReevaluateAttribute(t, e) {
|
|
3226
|
-
return e !== null && !
|
|
3279
|
+
return e !== null && !g.isEvaluateAllExcludedAttributeName(t) && g.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
|
|
3227
3280
|
}
|
|
3228
3281
|
/**
|
|
3229
3282
|
* プレースホルダを含む通常属性を再評価します。
|
|
@@ -3236,7 +3289,7 @@ const m = class m {
|
|
|
3236
3289
|
let e = Promise.resolve();
|
|
3237
3290
|
for (const r of t.getAttributeNames()) {
|
|
3238
3291
|
const i = t.getRawAttribute(r);
|
|
3239
|
-
|
|
3292
|
+
g.shouldReevaluateAttribute(r, i) && (e = e.then(() => t.setAttribute(r, i)));
|
|
3240
3293
|
}
|
|
3241
3294
|
return e.then(() => {
|
|
3242
3295
|
});
|
|
@@ -3253,10 +3306,10 @@ const m = class m {
|
|
|
3253
3306
|
return Promise.resolve();
|
|
3254
3307
|
t.parentNode && (N.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3255
3308
|
const r = [], i = /* @__PURE__ */ new Set();
|
|
3256
|
-
for (const s of
|
|
3309
|
+
for (const s of g.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3257
3310
|
const n = l.prefix + s;
|
|
3258
3311
|
e.hasAttribute(n) && (r.push(
|
|
3259
|
-
|
|
3312
|
+
g.setAttribute(
|
|
3260
3313
|
e.getTarget(),
|
|
3261
3314
|
n,
|
|
3262
3315
|
e.getRawAttribute(n)
|
|
@@ -3264,15 +3317,15 @@ const m = class m {
|
|
|
3264
3317
|
), i.add(n));
|
|
3265
3318
|
}
|
|
3266
3319
|
for (const s of e.getAttributeNames()) {
|
|
3267
|
-
if (i.has(s) ||
|
|
3320
|
+
if (i.has(s) || g.isDeferredAttributeName(s))
|
|
3268
3321
|
continue;
|
|
3269
3322
|
const n = e.getRawAttribute(s);
|
|
3270
|
-
n !== null && r.push(
|
|
3323
|
+
n !== null && r.push(g.setAttribute(e.getTarget(), s, n));
|
|
3271
3324
|
}
|
|
3272
|
-
for (const s of
|
|
3325
|
+
for (const s of g.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3273
3326
|
const n = l.prefix + s;
|
|
3274
3327
|
e.hasAttribute(n) && (r.push(
|
|
3275
|
-
|
|
3328
|
+
g.setAttribute(
|
|
3276
3329
|
e.getTarget(),
|
|
3277
3330
|
n,
|
|
3278
3331
|
e.getRawAttribute(n)
|
|
@@ -3280,7 +3333,7 @@ const m = class m {
|
|
|
3280
3333
|
), i.add(n));
|
|
3281
3334
|
}
|
|
3282
3335
|
return e.getChildren().forEach((s) => {
|
|
3283
|
-
s instanceof D ? r.push(
|
|
3336
|
+
s instanceof D ? r.push(g.scan(s.getTarget())) : s instanceof L && r.push(g.evaluateText(s));
|
|
3284
3337
|
}), Promise.all(r).then(() => {
|
|
3285
3338
|
});
|
|
3286
3339
|
}
|
|
@@ -3297,14 +3350,14 @@ const m = class m {
|
|
|
3297
3350
|
const i = N.get(t), s = [];
|
|
3298
3351
|
switch (e) {
|
|
3299
3352
|
case `${l.prefix}bind`: {
|
|
3300
|
-
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(
|
|
3353
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(g.parseDataBind(r));
|
|
3301
3354
|
break;
|
|
3302
3355
|
}
|
|
3303
3356
|
case `${l.prefix}if`:
|
|
3304
|
-
s.push(
|
|
3357
|
+
s.push(g.evaluateIf(i));
|
|
3305
3358
|
break;
|
|
3306
3359
|
case `${l.prefix}each`:
|
|
3307
|
-
s.push(
|
|
3360
|
+
s.push(g.evaluateEach(i));
|
|
3308
3361
|
break;
|
|
3309
3362
|
case `${l.prefix}fetch`:
|
|
3310
3363
|
s.push(
|
|
@@ -3315,16 +3368,16 @@ const m = class m {
|
|
|
3315
3368
|
case `${l.prefix}import`: {
|
|
3316
3369
|
if (typeof r == "string") {
|
|
3317
3370
|
const n = i.getTarget(), a = performance.now();
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
const
|
|
3371
|
+
w.importStart(n, r), s.push(
|
|
3372
|
+
ut.load(r).then((o) => {
|
|
3373
|
+
const d = new TextEncoder().encode(o).length;
|
|
3321
3374
|
return F.enqueue(() => {
|
|
3322
3375
|
n.innerHTML = o;
|
|
3323
3376
|
}).then(() => {
|
|
3324
|
-
|
|
3377
|
+
w.importEnd(n, r, d, a);
|
|
3325
3378
|
});
|
|
3326
3379
|
}).catch((o) => {
|
|
3327
|
-
|
|
3380
|
+
w.importError(n, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
3328
3381
|
})
|
|
3329
3382
|
);
|
|
3330
3383
|
}
|
|
@@ -3333,10 +3386,10 @@ const m = class m {
|
|
|
3333
3386
|
case `${l.prefix}url-param`: {
|
|
3334
3387
|
const n = i.getAttribute(`${l.prefix}url-arg`), a = lt.readParams();
|
|
3335
3388
|
if (n === null)
|
|
3336
|
-
|
|
3389
|
+
g.setBindingData(t, a);
|
|
3337
3390
|
else {
|
|
3338
3391
|
const o = i.getRawBindingData() || {};
|
|
3339
|
-
o[String(n)] = a,
|
|
3392
|
+
o[String(n)] = a, g.setBindingData(t, o);
|
|
3340
3393
|
}
|
|
3341
3394
|
break;
|
|
3342
3395
|
}
|
|
@@ -3356,9 +3409,13 @@ const m = class m {
|
|
|
3356
3409
|
const r = N.get(t), i = r.getRawBindingData();
|
|
3357
3410
|
r.setBindingData(e);
|
|
3358
3411
|
const s = [];
|
|
3359
|
-
|
|
3412
|
+
if (s.push(
|
|
3360
3413
|
r.setAttribute(`${l.prefix}bind`, JSON.stringify(e))
|
|
3361
|
-
),
|
|
3414
|
+
), t.tagName === "FORM") {
|
|
3415
|
+
const n = r.getAttribute(`${l.prefix}form-arg`), a = n && e[String(n)] && typeof e[String(n)] == "object" && !Array.isArray(e[String(n)]) ? e[String(n)] : n ? {} : e;
|
|
3416
|
+
s.push(m.syncValues(r, a));
|
|
3417
|
+
}
|
|
3418
|
+
return s.push(g.evaluateAll(r)), w.bindChange(t, i, e, "manual"), Promise.all(s).then(() => {
|
|
3362
3419
|
});
|
|
3363
3420
|
}
|
|
3364
3421
|
/**
|
|
@@ -3392,7 +3449,7 @@ const m = class m {
|
|
|
3392
3449
|
if (r.isSkipMutationNodes())
|
|
3393
3450
|
return;
|
|
3394
3451
|
const i = N.get(e.nextSibling), s = N.get(e);
|
|
3395
|
-
s && (r.insertBefore(s, i), s instanceof D ?
|
|
3452
|
+
s && (r.insertBefore(s, i), s instanceof D ? g.scan(s.getTarget()) : s instanceof L && g.evaluateText(s));
|
|
3396
3453
|
}
|
|
3397
3454
|
/**
|
|
3398
3455
|
* ノードを親要素から削除します。
|
|
@@ -3432,11 +3489,11 @@ const m = class m {
|
|
|
3432
3489
|
return Promise.resolve();
|
|
3433
3490
|
const i = [];
|
|
3434
3491
|
i.push(r.setValue(e));
|
|
3435
|
-
const s =
|
|
3492
|
+
const s = g.getFormFragment(r);
|
|
3436
3493
|
if (s) {
|
|
3437
|
-
const n =
|
|
3494
|
+
const n = m.getValues(s), a = s.getAttribute(`${l.prefix}form-arg`);
|
|
3438
3495
|
let o;
|
|
3439
|
-
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(
|
|
3496
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(g.setBindingData(s.getTarget(), o));
|
|
3440
3497
|
}
|
|
3441
3498
|
return Promise.all(i).then(() => {
|
|
3442
3499
|
});
|
|
@@ -3451,7 +3508,7 @@ const m = class m {
|
|
|
3451
3508
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
3452
3509
|
return t;
|
|
3453
3510
|
const e = t.getParent();
|
|
3454
|
-
return e ?
|
|
3511
|
+
return e ? g.getFormFragment(e) : null;
|
|
3455
3512
|
}
|
|
3456
3513
|
/**
|
|
3457
3514
|
* フラグメントとその子要素を評価します。
|
|
@@ -3461,8 +3518,8 @@ const m = class m {
|
|
|
3461
3518
|
*/
|
|
3462
3519
|
static evaluateAll(t) {
|
|
3463
3520
|
const e = [];
|
|
3464
|
-
return e.push(
|
|
3465
|
-
r instanceof D ? e.push(
|
|
3521
|
+
return e.push(g.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${l.prefix}if`) && e.push(g.evaluateIf(t)), t.hasAttribute(`${l.prefix}each`) && e.push(g.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3522
|
+
r instanceof D ? e.push(g.evaluateAll(r)) : r instanceof L && e.push(g.evaluateText(r));
|
|
3466
3523
|
}), Promise.all(e).then(() => {
|
|
3467
3524
|
});
|
|
3468
3525
|
}
|
|
@@ -3486,13 +3543,13 @@ const m = class m {
|
|
|
3486
3543
|
const e = [], r = t.getAttribute(`${l.prefix}if`);
|
|
3487
3544
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3488
3545
|
t.hide().then(() => {
|
|
3489
|
-
|
|
3546
|
+
w.hide(t.getTarget());
|
|
3490
3547
|
})
|
|
3491
3548
|
) : t.isVisible() || (e.push(
|
|
3492
3549
|
t.show().then(() => {
|
|
3493
|
-
|
|
3550
|
+
w.show(t.getTarget());
|
|
3494
3551
|
})
|
|
3495
|
-
), e.push(
|
|
3552
|
+
), e.push(g.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3496
3553
|
});
|
|
3497
3554
|
}
|
|
3498
3555
|
/**
|
|
@@ -3535,68 +3592,68 @@ const m = class m {
|
|
|
3535
3592
|
let i = t.getAttribute(`${l.prefix}each-index`);
|
|
3536
3593
|
i && (i = String(i));
|
|
3537
3594
|
const s = t.getAttribute(`${l.prefix}each-key`), n = t.getAttribute(`${l.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3538
|
-
e.forEach((u,
|
|
3539
|
-
const
|
|
3595
|
+
e.forEach((u, p) => {
|
|
3596
|
+
const E = g.createListKey(
|
|
3540
3597
|
u,
|
|
3541
3598
|
s ? String(s) : null,
|
|
3542
|
-
|
|
3599
|
+
p
|
|
3543
3600
|
);
|
|
3544
|
-
o.push(
|
|
3601
|
+
o.push(E), a.set(E, { item: u, itemIndex: p });
|
|
3545
3602
|
});
|
|
3546
|
-
const
|
|
3547
|
-
let
|
|
3603
|
+
const d = [];
|
|
3604
|
+
let y = t.getChildren().filter((u) => u instanceof D).filter(
|
|
3548
3605
|
(u) => !u.hasAttribute(`${l.prefix}each-before`) && !u.hasAttribute(`${l.prefix}each-after`)
|
|
3549
3606
|
);
|
|
3550
|
-
|
|
3551
|
-
const
|
|
3552
|
-
let
|
|
3553
|
-
return o.forEach((u,
|
|
3554
|
-
const
|
|
3607
|
+
y = y.filter((u) => o.indexOf(String(u.getListKey())) === -1 ? (d.push(u.remove()), !1) : !0);
|
|
3608
|
+
const b = y.map((u) => u.getListKey()), v = t.getChildren().filter((u) => u instanceof D).filter((u) => u.hasAttribute(`${l.prefix}each-before`)).length;
|
|
3609
|
+
let f = Promise.resolve();
|
|
3610
|
+
return o.forEach((u, p) => {
|
|
3611
|
+
const E = b.indexOf(u), { item: A, itemIndex: R } = a.get(u);
|
|
3555
3612
|
let k;
|
|
3556
|
-
if (
|
|
3557
|
-
k =
|
|
3558
|
-
() =>
|
|
3613
|
+
if (E !== -1)
|
|
3614
|
+
k = y[E], f = f.then(
|
|
3615
|
+
() => g.updateRowFragment(
|
|
3559
3616
|
k,
|
|
3560
|
-
|
|
3617
|
+
A,
|
|
3561
3618
|
i,
|
|
3562
|
-
|
|
3619
|
+
R,
|
|
3563
3620
|
n ? String(n) : null,
|
|
3564
3621
|
u
|
|
3565
|
-
).then(() =>
|
|
3622
|
+
).then(() => g.evaluateAll(k))
|
|
3566
3623
|
);
|
|
3567
3624
|
else {
|
|
3568
3625
|
k = r.clone();
|
|
3569
|
-
const U =
|
|
3570
|
-
|
|
3571
|
-
() =>
|
|
3626
|
+
const U = v + p;
|
|
3627
|
+
f = f.then(
|
|
3628
|
+
() => g.updateRowFragment(
|
|
3572
3629
|
k,
|
|
3573
|
-
|
|
3630
|
+
A,
|
|
3574
3631
|
i,
|
|
3575
|
-
|
|
3632
|
+
R,
|
|
3576
3633
|
n ? String(n) : null,
|
|
3577
3634
|
u
|
|
3578
3635
|
).then(
|
|
3579
3636
|
() => t.insertBefore(
|
|
3580
3637
|
k,
|
|
3581
3638
|
t.getChildren()[U] || null
|
|
3582
|
-
).then(() =>
|
|
3639
|
+
).then(() => g.evaluateAll(k))
|
|
3583
3640
|
)
|
|
3584
3641
|
);
|
|
3585
3642
|
}
|
|
3586
|
-
}), Promise.all(
|
|
3643
|
+
}), Promise.all(d).then(() => f).then(() => {
|
|
3587
3644
|
const u = o.filter(
|
|
3588
|
-
(
|
|
3589
|
-
),
|
|
3590
|
-
(
|
|
3591
|
-
),
|
|
3592
|
-
(
|
|
3593
|
-
),
|
|
3594
|
-
(
|
|
3645
|
+
(R) => R !== null
|
|
3646
|
+
), p = b.filter(
|
|
3647
|
+
(R) => R !== null
|
|
3648
|
+
), E = u.filter(
|
|
3649
|
+
(R) => !p.includes(R)
|
|
3650
|
+
), A = p.filter(
|
|
3651
|
+
(R) => !u.includes(R)
|
|
3595
3652
|
);
|
|
3596
|
-
|
|
3653
|
+
w.eachUpdate(
|
|
3597
3654
|
t.getTarget(),
|
|
3598
|
-
|
|
3599
|
-
|
|
3655
|
+
E,
|
|
3656
|
+
A,
|
|
3600
3657
|
u
|
|
3601
3658
|
);
|
|
3602
3659
|
});
|
|
@@ -3650,16 +3707,16 @@ const m = class m {
|
|
|
3650
3707
|
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${l.prefix}row`, n);
|
|
3651
3708
|
}
|
|
3652
3709
|
};
|
|
3653
|
-
|
|
3710
|
+
g.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], g.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], g.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
3654
3711
|
"bind",
|
|
3655
3712
|
"if",
|
|
3656
3713
|
"each",
|
|
3657
3714
|
"fetch",
|
|
3658
3715
|
"import",
|
|
3659
3716
|
"url-param"
|
|
3660
|
-
],
|
|
3661
|
-
let
|
|
3662
|
-
class
|
|
3717
|
+
], g.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3718
|
+
let x = g;
|
|
3719
|
+
class ct {
|
|
3663
3720
|
/**
|
|
3664
3721
|
* コンストラクタ。
|
|
3665
3722
|
*
|
|
@@ -3709,44 +3766,44 @@ class ut {
|
|
|
3709
3766
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3710
3767
|
}
|
|
3711
3768
|
}
|
|
3712
|
-
const
|
|
3769
|
+
const T = class T {
|
|
3713
3770
|
static syncTree(t) {
|
|
3714
|
-
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement &&
|
|
3715
|
-
|
|
3771
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && T.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
3772
|
+
T.syncElement(e);
|
|
3716
3773
|
}));
|
|
3717
3774
|
}
|
|
3718
3775
|
static syncElement(t) {
|
|
3719
|
-
const e =
|
|
3720
|
-
if (!r || !
|
|
3721
|
-
e && (e.observer.disconnect(),
|
|
3776
|
+
const e = T.registrations.get(t), r = N.get(t);
|
|
3777
|
+
if (!r || !T.shouldObserve(r)) {
|
|
3778
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3722
3779
|
return;
|
|
3723
3780
|
}
|
|
3724
3781
|
if (typeof IntersectionObserver > "u")
|
|
3725
3782
|
return;
|
|
3726
|
-
const i =
|
|
3727
|
-
if (e && e.observer.root === i && e.observer.rootMargin === s &&
|
|
3783
|
+
const i = T.resolveRoot(r), s = T.resolveRootMargin(r), n = T.resolveThreshold(r), a = r.hasAttribute(`${l.prefix}intersect-once`);
|
|
3784
|
+
if (e && e.observer.root === i && e.observer.rootMargin === s && T.sameThreshold(
|
|
3728
3785
|
e.observer.thresholds,
|
|
3729
3786
|
n
|
|
3730
3787
|
) && e.once === a) {
|
|
3731
3788
|
e.fragment = r;
|
|
3732
3789
|
return;
|
|
3733
3790
|
}
|
|
3734
|
-
e && (e.observer.disconnect(),
|
|
3791
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3735
3792
|
const o = new IntersectionObserver(
|
|
3736
|
-
(
|
|
3737
|
-
const
|
|
3738
|
-
|
|
3739
|
-
!
|
|
3740
|
-
|
|
3741
|
-
}).catch((
|
|
3793
|
+
(d) => {
|
|
3794
|
+
const y = T.registrations.get(t);
|
|
3795
|
+
y && d.forEach((b) => {
|
|
3796
|
+
!b.isIntersecting || y.running || T.isDisabled(y.fragment) || (y.running = !0, new V(y.fragment, "intersect").runWithResult().then((v) => {
|
|
3797
|
+
v && y.once && (y.observer.disconnect(), T.registrations.delete(t));
|
|
3798
|
+
}).catch((v) => {
|
|
3742
3799
|
h.error(
|
|
3743
3800
|
"[Haori]",
|
|
3744
3801
|
"Intersect procedure execution error:",
|
|
3745
|
-
|
|
3802
|
+
v
|
|
3746
3803
|
);
|
|
3747
3804
|
}).finally(() => {
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3805
|
+
const v = T.registrations.get(t);
|
|
3806
|
+
v && (v.running = !1);
|
|
3750
3807
|
}));
|
|
3751
3808
|
});
|
|
3752
3809
|
},
|
|
@@ -3756,7 +3813,7 @@ const w = class w {
|
|
|
3756
3813
|
threshold: n
|
|
3757
3814
|
}
|
|
3758
3815
|
);
|
|
3759
|
-
o.observe(t),
|
|
3816
|
+
o.observe(t), T.registrations.set(t, {
|
|
3760
3817
|
fragment: r,
|
|
3761
3818
|
observer: o,
|
|
3762
3819
|
once: a,
|
|
@@ -3765,25 +3822,25 @@ const w = class w {
|
|
|
3765
3822
|
}
|
|
3766
3823
|
static cleanupTree(t) {
|
|
3767
3824
|
if (t instanceof HTMLElement) {
|
|
3768
|
-
const e =
|
|
3769
|
-
e && (e.observer.disconnect(),
|
|
3825
|
+
const e = T.registrations.get(t);
|
|
3826
|
+
e && (e.observer.disconnect(), T.registrations.delete(t));
|
|
3770
3827
|
}
|
|
3771
3828
|
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
3772
|
-
const r =
|
|
3773
|
-
r && (r.observer.disconnect(),
|
|
3829
|
+
const r = T.registrations.get(e);
|
|
3830
|
+
r && (r.observer.disconnect(), T.registrations.delete(e));
|
|
3774
3831
|
});
|
|
3775
3832
|
}
|
|
3776
3833
|
static disconnectAll() {
|
|
3777
|
-
|
|
3834
|
+
T.registrations.forEach((t) => {
|
|
3778
3835
|
t.observer.disconnect();
|
|
3779
|
-
}),
|
|
3836
|
+
}), T.registrations.clear();
|
|
3780
3837
|
}
|
|
3781
3838
|
static shouldObserve(t) {
|
|
3782
3839
|
return t.getAttributeNames().some((e) => {
|
|
3783
3840
|
if (!e.startsWith(`${l.prefix}intersect-`))
|
|
3784
3841
|
return !1;
|
|
3785
3842
|
const r = e.slice(`${l.prefix}intersect-`.length);
|
|
3786
|
-
return !
|
|
3843
|
+
return !T.CONFIG_KEYS.has(r);
|
|
3787
3844
|
});
|
|
3788
3845
|
}
|
|
3789
3846
|
static resolveRoot(t) {
|
|
@@ -3817,14 +3874,14 @@ const w = class w {
|
|
|
3817
3874
|
return t.length === 1 && t[0] === e;
|
|
3818
3875
|
}
|
|
3819
3876
|
};
|
|
3820
|
-
|
|
3877
|
+
T.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
3821
3878
|
"root",
|
|
3822
3879
|
"root-margin",
|
|
3823
3880
|
"threshold",
|
|
3824
3881
|
"disabled",
|
|
3825
3882
|
"once"
|
|
3826
|
-
]),
|
|
3827
|
-
let B =
|
|
3883
|
+
]), T.registrations = /* @__PURE__ */ new Map();
|
|
3884
|
+
let B = T;
|
|
3828
3885
|
const H = class H {
|
|
3829
3886
|
/**
|
|
3830
3887
|
* 初期化メソッド。
|
|
@@ -3835,10 +3892,10 @@ const H = class H {
|
|
|
3835
3892
|
return;
|
|
3836
3893
|
H._initialized = !0;
|
|
3837
3894
|
const t = await Promise.allSettled([
|
|
3838
|
-
|
|
3839
|
-
|
|
3895
|
+
x.scan(document.head),
|
|
3896
|
+
x.scan(document.body)
|
|
3840
3897
|
]), [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
|
|
3898
|
+
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), H.observe(document.head), H.observe(document.body), new ct().start(), B.syncTree(document.body);
|
|
3842
3899
|
}
|
|
3843
3900
|
/**
|
|
3844
3901
|
* 指定された要素を監視します。
|
|
@@ -3858,7 +3915,7 @@ const H = class H {
|
|
|
3858
3915
|
i.attributeName
|
|
3859
3916
|
);
|
|
3860
3917
|
const s = i.target;
|
|
3861
|
-
|
|
3918
|
+
x.setAttribute(
|
|
3862
3919
|
s,
|
|
3863
3920
|
i.attributeName,
|
|
3864
3921
|
s.getAttribute(i.attributeName)
|
|
@@ -3872,9 +3929,9 @@ const H = class H {
|
|
|
3872
3929
|
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3873
3930
|
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3874
3931
|
), Array.from(i.removedNodes).forEach((s) => {
|
|
3875
|
-
B.cleanupTree(s),
|
|
3932
|
+
B.cleanupTree(s), x.removeNode(s);
|
|
3876
3933
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3877
|
-
s.parentElement instanceof HTMLElement && (
|
|
3934
|
+
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s), B.syncTree(s));
|
|
3878
3935
|
});
|
|
3879
3936
|
break;
|
|
3880
3937
|
}
|
|
@@ -3884,7 +3941,7 @@ const H = class H {
|
|
|
3884
3941
|
"Character data changed:",
|
|
3885
3942
|
i.target,
|
|
3886
3943
|
i.target.textContent
|
|
3887
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
3944
|
+
), i.target instanceof Text || i.target instanceof Comment ? x.changeText(i.target, i.target.textContent) : h.warn(
|
|
3888
3945
|
"[Haori]",
|
|
3889
3946
|
"Unsupported character data type:",
|
|
3890
3947
|
i.target
|
|
@@ -3909,11 +3966,11 @@ const H = class H {
|
|
|
3909
3966
|
H._initialized = !1;
|
|
3910
3967
|
let G = H;
|
|
3911
3968
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", G.init) : G.init();
|
|
3912
|
-
const ht = "0.4.
|
|
3969
|
+
const ht = "0.4.2";
|
|
3913
3970
|
export {
|
|
3914
|
-
|
|
3971
|
+
x as Core,
|
|
3915
3972
|
l as Env,
|
|
3916
|
-
|
|
3973
|
+
m as Form,
|
|
3917
3974
|
N as Fragment,
|
|
3918
3975
|
_ as Haori,
|
|
3919
3976
|
h as Log,
|