@aquera/nile-elements 0.0.35 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js +5 -5
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.d.ts +4 -2
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +64 -30
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.d.ts +9 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js +10 -0
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/theme.js.map +1 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +13 -0
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +4 -2
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/index.cjs.js +1 -1
  15. package/dist/index.esm.js +1 -1
  16. package/dist/index.iife.js +218 -200
  17. package/dist/nile-code-editor/index.cjs.js +1 -1
  18. package/dist/nile-code-editor/index.esm.js +1 -1
  19. package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
  20. package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
  21. package/dist/nile-code-editor/nile-code-editor.css.cjs.js +1 -1
  22. package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
  23. package/dist/nile-code-editor/nile-code-editor.css.esm.js +5 -5
  24. package/dist/nile-code-editor/nile-code-editor.esm.js +6 -3
  25. package/dist/nile-code-editor/theme.cjs.js +2 -0
  26. package/dist/nile-code-editor/theme.cjs.js.map +1 -0
  27. package/dist/nile-code-editor/theme.esm.js +1 -0
  28. package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
  29. package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
  30. package/dist/nile-switcher/nile-switcher.css.cjs.js +1 -1
  31. package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
  32. package/dist/nile-switcher/nile-switcher.css.esm.js +13 -0
  33. package/dist/nile-switcher/nile-switcher.esm.js +28 -26
  34. package/dist/src/nile-code-editor/nile-code-editor.css.js +5 -5
  35. package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
  36. package/dist/src/nile-code-editor/nile-code-editor.d.ts +4 -2
  37. package/dist/src/nile-code-editor/nile-code-editor.js +64 -30
  38. package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
  39. package/dist/src/nile-code-editor/theme.d.ts +9 -0
  40. package/dist/src/nile-code-editor/theme.js +10 -0
  41. package/dist/src/nile-code-editor/theme.js.map +1 -0
  42. package/dist/src/nile-switcher/nile-switcher.css.js +13 -0
  43. package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  44. package/dist/src/nile-switcher/nile-switcher.js +4 -2
  45. package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +1 -1
  48. package/src/nile-code-editor/nile-code-editor.css.ts +5 -5
  49. package/src/nile-code-editor/nile-code-editor.ts +68 -30
  50. package/src/nile-code-editor/theme.ts +9 -0
  51. package/src/nile-switcher/nile-switcher.css.ts +13 -0
  52. package/src/nile-switcher/nile-switcher.ts +4 -2
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.35",
6
+ "version": "0.0.36",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -19,7 +19,6 @@ export const styles = css`
19
19
  display: flex;
20
20
  justify-content: flex-end;
21
21
  flex-direction: row-reverse;
22
- gap: 0.6rem;
23
22
  }
24
23
 
25
24
  .cm-editor {
@@ -33,11 +32,12 @@ export const styles = css`
33
32
  }
34
33
 
35
34
  .code-editor__icon__container {
36
- cursor: pointer;
35
+ display: none;
37
36
  }
38
-
39
- .code-editor__icon__container {
40
- padding-right: 5px;
37
+ .code-mirror:hover > .code-editor__icon__container {
38
+ cursor: pointer;
39
+ display: flex;
40
+ padding-right: 10px;
41
41
  }
42
42
  `;
43
43
 
@@ -11,6 +11,7 @@ import {
11
11
  property,
12
12
  CSSResultArray,
13
13
  TemplateResult,
14
+ PropertyValueMap,
14
15
  } from 'lit-element';
15
16
  import { customElement, query } from 'lit/decorators.js';
16
17
  import { styles } from './nile-code-editor.css';
@@ -27,6 +28,10 @@ import { autocompletion } from '@codemirror/autocomplete';
27
28
  import { CompletionContext, Completion } from '@codemirror/autocomplete';
28
29
  import NileElement from '../internal/nile-element';
29
30
  import { basicSetup } from './extensionSetup';
31
+ import { watch } from '../internal/watch';
32
+ import { PropertyValues } from 'lit';
33
+ import { classMap } from 'lit/directives/class-map.js';
34
+ import { Theme } from './theme';
30
35
 
31
36
  // Choose the appropriate mode for your use case
32
37
 
@@ -42,7 +47,6 @@ export class NileCodeEditor extends NileElement {
42
47
  @property({ type: Boolean }) multiline: true;
43
48
  @property({ type: String }) value: true;
44
49
  @property({ type: String }) customOptions: any;
45
- @property({ type: String }) showLineNumbers: any;
46
50
 
47
51
  /**
48
52
  * The styles for CodeEditor
@@ -64,33 +68,61 @@ export class NileCodeEditor extends NileElement {
64
68
  }
65
69
  lineNumbersComp = new Compartment();
66
70
 
67
- updated() {
68
- const customAutoCompletions = javascriptLanguage.data.of({
69
- autocomplete: scopeCompletionSource(this.customOptions),
70
- });
71
- let startState = EditorState.create({
72
- doc: !this.multiline ? this.convertToSingleLine(this.value) : this.value,
73
- extensions: [
74
- basicSetup({
75
- lineNumbers: !!this.showLineNumbers,
76
- foldGutter: !this.multiline ? false : true,
77
- }),
78
- customAutoCompletions,
79
- autocompletion(),
80
- javascript(),
81
- !this.multiline ? this.restrictSingleLine() : [],
82
- EditorView.updateListener.of((v: ViewUpdate) => {
83
- if (v.docChanged) {
84
- this.emitValues(this.view.state.doc.toString());
85
- }
86
- }),
87
- ],
88
- });
89
-
90
- this.view = new EditorView({
91
- state: startState,
92
- parent: this.codeEditor,
93
- });
71
+ @watch(['value'], { waitUntilFirstUpdate: true })
72
+ handleValueChange() {}
73
+
74
+ updated(changedProperties: PropertyValues) {
75
+ super.updated(changedProperties);
76
+
77
+ if (changedProperties.has('value')) {
78
+ const customAutoCompletions = javascriptLanguage.data.of({
79
+ autocomplete: scopeCompletionSource(this.customOptions),
80
+ });
81
+ if (!this.view) {
82
+ let startState = EditorState.create({
83
+ doc: !this.multiline
84
+ ? this.convertToSingleLine(this.value)
85
+ : this.value,
86
+ extensions: [
87
+ basicSetup({
88
+ lineNumbers: !!this.multiline,
89
+ highlightActiveLine: false,
90
+ foldGutter: !!this.multiline,
91
+ }),
92
+ customAutoCompletions,
93
+ autocompletion(),
94
+ javascript(),
95
+ //this.setTheme(),
96
+ !this.multiline ? this.restrictSingleLine() : [],
97
+ EditorView.updateListener.of((v: ViewUpdate) => {
98
+ if (v.docChanged) {
99
+ this.emitValues(this.view.state.doc.toString());
100
+ }
101
+ }),
102
+ ],
103
+ });
104
+
105
+ this.view = new EditorView({
106
+ state: startState,
107
+ parent: this.codeEditor,
108
+ });
109
+ } else {
110
+ // Editor has already been initialized, update its state
111
+ this.view.dispatch({
112
+ changes: {
113
+ from: 0,
114
+ to: this.view.state.doc.length,
115
+ insert: !this.multiline
116
+ ? this.convertToSingleLine(this.value)
117
+ : this.value,
118
+ },
119
+ });
120
+ }
121
+ }
122
+ }
123
+
124
+ setTheme() {
125
+ return EditorView.theme(Theme);
94
126
  }
95
127
 
96
128
  emitValues(value: string) {
@@ -107,9 +139,15 @@ export class NileCodeEditor extends NileElement {
107
139
  );
108
140
  }
109
141
  public render(): TemplateResult {
110
- return html`<div class="code-mirror">
142
+ return html`<div
143
+ part="base"
144
+ class=${classMap({
145
+ 'code-mirror': true,
146
+ 'code-mirror__singleline': !this.multiline,
147
+ })}
148
+ >
111
149
  ${!this.multiline
112
- ? html`<nile-icon
150
+ ? html` <nile-icon
113
151
  name="fullscreenshrink"
114
152
  class="code-editor__icon__container"
115
153
  size="16"
@@ -0,0 +1,9 @@
1
+ export const Theme = {
2
+ '&': {
3
+ fontSize: '14px',
4
+ fontFamily: 'Colfax-regular',
5
+ fontWeight: '400',
6
+ },
7
+ '.cm-content': {},
8
+ '.cm-scroller': {},
9
+ };
@@ -16,6 +16,10 @@ export const styles = css`
16
16
  box-sizing: border-box;
17
17
  }
18
18
 
19
+ .pointer-cursor {
20
+ cursor: pointer;
21
+ }
22
+
19
23
  .switcher__label {
20
24
  display: flex;
21
25
  align-items: center;
@@ -29,6 +33,9 @@ export const styles = css`
29
33
  letter-spacing: 0.2px;
30
34
  }
31
35
 
36
+ switcher-object-mapper:hover {
37
+ display: flex;
38
+ }
32
39
  .switcher-icon-container.current {
33
40
  background: var(--nile-colors-blue-400);
34
41
  }
@@ -91,6 +98,12 @@ export const styles = css`
91
98
  border: none;
92
99
  }
93
100
 
101
+ .switcher-object-mapper-icon {
102
+ display: none;
103
+ }
104
+ .switcher-object-mapper:hover > .switcher-object-mapper-icon {
105
+ display: block;
106
+ }
94
107
  .switcher-object-mapper::part(input) {
95
108
  color: var(--nile-colors-primary-600);
96
109
  cursor: pointer;
@@ -177,6 +177,7 @@ export class NileSwitcher extends NileElement {
177
177
  } = Input;
178
178
 
179
179
  return html`<nile-select
180
+ part="dropdown"
180
181
  class="switcher-dropdown"
181
182
  .placeholder=${placeholder}
182
183
  .disabled="${disabled}"
@@ -276,7 +277,7 @@ export class NileSwitcher extends NileElement {
276
277
  const value =
277
278
  this.currentInput.mode === MODE.CREATE
278
279
  ? 'Click to Create - Not Mapped'
279
- : '';
280
+ : 'Click to Edit';
280
281
 
281
282
  return html`<nile-input
282
283
  class=${classMap({
@@ -312,6 +313,7 @@ export class NileSwitcher extends NileElement {
312
313
  noborder,
313
314
  } = Input;
314
315
  return html`<nile-code-editor
316
+ part="code-editor"
315
317
  class=${classMap({
316
318
  'code-editor': true,
317
319
  'code-editor__no-border': !!noborder,
@@ -323,7 +325,6 @@ export class NileSwitcher extends NileElement {
323
325
  .multiline="${multiLine}"
324
326
  .value="${value}"
325
327
  .customOptions="${customAutoCompletions}"
326
- .showLineNumbers="false"
327
328
  ></nile-code-editor> `;
328
329
  }
329
330
 
@@ -438,6 +439,7 @@ export class NileSwitcher extends NileElement {
438
439
  const hasLabelSlot = this.hasSlotController.test('label');
439
440
  const align = this.nileSwitchConfig.align;
440
441
  return html`<div
442
+ part="base"
441
443
  class=${classMap({
442
444
  'switcher-block': align === POSITIONS.BLOCK,
443
445
  'switcher-inline': align === POSITIONS.INLINE,