@unicef-polymer/etools-form-builder 3.1.1 → 3.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.
Files changed (29) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/form-attachments-popup/form-attachments-popup.js +135 -135
  4. package/dist/form-fields/abstract-field-base.class.js +101 -101
  5. package/dist/form-fields/field-renderer-component.js +164 -164
  6. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +111 -111
  7. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
  8. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -19
  9. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -57
  10. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -19
  11. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  12. package/dist/form-fields/single-fields/boolean-field.js +16 -16
  13. package/dist/form-fields/single-fields/number-field.js +20 -20
  14. package/dist/form-fields/single-fields/scale-field.js +58 -58
  15. package/dist/form-fields/single-fields/text-field.js +24 -24
  16. package/dist/form-groups/form-abstract-group.js +129 -129
  17. package/dist/form-groups/form-card.js +30 -30
  18. package/dist/form-groups/form-collapsed-card.js +34 -34
  19. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  20. package/dist/lib/additional-components/etools-fb-card.js +144 -144
  21. package/dist/lib/styles/attachments.styles.js +61 -61
  22. package/dist/lib/styles/card-styles.js +147 -147
  23. package/dist/lib/styles/dialog.styles.js +83 -83
  24. package/dist/lib/styles/elevation-styles.js +46 -46
  25. package/dist/lib/styles/flex-layout-classes.js +316 -316
  26. package/dist/lib/styles/form-builder-card.styles.js +53 -53
  27. package/dist/lib/styles/page-layout-styles.js +198 -198
  28. package/dist/lib/styles/shared-styles.js +61 -61
  29. package/package.json +51 -52
package/README.md CHANGED
@@ -1 +1 @@
1
- # Etools FM Form Builder Components
1
+ # Etools FM Form Builder Components
@@ -64,96 +64,96 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
64
64
  }
65
65
  render() {
66
66
  var _a;
67
- return html `
68
- ${DialogStyles}
69
- <style>
70
- etools-icon[name='error-outline'] {
71
- color: var(--etools-upload-danger-color, #ea4022);
72
- }
73
- </style>
74
- <etools-dialog
75
- id="form-attachments-dialog"
76
- size="md"
77
- no-padding
78
- keep-dialog-open
79
- ?opened="${this.dialogOpened}"
80
- .okBtnText="${getTranslation(this.language, 'SAVE')}"
81
- .cancelBtnText="${getTranslation(this.language, 'CANCEL')}"
82
- .hideConfirmBtn="${this.readonly}"
83
- dialog-title="${this.popupTitle}"
84
- @close="${this.onClose}"
85
- @confirm-btn-clicked="${() => this.saveChanges()}"
86
- >
87
- <!-- Link is used to download attachments -->
88
- <a id="link" target="_blank" hidden></a>
89
-
90
- <div class="popup-container">
67
+ return html `
68
+ ${DialogStyles}
69
+ <style>
70
+ etools-icon[name='error-outline'] {
71
+ color: var(--etools-upload-danger-color, #ea4022);
72
+ }
73
+ </style>
74
+ <etools-dialog
75
+ id="form-attachments-dialog"
76
+ size="md"
77
+ no-padding
78
+ keep-dialog-open
79
+ ?opened="${this.dialogOpened}"
80
+ .okBtnText="${getTranslation(this.language, 'SAVE')}"
81
+ .cancelBtnText="${getTranslation(this.language, 'CANCEL')}"
82
+ .hideConfirmBtn="${this.readonly}"
83
+ dialog-title="${this.popupTitle}"
84
+ @close="${this.onClose}"
85
+ @confirm-btn-clicked="${() => this.saveChanges()}"
86
+ >
87
+ <!-- Link is used to download attachments -->
88
+ <a id="link" target="_blank" hidden></a>
89
+
90
+ <div class="popup-container">
91
91
  ${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
92
92
  var _a, _b;
93
- return html `
94
- <div class="file-selector-container with-type-dropdown">
95
- <!-- Type select Dropdown -->
96
- <etools-dropdown
97
- class="type-dropdown file-selector__type-dropdown"
98
- .selected="${attachment.file_type}"
99
- @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
100
- trigger-value-change-event
101
- label="${getTranslation(this.language, 'DOCUMENT_TYPE')}"
102
- placeholder="${getTranslation(this.language, 'SELECT_DOCUMENT_TYPE')}"
103
- required
104
- ?readonly="${this.readonly}"
105
- hide-search
106
- .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}"
107
- option-label="label"
108
- option-value="value"
109
- ?invalid="${this.checkFileType(index)}"
110
- .errorMessage="${this.retrieveErrorMessage(index)}"
111
- allow-outside-scroll
112
- dynamic-align
113
- ></etools-dropdown>
114
-
115
- <!-- File name component -->
116
- <div class="filename-container file-selector__filename">
117
- <etools-icon class="file-icon" name="attachment"></etools-icon>
118
- <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
119
- </div>
120
-
121
- <!-- Download Button -->
122
- <etools-button
123
- variant="text"
124
- ?hidden="${!attachment.url}"
125
- class="download-button file-selector__download"
126
- @click="${() => this.downloadFile(attachment)}"
127
- >
128
- <etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
129
- ${getTranslation(this.language, 'DOWNLOAD')}
130
- </etools-button>
131
-
132
- <!-- Delete Button -->
133
- <etools-button
134
- variant="text"
135
- class="danger delete-button file-selector__delete"
136
- ?hidden="${this.readonly}"
137
- @click="${() => this.deleteAttachment(index)}"
138
- >
139
- ${getTranslation(this.language, 'DELETE')}
140
- </etools-button>
141
- </div>
93
+ return html `
94
+ <div class="file-selector-container with-type-dropdown">
95
+ <!-- Type select Dropdown -->
96
+ <etools-dropdown
97
+ class="type-dropdown file-selector__type-dropdown"
98
+ .selected="${attachment.file_type}"
99
+ @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
100
+ trigger-value-change-event
101
+ label="${getTranslation(this.language, 'DOCUMENT_TYPE')}"
102
+ placeholder="${getTranslation(this.language, 'SELECT_DOCUMENT_TYPE')}"
103
+ required
104
+ ?readonly="${this.readonly}"
105
+ hide-search
106
+ .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}"
107
+ option-label="label"
108
+ option-value="value"
109
+ ?invalid="${this.checkFileType(index)}"
110
+ .errorMessage="${this.retrieveErrorMessage(index)}"
111
+ allow-outside-scroll
112
+ dynamic-align
113
+ ></etools-dropdown>
114
+
115
+ <!-- File name component -->
116
+ <div class="filename-container file-selector__filename">
117
+ <etools-icon class="file-icon" name="attachment"></etools-icon>
118
+ <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
119
+ </div>
120
+
121
+ <!-- Download Button -->
122
+ <etools-button
123
+ variant="text"
124
+ ?hidden="${!attachment.url}"
125
+ class="download-button file-selector__download"
126
+ @click="${() => this.downloadFile(attachment)}"
127
+ >
128
+ <etools-icon name="cloud-download" class="dw-icon" slot="prefix"></etools-icon>
129
+ ${getTranslation(this.language, 'DOWNLOAD')}
130
+ </etools-button>
131
+
132
+ <!-- Delete Button -->
133
+ <etools-button
134
+ variant="text"
135
+ class="danger delete-button file-selector__delete"
136
+ ?hidden="${this.readonly}"
137
+ @click="${() => this.deleteAttachment(index)}"
138
+ >
139
+ ${getTranslation(this.language, 'DELETE')}
140
+ </etools-button>
141
+ </div>
142
142
  `;
143
- })}
144
-
145
- <!-- Upload button -->
146
- <etools-upload-multi
147
- class="with-padding"
148
- activate-offline
149
- ?hidden="${this.readonly}"
150
- @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
151
- .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
152
- .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
153
- >
154
- </etools-upload-multi>
155
- </div>
156
- </etools-dialog>
143
+ })}
144
+
145
+ <!-- Upload button -->
146
+ <etools-upload-multi
147
+ class="with-padding"
148
+ activate-offline
149
+ ?hidden="${this.readonly}"
150
+ @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
151
+ .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
152
+ .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
153
+ >
154
+ </etools-upload-multi>
155
+ </div>
156
+ </etools-dialog>
157
157
  `;
158
158
  }
159
159
  /**
@@ -276,54 +276,54 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
276
276
  return [
277
277
  SharedStyles,
278
278
  AttachmentsStyles,
279
- css `
280
- .file-selector__type-dropdown {
281
- flex-basis: 25%;
282
- padding-left: 8px;
283
- padding-right: 8px;
284
- }
285
- .file-selector__filename {
286
- flex-basis: 35%;
287
- }
288
- .file-selector__download {
289
- flex-basis: 10%;
290
- }
291
- .file-selector__delete {
292
- flex-basis: 10%;
293
- }
294
- .file-selector-container.with-type-dropdown {
295
- flex-wrap: nowrap;
296
- }
297
- .popup-container {
298
- padding: 12px 12px 0;
299
- }
300
- @media (max-width: 380px) {
301
- .file-selector-container.with-type-dropdown {
302
- justify-content: center;
303
- }
304
- .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
305
- flex-basis: 90%;
306
- }
307
- .file-selector__filename {
308
- flex-basis: 90%;
309
- }
310
- .file-selector__download {
311
- flex-basis: 5%;
312
- }
313
- .file-selector__delete {
314
- flex-basis: 5%;
315
- }
316
- }
317
- @media (max-width: 600px) {
318
- etools-dropdown {
319
- padding: 0;
320
- }
321
- .file-selector-container.with-type-dropdown {
322
- border-bottom: 1px solid lightgrey;
323
- flex-wrap: wrap;
324
- padding-bottom: 10px;
325
- }
326
- }
279
+ css `
280
+ .file-selector__type-dropdown {
281
+ flex-basis: 25%;
282
+ padding-left: 8px;
283
+ padding-right: 8px;
284
+ }
285
+ .file-selector__filename {
286
+ flex-basis: 35%;
287
+ }
288
+ .file-selector__download {
289
+ flex-basis: 10%;
290
+ }
291
+ .file-selector__delete {
292
+ flex-basis: 10%;
293
+ }
294
+ .file-selector-container.with-type-dropdown {
295
+ flex-wrap: nowrap;
296
+ }
297
+ .popup-container {
298
+ padding: 12px 12px 0;
299
+ }
300
+ @media (max-width: 380px) {
301
+ .file-selector-container.with-type-dropdown {
302
+ justify-content: center;
303
+ }
304
+ .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
305
+ flex-basis: 90%;
306
+ }
307
+ .file-selector__filename {
308
+ flex-basis: 90%;
309
+ }
310
+ .file-selector__download {
311
+ flex-basis: 5%;
312
+ }
313
+ .file-selector__delete {
314
+ flex-basis: 5%;
315
+ }
316
+ }
317
+ @media (max-width: 600px) {
318
+ etools-dropdown {
319
+ padding: 0;
320
+ }
321
+ .file-selector-container.with-type-dropdown {
322
+ border-bottom: 1px solid lightgrey;
323
+ flex-wrap: wrap;
324
+ padding-bottom: 10px;
325
+ }
326
+ }
327
327
  `
328
328
  ];
329
329
  }
@@ -47,11 +47,11 @@ export class AbstractFieldBaseClass extends LitElement {
47
47
  this.language = e.detail.language;
48
48
  }
49
49
  render() {
50
- return html `
51
- <div class="finding-container">
52
- <div class="question"><slot>${this.questionTemplate()}</slot></div>
53
- <div class="question-control">${this.controlTemplate()}</div>
54
- </div>
50
+ return html `
51
+ <div class="finding-container">
52
+ <div class="question"><slot>${this.questionTemplate()}</slot></div>
53
+ <div class="question-control">${this.controlTemplate()}</div>
54
+ </div>
55
55
  `;
56
56
  }
57
57
  questionTemplate() {
@@ -76,102 +76,102 @@ export class AbstractFieldBaseClass extends LitElement {
76
76
  // language=CSS
77
77
  return [
78
78
  FlexLayoutClasses,
79
- css `
80
- :host {
81
- display: block;
82
- width: 100%;
83
- padding: 0 25px 0 45px;
84
- box-sizing: border-box;
85
- }
86
-
87
- .finding-container {
88
- width: 100%;
89
- display: flex;
90
- }
91
- .flex-wrapping {
92
- flex-wrap: wrap;
93
- }
94
-
95
- :host(.wide) .finding-container {
96
- flex-direction: column;
97
- }
98
-
99
- :host(.wide) .question {
100
- margin-bottom: -8px;
101
- min-height: 0;
102
- }
103
-
104
- .question-control,
105
- .question {
106
- min-width: 0;
107
- min-height: 57px;
108
- display: flex;
109
- align-items: center;
110
- }
111
- .question {
112
- flex: 2;
113
- }
114
- .question-control {
115
- flex: 3;
116
- }
117
- .add-button {
118
- padding: 3px;
119
- margin: 10px;
120
- background: transparent;
121
- color: var(--primary-color);
122
- border: 1px solid;
123
- }
124
-
125
- .full-width {
126
- width: 100%;
127
- }
128
-
129
- .question-text {
130
- font-weight: 500;
131
- font-size: var(--etools-font-size-13, 13px);
132
- color: var(--primary-text-color);
133
- }
134
-
135
- etools-icon[name='close'] {
136
- cursor: pointer;
137
- }
138
-
139
- .error-text {
140
- color: var(--error-color);
141
- font-size: var(--etools-font-size-12, 12px);
142
- }
143
-
144
- @media (max-width: 1080px) {
145
- :host {
146
- padding: 0 15px;
147
- }
148
- .finding-container {
149
- flex-direction: column;
150
- }
151
- .question,
152
- .question-control {
153
- flex: 0 1 auto;
154
- }
155
- }
156
-
157
- @media print {
158
- .question-control {
159
- align-items: start;
160
- }
161
-
162
- :host(text-field) .question-control {
163
- min-height: 150px;
164
- }
165
-
166
- .question-control .container etools-radio-group {
167
- flex-direction: column;
168
- opacity: 1 !important;
169
- }
170
-
171
- .finding-container {
172
- flex-direction: column;
173
- }
174
- }
79
+ css `
80
+ :host {
81
+ display: block;
82
+ width: 100%;
83
+ padding: 0 25px 0 45px;
84
+ box-sizing: border-box;
85
+ }
86
+
87
+ .finding-container {
88
+ width: 100%;
89
+ display: flex;
90
+ }
91
+ .flex-wrapping {
92
+ flex-wrap: wrap;
93
+ }
94
+
95
+ :host(.wide) .finding-container {
96
+ flex-direction: column;
97
+ }
98
+
99
+ :host(.wide) .question {
100
+ margin-bottom: -8px;
101
+ min-height: 0;
102
+ }
103
+
104
+ .question-control,
105
+ .question {
106
+ min-width: 0;
107
+ min-height: 57px;
108
+ display: flex;
109
+ align-items: center;
110
+ }
111
+ .question {
112
+ flex: 2;
113
+ }
114
+ .question-control {
115
+ flex: 3;
116
+ }
117
+ .add-button {
118
+ padding: 3px;
119
+ margin: 10px;
120
+ background: transparent;
121
+ color: var(--primary-color);
122
+ border: 1px solid;
123
+ }
124
+
125
+ .full-width {
126
+ width: 100%;
127
+ }
128
+
129
+ .question-text {
130
+ font-weight: 500;
131
+ font-size: var(--etools-font-size-13, 13px);
132
+ color: var(--primary-text-color);
133
+ }
134
+
135
+ etools-icon[name='close'] {
136
+ cursor: pointer;
137
+ }
138
+
139
+ .error-text {
140
+ color: var(--error-color);
141
+ font-size: var(--etools-font-size-12, 12px);
142
+ }
143
+
144
+ @media (max-width: 1080px) {
145
+ :host {
146
+ padding: 0 15px;
147
+ }
148
+ .finding-container {
149
+ flex-direction: column;
150
+ }
151
+ .question,
152
+ .question-control {
153
+ flex: 0 1 auto;
154
+ }
155
+ }
156
+
157
+ @media print {
158
+ .question-control {
159
+ align-items: start;
160
+ }
161
+
162
+ :host(text-field) .question-control {
163
+ min-height: 150px;
164
+ }
165
+
166
+ .question-control .container etools-radio-group {
167
+ flex-direction: column;
168
+ opacity: 1 !important;
169
+ }
170
+
171
+ .finding-container {
172
+ flex-direction: column;
173
+ }
174
+ }
175
175
  `
176
176
  ];
177
177
  }