@wordpress/dom 3.2.4 → 3.2.5

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.
@@ -23,31 +23,33 @@ exports.find = find;
23
23
  * AREA elements associated with an IMG:
24
24
  * - https://w3c.github.io/html/editing.html#data-model
25
25
  */
26
- const SELECTOR = ['[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
26
+
27
27
  /**
28
- * Returns true if the specified element is visible (i.e. neither display: none
29
- * nor visibility: hidden).
28
+ * Returns a CSS selector used to query for focusable elements.
30
29
  *
31
- * @param {HTMLElement} element DOM element to test.
30
+ * @param {boolean} sequential If set, only query elements that are sequentially
31
+ * focusable. Non-interactive elements with a
32
+ * negative `tabindex` are focusable but not
33
+ * sequentially focusable.
34
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
32
35
  *
33
- * @return {boolean} Whether element is visible.
36
+ * @return {string} CSS selector.
34
37
  */
35
-
36
- function isVisible(element) {
37
- return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
38
+ function buildSelector(sequential) {
39
+ return [sequential ? '[tabindex]:not([tabindex^="-"])' : '[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe:not([tabindex^="-"])', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
38
40
  }
39
41
  /**
40
- * Returns true if the specified element should be skipped from focusable elements.
41
- * For now it rather specific for `iframes` and if tabindex attribute is set to -1.
42
+ * Returns true if the specified element is visible (i.e. neither display: none
43
+ * nor visibility: hidden).
42
44
  *
43
- * @param {Element} element DOM element to test.
45
+ * @param {HTMLElement} element DOM element to test.
44
46
  *
45
- * @return {boolean} Whether element should be skipped from focusable elements.
47
+ * @return {boolean} Whether element is visible.
46
48
  */
47
49
 
48
50
 
49
- function skipFocus(element) {
50
- return element.nodeName.toLowerCase() === 'iframe' && element.getAttribute('tabindex') === '-1';
51
+ function isVisible(element) {
52
+ return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
51
53
  }
52
54
  /**
53
55
  * Returns true if the specified area element is a valid focusable element, or
@@ -76,21 +78,30 @@ function isValidFocusableArea(element) {
76
78
  /**
77
79
  * Returns all focusable elements within a given context.
78
80
  *
79
- * @param {Element} context Element in which to search.
81
+ * @param {Element} context Element in which to search.
82
+ * @param {Object} [options]
83
+ * @param {boolean} [options.sequential] If set, only return elements that are
84
+ * sequentially focusable.
85
+ * Non-interactive elements with a
86
+ * negative `tabindex` are focusable but
87
+ * not sequentially focusable.
88
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
80
89
  *
81
90
  * @return {Element[]} Focusable elements.
82
91
  */
83
92
 
84
93
 
85
- function find(context) {
94
+ function find(context, {
95
+ sequential = false
96
+ } = {}) {
86
97
  /* eslint-disable jsdoc/no-undefined-types */
87
98
 
88
99
  /** @type {NodeListOf<HTMLElement>} */
89
100
 
90
101
  /* eslint-enable jsdoc/no-undefined-types */
91
- const elements = context.querySelectorAll(SELECTOR);
102
+ const elements = context.querySelectorAll(buildSelector(sequential));
92
103
  return Array.from(elements).filter(element => {
93
- if (!isVisible(element) || skipFocus(element)) {
104
+ if (!isVisible(element)) {
94
105
  return false;
95
106
  }
96
107
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["SELECTOR","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","skipFocus","nodeName","toLowerCase","getAttribute","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AK,CAACC,IAAN,CAAYH,QAAZ,EAAuBI,MAAvB,CAAiCtB,OAAF,IAAe;AACpD,QAAK,CAAED,SAAS,CAAEC,OAAF,CAAX,IAA0BK,SAAS,CAAEL,OAAF,CAAxC,EAAsD;AACrD,aAAO,KAAP;AACA;;AAED,UAAM;AAAEM,MAAAA;AAAF,QAAeN,OAArB;;AACA,QAAK,WAAWM,QAAhB,EAA2B;AAC1B,aAAOG,oBAAoB;AAC1B;AAAiCT,MAAAA,OADP,CAA3B;AAGA;;AAED,WAAO,IAAP;AACA,GAbM,CAAP;AAcA","sourcesContent":["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\nconst SELECTOR = [\n\t'[tabindex]',\n\t'a[href]',\n\t'button:not([disabled])',\n\t'input:not([type=\"hidden\"]):not([disabled])',\n\t'select:not([disabled])',\n\t'textarea:not([disabled])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'area[href]',\n\t'[contenteditable]:not([contenteditable=false])',\n].join( ',' );\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified element should be skipped from focusable elements.\n * For now it rather specific for `iframes` and if tabindex attribute is set to -1.\n *\n * @param {Element} element DOM element to test.\n *\n * @return {boolean} Whether element should be skipped from focusable elements.\n */\nfunction skipFocus( element ) {\n\treturn (\n\t\telement.nodeName.toLowerCase() === 'iframe' &&\n\t\telement.getAttribute( 'tabindex' ) === '-1'\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n *\n * @return {Element[]} Focusable elements.\n */\nexport function find( context ) {\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {NodeListOf<HTMLElement>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst elements = context.querySelectorAll( SELECTOR );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) || skipFocus( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["buildSelector","sequential","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter","nodeName"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AN,CAAYH,QAAZ,EAAuBI,MAAvB,CAAiClB,OAAF,IAAe;AACpD,QAAK,CAAED,SAAS,CAAEC,OAAF,CAAhB,EAA8B;AAC7B,aAAO,KAAP;AACA;;AAED,UAAM;AAAEmB,MAAAA;AAAF,QAAenB,OAArB;;AACA,QAAK,WAAWmB,QAAhB,EAA2B;AAC1B,aAAOd,oBAAoB;AAC1B;AAAiCL,MAAAA,OADP,CAA3B;AAGA;;AAED,WAAO,IAAP;AACA,GAbM,CAAP;AAcA","sourcesContent":["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\n/**\n * Returns a CSS selector used to query for focusable elements.\n *\n * @param {boolean} sequential If set, only query elements that are sequentially\n * focusable. Non-interactive elements with a\n * negative `tabindex` are focusable but not\n * sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {string} CSS selector.\n */\nfunction buildSelector( sequential ) {\n\treturn [\n\t\tsequential ? '[tabindex]:not([tabindex^=\"-\"])' : '[tabindex]',\n\t\t'a[href]',\n\t\t'button:not([disabled])',\n\t\t'input:not([type=\"hidden\"]):not([disabled])',\n\t\t'select:not([disabled])',\n\t\t'textarea:not([disabled])',\n\t\t'iframe:not([tabindex^=\"-\"])',\n\t\t'object',\n\t\t'embed',\n\t\t'area[href]',\n\t\t'[contenteditable]:not([contenteditable=false])',\n\t].join( ',' );\n}\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n * @param {Object} [options]\n * @param {boolean} [options.sequential] If set, only return elements that are\n * sequentially focusable.\n * Non-interactive elements with a\n * negative `tabindex` are focusable but\n * not sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {Element[]} Focusable elements.\n */\nexport function find( context, { sequential = false } = {} ) {\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {NodeListOf<HTMLElement>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst elements = context.querySelectorAll( buildSelector( sequential ) );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"]}
package/build/tabbable.js CHANGED
@@ -199,9 +199,9 @@ function findPrevious(element) {
199
199
 
200
200
  function findNext(element) {
201
201
  const focusables = (0, _focusable.find)(element.ownerDocument.body);
202
- const index = focusables.indexOf(element); // Remove all focusables before and inside `element`.
202
+ const index = focusables.indexOf(element); // Remove all focusables before and including `element`.
203
203
 
204
- const remaining = focusables.slice(index + 1).filter(node => !element.contains(node));
204
+ const remaining = focusables.slice(index + 1);
205
205
  return (0, _lodash.first)(filterTabbable(remaining));
206
206
  }
207
207
  //# sourceMappingURL=tabbable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","filter","map","sort","reduce","find","context","findPrevious","ownerDocument","body","indexOf","length","findNext","remaining","slice","node","contains"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAAsBC,OAAtB,EAAgC;AAC/B,QAAMC,QAAQ,GAAGD,OAAO,CAACE,YAAR,CAAsB,UAAtB,CAAjB;AACA,SAAOD,QAAQ,KAAK,IAAb,GAAoB,CAApB,GAAwBE,QAAQ,CAAEF,QAAF,EAAY,EAAZ,CAAvC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,eAAT,CAA0BJ,OAA1B,EAAoC;AAC1C,SAAOD,WAAW,CAAEC,OAAF,CAAX,KAA2B,CAAC,CAAnC;AACA;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASK,gCAAT,GAA4C;AAC3C;AACA,QAAMC,oBAAoB,GAAG,EAA7B;AAEA,SAAO,SAASC,kBAAT;AACN;AAAuCC,EA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yC,SAAS,GAAGb,UAAU,CAC1Bc,KADgB,CACTvB,KAAK,GAAG,CADC,EAEhBU,MAFgB,CAENc,IAAF,IAAY,CAAE3C,OAAO,CAAC4C,QAAR,CAAkBD,IAAlB,CAFN,CAAlB;AAIA,SAAO,mBAAOhB,cAAc,CAAEc,SAAF,CAArB,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { without, first, last } from 'lodash';\n\n/**\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 {Element & { 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 = without( result, 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 {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, 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: Element }} object Mapped object with element.\n *\n * @return {Element} 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: Element, index: number }} a First object to compare.\n * @param {{ element: Element, 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 {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} 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 {Element[]} 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 */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\treturn last( filterTabbable( focusables ) );\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 */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and inside `element`.\n\tconst remaining = focusables\n\t\t.slice( index + 1 )\n\t\t.filter( ( node ) => ! element.contains( node ) );\n\n\treturn first( filterTabbable( remaining ) );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","filter","map","sort","reduce","find","context","findPrevious","ownerDocument","body","indexOf","length","findNext","remaining","slice"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA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ACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,CAAuBnC,OAAvB,EAAiC;AACvC,QAAM4B,UAAU,GAAG,qBAAe5B,OAAO,CAACoC,aAAR,CAAsBC,IAArC,CAAnB;AACA,QAAMlB,KAAK,GAAGS,UAAU,CAACU,OAAX,CAAoBtC,OAApB,CAAd,CAFuC,CAIvC;;AACA4B,EAAAA,UAAU,CAACW,MAAX,GAAoBpB,KAApB;AAEA,SAAO,kBAAMQ,cAAc,CAAEC,UAAF,CAApB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASY,QAAT,CAAmBxC,OAAnB,EAA6B;AACnC,QAAM4B,UAAU,GAAG,qBAAe5B,OAAO,CAACoC,aAAR,CAAsBC,IAArC,CAAnB;AACA,QAAMlB,KAAK,GAAGS,UAAU,CAACU,OAAX,CAAoBtC,OAApB,CAAd,CAFmC,CAInC;;AACA,QAAMyC,SAAS,GAAGb,UAAU,CAACc,KAAX,CAAkBvB,KAAK,GAAG,CAA1B,CAAlB;AAEA,SAAO,mBAAOQ,cAAc,CAAEc,SAAF,CAArB,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { without, first, last } from 'lodash';\n\n/**\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 {Element & { 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 = without( result, 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 {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, 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: Element }} object Mapped object with element.\n *\n * @return {Element} 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: Element, index: number }} a First object to compare.\n * @param {{ element: Element, 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 {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} 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 {Element[]} 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 */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\treturn last( filterTabbable( focusables ) );\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 */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and including `element`.\n\tconst remaining = focusables.slice( index + 1 );\n\n\treturn first( filterTabbable( remaining ) );\n}\n"]}
@@ -16,31 +16,33 @@
16
16
  * AREA elements associated with an IMG:
17
17
  * - https://w3c.github.io/html/editing.html#data-model
18
18
  */
19
- const SELECTOR = ['[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
19
+
20
20
  /**
21
- * Returns true if the specified element is visible (i.e. neither display: none
22
- * nor visibility: hidden).
21
+ * Returns a CSS selector used to query for focusable elements.
23
22
  *
24
- * @param {HTMLElement} element DOM element to test.
23
+ * @param {boolean} sequential If set, only query elements that are sequentially
24
+ * focusable. Non-interactive elements with a
25
+ * negative `tabindex` are focusable but not
26
+ * sequentially focusable.
27
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
25
28
  *
26
- * @return {boolean} Whether element is visible.
29
+ * @return {string} CSS selector.
27
30
  */
28
-
29
- function isVisible(element) {
30
- return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
31
+ function buildSelector(sequential) {
32
+ return [sequential ? '[tabindex]:not([tabindex^="-"])' : '[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe:not([tabindex^="-"])', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
31
33
  }
32
34
  /**
33
- * Returns true if the specified element should be skipped from focusable elements.
34
- * For now it rather specific for `iframes` and if tabindex attribute is set to -1.
35
+ * Returns true if the specified element is visible (i.e. neither display: none
36
+ * nor visibility: hidden).
35
37
  *
36
- * @param {Element} element DOM element to test.
38
+ * @param {HTMLElement} element DOM element to test.
37
39
  *
38
- * @return {boolean} Whether element should be skipped from focusable elements.
40
+ * @return {boolean} Whether element is visible.
39
41
  */
40
42
 
41
43
 
42
- function skipFocus(element) {
43
- return element.nodeName.toLowerCase() === 'iframe' && element.getAttribute('tabindex') === '-1';
44
+ function isVisible(element) {
45
+ return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
44
46
  }
45
47
  /**
46
48
  * Returns true if the specified area element is a valid focusable element, or
@@ -69,21 +71,30 @@ function isValidFocusableArea(element) {
69
71
  /**
70
72
  * Returns all focusable elements within a given context.
71
73
  *
72
- * @param {Element} context Element in which to search.
74
+ * @param {Element} context Element in which to search.
75
+ * @param {Object} [options]
76
+ * @param {boolean} [options.sequential] If set, only return elements that are
77
+ * sequentially focusable.
78
+ * Non-interactive elements with a
79
+ * negative `tabindex` are focusable but
80
+ * not sequentially focusable.
81
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
73
82
  *
74
83
  * @return {Element[]} Focusable elements.
75
84
  */
76
85
 
77
86
 
78
- export function find(context) {
87
+ export function find(context, {
88
+ sequential = false
89
+ } = {}) {
79
90
  /* eslint-disable jsdoc/no-undefined-types */
80
91
 
81
92
  /** @type {NodeListOf<HTMLElement>} */
82
93
 
83
94
  /* eslint-enable jsdoc/no-undefined-types */
84
- const elements = context.querySelectorAll(SELECTOR);
95
+ const elements = context.querySelectorAll(buildSelector(sequential));
85
96
  return Array.from(elements).filter(element => {
86
- if (!isVisible(element) || skipFocus(element)) {
97
+ if (!isVisible(element)) {
87
98
  return false;
88
99
  }
89
100
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["SELECTOR","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","skipFocus","nodeName","toLowerCase","getAttribute","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,QAAQ,GAAG,CAChB,YADgB,EAEhB,SAFgB,EAGhB,wBAHgB,EAIhB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CAAED,SAAS,CAAEC,OAAF,CAAX,IAA0BK,SAAS,CAAEL,OAAF,CAAxC,EAAsD;AACrD,aAAO,KAAP;AACA;;AAED,UAAM;AAAEM,MAAAA;AAAF,QAAeN,OAArB;;AACA,QAAK,WAAWM,QAAhB,EAA2B;AAC1B,aAAOG,oBAAoB;AAC1B;AAAiCT,MAAAA,OADP,CAA3B;AAGA;;AAED,WAAO,IAAP;AACA,GAbM,CAAP;AAcA","sourcesContent":["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\nconst SELECTOR = [\n\t'[tabindex]',\n\t'a[href]',\n\t'button:not([disabled])',\n\t'input:not([type=\"hidden\"]):not([disabled])',\n\t'select:not([disabled])',\n\t'textarea:not([disabled])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'area[href]',\n\t'[contenteditable]:not([contenteditable=false])',\n].join( ',' );\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified element should be skipped from focusable elements.\n * For now it rather specific for `iframes` and if tabindex attribute is set to -1.\n *\n * @param {Element} element DOM element to test.\n *\n * @return {boolean} Whether element should be skipped from focusable elements.\n */\nfunction skipFocus( element ) {\n\treturn (\n\t\telement.nodeName.toLowerCase() === 'iframe' &&\n\t\telement.getAttribute( 'tabindex' ) === '-1'\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n *\n * @return {Element[]} Focusable elements.\n */\nexport function find( context ) {\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {NodeListOf<HTMLElement>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst elements = context.querySelectorAll( SELECTOR );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) || skipFocus( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["buildSelector","sequential","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter","nodeName"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,UA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AEC,OAAF,CAAhB,EAA8B;AAC7B,aAAO,KAAP;AACA;;AAED,UAAM;AAAEmB,MAAAA;AAAF,QAAenB,OAArB;;AACA,QAAK,WAAWmB,QAAhB,EAA2B;AAC1B,aAAOd,oBAAoB;AAC1B;AAAiCL,MAAAA,OADP,CAA3B;AAGA;;AAED,WAAO,IAAP;AACA,GAbM,CAAP;AAcA","sourcesContent":["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\n/**\n * Returns a CSS selector used to query for focusable elements.\n *\n * @param {boolean} sequential If set, only query elements that are sequentially\n * focusable. Non-interactive elements with a\n * negative `tabindex` are focusable but not\n * sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {string} CSS selector.\n */\nfunction buildSelector( sequential ) {\n\treturn [\n\t\tsequential ? '[tabindex]:not([tabindex^=\"-\"])' : '[tabindex]',\n\t\t'a[href]',\n\t\t'button:not([disabled])',\n\t\t'input:not([type=\"hidden\"]):not([disabled])',\n\t\t'select:not([disabled])',\n\t\t'textarea:not([disabled])',\n\t\t'iframe:not([tabindex^=\"-\"])',\n\t\t'object',\n\t\t'embed',\n\t\t'area[href]',\n\t\t'[contenteditable]:not([contenteditable=false])',\n\t].join( ',' );\n}\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n * @param {Object} [options]\n * @param {boolean} [options.sequential] If set, only return elements that are\n * sequentially focusable.\n * Non-interactive elements with a\n * negative `tabindex` are focusable but\n * not sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {Element[]} Focusable elements.\n */\nexport function find( context, { sequential = false } = {} ) {\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {NodeListOf<HTMLElement>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst elements = context.querySelectorAll( buildSelector( sequential ) );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"]}
@@ -184,9 +184,9 @@ export function findPrevious(element) {
184
184
 
185
185
  export function findNext(element) {
186
186
  const focusables = findFocusable(element.ownerDocument.body);
187
- const index = focusables.indexOf(element); // Remove all focusables before and inside `element`.
187
+ const index = focusables.indexOf(element); // Remove all focusables before and including `element`.
188
188
 
189
- const remaining = focusables.slice(index + 1).filter(node => !element.contains(node));
189
+ const remaining = focusables.slice(index + 1);
190
190
  return first(filterTabbable(remaining));
191
191
  }
192
192
  //# sourceMappingURL=tabbable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["without","first","last","find","findFocusable","getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","filter","map","sort","reduce","context","findPrevious","ownerDocument","body","indexOf","length","findNext","remaining","slice","node","contains"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,KAAlB,EAAyBC,IAAzB,QAAqC,QAArC;AAEA;AACA;AACA;;AACA,SAASC,IAAI,IAAIC,aAAjB,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,OAAtB,EAAgC;AAC/B,QAAMC,QAAQ,GAAGD,OAAO,CAACE,YAAR,CAAsB,UAAtB,CAAjB;AACA,SAAOD,QAAQ,KAAK,IAAb,GAAoB,CAApB,GAAwBE,QAAQ,CAAEF,QAAF,EAAY,EAAZ,CAAvC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASG,eAAT,CAA0BJ,OAA1B,EAAoC;AAC1C,SAAOD,WAAW,CAAEC,OAAF,CAAX,KAA2B,CAAC,CAAnC;AACA;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASK,gCAAT,GAA4C;AAC3C;AACA,QAAMC,oBAAoB,GAAG,EAA7B;AAEA,SAAO,SAASC,kBAAT;AACN;AAAuCC,EAAAA,MADjC;A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C,OAApB,CAAd,CAFmC,CAInC;;AACA,QAAMwC,SAAS,GAAGZ,UAAU,CAC1Ba,KADgB,CACTtB,KAAK,GAAG,CADC,EAEhBU,MAFgB,CAENa,IAAF,IAAY,CAAE1C,OAAO,CAAC2C,QAAR,CAAkBD,IAAlB,CAFN,CAAlB;AAIA,SAAO/C,KAAK,CAAEgC,cAAc,CAAEa,SAAF,CAAhB,CAAZ;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { without, first, last } from 'lodash';\n\n/**\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 {Element & { 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 = without( result, 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 {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, 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: Element }} object Mapped object with element.\n *\n * @return {Element} 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: Element, index: number }} a First object to compare.\n * @param {{ element: Element, 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 {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} 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 {Element[]} 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 */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\treturn last( filterTabbable( focusables ) );\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 */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and inside `element`.\n\tconst remaining = focusables\n\t\t.slice( index + 1 )\n\t\t.filter( ( node ) => ! element.contains( node ) );\n\n\treturn first( filterTabbable( remaining ) );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/tabbable.js"],"names":["without","first","last","find","findFocusable","getTabIndex","element","tabIndex","getAttribute","parseInt","isTabbableIndex","createStatefulCollapseRadioGroup","CHOSEN_RADIO_BY_NAME","collapseRadioGroup","result","nodeName","type","checked","name","concat","hasChosen","hasOwnProperty","isChosen","hadChosenElement","mapElementToObjectTabbable","index","mapObjectTabbableToElement","object","compareObjectTabbables","a","b","aTabIndex","bTabIndex","filterTabbable","focusables","filter","map","sort","reduce","context","findPrevious","ownerDocument","body","indexOf","length","findNext","remaining","slice"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C,EAKuC,EALvC,CAAP;AAMA;AAED;AACA;AACA;AACA;;;AACA,OAAO,SAASR,IAAT,CAAeoC,OAAf,EAAyB;AAC/B,SAAON,cAAc,CAAE7B,aAAa,CAAEmC,OAAF,CAAf,CAArB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBlC,OAAvB,EAAiC;AACvC,QAAM4B,UAAU,GAAG9B,aAAa,CAAEE,OAAO,CAACmC,aAAR,CAAsBC,IAAxB,CAAhC;AACA,QAAMjB,KAAK,GAAGS,UAAU,CAACS,OAAX,CAAoBrC,OAApB,CAAd,CAFuC,CAIvC;;AACA4B,EAAAA,UAAU,CAACU,MAAX,GAAoBnB,KAApB;AAEA,SAAOvB,IAAI,CAAE+B,cAAc,CAAEC,UAAF,CAAhB,CAAX;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,QAAT,CAAmBvC,OAAnB,EAA6B;AACnC,QAAM4B,UAAU,GAAG9B,aAAa,CAAEE,OAAO,CAACmC,aAAR,CAAsBC,IAAxB,CAAhC;AACA,QAAMjB,KAAK,GAAGS,UAAU,CAACS,OAAX,CAAoBrC,OAApB,CAAd,CAFmC,CAInC;;AACA,QAAMwC,SAAS,GAAGZ,UAAU,CAACa,KAAX,CAAkBtB,KAAK,GAAG,CAA1B,CAAlB;AAEA,SAAOxB,KAAK,CAAEgC,cAAc,CAAEa,SAAF,CAAhB,CAAZ;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { without, first, last } from 'lodash';\n\n/**\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 {Element & { 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 = without( result, 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 {Element} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: Element, 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: Element }} object Mapped object with element.\n *\n * @return {Element} 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: Element, index: number }} a First object to compare.\n * @param {{ element: Element, 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 {Element[]} focusables Focusable elements to filter.\n *\n * @return {Element[]} 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 {Element[]} 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 */\nexport function findPrevious( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables after and including `element`.\n\tfocusables.length = index;\n\n\treturn last( filterTabbable( focusables ) );\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 */\nexport function findNext( element ) {\n\tconst focusables = findFocusable( element.ownerDocument.body );\n\tconst index = focusables.indexOf( element );\n\n\t// Remove all focusables before and including `element`.\n\tconst remaining = focusables.slice( index + 1 );\n\n\treturn first( filterTabbable( remaining ) );\n}\n"]}
@@ -1,9 +1,18 @@
1
1
  /**
2
2
  * Returns all focusable elements within a given context.
3
3
  *
4
- * @param {Element} context Element in which to search.
4
+ * @param {Element} context Element in which to search.
5
+ * @param {Object} [options]
6
+ * @param {boolean} [options.sequential] If set, only return elements that are
7
+ * sequentially focusable.
8
+ * Non-interactive elements with a
9
+ * negative `tabindex` are focusable but
10
+ * not sequentially focusable.
11
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
5
12
  *
6
13
  * @return {Element[]} Focusable elements.
7
14
  */
8
- export function find(context: Element): Element[];
15
+ export function find(context: Element, { sequential }?: {
16
+ sequential?: boolean | undefined;
17
+ } | undefined): Element[];
9
18
  //# sourceMappingURL=focusable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"focusable.d.ts","sourceRoot":"","sources":["../src/focusable.js"],"names":[],"mappings":"AAuFA;;;;;;GAMG;AACH,8BAJW,OAAO,GAEN,OAAO,EAAE,CAsBpB"}
1
+ {"version":3,"file":"focusable.d.ts","sourceRoot":"","sources":["../src/focusable.js"],"names":[],"mappings":"AAqFA;;;;;;;;;;;;;GAaG;AACH,8BAXW,OAAO;;gBASN,OAAO,EAAE,CAsBpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,yCAJW,OAAO,GAEN,OAAO,CAIlB;AAiHD;;;GAGG;AACH,8BAHW,OAAO,GACN,OAAO,EAAE,CAIpB;AAED;;;;;GAKG;AACH,sCAHW,OAAO,uBAWjB;AAED;;;;;GAKG;AACH,kCAHW,OAAO,uBAajB;oCAvJa,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE"}
1
+ {"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,yCAJW,OAAO,GAEN,OAAO,CAIlB;AAiHD;;;GAGG;AACH,8BAHW,OAAO,GACN,OAAO,EAAE,CAIpB;AAED;;;;;GAKG;AACH,sCAHW,OAAO,uBAWjB;AAED;;;;;GAKG;AACH,kCAHW,OAAO,uBAWjB;oCArJa,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dom",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "DOM utilities module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "8f7f052bc04e3f4eb50f479ced14be1489b9fa79"
37
+ "gitHead": "157f4ae53ab98e574af01f72213ae5a9613159ff"
38
38
  }
package/src/focusable.js CHANGED
@@ -17,19 +17,32 @@
17
17
  * - https://w3c.github.io/html/editing.html#data-model
18
18
  */
19
19
 
20
- const SELECTOR = [
21
- '[tabindex]',
22
- 'a[href]',
23
- 'button:not([disabled])',
24
- 'input:not([type="hidden"]):not([disabled])',
25
- 'select:not([disabled])',
26
- 'textarea:not([disabled])',
27
- 'iframe',
28
- 'object',
29
- 'embed',
30
- 'area[href]',
31
- '[contenteditable]:not([contenteditable=false])',
32
- ].join( ',' );
20
+ /**
21
+ * Returns a CSS selector used to query for focusable elements.
22
+ *
23
+ * @param {boolean} sequential If set, only query elements that are sequentially
24
+ * focusable. Non-interactive elements with a
25
+ * negative `tabindex` are focusable but not
26
+ * sequentially focusable.
27
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
28
+ *
29
+ * @return {string} CSS selector.
30
+ */
31
+ function buildSelector( sequential ) {
32
+ return [
33
+ sequential ? '[tabindex]:not([tabindex^="-"])' : '[tabindex]',
34
+ 'a[href]',
35
+ 'button:not([disabled])',
36
+ 'input:not([type="hidden"]):not([disabled])',
37
+ 'select:not([disabled])',
38
+ 'textarea:not([disabled])',
39
+ 'iframe:not([tabindex^="-"])',
40
+ 'object',
41
+ 'embed',
42
+ 'area[href]',
43
+ '[contenteditable]:not([contenteditable=false])',
44
+ ].join( ',' );
45
+ }
33
46
 
34
47
  /**
35
48
  * Returns true if the specified element is visible (i.e. neither display: none
@@ -47,21 +60,6 @@ function isVisible( element ) {
47
60
  );
48
61
  }
49
62
 
50
- /**
51
- * Returns true if the specified element should be skipped from focusable elements.
52
- * For now it rather specific for `iframes` and if tabindex attribute is set to -1.
53
- *
54
- * @param {Element} element DOM element to test.
55
- *
56
- * @return {boolean} Whether element should be skipped from focusable elements.
57
- */
58
- function skipFocus( element ) {
59
- return (
60
- element.nodeName.toLowerCase() === 'iframe' &&
61
- element.getAttribute( 'tabindex' ) === '-1'
62
- );
63
- }
64
-
65
63
  /**
66
64
  * Returns true if the specified area element is a valid focusable element, or
67
65
  * false otherwise. Area is only focusable if within a map where a named map
@@ -88,18 +86,25 @@ function isValidFocusableArea( element ) {
88
86
  /**
89
87
  * Returns all focusable elements within a given context.
90
88
  *
91
- * @param {Element} context Element in which to search.
89
+ * @param {Element} context Element in which to search.
90
+ * @param {Object} [options]
91
+ * @param {boolean} [options.sequential] If set, only return elements that are
92
+ * sequentially focusable.
93
+ * Non-interactive elements with a
94
+ * negative `tabindex` are focusable but
95
+ * not sequentially focusable.
96
+ * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
92
97
  *
93
98
  * @return {Element[]} Focusable elements.
94
99
  */
95
- export function find( context ) {
100
+ export function find( context, { sequential = false } = {} ) {
96
101
  /* eslint-disable jsdoc/no-undefined-types */
97
102
  /** @type {NodeListOf<HTMLElement>} */
98
103
  /* eslint-enable jsdoc/no-undefined-types */
99
- const elements = context.querySelectorAll( SELECTOR );
104
+ const elements = context.querySelectorAll( buildSelector( sequential ) );
100
105
 
101
106
  return Array.from( elements ).filter( ( element ) => {
102
- if ( ! isVisible( element ) || skipFocus( element ) ) {
107
+ if ( ! isVisible( element ) ) {
103
108
  return false;
104
109
  }
105
110
 
package/src/tabbable.js CHANGED
@@ -181,10 +181,8 @@ export function findNext( element ) {
181
181
  const focusables = findFocusable( element.ownerDocument.body );
182
182
  const index = focusables.indexOf( element );
183
183
 
184
- // Remove all focusables before and inside `element`.
185
- const remaining = focusables
186
- .slice( index + 1 )
187
- .filter( ( node ) => ! element.contains( node ) );
184
+ // Remove all focusables before and including `element`.
185
+ const remaining = focusables.slice( index + 1 );
188
186
 
189
187
  return first( filterTabbable( remaining ) );
190
188
  }
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/data-transfer.js","./src/focusable.js","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","./src/tabbable.js","./src/utils/assert-is-defined.ts","./src/dom/get-rectangle-from-range.js","./src/dom/compute-caret-rect.js","./src/dom/document-has-text-selection.js","./src/dom/is-html-input-element.js","./src/dom/is-text-field.js","./src/dom/is-number-input.js","./src/dom/input-field-has-uncollapsed-selection.js","./src/dom/document-has-uncollapsed-selection.js","./src/dom/document-has-selection.js","./src/dom/get-computed-style.js","./src/dom/get-scroll-container.js","./src/dom/get-offset-parent.js","./src/dom/is-input-or-text-area.js","./src/dom/is-entirely-selected.js","./src/dom/is-rtl.js","./src/dom/get-range-height.js","./src/dom/is-selection-forward.js","./src/dom/caret-range-from-point.js","./src/dom/hidden-caret-range-from-point.js","./src/dom/is-edge.js","./src/dom/is-horizontal-edge.js","./src/dom/is-vertical-edge.js","./src/dom/place-caret-at-edge.js","./src/dom/place-caret-at-horizontal-edge.js","./src/dom/place-caret-at-vertical-edge.js","./src/dom/insert-after.js","./src/dom/remove.js","./src/dom/replace.js","./src/dom/unwrap.js","./src/dom/replace-tag.js","./src/dom/wrap.js","./src/dom/strip-html.js","./src/dom/is-empty.js","./src/phrasing-content.js","./src/dom/is-element.js","./src/dom/clean-node-list.js","./src/dom/remove-invalid-html.js","./src/dom/safe-html.js","./src/dom/index.js","./src/index.js","../../typings/gutenberg-env/index.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"80d2e2a2e1685c82cba3c320f5d077376fadff77fe1f52a4c29f995bdc40ea70","4cdbde4fda515e699256d87e4f0c65545b043aee01cf35e6f24afd290b8a966b","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"2468bfa0bb192ba442f86ed3b0d122db0247f1975c41a3459d9b8db3b7765d1f","a7836408f857cb8855443e0ff79d3ed7027415dca85f312c5f9f47daa6cd355d","60c4ae06adc3b6c7e1bbde496c9e2ff9bf3ff2f811675b7a897d460d2b7b814a","99546def4f9cd760e5ee13c0cce45c83aaa3d5474d75cef79c34b1990a808022","a80ab4ddcbdb314f6c5780edf87f6b63c7b4149ca299a72451ab2fb8304ba11e","7d41e8f297df3090da557100eb1cd95013d2cff0277cef6848d389660ed607af","08129a92bea6c56eb44b6978842a1613e267a0100f6e96c36bcfc05128ce7610","2daaade587180e90e650acf824330ddbed8239f5439e84520d9f00d3fa7eeed6","4ef4710028ee537bc9a325373707d5a1ce077b6af13346764746192704363d9b","e792137d19ad029831fbdc751e06833bc98f4b7197170bc4d01b1a1d6e859fe3","8c6fad120d4f0e25311b2ac81d8677fc4ceecdc92a7d03865734bf961c5d587e","dea4257186ad318062499e0aff7122433b1081b7883e95ef78d9b4121fc8e7da","44575ab99b22879c2c9fa3c9cb0e3811a71b6a1acd0d0ffafe612721eecb32b9","9fceedcd6483e17acc07c4c3ecf0a00606c769a255d127259b96f2cb97b34941","4d31f8f7e9d8a43d2fd3c5a378e390080706392dd4d1541fc6b6f876ed961cf4","756cc95fd142eb928ba7bd366cc2756a902d8a1219182a45a2820e86702b1f3e","4312fd698114e973469529ec29680789e8ce13ffddcf711a8660c85e522b4069","cb412dab570deef76d26e0c5759e3fbe12625947ac6a82037573c788b7a2d1a4","59fbe797b38f7f549100d38fc9a4c6cd0f4b990407700f5e1979a54c9d8e3ed6","e8be8e4d18f330bdd294cdbe7d3c4a89e8dca65585284745a25c515ecb69249f","8b692a361fc9f2d4102106f168b35cf6f30c9efc66050108001955a1a59b4fd2","59ac58f0ebf648d5e38b01df0cfd02700d475ff8367c3f4695d3632e3db3416b","6199e013116305fa2d162835ad812abfe210076e1249852851c5a80a753f4f3d","ba688a4815abd9d27b425a819def1721b61e1798acc748b471e54d50a7804bcd","c6684892ae32c0d3fe0c2bb1b7e6bb37ffc86fc91d39c0cfe557aba4816e7766","609b8944af1aa9b73959c0bd766370986176a197c16c27e365e867a0bc85eed8","2ffc9898fdf8f285b73f08ee256ca9a6f20cf3de25c57dd7aa28f7558d3af624","0fb6bab9bd95185809964d513dcfeeab6b5609d280dcc6291b5277e36998afe1","2d18411640dd8fcf1067392b839136628cafef5a648d0d49dc9da2f7d344046e","57597a1e8735ae08b671194c8b64a2c2831fd6ce2793d1bca705dbceb41bdaae","fc9b503ac41bf643bdd2c5bcf21e7e8c052881dd6b94699e3624f3a60e02b0be","665d3d55e94122f2fe1c2dd78dd61774134151557a3b8dd41d49868a642c1277","2259073e3a0fcbd5d873f90465ad8364007668a97c0291a6b6d7975d8edbe30d","05a5f6e843f0e788b2530f08bd8407e4cd37bfdae9c549af25406289d47bfd80","70388aac7550e4cb19e9eb5aafba7ed3333fbae173f0d377643f5fa733317ae9","5620e210666cc9ff9409e6b18b23bdfbfd3edfa21a6b12ac28f48933842396b7","0d0dd5ae0237a3571383b9ac701d40220e1d963d0bbb22473c336225b2ed44a7","1e5577dfce1e114e9dc58a7199bdb9e359b30deb86d29a9f0a0b111fc8d29943","dcc4b56e334bd6f9a8680a5dd343e417cdb03bae06bdc4786211d2cdfd7899e8","02959309d4b7d9a875c4f175abae0a359a074585513d073d1fbb828b704e5663","53c80552acaabb705837f41f5bc28c79322645d3472b5fc214dbf81fa7fb9117","0af026de3ab75c99339016a7aa606da158668df7cfc0c25668c1d1617323da20",{"version":"f254c1abf6bb4c92633159831f924588908da902aa5e04ae45c39bd001f62e2e","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[47,49,50,51,52,53,54,55,56,57,58,59],[47,48,50,51,52,53,54,55,56,57,58,59],[48,49,50,51,52,53,54,55,56,57,58,59],[47,48,49,51,52,53,54,55,56,57,58,59],[47,48,49,50,52,53,54,55,56,57,58,59],[47,48,49,50,51,53,54,55,56,57,58,59],[47,48,49,50,51,52,54,55,56,57,58,59],[47,48,49,50,51,52,53,55,56,57,58,59],[47,48,49,50,51,52,53,54,56,57,58,59],[47,48,49,50,51,52,53,54,55,57,58,59],[47,48,49,50,51,52,53,54,55,56,58,59],[47,48,49,50,51,52,53,54,55,56,57,59],[47,48,49,50,51,52,53,54,55,56,57,58],[59,87,88,90,94,95,96],[61,62],[64,66,67],[61],[64,68],[71],[71,79],[62,63,64,66,67,69,70,72,73,75,76,82,83,85,86,87,88,89,90,91,92,93,94,98,99],[66,67],[61,62,74,76,77,78,80],[61,74],[81],[65],[61,74,76,80],[84],[97],[61,87,88],[88],[45,46,60,95,100],[59],[46,59]],"referencedMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[97,14],[63,15],[70,16],[64,17],[69,18],[71,17],[73,19],[62,17],[72,19],[80,20],[100,21],[68,22],[87,17],[81,23],[75,24],[82,25],[67,26],[76,19],[78,17],[66,26],[83,25],[84,27],[85,28],[86,28],[98,29],[88,17],[91,17],[89,30],[99,31],[90,17],[92,17],[101,32],[95,33],[60,34]],"exportedModulesMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[97,14],[63,15],[70,16],[64,17],[69,18],[71,17],[73,19],[62,17],[72,19],[80,20],[100,21],[68,22],[87,17],[81,23],[75,24],[82,25],[67,26],[76,19],[78,17],[66,26],[83,25],[84,27],[85,28],[86,28],[98,29],[88,17],[91,17],[89,30],[99,31],[90,17],[92,17],[101,32],[95,33],[60,34]],"semanticDiagnosticsPerFile":[48,49,47,50,51,52,53,54,55,56,57,58,59,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,45,79,97,63,70,64,69,71,73,77,62,72,80,100,68,87,81,96,94,75,82,65,74,67,76,78,66,83,84,85,86,98,88,91,89,99,93,90,92,46,101,95,60,61,102]},"version":"4.4.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/data-transfer.js","./src/focusable.js","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","./src/tabbable.js","./src/utils/assert-is-defined.ts","./src/dom/get-rectangle-from-range.js","./src/dom/compute-caret-rect.js","./src/dom/document-has-text-selection.js","./src/dom/is-html-input-element.js","./src/dom/is-text-field.js","./src/dom/is-number-input.js","./src/dom/input-field-has-uncollapsed-selection.js","./src/dom/document-has-uncollapsed-selection.js","./src/dom/document-has-selection.js","./src/dom/get-computed-style.js","./src/dom/get-scroll-container.js","./src/dom/get-offset-parent.js","./src/dom/is-input-or-text-area.js","./src/dom/is-entirely-selected.js","./src/dom/is-rtl.js","./src/dom/get-range-height.js","./src/dom/is-selection-forward.js","./src/dom/caret-range-from-point.js","./src/dom/hidden-caret-range-from-point.js","./src/dom/is-edge.js","./src/dom/is-horizontal-edge.js","./src/dom/is-vertical-edge.js","./src/dom/place-caret-at-edge.js","./src/dom/place-caret-at-horizontal-edge.js","./src/dom/place-caret-at-vertical-edge.js","./src/dom/insert-after.js","./src/dom/remove.js","./src/dom/replace.js","./src/dom/unwrap.js","./src/dom/replace-tag.js","./src/dom/wrap.js","./src/dom/strip-html.js","./src/dom/is-empty.js","./src/phrasing-content.js","./src/dom/is-element.js","./src/dom/clean-node-list.js","./src/dom/remove-invalid-html.js","./src/dom/safe-html.js","./src/dom/index.js","./src/index.js","../../typings/gutenberg-env/index.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"80d2e2a2e1685c82cba3c320f5d077376fadff77fe1f52a4c29f995bdc40ea70","0ca9a18ed362f11af31b31312d27380b605653eb7d9b005abc7ce9af29e6c545","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"5a7e042af19f83e768650f7a301ce19a58a0ce8d38c5b567ae96e814033740ec","a7836408f857cb8855443e0ff79d3ed7027415dca85f312c5f9f47daa6cd355d","60c4ae06adc3b6c7e1bbde496c9e2ff9bf3ff2f811675b7a897d460d2b7b814a","99546def4f9cd760e5ee13c0cce45c83aaa3d5474d75cef79c34b1990a808022","a80ab4ddcbdb314f6c5780edf87f6b63c7b4149ca299a72451ab2fb8304ba11e","7d41e8f297df3090da557100eb1cd95013d2cff0277cef6848d389660ed607af","08129a92bea6c56eb44b6978842a1613e267a0100f6e96c36bcfc05128ce7610","2daaade587180e90e650acf824330ddbed8239f5439e84520d9f00d3fa7eeed6","4ef4710028ee537bc9a325373707d5a1ce077b6af13346764746192704363d9b","e792137d19ad029831fbdc751e06833bc98f4b7197170bc4d01b1a1d6e859fe3","8c6fad120d4f0e25311b2ac81d8677fc4ceecdc92a7d03865734bf961c5d587e","dea4257186ad318062499e0aff7122433b1081b7883e95ef78d9b4121fc8e7da","44575ab99b22879c2c9fa3c9cb0e3811a71b6a1acd0d0ffafe612721eecb32b9","9fceedcd6483e17acc07c4c3ecf0a00606c769a255d127259b96f2cb97b34941","4d31f8f7e9d8a43d2fd3c5a378e390080706392dd4d1541fc6b6f876ed961cf4","756cc95fd142eb928ba7bd366cc2756a902d8a1219182a45a2820e86702b1f3e","4312fd698114e973469529ec29680789e8ce13ffddcf711a8660c85e522b4069","cb412dab570deef76d26e0c5759e3fbe12625947ac6a82037573c788b7a2d1a4","59fbe797b38f7f549100d38fc9a4c6cd0f4b990407700f5e1979a54c9d8e3ed6","e8be8e4d18f330bdd294cdbe7d3c4a89e8dca65585284745a25c515ecb69249f","8b692a361fc9f2d4102106f168b35cf6f30c9efc66050108001955a1a59b4fd2","59ac58f0ebf648d5e38b01df0cfd02700d475ff8367c3f4695d3632e3db3416b","6199e013116305fa2d162835ad812abfe210076e1249852851c5a80a753f4f3d","ba688a4815abd9d27b425a819def1721b61e1798acc748b471e54d50a7804bcd","c6684892ae32c0d3fe0c2bb1b7e6bb37ffc86fc91d39c0cfe557aba4816e7766","609b8944af1aa9b73959c0bd766370986176a197c16c27e365e867a0bc85eed8","2ffc9898fdf8f285b73f08ee256ca9a6f20cf3de25c57dd7aa28f7558d3af624","0fb6bab9bd95185809964d513dcfeeab6b5609d280dcc6291b5277e36998afe1","2d18411640dd8fcf1067392b839136628cafef5a648d0d49dc9da2f7d344046e","57597a1e8735ae08b671194c8b64a2c2831fd6ce2793d1bca705dbceb41bdaae","fc9b503ac41bf643bdd2c5bcf21e7e8c052881dd6b94699e3624f3a60e02b0be","665d3d55e94122f2fe1c2dd78dd61774134151557a3b8dd41d49868a642c1277","2259073e3a0fcbd5d873f90465ad8364007668a97c0291a6b6d7975d8edbe30d","05a5f6e843f0e788b2530f08bd8407e4cd37bfdae9c549af25406289d47bfd80","70388aac7550e4cb19e9eb5aafba7ed3333fbae173f0d377643f5fa733317ae9","5620e210666cc9ff9409e6b18b23bdfbfd3edfa21a6b12ac28f48933842396b7","0d0dd5ae0237a3571383b9ac701d40220e1d963d0bbb22473c336225b2ed44a7","1e5577dfce1e114e9dc58a7199bdb9e359b30deb86d29a9f0a0b111fc8d29943","dcc4b56e334bd6f9a8680a5dd343e417cdb03bae06bdc4786211d2cdfd7899e8","02959309d4b7d9a875c4f175abae0a359a074585513d073d1fbb828b704e5663","53c80552acaabb705837f41f5bc28c79322645d3472b5fc214dbf81fa7fb9117","0af026de3ab75c99339016a7aa606da158668df7cfc0c25668c1d1617323da20",{"version":"f254c1abf6bb4c92633159831f924588908da902aa5e04ae45c39bd001f62e2e","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[47,49,50,51,52,53,54,55,56,57,58,59],[47,48,50,51,52,53,54,55,56,57,58,59],[48,49,50,51,52,53,54,55,56,57,58,59],[47,48,49,51,52,53,54,55,56,57,58,59],[47,48,49,50,52,53,54,55,56,57,58,59],[47,48,49,50,51,53,54,55,56,57,58,59],[47,48,49,50,51,52,54,55,56,57,58,59],[47,48,49,50,51,52,53,55,56,57,58,59],[47,48,49,50,51,52,53,54,56,57,58,59],[47,48,49,50,51,52,53,54,55,57,58,59],[47,48,49,50,51,52,53,54,55,56,58,59],[47,48,49,50,51,52,53,54,55,56,57,59],[47,48,49,50,51,52,53,54,55,56,57,58],[59,87,88,90,94,95,96],[61,62],[64,66,67],[61],[64,68],[71],[71,79],[62,63,64,66,67,69,70,72,73,75,76,82,83,85,86,87,88,89,90,91,92,93,94,98,99],[66,67],[61,62,74,76,77,78,80],[61,74],[81],[65],[61,74,76,80],[84],[97],[61,87,88],[88],[45,46,60,95,100],[59],[46,59]],"referencedMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[97,14],[63,15],[70,16],[64,17],[69,18],[71,17],[73,19],[62,17],[72,19],[80,20],[100,21],[68,22],[87,17],[81,23],[75,24],[82,25],[67,26],[76,19],[78,17],[66,26],[83,25],[84,27],[85,28],[86,28],[98,29],[88,17],[91,17],[89,30],[99,31],[90,17],[92,17],[101,32],[95,33],[60,34]],"exportedModulesMap":[[48,1],[49,2],[47,3],[50,4],[51,5],[52,6],[53,7],[54,8],[55,9],[56,10],[57,11],[58,12],[59,13],[97,14],[63,15],[70,16],[64,17],[69,18],[71,17],[73,19],[62,17],[72,19],[80,20],[100,21],[68,22],[87,17],[81,23],[75,24],[82,25],[67,26],[76,19],[78,17],[66,26],[83,25],[84,27],[85,28],[86,28],[98,29],[88,17],[91,17],[89,30],[99,31],[90,17],[92,17],[101,32],[95,33],[60,34]],"semanticDiagnosticsPerFile":[48,49,47,50,51,52,53,54,55,56,57,58,59,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,45,79,97,63,70,64,69,71,73,77,62,72,80,100,68,87,81,96,94,75,82,65,74,67,76,78,66,83,84,85,86,98,88,91,89,99,93,90,92,46,101,95,60,61,102]},"version":"4.4.2"}