@unicef-polymer/etools-form-builder 3.0.0-rc.9 → 3.1.1

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 (33) hide show
  1. package/dist/assets/translations.js +70 -2
  2. package/dist/form-attachments-popup/form-attachments-popup.d.ts +4 -0
  3. package/dist/form-attachments-popup/form-attachments-popup.js +108 -5
  4. package/dist/form-fields/abstract-field-base.class.d.ts +1 -0
  5. package/dist/form-fields/abstract-field-base.class.js +10 -20
  6. package/dist/form-fields/field-renderer-component.d.ts +7 -3
  7. package/dist/form-fields/field-renderer-component.js +50 -19
  8. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +3 -3
  9. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +0 -2
  10. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +0 -2
  11. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +0 -5
  12. package/dist/form-fields/single-fields/boolean-field.js +0 -5
  13. package/dist/form-fields/single-fields/number-field.js +1 -3
  14. package/dist/form-fields/single-fields/scale-field.js +0 -2
  15. package/dist/form-fields/single-fields/text-field.js +1 -2
  16. package/dist/form-groups/form-abstract-group.d.ts +2 -1
  17. package/dist/form-groups/form-abstract-group.js +7 -3
  18. package/dist/form-groups/form-card.js +6 -0
  19. package/dist/lib/additional-components/confirmation-dialog.js +1 -1
  20. package/dist/lib/additional-components/etools-fb-card.js +20 -10
  21. package/dist/lib/styles/attachments.styles.js +3 -8
  22. package/dist/lib/styles/card-styles.js +5 -9
  23. package/dist/lib/styles/dialog.styles.js +1 -1
  24. package/dist/lib/styles/elevation-styles.d.ts +2 -2
  25. package/dist/lib/styles/elevation-styles.js +20 -7
  26. package/dist/lib/styles/form-builder-card.styles.js +10 -3
  27. package/dist/lib/styles/shared-styles.js +3 -9
  28. package/dist/lib/utils/translate.js +1 -1
  29. package/package.json +23 -26
  30. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -7
  31. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +0 -102
  32. package/dist/lib/styles/input-styles.d.ts +0 -2
  33. package/dist/lib/styles/input-styles.js +0 -143
@@ -29,7 +29,8 @@ const translations = {
29
29
  NUMBER_MUST_BE_GREATER_THAN: 'Number must be greater than {0}',
30
30
  NUMBER_MUST_BE_LOWER_THAN: 'Number must be lower than {0}',
31
31
  DOCUMENT_TYPE: 'Document type',
32
- SELECT_DOCUMENT_TYPE: 'Select Document Type'
32
+ SELECT_DOCUMENT_TYPE: 'Select Document Type',
33
+ PLEASE_ANSWER: 'Important: Please provide the answer if available'
33
34
  },
34
35
  fr: {
35
36
  SAVE: 'Sauvegarder',
@@ -61,7 +62,74 @@ const translations = {
61
62
  NUMBER_MUST_BE_GREATER_THAN: 'Le nombre doit être supérieur à {0}',
62
63
  NUMBER_MUST_BE_LOWER_THAN: 'Le nombre doit être inférieur à {0}',
63
64
  DOCUMENT_TYPE: 'Type de document',
64
- SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document'
65
+ SELECT_DOCUMENT_TYPE: 'Sélectionnez le type de document',
66
+ PLEASE_ANSWER: 'Important : veuillez fournir la réponse si disponible'
67
+ },
68
+ ar: {
69
+ SAVE: 'يحفظ',
70
+ DOWNLOAD: 'تحميل',
71
+ CHANGE: 'يتغير',
72
+ DELETE: 'يمسح',
73
+ CANCEL: 'يلغي',
74
+ OK: 'نعم',
75
+ ADD: 'يضيف',
76
+ UPLOAD_ATTACHMENTS_FAILED: 'لا يمكن تحميل المرفقات. الرجاء معاودة المحاولة في وقت لاحق',
77
+ REQUIRED_FIELD: 'هذه الخانة مطلوبه',
78
+ MUST_BE_INTEGER: 'يجب أن يكون صحيحا',
79
+ MUST_BE_NUMBER: 'يجب أن يكون رقما',
80
+ CLEAR: 'واضح',
81
+ GROUP_REQUIRED: 'المجموعة مطلوبة. يجب أن تكون هناك مجموعة واحدة على الأقل',
82
+ GROUP: 'مجموعة',
83
+ THIS_GROUP: 'هذه المجموعة',
84
+ CHECK_FIELDS_TRY_AGAIN: 'يرجى التحقق من كافة الحقول والمحاولة مرة أخرى',
85
+ CONFIRM_DELETE: 'هل أنت متأكد أنك تريد حذف',
86
+ UPLOAD_FILES: 'تحميل الملفات',
87
+ FILE: 'ملف',
88
+ FILES: 'ملفات',
89
+ ATTACHMENTS_FOR: 'المرفقات ل',
90
+ PARTNER: 'شريك',
91
+ CP_OUTPUT: 'إخراج سي بي',
92
+ PD_SPD: 'بي دي/SPD',
93
+ TEXT_MUST_BE_LESS_CHARS: 'يجب أن يكون النص أقل من {0} حرف',
94
+ DOES_NOT_MATCH_PATTERN: 'لا يتطابق مع النمط المسموح به',
95
+ NUMBER_MUST_BE_GREATER_THAN: 'يجب أن يكون الرقم أكبر من {0}',
96
+ NUMBER_MUST_BE_LOWER_THAN: 'يجب أن يكون الرقم أقل من {0}',
97
+ DOCUMENT_TYPE: 'نوع الوثيقة',
98
+ SELECT_DOCUMENT_TYPE: 'حدد نوع المستند',
99
+ PLEASE_ANSWER: 'هام: يرجى تقديم الإجابة إذا كانت متوفرة'
100
+ },
101
+ es: {
102
+ SAVE: 'Guardar',
103
+ DOWNLOAD: 'Descargar',
104
+ CHANGE: 'Cambia',
105
+ DELETE: 'Eliminar',
106
+ CANCEL: 'Cancelar',
107
+ OK: 'Biean',
108
+ ADD: 'Añadir',
109
+ UPLOAD_ATTACHMENTS_FAILED: 'No se pueden cargar archivos adjuntos. Por favor, inténtelo de nuevo más tarde',
110
+ REQUIRED_FIELD: 'Este campo es obligatorio',
111
+ MUST_BE_INTEGER: 'Debe ser un entero',
112
+ MUST_BE_NUMBER: 'Tiene que ser un número',
113
+ CLEAR: 'Claro',
114
+ GROUP_REQUIRED: 'Se requiere grupo. Debe existir al menos un grupo.',
115
+ GROUP: 'grupo',
116
+ THIS_GROUP: 'este grupo',
117
+ CHECK_FIELDS_TRY_AGAIN: 'Por favor revisa todos los campos y vuelve a intentarlo.',
118
+ CONFIRM_DELETE: '¿Estás seguro de que quieres eliminar?',
119
+ UPLOAD_FILES: 'Subir archivos',
120
+ FILE: 'Archivo',
121
+ FILES: 'Archivos',
122
+ ATTACHMENTS_FOR: 'Adjuntos para',
123
+ PARTNER: 'Pareja',
124
+ CP_OUTPUT: 'Salida CP',
125
+ PD_SPD: 'PD/SPD',
126
+ TEXT_MUST_BE_LESS_CHARS: 'El texto debe tener menos de {0} caracteres',
127
+ DOES_NOT_MATCH_PATTERN: 'No coincide con el patrón permitido',
128
+ NUMBER_MUST_BE_GREATER_THAN: 'El número debe ser mayor que {0}',
129
+ NUMBER_MUST_BE_LOWER_THAN: 'El número debe ser inferior a {0}',
130
+ DOCUMENT_TYPE: 'Tipo de Documento',
131
+ SELECT_DOCUMENT_TYPE: 'Seleccionar tipo de documento',
132
+ PLEASE_ANSWER: 'Importante: proporcione la respuesta si está disponible.'
65
133
  }
66
134
  };
67
135
  export default translations;
@@ -1,6 +1,7 @@
1
1
  import '@unicef-polymer/etools-unicef/src/etools-dialog/etools-dialog';
2
2
  import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload-multi';
3
3
  import '@unicef-polymer/etools-unicef/src/etools-dropdown/etools-dropdown';
4
+ import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
4
5
  import { CSSResultArray, LitElement, TemplateResult } from 'lit';
5
6
  import { GenericObject } from '../lib/types/global.types';
6
7
  import { BlueprintMetadata } from '../lib/types/form-builder.types';
@@ -65,6 +66,9 @@ export declare class FormAttachmentsPopup extends LitElement {
65
66
  get uploadUrl(): string;
66
67
  get jwtLocalStorageKey(): string;
67
68
  constructor();
69
+ connectedCallback(): void;
70
+ disconnectedCallback(): void;
71
+ handleLanguageChange(e: CustomEvent): void;
68
72
  render(): TemplateResult | void;
69
73
  /**
70
74
  * on Cancel button click
@@ -2,16 +2,17 @@ import { __decorate } from "tslib";
2
2
  import '@unicef-polymer/etools-unicef/src/etools-dialog/etools-dialog';
3
3
  import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload-multi';
4
4
  import '@unicef-polymer/etools-unicef/src/etools-dropdown/etools-dropdown';
5
+ import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
5
6
  import { deleteFileFromDexie } from '@unicef-polymer/etools-unicef/src/etools-upload/offline/dexie-operations';
6
- import { css, LitElement } from 'lit';
7
+ import { css, html, LitElement } from 'lit';
7
8
  import { property, query, customElement } from 'lit/decorators.js';
8
9
  import { clone, equals } from 'ramda';
9
- import { template } from './form-attachments-popup.tpl';
10
10
  import { fireEvent } from '../lib/utils/fire-custom-event';
11
11
  import { SharedStyles } from '../lib/styles/shared-styles';
12
12
  import { AttachmentsStyles } from '../lib/styles/attachments.styles';
13
13
  import { AttachmentsHelper } from './form-attachments-popup.helper';
14
14
  import { getTranslation } from '../lib/utils/translate';
15
+ import { DialogStyles } from '../lib/styles/dialog.styles';
15
16
  let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
16
17
  set dialogData({ attachments, title, metadata, readonly, computedPath, errors }) {
17
18
  this.popupTitle = title;
@@ -47,11 +48,113 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
47
48
  throw new Error('Please initialize attachments popup before use');
48
49
  }
49
50
  if (!this.language) {
50
- this.language = window.localStorage.defaultLanguage || 'en';
51
+ this.language = window.EtoolsLanguage || 'en';
51
52
  }
52
53
  }
54
+ connectedCallback() {
55
+ super.connectedCallback();
56
+ document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
57
+ }
58
+ disconnectedCallback() {
59
+ super.disconnectedCallback();
60
+ document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
61
+ }
62
+ handleLanguageChange(e) {
63
+ this.language = e.detail.language;
64
+ }
53
65
  render() {
54
- return template.call(this);
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">
91
+ ${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
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>
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>
157
+ `;
55
158
  }
56
159
  /**
57
160
  * on Cancel button click
@@ -73,7 +176,7 @@ let FormAttachmentsPopup = class FormAttachmentsPopup extends LitElement {
73
176
  this.attachments.forEach((attachment, index) => {
74
177
  if (!attachment.file_type) {
75
178
  fileTypeNotSelected = true;
76
- this.errors[index] = { file_type: ['This field is required'] };
179
+ this.errors[index] = { file_type: [getTranslation(this.language, 'REQUIRED_FIELD')] };
77
180
  }
78
181
  else {
79
182
  this.errors[index] = [];
@@ -10,6 +10,7 @@ export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
10
10
  get isReadonly(): boolean;
11
11
  required: boolean;
12
12
  placeholder: string;
13
+ name: string;
13
14
  value: T | null;
14
15
  validators: FieldValidator[];
15
16
  touched: boolean;
@@ -25,12 +25,13 @@ export class AbstractFieldBaseClass extends LitElement {
25
25
  this.questionText = '';
26
26
  this.required = false;
27
27
  this.placeholder = '';
28
+ this.name = '';
28
29
  this.value = null;
29
30
  this.validators = [];
30
31
  this.touched = false;
31
32
  this._readonly = false;
32
33
  if (!this.language) {
33
- this.language = window.localStorage.defaultLanguage || 'en';
34
+ this.language = window.EtoolsLanguage || 'en';
34
35
  }
35
36
  this.handleLanguageChange = this.handleLanguageChange.bind(this);
36
37
  }
@@ -121,37 +122,23 @@ export class AbstractFieldBaseClass extends LitElement {
121
122
  border: 1px solid;
122
123
  }
123
124
 
124
- .full-width,
125
- paper-input,
126
- paper-textarea {
125
+ .full-width {
127
126
  width: 100%;
128
127
  }
129
128
 
130
129
  .question-text {
131
130
  font-weight: 500;
132
- font-size: 13px;
131
+ font-size: var(--etools-font-size-13, 13px);
133
132
  color: var(--primary-text-color);
134
133
  }
135
134
 
136
- paper-input,
137
- paper-textarea {
138
- outline: none !important;
139
- }
140
- paper-input[required],
141
- paper-textarea[required] {
142
- --paper-input-container-label_-_background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221235%22%20height%3D%221175%22%3E%3Cpath%20fill%3D%22%23de0000%22%20d%3D%22M0%2C449h1235l-999%2C726%20382-1175%20382%2C1175z%22%2F%3E%3C%2Fsvg%3E')
143
- no-repeat 98% 14%/7px;
144
- --paper-input-container-label_-_max-width: max-content;
145
- --paper-input-container-label_-_padding-right: 15px;
146
- }
147
-
148
- iron-icon[icon='close'] {
135
+ etools-icon[name='close'] {
149
136
  cursor: pointer;
150
137
  }
151
138
 
152
139
  .error-text {
153
140
  color: var(--error-color);
154
- font-size: 12px;
141
+ font-size: var(--etools-font-size-12, 12px);
155
142
  }
156
143
 
157
144
  @media (max-width: 1080px) {
@@ -176,7 +163,7 @@ export class AbstractFieldBaseClass extends LitElement {
176
163
  min-height: 150px;
177
164
  }
178
165
 
179
- .question-control .container paper-radio-group {
166
+ .question-control .container etools-radio-group {
180
167
  flex-direction: column;
181
168
  opacity: 1 !important;
182
169
  }
@@ -204,6 +191,9 @@ __decorate([
204
191
  __decorate([
205
192
  property()
206
193
  ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
194
+ __decorate([
195
+ property()
196
+ ], AbstractFieldBaseClass.prototype, "name", void 0);
207
197
  __decorate([
208
198
  property()
209
199
  ], AbstractFieldBaseClass.prototype, "value", void 0);
@@ -2,9 +2,12 @@ import { CSSResultArray, LitElement, TemplateResult } from 'lit';
2
2
  import { BlueprintField } from '../lib/types/form-builder.types';
3
3
  import { FieldValidator } from '../lib/utils/validations.helper';
4
4
  import { FieldOption } from './single-fields/scale-field';
5
+ import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
6
+ import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
5
7
  export declare class FieldRendererComponent extends LitElement {
6
8
  field: BlueprintField;
7
9
  value: any;
10
+ language: string;
8
11
  errorMessage: string | null;
9
12
  validations: FieldValidator[];
10
13
  readonly: boolean;
@@ -13,8 +16,9 @@ export declare class FieldRendererComponent extends LitElement {
13
16
  defaultValue: any;
14
17
  render(): TemplateResult;
15
18
  renderField(blueprintField: BlueprintField): TemplateResult;
16
- renderStandardField({ input_type, label, help_text, required, placeholder, styling }: BlueprintField): TemplateResult;
17
- renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }: BlueprintField): TemplateResult;
18
- renderFieldLabel(label: string, helperText: string): TemplateResult;
19
+ renderStandardField({ input_type, label, help_text, required, placeholder, styling, name }: BlueprintField, isMandatory?: boolean): TemplateResult;
20
+ 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;
19
23
  static get styles(): CSSResultArray;
20
24
  }
@@ -4,6 +4,9 @@ import { property, customElement } from 'lit/decorators.js';
4
4
  import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
5
5
  import { FieldTypes, StructureTypes } from '../form-groups';
6
6
  import { FormBuilderCardStyles } from '../lib/styles/form-builder-card.styles';
7
+ import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
8
+ import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
9
+ import { getTranslation } from '../lib/utils/translate';
7
10
  let FieldRendererComponent = class FieldRendererComponent extends LitElement {
8
11
  constructor() {
9
12
  super(...arguments);
@@ -21,18 +24,21 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
21
24
  }
22
25
  renderField(blueprintField) {
23
26
  const additionalClass = blueprintField.styling.includes(StructureTypes.ADDITIONAL)
24
- ? 'additional-field '
25
- : '';
27
+ ? `additional-field ${blueprintField.name} `
28
+ : `${blueprintField.name} `;
26
29
  const wideClass = blueprintField.styling.includes(StructureTypes.WIDE) ? 'wide-field-container ' : '';
30
+ const mandatoryClass = blueprintField.styling.includes(StructureTypes.MANDATORY_WARNING)
31
+ ? 'mandatory_warning '
32
+ : '';
27
33
  return html `
28
- <div class="${`${additionalClass}${wideClass}finding-container`}">
34
+ <div class="${`${additionalClass}${wideClass}${mandatoryClass}finding-container`}">
29
35
  ${blueprintField.repeatable
30
- ? this.renderRepeatableField(blueprintField)
31
- : this.renderStandardField(blueprintField)}
36
+ ? this.renderRepeatableField(blueprintField, !!mandatoryClass)
37
+ : this.renderStandardField(blueprintField, !!mandatoryClass)}
32
38
  </div>
33
39
  `;
34
40
  }
35
- renderStandardField({ input_type, label, help_text, required, placeholder, styling }) {
41
+ renderStandardField({ input_type, label, help_text, required, placeholder, styling, name }, isMandatory = false) {
36
42
  var _a, _b, _c, _d;
37
43
  const isWide = styling.includes(StructureTypes.WIDE);
38
44
  switch (input_type) {
@@ -43,12 +49,13 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
43
49
  ?is-readonly="${this.readonly}"
44
50
  ?required="${required}"
45
51
  .placeholder="${placeholder}"
52
+ .name="${name}"
46
53
  .value="${this.value}"
47
54
  .validators="${this.validations}"
48
55
  .errorMessage="${this.errorMessage}"
49
56
  .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
50
57
  >
51
- ${this.renderFieldLabel(label, help_text)}
58
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
52
59
  </text-field>
53
60
  `;
54
61
  case FieldTypes.NUMBER_TYPE:
@@ -60,12 +67,13 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
60
67
  ?required="${required}"
61
68
  .placeholder="${placeholder}"
62
69
  .value="${this.value}"
70
+ .name="${name}"
63
71
  .validators="${this.validations}"
64
72
  .errorMessage="${this.errorMessage}"
65
73
  .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
66
74
  .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
67
75
  >
68
- ${this.renderFieldLabel(label, help_text)}
76
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
69
77
  </number-field>
70
78
  `;
71
79
  case FieldTypes.BOOL_TYPE:
@@ -74,11 +82,12 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
74
82
  ?is-readonly="${this.readonly}"
75
83
  ?required="${required}"
76
84
  .value="${this.value}"
85
+ .name="${name}"
77
86
  .validators="${this.validations}"
78
87
  .errorMessage="${this.errorMessage}"
79
88
  .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
80
89
  >
81
- ${this.renderFieldLabel(label, help_text)}
90
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
82
91
  </boolean-field>
83
92
  `;
84
93
  case FieldTypes.SCALE_TYPE:
@@ -89,11 +98,12 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
89
98
  ?required="${required}"
90
99
  .placeholder="${placeholder}"
91
100
  .value="${this.value}"
101
+ .name="${name}"
92
102
  .validators="${this.validations}"
93
103
  .errorMessage="${this.errorMessage}"
94
104
  .defaultValue="${(_d = this.field) === null || _d === void 0 ? void 0 : _d.default_value}"
95
105
  >
96
- ${this.renderFieldLabel(label, help_text)}
106
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
97
107
  </scale-field>
98
108
  `;
99
109
  case FieldTypes.FILE_TYPE:
@@ -103,11 +113,12 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
103
113
  ?required="${required}"
104
114
  .placeholder="${placeholder}"
105
115
  .value="${this.value}"
116
+ .name="${name}"
106
117
  .validators="${this.validations}"
107
118
  .errorMessage="${this.errorMessage}"
108
119
  .computedPath="${this.computedPath}"
109
120
  >
110
- ${this.renderFieldLabel(label, help_text)}
121
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
111
122
  </attachments-field>
112
123
  `;
113
124
  default:
@@ -115,7 +126,14 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
115
126
  return html ``;
116
127
  }
117
128
  }
118
- renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }) {
129
+ renderTooltip(isMandatory) {
130
+ return isMandatory
131
+ ? html ` <sl-tooltip placement="top" content="${getTranslation(this.language, 'PLEASE_ANSWER')}">
132
+ <etools-icon id="users-icon" name="info-outline"></etools-icon>
133
+ </sl-tooltip>`
134
+ : ``;
135
+ }
136
+ renderRepeatableField({ input_type, label, help_text, required, placeholder, styling }, isMandatory = false) {
119
137
  var _a, _b, _c;
120
138
  const isWide = styling.includes(StructureTypes.WIDE);
121
139
  switch (input_type) {
@@ -131,7 +149,7 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
131
149
  .errorMessage="${this.errorMessage}"
132
150
  .defaultValue="${(_a = this.field) === null || _a === void 0 ? void 0 : _a.default_value}"
133
151
  >
134
- ${this.renderFieldLabel(label, help_text)}
152
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
135
153
  </repeatable-text-field>
136
154
  `;
137
155
  case FieldTypes.NUMBER_TYPE:
@@ -149,7 +167,7 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
149
167
  .isInteger="${Boolean(input_type === FieldTypes.NUMBER_INTEGER_TYPE)}"
150
168
  .defaultValue="${(_b = this.field) === null || _b === void 0 ? void 0 : _b.default_value}"
151
169
  >
152
- ${this.renderFieldLabel(label, help_text)}
170
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
153
171
  </repeatable-number-field>
154
172
  `;
155
173
  case FieldTypes.SCALE_TYPE:
@@ -165,7 +183,7 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
165
183
  .errorMessage="${this.errorMessage}"
166
184
  .defaultValue="${(_c = this.field) === null || _c === void 0 ? void 0 : _c.default_value}"
167
185
  >
168
- ${this.renderFieldLabel(label, help_text)}
186
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
169
187
  </repeatable-scale-field>
170
188
  `;
171
189
  case FieldTypes.FILE_TYPE:
@@ -179,7 +197,7 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
179
197
  .errorMessage="${this.errorMessage}"
180
198
  .computedPath="${this.computedPath}"
181
199
  >
182
- ${this.renderFieldLabel(label, help_text)}
200
+ ${this.renderFieldLabel(label, help_text, isMandatory)}
183
201
  </repeatable-attachments-field>
184
202
  `;
185
203
  default:
@@ -187,10 +205,10 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
187
205
  return html ``;
188
206
  }
189
207
  }
190
- renderFieldLabel(label, helperText) {
208
+ renderFieldLabel(label, helperText, isMandatory = false) {
191
209
  return html `
192
210
  <div class="layout vertical question-container">
193
- <div class="question-text">${label}</div>
211
+ <div class="question-text">${this.renderTooltip(isMandatory)}${label}</div>
194
212
  <div class="question-details">${helperText}</div>
195
213
  </div>
196
214
  `;
@@ -217,7 +235,17 @@ let FieldRendererComponent = class FieldRendererComponent extends LitElement {
217
235
  color: var(--secondary-text-color);
218
236
  font-weight: 400;
219
237
  }
220
-
238
+ .mandatory_warning etools-icon {
239
+ --etools-icon-fill-color: #f59e0b !important;
240
+ }
241
+ :host(:not([readonly])) {
242
+ .overall {
243
+ background-color: #ffffff;
244
+ border-style: inset;
245
+ border-width: 0 1px 1px 1px;
246
+ border-color: var(--dark-divider-color);
247
+ }
248
+ }
221
249
  @media print {
222
250
  :host {
223
251
  break-inside: avoid;
@@ -233,6 +261,9 @@ __decorate([
233
261
  __decorate([
234
262
  property()
235
263
  ], FieldRendererComponent.prototype, "value", void 0);
264
+ __decorate([
265
+ property()
266
+ ], FieldRendererComponent.prototype, "language", void 0);
236
267
  __decorate([
237
268
  property()
238
269
  ], FieldRendererComponent.prototype, "errorMessage", void 0);
@@ -83,8 +83,8 @@ let RepeatableAttachmentField = class RepeatableAttachmentField extends Repeatab
83
83
  }
84
84
  attachmentsUploaded({ success, error }) {
85
85
  success === null || success === void 0 ? void 0 : success.forEach((file, index) => {
86
- var _a, _b;
87
- const newIndex = ((_b = Number((_a = this.editedValues) === null || _a === void 0 ? void 0 : _a.length)) !== null && _b !== void 0 ? _b : 0) + index;
86
+ var _a;
87
+ const newIndex = (Number((_a = this.editedValues) === null || _a === void 0 ? void 0 : _a.length) || 0) + index;
88
88
  if (this.isUploadedAttachment(file)) {
89
89
  this.valueChanged({
90
90
  url: file.file_link,
@@ -107,7 +107,7 @@ let RepeatableAttachmentField = class RepeatableAttachmentField extends Repeatab
107
107
  });
108
108
  if (error && error.length) {
109
109
  console.error(error);
110
- fireEvent(this, 'toast', { text: 'Can not upload attachments. Please try again later' });
110
+ fireEvent(this, 'toast', { text: getTranslation(this.language, 'UPLOAD_ATTACHMENTS_FAILED') });
111
111
  }
112
112
  }
113
113
  downloadFile(attachment) {
@@ -2,7 +2,6 @@ import { __decorate } from "tslib";
2
2
  import { css, html } from 'lit';
3
3
  import { customElement } from 'lit/decorators.js';
4
4
  import '@unicef-polymer/etools-unicef/src/etools-input/etools-input';
5
- import { InputStyles } from '../../lib/styles/input-styles';
6
5
  import { RepeatableBaseField } from './repeatable-base-field';
7
6
  import { AbstractFieldBaseClass } from '../abstract-field-base.class';
8
7
  import { getTranslation } from '../../lib/utils/translate';
@@ -13,7 +12,6 @@ let RepeatableNumberField = class RepeatableNumberField extends RepeatableBaseFi
13
12
  }
14
13
  controlTemplate(value, index) {
15
14
  return html `
16
- ${InputStyles}
17
15
  <etools-input
18
16
  class="no-padding-left"
19
17
  no-label-float
@@ -5,7 +5,6 @@ import { repeat } from 'lit/directives/repeat.js';
5
5
  import '@unicef-polymer/etools-unicef/src/etools-radio/etools-radio-group';
6
6
  import '@shoelace-style/shoelace/dist/components/radio/radio.js';
7
7
  import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
8
- import { InputStyles } from '../../lib/styles/input-styles';
9
8
  import { RepeatableBaseField } from './repeatable-base-field';
10
9
  import { getTranslation } from '../../lib/utils/translate';
11
10
  import { AbstractFieldBaseClass } from '../abstract-field-base.class';
@@ -16,7 +15,6 @@ let RepeatableScaleField = class RepeatableScaleField extends RepeatableBaseFiel
16
15
  }
17
16
  controlTemplate(value, index) {
18
17
  return html `
19
- ${InputStyles}
20
18
  <div class="container">
21
19
  <etools-radio-group
22
20
  class="radio-group"
@@ -2,13 +2,11 @@ import { __decorate } from "tslib";
2
2
  import { css, html } from 'lit';
3
3
  import { customElement } from 'lit/decorators.js';
4
4
  import '@unicef-polymer/etools-unicef/src/etools-input/etools-textarea';
5
- import { InputStyles } from '../../lib/styles/input-styles';
6
5
  import { RepeatableBaseField } from './repeatable-base-field';
7
6
  import { AbstractFieldBaseClass } from '../abstract-field-base.class';
8
7
  let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField {
9
8
  controlTemplate(value, index) {
10
9
  return html `
11
- ${InputStyles}
12
10
  <etools-textarea
13
11
  id="textarea"
14
12
  class="no-padding-left"
@@ -31,9 +29,6 @@ let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField
31
29
  return [
32
30
  ...AbstractFieldBaseClass.styles,
33
31
  css `
34
- :host(.wide) paper-textarea {
35
- padding-left: 0;
36
- }
37
32
  @media (max-width: 380px) {
38
33
  .no-padding-left {
39
34
  padding-left: 0;
@@ -2,12 +2,10 @@ import { __decorate } from "tslib";
2
2
  import { css, html } from 'lit';
3
3
  import { customElement } from 'lit/decorators.js';
4
4
  import { BaseField } from './base-field';
5
- import { InputStyles } from '../../lib/styles/input-styles';
6
5
  import '@shoelace-style/shoelace/dist/components/switch/switch.js';
7
6
  let BooleanField = class BooleanField extends BaseField {
8
7
  controlTemplate() {
9
8
  return html `
10
- ${InputStyles}
11
9
  <sl-switch
12
10
  class="no-padding-left"
13
11
  ?checked="${this.value}"
@@ -27,9 +25,6 @@ let BooleanField = class BooleanField extends BaseField {
27
25
  return [
28
26
  ...BaseField.styles,
29
27
  css `
30
- :host(.wide) paper-textarea {
31
- padding-left: 0;
32
- }
33
28
  @media (max-width: 380px) {
34
29
  .no-padding-left {
35
30
  padding-left: 0;