@nanahoshi/mona-ui 0.27.2 → 0.28.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/docs/api/chart.md +2 -2
- package/docs/api/popup.md +1 -1
- package/docs/api/theme.md +2 -2
- package/docs/chart.md +14 -0
- package/docs/editor.md +2 -0
- package/docs/installation.md +147 -15
- package/docs/introduction.md +37 -15
- package/docs/theming-built-in-themes.md +67 -0
- package/docs/theming-custom-colors.md +274 -0
- package/docs/theming-custom-themes.md +168 -0
- package/docs/theming.md +164 -248
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
- package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
- package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
- package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
- package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
- package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
- package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
- package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
- package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
- package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
- package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
- package/llms.txt +6 -2
- package/package.json +62 -23
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
- package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
- package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
- package/types/nanahoshi-mona-ui-button.d.ts +227 -166
- package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
- package/types/nanahoshi-mona-ui-card.d.ts +125 -111
- package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
- package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
- package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
- package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
- package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
- package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
- package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
- package/types/nanahoshi-mona-ui-command.d.ts +279 -191
- package/types/nanahoshi-mona-ui-common.d.ts +354 -385
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
- package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
- package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
- package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
- package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
- package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
- package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
- package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
- package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
- package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
- package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
- package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
- package/types/nanahoshi-mona-ui-label.d.ts +108 -78
- package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
- package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
- package/types/nanahoshi-mona-ui-list.d.ts +2 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
- package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
- package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
- package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
- package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
- package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
- package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
- package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
- package/types/nanahoshi-mona-ui-query.d.ts +82 -88
- package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
- package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
- package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
- package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
- package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
- package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
- package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
- package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
- package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
- package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
- package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
- package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
- package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
- package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
- package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
- package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
- package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
- package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
- package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
- package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
- package/types/nanahoshi-mona-ui-window.d.ts +494 -399
- package/types/nanahoshi-mona-ui.d.ts +1 -2
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
|
@@ -1,790 +1,616 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Pipe,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Pipe, computed, linkedSignal, signal, untracked } from "@angular/core";
|
|
3
|
+
import { ImmutableDictionary, all, any, contains, firstOrDefault } from "@mirei/ts-collections";
|
|
4
|
+
var PreventableEvent = class {
|
|
5
|
+
#event;
|
|
6
|
+
#type;
|
|
7
|
+
#defaultPrevented = false;
|
|
8
|
+
constructor(type, event) {
|
|
9
|
+
this.#type = type;
|
|
10
|
+
this.#event = event;
|
|
11
|
+
}
|
|
12
|
+
isDefaultPrevented() {
|
|
13
|
+
return this.#defaultPrevented;
|
|
14
|
+
}
|
|
15
|
+
preventDefault() {
|
|
16
|
+
this.#defaultPrevented = true;
|
|
17
|
+
}
|
|
18
|
+
get originalEvent() {
|
|
19
|
+
return this.#event;
|
|
20
|
+
}
|
|
21
|
+
get type() {
|
|
22
|
+
return this.#type;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var FilterChangeEvent = class extends PreventableEvent {
|
|
26
|
+
#filter;
|
|
27
|
+
constructor(filterText) {
|
|
28
|
+
super("filterInputChange");
|
|
29
|
+
this.#filter = filterText;
|
|
30
|
+
}
|
|
31
|
+
get filter() {
|
|
32
|
+
return this.#filter;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var AnyPipe = class AnyPipe {
|
|
36
|
+
transform(sequence, predicate) {
|
|
37
|
+
if (sequence == null) return false;
|
|
38
|
+
if (!predicate) return any(sequence);
|
|
39
|
+
return any(sequence, predicate);
|
|
40
|
+
}
|
|
41
|
+
static {
|
|
42
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
43
|
+
minVersion: "12.0.0",
|
|
44
|
+
version: "22.2.6",
|
|
45
|
+
ngImport: i0,
|
|
46
|
+
type: AnyPipe,
|
|
47
|
+
deps: [],
|
|
48
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
static {
|
|
52
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
53
|
+
minVersion: "14.0.0",
|
|
54
|
+
version: "22.2.6",
|
|
55
|
+
ngImport: i0,
|
|
56
|
+
type: AnyPipe,
|
|
57
|
+
isStandalone: true,
|
|
58
|
+
name: "monaAny"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
63
|
+
minVersion: "12.0.0",
|
|
64
|
+
version: "22.2.6",
|
|
65
|
+
ngImport: i0,
|
|
66
|
+
type: AnyPipe,
|
|
67
|
+
decorators: [{
|
|
68
|
+
type: Pipe,
|
|
69
|
+
args: [{ name: "monaAny" }]
|
|
70
|
+
}]
|
|
71
|
+
});
|
|
72
|
+
var ContainsPipe = class ContainsPipe {
|
|
73
|
+
transform(sequence, value) {
|
|
74
|
+
if (sequence == null) return false;
|
|
75
|
+
if (typeof value === "string") return contains(sequence, value);
|
|
76
|
+
if (Symbol.iterator in Object(value)) return all(value, (item) => contains(sequence, item));
|
|
77
|
+
return contains(sequence, value);
|
|
78
|
+
}
|
|
79
|
+
static {
|
|
80
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
81
|
+
minVersion: "12.0.0",
|
|
82
|
+
version: "22.2.6",
|
|
83
|
+
ngImport: i0,
|
|
84
|
+
type: ContainsPipe,
|
|
85
|
+
deps: [],
|
|
86
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
static {
|
|
90
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
91
|
+
minVersion: "14.0.0",
|
|
92
|
+
version: "22.2.6",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: ContainsPipe,
|
|
95
|
+
isStandalone: true,
|
|
96
|
+
name: "monaContains"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
101
|
+
minVersion: "12.0.0",
|
|
102
|
+
version: "22.2.6",
|
|
103
|
+
ngImport: i0,
|
|
104
|
+
type: ContainsPipe,
|
|
105
|
+
decorators: [{
|
|
106
|
+
type: Pipe,
|
|
107
|
+
args: [{ name: "monaContains" }]
|
|
108
|
+
}]
|
|
109
|
+
});
|
|
110
|
+
var SlicePipe = class SlicePipe {
|
|
111
|
+
transform(value, start, end) {
|
|
112
|
+
if (value == null) return [];
|
|
113
|
+
return Array.from(value).slice(start, end);
|
|
114
|
+
}
|
|
115
|
+
static {
|
|
116
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
117
|
+
minVersion: "12.0.0",
|
|
118
|
+
version: "22.2.6",
|
|
119
|
+
ngImport: i0,
|
|
120
|
+
type: SlicePipe,
|
|
121
|
+
deps: [],
|
|
122
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
static {
|
|
126
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
127
|
+
minVersion: "14.0.0",
|
|
128
|
+
version: "22.2.6",
|
|
129
|
+
ngImport: i0,
|
|
130
|
+
type: SlicePipe,
|
|
131
|
+
isStandalone: true,
|
|
132
|
+
name: "monaSlice"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
137
|
+
minVersion: "12.0.0",
|
|
138
|
+
version: "22.2.6",
|
|
139
|
+
ngImport: i0,
|
|
140
|
+
type: SlicePipe,
|
|
141
|
+
decorators: [{
|
|
142
|
+
type: Pipe,
|
|
143
|
+
args: [{ name: "monaSlice" }]
|
|
144
|
+
}]
|
|
145
|
+
});
|
|
146
|
+
var TakeFirstPipe = class TakeFirstPipe {
|
|
147
|
+
transform(value) {
|
|
148
|
+
if (value == null) return null;
|
|
149
|
+
return firstOrDefault(value);
|
|
150
|
+
}
|
|
151
|
+
static {
|
|
152
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
153
|
+
minVersion: "12.0.0",
|
|
154
|
+
version: "22.2.6",
|
|
155
|
+
ngImport: i0,
|
|
156
|
+
type: TakeFirstPipe,
|
|
157
|
+
deps: [],
|
|
158
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
static {
|
|
162
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
163
|
+
minVersion: "14.0.0",
|
|
164
|
+
version: "22.2.6",
|
|
165
|
+
ngImport: i0,
|
|
166
|
+
type: TakeFirstPipe,
|
|
167
|
+
isStandalone: true,
|
|
168
|
+
name: "monaTakeFirst"
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
173
|
+
minVersion: "12.0.0",
|
|
174
|
+
version: "22.2.6",
|
|
175
|
+
ngImport: i0,
|
|
176
|
+
type: TakeFirstPipe,
|
|
177
|
+
decorators: [{
|
|
178
|
+
type: Pipe,
|
|
179
|
+
args: [{ name: "monaTakeFirst" }]
|
|
180
|
+
}]
|
|
181
|
+
});
|
|
126
182
|
const defaultOptions = { arrayStrategy: { kind: "replace" } };
|
|
127
183
|
const isEmptyObject = (obj) => {
|
|
128
|
-
|
|
184
|
+
return Object.keys(obj).length === 0;
|
|
129
185
|
};
|
|
130
186
|
const isPlainObject = (v) => {
|
|
131
|
-
|
|
187
|
+
return !!v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype;
|
|
132
188
|
};
|
|
133
189
|
function deepMerge(base, patch, options = defaultOptions, path = []) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
? item
|
|
183
|
-
: isPlainObject(item) && isPlainObject(existing)
|
|
184
|
-
? deepMerge(existing, item, options, currentPath)
|
|
185
|
-
: { ...existing, ...item };
|
|
186
|
-
};
|
|
187
|
-
for (const item of baseValue) {
|
|
188
|
-
add(item, false);
|
|
189
|
-
}
|
|
190
|
-
for (const item of patchValue) {
|
|
191
|
-
add(item, true);
|
|
192
|
-
}
|
|
193
|
-
out[key] = items;
|
|
194
|
-
}
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
if (isPlainObject(patchValue) && isPlainObject(baseValue)) {
|
|
198
|
-
out[key] = deepMerge(baseValue, patchValue, options, currentPath);
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
out[key] = patchValue;
|
|
202
|
-
}
|
|
203
|
-
return out;
|
|
190
|
+
if (!isPlainObject(patch)) return base;
|
|
191
|
+
const out = isPlainObject(base) ? { ...base } : {};
|
|
192
|
+
const keys = Object.keys(patch);
|
|
193
|
+
for (const key of keys) {
|
|
194
|
+
if (key === "__proto__") continue;
|
|
195
|
+
const patchValue = patch[key];
|
|
196
|
+
if (patchValue === void 0) {
|
|
197
|
+
if (options.undefinedValues === "assign") out[key] = void 0;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const baseValue = out[key];
|
|
201
|
+
const currentPath = [...path, key];
|
|
202
|
+
if (Array.isArray(patchValue)) {
|
|
203
|
+
const rawStrategy = options.arrayStrategy ?? defaultOptions.arrayStrategy;
|
|
204
|
+
const strategy = typeof rawStrategy === "function" ? rawStrategy(key, currentPath) : rawStrategy;
|
|
205
|
+
if (strategy.kind === "replace" || !Array.isArray(baseValue)) out[key] = patchValue;
|
|
206
|
+
else if (strategy.kind === "concat") out[key] = [...baseValue, ...patchValue];
|
|
207
|
+
else {
|
|
208
|
+
const identify = createUnionIdentifier(strategy.key);
|
|
209
|
+
const items = [];
|
|
210
|
+
const indexById = /* @__PURE__ */ new Map();
|
|
211
|
+
const add = (item, merge) => {
|
|
212
|
+
const id = identify(item);
|
|
213
|
+
const index = id === void 0 ? void 0 : indexById.get(id);
|
|
214
|
+
if (index === void 0) {
|
|
215
|
+
if (id !== void 0) indexById.set(id, items.length);
|
|
216
|
+
items.push(item);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const existing = items[index];
|
|
220
|
+
items[index] = !merge ? item : isPlainObject(item) && isPlainObject(existing) ? deepMerge(existing, item, options, currentPath) : {
|
|
221
|
+
...existing,
|
|
222
|
+
...item
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
for (const item of baseValue) add(item, false);
|
|
226
|
+
for (const item of patchValue) add(item, true);
|
|
227
|
+
out[key] = items;
|
|
228
|
+
}
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (isPlainObject(patchValue) && isPlainObject(baseValue)) {
|
|
232
|
+
out[key] = deepMerge(baseValue, patchValue, options, currentPath);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
out[key] = patchValue;
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
204
238
|
}
|
|
205
239
|
function mergeInto(base, patch, options) {
|
|
206
|
-
|
|
240
|
+
return deepMerge(base, patch, options);
|
|
207
241
|
}
|
|
208
242
|
function mergePatchInto(base, patch, options) {
|
|
209
|
-
|
|
243
|
+
return deepMerge(base, patch, options);
|
|
210
244
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Builds a patch that sets `leaf` at `keys`. When `current` (the value the patch will be merged into) holds an
|
|
213
|
-
* array along the path, the patch carries a copy of that array with the one element replaced, since arrays are
|
|
214
|
-
* replaced rather than merged. Without `current`, every level is an object.
|
|
215
|
-
*/
|
|
216
245
|
function buildNested(keys, leaf, current) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
return buildLevel(keys, leaf, current, false);
|
|
246
|
+
if (keys.length === 0) return {};
|
|
247
|
+
return buildLevel(keys, leaf, current, false);
|
|
221
248
|
}
|
|
222
249
|
function patchAt(path, value, current) {
|
|
223
|
-
|
|
224
|
-
const nested = buildNested(keys, value, current);
|
|
225
|
-
return nested;
|
|
250
|
+
return buildNested(path, value, current);
|
|
226
251
|
}
|
|
227
252
|
function setAt(obj, path, value, options) {
|
|
228
|
-
|
|
253
|
+
return deepMerge(obj, patchAt(path, value, obj), options);
|
|
229
254
|
}
|
|
230
255
|
function prunePatch(base, patch) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (pruned === undefined || (typeof pruned === "object" && Object.keys(pruned).length === 0)) {
|
|
254
|
-
delete result[key];
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
result[key] = pruned;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
else if (deepEquals(baseValue, patchValue)) {
|
|
261
|
-
delete result[key];
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return Object.keys(result).length === 0 ? undefined : result;
|
|
256
|
+
if (patch === null || typeof patch !== "object" || base === null || typeof base !== "object") return base === patch ? void 0 : patch;
|
|
257
|
+
const baseObj = base;
|
|
258
|
+
const patchObj = patch;
|
|
259
|
+
const result = { ...patchObj };
|
|
260
|
+
for (const key of Object.keys(patchObj)) {
|
|
261
|
+
if (key === "__proto__") {
|
|
262
|
+
delete result[key];
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (!(key in baseObj)) {
|
|
266
|
+
if (patchObj[key] === void 0) delete result[key];
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const baseValue = baseObj[key];
|
|
270
|
+
const patchValue = patchObj[key];
|
|
271
|
+
if (isPlainObject(patchValue) && isPlainObject(baseValue)) {
|
|
272
|
+
const pruned = prunePatch(baseValue, patchValue);
|
|
273
|
+
if (pruned === void 0 || typeof pruned === "object" && Object.keys(pruned).length === 0) delete result[key];
|
|
274
|
+
else result[key] = pruned;
|
|
275
|
+
} else if (deepEquals(baseValue, patchValue)) delete result[key];
|
|
276
|
+
}
|
|
277
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
265
278
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Structural equality for plain objects, arrays, `Date`, `RegExp`, `Map` and `Set`. Primitives are equal when
|
|
268
|
-
* `===` says so, and `NaN` equals `NaN`. Dates are equal when they hold the same time (two invalid dates are
|
|
269
|
-
* equal). Map keys and set members are matched by `SameValueZero`, like `Map.prototype.has`. Cyclic values are
|
|
270
|
-
* supported.
|
|
271
|
-
*/
|
|
272
279
|
function deepEquals(o1, o2) {
|
|
273
|
-
|
|
280
|
+
return valuesEqual(o1, o2, /* @__PURE__ */ new Map());
|
|
274
281
|
}
|
|
275
282
|
function valuesEqual(o1, o2, visited) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
visited.set(o1, seen);
|
|
296
|
-
}
|
|
297
|
-
seen.add(o2);
|
|
298
|
-
if (o1 instanceof Map || o2 instanceof Map) {
|
|
299
|
-
return o1 instanceof Map && o2 instanceof Map && mapsEqual(o1, o2, visited);
|
|
300
|
-
}
|
|
301
|
-
if (o1 instanceof Set || o2 instanceof Set) {
|
|
302
|
-
return o1 instanceof Set && o2 instanceof Set && setsEqual(o1, o2);
|
|
303
|
-
}
|
|
304
|
-
if (Array.isArray(o1) || Array.isArray(o2)) {
|
|
305
|
-
return (Array.isArray(o1) &&
|
|
306
|
-
Array.isArray(o2) &&
|
|
307
|
-
o1.length === o2.length &&
|
|
308
|
-
o1.every((value, index) => valuesEqual(value, o2[index], visited)));
|
|
309
|
-
}
|
|
310
|
-
const keys1 = Object.keys(o1);
|
|
311
|
-
if (keys1.length !== Object.keys(o2).length) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
const record1 = o1;
|
|
315
|
-
const record2 = o2;
|
|
316
|
-
return keys1.every(key => Object.hasOwn(record2, key) && valuesEqual(record1[key], record2[key], visited));
|
|
283
|
+
if (o1 === o2 || Number.isNaN(o1) && Number.isNaN(o2)) return true;
|
|
284
|
+
if (o1 === null || o2 === null || typeof o1 !== "object" || typeof o2 !== "object") return false;
|
|
285
|
+
if (o1 instanceof Date || o2 instanceof Date) return o1 instanceof Date && o2 instanceof Date && Object.is(o1.getTime(), o2.getTime());
|
|
286
|
+
if (o1 instanceof RegExp || o2 instanceof RegExp) return o1 instanceof RegExp && o2 instanceof RegExp && o1.source === o2.source && o1.flags === o2.flags;
|
|
287
|
+
let seen = visited.get(o1);
|
|
288
|
+
if (seen?.has(o2)) return true;
|
|
289
|
+
if (!seen) {
|
|
290
|
+
seen = /* @__PURE__ */ new Set();
|
|
291
|
+
visited.set(o1, seen);
|
|
292
|
+
}
|
|
293
|
+
seen.add(o2);
|
|
294
|
+
if (o1 instanceof Map || o2 instanceof Map) return o1 instanceof Map && o2 instanceof Map && mapsEqual(o1, o2, visited);
|
|
295
|
+
if (o1 instanceof Set || o2 instanceof Set) return o1 instanceof Set && o2 instanceof Set && setsEqual(o1, o2);
|
|
296
|
+
if (Array.isArray(o1) || Array.isArray(o2)) return Array.isArray(o1) && Array.isArray(o2) && o1.length === o2.length && o1.every((value, index) => valuesEqual(value, o2[index], visited));
|
|
297
|
+
const keys1 = Object.keys(o1);
|
|
298
|
+
if (keys1.length !== Object.keys(o2).length) return false;
|
|
299
|
+
const record1 = o1;
|
|
300
|
+
const record2 = o2;
|
|
301
|
+
return keys1.every((key) => Object.hasOwn(record2, key) && valuesEqual(record1[key], record2[key], visited));
|
|
317
302
|
}
|
|
318
|
-
/** Maps are equal when they have the same keys (by `SameValueZero`) and deeply equal values. */
|
|
319
303
|
function mapsEqual(m1, m2, visited) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
for (const [key, value] of m1) {
|
|
324
|
-
if (!m2.has(key) || !valuesEqual(value, m2.get(key), visited)) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return true;
|
|
304
|
+
if (m1.size !== m2.size) return false;
|
|
305
|
+
for (const [key, value] of m1) if (!m2.has(key) || !valuesEqual(value, m2.get(key), visited)) return false;
|
|
306
|
+
return true;
|
|
329
307
|
}
|
|
330
|
-
/** Sets are equal when they have the same members (by `SameValueZero`). */
|
|
331
308
|
function setsEqual(s1, s2) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
for (const value of s1) {
|
|
336
|
-
if (!s2.has(value)) {
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return true;
|
|
309
|
+
if (s1.size !== s2.size) return false;
|
|
310
|
+
for (const value of s1) if (!s2.has(value)) return false;
|
|
311
|
+
return true;
|
|
341
312
|
}
|
|
342
|
-
/**
|
|
343
|
-
* One level of `buildNested`. Inside an array (`whole`), each level must be the whole value, since the array
|
|
344
|
-
* element replaces the old one; outside, a level holds only the key on the path.
|
|
345
|
-
*/
|
|
346
313
|
function buildLevel(keys, leaf, current, whole) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return { [head]: value };
|
|
314
|
+
const [head, ...rest] = keys;
|
|
315
|
+
const isArray = Array.isArray(current);
|
|
316
|
+
const child = current != null && typeof current === "object" ? current[head] : void 0;
|
|
317
|
+
const value = rest.length === 0 ? leaf : buildLevel(rest, leaf, child, whole || isArray);
|
|
318
|
+
if (isArray) {
|
|
319
|
+
const copy = [...current];
|
|
320
|
+
copy[Number(head)] = value;
|
|
321
|
+
return copy;
|
|
322
|
+
}
|
|
323
|
+
if (whole && isPlainObject(current)) return {
|
|
324
|
+
...current,
|
|
325
|
+
[head]: value
|
|
326
|
+
};
|
|
327
|
+
return { [head]: value };
|
|
362
328
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Returns a function that tells `unionBy` items apart by the values of their key fields, or returns `undefined` for
|
|
365
|
-
* an item that lacks one. Values keep their type (`1` and `"1"` differ), and composite keys can't collide.
|
|
366
|
-
*/
|
|
367
329
|
function createUnionIdentifier(by) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
330
|
+
const keys = Array.isArray(by) ? by : [by];
|
|
331
|
+
return (item) => {
|
|
332
|
+
const values = keys.map((key) => item != null && typeof item === "object" ? item[key] : void 0);
|
|
333
|
+
return values.some((value) => value == null) ? void 0 : JSON.stringify(values, unionKeyReplacer);
|
|
334
|
+
};
|
|
373
335
|
}
|
|
374
336
|
function unionKeyReplacer(_key, value) {
|
|
375
|
-
|
|
337
|
+
return typeof value === "bigint" ? { bigint: String(value) } : value;
|
|
376
338
|
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Drafts hold final values: an `undefined` in a patch clears the field, and the draft is applied over the base
|
|
380
|
-
* with `replace`, so an array strategy only ever applies once, to the patch that introduced it.
|
|
381
|
-
*/
|
|
382
339
|
const STORE_MERGE_OPTIONS = { undefinedValues: "assign" };
|
|
383
|
-
/**
|
|
384
|
-
* Applies `patch` to the view of `base` with `draft`, and returns the fields that still differ from `base`.
|
|
385
|
-
*/
|
|
386
340
|
function applyPatch(base, draft, patch, options) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
class ObjectPatchStore {
|
|
392
|
-
#base;
|
|
393
|
-
#committed;
|
|
394
|
-
#draft;
|
|
395
|
-
#options;
|
|
396
|
-
constructor(options) {
|
|
397
|
-
this.#draft = linkedSignal({ ...(ngDevMode ? { debugName: "#draft" } : /* istanbul ignore next */ {}), source: () => this.#base(),
|
|
398
|
-
computation: (newBase, previous) => {
|
|
399
|
-
const strategy = this.#options.baseChangeStrategy ?? "wipe";
|
|
400
|
-
if (!previous) {
|
|
401
|
-
// First computation; the constructor then sets the initial draft.
|
|
402
|
-
return {};
|
|
403
|
-
}
|
|
404
|
-
switch (strategy) {
|
|
405
|
-
case "preserve":
|
|
406
|
-
return previous.value;
|
|
407
|
-
case "rebase":
|
|
408
|
-
return prunePatch(newBase, previous.value) ?? {};
|
|
409
|
-
case "wipe":
|
|
410
|
-
default:
|
|
411
|
-
return {};
|
|
412
|
-
}
|
|
413
|
-
} });
|
|
414
|
-
this.changes = computed(() => {
|
|
415
|
-
const draft = this.#draft();
|
|
416
|
-
return isEmptyObject(draft) ? undefined : draft;
|
|
417
|
-
}, /* @ts-ignore */
|
|
418
|
-
...(ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []));
|
|
419
|
-
this.pristine = computed(() => {
|
|
420
|
-
const base = this.#base();
|
|
421
|
-
const draft = this.#draft();
|
|
422
|
-
const committed = this.#committed();
|
|
423
|
-
const prunedDraft = prunePatch(base, draft) ?? {};
|
|
424
|
-
const prunedCommitted = prunePatch(base, committed) ?? {};
|
|
425
|
-
return deepEquals(prunedDraft, prunedCommitted);
|
|
426
|
-
}, /* @ts-ignore */
|
|
427
|
-
...(ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []));
|
|
428
|
-
this.view = computed(() => deepMerge(this.#base(), this.#draft(), STORE_MERGE_OPTIONS), /* @ts-ignore */
|
|
429
|
-
...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
430
|
-
this.#options = options;
|
|
431
|
-
this.#base = options.source();
|
|
432
|
-
const initial = options.initial?.() ?? {};
|
|
433
|
-
this.#committed = signal(initial, /* @ts-ignore */
|
|
434
|
-
...(ngDevMode ? [{ debugName: "#committed" }] : /* istanbul ignore next */ []));
|
|
435
|
-
// Sync initial draft; linkedSignal computation handles subsequent base changes.
|
|
436
|
-
this.#draft.set(initial);
|
|
437
|
-
}
|
|
438
|
-
clear() {
|
|
439
|
-
this.#draft.set({});
|
|
440
|
-
}
|
|
441
|
-
commit() {
|
|
442
|
-
this.#committed.set(this.#draft());
|
|
443
|
-
}
|
|
444
|
-
getCommitted() {
|
|
445
|
-
return this.#committed();
|
|
446
|
-
}
|
|
447
|
-
hasDraft() {
|
|
448
|
-
return !isEmptyObject(this.#draft());
|
|
449
|
-
}
|
|
450
|
-
patch(patch, options) {
|
|
451
|
-
const effectiveOptions = options ?? this.#options.mergeOptions;
|
|
452
|
-
this.#draft.update(currentDraft => applyPatch(this.#base(), currentDraft, patch, effectiveOptions));
|
|
453
|
-
}
|
|
454
|
-
patchPath(path, value, options) {
|
|
455
|
-
// Arrays along the path are copied from the current view (see buildNested).
|
|
456
|
-
const patch = buildNested(path, value, untracked(this.view));
|
|
457
|
-
this.patch(patch, options);
|
|
458
|
-
}
|
|
459
|
-
reset() {
|
|
460
|
-
this.#draft.set({});
|
|
461
|
-
this.#committed.set({});
|
|
462
|
-
}
|
|
463
|
-
select(projector, equal = deepEquals) {
|
|
464
|
-
return computed(() => projector(this.view()), { equal });
|
|
465
|
-
}
|
|
466
|
-
setDraft(patch) {
|
|
467
|
-
this.#draft.set(patch);
|
|
468
|
-
}
|
|
469
|
-
setPath(path, value, options) {
|
|
470
|
-
this.patchPath(path, value, options);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
class IterablePatchStore {
|
|
474
|
-
#base;
|
|
475
|
-
/**
|
|
476
|
-
* O(1) lookup map derived from the base signal. Rebuilt only when the
|
|
477
|
-
* base iterable emits a new value, not on every patch operation.
|
|
478
|
-
*/
|
|
479
|
-
#baseMap;
|
|
480
|
-
#committed;
|
|
481
|
-
#drafts;
|
|
482
|
-
#options;
|
|
483
|
-
/**
|
|
484
|
-
* Memoisation cache for the `view` computed. Keyed by item id; each
|
|
485
|
-
* entry stores the base item and draft references that produced the merged
|
|
486
|
-
* result, so we can skip deepMerge when neither of them changed. Rebuilt on
|
|
487
|
-
* every computation, so ids that leave the base or lose their draft drop out.
|
|
488
|
-
*/
|
|
489
|
-
#viewCache;
|
|
490
|
-
constructor(options) {
|
|
491
|
-
/**
|
|
492
|
-
* O(1) lookup map derived from the base signal. Rebuilt only when the
|
|
493
|
-
* base iterable emits a new value, not on every patch operation.
|
|
494
|
-
*/
|
|
495
|
-
this.#baseMap = computed(() => new Map(Array.from(this.#base()).map(item => [this.#options.idOf(item), item])), /* @ts-ignore */
|
|
496
|
-
...(ngDevMode ? [{ debugName: "#baseMap" }] : /* istanbul ignore next */ []));
|
|
497
|
-
this.#drafts = linkedSignal({ ...(ngDevMode ? { debugName: "#drafts" } : /* istanbul ignore next */ {}), source: () => this.#base(),
|
|
498
|
-
computation: (newBase, previous) => {
|
|
499
|
-
const strategy = this.#options.baseChangeStrategy ?? "wipe";
|
|
500
|
-
if (!previous) {
|
|
501
|
-
return ImmutableDictionary.create();
|
|
502
|
-
}
|
|
503
|
-
switch (strategy) {
|
|
504
|
-
case "preserve":
|
|
505
|
-
return previous.value;
|
|
506
|
-
case "rebase": {
|
|
507
|
-
const baseMap = new Map(Array.from(newBase, item => [this.#options.idOf(item), item]));
|
|
508
|
-
let rebased = ImmutableDictionary.create();
|
|
509
|
-
for (const [id, draft] of previous.value.entries()) {
|
|
510
|
-
const baseItem = baseMap.get(id);
|
|
511
|
-
if (!baseItem) {
|
|
512
|
-
// Item no longer exists in base — drop the draft.
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
const pruned = prunePatch(baseItem, draft);
|
|
516
|
-
if (pruned && !isEmptyObject(pruned)) {
|
|
517
|
-
rebased = rebased.put(id, pruned);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
return rebased;
|
|
521
|
-
}
|
|
522
|
-
case "wipe":
|
|
523
|
-
default:
|
|
524
|
-
return ImmutableDictionary.create();
|
|
525
|
-
}
|
|
526
|
-
} });
|
|
527
|
-
/**
|
|
528
|
-
* Memoisation cache for the `view` computed. Keyed by item id; each
|
|
529
|
-
* entry stores the base item and draft references that produced the merged
|
|
530
|
-
* result, so we can skip deepMerge when neither of them changed. Rebuilt on
|
|
531
|
-
* every computation, so ids that leave the base or lose their draft drop out.
|
|
532
|
-
*/
|
|
533
|
-
this.#viewCache = new Map();
|
|
534
|
-
this.changes = computed(() => {
|
|
535
|
-
const drafts = this.#drafts();
|
|
536
|
-
const changes = [];
|
|
537
|
-
for (const b of this.#base()) {
|
|
538
|
-
const draft = drafts.get(this.#options.idOf(b));
|
|
539
|
-
if (draft != null && !isEmptyObject(draft)) {
|
|
540
|
-
changes.push(deepMerge(b, draft, STORE_MERGE_OPTIONS));
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
return changes;
|
|
544
|
-
}, /* @ts-ignore */
|
|
545
|
-
...(ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []));
|
|
546
|
-
this.pristine = computed(() => {
|
|
547
|
-
const baseMap = this.#baseMap();
|
|
548
|
-
const drafts = this.#drafts();
|
|
549
|
-
const committed = this.#committed();
|
|
550
|
-
const allIds = new Set([...drafts.keys(), ...committed.keys()]);
|
|
551
|
-
for (const id of allIds) {
|
|
552
|
-
const draft = drafts.get(id) ?? {};
|
|
553
|
-
const committedDraft = committed.get(id) ?? {};
|
|
554
|
-
const originalItem = baseMap.get(id);
|
|
555
|
-
const prunedDraft = originalItem ? (prunePatch(originalItem, draft) ?? {}) : draft;
|
|
556
|
-
const prunedCommitted = originalItem
|
|
557
|
-
? (prunePatch(originalItem, committedDraft) ?? {})
|
|
558
|
-
: committedDraft;
|
|
559
|
-
if (!deepEquals(prunedDraft, prunedCommitted)) {
|
|
560
|
-
return false;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return true;
|
|
564
|
-
}, /* @ts-ignore */
|
|
565
|
-
...(ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []));
|
|
566
|
-
this.view = computed(() => {
|
|
567
|
-
const drafts = this.#drafts();
|
|
568
|
-
const previousCache = this.#viewCache;
|
|
569
|
-
const nextCache = new Map();
|
|
570
|
-
const view = Array.from(this.#base()).map(b => {
|
|
571
|
-
const id = this.#options.idOf(b);
|
|
572
|
-
const patch = drafts.get(id);
|
|
573
|
-
if (!patch || isEmptyObject(patch)) {
|
|
574
|
-
// No draft — return base item directly.
|
|
575
|
-
return b;
|
|
576
|
-
}
|
|
577
|
-
const cached = previousCache.get(id);
|
|
578
|
-
// Reuse the merged value only when neither the base item nor its
|
|
579
|
-
// draft changed, to avoid an unnecessary deepMerge and allocation.
|
|
580
|
-
const merged = cached && cached.baseRef === b && cached.patchRef === patch
|
|
581
|
-
? cached.merged
|
|
582
|
-
: deepMerge(b, patch, STORE_MERGE_OPTIONS);
|
|
583
|
-
nextCache.set(id, { baseRef: b, merged, patchRef: patch });
|
|
584
|
-
return merged;
|
|
585
|
-
});
|
|
586
|
-
this.#viewCache = nextCache;
|
|
587
|
-
return view;
|
|
588
|
-
}, /* @ts-ignore */
|
|
589
|
-
...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
590
|
-
this.#options = options;
|
|
591
|
-
this.#base = options.source();
|
|
592
|
-
const initialValue = options.initial?.();
|
|
593
|
-
const initial = initialValue instanceof ImmutableDictionary
|
|
594
|
-
? initialValue
|
|
595
|
-
: ImmutableDictionary.create(initialValue ?? []);
|
|
596
|
-
this.#committed = signal(initial, /* @ts-ignore */
|
|
597
|
-
...(ngDevMode ? [{ debugName: "#committed" }] : /* istanbul ignore next */ []));
|
|
598
|
-
if (initialValue) {
|
|
599
|
-
this.#drafts.set(initial);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
clear(id) {
|
|
603
|
-
this.#drafts.update(drafts => {
|
|
604
|
-
if (!drafts.containsKey(id))
|
|
605
|
-
return drafts;
|
|
606
|
-
return drafts.remove(id);
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
clearAll() {
|
|
610
|
-
this.#drafts.set(ImmutableDictionary.create());
|
|
611
|
-
}
|
|
612
|
-
commit() {
|
|
613
|
-
this.#committed.set(ImmutableDictionary.create(this.#drafts()));
|
|
614
|
-
}
|
|
615
|
-
dirtyCount() {
|
|
616
|
-
let count = 0;
|
|
617
|
-
for (const patch of this.#drafts().values()) {
|
|
618
|
-
if (typeof patch === "object" && patch != null && !isEmptyObject(patch)) {
|
|
619
|
-
++count;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return count;
|
|
623
|
-
}
|
|
624
|
-
getCommitted() {
|
|
625
|
-
return this.#committed();
|
|
626
|
-
}
|
|
627
|
-
hasDraft(id) {
|
|
628
|
-
const patch = this.#drafts().get(id);
|
|
629
|
-
return patch != null && !isEmptyObject(patch);
|
|
630
|
-
}
|
|
631
|
-
patch(id, patch, options = this.#options.mergeOptions) {
|
|
632
|
-
this.#drafts.update(drafts => {
|
|
633
|
-
const prev = drafts.get(id) ?? {};
|
|
634
|
-
const originalItem = this.#baseMap().get(id);
|
|
635
|
-
const next = originalItem
|
|
636
|
-
? applyPatch(originalItem, prev, patch, options)
|
|
637
|
-
: deepMerge(prev, patch, { ...STORE_MERGE_OPTIONS, ...options });
|
|
638
|
-
return isEmptyObject(next) ? drafts.remove(id) : drafts.put(id, next);
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
patchMany(patchTuple, options = this.#options.mergeOptions) {
|
|
642
|
-
const baseMap = this.#baseMap();
|
|
643
|
-
this.#drafts.update(drafts => {
|
|
644
|
-
// Each put on an ImmutableDictionary copies it, so collect the drafts in a Map and build one dictionary.
|
|
645
|
-
const nextDrafts = new Map(drafts.entries());
|
|
646
|
-
for (const [id, value] of patchTuple) {
|
|
647
|
-
const prev = nextDrafts.get(id) ?? {};
|
|
648
|
-
const originalItem = baseMap.get(id);
|
|
649
|
-
const next = originalItem
|
|
650
|
-
? applyPatch(originalItem, prev, value, options)
|
|
651
|
-
: deepMerge(prev, value, { ...STORE_MERGE_OPTIONS, ...options });
|
|
652
|
-
if (isEmptyObject(next)) {
|
|
653
|
-
nextDrafts.delete(id);
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
nextDrafts.set(id, next);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return ImmutableDictionary.create(nextDrafts);
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
patchPath(id, path, value, options) {
|
|
663
|
-
// Arrays along the path are copied from the item's current view (see buildNested).
|
|
664
|
-
const current = untracked(() => {
|
|
665
|
-
const baseItem = this.#baseMap().get(id);
|
|
666
|
-
const draft = this.#drafts().get(id);
|
|
667
|
-
return baseItem !== undefined && draft
|
|
668
|
-
? deepMerge(baseItem, draft, STORE_MERGE_OPTIONS)
|
|
669
|
-
: (baseItem ?? draft);
|
|
670
|
-
});
|
|
671
|
-
const patch = buildNested(path, value, current);
|
|
672
|
-
this.patch(id, patch, options);
|
|
673
|
-
}
|
|
674
|
-
reset() {
|
|
675
|
-
const empty = ImmutableDictionary.create();
|
|
676
|
-
this.#drafts.set(empty);
|
|
677
|
-
this.#committed.set(empty);
|
|
678
|
-
}
|
|
679
|
-
select(projector, equal = deepEquals) {
|
|
680
|
-
return computed(() => projector(this.view()), { equal });
|
|
681
|
-
}
|
|
682
|
-
setDraft(id, patch) {
|
|
683
|
-
this.#drafts.update(drafts => isEmptyObject(patch) ? drafts.remove(id) : drafts.put(id, patch));
|
|
684
|
-
}
|
|
685
|
-
setPath(id, path, value, options) {
|
|
686
|
-
this.patchPath(id, path, value, options);
|
|
687
|
-
}
|
|
341
|
+
return prunePatch(base, deepMerge(deepMerge(base, draft, STORE_MERGE_OPTIONS), patch, {
|
|
342
|
+
...STORE_MERGE_OPTIONS,
|
|
343
|
+
...options
|
|
344
|
+
})) ?? {};
|
|
688
345
|
}
|
|
346
|
+
var ObjectPatchStore = class {
|
|
347
|
+
#base;
|
|
348
|
+
#committed;
|
|
349
|
+
#draft;
|
|
350
|
+
#options;
|
|
351
|
+
constructor(options) {
|
|
352
|
+
this.#draft = linkedSignal({
|
|
353
|
+
...ngDevMode ? { debugName: "#draft" } : /* istanbul ignore next */ {},
|
|
354
|
+
source: () => this.#base(),
|
|
355
|
+
computation: (newBase, previous) => {
|
|
356
|
+
const strategy = this.#options.baseChangeStrategy ?? "wipe";
|
|
357
|
+
if (!previous) return {};
|
|
358
|
+
switch (strategy) {
|
|
359
|
+
case "preserve": return previous.value;
|
|
360
|
+
case "rebase": return prunePatch(newBase, previous.value) ?? {};
|
|
361
|
+
default: return {};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
this.changes = computed(() => {
|
|
366
|
+
const draft = this.#draft();
|
|
367
|
+
return isEmptyObject(draft) ? void 0 : draft;
|
|
368
|
+
}, ...ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []);
|
|
369
|
+
this.pristine = computed(() => {
|
|
370
|
+
const base = this.#base();
|
|
371
|
+
const draft = this.#draft();
|
|
372
|
+
const committed = this.#committed();
|
|
373
|
+
return deepEquals(prunePatch(base, draft) ?? {}, prunePatch(base, committed) ?? {});
|
|
374
|
+
}, ...ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []);
|
|
375
|
+
this.view = computed(() => deepMerge(this.#base(), this.#draft(), STORE_MERGE_OPTIONS), ...ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []);
|
|
376
|
+
this.#options = options;
|
|
377
|
+
this.#base = options.source();
|
|
378
|
+
const initial = options.initial?.() ?? {};
|
|
379
|
+
this.#committed = signal(initial, ...ngDevMode ? [{ debugName: "#committed" }] : /* istanbul ignore next */ []);
|
|
380
|
+
this.#draft.set(initial);
|
|
381
|
+
}
|
|
382
|
+
clear() {
|
|
383
|
+
this.#draft.set({});
|
|
384
|
+
}
|
|
385
|
+
commit() {
|
|
386
|
+
this.#committed.set(this.#draft());
|
|
387
|
+
}
|
|
388
|
+
getCommitted() {
|
|
389
|
+
return this.#committed();
|
|
390
|
+
}
|
|
391
|
+
hasDraft() {
|
|
392
|
+
return !isEmptyObject(this.#draft());
|
|
393
|
+
}
|
|
394
|
+
patch(patch, options) {
|
|
395
|
+
const effectiveOptions = options ?? this.#options.mergeOptions;
|
|
396
|
+
this.#draft.update((currentDraft) => applyPatch(this.#base(), currentDraft, patch, effectiveOptions));
|
|
397
|
+
}
|
|
398
|
+
patchPath(path, value, options) {
|
|
399
|
+
const patch = buildNested(path, value, untracked(this.view));
|
|
400
|
+
this.patch(patch, options);
|
|
401
|
+
}
|
|
402
|
+
reset() {
|
|
403
|
+
this.#draft.set({});
|
|
404
|
+
this.#committed.set({});
|
|
405
|
+
}
|
|
406
|
+
select(projector, equal = deepEquals) {
|
|
407
|
+
return computed(() => projector(this.view()), { equal });
|
|
408
|
+
}
|
|
409
|
+
setDraft(patch) {
|
|
410
|
+
this.#draft.set(patch);
|
|
411
|
+
}
|
|
412
|
+
setPath(path, value, options) {
|
|
413
|
+
this.patchPath(path, value, options);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var IterablePatchStore = class {
|
|
417
|
+
#base;
|
|
418
|
+
#baseMap;
|
|
419
|
+
#committed;
|
|
420
|
+
#drafts;
|
|
421
|
+
#options;
|
|
422
|
+
#viewCache;
|
|
423
|
+
constructor(options) {
|
|
424
|
+
this.#baseMap = computed(() => new Map(Array.from(this.#base()).map((item) => [this.#options.idOf(item), item])), ...ngDevMode ? [{ debugName: "#baseMap" }] : /* istanbul ignore next */ []);
|
|
425
|
+
this.#drafts = linkedSignal({
|
|
426
|
+
...ngDevMode ? { debugName: "#drafts" } : /* istanbul ignore next */ {},
|
|
427
|
+
source: () => this.#base(),
|
|
428
|
+
computation: (newBase, previous) => {
|
|
429
|
+
const strategy = this.#options.baseChangeStrategy ?? "wipe";
|
|
430
|
+
if (!previous) return ImmutableDictionary.create();
|
|
431
|
+
switch (strategy) {
|
|
432
|
+
case "preserve": return previous.value;
|
|
433
|
+
case "rebase": {
|
|
434
|
+
const baseMap = new Map(Array.from(newBase, (item) => [this.#options.idOf(item), item]));
|
|
435
|
+
let rebased = ImmutableDictionary.create();
|
|
436
|
+
for (const [id, draft] of previous.value.entries()) {
|
|
437
|
+
const baseItem = baseMap.get(id);
|
|
438
|
+
if (!baseItem) continue;
|
|
439
|
+
const pruned = prunePatch(baseItem, draft);
|
|
440
|
+
if (pruned && !isEmptyObject(pruned)) rebased = rebased.put(id, pruned);
|
|
441
|
+
}
|
|
442
|
+
return rebased;
|
|
443
|
+
}
|
|
444
|
+
default: return ImmutableDictionary.create();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
this.#viewCache = /* @__PURE__ */ new Map();
|
|
449
|
+
this.changes = computed(() => {
|
|
450
|
+
const drafts = this.#drafts();
|
|
451
|
+
const changes = [];
|
|
452
|
+
for (const b of this.#base()) {
|
|
453
|
+
const draft = drafts.get(this.#options.idOf(b));
|
|
454
|
+
if (draft != null && !isEmptyObject(draft)) changes.push(deepMerge(b, draft, STORE_MERGE_OPTIONS));
|
|
455
|
+
}
|
|
456
|
+
return changes;
|
|
457
|
+
}, ...ngDevMode ? [{ debugName: "changes" }] : /* istanbul ignore next */ []);
|
|
458
|
+
this.pristine = computed(() => {
|
|
459
|
+
const baseMap = this.#baseMap();
|
|
460
|
+
const drafts = this.#drafts();
|
|
461
|
+
const committed = this.#committed();
|
|
462
|
+
const allIds = /* @__PURE__ */ new Set([...drafts.keys(), ...committed.keys()]);
|
|
463
|
+
for (const id of allIds) {
|
|
464
|
+
const draft = drafts.get(id) ?? {};
|
|
465
|
+
const committedDraft = committed.get(id) ?? {};
|
|
466
|
+
const originalItem = baseMap.get(id);
|
|
467
|
+
if (!deepEquals(originalItem ? prunePatch(originalItem, draft) ?? {} : draft, originalItem ? prunePatch(originalItem, committedDraft) ?? {} : committedDraft)) return false;
|
|
468
|
+
}
|
|
469
|
+
return true;
|
|
470
|
+
}, ...ngDevMode ? [{ debugName: "pristine" }] : /* istanbul ignore next */ []);
|
|
471
|
+
this.view = computed(() => {
|
|
472
|
+
const drafts = this.#drafts();
|
|
473
|
+
const previousCache = this.#viewCache;
|
|
474
|
+
const nextCache = /* @__PURE__ */ new Map();
|
|
475
|
+
const view = Array.from(this.#base()).map((b) => {
|
|
476
|
+
const id = this.#options.idOf(b);
|
|
477
|
+
const patch = drafts.get(id);
|
|
478
|
+
if (!patch || isEmptyObject(patch)) return b;
|
|
479
|
+
const cached = previousCache.get(id);
|
|
480
|
+
const merged = cached && cached.baseRef === b && cached.patchRef === patch ? cached.merged : deepMerge(b, patch, STORE_MERGE_OPTIONS);
|
|
481
|
+
nextCache.set(id, {
|
|
482
|
+
baseRef: b,
|
|
483
|
+
merged,
|
|
484
|
+
patchRef: patch
|
|
485
|
+
});
|
|
486
|
+
return merged;
|
|
487
|
+
});
|
|
488
|
+
this.#viewCache = nextCache;
|
|
489
|
+
return view;
|
|
490
|
+
}, ...ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []);
|
|
491
|
+
this.#options = options;
|
|
492
|
+
this.#base = options.source();
|
|
493
|
+
const initialValue = options.initial?.();
|
|
494
|
+
const initial = initialValue instanceof ImmutableDictionary ? initialValue : ImmutableDictionary.create(initialValue ?? []);
|
|
495
|
+
this.#committed = signal(initial, ...ngDevMode ? [{ debugName: "#committed" }] : /* istanbul ignore next */ []);
|
|
496
|
+
if (initialValue) this.#drafts.set(initial);
|
|
497
|
+
}
|
|
498
|
+
clear(id) {
|
|
499
|
+
this.#drafts.update((drafts) => {
|
|
500
|
+
if (!drafts.containsKey(id)) return drafts;
|
|
501
|
+
return drafts.remove(id);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
clearAll() {
|
|
505
|
+
this.#drafts.set(ImmutableDictionary.create());
|
|
506
|
+
}
|
|
507
|
+
commit() {
|
|
508
|
+
this.#committed.set(ImmutableDictionary.create(this.#drafts()));
|
|
509
|
+
}
|
|
510
|
+
dirtyCount() {
|
|
511
|
+
let count = 0;
|
|
512
|
+
for (const patch of this.#drafts().values()) if (typeof patch === "object" && patch != null && !isEmptyObject(patch)) ++count;
|
|
513
|
+
return count;
|
|
514
|
+
}
|
|
515
|
+
getCommitted() {
|
|
516
|
+
return this.#committed();
|
|
517
|
+
}
|
|
518
|
+
hasDraft(id) {
|
|
519
|
+
const patch = this.#drafts().get(id);
|
|
520
|
+
return patch != null && !isEmptyObject(patch);
|
|
521
|
+
}
|
|
522
|
+
patch(id, patch, options = this.#options.mergeOptions) {
|
|
523
|
+
this.#drafts.update((drafts) => {
|
|
524
|
+
const prev = drafts.get(id) ?? {};
|
|
525
|
+
const originalItem = this.#baseMap().get(id);
|
|
526
|
+
const next = originalItem ? applyPatch(originalItem, prev, patch, options) : deepMerge(prev, patch, {
|
|
527
|
+
...STORE_MERGE_OPTIONS,
|
|
528
|
+
...options
|
|
529
|
+
});
|
|
530
|
+
return isEmptyObject(next) ? drafts.remove(id) : drafts.put(id, next);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
patchMany(patchTuple, options = this.#options.mergeOptions) {
|
|
534
|
+
const baseMap = this.#baseMap();
|
|
535
|
+
this.#drafts.update((drafts) => {
|
|
536
|
+
const nextDrafts = new Map(drafts.entries());
|
|
537
|
+
for (const [id, value] of patchTuple) {
|
|
538
|
+
const prev = nextDrafts.get(id) ?? {};
|
|
539
|
+
const originalItem = baseMap.get(id);
|
|
540
|
+
const next = originalItem ? applyPatch(originalItem, prev, value, options) : deepMerge(prev, value, {
|
|
541
|
+
...STORE_MERGE_OPTIONS,
|
|
542
|
+
...options
|
|
543
|
+
});
|
|
544
|
+
if (isEmptyObject(next)) nextDrafts.delete(id);
|
|
545
|
+
else nextDrafts.set(id, next);
|
|
546
|
+
}
|
|
547
|
+
return ImmutableDictionary.create(nextDrafts);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
patchPath(id, path, value, options) {
|
|
551
|
+
const patch = buildNested(path, value, untracked(() => {
|
|
552
|
+
const baseItem = this.#baseMap().get(id);
|
|
553
|
+
const draft = this.#drafts().get(id);
|
|
554
|
+
return baseItem !== void 0 && draft ? deepMerge(baseItem, draft, STORE_MERGE_OPTIONS) : baseItem ?? draft;
|
|
555
|
+
}));
|
|
556
|
+
this.patch(id, patch, options);
|
|
557
|
+
}
|
|
558
|
+
reset() {
|
|
559
|
+
const empty = ImmutableDictionary.create();
|
|
560
|
+
this.#drafts.set(empty);
|
|
561
|
+
this.#committed.set(empty);
|
|
562
|
+
}
|
|
563
|
+
select(projector, equal = deepEquals) {
|
|
564
|
+
return computed(() => projector(this.view()), { equal });
|
|
565
|
+
}
|
|
566
|
+
setDraft(id, patch) {
|
|
567
|
+
this.#drafts.update((drafts) => isEmptyObject(patch) ? drafts.remove(id) : drafts.put(id, patch));
|
|
568
|
+
}
|
|
569
|
+
setPath(id, path, value, options) {
|
|
570
|
+
this.patchPath(id, path, value, options);
|
|
571
|
+
}
|
|
572
|
+
};
|
|
689
573
|
const createIterablePatchStore = (options) => new IterablePatchStore(options);
|
|
690
574
|
const createObjectPatchStore = (options) => new ObjectPatchStore(options);
|
|
691
|
-
|
|
692
575
|
const classInputToClass = (input) => {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
if (Array.isArray(input)) {
|
|
700
|
-
return input.filter(Boolean).join(" ");
|
|
701
|
-
}
|
|
702
|
-
if (typeof input === "object") {
|
|
703
|
-
return Object.entries(input)
|
|
704
|
-
.filter(([, value]) => value)
|
|
705
|
-
.map(([key]) => key)
|
|
706
|
-
.join(" ");
|
|
707
|
-
}
|
|
708
|
-
return "";
|
|
576
|
+
if (input == null) return "";
|
|
577
|
+
if (typeof input === "string") return input;
|
|
578
|
+
if (Array.isArray(input)) return input.filter(Boolean).join(" ");
|
|
579
|
+
if (typeof input === "object") return Object.entries(input).filter(([, value]) => value).map(([key]) => key).join(" ");
|
|
580
|
+
return "";
|
|
709
581
|
};
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Calculates the percentage of a value within a given range, rounded to the specified precision.
|
|
713
|
-
* @param value The current value.
|
|
714
|
-
* @param min The minimum value.
|
|
715
|
-
* @param max The maximum value.
|
|
716
|
-
* @param precision The number of decimal places to round the percentage to, clamped to 0–100.
|
|
717
|
-
* @default 2
|
|
718
|
-
* @returns The percentage of the value within the range, rounded to the specified precision, or 0 when the range
|
|
719
|
-
* or the value is not finite.
|
|
720
|
-
*/
|
|
721
582
|
const getPercentage = (value, min, max, precision = 2) => {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
const digits = Math.min(100, Math.max(0, Math.trunc(precision) || 0));
|
|
727
|
-
return Number(Math.min(100, Math.max(0, raw)).toFixed(digits));
|
|
583
|
+
if (!isFinite(value) || !isFinite(min) || !isFinite(max) || max <= min) return 0;
|
|
584
|
+
const raw = (value - min) / (max - min) * 100;
|
|
585
|
+
const digits = Math.min(100, Math.max(0, Math.trunc(precision) || 0));
|
|
586
|
+
return Number(Math.min(100, Math.max(0, raw)).toFixed(digits));
|
|
728
587
|
};
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Gives the values a progress indicator can report: `value` clamped into the range, with a non-finite `value` read as
|
|
732
|
-
* `min`, the same place `getPercentage` draws it.
|
|
733
|
-
* @param value The current value.
|
|
734
|
-
* @param min The minimum value.
|
|
735
|
-
* @param max The maximum value.
|
|
736
|
-
* @returns The range and the value within it, or `null` when the range itself is invalid, because `min` or `max` isn't
|
|
737
|
-
* finite or `max` isn't above `min`.
|
|
738
|
-
* @hidden Exported for Mona UI's other entry points; applications don't need it.
|
|
739
|
-
*/
|
|
740
588
|
const normalizeProgressRange = (value, min, max) => {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
589
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max <= min) return null;
|
|
590
|
+
return {
|
|
591
|
+
max,
|
|
592
|
+
min,
|
|
593
|
+
now: Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : min
|
|
594
|
+
};
|
|
746
595
|
};
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Moves the items at `indices` by `offset` positions, keeping their relative order. Returns a copy of the array
|
|
750
|
-
* unchanged when the offset is 0 or not an integer, or when any index is not an integer, is out of bounds, or would
|
|
751
|
-
* move out of bounds. Duplicate indices count once.
|
|
752
|
-
*/
|
|
753
596
|
function moveIndices(array, indices, offset) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
const result = [...array];
|
|
771
|
-
// Sort indices based on movement direction to avoid conflicts
|
|
772
|
-
const sortedIndices = [...indices].sort((a, b) => (offset > 0 ? b - a : a - b));
|
|
773
|
-
// Move each item to its new position
|
|
774
|
-
for (const index of sortedIndices) {
|
|
775
|
-
const item = result[index];
|
|
776
|
-
const newIndex = index + offset;
|
|
777
|
-
// Remove item from current position
|
|
778
|
-
result.splice(index, 1);
|
|
779
|
-
// Insert at new position
|
|
780
|
-
result.splice(newIndex, 0, item);
|
|
781
|
-
}
|
|
782
|
-
return result;
|
|
597
|
+
if (offset === 0 || indices.length === 0 || !Number.isInteger(offset)) return [...array];
|
|
598
|
+
indices = [...new Set(indices)];
|
|
599
|
+
if (indices.some((i) => !Number.isInteger(i) || i < 0 || i >= array.length)) return [...array];
|
|
600
|
+
for (const index of indices) {
|
|
601
|
+
const newIndex = index + offset;
|
|
602
|
+
if (newIndex < 0 || newIndex >= array.length) return [...array];
|
|
603
|
+
}
|
|
604
|
+
const result = [...array];
|
|
605
|
+
const sortedIndices = [...indices].sort((a, b) => offset > 0 ? b - a : a - b);
|
|
606
|
+
for (const index of sortedIndices) {
|
|
607
|
+
const item = result[index];
|
|
608
|
+
const newIndex = index + offset;
|
|
609
|
+
result.splice(index, 1);
|
|
610
|
+
result.splice(newIndex, 0, item);
|
|
611
|
+
}
|
|
612
|
+
return result;
|
|
783
613
|
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Generated bundle index. Do not edit.
|
|
787
|
-
*/
|
|
788
|
-
|
|
789
614
|
export { AnyPipe, ContainsPipe, FilterChangeEvent, IterablePatchStore, ObjectPatchStore, PreventableEvent, SlicePipe, TakeFirstPipe, buildNested, classInputToClass, createIterablePatchStore, createObjectPatchStore, deepEquals, deepMerge, getPercentage, isEmptyObject, isPlainObject, mergeInto, mergePatchInto, moveIndices, normalizeProgressRange, patchAt, prunePatch, setAt };
|
|
790
|
-
|
|
615
|
+
|
|
616
|
+
//# sourceMappingURL=nanahoshi-mona-ui-common.mjs.map
|