@microsoft/fast-element 2.0.0 → 2.1.0
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/ARCHITECTURE_FASTELEMENT.md +63 -0
- package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +34 -0
- package/ARCHITECTURE_INTRO.md +10 -0
- package/ARCHITECTURE_OVERVIEW.md +52 -0
- package/ARCHITECTURE_UPDATES.md +11 -0
- package/CHANGELOG.json +44 -0
- package/CHANGELOG.md +18 -1
- package/dist/dts/components/attributes.d.ts +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/observation/arrays.d.ts +40 -0
- package/dist/dts/templating/repeat.d.ts +4 -3
- package/dist/esm/components/attributes.js +3 -5
- package/dist/esm/debug.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/observation/arrays.js +91 -8
- package/dist/esm/templating/repeat.js +25 -2
- package/dist/fast-element.api.json +286 -5
- package/dist/fast-element.debug.js +121 -17
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +120 -16
- package/dist/fast-element.min.js +2 -2
- package/dist/fast-element.untrimmed.d.ts +47 -3
- package/docs/api-report.api.md +19 -1
- package/package.json +1 -1
|
@@ -426,6 +426,52 @@
|
|
|
426
426
|
"name": "ArrayObserver",
|
|
427
427
|
"preserveMemberOrder": false,
|
|
428
428
|
"members": [
|
|
429
|
+
{
|
|
430
|
+
"kind": "MethodSignature",
|
|
431
|
+
"canonicalReference": "@microsoft/fast-element!ArrayObserver#addSort:member(1)",
|
|
432
|
+
"docComment": "/**\n * Adds a sort to the list of changes.\n *\n * @param sort - The sort to add.\n */\n",
|
|
433
|
+
"excerptTokens": [
|
|
434
|
+
{
|
|
435
|
+
"kind": "Content",
|
|
436
|
+
"text": "addSort(sort: "
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"kind": "Reference",
|
|
440
|
+
"text": "Sort",
|
|
441
|
+
"canonicalReference": "@microsoft/fast-element!Sort:class"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"kind": "Content",
|
|
445
|
+
"text": "): "
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"kind": "Content",
|
|
449
|
+
"text": "void"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"kind": "Content",
|
|
453
|
+
"text": ";"
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
"isOptional": false,
|
|
457
|
+
"returnTypeTokenRange": {
|
|
458
|
+
"startIndex": 3,
|
|
459
|
+
"endIndex": 4
|
|
460
|
+
},
|
|
461
|
+
"releaseTag": "Public",
|
|
462
|
+
"overloadIndex": 1,
|
|
463
|
+
"parameters": [
|
|
464
|
+
{
|
|
465
|
+
"parameterName": "sort",
|
|
466
|
+
"parameterTypeTokenRange": {
|
|
467
|
+
"startIndex": 1,
|
|
468
|
+
"endIndex": 2
|
|
469
|
+
},
|
|
470
|
+
"isOptional": false
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
"name": "addSort"
|
|
474
|
+
},
|
|
429
475
|
{
|
|
430
476
|
"kind": "MethodSignature",
|
|
431
477
|
"canonicalReference": "@microsoft/fast-element!ArrayObserver#addSplice:member(1)",
|
|
@@ -573,6 +619,34 @@
|
|
|
573
619
|
],
|
|
574
620
|
"name": "reset"
|
|
575
621
|
},
|
|
622
|
+
{
|
|
623
|
+
"kind": "PropertySignature",
|
|
624
|
+
"canonicalReference": "@microsoft/fast-element!ArrayObserver#sortObserver:member",
|
|
625
|
+
"docComment": "/**\n * The sort observer for the array.\n */\n",
|
|
626
|
+
"excerptTokens": [
|
|
627
|
+
{
|
|
628
|
+
"kind": "Content",
|
|
629
|
+
"text": "readonly sortObserver: "
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"kind": "Reference",
|
|
633
|
+
"text": "SortObserver",
|
|
634
|
+
"canonicalReference": "@microsoft/fast-element!SortObserver:interface"
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"kind": "Content",
|
|
638
|
+
"text": ";"
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
"isReadonly": true,
|
|
642
|
+
"isOptional": false,
|
|
643
|
+
"releaseTag": "Public",
|
|
644
|
+
"name": "sortObserver",
|
|
645
|
+
"propertyTypeTokenRange": {
|
|
646
|
+
"startIndex": 1,
|
|
647
|
+
"endIndex": 2
|
|
648
|
+
}
|
|
649
|
+
},
|
|
576
650
|
{
|
|
577
651
|
"kind": "PropertySignature",
|
|
578
652
|
"canonicalReference": "@microsoft/fast-element!ArrayObserver#strategy:member",
|
|
@@ -629,7 +703,7 @@
|
|
|
629
703
|
},
|
|
630
704
|
{
|
|
631
705
|
"kind": "Content",
|
|
632
|
-
"text": "<{\n readonly enable: () => void;\n}>"
|
|
706
|
+
"text": "<{\n readonly sorted: 0;\n readonly enable: () => void;\n}>"
|
|
633
707
|
}
|
|
634
708
|
],
|
|
635
709
|
"fileUrlPath": "dist/dts/observation/arrays.d.ts",
|
|
@@ -1286,7 +1360,7 @@
|
|
|
1286
1360
|
{
|
|
1287
1361
|
"kind": "Method",
|
|
1288
1362
|
"canonicalReference": "@microsoft/fast-element!AttributeDefinition#setValue:member(1)",
|
|
1289
|
-
"docComment": "/**\n * Sets the value of the attribute/property on the source element.\n *\n * @param source - The source element to access.\n *\n * @param
|
|
1363
|
+
"docComment": "/**\n * Sets the value of the attribute/property on the source element.\n *\n * @param source - The source element to access.\n *\n * @param newValue - The value to set the attribute/property to.\n */\n",
|
|
1290
1364
|
"excerptTokens": [
|
|
1291
1365
|
{
|
|
1292
1366
|
"kind": "Content",
|
|
@@ -16485,6 +16559,15 @@
|
|
|
16485
16559
|
"kind": "Content",
|
|
16486
16560
|
"text": "[] | "
|
|
16487
16561
|
},
|
|
16562
|
+
{
|
|
16563
|
+
"kind": "Reference",
|
|
16564
|
+
"text": "Sort",
|
|
16565
|
+
"canonicalReference": "@microsoft/fast-element!Sort:class"
|
|
16566
|
+
},
|
|
16567
|
+
{
|
|
16568
|
+
"kind": "Content",
|
|
16569
|
+
"text": "[] | "
|
|
16570
|
+
},
|
|
16488
16571
|
{
|
|
16489
16572
|
"kind": "Reference",
|
|
16490
16573
|
"text": "ExpressionObserver",
|
|
@@ -16505,8 +16588,8 @@
|
|
|
16505
16588
|
],
|
|
16506
16589
|
"isStatic": false,
|
|
16507
16590
|
"returnTypeTokenRange": {
|
|
16508
|
-
"startIndex":
|
|
16509
|
-
"endIndex":
|
|
16591
|
+
"startIndex": 9,
|
|
16592
|
+
"endIndex": 10
|
|
16510
16593
|
},
|
|
16511
16594
|
"releaseTag": "Public",
|
|
16512
16595
|
"isProtected": false,
|
|
@@ -16524,7 +16607,7 @@
|
|
|
16524
16607
|
"parameterName": "args",
|
|
16525
16608
|
"parameterTypeTokenRange": {
|
|
16526
16609
|
"startIndex": 3,
|
|
16527
|
-
"endIndex":
|
|
16610
|
+
"endIndex": 8
|
|
16528
16611
|
},
|
|
16529
16612
|
"isOptional": false
|
|
16530
16613
|
}
|
|
@@ -17462,6 +17545,204 @@
|
|
|
17462
17545
|
}
|
|
17463
17546
|
]
|
|
17464
17547
|
},
|
|
17548
|
+
{
|
|
17549
|
+
"kind": "Class",
|
|
17550
|
+
"canonicalReference": "@microsoft/fast-element!Sort:class",
|
|
17551
|
+
"docComment": "/**\n * A sort array indicates new index positions of array items.\n *\n * @public\n */\n",
|
|
17552
|
+
"excerptTokens": [
|
|
17553
|
+
{
|
|
17554
|
+
"kind": "Content",
|
|
17555
|
+
"text": "export declare class Sort "
|
|
17556
|
+
}
|
|
17557
|
+
],
|
|
17558
|
+
"fileUrlPath": "dist/dts/observation/arrays.d.ts",
|
|
17559
|
+
"releaseTag": "Public",
|
|
17560
|
+
"isAbstract": false,
|
|
17561
|
+
"name": "Sort",
|
|
17562
|
+
"preserveMemberOrder": false,
|
|
17563
|
+
"members": [
|
|
17564
|
+
{
|
|
17565
|
+
"kind": "Constructor",
|
|
17566
|
+
"canonicalReference": "@microsoft/fast-element!Sort:constructor(1)",
|
|
17567
|
+
"docComment": "/**\n * Creates a sort update.\n *\n * @param sorted - The updated index of sorted items.\n */\n",
|
|
17568
|
+
"excerptTokens": [
|
|
17569
|
+
{
|
|
17570
|
+
"kind": "Content",
|
|
17571
|
+
"text": "constructor(sorted?: "
|
|
17572
|
+
},
|
|
17573
|
+
{
|
|
17574
|
+
"kind": "Content",
|
|
17575
|
+
"text": "number[] | undefined"
|
|
17576
|
+
},
|
|
17577
|
+
{
|
|
17578
|
+
"kind": "Content",
|
|
17579
|
+
"text": ");"
|
|
17580
|
+
}
|
|
17581
|
+
],
|
|
17582
|
+
"releaseTag": "Public",
|
|
17583
|
+
"isProtected": false,
|
|
17584
|
+
"overloadIndex": 1,
|
|
17585
|
+
"parameters": [
|
|
17586
|
+
{
|
|
17587
|
+
"parameterName": "sorted",
|
|
17588
|
+
"parameterTypeTokenRange": {
|
|
17589
|
+
"startIndex": 1,
|
|
17590
|
+
"endIndex": 2
|
|
17591
|
+
},
|
|
17592
|
+
"isOptional": true
|
|
17593
|
+
}
|
|
17594
|
+
]
|
|
17595
|
+
},
|
|
17596
|
+
{
|
|
17597
|
+
"kind": "Property",
|
|
17598
|
+
"canonicalReference": "@microsoft/fast-element!Sort#sorted:member",
|
|
17599
|
+
"docComment": "",
|
|
17600
|
+
"excerptTokens": [
|
|
17601
|
+
{
|
|
17602
|
+
"kind": "Content",
|
|
17603
|
+
"text": "sorted?: "
|
|
17604
|
+
},
|
|
17605
|
+
{
|
|
17606
|
+
"kind": "Content",
|
|
17607
|
+
"text": "number[] | undefined"
|
|
17608
|
+
},
|
|
17609
|
+
{
|
|
17610
|
+
"kind": "Content",
|
|
17611
|
+
"text": ";"
|
|
17612
|
+
}
|
|
17613
|
+
],
|
|
17614
|
+
"isReadonly": false,
|
|
17615
|
+
"isOptional": true,
|
|
17616
|
+
"releaseTag": "Public",
|
|
17617
|
+
"name": "sorted",
|
|
17618
|
+
"propertyTypeTokenRange": {
|
|
17619
|
+
"startIndex": 1,
|
|
17620
|
+
"endIndex": 2
|
|
17621
|
+
},
|
|
17622
|
+
"isStatic": false,
|
|
17623
|
+
"isProtected": false,
|
|
17624
|
+
"isAbstract": false
|
|
17625
|
+
}
|
|
17626
|
+
],
|
|
17627
|
+
"implementsTokenRanges": []
|
|
17628
|
+
},
|
|
17629
|
+
{
|
|
17630
|
+
"kind": "Function",
|
|
17631
|
+
"canonicalReference": "@microsoft/fast-element!sortedCount:function(1)",
|
|
17632
|
+
"docComment": "/**\n * Enables observing the sorted property of an array.\n *\n * @param array - The array to observe the sorted property of.\n *\n * @returns The sorted property.\n *\n * @public\n */\n",
|
|
17633
|
+
"excerptTokens": [
|
|
17634
|
+
{
|
|
17635
|
+
"kind": "Content",
|
|
17636
|
+
"text": "export declare function sortedCount<T>(array: "
|
|
17637
|
+
},
|
|
17638
|
+
{
|
|
17639
|
+
"kind": "Content",
|
|
17640
|
+
"text": "readonly T[]"
|
|
17641
|
+
},
|
|
17642
|
+
{
|
|
17643
|
+
"kind": "Content",
|
|
17644
|
+
"text": "): "
|
|
17645
|
+
},
|
|
17646
|
+
{
|
|
17647
|
+
"kind": "Content",
|
|
17648
|
+
"text": "number"
|
|
17649
|
+
},
|
|
17650
|
+
{
|
|
17651
|
+
"kind": "Content",
|
|
17652
|
+
"text": ";"
|
|
17653
|
+
}
|
|
17654
|
+
],
|
|
17655
|
+
"fileUrlPath": "dist/dts/observation/arrays.d.ts",
|
|
17656
|
+
"returnTypeTokenRange": {
|
|
17657
|
+
"startIndex": 3,
|
|
17658
|
+
"endIndex": 4
|
|
17659
|
+
},
|
|
17660
|
+
"releaseTag": "Public",
|
|
17661
|
+
"overloadIndex": 1,
|
|
17662
|
+
"parameters": [
|
|
17663
|
+
{
|
|
17664
|
+
"parameterName": "array",
|
|
17665
|
+
"parameterTypeTokenRange": {
|
|
17666
|
+
"startIndex": 1,
|
|
17667
|
+
"endIndex": 2
|
|
17668
|
+
},
|
|
17669
|
+
"isOptional": false
|
|
17670
|
+
}
|
|
17671
|
+
],
|
|
17672
|
+
"typeParameters": [
|
|
17673
|
+
{
|
|
17674
|
+
"typeParameterName": "T",
|
|
17675
|
+
"constraintTokenRange": {
|
|
17676
|
+
"startIndex": 0,
|
|
17677
|
+
"endIndex": 0
|
|
17678
|
+
},
|
|
17679
|
+
"defaultTypeTokenRange": {
|
|
17680
|
+
"startIndex": 0,
|
|
17681
|
+
"endIndex": 0
|
|
17682
|
+
}
|
|
17683
|
+
}
|
|
17684
|
+
],
|
|
17685
|
+
"name": "sortedCount"
|
|
17686
|
+
},
|
|
17687
|
+
{
|
|
17688
|
+
"kind": "Interface",
|
|
17689
|
+
"canonicalReference": "@microsoft/fast-element!SortObserver:interface",
|
|
17690
|
+
"docComment": "/**\n * Observes array sort.\n *\n * @public\n */\n",
|
|
17691
|
+
"excerptTokens": [
|
|
17692
|
+
{
|
|
17693
|
+
"kind": "Content",
|
|
17694
|
+
"text": "export interface SortObserver extends "
|
|
17695
|
+
},
|
|
17696
|
+
{
|
|
17697
|
+
"kind": "Reference",
|
|
17698
|
+
"text": "Subscriber",
|
|
17699
|
+
"canonicalReference": "@microsoft/fast-element!Subscriber:interface"
|
|
17700
|
+
},
|
|
17701
|
+
{
|
|
17702
|
+
"kind": "Content",
|
|
17703
|
+
"text": " "
|
|
17704
|
+
}
|
|
17705
|
+
],
|
|
17706
|
+
"fileUrlPath": "dist/dts/observation/arrays.d.ts",
|
|
17707
|
+
"releaseTag": "Public",
|
|
17708
|
+
"name": "SortObserver",
|
|
17709
|
+
"preserveMemberOrder": false,
|
|
17710
|
+
"members": [
|
|
17711
|
+
{
|
|
17712
|
+
"kind": "PropertySignature",
|
|
17713
|
+
"canonicalReference": "@microsoft/fast-element!SortObserver#sorted:member",
|
|
17714
|
+
"docComment": "/**\n * The sorted times on the observed array, this should be incremented every time an item in the array changes location.\n */\n",
|
|
17715
|
+
"excerptTokens": [
|
|
17716
|
+
{
|
|
17717
|
+
"kind": "Content",
|
|
17718
|
+
"text": "sorted: "
|
|
17719
|
+
},
|
|
17720
|
+
{
|
|
17721
|
+
"kind": "Content",
|
|
17722
|
+
"text": "number"
|
|
17723
|
+
},
|
|
17724
|
+
{
|
|
17725
|
+
"kind": "Content",
|
|
17726
|
+
"text": ";"
|
|
17727
|
+
}
|
|
17728
|
+
],
|
|
17729
|
+
"isReadonly": false,
|
|
17730
|
+
"isOptional": false,
|
|
17731
|
+
"releaseTag": "Public",
|
|
17732
|
+
"name": "sorted",
|
|
17733
|
+
"propertyTypeTokenRange": {
|
|
17734
|
+
"startIndex": 1,
|
|
17735
|
+
"endIndex": 2
|
|
17736
|
+
}
|
|
17737
|
+
}
|
|
17738
|
+
],
|
|
17739
|
+
"extendsTokenRanges": [
|
|
17740
|
+
{
|
|
17741
|
+
"startIndex": 1,
|
|
17742
|
+
"endIndex": 2
|
|
17743
|
+
}
|
|
17744
|
+
]
|
|
17745
|
+
},
|
|
17465
17746
|
{
|
|
17466
17747
|
"kind": "TypeAlias",
|
|
17467
17748
|
"canonicalReference": "@microsoft/fast-element!SourceLifetime:type",
|
|
@@ -8,7 +8,7 @@ if (globalThis.FAST === void 0) {
|
|
|
8
8
|
}
|
|
9
9
|
const FAST$1 = globalThis.FAST;
|
|
10
10
|
const debugMessages = {
|
|
11
|
-
[1101 /* needsArrayObservation */]: "Must call
|
|
11
|
+
[1101 /* needsArrayObservation */]: "Must call ArrayObserver.enable() before observing arrays.",
|
|
12
12
|
[1201 /* onlySetDOMPolicyOnce */]: "The DOM Policy can only be set once.",
|
|
13
13
|
[1202 /* bindingInnerHTMLRequiresTrustedTypes */]: "To bind innerHTML, you must use a TrustedTypesPolicy.",
|
|
14
14
|
[1203 /* twoWayBindingRequiresObservables */]: "View=>Model update skipped. To use twoWay binding, the target property must be observable.",
|
|
@@ -1299,6 +1299,19 @@ class Splice {
|
|
|
1299
1299
|
return this;
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
|
+
/**
|
|
1303
|
+
* A sort array indicates new index positions of array items.
|
|
1304
|
+
* @public
|
|
1305
|
+
*/
|
|
1306
|
+
class Sort {
|
|
1307
|
+
/**
|
|
1308
|
+
* Creates a sort update.
|
|
1309
|
+
* @param sorted - The updated index of sorted items.
|
|
1310
|
+
*/
|
|
1311
|
+
constructor(sorted) {
|
|
1312
|
+
this.sorted = sorted;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1302
1315
|
/**
|
|
1303
1316
|
* Indicates what level of feature support the splice
|
|
1304
1317
|
* strategy provides.
|
|
@@ -1617,7 +1630,7 @@ function project(array, changes) {
|
|
|
1617
1630
|
* splices needed to represent the change from the old array to the new array.
|
|
1618
1631
|
* @public
|
|
1619
1632
|
*/
|
|
1620
|
-
let
|
|
1633
|
+
let defaultMutationStrategy = Object.freeze({
|
|
1621
1634
|
support: SpliceStrategySupport.optimized,
|
|
1622
1635
|
normalize(previous, current, changes) {
|
|
1623
1636
|
if (previous === void 0) {
|
|
@@ -1643,7 +1656,12 @@ let defaultSpliceStrategy = Object.freeze({
|
|
|
1643
1656
|
},
|
|
1644
1657
|
reverse(array, observer, reverse, args) {
|
|
1645
1658
|
const result = reverse.apply(array, args);
|
|
1646
|
-
|
|
1659
|
+
array.sorted++;
|
|
1660
|
+
const sortedItems = [];
|
|
1661
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
1662
|
+
sortedItems.push(i);
|
|
1663
|
+
}
|
|
1664
|
+
observer.addSort(new Sort(sortedItems));
|
|
1647
1665
|
return result;
|
|
1648
1666
|
},
|
|
1649
1667
|
shift(array, observer, shift, args) {
|
|
@@ -1655,8 +1673,20 @@ let defaultSpliceStrategy = Object.freeze({
|
|
|
1655
1673
|
return result;
|
|
1656
1674
|
},
|
|
1657
1675
|
sort(array, observer, sort, args) {
|
|
1676
|
+
const map = new Map();
|
|
1677
|
+
for (let i = 0, ii = array.length; i < ii; ++i) {
|
|
1678
|
+
const mapValue = map.get(array[i]) || [];
|
|
1679
|
+
map.set(array[i], [...mapValue, i]);
|
|
1680
|
+
}
|
|
1658
1681
|
const result = sort.apply(array, args);
|
|
1659
|
-
|
|
1682
|
+
array.sorted++;
|
|
1683
|
+
const sortedItems = [];
|
|
1684
|
+
for (let i = 0, ii = array.length; i < ii; ++i) {
|
|
1685
|
+
const indexs = map.get(array[i]);
|
|
1686
|
+
sortedItems.push(indexs[0]);
|
|
1687
|
+
map.set(array[i], indexs.splice(1));
|
|
1688
|
+
}
|
|
1689
|
+
observer.addSort(new Sort(sortedItems));
|
|
1660
1690
|
return result;
|
|
1661
1691
|
},
|
|
1662
1692
|
splice(array, observer, splice, args) {
|
|
@@ -1684,13 +1714,14 @@ const SpliceStrategy = Object.freeze({
|
|
|
1684
1714
|
* @param strategy - The splice strategy to use.
|
|
1685
1715
|
*/
|
|
1686
1716
|
setDefaultStrategy(strategy) {
|
|
1687
|
-
|
|
1717
|
+
defaultMutationStrategy = strategy;
|
|
1688
1718
|
},
|
|
1689
1719
|
});
|
|
1690
|
-
function setNonEnumerable(target, property, value) {
|
|
1720
|
+
function setNonEnumerable(target, property, value, writable = true) {
|
|
1691
1721
|
Reflect.defineProperty(target, property, {
|
|
1692
1722
|
value,
|
|
1693
1723
|
enumerable: false,
|
|
1724
|
+
writable,
|
|
1694
1725
|
});
|
|
1695
1726
|
}
|
|
1696
1727
|
class DefaultArrayObserver extends SubscriberSet {
|
|
@@ -1698,9 +1729,11 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1698
1729
|
super(subject);
|
|
1699
1730
|
this.oldCollection = void 0;
|
|
1700
1731
|
this.splices = void 0;
|
|
1732
|
+
this.sorts = void 0;
|
|
1701
1733
|
this.needsQueue = true;
|
|
1702
1734
|
this._strategy = null;
|
|
1703
1735
|
this._lengthObserver = void 0;
|
|
1736
|
+
this._sortObserver = void 0;
|
|
1704
1737
|
this.call = this.flush;
|
|
1705
1738
|
setNonEnumerable(subject, "$fastController", this);
|
|
1706
1739
|
}
|
|
@@ -1727,6 +1760,23 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1727
1760
|
}
|
|
1728
1761
|
return observer;
|
|
1729
1762
|
}
|
|
1763
|
+
get sortObserver() {
|
|
1764
|
+
let observer = this._sortObserver;
|
|
1765
|
+
if (observer === void 0) {
|
|
1766
|
+
const array = this.subject;
|
|
1767
|
+
this._sortObserver = observer = {
|
|
1768
|
+
sorted: array.sorted,
|
|
1769
|
+
handleChange() {
|
|
1770
|
+
if (this.sorted !== array.sorted) {
|
|
1771
|
+
this.sorted = array.sorted;
|
|
1772
|
+
Observable.notify(observer, "sorted");
|
|
1773
|
+
}
|
|
1774
|
+
},
|
|
1775
|
+
};
|
|
1776
|
+
this.subscribe(observer);
|
|
1777
|
+
}
|
|
1778
|
+
return observer;
|
|
1779
|
+
}
|
|
1730
1780
|
subscribe(subscriber) {
|
|
1731
1781
|
this.flush();
|
|
1732
1782
|
super.subscribe(subscriber);
|
|
@@ -1740,6 +1790,15 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1740
1790
|
}
|
|
1741
1791
|
this.enqueue();
|
|
1742
1792
|
}
|
|
1793
|
+
addSort(sort) {
|
|
1794
|
+
if (this.sorts === void 0) {
|
|
1795
|
+
this.sorts = [sort];
|
|
1796
|
+
}
|
|
1797
|
+
else {
|
|
1798
|
+
this.sorts.push(sort);
|
|
1799
|
+
}
|
|
1800
|
+
this.enqueue();
|
|
1801
|
+
}
|
|
1743
1802
|
reset(oldCollection) {
|
|
1744
1803
|
this.oldCollection = oldCollection;
|
|
1745
1804
|
this.enqueue();
|
|
@@ -1747,14 +1806,18 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
1747
1806
|
flush() {
|
|
1748
1807
|
var _a;
|
|
1749
1808
|
const splices = this.splices;
|
|
1809
|
+
const sorts = this.sorts;
|
|
1750
1810
|
const oldCollection = this.oldCollection;
|
|
1751
|
-
if (splices === void 0 && oldCollection === void 0) {
|
|
1811
|
+
if (splices === void 0 && oldCollection === void 0 && sorts === void 0) {
|
|
1752
1812
|
return;
|
|
1753
1813
|
}
|
|
1754
1814
|
this.needsQueue = true;
|
|
1755
1815
|
this.splices = void 0;
|
|
1816
|
+
this.sorts = void 0;
|
|
1756
1817
|
this.oldCollection = void 0;
|
|
1757
|
-
|
|
1818
|
+
sorts !== void 0
|
|
1819
|
+
? this.notify(sorts)
|
|
1820
|
+
: this.notify(((_a = this._strategy) !== null && _a !== void 0 ? _a : defaultMutationStrategy).normalize(oldCollection, this.subject, splices));
|
|
1758
1821
|
}
|
|
1759
1822
|
enqueue() {
|
|
1760
1823
|
if (this.needsQueue) {
|
|
@@ -1769,6 +1832,7 @@ let enabled = false;
|
|
|
1769
1832
|
* @public
|
|
1770
1833
|
*/
|
|
1771
1834
|
const ArrayObserver = Object.freeze({
|
|
1835
|
+
sorted: 0,
|
|
1772
1836
|
/**
|
|
1773
1837
|
* Enables the array observation mechanism.
|
|
1774
1838
|
* @remarks
|
|
@@ -1785,6 +1849,7 @@ const ArrayObserver = Object.freeze({
|
|
|
1785
1849
|
const proto = Array.prototype;
|
|
1786
1850
|
if (!proto.$fastPatch) {
|
|
1787
1851
|
setNonEnumerable(proto, "$fastPatch", 1);
|
|
1852
|
+
setNonEnumerable(proto, "sorted", 0);
|
|
1788
1853
|
[
|
|
1789
1854
|
proto.pop,
|
|
1790
1855
|
proto.push,
|
|
@@ -1799,7 +1864,7 @@ const ArrayObserver = Object.freeze({
|
|
|
1799
1864
|
const o = this.$fastController;
|
|
1800
1865
|
return o === void 0
|
|
1801
1866
|
? method.apply(this, args)
|
|
1802
|
-
: ((_a = o.strategy) !== null && _a !== void 0 ? _a :
|
|
1867
|
+
: ((_a = o.strategy) !== null && _a !== void 0 ? _a : defaultMutationStrategy)[method.name](this, o, method, args);
|
|
1803
1868
|
};
|
|
1804
1869
|
});
|
|
1805
1870
|
}
|
|
@@ -1823,6 +1888,24 @@ function lengthOf(array) {
|
|
|
1823
1888
|
Observable.track(arrayObserver.lengthObserver, "length");
|
|
1824
1889
|
return array.length;
|
|
1825
1890
|
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Enables observing the sorted property of an array.
|
|
1893
|
+
* @param array - The array to observe the sorted property of.
|
|
1894
|
+
* @returns The sorted property.
|
|
1895
|
+
* @public
|
|
1896
|
+
*/
|
|
1897
|
+
function sortedCount(array) {
|
|
1898
|
+
if (!array) {
|
|
1899
|
+
return 0;
|
|
1900
|
+
}
|
|
1901
|
+
let arrayObserver = array.$fastController;
|
|
1902
|
+
if (arrayObserver === void 0) {
|
|
1903
|
+
ArrayObserver.enable();
|
|
1904
|
+
arrayObserver = Observable.getNotifier(array);
|
|
1905
|
+
}
|
|
1906
|
+
Observable.track(arrayObserver.sortObserver, "sorted");
|
|
1907
|
+
return array.sorted;
|
|
1908
|
+
}
|
|
1826
1909
|
|
|
1827
1910
|
/**
|
|
1828
1911
|
* Captures a binding expression along with related information and capabilities.
|
|
@@ -3927,8 +4010,11 @@ class RepeatBehavior {
|
|
|
3927
4010
|
else if (args[0].reset) {
|
|
3928
4011
|
this.refreshAllViews();
|
|
3929
4012
|
}
|
|
4013
|
+
else if (args[0].sorted) {
|
|
4014
|
+
this.updateSortedViews(args);
|
|
4015
|
+
}
|
|
3930
4016
|
else {
|
|
3931
|
-
this.
|
|
4017
|
+
this.updateSplicedViews(args);
|
|
3932
4018
|
}
|
|
3933
4019
|
}
|
|
3934
4020
|
observeItems(force = false) {
|
|
@@ -3946,7 +4032,27 @@ class RepeatBehavior {
|
|
|
3946
4032
|
newObserver.subscribe(this);
|
|
3947
4033
|
}
|
|
3948
4034
|
}
|
|
3949
|
-
|
|
4035
|
+
updateSortedViews(sorts) {
|
|
4036
|
+
const views = this.views;
|
|
4037
|
+
for (let i = 0, ii = sorts.length; i < ii; ++i) {
|
|
4038
|
+
const sortedItems = sorts[i].sorted.slice();
|
|
4039
|
+
const unsortedItems = sortedItems.slice().sort();
|
|
4040
|
+
for (let j = 0, jj = sortedItems.length; j < jj; ++j) {
|
|
4041
|
+
const sortedIndex = sortedItems.find(value => sortedItems[j] === unsortedItems[value]);
|
|
4042
|
+
if (sortedIndex !== j) {
|
|
4043
|
+
const removedItems = unsortedItems.splice(sortedIndex, 1);
|
|
4044
|
+
unsortedItems.splice(j, 0, ...removedItems);
|
|
4045
|
+
const neighbor = views[j];
|
|
4046
|
+
const location = neighbor ? neighbor.firstChild : this.location;
|
|
4047
|
+
views[sortedIndex].remove();
|
|
4048
|
+
views[sortedIndex].insertBefore(location);
|
|
4049
|
+
const removedViews = views.splice(sortedIndex, 1);
|
|
4050
|
+
views.splice(j, 0, ...removedViews);
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
updateSplicedViews(splices) {
|
|
3950
4056
|
const views = this.views;
|
|
3951
4057
|
const bindView = this.bindView;
|
|
3952
4058
|
const items = this.items;
|
|
@@ -4403,13 +4509,11 @@ const booleanConverter = {
|
|
|
4403
4509
|
return value ? "true" : "false";
|
|
4404
4510
|
},
|
|
4405
4511
|
fromView(value) {
|
|
4406
|
-
return value === null ||
|
|
4512
|
+
return !(value === null ||
|
|
4407
4513
|
value === void 0 ||
|
|
4408
4514
|
value === "false" ||
|
|
4409
4515
|
value === false ||
|
|
4410
|
-
value === 0
|
|
4411
|
-
? false
|
|
4412
|
-
: true;
|
|
4516
|
+
value === 0);
|
|
4413
4517
|
},
|
|
4414
4518
|
};
|
|
4415
4519
|
/**
|
|
@@ -4481,7 +4585,7 @@ class AttributeDefinition {
|
|
|
4481
4585
|
/**
|
|
4482
4586
|
* Sets the value of the attribute/property on the source element.
|
|
4483
4587
|
* @param source - The source element to access.
|
|
4484
|
-
* @param
|
|
4588
|
+
* @param newValue - The value to set the attribute/property to.
|
|
4485
4589
|
*/
|
|
4486
4590
|
setValue(source, newValue) {
|
|
4487
4591
|
const oldValue = source[this.fieldName];
|
|
@@ -5919,4 +6023,4 @@ function customElement(nameOrDef) {
|
|
|
5919
6023
|
|
|
5920
6024
|
DOM.setPolicy(DOMPolicy.create());
|
|
5921
6025
|
|
|
5922
|
-
export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, HydratableElementController, HydrationBindingError, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RenderBehavior, RenderDirective, RepeatBehavior, RepeatDirective, SlottedDirective, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding$1 as normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, render, repeat, slotted, volatile, when };
|
|
6026
|
+
export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, HydratableElementController, HydrationBindingError, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RenderBehavior, RenderDirective, RepeatBehavior, RepeatDirective, SlottedDirective, Sort, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding$1 as normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, render, repeat, slotted, sortedCount, volatile, when };
|