@aquera/nile-elements 0.0.36-3 → 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-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-switcher/nile-switcher.css.js +5 -73
- 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 -39
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +111 -217
- 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 +340 -454
- 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-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 -75
- package/dist/nile-switcher/nile-switcher.esm.js +51 -101
- 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-switcher/nile-switcher.css.js +5 -73
- package/dist/src/nile-switcher/nile-switcher.css.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.d.ts +17 -39
- package/dist/src/nile-switcher/nile-switcher.js +111 -217
- 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-content-editor/nile-content-editor.css.ts +0 -1
- package/src/nile-switcher/nile-switcher.css.ts +5 -73
- package/src/nile-switcher/nile-switcher.ts +172 -255
@@ -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,205 +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="switcher-code-editor"
|
317
|
-
class=${classMap({
|
318
|
-
'code-editor': true,
|
319
|
-
})}
|
320
|
-
@nile-expand="${(e: CustomEvent) =>
|
321
|
-
this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
322
|
-
@nile-change="${(e: CustomEvent) =>
|
323
|
-
this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
324
|
-
.multiline="${multiLine}"
|
325
|
-
.value="${value}"
|
326
|
-
.customOptions="${customAutoCompletions}"
|
327
|
-
></nile-code-editor> `;
|
284
|
+
@click=${this.toggleField}
|
285
|
+
></nile-icon>
|
286
|
+
</nile-tooltip>`;
|
328
287
|
}
|
329
288
|
|
330
|
-
|
331
|
-
this.
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
switch (inputType) {
|
337
|
-
case INPUT_TYPE_NAMES.OBJECT_MAPPER:
|
338
|
-
this.currentInput.value = 'clicked';
|
339
|
-
break;
|
340
|
-
case INPUT_TYPE_NAMES.CHECKBOX:
|
341
|
-
this.currentInput.value = event.detail.checked;
|
342
|
-
break;
|
343
|
-
case INPUT_TYPE_NAMES.CODE_EDITOR:
|
344
|
-
this.currentInput.value = event.detail.value;
|
345
|
-
break;
|
346
|
-
default:
|
347
|
-
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
|
+
};
|
348
295
|
}
|
349
|
-
|
350
|
-
this.emit('nile-change', { input: this.currentInput });
|
296
|
+
this.emit('nile-switch', { config: this.nileSwitchConfig });
|
351
297
|
}
|
352
298
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
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;
|
358
307
|
return html`
|
359
|
-
|
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
|
-
|
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) : ''}
|
387
367
|
`;
|
388
368
|
}
|
389
|
-
|
390
|
-
isToggleSwitch = (item: any) => {
|
391
|
-
return typeof item === 'undefined' || item;
|
392
|
-
};
|
393
|
-
|
394
|
-
toggleField(currentInput: switchInputType, index: Number) {
|
395
|
-
this.emit('nile-switch', {
|
396
|
-
inputClicked: index,
|
397
|
-
currentInput: currentInput,
|
398
|
-
});
|
399
|
-
}
|
400
|
-
|
401
|
-
singleFieldSwitcher() {
|
402
|
-
if (!this.currentInput) {
|
403
|
-
this.setCurrentInput();
|
404
|
-
}
|
405
|
-
return html`
|
406
|
-
${choose(
|
407
|
-
this.currentInput.inputType,
|
408
|
-
[
|
409
|
-
[INPUT_TYPE_NAMES.TEXT, () => this.renderNileText(this.currentInput)],
|
410
|
-
[
|
411
|
-
INPUT_TYPE_NAMES.CHECKBOX,
|
412
|
-
() => this.renderNileCheckBox(this.currentInput),
|
413
|
-
],
|
414
|
-
[
|
415
|
-
INPUT_TYPE_NAMES.TEXTAREA,
|
416
|
-
() => this.renderNileTextArea(this.currentInput),
|
417
|
-
],
|
418
|
-
[
|
419
|
-
INPUT_TYPE_NAMES.RADIO,
|
420
|
-
() => this.renderNileRadio(this.currentInput),
|
421
|
-
],
|
422
|
-
[
|
423
|
-
INPUT_TYPE_NAMES.DROPDOWN,
|
424
|
-
() => this.renderDropdown(this.currentInput),
|
425
|
-
],
|
426
|
-
[
|
427
|
-
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
428
|
-
() => this.renderContentEditor(this.currentInput),
|
429
|
-
],
|
430
|
-
[INPUT_TYPE_NAMES.OBJECT_MAPPER, () => this.renderObjectMapper()],
|
431
|
-
[
|
432
|
-
INPUT_TYPE_NAMES.CODE_EDITOR,
|
433
|
-
() => this.renderCodeEditor(this.currentInput),
|
434
|
-
],
|
435
|
-
],
|
436
|
-
() => this.renderNileText(this.currentInput)
|
437
|
-
)}
|
438
|
-
`;
|
439
|
-
}
|
440
|
-
|
441
369
|
public render(): TemplateResult {
|
442
|
-
const
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
part="switcher-label"
|
457
|
-
class="switcher__label"
|
458
|
-
for="input"
|
459
|
-
>
|
460
|
-
<slot name="label"></slot>
|
461
|
-
</label>
|
462
|
-
</div> `
|
463
|
-
: ''}
|
464
|
-
${this.renderIcon()}
|
465
|
-
</div>
|
466
|
-
${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
|
+
)}
|
467
384
|
</div>`;
|
468
385
|
}
|
469
386
|
}
|