@unicef-polymer/etools-form-builder 2.1.8 → 3.0.0-rc.1
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 -6
- package/dist/assets/translations.js +67 -67
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +84 -86
- 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 +249 -255
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +7 -3
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +102 -91
- 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 -33
- package/dist/form-fields/abstract-field-base.class.js +209 -213
- package/dist/form-fields/field-renderer-component.d.ts +20 -20
- package/dist/form-fields/field-renderer-component.js +251 -255
- 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 +19 -17
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +212 -209
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +21 -20
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +121 -124
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +63 -67
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +106 -108
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +49 -53
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
- package/dist/form-fields/single-fields/attachment-field.js +94 -98
- package/dist/form-fields/single-fields/base-field.d.ts +11 -11
- package/dist/form-fields/single-fields/base-field.js +53 -58
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
- package/dist/form-fields/single-fields/boolean-field.js +45 -49
- package/dist/form-fields/single-fields/number-field.d.ts +10 -10
- package/dist/form-fields/single-fields/number-field.js +63 -67
- package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
- package/dist/form-fields/single-fields/scale-field.js +109 -108
- package/dist/form-fields/single-fields/text-field.d.ts +8 -8
- package/dist/form-fields/single-fields/text-field.js +49 -54
- package/dist/form-groups/form-abstract-group.d.ts +71 -71
- package/dist/form-groups/form-abstract-group.js +396 -398
- package/dist/form-groups/form-card.d.ts +35 -32
- package/dist/form-groups/form-card.js +115 -113
- package/dist/form-groups/form-collapsed-card.d.ts +72 -71
- package/dist/form-groups/form-collapsed-card.js +261 -259
- 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 -18
- package/dist/lib/additional-components/confirmation-dialog.js +68 -72
- package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
- package/dist/lib/additional-components/etools-fb-card.js +242 -239
- 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 +1 -0
- package/dist/lib/types/form-builder.types.d.ts +59 -59
- package/dist/lib/types/form-builder.types.js +1 -0
- package/dist/lib/types/global.types.d.ts +4 -4
- package/dist/lib/types/global.types.js +1 -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 -1
- package/dist/lib/utils/translate.js +9 -9
- package/dist/lib/utils/validations.helper.d.ts +26 -26
- package/dist/lib/utils/validations.helper.js +42 -42
- package/package.json +51 -56
|
@@ -1,209 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import '
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<div class="question layout start"
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
link
|
|
120
|
-
link.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload';
|
|
3
|
+
import { RepeatableBaseField } from './repeatable-base-field';
|
|
4
|
+
import { AttachmentsHelper } from '../../form-attachments-popup';
|
|
5
|
+
import { css, html } from 'lit';
|
|
6
|
+
import { customElement } from 'lit/decorators.js';
|
|
7
|
+
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
8
|
+
import { SharedStyles } from '../../lib/styles/shared-styles';
|
|
9
|
+
import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
|
|
10
|
+
import { getTranslation } from '../../lib/utils/translate';
|
|
11
|
+
import '@shoelace-style/shoelace/dist/components/button/button.js';
|
|
12
|
+
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload-multi';
|
|
13
|
+
import { buttonsStyles } from '@unicef-polymer/etools-unicef/src/styles/button-styles';
|
|
14
|
+
let RepeatableAttachmentField = class RepeatableAttachmentField extends RepeatableBaseField {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.computedPath = [];
|
|
18
|
+
}
|
|
19
|
+
get uploadUrl() {
|
|
20
|
+
return AttachmentsHelper.uploadUrl;
|
|
21
|
+
}
|
|
22
|
+
get jwtLocalStorageKey() {
|
|
23
|
+
return AttachmentsHelper.jwtLocalStorageKey;
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
var _a;
|
|
27
|
+
const values = this.getValues();
|
|
28
|
+
return html `
|
|
29
|
+
<div class="finding-container">
|
|
30
|
+
<div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
|
|
31
|
+
<div class="question-control layout vertical center-justified start">
|
|
32
|
+
${values.map((value, index) => value
|
|
33
|
+
? html `
|
|
34
|
+
<div class="layout horizontal file-container">
|
|
35
|
+
<!-- File name component -->
|
|
36
|
+
<div class="filename-container file-selector__filename">
|
|
37
|
+
<etools-icon class="file-icon" name="attachment"></etools-icon>
|
|
38
|
+
<span class="filename" title="${value.filename}">${value.filename}</span>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<!-- Download Button -->
|
|
42
|
+
<sl-button
|
|
43
|
+
class="neutral"
|
|
44
|
+
variant="text"
|
|
45
|
+
?hidden="${!value.url}"
|
|
46
|
+
class="download-button file-selector__download"
|
|
47
|
+
@click="${this.downloadFile(value)}"
|
|
48
|
+
>
|
|
49
|
+
<etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
|
|
50
|
+
${getTranslation(this.language, 'DOWNLOAD')}
|
|
51
|
+
</sl-button>
|
|
52
|
+
|
|
53
|
+
<!-- Delete Button -->
|
|
54
|
+
<sl-button
|
|
55
|
+
variant="danger"
|
|
56
|
+
class="delete-button file-selector__delete"
|
|
57
|
+
?hidden="${this.isReadonly}"
|
|
58
|
+
@click="${this.removeControl(index)}"
|
|
59
|
+
>
|
|
60
|
+
${getTranslation(this.language, 'DELETE')}
|
|
61
|
+
</sl-button>
|
|
62
|
+
</div>
|
|
63
|
+
`
|
|
64
|
+
: '')}
|
|
65
|
+
<!-- Upload button -->
|
|
66
|
+
<etools-upload-multi
|
|
67
|
+
class="with-padding"
|
|
68
|
+
activate-offline
|
|
69
|
+
?hidden="${this.isReadonly}"
|
|
70
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
71
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
72
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
73
|
+
>
|
|
74
|
+
</etools-upload-multi>
|
|
75
|
+
<div ?hidden="${!this.isReadonly || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length)}">—</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
controlTemplate() {
|
|
81
|
+
return html ``;
|
|
82
|
+
}
|
|
83
|
+
customValidation() {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
attachmentsUploaded({ success, error }) {
|
|
87
|
+
success === null || success === void 0 ? void 0 : success.forEach((file, index) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const newIndex = ((_b = Number((_a = this.editedValues) === null || _a === void 0 ? void 0 : _a.length)) !== null && _b !== void 0 ? _b : 0) + index;
|
|
90
|
+
if (this.isUploadedAttachment(file)) {
|
|
91
|
+
this.valueChanged({
|
|
92
|
+
url: file.file_link,
|
|
93
|
+
attachment: file.id,
|
|
94
|
+
filename: file.filename,
|
|
95
|
+
file_type: null
|
|
96
|
+
}, newIndex);
|
|
97
|
+
}
|
|
98
|
+
else if (this.isOfflineSavedAttachment(file)) {
|
|
99
|
+
this.valueChanged({
|
|
100
|
+
attachment: file.id,
|
|
101
|
+
filename: file.filename,
|
|
102
|
+
composedPath: [],
|
|
103
|
+
file_type: null
|
|
104
|
+
}, newIndex);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.warn('Missing fields in parsed attachment');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (error && error.length) {
|
|
111
|
+
console.error(error);
|
|
112
|
+
fireEvent(this, 'toast', { text: 'Can not upload attachments. Please try again later' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
downloadFile(attachment) {
|
|
116
|
+
if (!(attachment === null || attachment === void 0 ? void 0 : attachment.url)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const link = document.createElement('a');
|
|
120
|
+
link.target = '_blank';
|
|
121
|
+
link.href = attachment.url;
|
|
122
|
+
link.click();
|
|
123
|
+
window.URL.revokeObjectURL(attachment.url);
|
|
124
|
+
}
|
|
125
|
+
isUploadedAttachment(attachment) {
|
|
126
|
+
return (attachment.hasOwnProperty('filename') &&
|
|
127
|
+
attachment.hasOwnProperty('id') &&
|
|
128
|
+
attachment.hasOwnProperty('file_link') &&
|
|
129
|
+
!attachment.hasOwnProperty('unsynced'));
|
|
130
|
+
}
|
|
131
|
+
isOfflineSavedAttachment(attachment) {
|
|
132
|
+
return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
|
|
133
|
+
}
|
|
134
|
+
static get styles() {
|
|
135
|
+
// language=CSS
|
|
136
|
+
return [
|
|
137
|
+
...RepeatableBaseField.styles,
|
|
138
|
+
SharedStyles,
|
|
139
|
+
AttachmentsStyles,
|
|
140
|
+
buttonsStyles,
|
|
141
|
+
css `
|
|
142
|
+
.file-selector__type-dropdown {
|
|
143
|
+
flex-basis: 25%;
|
|
144
|
+
padding-left: 8px;
|
|
145
|
+
padding-right: 8px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.file-selector__filename {
|
|
149
|
+
flex-basis: 35%;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.file-selector__download {
|
|
153
|
+
flex-basis: 10%;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.file-selector__delete {
|
|
157
|
+
flex-basis: 10%;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.file-selector-container.with-type-dropdown {
|
|
161
|
+
flex-wrap: nowrap;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.popup-container {
|
|
165
|
+
padding: 12px 12px 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.file-container {
|
|
169
|
+
padding: 8px 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media (max-width: 380px) {
|
|
173
|
+
.file-selector-container.with-type-dropdown {
|
|
174
|
+
justify-content: center;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
|
|
178
|
+
flex-basis: 90%;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.file-selector__filename {
|
|
182
|
+
flex-basis: 90%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.file-selector__download {
|
|
186
|
+
flex-basis: 5%;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.file-selector__delete {
|
|
190
|
+
flex-basis: 5%;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@media (max-width: 600px) {
|
|
195
|
+
etools-dropdown {
|
|
196
|
+
padding: 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.file-selector-container.with-type-dropdown {
|
|
200
|
+
border-bottom: 1px solid lightgrey;
|
|
201
|
+
flex-wrap: wrap;
|
|
202
|
+
padding-bottom: 10px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
RepeatableAttachmentField = __decorate([
|
|
210
|
+
customElement('repeatable-attachments-field')
|
|
211
|
+
], RepeatableAttachmentField);
|
|
212
|
+
export { RepeatableAttachmentField };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
protected
|
|
8
|
-
protected
|
|
9
|
-
protected
|
|
10
|
-
protected
|
|
11
|
-
protected
|
|
12
|
-
protected
|
|
13
|
-
protected validateField(value: T
|
|
14
|
-
protected
|
|
15
|
-
protected
|
|
16
|
-
protected
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
3
|
+
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
4
|
+
export declare abstract class RepeatableBaseField<T> extends AbstractFieldBaseClass<T[]> {
|
|
5
|
+
set errorMessage(messages: (string | null)[]);
|
|
6
|
+
get errorMessage(): (string | null)[];
|
|
7
|
+
protected _errorMessage: (string | null)[];
|
|
8
|
+
protected editedValues: (T | null)[] | null;
|
|
9
|
+
protected render(): TemplateResult;
|
|
10
|
+
protected questionTemplate(): TemplateResult;
|
|
11
|
+
protected valueChanged(newValue: T, index: number): void;
|
|
12
|
+
protected setValue(value: (T | null)[]): void;
|
|
13
|
+
protected validateField(value: T[]): void;
|
|
14
|
+
protected validateField(value: T, index: number): void;
|
|
15
|
+
protected addNewField(): void;
|
|
16
|
+
protected removeControl(index: number): void;
|
|
17
|
+
protected getValues(): (T | null)[];
|
|
18
|
+
private isArrayData;
|
|
19
|
+
protected abstract controlTemplate(value: T | null, index: number): TemplateResult;
|
|
20
|
+
static get styles(): CSSResultArray;
|
|
21
|
+
}
|