@angular/cdk 20.0.0-next.5 → 20.0.0-next.7

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 (203) hide show
  1. package/a11y/index.d.ts +11 -11
  2. package/{a11y-module.d-9287508d.d.ts → a11y-module.d-DrV0SO0k.d.ts} +4 -3
  3. package/a11y-prebuilt.css +1 -1
  4. package/accordion/index.d.ts +2 -2
  5. package/{activedescendant-key-manager.d-24783633.d.ts → activedescendant-key-manager.d-DSYvyoT0.d.ts} +3 -2
  6. package/bidi/index.d.ts +1 -1
  7. package/{bidi-module.d-e045bff7.d.ts → bidi-module.d-bsVYOt0R.d.ts} +2 -1
  8. package/clipboard/index.d.ts +3 -2
  9. package/coercion/index.d.ts +3 -2
  10. package/collections/index.d.ts +9 -8
  11. package/{data-source.d-cd31f292.d.ts → data-source.d-DAIyaEMO.d.ts} +2 -1
  12. package/dialog/index.d.ts +17 -16
  13. package/drag-drop/index.d.ts +8 -7
  14. package/fesm2022/{a11y-module-f780e811.mjs → a11y-module-tRUj0Pog.mjs} +32 -32
  15. package/fesm2022/a11y-module-tRUj0Pog.mjs.map +1 -0
  16. package/fesm2022/a11y.mjs +33 -33
  17. package/fesm2022/a11y.mjs.map +1 -1
  18. package/fesm2022/accordion.mjs +13 -13
  19. package/fesm2022/accordion.mjs.map +1 -1
  20. package/fesm2022/{activedescendant-key-manager-f0c079ca.mjs → activedescendant-key-manager-BYiHZAZc.mjs} +3 -3
  21. package/fesm2022/activedescendant-key-manager-BYiHZAZc.mjs.map +1 -0
  22. package/fesm2022/{array-6239d2f8.mjs → array-Hg8isvLj.mjs} +2 -2
  23. package/fesm2022/array-Hg8isvLj.mjs.map +1 -0
  24. package/fesm2022/bidi.mjs +77 -3
  25. package/fesm2022/bidi.mjs.map +1 -1
  26. package/fesm2022/{breakpoints-observer-af989fcc.mjs → breakpoints-observer-CsCzbYlX.mjs} +10 -10
  27. package/fesm2022/breakpoints-observer-CsCzbYlX.mjs.map +1 -0
  28. package/fesm2022/cdk.mjs +1 -1
  29. package/fesm2022/cdk.mjs.map +1 -1
  30. package/fesm2022/clipboard.mjs +11 -11
  31. package/fesm2022/clipboard.mjs.map +1 -1
  32. package/fesm2022/coercion/private.mjs +14 -2
  33. package/fesm2022/coercion/private.mjs.map +1 -1
  34. package/fesm2022/coercion.mjs +3 -3
  35. package/fesm2022/coercion.mjs.map +1 -1
  36. package/fesm2022/collections.mjs +5 -5
  37. package/fesm2022/{css-pixel-value-5d0cae55.mjs → css-pixel-value-C1yoKJ7R.mjs} +2 -2
  38. package/fesm2022/css-pixel-value-C1yoKJ7R.mjs.map +1 -0
  39. package/fesm2022/{data-source-d79c6e09.mjs → data-source-CL6Fasig.mjs} +2 -2
  40. package/fesm2022/data-source-CL6Fasig.mjs.map +1 -0
  41. package/fesm2022/dialog.mjs +47 -47
  42. package/fesm2022/dialog.mjs.map +1 -1
  43. package/fesm2022/{directionality-d3343e21.mjs → directionality-6lVHj23y.mjs} +5 -5
  44. package/fesm2022/directionality-6lVHj23y.mjs.map +1 -0
  45. package/fesm2022/{dispose-view-repeater-strategy-4c6df00e.mjs → dispose-view-repeater-strategy-BLw1RSwm.mjs} +3 -3
  46. package/fesm2022/dispose-view-repeater-strategy-BLw1RSwm.mjs.map +1 -0
  47. package/fesm2022/drag-drop.mjs +47 -47
  48. package/fesm2022/drag-drop.mjs.map +1 -1
  49. package/fesm2022/{element-15999318.mjs → element-CpqV8p-X.mjs} +2 -2
  50. package/fesm2022/element-CpqV8p-X.mjs.map +1 -0
  51. package/fesm2022/{fake-event-detection-84590b88.mjs → fake-event-detection-D0_6qVp2.mjs} +2 -2
  52. package/fesm2022/fake-event-detection-D0_6qVp2.mjs.map +1 -0
  53. package/fesm2022/{focus-key-manager-ff488563.mjs → focus-key-manager-DgyxYbV2.mjs} +3 -3
  54. package/fesm2022/focus-key-manager-DgyxYbV2.mjs.map +1 -0
  55. package/fesm2022/{focus-monitor-3464a8c8.mjs → focus-monitor-BZnK-7fT.mjs} +18 -18
  56. package/fesm2022/focus-monitor-BZnK-7fT.mjs.map +1 -0
  57. package/fesm2022/{id-generator-c0f67d1b.mjs → id-generator-B33AfkWd.mjs} +5 -5
  58. package/fesm2022/id-generator-B33AfkWd.mjs.map +1 -0
  59. package/fesm2022/{keycodes-0e4398c6.mjs → keycodes-DPWmI2Ix.mjs} +2 -2
  60. package/fesm2022/keycodes-DPWmI2Ix.mjs.map +1 -0
  61. package/fesm2022/keycodes.mjs +14 -2
  62. package/fesm2022/keycodes.mjs.map +1 -1
  63. package/fesm2022/layout.mjs +7 -7
  64. package/fesm2022/layout.mjs.map +1 -1
  65. package/fesm2022/{list-key-manager-f9c3e90c.mjs → list-key-manager-CYBoL_nN.mjs} +5 -5
  66. package/fesm2022/list-key-manager-CYBoL_nN.mjs.map +1 -0
  67. package/fesm2022/listbox.mjs +21 -21
  68. package/fesm2022/listbox.mjs.map +1 -1
  69. package/fesm2022/menu.mjs +75 -75
  70. package/fesm2022/menu.mjs.map +1 -1
  71. package/fesm2022/observers/private.mjs +3 -3
  72. package/fesm2022/observers/private.mjs.map +1 -1
  73. package/fesm2022/observers.mjs +209 -5
  74. package/fesm2022/observers.mjs.map +1 -1
  75. package/fesm2022/{overlay-module-778cde6a.mjs → overlay-module-UgjfuiDh.mjs} +52 -52
  76. package/fesm2022/overlay-module-UgjfuiDh.mjs.map +1 -0
  77. package/fesm2022/overlay.mjs +23 -23
  78. package/fesm2022/overlay.mjs.map +1 -1
  79. package/fesm2022/{passive-listeners-93cf8be8.mjs → passive-listeners-ZmZRMx8D.mjs} +2 -2
  80. package/fesm2022/passive-listeners-ZmZRMx8D.mjs.map +1 -0
  81. package/fesm2022/{platform-fd50034d.mjs → platform-BInyKIh1.mjs} +5 -5
  82. package/fesm2022/platform-BInyKIh1.mjs.map +1 -0
  83. package/fesm2022/platform.mjs +9 -9
  84. package/fesm2022/platform.mjs.map +1 -1
  85. package/fesm2022/portal.mjs +614 -3
  86. package/fesm2022/portal.mjs.map +1 -1
  87. package/fesm2022/private.mjs +18 -3
  88. package/fesm2022/private.mjs.map +1 -1
  89. package/fesm2022/{recycle-view-repeater-strategy-0f32b0a8.mjs → recycle-view-repeater-strategy-Ce0p4WhD.mjs} +4 -4
  90. package/fesm2022/recycle-view-repeater-strategy-Ce0p4WhD.mjs.map +1 -0
  91. package/fesm2022/{scrolling-59340c46.mjs → scrolling-BXVcIfjZ.mjs} +2 -2
  92. package/fesm2022/scrolling-BXVcIfjZ.mjs.map +1 -0
  93. package/fesm2022/scrolling.mjs +1463 -12
  94. package/fesm2022/scrolling.mjs.map +1 -1
  95. package/fesm2022/{selection-model-4044ace7.mjs → selection-model-88BErm4w.mjs} +2 -2
  96. package/fesm2022/selection-model-88BErm4w.mjs.map +1 -0
  97. package/fesm2022/{shadow-dom-318658ae.mjs → shadow-dom-DFvX9W95.mjs} +2 -2
  98. package/fesm2022/shadow-dom-DFvX9W95.mjs.map +1 -0
  99. package/fesm2022/stepper.mjs +32 -32
  100. package/fesm2022/stepper.mjs.map +1 -1
  101. package/fesm2022/{style-loader-902ffada.mjs → style-loader-DpEDdstc.mjs} +5 -5
  102. package/fesm2022/style-loader-DpEDdstc.mjs.map +1 -0
  103. package/fesm2022/table.mjs +95 -92
  104. package/fesm2022/table.mjs.map +1 -1
  105. package/fesm2022/{test-environment-f6f8bc13.mjs → test-environment-BgaaXvCA.mjs} +2 -2
  106. package/fesm2022/test-environment-BgaaXvCA.mjs.map +1 -0
  107. package/fesm2022/testing/selenium-webdriver.mjs +1 -1
  108. package/fesm2022/testing/selenium-webdriver.mjs.map +1 -1
  109. package/fesm2022/testing/testbed.mjs +2 -2
  110. package/fesm2022/testing/testbed.mjs.map +1 -1
  111. package/fesm2022/testing.mjs +697 -2
  112. package/fesm2022/testing.mjs.map +1 -1
  113. package/fesm2022/text-field.mjs +21 -21
  114. package/fesm2022/text-field.mjs.map +1 -1
  115. package/fesm2022/{tree-key-manager-1212bcbe.mjs → tree-key-manager-DIhQ-v4R.mjs} +5 -5
  116. package/fesm2022/tree-key-manager-DIhQ-v4R.mjs.map +1 -0
  117. package/fesm2022/tree.mjs +33 -33
  118. package/fesm2022/tree.mjs.map +1 -1
  119. package/fesm2022/{typeahead-0113d27c.mjs → typeahead-BAa3HZoh.mjs} +3 -3
  120. package/fesm2022/typeahead-BAa3HZoh.mjs.map +1 -0
  121. package/fesm2022/{unique-selection-dispatcher-b23237b2.mjs → unique-selection-dispatcher-SqPM2COI.mjs} +5 -5
  122. package/fesm2022/unique-selection-dispatcher-SqPM2COI.mjs.map +1 -0
  123. package/{focus-key-manager.d-639d8a5d.d.ts → focus-key-manager.d-DCiEwxN7.d.ts} +4 -3
  124. package/{focus-monitor.d-b42086db.d.ts → focus-monitor.d-BBkiOKUH.d.ts} +2 -1
  125. package/{harness-environment.d-300a0fdc.d.ts → harness-environment.d-ByFLvxZh.d.ts} +2 -1
  126. package/keycodes/index.d.ts +2 -1
  127. package/layout/index.d.ts +2 -1
  128. package/{list-key-manager.d-6fe81cb7.d.ts → list-key-manager.d-CylnKWfo.d.ts} +2 -1
  129. package/listbox/index.d.ts +5 -4
  130. package/menu/index.d.ts +14 -13
  131. package/{number-property.d-5998850c.d.ts → number-property.d-BzBQchZ2.d.ts} +2 -1
  132. package/observers/index.d.ts +84 -4
  133. package/overlay/_index.scss +4 -1
  134. package/overlay/index.d.ts +13 -13
  135. package/{overlay-module.d-7674c06c.d.ts → overlay-module.d-24bhgNtF.d.ts} +8 -7
  136. package/overlay-prebuilt.css +1 -1
  137. package/package.json +1 -1
  138. package/platform/index.d.ts +1 -1
  139. package/{platform.d-4dc3e073.d.ts → platform.d-cnFZCLss.d.ts} +1 -1
  140. package/portal/index.d.ts +3 -3
  141. package/{portal-directives.d-cac5eb8d.d.ts → portal-directives.d-D9c4J36c.d.ts} +2 -1
  142. package/private/index.d.ts +1 -1
  143. package/schematics/ng-add/index.js +1 -1
  144. package/scrolling/index.d.ts +62 -7
  145. package/{scrolling-module.d-132f8fdb.d.ts → scrolling-module.d-CuNwYGVM.d.ts} +6 -5
  146. package/{selection-model.d-6137a548.d.ts → selection-model.d-CHuTS0tw.d.ts} +2 -1
  147. package/stepper/index.d.ts +7 -6
  148. package/{style-loader.d-972eab2d.d.ts → style-loader.d-DbvWk0ty.d.ts} +1 -1
  149. package/table/index.d.ts +8 -8
  150. package/testing/index.d.ts +3 -2
  151. package/testing/selenium-webdriver/index.d.ts +3 -2
  152. package/testing/testbed/index.d.ts +3 -2
  153. package/text-field/index.d.ts +3 -2
  154. package/text-field-prebuilt.css +1 -1
  155. package/tree/index.d.ts +6 -5
  156. package/{tree-key-manager-strategy.d-d824697d.d.ts → tree-key-manager-strategy.d-DipnXoCr.d.ts} +1 -1
  157. package/{unique-selection-dispatcher.d-c36427c5.d.ts → unique-selection-dispatcher.d-BgWACqWn.d.ts} +2 -1
  158. package/{view-repeater.d-8ca257d8.d.ts → view-repeater.d-CJ9e48MX.d.ts} +3 -2
  159. package/fesm2022/a11y-module-f780e811.mjs.map +0 -1
  160. package/fesm2022/activedescendant-key-manager-f0c079ca.mjs.map +0 -1
  161. package/fesm2022/array-6239d2f8.mjs.map +0 -1
  162. package/fesm2022/bidi-module-bd809f3d.mjs +0 -77
  163. package/fesm2022/bidi-module-bd809f3d.mjs.map +0 -1
  164. package/fesm2022/breakpoints-observer-af989fcc.mjs.map +0 -1
  165. package/fesm2022/css-pixel-value-5d0cae55.mjs.map +0 -1
  166. package/fesm2022/data-source-d79c6e09.mjs.map +0 -1
  167. package/fesm2022/directionality-d3343e21.mjs.map +0 -1
  168. package/fesm2022/dispose-view-repeater-strategy-4c6df00e.mjs.map +0 -1
  169. package/fesm2022/element-15999318.mjs.map +0 -1
  170. package/fesm2022/fake-event-detection-84590b88.mjs.map +0 -1
  171. package/fesm2022/focus-key-manager-ff488563.mjs.map +0 -1
  172. package/fesm2022/focus-monitor-3464a8c8.mjs.map +0 -1
  173. package/fesm2022/id-generator-c0f67d1b.mjs.map +0 -1
  174. package/fesm2022/keycodes-0e4398c6.mjs.map +0 -1
  175. package/fesm2022/list-key-manager-f9c3e90c.mjs.map +0 -1
  176. package/fesm2022/modifiers-3e8908bb.mjs +0 -13
  177. package/fesm2022/modifiers-3e8908bb.mjs.map +0 -1
  178. package/fesm2022/observable-3cba8a1c.mjs +0 -15
  179. package/fesm2022/observable-3cba8a1c.mjs.map +0 -1
  180. package/fesm2022/observe-content-f2aba0c9.mjs +0 -210
  181. package/fesm2022/observe-content-f2aba0c9.mjs.map +0 -1
  182. package/fesm2022/overlay-module-778cde6a.mjs.map +0 -1
  183. package/fesm2022/passive-listeners-93cf8be8.mjs.map +0 -1
  184. package/fesm2022/platform-fd50034d.mjs.map +0 -1
  185. package/fesm2022/portal-directives-26ab1686.mjs +0 -615
  186. package/fesm2022/portal-directives-26ab1686.mjs.map +0 -1
  187. package/fesm2022/recycle-view-repeater-strategy-0f32b0a8.mjs.map +0 -1
  188. package/fesm2022/scrolling-59340c46.mjs.map +0 -1
  189. package/fesm2022/scrolling-module-7394419e.mjs +0 -1463
  190. package/fesm2022/scrolling-module-7394419e.mjs.map +0 -1
  191. package/fesm2022/selection-model-4044ace7.mjs.map +0 -1
  192. package/fesm2022/shadow-dom-318658ae.mjs.map +0 -1
  193. package/fesm2022/style-loader-902ffada.mjs.map +0 -1
  194. package/fesm2022/test-environment-f6f8bc13.mjs.map +0 -1
  195. package/fesm2022/text-filtering-55cbd0d9.mjs +0 -698
  196. package/fesm2022/text-filtering-55cbd0d9.mjs.map +0 -1
  197. package/fesm2022/tree-key-manager-1212bcbe.mjs.map +0 -1
  198. package/fesm2022/typeahead-0113d27c.mjs.map +0 -1
  199. package/fesm2022/unique-selection-dispatcher-b23237b2.mjs.map +0 -1
  200. package/fesm2022/visually-hidden-cfa9d7fd.mjs +0 -18
  201. package/fesm2022/visually-hidden-cfa9d7fd.mjs.map +0 -1
  202. package/observe-content.d-8b3dea1d.d.ts +0 -84
  203. package/viewport-ruler.d-17d129ea.d.ts +0 -57
@@ -1,4 +1,615 @@
1
- export { B as BasePortalOutlet, b as CdkPortal, C as CdkPortalOutlet, a as ComponentPortal, f as DomPortal, D as DomPortalOutlet, e as Portal, d as PortalHostDirective, P as PortalModule, T as TemplatePortal, c as TemplatePortalDirective } from './portal-directives-26ab1686.mjs';
2
- import '@angular/core';
3
- import '@angular/common';
1
+ import * as i0 from '@angular/core';
2
+ import { ElementRef, NgModuleRef, Injector, EnvironmentInjector, createComponent, inject, TemplateRef, ViewContainerRef, EventEmitter, Directive, Output, Input, NgModule } from '@angular/core';
3
+ import { DOCUMENT } from '@angular/common';
4
+
5
+ /**
6
+ * Throws an exception when attempting to attach a null portal to a host.
7
+ * @docs-private
8
+ */
9
+ function throwNullPortalError() {
10
+ throw Error('Must provide a portal to attach');
11
+ }
12
+ /**
13
+ * Throws an exception when attempting to attach a portal to a host that is already attached.
14
+ * @docs-private
15
+ */
16
+ function throwPortalAlreadyAttachedError() {
17
+ throw Error('Host already has a portal attached');
18
+ }
19
+ /**
20
+ * Throws an exception when attempting to attach a portal to an already-disposed host.
21
+ * @docs-private
22
+ */
23
+ function throwPortalOutletAlreadyDisposedError() {
24
+ throw Error('This PortalOutlet has already been disposed');
25
+ }
26
+ /**
27
+ * Throws an exception when attempting to attach an unknown portal type.
28
+ * @docs-private
29
+ */
30
+ function throwUnknownPortalTypeError() {
31
+ throw Error('Attempting to attach an unknown Portal type. BasePortalOutlet accepts either ' +
32
+ 'a ComponentPortal or a TemplatePortal.');
33
+ }
34
+ /**
35
+ * Throws an exception when attempting to attach a portal to a null host.
36
+ * @docs-private
37
+ */
38
+ function throwNullPortalOutletError() {
39
+ throw Error('Attempting to attach a portal to a null PortalOutlet');
40
+ }
41
+ /**
42
+ * Throws an exception when attempting to detach a portal that is not attached.
43
+ * @docs-private
44
+ */
45
+ function throwNoPortalAttachedError() {
46
+ throw Error('Attempting to detach a portal that is not attached to a host');
47
+ }
48
+
49
+ /**
50
+ * A `Portal` is something that you want to render somewhere else.
51
+ * It can be attach to / detached from a `PortalOutlet`.
52
+ */
53
+ class Portal {
54
+ _attachedHost;
55
+ /** Attach this portal to a host. */
56
+ attach(host) {
57
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
58
+ if (host == null) {
59
+ throwNullPortalOutletError();
60
+ }
61
+ if (host.hasAttached()) {
62
+ throwPortalAlreadyAttachedError();
63
+ }
64
+ }
65
+ this._attachedHost = host;
66
+ return host.attach(this);
67
+ }
68
+ /** Detach this portal from its host */
69
+ detach() {
70
+ let host = this._attachedHost;
71
+ if (host != null) {
72
+ this._attachedHost = null;
73
+ host.detach();
74
+ }
75
+ else if (typeof ngDevMode === 'undefined' || ngDevMode) {
76
+ throwNoPortalAttachedError();
77
+ }
78
+ }
79
+ /** Whether this portal is attached to a host. */
80
+ get isAttached() {
81
+ return this._attachedHost != null;
82
+ }
83
+ /**
84
+ * Sets the PortalOutlet reference without performing `attach()`. This is used directly by
85
+ * the PortalOutlet when it is performing an `attach()` or `detach()`.
86
+ */
87
+ setAttachedHost(host) {
88
+ this._attachedHost = host;
89
+ }
90
+ }
91
+ /**
92
+ * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
93
+ */
94
+ class ComponentPortal extends Portal {
95
+ /** The type of the component that will be instantiated for attachment. */
96
+ component;
97
+ /**
98
+ * Where the attached component should live in Angular's *logical* component tree.
99
+ * This is different from where the component *renders*, which is determined by the PortalOutlet.
100
+ * The origin is necessary when the host is outside of the Angular application context.
101
+ */
102
+ viewContainerRef;
103
+ /** Injector used for the instantiation of the component. */
104
+ injector;
105
+ /**
106
+ * List of DOM nodes that should be projected through `<ng-content>` of the attached component.
107
+ */
108
+ projectableNodes;
109
+ constructor(component, viewContainerRef, injector, projectableNodes) {
110
+ super();
111
+ this.component = component;
112
+ this.viewContainerRef = viewContainerRef;
113
+ this.injector = injector;
114
+ this.projectableNodes = projectableNodes;
115
+ }
116
+ }
117
+ /**
118
+ * A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).
119
+ */
120
+ class TemplatePortal extends Portal {
121
+ templateRef;
122
+ viewContainerRef;
123
+ context;
124
+ injector;
125
+ constructor(
126
+ /** The embedded template that will be used to instantiate an embedded View in the host. */
127
+ templateRef,
128
+ /** Reference to the ViewContainer into which the template will be stamped out. */
129
+ viewContainerRef,
130
+ /** Contextual data to be passed in to the embedded view. */
131
+ context,
132
+ /** The injector to use for the embedded view. */
133
+ injector) {
134
+ super();
135
+ this.templateRef = templateRef;
136
+ this.viewContainerRef = viewContainerRef;
137
+ this.context = context;
138
+ this.injector = injector;
139
+ }
140
+ get origin() {
141
+ return this.templateRef.elementRef;
142
+ }
143
+ /**
144
+ * Attach the portal to the provided `PortalOutlet`.
145
+ * When a context is provided it will override the `context` property of the `TemplatePortal`
146
+ * instance.
147
+ */
148
+ attach(host, context = this.context) {
149
+ this.context = context;
150
+ return super.attach(host);
151
+ }
152
+ detach() {
153
+ this.context = undefined;
154
+ return super.detach();
155
+ }
156
+ }
157
+ /**
158
+ * A `DomPortal` is a portal whose DOM element will be taken from its current position
159
+ * in the DOM and moved into a portal outlet, when it is attached. On detach, the content
160
+ * will be restored to its original position.
161
+ */
162
+ class DomPortal extends Portal {
163
+ /** DOM node hosting the portal's content. */
164
+ element;
165
+ constructor(element) {
166
+ super();
167
+ this.element = element instanceof ElementRef ? element.nativeElement : element;
168
+ }
169
+ }
170
+ /**
171
+ * Partial implementation of PortalOutlet that handles attaching
172
+ * ComponentPortal and TemplatePortal.
173
+ */
174
+ class BasePortalOutlet {
175
+ /** The portal currently attached to the host. */
176
+ _attachedPortal;
177
+ /** A function that will permanently dispose this host. */
178
+ _disposeFn;
179
+ /** Whether this host has already been permanently disposed. */
180
+ _isDisposed = false;
181
+ /** Whether this host has an attached portal. */
182
+ hasAttached() {
183
+ return !!this._attachedPortal;
184
+ }
185
+ /** Attaches a portal. */
186
+ attach(portal) {
187
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
188
+ if (!portal) {
189
+ throwNullPortalError();
190
+ }
191
+ if (this.hasAttached()) {
192
+ throwPortalAlreadyAttachedError();
193
+ }
194
+ if (this._isDisposed) {
195
+ throwPortalOutletAlreadyDisposedError();
196
+ }
197
+ }
198
+ if (portal instanceof ComponentPortal) {
199
+ this._attachedPortal = portal;
200
+ return this.attachComponentPortal(portal);
201
+ }
202
+ else if (portal instanceof TemplatePortal) {
203
+ this._attachedPortal = portal;
204
+ return this.attachTemplatePortal(portal);
205
+ // @breaking-change 10.0.0 remove null check for `this.attachDomPortal`.
206
+ }
207
+ else if (this.attachDomPortal && portal instanceof DomPortal) {
208
+ this._attachedPortal = portal;
209
+ return this.attachDomPortal(portal);
210
+ }
211
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
212
+ throwUnknownPortalTypeError();
213
+ }
214
+ }
215
+ // @breaking-change 10.0.0 `attachDomPortal` to become a required abstract method.
216
+ attachDomPortal = null;
217
+ /** Detaches a previously attached portal. */
218
+ detach() {
219
+ if (this._attachedPortal) {
220
+ this._attachedPortal.setAttachedHost(null);
221
+ this._attachedPortal = null;
222
+ }
223
+ this._invokeDisposeFn();
224
+ }
225
+ /** Permanently dispose of this portal host. */
226
+ dispose() {
227
+ if (this.hasAttached()) {
228
+ this.detach();
229
+ }
230
+ this._invokeDisposeFn();
231
+ this._isDisposed = true;
232
+ }
233
+ /** @docs-private */
234
+ setDisposeFn(fn) {
235
+ this._disposeFn = fn;
236
+ }
237
+ _invokeDisposeFn() {
238
+ if (this._disposeFn) {
239
+ this._disposeFn();
240
+ this._disposeFn = null;
241
+ }
242
+ }
243
+ }
244
+
245
+ /**
246
+ * A PortalOutlet for attaching portals to an arbitrary DOM element outside of the Angular
247
+ * application context.
248
+ */
249
+ class DomPortalOutlet extends BasePortalOutlet {
250
+ outletElement;
251
+ _appRef;
252
+ _defaultInjector;
253
+ /**
254
+ * @param outletElement Element into which the content is projected.
255
+ * @param _appRef Reference to the application. Only used in component portals when there
256
+ * is no `ViewContainerRef` available.
257
+ * @param _defaultInjector Injector to use as a fallback when the portal being attached doesn't
258
+ * have one. Only used for component portals.
259
+ */
260
+ constructor(
261
+ /** Element into which the content is projected. */
262
+ outletElement, _appRef, _defaultInjector) {
263
+ super();
264
+ this.outletElement = outletElement;
265
+ this._appRef = _appRef;
266
+ this._defaultInjector = _defaultInjector;
267
+ }
268
+ /**
269
+ * Attach the given ComponentPortal to DOM element.
270
+ * @param portal Portal to be attached
271
+ * @returns Reference to the created component.
272
+ */
273
+ attachComponentPortal(portal) {
274
+ let componentRef;
275
+ // If the portal specifies a ViewContainerRef, we will use that as the attachment point
276
+ // for the component (in terms of Angular's component tree, not rendering).
277
+ // When the ViewContainerRef is missing, we use the factory to create the component directly
278
+ // and then manually attach the view to the application.
279
+ if (portal.viewContainerRef) {
280
+ const injector = portal.injector || portal.viewContainerRef.injector;
281
+ const ngModuleRef = injector.get(NgModuleRef, null, { optional: true }) || undefined;
282
+ componentRef = portal.viewContainerRef.createComponent(portal.component, {
283
+ index: portal.viewContainerRef.length,
284
+ injector,
285
+ ngModuleRef,
286
+ projectableNodes: portal.projectableNodes || undefined,
287
+ });
288
+ this.setDisposeFn(() => componentRef.destroy());
289
+ }
290
+ else {
291
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._appRef) {
292
+ throw Error('Cannot attach component portal to outlet without an ApplicationRef.');
293
+ }
294
+ const appRef = this._appRef;
295
+ const elementInjector = portal.injector || this._defaultInjector || Injector.NULL;
296
+ const environmentInjector = elementInjector.get(EnvironmentInjector, appRef.injector);
297
+ componentRef = createComponent(portal.component, {
298
+ elementInjector,
299
+ environmentInjector,
300
+ projectableNodes: portal.projectableNodes || undefined,
301
+ });
302
+ appRef.attachView(componentRef.hostView);
303
+ this.setDisposeFn(() => {
304
+ // Verify that the ApplicationRef has registered views before trying to detach a host view.
305
+ // This check also protects the `detachView` from being called on a destroyed ApplicationRef.
306
+ if (appRef.viewCount > 0) {
307
+ appRef.detachView(componentRef.hostView);
308
+ }
309
+ componentRef.destroy();
310
+ });
311
+ }
312
+ // At this point the component has been instantiated, so we move it to the location in the DOM
313
+ // where we want it to be rendered.
314
+ this.outletElement.appendChild(this._getComponentRootNode(componentRef));
315
+ this._attachedPortal = portal;
316
+ return componentRef;
317
+ }
318
+ /**
319
+ * Attaches a template portal to the DOM as an embedded view.
320
+ * @param portal Portal to be attached.
321
+ * @returns Reference to the created embedded view.
322
+ */
323
+ attachTemplatePortal(portal) {
324
+ let viewContainer = portal.viewContainerRef;
325
+ let viewRef = viewContainer.createEmbeddedView(portal.templateRef, portal.context, {
326
+ injector: portal.injector,
327
+ });
328
+ // The method `createEmbeddedView` will add the view as a child of the viewContainer.
329
+ // But for the DomPortalOutlet the view can be added everywhere in the DOM
330
+ // (e.g Overlay Container) To move the view to the specified host element. We just
331
+ // re-append the existing root nodes.
332
+ viewRef.rootNodes.forEach(rootNode => this.outletElement.appendChild(rootNode));
333
+ // Note that we want to detect changes after the nodes have been moved so that
334
+ // any directives inside the portal that are looking at the DOM inside a lifecycle
335
+ // hook won't be invoked too early.
336
+ viewRef.detectChanges();
337
+ this.setDisposeFn(() => {
338
+ let index = viewContainer.indexOf(viewRef);
339
+ if (index !== -1) {
340
+ viewContainer.remove(index);
341
+ }
342
+ });
343
+ this._attachedPortal = portal;
344
+ // TODO(jelbourn): Return locals from view.
345
+ return viewRef;
346
+ }
347
+ /**
348
+ * Attaches a DOM portal by transferring its content into the outlet.
349
+ * @param portal Portal to be attached.
350
+ * @deprecated To be turned into a method.
351
+ * @breaking-change 10.0.0
352
+ */
353
+ attachDomPortal = (portal) => {
354
+ const element = portal.element;
355
+ if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {
356
+ throw Error('DOM portal content must be attached to a parent node.');
357
+ }
358
+ // Anchor used to save the element's previous position so
359
+ // that we can restore it when the portal is detached.
360
+ const anchorNode = this.outletElement.ownerDocument.createComment('dom-portal');
361
+ element.parentNode.insertBefore(anchorNode, element);
362
+ this.outletElement.appendChild(element);
363
+ this._attachedPortal = portal;
364
+ super.setDisposeFn(() => {
365
+ // We can't use `replaceWith` here because IE doesn't support it.
366
+ if (anchorNode.parentNode) {
367
+ anchorNode.parentNode.replaceChild(element, anchorNode);
368
+ }
369
+ });
370
+ };
371
+ /**
372
+ * Clears out a portal from the DOM.
373
+ */
374
+ dispose() {
375
+ super.dispose();
376
+ this.outletElement.remove();
377
+ }
378
+ /** Gets the root HTMLElement for an instantiated component. */
379
+ _getComponentRootNode(componentRef) {
380
+ return componentRef.hostView.rootNodes[0];
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Directive version of a `TemplatePortal`. Because the directive *is* a TemplatePortal,
386
+ * the directive instance itself can be attached to a host, enabling declarative use of portals.
387
+ */
388
+ class CdkPortal extends TemplatePortal {
389
+ constructor() {
390
+ const templateRef = inject(TemplateRef);
391
+ const viewContainerRef = inject(ViewContainerRef);
392
+ super(templateRef, viewContainerRef);
393
+ }
394
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CdkPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive });
395
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: CdkPortal, isStandalone: true, selector: "[cdkPortal]", exportAs: ["cdkPortal"], usesInheritance: true, ngImport: i0 });
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CdkPortal, decorators: [{
398
+ type: Directive,
399
+ args: [{
400
+ selector: '[cdkPortal]',
401
+ exportAs: 'cdkPortal',
402
+ }]
403
+ }], ctorParameters: () => [] });
404
+ /**
405
+ * @deprecated Use `CdkPortal` instead.
406
+ * @breaking-change 9.0.0
407
+ */
408
+ class TemplatePortalDirective extends CdkPortal {
409
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: TemplatePortalDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
410
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: TemplatePortalDirective, isStandalone: true, selector: "[cdk-portal], [portal]", providers: [
411
+ {
412
+ provide: CdkPortal,
413
+ useExisting: TemplatePortalDirective,
414
+ },
415
+ ], exportAs: ["cdkPortal"], usesInheritance: true, ngImport: i0 });
416
+ }
417
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: TemplatePortalDirective, decorators: [{
418
+ type: Directive,
419
+ args: [{
420
+ selector: '[cdk-portal], [portal]',
421
+ exportAs: 'cdkPortal',
422
+ providers: [
423
+ {
424
+ provide: CdkPortal,
425
+ useExisting: TemplatePortalDirective,
426
+ },
427
+ ],
428
+ }]
429
+ }] });
430
+ /**
431
+ * Directive version of a PortalOutlet. Because the directive *is* a PortalOutlet, portals can be
432
+ * directly attached to it, enabling declarative use.
433
+ *
434
+ * Usage:
435
+ * `<ng-template [cdkPortalOutlet]="greeting"></ng-template>`
436
+ */
437
+ class CdkPortalOutlet extends BasePortalOutlet {
438
+ _moduleRef = inject(NgModuleRef, { optional: true });
439
+ _document = inject(DOCUMENT);
440
+ _viewContainerRef = inject(ViewContainerRef);
441
+ /** Whether the portal component is initialized. */
442
+ _isInitialized = false;
443
+ /** Reference to the currently-attached component/view ref. */
444
+ _attachedRef;
445
+ constructor() {
446
+ super();
447
+ }
448
+ /** Portal associated with the Portal outlet. */
449
+ get portal() {
450
+ return this._attachedPortal;
451
+ }
452
+ set portal(portal) {
453
+ // Ignore the cases where the `portal` is set to a falsy value before the lifecycle hooks have
454
+ // run. This handles the cases where the user might do something like `<div cdkPortalOutlet>`
455
+ // and attach a portal programmatically in the parent component. When Angular does the first CD
456
+ // round, it will fire the setter with empty string, causing the user's content to be cleared.
457
+ if (this.hasAttached() && !portal && !this._isInitialized) {
458
+ return;
459
+ }
460
+ if (this.hasAttached()) {
461
+ super.detach();
462
+ }
463
+ if (portal) {
464
+ super.attach(portal);
465
+ }
466
+ this._attachedPortal = portal || null;
467
+ }
468
+ /** Emits when a portal is attached to the outlet. */
469
+ attached = new EventEmitter();
470
+ /** Component or view reference that is attached to the portal. */
471
+ get attachedRef() {
472
+ return this._attachedRef;
473
+ }
474
+ ngOnInit() {
475
+ this._isInitialized = true;
476
+ }
477
+ ngOnDestroy() {
478
+ super.dispose();
479
+ this._attachedRef = this._attachedPortal = null;
480
+ }
481
+ /**
482
+ * Attach the given ComponentPortal to this PortalOutlet.
483
+ *
484
+ * @param portal Portal to be attached to the portal outlet.
485
+ * @returns Reference to the created component.
486
+ */
487
+ attachComponentPortal(portal) {
488
+ portal.setAttachedHost(this);
489
+ // If the portal specifies an origin, use that as the logical location of the component
490
+ // in the application tree. Otherwise use the location of this PortalOutlet.
491
+ const viewContainerRef = portal.viewContainerRef != null ? portal.viewContainerRef : this._viewContainerRef;
492
+ const ref = viewContainerRef.createComponent(portal.component, {
493
+ index: viewContainerRef.length,
494
+ injector: portal.injector || viewContainerRef.injector,
495
+ projectableNodes: portal.projectableNodes || undefined,
496
+ ngModuleRef: this._moduleRef || undefined,
497
+ });
498
+ // If we're using a view container that's different from the injected one (e.g. when the portal
499
+ // specifies its own) we need to move the component into the outlet, otherwise it'll be rendered
500
+ // inside of the alternate view container.
501
+ if (viewContainerRef !== this._viewContainerRef) {
502
+ this._getRootNode().appendChild(ref.hostView.rootNodes[0]);
503
+ }
504
+ super.setDisposeFn(() => ref.destroy());
505
+ this._attachedPortal = portal;
506
+ this._attachedRef = ref;
507
+ this.attached.emit(ref);
508
+ return ref;
509
+ }
510
+ /**
511
+ * Attach the given TemplatePortal to this PortalHost as an embedded View.
512
+ * @param portal Portal to be attached.
513
+ * @returns Reference to the created embedded view.
514
+ */
515
+ attachTemplatePortal(portal) {
516
+ portal.setAttachedHost(this);
517
+ const viewRef = this._viewContainerRef.createEmbeddedView(portal.templateRef, portal.context, {
518
+ injector: portal.injector,
519
+ });
520
+ super.setDisposeFn(() => this._viewContainerRef.clear());
521
+ this._attachedPortal = portal;
522
+ this._attachedRef = viewRef;
523
+ this.attached.emit(viewRef);
524
+ return viewRef;
525
+ }
526
+ /**
527
+ * Attaches the given DomPortal to this PortalHost by moving all of the portal content into it.
528
+ * @param portal Portal to be attached.
529
+ * @deprecated To be turned into a method.
530
+ * @breaking-change 10.0.0
531
+ */
532
+ attachDomPortal = (portal) => {
533
+ const element = portal.element;
534
+ if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {
535
+ throw Error('DOM portal content must be attached to a parent node.');
536
+ }
537
+ // Anchor used to save the element's previous position so
538
+ // that we can restore it when the portal is detached.
539
+ const anchorNode = this._document.createComment('dom-portal');
540
+ portal.setAttachedHost(this);
541
+ element.parentNode.insertBefore(anchorNode, element);
542
+ this._getRootNode().appendChild(element);
543
+ this._attachedPortal = portal;
544
+ super.setDisposeFn(() => {
545
+ if (anchorNode.parentNode) {
546
+ anchorNode.parentNode.replaceChild(element, anchorNode);
547
+ }
548
+ });
549
+ };
550
+ /** Gets the root node of the portal outlet. */
551
+ _getRootNode() {
552
+ const nativeElement = this._viewContainerRef.element.nativeElement;
553
+ // The directive could be set on a template which will result in a comment
554
+ // node being the root. Use the comment's parent node if that is the case.
555
+ return (nativeElement.nodeType === nativeElement.ELEMENT_NODE
556
+ ? nativeElement
557
+ : nativeElement.parentNode);
558
+ }
559
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CdkPortalOutlet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
560
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: CdkPortalOutlet, isStandalone: true, selector: "[cdkPortalOutlet]", inputs: { portal: ["cdkPortalOutlet", "portal"] }, outputs: { attached: "attached" }, exportAs: ["cdkPortalOutlet"], usesInheritance: true, ngImport: i0 });
561
+ }
562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: CdkPortalOutlet, decorators: [{
563
+ type: Directive,
564
+ args: [{
565
+ selector: '[cdkPortalOutlet]',
566
+ exportAs: 'cdkPortalOutlet',
567
+ }]
568
+ }], ctorParameters: () => [], propDecorators: { portal: [{
569
+ type: Input,
570
+ args: ['cdkPortalOutlet']
571
+ }], attached: [{
572
+ type: Output
573
+ }] } });
574
+ /**
575
+ * @deprecated Use `CdkPortalOutlet` instead.
576
+ * @breaking-change 9.0.0
577
+ */
578
+ class PortalHostDirective extends CdkPortalOutlet {
579
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalHostDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
580
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.5", type: PortalHostDirective, isStandalone: true, selector: "[cdkPortalHost], [portalHost]", inputs: { portal: ["cdkPortalHost", "portal"] }, providers: [
581
+ {
582
+ provide: CdkPortalOutlet,
583
+ useExisting: PortalHostDirective,
584
+ },
585
+ ], exportAs: ["cdkPortalHost"], usesInheritance: true, ngImport: i0 });
586
+ }
587
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalHostDirective, decorators: [{
588
+ type: Directive,
589
+ args: [{
590
+ selector: '[cdkPortalHost], [portalHost]',
591
+ exportAs: 'cdkPortalHost',
592
+ inputs: [{ name: 'portal', alias: 'cdkPortalHost' }],
593
+ providers: [
594
+ {
595
+ provide: CdkPortalOutlet,
596
+ useExisting: PortalHostDirective,
597
+ },
598
+ ],
599
+ }]
600
+ }] });
601
+ class PortalModule {
602
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
603
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalModule, imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective], exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective] });
604
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalModule });
605
+ }
606
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.5", ngImport: i0, type: PortalModule, decorators: [{
607
+ type: NgModule,
608
+ args: [{
609
+ imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
610
+ exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],
611
+ }]
612
+ }] });
613
+
614
+ export { BasePortalOutlet, CdkPortal, CdkPortalOutlet, ComponentPortal, DomPortal, DomPortalOutlet, Portal, PortalHostDirective, PortalModule, TemplatePortal, TemplatePortalDirective };
4
615
  //# sourceMappingURL=portal.mjs.map