@unicef-polymer/etools-form-builder 4.0.0 → 4.0.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 (38) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/assets/translations.js +8 -0
  4. package/dist/form-attachments-popup/form-attachments-popup.js +135 -135
  5. package/dist/form-fields/abstract-field-base.class.js +100 -100
  6. package/dist/form-fields/field-renderer-component.d.ts +4 -3
  7. package/dist/form-fields/field-renderer-component.js +209 -195
  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.js +63 -63
  11. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -19
  12. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -57
  13. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -19
  14. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  15. package/dist/form-fields/single-fields/boolean-field.js +16 -16
  16. package/dist/form-fields/single-fields/choice-field.js +65 -65
  17. package/dist/form-fields/single-fields/number-field.js +20 -20
  18. package/dist/form-fields/single-fields/scale-field.js +58 -58
  19. package/dist/form-fields/single-fields/text-field.js +30 -30
  20. package/dist/form-groups/form-abstract-group.js +129 -129
  21. package/dist/form-groups/form-card.js +30 -30
  22. package/dist/form-groups/form-collapsed-card.js +40 -34
  23. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  24. package/dist/lib/additional-components/etools-fb-card.js +144 -144
  25. package/dist/lib/styles/attachments.styles.js +61 -61
  26. package/dist/lib/styles/card-styles.js +147 -147
  27. package/dist/lib/styles/dialog.styles.js +83 -83
  28. package/dist/lib/styles/elevation-styles.js +46 -46
  29. package/dist/lib/styles/flex-layout-classes.js +316 -316
  30. package/dist/lib/styles/form-builder-card.styles.js +53 -53
  31. package/dist/lib/styles/page-layout-styles.js +198 -198
  32. package/dist/lib/styles/shared-styles.js +61 -61
  33. package/dist/lib/types/form-builder.types.d.ts +1 -0
  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
package/README.md CHANGED
@@ -1 +1 @@
1
- # Etools FM Form Builder Components
1
+ # Etools FM Form Builder Components
@@ -24,6 +24,8 @@ const translations = {
24
24
  PARTNER: 'Partner',
25
25
  CP_OUTPUT: 'CP Output',
26
26
  PD_SPD: 'PD/SPD',
27
+ GPD: 'GPD',
28
+ EWP_ACTIVITY: 'Key Interventions and Activities',
27
29
  TEXT_MUST_BE_LESS_CHARS: 'Text must be less than {0} character',
28
30
  DOES_NOT_MATCH_PATTERN: 'Does not match allowed pattern',
29
31
  NUMBER_MUST_BE_GREATER_THAN: 'Number must be greater than {0}',
@@ -74,6 +76,8 @@ const translations = {
74
76
  PARTNER: 'Partenaire',
75
77
  CP_OUTPUT: 'Sortie CP',
76
78
  PD_SPD: 'PD/SPD',
79
+ GPD: 'GPD',
80
+ EWP_ACTIVITY: 'Interventions et activités clés',
77
81
  TEXT_MUST_BE_LESS_CHARS: 'Le texte doit comporter moins de {0} caractères',
78
82
  DOES_NOT_MATCH_PATTERN: 'Ne correspond pas au modèle autorisé',
79
83
  NUMBER_MUST_BE_GREATER_THAN: 'Le nombre doit être supérieur à {0}',
@@ -124,6 +128,8 @@ const translations = {
124
128
  PARTNER: 'شريك',
125
129
  CP_OUTPUT: 'إخراج سي بي',
126
130
  PD_SPD: 'بي دي/SPD',
131
+ GPD: 'GPD',
132
+ EWP_ACTIVITY: 'التدخلات والأنشطة الرئيسية',
127
133
  TEXT_MUST_BE_LESS_CHARS: 'يجب أن يكون النص أقل من {0} حرف',
128
134
  DOES_NOT_MATCH_PATTERN: 'لا يتطابق مع النمط المسموح به',
129
135
  NUMBER_MUST_BE_GREATER_THAN: 'يجب أن يكون الرقم أكبر من {0}',
@@ -174,6 +180,8 @@ const translations = {
174
180
  PARTNER: 'Pareja',
175
181
  CP_OUTPUT: 'Salida CP',
176
182
  PD_SPD: 'PD/SPD',
183
+ GPD: 'GPD',
184
+ EWP_ACTIVITY: 'Intervenciones y actividades clave',
177
185
  TEXT_MUST_BE_LESS_CHARS: 'El texto debe tener menos de {0} caracteres',
178
186
  DOES_NOT_MATCH_PATTERN: 'No coincide con el patrón permitido',
179
187
  NUMBER_MUST_BE_GREATER_THAN: 'El número debe ser mayor que {0}',
@@ -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
  }
@@ -4,6 +4,7 @@ import { FieldValidator } from '../lib/utils/validations.helper';
4
4
  import { FieldOption } from './single-fields/scale-field';
5
5
  import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
6
6
  import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
7
+ import '@unicef-polymer/etools-unicef/src/etools-info-tooltip/etools-info-tooltip';
7
8
  export declare class FieldRendererComponent extends LitElement {
8
9
  field: BlueprintField;
9
10
  value: any;
@@ -16,9 +17,9 @@ export declare class FieldRendererComponent extends LitElement {
16
17
  defaultValue: any;
17
18
  render(): TemplateResult;
18
19
  renderField(blueprintField: BlueprintField): TemplateResult;
19
- renderStandardField({ input_type, label, help_text, required, placeholder, styling, name }: BlueprintField, isMandatory?: boolean, isAdditionalField?: boolean): TemplateResult;
20
+ renderStandardField({ input_type, label, help_text, required, placeholder, styling, name, tooltip }: BlueprintField, isMandatory?: boolean, isAdditionalField?: boolean): TemplateResult;
20
21
  renderTooltip(isMandatory: boolean): "" | TemplateResult<1>;
21
- renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }: BlueprintField, isMandatory?: boolean): TemplateResult;
22
- renderFieldLabel(label: string, helperText: string, isMandatory?: boolean): TemplateResult;
22
+ renderRepeatableField({ input_type, label, help_text, required, placeholder, styling, tooltip }: BlueprintField, isMandatory?: boolean): TemplateResult;
23
+ renderFieldLabel(label: string, helperText: string, isMandatory?: boolean, tooltip?: string): TemplateResult;
23
24
  static get styles(): CSSResultArray;
24
25
  }