@aquera/nile-elements 0.0.89 → 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.
Files changed (46) hide show
  1. package/README.md +7 -0
  2. package/demo/variables.css +6 -0
  3. package/demo/variables_v2.css +6 -0
  4. package/dist/index.cjs.js +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.iife.js +249 -221
  7. package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
  8. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  9. package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
  10. package/dist/nile-divider/nile-divider.css.cjs.js +1 -1
  11. package/dist/nile-divider/nile-divider.css.cjs.js.map +1 -1
  12. package/dist/nile-divider/nile-divider.css.esm.js +2 -2
  13. package/dist/nile-toolbar/index.cjs.js +1 -1
  14. package/dist/nile-toolbar/index.cjs.js.map +1 -1
  15. package/dist/nile-toolbar/index.esm.js +1 -3
  16. package/dist/nile-toolbar/nile-toolbar.cjs.js +2 -0
  17. package/dist/nile-toolbar/nile-toolbar.cjs.js.map +1 -0
  18. package/dist/nile-toolbar/nile-toolbar.css.cjs.js +1 -1
  19. package/dist/nile-toolbar/nile-toolbar.css.cjs.js.map +1 -1
  20. package/dist/nile-toolbar/nile-toolbar.css.esm.js +20 -4
  21. package/dist/nile-toolbar/nile-toolbar.esm.js +9 -0
  22. package/dist/src/index.d.ts +1 -0
  23. package/dist/src/index.js +1 -0
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/nile-code-editor/nile-code-editor.d.ts +6 -7
  26. package/dist/src/nile-code-editor/nile-code-editor.js +11 -9
  27. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  28. package/dist/src/nile-divider/nile-divider.css.js +2 -2
  29. package/dist/src/nile-divider/nile-divider.css.js.map +1 -1
  30. package/dist/src/nile-toolbar/index.d.ts +1 -31
  31. package/dist/src/nile-toolbar/index.js +1 -41
  32. package/dist/src/nile-toolbar/index.js.map +1 -1
  33. package/dist/src/nile-toolbar/nile-toolbar.css.d.ts +5 -5
  34. package/dist/src/nile-toolbar/nile-toolbar.css.js +23 -7
  35. package/dist/src/nile-toolbar/nile-toolbar.css.js.map +1 -1
  36. package/dist/src/nile-toolbar/nile-toolbar.d.ts +34 -0
  37. package/dist/src/nile-toolbar/nile-toolbar.js +61 -0
  38. package/dist/src/nile-toolbar/nile-toolbar.js.map +1 -0
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +5 -2
  41. package/src/index.ts +2 -0
  42. package/src/nile-code-editor/nile-code-editor.ts +41 -30
  43. package/src/nile-divider/nile-divider.css.ts +2 -2
  44. package/src/nile-toolbar/index.ts +1 -52
  45. package/src/nile-toolbar/nile-toolbar.css.ts +25 -9
  46. 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.89",
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
@@ -72,3 +72,5 @@ export { NileList } from './nile-list';
72
72
  export { NileDetail } from './nile-detail';
73
73
  export { NileDivider } from './nile-divider';
74
74
  export { NileTitle } from './nile-title';
75
+
76
+ export { NileToolbar } from './nile-toolbar';
@@ -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
- @property({ type: Boolean, reflect: true }) multiline = false;
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: Boolean }) expandable: any = false;
57
- @property({ type: Boolean, reflect:true }) readonly: boolean = false;
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,13 +88,13 @@ export class NileCodeEditor extends NileElement {
78
88
  public view: EditorView;
79
89
 
80
90
  convertToSingleLine(code: any) {
81
- if(!code) return '';
91
+ if (!code) return '';
82
92
  // Remove line breaks and unnecessary whitespace
83
93
  return code.replace(/\s+/g, ' ').trim();
84
94
  }
85
- lineNumbersComp = new Compartment();
86
- restrictSingleLineComp = new Compartment();
87
- readOnlyComp = new Compartment();
95
+ private lineNumbersComp = new Compartment();
96
+ private restrictSingleLineComp = new Compartment();
97
+ private readOnlyComp = new Compartment();
88
98
 
89
99
  getLineNumbersExension() {
90
100
  return this.multiline ? lineNumbers() : [];
@@ -94,8 +104,8 @@ export class NileCodeEditor extends NileElement {
94
104
  return EditorState.readOnly.of(this.readonly);
95
105
  }
96
106
 
97
- getSingleLineExtension(){
98
- return !this.multiline ? EditorState.transactionFilter.of(tr =>
107
+ getSingleLineExtension() {
108
+ return !this.multiline ? EditorState.transactionFilter.of(tr =>
99
109
  tr.newDoc.lines > 1 ? [] : tr
100
110
  ) : [];
101
111
  }
@@ -107,6 +117,7 @@ export class NileCodeEditor extends NileElement {
107
117
  const customAutoCompletions = javascriptLanguage.data.of({
108
118
  autocomplete: scopeCompletionSource(this.customAutoCompletions),
109
119
  });
120
+ const language = this.language == "sql" ? sql() : javascript()
110
121
  let startState = EditorState.create({
111
122
  doc: !this.multiline
112
123
  ? this.convertToSingleLine(this.value)
@@ -121,7 +132,7 @@ export class NileCodeEditor extends NileElement {
121
132
  restrictSingleLineExtension,
122
133
  customAutoCompletions,
123
134
  autocompletion(),
124
- javascript(),
135
+ language,
125
136
  EditorView.theme(Theme),
126
137
  EditorView.updateListener.of((v: ViewUpdate) => {
127
138
  if (v.docChanged) {
@@ -142,7 +153,7 @@ export class NileCodeEditor extends NileElement {
142
153
  }
143
154
 
144
155
  singleLineMultiLineToggle() {
145
- this.view.dispatch({
156
+ this.view.dispatch({
146
157
  changes: {
147
158
  from: 0,
148
159
  to: this.view.state.doc.length,
@@ -152,22 +163,22 @@ export class NileCodeEditor extends NileElement {
152
163
  },
153
164
  });
154
165
  }
155
-
166
+
156
167
  updated(changedProperties: PropertyValues) {
157
168
  super.updated(changedProperties);
158
- if (changedProperties.has('value') && this.updateValue) {
159
- // Editor has already been initialized, update its state
160
- this.singleLineMultiLineToggle();
161
- }
169
+ if (changedProperties.has('value')) {
170
+ // Editor has already been initialized, update its state
171
+ this.singleLineMultiLineToggle();
172
+ }
162
173
  if (changedProperties.has('multiline')) {
163
174
  this.view.dispatch({
164
175
  effects: [this.lineNumbersComp.reconfigure(this.getLineNumbersExension()),
165
- this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())],
176
+ this.restrictSingleLineComp.reconfigure(this.getSingleLineExtension())],
166
177
  })
167
178
  this.singleLineMultiLineToggle();
168
179
  }
169
180
  if (changedProperties.has('readonly')) {
170
- this.view.dispatch({ effects: this.readOnlyComp.reconfigure(this.getReadOnlyExtension()) })
181
+ this.view.dispatch({ effects: this.readOnlyComp.reconfigure(this.getReadOnlyExtension()) })
171
182
  }
172
183
  }
173
184
 
@@ -187,21 +198,21 @@ export class NileCodeEditor extends NileElement {
187
198
  return html`<div
188
199
  part="code-editor-base"
189
200
  class=${classMap({
190
- 'code-mirror': true,
191
- noborder: noborder,
192
- error: hasError || hasErrorMessage,
193
- 'code-mirror__singleline': !this.multiline,
194
- })}
201
+ 'code-mirror': true,
202
+ noborder: noborder,
203
+ error: hasError || hasErrorMessage,
204
+ 'code-mirror__singleline': !this.multiline,
205
+ })}
195
206
  >
196
207
  ${this.expandable
197
- ? html` <nile-icon
208
+ ? html` <nile-icon
198
209
  name="expand-2"
199
210
  class="code-editor__icon__container"
200
211
  size="16"
201
212
  color="black"
202
213
  @click="${(e: CustomEvent) => this.expandCodeEditor()}"
203
214
  ></nile-icon>`
204
- : ''}
215
+ : ''}
205
216
  </div>
206
217
  ${hasErrorMessage
207
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
- :host {
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
+ }