@unicef-polymer/etools-form-builder 2.1.8 → 3.0.0-rc.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 (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 +84 -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 +249 -255
  9. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +7 -3
  10. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +102 -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 +209 -213
  15. package/dist/form-fields/field-renderer-component.d.ts +20 -20
  16. package/dist/form-fields/field-renderer-component.js +251 -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 +19 -17
  20. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +212 -209
  21. package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +21 -20
  22. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +121 -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 +63 -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 +106 -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 +49 -53
  29. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
  30. package/dist/form-fields/single-fields/attachment-field.js +94 -98
  31. package/dist/form-fields/single-fields/base-field.d.ts +11 -11
  32. package/dist/form-fields/single-fields/base-field.js +53 -58
  33. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
  34. package/dist/form-fields/single-fields/boolean-field.js +45 -49
  35. package/dist/form-fields/single-fields/number-field.d.ts +10 -10
  36. package/dist/form-fields/single-fields/number-field.js +63 -67
  37. package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
  38. package/dist/form-fields/single-fields/scale-field.js +109 -108
  39. package/dist/form-fields/single-fields/text-field.d.ts +8 -8
  40. package/dist/form-fields/single-fields/text-field.js +49 -54
  41. package/dist/form-groups/form-abstract-group.d.ts +71 -71
  42. package/dist/form-groups/form-abstract-group.js +396 -398
  43. package/dist/form-groups/form-card.d.ts +35 -32
  44. package/dist/form-groups/form-card.js +115 -113
  45. package/dist/form-groups/form-collapsed-card.d.ts +72 -71
  46. package/dist/form-groups/form-collapsed-card.js +261 -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 +68 -72
  53. package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
  54. package/dist/lib/additional-components/etools-fb-card.js +242 -239
  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 +1 -0
  75. package/dist/lib/types/form-builder.types.d.ts +59 -59
  76. package/dist/lib/types/form-builder.types.js +1 -0
  77. package/dist/lib/types/global.types.d.ts +4 -4
  78. package/dist/lib/types/global.types.js +1 -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 +51 -56
@@ -1,213 +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 { 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
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import { validate } from '../lib/utils/validations.helper';
5
+ import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
6
+ /**
7
+ * Class that contains common properties and methods for single and repeatable fields
8
+ */
9
+ export class AbstractFieldBaseClass extends LitElement {
10
+ set isReadonly(readonly) {
11
+ this._readonly = readonly;
12
+ this.setDefaultValue(readonly, this._defaultValue);
13
+ this.requestUpdate();
14
+ }
15
+ get isReadonly() {
16
+ return this._readonly;
17
+ }
18
+ set defaultValue(value) {
19
+ this._defaultValue = value;
20
+ this.setDefaultValue(this._readonly, value);
21
+ this.requestUpdate();
22
+ }
23
+ constructor() {
24
+ super();
25
+ this.questionText = '';
26
+ this.required = false;
27
+ this.placeholder = '';
28
+ this.value = null;
29
+ this.validators = [];
30
+ this.touched = false;
31
+ this._readonly = false;
32
+ if (!this.language) {
33
+ this.language = window.localStorage.defaultLanguage || 'en';
34
+ }
35
+ this.handleLanguageChange = this.handleLanguageChange.bind(this);
36
+ }
37
+ connectedCallback() {
38
+ super.connectedCallback();
39
+ document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
40
+ }
41
+ disconnectedCallback() {
42
+ super.disconnectedCallback();
43
+ document.removeEventListener('language-changed', this.handleLanguageChange.bind(this));
44
+ }
45
+ handleLanguageChange(e) {
46
+ this.language = e.detail.language;
47
+ }
48
+ render() {
49
+ return html `
50
+ <div class="finding-container">
51
+ <div class="question"><slot>${this.questionTemplate()}</slot></div>
52
+ <div class="question-control">${this.controlTemplate()}</div>
53
+ </div>
54
+ `;
55
+ }
56
+ questionTemplate() {
57
+ return html `<span class="question-text">${this.questionText}</span>`;
58
+ }
59
+ metaValidation(value) {
60
+ const message = validate(this.validators, value, this.language);
61
+ return message ? message : this.customValidation(value);
62
+ }
63
+ setDefaultValue(readonly, defaultValue) {
64
+ if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
65
+ return;
66
+ }
67
+ this.getUpdateComplete().then(() => {
68
+ if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
69
+ this.setValue(defaultValue);
70
+ this.validateField(defaultValue);
71
+ }
72
+ });
73
+ }
74
+ static get styles() {
75
+ // language=CSS
76
+ return [
77
+ FlexLayoutClasses,
78
+ css `
79
+ :host {
80
+ display: block;
81
+ width: 100%;
82
+ padding: 0 25px 0 45px;
83
+ box-sizing: border-box;
84
+ }
85
+
86
+ .finding-container {
87
+ width: 100%;
88
+ display: flex;
89
+ }
90
+ .flex-wrapping {
91
+ flex-wrap: wrap;
92
+ }
93
+
94
+ :host(.wide) .finding-container {
95
+ flex-direction: column;
96
+ }
97
+
98
+ :host(.wide) .question {
99
+ margin-bottom: -8px;
100
+ min-height: 0;
101
+ }
102
+
103
+ .question-control,
104
+ .question {
105
+ min-width: 0;
106
+ min-height: 57px;
107
+ display: flex;
108
+ align-items: center;
109
+ }
110
+ .question {
111
+ flex: 2;
112
+ }
113
+ .question-control {
114
+ flex: 3;
115
+ }
116
+ .add-button {
117
+ padding: 3px;
118
+ margin: 10px;
119
+ background: transparent;
120
+ color: var(--primary-color);
121
+ border: 1px solid;
122
+ }
123
+
124
+ .full-width,
125
+ paper-input,
126
+ paper-textarea {
127
+ width: 100%;
128
+ }
129
+
130
+ .question-text {
131
+ font-weight: 500;
132
+ font-size: 13px;
133
+ color: var(--primary-text-color);
134
+ }
135
+
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'] {
149
+ cursor: pointer;
150
+ }
151
+
152
+ .error-text {
153
+ color: var(--error-color);
154
+ font-size: 12px;
155
+ }
156
+
157
+ @media (max-width: 1080px) {
158
+ :host {
159
+ padding: 0 15px;
160
+ }
161
+ .finding-container {
162
+ flex-direction: column;
163
+ }
164
+ .question,
165
+ .question-control {
166
+ flex: 0 1 auto;
167
+ }
168
+ }
169
+
170
+ @media print {
171
+ .question-control {
172
+ align-items: start;
173
+ }
174
+
175
+ :host(text-field) .question-control {
176
+ min-height: 150px;
177
+ }
178
+
179
+ .question-control .container paper-radio-group {
180
+ flex-direction: column;
181
+ opacity: 1 !important;
182
+ }
183
+
184
+ .finding-container {
185
+ flex-direction: column;
186
+ }
187
+ }
188
+ `
189
+ ];
190
+ }
191
+ }
192
+ __decorate([
193
+ property({ type: String })
194
+ ], AbstractFieldBaseClass.prototype, "questionText", void 0);
195
+ __decorate([
196
+ property()
197
+ ], AbstractFieldBaseClass.prototype, "language", void 0);
198
+ __decorate([
199
+ property({ type: Boolean, attribute: 'is-readonly' })
200
+ ], AbstractFieldBaseClass.prototype, "isReadonly", null);
201
+ __decorate([
202
+ property({ type: Boolean, attribute: 'required' })
203
+ ], AbstractFieldBaseClass.prototype, "required", void 0);
204
+ __decorate([
205
+ property()
206
+ ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
207
+ __decorate([
208
+ property()
209
+ ], 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';
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
+ }