@unicef-polymer/etools-form-builder 2.1.7 → 2.1.9

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 (87) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/assets/translations.d.ts +6 -6
  4. package/dist/assets/translations.js +67 -67
  5. package/dist/form-attachments-popup/form-attachments-popup.d.ts +86 -86
  6. package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
  7. package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
  8. package/dist/form-attachments-popup/form-attachments-popup.js +255 -255
  9. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
  10. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +91 -91
  11. package/dist/form-attachments-popup/index.d.ts +2 -2
  12. package/dist/form-attachments-popup/index.js +2 -2
  13. package/dist/form-fields/abstract-field-base.class.d.ts +33 -33
  14. package/dist/form-fields/abstract-field-base.class.js +213 -213
  15. package/dist/form-fields/field-renderer-component.d.ts +20 -20
  16. package/dist/form-fields/field-renderer-component.js +255 -255
  17. package/dist/form-fields/index.d.ts +12 -12
  18. package/dist/form-fields/index.js +12 -12
  19. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
  20. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +209 -209
  21. package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
  22. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +124 -124
  23. package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
  24. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +67 -67
  25. package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
  26. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
  27. package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
  28. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
  29. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
  30. package/dist/form-fields/single-fields/attachment-field.js +98 -98
  31. package/dist/form-fields/single-fields/base-field.d.ts +11 -11
  32. package/dist/form-fields/single-fields/base-field.js +58 -58
  33. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
  34. package/dist/form-fields/single-fields/boolean-field.js +49 -49
  35. package/dist/form-fields/single-fields/number-field.d.ts +10 -10
  36. package/dist/form-fields/single-fields/number-field.js +67 -67
  37. package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
  38. package/dist/form-fields/single-fields/scale-field.js +108 -108
  39. package/dist/form-fields/single-fields/text-field.d.ts +8 -8
  40. package/dist/form-fields/single-fields/text-field.js +54 -54
  41. package/dist/form-groups/form-abstract-group.d.ts +71 -71
  42. package/dist/form-groups/form-abstract-group.js +398 -398
  43. package/dist/form-groups/form-card.d.ts +32 -32
  44. package/dist/form-groups/form-card.js +113 -113
  45. package/dist/form-groups/form-collapsed-card.d.ts +71 -71
  46. package/dist/form-groups/form-collapsed-card.js +259 -259
  47. package/dist/form-groups/index.d.ts +3 -3
  48. package/dist/form-groups/index.js +3 -3
  49. package/dist/index.d.ts +3 -3
  50. package/dist/index.js +3 -3
  51. package/dist/lib/additional-components/confirmation-dialog.d.ts +18 -18
  52. package/dist/lib/additional-components/confirmation-dialog.js +72 -72
  53. package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
  54. package/dist/lib/additional-components/etools-fb-card.js +239 -238
  55. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  56. package/dist/lib/styles/attachments.styles.js +72 -72
  57. package/dist/lib/styles/card-styles.d.ts +2 -2
  58. package/dist/lib/styles/card-styles.js +154 -154
  59. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  60. package/dist/lib/styles/dialog.styles.js +85 -85
  61. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  62. package/dist/lib/styles/elevation-styles.js +43 -43
  63. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  64. package/dist/lib/styles/flex-layout-classes.js +319 -319
  65. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  66. package/dist/lib/styles/form-builder-card.styles.js +49 -49
  67. package/dist/lib/styles/input-styles.d.ts +2 -2
  68. package/dist/lib/styles/input-styles.js +138 -138
  69. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  70. package/dist/lib/styles/page-layout-styles.js +201 -201
  71. package/dist/lib/styles/shared-styles.d.ts +2 -2
  72. package/dist/lib/styles/shared-styles.js +70 -70
  73. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  74. package/dist/lib/types/form-builder.interfaces.js +0 -0
  75. package/dist/lib/types/form-builder.types.d.ts +59 -59
  76. package/dist/lib/types/form-builder.types.js +0 -0
  77. package/dist/lib/types/global.types.d.ts +4 -4
  78. package/dist/lib/types/global.types.js +0 -0
  79. package/dist/lib/utils/dialog.d.ts +10 -10
  80. package/dist/lib/utils/dialog.js +21 -21
  81. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  82. package/dist/lib/utils/fire-custom-event.js +7 -7
  83. package/dist/lib/utils/translate.d.ts +1 -1
  84. package/dist/lib/utils/translate.js +9 -9
  85. package/dist/lib/utils/validations.helper.d.ts +26 -26
  86. package/dist/lib/utils/validations.helper.js +42 -42
  87. package/package.json +56 -56
@@ -1,209 +1,209 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import '@unicef-polymer/etools-upload/etools-upload';
8
- import { RepeatableBaseField } from './repeatable-base-field';
9
- import { AttachmentsHelper } from '../../form-attachments-popup';
10
- import { html, css, customElement } from 'lit-element';
11
- import { fireEvent } from '../../lib/utils/fire-custom-event';
12
- import { SharedStyles } from '../../lib/styles/shared-styles';
13
- import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
14
- import { getTranslation } from '../../lib/utils/translate';
15
- let RepeatableAttachmentField = class RepeatableAttachmentField extends RepeatableBaseField {
16
- constructor() {
17
- super(...arguments);
18
- this.computedPath = [];
19
- }
20
- get uploadUrl() {
21
- return AttachmentsHelper.uploadUrl;
22
- }
23
- get jwtLocalStorageKey() {
24
- return AttachmentsHelper.jwtLocalStorageKey;
25
- }
26
- render() {
27
- var _a;
28
- const values = this.getValues();
29
- return html `
30
- <div class="finding-container">
31
- <div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
32
- <div class="question-control layout vertical center-justified start">
33
- ${values.map((value, index) => value
34
- ? html `
35
- <div class="layout horizontal file-container">
36
- <!-- File name component -->
37
- <div class="filename-container file-selector__filename">
38
- <iron-icon class="file-icon" icon="attachment"></iron-icon>
39
- <span class="filename" title="${value.filename}">${value.filename}</span>
40
- </div>
41
-
42
- <!-- Download Button -->
43
- <paper-button
44
- ?hidden="${!value.url}"
45
- class="download-button file-selector__download"
46
- @tap="${() => this.downloadFile(value)}"
47
- >
48
- <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
49
- ${getTranslation(this.language, 'DOWNLOAD')}
50
- </paper-button>
51
-
52
- <!-- Delete Button -->
53
- <paper-button
54
- class="delete-button file-selector__delete"
55
- ?hidden="${this.isReadonly}"
56
- @tap="${() => this.removeControl(index)}"
57
- >
58
- ${getTranslation(this.language, 'DELETE')}
59
- </paper-button>
60
- </div>
61
- `
62
- : '')}
63
- <!-- Upload button -->
64
- <etools-upload-multi
65
- class="with-padding"
66
- activate-offline
67
- ?hidden="${this.isReadonly}"
68
- @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
69
- .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
70
- .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
71
- >
72
- </etools-upload-multi>
73
- <div ?hidden="${!this.isReadonly || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length)}">—</div>
74
- </div>
75
- </div>
76
- `;
77
- }
78
- controlTemplate() {
79
- return html ``;
80
- }
81
- customValidation() {
82
- return null;
83
- }
84
- attachmentsUploaded({ success, error }) {
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;
88
- if (this.isUploadedAttachment(file)) {
89
- this.valueChanged({
90
- url: file.file_link,
91
- attachment: file.id,
92
- filename: file.filename,
93
- file_type: null
94
- }, newIndex);
95
- }
96
- else if (this.isOfflineSavedAttachment(file)) {
97
- this.valueChanged({
98
- attachment: file.id,
99
- filename: file.filename,
100
- composedPath: [],
101
- file_type: null
102
- }, newIndex);
103
- }
104
- else {
105
- console.warn('Missing fields in parsed attachment');
106
- }
107
- });
108
- if (error && error.length) {
109
- console.error(error);
110
- fireEvent(this, 'toast', { text: 'Can not upload attachments. Please try again later' });
111
- }
112
- }
113
- downloadFile(attachment) {
114
- if (!(attachment === null || attachment === void 0 ? void 0 : attachment.url)) {
115
- return;
116
- }
117
- const link = document.createElement('a');
118
- link.target = '_blank';
119
- link.href = attachment.url;
120
- link.click();
121
- window.URL.revokeObjectURL(attachment.url);
122
- }
123
- isUploadedAttachment(attachment) {
124
- return (attachment.hasOwnProperty('filename') &&
125
- attachment.hasOwnProperty('id') &&
126
- attachment.hasOwnProperty('file_link') &&
127
- !attachment.hasOwnProperty('unsynced'));
128
- }
129
- isOfflineSavedAttachment(attachment) {
130
- return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
131
- }
132
- static get styles() {
133
- // language=CSS
134
- return [
135
- ...RepeatableBaseField.styles,
136
- SharedStyles,
137
- AttachmentsStyles,
138
- css `
139
- .file-selector__type-dropdown {
140
- flex-basis: 25%;
141
- padding-left: 8px;
142
- padding-right: 8px;
143
- }
144
-
145
- .file-selector__filename {
146
- flex-basis: 35%;
147
- }
148
-
149
- .file-selector__download {
150
- flex-basis: 10%;
151
- }
152
-
153
- .file-selector__delete {
154
- flex-basis: 10%;
155
- }
156
-
157
- .file-selector-container.with-type-dropdown {
158
- flex-wrap: nowrap;
159
- }
160
-
161
- .popup-container {
162
- padding: 12px 12px 0;
163
- }
164
-
165
- .file-container {
166
- padding: 8px 0;
167
- }
168
-
169
- @media (max-width: 380px) {
170
- .file-selector-container.with-type-dropdown {
171
- justify-content: center;
172
- }
173
-
174
- .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
175
- flex-basis: 90%;
176
- }
177
-
178
- .file-selector__filename {
179
- flex-basis: 90%;
180
- }
181
-
182
- .file-selector__download {
183
- flex-basis: 5%;
184
- }
185
-
186
- .file-selector__delete {
187
- flex-basis: 5%;
188
- }
189
- }
190
-
191
- @media (max-width: 600px) {
192
- etools-dropdown {
193
- padding: 0;
194
- }
195
-
196
- .file-selector-container.with-type-dropdown {
197
- border-bottom: 1px solid lightgrey;
198
- flex-wrap: wrap;
199
- padding-bottom: 10px;
200
- }
201
- }
202
- `
203
- ];
204
- }
205
- };
206
- RepeatableAttachmentField = __decorate([
207
- customElement('repeatable-attachments-field')
208
- ], RepeatableAttachmentField);
209
- export { RepeatableAttachmentField };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import '@unicef-polymer/etools-upload/etools-upload';
8
+ import { RepeatableBaseField } from './repeatable-base-field';
9
+ import { AttachmentsHelper } from '../../form-attachments-popup';
10
+ import { html, css, customElement } from 'lit-element';
11
+ import { fireEvent } from '../../lib/utils/fire-custom-event';
12
+ import { SharedStyles } from '../../lib/styles/shared-styles';
13
+ import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
14
+ import { getTranslation } from '../../lib/utils/translate';
15
+ let RepeatableAttachmentField = class RepeatableAttachmentField extends RepeatableBaseField {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.computedPath = [];
19
+ }
20
+ get uploadUrl() {
21
+ return AttachmentsHelper.uploadUrl;
22
+ }
23
+ get jwtLocalStorageKey() {
24
+ return AttachmentsHelper.jwtLocalStorageKey;
25
+ }
26
+ render() {
27
+ var _a;
28
+ const values = this.getValues();
29
+ return html `
30
+ <div class="finding-container">
31
+ <div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
32
+ <div class="question-control layout vertical center-justified start">
33
+ ${values.map((value, index) => value
34
+ ? html `
35
+ <div class="layout horizontal file-container">
36
+ <!-- File name component -->
37
+ <div class="filename-container file-selector__filename">
38
+ <iron-icon class="file-icon" icon="attachment"></iron-icon>
39
+ <span class="filename" title="${value.filename}">${value.filename}</span>
40
+ </div>
41
+
42
+ <!-- Download Button -->
43
+ <paper-button
44
+ ?hidden="${!value.url}"
45
+ class="download-button file-selector__download"
46
+ @tap="${() => this.downloadFile(value)}"
47
+ >
48
+ <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
49
+ ${getTranslation(this.language, 'DOWNLOAD')}
50
+ </paper-button>
51
+
52
+ <!-- Delete Button -->
53
+ <paper-button
54
+ class="delete-button file-selector__delete"
55
+ ?hidden="${this.isReadonly}"
56
+ @tap="${() => this.removeControl(index)}"
57
+ >
58
+ ${getTranslation(this.language, 'DELETE')}
59
+ </paper-button>
60
+ </div>
61
+ `
62
+ : '')}
63
+ <!-- Upload button -->
64
+ <etools-upload-multi
65
+ class="with-padding"
66
+ activate-offline
67
+ ?hidden="${this.isReadonly}"
68
+ @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
69
+ .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
70
+ .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
71
+ >
72
+ </etools-upload-multi>
73
+ <div ?hidden="${!this.isReadonly || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length)}">—</div>
74
+ </div>
75
+ </div>
76
+ `;
77
+ }
78
+ controlTemplate() {
79
+ return html ``;
80
+ }
81
+ customValidation() {
82
+ return null;
83
+ }
84
+ attachmentsUploaded({ success, error }) {
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;
88
+ if (this.isUploadedAttachment(file)) {
89
+ this.valueChanged({
90
+ url: file.file_link,
91
+ attachment: file.id,
92
+ filename: file.filename,
93
+ file_type: null
94
+ }, newIndex);
95
+ }
96
+ else if (this.isOfflineSavedAttachment(file)) {
97
+ this.valueChanged({
98
+ attachment: file.id,
99
+ filename: file.filename,
100
+ composedPath: [],
101
+ file_type: null
102
+ }, newIndex);
103
+ }
104
+ else {
105
+ console.warn('Missing fields in parsed attachment');
106
+ }
107
+ });
108
+ if (error && error.length) {
109
+ console.error(error);
110
+ fireEvent(this, 'toast', { text: 'Can not upload attachments. Please try again later' });
111
+ }
112
+ }
113
+ downloadFile(attachment) {
114
+ if (!(attachment === null || attachment === void 0 ? void 0 : attachment.url)) {
115
+ return;
116
+ }
117
+ const link = document.createElement('a');
118
+ link.target = '_blank';
119
+ link.href = attachment.url;
120
+ link.click();
121
+ window.URL.revokeObjectURL(attachment.url);
122
+ }
123
+ isUploadedAttachment(attachment) {
124
+ return (attachment.hasOwnProperty('filename') &&
125
+ attachment.hasOwnProperty('id') &&
126
+ attachment.hasOwnProperty('file_link') &&
127
+ !attachment.hasOwnProperty('unsynced'));
128
+ }
129
+ isOfflineSavedAttachment(attachment) {
130
+ return (attachment.hasOwnProperty('filename') && attachment.hasOwnProperty('id') && attachment.hasOwnProperty('unsynced'));
131
+ }
132
+ static get styles() {
133
+ // language=CSS
134
+ return [
135
+ ...RepeatableBaseField.styles,
136
+ SharedStyles,
137
+ AttachmentsStyles,
138
+ css `
139
+ .file-selector__type-dropdown {
140
+ flex-basis: 25%;
141
+ padding-left: 8px;
142
+ padding-right: 8px;
143
+ }
144
+
145
+ .file-selector__filename {
146
+ flex-basis: 35%;
147
+ }
148
+
149
+ .file-selector__download {
150
+ flex-basis: 10%;
151
+ }
152
+
153
+ .file-selector__delete {
154
+ flex-basis: 10%;
155
+ }
156
+
157
+ .file-selector-container.with-type-dropdown {
158
+ flex-wrap: nowrap;
159
+ }
160
+
161
+ .popup-container {
162
+ padding: 12px 12px 0;
163
+ }
164
+
165
+ .file-container {
166
+ padding: 8px 0;
167
+ }
168
+
169
+ @media (max-width: 380px) {
170
+ .file-selector-container.with-type-dropdown {
171
+ justify-content: center;
172
+ }
173
+
174
+ .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
175
+ flex-basis: 90%;
176
+ }
177
+
178
+ .file-selector__filename {
179
+ flex-basis: 90%;
180
+ }
181
+
182
+ .file-selector__download {
183
+ flex-basis: 5%;
184
+ }
185
+
186
+ .file-selector__delete {
187
+ flex-basis: 5%;
188
+ }
189
+ }
190
+
191
+ @media (max-width: 600px) {
192
+ etools-dropdown {
193
+ padding: 0;
194
+ }
195
+
196
+ .file-selector-container.with-type-dropdown {
197
+ border-bottom: 1px solid lightgrey;
198
+ flex-wrap: wrap;
199
+ padding-bottom: 10px;
200
+ }
201
+ }
202
+ `
203
+ ];
204
+ }
205
+ };
206
+ RepeatableAttachmentField = __decorate([
207
+ customElement('repeatable-attachments-field')
208
+ ], RepeatableAttachmentField);
209
+ export { RepeatableAttachmentField };
@@ -1,20 +1,20 @@
1
- import { CSSResultArray, TemplateResult } from 'lit-element';
2
- import { AbstractFieldBaseClass } from '../abstract-field-base.class';
3
- export declare abstract class RepeatableBaseField<T> extends AbstractFieldBaseClass<T[]> {
4
- set errorMessage(messages: (string | null)[]);
5
- get errorMessage(): (string | null)[];
6
- protected _errorMessage: (string | null)[];
7
- protected editedValues: (T | null)[] | null;
8
- protected render(): TemplateResult;
9
- protected questionTemplate(): TemplateResult;
10
- protected valueChanged(newValue: T, index: number): void;
11
- protected setValue(value: (T | null)[]): void;
12
- protected validateField(value: T[]): void;
13
- protected validateField(value: T, index: number): void;
14
- protected addNewField(): void;
15
- protected removeControl(index: number): void;
16
- protected getValues(): (T | null)[];
17
- private isArrayData;
18
- protected abstract controlTemplate(value: T | null, index: number): TemplateResult;
19
- static get styles(): CSSResultArray;
20
- }
1
+ import { CSSResultArray, TemplateResult } from 'lit-element';
2
+ import { AbstractFieldBaseClass } from '../abstract-field-base.class';
3
+ export declare abstract class RepeatableBaseField<T> extends AbstractFieldBaseClass<T[]> {
4
+ set errorMessage(messages: (string | null)[]);
5
+ get errorMessage(): (string | null)[];
6
+ protected _errorMessage: (string | null)[];
7
+ protected editedValues: (T | null)[] | null;
8
+ protected render(): TemplateResult;
9
+ protected questionTemplate(): TemplateResult;
10
+ protected valueChanged(newValue: T, index: number): void;
11
+ protected setValue(value: (T | null)[]): void;
12
+ protected validateField(value: T[]): void;
13
+ protected validateField(value: T, index: number): void;
14
+ protected addNewField(): void;
15
+ protected removeControl(index: number): void;
16
+ protected getValues(): (T | null)[];
17
+ private isArrayData;
18
+ protected abstract controlTemplate(value: T | null, index: number): TemplateResult;
19
+ static get styles(): CSSResultArray;
20
+ }