@aquera/nile-elements 0.0.21 → 0.0.22
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-content-editor/nile-content-editor.css.js +4 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.d.ts +8 -3
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js +58 -31
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +5 -9
- 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 +29 -15
- 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/src/nile-tab/nile-tab.css.js +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.iife.js +40 -35
- package/dist/nile-content-editor/nile-content-editor.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.esm.js +4 -2
- package/dist/nile-content-editor/nile-content-editor.esm.js +5 -5
- 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 +7 -11
- package/dist/nile-switcher/nile-switcher.esm.js +33 -26
- package/dist/nile-tab/nile-tab.css.cjs.js +1 -1
- package/dist/nile-tab/nile-tab.css.cjs.js.map +1 -1
- package/dist/nile-tab/nile-tab.css.esm.js +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.css.js +4 -2
- package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.d.ts +8 -3
- package/dist/src/nile-content-editor/nile-content-editor.js +58 -31
- package/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.css.js +5 -9
- 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 +29 -15
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/dist/src/nile-tab/nile-tab.css.js +1 -1
- package/dist/src/nile-tab/nile-tab.css.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-content-editor/nile-content-editor.css.ts +4 -2
- package/src/nile-content-editor/nile-content-editor.ts +74 -39
- package/src/nile-switcher/nile-switcher.css.ts +5 -9
- package/src/nile-switcher/nile-switcher.ts +46 -22
- package/src/nile-tab/nile-tab.css.ts +1 -1
package/package.json
CHANGED
@@ -12,7 +12,6 @@ import { css } from 'lit-element';
|
|
12
12
|
*/
|
13
13
|
export const styles = css`
|
14
14
|
:host {
|
15
|
-
width: 100%;
|
16
15
|
box-sizing: border-box;
|
17
16
|
font-size: 14px;
|
18
17
|
}
|
@@ -25,7 +24,7 @@ export const styles = css`
|
|
25
24
|
|
26
25
|
.dropdown-position {
|
27
26
|
position: relative;
|
28
|
-
bottom:
|
27
|
+
bottom: 1px;
|
29
28
|
}
|
30
29
|
.content-editable-input {
|
31
30
|
box-sizing: border-box;
|
@@ -33,6 +32,7 @@ export const styles = css`
|
|
33
32
|
padding: 9px;
|
34
33
|
border: 1px solid #c7ced4;
|
35
34
|
border-radius: 4px;
|
35
|
+
overflow: auto;
|
36
36
|
overflow-x: auto;
|
37
37
|
overflow-anchor: none;
|
38
38
|
scrollbar-width: none;
|
@@ -51,6 +51,8 @@ export const styles = css`
|
|
51
51
|
}
|
52
52
|
|
53
53
|
.read-only {
|
54
|
+
background-color: hsl(240 4.8% 95.9%);
|
55
|
+
opacity: 0.5;
|
54
56
|
cursor: not-allowed;
|
55
57
|
}
|
56
58
|
|
@@ -63,6 +63,8 @@ export class NileContentEditor extends NileElement {
|
|
63
63
|
@property({ attribute: 'error' }) error = false;
|
64
64
|
@property({ attribute: 'noborder' }) noborder = false;
|
65
65
|
|
66
|
+
@state() initialValue = '';
|
67
|
+
|
66
68
|
static styles: CSSResultGroup = styles;
|
67
69
|
|
68
70
|
connectedCallback() {
|
@@ -74,17 +76,8 @@ export class NileContentEditor extends NileElement {
|
|
74
76
|
this.setInitialValues();
|
75
77
|
}
|
76
78
|
|
77
|
-
setInitialValues() {
|
78
|
-
this.updateComplete.then(res => {
|
79
|
-
if (res && !!this.value)
|
80
|
-
this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(
|
81
|
-
this.value
|
82
|
-
);
|
83
|
-
});
|
84
|
-
}
|
85
|
-
|
86
79
|
addOpenListeners() {
|
87
|
-
|
80
|
+
window.addEventListener('click', this.handleOutsideClick);
|
88
81
|
this.addEventListener('cut', this.handleClipboardEvent);
|
89
82
|
this.addEventListener('copy', this.handleClipboardEvent);
|
90
83
|
this.addEventListener('paste', this.handleClipboardEvent);
|
@@ -97,6 +90,12 @@ export class NileContentEditor extends NileElement {
|
|
97
90
|
this.removeEventListener('paste', this.handleClipboardEvent);
|
98
91
|
}
|
99
92
|
|
93
|
+
handleOutsideClick(event: any) {
|
94
|
+
if (event && event.target && !this.contains(event.target)) {
|
95
|
+
this.toggleDropdown(false);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
100
99
|
async handleClipboardEvent(event: Event) {
|
101
100
|
const selectedText = window?.getSelection()?.toString();
|
102
101
|
switch (event.type) {
|
@@ -126,13 +125,16 @@ export class NileContentEditor extends NileElement {
|
|
126
125
|
this.openDropdown = value;
|
127
126
|
}
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
setInitialValues() {
|
129
|
+
this.updateComplete.then(res => {
|
130
|
+
if (res)
|
131
|
+
this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(
|
132
|
+
this.value
|
133
|
+
);
|
134
|
+
});
|
133
135
|
}
|
134
136
|
|
135
|
-
@watch(['type'], { waitUntilFirstUpdate: true })
|
137
|
+
@watch(['type', 'value'], { waitUntilFirstUpdate: true })
|
136
138
|
handleTypeChange() {
|
137
139
|
this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(this.value);
|
138
140
|
}
|
@@ -155,14 +157,6 @@ export class NileContentEditor extends NileElement {
|
|
155
157
|
return;
|
156
158
|
}
|
157
159
|
|
158
|
-
if (event.code === KeyCode.ARROW_RIGHT) {
|
159
|
-
this.contentEditor.focus();
|
160
|
-
// select all the content in the element
|
161
|
-
document.execCommand('selectAll', false, undefined);
|
162
|
-
// collapse selection to the end
|
163
|
-
|
164
|
-
document?.getSelection()?.collapseToEnd();
|
165
|
-
}
|
166
160
|
if (event.code === KeyCode.ESCAPE) {
|
167
161
|
event.preventDefault();
|
168
162
|
this.toggleDropdown(false);
|
@@ -194,9 +188,12 @@ export class NileContentEditor extends NileElement {
|
|
194
188
|
}
|
195
189
|
|
196
190
|
generateValuesFromHTMLTags(string: any): string {
|
191
|
+
let errorTag =
|
192
|
+
/<span class="chips chip-error" contenteditable="false">(.*?)<\/span>/g;
|
193
|
+
this.error = !!string.match(errorTag);
|
197
194
|
var pattern =
|
198
195
|
/<span class="chips(?: chip-error)?" contenteditable="false">(.*?)<\/span>/g;
|
199
|
-
|
196
|
+
let result = string.replace(pattern, (match: any, option: any) => {
|
200
197
|
return '{{' + option + '}}';
|
201
198
|
});
|
202
199
|
return result;
|
@@ -224,9 +221,6 @@ export class NileContentEditor extends NileElement {
|
|
224
221
|
emitInputChange(): void {
|
225
222
|
if (this.contentEditor) {
|
226
223
|
let fieldValue = this.contentEditor.innerHTML;
|
227
|
-
if (this.contentEditor.innerText !== '') {
|
228
|
-
fieldValue = this.generateValuesFromHTMLTags(fieldValue);
|
229
|
-
}
|
230
224
|
fieldValue = fieldValue.replace(/ /g, ' ');
|
231
225
|
fieldValue = fieldValue.replace('<br>', '');
|
232
226
|
this.emit('nile-change', {
|
@@ -235,7 +229,13 @@ export class NileContentEditor extends NileElement {
|
|
235
229
|
}
|
236
230
|
}
|
237
231
|
|
238
|
-
|
232
|
+
replaceText = '';
|
233
|
+
|
234
|
+
insertNodes(
|
235
|
+
parentNode: Node,
|
236
|
+
childNodes: NodeList,
|
237
|
+
autoOptionsTag?: HTMLElement
|
238
|
+
) {
|
239
239
|
[...childNodes].forEach((node: Node, index: number) => {
|
240
240
|
if (node.hasChildNodes()) {
|
241
241
|
if (autoOptionsTag) {
|
@@ -246,23 +246,54 @@ export class NileContentEditor extends NileElement {
|
|
246
246
|
} else {
|
247
247
|
if (node.nodeValue?.includes(this.tagIdentifier)) {
|
248
248
|
if (autoOptionsTag) {
|
249
|
-
|
250
|
-
this.tagIdentifier + this.filteredValue,
|
251
|
-
''
|
252
|
-
);
|
253
|
-
parentNode.childNodes[index].after(autoOptionsTag);
|
249
|
+
this.insertAutoOptionsTag(node, autoOptionsTag);
|
254
250
|
}
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
.slice(1)
|
259
|
-
.join() || '';
|
251
|
+
|
252
|
+
this.setFilterValue(node.nodeValue);
|
253
|
+
|
260
254
|
return;
|
261
255
|
}
|
262
256
|
}
|
263
257
|
});
|
264
258
|
}
|
265
259
|
|
260
|
+
insertAutoOptionsTag(node: any, autoOptionsTag: any) {
|
261
|
+
const selection = window.getSelection();
|
262
|
+
const range = document.createRange();
|
263
|
+
const curssorNodeindex = node.nodeValue.indexOf(this.tagIdentifier);
|
264
|
+
range.setStart(node, curssorNodeindex);
|
265
|
+
range.insertNode(autoOptionsTag);
|
266
|
+
range.setStartAfter(autoOptionsTag);
|
267
|
+
range.collapse(true);
|
268
|
+
selection?.removeAllRanges();
|
269
|
+
selection?.addRange(range);
|
270
|
+
|
271
|
+
if (autoOptionsTag.nextSibling?.nodeValue) {
|
272
|
+
autoOptionsTag.nextSibling.nodeValue =
|
273
|
+
autoOptionsTag.nextSibling?.nodeValue?.replace(
|
274
|
+
this.tagIdentifier + this.filteredValue,
|
275
|
+
''
|
276
|
+
);
|
277
|
+
}
|
278
|
+
this.contentEditor.focus();
|
279
|
+
}
|
280
|
+
|
281
|
+
setFilterValue(value: any) {
|
282
|
+
//replace Text - check if text exists after tagidentifier , if exists take account of that too
|
283
|
+
if (!this.openDropdown) {
|
284
|
+
this.replaceText = value.split(this.tagIdentifier).slice(1).join();
|
285
|
+
}
|
286
|
+
if (!!value && this.openDropdown) {
|
287
|
+
this.filteredValue = value
|
288
|
+
?.split(this.tagIdentifier)
|
289
|
+
.slice(1)
|
290
|
+
.join()
|
291
|
+
.replace(this.replaceText, '');
|
292
|
+
} else {
|
293
|
+
this.filteredValue = '';
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
266
297
|
handleOptions(option: any): void {
|
267
298
|
this.toggleDropdown(false);
|
268
299
|
let autoOptionsTag = document.createElement('span');
|
@@ -274,9 +305,13 @@ export class NileContentEditor extends NileElement {
|
|
274
305
|
this.contentEditor.childNodes,
|
275
306
|
autoOptionsTag
|
276
307
|
);
|
308
|
+
this.resetOptions();
|
309
|
+
this.emitInputChange();
|
310
|
+
}
|
311
|
+
|
312
|
+
resetOptions() {
|
277
313
|
this.filteredOptions = this.options;
|
278
314
|
this.filteredValue = '';
|
279
|
-
this.emitInputChange();
|
280
315
|
}
|
281
316
|
|
282
317
|
public renderAutoOptions(): TemplateResult {
|
@@ -12,8 +12,6 @@ import { css } from 'lit-element';
|
|
12
12
|
*/
|
13
13
|
export const styles = css`
|
14
14
|
:host {
|
15
|
-
display: inline-block;
|
16
|
-
width: 100%;
|
17
15
|
box-sizing: border-box;
|
18
16
|
}
|
19
17
|
|
@@ -25,15 +23,13 @@ export const styles = css`
|
|
25
23
|
gap: 0.5rem;
|
26
24
|
}
|
27
25
|
|
28
|
-
.
|
29
|
-
|
30
|
-
|
31
|
-
flex-shrink: 0;
|
26
|
+
.input-container > :first-child {
|
27
|
+
max-width: 99%;
|
28
|
+
min-width: 99%;
|
32
29
|
}
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
flex-shrink: 0;
|
31
|
+
nile-icon {
|
32
|
+
max-height: 38px;
|
37
33
|
}
|
38
34
|
|
39
35
|
nile-radio {
|
@@ -83,6 +83,8 @@ export class NileSwitcher extends NileElement {
|
|
83
83
|
static styles: CSSResultGroup = styles;
|
84
84
|
@property({ type: Object }) nileSwitchConfig: switchconfig;
|
85
85
|
|
86
|
+
@property() value: string;
|
87
|
+
|
86
88
|
connectedCallback() {
|
87
89
|
super.connectedCallback();
|
88
90
|
this.emit('nile-init');
|
@@ -124,12 +126,19 @@ export class NileSwitcher extends NileElement {
|
|
124
126
|
multiple,
|
125
127
|
placeholder,
|
126
128
|
disabled,
|
129
|
+
value,
|
130
|
+
error,
|
131
|
+
errorMessage,
|
127
132
|
inputType: inputTypeName,
|
128
133
|
} = Input;
|
134
|
+
|
129
135
|
return html`<nile-select
|
130
136
|
.placeholder=${placeholder}
|
131
137
|
.disabled="${disabled}"
|
132
138
|
.multiple="${multiple}"
|
139
|
+
.value="${value}"
|
140
|
+
.error="${error}"
|
141
|
+
.errorMessage="${errorMessage}"
|
133
142
|
@nile-change=${(e: CustomEvent) => {
|
134
143
|
this.handleChange(e, inputType, inputTypeName);
|
135
144
|
}}
|
@@ -166,35 +175,50 @@ export class NileSwitcher extends NileElement {
|
|
166
175
|
const { value, label, disabled, inputType: inputTypeName } = Input;
|
167
176
|
|
168
177
|
return html`<nile-checkbox
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
178
|
+
.checked=${value}
|
179
|
+
.label=${label}
|
180
|
+
.disabled=${disabled}
|
181
|
+
@valueChange=${(e: CustomEvent) => {
|
182
|
+
this.handleChange(e, inputType, inputTypeName);
|
183
|
+
}}
|
184
|
+
></nile-checkbox
|
185
|
+
>; `;
|
176
186
|
}
|
177
187
|
|
178
188
|
renderNileRadio(Input: switchInputType, inputType: string) {
|
179
|
-
const {
|
189
|
+
const {
|
190
|
+
options,
|
191
|
+
value,
|
192
|
+
disabled,
|
193
|
+
inputType: inputTypeName,
|
194
|
+
errorMessage,
|
195
|
+
} = Input;
|
196
|
+
|
197
|
+
const haserrorMessage = !!errorMessage;
|
180
198
|
|
181
199
|
return html`<nile-radio-group
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
200
|
+
.value=${value}
|
201
|
+
.disabled=${disabled}
|
202
|
+
@change=${(e: CustomEvent) => {
|
203
|
+
this.handleChange(e, inputType, inputTypeName);
|
204
|
+
}}
|
205
|
+
>
|
206
|
+
${options &&
|
207
|
+
options.map((option: any) => {
|
208
|
+
return html`<nile-radio .value="${option}">${option} </nile-radio>`;
|
209
|
+
})}
|
210
|
+
</nile-radio-group>
|
211
|
+
${haserrorMessage ? this.renderErrorMessage(errorMessage) : ''}`;
|
212
|
+
}
|
213
|
+
|
214
|
+
renderErrorMessage(errorMessage: string) {
|
215
|
+
return html`
|
216
|
+
<nile-form-error-message>${errorMessage}</nile-form-error-message>
|
217
|
+
`;
|
193
218
|
}
|
194
219
|
|
195
220
|
renderContentEditor(Input: switchInputType, inputType: string) {
|
196
|
-
|
197
|
-
value,
|
221
|
+
let {
|
198
222
|
options,
|
199
223
|
inputType: inputTypeName,
|
200
224
|
errorMessage,
|
@@ -203,7 +227,7 @@ export class NileSwitcher extends NileElement {
|
|
203
227
|
noborder,
|
204
228
|
} = Input;
|
205
229
|
return html`<nile-content-editor
|
206
|
-
.value=${value}
|
230
|
+
.value=${this.value}
|
207
231
|
.options=${options}
|
208
232
|
.type=${type}
|
209
233
|
.readonly=${readonly}
|