@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.
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +10 -2
- package/dist/form-attachments-popup/form-attachments-popup.js +53 -48
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -5
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +79 -85
- package/dist/form-fields/abstract-field-base.class.d.ts +28 -0
- package/dist/form-fields/{base-field.js → abstract-field-base.class.js} +133 -112
- package/dist/form-fields/custom-elements.define.js +17 -5
- package/dist/form-fields/field-renderer-component.d.ts +20 -0
- package/dist/form-fields/field-renderer-component.js +245 -0
- package/dist/form-fields/index.d.ts +9 -5
- package/dist/form-fields/index.js +9 -5
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -0
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +198 -0
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -0
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +123 -0
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -0
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +56 -0
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -0
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +104 -0
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -0
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +43 -0
- package/dist/form-fields/single-fields/attachment-field.d.ts +16 -0
- package/dist/form-fields/single-fields/attachment-field.js +87 -0
- package/dist/form-fields/single-fields/base-field.d.ts +11 -0
- package/dist/form-fields/single-fields/base-field.js +57 -0
- package/dist/form-fields/single-fields/boolean-field.d.ts +8 -0
- package/dist/form-fields/single-fields/boolean-field.js +39 -0
- package/dist/form-fields/{number-field.d.ts → single-fields/number-field.d.ts} +1 -0
- package/dist/form-fields/{number-field.js → single-fields/number-field.js} +34 -21
- package/dist/form-fields/{scale-field.d.ts → single-fields/scale-field.d.ts} +4 -2
- package/dist/form-fields/{scale-field.js → single-fields/scale-field.js} +66 -54
- package/dist/form-fields/{text-field.d.ts → single-fields/text-field.d.ts} +0 -0
- package/dist/form-fields/{text-field.js → single-fields/text-field.js} +26 -21
- package/dist/form-fields/wide-field.d.ts +1 -1
- package/dist/form-fields/wide-field.js +3 -3
- package/dist/form-groups/form-abstract-group.d.ts +12 -12
- package/dist/form-groups/form-abstract-group.js +189 -166
- package/dist/form-groups/form-card.d.ts +1 -0
- package/dist/form-groups/form-card.js +35 -10
- package/dist/form-groups/form-collapsed-card.d.ts +3 -1
- package/dist/form-groups/form-collapsed-card.js +45 -25
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/lib/additional-components/confirmation-dialog.d.ts +16 -0
- package/dist/lib/additional-components/confirmation-dialog.js +61 -0
- package/dist/lib/additional-components/etools-fb-card.js +135 -128
- package/dist/lib/styles/attachments.styles.js +69 -66
- package/dist/lib/styles/form-builder-card.styles.js +46 -41
- package/dist/lib/styles/input-styles.js +53 -64
- package/dist/lib/styles/page-layout-styles.js +198 -198
- package/dist/lib/types/form-builder.interfaces.d.ts +2 -2
- package/dist/lib/types/form-builder.types.d.ts +8 -2
- package/dist/lib/utils/validations.helper.d.ts +3 -3
- package/dist/lib/utils/validations.helper.js +7 -7
- package/package.json +53 -52
- package/dist/form-fields/base-field.d.ts +0 -20
|
@@ -7,9 +7,11 @@ export declare type FieldOption = {
|
|
|
7
7
|
value: any;
|
|
8
8
|
label: string;
|
|
9
9
|
};
|
|
10
|
-
export declare class ScaleField extends BaseField<string | null> {
|
|
11
|
-
options: FieldOption[];
|
|
10
|
+
export declare class ScaleField extends BaseField<string | number | null> {
|
|
11
|
+
options: (FieldOption | string | number)[];
|
|
12
12
|
protected controlTemplate(): TemplateResult;
|
|
13
|
+
protected getLabel(option: FieldOption | string | number): unknown;
|
|
14
|
+
protected getValue(option: FieldOption | string | number): unknown;
|
|
13
15
|
protected onSelect(item: PaperRadioButtonElement): void;
|
|
14
16
|
protected customValidation(): string | null;
|
|
15
17
|
static get styles(): CSSResultArray;
|
|
@@ -9,34 +9,46 @@ import { BaseField } from './base-field';
|
|
|
9
9
|
import { repeat } from 'lit-html/directives/repeat';
|
|
10
10
|
import '@polymer/paper-radio-group/paper-radio-group';
|
|
11
11
|
import '@polymer/paper-radio-button/paper-radio-button';
|
|
12
|
-
import { InputStyles } from '
|
|
12
|
+
import { InputStyles } from '../../lib/styles/input-styles';
|
|
13
13
|
export class ScaleField extends BaseField {
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.options = [];
|
|
17
17
|
}
|
|
18
18
|
controlTemplate() {
|
|
19
|
-
return html `
|
|
20
|
-
${InputStyles}
|
|
21
|
-
<div class="container">
|
|
22
|
-
<paper-radio-group
|
|
23
|
-
class="radio-group"
|
|
24
|
-
selected="${this.value}"
|
|
25
|
-
@iron-select="${({ detail }) => this.onSelect(detail.item)}"
|
|
26
|
-
>
|
|
27
|
-
${repeat(this.options, (option) => html `
|
|
28
|
-
<paper-radio-button class="radio-button" name="${option
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
return html `
|
|
20
|
+
${InputStyles}
|
|
21
|
+
<div class="container">
|
|
22
|
+
<paper-radio-group
|
|
23
|
+
class="radio-group"
|
|
24
|
+
selected="${this.value}"
|
|
25
|
+
@iron-select="${({ detail }) => this.onSelect(detail.item)}"
|
|
26
|
+
>
|
|
27
|
+
${repeat(this.options, (option) => html `
|
|
28
|
+
<paper-radio-button class="radio-button" name="${this.getValue(option)}">
|
|
29
|
+
${this.getLabel(option)}
|
|
30
|
+
</paper-radio-button>
|
|
31
|
+
`)}
|
|
32
|
+
</paper-radio-group>
|
|
33
|
+
|
|
34
|
+
<paper-button ?hidden="${this.isReadonly}" @click="${() => this.valueChanged(null)}" class="clear-button">
|
|
35
|
+
<iron-icon icon="clear"></iron-icon>Clear
|
|
36
|
+
</paper-button>
|
|
37
|
+
</div>
|
|
38
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
36
39
|
`;
|
|
37
40
|
}
|
|
41
|
+
getLabel(option) {
|
|
42
|
+
return typeof option === 'object' ? option.label : option;
|
|
43
|
+
}
|
|
44
|
+
getValue(option) {
|
|
45
|
+
return typeof option === 'object' ? option.value : option;
|
|
46
|
+
}
|
|
38
47
|
onSelect(item) {
|
|
39
48
|
const newValue = item.get('name');
|
|
49
|
+
if (newValue !== this.value) {
|
|
50
|
+
this.touched = true;
|
|
51
|
+
}
|
|
40
52
|
this.valueChanged(newValue);
|
|
41
53
|
}
|
|
42
54
|
customValidation() {
|
|
@@ -46,42 +58,42 @@ export class ScaleField extends BaseField {
|
|
|
46
58
|
// language=CSS
|
|
47
59
|
return [
|
|
48
60
|
...BaseField.styles,
|
|
49
|
-
css `
|
|
50
|
-
.container {
|
|
51
|
-
position: relative;
|
|
52
|
-
min-height: 48px;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
flex-direction: row;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.radio-group {
|
|
59
|
-
display: flex;
|
|
60
|
-
flex-direction: row;
|
|
61
|
-
flex-wrap: wrap;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
:host([is-readonly]) paper-radio-group {
|
|
65
|
-
pointer-events: none;
|
|
66
|
-
opacity: 0.55;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@media (max-width: 1080px) {
|
|
70
|
-
.container {
|
|
71
|
-
flex-direction: column;
|
|
72
|
-
align-items: flex-start;
|
|
73
|
-
}
|
|
74
|
-
.radio-group {
|
|
75
|
-
flex-direction: column;
|
|
76
|
-
}
|
|
77
|
-
.radio-button {
|
|
78
|
-
padding-left: 3px;
|
|
79
|
-
}
|
|
80
|
-
.clear-button {
|
|
81
|
-
margin: 0;
|
|
82
|
-
padding-left: 0;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
61
|
+
css `
|
|
62
|
+
.container {
|
|
63
|
+
position: relative;
|
|
64
|
+
min-height: 48px;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.radio-group {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: row;
|
|
73
|
+
flex-wrap: wrap;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([is-readonly]) paper-radio-group {
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
opacity: 0.55;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media (max-width: 1080px) {
|
|
82
|
+
.container {
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
align-items: flex-start;
|
|
85
|
+
}
|
|
86
|
+
.radio-group {
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
}
|
|
89
|
+
.radio-button {
|
|
90
|
+
padding-left: 3px;
|
|
91
|
+
}
|
|
92
|
+
.clear-button {
|
|
93
|
+
margin: 0;
|
|
94
|
+
padding-left: 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
85
97
|
`
|
|
86
98
|
];
|
|
87
99
|
}
|
|
File without changes
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { css, html } from 'lit-element';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
3
|
import '@polymer/paper-input/paper-textarea';
|
|
4
|
-
import { InputStyles } from '
|
|
4
|
+
import { InputStyles } from '../../lib/styles/input-styles';
|
|
5
5
|
export class TextField extends BaseField {
|
|
6
6
|
controlTemplate() {
|
|
7
|
-
return html `
|
|
8
|
-
${InputStyles}
|
|
9
|
-
<paper-textarea
|
|
10
|
-
id="textarea"
|
|
11
|
-
class="no-padding-left
|
|
12
|
-
no-label-float
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
return html `
|
|
8
|
+
${InputStyles}
|
|
9
|
+
<paper-textarea
|
|
10
|
+
id="textarea"
|
|
11
|
+
class="no-padding-left"
|
|
12
|
+
no-label-float
|
|
13
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
14
|
+
.value="${this.value}"
|
|
15
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
16
|
+
@focus="${() => (this.touched = true)}"
|
|
17
|
+
placeholder="—"
|
|
18
|
+
?readonly="${this.isReadonly}"
|
|
19
|
+
?invalid="${this.errorMessage}"
|
|
20
|
+
error-message="${this.errorMessage}"
|
|
21
|
+
>
|
|
22
|
+
</paper-textarea>
|
|
21
23
|
`;
|
|
22
24
|
}
|
|
23
25
|
customValidation() {
|
|
@@ -27,12 +29,15 @@ export class TextField extends BaseField {
|
|
|
27
29
|
// language=CSS
|
|
28
30
|
return [
|
|
29
31
|
...BaseField.styles,
|
|
30
|
-
css `
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
css `
|
|
33
|
+
:host(.wide) paper-textarea {
|
|
34
|
+
padding-left: 0;
|
|
35
|
+
}
|
|
36
|
+
@media (max-width: 380px) {
|
|
37
|
+
.no-padding-left {
|
|
38
|
+
padding-left: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
36
41
|
`
|
|
37
42
|
];
|
|
38
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TemplateResult, CSSResultArray } from 'lit-element';
|
|
2
|
-
import { BaseField } from './base-field';
|
|
3
2
|
import '@polymer/paper-input/paper-textarea';
|
|
3
|
+
import { BaseField } from './single-fields/base-field';
|
|
4
4
|
export declare class WideField extends BaseField<string> {
|
|
5
5
|
label: string;
|
|
6
6
|
placeholder: string;
|
|
@@ -5,9 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, property } from 'lit-element';
|
|
8
|
-
import { BaseField } from './base-field';
|
|
9
8
|
import '@polymer/paper-input/paper-textarea';
|
|
10
9
|
import { InputStyles } from '../lib/styles/input-styles';
|
|
10
|
+
import { BaseField } from './single-fields/base-field';
|
|
11
11
|
export class WideField extends BaseField {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
@@ -18,13 +18,13 @@ export class WideField extends BaseField {
|
|
|
18
18
|
return html `
|
|
19
19
|
${InputStyles}
|
|
20
20
|
<paper-textarea
|
|
21
|
-
class="wide-input
|
|
21
|
+
class="wide-input"
|
|
22
22
|
always-float-label
|
|
23
23
|
.value="${this.value}"
|
|
24
24
|
label="${this.label}"
|
|
25
25
|
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
26
26
|
?required="${this.required}"
|
|
27
|
-
?
|
|
27
|
+
?readonly="${this.isReadonly}"
|
|
28
28
|
?invalid="${this.errorMessage}"
|
|
29
29
|
error-message="${this.errorMessage}"
|
|
30
30
|
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { LitElement, TemplateResult, CSSResultArray } from 'lit-element';
|
|
2
|
-
import '../form-fields/text-field';
|
|
3
|
-
import '../form-fields/number-field';
|
|
4
|
-
import '../form-fields/scale-field';
|
|
5
|
-
import '../form-fields/wide-field';
|
|
2
|
+
import '../form-fields/single-fields/text-field';
|
|
3
|
+
import '../form-fields/single-fields/number-field';
|
|
4
|
+
import '../form-fields/single-fields/scale-field';
|
|
6
5
|
import '@polymer/paper-input/paper-textarea';
|
|
7
6
|
import { IFormBuilderAbstractGroup } from '../lib/types/form-builder.interfaces';
|
|
8
|
-
import { BlueprintField, BlueprintGroup, BlueprintMetadata } from '../lib/types/form-builder.types';
|
|
7
|
+
import { BlueprintField, BlueprintGroup, BlueprintMetadata, Information } from '../lib/types/form-builder.types';
|
|
9
8
|
import { GenericObject } from '../lib/types/global.types';
|
|
10
9
|
export declare enum FieldTypes {
|
|
11
10
|
FILE_TYPE = "file",
|
|
@@ -47,14 +46,15 @@ export declare class FormAbstractGroup extends LitElement implements IFormBuilde
|
|
|
47
46
|
*/
|
|
48
47
|
set errors(errors: GenericObject | string[] | null);
|
|
49
48
|
render(): TemplateResult;
|
|
50
|
-
renderChild(child: BlueprintGroup | BlueprintField): TemplateResult;
|
|
49
|
+
renderChild(child: BlueprintGroup | BlueprintField | Information): TemplateResult | TemplateResult[];
|
|
51
50
|
renderField(blueprintField: BlueprintField): TemplateResult;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
renderInformation(information: Information): TemplateResult;
|
|
52
|
+
renderGroup(groupStructure: BlueprintGroup): TemplateResult | TemplateResult[];
|
|
53
|
+
getGroupTemplate(groupStructure: BlueprintGroup, index?: number): TemplateResult;
|
|
54
|
+
valueChanged(event: CustomEvent, name: string, index?: number): void;
|
|
55
|
+
errorChanged(event: CustomEvent, name: string, index?: number): void;
|
|
56
|
+
addGroup(name: string): void;
|
|
57
|
+
removeGroup(group: BlueprintGroup, index?: number): void;
|
|
58
58
|
protected getErrorMessage(fieldName: string): string | null;
|
|
59
59
|
static get styles(): CSSResultArray;
|
|
60
60
|
}
|