@unicef-polymer/etools-form-builder 3.1.4 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form-fields/abstract-field-base.class.js +2 -0
- package/dist/form-fields/single-fields/text-field.d.ts +3 -0
- package/dist/form-fields/single-fields/text-field.js +14 -0
- package/dist/rich-editor/rich-toolbar.d.ts +1 -0
- package/dist/rich-editor/rich-toolbar.js +7 -4
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ import { css, html, LitElement } from 'lit';
|
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { validate } from '../lib/utils/validations.helper';
|
|
5
5
|
import { FlexLayoutClasses } from '../lib/styles/flex-layout-classes';
|
|
6
|
+
import { fireEvent } from '../lib/utils/fire-custom-event';
|
|
6
7
|
/**
|
|
7
8
|
* Class that contains common properties and methods for single and repeatable fields
|
|
8
9
|
*/
|
|
@@ -10,6 +11,7 @@ export class AbstractFieldBaseClass extends LitElement {
|
|
|
10
11
|
set isReadonly(readonly) {
|
|
11
12
|
this._readonly = readonly;
|
|
12
13
|
this.setDefaultValue(readonly, this._defaultValue);
|
|
14
|
+
fireEvent(this, 'readonly-changed', { value: readonly });
|
|
13
15
|
this.requestUpdate();
|
|
14
16
|
}
|
|
15
17
|
get isReadonly() {
|
|
@@ -5,6 +5,9 @@ import '../../rich-editor/rich-text';
|
|
|
5
5
|
export declare class TextField extends BaseField<string> {
|
|
6
6
|
protected originalValue: string | null;
|
|
7
7
|
protected controlTemplate(): TemplateResult;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
handleReadonlyChange(_e: CustomEvent): void;
|
|
8
11
|
updated(changedProperties: PropertyValues): void;
|
|
9
12
|
protected customValidation(): string | null;
|
|
10
13
|
static get styles(): CSSResultArray;
|
|
@@ -39,6 +39,20 @@ let TextField = class TextField extends BaseField {
|
|
|
39
39
|
</etools-textarea>
|
|
40
40
|
`;
|
|
41
41
|
}
|
|
42
|
+
connectedCallback() {
|
|
43
|
+
super.connectedCallback();
|
|
44
|
+
document.addEventListener('readonly-changed', this.handleReadonlyChange.bind(this));
|
|
45
|
+
}
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
super.disconnectedCallback();
|
|
48
|
+
document.removeEventListener('readonly-changed', this.handleReadonlyChange.bind(this));
|
|
49
|
+
}
|
|
50
|
+
handleReadonlyChange(_e) {
|
|
51
|
+
// for rich editor need to reset the value here because of the logic below
|
|
52
|
+
if (this.showRichEditor && this.originalValue !== this.value) {
|
|
53
|
+
this.originalValue = this.value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
updated(changedProperties) {
|
|
43
57
|
super.updated(changedProperties);
|
|
44
58
|
// set control value only at the beginning with a proxy param (originalValue),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { property, customElement, query, state } from 'lit/decorators.js';
|
|
4
|
+
import '@unicef-polymer/etools-unicef/src/etools-icon-button/etools-icon-button';
|
|
4
5
|
import './rich-action';
|
|
5
6
|
import { editorCommand } from './rich-action';
|
|
6
7
|
import { getTranslation } from '../lib/utils/translate';
|
|
@@ -8,7 +9,6 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
8
9
|
render() {
|
|
9
10
|
const tags = this.getTags();
|
|
10
11
|
return html `<header>
|
|
11
|
-
<rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
|
|
12
12
|
<rich-action icon="editor:format-bold" command="bold" ?active=${tags.includes('b')}></rich-action>
|
|
13
13
|
<rich-action icon="editor:format-italic" command="italic" ?active=${tags.includes('i')}></rich-action>
|
|
14
14
|
<rich-action icon="editor:format-underlined" command="underline" ?active=${tags.includes('u')}></rich-action>
|
|
@@ -44,8 +44,9 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
44
44
|
<rich-action
|
|
45
45
|
icon="editor:format-color-text"
|
|
46
46
|
.color="${this.formatColor}"
|
|
47
|
-
@action=${() => this.
|
|
47
|
+
@action=${() => editorCommand('forecolor', this.formatColor)}
|
|
48
48
|
>
|
|
49
|
+
<etools-icon-button name="arrow-drop-down" @click="${() => this.fgColorInput.click()}"></etools-icon-button>
|
|
49
50
|
<input
|
|
50
51
|
type="color"
|
|
51
52
|
id="fg-color"
|
|
@@ -57,10 +58,11 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
57
58
|
/>
|
|
58
59
|
</rich-action>
|
|
59
60
|
<rich-action
|
|
60
|
-
icon="editor:
|
|
61
|
+
icon="editor:background-color"
|
|
61
62
|
.color="${this.backgroundColor}"
|
|
62
|
-
@action=${() => this.
|
|
63
|
+
@action=${() => editorCommand('backcolor', this.backgroundColor)}
|
|
63
64
|
>
|
|
65
|
+
<etools-icon-button name="arrow-drop-down" @click="${() => this.bdColorInput.click()}"></etools-icon-button>
|
|
64
66
|
<input
|
|
65
67
|
type="color"
|
|
66
68
|
id="bd-color"
|
|
@@ -102,6 +104,7 @@ let RichToolbar = class RichToolbar extends LitElement {
|
|
|
102
104
|
></rich-action>
|
|
103
105
|
<rich-action icon="undo" command="undo"></rich-action>
|
|
104
106
|
<rich-action icon="redo" command="redo"></rich-action>
|
|
107
|
+
<rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
|
|
105
108
|
<!-- <rich-action icon="content_cut" command="cut"></rich-action> -->
|
|
106
109
|
<!-- <rich-action icon="content_copy" command="copy"></rich-action>
|
|
107
110
|
<rich-action icon="content_paste" command="paste"></rich-action> -->
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unicef-polymer/etools-form-builder",
|
|
3
3
|
"description": "Etools FM Form Builder components",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"eTools Team"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"typescript": "^4.9.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@unicef-polymer/etools-unicef": ">=1.2.
|
|
35
|
+
"@unicef-polymer/etools-unicef": ">=1.2.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/eslintrc": "^3.2.0",
|
|
39
39
|
"@eslint/js": "^9.16.0",
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
41
41
|
"@typescript-eslint/parser": "^8.17.0",
|
|
42
|
-
"@unicef-polymer/etools-unicef": "^1.2.
|
|
42
|
+
"@unicef-polymer/etools-unicef": "^1.2.3",
|
|
43
43
|
"eslint": "^9.16.0",
|
|
44
44
|
"eslint-config-prettier": "^9.1.0",
|
|
45
45
|
"eslint-plugin-html": "^8.1.2",
|