@unicef-polymer/etools-form-builder 2.1.0 → 2.1.2
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/LICENSE +674 -674
- package/README.md +1 -1
- package/dist/assets/translations.d.ts +6 -0
- package/dist/assets/translations.js +67 -0
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +86 -85
- package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
- package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
- package/dist/form-attachments-popup/form-attachments-popup.js +255 -248
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +91 -89
- package/dist/form-attachments-popup/index.d.ts +2 -2
- package/dist/form-attachments-popup/index.js +2 -2
- package/dist/form-fields/abstract-field-base.class.d.ts +33 -28
- package/dist/form-fields/abstract-field-base.class.js +194 -176
- package/dist/form-fields/field-renderer-component.d.ts +20 -20
- package/dist/form-fields/field-renderer-component.js +249 -249
- package/dist/form-fields/index.d.ts +12 -12
- package/dist/form-fields/index.js +12 -12
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +209 -208
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +124 -123
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +67 -66
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
- package/dist/form-fields/single-fields/attachment-field.js +98 -97
- package/dist/form-fields/single-fields/base-field.d.ts +11 -11
- package/dist/form-fields/single-fields/base-field.js +58 -57
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
- package/dist/form-fields/single-fields/boolean-field.js +49 -49
- package/dist/form-fields/single-fields/number-field.d.ts +10 -10
- package/dist/form-fields/single-fields/number-field.js +67 -66
- package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
- package/dist/form-fields/single-fields/scale-field.js +108 -107
- package/dist/form-fields/single-fields/text-field.d.ts +8 -8
- package/dist/form-fields/single-fields/text-field.js +54 -54
- package/dist/form-groups/form-abstract-group.d.ts +65 -60
- package/dist/form-groups/form-abstract-group.js +375 -353
- package/dist/form-groups/form-card.d.ts +32 -32
- package/dist/form-groups/form-card.js +113 -108
- package/dist/form-groups/form-collapsed-card.d.ts +70 -70
- package/dist/form-groups/form-collapsed-card.js +254 -253
- package/dist/form-groups/index.d.ts +3 -3
- package/dist/form-groups/index.js +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/lib/additional-components/confirmation-dialog.d.ts +18 -16
- package/dist/lib/additional-components/confirmation-dialog.js +72 -65
- package/dist/lib/additional-components/etools-fb-card.d.ts +21 -16
- package/dist/lib/additional-components/etools-fb-card.js +238 -215
- package/dist/lib/styles/attachments.styles.d.ts +2 -2
- package/dist/lib/styles/attachments.styles.js +72 -72
- package/dist/lib/styles/card-styles.d.ts +2 -2
- package/dist/lib/styles/card-styles.js +154 -154
- package/dist/lib/styles/dialog.styles.d.ts +2 -2
- package/dist/lib/styles/dialog.styles.js +85 -85
- package/dist/lib/styles/elevation-styles.d.ts +9 -9
- package/dist/lib/styles/elevation-styles.js +43 -43
- package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
- package/dist/lib/styles/flex-layout-classes.js +319 -319
- package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
- package/dist/lib/styles/form-builder-card.styles.js +49 -49
- package/dist/lib/styles/input-styles.d.ts +2 -2
- package/dist/lib/styles/input-styles.js +138 -138
- package/dist/lib/styles/page-layout-styles.d.ts +2 -2
- package/dist/lib/styles/page-layout-styles.js +201 -201
- package/dist/lib/styles/shared-styles.d.ts +2 -2
- package/dist/lib/styles/shared-styles.js +70 -70
- package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
- package/dist/lib/types/form-builder.interfaces.js +0 -0
- package/dist/lib/types/form-builder.types.d.ts +59 -59
- package/dist/lib/types/form-builder.types.js +0 -0
- package/dist/lib/types/global.types.d.ts +4 -4
- package/dist/lib/types/global.types.js +0 -0
- package/dist/lib/utils/dialog.d.ts +10 -10
- package/dist/lib/utils/dialog.js +21 -21
- package/dist/lib/utils/fire-custom-event.d.ts +1 -1
- package/dist/lib/utils/fire-custom-event.js +7 -7
- package/dist/lib/utils/translate.d.ts +1 -0
- package/dist/lib/utils/translate.js +9 -0
- package/dist/lib/utils/validations.helper.d.ts +26 -26
- package/dist/lib/utils/validations.helper.js +42 -35
- package/package.json +56 -56
|
@@ -1,89 +1,91 @@
|
|
|
1
|
-
import { html } from 'lit-html';
|
|
2
|
-
import { InputStyles } from '../lib/styles/input-styles';
|
|
3
|
-
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
import { html } from 'lit-html';
|
|
2
|
+
import { InputStyles } from '../lib/styles/input-styles';
|
|
3
|
+
import { DialogStyles } from '../lib/styles/dialog.styles';
|
|
4
|
+
import { getTranslation } from '../lib/utils/translate';
|
|
5
|
+
export function template() {
|
|
6
|
+
var _a;
|
|
7
|
+
return html `
|
|
8
|
+
${InputStyles} ${DialogStyles}
|
|
9
|
+
<etools-dialog
|
|
10
|
+
id="form-attachments-dialog"
|
|
11
|
+
size="md"
|
|
12
|
+
no-padding
|
|
13
|
+
keep-dialog-open
|
|
14
|
+
?opened="${this.dialogOpened}"
|
|
15
|
+
.okBtnText="${getTranslation(this.language, 'SAVE')}"
|
|
16
|
+
.cancelBtnText="${getTranslation(this.language, 'CANCEL')}"
|
|
17
|
+
.hideConfirmBtn="${this.readonly}"
|
|
18
|
+
dialog-title="${this.popupTitle}"
|
|
19
|
+
@close="${this.onClose}"
|
|
20
|
+
@confirm-btn-clicked="${() => this.saveChanges()}"
|
|
21
|
+
>
|
|
22
|
+
<!-- Link is used to download attachments -->
|
|
23
|
+
<a id="link" target="_blank" hidden></a>
|
|
24
|
+
|
|
25
|
+
<div class="popup-container">
|
|
26
|
+
${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
return html `
|
|
29
|
+
<div class="file-selector-container with-type-dropdown">
|
|
30
|
+
<!-- Type select Dropdown -->
|
|
31
|
+
<etools-dropdown
|
|
32
|
+
class="type-dropdown file-selector__type-dropdown"
|
|
33
|
+
.selected="${attachment.file_type}"
|
|
34
|
+
@etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
|
|
35
|
+
trigger-value-change-event
|
|
36
|
+
label="${getTranslation(this.language, 'DOCUMENT_TYPE')}"
|
|
37
|
+
placeholder="${getTranslation(this.language, 'SELECT_DOCUMENT_TYPE')}"
|
|
38
|
+
required
|
|
39
|
+
?readonly="${this.readonly}"
|
|
40
|
+
hide-search
|
|
41
|
+
.options="${(_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.options.target_attachments_file_types) === null || _b === void 0 ? void 0 : _b.values}"
|
|
42
|
+
option-label="label"
|
|
43
|
+
option-value="value"
|
|
44
|
+
?invalid="${this.checkFileType(index)}"
|
|
45
|
+
.errorMessage="${this.retrieveErrorMessage(index)}"
|
|
46
|
+
allow-outside-scroll
|
|
47
|
+
dynamic-align
|
|
48
|
+
></etools-dropdown>
|
|
49
|
+
|
|
50
|
+
<!-- File name component -->
|
|
51
|
+
<div class="filename-container file-selector__filename">
|
|
52
|
+
<iron-icon class="file-icon" icon="attachment"></iron-icon>
|
|
53
|
+
<span class="filename" title="${attachment.filename}">${attachment.filename}</span>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Download Button -->
|
|
57
|
+
<paper-button
|
|
58
|
+
?hidden="${!attachment.url}"
|
|
59
|
+
class="download-button file-selector__download"
|
|
60
|
+
@tap="${() => this.downloadFile(attachment)}"
|
|
61
|
+
>
|
|
62
|
+
<iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
|
|
63
|
+
${getTranslation(this.language, 'DOWNLOAD')}
|
|
64
|
+
</paper-button>
|
|
65
|
+
|
|
66
|
+
<!-- Delete Button -->
|
|
67
|
+
<paper-button
|
|
68
|
+
class="delete-button file-selector__delete"
|
|
69
|
+
?hidden="${this.readonly}"
|
|
70
|
+
@tap="${() => this.deleteAttachment(index)}"
|
|
71
|
+
>
|
|
72
|
+
${getTranslation(this.language, 'DELETE')}
|
|
73
|
+
</paper-button>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
})}
|
|
77
|
+
|
|
78
|
+
<!-- Upload button -->
|
|
79
|
+
<etools-upload-multi
|
|
80
|
+
class="with-padding"
|
|
81
|
+
activate-offline
|
|
82
|
+
?hidden="${this.readonly}"
|
|
83
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
84
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
85
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
86
|
+
>
|
|
87
|
+
</etools-upload-multi>
|
|
88
|
+
</div>
|
|
89
|
+
</etools-dialog>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form-attachments-popup';
|
|
2
|
-
export * from './form-attachments-popup.helper';
|
|
1
|
+
export * from './form-attachments-popup';
|
|
2
|
+
export * from './form-attachments-popup.helper';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './form-attachments-popup';
|
|
2
|
-
export * from './form-attachments-popup.helper';
|
|
1
|
+
export * from './form-attachments-popup';
|
|
2
|
+
export * from './form-attachments-popup.helper';
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
|
-
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
3
|
-
/**
|
|
4
|
-
* Class that contains common properties and methods for single and repeatable fields
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
|
|
7
|
-
questionText: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
protected
|
|
24
|
-
protected
|
|
25
|
-
protected
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
|
|
2
|
+
import { FieldValidator } from '../lib/utils/validations.helper';
|
|
3
|
+
/**
|
|
4
|
+
* Class that contains common properties and methods for single and repeatable fields
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
|
|
7
|
+
questionText: string;
|
|
8
|
+
language: string;
|
|
9
|
+
set isReadonly(readonly: boolean);
|
|
10
|
+
get isReadonly(): boolean;
|
|
11
|
+
required: boolean;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
value: T | null;
|
|
14
|
+
validators: FieldValidator[];
|
|
15
|
+
touched: boolean;
|
|
16
|
+
set defaultValue(value: any);
|
|
17
|
+
private _defaultValue;
|
|
18
|
+
private _readonly;
|
|
19
|
+
constructor();
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
handleLanguageChange(e: CustomEvent): void;
|
|
23
|
+
protected render(): TemplateResult;
|
|
24
|
+
protected questionTemplate(): TemplateResult;
|
|
25
|
+
protected metaValidation(value: unknown): string | null;
|
|
26
|
+
private setDefaultValue;
|
|
27
|
+
protected abstract valueChanged(...args: any): void;
|
|
28
|
+
protected abstract customValidation(value: unknown): string | null;
|
|
29
|
+
protected abstract controlTemplate(...args: any): TemplateResult;
|
|
30
|
+
protected abstract setValue(value: T): void;
|
|
31
|
+
protected abstract validateField(value: T): void;
|
|
32
|
+
static get styles(): CSSResultArray;
|
|
33
|
+
}
|
|
@@ -1,176 +1,194 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { LitElement, property, css, html } from 'lit-element';
|
|
8
|
-
import { validate } from '../lib/utils/validations.helper';
|
|
9
|
-
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
10
|
-
/**
|
|
11
|
-
* Class that contains common properties and methods for single and repeatable fields
|
|
12
|
-
*/
|
|
13
|
-
export class AbstractFieldBaseClass extends LitElement {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(
|
|
16
|
-
this.questionText = '';
|
|
17
|
-
this.required = false;
|
|
18
|
-
this.placeholder = '';
|
|
19
|
-
this.value = null;
|
|
20
|
-
this.validators = [];
|
|
21
|
-
this.touched = false;
|
|
22
|
-
this._readonly = false;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:host
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.question
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
paper-input
|
|
130
|
-
paper-textarea
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, property, css, html } from 'lit-element';
|
|
8
|
+
import { validate } from '../lib/utils/validations.helper';
|
|
9
|
+
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
10
|
+
/**
|
|
11
|
+
* Class that contains common properties and methods for single and repeatable fields
|
|
12
|
+
*/
|
|
13
|
+
export class AbstractFieldBaseClass extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.questionText = '';
|
|
17
|
+
this.required = false;
|
|
18
|
+
this.placeholder = '';
|
|
19
|
+
this.value = null;
|
|
20
|
+
this.validators = [];
|
|
21
|
+
this.touched = false;
|
|
22
|
+
this._readonly = false;
|
|
23
|
+
if (!this.language) {
|
|
24
|
+
this.language = window.localStorage.defaultLanguage || 'en';
|
|
25
|
+
}
|
|
26
|
+
this.handleLanguageChange = this.handleLanguageChange.bind(this);
|
|
27
|
+
}
|
|
28
|
+
set isReadonly(readonly) {
|
|
29
|
+
this._readonly = readonly;
|
|
30
|
+
this.setDefaultValue(readonly, this._defaultValue);
|
|
31
|
+
this.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
get isReadonly() {
|
|
34
|
+
return this._readonly;
|
|
35
|
+
}
|
|
36
|
+
set defaultValue(value) {
|
|
37
|
+
this._defaultValue = value;
|
|
38
|
+
this.setDefaultValue(this._readonly, value);
|
|
39
|
+
this.requestUpdate();
|
|
40
|
+
}
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
|
|
44
|
+
}
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
super.disconnectedCallback();
|
|
47
|
+
document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
|
|
48
|
+
}
|
|
49
|
+
handleLanguageChange(e) {
|
|
50
|
+
this.language = e.detail.language;
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
return html `
|
|
54
|
+
<div class="finding-container">
|
|
55
|
+
<div class="question"><slot>${this.questionTemplate()}</slot></div>
|
|
56
|
+
<div class="question-control">${this.controlTemplate()}</div>
|
|
57
|
+
</div>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
questionTemplate() {
|
|
61
|
+
return html `<span class="question-text">${this.questionText}</span>`;
|
|
62
|
+
}
|
|
63
|
+
metaValidation(value) {
|
|
64
|
+
const message = validate(this.validators, value, this.language);
|
|
65
|
+
return message ? message : this.customValidation(value);
|
|
66
|
+
}
|
|
67
|
+
setDefaultValue(readonly, defaultValue) {
|
|
68
|
+
if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.getUpdateComplete().then(() => {
|
|
72
|
+
if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
|
|
73
|
+
this.setValue(defaultValue);
|
|
74
|
+
this.validateField(defaultValue);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
static get styles() {
|
|
79
|
+
// language=CSS
|
|
80
|
+
return [
|
|
81
|
+
FlexLayoutClasses,
|
|
82
|
+
css `
|
|
83
|
+
:host {
|
|
84
|
+
display: block;
|
|
85
|
+
width: 100%;
|
|
86
|
+
padding: 0 25px 0 45px;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.finding-container {
|
|
91
|
+
width: 100%;
|
|
92
|
+
display: flex;
|
|
93
|
+
}
|
|
94
|
+
.flex-wrapping {
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host(.wide) .finding-container {
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host(.wide) .question {
|
|
103
|
+
margin-bottom: -8px;
|
|
104
|
+
min-height: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.question-control,
|
|
108
|
+
.question {
|
|
109
|
+
min-width: 0;
|
|
110
|
+
min-height: 57px;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
}
|
|
114
|
+
.question {
|
|
115
|
+
flex: 2;
|
|
116
|
+
}
|
|
117
|
+
.question-control {
|
|
118
|
+
flex: 3;
|
|
119
|
+
}
|
|
120
|
+
.add-button {
|
|
121
|
+
padding: 3px;
|
|
122
|
+
margin: 10px;
|
|
123
|
+
background: transparent;
|
|
124
|
+
color: var(--primary-color);
|
|
125
|
+
border: 1px solid;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.full-width,
|
|
129
|
+
paper-input,
|
|
130
|
+
paper-textarea {
|
|
131
|
+
width: 100%;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.question-text {
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
font-size: 13px;
|
|
137
|
+
color: var(--primary-text-color);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
paper-input,
|
|
141
|
+
paper-textarea {
|
|
142
|
+
outline: none !important;
|
|
143
|
+
}
|
|
144
|
+
paper-input[required],
|
|
145
|
+
paper-textarea[required] {
|
|
146
|
+
--paper-input-container-label_-_background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221235%22%20height%3D%221175%22%3E%3Cpath%20fill%3D%22%23de0000%22%20d%3D%22M0%2C449h1235l-999%2C726%20382-1175%20382%2C1175z%22%2F%3E%3C%2Fsvg%3E')
|
|
147
|
+
no-repeat 98% 14%/7px;
|
|
148
|
+
--paper-input-container-label_-_max-width: max-content;
|
|
149
|
+
--paper-input-container-label_-_padding-right: 15px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
iron-icon[icon='close'] {
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.error-text {
|
|
157
|
+
color: var(--error-color);
|
|
158
|
+
font-size: 12px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (max-width: 1080px) {
|
|
162
|
+
:host {
|
|
163
|
+
padding: 0 15px;
|
|
164
|
+
}
|
|
165
|
+
.finding-container {
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
}
|
|
168
|
+
.question,
|
|
169
|
+
.question-control {
|
|
170
|
+
flex: 0 1 auto;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
`
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
__decorate([
|
|
178
|
+
property({ type: String })
|
|
179
|
+
], AbstractFieldBaseClass.prototype, "questionText", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
property()
|
|
182
|
+
], AbstractFieldBaseClass.prototype, "language", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
property({ type: Boolean, attribute: 'is-readonly' })
|
|
185
|
+
], AbstractFieldBaseClass.prototype, "isReadonly", null);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Boolean, attribute: 'required' })
|
|
188
|
+
], AbstractFieldBaseClass.prototype, "required", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property()
|
|
191
|
+
], AbstractFieldBaseClass.prototype, "placeholder", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property()
|
|
194
|
+
], AbstractFieldBaseClass.prototype, "value", void 0);
|