@unicef-polymer/etools-form-builder 4.0.2 → 4.0.4

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 (38) 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 +203 -203
  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-choice-field.d.ts +1 -0
  9. package/dist/form-fields/repeatable-fields/repeatable-choice-field.js +66 -63
  10. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -19
  11. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -57
  12. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -19
  13. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  14. package/dist/form-fields/single-fields/boolean-field.js +16 -16
  15. package/dist/form-fields/single-fields/choice-field.d.ts +2 -0
  16. package/dist/form-fields/single-fields/choice-field.js +68 -65
  17. package/dist/form-fields/single-fields/number-field.js +20 -20
  18. package/dist/form-fields/single-fields/scale-field.d.ts +1 -0
  19. package/dist/form-fields/single-fields/scale-field.js +58 -58
  20. package/dist/form-fields/single-fields/text-field.js +30 -30
  21. package/dist/form-groups/form-abstract-group.js +129 -129
  22. package/dist/form-groups/form-card.js +30 -30
  23. package/dist/form-groups/form-collapsed-card.js +36 -39
  24. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  25. package/dist/lib/additional-components/etools-fb-card.js +144 -144
  26. package/dist/lib/styles/attachments.styles.js +61 -61
  27. package/dist/lib/styles/card-styles.js +147 -147
  28. package/dist/lib/styles/dialog.styles.js +83 -83
  29. package/dist/lib/styles/elevation-styles.js +46 -46
  30. package/dist/lib/styles/flex-layout-classes.js +316 -316
  31. package/dist/lib/styles/form-builder-card.styles.js +53 -53
  32. package/dist/lib/styles/page-layout-styles.js +198 -198
  33. package/dist/lib/styles/shared-styles.js +61 -61
  34. package/dist/rich-editor/rich-action.js +34 -34
  35. package/dist/rich-editor/rich-text.js +64 -64
  36. package/dist/rich-editor/rich-toolbar.js +125 -125
  37. package/dist/rich-editor/rich-viewer.js +21 -21
  38. package/package.json +53 -53
@@ -32,12 +32,12 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
32
32
  const mandatoryClass = blueprintField.styling.includes(StructureTypes.MANDATORY_WARNING)
33
33
  ? 'mandatory_warning '
34
34
  : '';
35
- return html `
36
- <div class="${`${additionalClass}${wideClass}${mandatoryClass}finding-container`}">
35
+ return html `
36
+ <div class="${`${additionalClass}${wideClass}${mandatoryClass}finding-container`}">
37
37
  ${blueprintField.repeatable
38
38
  ? this.renderRepeatableField(blueprintField, !!mandatoryClass)
39
- : this.renderStandardField(blueprintField, !!mandatoryClass, isAdditionalField)}
40
- </div>
39
+ : this.renderStandardField(blueprintField, !!mandatoryClass, isAdditionalField)}
40
+ </div>
41
41
  `;
42
42
  }
43
43
  renderStandardField({ input_type, label, help_text, required, placeholder, styling, name, tooltip }, isMandatory = false, isAdditionalField = false) {
@@ -45,100 +45,100 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
45
45
  const isWide = styling.includes(StructureTypes.WIDE);
46
46
  switch (input_type) {
47
47
  case FieldTypes.TEXT_TYPE:
48
- return html `
49
- <text-field
50
- class="${isWide ? 'wide' : ''}"
51
- ?is-readonly="${this.readonly}"
52
- ?required="${required}"
53
- .placeholder="${placeholder}"
54
- .name="${name}"
55
- .value="${this.value}"
56
- .validators="${this.validations}"
57
- .errorMessage="${this.errorMessage}"
58
- .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
59
- .showRichEditor="${isAdditionalField}"
60
- >
61
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
62
- </text-field>
48
+ return html `
49
+ <text-field
50
+ class="${isWide ? 'wide' : ''}"
51
+ ?is-readonly="${this.readonly}"
52
+ ?required="${required}"
53
+ .placeholder="${placeholder}"
54
+ .name="${name}"
55
+ .value="${this.value}"
56
+ .validators="${this.validations}"
57
+ .errorMessage="${this.errorMessage}"
58
+ .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
59
+ .showRichEditor="${isAdditionalField}"
60
+ >
61
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
62
+ </text-field>
63
63
  `;
64
64
  case FieldTypes.NUMBER_TYPE:
65
65
  case FieldTypes.NUMBER_FLOAT_TYPE:
66
66
  case FieldTypes.NUMBER_INTEGER_TYPE:
67
- return html `
68
- <number-field
69
- ?is-readonly="${this.readonly}"
70
- ?required="${required}"
71
- .placeholder="${placeholder}"
72
- .value="${this.value}"
73
- .name="${name}"
74
- .validators="${this.validations}"
75
- .errorMessage="${this.errorMessage}"
76
- .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
77
- .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
78
- >
79
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
80
- </number-field>
67
+ return html `
68
+ <number-field
69
+ ?is-readonly="${this.readonly}"
70
+ ?required="${required}"
71
+ .placeholder="${placeholder}"
72
+ .value="${this.value}"
73
+ .name="${name}"
74
+ .validators="${this.validations}"
75
+ .errorMessage="${this.errorMessage}"
76
+ .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
77
+ .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
78
+ >
79
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
80
+ </number-field>
81
81
  `;
82
82
  case FieldTypes.BOOL_TYPE:
83
- return html `
84
- <boolean-field
85
- ?is-readonly="${this.readonly}"
86
- ?required="${required}"
87
- .value="${this.value}"
88
- .name="${name}"
89
- .validators="${this.validations}"
90
- .errorMessage="${this.errorMessage}"
91
- .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
92
- >
93
- ${this.renderFieldLabel(label, help_text, isMandatory)}
94
- </boolean-field>
83
+ return html `
84
+ <boolean-field
85
+ ?is-readonly="${this.readonly}"
86
+ ?required="${required}"
87
+ .value="${this.value}"
88
+ .name="${name}"
89
+ .validators="${this.validations}"
90
+ .errorMessage="${this.errorMessage}"
91
+ .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
92
+ >
93
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
94
+ </boolean-field>
95
95
  `;
96
96
  case FieldTypes.SCALE_TYPE:
97
- return html `
98
- <scale-field
99
- .options="${this.options}"
100
- ?is-readonly="${this.readonly}"
101
- ?required="${required}"
102
- .placeholder="${placeholder}"
103
- .value="${this.value}"
104
- .name="${name}"
105
- .validators="${this.validations}"
106
- .errorMessage="${this.errorMessage}"
107
- .defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
108
- >
109
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
110
- </scale-field>
97
+ return html `
98
+ <scale-field
99
+ .options="${this.options}"
100
+ ?is-readonly="${this.readonly}"
101
+ ?required="${required}"
102
+ .placeholder="${placeholder}"
103
+ .value="${this.value}"
104
+ .name="${name}"
105
+ .validators="${this.validations}"
106
+ .errorMessage="${this.errorMessage}"
107
+ .defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
108
+ >
109
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
110
+ </scale-field>
111
111
  `;
112
112
  case FieldTypes.MULTIPLE_CHOICE_TYPE:
113
- return html `
114
- <choice-field
115
- .options="${this.options}"
116
- ?is-readonly="${this.readonly}"
117
- ?required="${required}"
118
- .placeholder="${placeholder}"
119
- .value="${this.value}"
120
- .name="${name}"
121
- .validators="${this.validations}"
122
- .errorMessage="${this.errorMessage}"
123
- .defaultValue="${(_e = this.field) === null || _e === void 0 ? void 0 : _e.default_value}"
124
- >
125
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
126
- </choice-field>
113
+ return html `
114
+ <choice-field
115
+ .options="${this.options}"
116
+ ?is-readonly="${this.readonly}"
117
+ ?required="${required}"
118
+ .placeholder="${placeholder}"
119
+ .value="${this.value}"
120
+ .name="${name}"
121
+ .validators="${this.validations}"
122
+ .errorMessage="${this.errorMessage}"
123
+ .defaultValue="${(_e = this.field) === null || _e === void 0 ? void 0 : _e.default_value}"
124
+ >
125
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
126
+ </choice-field>
127
127
  `;
128
128
  case FieldTypes.FILE_TYPE:
129
- return html `
130
- <attachments-field
131
- ?is-readonly="${this.readonly}"
132
- ?required="${required}"
133
- .placeholder="${placeholder}"
134
- .value="${this.value}"
135
- .name="${name}"
136
- .validators="${this.validations}"
137
- .errorMessage="${this.errorMessage}"
138
- .computedPath="${this.computedPath}"
139
- >
140
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
141
- </attachments-field>
129
+ return html `
130
+ <attachments-field
131
+ ?is-readonly="${this.readonly}"
132
+ ?required="${required}"
133
+ .placeholder="${placeholder}"
134
+ .value="${this.value}"
135
+ .name="${name}"
136
+ .validators="${this.validations}"
137
+ .errorMessage="${this.errorMessage}"
138
+ .computedPath="${this.computedPath}"
139
+ >
140
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
141
+ </attachments-field>
142
142
  `;
143
143
  default:
144
144
  console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
@@ -147,8 +147,8 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
147
147
  }
148
148
  renderTooltip(isMandatory) {
149
149
  return isMandatory
150
- ? html ` <sl-tooltip placement="top" content="${getTranslation(this.language, 'PLEASE_ANSWER')}">
151
- <etools-icon id="users-icon" name="info-outline"></etools-icon>
150
+ ? html ` <sl-tooltip placement="top" content="${getTranslation(this.language, 'PLEASE_ANSWER')}">
151
+ <etools-icon id="users-icon" name="info-outline"></etools-icon>
152
152
  </sl-tooltip>`
153
153
  : ``;
154
154
  }
@@ -157,83 +157,83 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
157
157
  const isWide = styling.includes(StructureTypes.WIDE);
158
158
  switch (input_type) {
159
159
  case FieldTypes.TEXT_TYPE:
160
- return html `
161
- <repeatable-text-field
162
- class="${isWide ? 'wide' : ''}"
163
- ?is-readonly="${this.readonly}"
164
- ?required="${required}"
165
- .placeholder="${placeholder}"
166
- .value="${this.value}"
167
- .validators="${this.validations}"
168
- .errorMessage="${this.errorMessage}"
169
- .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
170
- >
171
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
172
- </repeatable-text-field>
160
+ return html `
161
+ <repeatable-text-field
162
+ class="${isWide ? 'wide' : ''}"
163
+ ?is-readonly="${this.readonly}"
164
+ ?required="${required}"
165
+ .placeholder="${placeholder}"
166
+ .value="${this.value}"
167
+ .validators="${this.validations}"
168
+ .errorMessage="${this.errorMessage}"
169
+ .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
170
+ >
171
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
172
+ </repeatable-text-field>
173
173
  `;
174
174
  case FieldTypes.NUMBER_TYPE:
175
175
  case FieldTypes.NUMBER_FLOAT_TYPE:
176
176
  case FieldTypes.NUMBER_INTEGER_TYPE:
177
- return html `
178
- <repeatable-number-field
179
- class="${isWide ? 'wide' : ''}"
180
- ?is-readonly="${this.readonly}"
181
- ?required="${required}"
182
- .placeholder="${placeholder}"
183
- .value="${this.value}"
184
- .validators="${this.validations}"
185
- .errorMessage="${this.errorMessage}"
186
- .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
187
- .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
188
- >
189
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
190
- </repeatable-number-field>
177
+ return html `
178
+ <repeatable-number-field
179
+ class="${isWide ? 'wide' : ''}"
180
+ ?is-readonly="${this.readonly}"
181
+ ?required="${required}"
182
+ .placeholder="${placeholder}"
183
+ .value="${this.value}"
184
+ .validators="${this.validations}"
185
+ .errorMessage="${this.errorMessage}"
186
+ .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
187
+ .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
188
+ >
189
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
190
+ </repeatable-number-field>
191
191
  `;
192
192
  case FieldTypes.SCALE_TYPE:
193
- return html `
194
- <repeatable-scale-field
195
- class="${isWide ? 'wide' : ''}"
196
- .options="${this.options}"
197
- ?is-readonly="${this.readonly}"
198
- ?required="${required}"
199
- .placeholder="${placeholder}"
200
- .value="${this.value}"
201
- .validators="${this.validations}"
202
- .errorMessage="${this.errorMessage}"
203
- .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
204
- >
205
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
206
- </repeatable-scale-field>
193
+ return html `
194
+ <repeatable-scale-field
195
+ class="${isWide ? 'wide' : ''}"
196
+ .options="${this.options}"
197
+ ?is-readonly="${this.readonly}"
198
+ ?required="${required}"
199
+ .placeholder="${placeholder}"
200
+ .value="${this.value}"
201
+ .validators="${this.validations}"
202
+ .errorMessage="${this.errorMessage}"
203
+ .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
204
+ >
205
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
206
+ </repeatable-scale-field>
207
207
  `;
208
208
  case FieldTypes.MULTIPLE_CHOICE_TYPE:
209
- return html `
210
- <repeatable-choice-field
211
- class="${isWide ? 'wide' : ''}"
212
- .options="${this.options}"
213
- ?is-readonly="${this.readonly}"
214
- ?required="${required}"
215
- .placeholder="${placeholder}"
216
- .value="${this.value}"
217
- .validators="${this.validations}"
218
- .errorMessage="${this.errorMessage}"
219
- .defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
220
- >
221
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
222
- </repeatable-choice-field>
209
+ return html `
210
+ <repeatable-choice-field
211
+ class="${isWide ? 'wide' : ''}"
212
+ .options="${this.options}"
213
+ ?is-readonly="${this.readonly}"
214
+ ?required="${required}"
215
+ .placeholder="${placeholder}"
216
+ .value="${this.value}"
217
+ .validators="${this.validations}"
218
+ .errorMessage="${this.errorMessage}"
219
+ .defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
220
+ >
221
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
222
+ </repeatable-choice-field>
223
223
  `;
224
224
  case FieldTypes.FILE_TYPE:
225
- return html `
226
- <repeatable-attachments-field
227
- ?is-readonly="${this.readonly}"
228
- ?required="${required}"
229
- .placeholder="${placeholder}"
230
- .value="${this.value}"
231
- .validators="${this.validations}"
232
- .errorMessage="${this.errorMessage}"
233
- .computedPath="${this.computedPath}"
234
- >
235
- ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
236
- </repeatable-attachments-field>
225
+ return html `
226
+ <repeatable-attachments-field
227
+ ?is-readonly="${this.readonly}"
228
+ ?required="${required}"
229
+ .placeholder="${placeholder}"
230
+ .value="${this.value}"
231
+ .validators="${this.validations}"
232
+ .errorMessage="${this.errorMessage}"
233
+ .computedPath="${this.computedPath}"
234
+ >
235
+ ${this.renderFieldLabel(label, help_text, isMandatory, tooltip)}
236
+ </repeatable-attachments-field>
237
237
  `;
238
238
  default:
239
239
  console.warn(`FormBuilderGroup: Unknown field type: ${input_type}`);
@@ -241,21 +241,21 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
241
241
  }
242
242
  }
243
243
  renderFieldLabel(label, helperText, isMandatory = false, tooltip) {
244
- return html `
245
- <div class="layout vertical question-container">
246
- <div class="question-text">
247
- ${this.renderTooltip(isMandatory)}
244
+ return html `
245
+ <div class="layout vertical question-container">
246
+ <div class="question-text">
247
+ ${this.renderTooltip(isMandatory)}
248
248
  ${tooltip
249
- ? html `
250
- <etools-info-tooltip hoist to="body" class="question-tooltip">
251
- <span slot="field">${label}</span>
252
- <span slot="message">${tooltip}</span>
253
- </etools-info-tooltip>
249
+ ? html `
250
+ <etools-info-tooltip hoist to="body" class="question-tooltip">
251
+ <span slot="field">${label}</span>
252
+ <span slot="message">${tooltip}</span>
253
+ </etools-info-tooltip>
254
254
  `
255
- : html `${label}`}
256
- </div>
257
- <div class="question-details">${helperText}</div>
258
- </div>
255
+ : html `${label}`}
256
+ </div>
257
+ <div class="question-details">${helperText}</div>
258
+ </div>
259
259
  `;
260
260
  }
261
261
  static get styles() {
@@ -263,41 +263,41 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
263
263
  return [
264
264
  FlexLayoutClasses,
265
265
  FormBuilderCardStyles,
266
- css `
267
- .additional-field {
268
- padding-top: 15px;
269
- padding-bottom: 20px;
270
- }
271
- .wide-field-container {
272
- padding-bottom: 10px;
273
- }
274
- .wide-field-container .question-container {
275
- min-height: 0;
276
- padding: 7px 0 0;
277
- }
278
- .wide-field-container .question-text {
279
- color: var(--secondary-text-color);
280
- font-weight: 600;
281
- }
282
- .mandatory_warning etools-icon {
283
- --etools-icon-fill-color: #f59e0b !important;
284
- }
285
- :host(:not([readonly])) {
286
- .overall {
287
- background-color: #ffffff;
288
- border-style: inset;
289
- border-width: 0 1px 1px 1px;
290
- border-color: var(--dark-divider-color);
291
- }
292
- }
293
- .question-tooltip {
294
- align-items: start;
295
- }
296
- @media print {
297
- :host {
298
- break-inside: avoid;
299
- }
300
- }
266
+ css `
267
+ .additional-field {
268
+ padding-top: 15px;
269
+ padding-bottom: 20px;
270
+ }
271
+ .wide-field-container {
272
+ padding-bottom: 10px;
273
+ }
274
+ .wide-field-container .question-container {
275
+ min-height: 0;
276
+ padding: 7px 0 0;
277
+ }
278
+ .wide-field-container .question-text {
279
+ color: var(--secondary-text-color);
280
+ font-weight: 600;
281
+ }
282
+ .mandatory_warning etools-icon {
283
+ --etools-icon-fill-color: #f59e0b !important;
284
+ }
285
+ :host(:not([readonly])) {
286
+ .overall {
287
+ background-color: #ffffff;
288
+ border-style: inset;
289
+ border-width: 0 1px 1px 1px;
290
+ border-color: var(--dark-divider-color);
291
+ }
292
+ }
293
+ .question-tooltip {
294
+ align-items: start;
295
+ }
296
+ @media print {
297
+ :host {
298
+ break-inside: avoid;
299
+ }
300
+ }
301
301
  `
302
302
  ];
303
303
  }