@soomo/react-text-annotator 3.0.0-staging.37 → 3.0.0-staging.39
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.
- package/dist/{TextAnnotatorPopup.d.ts → TextAnnotatorPopup/TextAnnotatorPopup.d.ts} +3 -2
- package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -0
- package/dist/TextAnnotatorPopup/index.d.ts +2 -0
- package/dist/TextAnnotatorPopup/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts +8 -0
- package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts +13 -0
- package/dist/hooks/useRestoreSelectionCaret.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.css +31 -1
- package/dist/react-text-annotator.es.js +8 -4
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es11.js +445 -527
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +60 -483
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +45 -2
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1450 -30
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es16.js +227 -37
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +537 -115
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +2 -2
- package/dist/react-text-annotator.es19.js +31 -2
- package/dist/react-text-annotator.es19.js.map +1 -1
- package/dist/react-text-annotator.es2.js +2 -2
- package/dist/react-text-annotator.es20.js +893 -109
- package/dist/react-text-annotator.es20.js.map +1 -1
- package/dist/react-text-annotator.es21.js +2 -309
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es22.js +2 -58
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es23.js +113 -19
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +290 -130
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +43 -545
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js +23 -0
- package/dist/react-text-annotator.es26.js.map +1 -0
- package/dist/react-text-annotator.es27.js +130 -0
- package/dist/react-text-annotator.es27.js.map +1 -0
- package/dist/react-text-annotator.es28.js +155 -0
- package/dist/react-text-annotator.es28.js.map +1 -0
- package/dist/react-text-annotator.es29.js +314 -0
- package/dist/react-text-annotator.es29.js.map +1 -0
- package/dist/react-text-annotator.es3.js +2 -2
- package/dist/react-text-annotator.es30.js +152 -0
- package/dist/react-text-annotator.es30.js.map +1 -0
- package/dist/react-text-annotator.es31.js +563 -0
- package/dist/react-text-annotator.es31.js.map +1 -0
- package/dist/react-text-annotator.es4.js +30 -23
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +36 -78
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +24 -178
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +126 -10
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +182 -0
- package/dist/react-text-annotator.es8.js.map +1 -0
- package/dist/react-text-annotator.es9.js +10 -670
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/package.json +5 -3
- package/dist/TextAnnotatorPopup.d.ts.map +0 -1
- package/dist/react-text-annotator.es10.js +0 -244
- package/dist/react-text-annotator.es10.js.map +0 -1
- package/dist/react-text-annotator.es15.js +0 -901
- package/dist/react-text-annotator.es15.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es24.js","sources":["../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs"],"sourcesContent":["/**\n * Custom positioning reference element.\n * @see https://floating-ui.com/docs/virtual-elements\n */\n\nconst sides = ['top', 'right', 'bottom', 'left'];\nconst alignments = ['start', 'end'];\nconst placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + \"-\" + alignments[0], side + \"-\" + alignments[1]), []);\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\nconst floor = Math.floor;\nconst createCoords = v => ({\n x: v,\n y: v\n});\nconst oppositeSideMap = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nconst oppositeAlignmentMap = {\n start: 'end',\n end: 'start'\n};\nfunction clamp(start, value, end) {\n return max(start, min(value, end));\n}\nfunction evaluate(value, param) {\n return typeof value === 'function' ? value(param) : value;\n}\nfunction getSide(placement) {\n return placement.split('-')[0];\n}\nfunction getAlignment(placement) {\n return placement.split('-')[1];\n}\nfunction getOppositeAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}\nfunction getAxisLength(axis) {\n return axis === 'y' ? 'height' : 'width';\n}\nfunction getSideAxis(placement) {\n return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';\n}\nfunction getAlignmentAxis(placement) {\n return getOppositeAxis(getSideAxis(placement));\n}\nfunction getAlignmentSides(placement, rects, rtl) {\n if (rtl === void 0) {\n rtl = false;\n }\n const alignment = getAlignment(placement);\n const alignmentAxis = getAlignmentAxis(placement);\n const length = getAxisLength(alignmentAxis);\n let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';\n if (rects.reference[length] > rects.floating[length]) {\n mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n }\n return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];\n}\nfunction getExpandedPlacements(placement) {\n const oppositePlacement = getOppositePlacement(placement);\n return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\nfunction getOppositeAlignmentPlacement(placement) {\n return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);\n}\nfunction getSideList(side, isStart, rtl) {\n const lr = ['left', 'right'];\n const rl = ['right', 'left'];\n const tb = ['top', 'bottom'];\n const bt = ['bottom', 'top'];\n switch (side) {\n case 'top':\n case 'bottom':\n if (rtl) return isStart ? rl : lr;\n return isStart ? lr : rl;\n case 'left':\n case 'right':\n return isStart ? tb : bt;\n default:\n return [];\n }\n}\nfunction getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {\n const alignment = getAlignment(placement);\n let list = getSideList(getSide(placement), direction === 'start', rtl);\n if (alignment) {\n list = list.map(side => side + \"-\" + alignment);\n if (flipAlignment) {\n list = list.concat(list.map(getOppositeAlignmentPlacement));\n }\n }\n return list;\n}\nfunction getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);\n}\nfunction expandPaddingObject(padding) {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n ...padding\n };\n}\nfunction getPaddingObject(padding) {\n return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n top: padding,\n right: padding,\n bottom: padding,\n left: padding\n };\n}\nfunction rectToClientRect(rect) {\n const {\n x,\n y,\n width,\n height\n } = rect;\n return {\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n x,\n y\n };\n}\n\nexport { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };\n"],"names":[],"mappings":"AAQK,MAAC,MAAM,KAAK;AACZ,MAAC,MAAM,KAAK;AACZ,MAAC,QAAQ,KAAK;AACd,MAA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AS;AACjC,SAAO,OAAO,YAAY,WAAW,oBAAoB,OAAO,IAAI;AAAA,IAClE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EACV;AACA;AACA,SAAS,iBAAiB,MAAM;AAC9B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAG;AACJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO,IAAI;AAAA,IACX,QAAQ,IAAI;AAAA,IACZ;AAAA,IACA;AAAA,EACJ;AACA;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es24.js","sources":["../../../node_modules/CETEIcean/src/utilities.js"],"sourcesContent":["export function getOrdinality(elt, name) {\n let pos = 1;\n let e = elt;\n while (e && e.previousElementSibling !== null && (name ? e.previousElementSibling.localName == name : true)) {\n pos++;\n e = e.previousElementSibling;\n if (!e.previousElementSibling) {\n break;\n }\n }\n return pos;\n}\n\n/* \n Performs a deep copy operation of the input node while stripping\n out child elements introduced by CETEIcean.\n*/ \nexport function copyAndReset(node) {\n const doc = node.ownerDocument;\n let clone = (n) => { \n let result;\n switch (n.nodeType) {\n case 1: // nodeType 1 is Node.ELEMENT_NODE\n result = doc.createElement(n.nodeName);\n break;\n case 9: // nodeType 9 is Node.DOCUMENT_NODE\n result = doc.implementation.createDocument();\n break;\n case 11: // nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n result = doc.createDocumentFragment();\n break;\n default:\n result = n.cloneNode(true);\n }\n if (n.attributes) {\n for (let att of Array.from(n.attributes)) {\n if (att.name !== \"data-processed\") {\n result.setAttribute(att.name,att.value);\n }\n }\n }\n for (let nd of Array.from(n.childNodes)){\n // nodeType 1 is Node.ELEMENT_NODE\n if (nd.nodeType == 1) {\n if (nd.hasAttribute(\"data-original\")) {\n for (let childNode of Array.from(nd.childNodes)) {\n let child = result.appendChild(clone(childNode));\n // nodeType 1 is Node.ELEMENT_NODE\n if (child.nodeType === 1 && child.hasAttribute(\"data-origid\")) {\n child.setAttribute(\"id\", child.getAttribute(\"data-origid\"));\n child.removeAttribute(\"data-origid\");\n }\n }\n return result;\n } else if (nd.hasAttribute(\"data-origname\")) {\n result.appendChild(clone(nd));\n }\n } else {\n result.appendChild(nd.cloneNode());\n }\n }\n return result;\n }\n return clone(node);\n}\n\n/* \n Given a space-separated list of URLs (e.g. in a ref with multiple\n targets), returns just the first one.\n*/\nexport function first(urls) {\n return urls.replace(/ .*$/, \"\");\n}\n\n/* \n Wraps the content of the element parameter in a hidden <cetei-original data-original>\n*/\nexport function hideContent(elt, rewriteIds = true) {\n const doc = elt.ownerDocument;\n if (elt.childNodes.length > 0) {\n let hidden = doc.createElement(\"cetei-original\");\n elt.appendChild(hidden);\n hidden.setAttribute(\"hidden\", \"\");\n hidden.setAttribute(\"data-original\", \"\");\n for (let node of Array.from(elt.childNodes)) {\n if (node !== hidden) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1) {\n node.setAttribute(\"data-processed\", \"\");\n for (let e of node.querySelectorAll(\"*\")) {\n e.setAttribute(\"data-processed\", \"\");\n }\n }\n hidden.appendChild(elt.removeChild(node));\n }\n }\n if (rewriteIds) {\n for (let e of Array.from(hidden.querySelectorAll(\"*\"))) {\n if (e.hasAttribute(\"id\")) {\n e.setAttribute(\"data-origid\", e.getAttribute(\"id\"));\n e.removeAttribute(\"id\");\n }\n }\n }\n }\n}\n\nexport function normalizeURI(urls) {\n return this.rw(this.first(urls))\n}\n\n/* \n Takes a string and a number and returns the original string\n printed that number of times.\n*/\nexport function repeat(str, times) {\n let result = \"\";\n for (let i = 0; i < times; i++) {\n result += str;\n }\n return result;\n}\n\n/* \n Resolves URIs that use TEI prefixDefs into full URIs.\n See https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-prefixDef.html\n*/\nexport function resolveURI(uri) {\n let prefixdef = this.prefixDefs[uri.substring(0,uri.indexOf(\":\"))];\n return uri.replace(new RegExp(prefixdef[\"matchPattern\"]), prefixdef[\"replacementPattern\"]);\n}\n\n/*\n Convenience function for getting prefix definitions, Takes a prefix\n and returns an object with \"matchPattern\" and \"replacementPattern\"\n keys.\n*/\nexport function getPrefixDef(prefix) {\n return this.prefixDefs[prefix];\n}\n\n/* \n Takes a relative URL and rewrites it based on the base URL of the\n HTML document\n*/\nexport function rw(url) {\n if (!url.match(/^(?:http|mailto|file|\\/|#).*$/)) {\n return this.base + first(url);\n } else {\n return url;\n }\n}\n\n/*\n Combines the functionality of copyAndReset() and serialize() to return\n a \"clean\" version of the XML markup.\n */\nexport function resetAndSerialize(el, stripElt, ws) {\n return serialize(copyAndReset(el), stripElt, ws);\n}\n\n/* \n Takes an element and serializes it to an XML string or, if the stripElt\n parameter is set, serializes the element's content. The ws parameter, if\n set, will switch on minimal \"pretty-printing\" and indenting of the serialized\n result.\n*/\nexport function serialize(el, stripElt, ws) {\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n if (el.nodeType === 9 || el.nodeType === 11) { // nodeType 9 is Node.DOCUMENT_NODE; nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n str += \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.getAttribute(\"data-origname\");\n // HTML5 lowercases all attribute names; @data-origatts contains the original names\n let attrNames = el.hasAttribute(\"data-origatts\") ? el.getAttribute(\"data-origatts\").split(\" \") : [];\n for (let attr of Array.from(el.attributes)) {\n if (!attr.name.startsWith(\"data-\") && !([\"id\", \"lang\", \"class\"].includes(attr.name))) {\n str += \" \" + attrNames.find(function(e) {return e.toLowerCase() == attr.name}) + \"=\\\"\" + attr.value + \"\\\"\";\n }\n if (attr.name == \"data-xmlns\") {\n str += \" xmlns=\\\"\" + attr.value +\"\\\"\";\n }\n }\n if (el.childNodes.length > 0) {\n str += \">\";\n } else {\n str += \"/>\";\n }\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serialize(node, false, ws + \" \");\n } else {\n str += serialize(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue;\n }\n }\n if (!stripElt && el.nodeType == 1 && el.childNodes.length > 0) {\n if (typeof ws === \"string\") {\n str += \"\\n\" + ws + \"</\";\n } else {\n str += \"</\";\n }\n str += el.getAttribute(\"data-origname\") + \">\";\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\n/* \n Write out the HTML markup to a string, using HTML conventions.\n */\nexport function serializeHTML(el, stripElt, ws) {\n const EMPTY_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.nodeName;\n for (let attr of Array.from(el.attributes)) {\n str += \" \" + attr.name + \"=\\\"\" + attr.value + \"\\\"\";\n }\n str += \">\";\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serializeHTML(node, false, ws + \" \");\n } else {\n str += serializeHTML(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue.replace(/</g, \"<\");\n }\n }\n if (!EMPTY_ELEMENTS.includes(el.nodeName)) {\n if (!stripElt && el.nodeType == 1) {\n if (typeof ws === \"string\") {\n str += `\\n${ws}</`;\n } else {\n str += \"</\";\n }\n str += `${el.nodeName}>`;\n }\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\nexport function unEscapeEntities(str) {\n return str.replace(/>/, \">\")\n .replace(/"/, \"\\\"\")\n .replace(/'/, \"'\")\n .replace(/&/, \"&\");\n}\n\n// Given a qualified name (e.g. tei:text), return the element name\nexport function tagName(name) {\n if (name.includes(\":\"), 1) {\n return name.replace(/:/,\"-\").toLowerCase();\n } else {\n return \"ceteicean-\" + name.toLowerCase();\n }\n}\n\nexport function defineCustomElement(name, behavior = null, debug = false) {\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 */\n try {\n window.customElements.define(tagName(name), class extends HTMLElement {\n constructor() {\n super(); \n if (!this.matches(\":defined\")) { // \"Upgraded\" undefined elements can have attributes & children; new elements can't\n if (behavior) {\n behavior.call(this);\n // We don't want to double-process elements, so add a flag\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n }\n // Process new elements when they are connected to the browser DOM\n connectedCallback() {\n if (!this.hasAttribute(\"data-processed\")) {\n if (behavior) {\n behavior.call(this);\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n };\n });\n } catch (error) {\n // When using the same CETEIcean instance for multiple TEI files, this error becomes very common. \n // It's muted by default unless the debug option is set.\n if (debug) {\n console.log(tagName(name) + \" couldn't be registered or is already registered.\");\n console.log(error);\n }\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,KAAK,MAAM;AACvC,MAAI,MAAM;AACV,MAAI,IAAI;AACR,SAAO,KAAK,EAAE,2BAA2B,SAAS,OAAO,EAAE,uBAAuB,aAAa,OAAO,OAAO;AAC3G;AACA,QAAI,EAAE;AACN,QAAI,CAAC,EAAE,wBAAwB;AAC7B;AAAA,IACD;AAAA,EACF;AACD,SAAO;AACT;AAMO,SAAS,aAAa,MAAM;AACjC,QAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,CAAC,MAAM;AACjB,QAAI;AACJ,YAAQ,EAAE,UAAQ;AAAA,MAChB,KAAK;AACH,iBAAS,IAAI,cAAc,EAAE,QAAQ;AACrC;AAAA,MACF,KAAK;AACH,iBAAS,IAAI,eAAe;AAC5B;AAAA,MACF,KAAK;AACH,iBAAS,IAAI;AACb;AAAA,MACF;AACE,iBAAS,EAAE,UAAU,IAAI;AAAA,IAC5B;AACD,QAAI,EAAE,YAAY;AAChB,eAAS,OAAO,MAAM,KAAK,EAAE,UAAU,GAAG;AACxC,YAAI,IAAI,SAAS,kBAAkB;AACjC,iBAAO,aAAa,IAAI,MAAK,IAAI,KAAK;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AACD,aAAS,MAAM,MAAM,KAAK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CAAC,KAAK,QAAQ,UAAU,GAAG;AAC7B,cAAI,UAAU;AACZ,qBAAS,KAAK,IAAI;AAElB,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAED,oBAAoB;AAClB,YAAI,CAAC,KAAK,aAAa,gBAAgB,GAAG;AACxC,cAAI,UAAU;AACZ,qBAAS,KAAK,IAAI;AAClB,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA,IACP,CAAK;AAAA,EACF,SAAQ,OAAO;AAGd,QAAI,OAAO;AACP,cAAQ,IAAI,QAAQ,IAAI,IAAI,mDAAmD;AAC/E,cAAQ,IAAI,KAAK;AAAA,IACpB;AAAA,EACF;AACH;","x_google_ignoreList":[0]}
|
|
@@ -1,563 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = _ref;
|
|
7
|
-
const sideAxis = getSideAxis(placement);
|
|
8
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
9
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
10
|
-
const side = getSide(placement);
|
|
11
|
-
const isVertical = sideAxis === "y";
|
|
12
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
13
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
14
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
15
|
-
let coords;
|
|
16
|
-
switch (side) {
|
|
17
|
-
case "top":
|
|
18
|
-
coords = {
|
|
19
|
-
x: commonX,
|
|
20
|
-
y: reference.y - floating.height
|
|
21
|
-
};
|
|
22
|
-
break;
|
|
23
|
-
case "bottom":
|
|
24
|
-
coords = {
|
|
25
|
-
x: commonX,
|
|
26
|
-
y: reference.y + reference.height
|
|
27
|
-
};
|
|
28
|
-
break;
|
|
29
|
-
case "right":
|
|
30
|
-
coords = {
|
|
31
|
-
x: reference.x + reference.width,
|
|
32
|
-
y: commonY
|
|
33
|
-
};
|
|
34
|
-
break;
|
|
35
|
-
case "left":
|
|
36
|
-
coords = {
|
|
37
|
-
x: reference.x - floating.width,
|
|
38
|
-
y: commonY
|
|
39
|
-
};
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
coords = {
|
|
43
|
-
x: reference.x,
|
|
44
|
-
y: reference.y
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
switch (getAlignment(placement)) {
|
|
48
|
-
case "start":
|
|
49
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
50
|
-
break;
|
|
51
|
-
case "end":
|
|
52
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
return coords;
|
|
56
|
-
}
|
|
57
|
-
const computePosition = async (reference, floating, config) => {
|
|
58
|
-
const {
|
|
59
|
-
placement = "bottom",
|
|
60
|
-
strategy = "absolute",
|
|
61
|
-
middleware = [],
|
|
62
|
-
platform
|
|
63
|
-
} = config;
|
|
64
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
65
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
66
|
-
let rects = await platform.getElementRects({
|
|
67
|
-
reference,
|
|
68
|
-
floating,
|
|
69
|
-
strategy
|
|
70
|
-
});
|
|
71
|
-
let {
|
|
72
|
-
x,
|
|
73
|
-
y
|
|
74
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
75
|
-
let statefulPlacement = placement;
|
|
76
|
-
let middlewareData = {};
|
|
77
|
-
let resetCount = 0;
|
|
78
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
79
|
-
const {
|
|
80
|
-
name,
|
|
81
|
-
fn
|
|
82
|
-
} = validMiddleware[i];
|
|
83
|
-
const {
|
|
84
|
-
x: nextX,
|
|
85
|
-
y: nextY,
|
|
86
|
-
data,
|
|
87
|
-
reset
|
|
88
|
-
} = await fn({
|
|
89
|
-
x,
|
|
90
|
-
y,
|
|
91
|
-
initialPlacement: placement,
|
|
92
|
-
placement: statefulPlacement,
|
|
93
|
-
strategy,
|
|
94
|
-
middlewareData,
|
|
95
|
-
rects,
|
|
96
|
-
platform,
|
|
97
|
-
elements: {
|
|
98
|
-
reference,
|
|
99
|
-
floating
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
x = nextX != null ? nextX : x;
|
|
103
|
-
y = nextY != null ? nextY : y;
|
|
104
|
-
middlewareData = {
|
|
105
|
-
...middlewareData,
|
|
106
|
-
[name]: {
|
|
107
|
-
...middlewareData[name],
|
|
108
|
-
...data
|
|
1
|
+
function addBehaviors(bhvs) {
|
|
2
|
+
if (bhvs.namespaces) {
|
|
3
|
+
for (let prefix of Object.keys(bhvs.namespaces)) {
|
|
4
|
+
if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {
|
|
5
|
+
this.namespaces.set(bhvs.namespaces[prefix], prefix);
|
|
109
6
|
}
|
|
110
|
-
};
|
|
111
|
-
if (reset && resetCount <= 50) {
|
|
112
|
-
resetCount++;
|
|
113
|
-
if (typeof reset === "object") {
|
|
114
|
-
if (reset.placement) {
|
|
115
|
-
statefulPlacement = reset.placement;
|
|
116
|
-
}
|
|
117
|
-
if (reset.rects) {
|
|
118
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
119
|
-
reference,
|
|
120
|
-
floating,
|
|
121
|
-
strategy
|
|
122
|
-
}) : reset.rects;
|
|
123
|
-
}
|
|
124
|
-
({
|
|
125
|
-
x,
|
|
126
|
-
y
|
|
127
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
128
|
-
}
|
|
129
|
-
i = -1;
|
|
130
7
|
}
|
|
131
8
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
strategy,
|
|
137
|
-
middlewareData
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
async function detectOverflow(state, options) {
|
|
141
|
-
var _await$platform$isEle;
|
|
142
|
-
if (options === void 0) {
|
|
143
|
-
options = {};
|
|
144
|
-
}
|
|
145
|
-
const {
|
|
146
|
-
x,
|
|
147
|
-
y,
|
|
148
|
-
platform,
|
|
149
|
-
rects,
|
|
150
|
-
elements,
|
|
151
|
-
strategy
|
|
152
|
-
} = state;
|
|
153
|
-
const {
|
|
154
|
-
boundary = "clippingAncestors",
|
|
155
|
-
rootBoundary = "viewport",
|
|
156
|
-
elementContext = "floating",
|
|
157
|
-
altBoundary = false,
|
|
158
|
-
padding = 0
|
|
159
|
-
} = evaluate(options, state);
|
|
160
|
-
const paddingObject = getPaddingObject(padding);
|
|
161
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
162
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
163
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
164
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
|
|
165
|
-
boundary,
|
|
166
|
-
rootBoundary,
|
|
167
|
-
strategy
|
|
168
|
-
}));
|
|
169
|
-
const rect = elementContext === "floating" ? {
|
|
170
|
-
x,
|
|
171
|
-
y,
|
|
172
|
-
width: rects.floating.width,
|
|
173
|
-
height: rects.floating.height
|
|
174
|
-
} : rects.reference;
|
|
175
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
176
|
-
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
177
|
-
x: 1,
|
|
178
|
-
y: 1
|
|
179
|
-
} : {
|
|
180
|
-
x: 1,
|
|
181
|
-
y: 1
|
|
182
|
-
};
|
|
183
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
184
|
-
elements,
|
|
185
|
-
rect,
|
|
186
|
-
offsetParent,
|
|
187
|
-
strategy
|
|
188
|
-
}) : rect);
|
|
189
|
-
return {
|
|
190
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
191
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
192
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
193
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
const flip = function(options) {
|
|
197
|
-
if (options === void 0) {
|
|
198
|
-
options = {};
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
name: "flip",
|
|
202
|
-
options,
|
|
203
|
-
async fn(state) {
|
|
204
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
205
|
-
const {
|
|
206
|
-
placement,
|
|
207
|
-
middlewareData,
|
|
208
|
-
rects,
|
|
209
|
-
initialPlacement,
|
|
210
|
-
platform,
|
|
211
|
-
elements
|
|
212
|
-
} = state;
|
|
213
|
-
const {
|
|
214
|
-
mainAxis: checkMainAxis = true,
|
|
215
|
-
crossAxis: checkCrossAxis = true,
|
|
216
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
217
|
-
fallbackStrategy = "bestFit",
|
|
218
|
-
fallbackAxisSideDirection = "none",
|
|
219
|
-
flipAlignment = true,
|
|
220
|
-
...detectOverflowOptions
|
|
221
|
-
} = evaluate(options, state);
|
|
222
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
223
|
-
return {};
|
|
224
|
-
}
|
|
225
|
-
const side = getSide(placement);
|
|
226
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
227
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
228
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
229
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
230
|
-
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
231
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
232
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
233
|
-
}
|
|
234
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
235
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
236
|
-
const overflows = [];
|
|
237
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
238
|
-
if (checkMainAxis) {
|
|
239
|
-
overflows.push(overflow[side]);
|
|
9
|
+
for (let prefix of this.namespaces.values()) {
|
|
10
|
+
if (bhvs[prefix]) {
|
|
11
|
+
for (let b of Object.keys(bhvs[prefix])) {
|
|
12
|
+
this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];
|
|
240
13
|
}
|
|
241
|
-
if (checkCrossAxis) {
|
|
242
|
-
const sides = getAlignmentSides(placement, rects, rtl);
|
|
243
|
-
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
244
|
-
}
|
|
245
|
-
overflowsData = [...overflowsData, {
|
|
246
|
-
placement,
|
|
247
|
-
overflows
|
|
248
|
-
}];
|
|
249
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
250
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
251
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
252
|
-
const nextPlacement = placements[nextIndex];
|
|
253
|
-
if (nextPlacement) {
|
|
254
|
-
return {
|
|
255
|
-
data: {
|
|
256
|
-
index: nextIndex,
|
|
257
|
-
overflows: overflowsData
|
|
258
|
-
},
|
|
259
|
-
reset: {
|
|
260
|
-
placement: nextPlacement
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
265
|
-
if (!resetPlacement) {
|
|
266
|
-
switch (fallbackStrategy) {
|
|
267
|
-
case "bestFit": {
|
|
268
|
-
var _overflowsData$filter2;
|
|
269
|
-
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
270
|
-
if (hasFallbackAxisSideDirection) {
|
|
271
|
-
const currentSideAxis = getSideAxis(d.placement);
|
|
272
|
-
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
273
|
-
// reading directions favoring greater width.
|
|
274
|
-
currentSideAxis === "y";
|
|
275
|
-
}
|
|
276
|
-
return true;
|
|
277
|
-
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
278
|
-
if (placement2) {
|
|
279
|
-
resetPlacement = placement2;
|
|
280
|
-
}
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
case "initialPlacement":
|
|
284
|
-
resetPlacement = initialPlacement;
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (placement !== resetPlacement) {
|
|
289
|
-
return {
|
|
290
|
-
reset: {
|
|
291
|
-
placement: resetPlacement
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return {};
|
|
297
14
|
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const minY = min(...rects.map((rect) => rect.top));
|
|
303
|
-
const maxX = max(...rects.map((rect) => rect.right));
|
|
304
|
-
const maxY = max(...rects.map((rect) => rect.bottom));
|
|
305
|
-
return {
|
|
306
|
-
x: minX,
|
|
307
|
-
y: minY,
|
|
308
|
-
width: maxX - minX,
|
|
309
|
-
height: maxY - minY
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function getRectsByLine(rects) {
|
|
313
|
-
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
314
|
-
const groups = [];
|
|
315
|
-
let prevRect = null;
|
|
316
|
-
for (let i = 0; i < sortedRects.length; i++) {
|
|
317
|
-
const rect = sortedRects[i];
|
|
318
|
-
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
319
|
-
groups.push([rect]);
|
|
320
|
-
} else {
|
|
321
|
-
groups[groups.length - 1].push(rect);
|
|
15
|
+
}
|
|
16
|
+
if (bhvs["functions"]) {
|
|
17
|
+
for (let fn of Object.keys(bhvs["functions"])) {
|
|
18
|
+
this.utilities[fn] = bhvs["functions"][fn].bind(this.utilities);
|
|
322
19
|
}
|
|
323
|
-
prevRect = rect;
|
|
324
20
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const inline = function(options) {
|
|
328
|
-
if (options === void 0) {
|
|
329
|
-
options = {};
|
|
21
|
+
if (bhvs["handlers"]) {
|
|
22
|
+
console.log("Behavior handlers are no longer used.");
|
|
330
23
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
options,
|
|
334
|
-
async fn(state) {
|
|
335
|
-
const {
|
|
336
|
-
placement,
|
|
337
|
-
elements,
|
|
338
|
-
rects,
|
|
339
|
-
platform,
|
|
340
|
-
strategy
|
|
341
|
-
} = state;
|
|
342
|
-
const {
|
|
343
|
-
padding = 2,
|
|
344
|
-
x,
|
|
345
|
-
y
|
|
346
|
-
} = evaluate(options, state);
|
|
347
|
-
const nativeClientRects = Array.from(await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference)) || []);
|
|
348
|
-
const clientRects = getRectsByLine(nativeClientRects);
|
|
349
|
-
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
350
|
-
const paddingObject = getPaddingObject(padding);
|
|
351
|
-
function getBoundingClientRect() {
|
|
352
|
-
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
353
|
-
return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
354
|
-
}
|
|
355
|
-
if (clientRects.length >= 2) {
|
|
356
|
-
if (getSideAxis(placement) === "y") {
|
|
357
|
-
const firstRect = clientRects[0];
|
|
358
|
-
const lastRect = clientRects[clientRects.length - 1];
|
|
359
|
-
const isTop = getSide(placement) === "top";
|
|
360
|
-
const top2 = firstRect.top;
|
|
361
|
-
const bottom2 = lastRect.bottom;
|
|
362
|
-
const left2 = isTop ? firstRect.left : lastRect.left;
|
|
363
|
-
const right2 = isTop ? firstRect.right : lastRect.right;
|
|
364
|
-
const width2 = right2 - left2;
|
|
365
|
-
const height2 = bottom2 - top2;
|
|
366
|
-
return {
|
|
367
|
-
top: top2,
|
|
368
|
-
bottom: bottom2,
|
|
369
|
-
left: left2,
|
|
370
|
-
right: right2,
|
|
371
|
-
width: width2,
|
|
372
|
-
height: height2,
|
|
373
|
-
x: left2,
|
|
374
|
-
y: top2
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
const isLeftSide = getSide(placement) === "left";
|
|
378
|
-
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
379
|
-
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
380
|
-
const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
381
|
-
const top = measureRects[0].top;
|
|
382
|
-
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
383
|
-
const left = minLeft;
|
|
384
|
-
const right = maxRight;
|
|
385
|
-
const width = right - left;
|
|
386
|
-
const height = bottom - top;
|
|
387
|
-
return {
|
|
388
|
-
top,
|
|
389
|
-
bottom,
|
|
390
|
-
left,
|
|
391
|
-
right,
|
|
392
|
-
width,
|
|
393
|
-
height,
|
|
394
|
-
x: left,
|
|
395
|
-
y: top
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
return fallback;
|
|
399
|
-
}
|
|
400
|
-
const resetRects = await platform.getElementRects({
|
|
401
|
-
reference: {
|
|
402
|
-
getBoundingClientRect
|
|
403
|
-
},
|
|
404
|
-
floating: elements.floating,
|
|
405
|
-
strategy
|
|
406
|
-
});
|
|
407
|
-
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
408
|
-
return {
|
|
409
|
-
reset: {
|
|
410
|
-
rects: resetRects
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
return {};
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
};
|
|
418
|
-
async function convertValueToCoords(state, options) {
|
|
419
|
-
const {
|
|
420
|
-
placement,
|
|
421
|
-
platform,
|
|
422
|
-
elements
|
|
423
|
-
} = state;
|
|
424
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
425
|
-
const side = getSide(placement);
|
|
426
|
-
const alignment = getAlignment(placement);
|
|
427
|
-
const isVertical = getSideAxis(placement) === "y";
|
|
428
|
-
const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
|
|
429
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
430
|
-
const rawValue = evaluate(options, state);
|
|
431
|
-
let {
|
|
432
|
-
mainAxis,
|
|
433
|
-
crossAxis,
|
|
434
|
-
alignmentAxis
|
|
435
|
-
} = typeof rawValue === "number" ? {
|
|
436
|
-
mainAxis: rawValue,
|
|
437
|
-
crossAxis: 0,
|
|
438
|
-
alignmentAxis: null
|
|
439
|
-
} : {
|
|
440
|
-
mainAxis: 0,
|
|
441
|
-
crossAxis: 0,
|
|
442
|
-
alignmentAxis: null,
|
|
443
|
-
...rawValue
|
|
444
|
-
};
|
|
445
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
446
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
24
|
+
if (bhvs["fallbacks"]) {
|
|
25
|
+
console.log("Fallback behaviors are no longer used.");
|
|
447
26
|
}
|
|
448
|
-
return isVertical ? {
|
|
449
|
-
x: crossAxis * crossAxisMulti,
|
|
450
|
-
y: mainAxis * mainAxisMulti
|
|
451
|
-
} : {
|
|
452
|
-
x: mainAxis * mainAxisMulti,
|
|
453
|
-
y: crossAxis * crossAxisMulti
|
|
454
|
-
};
|
|
455
27
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
async fn(state) {
|
|
464
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
465
|
-
const {
|
|
466
|
-
x,
|
|
467
|
-
y,
|
|
468
|
-
placement,
|
|
469
|
-
middlewareData
|
|
470
|
-
} = state;
|
|
471
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
472
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
473
|
-
return {};
|
|
28
|
+
function addBehavior(ns, element, b) {
|
|
29
|
+
let p;
|
|
30
|
+
if (ns === Object(ns)) {
|
|
31
|
+
for (let prefix of Object.keys(ns)) {
|
|
32
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
33
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
34
|
+
p = prefix;
|
|
474
35
|
}
|
|
475
|
-
return {
|
|
476
|
-
x: x + diffCoords.x,
|
|
477
|
-
y: y + diffCoords.y,
|
|
478
|
-
data: {
|
|
479
|
-
...diffCoords,
|
|
480
|
-
placement
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
36
|
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
const shift = function(options) {
|
|
487
|
-
if (options === void 0) {
|
|
488
|
-
options = {};
|
|
37
|
+
} else {
|
|
38
|
+
p = ns;
|
|
489
39
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const {
|
|
500
|
-
mainAxis: checkMainAxis = true,
|
|
501
|
-
crossAxis: checkCrossAxis = false,
|
|
502
|
-
limiter = {
|
|
503
|
-
fn: (_ref) => {
|
|
504
|
-
let {
|
|
505
|
-
x: x2,
|
|
506
|
-
y: y2
|
|
507
|
-
} = _ref;
|
|
508
|
-
return {
|
|
509
|
-
x: x2,
|
|
510
|
-
y: y2
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
},
|
|
514
|
-
...detectOverflowOptions
|
|
515
|
-
} = evaluate(options, state);
|
|
516
|
-
const coords = {
|
|
517
|
-
x,
|
|
518
|
-
y
|
|
519
|
-
};
|
|
520
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
521
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
522
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
523
|
-
let mainAxisCoord = coords[mainAxis];
|
|
524
|
-
let crossAxisCoord = coords[crossAxis];
|
|
525
|
-
if (checkMainAxis) {
|
|
526
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
527
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
528
|
-
const min2 = mainAxisCoord + overflow[minSide];
|
|
529
|
-
const max2 = mainAxisCoord - overflow[maxSide];
|
|
530
|
-
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
531
|
-
}
|
|
532
|
-
if (checkCrossAxis) {
|
|
533
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
534
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
535
|
-
const min2 = crossAxisCoord + overflow[minSide];
|
|
536
|
-
const max2 = crossAxisCoord - overflow[maxSide];
|
|
537
|
-
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
40
|
+
this.behaviors[`${p}:${element}`] = b;
|
|
41
|
+
}
|
|
42
|
+
function removeBehavior(ns, element) {
|
|
43
|
+
let p;
|
|
44
|
+
if (ns === Object(ns)) {
|
|
45
|
+
for (let prefix of Object.keys(ns)) {
|
|
46
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
47
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
48
|
+
p = prefix;
|
|
538
49
|
}
|
|
539
|
-
const limitedCoords = limiter.fn({
|
|
540
|
-
...state,
|
|
541
|
-
[mainAxis]: mainAxisCoord,
|
|
542
|
-
[crossAxis]: crossAxisCoord
|
|
543
|
-
});
|
|
544
|
-
return {
|
|
545
|
-
...limitedCoords,
|
|
546
|
-
data: {
|
|
547
|
-
x: limitedCoords.x - x,
|
|
548
|
-
y: limitedCoords.y - y
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
50
|
}
|
|
552
|
-
}
|
|
553
|
-
|
|
51
|
+
} else {
|
|
52
|
+
p = ns;
|
|
53
|
+
}
|
|
54
|
+
delete this.behaviors[`${p}:${element}`];
|
|
55
|
+
}
|
|
554
56
|
export {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
inline,
|
|
559
|
-
offset,
|
|
560
|
-
rectToClientRect,
|
|
561
|
-
shift
|
|
57
|
+
addBehavior,
|
|
58
|
+
addBehaviors,
|
|
59
|
+
removeBehavior
|
|
562
60
|
};
|
|
563
61
|
//# sourceMappingURL=react-text-annotator.es25.js.map
|