@unicef-polymer/etools-form-builder 2.1.9 → 3.0.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/LICENSE +0 -0
- package/README.md +0 -0
- 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 +22 -28
- package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +4 -0
- package/dist/form-attachments-popup/form-attachments-popup.tpl.js +19 -8
- 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 +16 -20
- package/dist/form-fields/field-renderer-component.d.ts +1 -1
- package/dist/form-fields/field-renderer-component.js +3 -7
- 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 +19 -16
- package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +2 -1
- package/dist/form-fields/repeatable-fields/repeatable-base-field.js +9 -12
- package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +2 -2
- package/dist/form-fields/repeatable-fields/repeatable-number-field.js +6 -10
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +5 -5
- package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +22 -24
- package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +2 -2
- package/dist/form-fields/repeatable-fields/repeatable-text-field.js +6 -10
- package/dist/form-fields/single-fields/attachment-field.d.ts +2 -2
- package/dist/form-fields/single-fields/attachment-field.js +4 -8
- 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 +7 -11
- package/dist/form-fields/single-fields/number-field.d.ts +2 -2
- package/dist/form-fields/single-fields/number-field.js +6 -10
- package/dist/form-fields/single-fields/scale-field.d.ts +6 -6
- package/dist/form-fields/single-fields/scale-field.js +26 -25
- package/dist/form-fields/single-fields/text-field.d.ts +2 -2
- package/dist/form-fields/single-fields/text-field.js +8 -13
- package/dist/form-groups/form-abstract-group.d.ts +2 -2
- package/dist/form-groups/form-abstract-group.js +22 -24
- package/dist/form-groups/form-card.d.ts +5 -2
- package/dist/form-groups/form-card.js +16 -14
- package/dist/form-groups/form-collapsed-card.d.ts +4 -3
- package/dist/form-groups/form-collapsed-card.js +19 -17
- 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 +9 -13
- package/dist/lib/additional-components/etools-fb-card.d.ts +2 -2
- package/dist/lib/additional-components/etools-fb-card.js +40 -37
- package/dist/lib/styles/attachments.styles.d.ts +1 -1
- package/dist/lib/styles/attachments.styles.js +1 -1
- package/dist/lib/styles/card-styles.d.ts +1 -1
- package/dist/lib/styles/card-styles.js +1 -1
- package/dist/lib/styles/dialog.styles.d.ts +1 -1
- package/dist/lib/styles/dialog.styles.js +1 -1
- package/dist/lib/styles/elevation-styles.d.ts +1 -1
- package/dist/lib/styles/elevation-styles.js +1 -1
- package/dist/lib/styles/flex-layout-classes.d.ts +1 -1
- package/dist/lib/styles/flex-layout-classes.js +1 -1
- package/dist/lib/styles/form-builder-card.styles.d.ts +1 -1
- package/dist/lib/styles/form-builder-card.styles.js +1 -1
- package/dist/lib/styles/input-styles.d.ts +1 -1
- package/dist/lib/styles/input-styles.js +1 -1
- package/dist/lib/styles/page-layout-styles.d.ts +1 -1
- package/dist/lib/styles/page-layout-styles.js +1 -1
- package/dist/lib/styles/shared-styles.d.ts +1 -1
- package/dist/lib/styles/shared-styles.js +1 -1
- package/dist/lib/types/form-builder.interfaces.d.ts +1 -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 +20 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import '@unicef-polymer/etools-upload/etools-upload';
|
|
1
|
+
import '@unicef-polymer/etools-unicef/scr/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/scr/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';
|
|
@@ -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,24 +1,20 @@
|
|
|
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
9
|
return html `
|
|
14
10
|
${InputStyles}
|
|
15
|
-
<
|
|
11
|
+
<sl-switch
|
|
16
12
|
class="no-padding-left"
|
|
17
13
|
?checked="${this.value}"
|
|
18
|
-
@
|
|
14
|
+
@sl-change="${(e) => this.valueChanged(e.target.checked)}"
|
|
19
15
|
?disabled="${this.isReadonly}"
|
|
20
16
|
>
|
|
21
|
-
</
|
|
17
|
+
</sl-switch>
|
|
22
18
|
|
|
23
19
|
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
24
20
|
`;
|
|
@@ -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 {
|
|
@@ -17,7 +13,7 @@ let NumberField = class NumberField extends BaseField {
|
|
|
17
13
|
controlTemplate() {
|
|
18
14
|
return html `
|
|
19
15
|
${InputStyles}
|
|
20
|
-
<
|
|
16
|
+
<etools-input
|
|
21
17
|
class="no-padding-left"
|
|
22
18
|
no-label-float
|
|
23
19
|
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
@@ -29,7 +25,7 @@ let NumberField = class NumberField extends BaseField {
|
|
|
29
25
|
error-message="${this.errorMessage}"
|
|
30
26
|
?readonly="${this.isReadonly}"
|
|
31
27
|
>
|
|
32
|
-
</
|
|
28
|
+
</etools-input>
|
|
33
29
|
`;
|
|
34
30
|
}
|
|
35
31
|
valueChanged(newValue) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { BaseField } from './base-field';
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
5
|
-
import
|
|
6
|
-
export
|
|
3
|
+
import '@shoelace-style/shoelace/dist/components/radio-group/radio-group.js';
|
|
4
|
+
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
5
|
+
import '@shoelace-style/shoelace/dist/components/button/button.js';
|
|
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,12 @@
|
|
|
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 '@
|
|
11
|
-
import '@polymer/
|
|
5
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
6
|
+
import '@shoelace-style/shoelace/dist/components/radio-group/radio-group.js';
|
|
7
|
+
import { buttonsStyles } from '@unicef-polymer/etools-unicef/src/styles/button-styles';
|
|
8
|
+
import '@shoelace-style/shoelace/dist/components/radio/radio.js';
|
|
9
|
+
import '@shoelace-style/shoelace/dist/components/button/button.js';
|
|
12
10
|
import { InputStyles } from '../../lib/styles/input-styles';
|
|
13
11
|
import { getTranslation } from '../../lib/utils/translate';
|
|
14
12
|
let ScaleField = class ScaleField extends BaseField {
|
|
@@ -20,21 +18,24 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
20
18
|
return html `
|
|
21
19
|
${InputStyles}
|
|
22
20
|
<div class="container">
|
|
23
|
-
<
|
|
21
|
+
<sl-radio-group
|
|
24
22
|
class="radio-group"
|
|
25
|
-
|
|
26
|
-
@
|
|
23
|
+
.value="${this.value}"
|
|
24
|
+
@sl-change="${(e) => this.onSelect(e.target.value)}"
|
|
27
25
|
>
|
|
28
26
|
${repeat(this.options, (option) => html `
|
|
29
|
-
<
|
|
30
|
-
${this.getLabel(option)}
|
|
31
|
-
</paper-radio-button>
|
|
27
|
+
<sl-radio class="radio-button" value="${this.getValue(option)}">${this.getLabel(option)}</sl-radio>
|
|
32
28
|
`)}
|
|
33
|
-
</
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
</sl-radio-group>
|
|
30
|
+
<sl-button
|
|
31
|
+
variant="primary"
|
|
32
|
+
?hidden="${this.isReadonly}"
|
|
33
|
+
@click="${() => this.valueChanged(null)}"
|
|
34
|
+
class="clear-button"
|
|
35
|
+
>
|
|
36
|
+
<etools-icon name="clear" slot="prefix"></etools-icon>
|
|
37
|
+
${getTranslation(this.language, 'CLEAR')}
|
|
38
|
+
</sl-button>
|
|
38
39
|
</div>
|
|
39
40
|
<div ?hidden="${!this.errorMessage}" class="error-text">${this.errorMessage}</div>
|
|
40
41
|
`;
|
|
@@ -45,12 +46,11 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
45
46
|
getValue(option) {
|
|
46
47
|
return typeof option === 'object' ? option.value : option;
|
|
47
48
|
}
|
|
48
|
-
onSelect(
|
|
49
|
-
|
|
50
|
-
if (newValue !== this.value) {
|
|
49
|
+
onSelect(itemValue) {
|
|
50
|
+
if (itemValue !== this.value) {
|
|
51
51
|
this.touched = true;
|
|
52
52
|
}
|
|
53
|
-
this.valueChanged(
|
|
53
|
+
this.valueChanged(itemValue);
|
|
54
54
|
}
|
|
55
55
|
customValidation() {
|
|
56
56
|
return null;
|
|
@@ -59,6 +59,7 @@ let ScaleField = class ScaleField extends BaseField {
|
|
|
59
59
|
// language=CSS
|
|
60
60
|
return [
|
|
61
61
|
...BaseField.styles,
|
|
62
|
+
buttonsStyles,
|
|
62
63
|
css `
|
|
63
64
|
.container {
|
|
64
65
|
position: relative;
|
|
@@ -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
9
|
return html `
|
|
14
10
|
${InputStyles}
|
|
15
|
-
<
|
|
16
|
-
id="
|
|
11
|
+
<etools-textarea
|
|
12
|
+
id="otherInfo"
|
|
17
13
|
class="no-padding-left"
|
|
18
14
|
no-label-float
|
|
19
15
|
placeholder="${this.isReadonly ? '—' : this.placeholder}"
|
|
20
16
|
.value="${this.value}"
|
|
21
17
|
@value-changed="${({ detail }) => this.valueChanged(detail.value)}"
|
|
22
18
|
@focus="${() => (this.touched = true)}"
|
|
23
|
-
placeholder="—"
|
|
24
19
|
?readonly="${this.isReadonly}"
|
|
25
20
|
?invalid="${this.errorMessage}"
|
|
26
21
|
error-message="${this.errorMessage}"
|
|
27
22
|
>
|
|
28
|
-
</
|
|
23
|
+
</etools-textarea>
|
|
29
24
|
`;
|
|
30
25
|
}
|
|
31
26
|
customValidation() {
|
|
@@ -36,7 +31,7 @@ let TextField = class TextField extends BaseField {
|
|
|
36
31
|
return [
|
|
37
32
|
...BaseField.styles,
|
|
38
33
|
css `
|
|
39
|
-
:host(.wide)
|
|
34
|
+
:host(.wide) etools-textarea {
|
|
40
35
|
padding-left: 0;
|
|
41
36
|
}
|
|
42
37
|
@media (max-width: 380px) {
|
|
@@ -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 '@
|
|
5
|
+
import '@shoelace-style/shoelace/dist/components/button/button.js';
|
|
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';
|
|
@@ -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 { LitElement, property, html, css, customElement } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
8
4
|
import '../form-fields/single-fields/text-field';
|
|
9
5
|
import '../form-fields/single-fields/number-field';
|
|
10
6
|
import '../form-fields/single-fields/scale-field';
|
|
11
|
-
import '@
|
|
7
|
+
import '@shoelace-style/shoelace/dist/components/button/button.js';
|
|
8
|
+
import { buttonsStyles } from '@unicef-polymer/etools-unicef/src/styles/button-styles';
|
|
12
9
|
import { SharedStyles } from '../lib/styles/shared-styles';
|
|
13
10
|
import { pageLayoutStyles } from '../lib/styles/page-layout-styles';
|
|
14
11
|
import { elevationStyles } from '../lib/styles/elevation-styles';
|
|
@@ -16,7 +13,7 @@ import { CardStyles } from '../lib/styles/card-styles';
|
|
|
16
13
|
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
17
14
|
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
18
15
|
import { clone } from 'ramda';
|
|
19
|
-
import { live } from 'lit
|
|
16
|
+
import { live } from 'lit/directives/live.js';
|
|
20
17
|
import { openDialog } from '../lib/utils/dialog';
|
|
21
18
|
import { FormBuilderCardStyles } from '../lib/styles/form-builder-card.styles';
|
|
22
19
|
import { getTranslation } from '../lib/utils/translate';
|
|
@@ -40,19 +37,6 @@ export var StructureTypes;
|
|
|
40
37
|
StructureTypes["ATTACHMENTS_BUTTON"] = "floating_attachments";
|
|
41
38
|
})(StructureTypes || (StructureTypes = {}));
|
|
42
39
|
let FormAbstractGroup = class FormAbstractGroup extends LitElement {
|
|
43
|
-
constructor() {
|
|
44
|
-
super();
|
|
45
|
-
this.parentGroupName = '';
|
|
46
|
-
this.collapsed = false;
|
|
47
|
-
this.readonly = false;
|
|
48
|
-
this._errors = {};
|
|
49
|
-
this._value = {};
|
|
50
|
-
this.computedPath = [];
|
|
51
|
-
if (!this.language) {
|
|
52
|
-
this.language = window.localStorage.defaultLanguage || 'en';
|
|
53
|
-
}
|
|
54
|
-
this.handleLanguageChange = this.handleLanguageChange.bind(this);
|
|
55
|
-
}
|
|
56
40
|
/**
|
|
57
41
|
* Make value property immutable
|
|
58
42
|
* @param value
|
|
@@ -84,6 +68,19 @@ let FormAbstractGroup = class FormAbstractGroup extends LitElement {
|
|
|
84
68
|
this._errors = errors;
|
|
85
69
|
}
|
|
86
70
|
}
|
|
71
|
+
constructor() {
|
|
72
|
+
super();
|
|
73
|
+
this.parentGroupName = '';
|
|
74
|
+
this.collapsed = false;
|
|
75
|
+
this.readonly = false;
|
|
76
|
+
this._errors = {};
|
|
77
|
+
this._value = {};
|
|
78
|
+
this.computedPath = [];
|
|
79
|
+
if (!this.language) {
|
|
80
|
+
this.language = window.localStorage.defaultLanguage || 'en';
|
|
81
|
+
}
|
|
82
|
+
this.handleLanguageChange = this.handleLanguageChange.bind(this);
|
|
83
|
+
}
|
|
87
84
|
connectedCallback() {
|
|
88
85
|
super.connectedCallback();
|
|
89
86
|
document.addEventListener('language-changed', this.handleLanguageChange.bind(this));
|
|
@@ -155,12 +152,12 @@ let FormAbstractGroup = class FormAbstractGroup extends LitElement {
|
|
|
155
152
|
const value = (this.value && this.value[groupStructure.name]) || [{}];
|
|
156
153
|
return html `
|
|
157
154
|
${value.map((_, index) => this.getGroupTemplate(groupStructure, index))}
|
|
158
|
-
<
|
|
155
|
+
<sl-button variant="primary" class="add-group save-button" @click="${() => this.addGroup(groupStructure.name)}">
|
|
159
156
|
${getTranslation(this.language, 'ADD')}
|
|
160
157
|
${!groupStructure.title || groupStructure.title.length > 15
|
|
161
158
|
? getTranslation(this.language, 'GROUP')
|
|
162
159
|
: groupStructure.title}
|
|
163
|
-
</
|
|
160
|
+
</sl-button>
|
|
164
161
|
`;
|
|
165
162
|
}
|
|
166
163
|
getGroupTemplate(groupStructure, index) {
|
|
@@ -302,6 +299,7 @@ let FormAbstractGroup = class FormAbstractGroup extends LitElement {
|
|
|
302
299
|
CardStyles,
|
|
303
300
|
FlexLayoutClasses,
|
|
304
301
|
FormBuilderCardStyles,
|
|
302
|
+
buttonsStyles,
|
|
305
303
|
css `
|
|
306
304
|
:host {
|
|
307
305
|
display: flex;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit
|
|
1
|
+
import { CSSResultArray, TemplateResult } from 'lit';
|
|
2
2
|
import { IFormBuilderCard } from '../lib/types/form-builder.interfaces';
|
|
3
3
|
import { FormAbstractGroup } from './form-abstract-group';
|
|
4
4
|
import { GenericObject } from '../lib/types/global.types';
|
|
5
|
-
import '@polymer/
|
|
5
|
+
import '@unicef-polymer/etools-unicef/src/etools-collapse/etools-collapse';
|
|
6
|
+
import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
|
|
7
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
6
8
|
export declare class FormCard extends FormAbstractGroup implements IFormBuilderCard {
|
|
7
9
|
protected _value: GenericObject;
|
|
8
10
|
/**
|
|
@@ -21,6 +23,7 @@ export declare class FormCard extends FormAbstractGroup implements IFormBuilderC
|
|
|
21
23
|
* Extends parent render method,
|
|
22
24
|
* adds card-container html wrapper and dynamic save button
|
|
23
25
|
*/
|
|
26
|
+
static get styles(): CSSResultArray;
|
|
24
27
|
render(): TemplateResult;
|
|
25
28
|
/**
|
|
26
29
|
* Updates value property, stops event propagation.
|
|
@@ -1,16 +1,15 @@
|
|
|
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, customElement } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
8
4
|
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
9
5
|
import { clone, equals } from 'ramda';
|
|
10
6
|
import { FormAbstractGroup } from './form-abstract-group';
|
|
11
|
-
import '@polymer/iron-collapse';
|
|
12
7
|
import { openDialog } from '../lib/utils/dialog';
|
|
13
8
|
import { getTranslation } from '../lib/utils/translate';
|
|
9
|
+
import '@unicef-polymer/etools-unicef/src/etools-collapse/etools-collapse';
|
|
10
|
+
import '@unicef-polymer/etools-unicef/src/etools-icons/etools-icon';
|
|
11
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
12
|
+
import { buttonsStyles } from '@unicef-polymer/etools-unicef/src/styles/button-styles';
|
|
14
13
|
let FormCard = class FormCard extends FormAbstractGroup {
|
|
15
14
|
constructor() {
|
|
16
15
|
super(...arguments);
|
|
@@ -39,6 +38,9 @@ let FormCard = class FormCard extends FormAbstractGroup {
|
|
|
39
38
|
* Extends parent render method,
|
|
40
39
|
* adds card-container html wrapper and dynamic save button
|
|
41
40
|
*/
|
|
41
|
+
static get styles() {
|
|
42
|
+
return [buttonsStyles];
|
|
43
|
+
}
|
|
42
44
|
render() {
|
|
43
45
|
return html `
|
|
44
46
|
<section class="elevation page-content card-container form-card" elevation="1">
|
|
@@ -53,18 +55,18 @@ let FormCard = class FormCard extends FormAbstractGroup {
|
|
|
53
55
|
${!this.groupStructure.title || this.groupStructure.title.length > 15
|
|
54
56
|
? getTranslation(this.language, 'GROUP')
|
|
55
57
|
: this.groupStructure.title}
|
|
56
|
-
<
|
|
58
|
+
<etools-icon-button class="attachments-warning" name="delete"></etools-icon-button>
|
|
57
59
|
</div>
|
|
58
60
|
</div>
|
|
59
61
|
${super.render()}
|
|
60
62
|
|
|
61
|
-
<
|
|
63
|
+
<etools-collapse ?opened="${this.showSaveButton}">
|
|
62
64
|
<div class="layout horizontal end-justified card-buttons actions-container">
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
>
|
|
65
|
+
<sl-button variant="primary" @click="${this.saveChanges}">
|
|
66
|
+
${getTranslation(this.language, 'SAVE')}
|
|
67
|
+
</sl-button>
|
|
66
68
|
</div>
|
|
67
|
-
</
|
|
69
|
+
</etools-collapse>
|
|
68
70
|
</section>
|
|
69
71
|
`;
|
|
70
72
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
2
|
import { IFormBuilderCard, IFormBuilderCollapsedCard } from '../lib/types/form-builder.interfaces';
|
|
3
3
|
import { FormAbstractGroup } from './form-abstract-group';
|
|
4
4
|
import '../lib/additional-components/etools-fb-card';
|
|
5
5
|
import { GenericObject } from '../lib/types/global.types';
|
|
6
6
|
import '../lib/additional-components/confirmation-dialog';
|
|
7
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
7
8
|
export declare class FormCollapsedCard extends FormAbstractGroup implements IFormBuilderCollapsedCard, IFormBuilderCard {
|
|
8
9
|
collapsed: boolean;
|
|
9
10
|
/**
|
|
@@ -11,8 +12,8 @@ export declare class FormCollapsedCard extends FormAbstractGroup implements IFor
|
|
|
11
12
|
* In collapsed card it must consider isEditMode property,
|
|
12
13
|
* components inside card are readonly if isEditMode is off or if card is readonly
|
|
13
14
|
*/
|
|
14
|
-
set
|
|
15
|
-
get
|
|
15
|
+
set setReadonly(state: boolean);
|
|
16
|
+
get getReadonly(): boolean;
|
|
16
17
|
protected isEditMode: boolean;
|
|
17
18
|
protected _readonly: boolean;
|
|
18
19
|
/**
|
|
@@ -1,10 +1,6 @@
|
|
|
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, customElement } from 'lit-element';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property, customElement } from 'lit/decorators.js';
|
|
8
4
|
import { clone } from 'ramda';
|
|
9
5
|
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
10
6
|
import { openDialog } from '../lib/utils/dialog';
|
|
@@ -12,6 +8,7 @@ import { FormAbstractGroup, StructureTypes } from './form-abstract-group';
|
|
|
12
8
|
import '../lib/additional-components/etools-fb-card';
|
|
13
9
|
import '../lib/additional-components/confirmation-dialog';
|
|
14
10
|
import { getTranslation } from '../lib/utils/translate';
|
|
11
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
15
12
|
const PARTNER_KEY = 'partner';
|
|
16
13
|
const OUTPUT_KEY = 'output';
|
|
17
14
|
const INTERVENTION_KEY = 'intervention';
|
|
@@ -29,10 +26,10 @@ let FormCollapsedCard = class FormCollapsedCard extends FormAbstractGroup {
|
|
|
29
26
|
* In collapsed card it must consider isEditMode property,
|
|
30
27
|
* components inside card are readonly if isEditMode is off or if card is readonly
|
|
31
28
|
*/
|
|
32
|
-
set
|
|
29
|
+
set setReadonly(state) {
|
|
33
30
|
this._readonly = state;
|
|
34
31
|
}
|
|
35
|
-
get
|
|
32
|
+
get getReadonly() {
|
|
36
33
|
return this._readonly || !this.isEditMode;
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
@@ -87,11 +84,12 @@ let FormCollapsedCard = class FormCollapsedCard extends FormAbstractGroup {
|
|
|
87
84
|
<!-- Open Attachments popup button -->
|
|
88
85
|
<div slot="actions" class="layout horizontal center">${this.getAdditionalButtons()}</div>
|
|
89
86
|
<div slot="postfix" class="layout horizontal center" ?hidden="${!this.groupStructure.repeatable}">
|
|
90
|
-
<
|
|
91
|
-
icon="close"
|
|
87
|
+
<etools-icon-button
|
|
92
88
|
class="attachments-warning"
|
|
89
|
+
name="close"
|
|
93
90
|
@click="${() => this.confirmRemove(this.groupStructure.title || getTranslation(this.language, 'THIS_GROUP'))}"
|
|
94
|
-
|
|
91
|
+
>
|
|
92
|
+
</etools-icon-button>
|
|
95
93
|
</div>
|
|
96
94
|
<div slot="content">${this.renderGroupChildren()}</div>
|
|
97
95
|
</etools-fb-card>
|
|
@@ -118,11 +116,14 @@ let FormCollapsedCard = class FormCollapsedCard extends FormAbstractGroup {
|
|
|
118
116
|
return hideAttachmentsButton
|
|
119
117
|
? html ``
|
|
120
118
|
: html `
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
<
|
|
119
|
+
<etools-icon id="attachments-warning" name="warning" ?hidden="${!this._errors.attachments}"></etools-icon>
|
|
120
|
+
<sl-button id="primary" variant="primary" @click="${this.openAttachmentsPopup}">
|
|
121
|
+
<etools-icon
|
|
122
|
+
slot="prefix"
|
|
123
|
+
name="${((_d = (_c = this.value) === null || _c === void 0 ? void 0 : _c.attachments) === null || _d === void 0 ? void 0 : _d.length) ? 'file-download' : 'file-upload'}"
|
|
124
|
+
></etools-icon>
|
|
124
125
|
${this.getAttachmentsBtnText((_f = (_e = this.value) === null || _e === void 0 ? void 0 : _e.attachments) === null || _f === void 0 ? void 0 : _f.length)}
|
|
125
|
-
</
|
|
126
|
+
</sl-button>
|
|
126
127
|
`;
|
|
127
128
|
}
|
|
128
129
|
retrieveTitle(target) {
|
|
@@ -149,7 +150,8 @@ let FormCollapsedCard = class FormCollapsedCard extends FormAbstractGroup {
|
|
|
149
150
|
* Only then we can reset all changed values to their original
|
|
150
151
|
*/
|
|
151
152
|
cancelEdit() {
|
|
152
|
-
this.requestUpdate()
|
|
153
|
+
this.requestUpdate();
|
|
154
|
+
this.updateComplete.then(() => {
|
|
153
155
|
this._value = clone(this.originalValue);
|
|
154
156
|
this.isEditMode = false;
|
|
155
157
|
});
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|