@aquera/nile-elements 1.5.8 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +6 -0
  2. package/dist/index.js +85 -46
  3. package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
  4. package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -1
  5. package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
  6. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
  7. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
  8. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
  9. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
  10. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +24 -0
  11. package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
  12. package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
  13. package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
  14. package/dist/nile-rich-text-editor/nile-rte-link.esm.js +59 -44
  15. package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js +1 -1
  16. package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js.map +1 -1
  17. package/dist/nile-rich-text-editor/utils/inline-utils.esm.js +1 -1
  18. package/dist/src/nile-dropdown/nile-dropdown.js +4 -2
  19. package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
  20. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +24 -0
  21. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
  22. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +6 -0
  23. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +62 -24
  24. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
  25. package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +12 -0
  26. package/dist/src/nile-rich-text-editor/nile-rte-link.js +239 -130
  27. package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
  28. package/dist/src/nile-rich-text-editor/nile-rte-link.test.d.ts +1 -0
  29. package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +469 -0
  30. package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -0
  31. package/dist/src/nile-rich-text-editor/utils/inline-utils.js +13 -4
  32. package/dist/src/nile-rich-text-editor/utils/inline-utils.js.map +1 -1
  33. package/dist/src/version.js +1 -1
  34. package/dist/src/version.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/src/nile-dropdown/nile-dropdown.ts +5 -3
  38. package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +24 -0
  39. package/src/nile-rich-text-editor/nile-rich-text-editor.ts +66 -26
  40. package/src/nile-rich-text-editor/nile-rte-link.test.ts +682 -0
  41. package/src/nile-rich-text-editor/nile-rte-link.ts +195 -100
  42. package/src/nile-rich-text-editor/utils/inline-utils.ts +11 -4
  43. package/vscode-html-custom-data.json +16 -2
@@ -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-dropdown.css.cjs.js","../internal/animate.cjs.js","lit/directives/class-map.js","../utilities/animation-registry.cjs.js","../internal/tabbable.cjs.js","../internal/event.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","./portal-manager.cjs.js","../utilities/visibility-manager.cjs.js","../floating-ui.dom-007bbe96.cjs.js","../nile-popup/nile-popup.css.cjs.js","./portal-utils.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,n,o,h,a,r,l,d,p,c,m,u,f,w,_templateObject,y;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function define(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==_typeof(h)&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function value(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator["return"]&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(_typeof(e)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function reset(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},"catch":function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}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.html;},function(_litDecoratorsJs){s=_litDecoratorsJs.query;e=_litDecoratorsJs.property;n=_litDecoratorsJs.customElement;},function(_nileDropdownCssCjsJs){o=_nileDropdownCssCjsJs.s;},function(_internalAnimateCjsJs){h=_internalAnimateCjsJs.s;a=_internalAnimateCjsJs.a;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_utilitiesAnimationRegistryCjsJs){l=_utilitiesAnimationRegistryCjsJs.s;d=_utilitiesAnimationRegistryCjsJs.g;},function(_internalTabbableCjsJs){p=_internalTabbableCjsJs.g;},function(_internalEventCjsJs){c=_internalEventCjsJs.w;},function(_internalWatchCjsJs){m=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){u=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_portalManagerCjsJs){f=_portalManagerCjsJs.D;},function(_utilitiesVisibilityManagerCjsJs){w=_utilitiesVisibilityManagerCjsJs.V;},function(_floatingUiDom001CjsJs){},function(_nilePopupNilePopupCssCjsJs){},function(_portalUtilsCjsJs){}],execute:function execute(){_export("N",y=/*#__PURE__*/function(_u){function y(){var _this;_classCallCheck(this,y);_this=_callSuper(this,y,arguments),_this.open=!1,_this.placement="bottom-start",_this.disabled=!1,_this.stayOpenOnSelect=!1,_this.distance=0,_this.noOpenOnClick=!1,_this.skidding=0,_this.hoist=!1,_this.portal=!1,_this.enableVisibilityEffect=!1,_this.enableTabClose=!1,_this.portalManager=null;return _this;}_inherits(y,_u);return _createClass(y,[{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_superPropGet(y,"connectedCallback",this,3)([]),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame(function(){_this2.portal&&!_this2.portalManager&&(_this2.portalManager=new f(_this2));});}},{key:"firstUpdated",value:function(){var _firstUpdated=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(t){var _this3=this;var i;return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:this.panel.hidden=!this.open;this.open&&(this.addOpenListeners(),this.popup.active=!0);_context2.next=4;return this.updateComplete;case 4:i=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new w({host:this,target:i||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:function isOpen(){return _this3.open;},onAnchorOutOfView:function onAnchorOutOfView(){_this3.hide(),_this3.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"});},onDocumentHidden:function onDocumentHidden(){_this3.hide(),_this3.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"});},emit:function emit(t,i){return _this3.emit("nile-".concat(t),i);}});case 6:case"end":return _context2.stop();}},_callee,this);}));function firstUpdated(_x){return _firstUpdated.apply(this,arguments);}return firstUpdated;}()},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this$visibilityManag;_superPropGet(y,"disconnectedCallback",this,3)([]),(_this$visibilityManag=this.visibilityManager)!==null&&_this$visibilityManag!==void 0&&_this$visibilityManag.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null);}},{key:"focusOnTrigger",value:function focusOnTrigger(){var t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(t===null||t===void 0?void 0:t.focus)&&t.focus();}},{key:"getMenu",value:function getMenu(){return this.panel.assignedElements({flatten:!0}).find(function(t){return"nile-menu"===t.tagName.toLowerCase();});}},{key:"handleKeyDown",value:function handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger());}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(t){var _this4=this;if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){var _document$activeEleme;if(this.open&&"nile-menu-item"===((_document$activeEleme=document.activeElement)===null||_document$activeEleme===void 0?void 0:_document$activeEleme.tagName.toLowerCase()))return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout(function(){var _this4$containingElem,_document$activeEleme2,_this4$portalManager;var t=((_this4$containingElem=_this4.containingElement)===null||_this4$containingElem===void 0?void 0:_this4$containingElem.getRootNode())instanceof ShadowRoot?(_document$activeEleme2=document.activeElement)===null||_document$activeEleme2===void 0||(_document$activeEleme2=_document$activeEleme2.shadowRoot)===null||_document$activeEleme2===void 0?void 0:_document$activeEleme2.activeElement:document.activeElement,i=_this4.containingElement&&(t===null||t===void 0?void 0:t.closest(_this4.containingElement.tagName.toLowerCase()))===_this4.containingElement,s=_this4.portal&&((_this4$portalManager=_this4.portalManager)===null||_this4$portalManager===void 0?void 0:_this4$portalManager.portalContainerElement)&&(t===_this4.portalManager.portalContainerElement||(t===null||t===void 0?void 0:t.closest(".nile-dropdown-portal-append"))===_this4.portalManager.portalContainerElement);i||s||_this4.hide();});}}},{key:"handleDocumentMouseDown",value:function handleDocumentMouseDown(t){var _this$portalManager;var i=t.composedPath(),s=this.containingElement&&i.includes(this.containingElement),e=this.portal&&((_this$portalManager=this.portalManager)===null||_this$portalManager===void 0?void 0:_this$portalManager.portalContainerElement)&&i.includes(this.portalManager.portalContainerElement);s||e||this.hide();}},{key:"handlePanelSelect",value:function handlePanelSelect(t){var i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===i.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger());}},{key:"handleTriggerClick",value:function handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()));}},{key:"handleTriggerKeyDown",value:function handleTriggerKeyDown(t){var i=this.getMenu();if(i){var _s=i.getAllItems(),_e=_s[0],_n=_s[_s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),_s.length>0&&this.updateComplete.then(function(){"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(_e),_e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(_n),_n.focus());}));}}},{key:"handleTriggerKeyUp",value:function handleTriggerKeyUp(t){" "===t.key&&t.preventDefault();}},{key:"handleTriggerSlotChange",value:function handleTriggerSlotChange(){this.updateAccessibleTrigger();}},{key:"updateAccessibleTrigger",value:function updateAccessibleTrigger(){var t=this.trigger.assignedElements({flatten:!0}).find(function(t){return p(t).start;});var i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t;}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false");}}},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(this.open){_context3.next=2;break;}return _context3.abrupt("return",(this.open=!0,c(this,"nile-after-show")));case 2:case"end":return _context3.stop();}},_callee2,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!this.open){_context4.next=2;break;}return _context4.abrupt("return",(this.open=!1,c(this,"nile-after-hide")));case 2:case"end":return _context4.stop();}},_callee3,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"reposition",value:function reposition(){this.popup.reposition();}},{key:"addOpenListeners",value:function addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"removeOpenListeners",value:function removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"updated",value:function updated(t){_superPropGet(y,"updated",this,3)([t]),t.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new f(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),t.has("disabled")&&this.updateTriggerDisabledState();}},{key:"updateTriggerDisabledState",value:function updateTriggerDisabledState(){var t=this.querySelector('[slot="trigger"]');t&&"disabled"in t&&(t.disabled=this.disabled);}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _this$visibilityManag2;var _d,_t,_i,_this$visibilityManag3,_d2,_t2,_i2;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:if(!((_this$visibilityManag2=this.visibilityManager)!==null&&_this$visibilityManag2!==void 0&&_this$visibilityManag2.setup(),this.disabled)){_context5.next=4;break;}this.open=!1;_context5.next=31;break;case 4:if(!(this.updateAccessibleTrigger(),this.open)){_context5.next=18;break;}this.emit("nile-show");this.addOpenListeners();this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new f(this),this.portalManager.setupPortalAppend());_context5.next=10;return h(this);case 10:if(this.portal){_context5.next=15;break;}this.panel.hidden=!1,this.popup.active=!0;_d=d(this,"dropdown.show",{dir:""}),_t=_d.keyframes,_i=_d.options;_context5.next=15;return a(this.popup.popup,_t,_i);case 15:this.emit("nile-after-show");_context5.next=31;break;case 18:this.emit("nile-hide");this.removeOpenListeners();(_this$visibilityManag3=this.visibilityManager)!==null&&_this$visibilityManag3!==void 0&&_this$visibilityManag3.cleanup();this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend();_context5.next=24;return h(this);case 24:if(this.portal){_context5.next=30;break;}_d2=d(this,"dropdown.hide",{dir:""}),_t2=_d2.keyframes,_i2=_d2.options;_context5.next=28;return a(this.popup.popup,_t2,_i2);case 28:this.panel.hidden=!0;this.popup.active=!1;case 30:this.emit("nile-after-hide");case 31:case"end":return _context5.stop();}},_callee4,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"render",value:function render(){return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=","\n distance=","\n skidding=","\n strategy=","\n sync=","\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=","\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=","\n @keydown=","\n @keyup=","\n @slotchange=","\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=","\n aria-labelledby=\"dropdown\"\n style=","\n ></slot>\n </nile-popup>\n "])),this.placement,this.distance,this.skidding,this.hoist?"fixed":"absolute",this.sync,r({dropdown:!0,"dropdown--open":this.open}),this.handleTriggerClick,this.handleTriggerKeyDown,this.handleTriggerKeyUp,this.handleTriggerSlotChange,this.open?"false":"true",this.portal&&this.portalManager?"display: none;":"");}}]);}(u));y.styles=o,t([s(".dropdown")],y.prototype,"popup",void 0),t([s(".dropdown__trigger")],y.prototype,"trigger",void 0),t([s(".dropdown__panel")],y.prototype,"panel",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"open",void 0),t([e({reflect:!0})],y.prototype,"placement",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"disabled",void 0),t([e({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],y.prototype,"stayOpenOnSelect",void 0),t([e({attribute:!1})],y.prototype,"containingElement",void 0),t([e({type:Number})],y.prototype,"distance",void 0),t([e({type:Boolean})],y.prototype,"noOpenOnClick",void 0),t([e({type:Number})],y.prototype,"skidding",void 0),t([e()],y.prototype,"sync",void 0),t([e({type:Boolean})],y.prototype,"hoist",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"portal",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"enableVisibilityEffect",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"enableTabClose",void 0),t([m("open",{waitUntilFirstUpdate:!0})],y.prototype,"handleOpenChange",null),_export("N",y=t([n("nile-dropdown")],y)),l("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),l("dropdown.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
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-dropdown.css.cjs.js","../internal/animate.cjs.js","lit/directives/class-map.js","../utilities/animation-registry.cjs.js","../internal/tabbable.cjs.js","../internal/event.cjs.js","../internal/watch.cjs.js","../internal/nile-element.cjs.js","../nile-popup/nile-popup.cjs.js","./portal-manager.cjs.js","../utilities/visibility-manager.cjs.js","../floating-ui.dom-007bbe96.cjs.js","../nile-popup/nile-popup.css.cjs.js","./portal-utils.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,n,o,h,a,r,l,d,p,c,m,u,f,w,_templateObject,y;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return e;};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value;},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{define({},"");}catch(t){define=function define(t,e,r){return t[e]=r;};}function wrap(t,e,r,n){var i=e&&e.prototype instanceof Generator?e:Generator,a=Object.create(i.prototype),c=new Context(n||[]);return o(a,"_invoke",{value:makeInvokeMethod(t,r,c)}),a;}function tryCatch(t,e,r){try{return{type:"normal",arg:t.call(e,r)};}catch(t){return{type:"throw",arg:t};}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this;});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach(function(e){define(t,e,function(t){return this._invoke(e,t);});});}function AsyncIterator(t,e){function invoke(r,o,i,a){var c=tryCatch(t[r],t,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==_typeof(h)&&n.call(h,"__await")?e.resolve(h.__await).then(function(t){invoke("next",t,i,a);},function(t){invoke("throw",t,i,a);}):e.resolve(h).then(function(t){u.value=t,i(u);},function(t){return invoke("throw",t,i,a);});}a(c.arg);}var r;o(this,"_invoke",{value:function value(t,n){function callInvokeWithMethodAndArg(){return new e(function(e,r){invoke(t,n,e,r);});}return r=r?r.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(e,r,n){var o=h;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===s){if("throw"===i)throw a;return{value:t,done:!0};}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=maybeInvokeDelegate(c,n);if(u){if(u===y)continue;return u;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=s,n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var p=tryCatch(e,r,n);if("normal"===p.type){if(o=n.done?s:l,p.arg===y)continue;return{value:p.arg,done:n.done};}"throw"===p.type&&(o=s,n.method="throw",n.arg=p.arg);}};}function maybeInvokeDelegate(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator["return"]&&(r.method="return",r.arg=t,maybeInvokeDelegate(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=tryCatch(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y);}function pushTryEntry(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function resetTryEntry(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0);}function values(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function next(){for(;++o<e.length;)if(n.call(e,o))return next.value=e[o],next.done=!1,next;return next.value=t,next.done=!0,next;};return i.next=i;}}throw new TypeError(_typeof(e)+" is not iterable");}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===GeneratorFunction||"GeneratorFunction"===(e.displayName||e.name));},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,GeneratorFunctionPrototype):(t.__proto__=GeneratorFunctionPrototype,define(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t;},e.awrap=function(t){return{__await:t};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this;}),e.AsyncIterator=AsyncIterator,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new AsyncIterator(wrap(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next();});},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this;}),define(g,"toString",function(){return"[object Generator]";}),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function next(){for(;r.length;){var t=r.pop();if(t in e)return next.value=t,next.done=!1,next;}return next.done=!0,next;};},e.values=values,Context.prototype={constructor:Context,reset:function reset(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(e){if(this.done)throw e;var r=this;function handle(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o;}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}else if(c){if(this.prev<i.catchLoc)return handle(i.catchLoc,!0);}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return handle(i.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break;}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y;}},"catch":function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r);}return o;}}throw Error("illegal catch attempt");},delegateYield:function delegateYield(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y;}},e;}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}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.html;},function(_litDecoratorsJs){s=_litDecoratorsJs.query;e=_litDecoratorsJs.property;n=_litDecoratorsJs.customElement;},function(_nileDropdownCssCjsJs){o=_nileDropdownCssCjsJs.s;},function(_internalAnimateCjsJs){h=_internalAnimateCjsJs.s;a=_internalAnimateCjsJs.a;},function(_litDirectivesClassMapJs){r=_litDirectivesClassMapJs.classMap;},function(_utilitiesAnimationRegistryCjsJs){l=_utilitiesAnimationRegistryCjsJs.s;d=_utilitiesAnimationRegistryCjsJs.g;},function(_internalTabbableCjsJs){p=_internalTabbableCjsJs.g;},function(_internalEventCjsJs){c=_internalEventCjsJs.w;},function(_internalWatchCjsJs){m=_internalWatchCjsJs.w;},function(_internalNileElementCjsJs){u=_internalNileElementCjsJs.N;},function(_nilePopupNilePopupCjsJs){},function(_portalManagerCjsJs){f=_portalManagerCjsJs.D;},function(_utilitiesVisibilityManagerCjsJs){w=_utilitiesVisibilityManagerCjsJs.V;},function(_floatingUiDom001CjsJs){},function(_nilePopupNilePopupCssCjsJs){},function(_portalUtilsCjsJs){}],execute:function execute(){_export("N",y=/*#__PURE__*/function(_u){function y(){var _this;_classCallCheck(this,y);_this=_callSuper(this,y,arguments),_this.open=!1,_this.placement="bottom-start",_this.disabled=!1,_this.stayOpenOnSelect=!1,_this.distance=0,_this.noOpenOnClick=!1,_this.skidding=0,_this.hoist=!1,_this.portal=!1,_this.enableVisibilityEffect=!1,_this.enableTabClose=!1,_this.portalManager=null;return _this;}_inherits(y,_u);return _createClass(y,[{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_superPropGet(y,"connectedCallback",this,3)([]),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame(function(){_this2.portal&&!_this2.portalManager&&(_this2.portalManager=new f(_this2));});}},{key:"firstUpdated",value:function(){var _firstUpdated=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(t){var _this3=this;var i;return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:this.panel.hidden=!this.open;this.open&&(this.addOpenListeners(),this.popup.active=!0);_context2.next=4;return this.updateComplete;case 4:i=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new w({host:this,target:i||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:function isOpen(){return _this3.open;},onAnchorOutOfView:function onAnchorOutOfView(){_this3.hide(),_this3.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"});},onDocumentHidden:function onDocumentHidden(){_this3.hide(),_this3.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"});},emit:function emit(t,i){return _this3.emit("nile-".concat(t),i);}});case 6:case"end":return _context2.stop();}},_callee,this);}));function firstUpdated(_x){return _firstUpdated.apply(this,arguments);}return firstUpdated;}()},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this$visibilityManag;_superPropGet(y,"disconnectedCallback",this,3)([]),(_this$visibilityManag=this.visibilityManager)!==null&&_this$visibilityManag!==void 0&&_this$visibilityManag.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null);}},{key:"focusOnTrigger",value:function focusOnTrigger(){var t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(t===null||t===void 0?void 0:t.focus)&&t.focus();}},{key:"getMenu",value:function getMenu(){return this.panel.assignedElements({flatten:!0}).find(function(t){return"nile-menu"===t.tagName.toLowerCase();});}},{key:"handleKeyDown",value:function handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger());}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(t){var _this4=this;if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){var _document$activeEleme;if(this.open&&"nile-menu-item"===((_document$activeEleme=document.activeElement)===null||_document$activeEleme===void 0?void 0:_document$activeEleme.tagName.toLowerCase()))return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout(function(){var _this4$containingElem,_document$activeEleme2,_this4$portalManager;var t=((_this4$containingElem=_this4.containingElement)===null||_this4$containingElem===void 0?void 0:_this4$containingElem.getRootNode())instanceof ShadowRoot?(_document$activeEleme2=document.activeElement)===null||_document$activeEleme2===void 0||(_document$activeEleme2=_document$activeEleme2.shadowRoot)===null||_document$activeEleme2===void 0?void 0:_document$activeEleme2.activeElement:document.activeElement,i=_this4.containingElement&&(t===null||t===void 0?void 0:t.closest(_this4.containingElement.tagName.toLowerCase()))===_this4.containingElement,s=_this4.portal&&((_this4$portalManager=_this4.portalManager)===null||_this4$portalManager===void 0?void 0:_this4$portalManager.portalContainerElement)&&(t===_this4.portalManager.portalContainerElement||(t===null||t===void 0?void 0:t.closest(".nile-dropdown-portal-append"))===_this4.portalManager.portalContainerElement);i||s||_this4.hide();});}}},{key:"handleDocumentMouseDown",value:function handleDocumentMouseDown(t){var _this$portalManager;var i=t.composedPath(),s=this.containingElement&&i.includes(this.containingElement),e=this.portal&&((_this$portalManager=this.portalManager)===null||_this$portalManager===void 0?void 0:_this$portalManager.portalContainerElement)&&i.includes(this.portalManager.portalContainerElement);s||e||this.hide();}},{key:"handlePanelSelect",value:function handlePanelSelect(t){var i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===i.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger());}},{key:"handleTriggerClick",value:function handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()));}},{key:"handleTriggerKeyDown",value:function handleTriggerKeyDown(t){var i=this.getMenu();if(i){var _s=i.getAllItems(),_e=_s[0],_n=_s[_s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),_s.length>0&&this.updateComplete.then(function(){"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(_e),_e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(_n),_n.focus());}));}}},{key:"handleTriggerKeyUp",value:function handleTriggerKeyUp(t){" "===t.key&&t.preventDefault();}},{key:"handleTriggerSlotChange",value:function handleTriggerSlotChange(){this.updateAccessibleTrigger();}},{key:"updateAccessibleTrigger",value:function updateAccessibleTrigger(){var t=this.trigger.assignedElements({flatten:!0}).find(function(t){return p(t).start;});var i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t;}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false");}}},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(this.open){_context3.next=2;break;}return _context3.abrupt("return",(this.open=!0,c(this,"nile-after-show")));case 2:case"end":return _context3.stop();}},_callee2,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!this.open){_context4.next=2;break;}return _context4.abrupt("return",(this.open=!1,c(this,"nile-after-hide")));case 2:case"end":return _context4.stop();}},_callee3,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"reposition",value:function reposition(){this.popup.reposition();}},{key:"addOpenListeners",value:function addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"removeOpenListeners",value:function removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown);}},{key:"updated",value:function updated(t){_superPropGet(y,"updated",this,3)([t]),t.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new f(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),t.has("disabled")&&this.updateTriggerDisabledState();}},{key:"updateTriggerDisabledState",value:function updateTriggerDisabledState(){var t=this.querySelector('[slot="trigger"]');if(!t)return;var i=t.hasAttribute("disabled");(this.disabled||i)&&(t.disabled=!0,this.disabled=!0);}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _this$visibilityManag2;var _d,_t,_i,_this$visibilityManag3,_d2,_t2,_i2;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:if(!((_this$visibilityManag2=this.visibilityManager)!==null&&_this$visibilityManag2!==void 0&&_this$visibilityManag2.setup(),this.disabled)){_context5.next=4;break;}this.open=!1;_context5.next=31;break;case 4:if(!(this.updateAccessibleTrigger(),this.open)){_context5.next=18;break;}this.emit("nile-show");this.addOpenListeners();this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new f(this),this.portalManager.setupPortalAppend());_context5.next=10;return h(this);case 10:if(this.portal){_context5.next=15;break;}this.panel.hidden=!1,this.popup.active=!0;_d=d(this,"dropdown.show",{dir:""}),_t=_d.keyframes,_i=_d.options;_context5.next=15;return a(this.popup.popup,_t,_i);case 15:this.emit("nile-after-show");_context5.next=31;break;case 18:this.emit("nile-hide");this.removeOpenListeners();(_this$visibilityManag3=this.visibilityManager)!==null&&_this$visibilityManag3!==void 0&&_this$visibilityManag3.cleanup();this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend();_context5.next=24;return h(this);case 24:if(this.portal){_context5.next=30;break;}_d2=d(this,"dropdown.hide",{dir:""}),_t2=_d2.keyframes,_i2=_d2.options;_context5.next=28;return a(this.popup.popup,_t2,_i2);case 28:this.panel.hidden=!0;this.popup.active=!1;case 30:this.emit("nile-after-hide");case 31:case"end":return _context5.stop();}},_callee4,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"render",value:function render(){return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=","\n distance=","\n skidding=","\n strategy=","\n sync=","\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=","\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=","\n @keydown=","\n @keyup=","\n @slotchange=","\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=","\n aria-labelledby=\"dropdown\"\n style=","\n ></slot>\n </nile-popup>\n "])),this.placement,this.distance,this.skidding,this.hoist?"fixed":"absolute",this.sync,r({dropdown:!0,"dropdown--open":this.open}),this.handleTriggerClick,this.handleTriggerKeyDown,this.handleTriggerKeyUp,this.handleTriggerSlotChange,this.open?"false":"true",this.portal&&this.portalManager?"display: none;":"");}}]);}(u));y.styles=o,t([s(".dropdown")],y.prototype,"popup",void 0),t([s(".dropdown__trigger")],y.prototype,"trigger",void 0),t([s(".dropdown__panel")],y.prototype,"panel",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"open",void 0),t([e({reflect:!0})],y.prototype,"placement",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"disabled",void 0),t([e({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],y.prototype,"stayOpenOnSelect",void 0),t([e({attribute:!1})],y.prototype,"containingElement",void 0),t([e({type:Number})],y.prototype,"distance",void 0),t([e({type:Boolean})],y.prototype,"noOpenOnClick",void 0),t([e({type:Number})],y.prototype,"skidding",void 0),t([e()],y.prototype,"sync",void 0),t([e({type:Boolean})],y.prototype,"hoist",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"portal",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"enableVisibilityEffect",void 0),t([e({type:Boolean,reflect:!0})],y.prototype,"enableTabClose",void 0),t([m("open",{waitUntilFirstUpdate:!0})],y.prototype,"handleOpenChange",null),_export("N",y=t([n("nile-dropdown")],y)),l("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),l("dropdown.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
2
2
  //# sourceMappingURL=nile-dropdown.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-dropdown.cjs.js","sources":["../../../src/nile-dropdown/nile-dropdown.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, html, CSSResultArray, TemplateResult, PropertyValues} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport {styles} from './nile-dropdown.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\nimport { DropdownPortalManager } from './portal-manager';\nimport { VisibilityManager } from '../utilities/visibility-manager.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-dropdown\n * @summary Dropdowns expose additional content that \"drops down\" in a panel.\n * @dependency nile-popup\n *\n * @slot - The dropdown's main content.\n * @slot trigger - The dropdown's trigger, usually a `<nile-button>` element.\n *\n * @event nile-show - Emitted when the dropdown opens.\n * @event nile-after-show - Emitted after the dropdown opens and all animations are complete.\n * @event nile-hide - Emitted when the dropdown closes.\n * @event nile-after-hide - Emitted after the dropdown closes and all animations are complete.\n *\n * @csspart base - The component's base wrapper.\n * @csspart trigger - The container that wraps the trigger.\n * @csspart panel - The panel that gets shown when the dropdown is open.\n *\n * @animation dropdown.show - The animation to use when showing the dropdown.\n * @animation dropdown.hide - The animation to use when hiding the dropdown.\n */\n@customElement('nile-dropdown')\nexport class NileDropdown extends NileElement {\n static styles: CSSResultGroup = styles;\n\n @query('.dropdown') popup: NilePopup;\n @query('.dropdown__trigger') trigger: HTMLSlotElement;\n @query('.dropdown__panel') panel: HTMLSlotElement;\n\n\n /**\n * Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you\n * can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel\n * inside of the viewport.\n */\n @property({ reflect: true }) placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'bottom-start';\n\n /** Disables the dropdown so the panel will not open. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for\n * dropdowns that allow for multiple interactions.\n */\n @property({ attribute: 'stay-open-on-select', type: Boolean, reflect: true }) stayOpenOnSelect = false;\n\n /**\n * The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other\n * components that use a dropdown internally.\n */\n @property({ attribute: false }) containingElement?: HTMLElement;\n\n /** The distance in pixels from which to offset the panel away from its trigger. */\n @property({ type: Number }) distance = 0;\n\n\n @property({ type: Boolean }) noOpenOnClick = false;\n\n /** The distance in pixels from which to offset the panel along its trigger. */\n @property({ type: Number }) skidding = 0;\n\n /** Syncs the popup's width or height to that of the anchor element. */\n @property() sync: 'width' | 'height' | 'both';\n\n /**\n * Enable this option to prevent the panel from being clipped when the component is placed inside a container with\n * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.\n */\n @property({ type: Boolean }) hoist = false;\n\n /**\n * Enable portal mode to render the dropdown panel in a portal outside the component's DOM tree.\n * This provides better positioning control and prevents clipping issues in complex layouts.\n */\n @property({ type: Boolean, reflect: true }) portal = false;\n\n @property({ type: Boolean, reflect: true }) enableVisibilityEffect = false;\n\n @property({ type: Boolean, reflect: true }) enableTabClose = false;\n\n\n private portalManager: DropdownPortalManager | null = null;\n private visibilityManager?: VisibilityManager;\n\n connectedCallback() {\n super.connectedCallback();\n this.handlePanelSelect = this.handlePanelSelect.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);\n\n if (!this.containingElement) {\n this.containingElement = this;\n }\n this.emit('nile-init');\n\n requestAnimationFrame(() => {\n if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n }\n });\n }\n\n protected async firstUpdated(_changed: PropertyValues) {\n \n this.panel.hidden = !this.open;\n\n // If the dropdown is visible on init, update its position\n if (this.open) {\n this.addOpenListeners();\n this.popup.active = true;\n }\n \n await this.updateComplete;\n const triggerNode = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n \n this.visibilityManager = new VisibilityManager({\n host: this,\n target: triggerNode || null,\n enableVisibilityEffect: this.enableVisibilityEffect,\n enableTabClose: this.enableTabClose,\n isOpen: () => this.open,\n onAnchorOutOfView: () => {\n this.hide();\n this.emit('nile-visibility-change', {\n visible: false,\n reason: 'anchor-out-of-view',\n });\n },\n onDocumentHidden: () => {\n this.hide();\n this.emit('nile-visibility-change', {\n visible: false,\n reason: 'document-hidden',\n });\n },\n emit: (event, detail) => this.emit(`nile-${event}`, detail),\n });\n }\n \n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.visibilityManager?.cleanup();\n this.removeOpenListeners();\n this.hide();\n this.emit('nile-destroy');\n\n if (this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n this.portalManager = null;\n }\n }\n\n focusOnTrigger() {\n const trigger = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n if (typeof trigger?.focus === 'function') {\n trigger.focus();\n }\n }\n\n getMenu() {\n return this.panel.assignedElements({ flatten: true }).find(el => el.tagName.toLowerCase() === 'nile-menu') as\n | NileMenu\n | undefined;\n }\n\n handleKeyDown(event: KeyboardEvent) {\n // Close when escape is pressed inside an open dropdown. We need to listen on the panel itself and stop propagation\n // in case any ancestors are also listening for this key.\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n // Close when escape or tab is pressed\n if (event.key === 'Escape' && this.open) {\n event.stopPropagation();\n this.focusOnTrigger();\n this.hide();\n return;\n }\n\n // Handle tabbing\n if (event.key === 'Tab') {\n // Tabbing within an open menu should close the dropdown and refocus the trigger\n if (this.open && document.activeElement?.tagName.toLowerCase() === 'nile-menu-item') {\n event.preventDefault();\n this.hide();\n this.focusOnTrigger();\n return;\n }\n\n // Tabbing outside of the containing element closes the panel\n //\n // If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,\n // otherwise `document.activeElement` will only return the name of the parent shadow DOM element.\n setTimeout(() => {\n const activeElement =\n this.containingElement?.getRootNode() instanceof ShadowRoot\n ? document.activeElement?.shadowRoot?.activeElement\n : document.activeElement;\n\n const hitSelf = this.containingElement && activeElement?.closest(this.containingElement.tagName.toLowerCase()) === this.containingElement;\n const hitPortalAppend = this.portal && this.portalManager?.portalContainerElement && \n (activeElement === this.portalManager.portalContainerElement || \n activeElement?.closest('.nile-dropdown-portal-append') === this.portalManager.portalContainerElement);\n\n if (!hitSelf && !hitPortalAppend) {\n this.hide();\n }\n });\n }\n }\n\n handleDocumentMouseDown(event: MouseEvent) {\n // Close when clicking outside of the containing element\n const path = event.composedPath();\n const hitSelf = this.containingElement && path.includes(this.containingElement);\n const hitPortalAppend = this.portal && this.portalManager?.portalContainerElement && path.includes(this.portalManager.portalContainerElement);\n\n if (!hitSelf && !hitPortalAppend) {\n this.hide();\n }\n }\n\n handlePanelSelect(event: any) {\n const target = event.target as HTMLElement;\n\n // Hide the dropdown when a menu item is selected\n if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.hide();\n this.focusOnTrigger();\n } else if(this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerClick() {\n if(this.noOpenOnClick){\n return;\n }\n if (this.open) {\n this.hide();\n } else {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerKeyDown(event: KeyboardEvent) {\n // When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same\n // key again to hide the menu in case they don't want to make a selection.\n // if (['Enter'].includes(event.key)) {\n // event.preventDefault();\n // this.handleTriggerClick();\n // return;\n // }\n\n const menu = this.getMenu();\n\n if (menu) {\n const menuItems = menu.getAllItems();\n const firstMenuItem = menuItems[0];\n const lastMenuItem = menuItems[menuItems.length - 1];\n\n // When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a\n // selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for\n // faster navigation.\n if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n\n // Show the menu if it's not already open\n if (!this.open) {\n this.show();\n }\n\n if (menuItems.length > 0) {\n // Focus on the first/last menu item after showing\n this.updateComplete.then(() => {\n if (event.key === 'ArrowDown' || event.key === 'Home') {\n menu.setCurrentItem(firstMenuItem);\n firstMenuItem.focus();\n }\n\n if (event.key === 'ArrowUp' || event.key === 'End') {\n menu.setCurrentItem(lastMenuItem);\n lastMenuItem.focus();\n }\n });\n }\n }\n }\n }\n\n handleTriggerKeyUp(event: KeyboardEvent) {\n // Prevent space from triggering a click event in Firefox\n if (event.key === ' ') {\n event.preventDefault();\n }\n }\n\n handleTriggerSlotChange() {\n this.updateAccessibleTrigger();\n }\n\n //\n // Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and\n // `aria-expanded`. These must be applied to the \"accessible trigger\" (the tabbable portion of the trigger element\n // that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,\n // a child of the slotted element, or an element in the slotted element's shadow root.\n //\n // For example, the accessible trigger of an <nile-button> is a <button> located inside its shadow root.\n //\n // To determine this, we assume the first tabbable element in the trigger slot is the \"accessible trigger.\"\n //\n updateAccessibleTrigger() {\n const assignedElements = this.trigger.assignedElements({ flatten: true }) as HTMLElement[];\n const accessibleTrigger = assignedElements.find(el => getTabbableBoundary(el).start);\n let target: HTMLElement;\n\n if (accessibleTrigger) {\n switch (accessibleTrigger.tagName.toLowerCase()) {\n // nile buttons have to update the internal button so it's announced correctly by screen readers\n case 'nile-button':\n case 'nile-icon-button':\n target = (accessibleTrigger as NileButton | NileIconButton).button;\n break;\n\n default:\n target = accessibleTrigger;\n }\n\n target.setAttribute('aria-haspopup', 'true');\n target.setAttribute('aria-expanded', this.open ? 'true' : 'false');\n }\n }\n\n /** Shows the dropdown panel. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dropdown panel */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n /**\n * Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu\n * is activated.\n */\n reposition() {\n this.popup.reposition();\n }\n\n addOpenListeners() {\n this.panel.addEventListener('nile-select', this.handlePanelSelect);\n this.panel.addEventListener('keydown', this.handleKeyDown);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n document.addEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n removeOpenListeners() {\n if (this.panel) {\n this.panel.removeEventListener('nile-select', this.handlePanelSelect);\n this.panel.removeEventListener('keydown', this.handleKeyDown);\n }\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n document.removeEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n \n if (changedProperties.has('portal')) {\n if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n if (this.open) {\n this.portalManager.setupPortalAppend();\n }\n } else if (!this.portal && this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n this.portalManager = null;\n }\n }\n if (changedProperties.has('disabled')) {\n this.updateTriggerDisabledState();\n }\n }\n \n private updateTriggerDisabledState() {\n const trigger = this.querySelector('[slot=\"trigger\"]') as HTMLElement | null;\n if (!trigger) return;\n if ('disabled' in trigger) {\n (trigger as any).disabled = this.disabled;\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n this.visibilityManager?.setup();\n if (this.disabled) {\n this.open = false;\n return;\n }\n\n this.updateAccessibleTrigger();\n\n if (this.open) {\n // Show\n this.emit('nile-show');\n this.addOpenListeners();\n\n if (this.portal && this.portalManager) {\n this.portalManager.setupPortalAppend();\n } else if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n this.portalManager.setupPortalAppend();\n }\n\n await stopAnimations(this);\n \n // Only show panel and animate if not using portal\n if (!this.portal) {\n this.panel.hidden = false;\n this.popup.active = true;\n const { keyframes, options } = getAnimation(this, 'dropdown.show', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n }\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n this.visibilityManager?.cleanup();\n\n if (this.portal && this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n }\n\n await stopAnimations(this);\n \n // Only hide panel and animate if not using portal\n if (!this.portal) {\n const { keyframes, options } = getAnimation(this, 'dropdown.hide', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n this.panel.hidden = true;\n this.popup.active = false;\n }\n\n this.emit('nile-after-hide');\n }\n }\n\n render() {\n return html`\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=${this.placement}\n distance=${this.distance}\n skidding=${this.skidding}\n strategy=${this.hoist ? 'fixed' : 'absolute'}\n sync=${this.sync}\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': this.open\n })}\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=${this.handleTriggerClick}\n @keydown=${this.handleTriggerKeyDown}\n @keyup=${this.handleTriggerKeyUp}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-labelledby=\"dropdown\"\n style=${this.portal && this.portalManager ? 'display: none;' : ''}\n ></slot>\n </nile-popup>\n `;\n }\n}\n\nsetDefaultAnimation('dropdown.show', {\n keyframes: [\n { opacity: 0, scale: 0.9 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nsetDefaultAnimation('dropdown.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.9 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nexport default NileDropdown;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dropdown': NileDropdown;\n }\n}\n"],"names":["NileDropdown","y","this","open","placement","disabled","stayOpenOnSelect","distance","noOpenOnClick","skidding","hoist","portal","enableVisibilityEffect","enableTabClose","portalManager","_this","_inherits","_u","_createClass","key","value","connectedCallback","super","handlePanelSelect","bind","handleKeyDown","handleDocumentKeyDown","handleDocumentMouseDown","containingElement","emit","requestAnimationFrame","DropdownPortalManager","_firstUpdated","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_changed","panel","hidden","addOpenListeners","popup","active","updateComplete","triggerNode","trigger","assignedElements","flatten","visibilityManager","VisibilityManager","host","target","isOpen","onAnchorOutOfView","hide","visible","reason","onDocumentHidden","event","detail","_context2","stop","firstUpdated","disconnectedCallback","cleanup","removeOpenListeners","cleanupPortalAppend","focusOnTrigger","focus","getMenu","find","el","tagName","toLowerCase","stopPropagation","_document$activeEleme","document","activeElement","preventDefault","setTimeout","_this4$containingElem","_document$activeEleme2","_this4$portalManager","getRootNode","ShadowRoot","shadowRoot","hitSelf","closest","hitPortalAppend","portalContainerElement","path","composedPath","includes","show","handleTriggerClick","handleTriggerKeyDown","menu","menuItems","getAllItems","firstMenuItem","lastMenuItem","length","then","setCurrentItem","handleTriggerKeyUp","handleTriggerSlotChange","updateAccessibleTrigger","accessibleTrigger","getTabbableBoundary","start","button","setAttribute","_show","_callee2","wrap","_callee2$","_context3","prev","next","waitForEvent","_callee3","_callee3$","_context4","reposition","addEventListener","removeEventListener","updated","changedProperties","has","setupPortalAppend","updateTriggerDisabledState","querySelector","_handleOpenChange","_callee4","_this$visibilityManag2","_d","_t","_i","_this$visibilityManag3","_d2","_t2","_i2","_callee4$","_context5","setup","stopAnimations","getAnimation","dir","keyframes","options","animateTo","handleOpenChange","render","html","_templateObject","_taggedTemplateLiteral","sync","classMap","dropdown","NileElement","styles","__decorate","query","prototype","property","type","Boolean","reflect","attribute","Number","watch","waitUntilFirstUpdate","customElement","setDefaultAnimation","opacity","scale","duration","easing"],"mappings":"qxZAkDaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,uEAYuCC,KAAAA,CAAIC,IAAAA,CAAAA,CAAG,EAMtBD,KAAAA,CAASE,SAAAA,CAYrB,cAG2BF,CAAAA,KAAAA,CAAQG,QAAG,CAAA,CAAA,CAAA,CAMuBH,KAAAA,CAAgBI,gBAAG,CAAA,CAAA,CAAA,CASrEJ,KAAAA,CAAQK,QAAG,CAAA,CAAA,CAGVL,KAAAA,CAAaM,aAAG,CAAA,CAAA,CAAA,CAGjBN,KAAAA,CAAQO,QAAAA,CAAG,CASVP,CAAAA,KAAAA,CAAKQ,OAAG,CAMOR,CAAAA,KAAAA,CAAMS,QAAG,CAETT,CAAAA,KAAAA,CAAsBU,wBAA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A,KAAAA,CAAAA,CAAYiK,CAAA,CAAA,CADxBW,CAAc,CAAA,eAAA,CAAA,CAAA,CACF5K,IA2fb6K,CAAoB,CAAA,eAAA,CAAiB,CACnCzB,SAAAA,CAAW,CACT,CAAE0B,OAAS,CAAA,CAAA,CAAGC,KAAO,CAAA,EAAA,CAAA,CACrB,CAAED,OAAAA,CAAS,CAAGC,CAAAA,KAAAA,CAAO,IAEvB1B,OAAS,CAAA,CAAE2B,QAAU,CAAA,GAAA,CAAKC,MAAQ,CAAA,MAAA,CAAA,CAAA,CAAA,CAGpCJ,EAAoB,eAAiB,CAAA,CACnCzB,SAAW,CAAA,CACT,CAAE0B,OAAAA,CAAS,EAAGC,KAAO,CAAA,CAAA,CAAA,CACrB,CAAED,OAAAA,CAAS,CAAGC,CAAAA,KAAAA,CAAO,EAEvB1B,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAE2B,QAAAA,CAAU,GAAKC,CAAAA,MAAAA,CAAQ"}
1
+ {"version":3,"file":"nile-dropdown.cjs.js","sources":["../../../src/nile-dropdown/nile-dropdown.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, html, CSSResultArray, TemplateResult, PropertyValues} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport {styles} from './nile-dropdown.css';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { getTabbableBoundary } from '../internal/tabbable';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\nimport type NileButton from '../nile-button/nile-button';\nimport type NileIconButton from '../nile-icon-button/nile-icon-button';\nimport type { NileMenu } from '../nile-menu';\nimport type { NilePopup } from '../nile-popup';\nimport '../nile-popup';\nimport { DropdownPortalManager } from './portal-manager';\nimport { VisibilityManager } from '../utilities/visibility-manager.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-dropdown\n * @summary Dropdowns expose additional content that \"drops down\" in a panel.\n * @dependency nile-popup\n *\n * @slot - The dropdown's main content.\n * @slot trigger - The dropdown's trigger, usually a `<nile-button>` element.\n *\n * @event nile-show - Emitted when the dropdown opens.\n * @event nile-after-show - Emitted after the dropdown opens and all animations are complete.\n * @event nile-hide - Emitted when the dropdown closes.\n * @event nile-after-hide - Emitted after the dropdown closes and all animations are complete.\n *\n * @csspart base - The component's base wrapper.\n * @csspart trigger - The container that wraps the trigger.\n * @csspart panel - The panel that gets shown when the dropdown is open.\n *\n * @animation dropdown.show - The animation to use when showing the dropdown.\n * @animation dropdown.hide - The animation to use when hiding the dropdown.\n */\n@customElement('nile-dropdown')\nexport class NileDropdown extends NileElement {\n static styles: CSSResultGroup = styles;\n\n @query('.dropdown') popup: NilePopup;\n @query('.dropdown__trigger') trigger: HTMLSlotElement;\n @query('.dropdown__panel') panel: HTMLSlotElement;\n\n\n /**\n * Indicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you\n * can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel\n * inside of the viewport.\n */\n @property({ reflect: true }) placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'bottom-start';\n\n /** Disables the dropdown so the panel will not open. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * By default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for\n * dropdowns that allow for multiple interactions.\n */\n @property({ attribute: 'stay-open-on-select', type: Boolean, reflect: true }) stayOpenOnSelect = false;\n\n /**\n * The dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other\n * components that use a dropdown internally.\n */\n @property({ attribute: false }) containingElement?: HTMLElement;\n\n /** The distance in pixels from which to offset the panel away from its trigger. */\n @property({ type: Number }) distance = 0;\n\n\n @property({ type: Boolean }) noOpenOnClick = false;\n\n /** The distance in pixels from which to offset the panel along its trigger. */\n @property({ type: Number }) skidding = 0;\n\n /** Syncs the popup's width or height to that of the anchor element. */\n @property() sync: 'width' | 'height' | 'both';\n\n /**\n * Enable this option to prevent the panel from being clipped when the component is placed inside a container with\n * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.\n */\n @property({ type: Boolean }) hoist = false;\n\n /**\n * Enable portal mode to render the dropdown panel in a portal outside the component's DOM tree.\n * This provides better positioning control and prevents clipping issues in complex layouts.\n */\n @property({ type: Boolean, reflect: true }) portal = false;\n\n @property({ type: Boolean, reflect: true }) enableVisibilityEffect = false;\n\n @property({ type: Boolean, reflect: true }) enableTabClose = false;\n\n\n private portalManager: DropdownPortalManager | null = null;\n private visibilityManager?: VisibilityManager;\n\n connectedCallback() {\n super.connectedCallback();\n this.handlePanelSelect = this.handlePanelSelect.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);\n\n if (!this.containingElement) {\n this.containingElement = this;\n }\n this.emit('nile-init');\n\n requestAnimationFrame(() => {\n if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n }\n });\n }\n\n protected async firstUpdated(_changed: PropertyValues) {\n \n this.panel.hidden = !this.open;\n\n // If the dropdown is visible on init, update its position\n if (this.open) {\n this.addOpenListeners();\n this.popup.active = true;\n }\n \n await this.updateComplete;\n const triggerNode = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n \n this.visibilityManager = new VisibilityManager({\n host: this,\n target: triggerNode || null,\n enableVisibilityEffect: this.enableVisibilityEffect,\n enableTabClose: this.enableTabClose,\n isOpen: () => this.open,\n onAnchorOutOfView: () => {\n this.hide();\n this.emit('nile-visibility-change', {\n visible: false,\n reason: 'anchor-out-of-view',\n });\n },\n onDocumentHidden: () => {\n this.hide();\n this.emit('nile-visibility-change', {\n visible: false,\n reason: 'document-hidden',\n });\n },\n emit: (event, detail) => this.emit(`nile-${event}`, detail),\n });\n }\n \n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.visibilityManager?.cleanup();\n this.removeOpenListeners();\n this.hide();\n this.emit('nile-destroy');\n\n if (this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n this.portalManager = null;\n }\n }\n\n focusOnTrigger() {\n const trigger = this.trigger.assignedElements({ flatten: true })[0] as HTMLElement | undefined;\n if (typeof trigger?.focus === 'function') {\n trigger.focus();\n }\n }\n\n getMenu() {\n return this.panel.assignedElements({ flatten: true }).find(el => el.tagName.toLowerCase() === 'nile-menu') as\n | NileMenu\n | undefined;\n }\n\n handleKeyDown(event: KeyboardEvent) {\n // Close when escape is pressed inside an open dropdown. We need to listen on the panel itself and stop propagation\n // in case any ancestors are also listening for this key.\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.hide();\n this.focusOnTrigger();\n }\n }\n\n handleDocumentKeyDown(event: KeyboardEvent) {\n // Close when escape or tab is pressed\n if (event.key === 'Escape' && this.open) {\n event.stopPropagation();\n this.focusOnTrigger();\n this.hide();\n return;\n }\n\n // Handle tabbing\n if (event.key === 'Tab') {\n // Tabbing within an open menu should close the dropdown and refocus the trigger\n if (this.open && document.activeElement?.tagName.toLowerCase() === 'nile-menu-item') {\n event.preventDefault();\n this.hide();\n this.focusOnTrigger();\n return;\n }\n\n // Tabbing outside of the containing element closes the panel\n //\n // If the dropdown is used within a shadow DOM, we need to obtain the activeElement within that shadowRoot,\n // otherwise `document.activeElement` will only return the name of the parent shadow DOM element.\n setTimeout(() => {\n const activeElement =\n this.containingElement?.getRootNode() instanceof ShadowRoot\n ? document.activeElement?.shadowRoot?.activeElement\n : document.activeElement;\n\n const hitSelf = this.containingElement && activeElement?.closest(this.containingElement.tagName.toLowerCase()) === this.containingElement;\n const hitPortalAppend = this.portal && this.portalManager?.portalContainerElement && \n (activeElement === this.portalManager.portalContainerElement || \n activeElement?.closest('.nile-dropdown-portal-append') === this.portalManager.portalContainerElement);\n\n if (!hitSelf && !hitPortalAppend) {\n this.hide();\n }\n });\n }\n }\n\n handleDocumentMouseDown(event: MouseEvent) {\n // Close when clicking outside of the containing element\n const path = event.composedPath();\n const hitSelf = this.containingElement && path.includes(this.containingElement);\n const hitPortalAppend = this.portal && this.portalManager?.portalContainerElement && path.includes(this.portalManager.portalContainerElement);\n\n if (!hitSelf && !hitPortalAppend) {\n this.hide();\n }\n }\n\n handlePanelSelect(event: any) {\n const target = event.target as HTMLElement;\n\n // Hide the dropdown when a menu item is selected\n if (!this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.hide();\n this.focusOnTrigger();\n } else if(this.stayOpenOnSelect && target.tagName.toLowerCase() === 'nile-menu') {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerClick() {\n if(this.noOpenOnClick){\n return;\n }\n if (this.open) {\n this.hide();\n } else {\n this.show();\n this.focusOnTrigger();\n }\n }\n\n handleTriggerKeyDown(event: KeyboardEvent) {\n // When spacebar/enter is pressed, show the panel but don't focus on the menu. This let's the user press the same\n // key again to hide the menu in case they don't want to make a selection.\n // if (['Enter'].includes(event.key)) {\n // event.preventDefault();\n // this.handleTriggerClick();\n // return;\n // }\n\n const menu = this.getMenu();\n\n if (menu) {\n const menuItems = menu.getAllItems();\n const firstMenuItem = menuItems[0];\n const lastMenuItem = menuItems[menuItems.length - 1];\n\n // When up/down is pressed, we make the assumption that the user is familiar with the menu and plans to make a\n // selection. Rather than toggle the panel, we focus on the menu (if one exists) and activate the first item for\n // faster navigation.\n if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n\n // Show the menu if it's not already open\n if (!this.open) {\n this.show();\n }\n\n if (menuItems.length > 0) {\n // Focus on the first/last menu item after showing\n this.updateComplete.then(() => {\n if (event.key === 'ArrowDown' || event.key === 'Home') {\n menu.setCurrentItem(firstMenuItem);\n firstMenuItem.focus();\n }\n\n if (event.key === 'ArrowUp' || event.key === 'End') {\n menu.setCurrentItem(lastMenuItem);\n lastMenuItem.focus();\n }\n });\n }\n }\n }\n }\n\n handleTriggerKeyUp(event: KeyboardEvent) {\n // Prevent space from triggering a click event in Firefox\n if (event.key === ' ') {\n event.preventDefault();\n }\n }\n\n handleTriggerSlotChange() {\n this.updateAccessibleTrigger();\n }\n\n //\n // Slotted triggers can be arbitrary content, but we need to link them to the dropdown panel with `aria-haspopup` and\n // `aria-expanded`. These must be applied to the \"accessible trigger\" (the tabbable portion of the trigger element\n // that gets slotted in) so screen readers will understand them. The accessible trigger could be the slotted element,\n // a child of the slotted element, or an element in the slotted element's shadow root.\n //\n // For example, the accessible trigger of an <nile-button> is a <button> located inside its shadow root.\n //\n // To determine this, we assume the first tabbable element in the trigger slot is the \"accessible trigger.\"\n //\n updateAccessibleTrigger() {\n const assignedElements = this.trigger.assignedElements({ flatten: true }) as HTMLElement[];\n const accessibleTrigger = assignedElements.find(el => getTabbableBoundary(el).start);\n let target: HTMLElement;\n\n if (accessibleTrigger) {\n switch (accessibleTrigger.tagName.toLowerCase()) {\n // nile buttons have to update the internal button so it's announced correctly by screen readers\n case 'nile-button':\n case 'nile-icon-button':\n target = (accessibleTrigger as NileButton | NileIconButton).button;\n break;\n\n default:\n target = accessibleTrigger;\n }\n\n target.setAttribute('aria-haspopup', 'true');\n target.setAttribute('aria-expanded', this.open ? 'true' : 'false');\n }\n }\n\n /** Shows the dropdown panel. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dropdown panel */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n /**\n * Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu\n * is activated.\n */\n reposition() {\n this.popup.reposition();\n }\n\n addOpenListeners() {\n this.panel.addEventListener('nile-select', this.handlePanelSelect);\n this.panel.addEventListener('keydown', this.handleKeyDown);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n document.addEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n removeOpenListeners() {\n if (this.panel) {\n this.panel.removeEventListener('nile-select', this.handlePanelSelect);\n this.panel.removeEventListener('keydown', this.handleKeyDown);\n }\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n document.removeEventListener('mousedown', this.handleDocumentMouseDown);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n \n if (changedProperties.has('portal')) {\n if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n if (this.open) {\n this.portalManager.setupPortalAppend();\n }\n } else if (!this.portal && this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n this.portalManager = null;\n }\n }\n if (changedProperties.has('disabled')) {\n this.updateTriggerDisabledState();\n }\n }\n \n private updateTriggerDisabledState() {\n const trigger = this.querySelector('[slot=\"trigger\"]') as any;\n if (!trigger) return;\n const triggerAlreadyDisabled = trigger.hasAttribute('disabled');\n if (this.disabled || triggerAlreadyDisabled) {\n trigger.disabled = true;\n this.disabled = true;\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n this.visibilityManager?.setup();\n if (this.disabled) {\n this.open = false;\n return;\n }\n\n this.updateAccessibleTrigger();\n\n if (this.open) {\n // Show\n this.emit('nile-show');\n this.addOpenListeners();\n\n if (this.portal && this.portalManager) {\n this.portalManager.setupPortalAppend();\n } else if (this.portal && !this.portalManager) {\n this.portalManager = new DropdownPortalManager(this);\n this.portalManager.setupPortalAppend();\n }\n\n await stopAnimations(this);\n \n // Only show panel and animate if not using portal\n if (!this.portal) {\n this.panel.hidden = false;\n this.popup.active = true;\n const { keyframes, options } = getAnimation(this, 'dropdown.show', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n }\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n this.visibilityManager?.cleanup();\n\n if (this.portal && this.portalManager) {\n this.portalManager.cleanupPortalAppend();\n }\n\n await stopAnimations(this);\n \n // Only hide panel and animate if not using portal\n if (!this.portal) {\n const { keyframes, options } = getAnimation(this, 'dropdown.hide', { dir: '' });\n await animateTo(this.popup.popup, keyframes, options);\n this.panel.hidden = true;\n this.popup.active = false;\n }\n\n this.emit('nile-after-hide');\n }\n }\n\n render() {\n return html`\n <nile-popup\n part=\"base\"\n id=\"dropdown\"\n placement=${this.placement}\n distance=${this.distance}\n skidding=${this.skidding}\n strategy=${this.hoist ? 'fixed' : 'absolute'}\n sync=${this.sync}\n flip\n shift\n auto-size=\"both\"\n auto-size-padding=\"10\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': this.open\n })}\n >\n <slot\n name=\"trigger\"\n slot=\"anchor\"\n part=\"trigger\"\n class=\"dropdown__trigger\"\n @click=${this.handleTriggerClick}\n @keydown=${this.handleTriggerKeyDown}\n @keyup=${this.handleTriggerKeyUp}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n\n <slot\n part=\"panel\"\n class=\"dropdown__panel\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-labelledby=\"dropdown\"\n style=${this.portal && this.portalManager ? 'display: none;' : ''}\n ></slot>\n </nile-popup>\n `;\n }\n}\n\nsetDefaultAnimation('dropdown.show', {\n keyframes: [\n { opacity: 0, scale: 0.9 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nsetDefaultAnimation('dropdown.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.9 }\n ],\n options: { duration: 100, easing: 'ease' }\n});\n\nexport default NileDropdown;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dropdown': NileDropdown;\n }\n}\n"],"names":["NileDropdown","y","this","open","placement","disabled","stayOpenOnSelect","distance","noOpenOnClick","skidding","hoist","portal","enableVisibilityEffect","enableTabClose","portalManager","_this","_inherits","_u","_createClass","key","value","connectedCallback","super","handlePanelSelect","bind","handleKeyDown","handleDocumentKeyDown","handleDocumentMouseDown","containingElement","emit","requestAnimationFrame","DropdownPortalManager","_firstUpdated","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_changed","panel","hidden","addOpenListeners","popup","active","_context2","next","updateComplete","triggerNode","trigger","assignedElements","flatten","visibilityManager","VisibilityManager","host","target","isOpen","onAnchorOutOfView","hide","visible","reason","onDocumentHidden","event","detail","stop","firstUpdated","disconnectedCallback","cleanup","removeOpenListeners","cleanupPortalAppend","focusOnTrigger","focus","getMenu","find","el","tagName","toLowerCase","stopPropagation","_this4","_document$activeEleme","document","activeElement","preventDefault","setTimeout","_this4$containingElem","_document$activeEleme2","_this4$portalManager","getRootNode","ShadowRoot","shadowRoot","hitSelf","closest","hitPortalAppend","portalContainerElement","_this$portalManager","path","composedPath","includes","show","handleTriggerClick","handleTriggerKeyDown","menu","menuItems","getAllItems","firstMenuItem","lastMenuItem","length","then","setCurrentItem","handleTriggerKeyUp","handleTriggerSlotChange","updateAccessibleTrigger","accessibleTrigger","getTabbableBoundary","start","button","setAttribute","_show","_callee2","wrap","_callee2$","_context3","prev","waitForEvent","_callee3","_callee3$","_context4","abrupt","reposition","addEventListener","removeEventListener","updated","changedProperties","has","setupPortalAppend","updateTriggerDisabledState","querySelector","triggerAlreadyDisabled","hasAttribute","_handleOpenChange","_callee4","_this$visibilityManag2","_d","_t","_i","_this$visibilityManag3","_d2","_t2","_i2","_callee4$","_context5","setup","stopAnimations","getAnimation","dir","animateTo","keyframes","options","handleOpenChange","render","html","_templateObject","_taggedTemplateLiteral","sync","classMap","dropdown","NileElement","styles","__decorate","query","prototype","property","type","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B,CAAED,OAAAA,CAAS,CAAGC,CAAAA,KAAAA,CAAO,IAEvBzB,OAAS,CAAA,CAAE0B,QAAU,CAAA,GAAA,CAAKC,MAAQ,CAAA,MAAA,CAAA,CAAA,CAAA,CAGpCJ,EAAoB,eAAiB,CAAA,CACnCxB,SAAW,CAAA,CACT,CAAEyB,OAAAA,CAAS,EAAGC,KAAO,CAAA,CAAA,CAAA,CACrB,CAAED,OAAAA,CAAS,CAAGC,CAAAA,KAAAA,CAAO,EAEvBzB,CAAAA,CAAAA,CAAAA,OAAAA,CAAS,CAAE0B,QAAAA,CAAU,GAAKC,CAAAA,MAAAA,CAAQ"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t}from"tslib";import{html as i}from"lit";import{query as s,property as e,customElement as n}from"lit/decorators.js";import{s as o}from"./nile-dropdown.css.esm.js";import{s as h,a}from"../internal/animate.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{s as l,g as d}from"../utilities/animation-registry.esm.js";import{g as p}from"../internal/tabbable.esm.js";import{w as c}from"../internal/event.esm.js";import{w as m}from"../internal/watch.esm.js";import{N as u}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{D as f}from"./portal-manager.esm.js";import{V as w}from"../utilities/visibility-manager.esm.js";import"../floating-ui.dom-cc9126da.esm.js";import"../nile-popup/nile-popup.css.esm.js";import"./portal-utils.esm.js";let y=class extends u{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1,this.portal=!1,this.enableVisibilityEffect=!1,this.enableTabClose=!1,this.portalManager=null}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame((()=>{this.portal&&!this.portalManager&&(this.portalManager=new f(this))}))}async firstUpdated(t){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0),await this.updateComplete;const i=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new w({host:this,target:i||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(t,i)=>this.emit(`nile-${t}`,i)})}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)}focusOnTrigger(){const t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof t?.focus&&t.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((t=>"nile-menu"===t.tagName.toLowerCase()))}handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(t){if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const t=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement,i=this.containingElement&&t?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement,s=this.portal&&this.portalManager?.portalContainerElement&&(t===this.portalManager.portalContainerElement||t?.closest(".nile-dropdown-portal-append")===this.portalManager.portalContainerElement);i||s||this.hide()}))}}handleDocumentMouseDown(t){const i=t.composedPath(),s=this.containingElement&&i.includes(this.containingElement),e=this.portal&&this.portalManager?.portalContainerElement&&i.includes(this.portalManager.portalContainerElement);s||e||this.hide()}handlePanelSelect(t){const i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===i.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(t){const i=this.getMenu();if(i){const s=i.getAllItems(),e=s[0],n=s[s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),s.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(e),e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(n),n.focus())})))}}handleTriggerKeyUp(t){" "===t.key&&t.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const t=this.trigger.assignedElements({flatten:!0}).find((t=>p(t).start));let i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,c(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,c(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}updated(t){super.updated(t),t.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new f(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),t.has("disabled")&&this.updateTriggerDisabledState()}updateTriggerDisabledState(){const t=this.querySelector('[slot="trigger"]');t&&"disabled"in t&&(t.disabled=this.disabled)}async handleOpenChange(){if(this.visibilityManager?.setup(),this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){if(this.emit("nile-show"),this.addOpenListeners(),this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new f(this),this.portalManager.setupPortalAppend()),await h(this),!this.portal){this.panel.hidden=!1,this.popup.active=!0;const{keyframes:t,options:i}=d(this,"dropdown.show",{dir:""});await a(this.popup.popup,t,i)}this.emit("nile-after-show")}else{if(this.emit("nile-hide"),this.removeOpenListeners(),this.visibilityManager?.cleanup(),this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend(),await h(this),!this.portal){const{keyframes:t,options:i}=d(this,"dropdown.hide",{dir:""});await a(this.popup.popup,t,i),this.panel.hidden=!0,this.popup.active=!1}this.emit("nile-after-hide")}}render(){return i`
1
+ import{__decorate as t}from"tslib";import{html as i}from"lit";import{query as s,property as e,customElement as n}from"lit/decorators.js";import{s as o}from"./nile-dropdown.css.esm.js";import{s as h,a}from"../internal/animate.esm.js";import{classMap as r}from"lit/directives/class-map.js";import{s as l,g as d}from"../utilities/animation-registry.esm.js";import{g as p}from"../internal/tabbable.esm.js";import{w as c}from"../internal/event.esm.js";import{w as m}from"../internal/watch.esm.js";import{N as u}from"../internal/nile-element.esm.js";import"../nile-popup/nile-popup.esm.js";import{D as f}from"./portal-manager.esm.js";import{V as w}from"../utilities/visibility-manager.esm.js";import"../floating-ui.dom-cc9126da.esm.js";import"../nile-popup/nile-popup.css.esm.js";import"./portal-utils.esm.js";let y=class extends u{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1,this.portal=!1,this.enableVisibilityEffect=!1,this.enableTabClose=!1,this.portalManager=null}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame((()=>{this.portal&&!this.portalManager&&(this.portalManager=new f(this))}))}async firstUpdated(t){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0),await this.updateComplete;const i=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new w({host:this,target:i||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(t,i)=>this.emit(`nile-${t}`,i)})}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)}focusOnTrigger(){const t=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof t?.focus&&t.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((t=>"nile-menu"===t.tagName.toLowerCase()))}handleKeyDown(t){this.open&&"Escape"===t.key&&(t.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(t){if("Escape"===t.key&&this.open)return t.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===t.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return t.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const t=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement,i=this.containingElement&&t?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement,s=this.portal&&this.portalManager?.portalContainerElement&&(t===this.portalManager.portalContainerElement||t?.closest(".nile-dropdown-portal-append")===this.portalManager.portalContainerElement);i||s||this.hide()}))}}handleDocumentMouseDown(t){const i=t.composedPath(),s=this.containingElement&&i.includes(this.containingElement),e=this.portal&&this.portalManager?.portalContainerElement&&i.includes(this.portalManager.portalContainerElement);s||e||this.hide()}handlePanelSelect(t){const i=t.target;this.stayOpenOnSelect||"nile-menu"!==i.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===i.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(t){const i=this.getMenu();if(i){const s=i.getAllItems(),e=s[0],n=s[s.length-1];["ArrowDown","ArrowUp","Home","End"].includes(t.key)&&(t.preventDefault(),this.open||this.show(),s.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==t.key&&"Home"!==t.key||(i.setCurrentItem(e),e.focus()),"ArrowUp"!==t.key&&"End"!==t.key||(i.setCurrentItem(n),n.focus())})))}}handleTriggerKeyUp(t){" "===t.key&&t.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const t=this.trigger.assignedElements({flatten:!0}).find((t=>p(t).start));let i;if(t){switch(t.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":i=t.button;break;default:i=t}i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,c(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,c(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}updated(t){super.updated(t),t.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new f(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),t.has("disabled")&&this.updateTriggerDisabledState()}updateTriggerDisabledState(){const t=this.querySelector('[slot="trigger"]');if(!t)return;const i=t.hasAttribute("disabled");(this.disabled||i)&&(t.disabled=!0,this.disabled=!0)}async handleOpenChange(){if(this.visibilityManager?.setup(),this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){if(this.emit("nile-show"),this.addOpenListeners(),this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new f(this),this.portalManager.setupPortalAppend()),await h(this),!this.portal){this.panel.hidden=!1,this.popup.active=!0;const{keyframes:t,options:i}=d(this,"dropdown.show",{dir:""});await a(this.popup.popup,t,i)}this.emit("nile-after-show")}else{if(this.emit("nile-hide"),this.removeOpenListeners(),this.visibilityManager?.cleanup(),this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend(),await h(this),!this.portal){const{keyframes:t,options:i}=d(this,"dropdown.hide",{dir:""});await a(this.popup.popup,t,i),this.panel.hidden=!0,this.popup.active=!1}this.emit("nile-after-hide")}}render(){return i`
2
2
  <nile-popup
3
3
  part="base"
4
4
  id="dropdown"
@@ -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