@aquera/nile-elements 0.0.36 → 0.0.37
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 +10 -4
- 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 +6 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-code-editor/nile-code-editor.js +55 -23
- 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-content-editor/nile-content-editor.css.js +0 -1
- 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-icon/icons/svg/edit-write.d.ts +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/edit-write.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/edit-write.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/expand-2.d.ts +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/expand-2.js +5 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/expand-2.js.map +1 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.d.ts +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.js +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/index.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.css.js +5 -83
- 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 +17 -38
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +110 -214
- 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/demo/filenames.txt +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +362 -475
- package/dist/nile-badge/index.cjs.js +1 -1
- package/dist/nile-badge/index.esm.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
- package/dist/nile-badge/nile-badge.esm.js +1 -1
- package/dist/nile-button/index.cjs.js +1 -1
- package/dist/nile-button/index.esm.js +1 -1
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.esm.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js +2 -2
- 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/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 +12 -6
- package/dist/nile-code-editor/nile-code-editor.esm.js +17 -12
- 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 +0 -1
- package/dist/nile-dialog/index.cjs.js +1 -1
- package/dist/nile-dialog/index.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.esm.js +1 -1
- package/dist/nile-icon/icons/svg/edit-write.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/edit-write.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/edit-write.esm.js +1 -0
- package/dist/nile-icon/icons/svg/expand-2.cjs.js +2 -0
- package/dist/nile-icon/icons/svg/expand-2.cjs.js.map +1 -0
- package/dist/nile-icon/icons/svg/expand-2.esm.js +1 -0
- package/dist/nile-icon/icons/svg/index.cjs.js +1 -1
- package/dist/nile-icon/icons/svg/index.esm.js +1 -1
- package/dist/nile-icon/index.cjs.js +1 -1
- package/dist/nile-icon/index.cjs.js.map +1 -1
- package/dist/nile-icon/index.esm.js +1 -1
- package/dist/nile-icon-button/index.cjs.js +1 -1
- package/dist/nile-icon-button/index.esm.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js +1 -1
- package/dist/nile-icon-button/nile-icon-button.cjs.js.map +1 -1
- package/dist/nile-icon-button/nile-icon-button.esm.js +1 -1
- package/dist/nile-input/index.cjs.js +1 -1
- package/dist/nile-input/index.esm.js +1 -1
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.esm.js +1 -1
- package/dist/nile-menu-item/index.cjs.js +1 -1
- package/dist/nile-menu-item/index.esm.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js +1 -1
- package/dist/nile-menu-item/nile-menu-item.cjs.js.map +1 -1
- package/dist/nile-menu-item/nile-menu-item.esm.js +1 -1
- package/dist/nile-option/index.cjs.js +1 -1
- package/dist/nile-option/index.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- 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 +7 -85
- package/dist/nile-switcher/nile-switcher.esm.js +51 -101
- package/dist/nile-tab/index.cjs.js +1 -1
- package/dist/nile-tab/index.esm.js +1 -1
- package/dist/nile-tab/nile-tab.cjs.js +1 -1
- package/dist/nile-tab/nile-tab.cjs.js.map +1 -1
- package/dist/nile-tab/nile-tab.esm.js +1 -1
- package/dist/nile-tab-group/index.cjs.js +1 -1
- package/dist/nile-tab-group/index.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.cjs.js.map +1 -1
- package/dist/nile-tab-group/nile-tab-group.esm.js +1 -1
- package/dist/nile-tag/index.cjs.js +1 -1
- package/dist/nile-tag/index.esm.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js +1 -1
- package/dist/nile-tag/nile-tag.cjs.js.map +1 -1
- package/dist/nile-tag/nile-tag.esm.js +1 -1
- package/dist/nile-toast/index.cjs.js +1 -1
- package/dist/nile-toast/index.esm.js +1 -1
- package/dist/nile-toast/nile-toast.cjs.js +1 -1
- package/dist/nile-toast/nile-toast.cjs.js.map +1 -1
- package/dist/nile-toast/nile-toast.esm.js +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js +10 -4
- 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 +6 -2
- package/dist/src/nile-code-editor/nile-code-editor.js +55 -23
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.css.js +0 -1
- package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/dist/src/nile-icon/icons/svg/edit-write.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/edit-write.js +5 -0
- package/dist/src/nile-icon/icons/svg/edit-write.js.map +1 -0
- package/dist/src/nile-icon/icons/svg/expand-2.d.ts +5 -0
- package/dist/src/nile-icon/icons/svg/expand-2.js +5 -0
- package/dist/src/nile-icon/icons/svg/expand-2.js.map +1 -0
- package/dist/src/nile-icon/icons/svg/index.d.ts +2 -0
- package/dist/src/nile-icon/icons/svg/index.js +2 -0
- package/dist/src/nile-icon/icons/svg/index.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.css.js +5 -83
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +17 -38
- package/dist/src/nile-switcher/nile-switcher.js +110 -214
- 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 +10 -4
- package/src/nile-code-editor/nile-code-editor.ts +51 -31
- package/src/nile-content-editor/nile-content-editor.css.ts +0 -1
- package/src/nile-icon/icons/svg/edit-write.ts +5 -0
- package/src/nile-icon/icons/svg/expand-2.ts +5 -0
- package/src/nile-icon/icons/svg/index.ts +2 -0
- package/src/nile-switcher/nile-switcher.css.ts +5 -83
- package/src/nile-switcher/nile-switcher.ts +172 -252
@@ -12,21 +12,20 @@ import NileElement from '../internal/nile-element';
|
|
12
12
|
import { CSSResultGroup } from 'lit';
|
13
13
|
import { choose } from 'lit/directives/choose.js';
|
14
14
|
import { classMap } from 'lit/directives/class-map.js';
|
15
|
-
import { repeat } from 'lit/directives/repeat.js';
|
16
|
-
import { watch } from '../internal/watch';
|
17
|
-
import { HasSlotController } from '../internal/slot';
|
18
15
|
|
19
16
|
/**
|
20
17
|
* @summary Allows you to switch between nile elements
|
21
|
-
|
18
|
+
|
22
19
|
* @dependency nile-icon
|
23
20
|
* @dependency nile-input
|
24
21
|
* @dependency nile-checkbox
|
25
22
|
* @dependency nile-dropdown
|
26
23
|
* @dependency nile-textarea
|
27
24
|
*
|
25
|
+
|
28
26
|
* @event nile-change - Emitted when the control's value changes.
|
29
27
|
* @event nile-switch - Emitted when the nile component is being switched.
|
28
|
+
|
30
29
|
*/
|
31
30
|
|
32
31
|
export interface switchconfig {
|
@@ -34,8 +33,8 @@ export interface switchconfig {
|
|
34
33
|
toggleSwitch: boolean;
|
35
34
|
disable?: boolean;
|
36
35
|
confirmation?: boolean;
|
37
|
-
|
38
|
-
|
36
|
+
defaultInput: switchInputType;
|
37
|
+
switchInput: switchInputType;
|
39
38
|
}
|
40
39
|
|
41
40
|
export interface switchInputType {
|
@@ -45,32 +44,20 @@ export interface switchInputType {
|
|
45
44
|
| INPUT_TYPE_NAMES.CHECKBOX
|
46
45
|
| INPUT_TYPE_NAMES.TEXTAREA
|
47
46
|
| INPUT_TYPE_NAMES.RADIO
|
48
|
-
| INPUT_TYPE_NAMES.CONTENTEDITOR
|
49
|
-
| INPUT_TYPE_NAMES.OBJECT_MAPPER
|
50
|
-
| INPUT_TYPE_NAMES.CODE_EDITOR;
|
47
|
+
| INPUT_TYPE_NAMES.CONTENTEDITOR;
|
51
48
|
value?: String | boolean;
|
52
49
|
label?: String;
|
53
50
|
readonly?: boolean;
|
54
51
|
type?: string;
|
55
|
-
icon: string;
|
56
|
-
mode?: string;
|
57
52
|
placeholder?: string;
|
58
53
|
disabled?: boolean;
|
59
54
|
required?: boolean;
|
60
55
|
error?: boolean;
|
61
56
|
errorMessage?: string;
|
62
57
|
options?: Array<any>;
|
63
|
-
customAutoCompletions?: any;
|
64
58
|
helperText?: string;
|
65
59
|
multiple?: boolean;
|
66
60
|
noborder?: boolean;
|
67
|
-
multiLine?: boolean;
|
68
|
-
expand?: boolean;
|
69
|
-
}
|
70
|
-
|
71
|
-
export enum POSITIONS {
|
72
|
-
INLINE = 'inline',
|
73
|
-
BLOCK = 'block',
|
74
61
|
}
|
75
62
|
|
76
63
|
export enum INPUT_TYPE {
|
@@ -85,13 +72,6 @@ export enum INPUT_TYPE_NAMES {
|
|
85
72
|
TEXTAREA = 'text-area',
|
86
73
|
RADIO = 'radio',
|
87
74
|
CONTENTEDITOR = 'content-editor',
|
88
|
-
OBJECT_MAPPER = 'object-mapper',
|
89
|
-
CODE_EDITOR = 'code-editor',
|
90
|
-
}
|
91
|
-
|
92
|
-
export enum MODE {
|
93
|
-
CREATE = 'create',
|
94
|
-
EDIT = 'edit',
|
95
75
|
}
|
96
76
|
|
97
77
|
@customElement('nile-switcher')
|
@@ -101,40 +81,19 @@ export class NileSwitcher extends NileElement {
|
|
101
81
|
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
102
82
|
*/
|
103
83
|
static styles: CSSResultGroup = styles;
|
104
|
-
|
105
|
-
private readonly hasSlotController = new HasSlotController(this, 'label');
|
106
|
-
|
107
84
|
@property({ type: Object }) nileSwitchConfig: switchconfig;
|
108
85
|
|
109
|
-
@property({ type: Number }) current: Number = 0;
|
110
|
-
|
111
|
-
@property({ type: Object }) currentInput: switchInputType;
|
112
|
-
|
113
86
|
connectedCallback() {
|
114
87
|
super.connectedCallback();
|
115
88
|
this.emit('nile-init');
|
116
89
|
}
|
117
90
|
|
118
|
-
@watch(['current'], { waitUntilFirstUpdate: true })
|
119
|
-
handleSwitcherChange() {
|
120
|
-
this.setCurrentInput();
|
121
|
-
}
|
122
|
-
|
123
|
-
setCurrentInput() {
|
124
|
-
if (this.nileSwitchConfig?.inputs) {
|
125
|
-
this.currentInput = this.nileSwitchConfig.inputs.filter(
|
126
|
-
(input: switchInputType, index: Number) => {
|
127
|
-
return index === this.current;
|
128
|
-
}
|
129
|
-
)[0];
|
130
|
-
}
|
131
|
-
}
|
132
91
|
disconnectedCallback() {
|
133
92
|
super.disconnectedCallback();
|
134
93
|
this.emit('nile-destroy');
|
135
94
|
}
|
136
95
|
|
137
|
-
renderNileText(Input: switchInputType) {
|
96
|
+
renderNileText(Input: switchInputType, inputType: string) {
|
138
97
|
const {
|
139
98
|
value,
|
140
99
|
label,
|
@@ -143,14 +102,9 @@ export class NileSwitcher extends NileElement {
|
|
143
102
|
required,
|
144
103
|
error,
|
145
104
|
errorMessage,
|
146
|
-
inputType,
|
147
|
-
noborder,
|
105
|
+
inputType: inputTypeName,
|
148
106
|
} = Input;
|
149
107
|
return html`<nile-input
|
150
|
-
class=${classMap({
|
151
|
-
'switcher-input': true,
|
152
|
-
'switcher-input--noborder': !!noborder,
|
153
|
-
})}
|
154
108
|
.value=${value}
|
155
109
|
.label=${label}
|
156
110
|
.disabled=${disabled}
|
@@ -159,12 +113,12 @@ export class NileSwitcher extends NileElement {
|
|
159
113
|
.placeholder=${placeholder}
|
160
114
|
.error=${error}
|
161
115
|
@nile-input=${(e: CustomEvent) => {
|
162
|
-
this.handleChange(e, inputType);
|
116
|
+
this.handleChange(e, inputType, inputTypeName);
|
163
117
|
}}
|
164
118
|
></nile-input>`;
|
165
119
|
}
|
166
120
|
|
167
|
-
renderDropdown(Input: switchInputType) {
|
121
|
+
renderDropdown(Input: switchInputType, inputType: string) {
|
168
122
|
const {
|
169
123
|
options,
|
170
124
|
multiple,
|
@@ -173,12 +127,10 @@ export class NileSwitcher extends NileElement {
|
|
173
127
|
value,
|
174
128
|
error,
|
175
129
|
errorMessage,
|
176
|
-
inputType,
|
130
|
+
inputType: inputTypeName,
|
177
131
|
} = Input;
|
178
132
|
|
179
133
|
return html`<nile-select
|
180
|
-
part="dropdown"
|
181
|
-
class="switcher-dropdown"
|
182
134
|
.placeholder=${placeholder}
|
183
135
|
.disabled="${disabled}"
|
184
136
|
.multiple="${multiple}"
|
@@ -186,7 +138,7 @@ export class NileSwitcher extends NileElement {
|
|
186
138
|
.error="${error}"
|
187
139
|
.errorMessage="${errorMessage}"
|
188
140
|
@nile-change=${(e: CustomEvent) => {
|
189
|
-
this.handleChange(e, inputType);
|
141
|
+
this.handleChange(e, inputType, inputTypeName);
|
190
142
|
}}
|
191
143
|
>
|
192
144
|
${options?.map((option: any) => {
|
@@ -195,48 +147,58 @@ export class NileSwitcher extends NileElement {
|
|
195
147
|
</nile-select>`;
|
196
148
|
}
|
197
149
|
|
198
|
-
renderNileTextArea(Input: switchInputType) {
|
199
|
-
const {
|
150
|
+
renderNileTextArea(Input: switchInputType, inputType: string) {
|
151
|
+
const {
|
152
|
+
value,
|
153
|
+
disabled,
|
154
|
+
readonly,
|
155
|
+
errorMessage,
|
156
|
+
error,
|
157
|
+
inputType: inputTypeName,
|
158
|
+
} = Input;
|
200
159
|
|
201
160
|
return html`<nile-textarea
|
202
|
-
class="switcher-textarea"
|
203
161
|
.value=${value}
|
204
162
|
.disabled=${disabled}
|
205
163
|
?readonly=${readonly}
|
206
164
|
.error=${error}
|
207
165
|
.errorMessage=${errorMessage}
|
208
166
|
@nile-input=${(e: CustomEvent) => {
|
209
|
-
this.handleChange(e, inputType);
|
167
|
+
this.handleChange(e, inputType, inputTypeName);
|
210
168
|
}}
|
211
169
|
></nile-textarea>`;
|
212
170
|
}
|
213
171
|
|
214
|
-
renderNileCheckBox(Input: switchInputType) {
|
215
|
-
const { value, label, disabled, inputType } = Input;
|
172
|
+
renderNileCheckBox(Input: switchInputType, inputType: string) {
|
173
|
+
const { value, label, disabled, inputType: inputTypeName } = Input;
|
216
174
|
|
217
175
|
return html`<nile-checkbox
|
218
|
-
class="switcher-checkbox"
|
219
176
|
.checked=${value}
|
220
177
|
.label=${label}
|
221
178
|
.disabled=${disabled}
|
222
179
|
@valueChange=${(e: CustomEvent) => {
|
223
|
-
this.handleChange(e, inputType);
|
180
|
+
this.handleChange(e, inputType, inputTypeName);
|
224
181
|
}}
|
225
182
|
></nile-checkbox
|
226
183
|
>; `;
|
227
184
|
}
|
228
185
|
|
229
|
-
renderNileRadio(Input: switchInputType) {
|
230
|
-
const {
|
186
|
+
renderNileRadio(Input: switchInputType, inputType: string) {
|
187
|
+
const {
|
188
|
+
options,
|
189
|
+
value,
|
190
|
+
disabled,
|
191
|
+
inputType: inputTypeName,
|
192
|
+
errorMessage,
|
193
|
+
} = Input;
|
231
194
|
|
232
195
|
const haserrorMessage = !!errorMessage;
|
233
196
|
|
234
197
|
return html`<nile-radio-group
|
235
|
-
class="switcher-radio-group"
|
236
198
|
.value=${value}
|
237
199
|
.disabled=${disabled}
|
238
200
|
@change=${(e: CustomEvent) => {
|
239
|
-
this.handleChange(e, inputType);
|
201
|
+
this.handleChange(e, inputType, inputTypeName);
|
240
202
|
}}
|
241
203
|
>
|
242
204
|
${options &&
|
@@ -253,11 +215,17 @@ export class NileSwitcher extends NileElement {
|
|
253
215
|
`;
|
254
216
|
}
|
255
217
|
|
256
|
-
renderContentEditor(Input: switchInputType) {
|
257
|
-
let {
|
258
|
-
|
218
|
+
renderContentEditor(Input: switchInputType, inputType: string) {
|
219
|
+
let {
|
220
|
+
options,
|
221
|
+
inputType: inputTypeName,
|
222
|
+
errorMessage,
|
223
|
+
type,
|
224
|
+
readonly,
|
225
|
+
noborder,
|
226
|
+
value,
|
227
|
+
} = Input;
|
259
228
|
return html`<nile-content-editor
|
260
|
-
class="switcher-content-editor"
|
261
229
|
.value=${value}
|
262
230
|
.options=${options}
|
263
231
|
.type=${type}
|
@@ -265,202 +233,154 @@ export class NileSwitcher extends NileElement {
|
|
265
233
|
.noborder=${noborder}
|
266
234
|
.errorMessage=${errorMessage}
|
267
235
|
@nile-change=${(e: CustomEvent) => {
|
268
|
-
this.handleChange(e, inputType);
|
236
|
+
this.handleChange(e, inputType, inputTypeName);
|
269
237
|
}}
|
270
238
|
>
|
271
239
|
</nile-content-editor>`;
|
272
240
|
}
|
273
241
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
242
|
+
handleChange(event: CustomEvent, inputType: string, inputTypeName: string) {
|
243
|
+
if (inputTypeName === INPUT_TYPE_NAMES.CHECKBOX) {
|
244
|
+
this.nileSwitchConfig[inputType as keyof switchconfig].value =
|
245
|
+
event.detail.checked;
|
246
|
+
} else {
|
247
|
+
this.nileSwitchConfig[inputType as keyof switchconfig].value =
|
248
|
+
event.detail.value;
|
249
|
+
}
|
250
|
+
event.stopPropagation();
|
251
|
+
this.emit('nile-change', { config: this.nileSwitchConfig });
|
252
|
+
}
|
253
|
+
|
254
|
+
renderIcon(defaultInput: switchInputType, switchInput: switchInputType) {
|
255
|
+
const defaultHelperText = defaultInput.helperText;
|
256
|
+
const switchHelperText = switchInput.helperText;
|
281
257
|
|
282
|
-
|
258
|
+
const icon = !this.nileSwitchConfig.toggleSwitch
|
259
|
+
? 'header-functions'
|
260
|
+
: 'stringinput';
|
261
|
+
|
262
|
+
const helperText = !this.nileSwitchConfig.toggleSwitch
|
263
|
+
? !!switchHelperText
|
264
|
+
? switchHelperText
|
265
|
+
: `switch to ${switchInput.inputType}`
|
266
|
+
: !!defaultHelperText
|
267
|
+
? defaultHelperText
|
268
|
+
: `switch to ${defaultInput.inputType}`;
|
269
|
+
|
270
|
+
return html` <nile-tooltip
|
283
271
|
class=${classMap({
|
284
|
-
'
|
285
|
-
'switcher-object-mapper--noborder': !!noborder,
|
272
|
+
'tooltip-container': true,
|
286
273
|
})}
|
287
|
-
|
288
|
-
|
289
|
-
@click="${(e: CustomEvent) =>
|
290
|
-
this.handleChange(e, INPUT_TYPE_NAMES.OBJECT_MAPPER)}"
|
274
|
+
content=${helperText}
|
275
|
+
placement="bottom"
|
291
276
|
>
|
292
277
|
<nile-icon
|
293
|
-
|
294
|
-
|
295
|
-
|
278
|
+
size="14"
|
279
|
+
class=${classMap({
|
280
|
+
'pointer-cursor': true,
|
281
|
+
})}
|
282
|
+
.name=${icon}
|
296
283
|
color="#005EA6"
|
297
|
-
|
298
|
-
>
|
299
|
-
|
300
|
-
</nile-input>`;
|
301
|
-
}
|
302
|
-
|
303
|
-
renderCodeEditor(Input: switchInputType) {
|
304
|
-
const {
|
305
|
-
value,
|
306
|
-
multiLine,
|
307
|
-
customAutoCompletions,
|
308
|
-
disabled,
|
309
|
-
readonly,
|
310
|
-
errorMessage,
|
311
|
-
error,
|
312
|
-
inputType,
|
313
|
-
noborder,
|
314
|
-
} = Input;
|
315
|
-
return html`<nile-code-editor
|
316
|
-
part="code-editor"
|
317
|
-
class=${classMap({
|
318
|
-
'code-editor': true,
|
319
|
-
'code-editor__no-border': !!noborder,
|
320
|
-
})}
|
321
|
-
@nile-expand="${(e: CustomEvent) =>
|
322
|
-
this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
323
|
-
@nile-change="${(e: CustomEvent) =>
|
324
|
-
this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
325
|
-
.multiline="${multiLine}"
|
326
|
-
.value="${value}"
|
327
|
-
.customOptions="${customAutoCompletions}"
|
328
|
-
></nile-code-editor> `;
|
284
|
+
@click=${this.toggleField}
|
285
|
+
></nile-icon>
|
286
|
+
</nile-tooltip>`;
|
329
287
|
}
|
330
288
|
|
331
|
-
|
332
|
-
this.
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
switch (inputType) {
|
338
|
-
case INPUT_TYPE_NAMES.OBJECT_MAPPER:
|
339
|
-
this.currentInput.value = 'clicked';
|
340
|
-
break;
|
341
|
-
case INPUT_TYPE_NAMES.CHECKBOX:
|
342
|
-
this.currentInput.value = event.detail.checked;
|
343
|
-
break;
|
344
|
-
case INPUT_TYPE_NAMES.CODE_EDITOR:
|
345
|
-
this.currentInput.value = event.detail.value;
|
346
|
-
break;
|
347
|
-
default:
|
348
|
-
this.currentInput.value = event.detail.value;
|
289
|
+
toggleField() {
|
290
|
+
if (!this.nileSwitchConfig.confirmation) {
|
291
|
+
this.nileSwitchConfig = {
|
292
|
+
...this.nileSwitchConfig,
|
293
|
+
toggleSwitch: !this.nileSwitchConfig.toggleSwitch,
|
294
|
+
};
|
349
295
|
}
|
350
|
-
|
351
|
-
this.emit('nile-change', { input: this.currentInput });
|
296
|
+
this.emit('nile-switch', { config: this.nileSwitchConfig });
|
352
297
|
}
|
353
298
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
299
|
+
singleFieldSwitcher(
|
300
|
+
defaultInput: switchInputType,
|
301
|
+
switchInput: switchInputType,
|
302
|
+
toggleField: boolean,
|
303
|
+
disable: boolean
|
304
|
+
) {
|
305
|
+
const defaultInputType = defaultInput.inputType;
|
306
|
+
const switchInputType = switchInput.inputType;
|
359
307
|
return html`
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
308
|
+
${!toggleField
|
309
|
+
? choose(
|
310
|
+
defaultInputType,
|
311
|
+
[
|
312
|
+
[
|
313
|
+
INPUT_TYPE_NAMES.TEXT,
|
314
|
+
() => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT),
|
315
|
+
],
|
316
|
+
[
|
317
|
+
INPUT_TYPE_NAMES.CHECKBOX,
|
318
|
+
() => this.renderNileCheckBox(defaultInput, INPUT_TYPE.DEFAULT),
|
319
|
+
],
|
320
|
+
[
|
321
|
+
INPUT_TYPE_NAMES.TEXTAREA,
|
322
|
+
() => this.renderNileTextArea(defaultInput, INPUT_TYPE.DEFAULT),
|
323
|
+
],
|
324
|
+
[
|
325
|
+
INPUT_TYPE_NAMES.RADIO,
|
326
|
+
() => this.renderNileRadio(defaultInput, INPUT_TYPE.DEFAULT),
|
327
|
+
],
|
328
|
+
[
|
329
|
+
INPUT_TYPE_NAMES.DROPDOWN,
|
330
|
+
() =>
|
331
|
+
this.renderDropdown(
|
332
|
+
this.nileSwitchConfig.defaultInput,
|
333
|
+
INPUT_TYPE.DEFAULT
|
334
|
+
),
|
335
|
+
],
|
336
|
+
[
|
337
|
+
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
338
|
+
() =>
|
339
|
+
this.renderContentEditor(
|
340
|
+
this.nileSwitchConfig.defaultInput,
|
341
|
+
INPUT_TYPE.DEFAULT
|
342
|
+
),
|
343
|
+
],
|
344
|
+
],
|
345
|
+
() => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT)
|
346
|
+
)
|
347
|
+
: choose(
|
348
|
+
switchInputType,
|
349
|
+
[
|
350
|
+
[
|
351
|
+
INPUT_TYPE_NAMES.TEXTAREA,
|
352
|
+
() => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH),
|
353
|
+
],
|
354
|
+
[
|
355
|
+
INPUT_TYPE_NAMES.TEXT,
|
356
|
+
() => this.renderNileText(switchInput, INPUT_TYPE.SWITCH),
|
357
|
+
],
|
358
|
+
[
|
359
|
+
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
360
|
+
() => this.renderContentEditor(switchInput, INPUT_TYPE.SWITCH),
|
361
|
+
],
|
362
|
+
],
|
363
|
+
|
364
|
+
() => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH)
|
365
|
+
)}
|
366
|
+
${!disable ? this.renderIcon(defaultInput, switchInput) : ''}
|
388
367
|
`;
|
389
368
|
}
|
390
|
-
|
391
|
-
toggleField(currentInput: switchInputType, index: Number) {
|
392
|
-
if (this.nileSwitchConfig.confirmation) {
|
393
|
-
this.current = index;
|
394
|
-
}
|
395
|
-
this.emit('nile-switch', { input: this.currentInput });
|
396
|
-
}
|
397
|
-
|
398
|
-
singleFieldSwitcher() {
|
399
|
-
if (!this.currentInput) {
|
400
|
-
this.setCurrentInput();
|
401
|
-
}
|
402
|
-
return html`
|
403
|
-
${choose(
|
404
|
-
this.currentInput.inputType,
|
405
|
-
[
|
406
|
-
[INPUT_TYPE_NAMES.TEXT, () => this.renderNileText(this.currentInput)],
|
407
|
-
[
|
408
|
-
INPUT_TYPE_NAMES.CHECKBOX,
|
409
|
-
() => this.renderNileCheckBox(this.currentInput),
|
410
|
-
],
|
411
|
-
[
|
412
|
-
INPUT_TYPE_NAMES.TEXTAREA,
|
413
|
-
() => this.renderNileTextArea(this.currentInput),
|
414
|
-
],
|
415
|
-
[
|
416
|
-
INPUT_TYPE_NAMES.RADIO,
|
417
|
-
() => this.renderNileRadio(this.currentInput),
|
418
|
-
],
|
419
|
-
[
|
420
|
-
INPUT_TYPE_NAMES.DROPDOWN,
|
421
|
-
() => this.renderDropdown(this.currentInput),
|
422
|
-
],
|
423
|
-
[
|
424
|
-
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
425
|
-
() => this.renderContentEditor(this.currentInput),
|
426
|
-
],
|
427
|
-
[INPUT_TYPE_NAMES.OBJECT_MAPPER, () => this.renderObjectMapper()],
|
428
|
-
[
|
429
|
-
INPUT_TYPE_NAMES.CODE_EDITOR,
|
430
|
-
() => this.renderCodeEditor(this.currentInput),
|
431
|
-
],
|
432
|
-
],
|
433
|
-
() => this.renderNileText(this.currentInput)
|
434
|
-
)}
|
435
|
-
`;
|
436
|
-
}
|
437
|
-
|
438
369
|
public render(): TemplateResult {
|
439
|
-
const
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
part="switcher-label"
|
454
|
-
class="switcher__label"
|
455
|
-
for="input"
|
456
|
-
>
|
457
|
-
<slot name="label"></slot>
|
458
|
-
</label>
|
459
|
-
</div> `
|
460
|
-
: ''}
|
461
|
-
${this.renderIcon()}
|
462
|
-
</div>
|
463
|
-
${this.singleFieldSwitcher()}
|
370
|
+
const {
|
371
|
+
toggleSwitch: toggleField,
|
372
|
+
defaultInput,
|
373
|
+
switchInput,
|
374
|
+
disable,
|
375
|
+
} = this.nileSwitchConfig;
|
376
|
+
|
377
|
+
return html`<div class="input-container">
|
378
|
+
${this.singleFieldSwitcher(
|
379
|
+
defaultInput,
|
380
|
+
switchInput,
|
381
|
+
toggleField,
|
382
|
+
!!disable
|
383
|
+
)}
|
464
384
|
</div>`;
|
465
385
|
}
|
466
386
|
}
|