@wordpress/dom 4.32.0 → 4.32.1-next.47f435fc9.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 (185) hide show
  1. package/build/data-transfer.js +30 -18
  2. package/build/data-transfer.js.map +7 -1
  3. package/build/dom/caret-range-from-point.js +22 -25
  4. package/build/dom/caret-range-from-point.js.map +7 -1
  5. package/build/dom/clean-node-list.js +122 -129
  6. package/build/dom/clean-node-list.js.map +7 -1
  7. package/build/dom/compute-caret-rect.js +36 -21
  8. package/build/dom/compute-caret-rect.js.map +7 -1
  9. package/build/dom/document-has-selection.js +36 -22
  10. package/build/dom/document-has-selection.js.map +7 -1
  11. package/build/dom/document-has-text-selection.js +25 -23
  12. package/build/dom/document-has-text-selection.js.map +7 -1
  13. package/build/dom/document-has-uncollapsed-selection.js +35 -22
  14. package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
  15. package/build/dom/get-computed-style.js +27 -17
  16. package/build/dom/get-computed-style.js.map +7 -1
  17. package/build/dom/get-offset-parent.js +43 -32
  18. package/build/dom/get-offset-parent.js.map +7 -1
  19. package/build/dom/get-range-height.js +24 -18
  20. package/build/dom/get-range-height.js.map +7 -1
  21. package/build/dom/get-rectangle-from-range.js +47 -68
  22. package/build/dom/get-rectangle-from-range.js.map +7 -1
  23. package/build/dom/get-scroll-container.js +44 -37
  24. package/build/dom/get-scroll-container.js.map +7 -1
  25. package/build/dom/hidden-caret-range-from-point.js +39 -33
  26. package/build/dom/hidden-caret-range-from-point.js.map +7 -1
  27. package/build/dom/index.js +116 -195
  28. package/build/dom/index.js.map +7 -1
  29. package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
  30. package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  31. package/build/dom/insert-after.js +24 -19
  32. package/build/dom/insert-after.js.map +7 -1
  33. package/build/dom/is-edge.js +57 -67
  34. package/build/dom/is-edge.js.map +7 -1
  35. package/build/dom/is-element.js +22 -11
  36. package/build/dom/is-element.js.map +7 -1
  37. package/build/dom/is-empty.js +27 -17
  38. package/build/dom/is-empty.js.map +7 -1
  39. package/build/dom/is-entirely-selected.js +46 -50
  40. package/build/dom/is-entirely-selected.js.map +7 -1
  41. package/build/dom/is-form-element.js +36 -24
  42. package/build/dom/is-form-element.js.map +7 -1
  43. package/build/dom/is-horizontal-edge.js +34 -20
  44. package/build/dom/is-horizontal-edge.js.map +7 -1
  45. package/build/dom/is-html-input-element.js +23 -12
  46. package/build/dom/is-html-input-element.js.map +7 -1
  47. package/build/dom/is-input-or-text-area.js +23 -12
  48. package/build/dom/is-input-or-text-area.js.map +7 -1
  49. package/build/dom/is-number-input.js +38 -29
  50. package/build/dom/is-number-input.js.map +7 -1
  51. package/build/dom/is-rtl.js +34 -19
  52. package/build/dom/is-rtl.js.map +7 -1
  53. package/build/dom/is-selection-forward.js +26 -40
  54. package/build/dom/is-selection-forward.js.map +7 -1
  55. package/build/dom/is-text-field.js +49 -24
  56. package/build/dom/is-text-field.js.map +7 -1
  57. package/build/dom/is-vertical-edge.js +34 -20
  58. package/build/dom/is-vertical-edge.js.map +7 -1
  59. package/build/dom/place-caret-at-edge.js +52 -55
  60. package/build/dom/place-caret-at-edge.js.map +7 -1
  61. package/build/dom/place-caret-at-horizontal-edge.js +34 -18
  62. package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
  63. package/build/dom/place-caret-at-vertical-edge.js +34 -19
  64. package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
  65. package/build/dom/remove-invalid-html.js +35 -22
  66. package/build/dom/remove-invalid-html.js.map +7 -1
  67. package/build/dom/remove.js +24 -17
  68. package/build/dom/remove.js.map +7 -1
  69. package/build/dom/replace-tag.js +24 -19
  70. package/build/dom/replace-tag.js.map +7 -1
  71. package/build/dom/replace.js +38 -23
  72. package/build/dom/replace.js.map +7 -1
  73. package/build/dom/safe-html.js +39 -28
  74. package/build/dom/safe-html.js.map +7 -1
  75. package/build/dom/scroll-if-no-range.js +26 -18
  76. package/build/dom/scroll-if-no-range.js.map +7 -1
  77. package/build/dom/strip-html.js +36 -23
  78. package/build/dom/strip-html.js.map +7 -1
  79. package/build/dom/unwrap.js +24 -18
  80. package/build/dom/unwrap.js.map +7 -1
  81. package/build/dom/wrap.js +24 -17
  82. package/build/dom/wrap.js.map +7 -1
  83. package/build/focusable.js +52 -85
  84. package/build/focusable.js.map +7 -1
  85. package/build/index.js +44 -58
  86. package/build/index.js.map +7 -1
  87. package/build/phrasing-content.js +88 -128
  88. package/build/phrasing-content.js.map +7 -1
  89. package/build/tabbable.js +52 -137
  90. package/build/tabbable.js.map +7 -1
  91. package/build/utils/assert-is-defined.js +30 -7
  92. package/build/utils/assert-is-defined.js.map +7 -1
  93. package/build-module/data-transfer.js +9 -15
  94. package/build-module/data-transfer.js.map +7 -1
  95. package/build-module/dom/caret-range-from-point.js +5 -22
  96. package/build-module/dom/caret-range-from-point.js.map +7 -1
  97. package/build-module/dom/clean-node-list.js +94 -123
  98. package/build-module/dom/clean-node-list.js.map +7 -1
  99. package/build-module/dom/compute-caret-rect.js +8 -16
  100. package/build-module/dom/compute-caret-rect.js.map +7 -1
  101. package/build-module/dom/document-has-selection.js +8 -17
  102. package/build-module/dom/document-has-selection.js.map +7 -1
  103. package/build-module/dom/document-has-text-selection.js +8 -20
  104. package/build-module/dom/document-has-text-selection.js.map +7 -1
  105. package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
  106. package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
  107. package/build-module/dom/get-computed-style.js +10 -14
  108. package/build-module/dom/get-computed-style.js.map +7 -1
  109. package/build-module/dom/get-offset-parent.js +16 -28
  110. package/build-module/dom/get-offset-parent.js.map +7 -1
  111. package/build-module/dom/get-range-height.js +7 -15
  112. package/build-module/dom/get-range-height.js.map +7 -1
  113. package/build-module/dom/get-rectangle-from-range.js +30 -65
  114. package/build-module/dom/get-rectangle-from-range.js.map +7 -1
  115. package/build-module/dom/get-scroll-container.js +16 -32
  116. package/build-module/dom/get-scroll-container.js.map +7 -1
  117. package/build-module/dom/hidden-caret-range-from-point.js +11 -28
  118. package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
  119. package/build-module/dom/index.js +57 -28
  120. package/build-module/dom/index.js.map +7 -1
  121. package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
  122. package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  123. package/build-module/dom/insert-after.js +7 -16
  124. package/build-module/dom/insert-after.js.map +7 -1
  125. package/build-module/dom/is-edge.js +24 -57
  126. package/build-module/dom/is-edge.js.map +7 -1
  127. package/build-module/dom/is-element.js +5 -8
  128. package/build-module/dom/is-element.js.map +7 -1
  129. package/build-module/dom/is-empty.js +10 -14
  130. package/build-module/dom/is-empty.js.map +7 -1
  131. package/build-module/dom/is-entirely-selected.js +18 -45
  132. package/build-module/dom/is-entirely-selected.js.map +7 -1
  133. package/build-module/dom/is-form-element.js +8 -19
  134. package/build-module/dom/is-form-element.js.map +7 -1
  135. package/build-module/dom/is-horizontal-edge.js +6 -15
  136. package/build-module/dom/is-horizontal-edge.js.map +7 -1
  137. package/build-module/dom/is-html-input-element.js +6 -9
  138. package/build-module/dom/is-html-input-element.js.map +7 -1
  139. package/build-module/dom/is-input-or-text-area.js +6 -9
  140. package/build-module/dom/is-input-or-text-area.js.map +7 -1
  141. package/build-module/dom/is-number-input.js +11 -25
  142. package/build-module/dom/is-number-input.js.map +7 -1
  143. package/build-module/dom/is-rtl.js +7 -15
  144. package/build-module/dom/is-rtl.js.map +7 -1
  145. package/build-module/dom/is-selection-forward.js +9 -37
  146. package/build-module/dom/is-selection-forward.js.map +7 -1
  147. package/build-module/dom/is-text-field.js +22 -20
  148. package/build-module/dom/is-text-field.js.map +7 -1
  149. package/build-module/dom/is-vertical-edge.js +6 -15
  150. package/build-module/dom/is-vertical-edge.js.map +7 -1
  151. package/build-module/dom/place-caret-at-edge.js +22 -48
  152. package/build-module/dom/place-caret-at-edge.js.map +7 -1
  153. package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
  154. package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
  155. package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
  156. package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
  157. package/build-module/dom/remove-invalid-html.js +7 -17
  158. package/build-module/dom/remove-invalid-html.js.map +7 -1
  159. package/build-module/dom/remove.js +7 -14
  160. package/build-module/dom/remove.js.map +7 -1
  161. package/build-module/dom/replace-tag.js +7 -16
  162. package/build-module/dom/replace-tag.js.map +7 -1
  163. package/build-module/dom/replace.js +9 -17
  164. package/build-module/dom/replace.js.map +7 -1
  165. package/build-module/dom/safe-html.js +11 -23
  166. package/build-module/dom/safe-html.js.map +7 -1
  167. package/build-module/dom/scroll-if-no-range.js +5 -15
  168. package/build-module/dom/scroll-if-no-range.js.map +7 -1
  169. package/build-module/dom/strip-html.js +8 -18
  170. package/build-module/dom/strip-html.js.map +7 -1
  171. package/build-module/dom/unwrap.js +7 -15
  172. package/build-module/dom/unwrap.js.map +7 -1
  173. package/build-module/dom/wrap.js +7 -14
  174. package/build-module/dom/wrap.js.map +7 -1
  175. package/build-module/focusable.js +30 -81
  176. package/build-module/focusable.js.map +7 -1
  177. package/build-module/index.js +9 -17
  178. package/build-module/index.js.map +7 -1
  179. package/build-module/phrasing-content.js +67 -125
  180. package/build-module/phrasing-content.js.map +7 -1
  181. package/build-module/tabbable.js +30 -133
  182. package/build-module/tabbable.js.map +7 -1
  183. package/build-module/utils/assert-is-defined.js +9 -4
  184. package/build-module/utils/assert-is-defined.js.map +7 -1
  185. package/package.json +11 -4
package/build/tabbable.js CHANGED
@@ -1,130 +1,63 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var tabbable_exports = {};
20
+ __export(tabbable_exports, {
21
+ find: () => find,
22
+ findNext: () => findNext,
23
+ findPrevious: () => findPrevious,
24
+ isTabbableIndex: () => isTabbableIndex
5
25
  });
6
- exports.find = find;
7
- exports.findNext = findNext;
8
- exports.findPrevious = findPrevious;
9
- exports.isTabbableIndex = isTabbableIndex;
10
- var _focusable = require("./focusable");
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- /**
16
- * Returns the tab index of the given element. In contrast with the tabIndex
17
- * property, this normalizes the default (0) to avoid browser inconsistencies,
18
- * operating under the assumption that this function is only ever called with a
19
- * focusable node.
20
- *
21
- * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
22
- *
23
- * @param {Element} element Element from which to retrieve.
24
- *
25
- * @return {number} Tab index of element (default 0).
26
- */
26
+ module.exports = __toCommonJS(tabbable_exports);
27
+ var import_focusable = require("./focusable");
27
28
  function getTabIndex(element) {
28
- const tabIndex = element.getAttribute('tabindex');
29
+ const tabIndex = element.getAttribute("tabindex");
29
30
  return tabIndex === null ? 0 : parseInt(tabIndex, 10);
30
31
  }
31
-
32
- /**
33
- * Returns true if the specified element is tabbable, or false otherwise.
34
- *
35
- * @param {Element} element Element to test.
36
- *
37
- * @return {boolean} Whether element is tabbable.
38
- */
39
32
  function isTabbableIndex(element) {
40
33
  return getTabIndex(element) !== -1;
41
34
  }
42
-
43
- /** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */
44
-
45
- /**
46
- * Returns a stateful reducer function which constructs a filtered array of
47
- * tabbable elements, where at most one radio input is selected for a given
48
- * name, giving priority to checked input, falling back to the first
49
- * encountered.
50
- *
51
- * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.
52
- */
53
35
  function createStatefulCollapseRadioGroup() {
54
- /** @type {Record<string, MaybeHTMLInputElement>} */
55
36
  const CHOSEN_RADIO_BY_NAME = {};
56
- return function collapseRadioGroup(/** @type {MaybeHTMLInputElement[]} */result, /** @type {MaybeHTMLInputElement} */element) {
57
- const {
58
- nodeName,
59
- type,
60
- checked,
61
- name
62
- } = element;
63
-
64
- // For all non-radio tabbables, construct to array by concatenating.
65
- if (nodeName !== 'INPUT' || type !== 'radio' || !name) {
37
+ return function collapseRadioGroup(result, element) {
38
+ const { nodeName, type, checked, name } = element;
39
+ if (nodeName !== "INPUT" || type !== "radio" || !name) {
66
40
  return result.concat(element);
67
41
  }
68
42
  const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
69
-
70
- // Omit by skipping concatenation if the radio element is not chosen.
71
43
  const isChosen = checked || !hasChosen;
72
44
  if (!isChosen) {
73
45
  return result;
74
46
  }
75
-
76
- // At this point, if there had been a chosen element, the current
77
- // element is checked and should take priority. Retroactively remove
78
- // the element which had previously been considered the chosen one.
79
47
  if (hasChosen) {
80
48
  const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
81
- result = result.filter(e => e !== hadChosenElement);
49
+ result = result.filter((e) => e !== hadChosenElement);
82
50
  }
83
51
  CHOSEN_RADIO_BY_NAME[name] = element;
84
52
  return result.concat(element);
85
53
  };
86
54
  }
87
-
88
- /**
89
- * An array map callback, returning an object with the element value and its
90
- * array index location as properties. This is used to emulate a proper stable
91
- * sort where equal tabIndex should be left in order of their occurrence in the
92
- * document.
93
- *
94
- * @param {HTMLElement} element Element.
95
- * @param {number} index Array index of element.
96
- *
97
- * @return {{ element: HTMLElement, index: number }} Mapped object with element, index.
98
- */
99
55
  function mapElementToObjectTabbable(element, index) {
100
- return {
101
- element,
102
- index
103
- };
56
+ return { element, index };
104
57
  }
105
-
106
- /**
107
- * An array map callback, returning an element of the given mapped object's
108
- * element value.
109
- *
110
- * @param {{ element: HTMLElement }} object Mapped object with element.
111
- *
112
- * @return {HTMLElement} Mapped object element.
113
- */
114
58
  function mapObjectTabbableToElement(object) {
115
59
  return object.element;
116
60
  }
117
-
118
- /**
119
- * A sort comparator function used in comparing two objects of mapped elements.
120
- *
121
- * @see mapElementToObjectTabbable
122
- *
123
- * @param {{ element: HTMLElement, index: number }} a First object to compare.
124
- * @param {{ element: HTMLElement, index: number }} b Second object to compare.
125
- *
126
- * @return {number} Comparator result.
127
- */
128
61
  function compareObjectTabbables(a, b) {
129
62
  const aTabIndex = getTabIndex(a.element);
130
63
  const bTabIndex = getTabIndex(b.element);
@@ -133,51 +66,33 @@ function compareObjectTabbables(a, b) {
133
66
  }
134
67
  return aTabIndex - bTabIndex;
135
68
  }
136
-
137
- /**
138
- * Givin focusable elements, filters out tabbable element.
139
- *
140
- * @param {HTMLElement[]} focusables Focusable elements to filter.
141
- *
142
- * @return {HTMLElement[]} Tabbable elements.
143
- */
144
69
  function filterTabbable(focusables) {
145
70
  return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
146
71
  }
147
-
148
- /**
149
- * @param {Element} context
150
- * @return {HTMLElement[]} Tabbable elements within the context.
151
- */
152
72
  function find(context) {
153
- return filterTabbable((0, _focusable.find)(context));
73
+ return filterTabbable((0, import_focusable.find)(context));
154
74
  }
155
-
156
- /**
157
- * Given a focusable element, find the preceding tabbable element.
158
- *
159
- * @param {Element} element The focusable element before which to look. Defaults
160
- * to the active element.
161
- *
162
- * @return {HTMLElement|undefined} Preceding tabbable element.
163
- */
164
75
  function findPrevious(element) {
165
- return filterTabbable((0, _focusable.find)(element.ownerDocument.body)).reverse().find(focusable =>
166
- // eslint-disable-next-line no-bitwise
167
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING);
76
+ return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).reverse().find(
77
+ (focusable) => (
78
+ // eslint-disable-next-line no-bitwise
79
+ element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
80
+ )
81
+ );
168
82
  }
169
-
170
- /**
171
- * Given a focusable element, find the next tabbable element.
172
- *
173
- * @param {Element} element The focusable element after which to look. Defaults
174
- * to the active element.
175
- *
176
- * @return {HTMLElement|undefined} Next tabbable element.
177
- */
178
83
  function findNext(element) {
179
- return filterTabbable((0, _focusable.find)(element.ownerDocument.body)).find(focusable =>
180
- // eslint-disable-next-line no-bitwise
181
- element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING);
84
+ return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).find(
85
+ (focusable) => (
86
+ // eslint-disable-next-line no-bitwise
87
+ element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
88
+ )
89
+ );
182
90
  }
183
- //# sourceMappingURL=tabbable.js.map
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ find,
94
+ findNext,
95
+ findPrevious,
96
+ isTabbableIndex
97
+ });
98
+ //# sourceMappingURL=tabbable.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_focusable","require","getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","filter","e","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","map","sort","reduce","find","context","findFocusable","findPrevious","ownerDocument","body","reverse","focusable","compareDocumentPosition","DOCUMENT_POSITION_PRECEDING","findNext","DOCUMENT_POSITION_FOLLOWING"],"sources":["@wordpress/dom/src/tabbable.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param {Element} element Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param {HTMLElement} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: HTMLElement, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param {{ element: HTMLElement }} object Mapped object with element.\n *\n * @return {HTMLElement} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param {{ element: HTMLElement, index: number }} a First object to compare.\n * @param {{ element: HTMLElement, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Givin focusable elements, filters out tabbable element.\n *\n * @param {HTMLElement[]} focusables Focusable elements to filter.\n *\n * @return {HTMLElement[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param {Element} context\n * @return {HTMLElement[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) )\n\t\t.reverse()\n\t\t.find(\n\t\t\t( focusable ) =>\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\t\telement.DOCUMENT_POSITION_PRECEDING\n\t\t);\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param {Element} element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Next tabbable element.\n */\nexport function findNext( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) ).find(\n\t\t( focusable ) =>\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\telement.DOCUMENT_POSITION_FOLLOWING\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CAAEC,OAAO,EAAG;EAC/B,MAAMC,QAAQ,GAAGD,OAAO,CAACE,YAAY,CAAE,UAAW,CAAC;EACnD,OAAOD,QAAQ,KAAK,IAAI,GAAG,CAAC,GAAGE,QAAQ,CAAEF,QAAQ,EAAE,EAAG,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AAC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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAAE5C,OAAO,EAAG;EACnC,OAAO6B,cAAc,CAAE,IAAAO,eAAa,EAAEpC,OAAO,CAACsC,aAAa,CAACC,IAAK,CAAE,CAAC,CAACL,IAAI,CACtEO,SAAS;EACV;EACAzC,OAAO,CAAC0C,uBAAuB,CAAED,SAAU,CAAC,GAC5CzC,OAAO,CAAC6C,2BACV,CAAC;AACF","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/tabbable.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param {Element} element Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param {HTMLElement} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: HTMLElement, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param {{ element: HTMLElement }} object Mapped object with element.\n *\n * @return {HTMLElement} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param {{ element: HTMLElement, index: number }} a First object to compare.\n * @param {{ element: HTMLElement, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Givin focusable elements, filters out tabbable element.\n *\n * @param {HTMLElement[]} focusables Focusable elements to filter.\n *\n * @return {HTMLElement[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param {Element} context\n * @return {HTMLElement[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) )\n\t\t.reverse()\n\t\t.find(\n\t\t\t( focusable ) =>\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\t\telement.DOCUMENT_POSITION_PRECEDING\n\t\t);\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param {Element} element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Next tabbable element.\n */\nexport function findNext( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) ).find(\n\t\t( focusable ) =>\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\telement.DOCUMENT_POSITION_FOLLOWING\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAsC;AActC,SAAS,YAAa,SA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iBAAAA,MAAe,OAAQ,CAAE;AACjD;AAUO,SAAS,aAAc,SAAU;AACvC,SAAO,mBAAgB,iBAAAA,MAAe,QAAQ,cAAc,IAAK,CAAE,EACjE,QAAQ,EACR;AAAA,IACA,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACF;AAUO,SAAS,SAAU,SAAU;AACnC,SAAO,mBAAgB,iBAAAA,MAAe,QAAQ,cAAc,IAAK,CAAE,EAAE;AAAA,IACpE,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACD;",
6
+ "names": ["findFocusable"]
7
+ }
@@ -1,12 +1,35 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var assert_is_defined_exports = {};
20
+ __export(assert_is_defined_exports, {
21
+ assertIsDefined: () => assertIsDefined
5
22
  });
6
- exports.assertIsDefined = assertIsDefined;
23
+ module.exports = __toCommonJS(assert_is_defined_exports);
7
24
  function assertIsDefined(val, name) {
8
- if (process.env.NODE_ENV !== 'production' && (val === undefined || val === null)) {
9
- throw new Error(`Expected '${name}' to be defined, but received ${val}`);
25
+ if (process.env.NODE_ENV !== "production" && (val === void 0 || val === null)) {
26
+ throw new Error(
27
+ `Expected '${name}' to be defined, but received ${val}`
28
+ );
10
29
  }
11
30
  }
12
- //# sourceMappingURL=assert-is-defined.js.map
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ assertIsDefined
34
+ });
35
+ //# sourceMappingURL=assert-is-defined.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["assertIsDefined","val","name","process","env","NODE_ENV","undefined","Error"],"sources":["@wordpress/dom/src/utils/assert-is-defined.ts"],"sourcesContent":["export function assertIsDefined< T >(\n\tval: T,\n\tname: string\n): asserts val is NonNullable< T > {\n\tif (\n\t\tprocess.env.NODE_ENV !== 'production' &&\n\t\t( val === undefined || val === null )\n\t) {\n\t\tthrow new Error(\n\t\t\t`Expected '${ name }' to be defined, but received ${ val }`\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;AAAO,SAASA,eAAeA,CAC9BC,GAAM,EACNC,IAAY,EACsB;EAClC,IACCC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,KACnCJ,GAAG,KAAKK,SAAS,IAAIL,GAAG,KAAK,IAAI,CAAE,EACpC;IACD,MAAM,IAAIM,KAAK,CACd,aAAcL,IAAI,iCAAmCD,GAAG,EACzD,CAAC;EACF;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/assert-is-defined.ts"],
4
+ "sourcesContent": ["export function assertIsDefined< T >(\n\tval: T,\n\tname: string\n): asserts val is NonNullable< T > {\n\tif (\n\t\tprocess.env.NODE_ENV !== 'production' &&\n\t\t( val === undefined || val === null )\n\t) {\n\t\tthrow new Error(\n\t\t\t`Expected '${ name }' to be defined, but received ${ val }`\n\t\t);\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,gBACf,KACA,MACkC;AAClC,MACC,QAAQ,IAAI,aAAa,iBACvB,QAAQ,UAAa,QAAQ,OAC9B;AACD,UAAM,IAAI;AAAA,MACT,aAAc,IAAK,iCAAkC,GAAI;AAAA,IAC1D;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -1,22 +1,16 @@
1
- /**
2
- * Gets all files from a DataTransfer object.
3
- *
4
- * @param {DataTransfer} dataTransfer DataTransfer object to inspect.
5
- *
6
- * @return {File[]} An array containing all files.
7
- */
8
- export function getFilesFromDataTransfer(dataTransfer) {
1
+ function getFilesFromDataTransfer(dataTransfer) {
9
2
  const files = Array.from(dataTransfer.files);
10
- Array.from(dataTransfer.items).forEach(item => {
3
+ Array.from(dataTransfer.items).forEach((item) => {
11
4
  const file = item.getAsFile();
12
- if (file && !files.find(({
13
- name,
14
- type,
15
- size
16
- }) => name === file.name && type === file.type && size === file.size)) {
5
+ if (file && !files.find(
6
+ ({ name, type, size }) => name === file.name && type === file.type && size === file.size
7
+ )) {
17
8
  files.push(file);
18
9
  }
19
10
  });
20
11
  return files;
21
12
  }
22
- //# sourceMappingURL=data-transfer.js.map
13
+ export {
14
+ getFilesFromDataTransfer
15
+ };
16
+ //# sourceMappingURL=data-transfer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"sources":["@wordpress/dom/src/data-transfer.js"],"sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAwBA,CAAEC,YAAY,EAAG;EACxD,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACC,KAAM,CAAC;EAE9CC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACI,KAAM,CAAC,CAACC,OAAO,CAAIC,IAAI,IAAM;IACrD,MAAMC,IAAI,GAAGD,IAAI,CAACE,SAAS,CAAC,CAAC;IAE7B,IACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAI,CACX,CAAE;MAAEC,IAAI;MAAEC,IAAI;MAAEC;IAAK,CAAC,KACrBF,IAAI,KAAKH,IAAI,CAACG,IAAI,IAClBC,IAAI,KAAKJ,IAAI,CAACI,IAAI,IAClBC,IAAI,KAAKL,IAAI,CAACK,IAChB,CAAC,EACA;MACDX,KAAK,CAACY,IAAI,CAAEN,IAAK,CAAC;IACnB;EACD,CAAE,CAAC;EAEH,OAAON,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/data-transfer.js"],
4
+ "sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],
5
+ "mappings": "AAOO,SAAS,yBAA0B,cAAe;AACxD,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,16 +1,4 @@
1
- /**
2
- * Polyfill.
3
- * Get a collapsed range for a given point.
4
- *
5
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
6
- *
7
- * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.
8
- * @param {number} x Horizontal position within the current viewport.
9
- * @param {number} y Vertical position within the current viewport.
10
- *
11
- * @return {Range | null} The best range for the given point.
12
- */
13
- export default function caretRangeFromPoint(doc, x, y) {
1
+ function caretRangeFromPoint(doc, x, y) {
14
2
  if (doc.caretRangeFromPoint) {
15
3
  return doc.caretRangeFromPoint(x, y);
16
4
  }
@@ -18,9 +6,6 @@ export default function caretRangeFromPoint(doc, x, y) {
18
6
  return null;
19
7
  }
20
8
  const point = doc.caretPositionFromPoint(x, y);
21
-
22
- // If x or y are negative, outside viewport, or there is no text entry node.
23
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
24
9
  if (!point) {
25
10
  return null;
26
11
  }
@@ -29,9 +14,7 @@ export default function caretRangeFromPoint(doc, x, y) {
29
14
  range.collapse(true);
30
15
  return range;
31
16
  }
32
-
33
- /**
34
- * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint
35
- * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition
36
- */
37
- //# sourceMappingURL=caret-range-from-point.js.map
17
+ export {
18
+ caretRangeFromPoint as default
19
+ };
20
+ //# sourceMappingURL=caret-range-from-point.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["caretRangeFromPoint","doc","x","y","caretPositionFromPoint","point","range","createRange","setStart","offsetNode","offset","collapse"],"sources":["@wordpress/dom/src/dom/caret-range-from-point.js"],"sourcesContent":["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,mBAAmBA,CAAEC,GAAG,EAAEC,CAAC,EAAEC,CAAC,EAAG;EACxD,IAAKF,GAAG,CAACD,mBAAmB,EAAG;IAC9B,OAAOC,GAAG,CAACD,mBAAmB,CAAEE,CAAC,EAAEC,CAAE,CAAC;EACvC;EAEA,IAAK,CAAEF,GAAG,CAACG,sBAAsB,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGJ,GAAG,CAACG,sBAAsB,CAAEF,CAAC,EAAEC,CAAE,CAAC;;EAEhD;EACA;EACA,IAAK,CAAEE,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGL,GAAG,CAACM,WAAW,CAAC,CAAC;EAE/BD,KAAK,CAACE,QAAQ,CAAEH,KAAK,CAACI,UAAU,EAAEJ,KAAK,CAACK,MAAO,CAAC;EAChDJ,KAAK,CAACK,QAAQ,CAAE,IAAK,CAAC;EAEtB,OAAOL,KAAK;AACb;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/caret-range-from-point.js"],
4
+ "sourcesContent": ["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],
5
+ "mappings": "AAYe,SAAR,oBAAsC,KAAK,GAAG,GAAI;AACxD,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,MAAK,CAAE,IAAI,wBAAyB;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,YAAY;AAE9B,QAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,QAAM,SAAU,IAAK;AAErB,SAAO;AACR;",
6
+ "names": []
7
+ }