@aquera/nile-elements 0.0.34 → 0.0.36-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 +12 -5
- 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 +9 -4
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +98 -39
- 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-code-editor/theme.d.ts +9 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js +10 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +41 -18
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +36 -9
- 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.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +279 -227
- package/dist/nile-code-editor/extensionSetup.cjs.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/index.cjs.js +1 -1
- package/dist/nile-code-editor/index.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- 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 +14 -7
- package/dist/nile-code-editor/nile-code-editor.esm.js +17 -9
- package/dist/nile-code-editor/theme.cjs.js +2 -0
- package/dist/nile-code-editor/theme.cjs.js.map +1 -0
- package/dist/nile-code-editor/theme.esm.js +1 -0
- package/dist/nile-switcher/index.cjs.js +1 -1
- package/dist/nile-switcher/index.esm.js +1 -1
- 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.css.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.css.esm.js +43 -20
- package/dist/nile-switcher/nile-switcher.esm.js +51 -37
- package/dist/src/nile-code-editor/nile-code-editor.css.js +12 -5
- 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 +9 -4
- package/dist/src/nile-code-editor/nile-code-editor.js +98 -39
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +9 -0
- package/dist/src/nile-code-editor/theme.js +10 -0
- package/dist/src/nile-code-editor/theme.js.map +1 -0
- package/dist/src/nile-switcher/nile-switcher.css.js +41 -18
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +2 -0
- package/dist/src/nile-switcher/nile-switcher.js +36 -9
- 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 +12 -5
- package/src/nile-code-editor/nile-code-editor.ts +93 -42
- package/src/nile-code-editor/theme.ts +9 -0
- package/src/nile-switcher/nile-switcher.css.ts +41 -18
- package/src/nile-switcher/nile-switcher.ts +38 -9
@@ -17,7 +17,13 @@ export const styles = css `
|
|
17
17
|
display: flex;
|
18
18
|
justify-content: flex-end;
|
19
19
|
flex-direction: row-reverse;
|
20
|
-
|
20
|
+
padding: 5px;
|
21
|
+
border-radius: 5px;
|
22
|
+
border: 1px solid rgb(204, 204, 204);
|
23
|
+
}
|
24
|
+
|
25
|
+
.error {
|
26
|
+
border-color: #e5434d;
|
21
27
|
}
|
22
28
|
|
23
29
|
.cm-editor {
|
@@ -31,11 +37,12 @@ export const styles = css `
|
|
31
37
|
}
|
32
38
|
|
33
39
|
.code-editor__icon__container {
|
34
|
-
|
40
|
+
display: none;
|
35
41
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
.code-mirror:hover > .code-editor__icon__container {
|
43
|
+
cursor: pointer;
|
44
|
+
display: flex;
|
45
|
+
padding-right: 10px;
|
39
46
|
}
|
40
47
|
`;
|
41
48
|
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
|
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 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
|
*
|
@@ -16,10 +17,12 @@ import NileElement from '../internal/nile-element';
|
|
16
17
|
*/
|
17
18
|
export declare class NileCodeEditor extends NileElement {
|
18
19
|
codeEditor: HTMLInputElement;
|
19
|
-
multiline:
|
20
|
-
value:
|
20
|
+
multiline: boolean;
|
21
|
+
value: string;
|
21
22
|
customOptions: any;
|
22
|
-
|
23
|
+
updateValue: any;
|
24
|
+
errorMessage: string;
|
25
|
+
error: boolean;
|
23
26
|
/**
|
24
27
|
* The styles for CodeEditor
|
25
28
|
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
@@ -29,7 +32,9 @@ export declare class NileCodeEditor extends NileElement {
|
|
29
32
|
view: EditorView;
|
30
33
|
convertToSingleLine(code: any): any;
|
31
34
|
lineNumbersComp: Compartment;
|
32
|
-
|
35
|
+
handleValueChange(): void;
|
36
|
+
firstUpdated(changedProperties: PropertyValues): void;
|
37
|
+
setTheme(): import("@codemirror/state").Extension;
|
33
38
|
emitValues(value: string): void;
|
34
39
|
expandCodeEditor(): void;
|
35
40
|
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.
|
@@ -24,6 +27,12 @@ import { basicSetup } from './extensionSetup';
|
|
24
27
|
let NileCodeEditor = class NileCodeEditor extends NileElement {
|
25
28
|
constructor() {
|
26
29
|
super(...arguments);
|
30
|
+
this.multiline = false;
|
31
|
+
this.value = '';
|
32
|
+
this.customOptions = {};
|
33
|
+
this.updateValue = false;
|
34
|
+
this.errorMessage = '';
|
35
|
+
this.error = false;
|
27
36
|
this.lineNumbersComp = new Compartment();
|
28
37
|
/* #endregion */
|
29
38
|
}
|
@@ -41,32 +50,57 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
41
50
|
// Remove line breaks and unnecessary whitespace
|
42
51
|
return code.replace(/\s+/g, ' ').trim();
|
43
52
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
53
|
+
handleValueChange() { }
|
54
|
+
firstUpdated(changedProperties) {
|
55
|
+
super.updated(changedProperties);
|
56
|
+
if (changedProperties.has('value')) {
|
57
|
+
const customAutoCompletions = javascriptLanguage.data.of({
|
58
|
+
autocomplete: scopeCompletionSource(this.customOptions),
|
59
|
+
});
|
60
|
+
if (!this.view) {
|
61
|
+
let startState = EditorState.create({
|
62
|
+
doc: !this.multiline
|
63
|
+
? this.convertToSingleLine(this.value)
|
64
|
+
: this.value,
|
65
|
+
extensions: [
|
66
|
+
basicSetup({
|
67
|
+
lineNumbers: !!this.multiline,
|
68
|
+
highlightActiveLine: false,
|
69
|
+
foldGutter: !!this.multiline,
|
70
|
+
}),
|
71
|
+
customAutoCompletions,
|
72
|
+
autocompletion(),
|
73
|
+
javascript(),
|
74
|
+
this.setTheme(),
|
75
|
+
!this.multiline ? this.restrictSingleLine() : [],
|
76
|
+
EditorView.updateListener.of((v) => {
|
77
|
+
if (v.docChanged) {
|
78
|
+
this.emitValues(this.view.state.doc.toString());
|
79
|
+
}
|
80
|
+
}),
|
81
|
+
],
|
82
|
+
});
|
83
|
+
this.view = new EditorView({
|
84
|
+
state: startState,
|
85
|
+
parent: this.codeEditor,
|
86
|
+
});
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
// Editor has already been initialized, update its state
|
90
|
+
this.view.dispatch({
|
91
|
+
changes: {
|
92
|
+
from: 0,
|
93
|
+
to: this.view.state.doc.length,
|
94
|
+
insert: !this.multiline
|
95
|
+
? this.convertToSingleLine(this.value)
|
96
|
+
: this.value,
|
97
|
+
},
|
98
|
+
});
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
setTheme() {
|
103
|
+
return EditorView.theme(Theme);
|
70
104
|
}
|
71
105
|
emitValues(value) {
|
72
106
|
this.emit('nile-change', { value: value });
|
@@ -78,24 +112,40 @@ let NileCodeEditor = class NileCodeEditor extends NileElement {
|
|
78
112
|
return EditorState.transactionFilter.of(tr => tr.newDoc.lines > 1 ? [] : tr);
|
79
113
|
}
|
80
114
|
render() {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
115
|
+
const hasErrorMessage = !!this.errorMessage;
|
116
|
+
const hasError = !!this.error;
|
117
|
+
return html `<div
|
118
|
+
part="code-editor-base"
|
119
|
+
class=${classMap({
|
120
|
+
'code-mirror': true,
|
121
|
+
error: hasError || hasErrorMessage,
|
122
|
+
'code-mirror__singleline': !this.multiline,
|
123
|
+
})}
|
124
|
+
>
|
125
|
+
${!this.multiline
|
126
|
+
? html ` <nile-icon
|
127
|
+
name="fullscreenshrink"
|
128
|
+
class="code-editor__icon__container"
|
129
|
+
size="16"
|
130
|
+
color="black"
|
131
|
+
@click="${(e) => this.expandCodeEditor()}"
|
132
|
+
></nile-icon>`
|
90
133
|
: ''}
|
91
|
-
|
134
|
+
</div>
|
135
|
+
${hasErrorMessage
|
136
|
+
? html `
|
137
|
+
<nile-form-error-message
|
138
|
+
>${this.errorMessage}</nile-form-error-message
|
139
|
+
>
|
140
|
+
`
|
141
|
+
: ``}`;
|
92
142
|
}
|
93
143
|
};
|
94
144
|
__decorate([
|
95
145
|
query('.code-mirror')
|
96
146
|
], NileCodeEditor.prototype, "codeEditor", void 0);
|
97
147
|
__decorate([
|
98
|
-
property({ type: Boolean })
|
148
|
+
property({ type: Boolean, reflect: true })
|
99
149
|
], NileCodeEditor.prototype, "multiline", void 0);
|
100
150
|
__decorate([
|
101
151
|
property({ type: String })
|
@@ -104,8 +154,17 @@ __decorate([
|
|
104
154
|
property({ type: String })
|
105
155
|
], NileCodeEditor.prototype, "customOptions", void 0);
|
106
156
|
__decorate([
|
107
|
-
property({ type:
|
108
|
-
], NileCodeEditor.prototype, "
|
157
|
+
property({ type: Boolean })
|
158
|
+
], NileCodeEditor.prototype, "updateValue", void 0);
|
159
|
+
__decorate([
|
160
|
+
property({ attribute: 'error-message' })
|
161
|
+
], NileCodeEditor.prototype, "errorMessage", void 0);
|
162
|
+
__decorate([
|
163
|
+
property({ attribute: 'error' })
|
164
|
+
], NileCodeEditor.prototype, "error", void 0);
|
165
|
+
__decorate([
|
166
|
+
watch(['value'], { waitUntilFirstUpdate: true })
|
167
|
+
], NileCodeEditor.prototype, "handleValueChange", null);
|
109
168
|
NileCodeEditor = __decorate([
|
110
169
|
customElement('nile-code-editor')
|
111
170
|
], 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,
|
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,k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,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAmB;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,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;AAuBhD;IADC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;uDAC3B;AA9BX,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAkI1B;SAlIY,cAAc;AAoI3B,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 }\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 firstUpdated(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 // 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=\"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 ${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"]}
|
@@ -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
|
-
.
|
17
|
+
.pointer-cursor {
|
18
18
|
cursor: pointer;
|
19
|
-
|
19
|
+
}
|
20
|
+
|
21
|
+
.switcher__label {
|
20
22
|
display: flex;
|
21
23
|
align-items: center;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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-
|
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-
|
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;
|
@@ -63,15 +87,14 @@ export const styles = css `
|
|
63
87
|
|
64
88
|
nile-code-editor {
|
65
89
|
overflow: hidden;
|
66
|
-
padding-top: 2px;
|
67
|
-
border-radius: 5px;
|
68
|
-
border: 1px solid rgb(204, 204, 204);
|
69
90
|
}
|
70
91
|
|
71
|
-
.
|
72
|
-
|
92
|
+
.switcher-object-mapper-icon {
|
93
|
+
display: none;
|
94
|
+
}
|
95
|
+
.switcher-object-mapper:hover > .switcher-object-mapper-icon {
|
96
|
+
display: block;
|
73
97
|
}
|
74
|
-
|
75
98
|
.switcher-object-mapper::part(input) {
|
76
99
|
color: var(--nile-colors-primary-600);
|
77
100
|
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
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGxB,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 }\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;
|
@@ -95,6 +96,7 @@ export declare class NileSwitcher extends NileElement {
|
|
95
96
|
handleExpand(event: CustomEvent, inputType: string): void;
|
96
97
|
handleChange(event: CustomEvent, inputType: string): void;
|
97
98
|
renderIcon(): TemplateResult<1>;
|
99
|
+
isToggleSwitch: (item: any) => any;
|
98
100
|
toggleField(currentInput: switchInputType, index: Number): void;
|
99
101
|
singleFieldSwitcher(): TemplateResult<1>;
|
100
102
|
render(): TemplateResult;
|
@@ -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,7 +43,11 @@ export var MODE;
|
|
42
43
|
let NileSwitcher = class NileSwitcher extends NileElement {
|
43
44
|
constructor() {
|
44
45
|
super(...arguments);
|
45
|
-
this.
|
46
|
+
this.hasSlotController = new HasSlotController(this, 'label');
|
47
|
+
this.current = 1;
|
48
|
+
this.isToggleSwitch = (item) => {
|
49
|
+
return typeof item === 'undefined' || item;
|
50
|
+
};
|
46
51
|
}
|
47
52
|
connectedCallback() {
|
48
53
|
super.connectedCallback();
|
@@ -84,6 +89,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
84
89
|
renderDropdown(Input) {
|
85
90
|
const { options, multiple, placeholder, disabled, value, error, errorMessage, inputType, } = Input;
|
86
91
|
return html `<nile-select
|
92
|
+
part="dropdown"
|
87
93
|
class="switcher-dropdown"
|
88
94
|
.placeholder=${placeholder}
|
89
95
|
.disabled="${disabled}"
|
@@ -171,7 +177,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
171
177
|
const mode = this.currentInput.mode;
|
172
178
|
const value = this.currentInput.mode === MODE.CREATE
|
173
179
|
? 'Click to Create - Not Mapped'
|
174
|
-
: '';
|
180
|
+
: 'Click to Edit';
|
175
181
|
return html `<nile-input
|
176
182
|
class=${classMap({
|
177
183
|
'switcher-object-mapper': true,
|
@@ -194,16 +200,15 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
194
200
|
renderCodeEditor(Input) {
|
195
201
|
const { value, multiLine, customAutoCompletions, disabled, readonly, errorMessage, error, inputType, noborder, } = Input;
|
196
202
|
return html `<nile-code-editor
|
203
|
+
part="switcher-code-editor"
|
197
204
|
class=${classMap({
|
198
205
|
'code-editor': true,
|
199
|
-
'code-editor__no-border': !!noborder,
|
200
206
|
})}
|
201
207
|
@nile-expand="${(e) => this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
202
208
|
@nile-change="${(e) => this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
203
209
|
.multiline="${multiLine}"
|
204
210
|
.value="${value}"
|
205
211
|
.customOptions="${customAutoCompletions}"
|
206
|
-
.showLineNumbers="false"
|
207
212
|
></nile-code-editor> `;
|
208
213
|
}
|
209
214
|
handleExpand(event, inputType) {
|
@@ -231,7 +236,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
231
236
|
const inputs = this.nileSwitchConfig.inputs;
|
232
237
|
const toolTipPosition = this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';
|
233
238
|
return html `
|
234
|
-
<div class="switcher-icons-container">
|
239
|
+
<div part="icons-container" class="switcher-icons-container">
|
235
240
|
${repeat(inputs, (input, index) => html ` <nile-tooltip
|
236
241
|
class=${classMap({
|
237
242
|
'switcher-tooltip-container': true,
|
@@ -259,8 +264,14 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
259
264
|
`;
|
260
265
|
}
|
261
266
|
toggleField(currentInput, index) {
|
262
|
-
this.
|
263
|
-
|
267
|
+
if (this.isToggleSwitch(this.nileSwitchConfig.confirmation)) {
|
268
|
+
this.current = index;
|
269
|
+
}
|
270
|
+
this.updateComplete.then(res => {
|
271
|
+
if (res) {
|
272
|
+
this.emit('nile-switch', { input: this.currentInput });
|
273
|
+
}
|
274
|
+
});
|
264
275
|
}
|
265
276
|
singleFieldSwitcher() {
|
266
277
|
if (!this.currentInput) {
|
@@ -298,15 +309,31 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
298
309
|
`;
|
299
310
|
}
|
300
311
|
render() {
|
312
|
+
const hasLabelSlot = this.hasSlotController.test('label');
|
301
313
|
const align = this.nileSwitchConfig.align;
|
302
314
|
return html `<div
|
315
|
+
part="base"
|
303
316
|
class=${classMap({
|
304
317
|
'switcher-block': align === POSITIONS.BLOCK,
|
305
318
|
'switcher-inline': align === POSITIONS.INLINE,
|
306
|
-
'switcher-
|
319
|
+
'switcher-container': true,
|
307
320
|
})}
|
308
321
|
>
|
309
|
-
|
322
|
+
<div class="label-container">
|
323
|
+
${hasLabelSlot
|
324
|
+
? html `
|
325
|
+
<label
|
326
|
+
part="switcher-label"
|
327
|
+
class="switcher__label"
|
328
|
+
for="input"
|
329
|
+
>
|
330
|
+
<slot name="label"></slot>
|
331
|
+
</label>
|
332
|
+
</div> `
|
333
|
+
: ''}
|
334
|
+
${this.renderIcon()}
|
335
|
+
</div>
|
336
|
+
${this.singleFieldSwitcher()}
|
310
337
|
</div>`;
|
311
338
|
}
|
312
339
|
};
|