@aquera/nile-elements 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-error-notification.css.cjs.js"],function(_export,_context){"use strict";var i,r,o,t,e,n,_templateObject,s;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){i=_tslib.__decorate;},function(_lit){r=_lit.LitElement;o=_lit.html;},function(_litDecoratorsJs){t=_litDecoratorsJs.property;e=_litDecoratorsJs.customElement;},function(_nileErrorNotificationCssCjsJs){n=_nileErrorNotificationCssCjsJs.s;}],execute:function execute(){_export("N",s=/*#__PURE__*/function(_r){function s(){var _this;_classCallCheck(this,s);_this=_callSuper(this,s,arguments),_this.errorMessage="",_this.color="";return _this;}_inherits(s,_r);return _createClass(s,[{key:"connectedCallback",value:function connectedCallback(){_get(_getPrototypeOf(s.prototype),"connectedCallback",this).call(this),this.color&&this.style.setProperty("--indication-color",this.color);}},{key:"render",value:function render(){return o(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ","\n </div>\n "])),this.errorMessage);}}],[{key:"styles",get:function get(){return[n];}}]);}(r));i([t({type:String,reflect:!0})],s.prototype,"errorMessage",void 0),i([t({type:String,reflect:!0})],s.prototype,"color",void 0),_export("N",s=i([e("nile-error-notification")],s));}};});
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-error-notification.css.cjs.js"],function(_export,_context){"use strict";var i,r,o,t,e,n,_templateObject,s;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 _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){i=_tslib.__decorate;},function(_lit){r=_lit.LitElement;o=_lit.html;},function(_litDecoratorsJs){t=_litDecoratorsJs.property;e=_litDecoratorsJs.customElement;},function(_nileErrorNotificationCssCjsJs){n=_nileErrorNotificationCssCjsJs.s;}],execute:function execute(){_export("N",s=/*#__PURE__*/function(_r){function s(){var _this;_classCallCheck(this,s);_this=_callSuper(this,s,arguments),_this.errorMessage="",_this.color="";return _this;}_inherits(s,_r);return _createClass(s,[{key:"updated",value:function updated(i){i.has("color")&&this.style.setProperty("--indication-color",this.color);}},{key:"render",value:function render(){return o(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ","\n </div>\n "])),this.errorMessage);}}],[{key:"styles",get:function get(){return[n];}}]);}(r));i([t({type:String,reflect:!0})],s.prototype,"errorMessage",void 0),i([t({type:String,reflect:!0})],s.prototype,"color",void 0),_export("N",s=i([e("nile-error-notification")],s));}};});
2
2
  //# sourceMappingURL=nile-error-notification.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-error-notification.cjs.js","sources":["../../../src/nile-error-notification/nile-error-notification.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 {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styles } from './nile-error-notification.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-error-notification\n *\n */\n@customElement('nile-error-notification')\nexport class NileErrorNotification extends LitElement {\n /**\n * The styles for ErrorNotification\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 // Represents the error message to be displayed to the user.\n @property({ type: String, reflect: true }) errorMessage: string = '';\n\n @property({ type: String, reflect: true }) color: string = '';\n \n connectedCallback(): void {\n super.connectedCallback();\n if(this.color){\n this.style.setProperty('--indication-color',this.color)\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 return html`\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ${this.errorMessage}\n </div>\n `;\n }\n\n /* #endregion */\n}\n\nexport default NileErrorNotification;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-error-notification': NileErrorNotification;\n }\n}\n"],"names":["NileErrorNotification","s","this","errorMessage","color","_this","_inherits","_r","_createClass","key","value","connectedCallback","super","style","setProperty","render","html","_templateObject","_taggedTemplateLiteral","get","styles","LitElement","__decorate","property","type","String","reflect","prototype","_export","customElement"],"mappings":"mkIAuBaA,4BAAN,SAAAC,EAAA,uEAUuCC,KAAAA,CAAYC,YAAAA,CAAW,EAEvBD,CAAAA,KAAAA,CAAKE,KAAW,CAAA,EAiC7D,QAAAC,KAAA,EAxCQC,SAAA,CAAAL,CAAA,CAAAM,EAAA,SAAAC,YAAA,CAAAP,CAAA,GAAAQ,GAAA,qBAAAC,KAAA,CASP,SAAAC,kBAAA,CAAAA,CACEC,IAAAA,CAAAA,eAAAA,CAAAA,CAAAA,CAAAA,SAAAA,4BAAAA,IAAAA,OACGV,IAAAA,CAAKE,OACNF,IAAKW,CAAAA,KAAAA,CAAMC,YAAY,oBAAqBZ,CAAAA,IAAAA,CAAKE,MAEpD,EAUM,GAAAK,GAAA,UAAAC,KAAA,UAAAK,OAAA,CACL,CAAA,MAAOC,CAAAA,CAAI,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA,6SASLhB,IAAKC,CAAAA,YAAAA,EAGZ,CAAA,KAAAM,GAAA,UAAAU,GAAA,CArCM,SAAAA,IAAA,CAAWC,CAChB,MAAO,CAACA,CAAAA,CACT,EAOD,MAdyCC,CAAAA,GAUGC,CAAA,CAAA,CAA3CC,CAAS,CAAA,CAAEC,IAAMC,CAAAA,MAAAA,CAAQC,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC1B,CAAA2B,CAAAA,SAAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAE1BL,CAAA,CAAA,CAA3CC,CAAS,CAAA,CAAEC,IAAMC,CAAAA,MAAAA,CAAQC,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4B1B,CAAA2B,CAAAA,SAAAA,CAAA,OAAA,CAAA,IAAA,EAAA,CAAA,CAAAC,OAAA,KAZpD5B,CAAqBsB,CAAAA,CAAAA,CAAA,CADjCO,CAAAA,CAAc,4BACF7B"}
1
+ {"version":3,"file":"nile-error-notification.cjs.js","sources":["../../../src/nile-error-notification/nile-error-notification.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 {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styles } from './nile-error-notification.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-error-notification\n *\n */\n@customElement('nile-error-notification')\nexport class NileErrorNotification extends LitElement {\n /**\n * The styles for ErrorNotification\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 // Represents the error message to be displayed to the user.\n @property({ type: String, reflect: true }) errorMessage: string = '';\n\n @property({ type: String, reflect: true }) color: string = '';\n \n protected updated(_changedProperties: PropertyValues): void {\n if(_changedProperties.has('color')){\n this.style.setProperty('--indication-color',this.color)\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 return html`\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ${this.errorMessage}\n </div>\n `;\n }\n\n /* #endregion */\n}\n\nexport default NileErrorNotification;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-error-notification': NileErrorNotification;\n }\n}\n"],"names":["NileErrorNotification","s","this","errorMessage","color","_this","_inherits","_r","_createClass","key","value","updated","_changedProperties","has","style","setProperty","render","html","_templateObject","_taggedTemplateLiteral","get","styles","LitElement","__decorate","property","type","String","reflect","prototype","_export","customElement"],"mappings":"6hHAwBaA,4BAAN,SAAAC,EAAA,uEAUuCC,KAAAA,CAAYC,YAAAA,CAAW,EAEvBD,CAAAA,KAAAA,CAAKE,KAAW,CAAA,EAgC7D,QAAAC,KAAA,EAvCQC,SAAA,CAAAL,CAAA,CAAAM,EAAA,SAAAC,YAAA,CAAAP,CAAA,GAAAQ,GAAA,WAAAC,KAAA,CASG,SAAAC,QAAQC,GACbA,CAAmBC,CAAAA,GAAAA,CAAI,UACxBX,IAAKY,CAAAA,KAAAA,CAAMC,YAAY,oBAAqBb,CAAAA,IAAAA,CAAKE,MAEpD,EAUM,GAAAK,GAAA,UAAAC,KAAA,UAAAM,OAAA,CACL,CAAA,MAAOC,CAAAA,CAAI,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA,6SASLjB,IAAKC,CAAAA,YAAAA,EAGZ,CAAA,KAAAM,GAAA,UAAAW,GAAA,CApCM,SAAAA,IAAA,CAAWC,CAChB,MAAO,CAACA,CAAAA,CACT,EAOS,MAd+BC,CAAAA,GAUGC,CAAA,CAAA,CAA3CC,CAAS,CAAA,CAAEC,IAAMC,CAAAA,MAAAA,CAAQC,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC3B,CAAA4B,CAAAA,SAAAA,CAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAE1BL,CAAA,CAAA,CAA3CC,CAAS,CAAA,CAAEC,IAAMC,CAAAA,MAAAA,CAAQC,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4B3B,CAAA4B,CAAAA,SAAAA,CAAA,OAAA,CAAA,IAAA,EAAA,CAAA,CAAAC,OAAA,KAZpD7B,CAAqBuB,CAAAA,CAAAA,CAAA,CADjCO,CAAAA,CAAc,4BACF9B"}
@@ -1,4 +1,4 @@
1
- import{__decorate as i}from"tslib";import{LitElement as r,html as o}from"lit";import{property as t,customElement as e}from"lit/decorators.js";import{s as n}from"./nile-error-notification.css.esm.js";let s=class extends r{constructor(){super(...arguments),this.errorMessage="",this.color=""}static get styles(){return[n]}connectedCallback(){super.connectedCallback(),this.color&&this.style.setProperty("--indication-color",this.color)}render(){return o`
1
+ import{__decorate as i}from"tslib";import{LitElement as r,html as o}from"lit";import{property as t,customElement as e}from"lit/decorators.js";import{s as n}from"./nile-error-notification.css.esm.js";let s=class extends r{constructor(){super(...arguments),this.errorMessage="",this.color=""}static get styles(){return[n]}updated(i){i.has("color")&&this.style.setProperty("--indication-color",this.color)}render(){return o`
2
2
  <div class="nile-error-notification">
3
3
  <nile-icon
4
4
  name="info2"
@@ -19,13 +19,14 @@ export declare class NileCodeEditor extends NileElement {
19
19
  codeEditor: HTMLInputElement;
20
20
  value: string;
21
21
  expandIcon: string;
22
+ placeholder: string;
22
23
  customAutoCompletions: object | any;
23
24
  language: 'javascript' | 'sql' | 'json';
24
25
  errorMessage: string;
25
26
  error: boolean;
26
27
  noborder: boolean;
27
28
  multiline: boolean;
28
- suggestionBracketSupport: boolean;
29
+ allowVariableInCustomSuggestion: boolean;
29
30
  lineNumbers: boolean;
30
31
  lineNumbersMultiline: boolean;
31
32
  hasScroller: boolean;
@@ -39,6 +40,7 @@ export declare class NileCodeEditor extends NileElement {
39
40
  private restrictSingleLineComp;
40
41
  private readOnlyComp;
41
42
  private customCompletionComp;
43
+ private placeholderComp;
42
44
  /**
43
45
  * The styles for CodeEditor
44
46
  * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
@@ -59,8 +61,8 @@ export declare class NileCodeEditor extends NileElement {
59
61
  getLanguageExtension(): import("@codemirror/language").LanguageSupport;
60
62
  getReadOnlyExtension(): import("@codemirror/state").Extension;
61
63
  getSingleLineExtension(): import("@codemirror/state").Extension;
64
+ getPlaceholderExtension(): import("@codemirror/state").Extension;
62
65
  restrictSingleLine(): import("@codemirror/state").Extension;
63
- emitNileExpand(): void;
64
66
  customAutocomplete: (context: CompletionContext) => CompletionResult | null;
65
67
  resolveNestedProperties: (obj: any, keys: any[]) => any;
66
68
  parsePath(text: string): string[] | null;
@@ -9,9 +9,10 @@ import { html, } from 'lit';
9
9
  import { customElement, query, property } from 'lit/decorators.js';
10
10
  import { styles } from './nile-code-editor.css';
11
11
  import { EditorView } from 'codemirror';
12
+ import { placeholder } from '@codemirror/view';
12
13
  import { Compartment, EditorState, } from '@codemirror/state';
13
14
  import { lineNumbers } from '@codemirror/view';
14
- import { javascript, javascriptLanguage, scopeCompletionSource, } from '@codemirror/lang-javascript';
15
+ import { javascript, javascriptLanguage, } from '@codemirror/lang-javascript';
15
16
  import { sql } from '@codemirror/lang-sql';
16
17
  import { json } from '@codemirror/lang-json';
17
18
  import { autocompletion } from '@codemirror/autocomplete';
@@ -32,13 +33,14 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
32
33
  super(...arguments);
33
34
  this.value = '';
34
35
  this.expandIcon = "expand-2";
36
+ this.placeholder = "";
35
37
  this.customAutoCompletions = {};
36
38
  this.language = 'javascript';
37
39
  this.errorMessage = '';
38
40
  this.error = false;
39
41
  this.noborder = false;
40
42
  this.multiline = false;
41
- this.suggestionBracketSupport = false;
43
+ this.allowVariableInCustomSuggestion = false;
42
44
  this.lineNumbers = false;
43
45
  this.lineNumbersMultiline = true;
44
46
  this.hasScroller = true;
@@ -51,6 +53,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
51
53
  this.restrictSingleLineComp = new Compartment();
52
54
  this.readOnlyComp = new Compartment();
53
55
  this.customCompletionComp = new Compartment();
56
+ this.placeholderComp = new Compartment();
54
57
  this.insertBetweenCode = (text) => {
55
58
  const transaction = this.view.state.changeByRange(range => {
56
59
  const { from, to } = range;
@@ -63,13 +66,17 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
63
66
  let text = context.state.doc.sliceString(0, context.pos);
64
67
  const [textBeforeCursor, baseTextAfterSeperation] = this.splitStringAtLastSeparator(text.split('\n').at(-1)?.split(' ').at(-1) + '');
65
68
  const textAfterSeperation = baseTextAfterSeperation.replace(/["'\[]/g, '');
66
- const isSuggestionString = textAfterSeperation != baseTextAfterSeperation;
69
+ const isInString = textAfterSeperation != baseTextAfterSeperation;
70
+ const isBracket = textBeforeCursor.at(-1) == '[';
71
+ const isDot = textBeforeCursor.at(-1) == '.';
67
72
  if (!this.isValidPath(textBeforeCursor))
68
73
  return { from: context.pos, options: [] };
69
74
  if (['.', '['].includes(textBeforeCursor[textBeforeCursor.length - 1])) {
70
75
  // Parse the path for dot or bracket notation
71
76
  const path = this.parsePath(textBeforeCursor);
72
77
  if (path) {
78
+ if (isDot && isInString)
79
+ return null;
73
80
  let resolved = this.resolveNestedProperties(this.customAutoCompletions, path);
74
81
  if (textAfterSeperation) {
75
82
  const obj = {};
@@ -88,7 +95,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
88
95
  label: key,
89
96
  type: 'property',
90
97
  info: `Key of ${path[path.length - 1]}`,
91
- apply: key,
98
+ apply: !this.allowVariableInCustomSuggestion && (isBracket && !isInString) ? "\'" + key + "\'" : key,
92
99
  boost: 999
93
100
  })),
94
101
  };
@@ -110,7 +117,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
110
117
  };
111
118
  }
112
119
  // Default to an empty list if no match
113
- return { from: context.pos, options: [] };
120
+ return null;
114
121
  };
115
122
  this.resolveNestedProperties = (obj, keys) => {
116
123
  return keys.reduce((acc, key) => {
@@ -168,6 +175,13 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
168
175
  ]
169
176
  });
170
177
  }
178
+ if (changedProperties.has('placeholder')) {
179
+ this.view.dispatch({
180
+ effects: [
181
+ this.placeholderComp.reconfigure(this.getPlaceholderExtension()),
182
+ ]
183
+ });
184
+ }
171
185
  if (changedProperties.has('lineNumbers') || changedProperties.has('lineNumbersMultiline')) {
172
186
  this.view.dispatch({
173
187
  effects: [
@@ -179,7 +193,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
179
193
  this.view.dispatch({
180
194
  effects: [
181
195
  this.customCompletionComp.reconfigure(javascriptLanguage.data.of({
182
- autocomplete: this.suggestionBracketSupport ? this.customAutocomplete : scopeCompletionSource(this.customAutoCompletions),
196
+ autocomplete: this.customAutocomplete
183
197
  }))
184
198
  ]
185
199
  });
@@ -200,15 +214,15 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
200
214
  'no-scroller': noScrollbar
201
215
  })}
202
216
  >
203
- ${this.expandable
217
+ ${this.expandable
204
218
  ? html `
205
- <nile-icon
206
- name="${this.expandIcon}"
207
- class="code-editor__icon__container"
208
- size="16"
209
- color="black"
210
- @click="${(e) => this.emitNileExpand()}"
211
- ></nile-icon>`
219
+ <nile-icon
220
+ name="${this.expandIcon}"
221
+ class="code-editor__icon__container"
222
+ size="16"
223
+ color="black"
224
+ @click="${(e) => this.emit('nile-expand')}"
225
+ ></nile-icon>`
212
226
  : ''}
213
227
  </div>
214
228
  ${hasErrorMessage
@@ -234,10 +248,11 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
234
248
  const lineNumbersExtension = this.lineNumbersComp.of(this.getLineNumbersExension());
235
249
  const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());
236
250
  const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension());
251
+ const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension());
252
+ const language = this.getLanguageExtension();
237
253
  const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({
238
- autocomplete: this.suggestionBracketSupport ? this.customAutocomplete : scopeCompletionSource(this.customAutoCompletions),
254
+ autocomplete: this.customAutocomplete
239
255
  }));
240
- const language = this.getLanguageExtension();
241
256
  this.viewState = EditorState.create({
242
257
  doc: !this.multiline ? this.convertToSingleLine(this.value) : this.value,
243
258
  extensions: [
@@ -249,6 +264,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
249
264
  readOnlyExtension,
250
265
  restrictSingleLineExtension,
251
266
  customAutoCompletions,
267
+ placeholderExtension,
252
268
  autocompletion(),
253
269
  language,
254
270
  EditorView.theme(Theme),
@@ -307,12 +323,12 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
307
323
  getSingleLineExtension() {
308
324
  return !this.multiline ? EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr) : [];
309
325
  }
326
+ getPlaceholderExtension() {
327
+ return this.placeholder ? placeholder(this.placeholder) : [];
328
+ }
310
329
  restrictSingleLine() {
311
330
  return EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr);
312
331
  }
313
- emitNileExpand() {
314
- this.emit('nile-expand', { expand: true }, false);
315
- }
316
332
  parsePath(text) {
317
333
  const regex = /([a-zA-Z_$][\w$]*)(\[(?:[^\]]+)\]|\.[a-zA-Z_$][\w$]*)*/g;
318
334
  const matches = [...text.matchAll(regex)];
@@ -356,6 +372,9 @@ __decorate([
356
372
  __decorate([
357
373
  property({ type: String, reflect: true, attribute: true })
358
374
  ], NileCodeEditor.prototype, "expandIcon", void 0);
375
+ __decorate([
376
+ property({ type: String, reflect: true, attribute: true })
377
+ ], NileCodeEditor.prototype, "placeholder", void 0);
359
378
  __decorate([
360
379
  property({ type: Object, reflect: true, attribute: true })
361
380
  ], NileCodeEditor.prototype, "customAutoCompletions", void 0);
@@ -376,7 +395,7 @@ __decorate([
376
395
  ], NileCodeEditor.prototype, "multiline", void 0);
377
396
  __decorate([
378
397
  property({ type: Boolean, reflect: true, attribute: true })
379
- ], NileCodeEditor.prototype, "suggestionBracketSupport", void 0);
398
+ ], NileCodeEditor.prototype, "allowVariableInCustomSuggestion", void 0);
380
399
  __decorate([
381
400
  property({ type: Boolean, reflect: true, attribute: true })
382
401
  ], NileCodeEditor.prototype, "lineNumbers", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"nile-code-editor.js","sourceRoot":"","sources":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ourcesContent":["/**\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 LitElement,\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 } from '@codemirror/view';\nimport { \n Compartment,\n EditorState,\n} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n scopeCompletionSource,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\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: Object, reflect: true , attribute: true }) customAutoCompletions: object | any = {};\n\n @property({ type: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' = '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 }) suggestionBracketSupport: 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\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('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('suggestionBracketSupport') ){\n this.view.dispatch({ \n effects: [\n this.customCompletionComp.reconfigure(javascriptLanguage.data.of({\n autocomplete: this.suggestionBracketSupport?this.customAutocomplete: scopeCompletionSource(this.customAutoCompletions),\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.emitNileExpand()}\"\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 customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({\n autocomplete: this.suggestionBracketSupport?this.customAutocomplete: scopeCompletionSource(this.customAutoCompletions),\n }));\n const language = this.getLanguageExtension()\n this.viewState = EditorState.create({\n doc: !this.multiline ? this.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 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 singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? this.convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n convertToSingleLine(code: any) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\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 //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension(){\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\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 restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n\n emitNileExpand() {\n this.emit('nile-expand', { expand: true },false);\n }\n\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n let text = context.state.doc.sliceString(0, context.pos);\n const [textBeforeCursor,baseTextAfterSeperation]=this.splitStringAtLastSeparator(text.split('\\n').at(-1)?.split(' ').at(-1)+'')\n const textAfterSeperation=baseTextAfterSeperation.replace(/[\"'\\[]/g, '')\n\n const isSuggestionString=textAfterSeperation!=baseTextAfterSeperation;\n\n if (!this.isValidPath(textBeforeCursor)) return { from: context.pos, options: [] };\n if(['.', '['].includes(textBeforeCursor[textBeforeCursor.length - 1])){\n // Parse the path for dot or bracket notation\n const path = this.parsePath(textBeforeCursor);\n if (path) {\n let resolved = this.resolveNestedProperties(this.customAutoCompletions, path);\n if(textAfterSeperation){\n const obj:any={}\n Object.keys(resolved).forEach((key)=>{\n if(key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())){\n obj[key]=resolved[key]\n }\n })\n resolved=obj\n }\n // If resolved is an object, provide its keys as suggestions\n if (resolved && typeof resolved === 'object') {\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: key,\n boost: 999\n })),\n };\n }\n }\n }\n \n // Match for top-level object suggestions, e.g., \"a\"\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (baseMatch) {\n const optionsList=Object.keys(this.customAutoCompletions).filter(key=>key.toLowerCase().startsWith(textBeforeCursor.toLowerCase()));\n return {\n from: context.pos - baseMatch[1].length,\n options: optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n }\n }\n // Default to an empty list if no match\n return { from: context.pos, options: [] };\n };\n\n 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 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 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 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 /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\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,EAEL,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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AAG,SAAS,EAAE,IAAI,EAAE,CAAC;kDAA4B;AAE5B;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAG,SAAS,EAAE,IAAI,EAAC,CAAC;gDAA2B;AAE1B;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAG,SAAS,EAAE,IAAI,EAAC,CAAC;gDAA2B;AAlC5E,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwX1B;;AAED,eAAe,cAAc,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 LitElement,\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} from '@codemirror/state';\n\nimport { lineNumbers } from '@codemirror/view';\nimport {\n javascript,\n javascriptLanguage,\n scopeCompletionSource,\n} from '@codemirror/lang-javascript';\nimport { sql } from '@codemirror/lang-sql';\nimport { json } from '@codemirror/lang-json';\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: String, reflect: true , attribute: true}) language: 'javascript' | 'sql' | 'json' = '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('suggestionBracketSupport') ){\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 ? this.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 singleLineMultiLineToggle() {\n this.view.dispatch({\n changes: {\n from: 0,\n to: this.view.state.doc.length,\n insert: !this.multiline\n ? this.convertToSingleLine(this.value)\n : this.value,\n },\n });\n }\n\n convertToSingleLine(code: any) {\n if (!code) return '';\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\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 //EXTENSION CONFIGURATIONS\n getLineNumbersExension() {\n return (!this.multiline && this.lineNumbers) || (this.multiline && this.lineNumbersMultiline) ? lineNumbers() : [];\n }\n \n getLanguageExtension(){\n switch(this.language){\n case 'sql':\n return sql();\n case 'json':\n return json();\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\n customAutocomplete = (context: CompletionContext): CompletionResult | null => {\n // Getting the valid last line, last text from the code editor\n let text = context.state.doc.sliceString(0, context.pos);\n const [textBeforeCursor, baseTextAfterSeperation] = this.splitStringAtLastSeparator(text.split('\\n').at(-1)?.split(' ').at(-1) + '')\n const textAfterSeperation = baseTextAfterSeperation.replace(/[\"'\\[]/g, '')\n\n const isInString = textAfterSeperation != baseTextAfterSeperation;\n const isBracket = textBeforeCursor.at(-1) == '[';\n const isDot = textBeforeCursor.at(-1) == '.';\n\n if (!this.isValidPath(textBeforeCursor)) return { from: context.pos, options: [] };\n if (['.', '['].includes(textBeforeCursor[textBeforeCursor.length - 1])) {\n // Parse the path for dot or bracket notation\n const path = this.parsePath(textBeforeCursor);\n if (path) {\n if (isDot && isInString) return null;\n let resolved = this.resolveNestedProperties(this.customAutoCompletions, path);\n if (textAfterSeperation) {\n const obj: any = {}\n Object.keys(resolved).forEach((key) => {\n if (key.toLowerCase().startsWith(textAfterSeperation.toLowerCase())) {\n obj[key] = resolved[key]\n }\n })\n resolved = obj\n }\n // If resolved is an object, provide its keys as suggestions\n if (resolved && typeof resolved === 'object') {\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) ? \"\\'\" + key + \"\\'\" : key,\n boost: 999\n })),\n };\n }\n }\n }\n\n // Match for top-level object suggestions, e.g., \"a\"\n const baseMatch: any = textBeforeCursor.match(/([a-zA-Z_$][\\w$]*)$/);\n if (baseMatch) {\n const optionsList=Object.keys(this.customAutoCompletions).filter(key=>key.toLowerCase().startsWith(textBeforeCursor.toLowerCase()));\n return {\n from: context.pos - baseMatch[1].length,\n options: optionsList.map((key) => ({\n label: key,\n type: 'property',\n apply: key,\n boost: 999\n }))\n }\n }\n // Default to an empty list if no match\n return null;\n };\n\n 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 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 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 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 /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the BSD-3-Clause license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { LitElement, CSSResultArray, TemplateResult } from 'lit';
7
+ import { LitElement, CSSResultArray, TemplateResult, PropertyValues } from 'lit';
8
8
  /**
9
9
  * Nile icon component.
10
10
  *
@@ -19,7 +19,7 @@ export declare class NileErrorNotification extends LitElement {
19
19
  static get styles(): CSSResultArray;
20
20
  errorMessage: string;
21
21
  color: string;
22
- connectedCallback(): void;
22
+ protected updated(_changedProperties: PropertyValues): void;
23
23
  /**
24
24
  * Render method
25
25
  * @slot This is a slot test
@@ -29,9 +29,8 @@ let NileErrorNotification = class NileErrorNotification extends LitElement {
29
29
  static get styles() {
30
30
  return [styles];
31
31
  }
32
- connectedCallback() {
33
- super.connectedCallback();
34
- if (this.color) {
32
+ updated(_changedProperties) {
33
+ if (_changedProperties.has('color')) {
35
34
  this.style.setProperty('--indication-color', this.color);
36
35
  }
37
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nile-error-notification.js","sourceRoot":"","sources":["../../../src/nile-error-notification/nile-error-notification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EACL,UAAU,EACV,IAAI,GAGL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;QASL,4DAA4D;QAChB,iBAAY,GAAW,EAAE,CAAC;QAE1B,UAAK,GAAW,EAAE,CAAC;QAgC/D,gBAAgB;IAClB,CAAC;IA5CC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAOD,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAG,IAAI,CAAC,KAAK,EAAC,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED,gBAAgB;IAEhB,qBAAqB;IAErB;;;OAGG;IACI,MAAM;QACX,OAAO,IAAI,CAAA;;;;;;;;;UASL,IAAI,CAAC,YAAY;;KAEtB,CAAC;IACJ,CAAC;CAGF,CAAA;AAnC6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;2DAA2B;AAE1B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;oDAAoB;AAZpD,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CA6CjC;;AAED,eAAe,qBAAqB,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 LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styles } from './nile-error-notification.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-error-notification\n *\n */\n@customElement('nile-error-notification')\nexport class NileErrorNotification extends LitElement {\n /**\n * The styles for ErrorNotification\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 // Represents the error message to be displayed to the user.\n @property({ type: String, reflect: true }) errorMessage: string = '';\n\n @property({ type: String, reflect: true }) color: string = '';\n \n connectedCallback(): void {\n super.connectedCallback();\n if(this.color){\n this.style.setProperty('--indication-color',this.color)\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 return html`\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ${this.errorMessage}\n </div>\n `;\n }\n\n /* #endregion */\n}\n\nexport default NileErrorNotification;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-error-notification': NileErrorNotification;\n }\n}\n"]}
1
+ {"version":3,"file":"nile-error-notification.js","sourceRoot":"","sources":["../../../src/nile-error-notification/nile-error-notification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EACL,UAAU,EACV,IAAI,GAIL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;QASL,4DAA4D;QAChB,iBAAY,GAAW,EAAE,CAAC;QAE1B,UAAK,GAAW,EAAE,CAAC;QA+B/D,gBAAgB;IAClB,CAAC;IA3CC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAOS,OAAO,CAAC,kBAAkC;QAClD,IAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAC,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED,gBAAgB;IAEhB,qBAAqB;IAErB;;;OAGG;IACI,MAAM;QACX,OAAO,IAAI,CAAA;;;;;;;;;UASL,IAAI,CAAC,YAAY;;KAEtB,CAAC;IACJ,CAAC;CAGF,CAAA;AAlC6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;2DAA2B;AAE1B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAG,CAAC;oDAAoB;AAZpD,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CA4CjC;;AAED,eAAe,qBAAqB,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 LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styles } from './nile-error-notification.css';\n\n/**\n * Nile icon component.\n *\n * @tag nile-error-notification\n *\n */\n@customElement('nile-error-notification')\nexport class NileErrorNotification extends LitElement {\n /**\n * The styles for ErrorNotification\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 // Represents the error message to be displayed to the user.\n @property({ type: String, reflect: true }) errorMessage: string = '';\n\n @property({ type: String, reflect: true }) color: string = '';\n \n protected updated(_changedProperties: PropertyValues): void {\n if(_changedProperties.has('color')){\n this.style.setProperty('--indication-color',this.color)\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 return html`\n <div class=\"nile-error-notification\">\n <nile-icon\n name=\"info2\"\n size=\"14\"\n class=\"nile-error-notification__icon\"\n part=\"icon\"\n color=\"var(--indication-color)\"\n ></nile-icon>\n ${this.errorMessage}\n </div>\n `;\n }\n\n /* #endregion */\n}\n\nexport default NileErrorNotification;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-error-notification': NileErrorNotification;\n }\n}\n"]}