@unicef-polymer/etools-form-builder 1.0.0-rc.2 → 1.0.3

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 (64) hide show
  1. package/dist/form-attachments-popup/form-attachments-popup.d.ts +77 -77
  2. package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
  3. package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
  4. package/dist/form-attachments-popup/form-attachments-popup.js +191 -191
  5. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +8 -8
  6. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +15 -15
  7. package/dist/form-attachments-popup/index.d.ts +2 -2
  8. package/dist/form-attachments-popup/index.js +2 -2
  9. package/dist/form-fields/base-field.d.ts +20 -20
  10. package/dist/form-fields/base-field.js +80 -80
  11. package/dist/form-fields/custom-elements.define.d.ts +1 -1
  12. package/dist/form-fields/custom-elements.define.js +11 -11
  13. package/dist/form-fields/index.d.ts +5 -5
  14. package/dist/form-fields/index.js +5 -5
  15. package/dist/form-fields/number-field.d.ts +9 -9
  16. package/dist/form-fields/number-field.js +24 -24
  17. package/dist/form-fields/scale-field.d.ts +16 -16
  18. package/dist/form-fields/scale-field.js +38 -38
  19. package/dist/form-fields/text-field.d.ts +8 -8
  20. package/dist/form-fields/text-field.js +19 -19
  21. package/dist/form-fields/wide-field.d.ts +11 -11
  22. package/dist/form-fields/wide-field.js +36 -36
  23. package/dist/form-groups/custom-elements.define.d.ts +1 -1
  24. package/dist/form-groups/custom-elements.define.js +9 -9
  25. package/dist/form-groups/form-abstract-group.d.ts +60 -60
  26. package/dist/form-groups/form-abstract-group.js +199 -199
  27. package/dist/form-groups/form-card.d.ts +31 -31
  28. package/dist/form-groups/form-card.js +69 -69
  29. package/dist/form-groups/form-collapsed-card.d.ts +68 -68
  30. package/dist/form-groups/form-collapsed-card.js +210 -209
  31. package/dist/form-groups/index.d.ts +3 -3
  32. package/dist/form-groups/index.js +3 -3
  33. package/dist/index.d.ts +14 -14
  34. package/dist/index.js +19 -19
  35. package/dist/lib/additional-components/etools-fb-card.d.ts +16 -16
  36. package/dist/lib/additional-components/etools-fb-card.js +81 -81
  37. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  38. package/dist/lib/styles/attachments.styles.js +3 -3
  39. package/dist/lib/styles/card-styles.d.ts +2 -2
  40. package/dist/lib/styles/card-styles.js +3 -3
  41. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  42. package/dist/lib/styles/dialog.styles.js +3 -3
  43. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  44. package/dist/lib/styles/elevation-styles.js +10 -10
  45. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  46. package/dist/lib/styles/flex-layout-classes.js +3 -3
  47. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  48. package/dist/lib/styles/form-builder-card.styles.js +3 -3
  49. package/dist/lib/styles/input-styles.d.ts +2 -2
  50. package/dist/lib/styles/input-styles.js +5 -5
  51. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  52. package/dist/lib/styles/page-layout-styles.js +3 -3
  53. package/dist/lib/styles/shared-styles.d.ts +2 -2
  54. package/dist/lib/styles/shared-styles.js +3 -3
  55. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  56. package/dist/lib/types/form-builder.types.d.ts +53 -53
  57. package/dist/lib/types/global.types.d.ts +4 -4
  58. package/dist/lib/utils/dialog.d.ts +10 -10
  59. package/dist/lib/utils/dialog.js +21 -21
  60. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  61. package/dist/lib/utils/fire-custom-event.js +7 -7
  62. package/dist/lib/utils/validations.helper.d.ts +26 -26
  63. package/dist/lib/utils/validations.helper.js +35 -35
  64. package/package.json +1 -1
@@ -1,30 +1,30 @@
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 { css, customElement, html, LitElement, property } from 'lit-element';
8
- import '@polymer/iron-icons/iron-icons';
9
- import { CardStyles } from '../styles/card-styles';
10
- import { elevationStyles } from '../styles/elevation-styles';
11
- import { FlexLayoutClasses } from '../styles/flex-layout-classes';
12
- import { fireEvent } from '../utils/fire-custom-event';
13
- let EtoolsFbCard = class EtoolsFbCard extends LitElement {
14
- constructor() {
15
- super(...arguments);
16
- this.isEditable = false;
17
- this.isCollapsible = false;
18
- this.hideEditButton = false;
19
- this.collapsed = false;
20
- this.edit = false;
21
- }
22
- static get styles() {
23
- // language=CSS
24
- return [
25
- elevationStyles,
26
- CardStyles,
27
- FlexLayoutClasses,
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 { css, customElement, html, LitElement, property } from 'lit-element';
8
+ import '@polymer/iron-icons/iron-icons';
9
+ import { CardStyles } from '../styles/card-styles';
10
+ import { elevationStyles } from '../styles/elevation-styles';
11
+ import { FlexLayoutClasses } from '../styles/flex-layout-classes';
12
+ import { fireEvent } from '../utils/fire-custom-event';
13
+ let EtoolsFbCard = class EtoolsFbCard extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.isEditable = false;
17
+ this.isCollapsible = false;
18
+ this.hideEditButton = false;
19
+ this.collapsed = false;
20
+ this.edit = false;
21
+ }
22
+ static get styles() {
23
+ // language=CSS
24
+ return [
25
+ elevationStyles,
26
+ CardStyles,
27
+ FlexLayoutClasses,
28
28
  css `
29
29
  :host {
30
30
  display: block;
@@ -116,43 +116,44 @@ let EtoolsFbCard = class EtoolsFbCard extends LitElement {
116
116
  flex-basis: 20%;
117
117
  }
118
118
  }
119
- `
120
- ];
121
- }
122
- save() {
123
- fireEvent(this, 'save');
124
- }
125
- cancel() {
126
- this.edit = false;
127
- fireEvent(this, 'cancel');
128
- }
129
- startEdit() {
130
- if (this.edit) {
131
- return;
132
- }
133
- this.edit = true;
134
- fireEvent(this, 'start-edit');
135
- }
136
- toggleCollapse() {
137
- this.collapsed = !this.collapsed;
138
- }
139
- // language=HTML
140
- render() {
119
+ `
120
+ ];
121
+ }
122
+ save() {
123
+ fireEvent(this, 'save');
124
+ }
125
+ cancel() {
126
+ this.edit = false;
127
+ fireEvent(this, 'cancel');
128
+ }
129
+ startEdit() {
130
+ if (this.edit) {
131
+ return;
132
+ }
133
+ this.edit = true;
134
+ fireEvent(this, 'start-edit');
135
+ }
136
+ toggleCollapse() {
137
+ this.collapsed = !this.collapsed;
138
+ }
139
+ // language=HTML
140
+ render() {
141
141
  return html `
142
142
  <div class="elevation card-container" elevation="1">
143
143
  <header class="card-title-box with-bottom-line flex-header" ?is-collapsible="${this.isCollapsible}">
144
- ${this.isCollapsible
144
+ ${this.isCollapsible
145
145
  ? html `
146
146
  <paper-icon-button
147
147
  class="flex-header__collapse"
148
148
  @tap="${() => this.toggleCollapse()}"
149
149
  icon="${this.collapsed ? 'expand-more' : 'expand-less'}"
150
150
  ></paper-icon-button>
151
- `
151
+ `
152
152
  : ''}
153
153
  <div class="flex-header__title">${this.cardTitle}</div>
154
+ <div class="flex-header__actions"><slot name="actions"></slot></div>
154
155
  <div class="layout horizontal center flex-header__edit">
155
- ${this.isEditable
156
+ ${this.isEditable
156
157
  ? html `
157
158
  <paper-icon-button
158
159
  icon="create"
@@ -161,48 +162,47 @@ let EtoolsFbCard = class EtoolsFbCard extends LitElement {
161
162
  class="edit-button"
162
163
  @tap="${() => this.startEdit()}"
163
164
  ></paper-icon-button>
164
- `
165
+ `
165
166
  : ''}
166
167
  </div>
167
- <div class="flex-header__actions"><slot name="actions"></slot></div>
168
168
  </header>
169
169
  <iron-collapse ?opened="${!this.collapsed}">
170
170
  <section class="card-content-block">
171
171
  <slot name="content"></slot>
172
172
 
173
- ${this.isEditable && this.edit
173
+ ${this.isEditable && this.edit
174
174
  ? html `
175
175
  <div class="layout horizontal end-justified card-buttons">
176
176
  <paper-button @tap="${() => this.cancel()}">Cancel</paper-button>
177
177
  <paper-button class="save-button" @tap="${() => this.save()}">Save</paper-button>
178
178
  </div>
179
- `
179
+ `
180
180
  : ''}
181
181
  </section>
182
182
  </iron-collapse>
183
183
  </div>
184
- `;
185
- }
186
- };
187
- __decorate([
188
- property({ attribute: 'card-title' })
189
- ], EtoolsFbCard.prototype, "cardTitle", void 0);
190
- __decorate([
191
- property({ type: Boolean, attribute: 'is-editable' })
192
- ], EtoolsFbCard.prototype, "isEditable", void 0);
193
- __decorate([
194
- property({ type: Boolean, attribute: 'is-collapsible' })
195
- ], EtoolsFbCard.prototype, "isCollapsible", void 0);
196
- __decorate([
197
- property({ type: Boolean, attribute: 'hide-edit-button' })
198
- ], EtoolsFbCard.prototype, "hideEditButton", void 0);
199
- __decorate([
200
- property({ type: Boolean })
201
- ], EtoolsFbCard.prototype, "collapsed", void 0);
202
- __decorate([
203
- property({ type: Boolean })
204
- ], EtoolsFbCard.prototype, "edit", void 0);
205
- EtoolsFbCard = __decorate([
206
- customElement('etools-fb-card')
207
- ], EtoolsFbCard);
208
- export { EtoolsFbCard };
184
+ `;
185
+ }
186
+ };
187
+ __decorate([
188
+ property({ attribute: 'card-title' })
189
+ ], EtoolsFbCard.prototype, "cardTitle", void 0);
190
+ __decorate([
191
+ property({ type: Boolean, attribute: 'is-editable' })
192
+ ], EtoolsFbCard.prototype, "isEditable", void 0);
193
+ __decorate([
194
+ property({ type: Boolean, attribute: 'is-collapsible' })
195
+ ], EtoolsFbCard.prototype, "isCollapsible", void 0);
196
+ __decorate([
197
+ property({ type: Boolean, attribute: 'hide-edit-button' })
198
+ ], EtoolsFbCard.prototype, "hideEditButton", void 0);
199
+ __decorate([
200
+ property({ type: Boolean })
201
+ ], EtoolsFbCard.prototype, "collapsed", void 0);
202
+ __decorate([
203
+ property({ type: Boolean })
204
+ ], EtoolsFbCard.prototype, "edit", void 0);
205
+ EtoolsFbCard = __decorate([
206
+ customElement('etools-fb-card')
207
+ ], EtoolsFbCard);
208
+ export { EtoolsFbCard };
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const AttachmentsStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const AttachmentsStyles: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const AttachmentsStyles = css `
4
4
  .file-selector-container {
5
5
  display: flex;
@@ -66,4 +66,4 @@ export const AttachmentsStyles = css `
66
66
  padding: 12px 9px;
67
67
  box-sizing: border-box;
68
68
  }
69
- `;
69
+ `;
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const CardStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const CardStyles: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const CardStyles = css `
4
4
  .card-title-box {
5
5
  position: relative;
@@ -151,4 +151,4 @@ export const CardStyles = css `
151
151
  text-decoration: none;
152
152
  color: var(--primary-color);
153
153
  }
154
- `;
154
+ `;
@@ -1,2 +1,2 @@
1
- import { TemplateResult } from 'lit-element';
2
- export declare const DialogStyles: TemplateResult;
1
+ import { TemplateResult } from 'lit-element';
2
+ export declare const DialogStyles: TemplateResult;
@@ -1,5 +1,5 @@
1
- import { html } from 'lit-element';
2
- // language=HTML
1
+ import { html } from 'lit-element';
2
+ // language=HTML
3
3
  export const DialogStyles = html `
4
4
  <style>
5
5
  #form-attachments-dialog etools-dialog etools-loading {
@@ -82,4 +82,4 @@ export const DialogStyles = html `
82
82
  }
83
83
  }
84
84
  </style>
85
- `;
85
+ `;
@@ -1,9 +1,9 @@
1
- import { CSSResult } from 'lit-element';
2
- /**
3
- * LitElement css version for used paper-material-styles
4
- * TODO:
5
- * - use only in new litElements
6
- * - add more elevations if needed
7
- * - replace all paper-material-styles with this css module
8
- */
9
- export declare const elevationStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ /**
3
+ * LitElement css version for used paper-material-styles
4
+ * TODO:
5
+ * - use only in new litElements
6
+ * - add more elevations if needed
7
+ * - replace all paper-material-styles with this css module
8
+ */
9
+ export declare const elevationStyles: CSSResult;
@@ -1,12 +1,12 @@
1
- import { css } from 'lit-element';
2
- /**
3
- * LitElement css version for used paper-material-styles
4
- * TODO:
5
- * - use only in new litElements
6
- * - add more elevations if needed
7
- * - replace all paper-material-styles with this css module
8
- */
9
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ /**
3
+ * LitElement css version for used paper-material-styles
4
+ * TODO:
5
+ * - use only in new litElements
6
+ * - add more elevations if needed
7
+ * - replace all paper-material-styles with this css module
8
+ */
9
+ // language=CSS
10
10
  export const elevationStyles = css `
11
11
  .elevation,
12
12
  :host(.elevation) {
@@ -40,4 +40,4 @@ export const elevationStyles = css `
40
40
  box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12),
41
41
  0 8px 10px -5px rgba(0, 0, 0, 0.4);
42
42
  }
43
- `;
43
+ `;
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const FlexLayoutClasses: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const FlexLayoutClasses: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const FlexLayoutClasses = css `
4
4
  .layout.horizontal,
5
5
  .layout.vertical {
@@ -316,4 +316,4 @@ export const FlexLayoutClasses = css `
316
316
  bottom: 0;
317
317
  left: 0;
318
318
  }
319
- `;
319
+ `;
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const FormBuilderCardStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const FormBuilderCardStyles: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const FormBuilderCardStyles = css `
4
4
  .overall-finding {
5
5
  padding: 15px 25px 20px 45px;
@@ -41,4 +41,4 @@ export const FormBuilderCardStyles = css `
41
41
  padding: 5px;
42
42
  }
43
43
  }
44
- `;
44
+ `;
@@ -1,2 +1,2 @@
1
- import { TemplateResult } from 'lit-element';
2
- export declare const InputStyles: TemplateResult;
1
+ import { TemplateResult } from 'lit-element';
2
+ export declare const InputStyles: TemplateResult;
@@ -1,5 +1,5 @@
1
- import { html } from 'lit-element';
2
- // language=HTML
1
+ import { html } from 'lit-element';
2
+ // language=HTML
3
3
  export const InputStyles = html `
4
4
  <style>
5
5
  etools-dropdown.form-control,
@@ -93,8 +93,8 @@ export const InputStyles = html `
93
93
  opacity: 1 !important;
94
94
  }
95
95
  --paper-input-container-underline: {
96
- border-bottom: 1px solid rgba(0, 0, 0, 0.2) !important;
97
- display: block !important;
96
+ border-bottom: none !important;
97
+ display: none !important;
98
98
  }
99
99
  --paper-input-container-underline-focus: {
100
100
  display: none;
@@ -157,4 +157,4 @@ export const InputStyles = html `
157
157
  }
158
158
  }
159
159
  </style>
160
- `;
160
+ `;
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const pageLayoutStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const pageLayoutStyles: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const pageLayoutStyles = css `
4
4
  .page-content {
5
5
  margin: 24px;
@@ -198,4 +198,4 @@ export const pageLayoutStyles = css `
198
198
  margin: 8px;
199
199
  }
200
200
  }
201
- `;
201
+ `;
@@ -1,2 +1,2 @@
1
- import { CSSResult } from 'lit-element';
2
- export declare const SharedStyles: CSSResult;
1
+ import { CSSResult } from 'lit-element';
2
+ export declare const SharedStyles: CSSResult;
@@ -1,5 +1,5 @@
1
- import { css } from 'lit-element';
2
- // language=CSS
1
+ import { css } from 'lit-element';
2
+ // language=CSS
3
3
  export const SharedStyles = css `
4
4
  :host {
5
5
  display: block;
@@ -67,4 +67,4 @@ export const SharedStyles = css `
67
67
  .filters-section {
68
68
  padding: 0 30px;
69
69
  }
70
- `;
70
+ `;
@@ -1,83 +1,83 @@
1
- import { TemplateResult } from 'lit-element';
2
- import { BlueprintField, BlueprintGroup, BlueprintMetadata } from './form-builder.types';
3
- import { GenericObject } from './global.types';
4
- /** Component for rendering BlueprintGroup with group.extra.type.includes('abstract') or group.name === 'root' */
5
- export interface IFormBuilderAbstractGroup {
6
- groupStructure: BlueprintGroup;
7
- metadata: BlueprintMetadata;
8
- parentGroupName: string;
9
- readonly: boolean;
10
- value: GenericObject;
11
- /**
12
- * Updates groupValue object by this.value[fieldName] = event.details.value
13
- * @param event - comes from event emitted by rendered BlueprintField or BlueprintGroup child of current Group
14
- * @param fieldName - name field of BlueprintField or BlueprintGroup child of current Group
15
- *
16
- * stopsPropagation of current value-changed event it will be replaced with new event
17
- * Emits value-changed event with updated groupValue
18
- */
19
- valueChanged(event: CustomEvent, fieldName: string): void;
20
- /**
21
- * Returns template for BlueprintField structure depending on their styling
22
- *
23
- * without styling (empty array) - standard appearance (label and helper text in left column field element in right)
24
- * styling.includes('wide') - field takes all parent width
25
- * styling.includes('additional') - gray background
26
- *
27
- * Pass value to field as this.value[BlueprintField.name]
28
- * Rendered field must emit value-changed event
29
- * Use it to update current group value:
30
- * @value-changed="${(event) => this.valueChanged(event, BlueprintField.name)}"
31
- */
32
- renderField(fieldStructure: BlueprintField): TemplateResult;
33
- /**
34
- * Returns template for BlueprintGroup structure depending on their styling
35
- *
36
- * styling.includes('card') && styling.includes('collapse') - render as IFormBuilderCollapsedCard
37
- * styling.includes('card') - render as IFormBuilderCard
38
- * styling.includes('abstract') - render as IFormBuilderAbstractGroup recursively
39
- *
40
- * Pass groupValue to group as this.value[BlueprintGroup.name]
41
- * Rendered group must emit value-changed event
42
- * Use it to update current group value:
43
- * @value-changed="${(event) => this.valueChanged(event, BlueprintGroup.name)}"
44
- */
45
- renderGroup(groupStructure: BlueprintGroup, groupValue?: GenericObject): TemplateResult;
46
- }
47
- export interface IFormBuilderCard extends IFormBuilderAbstractGroup {
48
- /**
49
- * Overrides parent method.
50
- * It must doing the same but not sending new event, only stop current.
51
- * value-changed will be send latter
52
- */
53
- valueChanged(event: CustomEvent, fieldName: string): void;
54
- /**
55
- * Show toastr if card has errors, returns;
56
- * Emits value-changed event for updating changed value
57
- */
58
- saveChanges(): void;
59
- }
60
- /**
61
- * Component for rendering BlueprintGroup as DataCollectionCard.
62
- * Computes Card title using parentGroupName mapping + currentGroup.name
63
- * Allows to render attachment group and handles their logic
64
- */
65
- export interface IFormBuilderCollapsedCard extends IFormBuilderAbstractGroup, IFormBuilderCard {
66
- /**
67
- * Extend renderGroup() method. It must handle additional type:
68
- *
69
- * styling.includes('floating_attachments') - render group as attachment button
70
- *
71
- * ---
72
- * if (styling.includes('floating_attachments')) { ...render attachment button... }
73
- * else { super.renderGroup(groupStructure); }
74
- *
75
- */
76
- renderGroup(groupStructure: BlueprintGroup, groupValue?: GenericObject): TemplateResult;
77
- /**
78
- * Use openDialog method. Call valueChanged() on popup resolve with confirmed === true
79
- */
80
- openAttachmentsPopup(): void;
81
- cancelEdit(): void;
82
- startEdit(): void;
83
- }
1
+ import { TemplateResult } from 'lit-element';
2
+ import { BlueprintField, BlueprintGroup, BlueprintMetadata } from './form-builder.types';
3
+ import { GenericObject } from './global.types';
4
+ /** Component for rendering BlueprintGroup with group.extra.type.includes('abstract') or group.name === 'root' */
5
+ export interface IFormBuilderAbstractGroup {
6
+ groupStructure: BlueprintGroup;
7
+ metadata: BlueprintMetadata;
8
+ parentGroupName: string;
9
+ readonly: boolean;
10
+ value: GenericObject;
11
+ /**
12
+ * Updates groupValue object by this.value[fieldName] = event.details.value
13
+ * @param event - comes from event emitted by rendered BlueprintField or BlueprintGroup child of current Group
14
+ * @param fieldName - name field of BlueprintField or BlueprintGroup child of current Group
15
+ *
16
+ * stopsPropagation of current value-changed event it will be replaced with new event
17
+ * Emits value-changed event with updated groupValue
18
+ */
19
+ valueChanged(event: CustomEvent, fieldName: string): void;
20
+ /**
21
+ * Returns template for BlueprintField structure depending on their styling
22
+ *
23
+ * without styling (empty array) - standard appearance (label and helper text in left column field element in right)
24
+ * styling.includes('wide') - field takes all parent width
25
+ * styling.includes('additional') - gray background
26
+ *
27
+ * Pass value to field as this.value[BlueprintField.name]
28
+ * Rendered field must emit value-changed event
29
+ * Use it to update current group value:
30
+ * @value-changed="${(event) => this.valueChanged(event, BlueprintField.name)}"
31
+ */
32
+ renderField(fieldStructure: BlueprintField): TemplateResult;
33
+ /**
34
+ * Returns template for BlueprintGroup structure depending on their styling
35
+ *
36
+ * styling.includes('card') && styling.includes('collapse') - render as IFormBuilderCollapsedCard
37
+ * styling.includes('card') - render as IFormBuilderCard
38
+ * styling.includes('abstract') - render as IFormBuilderAbstractGroup recursively
39
+ *
40
+ * Pass groupValue to group as this.value[BlueprintGroup.name]
41
+ * Rendered group must emit value-changed event
42
+ * Use it to update current group value:
43
+ * @value-changed="${(event) => this.valueChanged(event, BlueprintGroup.name)}"
44
+ */
45
+ renderGroup(groupStructure: BlueprintGroup, groupValue?: GenericObject): TemplateResult;
46
+ }
47
+ export interface IFormBuilderCard extends IFormBuilderAbstractGroup {
48
+ /**
49
+ * Overrides parent method.
50
+ * It must doing the same but not sending new event, only stop current.
51
+ * value-changed will be send latter
52
+ */
53
+ valueChanged(event: CustomEvent, fieldName: string): void;
54
+ /**
55
+ * Show toastr if card has errors, returns;
56
+ * Emits value-changed event for updating changed value
57
+ */
58
+ saveChanges(): void;
59
+ }
60
+ /**
61
+ * Component for rendering BlueprintGroup as DataCollectionCard.
62
+ * Computes Card title using parentGroupName mapping + currentGroup.name
63
+ * Allows to render attachment group and handles their logic
64
+ */
65
+ export interface IFormBuilderCollapsedCard extends IFormBuilderAbstractGroup, IFormBuilderCard {
66
+ /**
67
+ * Extend renderGroup() method. It must handle additional type:
68
+ *
69
+ * styling.includes('floating_attachments') - render group as attachment button
70
+ *
71
+ * ---
72
+ * if (styling.includes('floating_attachments')) { ...render attachment button... }
73
+ * else { super.renderGroup(groupStructure); }
74
+ *
75
+ */
76
+ renderGroup(groupStructure: BlueprintGroup, groupValue?: GenericObject): TemplateResult;
77
+ /**
78
+ * Use openDialog method. Call valueChanged() on popup resolve with confirmed === true
79
+ */
80
+ openAttachmentsPopup(): void;
81
+ cancelEdit(): void;
82
+ startEdit(): void;
83
+ }