@unicef-polymer/etools-form-builder 3.0.0-rc.9 → 3.1.0
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/LICENSE +674 -674
- package/README.md +1 -1
- package/dist/assets/translations.js +70 -2
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +4 -0
- package/dist/form-attachments-popup/form-attachments-popup.js +156 -53
- package/dist/form-fields/abstract-field-base.class.d.ts +1 -0
- package/dist/form-fields/abstract-field-base.class.js +106 -116
- package/dist/form-fields/field-renderer-component.d.ts +7 -3
- package/dist/form-fields/field-renderer-component.js +185 -154
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +112 -112
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -21
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -59
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -24
- package/dist/form-fields/single-fields/attachment-field.js +13 -13
- package/dist/form-fields/single-fields/boolean-field.js +16 -21
- package/dist/form-fields/single-fields/number-field.js +21 -23
- package/dist/form-fields/single-fields/scale-field.js +58 -60
- package/dist/form-fields/single-fields/text-field.js +24 -25
- package/dist/form-groups/form-abstract-group.d.ts +2 -1
- package/dist/form-groups/form-abstract-group.js +129 -127
- package/dist/form-groups/form-card.js +30 -24
- package/dist/form-groups/form-collapsed-card.js +34 -34
- package/dist/lib/additional-components/confirmation-dialog.js +21 -21
- package/dist/lib/additional-components/etools-fb-card.js +136 -135
- package/dist/lib/styles/attachments.styles.js +61 -66
- package/dist/lib/styles/card-styles.js +147 -151
- package/dist/lib/styles/dialog.styles.js +83 -83
- package/dist/lib/styles/elevation-styles.d.ts +2 -2
- package/dist/lib/styles/elevation-styles.js +35 -35
- package/dist/lib/styles/flex-layout-classes.js +316 -316
- package/dist/lib/styles/form-builder-card.styles.js +53 -46
- package/dist/lib/styles/page-layout-styles.js +198 -198
- package/dist/lib/styles/shared-styles.js +61 -67
- package/package.json +55 -55
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +0 -7
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +0 -102
- package/dist/lib/styles/input-styles.d.ts +0 -2
- package/dist/lib/styles/input-styles.js +0 -143
|
@@ -19,23 +19,23 @@ export class RepeatableBaseField extends AbstractFieldBaseClass {
|
|
|
19
19
|
}
|
|
20
20
|
render() {
|
|
21
21
|
const values = this.getValues();
|
|
22
|
-
return html `
|
|
23
|
-
<div class="finding-container">
|
|
24
|
-
<div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
|
|
25
|
-
<div class="question-control layout vertical center-justified start">
|
|
26
|
-
${values.map((value, index) => html `<div class="layout horizontal center full-width">
|
|
27
|
-
${this.controlTemplate(value, index)}
|
|
28
|
-
<etools-icon-button
|
|
29
|
-
name="close"
|
|
30
|
-
?hidden="${this.isReadonly || values.length < 2}"
|
|
31
|
-
@click="${() => this.removeControl(index)}"
|
|
32
|
-
></etools-icon-button>
|
|
33
|
-
</div>`)}
|
|
34
|
-
<etools-button variant="primary" class="add-button" ?hidden="${this.isReadonly}" @click="${this.addNewField}">
|
|
35
|
-
${getTranslation(this.language, 'ADD')}
|
|
36
|
-
</etools-button>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
22
|
+
return html `
|
|
23
|
+
<div class="finding-container">
|
|
24
|
+
<div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
|
|
25
|
+
<div class="question-control layout vertical center-justified start">
|
|
26
|
+
${values.map((value, index) => html `<div class="layout horizontal center full-width">
|
|
27
|
+
${this.controlTemplate(value, index)}
|
|
28
|
+
<etools-icon-button
|
|
29
|
+
name="close"
|
|
30
|
+
?hidden="${this.isReadonly || values.length < 2}"
|
|
31
|
+
@click="${() => this.removeControl(index)}"
|
|
32
|
+
></etools-icon-button>
|
|
33
|
+
</div>`)}
|
|
34
|
+
<etools-button variant="primary" class="add-button" ?hidden="${this.isReadonly}" @click="${this.addNewField}">
|
|
35
|
+
${getTranslation(this.language, 'ADD')}
|
|
36
|
+
</etools-button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
39
|
`;
|
|
40
40
|
}
|
|
41
41
|
questionTemplate() {
|
|
@@ -104,11 +104,11 @@ export class RepeatableBaseField extends AbstractFieldBaseClass {
|
|
|
104
104
|
// language=CSS
|
|
105
105
|
return [
|
|
106
106
|
...AbstractFieldBaseClass.styles,
|
|
107
|
-
css `
|
|
108
|
-
:host(:not([is-readonly])) .question-control,
|
|
109
|
-
:host(:not([is-readonly])) .question {
|
|
110
|
-
padding-bottom: 10px;
|
|
111
|
-
}
|
|
107
|
+
css `
|
|
108
|
+
:host(:not([is-readonly])) .question-control,
|
|
109
|
+
:host(:not([is-readonly])) .question {
|
|
110
|
+
padding-bottom: 10px;
|
|
111
|
+
}
|
|
112
112
|
`
|
|
113
113
|
];
|
|
114
114
|
}
|
|
@@ -2,7 +2,6 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import '@unicef-polymer/etools-unicef/src/etools-input/etools-input';
|
|
5
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
6
5
|
import { RepeatableBaseField } from './repeatable-base-field';
|
|
7
6
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
8
7
|
import { getTranslation } from '../../lib/utils/translate';
|
|
@@ -12,20 +11,19 @@ let RepeatableNumberField = class RepeatableNumberField extends RepeatableBaseFi
|
|
|
12
11
|
this.isInteger = false;
|
|
13
12
|
}
|
|
14
13
|
controlTemplate(value, index) {
|
|
15
|
-
return html `
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
</etools-input>
|
|
14
|
+
return html `
|
|
15
|
+
<etools-input
|
|
16
|
+
class="no-padding-left"
|
|
17
|
+
no-label-float
|
|
18
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
19
|
+
.value="${value}"
|
|
20
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
21
|
+
placeholder="—"
|
|
22
|
+
?invalid="${this.errorMessage[index]}"
|
|
23
|
+
error-message="${this.errorMessage[index]}"
|
|
24
|
+
?readonly="${this.isReadonly}"
|
|
25
|
+
>
|
|
26
|
+
</etools-input>
|
|
29
27
|
`;
|
|
30
28
|
}
|
|
31
29
|
valueChanged(newValue, index) {
|
|
@@ -47,12 +45,12 @@ let RepeatableNumberField = class RepeatableNumberField extends RepeatableBaseFi
|
|
|
47
45
|
// language=CSS
|
|
48
46
|
return [
|
|
49
47
|
...AbstractFieldBaseClass.styles,
|
|
50
|
-
css `
|
|
51
|
-
@media (max-width: 380px) {
|
|
52
|
-
.no-padding-left {
|
|
53
|
-
padding-left: 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
48
|
+
css `
|
|
49
|
+
@media (max-width: 380px) {
|
|
50
|
+
.no-padding-left {
|
|
51
|
+
padding-left: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
56
54
|
`
|
|
57
55
|
];
|
|
58
56
|
}
|
|
@@ -5,7 +5,6 @@ import { repeat } from 'lit/directives/repeat.js';
|
|
|
5
5
|
import '@unicef-polymer/etools-unicef/src/etools-radio/etools-radio-group';
|
|
6
6
|
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
7
7
|
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
8
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
9
8
|
import { RepeatableBaseField } from './repeatable-base-field';
|
|
10
9
|
import { getTranslation } from '../../lib/utils/translate';
|
|
11
10
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
@@ -15,28 +14,27 @@ let RepeatableScaleField = class RepeatableScaleField extends RepeatableBaseFiel
|
|
|
15
14
|
this.options = [];
|
|
16
15
|
}
|
|
17
16
|
controlTemplate(value, index) {
|
|
18
|
-
return html `
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
</div>
|
|
17
|
+
return html `
|
|
18
|
+
<div class="container">
|
|
19
|
+
<etools-radio-group
|
|
20
|
+
class="radio-group"
|
|
21
|
+
.value="${value}"
|
|
22
|
+
@sl-change="${(e) => this.onSelect(e.target.value, index)}"
|
|
23
|
+
>
|
|
24
|
+
${repeat(this.options, (option) => html `
|
|
25
|
+
<sl-radio class="radio-button" value="${this.getValue(option)}"> ${this.getLabel(option)} </sl-radio>
|
|
26
|
+
`)}
|
|
27
|
+
</etools-radio-group>
|
|
28
|
+
<etools-button
|
|
29
|
+
class="neutral clear-button"
|
|
30
|
+
variant="text"
|
|
31
|
+
?hidden="${this.isReadonly}"
|
|
32
|
+
@click="${() => this.valueChanged(null, index)}"
|
|
33
|
+
>
|
|
34
|
+
<etools-icon name="clear" slot="prefix"></etools-icon>
|
|
35
|
+
${getTranslation(this.language, 'CLEAR')}
|
|
36
|
+
</etools-button>
|
|
37
|
+
</div>
|
|
40
38
|
`;
|
|
41
39
|
}
|
|
42
40
|
onSelect(itemValue, index) {
|
|
@@ -55,42 +53,42 @@ let RepeatableScaleField = class RepeatableScaleField extends RepeatableBaseFiel
|
|
|
55
53
|
// language=CSS
|
|
56
54
|
return [
|
|
57
55
|
...AbstractFieldBaseClass.styles,
|
|
58
|
-
css `
|
|
59
|
-
.container {
|
|
60
|
-
position: relative;
|
|
61
|
-
min-height: 48px;
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
flex-direction: row;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.radio-group {
|
|
68
|
-
display: flex;
|
|
69
|
-
flex-direction: row;
|
|
70
|
-
flex-wrap: wrap;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:host([is-readonly]) etools-radio-group {
|
|
74
|
-
pointer-events: none;
|
|
75
|
-
opacity: 0.55;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@media (max-width: 1080px) {
|
|
79
|
-
.container {
|
|
80
|
-
flex-direction: column;
|
|
81
|
-
align-items: flex-start;
|
|
82
|
-
}
|
|
83
|
-
.radio-group {
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
}
|
|
86
|
-
.radio-button {
|
|
87
|
-
padding-left: 3px;
|
|
88
|
-
}
|
|
89
|
-
.clear-button {
|
|
90
|
-
margin: 0;
|
|
91
|
-
padding-left: 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
56
|
+
css `
|
|
57
|
+
.container {
|
|
58
|
+
position: relative;
|
|
59
|
+
min-height: 48px;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
flex-direction: row;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.radio-group {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
flex-wrap: wrap;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([is-readonly]) etools-radio-group {
|
|
72
|
+
pointer-events: none;
|
|
73
|
+
opacity: 0.55;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@media (max-width: 1080px) {
|
|
77
|
+
.container {
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: flex-start;
|
|
80
|
+
}
|
|
81
|
+
.radio-group {
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
}
|
|
84
|
+
.radio-button {
|
|
85
|
+
padding-left: 3px;
|
|
86
|
+
}
|
|
87
|
+
.clear-button {
|
|
88
|
+
margin: 0;
|
|
89
|
+
padding-left: 0;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
94
92
|
`
|
|
95
93
|
];
|
|
96
94
|
}
|
|
@@ -2,25 +2,23 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import '@unicef-polymer/etools-unicef/src/etools-input/etools-textarea';
|
|
5
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
6
5
|
import { RepeatableBaseField } from './repeatable-base-field';
|
|
7
6
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
8
7
|
let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField {
|
|
9
8
|
controlTemplate(value, index) {
|
|
10
|
-
return html `
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
?
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
>
|
|
23
|
-
</etools-textarea>
|
|
9
|
+
return html `
|
|
10
|
+
<etools-textarea
|
|
11
|
+
id="textarea"
|
|
12
|
+
class="no-padding-left"
|
|
13
|
+
no-label-float
|
|
14
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
15
|
+
.value="${value}"
|
|
16
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
17
|
+
?readonly="${this.isReadonly}"
|
|
18
|
+
?invalid="${this.errorMessage[index]}"
|
|
19
|
+
error-message="${this.errorMessage[index]}"
|
|
20
|
+
>
|
|
21
|
+
</etools-textarea>
|
|
24
22
|
`;
|
|
25
23
|
}
|
|
26
24
|
customValidation() {
|
|
@@ -30,15 +28,12 @@ let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField
|
|
|
30
28
|
// language=CSS
|
|
31
29
|
return [
|
|
32
30
|
...AbstractFieldBaseClass.styles,
|
|
33
|
-
css `
|
|
34
|
-
:
|
|
35
|
-
padding-left
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
31
|
+
css `
|
|
32
|
+
@media (max-width: 380px) {
|
|
33
|
+
.no-padding-left {
|
|
34
|
+
padding-left: 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
42
37
|
`
|
|
43
38
|
];
|
|
44
39
|
}
|
|
@@ -20,19 +20,19 @@ let AttachmentField = class AttachmentField extends BaseField {
|
|
|
20
20
|
return AttachmentsHelper.jwtLocalStorageKey;
|
|
21
21
|
}
|
|
22
22
|
controlTemplate() {
|
|
23
|
-
return html `
|
|
24
|
-
<!-- Upload button -->
|
|
25
|
-
<etools-upload
|
|
26
|
-
class="with-padding"
|
|
27
|
-
activate-offline
|
|
28
|
-
.uploadedFileInfo="${this.value}"
|
|
29
|
-
?readonly="${this.isReadonly}"
|
|
30
|
-
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
31
|
-
@delete-file="${() => this.valueChanged(null)}"
|
|
32
|
-
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
33
|
-
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
34
|
-
>
|
|
35
|
-
</etools-upload>
|
|
23
|
+
return html `
|
|
24
|
+
<!-- Upload button -->
|
|
25
|
+
<etools-upload
|
|
26
|
+
class="with-padding"
|
|
27
|
+
activate-offline
|
|
28
|
+
.uploadedFileInfo="${this.value}"
|
|
29
|
+
?readonly="${this.isReadonly}"
|
|
30
|
+
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
31
|
+
@delete-file="${() => this.valueChanged(null)}"
|
|
32
|
+
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
33
|
+
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
34
|
+
>
|
|
35
|
+
</etools-upload>
|
|
36
36
|
`;
|
|
37
37
|
}
|
|
38
38
|
customValidation() {
|
|
@@ -2,21 +2,19 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { BaseField } from './base-field';
|
|
5
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
6
5
|
import '@shoelace-style/shoelace/dist/components/switch/switch.js';
|
|
7
6
|
let BooleanField = class BooleanField extends BaseField {
|
|
8
7
|
controlTemplate() {
|
|
9
|
-
return html `
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
8
|
+
return html `
|
|
9
|
+
<sl-switch
|
|
10
|
+
class="no-padding-left"
|
|
11
|
+
?checked="${this.value}"
|
|
12
|
+
@sl-change="${(e) => this.valueChanged(e.target.checked)}"
|
|
13
|
+
?disabled="${this.isReadonly}"
|
|
14
|
+
>
|
|
15
|
+
</sl-switch>
|
|
16
|
+
|
|
17
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
20
18
|
`;
|
|
21
19
|
}
|
|
22
20
|
customValidation() {
|
|
@@ -26,15 +24,12 @@ let BooleanField = class BooleanField extends BaseField {
|
|
|
26
24
|
// language=CSS
|
|
27
25
|
return [
|
|
28
26
|
...BaseField.styles,
|
|
29
|
-
css `
|
|
30
|
-
:
|
|
31
|
-
padding-left
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
padding-left: 0;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
27
|
+
css `
|
|
28
|
+
@media (max-width: 380px) {
|
|
29
|
+
.no-padding-left {
|
|
30
|
+
padding-left: 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
38
33
|
`
|
|
39
34
|
];
|
|
40
35
|
}
|
|
@@ -3,7 +3,6 @@ import { css, html } from 'lit';
|
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { BaseField } from './base-field';
|
|
5
5
|
import '@unicef-polymer/etools-unicef/src/etools-input/etools-input';
|
|
6
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
7
6
|
import { getTranslation } from '../../lib/utils/translate';
|
|
8
7
|
let NumberField = class NumberField extends BaseField {
|
|
9
8
|
constructor() {
|
|
@@ -11,21 +10,20 @@ let NumberField = class NumberField extends BaseField {
|
|
|
11
10
|
this.isInteger = false;
|
|
12
11
|
}
|
|
13
12
|
controlTemplate() {
|
|
14
|
-
return html `
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
</etools-input>
|
|
13
|
+
return html `
|
|
14
|
+
<etools-input
|
|
15
|
+
class="no-padding-left"
|
|
16
|
+
no-label-float
|
|
17
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
18
|
+
.value="${this.value}"
|
|
19
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
20
|
+
@focus="${() => (this.touched = true)}"
|
|
21
|
+
placeholder="—"
|
|
22
|
+
?invalid="${this.errorMessage}"
|
|
23
|
+
error-message="${this.errorMessage}"
|
|
24
|
+
?readonly="${this.isReadonly}"
|
|
25
|
+
>
|
|
26
|
+
</etools-input>
|
|
29
27
|
`;
|
|
30
28
|
}
|
|
31
29
|
valueChanged(newValue) {
|
|
@@ -38,7 +36,7 @@ let NumberField = class NumberField extends BaseField {
|
|
|
38
36
|
return null;
|
|
39
37
|
}
|
|
40
38
|
if (isNaN(value)) {
|
|
41
|
-
return
|
|
39
|
+
return getTranslation(this.language, 'MUST_BE_NUMBER');
|
|
42
40
|
}
|
|
43
41
|
const integerValidation = !this.isInteger || value - Math.floor(value) === 0;
|
|
44
42
|
return integerValidation ? null : getTranslation(this.language, 'MUST_BE_INTEGER');
|
|
@@ -47,12 +45,12 @@ let NumberField = class NumberField extends BaseField {
|
|
|
47
45
|
// language=CSS
|
|
48
46
|
return [
|
|
49
47
|
...BaseField.styles,
|
|
50
|
-
css `
|
|
51
|
-
@media (max-width: 380px) {
|
|
52
|
-
.no-padding-left {
|
|
53
|
-
padding-left: 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
48
|
+
css `
|
|
49
|
+
@media (max-width: 380px) {
|
|
50
|
+
.no-padding-left {
|
|
51
|
+
padding-left: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
56
54
|
`
|
|
57
55
|
];
|
|
58
56
|
}
|
|
@@ -6,7 +6,6 @@ import { repeat } from 'lit/directives/repeat.js';
|
|
|
6
6
|
import '@unicef-polymer/etools-unicef/src/etools-radio/etools-radio-group';
|
|
7
7
|
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
8
8
|
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
9
|
-
import { InputStyles } from '../../lib/styles/input-styles';
|
|
10
9
|
import { getTranslation } from '../../lib/utils/translate';
|
|
11
10
|
let ScaleField = class ScaleField extends BaseField {
|
|
12
11
|
constructor() {
|
|
@@ -14,29 +13,28 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
14
13
|
this.options = [];
|
|
15
14
|
}
|
|
16
15
|
controlTemplate() {
|
|
17
|
-
return html `
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</div>
|
|
39
|
-
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
16
|
+
return html `
|
|
17
|
+
<div class="container">
|
|
18
|
+
<etools-radio-group
|
|
19
|
+
class="radio-group"
|
|
20
|
+
.value="${this.value}"
|
|
21
|
+
@sl-change="${(e) => this.onSelect(e.target.value)}"
|
|
22
|
+
>
|
|
23
|
+
${repeat(this.options, (option) => html `
|
|
24
|
+
<sl-radio class="radio-button" value="${this.getValue(option)}">${this.getLabel(option)}</sl-radio>
|
|
25
|
+
`)}
|
|
26
|
+
</etools-radio-group>
|
|
27
|
+
<etools-button
|
|
28
|
+
class="neutral clear-button"
|
|
29
|
+
variant="text"
|
|
30
|
+
?hidden="${this.isReadonly}"
|
|
31
|
+
@click="${() => this.valueChanged(null)}"
|
|
32
|
+
>
|
|
33
|
+
<etools-icon name="clear" slot="prefix"></etools-icon>
|
|
34
|
+
${getTranslation(this.language, 'CLEAR')}
|
|
35
|
+
</etools-button>
|
|
36
|
+
</div>
|
|
37
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
40
38
|
`;
|
|
41
39
|
}
|
|
42
40
|
getLabel(option) {
|
|
@@ -58,42 +56,42 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
58
56
|
// language=CSS
|
|
59
57
|
return [
|
|
60
58
|
...BaseField.styles,
|
|
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]) etools-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
|
-
}
|
|
59
|
+
css `
|
|
60
|
+
.container {
|
|
61
|
+
position: relative;
|
|
62
|
+
min-height: 48px;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
flex-direction: row;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.radio-group {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: row;
|
|
71
|
+
flex-wrap: wrap;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:host([is-readonly]) etools-radio-group {
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
opacity: 0.55;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@media (max-width: 1080px) {
|
|
80
|
+
.container {
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
align-items: flex-start;
|
|
83
|
+
}
|
|
84
|
+
.radio-group {
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
}
|
|
87
|
+
.radio-button {
|
|
88
|
+
padding-left: 3px;
|
|
89
|
+
}
|
|
90
|
+
.clear-button {
|
|
91
|
+
margin: 0;
|
|
92
|
+
padding-left: 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
97
95
|
`
|
|
98
96
|
];
|
|
99
97
|
}
|