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