@wordpress/dom 3.34.0 → 3.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/data-transfer.js +5 -8
  3. package/build/data-transfer.js.map +1 -1
  4. package/build/dom/clean-node-list.js +4 -8
  5. package/build/dom/clean-node-list.js.map +1 -1
  6. package/build/dom/get-range-height.js +6 -12
  7. package/build/dom/get-range-height.js.map +1 -1
  8. package/build/dom/get-rectangle-from-range.js +3 -6
  9. package/build/dom/get-rectangle-from-range.js.map +1 -1
  10. package/build/dom/get-scroll-container.js +1 -3
  11. package/build/dom/get-scroll-container.js.map +1 -1
  12. package/build/dom/is-edge.js +1 -3
  13. package/build/dom/is-edge.js.map +1 -1
  14. package/build/dom/is-html-input-element.js +1 -1
  15. package/build/dom/is-html-input-element.js.map +1 -1
  16. package/build/dom/place-caret-at-vertical-edge.js +1 -1
  17. package/build/dom/place-caret-at-vertical-edge.js.map +1 -1
  18. package/build/focusable.js +3 -5
  19. package/build/focusable.js.map +1 -1
  20. package/build-module/data-transfer.js +5 -8
  21. package/build-module/data-transfer.js.map +1 -1
  22. package/build-module/dom/clean-node-list.js +4 -8
  23. package/build-module/dom/clean-node-list.js.map +1 -1
  24. package/build-module/dom/get-range-height.js +6 -12
  25. package/build-module/dom/get-range-height.js.map +1 -1
  26. package/build-module/dom/get-rectangle-from-range.js +3 -6
  27. package/build-module/dom/get-rectangle-from-range.js.map +1 -1
  28. package/build-module/dom/get-scroll-container.js +1 -3
  29. package/build-module/dom/get-scroll-container.js.map +1 -1
  30. package/build-module/dom/is-edge.js +1 -3
  31. package/build-module/dom/is-edge.js.map +1 -1
  32. package/build-module/dom/is-html-input-element.js +1 -1
  33. package/build-module/dom/is-html-input-element.js.map +1 -1
  34. package/build-module/dom/place-caret-at-vertical-edge.js +1 -1
  35. package/build-module/dom/place-caret-at-vertical-edge.js.map +1 -1
  36. package/build-module/focusable.js +3 -5
  37. package/build-module/focusable.js.map +1 -1
  38. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.35.0 (2023-06-07)
6
+
5
7
  ## 3.34.0 (2023-05-24)
6
8
 
7
9
  ## 3.33.0 (2023-05-10)
@@ -17,14 +17,11 @@ function getFilesFromDataTransfer(dataTransfer) {
17
17
  Array.from(dataTransfer.items).forEach(item => {
18
18
  const file = item.getAsFile();
19
19
 
20
- if (file && !files.find(_ref => {
21
- let {
22
- name,
23
- type,
24
- size
25
- } = _ref;
26
- return name === file.name && type === file.type && size === file.size;
27
- })) {
20
+ if (file && !files.find(({
21
+ name,
22
+ type,
23
+ size
24
+ }) => name === file.name && type === file.type && size === file.size)) {
28
25
  files.push(file);
29
26
  }
30
27
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD;AAAA,UAAE;AAAEC,QAAAA,IAAF;AAAQC,QAAAA,IAAR;AAAcC,QAAAA;AAAd,OAAF;AAAA,aACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAHf;AAAA,KADC,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD,CAAE;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcC,MAAAA;AAAd,KAAF,KACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAJd,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"]}
@@ -54,12 +54,10 @@ function cleanNodeList(nodeList, doc, schema, inline) {
54
54
  Array.from(nodeList).forEach((
55
55
  /** @type {Node & { nextElementSibling?: unknown }} */
56
56
  node) => {
57
- var _schema$tag$isMatch, _schema$tag;
58
-
59
57
  const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch
60
58
  // function, or with an isMatch function that matches the node.
61
59
 
62
- if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || (_schema$tag$isMatch = (_schema$tag = schema[tag]).isMatch) !== null && _schema$tag$isMatch !== void 0 && _schema$tag$isMatch.call(_schema$tag, node))) {
60
+ if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
63
61
  if ((0, _isElement.default)(node)) {
64
62
  const {
65
63
  attributes = [],
@@ -77,11 +75,9 @@ function cleanNodeList(nodeList, doc, schema, inline) {
77
75
 
78
76
  if (node.hasAttributes()) {
79
77
  // Strip invalid attributes.
80
- Array.from(node.attributes).forEach(_ref => {
81
- let {
82
- name
83
- } = _ref;
84
-
78
+ Array.from(node.attributes).forEach(({
79
+ name
80
+ }) => {
85
81
  if (name !== 'class' && !attributes.includes(name)) {
86
82
  node.removeAttribute(name);
87
83
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","remove","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CACC;AAAE;AAAuDC,EAAAA,IAAzD,KAAmE;AAAA;;AAClE,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADkE,CAGlE;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAhB,2BAA2B,eAAAV,MAAM,CAAEM,GAAF,CAAN,EAAcI,OAAzC,gDAA2B,sCAAyBL,IAAzB,CAD7B,CADD,EAGE;AACD,UAAK,wBAAWA,IAAX,CAAL,EAAyB;AACxB,cAAM;AACLM,UAAAA,UAAU,GAAG,EADR;AAELC,UAAAA,OAAO,GAAG,EAFL;AAGLC,UAAAA,QAHK;AAILC,UAAAA,OAAO,GAAG,EAJL;AAKLC,UAAAA;AALK,YAMFf,MAAM,CAAEM,GAAF,C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UAAP,EAAmBlC,GAAnB,EAAwBC,MAAxB,EAAgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAE,wCAAmBI,IAAnB,CADF,IAEAA,IAAI,CAACgC,kBAHN,EAIE;AACD,kCAAatC,GAAG,CAACuC,aAAJ,CAAmB,IAAnB,CAAb,EAAwCjC,IAAxC;AACA;;AAED,2BAAQA,IAAR;AACA;AACD,GAnJF;AAqJA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","remove","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CACC;AAAE;AAAuDC,EAAAA,IAAzD,KAAmE;AAClE,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADkE,CAGlE;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAhB,IAA2BV,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAd,GAAyBL,IAAzB,CAD7B,CADD,EAGE;AACD,UAAK,wBAAWA,IAAX,CAAL,EAAyB;AACxB,cAAM;AACLM,UAAAA,UAAU,GAAG,EADR;AAELC,UAAAA,OAAO,GAAG,EAFL;AAGLC,UAAAA,QAHK;AAILC,UAAAA,OAAO,GAAG,EAJL;AAKLC,UAAAA;AALK,YAMFf,MAAM,CAAEM,GAAF,CANV,CADwB,CASxB;AACA;;AACA,YAAKO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AgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAE,wCAAmBI,IAAnB,CADF,IAEAA,IAAI,CAACgC,kBAHN,EAIE;AACD,kCAAatC,GAAG,CAACuC,aAAJ,CAAmB,IAAnB,CAAb,EAAwCjC,IAAxC;AACA;;AAED,2BAAQA,IAAR;AACA;AACD,GAnJF;AAqJA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"]}
@@ -19,18 +19,12 @@ function getRangeHeight(range) {
19
19
  return;
20
20
  }
21
21
 
22
- const highestTop = Math.min(...rects.map(_ref => {
23
- let {
24
- top
25
- } = _ref;
26
- return top;
27
- }));
28
- const lowestBottom = Math.max(...rects.map(_ref2 => {
29
- let {
30
- bottom
31
- } = _ref2;
32
- return bottom;
33
- }));
22
+ const highestTop = Math.min(...rects.map(({
23
+ top
24
+ }) => top));
25
+ const lowestBottom = Math.max(...rects.map(({
26
+ bottom
27
+ }) => bottom));
34
28
  return lowestBottom - highestTop;
35
29
  }
36
30
  //# sourceMappingURL=get-range-height.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAeA,GAAf;AAAA,GAAX,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEI,MAAAA;AAAF,KAAF;AAAA,WAAkBA,MAAlB;AAAA,GAAX,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAeA,GAA1B,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEI,IAAAA;AAAF,GAAF,KAAkBA,MAA7B,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
@@ -31,12 +31,9 @@ function getRectangleFromRange(range) {
31
31
  } // Ignore tiny selection at the edge of a range.
32
32
 
33
33
 
34
- const filteredRects = rects.filter(_ref => {
35
- let {
36
- width
37
- } = _ref;
38
- return width > 1;
39
- }); // If it's full of tiny selections, return browser default.
34
+ const filteredRects = rects.filter(({
35
+ width
36
+ }) => width > 1); // If it's full of tiny selections, return browser default.
40
37
 
41
38
  if (filteredRects.length === 0) {
42
39
  return range.getBoundingClientRect();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","height","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAiBA,KAAK,GAAG,CAAzB;AAAA,KAAd,CAAtB,CATwB,CAWxB;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAON,KAAK,CAACU,qBAAN,EAAP;AACA;;AAED,QA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WAAd,EAAR;AACA5B,IAAAA,KAAK,CAAC6B,QAAN,CAAgBL,UAAhB,EAA4BC,KAA5B;AACAzB,IAAAA,KAAK,CAAC8B,MAAN,CAAcN,UAAd,EAA0BC,KAA1B;AACA;;AAED,QAAMvB,KAAK,GAAGF,KAAK,CAACK,cAAN,EAAd,CA/DsD,CAiEtD;AACA;;AACA,MAAKH,KAAK,CAACI,MAAN,GAAe,CAApB,EAAwB;AACvB,WAAO,IAAP;AACA;;AAED,MAAIyB,IAAI,GAAG7B,KAAK,CAAE,CAAF,CAAhB,CAvEsD,CAyEtD;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAE6B,IAAF,IAAUA,IAAI,CAACC,MAAL,KAAgB,CAA/B,EAAmC;AAClC,0CAAiBV,aAAjB,EAAgC,eAAhC;AACA,UAAMW,OAAO,GAAGX,aAAa,CAACY,cAAd,CAA8B,QAA9B,CAAhB,CAFkC,CAGlC;;AACAlC,IAAAA,KAAK,GAAGA,KAAK,CAACmC,UAAN,EAAR;AACAnC,IAAAA,KAAK,CAACoC,UAAN,CAAkBH,OAAlB;AACAF,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACA,0CAAiB4B,OAAO,CAACT,UAAzB,EAAqC,oBAArC;AACAS,IAAAA,OAAO,CAACT,UAAR,CAAmBa,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOF,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect || rect.height === 0 ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","height","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiBA,KAAK,GAAG,CAAvC,CAAtB,CATwB,CAWxB;;AACA,QAAKF,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AFyB,CAApC;AAIA,0CAAiBC,aAAjB,EAAgC,eAAhC;AACAtB,IAAAA,KAAK,GAAGsB,aAAa,CAACM,WAAd,EAAR;AACA5B,IAAAA,KAAK,CAAC6B,QAAN,CAAgBL,UAAhB,EAA4BC,KAA5B;AACAzB,IAAAA,KAAK,CAAC8B,MAAN,CAAcN,UAAd,EAA0BC,KAA1B;AACA;;AAED,QAAMvB,KAAK,GAAGF,KAAK,CAACK,cAAN,EAAd,CA/DsD,CAiEtD;AACA;;AACA,MAAKH,KAAK,CAACI,MAAN,GAAe,CAApB,EAAwB;AACvB,WAAO,IAAP;AACA;;AAED,MAAIyB,IAAI,GAAG7B,KAAK,CAAE,CAAF,CAAhB,CAvEsD,CAyEtD;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAE6B,IAAF,IAAUA,IAAI,CAACC,MAAL,KAAgB,CAA/B,EAAmC;AAClC,0CAAiBV,aAAjB,EAAgC,eAAhC;AACA,UAAMW,OAAO,GAAGX,aAAa,CAACY,cAAd,CAA8B,QAA9B,CAAhB,CAFkC,CAGlC;;AACAlC,IAAAA,KAAK,GAAGA,KAAK,CAACmC,UAAN,EAAR;AACAnC,IAAAA,KAAK,CAACoC,UAAN,CAAkBH,OAAlB;AACAF,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACA,0CAAiB4B,OAAO,CAACT,UAAzB,EAAqC,oBAArC;AACAS,IAAAA,OAAO,CAACT,UAAR,CAAmBa,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOF,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect || rect.height === 0 ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
@@ -22,9 +22,7 @@ var _getComputedStyle = _interopRequireDefault(require("./get-computed-style"));
22
22
  * Defaults to 'vertical'.
23
23
  * @return {Element | undefined} Scrollable container node, if found.
24
24
  */
25
- function getScrollContainer(node) {
26
- let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
27
-
25
+ function getScrollContainer(node, direction = 'vertical') {
28
26
  if (!node) {
29
27
  return undefined;
30
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-scroll-container.js"],"names":["getScrollContainer","node","direction","undefined","scrollHeight","clientHeight","overflowY","test","scrollWidth","clientWidth","overflowX","ownerDocument","parentNode"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAT,CAA6BC,IAA7B,EAA4D;AAAA,MAAzBC,SAAyB,uEAAb,UAAa;;AAC1E,MAAK,CAAED,IAAP,EAAc;AACb,WAAOE,SAAP;AACA;;AAED,MAAKD,SAAS,KAAK,UAAd,IAA4BA,SAAS,KAAK,KAA/C,EAAuD;AACtD;AACA,QAAKD,IAAI,CAACG,YAAL,GAAoBH,IAAI,CAACI,YAA9B,EAA6C;AAC5C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgB,+BAAkBL,IAAlB,CAAtB;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBD,SAAtB,CAAL,EAAyC;AACxC,eAAOL,IAAP;AACA;AACD;AACD;;AAED,MAAKC,SAAS,KAAK,YAAd,IAA8BA,SAAS,KAAK,KAAjD,EAAyD;AACxD;AACA,QAAKD,IAAI,CAACO,WAAL,GAAmBP,IAAI,CAACQ,WAA7B,EAA2C;AAC1C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgB,+BAAkBT,IAAlB,CAAtB;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBG,SAAtB,CAAL,EAAyC;AACxC,eAAOT,IAAP;AACA;AACD;AACD;;AAED,MAAKA,IAAI,CAACU,aAAL,KAAuBV,IAAI,CAACW,UAAjC,EAA8C;AAC7C,WAAOX,IAAP;AACA,GA/ByE,CAiC1E;;;AACA,SAAOD,kBAAkB;AACxB;AAAyBC,EAAAA,IAAI,CAACW,UADN,EAExBV,SAFwB,CAAzB;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-scroll-container.js"],"names":["getScrollContainer","node","direction","undefined","scrollHeight","clientHeight","overflowY","test","scrollWidth","clientWidth","overflowX","ownerDocument","parentNode"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAT,CAA6BC,IAA7B,EAAmCC,SAAS,GAAG,UAA/C,EAA4D;AAC1E,MAAK,CAAED,IAAP,EAAc;AACb,WAAOE,SAAP;AACA;;AAED,MAAKD,SAAS,KAAK,UAAd,IAA4BA,SAAS,KAAK,KAA/C,EAAuD;AACtD;AACA,QAAKD,IAAI,CAACG,YAAL,GAAoBH,IAAI,CAACI,YAA9B,EAA6C;AAC5C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgB,+BAAkBL,IAAlB,CAAtB;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBD,SAAtB,CAAL,EAAyC;AACxC,eAAOL,IAAP;AACA;AACD;AACD;;AAED,MAAKC,SAAS,KAAK,YAAd,IAA8BA,SAAS,KAAK,KAAjD,EAAyD;AACxD;AACA,QAAKD,IAAI,CAACO,WAAL,GAAmBP,IAAI,CAACQ,WAA7B,EAA2C;AAC1C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgB,+BAAkBT,IAAlB,CAAtB;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBG,SAAtB,CAAL,EAAyC;AACxC,eAAOT,IAAP;AACA;AACD;AACD;;AAED,MAAKA,IAAI,CAACU,aAAL,KAAuBV,IAAI,CAACW,UAAjC,EAA8C;AAC7C,WAAOX,IAAP;AACA,GA/ByE,CAiC1E;;;AACA,SAAOD,kBAAkB;AACxB;AAAyBC,EAAAA,IAAI,CAACW,UADN,EAExBV,SAFwB,CAAzB;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"]}
@@ -36,9 +36,7 @@ var _isInputOrTextArea = _interopRequireDefault(require("./is-input-or-text-area
36
36
  *
37
37
  * @return {boolean} True if at the edge, false if not.
38
38
  */
39
- function isEdge(container, isReverse) {
40
- let onlyVertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
41
-
39
+ function isEdge(container, isReverse, onlyVertical = false) {
42
40
  if ((0, _isInputOrTextArea.default)(container) && typeof container.selectionStart === 'number') {
43
41
  if (container.selectionStart !== container.selectionEnd) {
44
42
  return false;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,EAA8D;AAAA,MAAvBC,YAAuB,uEAAR,KAAQ;;AAC5E,MACC,gCAAmBF,SAAnB,KACA,OAAOA,SAAS,CAACG,cAAjB,KAAoC,QAFrC,EAGE;AACD,QAAKH,SAAS,CAACG,cAAV,KAA6BH,SAAS,CAACI,YAA5C,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,QAAKH,SAAL,EAAiB;AAChB,aAAOD,SAAS,CAACG,cAAV,KAA6B,CAApC;AACA;;AAED,WAAOH,SAAS,CAACK,KAAV,CAAgBC,MAAhB,KAA2BN,SAAS,C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B,CA9D4E,CAgE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMC,CAAC,GAAGH,YAAY,GAAGC,aAAa,CAACG,IAAd,GAAqB,CAAxB,GAA4BH,aAAa,CAACI,KAAd,GAAsB,CAAxE;AACA,QAAMC,CAAC,GAAG7B,SAAS,GAAGwB,aAAa,CAACM,GAAd,GAAoB,CAAvB,GAA2BN,aAAa,CAACO,MAAd,GAAuB,CAArE;AACA,QAAMC,SAAS,GAAG,wCACjBzB,aADiB,EAEjBmB,CAFiB,EAGjBG,CAHiB;AAIjB;AAA6B9B,EAAAA,SAJZ,CAAlB;;AAOA,MAAK,CAAEiC,SAAP,EAAmB;AAClB,WAAO,KAAP;AACA;;AAED,QAAMC,QAAQ,GAAG,oCAAuBD,SAAvB,CAAjB;;AAEA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,QAAMC,YAAY,GAAGlC,SAAS,GAAG,KAAH,GAAW,QAAzC;AACA,QAAMmC,cAAc,GAAGZ,YAAY,GAAG,MAAH,GAAY,OAA/C;AACA,QAAMa,YAAY,GAAGH,QAAQ,CAAEC,YAAF,CAAR,GAA2Bd,SAAS,CAAEc,YAAF,CAAzD;AACA,QAAMG,cAAc,GACnBJ,QAAQ,CAAEE,cAAF,CAAR,GAA6BhB,kBAAkB,CAAEgB,cAAF,CADhD,CAhG4E,CAmG5E;;AACA,QAAMG,eAAe,GAAGC,IAAI,CAACC,GAAL,CAAUJ,YAAV,KAA4B,CAApD;AACA,QAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAL,CAAUH,cAAV,KAA8B,CAAxD;AAEA,SAAOpC,YAAY,GAChBqC,eADgB,GAEhBA,eAAe,IAAIG,iBAFtB;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {Element} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\t/** @type {HTMLElement} */ ( container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,EAAuCC,YAAY,GAAG,KAAtD,EAA8D;AAC5E,MACC,gCAAmBF,SAAnB,KACA,OAAOA,SAAS,CAACG,cAAjB,KAAoC,QAFrC,EAGE;AACD,QAAKH,SAAS,CAACG,cAAV,KAA6BH,SAAS,CAACI,YAA5C,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,QAAKH,SAAL,EAAiB;AAChB,aAAOD,SAAS,CAACG,cAAV,KAA6B,CAApC;AACA;;AAED,WAAOH,SAAS,CAACK,KAAV,CAAgBC,MAAhB,KAA2BN,SAAS,CAACG,cAA5C;AACA;;AAED,MAAK;AAAI;AAA6BH,EAAAA,SAAF,CAAcO,iBAAlD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAoBR,SAA1B;AACA,QAAM;AAAES,IAAAA;AAAF,MAAkBD,aAAxB;AAEA,wCAAiBC,WAAjB,EAA8B,aAA9B;AACA,QAAMC,SAAS,GAAGD,WAAW,CAACE,YAAZ,EAAlB;;AAEA,MAAK,CAAED,SAAF,IAAe,CAAEA,SAAS,CAACE,UAAhC,EAA6C;AAC5C,WAAO,KAAP;AACA;;AAED,QAAMC,KAAK,GAAGH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAAd;AACA,QAAMC,cAAc,GAAGF,KAAK,CAACG,UAAN,EAAvB;AAC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,SAAvB,CAAjB;;AAEA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,QAAMC,YAAY,GAAGlC,SAAS,GAAG,KAAH,GAAW,QAAzC;AACA,QAAMmC,cAAc,GAAGZ,YAAY,GAAG,MAAH,GAAY,OAA/C;AACA,QAAMa,YAAY,GAAGH,QAAQ,CAAEC,YAAF,CAAR,GAA2Bd,SAAS,CAAEc,YAAF,CAAzD;AACA,QAAMG,cAAc,GACnBJ,QAAQ,CAAEE,cAAF,CAAR,GAA6BhB,kBAAkB,CAAEgB,cAAF,CADhD,CAhG4E,CAmG5E;;AACA,QAAMG,eAAe,GAAGC,IAAI,CAACC,GAAL,CAAUJ,YAAV,KAA4B,CAApD;AACA,QAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAL,CAAUH,cAAV,KAA8B,CAAxD;AAEA,SAAOpC,YAAY,GAChBqC,eADgB,GAEhBA,eAAe,IAAIG,iBAFtB;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {Element} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\t/** @type {HTMLElement} */ ( container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"]}
@@ -13,6 +13,6 @@ exports.default = isHTMLInputElement;
13
13
  */
14
14
  function isHTMLInputElement(node) {
15
15
  /* eslint-enable jsdoc/valid-types */
16
- return (node === null || node === void 0 ? void 0 : node.nodeName) === 'INPUT';
16
+ return node?.nodeName === 'INPUT';
17
17
  }
18
18
  //# sourceMappingURL=is-html-input-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"names":["isHTMLInputElement","node","nodeName"],"mappings":";;;;;;;AAAA;;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAT,CAA6BC,IAA7B,EAAoC;AAClD;AACA,SAAO,CAAAA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEC,QAAN,MAAmB,OAA1B;AACA","sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"names":["isHTMLInputElement","node","nodeName"],"mappings":";;;;;;;AAAA;;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAT,CAA6BC,IAA7B,EAAoC;AAClD;AACA,SAAOA,IAAI,EAAEC,QAAN,KAAmB,OAA1B;AACA","sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"]}
@@ -21,6 +21,6 @@ var _placeCaretAtEdge = _interopRequireDefault(require("./place-caret-at-edge"))
21
21
  * @param {DOMRect} [rect] The rectangle to position the caret with.
22
22
  */
23
23
  function placeCaretAtVerticalEdge(container, isReverse, rect) {
24
- return (0, _placeCaretAtEdge.default)(container, isReverse, rect === null || rect === void 0 ? void 0 : rect.left);
24
+ return (0, _placeCaretAtEdge.default)(container, isReverse, rect?.left);
25
25
  }
26
26
  //# sourceMappingURL=place-caret-at-vertical-edge.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-vertical-edge.js"],"names":["placeCaretAtVerticalEdge","container","isReverse","rect","left"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAT,CAAmCC,SAAnC,EAA8CC,SAA9C,EAAyDC,IAAzD,EAAgE;AAC9E,SAAO,+BAAkBF,SAAlB,EAA6BC,SAA7B,EAAwCC,IAAxC,aAAwCA,IAAxC,uBAAwCA,IAAI,CAAEC,IAA9C,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge( container, isReverse, rect ) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-vertical-edge.js"],"names":["placeCaretAtVerticalEdge","container","isReverse","rect","left"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAT,CAAmCC,SAAnC,EAA8CC,SAA9C,EAAyDC,IAAzD,EAAgE;AAC9E,SAAO,+BAAkBF,SAAlB,EAA6BC,SAA7B,EAAwCC,IAAI,EAAEC,IAA9C,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge( container, isReverse, rect ) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"]}
@@ -91,11 +91,9 @@ function isValidFocusableArea(element) {
91
91
  */
92
92
 
93
93
 
94
- function find(context) {
95
- let {
96
- sequential = false
97
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
98
-
94
+ function find(context, {
95
+ sequential = false
96
+ } = {}) {
99
97
  /* eslint-disable jsdoc/no-undefined-types */
100
98
 
101
99
  /** @type {NodeListOf<HTMLElement>} */
@@ -1 +1 @@
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":";;;;;;;AAA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D,OAAO,CAACE,gBAAR,CAA0BnB,aAAa,CAAEC,UAAF,CAAvC,CAAjB;AAEA,SAAOmB,KAAK,CAACC,IAAN,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 {HTMLElement[]} 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"]}
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,UAAxB,EAAqC;AACpC,SAAO,CACNA,UAAU,GAAG,iCAAH,GAAuC,YAD3C,EAEN,SAFM,EAGN,wBAHM,EAIN,4CAJM,EAKN,wBALM,EAMN,0BANM,EAON,6BAPM,EAQN,QARM,EASN,OATM,EAUN,YAVM,EAWN,gDAXM,EAYLC,IAZK,CAYC,GAZD,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,SACCA,OAAO,CAACC,WAAR,GAAsB,CAAtB,IACAD,OAAO,CAACE,YAAR,GAAuB,CADvB,IAEAF,OAAO,CAACG,cAAR,GAAyBC,MAAzB,GAAkC,CAHnC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA+BL,OAA/B,EAAyC;AACxC;AACA,QAAMM,GAAG,GAAGN,OAAO,CAACO,OAAR,CAAiB,WAAjB,CAAZ;;AACA,MAAK,CAAED,GAAP,EAAa;AACZ,WAAO,KAAP;AACA;AAED;;;AACA,QAAME,GAAG,GAAGR,OAAO,CAACS,aAAR,CAAsBC,aAAtB,CACX,kBAAkBJ,GAAG,CAACK,IAAtB,GAA6B,IADlB,CAAZ;AAGA,SAAO,CAAC,CAAEH,GAAH,IAAUT,SAAS,CAAES,GAAF,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,IAAT,CAAeC,OAAf,EAAwB;AAAEhB,EAAAA,UAAU,GAAG;AAAf,IAAyB,EAAjD,EAAsD;AAC5D;;AACA;;AACA;AACA,QAAMiB,QAAQ,GAAGD,OAAO,CAACE,gBAAR,CAA0BnB,aAAa,CAAEC,UAAF,CAAvC,CAAjB;AAEA,SAAOmB,KAAK,CAACC,IAAN,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 {HTMLElement[]} 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"]}
@@ -10,14 +10,11 @@ export function getFilesFromDataTransfer(dataTransfer) {
10
10
  Array.from(dataTransfer.items).forEach(item => {
11
11
  const file = item.getAsFile();
12
12
 
13
- if (file && !files.find(_ref => {
14
- let {
15
- name,
16
- type,
17
- size
18
- } = _ref;
19
- return name === file.name && type === file.type && size === file.size;
20
- })) {
13
+ if (file && !files.find(({
14
+ name,
15
+ type,
16
+ size
17
+ }) => name === file.name && type === file.type && size === file.size)) {
21
18
  files.push(file);
22
19
  }
23
20
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD;AAAA,UAAE;AAAEC,QAAAA,IAAF;AAAQC,QAAAA,IAAR;AAAcC,QAAAA;AAAd,OAAF;AAAA,aACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAHf;AAAA,KADC,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD,CAAE;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcC,MAAAA;AAAd,KAAF,KACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAJd,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"]}
@@ -40,12 +40,10 @@ export default function cleanNodeList(nodeList, doc, schema, inline) {
40
40
  Array.from(nodeList).forEach((
41
41
  /** @type {Node & { nextElementSibling?: unknown }} */
42
42
  node) => {
43
- var _schema$tag$isMatch, _schema$tag;
44
-
45
43
  const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch
46
44
  // function, or with an isMatch function that matches the node.
47
45
 
48
- if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || (_schema$tag$isMatch = (_schema$tag = schema[tag]).isMatch) !== null && _schema$tag$isMatch !== void 0 && _schema$tag$isMatch.call(_schema$tag, node))) {
46
+ if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
49
47
  if (isElement(node)) {
50
48
  const {
51
49
  attributes = [],
@@ -63,11 +61,9 @@ export default function cleanNodeList(nodeList, doc, schema, inline) {
63
61
 
64
62
  if (node.hasAttributes()) {
65
63
  // Strip invalid attributes.
66
- Array.from(node.attributes).forEach(_ref => {
67
- let {
68
- name
69
- } = _ref;
70
-
64
+ Array.from(node.attributes).forEach(({
65
+ name
66
+ }) => {
71
67
  if (name !== 'class' && !attributes.includes(name)) {
72
68
  node.removeAttribute(name);
73
69
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["isEmpty","remove","unwrap","isPhrasingContent","insertAfter","isElement","noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,YAApB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,cAAtB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASC,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CACC;AAAE;AAAuDC,EAAAA,IAAzD,KAAmE;AAAA;;AAClE,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADkE,CAGlE;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAhB,2BAA2B,eAAAV,MAAM,CAAEM,GAAF,CAAN,EAAcI,OAAzC,gDAA2B,sCAAyBL,IAAzB,CAD7B,CADD,EAGE;AACD,UAAKV,SAAS,CAAEU,IAAF,CAAd,EAAyB;AACxB,cAAM;AACLM,UAAAA,UAAU,GAAG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AMA,aA5Cc,CA6Cf;;AACA,WA9CD,MA8CO;AACN,mBAAQI,IAAI,CAAC8B,UAAb,EAA0B;AACzB5C,cAAAA,MAAM,CAAEc,IAAI,CAAC8B,UAAP,CAAN;AACA;AACD;AACD;AACD,OAzHA,CA0HD;;AACA,KA9HD,MA8HO;AACNtC,MAAAA,aAAa,CAAEQ,IAAI,CAAC2B,UAAP,EAAmBjC,GAAnB,EAAwBC,MAAxB,EAAgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAER,iBAAiB,CAAEY,IAAF,CADnB,IAEAA,IAAI,CAAC+B,kBAHN,EAIE;AACD1C,QAAAA,WAAW,CAAEK,GAAG,CAACsC,aAAJ,CAAmB,IAAnB,CAAF,EAA6BhC,IAA7B,CAAX;AACA;;AAEDb,MAAAA,MAAM,CAAEa,IAAF,CAAN;AACA;AACD,GAnJF;AAqJA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["isEmpty","remove","unwrap","isPhrasingContent","insertAfter","isElement","noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,YAApB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,cAAtB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASC,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CACC;AAAE;AAAuDC,EAAAA,IAAzD,KAAmE;AAClE,UAAMC,GAAG,GAAGD,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Ab;;AAOA,kBACCC,KAAK,CAACC,IAAN,CAAYE,IAAI,CAAC2B,UAAjB,EAA8BJ,IAA9B,CACGM,KAAF,IACC,CAAEzC,iBAAiB,CAAEyC,KAAF,CAFrB,CADD,EAKE;AACD1C,gBAAAA,MAAM,CAAEa,IAAF,CAAN;AACA;AACD,aApBM,MAoBA;AACNR,cAAAA,aAAa,CACZQ,IAAI,CAAC2B,UADO,EAEZjC,GAFY,EAGZc,QAHY,EAIZZ,MAJY,CAAb;AAMA,aA5Cc,CA6Cf;;AACA,WA9CD,MA8CO;AACN,mBAAQI,IAAI,CAAC8B,UAAb,EAA0B;AACzB5C,cAAAA,MAAM,CAAEc,IAAI,CAAC8B,UAAP,CAAN;AACA;AACD;AACD;AACD,OAzHA,CA0HD;;AACA,KA9HD,MA8HO;AACNtC,MAAAA,aAAa,CAAEQ,IAAI,CAAC2B,UAAP,EAAmBjC,GAAnB,EAAwBC,MAAxB,EAAgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAER,iBAAiB,CAAEY,IAAF,CADnB,IAEAA,IAAI,CAAC+B,kBAHN,EAIE;AACD1C,QAAAA,WAAW,CAAEK,GAAG,CAACsC,aAAJ,CAAmB,IAAnB,CAAF,EAA6BhC,IAA7B,CAAX;AACA;;AAEDb,MAAAA,MAAM,CAAEa,IAAF,CAAN;AACA;AACD,GAnJF;AAqJA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"]}
@@ -12,18 +12,12 @@ export default function getRangeHeight(range) {
12
12
  return;
13
13
  }
14
14
 
15
- const highestTop = Math.min(...rects.map(_ref => {
16
- let {
17
- top
18
- } = _ref;
19
- return top;
20
- }));
21
- const lowestBottom = Math.max(...rects.map(_ref2 => {
22
- let {
23
- bottom
24
- } = _ref2;
25
- return bottom;
26
- }));
15
+ const highestTop = Math.min(...rects.map(({
16
+ top
17
+ }) => top));
18
+ const lowestBottom = Math.max(...rects.map(({
19
+ bottom
20
+ }) => bottom));
27
21
  return lowestBottom - highestTop;
28
22
  }
29
23
  //# sourceMappingURL=get-range-height.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAeA,GAAf;AAAA,GAAX,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEI,MAAAA;AAAF,KAAF;AAAA,WAAkBA,MAAlB;AAAA,GAAX,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAeA,GAA1B,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEI,IAAAA;AAAF,GAAF,KAAkBA,MAA7B,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
@@ -23,12 +23,9 @@ export default function getRectangleFromRange(range) {
23
23
  } // Ignore tiny selection at the edge of a range.
24
24
 
25
25
 
26
- const filteredRects = rects.filter(_ref => {
27
- let {
28
- width
29
- } = _ref;
30
- return width > 1;
31
- }); // If it's full of tiny selections, return browser default.
26
+ const filteredRects = rects.filter(({
27
+ width
28
+ }) => width > 1); // If it's full of tiny selections, return browser default.
32
29
 
33
30
  if (filteredRects.length === 0) {
34
31
  return range.getBoundingClientRect();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["assertIsDefined","getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","height","padNode","createTextNode","cloneRange","insertNode","removeChild"],"m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O,GAAGX,aAAa,CAACY,cAAd,CAA8B,QAA9B,CAAhB,CAFkC,CAGlC;;AACAlC,IAAAA,KAAK,GAAGA,KAAK,CAACmC,UAAN,EAAR;AACAnC,IAAAA,KAAK,CAACoC,UAAN,CAAkBH,OAAlB;AACAF,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACAP,IAAAA,eAAe,CAAEmC,OAAO,CAACT,UAAV,EAAsB,oBAAtB,CAAf;AACAS,IAAAA,OAAO,CAACT,UAAR,CAAmBa,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOF,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect || rect.height === 0 ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["assertIsDefined","getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","height","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,4BAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiBA,KAAK,GAAG,CAAvC,CAAtB,CATwB,CAWxB;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAON,KAAK,CAACU,qBAAN,EAAP;AACA;;AAED,QAAKH,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAOC,aAAa,CAAE,CAAF,CAApB;AACA;;AAED,QAAI;AACHI,MAAAA,GAAG,EAAEC,WADF;AAEHC,MAAAA,MAAM,EAAEC,cAFL;AAGHC,MAAAA,IAAI,EAAEC,YAHH;AAIHC,MAAAA,KAAK,EAAEC;AAJJ,QAKAX,aAAa,CAAE,CAAF,CALjB;;AAOA,SAAM,MAAM;AAAEI,MAAAA,GAAF;AAAOE,MAAAA,MAAP;AAAeE,MAAAA,IAAf;AAAqBE,MAAAA;AAArB,KA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E,CAAF,CAAhB,CAvEsD,CAyEtD;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAE6B,IAAF,IAAUA,IAAI,CAACC,MAAL,KAAgB,CAA/B,EAAmC;AAClClC,IAAAA,eAAe,CAAEwB,aAAF,EAAiB,eAAjB,CAAf;AACA,UAAMW,OAAO,GAAGX,aAAa,CAACY,cAAd,CAA8B,QAA9B,CAAhB,CAFkC,CAGlC;;AACAlC,IAAAA,KAAK,GAAGA,KAAK,CAACmC,UAAN,EAAR;AACAnC,IAAAA,KAAK,CAACoC,UAAN,CAAkBH,OAAlB;AACAF,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACAP,IAAAA,eAAe,CAAEmC,OAAO,CAACT,UAAV,EAAsB,oBAAtB,CAAf;AACAS,IAAAA,OAAO,CAACT,UAAR,CAAmBa,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOF,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect || rect.height === 0 ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
@@ -12,9 +12,7 @@ import getComputedStyle from './get-computed-style';
12
12
  * @return {Element | undefined} Scrollable container node, if found.
13
13
  */
14
14
 
15
- export default function getScrollContainer(node) {
16
- let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
17
-
15
+ export default function getScrollContainer(node, direction = 'vertical') {
18
16
  if (!node) {
19
17
  return undefined;
20
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-scroll-container.js"],"names":["getComputedStyle","getScrollContainer","node","direction","undefined","scrollHeight","clientHeight","overflowY","test","scrollWidth","clientWidth","overflowX","ownerDocument","parentNode"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,sBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,kBAAT,CAA6BC,IAA7B,EAA4D;AAAA,MAAzBC,SAAyB,uEAAb,UAAa;;AAC1E,MAAK,CAAED,IAAP,EAAc;AACb,WAAOE,SAAP;AACA;;AAED,MAAKD,SAAS,KAAK,UAAd,IAA4BA,SAAS,KAAK,KAA/C,EAAuD;AACtD;AACA,QAAKD,IAAI,CAACG,YAAL,GAAoBH,IAAI,CAACI,YAA9B,EAA6C;AAC5C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgBP,gBAAgB,CAAEE,IAAF,CAAtC;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBD,SAAtB,CAAL,EAAyC;AACxC,eAAOL,IAAP;AACA;AACD;AACD;;AAED,MAAKC,SAAS,KAAK,YAAd,IAA8BA,SAAS,KAAK,KAAjD,EAAyD;AACxD;AACA,QAAKD,IAAI,CAACO,WAAL,GAAmBP,IAAI,CAACQ,WAA7B,EAA2C;AAC1C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgBX,gBAAgB,CAAEE,IAAF,CAAtC;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBG,SAAtB,CAAL,EAAyC;AACxC,eAAOT,IAAP;AACA;AACD;AACD;;AAED,MAAKA,IAAI,CAACU,aAAL,KAAuBV,IAAI,CAACW,UAAjC,EAA8C;AAC7C,WAAOX,IAAP;AACA,GA/ByE,CAiC1E;;;AACA,SAAOD,kBAAkB;AACxB;AAAyBC,EAAAA,IAAI,CAACW,UADN,EAExBV,SAFwB,CAAzB;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/get-scroll-container.js"],"names":["getComputedStyle","getScrollContainer","node","direction","undefined","scrollHeight","clientHeight","overflowY","test","scrollWidth","clientWidth","overflowX","ownerDocument","parentNode"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,sBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,kBAAT,CAA6BC,IAA7B,EAAmCC,SAAS,GAAG,UAA/C,EAA4D;AAC1E,MAAK,CAAED,IAAP,EAAc;AACb,WAAOE,SAAP;AACA;;AAED,MAAKD,SAAS,KAAK,UAAd,IAA4BA,SAAS,KAAK,KAA/C,EAAuD;AACtD;AACA,QAAKD,IAAI,CAACG,YAAL,GAAoBH,IAAI,CAACI,YAA9B,EAA6C;AAC5C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgBP,gBAAgB,CAAEE,IAAF,CAAtC;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBD,SAAtB,CAAL,EAAyC;AACxC,eAAOL,IAAP;AACA;AACD;AACD;;AAED,MAAKC,SAAS,KAAK,YAAd,IAA8BA,SAAS,KAAK,KAAjD,EAAyD;AACxD;AACA,QAAKD,IAAI,CAACO,WAAL,GAAmBP,IAAI,CAACQ,WAA7B,EAA2C;AAC1C;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAgBX,gBAAgB,CAAEE,IAAF,CAAtC;;AAEA,UAAK,gBAAgBM,IAAhB,CAAsBG,SAAtB,CAAL,EAAyC;AACxC,eAAOT,IAAP;AACA;AACD;AACD;;AAED,MAAKA,IAAI,CAACU,aAAL,KAAuBV,IAAI,CAACW,UAAjC,EAA8C;AAC7C,WAAOX,IAAP;AACA,GA/ByE,CAiC1E;;;AACA,SAAOD,kBAAkB;AACxB;AAAyBC,EAAAA,IAAI,CAACW,UADN,EAExBV,SAFwB,CAAzB;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"]}
@@ -20,9 +20,7 @@ import isInputOrTextArea from './is-input-or-text-area';
20
20
  * @return {boolean} True if at the edge, false if not.
21
21
  */
22
22
 
23
- export default function isEdge(container, isReverse) {
24
- let onlyVertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
25
-
23
+ export default function isEdge(container, isReverse, onlyVertical = false) {
26
24
  if (isInputOrTextArea(container) && typeof container.selectionStart === 'number') {
27
25
  if (container.selectionStart !== container.selectionEnd) {
28
26
  return false;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isRTL","getRangeHeight","getRectangleFromRange","isSelectionForward","hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,UAAlB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,eAAT,QAAgC,4BAAhC;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,EAA8D;AAAA,MAAvBC,YAAuB,uEAAR,KAAQ;;AAC5E,MACCJ,iBAAiB,CAAEE,SAAF,CAAjB,IACA,OAAOA,SAAS,CAACG,cAAjB,KAAoC,QAFrC,EAGE;AACD,QAAKH,SAAS,CAACG,cAAV,KAA6BH,SAAS,CAACI,YAA5C,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,QAAKH,SAAL,EAAiB;AAChB,aAAOD,SAAS,CAACG,cAAV,KAA6B,CAApC;AACA;;AAED,WAAOH,SAAS,CAACK,KAAV,CAAgBC,MAAhB,KAA2BN,SAAS,CAACG,cAA5C;AACA;;AAED,MAAK;AAAI;AAA6BH,EAAAA,SAAF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AAtB,CA9D4E,CAgE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMC,CAAC,GAAGH,YAAY,GAAGC,aAAa,CAACG,IAAd,GAAqB,CAAxB,GAA4BH,aAAa,CAACI,KAAd,GAAsB,CAAxE;AACA,QAAMC,CAAC,GAAG7B,SAAS,GAAGwB,aAAa,CAACM,GAAd,GAAoB,CAAvB,GAA2BN,aAAa,CAACO,MAAd,GAAuB,CAArE;AACA,QAAMC,SAAS,GAAGrC,yBAAyB,CAC1CY,aAD0C,EAE1CmB,CAF0C,EAG1CG,CAH0C;AAI1C;AAA6B9B,EAAAA,SAJa,CAA3C;;AAOA,MAAK,CAAEiC,SAAP,EAAmB;AAClB,WAAO,KAAP;AACA;;AAED,QAAMC,QAAQ,GAAGxC,qBAAqB,CAAEuC,SAAF,CAAtC;;AAEA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,QAAMC,YAAY,GAAGlC,SAAS,GAAG,KAAH,GAAW,QAAzC;AACA,QAAMmC,cAAc,GAAGZ,YAAY,GAAG,MAAH,GAAY,OAA/C;AACA,QAAMa,YAAY,GAAGH,QAAQ,CAAEC,YAAF,CAAR,GAA2Bd,SAAS,CAAEc,YAAF,CAAzD;AACA,QAAMG,cAAc,GACnBJ,QAAQ,CAAEE,cAAF,CAAR,GAA6BhB,kBAAkB,CAAEgB,cAAF,CADhD,CAhG4E,CAmG5E;;AACA,QAAMG,eAAe,GAAGC,IAAI,CAACC,GAAL,CAAUJ,YAAV,KAA4B,CAApD;AACA,QAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAL,CAAUH,cAAV,KAA8B,CAAxD;AAEA,SAAOpC,YAAY,GAChBqC,eADgB,GAEhBA,eAAe,IAAIG,iBAFtB;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {Element} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\t/** @type {HTMLElement} */ ( container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isRTL","getRangeHeight","getRectangleFromRange","isSelectionForward","hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,UAAlB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,eAAT,QAAgC,4BAAhC;AACA,OAAOC,iBAAP,MAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,EAAuCC,YAAY,GAAG,KAAtD,EAA8D;AAC5E,MACCJ,iBAAiB,CAAEE,SAAF,CAAjB,IACA,OAAOA,SAAS,CAACG,cAAjB,KAAoC,QAFrC,EAGE;AACD,QAAKH,SAAS,CAACG,cAAV,KAA6BH,SAAS,CAACI,YAA5C,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,QAAKH,SAAL,EAAiB;AAChB,aAAOD,SAAS,CAACG,cAAV,KAA6B,CAApC;AACA;;AAED,WAAOH,SAAS,CAACK,KAAV,CAAgBC,MAAhB,KAA2BN,SAAS,CAACG,cAA5C;AACA;;AAED,MAAK;AAAI;AAA6BH,EAAAA,SAAF,CAAcO,iBAAlD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAoBR,SAA1B;AACA,QAAM;AAAES,IAAAA;AAAF,MAA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B,CAAxB,GAA4BH,aAAa,CAACI,KAAd,GAAsB,CAAxE;AACA,QAAMC,CAAC,GAAG7B,SAAS,GAAGwB,aAAa,CAACM,GAAd,GAAoB,CAAvB,GAA2BN,aAAa,CAACO,MAAd,GAAuB,CAArE;AACA,QAAMC,SAAS,GAAGrC,yBAAyB,CAC1CY,aAD0C,EAE1CmB,CAF0C,EAG1CG,CAH0C;AAI1C;AAA6B9B,EAAAA,SAJa,CAA3C;;AAOA,MAAK,CAAEiC,SAAP,EAAmB;AAClB,WAAO,KAAP;AACA;;AAED,QAAMC,QAAQ,GAAGxC,qBAAqB,CAAEuC,SAAF,CAAtC;;AAEA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,QAAMC,YAAY,GAAGlC,SAAS,GAAG,KAAH,GAAW,QAAzC;AACA,QAAMmC,cAAc,GAAGZ,YAAY,GAAG,MAAH,GAAY,OAA/C;AACA,QAAMa,YAAY,GAAGH,QAAQ,CAAEC,YAAF,CAAR,GAA2Bd,SAAS,CAAEc,YAAF,CAAzD;AACA,QAAMG,cAAc,GACnBJ,QAAQ,CAAEE,cAAF,CAAR,GAA6BhB,kBAAkB,CAAEgB,cAAF,CADhD,CAhG4E,CAmG5E;;AACA,QAAMG,eAAe,GAAGC,IAAI,CAACC,GAAL,CAAUJ,YAAV,KAA4B,CAApD;AACA,QAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAL,CAAUH,cAAV,KAA8B,CAAxD;AAEA,SAAOpC,YAAY,GAChBqC,eADgB,GAEhBA,eAAe,IAAIG,iBAFtB;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {Element} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\t/** @type {HTMLElement} */ ( container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"]}
@@ -6,6 +6,6 @@
6
6
  */
7
7
  export default function isHTMLInputElement(node) {
8
8
  /* eslint-enable jsdoc/valid-types */
9
- return (node === null || node === void 0 ? void 0 : node.nodeName) === 'INPUT';
9
+ return node?.nodeName === 'INPUT';
10
10
  }
11
11
  //# sourceMappingURL=is-html-input-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"names":["isHTMLInputElement","node","nodeName"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,kBAAT,CAA6BC,IAA7B,EAAoC;AAClD;AACA,SAAO,CAAAA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEC,QAAN,MAAmB,OAA1B;AACA","sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"names":["isHTMLInputElement","node","nodeName"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,kBAAT,CAA6BC,IAA7B,EAAoC;AAClD;AACA,SAAOA,IAAI,EAAEC,QAAN,KAAmB,OAA1B;AACA","sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"]}
@@ -11,6 +11,6 @@ import placeCaretAtEdge from './place-caret-at-edge';
11
11
  */
12
12
 
13
13
  export default function placeCaretAtVerticalEdge(container, isReverse, rect) {
14
- return placeCaretAtEdge(container, isReverse, rect === null || rect === void 0 ? void 0 : rect.left);
14
+ return placeCaretAtEdge(container, isReverse, rect?.left);
15
15
  }
16
16
  //# sourceMappingURL=place-caret-at-vertical-edge.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-vertical-edge.js"],"names":["placeCaretAtEdge","placeCaretAtVerticalEdge","container","isReverse","rect","left"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,wBAAT,CAAmCC,SAAnC,EAA8CC,SAA9C,EAAyDC,IAAzD,EAAgE;AAC9E,SAAOJ,gBAAgB,CAAEE,SAAF,EAAaC,SAAb,EAAwBC,IAAxB,aAAwBA,IAAxB,uBAAwBA,IAAI,CAAEC,IAA9B,CAAvB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge( container, isReverse, rect ) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/dom/src/dom/place-caret-at-vertical-edge.js"],"names":["placeCaretAtEdge","placeCaretAtVerticalEdge","container","isReverse","rect","left"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,wBAAT,CAAmCC,SAAnC,EAA8CC,SAA9C,EAAyDC,IAAzD,EAAgE;AAC9E,SAAOJ,gBAAgB,CAAEE,SAAF,EAAaC,SAAb,EAAwBC,IAAI,EAAEC,IAA9B,CAAvB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at the top or bottom of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for bottom, false for top.\n * @param {DOMRect} [rect] The rectangle to position the caret with.\n */\nexport default function placeCaretAtVerticalEdge( container, isReverse, rect ) {\n\treturn placeCaretAtEdge( container, isReverse, rect?.left );\n}\n"]}
@@ -84,11 +84,9 @@ function isValidFocusableArea(element) {
84
84
  */
85
85
 
86
86
 
87
- export function find(context) {
88
- let {
89
- sequential = false
90
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
91
-
87
+ export function find(context, {
88
+ sequential = false
89
+ } = {}) {
92
90
  /* eslint-disable jsdoc/no-undefined-types */
93
91
 
94
92
  /** @type {NodeListOf<HTMLElement>} */
@@ -1 +1 @@
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,UAAxB,EAAqC;AACpC,SAAO,CACNA,UAAU,GAAG,iCAAH,GAAuC,YAD3C,EAEN,SAFM,EAGN,wBAHM,EAIN,4CAJM,EAKN,wBALM,EAMN,0BANM,EAON,6BAPM,EAQN,QARM,EASN,OATM,EAUN,YAVM,EAWN,gDAXM,EAYLC,IAZK,CAYC,GAZD,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,SACCA,OAAO,CAACC,WAAR,GAAsB,CAAtB,IACAD,OAAO,CAACE,YAAR,GAAuB,CADvB,IAEAF,OAAO,CAACG,cAAR,GAAyBC,MAAzB,GAAkC,CAHnC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA+BL,OAA/B,EAAyC;AACxC;AACA,QAAMM,GAAG,GAAGN,OAAO,CAACO,OAAR,CAAiB,WAAjB,CAAZ;;AACA,MAAK,CAAED,GAAP,EAAa;AACZ,WAAO,KAAP;AACA;AAED;;;AACA,QAAME,GAAG,GAAGR,OAAO,CAACS,aAAR,CAAsBC,aAAtB,CACX,kBAAkBJ,GAAG,CAACK,IAAtB,GAA6B,IADlB,CAAZ;AAGA,SAAO,CAAC,CAAEH,GAAH,IAAUT,SAAS,CAAES,GAAF,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASI,IAAT,CAAeC,OAAf,EAAsD;AAAA,MAA9B;AAAEhB,IAAAA,UAAU,GAAG;AAAf,GAA8B,uEAAL,EAAK;;AAC5D;;AACA;;AACA;AACA,QAAMiB,QAAQ,GAAGD,OAAO,CAACE,gBAAR,CAA0BnB,aAAa,CAAEC,UAAF,CAAvC,CAAjB;AAEA,SAAOmB,KAAK,CAACC,IAAN,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 {HTMLElement[]} 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"]}
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,UAAxB,EAAqC;AACpC,SAAO,CACNA,UAAU,GAAG,iCAAH,GAAuC,YAD3C,EAEN,SAFM,EAGN,wBAHM,EAIN,4CAJM,EAKN,wBALM,EAMN,0BANM,EAON,6BAPM,EAQN,QARM,EASN,OATM,EAUN,YAVM,EAWN,gDAXM,EAYLC,IAZK,CAYC,GAZD,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,SACCA,OAAO,CAACC,WAAR,GAAsB,CAAtB,IACAD,OAAO,CAACE,YAAR,GAAuB,CADvB,IAEAF,OAAO,CAACG,cAAR,GAAyBC,MAAzB,GAAkC,CAHnC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA+BL,OAA/B,EAAyC;AACxC;AACA,QAAMM,GAAG,GAAGN,OAAO,CAACO,OAAR,CAAiB,WAAjB,CAAZ;;AACA,MAAK,CAAED,GAAP,EAAa;AACZ,WAAO,KAAP;AACA;AAED;;;AACA,QAAME,GAAG,GAAGR,OAAO,CAACS,aAAR,CAAsBC,aAAtB,CACX,kBAAkBJ,GAAG,CAACK,IAAtB,GAA6B,IADlB,CAAZ;AAGA,SAAO,CAAC,CAAEH,GAAH,IAAUT,SAAS,CAAES,GAAF,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASI,IAAT,CAAeC,OAAf,EAAwB;AAAEhB,EAAAA,UAAU,GAAG;AAAf,IAAyB,EAAjD,EAAsD;AAC5D;;AACA;;AACA;AACA,QAAMiB,QAAQ,GAAGD,OAAO,CAACE,gBAAR,CAA0BnB,aAAa,CAAEC,UAAF,CAAvC,CAAjB;AAEA,SAAOmB,KAAK,CAACC,IAAN,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 {HTMLElement[]} 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dom",
3
- "version": "3.34.0",
3
+ "version": "3.35.0",
4
4
  "description": "DOM utilities module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,10 +29,10 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@wordpress/deprecated": "^3.34.0"
32
+ "@wordpress/deprecated": "^3.35.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "c7c79cb11b677adcbf06cf5f8cfb6c5ec1699f19"
37
+ "gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
38
38
  }