@aquera/nile-elements 0.0.12 → 0.0.13

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 (50) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.d.ts +3 -0
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js +3 -0
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js.map +1 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js +1 -1
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.d.ts +2 -2
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js +52 -15
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.d.ts +1 -1
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.js +1 -1
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.js.map +1 -1
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +4 -3
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  14. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/index.iife.js +25 -24
  16. package/dist/internal/enum.cjs.js +1 -1
  17. package/dist/internal/enum.cjs.js.map +1 -1
  18. package/dist/internal/enum.esm.js +1 -1
  19. package/dist/nile-content-editor/nile-content-editor.cjs.js +1 -1
  20. package/dist/nile-content-editor/nile-content-editor.cjs.js.map +1 -1
  21. package/dist/nile-content-editor/nile-content-editor.css.cjs.js +1 -1
  22. package/dist/nile-content-editor/nile-content-editor.css.cjs.js.map +1 -1
  23. package/dist/nile-content-editor/nile-content-editor.css.esm.js +1 -1
  24. package/dist/nile-content-editor/nile-content-editor.esm.js +11 -11
  25. package/dist/nile-icon/icons/svg/document.cjs.js +1 -1
  26. package/dist/nile-icon/icons/svg/document.cjs.js.map +1 -1
  27. package/dist/nile-icon/icons/svg/document.esm.js +1 -1
  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.esm.js +7 -6
  31. package/dist/src/internal/enum.d.ts +3 -0
  32. package/dist/src/internal/enum.js +3 -0
  33. package/dist/src/internal/enum.js.map +1 -1
  34. package/dist/src/nile-content-editor/nile-content-editor.css.js +1 -1
  35. package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
  36. package/dist/src/nile-content-editor/nile-content-editor.d.ts +2 -2
  37. package/dist/src/nile-content-editor/nile-content-editor.js +52 -15
  38. package/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
  39. package/dist/src/nile-icon/icons/svg/document.d.ts +1 -1
  40. package/dist/src/nile-icon/icons/svg/document.js +1 -1
  41. package/dist/src/nile-icon/icons/svg/document.js.map +1 -1
  42. package/dist/src/nile-switcher/nile-switcher.js +4 -3
  43. package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +1 -1
  46. package/src/internal/enum.ts +3 -0
  47. package/src/nile-content-editor/nile-content-editor.css.ts +1 -1
  48. package/src/nile-content-editor/nile-content-editor.ts +56 -21
  49. package/src/nile-icon/icons/svg/document.ts +1 -1
  50. 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.12",
6
+ "version": "0.0.13",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -14,4 +14,7 @@ export const KeyCode = {
14
14
  ARROW_UP: 'ArrowUp',
15
15
  ARROW_RIGHT: 'ArrowRight',
16
16
  ARROW_DOWN: 'ArrowDown',
17
+ CUT: 'KeyX',
18
+ COPY: 'Copy',
19
+ PASTE: 'Paste',
17
20
  };
@@ -25,7 +25,7 @@ export const styles = css`
25
25
 
26
26
  .dropdown-position {
27
27
  position: relative;
28
- bottom: 60px;
28
+ bottom: 20px;
29
29
  }
30
30
  .content-editable-input {
31
31
  box-sizing: border-box;
@@ -66,6 +66,7 @@ export class NileContentEditor extends NileElement {
66
66
 
67
67
  connectedCallback() {
68
68
  this.handleOutsideClick = this.handleOutsideClick.bind(this);
69
+ this.handleClipboardEvent = this.handleClipboardEvent.bind(this);
69
70
  super.connectedCallback();
70
71
  this.emit('nile-init');
71
72
  this.addOpenListeners();
@@ -83,10 +84,38 @@ export class NileContentEditor extends NileElement {
83
84
 
84
85
  addOpenListeners() {
85
86
  window.addEventListener('click', this.handleOutsideClick);
87
+ window.addEventListener('cut', this.handleClipboardEvent);
88
+ window.addEventListener('copy', this.handleClipboardEvent);
89
+ window.addEventListener('paste', this.handleClipboardEvent);
86
90
  }
87
91
 
88
92
  removeOpenListeners() {
89
93
  window.removeEventListener('click', this.handleOutsideClick);
94
+ window.removeEventListener('cut', this.handleClipboardEvent);
95
+ window.removeEventListener('copy', this.handleClipboardEvent);
96
+ window.removeEventListener('paste', this.handleClipboardEvent);
97
+ }
98
+
99
+ async handleClipboardEvent(event: Event) {
100
+ const selectedText = window?.getSelection()?.toString();
101
+ if (!!selectedText) {
102
+ switch (event.type) {
103
+ case 'cut':
104
+ case 'copy':
105
+ await navigator.clipboard.writeText(selectedText);
106
+ document.execCommand(event.type);
107
+ break;
108
+ case 'paste':
109
+ const pastedText = await navigator.clipboard.readText();
110
+ document.execCommand('insertText', false, pastedText);
111
+ break;
112
+ default:
113
+ break;
114
+ }
115
+ }
116
+ setTimeout(() => {
117
+ this.emitInputChange();
118
+ });
90
119
  }
91
120
 
92
121
  toggleDropdown(value: boolean) {
@@ -110,20 +139,14 @@ export class NileContentEditor extends NileElement {
110
139
  this.emit('nile-destroy');
111
140
  }
112
141
 
113
- handlePaste(event: ClipboardEvent) {
114
- event.preventDefault();
115
- if (event.clipboardData) {
116
- let text = event.clipboardData.getData('text/plain');
117
- document.execCommand('insertText', false, text);
118
- }
119
- this.emitInputChange();
120
- }
121
-
122
142
  private handlekeyDown(event: any) {
123
143
  if (event.code === KeyCode.ENTER && this.type === 'text') {
124
144
  event.preventDefault();
125
145
  return;
126
146
  }
147
+ if ([KeyCode.CUT, KeyCode.COPY, KeyCode.PASTE].includes(event.code)) {
148
+ return;
149
+ }
127
150
  if (event.code === KeyCode.ESCAPE) {
128
151
  event.preventDefault();
129
152
  this.toggleDropdown(false);
@@ -133,8 +156,9 @@ export class NileContentEditor extends NileElement {
133
156
  const value = this.contentEditor.innerText;
134
157
  this.emitInputChange();
135
158
  if (value.includes(this.tagIdentifier)) {
136
- this.toggleDropdown(true);
159
+ this.insertNodes(this.contentEditor, this.contentEditor.childNodes);
137
160
  this.filterOptions();
161
+ this.toggleDropdown(true);
138
162
  } else {
139
163
  this.toggleDropdown(false);
140
164
  }
@@ -176,7 +200,6 @@ export class NileContentEditor extends NileElement {
176
200
  emitInputChange(): void {
177
201
  if (this.contentEditor) {
178
202
  let fieldValue = this.contentEditor.innerHTML;
179
-
180
203
  if (this.contentEditor.innerText !== '') {
181
204
  fieldValue = this.generateValuesFromHTMLTags(fieldValue);
182
205
  }
@@ -188,17 +211,29 @@ export class NileContentEditor extends NileElement {
188
211
  }
189
212
  }
190
213
 
191
- insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag: Node) {
192
- Array.from(childNodes).map((node: Node, index: number) => {
214
+ insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag?: Node) {
215
+ [...childNodes].forEach((node: Node, index: number) => {
193
216
  if (node.hasChildNodes()) {
194
- this.insertNodes(node, node.childNodes, autoOptionsTag);
217
+ if (autoOptionsTag) {
218
+ this.insertNodes(node, node.childNodes, autoOptionsTag);
219
+ } else {
220
+ this.insertNodes(node, node.childNodes);
221
+ }
195
222
  } else {
196
223
  if (node.nodeValue?.includes(this.tagIdentifier)) {
197
- parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(
198
- this.tagIdentifier + this.filteredValue,
199
- ''
200
- );
201
- parentNode.childNodes[index].after(autoOptionsTag);
224
+ if (autoOptionsTag) {
225
+ parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(
226
+ this.tagIdentifier + this.filteredValue,
227
+ ''
228
+ );
229
+ parentNode.childNodes[index].after(autoOptionsTag);
230
+ }
231
+ this.filteredValue =
232
+ parentNode?.childNodes[index]?.nodeValue
233
+ ?.split(this.tagIdentifier)
234
+ .slice(1)
235
+ .join() || '';
236
+ return;
202
237
  }
203
238
  }
204
239
  });
@@ -250,6 +285,7 @@ export class NileContentEditor extends NileElement {
250
285
  <nile-popup
251
286
  .active="${live(this.openDropdown)}"
252
287
  sync="width"
288
+ strategy="fixed"
253
289
  placement="bottom"
254
290
  class=${classMap({
255
291
  dropdown: true,
@@ -261,7 +297,7 @@ export class NileContentEditor extends NileElement {
261
297
  ${this.showLabel && this.labelText
262
298
  ? html`<label class="ods-label">${this.labelText} </label> ${this
263
299
  .required
264
- ? html`<sapn class="asterik">*</span>`
300
+ ? html`<span class="asterik">*</span>`
265
301
  : ''}`
266
302
  : ''}
267
303
  <div
@@ -273,7 +309,6 @@ export class NileContentEditor extends NileElement {
273
309
  'text-area': type === 'text-area' ? true : false,
274
310
  })}
275
311
  @keydown=${this.handlekeyDown}
276
- @paste=${this.handlePaste}
277
312
  ></div>
278
313
  ${hasHelpText
279
314
  ? html`
@@ -2,4 +2,4 @@
2
2
  * Do not edit directly
3
3
  */
4
4
 
5
- export default "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMjEuMS4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIJIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMjQgMjQ7IiB4bWw6c3BhY2U9InByZXNlcnZlIj48Zz48Zz48cGF0aCBpZD0iZG9jdW1lbnRfMV8iIGQ9Ik0xNi4zLDAuMmw2LjQsNi40djE3LjFIMS4yVjAuM0wxNi4zLDAuMnogTTE1LjMsMS43SDIuOHYyMC41aDE4LjVWNy43aC02TDE1LjMsMS43eiBNMTcsMTYuMnYxLjVINwkJCXYtMS41SDE3eiBNMTcsMTEuMnYxLjVIN3YtMS41SDE3eiBNMTEsNi4ydjEuNUg3VjYuMkgxMXogTTE2LjgsMi44djMuNGgzLjRMMTYuOCwyLjh6Ii8+PC9nPjwvZz48L3N2Zz4=";
5
+ export default "PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjUiIHZpZXdCb3g9IjAgMCAyNCAyNSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMuNzUgNS43MzgyOEMzLjc1IDQuNDk1NjQgNC43NTczNiAzLjQ4ODI4IDYgMy40ODgyOEgxMy4zNzVWNS43MzgyOEMxMy4zNzUgNy44MDkzNSAxNS4wNTM5IDkuNDg4MjggMTcuMTI1IDkuNDg4MjhIMjAuMjVWMTkuNzM4M0MyMC4yNSAyMC45ODA5IDE5LjI0MjYgMjEuOTg4MyAxOCAyMS45ODgzSDZDNC43NTczNiAyMS45ODgzIDMuNzUgMjAuOTgwOSAzLjc1IDE5LjczODNWNS43MzgyOFpNMTkgNy45ODgyOEwxNC44NzUgNC4zODgyOFY1LjczODI4QzE0Ljg3NSA2Ljk4MDkyIDE1Ljg4MjQgNy45ODgyOCAxNy4xMjUgNy45ODgyOEgxOVpNNiAxLjk4ODI4QzMuOTI4OTMgMS45ODgyOCAyLjI1IDMuNjY3MjEgMi4yNSA1LjczODI4VjE5LjczODNDMi4yNSAyMS44MDkzIDMuOTI4OTMgMjMuNDg4MyA2IDIzLjQ4ODNIMThDMjAuMDcxMSAyMy40ODgzIDIxLjc1IDIxLjgwOTMgMjEuNzUgMTkuNzM4M1Y4LjM5NzM3TDE0LjQwNjIgMS45ODgyOEg2Wk02IDE4LjQ4ODNMMTggMTguNDg4M1YxNi45ODgzTDYgMTYuOTg4M0w2IDE4LjQ4ODNaTTE4IDE0LjIzODNMNiAxNC4yMzgzTDYgMTIuNzM4M0wxOCAxMi43MzgzVjE0LjIzODNaTTYgMTAuMjM4M0gxMVY4LjczODI4TDYgOC43MzgyOEw2IDEwLjIzODNaIiBmaWxsPSJibGFjayIvPjwvc3ZnPg==";
@@ -98,6 +98,7 @@ export class NileSwitcher extends NileElement {
98
98
  placeholder,
99
99
  disabled,
100
100
  required,
101
+ error,
101
102
  errorMessage,
102
103
  inputType: inputTypeName,
103
104
  } = Input;
@@ -108,7 +109,7 @@ export class NileSwitcher extends NileElement {
108
109
  .required=${required}
109
110
  .errorMessage=${errorMessage}
110
111
  .placeholder=${placeholder}
111
- .error=${true}
112
+ .error=${error}
112
113
  @nile-input=${(e: CustomEvent) => {
113
114
  this.handleChange(e, inputType, inputTypeName);
114
115
  }}
@@ -138,10 +139,11 @@ export class NileSwitcher extends NileElement {
138
139
  }
139
140
 
140
141
  renderNileTextArea(Input: switchInputType, inputType: string) {
141
- const { value, disabled, inputType: inputTypeName } = Input;
142
+ const { value, disabled, readonly, inputType: inputTypeName } = Input;
142
143
  return html`<nile-textarea
143
144
  .value=${value}
144
145
  .disabled=${disabled}
146
+ ?readonly=${readonly}
145
147
  @nile-input=${(e: CustomEvent) => {
146
148
  this.handleChange(e, inputType, inputTypeName);
147
149
  }}