@soomo/react-text-annotator 3.1.0-staging.13 → 3.1.0-staging.15

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 (68) hide show
  1. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +1 -11
  2. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -1
  3. package/dist/hooks/index.d.ts +2 -1
  4. package/dist/hooks/index.d.ts.map +1 -1
  5. package/dist/hooks/useAnnotationTargetIdling.d.ts +4 -0
  6. package/dist/hooks/useAnnotationTargetIdling.d.ts.map +1 -0
  7. package/dist/react-text-annotator.es.js +5 -4
  8. package/dist/react-text-annotator.es.js.map +1 -1
  9. package/dist/react-text-annotator.es11.js +483 -78
  10. package/dist/react-text-annotator.es11.js.map +1 -1
  11. package/dist/react-text-annotator.es12.js +77 -40
  12. package/dist/react-text-annotator.es12.js.map +1 -1
  13. package/dist/react-text-annotator.es13.js +45 -9
  14. package/dist/react-text-annotator.es13.js.map +1 -1
  15. package/dist/react-text-annotator.es14.js +45 -10
  16. package/dist/react-text-annotator.es14.js.map +1 -1
  17. package/dist/react-text-annotator.es15.js +12 -0
  18. package/dist/react-text-annotator.es15.js.map +1 -0
  19. package/dist/react-text-annotator.es17.js +215 -554
  20. package/dist/react-text-annotator.es17.js.map +1 -1
  21. package/dist/react-text-annotator.es18.js +585 -2
  22. package/dist/react-text-annotator.es18.js.map +1 -1
  23. package/dist/react-text-annotator.es19.js +2 -31
  24. package/dist/react-text-annotator.es19.js.map +1 -1
  25. package/dist/react-text-annotator.es2.js +2 -2
  26. package/dist/react-text-annotator.es20.js +20 -887
  27. package/dist/react-text-annotator.es20.js.map +1 -1
  28. package/dist/react-text-annotator.es21.js +893 -109
  29. package/dist/react-text-annotator.es21.js.map +1 -1
  30. package/dist/react-text-annotator.es22.js +2 -309
  31. package/dist/react-text-annotator.es22.js.map +1 -1
  32. package/dist/react-text-annotator.es23.js +2 -58
  33. package/dist/react-text-annotator.es23.js.map +1 -1
  34. package/dist/react-text-annotator.es24.js +113 -19
  35. package/dist/react-text-annotator.es24.js.map +1 -1
  36. package/dist/react-text-annotator.es25.js +309 -2
  37. package/dist/react-text-annotator.es25.js.map +1 -1
  38. package/dist/react-text-annotator.es26.js +58 -2
  39. package/dist/react-text-annotator.es26.js.map +1 -1
  40. package/dist/react-text-annotator.es27.js +17 -124
  41. package/dist/react-text-annotator.es27.js.map +1 -1
  42. package/dist/react-text-annotator.es28.js +107 -144
  43. package/dist/react-text-annotator.es28.js.map +1 -1
  44. package/dist/react-text-annotator.es29.js +156 -303
  45. package/dist/react-text-annotator.es29.js.map +1 -1
  46. package/dist/react-text-annotator.es3.js +2 -2
  47. package/dist/react-text-annotator.es30.js +308 -146
  48. package/dist/react-text-annotator.es30.js.map +1 -1
  49. package/dist/react-text-annotator.es31.js +130 -544
  50. package/dist/react-text-annotator.es31.js.map +1 -1
  51. package/dist/react-text-annotator.es32.js +566 -0
  52. package/dist/react-text-annotator.es32.js.map +1 -0
  53. package/dist/react-text-annotator.es4.js +2 -2
  54. package/dist/react-text-annotator.es5.js +28 -24
  55. package/dist/react-text-annotator.es5.js.map +1 -1
  56. package/dist/react-text-annotator.es6.js +23 -124
  57. package/dist/react-text-annotator.es6.js.map +1 -1
  58. package/dist/react-text-annotator.es7.js +121 -538
  59. package/dist/react-text-annotator.es7.js.map +1 -1
  60. package/dist/react-text-annotator.es8.js +545 -10
  61. package/dist/react-text-annotator.es8.js.map +1 -1
  62. package/dist/react-text-annotator.es9.js +13 -0
  63. package/dist/react-text-annotator.es9.js.map +1 -0
  64. package/package.json +11 -11
  65. package/dist/react-text-annotator.es10.js +0 -490
  66. package/dist/react-text-annotator.es10.js.map +0 -1
  67. package/dist/react-text-annotator.es16.js +0 -249
  68. package/dist/react-text-annotator.es16.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es11.js","sources":["../../../node_modules/@react-aria/live-announcer/dist/LiveAnnouncer.mjs"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;\nlet $319e236875307eab$var$liveAnnouncer = null;\nfunction $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {\n if (!$319e236875307eab$var$liveAnnouncer) {\n $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();\n // wait for the live announcer regions to be added to the dom, then announce\n // otherwise Safari won't announce the message if it's added too quickly\n // found most times less than 100ms were not consistent when announcing with Safari\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // if we're in a test environment, announce without waiting\n // @ts-ignore\n if (!(typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined')) setTimeout(()=>{\n if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n }, 100);\n else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n}\nfunction $319e236875307eab$export$d10ae4f68404609a(assertiveness) {\n if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);\n}\nfunction $319e236875307eab$export$d8686216b8b81b2f() {\n if ($319e236875307eab$var$liveAnnouncer) {\n $319e236875307eab$var$liveAnnouncer.destroy();\n $319e236875307eab$var$liveAnnouncer = null;\n }\n}\n// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18\n// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a\n// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.\n// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer\n// is simple enough to implement without React, so that's what we do here.\n// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638\nclass $319e236875307eab$var$LiveAnnouncer {\n isAttached() {\n var _this_node;\n return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;\n }\n createLog(ariaLive) {\n let node = document.createElement('div');\n node.setAttribute('role', 'log');\n node.setAttribute('aria-live', ariaLive);\n node.setAttribute('aria-relevant', 'additions');\n return node;\n }\n destroy() {\n if (!this.node) return;\n document.body.removeChild(this.node);\n this.node = null;\n }\n announce(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {\n var _this_assertiveLog, _this_politeLog;\n if (!this.node) return;\n let node = document.createElement('div');\n if (typeof message === 'object') {\n // To read an aria-labelledby, the element must have an appropriate role, such as img.\n node.setAttribute('role', 'img');\n node.setAttribute('aria-labelledby', message['aria-labelledby']);\n } else node.textContent = message;\n if (assertiveness === 'assertive') (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);\n else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);\n if (message !== '') setTimeout(()=>{\n node.remove();\n }, timeout);\n }\n clear(assertiveness) {\n if (!this.node) return;\n if ((!assertiveness || assertiveness === 'assertive') && this.assertiveLog) this.assertiveLog.innerHTML = '';\n if ((!assertiveness || assertiveness === 'polite') && this.politeLog) this.politeLog.innerHTML = '';\n }\n constructor(){\n this.node = null;\n this.assertiveLog = null;\n this.politeLog = null;\n if (typeof document !== 'undefined') {\n this.node = document.createElement('div');\n this.node.dataset.liveAnnouncer = 'true';\n // copied from VisuallyHidden\n Object.assign(this.node.style, {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: '1px',\n whiteSpace: 'nowrap'\n });\n this.assertiveLog = this.createLog('assertive');\n this.node.appendChild(this.assertiveLog);\n this.politeLog = this.createLog('polite');\n this.node.appendChild(this.politeLog);\n document.body.prepend(this.node);\n }\n }\n}\n\n\nexport {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};\n//# sourceMappingURL=LiveAnnouncer.module.js.map\n"],"names":[],"mappings":"AAUqE,MAAM,iDAAiD;AAC5H,IAAI,sCAAsC;AAC1C,SAAS,0CAA0C,SAAS,gBAAgB,aAAa,UAAU,gDAAgD;AAC/I,MAAI,CAAC,qCAAqC;AACtC,0CAAsC,IAAI;AAQ1C,QAAI,EAAE,OAAO,6BAA6B,YAAY,2BAA2B,OAAO,SAAS,aAAc,YAAW,MAAI;AAC1H,UAAI,wCAAwC,QAAQ,wCAAwC,SAAS,SAAS,oCAAoC,WAAU,EAAI,yCAAwC,QAAQ,wCAAwC,SAAS,SAAS,oCAAoC,SAAS,SAAS,eAAe,OAAO;AAAA,IACzV,GAAE,GAAG;AAAA,QACD,qCAAoC,SAAS,SAAS,eAAe,OAAO;AAAA,EACpF,MAAM,qCAAoC,SAAS,SAAS,eAAe,OAAO;AACvF;AAIA,SAAS,4CAA4C;AACjD,MAAI,qCAAqC;AACrC,wCAAo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AAA,EACD,cAAa;AACT,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,YAAY;AACjB,QAAI,OAAO,aAAa,aAAa;AACjC,WAAK,OAAO,SAAS,cAAc,KAAK;AACxC,WAAK,KAAK,QAAQ,gBAAgB;AAElC,aAAO,OAAO,KAAK,KAAK,OAAO;AAAA,QAC3B,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,SAAS;AAAA,QACT,UAAU;AAAA,QACV,OAAO;AAAA,QACP,YAAY;AAAA,MAC5B,CAAa;AACD,WAAK,eAAe,KAAK,UAAU,WAAW;AAC9C,WAAK,KAAK,YAAY,KAAK,YAAY;AACvC,WAAK,YAAY,KAAK,UAAU,QAAQ;AACxC,WAAK,KAAK,YAAY,KAAK,SAAS;AACpC,eAAS,KAAK,QAAQ,KAAK,IAAI;AAAA,IAClC;AAAA,EACJ;AACL;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"react-text-annotator.es11.js","sources":["../../../node_modules/CETEIcean/src/CETEI.js"],"sourcesContent":["import defaultBehaviors from './defaultBehaviors.js';\nimport * as utilities from './utilities.js';\nimport {addBehaviors, addBehavior, removeBehavior} from './behaviors.js';\nimport {learnElementNames, learnCustomElementNames} from './dom.js';\n\nclass CETEI {\n constructor(options){\n this.options = options ? options : {}\n\n // Set a local reference to the Document object\n // Determine document in this order of preference: options, window, global \n this.document = this.options.documentObject ? this.options.documentObject : undefined\n if (this.document === undefined) {\n if (typeof window !== 'undefined' && window.document) {\n this.document = window.document\n } else if (typeof global !== 'undefined' && global.document) {\n this.document = global.document\n }\n }\n\n // Bind methods\n this.addBehaviors = addBehaviors.bind(this);\n this.addBehavior = addBehavior.bind(this);\n this.removeBehavior = removeBehavior.bind(this);\n\n // Bind selected utilities\n this.utilities = {}\n for (const u of Object.keys(utilities)) {\n if ([\"getPrefixDef\", \"rw\", \"resolveURI\"].includes(u)) {\n this.utilities[u] = utilities[u].bind(this);\n } else {\n this.utilities[u] = utilities[u];\n }\n }\n\n // Set properties\n this.els = [];\n this.namespaces = new Map();\n this.behaviors = {};\n this.hasStyle = false;\n this.prefixDefs = [];\n this.debug = this.options.debug === true ? true : false;\n this.discardContent = this.options.discardContent === true ? true : false;\n\n if (this.options.base) {\n this.base = this.options.base;\n } else {\n try {\n if (window) {\n this.base = window.location.href.replace(/\\/[^\\/]*$/, \"/\");\n }\n } catch (e) {\n this.base = \"\";\n }\n }\n if (!this.options.omitDefaultBehaviors) {\n this.addBehaviors(defaultBehaviors);\n }\n if (this.options.ignoreFragmentId) {\n if (window) {\n window.removeEventListener(\"ceteiceanload\", CETEI.restorePosition);\n }\n }\n }\n\n /* \n Returns a Promise that fetches an XML source document from the URL\n provided in the first parameter and then calls the makeHTML5 method\n on the returned document.\n */\n async getHTML5(XML_url, callback, perElementFn){\n if (window && window.location.href.startsWith(this.base) && (XML_url.indexOf(\"/\") >= 0)) {\n this.base = XML_url.replace(/\\/[^\\/]*$/, \"/\");\n }\n try {\n const response = await fetch(XML_url);\n if (response.ok) {\n const XML = await response.text();\n return this.makeHTML5(XML, callback, perElementFn);\n } else {\n console.log(`Could not get XML file ${XML_url}.\\nServer returned ${response.status}: ${response.statusText}`);\n }\n }\n catch (error) {\n console.log(error);\n }\n }\n\n /* \n Converts the supplied XML string into HTML5 Custom Elements. If a callback\n function is supplied, calls it on the result.\n */\n makeHTML5(XML, callback, perElementFn){\n // XML is assumed to be a string\n this.XML_dom = ( new DOMParser() ).parseFromString(XML, \"text/xml\");\n return this.domToHTML5(this.XML_dom, callback, perElementFn);\n }\n\n preprocess(XML_dom, callback, perElementFn) {\n this.els = learnElementNames(XML_dom, this.namespaces);\n\n let convertEl = (el) => {\n // Elements with defined namespaces get the prefix mapped to that element. All others keep\n // their namespaces and are copied as-is.\n let newElement;\n if (this.namespaces.has(el.namespaceURI ? el.namespaceURI : \"\")) {\n let prefix = this.namespaces.get(el.namespaceURI ? el.namespaceURI : \"\");\n newElement = this.document.createElement(`${prefix}-${el.localName.toLowerCase()}`);\n } else {\n newElement = this.document.importNode(el, false);\n }\n // Copy attributes; @xmlns, @xml:id, @xml:lang, and\n // @rendition get special handling.\n for (let att of Array.from(el.attributes)) {\n if (att.name == \"xmlns\") {\n //Strip default namespaces, but hang on to the values\n newElement.setAttribute(\"data-xmlns\", att.value);\n } else {\n newElement.setAttribute(att.name, att.value);\n }\n if (att.name == \"xml:id\") {\n newElement.setAttribute(\"id\", att.value);\n }\n if (att.name == \"xml:lang\") {\n newElement.setAttribute(\"lang\", att.value);\n }\n if (att.name == \"rendition\") {\n newElement.setAttribute(\"class\", att.value.replace(/#/g, \"\"));\n }\n }\n // Preserve element name so we can use it later\n newElement.setAttribute(\"data-origname\", el.localName);\n if (el.hasAttributes()) {\n newElement.setAttribute(\"data-origatts\", el.getAttributeNames().join(\" \"));\n }\n // If element is empty, flag it\n if (el.childNodes.length == 0) {\n newElement.setAttribute(\"data-empty\", \"\");\n }\n // <head> elements need to know their level\n if (el.localName == \"head\") {\n // 1 is XPathResult.NUMBER_TYPE\n let level = XML_dom.evaluate(\"count(ancestor::*[tei:head])\", el, function(ns) {\n if (ns == \"tei\") return \"http://www.tei-c.org/ns/1.0\";\n }, 1, null);\n newElement.setAttribute(\"data-level\", level.numberValue);\n }\n // Turn <rendition scheme=\"css\"> elements into HTML styles\n if (el.localName == \"tagsDecl\") {\n let style = this.document.createElement(\"style\");\n for (let node of Array.from(el.childNodes)){\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType == 1 && node.localName == \"rendition\" && node.getAttribute(\"scheme\") == \"css\") {\n let rule = \"\";\n if (node.hasAttribute(\"selector\")) {\n //rewrite element names in selectors\n rule += node.getAttribute(\"selector\").replace(/([^#, >]+\\w*)/g, \"tei-$1\").replace(/#tei-/g, \"#\") + \"{\\n\";\n rule += node.textContent;\n } else {\n rule += \".\" + node.getAttribute(\"xml:id\") + \"{\\n\";\n rule += node.textContent;\n }\n rule += \"\\n}\\n\";\n style.appendChild(this.document.createTextNode(rule));\n }\n }\n if (style.childNodes.length > 0) {\n newElement.appendChild(style);\n this.hasStyle = true;\n }\n }\n // Get prefix definitions\n if (el.localName == \"prefixDef\") {\n this.prefixDefs.push(el.getAttribute(\"ident\"));\n this.prefixDefs[el.getAttribute(\"ident\")] = {\n \"matchPattern\": el.getAttribute(\"matchPattern\"),\n \"replacementPattern\": el.getAttribute(\"replacementPattern\")\n };\n }\n for (let node of Array.from(el.childNodes)) {\n // Node.ELEMENT_NODE\n if (node.nodeType == 1 ) {\n newElement.appendChild(convertEl(node));\n }\n else {\n newElement.appendChild(node.cloneNode());\n }\n }\n if (perElementFn) {\n perElementFn(newElement, el);\n }\n return newElement;\n }\n\n this.dom = this.document.createDocumentFragment();\n for (let node of Array.from(XML_dom.childNodes)) {\n // Node.ELEMENT_NODE\n if (node.nodeType == 1) {\n this.dom.appendChild(convertEl(node));\n }\n // Node.PROCESSING_INSTRUCTION_NODE\n if (node.nodeType == 7) {\n this.dom.appendChild(this.document.importNode(node, true));\n }\n // Node.COMMENT_NODE\n if (node.nodeType == 8) {\n this.dom.appendChild(this.document.importNode(node, true));\n }\n }\n // DocumentFragments don't work in the same ways as other nodes, so use the root element.\n this.utilities.dom = this.dom.firstElementChild;\n\n if (callback) {\n callback(this.dom, this);\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n } else {\n if (typeof window !== 'undefined') {\n window.dispatchEvent(ceteiceanLoad);\n }\n return this.dom;\n }\n }\n\n /* \n Converts the supplied XML DOM into HTML5 Custom Elements. If a callback\n function is supplied, calls it on the result.\n */\n domToHTML5(XML_dom, callback, perElementFn){\n\n this.preprocess(XML_dom, null, perElementFn);\n\n this.applyBehaviors();\n this.done = true;\n if (callback) {\n callback(this.dom, this);\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n } else {\n if (typeof window !== 'undefined') {\n window.dispatchEvent(ceteiceanLoad);\n }\n return this.dom;\n }\n }\n\n /*\n Convenience method for HTML pages containing pre-processed CETEIcean Custom \n Elements. Usage:\n const c = new CETEI();\n c.processPage();\n */\n processPage() {\n this.els = learnCustomElementNames(this.document);\n this.applyBehaviors();\n if (window) {\n window.dispatchEvent(ceteiceanLoad);\n }\n }\n\n /* \n To change a namespace -> prefix mapping, the namespace must first be \n unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,\n the TEI namespace must be unset before it can be set to the empty string.\n */\n unsetNamespace(ns) {\n this.namespaces.delete(ns);\n }\n\n /* \n Sets the base URL for the document. Used to rewrite relative links in the\n XML source (which may be in a completely different location from the HTML\n wrapper).\n */\n setBaseUrl(base) {\n this.base = base;\n }\n\n /* \n Appends any element returned by the function passed in the first\n parameter to the element in the second parameter. If the function\n returns nothing, this is a no-op aside from any side effects caused\n by the provided function.\n\n Called by getHandler() and fallback()\n */\nappend(fn, elt) {\n let self = this;\n if (elt && !elt.hasAttribute('data-processed')) {\n let content = fn.call(self.utilities, elt);\n if (content) {\n self.appendBasic(elt, content);\n }\n } else {\n return function() {\n if (!this.hasAttribute(\"data-processed\")) {\n let content = fn.call(self.utilities, this);\n if (content) {\n self.appendBasic(this, content);\n }\n }\n }\n }\n}\n\nappendBasic(elt, content) {\n if (this.discardContent) {\n elt.innerHTML = \"\";\n } else {\n utilities.hideContent(elt, true);\n }\n elt.appendChild(content);\n}\n\n// Given an element, return its qualified name as defined in a behaviors object\nbName(e) {\n return e.tagName.substring(0,e.tagName.indexOf(\"-\")).toLowerCase() + \":\" + e.getAttribute(\"data-origname\");\n}\n\n/* \n Private method called by append(). Takes a child element and a name, and recurses through the\n child's siblings until an element with that name is found, returning true if it is and false if not.\n*/\nchildExists(elt, name) {\n if (elt && elt.nodeName == name) {\n return true;\n } else {\n return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);\n }\n}\n\n/* \n Takes a template in the form of either an array of 1 or 2 \n strings or an object with CSS selector keys and either functions\n or arrays as described above. Returns a closure around a function \n that can be called in the element constructor or applied to an \n individual element. An empty array is considered a no-op.\n\n Called by the getHandler() and getFallback() methods\n*/\ndecorator(template) {\n if (Array.isArray(template) && template.length == 0) {\n return function(e) {};\n }\n if (Array.isArray(template) && !Array.isArray(template[0])) {\n return this.applyDecorator(template)\n } \n let self = this;\n return function(elt) {\n for (let rule of template) {\n if (elt.matches(rule[0]) || rule[0] === \"_\") {\n if (Array.isArray(rule[1])) {\n return self.decorator(rule[1]).call(this, elt);\n } else {\n return rule[1].call(this, elt);\n }\n }\n }\n }\n}\n\napplyDecorator(strings) {\n let self = this;\n return function (elt) {\n let copy = [];\n for (let i = 0; i < strings.length; i++) {\n copy.push(self.template(strings[i], elt));\n }\n return self.insert(elt, copy);\n }\n}\n\n/* \n Returns the fallback function for the given element name.\n Called by fallback().\n*/\ngetFallback(behaviors, fn) {\n if (behaviors[fn]) {\n if (behaviors[fn] instanceof Function) {\n return behaviors[fn];\n } else {\n return this.decorator(behaviors[fn]);\n }\n }\n}\n\n/* \n Returns the handler function for the given element name\n Called by define().\n*/\ngetHandler(behaviors, fn) {\n if (behaviors[fn]) {\n if (behaviors[fn] instanceof Function) {\n return this.append(behaviors[fn]);\n } else {\n return this.append(this.decorator(behaviors[fn]));\n }\n }\n}\n\ninsert(elt, strings) {\n let content = this.document.createElement(\"cetei-content\");\n for (let node of Array.from(elt.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1 && !node.hasAttribute(\"data-processed\")) {\n this.processElement(node);\n }\n } \n // If we have before and after tags have them parsed by\n // .innerHTML and then add the content to the resulting child\n if (strings[0].match(\"<[^>]+>\") && strings[1] && strings[1].match(\"<[^>]+>\")) { \n content.innerHTML = strings[0] + elt.innerHTML + (strings[1]?strings[1]:\"\");\n } else {\n content.innerHTML = strings[0];\n content.setAttribute(\"data-before\", strings[0].replace(/<[^>]+>/g,\"\").length);\n for (let node of Array.from(elt.childNodes)) {\n content.appendChild(node.cloneNode(true));\n }\n if (strings.length > 1) {\n content.innerHTML += strings[1];\n content.setAttribute(\"data-after\", strings[1].replace(/<[^>]+>/g,\"\").length);\n } \n }\n if (content.childNodes.length < 2) {\n return content.firstChild;\n } else {\n return content;\n }\n}\n\n// Runs behaviors recursively on the supplied element and children\nprocessElement(elt) {\n if (elt.hasAttribute(\"data-origname\") && ! elt.hasAttribute(\"data-processed\")) {\n let fn = this.getFallback(this.bName(elt));\n if (fn) {\n this.append(fn,elt);\n elt.setAttribute(\"data-processed\", \"\");\n }\n }\n for (let node of Array.from(elt.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1) {\n this.processElement(node);\n }\n }\n}\n\ntemplate(str, elt) {\n let result = str;\n if (str.search(/\\$(\\w*)(@([a-zA-Z:]+))/ )) {\n let re = /\\$(\\w*)@([a-zA-Z:]+)/g;\n let replacements;\n while (replacements = re.exec(str)) {\n if (elt.hasAttribute(replacements[2])) {\n if (replacements[1] && this.utilities[replacements[1]]) {\n result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));\n } else {\n result = result.replace(replacements[0], elt.getAttribute(replacements[2]));\n }\n } else {\n result = result.replace(replacements[0], \"\");\n }\n }\n }\n return result;\n}\n\n// Define or apply behaviors for the document\napplyBehaviors() {\n if (typeof window !== 'undefined' && window.customElements) {\n this.define.call(this, this.els);\n } else {\n this.fallback.call(this, this.els);\n }\n}\n\n/* \n Registers the list of elements provided with the browser.\n Called by makeHTML5(), but can be called independently if, for example,\n you've created Custom Elements via an XSLT transformation instead.\n*/\ndefine(names) {\n for (let name of names) {\n const fn = this.getHandler(this.behaviors, name);\n utilities.defineCustomElement(name, fn, this.debug);\n }\n}\n\n/* \n Provides fallback functionality for environments where Custom Elements\n are not supported.\n\n Like define(), this is called by makeHTML5(), but can be called\n independently.\n*/\nfallback(names) {\n for (let name of names) {\n let fn = this.getFallback(this.behaviors, name);\n if (fn) {\n for (let elt of Array.from((\n this.dom && !this.done \n ? this.dom\n : this.document\n ).querySelectorAll(utilities.tagName(name)))) {\n if (!elt.hasAttribute(\"data-processed\")) {\n this.append(fn, elt);\n elt.setAttribute(\"data-processed\", \"\");\n }\n }\n }\n }\n}\n\n /**********************\n * Utility functions *\n **********************/\n\n \n static savePosition() {\n window.sessionStorage.setItem(window.location + \"-scroll\", window.scrollY);\n }\n \n static restorePosition() {\n if (!window.location.hash) {\n let scroll;\n if (scroll = window.sessionStorage.getItem(window.location + \"-scroll\")) {\n window.sessionStorage.removeItem(window.location + \"-scroll\");\n setTimeout(function() {\n window.scrollTo(0, scroll);\n }, 100);\n }\n } else {\n setTimeout(function() {\n let h = this.document.querySelector(window.decodeURI(window.location.hash));\n if (h) {\n h.scrollIntoView();\n }\n }, 100);\n }\n }\n\n}\n\ntry {\n if (typeof window !== 'undefined') {\n window.CETEI = CETEI;\n window.addEventListener(\"beforeunload\", CETEI.savePosition);\n var ceteiceanLoad = new Event(\"ceteiceanload\");\n window.addEventListener(\"ceteiceanload\", CETEI.restorePosition);\n }\n} catch (e) {\n console.log(e);\n}\n\nexport default CETEI;\n"],"names":["utilities.hideContent","utilities.defineCustomElement","utilities.tagName"],"mappings":";;;;;AAKA,MAAM,MAAM;AAAA,EACV,YAAY,SAAQ;AAClB,SAAK,UAAU,UAAU,UAAU,CAAE;AAIrC,SAAK,WAAW,KAAK,QAAQ,iBAAiB,KAAK,QAAQ,iBAAiB;AAC5E,QAAI,KAAK,aAAa,QAAW;AAC/B,UAAI,OAAO,WAAW,eAAe,OAAO,UAAU;AACpD,aAAK,WAAW,OAAO;AAAA,MACxB,WAAU,OAAO,WAAW,eAAe,OAAO,UAAU;AAC3D,aAAK,WAAW,OAAO;AAAA,MACxB;AAAA,IACF;AAGD,SAAK,eAAe,aAAa,KAAK,IAAI;AAC1C,SAAK,cAAc,YAAY,KAAK,IAAI;AACxC,SAAK,iBAAiB,eAAe,KAAK,IAAI;AAG9C,SAAK,YAAY,CAAE;AACnB,eAAW,KAAK,OAAO,KAAK,SAAS,GAAG;AACtC,UAAI,CAAC,gB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cAAc,OAAO,UAAU,OAAO,SAAS,IAAI,CAAC;AAC1E,YAAI,GAAG;AACL,YAAE,eAAc;AAAA,QACjB;AAAA,MACF,GAAE,GAAG;AAAA,IACP;AAAA,EACF;AAEH;AAEA,IAAI;AACF,MAAI,OAAO,WAAW,aAAa;AAC/B,WAAO,QAAQ;AACf,WAAO,iBAAiB,gBAAgB,MAAM,YAAY;AAC1D,QAAI,gBAAgB,IAAI,MAAM,eAAe;AAC7C,WAAO,iBAAiB,iBAAiB,MAAM,eAAe;AAAA,EACjE;AACH,SAAS,GAAG;AACV,UAAQ,IAAI,CAAC;AACf;","x_google_ignoreList":[0]}
@@ -1,48 +1,85 @@
1
- function* range(minimum, maximum) {
2
- for (let number = minimum; number <= maximum; number++) {
3
- yield number;
4
- }
5
- }
6
- function randomInteger(minimum, maximum) {
7
- return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
8
- }
9
- function randomIntegerWithout(minimum, maximum, excludedValue) {
10
- const number = randomInteger(minimum, maximum - 1);
11
- return number >= excludedValue ? number + 1 : number;
1
+ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7e3;
2
+ let $319e236875307eab$var$liveAnnouncer = null;
3
+ function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
4
+ if (!$319e236875307eab$var$liveAnnouncer) {
5
+ $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
6
+ if (!(typeof IS_REACT_ACT_ENVIRONMENT === "boolean" ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== "undefined")) setTimeout(() => {
7
+ if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
8
+ }, 100);
9
+ else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
10
+ } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
12
11
  }
13
- function makeCallable(generator) {
14
- const iterator = generator();
15
- function random() {
16
- return iterator.next().value;
12
+ function $319e236875307eab$export$d8686216b8b81b2f() {
13
+ if ($319e236875307eab$var$liveAnnouncer) {
14
+ $319e236875307eab$var$liveAnnouncer.destroy();
15
+ $319e236875307eab$var$liveAnnouncer = null;
17
16
  }
18
- random[Symbol.iterator] = function* () {
19
- while (true) {
20
- yield random();
21
- }
22
- };
23
- return random;
24
17
  }
25
- function exhaustiveUniqueRandom(minimum, maximum) {
26
- return makeCallable(function* () {
27
- let unconsumedValues = [...range(minimum, maximum)];
28
- while (true) {
29
- while (unconsumedValues.length > 1) {
30
- yield unconsumedValues.splice(
31
- randomInteger(0, unconsumedValues.length - 1),
32
- 1
33
- )[0];
34
- }
35
- const [previousValue] = unconsumedValues;
36
- yield previousValue;
37
- unconsumedValues = [...range(minimum, maximum)];
38
- yield unconsumedValues.splice(
39
- randomIntegerWithout(0, unconsumedValues.length - 1, previousValue - minimum),
40
- 1
41
- )[0];
18
+ class $319e236875307eab$var$LiveAnnouncer {
19
+ isAttached() {
20
+ var _this_node;
21
+ return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
22
+ }
23
+ createLog(ariaLive) {
24
+ let node = document.createElement("div");
25
+ node.setAttribute("role", "log");
26
+ node.setAttribute("aria-live", ariaLive);
27
+ node.setAttribute("aria-relevant", "additions");
28
+ return node;
29
+ }
30
+ destroy() {
31
+ if (!this.node) return;
32
+ document.body.removeChild(this.node);
33
+ this.node = null;
34
+ }
35
+ announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
36
+ var _this_assertiveLog, _this_politeLog;
37
+ if (!this.node) return;
38
+ let node = document.createElement("div");
39
+ if (typeof message === "object") {
40
+ node.setAttribute("role", "img");
41
+ node.setAttribute("aria-labelledby", message["aria-labelledby"]);
42
+ } else node.textContent = message;
43
+ if (assertiveness === "assertive") (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);
44
+ else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);
45
+ if (message !== "") setTimeout(() => {
46
+ node.remove();
47
+ }, timeout);
48
+ }
49
+ clear(assertiveness) {
50
+ if (!this.node) return;
51
+ if ((!assertiveness || assertiveness === "assertive") && this.assertiveLog) this.assertiveLog.innerHTML = "";
52
+ if ((!assertiveness || assertiveness === "polite") && this.politeLog) this.politeLog.innerHTML = "";
53
+ }
54
+ constructor() {
55
+ this.node = null;
56
+ this.assertiveLog = null;
57
+ this.politeLog = null;
58
+ if (typeof document !== "undefined") {
59
+ this.node = document.createElement("div");
60
+ this.node.dataset.liveAnnouncer = "true";
61
+ Object.assign(this.node.style, {
62
+ border: 0,
63
+ clip: "rect(0 0 0 0)",
64
+ clipPath: "inset(50%)",
65
+ height: "1px",
66
+ margin: "-1px",
67
+ overflow: "hidden",
68
+ padding: 0,
69
+ position: "absolute",
70
+ width: "1px",
71
+ whiteSpace: "nowrap"
72
+ });
73
+ this.assertiveLog = this.createLog("assertive");
74
+ this.node.appendChild(this.assertiveLog);
75
+ this.politeLog = this.createLog("polite");
76
+ this.node.appendChild(this.politeLog);
77
+ document.body.prepend(this.node);
42
78
  }
43
- });
79
+ }
44
80
  }
45
81
  export {
46
- exhaustiveUniqueRandom
82
+ $319e236875307eab$export$a9b970dcc4ae71a9 as announce,
83
+ $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer
47
84
  };
48
85
  //# sourceMappingURL=react-text-annotator.es12.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es12.js","sources":["../../../node_modules/unique-random/index.js"],"sourcesContent":["function * range(minimum, maximum) {\n\tfor (let number = minimum; number <= maximum; number++) {\n\t\tyield number;\n\t}\n}\n\nfunction randomInteger(minimum, maximum) {\n\treturn Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;\n}\n\nfunction randomIntegerWithout(minimum, maximum, excludedValue) {\n\tconst number = randomInteger(minimum, maximum - 1);\n\n\treturn number >= excludedValue ? number + 1 : number;\n}\n\nfunction makeCallable(generator) {\n\tconst iterator = generator();\n\n\tfunction random() {\n\t\treturn iterator.next().value;\n\t}\n\n\trandom[Symbol.iterator] = function * () {\n\t\twhile (true) {\n\t\t\tyield random();\n\t\t}\n\t};\n\n\treturn random;\n}\n\nexport function consecutiveUniqueRandom(minimum, maximum) {\n\treturn makeCallable(function * () {\n\t\tif (minimum === maximum) {\n\t\t\twhile (true) {\n\t\t\t\tyield minimum;\n\t\t\t}\n\t\t}\n\n\t\tlet previousValue = randomInteger(minimum, maximum);\n\t\tyield previousValue;\n\n\t\twhile (true) {\n\t\t\tpreviousValue = randomIntegerWithout(minimum, maximum, previousValue);\n\t\t\tyield previousValue;\n\t\t}\n\t});\n}\n\nexport function exhaustiveUniqueRandom(minimum, maximum) {\n\treturn makeCallable(function * () {\n\t\tif (minimum === maximum) {\n\t\t\twhile (true) {\n\t\t\t\tyield minimum;\n\t\t\t}\n\t\t}\n\n\t\tlet unconsumedValues = [...range(minimum, maximum)];\n\n\t\twhile (true) {\n\t\t\twhile (unconsumedValues.length > 1) {\n\t\t\t\tyield unconsumedValues.splice(\n\t\t\t\t\trandomInteger(0, unconsumedValues.length - 1),\n\t\t\t\t\t1,\n\t\t\t\t)[0];\n\t\t\t}\n\n\t\t\tconst [previousValue] = unconsumedValues;\n\n\t\t\tyield previousValue;\n\n\t\t\tunconsumedValues = [...range(minimum, maximum)];\n\n\t\t\tyield unconsumedValues.splice(\n\t\t\t\trandomIntegerWithout(0, unconsumedValues.length - 1, previousValue - minimum),\n\t\t\t\t1,\n\t\t\t)[0];\n\t\t}\n\t});\n}\n"],"names":[],"mappings":"AAAA,UAAW,MAAM,SAAS,SAAS;AAClC,WAAS,SAAS,SAAS,UAAU,SAAS,UAAU;AACvD,UAAM;AAAA,EACN;AACF;AAEA,SAAS,cAAc,SAAS,SAAS;AACxC,SAAO,KAAK,MAAM,KAAK,OAAM,KAAM,UAAU,UAAU,EAAE,IAAI;AAC9D;AAEA,SAAS,qBAAqB,SAAS,SAAS,eAAe;AAC9D,QAAM,SAAS,cAAc,SAAS,UAAU,CAAC;AAEjD,SAAO,UAAU,gBAAgB,SAAS,IAAI;AAC/C;AAEA,SAAS,aAAa,WAAW;AAChC,QAAM,WAAW;AAEjB,WAAS,SAAS;AACjB,WAAO,SAAS,KAAM,EAAC;AAAA,EACvB;AAED,SAAO,OAAO,QAAQ,IAAI,aAAc;AACvC,WAAO,MAAM;AACZ,YAAM,OAAM;AAAA,IACZ;AAAA,EACH;AAEC,SAAO;AACR;AAoBO,SAAS,uBAAuB,SAAS,SAAS;AACxD,SAAO,aAAa,aAAc;AAOjC,QAAI,mBAAmB,CAAC,GAAG,MAAM,SAAS,OAAO,CAAC;AAElD,WAAO,MAAM;AACZ,aAAO,iBAAiB,SAAS,GAAG;AACnC,cAAM,iBAAiB;AAAA,UACtB,cAAc,GAAG,iBAAiB,SAAS,CAAC;AAAA,UAC5C;AAAA,QACA,EAAC,CAAC;AAAA,MACH;AAED,YAAM,CAAC,aAAa,IAAI;AAExB,YAAM;AAEN,yBAAmB,CAAC,GAAG,MAAM,SAAS,OAAO,CAAC;AAE9C,YAAM,iBAAiB;AAAA,QACtB,qBAAqB,GAAG,iBAAiB,SAAS,GAAG,gBAAgB,OAAO;AAAA,QAC5E;AAAA,MACA,EAAC,CAAC;AAAA,IACH;AAAA,EACH,CAAE;AACF;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"react-text-annotator.es12.js","sources":["../../../node_modules/@react-aria/live-announcer/dist/LiveAnnouncer.mjs"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;\nlet $319e236875307eab$var$liveAnnouncer = null;\nfunction $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {\n if (!$319e236875307eab$var$liveAnnouncer) {\n $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();\n // wait for the live announcer regions to be added to the dom, then announce\n // otherwise Safari won't announce the message if it's added too quickly\n // found most times less than 100ms were not consistent when announcing with Safari\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // if we're in a test environment, announce without waiting\n // @ts-ignore\n if (!(typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined')) setTimeout(()=>{\n if ($319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.isAttached()) $319e236875307eab$var$liveAnnouncer === null || $319e236875307eab$var$liveAnnouncer === void 0 ? void 0 : $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n }, 100);\n else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n } else $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);\n}\nfunction $319e236875307eab$export$d10ae4f68404609a(assertiveness) {\n if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);\n}\nfunction $319e236875307eab$export$d8686216b8b81b2f() {\n if ($319e236875307eab$var$liveAnnouncer) {\n $319e236875307eab$var$liveAnnouncer.destroy();\n $319e236875307eab$var$liveAnnouncer = null;\n }\n}\n// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18\n// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a\n// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.\n// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer\n// is simple enough to implement without React, so that's what we do here.\n// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638\nclass $319e236875307eab$var$LiveAnnouncer {\n isAttached() {\n var _this_node;\n return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;\n }\n createLog(ariaLive) {\n let node = document.createElement('div');\n node.setAttribute('role', 'log');\n node.setAttribute('aria-live', ariaLive);\n node.setAttribute('aria-relevant', 'additions');\n return node;\n }\n destroy() {\n if (!this.node) return;\n document.body.removeChild(this.node);\n this.node = null;\n }\n announce(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {\n var _this_assertiveLog, _this_politeLog;\n if (!this.node) return;\n let node = document.createElement('div');\n if (typeof message === 'object') {\n // To read an aria-labelledby, the element must have an appropriate role, such as img.\n node.setAttribute('role', 'img');\n node.setAttribute('aria-labelledby', message['aria-labelledby']);\n } else node.textContent = message;\n if (assertiveness === 'assertive') (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 ? void 0 : _this_assertiveLog.appendChild(node);\n else (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 ? void 0 : _this_politeLog.appendChild(node);\n if (message !== '') setTimeout(()=>{\n node.remove();\n }, timeout);\n }\n clear(assertiveness) {\n if (!this.node) return;\n if ((!assertiveness || assertiveness === 'assertive') && this.assertiveLog) this.assertiveLog.innerHTML = '';\n if ((!assertiveness || assertiveness === 'polite') && this.politeLog) this.politeLog.innerHTML = '';\n }\n constructor(){\n this.node = null;\n this.assertiveLog = null;\n this.politeLog = null;\n if (typeof document !== 'undefined') {\n this.node = document.createElement('div');\n this.node.dataset.liveAnnouncer = 'true';\n // copied from VisuallyHidden\n Object.assign(this.node.style, {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: '1px',\n whiteSpace: 'nowrap'\n });\n this.assertiveLog = this.createLog('assertive');\n this.node.appendChild(this.assertiveLog);\n this.politeLog = this.createLog('polite');\n this.node.appendChild(this.politeLog);\n document.body.prepend(this.node);\n }\n }\n}\n\n\nexport {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};\n//# sourceMappingURL=LiveAnnouncer.module.js.map\n"],"names":[],"mappings":"AAUqE,MAAM,iDAAiD;AAC5H,IAAI,sCAAsC;AAC1C,SAAS,0CAA0C,SAAS,gBAAgB,aAAa,UAAU,gDAAgD;AAC/I,MAAI,CAAC,qCAAqC;AACtC,0CAAsC,IAAI;AAQ1C,QAAI,EAAE,OAAO,6BAA6B,YAAY,2BAA2B,OAAO,SAAS,aAAc,YAAW,MAAI;AAC1H,UAAI,wCAAwC,QAAQ,wCAAwC,SAAS,SAAS,oCAAoC,WAAU,EAAI,yCAAwC,QAAQ,wCAAwC,SAAS,SAAS,oCAAoC,SAAS,SAAS,eAAe,OAAO;AAAA,IACzV,GAAE,GAAG;AAAA,QACD,qCAAoC,SAAS,SAAS,eAAe,OAAO;AAAA,EACpF,MAAM,qCAAoC,SAAS,SAAS,eAAe,OAAO;AACvF;AAIA,SAAS,4CAA4C;AACjD,MAAI,qCAAqC;AACrC,wCAAoC,QAAO;AAC3C,0CAAsC;AAAA,EACzC;AACL;AAOA,MAAM,oCAAoC;AAAA,EACtC,aAAa;AACT,QAAI;AACJ,YA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AACjC,WAAK,OAAO,SAAS,cAAc,KAAK;AACxC,WAAK,KAAK,QAAQ,gBAAgB;AAElC,aAAO,OAAO,KAAK,KAAK,OAAO;AAAA,QAC3B,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,SAAS;AAAA,QACT,UAAU;AAAA,QACV,OAAO;AAAA,QACP,YAAY;AAAA,MAC5B,CAAa;AACD,WAAK,eAAe,KAAK,UAAU,WAAW;AAC9C,WAAK,KAAK,YAAY,KAAK,YAAY;AACvC,WAAK,YAAY,KAAK,UAAU,QAAQ;AACxC,WAAK,KAAK,YAAY,KAAK,SAAS;AACpC,eAAS,KAAK,QAAQ,KAAK,IAAI;AAAA,IAClC;AAAA,EACJ;AACL;","x_google_ignoreList":[0]}
@@ -1,12 +1,48 @@
1
- const isMobile = () => {
2
- var userAgent = navigator.userAgent || navigator.vendor || window.opera;
3
- if (/android/i.test(userAgent))
4
- return true;
5
- if (/iPad|iPhone/.test(userAgent) && !window.MSStream)
6
- return true;
7
- return false;
8
- };
1
+ function* range(minimum, maximum) {
2
+ for (let number = minimum; number <= maximum; number++) {
3
+ yield number;
4
+ }
5
+ }
6
+ function randomInteger(minimum, maximum) {
7
+ return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
8
+ }
9
+ function randomIntegerWithout(minimum, maximum, excludedValue) {
10
+ const number = randomInteger(minimum, maximum - 1);
11
+ return number >= excludedValue ? number + 1 : number;
12
+ }
13
+ function makeCallable(generator) {
14
+ const iterator = generator();
15
+ function random() {
16
+ return iterator.next().value;
17
+ }
18
+ random[Symbol.iterator] = function* () {
19
+ while (true) {
20
+ yield random();
21
+ }
22
+ };
23
+ return random;
24
+ }
25
+ function exhaustiveUniqueRandom(minimum, maximum) {
26
+ return makeCallable(function* () {
27
+ let unconsumedValues = [...range(minimum, maximum)];
28
+ while (true) {
29
+ while (unconsumedValues.length > 1) {
30
+ yield unconsumedValues.splice(
31
+ randomInteger(0, unconsumedValues.length - 1),
32
+ 1
33
+ )[0];
34
+ }
35
+ const [previousValue] = unconsumedValues;
36
+ yield previousValue;
37
+ unconsumedValues = [...range(minimum, maximum)];
38
+ yield unconsumedValues.splice(
39
+ randomIntegerWithout(0, unconsumedValues.length - 1, previousValue - minimum),
40
+ 1
41
+ )[0];
42
+ }
43
+ });
44
+ }
9
45
  export {
10
- isMobile
46
+ exhaustiveUniqueRandom
11
47
  };
12
48
  //# sourceMappingURL=react-text-annotator.es13.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-text-annotator.es13.js","sources":["../src/TextAnnotatorPopup/isMobile.ts"],"sourcesContent":["// https://stackoverflow.com/questions/21741841/detecting-ios-android-operating-system\nexport const isMobile = () => {\n // @ts-ignore\n var userAgent: string = navigator.userAgent || navigator.vendor || window.opera;\n\n if (/android/i.test(userAgent)) \n return true;\n\n // @ts-ignore\n // Note: as of recently, this NO LONGER DETECTS FIREFOX ON iOS!\n // This means FF/iOS will behave like on the desktop, and loose\n // selection handlebars after the popup opens.\n if (/iPad|iPhone/.test(userAgent) && !window.MSStream)\n return true;\n\n return false;\n}"],"names":[],"mappings":"AACO,MAAM,WAAW,MAAM;AAE5B,MAAI,YAAoB,UAAU,aAAa,UAAU,UAAU,OAAO;AAEtE,MAAA,WAAW,KAAK,SAAS;AACpB,WAAA;AAMT,MAAI,cAAc,KAAK,SAAS,KAAK,CAAC,OAAO;AACpC,WAAA;AAEF,SAAA;AACT;"}
1
+ {"version":3,"file":"react-text-annotator.es13.js","sources":["../../../node_modules/unique-random/index.js"],"sourcesContent":["function * range(minimum, maximum) {\n\tfor (let number = minimum; number <= maximum; number++) {\n\t\tyield number;\n\t}\n}\n\nfunction randomInteger(minimum, maximum) {\n\treturn Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;\n}\n\nfunction randomIntegerWithout(minimum, maximum, excludedValue) {\n\tconst number = randomInteger(minimum, maximum - 1);\n\n\treturn number >= excludedValue ? number + 1 : number;\n}\n\nfunction makeCallable(generator) {\n\tconst iterator = generator();\n\n\tfunction random() {\n\t\treturn iterator.next().value;\n\t}\n\n\trandom[Symbol.iterator] = function * () {\n\t\twhile (true) {\n\t\t\tyield random();\n\t\t}\n\t};\n\n\treturn random;\n}\n\nexport function consecutiveUniqueRandom(minimum, maximum) {\n\treturn makeCallable(function * () {\n\t\tif (minimum === maximum) {\n\t\t\twhile (true) {\n\t\t\t\tyield minimum;\n\t\t\t}\n\t\t}\n\n\t\tlet previousValue = randomInteger(minimum, maximum);\n\t\tyield previousValue;\n\n\t\twhile (true) {\n\t\t\tpreviousValue = randomIntegerWithout(minimum, maximum, previousValue);\n\t\t\tyield previousValue;\n\t\t}\n\t});\n}\n\nexport function exhaustiveUniqueRandom(minimum, maximum) {\n\treturn makeCallable(function * () {\n\t\tif (minimum === maximum) {\n\t\t\twhile (true) {\n\t\t\t\tyield minimum;\n\t\t\t}\n\t\t}\n\n\t\tlet unconsumedValues = [...range(minimum, maximum)];\n\n\t\twhile (true) {\n\t\t\twhile (unconsumedValues.length > 1) {\n\t\t\t\tyield unconsumedValues.splice(\n\t\t\t\t\trandomInteger(0, unconsumedValues.length - 1),\n\t\t\t\t\t1,\n\t\t\t\t)[0];\n\t\t\t}\n\n\t\t\tconst [previousValue] = unconsumedValues;\n\n\t\t\tyield previousValue;\n\n\t\t\tunconsumedValues = [...range(minimum, maximum)];\n\n\t\t\tyield unconsumedValues.splice(\n\t\t\t\trandomIntegerWithout(0, unconsumedValues.length - 1, previousValue - minimum),\n\t\t\t\t1,\n\t\t\t)[0];\n\t\t}\n\t});\n}\n"],"names":[],"mappings":"AAAA,UAAW,MAAM,SAAS,SAAS;AAClC,WAAS,SAAS,SAAS,UAAU,SAAS,UAAU;AACvD,UAAM;AAAA,EACN;AACF;AAEA,SAAS,cAAc,SAAS,SAAS;AACxC,SAAO,KAAK,MAAM,KAAK,OAAM,KAAM,UAAU,UAAU,EAAE,IAAI;AAC9D;AAEA,SAAS,qBAAqB,SAAS,SAAS,eAAe;AAC9D,QAAM,SAAS,cAAc,SAAS,UAAU,CAAC;AAEjD,SAAO,UAAU,gBAAgB,SAAS,IAAI;AAC/C;AAEA,SAAS,aAAa,WAAW;AAChC,QAAM,WAAW;AAEjB,WAAS,SAAS;AACjB,WAAO,SAAS,KAAM,EAAC;AAAA,EACvB;AAED,SAAO,OAAO,QAAQ,IAAI,aAAc;AACvC,WAAO,MAAM;AACZ,YAAM,OAAM;AAAA,IACZ;AAAA,EACH;AAEC,SAAO;AACR;AAoBO,SAAS,uBAAuB,SAAS,SAAS;AACxD,SAAO,aAAa,aAAc;AAOjC,QAAI,mBAAmB,CAAC,GAAG,MAAM,SAAS,OAAO,CAAC;AAElD,WAAO,MAAM;AACZ,aAAO,iBAAiB,SAAS,GAAG;AACnC,cAAM,iBAAiB;AAAA,UACtB,cAAc,GAAG,iBAAiB,SAAS,CAAC;AAAA,UAC5C;AAAA,QACA,EAAC,CAAC;AAAA,MACH;AAED,YAAM,CAAC,aAAa,IAAI;AAExB,YAAM;AAEN,yBAAmB,CAAC,GAAG,MAAM,SAAS,OAAO,CAAC;AAE9C,YAAM,iBAAiB;AAAA,QACtB,qBAAqB,GAAG,iBAAiB,SAAS,GAAG,gBAAgB,OAAO;AAAA,QAC5E;AAAA,MACA,EAAC,CAAC;AAAA,IACH;AAAA,EACH,CAAE;AACF;","x_google_ignoreList":[0]}
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { useLayoutEffect, useEffect, useRef } from "react";
3
- import { isTypeableCombobox, getDocument, activeElement, contains, isVirtualClick, isVirtualPointerEvent, isSafari, stopEvent, getTarget, isReactEvent, isRootElement, isEventTargetWithin } from "./react-text-annotator.es27.js";
4
- import { isHTMLElement, isElement, getOverflowAncestors, getNodeName, isLastTraversableNode, getParentNode, getComputedStyle } from "./react-text-annotator.es28.js";
5
- import { isTabbable, tabbable } from "./react-text-annotator.es29.js";
3
+ import { isTypeableCombobox, getDocument, activeElement, contains, isVirtualClick, isVirtualPointerEvent, isSafari, stopEvent, getTarget, isReactEvent, isRootElement, isEventTargetWithin } from "./react-text-annotator.es28.js";
4
+ import { isHTMLElement, isElement, getOverflowAncestors, getNodeName, isLastTraversableNode, getParentNode, getComputedStyle, isWebKit } from "./react-text-annotator.es29.js";
5
+ import { isTabbable, tabbable } from "./react-text-annotator.es30.js";
6
6
  import * as ReactDOM from "react-dom";
7
- import { useFloating as useFloating$1 } from "./react-text-annotator.es16.js";
8
- import { flip, inline, offset, shift } from "./react-text-annotator.es16.js";
7
+ import { useFloating as useFloating$1 } from "./react-text-annotator.es17.js";
8
+ import { flip, inline, offset, shift } from "./react-text-annotator.es17.js";
9
9
  const SafeReact = {
10
10
  ...React
11
11
  };
@@ -389,6 +389,7 @@ function useFloatingPortalNode(props) {
389
389
  setPortalNode(subRoot);
390
390
  }, [id, uniqueId]);
391
391
  index(() => {
392
+ if (root === null) return;
392
393
  if (!uniqueId) return;
393
394
  if (portalNodeRef.current) return;
394
395
  let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
@@ -414,7 +415,7 @@ function FloatingPortal(props) {
414
415
  const {
415
416
  children,
416
417
  id,
417
- root = null,
418
+ root,
418
419
  preserveTabOrder = true
419
420
  } = props;
420
421
  const portalNode = useFloatingPortalNode({
@@ -759,6 +760,12 @@ function FloatingFocusManager(props) {
759
760
  if (isInsidePortal && domReference) {
760
761
  domReference.insertAdjacentElement("afterend", fallbackEl);
761
762
  }
763
+ function getReturnElement() {
764
+ if (typeof returnFocusRef.current === "boolean") {
765
+ return getPreviouslyFocusedElement() || fallbackEl;
766
+ }
767
+ return returnFocusRef.current.current || fallbackEl;
768
+ }
762
769
  return () => {
763
770
  events.off("openchange", onOpenChange2);
764
771
  const activeEl = activeElement(doc);
@@ -770,7 +777,7 @@ function FloatingFocusManager(props) {
770
777
  if (shouldFocusReference && refs.domReference.current) {
771
778
  addPreviouslyFocusedElement(refs.domReference.current);
772
779
  }
773
- const returnElement = getPreviouslyFocusedElement() || fallbackEl;
780
+ const returnElement = getReturnElement();
774
781
  queueMicrotask(() => {
775
782
  if (
776
783
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -933,11 +940,15 @@ function useDismiss(context, props) {
933
940
  escapeKey: escapeKeyCapture,
934
941
  outsidePress: outsidePressCapture
935
942
  } = normalizeProp(capture);
943
+ const isComposingRef = React.useRef(false);
936
944
  const closeOnEscapeKeyDown = useEffectEvent((event) => {
937
945
  var _dataRef$current$floa;
938
946
  if (!open || !enabled || !escapeKey || event.key !== "Escape") {
939
947
  return;
940
948
  }
949
+ if (isComposingRef.current) {
950
+ return;
951
+ }
941
952
  const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
942
953
  const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
943
954
  if (!escapeKeyBubbles) {
@@ -1052,11 +1063,30 @@ function useDismiss(context, props) {
1052
1063
  }
1053
1064
  dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
1054
1065
  dataRef.current.__outsidePressBubbles = outsidePressBubbles;
1066
+ let compositionTimeout = -1;
1055
1067
  function onScroll(event) {
1056
1068
  onOpenChange(false, event, "ancestor-scroll");
1057
1069
  }
1070
+ function handleCompositionStart() {
1071
+ window.clearTimeout(compositionTimeout);
1072
+ isComposingRef.current = true;
1073
+ }
1074
+ function handleCompositionEnd() {
1075
+ compositionTimeout = window.setTimeout(
1076
+ () => {
1077
+ isComposingRef.current = false;
1078
+ },
1079
+ // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
1080
+ // Only apply to WebKit for the test to remain 0ms.
1081
+ isWebKit() ? 5 : 0
1082
+ );
1083
+ }
1058
1084
  const doc = getDocument(elements.floating);
1059
- escapeKey && doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1085
+ if (escapeKey) {
1086
+ doc.addEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1087
+ doc.addEventListener("compositionstart", handleCompositionStart);
1088
+ doc.addEventListener("compositionend", handleCompositionEnd);
1089
+ }
1060
1090
  outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
1061
1091
  let ancestors = [];
1062
1092
  if (ancestorScroll) {
@@ -1080,11 +1110,16 @@ function useDismiss(context, props) {
1080
1110
  });
1081
1111
  });
1082
1112
  return () => {
1083
- escapeKey && doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1113
+ if (escapeKey) {
1114
+ doc.removeEventListener("keydown", escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
1115
+ doc.removeEventListener("compositionstart", handleCompositionStart);
1116
+ doc.removeEventListener("compositionend", handleCompositionEnd);
1117
+ }
1084
1118
  outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
1085
1119
  ancestors.forEach((ancestor) => {
1086
1120
  ancestor.removeEventListener("scroll", onScroll);
1087
1121
  });
1122
+ window.clearTimeout(compositionTimeout);
1088
1123
  };
1089
1124
  }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
1090
1125
  React.useEffect(() => {
@@ -1179,7 +1214,7 @@ function useFloating(options) {
1179
1214
  const computedElements = rootContext.elements;
1180
1215
  const [_domReference, setDomReference] = React.useState(null);
1181
1216
  const [positionReference, _setPositionReference] = React.useState(null);
1182
- const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
1217
+ const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
1183
1218
  const domReference = optionDomReference || _domReference;
1184
1219
  const domReferenceRef = React.useRef(null);
1185
1220
  const tree = useFloatingTree();