@unicef-polymer/etools-form-builder 2.1.0-rc.6 → 2.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 (83) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/form-attachments-popup/form-attachments-popup.d.ts +85 -85
  4. package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
  5. package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
  6. package/dist/form-attachments-popup/form-attachments-popup.js +248 -248
  7. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
  8. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +89 -89
  9. package/dist/form-attachments-popup/index.d.ts +2 -2
  10. package/dist/form-attachments-popup/index.js +2 -2
  11. package/dist/form-fields/abstract-field-base.class.d.ts +28 -28
  12. package/dist/form-fields/abstract-field-base.class.js +176 -176
  13. package/dist/form-fields/field-renderer-component.d.ts +20 -20
  14. package/dist/form-fields/field-renderer-component.js +249 -249
  15. package/dist/form-fields/index.d.ts +12 -12
  16. package/dist/form-fields/index.js +12 -12
  17. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
  18. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +208 -208
  19. package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
  20. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +123 -123
  21. package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
  22. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +66 -66
  23. package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
  24. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
  25. package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
  26. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
  27. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
  28. package/dist/form-fields/single-fields/attachment-field.js +97 -97
  29. package/dist/form-fields/single-fields/base-field.d.ts +11 -11
  30. package/dist/form-fields/single-fields/base-field.js +57 -57
  31. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
  32. package/dist/form-fields/single-fields/boolean-field.js +49 -49
  33. package/dist/form-fields/single-fields/number-field.d.ts +10 -10
  34. package/dist/form-fields/single-fields/number-field.js +66 -66
  35. package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
  36. package/dist/form-fields/single-fields/scale-field.js +107 -107
  37. package/dist/form-fields/single-fields/text-field.d.ts +8 -8
  38. package/dist/form-fields/single-fields/text-field.js +54 -54
  39. package/dist/form-groups/form-abstract-group.d.ts +60 -60
  40. package/dist/form-groups/form-abstract-group.js +353 -353
  41. package/dist/form-groups/form-card.d.ts +32 -32
  42. package/dist/form-groups/form-card.js +108 -108
  43. package/dist/form-groups/form-collapsed-card.d.ts +70 -70
  44. package/dist/form-groups/form-collapsed-card.js +253 -253
  45. package/dist/form-groups/index.d.ts +3 -3
  46. package/dist/form-groups/index.js +3 -3
  47. package/dist/index.d.ts +3 -3
  48. package/dist/index.js +3 -3
  49. package/dist/lib/additional-components/confirmation-dialog.d.ts +16 -16
  50. package/dist/lib/additional-components/confirmation-dialog.js +65 -65
  51. package/dist/lib/additional-components/etools-fb-card.d.ts +16 -16
  52. package/dist/lib/additional-components/etools-fb-card.js +215 -215
  53. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  54. package/dist/lib/styles/attachments.styles.js +72 -72
  55. package/dist/lib/styles/card-styles.d.ts +2 -2
  56. package/dist/lib/styles/card-styles.js +154 -154
  57. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  58. package/dist/lib/styles/dialog.styles.js +85 -85
  59. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  60. package/dist/lib/styles/elevation-styles.js +43 -43
  61. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  62. package/dist/lib/styles/flex-layout-classes.js +319 -319
  63. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  64. package/dist/lib/styles/form-builder-card.styles.js +49 -49
  65. package/dist/lib/styles/input-styles.d.ts +2 -2
  66. package/dist/lib/styles/input-styles.js +138 -138
  67. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  68. package/dist/lib/styles/page-layout-styles.js +201 -201
  69. package/dist/lib/styles/shared-styles.d.ts +2 -2
  70. package/dist/lib/styles/shared-styles.js +70 -70
  71. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  72. package/dist/lib/types/form-builder.interfaces.js +0 -0
  73. package/dist/lib/types/form-builder.types.d.ts +59 -59
  74. package/dist/lib/types/form-builder.types.js +0 -0
  75. package/dist/lib/types/global.types.d.ts +4 -4
  76. package/dist/lib/types/global.types.js +0 -0
  77. package/dist/lib/utils/dialog.d.ts +10 -10
  78. package/dist/lib/utils/dialog.js +21 -21
  79. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  80. package/dist/lib/utils/fire-custom-event.js +7 -7
  81. package/dist/lib/utils/validations.helper.d.ts +26 -26
  82. package/dist/lib/utils/validations.helper.js +35 -35
  83. package/package.json +56 -56
@@ -1,89 +1,89 @@
1
- import { html } from 'lit-html';
2
- import { InputStyles } from '../lib/styles/input-styles';
3
- import { DialogStyles } from '../lib/styles/dialog.styles';
4
- export function template() {
5
- var _a;
6
- return html `
7
- ${InputStyles} ${DialogStyles}
8
- <etools-dialog
9
- id="form-attachments-dialog"
10
- size="md"
11
- no-padding
12
- keep-dialog-open
13
- ?opened="${this.dialogOpened}"
14
- .okBtnText="Save"
15
- .hideConfirmBtn="${this.readonly}"
16
- dialog-title="${this.popupTitle}"
17
- @close="${this.onClose}"
18
- @confirm-btn-clicked="${() => this.saveChanges()}"
19
- >
20
- <!-- Link is used to download attachments -->
21
- <a id="link" target="_blank" hidden></a>
22
-
23
- <div class="popup-container">
24
- ${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
25
- var _a, _b;
26
- return html `
27
- <div class="file-selector-container with-type-dropdown">
28
- <!-- Type select Dropdown -->
29
- <etools-dropdown
30
- class="type-dropdown file-selector__type-dropdown"
31
- .selected="${attachment.file_type}"
32
- @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
33
- trigger-value-change-event
34
- label="Document Type"
35
- placeholder="Select Document Type"
36
- required
37
- ?readonly="${this.readonly}"
38
- hide-search
39
- .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}"
40
- option-label="label"
41
- option-value="value"
42
- ?invalid="${this.checkFileType(index)}"
43
- .errorMessage="${this.retrieveErrorMessage(index)}"
44
- allow-outside-scroll
45
- dynamic-align
46
- ></etools-dropdown>
47
-
48
- <!-- File name component -->
49
- <div class="filename-container file-selector__filename">
50
- <iron-icon class="file-icon" icon="attachment"></iron-icon>
51
- <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
52
- </div>
53
-
54
- <!-- Download Button -->
55
- <paper-button
56
- ?hidden="${!attachment.url}"
57
- class="download-button file-selector__download"
58
- @tap="${() => this.downloadFile(attachment)}"
59
- >
60
- <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
61
- Download
62
- </paper-button>
63
-
64
- <!-- Delete Button -->
65
- <paper-button
66
- class="delete-button file-selector__delete"
67
- ?hidden="${this.readonly}"
68
- @tap="${() => this.deleteAttachment(index)}"
69
- >
70
- Delete
71
- </paper-button>
72
- </div>
73
- `;
74
- })}
75
-
76
- <!-- Upload button -->
77
- <etools-upload-multi
78
- class="with-padding"
79
- activate-offline
80
- ?hidden="${this.readonly}"
81
- @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
82
- .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
83
- .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
84
- >
85
- </etools-upload-multi>
86
- </div>
87
- </etools-dialog>
88
- `;
89
- }
1
+ import { html } from 'lit-html';
2
+ import { InputStyles } from '../lib/styles/input-styles';
3
+ import { DialogStyles } from '../lib/styles/dialog.styles';
4
+ export function template() {
5
+ var _a;
6
+ return html `
7
+ ${InputStyles} ${DialogStyles}
8
+ <etools-dialog
9
+ id="form-attachments-dialog"
10
+ size="md"
11
+ no-padding
12
+ keep-dialog-open
13
+ ?opened="${this.dialogOpened}"
14
+ .okBtnText="Save"
15
+ .hideConfirmBtn="${this.readonly}"
16
+ dialog-title="${this.popupTitle}"
17
+ @close="${this.onClose}"
18
+ @confirm-btn-clicked="${() => this.saveChanges()}"
19
+ >
20
+ <!-- Link is used to download attachments -->
21
+ <a id="link" target="_blank" hidden></a>
22
+
23
+ <div class="popup-container">
24
+ ${(_a = this.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment, index) => {
25
+ var _a, _b;
26
+ return html `
27
+ <div class="file-selector-container with-type-dropdown">
28
+ <!-- Type select Dropdown -->
29
+ <etools-dropdown
30
+ class="type-dropdown file-selector__type-dropdown"
31
+ .selected="${attachment.file_type}"
32
+ @etools-selected-item-changed="${({ detail }) => { var _a; return this.changeFileType(attachment, (_a = detail.selectedItem) === null || _a === void 0 ? void 0 : _a.value, index); }}"
33
+ trigger-value-change-event
34
+ label="Document Type"
35
+ placeholder="Select Document Type"
36
+ required
37
+ ?readonly="${this.readonly}"
38
+ hide-search
39
+ .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}"
40
+ option-label="label"
41
+ option-value="value"
42
+ ?invalid="${this.checkFileType(index)}"
43
+ .errorMessage="${this.retrieveErrorMessage(index)}"
44
+ allow-outside-scroll
45
+ dynamic-align
46
+ ></etools-dropdown>
47
+
48
+ <!-- File name component -->
49
+ <div class="filename-container file-selector__filename">
50
+ <iron-icon class="file-icon" icon="attachment"></iron-icon>
51
+ <span class="filename" title="${attachment.filename}">${attachment.filename}</span>
52
+ </div>
53
+
54
+ <!-- Download Button -->
55
+ <paper-button
56
+ ?hidden="${!attachment.url}"
57
+ class="download-button file-selector__download"
58
+ @tap="${() => this.downloadFile(attachment)}"
59
+ >
60
+ <iron-icon icon="cloud-download" class="dw-icon"></iron-icon>
61
+ Download
62
+ </paper-button>
63
+
64
+ <!-- Delete Button -->
65
+ <paper-button
66
+ class="delete-button file-selector__delete"
67
+ ?hidden="${this.readonly}"
68
+ @tap="${() => this.deleteAttachment(index)}"
69
+ >
70
+ Delete
71
+ </paper-button>
72
+ </div>
73
+ `;
74
+ })}
75
+
76
+ <!-- Upload button -->
77
+ <etools-upload-multi
78
+ class="with-padding"
79
+ activate-offline
80
+ ?hidden="${this.readonly}"
81
+ @upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
82
+ .endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
83
+ .jwtLocalStorageKey="${this.jwtLocalStorageKey}"
84
+ >
85
+ </etools-upload-multi>
86
+ </div>
87
+ </etools-dialog>
88
+ `;
89
+ }
@@ -1,2 +1,2 @@
1
- export * from './form-attachments-popup';
2
- export * from './form-attachments-popup.helper';
1
+ export * from './form-attachments-popup';
2
+ export * from './form-attachments-popup.helper';
@@ -1,2 +1,2 @@
1
- export * from './form-attachments-popup';
2
- export * from './form-attachments-popup.helper';
1
+ export * from './form-attachments-popup';
2
+ export * from './form-attachments-popup.helper';
@@ -1,28 +1,28 @@
1
- import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
2
- import { FieldValidator } from '../lib/utils/validations.helper';
3
- /**
4
- * Class that contains common properties and methods for single and repeatable fields
5
- */
6
- export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
7
- questionText: string;
8
- set isReadonly(readonly: boolean);
9
- get isReadonly(): boolean;
10
- required: boolean;
11
- placeholder: string;
12
- value: T | null;
13
- validators: FieldValidator[];
14
- touched: boolean;
15
- set defaultValue(value: any);
16
- private _defaultValue;
17
- private _readonly;
18
- protected render(): TemplateResult;
19
- protected questionTemplate(): TemplateResult;
20
- protected metaValidation(value: unknown): string | null;
21
- private setDefaultValue;
22
- protected abstract valueChanged(...args: any): void;
23
- protected abstract customValidation(value: unknown): string | null;
24
- protected abstract controlTemplate(...args: any): TemplateResult;
25
- protected abstract setValue(value: T): void;
26
- protected abstract validateField(value: T): void;
27
- static get styles(): CSSResultArray;
28
- }
1
+ import { CSSResultArray, LitElement, TemplateResult } from 'lit-element';
2
+ import { FieldValidator } from '../lib/utils/validations.helper';
3
+ /**
4
+ * Class that contains common properties and methods for single and repeatable fields
5
+ */
6
+ export declare abstract class AbstractFieldBaseClass<T> extends LitElement {
7
+ questionText: string;
8
+ set isReadonly(readonly: boolean);
9
+ get isReadonly(): boolean;
10
+ required: boolean;
11
+ placeholder: string;
12
+ value: T | null;
13
+ validators: FieldValidator[];
14
+ touched: boolean;
15
+ set defaultValue(value: any);
16
+ private _defaultValue;
17
+ private _readonly;
18
+ protected render(): TemplateResult;
19
+ protected questionTemplate(): TemplateResult;
20
+ protected metaValidation(value: unknown): string | null;
21
+ private setDefaultValue;
22
+ protected abstract valueChanged(...args: any): void;
23
+ protected abstract customValidation(value: unknown): string | null;
24
+ protected abstract controlTemplate(...args: any): TemplateResult;
25
+ protected abstract setValue(value: T): void;
26
+ protected abstract validateField(value: T): void;
27
+ static get styles(): CSSResultArray;
28
+ }
@@ -1,176 +1,176 @@
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(...arguments);
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
- }
24
- set isReadonly(readonly) {
25
- this._readonly = readonly;
26
- this.setDefaultValue(readonly, this._defaultValue);
27
- this.requestUpdate();
28
- }
29
- get isReadonly() {
30
- return this._readonly;
31
- }
32
- set defaultValue(value) {
33
- this._defaultValue = value;
34
- this.setDefaultValue(this._readonly, value);
35
- this.requestUpdate();
36
- }
37
- render() {
38
- return html `
39
- <div class="finding-container">
40
- <div class="question"><slot>${this.questionTemplate()}</slot></div>
41
- <div class="question-control">${this.controlTemplate()}</div>
42
- </div>
43
- `;
44
- }
45
- questionTemplate() {
46
- return html `<span class="question-text">${this.questionText}</span>`;
47
- }
48
- metaValidation(value) {
49
- const message = validate(this.validators, value);
50
- return message ? message : this.customValidation(value);
51
- }
52
- setDefaultValue(readonly, defaultValue) {
53
- if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
54
- return;
55
- }
56
- this.getUpdateComplete().then(() => {
57
- if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
58
- this.setValue(defaultValue);
59
- this.validateField(defaultValue);
60
- }
61
- });
62
- }
63
- static get styles() {
64
- // language=CSS
65
- return [
66
- FlexLayoutClasses,
67
- css `
68
- :host {
69
- display: block;
70
- width: 100%;
71
- padding: 0 25px 0 45px;
72
- box-sizing: border-box;
73
- }
74
-
75
- .finding-container {
76
- width: 100%;
77
- display: flex;
78
- }
79
- .flex-wrapping {
80
- flex-wrap: wrap;
81
- }
82
-
83
- :host(.wide) .finding-container {
84
- flex-direction: column;
85
- }
86
-
87
- :host(.wide) .question {
88
- margin-bottom: -8px;
89
- min-height: 0;
90
- }
91
-
92
- .question-control,
93
- .question {
94
- min-width: 0;
95
- min-height: 57px;
96
- display: flex;
97
- align-items: center;
98
- }
99
- .question {
100
- flex: 2;
101
- }
102
- .question-control {
103
- flex: 3;
104
- }
105
- .add-button {
106
- padding: 3px;
107
- margin: 10px;
108
- background: transparent;
109
- color: var(--primary-color);
110
- border: 1px solid;
111
- }
112
-
113
- .full-width,
114
- paper-input,
115
- paper-textarea {
116
- width: 100%;
117
- }
118
-
119
- .question-text {
120
- font-weight: 500;
121
- font-size: 13px;
122
- color: var(--primary-text-color);
123
- }
124
-
125
- paper-input,
126
- paper-textarea {
127
- outline: none !important;
128
- }
129
- paper-input[required],
130
- paper-textarea[required] {
131
- --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')
132
- no-repeat 98% 14%/7px;
133
- --paper-input-container-label_-_max-width: max-content;
134
- --paper-input-container-label_-_padding-right: 15px;
135
- }
136
-
137
- iron-icon[icon='close'] {
138
- cursor: pointer;
139
- }
140
-
141
- .error-text {
142
- color: var(--error-color);
143
- font-size: 12px;
144
- }
145
-
146
- @media (max-width: 1080px) {
147
- :host {
148
- padding: 0 15px;
149
- }
150
- .finding-container {
151
- flex-direction: column;
152
- }
153
- .question,
154
- .question-control {
155
- flex: 0 1 auto;
156
- }
157
- }
158
- `
159
- ];
160
- }
161
- }
162
- __decorate([
163
- property({ type: String })
164
- ], AbstractFieldBaseClass.prototype, "questionText", void 0);
165
- __decorate([
166
- property({ type: Boolean, attribute: 'is-readonly' })
167
- ], AbstractFieldBaseClass.prototype, "isReadonly", null);
168
- __decorate([
169
- property({ type: Boolean, attribute: 'required' })
170
- ], AbstractFieldBaseClass.prototype, "required", void 0);
171
- __decorate([
172
- property()
173
- ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
174
- __decorate([
175
- property()
176
- ], 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(...arguments);
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
+ }
24
+ set isReadonly(readonly) {
25
+ this._readonly = readonly;
26
+ this.setDefaultValue(readonly, this._defaultValue);
27
+ this.requestUpdate();
28
+ }
29
+ get isReadonly() {
30
+ return this._readonly;
31
+ }
32
+ set defaultValue(value) {
33
+ this._defaultValue = value;
34
+ this.setDefaultValue(this._readonly, value);
35
+ this.requestUpdate();
36
+ }
37
+ render() {
38
+ return html `
39
+ <div class="finding-container">
40
+ <div class="question"><slot>${this.questionTemplate()}</slot></div>
41
+ <div class="question-control">${this.controlTemplate()}</div>
42
+ </div>
43
+ `;
44
+ }
45
+ questionTemplate() {
46
+ return html `<span class="question-text">${this.questionText}</span>`;
47
+ }
48
+ metaValidation(value) {
49
+ const message = validate(this.validators, value);
50
+ return message ? message : this.customValidation(value);
51
+ }
52
+ setDefaultValue(readonly, defaultValue) {
53
+ if (readonly || (!defaultValue && defaultValue !== 0) || this.value !== undefined) {
54
+ return;
55
+ }
56
+ this.getUpdateComplete().then(() => {
57
+ if (defaultValue === this._defaultValue && readonly === this._readonly && this.value === undefined) {
58
+ this.setValue(defaultValue);
59
+ this.validateField(defaultValue);
60
+ }
61
+ });
62
+ }
63
+ static get styles() {
64
+ // language=CSS
65
+ return [
66
+ FlexLayoutClasses,
67
+ css `
68
+ :host {
69
+ display: block;
70
+ width: 100%;
71
+ padding: 0 25px 0 45px;
72
+ box-sizing: border-box;
73
+ }
74
+
75
+ .finding-container {
76
+ width: 100%;
77
+ display: flex;
78
+ }
79
+ .flex-wrapping {
80
+ flex-wrap: wrap;
81
+ }
82
+
83
+ :host(.wide) .finding-container {
84
+ flex-direction: column;
85
+ }
86
+
87
+ :host(.wide) .question {
88
+ margin-bottom: -8px;
89
+ min-height: 0;
90
+ }
91
+
92
+ .question-control,
93
+ .question {
94
+ min-width: 0;
95
+ min-height: 57px;
96
+ display: flex;
97
+ align-items: center;
98
+ }
99
+ .question {
100
+ flex: 2;
101
+ }
102
+ .question-control {
103
+ flex: 3;
104
+ }
105
+ .add-button {
106
+ padding: 3px;
107
+ margin: 10px;
108
+ background: transparent;
109
+ color: var(--primary-color);
110
+ border: 1px solid;
111
+ }
112
+
113
+ .full-width,
114
+ paper-input,
115
+ paper-textarea {
116
+ width: 100%;
117
+ }
118
+
119
+ .question-text {
120
+ font-weight: 500;
121
+ font-size: 13px;
122
+ color: var(--primary-text-color);
123
+ }
124
+
125
+ paper-input,
126
+ paper-textarea {
127
+ outline: none !important;
128
+ }
129
+ paper-input[required],
130
+ paper-textarea[required] {
131
+ --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')
132
+ no-repeat 98% 14%/7px;
133
+ --paper-input-container-label_-_max-width: max-content;
134
+ --paper-input-container-label_-_padding-right: 15px;
135
+ }
136
+
137
+ iron-icon[icon='close'] {
138
+ cursor: pointer;
139
+ }
140
+
141
+ .error-text {
142
+ color: var(--error-color);
143
+ font-size: 12px;
144
+ }
145
+
146
+ @media (max-width: 1080px) {
147
+ :host {
148
+ padding: 0 15px;
149
+ }
150
+ .finding-container {
151
+ flex-direction: column;
152
+ }
153
+ .question,
154
+ .question-control {
155
+ flex: 0 1 auto;
156
+ }
157
+ }
158
+ `
159
+ ];
160
+ }
161
+ }
162
+ __decorate([
163
+ property({ type: String })
164
+ ], AbstractFieldBaseClass.prototype, "questionText", void 0);
165
+ __decorate([
166
+ property({ type: Boolean, attribute: 'is-readonly' })
167
+ ], AbstractFieldBaseClass.prototype, "isReadonly", null);
168
+ __decorate([
169
+ property({ type: Boolean, attribute: 'required' })
170
+ ], AbstractFieldBaseClass.prototype, "required", void 0);
171
+ __decorate([
172
+ property()
173
+ ], AbstractFieldBaseClass.prototype, "placeholder", void 0);
174
+ __decorate([
175
+ property()
176
+ ], 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
+ }