@unicef-polymer/etools-form-builder 2.1.9 → 3.0.0-rc.10
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.d.ts +0 -0
- package/dist/assets/translations.js +0 -0
- package/dist/form-attachments-popup/form-attachments-popup.d.ts +10 -12
- package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +0 -0
- package/dist/form-attachments-popup/form-attachments-popup.helper.js +0 -0
- package/dist/form-attachments-popup/form-attachments-popup.js +70 -76
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +5 -1
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +92 -81
- package/dist/form-attachments-popup/index.d.ts +0 -0
- package/dist/form-attachments-popup/index.js +0 -0
- package/dist/form-fields/abstract-field-base.class.d.ts +1 -1
- package/dist/form-fields/abstract-field-base.class.js +131 -135
- package/dist/form-fields/field-renderer-component.d.ts +1 -1
- package/dist/form-fields/field-renderer-component.js +150 -154
- package/dist/form-fields/index.d.ts +0 -0
- package/dist/form-fields/index.js +0 -0
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +4 -2
- package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +117 -117
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +2 -1
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +26 -29
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +2 -2
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +24 -28
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +5 -5
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +68 -72
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +2 -2
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +27 -31
- package/dist/form-fields/single-fields/attachment-field.d.ts +2 -2
- package/dist/form-fields/single-fields/attachment-field.js +17 -21
- package/dist/form-fields/single-fields/base-field.d.ts +1 -1
- package/dist/form-fields/single-fields/base-field.js +2 -7
- package/dist/form-fields/single-fields/boolean-field.d.ts +2 -2
- package/dist/form-fields/single-fields/boolean-field.js +24 -28
- package/dist/form-fields/single-fields/number-field.d.ts +2 -2
- package/dist/form-fields/single-fields/number-field.js +25 -29
- package/dist/form-fields/single-fields/scale-field.d.ts +6 -6
- package/dist/form-fields/single-fields/scale-field.js +69 -70
- package/dist/form-fields/single-fields/text-field.d.ts +2 -2
- package/dist/form-fields/single-fields/text-field.js +28 -33
- package/dist/form-groups/form-abstract-group.d.ts +3 -2
- package/dist/form-groups/form-abstract-group.js +147 -144
- package/dist/form-groups/form-card.d.ts +5 -2
- package/dist/form-groups/form-card.js +39 -32
- package/dist/form-groups/form-collapsed-card.d.ts +4 -4
- package/dist/form-groups/form-collapsed-card.js +60 -54
- package/dist/form-groups/index.d.ts +0 -0
- package/dist/form-groups/index.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/lib/additional-components/confirmation-dialog.d.ts +1 -1
- package/dist/lib/additional-components/confirmation-dialog.js +29 -33
- package/dist/lib/additional-components/etools-fb-card.d.ts +2 -2
- package/dist/lib/additional-components/etools-fb-card.js +147 -156
- package/dist/lib/styles/attachments.styles.d.ts +1 -1
- package/dist/lib/styles/attachments.styles.js +67 -70
- package/dist/lib/styles/card-styles.d.ts +1 -1
- package/dist/lib/styles/card-styles.js +152 -152
- package/dist/lib/styles/dialog.styles.d.ts +1 -1
- package/dist/lib/styles/dialog.styles.js +84 -83
- package/dist/lib/styles/elevation-styles.d.ts +1 -1
- package/dist/lib/styles/elevation-styles.js +34 -34
- package/dist/lib/styles/flex-layout-classes.d.ts +1 -1
- package/dist/lib/styles/flex-layout-classes.js +317 -317
- package/dist/lib/styles/form-builder-card.styles.d.ts +1 -1
- package/dist/lib/styles/form-builder-card.styles.js +47 -47
- package/dist/lib/styles/input-styles.d.ts +1 -1
- package/dist/lib/styles/input-styles.js +141 -136
- package/dist/lib/styles/page-layout-styles.d.ts +1 -1
- package/dist/lib/styles/page-layout-styles.js +199 -199
- package/dist/lib/styles/shared-styles.d.ts +1 -1
- package/dist/lib/styles/shared-styles.js +68 -68
- package/dist/lib/types/form-builder.interfaces.d.ts +2 -1
- package/dist/lib/types/form-builder.interfaces.js +1 -0
- package/dist/lib/types/form-builder.types.d.ts +7 -7
- package/dist/lib/types/form-builder.types.js +1 -0
- package/dist/lib/types/global.types.d.ts +2 -2
- package/dist/lib/types/global.types.js +1 -0
- package/dist/lib/utils/dialog.d.ts +0 -0
- package/dist/lib/utils/dialog.js +0 -0
- package/dist/lib/utils/fire-custom-event.d.ts +0 -0
- package/dist/lib/utils/fire-custom-event.js +0 -0
- package/dist/lib/utils/translate.d.ts +0 -0
- package/dist/lib/utils/translate.js +0 -0
- package/dist/lib/utils/validations.helper.d.ts +5 -5
- package/dist/lib/utils/validations.helper.js +0 -0
- package/package.json +55 -56
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { css, customElement, html } from 'lit-element';
|
|
8
|
-
import '@polymer/paper-input/paper-textarea';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import '@unicef-polymer/etools-unicef/src/etools-input/etools-textarea';
|
|
9
5
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
10
6
|
import { RepeatableBaseField } from './repeatable-base-field';
|
|
11
7
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
12
8
|
let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField {
|
|
13
9
|
controlTemplate(value, index) {
|
|
14
|
-
return html `
|
|
15
|
-
${InputStyles}
|
|
16
|
-
<
|
|
17
|
-
id="textarea"
|
|
18
|
-
class="no-padding-left"
|
|
19
|
-
no-label-float
|
|
20
|
-
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
21
|
-
.value="${value}"
|
|
22
|
-
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
23
|
-
?readonly="${this.isReadonly}"
|
|
24
|
-
?invalid="${this.errorMessage[index]}"
|
|
25
|
-
error-message="${this.errorMessage[index]}"
|
|
26
|
-
>
|
|
27
|
-
</
|
|
10
|
+
return html `
|
|
11
|
+
${InputStyles}
|
|
12
|
+
<etools-textarea
|
|
13
|
+
id="textarea"
|
|
14
|
+
class="no-padding-left"
|
|
15
|
+
no-label-float
|
|
16
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
17
|
+
.value="${value}"
|
|
18
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
|
|
19
|
+
?readonly="${this.isReadonly}"
|
|
20
|
+
?invalid="${this.errorMessage[index]}"
|
|
21
|
+
error-message="${this.errorMessage[index]}"
|
|
22
|
+
>
|
|
23
|
+
</etools-textarea>
|
|
28
24
|
`;
|
|
29
25
|
}
|
|
30
26
|
customValidation() {
|
|
@@ -34,15 +30,15 @@ let RepeatableTextField = class RepeatableTextField extends RepeatableBaseField
|
|
|
34
30
|
// language=CSS
|
|
35
31
|
return [
|
|
36
32
|
...AbstractFieldBaseClass.styles,
|
|
37
|
-
css `
|
|
38
|
-
:host(.wide) paper-textarea {
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
}
|
|
41
|
-
@media (max-width: 380px) {
|
|
42
|
-
.no-padding-left {
|
|
43
|
-
padding-left: 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
33
|
+
css `
|
|
34
|
+
:host(.wide) paper-textarea {
|
|
35
|
+
padding-left: 0;
|
|
36
|
+
}
|
|
37
|
+
@media (max-width: 380px) {
|
|
38
|
+
.no-padding-left {
|
|
39
|
+
padding-left: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
46
42
|
`
|
|
47
43
|
];
|
|
48
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import '@unicef-polymer/etools-upload/etools-upload';
|
|
1
|
+
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
3
|
import { SingleUploadFinishedDetails, StoredAttachment } from '../../form-attachments-popup';
|
|
4
|
-
import {
|
|
4
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
5
5
|
export declare class AttachmentField extends BaseField<StoredAttachment | null> {
|
|
6
6
|
get uploadUrl(): string;
|
|
7
7
|
get jwtLocalStorageKey(): string;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 '@unicef-polymer/etools-upload/etools-upload';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@unicef-polymer/etools-unicef/src/etools-upload/etools-upload';
|
|
8
3
|
import { BaseField } from './base-field';
|
|
9
4
|
import { AttachmentsHelper } from '../../form-attachments-popup';
|
|
10
|
-
import { html
|
|
5
|
+
import { html } from 'lit';
|
|
6
|
+
import { customElement } from 'lit/decorators.js';
|
|
11
7
|
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
12
8
|
import { SharedStyles } from '../../lib/styles/shared-styles';
|
|
13
9
|
import { AttachmentsStyles } from '../../lib/styles/attachments.styles';
|
|
@@ -24,19 +20,19 @@ let AttachmentField = class AttachmentField extends BaseField {
|
|
|
24
20
|
return AttachmentsHelper.jwtLocalStorageKey;
|
|
25
21
|
}
|
|
26
22
|
controlTemplate() {
|
|
27
|
-
return html `
|
|
28
|
-
<!-- Upload button -->
|
|
29
|
-
<etools-upload
|
|
30
|
-
class="with-padding"
|
|
31
|
-
activate-offline
|
|
32
|
-
.uploadedFileInfo="${this.value}"
|
|
33
|
-
?readonly="${this.isReadonly}"
|
|
34
|
-
@upload-finished="${({ detail }) => this.attachmentsUploaded(detail)}"
|
|
35
|
-
@delete-file="${() => this.valueChanged(null)}"
|
|
36
|
-
.endpointInfo="${{ endpoint: this.uploadUrl, extraInfo: { composedPath: this.computedPath } }}"
|
|
37
|
-
.jwtLocalStorageKey="${this.jwtLocalStorageKey}"
|
|
38
|
-
>
|
|
39
|
-
</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>
|
|
40
36
|
`;
|
|
41
37
|
}
|
|
42
38
|
customValidation() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
2
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
3
3
|
export declare abstract class BaseField<T> extends AbstractFieldBaseClass<T> {
|
|
4
4
|
set errorMessage(message: string | null);
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { property } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
8
3
|
import { fireEvent } from '../../lib/utils/fire-custom-event';
|
|
9
4
|
import { AbstractFieldBaseClass } from '../abstract-field-base.class';
|
|
10
5
|
import { getTranslation } from '../../lib/utils/translate';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
|
-
import '@
|
|
3
|
+
import '@shoelace-style/shoelace/dist/components/switch/switch.js';
|
|
4
4
|
export declare class BooleanField extends BaseField<boolean> {
|
|
5
5
|
protected controlTemplate(): TemplateResult;
|
|
6
6
|
protected customValidation(): string | null;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
4
|
import { BaseField } from './base-field';
|
|
9
|
-
import '@polymer/paper-toggle-button';
|
|
10
5
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
6
|
+
import '@shoelace-style/shoelace/dist/components/switch/switch.js';
|
|
11
7
|
let BooleanField = class BooleanField extends BaseField {
|
|
12
8
|
controlTemplate() {
|
|
13
|
-
return html `
|
|
14
|
-
${InputStyles}
|
|
15
|
-
<
|
|
16
|
-
class="no-padding-left"
|
|
17
|
-
?checked="${this.value}"
|
|
18
|
-
@
|
|
19
|
-
?disabled="${this.isReadonly}"
|
|
20
|
-
>
|
|
21
|
-
</
|
|
22
|
-
|
|
23
|
-
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
9
|
+
return html `
|
|
10
|
+
${InputStyles}
|
|
11
|
+
<sl-switch
|
|
12
|
+
class="no-padding-left"
|
|
13
|
+
?checked="${this.value}"
|
|
14
|
+
@sl-change="${(e) => this.valueChanged(e.target.checked)}"
|
|
15
|
+
?disabled="${this.isReadonly}"
|
|
16
|
+
>
|
|
17
|
+
</sl-switch>
|
|
18
|
+
|
|
19
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
24
20
|
`;
|
|
25
21
|
}
|
|
26
22
|
customValidation() {
|
|
@@ -30,15 +26,15 @@ let BooleanField = class BooleanField extends BaseField {
|
|
|
30
26
|
// language=CSS
|
|
31
27
|
return [
|
|
32
28
|
...BaseField.styles,
|
|
33
|
-
css `
|
|
34
|
-
:host(.wide) paper-textarea {
|
|
35
|
-
padding-left: 0;
|
|
36
|
-
}
|
|
37
|
-
@media (max-width: 380px) {
|
|
38
|
-
.no-padding-left {
|
|
39
|
-
padding-left: 0;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
29
|
+
css `
|
|
30
|
+
:host(.wide) paper-textarea {
|
|
31
|
+
padding-left: 0;
|
|
32
|
+
}
|
|
33
|
+
@media (max-width: 380px) {
|
|
34
|
+
.no-padding-left {
|
|
35
|
+
padding-left: 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
42
38
|
`
|
|
43
39
|
];
|
|
44
40
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
|
-
import '@polymer/
|
|
3
|
+
import '@unicef-polymer/etools-unicef/src/etools-input/etools-input';
|
|
4
4
|
export declare class NumberField extends BaseField<number> {
|
|
5
5
|
isInteger: boolean;
|
|
6
6
|
protected controlTemplate(): TemplateResult;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
4
|
import { BaseField } from './base-field';
|
|
9
|
-
import '@polymer/
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-input/etools-input';
|
|
10
6
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
11
7
|
import { getTranslation } from '../../lib/utils/translate';
|
|
12
8
|
let NumberField = class NumberField extends BaseField {
|
|
@@ -15,21 +11,21 @@ let NumberField = class NumberField extends BaseField {
|
|
|
15
11
|
this.isInteger = false;
|
|
16
12
|
}
|
|
17
13
|
controlTemplate() {
|
|
18
|
-
return html `
|
|
19
|
-
${InputStyles}
|
|
20
|
-
<
|
|
21
|
-
class="no-padding-left"
|
|
22
|
-
no-label-float
|
|
23
|
-
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
24
|
-
.value="${this.value}"
|
|
25
|
-
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
26
|
-
@focus="${() => (this.touched = true)}"
|
|
27
|
-
placeholder="—"
|
|
28
|
-
?invalid="${this.errorMessage}"
|
|
29
|
-
error-message="${this.errorMessage}"
|
|
30
|
-
?readonly="${this.isReadonly}"
|
|
31
|
-
>
|
|
32
|
-
</
|
|
14
|
+
return html `
|
|
15
|
+
${InputStyles}
|
|
16
|
+
<etools-input
|
|
17
|
+
class="no-padding-left"
|
|
18
|
+
no-label-float
|
|
19
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
20
|
+
.value="${this.value}"
|
|
21
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
22
|
+
@focus="${() => (this.touched = true)}"
|
|
23
|
+
placeholder="—"
|
|
24
|
+
?invalid="${this.errorMessage}"
|
|
25
|
+
error-message="${this.errorMessage}"
|
|
26
|
+
?readonly="${this.isReadonly}"
|
|
27
|
+
>
|
|
28
|
+
</etools-input>
|
|
33
29
|
`;
|
|
34
30
|
}
|
|
35
31
|
valueChanged(newValue) {
|
|
@@ -51,12 +47,12 @@ let NumberField = class NumberField extends BaseField {
|
|
|
51
47
|
// language=CSS
|
|
52
48
|
return [
|
|
53
49
|
...BaseField.styles,
|
|
54
|
-
css `
|
|
55
|
-
@media (max-width: 380px) {
|
|
56
|
-
.no-padding-left {
|
|
57
|
-
padding-left: 0;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
50
|
+
css `
|
|
51
|
+
@media (max-width: 380px) {
|
|
52
|
+
.no-padding-left {
|
|
53
|
+
padding-left: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
60
56
|
`
|
|
61
57
|
];
|
|
62
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
|
-
import '@polymer/
|
|
4
|
-
import '@
|
|
5
|
-
import
|
|
6
|
-
export
|
|
3
|
+
import '@unicef-polymer/etools-unicef/src/etools-radio/etools-radio-group';
|
|
4
|
+
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
6
|
+
export type FieldOption = {
|
|
7
7
|
value: any;
|
|
8
8
|
label: string;
|
|
9
9
|
};
|
|
@@ -12,7 +12,7 @@ export declare class ScaleField extends BaseField<string | number | null> {
|
|
|
12
12
|
protected controlTemplate(): TemplateResult;
|
|
13
13
|
protected getLabel(option: FieldOption | string | number): unknown;
|
|
14
14
|
protected getValue(option: FieldOption | string | number): unknown;
|
|
15
|
-
protected onSelect(
|
|
15
|
+
protected onSelect(itemValue: string): void;
|
|
16
16
|
protected customValidation(): string | null;
|
|
17
17
|
static get styles(): CSSResultArray;
|
|
18
18
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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, css, customElement } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
8
4
|
import { BaseField } from './base-field';
|
|
9
|
-
import { repeat } from 'lit
|
|
10
|
-
import '@polymer/
|
|
11
|
-
import '@
|
|
5
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
6
|
+
import '@unicef-polymer/etools-unicef/src/etools-radio/etools-radio-group';
|
|
7
|
+
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
8
|
+
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
12
9
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
13
10
|
import { getTranslation } from '../../lib/utils/translate';
|
|
14
11
|
let ScaleField = class ScaleField extends BaseField {
|
|
@@ -17,26 +14,29 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
17
14
|
this.options = [];
|
|
18
15
|
}
|
|
19
16
|
controlTemplate() {
|
|
20
|
-
return html `
|
|
21
|
-
${InputStyles}
|
|
22
|
-
<div class="container">
|
|
23
|
-
<
|
|
24
|
-
class="radio-group"
|
|
25
|
-
|
|
26
|
-
@
|
|
27
|
-
>
|
|
28
|
-
${repeat(this.options, (option) => html `
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
return html `
|
|
18
|
+
${InputStyles}
|
|
19
|
+
<div class="container">
|
|
20
|
+
<etools-radio-group
|
|
21
|
+
class="radio-group"
|
|
22
|
+
.value="${this.value}"
|
|
23
|
+
@sl-change="${(e) => this.onSelect(e.target.value)}"
|
|
24
|
+
>
|
|
25
|
+
${repeat(this.options, (option) => html `
|
|
26
|
+
<sl-radio class="radio-button" value="${this.getValue(option)}">${this.getLabel(option)}</sl-radio>
|
|
27
|
+
`)}
|
|
28
|
+
</etools-radio-group>
|
|
29
|
+
<etools-button
|
|
30
|
+
class="neutral clear-button"
|
|
31
|
+
variant="text"
|
|
32
|
+
?hidden="${this.isReadonly}"
|
|
33
|
+
@click="${() => this.valueChanged(null)}"
|
|
34
|
+
>
|
|
35
|
+
<etools-icon name="clear" slot="prefix"></etools-icon>
|
|
36
|
+
${getTranslation(this.language, 'CLEAR')}
|
|
37
|
+
</etools-button>
|
|
38
|
+
</div>
|
|
39
|
+
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
40
40
|
`;
|
|
41
41
|
}
|
|
42
42
|
getLabel(option) {
|
|
@@ -45,12 +45,11 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
45
45
|
getValue(option) {
|
|
46
46
|
return typeof option === 'object' ? option.value : option;
|
|
47
47
|
}
|
|
48
|
-
onSelect(
|
|
49
|
-
|
|
50
|
-
if (newValue !== this.value) {
|
|
48
|
+
onSelect(itemValue) {
|
|
49
|
+
if (itemValue !== this.value) {
|
|
51
50
|
this.touched = true;
|
|
52
51
|
}
|
|
53
|
-
this.valueChanged(
|
|
52
|
+
this.valueChanged(itemValue);
|
|
54
53
|
}
|
|
55
54
|
customValidation() {
|
|
56
55
|
return null;
|
|
@@ -59,42 +58,42 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
59
58
|
// language=CSS
|
|
60
59
|
return [
|
|
61
60
|
...BaseField.styles,
|
|
62
|
-
css `
|
|
63
|
-
.container {
|
|
64
|
-
position: relative;
|
|
65
|
-
min-height: 48px;
|
|
66
|
-
display: flex;
|
|
67
|
-
align-items: center;
|
|
68
|
-
flex-direction: row;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.radio-group {
|
|
72
|
-
display: flex;
|
|
73
|
-
flex-direction: row;
|
|
74
|
-
flex-wrap: wrap;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
:host([is-readonly])
|
|
78
|
-
pointer-events: none;
|
|
79
|
-
opacity: 0.55;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@media (max-width: 1080px) {
|
|
83
|
-
.container {
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
align-items: flex-start;
|
|
86
|
-
}
|
|
87
|
-
.radio-group {
|
|
88
|
-
flex-direction: column;
|
|
89
|
-
}
|
|
90
|
-
.radio-button {
|
|
91
|
-
padding-left: 3px;
|
|
92
|
-
}
|
|
93
|
-
.clear-button {
|
|
94
|
-
margin: 0;
|
|
95
|
-
padding-left: 0;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
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
|
+
}
|
|
98
97
|
`
|
|
99
98
|
];
|
|
100
99
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSResultArray, TemplateResult } from 'lit
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
|
-
import '@polymer/
|
|
3
|
+
import '@unicef-polymer/etools-unicef/src/etools-input/etools-textarea';
|
|
4
4
|
export declare class TextField extends BaseField<string> {
|
|
5
5
|
protected controlTemplate(): TemplateResult;
|
|
6
6
|
protected customValidation(): string | null;
|
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
4
|
import { BaseField } from './base-field';
|
|
9
|
-
import '@polymer/
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-input/etools-textarea';
|
|
10
6
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
11
7
|
let TextField = class TextField extends BaseField {
|
|
12
8
|
controlTemplate() {
|
|
13
|
-
return html `
|
|
14
|
-
${InputStyles}
|
|
15
|
-
<
|
|
16
|
-
id="
|
|
17
|
-
class="no-padding-left"
|
|
18
|
-
no-label-float
|
|
19
|
-
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
20
|
-
.value="${this.value}"
|
|
21
|
-
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
22
|
-
@focus="${() => (this.touched = true)}"
|
|
23
|
-
|
|
24
|
-
?
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
</paper-textarea>
|
|
9
|
+
return html `
|
|
10
|
+
${InputStyles}
|
|
11
|
+
<etools-textarea
|
|
12
|
+
id="otherInfo"
|
|
13
|
+
class="no-padding-left"
|
|
14
|
+
no-label-float
|
|
15
|
+
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
16
|
+
.value="${this.value}"
|
|
17
|
+
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
18
|
+
@focus="${() => (this.touched = true)}"
|
|
19
|
+
?readonly="${this.isReadonly}"
|
|
20
|
+
?invalid="${this.errorMessage}"
|
|
21
|
+
error-message="${this.errorMessage}"
|
|
22
|
+
>
|
|
23
|
+
</etools-textarea>
|
|
29
24
|
`;
|
|
30
25
|
}
|
|
31
26
|
customValidation() {
|
|
@@ -35,15 +30,15 @@ let TextField = class TextField extends BaseField {
|
|
|
35
30
|
// language=CSS
|
|
36
31
|
return [
|
|
37
32
|
...BaseField.styles,
|
|
38
|
-
css `
|
|
39
|
-
:host(.wide)
|
|
40
|
-
padding-left: 0;
|
|
41
|
-
}
|
|
42
|
-
@media (max-width: 380px) {
|
|
43
|
-
.no-padding-left {
|
|
44
|
-
padding-left: 0;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
33
|
+
css `
|
|
34
|
+
:host(.wide) etools-textarea {
|
|
35
|
+
padding-left: 0;
|
|
36
|
+
}
|
|
37
|
+
@media (max-width: 380px) {
|
|
38
|
+
.no-padding-left {
|
|
39
|
+
padding-left: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
47
42
|
`
|
|
48
43
|
];
|
|
49
44
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LitElement, TemplateResult
|
|
1
|
+
import { CSSResultArray, LitElement, TemplateResult } from 'lit';
|
|
2
2
|
import '../form-fields/single-fields/text-field';
|
|
3
3
|
import '../form-fields/single-fields/number-field';
|
|
4
4
|
import '../form-fields/single-fields/scale-field';
|
|
5
|
-
import '@polymer/
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
|
|
6
6
|
import { IFormBuilderAbstractGroup } from '../lib/types/form-builder.interfaces';
|
|
7
7
|
import { BlueprintField, BlueprintGroup, BlueprintMetadata, Information } from '../lib/types/form-builder.types';
|
|
8
8
|
import { GenericObject } from '../lib/types/global.types';
|
|
@@ -39,6 +39,7 @@ export declare class FormAbstractGroup extends LitElement implements IFormBuilde
|
|
|
39
39
|
*/
|
|
40
40
|
set value(value: GenericObject);
|
|
41
41
|
get value(): GenericObject;
|
|
42
|
+
isReadonly(): boolean;
|
|
42
43
|
/**
|
|
43
44
|
* Setter for handling error.
|
|
44
45
|
* Normally we wouldn't have errors as string or string[] for FormGroups.
|