@aquera/nile-elements 0.1.2 → 0.1.3

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 (28) hide show
  1. package/README.md +5 -0
  2. package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
  3. package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
  4. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  5. package/dist/nile-code-editor/nile-code-editor.esm.js +2 -2
  6. package/dist/nile-drawer/nile-drawer.css.cjs.js +1 -1
  7. package/dist/nile-drawer/nile-drawer.css.cjs.js.map +1 -1
  8. package/dist/nile-drawer/nile-drawer.css.esm.js +1 -1
  9. package/dist/nile-form-help-text/nile-form-help-text.cjs.js +1 -1
  10. package/dist/nile-form-help-text/nile-form-help-text.cjs.js.map +1 -1
  11. package/dist/nile-form-help-text/nile-form-help-text.esm.js +2 -2
  12. package/dist/src/nile-code-editor/extensionSetup.d.ts +8 -9
  13. package/dist/src/nile-code-editor/extensionSetup.js +0 -13
  14. package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
  15. package/dist/src/nile-code-editor/nile-code-editor.d.ts +19 -0
  16. package/dist/src/nile-code-editor/nile-code-editor.js +61 -2
  17. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  18. package/dist/src/nile-drawer/nile-drawer.css.js +1 -1
  19. package/dist/src/nile-drawer/nile-drawer.css.js.map +1 -1
  20. package/dist/src/nile-form-help-text/nile-form-help-text.js +32 -2
  21. package/dist/src/nile-form-help-text/nile-form-help-text.js.map +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +1 -1
  24. package/src/nile-code-editor/extensionSetup.ts +8 -23
  25. package/src/nile-code-editor/nile-code-editor.ts +59 -3
  26. package/src/nile-drawer/nile-drawer.css.ts +1 -1
  27. package/src/nile-form-help-text/nile-form-help-text.ts +37 -3
  28. package/vscode-html-custom-data.json +5 -1
@@ -1,2 +1,2 @@
1
- System.register(["lit"],function(_export,_context){"use strict";var e,_templateObject,t;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}return{setters:[function(_lit){e=_lit.css;}],execute:function execute(){_export("s",t=[e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.25rem;\n padding: 0 var(--header-spacing);\n }\n\n .drawer__header-actions nile-icon-button,\n .drawer__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .drawer__body {\n flex: 1 1 auto;\n display: block;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .drawer__footer {\n text-align: right;\n padding: var(--footer-spacing);\n }\n\n .drawer__footer ::slotted(nile-button:not(:last-of-type)) {\n margin-inline-end: 0.5rem;\n }\n\n .drawer:not(.drawer--has-footer) .drawer__footer {\n display: none;\n }\n\n .drawer__overlay {\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(240 3.8% 46.1% / 33%);\n pointer-events: all;\n }\n\n .drawer--contained .drawer__overlay {\n display: none;\n }\n\n .drawer__close:hover {\n cursor:pointer;\n }\n\n @media (forced-colors: active) {\n .drawer__panel {\n border: solid 1px hsl(0, 0%, 100%);\n }\n }\n"])))]);}};});
1
+ System.register(["lit"],function(_export,_context){"use strict";var e,_templateObject,t;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}return{setters:[function(_lit){e=_lit.css;}],execute:function execute(){_export("s",t=[e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.5rem;\n padding: 0 var(--header-spacing);\n }\n\n .drawer__header-actions nile-icon-button,\n .drawer__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .drawer__body {\n flex: 1 1 auto;\n display: block;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .drawer__footer {\n text-align: right;\n padding: var(--footer-spacing);\n }\n\n .drawer__footer ::slotted(nile-button:not(:last-of-type)) {\n margin-inline-end: 0.5rem;\n }\n\n .drawer:not(.drawer--has-footer) .drawer__footer {\n display: none;\n }\n\n .drawer__overlay {\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(240 3.8% 46.1% / 33%);\n pointer-events: all;\n }\n\n .drawer--contained .drawer__overlay {\n display: none;\n }\n\n .drawer__close:hover {\n cursor:pointer;\n }\n\n @media (forced-colors: active) {\n .drawer__panel {\n border: solid 1px hsl(0, 0%, 100%);\n }\n }\n"])))]);}};});
2
2
  //# sourceMappingURL=nile-drawer.css.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-drawer.css.cjs.js","sources":["../../../src/nile-drawer/nile-drawer.css.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 { css } from 'lit';\n\n/**\n * Drawer CSS\n */\nexport const styles = css`\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.25rem;\n padding: 0 var(--header-spacing);\n }\n\n .drawer__header-actions nile-icon-button,\n .drawer__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .drawer__body {\n flex: 1 1 auto;\n display: block;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .drawer__footer {\n text-align: right;\n padding: var(--footer-spacing);\n }\n\n .drawer__footer ::slotted(nile-button:not(:last-of-type)) {\n margin-inline-end: 0.5rem;\n }\n\n .drawer:not(.drawer--has-footer) .drawer__footer {\n display: none;\n }\n\n .drawer__overlay {\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(240 3.8% 46.1% / 33%);\n pointer-events: all;\n }\n\n .drawer--contained .drawer__overlay {\n display: none;\n }\n\n .drawer__close:hover {\n cursor:pointer;\n }\n\n @media (forced-colors: active) {\n .drawer__panel {\n border: solid 1px hsl(0, 0%, 100%);\n }\n }\n`;\n\nexport default [styles];\n"],"names":["styles$1","css","_templateObject","_taggedTemplateLiteral"],"mappings":"iVA0LeA,CAAA,CAAA,CA9KOC,CAAG,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA"}
1
+ {"version":3,"file":"nile-drawer.css.cjs.js","sources":["../../../src/nile-drawer/nile-drawer.css.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 { css } from 'lit';\n\n/**\n * Drawer CSS\n */\nexport const styles = css`\n :host {\n box-sizing: border-box;\n --nile-drawer-remove-icon-color:#000;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n :host {\n --size: 25rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n .drawer {\n top: 0;\n inset-inline-start: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n overflow: hidden;\n }\n\n .drawer--contained {\n position: absolute;\n z-index: initial;\n }\n\n .drawer--fixed {\n position: fixed;\n z-index: 700;\n }\n\n .drawer__panel {\n position: absolute;\n display: flex;\n flex-direction: column;\n z-index: 2;\n max-width: 100%;\n max-height: 100%;\n background-color: hsl(0, 0%, 100%);\n box-shadow: 0 4px 16px hsl(240 3.8% 46.1% / 12%);\n overflow: auto;\n pointer-events: all;\n }\n\n .drawer__panel:focus {\n outline: none;\n }\n\n .drawer--top .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--end .drawer__panel {\n top: 0;\n inset-inline-end: 0;\n bottom: auto;\n inset-inline-start: auto;\n width: var(--size);\n height: 100%;\n }\n\n .drawer--bottom .drawer__panel {\n top: auto;\n inset-inline-end: auto;\n bottom: 0;\n inset-inline-start: 0;\n width: 100%;\n height: var(--size);\n }\n\n .drawer--start .drawer__panel {\n top: 0;\n inset-inline-end: auto;\n bottom: auto;\n inset-inline-start: 0;\n width: var(--size);\n height: 100%;\n }\n\n .drawer__header {\n display: flex;\n }\n\n .drawer__title {\n flex: 1 1 auto;\n font: inherit;\n font-size: 1.25rem;\n line-height: 1.4;\n padding: var(--header-spacing);\n margin: 0;\n }\n\n .drawer__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 0.5rem;\n padding: 0 var(--header-spacing);\n }\n\n .drawer__header-actions nile-icon-button,\n .drawer__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .drawer__body {\n flex: 1 1 auto;\n display: block;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n .drawer__footer {\n text-align: right;\n padding: var(--footer-spacing);\n }\n\n .drawer__footer ::slotted(nile-button:not(:last-of-type)) {\n margin-inline-end: 0.5rem;\n }\n\n .drawer:not(.drawer--has-footer) .drawer__footer {\n display: none;\n }\n\n .drawer__overlay {\n display: block;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(240 3.8% 46.1% / 33%);\n pointer-events: all;\n }\n\n .drawer--contained .drawer__overlay {\n display: none;\n }\n\n .drawer__close:hover {\n cursor:pointer;\n }\n\n @media (forced-colors: active) {\n .drawer__panel {\n border: solid 1px hsl(0, 0%, 100%);\n }\n }\n`;\n\nexport default [styles];\n"],"names":["styles$1","css","_templateObject","_taggedTemplateLiteral"],"mappings":"iVA0LeA,CAAA,CAAA,CA9KOC,CAAG,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA"}
@@ -113,7 +113,7 @@ import{css as e}from"lit";var t=[e`
113
113
  display: flex;
114
114
  flex-wrap: wrap;
115
115
  justify-content: end;
116
- gap: 0.25rem;
116
+ gap: 0.5rem;
117
117
  padding: 0 var(--header-spacing);
118
118
  }
119
119
 
@@ -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-form-help-text.css.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,o,r,l,_templateObject,_templateObject2,n;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.LitElement;i=_lit.html;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;o=_litDecoratorsJs.query;r=_litDecoratorsJs.customElement;},function(_nileFormHelpTextCssCjsJs){l=_nileFormHelpTextCssCjsJs.s;}],execute:function execute(){_export("N",n=/*#__PURE__*/function(_e){function n(){var _this;_classCallCheck(this,n);_this=_callSuper(this,n,arguments),_this.isExpanded=!1,_this.fullText="",_this.textLimit=47,_this.displayedText="";return _this;}_inherits(n,_e);return _createClass(n,[{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_get(_getPrototypeOf(n.prototype),"connectedCallback",this).call(this),requestAnimationFrame(function(){var _this2$slotElement;(_this2$slotElement=_this2.slotElement)===null||_this2$slotElement===void 0||_this2$slotElement.addEventListener("slotchange",_this2.handleSlotChange.bind(_this2));});}},{key:"firstUpdated",value:function firstUpdated(){this.handleSlotChange();}},{key:"handleSlotChange",value:function handleSlotChange(){var t=this.slotElement.assignedNodes({flatten:!0}).map(function(t){return t.textContent;}).join("");this.fullText=t.trim(),this.updateDisplayedText();}},{key:"toggleExpanded",value:function toggleExpanded(){this.isExpanded=!this.isExpanded,this.updateDisplayedText();}},{key:"updateDisplayedText",value:function updateDisplayedText(){this.displayedText=this.isExpanded?this.fullText:"".concat(this.fullText.substring(0,this.textLimit),"...");}},{key:"render",value:function render(){var t=this.fullText.length>this.textLimit+3,e=this.isExpanded?"arrowup":"arrowdown";return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"nile-form-help-text\" part=\"container\">\n <slot hidden>","</slot>\n <div part=\"text\">\n <span>","</span>\n ","\n </div>\n </div>\n "])),this.fullText,this.displayedText,t?i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=","\n >","\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"","\"></nile-icon>\n </span>\n "])),this.toggleExpanded,this.isExpanded?"View Less":"View More",e):"");}}],[{key:"styles",get:function get(){return[l];}}]);}(e));t([s({type:Boolean,reflect:!0})],n.prototype,"isExpanded",void 0),t([s({type:String,reflect:!0})],n.prototype,"fullText",void 0),t([s({type:Number,reflect:!0})],n.prototype,"textLimit",void 0),t([s({type:String,reflect:!0})],n.prototype,"displayedText",void 0),t([o("slot")],n.prototype,"slotElement",void 0),_export("N",n=t([r("nile-form-help-text")],n));}};});
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-form-help-text.css.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,o,r,n,_templateObject,_templateObject2,l;function _taggedTemplateLiteral(strings,raw){if(!raw){raw=strings.slice(0);}return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}));}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}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(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.LitElement;i=_lit.html;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;o=_litDecoratorsJs.query;r=_litDecoratorsJs.customElement;},function(_nileFormHelpTextCssCjsJs){n=_nileFormHelpTextCssCjsJs.s;}],execute:function execute(){_export("N",l=/*#__PURE__*/function(_e){function l(){var _this;_classCallCheck(this,l);_this=_callSuper(this,l,arguments),_this.isExpanded=!1,_this.fullText="",_this.textLimit=47,_this.displayedText="";return _this;}_inherits(l,_e);return _createClass(l,[{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_get(_getPrototypeOf(l.prototype),"connectedCallback",this).call(this),requestAnimationFrame(function(){var _this2$slotElement;(_this2$slotElement=_this2.slotElement)===null||_this2$slotElement===void 0||_this2$slotElement.addEventListener("slotchange",_this2.handleSlotChange.bind(_this2));});}},{key:"firstUpdated",value:function firstUpdated(){this.handleSlotChange();}},{key:"handleSlotChange",value:function handleSlotChange(){var t=this.slotElement.assignedNodes({flatten:!0}).map(function(t){return t.textContent;}).join("");this.fullText=t.trim(),this.updateDisplayedText();}},{key:"toggleExpanded",value:function toggleExpanded(){this.isExpanded=!this.isExpanded,this.updateDisplayedText();}},{key:"updateDisplayedText",value:function updateDisplayedText(){if(this.isExpanded)this.displayedText=this.fullText;else{var _t=function(t,e){if(e<0||e>t.length)throw new Error("Invalid value of n. It must be between 0 and the sentence length.");if(" "!==t[e]&&0!==e&&e!==t.length){var _i2=e;for(;_i2>0&&" "!==t[_i2-1];)_i2--;var _s=e;for(;_s<t.length&&" "!==t[_s];)_s++;e=e-_i2<=_s-e?_i2:_s;}return e;}(this.fullText,this.textLimit),_e2=this.fullText.slice(0,_t),_i=this.fullText.length>_t?"...":"";this.displayedText="".concat(_e2).concat(_i);}}},{key:"render",value:function render(){var t=this.fullText.length>this.textLimit,e=this.isExpanded?"arrowup":"arrowdown";return i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"nile-form-help-text\" part=\"container\">\n <slot hidden>","</slot>\n <div part=\"text\">\n <span>","</span>\n ","\n </div>\n </div>\n "])),this.fullText,this.displayedText,t?i(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=","\n >","\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"","\"></nile-icon>\n </span>\n "])),this.toggleExpanded,this.isExpanded?"View Less":"View More",e):"");}}],[{key:"styles",get:function get(){return[n];}}]);}(e));t([s({type:Boolean,reflect:!0})],l.prototype,"isExpanded",void 0),t([s({type:String,reflect:!0})],l.prototype,"fullText",void 0),t([s({type:Number,reflect:!0})],l.prototype,"textLimit",void 0),t([s({type:String,reflect:!0})],l.prototype,"displayedText",void 0),t([o("slot")],l.prototype,"slotElement",void 0),_export("N",l=t([r("nile-form-help-text")],l));}};});
2
2
  //# sourceMappingURL=nile-form-help-text.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-form-help-text.cjs.js","sources":["../../../src/nile-form-help-text/nile-form-help-text.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} from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport {styles} from './nile-form-help-text.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-form-help-text\n *\n */\n@customElement('nile-form-help-text')\nexport class NileFormHelpText extends LitElement {\n /**\n * The styles for FormHelpText\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true }) isExpanded: boolean = false;\n\n @property({ type: String, reflect: true }) fullText: string = '';\n\n @property({ type: Number, reflect: true }) textLimit: number = 47;\n\n @property({ type: String, reflect: true }) displayedText: string = '';\n\n @query('slot') slotElement!: HTMLSlotElement;\n\n connectedCallback() {\n super.connectedCallback();\n requestAnimationFrame(() => {\n this.slotElement?.addEventListener('slotchange', this.handleSlotChange.bind(this));\n });\n }\n\n firstUpdated() {\n this.handleSlotChange();\n }\n\n handleSlotChange() {\n const nodes = this.slotElement.assignedNodes({flatten: true});\n const textContent = nodes.map(node => node.textContent).join('');\n this.fullText = textContent.trim();\n this.updateDisplayedText()\n }\n\n toggleExpanded() {\n this.isExpanded = !this.isExpanded;\n this.updateDisplayedText()\n }\n\n updateDisplayedText(){\n this.displayedText = this.isExpanded ? this.fullText : `${this.fullText.substring(0, this.textLimit)}...`;\n }\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n const showMoreButton = this.fullText.length > this.textLimit+3;\n const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';\n\n return html`\n <div class=\"nile-form-help-text\" part=\"container\">\n <slot hidden>${this.fullText}</slot>\n <div part=\"text\">\n <span>${this.displayedText}</span>\n ${showMoreButton ? html`\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=${this.toggleExpanded}\n >${this.isExpanded ? 'View Less' : 'View More'}\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"${iconName}\"></nile-icon>\n </span>\n ` : ''}\n </div>\n </div>\n `;\n }\n}\n\nexport default NileFormHelpText;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-form-help-text': NileFormHelpText;\n }\n}\n"],"names":["NileFormHelpText","_e","n","this","isExpanded","fullText","textLimit","displayedText","_this","_inherits","_createClass","key","value","connectedCallback","super","requestAnimationFrame","_this2$slotElement","slotElement","addEventListener","handleSlotChange","bind","firstUpdated","textContent","assignedNodes","flatten","map","node","join","trim","updateDisplayedText","toggleExpanded","substring","render","showMoreButton","length","iconName","html","_templateObject","_taggedTemplateLiteral","_templateObject2","get","styles","LitElement","__decorate","property","type","Boolean","reflect","prototype","String","Number","query","_export","customElement"],"mappings":"imIAkBaA,CAAN,uBAAAC,EAAA,EAAA,SAAAC,EAAA,qEASwCC,EAAAA,KAAAA,CAAUC,UAAY,CAAA,CAAA,CAAA,CAEvBD,KAAAA,CAAQE,QAAAA,CAAW,EAEnBF,CAAAA,KAAAA,CAASG,SAAW,CAAA,EAAA,CAEpBH,KAAAA,CAAaI,aAAAA,CAAW,EA6DrE,QAAAC,KAAA,EAvEQC,SAAA,CAAAP,CAAA,CAAAD,EAAA,SAAAS,YAAA,CAAAR,CAAA,GAAAS,GAAA,qBAAAC,KAAA,CAcP,SAAAC,kBAAA,CAAAA,KAAAA,MAAAA,MACEC,IAAAA,CAAAA,eAAAA,CAAAA,CAAAA,CAAAA,SAAAA,4BAAAA,IAAAA,OACAC,qBAAsB,CAAA,UAAA,KAAAC,kBAAA,CACpBb,CAAAA,kBAAAA,CAAAA,MAAKc,CAAAA,WAAAA,UAAAA,kBAAAA,WAALd,kBAAAA,CAA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AA,CAAdQ,CAAM,CAAA,MAAA,CAAA,CAAA,CAAsCnD,CAAAgD,CAAAA,SAAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,CAAAI,OAAA,KAjBlCpD,CAAgB2C,CAAAA,CAAAA,CAAA,CAD5BU,CAAAA,CAAc,wBACFrD"}
1
+ {"version":3,"file":"nile-form-help-text.cjs.js","sources":["../../../src/nile-form-help-text/nile-form-help-text.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} from 'lit';\nimport { customElement, query, property } from 'lit/decorators.js';\nimport {styles} from './nile-form-help-text.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-form-help-text\n *\n */\n@customElement('nile-form-help-text')\nexport class NileFormHelpText extends LitElement {\n /**\n * The styles for FormHelpText\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true }) isExpanded: boolean = false;\n\n @property({ type: String, reflect: true }) fullText: string = '';\n\n @property({ type: Number, reflect: true }) textLimit: number = 47;\n\n @property({ type: String, reflect: true }) displayedText: string = '';\n\n @query('slot') slotElement!: HTMLSlotElement;\n\n connectedCallback() {\n super.connectedCallback();\n requestAnimationFrame(() => {\n this.slotElement?.addEventListener('slotchange', this.handleSlotChange.bind(this));\n });\n }\n\n firstUpdated() {\n this.handleSlotChange();\n }\n\n handleSlotChange() {\n const nodes = this.slotElement.assignedNodes({flatten: true});\n const textContent = nodes.map(node => node.textContent).join('');\n this.fullText = textContent.trim();\n this.updateDisplayedText()\n }\n\n toggleExpanded() {\n this.isExpanded = !this.isExpanded;\n this.updateDisplayedText()\n }\n\n updateDisplayedText() {\n if (this.isExpanded) {\n this.displayedText = this.fullText;\n } else {\n const validConcatNumber=concatSentence(this.fullText, this.textLimit)\n const truncatedText = this.fullText.slice(0, validConcatNumber);\n const ellipsis = this.fullText.length > validConcatNumber ? '...' : '';\n this.displayedText = `${truncatedText}${ellipsis}`;\n }\n }\n\n /* #endregion */\n\n /* #region Methods */\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n const showMoreButton = this.fullText.length > this.textLimit;\n const iconName = this.isExpanded ? 'arrowup' : 'arrowdown';\n\n return html`\n <div class=\"nile-form-help-text\" part=\"container\">\n <slot hidden>${this.fullText}</slot>\n <div part=\"text\">\n <span>${this.displayedText}</span>\n ${showMoreButton ? html`\n <span\n class=\"nile-form-help-text__more-button\"\n part=\"toggle-button\"\n @click=${this.toggleExpanded}\n >${this.isExpanded ? 'View Less' : 'View More'}\n <nile-icon color=\"#005EA6\" part=\"icon\" size=\"14\" name=\"${iconName}\"></nile-icon>\n </span>\n ` : ''}\n </div>\n </div>\n `;\n }\n}\n\nexport default NileFormHelpText;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-form-help-text': NileFormHelpText;\n }\n}\n\nfunction concatSentence(sentence:string, n:number) {\n if (n < 0 || n > sentence.length) {\n throw new Error(\"Invalid value of n. It must be between 0 and the sentence length.\");\n }\n\n // Adjust n if it falls in the middle of a word\n if (sentence[n] !== \" \" && n !== 0 && n !== sentence.length) {\n // Move left until the start of the word or the beginning of the sentence\n let left = n;\n while (left > 0 && sentence[left - 1] !== \" \") {\n left--;\n }\n\n // Move right until the end of the word or the end of the sentence\n let right = n;\n while (right < sentence.length && sentence[right] !== \" \") {\n right++;\n }\n\n // Adjust n to the closer boundary\n n = (n - left <= right - n) ? left : right;\n }\n\n // Return the substring from the start to the adjusted n\n return n;\n}\n"],"names":["NileFormHelpText","_e","l","constructor","this","isExpanded","fullText","textLimit","displayedText","_this","_inherits","_createClass","key","value","connectedCallback","super","requestAnimationFrame","slotElement","addEventListener","handleSlotChange","bind","firstUpdated","textContent","assignedNodes","flatten","map","node","join","trim","updateDisplayedText","toggleExpanded","validConcatNumber","sentence","n","length","Error","left","right","concatSentence","truncatedText","slice","ellipsis","render","showMoreButton","iconName","html","_templateObject","_taggedTemplateLiteral","_templateObject2","get","styles","LitElement","__decorate","property","type","Boolean","reflect","prototype","String","Number","query","_export","customElement"],"mappings":"imIAkBaA,CAAN,uBAAAC,EAAA,EAAA,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,mCASwCC,EAAAA,KAAAA,CAAUC,UAAY,CAAA,CAAA,CAAA,CAEvBD,KAAAA,CAAQE,QAAAA,CAAW,GAEnBF,KAAAA,CAASG,SAAAA,CAAW,GAEpBH,KAAAA,CAAaI,aAAAA,CAAW,EAoErE,QAAAC,KAAA,EA9EQC,SAAA,CAAAR,CAAA,CAAAD,EAAA,SAAAU,YAAA,CAAAT,CAAA,GAAAU,GAAA,qBAAAC,KAAA,CAcP,SAAAC,kBAAA,kBACEC,IAAAA,CAAAA,eAAAA,CAAAA,CAAAA,CAAAA,SAAAA,4BAAAA,IAAAA,OACAC,sBAAsB,UACpBZ,KAAAA,kBAAAA,CAAAA,CAAAA,kBAAAA,CAAAA,MAAAA,CAAKa,WAAaC,UAAAA,kBAAAA,WAAlBd,kBAAAA,CAAkBc,gBAAAA,CAAiB,YAAcd,CAAAA,MAAAA,CAAKe,iBAAiBC,IAAKhB,CAAAA,MAAAA,CAAAA,CAAM,GAErF,EAED,GAAAQ,GAAA,gBAAAC,KAAA,UAAAQ,aAAA,EACEjB,IAAKe,CAAAA,gBAAAA,CAAAA,CACN,EAED,GAAAP,GAAA,oBAAAC,KAAA,UAAAM,iBAAA,CAAAA,CACE,GACMG,CAAAA,CADQlB,CAAAA,IAAAA,CAAKa,YAAYM,aAAc,CAAA,CAACC,SAAS,CAC7BC,CAAAA,CAAAA,CAAAA,GAAAA,CAAIC,SAAAA,CAAQA,QAAAA,CAAAA,CAAAA,CAAKJ,WAAaK,EAAAA,CAAAA,CAAAA,IAAAA,CAAK,IAC7DvB,IAAKE,CAA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C,IAAMK,CAAAA,MAAAA,CAAQH,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgCxD,CAAAyD,CAAAA,SAAAA,CAAA,WAAA,CAAA,IAAA,EAAA,CAAA,CAEvBL,CAAA,CAAA,CAA3CC,CAAS,CAAA,CAAEC,IAAMI,CAAAA,MAAAA,CAAQF,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoCxD,CAAAyD,CAAAA,SAAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAExDL,CAAA,CAAA,CAAdQ,CAAM,CAAA,MAAA,CAAA,CAAA,CAAsC5D,CAAAyD,CAAAA,SAAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,CAAAI,OAAA,KAjBlC7D,CAAgBoD,CAAAA,CAAAA,CAAA,CAD5BU,CAAAA,CAAc,wBACF9D"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t}from"tslib";import{LitElement as e,html as i}from"lit";import{property as s,query as o,customElement as r}from"lit/decorators.js";import{s as l}from"./nile-form-help-text.css.esm.js";let n=class extends e{constructor(){super(...arguments),this.isExpanded=!1,this.fullText="",this.textLimit=47,this.displayedText=""}static get styles(){return[l]}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>{this.slotElement?.addEventListener("slotchange",this.handleSlotChange.bind(this))}))}firstUpdated(){this.handleSlotChange()}handleSlotChange(){const t=this.slotElement.assignedNodes({flatten:!0}).map((t=>t.textContent)).join("");this.fullText=t.trim(),this.updateDisplayedText()}toggleExpanded(){this.isExpanded=!this.isExpanded,this.updateDisplayedText()}updateDisplayedText(){this.displayedText=this.isExpanded?this.fullText:`${this.fullText.substring(0,this.textLimit)}...`}render(){const t=this.fullText.length>this.textLimit+3,e=this.isExpanded?"arrowup":"arrowdown";return i`
1
+ import{__decorate as t}from"tslib";import{LitElement as e,html as i}from"lit";import{property as s,query as o,customElement as r}from"lit/decorators.js";import{s as n}from"./nile-form-help-text.css.esm.js";let l=class extends e{constructor(){super(...arguments),this.isExpanded=!1,this.fullText="",this.textLimit=47,this.displayedText=""}static get styles(){return[n]}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>{this.slotElement?.addEventListener("slotchange",this.handleSlotChange.bind(this))}))}firstUpdated(){this.handleSlotChange()}handleSlotChange(){const t=this.slotElement.assignedNodes({flatten:!0}).map((t=>t.textContent)).join("");this.fullText=t.trim(),this.updateDisplayedText()}toggleExpanded(){this.isExpanded=!this.isExpanded,this.updateDisplayedText()}updateDisplayedText(){if(this.isExpanded)this.displayedText=this.fullText;else{const t=function(t,e){if(e<0||e>t.length)throw new Error("Invalid value of n. It must be between 0 and the sentence length.");if(" "!==t[e]&&0!==e&&e!==t.length){let i=e;for(;i>0&&" "!==t[i-1];)i--;let s=e;for(;s<t.length&&" "!==t[s];)s++;e=e-i<=s-e?i:s}return e}(this.fullText,this.textLimit),e=this.fullText.slice(0,t),i=this.fullText.length>t?"...":"";this.displayedText=`${e}${i}`}}render(){const t=this.fullText.length>this.textLimit,e=this.isExpanded?"arrowup":"arrowdown";return i`
2
2
  <div class="nile-form-help-text" part="container">
3
3
  <slot hidden>${this.fullText}</slot>
4
4
  <div part="text">
@@ -14,4 +14,4 @@ import{__decorate as t}from"tslib";import{LitElement as e,html as i}from"lit";im
14
14
  `:""}
15
15
  </div>
16
16
  </div>
17
- `}};t([s({type:Boolean,reflect:!0})],n.prototype,"isExpanded",void 0),t([s({type:String,reflect:!0})],n.prototype,"fullText",void 0),t([s({type:Number,reflect:!0})],n.prototype,"textLimit",void 0),t([s({type:String,reflect:!0})],n.prototype,"displayedText",void 0),t([o("slot")],n.prototype,"slotElement",void 0),n=t([r("nile-form-help-text")],n);export{n as N};
17
+ `}};t([s({type:Boolean,reflect:!0})],l.prototype,"isExpanded",void 0),t([s({type:String,reflect:!0})],l.prototype,"fullText",void 0),t([s({type:Number,reflect:!0})],l.prototype,"textLimit",void 0),t([s({type:String,reflect:!0})],l.prototype,"displayedText",void 0),t([o("slot")],l.prototype,"slotElement",void 0),l=t([r("nile-form-help-text")],l);export{l as N};
@@ -1,4 +1,12 @@
1
1
  import { Extension } from '@codemirror/state';
2
+ export interface MinimalSetupOptions {
3
+ highlightSpecialChars?: boolean;
4
+ history?: boolean;
5
+ drawSelection?: boolean;
6
+ syntaxHighlighting?: boolean;
7
+ defaultKeymap?: boolean;
8
+ historyKeymap?: boolean;
9
+ }
2
10
  export interface BasicSetupOptions extends MinimalSetupOptions {
3
11
  lineNumbers?: boolean;
4
12
  highlightActiveLineGutter?: boolean;
@@ -23,12 +31,3 @@ export interface BasicSetupOptions extends MinimalSetupOptions {
23
31
  }
24
32
  export declare const isValidSetup: (item: any) => any;
25
33
  export declare const basicSetup: (options?: BasicSetupOptions) => Extension[];
26
- export interface MinimalSetupOptions {
27
- highlightSpecialChars?: boolean;
28
- history?: boolean;
29
- drawSelection?: boolean;
30
- syntaxHighlighting?: boolean;
31
- defaultKeymap?: boolean;
32
- historyKeymap?: boolean;
33
- }
34
- export declare const minimalSetup: (options?: MinimalSetupOptions) => Extension[];
@@ -39,17 +39,4 @@ export const basicSetup = (options = {}) => {
39
39
  extensions.push(indentUnit.of(' '.repeat(options.tabSize)));
40
40
  return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);
41
41
  };
42
- export const minimalSetup = (options = {}) => {
43
- let keymaps = [];
44
- isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);
45
- isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);
46
- const extensions = [];
47
- isValidSetup(options.highlightSpecialChars) &&
48
- extensions.push(highlightSpecialChars());
49
- isValidSetup(options.history) && extensions.push(history());
50
- isValidSetup(options.drawSelection) && extensions.push(drawSelection());
51
- isValidSetup(options.syntaxHighlighting) &&
52
- extensions.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true }));
53
- return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);
54
- };
55
42
  //# sourceMappingURL=extensionSetup.js.map
@@ -1 +1 @@
1
- {"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AI,OAAO,GAAiB,EAAE,CAAC;IAC/B,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;IACtE,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;IACtE,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACzC,UAAU,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC3C,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACxE,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACtC,UAAU,CAAC,IAAI,CACb,kBAAkB,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC9D,CAAC;IACJ,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC,CAAC","sourcesContent":["import {\n KeyBinding,\n highlightActiveLineGutter,\n highlightSpecialChars,\n drawSelection,\n dropCursor,\n rectangularSelection,\n crosshairCursor,\n highlightActiveLine,\n keymap,\n} from '@codemirror/view';\nimport { EditorState, Extension } from '@codemirror/state';\nimport { history, defaultKeymap, historyKeymap } from '@codemirror/commands';\nimport { highlightSelectionMatches, searchKeymap } from '@codemirror/search';\nimport {\n closeBrackets,\n autocompletion,\n closeBracketsKeymap,\n completionKeymap,\n} from '@codemirror/autocomplete';\nimport {\n foldGutter,\n indentOnInput,\n syntaxHighlighting,\n defaultHighlightStyle,\n bracketMatching,\n indentUnit,\n foldKeymap,\n} from '@codemirror/language';\n\nimport { lintKeymap } from '@codemirror/lint';\n\nexport interface BasicSetupOptions extends MinimalSetupOptions {\n lineNumbers?: boolean;\n highlightActiveLineGutter?: boolean;\n foldGutter?: boolean;\n dropCursor?: boolean;\n allowMultipleSelections?: boolean;\n indentOnInput?: boolean;\n bracketMatching?: boolean;\n closeBrackets?: boolean;\n autocompletion?: boolean;\n rectangularSelection?: boolean;\n crosshairCursor?: boolean;\n highlightActiveLine?: boolean;\n highlightSelectionMatches?: boolean;\n closeBracketsKeymap?: boolean;\n searchKeymap?: boolean;\n foldKeymap?: boolean;\n completionKeymap?: boolean;\n lintKeymap?: boolean;\n tabSize?: number;\n readonly?: false;\n}\n\nexport const isValidSetup = (item: any) => {\n return typeof item === 'undefined' || item;\n};\n\nexport const basicSetup = (options: BasicSetupOptions = {}): Extension[] => {\n const { crosshairCursor: initCrosshairCursor = false } = options;\n let keymaps: KeyBinding[] = [];\n isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);\n isValidSetup(options.closeBracketsKeymap) && keymaps.push(...closeBracketsKeymap);\n isValidSetup(options.searchKeymap) && keymaps.push(...searchKeymap);\n isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);\n isValidSetup(options.foldKeymap) && keymaps.push(...foldKeymap);\n isValidSetup(options.lintKeymap) && keymaps.push(...lintKeymap);\n const extensions: Extension[] = [];\n isValidSetup(options.highlightActiveLineGutter) && extensions.push(highlightActiveLineGutter());\n isValidSetup(options.highlightSpecialChars) && extensions.push(highlightSpecialChars());\n isValidSetup(options.history) && extensions.push(history());\n isValidSetup(options.foldGutter) && extensions.push(foldGutter());\n isValidSetup(options.drawSelection) && extensions.push(drawSelection());\n isValidSetup(options.dropCursor) && extensions.push(dropCursor());\n isValidSetup(options.allowMultipleSelections) && extensions.push(EditorState.allowMultipleSelections.of(true));\n isValidSetup(options.indentOnInput) && extensions.push(indentOnInput());\n isValidSetup(options.syntaxHighlighting) &&\n extensions.push(\n syntaxHighlighting(defaultHighlightStyle, { fallback: true })\n );\n isValidSetup(options.bracketMatching) && extensions.push(bracketMatching());\n isValidSetup(options.closeBrackets) && extensions.push(closeBrackets());\n isValidSetup(options.autocompletion) && extensions.push(autocompletion());\n isValidSetup(options.rectangularSelection) && extensions.push(rectangularSelection());\n isValidSetup(options.crosshairCursor) && extensions.push(crosshairCursor());\n isValidSetup(options.highlightActiveLine) && extensions.push(highlightActiveLine());\n isValidSetup(options.highlightSelectionMatches) && extensions.push(highlightSelectionMatches());\n if (options.tabSize && typeof options.tabSize === 'number')\n extensions.push(indentUnit.of(' '.repeat(options.tabSize)));\n return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);\n};\n\nexport interface MinimalSetupOptions {\n highlightSpecialChars?: boolean;\n history?: boolean;\n drawSelection?: boolean;\n syntaxHighlighting?: boolean;\n defaultKeymap?: boolean;\n historyKeymap?: boolean;\n}\n\nexport const minimalSetup = (options: MinimalSetupOptions = {}) => {\n let keymaps: KeyBinding[] = [];\n isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);\n isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);\n const extensions: Extension[] = [];\n isValidSetup(options.highlightSpecialChars) &&\n extensions.push(highlightSpecialChars());\n isValidSetup(options.history) && extensions.push(history());\n isValidSetup(options.drawSelection) && extensions.push(drawSelection());\n isValidSetup(options.syntaxHighlighting) &&\n extensions.push(\n syntaxHighlighting(defaultHighlightStyle, { fallback: true })\n );\n return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);\n};\n"]}
1
+ {"version":3,"file":"extensionSetup.js","sourceRoot":"","sources":["../../../src/nile-code-editor/extensionSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B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AAO,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACxE,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC1E,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACtF,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAC5E,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACpF,YAAY,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAChG,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;QACxD,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC,CAAC","sourcesContent":["import {\n KeyBinding,\n highlightActiveLineGutter,\n highlightSpecialChars,\n drawSelection,\n dropCursor,\n rectangularSelection,\n crosshairCursor,\n highlightActiveLine,\n keymap,\n} from '@codemirror/view';\nimport { EditorState, Extension } from '@codemirror/state';\nimport { history, defaultKeymap, historyKeymap } from '@codemirror/commands';\nimport { highlightSelectionMatches, searchKeymap } from '@codemirror/search';\nimport {\n closeBrackets,\n autocompletion,\n closeBracketsKeymap,\n completionKeymap,\n} from '@codemirror/autocomplete';\nimport {\n foldGutter,\n indentOnInput,\n syntaxHighlighting,\n defaultHighlightStyle,\n bracketMatching,\n indentUnit,\n foldKeymap,\n} from '@codemirror/language';\n\nimport { lintKeymap } from '@codemirror/lint';\n\nexport interface MinimalSetupOptions {\n highlightSpecialChars?: boolean;\n history?: boolean;\n drawSelection?: boolean;\n syntaxHighlighting?: boolean;\n defaultKeymap?: boolean;\n historyKeymap?: boolean;\n}\nexport interface BasicSetupOptions extends MinimalSetupOptions {\n lineNumbers?: boolean;\n highlightActiveLineGutter?: boolean;\n foldGutter?: boolean;\n dropCursor?: boolean;\n allowMultipleSelections?: boolean;\n indentOnInput?: boolean;\n bracketMatching?: boolean;\n closeBrackets?: boolean;\n autocompletion?: boolean;\n rectangularSelection?: boolean;\n crosshairCursor?: boolean;\n highlightActiveLine?: boolean;\n highlightSelectionMatches?: boolean;\n closeBracketsKeymap?: boolean;\n searchKeymap?: boolean;\n foldKeymap?: boolean;\n completionKeymap?: boolean;\n lintKeymap?: boolean;\n tabSize?: number;\n readonly?: false;\n}\n\nexport const isValidSetup = (item: any) => {\n return typeof item === 'undefined' || item;\n};\n\nexport const basicSetup = (options: BasicSetupOptions = {}): Extension[] => {\n const { crosshairCursor: initCrosshairCursor = false } = options;\n let keymaps: KeyBinding[] = [];\n isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);\n isValidSetup(options.closeBracketsKeymap) && keymaps.push(...closeBracketsKeymap);\n isValidSetup(options.searchKeymap) && keymaps.push(...searchKeymap);\n isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);\n isValidSetup(options.foldKeymap) && keymaps.push(...foldKeymap);\n isValidSetup(options.lintKeymap) && keymaps.push(...lintKeymap);\n const extensions: Extension[] = [];\n isValidSetup(options.highlightActiveLineGutter) && extensions.push(highlightActiveLineGutter());\n isValidSetup(options.highlightSpecialChars) && extensions.push(highlightSpecialChars());\n isValidSetup(options.history) && extensions.push(history());\n isValidSetup(options.foldGutter) && extensions.push(foldGutter());\n isValidSetup(options.drawSelection) && extensions.push(drawSelection());\n isValidSetup(options.dropCursor) && extensions.push(dropCursor());\n isValidSetup(options.allowMultipleSelections) && extensions.push(EditorState.allowMultipleSelections.of(true));\n isValidSetup(options.indentOnInput) && extensions.push(indentOnInput());\n isValidSetup(options.syntaxHighlighting) &&\n extensions.push(\n syntaxHighlighting(defaultHighlightStyle, { fallback: true })\n );\n isValidSetup(options.bracketMatching) && extensions.push(bracketMatching());\n isValidSetup(options.closeBrackets) && extensions.push(closeBrackets());\n isValidSetup(options.autocompletion) && extensions.push(autocompletion());\n isValidSetup(options.rectangularSelection) && extensions.push(rectangularSelection());\n isValidSetup(options.crosshairCursor) && extensions.push(crosshairCursor());\n isValidSetup(options.highlightActiveLine) && extensions.push(highlightActiveLine());\n isValidSetup(options.highlightSelectionMatches) && extensions.push(highlightSelectionMatches());\n if (options.tabSize && typeof options.tabSize === 'number')\n extensions.push(indentUnit.of(' '.repeat(options.tabSize)));\n return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);\n};\n\n\n"]}
@@ -34,6 +34,7 @@ export declare class NileCodeEditor extends NileElement {
34
34
  expandable: boolean;
35
35
  readonly: boolean;
36
36
  debounce: boolean;
37
+ debounceTimeout: number;
37
38
  view: EditorView;
38
39
  viewState: EditorState;
39
40
  private timeOut;
@@ -54,7 +55,19 @@ export declare class NileCodeEditor extends NileElement {
54
55
  render(): TemplateResult;
55
56
  createNewView(emitEvent?: boolean): void;
56
57
  createState(): EditorState;
58
+ /**
59
+ * Custom autocomplete handler for code editor suggestions
60
+ * @param context CompletionContext from CodeMirror
61
+ * @returns CompletionResult with suggestions or null if no suggestions
62
+ */
57
63
  customAutocomplete: (context: CompletionContext) => CompletionResult | null;
64
+ /**
65
+ * Gets nested property suggestions based on the current path
66
+ * @param context CompletionContext from CodeMirror
67
+ * @param textBeforeCursor Text before cursor position
68
+ * @param baseTextAfterSeperation Text after the last separator (. or [)
69
+ * @returns CompletionResult with nested suggestions or null
70
+ */
58
71
  getNestedSuggestions(context: CompletionContext, textBeforeCursor: string, baseTextAfterSeperation: string): {
59
72
  from: number;
60
73
  options: {
@@ -65,6 +78,12 @@ export declare class NileCodeEditor extends NileElement {
65
78
  boost: number;
66
79
  }[];
67
80
  } | null;
81
+ /**
82
+ * Gets top level suggestions based on custom completions and paths
83
+ * @param context CompletionContext from CodeMirror
84
+ * @param textBeforeCursor Text before cursor position
85
+ * @returns CompletionResult with top level suggestions or null
86
+ */
68
87
  getTopLevelSuggestions(context: CompletionContext, textBeforeCursor: string): {
69
88
  from: number;
70
89
  options: {
@@ -21,7 +21,6 @@ import NileElement from '../internal/nile-element';
21
21
  import { basicSetup } from './extensionSetup';
22
22
  import { classMap } from 'lit/directives/class-map.js';
23
23
  import { Theme } from './theme';
24
- const TIME_OUT_DURATION = 200;
25
24
  // Choose the appropriate mode for your use case
26
25
  /**
27
26
  * Nile icon component.
@@ -49,6 +48,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
49
48
  this.expandable = true;
50
49
  this.readonly = false;
51
50
  this.debounce = false;
51
+ this.debounceTimeout = 200;
52
52
  this.timeOut = null;
53
53
  // Compartments for initialiazing and switching extensions
54
54
  this.lineNumbersComp = new Compartment();
@@ -56,6 +56,11 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
56
56
  this.readOnlyComp = new Compartment();
57
57
  this.customCompletionComp = new Compartment();
58
58
  this.placeholderComp = new Compartment();
59
+ /**
60
+ * Custom autocomplete handler for code editor suggestions
61
+ * @param context CompletionContext from CodeMirror
62
+ * @returns CompletionResult with suggestions or null if no suggestions
63
+ */
59
64
  this.customAutocomplete = (context) => {
60
65
  // Getting the valid last line, last text from the code editor
61
66
  const text = context.state.doc.sliceString(0, context.pos);
@@ -225,6 +230,13 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
225
230
  });
226
231
  return this.viewState;
227
232
  }
233
+ /**
234
+ * Gets nested property suggestions based on the current path
235
+ * @param context CompletionContext from CodeMirror
236
+ * @param textBeforeCursor Text before cursor position
237
+ * @param baseTextAfterSeperation Text after the last separator (. or [)
238
+ * @returns CompletionResult with nested suggestions or null
239
+ */
228
240
  getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation) {
229
241
  // Return early if not a valid path or not ending with . or [
230
242
  if (!isValidPath(textBeforeCursor) || !['.', '['].includes(textBeforeCursor.at(-1))) {
@@ -259,6 +271,12 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
259
271
  }))
260
272
  };
261
273
  }
274
+ /**
275
+ * Gets top level suggestions based on custom completions and paths
276
+ * @param context CompletionContext from CodeMirror
277
+ * @param textBeforeCursor Text before cursor position
278
+ * @returns CompletionResult with top level suggestions or null
279
+ */
262
280
  getTopLevelSuggestions(context, textBeforeCursor) {
263
281
  const baseMatch = textBeforeCursor.match(/([a-zA-Z_$][\w$]*)$/);
264
282
  if (!baseMatch)
@@ -291,7 +309,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
291
309
  emitAfterTimeout(value) {
292
310
  if (this.timeOut)
293
311
  clearTimeout(this.timeOut);
294
- this.timeOut = setTimeout(() => this.emit('nile-change', value, false), TIME_OUT_DURATION);
312
+ this.timeOut = setTimeout(() => this.emit('nile-change', value, false), this.debounceTimeout);
295
313
  }
296
314
  singleLineMultiLineToggle() {
297
315
  this.view.dispatch({
@@ -387,11 +405,22 @@ __decorate([
387
405
  __decorate([
388
406
  property({ type: Boolean, reflect: true, attribute: true })
389
407
  ], NileCodeEditor.prototype, "debounce", void 0);
408
+ __decorate([
409
+ property({ type: Number, reflect: true, attribute: true })
410
+ ], NileCodeEditor.prototype, "debounceTimeout", void 0);
390
411
  NileCodeEditor = __decorate([
391
412
  customElement('nile-code-editor')
392
413
  ], NileCodeEditor);
393
414
  export { NileCodeEditor };
394
415
  export default NileCodeEditor;
416
+ /**
417
+ * Parses a string path into an array of keys representing nested object access
418
+ * @param text The path string to parse (e.g. "foo.bar[0].baz")
419
+ * @returns Array of keys if valid path, null otherwise
420
+ * @example
421
+ * parsePath("foo.bar[0]") // returns ["foo", "bar", "0"]
422
+ * parsePath("invalid") // returns null
423
+ */
395
424
  function parsePath(text) {
396
425
  const regex = /([a-zA-Z_$][\w$]*)(\[(?:[^\]]+)\]|\.[a-zA-Z_$][\w$]*)*/g;
397
426
  const matches = [...text.matchAll(regex)];
@@ -413,12 +442,27 @@ function parsePath(text) {
413
442
  return null;
414
443
  }
415
444
  ;
445
+ /**
446
+ * Splits a path string at the last separator (. or [)
447
+ * @param input The path string to split
448
+ * @returns Array containing [path up to last separator, remainder after separator]
449
+ * @example
450
+ * splitStringAtLastSeparator("foo.bar[0]") // returns ["foo.bar[", "0"]
451
+ */
416
452
  function splitStringAtLastSeparator(input) {
417
453
  const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));
418
454
  if (lastSeparatorIndex === -1)
419
455
  return [input, ''];
420
456
  return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];
421
457
  }
458
+ /**
459
+ * Traverses an object using an array of keys to access nested properties
460
+ * @param obj The object to traverse
461
+ * @param keys Array of keys defining the path to the desired property
462
+ * @returns The value at the specified path, or null if path is invalid
463
+ * @example
464
+ * resolveNestedProperties({foo: {bar: 123}}, ["foo", "bar"]) // returns 123
465
+ */
422
466
  function resolveNestedProperties(obj, keys) {
423
467
  return keys.reduce((acc, key) => {
424
468
  if (acc && typeof acc === 'object') {
@@ -428,12 +472,27 @@ function resolveNestedProperties(obj, keys) {
428
472
  }, obj);
429
473
  }
430
474
  ;
475
+ /**
476
+ * Validates if a string represents a valid object path format
477
+ * @param path The path string to validate
478
+ * @returns Boolean indicating if path format is valid
479
+ * @example
480
+ * isValidPath("foo.bar[0]") // returns true
481
+ * isValidPath("foo..bar") // returns false
482
+ */
431
483
  function isValidPath(path) {
432
484
  // Regex to validate the format of the string
433
485
  const regex = /^([a-zA-Z_$][\w$]*)(\.[a-zA-Z_$][\w$]*|\[\s*(['"]?[a-zA-Z0-9_$]*['"]?)\s*\])*([\.\[])?$/;
434
486
  // Test the string against the regex
435
487
  return regex.test(path);
436
488
  }
489
+ /**
490
+ * Converts multi-line code into a single line by removing line breaks and extra whitespace
491
+ * @param code The code string to convert
492
+ * @returns Single line version of the code
493
+ * @example
494
+ * convertToSingleLine("foo\n bar") // returns "foo bar"
495
+ */
437
496
  function convertToSingleLine(code) {
438
497
  if (!code)
439
498
  return '';
@@ -1 +1 @@
1
- {"version":3,"file":"nile-code-editor.js","sourceRoot":"","sources":["../../../src/nile-code-editor/nile-code-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EACL,IAAI,GAIL,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAc,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAqC,MAAM,0BAA0B,CAAC;AAC7F,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAA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AC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC;AAAA,CAAC;AAEF,SAAS,WAAW,CAAC,IAAY;IAC/B,6CAA6C;IAC7C,MAAM,KAAK,GAAG,yFAAyF,CAAC;IACxG,oCAAoC;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,gDAAgD;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1C,CAAC","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 {\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValueMap,\n} from 'lit';\n\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-code-editor.css';\nimport { EditorView } from 'codemirror';\nimport { ViewUpdate, placeholder } from '@codemirror/view';\nimport { \n Compartment,\n EditorState,\n Extension\n} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\nimport { html as htmlLang } from '@codemirror/lang-html';\nimport { autocompletion,CompletionContext,CompletionResult } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { Theme } from './theme';\n\nconst TIME_OUT_DURATION=200;\n// Choose the appropriate mode for your use case\n\n/**\n * Nile icon component.\n *\n * @tag nile-code-editor\n *\n */\n@customElement('nile-code-editor')\nexport class NileCodeEditor extends NileElement {\n \n @query('.code-mirror') codeEditor: HTMLInputElement;\n\n @property({ type: String, reflect: true , attribute: true }) value = '';\n\n @property({ type: String, reflect: true , attribute: true }) expandIcon = \"expand-2\";\n\n @property({ type: String, reflect: true , attribute: true }) placeholder = \"\";\n\n @property({ type: Object, reflect: true , attribute: true }) customAutoCompletions: object | any = {};\n\n @property({ type: Array, reflect: true , attribute: true }) customCompletionsPaths: string[] = [];\n\n @property({ type: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' | 'html' = 'javascript';\n\n @property({ type: String, reflect: true , attribute: 'error-message' }) errorMessage: string = '';\n\n @property({ type: Boolean, reflect: true , attribute: 'error' }) error: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: 'noborder' }) noborder: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) multiline: boolean = false;\n \n @property({ type: Boolean, reflect: true , attribute: true }) allowVariableInCustomSuggestion: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbers: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbersMultiline: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) hasScroller: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) expandable: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true}) readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true}) debounce: boolean = false;\n\n public view: EditorView;\n public viewState:EditorState;\n private timeOut: any = null;\n\n // Compartments for initialiazing and switching extensions\n private lineNumbersComp = new Compartment();\n private restrictSingleLineComp = new Compartment();\n private readOnlyComp = new Compartment();\n private customCompletionComp = new Compartment();\n private placeholderComp = new Compartment();\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init',undefined,false);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.view.destroy()\n this.emit('nile-destroy',undefined,false);\n }\n\n firstUpdated() {\n this.createNewView()\n this.emit('nile-after-init',{ \n codeMirrorInstance: this.view, \n createNewView: this.createNewView, \n insertAtCursor: this.insertBetweenCode \n }, false )\n }\n\n protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void{\n super.updated(changedProperties);\n if (changedProperties.has('value') && this.view.state.doc.toString()!=this.value) {\n // Editor has already been initialized, update its state\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('multiline')) {\n this.view.dispatch({\n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())\n ],\n })\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('readonly')) {\n this.view.dispatch({ \n effects: [\n this.readOnlyComp.reconfigure(this.getReadOnlyExtension()),\n ]\n })\n }\n if (changedProperties.has('placeholder')) {\n this.view.dispatch({ \n effects: [\n this.placeholderComp.reconfigure(this.getPlaceholderExtension()),\n ]\n })\n }\n if (changedProperties.has('lineNumbers') || changedProperties.has('lineNumbersMultiline')) {\n this.view.dispatch({ \n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n ]\n })\n }\n if(changedProperties.has('customAutoCompletions') || changedProperties.has('customCompletionsPaths')){\n this.view.dispatch({ \n effects: [\n this.customCompletionComp.reconfigure(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }))\n ]\n })\n }\n }\n\n public render(): TemplateResult {\n const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n const noborder = !!this.noborder;\n const noScrollbar = !this.hasScroller\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n 'noborder': noborder,\n 'error': hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n 'no-scroller': noScrollbar\n })}\n >\n ${this.expandable\n ? html` \n <nile-icon\n name=\"${this.expandIcon}\"\n class=\"code-editor__icon__container\"\n size=\"16\"\n color=\"black\"\n @click=\"${(e: CustomEvent) => this.emit('nile-expand')}\"\n ></nile-icon>`\n : ''}\n </div>\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\n }\n\n createNewView(emitEvent=true){\n if(this.view) this.view.destroy();\n this.createState()\n this.view = new EditorView({\n state: this.viewState,\n parent: this.codeEditor\n });\n\n if(emitEvent) this.emit('nile-after-update',{ createNewView: this.createNewView, codeMirrorInstance: this.view, }, false );\n }\n\n createState(){\n const lineNumbersExtension = this.lineNumbersComp.of(this.getLineNumbersExension());\n const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());\n const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension())\n const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension())\n const language = this.getLanguageExtension()\n const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }));\n\n this.viewState = EditorState.create({\n doc: !this.multiline ? convertToSingleLine(this.value) : this.value,\n extensions: [\n basicSetup({\n highlightActiveLine: false,\n foldGutter: false,\n }),\n lineNumbersExtension,\n readOnlyExtension,\n restrictSingleLineExtension,\n customAutoCompletions,\n placeholderExtension,\n autocompletion(),\n language,\n EditorView.theme(Theme),\n EditorView.updateListener.of((v: ViewUpdate) => {\n if (v.docChanged) {\n this.debounce ? this.emitAfterTimeout({ value: this.view.state.doc.toString() }) : this.emit('nile-change', { value: this.view.state.doc.toString() })\n }\n }),\n EditorView.domEventHandlers({\n focus: () => this.dispatchEvent(new Event('nile-focus')),\n blur: () => this.dispatchEvent(new Event('nile-blur')),\n }),\n ],\n });\n return this.viewState\n }\n\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n const text = context.state.doc.sliceString(0, context.pos);\n const lastWord = text.split('\\n').at(-1)?.split(' ').at(-1) || '';\n const [textBeforeCursor, baseTextAfterSeperation] = splitStringAtLastSeparator(lastWord);\n \n return this.getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation) \n || this.getTopLevelSuggestions(context, textBeforeCursor);\n };\n\n getNestedSuggestions(context: CompletionContext, textBeforeCursor: string, baseTextAfterSeperation: string) {\n // Return early if not a valid path or not ending with . or [\n if (!isValidPath(textBeforeCursor) || !['.', '['].includes(textBeforeCursor.at(-1)!)) {\n return null;\n }\n\n const path = parsePath(textBeforeCursor);\n if (!path) return null;\n\n const textAfterSeperation = baseTextAfterSeperation.replace(/[\"'\\[]/g, '');\n const isInString = textAfterSeperation !== baseTextAfterSeperation;\n const isBracket = textBeforeCursor.at(-1) === '[';\n\n // Return null if we're in a string after a dot\n if (textBeforeCursor.at(-1) === '.' && isInString) return null;\n\n // Get nested properties and filter by text after separation if it exists\n let resolved = resolveNestedProperties(this.customAutoCompletions, path);\n if (!resolved || typeof resolved !== 'object') return null;\n\n if (textAfterSeperation) {\n resolved = Object.fromEntries(\n Object.entries(resolved).filter(([key]) => \n key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())\n )\n );\n }\n\n return {\n from: context.pos - textAfterSeperation.length,\n options: Object.keys(resolved).map(key => ({\n label: key,\n type: 'property',\n info: `Key of ${path[path.length - 1]}`,\n apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) \n ? `'${key}'` \n : key,\n boost: 999\n }))\n };\n }\n\n getTopLevelSuggestions(context: CompletionContext,textBeforeCursor:string){\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (!baseMatch) return null;\n \n const optionsList = Object.keys(this.customAutoCompletions).filter(key => \n Object.keys(this.customAutoCompletions[key]).length && \n key.toLowerCase().startsWith(textBeforeCursor.toLowerCase())\n );\n \n const options=optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n if(this.customCompletionsPaths.length){\n this.customCompletionsPaths\n .filter(path=>path.toLocaleLowerCase().includes(textBeforeCursor.toLocaleLowerCase()))\n .map(path=>{\n options.push({\n label: ''+path,\n type: 'property',\n apply: ''+path,\n boost: 998\n })\n })\n }\n return {\n from: context.pos - baseMatch[1].length,\n options: options\n }\n }\n\n emitAfterTimeout(value:any){\n if(this.timeOut) clearTimeout(this.timeOut);\n this.timeOut=setTimeout(()=> this.emit('nile-change', value, false), TIME_OUT_DURATION)\n }\n\n public insertBetweenCode=(text: string) => {\n const transaction = this.view.state.changeByRange(range => {\n const { from, to } = range;\n return { changes: { from:from, to, insert: text }, range };\n });\n this.view.dispatch(transaction);\n }\n\n singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension():Extension{\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\n case 'html':\n return htmlLang();\n default:\n return javascript(); \n }\n }\n\n getReadOnlyExtension() {\n return this.readonly ? EditorState.readOnly.of(true) : [];\n }\n\n getSingleLineExtension() {\n return !this.multiline ? EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n ) : [];\n }\n\n getPlaceholderExtension(){\n return this.placeholder ? placeholder(this.placeholder) : [];\n }\n\n restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n\nfunction parsePath(text: string) {\n const regex = /([a-zA-Z_$][\\w$]*)(\\[(?:[^\\]]+)\\]|\\.[a-zA-Z_$][\\w$]*)*/g;\n const matches = [...text.matchAll(regex)];\n if (matches.length > 0) {\n const base = matches[0][1]; // The base object name\n const keys = [base];\n // Extract keys from dot or bracket notation\n const pathMatches = text.match(/\\[(.*?)\\]|\\.(\\w+)/g) || [];\n for (const match of pathMatches) {\n if (match.startsWith('[')) {\n keys.push(match.slice(1, -1).replace(/['\"]/g, '')); // Remove brackets and quotes\n } else if (match.startsWith('.')) {\n keys.push(match.slice(1));\n }\n }\n return keys;\n }\n return null;\n};\n\nfunction splitStringAtLastSeparator(input:string) {\n const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));\n if (lastSeparatorIndex === -1) return [input, ''];\n return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];\n}\n\nfunction resolveNestedProperties (obj:any, keys:any[]){\n return keys.reduce((acc, key) => {\n if (acc && typeof acc === 'object') {\n return acc[key];\n }\n return null;\n }, obj);\n};\n\nfunction isValidPath(path: string) {\n // Regex to validate the format of the string\n const regex = /^([a-zA-Z_$][\\w$]*)(\\.[a-zA-Z_$][\\w$]*|\\[\\s*(['\"]?[a-zA-Z0-9_$]*['\"]?)\\s*\\])*([\\.\\[])?$/;\n // Test the string against the regex\n return regex.test(path);\n}\n\nfunction convertToSingleLine(code: string) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\n}"]}
1
+ {"version":3,"file":"nile-code-editor.js","sourceRoot":"","sources":["../../../src/nile-code-editor/nile-code-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EACL,IAAI,GAIL,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC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AAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,gDAAgD;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1C,CAAC","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 {\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValueMap,\n} from 'lit';\n\nimport { customElement, query, property } from 'lit/decorators.js';\nimport { styles } from './nile-code-editor.css';\nimport { EditorView } from 'codemirror';\nimport { ViewUpdate, placeholder } from '@codemirror/view';\nimport { \n Compartment,\n EditorState,\n Extension\n} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\nimport { html as htmlLang } from '@codemirror/lang-html';\nimport { autocompletion,CompletionContext,CompletionResult } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { Theme } from './theme';\n\n// Choose the appropriate mode for your use case\n\n/**\n * Nile icon component.\n *\n * @tag nile-code-editor\n *\n */\n@customElement('nile-code-editor')\nexport class NileCodeEditor extends NileElement {\n \n @query('.code-mirror') codeEditor: HTMLInputElement;\n\n @property({ type: String, reflect: true , attribute: true }) value = '';\n\n @property({ type: String, reflect: true , attribute: true }) expandIcon = \"expand-2\";\n\n @property({ type: String, reflect: true , attribute: true }) placeholder = \"\";\n\n @property({ type: Object, reflect: true , attribute: true }) customAutoCompletions: object | any = {};\n\n @property({ type: Array, reflect: true , attribute: true }) customCompletionsPaths: string[] = [];\n\n @property({ type: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' | 'html' = 'javascript';\n\n @property({ type: String, reflect: true , attribute: 'error-message' }) errorMessage: string = '';\n\n @property({ type: Boolean, reflect: true , attribute: 'error' }) error: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: 'noborder' }) noborder: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) multiline: boolean = false;\n \n @property({ type: Boolean, reflect: true , attribute: true }) allowVariableInCustomSuggestion: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbers: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true }) lineNumbersMultiline: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) hasScroller: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true }) expandable: boolean = true;\n\n @property({ type: Boolean, reflect: true , attribute: true}) readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true , attribute: true}) debounce: boolean = false;\n\n @property({ type: Number, reflect: true , attribute: true}) debounceTimeout: number = 200;\n\n public view: EditorView;\n public viewState:EditorState;\n private timeOut: any = null;\n\n // Compartments for initialiazing and switching extensions\n private lineNumbersComp = new Compartment();\n private restrictSingleLineComp = new Compartment();\n private readOnlyComp = new Compartment();\n private customCompletionComp = new Compartment();\n private placeholderComp = new Compartment();\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init',undefined,false);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.view.destroy()\n this.emit('nile-destroy',undefined,false);\n }\n\n firstUpdated() {\n this.createNewView()\n this.emit('nile-after-init',{ \n codeMirrorInstance: this.view, \n createNewView: this.createNewView, \n insertAtCursor: this.insertBetweenCode \n }, false )\n }\n\n protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void{\n super.updated(changedProperties);\n if (changedProperties.has('value') && this.view.state.doc.toString()!=this.value) {\n // Editor has already been initialized, update its state\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('multiline')) {\n this.view.dispatch({\n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())\n ],\n })\n this.singleLineMultiLineToggle();\n }\n if (changedProperties.has('readonly')) {\n this.view.dispatch({ \n effects: [\n this.readOnlyComp.reconfigure(this.getReadOnlyExtension()),\n ]\n })\n }\n if (changedProperties.has('placeholder')) {\n this.view.dispatch({ \n effects: [\n this.placeholderComp.reconfigure(this.getPlaceholderExtension()),\n ]\n })\n }\n if (changedProperties.has('lineNumbers') || changedProperties.has('lineNumbersMultiline')) {\n this.view.dispatch({ \n effects: [\n this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),\n ]\n })\n }\n if(changedProperties.has('customAutoCompletions') || changedProperties.has('customCompletionsPaths')){\n this.view.dispatch({ \n effects: [\n this.customCompletionComp.reconfigure(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }))\n ]\n })\n }\n }\n\n public render(): TemplateResult {\n const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n const noborder = !!this.noborder;\n const noScrollbar = !this.hasScroller\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n 'noborder': noborder,\n 'error': hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n 'no-scroller': noScrollbar\n })}\n >\n ${this.expandable\n ? html` \n <nile-icon\n name=\"${this.expandIcon}\"\n class=\"code-editor__icon__container\"\n size=\"16\"\n color=\"black\"\n @click=\"${(e: CustomEvent) => this.emit('nile-expand')}\"\n ></nile-icon>`\n : ''}\n </div>\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\n }\n\n createNewView(emitEvent=true){\n if(this.view) this.view.destroy();\n this.createState()\n this.view = new EditorView({\n state: this.viewState,\n parent: this.codeEditor\n });\n\n if(emitEvent) this.emit('nile-after-update',{ createNewView: this.createNewView, codeMirrorInstance: this.view, }, false );\n }\n\n createState(){\n const lineNumbersExtension = this.lineNumbersComp.of(this.getLineNumbersExension());\n const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());\n const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension())\n const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension())\n const language = this.getLanguageExtension()\n const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({\n autocomplete: this.customAutocomplete\n }));\n\n this.viewState = EditorState.create({\n doc: !this.multiline ? convertToSingleLine(this.value) : this.value,\n extensions: [\n basicSetup({\n highlightActiveLine: false,\n foldGutter: false,\n }),\n lineNumbersExtension,\n readOnlyExtension,\n restrictSingleLineExtension,\n customAutoCompletions,\n placeholderExtension,\n autocompletion(),\n language,\n EditorView.theme(Theme),\n EditorView.updateListener.of((v: ViewUpdate) => {\n if (v.docChanged) {\n this.debounce ? this.emitAfterTimeout({ value: this.view.state.doc.toString() }) : this.emit('nile-change', { value: this.view.state.doc.toString() })\n }\n }),\n EditorView.domEventHandlers({\n focus: () => this.dispatchEvent(new Event('nile-focus')),\n blur: () => this.dispatchEvent(new Event('nile-blur')),\n }),\n ],\n });\n return this.viewState\n }\n /**\n * Custom autocomplete handler for code editor suggestions\n * @param context CompletionContext from CodeMirror\n * @returns CompletionResult with suggestions or null if no suggestions\n */\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n const text = context.state.doc.sliceString(0, context.pos);\n const lastWord = text.split('\\n').at(-1)?.split(' ').at(-1) || '';\n const [textBeforeCursor, baseTextAfterSeperation] = splitStringAtLastSeparator(lastWord);\n \n return this.getNestedSuggestions(context, textBeforeCursor, baseTextAfterSeperation) \n || this.getTopLevelSuggestions(context, textBeforeCursor);\n };\n\n /**\n * Gets nested property suggestions based on the current path\n * @param context CompletionContext from CodeMirror\n * @param textBeforeCursor Text before cursor position\n * @param baseTextAfterSeperation Text after the last separator (. or [)\n * @returns CompletionResult with nested suggestions or null\n */\n getNestedSuggestions(context: CompletionContext, textBeforeCursor: string, baseTextAfterSeperation: string) {\n // Return early if not a valid path or not ending with . or [\n if (!isValidPath(textBeforeCursor) || !['.', '['].includes(textBeforeCursor.at(-1)!)) {\n return null;\n }\n\n const path = parsePath(textBeforeCursor);\n if (!path) return null;\n\n const textAfterSeperation = baseTextAfterSeperation.replace(/[\"'\\[]/g, '');\n const isInString = textAfterSeperation !== baseTextAfterSeperation;\n const isBracket = textBeforeCursor.at(-1) === '[';\n\n // Return null if we're in a string after a dot\n if (textBeforeCursor.at(-1) === '.' && isInString) return null;\n\n // Get nested properties and filter by text after separation if it exists\n let resolved = resolveNestedProperties(this.customAutoCompletions, path);\n if (!resolved || typeof resolved !== 'object') return null;\n\n if (textAfterSeperation) {\n resolved = Object.fromEntries(\n Object.entries(resolved).filter(([key]) => \n key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())\n )\n );\n }\n\n return {\n from: context.pos - textAfterSeperation.length,\n options: Object.keys(resolved).map(key => ({\n label: key,\n type: 'property',\n info: `Key of ${path[path.length - 1]}`,\n apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) \n ? `'${key}'` \n : key,\n boost: 999\n }))\n };\n }\n\n /**\n * Gets top level suggestions based on custom completions and paths\n * @param context CompletionContext from CodeMirror\n * @param textBeforeCursor Text before cursor position\n * @returns CompletionResult with top level suggestions or null\n */\n getTopLevelSuggestions(context: CompletionContext,textBeforeCursor:string){\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (!baseMatch) return null;\n \n const optionsList = Object.keys(this.customAutoCompletions).filter(key => \n Object.keys(this.customAutoCompletions[key]).length && \n key.toLowerCase().startsWith(textBeforeCursor.toLowerCase())\n );\n \n const options=optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n if(this.customCompletionsPaths.length){\n this.customCompletionsPaths\n .filter(path=>path.toLocaleLowerCase().includes(textBeforeCursor.toLocaleLowerCase()))\n .map(path=>{\n options.push({\n label: ''+path,\n type: 'property',\n apply: ''+path,\n boost: 998\n })\n })\n }\n return {\n from: context.pos - baseMatch[1].length,\n options: options\n }\n }\n\n emitAfterTimeout(value:any){\n if(this.timeOut) clearTimeout(this.timeOut);\n this.timeOut=setTimeout(()=> this.emit('nile-change', value, false), this.debounceTimeout)\n }\n\n public insertBetweenCode=(text: string) => {\n const transaction = this.view.state.changeByRange(range => {\n const { from, to } = range;\n return { changes: { from:from, to, insert: text }, range };\n });\n this.view.dispatch(transaction);\n }\n\n singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension():Extension{\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\n case 'html':\n return htmlLang();\n default:\n return javascript(); \n }\n }\n\n getReadOnlyExtension() {\n return this.readonly ? EditorState.readOnly.of(true) : [];\n }\n\n getSingleLineExtension() {\n return !this.multiline ? EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n ) : [];\n }\n\n getPlaceholderExtension(){\n return this.placeholder ? placeholder(this.placeholder) : [];\n }\n\n restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n\n/**\n * Parses a string path into an array of keys representing nested object access\n * @param text The path string to parse (e.g. \"foo.bar[0].baz\")\n * @returns Array of keys if valid path, null otherwise\n * @example\n * parsePath(\"foo.bar[0]\") // returns [\"foo\", \"bar\", \"0\"]\n * parsePath(\"invalid\") // returns null\n */\nfunction parsePath(text: string) {\n const regex = /([a-zA-Z_$][\\w$]*)(\\[(?:[^\\]]+)\\]|\\.[a-zA-Z_$][\\w$]*)*/g;\n const matches = [...text.matchAll(regex)];\n if (matches.length > 0) {\n const base = matches[0][1]; // The base object name\n const keys = [base];\n // Extract keys from dot or bracket notation\n const pathMatches = text.match(/\\[(.*?)\\]|\\.(\\w+)/g) || [];\n for (const match of pathMatches) {\n if (match.startsWith('[')) {\n keys.push(match.slice(1, -1).replace(/['\"]/g, '')); // Remove brackets and quotes\n } else if (match.startsWith('.')) {\n keys.push(match.slice(1));\n }\n }\n return keys;\n }\n return null;\n};\n\n/**\n * Splits a path string at the last separator (. or [)\n * @param input The path string to split\n * @returns Array containing [path up to last separator, remainder after separator]\n * @example\n * splitStringAtLastSeparator(\"foo.bar[0]\") // returns [\"foo.bar[\", \"0\"]\n */\nfunction splitStringAtLastSeparator(input:string) {\n const lastSeparatorIndex = Math.max(input.lastIndexOf('.'), input.lastIndexOf('['));\n if (lastSeparatorIndex === -1) return [input, ''];\n return [input.slice(0, lastSeparatorIndex + 1), input.slice(lastSeparatorIndex + 1)];\n}\n\n/**\n * Traverses an object using an array of keys to access nested properties\n * @param obj The object to traverse\n * @param keys Array of keys defining the path to the desired property\n * @returns The value at the specified path, or null if path is invalid\n * @example\n * resolveNestedProperties({foo: {bar: 123}}, [\"foo\", \"bar\"]) // returns 123\n */\nfunction resolveNestedProperties (obj:any, keys:any[]){\n return keys.reduce((acc, key) => {\n if (acc && typeof acc === 'object') {\n return acc[key];\n }\n return null;\n }, obj);\n};\n\n/**\n * Validates if a string represents a valid object path format\n * @param path The path string to validate\n * @returns Boolean indicating if path format is valid\n * @example\n * isValidPath(\"foo.bar[0]\") // returns true\n * isValidPath(\"foo..bar\") // returns false\n */\nfunction isValidPath(path: string) {\n // Regex to validate the format of the string\n const regex = /^([a-zA-Z_$][\\w$]*)(\\.[a-zA-Z_$][\\w$]*|\\[\\s*(['\"]?[a-zA-Z0-9_$]*['\"]?)\\s*\\])*([\\.\\[])?$/;\n // Test the string against the regex\n return regex.test(path);\n}\n\n/**\n * Converts multi-line code into a single line by removing line breaks and extra whitespace\n * @param code The code string to convert\n * @returns Single line version of the code\n * @example\n * convertToSingleLine(\"foo\\n bar\") // returns \"foo bar\"\n */\nfunction convertToSingleLine(code: string) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\n}"]}
@@ -123,7 +123,7 @@ export const styles = css `
123
123
  display: flex;
124
124
  flex-wrap: wrap;
125
125
  justify-content: end;
126
- gap: 0.25rem;
126
+ gap: 0.5rem;
127
127
  padding: 0 var(--header-spacing);
128
128
  }
129
129