accented 0.0.1-dev.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/NOTICE +14 -0
  2. package/README.md +71 -0
  3. package/dist/accented.d.ts +28 -7
  4. package/dist/accented.d.ts.map +1 -1
  5. package/dist/accented.js +107 -42
  6. package/dist/accented.js.map +1 -1
  7. package/dist/common/tokens.d.ts +7 -0
  8. package/dist/common/tokens.d.ts.map +1 -0
  9. package/dist/common/tokens.js +8 -0
  10. package/dist/common/tokens.js.map +1 -0
  11. package/dist/constants.d.ts +4 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +4 -0
  14. package/dist/constants.js.map +1 -0
  15. package/dist/dom-updater.d.ts +1 -6
  16. package/dist/dom-updater.d.ts.map +1 -1
  17. package/dist/dom-updater.js +136 -20
  18. package/dist/dom-updater.js.map +1 -1
  19. package/dist/elements/accented-dialog.d.ts +359 -0
  20. package/dist/elements/accented-dialog.d.ts.map +1 -0
  21. package/dist/elements/accented-dialog.js +377 -0
  22. package/dist/elements/accented-dialog.js.map +1 -0
  23. package/dist/elements/accented-trigger.d.ts +364 -0
  24. package/dist/elements/accented-trigger.d.ts.map +1 -0
  25. package/dist/elements/accented-trigger.js +214 -0
  26. package/dist/elements/accented-trigger.js.map +1 -0
  27. package/dist/fullscreen-listener.d.ts +2 -0
  28. package/dist/fullscreen-listener.d.ts.map +1 -0
  29. package/dist/fullscreen-listener.js +17 -0
  30. package/dist/fullscreen-listener.js.map +1 -0
  31. package/dist/intersection-observer.d.ts +5 -0
  32. package/dist/intersection-observer.d.ts.map +1 -0
  33. package/dist/intersection-observer.js +34 -0
  34. package/dist/intersection-observer.js.map +1 -0
  35. package/dist/log-and-rethrow.d.ts +2 -0
  36. package/dist/log-and-rethrow.d.ts.map +1 -0
  37. package/dist/log-and-rethrow.js +6 -0
  38. package/dist/log-and-rethrow.js.map +1 -0
  39. package/dist/logger.d.ts +2 -0
  40. package/dist/logger.d.ts.map +1 -0
  41. package/dist/logger.js +28 -0
  42. package/dist/logger.js.map +1 -0
  43. package/dist/register-elements.d.ts +2 -0
  44. package/dist/register-elements.d.ts.map +1 -0
  45. package/dist/register-elements.js +20 -0
  46. package/dist/register-elements.js.map +1 -0
  47. package/dist/resize-listener.d.ts +2 -0
  48. package/dist/resize-listener.d.ts.map +1 -0
  49. package/dist/resize-listener.js +17 -0
  50. package/dist/resize-listener.js.map +1 -0
  51. package/dist/scanner.d.ts +3 -0
  52. package/dist/scanner.d.ts.map +1 -0
  53. package/dist/scanner.js +153 -0
  54. package/dist/scanner.js.map +1 -0
  55. package/dist/scroll-listeners.d.ts +2 -0
  56. package/dist/scroll-listeners.d.ts.map +1 -0
  57. package/dist/scroll-listeners.js +37 -0
  58. package/dist/scroll-listeners.js.map +1 -0
  59. package/dist/state.d.ts +7 -0
  60. package/dist/state.d.ts.map +1 -0
  61. package/dist/state.js +16 -0
  62. package/dist/state.js.map +1 -0
  63. package/dist/task-queue.d.ts +5 -6
  64. package/dist/task-queue.d.ts.map +1 -1
  65. package/dist/task-queue.js +30 -25
  66. package/dist/task-queue.js.map +1 -1
  67. package/dist/types.d.ts +227 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +2 -0
  70. package/dist/types.js.map +1 -0
  71. package/dist/utils/are-elements-with-issues-equal.d.ts +3 -0
  72. package/dist/utils/are-elements-with-issues-equal.d.ts.map +1 -0
  73. package/dist/utils/are-elements-with-issues-equal.js +5 -0
  74. package/dist/utils/are-elements-with-issues-equal.js.map +1 -0
  75. package/dist/utils/are-issue-sets-equal.d.ts +3 -0
  76. package/dist/utils/are-issue-sets-equal.d.ts.map +1 -0
  77. package/dist/utils/are-issue-sets-equal.js +6 -0
  78. package/dist/utils/are-issue-sets-equal.js.map +1 -0
  79. package/dist/utils/containing-blocks.d.ts +3 -0
  80. package/dist/utils/containing-blocks.d.ts.map +1 -0
  81. package/dist/utils/containing-blocks.js +46 -0
  82. package/dist/utils/containing-blocks.js.map +1 -0
  83. package/dist/utils/contains.d.ts +2 -0
  84. package/dist/utils/contains.d.ts.map +1 -0
  85. package/dist/utils/contains.js +19 -0
  86. package/dist/utils/contains.js.map +1 -0
  87. package/dist/utils/deduplicate-nodes.d.ts +2 -0
  88. package/dist/utils/deduplicate-nodes.d.ts.map +1 -0
  89. package/dist/utils/deduplicate-nodes.js +4 -0
  90. package/dist/utils/deduplicate-nodes.js.map +1 -0
  91. package/dist/utils/deep-merge.d.ts +4 -0
  92. package/dist/utils/deep-merge.d.ts.map +1 -0
  93. package/dist/utils/deep-merge.js +21 -0
  94. package/dist/utils/deep-merge.js.map +1 -0
  95. package/dist/utils/dom-helpers.d.ts +9 -0
  96. package/dist/utils/dom-helpers.d.ts.map +1 -0
  97. package/dist/utils/dom-helpers.js +34 -0
  98. package/dist/utils/dom-helpers.js.map +1 -0
  99. package/dist/utils/ensure-non-empty.d.ts +2 -0
  100. package/dist/utils/ensure-non-empty.d.ts.map +1 -0
  101. package/dist/utils/ensure-non-empty.js +7 -0
  102. package/dist/utils/ensure-non-empty.js.map +1 -0
  103. package/dist/utils/get-element-html.d.ts +2 -0
  104. package/dist/utils/get-element-html.d.ts.map +1 -0
  105. package/dist/utils/get-element-html.js +16 -0
  106. package/dist/utils/get-element-html.js.map +1 -0
  107. package/dist/utils/get-element-position.d.ts +11 -0
  108. package/dist/utils/get-element-position.d.ts.map +1 -0
  109. package/dist/utils/get-element-position.js +70 -0
  110. package/dist/utils/get-element-position.js.map +1 -0
  111. package/dist/utils/get-parent.d.ts +2 -0
  112. package/dist/utils/get-parent.d.ts.map +1 -0
  113. package/dist/utils/get-parent.js +12 -0
  114. package/dist/utils/get-parent.js.map +1 -0
  115. package/dist/utils/get-scan-context.d.ts +3 -0
  116. package/dist/utils/get-scan-context.d.ts.map +1 -0
  117. package/dist/utils/get-scan-context.js +28 -0
  118. package/dist/utils/get-scan-context.js.map +1 -0
  119. package/dist/utils/get-scrollable-ancestors.d.ts +2 -0
  120. package/dist/utils/get-scrollable-ancestors.d.ts.map +1 -0
  121. package/dist/utils/get-scrollable-ancestors.js +19 -0
  122. package/dist/utils/get-scrollable-ancestors.js.map +1 -0
  123. package/dist/utils/is-node-in-scan-context.d.ts +3 -0
  124. package/dist/utils/is-node-in-scan-context.d.ts.map +1 -0
  125. package/dist/utils/is-node-in-scan-context.js +26 -0
  126. package/dist/utils/is-node-in-scan-context.js.map +1 -0
  127. package/dist/utils/is-non-empty.d.ts +2 -0
  128. package/dist/utils/is-non-empty.d.ts.map +1 -0
  129. package/dist/utils/is-non-empty.js +4 -0
  130. package/dist/utils/is-non-empty.js.map +1 -0
  131. package/dist/utils/normalize-context.d.ts +3 -0
  132. package/dist/utils/normalize-context.d.ts.map +1 -0
  133. package/dist/utils/normalize-context.js +59 -0
  134. package/dist/utils/normalize-context.js.map +1 -0
  135. package/dist/utils/recalculate-positions.d.ts +2 -0
  136. package/dist/utils/recalculate-positions.d.ts.map +1 -0
  137. package/dist/utils/recalculate-positions.js +27 -0
  138. package/dist/utils/recalculate-positions.js.map +1 -0
  139. package/dist/utils/recalculate-scrollable-ancestors.d.ts +2 -0
  140. package/dist/utils/recalculate-scrollable-ancestors.d.ts.map +1 -0
  141. package/dist/utils/recalculate-scrollable-ancestors.js +13 -0
  142. package/dist/utils/recalculate-scrollable-ancestors.js.map +1 -0
  143. package/dist/utils/shadow-dom-aware-mutation-observer.d.ts +10 -0
  144. package/dist/utils/shadow-dom-aware-mutation-observer.d.ts.map +1 -0
  145. package/dist/utils/shadow-dom-aware-mutation-observer.js +61 -0
  146. package/dist/utils/shadow-dom-aware-mutation-observer.js.map +1 -0
  147. package/dist/utils/supports-anchor-positioning.d.ts +6 -0
  148. package/dist/utils/supports-anchor-positioning.d.ts.map +1 -0
  149. package/dist/utils/supports-anchor-positioning.js +4 -0
  150. package/dist/utils/supports-anchor-positioning.js.map +1 -0
  151. package/dist/utils/transform-violations.d.ts +4 -0
  152. package/dist/utils/transform-violations.d.ts.map +1 -0
  153. package/dist/utils/transform-violations.js +61 -0
  154. package/dist/utils/transform-violations.js.map +1 -0
  155. package/dist/utils/update-elements-with-issues.d.ts +13 -0
  156. package/dist/utils/update-elements-with-issues.d.ts.map +1 -0
  157. package/dist/utils/update-elements-with-issues.js +96 -0
  158. package/dist/utils/update-elements-with-issues.js.map +1 -0
  159. package/dist/validate-options.d.ts +3 -0
  160. package/dist/validate-options.d.ts.map +1 -0
  161. package/dist/validate-options.js +129 -0
  162. package/dist/validate-options.js.map +1 -0
  163. package/package.json +21 -8
  164. package/src/accented.test.ts +24 -0
  165. package/src/accented.ts +130 -0
  166. package/src/common/tokens.ts +10 -0
  167. package/src/constants.ts +3 -0
  168. package/src/dom-updater.ts +165 -0
  169. package/src/elements/accented-dialog.ts +419 -0
  170. package/src/elements/accented-trigger.ts +251 -0
  171. package/src/fullscreen-listener.ts +21 -0
  172. package/src/intersection-observer.ts +39 -0
  173. package/src/log-and-rethrow.ts +8 -0
  174. package/src/logger.ts +36 -0
  175. package/src/register-elements.ts +21 -0
  176. package/src/resize-listener.ts +21 -0
  177. package/src/scanner.ts +195 -0
  178. package/src/scroll-listeners.ts +45 -0
  179. package/src/state.ts +35 -0
  180. package/src/task-queue.test.ts +136 -0
  181. package/src/task-queue.ts +61 -0
  182. package/src/types.ts +258 -0
  183. package/src/utils/are-elements-with-issues-equal.ts +11 -0
  184. package/src/utils/are-issue-sets-equal.test.ts +53 -0
  185. package/src/utils/are-issue-sets-equal.ts +12 -0
  186. package/src/utils/containing-blocks.ts +60 -0
  187. package/src/utils/contains.test.ts +54 -0
  188. package/src/utils/contains.ts +19 -0
  189. package/src/utils/deduplicate-nodes.ts +3 -0
  190. package/src/utils/deep-merge.test.ts +41 -0
  191. package/src/utils/deep-merge.ts +24 -0
  192. package/src/utils/dom-helpers.ts +42 -0
  193. package/src/utils/ensure-non-empty.ts +6 -0
  194. package/src/utils/get-element-html.ts +15 -0
  195. package/src/utils/get-element-position.ts +89 -0
  196. package/src/utils/get-parent.ts +14 -0
  197. package/src/utils/get-scan-context.test.ts +85 -0
  198. package/src/utils/get-scan-context.ts +36 -0
  199. package/src/utils/get-scrollable-ancestors.ts +22 -0
  200. package/src/utils/is-node-in-scan-context.test.ts +70 -0
  201. package/src/utils/is-node-in-scan-context.ts +29 -0
  202. package/src/utils/is-non-empty.ts +3 -0
  203. package/src/utils/normalize-context.test.ts +105 -0
  204. package/src/utils/normalize-context.ts +65 -0
  205. package/src/utils/recalculate-positions.ts +27 -0
  206. package/src/utils/recalculate-scrollable-ancestors.ts +13 -0
  207. package/src/utils/shadow-dom-aware-mutation-observer.ts +75 -0
  208. package/src/utils/supports-anchor-positioning.ts +7 -0
  209. package/src/utils/transform-violations.test.ts +128 -0
  210. package/src/utils/transform-violations.ts +74 -0
  211. package/src/utils/update-elements-with-issues.test.ts +371 -0
  212. package/src/utils/update-elements-with-issues.ts +144 -0
  213. package/src/validate-options.ts +184 -0
  214. package/dist/utils/issuesToElements.d.ts +0 -3
  215. package/dist/utils/issuesToElements.d.ts.map +0 -1
  216. package/dist/utils/issuesToElements.js +0 -16
  217. package/dist/utils/issuesToElements.js.map +0 -1
@@ -0,0 +1,227 @@
1
+ import type { Signal } from '@preact/signals-core';
2
+ import type axe from 'axe-core';
3
+ import type { AccentedTrigger } from './elements/accented-trigger.ts';
4
+ export type Throttle = {
5
+ /**
6
+ * How long Accented must wait (in milliseconds) to run a scan after a mutation or after the previous scan (whichever finished last).
7
+ *
8
+ * If the page you’re scanning has a lot of nodes,
9
+ * scanning may take a noticeable time (~ a few hundred milliseconds),
10
+ * during which time the main thread will be blocked most of the time.
11
+ *
12
+ * You may want to experiment with this value if your page contents change frequently
13
+ * or if it has JavaScript-based animations running on the main thread.
14
+ *
15
+ * @default 1000
16
+ * */
17
+ wait?: number;
18
+ /**
19
+ * If `leading` is set to `true`, the scan runs immediately after a mutation.
20
+ * In this case, `wait` only applies to subsequent scans,
21
+ * giving the page at least `wait` milliseconds between the end of the previous scan
22
+ * and the beginning of the next one.
23
+ *
24
+ * If `leading` is set to `false`, the wait applies to mutations as well,
25
+ * delaying the output.
26
+ * This may be useful if you’re expecting quick bursts of mutations on your page.
27
+ *
28
+ * @default true
29
+ * */
30
+ leading?: boolean;
31
+ };
32
+ export type Output = {
33
+ /**
34
+ * Whether the list of elements with issues should be printed to the browser console whenever issues are added, removed, or changed.
35
+ *
36
+ * @default true
37
+ * */
38
+ console?: boolean;
39
+ };
40
+ /**
41
+ * Model context type based on axe.ElementContext,
42
+ * excluding frame selectors (since we don't support scanning iframes).
43
+ */
44
+ export type Selector = Exclude<axe.Selector, axe.LabelledFramesSelector>;
45
+ export type SelectorList = Array<Selector> | NodeList;
46
+ export type ContextProp = Selector | SelectorList;
47
+ export type ContextObject = {
48
+ include: ContextProp;
49
+ exclude?: ContextProp;
50
+ } | {
51
+ exclude: ContextProp;
52
+ include?: ContextProp;
53
+ };
54
+ export type Context = ContextProp | ContextObject;
55
+ export declare const allowedAxeOptions: readonly ["rules", "runOnly"];
56
+ export type AxeOptions = Pick<axe.RunOptions, (typeof allowedAxeOptions)[number]>;
57
+ type CallbackParams = {
58
+ /**
59
+ * The most up-to-date array of all elements with accessibility issues.
60
+ * */
61
+ elementsWithIssues: Array<ElementWithIssues>;
62
+ /**
63
+ * Runtime performance of the last scan. An object with the following props:
64
+ * - `totalBlockingTime`: how long the main thread was blocked by Accented during the last scan, in milliseconds.
65
+ * It’s further divided into the `scan` and `domUpdate` phases.
66
+ * - `scan`: how long scanning (the execution of `axe.run()`) took, in milliseconds.
67
+ * - `domUpdate`: how long the DOM update (adding / removing outlines and dialog trigger buttons) took, in milliseconds.
68
+ * */
69
+ performance: {
70
+ totalBlockingTime: number;
71
+ scan: number;
72
+ domUpdate: number;
73
+ };
74
+ /**
75
+ * Nodes that got scanned. Either an array of nodes,
76
+ * or an object with `include` and `exclude` properties (if any nodes were excluded).
77
+ */
78
+ scanContext: ScanContext | Array<Node>;
79
+ };
80
+ export type Callback = (params: CallbackParams) => void;
81
+ export type AccentedOptions = {
82
+ /**
83
+ * The `options` parameter for `axe.run()`.
84
+ *
85
+ * Accented only supports two keys of the `options` object:
86
+ * * `rules`;
87
+ * * `runOnly`.
88
+ *
89
+ * Both properties are optional, and both control
90
+ * which accessibility rules your page is tested against.
91
+ *
92
+ * See documentation: https://www.deque.com/axe/core-documentation/api-documentation/#options-parameter
93
+ *
94
+ * @default {}
95
+ */
96
+ axeOptions?: AxeOptions;
97
+ /**
98
+ * A function that will be called after each scan.
99
+ *
100
+ * Potential uses:
101
+
102
+ * - do something with the scan results,
103
+ * for example send them to a backend for storage and analysis;
104
+ * - analyze Accented’s performance.
105
+ *
106
+ * @default () => {}
107
+ *
108
+ * @example
109
+ *
110
+ * accented({
111
+ * callback: ({ elementsWithIssues, performance, scanContext }) => {
112
+ * console.log('Elements with issues:', elementsWithIssues);
113
+ * console.log('Total blocking time:', performance.totalBlockingTime);
114
+ * console.log('Scan context:', scanContext);
115
+ * }
116
+ * });
117
+ *
118
+ * */
119
+ callback?: Callback;
120
+ /**
121
+ * The `context` parameter for `axe.run()`.
122
+ *
123
+ * Determines what part(s) of the page to scan for accessibility issues.
124
+ *
125
+ * Accepts a variety of shapes:
126
+ *
127
+ * - a [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) (in practice it will likely be an instance of [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element), [`Document`](https://developer.mozilla.org/en-US/docs/Web/API/Document), or [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment));
128
+ * - a valid [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors);
129
+ * - an object for selecting elements within shadow DOM,
130
+ * whose shape is `{ fromShadowDom: [selector1, selector2, ...] }`,
131
+ * where `selector1`, `selector2`, etc. select shadow hosts, and the last selector selects the actual context.
132
+ * `selector2` in this example is _within_ the shadow root created on the element(s) that match `selector1`,
133
+ * so in practice you shouldn’t have more than two elements in such an array
134
+ * unless you have a very complex structure with multiple shadow DOM layers;
135
+ * - a [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) (likely a result of a [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) call);
136
+ * - an array containing any combination of selectors, nodes, or shadow DOM objects (described above);
137
+ * - an object containing `include` and / or `exclude` properties.
138
+ * It’s useful if you’d like to exclude certain elements or parts of the page.
139
+ * The values for `include` and `exclude` can take any of the above shapes.
140
+ * It’s unlikely that you’d want to have complex `include` / `exclude` rules,
141
+ * but if you do, the exact behavior is documented by the relevant tests:
142
+ * [`is-node-in-scan-context.test.ts`](https://github.com/pomerantsev/accented/blob/main/packages/accented/src/utils/is-node-in-scan-context.test.ts).
143
+ *
144
+ * See also the documentation for the [`context` parameter of `axe.run()`](https://www.deque.com/axe/core-documentation/api-documentation/#context-parameter),
145
+ * which the `context` option from Accented mostly mirrors
146
+ * (note that Accented doesn’t support the `fromFrames` object shape).
147
+ *
148
+ * @default document
149
+ */
150
+ context?: Context;
151
+ /**
152
+ * The character sequence that’s used in various elements, attributes and stylesheets that Accented adds to the page.
153
+ *
154
+ * You shouldn’t have to provide this prop unless some of the names on your page have "accented" in it and conflict with what Accented provides by default.
155
+ *
156
+ * * The data attribute that’s added to elements with issues (default: `data-accented`).
157
+ * * The names of custom elements for the button and the dialog that get created for each element with issues
158
+ * (default: `accented-trigger`, `accented-dialog`).
159
+ * * The CSS cascade layer containing page-wide Accented-specific styles (default: `accented`).
160
+ * * The prefix for some of the CSS custom properties used by Accented (default: `--accented-`).
161
+ * * The window property that’s used to prevent multiple axe-core scans from running simultaneously
162
+ * (default: `__accented_axe_running__`).
163
+ *
164
+ * Only lowercase alphanumeric characters and dashes (-) are allowed in the name,
165
+ * and it must start with a lowercase letter.
166
+ *
167
+ * @default 'accented'
168
+ *
169
+ * @example
170
+ *
171
+ * accented({name: 'my-name'});
172
+ *
173
+ * With the above option provided, the attribute set on elements with issues will be `data-my-name`,
174
+ * a custom element will be called `my-name-trigger`, and so on.
175
+ *
176
+ */
177
+ name?: string;
178
+ /**
179
+ * An object controlling how the results of scans are presented.
180
+ * */
181
+ output?: Output;
182
+ /**
183
+ * An object controlling at what moments Accented will run its scans.
184
+ * */
185
+ throttle?: Throttle;
186
+ };
187
+ /**
188
+ * A function that fully disables Accented,
189
+ * stopping the scanning and removing all highlights from the page.
190
+ */
191
+ export type DisableAccented = () => void;
192
+ export type Position = {
193
+ left: number;
194
+ top: number;
195
+ width: number;
196
+ height: number;
197
+ };
198
+ export type Issue = {
199
+ id: string;
200
+ title: string;
201
+ description: string;
202
+ url: string;
203
+ impact: axe.ImpactValue;
204
+ };
205
+ export type BaseElementWithIssues = {
206
+ element: HTMLElement | SVGElement;
207
+ rootNode: Node;
208
+ };
209
+ export type ElementWithIssues = BaseElementWithIssues & {
210
+ issues: Array<Issue>;
211
+ };
212
+ export type ExtendedElementWithIssues = BaseElementWithIssues & {
213
+ issues: Signal<ElementWithIssues['issues']>;
214
+ visible: Signal<boolean>;
215
+ trigger: AccentedTrigger;
216
+ position: Signal<Position>;
217
+ skipRender: boolean;
218
+ anchorNameValue: string;
219
+ scrollableAncestors: Signal<Set<Element>>;
220
+ id: number;
221
+ };
222
+ export type ScanContext = {
223
+ include: Array<Node>;
224
+ exclude: Array<Node>;
225
+ };
226
+ export {};
227
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG;IACrB;;;;;;;;;;;SAWK;IACL,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;;SAWK;IACL,OAAO,CAAC,EAA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AAM,CAAC,QAAQ,CAAC,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CACtB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export const allowedAxeOptions = ['rules', 'runOnly'];
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BaseElementWithIssues } from '../types.ts';
2
+ export declare function areElementsWithIssuesEqual(elementWithIssues1: BaseElementWithIssues, elementWithIssues2: BaseElementWithIssues): boolean;
3
+ //# sourceMappingURL=are-elements-with-issues-equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-elements-with-issues-equal.d.ts","sourceRoot":"","sources":["../../src/utils/are-elements-with-issues-equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,wBAAgB,0BAA0B,CACxC,kBAAkB,EAAE,qBAAqB,EACzC,kBAAkB,EAAE,qBAAqB,WAM1C"}
@@ -0,0 +1,5 @@
1
+ export function areElementsWithIssuesEqual(elementWithIssues1, elementWithIssues2) {
2
+ return (elementWithIssues1.element === elementWithIssues2.element &&
3
+ elementWithIssues1.rootNode === elementWithIssues2.rootNode);
4
+ }
5
+ //# sourceMappingURL=are-elements-with-issues-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-elements-with-issues-equal.js","sourceRoot":"","sources":["../../src/utils/are-elements-with-issues-equal.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,0BAA0B,CACxC,kBAAyC,EACzC,kBAAyC;IAEzC,OAAO,CACL,kBAAkB,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO;QACzD,kBAAkB,CAAC,QAAQ,KAAK,kBAAkB,CAAC,QAAQ,CAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Issue } from '../types.ts';
2
+ export declare function areIssueSetsEqual(issues1: Array<Issue>, issues2: Array<Issue>): boolean;
3
+ //# sourceMappingURL=are-issue-sets-equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-issue-sets-equal.d.ts","sourceRoot":"","sources":["../../src/utils/are-issue-sets-equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIzC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,WAO7E"}
@@ -0,0 +1,6 @@
1
+ const issueProps = ['id', 'title', 'description', 'url', 'impact'];
2
+ export function areIssueSetsEqual(issues1, issues2) {
3
+ return (issues1.length === issues2.length &&
4
+ issues1.every((issue1) => Boolean(issues2.find((issue2) => issueProps.every((prop) => issue2[prop] === issue1[prop])))));
5
+ }
6
+ //# sourceMappingURL=are-issue-sets-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"are-issue-sets-equal.js","sourceRoot":"","sources":["../../src/utils/are-issue-sets-equal.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAEvF,MAAM,UAAU,iBAAiB,CAAC,OAAqB,EAAE,OAAqB;IAC5E,OAAO,CACL,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QACjC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CACvB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC7F,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function createsContainingBlock(prop: keyof CSSStyleDeclaration): boolean;
2
+ export declare function initializeContainingBlockSupportSet(): void;
3
+ //# sourceMappingURL=containing-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containing-blocks.d.ts","sourceRoot":"","sources":["../../src/utils/containing-blocks.ts"],"names":[],"mappings":"AAuCA,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,mBAAmB,WAErE;AAED,wBAAgB,mCAAmC,SAgBlD"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Tests whether a particular combination of CSS property and value on an element
3
+ * makes that element a containing block.
4
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_display/Containing_block
5
+ *
6
+ * The function is meant to be run with properties that behave inconsistently across browsers.
7
+ *
8
+ * It's only meant to be used during initialization.
9
+ */
10
+ function testContainingBlockCreation(prop, value) {
11
+ const container = document.createElement('div');
12
+ container.style[prop] = value;
13
+ container.style.position = 'fixed';
14
+ container.style.insetInlineStart = '10px';
15
+ container.style.insetBlockStart = '10px';
16
+ const element = document.createElement('div');
17
+ element.style.position = 'fixed';
18
+ element.style.insetInlineStart = '0';
19
+ element.style.insetBlockStart = '0';
20
+ container.appendChild(element);
21
+ document.body.appendChild(container);
22
+ const containerRect = container.getBoundingClientRect();
23
+ const elementRect = element.getBoundingClientRect();
24
+ container.remove();
25
+ return containerRect.top === elementRect.top && containerRect.left === elementRect.left;
26
+ }
27
+ // This is the set we'll use to store the properties that _may_ create containing blocks
28
+ // (the behavior of the ones that we'll be checking is inconsistent across browsers
29
+ // at the time of writing this comment).
30
+ const propsAffectingContainingBlocks = new Set();
31
+ export function createsContainingBlock(prop) {
32
+ return propsAffectingContainingBlocks.has(prop);
33
+ }
34
+ export function initializeContainingBlockSupportSet() {
35
+ const propsToTest = [
36
+ { prop: 'filter', value: 'blur(1px)' },
37
+ { prop: 'backdropFilter', value: 'blur(1px)' },
38
+ { prop: 'containerType', value: 'size' },
39
+ ];
40
+ for (const { prop, value } of propsToTest) {
41
+ if (testContainingBlockCreation(prop, value)) {
42
+ propsAffectingContainingBlocks.add(prop);
43
+ }
44
+ }
45
+ }
46
+ //# sourceMappingURL=containing-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containing-blocks.js","sourceRoot":"","sources":["../../src/utils/containing-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,SAAS,2BAA2B,CAClC,IAAO,EACP,KAA6B;IAE7B,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC9B,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;IACnC,SAAS,CAAC,KAAK,CAAC,gBAAgB,GAAG,MAAM,CAAC;IAC1C,SAAS,CAAC,KAAK,CAAC,eAAe,GAAG,MAAM,CAAC;IAEzC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,gBAAgB,GAAG,GAAG,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC;IAEpC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,aAAa,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IACxD,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAEpD,SAAS,CAAC,MAAM,EAAE,CAAC;IAEnB,OAAO,aAAa,CAAC,GAAG,KAAK,WAAW,CAAC,GAAG,IAAI,aAAa,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC;AAC1F,CAAC;AAED,wFAAwF;AACxF,mFAAmF;AACnF,wCAAwC;AACxC,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAA6B,CAAC;AAE5E,MAAM,UAAU,sBAAsB,CAAC,IAA+B;IACpE,OAAO,8BAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,mCAAmC;IAKjD,MAAM,WAAW,GAAqE;QACpF,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE;QACtC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE;QAC9C,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE;KACzC,CAAC;IAEF,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,WAAW,EAAE,CAAC;QAC1C,IAAI,2BAA2B,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7C,8BAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function contains(ancestor: Node, descendant: Node): boolean;
2
+ //# sourceMappingURL=contains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contains.d.ts","sourceRoot":"","sources":["../../src/utils/contains.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,GAAG,OAAO,CAgBlE"}
@@ -0,0 +1,19 @@
1
+ import { isDocumentFragment, isShadowRoot } from './dom-helpers.js';
2
+ export function contains(ancestor, descendant) {
3
+ if (ancestor.contains(descendant)) {
4
+ return true;
5
+ }
6
+ let rootNode = descendant.getRootNode();
7
+ while (rootNode) {
8
+ if (!(isDocumentFragment(rootNode) && isShadowRoot(rootNode))) {
9
+ return false;
10
+ }
11
+ const host = rootNode.host;
12
+ if (ancestor.contains(host)) {
13
+ return true;
14
+ }
15
+ rootNode = host.getRootNode();
16
+ }
17
+ return false;
18
+ }
19
+ //# sourceMappingURL=contains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contains.js","sourceRoot":"","sources":["../../src/utils/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpE,MAAM,UAAU,QAAQ,CAAC,QAAc,EAAE,UAAgB;IACvD,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,QAAQ,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC3B,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function deduplicateNodes(nodes: Array<Node>): Array<Node>;
2
+ //# sourceMappingURL=deduplicate-nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicate-nodes.d.ts","sourceRoot":"","sources":["../../src/utils/deduplicate-nodes.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAEhE"}
@@ -0,0 +1,4 @@
1
+ export function deduplicateNodes(nodes) {
2
+ return [...new Set(nodes)];
3
+ }
4
+ //# sourceMappingURL=deduplicate-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deduplicate-nodes.js","sourceRoot":"","sources":["../../src/utils/deduplicate-nodes.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,KAAkB;IACjD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,4 @@
1
+ type AnyObject = Record<string, any>;
2
+ export declare function deepMerge(target: AnyObject, source: AnyObject): AnyObject;
3
+ export {};
4
+ //# sourceMappingURL=deep-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-merge.d.ts","sourceRoot":"","sources":["../../src/utils/deep-merge.ts"],"names":[],"mappings":"AAGA,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAKrC,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAezE"}
@@ -0,0 +1,21 @@
1
+ import { isNode } from './dom-helpers.js';
2
+ const isObject = (obj) => typeof obj === 'object' && obj !== null && !Array.isArray(obj);
3
+ export function deepMerge(target, source) {
4
+ const output = { ...target };
5
+ for (const key of Object.keys(source)) {
6
+ if (isObject(source[key])) {
7
+ // Don't merge DOM nodes.
8
+ if (isObject(target[key]) && !isNode(target[key])) {
9
+ output[key] = deepMerge(target[key], source[key]);
10
+ }
11
+ else {
12
+ output[key] = source[key];
13
+ }
14
+ }
15
+ else {
16
+ output[key] = source[key];
17
+ }
18
+ }
19
+ return output;
20
+ }
21
+ //# sourceMappingURL=deep-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../src/utils/deep-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK1C,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAoB,EAAE,CAClD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAEjE,MAAM,UAAU,SAAS,CAAC,MAAiB,EAAE,MAAiB;IAC5D,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC1B,yBAAyB;YACzB,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAClD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare function isNode(obj: object): obj is Node;
2
+ export declare function isNodeList(obj: object): obj is NodeList;
3
+ export declare function isElement(node: Node): node is Element;
4
+ export declare function isDocument(node: Node): node is Document;
5
+ export declare function isDocumentFragment(node: Node): node is DocumentFragment;
6
+ export declare function isShadowRoot(documentFragment: DocumentFragment): documentFragment is ShadowRoot;
7
+ export declare function isHtmlElement(element: Element): element is HTMLElement;
8
+ export declare function isSvgElement(element: Element): element is SVGElement;
9
+ //# sourceMappingURL=dom-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/dom-helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,IAAI,CAO/C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAEvD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,OAAO,CAErD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,CAEvD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,gBAAgB,CAEvE;AAED,wBAAgB,YAAY,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,gBAAgB,IAAI,UAAU,CAE/F;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,WAAW,CAKtE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,UAAU,CAKpE"}
@@ -0,0 +1,34 @@
1
+ export function isNode(obj) {
2
+ return ('nodeType' in obj &&
3
+ typeof obj.nodeType === 'number' &&
4
+ 'nodeName' in obj &&
5
+ typeof obj.nodeName === 'string');
6
+ }
7
+ export function isNodeList(obj) {
8
+ return Object.prototype.toString.call(obj) === '[object NodeList]';
9
+ }
10
+ export function isElement(node) {
11
+ return typeof Node !== 'undefined' && node.nodeType === Node.ELEMENT_NODE;
12
+ }
13
+ export function isDocument(node) {
14
+ return typeof Node !== 'undefined' && node.nodeType === Node.DOCUMENT_NODE;
15
+ }
16
+ export function isDocumentFragment(node) {
17
+ return typeof Node !== 'undefined' && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
18
+ }
19
+ export function isShadowRoot(documentFragment) {
20
+ return 'host' in documentFragment;
21
+ }
22
+ export function isHtmlElement(element) {
23
+ // We can't use instanceof because it may not work across contexts
24
+ // (such as when an element is moved from an iframe).
25
+ // This heuristic seems to be the most robust and fastest that I could think of.
26
+ return element.constructor.name.startsWith('HTML');
27
+ }
28
+ export function isSvgElement(element) {
29
+ // We can't use instanceof because it may not work across contexts
30
+ // (such as when an element is moved from an iframe).
31
+ // This heuristic seems to be the most robust and fastest that I could think of.
32
+ return element.constructor.name.startsWith('SVG');
33
+ }
34
+ //# sourceMappingURL=dom-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-helpers.js","sourceRoot":"","sources":["../../src/utils/dom-helpers.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,CACL,UAAU,IAAI,GAAG;QACjB,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAChC,UAAU,IAAI,GAAG;QACjB,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,mBAAmB,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,aAAa,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAU;IAC3C,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,sBAAsB,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,gBAAkC;IAC7D,OAAO,MAAM,IAAI,gBAAgB,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,kEAAkE;IAClE,qDAAqD;IACrD,gFAAgF;IAChF,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,kEAAkE;IAClE,qDAAqD;IACrD,gFAAgF;IAChF,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function ensureNonEmpty<T>(arr: T[]): [T, ...T[]];
2
+ //# sourceMappingURL=ensure-non-empty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-non-empty.d.ts","sourceRoot":"","sources":["../../src/utils/ensure-non-empty.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAKvD"}
@@ -0,0 +1,7 @@
1
+ export function ensureNonEmpty(arr) {
2
+ if (arr.length === 0) {
3
+ throw new Error('Array must not be empty');
4
+ }
5
+ return arr;
6
+ }
7
+ //# sourceMappingURL=ensure-non-empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-non-empty.js","sourceRoot":"","sources":["../../src/utils/ensure-non-empty.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAI,GAAQ;IACxC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getElementHtml(element: Element): string;
2
+ //# sourceMappingURL=get-element-html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-element-html.d.ts","sourceRoot":"","sources":["../../src/utils/get-element-html.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,UAc9C"}
@@ -0,0 +1,16 @@
1
+ export function getElementHtml(element) {
2
+ const outerHtml = element.outerHTML;
3
+ const innerHtml = element.innerHTML;
4
+ if (!innerHtml) {
5
+ return outerHtml;
6
+ }
7
+ const index = outerHtml.indexOf(innerHtml);
8
+ if (index === -1) {
9
+ // This shouldn't be happening, but if it does, we can just return the outer HTML.
10
+ return outerHtml;
11
+ }
12
+ const openingTag = outerHtml.slice(0, index);
13
+ const closingTag = outerHtml.slice(index + innerHtml.length);
14
+ return `${openingTag}…${closingTag}`;
15
+ }
16
+ //# sourceMappingURL=get-element-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-element-html.js","sourceRoot":"","sources":["../../src/utils/get-element-html.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,kFAAkF;QAClF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Position } from '../types.ts';
2
+ /**
3
+ * https://github.com/pomerantsev/accented/issues/116
4
+ *
5
+ * This calculation leads to incorrectly positioned Accented triggers when all of the following are true:
6
+ * * The element is an SVG element.
7
+ * * The element itself, or one of the element's ancestors has a scale or rotate transform.
8
+ * * The browser doesn't support anchor positioning.
9
+ */
10
+ export declare function getElementPosition(element: Element, win: Window): Position;
11
+ //# sourceMappingURL=get-element-position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-element-position.d.ts","sourceRoot":"","sources":["../../src/utils/get-element-position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA8C5C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,CAkC1E"}
@@ -0,0 +1,70 @@
1
+ import { createsContainingBlock } from './containing-blocks.js';
2
+ import { isHtmlElement } from './dom-helpers.js';
3
+ import { getParent } from './get-parent.js';
4
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_display/Containing_block#identifying_the_containing_block
5
+ function isContainingBlock(element, win) {
6
+ const style = win.getComputedStyle(element);
7
+ const { transform, perspective, contain, contentVisibility, containerType, filter, backdropFilter, willChange, } = style;
8
+ const containItems = contain.split(' ');
9
+ const willChangeItems = willChange.split(/\s*,\s*/);
10
+ return (transform !== 'none' ||
11
+ perspective !== 'none' ||
12
+ containItems.some((item) => ['layout', 'paint', 'strict', 'content'].includes(item)) ||
13
+ contentVisibility === 'auto' ||
14
+ (createsContainingBlock('containerType') && containerType !== 'normal') ||
15
+ (createsContainingBlock('filter') && filter !== 'none') ||
16
+ (createsContainingBlock('backdropFilter') && backdropFilter !== 'none') ||
17
+ willChangeItems.some((item) => ['transform', 'perspective', 'contain', 'filter', 'backdrop-filter'].includes(item)));
18
+ }
19
+ function getNonInitialContainingBlock(element, win) {
20
+ let currentElement = element;
21
+ while (currentElement) {
22
+ currentElement = getParent(currentElement);
23
+ if (currentElement && isContainingBlock(currentElement, win)) {
24
+ return currentElement;
25
+ }
26
+ }
27
+ return null;
28
+ }
29
+ /**
30
+ * https://github.com/pomerantsev/accented/issues/116
31
+ *
32
+ * This calculation leads to incorrectly positioned Accented triggers when all of the following are true:
33
+ * * The element is an SVG element.
34
+ * * The element itself, or one of the element's ancestors has a scale or rotate transform.
35
+ * * The browser doesn't support anchor positioning.
36
+ */
37
+ export function getElementPosition(element, win) {
38
+ const nonInitialContainingBlock = getNonInitialContainingBlock(element, win);
39
+ // If an element has a containing block as an ancestor,
40
+ // and that containing block is not the <html> element (the initial containing block),
41
+ // fixed positioning works differently.
42
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_display/Containing_block#effects_of_the_containing_block
43
+ // https://achrafkassioui.com/blog/position-fixed-and-CSS-transforms/
44
+ if (nonInitialContainingBlock) {
45
+ if (isHtmlElement(element)) {
46
+ const width = element.offsetWidth;
47
+ const height = element.offsetHeight;
48
+ let left = element.offsetLeft;
49
+ let top = element.offsetTop;
50
+ let currentElement = element.offsetParent;
51
+ // Non-initial containing block may not be an offset parent, we have to account for that as well.
52
+ while (currentElement && currentElement !== nonInitialContainingBlock) {
53
+ left += currentElement.offsetLeft;
54
+ top += currentElement.offsetTop;
55
+ currentElement = currentElement.offsetParent;
56
+ }
57
+ return { top, left, width, height };
58
+ }
59
+ const elementRect = element.getBoundingClientRect();
60
+ const nonInitialContainingBlockRect = nonInitialContainingBlock.getBoundingClientRect();
61
+ return {
62
+ top: elementRect.top - nonInitialContainingBlockRect.top,
63
+ height: elementRect.height,
64
+ left: elementRect.left - nonInitialContainingBlockRect.left,
65
+ width: elementRect.width,
66
+ };
67
+ }
68
+ return element.getBoundingClientRect();
69
+ }
70
+ //# sourceMappingURL=get-element-position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-element-position.js","sourceRoot":"","sources":["../../src/utils/get-element-position.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,iHAAiH;AACjH,SAAS,iBAAiB,CAAC,OAAgB,EAAE,GAAW;IACtD,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,EACJ,SAAS,EACT,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,cAAc,EACd,UAAU,GACX,GAAG,KAAK,CAAC;IACV,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,eAAe,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEpD,OAAO,CACL,SAAS,KAAK,MAAM;QACpB,WAAW,KAAK,MAAM;QACtB,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpF,iBAAiB,KAAK,MAAM;QAC5B,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,aAAa,KAAK,QAAQ,CAAC;QACvE,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,MAAM,KAAK,MAAM,CAAC;QACvD,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,IAAI,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