@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
@@ -17,92 +17,24 @@ export const styles = css `
|
|
17
17
|
.pointer-cursor {
|
18
18
|
cursor: pointer;
|
19
19
|
}
|
20
|
-
|
21
|
-
.switcher__label {
|
22
|
-
display: flex;
|
23
|
-
align-items: center;
|
24
|
-
color: inherit;
|
25
|
-
color: var(--nile-colors-dark-900);
|
26
|
-
font-family: Colfax-regular;
|
27
|
-
font-size: 14px;
|
28
|
-
font-style: normal;
|
29
|
-
font-weight: 400;
|
30
|
-
line-height: 14px;
|
31
|
-
letter-spacing: 0.2px;
|
32
|
-
}
|
33
|
-
|
34
|
-
switcher-object-mapper:hover {
|
35
|
-
display: flex;
|
36
|
-
}
|
37
|
-
.switcher-icon-container.current {
|
38
|
-
background: var(--nile-colors-primary-100);
|
39
|
-
}
|
40
|
-
|
41
|
-
.switcher-container {
|
20
|
+
.input-container {
|
42
21
|
display: flex;
|
43
|
-
}
|
44
|
-
|
45
|
-
.switcher-inline {
|
46
22
|
gap: 0.5rem;
|
47
23
|
}
|
48
24
|
|
49
|
-
.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
.switcher-inline > :nth-child(2) {
|
54
|
-
flex: 1;
|
55
|
-
overflow: hidden;
|
25
|
+
.input-container > :first-child {
|
26
|
+
max-width: 98%;
|
27
|
+
min-width: 98%;
|
56
28
|
}
|
57
29
|
|
58
|
-
|
59
|
-
display: flex;
|
60
|
-
margin-left: auto;
|
61
|
-
gap: 0.5rem;
|
30
|
+
nile-icon {
|
62
31
|
max-height: 38px;
|
63
|
-
align-items: center;
|
64
|
-
}
|
65
|
-
|
66
|
-
.switcher-block > .switcher-icons-container {
|
67
|
-
margin-left: auto;
|
68
|
-
}
|
69
|
-
|
70
|
-
.label-container {
|
71
|
-
display: flex;
|
72
32
|
}
|
73
33
|
|
74
|
-
.switcher-icon-container {
|
75
|
-
cursor: pointer;
|
76
|
-
justify-content: center;
|
77
|
-
display: flex;
|
78
|
-
align-items: center;
|
79
|
-
margin-bottom: 6px;
|
80
|
-
height: 28px;
|
81
|
-
width: 28px;
|
82
|
-
border-radius: 4px;
|
83
|
-
}
|
84
34
|
nile-radio {
|
85
35
|
display: inline-block;
|
86
36
|
padding-right: 10px;
|
87
37
|
}
|
88
|
-
|
89
|
-
.switcher-object-mapper-icon {
|
90
|
-
display: none;
|
91
|
-
}
|
92
|
-
.switcher-object-mapper:hover > .switcher-object-mapper-icon {
|
93
|
-
display: block;
|
94
|
-
}
|
95
|
-
.switcher-object-mapper::part(input) {
|
96
|
-
color: var(--nile-colors-primary-600);
|
97
|
-
cursor: pointer;
|
98
|
-
}
|
99
|
-
|
100
|
-
.switcher-input--noborder::part(base) {
|
101
|
-
border: none;
|
102
|
-
}
|
103
|
-
.switcher-object-mapper--noborder::part(base) {
|
104
|
-
border: none;
|
105
|
-
}
|
106
38
|
`;
|
107
39
|
export default [styles];
|
108
40
|
//# sourceMappingURL=nile-switcher.css.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-switcher.css.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
1
|
+
{"version":3,"file":"nile-switcher.css.js","sourceRoot":"","sources":["../../../src/nile-switcher/nile-switcher.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * FieldGenerator CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n }\n\n .pointer-cursor {\n cursor: pointer;\n }\n .input-container {\n display: flex;\n gap: 0.5rem;\n }\n\n .input-container > :first-child {\n max-width: 98%;\n min-width: 98%;\n }\n\n nile-icon {\n max-height: 38px;\n }\n\n nile-radio {\n display: inline-block;\n padding-right: 10px;\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -9,48 +9,41 @@ import NileElement from '../internal/nile-element';
|
|
9
9
|
import { CSSResultGroup } from 'lit';
|
10
10
|
/**
|
11
11
|
* @summary Allows you to switch between nile elements
|
12
|
-
|
12
|
+
|
13
13
|
* @dependency nile-icon
|
14
14
|
* @dependency nile-input
|
15
15
|
* @dependency nile-checkbox
|
16
16
|
* @dependency nile-dropdown
|
17
17
|
* @dependency nile-textarea
|
18
18
|
*
|
19
|
+
|
19
20
|
* @event nile-change - Emitted when the control's value changes.
|
20
21
|
* @event nile-switch - Emitted when the nile component is being switched.
|
22
|
+
|
21
23
|
*/
|
22
24
|
export interface switchconfig {
|
23
25
|
[key: string]: any;
|
24
26
|
toggleSwitch: boolean;
|
25
27
|
disable?: boolean;
|
26
28
|
confirmation?: boolean;
|
27
|
-
|
28
|
-
|
29
|
+
defaultInput: switchInputType;
|
30
|
+
switchInput: switchInputType;
|
29
31
|
}
|
30
32
|
export interface switchInputType {
|
31
|
-
inputType: INPUT_TYPE_NAMES.DROPDOWN | INPUT_TYPE_NAMES.TEXT | INPUT_TYPE_NAMES.CHECKBOX | INPUT_TYPE_NAMES.TEXTAREA | INPUT_TYPE_NAMES.RADIO | INPUT_TYPE_NAMES.CONTENTEDITOR
|
33
|
+
inputType: INPUT_TYPE_NAMES.DROPDOWN | INPUT_TYPE_NAMES.TEXT | INPUT_TYPE_NAMES.CHECKBOX | INPUT_TYPE_NAMES.TEXTAREA | INPUT_TYPE_NAMES.RADIO | INPUT_TYPE_NAMES.CONTENTEDITOR;
|
32
34
|
value?: String | boolean;
|
33
35
|
label?: String;
|
34
36
|
readonly?: boolean;
|
35
37
|
type?: string;
|
36
|
-
icon: string;
|
37
|
-
mode?: string;
|
38
38
|
placeholder?: string;
|
39
39
|
disabled?: boolean;
|
40
40
|
required?: boolean;
|
41
41
|
error?: boolean;
|
42
42
|
errorMessage?: string;
|
43
43
|
options?: Array<any>;
|
44
|
-
customAutoCompletions?: any;
|
45
44
|
helperText?: string;
|
46
45
|
multiple?: boolean;
|
47
46
|
noborder?: boolean;
|
48
|
-
multiLine?: boolean;
|
49
|
-
expand?: boolean;
|
50
|
-
}
|
51
|
-
export declare enum POSITIONS {
|
52
|
-
INLINE = "inline",
|
53
|
-
BLOCK = "block"
|
54
47
|
}
|
55
48
|
export declare enum INPUT_TYPE {
|
56
49
|
DEFAULT = "defaultInput",
|
@@ -62,13 +55,7 @@ export declare enum INPUT_TYPE_NAMES {
|
|
62
55
|
CHECKBOX = "checkbox",
|
63
56
|
TEXTAREA = "text-area",
|
64
57
|
RADIO = "radio",
|
65
|
-
CONTENTEDITOR = "content-editor"
|
66
|
-
OBJECT_MAPPER = "object-mapper",
|
67
|
-
CODE_EDITOR = "code-editor"
|
68
|
-
}
|
69
|
-
export declare enum MODE {
|
70
|
-
CREATE = "create",
|
71
|
-
EDIT = "edit"
|
58
|
+
CONTENTEDITOR = "content-editor"
|
72
59
|
}
|
73
60
|
export declare class NileSwitcher extends NileElement {
|
74
61
|
/**
|
@@ -76,29 +63,20 @@ export declare class NileSwitcher extends NileElement {
|
|
76
63
|
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
77
64
|
*/
|
78
65
|
static styles: CSSResultGroup;
|
79
|
-
private readonly hasSlotController;
|
80
66
|
nileSwitchConfig: switchconfig;
|
81
|
-
current: Number;
|
82
|
-
currentInput: switchInputType;
|
83
67
|
connectedCallback(): void;
|
84
|
-
handleSwitcherChange(): void;
|
85
|
-
setCurrentInput(): void;
|
86
68
|
disconnectedCallback(): void;
|
87
|
-
renderNileText(Input: switchInputType): TemplateResult<1>;
|
88
|
-
renderDropdown(Input: switchInputType): TemplateResult<1>;
|
89
|
-
renderNileTextArea(Input: switchInputType): TemplateResult<1>;
|
90
|
-
renderNileCheckBox(Input: switchInputType): TemplateResult<1>;
|
91
|
-
renderNileRadio(Input: switchInputType): TemplateResult<1>;
|
69
|
+
renderNileText(Input: switchInputType, inputType: string): TemplateResult<1>;
|
70
|
+
renderDropdown(Input: switchInputType, inputType: string): TemplateResult<1>;
|
71
|
+
renderNileTextArea(Input: switchInputType, inputType: string): TemplateResult<1>;
|
72
|
+
renderNileCheckBox(Input: switchInputType, inputType: string): TemplateResult<1>;
|
73
|
+
renderNileRadio(Input: switchInputType, inputType: string): TemplateResult<1>;
|
92
74
|
renderErrorMessage(errorMessage: string): TemplateResult<1>;
|
93
|
-
renderContentEditor(Input: switchInputType): TemplateResult<1>;
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
renderIcon(): TemplateResult<1>;
|
99
|
-
isToggleSwitch: (item: any) => any;
|
100
|
-
toggleField(currentInput: switchInputType, index: Number): void;
|
101
|
-
singleFieldSwitcher(): TemplateResult<1>;
|
75
|
+
renderContentEditor(Input: switchInputType, inputType: string): TemplateResult<1>;
|
76
|
+
handleChange(event: CustomEvent, inputType: string, inputTypeName: string): void;
|
77
|
+
renderIcon(defaultInput: switchInputType, switchInput: switchInputType): TemplateResult<1>;
|
78
|
+
toggleField(): void;
|
79
|
+
singleFieldSwitcher(defaultInput: switchInputType, switchInput: switchInputType, toggleField: boolean, disable: boolean): TemplateResult<1>;
|
102
80
|
render(): TemplateResult;
|
103
81
|
}
|
104
82
|
export default NileSwitcher;
|
@@ -11,14 +11,6 @@ import { styles } from './nile-switcher.css';
|
|
11
11
|
import NileElement from '../internal/nile-element';
|
12
12
|
import { choose } from 'lit/directives/choose.js';
|
13
13
|
import { classMap } from 'lit/directives/class-map.js';
|
14
|
-
import { repeat } from 'lit/directives/repeat.js';
|
15
|
-
import { watch } from '../internal/watch';
|
16
|
-
import { HasSlotController } from '../internal/slot';
|
17
|
-
export var POSITIONS;
|
18
|
-
(function (POSITIONS) {
|
19
|
-
POSITIONS["INLINE"] = "inline";
|
20
|
-
POSITIONS["BLOCK"] = "block";
|
21
|
-
})(POSITIONS || (POSITIONS = {}));
|
22
14
|
export var INPUT_TYPE;
|
23
15
|
(function (INPUT_TYPE) {
|
24
16
|
INPUT_TYPE["DEFAULT"] = "defaultInput";
|
@@ -32,48 +24,19 @@ export var INPUT_TYPE_NAMES;
|
|
32
24
|
INPUT_TYPE_NAMES["TEXTAREA"] = "text-area";
|
33
25
|
INPUT_TYPE_NAMES["RADIO"] = "radio";
|
34
26
|
INPUT_TYPE_NAMES["CONTENTEDITOR"] = "content-editor";
|
35
|
-
INPUT_TYPE_NAMES["OBJECT_MAPPER"] = "object-mapper";
|
36
|
-
INPUT_TYPE_NAMES["CODE_EDITOR"] = "code-editor";
|
37
27
|
})(INPUT_TYPE_NAMES || (INPUT_TYPE_NAMES = {}));
|
38
|
-
export var MODE;
|
39
|
-
(function (MODE) {
|
40
|
-
MODE["CREATE"] = "create";
|
41
|
-
MODE["EDIT"] = "edit";
|
42
|
-
})(MODE || (MODE = {}));
|
43
28
|
let NileSwitcher = class NileSwitcher extends NileElement {
|
44
|
-
constructor() {
|
45
|
-
super(...arguments);
|
46
|
-
this.hasSlotController = new HasSlotController(this, 'label');
|
47
|
-
this.current = 0;
|
48
|
-
this.isToggleSwitch = (item) => {
|
49
|
-
return typeof item === 'undefined' || item;
|
50
|
-
};
|
51
|
-
}
|
52
29
|
connectedCallback() {
|
53
30
|
super.connectedCallback();
|
54
31
|
this.emit('nile-init');
|
55
32
|
}
|
56
|
-
handleSwitcherChange() {
|
57
|
-
this.setCurrentInput();
|
58
|
-
}
|
59
|
-
setCurrentInput() {
|
60
|
-
if (this.nileSwitchConfig?.inputs) {
|
61
|
-
this.currentInput = this.nileSwitchConfig.inputs.filter((input, index) => {
|
62
|
-
return index === this.current;
|
63
|
-
})[0];
|
64
|
-
}
|
65
|
-
}
|
66
33
|
disconnectedCallback() {
|
67
34
|
super.disconnectedCallback();
|
68
35
|
this.emit('nile-destroy');
|
69
36
|
}
|
70
|
-
renderNileText(Input) {
|
71
|
-
const { value, label, placeholder, disabled, required, error, errorMessage, inputType
|
37
|
+
renderNileText(Input, inputType) {
|
38
|
+
const { value, label, placeholder, disabled, required, error, errorMessage, inputType: inputTypeName, } = Input;
|
72
39
|
return html `<nile-input
|
73
|
-
class=${classMap({
|
74
|
-
'switcher-input': true,
|
75
|
-
'switcher-input--noborder': !!noborder,
|
76
|
-
})}
|
77
40
|
.value=${value}
|
78
41
|
.label=${label}
|
79
42
|
.disabled=${disabled}
|
@@ -82,15 +45,13 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
82
45
|
.placeholder=${placeholder}
|
83
46
|
.error=${error}
|
84
47
|
@nile-input=${(e) => {
|
85
|
-
this.handleChange(e, inputType);
|
48
|
+
this.handleChange(e, inputType, inputTypeName);
|
86
49
|
}}
|
87
50
|
></nile-input>`;
|
88
51
|
}
|
89
|
-
renderDropdown(Input) {
|
90
|
-
const { options, multiple, placeholder, disabled, value, error, errorMessage, inputType, } = Input;
|
52
|
+
renderDropdown(Input, inputType) {
|
53
|
+
const { options, multiple, placeholder, disabled, value, error, errorMessage, inputType: inputTypeName, } = Input;
|
91
54
|
return html `<nile-select
|
92
|
-
part="dropdown"
|
93
|
-
class="switcher-dropdown"
|
94
55
|
.placeholder=${placeholder}
|
95
56
|
.disabled="${disabled}"
|
96
57
|
.multiple="${multiple}"
|
@@ -98,7 +59,7 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
98
59
|
.error="${error}"
|
99
60
|
.errorMessage="${errorMessage}"
|
100
61
|
@nile-change=${(e) => {
|
101
|
-
this.handleChange(e, inputType);
|
62
|
+
this.handleChange(e, inputType, inputTypeName);
|
102
63
|
}}
|
103
64
|
>
|
104
65
|
${options?.map((option) => {
|
@@ -106,42 +67,39 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
106
67
|
})}
|
107
68
|
</nile-select>`;
|
108
69
|
}
|
109
|
-
renderNileTextArea(Input) {
|
110
|
-
const { value, disabled, readonly, errorMessage, error, inputType } = Input;
|
70
|
+
renderNileTextArea(Input, inputType) {
|
71
|
+
const { value, disabled, readonly, errorMessage, error, inputType: inputTypeName, } = Input;
|
111
72
|
return html `<nile-textarea
|
112
|
-
class="switcher-textarea"
|
113
73
|
.value=${value}
|
114
74
|
.disabled=${disabled}
|
115
75
|
?readonly=${readonly}
|
116
76
|
.error=${error}
|
117
77
|
.errorMessage=${errorMessage}
|
118
78
|
@nile-input=${(e) => {
|
119
|
-
this.handleChange(e, inputType);
|
79
|
+
this.handleChange(e, inputType, inputTypeName);
|
120
80
|
}}
|
121
81
|
></nile-textarea>`;
|
122
82
|
}
|
123
|
-
renderNileCheckBox(Input) {
|
124
|
-
const { value, label, disabled, inputType } = Input;
|
83
|
+
renderNileCheckBox(Input, inputType) {
|
84
|
+
const { value, label, disabled, inputType: inputTypeName } = Input;
|
125
85
|
return html `<nile-checkbox
|
126
|
-
class="switcher-checkbox"
|
127
86
|
.checked=${value}
|
128
87
|
.label=${label}
|
129
88
|
.disabled=${disabled}
|
130
89
|
@valueChange=${(e) => {
|
131
|
-
this.handleChange(e, inputType);
|
90
|
+
this.handleChange(e, inputType, inputTypeName);
|
132
91
|
}}
|
133
92
|
></nile-checkbox
|
134
93
|
>; `;
|
135
94
|
}
|
136
|
-
renderNileRadio(Input) {
|
137
|
-
const { options, value, disabled, errorMessage,
|
95
|
+
renderNileRadio(Input, inputType) {
|
96
|
+
const { options, value, disabled, inputType: inputTypeName, errorMessage, } = Input;
|
138
97
|
const haserrorMessage = !!errorMessage;
|
139
98
|
return html `<nile-radio-group
|
140
|
-
class="switcher-radio-group"
|
141
99
|
.value=${value}
|
142
100
|
.disabled=${disabled}
|
143
101
|
@change=${(e) => {
|
144
|
-
this.handleChange(e, inputType);
|
102
|
+
this.handleChange(e, inputType, inputTypeName);
|
145
103
|
}}
|
146
104
|
>
|
147
105
|
${options &&
|
@@ -156,10 +114,9 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
156
114
|
<nile-form-error-message>${errorMessage}</nile-form-error-message>
|
157
115
|
`;
|
158
116
|
}
|
159
|
-
renderContentEditor(Input) {
|
160
|
-
let { options, inputType, errorMessage, type, readonly, noborder, value } = Input;
|
117
|
+
renderContentEditor(Input, inputType) {
|
118
|
+
let { options, inputType: inputTypeName, errorMessage, type, readonly, noborder, value, } = Input;
|
161
119
|
return html `<nile-content-editor
|
162
|
-
class="switcher-content-editor"
|
163
120
|
.value=${value}
|
164
121
|
.options=${options}
|
165
122
|
.type=${type}
|
@@ -167,169 +124,115 @@ let NileSwitcher = class NileSwitcher extends NileElement {
|
|
167
124
|
.noborder=${noborder}
|
168
125
|
.errorMessage=${errorMessage}
|
169
126
|
@nile-change=${(e) => {
|
170
|
-
this.handleChange(e, inputType);
|
127
|
+
this.handleChange(e, inputType, inputTypeName);
|
171
128
|
}}
|
172
129
|
>
|
173
130
|
</nile-content-editor>`;
|
174
131
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
132
|
+
handleChange(event, inputType, inputTypeName) {
|
133
|
+
if (inputTypeName === INPUT_TYPE_NAMES.CHECKBOX) {
|
134
|
+
this.nileSwitchConfig[inputType].value =
|
135
|
+
event.detail.checked;
|
136
|
+
}
|
137
|
+
else {
|
138
|
+
this.nileSwitchConfig[inputType].value =
|
139
|
+
event.detail.value;
|
140
|
+
}
|
141
|
+
event.stopPropagation();
|
142
|
+
this.emit('nile-change', { config: this.nileSwitchConfig });
|
143
|
+
}
|
144
|
+
renderIcon(defaultInput, switchInput) {
|
145
|
+
const defaultHelperText = defaultInput.helperText;
|
146
|
+
const switchHelperText = switchInput.helperText;
|
147
|
+
const icon = !this.nileSwitchConfig.toggleSwitch
|
148
|
+
? 'header-functions'
|
149
|
+
: 'stringinput';
|
150
|
+
const helperText = !this.nileSwitchConfig.toggleSwitch
|
151
|
+
? !!switchHelperText
|
152
|
+
? switchHelperText
|
153
|
+
: `switch to ${switchInput.inputType}`
|
154
|
+
: !!defaultHelperText
|
155
|
+
? defaultHelperText
|
156
|
+
: `switch to ${defaultInput.inputType}`;
|
157
|
+
return html ` <nile-tooltip
|
182
158
|
class=${classMap({
|
183
|
-
'
|
184
|
-
'switcher-object-mapper--noborder': !!noborder,
|
159
|
+
'tooltip-container': true,
|
185
160
|
})}
|
186
|
-
|
187
|
-
|
188
|
-
@click="${(e) => this.handleChange(e, INPUT_TYPE_NAMES.OBJECT_MAPPER)}"
|
161
|
+
content=${helperText}
|
162
|
+
placement="bottom"
|
189
163
|
>
|
190
164
|
<nile-icon
|
191
|
-
|
192
|
-
|
193
|
-
name="collapse"
|
194
|
-
color="#005EA6"
|
195
|
-
size="16"
|
196
|
-
>
|
197
|
-
</nile-icon>
|
198
|
-
</nile-input>`;
|
199
|
-
}
|
200
|
-
renderCodeEditor(Input) {
|
201
|
-
const { value, multiLine, customAutoCompletions, disabled, readonly, errorMessage, error, inputType, noborder, } = Input;
|
202
|
-
return html `<nile-code-editor
|
203
|
-
part="switcher-code-editor"
|
204
|
-
class=${classMap({
|
205
|
-
'code-editor': true,
|
206
|
-
})}
|
207
|
-
@nile-expand="${(e) => this.handleExpand(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
208
|
-
@nile-change="${(e) => this.handleChange(e, INPUT_TYPE_NAMES.CODE_EDITOR)}"
|
209
|
-
.multiline="${multiLine}"
|
210
|
-
.value="${value}"
|
211
|
-
.customOptions="${customAutoCompletions}"
|
212
|
-
></nile-code-editor> `;
|
213
|
-
}
|
214
|
-
handleExpand(event, inputType) {
|
215
|
-
this.currentInput.expand = event.detail.expand;
|
216
|
-
this.emit('nile-change', { input: this.currentInput });
|
217
|
-
}
|
218
|
-
handleChange(event, inputType) {
|
219
|
-
switch (inputType) {
|
220
|
-
case INPUT_TYPE_NAMES.OBJECT_MAPPER:
|
221
|
-
this.currentInput.value = 'clicked';
|
222
|
-
break;
|
223
|
-
case INPUT_TYPE_NAMES.CHECKBOX:
|
224
|
-
this.currentInput.value = event.detail.checked;
|
225
|
-
break;
|
226
|
-
case INPUT_TYPE_NAMES.CODE_EDITOR:
|
227
|
-
this.currentInput.value = event.detail.value;
|
228
|
-
break;
|
229
|
-
default:
|
230
|
-
this.currentInput.value = event.detail.value;
|
231
|
-
}
|
232
|
-
event.stopPropagation();
|
233
|
-
this.emit('nile-change', { input: this.currentInput });
|
234
|
-
}
|
235
|
-
renderIcon() {
|
236
|
-
const inputs = this.nileSwitchConfig.inputs;
|
237
|
-
const toolTipPosition = this.nileSwitchConfig.align === POSITIONS.BLOCK ? 'top' : 'bottom';
|
238
|
-
return html `
|
239
|
-
<div part="icons-container" class="switcher-icons-container">
|
240
|
-
${repeat(inputs, (input, index) => html ` <nile-tooltip
|
241
|
-
class=${classMap({
|
242
|
-
'switcher-tooltip-container': true,
|
243
|
-
})}
|
244
|
-
content=${input.helperText}
|
245
|
-
placement=${toolTipPosition}
|
246
|
-
>
|
247
|
-
<div class=${classMap({
|
248
|
-
'switcher-icon-container': true,
|
249
|
-
current: index === this.current,
|
250
|
-
})}>
|
251
|
-
<nile-icon
|
252
|
-
size="16"
|
253
|
-
class=${classMap({
|
165
|
+
size="14"
|
166
|
+
class=${classMap({
|
254
167
|
'pointer-cursor': true,
|
255
168
|
})}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
inputClicked: index,
|
269
|
-
currentInput: currentInput,
|
270
|
-
});
|
271
|
-
}
|
272
|
-
singleFieldSwitcher() {
|
273
|
-
if (!this.currentInput) {
|
274
|
-
this.setCurrentInput();
|
169
|
+
.name=${icon}
|
170
|
+
color="#005EA6"
|
171
|
+
@click=${this.toggleField}
|
172
|
+
></nile-icon>
|
173
|
+
</nile-tooltip>`;
|
174
|
+
}
|
175
|
+
toggleField() {
|
176
|
+
if (!this.nileSwitchConfig.confirmation) {
|
177
|
+
this.nileSwitchConfig = {
|
178
|
+
...this.nileSwitchConfig,
|
179
|
+
toggleSwitch: !this.nileSwitchConfig.toggleSwitch,
|
180
|
+
};
|
275
181
|
}
|
182
|
+
this.emit('nile-switch', { config: this.nileSwitchConfig });
|
183
|
+
}
|
184
|
+
singleFieldSwitcher(defaultInput, switchInput, toggleField, disable) {
|
185
|
+
const defaultInputType = defaultInput.inputType;
|
186
|
+
const switchInputType = switchInput.inputType;
|
276
187
|
return html `
|
277
|
-
${
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
],
|
304
|
-
|
188
|
+
${!toggleField
|
189
|
+
? choose(defaultInputType, [
|
190
|
+
[
|
191
|
+
INPUT_TYPE_NAMES.TEXT,
|
192
|
+
() => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT),
|
193
|
+
],
|
194
|
+
[
|
195
|
+
INPUT_TYPE_NAMES.CHECKBOX,
|
196
|
+
() => this.renderNileCheckBox(defaultInput, INPUT_TYPE.DEFAULT),
|
197
|
+
],
|
198
|
+
[
|
199
|
+
INPUT_TYPE_NAMES.TEXTAREA,
|
200
|
+
() => this.renderNileTextArea(defaultInput, INPUT_TYPE.DEFAULT),
|
201
|
+
],
|
202
|
+
[
|
203
|
+
INPUT_TYPE_NAMES.RADIO,
|
204
|
+
() => this.renderNileRadio(defaultInput, INPUT_TYPE.DEFAULT),
|
205
|
+
],
|
206
|
+
[
|
207
|
+
INPUT_TYPE_NAMES.DROPDOWN,
|
208
|
+
() => this.renderDropdown(this.nileSwitchConfig.defaultInput, INPUT_TYPE.DEFAULT),
|
209
|
+
],
|
210
|
+
[
|
211
|
+
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
212
|
+
() => this.renderContentEditor(this.nileSwitchConfig.defaultInput, INPUT_TYPE.DEFAULT),
|
213
|
+
],
|
214
|
+
], () => this.renderNileText(defaultInput, INPUT_TYPE.DEFAULT))
|
215
|
+
: choose(switchInputType, [
|
216
|
+
[
|
217
|
+
INPUT_TYPE_NAMES.TEXTAREA,
|
218
|
+
() => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH),
|
219
|
+
],
|
220
|
+
[
|
221
|
+
INPUT_TYPE_NAMES.TEXT,
|
222
|
+
() => this.renderNileText(switchInput, INPUT_TYPE.SWITCH),
|
223
|
+
],
|
224
|
+
[
|
225
|
+
INPUT_TYPE_NAMES.CONTENTEDITOR,
|
226
|
+
() => this.renderContentEditor(switchInput, INPUT_TYPE.SWITCH),
|
227
|
+
],
|
228
|
+
], () => this.renderNileTextArea(switchInput, INPUT_TYPE.SWITCH))}
|
229
|
+
${!disable ? this.renderIcon(defaultInput, switchInput) : ''}
|
305
230
|
`;
|
306
231
|
}
|
307
232
|
render() {
|
308
|
-
const
|
309
|
-
|
310
|
-
|
311
|
-
part="base"
|
312
|
-
class=${classMap({
|
313
|
-
'switcher-block': align === POSITIONS.BLOCK,
|
314
|
-
'switcher-inline': align === POSITIONS.INLINE,
|
315
|
-
'switcher-container': true,
|
316
|
-
})}
|
317
|
-
>
|
318
|
-
<div class="label-container">
|
319
|
-
${hasLabelSlot
|
320
|
-
? html `
|
321
|
-
<label
|
322
|
-
part="switcher-label"
|
323
|
-
class="switcher__label"
|
324
|
-
for="input"
|
325
|
-
>
|
326
|
-
<slot name="label"></slot>
|
327
|
-
</label>
|
328
|
-
</div> `
|
329
|
-
: ''}
|
330
|
-
${this.renderIcon()}
|
331
|
-
</div>
|
332
|
-
${this.singleFieldSwitcher()}
|
233
|
+
const { toggleSwitch: toggleField, defaultInput, switchInput, disable, } = this.nileSwitchConfig;
|
234
|
+
return html `<div class="input-container">
|
235
|
+
${this.singleFieldSwitcher(defaultInput, switchInput, toggleField, !!disable)}
|
333
236
|
</div>`;
|
334
237
|
}
|
335
238
|
};
|
@@ -341,15 +244,6 @@ NileSwitcher.styles = styles;
|
|
341
244
|
__decorate([
|
342
245
|
property({ type: Object })
|
343
246
|
], NileSwitcher.prototype, "nileSwitchConfig", void 0);
|
344
|
-
__decorate([
|
345
|
-
property({ type: Number })
|
346
|
-
], NileSwitcher.prototype, "current", void 0);
|
347
|
-
__decorate([
|
348
|
-
property({ type: Object })
|
349
|
-
], NileSwitcher.prototype, "currentInput", void 0);
|
350
|
-
__decorate([
|
351
|
-
watch(['current'], { waitUntilFirstUpdate: true })
|
352
|
-
], NileSwitcher.prototype, "handleSwitcherChange", null);
|
353
247
|
NileSwitcher = __decorate([
|
354
248
|
customElement('nile-switcher')
|
355
249
|
], NileSwitcher);
|