@aquera/nile-elements 1.5.9 → 1.6.1
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/README.md +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +382 -227
- package/dist/nile-floating-panel/index.cjs.js +1 -1
- package/dist/nile-floating-panel/index.esm.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.esm.js +137 -21
- package/dist/nile-floating-panel/nile-floating-panel.esm.js +1 -1
- package/dist/nile-lite-tooltip/index.cjs.js +1 -1
- package/dist/nile-lite-tooltip/index.esm.js +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js.map +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +24 -0
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.esm.js +59 -44
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.esm.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-floating-panel/index.js.map +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.css.d.ts +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js +147 -20
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js.map +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.d.ts +90 -24
- package/dist/src/nile-floating-panel/nile-floating-panel.js +478 -159
- package/dist/src/nile-floating-panel/nile-floating-panel.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +24 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +6 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +62 -24
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +12 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.js +239 -130
- package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +469 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -0
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js +13 -4
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tippy.esm-57628c2b.esm.js +1 -0
- package/dist/tippy.esm-78baa8f2.cjs.js +2 -0
- package/dist/tippy.esm-78baa8f2.cjs.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/index.ts +2 -2
- package/src/nile-floating-panel/index.ts +0 -1
- package/src/nile-floating-panel/nile-floating-panel.css.ts +149 -21
- package/src/nile-floating-panel/nile-floating-panel.ts +489 -190
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +24 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +66 -26
- package/src/nile-rich-text-editor/nile-rte-link.test.ts +682 -0
- package/src/nile-rich-text-editor/nile-rte-link.ts +195 -100
- package/src/nile-rich-text-editor/utils/inline-utils.ts +11 -4
- package/vscode-html-custom-data.json +229 -25
- package/dist/nile-floating-panel/anchor-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/anchor-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/anchor-manager.esm.js +0 -1
- package/dist/nile-floating-panel/content-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/content-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/content-manager.esm.js +0 -1
- package/dist/nile-floating-panel/event-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/event-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/event-manager.esm.js +0 -1
- package/dist/nile-floating-panel/position-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/position-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/position-manager.esm.js +0 -1
- package/dist/nile-floating-panel/style-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/style-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/style-manager.esm.js +0 -1
- package/dist/nile-floating-panel/types.cjs.js +0 -2
- package/dist/nile-floating-panel/types.cjs.js.map +0 -1
- package/dist/nile-floating-panel/types.esm.js +0 -1
- package/dist/src/nile-floating-panel/anchor-manager.d.ts +0 -6
- package/dist/src/nile-floating-panel/anchor-manager.js +0 -27
- package/dist/src/nile-floating-panel/anchor-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/content-manager.d.ts +0 -5
- package/dist/src/nile-floating-panel/content-manager.js +0 -44
- package/dist/src/nile-floating-panel/content-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/event-manager.d.ts +0 -14
- package/dist/src/nile-floating-panel/event-manager.js +0 -52
- package/dist/src/nile-floating-panel/event-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/position-manager.d.ts +0 -17
- package/dist/src/nile-floating-panel/position-manager.js +0 -72
- package/dist/src/nile-floating-panel/position-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/style-manager.d.ts +0 -9
- package/dist/src/nile-floating-panel/style-manager.js +0 -44
- package/dist/src/nile-floating-panel/style-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/types.d.ts +0 -11
- package/dist/src/nile-floating-panel/types.js +0 -2
- package/dist/src/nile-floating-panel/types.js.map +0 -1
- package/src/nile-floating-panel/anchor-manager.ts +0 -33
- package/src/nile-floating-panel/content-manager.ts +0 -54
- package/src/nile-floating-panel/event-manager.ts +0 -74
- package/src/nile-floating-panel/position-manager.ts +0 -102
- package/src/nile-floating-panel/style-manager.ts +0 -54
- package/src/nile-floating-panel/types.ts +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as t}from"tslib";import{property as n,customElement as e}from"lit/decorators.js";import{s as i}from"./nile-lite-tooltip.css.esm.js";import{N as o}from"../internal/nile-element.esm.js";import{p as r,a as u}from"./utils.esm.js";import{V as a}from"../utilities/visibility-manager.esm.js";import"lit";var c="top",f="bottom",s="right",d="left",l="auto",p=[c,f,s,d],v="start",h="end",m="viewport",b="popper",y=p.reduce((function(t,n){return t.concat([n+"-"+v,n+"-"+h])}),[]),g=[].concat(p,[l]).reduce((function(t,n){return t.concat([n,n+"-"+v,n+"-"+h])}),[]),w=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function O(t){return t?(t.nodeName||"").toLowerCase():null}function x(t){if(null==t)return window;if("[object Window]"!==t.toString()){var n=t.ownerDocument;return n&&n.defaultView||window}return t}function j(t){return t instanceof x(t).Element||t instanceof Element}function T(t){return t instanceof x(t).HTMLElement||t instanceof HTMLElement}function k(t){return"undefined"!=typeof ShadowRoot&&(t instanceof x(t).ShadowRoot||t instanceof ShadowRoot)}var C={name:"applyStyles",enabled:!0,phase:"write",fn:function(t){var n=t.state;Object.keys(n.elements).forEach((function(t){var e=n.styles[t]||{},i=n.attributes[t]||{},o=n.elements[t];T(o)&&O(o)&&(Object.assign(o.style,e),Object.keys(i).forEach((function(t){var n=i[t];!1===n?o.removeAttribute(t):o.setAttribute(t,!0===n?"":n)})))}))},effect:function(t){var n=t.state,e={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(n.elements.popper.style,e.popper),n.styles=e,n.elements.arrow&&Object.assign(n.elements.arrow.style,e.arrow),function(){Object.keys(n.elements).forEach((function(t){var i=n.elements[t],o=n.attributes[t]||{},r=Object.keys(n.styles.hasOwnProperty(t)?n.styles[t]:e[t]).reduce((function(t,n){return t[n]="",t}),{});T(i)&&O(i)&&(Object.assign(i.style,r),Object.keys(o).forEach((function(t){i.removeAttribute(t)})))}))}},requires:["computeStyles"]};function S(t){return t.split("-")[0]}var B=Math.max,M=Math.min,A=Math.round;function E(){var t=navigator.userAgentData;return null!=t&&t.brands&&Array.isArray(t.brands)?t.brands.map((function(t){return t.brand+"/"+t.version})).join(" "):navigator.userAgent}function R(){return!/^((?!chrome|android).)*safari/i.test(E())}function H(t,n,e){void 0===n&&(n=!1),void 0===e&&(e=!1);var i=t.getBoundingClientRect(),o=1,r=1;n&&T(t)&&(o=t.offsetWidth>0&&A(i.width)/t.offsetWidth||1,r=t.offsetHeight>0&&A(i.height)/t.offsetHeight||1);var u=(j(t)?x(t):window).visualViewport,a=!R()&&e,c=(i.left+(a&&u?u.offsetLeft:0))/o,f=(i.top+(a&&u?u.offsetTop:0))/r,s=i.width/o,d=i.height/r;return{width:s,height:d,top:f,right:c+s,bottom:f+d,left:c,x:c,y:f}}function q(t){var n=H(t),e=t.offsetWidth,i=t.offsetHeight;return Math.abs(n.width-e)<=1&&(e=n.width),Math.abs(n.height-i)<=1&&(i=n.height),{x:t.offsetLeft,y:t.offsetTop,width:e,height:i}}function U(t,n){var e=n.getRootNode&&n.getRootNode();if(t.contains(n))return!0;if(e&&k(e)){var i=n;do{if(i&&t.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function W(t){return x(t).getComputedStyle(t)}function z(t){return["table","td","th"].indexOf(O(t))>=0}function L(t){return((j(t)?t.ownerDocument:t.document)||window.document).documentElement}function D(t){return"html"===O(t)?t:t.assignedSlot||t.parentNode||(k(t)?t.host:null)||L(t)}function I(t){return T(t)&&"fixed"!==W(t).position?t.offsetParent:null}function P(t){for(var n=x(t),e=I(t);e&&z(e)&&"static"===W(e).position;)e=I(e);return e&&("html"===O(e)||"body"===O(e)&&"static"===W(e).position)?n:e||function(t){var n=/firefox/i.test(E());if(/Trident/i.test(E())&&T(t)&&"fixed"===W(t).position)return null;var e=D(t);for(k(e)&&(e=e.host);T(e)&&["html","body"].indexOf(O(e))<0;){var i=W(e);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||n&&"filter"===i.willChange||n&&i.filter&&"none"!==i.filter)return e;e=e.parentNode}return null}(t)||n}function N(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function V(t,n,e){return B(t,M(n,e))}function F(t){return Object.assign({},{top:0,right:0,bottom:0,left:0},t)}function $(t,n){return n.reduce((function(n,e){return n[e]=t,n}),{})}var X={name:"arrow",enabled:!0,phase:"main",fn:function(t){var n,e=t.state,i=t.name,o=t.options,r=e.elements.arrow,u=e.modifiersData.popperOffsets,a=S(e.placement),l=N(a),v=[d,s].indexOf(a)>=0?"height":"width";if(r&&u){var h=function(t,n){return F("number"!=typeof(t="function"==typeof t?t(Object.assign({},n.rects,{placement:n.placement})):t)?t:$(t,p))}(o.padding,e),m=q(r),b="y"===l?c:d,y="y"===l?f:s,g=e.rects.reference[v]+e.rects.reference[l]-u[l]-e.rects.popper[v],w=u[l]-e.rects.reference[l],O=P(r),x=O?"y"===l?O.clientHeight||0:O.clientWidth||0:0,j=g/2-w/2,T=h[b],k=x-m[v]-h[y],C=x/2-m[v]/2+j,B=V(T,C,k),M=l;e.modifiersData[i]=((n={})[M]=B,n.centerOffset=B-C,n)}},effect:function(t){var n=t.state,e=t.options.element,i=void 0===e?"[data-popper-arrow]":e;null!=i&&("string"!=typeof i||(i=n.elements.popper.querySelector(i)))&&U(n.elements.popper,i)&&(n.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Y(t){return t.split("-")[1]}var J={top:"auto",right:"auto",bottom:"auto",left:"auto"};function _(t){var n,e=t.popper,i=t.popperRect,o=t.placement,r=t.variation,u=t.offsets,a=t.position,l=t.gpuAcceleration,p=t.adaptive,v=t.roundOffsets,m=t.isFixed,b=u.x,y=void 0===b?0:b,g=u.y,w=void 0===g?0:g,O="function"==typeof v?v({x:y,y:w}):{x:y,y:w};y=O.x,w=O.y;var j=u.hasOwnProperty("x"),T=u.hasOwnProperty("y"),k=d,C=c,S=window;if(p){var B=P(e),M="clientHeight",E="clientWidth";if(B===x(e)&&"static"!==W(B=L(e)).position&&"absolute"===a&&(M="scrollHeight",E="scrollWidth"),o===c||(o===d||o===s)&&r===h)C=f,w-=(m&&B===S&&S.visualViewport?S.visualViewport.height:B[M])-i.height,w*=l?1:-1;if(o===d||(o===c||o===f)&&r===h)k=s,y-=(m&&B===S&&S.visualViewport?S.visualViewport.width:B[E])-i.width,y*=l?1:-1}var R,H=Object.assign({position:a},p&&J),q=!0===v?function(t,n){var e=t.x,i=t.y,o=n.devicePixelRatio||1;return{x:A(e*o)/o||0,y:A(i*o)/o||0}}({x:y,y:w},x(e)):{x:y,y:w};return y=q.x,w=q.y,l?Object.assign({},H,((R={})[C]=T?"0":"",R[k]=j?"0":"",R.transform=(S.devicePixelRatio||1)<=1?"translate("+y+"px, "+w+"px)":"translate3d("+y+"px, "+w+"px, 0)",R)):Object.assign({},H,((n={})[C]=T?w+"px":"",n[k]=j?y+"px":"",n.transform="",n))}var G={passive:!0};var K={left:"right",right:"left",bottom:"top",top:"bottom"};function Q(t){return t.replace(/left|right|bottom|top/g,(function(t){return K[t]}))}var Z={start:"end",end:"start"};function tt(t){return t.replace(/start|end/g,(function(t){return Z[t]}))}function nt(t){var n=x(t);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function et(t){return H(L(t)).left+nt(t).scrollLeft}function it(t){var n=W(t),e=n.overflow,i=n.overflowX,o=n.overflowY;return/auto|scroll|overlay|hidden/.test(e+o+i)}function ot(t){return["html","body","#document"].indexOf(O(t))>=0?t.ownerDocument.body:T(t)&&it(t)?t:ot(D(t))}function rt(t,n){var e;void 0===n&&(n=[]);var i=ot(t),o=i===(null==(e=t.ownerDocument)?void 0:e.body),r=x(i),u=o?[r].concat(r.visualViewport||[],it(i)?i:[]):i,a=n.concat(u);return o?a:a.concat(rt(D(u)))}function ut(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function at(t,n,e){return n===m?ut(function(t,n){var e=x(t),i=L(t),o=e.visualViewport,r=i.clientWidth,u=i.clientHeight,a=0,c=0;if(o){r=o.width,u=o.height;var f=R();(f||!f&&"fixed"===n)&&(a=o.offsetLeft,c=o.offsetTop)}return{width:r,height:u,x:a+et(t),y:c}}(t,e)):j(n)?function(t,n){var e=H(t,!1,"fixed"===n);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}(n,e):ut(function(t){var n,e=L(t),i=nt(t),o=null==(n=t.ownerDocument)?void 0:n.body,r=B(e.scrollWidth,e.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),u=B(e.scrollHeight,e.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-i.scrollLeft+et(t),c=-i.scrollTop;return"rtl"===W(o||e).direction&&(a+=B(e.clientWidth,o?o.clientWidth:0)-r),{width:r,height:u,x:a,y:c}}(L(t)))}function ct(t,n,e,i){var o="clippingParents"===n?function(t){var n=rt(D(t)),e=["absolute","fixed"].indexOf(W(t).position)>=0&&T(t)?P(t):t;return j(e)?n.filter((function(t){return j(t)&&U(t,e)&&"body"!==O(t)})):[]}(t):[].concat(n),r=[].concat(o,[e]),u=r[0],a=r.reduce((function(n,e){var o=at(t,e,i);return n.top=B(o.top,n.top),n.right=M(o.right,n.right),n.bottom=M(o.bottom,n.bottom),n.left=B(o.left,n.left),n}),at(t,u,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ft(t){var n,e=t.reference,i=t.element,o=t.placement,r=o?S(o):null,u=o?Y(o):null,a=e.x+e.width/2-i.width/2,l=e.y+e.height/2-i.height/2;switch(r){case c:n={x:a,y:e.y-i.height};break;case f:n={x:a,y:e.y+e.height};break;case s:n={x:e.x+e.width,y:l};break;case d:n={x:e.x-i.width,y:l};break;default:n={x:e.x,y:e.y}}var p=r?N(r):null;if(null!=p){var m="y"===p?"height":"width";switch(u){case v:n[p]=n[p]-(e[m]/2-i[m]/2);break;case h:n[p]=n[p]+(e[m]/2-i[m]/2)}}return n}function st(t,n){void 0===n&&(n={});var e=n,i=e.placement,o=void 0===i?t.placement:i,r=e.strategy,u=void 0===r?t.strategy:r,a=e.boundary,d=void 0===a?"clippingParents":a,l=e.rootBoundary,v=void 0===l?m:l,h=e.elementContext,y=void 0===h?b:h,g=e.altBoundary,w=void 0!==g&&g,O=e.padding,x=void 0===O?0:O,T=F("number"!=typeof x?x:$(x,p)),k=y===b?"reference":b,C=t.rects.popper,S=t.elements[w?k:y],B=ct(j(S)?S:S.contextElement||L(t.elements.popper),d,v,u),M=H(t.elements.reference),A=ft({reference:M,element:C,strategy:"absolute",placement:o}),E=ut(Object.assign({},C,A)),R=y===b?E:M,q={top:B.top-R.top+T.top,bottom:R.bottom-B.bottom+T.bottom,left:B.left-R.left+T.left,right:R.right-B.right+T.right},U=t.modifiersData.offset;if(y===b&&U){var W=U[o];Object.keys(q).forEach((function(t){var n=[s,f].indexOf(t)>=0?1:-1,e=[c,f].indexOf(t)>=0?"y":"x";q[t]+=W[e]*n}))}return q}function dt(t,n){void 0===n&&(n={});var e=n,i=e.placement,o=e.boundary,r=e.rootBoundary,u=e.padding,a=e.flipVariations,c=e.allowedAutoPlacements,f=void 0===c?g:c,s=Y(i),d=s?a?y:y.filter((function(t){return Y(t)===s})):p,l=d.filter((function(t){return f.indexOf(t)>=0}));0===l.length&&(l=d);var v=l.reduce((function(n,e){return n[e]=st(t,{placement:e,boundary:o,rootBoundary:r,padding:u})[S(e)],n}),{});return Object.keys(v).sort((function(t,n){return v[t]-v[n]}))}var lt={name:"flip",enabled:!0,phase:"main",fn:function(t){var n=t.state,e=t.options,i=t.name;if(!n.modifiersData[i]._skip){for(var o=e.mainAxis,r=void 0===o||o,u=e.altAxis,a=void 0===u||u,p=e.fallbackPlacements,h=e.padding,m=e.boundary,b=e.rootBoundary,y=e.altBoundary,g=e.flipVariations,w=void 0===g||g,O=e.allowedAutoPlacements,x=n.options.placement,j=S(x),T=p||(j===x||!w?[Q(x)]:function(t){if(S(t)===l)return[];var n=Q(t);return[tt(t),n,tt(n)]}(x)),k=[x].concat(T).reduce((function(t,e){return t.concat(S(e)===l?dt(n,{placement:e,boundary:m,rootBoundary:b,padding:h,flipVariations:w,allowedAutoPlacements:O}):e)}),[]),C=n.rects.reference,B=n.rects.popper,M=new Map,A=!0,E=k[0],R=0;R<k.length;R++){var H=k[R],q=S(H),U=Y(H)===v,W=[c,f].indexOf(q)>=0,z=W?"width":"height",L=st(n,{placement:H,boundary:m,rootBoundary:b,altBoundary:y,padding:h}),D=W?U?s:d:U?f:c;C[z]>B[z]&&(D=Q(D));var I=Q(D),P=[];if(r&&P.push(L[q]<=0),a&&P.push(L[D]<=0,L[I]<=0),P.every((function(t){return t}))){E=H,A=!1;break}M.set(H,P)}if(A)for(var N=function(t){var n=k.find((function(n){var e=M.get(n);if(e)return e.slice(0,t).every((function(t){return t}))}));if(n)return E=n,"break"},V=w?3:1;V>0;V--){if("break"===N(V))break}n.placement!==E&&(n.modifiersData[i]._skip=!0,n.placement=E,n.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function pt(t,n,e){return void 0===e&&(e={x:0,y:0}),{top:t.top-n.height-e.y,right:t.right-n.width+e.x,bottom:t.bottom-n.height+e.y,left:t.left-n.width-e.x}}function vt(t){return[c,s,f,d].some((function(n){return t[n]>=0}))}var ht={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(t){var n=t.state,e=t.options,i=t.name,o=e.offset,r=void 0===o?[0,0]:o,u=g.reduce((function(t,e){return t[e]=function(t,n,e){var i=S(t),o=[d,c].indexOf(i)>=0?-1:1,r="function"==typeof e?e(Object.assign({},n,{placement:t})):e,u=r[0],a=r[1];return u=u||0,a=(a||0)*o,[d,s].indexOf(i)>=0?{x:a,y:u}:{x:u,y:a}}(e,n.rects,r),t}),{}),a=u[n.placement],f=a.x,l=a.y;null!=n.modifiersData.popperOffsets&&(n.modifiersData.popperOffsets.x+=f,n.modifiersData.popperOffsets.y+=l),n.modifiersData[i]=u}};var mt={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var n=t.state,e=t.options,i=t.name,o=e.mainAxis,r=void 0===o||o,u=e.altAxis,a=void 0!==u&&u,l=e.boundary,p=e.rootBoundary,h=e.altBoundary,m=e.padding,b=e.tether,y=void 0===b||b,g=e.tetherOffset,w=void 0===g?0:g,O=st(n,{boundary:l,rootBoundary:p,padding:m,altBoundary:h}),x=S(n.placement),j=Y(n.placement),T=!j,k=N(x),C="x"===k?"y":"x",A=n.modifiersData.popperOffsets,E=n.rects.reference,R=n.rects.popper,H="function"==typeof w?w(Object.assign({},n.rects,{placement:n.placement})):w,U="number"==typeof H?{mainAxis:H,altAxis:H}:Object.assign({mainAxis:0,altAxis:0},H),W=n.modifiersData.offset?n.modifiersData.offset[n.placement]:null,z={x:0,y:0};if(A){if(r){var L,D="y"===k?c:d,I="y"===k?f:s,F="y"===k?"height":"width",$=A[k],X=$+O[D],J=$-O[I],_=y?-R[F]/2:0,G=j===v?E[F]:R[F],K=j===v?-R[F]:-E[F],Q=n.elements.arrow,Z=y&&Q?q(Q):{width:0,height:0},tt=n.modifiersData["arrow#persistent"]?n.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},nt=tt[D],et=tt[I],it=V(0,E[F],Z[F]),ot=T?E[F]/2-_-it-nt-U.mainAxis:G-it-nt-U.mainAxis,rt=T?-E[F]/2+_+it+et+U.mainAxis:K+it+et+U.mainAxis,ut=n.elements.arrow&&P(n.elements.arrow),at=ut?"y"===k?ut.clientTop||0:ut.clientLeft||0:0,ct=null!=(L=null==W?void 0:W[k])?L:0,ft=$+rt-ct,dt=V(y?M(X,$+ot-ct-at):X,$,y?B(J,ft):J);A[k]=dt,z[k]=dt-$}if(a){var lt,pt="x"===k?c:d,vt="x"===k?f:s,ht=A[C],mt="y"===C?"height":"width",bt=ht+O[pt],yt=ht-O[vt],gt=-1!==[c,d].indexOf(x),wt=null!=(lt=null==W?void 0:W[C])?lt:0,Ot=gt?bt:ht-E[mt]-R[mt]-wt+U.altAxis,xt=gt?ht+E[mt]+R[mt]-wt-U.altAxis:yt,jt=y&>?function(t,n,e){var i=V(t,n,e);return i>e?e:i}(Ot,ht,xt):V(y?Ot:bt,ht,y?xt:yt);A[C]=jt,z[C]=jt-ht}n.modifiersData[i]=z}},requiresIfExists:["offset"]};function bt(t,n,e){void 0===e&&(e=!1);var i,o,r=T(n),u=T(n)&&function(t){var n=t.getBoundingClientRect(),e=A(n.width)/t.offsetWidth||1,i=A(n.height)/t.offsetHeight||1;return 1!==e||1!==i}(n),a=L(n),c=H(t,u,e),f={scrollLeft:0,scrollTop:0},s={x:0,y:0};return(r||!r&&!e)&&(("body"!==O(n)||it(a))&&(f=(i=n)!==x(i)&&T(i)?{scrollLeft:(o=i).scrollLeft,scrollTop:o.scrollTop}:nt(i)),T(n)?((s=H(n,!0)).x+=n.clientLeft,s.y+=n.clientTop):a&&(s.x=et(a))),{x:c.left+f.scrollLeft-s.x,y:c.top+f.scrollTop-s.y,width:c.width,height:c.height}}function yt(t){var n=new Map,e=new Set,i=[];function o(t){e.add(t.name),[].concat(t.requires||[],t.requiresIfExists||[]).forEach((function(t){if(!e.has(t)){var i=n.get(t);i&&o(i)}})),i.push(t)}return t.forEach((function(t){n.set(t.name,t)})),t.forEach((function(t){e.has(t.name)||o(t)})),i}var gt={placement:"bottom",modifiers:[],strategy:"absolute"};function wt(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];return!n.some((function(t){return!(t&&"function"==typeof t.getBoundingClientRect)}))}function Ot(t){void 0===t&&(t={});var n=t,e=n.defaultModifiers,i=void 0===e?[]:e,o=n.defaultOptions,r=void 0===o?gt:o;return function(t,n,e){void 0===e&&(e=r);var o,u,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},gt,r),modifiersData:{},elements:{reference:t,popper:n},attributes:{},styles:{}},c=[],f=!1,s={state:a,setOptions:function(e){var o="function"==typeof e?e(a.options):e;d(),a.options=Object.assign({},r,a.options,o),a.scrollParents={reference:j(t)?rt(t):t.contextElement?rt(t.contextElement):[],popper:rt(n)};var u,f,l=function(t){var n=yt(t);return w.reduce((function(t,e){return t.concat(n.filter((function(t){return t.phase===e})))}),[])}((u=[].concat(i,a.options.modifiers),f=u.reduce((function(t,n){var e=t[n.name];return t[n.name]=e?Object.assign({},e,n,{options:Object.assign({},e.options,n.options),data:Object.assign({},e.data,n.data)}):n,t}),{}),Object.keys(f).map((function(t){return f[t]}))));return a.orderedModifiers=l.filter((function(t){return t.enabled})),a.orderedModifiers.forEach((function(t){var n=t.name,e=t.options,i=void 0===e?{}:e,o=t.effect;if("function"==typeof o){var r=o({state:a,name:n,instance:s,options:i}),u=function(){};c.push(r||u)}})),s.update()},forceUpdate:function(){if(!f){var t=a.elements,n=t.reference,e=t.popper;if(wt(n,e)){a.rects={reference:bt(n,P(e),"fixed"===a.options.strategy),popper:q(e)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(t){return a.modifiersData[t.name]=Object.assign({},t.data)}));for(var i=0;i<a.orderedModifiers.length;i++)if(!0!==a.reset){var o=a.orderedModifiers[i],r=o.fn,u=o.options,c=void 0===u?{}:u,d=o.name;"function"==typeof r&&(a=r({state:a,options:c,name:d,instance:s})||a)}else a.reset=!1,i=-1}}},update:(o=function(){return new Promise((function(t){s.forceUpdate(),t(a)}))},function(){return u||(u=new Promise((function(t){Promise.resolve().then((function(){u=void 0,t(o())}))}))),u}),destroy:function(){d(),f=!0}};if(!wt(t,n))return s;function d(){c.forEach((function(t){return t()})),c=[]}return s.setOptions(e).then((function(t){!f&&e.onFirstUpdate&&e.onFirstUpdate(t)})),s}}var xt=Ot({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(t){var n=t.state,e=t.instance,i=t.options,o=i.scroll,r=void 0===o||o,u=i.resize,a=void 0===u||u,c=x(n.elements.popper),f=[].concat(n.scrollParents.reference,n.scrollParents.popper);return r&&f.forEach((function(t){t.addEventListener("scroll",e.update,G)})),a&&c.addEventListener("resize",e.update,G),function(){r&&f.forEach((function(t){t.removeEventListener("scroll",e.update,G)})),a&&c.removeEventListener("resize",e.update,G)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(t){var n=t.state,e=t.name;n.modifiersData[e]=ft({reference:n.rects.reference,element:n.rects.popper,strategy:"absolute",placement:n.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(t){var n=t.state,e=t.options,i=e.gpuAcceleration,o=void 0===i||i,r=e.adaptive,u=void 0===r||r,a=e.roundOffsets,c=void 0===a||a,f={placement:S(n.placement),variation:Y(n.placement),popper:n.elements.popper,popperRect:n.rects.popper,gpuAcceleration:o,isFixed:"fixed"===n.options.strategy};null!=n.modifiersData.popperOffsets&&(n.styles.popper=Object.assign({},n.styles.popper,_(Object.assign({},f,{offsets:n.modifiersData.popperOffsets,position:n.options.strategy,adaptive:u,roundOffsets:c})))),null!=n.modifiersData.arrow&&(n.styles.arrow=Object.assign({},n.styles.arrow,_(Object.assign({},f,{offsets:n.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),n.attributes.popper=Object.assign({},n.attributes.popper,{"data-popper-placement":n.placement})},data:{}},C,ht,lt,mt,X,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(t){var n=t.state,e=t.name,i=n.rects.reference,o=n.rects.popper,r=n.modifiersData.preventOverflow,u=st(n,{elementContext:"reference"}),a=st(n,{altBoundary:!0}),c=pt(u,i),f=pt(a,o,r),s=vt(c),d=vt(f);n.modifiersData[e]={referenceClippingOffsets:c,popperEscapeOffsets:f,isReferenceHidden:s,hasPopperEscaped:d},n.attributes.popper=Object.assign({},n.attributes.popper,{"data-popper-reference-hidden":s,"data-popper-escaped":d})}}]}),jt='<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>',Tt="tippy-content",kt="tippy-arrow",Ct="tippy-svg-arrow",St={passive:!0,capture:!0},Bt=function(){return document.body};function Mt(t,n,e){if(Array.isArray(t)){var i=t[n];return null==i?Array.isArray(e)?e[n]:e:i}return t}function At(t,n){var e={}.toString.call(t);return 0===e.indexOf("[object")&&e.indexOf(n+"]")>-1}function Et(t,n){return"function"==typeof t?t.apply(void 0,n):t}function Rt(t,n){return 0===n?t:function(i){clearTimeout(e),e=setTimeout((function(){t(i)}),n)};var e}function Ht(t){return[].concat(t)}function qt(t,n){-1===t.indexOf(n)&&t.push(n)}function Ut(t){return[].slice.call(t)}function Wt(t){return Object.keys(t).reduce((function(n,e){return void 0!==t[e]&&(n[e]=t[e]),n}),{})}function zt(){return document.createElement("div")}function Lt(t){return["Element","Fragment"].some((function(n){return At(t,n)}))}function Dt(t){return At(t,"MouseEvent")}function It(t){return Lt(t)?[t]:function(t){return At(t,"NodeList")}(t)?Ut(t):Array.isArray(t)?t:Ut(document.querySelectorAll(t))}function Pt(t,n){t.forEach((function(t){t&&(t.style.transitionDuration=n+"ms")}))}function Nt(t,n){t.forEach((function(t){t&&t.setAttribute("data-state",n)}))}function Vt(t){var n,e=Ht(t)[0];return null!=e&&null!=(n=e.ownerDocument)&&n.body?e.ownerDocument:document}function Ft(t,n,e){var i=n+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(n){t[i](n,e)}))}function $t(t,n){for(var e=n;e;){var i;if(t.contains(e))return!0;e=null==e.getRootNode||null==(i=e.getRootNode())?void 0:i.host}return!1}var Xt={isTouch:!1},Yt=0;function Jt(){Xt.isTouch||(Xt.isTouch=!0,window.performance&&document.addEventListener("mousemove",_t))}function _t(){var t=performance.now();t-Yt<20&&(Xt.isTouch=!1,document.removeEventListener("mousemove",_t)),Yt=t}function Gt(){var t,n=document.activeElement;if((t=n)&&t._tippy&&t._tippy.reference===t){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}var Kt=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto,Qt=Object.assign({appendTo:Bt,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},{animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),Zt=Object.keys(Qt);function tn(t){var n=(t.plugins||[]).reduce((function(n,e){var i,o=e.name,r=e.defaultValue;o&&(n[o]=void 0!==t[o]?t[o]:null!=(i=Qt[o])?i:r);return n}),{});return Object.assign({},t,n)}function nn(t,n){var e=Object.assign({},n,{content:Et(n.content,[t])},n.ignoreAttributes?{}:function(t,n){return(n?Object.keys(tn(Object.assign({},Qt,{plugins:n}))):Zt).reduce((function(n,e){var i=(t.getAttribute("data-tippy-"+e)||"").trim();if(!i)return n;if("content"===e)n[e]=i;else try{n[e]=JSON.parse(i)}catch(t){n[e]=i}return n}),{})}(t,n.plugins));return e.aria=Object.assign({},Qt.aria,e.aria),e.aria={expanded:"auto"===e.aria.expanded?n.interactive:e.aria.expanded,content:"auto"===e.aria.content?n.interactive?null:"describedby":e.aria.content},e}function en(t,n){t.innerHTML=n}function on(t){var n=zt();return!0===t?n.className=kt:(n.className=Ct,Lt(t)?n.appendChild(t):en(n,t)),n}function rn(t,n){Lt(n.content)?(en(t,""),t.appendChild(n.content)):"function"!=typeof n.content&&(n.allowHTML?en(t,n.content):t.textContent=n.content)}function un(t){var n=t.firstElementChild,e=Ut(n.children);return{box:n,content:e.find((function(t){return t.classList.contains(Tt)})),arrow:e.find((function(t){return t.classList.contains(kt)||t.classList.contains(Ct)})),backdrop:e.find((function(t){return t.classList.contains("tippy-backdrop")}))}}function an(t){var n=zt(),e=zt();e.className="tippy-box",e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=zt();function o(e,i){var o=un(n),r=o.box,u=o.content,a=o.arrow;i.theme?r.setAttribute("data-theme",i.theme):r.removeAttribute("data-theme"),"string"==typeof i.animation?r.setAttribute("data-animation",i.animation):r.removeAttribute("data-animation"),i.inertia?r.setAttribute("data-inertia",""):r.removeAttribute("data-inertia"),r.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?r.setAttribute("role",i.role):r.removeAttribute("role"),e.content===i.content&&e.allowHTML===i.allowHTML||rn(u,t.props),i.arrow?a?e.arrow!==i.arrow&&(r.removeChild(a),r.appendChild(on(i.arrow))):r.appendChild(on(i.arrow)):a&&r.removeChild(a)}return i.className=Tt,i.setAttribute("data-state","hidden"),rn(i,t.props),n.appendChild(e),e.appendChild(i),o(t.props,t.props),{popper:n,onUpdate:o}}an.$$tippy=!0;var cn=1,fn=[],sn=[];function dn(t,n){var e,i,o,r,u,a,c,f,s=nn(t,Object.assign({},Qt,tn(Wt(n)))),d=!1,l=!1,p=!1,v=!1,h=[],m=Rt(Y,s.interactiveDebounce),b=cn++,y=(f=s.plugins).filter((function(t,n){return f.indexOf(t)===n})),g={id:b,reference:t,popper:zt(),popperInstance:null,props:s,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:y,clearDelayTimeouts:function(){clearTimeout(e),clearTimeout(i),cancelAnimationFrame(o)},setProps:function(n){if(g.state.isDestroyed)return;H("onBeforeUpdate",[g,n]),$();var e=g.props,i=nn(t,Object.assign({},e,Wt(n),{ignoreAttributes:!0}));g.props=i,F(),e.interactiveDebounce!==i.interactiveDebounce&&(W(),m=Rt(Y,i.interactiveDebounce));e.triggerTarget&&!i.triggerTarget?Ht(e.triggerTarget).forEach((function(t){t.removeAttribute("aria-expanded")})):i.triggerTarget&&t.removeAttribute("aria-expanded");U(),R(),x&&x(e,i);g.popperInstance&&(K(),Z().forEach((function(t){requestAnimationFrame(t._tippy.popperInstance.forceUpdate)})));H("onAfterUpdate",[g,n])},setContent:function(t){g.setProps({content:t})},show:function(){var t=g.state.isVisible,n=g.state.isDestroyed,e=!g.state.isEnabled,i=Xt.isTouch&&!g.props.touch,o=Mt(g.props.duration,0,Qt.duration);if(t||n||e||i)return;if(B().hasAttribute("disabled"))return;if(H("onShow",[g],!1),!1===g.props.onShow(g))return;g.state.isVisible=!0,S()&&(O.style.visibility="visible");R(),I(),g.state.isMounted||(O.style.transition="none");if(S()){var r=A();Pt([r.box,r.content],0)}a=function(){var t;if(g.state.isVisible&&!v){if(v=!0,O.offsetHeight,O.style.transition=g.props.moveTransition,S()&&g.props.animation){var n=A(),e=n.box,i=n.content;Pt([e,i],o),Nt([e,i],"visible")}q(),U(),qt(sn,g),null==(t=g.popperInstance)||t.forceUpdate(),H("onMount",[g]),g.props.animation&&S()&&function(t,n){N(t,n)}(o,(function(){g.state.isShown=!0,H("onShown",[g])}))}},function(){var t,n=g.props.appendTo,e=B();t=g.props.interactive&&n===Bt||"parent"===n?e.parentNode:Et(n,[e]);t.contains(O)||t.appendChild(O);g.state.isMounted=!0,K()}()},hide:function(){var t=!g.state.isVisible,n=g.state.isDestroyed,e=!g.state.isEnabled,i=Mt(g.props.duration,1,Qt.duration);if(t||n||e)return;if(H("onHide",[g],!1),!1===g.props.onHide(g))return;g.state.isVisible=!1,g.state.isShown=!1,v=!1,d=!1,S()&&(O.style.visibility="hidden");if(W(),P(),R(!0),S()){var o=A(),r=o.box,u=o.content;g.props.animation&&(Pt([r,u],i),Nt([r,u],"hidden"))}q(),U(),g.props.animation?S()&&function(t,n){N(t,(function(){!g.state.isVisible&&O.parentNode&&O.parentNode.contains(O)&&n()}))}(i,g.unmount):g.unmount()},hideWithInteractivity:function(t){M().addEventListener("mousemove",m),qt(fn,m),m(t)},enable:function(){g.state.isEnabled=!0},disable:function(){g.hide(),g.state.isEnabled=!1},unmount:function(){g.state.isVisible&&g.hide();if(!g.state.isMounted)return;Q(),Z().forEach((function(t){t._tippy.unmount()})),O.parentNode&&O.parentNode.removeChild(O);sn=sn.filter((function(t){return t!==g})),g.state.isMounted=!1,H("onHidden",[g])},destroy:function(){if(g.state.isDestroyed)return;g.clearDelayTimeouts(),g.unmount(),$(),delete t._tippy,g.state.isDestroyed=!0,H("onDestroy",[g])}};if(!s.render)return g;var w=s.render(g),O=w.popper,x=w.onUpdate;O.setAttribute("data-tippy-root",""),O.id="tippy-"+g.id,g.popper=O,t._tippy=g,O._tippy=g;var j=y.map((function(t){return t.fn(g)})),T=t.hasAttribute("aria-expanded");return F(),U(),R(),H("onCreate",[g]),s.showOnCreate&&tt(),O.addEventListener("mouseenter",(function(){g.props.interactive&&g.state.isVisible&&g.clearDelayTimeouts()})),O.addEventListener("mouseleave",(function(){g.props.interactive&&g.props.trigger.indexOf("mouseenter")>=0&&M().addEventListener("mousemove",m)})),g;function k(){var t=g.props.touch;return Array.isArray(t)?t:[t,0]}function C(){return"hold"===k()[0]}function S(){var t;return!(null==(t=g.props.render)||!t.$$tippy)}function B(){return c||t}function M(){var t=B().parentNode;return t?Vt(t):document}function A(){return un(O)}function E(t){return g.state.isMounted&&!g.state.isVisible||Xt.isTouch||r&&"focus"===r.type?0:Mt(g.props.delay,t?0:1,Qt.delay)}function R(t){void 0===t&&(t=!1),O.style.pointerEvents=g.props.interactive&&!t?"":"none",O.style.zIndex=""+g.props.zIndex}function H(t,n,e){var i;(void 0===e&&(e=!0),j.forEach((function(e){e[t]&&e[t].apply(e,n)})),e)&&(i=g.props)[t].apply(i,n)}function q(){var n=g.props.aria;if(n.content){var e="aria-"+n.content,i=O.id;Ht(g.props.triggerTarget||t).forEach((function(t){var n=t.getAttribute(e);if(g.state.isVisible)t.setAttribute(e,n?n+" "+i:i);else{var o=n&&n.replace(i,"").trim();o?t.setAttribute(e,o):t.removeAttribute(e)}}))}}function U(){!T&&g.props.aria.expanded&&Ht(g.props.triggerTarget||t).forEach((function(t){g.props.interactive?t.setAttribute("aria-expanded",g.state.isVisible&&t===B()?"true":"false"):t.removeAttribute("aria-expanded")}))}function W(){M().removeEventListener("mousemove",m),fn=fn.filter((function(t){return t!==m}))}function z(n){if(!Xt.isTouch||!p&&"mousedown"!==n.type){var e=n.composedPath&&n.composedPath()[0]||n.target;if(!g.props.interactive||!$t(O,e)){if(Ht(g.props.triggerTarget||t).some((function(t){return $t(t,e)}))){if(Xt.isTouch)return;if(g.state.isVisible&&g.props.trigger.indexOf("click")>=0)return}else H("onClickOutside",[g,n]);!0===g.props.hideOnClick&&(g.clearDelayTimeouts(),g.hide(),l=!0,setTimeout((function(){l=!1})),g.state.isMounted||P())}}}function L(){p=!0}function D(){p=!1}function I(){var t=M();t.addEventListener("mousedown",z,!0),t.addEventListener("touchend",z,St),t.addEventListener("touchstart",D,St),t.addEventListener("touchmove",L,St)}function P(){var t=M();t.removeEventListener("mousedown",z,!0),t.removeEventListener("touchend",z,St),t.removeEventListener("touchstart",D,St),t.removeEventListener("touchmove",L,St)}function N(t,n){var e=A().box;function i(t){t.target===e&&(Ft(e,"remove",i),n())}if(0===t)return n();Ft(e,"remove",u),Ft(e,"add",i),u=i}function V(n,e,i){void 0===i&&(i=!1),Ht(g.props.triggerTarget||t).forEach((function(t){t.addEventListener(n,e,i),h.push({node:t,eventType:n,handler:e,options:i})}))}function F(){var t;C()&&(V("touchstart",X,{passive:!0}),V("touchend",J,{passive:!0})),(t=g.props.trigger,t.split(/\s+/).filter(Boolean)).forEach((function(t){if("manual"!==t)switch(V(t,X),t){case"mouseenter":V("mouseleave",J);break;case"focus":V(Kt?"focusout":"blur",_);break;case"focusin":V("focusout",_)}}))}function $(){h.forEach((function(t){var n=t.node,e=t.eventType,i=t.handler,o=t.options;n.removeEventListener(e,i,o)})),h=[]}function X(t){var n,e=!1;if(g.state.isEnabled&&!G(t)&&!l){var i="focus"===(null==(n=r)?void 0:n.type);r=t,c=t.currentTarget,U(),!g.state.isVisible&&Dt(t)&&fn.forEach((function(n){return n(t)})),"click"===t.type&&(g.props.trigger.indexOf("mouseenter")<0||d)&&!1!==g.props.hideOnClick&&g.state.isVisible?e=!0:tt(t),"click"===t.type&&(d=!e),e&&!i&&nt(t)}}function Y(t){var n=t.target,e=B().contains(n)||O.contains(n);if("mousemove"!==t.type||!e){var i=Z().concat(O).map((function(t){var n,e=null==(n=t._tippy.popperInstance)?void 0:n.state;return e?{popperRect:t.getBoundingClientRect(),popperState:e,props:s}:null})).filter(Boolean);(function(t,n){var e=n.clientX,i=n.clientY;return t.every((function(t){var n=t.popperRect,o=t.popperState,r=t.props.interactiveBorder,u=o.placement.split("-")[0],a=o.modifiersData.offset;if(!a)return!0;var c="bottom"===u?a.top.y:0,f="top"===u?a.bottom.y:0,s="right"===u?a.left.x:0,d="left"===u?a.right.x:0,l=n.top-i+c>r,p=i-n.bottom-f>r,v=n.left-e+s>r,h=e-n.right-d>r;return l||p||v||h}))})(i,t)&&(W(),nt(t))}}function J(t){G(t)||g.props.trigger.indexOf("click")>=0&&d||(g.props.interactive?g.hideWithInteractivity(t):nt(t))}function _(t){g.props.trigger.indexOf("focusin")<0&&t.target!==B()||g.props.interactive&&t.relatedTarget&&O.contains(t.relatedTarget)||nt(t)}function G(t){return!!Xt.isTouch&&C()!==t.type.indexOf("touch")>=0}function K(){Q();var n=g.props,e=n.popperOptions,i=n.placement,o=n.offset,r=n.getReferenceClientRect,u=n.moveTransition,c=S()?un(O).arrow:null,f=r?{getBoundingClientRect:r,contextElement:r.contextElement||B()}:t,s={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(t){var n=t.state;if(S()){var e=A().box;["placement","reference-hidden","escaped"].forEach((function(t){"placement"===t?e.setAttribute("data-placement",n.placement):n.attributes.popper["data-popper-"+t]?e.setAttribute("data-"+t,""):e.removeAttribute("data-"+t)})),n.attributes.popper={}}}},d=[{name:"offset",options:{offset:o}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!u}},s];S()&&c&&d.push({name:"arrow",options:{element:c,padding:3}}),d.push.apply(d,(null==e?void 0:e.modifiers)||[]),g.popperInstance=xt(f,O,Object.assign({},e,{placement:i,onFirstUpdate:a,modifiers:d}))}function Q(){g.popperInstance&&(g.popperInstance.destroy(),g.popperInstance=null)}function Z(){return Ut(O.querySelectorAll("[data-tippy-root]"))}function tt(t){g.clearDelayTimeouts(),t&&H("onTrigger",[g,t]),I();var n=E(!0),i=k(),o=i[0],r=i[1];Xt.isTouch&&"hold"===o&&r&&(n=r),n?e=setTimeout((function(){g.show()}),n):g.show()}function nt(t){if(g.clearDelayTimeouts(),H("onUntrigger",[g,t]),g.state.isVisible){if(!(g.props.trigger.indexOf("mouseenter")>=0&&g.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(t.type)>=0&&d)){var n=E(!1);n?i=setTimeout((function(){g.state.isVisible&&g.hide()}),n):o=requestAnimationFrame((function(){g.hide()}))}}else P()}}function ln(t,n){void 0===n&&(n={});var e=Qt.plugins.concat(n.plugins||[]);document.addEventListener("touchstart",Jt,St),window.addEventListener("blur",Gt);var i=Object.assign({},n,{plugins:e}),o=It(t).reduce((function(t,n){var e=n&&dn(n,i);return e&&t.push(e),t}),[]);return Lt(t)?o[0]:o}ln.defaultProps=Qt,ln.setDefaultProps=function(t){Object.keys(t).forEach((function(n){Qt[n]=t[n]}))},ln.currentInput=Xt;var pn=Object.assign({},C,{effect:function(t){var n=t.state,e={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,e.popper),n.styles=e,n.elements.arrow&&Object.assign(n.elements.arrow.style,e.arrow)}}),vn=function(t,n){var e;void 0===n&&(n={});var i,o=t,r=[],u=[],a=n.overrides,c=[],f=!1;function s(){u=o.map((function(t){return Ht(t.props.triggerTarget||t.reference)})).reduce((function(t,n){return t.concat(n)}),[])}function d(){r=o.map((function(t){return t.reference}))}function l(t){o.forEach((function(n){t?n.enable():n.disable()}))}function p(t){return o.map((function(n){var e=n.setProps;return n.setProps=function(o){e(o),n.reference===i&&t.setProps(o)},function(){n.setProps=e}}))}function v(t,n){var e=u.indexOf(n);if(n!==i){i=n;var c=(a||[]).concat("content").reduce((function(t,n){return t[n]=o[e].props[n],t}),{});t.setProps(Object.assign({},c,{getReferenceClientRect:"function"==typeof c.getReferenceClientRect?c.getReferenceClientRect:function(){var t;return null==(t=r[e])?void 0:t.getBoundingClientRect()}}))}}l(!1),d(),s();var h,m,b,y={fn:function(){return{onDestroy:function(){l(!0)},onHidden:function(){i=null},onClickOutside:function(t){t.props.showOnCreate&&!f&&(f=!0,i=null)},onShow:function(t){t.props.showOnCreate&&!f&&(f=!0,v(t,r[0]))},onTrigger:function(t,n){v(t,n.currentTarget)}}}},g=ln(zt(),Object.assign({},(h=n,m=["overrides"],b=Object.assign({},h),m.forEach((function(t){delete b[t]})),b),{plugins:[y].concat(n.plugins||[]),triggerTarget:u,popperOptions:Object.assign({},n.popperOptions,{modifiers:[].concat((null==(e=n.popperOptions)?void 0:e.modifiers)||[],[pn])})})),w=g.show;g.show=function(t){if(w(),!i&&null==t)return v(g,r[0]);if(!i||null!=t){if("number"==typeof t)return r[t]&&v(g,r[t]);if(o.indexOf(t)>=0){var n=t.reference;return v(g,n)}return r.indexOf(t)>=0?v(g,t):void 0}},g.showNext=function(){var t=r[0];if(!i)return g.show(0);var n=r.indexOf(i);g.show(r[n+1]||t)},g.showPrevious=function(){var t=r[r.length-1];if(!i)return g.show(t);var n=r.indexOf(i),e=r[n-1]||t;g.show(e)};var O=g.setProps;return g.setProps=function(t){a=t.overrides||a,O(t)},g.setInstances=function(t){l(!0),c.forEach((function(t){return t()})),o=t,l(!1),d(),s(),c=p(g),g.setProps({triggerTarget:u})},c=p(g),g},hn={clientX:0,clientY:0},mn=[];function bn(t){var n=t.clientX,e=t.clientY;hn={clientX:n,clientY:e}}var yn={name:"followCursor",defaultValue:!1,fn:function(t){var n=t.reference,e=Vt(t.props.triggerTarget||n),i=!1,o=!1,r=!0,u=t.props;function a(){return"initial"===t.props.followCursor&&t.state.isVisible}function c(){e.addEventListener("mousemove",d)}function f(){e.removeEventListener("mousemove",d)}function s(){i=!0,t.setProps({getReferenceClientRect:null}),i=!1}function d(e){var i=!e.target||n.contains(e.target),o=t.props.followCursor,r=e.clientX,u=e.clientY,a=n.getBoundingClientRect(),c=r-a.left,f=u-a.top;!i&&t.props.interactive||t.setProps({getReferenceClientRect:function(){var t=n.getBoundingClientRect(),e=r,i=u;"initial"===o&&(e=t.left+c,i=t.top+f);var a="horizontal"===o?t.top:i,s="vertical"===o?t.right:e,d="horizontal"===o?t.bottom:i,l="vertical"===o?t.left:e;return{width:s-l,height:d-a,top:a,right:s,bottom:d,left:l}}})}function l(){t.props.followCursor&&(mn.push({instance:t,doc:e}),function(t){t.addEventListener("mousemove",bn)}(e))}function p(){0===(mn=mn.filter((function(n){return n.instance!==t}))).filter((function(t){return t.doc===e})).length&&function(t){t.removeEventListener("mousemove",bn)}(e)}return{onCreate:l,onDestroy:p,onBeforeUpdate:function(){u=t.props},onAfterUpdate:function(n,e){var r=e.followCursor;i||void 0!==r&&u.followCursor!==r&&(p(),r?(l(),!t.state.isMounted||o||a()||c()):(f(),s()))},onMount:function(){t.props.followCursor&&!o&&(r&&(d(hn),r=!1),a()||c())},onTrigger:function(t,n){Dt(n)&&(hn={clientX:n.clientX,clientY:n.clientY}),o="focus"===n.type},onHidden:function(){t.props.followCursor&&(s(),f(),r=!0)}}}};ln.setDefaultProps({render:an});let gn=class extends o{static get styles(){return[i]}createRenderRoot(){return this}constructor(){super(),this.for=null,this.content="",this.size="small",this.duration=200,this.interactive=!1,this.placement="top",this.disabled=!1,this.distance=8,this.skidding=0,this.open=!1,this.trigger="mouseenter focus",this.allowHTML=!1,this.followCursor=!1,this.arrow="default",this.singleton=!1,this.enableRecursiveMode=!1,this.delay=0,this.maxWidth="auto",this.zIndex=9999,this.hideOnClick=!0,this.inertia=!1,this.interactiveBorder=2,this.enableVisibilityEffect=!1,this.enableTabClose=!1}firstUpdated(){this.attachTooltip();const t=this.for&&document.getElementById(this.for)||this.firstElementChild;this.visibilityManager=new a({host:this,target:t,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.open=!1,this.hideAllTooltips(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.open=!1,this.hideAllTooltips(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(t,n)=>this.emit(`nile-${t}`,n)})}refresh(){this.attachTooltip()}hasValidContent(){const t=this.content??this.getAttribute("data-tippy-content")??"";return"string"==typeof t&&t.trim().length>0}attachTooltip(){if(this.destroyTooltips(),this.disabled||!this.enableRecursiveMode&&!this.singleton&&!this.hasValidContent())return;const t={content:this.content||this.getAttribute("data-tippy-content")||void 0,placement:this.placement,trigger:this.trigger,offset:[this.skidding,this.distance],theme:"lite",animation:"fade",interactive:this.interactive,arrow:jt,duration:r(this.duration),allowHTML:this.allowHTML,delay:this.delay,maxWidth:this.maxWidth,zIndex:this.zIndex,hideOnClick:!1,inertia:this.inertia,interactiveBorder:this.interactiveBorder,appendTo:document.body,followCursor:u(this.followCursor),plugins:u(this.followCursor)?[yn]:[],onShow:t=>{this.open=!0;const n=t.popper.querySelector(".tippy-content");n&&(this.width&&(n.style.width=this.width),this.height&&(n.style.height=this.height,n.style.overflow="auto")),this.dispatchEvent(new CustomEvent("nile-show",{detail:{instance:t,target:t.reference}})),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{open:!0,instance:t,target:t.reference}}))},onHide:t=>{this.open=!1,this.dispatchEvent(new CustomEvent("nile-hide",{detail:{instance:t,target:t.reference}})),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{open:!1,instance:t,target:t.reference}}))}};if(this.for){if(this.singleton&&!this.for.startsWith("#")&&!document.getElementById(this.for)){const n=Array.from(document.querySelectorAll(`.${this.for}`));if(n.length>0)return this.tooltipInstances=n.map((n=>{const e=ln(n,{...t,content:n.getAttribute("content")||this.content});return e.popper.querySelector(".tippy-box")?.classList.add(this.size),e})),this.singletonInstance=vn(this.tooltipInstances,{delay:[75,0],arrow:jt,moveTransition:"transform 0.15s ease-out"}),void(this.open&&queueMicrotask((()=>this.singletonInstance?.show())))}const n=document.getElementById(this.for);if(this.singleton&&n){const e=Array.from(n.querySelectorAll("[content]"));if(e.length>0)return this.tooltipInstances=e.map((n=>{const e=ln(n,{...t,content:n.getAttribute("content")||this.content});return e.popper.querySelector(".tippy-box")?.classList.add(this.size),e})),this.singletonInstance=vn(this.tooltipInstances,{delay:[75,0],arrow:jt,moveTransition:"transform 0.15s ease-out"}),void(this.open&&queueMicrotask((()=>this.singletonInstance?.show())))}if(this.targetEl=document.getElementById(this.for),!this.targetEl)return;this.id||(this.generatedId=`nile-tooltip-${Math.random().toString(36).slice(2,9)}`,this.id=this.generatedId),this.prevDescribedby=this.targetEl.getAttribute("aria-describedby");const e=this.prevDescribedby?`${this.prevDescribedby} ${this.id}`:this.id;return this.targetEl.setAttribute("aria-describedby",e),this.singleInstance=ln(this.targetEl,t),this.size&&this.singleInstance.popper.querySelector(".tippy-box")?.classList.add(this.size),void(this.open&&queueMicrotask((()=>this.singleInstance?.show())))}if(this.enableRecursiveMode){const n=Array.from(this.querySelectorAll("[content]")).filter((t=>{const n=t.getAttribute("content");return null!==n&&n.trim().length>0}));n.length>0&&(this.tooltipInstances=n.map((n=>{const e=n,i=e.getAttribute("content")||this.content,o=ln(e,{...t,content:i});return o.popper.querySelector(".tippy-box")?.classList.add(this.size),o})),this.singleton&&this.tooltipInstances.length>1&&(this.singletonInstance=vn(this.tooltipInstances,{delay:[75,0],arrow:jt,moveTransition:"transform 0.15s ease-out"})),this.open&&(this.singletonInstance?this.singletonInstance.show():this.tooltipInstances.forEach((t=>t.show()))))}else{const n=this.firstElementChild;if(n){const e=n.getAttribute("content")||this.content,i=ln(n,{...t,content:e});i.popper.querySelector(".tippy-box")?.classList.add(this.size),this.tooltipInstances=[i],this.open&&i.show()}}}destroyTooltips(){if(this.tooltipInstances?.forEach((t=>t.destroy())),this.singleInstance?.destroy(),this.singletonInstance?.destroy(),this.tooltipInstances=void 0,this.singleInstance=void 0,this.singletonInstance=void 0,this.targetEl&&this.id){const t=this.targetEl.getAttribute("aria-describedby")?.split(" ").filter((t=>t!==this.id)).join(" ").trim();t?this.targetEl.setAttribute("aria-describedby",t):this.targetEl.removeAttribute("aria-describedby")}}hideAllTooltips(){this.singleInstance?.hide(),this.singletonInstance?.hide(),this.tooltipInstances?.forEach((t=>t.hide()))}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.destroyTooltips()}updated(t){super.updated(t),["for","content","placement","distance","skidding","trigger","disabled","hoist","size","arrow","singleton"].some((n=>t.has(n)))&&this.attachTooltip(),t.has("open")&&(this.open?(this.visibilityManager?.setup(),this.singleInstance?.show(),this.singletonInstance?.show(),this.tooltipInstances?.forEach((t=>t.show()))):(this.visibilityManager?.cleanup(),this.singleInstance?.hide(),this.singletonInstance?.hide(),this.tooltipInstances?.forEach((t=>t.hide()))))}};t([n({type:String,attribute:"for"})],gn.prototype,"for",void 0),t([n({type:String,reflect:!0})],gn.prototype,"content",void 0),t([n({type:String,reflect:!0})],gn.prototype,"size",void 0),t([n({type:String,reflect:!0})],gn.prototype,"duration",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"interactive",void 0),t([n({type:String})],gn.prototype,"placement",void 0),t([n({type:Boolean})],gn.prototype,"disabled",void 0),t([n({type:Number})],gn.prototype,"distance",void 0),t([n({type:Number})],gn.prototype,"skidding",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"open",void 0),t([n({type:String})],gn.prototype,"trigger",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"allowHTML",void 0),t([n({type:String,reflect:!0,attribute:!0})],gn.prototype,"followCursor",void 0),t([n({type:String,reflect:!0,attribute:!0})],gn.prototype,"arrow",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"singleton",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"enableRecursiveMode",void 0),t([n({type:String,reflect:!0})],gn.prototype,"delay",void 0),t([n({type:String,reflect:!0})],gn.prototype,"maxWidth",void 0),t([n({type:Number})],gn.prototype,"zIndex",void 0),t([n({type:[Boolean,String],reflect:!0})],gn.prototype,"hideOnClick",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"inertia",void 0),t([n({type:Number})],gn.prototype,"interactiveBorder",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"enableVisibilityEffect",void 0),t([n({type:Boolean,reflect:!0})],gn.prototype,"enableTabClose",void 0),t([n({type:String,reflect:!0})],gn.prototype,"width",void 0),t([n({type:String,reflect:!0})],gn.prototype,"height",void 0),gn=t([e("nile-lite-tooltip")],gn);export{gn as N};
|
|
1
|
+
import{__decorate as t}from"tslib";import{property as i,customElement as e}from"lit/decorators.js";import{s}from"./nile-lite-tooltip.css.esm.js";import{N as o}from"../internal/nile-element.esm.js";import{R as n,f as h,t as r,c as a}from"../tippy.esm-57628c2b.esm.js";import{p as l,a as d}from"./utils.esm.js";import{V as c}from"../utilities/visibility-manager.esm.js";import"lit";let p=class extends o{static get styles(){return[s]}createRenderRoot(){return this}constructor(){super(),this.for=null,this.content="",this.size="small",this.duration=200,this.interactive=!1,this.placement="top",this.disabled=!1,this.distance=8,this.skidding=0,this.open=!1,this.trigger="mouseenter focus",this.allowHTML=!1,this.followCursor=!1,this.arrow="default",this.singleton=!1,this.enableRecursiveMode=!1,this.delay=0,this.maxWidth="auto",this.zIndex=9999,this.hideOnClick=!0,this.inertia=!1,this.interactiveBorder=2,this.enableVisibilityEffect=!1,this.enableTabClose=!1}firstUpdated(){this.attachTooltip();const t=this.for&&document.getElementById(this.for)||this.firstElementChild;this.visibilityManager=new c({host:this,target:t,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.open=!1,this.hideAllTooltips(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.open=!1,this.hideAllTooltips(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(t,i)=>this.emit(`nile-${t}`,i)})}refresh(){this.attachTooltip()}hasValidContent(){const t=this.content??this.getAttribute("data-tippy-content")??"";return"string"==typeof t&&t.trim().length>0}attachTooltip(){if(this.destroyTooltips(),this.disabled||!this.enableRecursiveMode&&!this.singleton&&!this.hasValidContent())return;const t={content:this.content||this.getAttribute("data-tippy-content")||void 0,placement:this.placement,trigger:this.trigger,offset:[this.skidding,this.distance],theme:"lite",animation:"fade",interactive:this.interactive,arrow:n,duration:l(this.duration),allowHTML:this.allowHTML,delay:this.delay,maxWidth:this.maxWidth,zIndex:this.zIndex,hideOnClick:!1,inertia:this.inertia,interactiveBorder:this.interactiveBorder,appendTo:document.body,followCursor:d(this.followCursor),plugins:d(this.followCursor)?[h]:[],onShow:t=>{this.open=!0;const i=t.popper.querySelector(".tippy-content");i&&(this.width&&(i.style.width=this.width),this.height&&(i.style.height=this.height,i.style.overflow="auto")),this.dispatchEvent(new CustomEvent("nile-show",{detail:{instance:t,target:t.reference}})),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{open:!0,instance:t,target:t.reference}}))},onHide:t=>{this.open=!1,this.dispatchEvent(new CustomEvent("nile-hide",{detail:{instance:t,target:t.reference}})),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{open:!1,instance:t,target:t.reference}}))}};if(this.for){if(this.singleton&&!this.for.startsWith("#")&&!document.getElementById(this.for)){const i=Array.from(document.querySelectorAll(`.${this.for}`));if(i.length>0)return this.tooltipInstances=i.map((i=>{const e=r(i,{...t,content:i.getAttribute("content")||this.content});return e.popper.querySelector(".tippy-box")?.classList.add(this.size),e})),this.singletonInstance=a(this.tooltipInstances,{delay:[75,0],arrow:n,moveTransition:"transform 0.15s ease-out"}),void(this.open&&queueMicrotask((()=>this.singletonInstance?.show())))}const i=document.getElementById(this.for);if(this.singleton&&i){const e=Array.from(i.querySelectorAll("[content]"));if(e.length>0)return this.tooltipInstances=e.map((i=>{const e=r(i,{...t,content:i.getAttribute("content")||this.content});return e.popper.querySelector(".tippy-box")?.classList.add(this.size),e})),this.singletonInstance=a(this.tooltipInstances,{delay:[75,0],arrow:n,moveTransition:"transform 0.15s ease-out"}),void(this.open&&queueMicrotask((()=>this.singletonInstance?.show())))}if(this.targetEl=document.getElementById(this.for),!this.targetEl)return;this.id||(this.generatedId=`nile-tooltip-${Math.random().toString(36).slice(2,9)}`,this.id=this.generatedId),this.prevDescribedby=this.targetEl.getAttribute("aria-describedby");const e=this.prevDescribedby?`${this.prevDescribedby} ${this.id}`:this.id;return this.targetEl.setAttribute("aria-describedby",e),this.singleInstance=r(this.targetEl,t),this.size&&this.singleInstance.popper.querySelector(".tippy-box")?.classList.add(this.size),void(this.open&&queueMicrotask((()=>this.singleInstance?.show())))}if(this.enableRecursiveMode){const i=Array.from(this.querySelectorAll("[content]")).filter((t=>{const i=t.getAttribute("content");return null!==i&&i.trim().length>0}));i.length>0&&(this.tooltipInstances=i.map((i=>{const e=i,s=e.getAttribute("content")||this.content,o=r(e,{...t,content:s});return o.popper.querySelector(".tippy-box")?.classList.add(this.size),o})),this.singleton&&this.tooltipInstances.length>1&&(this.singletonInstance=a(this.tooltipInstances,{delay:[75,0],arrow:n,moveTransition:"transform 0.15s ease-out"})),this.open&&(this.singletonInstance?this.singletonInstance.show():this.tooltipInstances.forEach((t=>t.show()))))}else{const i=this.firstElementChild;if(i){const e=i.getAttribute("content")||this.content,s=r(i,{...t,content:e});s.popper.querySelector(".tippy-box")?.classList.add(this.size),this.tooltipInstances=[s],this.open&&s.show()}}}destroyTooltips(){if(this.tooltipInstances?.forEach((t=>t.destroy())),this.singleInstance?.destroy(),this.singletonInstance?.destroy(),this.tooltipInstances=void 0,this.singleInstance=void 0,this.singletonInstance=void 0,this.targetEl&&this.id){const t=this.targetEl.getAttribute("aria-describedby")?.split(" ").filter((t=>t!==this.id)).join(" ").trim();t?this.targetEl.setAttribute("aria-describedby",t):this.targetEl.removeAttribute("aria-describedby")}}hideAllTooltips(){this.singleInstance?.hide(),this.singletonInstance?.hide(),this.tooltipInstances?.forEach((t=>t.hide()))}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.destroyTooltips()}updated(t){super.updated(t),["for","content","placement","distance","skidding","trigger","disabled","hoist","size","arrow","singleton"].some((i=>t.has(i)))&&this.attachTooltip(),t.has("open")&&(this.open?(this.visibilityManager?.setup(),this.singleInstance?.show(),this.singletonInstance?.show(),this.tooltipInstances?.forEach((t=>t.show()))):(this.visibilityManager?.cleanup(),this.singleInstance?.hide(),this.singletonInstance?.hide(),this.tooltipInstances?.forEach((t=>t.hide()))))}};t([i({type:String,attribute:"for"})],p.prototype,"for",void 0),t([i({type:String,reflect:!0})],p.prototype,"content",void 0),t([i({type:String,reflect:!0})],p.prototype,"size",void 0),t([i({type:String,reflect:!0})],p.prototype,"duration",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"interactive",void 0),t([i({type:String})],p.prototype,"placement",void 0),t([i({type:Boolean})],p.prototype,"disabled",void 0),t([i({type:Number})],p.prototype,"distance",void 0),t([i({type:Number})],p.prototype,"skidding",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"open",void 0),t([i({type:String})],p.prototype,"trigger",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"allowHTML",void 0),t([i({type:String,reflect:!0,attribute:!0})],p.prototype,"followCursor",void 0),t([i({type:String,reflect:!0,attribute:!0})],p.prototype,"arrow",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"singleton",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"enableRecursiveMode",void 0),t([i({type:String,reflect:!0})],p.prototype,"delay",void 0),t([i({type:String,reflect:!0})],p.prototype,"maxWidth",void 0),t([i({type:Number})],p.prototype,"zIndex",void 0),t([i({type:[Boolean,String],reflect:!0})],p.prototype,"hideOnClick",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"inertia",void 0),t([i({type:Number})],p.prototype,"interactiveBorder",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"enableVisibilityEffect",void 0),t([i({type:Boolean,reflect:!0})],p.prototype,"enableTabClose",void 0),t([i({type:String,reflect:!0})],p.prototype,"width",void 0),t([i({type:String,reflect:!0})],p.prototype,"height",void 0),p=t([e("nile-lite-tooltip")],p);export{p as N};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-rte-toolbar.cjs.js","./nile-rte-toolbar-item.cjs.js","./nile-rte-select.cjs.js","./nile-rte-color.cjs.js","./nile-rte-divider.cjs.js","./nile-rte-preview.cjs.js","./nile-rte-mentions.cjs.js","./nile-rte-link.cjs.js","./utils/block-utils.cjs.js","./utils/inline-utils.cjs.js","./utils/color-utils.cjs.js","./utils/list-utils.cjs.js","./nile-rich-text-editor.css.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,n,r,o,h,l,c,a,u,d,f,m,p,b,g,y;function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n4){function n(){return _n4.apply(this,arguments);}n.toString=function(){return _n4.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.LitElement;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;e=_litDecoratorsJs.state;n=_litDecoratorsJs.customElement;},function(_nileRteToolbarCjsJs){},function(_nileRteToolbarItemCjsJs){},function(_nileRteSelectCjsJs){},function(_nileRteColorCjsJs){},function(_nileRteDividerCjsJs){},function(_nileRtePreviewCjsJs){},function(_nileRteMentionsCjsJs){},function(_nileRteLinkCjsJs){},function(_utilsBlockUtilsCjsJs){r=_utilsBlockUtilsCjsJs.s;o=_utilsBlockUtilsCjsJs.a;h=_utilsBlockUtilsCjsJs.n;l=_utilsBlockUtilsCjsJs.c;},function(_utilsInlineUtilsCjsJs){c=_utilsInlineUtilsCjsJs.t;a=_utilsInlineUtilsCjsJs.s;u=_utilsInlineUtilsCjsJs.r;},function(_utilsColorUtilsCjsJs){d=_utilsColorUtilsCjsJs.s;f=_utilsColorUtilsCjsJs.a;},function(_utilsListUtilsCjsJs){m=_utilsListUtilsCjsJs.t;},function(_nileRichTextEditorCssCjsJs){p=_nileRichTextEditorCssCjsJs.s;}],execute:function execute(){b={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"},g=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];_export("N",y=/*#__PURE__*/function(_i){function y(){var _this;_classCallCheck(this,y);_this=_callSuper(this,y,arguments),_this.value="",_this.noStyles=!1,_this.disabled=!1,_this.singleLineEditor=!1,_this.placeholder="",_this.mentions={},_this.whitelist=[],_this.content="",_this.previewEl=null,_this.toolbarEl=null,_this.lastRange=null,_this.buttonMap=new Map(),_this.headingSelect=null,_this.fontSelect=null,_this.colorInput=null,_this.bgColorInput=null,_this.colorSwatchEl=null,_this.bgSwatchEl=null,_this.containerEl=null,_this.mentionsEl=null,_this.onEditorKeydown=function(t){if(_this.singleLineEditor&&"Enter"===t.key&&t.shiftKey)return void t.preventDefault();if(t.ctrlKey&&"i"===t.key.toLowerCase()&&(t.preventDefault(),c(_this.editorEl,"em"),_this.updateContent(),_this.updateToolbarState()),_this.singleLineEditor&&"Enter"===t.key)return void t.preventDefault();if("Tab"!==t.key)return;t.preventDefault(),_this.focusAndRestore();var i=window.getSelection();if(!i||0===i.rangeCount)return;var s=i.getRangeAt(0);if(t.shiftKey){if(s.collapsed&&s.startContainer.nodeType===Node.TEXT_NODE){var _t=s.startContainer,_e=s.startOffset,_n=_t.data.slice(0,_e),_r=_n.replace(/(\t|[ \u00a0]{2})$/,"");if(_r.length!==_n.length){_t.data=_r+_t.data.slice(_e);var _s=document.createRange();_s.setStart(_t,_r.length),_s.collapse(!0),i.removeAllRanges(),i.addRange(_s),_this.updateContent(),_this.updateToolbarState();}}return;}s.deleteContents();var e=document.createTextNode("\t");s.insertNode(e);var n=document.createRange();n.setStartAfter(e),n.collapse(!0),i.removeAllRanges(),i.addRange(n),_this.updateContent(),_this.updateToolbarState();},_this.onSelectionChange=function(){if(!_this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);_this.editorEl.contains(i.commonAncestorContainer)&&(_this.lastRange=i.cloneRange(),_this.updateToolbarState());};return _this;}_inherits(y,_i);return _createClass(y,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"injectCss",value:function injectCss(t){if(this.querySelector("style[data-rte-style]"))return;var i=document.createElement("style");i.setAttribute("data-rte-style","true"),i.textContent=t,this.insertBefore(i,this.firstChild);}},{key:"connectedCallback",value:function connectedCallback(){var _this$mentionsEl$atta,_this$mentionsEl,_this$mentionsEl$setE,_this$mentionsEl2;_superPropGet(y,"connectedCallback",this,3)([]),this.injectCss(p.cssText),this.ensureStructure(),this.placeholder&&this.editorEl&&(this.editorEl.dataset.placeholder=this.placeholder),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&((_this$mentionsEl$atta=(_this$mentionsEl=this.mentionsEl).attach)!==null&&_this$mentionsEl$atta!==void 0&&_this$mentionsEl$atta.call(_this$mentionsEl,this.editorEl,this),(_this$mentionsEl$setE=(_this$mentionsEl2=this.mentionsEl).setExternalConfig)!==null&&_this$mentionsEl$setE!==void 0&&_this$mentionsEl$setE.call(_this$mentionsEl2,this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview();}},{key:"ensureStructure",value:function ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling));}},{key:"updateContentWithMention",value:function updateContentWithMention(t){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:t},bubbles:!0,composed:!0}));}},{key:"disconnectedCallback",value:function disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),_superPropGet(y,"disconnectedCallback",this,3)([]);}},{key:"updated",value:function updated(t){t.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),t.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor)),t.has("disabled")&&this.editorEl&&(this.editorEl.setAttribute("contenteditable",this.disabled?"false":"true"),this.editorEl.tabIndex=this.disabled?-1:0);}},{key:"ensureEditor",value:function ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){var _t2=document.createElement("article");_t2.className="editor",_t2.setAttribute("contenteditable",this.disabled?"false":"true"),_t2.tabIndex=this.disabled?-1:0,this.editorEl=_t2;}this.placeholder&&(this.editorEl.dataset.placeholder=this.placeholder),this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>");}},{key:"unwrapMention",value:function unwrapMention(t){var _t$textContent;var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var s=t.parentNode;if(!s)return;var e=i?((_t$textContent=t.textContent)!==null&&_t$textContent!==void 0?_t$textContent:"").replace(/\u200B/g,""):"",n=document.createTextNode(e);s.insertBefore(n,t),s.removeChild(t);var r=document.createRange();r.setStartAfter(n),r.collapse(!0);var o=window.getSelection();o!==null&&o!==void 0&&o.removeAllRanges(),o===null||o===void 0?void 0:o.addRange(r);}},{key:"scrubBrokenMentions",value:function scrubBrokenMentions(){var _this2=this;if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach(function(t){var _i$textContent;var i=t,s=i.getAttribute("data-mention-key"),e=i.getAttribute("data-mention-label"),n=i.getAttribute("data-mention-trigger")||"",r=((_i$textContent=i.textContent)!==null&&_i$textContent!==void 0?_i$textContent:"").replace(/\u200B/g,"").trim(),o=!!s&&!!e&&r.length>0&&r.startsWith(n)&&r.includes(e);r&&o||_this2.unwrapMention(i,!0);});}},{key:"wireEditor",value:function wireEditor(){var _this3=this;this.editorEl.addEventListener("input",function(){_this3.ensureAtLeastOneParagraph(),_this3.scrubBrokenMentions(),_this3.updateContent(),_this3.updateToolbarState();}),this.editorEl.addEventListener("mouseup",function(){_this3.saveSelection(),_this3.updateToolbarState();}),this.editorEl.addEventListener("keyup",function(t){_this3.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t.key)&&_this3.updateToolbarState();}),this.editorEl.addEventListener("keydown",this.onEditorKeydown);}},{key:"wireAuthoredToolbar",value:function wireAuthoredToolbar(t){var _this4=this;this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach(function(t){var i=t.tagName.toLowerCase();if("nile-rte-select"===i&&"align"===t.getAttribute("type"))return t.disabled=_this4.disabled,void t.addEventListener("change",function(t){_this4.focusAndRestore();var i=t.detail;r(_this4.editorEl,i),_this4.updateContent(),_this4.updateToolbarState();});if("nile-rte-link"===i)return t.editorEl=_this4.editorEl,void t.addEventListener("link-changed",function(){_this4.updateContent(),_this4.updateToolbarState();});if("nile-rte-toolbar-item"===i){var _this4$buttonMap$get;var _i2=t.querySelector(":scope > nile-button");var _s2=t.getAttribute("name")||"",_e2=t.getAttribute("label")||_s2,_n2=t.getAttribute("icon"),_r2=t.innerHTML.trim().length>0;if(_i2||(_i2=document.createElement("nile-button"),_i2.variant="tertiary",_i2.size="small"),_i2.disabled=_this4.disabled,_n2)_i2.innerHTML="<nile-icon name=\"".concat(_n2,"\" color=\"").concat(_this4.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))","\" ></nile-icon>"),t.innerHTML="";else if(_r2)_i2.innerHTML=t.innerHTML,t.innerHTML="";else{var _n3=b[_s2];_n3?_i2.innerHTML="<nile-icon name=\"".concat(_n3,"\" size=\"20\" color=\"").concat(_this4.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))","\" ></nile-icon>"):_i2.textContent=_e2||_s2,t.innerHTML="";}if(!_i2.isConnected)if(_this4.disabled)t.appendChild(_i2);else{var _s3=document.createElement("nile-lite-tooltip");_s3.setAttribute("content",_e2),_s3.appendChild(_i2),t.appendChild(_s3);}_i2.setAttribute("aria-label",_e2),_i2.addEventListener("mousedown",function(t){return t.preventDefault();}),_i2.addEventListener("click",function(){return _this4.onToolbarCommand(_s2);});var _o=(_this4$buttonMap$get=_this4.buttonMap.get(_s2))!==null&&_this4$buttonMap$get!==void 0?_this4$buttonMap$get:[];return _o.push(_i2),void _this4.buttonMap.set(_s2,_o);}if("nile-rte-select"!==i)"nile-rte-color"!==i||t.addEventListener("change",function(t){_this4.focusAndRestore();var _t$detail=t.detail,i=_t$detail.mode,s=_t$detail.value;"backColor"===i?d(_this4.editorEl,s):f(_this4.editorEl,s),_this4.updateContent(),_this4.updateToolbarState();});else{var _i3=t.getAttribute("type")||"";t.addEventListener("change",function(t){_this4.focusAndRestore();var s=t.detail;"heading"===_i3?o(_this4.editorEl,s):"font"===_i3&&a(_this4.editorEl,s),_this4.updateContent(),_this4.updateToolbarState();});}});}},{key:"saveSelection",value:function saveSelection(){var t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange());}},{key:"restoreSelection",value:function restoreSelection(){if(!this.lastRange)return;var t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange));}},{key:"focusAndRestore",value:function focusAndRestore(){var _this$editorEl;(_this$editorEl=this.editorEl)!==null&&_this$editorEl!==void 0&&_this$editorEl.focus(),this.restoreSelection();}},{key:"getCleanContent",value:function getCleanContent(){var t=this.editorEl.cloneNode(!0);return t.querySelectorAll("*").forEach(function(t){t.removeAttribute("style");}),t.innerHTML;}},{key:"insertList",value:function insertList(t){if(this.restoreSelection(),!this.lastRange)return;var i=document.createElement(t),s=this.lastRange.extractContents(),e=document.createElement("div");e.appendChild(s),Array.from(e.childNodes).forEach(function(t){var _t$textContent2;if(t.nodeType===Node.TEXT_NODE&&!((_t$textContent2=t.textContent)!==null&&_t$textContent2!==void 0&&_t$textContent2.trim()))return;var s=document.createElement("li");s.appendChild(t),i.appendChild(s);}),this.lastRange.insertNode(i),this.afterListEdit(i);}},{key:"afterListEdit",value:function afterListEdit(t){var i=document.createRange();i.setStartAfter(t),i.collapse(!0);var s=window.getSelection();s!==null&&s!==void 0&&s.removeAllRanges(),s!==null&&s!==void 0&&s.addRange(i),this.saveSelection(),this.updateContent(),this.updateToolbarState();}},{key:"ensureAtLeastOneParagraph",value:function ensureAtLeastOneParagraph(){var _t$textContent3;var t=this.editorEl;if(!t)return;var i=""===((_t$textContent3=t.textContent)!==null&&_t$textContent3!==void 0?_t$textContent3:"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||i)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){var _i4=document.createElement("p");for(;t.firstChild;)_i4.appendChild(t.firstChild);return _i4.hasChildNodes()||_i4.appendChild(document.createElement("br")),void t.appendChild(_i4);}t.querySelectorAll("p").forEach(function(t){var _t$textContent4;""===((_t$textContent4=t.textContent)!==null&&_t$textContent4!==void 0?_t$textContent4:"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"));});}},{key:"onToolbarCommand",value:function onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":c(this.editorEl,"strong");break;case"italic":c(this.editorEl,"em");break;case"underline":c(this.editorEl,"u");break;case"left":r(this.editorEl,"left");break;case"center":r(this.editorEl,"center");break;case"right":r(this.editorEl,"right");break;case"justify":r(this.editorEl,"justify");break;case"ul":m(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":m(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":var _t3=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),_i5=[];for(;_t3.nextNode();){var _s4=_t3.currentNode;_s4.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(_s4.tagName)&&_i5.push(_s4);}for(var _i7=0,_i6=_i5;_i7<_i6.length;_i7++){var _t4=_i6[_i7];for(;_t4.firstChild;){var _t4$parentNode;(_t4$parentNode=_t4.parentNode)===null||_t4$parentNode===void 0||_t4$parentNode.insertBefore(_t4.firstChild,_t4);}_t4.remove();}this.ensureAtLeastOneParagraph();}this.updateContent(),this.updateToolbarState();}},{key:"setBtnActive",value:function setBtnActive(t,i){var s=this.buttonMap.get(t);if(s){var _iterator=_createForOfIteratorHelper(s),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _t5=_step.value;_t5.toggleAttribute("data-active",!!i);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}}},{key:"updateToolbarState",value:function updateToolbarState(){var _this5=this,_s$closest;if(!this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);if(!this.editorEl.contains(i.commonAncestorContainer))return;var s=h(i.startContainer)||this.editorEl,e=getComputedStyle(s),n=l(i.startContainer,this.editorEl)||this.editorEl,r=function(){var t=s;for(;t&&t!==_this5.editorEl;){if(t instanceof HTMLElement){var _i8=t.tagName.toLowerCase();if("strong"===_i8||"b"===_i8)return!0;var _s5=getComputedStyle(t).fontWeight;if(parseInt(_s5,10)>=600)return!0;}t=t.parentNode;}return!1;}(),o=function(){var t=s;for(;t&&t!==_this5.editorEl;){if(t instanceof HTMLElement){var _i9=t.tagName.toLowerCase();if("em"===_i9||"i"===_i9)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0;}t=t.parentNode;}return!1;}(),c=function(){var t=s;for(;t&&t!==_this5.editorEl;){if(t instanceof HTMLElement){var _i10=getComputedStyle(t).textDecorationLine;if(_i10&&_i10.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0;}t=t.parentNode;}return!1;}(),a=!!s.closest("a"),d=n.style.textAlign||getComputedStyle(n).textAlign||"start",f="start"===d?"left":d,m=!!s.closest("li")&&((_s$closest=s.closest("ul,ol"))===null||_s$closest===void 0?void 0:_s$closest.tagName.toLowerCase())||"";if(this.setBtnActive("bold",r),this.setBtnActive("italic",o),this.setBtnActive("underline",c),this.setBtnActive("link",a),this.setBtnActive("left","left"===f&&!["center","right","justify"].includes(f)),this.setBtnActive("center","center"===f),this.setBtnActive("right","right"===f),this.setBtnActive("justify","justify"===f),this.setBtnActive("ul","ul"===m),this.setBtnActive("ol","ol"===m),this.headingSelect){var _t6=n.tagName.toLowerCase(),_i11=["h1","h2","h3"].includes(_t6)?_t6:"p";this.headingSelect.value!==_i11&&(this.headingSelect.value=_i11);}if(this.fontSelect){var _t7=(e.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(_t7)for(var _i12=0,_Array$from=Array.from(this.fontSelect.options);_i12<_Array$from.length;_i12++){var _i13=_Array$from[_i12];if(_i13.value.toLowerCase()===_t7){this.fontSelect.value=_i13.value;break;}}}if(this.colorInput){var _t8=u(e.color);_t8&&this.colorInput.value.toLowerCase()!==_t8.toLowerCase()&&(this.colorInput.value=_t8),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value);}if(this.bgColorInput){var _t9=getComputedStyle(s).backgroundColor;if(_t9&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(_t9)){var _i14=u(_t9);_i14&&this.bgColorInput.value.toLowerCase()!==_i14.toLowerCase()&&(this.bgColorInput.value=_i14);}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value);}}},{key:"syncPreview",value:function syncPreview(){this.updateContent();}},{key:"getComputedImportantProps",value:function getComputedImportantProps(){var _this$whitelist;return Array.from(new Set([].concat(g,_toConsumableArray((_this$whitelist=this.whitelist)!==null&&_this$whitelist!==void 0?_this$whitelist:[]))));}},{key:"updateContent",value:function updateContent(){var _this$editorEl$textCo;if(!this.editorEl)return;this.ensureAtLeastOneParagraph();var t=""===((_this$editorEl$textCo=this.editorEl.textContent)!==null&&_this$editorEl$textCo!==void 0?_this$editorEl$textCo:"").trim();this.editorEl.classList.toggle("empty",t);var i=this.editorEl.cloneNode(!0);if(this.noStyles)i.querySelectorAll("[style]").forEach(function(t){return t.removeAttribute("style");});else{var _t10=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),_s6=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),_e3=this.getComputedImportantProps();var _loop=function _loop(){var i=_t10.currentNode,n=_s6.currentNode,r=window.getComputedStyle(i),o=_e3.map(function(t){return"".concat(t,":").concat(r.getPropertyValue(t));}).join(";");o.trim()&&n.setAttribute("style",o);};for(;_t10.nextNode()&&_s6.nextNode();){_loop();}}this.content=i.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}));}}]);}(i));t([s({type:String,attribute:!0,reflect:!0})],y.prototype,"value",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],y.prototype,"noStyles",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],y.prototype,"disabled",void 0),t([s({type:Boolean,attribute:"singlelineeditor",reflect:!0})],y.prototype,"singleLineEditor",void 0),t([s({type:String})],y.prototype,"placeholder",void 0),t([s({attribute:"mentions",reflect:!0,converter:{fromAttribute:function fromAttribute(t){try{var _i15=JSON.parse(t),_s7={};for(var _i16=0,_Object$keys=Object.keys(_i15);_i16<_Object$keys.length;_i16++){var _t11=_Object$keys[_i16];var _e4=_i15[_t11];Array.isArray(_e4)&&(_s7[_t11]=_e4.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}).map(function(t){return{key:t.key,label:t.label};}));}return _s7;}catch(_unused){return{};}},toAttribute:function toAttribute(t){return JSON.stringify(t);}}})],y.prototype,"mentions",void 0),t([s({attribute:"whitelist",reflect:!1,converter:{fromAttribute:function fromAttribute(t){try{var _i17=JSON.parse(t);return Array.isArray(_i17)?_i17.filter(function(t){return"string"==typeof t;}):[];}catch(_unused2){return[];}}}})],y.prototype,"whitelist",void 0),t([e()],y.prototype,"content",void 0),_export("N",y=t([n("nile-rich-text-editor")],y));}};});
|
|
1
|
+
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-rte-toolbar.cjs.js","./nile-rte-toolbar-item.cjs.js","./nile-rte-select.cjs.js","./nile-rte-color.cjs.js","./nile-rte-divider.cjs.js","./nile-rte-preview.cjs.js","./nile-rte-mentions.cjs.js","./nile-rte-link.cjs.js","./utils/block-utils.cjs.js","./utils/inline-utils.cjs.js","./utils/color-utils.cjs.js","./utils/list-utils.cjs.js","./nile-rich-text-editor.css.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,n,r,o,h,l,c,a,u,d,f,m,p,b,g,y;function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n4){function n(){return _n4.apply(this,arguments);}n.toString=function(){return _n4.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.LitElement;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;e=_litDecoratorsJs.state;n=_litDecoratorsJs.customElement;},function(_nileRteToolbarCjsJs){},function(_nileRteToolbarItemCjsJs){},function(_nileRteSelectCjsJs){},function(_nileRteColorCjsJs){},function(_nileRteDividerCjsJs){},function(_nileRtePreviewCjsJs){},function(_nileRteMentionsCjsJs){},function(_nileRteLinkCjsJs){},function(_utilsBlockUtilsCjsJs){r=_utilsBlockUtilsCjsJs.s;o=_utilsBlockUtilsCjsJs.a;h=_utilsBlockUtilsCjsJs.n;l=_utilsBlockUtilsCjsJs.c;},function(_utilsInlineUtilsCjsJs){c=_utilsInlineUtilsCjsJs.t;a=_utilsInlineUtilsCjsJs.s;u=_utilsInlineUtilsCjsJs.r;},function(_utilsColorUtilsCjsJs){d=_utilsColorUtilsCjsJs.s;f=_utilsColorUtilsCjsJs.a;},function(_utilsListUtilsCjsJs){m=_utilsListUtilsCjsJs.t;},function(_nileRichTextEditorCssCjsJs){p=_nileRichTextEditorCssCjsJs.s;}],execute:function execute(){b={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"},g=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];_export("N",y=/*#__PURE__*/function(_i){function y(){var _this;_classCallCheck(this,y);_this=_callSuper(this,y,arguments),_this.value="",_this.noStyles=!1,_this.disabled=!1,_this.singleLineEditor=!1,_this.placeholder="",_this.mentions={},_this.whitelist=[],_this.content="",_this.previewEl=null,_this.toolbarEl=null,_this.lastRange=null,_this.buttonMap=new Map(),_this.headingSelect=null,_this.fontSelect=null,_this.colorInput=null,_this.bgColorInput=null,_this.colorSwatchEl=null,_this.bgSwatchEl=null,_this.containerEl=null,_this.linkEl=null,_this.mentionsEl=null,_this.onEditorClick=function(t){var _t$target$closest,_t$target;var i=(_t$target$closest=(_t$target=t.target).closest)===null||_t$target$closest===void 0?void 0:_t$target$closest.call(_t$target,"a");i&&t.preventDefault();},_this.onEditorInput=function(){_this.ensureAtLeastOneParagraph(),_this.scrubBrokenMentions(),_this.updateContent(),_this.updateToolbarState();},_this.onEditorMouseup=function(){_this.saveSelection(),_this.updateToolbarState();},_this.onEditorKeyup=function(t){_this.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t.key)&&_this.updateToolbarState();},_this.onEditorKeydown=function(t){if(_this.singleLineEditor&&"Enter"===t.key&&t.shiftKey)return void t.preventDefault();if(t.ctrlKey&&"i"===t.key.toLowerCase()&&(t.preventDefault(),c(_this.editorEl,"em"),_this.updateContent(),_this.updateToolbarState()),_this.singleLineEditor&&"Enter"===t.key)return void t.preventDefault();if("Tab"!==t.key)return;t.preventDefault(),_this.focusAndRestore();var i=window.getSelection();if(!i||0===i.rangeCount)return;var s=i.getRangeAt(0);if(t.shiftKey){if(s.collapsed&&s.startContainer.nodeType===Node.TEXT_NODE){var _t=s.startContainer,_e=s.startOffset,_n=_t.data.slice(0,_e),_r=_n.replace(/(\t|[ \u00a0]{2})$/,"");if(_r.length!==_n.length){_t.data=_r+_t.data.slice(_e);var _s=document.createRange();_s.setStart(_t,_r.length),_s.collapse(!0),i.removeAllRanges(),i.addRange(_s),_this.updateContent(),_this.updateToolbarState();}}return;}s.deleteContents();var e=document.createTextNode("\t");s.insertNode(e);var n=document.createRange();n.setStartAfter(e),n.collapse(!0),i.removeAllRanges(),i.addRange(n),_this.updateContent(),_this.updateToolbarState();},_this.onSelectionChange=function(){if(!_this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);_this.editorEl.contains(i.commonAncestorContainer)&&(_this.lastRange=i.cloneRange(),_this.updateToolbarState());};return _this;}_inherits(y,_i);return _createClass(y,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"injectCss",value:function injectCss(t){if(this.querySelector("style[data-rte-style]"))return;var i=document.createElement("style");i.setAttribute("data-rte-style","true"),i.textContent=t,this.insertBefore(i,this.firstChild);}},{key:"connectedCallback",value:function connectedCallback(){var _this$mentionsEl$atta,_this$mentionsEl,_this$mentionsEl$setE,_this$mentionsEl2;_superPropGet(y,"connectedCallback",this,3)([]),this.injectCss(p.cssText),this.ensureStructure(),this.placeholder&&this.editorEl&&(this.editorEl.dataset.placeholder=this.placeholder),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&((_this$mentionsEl$atta=(_this$mentionsEl=this.mentionsEl).attach)!==null&&_this$mentionsEl$atta!==void 0&&_this$mentionsEl$atta.call(_this$mentionsEl,this.editorEl,this),(_this$mentionsEl$setE=(_this$mentionsEl2=this.mentionsEl).setExternalConfig)!==null&&_this$mentionsEl$setE!==void 0&&_this$mentionsEl$setE.call(_this$mentionsEl2,this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview();}},{key:"ensureStructure",value:function ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling));}},{key:"updateContentWithMention",value:function updateContentWithMention(t){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:t},bubbles:!0,composed:!0}));}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.unwireEditor(),document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),_superPropGet(y,"disconnectedCallback",this,3)([]);}},{key:"updated",value:function updated(t){t.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),t.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor)),t.has("disabled")&&this.editorEl&&(this.editorEl.setAttribute("contenteditable",this.disabled?"false":"true"),this.editorEl.tabIndex=this.disabled?-1:0,this.linkEl&&(this.linkEl.disabled=this.disabled)),t.has("placeholder")&&this.editorEl&&(this.placeholder?this.editorEl.dataset.placeholder=this.placeholder:delete this.editorEl.dataset.placeholder);}},{key:"ensureEditor",value:function ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){var _t2=document.createElement("article");_t2.className="editor",_t2.setAttribute("contenteditable",this.disabled?"false":"true"),_t2.tabIndex=this.disabled?-1:0,this.editorEl=_t2;}this.placeholder&&(this.editorEl.dataset.placeholder=this.placeholder),this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>");}},{key:"unwrapMention",value:function unwrapMention(t){var _t$textContent;var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var s=t.parentNode;if(!s)return;var e=i?((_t$textContent=t.textContent)!==null&&_t$textContent!==void 0?_t$textContent:"").replace(/\u200B/g,""):"",n=document.createTextNode(e);s.insertBefore(n,t),s.removeChild(t);var r=document.createRange();r.setStartAfter(n),r.collapse(!0);var o=window.getSelection();o!==null&&o!==void 0&&o.removeAllRanges(),o===null||o===void 0?void 0:o.addRange(r);}},{key:"scrubBrokenMentions",value:function scrubBrokenMentions(){var _this2=this;if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach(function(t){var _i$textContent;var i=t,s=i.getAttribute("data-mention-key"),e=i.getAttribute("data-mention-label"),n=i.getAttribute("data-mention-trigger")||"",r=((_i$textContent=i.textContent)!==null&&_i$textContent!==void 0?_i$textContent:"").replace(/\u200B/g,"").trim(),o=!!s&&!!e&&r.length>0&&r.startsWith(n)&&r.includes(e);r&&o||_this2.unwrapMention(i,!0);});}},{key:"wireEditor",value:function wireEditor(){this.editorEl.addEventListener("click",this.onEditorClick),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.onEditorMouseup),this.editorEl.addEventListener("keyup",this.onEditorKeyup),this.editorEl.addEventListener("keydown",this.onEditorKeydown);}},{key:"unwireEditor",value:function unwireEditor(){this.editorEl&&(this.editorEl.removeEventListener("click",this.onEditorClick),this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.onEditorMouseup),this.editorEl.removeEventListener("keyup",this.onEditorKeyup),this.editorEl.removeEventListener("keydown",this.onEditorKeydown));}},{key:"wireAuthoredToolbar",value:function wireAuthoredToolbar(t){var _this3=this;this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach(function(t){var i=t.tagName.toLowerCase();if("nile-rte-select"===i&&"align"===t.getAttribute("type"))return t.disabled=_this3.disabled,void t.addEventListener("change",function(t){_this3.focusAndRestore();var i=t.detail;r(_this3.editorEl,i),_this3.updateContent(),_this3.updateToolbarState();});if("nile-rte-link"===i)return t.editorEl=_this3.editorEl,t.disabled=_this3.disabled,_this3.linkEl=t,void t.addEventListener("nile-link-changed",function(){_this3.updateContent(),_this3.updateToolbarState();});if("nile-rte-toolbar-item"===i){var _this3$buttonMap$get;var _i2=t.querySelector(":scope > nile-button");var _s2=t.getAttribute("name")||"",_e2=t.getAttribute("label")||_s2,_n2=t.getAttribute("icon"),_r2=t.innerHTML.trim().length>0;if(_i2||(_i2=document.createElement("nile-button"),_i2.variant="tertiary",_i2.size="small"),_i2.disabled=_this3.disabled,_n2)_i2.innerHTML="<nile-icon name=\"".concat(_n2,"\" color=\"").concat(_this3.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))","\" ></nile-icon>"),t.innerHTML="";else if(_r2)_i2.innerHTML=t.innerHTML,t.innerHTML="";else{var _n3=b[_s2];_n3?_i2.innerHTML="<nile-icon name=\"".concat(_n3,"\" size=\"20\" color=\"").concat(_this3.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))","\" ></nile-icon>"):_i2.textContent=_e2||_s2,t.innerHTML="";}if(!_i2.isConnected)if(_this3.disabled)t.appendChild(_i2);else{var _s3=document.createElement("nile-lite-tooltip");_s3.setAttribute("content",_e2),_s3.appendChild(_i2),t.appendChild(_s3);}_i2.setAttribute("aria-label",_e2),_i2.addEventListener("mousedown",function(t){return t.preventDefault();}),_i2.addEventListener("click",function(){return _this3.onToolbarCommand(_s2);});var _o=(_this3$buttonMap$get=_this3.buttonMap.get(_s2))!==null&&_this3$buttonMap$get!==void 0?_this3$buttonMap$get:[];return _o.push(_i2),void _this3.buttonMap.set(_s2,_o);}if("nile-rte-select"!==i)"nile-rte-color"!==i||t.addEventListener("change",function(t){_this3.focusAndRestore();var _t$detail=t.detail,i=_t$detail.mode,s=_t$detail.value;"backColor"===i?d(_this3.editorEl,s):f(_this3.editorEl,s),_this3.updateContent(),_this3.updateToolbarState();});else{var _i3=t.getAttribute("type")||"";t.addEventListener("change",function(t){_this3.focusAndRestore();var s=t.detail;"heading"===_i3?o(_this3.editorEl,s):"font"===_i3&&a(_this3.editorEl,s),_this3.updateContent(),_this3.updateToolbarState();});}});}},{key:"saveSelection",value:function saveSelection(){var t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange());}},{key:"restoreSelection",value:function restoreSelection(){if(!this.lastRange)return;var t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange));}},{key:"focusAndRestore",value:function focusAndRestore(){var _this$editorEl;(_this$editorEl=this.editorEl)!==null&&_this$editorEl!==void 0&&_this$editorEl.focus(),this.restoreSelection();}},{key:"getCleanContent",value:function getCleanContent(){var t=this.editorEl.cloneNode(!0);return t.querySelectorAll("*").forEach(function(t){t.removeAttribute("style");}),t.innerHTML;}},{key:"insertList",value:function insertList(t){if(this.restoreSelection(),!this.lastRange)return;var i=document.createElement(t),s=this.lastRange.extractContents(),e=document.createElement("div");e.appendChild(s),Array.from(e.childNodes).forEach(function(t){var _t$textContent2;if(t.nodeType===Node.TEXT_NODE&&!((_t$textContent2=t.textContent)!==null&&_t$textContent2!==void 0&&_t$textContent2.trim()))return;var s=document.createElement("li");s.appendChild(t),i.appendChild(s);}),this.lastRange.insertNode(i),this.afterListEdit(i);}},{key:"afterListEdit",value:function afterListEdit(t){var i=document.createRange();i.setStartAfter(t),i.collapse(!0);var s=window.getSelection();s!==null&&s!==void 0&&s.removeAllRanges(),s!==null&&s!==void 0&&s.addRange(i),this.saveSelection(),this.updateContent(),this.updateToolbarState();}},{key:"ensureAtLeastOneParagraph",value:function ensureAtLeastOneParagraph(){var _t$textContent3;var t=this.editorEl;if(!t)return;var i=""===((_t$textContent3=t.textContent)!==null&&_t$textContent3!==void 0?_t$textContent3:"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||i)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){var _i4=document.createElement("p");for(;t.firstChild;)_i4.appendChild(t.firstChild);return _i4.hasChildNodes()||_i4.appendChild(document.createElement("br")),void t.appendChild(_i4);}t.querySelectorAll("p").forEach(function(t){var _t$textContent4;""===((_t$textContent4=t.textContent)!==null&&_t$textContent4!==void 0?_t$textContent4:"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"));});}},{key:"onToolbarCommand",value:function onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":c(this.editorEl,"strong");break;case"italic":c(this.editorEl,"em");break;case"underline":c(this.editorEl,"u");break;case"left":r(this.editorEl,"left");break;case"center":r(this.editorEl,"center");break;case"right":r(this.editorEl,"right");break;case"justify":r(this.editorEl,"justify");break;case"ul":m(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":m(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":var _t3=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),_i5=[];for(;_t3.nextNode();){var _s4=_t3.currentNode;_s4.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(_s4.tagName)&&_i5.push(_s4);}for(var _i7=0,_i6=_i5;_i7<_i6.length;_i7++){var _t4=_i6[_i7];for(;_t4.firstChild;){var _t4$parentNode;(_t4$parentNode=_t4.parentNode)===null||_t4$parentNode===void 0||_t4$parentNode.insertBefore(_t4.firstChild,_t4);}_t4.remove();}this.ensureAtLeastOneParagraph();}this.updateContent(),this.updateToolbarState();}},{key:"setBtnActive",value:function setBtnActive(t,i){var s=this.buttonMap.get(t);if(s){var _iterator=_createForOfIteratorHelper(s),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _t5=_step.value;_t5.toggleAttribute("data-active",!!i);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}}},{key:"updateToolbarState",value:function updateToolbarState(){var _this4=this,_s$closest;if(!this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);if(!this.editorEl.contains(i.commonAncestorContainer))return;var s=h(i.startContainer)||this.editorEl,e=getComputedStyle(s),n=l(i.startContainer,this.editorEl)||this.editorEl,r=function(){var t=s;for(;t&&t!==_this4.editorEl;){if(t instanceof HTMLElement){var _i8=t.tagName.toLowerCase();if("strong"===_i8||"b"===_i8)return!0;var _s5=getComputedStyle(t).fontWeight;if(parseInt(_s5,10)>=600)return!0;}t=t.parentNode;}return!1;}(),o=function(){var t=s;for(;t&&t!==_this4.editorEl;){if(t instanceof HTMLElement){var _i9=t.tagName.toLowerCase();if("em"===_i9||"i"===_i9)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0;}t=t.parentNode;}return!1;}(),c=function(){var t=s;for(;t&&t!==_this4.editorEl;){if(t instanceof HTMLElement){var _i10=getComputedStyle(t).textDecorationLine;if(_i10&&_i10.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0;}t=t.parentNode;}return!1;}(),a=!!s.closest("a"),d=n.style.textAlign||getComputedStyle(n).textAlign||"start",f="start"===d?"left":d,m=!!s.closest("li")&&((_s$closest=s.closest("ul,ol"))===null||_s$closest===void 0?void 0:_s$closest.tagName.toLowerCase())||"";if(this.setBtnActive("bold",r),this.setBtnActive("italic",o),this.setBtnActive("underline",c),this.setBtnActive("link",a),this.linkEl){var _t6=this.linkEl.querySelector("nile-button");_t6&&_t6.toggleAttribute("data-active",a);}if(this.setBtnActive("left","left"===f&&!["center","right","justify"].includes(f)),this.setBtnActive("center","center"===f),this.setBtnActive("right","right"===f),this.setBtnActive("justify","justify"===f),this.setBtnActive("ul","ul"===m),this.setBtnActive("ol","ol"===m),this.headingSelect){var _t7=n.tagName.toLowerCase(),_i11=["h1","h2","h3"].includes(_t7)?_t7:"p";this.headingSelect.value!==_i11&&(this.headingSelect.value=_i11);}if(this.fontSelect){var _t8=(e.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(_t8)for(var _i12=0,_Array$from=Array.from(this.fontSelect.options);_i12<_Array$from.length;_i12++){var _i13=_Array$from[_i12];if(_i13.value.toLowerCase()===_t8){this.fontSelect.value=_i13.value;break;}}}if(this.colorInput){var _t9=u(e.color);_t9&&this.colorInput.value.toLowerCase()!==_t9.toLowerCase()&&(this.colorInput.value=_t9),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value);}if(this.bgColorInput){var _t10=getComputedStyle(s).backgroundColor;if(_t10&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(_t10)){var _i14=u(_t10);_i14&&this.bgColorInput.value.toLowerCase()!==_i14.toLowerCase()&&(this.bgColorInput.value=_i14);}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value);}}},{key:"syncPreview",value:function syncPreview(){this.updateContent();}},{key:"getComputedImportantProps",value:function getComputedImportantProps(){var _this$whitelist;return Array.from(new Set([].concat(g,_toConsumableArray((_this$whitelist=this.whitelist)!==null&&_this$whitelist!==void 0?_this$whitelist:[]))));}},{key:"updateContent",value:function updateContent(){var _this$editorEl$textCo;if(!this.editorEl)return;this.ensureAtLeastOneParagraph();var t=""===((_this$editorEl$textCo=this.editorEl.textContent)!==null&&_this$editorEl$textCo!==void 0?_this$editorEl$textCo:"").trim();this.editorEl.classList.toggle("empty",t);var i=this.editorEl.cloneNode(!0);if(this.noStyles)i.querySelectorAll("[style]").forEach(function(t){return t.removeAttribute("style");});else{var _t11=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),_s6=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),_e3=this.getComputedImportantProps();var _loop=function _loop(){var i=_t11.currentNode,n=_s6.currentNode,r=window.getComputedStyle(i),o=_e3.map(function(t){return"".concat(t,":").concat(r.getPropertyValue(t));}).join(";");o.trim()&&n.setAttribute("style",o);};for(;_t11.nextNode()&&_s6.nextNode();){_loop();}}this.content=i.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}));}}]);}(i));t([s({type:String,attribute:!0,reflect:!0})],y.prototype,"value",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],y.prototype,"noStyles",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],y.prototype,"disabled",void 0),t([s({type:Boolean,attribute:"singlelineeditor",reflect:!0})],y.prototype,"singleLineEditor",void 0),t([s({type:String})],y.prototype,"placeholder",void 0),t([s({attribute:"mentions",reflect:!0,converter:{fromAttribute:function fromAttribute(t){try{var _i15=JSON.parse(t),_s7={};for(var _i16=0,_Object$keys=Object.keys(_i15);_i16<_Object$keys.length;_i16++){var _t12=_Object$keys[_i16];var _e4=_i15[_t12];Array.isArray(_e4)&&(_s7[_t12]=_e4.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}).map(function(t){return{key:t.key,label:t.label};}));}return _s7;}catch(_unused){return{};}},toAttribute:function toAttribute(t){return JSON.stringify(t);}}})],y.prototype,"mentions",void 0),t([s({attribute:"whitelist",reflect:!1,converter:{fromAttribute:function fromAttribute(t){try{var _i17=JSON.parse(t);return Array.isArray(_i17)?_i17.filter(function(t){return"string"==typeof t;}):[];}catch(_unused2){return[];}}}})],y.prototype,"whitelist",void 0),t([e()],y.prototype,"content",void 0),_export("N",y=t([n("nile-rich-text-editor")],y));}};});
|
|
2
2
|
//# sourceMappingURL=nile-rich-text-editor.cjs.js.map
|