@aquera/nile-elements 0.0.31 → 0.0.32

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 (73) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +1 -0
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +1 -0
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.d.ts +33 -0
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.js +63 -0
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/extensionSetup.js.map +1 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.d.ts +1 -0
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.js +2 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/index.js.map +1 -0
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.d.ts +12 -0
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js +42 -0
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -0
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.d.ts +43 -0
  14. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +114 -0
  15. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js.map +1 -0
  16. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +11 -0
  17. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  18. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +11 -5
  19. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +55 -7
  20. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  21. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/index.cjs.js +1 -1
  23. package/dist/index.esm.js +1 -1
  24. package/dist/index.iife.js +408 -352
  25. package/dist/nile-code-editor/extensionSetup.cjs.js +7 -0
  26. package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -0
  27. package/dist/nile-code-editor/extensionSetup.esm.js +1 -0
  28. package/dist/nile-code-editor/index.cjs.js +2 -0
  29. package/dist/nile-code-editor/index.cjs.js.map +1 -0
  30. package/dist/nile-code-editor/index.esm.js +1 -0
  31. package/dist/nile-code-editor/nile-code-editor.cjs.js +3 -0
  32. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -0
  33. package/dist/nile-code-editor/nile-code-editor.css.cjs.js +2 -0
  34. package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -0
  35. package/dist/nile-code-editor/nile-code-editor.css.esm.js +30 -0
  36. package/dist/nile-code-editor/nile-code-editor.esm.js +9 -0
  37. package/dist/nile-switcher/index.cjs.js +1 -1
  38. package/dist/nile-switcher/index.esm.js +1 -1
  39. package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
  40. package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
  41. package/dist/nile-switcher/nile-switcher.css.cjs.js +1 -1
  42. package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
  43. package/dist/nile-switcher/nile-switcher.css.esm.js +13 -2
  44. package/dist/nile-switcher/nile-switcher.esm.js +38 -30
  45. package/dist/src/index.d.ts +1 -0
  46. package/dist/src/index.js +1 -0
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/nile-code-editor/extensionSetup.d.ts +33 -0
  49. package/dist/src/nile-code-editor/extensionSetup.js +63 -0
  50. package/dist/src/nile-code-editor/extensionSetup.js.map +1 -0
  51. package/dist/src/nile-code-editor/index.d.ts +1 -0
  52. package/dist/src/nile-code-editor/index.js +2 -0
  53. package/dist/src/nile-code-editor/index.js.map +1 -0
  54. package/dist/src/nile-code-editor/nile-code-editor.css.d.ts +12 -0
  55. package/dist/src/nile-code-editor/nile-code-editor.css.js +42 -0
  56. package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -0
  57. package/dist/src/nile-code-editor/nile-code-editor.d.ts +43 -0
  58. package/dist/src/nile-code-editor/nile-code-editor.js +114 -0
  59. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -0
  60. package/dist/src/nile-switcher/nile-switcher.css.js +11 -0
  61. package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  62. package/dist/src/nile-switcher/nile-switcher.d.ts +11 -5
  63. package/dist/src/nile-switcher/nile-switcher.js +55 -7
  64. package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  65. package/dist/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +1 -1
  67. package/src/index.ts +2 -1
  68. package/src/nile-code-editor/extensionSetup.ts +125 -0
  69. package/src/nile-code-editor/index.ts +1 -0
  70. package/src/nile-code-editor/nile-code-editor.css.ts +44 -0
  71. package/src/nile-code-editor/nile-code-editor.ts +127 -0
  72. package/src/nile-switcher/nile-switcher.css.ts +11 -0
  73. package/src/nile-switcher/nile-switcher.ts +70 -10
@@ -1,4 +1,4 @@
1
- import{i as e}from"../index-cd2f9c12.esm.js";const i=e`
1
+ import{i as r}from"../index-cd2f9c12.esm.js";const e=r`
2
2
  :host {
3
3
  width: 100%;
4
4
  box-sizing: border-box;
@@ -51,6 +51,17 @@ import{i as e}from"../index-cd2f9c12.esm.js";const i=e`
51
51
  padding-right: 10px;
52
52
  }
53
53
 
54
+ nile-code-editor {
55
+ overflow: hidden;
56
+ padding-top: 2px;
57
+ border-radius: 5px;
58
+ border: 1px solid rgb(204, 204, 204);
59
+ }
60
+
61
+ .code-editor__no-border {
62
+ border: none;
63
+ }
64
+
54
65
  .switcher-object-mapper::part(input) {
55
66
  color: var(--nile-colors-primary-600);
56
67
  cursor: pointer;
@@ -62,4 +73,4 @@ import{i as e}from"../index-cd2f9c12.esm.js";const i=e`
62
73
  .switcher-object-mapper--noborder::part(base) {
63
74
  border: none;
64
75
  }
65
- `;export{i as s};
76
+ `;export{e as s};
@@ -1,64 +1,64 @@
1
- import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{customElement as r}from"lit/decorators.js";import{s as t}from"./nile-switcher.css.esm.js";import{N as s}from"../internal/nile-element.esm.js";import{choose as n}from"lit/directives/choose.js";import{classMap as o}from"lit/directives/class-map.js";import{repeat as l}from"lit/directives/repeat.js";import{n as c}from"../property-09139d3c.esm.js";import"lit";var a,d,h,p;!function(e){e.INLINE="inline",e.BLOCK="block"}(a||(a={})),function(e){e.DEFAULT="defaultInput",e.SWITCH="switchInput"}(d||(d={})),function(e){e.DROPDOWN="dropdown",e.TEXT="text",e.CHECKBOX="checkbox",e.TEXTAREA="text-area",e.RADIO="radio",e.CONTENTEDITOR="content-editor",e.OBJECT_MAPPER="object-mapper"}(h||(h={})),function(e){e.CREATE="create",e.EDIT="edit"}(p||(p={}));let u=class extends s{connectedCallback(){this.currentInput=this.nileSwitchConfig.inputs[0],super.connectedCallback(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}renderNileText(e){const{value:r,label:t,placeholder:s,disabled:n,required:l,error:c,errorMessage:a,inputType:d,noborder:h}=e;return i`<nile-input
1
+ import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";import{customElement as t}from"lit/decorators.js";import{s as r}from"./nile-switcher.css.esm.js";import{N as s}from"../internal/nile-element.esm.js";import{choose as n}from"lit/directives/choose.js";import{classMap as o}from"lit/directives/class-map.js";import{repeat as l}from"lit/directives/repeat.js";import{w as c}from"../internal/watch.esm.js";import{n as a}from"../property-09139d3c.esm.js";import"lit";var d,h,p,u;!function(e){e.INLINE="inline",e.BLOCK="block"}(d||(d={})),function(e){e.DEFAULT="defaultInput",e.SWITCH="switchInput"}(h||(h={})),function(e){e.DROPDOWN="dropdown",e.TEXT="text",e.CHECKBOX="checkbox",e.TEXTAREA="text-area",e.RADIO="radio",e.CONTENTEDITOR="content-editor",e.OBJECT_MAPPER="object-mapper",e.CODE_EDITOR="code-editor"}(p||(p={})),function(e){e.CREATE="create",e.EDIT="edit"}(u||(u={}));let $=class extends s{constructor(){super(...arguments),this.current=0}connectedCallback(){super.connectedCallback(),this.setCurrentInput(),this.emit("nile-init")}handleSwitcherChange(){this.setCurrentInput()}setCurrentInput(){this.nileSwitchConfig?.inputs&&(this.currentInput=this.nileSwitchConfig.inputs.filter(((e,i)=>i===this.current))[0])}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}renderNileText(e){const{value:t,label:r,placeholder:s,disabled:n,required:l,error:c,errorMessage:a,inputType:d,noborder:h}=e;return i`<nile-input
2
2
  class=${o({"switcher-input":!0,"switcher-input--noborder":!!h})}
3
- .value=${r}
4
- .label=${t}
3
+ .value=${t}
4
+ .label=${r}
5
5
  .disabled=${n}
6
6
  .required=${l}
7
7
  .errorMessage=${a}
8
8
  .placeholder=${s}
9
9
  .error=${c}
10
10
  @nile-input=${e=>{this.handleChange(e,d)}}
11
- ></nile-input>`}renderDropdown(e){const{options:r,multiple:t,placeholder:s,disabled:n,value:o,error:l,errorMessage:c,inputType:a}=e;return i`<nile-select
11
+ ></nile-input>`}renderDropdown(e){const{options:t,multiple:r,placeholder:s,disabled:n,value:o,error:l,errorMessage:c,inputType:a}=e;return i`<nile-select
12
12
  class="switcher-dropdown"
13
13
  .placeholder=${s}
14
14
  .disabled="${n}"
15
- .multiple="${t}"
15
+ .multiple="${r}"
16
16
  .value="${o}"
17
17
  .error="${l}"
18
18
  .errorMessage="${c}"
19
19
  @nile-change=${e=>{this.handleChange(e,a)}}
20
20
  >
21
- ${r?.map((e=>i`<nile-option .value="${e}">${e} </nile-option>`))}
22
- </nile-select>`}renderNileTextArea(e){const{value:r,disabled:t,readonly:s,errorMessage:n,error:o,inputType:l}=e;return i`<nile-textarea
21
+ ${t?.map((e=>i`<nile-option .value="${e}">${e} </nile-option>`))}
22
+ </nile-select>`}renderNileTextArea(e){const{value:t,disabled:r,readonly:s,errorMessage:n,error:o,inputType:l}=e;return i`<nile-textarea
23
23
  class="switcher-textarea"
24
- .value=${r}
25
- .disabled=${t}
24
+ .value=${t}
25
+ .disabled=${r}
26
26
  ?readonly=${s}
27
27
  .error=${o}
28
28
  .errorMessage=${n}
29
29
  @nile-input=${e=>{this.handleChange(e,l)}}
30
- ></nile-textarea>`}renderNileCheckBox(e){const{value:r,label:t,disabled:s,inputType:n}=e;return i`<nile-checkbox
30
+ ></nile-textarea>`}renderNileCheckBox(e){const{value:t,label:r,disabled:s,inputType:n}=e;return i`<nile-checkbox
31
31
  class="switcher-checkbox"
32
- .checked=${r}
33
- .label=${t}
32
+ .checked=${t}
33
+ .label=${r}
34
34
  .disabled=${s}
35
35
  @valueChange=${e=>{this.handleChange(e,n)}}
36
36
  ></nile-checkbox
37
- >; `}renderNileRadio(e){const{options:r,value:t,disabled:s,errorMessage:n,inputType:o}=e,l=!!n;return i`<nile-radio-group
37
+ >; `}renderNileRadio(e){const{options:t,value:r,disabled:s,errorMessage:n,inputType:o}=e,l=!!n;return i`<nile-radio-group
38
38
  class="switcher-radio-group"
39
- .value=${t}
39
+ .value=${r}
40
40
  .disabled=${s}
41
41
  @change=${e=>{this.handleChange(e,o)}}
42
42
  >
43
- ${r&&r.map((e=>i`<nile-radio .value="${e}">${e} </nile-radio>`))}
43
+ ${t&&t.map((e=>i`<nile-radio .value="${e}">${e} </nile-radio>`))}
44
44
  ${l?this.renderErrorMessage(n):""}
45
45
  </nile-radio-group> `}renderErrorMessage(e){return i`
46
46
  <nile-form-error-message>${e}</nile-form-error-message>
47
- `}renderContentEditor(e){let{options:r,inputType:t,errorMessage:s,type:n,readonly:o,noborder:l,value:c}=e;return i`<nile-content-editor
47
+ `}renderContentEditor(e){let{options:t,inputType:r,errorMessage:s,type:n,readonly:o,noborder:l,value:c}=e;return i`<nile-content-editor
48
48
  class="switcher-content-editor"
49
49
  .value=${c}
50
- .options=${r}
50
+ .options=${t}
51
51
  .type=${n}
52
52
  .readonly=${o}
53
53
  .noborder=${l}
54
54
  .errorMessage=${s}
55
- @nile-change=${e=>{this.handleChange(e,t)}}
55
+ @nile-change=${e=>{this.handleChange(e,r)}}
56
56
  >
57
- </nile-content-editor>`}renderObjectMapper(){const e=this.currentInput.noborder;this.currentInput.mode;const r=this.currentInput.mode===p.CREATE?"Click to Create - Not Mapped":"";return i`<nile-input
57
+ </nile-content-editor>`}renderObjectMapper(){const e=this.currentInput.noborder;this.currentInput.mode;const t=this.currentInput.mode===u.CREATE?"Click to Create - Not Mapped":"";return i`<nile-input
58
58
  class=${o({"switcher-object-mapper":!0,"switcher-object-mapper--noborder":!!e})}
59
- .value=${r}
59
+ .value=${t}
60
60
  readonly="true"
61
- @click="${e=>this.handleChange(e,h.OBJECT_MAPPER)}"
61
+ @click="${e=>this.handleChange(e,p.OBJECT_MAPPER)}"
62
62
  >
63
63
  <nile-icon
64
64
  class="pointer-cursor switcher-object-mapper-icon"
@@ -68,29 +68,37 @@ import{__decorate as e}from"tslib";import{x as i}from"../index-cd2f9c12.esm.js";
68
68
  size="16"
69
69
  >
70
70
  </nile-icon>
71
- </nile-input>`}handleChange(e,i){switch(i){case h.OBJECT_MAPPER:this.currentInput.value="clicked";break;case h.CHECKBOX:this.currentInput.value=e.detail.checked;break;default:this.currentInput.value=e.detail.value}e.stopPropagation(),this.emit("nile-change",{input:this.currentInput})}renderIcon(){const e=this.nileSwitchConfig.inputs,r=this.nileSwitchConfig.align===a.BLOCK?"top":"bottom";return i`
71
+ </nile-input>`}renderCodeEditor(e){const{value:t,multiLine:r,options:s,disabled:n,readonly:l,errorMessage:c,error:a,inputType:d,noborder:h}=e;return i`<nile-code-editor
72
+ class=${o({"code-editor":!0,"code-editor__no-border":!!h})}
73
+ @nile-expand="${e=>this.handleExpand(e,p.CODE_EDITOR)}"
74
+ @nile-change="${e=>this.handleChange(e,p.CODE_EDITOR)}"
75
+ .multiline="${r}"
76
+ .value="${t}"
77
+ .customOptions="${s}"
78
+ .showLineNumbers="false"
79
+ ></nile-code-editor> `}handleExpand(e,i){this.currentInput.expand=e.detail.expand,this.emit("nile-change",{input:this.currentInput})}handleChange(e,i){switch(i){case p.OBJECT_MAPPER:this.currentInput.value="clicked";break;case p.CHECKBOX:this.currentInput.value=e.detail.checked;break;case p.CODE_EDITOR:default:this.currentInput.value=e.detail.value}e.stopPropagation(),this.emit("nile-change",{input:this.currentInput})}renderIcon(){const e=this.nileSwitchConfig.inputs,t=this.nileSwitchConfig.align===d.BLOCK?"top":"bottom";return i`
72
80
  <div class="switcher-icons-container">
73
- ${l(e,(e=>i` <nile-tooltip
81
+ ${l(e,((e,r)=>i` <nile-tooltip
74
82
  class=${o({"switcher-tooltip-container":!0})}
75
83
  content=${e.helperText}
76
- placement=${r}
84
+ placement=${t}
77
85
  >
78
- <div class=${o({"switcher-icon-container":!0,current:e.order===this.currentInput.order})}>
86
+ <div class=${o({"switcher-icon-container":!0,current:r===this.current})}>
79
87
  <nile-icon
80
88
  size="16"
81
89
  class=${o({"pointer-cursor":!0})}
82
90
  .name=${e.icon}
83
91
  color="#000000"
84
- @click=${()=>this.toggleField(e)}
92
+ @click=${()=>this.toggleField(e,r)}
85
93
  ></nile-icon>
86
94
  <div>
87
95
 
88
96
  </nile-tooltip>`))}
89
97
  </div>
90
- `}toggleField(e){this.currentInput=e,this.emit("nile-switch",{input:this.currentInput})}singleFieldSwitcher(){return i`
91
- ${n(this.currentInput.inputType,[[h.TEXT,()=>this.renderNileText(this.currentInput)],[h.CHECKBOX,()=>this.renderNileCheckBox(this.currentInput)],[h.TEXTAREA,()=>this.renderNileTextArea(this.currentInput)],[h.RADIO,()=>this.renderNileRadio(this.currentInput)],[h.DROPDOWN,()=>this.renderDropdown(this.currentInput)],[h.CONTENTEDITOR,()=>this.renderContentEditor(this.currentInput)],[h.OBJECT_MAPPER,()=>this.renderObjectMapper()]],(()=>this.renderNileText(this.currentInput)))}
98
+ `}toggleField(e,i){this.current=i,this.emit("nile-switch",{input:this.currentInput})}singleFieldSwitcher(){return i`
99
+ ${n(this.currentInput.inputType,[[p.TEXT,()=>this.renderNileText(this.currentInput)],[p.CHECKBOX,()=>this.renderNileCheckBox(this.currentInput)],[p.TEXTAREA,()=>this.renderNileTextArea(this.currentInput)],[p.RADIO,()=>this.renderNileRadio(this.currentInput)],[p.DROPDOWN,()=>this.renderDropdown(this.currentInput)],[p.CONTENTEDITOR,()=>this.renderContentEditor(this.currentInput)],[p.OBJECT_MAPPER,()=>this.renderObjectMapper()],[p.CODE_EDITOR,()=>this.renderCodeEditor(this.currentInput)]],(()=>this.renderNileText(this.currentInput)))}
92
100
  `}render(){const e=this.nileSwitchConfig.align;return i`<div
93
- class=${o({"switcher-block":e===a.BLOCK,"switcher-inline":e===a.INLINE,"switcher-input-container":!0})}
101
+ class=${o({"switcher-block":e===d.BLOCK,"switcher-inline":e===d.INLINE,"switcher-input-container":!0})}
94
102
  >
95
103
  ${this.renderIcon()} ${this.singleFieldSwitcher()}
96
- </div>`}};u.styles=t,e([c({type:Object})],u.prototype,"nileSwitchConfig",void 0),e([c()],u.prototype,"currentInput",void 0),u=e([r("nile-switcher")],u);export{u as N};
104
+ </div>`}};$.styles=r,e([a({type:Object})],$.prototype,"nileSwitchConfig",void 0),e([a({type:Number})],$.prototype,"current",void 0),e([a({type:Object})],$.prototype,"currentInput",void 0),e([c(["current"],{waitUntilFirstUpdate:!0})],$.prototype,"handleSwitcherChange",null),$=e([t("nile-switcher")],$);export{$ as N};
@@ -39,4 +39,5 @@ export { NileErrorNotification } from './nile-error-notification';
39
39
  export { NileTabGroup } from './nile-tab-group';
40
40
  export { NileTab } from './nile-tab';
41
41
  export { NileTabPanel } from './nile-tab-panel';
42
+ export { NileCodeEditor } from './nile-code-editor';
42
43
  export { NileToast } from './nile-toast';
package/dist/src/index.js CHANGED
@@ -39,5 +39,6 @@ export { NileErrorNotification } from './nile-error-notification';
39
39
  export { NileTabGroup } from './nile-tab-group';
40
40
  export { NileTab } from './nile-tab';
41
41
  export { NileTabPanel } from './nile-tab-panel';
42
+ export { NileCodeEditor } from './nile-code-editor';
42
43
  export { NileToast } from './nile-toast';
43
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,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MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { NileButton } from './nile-button';\nexport { NileHeading } from './nile-heading';\nexport { NileIcon } from './nile-icon';\nexport { NileInput } from './nile-input';\nexport { NileSidebar } from './nile-sidebar';\nexport { NileMenu } from './nile-menu';\nexport { NileBadge } from './nile-badge';\nexport { NileDrawer } from './nile-drawer';\nexport { NileCheckbox } from './nile-checkbox';\nexport { NileRadio } from './nile-radio';\nexport { NileRadioGroup } from './nile-radio-group';\nexport { NilePopup } from './nile-popup';\nexport { NileTooltip } from './nile-tooltip';\nexport { NileSlideToggle } from './nile-slide-toggle';\nexport { NileLoader } from './nile-loader';\nexport { NileProgressBar } from './nile-progress-bar';\nexport { NileSpinner } from './nile-spinner';\nexport { NileSelect } from './nile-select';\nexport { NileOption } from './nile-option';\nexport { NileTag } from './nile-tag';\nexport { NileIconButton } from './nile-icon-button';\nexport { NileMenuItem } from './nile-menu-item';\nexport { NileDropdown } from './nile-dropdown';\nexport { NileAutoComplete } from './nile-auto-complete';\nexport { NileChip } from './nile-chip';\nexport { NileTextarea } from './nile-textarea';\nexport { NileDatePicker } from './nile-date-picker';\nexport { NileErrorMessage } from './nile-error-message';\nexport { NileFormErrorMessage } from './nile-form-error-message';\nexport { NileFormHelpText } from './nile-form-help-text';\nexport { NileCalendar } from './nile-calendar';\nexport { NileLink} from './nile-link';\nexport { NileButtonToggleGroup } from './nile-button-toggle-group';\nexport { NileButtonToggle } from './nile-button-toggle';\nexport { NileSwitcher } from './nile-switcher';\nexport { NileContentEditor } from './nile-content-editor';\nexport { NileDialog } from './nile-dialog';\nexport { NileErrorNotification } from './nile-error-notification';\nexport { NileTabGroup } from './nile-tab-group';\nexport { NileTab } from './nile-tab';\nexport { NileTabPanel } from './nile-tab-panel';\nexport { NileToast } from './nile-toast';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAA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AAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { NileButton } from './nile-button';\nexport { NileHeading } from './nile-heading';\nexport { NileIcon } from './nile-icon';\nexport { NileInput } from './nile-input';\nexport { NileSidebar } from './nile-sidebar';\nexport { NileMenu } from './nile-menu';\nexport { NileBadge } from './nile-badge';\nexport { NileDrawer } from './nile-drawer';\nexport { NileCheckbox } from './nile-checkbox';\nexport { NileRadio } from './nile-radio';\nexport { NileRadioGroup } from './nile-radio-group';\nexport { NilePopup } from './nile-popup';\nexport { NileTooltip } from './nile-tooltip';\nexport { NileSlideToggle } from './nile-slide-toggle';\nexport { NileLoader } from './nile-loader';\nexport { NileProgressBar } from './nile-progress-bar';\nexport { NileSpinner } from './nile-spinner';\nexport { NileSelect } from './nile-select';\nexport { NileOption } from './nile-option';\nexport { NileTag } from './nile-tag';\nexport { NileIconButton } from './nile-icon-button';\nexport { NileMenuItem } from './nile-menu-item';\nexport { NileDropdown } from './nile-dropdown';\nexport { NileAutoComplete } from './nile-auto-complete';\nexport { NileChip } from './nile-chip';\nexport { NileTextarea } from './nile-textarea';\nexport { NileDatePicker } from './nile-date-picker';\nexport { NileErrorMessage } from './nile-error-message';\nexport { NileFormErrorMessage } from './nile-form-error-message';\nexport { NileFormHelpText } from './nile-form-help-text';\nexport { NileCalendar } from './nile-calendar';\nexport { NileLink } from './nile-link';\nexport { NileButtonToggleGroup } from './nile-button-toggle-group';\nexport { NileButtonToggle } from './nile-button-toggle';\nexport { NileSwitcher } from './nile-switcher';\nexport { NileContentEditor } from './nile-content-editor';\nexport { NileDialog } from './nile-dialog';\nexport { NileErrorNotification } from './nile-error-notification';\nexport { NileTabGroup } from './nile-tab-group';\nexport { NileTab } from './nile-tab';\nexport { NileTabPanel } from './nile-tab-panel';\nexport { NileCodeEditor } from './nile-code-editor';\nexport { NileToast } from './nile-toast';\n"]}
@@ -0,0 +1,33 @@
1
+ import { Extension } from '@codemirror/state';
2
+ export interface BasicSetupOptions extends MinimalSetupOptions {
3
+ lineNumbers?: boolean;
4
+ highlightActiveLineGutter?: boolean;
5
+ foldGutter?: boolean;
6
+ dropCursor?: boolean;
7
+ allowMultipleSelections?: boolean;
8
+ indentOnInput?: boolean;
9
+ bracketMatching?: boolean;
10
+ closeBrackets?: boolean;
11
+ autocompletion?: boolean;
12
+ rectangularSelection?: boolean;
13
+ crosshairCursor?: boolean;
14
+ highlightActiveLine?: boolean;
15
+ highlightSelectionMatches?: boolean;
16
+ closeBracketsKeymap?: boolean;
17
+ searchKeymap?: boolean;
18
+ foldKeymap?: boolean;
19
+ completionKeymap?: boolean;
20
+ lintKeymap?: boolean;
21
+ tabSize?: number;
22
+ }
23
+ export declare const isValidSetup: (item: any) => any;
24
+ export declare const basicSetup: (options?: BasicSetupOptions) => Extension[];
25
+ export interface MinimalSetupOptions {
26
+ highlightSpecialChars?: boolean;
27
+ history?: boolean;
28
+ drawSelection?: boolean;
29
+ syntaxHighlighting?: boolean;
30
+ defaultKeymap?: boolean;
31
+ historyKeymap?: boolean;
32
+ }
33
+ export declare const minimalSetup: (options?: MinimalSetupOptions) => Extension[];
@@ -0,0 +1,63 @@
1
+ import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap, } from '@codemirror/view';
2
+ import { EditorState } from '@codemirror/state';
3
+ import { history, defaultKeymap, historyKeymap } from '@codemirror/commands';
4
+ import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
5
+ import { closeBrackets, autocompletion, closeBracketsKeymap, } from '@codemirror/autocomplete';
6
+ import { foldGutter, indentOnInput, syntaxHighlighting, defaultHighlightStyle, bracketMatching, indentUnit, foldKeymap, } from '@codemirror/language';
7
+ import { lintKeymap } from '@codemirror/lint';
8
+ export const isValidSetup = (item) => {
9
+ return typeof item === 'undefined' || item;
10
+ };
11
+ export const basicSetup = (options = {}) => {
12
+ const { crosshairCursor: initCrosshairCursor = false } = options;
13
+ let keymaps = [];
14
+ isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);
15
+ isValidSetup(options.closeBracketsKeymap) &&
16
+ keymaps.push(...closeBracketsKeymap);
17
+ isValidSetup(options.searchKeymap) && keymaps.push(...searchKeymap);
18
+ isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);
19
+ isValidSetup(options.foldKeymap) && keymaps.push(...foldKeymap);
20
+ isValidSetup(options.lintKeymap) && keymaps.push(...lintKeymap);
21
+ const extensions = [];
22
+ isValidSetup(options.lineNumbers) && extensions.push(lineNumbers());
23
+ isValidSetup(options.highlightActiveLineGutter) &&
24
+ extensions.push(highlightActiveLineGutter());
25
+ isValidSetup(options.highlightSpecialChars) &&
26
+ extensions.push(highlightSpecialChars());
27
+ isValidSetup(options.history) && extensions.push(history());
28
+ isValidSetup(options.foldGutter) && extensions.push(foldGutter());
29
+ isValidSetup(options.drawSelection) && extensions.push(drawSelection());
30
+ isValidSetup(options.dropCursor) && extensions.push(dropCursor());
31
+ isValidSetup(options.allowMultipleSelections) &&
32
+ extensions.push(EditorState.allowMultipleSelections.of(true));
33
+ isValidSetup(options.indentOnInput) && extensions.push(indentOnInput());
34
+ isValidSetup(options.syntaxHighlighting) &&
35
+ extensions.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true }));
36
+ isValidSetup(options.bracketMatching) && extensions.push(bracketMatching());
37
+ isValidSetup(options.closeBrackets) && extensions.push(closeBrackets());
38
+ isValidSetup(options.autocompletion) && extensions.push(autocompletion());
39
+ isValidSetup(options.rectangularSelection) &&
40
+ extensions.push(rectangularSelection());
41
+ isValidSetup(options.crosshairCursor) && extensions.push(crosshairCursor());
42
+ isValidSetup(options.highlightActiveLine) &&
43
+ extensions.push(highlightActiveLine());
44
+ isValidSetup(options.highlightSelectionMatches) &&
45
+ extensions.push(highlightSelectionMatches());
46
+ if (options.tabSize && typeof options.tabSize === 'number')
47
+ extensions.push(indentUnit.of(' '.repeat(options.tabSize)));
48
+ return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);
49
+ };
50
+ export const minimalSetup = (options = {}) => {
51
+ let keymaps = [];
52
+ isValidSetup(options.defaultKeymap) && keymaps.push(...defaultKeymap);
53
+ isValidSetup(options.historyKeymap) && keymaps.push(...historyKeymap);
54
+ const extensions = [];
55
+ isValidSetup(options.highlightSpecialChars) &&
56
+ extensions.push(highlightSpecialChars());
57
+ isValidSetup(options.history) && extensions.push(history());
58
+ isValidSetup(options.drawSelection) && extensions.push(drawSelection());
59
+ isValidSetup(options.syntaxHighlighting) &&
60
+ extensions.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true }));
61
+ return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);
62
+ };
63
+ //# sourceMappingURL=extensionSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensionSetup.js","sourceRoot":"","sources":["../../../src/nile-code-editor/extensionSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,cAAc,EACd,mBAAmB,GAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAwB9C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAS,EAAE,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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 lineNumbers,\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}\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) &&\n 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.lineNumbers) && extensions.push(lineNumbers());\n isValidSetup(options.highlightActiveLineGutter) &&\n extensions.push(highlightActiveLineGutter());\n isValidSetup(options.highlightSpecialChars) &&\n 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) &&\n 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) &&\n extensions.push(rectangularSelection());\n isValidSetup(options.crosshairCursor) && extensions.push(crosshairCursor());\n isValidSetup(options.highlightActiveLine) &&\n extensions.push(highlightActiveLine());\n isValidSetup(options.highlightSelectionMatches) &&\n 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"]}
@@ -0,0 +1 @@
1
+ export { NileCodeEditor } from './nile-code-editor';
@@ -0,0 +1,2 @@
1
+ export { NileCodeEditor } from './nile-code-editor';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-code-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { NileCodeEditor } from './nile-code-editor';\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * CodeEditor CSS
9
+ */
10
+ export declare const styles: import("lit-element").CSSResult;
11
+ declare const _default: import("lit-element").CSSResult[];
12
+ export default _default;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { css } from 'lit-element';
8
+ /**
9
+ * CodeEditor CSS
10
+ */
11
+ export const styles = css `
12
+ :host {
13
+ display: block;
14
+ }
15
+
16
+ .code-mirror {
17
+ display: flex;
18
+ justify-content: flex-end;
19
+ flex-direction: row-reverse;
20
+ gap: 0.6rem;
21
+ }
22
+
23
+ .cm-editor {
24
+ overflow: hidden;
25
+ width: 100%;
26
+ height: 100%;
27
+ }
28
+
29
+ .ͼ1.cm-focused {
30
+ outline: none;
31
+ }
32
+
33
+ .code-editor__icon__container {
34
+ cursor: pointer;
35
+ }
36
+
37
+ .code-editor__icon__container {
38
+ padding-right: 5px;
39
+ }
40
+ `;
41
+ export default [styles];
42
+ //# sourceMappingURL=nile-code-editor.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-code-editor.css.js","sourceRoot":"","sources":["../../../src/nile-code-editor/nile-code-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BxB,CAAC;AAEF,eAAe,CAAC,MAAM,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 { css } from 'lit-element';\n\n/**\n * CodeEditor CSS\n */\nexport const styles = css`\n :host {\n display: block;\n }\n\n .code-mirror {\n display: flex;\n justify-content: flex-end;\n flex-direction: row-reverse;\n gap: 0.6rem;\n }\n\n .cm-editor {\n overflow: hidden;\n width: 100%;\n height: 100%;\n }\n\n .ͼ1.cm-focused {\n outline: none;\n }\n\n .code-editor__icon__container {\n cursor: pointer;\n }\n\n .code-editor__icon__container {\n padding-right: 5px;\n }\n`;\n\nexport default [styles];\n"]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { CSSResultArray, TemplateResult } from 'lit-element';
8
+ import { EditorView } from 'codemirror';
9
+ import { Compartment } from '@codemirror/state';
10
+ import NileElement from '../internal/nile-element';
11
+ /**
12
+ * Nile icon component.
13
+ *
14
+ * @tag nile-code-editor
15
+ *
16
+ */
17
+ export declare class NileCodeEditor extends NileElement {
18
+ codeEditor: HTMLInputElement;
19
+ multiline: true;
20
+ value: true;
21
+ customOptions: any;
22
+ showLineNumbers: any;
23
+ /**
24
+ * The styles for CodeEditor
25
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
26
+ */
27
+ static get styles(): CSSResultArray;
28
+ connectedCallback(): void;
29
+ view: EditorView;
30
+ convertToSingleLine(code: any): any;
31
+ lineNumbersComp: Compartment;
32
+ updated(): void;
33
+ emitValues(value: string): void;
34
+ expandCodeEditor(): void;
35
+ restrictSingleLine(): import("@codemirror/state").Extension;
36
+ render(): TemplateResult;
37
+ }
38
+ export default NileCodeEditor;
39
+ declare global {
40
+ interface HTMLElementTagNameMap {
41
+ 'nile-code-editor': NileCodeEditor;
42
+ }
43
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Copyright Aquera Inc 2023
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { __decorate } from "tslib";
8
+ import { html, property, } from 'lit-element';
9
+ import { customElement, query } from 'lit/decorators.js';
10
+ import { styles } from './nile-code-editor.css';
11
+ import { EditorView } from 'codemirror';
12
+ import { EditorState, Compartment } from '@codemirror/state';
13
+ import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';
14
+ import { autocompletion } from '@codemirror/autocomplete';
15
+ import NileElement from '../internal/nile-element';
16
+ import { basicSetup } from './extensionSetup';
17
+ // Choose the appropriate mode for your use case
18
+ /**
19
+ * Nile icon component.
20
+ *
21
+ * @tag nile-code-editor
22
+ *
23
+ */
24
+ let NileCodeEditor = class NileCodeEditor extends NileElement {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.lineNumbersComp = new Compartment();
28
+ /* #endregion */
29
+ }
30
+ /**
31
+ * The styles for CodeEditor
32
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
33
+ */
34
+ static get styles() {
35
+ return [styles];
36
+ }
37
+ connectedCallback() {
38
+ super.connectedCallback();
39
+ }
40
+ convertToSingleLine(code) {
41
+ // Remove line breaks and unnecessary whitespace
42
+ return code.replace(/\s+/g, ' ').trim();
43
+ }
44
+ updated() {
45
+ const customAutoCompletions = javascriptLanguage.data.of({
46
+ autocomplete: this.customOptions,
47
+ });
48
+ let startState = EditorState.create({
49
+ doc: !this.multiline ? this.convertToSingleLine(this.value) : this.value,
50
+ extensions: [
51
+ basicSetup({
52
+ lineNumbers: !!this.showLineNumbers,
53
+ foldGutter: !this.multiline ? false : true,
54
+ }),
55
+ customAutoCompletions,
56
+ autocompletion(),
57
+ javascript(),
58
+ !this.multiline ? this.restrictSingleLine() : [],
59
+ EditorView.updateListener.of((v) => {
60
+ if (v.docChanged) {
61
+ this.emitValues(this.view.state.doc.toString());
62
+ }
63
+ }),
64
+ ],
65
+ });
66
+ this.view = new EditorView({
67
+ state: startState,
68
+ parent: this.codeEditor,
69
+ });
70
+ }
71
+ emitValues(value) {
72
+ this.emit('nile-change', { value: value });
73
+ }
74
+ expandCodeEditor() {
75
+ this.emit('nile-expand', { expand: true });
76
+ }
77
+ restrictSingleLine() {
78
+ return EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr);
79
+ }
80
+ render() {
81
+ return html `<div class="code-mirror">
82
+ ${!this.multiline
83
+ ? html `<nile-icon
84
+ name="fullscreenshrink"
85
+ class="code-editor__icon__container"
86
+ size="16"
87
+ color="black"
88
+ @click="${(e) => this.expandCodeEditor()}"
89
+ ></nile-icon>`
90
+ : ''}
91
+ </div>`;
92
+ }
93
+ };
94
+ __decorate([
95
+ query('.code-mirror')
96
+ ], NileCodeEditor.prototype, "codeEditor", void 0);
97
+ __decorate([
98
+ property({ type: Boolean })
99
+ ], NileCodeEditor.prototype, "multiline", void 0);
100
+ __decorate([
101
+ property({ type: String })
102
+ ], NileCodeEditor.prototype, "value", void 0);
103
+ __decorate([
104
+ property({ type: String })
105
+ ], NileCodeEditor.prototype, "customOptions", void 0);
106
+ __decorate([
107
+ property({ type: String })
108
+ ], NileCodeEditor.prototype, "showLineNumbers", void 0);
109
+ NileCodeEditor = __decorate([
110
+ customElement('nile-code-editor')
111
+ ], NileCodeEditor);
112
+ export { NileCodeEditor };
113
+ export default NileCodeEditor;
114
+ //# sourceMappingURL=nile-code-editor.js.map
@@ -0,0 +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,EAEL,IAAI,EACJ,QAAQ,GAGT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,gDAAgD;AAEhD;;;;;GAKG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,WAAW;IAAxC;;QAyBL,oBAAe,GAAG,IAAI,WAAW,EAAE,CAAC;QA0DpC,gBAAgB;IAClB,CAAC;IA7EC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB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AC,UAAU;SACxB,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,kBAAkB;QAChB,OAAO,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAC3C,EAAE,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC9B,CAAC;IACJ,CAAC;IACM,MAAM;QACX,OAAO,IAAI,CAAA;QACP,CAAC,IAAI,CAAC,SAAS;YACf,CAAC,CAAC,IAAI,CAAA;;;;;sBAKQ,CAAC,CAAc,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE;wBACzC;YAChB,CAAC,CAAC,EAAE;WACD,CAAC;IACV,CAAC;CAGF,CAAA;AAnFwB;IAAtB,KAAK,CAAC,cAAc,CAAC;kDAA8B;AACvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAiB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAa;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAsB;AALtC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAoF1B;SApFY,cAAc;AAsF3B,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 property,\n CSSResultArray,\n TemplateResult,\n} from 'lit-element';\nimport { customElement, query } from 'lit/decorators.js';\nimport { styles } from './nile-code-editor.css';\nimport { EditorView } from 'codemirror';\nimport { ViewUpdate } from '@codemirror/view';\nimport { EditorState, Compartment } from '@codemirror/state';\nimport { javascript, javascriptLanguage } from '@codemirror/lang-javascript';\nimport { autocompletion } from '@codemirror/autocomplete';\nimport { CompletionContext } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\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 @query('.code-mirror') codeEditor: HTMLInputElement;\n @property({ type: Boolean }) multiline: true;\n @property({ type: String }) value: true;\n @property({ type: String }) customOptions: any;\n @property({ type: String }) showLineNumbers: any;\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 }\n\n view: EditorView;\n\n convertToSingleLine(code: any) {\n // Remove line breaks and unnecessary whitespace\n return code.replace(/\\s+/g, ' ').trim();\n }\n lineNumbersComp = new Compartment();\n\n updated() {\n const customAutoCompletions = javascriptLanguage.data.of({\n autocomplete: this.customOptions,\n });\n let startState = EditorState.create({\n doc: !this.multiline ? this.convertToSingleLine(this.value) : this.value,\n extensions: [\n basicSetup({\n lineNumbers: !!this.showLineNumbers,\n foldGutter: !this.multiline ? false : true,\n }),\n customAutoCompletions,\n autocompletion(),\n javascript(),\n !this.multiline ? this.restrictSingleLine() : [],\n EditorView.updateListener.of((v: ViewUpdate) => {\n if (v.docChanged) {\n this.emitValues(this.view.state.doc.toString());\n }\n }),\n ],\n });\n\n this.view = new EditorView({\n state: startState,\n parent: this.codeEditor,\n });\n }\n\n emitValues(value: string) {\n this.emit('nile-change', { value: value });\n }\n\n expandCodeEditor() {\n this.emit('nile-expand', { expand: true });\n }\n\n restrictSingleLine() {\n return EditorState.transactionFilter.of(tr =>\n tr.newDoc.lines > 1 ? [] : tr\n );\n }\n public render(): TemplateResult {\n return html`<div class=\"code-mirror\">\n ${!this.multiline\n ? html`<nile-icon\n name=\"fullscreenshrink\"\n class=\"code-editor__icon__container\"\n size=\"16\"\n color=\"black\"\n @click=\"${(e: CustomEvent) => this.expandCodeEditor()}\"\n ></nile-icon>`\n : ''}\n </div>`;\n }\n\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n"]}
@@ -61,6 +61,17 @@ export const styles = css `
61
61
  padding-right: 10px;
62
62
  }
63
63
 
64
+ nile-code-editor {
65
+ overflow: hidden;
66
+ padding-top: 2px;
67
+ border-radius: 5px;
68
+ border: 1px solid rgb(204, 204, 204);
69
+ }
70
+
71
+ .code-editor__no-border {
72
+ border: none;
73
+ }
74
+
64
75
  .switcher-object-mapper::part(input) {
65
76
  color: var(--nile-colors-primary-600);
66
77
  cursor: pointer;
@@ -1 +1 @@
1
- {"version":3,"file":"nile-switcher.css.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgExB,CAAC;AAEF,eAAe,CAAC,MAAM,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 { css } from 'lit-element';\n\n/**\n * FieldGenerator CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n }\n\n .switcher-icon-container {\n cursor: pointer;\n justify-content: center;\n display: flex;\n align-items: center;\n margin-bottom: 6px;\n height: 28px;\n width: 28px;\n border-radius: 4px;\n }\n\n .switcher-icon-container.current {\n background: var(--nile-colors-blue-400);\n }\n\n .switcher-input-container {\n display: flex;\n }\n\n .switcher-inline {\n gap: 0.5rem;\n }\n\n .switcher-block {\n flex-direction: column;\n }\n\n .switcher-block > :first-child {\n align-self: end;\n }\n\n .switcher-inline > :nth-child(2) {\n flex: 1;\n }\n\n .switcher-input-container > :first-child {\n display: flex;\n gap: 0.5rem;\n max-height: 38px;\n align-items: center;\n }\n\n nile-radio {\n display: inline-block;\n padding-right: 10px;\n }\n\n .switcher-object-mapper::part(input) {\n color: var(--nile-colors-primary-600);\n cursor: pointer;\n }\n\n .switcher-input--noborder::part(base) {\n border: none;\n }\n .switcher-object-mapper--noborder::part(base) {\n border: none;\n }\n`;\n\nexport default [styles];\n"]}
1
+ {"version":3,"file":"nile-switcher.css.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ExB,CAAC;AAEF,eAAe,CAAC,MAAM,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 { css } from 'lit-element';\n\n/**\n * FieldGenerator CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n }\n\n .switcher-icon-container {\n cursor: pointer;\n justify-content: center;\n display: flex;\n align-items: center;\n margin-bottom: 6px;\n height: 28px;\n width: 28px;\n border-radius: 4px;\n }\n\n .switcher-icon-container.current {\n background: var(--nile-colors-blue-400);\n }\n\n .switcher-input-container {\n display: flex;\n }\n\n .switcher-inline {\n gap: 0.5rem;\n }\n\n .switcher-block {\n flex-direction: column;\n }\n\n .switcher-block > :first-child {\n align-self: end;\n }\n\n .switcher-inline > :nth-child(2) {\n flex: 1;\n }\n\n .switcher-input-container > :first-child {\n display: flex;\n gap: 0.5rem;\n max-height: 38px;\n align-items: center;\n }\n\n nile-radio {\n display: inline-block;\n padding-right: 10px;\n }\n\n nile-code-editor {\n overflow: hidden;\n padding-top: 2px;\n border-radius: 5px;\n border: 1px solid rgb(204, 204, 204);\n }\n\n .code-editor__no-border {\n border: none;\n }\n\n .switcher-object-mapper::part(input) {\n color: var(--nile-colors-primary-600);\n cursor: pointer;\n }\n\n .switcher-input--noborder::part(base) {\n border: none;\n }\n .switcher-object-mapper--noborder::part(base) {\n border: none;\n }\n`;\n\nexport default [styles];\n"]}