@ionic/angular 8.0.0-beta.1 → 8.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/common/directives/control-value-accessors/value-accessor.d.ts +1 -1
  2. package/common/directives/navigation/back-button.d.ts +1 -4
  3. package/common/directives/navigation/nav.d.ts +10 -2
  4. package/common/directives/navigation/router-link-delegate.d.ts +2 -2
  5. package/common/directives/navigation/router-outlet.d.ts +6 -6
  6. package/common/directives/navigation/tabs.d.ts +5 -5
  7. package/common/overlays/modal.d.ts +1 -1
  8. package/common/overlays/popover.d.ts +1 -1
  9. package/common/providers/dom-controller.d.ts +1 -1
  10. package/css/palettes/dark.always.css.map +1 -0
  11. package/css/{themes → palettes}/dark.class.css +4 -4
  12. package/css/palettes/dark.class.css.map +1 -0
  13. package/css/palettes/dark.system.css.map +1 -0
  14. package/css/palettes/high-contrast-dark.always.css.map +1 -0
  15. package/css/{themes → palettes}/high-contrast-dark.class.css +10 -10
  16. package/css/palettes/high-contrast-dark.class.css.map +1 -0
  17. package/css/palettes/high-contrast-dark.system.css.map +1 -0
  18. package/css/palettes/high-contrast.always.css.map +1 -0
  19. package/css/{themes → palettes}/high-contrast.class.css +31 -31
  20. package/css/palettes/high-contrast.class.css.map +1 -0
  21. package/css/palettes/high-contrast.system.css.map +1 -0
  22. package/directives/control-value-accessors/boolean-value-accessor.d.ts +1 -1
  23. package/directives/control-value-accessors/numeric-value-accessor.d.ts +1 -1
  24. package/directives/control-value-accessors/select-value-accessor.d.ts +1 -1
  25. package/directives/control-value-accessors/text-value-accessor.d.ts +1 -1
  26. package/directives/navigation/ion-back-button.d.ts +1 -1
  27. package/directives/navigation/ion-nav.d.ts +1 -1
  28. package/directives/navigation/ion-router-outlet.d.ts +3 -3
  29. package/directives/navigation/ion-tabs.d.ts +1 -1
  30. package/directives/navigation/router-link-delegate.d.ts +2 -2
  31. package/directives/overlays/modal.d.ts +1 -1
  32. package/directives/overlays/popover.d.ts +1 -1
  33. package/directives/proxies.d.ts +80 -80
  34. package/directives/validators/max-validator.d.ts +1 -1
  35. package/directives/validators/min-validator.d.ts +1 -1
  36. package/esm2022/common/directives/control-value-accessors/value-accessor.mjs +145 -0
  37. package/esm2022/common/directives/navigation/back-button.mjs +61 -0
  38. package/esm2022/common/directives/navigation/nav-params.mjs +46 -0
  39. package/esm2022/common/directives/navigation/nav.mjs +49 -0
  40. package/esm2022/common/directives/navigation/router-link-delegate.mjs +123 -0
  41. package/esm2022/common/directives/navigation/router-outlet.mjs +480 -0
  42. package/esm2022/common/directives/navigation/stack-controller.mjs +280 -0
  43. package/esm2022/common/directives/navigation/tabs.mjs +174 -0
  44. package/esm2022/common/overlays/modal.mjs +91 -0
  45. package/esm2022/common/overlays/popover.mjs +83 -0
  46. package/esm2022/common/providers/angular-delegate.mjs +155 -0
  47. package/{esm2020 → esm2022}/common/providers/config.mjs +4 -4
  48. package/{esm2020 → esm2022}/common/providers/dom-controller.mjs +4 -4
  49. package/esm2022/common/providers/menu-controller.mjs +114 -0
  50. package/esm2022/common/providers/nav-controller.mjs +227 -0
  51. package/esm2022/common/providers/platform.mjs +257 -0
  52. package/esm2022/common/utils/overlay.mjs +26 -0
  53. package/esm2022/directives/control-value-accessors/boolean-value-accessor.mjs +41 -0
  54. package/esm2022/directives/control-value-accessors/numeric-value-accessor.mjs +49 -0
  55. package/esm2022/directives/control-value-accessors/select-value-accessor.mjs +38 -0
  56. package/esm2022/directives/control-value-accessors/text-value-accessor.mjs +37 -0
  57. package/{esm2020 → esm2022}/directives/navigation/ion-back-button.mjs +4 -4
  58. package/{esm2020 → esm2022}/directives/navigation/ion-nav.mjs +4 -4
  59. package/esm2022/directives/navigation/ion-router-outlet.mjs +52 -0
  60. package/esm2022/directives/navigation/ion-tabs.mjs +50 -0
  61. package/{esm2020 → esm2022}/directives/navigation/router-link-delegate.mjs +7 -7
  62. package/{esm2020 → esm2022}/directives/overlays/modal.mjs +5 -5
  63. package/{esm2020 → esm2022}/directives/overlays/popover.mjs +4 -4
  64. package/esm2022/directives/proxies.mjs +2207 -0
  65. package/{esm2020 → esm2022}/directives/validators/max-validator.mjs +4 -4
  66. package/{esm2020 → esm2022}/directives/validators/min-validator.mjs +4 -4
  67. package/{esm2020 → esm2022}/ionic-module.mjs +41 -41
  68. package/{esm2020 → esm2022}/providers/action-sheet-controller.mjs +4 -4
  69. package/{esm2020 → esm2022}/providers/alert-controller.mjs +4 -4
  70. package/{esm2020 → esm2022}/providers/animation-controller.mjs +4 -4
  71. package/esm2022/providers/gesture-controller.mjs +32 -0
  72. package/{esm2020 → esm2022}/providers/loading-controller.mjs +4 -4
  73. package/{esm2020 → esm2022}/providers/menu-controller.mjs +4 -4
  74. package/esm2022/providers/modal-controller.mjs +24 -0
  75. package/{esm2020 → esm2022}/providers/picker-controller.mjs +4 -4
  76. package/esm2022/providers/popover-controller.mjs +18 -0
  77. package/{esm2020 → esm2022}/providers/toast-controller.mjs +4 -4
  78. package/esm2022/standalone/directives/checkbox.mjs +74 -0
  79. package/esm2022/standalone/directives/datetime.mjs +93 -0
  80. package/esm2022/standalone/directives/icon.mjs +35 -0
  81. package/esm2022/standalone/directives/input.mjs +113 -0
  82. package/esm2022/standalone/directives/proxies.mjs +2108 -0
  83. package/esm2022/standalone/directives/radio-group.mjs +60 -0
  84. package/esm2022/standalone/directives/range.mjs +78 -0
  85. package/esm2022/standalone/directives/searchbar.mjs +82 -0
  86. package/esm2022/standalone/directives/segment.mjs +60 -0
  87. package/esm2022/standalone/directives/select.mjs +82 -0
  88. package/esm2022/standalone/directives/textarea.mjs +91 -0
  89. package/esm2022/standalone/directives/toggle.mjs +74 -0
  90. package/esm2022/standalone/navigation/back-button.mjs +32 -0
  91. package/esm2022/standalone/navigation/nav.mjs +28 -0
  92. package/{esm2020 → esm2022}/standalone/navigation/router-link-delegate.mjs +7 -7
  93. package/esm2022/standalone/navigation/router-outlet.mjs +60 -0
  94. package/esm2022/standalone/navigation/tabs.mjs +49 -0
  95. package/esm2022/standalone/overlays/modal.mjs +32 -0
  96. package/{esm2020 → esm2022}/standalone/overlays/popover.mjs +4 -4
  97. package/{esm2020 → esm2022}/standalone/providers/action-sheet-controller.mjs +4 -4
  98. package/{esm2020 → esm2022}/standalone/providers/alert-controller.mjs +4 -4
  99. package/{esm2020 → esm2022}/standalone/providers/animation-controller.mjs +4 -4
  100. package/esm2022/standalone/providers/gesture-controller.mjs +32 -0
  101. package/esm2022/standalone/providers/ionic-angular.mjs +38 -0
  102. package/{esm2020 → esm2022}/standalone/providers/loading-controller.mjs +4 -4
  103. package/{esm2020 → esm2022}/standalone/providers/menu-controller.mjs +4 -4
  104. package/esm2022/standalone/providers/modal-controller.mjs +26 -0
  105. package/{esm2020 → esm2022}/standalone/providers/picker-controller.mjs +4 -4
  106. package/esm2022/standalone/providers/popover-controller.mjs +20 -0
  107. package/{esm2020 → esm2022}/standalone/providers/toast-controller.mjs +4 -4
  108. package/{fesm2020 → fesm2022}/ionic-angular-common.mjs +221 -156
  109. package/fesm2022/ionic-angular-common.mjs.map +1 -0
  110. package/{fesm2020 → fesm2022}/ionic-angular-standalone.mjs +481 -312
  111. package/fesm2022/ionic-angular-standalone.mjs.map +1 -0
  112. package/{fesm2020 → fesm2022}/ionic-angular.mjs +565 -390
  113. package/fesm2022/ionic-angular.mjs.map +1 -0
  114. package/package.json +16 -26
  115. package/schematics/utils/config.js +0 -1
  116. package/standalone/directives/checkbox.d.ts +1 -1
  117. package/standalone/directives/datetime.d.ts +1 -1
  118. package/standalone/directives/icon.d.ts +1 -1
  119. package/standalone/directives/input.d.ts +1 -1
  120. package/standalone/directives/proxies.d.ts +69 -69
  121. package/standalone/directives/radio-group.d.ts +1 -1
  122. package/standalone/directives/range.d.ts +1 -1
  123. package/standalone/directives/searchbar.d.ts +1 -1
  124. package/standalone/directives/segment.d.ts +1 -1
  125. package/standalone/directives/select.d.ts +1 -1
  126. package/standalone/directives/textarea.d.ts +1 -1
  127. package/standalone/directives/toggle.d.ts +1 -1
  128. package/standalone/navigation/back-button.d.ts +1 -1
  129. package/standalone/navigation/nav.d.ts +1 -1
  130. package/standalone/navigation/router-link-delegate.d.ts +2 -2
  131. package/standalone/navigation/router-outlet.d.ts +3 -3
  132. package/standalone/navigation/tabs.d.ts +1 -1
  133. package/standalone/overlays/modal.d.ts +1 -1
  134. package/standalone/overlays/popover.d.ts +1 -1
  135. package/standalone/providers/ionic-angular.d.ts +2 -2
  136. package/css/themes/dark.always.css.map +0 -1
  137. package/css/themes/dark.class.css.map +0 -1
  138. package/css/themes/dark.system.css.map +0 -1
  139. package/css/themes/high-contrast-dark.always.css.map +0 -1
  140. package/css/themes/high-contrast-dark.class.css.map +0 -1
  141. package/css/themes/high-contrast-dark.system.css.map +0 -1
  142. package/css/themes/high-contrast.always.css.map +0 -1
  143. package/css/themes/high-contrast.class.css.map +0 -1
  144. package/css/themes/high-contrast.system.css.map +0 -1
  145. package/esm2020/common/directives/control-value-accessors/value-accessor.mjs +0 -141
  146. package/esm2020/common/directives/navigation/back-button.mjs +0 -59
  147. package/esm2020/common/directives/navigation/nav-params.mjs +0 -45
  148. package/esm2020/common/directives/navigation/nav.mjs +0 -47
  149. package/esm2020/common/directives/navigation/router-link-delegate.mjs +0 -111
  150. package/esm2020/common/directives/navigation/router-outlet.mjs +0 -470
  151. package/esm2020/common/directives/navigation/stack-controller.mjs +0 -272
  152. package/esm2020/common/directives/navigation/tabs.mjs +0 -172
  153. package/esm2020/common/overlays/modal.mjs +0 -87
  154. package/esm2020/common/overlays/popover.mjs +0 -79
  155. package/esm2020/common/providers/angular-delegate.mjs +0 -152
  156. package/esm2020/common/providers/menu-controller.mjs +0 -113
  157. package/esm2020/common/providers/nav-controller.mjs +0 -221
  158. package/esm2020/common/providers/platform.mjs +0 -254
  159. package/esm2020/common/utils/overlay.mjs +0 -25
  160. package/esm2020/directives/control-value-accessors/boolean-value-accessor.mjs +0 -41
  161. package/esm2020/directives/control-value-accessors/numeric-value-accessor.mjs +0 -48
  162. package/esm2020/directives/control-value-accessors/select-value-accessor.mjs +0 -38
  163. package/esm2020/directives/control-value-accessors/text-value-accessor.mjs +0 -37
  164. package/esm2020/directives/navigation/ion-router-outlet.mjs +0 -43
  165. package/esm2020/directives/navigation/ion-tabs.mjs +0 -47
  166. package/esm2020/directives/proxies.mjs +0 -2047
  167. package/esm2020/providers/gesture-controller.mjs +0 -31
  168. package/esm2020/providers/modal-controller.mjs +0 -24
  169. package/esm2020/providers/popover-controller.mjs +0 -18
  170. package/esm2020/standalone/directives/checkbox.mjs +0 -72
  171. package/esm2020/standalone/directives/datetime.mjs +0 -91
  172. package/esm2020/standalone/directives/icon.mjs +0 -33
  173. package/esm2020/standalone/directives/input.mjs +0 -111
  174. package/esm2020/standalone/directives/proxies.mjs +0 -1970
  175. package/esm2020/standalone/directives/radio-group.mjs +0 -58
  176. package/esm2020/standalone/directives/range.mjs +0 -76
  177. package/esm2020/standalone/directives/searchbar.mjs +0 -80
  178. package/esm2020/standalone/directives/segment.mjs +0 -58
  179. package/esm2020/standalone/directives/select.mjs +0 -80
  180. package/esm2020/standalone/directives/textarea.mjs +0 -89
  181. package/esm2020/standalone/directives/toggle.mjs +0 -72
  182. package/esm2020/standalone/navigation/back-button.mjs +0 -32
  183. package/esm2020/standalone/navigation/nav.mjs +0 -28
  184. package/esm2020/standalone/navigation/router-outlet.mjs +0 -51
  185. package/esm2020/standalone/navigation/tabs.mjs +0 -46
  186. package/esm2020/standalone/overlays/modal.mjs +0 -32
  187. package/esm2020/standalone/providers/gesture-controller.mjs +0 -31
  188. package/esm2020/standalone/providers/ionic-angular.mjs +0 -43
  189. package/esm2020/standalone/providers/modal-controller.mjs +0 -26
  190. package/esm2020/standalone/providers/popover-controller.mjs +0 -20
  191. package/fesm2015/ionic-angular-common.mjs +0 -2484
  192. package/fesm2015/ionic-angular-common.mjs.map +0 -1
  193. package/fesm2015/ionic-angular-standalone.mjs +0 -3146
  194. package/fesm2015/ionic-angular-standalone.mjs.map +0 -1
  195. package/fesm2015/ionic-angular.mjs +0 -2790
  196. package/fesm2015/ionic-angular.mjs.map +0 -1
  197. package/fesm2020/ionic-angular-common.mjs.map +0 -1
  198. package/fesm2020/ionic-angular-standalone.mjs.map +0 -1
  199. package/fesm2020/ionic-angular.mjs.map +0 -1
  200. package/test/README.md +0 -118
  201. package/css/{themes → palettes}/dark.always.css +0 -0
  202. package/css/{themes → palettes}/dark.css +0 -0
  203. package/css/{themes → palettes}/dark.css.map +0 -0
  204. package/css/{themes → palettes}/dark.system.css +0 -0
  205. package/css/{themes → palettes}/high-contrast-dark.always.css +1 -1
  206. package/css/{themes → palettes}/high-contrast-dark.css +0 -0
  207. package/css/{themes → palettes}/high-contrast-dark.css.map +0 -0
  208. package/css/{themes → palettes}/high-contrast-dark.system.css +1 -1
  209. package/css/{themes → palettes}/high-contrast.always.css +25 -25
  210. package/css/{themes → palettes}/high-contrast.css +0 -0
  211. package/css/{themes → palettes}/high-contrast.css.map +0 -0
  212. package/css/{themes → palettes}/high-contrast.system.css +25 -25
  213. /package/{esm2020 → esm2022}/app-initialize.mjs +0 -0
  214. /package/{esm2020 → esm2022}/common/directives/control-value-accessors/index.mjs +0 -0
  215. /package/{esm2020 → esm2022}/common/directives/navigation/stack-utils.mjs +0 -0
  216. /package/{esm2020 → esm2022}/common/index.mjs +0 -0
  217. /package/{esm2020 → esm2022}/common/ionic-angular-common.mjs +0 -0
  218. /package/{esm2020 → esm2022}/common/types/interfaces.mjs +0 -0
  219. /package/{esm2020 → esm2022}/common/types/ionic-lifecycle-hooks.mjs +0 -0
  220. /package/{esm2020 → esm2022}/common/utils/proxy.mjs +0 -0
  221. /package/{esm2020 → esm2022}/common/utils/routing.mjs +0 -0
  222. /package/{esm2020 → esm2022}/common/utils/util.mjs +0 -0
  223. /package/{esm2020 → esm2022}/directives/angular-component-lib/utils.mjs +0 -0
  224. /package/{esm2020 → esm2022}/directives/control-value-accessors/index.mjs +0 -0
  225. /package/{esm2020 → esm2022}/directives/proxies-list.mjs +0 -0
  226. /package/{esm2020 → esm2022}/directives/validators/index.mjs +0 -0
  227. /package/{esm2020 → esm2022}/index.mjs +0 -0
  228. /package/{esm2020 → esm2022}/ionic-angular.mjs +0 -0
  229. /package/{esm2020 → esm2022}/standalone/directives/angular-component-lib/utils.mjs +0 -0
  230. /package/{esm2020 → esm2022}/standalone/directives/index.mjs +0 -0
  231. /package/{esm2020 → esm2022}/standalone/index.mjs +0 -0
  232. /package/{esm2020 → esm2022}/standalone/ionic-angular-standalone.mjs +0 -0
@@ -1,2484 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Inject, Optional, InjectionToken, inject, NgZone, ApplicationRef, Injector, createComponent, TemplateRef, Directive, ContentChild, EventEmitter, ViewContainerRef, EnvironmentInjector, Attribute, SkipSelf, Input, Output, reflectComponentType, HostListener, ElementRef, ViewChild } from '@angular/core';
3
- import { __awaiter, __decorate } from 'tslib';
4
- import * as i3 from '@angular/router';
5
- import { NavigationStart, PRIMARY_OUTLET, ChildrenOutletContexts, ActivatedRoute, Router } from '@angular/router';
6
- import * as i1 from '@angular/common';
7
- import { DOCUMENT } from '@angular/common';
8
- import { isPlatform, getPlatforms, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_UNLOAD, componentOnReady } from '@ionic/core/components';
9
- import { Subject, fromEvent, BehaviorSubject, combineLatest, of } from 'rxjs';
10
- import { filter, switchMap, distinctUntilChanged } from 'rxjs/operators';
11
- import { NgControl } from '@angular/forms';
12
-
13
- class MenuController {
14
- constructor(menuController) {
15
- this.menuController = menuController;
16
- }
17
- /**
18
- * Programmatically open the Menu.
19
- * @param [menuId] Optionally get the menu by its id, or side.
20
- * @return returns a promise when the menu is fully opened
21
- */
22
- open(menuId) {
23
- return this.menuController.open(menuId);
24
- }
25
- /**
26
- * Programmatically close the Menu. If no `menuId` is given as the first
27
- * argument then it'll close any menu which is open. If a `menuId`
28
- * is given then it'll close that exact menu.
29
- * @param [menuId] Optionally get the menu by its id, or side.
30
- * @return returns a promise when the menu is fully closed
31
- */
32
- close(menuId) {
33
- return this.menuController.close(menuId);
34
- }
35
- /**
36
- * Toggle the menu. If it's closed, it will open, and if opened, it
37
- * will close.
38
- * @param [menuId] Optionally get the menu by its id, or side.
39
- * @return returns a promise when the menu has been toggled
40
- */
41
- toggle(menuId) {
42
- return this.menuController.toggle(menuId);
43
- }
44
- /**
45
- * Used to enable or disable a menu. For example, there could be multiple
46
- * left menus, but only one of them should be able to be opened at the same
47
- * time. If there are multiple menus on the same side, then enabling one menu
48
- * will also automatically disable all the others that are on the same side.
49
- * @param [menuId] Optionally get the menu by its id, or side.
50
- * @return Returns the instance of the menu, which is useful for chaining.
51
- */
52
- enable(shouldEnable, menuId) {
53
- return this.menuController.enable(shouldEnable, menuId);
54
- }
55
- /**
56
- * Used to enable or disable the ability to swipe open the menu.
57
- * @param shouldEnable True if it should be swipe-able, false if not.
58
- * @param [menuId] Optionally get the menu by its id, or side.
59
- * @return Returns the instance of the menu, which is useful for chaining.
60
- */
61
- swipeGesture(shouldEnable, menuId) {
62
- return this.menuController.swipeGesture(shouldEnable, menuId);
63
- }
64
- /**
65
- * @param [menuId] Optionally get the menu by its id, or side.
66
- * @return Returns true if the specified menu is currently open, otherwise false.
67
- * If the menuId is not specified, it returns true if ANY menu is currenly open.
68
- */
69
- isOpen(menuId) {
70
- return this.menuController.isOpen(menuId);
71
- }
72
- /**
73
- * @param [menuId] Optionally get the menu by its id, or side.
74
- * @return Returns true if the menu is currently enabled, otherwise false.
75
- */
76
- isEnabled(menuId) {
77
- return this.menuController.isEnabled(menuId);
78
- }
79
- /**
80
- * Used to get a menu instance. If a `menuId` is not provided then it'll
81
- * return the first menu found. If a `menuId` is `left` or `right`, then
82
- * it'll return the enabled menu on that side. Otherwise, if a `menuId` is
83
- * provided, then it'll try to find the menu using the menu's `id`
84
- * property. If a menu is not found then it'll return `null`.
85
- * @param [menuId] Optionally get the menu by its id, or side.
86
- * @return Returns the instance of the menu if found, otherwise `null`.
87
- */
88
- get(menuId) {
89
- return this.menuController.get(menuId);
90
- }
91
- /**
92
- * @return Returns the instance of the menu already opened, otherwise `null`.
93
- */
94
- getOpen() {
95
- return this.menuController.getOpen();
96
- }
97
- /**
98
- * @return Returns an array of all menu instances.
99
- */
100
- getMenus() {
101
- return this.menuController.getMenus();
102
- }
103
- registerAnimation(name, animation) {
104
- return this.menuController.registerAnimation(name, animation);
105
- }
106
- isAnimating() {
107
- return this.menuController.isAnimating();
108
- }
109
- _getOpenSync() {
110
- return this.menuController._getOpenSync();
111
- }
112
- _createAnimation(type, menuCmp) {
113
- return this.menuController._createAnimation(type, menuCmp);
114
- }
115
- _register(menu) {
116
- return this.menuController._register(menu);
117
- }
118
- _unregister(menu) {
119
- return this.menuController._unregister(menu);
120
- }
121
- _setOpen(menu, shouldOpen, animated) {
122
- return this.menuController._setOpen(menu, shouldOpen, animated);
123
- }
124
- }
125
-
126
- class DomController {
127
- /**
128
- * Schedules a task to run during the READ phase of the next frame.
129
- * This task should only read the DOM, but never modify it.
130
- */
131
- read(cb) {
132
- getQueue().read(cb);
133
- }
134
- /**
135
- * Schedules a task to run during the WRITE phase of the next frame.
136
- * This task should write the DOM, but never READ it.
137
- */
138
- write(cb) {
139
- getQueue().write(cb);
140
- }
141
- }
142
- /** @nocollapse */ DomController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
143
- /** @nocollapse */ DomController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, providedIn: 'root' });
144
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: DomController, decorators: [{
145
- type: Injectable,
146
- args: [{
147
- providedIn: 'root',
148
- }]
149
- }] });
150
- const getQueue = () => {
151
- const win = typeof window !== 'undefined' ? window : null;
152
- if (win != null) {
153
- const Ionic = win.Ionic;
154
- if (Ionic === null || Ionic === void 0 ? void 0 : Ionic.queue) {
155
- return Ionic.queue;
156
- }
157
- return {
158
- read: (cb) => win.requestAnimationFrame(cb),
159
- write: (cb) => win.requestAnimationFrame(cb),
160
- };
161
- }
162
- return {
163
- read: (cb) => cb(),
164
- write: (cb) => cb(),
165
- };
166
- };
167
-
168
- class Platform {
169
- constructor(doc, zone) {
170
- this.doc = doc;
171
- /**
172
- * @hidden
173
- */
174
- this.backButton = new Subject();
175
- /**
176
- * The keyboardDidShow event emits when the
177
- * on-screen keyboard is presented.
178
- */
179
- this.keyboardDidShow = new Subject();
180
- /**
181
- * The keyboardDidHide event emits when the
182
- * on-screen keyboard is hidden.
183
- */
184
- this.keyboardDidHide = new Subject();
185
- /**
186
- * The pause event emits when the native platform puts the application
187
- * into the background, typically when the user switches to a different
188
- * application. This event would emit when a Cordova app is put into
189
- * the background, however, it would not fire on a standard web browser.
190
- */
191
- this.pause = new Subject();
192
- /**
193
- * The resume event emits when the native platform pulls the application
194
- * out from the background. This event would emit when a Cordova app comes
195
- * out from the background, however, it would not fire on a standard web browser.
196
- */
197
- this.resume = new Subject();
198
- /**
199
- * The resize event emits when the browser window has changed dimensions. This
200
- * could be from a browser window being physically resized, or from a device
201
- * changing orientation.
202
- */
203
- this.resize = new Subject();
204
- zone.run(() => {
205
- var _a;
206
- this.win = doc.defaultView;
207
- this.backButton.subscribeWithPriority = function (priority, callback) {
208
- return this.subscribe((ev) => {
209
- return ev.register(priority, (processNextHandler) => zone.run(() => callback(processNextHandler)));
210
- });
211
- };
212
- proxyEvent(this.pause, doc, 'pause', zone);
213
- proxyEvent(this.resume, doc, 'resume', zone);
214
- proxyEvent(this.backButton, doc, 'ionBackButton', zone);
215
- proxyEvent(this.resize, this.win, 'resize', zone);
216
- proxyEvent(this.keyboardDidShow, this.win, 'ionKeyboardDidShow', zone);
217
- proxyEvent(this.keyboardDidHide, this.win, 'ionKeyboardDidHide', zone);
218
- let readyResolve;
219
- this._readyPromise = new Promise((res) => {
220
- readyResolve = res;
221
- });
222
- if ((_a = this.win) === null || _a === void 0 ? void 0 : _a['cordova']) {
223
- doc.addEventListener('deviceready', () => {
224
- readyResolve('cordova');
225
- }, { once: true });
226
- }
227
- else {
228
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
229
- readyResolve('dom');
230
- }
231
- });
232
- }
233
- /**
234
- * @returns returns true/false based on platform.
235
- * @description
236
- * Depending on the platform the user is on, `is(platformName)` will
237
- * return `true` or `false`. Note that the same app can return `true`
238
- * for more than one platform name. For example, an app running from
239
- * an iPad would return `true` for the platform names: `mobile`,
240
- * `ios`, `ipad`, and `tablet`. Additionally, if the app was running
241
- * from Cordova then `cordova` would be true, and if it was running
242
- * from a web browser on the iPad then `mobileweb` would be `true`.
243
- *
244
- * ```
245
- * import { Platform } from 'ionic-angular';
246
- *
247
- * @Component({...})
248
- * export MyPage {
249
- * constructor(public platform: Platform) {
250
- * if (this.platform.is('ios')) {
251
- * // This will only print when on iOS
252
- * console.log('I am an iOS device!');
253
- * }
254
- * }
255
- * }
256
- * ```
257
- *
258
- * | Platform Name | Description |
259
- * |-----------------|------------------------------------|
260
- * | android | on a device running Android. |
261
- * | capacitor | on a device running Capacitor. |
262
- * | cordova | on a device running Cordova. |
263
- * | ios | on a device running iOS. |
264
- * | ipad | on an iPad device. |
265
- * | iphone | on an iPhone device. |
266
- * | phablet | on a phablet device. |
267
- * | tablet | on a tablet device. |
268
- * | electron | in Electron on a desktop device. |
269
- * | pwa | as a PWA app. |
270
- * | mobile | on a mobile device. |
271
- * | mobileweb | on a mobile device in a browser. |
272
- * | desktop | on a desktop device. |
273
- * | hybrid | is a cordova or capacitor app. |
274
- *
275
- */
276
- is(platformName) {
277
- return isPlatform(this.win, platformName);
278
- }
279
- /**
280
- * @returns the array of platforms
281
- * @description
282
- * Depending on what device you are on, `platforms` can return multiple values.
283
- * Each possible value is a hierarchy of platforms. For example, on an iPhone,
284
- * it would return `mobile`, `ios`, and `iphone`.
285
- *
286
- * ```
287
- * import { Platform } from 'ionic-angular';
288
- *
289
- * @Component({...})
290
- * export MyPage {
291
- * constructor(public platform: Platform) {
292
- * // This will print an array of the current platforms
293
- * console.log(this.platform.platforms());
294
- * }
295
- * }
296
- * ```
297
- */
298
- platforms() {
299
- return getPlatforms(this.win);
300
- }
301
- /**
302
- * Returns a promise when the platform is ready and native functionality
303
- * can be called. If the app is running from within a web browser, then
304
- * the promise will resolve when the DOM is ready. When the app is running
305
- * from an application engine such as Cordova, then the promise will
306
- * resolve when Cordova triggers the `deviceready` event.
307
- *
308
- * The resolved value is the `readySource`, which states which platform
309
- * ready was used. For example, when Cordova is ready, the resolved ready
310
- * source is `cordova`. The default ready source value will be `dom`. The
311
- * `readySource` is useful if different logic should run depending on the
312
- * platform the app is running from. For example, only Cordova can execute
313
- * the status bar plugin, so the web should not run status bar plugin logic.
314
- *
315
- * ```
316
- * import { Component } from '@angular/core';
317
- * import { Platform } from 'ionic-angular';
318
- *
319
- * @Component({...})
320
- * export MyApp {
321
- * constructor(public platform: Platform) {
322
- * this.platform.ready().then((readySource) => {
323
- * console.log('Platform ready from', readySource);
324
- * // Platform now ready, execute any required native code
325
- * });
326
- * }
327
- * }
328
- * ```
329
- */
330
- ready() {
331
- return this._readyPromise;
332
- }
333
- /**
334
- * Returns if this app is using right-to-left language direction or not.
335
- * We recommend the app's `index.html` file already has the correct `dir`
336
- * attribute value set, such as `<html dir="ltr">` or `<html dir="rtl">`.
337
- * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
338
- */
339
- get isRTL() {
340
- return this.doc.dir === 'rtl';
341
- }
342
- /**
343
- * Get the query string parameter
344
- */
345
- getQueryParam(key) {
346
- return readQueryParam(this.win.location.href, key);
347
- }
348
- /**
349
- * Returns `true` if the app is in landscape mode.
350
- */
351
- isLandscape() {
352
- return !this.isPortrait();
353
- }
354
- /**
355
- * Returns `true` if the app is in portrait mode.
356
- */
357
- isPortrait() {
358
- var _a, _b;
359
- return (_b = (_a = this.win).matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, '(orientation: portrait)').matches;
360
- }
361
- testUserAgent(expression) {
362
- const nav = this.win.navigator;
363
- return !!((nav === null || nav === void 0 ? void 0 : nav.userAgent) && nav.userAgent.indexOf(expression) >= 0);
364
- }
365
- /**
366
- * Get the current url.
367
- */
368
- url() {
369
- return this.win.location.href;
370
- }
371
- /**
372
- * Gets the width of the platform's viewport using `window.innerWidth`.
373
- */
374
- width() {
375
- return this.win.innerWidth;
376
- }
377
- /**
378
- * Gets the height of the platform's viewport using `window.innerHeight`.
379
- */
380
- height() {
381
- return this.win.innerHeight;
382
- }
383
- }
384
- /** @nocollapse */ Platform.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, deps: [{ token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
385
- /** @nocollapse */ Platform.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, providedIn: 'root' });
386
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Platform, decorators: [{
387
- type: Injectable,
388
- args: [{
389
- providedIn: 'root',
390
- }]
391
- }], ctorParameters: function () {
392
- return [{ type: undefined, decorators: [{
393
- type: Inject,
394
- args: [DOCUMENT]
395
- }] }, { type: i0.NgZone }];
396
- } });
397
- const readQueryParam = (url, key) => {
398
- key = key.replace(/[[\]\\]/g, '\\$&');
399
- const regex = new RegExp('[\\?&]' + key + '=([^&#]*)');
400
- const results = regex.exec(url);
401
- return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null;
402
- };
403
- const proxyEvent = (emitter, el, eventName, zone) => {
404
- if (el) {
405
- el.addEventListener(eventName, (ev) => {
406
- /**
407
- * `zone.run` is required to make sure that we are running inside the Angular zone
408
- * at all times. This is necessary since an app that has Capacitor will
409
- * override the `document.addEventListener` with its own implementation.
410
- * The override causes the event to no longer be in the Angular zone.
411
- */
412
- zone.run(() => {
413
- // ?? cordova might emit "null" events
414
- const value = ev != null ? ev.detail : undefined;
415
- emitter.next(value);
416
- });
417
- });
418
- }
419
- };
420
-
421
- class NavController {
422
- constructor(platform, location, serializer, router) {
423
- this.location = location;
424
- this.serializer = serializer;
425
- this.router = router;
426
- this.direction = DEFAULT_DIRECTION;
427
- this.animated = DEFAULT_ANIMATED;
428
- this.guessDirection = 'forward';
429
- this.lastNavId = -1;
430
- // Subscribe to router events to detect direction
431
- if (router) {
432
- router.events.subscribe((ev) => {
433
- if (ev instanceof NavigationStart) {
434
- // restoredState is set if the browser back/forward button is used
435
- const id = ev.restoredState ? ev.restoredState.navigationId : ev.id;
436
- this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward';
437
- this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
438
- }
439
- });
440
- }
441
- // Subscribe to backButton events
442
- platform.backButton.subscribeWithPriority(0, (processNextHandler) => {
443
- this.pop();
444
- processNextHandler();
445
- });
446
- }
447
- /**
448
- * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
449
- * it's equivalent to calling `this.router.navigateByUrl()`, but it's explicit about the **direction** of the transition.
450
- *
451
- * Going **forward** means that a new page is going to be pushed to the stack of the outlet (ion-router-outlet),
452
- * and that it will show a "forward" animation by default.
453
- *
454
- * Navigating forward can also be triggered in a declarative manner by using the `[routerDirection]` directive:
455
- *
456
- * ```html
457
- * <a routerLink="/path/to/page" routerDirection="forward">Link</a>
458
- * ```
459
- */
460
- navigateForward(url, options = {}) {
461
- this.setDirection('forward', options.animated, options.animationDirection, options.animation);
462
- return this.navigate(url, options);
463
- }
464
- /**
465
- * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
466
- * it's equivalent to calling:
467
- *
468
- * ```ts
469
- * this.navController.setDirection('back');
470
- * this.router.navigateByUrl(path);
471
- * ```
472
- *
473
- * Going **back** means that all the pages in the stack until the navigated page is found will be popped,
474
- * and that it will show a "back" animation by default.
475
- *
476
- * Navigating back can also be triggered in a declarative manner by using the `[routerDirection]` directive:
477
- *
478
- * ```html
479
- * <a routerLink="/path/to/page" routerDirection="back">Link</a>
480
- * ```
481
- */
482
- navigateBack(url, options = {}) {
483
- this.setDirection('back', options.animated, options.animationDirection, options.animation);
484
- return this.navigate(url, options);
485
- }
486
- /**
487
- * This method uses Angular's [Router](https://angular.io/api/router/Router) under the hood,
488
- * it's equivalent to calling:
489
- *
490
- * ```ts
491
- * this.navController.setDirection('root');
492
- * this.router.navigateByUrl(path);
493
- * ```
494
- *
495
- * Going **root** means that all existing pages in the stack will be removed,
496
- * and the navigated page will become the single page in the stack.
497
- *
498
- * Navigating root can also be triggered in a declarative manner by using the `[routerDirection]` directive:
499
- *
500
- * ```html
501
- * <a routerLink="/path/to/page" routerDirection="root">Link</a>
502
- * ```
503
- */
504
- navigateRoot(url, options = {}) {
505
- this.setDirection('root', options.animated, options.animationDirection, options.animation);
506
- return this.navigate(url, options);
507
- }
508
- /**
509
- * Same as [Location](https://angular.io/api/common/Location)'s back() method.
510
- * It will use the standard `window.history.back()` under the hood, but featuring a `back` animation
511
- * by default.
512
- */
513
- back(options = { animated: true, animationDirection: 'back' }) {
514
- this.setDirection('back', options.animated, options.animationDirection, options.animation);
515
- return this.location.back();
516
- }
517
- /**
518
- * This methods goes back in the context of Ionic's stack navigation.
519
- *
520
- * It recursively finds the top active `ion-router-outlet` and calls `pop()`.
521
- * This is the recommended way to go back when you are using `ion-router-outlet`.
522
- *
523
- * Resolves to `true` if it was able to pop.
524
- */
525
- pop() {
526
- return __awaiter(this, void 0, void 0, function* () {
527
- let outlet = this.topOutlet;
528
- while (outlet) {
529
- if (yield outlet.pop()) {
530
- return true;
531
- }
532
- else {
533
- outlet = outlet.parentOutlet;
534
- }
535
- }
536
- return false;
537
- });
538
- }
539
- /**
540
- * This methods specifies the direction of the next navigation performed by the Angular router.
541
- *
542
- * `setDirection()` does not trigger any transition, it just sets some flags to be consumed by `ion-router-outlet`.
543
- *
544
- * It's recommended to use `navigateForward()`, `navigateBack()` and `navigateRoot()` instead of `setDirection()`.
545
- */
546
- setDirection(direction, animated, animationDirection, animationBuilder) {
547
- this.direction = direction;
548
- this.animated = getAnimation(direction, animated, animationDirection);
549
- this.animationBuilder = animationBuilder;
550
- }
551
- /**
552
- * @internal
553
- */
554
- setTopOutlet(outlet) {
555
- this.topOutlet = outlet;
556
- }
557
- /**
558
- * @internal
559
- */
560
- consumeTransition() {
561
- let direction = 'root';
562
- let animation;
563
- const animationBuilder = this.animationBuilder;
564
- if (this.direction === 'auto') {
565
- direction = this.guessDirection;
566
- animation = this.guessAnimation;
567
- }
568
- else {
569
- animation = this.animated;
570
- direction = this.direction;
571
- }
572
- this.direction = DEFAULT_DIRECTION;
573
- this.animated = DEFAULT_ANIMATED;
574
- this.animationBuilder = undefined;
575
- return {
576
- direction,
577
- animation,
578
- animationBuilder,
579
- };
580
- }
581
- navigate(url, options) {
582
- if (Array.isArray(url)) {
583
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
584
- return this.router.navigate(url, options);
585
- }
586
- else {
587
- /**
588
- * navigateByUrl ignores any properties that
589
- * would change the url, so things like queryParams
590
- * would be ignored unless we create a url tree
591
- * More Info: https://github.com/angular/angular/issues/18798
592
- */
593
- const urlTree = this.serializer.parse(url.toString());
594
- if (options.queryParams !== undefined) {
595
- urlTree.queryParams = Object.assign({}, options.queryParams);
596
- }
597
- if (options.fragment !== undefined) {
598
- urlTree.fragment = options.fragment;
599
- }
600
- /**
601
- * `navigateByUrl` will still apply `NavigationExtras` properties
602
- * that do not modify the url, such as `replaceUrl` which is why
603
- * `options` is passed in here.
604
- */
605
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
606
- return this.router.navigateByUrl(urlTree, options);
607
- }
608
- }
609
- }
610
- /** @nocollapse */ NavController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, deps: [{ token: Platform }, { token: i1.Location }, { token: i3.UrlSerializer }, { token: i3.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
611
- /** @nocollapse */ NavController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, providedIn: 'root' });
612
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: NavController, decorators: [{
613
- type: Injectable,
614
- args: [{
615
- providedIn: 'root',
616
- }]
617
- }], ctorParameters: function () {
618
- return [{ type: Platform }, { type: i1.Location }, { type: i3.UrlSerializer }, { type: i3.Router, decorators: [{
619
- type: Optional
620
- }] }];
621
- } });
622
- const getAnimation = (direction, animated, animationDirection) => {
623
- if (animated === false) {
624
- return undefined;
625
- }
626
- if (animationDirection !== undefined) {
627
- return animationDirection;
628
- }
629
- if (direction === 'forward' || direction === 'back') {
630
- return direction;
631
- }
632
- else if (direction === 'root' && animated === true) {
633
- return 'forward';
634
- }
635
- return undefined;
636
- };
637
- const DEFAULT_DIRECTION = 'auto';
638
- const DEFAULT_ANIMATED = undefined;
639
-
640
- class Config {
641
- get(key, fallback) {
642
- const c = getConfig();
643
- if (c) {
644
- return c.get(key, fallback);
645
- }
646
- return null;
647
- }
648
- getBoolean(key, fallback) {
649
- const c = getConfig();
650
- if (c) {
651
- return c.getBoolean(key, fallback);
652
- }
653
- return false;
654
- }
655
- getNumber(key, fallback) {
656
- const c = getConfig();
657
- if (c) {
658
- return c.getNumber(key, fallback);
659
- }
660
- return 0;
661
- }
662
- }
663
- /** @nocollapse */ Config.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
664
- /** @nocollapse */ Config.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, providedIn: 'root' });
665
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: Config, decorators: [{
666
- type: Injectable,
667
- args: [{
668
- providedIn: 'root',
669
- }]
670
- }] });
671
- const ConfigToken = new InjectionToken('USERCONFIG');
672
- const getConfig = () => {
673
- if (typeof window !== 'undefined') {
674
- const Ionic = window.Ionic;
675
- if (Ionic === null || Ionic === void 0 ? void 0 : Ionic.config) {
676
- return Ionic.config;
677
- }
678
- }
679
- return null;
680
- };
681
-
682
- /**
683
- * @description
684
- * NavParams are an object that exists on a page and can contain data for that particular view.
685
- * Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
686
- * option with a simple `get` method.
687
- *
688
- * @usage
689
- * ```ts
690
- * import { NavParams } from '@ionic/angular';
691
- *
692
- * export class MyClass{
693
- *
694
- * constructor(navParams: NavParams){
695
- * // userParams is an object we have in our nav-parameters
696
- * navParams.get('userParams');
697
- * }
698
- *
699
- * }
700
- * ```
701
- */
702
- class NavParams {
703
- constructor(data = {}) {
704
- this.data = data;
705
- }
706
- /**
707
- * Get the value of a nav-parameter for the current view
708
- *
709
- * ```ts
710
- * import { NavParams } from 'ionic-angular';
711
- *
712
- * export class MyClass{
713
- * constructor(public navParams: NavParams){
714
- * // userParams is an object we have in our nav-parameters
715
- * this.navParams.get('userParams');
716
- * }
717
- * }
718
- * ```
719
- *
720
- * @param param Which param you want to look up
721
- */
722
- get(param) {
723
- return this.data[param];
724
- }
725
- }
726
-
727
- // TODO(FW-2827): types
728
- class AngularDelegate {
729
- constructor() {
730
- this.zone = inject(NgZone);
731
- this.applicationRef = inject(ApplicationRef);
732
- }
733
- create(environmentInjector, injector, elementReferenceKey) {
734
- return new AngularFrameworkDelegate(environmentInjector, injector, this.applicationRef, this.zone, elementReferenceKey);
735
- }
736
- }
737
- /** @nocollapse */ AngularDelegate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
738
- /** @nocollapse */ AngularDelegate.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate });
739
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: AngularDelegate, decorators: [{
740
- type: Injectable
741
- }] });
742
- class AngularFrameworkDelegate {
743
- constructor(environmentInjector, injector, applicationRef, zone, elementReferenceKey) {
744
- this.environmentInjector = environmentInjector;
745
- this.injector = injector;
746
- this.applicationRef = applicationRef;
747
- this.zone = zone;
748
- this.elementReferenceKey = elementReferenceKey;
749
- this.elRefMap = new WeakMap();
750
- this.elEventsMap = new WeakMap();
751
- }
752
- attachViewToDom(container, component, params, cssClasses) {
753
- return this.zone.run(() => {
754
- return new Promise((resolve) => {
755
- const componentProps = Object.assign({}, params);
756
- /**
757
- * Ionic Angular passes a reference to a modal
758
- * or popover that can be accessed using a
759
- * variable in the overlay component. If
760
- * elementReferenceKey is defined, then we should
761
- * pass a reference to the component using
762
- * elementReferenceKey as the key.
763
- */
764
- if (this.elementReferenceKey !== undefined) {
765
- componentProps[this.elementReferenceKey] = container;
766
- }
767
- const el = attachView(this.zone, this.environmentInjector, this.injector, this.applicationRef, this.elRefMap, this.elEventsMap, container, component, componentProps, cssClasses, this.elementReferenceKey);
768
- resolve(el);
769
- });
770
- });
771
- }
772
- removeViewFromDom(_container, component) {
773
- return this.zone.run(() => {
774
- return new Promise((resolve) => {
775
- const componentRef = this.elRefMap.get(component);
776
- if (componentRef) {
777
- componentRef.destroy();
778
- this.elRefMap.delete(component);
779
- const unbindEvents = this.elEventsMap.get(component);
780
- if (unbindEvents) {
781
- unbindEvents();
782
- this.elEventsMap.delete(component);
783
- }
784
- }
785
- resolve();
786
- });
787
- });
788
- }
789
- }
790
- const attachView = (zone, environmentInjector, injector, applicationRef, elRefMap, elEventsMap, container, component, params, cssClasses, elementReferenceKey) => {
791
- /**
792
- * Wraps the injector with a custom injector that
793
- * provides NavParams to the component.
794
- *
795
- * NavParams is a legacy feature from Ionic v3 that allows
796
- * Angular developers to provide data to a component
797
- * and access it by providing NavParams as a dependency
798
- * in the constructor.
799
- *
800
- * The modern approach is to access the data directly
801
- * from the component's class instance.
802
- */
803
- const childInjector = Injector.create({
804
- providers: getProviders(params),
805
- parent: injector,
806
- });
807
- const componentRef = createComponent(component, {
808
- environmentInjector,
809
- elementInjector: childInjector,
810
- });
811
- const instance = componentRef.instance;
812
- const hostElement = componentRef.location.nativeElement;
813
- if (params) {
814
- /**
815
- * For modals and popovers, a reference to the component is
816
- * added to `params` during the call to attachViewToDom. If
817
- * a reference using this name is already set, this means
818
- * the app is trying to use the name as a component prop,
819
- * which will cause collisions.
820
- */
821
- if (elementReferenceKey && instance[elementReferenceKey] !== undefined) {
822
- console.error(`[Ionic Error]: ${elementReferenceKey} is a reserved property when using ${container.tagName.toLowerCase()}. Rename or remove the "${elementReferenceKey}" property from ${component.name}.`);
823
- }
824
- Object.assign(instance, params);
825
- }
826
- if (cssClasses) {
827
- for (const cssClass of cssClasses) {
828
- hostElement.classList.add(cssClass);
829
- }
830
- }
831
- const unbindEvents = bindLifecycleEvents(zone, instance, hostElement);
832
- container.appendChild(hostElement);
833
- applicationRef.attachView(componentRef.hostView);
834
- elRefMap.set(hostElement, componentRef);
835
- elEventsMap.set(hostElement, unbindEvents);
836
- return hostElement;
837
- };
838
- const LIFECYCLES = [
839
- LIFECYCLE_WILL_ENTER,
840
- LIFECYCLE_DID_ENTER,
841
- LIFECYCLE_WILL_LEAVE,
842
- LIFECYCLE_DID_LEAVE,
843
- LIFECYCLE_WILL_UNLOAD,
844
- ];
845
- const bindLifecycleEvents = (zone, instance, element) => {
846
- return zone.run(() => {
847
- const unregisters = LIFECYCLES.filter((eventName) => typeof instance[eventName] === 'function').map((eventName) => {
848
- const handler = (ev) => instance[eventName](ev.detail);
849
- element.addEventListener(eventName, handler);
850
- return () => element.removeEventListener(eventName, handler);
851
- });
852
- return () => unregisters.forEach((fn) => fn());
853
- });
854
- };
855
- const NavParamsToken = new InjectionToken('NavParamsToken');
856
- const getProviders = (params) => {
857
- return [
858
- {
859
- provide: NavParamsToken,
860
- useValue: params,
861
- },
862
- {
863
- provide: NavParams,
864
- useFactory: provideNavParamsInjectable,
865
- deps: [NavParamsToken],
866
- },
867
- ];
868
- };
869
- const provideNavParamsInjectable = (params) => {
870
- return new NavParams(params);
871
- };
872
-
873
- // TODO: Is there a way we can grab this from angular-component-lib instead?
874
- const proxyInputs = (Cmp, inputs) => {
875
- const Prototype = Cmp.prototype;
876
- inputs.forEach((item) => {
877
- Object.defineProperty(Prototype, item, {
878
- get() {
879
- return this.el[item];
880
- },
881
- set(val) {
882
- this.z.runOutsideAngular(() => (this.el[item] = val));
883
- },
884
- });
885
- });
886
- };
887
- const proxyMethods = (Cmp, methods) => {
888
- const Prototype = Cmp.prototype;
889
- methods.forEach((methodName) => {
890
- Prototype[methodName] = function () {
891
- const args = arguments;
892
- return this.z.runOutsideAngular(() => this.el[methodName].apply(this.el, args));
893
- };
894
- });
895
- };
896
- const proxyOutputs = (instance, el, events) => {
897
- events.forEach((eventName) => (instance[eventName] = fromEvent(el, eventName)));
898
- };
899
- // tslint:disable-next-line: only-arrow-functions
900
- function ProxyCmp(opts) {
901
- const decorator = function (cls) {
902
- const { defineCustomElementFn, inputs, methods } = opts;
903
- if (defineCustomElementFn !== undefined) {
904
- defineCustomElementFn();
905
- }
906
- if (inputs) {
907
- proxyInputs(cls, inputs);
908
- }
909
- if (methods) {
910
- proxyMethods(cls, methods);
911
- }
912
- return cls;
913
- };
914
- return decorator;
915
- }
916
-
917
- const POPOVER_INPUTS = [
918
- 'alignment',
919
- 'animated',
920
- 'arrow',
921
- 'keepContentsMounted',
922
- 'backdropDismiss',
923
- 'cssClass',
924
- 'dismissOnSelect',
925
- 'enterAnimation',
926
- 'event',
927
- 'isOpen',
928
- 'keyboardClose',
929
- 'leaveAnimation',
930
- 'mode',
931
- 'showBackdrop',
932
- 'translucent',
933
- 'trigger',
934
- 'triggerAction',
935
- 'reference',
936
- 'size',
937
- 'side',
938
- ];
939
- const POPOVER_METHODS = ['present', 'dismiss', 'onDidDismiss', 'onWillDismiss'];
940
- let IonPopover = class IonPopover {
941
- constructor(c, r, z) {
942
- this.z = z;
943
- this.isCmpOpen = false;
944
- this.el = r.nativeElement;
945
- this.el.addEventListener('ionMount', () => {
946
- this.isCmpOpen = true;
947
- c.detectChanges();
948
- });
949
- this.el.addEventListener('didDismiss', () => {
950
- this.isCmpOpen = false;
951
- c.detectChanges();
952
- });
953
- proxyOutputs(this, this.el, [
954
- 'ionPopoverDidPresent',
955
- 'ionPopoverWillPresent',
956
- 'ionPopoverWillDismiss',
957
- 'ionPopoverDidDismiss',
958
- 'didPresent',
959
- 'willPresent',
960
- 'willDismiss',
961
- 'didDismiss',
962
- ]);
963
- }
964
- };
965
- /** @nocollapse */ IonPopover.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonPopover, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
966
- /** @nocollapse */ IonPopover.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonPopover, selector: "ion-popover", inputs: { alignment: "alignment", animated: "animated", arrow: "arrow", keepContentsMounted: "keepContentsMounted", backdropDismiss: "backdropDismiss", cssClass: "cssClass", dismissOnSelect: "dismissOnSelect", enterAnimation: "enterAnimation", event: "event", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger", triggerAction: "triggerAction", reference: "reference", size: "size", side: "side" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
967
- IonPopover = __decorate([
968
- ProxyCmp({
969
- inputs: POPOVER_INPUTS,
970
- methods: POPOVER_METHODS,
971
- })
972
- /**
973
- * @Component extends from @Directive
974
- * so by defining the inputs here we
975
- * do not need to re-define them for the
976
- * lazy loaded popover.
977
- */
978
- ], IonPopover);
979
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonPopover, decorators: [{
980
- type: Directive,
981
- args: [{
982
- selector: 'ion-popover',
983
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
984
- inputs: POPOVER_INPUTS,
985
- }]
986
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
987
- type: ContentChild,
988
- args: [TemplateRef, { static: false }]
989
- }] } });
990
-
991
- const MODAL_INPUTS = [
992
- 'animated',
993
- 'keepContentsMounted',
994
- 'backdropBreakpoint',
995
- 'backdropDismiss',
996
- 'breakpoints',
997
- 'canDismiss',
998
- 'cssClass',
999
- 'enterAnimation',
1000
- 'event',
1001
- 'handle',
1002
- 'handleBehavior',
1003
- 'initialBreakpoint',
1004
- 'isOpen',
1005
- 'keyboardClose',
1006
- 'leaveAnimation',
1007
- 'mode',
1008
- 'presentingElement',
1009
- 'showBackdrop',
1010
- 'translucent',
1011
- 'trigger',
1012
- ];
1013
- const MODAL_METHODS = [
1014
- 'present',
1015
- 'dismiss',
1016
- 'onDidDismiss',
1017
- 'onWillDismiss',
1018
- 'setCurrentBreakpoint',
1019
- 'getCurrentBreakpoint',
1020
- ];
1021
- let IonModal = class IonModal {
1022
- constructor(c, r, z) {
1023
- this.z = z;
1024
- this.isCmpOpen = false;
1025
- this.el = r.nativeElement;
1026
- this.el.addEventListener('ionMount', () => {
1027
- this.isCmpOpen = true;
1028
- c.detectChanges();
1029
- });
1030
- this.el.addEventListener('didDismiss', () => {
1031
- this.isCmpOpen = false;
1032
- c.detectChanges();
1033
- });
1034
- proxyOutputs(this, this.el, [
1035
- 'ionModalDidPresent',
1036
- 'ionModalWillPresent',
1037
- 'ionModalWillDismiss',
1038
- 'ionModalDidDismiss',
1039
- 'ionBreakpointDidChange',
1040
- 'didPresent',
1041
- 'willPresent',
1042
- 'willDismiss',
1043
- 'didDismiss',
1044
- ]);
1045
- }
1046
- };
1047
- /** @nocollapse */ IonModal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonModal, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1048
- /** @nocollapse */ IonModal.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonModal, selector: "ion-modal", inputs: { animated: "animated", keepContentsMounted: "keepContentsMounted", backdropBreakpoint: "backdropBreakpoint", backdropDismiss: "backdropDismiss", breakpoints: "breakpoints", canDismiss: "canDismiss", cssClass: "cssClass", enterAnimation: "enterAnimation", event: "event", handle: "handle", handleBehavior: "handleBehavior", initialBreakpoint: "initialBreakpoint", isOpen: "isOpen", keyboardClose: "keyboardClose", leaveAnimation: "leaveAnimation", mode: "mode", presentingElement: "presentingElement", showBackdrop: "showBackdrop", translucent: "translucent", trigger: "trigger" }, queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0 });
1049
- IonModal = __decorate([
1050
- ProxyCmp({
1051
- inputs: MODAL_INPUTS,
1052
- methods: MODAL_METHODS,
1053
- })
1054
- /**
1055
- * @Component extends from @Directive
1056
- * so by defining the inputs here we
1057
- * do not need to re-define them for the
1058
- * lazy loaded popover.
1059
- */
1060
- ], IonModal);
1061
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonModal, decorators: [{
1062
- type: Directive,
1063
- args: [{
1064
- selector: 'ion-modal',
1065
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1066
- inputs: MODAL_INPUTS,
1067
- }]
1068
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { template: [{
1069
- type: ContentChild,
1070
- args: [TemplateRef, { static: false }]
1071
- }] } });
1072
-
1073
- const insertView = (views, view, direction) => {
1074
- if (direction === 'root') {
1075
- return setRoot(views, view);
1076
- }
1077
- else if (direction === 'forward') {
1078
- return setForward(views, view);
1079
- }
1080
- else {
1081
- return setBack(views, view);
1082
- }
1083
- };
1084
- const setRoot = (views, view) => {
1085
- views = views.filter((v) => v.stackId !== view.stackId);
1086
- views.push(view);
1087
- return views;
1088
- };
1089
- const setForward = (views, view) => {
1090
- const index = views.indexOf(view);
1091
- if (index >= 0) {
1092
- views = views.filter((v) => v.stackId !== view.stackId || v.id <= view.id);
1093
- }
1094
- else {
1095
- views.push(view);
1096
- }
1097
- return views;
1098
- };
1099
- const setBack = (views, view) => {
1100
- const index = views.indexOf(view);
1101
- if (index >= 0) {
1102
- return views.filter((v) => v.stackId !== view.stackId || v.id <= view.id);
1103
- }
1104
- else {
1105
- return setRoot(views, view);
1106
- }
1107
- };
1108
- const getUrl = (router, activatedRoute) => {
1109
- const urlTree = router.createUrlTree(['.'], { relativeTo: activatedRoute });
1110
- return router.serializeUrl(urlTree);
1111
- };
1112
- const isTabSwitch = (enteringView, leavingView) => {
1113
- if (!leavingView) {
1114
- return true;
1115
- }
1116
- return enteringView.stackId !== leavingView.stackId;
1117
- };
1118
- const computeStackId = (prefixUrl, url) => {
1119
- if (!prefixUrl) {
1120
- return undefined;
1121
- }
1122
- const segments = toSegments(url);
1123
- for (let i = 0; i < segments.length; i++) {
1124
- if (i >= prefixUrl.length) {
1125
- return segments[i];
1126
- }
1127
- if (segments[i] !== prefixUrl[i]) {
1128
- return undefined;
1129
- }
1130
- }
1131
- return undefined;
1132
- };
1133
- const toSegments = (path) => {
1134
- return path
1135
- .split('/')
1136
- .map((s) => s.trim())
1137
- .filter((s) => s !== '');
1138
- };
1139
- const destroyView = (view) => {
1140
- if (view) {
1141
- view.ref.destroy();
1142
- view.unlistenEvents();
1143
- }
1144
- };
1145
-
1146
- // TODO(FW-2827): types
1147
- class StackController {
1148
- constructor(tabsPrefix, containerEl, router, navCtrl, zone, location) {
1149
- this.containerEl = containerEl;
1150
- this.router = router;
1151
- this.navCtrl = navCtrl;
1152
- this.zone = zone;
1153
- this.location = location;
1154
- this.views = [];
1155
- this.skipTransition = false;
1156
- this.nextId = 0;
1157
- this.tabsPrefix = tabsPrefix !== undefined ? toSegments(tabsPrefix) : undefined;
1158
- }
1159
- createView(ref, activatedRoute) {
1160
- var _a;
1161
- const url = getUrl(this.router, activatedRoute);
1162
- const element = (_a = ref === null || ref === void 0 ? void 0 : ref.location) === null || _a === void 0 ? void 0 : _a.nativeElement;
1163
- const unlistenEvents = bindLifecycleEvents(this.zone, ref.instance, element);
1164
- return {
1165
- id: this.nextId++,
1166
- stackId: computeStackId(this.tabsPrefix, url),
1167
- unlistenEvents,
1168
- element,
1169
- ref,
1170
- url,
1171
- };
1172
- }
1173
- getExistingView(activatedRoute) {
1174
- const activatedUrlKey = getUrl(this.router, activatedRoute);
1175
- const view = this.views.find((vw) => vw.url === activatedUrlKey);
1176
- if (view) {
1177
- view.ref.changeDetectorRef.reattach();
1178
- }
1179
- return view;
1180
- }
1181
- setActive(enteringView) {
1182
- var _a, _b;
1183
- const consumeResult = this.navCtrl.consumeTransition();
1184
- let { direction, animation, animationBuilder } = consumeResult;
1185
- const leavingView = this.activeView;
1186
- const tabSwitch = isTabSwitch(enteringView, leavingView);
1187
- if (tabSwitch) {
1188
- direction = 'back';
1189
- animation = undefined;
1190
- }
1191
- const viewsSnapshot = this.views.slice();
1192
- let currentNavigation;
1193
- const router = this.router;
1194
- // Angular >= 7.2.0
1195
- if (router.getCurrentNavigation) {
1196
- currentNavigation = router.getCurrentNavigation();
1197
- // Angular < 7.2.0
1198
- }
1199
- else if ((_a = router.navigations) === null || _a === void 0 ? void 0 : _a.value) {
1200
- currentNavigation = router.navigations.value;
1201
- }
1202
- /**
1203
- * If the navigation action
1204
- * sets `replaceUrl: true`
1205
- * then we need to make sure
1206
- * we remove the last item
1207
- * from our views stack
1208
- */
1209
- if ((_b = currentNavigation === null || currentNavigation === void 0 ? void 0 : currentNavigation.extras) === null || _b === void 0 ? void 0 : _b.replaceUrl) {
1210
- if (this.views.length > 0) {
1211
- this.views.splice(-1, 1);
1212
- }
1213
- }
1214
- const reused = this.views.includes(enteringView);
1215
- const views = this.insertView(enteringView, direction);
1216
- // Trigger change detection before transition starts
1217
- // This will call ngOnInit() the first time too, just after the view
1218
- // was attached to the dom, but BEFORE the transition starts
1219
- if (!reused) {
1220
- enteringView.ref.changeDetectorRef.detectChanges();
1221
- }
1222
- /**
1223
- * If we are going back from a page that
1224
- * was presented using a custom animation
1225
- * we should default to using that
1226
- * unless the developer explicitly
1227
- * provided another animation.
1228
- */
1229
- const customAnimation = enteringView.animationBuilder;
1230
- if (animationBuilder === undefined && direction === 'back' && !tabSwitch && customAnimation !== undefined) {
1231
- animationBuilder = customAnimation;
1232
- }
1233
- /**
1234
- * Save any custom animation so that navigating
1235
- * back will use this custom animation by default.
1236
- */
1237
- if (leavingView) {
1238
- leavingView.animationBuilder = animationBuilder;
1239
- }
1240
- // Wait until previous transitions finish
1241
- return this.zone.runOutsideAngular(() => {
1242
- return this.wait(() => {
1243
- // disconnect leaving page from change detection to
1244
- // reduce jank during the page transition
1245
- if (leavingView) {
1246
- leavingView.ref.changeDetectorRef.detach();
1247
- }
1248
- // In case the enteringView is the same as the leavingPage we need to reattach()
1249
- enteringView.ref.changeDetectorRef.reattach();
1250
- return this.transition(enteringView, leavingView, animation, this.canGoBack(1), false, animationBuilder)
1251
- .then(() => cleanupAsync(enteringView, views, viewsSnapshot, this.location, this.zone))
1252
- .then(() => ({
1253
- enteringView,
1254
- direction,
1255
- animation,
1256
- tabSwitch,
1257
- }));
1258
- });
1259
- });
1260
- }
1261
- canGoBack(deep, stackId = this.getActiveStackId()) {
1262
- return this.getStack(stackId).length > deep;
1263
- }
1264
- pop(deep, stackId = this.getActiveStackId()) {
1265
- return this.zone.run(() => {
1266
- var _a, _b;
1267
- const views = this.getStack(stackId);
1268
- if (views.length <= deep) {
1269
- return Promise.resolve(false);
1270
- }
1271
- const view = views[views.length - deep - 1];
1272
- let url = view.url;
1273
- const viewSavedData = view.savedData;
1274
- if (viewSavedData) {
1275
- const primaryOutlet = viewSavedData.get('primary');
1276
- if ((_b = (_a = primaryOutlet === null || primaryOutlet === void 0 ? void 0 : primaryOutlet.route) === null || _a === void 0 ? void 0 : _a._routerState) === null || _b === void 0 ? void 0 : _b.snapshot.url) {
1277
- url = primaryOutlet.route._routerState.snapshot.url;
1278
- }
1279
- }
1280
- const { animationBuilder } = this.navCtrl.consumeTransition();
1281
- return this.navCtrl.navigateBack(url, Object.assign(Object.assign({}, view.savedExtras), { animation: animationBuilder })).then(() => true);
1282
- });
1283
- }
1284
- startBackTransition() {
1285
- const leavingView = this.activeView;
1286
- if (leavingView) {
1287
- const views = this.getStack(leavingView.stackId);
1288
- const enteringView = views[views.length - 2];
1289
- const customAnimation = enteringView.animationBuilder;
1290
- return this.wait(() => {
1291
- return this.transition(enteringView, // entering view
1292
- leavingView, // leaving view
1293
- 'back', this.canGoBack(2), true, customAnimation);
1294
- });
1295
- }
1296
- return Promise.resolve();
1297
- }
1298
- endBackTransition(shouldComplete) {
1299
- if (shouldComplete) {
1300
- this.skipTransition = true;
1301
- this.pop(1);
1302
- }
1303
- else if (this.activeView) {
1304
- cleanup(this.activeView, this.views, this.views, this.location, this.zone);
1305
- }
1306
- }
1307
- getLastUrl(stackId) {
1308
- const views = this.getStack(stackId);
1309
- return views.length > 0 ? views[views.length - 1] : undefined;
1310
- }
1311
- /**
1312
- * @internal
1313
- */
1314
- getRootUrl(stackId) {
1315
- const views = this.getStack(stackId);
1316
- return views.length > 0 ? views[0] : undefined;
1317
- }
1318
- getActiveStackId() {
1319
- return this.activeView ? this.activeView.stackId : undefined;
1320
- }
1321
- /**
1322
- * @internal
1323
- */
1324
- getActiveView() {
1325
- return this.activeView;
1326
- }
1327
- hasRunningTask() {
1328
- return this.runningTask !== undefined;
1329
- }
1330
- destroy() {
1331
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1332
- this.containerEl = undefined;
1333
- this.views.forEach(destroyView);
1334
- this.activeView = undefined;
1335
- this.views = [];
1336
- }
1337
- getStack(stackId) {
1338
- return this.views.filter((v) => v.stackId === stackId);
1339
- }
1340
- insertView(enteringView, direction) {
1341
- this.activeView = enteringView;
1342
- this.views = insertView(this.views, enteringView, direction);
1343
- return this.views.slice();
1344
- }
1345
- transition(enteringView, leavingView, direction, showGoBack, progressAnimation, animationBuilder) {
1346
- if (this.skipTransition) {
1347
- this.skipTransition = false;
1348
- return Promise.resolve(false);
1349
- }
1350
- if (leavingView === enteringView) {
1351
- return Promise.resolve(false);
1352
- }
1353
- const enteringEl = enteringView ? enteringView.element : undefined;
1354
- const leavingEl = leavingView ? leavingView.element : undefined;
1355
- const containerEl = this.containerEl;
1356
- if (enteringEl && enteringEl !== leavingEl) {
1357
- enteringEl.classList.add('ion-page');
1358
- enteringEl.classList.add('ion-page-invisible');
1359
- if (containerEl.commit) {
1360
- return containerEl.commit(enteringEl, leavingEl, {
1361
- duration: direction === undefined ? 0 : undefined,
1362
- direction,
1363
- showGoBack,
1364
- progressAnimation,
1365
- animationBuilder,
1366
- });
1367
- }
1368
- }
1369
- return Promise.resolve(false);
1370
- }
1371
- wait(task) {
1372
- return __awaiter(this, void 0, void 0, function* () {
1373
- if (this.runningTask !== undefined) {
1374
- yield this.runningTask;
1375
- this.runningTask = undefined;
1376
- }
1377
- const promise = (this.runningTask = task());
1378
- promise.finally(() => (this.runningTask = undefined));
1379
- return promise;
1380
- });
1381
- }
1382
- }
1383
- const cleanupAsync = (activeRoute, views, viewsSnapshot, location, zone) => {
1384
- if (typeof requestAnimationFrame === 'function') {
1385
- return new Promise((resolve) => {
1386
- requestAnimationFrame(() => {
1387
- cleanup(activeRoute, views, viewsSnapshot, location, zone);
1388
- resolve();
1389
- });
1390
- });
1391
- }
1392
- return Promise.resolve();
1393
- };
1394
- const cleanup = (activeRoute, views, viewsSnapshot, location, zone) => {
1395
- /**
1396
- * Re-enter the Angular zone when destroying page components. This will allow
1397
- * lifecycle events (`ngOnDestroy`) to be run inside the Angular zone.
1398
- */
1399
- zone.run(() => viewsSnapshot.filter((view) => !views.includes(view)).forEach(destroyView));
1400
- views.forEach((view) => {
1401
- /**
1402
- * In the event that a user navigated multiple
1403
- * times in rapid succession, we want to make sure
1404
- * we don't pre-emptively detach a view while
1405
- * it is in mid-transition.
1406
- *
1407
- * In this instance we also do not care about query
1408
- * params or fragments as it will be the same view regardless
1409
- */
1410
- const locationWithoutParams = location.path().split('?')[0];
1411
- const locationWithoutFragment = locationWithoutParams.split('#')[0];
1412
- if (view !== activeRoute && view.url !== locationWithoutFragment) {
1413
- const element = view.element;
1414
- element.setAttribute('aria-hidden', 'true');
1415
- element.classList.add('ion-page-hidden');
1416
- view.ref.changeDetectorRef.detach();
1417
- }
1418
- });
1419
- };
1420
-
1421
- // TODO(FW-2827): types
1422
- // eslint-disable-next-line @angular-eslint/directive-class-suffix
1423
- class IonRouterOutlet {
1424
- constructor(name, tabs, commonLocation, elementRef, router, zone, activatedRoute, outletContent, parentOutlet) {
1425
- this.outletContent = outletContent;
1426
- this.parentOutlet = parentOutlet;
1427
- this.activatedView = null;
1428
- // Maintain map of activated route proxies for each component instance
1429
- this.proxyMap = new WeakMap();
1430
- // Keep the latest activated route in a subject for the proxy routes to switch map to
1431
- this.currentActivatedRoute$ = new BehaviorSubject(null);
1432
- this.activated = null;
1433
- this._activatedRoute = null;
1434
- /**
1435
- * The name of the outlet
1436
- */
1437
- this.name = PRIMARY_OUTLET;
1438
- /** @internal */
1439
- this.stackWillChange = new EventEmitter();
1440
- /** @internal */
1441
- this.stackDidChange = new EventEmitter();
1442
- // eslint-disable-next-line @angular-eslint/no-output-rename
1443
- this.activateEvents = new EventEmitter();
1444
- // eslint-disable-next-line @angular-eslint/no-output-rename
1445
- this.deactivateEvents = new EventEmitter();
1446
- this.parentContexts = inject(ChildrenOutletContexts);
1447
- this.location = inject(ViewContainerRef);
1448
- this.environmentInjector = inject(EnvironmentInjector);
1449
- this.inputBinder = inject(INPUT_BINDER, { optional: true });
1450
- /** @nodoc */
1451
- this.supportsBindingToComponentInputs = true;
1452
- // Ionic providers
1453
- this.config = inject(Config);
1454
- this.navCtrl = inject(NavController);
1455
- this.nativeEl = elementRef.nativeElement;
1456
- this.name = name || PRIMARY_OUTLET;
1457
- this.tabsPrefix = tabs === 'true' ? getUrl(router, activatedRoute) : undefined;
1458
- this.stackCtrl = new StackController(this.tabsPrefix, this.nativeEl, router, this.navCtrl, zone, commonLocation);
1459
- this.parentContexts.onChildOutletCreated(this.name, this);
1460
- }
1461
- /** @internal */
1462
- get activatedComponentRef() {
1463
- return this.activated;
1464
- }
1465
- set animation(animation) {
1466
- this.nativeEl.animation = animation;
1467
- }
1468
- set animated(animated) {
1469
- this.nativeEl.animated = animated;
1470
- }
1471
- set swipeGesture(swipe) {
1472
- this._swipeGesture = swipe;
1473
- this.nativeEl.swipeHandler = swipe
1474
- ? {
1475
- canStart: () => this.stackCtrl.canGoBack(1) && !this.stackCtrl.hasRunningTask(),
1476
- onStart: () => this.stackCtrl.startBackTransition(),
1477
- onEnd: (shouldContinue) => this.stackCtrl.endBackTransition(shouldContinue),
1478
- }
1479
- : undefined;
1480
- }
1481
- ngOnDestroy() {
1482
- var _a;
1483
- this.stackCtrl.destroy();
1484
- (_a = this.inputBinder) === null || _a === void 0 ? void 0 : _a.unsubscribeFromRouteData(this);
1485
- }
1486
- getContext() {
1487
- return this.parentContexts.getContext(this.name);
1488
- }
1489
- ngOnInit() {
1490
- this.initializeOutletWithName();
1491
- }
1492
- // Note: Ionic deviates from the Angular Router implementation here
1493
- initializeOutletWithName() {
1494
- if (!this.activated) {
1495
- // If the outlet was not instantiated at the time the route got activated we need to populate
1496
- // the outlet when it is initialized (ie inside a NgIf)
1497
- const context = this.getContext();
1498
- if (context === null || context === void 0 ? void 0 : context.route) {
1499
- this.activateWith(context.route, context.injector);
1500
- }
1501
- }
1502
- new Promise((resolve) => componentOnReady(this.nativeEl, resolve)).then(() => {
1503
- if (this._swipeGesture === undefined) {
1504
- this.swipeGesture = this.config.getBoolean('swipeBackEnabled', this.nativeEl.mode === 'ios');
1505
- }
1506
- });
1507
- }
1508
- get isActivated() {
1509
- return !!this.activated;
1510
- }
1511
- get component() {
1512
- if (!this.activated) {
1513
- throw new Error('Outlet is not activated');
1514
- }
1515
- return this.activated.instance;
1516
- }
1517
- get activatedRoute() {
1518
- if (!this.activated) {
1519
- throw new Error('Outlet is not activated');
1520
- }
1521
- return this._activatedRoute;
1522
- }
1523
- get activatedRouteData() {
1524
- if (this._activatedRoute) {
1525
- return this._activatedRoute.snapshot.data;
1526
- }
1527
- return {};
1528
- }
1529
- /**
1530
- * Called when the `RouteReuseStrategy` instructs to detach the subtree
1531
- */
1532
- detach() {
1533
- throw new Error('incompatible reuse strategy');
1534
- }
1535
- /**
1536
- * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
1537
- */
1538
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1539
- attach(_ref, _activatedRoute) {
1540
- throw new Error('incompatible reuse strategy');
1541
- }
1542
- deactivate() {
1543
- if (this.activated) {
1544
- if (this.activatedView) {
1545
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1546
- const context = this.getContext();
1547
- this.activatedView.savedData = new Map(context.children['contexts']);
1548
- /**
1549
- * Angular v11.2.10 introduced a change
1550
- * where this route context is cleared out when
1551
- * a router-outlet is deactivated, However,
1552
- * we need this route information in order to
1553
- * return a user back to the correct tab when
1554
- * leaving and then going back to the tab context.
1555
- */
1556
- const primaryOutlet = this.activatedView.savedData.get('primary');
1557
- if (primaryOutlet && context.route) {
1558
- primaryOutlet.route = Object.assign({}, context.route);
1559
- }
1560
- /**
1561
- * Ensure we are saving the NavigationExtras
1562
- * data otherwise it will be lost
1563
- */
1564
- this.activatedView.savedExtras = {};
1565
- if (context.route) {
1566
- const contextSnapshot = context.route.snapshot;
1567
- this.activatedView.savedExtras.queryParams = contextSnapshot.queryParams;
1568
- this.activatedView.savedExtras.fragment = contextSnapshot.fragment;
1569
- }
1570
- }
1571
- const c = this.component;
1572
- this.activatedView = null;
1573
- this.activated = null;
1574
- this._activatedRoute = null;
1575
- this.deactivateEvents.emit(c);
1576
- }
1577
- }
1578
- activateWith(activatedRoute, environmentInjector) {
1579
- var _a, _b;
1580
- if (this.isActivated) {
1581
- throw new Error('Cannot activate an already activated outlet');
1582
- }
1583
- this._activatedRoute = activatedRoute;
1584
- let cmpRef;
1585
- let enteringView = this.stackCtrl.getExistingView(activatedRoute);
1586
- if (enteringView) {
1587
- cmpRef = this.activated = enteringView.ref;
1588
- const saved = enteringView.savedData;
1589
- if (saved) {
1590
- // self-restore
1591
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1592
- const context = this.getContext();
1593
- context.children['contexts'] = saved;
1594
- }
1595
- // Updated activated route proxy for this component
1596
- this.updateActivatedRouteProxy(cmpRef.instance, activatedRoute);
1597
- }
1598
- else {
1599
- const snapshot = activatedRoute._futureSnapshot;
1600
- /**
1601
- * Angular 14 introduces a new `loadComponent` property to the route config.
1602
- * This function will assign a `component` property to the route snapshot.
1603
- * We check for the presence of this property to determine if the route is
1604
- * using standalone components.
1605
- */
1606
- const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
1607
- // We create an activated route proxy object that will maintain future updates for this component
1608
- // over its lifecycle in the stack.
1609
- const component$ = new BehaviorSubject(null);
1610
- const activatedRouteProxy = this.createActivatedRouteProxy(component$, activatedRoute);
1611
- const injector = new OutletInjector(activatedRouteProxy, childContexts, this.location.injector);
1612
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1613
- const component = (_a = snapshot.routeConfig.component) !== null && _a !== void 0 ? _a : snapshot.component;
1614
- /**
1615
- * View components need to be added as a child of ion-router-outlet
1616
- * for page transitions and swipe to go back.
1617
- * However, createComponent mounts components as siblings of the
1618
- * ViewContainerRef. As a result, outletContent must reference
1619
- * an ng-container inside of ion-router-outlet and not
1620
- * ion-router-outlet itself.
1621
- */
1622
- cmpRef = this.activated = this.outletContent.createComponent(component, {
1623
- index: this.outletContent.length,
1624
- injector,
1625
- environmentInjector: environmentInjector !== null && environmentInjector !== void 0 ? environmentInjector : this.environmentInjector,
1626
- });
1627
- // Once the component is created we can push it to our local subject supplied to the proxy
1628
- component$.next(cmpRef.instance);
1629
- // Calling `markForCheck` to make sure we will run the change detection when the
1630
- // `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
1631
- enteringView = this.stackCtrl.createView(this.activated, activatedRoute);
1632
- // Store references to the proxy by component
1633
- this.proxyMap.set(cmpRef.instance, activatedRouteProxy);
1634
- this.currentActivatedRoute$.next({ component: cmpRef.instance, activatedRoute });
1635
- }
1636
- (_b = this.inputBinder) === null || _b === void 0 ? void 0 : _b.bindActivatedRouteToOutletComponent(this);
1637
- this.activatedView = enteringView;
1638
- /**
1639
- * The top outlet is set prior to the entering view's transition completing,
1640
- * so that when we have nested outlets (e.g. ion-tabs inside an ion-router-outlet),
1641
- * the tabs outlet will be assigned as the top outlet when a view inside tabs is
1642
- * activated.
1643
- *
1644
- * In this scenario, activeWith is called for both the tabs and the root router outlet.
1645
- * To avoid a race condition, we assign the top outlet synchronously.
1646
- */
1647
- this.navCtrl.setTopOutlet(this);
1648
- const leavingView = this.stackCtrl.getActiveView();
1649
- this.stackWillChange.emit({
1650
- enteringView,
1651
- tabSwitch: isTabSwitch(enteringView, leavingView),
1652
- });
1653
- this.stackCtrl.setActive(enteringView).then((data) => {
1654
- this.activateEvents.emit(cmpRef.instance);
1655
- this.stackDidChange.emit(data);
1656
- });
1657
- }
1658
- /**
1659
- * Returns `true` if there are pages in the stack to go back.
1660
- */
1661
- canGoBack(deep = 1, stackId) {
1662
- return this.stackCtrl.canGoBack(deep, stackId);
1663
- }
1664
- /**
1665
- * Resolves to `true` if it the outlet was able to sucessfully pop the last N pages.
1666
- */
1667
- pop(deep = 1, stackId) {
1668
- return this.stackCtrl.pop(deep, stackId);
1669
- }
1670
- /**
1671
- * Returns the URL of the active page of each stack.
1672
- */
1673
- getLastUrl(stackId) {
1674
- const active = this.stackCtrl.getLastUrl(stackId);
1675
- return active ? active.url : undefined;
1676
- }
1677
- /**
1678
- * Returns the RouteView of the active page of each stack.
1679
- * @internal
1680
- */
1681
- getLastRouteView(stackId) {
1682
- return this.stackCtrl.getLastUrl(stackId);
1683
- }
1684
- /**
1685
- * Returns the root view in the tab stack.
1686
- * @internal
1687
- */
1688
- getRootView(stackId) {
1689
- return this.stackCtrl.getRootUrl(stackId);
1690
- }
1691
- /**
1692
- * Returns the active stack ID. In the context of ion-tabs, it means the active tab.
1693
- */
1694
- getActiveStackId() {
1695
- return this.stackCtrl.getActiveStackId();
1696
- }
1697
- /**
1698
- * Since the activated route can change over the life time of a component in an ion router outlet, we create
1699
- * a proxy so that we can update the values over time as a user navigates back to components already in the stack.
1700
- */
1701
- createActivatedRouteProxy(component$, activatedRoute) {
1702
- const proxy = new ActivatedRoute();
1703
- proxy._futureSnapshot = activatedRoute._futureSnapshot;
1704
- proxy._routerState = activatedRoute._routerState;
1705
- proxy.snapshot = activatedRoute.snapshot;
1706
- proxy.outlet = activatedRoute.outlet;
1707
- proxy.component = activatedRoute.component;
1708
- // Setup wrappers for the observables so consumers don't have to worry about switching to new observables as the state updates
1709
- proxy._paramMap = this.proxyObservable(component$, 'paramMap');
1710
- proxy._queryParamMap = this.proxyObservable(component$, 'queryParamMap');
1711
- proxy.url = this.proxyObservable(component$, 'url');
1712
- proxy.params = this.proxyObservable(component$, 'params');
1713
- proxy.queryParams = this.proxyObservable(component$, 'queryParams');
1714
- proxy.fragment = this.proxyObservable(component$, 'fragment');
1715
- proxy.data = this.proxyObservable(component$, 'data');
1716
- return proxy;
1717
- }
1718
- /**
1719
- * Create a wrapped observable that will switch to the latest activated route matched by the given component
1720
- */
1721
- proxyObservable(component$, path) {
1722
- return component$.pipe(
1723
- // First wait until the component instance is pushed
1724
- filter((component) => !!component), switchMap((component) => this.currentActivatedRoute$.pipe(filter((current) => current !== null && current.component === component), switchMap((current) => current && current.activatedRoute[path]), distinctUntilChanged())));
1725
- }
1726
- /**
1727
- * Updates the activated route proxy for the given component to the new incoming router state
1728
- */
1729
- updateActivatedRouteProxy(component, activatedRoute) {
1730
- const proxy = this.proxyMap.get(component);
1731
- if (!proxy) {
1732
- throw new Error(`Could not find activated route proxy for view`);
1733
- }
1734
- proxy._futureSnapshot = activatedRoute._futureSnapshot;
1735
- proxy._routerState = activatedRoute._routerState;
1736
- proxy.snapshot = activatedRoute.snapshot;
1737
- proxy.outlet = activatedRoute.outlet;
1738
- proxy.component = activatedRoute.component;
1739
- this.currentActivatedRoute$.next({ component, activatedRoute });
1740
- }
1741
- }
1742
- /** @nocollapse */ IonRouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonRouterOutlet, deps: [{ token: 'name', attribute: true }, { token: 'tabs', attribute: true, optional: true }, { token: i1.Location }, { token: i0.ElementRef }, { token: i3.Router }, { token: i0.NgZone }, { token: i3.ActivatedRoute }, { token: i0.ViewContainerRef }, { token: IonRouterOutlet, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
1743
- /** @nocollapse */ IonRouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonRouterOutlet, selector: "ion-router-outlet", inputs: { animated: "animated", animation: "animation", mode: "mode", swipeGesture: "swipeGesture", name: "name" }, outputs: { stackWillChange: "stackWillChange", stackDidChange: "stackDidChange", activateEvents: "activate", deactivateEvents: "deactivate" }, exportAs: ["outlet"], ngImport: i0 });
1744
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonRouterOutlet, decorators: [{
1745
- type: Directive,
1746
- args: [{
1747
- selector: 'ion-router-outlet',
1748
- exportAs: 'outlet',
1749
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1750
- inputs: ['animated', 'animation', 'mode', 'swipeGesture'],
1751
- }]
1752
- }], ctorParameters: function () {
1753
- return [{ type: undefined, decorators: [{
1754
- type: Attribute,
1755
- args: ['name']
1756
- }] }, { type: undefined, decorators: [{
1757
- type: Optional
1758
- }, {
1759
- type: Attribute,
1760
- args: ['tabs']
1761
- }] }, { type: i1.Location }, { type: i0.ElementRef }, { type: i3.Router }, { type: i0.NgZone }, { type: i3.ActivatedRoute }, { type: i0.ViewContainerRef }, { type: IonRouterOutlet, decorators: [{
1762
- type: SkipSelf
1763
- }, {
1764
- type: Optional
1765
- }] }];
1766
- }, propDecorators: { name: [{
1767
- type: Input
1768
- }], stackWillChange: [{
1769
- type: Output
1770
- }], stackDidChange: [{
1771
- type: Output
1772
- }], activateEvents: [{
1773
- type: Output,
1774
- args: ['activate']
1775
- }], deactivateEvents: [{
1776
- type: Output,
1777
- args: ['deactivate']
1778
- }] } });
1779
- class OutletInjector {
1780
- constructor(route, childContexts, parent) {
1781
- this.route = route;
1782
- this.childContexts = childContexts;
1783
- this.parent = parent;
1784
- }
1785
- get(token, notFoundValue) {
1786
- if (token === ActivatedRoute) {
1787
- return this.route;
1788
- }
1789
- if (token === ChildrenOutletContexts) {
1790
- return this.childContexts;
1791
- }
1792
- return this.parent.get(token, notFoundValue);
1793
- }
1794
- }
1795
- // TODO: FW-4785 - Remove this once Angular 15 support is dropped
1796
- const INPUT_BINDER = new InjectionToken('');
1797
- /**
1798
- * Injectable used as a tree-shakable provider for opting in to binding router data to component
1799
- * inputs.
1800
- *
1801
- * The RouterOutlet registers itself with this service when an `ActivatedRoute` is attached or
1802
- * activated. When this happens, the service subscribes to the `ActivatedRoute` observables (params,
1803
- * queryParams, data) and sets the inputs of the component using `ComponentRef.setInput`.
1804
- * Importantly, when an input does not have an item in the route data with a matching key, this
1805
- * input is set to `undefined`. If it were not done this way, the previous information would be
1806
- * retained if the data got removed from the route (i.e. if a query parameter is removed).
1807
- *
1808
- * The `RouterOutlet` should unregister itself when destroyed via `unsubscribeFromRouteData` so that
1809
- * the subscriptions are cleaned up.
1810
- */
1811
- class RoutedComponentInputBinder {
1812
- constructor() {
1813
- this.outletDataSubscriptions = new Map();
1814
- }
1815
- bindActivatedRouteToOutletComponent(outlet) {
1816
- this.unsubscribeFromRouteData(outlet);
1817
- this.subscribeToRouteData(outlet);
1818
- }
1819
- unsubscribeFromRouteData(outlet) {
1820
- var _a;
1821
- (_a = this.outletDataSubscriptions.get(outlet)) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1822
- this.outletDataSubscriptions.delete(outlet);
1823
- }
1824
- subscribeToRouteData(outlet) {
1825
- const { activatedRoute } = outlet;
1826
- const dataSubscription = combineLatest([activatedRoute.queryParams, activatedRoute.params, activatedRoute.data])
1827
- .pipe(switchMap(([queryParams, params, data], index) => {
1828
- data = Object.assign(Object.assign(Object.assign({}, queryParams), params), data);
1829
- // Get the first result from the data subscription synchronously so it's available to
1830
- // the component as soon as possible (and doesn't require a second change detection).
1831
- if (index === 0) {
1832
- return of(data);
1833
- }
1834
- // Promise.resolve is used to avoid synchronously writing the wrong data when
1835
- // two of the Observables in the `combineLatest` stream emit one after
1836
- // another.
1837
- return Promise.resolve(data);
1838
- }))
1839
- .subscribe((data) => {
1840
- // Outlet may have been deactivated or changed names to be associated with a different
1841
- // route
1842
- if (!outlet.isActivated ||
1843
- !outlet.activatedComponentRef ||
1844
- outlet.activatedRoute !== activatedRoute ||
1845
- activatedRoute.component === null) {
1846
- this.unsubscribeFromRouteData(outlet);
1847
- return;
1848
- }
1849
- const mirror = reflectComponentType(activatedRoute.component);
1850
- if (!mirror) {
1851
- this.unsubscribeFromRouteData(outlet);
1852
- return;
1853
- }
1854
- for (const { templateName } of mirror.inputs) {
1855
- outlet.activatedComponentRef.setInput(templateName, data[templateName]);
1856
- }
1857
- });
1858
- this.outletDataSubscriptions.set(outlet, dataSubscription);
1859
- }
1860
- }
1861
- /** @nocollapse */ RoutedComponentInputBinder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1862
- /** @nocollapse */ RoutedComponentInputBinder.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder });
1863
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RoutedComponentInputBinder, decorators: [{
1864
- type: Injectable
1865
- }] });
1866
- const provideComponentInputBinding = () => {
1867
- return {
1868
- provide: INPUT_BINDER,
1869
- useFactory: componentInputBindingFactory,
1870
- deps: [Router],
1871
- };
1872
- };
1873
- function componentInputBindingFactory(router) {
1874
- /**
1875
- * We cast the router to any here, since the componentInputBindingEnabled
1876
- * property is not available until Angular v16.
1877
- */
1878
- if (router === null || router === void 0 ? void 0 : router.componentInputBindingEnabled) {
1879
- return new RoutedComponentInputBinder();
1880
- }
1881
- return null;
1882
- }
1883
-
1884
- const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type'];
1885
- let IonBackButton = class IonBackButton {
1886
- constructor(routerOutlet, navCtrl, config, r, z, c) {
1887
- this.routerOutlet = routerOutlet;
1888
- this.navCtrl = navCtrl;
1889
- this.config = config;
1890
- this.r = r;
1891
- this.z = z;
1892
- c.detach();
1893
- this.el = this.r.nativeElement;
1894
- }
1895
- /**
1896
- * @internal
1897
- */
1898
- onClick(ev) {
1899
- var _a;
1900
- const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref');
1901
- if ((_a = this.routerOutlet) === null || _a === void 0 ? void 0 : _a.canGoBack()) {
1902
- this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation);
1903
- this.routerOutlet.pop();
1904
- ev.preventDefault();
1905
- }
1906
- else if (defaultHref != null) {
1907
- this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation });
1908
- ev.preventDefault();
1909
- }
1910
- }
1911
- };
1912
- /** @nocollapse */ IonBackButton.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonBackButton, deps: [{ token: IonRouterOutlet, optional: true }, { token: NavController }, { token: Config }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1913
- /** @nocollapse */ IonBackButton.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonBackButton, inputs: { color: "color", defaultHref: "defaultHref", disabled: "disabled", icon: "icon", mode: "mode", routerAnimation: "routerAnimation", text: "text", type: "type" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
1914
- IonBackButton = __decorate([
1915
- ProxyCmp({
1916
- inputs: BACK_BUTTON_INPUTS,
1917
- })
1918
- ], IonBackButton);
1919
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonBackButton, decorators: [{
1920
- type: Directive,
1921
- args: [{
1922
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1923
- inputs: BACK_BUTTON_INPUTS,
1924
- }]
1925
- }], ctorParameters: function () {
1926
- return [{ type: IonRouterOutlet, decorators: [{
1927
- type: Optional
1928
- }] }, { type: NavController }, { type: Config }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }];
1929
- }, propDecorators: { defaultHref: [{
1930
- type: Input
1931
- }], routerAnimation: [{
1932
- type: Input
1933
- }], onClick: [{
1934
- type: HostListener,
1935
- args: ['click', ['$event']]
1936
- }] } });
1937
-
1938
- /**
1939
- * Adds support for Ionic routing directions and animations to the base Angular router link directive.
1940
- *
1941
- * When the router link is clicked, the directive will assign the direction and
1942
- * animation so that the routing integration will transition correctly.
1943
- */
1944
- class RouterLinkDelegateDirective {
1945
- constructor(locationStrategy, navCtrl, elementRef, router, routerLink) {
1946
- this.locationStrategy = locationStrategy;
1947
- this.navCtrl = navCtrl;
1948
- this.elementRef = elementRef;
1949
- this.router = router;
1950
- this.routerLink = routerLink;
1951
- this.routerDirection = 'forward';
1952
- }
1953
- ngOnInit() {
1954
- this.updateTargetUrlAndHref();
1955
- }
1956
- ngOnChanges() {
1957
- this.updateTargetUrlAndHref();
1958
- }
1959
- updateTargetUrlAndHref() {
1960
- var _a;
1961
- if ((_a = this.routerLink) === null || _a === void 0 ? void 0 : _a.urlTree) {
1962
- const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree));
1963
- this.elementRef.nativeElement.href = href;
1964
- }
1965
- }
1966
- /**
1967
- * @internal
1968
- */
1969
- onClick(ev) {
1970
- this.navCtrl.setDirection(this.routerDirection, undefined, undefined, this.routerAnimation);
1971
- /**
1972
- * This prevents the browser from
1973
- * performing a page reload when pressing
1974
- * an Ionic component with routerLink.
1975
- * The page reload interferes with routing
1976
- * and causes ion-back-button to disappear
1977
- * since the local history is wiped on reload.
1978
- */
1979
- ev.preventDefault();
1980
- }
1981
- }
1982
- /** @nocollapse */ RouterLinkDelegateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDelegateDirective, deps: [{ token: i1.LocationStrategy }, { token: NavController }, { token: i0.ElementRef }, { token: i3.Router }, { token: i3.RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
1983
- /** @nocollapse */ RouterLinkDelegateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkDelegateDirective, selector: ":not(a):not(area)[routerLink]", inputs: { routerDirection: "routerDirection", routerAnimation: "routerAnimation" }, host: { listeners: { "click": "onClick($event)" } }, usesOnChanges: true, ngImport: i0 });
1984
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkDelegateDirective, decorators: [{
1985
- type: Directive,
1986
- args: [{
1987
- selector: ':not(a):not(area)[routerLink]',
1988
- }]
1989
- }], ctorParameters: function () {
1990
- return [{ type: i1.LocationStrategy }, { type: NavController }, { type: i0.ElementRef }, { type: i3.Router }, { type: i3.RouterLink, decorators: [{
1991
- type: Optional
1992
- }] }];
1993
- }, propDecorators: { routerDirection: [{
1994
- type: Input
1995
- }], routerAnimation: [{
1996
- type: Input
1997
- }], onClick: [{
1998
- type: HostListener,
1999
- args: ['click', ['$event']]
2000
- }] } });
2001
- class RouterLinkWithHrefDelegateDirective {
2002
- constructor(locationStrategy, navCtrl, elementRef, router, routerLink) {
2003
- this.locationStrategy = locationStrategy;
2004
- this.navCtrl = navCtrl;
2005
- this.elementRef = elementRef;
2006
- this.router = router;
2007
- this.routerLink = routerLink;
2008
- this.routerDirection = 'forward';
2009
- }
2010
- ngOnInit() {
2011
- this.updateTargetUrlAndHref();
2012
- }
2013
- ngOnChanges() {
2014
- this.updateTargetUrlAndHref();
2015
- }
2016
- updateTargetUrlAndHref() {
2017
- var _a;
2018
- if ((_a = this.routerLink) === null || _a === void 0 ? void 0 : _a.urlTree) {
2019
- const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree));
2020
- this.elementRef.nativeElement.href = href;
2021
- }
2022
- }
2023
- /**
2024
- * @internal
2025
- */
2026
- onClick() {
2027
- this.navCtrl.setDirection(this.routerDirection, undefined, undefined, this.routerAnimation);
2028
- }
2029
- }
2030
- /** @nocollapse */ RouterLinkWithHrefDelegateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkWithHrefDelegateDirective, deps: [{ token: i1.LocationStrategy }, { token: NavController }, { token: i0.ElementRef }, { token: i3.Router }, { token: i3.RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2031
- /** @nocollapse */ RouterLinkWithHrefDelegateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: RouterLinkWithHrefDelegateDirective, selector: "a[routerLink],area[routerLink]", inputs: { routerDirection: "routerDirection", routerAnimation: "routerAnimation" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
2032
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: RouterLinkWithHrefDelegateDirective, decorators: [{
2033
- type: Directive,
2034
- args: [{
2035
- selector: 'a[routerLink],area[routerLink]',
2036
- }]
2037
- }], ctorParameters: function () {
2038
- return [{ type: i1.LocationStrategy }, { type: NavController }, { type: i0.ElementRef }, { type: i3.Router }, { type: i3.RouterLink, decorators: [{
2039
- type: Optional
2040
- }] }];
2041
- }, propDecorators: { routerDirection: [{
2042
- type: Input
2043
- }], routerAnimation: [{
2044
- type: Input
2045
- }], onClick: [{
2046
- type: HostListener,
2047
- args: ['click']
2048
- }] } });
2049
-
2050
- const NAV_INPUTS = ['animated', 'animation', 'root', 'rootParams', 'swipeGesture'];
2051
- const NAV_METHODS = [
2052
- 'push',
2053
- 'insert',
2054
- 'insertPages',
2055
- 'pop',
2056
- 'popTo',
2057
- 'popToRoot',
2058
- 'removeIndex',
2059
- 'setRoot',
2060
- 'setPages',
2061
- 'getActive',
2062
- 'getByIndex',
2063
- 'canGoBack',
2064
- 'getPrevious',
2065
- ];
2066
- let IonNav = class IonNav {
2067
- constructor(ref, environmentInjector, injector, angularDelegate, z, c) {
2068
- this.z = z;
2069
- c.detach();
2070
- this.el = ref.nativeElement;
2071
- ref.nativeElement.delegate = angularDelegate.create(environmentInjector, injector);
2072
- proxyOutputs(this, this.el, ['ionNavDidChange', 'ionNavWillChange']);
2073
- }
2074
- };
2075
- /** @nocollapse */ IonNav.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonNav, deps: [{ token: i0.ElementRef }, { token: i0.EnvironmentInjector }, { token: i0.Injector }, { token: AngularDelegate }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2076
- /** @nocollapse */ IonNav.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonNav, inputs: { animated: "animated", animation: "animation", root: "root", rootParams: "rootParams", swipeGesture: "swipeGesture" }, ngImport: i0 });
2077
- IonNav = __decorate([
2078
- ProxyCmp({
2079
- inputs: NAV_INPUTS,
2080
- methods: NAV_METHODS,
2081
- })
2082
- ], IonNav);
2083
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonNav, decorators: [{
2084
- type: Directive,
2085
- args: [{
2086
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
2087
- inputs: NAV_INPUTS,
2088
- }]
2089
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.EnvironmentInjector }, { type: i0.Injector }, { type: AngularDelegate }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; } });
2090
-
2091
- // eslint-disable-next-line @angular-eslint/directive-class-suffix
2092
- class IonTabs {
2093
- constructor(navCtrl) {
2094
- this.navCtrl = navCtrl;
2095
- /**
2096
- * Emitted before the tab view is changed.
2097
- */
2098
- this.ionTabsWillChange = new EventEmitter();
2099
- /**
2100
- * Emitted after the tab view is changed.
2101
- */
2102
- this.ionTabsDidChange = new EventEmitter();
2103
- this.tabBarSlot = 'bottom';
2104
- }
2105
- ngAfterContentInit() {
2106
- this.detectSlotChanges();
2107
- }
2108
- ngAfterContentChecked() {
2109
- this.detectSlotChanges();
2110
- }
2111
- /**
2112
- * @internal
2113
- */
2114
- onStackWillChange({ enteringView, tabSwitch }) {
2115
- const stackId = enteringView.stackId;
2116
- if (tabSwitch && stackId !== undefined) {
2117
- this.ionTabsWillChange.emit({ tab: stackId });
2118
- }
2119
- }
2120
- /**
2121
- * @internal
2122
- */
2123
- onStackDidChange({ enteringView, tabSwitch }) {
2124
- const stackId = enteringView.stackId;
2125
- if (tabSwitch && stackId !== undefined) {
2126
- if (this.tabBar) {
2127
- this.tabBar.selectedTab = stackId;
2128
- }
2129
- this.ionTabsDidChange.emit({ tab: stackId });
2130
- }
2131
- }
2132
- /**
2133
- * When a tab button is clicked, there are several scenarios:
2134
- * 1. If the selected tab is currently active (the tab button has been clicked
2135
- * again), then it should go to the root view for that tab.
2136
- *
2137
- * a. Get the saved root view from the router outlet. If the saved root view
2138
- * matches the tabRootUrl, set the route view to this view including the
2139
- * navigation extras.
2140
- * b. If the saved root view from the router outlet does
2141
- * not match, navigate to the tabRootUrl. No navigation extras are
2142
- * included.
2143
- *
2144
- * 2. If the current tab tab is not currently selected, get the last route
2145
- * view from the router outlet.
2146
- *
2147
- * a. If the last route view exists, navigate to that view including any
2148
- * navigation extras
2149
- * b. If the last route view doesn't exist, then navigate
2150
- * to the default tabRootUrl
2151
- */
2152
- select(tabOrEvent) {
2153
- const isTabString = typeof tabOrEvent === 'string';
2154
- const tab = isTabString ? tabOrEvent : tabOrEvent.detail.tab;
2155
- const alreadySelected = this.outlet.getActiveStackId() === tab;
2156
- const tabRootUrl = `${this.outlet.tabsPrefix}/${tab}`;
2157
- /**
2158
- * If this is a nested tab, prevent the event
2159
- * from bubbling otherwise the outer tabs
2160
- * will respond to this event too, causing
2161
- * the app to get directed to the wrong place.
2162
- */
2163
- if (!isTabString) {
2164
- tabOrEvent.stopPropagation();
2165
- }
2166
- if (alreadySelected) {
2167
- const activeStackId = this.outlet.getActiveStackId();
2168
- const activeView = this.outlet.getLastRouteView(activeStackId);
2169
- // If on root tab, do not navigate to root tab again
2170
- if ((activeView === null || activeView === void 0 ? void 0 : activeView.url) === tabRootUrl) {
2171
- return;
2172
- }
2173
- const rootView = this.outlet.getRootView(tab);
2174
- const navigationExtras = rootView && tabRootUrl === rootView.url && rootView.savedExtras;
2175
- return this.navCtrl.navigateRoot(tabRootUrl, Object.assign(Object.assign({}, navigationExtras), { animated: true, animationDirection: 'back' }));
2176
- }
2177
- else {
2178
- const lastRoute = this.outlet.getLastRouteView(tab);
2179
- /**
2180
- * If there is a lastRoute, goto that, otherwise goto the fallback url of the
2181
- * selected tab
2182
- */
2183
- const url = (lastRoute === null || lastRoute === void 0 ? void 0 : lastRoute.url) || tabRootUrl;
2184
- const navigationExtras = lastRoute === null || lastRoute === void 0 ? void 0 : lastRoute.savedExtras;
2185
- return this.navCtrl.navigateRoot(url, Object.assign(Object.assign({}, navigationExtras), { animated: true, animationDirection: 'back' }));
2186
- }
2187
- }
2188
- getSelected() {
2189
- return this.outlet.getActiveStackId();
2190
- }
2191
- /**
2192
- * Detects changes to the slot attribute of the tab bar.
2193
- *
2194
- * If the slot attribute has changed, then the tab bar
2195
- * should be relocated to the new slot position.
2196
- */
2197
- detectSlotChanges() {
2198
- this.tabBars.forEach((tabBar) => {
2199
- // el is a protected attribute from the generated component wrapper
2200
- const currentSlot = tabBar.el.getAttribute('slot');
2201
- if (currentSlot !== this.tabBarSlot) {
2202
- this.tabBarSlot = currentSlot;
2203
- this.relocateTabBar();
2204
- }
2205
- });
2206
- }
2207
- /**
2208
- * Relocates the tab bar to the new slot position.
2209
- */
2210
- relocateTabBar() {
2211
- /**
2212
- * `el` is a protected attribute from the generated component wrapper.
2213
- * To avoid having to manually create the wrapper for tab bar, we
2214
- * cast the tab bar to any and access the protected attribute.
2215
- */
2216
- const tabBar = this.tabBar.el;
2217
- if (this.tabBarSlot === 'top') {
2218
- /**
2219
- * A tab bar with a slot of "top" should be inserted
2220
- * at the top of the container.
2221
- */
2222
- this.tabsInner.nativeElement.before(tabBar);
2223
- }
2224
- else {
2225
- /**
2226
- * A tab bar with a slot of "bottom" or without a slot
2227
- * should be inserted at the end of the container.
2228
- */
2229
- this.tabsInner.nativeElement.after(tabBar);
2230
- }
2231
- }
2232
- }
2233
- /** @nocollapse */ IonTabs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonTabs, deps: [{ token: NavController }], target: i0.ɵɵFactoryTarget.Directive });
2234
- /** @nocollapse */ IonTabs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: IonTabs, selector: "ion-tabs", outputs: { ionTabsWillChange: "ionTabsWillChange", ionTabsDidChange: "ionTabsDidChange" }, host: { listeners: { "ionTabButtonClick": "select($event)" } }, viewQueries: [{ propertyName: "tabsInner", first: true, predicate: ["tabsInner"], descendants: true, read: ElementRef, static: true }], ngImport: i0 });
2235
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: IonTabs, decorators: [{
2236
- type: Directive,
2237
- args: [{
2238
- selector: 'ion-tabs',
2239
- }]
2240
- }], ctorParameters: function () { return [{ type: NavController }]; }, propDecorators: { tabsInner: [{
2241
- type: ViewChild,
2242
- args: ['tabsInner', { read: ElementRef, static: true }]
2243
- }], ionTabsWillChange: [{
2244
- type: Output
2245
- }], ionTabsDidChange: [{
2246
- type: Output
2247
- }], select: [{
2248
- type: HostListener,
2249
- args: ['ionTabButtonClick', ['$event']]
2250
- }] } });
2251
-
2252
- const raf = (h) => {
2253
- if (typeof __zone_symbol__requestAnimationFrame === 'function') {
2254
- return __zone_symbol__requestAnimationFrame(h);
2255
- }
2256
- if (typeof requestAnimationFrame === 'function') {
2257
- return requestAnimationFrame(h);
2258
- }
2259
- return setTimeout(h);
2260
- };
2261
-
2262
- // TODO(FW-2827): types
2263
- class ValueAccessor {
2264
- constructor(injector, elementRef) {
2265
- this.injector = injector;
2266
- this.elementRef = elementRef;
2267
- this.onChange = () => {
2268
- /**/
2269
- };
2270
- this.onTouched = () => {
2271
- /**/
2272
- };
2273
- }
2274
- writeValue(value) {
2275
- this.elementRef.nativeElement.value = this.lastValue = value;
2276
- setIonicClasses(this.elementRef);
2277
- }
2278
- /**
2279
- * Notifies the ControlValueAccessor of a change in the value of the control.
2280
- *
2281
- * This is called by each of the ValueAccessor directives when we want to update
2282
- * the status and validity of the form control. For example with text components this
2283
- * is called when the ionInput event is fired. For select components this is called
2284
- * when the ionChange event is fired.
2285
- *
2286
- * This also updates the Ionic form status classes on the element.
2287
- *
2288
- * @param el The component element.
2289
- * @param value The new value of the control.
2290
- */
2291
- handleValueChange(el, value) {
2292
- if (el === this.elementRef.nativeElement) {
2293
- if (value !== this.lastValue) {
2294
- this.lastValue = value;
2295
- this.onChange(value);
2296
- }
2297
- setIonicClasses(this.elementRef);
2298
- }
2299
- }
2300
- _handleBlurEvent(el) {
2301
- if (el === this.elementRef.nativeElement) {
2302
- this.onTouched();
2303
- setIonicClasses(this.elementRef);
2304
- }
2305
- }
2306
- registerOnChange(fn) {
2307
- this.onChange = fn;
2308
- }
2309
- registerOnTouched(fn) {
2310
- this.onTouched = fn;
2311
- }
2312
- setDisabledState(isDisabled) {
2313
- this.elementRef.nativeElement.disabled = isDisabled;
2314
- }
2315
- ngOnDestroy() {
2316
- if (this.statusChanges) {
2317
- this.statusChanges.unsubscribe();
2318
- }
2319
- }
2320
- ngAfterViewInit() {
2321
- let ngControl;
2322
- try {
2323
- ngControl = this.injector.get(NgControl);
2324
- }
2325
- catch (_a) {
2326
- /* No FormControl or ngModel binding */
2327
- }
2328
- if (!ngControl) {
2329
- return;
2330
- }
2331
- // Listen for changes in validity, disabled, or pending states
2332
- if (ngControl.statusChanges) {
2333
- this.statusChanges = ngControl.statusChanges.subscribe(() => setIonicClasses(this.elementRef));
2334
- }
2335
- /**
2336
- * TODO FW-2787: Remove this in favor of https://github.com/angular/angular/issues/10887
2337
- * whenever it is implemented.
2338
- */
2339
- const formControl = ngControl.control;
2340
- if (formControl) {
2341
- const methodsToPatch = ['markAsTouched', 'markAllAsTouched', 'markAsUntouched', 'markAsDirty', 'markAsPristine'];
2342
- methodsToPatch.forEach((method) => {
2343
- if (typeof formControl[method] !== 'undefined') {
2344
- const oldFn = formControl[method].bind(formControl);
2345
- formControl[method] = (...params) => {
2346
- oldFn(...params);
2347
- setIonicClasses(this.elementRef);
2348
- };
2349
- }
2350
- });
2351
- }
2352
- }
2353
- }
2354
- /** @nocollapse */ ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.Injector }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2355
- /** @nocollapse */ ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.12", type: ValueAccessor, host: { listeners: { "ionBlur": "_handleBlurEvent($event.target)" } }, ngImport: i0 });
2356
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ValueAccessor, decorators: [{
2357
- type: Directive
2358
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
2359
- type: HostListener,
2360
- args: ['ionBlur', ['$event.target']]
2361
- }] } });
2362
- const setIonicClasses = (element) => {
2363
- raf(() => {
2364
- const input = element.nativeElement;
2365
- const hasValue = input.value != null && input.value.toString().length > 0;
2366
- const classes = getClasses(input);
2367
- setClasses(input, classes);
2368
- const item = input.closest('ion-item');
2369
- if (item) {
2370
- if (hasValue) {
2371
- setClasses(item, [...classes, 'item-has-value']);
2372
- }
2373
- else {
2374
- setClasses(item, classes);
2375
- }
2376
- }
2377
- });
2378
- };
2379
- const getClasses = (element) => {
2380
- const classList = element.classList;
2381
- const classes = [];
2382
- for (let i = 0; i < classList.length; i++) {
2383
- const item = classList.item(i);
2384
- if (item !== null && startsWith(item, 'ng-')) {
2385
- classes.push(`ion-${item.substring(3)}`);
2386
- }
2387
- }
2388
- return classes;
2389
- };
2390
- const setClasses = (element, classes) => {
2391
- const classList = element.classList;
2392
- classList.remove('ion-valid', 'ion-invalid', 'ion-touched', 'ion-untouched', 'ion-dirty', 'ion-pristine');
2393
- classList.add(...classes);
2394
- };
2395
- const startsWith = (input, search) => {
2396
- return input.substring(0, search.length) === search;
2397
- };
2398
-
2399
- /**
2400
- * Provides a way to customize when activated routes get reused.
2401
- */
2402
- class IonicRouteStrategy {
2403
- /**
2404
- * Whether the given route should detach for later reuse.
2405
- */
2406
- shouldDetach(_route) {
2407
- return false;
2408
- }
2409
- /**
2410
- * Returns `false`, meaning the route (and its subtree) is never reattached
2411
- */
2412
- shouldAttach(_route) {
2413
- return false;
2414
- }
2415
- /**
2416
- * A no-op; the route is never stored since this strategy never detaches routes for later re-use.
2417
- */
2418
- store(_route, _detachedTree) {
2419
- return;
2420
- }
2421
- /**
2422
- * Returns `null` because this strategy does not store routes for later re-use.
2423
- */
2424
- retrieve(_route) {
2425
- return null;
2426
- }
2427
- /**
2428
- * Determines if a route should be reused.
2429
- * This strategy returns `true` when the future route config and
2430
- * current route config are identical and all route parameters are identical.
2431
- */
2432
- shouldReuseRoute(future, curr) {
2433
- if (future.routeConfig !== curr.routeConfig) {
2434
- return false;
2435
- }
2436
- // checking router params
2437
- const futureParams = future.params;
2438
- const currentParams = curr.params;
2439
- const keysA = Object.keys(futureParams);
2440
- const keysB = Object.keys(currentParams);
2441
- if (keysA.length !== keysB.length) {
2442
- return false;
2443
- }
2444
- // Test for A's keys different from B.
2445
- for (const key of keysA) {
2446
- if (currentParams[key] !== futureParams[key]) {
2447
- return false;
2448
- }
2449
- }
2450
- return true;
2451
- }
2452
- }
2453
-
2454
- // TODO(FW-2827): types
2455
- class OverlayBaseController {
2456
- constructor(ctrl) {
2457
- this.ctrl = ctrl;
2458
- }
2459
- /**
2460
- * Creates a new overlay
2461
- */
2462
- create(opts) {
2463
- return this.ctrl.create((opts || {}));
2464
- }
2465
- /**
2466
- * When `id` is not provided, it dismisses the top overlay.
2467
- */
2468
- dismiss(data, role, id) {
2469
- return this.ctrl.dismiss(data, role, id);
2470
- }
2471
- /**
2472
- * Returns the top overlay.
2473
- */
2474
- getTop() {
2475
- return this.ctrl.getTop();
2476
- }
2477
- }
2478
-
2479
- /**
2480
- * Generated bundle index. Do not edit.
2481
- */
2482
-
2483
- export { AngularDelegate, Config, ConfigToken, DomController, IonBackButton, IonModal, IonNav, IonPopover, IonRouterOutlet, IonTabs, IonicRouteStrategy, MenuController, NavController, NavParams, OverlayBaseController, Platform, ProxyCmp, RouterLinkDelegateDirective, RouterLinkWithHrefDelegateDirective, ValueAccessor, bindLifecycleEvents, provideComponentInputBinding, raf, setIonicClasses };
2484
- //# sourceMappingURL=ionic-angular-common.mjs.map