@unicef-polymer/etools-form-builder 3.2.3 → 3.2.5

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 (41) 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 +100 -100
  5. package/dist/form-fields/field-renderer-component.js +198 -166
  6. package/dist/form-fields/index.d.ts +2 -0
  7. package/dist/form-fields/index.js +2 -0
  8. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +111 -111
  9. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
  10. package/dist/form-fields/repeatable-fields/repeatable-choice-field.d.ts +15 -0
  11. package/dist/form-fields/repeatable-fields/repeatable-choice-field.js +123 -0
  12. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -19
  13. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -57
  14. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -19
  15. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  16. package/dist/form-fields/single-fields/boolean-field.js +16 -16
  17. package/dist/form-fields/single-fields/choice-field.d.ts +17 -0
  18. package/dist/form-fields/single-fields/choice-field.js +121 -0
  19. package/dist/form-fields/single-fields/number-field.js +20 -20
  20. package/dist/form-fields/single-fields/scale-field.js +58 -58
  21. package/dist/form-fields/single-fields/text-field.js +30 -30
  22. package/dist/form-groups/form-abstract-group.d.ts +2 -1
  23. package/dist/form-groups/form-abstract-group.js +130 -129
  24. package/dist/form-groups/form-card.js +30 -30
  25. package/dist/form-groups/form-collapsed-card.js +34 -34
  26. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  27. package/dist/lib/additional-components/etools-fb-card.js +144 -144
  28. package/dist/lib/styles/attachments.styles.js +61 -61
  29. package/dist/lib/styles/card-styles.js +147 -147
  30. package/dist/lib/styles/dialog.styles.js +83 -83
  31. package/dist/lib/styles/elevation-styles.js +46 -46
  32. package/dist/lib/styles/flex-layout-classes.js +316 -316
  33. package/dist/lib/styles/form-builder-card.styles.js +53 -53
  34. package/dist/lib/styles/page-layout-styles.js +198 -198
  35. package/dist/lib/styles/shared-styles.js +61 -61
  36. package/dist/lib/types/form-builder.types.d.ts +1 -1
  37. package/dist/rich-editor/rich-action.js +34 -34
  38. package/dist/rich-editor/rich-text.js +64 -64
  39. package/dist/rich-editor/rich-toolbar.js +125 -125
  40. package/dist/rich-editor/rich-viewer.js +21 -21
  41. package/package.json +52 -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
  }
@@ -50,11 +50,11 @@ export class AbstractFieldBaseClass extends LitElement {
50
50
  this.language = e.detail.language;
51
51
  }
52
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>
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
58
  `;
59
59
  }
60
60
  questionTemplate() {
@@ -79,101 +79,101 @@ export class AbstractFieldBaseClass extends LitElement {
79
79
  // language=CSS
80
80
  return [
81
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
- min-height: 0;
104
- }
105
-
106
- .question-control,
107
- .question {
108
- min-width: 0;
109
- min-height: 57px;
110
- display: flex;
111
- align-items: center;
112
- }
113
- .question {
114
- flex: 2;
115
- }
116
- .question-control {
117
- flex: 3;
118
- }
119
- .add-button {
120
- padding: 3px;
121
- margin: 10px;
122
- background: transparent;
123
- color: var(--primary-color);
124
- border: 1px solid;
125
- }
126
-
127
- .full-width {
128
- width: 100%;
129
- }
130
-
131
- .question-text {
132
- font-weight: 500;
133
- font-size: var(--etools-font-size-13, 13px);
134
- color: var(--primary-text-color);
135
- }
136
-
137
- etools-icon[name='close'] {
138
- cursor: pointer;
139
- }
140
-
141
- .error-text {
142
- color: var(--error-color);
143
- font-size: var(--etools-font-size-12, 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
- }
158
-
159
- @media print {
160
- .question-control {
161
- align-items: start;
162
- }
163
-
164
- :host(text-field) .question-control {
165
- min-height: 150px;
166
- }
167
-
168
- .question-control .container etools-radio-group {
169
- flex-direction: column;
170
- opacity: 1 !important;
171
- }
172
-
173
- .finding-container {
174
- flex-direction: column;
175
- }
176
- }
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
+ min-height: 0;
104
+ }
105
+
106
+ .question-control,
107
+ .question {
108
+ min-width: 0;
109
+ min-height: 57px;
110
+ display: flex;
111
+ align-items: center;
112
+ }
113
+ .question {
114
+ flex: 2;
115
+ }
116
+ .question-control {
117
+ flex: 3;
118
+ }
119
+ .add-button {
120
+ padding: 3px;
121
+ margin: 10px;
122
+ background: transparent;
123
+ color: var(--primary-color);
124
+ border: 1px solid;
125
+ }
126
+
127
+ .full-width {
128
+ width: 100%;
129
+ }
130
+
131
+ .question-text {
132
+ font-weight: 500;
133
+ font-size: var(--etools-font-size-13, 13px);
134
+ color: var(--primary-text-color);
135
+ }
136
+
137
+ etools-icon[name='close'] {
138
+ cursor: pointer;
139
+ }
140
+
141
+ .error-text {
142
+ color: var(--error-color);
143
+ font-size: var(--etools-font-size-12, 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
+ }
158
+
159
+ @media print {
160
+ .question-control {
161
+ align-items: start;
162
+ }
163
+
164
+ :host(text-field) .question-control {
165
+ min-height: 150px;
166
+ }
167
+
168
+ .question-control .container etools-radio-group {
169
+ flex-direction: column;
170
+ opacity: 1 !important;
171
+ }
172
+
173
+ .finding-container {
174
+ flex-direction: column;
175
+ }
176
+ }
177
177
  `
178
178
  ];
179
179
  }