@angular/cdk 20.0.0-next.6 → 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 (173) hide show
  1. package/a11y/index.d.ts +10 -11
  2. package/{a11y-module.d-9e4162d8.d.ts → a11y-module.d-DrV0SO0k.d.ts} +4 -4
  3. package/a11y-prebuilt.css +1 -1
  4. package/accordion/index.d.ts +2 -2
  5. package/{activedescendant-key-manager.d-8f004111.d.ts → activedescendant-key-manager.d-DSYvyoT0.d.ts} +3 -3
  6. package/bidi/index.d.ts +1 -1
  7. package/{bidi-module.d-e02fd94c.d.ts → bidi-module.d-bsVYOt0R.d.ts} +2 -2
  8. package/clipboard/index.d.ts +1 -1
  9. package/coercion/index.d.ts +1 -1
  10. package/collections/index.d.ts +8 -8
  11. package/{data-source.d-7eda4d9a.d.ts → data-source.d-DAIyaEMO.d.ts} +2 -2
  12. package/dialog/index.d.ts +16 -16
  13. package/drag-drop/index.d.ts +6 -6
  14. package/fesm2022/{a11y-module-3f18e5c2.mjs → a11y-module-tRUj0Pog.mjs} +10 -10
  15. package/fesm2022/{a11y-module-3f18e5c2.mjs.map → a11y-module-tRUj0Pog.mjs.map} +1 -1
  16. package/fesm2022/a11y.mjs +24 -24
  17. package/fesm2022/a11y.mjs.map +1 -1
  18. package/fesm2022/accordion.mjs +3 -3
  19. package/fesm2022/accordion.mjs.map +1 -1
  20. package/fesm2022/{activedescendant-key-manager-ca3e95bd.mjs → activedescendant-key-manager-BYiHZAZc.mjs} +3 -3
  21. package/fesm2022/{activedescendant-key-manager-ca3e95bd.mjs.map → activedescendant-key-manager-BYiHZAZc.mjs.map} +1 -1
  22. package/fesm2022/{array-88204b72.mjs → array-Hg8isvLj.mjs} +2 -2
  23. package/fesm2022/{array-88204b72.mjs.map → array-Hg8isvLj.mjs.map} +1 -1
  24. package/fesm2022/bidi.mjs +77 -3
  25. package/fesm2022/bidi.mjs.map +1 -1
  26. package/fesm2022/{breakpoints-observer-9d296976.mjs → breakpoints-observer-CsCzbYlX.mjs} +4 -4
  27. package/fesm2022/{breakpoints-observer-9d296976.mjs.map → breakpoints-observer-CsCzbYlX.mjs.map} +1 -1
  28. package/fesm2022/cdk.mjs +1 -1
  29. package/fesm2022/cdk.mjs.map +1 -1
  30. package/fesm2022/clipboard.mjs +1 -1
  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-5ab12b77.mjs → css-pixel-value-C1yoKJ7R.mjs} +2 -2
  38. package/fesm2022/{css-pixel-value-5ab12b77.mjs.map → css-pixel-value-C1yoKJ7R.mjs.map} +1 -1
  39. package/fesm2022/{data-source-a3a3a257.mjs → data-source-CL6Fasig.mjs} +2 -2
  40. package/fesm2022/{data-source-a3a3a257.mjs.map → data-source-CL6Fasig.mjs.map} +1 -1
  41. package/fesm2022/dialog.mjs +38 -38
  42. package/fesm2022/dialog.mjs.map +1 -1
  43. package/fesm2022/{directionality-25132624.mjs → directionality-6lVHj23y.mjs} +2 -2
  44. package/fesm2022/{directionality-25132624.mjs.map → directionality-6lVHj23y.mjs.map} +1 -1
  45. package/fesm2022/{dispose-view-repeater-strategy-0bf96031.mjs → dispose-view-repeater-strategy-BLw1RSwm.mjs} +3 -3
  46. package/fesm2022/{dispose-view-repeater-strategy-0bf96031.mjs.map → dispose-view-repeater-strategy-BLw1RSwm.mjs.map} +1 -1
  47. package/fesm2022/drag-drop.mjs +17 -17
  48. package/fesm2022/drag-drop.mjs.map +1 -1
  49. package/fesm2022/{element-bed495ef.mjs → element-CpqV8p-X.mjs} +2 -2
  50. package/fesm2022/{element-bed495ef.mjs.map → element-CpqV8p-X.mjs.map} +1 -1
  51. package/fesm2022/{fake-event-detection-61bf2988.mjs → fake-event-detection-D0_6qVp2.mjs} +2 -2
  52. package/fesm2022/{fake-event-detection-61bf2988.mjs.map → fake-event-detection-D0_6qVp2.mjs.map} +1 -1
  53. package/fesm2022/{focus-key-manager-f4cf48e1.mjs → focus-key-manager-DgyxYbV2.mjs} +3 -3
  54. package/fesm2022/{focus-key-manager-f4cf48e1.mjs.map → focus-key-manager-DgyxYbV2.mjs.map} +1 -1
  55. package/fesm2022/{focus-monitor-4af46fa6.mjs → focus-monitor-BZnK-7fT.mjs} +9 -9
  56. package/fesm2022/{focus-monitor-4af46fa6.mjs.map → focus-monitor-BZnK-7fT.mjs.map} +1 -1
  57. package/fesm2022/{id-generator-dd03740e.mjs → id-generator-B33AfkWd.mjs} +2 -2
  58. package/fesm2022/{id-generator-dd03740e.mjs.map → id-generator-B33AfkWd.mjs.map} +1 -1
  59. package/fesm2022/{keycodes-fbdb6e67.mjs → keycodes-DPWmI2Ix.mjs} +2 -2
  60. package/fesm2022/{keycodes-fbdb6e67.mjs.map → keycodes-DPWmI2Ix.mjs.map} +1 -1
  61. package/fesm2022/keycodes.mjs +14 -2
  62. package/fesm2022/keycodes.mjs.map +1 -1
  63. package/fesm2022/layout.mjs +3 -3
  64. package/fesm2022/layout.mjs.map +1 -1
  65. package/fesm2022/{list-key-manager-0ce9d5be.mjs → list-key-manager-CYBoL_nN.mjs} +5 -5
  66. package/fesm2022/{list-key-manager-0ce9d5be.mjs.map → list-key-manager-CYBoL_nN.mjs.map} +1 -1
  67. package/fesm2022/listbox.mjs +11 -11
  68. package/fesm2022/listbox.mjs.map +1 -1
  69. package/fesm2022/menu.mjs +26 -26
  70. package/fesm2022/menu.mjs.map +1 -1
  71. package/fesm2022/observers/private.mjs.map +1 -1
  72. package/fesm2022/observers.mjs +209 -5
  73. package/fesm2022/observers.mjs.map +1 -1
  74. package/fesm2022/{overlay-module-a2bddb9f.mjs → overlay-module-UgjfuiDh.mjs} +19 -19
  75. package/fesm2022/{overlay-module-a2bddb9f.mjs.map → overlay-module-UgjfuiDh.mjs.map} +1 -1
  76. package/fesm2022/overlay.mjs +20 -20
  77. package/fesm2022/overlay.mjs.map +1 -1
  78. package/fesm2022/{passive-listeners-1189a3bc.mjs → passive-listeners-ZmZRMx8D.mjs} +2 -2
  79. package/fesm2022/{passive-listeners-1189a3bc.mjs.map → passive-listeners-ZmZRMx8D.mjs.map} +1 -1
  80. package/fesm2022/{platform-3b280dd2.mjs → platform-BInyKIh1.mjs} +2 -2
  81. package/fesm2022/{platform-3b280dd2.mjs.map → platform-BInyKIh1.mjs.map} +1 -1
  82. package/fesm2022/platform.mjs +5 -5
  83. package/fesm2022/platform.mjs.map +1 -1
  84. package/fesm2022/portal.mjs +614 -3
  85. package/fesm2022/portal.mjs.map +1 -1
  86. package/fesm2022/private.mjs +18 -3
  87. package/fesm2022/private.mjs.map +1 -1
  88. package/fesm2022/{recycle-view-repeater-strategy-7fe34ce5.mjs → recycle-view-repeater-strategy-Ce0p4WhD.mjs} +4 -4
  89. package/fesm2022/{recycle-view-repeater-strategy-7fe34ce5.mjs.map → recycle-view-repeater-strategy-Ce0p4WhD.mjs.map} +1 -1
  90. package/fesm2022/{scrolling-4b9e82b7.mjs → scrolling-BXVcIfjZ.mjs} +2 -2
  91. package/fesm2022/{scrolling-4b9e82b7.mjs.map → scrolling-BXVcIfjZ.mjs.map} +1 -1
  92. package/fesm2022/scrolling.mjs +1463 -12
  93. package/fesm2022/scrolling.mjs.map +1 -1
  94. package/fesm2022/{selection-model-7800ff2c.mjs → selection-model-88BErm4w.mjs} +2 -2
  95. package/fesm2022/{selection-model-7800ff2c.mjs.map → selection-model-88BErm4w.mjs.map} +1 -1
  96. package/fesm2022/{shadow-dom-09da63d7.mjs → shadow-dom-DFvX9W95.mjs} +2 -2
  97. package/fesm2022/{shadow-dom-09da63d7.mjs.map → shadow-dom-DFvX9W95.mjs.map} +1 -1
  98. package/fesm2022/stepper.mjs +10 -10
  99. package/fesm2022/stepper.mjs.map +1 -1
  100. package/fesm2022/{style-loader-f70e1cd6.mjs → style-loader-DpEDdstc.mjs} +2 -2
  101. package/fesm2022/{style-loader-f70e1cd6.mjs.map → style-loader-DpEDdstc.mjs.map} +1 -1
  102. package/fesm2022/table.mjs +13 -13
  103. package/fesm2022/table.mjs.map +1 -1
  104. package/fesm2022/{test-environment-75e095b5.mjs → test-environment-BgaaXvCA.mjs} +2 -2
  105. package/fesm2022/{test-environment-75e095b5.mjs.map → test-environment-BgaaXvCA.mjs.map} +1 -1
  106. package/fesm2022/testing/selenium-webdriver.mjs +1 -1
  107. package/fesm2022/testing/selenium-webdriver.mjs.map +1 -1
  108. package/fesm2022/testing/testbed.mjs +2 -2
  109. package/fesm2022/testing/testbed.mjs.map +1 -1
  110. package/fesm2022/testing.mjs +697 -2
  111. package/fesm2022/testing.mjs.map +1 -1
  112. package/fesm2022/text-field.mjs +6 -6
  113. package/fesm2022/text-field.mjs.map +1 -1
  114. package/fesm2022/{tree-key-manager-fb779925.mjs → tree-key-manager-DIhQ-v4R.mjs} +5 -5
  115. package/fesm2022/{tree-key-manager-fb779925.mjs.map → tree-key-manager-DIhQ-v4R.mjs.map} +1 -1
  116. package/fesm2022/tree.mjs +8 -8
  117. package/fesm2022/tree.mjs.map +1 -1
  118. package/fesm2022/{typeahead-5b1c5e41.mjs → typeahead-BAa3HZoh.mjs} +3 -3
  119. package/fesm2022/{typeahead-5b1c5e41.mjs.map → typeahead-BAa3HZoh.mjs.map} +1 -1
  120. package/fesm2022/{unique-selection-dispatcher-95d71775.mjs → unique-selection-dispatcher-SqPM2COI.mjs} +2 -2
  121. package/fesm2022/{unique-selection-dispatcher-95d71775.mjs.map → unique-selection-dispatcher-SqPM2COI.mjs.map} +1 -1
  122. package/{focus-key-manager.d-808a8cfc.d.ts → focus-key-manager.d-DCiEwxN7.d.ts} +4 -4
  123. package/{focus-monitor.d-463f4526.d.ts → focus-monitor.d-BBkiOKUH.d.ts} +2 -2
  124. package/{harness-environment.d-ccca6bee.d.ts → harness-environment.d-ByFLvxZh.d.ts} +2 -2
  125. package/{list-key-manager.d-6b8e8454.d.ts → list-key-manager.d-CylnKWfo.d.ts} +2 -2
  126. package/listbox/index.d.ts +3 -3
  127. package/menu/index.d.ts +12 -12
  128. package/{number-property.d-1067cb21.d.ts → number-property.d-BzBQchZ2.d.ts} +2 -2
  129. package/observers/index.d.ts +84 -4
  130. package/overlay/_index.scss +4 -1
  131. package/overlay/index.d.ts +12 -13
  132. package/{overlay-module.d-bb9fd227.d.ts → overlay-module.d-24bhgNtF.d.ts} +8 -8
  133. package/overlay-prebuilt.css +1 -1
  134. package/package.json +1 -1
  135. package/platform/index.d.ts +1 -1
  136. package/{platform.d-54a48c5c.d.ts → platform.d-cnFZCLss.d.ts} +1 -1
  137. package/portal/index.d.ts +3 -3
  138. package/{portal-directives.d-7048496c.d.ts → portal-directives.d-D9c4J36c.d.ts} +2 -2
  139. package/private/index.d.ts +1 -1
  140. package/schematics/ng-add/index.js +1 -1
  141. package/scrolling/index.d.ts +62 -7
  142. package/{scrolling-module.d-a309d6c8.d.ts → scrolling-module.d-CuNwYGVM.d.ts} +6 -6
  143. package/{selection-model.d-8f93f170.d.ts → selection-model.d-CHuTS0tw.d.ts} +2 -2
  144. package/stepper/index.d.ts +5 -5
  145. package/{style-loader.d-a4916e34.d.ts → style-loader.d-DbvWk0ty.d.ts} +1 -1
  146. package/table/index.d.ts +6 -7
  147. package/testing/index.d.ts +1 -1
  148. package/testing/selenium-webdriver/index.d.ts +1 -1
  149. package/testing/testbed/index.d.ts +1 -1
  150. package/text-field/index.d.ts +1 -1
  151. package/text-field-prebuilt.css +1 -1
  152. package/tree/index.d.ts +4 -4
  153. package/{tree-key-manager-strategy.d-e1a4bb7c.d.ts → tree-key-manager-strategy.d-DipnXoCr.d.ts} +1 -1
  154. package/{unique-selection-dispatcher.d-49e3cd5f.d.ts → unique-selection-dispatcher.d-BgWACqWn.d.ts} +2 -2
  155. package/{view-repeater.d-bf5e36f0.d.ts → view-repeater.d-CJ9e48MX.d.ts} +3 -3
  156. package/fesm2022/bidi-module-93941905.mjs +0 -77
  157. package/fesm2022/bidi-module-93941905.mjs.map +0 -1
  158. package/fesm2022/modifiers-68a3bc3a.mjs +0 -13
  159. package/fesm2022/modifiers-68a3bc3a.mjs.map +0 -1
  160. package/fesm2022/observable-36bb5527.mjs +0 -15
  161. package/fesm2022/observable-36bb5527.mjs.map +0 -1
  162. package/fesm2022/observe-content-85983868.mjs +0 -210
  163. package/fesm2022/observe-content-85983868.mjs.map +0 -1
  164. package/fesm2022/portal-directives-4da94e82.mjs +0 -615
  165. package/fesm2022/portal-directives-4da94e82.mjs.map +0 -1
  166. package/fesm2022/scrolling-module-2ed090a6.mjs +0 -1463
  167. package/fesm2022/scrolling-module-2ed090a6.mjs.map +0 -1
  168. package/fesm2022/text-filtering-682c2e05.mjs +0 -698
  169. package/fesm2022/text-filtering-682c2e05.mjs.map +0 -1
  170. package/fesm2022/visually-hidden-912d0ccc.mjs +0 -18
  171. package/fesm2022/visually-hidden-912d0ccc.mjs.map +0 -1
  172. package/observe-content.d-406532a1.d.ts +0 -84
  173. package/viewport-ruler.d-5b507354.d.ts +0 -58
@@ -1,698 +0,0 @@
1
- import { BehaviorSubject } from 'rxjs';
2
-
3
- /** Subject used to dispatch and listen for changes to the auto change detection status . */
4
- const autoChangeDetectionSubject = new BehaviorSubject({
5
- isDisabled: false,
6
- });
7
- /** The current subscription to `autoChangeDetectionSubject`. */
8
- let autoChangeDetectionSubscription;
9
- /**
10
- * The default handler for auto change detection status changes. This handler will be used if the
11
- * specific environment does not install its own.
12
- * @param status The new auto change detection status.
13
- */
14
- function defaultAutoChangeDetectionHandler(status) {
15
- status.onDetectChangesNow?.();
16
- }
17
- /**
18
- * Allows a test `HarnessEnvironment` to install its own handler for auto change detection status
19
- * changes.
20
- * @param handler The handler for the auto change detection status.
21
- */
22
- function handleAutoChangeDetectionStatus(handler) {
23
- stopHandlingAutoChangeDetectionStatus();
24
- autoChangeDetectionSubscription = autoChangeDetectionSubject.subscribe(handler);
25
- }
26
- /** Allows a `HarnessEnvironment` to stop handling auto change detection status changes. */
27
- function stopHandlingAutoChangeDetectionStatus() {
28
- autoChangeDetectionSubscription?.unsubscribe();
29
- autoChangeDetectionSubscription = null;
30
- }
31
- /**
32
- * Batches together triggering of change detection over the duration of the given function.
33
- * @param fn The function to call with batched change detection.
34
- * @param triggerBeforeAndAfter Optionally trigger change detection once before and after the batch
35
- * operation. If false, change detection will not be triggered.
36
- * @return The result of the given function.
37
- */
38
- async function batchChangeDetection(fn, triggerBeforeAndAfter) {
39
- // If change detection batching is already in progress, just run the function.
40
- if (autoChangeDetectionSubject.getValue().isDisabled) {
41
- return await fn();
42
- }
43
- // If nothing is handling change detection batching, install the default handler.
44
- if (!autoChangeDetectionSubscription) {
45
- handleAutoChangeDetectionStatus(defaultAutoChangeDetectionHandler);
46
- }
47
- if (triggerBeforeAndAfter) {
48
- await new Promise(resolve => autoChangeDetectionSubject.next({
49
- isDisabled: true,
50
- onDetectChangesNow: resolve,
51
- }));
52
- // The function passed in may throw (e.g. if the user wants to make an expectation of an error
53
- // being thrown. If this happens, we need to make sure we still re-enable change detection, so
54
- // we wrap it in a `finally` block.
55
- try {
56
- return await fn();
57
- }
58
- finally {
59
- await new Promise(resolve => autoChangeDetectionSubject.next({
60
- isDisabled: false,
61
- onDetectChangesNow: resolve,
62
- }));
63
- }
64
- }
65
- else {
66
- autoChangeDetectionSubject.next({ isDisabled: true });
67
- // The function passed in may throw (e.g. if the user wants to make an expectation of an error
68
- // being thrown. If this happens, we need to make sure we still re-enable change detection, so
69
- // we wrap it in a `finally` block.
70
- try {
71
- return await fn();
72
- }
73
- finally {
74
- autoChangeDetectionSubject.next({ isDisabled: false });
75
- }
76
- }
77
- }
78
- /**
79
- * Disables the harness system's auto change detection for the duration of the given function.
80
- * @param fn The function to disable auto change detection for.
81
- * @return The result of the given function.
82
- */
83
- async function manualChangeDetection(fn) {
84
- return batchChangeDetection(fn, false);
85
- }
86
- /**
87
- * Resolves the given list of async values in parallel (i.e. via Promise.all) while batching change
88
- * detection over the entire operation such that change detection occurs exactly once before
89
- * resolving the values and once after.
90
- * @param values A getter for the async values to resolve in parallel with batched change detection.
91
- * @return The resolved values.
92
- */
93
- async function parallel(values) {
94
- return batchChangeDetection(() => Promise.all(values()), true);
95
- }
96
-
97
- /**
98
- * Base class for component harnesses that all component harness authors should extend. This base
99
- * component harness provides the basic ability to locate element and sub-component harness. It
100
- * should be inherited when defining user's own harness.
101
- */
102
- class ComponentHarness {
103
- locatorFactory;
104
- constructor(locatorFactory) {
105
- this.locatorFactory = locatorFactory;
106
- }
107
- /** Gets a `Promise` for the `TestElement` representing the host element of the component. */
108
- async host() {
109
- return this.locatorFactory.rootElement;
110
- }
111
- /**
112
- * Gets a `LocatorFactory` for the document root element. This factory can be used to create
113
- * locators for elements that a component creates outside of its own root element. (e.g. by
114
- * appending to document.body).
115
- */
116
- documentRootLocatorFactory() {
117
- return this.locatorFactory.documentRootLocatorFactory();
118
- }
119
- /**
120
- * Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
121
- * or element under the host element of this `ComponentHarness`.
122
- * @param queries A list of queries specifying which harnesses and elements to search for:
123
- * - A `string` searches for elements matching the CSS selector specified by the string.
124
- * - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
125
- * given class.
126
- * - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
127
- * predicate.
128
- * @return An asynchronous locator function that searches for and returns a `Promise` for the
129
- * first element or harness matching the given search criteria. Matches are ordered first by
130
- * order in the DOM, and second by order in the queries list. If no matches are found, the
131
- * `Promise` rejects. The type that the `Promise` resolves to is a union of all result types for
132
- * each query.
133
- *
134
- * e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
135
- * `DivHarness.hostSelector === 'div'`:
136
- * - `await ch.locatorFor(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
137
- * - `await ch.locatorFor('div', DivHarness)()` gets a `TestElement` instance for `#d1`
138
- * - `await ch.locatorFor('span')()` throws because the `Promise` rejects.
139
- */
140
- locatorFor(...queries) {
141
- return this.locatorFactory.locatorFor(...queries);
142
- }
143
- /**
144
- * Creates an asynchronous locator function that can be used to find a `ComponentHarness` instance
145
- * or element under the host element of this `ComponentHarness`.
146
- * @param queries A list of queries specifying which harnesses and elements to search for:
147
- * - A `string` searches for elements matching the CSS selector specified by the string.
148
- * - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
149
- * given class.
150
- * - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
151
- * predicate.
152
- * @return An asynchronous locator function that searches for and returns a `Promise` for the
153
- * first element or harness matching the given search criteria. Matches are ordered first by
154
- * order in the DOM, and second by order in the queries list. If no matches are found, the
155
- * `Promise` is resolved with `null`. The type that the `Promise` resolves to is a union of all
156
- * result types for each query or null.
157
- *
158
- * e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
159
- * `DivHarness.hostSelector === 'div'`:
160
- * - `await ch.locatorForOptional(DivHarness, 'div')()` gets a `DivHarness` instance for `#d1`
161
- * - `await ch.locatorForOptional('div', DivHarness)()` gets a `TestElement` instance for `#d1`
162
- * - `await ch.locatorForOptional('span')()` gets `null`.
163
- */
164
- locatorForOptional(...queries) {
165
- return this.locatorFactory.locatorForOptional(...queries);
166
- }
167
- /**
168
- * Creates an asynchronous locator function that can be used to find `ComponentHarness` instances
169
- * or elements under the host element of this `ComponentHarness`.
170
- * @param queries A list of queries specifying which harnesses and elements to search for:
171
- * - A `string` searches for elements matching the CSS selector specified by the string.
172
- * - A `ComponentHarness` constructor searches for `ComponentHarness` instances matching the
173
- * given class.
174
- * - A `HarnessPredicate` searches for `ComponentHarness` instances matching the given
175
- * predicate.
176
- * @return An asynchronous locator function that searches for and returns a `Promise` for all
177
- * elements and harnesses matching the given search criteria. Matches are ordered first by
178
- * order in the DOM, and second by order in the queries list. If an element matches more than
179
- * one `ComponentHarness` class, the locator gets an instance of each for the same element. If
180
- * an element matches multiple `string` selectors, only one `TestElement` instance is returned
181
- * for that element. The type that the `Promise` resolves to is an array where each element is
182
- * the union of all result types for each query.
183
- *
184
- * e.g. Given the following DOM: `<div id="d1" /><div id="d2" />`, and assuming
185
- * `DivHarness.hostSelector === 'div'` and `IdIsD1Harness.hostSelector === '#d1'`:
186
- * - `await ch.locatorForAll(DivHarness, 'div')()` gets `[
187
- * DivHarness, // for #d1
188
- * TestElement, // for #d1
189
- * DivHarness, // for #d2
190
- * TestElement // for #d2
191
- * ]`
192
- * - `await ch.locatorForAll('div', '#d1')()` gets `[
193
- * TestElement, // for #d1
194
- * TestElement // for #d2
195
- * ]`
196
- * - `await ch.locatorForAll(DivHarness, IdIsD1Harness)()` gets `[
197
- * DivHarness, // for #d1
198
- * IdIsD1Harness, // for #d1
199
- * DivHarness // for #d2
200
- * ]`
201
- * - `await ch.locatorForAll('span')()` gets `[]`.
202
- */
203
- locatorForAll(...queries) {
204
- return this.locatorFactory.locatorForAll(...queries);
205
- }
206
- /**
207
- * Flushes change detection and async tasks in the Angular zone.
208
- * In most cases it should not be necessary to call this manually. However, there may be some edge
209
- * cases where it is needed to fully flush animation events.
210
- */
211
- async forceStabilize() {
212
- return this.locatorFactory.forceStabilize();
213
- }
214
- /**
215
- * Waits for all scheduled or running async tasks to complete. This allows harness
216
- * authors to wait for async tasks outside of the Angular zone.
217
- */
218
- async waitForTasksOutsideAngular() {
219
- return this.locatorFactory.waitForTasksOutsideAngular();
220
- }
221
- }
222
- /**
223
- * Base class for component harnesses that authors should extend if they anticipate that consumers
224
- * of the harness may want to access other harnesses within the `<ng-content>` of the component.
225
- */
226
- class ContentContainerComponentHarness extends ComponentHarness {
227
- async getChildLoader(selector) {
228
- return (await this.getRootHarnessLoader()).getChildLoader(selector);
229
- }
230
- async getAllChildLoaders(selector) {
231
- return (await this.getRootHarnessLoader()).getAllChildLoaders(selector);
232
- }
233
- async getHarness(query) {
234
- return (await this.getRootHarnessLoader()).getHarness(query);
235
- }
236
- async getHarnessOrNull(query) {
237
- return (await this.getRootHarnessLoader()).getHarnessOrNull(query);
238
- }
239
- async getAllHarnesses(query) {
240
- return (await this.getRootHarnessLoader()).getAllHarnesses(query);
241
- }
242
- async hasHarness(query) {
243
- return (await this.getRootHarnessLoader()).hasHarness(query);
244
- }
245
- /**
246
- * Gets the root harness loader from which to start
247
- * searching for content contained by this harness.
248
- */
249
- async getRootHarnessLoader() {
250
- return this.locatorFactory.rootHarnessLoader();
251
- }
252
- }
253
- /**
254
- * A class used to associate a ComponentHarness class with predicates functions that can be used to
255
- * filter instances of the class.
256
- */
257
- class HarnessPredicate {
258
- harnessType;
259
- _predicates = [];
260
- _descriptions = [];
261
- _ancestor;
262
- constructor(harnessType, options) {
263
- this.harnessType = harnessType;
264
- this._addBaseOptions(options);
265
- }
266
- /**
267
- * Checks if the specified nullable string value matches the given pattern.
268
- * @param value The nullable string value to check, or a Promise resolving to the
269
- * nullable string value.
270
- * @param pattern The pattern the value is expected to match. If `pattern` is a string,
271
- * `value` is expected to match exactly. If `pattern` is a regex, a partial match is
272
- * allowed. If `pattern` is `null`, the value is expected to be `null`.
273
- * @return Whether the value matches the pattern.
274
- */
275
- static async stringMatches(value, pattern) {
276
- value = await value;
277
- if (pattern === null) {
278
- return value === null;
279
- }
280
- else if (value === null) {
281
- return false;
282
- }
283
- return typeof pattern === 'string' ? value === pattern : pattern.test(value);
284
- }
285
- /**
286
- * Adds a predicate function to be run against candidate harnesses.
287
- * @param description A description of this predicate that may be used in error messages.
288
- * @param predicate An async predicate function.
289
- * @return this (for method chaining).
290
- */
291
- add(description, predicate) {
292
- this._descriptions.push(description);
293
- this._predicates.push(predicate);
294
- return this;
295
- }
296
- /**
297
- * Adds a predicate function that depends on an option value to be run against candidate
298
- * harnesses. If the option value is undefined, the predicate will be ignored.
299
- * @param name The name of the option (may be used in error messages).
300
- * @param option The option value.
301
- * @param predicate The predicate function to run if the option value is not undefined.
302
- * @return this (for method chaining).
303
- */
304
- addOption(name, option, predicate) {
305
- if (option !== undefined) {
306
- this.add(`${name} = ${_valueAsString(option)}`, item => predicate(item, option));
307
- }
308
- return this;
309
- }
310
- /**
311
- * Filters a list of harnesses on this predicate.
312
- * @param harnesses The list of harnesses to filter.
313
- * @return A list of harnesses that satisfy this predicate.
314
- */
315
- async filter(harnesses) {
316
- if (harnesses.length === 0) {
317
- return [];
318
- }
319
- const results = await parallel(() => harnesses.map(h => this.evaluate(h)));
320
- return harnesses.filter((_, i) => results[i]);
321
- }
322
- /**
323
- * Evaluates whether the given harness satisfies this predicate.
324
- * @param harness The harness to check
325
- * @return A promise that resolves to true if the harness satisfies this predicate,
326
- * and resolves to false otherwise.
327
- */
328
- async evaluate(harness) {
329
- const results = await parallel(() => this._predicates.map(p => p(harness)));
330
- return results.reduce((combined, current) => combined && current, true);
331
- }
332
- /** Gets a description of this predicate for use in error messages. */
333
- getDescription() {
334
- return this._descriptions.join(', ');
335
- }
336
- /** Gets the selector used to find candidate elements. */
337
- getSelector() {
338
- // We don't have to go through the extra trouble if there are no ancestors.
339
- if (!this._ancestor) {
340
- return (this.harnessType.hostSelector || '').trim();
341
- }
342
- const [ancestors, ancestorPlaceholders] = _splitAndEscapeSelector(this._ancestor);
343
- const [selectors, selectorPlaceholders] = _splitAndEscapeSelector(this.harnessType.hostSelector || '');
344
- const result = [];
345
- // We have to add the ancestor to each part of the host compound selector, otherwise we can get
346
- // incorrect results. E.g. `.ancestor .a, .ancestor .b` vs `.ancestor .a, .b`.
347
- ancestors.forEach(escapedAncestor => {
348
- const ancestor = _restoreSelector(escapedAncestor, ancestorPlaceholders);
349
- return selectors.forEach(escapedSelector => result.push(`${ancestor} ${_restoreSelector(escapedSelector, selectorPlaceholders)}`));
350
- });
351
- return result.join(', ');
352
- }
353
- /** Adds base options common to all harness types. */
354
- _addBaseOptions(options) {
355
- this._ancestor = options.ancestor || '';
356
- if (this._ancestor) {
357
- this._descriptions.push(`has ancestor matching selector "${this._ancestor}"`);
358
- }
359
- const selector = options.selector;
360
- if (selector !== undefined) {
361
- this.add(`host matches selector "${selector}"`, async (item) => {
362
- return (await item.host()).matchesSelector(selector);
363
- });
364
- }
365
- }
366
- }
367
- /** Represent a value as a string for the purpose of logging. */
368
- function _valueAsString(value) {
369
- if (value === undefined) {
370
- return 'undefined';
371
- }
372
- try {
373
- // `JSON.stringify` doesn't handle RegExp properly, so we need a custom replacer.
374
- // Use a character that is unlikely to appear in real strings to denote the start and end of
375
- // the regex. This allows us to strip out the extra quotes around the value added by
376
- // `JSON.stringify`. Also do custom escaping on `"` characters to prevent `JSON.stringify`
377
- // from escaping them as if they were part of a string.
378
- const stringifiedValue = JSON.stringify(value, (_, v) => v instanceof RegExp
379
- ? `◬MAT_RE_ESCAPE◬${v.toString().replace(/"/g, '◬MAT_RE_ESCAPE◬')}◬MAT_RE_ESCAPE◬`
380
- : v);
381
- // Strip out the extra quotes around regexes and put back the manually escaped `"` characters.
382
- return stringifiedValue
383
- .replace(/"◬MAT_RE_ESCAPE◬|◬MAT_RE_ESCAPE◬"/g, '')
384
- .replace(/◬MAT_RE_ESCAPE◬/g, '"');
385
- }
386
- catch {
387
- // `JSON.stringify` will throw if the object is cyclical,
388
- // in this case the best we can do is report the value as `{...}`.
389
- return '{...}';
390
- }
391
- }
392
- /**
393
- * Splits up a compound selector into its parts and escapes any quoted content. The quoted content
394
- * has to be escaped, because it can contain commas which will throw throw us off when trying to
395
- * split it.
396
- * @param selector Selector to be split.
397
- * @returns The escaped string where any quoted content is replaced with a placeholder. E.g.
398
- * `[foo="bar"]` turns into `[foo=__cdkPlaceholder-0__]`. Use `_restoreSelector` to restore
399
- * the placeholders.
400
- */
401
- function _splitAndEscapeSelector(selector) {
402
- const placeholders = [];
403
- // Note that the regex doesn't account for nested quotes so something like `"ab'cd'e"` will be
404
- // considered as two blocks. It's a bit of an edge case, but if we find that it's a problem,
405
- // we can make it a bit smarter using a loop. Use this for now since it's more readable and
406
- // compact. More complete implementation:
407
- // https://github.com/angular/angular/blob/bd34bc9e89f18a/packages/compiler/src/shadow_css.ts#L655
408
- const result = selector.replace(/(["'][^["']*["'])/g, (_, keep) => {
409
- const replaceBy = `__cdkPlaceholder-${placeholders.length}__`;
410
- placeholders.push(keep);
411
- return replaceBy;
412
- });
413
- return [result.split(',').map(part => part.trim()), placeholders];
414
- }
415
- /** Restores a selector whose content was escaped in `_splitAndEscapeSelector`. */
416
- function _restoreSelector(selector, placeholders) {
417
- return selector.replace(/__cdkPlaceholder-(\d+)__/g, (_, index) => placeholders[+index]);
418
- }
419
-
420
- /**
421
- * Base harness environment class that can be extended to allow `ComponentHarness`es to be used in
422
- * different test environments (e.g. testbed, protractor, etc.). This class implements the
423
- * functionality of both a `HarnessLoader` and `LocatorFactory`. This class is generic on the raw
424
- * element type, `E`, used by the particular test environment.
425
- */
426
- class HarnessEnvironment {
427
- rawRootElement;
428
- // Implemented as part of the `LocatorFactory` interface.
429
- get rootElement() {
430
- this._rootElement = this._rootElement || this.createTestElement(this.rawRootElement);
431
- return this._rootElement;
432
- }
433
- set rootElement(element) {
434
- this._rootElement = element;
435
- }
436
- _rootElement;
437
- constructor(rawRootElement) {
438
- this.rawRootElement = rawRootElement;
439
- }
440
- // Implemented as part of the `LocatorFactory` interface.
441
- documentRootLocatorFactory() {
442
- return this.createEnvironment(this.getDocumentRoot());
443
- }
444
- // Implemented as part of the `LocatorFactory` interface.
445
- locatorFor(...queries) {
446
- return () => _assertResultFound(this._getAllHarnessesAndTestElements(queries), _getDescriptionForLocatorForQueries(queries));
447
- }
448
- // Implemented as part of the `LocatorFactory` interface.
449
- locatorForOptional(...queries) {
450
- return async () => (await this._getAllHarnessesAndTestElements(queries))[0] || null;
451
- }
452
- // Implemented as part of the `LocatorFactory` interface.
453
- locatorForAll(...queries) {
454
- return () => this._getAllHarnessesAndTestElements(queries);
455
- }
456
- // Implemented as part of the `LocatorFactory` interface.
457
- async rootHarnessLoader() {
458
- return this;
459
- }
460
- // Implemented as part of the `LocatorFactory` interface.
461
- async harnessLoaderFor(selector) {
462
- return this.createEnvironment(await _assertResultFound(this.getAllRawElements(selector), [
463
- _getDescriptionForHarnessLoaderQuery(selector),
464
- ]));
465
- }
466
- // Implemented as part of the `LocatorFactory` interface.
467
- async harnessLoaderForOptional(selector) {
468
- const elements = await this.getAllRawElements(selector);
469
- return elements[0] ? this.createEnvironment(elements[0]) : null;
470
- }
471
- // Implemented as part of the `LocatorFactory` interface.
472
- async harnessLoaderForAll(selector) {
473
- const elements = await this.getAllRawElements(selector);
474
- return elements.map(element => this.createEnvironment(element));
475
- }
476
- // Implemented as part of the `HarnessLoader` interface.
477
- getHarness(query) {
478
- return this.locatorFor(query)();
479
- }
480
- // Implemented as part of the `HarnessLoader` interface.
481
- getHarnessOrNull(query) {
482
- return this.locatorForOptional(query)();
483
- }
484
- // Implemented as part of the `HarnessLoader` interface.
485
- getAllHarnesses(query) {
486
- return this.locatorForAll(query)();
487
- }
488
- // Implemented as part of the `HarnessLoader` interface.
489
- async hasHarness(query) {
490
- return (await this.locatorForOptional(query)()) !== null;
491
- }
492
- // Implemented as part of the `HarnessLoader` interface.
493
- async getChildLoader(selector) {
494
- return this.createEnvironment(await _assertResultFound(this.getAllRawElements(selector), [
495
- _getDescriptionForHarnessLoaderQuery(selector),
496
- ]));
497
- }
498
- // Implemented as part of the `HarnessLoader` interface.
499
- async getAllChildLoaders(selector) {
500
- return (await this.getAllRawElements(selector)).map(e => this.createEnvironment(e));
501
- }
502
- /** Creates a `ComponentHarness` for the given harness type with the given raw host element. */
503
- createComponentHarness(harnessType, element) {
504
- return new harnessType(this.createEnvironment(element));
505
- }
506
- /**
507
- * Matches the given raw elements with the given list of element and harness queries to produce a
508
- * list of matched harnesses and test elements.
509
- */
510
- async _getAllHarnessesAndTestElements(queries) {
511
- if (!queries.length) {
512
- throw Error('CDK Component harness query must contain at least one element.');
513
- }
514
- const { allQueries, harnessQueries, elementQueries, harnessTypes } = _parseQueries(queries);
515
- // Combine all of the queries into one large comma-delimited selector and use it to get all raw
516
- // elements matching any of the individual queries.
517
- const rawElements = await this.getAllRawElements([...elementQueries, ...harnessQueries.map(predicate => predicate.getSelector())].join(','));
518
- // If every query is searching for the same harness subclass, we know every result corresponds
519
- // to an instance of that subclass. Likewise, if every query is for a `TestElement`, we know
520
- // every result corresponds to a `TestElement`. Otherwise we need to verify which result was
521
- // found by which selector so it can be matched to the appropriate instance.
522
- const skipSelectorCheck = (elementQueries.length === 0 && harnessTypes.size === 1) || harnessQueries.length === 0;
523
- const perElementMatches = await parallel(() => rawElements.map(async (rawElement) => {
524
- const testElement = this.createTestElement(rawElement);
525
- const allResultsForElement = await parallel(
526
- // For each query, get `null` if it doesn't match, or a `TestElement` or
527
- // `ComponentHarness` as appropriate if it does match. This gives us everything that
528
- // matches the current raw element, but it may contain duplicate entries (e.g.
529
- // multiple `TestElement` or multiple `ComponentHarness` of the same type).
530
- () => allQueries.map(query => this._getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck)));
531
- return _removeDuplicateQueryResults(allResultsForElement);
532
- }));
533
- return [].concat(...perElementMatches);
534
- }
535
- /**
536
- * Check whether the given query matches the given element, if it does return the matched
537
- * `TestElement` or `ComponentHarness`, if it does not, return null. In cases where the caller
538
- * knows for sure that the query matches the element's selector, `skipSelectorCheck` can be used
539
- * to skip verification and optimize performance.
540
- */
541
- async _getQueryResultForElement(query, rawElement, testElement, skipSelectorCheck = false) {
542
- if (typeof query === 'string') {
543
- return skipSelectorCheck || (await testElement.matchesSelector(query)) ? testElement : null;
544
- }
545
- if (skipSelectorCheck || (await testElement.matchesSelector(query.getSelector()))) {
546
- const harness = this.createComponentHarness(query.harnessType, rawElement);
547
- return (await query.evaluate(harness)) ? harness : null;
548
- }
549
- return null;
550
- }
551
- }
552
- /**
553
- * Parses a list of queries in the format accepted by the `locatorFor*` methods into an easier to
554
- * work with format.
555
- */
556
- function _parseQueries(queries) {
557
- const allQueries = [];
558
- const harnessQueries = [];
559
- const elementQueries = [];
560
- const harnessTypes = new Set();
561
- for (const query of queries) {
562
- if (typeof query === 'string') {
563
- allQueries.push(query);
564
- elementQueries.push(query);
565
- }
566
- else {
567
- const predicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
568
- allQueries.push(predicate);
569
- harnessQueries.push(predicate);
570
- harnessTypes.add(predicate.harnessType);
571
- }
572
- }
573
- return { allQueries, harnessQueries, elementQueries, harnessTypes };
574
- }
575
- /**
576
- * Removes duplicate query results for a particular element. (e.g. multiple `TestElement`
577
- * instances or multiple instances of the same `ComponentHarness` class.
578
- */
579
- async function _removeDuplicateQueryResults(results) {
580
- let testElementMatched = false;
581
- let matchedHarnessTypes = new Set();
582
- const dedupedMatches = [];
583
- for (const result of results) {
584
- if (!result) {
585
- continue;
586
- }
587
- if (result instanceof ComponentHarness) {
588
- if (!matchedHarnessTypes.has(result.constructor)) {
589
- matchedHarnessTypes.add(result.constructor);
590
- dedupedMatches.push(result);
591
- }
592
- }
593
- else if (!testElementMatched) {
594
- testElementMatched = true;
595
- dedupedMatches.push(result);
596
- }
597
- }
598
- return dedupedMatches;
599
- }
600
- /** Verifies that there is at least one result in an array. */
601
- async function _assertResultFound(results, queryDescriptions) {
602
- const result = (await results)[0];
603
- if (result == undefined) {
604
- throw Error(`Failed to find element matching one of the following queries:\n` +
605
- queryDescriptions.map(desc => `(${desc})`).join(',\n'));
606
- }
607
- return result;
608
- }
609
- /** Gets a list of description strings from a list of queries. */
610
- function _getDescriptionForLocatorForQueries(queries) {
611
- return queries.map(query => typeof query === 'string'
612
- ? _getDescriptionForTestElementQuery(query)
613
- : _getDescriptionForComponentHarnessQuery(query));
614
- }
615
- /** Gets a description string for a `ComponentHarness` query. */
616
- function _getDescriptionForComponentHarnessQuery(query) {
617
- const harnessPredicate = query instanceof HarnessPredicate ? query : new HarnessPredicate(query, {});
618
- const { name, hostSelector } = harnessPredicate.harnessType;
619
- const description = `${name} with host element matching selector: "${hostSelector}"`;
620
- const constraints = harnessPredicate.getDescription();
621
- return (description +
622
- (constraints ? ` satisfying the constraints: ${harnessPredicate.getDescription()}` : ''));
623
- }
624
- /** Gets a description string for a `TestElement` query. */
625
- function _getDescriptionForTestElementQuery(selector) {
626
- return `TestElement for element matching selector: "${selector}"`;
627
- }
628
- /** Gets a description string for a `HarnessLoader` query. */
629
- function _getDescriptionForHarnessLoaderQuery(selector) {
630
- return `HarnessLoader for element matching selector: "${selector}"`;
631
- }
632
-
633
- /** An enum of non-text keys that can be used with the `sendKeys` method. */
634
- // NOTE: This is a separate enum from `@angular/cdk/keycodes` because we don't necessarily want to
635
- // support every possible keyCode. We also can't rely on Protractor's `Key` because we don't want a
636
- // dependency on any particular testing framework here. Instead we'll just maintain this supported
637
- // list of keys and let individual concrete `HarnessEnvironment` classes map them to whatever key
638
- // representation is used in its respective testing framework.
639
- // tslint:disable-next-line:prefer-const-enum Seems like this causes some issues with System.js
640
- var TestKey;
641
- (function (TestKey) {
642
- TestKey[TestKey["BACKSPACE"] = 0] = "BACKSPACE";
643
- TestKey[TestKey["TAB"] = 1] = "TAB";
644
- TestKey[TestKey["ENTER"] = 2] = "ENTER";
645
- TestKey[TestKey["SHIFT"] = 3] = "SHIFT";
646
- TestKey[TestKey["CONTROL"] = 4] = "CONTROL";
647
- TestKey[TestKey["ALT"] = 5] = "ALT";
648
- TestKey[TestKey["ESCAPE"] = 6] = "ESCAPE";
649
- TestKey[TestKey["PAGE_UP"] = 7] = "PAGE_UP";
650
- TestKey[TestKey["PAGE_DOWN"] = 8] = "PAGE_DOWN";
651
- TestKey[TestKey["END"] = 9] = "END";
652
- TestKey[TestKey["HOME"] = 10] = "HOME";
653
- TestKey[TestKey["LEFT_ARROW"] = 11] = "LEFT_ARROW";
654
- TestKey[TestKey["UP_ARROW"] = 12] = "UP_ARROW";
655
- TestKey[TestKey["RIGHT_ARROW"] = 13] = "RIGHT_ARROW";
656
- TestKey[TestKey["DOWN_ARROW"] = 14] = "DOWN_ARROW";
657
- TestKey[TestKey["INSERT"] = 15] = "INSERT";
658
- TestKey[TestKey["DELETE"] = 16] = "DELETE";
659
- TestKey[TestKey["F1"] = 17] = "F1";
660
- TestKey[TestKey["F2"] = 18] = "F2";
661
- TestKey[TestKey["F3"] = 19] = "F3";
662
- TestKey[TestKey["F4"] = 20] = "F4";
663
- TestKey[TestKey["F5"] = 21] = "F5";
664
- TestKey[TestKey["F6"] = 22] = "F6";
665
- TestKey[TestKey["F7"] = 23] = "F7";
666
- TestKey[TestKey["F8"] = 24] = "F8";
667
- TestKey[TestKey["F9"] = 25] = "F9";
668
- TestKey[TestKey["F10"] = 26] = "F10";
669
- TestKey[TestKey["F11"] = 27] = "F11";
670
- TestKey[TestKey["F12"] = 28] = "F12";
671
- TestKey[TestKey["META"] = 29] = "META";
672
- TestKey[TestKey["COMMA"] = 30] = "COMMA";
673
- })(TestKey || (TestKey = {}));
674
-
675
- /**
676
- * Returns an error which reports that no keys have been specified.
677
- * @docs-private
678
- */
679
- function getNoKeysSpecifiedError() {
680
- return Error('No keys have been specified.');
681
- }
682
-
683
- /**
684
- * Gets text of element excluding certain selectors within the element.
685
- * @param element Element to get text from,
686
- * @param excludeSelector Selector identifying which elements to exclude,
687
- */
688
- function _getTextWithExcludedElements(element, excludeSelector) {
689
- const clone = element.cloneNode(true);
690
- const exclusions = clone.querySelectorAll(excludeSelector);
691
- for (let i = 0; i < exclusions.length; i++) {
692
- exclusions[i].remove();
693
- }
694
- return (clone.textContent || '').trim();
695
- }
696
-
697
- export { ComponentHarness as C, HarnessPredicate as H, TestKey as T, _getTextWithExcludedElements as _, ContentContainerComponentHarness as a, HarnessEnvironment as b, getNoKeysSpecifiedError as g, handleAutoChangeDetectionStatus as h, manualChangeDetection as m, parallel as p, stopHandlingAutoChangeDetectionStatus as s };
698
- //# sourceMappingURL=text-filtering-682c2e05.mjs.map