@unicef-polymer/etools-form-builder 1.0.3 → 2.1.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 (56) hide show
  1. package/dist/form-attachments-popup/form-attachments-popup.d.ts +10 -2
  2. package/dist/form-attachments-popup/form-attachments-popup.js +53 -48
  3. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -5
  4. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +79 -85
  5. package/dist/form-fields/abstract-field-base.class.d.ts +28 -0
  6. package/dist/form-fields/{base-field.js → abstract-field-base.class.js} +133 -112
  7. package/dist/form-fields/custom-elements.define.js +17 -5
  8. package/dist/form-fields/field-renderer-component.d.ts +20 -0
  9. package/dist/form-fields/field-renderer-component.js +245 -0
  10. package/dist/form-fields/index.d.ts +9 -5
  11. package/dist/form-fields/index.js +9 -5
  12. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -0
  13. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +198 -0
  14. package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -0
  15. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +123 -0
  16. package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -0
  17. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +56 -0
  18. package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -0
  19. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +104 -0
  20. package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -0
  21. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +43 -0
  22. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -0
  23. package/dist/form-fields/single-fields/attachment-field.js +87 -0
  24. package/dist/form-fields/single-fields/base-field.d.ts +11 -0
  25. package/dist/form-fields/single-fields/base-field.js +57 -0
  26. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -0
  27. package/dist/form-fields/single-fields/boolean-field.js +39 -0
  28. package/dist/form-fields/{number-field.d.ts → single-fields/number-field.d.ts} +1 -0
  29. package/dist/form-fields/{number-field.js → single-fields/number-field.js} +34 -21
  30. package/dist/form-fields/{scale-field.d.ts → single-fields/scale-field.d.ts} +4 -2
  31. package/dist/form-fields/{scale-field.js → single-fields/scale-field.js} +66 -54
  32. package/dist/form-fields/{text-field.d.ts → single-fields/text-field.d.ts} +0 -0
  33. package/dist/form-fields/{text-field.js → single-fields/text-field.js} +26 -21
  34. package/dist/form-fields/wide-field.d.ts +1 -1
  35. package/dist/form-fields/wide-field.js +3 -3
  36. package/dist/form-groups/form-abstract-group.d.ts +12 -12
  37. package/dist/form-groups/form-abstract-group.js +189 -166
  38. package/dist/form-groups/form-card.d.ts +1 -0
  39. package/dist/form-groups/form-card.js +35 -10
  40. package/dist/form-groups/form-collapsed-card.d.ts +3 -1
  41. package/dist/form-groups/form-collapsed-card.js +45 -25
  42. package/dist/index.d.ts +1 -1
  43. package/dist/index.js +6 -1
  44. package/dist/lib/additional-components/confirmation-dialog.d.ts +16 -0
  45. package/dist/lib/additional-components/confirmation-dialog.js +61 -0
  46. package/dist/lib/additional-components/etools-fb-card.js +135 -128
  47. package/dist/lib/styles/attachments.styles.js +69 -66
  48. package/dist/lib/styles/form-builder-card.styles.js +46 -41
  49. package/dist/lib/styles/input-styles.js +53 -64
  50. package/dist/lib/styles/page-layout-styles.js +198 -198
  51. package/dist/lib/types/form-builder.interfaces.d.ts +2 -2
  52. package/dist/lib/types/form-builder.types.d.ts +8 -2
  53. package/dist/lib/utils/validations.helper.d.ts +3 -3
  54. package/dist/lib/utils/validations.helper.js +7 -7
  55. package/package.json +53 -52
  56. package/dist/form-fields/base-field.d.ts +0 -20
package/dist/index.js CHANGED
@@ -11,9 +11,14 @@ import './form-groups/custom-elements.define';
11
11
  * Form field elements
12
12
  */
13
13
  import './form-fields/custom-elements.define';
14
- export * from './form-fields/base-field';
14
+ export * from './form-fields/single-fields/base-field';
15
15
  /**
16
16
  * Attachments Popup
17
17
  */
18
18
  import { FormAttachmentsPopup } from './form-attachments-popup';
19
19
  window.customElements.define('form-attachments-popup', FormAttachmentsPopup);
20
+ /**
21
+ * Confirmation Popup
22
+ */
23
+ import { ConfirmationDialog } from './lib/additional-components/confirmation-dialog';
24
+ window.customElements.define('confirmation-popup', ConfirmationDialog);
@@ -0,0 +1,16 @@
1
+ import { LitElement, CSSResultArray } from 'lit-element';
2
+ export declare class ConfirmationDialog extends LitElement {
3
+ dialogOpened: boolean;
4
+ text: string;
5
+ dialogTitle: string;
6
+ hideConfirmBtn: boolean;
7
+ set dialogData({ text, dialogTitle, hideConfirmBtn }: {
8
+ text: string;
9
+ dialogTitle: string;
10
+ hideConfirmBtn: boolean;
11
+ });
12
+ render(): unknown;
13
+ onClose(): void;
14
+ confirm(): void;
15
+ static get styles(): CSSResultArray;
16
+ }
@@ -0,0 +1,61 @@
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, html, css } from 'lit-element';
8
+ import { fireEvent } from '../utils/fire-custom-event';
9
+ export class ConfirmationDialog extends LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.dialogOpened = true;
13
+ this.text = '';
14
+ this.dialogTitle = '';
15
+ this.hideConfirmBtn = false;
16
+ }
17
+ set dialogData({ text, dialogTitle = 'Are you', hideConfirmBtn = false }) {
18
+ this.text = text;
19
+ this.dialogTitle = dialogTitle;
20
+ this.hideConfirmBtn = hideConfirmBtn;
21
+ this.requestUpdate();
22
+ }
23
+ render() {
24
+ return html `
25
+ <etools-dialog
26
+ id="confirmation-dialog"
27
+ size="md"
28
+ no-padding
29
+ keep-dialog-open
30
+ ?hide-confirm-btn="${this.hideConfirmBtn}"
31
+ cancel-btn-text="${this.hideConfirmBtn ? 'Ok' : 'Cancel'}"
32
+ ?opened="${this.dialogOpened}"
33
+ theme="confirmation"
34
+ dialog-title="${this.dialogTitle}"
35
+ @close="${this.onClose}"
36
+ @confirm-btn-clicked="${() => this.confirm()}"
37
+ >
38
+ <div class="confirmation-message">${this.text}</div>
39
+ </etools-dialog>
40
+ `;
41
+ }
42
+ onClose() {
43
+ fireEvent(this, 'response', { confirmed: false });
44
+ }
45
+ confirm() {
46
+ fireEvent(this, 'response', { confirmed: true });
47
+ }
48
+ static get styles() {
49
+ // language=CSS
50
+ return [
51
+ css `
52
+ .confirmation-message {
53
+ padding-left: 24px;
54
+ }
55
+ `
56
+ ];
57
+ }
58
+ }
59
+ __decorate([
60
+ property()
61
+ ], ConfirmationDialog.prototype, "dialogOpened", void 0);
@@ -25,97 +25,103 @@ let EtoolsFbCard = class EtoolsFbCard extends LitElement {
25
25
  elevationStyles,
26
26
  CardStyles,
27
27
  FlexLayoutClasses,
28
- css `
29
- :host {
30
- display: block;
31
- }
32
-
33
- .card-container {
34
- background-color: var(--primary-background-color);
35
- }
36
-
37
- .card-title-box[is-collapsible] {
38
- padding-left: 17px;
39
- padding-right: 25px;
40
- }
41
-
42
- .card-content {
43
- padding: 0;
44
- }
45
-
46
- .card-buttons {
47
- padding: 12px 24px;
48
- }
49
-
50
- .save-button {
51
- color: var(--primary-background-color);
52
- background-color: var(--primary-color);
53
- }
54
-
55
- .edit-button {
56
- color: var(--gray-mid);
57
- }
58
-
59
- .edit-button[edit] {
60
- color: var(--primary-color);
61
- }
62
-
63
- .flex-header {
64
- display: flex;
65
- align-items: center;
66
- padding-top: auto;
67
- flex-wrap: nowrap;
68
- }
69
- .flex-header__collapse {
70
- flex-basis: auto;
71
- }
72
- .flex-header__title {
73
- font-size: 18px;
74
- flex-basis: auto;
75
- flex-grow: 1;
76
- overflow: hidden;
77
- white-space: nowrap;
78
- text-overflow: ellipsis;
79
- }
80
- .flex-header__actions {
81
- order: 1;
82
- width: auto;
83
- display: flex;
84
- flex-basis: auto;
85
- }
86
- .flex-header__edit {
87
- order: 2;
88
- }
89
- @media (max-width: 380px) {
90
- .card-title-box[is-collapsible] {
91
- padding-left: 0;
92
- padding-right: 0;
93
- }
94
- .flex-header {
95
- align-items: baseline;
96
- padding-top: 10px;
97
- flex-wrap: wrap;
98
- }
99
- .flex-header__collapse {
100
- flex-basis: 20%;
101
- }
102
- .flex-header__title {
103
- flex-basis: 60%;
104
- overflow: unset;
105
- white-space: unset;
106
- text-overflow: unset;
107
- }
108
- .flex-header__actions {
109
- order: 2;
110
- width: 100%;
111
- border-top: 1px solid lightgrey;
112
- justify-content: flex-end;
113
- }
114
- .flex-header__edit {
115
- order: 1;
116
- flex-basis: 20%;
117
- }
118
- }
28
+ css `
29
+ :host {
30
+ display: block;
31
+ }
32
+
33
+ .card-container {
34
+ background-color: var(--primary-background-color);
35
+ }
36
+
37
+ .card-title-box[is-collapsible] {
38
+ padding-left: 17px;
39
+ padding-right: 25px;
40
+ }
41
+
42
+ .card-content {
43
+ padding: 0;
44
+ }
45
+
46
+ .card-buttons {
47
+ padding: 12px 24px;
48
+ }
49
+
50
+ .save-button {
51
+ color: var(--primary-background-color);
52
+ background-color: var(--primary-color);
53
+ }
54
+
55
+ .edit-button {
56
+ color: var(--gray-mid);
57
+ }
58
+
59
+ .edit-button[edit] {
60
+ color: var(--primary-color);
61
+ }
62
+
63
+ .flex-header {
64
+ display: flex;
65
+ align-items: center;
66
+ padding-top: auto;
67
+ flex-wrap: nowrap;
68
+ }
69
+ .flex-header__collapse {
70
+ flex-basis: auto;
71
+ }
72
+ .flex-header__title {
73
+ font-size: 18px;
74
+ flex-basis: auto;
75
+ flex-grow: 1;
76
+ overflow: hidden;
77
+ white-space: nowrap;
78
+ text-overflow: ellipsis;
79
+ }
80
+ .flex-header__actions {
81
+ order: 1;
82
+ width: auto;
83
+ display: flex;
84
+ flex-basis: auto;
85
+ }
86
+ .flex-header__postfix {
87
+ order: 3;
88
+ }
89
+ .flex-header__edit {
90
+ order: 2;
91
+ }
92
+ @media (max-width: 380px) {
93
+ .card-title-box[is-collapsible] {
94
+ padding-left: 0;
95
+ padding-right: 0;
96
+ }
97
+ .flex-header {
98
+ align-items: baseline;
99
+ padding-top: 10px;
100
+ flex-wrap: wrap;
101
+ }
102
+ .flex-header__collapse {
103
+ flex-basis: 20%;
104
+ }
105
+ .flex-header__title {
106
+ flex-basis: 60%;
107
+ overflow: unset;
108
+ white-space: unset;
109
+ text-overflow: unset;
110
+ }
111
+ .flex-header__actions {
112
+ order: 2;
113
+ width: 100%;
114
+ border-top: 1px solid lightgrey;
115
+ justify-content: flex-end;
116
+ }
117
+ .flex-header__postfix {
118
+ order: 3;
119
+ }
120
+ .flex-header__edit {
121
+ order: 1;
122
+ flex-basis: 20%;
123
+ }
124
+ }
119
125
  `
120
126
  ];
121
127
  }
@@ -138,49 +144,50 @@ let EtoolsFbCard = class EtoolsFbCard extends LitElement {
138
144
  }
139
145
  // language=HTML
140
146
  render() {
141
- return html `
142
- <div class="elevation card-container" elevation="1">
143
- <header class="card-title-box with-bottom-line flex-header" ?is-collapsible="${this.isCollapsible}">
147
+ return html `
148
+ <div class="elevation card-container" elevation="1">
149
+ <header class="card-title-box with-bottom-line flex-header" ?is-collapsible="${this.isCollapsible}">
144
150
  ${this.isCollapsible
145
- ? html `
146
- <paper-icon-button
147
- class="flex-header__collapse"
148
- @tap="${() => this.toggleCollapse()}"
149
- icon="${this.collapsed ? 'expand-more' : 'expand-less'}"
150
- ></paper-icon-button>
151
+ ? html `
152
+ <paper-icon-button
153
+ class="flex-header__collapse"
154
+ @tap="${() => this.toggleCollapse()}"
155
+ icon="${this.collapsed ? 'expand-more' : 'expand-less'}"
156
+ ></paper-icon-button>
151
157
  `
152
- : ''}
153
- <div class="flex-header__title">${this.cardTitle}</div>
154
- <div class="flex-header__actions"><slot name="actions"></slot></div>
155
- <div class="layout horizontal center flex-header__edit">
158
+ : ''}
159
+ <div class="flex-header__title">${this.cardTitle}</div>
160
+ <div class="flex-header__actions"><slot name="actions"></slot></div>
161
+ <div class="layout horizontal center flex-header__edit">
156
162
  ${this.isEditable
157
- ? html `
158
- <paper-icon-button
159
- icon="create"
160
- ?edit=${this.edit}
161
- ?hidden="${this.hideEditButton}"
162
- class="edit-button"
163
- @tap="${() => this.startEdit()}"
164
- ></paper-icon-button>
163
+ ? html `
164
+ <paper-icon-button
165
+ icon="create"
166
+ ?edit=${this.edit}
167
+ ?hidden="${this.hideEditButton}"
168
+ class="edit-button"
169
+ @tap="${() => this.startEdit()}"
170
+ ></paper-icon-button>
165
171
  `
166
- : ''}
167
- </div>
168
- </header>
169
- <iron-collapse ?opened="${!this.collapsed}">
170
- <section class="card-content-block">
171
- <slot name="content"></slot>
172
-
172
+ : ''}
173
+ </div>
174
+ <div class="flex-header__postfix"><slot name="postfix"></slot></div>
175
+ </header>
176
+ <iron-collapse ?opened="${!this.collapsed}">
177
+ <section class="card-content-block">
178
+ <slot name="content"></slot>
179
+
173
180
  ${this.isEditable && this.edit
174
- ? html `
175
- <div class="layout horizontal end-justified card-buttons">
176
- <paper-button @tap="${() => this.cancel()}">Cancel</paper-button>
177
- <paper-button class="save-button" @tap="${() => this.save()}">Save</paper-button>
178
- </div>
181
+ ? html `
182
+ <div class="layout horizontal end-justified card-buttons">
183
+ <paper-button @tap="${() => this.cancel()}">Cancel</paper-button>
184
+ <paper-button class="save-button" @tap="${() => this.save()}">Save</paper-button>
185
+ </div>
179
186
  `
180
- : ''}
181
- </section>
182
- </iron-collapse>
183
- </div>
187
+ : ''}
188
+ </section>
189
+ </iron-collapse>
190
+ </div>
184
191
  `;
185
192
  }
186
193
  };
@@ -1,69 +1,72 @@
1
1
  import { css } from 'lit-element';
2
2
  // language=CSS
3
- export const AttachmentsStyles = css `
4
- .file-selector-container {
5
- display: flex;
6
- flex-flow: row;
7
- align-items: center;
8
- padding: 8px 0;
9
- }
10
- .filename-container {
11
- display: flex;
12
- align-items: center;
13
- border-bottom: 1px solid var(--secondary-text-color, rgba(0, 0, 0, 0.54));
14
- margin: 0 14px;
15
- min-width: 145px;
16
- overflow-wrap: break-word;
17
- font-size: 16px;
18
- }
19
- .filename {
20
- overflow: hidden;
21
- text-overflow: ellipsis;
22
- white-space: nowrap;
23
- }
24
- .file-icon {
25
- width: 24px;
26
- flex: none;
27
- color: var(--secondary-text-color, rgba(0, 0, 0, 0.54));
28
- }
29
- .delete-button {
30
- color: #ea4022;
31
- }
32
- .upload-button,
33
- .download-button {
34
- color: var(--primary-color);
35
- min-width: 130px;
36
- }
37
- .change-button {
38
- color: var(--secondary-text-color, rgba(0, 0, 0, 0.54));
39
- }
40
- iron-icon {
41
- margin-right: 8px;
42
- }
43
- paper-button {
44
- font-weight: 700;
45
- margin: 0 0;
46
- padding: 0 0;
47
- }
48
- .file-selector-container.with-type-dropdown {
49
- padding: 0;
50
- }
51
- .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
52
- flex: none;
53
- width: 209px;
54
- }
55
- .file-selector-container.with-type-dropdown .filename-container {
56
- height: 32px;
57
- box-sizing: border-box;
58
- margin: 22px 0 8px;
59
- border-bottom: 1px solid var(--gray-20);
60
- }
61
- .file-selector-container.with-type-dropdown .delete-button,
62
- .file-selector-container.with-type-dropdown .download-button {
63
- margin-top: 15px;
64
- }
65
- etools-upload-multi.with-padding {
66
- padding: 12px 9px;
67
- box-sizing: border-box;
68
- }
3
+ export const AttachmentsStyles = css `
4
+ .file-selector-container {
5
+ display: flex;
6
+ flex-flow: row;
7
+ align-items: center;
8
+ padding: 8px 0;
9
+ }
10
+ .filename-container {
11
+ display: flex;
12
+ align-items: center;
13
+ border-bottom: 1px solid var(--secondary-text-color, rgba(0, 0, 0, 0.54));
14
+ margin: 0 14px 0 0;
15
+ min-width: 145px;
16
+ overflow-wrap: break-word;
17
+ font-size: 16px;
18
+ }
19
+ :host([is-readonly]) .filename-container {
20
+ border-bottom-color: transparent;
21
+ }
22
+ .filename {
23
+ overflow: hidden;
24
+ text-overflow: ellipsis;
25
+ white-space: nowrap;
26
+ }
27
+ .file-icon {
28
+ width: 24px;
29
+ flex: none;
30
+ color: var(--secondary-text-color, rgba(0, 0, 0, 0.54));
31
+ }
32
+ .delete-button {
33
+ color: #ea4022;
34
+ }
35
+ .upload-button,
36
+ .download-button {
37
+ color: var(--primary-color);
38
+ min-width: 130px;
39
+ }
40
+ .change-button {
41
+ color: var(--secondary-text-color, rgba(0, 0, 0, 0.54));
42
+ }
43
+ iron-icon {
44
+ margin-right: 8px;
45
+ }
46
+ paper-button {
47
+ font-weight: 700;
48
+ margin: 0 0;
49
+ padding: 0 0;
50
+ }
51
+ .file-selector-container.with-type-dropdown {
52
+ padding: 0;
53
+ }
54
+ .file-selector-container.with-type-dropdown etools-dropdown.type-dropdown {
55
+ flex: none;
56
+ width: 209px;
57
+ }
58
+ .file-selector-container.with-type-dropdown .filename-container {
59
+ height: 32px;
60
+ box-sizing: border-box;
61
+ margin: 22px 0 8px;
62
+ border-bottom: 1px solid var(--gray-20);
63
+ }
64
+ .file-selector-container.with-type-dropdown .delete-button,
65
+ .file-selector-container.with-type-dropdown .download-button {
66
+ margin-top: 15px;
67
+ }
68
+ etools-upload-multi.with-padding {
69
+ padding: 12px 9px 12px 0;
70
+ box-sizing: border-box;
71
+ }
69
72
  `;
@@ -1,44 +1,49 @@
1
1
  import { css } from 'lit-element';
2
2
  // language=CSS
3
- export const FormBuilderCardStyles = css `
4
- .overall-finding {
5
- padding: 15px 25px 20px 45px;
6
- background-color: var(--secondary-background-color);
7
- }
8
- .finding-container {
9
- border-bottom: 1px solid var(--light-divider-color);
10
- }
11
- .finding-container:last-child {
12
- /*border-bottom: none;*/
13
- }
14
- .attachments-button {
15
- color: var(--primary-color);
16
- font-weight: 500;
17
- }
18
- .attachments-button:focus {
19
- outline: 0;
20
- box-shadow: 0 0 5px 5px rgb(170 165 165 / 20%);
21
- background-color: rgba(170, 165, 165, 0.2);
22
- }
23
- .attachments-button iron-icon {
24
- margin-right: 8px;
25
- }
26
- .question-container {
27
- padding: 7px 0;
28
- width: 100%;
29
- }
30
- .question-text {
31
- font-weight: 500;
32
- font-size: 13px;
33
- color: var(--primary-text-color);
34
- }
35
- .question-details {
36
- font-size: 9px;
37
- }
38
-
39
- @media (max-width: 380px) {
40
- .overall-finding {
41
- padding: 5px;
42
- }
43
- }
3
+ export const FormBuilderCardStyles = css `
4
+ .overall-finding {
5
+ padding: 15px 25px 20px 45px;
6
+ background-color: var(--secondary-background-color);
7
+ }
8
+ field-renderer {
9
+ position: relative;
10
+ display: block;
11
+ border-bottom: 1px solid var(--light-divider-color);
12
+ }
13
+ field-renderer:last-of-type {
14
+ border-bottom: none;
15
+ }
16
+ .attachments-button {
17
+ color: var(--primary-color);
18
+ font-weight: 500;
19
+ }
20
+ .attachments-button:focus {
21
+ outline: 0;
22
+ box-shadow: 0 0 5px 5px rgb(170 165 165 / 20%);
23
+ background-color: rgba(170, 165, 165, 0.2);
24
+ }
25
+ .attachments-button iron-icon {
26
+ margin-right: 8px;
27
+ }
28
+ .question-container {
29
+ padding: 7px 0;
30
+ width: 100%;
31
+ min-height: 57px;
32
+ box-sizing: border-box;
33
+ justify-content: center;
34
+ }
35
+ .question-text {
36
+ font-weight: 500;
37
+ font-size: 13px;
38
+ color: var(--primary-text-color);
39
+ }
40
+ .question-details {
41
+ font-size: 9px;
42
+ }
43
+
44
+ @media (max-width: 380px) {
45
+ .overall-finding {
46
+ padding: 5px;
47
+ }
48
+ }
44
49
  `;