@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,213 +1,213 @@
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 { LitElement, property, css, html } from 'lit-element';
8
- import { validate } from '../lib/utils/validations.helper';
9
- import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
10
- /**
11
- * Class that contains common properties and methods for single and repeatable fields
12
- */
13
- export class AbstractFieldBaseClass extends LitElement {
14
- constructor() {
15
- super();
16
- this.questionText = '';
17
- this.required = false;
18
- this.placeholder = '';
19
- this.value = null;
20
- this.validators = [];
21
- this.touched = false;
22
- this._readonly = false;
23
- if (!this.language) {
24
- this.language = window.localStorage.defaultLanguage || 'en';
25
- }
26
- this.handleLanguageChange = this.handleLanguageChange.bind(this);
27
- }
28
- set isReadonly(readonly) {
29
- this._readonly = readonly;
30
- this.setDefaultValue(readonly, this._defaultValue);
31
- this.requestUpdate();
32
- }
33
- get isReadonly() {
34
- return this._readonly;
35
- }
36
- set defaultValue(value) {
37
- this._defaultValue = value;
38
- this.setDefaultValue(this._readonly, value);
39
- this.requestUpdate();
40
- }
41
- connectedCallback() {
42
- super.connectedCallback();
43
- document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
44
- }
45
- disconnectedCallback() {
46
- super.disconnectedCallback();
47
- document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
48
- }
49
- handleLanguageChange(e) {
50
- this.language = e.detail.language;
51
- }
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>
58
- `;
59
- }
60
- questionTemplate() {
61
- return html `<span class="question-text">${this.questionText}</span>`;
62
- }
63
- metaValidation(value) {
64
- const message = validate(this.validators, value, this.language);
65
- return message ? message : this.customValidation(value);
66
- }
67
- setDefaultValue(readonly, defaultValue) {
68
- if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
69
- return;
70
- }
71
- this.getUpdateComplete().then(() => {
72
- if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
73
- this.setValue(defaultValue);
74
- this.validateField(defaultValue);
75
- }
76
- });
77
- }
78
- static get styles() {
79
- // language=CSS
80
- return [
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
- margin-bottom: -8px;
104
- min-height: 0;
105
- }
106
-
107
- .question-control,
108
- .question {
109
- min-width: 0;
110
- min-height: 57px;
111
- display: flex;
112
- align-items: center;
113
- }
114
- .question {
115
- flex: 2;
116
- }
117
- .question-control {
118
- flex: 3;
119
- }
120
- .add-button {
121
- padding: 3px;
122
- margin: 10px;
123
- background: transparent;
124
- color: var(--primary-color);
125
- border: 1px solid;
126
- }
127
-
128
- .full-width,
129
- paper-input,
130
- paper-textarea {
131
- width: 100%;
132
- }
133
-
134
- .question-text {
135
- font-weight: 500;
136
- font-size: 13px;
137
- color: var(--primary-text-color);
138
- }
139
-
140
- paper-input,
141
- paper-textarea {
142
- outline: none !important;
143
- }
144
- paper-input[required],
145
- paper-textarea[required] {
146
- --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')
147
- no-repeat 98% 14%/7px;
148
- --paper-input-container-label_-_max-width: max-content;
149
- --paper-input-container-label_-_padding-right: 15px;
150
- }
151
-
152
- iron-icon[icon='close'] {
153
- cursor: pointer;
154
- }
155
-
156
- .error-text {
157
- color: var(--error-color);
158
- font-size: 12px;
159
- }
160
-
161
- @media (max-width: 1080px) {
162
- :host {
163
- padding: 0 15px;
164
- }
165
- .finding-container {
166
- flex-direction: column;
167
- }
168
- .question,
169
- .question-control {
170
- flex: 0 1 auto;
171
- }
172
- }
173
-
174
- @media print {
175
- .question-control {
176
- align-items: start;
177
- }
178
-
179
- :host(text-field) .question-control {
180
- min-height: 150px;
181
- }
182
-
183
- .question-control .container paper-radio-group {
184
- flex-direction: column;
185
- opacity: 1 !important;
186
- }
187
-
188
- .finding-container {
189
- flex-direction: column;
190
- }
191
- }
192
- `
193
- ];
194
- }
195
- }
196
- __decorate([
197
- property({ type: String })
198
- ], AbstractFieldBaseClass.prototype, "questionText", void 0);
199
- __decorate([
200
- property()
201
- ], AbstractFieldBaseClass.prototype, "language", void 0);
202
- __decorate([
203
- property({ type: Boolean, attribute: 'is-readonly' })
204
- ], AbstractFieldBaseClass.prototype, "isReadonly", null);
205
- __decorate([
206
- property({ type: Boolean, attribute: 'required' })
207
- ], AbstractFieldBaseClass.prototype, "required", void 0);
208
- __decorate([
209
- property()
210
- ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
211
- __decorate([
212
- property()
213
- ], AbstractFieldBaseClass.prototype, "value", void 0);
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 { LitElement, property, css, html } from 'lit-element';
8
+ import { validate } from '../lib/utils/validations.helper';
9
+ import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
10
+ /**
11
+ * Class that contains common properties and methods for single and repeatable fields
12
+ */
13
+ export class AbstractFieldBaseClass extends LitElement {
14
+ constructor() {
15
+ super();
16
+ this.questionText = '';
17
+ this.required = false;
18
+ this.placeholder = '';
19
+ this.value = null;
20
+ this.validators = [];
21
+ this.touched = false;
22
+ this._readonly = false;
23
+ if (!this.language) {
24
+ this.language = window.localStorage.defaultLanguage || 'en';
25
+ }
26
+ this.handleLanguageChange = this.handleLanguageChange.bind(this);
27
+ }
28
+ set isReadonly(readonly) {
29
+ this._readonly = readonly;
30
+ this.setDefaultValue(readonly, this._defaultValue);
31
+ this.requestUpdate();
32
+ }
33
+ get isReadonly() {
34
+ return this._readonly;
35
+ }
36
+ set defaultValue(value) {
37
+ this._defaultValue = value;
38
+ this.setDefaultValue(this._readonly, value);
39
+ this.requestUpdate();
40
+ }
41
+ connectedCallback() {
42
+ super.connectedCallback();
43
+ document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
44
+ }
45
+ disconnectedCallback() {
46
+ super.disconnectedCallback();
47
+ document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
48
+ }
49
+ handleLanguageChange(e) {
50
+ this.language = e.detail.language;
51
+ }
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>
58
+ `;
59
+ }
60
+ questionTemplate() {
61
+ return html `<span class="question-text">${this.questionText}</span>`;
62
+ }
63
+ metaValidation(value) {
64
+ const message = validate(this.validators, value, this.language);
65
+ return message ? message : this.customValidation(value);
66
+ }
67
+ setDefaultValue(readonly, defaultValue) {
68
+ if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
69
+ return;
70
+ }
71
+ this.getUpdateComplete().then(() => {
72
+ if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
73
+ this.setValue(defaultValue);
74
+ this.validateField(defaultValue);
75
+ }
76
+ });
77
+ }
78
+ static get styles() {
79
+ // language=CSS
80
+ return [
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
+ margin-bottom: -8px;
104
+ min-height: 0;
105
+ }
106
+
107
+ .question-control,
108
+ .question {
109
+ min-width: 0;
110
+ min-height: 57px;
111
+ display: flex;
112
+ align-items: center;
113
+ }
114
+ .question {
115
+ flex: 2;
116
+ }
117
+ .question-control {
118
+ flex: 3;
119
+ }
120
+ .add-button {
121
+ padding: 3px;
122
+ margin: 10px;
123
+ background: transparent;
124
+ color: var(--primary-color);
125
+ border: 1px solid;
126
+ }
127
+
128
+ .full-width,
129
+ paper-input,
130
+ paper-textarea {
131
+ width: 100%;
132
+ }
133
+
134
+ .question-text {
135
+ font-weight: 500;
136
+ font-size: 13px;
137
+ color: var(--primary-text-color);
138
+ }
139
+
140
+ paper-input,
141
+ paper-textarea {
142
+ outline: none !important;
143
+ }
144
+ paper-input[required],
145
+ paper-textarea[required] {
146
+ --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')
147
+ no-repeat 98% 14%/7px;
148
+ --paper-input-container-label_-_max-width: max-content;
149
+ --paper-input-container-label_-_padding-right: 15px;
150
+ }
151
+
152
+ iron-icon[icon='close'] {
153
+ cursor: pointer;
154
+ }
155
+
156
+ .error-text {
157
+ color: var(--error-color);
158
+ font-size: 12px;
159
+ }
160
+
161
+ @media (max-width: 1080px) {
162
+ :host {
163
+ padding: 0 15px;
164
+ }
165
+ .finding-container {
166
+ flex-direction: column;
167
+ }
168
+ .question,
169
+ .question-control {
170
+ flex: 0 1 auto;
171
+ }
172
+ }
173
+
174
+ @media print {
175
+ .question-control {
176
+ align-items: start;
177
+ }
178
+
179
+ :host(text-field) .question-control {
180
+ min-height: 150px;
181
+ }
182
+
183
+ .question-control .container paper-radio-group {
184
+ flex-direction: column;
185
+ opacity: 1 !important;
186
+ }
187
+
188
+ .finding-container {
189
+ flex-direction: column;
190
+ }
191
+ }
192
+ `
193
+ ];
194
+ }
195
+ }
196
+ __decorate([
197
+ property({ type: String })
198
+ ], AbstractFieldBaseClass.prototype, "questionText", void 0);
199
+ __decorate([
200
+ property()
201
+ ], AbstractFieldBaseClass.prototype, "language", void 0);
202
+ __decorate([
203
+ property({ type: Boolean, attribute: 'is-readonly' })
204
+ ], AbstractFieldBaseClass.prototype, "isReadonly", null);
205
+ __decorate([
206
+ property({ type: Boolean, attribute: 'required' })
207
+ ], AbstractFieldBaseClass.prototype, "required", void 0);
208
+ __decorate([
209
+ property()
210
+ ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
211
+ __decorate([
212
+ property()
213
+ ], AbstractFieldBaseClass.prototype, "value", void 0);
@@ -1,20 +1,20 @@
1
- import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
2
- import { BlueprintField } from '../lib/types/form-builder.types';
3
- import { FieldValidator } from '../lib/utils/validations.helper';
4
- import { FieldOption } from './single-fields/scale-field';
5
- export declare class FieldRendererComponent extends LitElement {
6
- field: BlueprintField;
7
- value: any;
8
- errorMessage: string | null;
9
- validations: FieldValidator[];
10
- readonly: boolean;
11
- options: (FieldOption | string | number)[];
12
- computedPath: string[];
13
- defaultValue: any;
14
- render(): TemplateResult;
15
- 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
- static get styles(): CSSResultArray;
20
- }
1
+ import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
2
+ import { BlueprintField } from '../lib/types/form-builder.types';
3
+ import { FieldValidator } from '../lib/utils/validations.helper';
4
+ import { FieldOption } from './single-fields/scale-field';
5
+ export declare class FieldRendererComponent extends LitElement {
6
+ field: BlueprintField;
7
+ value: any;
8
+ errorMessage: string | null;
9
+ validations: FieldValidator[];
10
+ readonly: boolean;
11
+ options: (FieldOption | string | number)[];
12
+ computedPath: string[];
13
+ defaultValue: any;
14
+ render(): TemplateResult;
15
+ 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
+ static get styles(): CSSResultArray;
20
+ }