@unicef-polymer/etools-form-builder 2.0.0-rc.1 → 2.1.0-rc.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.
Files changed (26) hide show
  1. package/dist/form-attachments-popup/form-attachments-popup.js +48 -48
  2. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +79 -80
  3. package/dist/form-fields/abstract-field-base.class.js +97 -101
  4. package/dist/form-fields/field-renderer-component.js +141 -141
  5. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +109 -109
  6. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
  7. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +20 -20
  8. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +59 -59
  9. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +23 -23
  10. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  11. package/dist/form-fields/single-fields/boolean-field.js +20 -20
  12. package/dist/form-fields/single-fields/number-field.js +21 -21
  13. package/dist/form-fields/single-fields/scale-field.js +56 -56
  14. package/dist/form-fields/single-fields/text-field.js +25 -25
  15. package/dist/form-fields/wide-field.d.ts +11 -0
  16. package/dist/form-fields/wide-field.js +51 -0
  17. package/dist/form-groups/form-abstract-group.js +119 -119
  18. package/dist/form-groups/form-card.js +22 -22
  19. package/dist/form-groups/form-collapsed-card.js +29 -29
  20. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  21. package/dist/lib/additional-components/etools-fb-card.js +135 -135
  22. package/dist/lib/styles/attachments.styles.js +69 -69
  23. package/dist/lib/styles/form-builder-card.styles.js +46 -46
  24. package/dist/lib/styles/input-styles.js +53 -64
  25. package/dist/lib/styles/page-layout-styles.js +198 -198
  26. package/package.json +53 -53
@@ -175,54 +175,54 @@ export class FormAttachmentsPopup extends LitElement {
175
175
  return [
176
176
  SharedStyles,
177
177
  AttachmentsStyles,
178
- css `
179
- .file-selector__type-dropdown {
180
- flex-basis: 25%;
181
- padding-left: 8px;
182
- padding-right: 8px;
183
- }
184
- .file-selector__filename {
185
- flex-basis: 35%;
186
- }
187
- .file-selector__download {
188
- flex-basis: 10%;
189
- }
190
- .file-selector__delete {
191
- flex-basis: 10%;
192
- }
193
- .file-selector-container.with-type-dropdown {
194
- flex-wrap: nowrap;
195
- }
196
- .popup-container {
197
- padding: 12px 12px 0;
198
- }
199
- @media (max-width: 380px) {
200
- .file-selector-container.with-type-dropdown {
201
- justify-content: center;
202
- }
203
- .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
204
- flex-basis: 90%;
205
- }
206
- .file-selector__filename {
207
- flex-basis: 90%;
208
- }
209
- .file-selector__download {
210
- flex-basis: 5%;
211
- }
212
- .file-selector__delete {
213
- flex-basis: 5%;
214
- }
215
- }
216
- @media (max-width: 600px) {
217
- etools-dropdown {
218
- padding: 0;
219
- }
220
- .file-selector-container.with-type-dropdown {
221
- border-bottom: 1px solid lightgrey;
222
- flex-wrap: wrap;
223
- padding-bottom: 10px;
224
- }
225
- }
178
+ css `
179
+ .file-selector__type-dropdown {
180
+ flex-basis: 25%;
181
+ padding-left: 8px;
182
+ padding-right: 8px;
183
+ }
184
+ .file-selector__filename {
185
+ flex-basis: 35%;
186
+ }
187
+ .file-selector__download {
188
+ flex-basis: 10%;
189
+ }
190
+ .file-selector__delete {
191
+ flex-basis: 10%;
192
+ }
193
+ .file-selector-container.with-type-dropdown {
194
+ flex-wrap: nowrap;
195
+ }
196
+ .popup-container {
197
+ padding: 12px 12px 0;
198
+ }
199
+ @media (max-width: 380px) {
200
+ .file-selector-container.with-type-dropdown {
201
+ justify-content: center;
202
+ }
203
+ .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
204
+ flex-basis: 90%;
205
+ }
206
+ .file-selector__filename {
207
+ flex-basis: 90%;
208
+ }
209
+ .file-selector__download {
210
+ flex-basis: 5%;
211
+ }
212
+ .file-selector__delete {
213
+ flex-basis: 5%;
214
+ }
215
+ }
216
+ @media (max-width: 600px) {
217
+ etools-dropdown {
218
+ padding: 0;
219
+ }
220
+ .file-selector-container.with-type-dropdown {
221
+ border-bottom: 1px solid lightgrey;
222
+ flex-wrap: wrap;
223
+ padding-bottom: 10px;
224
+ }
225
+ }
226
226
  `
227
227
  ];
228
228
  }
@@ -3,88 +3,87 @@ import { InputStyles } from '../lib/styles/input-styles';
3
3
  import { DialogStyles } from '../lib/styles/dialog.styles';
4
4
  export function template() {
5
5
  var _a;
6
- return html `
7
- ${InputStyles} ${DialogStyles}
8
- <etools-dialog
9
- id="form-attachments-dialog"
10
- size="md"
11
- no-padding
12
- keep-dialog-open
13
- ?opened="${this.dialogOpened}"
14
- .okBtnText="Save"
15
- .hideConfirmBtn="${this.readonly}"
16
- dialog-title="${this.popupTitle}"
17
- @close="${this.onClose}"
18
- @confirm-btn-clicked="${() => this.saveChanges()}"
19
- >
20
- <!-- Link is used to download attachments -->
21
- <a id="link" target="_blank" hidden></a>
22
-
23
- <div class="popup-container">
6
+ return html `
7
+ ${InputStyles} ${DialogStyles}
8
+ <etools-dialog
9
+ id="form-attachments-dialog"
10
+ size="md"
11
+ no-padding
12
+ keep-dialog-open
13
+ ?opened="${this.dialogOpened}"
14
+ .okBtnText="Save"
15
+ .hideConfirmBtn="${this.readonly}"
16
+ dialog-title="${this.popupTitle}"
17
+ @close="${this.onClose}"
18
+ @confirm-btn-clicked="${() => this.saveChanges()}"
19
+ >
20
+ <!-- Link is used to download attachments -->
21
+ <a id="link" target="_blank" hidden></a>
22
+
23
+ <div class="popup-container">
24
24
  ${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
25
25
  var _a, _b;
26
- return html `
27
- <div class="file-selector-container with-type-dropdown">
28
- <!-- Type select Dropdown -->
29
- <etools-dropdown
30
- class="type-dropdown disabled-as-readonly file-selector__type-dropdown"
31
- .selected="${attachment.file_type}"
32
- @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
33
- trigger-value-change-event
34
- label="Document Type"
35
- placeholder="Select Document Type"
36
- required
37
- ?readonly="${this.readonly}"
38
- ?disabled="${this.readonly}"
39
- hide-search
40
- .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}"
41
- option-label="label"
42
- option-value="value"
43
- ?invalid="${this.checkFileType(index)}"
44
- .errorMessage="${this.retrieveErrorMessage(index)}"
45
- allow-outside-scroll
46
- dynamic-align
47
- ></etools-dropdown>
48
-
49
- <!-- File name component -->
50
- <div class="filename-container file-selector__filename">
51
- <iron-icon class="file-icon" icon="attachment"></iron-icon>
52
- <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
53
- </div>
54
-
55
- <!-- Download Button -->
56
- <paper-button
57
- ?hidden="${!attachment.url}"
58
- class="download-button file-selector__download"
59
- @tap="${() => this.downloadFile(attachment)}"
60
- >
61
- <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
62
- Download
63
- </paper-button>
64
-
65
- <!-- Delete Button -->
66
- <paper-button
67
- class="delete-button file-selector__delete"
68
- ?hidden="${this.readonly}"
69
- @tap="${() => this.deleteAttachment(index)}"
70
- >
71
- Delete
72
- </paper-button>
73
- </div>
26
+ return html `
27
+ <div class="file-selector-container with-type-dropdown">
28
+ <!-- Type select Dropdown -->
29
+ <etools-dropdown
30
+ class="type-dropdown file-selector__type-dropdown"
31
+ .selected="${attachment.file_type}"
32
+ @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
33
+ trigger-value-change-event
34
+ label="Document Type"
35
+ placeholder="Select Document Type"
36
+ required
37
+ ?readonly="${this.readonly}"
38
+ hide-search
39
+ .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}"
40
+ option-label="label"
41
+ option-value="value"
42
+ ?invalid="${this.checkFileType(index)}"
43
+ .errorMessage="${this.retrieveErrorMessage(index)}"
44
+ allow-outside-scroll
45
+ dynamic-align
46
+ ></etools-dropdown>
47
+
48
+ <!-- File name component -->
49
+ <div class="filename-container file-selector__filename">
50
+ <iron-icon class="file-icon" icon="attachment"></iron-icon>
51
+ <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
52
+ </div>
53
+
54
+ <!-- Download Button -->
55
+ <paper-button
56
+ ?hidden="${!attachment.url}"
57
+ class="download-button file-selector__download"
58
+ @tap="${() => this.downloadFile(attachment)}"
59
+ >
60
+ <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
61
+ Download
62
+ </paper-button>
63
+
64
+ <!-- Delete Button -->
65
+ <paper-button
66
+ class="delete-button file-selector__delete"
67
+ ?hidden="${this.readonly}"
68
+ @tap="${() => this.deleteAttachment(index)}"
69
+ >
70
+ Delete
71
+ </paper-button>
72
+ </div>
74
73
  `;
75
- })}
76
-
77
- <!-- Upload button -->
78
- <etools-upload-multi
79
- class="with-padding"
80
- activate-offline
81
- ?hidden="${this.readonly}"
82
- @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
83
- .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
84
- .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
85
- >
86
- </etools-upload-multi>
87
- </div>
88
- </etools-dialog>
74
+ })}
75
+
76
+ <!-- Upload button -->
77
+ <etools-upload-multi
78
+ class="with-padding"
79
+ activate-offline
80
+ ?hidden="${this.readonly}"
81
+ @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
82
+ .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
83
+ .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
84
+ >
85
+ </etools-upload-multi>
86
+ </div>
87
+ </etools-dialog>
89
88
  `;
90
89
  }
@@ -24,6 +24,7 @@ export class AbstractFieldBaseClass extends LitElement {
24
24
  set isReadonly(readonly) {
25
25
  this._readonly = readonly;
26
26
  this.setDefaultValue(readonly, this._defaultValue);
27
+ this.requestUpdate();
27
28
  }
28
29
  get isReadonly() {
29
30
  return this._readonly;
@@ -34,11 +35,11 @@ export class AbstractFieldBaseClass extends LitElement {
34
35
  this.requestUpdate();
35
36
  }
36
37
  render() {
37
- return html `
38
- <div class="finding-container">
39
- <div class="question"><slot>${this.questionTemplate()}</slot></div>
40
- <div class="question-control">${this.controlTemplate()}</div>
41
- </div>
38
+ return html `
39
+ <div class="finding-container">
40
+ <div class="question"><slot>${this.questionTemplate()}</slot></div>
41
+ <div class="question-control">${this.controlTemplate()}</div>
42
+ </div>
42
43
  `;
43
44
  }
44
45
  questionTemplate() {
@@ -63,102 +64,97 @@ export class AbstractFieldBaseClass extends LitElement {
63
64
  // language=CSS
64
65
  return [
65
66
  FlexLayoutClasses,
66
- css `
67
- :host {
68
- display: block;
69
- width: 100%;
70
- padding: 0 25px 0 45px;
71
- box-sizing: border-box;
72
- }
73
-
74
- .finding-container {
75
- width: 100%;
76
- display: flex;
77
- }
78
- .flex-wrapping {
79
- flex-wrap: wrap;
80
- }
81
-
82
- :host(.wide) .finding-container {
83
- flex-direction: column;
84
- }
85
-
86
- :host(.wide) .question {
87
- margin-bottom: -8px;
88
- min-height: 0;
89
- }
90
-
91
- .question-control,
92
- .question {
93
- min-width: 0;
94
- min-height: 57px;
95
- display: flex;
96
- align-items: center;
97
- }
98
- .question {
99
- flex: 2;
100
- }
101
- .question-control {
102
- flex: 3;
103
- }
104
- .add-button {
105
- padding: 3px;
106
- margin: 10px;
107
- background: transparent;
108
- color: var(--primary-color);
109
- border: 1px solid;
110
- }
111
-
112
- .full-width,
113
- paper-input,
114
- paper-textarea {
115
- width: 100%;
116
- }
117
-
118
- .question-text {
119
- font-weight: 500;
120
- font-size: 13px;
121
- color: var(--primary-text-color);
122
- }
123
-
124
- paper-input.form-control,
125
- paper-textarea.form-control {
126
- outline: none !important;
127
- }
128
- paper-input[required].form-control,
129
- paper-textarea[required].form-control {
130
- --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')
131
- no-repeat 98% 14%/7px;
132
- --paper-input-container-label_-_max-width: max-content;
133
- --paper-input-container-label_-_padding-right: 15px;
134
- }
135
- paper-input[disabled].form-control,
136
- paper-textarea[disabled].form-control {
137
- --paper-input-container-underline_-_border-bottom: 1px solid rgba(0, 0, 0, 0.2) !important;
138
- --paper-input-container-underline_-_border-color: rgba(0, 0, 0, 0.2) !important;
139
- }
140
-
141
- iron-icon[icon='close'] {
142
- cursor: pointer;
143
- }
144
-
145
- .error-text {
146
- color: var(--error-color);
147
- font-size: 12px;
148
- }
149
-
150
- @media (max-width: 1080px) {
151
- :host {
152
- padding: 0 15px;
153
- }
154
- .finding-container {
155
- flex-direction: column;
156
- }
157
- .question,
158
- .question-control {
159
- flex: 0 1 auto;
160
- }
161
- }
67
+ css `
68
+ :host {
69
+ display: block;
70
+ width: 100%;
71
+ padding: 0 25px 0 45px;
72
+ box-sizing: border-box;
73
+ }
74
+
75
+ .finding-container {
76
+ width: 100%;
77
+ display: flex;
78
+ }
79
+ .flex-wrapping {
80
+ flex-wrap: wrap;
81
+ }
82
+
83
+ :host(.wide) .finding-container {
84
+ flex-direction: column;
85
+ }
86
+
87
+ :host(.wide) .question {
88
+ margin-bottom: -8px;
89
+ min-height: 0;
90
+ }
91
+
92
+ .question-control,
93
+ .question {
94
+ min-width: 0;
95
+ min-height: 57px;
96
+ display: flex;
97
+ align-items: center;
98
+ }
99
+ .question {
100
+ flex: 2;
101
+ }
102
+ .question-control {
103
+ flex: 3;
104
+ }
105
+ .add-button {
106
+ padding: 3px;
107
+ margin: 10px;
108
+ background: transparent;
109
+ color: var(--primary-color);
110
+ border: 1px solid;
111
+ }
112
+
113
+ .full-width,
114
+ paper-input,
115
+ paper-textarea {
116
+ width: 100%;
117
+ }
118
+
119
+ .question-text {
120
+ font-weight: 500;
121
+ font-size: 13px;
122
+ color: var(--primary-text-color);
123
+ }
124
+
125
+ paper-input,
126
+ paper-textarea {
127
+ outline: none !important;
128
+ }
129
+ paper-input[required],
130
+ paper-textarea[required] {
131
+ --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')
132
+ no-repeat 98% 14%/7px;
133
+ --paper-input-container-label_-_max-width: max-content;
134
+ --paper-input-container-label_-_padding-right: 15px;
135
+ }
136
+
137
+ iron-icon[icon='close'] {
138
+ cursor: pointer;
139
+ }
140
+
141
+ .error-text {
142
+ color: var(--error-color);
143
+ font-size: 12px;
144
+ }
145
+
146
+ @media (max-width: 1080px) {
147
+ :host {
148
+ padding: 0 15px;
149
+ }
150
+ .finding-container {
151
+ flex-direction: column;
152
+ }
153
+ .question,
154
+ .question-control {
155
+ flex: 0 1 auto;
156
+ }
157
+ }
162
158
  `
163
159
  ];
164
160
  }