@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
package/package.json
CHANGED
@@ -19,7 +19,13 @@ export const styles = css`
|
|
19
19
|
display: flex;
|
20
20
|
justify-content: flex-end;
|
21
21
|
flex-direction: row-reverse;
|
22
|
-
|
22
|
+
padding: 5px;
|
23
|
+
border-radius: 5px;
|
24
|
+
border: 1px solid rgb(204, 204, 204);
|
25
|
+
}
|
26
|
+
|
27
|
+
.error {
|
28
|
+
border-color: #e5434d;
|
23
29
|
}
|
24
30
|
|
25
31
|
.cm-editor {
|
@@ -33,11 +39,12 @@ export const styles = css`
|
|
33
39
|
}
|
34
40
|
|
35
41
|
.code-editor__icon__container {
|
36
|
-
|
42
|
+
display: none;
|
37
43
|
}
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
.code-mirror:hover > .code-editor__icon__container {
|
45
|
+
cursor: pointer;
|
46
|
+
display: flex;
|
47
|
+
padding-right: 10px;
|
41
48
|
}
|
42
49
|
`;
|
43
50
|
|
@@ -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
|
|
@@ -39,10 +44,12 @@ import { basicSetup } from './extensionSetup';
|
|
39
44
|
@customElement('nile-code-editor')
|
40
45
|
export class NileCodeEditor extends NileElement {
|
41
46
|
@query('.code-mirror') codeEditor: HTMLInputElement;
|
42
|
-
@property({ type: Boolean }) multiline
|
43
|
-
@property({ type: String }) value
|
44
|
-
@property({ type: String }) customOptions: any;
|
45
|
-
@property({ type:
|
47
|
+
@property({ type: Boolean, reflect: true }) multiline = false;
|
48
|
+
@property({ type: String }) value = '';
|
49
|
+
@property({ type: String }) customOptions: any = {};
|
50
|
+
@property({ type: Boolean }) updateValue: any = false;
|
51
|
+
@property({ attribute: 'error-message' }) errorMessage = '';
|
52
|
+
@property({ attribute: 'error' }) error = false;
|
46
53
|
|
47
54
|
/**
|
48
55
|
* The styles for CodeEditor
|
@@ -64,33 +71,61 @@ export class NileCodeEditor extends NileElement {
|
|
64
71
|
}
|
65
72
|
lineNumbersComp = new Compartment();
|
66
73
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
74
|
+
@watch(['value'], { waitUntilFirstUpdate: true })
|
75
|
+
handleValueChange() {}
|
76
|
+
|
77
|
+
firstUpdated(changedProperties: PropertyValues) {
|
78
|
+
super.updated(changedProperties);
|
79
|
+
if (changedProperties.has('value')) {
|
80
|
+
const customAutoCompletions = javascriptLanguage.data.of({
|
81
|
+
autocomplete: scopeCompletionSource(this.customOptions),
|
82
|
+
});
|
83
|
+
if (!this.view) {
|
84
|
+
let startState = EditorState.create({
|
85
|
+
doc: !this.multiline
|
86
|
+
? this.convertToSingleLine(this.value)
|
87
|
+
: this.value,
|
88
|
+
extensions: [
|
89
|
+
basicSetup({
|
90
|
+
lineNumbers: !!this.multiline,
|
91
|
+
highlightActiveLine: false,
|
92
|
+
foldGutter: !!this.multiline,
|
93
|
+
}),
|
94
|
+
customAutoCompletions,
|
95
|
+
autocompletion(),
|
96
|
+
javascript(),
|
97
|
+
this.setTheme(),
|
98
|
+
!this.multiline ? this.restrictSingleLine() : [],
|
99
|
+
EditorView.updateListener.of((v: ViewUpdate) => {
|
100
|
+
if (v.docChanged) {
|
101
|
+
this.emitValues(this.view.state.doc.toString());
|
102
|
+
}
|
103
|
+
}),
|
104
|
+
],
|
105
|
+
});
|
106
|
+
|
107
|
+
this.view = new EditorView({
|
108
|
+
state: startState,
|
109
|
+
parent: this.codeEditor,
|
110
|
+
});
|
111
|
+
} else {
|
112
|
+
// Editor has already been initialized, update its state
|
113
|
+
this.view.dispatch({
|
114
|
+
changes: {
|
115
|
+
from: 0,
|
116
|
+
to: this.view.state.doc.length,
|
117
|
+
insert: !this.multiline
|
118
|
+
? this.convertToSingleLine(this.value)
|
119
|
+
: this.value,
|
120
|
+
},
|
121
|
+
});
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
setTheme() {
|
128
|
+
return EditorView.theme(Theme);
|
94
129
|
}
|
95
130
|
|
96
131
|
emitValues(value: string) {
|
@@ -107,17 +142,33 @@ export class NileCodeEditor extends NileElement {
|
|
107
142
|
);
|
108
143
|
}
|
109
144
|
public render(): TemplateResult {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
145
|
+
const hasErrorMessage = !!this.errorMessage;
|
146
|
+
const hasError = !!this.error;
|
147
|
+
return html`<div
|
148
|
+
part="code-editor-base"
|
149
|
+
class=${classMap({
|
150
|
+
'code-mirror': true,
|
151
|
+
error: hasError || hasErrorMessage,
|
152
|
+
'code-mirror__singleline': !this.multiline,
|
153
|
+
})}
|
154
|
+
>
|
155
|
+
${!this.multiline
|
156
|
+
? html` <nile-icon
|
157
|
+
name="fullscreenshrink"
|
158
|
+
class="code-editor__icon__container"
|
159
|
+
size="16"
|
160
|
+
color="black"
|
161
|
+
@click="${(e: CustomEvent) => this.expandCodeEditor()}"
|
162
|
+
></nile-icon>`
|
163
|
+
: ''}
|
164
|
+
</div>
|
165
|
+
${hasErrorMessage
|
166
|
+
? html`
|
167
|
+
<nile-form-error-message
|
168
|
+
>${this.errorMessage}</nile-form-error-message
|
169
|
+
>
|
170
|
+
`
|
171
|
+
: ``}`;
|
121
172
|
}
|
122
173
|
|
123
174
|
/* #endregion */
|
@@ -16,22 +16,31 @@ export const styles = css`
|
|
16
16
|
box-sizing: border-box;
|
17
17
|
}
|
18
18
|
|
19
|
-
.
|
19
|
+
.pointer-cursor {
|
20
20
|
cursor: pointer;
|
21
|
-
|
21
|
+
}
|
22
|
+
|
23
|
+
.switcher__label {
|
22
24
|
display: flex;
|
23
25
|
align-items: center;
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
color: inherit;
|
27
|
+
color: var(--nile-colors-dark-900);
|
28
|
+
font-family: Colfax-regular;
|
29
|
+
font-size: 14px;
|
30
|
+
font-style: normal;
|
31
|
+
font-weight: 400;
|
32
|
+
line-height: 14px;
|
33
|
+
letter-spacing: 0.2px;
|
28
34
|
}
|
29
35
|
|
36
|
+
switcher-object-mapper:hover {
|
37
|
+
display: flex;
|
38
|
+
}
|
30
39
|
.switcher-icon-container.current {
|
31
40
|
background: var(--nile-colors-blue-400);
|
32
41
|
}
|
33
42
|
|
34
|
-
.switcher-
|
43
|
+
.switcher-container {
|
35
44
|
display: flex;
|
36
45
|
}
|
37
46
|
|
@@ -43,21 +52,36 @@ export const styles = css`
|
|
43
52
|
flex-direction: column;
|
44
53
|
}
|
45
54
|
|
46
|
-
.switcher-block > :first-child {
|
47
|
-
align-self: end;
|
48
|
-
}
|
49
|
-
|
50
55
|
.switcher-inline > :nth-child(2) {
|
51
56
|
flex: 1;
|
52
57
|
}
|
53
58
|
|
54
|
-
.switcher-
|
59
|
+
.switcher-icons-container {
|
55
60
|
display: flex;
|
61
|
+
margin-left: auto;
|
56
62
|
gap: 0.5rem;
|
57
63
|
max-height: 38px;
|
58
64
|
align-items: center;
|
59
65
|
}
|
60
66
|
|
67
|
+
.switcher-block > .switcher-icons-container {
|
68
|
+
margin-left: auto;
|
69
|
+
}
|
70
|
+
|
71
|
+
.label-container {
|
72
|
+
display: flex;
|
73
|
+
}
|
74
|
+
|
75
|
+
.switcher-icon-container {
|
76
|
+
cursor: pointer;
|
77
|
+
justify-content: center;
|
78
|
+
display: flex;
|
79
|
+
align-items: center;
|
80
|
+
margin-bottom: 6px;
|
81
|
+
height: 28px;
|
82
|
+
width: 28px;
|
83
|
+
border-radius: 4px;
|
84
|
+
}
|
61
85
|
nile-radio {
|
62
86
|
display: inline-block;
|
63
87
|
padding-right: 10px;
|
@@ -65,15 +89,14 @@ export const styles = css`
|
|
65
89
|
|
66
90
|
nile-code-editor {
|
67
91
|
overflow: hidden;
|
68
|
-
padding-top: 2px;
|
69
|
-
border-radius: 5px;
|
70
|
-
border: 1px solid rgb(204, 204, 204);
|
71
92
|
}
|
72
93
|
|
73
|
-
.
|
74
|
-
|
94
|
+
.switcher-object-mapper-icon {
|
95
|
+
display: none;
|
96
|
+
}
|
97
|
+
.switcher-object-mapper:hover > .switcher-object-mapper-icon {
|
98
|
+
display: block;
|
75
99
|
}
|
76
|
-
|
77
100
|
.switcher-object-mapper::part(input) {
|
78
101
|
color: var(--nile-colors-primary-600);
|
79
102
|
cursor: pointer;
|
@@ -14,6 +14,7 @@ import { choose } from 'lit/directives/choose.js';
|
|
14
14
|
import { classMap } from 'lit/directives/class-map.js';
|
15
15
|
import { repeat } from 'lit/directives/repeat.js';
|
16
16
|
import { watch } from '../internal/watch';
|
17
|
+
import { HasSlotController } from '../internal/slot';
|
17
18
|
|
18
19
|
/**
|
19
20
|
* @summary Allows you to switch between nile elements
|
@@ -101,8 +102,10 @@ export class NileSwitcher extends NileElement {
|
|
101
102
|
*/
|
102
103
|
static styles: CSSResultGroup = styles;
|
103
104
|
|
105
|
+
private readonly hasSlotController = new HasSlotController(this, 'label');
|
106
|
+
|
104
107
|
@property({ type: Object }) nileSwitchConfig: switchconfig;
|
105
|
-
@property({ type: Number }) current: Number =
|
108
|
+
@property({ type: Number }) current: Number = 1;
|
106
109
|
|
107
110
|
@property({ type: Object }) currentInput: switchInputType;
|
108
111
|
|
@@ -173,6 +176,7 @@ export class NileSwitcher extends NileElement {
|
|
173
176
|
} = Input;
|
174
177
|
|
175
178
|
return html`<nile-select
|
179
|
+
part="dropdown"
|
176
180
|
class="switcher-dropdown"
|
177
181
|
.placeholder=${placeholder}
|
178
182
|
.disabled="${disabled}"
|
@@ -272,7 +276,7 @@ export class NileSwitcher extends NileElement {
|
|
272
276
|
const value =
|
273
277
|
this.currentInput.mode === MODE.CREATE
|
274
278
|
? 'Click to Create - Not Mapped'
|
275
|
-
: '';
|
279
|
+
: 'Click to Edit';
|
276
280
|
|
277
281
|
return html`<nile-input
|
278
282
|
class=${classMap({
|
@@ -308,9 +312,9 @@ export class NileSwitcher extends NileElement {
|
|
308
312
|
noborder,
|
309
313
|
} = Input;
|
310
314
|
return html`<nile-code-editor
|
315
|
+
part="switcher-code-editor"
|
311
316
|
class=${classMap({
|
312
317
|
'code-editor': true,
|
313
|
-
'code-editor__no-border': !!noborder,
|
314
318
|
})}
|
315
319
|
@nile-expand="${(e: CustomEvent) =>
|
316
320
|
this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
@@ -319,7 +323,6 @@ export class NileSwitcher extends NileElement {
|
|
319
323
|
.multiline="${multiLine}"
|
320
324
|
.value="${value}"
|
321
325
|
.customOptions="${customAutoCompletions}"
|
322
|
-
.showLineNumbers="false"
|
323
326
|
></nile-code-editor> `;
|
324
327
|
}
|
325
328
|
|
@@ -352,7 +355,7 @@ export class NileSwitcher extends NileElement {
|
|
352
355
|
this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';
|
353
356
|
|
354
357
|
return html`
|
355
|
-
<div class="switcher-icons-container">
|
358
|
+
<div part="icons-container" class="switcher-icons-container">
|
356
359
|
${repeat(
|
357
360
|
inputs,
|
358
361
|
(input: any, index: number) => html` <nile-tooltip
|
@@ -383,9 +386,19 @@ export class NileSwitcher extends NileElement {
|
|
383
386
|
`;
|
384
387
|
}
|
385
388
|
|
389
|
+
isToggleSwitch = (item: any) => {
|
390
|
+
return typeof item === 'undefined' || item;
|
391
|
+
};
|
392
|
+
|
386
393
|
toggleField(currentInput: switchInputType, index: Number) {
|
387
|
-
this.
|
388
|
-
|
394
|
+
if (this.isToggleSwitch(this.nileSwitchConfig.confirmation)) {
|
395
|
+
this.current = index;
|
396
|
+
}
|
397
|
+
this.updateComplete.then(res => {
|
398
|
+
if (res) {
|
399
|
+
this.emit('nile-switch', { input: this.currentInput });
|
400
|
+
}
|
401
|
+
});
|
389
402
|
}
|
390
403
|
|
391
404
|
singleFieldSwitcher() {
|
@@ -429,15 +442,31 @@ export class NileSwitcher extends NileElement {
|
|
429
442
|
}
|
430
443
|
|
431
444
|
public render(): TemplateResult {
|
445
|
+
const hasLabelSlot = this.hasSlotController.test('label');
|
432
446
|
const align = this.nileSwitchConfig.align;
|
433
447
|
return html`<div
|
448
|
+
part="base"
|
434
449
|
class=${classMap({
|
435
450
|
'switcher-block': align === POSITIONS.BLOCK,
|
436
451
|
'switcher-inline': align === POSITIONS.INLINE,
|
437
|
-
'switcher-
|
452
|
+
'switcher-container': true,
|
438
453
|
})}
|
439
454
|
>
|
440
|
-
|
455
|
+
<div class="label-container">
|
456
|
+
${hasLabelSlot
|
457
|
+
? html`
|
458
|
+
<label
|
459
|
+
part="switcher-label"
|
460
|
+
class="switcher__label"
|
461
|
+
for="input"
|
462
|
+
>
|
463
|
+
<slot name="label"></slot>
|
464
|
+
</label>
|
465
|
+
</div> `
|
466
|
+
: ''}
|
467
|
+
${this.renderIcon()}
|
468
|
+
</div>
|
469
|
+
${this.singleFieldSwitcher()}
|
441
470
|
</div>`;
|
442
471
|
}
|
443
472
|
}
|