@aquera/nile-elements 0.0.88 → 0.0.90
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/README.md +11 -1
- package/demo/variables.css +6 -0
- package/demo/variables_v2.css +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +252 -221
- 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 +5 -2
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-code-editor/theme.cjs.js +1 -1
- package/dist/nile-code-editor/theme.cjs.js.map +1 -1
- package/dist/nile-code-editor/theme.esm.js +1 -1
- package/dist/nile-divider/nile-divider.css.cjs.js +1 -1
- package/dist/nile-divider/nile-divider.css.cjs.js.map +1 -1
- package/dist/nile-divider/nile-divider.css.esm.js +2 -2
- package/dist/nile-toolbar/index.cjs.js +1 -1
- package/dist/nile-toolbar/index.cjs.js.map +1 -1
- package/dist/nile-toolbar/index.esm.js +1 -3
- package/dist/nile-toolbar/nile-toolbar.cjs.js +2 -0
- package/dist/nile-toolbar/nile-toolbar.cjs.js.map +1 -0
- package/dist/nile-toolbar/nile-toolbar.css.cjs.js +1 -1
- package/dist/nile-toolbar/nile-toolbar.css.cjs.js.map +1 -1
- package/dist/nile-toolbar/nile-toolbar.css.esm.js +20 -4
- package/dist/nile-toolbar/nile-toolbar.esm.js +9 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js +3 -0
- 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 +6 -7
- package/dist/src/nile-code-editor/nile-code-editor.js +13 -9
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +1 -2
- package/dist/src/nile-code-editor/theme.js +3 -2
- package/dist/src/nile-code-editor/theme.js.map +1 -1
- package/dist/src/nile-divider/nile-divider.css.js +2 -2
- package/dist/src/nile-divider/nile-divider.css.js.map +1 -1
- package/dist/src/nile-toolbar/index.d.ts +1 -31
- package/dist/src/nile-toolbar/index.js +1 -41
- package/dist/src/nile-toolbar/index.js.map +1 -1
- package/dist/src/nile-toolbar/nile-toolbar.css.d.ts +5 -5
- package/dist/src/nile-toolbar/nile-toolbar.css.js +23 -7
- package/dist/src/nile-toolbar/nile-toolbar.css.js.map +1 -1
- package/dist/src/nile-toolbar/nile-toolbar.d.ts +34 -0
- package/dist/src/nile-toolbar/nile-toolbar.js +61 -0
- package/dist/src/nile-toolbar/nile-toolbar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
- package/src/index.ts +2 -0
- package/src/nile-code-editor/nile-code-editor.css.ts +3 -0
- package/src/nile-code-editor/nile-code-editor.ts +41 -29
- package/src/nile-code-editor/theme.ts +3 -2
- package/src/nile-divider/nile-divider.css.ts +2 -2
- package/src/nile-toolbar/index.ts +1 -52
- package/src/nile-toolbar/nile-toolbar.css.ts +25 -9
- package/src/nile-toolbar/nile-toolbar.ts +63 -0
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"description": "Webcomponent nile-elements following open-wc recommendations",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "nile-elements",
|
6
|
-
"version": "0.0.
|
6
|
+
"version": "0.0.90",
|
7
7
|
"main": "dist/src/index.js",
|
8
8
|
"type": "module",
|
9
9
|
"module": "dist/src/index.js",
|
@@ -78,8 +78,10 @@
|
|
78
78
|
"./nile-split-panel": "./dist/src/nile-split-panel/index.js",
|
79
79
|
"./nile-list": "./dist/src/nile-list/index.js",
|
80
80
|
"./nile-list-item": "./dist/src/nile-list-item/index.js",
|
81
|
+
"./nile-divider": "./dist/src/nile-divider/index.js",
|
81
82
|
"./nile-detail": "./dist/src/nile-detail/index.js",
|
82
|
-
"./nile-title": "./dist/src/nile-title/index.js"
|
83
|
+
"./nile-title": "./dist/src/nile-title/index.js",
|
84
|
+
"./nile-toolbar": "./dist/src/nile-toolbar/index.js"
|
83
85
|
},
|
84
86
|
"scripts": {
|
85
87
|
"analyze": "cem analyze --litelement",
|
@@ -108,6 +110,7 @@
|
|
108
110
|
"@floating-ui/dom": "^1.2.1",
|
109
111
|
"composed-offset-position": "^0.0.4",
|
110
112
|
"@codemirror/lang-javascript": "6.2.1",
|
113
|
+
"@codemirror/lang-sql": "6.7.0",
|
111
114
|
"codemirror": "6.0.1",
|
112
115
|
"chalk": "5.3.0",
|
113
116
|
"figlet": "1.7.0"
|
package/src/index.ts
CHANGED
@@ -18,13 +18,14 @@ import { styles } from './nile-code-editor.css';
|
|
18
18
|
import { EditorView } from 'codemirror';
|
19
19
|
import { ViewUpdate } from '@codemirror/view';
|
20
20
|
import { EditorState, Compartment } from '@codemirror/state';
|
21
|
-
import {lineNumbers} from '@codemirror/view';
|
21
|
+
import { lineNumbers } from '@codemirror/view';
|
22
22
|
import {
|
23
23
|
javascript,
|
24
24
|
javascriptLanguage,
|
25
25
|
scopeCompletionSource,
|
26
26
|
completionPath,
|
27
27
|
} from '@codemirror/lang-javascript';
|
28
|
+
import { sql } from '@codemirror/lang-sql';
|
28
29
|
import { autocompletion } from '@codemirror/autocomplete';
|
29
30
|
import { CompletionContext, Completion } from '@codemirror/autocomplete';
|
30
31
|
import NileElement from '../internal/nile-element';
|
@@ -44,17 +45,26 @@ import { Theme } from './theme';
|
|
44
45
|
*/
|
45
46
|
@customElement('nile-code-editor')
|
46
47
|
export class NileCodeEditor extends NileElement {
|
48
|
+
|
47
49
|
@query('.code-mirror') codeEditor: HTMLInputElement;
|
48
|
-
|
50
|
+
|
49
51
|
@property({ type: String }) value = '';
|
52
|
+
|
50
53
|
@property({ type: String }) customAutoCompletions: any = {};
|
51
|
-
@property({ type: Boolean }) updateValue: any = false;
|
52
|
-
@property({ attribute: 'error-message' }) errorMessage = '';
|
53
|
-
@property({ attribute: 'error', type: Boolean }) error = false;
|
54
|
-
@property({ attribute: 'noborder', type:Boolean }) noborder = false;
|
55
54
|
|
56
|
-
@property({ type:
|
57
|
-
|
55
|
+
@property({ type: String }) language: 'javascript' | 'sql' = 'javascript'
|
56
|
+
|
57
|
+
@property({ attribute: 'error-message' }) errorMessage: string = '';
|
58
|
+
|
59
|
+
@property({ attribute: 'error', type: Boolean }) error: boolean = false;
|
60
|
+
|
61
|
+
@property({ attribute: 'noborder', type: Boolean }) noborder: boolean = false;
|
62
|
+
|
63
|
+
@property({ type: Boolean, reflect: true }) multiline: boolean = false;
|
64
|
+
|
65
|
+
@property({ type: Boolean }) expandable: boolean = false;
|
66
|
+
|
67
|
+
@property({ type: Boolean, reflect: true }) readonly: boolean = false;
|
58
68
|
|
59
69
|
/**
|
60
70
|
* The styles for CodeEditor
|
@@ -78,12 +88,13 @@ export class NileCodeEditor extends NileElement {
|
|
78
88
|
public view: EditorView;
|
79
89
|
|
80
90
|
convertToSingleLine(code: any) {
|
91
|
+
if (!code) return '';
|
81
92
|
// Remove line breaks and unnecessary whitespace
|
82
93
|
return code.replace(/\s+/g, ' ').trim();
|
83
94
|
}
|
84
|
-
lineNumbersComp = new Compartment();
|
85
|
-
restrictSingleLineComp = new Compartment();
|
86
|
-
readOnlyComp = new Compartment();
|
95
|
+
private lineNumbersComp = new Compartment();
|
96
|
+
private restrictSingleLineComp = new Compartment();
|
97
|
+
private readOnlyComp = new Compartment();
|
87
98
|
|
88
99
|
getLineNumbersExension() {
|
89
100
|
return this.multiline ? lineNumbers() : [];
|
@@ -93,8 +104,8 @@ export class NileCodeEditor extends NileElement {
|
|
93
104
|
return EditorState.readOnly.of(this.readonly);
|
94
105
|
}
|
95
106
|
|
96
|
-
getSingleLineExtension(){
|
97
|
-
|
107
|
+
getSingleLineExtension() {
|
108
|
+
return !this.multiline ? EditorState.transactionFilter.of(tr =>
|
98
109
|
tr.newDoc.lines > 1 ? [] : tr
|
99
110
|
) : [];
|
100
111
|
}
|
@@ -106,6 +117,7 @@ export class NileCodeEditor extends NileElement {
|
|
106
117
|
const customAutoCompletions = javascriptLanguage.data.of({
|
107
118
|
autocomplete: scopeCompletionSource(this.customAutoCompletions),
|
108
119
|
});
|
120
|
+
const language = this.language == "sql" ? sql() : javascript()
|
109
121
|
let startState = EditorState.create({
|
110
122
|
doc: !this.multiline
|
111
123
|
? this.convertToSingleLine(this.value)
|
@@ -120,7 +132,7 @@ export class NileCodeEditor extends NileElement {
|
|
120
132
|
restrictSingleLineExtension,
|
121
133
|
customAutoCompletions,
|
122
134
|
autocompletion(),
|
123
|
-
|
135
|
+
language,
|
124
136
|
EditorView.theme(Theme),
|
125
137
|
EditorView.updateListener.of((v: ViewUpdate) => {
|
126
138
|
if (v.docChanged) {
|
@@ -141,7 +153,7 @@ export class NileCodeEditor extends NileElement {
|
|
141
153
|
}
|
142
154
|
|
143
155
|
singleLineMultiLineToggle() {
|
144
|
-
|
156
|
+
this.view.dispatch({
|
145
157
|
changes: {
|
146
158
|
from: 0,
|
147
159
|
to: this.view.state.doc.length,
|
@@ -151,22 +163,22 @@ export class NileCodeEditor extends NileElement {
|
|
151
163
|
},
|
152
164
|
});
|
153
165
|
}
|
154
|
-
|
166
|
+
|
155
167
|
updated(changedProperties: PropertyValues) {
|
156
168
|
super.updated(changedProperties);
|
157
|
-
if (changedProperties.has('value')
|
158
|
-
|
159
|
-
|
160
|
-
|
169
|
+
if (changedProperties.has('value')) {
|
170
|
+
// Editor has already been initialized, update its state
|
171
|
+
this.singleLineMultiLineToggle();
|
172
|
+
}
|
161
173
|
if (changedProperties.has('multiline')) {
|
162
174
|
this.view.dispatch({
|
163
175
|
effects: [this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),
|
164
|
-
|
176
|
+
this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())],
|
165
177
|
})
|
166
178
|
this.singleLineMultiLineToggle();
|
167
179
|
}
|
168
180
|
if (changedProperties.has('readonly')) {
|
169
|
-
this.view.dispatch({ effects: this.readOnlyComp.reconfigure(this.getReadOnlyExtension()) })
|
181
|
+
this.view.dispatch({ effects: this.readOnlyComp.reconfigure(this.getReadOnlyExtension()) })
|
170
182
|
}
|
171
183
|
}
|
172
184
|
|
@@ -186,21 +198,21 @@ export class NileCodeEditor extends NileElement {
|
|
186
198
|
return html`<div
|
187
199
|
part="code-editor-base"
|
188
200
|
class=${classMap({
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
201
|
+
'code-mirror': true,
|
202
|
+
noborder: noborder,
|
203
|
+
error: hasError || hasErrorMessage,
|
204
|
+
'code-mirror__singleline': !this.multiline,
|
205
|
+
})}
|
194
206
|
>
|
195
207
|
${this.expandable
|
196
|
-
|
208
|
+
? html` <nile-icon
|
197
209
|
name="expand-2"
|
198
210
|
class="code-editor__icon__container"
|
199
211
|
size="16"
|
200
212
|
color="black"
|
201
213
|
@click="${(e: CustomEvent) => this.expandCodeEditor()}"
|
202
214
|
></nile-icon>`
|
203
|
-
|
215
|
+
: ''}
|
204
216
|
</div>
|
205
217
|
${hasErrorMessage
|
206
218
|
? html`
|
@@ -22,7 +22,7 @@ export const styles = css`
|
|
22
22
|
|
23
23
|
.horizontal {
|
24
24
|
height: 2px;
|
25
|
-
width: 100%;
|
25
|
+
/* width: 100%; */
|
26
26
|
margin: 8px 0;
|
27
27
|
}
|
28
28
|
|
@@ -34,7 +34,7 @@ export const styles = css`
|
|
34
34
|
vertical-align: middle;
|
35
35
|
}
|
36
36
|
|
37
|
-
.inset {
|
37
|
+
.inset.horizontal {
|
38
38
|
margin-left: 72px;
|
39
39
|
}
|
40
40
|
`;
|
@@ -1,52 +1 @@
|
|
1
|
-
|
2
|
-
* Copyright Aquera Inc 2023
|
3
|
-
*
|
4
|
-
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*/
|
7
|
-
|
8
|
-
import {LitElement, html, property, CSSResultArray, TemplateResult} from 'lit-element';
|
9
|
-
import { customElement } from 'lit/decorators.js';
|
10
|
-
import {styles} from './nile-toolbar.css';
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Nile icon component.
|
14
|
-
*
|
15
|
-
* @tag nile-toolbar
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
@customElement('nile-toolbar')
|
19
|
-
export class NileToolbar extends LitElement {
|
20
|
-
|
21
|
-
/**
|
22
|
-
* The styles for Toolbar
|
23
|
-
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
24
|
-
*/
|
25
|
-
public static get styles(): CSSResultArray {
|
26
|
-
return [styles];
|
27
|
-
}
|
28
|
-
|
29
|
-
/* #endregion */
|
30
|
-
|
31
|
-
/* #region Methods */
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Render method
|
35
|
-
* @slot This is a slot test
|
36
|
-
*/
|
37
|
-
public render(): TemplateResult {
|
38
|
-
return html`
|
39
|
-
<slot> </slot>
|
40
|
-
`;
|
41
|
-
}
|
42
|
-
|
43
|
-
/* #endregion */
|
44
|
-
}
|
45
|
-
|
46
|
-
export default NileToolbar;
|
47
|
-
|
48
|
-
declare global {
|
49
|
-
interface HTMLElementTagNameMap {
|
50
|
-
'nile-toolbar': NileToolbar;
|
51
|
-
}
|
52
|
-
}
|
1
|
+
export { NileToolbar } from './nile-toolbar';
|
@@ -1,19 +1,35 @@
|
|
1
1
|
/**
|
2
|
-
* Copyright Aquera Inc 2023
|
3
|
-
*
|
4
|
-
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
6
|
-
*/
|
2
|
+
* Copyright Aquera Inc 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
7
|
|
8
|
-
import {css} from 'lit-element';
|
8
|
+
import { css } from 'lit-element';
|
9
9
|
|
10
10
|
/**
|
11
11
|
* Toolbar CSS
|
12
12
|
*/
|
13
13
|
export const styles = css`
|
14
|
-
|
14
|
+
:host {
|
15
|
+
display: block;
|
16
|
+
width: 100%;
|
17
|
+
}
|
15
18
|
|
16
|
-
|
19
|
+
.toolbar {
|
20
|
+
display: flex;
|
21
|
+
align-items: center;
|
22
|
+
justify-content: space-between;
|
23
|
+
padding: 0 16px;
|
24
|
+
box-sizing: border-box;
|
25
|
+
min-height: 64px;
|
26
|
+
line-height: var(--nile-toolbar-line-height);
|
27
|
+
font-weight: var(--nile-toolbar-font-weight);
|
28
|
+
font-family: var(--nile-font-family-sans-serif);
|
29
|
+
font-size: var(--nile-toolbar-font-size);
|
30
|
+
background-color: var(--nile-toolbar-background-color, #f5f5f5);
|
31
|
+
color: var(--nile-toolbar-text-color, rgba(0, 0, 0, 0.87));
|
32
|
+
}
|
17
33
|
`;
|
18
34
|
|
19
|
-
export default [styles];
|
35
|
+
export default [styles];
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { LitElement, html, property, CSSResultArray, TemplateResult } from 'lit-element';
|
9
|
+
import { customElement } from 'lit/decorators.js';
|
10
|
+
import { styles } from './nile-toolbar.css';
|
11
|
+
import NileElement from '../internal/nile-element';
|
12
|
+
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Nile toolbar component.
|
16
|
+
*
|
17
|
+
* @tag nile-toolbar
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
@customElement('nile-toolbar')
|
21
|
+
export class NileToolbar extends NileElement {
|
22
|
+
|
23
|
+
@property({ reflect: true }) color: string = ''
|
24
|
+
@property({ reflect: true }) background: string = ''
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The styles for nile-toolbar
|
28
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
29
|
+
*/
|
30
|
+
public static get styles(): CSSResultArray {
|
31
|
+
return [styles];
|
32
|
+
}
|
33
|
+
|
34
|
+
/* #endregion */
|
35
|
+
|
36
|
+
/* #region Methods */
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Render method
|
40
|
+
* @slot This is a slot test
|
41
|
+
*/
|
42
|
+
public render(): TemplateResult {
|
43
|
+
return html`
|
44
|
+
<div class="toolbar" part="nile-toolbar" style="${this.color ? 'color:' + this.color + ';' : ''} ${this.background ? 'background:' + this.background + ';' : ''}">
|
45
|
+
<slot name="start"></slot>
|
46
|
+
<div class="toolbar-content" part="toolbar-mid">
|
47
|
+
<slot></slot>
|
48
|
+
</div>
|
49
|
+
<slot name="end"></slot>
|
50
|
+
</div>
|
51
|
+
`;
|
52
|
+
}
|
53
|
+
|
54
|
+
/* #endregion */
|
55
|
+
}
|
56
|
+
|
57
|
+
export default NileToolbar;
|
58
|
+
|
59
|
+
declare global {
|
60
|
+
interface HTMLElementTagNameMap {
|
61
|
+
'nile-toolbar': NileToolbar;
|
62
|
+
}
|
63
|
+
}
|