@aquera/nile-elements 0.0.34 → 0.0.36

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 (59) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js +5 -5
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.d.ts +4 -2
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +64 -30
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.d.ts +9 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js +10 -0
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js.map +1 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +42 -12
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +1 -0
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +27 -6
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  14. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.esm.js +1 -1
  17. package/dist/index.iife.js +261 -214
  18. package/dist/nile-code-editor/extensionSetup.cjs.js +1 -1
  19. package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
  20. package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
  21. package/dist/nile-code-editor/index.cjs.js +1 -1
  22. package/dist/nile-code-editor/index.esm.js +1 -1
  23. package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
  24. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  25. package/dist/nile-code-editor/nile-code-editor.css.cjs.js +1 -1
  26. package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
  27. package/dist/nile-code-editor/nile-code-editor.css.esm.js +5 -5
  28. package/dist/nile-code-editor/nile-code-editor.esm.js +6 -3
  29. package/dist/nile-code-editor/theme.cjs.js +2 -0
  30. package/dist/nile-code-editor/theme.cjs.js.map +1 -0
  31. package/dist/nile-code-editor/theme.esm.js +1 -0
  32. package/dist/nile-switcher/index.cjs.js +1 -1
  33. package/dist/nile-switcher/index.esm.js +1 -1
  34. package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
  35. package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
  36. package/dist/nile-switcher/nile-switcher.css.cjs.js +1 -1
  37. package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
  38. package/dist/nile-switcher/nile-switcher.css.esm.js +44 -14
  39. package/dist/nile-switcher/nile-switcher.esm.js +50 -36
  40. package/dist/src/nile-code-editor/nile-code-editor.css.js +5 -5
  41. package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
  42. package/dist/src/nile-code-editor/nile-code-editor.d.ts +4 -2
  43. package/dist/src/nile-code-editor/nile-code-editor.js +64 -30
  44. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  45. package/dist/src/nile-code-editor/theme.d.ts +9 -0
  46. package/dist/src/nile-code-editor/theme.js +10 -0
  47. package/dist/src/nile-code-editor/theme.js.map +1 -0
  48. package/dist/src/nile-switcher/nile-switcher.css.js +42 -12
  49. package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  50. package/dist/src/nile-switcher/nile-switcher.d.ts +1 -0
  51. package/dist/src/nile-switcher/nile-switcher.js +27 -6
  52. package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +1 -1
  55. package/src/nile-code-editor/nile-code-editor.css.ts +5 -5
  56. package/src/nile-code-editor/nile-code-editor.ts +68 -30
  57. package/src/nile-code-editor/theme.ts +9 -0
  58. package/src/nile-switcher/nile-switcher.css.ts +42 -12
  59. package/src/nile-switcher/nile-switcher.ts +29 -6
@@ -17,7 +17,6 @@ export const styles = css `
17
17
  display: flex;
18
18
  justify-content: flex-end;
19
19
  flex-direction: row-reverse;
20
- gap: 0.6rem;
21
20
  }
22
21
 
23
22
  .cm-editor {
@@ -31,11 +30,12 @@ export const styles = css `
31
30
  }
32
31
 
33
32
  .code-editor__icon__container {
34
- cursor: pointer;
33
+ display: none;
35
34
  }
36
-
37
- .code-editor__icon__container {
38
- padding-right: 5px;
35
+ .code-mirror:hover > .code-editor__icon__container {
36
+ cursor: pointer;
37
+ display: flex;
38
+ padding-right: 10px;
39
39
  }
40
40
  `;
41
41
  export default [styles];
@@ -1 +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"]}
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 }\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 display: none;\n }\n .code-mirror:hover > .code-editor__icon__container {\n cursor: pointer;\n display: flex;\n padding-right: 10px;\n }\n`;\n\nexport default [styles];\n"]}
@@ -8,6 +8,7 @@ import { CSSResultArray, TemplateResult } from 'lit-element';
8
8
  import { EditorView } from 'codemirror';
9
9
  import { Compartment } from '@codemirror/state';
10
10
  import NileElement from '../internal/nile-element';
11
+ import { PropertyValues } from 'lit';
11
12
  /**
12
13
  * Nile icon component.
13
14
  *
@@ -19,7 +20,6 @@ export declare class NileCodeEditor extends NileElement {
19
20
  multiline: true;
20
21
  value: true;
21
22
  customOptions: any;
22
- showLineNumbers: any;
23
23
  /**
24
24
  * The styles for CodeEditor
25
25
  * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
@@ -29,7 +29,9 @@ export declare class NileCodeEditor extends NileElement {
29
29
  view: EditorView;
30
30
  convertToSingleLine(code: any): any;
31
31
  lineNumbersComp: Compartment;
32
- updated(): void;
32
+ handleValueChange(): void;
33
+ updated(changedProperties: PropertyValues): void;
34
+ setTheme(): import("@codemirror/state").Extension;
33
35
  emitValues(value: string): void;
34
36
  expandCodeEditor(): void;
35
37
  restrictSingleLine(): import("@codemirror/state").Extension;
@@ -14,6 +14,9 @@ import { javascript, javascriptLanguage, scopeCompletionSource, } from '@codemir
14
14
  import { autocompletion } from '@codemirror/autocomplete';
15
15
  import NileElement from '../internal/nile-element';
16
16
  import { basicSetup } from './extensionSetup';
17
+ import { watch } from '../internal/watch';
18
+ import { classMap } from 'lit/directives/class-map.js';
19
+ import { Theme } from './theme';
17
20
  // Choose the appropriate mode for your use case
18
21
  /**
19
22
  * Nile icon component.
@@ -41,32 +44,57 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
41
44
  // Remove line breaks and unnecessary whitespace
42
45
  return code.replace(/\s+/g, ' ').trim();
43
46
  }
44
- updated() {
45
- const customAutoCompletions = javascriptLanguage.data.of({
46
- autocomplete: scopeCompletionSource(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
- });
47
+ handleValueChange() { }
48
+ updated(changedProperties) {
49
+ super.updated(changedProperties);
50
+ if (changedProperties.has('value')) {
51
+ const customAutoCompletions = javascriptLanguage.data.of({
52
+ autocomplete: scopeCompletionSource(this.customOptions),
53
+ });
54
+ if (!this.view) {
55
+ let startState = EditorState.create({
56
+ doc: !this.multiline
57
+ ? this.convertToSingleLine(this.value)
58
+ : this.value,
59
+ extensions: [
60
+ basicSetup({
61
+ lineNumbers: !!this.multiline,
62
+ highlightActiveLine: false,
63
+ foldGutter: !!this.multiline,
64
+ }),
65
+ customAutoCompletions,
66
+ autocompletion(),
67
+ javascript(),
68
+ //this.setTheme(),
69
+ !this.multiline ? this.restrictSingleLine() : [],
70
+ EditorView.updateListener.of((v) => {
71
+ if (v.docChanged) {
72
+ this.emitValues(this.view.state.doc.toString());
73
+ }
74
+ }),
75
+ ],
76
+ });
77
+ this.view = new EditorView({
78
+ state: startState,
79
+ parent: this.codeEditor,
80
+ });
81
+ }
82
+ else {
83
+ // Editor has already been initialized, update its state
84
+ this.view.dispatch({
85
+ changes: {
86
+ from: 0,
87
+ to: this.view.state.doc.length,
88
+ insert: !this.multiline
89
+ ? this.convertToSingleLine(this.value)
90
+ : this.value,
91
+ },
92
+ });
93
+ }
94
+ }
95
+ }
96
+ setTheme() {
97
+ return EditorView.theme(Theme);
70
98
  }
71
99
  emitValues(value) {
72
100
  this.emit('nile-change', { value: value });
@@ -78,9 +106,15 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
78
106
  return EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr);
79
107
  }
80
108
  render() {
81
- return html `<div class="code-mirror">
109
+ return html `<div
110
+ part="base"
111
+ class=${classMap({
112
+ 'code-mirror': true,
113
+ 'code-mirror__singleline': !this.multiline,
114
+ })}
115
+ >
82
116
  ${!this.multiline
83
- ? html `<nile-icon
117
+ ? html ` <nile-icon
84
118
  name="fullscreenshrink"
85
119
  class="code-editor__icon__container"
86
120
  size="16"
@@ -104,8 +138,8 @@ __decorate([
104
138
  property({ type: String })
105
139
  ], NileCodeEditor.prototype, "customOptions", void 0);
106
140
  __decorate([
107
- property({ type: String })
108
- ], NileCodeEditor.prototype, "showLineNumbers", void 0);
141
+ watch(['value'], { waitUntilFirstUpdate: true })
142
+ ], NileCodeEditor.prototype, "handleValueChange", null);
109
143
  NileCodeEditor = __decorate([
110
144
  customElement('nile-code-editor')
111
145
  ], NileCodeEditor);
@@ -1 +1 @@
1
- {"version":3,"file":"nile-code-editor.js","sourceRoot":"","sources":["../../../src/nile-code-editor/nile-code-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,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,EACL,UAAU,EACV,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AACrC,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;QAC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* 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 {\n javascript,\n javascriptLanguage,\n scopeCompletionSource,\n completionPath,\n} from '@codemirror/lang-javascript';\nimport { autocompletion } from '@codemirror/autocomplete';\nimport { CompletionContext, Completion } 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: scopeCompletionSource(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"]}
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,GAIT,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,EACL,UAAU,EACV,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EA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M,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;;cAED,QAAQ,CAAC;YACf,aAAa,EAAE,IAAI;YACnB,yBAAyB,EAAE,CAAC,IAAI,CAAC,SAAS;SAC3C,CAAC;;QAEA,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;AApHwB;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;AAuB/C;IADC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;uDAC3B;AA3BX,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAqH1B;SArHY,cAAc;AAuH3B,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 PropertyValueMap,\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 {\n javascript,\n javascriptLanguage,\n scopeCompletionSource,\n completionPath,\n} from '@codemirror/lang-javascript';\nimport { autocompletion } from '@codemirror/autocomplete';\nimport { CompletionContext, Completion } from '@codemirror/autocomplete';\nimport NileElement from '../internal/nile-element';\nimport { basicSetup } from './extensionSetup';\nimport { watch } from '../internal/watch';\nimport { PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { Theme } from './theme';\n\n// Choose the appropriate mode for your use case\n\n/**\n * Nile icon component.\n *\n * @tag nile-code-editor\n *\n */\n@customElement('nile-code-editor')\nexport class NileCodeEditor extends NileElement {\n @query('.code-mirror') codeEditor: HTMLInputElement;\n @property({ type: Boolean }) multiline: true;\n @property({ type: String }) value: true;\n @property({ type: String }) customOptions: 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 @watch(['value'], { waitUntilFirstUpdate: true })\n handleValueChange() {}\n\n updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n\n if (changedProperties.has('value')) {\n const customAutoCompletions = javascriptLanguage.data.of({\n autocomplete: scopeCompletionSource(this.customOptions),\n });\n if (!this.view) {\n let startState = EditorState.create({\n doc: !this.multiline\n ? this.convertToSingleLine(this.value)\n : this.value,\n extensions: [\n basicSetup({\n lineNumbers: !!this.multiline,\n highlightActiveLine: false,\n foldGutter: !!this.multiline,\n }),\n customAutoCompletions,\n autocompletion(),\n javascript(),\n //this.setTheme(),\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 } else {\n // Editor has already been initialized, update its state\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 }\n\n setTheme() {\n return EditorView.theme(Theme);\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\n part=\"base\"\n class=${classMap({\n 'code-mirror': true,\n 'code-mirror__singleline': !this.multiline,\n })}\n >\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"]}
@@ -0,0 +1,9 @@
1
+ export declare const Theme: {
2
+ '&': {
3
+ fontSize: string;
4
+ fontFamily: string;
5
+ fontWeight: string;
6
+ };
7
+ '.cm-content': {};
8
+ '.cm-scroller': {};
9
+ };
@@ -0,0 +1,10 @@
1
+ export const Theme = {
2
+ '&': {
3
+ fontSize: '14px',
4
+ fontFamily: 'Colfax-regular',
5
+ fontWeight: '400',
6
+ },
7
+ '.cm-content': {},
8
+ '.cm-scroller': {},
9
+ };
10
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../src/nile-code-editor/theme.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,gBAAgB;QAC5B,UAAU,EAAE,KAAK;KAClB;IACD,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,EAAE;CACnB,CAAC","sourcesContent":["export const Theme = {\n '&': {\n fontSize: '14px',\n fontFamily: 'Colfax-regular',\n fontWeight: '400',\n },\n '.cm-content': {},\n '.cm-scroller': {},\n};\n"]}
@@ -14,22 +14,31 @@ export const styles = css `
14
14
  box-sizing: border-box;
15
15
  }
16
16
 
17
- .switcher-icon-container {
17
+ .pointer-cursor {
18
18
  cursor: pointer;
19
- justify-content: center;
19
+ }
20
+
21
+ .switcher__label {
20
22
  display: flex;
21
23
  align-items: center;
22
- margin-bottom: 6px;
23
- height: 28px;
24
- width: 28px;
25
- border-radius: 4px;
24
+ color: inherit;
25
+ color: var(--nile-colors-dark-900);
26
+ font-family: Colfax-regular;
27
+ font-size: 14px;
28
+ font-style: normal;
29
+ font-weight: 400;
30
+ line-height: 14px;
31
+ letter-spacing: 0.2px;
26
32
  }
27
33
 
34
+ switcher-object-mapper:hover {
35
+ display: flex;
36
+ }
28
37
  .switcher-icon-container.current {
29
38
  background: var(--nile-colors-blue-400);
30
39
  }
31
40
 
32
- .switcher-input-container {
41
+ .switcher-container {
33
42
  display: flex;
34
43
  }
35
44
 
@@ -41,21 +50,36 @@ export const styles = css `
41
50
  flex-direction: column;
42
51
  }
43
52
 
44
- .switcher-block > :first-child {
45
- align-self: end;
46
- }
47
-
48
53
  .switcher-inline > :nth-child(2) {
49
54
  flex: 1;
50
55
  }
51
56
 
52
- .switcher-input-container > :first-child {
57
+ .switcher-icons-container {
53
58
  display: flex;
59
+ margin-left: auto;
54
60
  gap: 0.5rem;
55
61
  max-height: 38px;
56
62
  align-items: center;
57
63
  }
58
64
 
65
+ .switcher-block > .switcher-icons-container {
66
+ margin-left: auto;
67
+ }
68
+
69
+ .label-container {
70
+ display: flex;
71
+ }
72
+
73
+ .switcher-icon-container {
74
+ cursor: pointer;
75
+ justify-content: center;
76
+ display: flex;
77
+ align-items: center;
78
+ margin-bottom: 6px;
79
+ height: 28px;
80
+ width: 28px;
81
+ border-radius: 4px;
82
+ }
59
83
  nile-radio {
60
84
  display: inline-block;
61
85
  padding-right: 10px;
@@ -72,6 +96,12 @@ export const styles = css `
72
96
  border: none;
73
97
  }
74
98
 
99
+ .switcher-object-mapper-icon {
100
+ display: none;
101
+ }
102
+ .switcher-object-mapper:hover > .switcher-object-mapper-icon {
103
+ display: block;
104
+ }
75
105
  .switcher-object-mapper::part(input) {
76
106
  color: var(--nile-colors-primary-600);
77
107
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyGxB,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 .pointer-cursor {\n cursor: pointer;\n }\n\n .switcher__label {\n display: flex;\n align-items: center;\n color: inherit;\n color: var(--nile-colors-dark-900);\n font-family: Colfax-regular;\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n switcher-object-mapper:hover {\n display: flex;\n }\n .switcher-icon-container.current {\n background: var(--nile-colors-blue-400);\n }\n\n .switcher-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-inline > :nth-child(2) {\n flex: 1;\n }\n\n .switcher-icons-container {\n display: flex;\n margin-left: auto;\n gap: 0.5rem;\n max-height: 38px;\n align-items: center;\n }\n\n .switcher-block > .switcher-icons-container {\n margin-left: auto;\n }\n\n .label-container {\n display: flex;\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 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-icon {\n display: none;\n }\n .switcher-object-mapper:hover > .switcher-object-mapper-icon {\n display: block;\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"]}
@@ -76,6 +76,7 @@ export declare class NileSwitcher extends NileElement {
76
76
  * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
77
77
  */
78
78
  static styles: CSSResultGroup;
79
+ private readonly hasSlotController;
79
80
  nileSwitchConfig: switchconfig;
80
81
  current: Number;
81
82
  currentInput: switchInputType;
@@ -13,6 +13,7 @@ import { choose } from 'lit/directives/choose.js';
13
13
  import { classMap } from 'lit/directives/class-map.js';
14
14
  import { repeat } from 'lit/directives/repeat.js';
15
15
  import { watch } from '../internal/watch';
16
+ import { HasSlotController } from '../internal/slot';
16
17
  export var POSITIONS;
17
18
  (function (POSITIONS) {
18
19
  POSITIONS["INLINE"] = "inline";
@@ -42,6 +43,7 @@ export var MODE;
42
43
  let NileSwitcher = class NileSwitcher extends NileElement {
43
44
  constructor() {
44
45
  super(...arguments);
46
+ this.hasSlotController = new HasSlotController(this, 'label');
45
47
  this.current = 0;
46
48
  }
47
49
  connectedCallback() {
@@ -84,6 +86,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
84
86
  renderDropdown(Input) {
85
87
  const { options, multiple, placeholder, disabled, value, error, errorMessage, inputType, } = Input;
86
88
  return html `<nile-select
89
+ part="dropdown"
87
90
  class="switcher-dropdown"
88
91
  .placeholder=${placeholder}
89
92
  .disabled="${disabled}"
@@ -171,7 +174,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
171
174
  const mode = this.currentInput.mode;
172
175
  const value = this.currentInput.mode === MODE.CREATE
173
176
  ? 'Click to Create - Not Mapped'
174
- : '';
177
+ : 'Click to Edit';
175
178
  return html `<nile-input
176
179
  class=${classMap({
177
180
  'switcher-object-mapper': true,
@@ -194,6 +197,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
194
197
  renderCodeEditor(Input) {
195
198
  const { value, multiLine, customAutoCompletions, disabled, readonly, errorMessage, error, inputType, noborder, } = Input;
196
199
  return html `<nile-code-editor
200
+ part="code-editor"
197
201
  class=${classMap({
198
202
  'code-editor': true,
199
203
  'code-editor__no-border': !!noborder,
@@ -203,7 +207,6 @@ let NileSwitcher = class NileSwitcher extends NileElement {
203
207
  .multiline="${multiLine}"
204
208
  .value="${value}"
205
209
  .customOptions="${customAutoCompletions}"
206
- .showLineNumbers="false"
207
210
  ></nile-code-editor> `;
208
211
  }
209
212
  handleExpand(event, inputType) {
@@ -231,7 +234,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
231
234
  const inputs = this.nileSwitchConfig.inputs;
232
235
  const toolTipPosition = this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';
233
236
  return html `
234
- <div class="switcher-icons-container">
237
+ <div part="icons-container" class="switcher-icons-container">
235
238
  ${repeat(inputs, (input, index) => html ` <nile-tooltip
236
239
  class=${classMap({
237
240
  'switcher-tooltip-container': true,
@@ -259,7 +262,9 @@ let NileSwitcher = class NileSwitcher extends NileElement {
259
262
  `;
260
263
  }
261
264
  toggleField(currentInput, index) {
262
- this.current = index;
265
+ if (this.nileSwitchConfig.confirmation) {
266
+ this.current = index;
267
+ }
263
268
  this.emit('nile-switch', { input: this.currentInput });
264
269
  }
265
270
  singleFieldSwitcher() {
@@ -298,15 +303,31 @@ let NileSwitcher = class NileSwitcher extends NileElement {
298
303
  `;
299
304
  }
300
305
  render() {
306
+ const hasLabelSlot = this.hasSlotController.test('label');
301
307
  const align = this.nileSwitchConfig.align;
302
308
  return html `<div
309
+ part="base"
303
310
  class=${classMap({
304
311
  'switcher-block': align === POSITIONS.BLOCK,
305
312
  'switcher-inline': align === POSITIONS.INLINE,
306
- 'switcher-input-container': true,
313
+ 'switcher-container': true,
307
314
  })}
308
315
  >
309
- ${this.renderIcon()} ${this.singleFieldSwitcher()}
316
+ <div class="label-container">
317
+ ${hasLabelSlot
318
+ ? html `
319
+ <label
320
+ part="switcher-label"
321
+ class="switcher__label"
322
+ for="input"
323
+ >
324
+ <slot name="label"></slot>
325
+ </label>
326
+ </div> `
327
+ : ''}
328
+ ${this.renderIcon()}
329
+ </div>
330
+ ${this.singleFieldSwitcher()}
310
331
  </div>`;
311
332
  }
312
333
  };
@@ -1 +1 @@
1
- {"version":3,"file":"nile-switcher.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,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CAAC;;AAxVD;;;GAGG;AACI,mBAAM,GAAmB,MAAM,CAAC;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAqB;AAEpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA+B;AAQ1D;IADC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;wDAGlD;AApBU,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA0VxB;SA1VY,YAAY;AA4VzB,eAAe,YAAY,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 { html, property, TemplateResult } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-switcher.css';\nimport NileElement from '../internal/nile-element';\nimport { CSSResultGroup } from 'lit';\nimport { choose } from 'lit/directives/choose.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { watch } from '../internal/watch';\n\n/**\n * @summary Allows you to switch between nile elements\n *\n * @dependency nile-icon\n * @dependency nile-input\n * @dependency nile-checkbox\n * @dependency nile-dropdown\n * @dependency nile-textarea\n *\n * @event nile-change - Emitted when the control's value changes.\n * @event nile-switch - Emitted when the nile component is being switched.\n */\n\nexport interface switchconfig {\n [key: string]: any;\n toggleSwitch: boolean;\n disable?: boolean;\n confirmation?: boolean;\n align: 'block' | 'inline';\n inputs: switchInputType[];\n}\n\nexport interface switchInputType {\n inputType:\n | INPUT_TYPE_NAMES.DROPDOWN\n | INPUT_TYPE_NAMES.TEXT\n | INPUT_TYPE_NAMES.CHECKBOX\n | INPUT_TYPE_NAMES.TEXTAREA\n | INPUT_TYPE_NAMES.RADIO\n | INPUT_TYPE_NAMES.CONTENTEDITOR\n | INPUT_TYPE_NAMES.OBJECT_MAPPER\n | INPUT_TYPE_NAMES.CODE_EDITOR;\n value?: String | boolean;\n label?: String;\n readonly?: boolean;\n type?: string;\n icon: string;\n mode?: string;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n errorMessage?: string;\n options?: Array<any>;\n customAutoCompletions?: any;\n helperText?: string;\n multiple?: boolean;\n noborder?: boolean;\n multiLine?: boolean;\n expand?: boolean;\n}\n\nexport enum POSITIONS {\n INLINE = 'inline',\n BLOCK = 'block',\n}\n\nexport enum INPUT_TYPE {\n DEFAULT = 'defaultInput',\n SWITCH = 'switchInput',\n}\n\nexport enum INPUT_TYPE_NAMES {\n DROPDOWN = 'dropdown',\n TEXT = 'text',\n CHECKBOX = 'checkbox',\n TEXTAREA = 'text-area',\n RADIO = 'radio',\n CONTENTEDITOR = 'content-editor',\n OBJECT_MAPPER = 'object-mapper',\n CODE_EDITOR = 'code-editor',\n}\n\nexport enum MODE {\n CREATE = 'create',\n EDIT = 'edit',\n}\n\n@customElement('nile-switcher')\nexport class NileSwitcher extends NileElement {\n /**\n * The styles for nile switcher\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n static styles: CSSResultGroup = styles;\n\n @property({ type: Object }) nileSwitchConfig: switchconfig;\n @property({ type: Number }) current: Number = 0;\n\n @property({ type: Object }) currentInput: switchInputType;\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n @watch(['current'], { waitUntilFirstUpdate: true })\n handleSwitcherChange() {\n this.setCurrentInput();\n }\n\n setCurrentInput() {\n if (this.nileSwitchConfig?.inputs) {\n this.currentInput = this.nileSwitchConfig.inputs.filter(\n (input: switchInputType, index: Number) => {\n return index === this.current;\n }\n )[0];\n }\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n renderNileText(Input: switchInputType) {\n const {\n value,\n label,\n placeholder,\n disabled,\n required,\n error,\n errorMessage,\n inputType,\n noborder,\n } = Input;\n return html`<nile-input\n class=${classMap({\n 'switcher-input': true,\n 'switcher-input--noborder': !!noborder,\n })}\n .value=${value}\n .label=${label}\n .disabled=${disabled}\n .required=${required}\n .errorMessage=${errorMessage}\n .placeholder=${placeholder}\n .error=${error}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-input>`;\n }\n\n renderDropdown(Input: switchInputType) {\n const {\n options,\n multiple,\n placeholder,\n disabled,\n value,\n error,\n errorMessage,\n inputType,\n } = Input;\n\n return html`<nile-select\n class=\"switcher-dropdown\"\n .placeholder=${placeholder}\n .disabled=\"${disabled}\"\n .multiple=\"${multiple}\"\n .value=\"${value}\"\n .error=\"${error}\"\n .errorMessage=\"${errorMessage}\"\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n ${options?.map((option: any) => {\n return html`<nile-option .value=\"${option}\">${option} </nile-option>`;\n })}\n </nile-select>`;\n }\n\n renderNileTextArea(Input: switchInputType) {\n const { value, disabled, readonly, errorMessage, error, inputType } = Input;\n\n return html`<nile-textarea\n class=\"switcher-textarea\"\n .value=${value}\n .disabled=${disabled}\n ?readonly=${readonly}\n .error=${error}\n .errorMessage=${errorMessage}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-textarea>`;\n }\n\n renderNileCheckBox(Input: switchInputType) {\n const { value, label, disabled, inputType } = Input;\n\n return html`<nile-checkbox\n class=\"switcher-checkbox\"\n .checked=${value}\n .label=${label}\n .disabled=${disabled}\n @valueChange=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-checkbox\n >; `;\n }\n\n renderNileRadio(Input: switchInputType) {\n const { options, value, disabled, errorMessage, inputType } = Input;\n\n const haserrorMessage = !!errorMessage;\n\n return html`<nile-radio-group\n class=\"switcher-radio-group\"\n .value=${value}\n .disabled=${disabled}\n @change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n ${options &&\n options.map((option: any) => {\n return html`<nile-radio .value=\"${option}\">${option} </nile-radio>`;\n })}\n ${haserrorMessage ? this.renderErrorMessage(errorMessage) : ''}\n </nile-radio-group> `;\n }\n\n renderErrorMessage(errorMessage: string) {\n return html`\n <nile-form-error-message>${errorMessage}</nile-form-error-message>\n `;\n }\n\n renderContentEditor(Input: switchInputType) {\n let { options, inputType, errorMessage, type, readonly, noborder, value } =\n Input;\n return html`<nile-content-editor\n class=\"switcher-content-editor\"\n .value=${value}\n .options=${options}\n .type=${type}\n .readonly=${readonly}\n .noborder=${noborder}\n .errorMessage=${errorMessage}\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n </nile-content-editor>`;\n }\n\n renderObjectMapper() {\n const noborder = this.currentInput.noborder;\n const mode = this.currentInput.mode;\n const value =\n this.currentInput.mode === MODE.CREATE\n ? 'Click to Create - Not Mapped'\n : '';\n\n return html`<nile-input\n class=${classMap({\n 'switcher-object-mapper': true,\n 'switcher-object-mapper--noborder': !!noborder,\n })}\n .value=${value}\n readonly=\"true\"\n @click=\"${(e: CustomEvent) =>\n this.handleChange(e, INPUT_TYPE_NAMES.OBJECT_MAPPER)}\"\n >\n <nile-icon\n class=\"pointer-cursor switcher-object-mapper-icon\"\n slot=\"suffix\"\n name=\"collapse\"\n color=\"#005EA6\"\n size=\"16\"\n >\n </nile-icon>\n </nile-input>`;\n }\n\n renderCodeEditor(Input: switchInputType) {\n const {\n value,\n multiLine,\n customAutoCompletions,\n disabled,\n readonly,\n errorMessage,\n error,\n inputType,\n noborder,\n } = Input;\n return html`<nile-code-editor\n class=${classMap({\n 'code-editor': true,\n 'code-editor__no-border': !!noborder,\n })}\n @nile-expand=\"${(e: CustomEvent) =>\n this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}\"\n @nile-change=\"${(e: CustomEvent) =>\n this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}\"\n .multiline=\"${multiLine}\"\n .value=\"${value}\"\n .customOptions=\"${customAutoCompletions}\"\n .showLineNumbers=\"false\"\n ></nile-code-editor> `;\n }\n\n handleExpand(event: CustomEvent, inputType: string) {\n this.currentInput.expand = event.detail.expand;\n this.emit('nile-change', { input: this.currentInput });\n }\n\n handleChange(event: CustomEvent, inputType: string) {\n switch (inputType) {\n case INPUT_TYPE_NAMES.OBJECT_MAPPER:\n this.currentInput.value = 'clicked';\n break;\n case INPUT_TYPE_NAMES.CHECKBOX:\n this.currentInput.value = event.detail.checked;\n break;\n case INPUT_TYPE_NAMES.CODE_EDITOR:\n this.currentInput.value = event.detail.value;\n break;\n default:\n this.currentInput.value = event.detail.value;\n }\n event.stopPropagation();\n this.emit('nile-change', { input: this.currentInput });\n }\n\n renderIcon() {\n const inputs = this.nileSwitchConfig.inputs;\n const toolTipPosition =\n this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';\n\n return html`\n <div class=\"switcher-icons-container\">\n ${repeat(\n inputs,\n (input: any, index: number) => html` <nile-tooltip\n class=${classMap({\n 'switcher-tooltip-container': true,\n })}\n content=${input.helperText}\n placement=${toolTipPosition}\n >\n <div class=${classMap({\n 'switcher-icon-container': true,\n current: index === this.current,\n })}>\n <nile-icon\n size=\"16\"\n class=${classMap({\n 'pointer-cursor': true,\n })}\n .name=${input.icon}\n color=\"#000000\"\n @click=${() => this.toggleField(input, index)}\n ></nile-icon>\n <div>\n \n </nile-tooltip>`\n )}\n </div>\n `;\n }\n\n toggleField(currentInput: switchInputType, index: Number) {\n this.current = index;\n this.emit('nile-switch', { input: this.currentInput });\n }\n\n singleFieldSwitcher() {\n if (!this.currentInput) {\n this.setCurrentInput();\n }\n return html`\n ${choose(\n this.currentInput.inputType,\n [\n [INPUT_TYPE_NAMES.TEXT, () => this.renderNileText(this.currentInput)],\n [\n INPUT_TYPE_NAMES.CHECKBOX,\n () => this.renderNileCheckBox(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.RADIO,\n () => this.renderNileRadio(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.DROPDOWN,\n () => this.renderDropdown(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () => this.renderContentEditor(this.currentInput),\n ],\n [INPUT_TYPE_NAMES.OBJECT_MAPPER, () => this.renderObjectMapper()],\n [\n INPUT_TYPE_NAMES.CODE_EDITOR,\n () => this.renderCodeEditor(this.currentInput),\n ],\n ],\n () => this.renderNileText(this.currentInput)\n )}\n `;\n }\n\n public render(): TemplateResult {\n const align = this.nileSwitchConfig.align;\n return html`<div\n class=${classMap({\n 'switcher-block': align === POSITIONS.BLOCK,\n 'switcher-inline': align === POSITIONS.INLINE,\n 'switcher-input-container': true,\n })}\n >\n ${this.renderIcon()} ${this.singleFieldSwitcher()}\n </div>`;\n }\n}\n\nexport default NileSwitcher;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-switcher': NileSwitcher;\n }\n}\n"]}
1
+ {"version":3,"file":"nile-switcher.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,E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AC,IAAI,CAAA;;;;;;;;kBAQE;YACR,CAAC,CAAC,EAAE;UACJ,IAAI,CAAC,UAAU,EAAE;;QAEnB,IAAI,CAAC,mBAAmB,EAAE;WACvB,CAAC;IACV,CAAC;;AA9WD;;;GAGG;AACI,mBAAM,GAAmB,MAAM,CAAC;AAIX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAgC;AAE/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAqB;AAEpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA+B;AAQ1D;IADC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;wDAGlD;AAvBU,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAgXxB;SAhXY,YAAY;AAkXzB,eAAe,YAAY,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 { html, property, TemplateResult } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-switcher.css';\nimport NileElement from '../internal/nile-element';\nimport { CSSResultGroup } from 'lit';\nimport { choose } from 'lit/directives/choose.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { watch } from '../internal/watch';\nimport { HasSlotController } from '../internal/slot';\n\n/**\n * @summary Allows you to switch between nile elements\n *\n * @dependency nile-icon\n * @dependency nile-input\n * @dependency nile-checkbox\n * @dependency nile-dropdown\n * @dependency nile-textarea\n *\n * @event nile-change - Emitted when the control's value changes.\n * @event nile-switch - Emitted when the nile component is being switched.\n */\n\nexport interface switchconfig {\n [key: string]: any;\n toggleSwitch: boolean;\n disable?: boolean;\n confirmation?: boolean;\n align: 'block' | 'inline';\n inputs: switchInputType[];\n}\n\nexport interface switchInputType {\n inputType:\n | INPUT_TYPE_NAMES.DROPDOWN\n | INPUT_TYPE_NAMES.TEXT\n | INPUT_TYPE_NAMES.CHECKBOX\n | INPUT_TYPE_NAMES.TEXTAREA\n | INPUT_TYPE_NAMES.RADIO\n | INPUT_TYPE_NAMES.CONTENTEDITOR\n | INPUT_TYPE_NAMES.OBJECT_MAPPER\n | INPUT_TYPE_NAMES.CODE_EDITOR;\n value?: String | boolean;\n label?: String;\n readonly?: boolean;\n type?: string;\n icon: string;\n mode?: string;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n errorMessage?: string;\n options?: Array<any>;\n customAutoCompletions?: any;\n helperText?: string;\n multiple?: boolean;\n noborder?: boolean;\n multiLine?: boolean;\n expand?: boolean;\n}\n\nexport enum POSITIONS {\n INLINE = 'inline',\n BLOCK = 'block',\n}\n\nexport enum INPUT_TYPE {\n DEFAULT = 'defaultInput',\n SWITCH = 'switchInput',\n}\n\nexport enum INPUT_TYPE_NAMES {\n DROPDOWN = 'dropdown',\n TEXT = 'text',\n CHECKBOX = 'checkbox',\n TEXTAREA = 'text-area',\n RADIO = 'radio',\n CONTENTEDITOR = 'content-editor',\n OBJECT_MAPPER = 'object-mapper',\n CODE_EDITOR = 'code-editor',\n}\n\nexport enum MODE {\n CREATE = 'create',\n EDIT = 'edit',\n}\n\n@customElement('nile-switcher')\nexport class NileSwitcher extends NileElement {\n /**\n * The styles for nile switcher\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n static styles: CSSResultGroup = styles;\n\n private readonly hasSlotController = new HasSlotController(this, 'label');\n\n @property({ type: Object }) nileSwitchConfig: switchconfig;\n\n @property({ type: Number }) current: Number = 0;\n\n @property({ type: Object }) currentInput: switchInputType;\n\n connectedCallback() {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n @watch(['current'], { waitUntilFirstUpdate: true })\n handleSwitcherChange() {\n this.setCurrentInput();\n }\n\n setCurrentInput() {\n if (this.nileSwitchConfig?.inputs) {\n this.currentInput = this.nileSwitchConfig.inputs.filter(\n (input: switchInputType, index: Number) => {\n return index === this.current;\n }\n )[0];\n }\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n renderNileText(Input: switchInputType) {\n const {\n value,\n label,\n placeholder,\n disabled,\n required,\n error,\n errorMessage,\n inputType,\n noborder,\n } = Input;\n return html`<nile-input\n class=${classMap({\n 'switcher-input': true,\n 'switcher-input--noborder': !!noborder,\n })}\n .value=${value}\n .label=${label}\n .disabled=${disabled}\n .required=${required}\n .errorMessage=${errorMessage}\n .placeholder=${placeholder}\n .error=${error}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-input>`;\n }\n\n renderDropdown(Input: switchInputType) {\n const {\n options,\n multiple,\n placeholder,\n disabled,\n value,\n error,\n errorMessage,\n inputType,\n } = Input;\n\n return html`<nile-select\n part=\"dropdown\"\n class=\"switcher-dropdown\"\n .placeholder=${placeholder}\n .disabled=\"${disabled}\"\n .multiple=\"${multiple}\"\n .value=\"${value}\"\n .error=\"${error}\"\n .errorMessage=\"${errorMessage}\"\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n ${options?.map((option: any) => {\n return html`<nile-option .value=\"${option}\">${option} </nile-option>`;\n })}\n </nile-select>`;\n }\n\n renderNileTextArea(Input: switchInputType) {\n const { value, disabled, readonly, errorMessage, error, inputType } = Input;\n\n return html`<nile-textarea\n class=\"switcher-textarea\"\n .value=${value}\n .disabled=${disabled}\n ?readonly=${readonly}\n .error=${error}\n .errorMessage=${errorMessage}\n @nile-input=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-textarea>`;\n }\n\n renderNileCheckBox(Input: switchInputType) {\n const { value, label, disabled, inputType } = Input;\n\n return html`<nile-checkbox\n class=\"switcher-checkbox\"\n .checked=${value}\n .label=${label}\n .disabled=${disabled}\n @valueChange=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n ></nile-checkbox\n >; `;\n }\n\n renderNileRadio(Input: switchInputType) {\n const { options, value, disabled, errorMessage, inputType } = Input;\n\n const haserrorMessage = !!errorMessage;\n\n return html`<nile-radio-group\n class=\"switcher-radio-group\"\n .value=${value}\n .disabled=${disabled}\n @change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n ${options &&\n options.map((option: any) => {\n return html`<nile-radio .value=\"${option}\">${option} </nile-radio>`;\n })}\n ${haserrorMessage ? this.renderErrorMessage(errorMessage) : ''}\n </nile-radio-group> `;\n }\n\n renderErrorMessage(errorMessage: string) {\n return html`\n <nile-form-error-message>${errorMessage}</nile-form-error-message>\n `;\n }\n\n renderContentEditor(Input: switchInputType) {\n let { options, inputType, errorMessage, type, readonly, noborder, value } =\n Input;\n return html`<nile-content-editor\n class=\"switcher-content-editor\"\n .value=${value}\n .options=${options}\n .type=${type}\n .readonly=${readonly}\n .noborder=${noborder}\n .errorMessage=${errorMessage}\n @nile-change=${(e: CustomEvent) => {\n this.handleChange(e, inputType);\n }}\n >\n </nile-content-editor>`;\n }\n\n renderObjectMapper() {\n const noborder = this.currentInput.noborder;\n const mode = this.currentInput.mode;\n const value =\n this.currentInput.mode === MODE.CREATE\n ? 'Click to Create - Not Mapped'\n : 'Click to Edit';\n\n return html`<nile-input\n class=${classMap({\n 'switcher-object-mapper': true,\n 'switcher-object-mapper--noborder': !!noborder,\n })}\n .value=${value}\n readonly=\"true\"\n @click=\"${(e: CustomEvent) =>\n this.handleChange(e, INPUT_TYPE_NAMES.OBJECT_MAPPER)}\"\n >\n <nile-icon\n class=\"pointer-cursor switcher-object-mapper-icon\"\n slot=\"suffix\"\n name=\"collapse\"\n color=\"#005EA6\"\n size=\"16\"\n >\n </nile-icon>\n </nile-input>`;\n }\n\n renderCodeEditor(Input: switchInputType) {\n const {\n value,\n multiLine,\n customAutoCompletions,\n disabled,\n readonly,\n errorMessage,\n error,\n inputType,\n noborder,\n } = Input;\n return html`<nile-code-editor\n part=\"code-editor\"\n class=${classMap({\n 'code-editor': true,\n 'code-editor__no-border': !!noborder,\n })}\n @nile-expand=\"${(e: CustomEvent) =>\n this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}\"\n @nile-change=\"${(e: CustomEvent) =>\n this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}\"\n .multiline=\"${multiLine}\"\n .value=\"${value}\"\n .customOptions=\"${customAutoCompletions}\"\n ></nile-code-editor> `;\n }\n\n handleExpand(event: CustomEvent, inputType: string) {\n this.currentInput.expand = event.detail.expand;\n this.emit('nile-change', { input: this.currentInput });\n }\n\n handleChange(event: CustomEvent, inputType: string) {\n switch (inputType) {\n case INPUT_TYPE_NAMES.OBJECT_MAPPER:\n this.currentInput.value = 'clicked';\n break;\n case INPUT_TYPE_NAMES.CHECKBOX:\n this.currentInput.value = event.detail.checked;\n break;\n case INPUT_TYPE_NAMES.CODE_EDITOR:\n this.currentInput.value = event.detail.value;\n break;\n default:\n this.currentInput.value = event.detail.value;\n }\n event.stopPropagation();\n this.emit('nile-change', { input: this.currentInput });\n }\n\n renderIcon() {\n const inputs = this.nileSwitchConfig.inputs;\n const toolTipPosition =\n this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';\n\n return html`\n <div part=\"icons-container\" class=\"switcher-icons-container\">\n ${repeat(\n inputs,\n (input: any, index: number) => html` <nile-tooltip\n class=${classMap({\n 'switcher-tooltip-container': true,\n })}\n content=${input.helperText}\n placement=${toolTipPosition}\n >\n <div class=${classMap({\n 'switcher-icon-container': true,\n current: index === this.current,\n })}>\n <nile-icon\n size=\"16\"\n class=${classMap({\n 'pointer-cursor': true,\n })}\n .name=${input.icon}\n color=\"#000000\"\n @click=${() => this.toggleField(input, index)}\n ></nile-icon>\n <div>\n \n </nile-tooltip>`\n )}\n </div>\n `;\n }\n\n toggleField(currentInput: switchInputType, index: Number) {\n if (this.nileSwitchConfig.confirmation) {\n this.current = index;\n }\n this.emit('nile-switch', { input: this.currentInput });\n }\n\n singleFieldSwitcher() {\n if (!this.currentInput) {\n this.setCurrentInput();\n }\n return html`\n ${choose(\n this.currentInput.inputType,\n [\n [INPUT_TYPE_NAMES.TEXT, () => this.renderNileText(this.currentInput)],\n [\n INPUT_TYPE_NAMES.CHECKBOX,\n () => this.renderNileCheckBox(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.TEXTAREA,\n () => this.renderNileTextArea(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.RADIO,\n () => this.renderNileRadio(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.DROPDOWN,\n () => this.renderDropdown(this.currentInput),\n ],\n [\n INPUT_TYPE_NAMES.CONTENTEDITOR,\n () => this.renderContentEditor(this.currentInput),\n ],\n [INPUT_TYPE_NAMES.OBJECT_MAPPER, () => this.renderObjectMapper()],\n [\n INPUT_TYPE_NAMES.CODE_EDITOR,\n () => this.renderCodeEditor(this.currentInput),\n ],\n ],\n () => this.renderNileText(this.currentInput)\n )}\n `;\n }\n\n public render(): TemplateResult {\n const hasLabelSlot = this.hasSlotController.test('label');\n const align = this.nileSwitchConfig.align;\n return html`<div\n part=\"base\"\n class=${classMap({\n 'switcher-block': align === POSITIONS.BLOCK,\n 'switcher-inline': align === POSITIONS.INLINE,\n 'switcher-container': true,\n })}\n >\n <div class=\"label-container\">\n ${hasLabelSlot\n ? html`\n <label\n part=\"switcher-label\"\n class=\"switcher__label\"\n for=\"input\"\n >\n <slot name=\"label\"></slot>\n </label>\n </div> `\n : ''}\n ${this.renderIcon()}\n </div>\n ${this.singleFieldSwitcher()}\n </div>`;\n }\n}\n\nexport default NileSwitcher;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-switcher': NileSwitcher;\n }\n}\n"]}