@aquera/nile-elements 0.0.36-3 → 0.0.37-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js +2 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.d.ts +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +5 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +2 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +12 -7
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.iife.js +71 -67
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.esm.js +4 -3
- package/dist/nile-code-editor/nile-code-editor.esm.js +4 -4
- package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.esm.js +11 -8
- package/dist/src/nile-code-editor/nile-code-editor.css.js +2 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +1 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +5 -1
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +2 -1
- package/dist/src/nile-switcher/nile-switcher.js +12 -7
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-code-editor/nile-code-editor.css.ts +2 -1
- package/src/nile-code-editor/nile-code-editor.ts +2 -1
- package/src/nile-switcher/nile-switcher.ts +15 -6
@@ -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
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCxB,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 padding: 5px;\n border-radius: 5px;\n border: 1px solid rgb(204, 204, 204);\n }\n\n .error {\n border-color: #e5434d;\n }\n\n .cm-editor {\n flex: 1;\n min-width: 0;\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 align-self: start;\n padding: 5px 5px 0px 0px;\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -23,6 +23,7 @@ export declare class NileCodeEditor extends NileElement {
|
|
23
23
|
updateValue: any;
|
24
24
|
errorMessage: string;
|
25
25
|
error: boolean;
|
26
|
+
expandable: any;
|
26
27
|
/**
|
27
28
|
* The styles for CodeEditor
|
28
29
|
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
@@ -33,6 +33,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
33
33
|
this.updateValue = false;
|
34
34
|
this.errorMessage = '';
|
35
35
|
this.error = false;
|
36
|
+
this.expandable = false;
|
36
37
|
this.lineNumbersComp = new Compartment();
|
37
38
|
/* #endregion */
|
38
39
|
}
|
@@ -129,7 +130,7 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
129
130
|
'code-mirror__singleline': !this.multiline,
|
130
131
|
})}
|
131
132
|
>
|
132
|
-
${
|
133
|
+
${this.expandable
|
133
134
|
? html ` <nile-icon
|
134
135
|
name="expand-2"
|
135
136
|
class="code-editor__icon__container"
|
@@ -169,6 +170,9 @@ __decorate([
|
|
169
170
|
__decorate([
|
170
171
|
property({ attribute: 'error' })
|
171
172
|
], NileCodeEditor.prototype, "error", void 0);
|
173
|
+
__decorate([
|
174
|
+
property({ type: Boolean })
|
175
|
+
], NileCodeEditor.prototype, "expandable", void 0);
|
172
176
|
__decorate([
|
173
177
|
watch(['value'], { waitUntilFirstUpdate: true })
|
174
178
|
], NileCodeEditor.prototype, "handleValueChange", null);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":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,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;uDAC3B;AApCX,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAyI1B;SAzIY,cAAc;AA2I3B,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, reflect: true }) multiline = false;\n @property({ type: String }) value = '';\n @property({ type: String }) customOptions: any = {};\n @property({ type: Boolean }) updateValue: any = false;\n @property({ attribute: 'error-message' }) errorMessage = '';\n @property({ attribute: 'error' }) error = false;\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.emit('nile-destroy');\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 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 if (this.updateValue) {\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\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 const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n error: hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n })}\n >\n ${!this.multiline\n ? html` <nile-icon\n name=\"expand-2\"\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 ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\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,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,gDAAgD;AAEhD;;;;;GAKG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,WAAW;IAAxC;;QAEuC,cAAS,GAAG,KAAK,CAAC;QAClC,UAAK,GAAG,EAAE,CAAC;QACX,kBAAa,GAAQ,EAAE,CAAC;QACvB,gBAAW,GAA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E,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAyB;AACvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA0B;AACZ;IAAzC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;oDAAmB;AAC1B;IAAjC,QAAQ,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;6CAAe;AACnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAyB;AA6BrD;IADC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;uDAC3B;AArCX,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA0I1B;SA1IY,cAAc;AA4I3B,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, reflect: true }) multiline = false;\n @property({ type: String }) value = '';\n @property({ type: String }) customOptions: any = {};\n @property({ type: Boolean }) updateValue: any = false;\n @property({ attribute: 'error-message' }) errorMessage = '';\n @property({ attribute: 'error' }) error = false;\n @property({ type: Boolean }) expandable: any = false;\n\n /**\n * The styles for CodeEditor\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit('nile-init');\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.emit('nile-destroy');\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 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 if (this.updateValue) {\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\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 const hasErrorMessage = !!this.errorMessage;\n const hasError = !!this.error;\n return html`<div\n part=\"code-editor-base\"\n class=${classMap({\n 'code-mirror': true,\n error: hasError || hasErrorMessage,\n 'code-mirror__singleline': !this.multiline,\n })}\n >\n ${this.expandable\n ? html` <nile-icon\n name=\"expand-2\"\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 ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}`;\n }\n\n /* #endregion */\n}\n\nexport default NileCodeEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-code-editor': NileCodeEditor;\n }\n}\n"]}
|
@@ -47,6 +47,7 @@ export interface switchInputType {
|
|
47
47
|
noborder?: boolean;
|
48
48
|
multiLine?: boolean;
|
49
49
|
expand?: boolean;
|
50
|
+
expandable?: boolean;
|
50
51
|
}
|
51
52
|
export declare enum POSITIONS {
|
52
53
|
INLINE = "inline",
|
@@ -91,7 +92,7 @@ export declare class NileSwitcher extends NileElement {
|
|
91
92
|
renderNileRadio(Input: switchInputType): TemplateResult<1>;
|
92
93
|
renderErrorMessage(errorMessage: string): TemplateResult<1>;
|
93
94
|
renderContentEditor(Input: switchInputType): TemplateResult<1>;
|
94
|
-
renderObjectMapper(): TemplateResult<1>;
|
95
|
+
renderObjectMapper(Input: switchInputType): TemplateResult<1>;
|
95
96
|
renderCodeEditor(Input: switchInputType): TemplateResult<1>;
|
96
97
|
handleExpand(event: CustomEvent, inputType: string): void;
|
97
98
|
handleChange(event: CustomEvent, inputType: string): void;
|
@@ -44,7 +44,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
44
44
|
constructor() {
|
45
45
|
super(...arguments);
|
46
46
|
this.hasSlotController = new HasSlotController(this, 'label');
|
47
|
-
this.current =
|
47
|
+
this.current = 1;
|
48
48
|
this.isToggleSwitch = (item) => {
|
49
49
|
return typeof item === 'undefined' || item;
|
50
50
|
};
|
@@ -172,9 +172,8 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
172
172
|
>
|
173
173
|
</nile-content-editor>`;
|
174
174
|
}
|
175
|
-
renderObjectMapper() {
|
176
|
-
|
177
|
-
const mode = this.currentInput.mode;
|
175
|
+
renderObjectMapper(Input) {
|
176
|
+
let { options, inputType, error, errorMessage, type, readonly, noborder } = Input;
|
178
177
|
const value = this.currentInput.mode === MODE.CREATE
|
179
178
|
? 'Click to Create - Not Mapped'
|
180
179
|
: 'Click to Edit';
|
@@ -184,13 +183,15 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
184
183
|
'switcher-object-mapper--noborder': !!noborder,
|
185
184
|
})}
|
186
185
|
.value=${value}
|
186
|
+
.errorMessage=${errorMessage}
|
187
|
+
.error=${error}
|
187
188
|
readonly="true"
|
188
189
|
@click="${(e) => this.handleChange(e, INPUT_TYPE_NAMES.OBJECT_MAPPER)}"
|
189
190
|
>
|
190
191
|
<nile-icon
|
191
192
|
class="pointer-cursor switcher-object-mapper-icon"
|
192
193
|
slot="suffix"
|
193
|
-
name="
|
194
|
+
name="expand-2"
|
194
195
|
color="#005EA6"
|
195
196
|
size="16"
|
196
197
|
>
|
@@ -198,7 +199,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
198
199
|
</nile-input>`;
|
199
200
|
}
|
200
201
|
renderCodeEditor(Input) {
|
201
|
-
const { value, multiLine, customAutoCompletions, disabled, readonly, errorMessage, error, inputType, noborder, } = Input;
|
202
|
+
const { value, multiLine, customAutoCompletions, disabled, readonly, errorMessage, error, inputType, noborder, expandable, } = Input;
|
202
203
|
return html `<nile-code-editor
|
203
204
|
part="switcher-code-editor"
|
204
205
|
class=${classMap({
|
@@ -208,6 +209,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
208
209
|
@nile-change="${(e) => this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
209
210
|
.multiline="${multiLine}"
|
210
211
|
.value="${value}"
|
212
|
+
.expandable="${expandable}"
|
211
213
|
.customOptions="${customAutoCompletions}"
|
212
214
|
></nile-code-editor> `;
|
213
215
|
}
|
@@ -296,7 +298,10 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
296
298
|
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
297
299
|
() => this.renderContentEditor(this.currentInput),
|
298
300
|
],
|
299
|
-
[
|
301
|
+
[
|
302
|
+
INPUT_TYPE_NAMES.OBJECT_MAPPER,
|
303
|
+
() => this.renderObjectMapper(this.currentInput),
|
304
|
+
],
|
300
305
|
[
|
301
306
|
INPUT_TYPE_NAMES.CODE_EDITOR,
|
302
307
|
() => this.renderCodeEditor(this.currentInput),
|
@@ -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,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,EAAE,MAAM,kB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;;;;;kBAQE;YACR,CAAC,CAAC,EAAE;UACJ,IAAI,CAAC,UAAU,EAAE;;QAEnB,IAAI,CAAC,mBAAmB,EAAE;WACvB,CAAC;IACV,CAAC;;AAjXD;;;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,CAmXxB;SAnXY,YAAY;AAqXzB,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=\"switcher-code-editor\"\n class=${classMap({\n 'code-editor': true,\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 isToggleSwitch = (item: any) => {\n return typeof item === 'undefined' || item;\n };\n\n toggleField(currentInput: switchInputType, index: Number) {\n this.emit('nile-switch', {\n inputClicked: index,\n currentInput: currentInput,\n });\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"]}
|
1
|
+
{"version":3,"file":"nile-switcher.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,O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C,IAAI,CAAC,YAAY,CAAC;aAC/C;SACF,EACD,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAC7C;KACF,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAC1C,OAAO,IAAI,CAAA;;cAED,QAAQ,CAAC;YACf,gBAAgB,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK;YAC3C,iBAAiB,EAAE,KAAK,KAAK,SAAS,CAAC,MAAM;YAC7C,oBAAoB,EAAE,IAAI;SAC3B,CAAC;;;UAGE,YAAY;YACZ,CAAC,CAAC,IAAI,CAAA;;;;;;;;kBAQE;YACR,CAAC,CAAC,EAAE;UACJ,IAAI,CAAC,UAAU,EAAE;;QAEnB,IAAI,CAAC,mBAAmB,EAAE;WACvB,CAAC;IACV,CAAC;;AAzXD;;;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,CA2XxB;SA3XY,YAAY;AA6XzB,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 expandable?: 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 = 1;\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(Input: switchInputType) {\n let { options, inputType, error, errorMessage, type, readonly, noborder } =\n Input;\n\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 .errorMessage=${errorMessage}\n .error=${error}\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=\"expand-2\"\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 expandable,\n } = Input;\n return html`<nile-code-editor\n part=\"switcher-code-editor\"\n class=${classMap({\n 'code-editor': true,\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 .expandable=\"${expandable}\"\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 isToggleSwitch = (item: any) => {\n return typeof item === 'undefined' || item;\n };\n\n toggleField(currentInput: switchInputType, index: Number) {\n this.emit('nile-switch', {\n inputClicked: index,\n currentInput: currentInput,\n });\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 [\n INPUT_TYPE_NAMES.OBJECT_MAPPER,\n () => this.renderObjectMapper(this.currentInput),\n ],\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"]}
|