@unicef-polymer/etools-form-builder 2.1.4 → 2.1.6

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 (82) hide show
  1. package/dist/assets/translations.d.ts +6 -6
  2. package/dist/assets/translations.js +67 -67
  3. package/dist/form-attachments-popup/form-attachments-popup.d.ts +86 -86
  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 +207 -207
  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 +11 -11
  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 +33 -33
  12. package/dist/form-fields/abstract-field-base.class.js +117 -98
  13. package/dist/form-fields/field-renderer-component.d.ts +20 -20
  14. package/dist/form-fields/field-renderer-component.js +114 -108
  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 +100 -100
  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 +102 -102
  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 +47 -47
  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 +49 -49
  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 +30 -30
  27. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
  28. package/dist/form-fields/single-fields/attachment-field.js +85 -85
  29. package/dist/form-fields/single-fields/base-field.d.ts +11 -11
  30. package/dist/form-fields/single-fields/base-field.js +58 -58
  31. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
  32. package/dist/form-fields/single-fields/boolean-field.js +29 -29
  33. package/dist/form-fields/single-fields/number-field.d.ts +10 -10
  34. package/dist/form-fields/single-fields/number-field.js +46 -46
  35. package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
  36. package/dist/form-fields/single-fields/scale-field.js +52 -52
  37. package/dist/form-fields/single-fields/text-field.d.ts +8 -8
  38. package/dist/form-fields/single-fields/text-field.js +29 -29
  39. package/dist/form-groups/form-abstract-group.d.ts +65 -65
  40. package/dist/form-groups/form-abstract-group.js +255 -255
  41. package/dist/form-groups/form-card.d.ts +32 -32
  42. package/dist/form-groups/form-card.js +89 -89
  43. package/dist/form-groups/form-collapsed-card.d.ts +70 -70
  44. package/dist/form-groups/form-collapsed-card.js +225 -225
  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 +18 -18
  50. package/dist/lib/additional-components/confirmation-dialog.js +52 -52
  51. package/dist/lib/additional-components/etools-fb-card.d.ts +21 -21
  52. package/dist/lib/additional-components/etools-fb-card.js +99 -99
  53. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  54. package/dist/lib/styles/attachments.styles.js +3 -3
  55. package/dist/lib/styles/card-styles.d.ts +2 -2
  56. package/dist/lib/styles/card-styles.js +3 -3
  57. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  58. package/dist/lib/styles/dialog.styles.js +3 -3
  59. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  60. package/dist/lib/styles/elevation-styles.js +10 -10
  61. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  62. package/dist/lib/styles/flex-layout-classes.js +3 -3
  63. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  64. package/dist/lib/styles/form-builder-card.styles.js +3 -3
  65. package/dist/lib/styles/input-styles.d.ts +2 -2
  66. package/dist/lib/styles/input-styles.js +3 -3
  67. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  68. package/dist/lib/styles/page-layout-styles.js +3 -3
  69. package/dist/lib/styles/shared-styles.d.ts +2 -2
  70. package/dist/lib/styles/shared-styles.js +3 -3
  71. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  72. package/dist/lib/types/form-builder.types.d.ts +59 -59
  73. package/dist/lib/types/global.types.d.ts +4 -4
  74. package/dist/lib/utils/dialog.d.ts +10 -10
  75. package/dist/lib/utils/dialog.js +21 -21
  76. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  77. package/dist/lib/utils/fire-custom-event.js +7 -7
  78. package/dist/lib/utils/translate.d.ts +1 -1
  79. package/dist/lib/utils/translate.js +9 -9
  80. package/dist/lib/utils/validations.helper.d.ts +26 -26
  81. package/dist/lib/utils/validations.helper.js +42 -42
  82. package/package.json +4 -4
@@ -1,45 +1,45 @@
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 { html, property, customElement } from 'lit-element';
8
- import { fireEvent } from '../lib/utils/fire-custom-event';
9
- import { clone, equals } from 'ramda';
10
- import { FormAbstractGroup } from './form-abstract-group';
11
- import '@polymer/iron-collapse';
12
- import { openDialog } from '../lib/utils/dialog';
13
- import { getTranslation } from '../lib/utils/translate';
14
- let FormCard = class FormCard extends FormAbstractGroup {
15
- constructor() {
16
- super(...arguments);
17
- this._value = {};
18
- /**
19
- * Show save button only if value was changed by user
20
- */
21
- this.showSaveButton = false;
22
- this.originalValue = {};
23
- }
24
- /**
25
- * Overrides value property. Saves originalValue.
26
- * We need to update inner _value only if it wasn't change
27
- * @param value
28
- */
29
- set value(value) {
30
- if (!this.showSaveButton) {
31
- this._value = clone(value);
32
- }
33
- this.originalValue = value;
34
- }
35
- get value() {
36
- return this._value;
37
- }
38
- /**
39
- * Extends parent render method,
40
- * adds card-container html wrapper and dynamic save button
41
- */
42
- render() {
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 { html, property, customElement } from 'lit-element';
8
+ import { fireEvent } from '../lib/utils/fire-custom-event';
9
+ import { clone, equals } from 'ramda';
10
+ import { FormAbstractGroup } from './form-abstract-group';
11
+ import '@polymer/iron-collapse';
12
+ import { openDialog } from '../lib/utils/dialog';
13
+ import { getTranslation } from '../lib/utils/translate';
14
+ let FormCard = class FormCard extends FormAbstractGroup {
15
+ constructor() {
16
+ super(...arguments);
17
+ this._value = {};
18
+ /**
19
+ * Show save button only if value was changed by user
20
+ */
21
+ this.showSaveButton = false;
22
+ this.originalValue = {};
23
+ }
24
+ /**
25
+ * Overrides value property. Saves originalValue.
26
+ * We need to update inner _value only if it wasn't change
27
+ * @param value
28
+ */
29
+ set value(value) {
30
+ if (!this.showSaveButton) {
31
+ this._value = clone(value);
32
+ }
33
+ this.originalValue = value;
34
+ }
35
+ get value() {
36
+ return this._value;
37
+ }
38
+ /**
39
+ * Extends parent render method,
40
+ * adds card-container html wrapper and dynamic save button
41
+ */
42
+ render() {
43
43
  return html `
44
44
  <section class="elevation page-content card-container form-card" elevation="1">
45
45
  <div class="card-header">
@@ -50,8 +50,8 @@ let FormCard = class FormCard extends FormAbstractGroup {
50
50
  @click="${() => this.confirmRemove(this.groupStructure.title || getTranslation(this.language, 'THIS_GROUP'))}"
51
51
  >
52
52
  Remove
53
- ${!this.groupStructure.title || this.groupStructure.title.length > 15
54
- ? getTranslation(this.language, 'GROUP')
53
+ ${!this.groupStructure.title || this.groupStructure.title.length > 15
54
+ ? getTranslation(this.language, 'GROUP')
55
55
  : this.groupStructure.title}
56
56
  <paper-icon-button icon="delete" class="attachments-warning"></paper-icon-button>
57
57
  </div>
@@ -66,48 +66,48 @@ let FormCard = class FormCard extends FormAbstractGroup {
66
66
  </div>
67
67
  </iron-collapse>
68
68
  </section>
69
- `;
70
- }
71
- /**
72
- * Updates value property, stops event propagation.
73
- * We need to fire value-changed event only after save button click
74
- */
75
- valueChanged(event, name) {
76
- if (!this._value) {
77
- this._value = {};
78
- }
79
- this._value[name] = event.detail.value;
80
- event.stopPropagation();
81
- this.showSaveButton = !equals(this.value, this.originalValue);
82
- }
83
- saveChanges() {
84
- if (Object.keys(this._errors).length) {
85
- fireEvent(this, 'toast', { text: getTranslation(this.language, 'CHECK_FIELDS_TRY_AGAIN') });
86
- return;
87
- }
88
- fireEvent(this, 'value-changed', { value: this.value });
89
- this.showSaveButton = false;
90
- }
91
- confirmRemove(groupName) {
92
- openDialog({
93
- dialog: 'confirmation-popup',
94
- dialogData: {
95
- text: `${getTranslation(this.language, 'CONFIRM_DELETE')} ${groupName}`
96
- }
97
- }).then((response) => {
98
- if (response.confirmed) {
99
- fireEvent(this, 'remove-group');
100
- }
101
- });
102
- }
103
- };
104
- __decorate([
105
- property()
106
- ], FormCard.prototype, "_value", void 0);
107
- __decorate([
108
- property()
109
- ], FormCard.prototype, "showSaveButton", void 0);
110
- FormCard = __decorate([
111
- customElement('form-card')
112
- ], FormCard);
113
- export { FormCard };
69
+ `;
70
+ }
71
+ /**
72
+ * Updates value property, stops event propagation.
73
+ * We need to fire value-changed event only after save button click
74
+ */
75
+ valueChanged(event, name) {
76
+ if (!this._value) {
77
+ this._value = {};
78
+ }
79
+ this._value[name] = event.detail.value;
80
+ event.stopPropagation();
81
+ this.showSaveButton = !equals(this.value, this.originalValue);
82
+ }
83
+ saveChanges() {
84
+ if (Object.keys(this._errors).length) {
85
+ fireEvent(this, 'toast', { text: getTranslation(this.language, 'CHECK_FIELDS_TRY_AGAIN') });
86
+ return;
87
+ }
88
+ fireEvent(this, 'value-changed', { value: this.value });
89
+ this.showSaveButton = false;
90
+ }
91
+ confirmRemove(groupName) {
92
+ openDialog({
93
+ dialog: 'confirmation-popup',
94
+ dialogData: {
95
+ text: `${getTranslation(this.language, 'CONFIRM_DELETE')} ${groupName}`
96
+ }
97
+ }).then((response) => {
98
+ if (response.confirmed) {
99
+ fireEvent(this, 'remove-group');
100
+ }
101
+ });
102
+ }
103
+ };
104
+ __decorate([
105
+ property()
106
+ ], FormCard.prototype, "_value", void 0);
107
+ __decorate([
108
+ property()
109
+ ], FormCard.prototype, "showSaveButton", void 0);
110
+ FormCard = __decorate([
111
+ customElement('form-card')
112
+ ], FormCard);
113
+ export { FormCard };
@@ -1,70 +1,70 @@
1
- import { TemplateResult } from 'lit-element';
2
- import { IFormBuilderCard, IFormBuilderCollapsedCard } from '../lib/types/form-builder.interfaces';
3
- import { FormAbstractGroup } from './form-abstract-group';
4
- import '../lib/additional-components/etools-fb-card';
5
- import { GenericObject } from '../lib/types/global.types';
6
- import '../lib/additional-components/confirmation-dialog';
7
- export declare class FormCollapsedCard extends FormAbstractGroup implements IFormBuilderCollapsedCard, IFormBuilderCard {
8
- /**
9
- * Overrides readonly property
10
- * In collapsed card it must consider isEditMode property,
11
- * components inside card are readonly if isEditMode is off or if card is readonly
12
- */
13
- set readonly(state: boolean);
14
- get readonly(): boolean;
15
- protected isEditMode: boolean;
16
- protected _readonly: boolean;
17
- /**
18
- * Overrides errors setter
19
- * In collapsed card it must consider isEditMode property,
20
- * We must to enable isEditMode if errors comes from backend
21
- */
22
- set errors(errors: GenericObject | string[] | null);
23
- /**
24
- * Overrides value property
25
- * We need to save originalValue to have Cancel possibility in collapsed card.
26
- * Don't override current edited value if isEditMode enabled
27
- * (It can be happened if other sibling card or component updates their value during current card edition)
28
- */
29
- set value(value: GenericObject);
30
- get value(): GenericObject;
31
- protected _value: GenericObject;
32
- protected originalValue: GenericObject;
33
- /**
34
- * Extends parent render method for handling additional types (StructureTypes.ATTACHMENTS_BUTTON in our case)
35
- * and adds etools-card as container wrapper
36
- */
37
- render(): TemplateResult;
38
- /**
39
- * Filters StructureTypes.ATTACHMENTS_BUTTON type. It will be rendered as button,
40
- * allows parent renderChild method to render other types
41
- */
42
- renderGroupChildren(): (TemplateResult | TemplateResult[])[];
43
- /**
44
- * Generate open Attachments popup button.
45
- * It is hidden if tab is readonly and no attachments uploaded
46
- */
47
- getAdditionalButtons(): TemplateResult;
48
- retrieveTitle(target: string): string;
49
- startEdit(): void;
50
- /**
51
- * We need to rerender view to update all changes that was happen,
52
- * because only fields are updating during @value-change event.
53
- * Only then we can reset all changed values to their original
54
- */
55
- cancelEdit(): void;
56
- /**
57
- * Updates value property, stops event propagation.
58
- * We need to fire value-changed event only after save button click
59
- */
60
- valueChanged(event: CustomEvent, name: string): void;
61
- saveChanges(): void;
62
- /**
63
- * Tries to save changed attachments on popup confirm
64
- * Generates value-changed event with originalValue clone if isEditMode enabled.
65
- * In this case it will take only attachments changes and ignore other changes that may happen during card edit
66
- */
67
- openAttachmentsPopup(): void;
68
- confirmRemove(groupName: string): void;
69
- protected getAttachmentsBtnText(attachmentsCount?: number): string;
70
- }
1
+ import { TemplateResult } from 'lit-element';
2
+ import { IFormBuilderCard, IFormBuilderCollapsedCard } from '../lib/types/form-builder.interfaces';
3
+ import { FormAbstractGroup } from './form-abstract-group';
4
+ import '../lib/additional-components/etools-fb-card';
5
+ import { GenericObject } from '../lib/types/global.types';
6
+ import '../lib/additional-components/confirmation-dialog';
7
+ export declare class FormCollapsedCard extends FormAbstractGroup implements IFormBuilderCollapsedCard, IFormBuilderCard {
8
+ /**
9
+ * Overrides readonly property
10
+ * In collapsed card it must consider isEditMode property,
11
+ * components inside card are readonly if isEditMode is off or if card is readonly
12
+ */
13
+ set readonly(state: boolean);
14
+ get readonly(): boolean;
15
+ protected isEditMode: boolean;
16
+ protected _readonly: boolean;
17
+ /**
18
+ * Overrides errors setter
19
+ * In collapsed card it must consider isEditMode property,
20
+ * We must to enable isEditMode if errors comes from backend
21
+ */
22
+ set errors(errors: GenericObject | string[] | null);
23
+ /**
24
+ * Overrides value property
25
+ * We need to save originalValue to have Cancel possibility in collapsed card.
26
+ * Don't override current edited value if isEditMode enabled
27
+ * (It can be happened if other sibling card or component updates their value during current card edition)
28
+ */
29
+ set value(value: GenericObject);
30
+ get value(): GenericObject;
31
+ protected _value: GenericObject;
32
+ protected originalValue: GenericObject;
33
+ /**
34
+ * Extends parent render method for handling additional types (StructureTypes.ATTACHMENTS_BUTTON in our case)
35
+ * and adds etools-card as container wrapper
36
+ */
37
+ render(): TemplateResult;
38
+ /**
39
+ * Filters StructureTypes.ATTACHMENTS_BUTTON type. It will be rendered as button,
40
+ * allows parent renderChild method to render other types
41
+ */
42
+ renderGroupChildren(): (TemplateResult | TemplateResult[])[];
43
+ /**
44
+ * Generate open Attachments popup button.
45
+ * It is hidden if tab is readonly and no attachments uploaded
46
+ */
47
+ getAdditionalButtons(): TemplateResult;
48
+ retrieveTitle(target: string): string;
49
+ startEdit(): void;
50
+ /**
51
+ * We need to rerender view to update all changes that was happen,
52
+ * because only fields are updating during @value-change event.
53
+ * Only then we can reset all changed values to their original
54
+ */
55
+ cancelEdit(): void;
56
+ /**
57
+ * Updates value property, stops event propagation.
58
+ * We need to fire value-changed event only after save button click
59
+ */
60
+ valueChanged(event: CustomEvent, name: string): void;
61
+ saveChanges(): void;
62
+ /**
63
+ * Tries to save changed attachments on popup confirm
64
+ * Generates value-changed event with originalValue clone if isEditMode enabled.
65
+ * In this case it will take only attachments changes and ignore other changes that may happen during card edit
66
+ */
67
+ openAttachmentsPopup(): void;
68
+ confirmRemove(groupName: string): void;
69
+ protected getAttachmentsBtnText(attachmentsCount?: number): string;
70
+ }