@nanahoshi/mona-ui 0.27.2 → 0.29.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.
Files changed (213) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/locales.md +8 -0
  3. package/docs/api/popup.md +1 -1
  4. package/docs/api/theme.md +2 -2
  5. package/docs/chart.md +14 -0
  6. package/docs/editor.md +2 -0
  7. package/docs/installation.md +147 -15
  8. package/docs/introduction.md +37 -15
  9. package/docs/theming-built-in-themes.md +67 -0
  10. package/docs/theming-custom-colors.md +274 -0
  11. package/docs/theming-custom-themes.md +168 -0
  12. package/docs/theming.md +164 -248
  13. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  14. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  15. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  16. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  17. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  18. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
  19. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  20. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  21. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  22. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  23. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  24. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  25. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  26. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  27. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  28. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  29. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  30. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  31. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  32. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  33. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  34. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  35. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  37. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  38. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  39. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  40. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  41. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  42. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  49. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  50. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  51. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  52. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  53. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  54. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  55. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  58. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  59. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  60. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  61. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  62. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  63. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  65. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  66. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  67. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  68. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  70. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
  71. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  72. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  73. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  74. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  75. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  76. package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
  77. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  78. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  79. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  80. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  81. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  82. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  83. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  84. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  85. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  86. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  87. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  88. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  89. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  90. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  91. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  92. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  93. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  94. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  95. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  96. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  97. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  98. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  99. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  100. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  101. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  102. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  103. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  104. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  105. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  106. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  107. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  108. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  109. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  110. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  111. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  112. package/llms.txt +7 -3
  113. package/locales/pl-pl/package.json +4 -0
  114. package/locales/pl-pl/pl-pl.messages.json +536 -0
  115. package/package.json +66 -23
  116. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  117. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  118. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  119. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  120. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  121. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  122. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  123. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  124. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  125. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  126. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  127. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  128. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  129. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  130. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  131. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  132. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  133. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  134. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  135. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  136. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  137. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  138. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  139. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  140. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  141. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  142. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  143. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  144. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  145. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  146. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  147. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  148. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  149. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  150. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  151. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  152. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  153. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  154. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  155. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  156. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  157. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  158. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  159. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
  168. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  169. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  170. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  171. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  172. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  173. package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
  174. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  175. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  176. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  177. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  178. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  179. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  180. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  181. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  182. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  183. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  184. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  185. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  186. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  187. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  188. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  189. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  190. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  191. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  192. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  193. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  194. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  195. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  196. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  197. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  198. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  199. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  200. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  201. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  202. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  203. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  204. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  205. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  206. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  207. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  208. package/types/nanahoshi-mona-ui.d.ts +1 -2
  209. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  210. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  211. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  212. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  213. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,790 +1,616 @@
1
- import * as i0 from '@angular/core';
2
- import { Pipe, linkedSignal, computed, signal, untracked } from '@angular/core';
3
- import { any, contains, all, firstOrDefault, ImmutableDictionary } from '@mirei/ts-collections';
4
-
5
- class PreventableEvent {
6
- #event;
7
- #type;
8
- #defaultPrevented = false;
9
- constructor(type, event) {
10
- this.#type = type;
11
- this.#event = event;
12
- }
13
- /** Whether `preventDefault()` was called. */
14
- isDefaultPrevented() {
15
- return this.#defaultPrevented;
16
- }
17
- /** Cancels what the event announces, such as opening or closing a popup, or closing a dialog. */
18
- preventDefault() {
19
- this.#defaultPrevented = true;
20
- }
21
- /** The DOM event that caused this one, when there is one. */
22
- get originalEvent() {
23
- return this.#event;
24
- }
25
- /** A name for the kind of event, when the component that emits it sets one. */
26
- get type() {
27
- return this.#type;
28
- }
29
- }
30
-
31
- class FilterChangeEvent extends PreventableEvent {
32
- #filter;
33
- constructor(filterText) {
34
- super("filterInputChange");
35
- this.#filter = filterText;
36
- }
37
- get filter() {
38
- return this.#filter;
39
- }
40
- }
41
-
42
- /** @hidden Exported for Mona UI's other entry points; applications don't need it. */
43
- class AnyPipe {
44
- transform(sequence, predicate) {
45
- if (sequence == null) {
46
- return false;
47
- }
48
- if (!predicate) {
49
- return any(sequence);
50
- }
51
- return any(sequence, predicate);
52
- }
53
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
54
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: AnyPipe, isStandalone: true, name: "monaAny" }); }
55
- }
56
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AnyPipe, decorators: [{
57
- type: Pipe,
58
- args: [{
59
- name: "monaAny"
60
- }]
61
- }] });
62
-
63
- class ContainsPipe {
64
- transform(sequence, value) {
65
- if (sequence == null) {
66
- return false;
67
- }
68
- if (typeof value === "string") {
69
- return contains(sequence, value);
70
- }
71
- if (Symbol.iterator in Object(value)) {
72
- return all(value, item => contains(sequence, item));
73
- }
74
- return contains(sequence, value);
75
- }
76
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ContainsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
77
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: ContainsPipe, isStandalone: true, name: "monaContains" }); }
78
- }
79
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ContainsPipe, decorators: [{
80
- type: Pipe,
81
- args: [{
82
- name: "monaContains"
83
- }]
84
- }] });
85
-
86
- class SlicePipe {
87
- /**
88
- * Returns the elements from `start` up to, but not including, `end`, with the semantics of `Array.prototype.slice`:
89
- * negative indices count from the end, and an omitted `end` slices to the end. Returns an empty array for
90
- * `null` or `undefined`, such as the first value of the `async` pipe.
91
- */
92
- transform(value, start, end) {
93
- if (value == null) {
94
- return [];
95
- }
96
- return Array.from(value).slice(start, end);
97
- }
98
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SlicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
99
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: SlicePipe, isStandalone: true, name: "monaSlice" }); }
100
- }
101
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SlicePipe, decorators: [{
102
- type: Pipe,
103
- args: [{
104
- name: "monaSlice"
105
- }]
106
- }] });
107
-
108
- /** @hidden Exported for Mona UI's other entry points; applications don't need it. */
109
- class TakeFirstPipe {
110
- transform(value) {
111
- if (value == null) {
112
- return null;
113
- }
114
- return firstOrDefault(value);
115
- }
116
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TakeFirstPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
117
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: TakeFirstPipe, isStandalone: true, name: "monaTakeFirst" }); }
118
- }
119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TakeFirstPipe, decorators: [{
120
- type: Pipe,
121
- args: [{
122
- name: "monaTakeFirst"
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
- return Object.keys(obj).length === 0;
184
+ return Object.keys(obj).length === 0;
129
185
  };
130
186
  const isPlainObject = (v) => {
131
- return !!v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype;
187
+ return !!v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype;
132
188
  };
133
189
  function deepMerge(base, patch, options = defaultOptions, path = []) {
134
- if (!isPlainObject(patch)) {
135
- return base;
136
- }
137
- const out = isPlainObject(base) ? { ...base } : {};
138
- const keys = Object.keys(patch);
139
- for (const key of keys) {
140
- if (key === "__proto__") {
141
- continue;
142
- }
143
- const patchValue = patch[key];
144
- if (patchValue === undefined) {
145
- if (options.undefinedValues === "assign") {
146
- out[key] = undefined;
147
- }
148
- continue;
149
- }
150
- const baseValue = out[key];
151
- const currentPath = [...path, key];
152
- if (Array.isArray(patchValue)) {
153
- const rawStrategy = options.arrayStrategy ?? defaultOptions.arrayStrategy;
154
- const strategy = typeof rawStrategy === "function" ? rawStrategy(key, currentPath) : rawStrategy;
155
- if (strategy.kind === "replace" || !Array.isArray(baseValue)) {
156
- out[key] = patchValue;
157
- }
158
- else if (strategy.kind === "concat") {
159
- out[key] = [
160
- ...baseValue,
161
- ...patchValue
162
- ];
163
- }
164
- else {
165
- // unionBy strategy: a patch item is merged into the base item with the same key; items without a
166
- // key are kept as they are.
167
- const identify = createUnionIdentifier(strategy.key);
168
- const items = [];
169
- const indexById = new Map();
170
- const add = (item, merge) => {
171
- const id = identify(item);
172
- const index = id === undefined ? undefined : indexById.get(id);
173
- if (index === undefined) {
174
- if (id !== undefined) {
175
- indexById.set(id, items.length);
176
- }
177
- items.push(item);
178
- return;
179
- }
180
- const existing = items[index];
181
- items[index] = !merge
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
- return deepMerge(base, patch, options);
240
+ return deepMerge(base, patch, options);
207
241
  }
208
242
  function mergePatchInto(base, patch, options) {
209
- return deepMerge(base, patch, options);
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
- if (keys.length === 0) {
218
- return {};
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
- const keys = path;
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
- return deepMerge(obj, patchAt(path, value, obj), options);
253
+ return deepMerge(obj, patchAt(path, value, obj), options);
229
254
  }
230
255
  function prunePatch(base, patch) {
231
- if (patch === null || typeof patch !== "object" || base === null || typeof base !== "object") {
232
- return base === patch ? undefined : patch;
233
- }
234
- const baseObj = base;
235
- const patchObj = patch;
236
- const result = { ...patchObj };
237
- for (const key of Object.keys(patchObj)) {
238
- if (key === "__proto__") {
239
- delete result[key];
240
- continue;
241
- }
242
- if (!(key in baseObj)) {
243
- // An undefined field the base doesn't have is no change.
244
- if (patchObj[key] === undefined) {
245
- delete result[key];
246
- }
247
- continue;
248
- }
249
- const baseValue = baseObj[key];
250
- const patchValue = patchObj[key];
251
- if (isPlainObject(patchValue) && isPlainObject(baseValue)) {
252
- const pruned = prunePatch(baseValue, patchValue);
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
- return valuesEqual(o1, o2, new Map());
280
+ return valuesEqual(o1, o2, /* @__PURE__ */ new Map());
274
281
  }
275
282
  function valuesEqual(o1, o2, visited) {
276
- if (o1 === o2 || (Number.isNaN(o1) && Number.isNaN(o2))) {
277
- return true;
278
- }
279
- if (o1 === null || o2 === null || typeof o1 !== "object" || typeof o2 !== "object") {
280
- return false;
281
- }
282
- if (o1 instanceof Date || o2 instanceof Date) {
283
- return o1 instanceof Date && o2 instanceof Date && Object.is(o1.getTime(), o2.getTime());
284
- }
285
- if (o1 instanceof RegExp || o2 instanceof RegExp) {
286
- return o1 instanceof RegExp && o2 instanceof RegExp && o1.source === o2.source && o1.flags === o2.flags;
287
- }
288
- // A pair already being compared further up is assumed equal; any difference shows up there.
289
- let seen = visited.get(o1);
290
- if (seen?.has(o2)) {
291
- return true;
292
- }
293
- if (!seen) {
294
- seen = new Set();
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
- if (m1.size !== m2.size) {
321
- return false;
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
- if (s1.size !== s2.size) {
333
- return false;
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
- const [head, ...rest] = keys;
348
- const isArray = Array.isArray(current);
349
- const child = current != null && typeof current === "object"
350
- ? current[head]
351
- : undefined;
352
- const value = rest.length === 0 ? leaf : buildLevel(rest, leaf, child, whole || isArray);
353
- if (isArray) {
354
- const copy = [...current];
355
- copy[Number(head)] = value;
356
- return copy;
357
- }
358
- if (whole && isPlainObject(current)) {
359
- return { ...current, [head]: value };
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
- const keys = Array.isArray(by) ? by : [by];
369
- return item => {
370
- const values = keys.map(key => item != null && typeof item === "object" ? item[key] : undefined);
371
- return values.some(value => value == null) ? undefined : JSON.stringify(values, unionKeyReplacer);
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
- return typeof value === "bigint" ? { bigint: String(value) } : value;
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
- const currentView = deepMerge(base, draft, STORE_MERGE_OPTIONS);
388
- const nextView = deepMerge(currentView, patch, { ...STORE_MERGE_OPTIONS, ...options });
389
- return prunePatch(base, nextView) ?? {};
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
- if (input == null) {
694
- return "";
695
- }
696
- if (typeof input === "string") {
697
- return input;
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
- if (!isFinite(value) || !isFinite(min) || !isFinite(max) || max <= min) {
723
- return 0;
724
- }
725
- const raw = ((value - min) / (max - min)) * 100;
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
- if (!Number.isFinite(min) || !Number.isFinite(max) || max <= min) {
742
- return null;
743
- }
744
- const now = Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : min;
745
- return { max, min, now };
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
- if (offset === 0 || indices.length === 0 || !Number.isInteger(offset)) {
755
- return [...array];
756
- }
757
- indices = [...new Set(indices)];
758
- // Validate indices are integers within bounds
759
- if (indices.some(i => !Number.isInteger(i) || i < 0 || i >= array.length)) {
760
- return [...array];
761
- }
762
- // Check if any index would go out of bounds after the move
763
- for (const index of indices) {
764
- const newIndex = index + offset;
765
- if (newIndex < 0 || newIndex >= array.length) {
766
- return [...array];
767
- }
768
- }
769
- // Create a copy of the array
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
- //# sourceMappingURL=nanahoshi-mona-ui-common.mjs.map
615
+
616
+ //# sourceMappingURL=nanahoshi-mona-ui-common.mjs.map