@aquera/nile-elements 0.0.20 → 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.
Files changed (157) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +3 -0
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +3 -0
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.css.js +2 -5
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.d.ts +1 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js +8 -16
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js +4 -2
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.d.ts +8 -3
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js +58 -31
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
  14. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +5 -9
  15. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  16. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.d.ts +2 -0
  17. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +29 -15
  18. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  19. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/index.d.ts +1 -0
  20. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/index.js +2 -0
  21. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/index.js.map +1 -0
  22. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.d.ts +12 -0
  23. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.js +80 -0
  24. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.css.js.map +1 -0
  25. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.d.ts +55 -0
  26. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.js +129 -0
  27. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab/nile-tab.js.map +1 -0
  28. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/index.d.ts +1 -0
  29. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/index.js +2 -0
  30. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/index.js.map +1 -0
  31. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.css.d.ts +12 -0
  32. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.css.js +245 -0
  33. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.css.js.map +1 -0
  34. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.d.ts +82 -0
  35. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.js +392 -0
  36. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-group/nile-tab-group.js.map +1 -0
  37. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/index.d.ts +1 -0
  38. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/index.js +2 -0
  39. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/index.js.map +1 -0
  40. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.css.d.ts +12 -0
  41. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.css.js +32 -0
  42. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.css.js.map +1 -0
  43. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.d.ts +38 -0
  44. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.js +71 -0
  45. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-tab-panel/nile-tab-panel.js.map +1 -0
  46. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  47. package/dist/index.cjs.js +1 -1
  48. package/dist/index.esm.js +1 -1
  49. package/dist/index.iife.js +497 -118
  50. package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
  51. package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
  52. package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
  53. package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
  54. package/dist/nile-calendar/nile-calendar.css.esm.js +2 -5
  55. package/dist/nile-calendar/nile-calendar.esm.js +8 -16
  56. package/dist/nile-content-editor/nile-content-editor.cjs.js +1 -1
  57. package/dist/nile-content-editor/nile-content-editor.cjs.js.map +1 -1
  58. package/dist/nile-content-editor/nile-content-editor.css.cjs.js +1 -1
  59. package/dist/nile-content-editor/nile-content-editor.css.cjs.js.map +1 -1
  60. package/dist/nile-content-editor/nile-content-editor.css.esm.js +4 -2
  61. package/dist/nile-content-editor/nile-content-editor.esm.js +5 -5
  62. package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
  63. package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
  64. package/dist/nile-switcher/nile-switcher.css.cjs.js +1 -1
  65. package/dist/nile-switcher/nile-switcher.css.cjs.js.map +1 -1
  66. package/dist/nile-switcher/nile-switcher.css.esm.js +7 -11
  67. package/dist/nile-switcher/nile-switcher.esm.js +33 -26
  68. package/dist/nile-tab/index.cjs.js +2 -0
  69. package/dist/nile-tab/index.cjs.js.map +1 -0
  70. package/dist/nile-tab/index.esm.js +1 -0
  71. package/dist/nile-tab/nile-tab.cjs.js +2 -0
  72. package/dist/nile-tab/nile-tab.cjs.js.map +1 -0
  73. package/dist/nile-tab/nile-tab.css.cjs.js +2 -0
  74. package/dist/nile-tab/nile-tab.css.cjs.js.map +1 -0
  75. package/dist/nile-tab/nile-tab.css.esm.js +68 -0
  76. package/dist/nile-tab/nile-tab.esm.js +21 -0
  77. package/dist/nile-tab-group/index.cjs.js +2 -0
  78. package/dist/nile-tab-group/index.cjs.js.map +1 -0
  79. package/dist/nile-tab-group/index.esm.js +1 -0
  80. package/dist/nile-tab-group/nile-tab-group.cjs.js +2 -0
  81. package/dist/nile-tab-group/nile-tab-group.cjs.js.map +1 -0
  82. package/dist/nile-tab-group/nile-tab-group.css.cjs.js +2 -0
  83. package/dist/nile-tab-group/nile-tab-group.css.cjs.js.map +1 -0
  84. package/dist/nile-tab-group/nile-tab-group.css.esm.js +233 -0
  85. package/dist/nile-tab-group/nile-tab-group.esm.js +43 -0
  86. package/dist/nile-tab-panel/index.cjs.js +2 -0
  87. package/dist/nile-tab-panel/index.cjs.js.map +1 -0
  88. package/dist/nile-tab-panel/index.esm.js +1 -0
  89. package/dist/nile-tab-panel/nile-tab-panel.cjs.js +2 -0
  90. package/dist/nile-tab-panel/nile-tab-panel.cjs.js.map +1 -0
  91. package/dist/nile-tab-panel/nile-tab-panel.css.cjs.js +2 -0
  92. package/dist/nile-tab-panel/nile-tab-panel.css.cjs.js.map +1 -0
  93. package/dist/nile-tab-panel/nile-tab-panel.css.esm.js +20 -0
  94. package/dist/nile-tab-panel/nile-tab-panel.esm.js +6 -0
  95. package/dist/src/index.d.ts +3 -0
  96. package/dist/src/index.js +3 -0
  97. package/dist/src/index.js.map +1 -1
  98. package/dist/src/nile-calendar/nile-calendar.css.js +2 -5
  99. package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  100. package/dist/src/nile-calendar/nile-calendar.d.ts +1 -0
  101. package/dist/src/nile-calendar/nile-calendar.js +8 -16
  102. package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  103. package/dist/src/nile-content-editor/nile-content-editor.css.js +4 -2
  104. package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
  105. package/dist/src/nile-content-editor/nile-content-editor.d.ts +8 -3
  106. package/dist/src/nile-content-editor/nile-content-editor.js +58 -31
  107. package/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
  108. package/dist/src/nile-switcher/nile-switcher.css.js +5 -9
  109. package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
  110. package/dist/src/nile-switcher/nile-switcher.d.ts +2 -0
  111. package/dist/src/nile-switcher/nile-switcher.js +29 -15
  112. package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
  113. package/dist/src/nile-tab/index.d.ts +1 -0
  114. package/dist/src/nile-tab/index.js +2 -0
  115. package/dist/src/nile-tab/index.js.map +1 -0
  116. package/dist/src/nile-tab/nile-tab.css.d.ts +12 -0
  117. package/dist/src/nile-tab/nile-tab.css.js +80 -0
  118. package/dist/src/nile-tab/nile-tab.css.js.map +1 -0
  119. package/dist/src/nile-tab/nile-tab.d.ts +55 -0
  120. package/dist/src/nile-tab/nile-tab.js +129 -0
  121. package/dist/src/nile-tab/nile-tab.js.map +1 -0
  122. package/dist/src/nile-tab-group/index.d.ts +1 -0
  123. package/dist/src/nile-tab-group/index.js +2 -0
  124. package/dist/src/nile-tab-group/index.js.map +1 -0
  125. package/dist/src/nile-tab-group/nile-tab-group.css.d.ts +12 -0
  126. package/dist/src/nile-tab-group/nile-tab-group.css.js +245 -0
  127. package/dist/src/nile-tab-group/nile-tab-group.css.js.map +1 -0
  128. package/dist/src/nile-tab-group/nile-tab-group.d.ts +82 -0
  129. package/dist/src/nile-tab-group/nile-tab-group.js +392 -0
  130. package/dist/src/nile-tab-group/nile-tab-group.js.map +1 -0
  131. package/dist/src/nile-tab-panel/index.d.ts +1 -0
  132. package/dist/src/nile-tab-panel/index.js +2 -0
  133. package/dist/src/nile-tab-panel/index.js.map +1 -0
  134. package/dist/src/nile-tab-panel/nile-tab-panel.css.d.ts +12 -0
  135. package/dist/src/nile-tab-panel/nile-tab-panel.css.js +32 -0
  136. package/dist/src/nile-tab-panel/nile-tab-panel.css.js.map +1 -0
  137. package/dist/src/nile-tab-panel/nile-tab-panel.d.ts +38 -0
  138. package/dist/src/nile-tab-panel/nile-tab-panel.js +71 -0
  139. package/dist/src/nile-tab-panel/nile-tab-panel.js.map +1 -0
  140. package/dist/tsconfig.tsbuildinfo +1 -1
  141. package/package.json +1 -1
  142. package/src/index.ts +3 -0
  143. package/src/nile-calendar/nile-calendar.css.ts +2 -5
  144. package/src/nile-calendar/nile-calendar.ts +9 -16
  145. package/src/nile-content-editor/nile-content-editor.css.ts +4 -2
  146. package/src/nile-content-editor/nile-content-editor.ts +74 -39
  147. package/src/nile-switcher/nile-switcher.css.ts +5 -9
  148. package/src/nile-switcher/nile-switcher.ts +46 -22
  149. package/src/nile-tab/index.ts +1 -0
  150. package/src/nile-tab/nile-tab.css.ts +82 -0
  151. package/src/nile-tab/nile-tab.ts +129 -0
  152. package/src/nile-tab-group/index.ts +1 -0
  153. package/src/nile-tab-group/nile-tab-group.css.ts +247 -0
  154. package/src/nile-tab-group/nile-tab-group.ts +441 -0
  155. package/src/nile-tab-panel/index.ts +1 -0
  156. package/src/nile-tab-panel/nile-tab-panel.css.ts +34 -0
  157. package/src/nile-tab-panel/nile-tab-panel.ts +74 -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.20",
6
+ "version": "0.0.22",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
package/src/index.ts CHANGED
@@ -36,3 +36,6 @@ export { NileSwitcher } from './nile-switcher';
36
36
  export { NileContentEditor } from './nile-content-editor';
37
37
  export { NileDialog } from './nile-dialog';
38
38
  export { NileErrorNotification } from './nile-error-notification';
39
+ export { NileTabGroup } from './nile-tab-group';
40
+ export { NileTab } from './nile-tab';
41
+ export { NileTabPanel } from './nile-tab-panel';
@@ -214,11 +214,8 @@ export const styles = css`
214
214
  }
215
215
 
216
216
  .calendar-switcher {
217
- display: flex;
218
- align-items: flex-start;
219
- gap: 24px;
220
- justify-content: space-between;
221
- border-bottom: 1px solid #e5e9eb;
217
+ width: 100%;
218
+ margin-right: 24px;
222
219
  }
223
220
 
224
221
  .calendar-switch {
@@ -620,6 +620,11 @@ export class NileCalendar extends NileElement {
620
620
  this.requestUpdate();
621
621
  }
622
622
 
623
+ onTypeChange(event: any) {
624
+ console.log(event);
625
+ this.type = event.detail.value;
626
+ }
627
+
623
628
  /**
624
629
  * Render method
625
630
  */
@@ -641,22 +646,10 @@ export class NileCalendar extends NileElement {
641
646
  >
642
647
  <div class="calendar-config ${!this.range ? 'hidden' : ''}">
643
648
  <div class="calendar-switcher">
644
- <div
645
- class="calendar-switch${this.type === 'absolute'
646
- ? '__active'
647
- : ''}"
648
- @click="${() => this.setType('absolute')}"
649
- >
650
- Absolute
651
- </div>
652
- <div
653
- class="calendar-switch${this.type === 'relative'
654
- ? '__active'
655
- : ''}"
656
- @click="${() => this.setType('relative')}"
657
- >
658
- Relative
659
- </div>
649
+ <nile-tab-group @nile-tab-show="${this.onTypeChange}">
650
+ <nile-tab slot="nav" panel="absolute">Absolute</nile-tab>
651
+ <nile-tab slot="nav" panel="relative">Relative</nile-tab>
652
+ </nile-tab-group>
660
653
  </div>
661
654
 
662
655
  <div class="calendar-timezone">
@@ -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: 20px;
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
- this.addEventListener('click', this.handleOutsideClick);
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
- handleOutsideClick(event: Event) {
130
- if (event && event.target) {
131
- this.toggleDropdown(false);
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
- var result = string.replace(pattern, (match: any, option: any) => {
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(/&nbsp;/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
- insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag?: Node) {
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
- parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(
250
- this.tagIdentifier + this.filteredValue,
251
- ''
252
- );
253
- parentNode.childNodes[index].after(autoOptionsTag);
249
+ this.insertAutoOptionsTag(node, autoOptionsTag);
254
250
  }
255
- this.filteredValue =
256
- parentNode?.childNodes[index]?.nodeValue
257
- ?.split(this.tagIdentifier)
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
- .tooltip-container {
29
- display: flex;
30
- flex-grow: 1;
31
- flex-shrink: 0;
26
+ .input-container > :first-child {
27
+ max-width: 99%;
28
+ min-width: 99%;
32
29
  }
33
30
 
34
- .input-container > :first-child {
35
- flex-grow: 1;
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
- .checked=${value}
170
- .label=${label}
171
- .disabled=${disabled}
172
- @valueChange=${(e: CustomEvent) => {
173
- this.handleChange(e, inputType, inputTypeName);
174
- }}
175
- ></nile-checkbox>`;
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 { options, value, disabled, inputType: inputTypeName } = Input;
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
- .value=${value}
183
- .disabled=${disabled}
184
- @change=${(e: CustomEvent) => {
185
- this.handleChange(e, inputType, inputTypeName);
186
- }}
187
- >
188
- ${options &&
189
- options.map((option: any) => {
190
- return html`<nile-radio .value="${option}">${option} </nile-radio>`;
191
- })}
192
- </nile-radio-group>`;
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
- const {
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}
@@ -0,0 +1 @@
1
+ export { NileTab } from './nile-tab';
@@ -0,0 +1,82 @@
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 {css} from 'lit-element';
9
+
10
+ /**
11
+ * Tab CSS
12
+ */
13
+ export const styles = css`
14
+ [hidden] {
15
+ display: none !important;
16
+ }
17
+
18
+ :host {
19
+ display: inline-block;
20
+ }
21
+
22
+ .tab {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ border-radius: 8px;
26
+ color: var(--nile-colors-dark-500);
27
+ padding: 4px 4px 12px 4px;
28
+ white-space: nowrap;
29
+ user-select: none;
30
+ cursor: pointer;
31
+ transition: 0.2s box-shadow, 0.2s color;
32
+ font-family: Colfax-regular;
33
+ font-size: 16px;
34
+ font-style: normal;
35
+ font-weight: 500;
36
+ line-height: 16px;
37
+ letter-spacing: 0.2px;
38
+ }
39
+
40
+ .tab:hover:not(.tab--disabled) {
41
+ color: var(--nile-colors-dark-900);
42
+ }
43
+
44
+ .tab:focus {
45
+ outline: none;
46
+ }
47
+
48
+ .tab:focus-visible:not(.tab--disabled) {
49
+ color: var(--nile-colors-primary-600);
50
+ }
51
+
52
+ .tab.tab--active:not(.tab--disabled) {
53
+ color: var(--nile-colors-primary-600);
54
+ }
55
+
56
+ .tab.tab--closable {
57
+ padding-inline-end: 4px;
58
+ }
59
+
60
+ .tab.tab--disabled {
61
+ opacity: 0.5;
62
+ cursor: not-allowed;
63
+ }
64
+
65
+ .tab__close-button {
66
+ font-size: 14px;
67
+ margin-inline-start: 4px;
68
+ }
69
+
70
+ .tab__close-button::part(base) {
71
+ padding: 3px;
72
+ }
73
+
74
+ @media (forced-colors: active) {
75
+ .tab.tab--active:not(.tab--disabled) {
76
+ outline: solid 1px transparent;
77
+ outline-offset: -3px;
78
+ }
79
+ }
80
+ `;
81
+
82
+ export default [styles];
@@ -0,0 +1,129 @@
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-tab.css';
11
+
12
+ import '../nile-icon-button/nile-icon-button';
13
+ import { classMap } from 'lit/directives/class-map.js';
14
+ import { query } from 'lit/decorators.js';
15
+ import { watch } from '../internal/watch';
16
+ import NileElement from '../internal/nile-element';
17
+ import type { CSSResultGroup } from 'lit';
18
+
19
+ let id = 0;
20
+
21
+ /**
22
+ * Nile icon component.
23
+ *
24
+ * @tag nile-tab
25
+ *
26
+ *
27
+ * @dependency nile-icon-button
28
+ *
29
+ * @slot - The tab's label.
30
+ *
31
+ * @event nile-close - Emitted when the tab is closable and the close button is activated.
32
+ *
33
+ * @csspart base - The component's base wrapper.
34
+ * @csspart close-button - The close button, an `<nile-icon-button>`.
35
+ * @csspart close-button__base - The close button's exported `base` part.
36
+ */
37
+ @customElement('nile-tab')
38
+ export class NileTab extends NileElement {
39
+ static styles: CSSResultGroup = styles;
40
+
41
+ private readonly attrId = ++id;
42
+ private readonly componentId = `nile-tab-${this.attrId}`;
43
+
44
+ @query('.tab') tab: HTMLElement;
45
+
46
+ /** The name of the tab panel this tab is associated with. The panel must be located in the same tab group. */
47
+ @property({ reflect: true }) panel = '';
48
+
49
+ /** Draws the tab in an active state. */
50
+ @property({ type: Boolean, reflect: true }) active = false;
51
+
52
+ /** Makes the tab closable and shows a close button. */
53
+ @property({ type: Boolean }) closable = false;
54
+
55
+ /** Disables the tab and prevents selection. */
56
+ @property({ type: Boolean, reflect: true }) disabled = false;
57
+
58
+ connectedCallback() {
59
+ super.connectedCallback();
60
+ this.setAttribute('role', 'tab');
61
+ }
62
+
63
+ private handleCloseClick(event: Event) {
64
+ event.stopPropagation();
65
+ this.emit('nile-close');
66
+ }
67
+
68
+ @watch('active')
69
+ handleActiveChange() {
70
+ this.setAttribute('aria-selected', this.active ? 'true' : 'false');
71
+ }
72
+
73
+ @watch('disabled')
74
+ handleDisabledChange() {
75
+ this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
76
+ }
77
+
78
+ /** Sets focus to the tab. */
79
+ focus(options?: FocusOptions) {
80
+ this.tab.focus(options);
81
+ }
82
+
83
+ /** Removes focus from the tab. */
84
+ blur() {
85
+ this.tab.blur();
86
+ }
87
+
88
+ render() {
89
+ // If the user didn't provide an ID, we'll set one so we can link tabs and tab panels with aria labels
90
+ this.id = this.id.length > 0 ? this.id : this.componentId;
91
+
92
+ return html`
93
+ <div
94
+ part="base"
95
+ class=${classMap({
96
+ tab: true,
97
+ 'tab--active': this.active,
98
+ 'tab--closable': this.closable,
99
+ 'tab--disabled': this.disabled
100
+ })}
101
+ tabindex=${this.disabled ? '-1' : '0'}
102
+ >
103
+ <slot></slot>
104
+ ${this.closable
105
+ ? html`
106
+ <nile-icon-button
107
+ part="close-button"
108
+ exportparts="base:close-button__base"
109
+ name="x-lg"
110
+ library="system"
111
+ label="close"
112
+ class="tab__close-button"
113
+ @click=${this.handleCloseClick}
114
+ tabindex="-1"
115
+ ></nile-icon-button>
116
+ `
117
+ : ''}
118
+ </div>
119
+ `;
120
+ }
121
+ }
122
+
123
+ export default NileTab;
124
+
125
+ declare global {
126
+ interface HTMLElementTagNameMap {
127
+ 'nile-tab': NileTab;
128
+ }
129
+ }
@@ -0,0 +1 @@
1
+ export { NileTabGroup } from './nile-tab-group';