@sankhyalabs/ezui 1.1.8 → 1.1.9
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/README.md +72 -72
- package/dist/cjs/{DataUnit-28b290cb.js → DataUnit-9a4a35ca.js} +415 -371
- package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
- package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1911
- package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
- package/dist/cjs/ez-modal.cjs.entry.js +104 -104
- package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
- package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
- package/dist/cjs/form-metadata.cjs.entry.js +65 -65
- package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
- package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
- package/dist/collection/components/ez-button/ez-button.css +94 -94
- package/dist/collection/components/ez-button/ez-button.js +125 -125
- package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
- package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
- package/dist/collection/components/ez-check/ez-check.css +265 -265
- package/dist/collection/components/ez-check/ez-check.js +168 -168
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
- package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
- package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
- package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
- package/dist/collection/components/ez-form/ez-form.css +19 -19
- package/dist/collection/components/ez-form/ez-form.js +368 -368
- package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
- package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
- package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +251 -207
- package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
- package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
- package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
- package/dist/collection/components/ez-icon/ez-icon.css +36 -36
- package/dist/collection/components/ez-icon/ez-icon.js +56 -56
- package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
- package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
- package/dist/collection/components/ez-modal/ez-modal.css +86 -86
- package/dist/collection/components/ez-modal/ez-modal.js +224 -224
- package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
- package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
- package/dist/collection/components/ez-popover/ez-popover.css +38 -38
- package/dist/collection/components/ez-popover/ez-popover.js +323 -323
- package/dist/collection/components/ez-search/ez-search.css +295 -295
- package/dist/collection/components/ez-search/ez-search.js +527 -527
- package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
- package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
- package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
- package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
- package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
- package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
- package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
- package/dist/collection/index.js +1 -1
- package/dist/collection/servidor.js +100 -100
- package/dist/collection/utils/FloatingManager.js +15 -15
- package/dist/collection/utils/utils.js +6 -6
- package/dist/custom-elements/index.js +3125 -3081
- package/dist/esm/{DataUnit-69e518fa.js → DataUnit-d5d4c9a3.js} +415 -371
- package/dist/esm/ez-action-chip.entry.js +41 -41
- package/dist/esm/ez-button_14.entry.js +1911 -1911
- package/dist/esm/ez-label-chip.entry.js +120 -120
- package/dist/esm/ez-modal.entry.js +104 -104
- package/dist/esm/ez-number-input.entry.js +236 -236
- package/dist/esm/ez-time-input.entry.js +168 -168
- package/dist/esm/form-metadata.entry.js +65 -65
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-b0974f4f.entry.js → p-0fcdfb51.entry.js} +1 -1
- package/dist/ezui/p-dac7a6c2.js +1 -0
- package/dist/ezui/{p-db11c600.entry.js → p-dbef7060.entry.js} +1 -1
- package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
- package/dist/types/components/ez-button/ez-button.d.ts +20 -20
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
- package/dist/types/components/ez-check/ez-check.d.ts +32 -32
- package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
- package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
- package/dist/types/components/ez-form/ez-form.d.ts +26 -31
- package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
- package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
- package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +60 -55
- package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
- package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
- package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
- package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
- package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
- package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
- package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
- package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
- package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
- package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
- package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
- package/dist/types/components/ez-search/ez-search.d.ts +95 -95
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +2 -2
- package/package.json +114 -114
- package/dist/ezui/p-10ef58b3.js +0 -1
- package/react/components.d.ts +0 -22
- package/react/components.js +0 -25
- package/react/components.js.map +0 -1
- package/react/react-component-lib/createComponent.d.ts +0 -10
- package/react/react-component-lib/createComponent.js +0 -59
- package/react/react-component-lib/createComponent.js.map +0 -1
- package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
- package/react/react-component-lib/createOverlayComponent.js +0 -89
- package/react/react-component-lib/createOverlayComponent.js.map +0 -1
- package/react/react-component-lib/index.d.ts +0 -2
- package/react/react-component-lib/index.js +0 -3
- package/react/react-component-lib/index.js.map +0 -1
- package/react/react-component-lib/interfaces.d.ts +0 -29
- package/react/react-component-lib/interfaces.js +0 -1
- package/react/react-component-lib/interfaces.js.map +0 -1
- package/react/react-component-lib/utils/attachProps.d.ts +0 -12
- package/react/react-component-lib/utils/attachProps.js +0 -96
- package/react/react-component-lib/utils/attachProps.js.map +0 -1
- package/react/react-component-lib/utils/case.d.ts +0 -2
- package/react/react-component-lib/utils/case.js +0 -7
- package/react/react-component-lib/utils/case.js.map +0 -1
- package/react/react-component-lib/utils/dev.d.ts +0 -2
- package/react/react-component-lib/utils/dev.js +0 -13
- package/react/react-component-lib/utils/dev.js.map +0 -1
- package/react/react-component-lib/utils/index.d.ts +0 -7
- package/react/react-component-lib/utils/index.js +0 -21
- package/react/react-component-lib/utils/index.js.map +0 -1
|
@@ -4,50 +4,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-9403fe8f.js');
|
|
6
6
|
const RequestMetadata = require('./RequestMetadata-2cd01e8a.js');
|
|
7
|
-
const DataUnit = require('./DataUnit-
|
|
7
|
+
const DataUnit = require('./DataUnit-9a4a35ca.js');
|
|
8
8
|
|
|
9
9
|
const ezButtonCss = ":host{--bt--min-width:100px;--bt--height:42px;--bt__icon--width:18px;--bt__inline__icon--padding:12px;--bt--padding-top:var(--space--medium, 12px);--bt--padding-bottom:var(--space--medium, 12px);--bt--padding-right:var(--space--large, 24px);--bt--padding-left:var(--space--large, 24px);--bt--color:var(--text--inverted, #FFF);--bt--font-size:var(--text--medium, 14px);--bt--font-family:var(--font-pattern, Arial);--bt--font-weight:var(--text-weight--large);--bt--background-color:var(--color--primary, #c0c0c0);--bt--border-radius:var(--border--radius-large, 12px);--bt--border:none;--bt--hover--background-color:var(--color--primary-700, var(--bt--background-color));--bt--disabled--color:var(--color--disable-primary, var(--bt--color));--bt--disabled--background-color:var(--color--disabled, var(--bt--background-color));--bt--focus--border:var(--bt--border);--bt--focus--box-shadow:none}button{display:flex;align-items:center;justify-content:center;margin:0;cursor:pointer;transition:background-color 0.2s linear;min-width:var(--bt--min-width);height:var(--bt--height);font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);padding:var(--bt--padding-top) var(--bt--padding-right) var(--bt--padding-bottom) var(--bt--padding-left);border-radius:var(--bt--border-radius);background-color:var(--bt--background-color);color:var(--bt--color);fill:var(--bt--color);border:var(--bt--border)}button:hover{background-color:var(--bt--hover--background-color)}button:focus{outline:none;border:var(--bt--focus--border);box-shadow:var(--bt--focus--box-shadow)}button:disabled{background-color:var(--bt--disabled--background-color);color:var(--bt--disabled--color);fill:var(--bt--disabled--color);border:none;cursor:no-drop}button.icon{width:42px;min-width:42px;height:42px;padding:0px}a{font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);cursor:pointer;display:flex;align-items:center;justify-content:center}";
|
|
10
10
|
|
|
11
|
-
const EzButton = class {
|
|
12
|
-
constructor(hostRef) {
|
|
13
|
-
index.registerInstance(this, hostRef);
|
|
14
|
-
/**
|
|
15
|
-
* Deixa o botão disponível ou não para interação com o usuário.
|
|
16
|
-
*/
|
|
17
|
-
this.enabled = true;
|
|
18
|
-
/**
|
|
19
|
-
* Define o modo de uso do botão; opções: icon, link e regular
|
|
20
|
-
*/
|
|
21
|
-
this.mode = "regular";
|
|
22
|
-
}
|
|
23
|
-
handleSlotChange(ev) {
|
|
24
|
-
const slot = ev.target;
|
|
25
|
-
const content = slot.assignedElements()[0];
|
|
26
|
-
if (this.mode == "link") {
|
|
27
|
-
content.style.display = "inline";
|
|
28
|
-
if (slot.name == "leftIcon") {
|
|
29
|
-
content.style.paddingRight = "var(--bt__inline__icon--padding)";
|
|
30
|
-
}
|
|
31
|
-
else if (slot.name == "rightIcon") {
|
|
32
|
-
content.style.paddingLeft = "var(--bt__inline__icon--padding)";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
render() {
|
|
37
|
-
if (this.mode == "icon") {
|
|
38
|
-
return (index.h("button", { class: "icon", type: "button", disabled: !this.enabled }, index.h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
|
|
39
|
-
if (!this.enabled)
|
|
40
|
-
evt.stopPropagation();
|
|
41
|
-
} })));
|
|
42
|
-
}
|
|
43
|
-
else if (this.mode == "link") {
|
|
44
|
-
return (index.h("a", null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return (index.h("button", { type: "button", disabled: !this.enabled }, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
11
|
+
const EzButton = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
/**
|
|
15
|
+
* Deixa o botão disponível ou não para interação com o usuário.
|
|
16
|
+
*/
|
|
17
|
+
this.enabled = true;
|
|
18
|
+
/**
|
|
19
|
+
* Define o modo de uso do botão; opções: icon, link e regular
|
|
20
|
+
*/
|
|
21
|
+
this.mode = "regular";
|
|
22
|
+
}
|
|
23
|
+
handleSlotChange(ev) {
|
|
24
|
+
const slot = ev.target;
|
|
25
|
+
const content = slot.assignedElements()[0];
|
|
26
|
+
if (this.mode == "link") {
|
|
27
|
+
content.style.display = "inline";
|
|
28
|
+
if (slot.name == "leftIcon") {
|
|
29
|
+
content.style.paddingRight = "var(--bt__inline__icon--padding)";
|
|
30
|
+
}
|
|
31
|
+
else if (slot.name == "rightIcon") {
|
|
32
|
+
content.style.paddingLeft = "var(--bt__inline__icon--padding)";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
if (this.mode == "icon") {
|
|
38
|
+
return (index.h("button", { class: "icon", type: "button", disabled: !this.enabled }, index.h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
|
|
39
|
+
if (!this.enabled)
|
|
40
|
+
evt.stopPropagation();
|
|
41
|
+
} })));
|
|
42
|
+
}
|
|
43
|
+
else if (this.mode == "link") {
|
|
44
|
+
return (index.h("a", null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return (index.h("button", { type: "button", disabled: !this.enabled }, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
51
|
EzButton.style = ezButtonCss;
|
|
52
52
|
|
|
53
53
|
class FloatingEntry {
|
|
@@ -197,439 +197,439 @@ class DateUtils {
|
|
|
197
197
|
|
|
198
198
|
const ezCalendarCss = ":host{--cal--font-family:var(--font-pattern, Arial);--cal--color:var(--title--primary, #626e82);--cal--text-shadow:var(--text-shadow, 0 0 0 #353535,0 0 1px transparent);--cal__body--background-color:var(--background--xlight, #FFF);--cal__body--padding:var(--space--medium, 12px);--cal__body--border-radius:var(--border--radius-medium, 12px);--cal__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--cal__header-line--stroke:2px;--cal__header-line--color:var(--color--strokes, #C0C0C0);--cal__nav-btn--fill:var(--text--primary, #008561);--cal__nav-btn--over--fill:var(--color--primary, #350404);--cal__nav-btn--width:10px;--cal__nav-btn--height:16px;--cal__nav-btn--previous-path:path(\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\");--cal__nav-btn--next-path:path(\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\");--cal__cell--margin:0px var(--space--small, 12px);--cal__cell--width:var(--space--large, 24px);--cal__cell--padding:var(--space--extra-small, 3px) 0px;--cal__cell--border-radius:var(--border--radius-small, 6px);--cal__cell--over--background-color:var(--color--strokes, #C0C0C0);--cal__cell--outset--color:var(--color--strokes, #C0C0C0);--cal__cell--selected--background-color:var(--color--primary, #008561);--cal__cell--selected--color:var(--color--inverted, #FFF);--cal__btn-today--color:var(--color--primary);--cal__btn-today--hover--background-color:var(--color--strokes, #C0C0C0);--cal__btn-today--border-radius:var(--border--radius-small, 6px);position:relative;display:flex;user-select:none}.calendar{z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--cal__body--background-color);padding:var(--cal__body--padding);border-radius:var(--cal__body--border-radius);box-shadow:var(--cal__body--shadow)}.calendar__header{display:flex;justify-content:space-between;padding-bottom:var(--space--medium, 12px);margin:var(--space--small, 6px) var(--space--, 12px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);border-bottom:solid var(--cal__header-line--stroke) var(--cal__header-line--color)}.calendar__btn-next,.calendar__btn-previous{outline:none;border:none;background-color:unset;cursor:pointer;padding:0px}.calendar__btn-next::after,.calendar__btn-previous::after{content:'';display:flex;background-color:var(--cal__nav-btn--fill);width:var(--cal__nav-btn--width);height:var(--cal__nav-btn--height)}.calendar__btn-previous::after{clip-path:var(--cal__nav-btn--previous-path)}.calendar__btn-next::after{clip-path:var(--cal__nav-btn--next-path)}.calendar__btn-next:hover::after,.calendar__btn-previous:hover::after{background-color:var(--cal__nav-btn--over--fill)}.calendar__lbl-month{font-weight:var(--text-weight--large, 600);font-size:var(--title--medium, 16px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow)}.calendar__line{display:flex;padding:0px;margin:0px}.calendar__cell{display:flex;justify-content:center;align-content:center;cursor:pointer;font-size:var(--text--small, 12px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);padding:var(--cal__cell--padding);margin:var(--cal__cell--margin);min-width:var(--cal__cell--width);border-radius:var(--cal__cell--border-radius)}.calendar__cell:hover{background-color:var(--cal__cell--over--background-color)}.calendar__cell--secondary{color:var(--cal__cell--outset--color)}.calendar__cell--unselectable:hover{background-color:unset;border-radius:unset;cursor:unset}.calendar__cell--unselectable{font-weight:var(--text-weight--large, 600);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow)}.calendar__cell--selected,.calendar__cell--selected:hover{background-color:var(--cal__cell--selected--background-color);color:var(--cal__cell--selected--color)}.calendar__body{padding:var(--space--small, 6px) 0px}.calendar__footer{display:flex;flex-direction:column}.calendar__btn-today{border:none;background-color:unset;cursor:pointer;font-weight:var(--text-weight--large, 600);font-size:var(--title--small);padding:var(--space--extra-small, 6px);font-family:var(--cal--font-family);text-shadow:var(--cal--text-shadow);color:var(--cal__btn-today--color);border-radius:var(--cal__btn-today--border-radius)}.calendar__btn-today:hover{background-color:var(--cal__btn-today--hover--background-color)}";
|
|
199
199
|
|
|
200
|
-
const EzCalendar = class {
|
|
201
|
-
constructor(hostRef) {
|
|
202
|
-
index.registerInstance(this, hostRef);
|
|
203
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
204
|
-
this._firstRender = true;
|
|
205
|
-
this._todayLabel = 'Hoje';
|
|
206
|
-
this._weekDayLabels = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];
|
|
207
|
-
this._monthLabels = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
|
|
208
|
-
/**
|
|
209
|
-
* A data selecionada no calendário
|
|
210
|
-
*/
|
|
211
|
-
this.value = new Date();
|
|
212
|
-
/**
|
|
213
|
-
* No modo floating o calendário só se tornará visível
|
|
214
|
-
* quando o método show() for acionado.
|
|
215
|
-
*/
|
|
216
|
-
this.floating = false;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Usado no modo floating. Faz com que o componente seja exibido.
|
|
220
|
-
* É possível determinar ajustes de posicionamento através dos parâmetros
|
|
221
|
-
* top, left, bottom e right. Esses parâmetros devem ser informados como
|
|
222
|
-
* strings no formato css.
|
|
223
|
-
*/
|
|
224
|
-
async show(top, left, bottom, right) {
|
|
225
|
-
if (this.floating) {
|
|
226
|
-
this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Usado no modo floating. Faz com que o componente seja ocultado.
|
|
231
|
-
*/
|
|
232
|
-
async hide() {
|
|
233
|
-
if (this._floatingID !== undefined) {
|
|
234
|
-
FloatingManager.close(this._floatingID);
|
|
235
|
-
this._floatingID = undefined;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
valueChanged() {
|
|
239
|
-
if (this.value) {
|
|
240
|
-
this._currentPosition.setTime(this.value.getTime());
|
|
241
|
-
this._currentPosition.setDate(1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
getMonthLabel() {
|
|
245
|
-
return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
|
|
246
|
-
}
|
|
247
|
-
isSelectedDate(d) {
|
|
248
|
-
if (this.value) {
|
|
249
|
-
return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
changeMonth(offset) {
|
|
254
|
-
this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
|
|
255
|
-
index.forceUpdate(this);
|
|
256
|
-
}
|
|
257
|
-
selectDate(d) {
|
|
258
|
-
this.value = d;
|
|
259
|
-
this.ezChange.emit();
|
|
260
|
-
}
|
|
261
|
-
componentDidRender() {
|
|
262
|
-
if (this.floating && this._firstRender) {
|
|
263
|
-
this._box.remove();
|
|
264
|
-
this._firstRender = false;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
render() {
|
|
268
|
-
if (this._currentPosition == null) {
|
|
269
|
-
this._currentPosition = new Date();
|
|
270
|
-
this._currentPosition.setTime(this.value.getTime());
|
|
271
|
-
this._currentPosition.setDate(1);
|
|
272
|
-
}
|
|
273
|
-
const firstDate = new Date();
|
|
274
|
-
firstDate.setTime(this._currentPosition.getTime());
|
|
275
|
-
firstDate.setDate(1 - firstDate.getDay());
|
|
276
|
-
return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { class: "calendar", ref: elem => this._box = elem }, index.h("div", { class: "calendar__header" }, index.h("button", { class: "calendar__btn-previous", onClick: () => this.changeMonth(-1) }), index.h("label", { class: "calendar__lbl-month" }, this.getMonthLabel()), index.h("button", { class: "calendar__btn-next", onClick: () => this.changeMonth(1) })), index.h("div", { class: "calendar__body" }, index.h("div", { class: "calendar__line" }, this._weekDayLabels.map(day => index.h("div", { class: "calendar__cell calendar__cell--unselectable" }, day))), [0, 7, 14, 21, 28, 35].map(offset => index.h("div", { class: "calendar__line" }, [0, 1, 2, 3, 4, 5, 6].map(index$1 => {
|
|
277
|
-
const date = new Date();
|
|
278
|
-
date.setTime(firstDate.getTime());
|
|
279
|
-
date.setDate(date.getDate() + offset + index$1);
|
|
280
|
-
let classNames = "calendar__cell";
|
|
281
|
-
if (this._currentPosition.getMonth() != date.getMonth()) {
|
|
282
|
-
classNames += " calendar__cell--secondary";
|
|
283
|
-
}
|
|
284
|
-
else if (this.isSelectedDate(date)) {
|
|
285
|
-
classNames += " calendar__cell--selected";
|
|
286
|
-
}
|
|
287
|
-
return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
|
|
288
|
-
})))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
|
|
289
|
-
}
|
|
290
|
-
static get watchers() { return {
|
|
291
|
-
"value": ["valueChanged"]
|
|
292
|
-
}; }
|
|
293
|
-
};
|
|
200
|
+
const EzCalendar = class {
|
|
201
|
+
constructor(hostRef) {
|
|
202
|
+
index.registerInstance(this, hostRef);
|
|
203
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
204
|
+
this._firstRender = true;
|
|
205
|
+
this._todayLabel = 'Hoje';
|
|
206
|
+
this._weekDayLabels = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];
|
|
207
|
+
this._monthLabels = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
|
|
208
|
+
/**
|
|
209
|
+
* A data selecionada no calendário
|
|
210
|
+
*/
|
|
211
|
+
this.value = new Date();
|
|
212
|
+
/**
|
|
213
|
+
* No modo floating o calendário só se tornará visível
|
|
214
|
+
* quando o método show() for acionado.
|
|
215
|
+
*/
|
|
216
|
+
this.floating = false;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Usado no modo floating. Faz com que o componente seja exibido.
|
|
220
|
+
* É possível determinar ajustes de posicionamento através dos parâmetros
|
|
221
|
+
* top, left, bottom e right. Esses parâmetros devem ser informados como
|
|
222
|
+
* strings no formato css.
|
|
223
|
+
*/
|
|
224
|
+
async show(top, left, bottom, right) {
|
|
225
|
+
if (this.floating) {
|
|
226
|
+
this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Usado no modo floating. Faz com que o componente seja ocultado.
|
|
231
|
+
*/
|
|
232
|
+
async hide() {
|
|
233
|
+
if (this._floatingID !== undefined) {
|
|
234
|
+
FloatingManager.close(this._floatingID);
|
|
235
|
+
this._floatingID = undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
valueChanged() {
|
|
239
|
+
if (this.value) {
|
|
240
|
+
this._currentPosition.setTime(this.value.getTime());
|
|
241
|
+
this._currentPosition.setDate(1);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
getMonthLabel() {
|
|
245
|
+
return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
|
|
246
|
+
}
|
|
247
|
+
isSelectedDate(d) {
|
|
248
|
+
if (this.value) {
|
|
249
|
+
return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
changeMonth(offset) {
|
|
254
|
+
this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
|
|
255
|
+
index.forceUpdate(this);
|
|
256
|
+
}
|
|
257
|
+
selectDate(d) {
|
|
258
|
+
this.value = d;
|
|
259
|
+
this.ezChange.emit();
|
|
260
|
+
}
|
|
261
|
+
componentDidRender() {
|
|
262
|
+
if (this.floating && this._firstRender) {
|
|
263
|
+
this._box.remove();
|
|
264
|
+
this._firstRender = false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
render() {
|
|
268
|
+
if (this._currentPosition == null) {
|
|
269
|
+
this._currentPosition = new Date();
|
|
270
|
+
this._currentPosition.setTime(this.value.getTime());
|
|
271
|
+
this._currentPosition.setDate(1);
|
|
272
|
+
}
|
|
273
|
+
const firstDate = new Date();
|
|
274
|
+
firstDate.setTime(this._currentPosition.getTime());
|
|
275
|
+
firstDate.setDate(1 - firstDate.getDay());
|
|
276
|
+
return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { class: "calendar", ref: elem => this._box = elem }, index.h("div", { class: "calendar__header" }, index.h("button", { class: "calendar__btn-previous", onClick: () => this.changeMonth(-1) }), index.h("label", { class: "calendar__lbl-month" }, this.getMonthLabel()), index.h("button", { class: "calendar__btn-next", onClick: () => this.changeMonth(1) })), index.h("div", { class: "calendar__body" }, index.h("div", { class: "calendar__line" }, this._weekDayLabels.map(day => index.h("div", { class: "calendar__cell calendar__cell--unselectable" }, day))), [0, 7, 14, 21, 28, 35].map(offset => index.h("div", { class: "calendar__line" }, [0, 1, 2, 3, 4, 5, 6].map(index$1 => {
|
|
277
|
+
const date = new Date();
|
|
278
|
+
date.setTime(firstDate.getTime());
|
|
279
|
+
date.setDate(date.getDate() + offset + index$1);
|
|
280
|
+
let classNames = "calendar__cell";
|
|
281
|
+
if (this._currentPosition.getMonth() != date.getMonth()) {
|
|
282
|
+
classNames += " calendar__cell--secondary";
|
|
283
|
+
}
|
|
284
|
+
else if (this.isSelectedDate(date)) {
|
|
285
|
+
classNames += " calendar__cell--selected";
|
|
286
|
+
}
|
|
287
|
+
return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
|
|
288
|
+
})))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
|
|
289
|
+
}
|
|
290
|
+
static get watchers() { return {
|
|
291
|
+
"value": ["valueChanged"]
|
|
292
|
+
}; }
|
|
293
|
+
};
|
|
294
294
|
EzCalendar.style = ezCalendarCss;
|
|
295
295
|
|
|
296
296
|
const ezCheckCss = ":host{--chk--box--width:18px;--chk--box--height:18px;--chk--width:calc(var(--chk--box--width) + 14px);--chk--height:calc(var(--chk--box--width) + 14px);--chk--border-radius:var(--border--radius-small);--chk--checked--background-color:var(--color--primary-200);--chk--focus--background-color:var(--color--strokes, #FFFFFF);--chk--hover--background-color:var(--background--medium);--chk--checked--disabled--background-color:var(--color--disable-secondary);--chk--border:var(--border--medium) var(--title--primary);--chk--disabled--border:var(--border--medium) var(--color--strokes);--chk--checked--border:var(--border--medium) var(--color--primary);--chk--checked--hover--background-color:var(--color--primary-200);--chk--checked--focus--background-color:var(--color--primary-300, #FFFFFF);--chk--check--clip-path:polygon(40% 70%, 46% 73%, 51% 71%, 93% 21%, 93% 16%, 83% 8%, 76% 9%, 47% 45%, 43% 44%, 38% 39%, 30% 37%, 22% 47%, 23% 54%, 40% 70%);--chk--check--background-color:var(--color--primary);--chk--check--disabled--background-color:var(--color--strokes);--swt--slider--width:34px;--swt--slider--height:14px;--swt--pin--width:20px;--swt--pin--height:20px;--swt--focus--width:32px;--swt--focus--height:32px;--swt--background-color:var(--color--strokes);--swt--disabled--background-color:var(--color--disable-secondary);--swt--checked--background-color:var(--color--primary-300);--swt--pin--background-color:var(--background--xlight);--swt--pin--disabled--background-color:var(--color--disable-secondary);--swt--pin--checked--background-color:var(--color--primary);--swt--pin--checked--disabled--background-color:#E8F7F4;--swt--pin--focus--background-color:var(--text--disable);--swt--pin--checked--focus--background-color:var(--color--primary);width:100%}input.regularMode{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;box-sizing:border-box;-webkit-appearance:none;cursor:pointer;border-radius:50%;width:var(--chk--width);height:var(--chk--height)}input.regularMode:enabled:hover{background-color:var(--chk--hover--background-color)}input.regularMode:enabled:focus{outline:none;background-color:var(--chk--focus--background-color)}input.regularMode:disabled{cursor:auto;background:none}input.regularMode::before{box-sizing:border-box;content:\"\";display:block;width:var(--chk--box--width);height:var(--chk--box--height);border-radius:var(--chk--border-radius);border:var(--chk--border)}input.regularMode:disabled::before{border:var(--chk--disabled--border)}input.regularMode:checked:enabled:hover{background-color:var(--chk--checked--hover--background-color)}input.regularMode:checked:enabled:focus{background-color:var(--chk--checked--focus--background-color)}input.regularMode:checked::before{border:var(--chk--checked--border);background-color:var(--chk--checked--background-color)}input.regularMode:checked:disabled:before{border:var(--chk--disabled--border);background-color:var(--chk--checked--disabled--background-color)}input.regularMode:checked::after{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;content:\"\";position:absolute;margin-top:3px;margin-left:-1px;width:12px;height:12px;background-color:var(--chk--check--background-color);clip-path:var(--chk--check--clip-path)}input.regularMode:checked:disabled::after{background-color:var(--chk--check--disabled--background-color)}input.switchMode{appearance:none;position:relative;outline:none;cursor:pointer;border-radius:20px;border:none;transition:background-color var(--transition);width:var(--swt--slider--width);height:var(--swt--slider--height);background-color:var(--swt--background-color)}input.switchMode:disabled{background-color:var(--swt--disabled--background-color)}input.switchMode::after{content:\"\";display:block;position:absolute;box-shadow:var(--shadow);transition:transform var(--transition);transition:background-color var(--transition);transform:translateY(-3px);border-radius:50%;width:var(--swt--pin--width);height:var(--swt--pin--height);background-color:var(--swt--pin--background-color)}input.switchMode:disabled::after{background-color:var(--swt--pin--disabled--background-color)}input.switchMode:checked{transition:background-color var(--transition);background-color:var(--swt--checked--background-color)}input.switchMode::before{display:block;content:\"\";display:block;position:absolute;border-radius:50%;opacity:0;width:var(--swt--focus--width);height:var(--swt--focus--height);top:calc((var(--swt--slider--height) - var(--swt--focus--height)) / 2);left:calc((var(--swt--pin--width) - var(--swt--focus--width))/2);background-color:var(--swt--pin--focus--background-color)}input.switchMode:focus::before{opacity:0.24;transition:opacity var(--transition)}input.switchMode:checked:focus::before{background-color:var(--swt--pin--checked--focus--background-color);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width)))}input.switchMode:checked::after{transition:transform var(--transition);transition:background-color var(--transition);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width))) translateY(-3px);box-shadow:var(--shadow);background-color:var(--swt--pin--checked--background-color)}input.switchMode:checked:disabled::after{background-color:var(--swt--pin--checked--disabled--background-color)}";
|
|
297
297
|
|
|
298
|
-
const EzCheck = class {
|
|
299
|
-
constructor(hostRef) {
|
|
300
|
-
index.registerInstance(this, hostRef);
|
|
301
|
-
this.valueChange = index.createEvent(this, "valueChange", 7);
|
|
302
|
-
/**
|
|
303
|
-
* Deixa o campo disponível ou não interagir com o usuário.
|
|
304
|
-
*/
|
|
305
|
-
this.enabled = true;
|
|
306
|
-
/**
|
|
307
|
-
* Existem dois modos de visualização: regular e switch.
|
|
308
|
-
* Se esta propriedade for omitida, o componete assume o formato "regular";
|
|
309
|
-
* No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
|
|
310
|
-
* No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
|
|
311
|
-
*/
|
|
312
|
-
this.mode = "regular";
|
|
313
|
-
}
|
|
314
|
-
adjustMode() {
|
|
315
|
-
if (this.mode === "switch") {
|
|
316
|
-
this._inputElem.classList.remove("regularMode");
|
|
317
|
-
this._inputElem.classList.add("switchMode");
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
this._inputElem.classList.remove("switchMode");
|
|
321
|
-
this._inputElem.classList.add("regularMode");
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
//---------------------------------------------
|
|
325
|
-
// Public methods
|
|
326
|
-
//---------------------------------------------
|
|
327
|
-
/**
|
|
328
|
-
* Devolve o modo escolhido para o componente
|
|
329
|
-
*/
|
|
330
|
-
async getMode() {
|
|
331
|
-
return this.mode;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Faz o foco no componente de input
|
|
335
|
-
*/
|
|
336
|
-
async setFocus() {
|
|
337
|
-
this._inputElem.focus();
|
|
338
|
-
}
|
|
339
|
-
componentDidLoad() {
|
|
340
|
-
this.adjustMode();
|
|
341
|
-
}
|
|
342
|
-
changeValue() {
|
|
343
|
-
this.value = !this.value;
|
|
344
|
-
this.valueChange.emit();
|
|
345
|
-
}
|
|
346
|
-
render() {
|
|
347
|
-
return (index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }));
|
|
348
|
-
}
|
|
349
|
-
static get watchers() { return {
|
|
350
|
-
"mode": ["adjustMode"]
|
|
351
|
-
}; }
|
|
352
|
-
};
|
|
298
|
+
const EzCheck = class {
|
|
299
|
+
constructor(hostRef) {
|
|
300
|
+
index.registerInstance(this, hostRef);
|
|
301
|
+
this.valueChange = index.createEvent(this, "valueChange", 7);
|
|
302
|
+
/**
|
|
303
|
+
* Deixa o campo disponível ou não interagir com o usuário.
|
|
304
|
+
*/
|
|
305
|
+
this.enabled = true;
|
|
306
|
+
/**
|
|
307
|
+
* Existem dois modos de visualização: regular e switch.
|
|
308
|
+
* Se esta propriedade for omitida, o componete assume o formato "regular";
|
|
309
|
+
* No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
|
|
310
|
+
* No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
|
|
311
|
+
*/
|
|
312
|
+
this.mode = "regular";
|
|
313
|
+
}
|
|
314
|
+
adjustMode() {
|
|
315
|
+
if (this.mode === "switch") {
|
|
316
|
+
this._inputElem.classList.remove("regularMode");
|
|
317
|
+
this._inputElem.classList.add("switchMode");
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
this._inputElem.classList.remove("switchMode");
|
|
321
|
+
this._inputElem.classList.add("regularMode");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
//---------------------------------------------
|
|
325
|
+
// Public methods
|
|
326
|
+
//---------------------------------------------
|
|
327
|
+
/**
|
|
328
|
+
* Devolve o modo escolhido para o componente
|
|
329
|
+
*/
|
|
330
|
+
async getMode() {
|
|
331
|
+
return this.mode;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Faz o foco no componente de input
|
|
335
|
+
*/
|
|
336
|
+
async setFocus() {
|
|
337
|
+
this._inputElem.focus();
|
|
338
|
+
}
|
|
339
|
+
componentDidLoad() {
|
|
340
|
+
this.adjustMode();
|
|
341
|
+
}
|
|
342
|
+
changeValue() {
|
|
343
|
+
this.value = !this.value;
|
|
344
|
+
this.valueChange.emit();
|
|
345
|
+
}
|
|
346
|
+
render() {
|
|
347
|
+
return (index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }));
|
|
348
|
+
}
|
|
349
|
+
static get watchers() { return {
|
|
350
|
+
"mode": ["adjustMode"]
|
|
351
|
+
}; }
|
|
352
|
+
};
|
|
353
353
|
EzCheck.style = ezCheckCss;
|
|
354
354
|
|
|
355
355
|
const ezCollapsableBoxCss = ":host{--collapsable-box--height:42px;--collapsable-box--font-size:var(--title--medium, 14px);--collapsable-box--font-family:var(--font-pattern, Arial);--collapsable-box--font-weight:var(--text-weight--large, 600);--collapsable-box--color:var(--title--primary);--collapsable-box__btn--path:path(\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\");--collapsable-box__btn--fill:var(--collapsable-box--color);--collapsable-box__btn--width:10px;--collapsable-box__btn--height:16px;display:flex;flex-wrap:wrap;width:100%}.collapsable-box__title{width:100%;display:flex;box-sizing:border-box}.collapsable-box__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;font-family:var(--collapsable-box--font-family);font-size:var(--collapsable-box--font-size);font-weight:var(--collapsable-box--font-weight);color:var(--collapsable-box--color)}.collapsable-box__btn{outline:none;border:none;background-color:unset;cursor:pointer;padding:1px 6px}.collapsable-box__btn::after{content:'';display:flex;clip-path:var(--collapsable-box__btn--path);background-color:var( --collapsable-box__btn--fill);width:var(--collapsable-box__btn--width);height:var(--collapsable-box__btn--height);transition:transform var(--transition);transform:rotate(90deg)}.collapsable-box__btn--collapsed::after{transform:rotate(0deg)}";
|
|
356
356
|
|
|
357
|
-
const EzCollapsableBox = class {
|
|
358
|
-
constructor(hostRef) {
|
|
359
|
-
index.registerInstance(this, hostRef);
|
|
360
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
361
|
-
/**
|
|
362
|
-
* Valor externalizado que garante a exibição ou não do componente
|
|
363
|
-
*/
|
|
364
|
-
this.value = false;
|
|
365
|
-
}
|
|
366
|
-
observeValue() {
|
|
367
|
-
this.ezChange.emit();
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Esconde ou revela o conteúdo do componente
|
|
371
|
-
*/
|
|
372
|
-
async showHide() {
|
|
373
|
-
this.value = !this.value;
|
|
374
|
-
}
|
|
375
|
-
render() {
|
|
376
|
-
return (index.h(index.Host, null, index.h("div", { class: "collapsable-box__title" }, index.h("button", { class: this.value ? "collapsable-box__btn collapsable-box__btn--collapsed" : "collapsable-box__btn", onClick: () => this.showHide() }), index.h("label", { class: "collapsable-box__label", title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
|
|
377
|
-
}
|
|
378
|
-
static get watchers() { return {
|
|
379
|
-
"value": ["observeValue"]
|
|
380
|
-
}; }
|
|
381
|
-
};
|
|
357
|
+
const EzCollapsableBox = class {
|
|
358
|
+
constructor(hostRef) {
|
|
359
|
+
index.registerInstance(this, hostRef);
|
|
360
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
361
|
+
/**
|
|
362
|
+
* Valor externalizado que garante a exibição ou não do componente
|
|
363
|
+
*/
|
|
364
|
+
this.value = false;
|
|
365
|
+
}
|
|
366
|
+
observeValue() {
|
|
367
|
+
this.ezChange.emit();
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Esconde ou revela o conteúdo do componente
|
|
371
|
+
*/
|
|
372
|
+
async showHide() {
|
|
373
|
+
this.value = !this.value;
|
|
374
|
+
}
|
|
375
|
+
render() {
|
|
376
|
+
return (index.h(index.Host, null, index.h("div", { class: "collapsable-box__title" }, index.h("button", { class: this.value ? "collapsable-box__btn collapsable-box__btn--collapsed" : "collapsable-box__btn", onClick: () => this.showHide() }), index.h("label", { class: "collapsable-box__label", title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
|
|
377
|
+
}
|
|
378
|
+
static get watchers() { return {
|
|
379
|
+
"value": ["observeValue"]
|
|
380
|
+
}; }
|
|
381
|
+
};
|
|
382
382
|
EzCollapsableBox.style = ezCollapsableBoxCss;
|
|
383
383
|
|
|
384
384
|
const ezComboBoxCss = ":host{--cx--height:42px;--cx--width:100%;--cx__icon--width:48px;--cx--border-radius:var(--border--radius-medium, 12px);--cx--border-radius-small:var(--border--radius-small, 6px);--cx--font-size:var(--text--medium, 14px);--cx--font-family:var(--font-pattern, Arial);--cx--font-weight--large:var(--text-weight--large, 500);--cx--font-weight--medium:var(--text-weight--medium, 400);--cx--space--medium:var(--space--medium, 12px);--cx--space--small:var(--space--small, 6px);--cx--shadow:var(--shadow, 0px 0px 16px 0px rgba(0, 38, 111, .12));--cx--background-color--xlight:var(--background--xlight,#fff);--cx__input--background-color:var(--background--medium, #e0e0e0);--cx__input--border:var(--border--medium, 2px solid);--cx__input--border-color:var(--cx__input--background-color);--cx__input--focus--border-color:var(--color--primary, #008561);--cx__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--cx__input--disabled--color:var(--text--disable, #AFB6C0);--cx__input--error--border-color:#CC2936;--cx__label--color:var(--title--primary, #919191);--cx__message_box--font-size:var(--text--small, 12px);--cx__message_box--info--color:var(--color--success, #22085d);--cx__message_box--error--color:var(--color--error, #FF0000);--cx__list-text--primary:var(--text--primary,#626e82);--cx__list-text--secondary:var(--text--secondary,#a2abb9);--cx__list-height:calc(var(--cx--font-size) + var(--cx--space--medium));display:flex;flex-wrap:wrap;position:relative;width:var(--cx--width)}ez-text-input{--it__input--background-color:var(--cx__input--background-color, #FFFFFF);--it__input--border-color:var(--cx__input--border-color, #DCE0E8)}.invisible{visibility:hidden}.list-container{scroll-behavior:smooth;z-index:var(--cx__list-z-index);padding:var(--cx--space--small);background:var(--cx--background-color--xlight);border-radius:var(--cx--border-radius);width:100%;overflow:auto;box-sizing:border-box;max-height:calc(4*var(--cx__list-height) + 2*var(--cx--space--small))}li{list-style-type:none;border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);display:flex;justify-content:space-between;align-items:center}li:hover{background-color:var(--background--medium)}.--li--preselected{background-color:var(--background--strong)}.--li__spanlabel{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:80%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanlabel--full-width{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:100%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanvalue{color:var(--cx__list-text--secondary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--medium);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:20%;min-width:20px;overflow-x:hidden;text-align:left}.btn-open-options{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-options:disabled{cursor:unset}.btn-open-options::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:16px;height:16px;clip-path:path(\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\")}.btn-open-options:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-options:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
|
|
385
385
|
|
|
386
|
-
const EzComboBox = class {
|
|
387
|
-
constructor(hostRef) {
|
|
388
|
-
index.registerInstance(this, hostRef);
|
|
389
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
390
|
-
this._inputLabelValue = '';
|
|
391
|
-
/**
|
|
392
|
-
* Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
|
|
393
|
-
* Pode ser Label ou Value de acordo com a opção "labelasindex"
|
|
394
|
-
* Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
|
|
395
|
-
* (executo pala valor undefined)
|
|
396
|
-
*/
|
|
397
|
-
this.value = undefined;
|
|
398
|
-
/**
|
|
399
|
-
* Label é o título do campo
|
|
400
|
-
*/
|
|
401
|
-
this.label = undefined;
|
|
402
|
-
/**
|
|
403
|
-
* Deixa o campo disponível ou não para digitação.
|
|
404
|
-
*/
|
|
405
|
-
this.enabled = true;
|
|
406
|
-
/**
|
|
407
|
-
* Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
|
|
408
|
-
*/
|
|
409
|
-
this.showvalue = false;
|
|
410
|
-
}
|
|
411
|
-
//---------------------------------------------
|
|
412
|
-
// Public methods
|
|
413
|
-
//---------------------------------------------
|
|
414
|
-
/**
|
|
415
|
-
* Faz o foco no componente de textarea
|
|
416
|
-
*/
|
|
417
|
-
async setFocus() {
|
|
418
|
-
this._textInput.setFocus();
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Remove o foco no componente de textarea
|
|
422
|
-
*/
|
|
423
|
-
async setBlur() {
|
|
424
|
-
this._textInput.setBlur();
|
|
425
|
-
}
|
|
426
|
-
updateValue() {
|
|
427
|
-
const selectedOption = this.options.filter(opt => opt.value === this.value);
|
|
428
|
-
if (selectedOption && selectedOption.length > 0) {
|
|
429
|
-
this._textInput.value = selectedOption[0].label;
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
this.value = null;
|
|
433
|
-
this._textInput.value = '';
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
setErrorMessage() {
|
|
437
|
-
this._textInput.errormessage = this.errormessage;
|
|
438
|
-
}
|
|
439
|
-
showOptions() {
|
|
440
|
-
if (this.enabled) {
|
|
441
|
-
this._criteria = undefined;
|
|
442
|
-
const top = this._textInput.errormessage ? '0px' : '-17px';
|
|
443
|
-
this._popover.show(top);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
updateSelection() {
|
|
447
|
-
const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
|
|
448
|
-
this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
|
|
449
|
-
}
|
|
450
|
-
selectOption(opt) {
|
|
451
|
-
this._popover.hide();
|
|
452
|
-
this.value = opt ? opt.value : null;
|
|
453
|
-
this.ezChange.emit();
|
|
454
|
-
}
|
|
455
|
-
buildItem(opt, index$1) {
|
|
456
|
-
const className = index$1 === this._preSelection ? "--li--preselected" : "";
|
|
457
|
-
return index.h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { class: '--li__spanvalue' }, opt.value) : null);
|
|
458
|
-
}
|
|
459
|
-
highlightMatch(label) {
|
|
460
|
-
const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
|
|
461
|
-
if (this._criteria) {
|
|
462
|
-
const criteriaLength = this._criteria.length;
|
|
463
|
-
const matchStart = label.toUpperCase().indexOf(this._criteria);
|
|
464
|
-
if (matchStart > -1) {
|
|
465
|
-
const strLabelStart = label.substr(0, matchStart);
|
|
466
|
-
const strLabelEnd = label.substr(matchStart + criteriaLength);
|
|
467
|
-
const strMatch = label.substr(matchStart, criteriaLength);
|
|
468
|
-
return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return (index.h("span", { class: spanClassName }, label));
|
|
472
|
-
}
|
|
473
|
-
matchOptions() {
|
|
474
|
-
this.showOptions();
|
|
475
|
-
this._criteria = this._textInput.value.toLocaleUpperCase();
|
|
476
|
-
this.filterOptions();
|
|
477
|
-
}
|
|
478
|
-
filterOptions() {
|
|
479
|
-
this._preSelection = undefined;
|
|
480
|
-
let opts = (this.options || []);
|
|
481
|
-
if (this._criteria) {
|
|
482
|
-
opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
|
|
483
|
-
}
|
|
484
|
-
this._visibleOptions = [{ value: '', label: '' }].concat(opts);
|
|
485
|
-
}
|
|
486
|
-
nextOption() {
|
|
487
|
-
this.showOptions();
|
|
488
|
-
this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
|
|
489
|
-
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
490
|
-
}
|
|
491
|
-
previousOption() {
|
|
492
|
-
this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
|
|
493
|
-
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
494
|
-
}
|
|
495
|
-
scrollToOption(opt) {
|
|
496
|
-
const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
|
|
497
|
-
if (liElem) {
|
|
498
|
-
const parent = liElem.parentElement;
|
|
499
|
-
const parentRect = parent.getBoundingClientRect();
|
|
500
|
-
const itemRect = liElem.getBoundingClientRect();
|
|
501
|
-
if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
|
|
502
|
-
liElem.scrollIntoView();
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
selectCurrentOption() {
|
|
507
|
-
if (this._preSelection !== undefined) {
|
|
508
|
-
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
509
|
-
this._preSelection = undefined;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
keyDownHandler(event) {
|
|
513
|
-
switch (event.key) {
|
|
514
|
-
case "ArrowDown":
|
|
515
|
-
this.nextOption();
|
|
516
|
-
break;
|
|
517
|
-
case "ArrowUp":
|
|
518
|
-
this.previousOption();
|
|
519
|
-
break;
|
|
520
|
-
case "Enter":
|
|
521
|
-
this.selectCurrentOption();
|
|
522
|
-
break;
|
|
523
|
-
}
|
|
524
|
-
event.stopPropagation();
|
|
525
|
-
}
|
|
526
|
-
//---------------------------------------------
|
|
527
|
-
// Lifecycle web component
|
|
528
|
-
//---------------------------------------------
|
|
529
|
-
componentWillLoad() {
|
|
530
|
-
if (this.options === undefined) {
|
|
531
|
-
this.options = [];
|
|
532
|
-
const optionsTags = this.el.querySelectorAll('option');
|
|
533
|
-
if (optionsTags) {
|
|
534
|
-
optionsTags.forEach(e => {
|
|
535
|
-
let label = e.innerText;
|
|
536
|
-
let value = e.getAttribute('value');
|
|
537
|
-
if (!value) {
|
|
538
|
-
value = label;
|
|
539
|
-
}
|
|
540
|
-
this.options.push({ label, value });
|
|
541
|
-
e.hidden = true;
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
this.filterOptions();
|
|
546
|
-
}
|
|
547
|
-
componentDidLoad() {
|
|
548
|
-
this.updateValue();
|
|
549
|
-
}
|
|
550
|
-
render() {
|
|
551
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true }, index.h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
|
|
552
|
-
}
|
|
553
|
-
;
|
|
554
|
-
get el() { return index.getElement(this); }
|
|
555
|
-
static get watchers() { return {
|
|
556
|
-
"value": ["updateValue"],
|
|
557
|
-
"errormessage": ["setErrorMessage"]
|
|
558
|
-
}; }
|
|
559
|
-
};
|
|
386
|
+
const EzComboBox = class {
|
|
387
|
+
constructor(hostRef) {
|
|
388
|
+
index.registerInstance(this, hostRef);
|
|
389
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
390
|
+
this._inputLabelValue = '';
|
|
391
|
+
/**
|
|
392
|
+
* Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
|
|
393
|
+
* Pode ser Label ou Value de acordo com a opção "labelasindex"
|
|
394
|
+
* Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
|
|
395
|
+
* (executo pala valor undefined)
|
|
396
|
+
*/
|
|
397
|
+
this.value = undefined;
|
|
398
|
+
/**
|
|
399
|
+
* Label é o título do campo
|
|
400
|
+
*/
|
|
401
|
+
this.label = undefined;
|
|
402
|
+
/**
|
|
403
|
+
* Deixa o campo disponível ou não para digitação.
|
|
404
|
+
*/
|
|
405
|
+
this.enabled = true;
|
|
406
|
+
/**
|
|
407
|
+
* Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
|
|
408
|
+
*/
|
|
409
|
+
this.showvalue = false;
|
|
410
|
+
}
|
|
411
|
+
//---------------------------------------------
|
|
412
|
+
// Public methods
|
|
413
|
+
//---------------------------------------------
|
|
414
|
+
/**
|
|
415
|
+
* Faz o foco no componente de textarea
|
|
416
|
+
*/
|
|
417
|
+
async setFocus() {
|
|
418
|
+
this._textInput.setFocus();
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Remove o foco no componente de textarea
|
|
422
|
+
*/
|
|
423
|
+
async setBlur() {
|
|
424
|
+
this._textInput.setBlur();
|
|
425
|
+
}
|
|
426
|
+
updateValue() {
|
|
427
|
+
const selectedOption = this.options.filter(opt => opt.value === this.value);
|
|
428
|
+
if (selectedOption && selectedOption.length > 0) {
|
|
429
|
+
this._textInput.value = selectedOption[0].label;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this.value = null;
|
|
433
|
+
this._textInput.value = '';
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
setErrorMessage() {
|
|
437
|
+
this._textInput.errormessage = this.errormessage;
|
|
438
|
+
}
|
|
439
|
+
showOptions() {
|
|
440
|
+
if (this.enabled) {
|
|
441
|
+
this._criteria = undefined;
|
|
442
|
+
const top = this._textInput.errormessage ? '0px' : '-17px';
|
|
443
|
+
this._popover.show(top);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
updateSelection() {
|
|
447
|
+
const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
|
|
448
|
+
this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
|
|
449
|
+
}
|
|
450
|
+
selectOption(opt) {
|
|
451
|
+
this._popover.hide();
|
|
452
|
+
this.value = opt ? opt.value : null;
|
|
453
|
+
this.ezChange.emit();
|
|
454
|
+
}
|
|
455
|
+
buildItem(opt, index$1) {
|
|
456
|
+
const className = index$1 === this._preSelection ? "--li--preselected" : "";
|
|
457
|
+
return index.h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { class: '--li__spanvalue' }, opt.value) : null);
|
|
458
|
+
}
|
|
459
|
+
highlightMatch(label) {
|
|
460
|
+
const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
|
|
461
|
+
if (this._criteria) {
|
|
462
|
+
const criteriaLength = this._criteria.length;
|
|
463
|
+
const matchStart = label.toUpperCase().indexOf(this._criteria);
|
|
464
|
+
if (matchStart > -1) {
|
|
465
|
+
const strLabelStart = label.substr(0, matchStart);
|
|
466
|
+
const strLabelEnd = label.substr(matchStart + criteriaLength);
|
|
467
|
+
const strMatch = label.substr(matchStart, criteriaLength);
|
|
468
|
+
return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return (index.h("span", { class: spanClassName }, label));
|
|
472
|
+
}
|
|
473
|
+
matchOptions() {
|
|
474
|
+
this.showOptions();
|
|
475
|
+
this._criteria = this._textInput.value.toLocaleUpperCase();
|
|
476
|
+
this.filterOptions();
|
|
477
|
+
}
|
|
478
|
+
filterOptions() {
|
|
479
|
+
this._preSelection = undefined;
|
|
480
|
+
let opts = (this.options || []);
|
|
481
|
+
if (this._criteria) {
|
|
482
|
+
opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
|
|
483
|
+
}
|
|
484
|
+
this._visibleOptions = [{ value: '', label: '' }].concat(opts);
|
|
485
|
+
}
|
|
486
|
+
nextOption() {
|
|
487
|
+
this.showOptions();
|
|
488
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
|
|
489
|
+
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
490
|
+
}
|
|
491
|
+
previousOption() {
|
|
492
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
|
|
493
|
+
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
494
|
+
}
|
|
495
|
+
scrollToOption(opt) {
|
|
496
|
+
const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
|
|
497
|
+
if (liElem) {
|
|
498
|
+
const parent = liElem.parentElement;
|
|
499
|
+
const parentRect = parent.getBoundingClientRect();
|
|
500
|
+
const itemRect = liElem.getBoundingClientRect();
|
|
501
|
+
if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
|
|
502
|
+
liElem.scrollIntoView();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
selectCurrentOption() {
|
|
507
|
+
if (this._preSelection !== undefined) {
|
|
508
|
+
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
509
|
+
this._preSelection = undefined;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
keyDownHandler(event) {
|
|
513
|
+
switch (event.key) {
|
|
514
|
+
case "ArrowDown":
|
|
515
|
+
this.nextOption();
|
|
516
|
+
break;
|
|
517
|
+
case "ArrowUp":
|
|
518
|
+
this.previousOption();
|
|
519
|
+
break;
|
|
520
|
+
case "Enter":
|
|
521
|
+
this.selectCurrentOption();
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
event.stopPropagation();
|
|
525
|
+
}
|
|
526
|
+
//---------------------------------------------
|
|
527
|
+
// Lifecycle web component
|
|
528
|
+
//---------------------------------------------
|
|
529
|
+
componentWillLoad() {
|
|
530
|
+
if (this.options === undefined) {
|
|
531
|
+
this.options = [];
|
|
532
|
+
const optionsTags = this.el.querySelectorAll('option');
|
|
533
|
+
if (optionsTags) {
|
|
534
|
+
optionsTags.forEach(e => {
|
|
535
|
+
let label = e.innerText;
|
|
536
|
+
let value = e.getAttribute('value');
|
|
537
|
+
if (!value) {
|
|
538
|
+
value = label;
|
|
539
|
+
}
|
|
540
|
+
this.options.push({ label, value });
|
|
541
|
+
e.hidden = true;
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
this.filterOptions();
|
|
546
|
+
}
|
|
547
|
+
componentDidLoad() {
|
|
548
|
+
this.updateValue();
|
|
549
|
+
}
|
|
550
|
+
render() {
|
|
551
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true }, index.h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
|
|
552
|
+
}
|
|
553
|
+
;
|
|
554
|
+
get el() { return index.getElement(this); }
|
|
555
|
+
static get watchers() { return {
|
|
556
|
+
"value": ["updateValue"],
|
|
557
|
+
"errormessage": ["setErrorMessage"]
|
|
558
|
+
}; }
|
|
559
|
+
};
|
|
560
560
|
EzComboBox.style = ezComboBoxCss;
|
|
561
561
|
|
|
562
562
|
const ezDateInputCss = ":host{display:block;width:100%;--it__input--background-color:var(--background--medium, #e0e0e0);--it__input--border-color:var(--it__input--background-color)}.text-input{--it__input--background-color:inherit;--it__input--border-color:inherit}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;clip-path:path(\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\")}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
|
|
563
563
|
|
|
564
|
-
const EzDateInput = class {
|
|
565
|
-
constructor(hostRef) {
|
|
566
|
-
index.registerInstance(this, hostRef);
|
|
567
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
568
|
-
/**
|
|
569
|
-
* Deixa o campo disponível ou não para uso.
|
|
570
|
-
*/
|
|
571
|
-
this.enabled = true;
|
|
572
|
-
}
|
|
573
|
-
setLabel() {
|
|
574
|
-
this._textInput.label = this.label;
|
|
575
|
-
}
|
|
576
|
-
setErrorMessage() {
|
|
577
|
-
this._textInput.errormessage = this.errormessage;
|
|
578
|
-
}
|
|
579
|
-
applyValueToInput() {
|
|
580
|
-
this._textInput.value = this.getTextValue(this.value);
|
|
581
|
-
}
|
|
582
|
-
changeValue(newValue) {
|
|
583
|
-
newValue = newValue == null ? null : DateUtils.clearTime(newValue);
|
|
584
|
-
this._textInput.errormessage = "";
|
|
585
|
-
if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
|
|
586
|
-
this.value = newValue;
|
|
587
|
-
this.ezChange.emit();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
showCalendar() {
|
|
591
|
-
this.parseDate();
|
|
592
|
-
this._calendar.value = this.value;
|
|
593
|
-
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
594
|
-
//posição errada no futuro. Preferi fazer simples no começo,
|
|
595
|
-
//porque não quis onerar o text input com essa funcionalidade...
|
|
596
|
-
const top = this._textInput.errormessage ? '0px' : '-17px';
|
|
597
|
-
this._calendar.show(top);
|
|
598
|
-
}
|
|
599
|
-
hideCalendar() {
|
|
600
|
-
this.changeValue(this._calendar.value);
|
|
601
|
-
this._calendar.hide();
|
|
602
|
-
}
|
|
603
|
-
parseDate() {
|
|
604
|
-
const strValue = this._textInput.value;
|
|
605
|
-
const parsedDate = DateUtils.strToDate(strValue);
|
|
606
|
-
if (parsedDate || !strValue) {
|
|
607
|
-
if (this.value === parsedDate) {
|
|
608
|
-
this.changeValue(this.value);
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this.changeValue(parsedDate);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
else {
|
|
615
|
-
this._textInput.errormessage = "O valor digitado não é uma data válida";
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
getTextValue(d) {
|
|
619
|
-
return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
|
|
620
|
-
}
|
|
621
|
-
render() {
|
|
622
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
|
|
623
|
-
if (event.key === 'H' || event.key === 'h')
|
|
624
|
-
this.changeValue(new Date());
|
|
625
|
-
}, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
626
|
-
}
|
|
627
|
-
static get watchers() { return {
|
|
628
|
-
"label": ["setLabel"],
|
|
629
|
-
"errormessage": ["setErrorMessage"],
|
|
630
|
-
"value": ["applyValueToInput"]
|
|
631
|
-
}; }
|
|
632
|
-
};
|
|
564
|
+
const EzDateInput = class {
|
|
565
|
+
constructor(hostRef) {
|
|
566
|
+
index.registerInstance(this, hostRef);
|
|
567
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
568
|
+
/**
|
|
569
|
+
* Deixa o campo disponível ou não para uso.
|
|
570
|
+
*/
|
|
571
|
+
this.enabled = true;
|
|
572
|
+
}
|
|
573
|
+
setLabel() {
|
|
574
|
+
this._textInput.label = this.label;
|
|
575
|
+
}
|
|
576
|
+
setErrorMessage() {
|
|
577
|
+
this._textInput.errormessage = this.errormessage;
|
|
578
|
+
}
|
|
579
|
+
applyValueToInput() {
|
|
580
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
581
|
+
}
|
|
582
|
+
changeValue(newValue) {
|
|
583
|
+
newValue = newValue == null ? null : DateUtils.clearTime(newValue);
|
|
584
|
+
this._textInput.errormessage = "";
|
|
585
|
+
if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
|
|
586
|
+
this.value = newValue;
|
|
587
|
+
this.ezChange.emit();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
showCalendar() {
|
|
591
|
+
this.parseDate();
|
|
592
|
+
this._calendar.value = this.value;
|
|
593
|
+
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
594
|
+
//posição errada no futuro. Preferi fazer simples no começo,
|
|
595
|
+
//porque não quis onerar o text input com essa funcionalidade...
|
|
596
|
+
const top = this._textInput.errormessage ? '0px' : '-17px';
|
|
597
|
+
this._calendar.show(top);
|
|
598
|
+
}
|
|
599
|
+
hideCalendar() {
|
|
600
|
+
this.changeValue(this._calendar.value);
|
|
601
|
+
this._calendar.hide();
|
|
602
|
+
}
|
|
603
|
+
parseDate() {
|
|
604
|
+
const strValue = this._textInput.value;
|
|
605
|
+
const parsedDate = DateUtils.strToDate(strValue);
|
|
606
|
+
if (parsedDate || !strValue) {
|
|
607
|
+
if (this.value === parsedDate) {
|
|
608
|
+
this.changeValue(this.value);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
this.changeValue(parsedDate);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
this._textInput.errormessage = "O valor digitado não é uma data válida";
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
getTextValue(d) {
|
|
619
|
+
return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
|
|
620
|
+
}
|
|
621
|
+
render() {
|
|
622
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
|
|
623
|
+
if (event.key === 'H' || event.key === 'h')
|
|
624
|
+
this.changeValue(new Date());
|
|
625
|
+
}, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
626
|
+
}
|
|
627
|
+
static get watchers() { return {
|
|
628
|
+
"label": ["setLabel"],
|
|
629
|
+
"errormessage": ["setErrorMessage"],
|
|
630
|
+
"value": ["applyValueToInput"]
|
|
631
|
+
}; }
|
|
632
|
+
};
|
|
633
633
|
EzDateInput.style = ezDateInputCss;
|
|
634
634
|
|
|
635
635
|
function _defineProperty(obj, key, value) {
|
|
@@ -1826,1503 +1826,1503 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
1826
1826
|
|
|
1827
1827
|
const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
|
|
1828
1828
|
|
|
1829
|
-
const inicialHistState = {
|
|
1830
|
-
currentTabIndex: {},
|
|
1831
|
-
currentRecordIndex: {},
|
|
1832
|
-
changes: {},
|
|
1833
|
-
collapsedGroups: {},
|
|
1834
|
-
newRecordIndex: {}
|
|
1835
|
-
};
|
|
1836
|
-
const inicialNonHistState = {
|
|
1837
|
-
dataLoading: {},
|
|
1838
|
-
invalidFields: {},
|
|
1839
|
-
visibleButtons: {
|
|
1840
|
-
previousVisible: true,
|
|
1841
|
-
nextVisible: true,
|
|
1842
|
-
addVisible: true,
|
|
1843
|
-
removeVisible: true,
|
|
1844
|
-
saveVisible: true,
|
|
1845
|
-
cancelVisible: true,
|
|
1846
|
-
reloadVisible: true
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1849
|
-
function formReducer(state = inicialHistState, action) {
|
|
1850
|
-
switch (action.type) {
|
|
1851
|
-
case 'FORM/COLLAPSEGROUP':
|
|
1852
|
-
return collapseGroup(state, action.payload);
|
|
1853
|
-
case 'FORM/CHANGETAB':
|
|
1854
|
-
return changeTab(state, action.payload.formId, action.payload.index);
|
|
1855
|
-
case 'FORM/NAVIGATE':
|
|
1856
|
-
return navigate(state, action.payload);
|
|
1857
|
-
case 'FORM/INSERT':
|
|
1858
|
-
return insertRecord(state, action.payload);
|
|
1859
|
-
case 'FORM/CHANGEFIELD':
|
|
1860
|
-
return changeFieldValue(state, action.payload);
|
|
1861
|
-
case 'FORM/CLEAREDITION':
|
|
1862
|
-
return clearEdition(state, action.payload);
|
|
1863
|
-
case 'FORM/INVALIDFIELD':
|
|
1864
|
-
return navigateToInvalid(state, action.payload);
|
|
1865
|
-
default:
|
|
1866
|
-
return state;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
function formNonHistoricReducer(state = inicialNonHistState, action) {
|
|
1870
|
-
switch (action.type) {
|
|
1871
|
-
case 'FORM/DATALOADING':
|
|
1872
|
-
return dataLoading(state, action.payload);
|
|
1873
|
-
case 'FORM/DATALOADED':
|
|
1874
|
-
return dataLoaded(state, action.payload);
|
|
1875
|
-
case 'FORM/SAVINGCHANGES':
|
|
1876
|
-
return savingChanges(state, action.payload);
|
|
1877
|
-
case 'FORM/CHANGESSAVED':
|
|
1878
|
-
return changesSaved(state, action.payload);
|
|
1879
|
-
case 'FORM/REMOVINGRECORD':
|
|
1880
|
-
return removingRecord(state, action.payload);
|
|
1881
|
-
case 'FORM/RECORDREMOVED':
|
|
1882
|
-
return recordRemoved(state, action.payload);
|
|
1883
|
-
case 'FORM/INVALIDFIELD':
|
|
1884
|
-
return invalidField(state, action.payload);
|
|
1885
|
-
case 'FORM/CLEAREDITION':
|
|
1886
|
-
return clearAllInvalidFields(state, action.payload);
|
|
1887
|
-
case 'FORM/CHANGEFIELD':
|
|
1888
|
-
return clearInvalidField(state, action.payload);
|
|
1889
|
-
case 'FORM/SHOWHIDENAVBTN':
|
|
1890
|
-
return showHideNavBtn(state, action.payload);
|
|
1891
|
-
default:
|
|
1892
|
-
return state;
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
function collapseGroup(state, { collapseId, collapsed }) {
|
|
1896
|
-
const currentCollapsed = Object.assign({}, state.collapsedGroups);
|
|
1897
|
-
if (collapsed) {
|
|
1898
|
-
currentCollapsed[collapseId] = true;
|
|
1899
|
-
}
|
|
1900
|
-
else {
|
|
1901
|
-
delete currentCollapsed[collapseId];
|
|
1902
|
-
}
|
|
1903
|
-
return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
|
|
1904
|
-
}
|
|
1905
|
-
function changeTab(state, formId, index) {
|
|
1906
|
-
const currentTabIndex = Object.assign({}, state.currentTabIndex);
|
|
1907
|
-
currentTabIndex[formId] = index;
|
|
1908
|
-
return Object.assign(Object.assign({}, state), { currentTabIndex });
|
|
1909
|
-
}
|
|
1910
|
-
function navigate(state, { dataUnit, limit, backward }) {
|
|
1911
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1912
|
-
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
1913
|
-
return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
|
|
1914
|
-
}
|
|
1915
|
-
function gotoIndex(state, dataUnit, index) {
|
|
1916
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1917
|
-
currentRecordIndex[dataUnit] = index;
|
|
1918
|
-
return Object.assign(Object.assign({}, state), { currentRecordIndex });
|
|
1919
|
-
}
|
|
1920
|
-
function insertRecord(state, { dataUnit, insertionIndex }) {
|
|
1921
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1922
|
-
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
1923
|
-
currentRecordIndex[dataUnit] = insertionIndex;
|
|
1924
|
-
newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
|
|
1925
|
-
return Object.assign(Object.assign({}, state), { currentRecordIndex,
|
|
1926
|
-
newRecordIndex });
|
|
1927
|
-
}
|
|
1928
|
-
function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
|
|
1929
|
-
const changes = Object.assign({}, state.changes);
|
|
1930
|
-
const dataUnitChanges = Object.assign({}, changes[dataUnit]);
|
|
1931
|
-
const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
|
|
1932
|
-
recordChanges[fieldName] = value;
|
|
1933
|
-
dataUnitChanges[recordId] = recordChanges;
|
|
1934
|
-
changes[dataUnit] = dataUnitChanges;
|
|
1935
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
1936
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
1937
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
1938
|
-
delete errorMessages[fieldName];
|
|
1939
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
1940
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
1941
|
-
return Object.assign(Object.assign({}, state), { changes,
|
|
1942
|
-
invalidFields, invalidFieldSelected: undefined });
|
|
1943
|
-
}
|
|
1944
|
-
function clearEdition(state, { dataUnit, recordsLimit }) {
|
|
1945
|
-
const changes = Object.assign({}, state.changes);
|
|
1946
|
-
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
1947
|
-
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1948
|
-
delete changes[dataUnit];
|
|
1949
|
-
delete newRecordIndex[dataUnit];
|
|
1950
|
-
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
1951
|
-
currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
|
|
1952
|
-
return Object.assign(Object.assign({}, state), { changes,
|
|
1953
|
-
newRecordIndex,
|
|
1954
|
-
currentRecordIndex });
|
|
1955
|
-
}
|
|
1956
|
-
function navigateToInvalid(state, payload) {
|
|
1957
|
-
let newState = Object.assign({}, state);
|
|
1958
|
-
if (newState.invalidFieldSelected === undefined) {
|
|
1959
|
-
newState.invalidFieldSelected = true;
|
|
1960
|
-
newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
|
|
1961
|
-
newState = changeTab(newState, payload.tabController, payload.tabIndex);
|
|
1962
|
-
}
|
|
1963
|
-
return newState;
|
|
1964
|
-
}
|
|
1965
|
-
function dataLoading(state, { dataUnit }) {
|
|
1966
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1967
|
-
dataLoading[dataUnit] = true;
|
|
1968
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1969
|
-
}
|
|
1970
|
-
function dataLoaded(state, { dataUnit }) {
|
|
1971
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1972
|
-
delete dataLoading[dataUnit];
|
|
1973
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1974
|
-
}
|
|
1975
|
-
function savingChanges(state, { dataUnit }) {
|
|
1976
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1977
|
-
dataLoading[dataUnit] = true;
|
|
1978
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1979
|
-
}
|
|
1980
|
-
function changesSaved(state, { dataUnit }) {
|
|
1981
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1982
|
-
delete dataLoading[dataUnit];
|
|
1983
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1984
|
-
}
|
|
1985
|
-
function removingRecord(state, { dataUnit }) {
|
|
1986
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1987
|
-
dataLoading[dataUnit] = true;
|
|
1988
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1989
|
-
}
|
|
1990
|
-
function recordRemoved(state, { dataUnit }) {
|
|
1991
|
-
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1992
|
-
delete dataLoading[dataUnit];
|
|
1993
|
-
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1994
|
-
}
|
|
1995
|
-
function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
|
|
1996
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
1997
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
1998
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
1999
|
-
errorMessages[fieldName] = errorMessage;
|
|
2000
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
2001
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
2002
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2003
|
-
}
|
|
2004
|
-
function clearAllInvalidFields(state, { dataUnit }) {
|
|
2005
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
2006
|
-
delete invalidFields[dataUnit];
|
|
2007
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2008
|
-
}
|
|
2009
|
-
function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
|
|
2010
|
-
const invalidFields = Object.assign({}, state.invalidFields);
|
|
2011
|
-
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
2012
|
-
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
2013
|
-
delete errorMessages[fieldName];
|
|
2014
|
-
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
2015
|
-
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
2016
|
-
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2017
|
-
}
|
|
2018
|
-
function showHideNavBtn(state, { buttonName, status }) {
|
|
2019
|
-
const visibleButtons = Object.assign({}, state.visibleButtons);
|
|
2020
|
-
visibleButtons[buttonName] = status;
|
|
2021
|
-
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
1829
|
+
const inicialHistState = {
|
|
1830
|
+
currentTabIndex: {},
|
|
1831
|
+
currentRecordIndex: {},
|
|
1832
|
+
changes: {},
|
|
1833
|
+
collapsedGroups: {},
|
|
1834
|
+
newRecordIndex: {}
|
|
1835
|
+
};
|
|
1836
|
+
const inicialNonHistState = {
|
|
1837
|
+
dataLoading: {},
|
|
1838
|
+
invalidFields: {},
|
|
1839
|
+
visibleButtons: {
|
|
1840
|
+
previousVisible: true,
|
|
1841
|
+
nextVisible: true,
|
|
1842
|
+
addVisible: true,
|
|
1843
|
+
removeVisible: true,
|
|
1844
|
+
saveVisible: true,
|
|
1845
|
+
cancelVisible: true,
|
|
1846
|
+
reloadVisible: true
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
function formReducer(state = inicialHistState, action) {
|
|
1850
|
+
switch (action.type) {
|
|
1851
|
+
case 'FORM/COLLAPSEGROUP':
|
|
1852
|
+
return collapseGroup(state, action.payload);
|
|
1853
|
+
case 'FORM/CHANGETAB':
|
|
1854
|
+
return changeTab(state, action.payload.formId, action.payload.index);
|
|
1855
|
+
case 'FORM/NAVIGATE':
|
|
1856
|
+
return navigate(state, action.payload);
|
|
1857
|
+
case 'FORM/INSERT':
|
|
1858
|
+
return insertRecord(state, action.payload);
|
|
1859
|
+
case 'FORM/CHANGEFIELD':
|
|
1860
|
+
return changeFieldValue(state, action.payload);
|
|
1861
|
+
case 'FORM/CLEAREDITION':
|
|
1862
|
+
return clearEdition(state, action.payload);
|
|
1863
|
+
case 'FORM/INVALIDFIELD':
|
|
1864
|
+
return navigateToInvalid(state, action.payload);
|
|
1865
|
+
default:
|
|
1866
|
+
return state;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
function formNonHistoricReducer(state = inicialNonHistState, action) {
|
|
1870
|
+
switch (action.type) {
|
|
1871
|
+
case 'FORM/DATALOADING':
|
|
1872
|
+
return dataLoading(state, action.payload);
|
|
1873
|
+
case 'FORM/DATALOADED':
|
|
1874
|
+
return dataLoaded(state, action.payload);
|
|
1875
|
+
case 'FORM/SAVINGCHANGES':
|
|
1876
|
+
return savingChanges(state, action.payload);
|
|
1877
|
+
case 'FORM/CHANGESSAVED':
|
|
1878
|
+
return changesSaved(state, action.payload);
|
|
1879
|
+
case 'FORM/REMOVINGRECORD':
|
|
1880
|
+
return removingRecord(state, action.payload);
|
|
1881
|
+
case 'FORM/RECORDREMOVED':
|
|
1882
|
+
return recordRemoved(state, action.payload);
|
|
1883
|
+
case 'FORM/INVALIDFIELD':
|
|
1884
|
+
return invalidField(state, action.payload);
|
|
1885
|
+
case 'FORM/CLEAREDITION':
|
|
1886
|
+
return clearAllInvalidFields(state, action.payload);
|
|
1887
|
+
case 'FORM/CHANGEFIELD':
|
|
1888
|
+
return clearInvalidField(state, action.payload);
|
|
1889
|
+
case 'FORM/SHOWHIDENAVBTN':
|
|
1890
|
+
return showHideNavBtn(state, action.payload);
|
|
1891
|
+
default:
|
|
1892
|
+
return state;
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
function collapseGroup(state, { collapseId, collapsed }) {
|
|
1896
|
+
const currentCollapsed = Object.assign({}, state.collapsedGroups);
|
|
1897
|
+
if (collapsed) {
|
|
1898
|
+
currentCollapsed[collapseId] = true;
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
delete currentCollapsed[collapseId];
|
|
1902
|
+
}
|
|
1903
|
+
return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
|
|
1904
|
+
}
|
|
1905
|
+
function changeTab(state, formId, index) {
|
|
1906
|
+
const currentTabIndex = Object.assign({}, state.currentTabIndex);
|
|
1907
|
+
currentTabIndex[formId] = index;
|
|
1908
|
+
return Object.assign(Object.assign({}, state), { currentTabIndex });
|
|
1909
|
+
}
|
|
1910
|
+
function navigate(state, { dataUnit, limit, backward }) {
|
|
1911
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1912
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
1913
|
+
return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
|
|
1914
|
+
}
|
|
1915
|
+
function gotoIndex(state, dataUnit, index) {
|
|
1916
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1917
|
+
currentRecordIndex[dataUnit] = index;
|
|
1918
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex });
|
|
1919
|
+
}
|
|
1920
|
+
function insertRecord(state, { dataUnit, insertionIndex }) {
|
|
1921
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1922
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
1923
|
+
currentRecordIndex[dataUnit] = insertionIndex;
|
|
1924
|
+
newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
|
|
1925
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex,
|
|
1926
|
+
newRecordIndex });
|
|
1927
|
+
}
|
|
1928
|
+
function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
|
|
1929
|
+
const changes = Object.assign({}, state.changes);
|
|
1930
|
+
const dataUnitChanges = Object.assign({}, changes[dataUnit]);
|
|
1931
|
+
const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
|
|
1932
|
+
recordChanges[fieldName] = value;
|
|
1933
|
+
dataUnitChanges[recordId] = recordChanges;
|
|
1934
|
+
changes[dataUnit] = dataUnitChanges;
|
|
1935
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
1936
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
1937
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
1938
|
+
delete errorMessages[fieldName];
|
|
1939
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
1940
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
1941
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
1942
|
+
invalidFields, invalidFieldSelected: undefined });
|
|
1943
|
+
}
|
|
1944
|
+
function clearEdition(state, { dataUnit, recordsLimit }) {
|
|
1945
|
+
const changes = Object.assign({}, state.changes);
|
|
1946
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
1947
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
1948
|
+
delete changes[dataUnit];
|
|
1949
|
+
delete newRecordIndex[dataUnit];
|
|
1950
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
1951
|
+
currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
|
|
1952
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
1953
|
+
newRecordIndex,
|
|
1954
|
+
currentRecordIndex });
|
|
1955
|
+
}
|
|
1956
|
+
function navigateToInvalid(state, payload) {
|
|
1957
|
+
let newState = Object.assign({}, state);
|
|
1958
|
+
if (newState.invalidFieldSelected === undefined) {
|
|
1959
|
+
newState.invalidFieldSelected = true;
|
|
1960
|
+
newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
|
|
1961
|
+
newState = changeTab(newState, payload.tabController, payload.tabIndex);
|
|
1962
|
+
}
|
|
1963
|
+
return newState;
|
|
1964
|
+
}
|
|
1965
|
+
function dataLoading(state, { dataUnit }) {
|
|
1966
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1967
|
+
dataLoading[dataUnit] = true;
|
|
1968
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1969
|
+
}
|
|
1970
|
+
function dataLoaded(state, { dataUnit }) {
|
|
1971
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1972
|
+
delete dataLoading[dataUnit];
|
|
1973
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1974
|
+
}
|
|
1975
|
+
function savingChanges(state, { dataUnit }) {
|
|
1976
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1977
|
+
dataLoading[dataUnit] = true;
|
|
1978
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1979
|
+
}
|
|
1980
|
+
function changesSaved(state, { dataUnit }) {
|
|
1981
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1982
|
+
delete dataLoading[dataUnit];
|
|
1983
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1984
|
+
}
|
|
1985
|
+
function removingRecord(state, { dataUnit }) {
|
|
1986
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1987
|
+
dataLoading[dataUnit] = true;
|
|
1988
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1989
|
+
}
|
|
1990
|
+
function recordRemoved(state, { dataUnit }) {
|
|
1991
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
1992
|
+
delete dataLoading[dataUnit];
|
|
1993
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
1994
|
+
}
|
|
1995
|
+
function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
|
|
1996
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
1997
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
1998
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
1999
|
+
errorMessages[fieldName] = errorMessage;
|
|
2000
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
2001
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
2002
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2003
|
+
}
|
|
2004
|
+
function clearAllInvalidFields(state, { dataUnit }) {
|
|
2005
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
2006
|
+
delete invalidFields[dataUnit];
|
|
2007
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2008
|
+
}
|
|
2009
|
+
function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
|
|
2010
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
2011
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
2012
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
2013
|
+
delete errorMessages[fieldName];
|
|
2014
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
2015
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
2016
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
2017
|
+
}
|
|
2018
|
+
function showHideNavBtn(state, { buttonName, status }) {
|
|
2019
|
+
const visibleButtons = Object.assign({}, state.visibleButtons);
|
|
2020
|
+
visibleButtons[buttonName] = status;
|
|
2021
|
+
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
2022
2022
|
}
|
|
2023
2023
|
|
|
2024
|
-
function removeHandler(dataUnit) {
|
|
2025
|
-
if (confirm("Tem certeza que deseja Remover?")) {
|
|
2026
|
-
dataUnit.remove();
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
const NavigationBar = ({ dataUnit: du, buttonProps }) => {
|
|
2030
|
-
if (buttonProps.previousVisible
|
|
2031
|
-
|| buttonProps.nextVisible
|
|
2032
|
-
|| buttonProps.addVisible
|
|
2033
|
-
|| buttonProps.removeVisible
|
|
2034
|
-
|| buttonProps.saveVisible
|
|
2035
|
-
|| buttonProps.cancelVisible
|
|
2036
|
-
|| buttonProps.reloadVisible) {
|
|
2037
|
-
return index.h("div", { class: "col col--sd-12 align--right" },
|
|
2038
|
-
buttonProps.previousVisible ? index.h("ez-button", { title: "Registro anterior", mode: "icon", enabled: du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2039
|
-
buttonProps.nextVisible ? index.h("ez-button", { title: "Pr\u00F3ximo registro", mode: "icon", enabled: du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2040
|
-
buttonProps.removeVisible ? index.h("ez-button", { title: "Remover " + du.unitLabel, mode: "icon", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2041
|
-
buttonProps.addVisible ? index.h("ez-button", { label: "Criar " + du.unitLabel, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
|
|
2042
|
-
buttonProps.reloadVisible ? index.h("ez-button", { title: "Recarregar", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
|
|
2043
|
-
buttonProps.cancelVisible ? index.h("ez-button", { label: "Cancelar", enabled: du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
|
|
2044
|
-
buttonProps.saveVisible ? index.h("ez-button", { label: "Salvar", enabled: du.hasChanges(), onClick: () => du.save(), class: "button--primary margin-right--medium" }) : null);
|
|
2045
|
-
}
|
|
2046
|
-
else {
|
|
2047
|
-
return null;
|
|
2048
|
-
}
|
|
2024
|
+
function removeHandler(dataUnit) {
|
|
2025
|
+
if (confirm("Tem certeza que deseja Remover?")) {
|
|
2026
|
+
dataUnit.remove();
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
const NavigationBar = ({ dataUnit: du, buttonProps }) => {
|
|
2030
|
+
if (buttonProps.previousVisible
|
|
2031
|
+
|| buttonProps.nextVisible
|
|
2032
|
+
|| buttonProps.addVisible
|
|
2033
|
+
|| buttonProps.removeVisible
|
|
2034
|
+
|| buttonProps.saveVisible
|
|
2035
|
+
|| buttonProps.cancelVisible
|
|
2036
|
+
|| buttonProps.reloadVisible) {
|
|
2037
|
+
return index.h("div", { class: "col col--sd-12 align--right" },
|
|
2038
|
+
buttonProps.previousVisible ? index.h("ez-button", { title: "Registro anterior", mode: "icon", enabled: du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2039
|
+
buttonProps.nextVisible ? index.h("ez-button", { title: "Pr\u00F3ximo registro", mode: "icon", enabled: du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2040
|
+
buttonProps.removeVisible ? index.h("ez-button", { title: "Remover " + du.unitLabel, mode: "icon", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
|
|
2041
|
+
buttonProps.addVisible ? index.h("ez-button", { label: "Criar " + du.unitLabel, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
|
|
2042
|
+
buttonProps.reloadVisible ? index.h("ez-button", { title: "Recarregar", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
|
|
2043
|
+
buttonProps.cancelVisible ? index.h("ez-button", { label: "Cancelar", enabled: du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
|
|
2044
|
+
buttonProps.saveVisible ? index.h("ez-button", { label: "Salvar", enabled: du.hasChanges(), onClick: () => du.save(), class: "button--primary margin-right--medium" }) : null);
|
|
2045
|
+
}
|
|
2046
|
+
else {
|
|
2047
|
+
return null;
|
|
2048
|
+
}
|
|
2049
2049
|
};
|
|
2050
2050
|
|
|
2051
|
-
var DependencyType;
|
|
2052
|
-
(function (DependencyType) {
|
|
2053
|
-
DependencyType["SEARCHING"] = "SEARCHING";
|
|
2054
|
-
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
2055
|
-
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
2051
|
+
var DependencyType;
|
|
2052
|
+
(function (DependencyType) {
|
|
2053
|
+
DependencyType["SEARCHING"] = "SEARCHING";
|
|
2054
|
+
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
2055
|
+
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
2056
2056
|
})(DependencyType || (DependencyType = {}));
|
|
2057
2057
|
|
|
2058
|
-
function scrollToView(forceScroll, elem) {
|
|
2059
|
-
if (forceScroll) {
|
|
2060
|
-
window.requestAnimationFrame(() => elem.scrollIntoView());
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
const Field = ({ dataUnit, source, forceScroll }) => {
|
|
2064
|
-
const { name, label, userInterface, properties, required, dependencies } = source;
|
|
2065
|
-
const value = dataUnit.getValue(name) || null;
|
|
2066
|
-
const loadingData = dataUnit.isLoading();
|
|
2067
|
-
const formattedLabel = required ? `* ${label} (obrigatório)` : label;
|
|
2068
|
-
const errorMessage = dataUnit.getErrorMessage(name);
|
|
2069
|
-
const changeFieldHandler = (newValue) => {
|
|
2070
|
-
dataUnit.changeValue(name, newValue);
|
|
2071
|
-
};
|
|
2072
|
-
switch (userInterface) {
|
|
2073
|
-
case 'LONGTEXT':
|
|
2074
|
-
return index.h("div", { class: "col col--sd-12 padding--small" },
|
|
2075
|
-
index.h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2076
|
-
case 'CHECKBOX':
|
|
2077
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2078
|
-
index.h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
|
|
2079
|
-
case 'SWITCH':
|
|
2080
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2081
|
-
index.h("div", { class: "row" },
|
|
2082
|
-
index.h("div", { class: "col col--sd-2" },
|
|
2083
|
-
index.h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
|
|
2084
|
-
index.h("div", { class: "col col--sd-10" },
|
|
2085
|
-
index.h("label", { class: "text text--primary text--medium" }, label))));
|
|
2086
|
-
case 'OPTIONSELECTOR':
|
|
2087
|
-
const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
|
|
2088
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2089
|
-
index.h("ez-combo-box", { value: value, label: formattedLabel, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }, Object.keys(optsObj).map(key => index.h("option", { value: key }, optsObj[key]))));
|
|
2090
|
-
case 'SEARCH':
|
|
2091
|
-
const context = {};
|
|
2092
|
-
properties.forEach(({ name, value }) => {
|
|
2093
|
-
context[name] = value;
|
|
2094
|
-
});
|
|
2095
|
-
let criteriaList = [];
|
|
2096
|
-
dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
|
|
2097
|
-
var _a;
|
|
2098
|
-
if (dependency.type === DependencyType.SEARCHING) {
|
|
2099
|
-
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2100
|
-
let criteria = {
|
|
2101
|
-
expression: dependency.expression,
|
|
2102
|
-
paramNames: [...dependency.masterFields],
|
|
2103
|
-
paramResolver: name => dataUnit.getValue(name)
|
|
2104
|
-
};
|
|
2105
|
-
criteriaList.push(criteria);
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
});
|
|
2109
|
-
if (criteriaList.length > 0) {
|
|
2110
|
-
context['CRITERIA'] = criteriaList;
|
|
2111
|
-
}
|
|
2112
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2113
|
-
index.h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
|
|
2114
|
-
case 'DATE':
|
|
2115
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2116
|
-
index.h("ez-date-input", { label: formattedLabel, enabled: true, value: !value ? null : DateUtils.clearTime(value), onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2117
|
-
//IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
|
|
2118
|
-
default:
|
|
2119
|
-
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
|
|
2120
|
-
?
|
|
2121
|
-
index.h("place-holder", null)
|
|
2122
|
-
:
|
|
2123
|
-
index.h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2124
|
-
}
|
|
2058
|
+
function scrollToView(forceScroll, elem) {
|
|
2059
|
+
if (forceScroll) {
|
|
2060
|
+
window.requestAnimationFrame(() => elem.scrollIntoView());
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
const Field = ({ dataUnit, source, forceScroll }) => {
|
|
2064
|
+
const { name, label, userInterface, properties, required, dependencies } = source;
|
|
2065
|
+
const value = dataUnit.getValue(name) || null;
|
|
2066
|
+
const loadingData = dataUnit.isLoading();
|
|
2067
|
+
const formattedLabel = required ? `* ${label} (obrigatório)` : label;
|
|
2068
|
+
const errorMessage = dataUnit.getErrorMessage(name);
|
|
2069
|
+
const changeFieldHandler = (newValue) => {
|
|
2070
|
+
dataUnit.changeValue(name, newValue);
|
|
2071
|
+
};
|
|
2072
|
+
switch (userInterface) {
|
|
2073
|
+
case 'LONGTEXT':
|
|
2074
|
+
return index.h("div", { class: "col col--sd-12 padding--small" },
|
|
2075
|
+
index.h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2076
|
+
case 'CHECKBOX':
|
|
2077
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2078
|
+
index.h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
|
|
2079
|
+
case 'SWITCH':
|
|
2080
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2081
|
+
index.h("div", { class: "row" },
|
|
2082
|
+
index.h("div", { class: "col col--sd-2" },
|
|
2083
|
+
index.h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
|
|
2084
|
+
index.h("div", { class: "col col--sd-10" },
|
|
2085
|
+
index.h("label", { class: "text text--primary text--medium" }, label))));
|
|
2086
|
+
case 'OPTIONSELECTOR':
|
|
2087
|
+
const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
|
|
2088
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2089
|
+
index.h("ez-combo-box", { value: value, label: formattedLabel, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }, Object.keys(optsObj).map(key => index.h("option", { value: key }, optsObj[key]))));
|
|
2090
|
+
case 'SEARCH':
|
|
2091
|
+
const context = {};
|
|
2092
|
+
properties.forEach(({ name, value }) => {
|
|
2093
|
+
context[name] = value;
|
|
2094
|
+
});
|
|
2095
|
+
let criteriaList = [];
|
|
2096
|
+
dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
|
|
2097
|
+
var _a;
|
|
2098
|
+
if (dependency.type === DependencyType.SEARCHING) {
|
|
2099
|
+
if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2100
|
+
let criteria = {
|
|
2101
|
+
expression: dependency.expression,
|
|
2102
|
+
paramNames: [...dependency.masterFields],
|
|
2103
|
+
paramResolver: name => dataUnit.getValue(name)
|
|
2104
|
+
};
|
|
2105
|
+
criteriaList.push(criteria);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
2109
|
+
if (criteriaList.length > 0) {
|
|
2110
|
+
context['CRITERIA'] = criteriaList;
|
|
2111
|
+
}
|
|
2112
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2113
|
+
index.h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
|
|
2114
|
+
case 'DATE':
|
|
2115
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
|
|
2116
|
+
index.h("ez-date-input", { label: formattedLabel, enabled: true, value: !value ? null : DateUtils.clearTime(value), onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2117
|
+
//IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
|
|
2118
|
+
default:
|
|
2119
|
+
return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
|
|
2120
|
+
?
|
|
2121
|
+
index.h("place-holder", null)
|
|
2122
|
+
:
|
|
2123
|
+
index.h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
|
|
2124
|
+
}
|
|
2125
2125
|
};
|
|
2126
2126
|
|
|
2127
|
-
const FieldSet = ({ store, formName, source, dataUnit }) => {
|
|
2128
|
-
const { label, fields } = source;
|
|
2129
|
-
const fieldSetName = formName + label;
|
|
2130
|
-
let isCollapsed = DataUnit.selectIsCollapsedFieldSet(store.getState(), formName + label);
|
|
2131
|
-
let fieldToScroll;
|
|
2132
|
-
source.fields.forEach((field) => {
|
|
2133
|
-
if (fieldToScroll === undefined) {
|
|
2134
|
-
const fieldError = dataUnit.getErrorMessage(field.name);
|
|
2135
|
-
if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
|
|
2136
|
-
fieldToScroll = field.name;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
});
|
|
2140
|
-
if (fieldToScroll) {
|
|
2141
|
-
isCollapsed = false;
|
|
2142
|
-
}
|
|
2143
|
-
return index.h("div", { class: "col col--sd-12 padding--small" },
|
|
2144
|
-
index.h("div", { class: "row margin-top--large" },
|
|
2145
|
-
index.h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
|
|
2146
|
-
index.h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(DataUnit.collapseExpandGroup(fieldSetName, !isCollapsed)) }),
|
|
2147
|
-
isCollapsed ? null :
|
|
2148
|
-
index.h("div", { class: "col col--sd-12" }, fields.map(field => index.h(Field, { source: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
|
|
2127
|
+
const FieldSet = ({ store, formName, source, dataUnit }) => {
|
|
2128
|
+
const { label, fields } = source;
|
|
2129
|
+
const fieldSetName = formName + label;
|
|
2130
|
+
let isCollapsed = DataUnit.selectIsCollapsedFieldSet(store.getState(), formName + label);
|
|
2131
|
+
let fieldToScroll;
|
|
2132
|
+
source.fields.forEach((field) => {
|
|
2133
|
+
if (fieldToScroll === undefined) {
|
|
2134
|
+
const fieldError = dataUnit.getErrorMessage(field.name);
|
|
2135
|
+
if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
|
|
2136
|
+
fieldToScroll = field.name;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
if (fieldToScroll) {
|
|
2141
|
+
isCollapsed = false;
|
|
2142
|
+
}
|
|
2143
|
+
return index.h("div", { class: "col col--sd-12 padding--small" },
|
|
2144
|
+
index.h("div", { class: "row margin-top--large" },
|
|
2145
|
+
index.h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
|
|
2146
|
+
index.h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(DataUnit.collapseExpandGroup(fieldSetName, !isCollapsed)) }),
|
|
2147
|
+
isCollapsed ? null :
|
|
2148
|
+
index.h("div", { class: "col col--sd-12" }, fields.map(field => index.h(Field, { source: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
|
|
2149
2149
|
};
|
|
2150
2150
|
|
|
2151
|
-
function buildFormItem(source, formName, store, dataUnit) {
|
|
2152
|
-
if ("fields" in source) {
|
|
2153
|
-
return index.h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
|
|
2154
|
-
}
|
|
2155
|
-
const errorMsg = dataUnit.getErrorMessage(source.name);
|
|
2156
|
-
const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
|
|
2157
|
-
return index.h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
|
|
2158
|
-
}
|
|
2159
|
-
const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
|
|
2160
|
-
const selectedTab = DataUnit.selectCurrentTab(store.getState(), parentName);
|
|
2161
|
-
const tabs = source.length > 1 ? source.map(form => index.h("ez-tab", { label: form.label, tabKey: form.name })) : null;
|
|
2162
|
-
const { subForms, items, name } = source[selectedTab];
|
|
2163
|
-
const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit);
|
|
2164
|
-
source[selectedTab].dataUnit = dataUnit;
|
|
2165
|
-
const hasSubForms = subForms && subForms.length > 0;
|
|
2166
|
-
const changeTabHandler = (index) => {
|
|
2167
|
-
store.dispatch(DataUnit.changeTab(parentName, index));
|
|
2168
|
-
};
|
|
2169
|
-
//todos os campos e subformulários precisam estar ligados a um DU
|
|
2170
|
-
const currentDU = dataUnit || parentDataUnit;
|
|
2171
|
-
let buttons = DataUnit.selectVisibleButtons(store.getState());
|
|
2172
|
-
if (currentDU.cardinality === "1") {
|
|
2173
|
-
buttons.addVisible = false;
|
|
2174
|
-
buttons.removeVisible = false;
|
|
2175
|
-
buttons.nextVisible = false;
|
|
2176
|
-
buttons.previousVisible = false;
|
|
2177
|
-
}
|
|
2178
|
-
return index.h("div", { class: "form-sheet" },
|
|
2179
|
-
tabs ? index.h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
|
|
2180
|
-
dataUnit ? index.h(NavigationBar, { dataUnit: dataUnit, buttonProps: buttons }) : null,
|
|
2181
|
-
index.h("div", { class: "tab__container" },
|
|
2182
|
-
items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
|
|
2183
|
-
hasSubForms ? index.h(FormSheet, { store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
|
|
2151
|
+
function buildFormItem(source, formName, store, dataUnit) {
|
|
2152
|
+
if ("fields" in source) {
|
|
2153
|
+
return index.h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
|
|
2154
|
+
}
|
|
2155
|
+
const errorMsg = dataUnit.getErrorMessage(source.name);
|
|
2156
|
+
const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
|
|
2157
|
+
return index.h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
|
|
2158
|
+
}
|
|
2159
|
+
const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
|
|
2160
|
+
const selectedTab = DataUnit.selectCurrentTab(store.getState(), parentName);
|
|
2161
|
+
const tabs = source.length > 1 ? source.map(form => index.h("ez-tab", { label: form.label, tabKey: form.name })) : null;
|
|
2162
|
+
const { subForms, items, name } = source[selectedTab];
|
|
2163
|
+
const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit, parentDataUnit);
|
|
2164
|
+
source[selectedTab].dataUnit = dataUnit;
|
|
2165
|
+
const hasSubForms = subForms && subForms.length > 0;
|
|
2166
|
+
const changeTabHandler = (index) => {
|
|
2167
|
+
store.dispatch(DataUnit.changeTab(parentName, index));
|
|
2168
|
+
};
|
|
2169
|
+
//todos os campos e subformulários precisam estar ligados a um DU
|
|
2170
|
+
const currentDU = dataUnit || parentDataUnit;
|
|
2171
|
+
let buttons = DataUnit.selectVisibleButtons(store.getState());
|
|
2172
|
+
if (currentDU.cardinality === "1") {
|
|
2173
|
+
buttons.addVisible = false;
|
|
2174
|
+
buttons.removeVisible = false;
|
|
2175
|
+
buttons.nextVisible = false;
|
|
2176
|
+
buttons.previousVisible = false;
|
|
2177
|
+
}
|
|
2178
|
+
return index.h("div", { class: "form-sheet" },
|
|
2179
|
+
tabs ? index.h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
|
|
2180
|
+
dataUnit ? index.h(NavigationBar, { dataUnit: dataUnit, buttonProps: buttons }) : null,
|
|
2181
|
+
index.h("div", { class: "tab__container" },
|
|
2182
|
+
items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
|
|
2183
|
+
hasSubForms ? index.h(FormSheet, { store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
|
|
2184
2184
|
};
|
|
2185
2185
|
|
|
2186
2186
|
const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
|
|
2187
2187
|
|
|
2188
|
-
const EzForm = class {
|
|
2189
|
-
constructor(hostRef) {
|
|
2190
|
-
index.registerInstance(this, hostRef);
|
|
2191
|
-
this._dataUnits = [];
|
|
2192
|
-
this._requiredFieldsByDU = {};
|
|
2193
|
-
}
|
|
2194
|
-
async validate() {
|
|
2195
|
-
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
2196
|
-
if (!this._dataUnits[i].validateRecords()) {
|
|
2197
|
-
return false;
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
async getChanges() {
|
|
2202
|
-
let allChanges = [];
|
|
2203
|
-
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
2204
|
-
const
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
if (this.metadata) {
|
|
2328
|
-
this.updateMetadata(this.metadata);
|
|
2329
|
-
}
|
|
2330
|
-
else {
|
|
2331
|
-
this.loadMDFromElement((md) => this.updateMetadata(md));
|
|
2332
|
-
if (!this.metadata) {
|
|
2333
|
-
this.loadMDFromExecutor((md) => this.updateMetadata(md));
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
buildDataUnit(dataUnit) {
|
|
2338
|
-
if (dataUnit) {
|
|
2339
|
-
const { name, unitLabel, records, cardinality } = dataUnit;
|
|
2340
|
-
if (!(dataUnit instanceof DataUnit.DataUnit)) {
|
|
2341
|
-
dataUnit = new DataUnit.DataUnit(name, unitLabel, cardinality);
|
|
2342
|
-
this._dataUnits.push(dataUnit);
|
|
2343
|
-
if (records) {
|
|
2344
|
-
dataUnit.records = records;
|
|
2345
|
-
}
|
|
2346
|
-
dataUnit.store = this._store;
|
|
2347
|
-
dataUnit.loadExecutor = this.
|
|
2348
|
-
dataUnit.saveExecutor = this.
|
|
2349
|
-
dataUnit.removeExecutor = this.
|
|
2350
|
-
dataUnit.recordsValidator = this;
|
|
2351
|
-
dataUnit.fieldSearchExecutor = this.
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
return dataUnit;
|
|
2355
|
-
}
|
|
2356
|
-
render() {
|
|
2357
|
-
return this.metadata ? index.h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
|
|
2358
|
-
}
|
|
2359
|
-
get _host() { return index.getElement(this); }
|
|
2360
|
-
};
|
|
2188
|
+
const EzForm = class {
|
|
2189
|
+
constructor(hostRef) {
|
|
2190
|
+
index.registerInstance(this, hostRef);
|
|
2191
|
+
this._dataUnits = [];
|
|
2192
|
+
this._requiredFieldsByDU = {};
|
|
2193
|
+
}
|
|
2194
|
+
async validate() {
|
|
2195
|
+
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
2196
|
+
if (!this._dataUnits[i].validateRecords()) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
async getChanges() {
|
|
2202
|
+
let allChanges = [];
|
|
2203
|
+
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
2204
|
+
const du = this._dataUnits[i];
|
|
2205
|
+
//Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
|
|
2206
|
+
if (!du.parentDU) {
|
|
2207
|
+
const duChanges = du.getChangesToSave();
|
|
2208
|
+
if (duChanges) {
|
|
2209
|
+
allChanges = allChanges.concat(duChanges);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return allChanges;
|
|
2214
|
+
}
|
|
2215
|
+
validateRecords(dataUnit, records) {
|
|
2216
|
+
const result = { isValid: true, message: '' };
|
|
2217
|
+
const reqFields = this._requiredFieldsByDU[dataUnit.name];
|
|
2218
|
+
const recordValidator = record => {
|
|
2219
|
+
reqFields.forEach(field => {
|
|
2220
|
+
const recordIndex = record["record__index"];
|
|
2221
|
+
const fieldName = field.name;
|
|
2222
|
+
const fieldValue = record[fieldName];
|
|
2223
|
+
if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
|
|
2224
|
+
this._store.dispatch(DataUnit.invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
|
|
2225
|
+
result.isValid = false;
|
|
2226
|
+
result.message = "Há pelo menos um campo obrigatório não preenchido.";
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
};
|
|
2230
|
+
if (records.length == 0) {
|
|
2231
|
+
recordValidator({});
|
|
2232
|
+
}
|
|
2233
|
+
else {
|
|
2234
|
+
records.forEach(recordValidator);
|
|
2235
|
+
}
|
|
2236
|
+
return result;
|
|
2237
|
+
}
|
|
2238
|
+
componentWillRender() {
|
|
2239
|
+
if (this._store === undefined) {
|
|
2240
|
+
const rootReducer = combineReducers({
|
|
2241
|
+
"hist": undoable(formReducer),
|
|
2242
|
+
"nonhist": formNonHistoricReducer
|
|
2243
|
+
});
|
|
2244
|
+
this._store = createStore(rootReducer, applyMiddleware(thunk));
|
|
2245
|
+
this._store.subscribe(() => { index.forceUpdate(this); });
|
|
2246
|
+
if (this.slavemode) {
|
|
2247
|
+
this._store.dispatch(DataUnit.showHideNavigationButtons("saveVisible", false));
|
|
2248
|
+
this._store.dispatch(DataUnit.showHideNavigationButtons("cancelVisible", false));
|
|
2249
|
+
this._store.dispatch(DataUnit.showHideNavigationButtons("reloadVisible", false));
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
loadMDFromExecutor(callBack) {
|
|
2254
|
+
const loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
|
|
2255
|
+
if (loadMetadataFunction) {
|
|
2256
|
+
const result = loadMetadataFunction();
|
|
2257
|
+
if (result) {
|
|
2258
|
+
if (result instanceof Promise) {
|
|
2259
|
+
result.then(md => {
|
|
2260
|
+
callBack(md);
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
else {
|
|
2264
|
+
callBack(result);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
loadMDFromElement(callBack) {
|
|
2270
|
+
const metadata = [];
|
|
2271
|
+
Array.from(this._host.children).forEach(elem => {
|
|
2272
|
+
if (elem.tagName === "FORM-METADATA") {
|
|
2273
|
+
const formMetadata = elem;
|
|
2274
|
+
metadata.push(formMetadata.metadata);
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
callBack(metadata.length > 0 ? metadata : null);
|
|
2278
|
+
}
|
|
2279
|
+
updateMetadata(metadata) {
|
|
2280
|
+
if (metadata) {
|
|
2281
|
+
const processFields = (duName, form, tabController, tabIndex) => {
|
|
2282
|
+
var _a;
|
|
2283
|
+
let requiredFields = this._requiredFieldsByDU[duName];
|
|
2284
|
+
if (requiredFields === undefined) {
|
|
2285
|
+
requiredFields = [];
|
|
2286
|
+
this._requiredFieldsByDU[duName] = requiredFields;
|
|
2287
|
+
}
|
|
2288
|
+
form.items.forEach(item => {
|
|
2289
|
+
if ("fields" in item) {
|
|
2290
|
+
const fSet = item;
|
|
2291
|
+
fSet.fields.forEach(f => {
|
|
2292
|
+
f.tabControler = tabController;
|
|
2293
|
+
f.tabIndex = tabIndex;
|
|
2294
|
+
if (f.required) {
|
|
2295
|
+
requiredFields.push(f);
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
else {
|
|
2300
|
+
const f = item;
|
|
2301
|
+
f.tabControler = tabController;
|
|
2302
|
+
f.tabIndex = tabIndex;
|
|
2303
|
+
if (f.required) {
|
|
2304
|
+
requiredFields.push(f);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
});
|
|
2308
|
+
(_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
|
|
2309
|
+
const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
|
|
2310
|
+
processFields(subDU, subForm, form.name, index);
|
|
2311
|
+
});
|
|
2312
|
+
};
|
|
2313
|
+
this.metadata = metadata;
|
|
2314
|
+
metadata.map((form, index) => {
|
|
2315
|
+
processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
|
|
2316
|
+
});
|
|
2317
|
+
this._store.dispatch(DataUnit.formLoad());
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
parseExecutor(executor) {
|
|
2321
|
+
if (executor) {
|
|
2322
|
+
return executor instanceof Function ? executor : eval(executor);
|
|
2323
|
+
}
|
|
2324
|
+
return null;
|
|
2325
|
+
}
|
|
2326
|
+
componentDidLoad() {
|
|
2327
|
+
if (this.metadata) {
|
|
2328
|
+
this.updateMetadata(this.metadata);
|
|
2329
|
+
}
|
|
2330
|
+
else {
|
|
2331
|
+
this.loadMDFromElement((md) => this.updateMetadata(md));
|
|
2332
|
+
if (!this.metadata) {
|
|
2333
|
+
this.loadMDFromExecutor((md) => this.updateMetadata(md));
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
buildDataUnit(dataUnit, parentDataUnit) {
|
|
2338
|
+
if (dataUnit) {
|
|
2339
|
+
const { name, unitLabel, records, cardinality } = dataUnit;
|
|
2340
|
+
if (!(dataUnit instanceof DataUnit.DataUnit)) {
|
|
2341
|
+
dataUnit = new DataUnit.DataUnit(name, unitLabel, cardinality, parentDataUnit);
|
|
2342
|
+
this._dataUnits.push(dataUnit);
|
|
2343
|
+
if (records) {
|
|
2344
|
+
dataUnit.records = records;
|
|
2345
|
+
}
|
|
2346
|
+
dataUnit.store = this._store;
|
|
2347
|
+
dataUnit.loadExecutor = this.parseExecutor(this.loadexecutor);
|
|
2348
|
+
dataUnit.saveExecutor = this.parseExecutor(this.saveexecutor);
|
|
2349
|
+
dataUnit.removeExecutor = this.parseExecutor(this.removeexecutor);
|
|
2350
|
+
dataUnit.recordsValidator = this;
|
|
2351
|
+
dataUnit.fieldSearchExecutor = this.parseExecutor(this.fieldsearchexecutor);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
return dataUnit;
|
|
2355
|
+
}
|
|
2356
|
+
render() {
|
|
2357
|
+
return this.metadata ? index.h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
|
|
2358
|
+
}
|
|
2359
|
+
get _host() { return index.getElement(this); }
|
|
2360
|
+
};
|
|
2361
2361
|
EzForm.style = ezFormCss;
|
|
2362
2362
|
|
|
2363
2363
|
const ezIconCss = ":host{display:block;overflow:hidden;position:relative}svg{display:flex;justify-content:center;align-items:center;fill:var(--color--icon)}.x-small{width:12px;height:12px}.small{width:16px;height:16px}.medium{width:20px;height:20px}.large{width:24px;height:24px}.x-large{width:30px;height:30px}";
|
|
2364
2364
|
|
|
2365
|
-
const EzIcon = class {
|
|
2366
|
-
constructor(hostRef) {
|
|
2367
|
-
index.registerInstance(this, hostRef);
|
|
2368
|
-
/*Tamanho do icone*/
|
|
2369
|
-
this.size = 'medium';
|
|
2370
|
-
}
|
|
2371
|
-
render() {
|
|
2372
|
-
return (index.h("svg", { class: this.size, role: "img" }, index.h("use", { xlinkHref: this.href })));
|
|
2373
|
-
}
|
|
2374
|
-
};
|
|
2365
|
+
const EzIcon = class {
|
|
2366
|
+
constructor(hostRef) {
|
|
2367
|
+
index.registerInstance(this, hostRef);
|
|
2368
|
+
/*Tamanho do icone*/
|
|
2369
|
+
this.size = 'medium';
|
|
2370
|
+
}
|
|
2371
|
+
render() {
|
|
2372
|
+
return (index.h("svg", { class: this.size, role: "img" }, index.h("use", { xlinkHref: this.href })));
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
2375
|
EzIcon.style = ezIconCss;
|
|
2376
2376
|
|
|
2377
2377
|
const ezPopoverCss = ":host{--pop__box--border-radius:var(--border--radius-medium, 12px);--pop__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);position:relative;display:flex;user-select:none;width:100%}.box{z-index:var(--more-visible, 1);display:flex;flex-direction:column;height:fit-content;background-color:transparent;border-radius:var(--pop__box--border-radius);box-shadow:var(--pop__box--box-shadow)}.box--fit-content{width:fit-content}.box--full-width{width:100%}";
|
|
2378
2378
|
|
|
2379
|
-
const EzPopover = class {
|
|
2380
|
-
constructor(hostRef) {
|
|
2381
|
-
index.registerInstance(this, hostRef);
|
|
2382
|
-
this._firstRender = true;
|
|
2383
|
-
/**
|
|
2384
|
-
* No modo floating = false o popover só se tornará visível
|
|
2385
|
-
* quando o método show() for acionado.
|
|
2386
|
-
*/
|
|
2387
|
-
this.autoclose = true;
|
|
2388
|
-
/**
|
|
2389
|
-
* Offset top do popover em relação ao componente pai
|
|
2390
|
-
*/
|
|
2391
|
-
this.top = '0px';
|
|
2392
|
-
/**
|
|
2393
|
-
* Offset left do popover em relação ao componente pai
|
|
2394
|
-
*/
|
|
2395
|
-
this.left = '0px';
|
|
2396
|
-
/**
|
|
2397
|
-
* Offset bottom do popover em relação ao componente pai
|
|
2398
|
-
*/
|
|
2399
|
-
this.bottom = '0px';
|
|
2400
|
-
/**
|
|
2401
|
-
* Offset right do popover em relação ao componente pai
|
|
2402
|
-
*/
|
|
2403
|
-
this.right = '0px';
|
|
2404
|
-
/**
|
|
2405
|
-
* Ajusta o comportamento da largura do popover.
|
|
2406
|
-
* Opções: "100% e "fit-content" (default)
|
|
2407
|
-
*/
|
|
2408
|
-
this.boxwidth = 'fit-content';
|
|
2409
|
-
}
|
|
2410
|
-
/**
|
|
2411
|
-
* Atualiza a posição do popover em relação ao componente pai.
|
|
2412
|
-
*/
|
|
2413
|
-
async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
|
|
2414
|
-
const floatingOptions = {
|
|
2415
|
-
autoClose: this.autoclose,
|
|
2416
|
-
top,
|
|
2417
|
-
left,
|
|
2418
|
-
bottom,
|
|
2419
|
-
right,
|
|
2420
|
-
innerClickTest: (_container, node) => {
|
|
2421
|
-
if (_container.contains(node)) {
|
|
2422
|
-
return true;
|
|
2423
|
-
}
|
|
2424
|
-
if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
|
|
2425
|
-
return true;
|
|
2426
|
-
}
|
|
2427
|
-
//Here: we pass this._box as parameter but we need to change to _host
|
|
2428
|
-
//because we need to get the lasChild (inner content to put in slot)
|
|
2429
|
-
_container = this._host;
|
|
2430
|
-
return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
|
|
2431
|
-
}
|
|
2432
|
-
};
|
|
2433
|
-
FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
|
|
2434
|
-
}
|
|
2435
|
-
/**
|
|
2436
|
-
* Faz com que o popover seja renderizado na DOM.
|
|
2437
|
-
*
|
|
2438
|
-
*/
|
|
2439
|
-
async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
|
|
2440
|
-
const floatingOptions = {
|
|
2441
|
-
autoClose: this.autoclose,
|
|
2442
|
-
top,
|
|
2443
|
-
left,
|
|
2444
|
-
bottom,
|
|
2445
|
-
right,
|
|
2446
|
-
innerClickTest: (_container, node) => {
|
|
2447
|
-
if (_container.contains(node)) {
|
|
2448
|
-
return true;
|
|
2449
|
-
}
|
|
2450
|
-
if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
|
|
2451
|
-
return true;
|
|
2452
|
-
}
|
|
2453
|
-
// Here: we pass this._box as parameter but we need to change to _host
|
|
2454
|
-
// because we need to get the lasChild (inner content to put in slot)
|
|
2455
|
-
_container = this._host;
|
|
2456
|
-
return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
|
|
2457
|
-
}
|
|
2458
|
-
};
|
|
2459
|
-
this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
|
|
2460
|
-
this.isOpened = true;
|
|
2461
|
-
}
|
|
2462
|
-
/**
|
|
2463
|
-
* Usado no modo floating. Faz com que o componente seja ocultado.
|
|
2464
|
-
*/
|
|
2465
|
-
async hide() {
|
|
2466
|
-
if (this._floatingID !== undefined) {
|
|
2467
|
-
FloatingManager.close(this._floatingID);
|
|
2468
|
-
this._floatingID = undefined;
|
|
2469
|
-
this.isOpened = false;
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
componentDidRender() {
|
|
2473
|
-
if (this._firstRender) {
|
|
2474
|
-
this._box.remove();
|
|
2475
|
-
this._firstRender = false;
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
render() {
|
|
2479
|
-
return (index.h(index.Host, null, index.h("section", { ref: el => this._container = el }, index.h("div", { class: `box ${this.boxwidth === 'fit-content' ? 'box--fit-content' : 'box--full-width'}`, ref: el => this._box = el }, index.h("slot", null)))));
|
|
2480
|
-
}
|
|
2481
|
-
get _host() { return index.getElement(this); }
|
|
2482
|
-
};
|
|
2379
|
+
const EzPopover = class {
|
|
2380
|
+
constructor(hostRef) {
|
|
2381
|
+
index.registerInstance(this, hostRef);
|
|
2382
|
+
this._firstRender = true;
|
|
2383
|
+
/**
|
|
2384
|
+
* No modo floating = false o popover só se tornará visível
|
|
2385
|
+
* quando o método show() for acionado.
|
|
2386
|
+
*/
|
|
2387
|
+
this.autoclose = true;
|
|
2388
|
+
/**
|
|
2389
|
+
* Offset top do popover em relação ao componente pai
|
|
2390
|
+
*/
|
|
2391
|
+
this.top = '0px';
|
|
2392
|
+
/**
|
|
2393
|
+
* Offset left do popover em relação ao componente pai
|
|
2394
|
+
*/
|
|
2395
|
+
this.left = '0px';
|
|
2396
|
+
/**
|
|
2397
|
+
* Offset bottom do popover em relação ao componente pai
|
|
2398
|
+
*/
|
|
2399
|
+
this.bottom = '0px';
|
|
2400
|
+
/**
|
|
2401
|
+
* Offset right do popover em relação ao componente pai
|
|
2402
|
+
*/
|
|
2403
|
+
this.right = '0px';
|
|
2404
|
+
/**
|
|
2405
|
+
* Ajusta o comportamento da largura do popover.
|
|
2406
|
+
* Opções: "100% e "fit-content" (default)
|
|
2407
|
+
*/
|
|
2408
|
+
this.boxwidth = 'fit-content';
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Atualiza a posição do popover em relação ao componente pai.
|
|
2412
|
+
*/
|
|
2413
|
+
async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
|
|
2414
|
+
const floatingOptions = {
|
|
2415
|
+
autoClose: this.autoclose,
|
|
2416
|
+
top,
|
|
2417
|
+
left,
|
|
2418
|
+
bottom,
|
|
2419
|
+
right,
|
|
2420
|
+
innerClickTest: (_container, node) => {
|
|
2421
|
+
if (_container.contains(node)) {
|
|
2422
|
+
return true;
|
|
2423
|
+
}
|
|
2424
|
+
if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
|
|
2425
|
+
return true;
|
|
2426
|
+
}
|
|
2427
|
+
//Here: we pass this._box as parameter but we need to change to _host
|
|
2428
|
+
//because we need to get the lasChild (inner content to put in slot)
|
|
2429
|
+
_container = this._host;
|
|
2430
|
+
return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
|
|
2431
|
+
}
|
|
2432
|
+
};
|
|
2433
|
+
FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Faz com que o popover seja renderizado na DOM.
|
|
2437
|
+
*
|
|
2438
|
+
*/
|
|
2439
|
+
async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
|
|
2440
|
+
const floatingOptions = {
|
|
2441
|
+
autoClose: this.autoclose,
|
|
2442
|
+
top,
|
|
2443
|
+
left,
|
|
2444
|
+
bottom,
|
|
2445
|
+
right,
|
|
2446
|
+
innerClickTest: (_container, node) => {
|
|
2447
|
+
if (_container.contains(node)) {
|
|
2448
|
+
return true;
|
|
2449
|
+
}
|
|
2450
|
+
if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
|
|
2451
|
+
return true;
|
|
2452
|
+
}
|
|
2453
|
+
// Here: we pass this._box as parameter but we need to change to _host
|
|
2454
|
+
// because we need to get the lasChild (inner content to put in slot)
|
|
2455
|
+
_container = this._host;
|
|
2456
|
+
return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
|
|
2457
|
+
}
|
|
2458
|
+
};
|
|
2459
|
+
this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
|
|
2460
|
+
this.isOpened = true;
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Usado no modo floating. Faz com que o componente seja ocultado.
|
|
2464
|
+
*/
|
|
2465
|
+
async hide() {
|
|
2466
|
+
if (this._floatingID !== undefined) {
|
|
2467
|
+
FloatingManager.close(this._floatingID);
|
|
2468
|
+
this._floatingID = undefined;
|
|
2469
|
+
this.isOpened = false;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
componentDidRender() {
|
|
2473
|
+
if (this._firstRender) {
|
|
2474
|
+
this._box.remove();
|
|
2475
|
+
this._firstRender = false;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
render() {
|
|
2479
|
+
return (index.h(index.Host, null, index.h("section", { ref: el => this._container = el }, index.h("div", { class: `box ${this.boxwidth === 'fit-content' ? 'box--fit-content' : 'box--full-width'}`, ref: el => this._box = el }, index.h("slot", null)))));
|
|
2480
|
+
}
|
|
2481
|
+
get _host() { return index.getElement(this); }
|
|
2482
|
+
};
|
|
2483
2483
|
EzPopover.style = ezPopoverCss;
|
|
2484
2484
|
|
|
2485
2485
|
const ezSearchCss = ":host{--srch--height:42px;--srch--width:100%;--srch__icon--width:48px;--srch--border-radius:var(--border--radius-medium, 12px);--srch--border-radius-small:var(--border--radius-small, 6px);--srch--font-size:var(--text--medium, 14px);--srch--font-family:var(--font-pattern, Arial);--srch--font-weight--large:var(--text-weight--large, 500);--srch--font-weight--medium:var(--text-weight--medium, 400);--srch--space--medium:var(--space--medium, 12px);--srch--space--small:var(--space--small, 6px);--srch--shadow:var(--shadow, 0px 0px 16px 0px rgba(0, 38, 111, .12));--srch--background-color--xlight:var(--background--xlight,#fff);--srch__list-z-index:var(--more-visible, 1);--srch__input--background-color:var(--background--medium, #e0e0e0);--srch__input--border:var(--border--medium, 2px solid);--srch__input--border-color:var(--srch__input--background-color);--srch__input--focus--border-color:var(--color--primary, #008561);--srch__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--srch__input--disabled--color:var(--text--disable, #AFB6C0);--srch__input--error--border-color:#CC2936;--srch__label--color:var(--title--primary, #919191);--srch__message_box--font-size:var(--text--small, 12px);--srch__message_box--info--color:var(--color--success, #22085d);--srch__message_box--error--color:var(--color--error, #FF0000);--srch__list-text--primary:var(--text--primary,#626e82);--srch__list-text--secondary:var(--text--secondary,#a2abb9);--srch__list-height:calc(4px + var(--srch--font-size) + var(--srch--space--medium));display:flex;flex-wrap:wrap;position:relative;width:var(--srch--width)}ez-text-input{--it__input--background-color:var(--srch__input--background-color, #FFFFFF);--it__input--border-color:var(--srch__input--border-color, #DCE0E8)}input{width:100%;box-sizing:border-box;padding:var(--space--medium);height:var(--srch--height);border-radius:var(--srch--border-radius);font-family:var(--srch--font-family);font-size:var(--srch--font-size);border:var(--srch__input--border);border-color:var(--srch__input--border-color);background-color:var(--srch__input--background-color);font-weight:var(--text-weight--large)}input:disabled{background-color:var(--srch__input--disabled--background-color);color:var(--srch__input--disabled--color)}input:focus{outline:none;border-color:var(--srch__input--focus--border-color)}input.icon--left{padding-left:var(--srch__icon--width)}input.icon--right{padding-right:var(--srch__icon--width)}input::placeholder{color:var(--srch__placeholder--color);font-weight:var(--srch__placeholder--font-weight)}input:disabled::placeholder{color:var(--srch__placeholder--disabled--color)}input.hasError{color:inherit;border-color:var(--srch__input--error--border-color)}input.text--right{text-align:right}ez-text-input{--it__input--background-color:var(--srch__input--background-color, #FFFFFF);--it__input--border-color:var(--srch__input--border-color, #DCE0E8)}.message-box{min-height:0;min-width:100%;margin-top:2px;line-height:12px;font-family:var(--srch--font-family);font-size:var(--srch__message_box--font-size);color:var(--srch__message_box--info--color)}.hasError{min-height:16px;color:var(--srch__message_box--error--color)}.input__label{font-size:var(--text--medium);font-weight:var(--text-weight--large);left:var(--space--medium);position:absolute;color:var(--title--primary);top:var(--space--medium);font-family:var(--srch--font-family);-webkit-transition:font-size .3s, top .3s;transition:font-size .3s, top .3s;z-index:var(--visible)}.input__label--floated{font-family:var(--srch--font-family);font-size:var(--text--extra-small);top:var(--space--small);color:var(--text--primary)}.input__label--left{left:var(--srch__icon--width)}.input--with--label{padding-bottom:0}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;font-family:var(--srch--font-family);font-size:var(--srch__message_box--font-size);color:var(--srch__message_box--info--color)}.hasError{color:var(--srch__message_box--error--color)}.list-container{z-index:var(--srch__list-z-index);padding:var(--srch--space--small);background:var(--srch--background-color--xlight);border-radius:var(--srch--border-radius);width:100%;overflow:auto;box-sizing:border-box;max-height:calc(4*var(--srch__list-height) + 2*var(--srch--space--small))}li{list-style-type:none;border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);display:flex;justify-content:space-between;align-items:center}li:hover{background-color:var(--background--medium)}.--li__spanlabel{color:var(--srch__list-text--primary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--large);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:80%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanlabel--full-width{color:var(--srch__list-text--primary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--large);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:100%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanvalue{color:var(--srch__list-text--secondary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--medium);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:20%;min-width:20px;overflow-x:hidden;text-align:right}.btn-open-search{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-search:disabled{cursor:unset}.btn-open-search::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:22px;height:22px;clip-path:path(\"m 9.4,2.3 c 4.1,0 7.4,3.2 7.4,7.2 0,1.8 -0.7,3.4 -1.8,4.7 l 0.3,0.3 h 0.9 l 5.7,5.6 -1.7,1.7 -5.7,-5.6 V 15.3 L 14.3,15 C 13,16.1 11.3,16.7 9.5,16.7 5.3,16.7 2,13.5 2,9.5 2,5.5 5.3,2.3 9.4,2.3 m 0,2.2 c -2.9,0 -5.1,2.2 -5.1,5 0,2.8 2.3,5 5.1,5 2.8,0 5.1,-2.2 5.1,-5 0,-2.8 -2.2,-5 -5.1,-5 z\")}.btn-open-search:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-search:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}.--li--preselected{background-color:var(--background--strong)}";
|
|
2486
2486
|
|
|
2487
|
-
const EzSearch = class {
|
|
2488
|
-
constructor(hostRef) {
|
|
2489
|
-
index.registerInstance(this, hostRef);
|
|
2490
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
2491
|
-
this._options = [];
|
|
2492
|
-
this._classSelect = 'list-container--4row';
|
|
2493
|
-
/**
|
|
2494
|
-
* Deixa o campo disponível ou não para digitação.
|
|
2495
|
-
*/
|
|
2496
|
-
this.enabled = true;
|
|
2497
|
-
/**
|
|
2498
|
-
* Quantidade máxima de itens guardados no localstorage
|
|
2499
|
-
*/
|
|
2500
|
-
this.qtdHotItems = 6;
|
|
2501
|
-
/**
|
|
2502
|
-
* Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
|
|
2503
|
-
*/
|
|
2504
|
-
this.showvalue = false;
|
|
2505
|
-
///// HOTSEARCH /////
|
|
2506
|
-
this.buildId = () => {
|
|
2507
|
-
return btoa(`${this.hotsearchid}:${location.pathname}`);
|
|
2508
|
-
};
|
|
2509
|
-
this.getStorageItems = (key) => {
|
|
2510
|
-
let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
|
|
2511
|
-
let storageItems = [];
|
|
2512
|
-
if (storageValueStr !== null) {
|
|
2513
|
-
storageItems = JSON.parse(storageValueStr);
|
|
2514
|
-
}
|
|
2515
|
-
return storageItems;
|
|
2516
|
-
};
|
|
2517
|
-
this.orderHotList = (list) => {
|
|
2518
|
-
return list.sort((a, b) => {
|
|
2519
|
-
let time1 = new Date(a.dtRecent).getTime();
|
|
2520
|
-
let time2 = new Date(b.dtRecent).getTime();
|
|
2521
|
-
let qtd1 = a.qtd;
|
|
2522
|
-
let qtd2 = b.qtd;
|
|
2523
|
-
if (time1 < time2)
|
|
2524
|
-
return -1;
|
|
2525
|
-
if (time1 > time2)
|
|
2526
|
-
return 1;
|
|
2527
|
-
if (qtd1 > qtd2)
|
|
2528
|
-
return -1;
|
|
2529
|
-
if (qtd1 < qtd2)
|
|
2530
|
-
return 1;
|
|
2531
|
-
return 0;
|
|
2532
|
-
});
|
|
2533
|
-
};
|
|
2534
|
-
this.saveStorageItem = (key, value) => {
|
|
2535
|
-
if (value == '' || value == undefined)
|
|
2536
|
-
return;
|
|
2537
|
-
let storageItem = this.getStorageItems(key);
|
|
2538
|
-
let element = this.getElement(storageItem, value);
|
|
2539
|
-
if (element) {
|
|
2540
|
-
element.qtd++;
|
|
2541
|
-
element.dtRecent = this.getOnlyDate();
|
|
2542
|
-
}
|
|
2543
|
-
else {
|
|
2544
|
-
if (storageItem.length >= this.qtdHotItems) {
|
|
2545
|
-
storageItem = this.orderHotList(storageItem);
|
|
2546
|
-
storageItem.splice(-1, 1);
|
|
2547
|
-
}
|
|
2548
|
-
storageItem.push({
|
|
2549
|
-
description: value,
|
|
2550
|
-
qtd: 1,
|
|
2551
|
-
dtRecent: this.getOnlyDate()
|
|
2552
|
-
});
|
|
2553
|
-
}
|
|
2554
|
-
localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
|
|
2555
|
-
return storageItem;
|
|
2556
|
-
};
|
|
2557
|
-
this.adjustOptions = (arrayOptions) => {
|
|
2558
|
-
let optionsTemp = [];
|
|
2559
|
-
arrayOptions.map(el => {
|
|
2560
|
-
optionsTemp.push({
|
|
2561
|
-
value: el.value,
|
|
2562
|
-
label: el.label,
|
|
2563
|
-
ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
|
|
2564
|
-
});
|
|
2565
|
-
});
|
|
2566
|
-
return optionsTemp;
|
|
2567
|
-
};
|
|
2568
|
-
this.sortArrayOptions = (array, propname) => {
|
|
2569
|
-
const sortedArray = array.sort(function (a, b) {
|
|
2570
|
-
if (a[propname] < b[propname]) {
|
|
2571
|
-
return -1;
|
|
2572
|
-
}
|
|
2573
|
-
if (a[propname] > b[propname]) {
|
|
2574
|
-
return 1;
|
|
2575
|
-
}
|
|
2576
|
-
return 0;
|
|
2577
|
-
});
|
|
2578
|
-
return sortedArray;
|
|
2579
|
-
};
|
|
2580
|
-
}
|
|
2581
|
-
valueChanged() {
|
|
2582
|
-
var _a;
|
|
2583
|
-
if (this.value) {
|
|
2584
|
-
this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
|
|
2585
|
-
let key = this.buildId();
|
|
2586
|
-
this.saveStorageItem(key, this.value);
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
//ajustar ao fim do teste
|
|
2590
|
-
onInputTeste() {
|
|
2591
|
-
if (this._inputElem) {
|
|
2592
|
-
this.handleChange();
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
getElement(storageItem, value) {
|
|
2596
|
-
return storageItem.find(e => e.description === value);
|
|
2597
|
-
}
|
|
2598
|
-
getOnlyDate() {
|
|
2599
|
-
let dt = new Date();
|
|
2600
|
-
dt.setHours(0);
|
|
2601
|
-
dt.setMinutes(0);
|
|
2602
|
-
dt.setSeconds(0);
|
|
2603
|
-
dt.setUTCMilliseconds(0);
|
|
2604
|
-
return dt.toString();
|
|
2605
|
-
}
|
|
2606
|
-
onInputChange(ev) {
|
|
2607
|
-
const el = ev.target;
|
|
2608
|
-
let key = this.buildId();
|
|
2609
|
-
this.saveStorageItem(key, el.value);
|
|
2610
|
-
}
|
|
2611
|
-
buildDataList() {
|
|
2612
|
-
try {
|
|
2613
|
-
if (this.hotsearchid === undefined) {
|
|
2614
|
-
return;
|
|
2615
|
-
}
|
|
2616
|
-
let key = this.buildId();
|
|
2617
|
-
let optionsArray = [];
|
|
2618
|
-
this._options = [];
|
|
2619
|
-
if (this.getStorageItems(key).length > 0) {
|
|
2620
|
-
this.orderHotList(this.getStorageItems(key))
|
|
2621
|
-
.forEach((el) => {
|
|
2622
|
-
optionsArray.push({
|
|
2623
|
-
value: el.description,
|
|
2624
|
-
label: el.description,
|
|
2625
|
-
});
|
|
2626
|
-
});
|
|
2627
|
-
this._options = [{ value: '', label: '' }].concat(optionsArray);
|
|
2628
|
-
this.buildOptions();
|
|
2629
|
-
}
|
|
2630
|
-
}
|
|
2631
|
-
catch (err) {
|
|
2632
|
-
this.errormessage = err;
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
///// EVENT HANDLERS
|
|
2636
|
-
buildItem(opt, index$1) {
|
|
2637
|
-
const className = index$1 === this._preSelection ? "--li--preselected" : "";
|
|
2638
|
-
return index.h("li", { class: className, key: opt.ajustedValue, accessKey: opt.label.toString(), id: 'item_' + opt.ajustedValue, onMouseDown: (ev) => this.handleSetValueByOption(ev) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { title: opt.ajustedValue, class: '--li__spanvalue' }, opt.ajustedValue) : null);
|
|
2639
|
-
}
|
|
2640
|
-
highlightMatch(label) {
|
|
2641
|
-
var _a;
|
|
2642
|
-
const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
|
|
2643
|
-
if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
|
|
2644
|
-
const criteriaLength = this._inputElem.value.length;
|
|
2645
|
-
const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
|
|
2646
|
-
if (matchStart > -1) {
|
|
2647
|
-
const strLabelStart = label.substr(0, matchStart);
|
|
2648
|
-
const strLabelEnd = label.substr(matchStart + criteriaLength);
|
|
2649
|
-
const strMatch = label.substr(matchStart, criteriaLength);
|
|
2650
|
-
return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
return (index.h("span", { class: spanClassName }, label));
|
|
2654
|
-
}
|
|
2655
|
-
showOptions() {
|
|
2656
|
-
if (this.enabled) {
|
|
2657
|
-
const top = this._inputElem.errormessage ? '0px' : '-17px';
|
|
2658
|
-
this._popover.show(top);
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
nextOption() {
|
|
2662
|
-
this.showOptions();
|
|
2663
|
-
this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
|
|
2664
|
-
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
2665
|
-
}
|
|
2666
|
-
previousOption() {
|
|
2667
|
-
this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
|
|
2668
|
-
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
2669
|
-
}
|
|
2670
|
-
scrollToOption(opt) {
|
|
2671
|
-
const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
|
|
2672
|
-
if (liElem) {
|
|
2673
|
-
const parent = liElem.parentElement;
|
|
2674
|
-
const parentRect = parent.getBoundingClientRect();
|
|
2675
|
-
const itemRect = liElem.getBoundingClientRect();
|
|
2676
|
-
if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
|
|
2677
|
-
liElem.scrollIntoView();
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
}
|
|
2681
|
-
selectCurrentOption() {
|
|
2682
|
-
if (this._preSelection !== undefined) {
|
|
2683
|
-
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
2684
|
-
this._preSelection = undefined;
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
selectOption(opt) {
|
|
2688
|
-
this._popover.hide();
|
|
2689
|
-
this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
|
|
2690
|
-
this._inputElem.value = opt.value;
|
|
2691
|
-
//Definir com a equipe de design se vai ser utilizado dessa forma.
|
|
2692
|
-
// this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
|
|
2693
|
-
}
|
|
2694
|
-
keyDownHandler(event) {
|
|
2695
|
-
switch (event.key) {
|
|
2696
|
-
case "ArrowDown":
|
|
2697
|
-
this.nextOption();
|
|
2698
|
-
break;
|
|
2699
|
-
case "ArrowUp":
|
|
2700
|
-
this.previousOption();
|
|
2701
|
-
break;
|
|
2702
|
-
case "Enter":
|
|
2703
|
-
this.selectCurrentOption();
|
|
2704
|
-
break;
|
|
2705
|
-
}
|
|
2706
|
-
event.stopPropagation();
|
|
2707
|
-
}
|
|
2708
|
-
handleSetValueByOption(ev) {
|
|
2709
|
-
this._popover.hide();
|
|
2710
|
-
const spanEl = ev.target;
|
|
2711
|
-
const sourceElement = ev.composedPath()[0];
|
|
2712
|
-
let li;
|
|
2713
|
-
if (sourceElement.tagName === 'SPAN') {
|
|
2714
|
-
li = spanEl.parentNode;
|
|
2715
|
-
}
|
|
2716
|
-
else {
|
|
2717
|
-
li = spanEl.parentNode.parentNode;
|
|
2718
|
-
}
|
|
2719
|
-
this.value = li.id.split('_')[1];
|
|
2720
|
-
this._inputElem.value = li.accessKey;
|
|
2721
|
-
this.ezChange.emit();
|
|
2722
|
-
}
|
|
2723
|
-
handleChange() {
|
|
2724
|
-
if (this._changeDeboucing) {
|
|
2725
|
-
window.clearTimeout(this._changeDeboucing);
|
|
2726
|
-
}
|
|
2727
|
-
this._changeDeboucing = window.setTimeout(() => {
|
|
2728
|
-
var _a, _b;
|
|
2729
|
-
if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
|
|
2730
|
-
return;
|
|
2731
|
-
}
|
|
2732
|
-
/* save tip on localStorage */
|
|
2733
|
-
let key = this.buildId();
|
|
2734
|
-
this.saveStorageItem(key, this._inputElem.value);
|
|
2735
|
-
/* load data */
|
|
2736
|
-
if (this.loadexecutor) {
|
|
2737
|
-
this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
|
|
2738
|
-
}
|
|
2739
|
-
}, 200);
|
|
2740
|
-
}
|
|
2741
|
-
normalizeResult(data) {
|
|
2742
|
-
let options = [];
|
|
2743
|
-
if (data instanceof Array) {
|
|
2744
|
-
options = data;
|
|
2745
|
-
}
|
|
2746
|
-
else {
|
|
2747
|
-
if (data instanceof Object) {
|
|
2748
|
-
for (var key in data) {
|
|
2749
|
-
let newOption = { value: '', label: '' };
|
|
2750
|
-
newOption.value = key;
|
|
2751
|
-
newOption.label = data[key];
|
|
2752
|
-
options.push(newOption);
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
this._options = [{ value: '', label: '' }].concat(options);
|
|
2757
|
-
this.buildOptions();
|
|
2758
|
-
}
|
|
2759
|
-
populateOptions(serverData) {
|
|
2760
|
-
if (serverData instanceof Promise) {
|
|
2761
|
-
serverData.then(this.normalizeResult);
|
|
2762
|
-
}
|
|
2763
|
-
else {
|
|
2764
|
-
this.normalizeResult(serverData);
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
buildOptions() {
|
|
2768
|
-
var _a;
|
|
2769
|
-
this._visibleOptions = [];
|
|
2770
|
-
this._visibleOptions = this.adjustOptions(this._options);
|
|
2771
|
-
this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
|
|
2772
|
-
if (this._visibleOptions.length > 0) {
|
|
2773
|
-
(_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
|
|
2774
|
-
this.showOptions();
|
|
2775
|
-
}
|
|
2776
|
-
}
|
|
2777
|
-
setClassForSpanLabel() {
|
|
2778
|
-
if (!this.showvalue) {
|
|
2779
|
-
return '--li__spanlabel--full-width';
|
|
2780
|
-
}
|
|
2781
|
-
else {
|
|
2782
|
-
return '--li__spanlabel';
|
|
2783
|
-
}
|
|
2784
|
-
}
|
|
2785
|
-
handleFocus() {
|
|
2786
|
-
if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
|
|
2787
|
-
this.buildDataList();
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
parseExecutor(executor) {
|
|
2791
|
-
if (executor) {
|
|
2792
|
-
return executor instanceof Function ? executor : eval(executor);
|
|
2793
|
-
}
|
|
2794
|
-
return null;
|
|
2795
|
-
}
|
|
2796
|
-
componentDidLoad() {
|
|
2797
|
-
if (this.value && this.value.length > 0) {
|
|
2798
|
-
this._inputElem.value = this.value;
|
|
2799
|
-
}
|
|
2800
|
-
this._loadDataFunction = this.parseExecutor(this.loadexecutor);
|
|
2801
|
-
}
|
|
2802
|
-
render() {
|
|
2803
|
-
var _a;
|
|
2804
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => { this._inputElem = el; }, label: this.label, enabled: this.enabled, onFocus: () => { this.handleFocus(); }, onInput: () => { this.handleChange(); }, onKeyDown: event => this.keyDownHandler(event), errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { alert("Esta ação irá abrir o PopUp!"); }, slot: "leftIcon" })), index.h("ez-popover", { boxwidth: '100%', ref: el => this._popover = el }, index.h("div", { class: 'list-container', ref: (el) => this._divElem = el }, (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.map((opt, index) => this.buildItem(opt, index))))));
|
|
2805
|
-
}
|
|
2806
|
-
;
|
|
2807
|
-
get el() { return index.getElement(this); }
|
|
2808
|
-
static get watchers() { return {
|
|
2809
|
-
"value": ["valueChanged"]
|
|
2810
|
-
}; }
|
|
2811
|
-
};
|
|
2487
|
+
const EzSearch = class {
|
|
2488
|
+
constructor(hostRef) {
|
|
2489
|
+
index.registerInstance(this, hostRef);
|
|
2490
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
2491
|
+
this._options = [];
|
|
2492
|
+
this._classSelect = 'list-container--4row';
|
|
2493
|
+
/**
|
|
2494
|
+
* Deixa o campo disponível ou não para digitação.
|
|
2495
|
+
*/
|
|
2496
|
+
this.enabled = true;
|
|
2497
|
+
/**
|
|
2498
|
+
* Quantidade máxima de itens guardados no localstorage
|
|
2499
|
+
*/
|
|
2500
|
+
this.qtdHotItems = 6;
|
|
2501
|
+
/**
|
|
2502
|
+
* Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
|
|
2503
|
+
*/
|
|
2504
|
+
this.showvalue = false;
|
|
2505
|
+
///// HOTSEARCH /////
|
|
2506
|
+
this.buildId = () => {
|
|
2507
|
+
return btoa(`${this.hotsearchid}:${location.pathname}`);
|
|
2508
|
+
};
|
|
2509
|
+
this.getStorageItems = (key) => {
|
|
2510
|
+
let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
|
|
2511
|
+
let storageItems = [];
|
|
2512
|
+
if (storageValueStr !== null) {
|
|
2513
|
+
storageItems = JSON.parse(storageValueStr);
|
|
2514
|
+
}
|
|
2515
|
+
return storageItems;
|
|
2516
|
+
};
|
|
2517
|
+
this.orderHotList = (list) => {
|
|
2518
|
+
return list.sort((a, b) => {
|
|
2519
|
+
let time1 = new Date(a.dtRecent).getTime();
|
|
2520
|
+
let time2 = new Date(b.dtRecent).getTime();
|
|
2521
|
+
let qtd1 = a.qtd;
|
|
2522
|
+
let qtd2 = b.qtd;
|
|
2523
|
+
if (time1 < time2)
|
|
2524
|
+
return -1;
|
|
2525
|
+
if (time1 > time2)
|
|
2526
|
+
return 1;
|
|
2527
|
+
if (qtd1 > qtd2)
|
|
2528
|
+
return -1;
|
|
2529
|
+
if (qtd1 < qtd2)
|
|
2530
|
+
return 1;
|
|
2531
|
+
return 0;
|
|
2532
|
+
});
|
|
2533
|
+
};
|
|
2534
|
+
this.saveStorageItem = (key, value) => {
|
|
2535
|
+
if (value == '' || value == undefined)
|
|
2536
|
+
return;
|
|
2537
|
+
let storageItem = this.getStorageItems(key);
|
|
2538
|
+
let element = this.getElement(storageItem, value);
|
|
2539
|
+
if (element) {
|
|
2540
|
+
element.qtd++;
|
|
2541
|
+
element.dtRecent = this.getOnlyDate();
|
|
2542
|
+
}
|
|
2543
|
+
else {
|
|
2544
|
+
if (storageItem.length >= this.qtdHotItems) {
|
|
2545
|
+
storageItem = this.orderHotList(storageItem);
|
|
2546
|
+
storageItem.splice(-1, 1);
|
|
2547
|
+
}
|
|
2548
|
+
storageItem.push({
|
|
2549
|
+
description: value,
|
|
2550
|
+
qtd: 1,
|
|
2551
|
+
dtRecent: this.getOnlyDate()
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
|
|
2555
|
+
return storageItem;
|
|
2556
|
+
};
|
|
2557
|
+
this.adjustOptions = (arrayOptions) => {
|
|
2558
|
+
let optionsTemp = [];
|
|
2559
|
+
arrayOptions.map(el => {
|
|
2560
|
+
optionsTemp.push({
|
|
2561
|
+
value: el.value,
|
|
2562
|
+
label: el.label,
|
|
2563
|
+
ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
|
|
2564
|
+
});
|
|
2565
|
+
});
|
|
2566
|
+
return optionsTemp;
|
|
2567
|
+
};
|
|
2568
|
+
this.sortArrayOptions = (array, propname) => {
|
|
2569
|
+
const sortedArray = array.sort(function (a, b) {
|
|
2570
|
+
if (a[propname] < b[propname]) {
|
|
2571
|
+
return -1;
|
|
2572
|
+
}
|
|
2573
|
+
if (a[propname] > b[propname]) {
|
|
2574
|
+
return 1;
|
|
2575
|
+
}
|
|
2576
|
+
return 0;
|
|
2577
|
+
});
|
|
2578
|
+
return sortedArray;
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
valueChanged() {
|
|
2582
|
+
var _a;
|
|
2583
|
+
if (this.value) {
|
|
2584
|
+
this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
|
|
2585
|
+
let key = this.buildId();
|
|
2586
|
+
this.saveStorageItem(key, this.value);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
//ajustar ao fim do teste
|
|
2590
|
+
onInputTeste() {
|
|
2591
|
+
if (this._inputElem) {
|
|
2592
|
+
this.handleChange();
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
getElement(storageItem, value) {
|
|
2596
|
+
return storageItem.find(e => e.description === value);
|
|
2597
|
+
}
|
|
2598
|
+
getOnlyDate() {
|
|
2599
|
+
let dt = new Date();
|
|
2600
|
+
dt.setHours(0);
|
|
2601
|
+
dt.setMinutes(0);
|
|
2602
|
+
dt.setSeconds(0);
|
|
2603
|
+
dt.setUTCMilliseconds(0);
|
|
2604
|
+
return dt.toString();
|
|
2605
|
+
}
|
|
2606
|
+
onInputChange(ev) {
|
|
2607
|
+
const el = ev.target;
|
|
2608
|
+
let key = this.buildId();
|
|
2609
|
+
this.saveStorageItem(key, el.value);
|
|
2610
|
+
}
|
|
2611
|
+
buildDataList() {
|
|
2612
|
+
try {
|
|
2613
|
+
if (this.hotsearchid === undefined) {
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
let key = this.buildId();
|
|
2617
|
+
let optionsArray = [];
|
|
2618
|
+
this._options = [];
|
|
2619
|
+
if (this.getStorageItems(key).length > 0) {
|
|
2620
|
+
this.orderHotList(this.getStorageItems(key))
|
|
2621
|
+
.forEach((el) => {
|
|
2622
|
+
optionsArray.push({
|
|
2623
|
+
value: el.description,
|
|
2624
|
+
label: el.description,
|
|
2625
|
+
});
|
|
2626
|
+
});
|
|
2627
|
+
this._options = [{ value: '', label: '' }].concat(optionsArray);
|
|
2628
|
+
this.buildOptions();
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
catch (err) {
|
|
2632
|
+
this.errormessage = err;
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
///// EVENT HANDLERS
|
|
2636
|
+
buildItem(opt, index$1) {
|
|
2637
|
+
const className = index$1 === this._preSelection ? "--li--preselected" : "";
|
|
2638
|
+
return index.h("li", { class: className, key: opt.ajustedValue, accessKey: opt.label.toString(), id: 'item_' + opt.ajustedValue, onMouseDown: (ev) => this.handleSetValueByOption(ev) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { title: opt.ajustedValue, class: '--li__spanvalue' }, opt.ajustedValue) : null);
|
|
2639
|
+
}
|
|
2640
|
+
highlightMatch(label) {
|
|
2641
|
+
var _a;
|
|
2642
|
+
const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
|
|
2643
|
+
if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
|
|
2644
|
+
const criteriaLength = this._inputElem.value.length;
|
|
2645
|
+
const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
|
|
2646
|
+
if (matchStart > -1) {
|
|
2647
|
+
const strLabelStart = label.substr(0, matchStart);
|
|
2648
|
+
const strLabelEnd = label.substr(matchStart + criteriaLength);
|
|
2649
|
+
const strMatch = label.substr(matchStart, criteriaLength);
|
|
2650
|
+
return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
return (index.h("span", { class: spanClassName }, label));
|
|
2654
|
+
}
|
|
2655
|
+
showOptions() {
|
|
2656
|
+
if (this.enabled) {
|
|
2657
|
+
const top = this._inputElem.errormessage ? '0px' : '-17px';
|
|
2658
|
+
this._popover.show(top);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
nextOption() {
|
|
2662
|
+
this.showOptions();
|
|
2663
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
|
|
2664
|
+
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
2665
|
+
}
|
|
2666
|
+
previousOption() {
|
|
2667
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
|
|
2668
|
+
this.scrollToOption(this._visibleOptions[this._preSelection]);
|
|
2669
|
+
}
|
|
2670
|
+
scrollToOption(opt) {
|
|
2671
|
+
const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
|
|
2672
|
+
if (liElem) {
|
|
2673
|
+
const parent = liElem.parentElement;
|
|
2674
|
+
const parentRect = parent.getBoundingClientRect();
|
|
2675
|
+
const itemRect = liElem.getBoundingClientRect();
|
|
2676
|
+
if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
|
|
2677
|
+
liElem.scrollIntoView();
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
selectCurrentOption() {
|
|
2682
|
+
if (this._preSelection !== undefined) {
|
|
2683
|
+
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
2684
|
+
this._preSelection = undefined;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
selectOption(opt) {
|
|
2688
|
+
this._popover.hide();
|
|
2689
|
+
this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
|
|
2690
|
+
this._inputElem.value = opt.value;
|
|
2691
|
+
//Definir com a equipe de design se vai ser utilizado dessa forma.
|
|
2692
|
+
// this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
|
|
2693
|
+
}
|
|
2694
|
+
keyDownHandler(event) {
|
|
2695
|
+
switch (event.key) {
|
|
2696
|
+
case "ArrowDown":
|
|
2697
|
+
this.nextOption();
|
|
2698
|
+
break;
|
|
2699
|
+
case "ArrowUp":
|
|
2700
|
+
this.previousOption();
|
|
2701
|
+
break;
|
|
2702
|
+
case "Enter":
|
|
2703
|
+
this.selectCurrentOption();
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
event.stopPropagation();
|
|
2707
|
+
}
|
|
2708
|
+
handleSetValueByOption(ev) {
|
|
2709
|
+
this._popover.hide();
|
|
2710
|
+
const spanEl = ev.target;
|
|
2711
|
+
const sourceElement = ev.composedPath()[0];
|
|
2712
|
+
let li;
|
|
2713
|
+
if (sourceElement.tagName === 'SPAN') {
|
|
2714
|
+
li = spanEl.parentNode;
|
|
2715
|
+
}
|
|
2716
|
+
else {
|
|
2717
|
+
li = spanEl.parentNode.parentNode;
|
|
2718
|
+
}
|
|
2719
|
+
this.value = li.id.split('_')[1];
|
|
2720
|
+
this._inputElem.value = li.accessKey;
|
|
2721
|
+
this.ezChange.emit();
|
|
2722
|
+
}
|
|
2723
|
+
handleChange() {
|
|
2724
|
+
if (this._changeDeboucing) {
|
|
2725
|
+
window.clearTimeout(this._changeDeboucing);
|
|
2726
|
+
}
|
|
2727
|
+
this._changeDeboucing = window.setTimeout(() => {
|
|
2728
|
+
var _a, _b;
|
|
2729
|
+
if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
|
|
2730
|
+
return;
|
|
2731
|
+
}
|
|
2732
|
+
/* save tip on localStorage */
|
|
2733
|
+
let key = this.buildId();
|
|
2734
|
+
this.saveStorageItem(key, this._inputElem.value);
|
|
2735
|
+
/* load data */
|
|
2736
|
+
if (this.loadexecutor) {
|
|
2737
|
+
this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
|
|
2738
|
+
}
|
|
2739
|
+
}, 200);
|
|
2740
|
+
}
|
|
2741
|
+
normalizeResult(data) {
|
|
2742
|
+
let options = [];
|
|
2743
|
+
if (data instanceof Array) {
|
|
2744
|
+
options = data;
|
|
2745
|
+
}
|
|
2746
|
+
else {
|
|
2747
|
+
if (data instanceof Object) {
|
|
2748
|
+
for (var key in data) {
|
|
2749
|
+
let newOption = { value: '', label: '' };
|
|
2750
|
+
newOption.value = key;
|
|
2751
|
+
newOption.label = data[key];
|
|
2752
|
+
options.push(newOption);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
this._options = [{ value: '', label: '' }].concat(options);
|
|
2757
|
+
this.buildOptions();
|
|
2758
|
+
}
|
|
2759
|
+
populateOptions(serverData) {
|
|
2760
|
+
if (serverData instanceof Promise) {
|
|
2761
|
+
serverData.then(this.normalizeResult);
|
|
2762
|
+
}
|
|
2763
|
+
else {
|
|
2764
|
+
this.normalizeResult(serverData);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
buildOptions() {
|
|
2768
|
+
var _a;
|
|
2769
|
+
this._visibleOptions = [];
|
|
2770
|
+
this._visibleOptions = this.adjustOptions(this._options);
|
|
2771
|
+
this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
|
|
2772
|
+
if (this._visibleOptions.length > 0) {
|
|
2773
|
+
(_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
|
|
2774
|
+
this.showOptions();
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
setClassForSpanLabel() {
|
|
2778
|
+
if (!this.showvalue) {
|
|
2779
|
+
return '--li__spanlabel--full-width';
|
|
2780
|
+
}
|
|
2781
|
+
else {
|
|
2782
|
+
return '--li__spanlabel';
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
handleFocus() {
|
|
2786
|
+
if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
|
|
2787
|
+
this.buildDataList();
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
parseExecutor(executor) {
|
|
2791
|
+
if (executor) {
|
|
2792
|
+
return executor instanceof Function ? executor : eval(executor);
|
|
2793
|
+
}
|
|
2794
|
+
return null;
|
|
2795
|
+
}
|
|
2796
|
+
componentDidLoad() {
|
|
2797
|
+
if (this.value && this.value.length > 0) {
|
|
2798
|
+
this._inputElem.value = this.value;
|
|
2799
|
+
}
|
|
2800
|
+
this._loadDataFunction = this.parseExecutor(this.loadexecutor);
|
|
2801
|
+
}
|
|
2802
|
+
render() {
|
|
2803
|
+
var _a;
|
|
2804
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => { this._inputElem = el; }, label: this.label, enabled: this.enabled, onFocus: () => { this.handleFocus(); }, onInput: () => { this.handleChange(); }, onKeyDown: event => this.keyDownHandler(event), errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { alert("Esta ação irá abrir o PopUp!"); }, slot: "leftIcon" })), index.h("ez-popover", { boxwidth: '100%', ref: el => this._popover = el }, index.h("div", { class: 'list-container', ref: (el) => this._divElem = el }, (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.map((opt, index) => this.buildItem(opt, index))))));
|
|
2805
|
+
}
|
|
2806
|
+
;
|
|
2807
|
+
get el() { return index.getElement(this); }
|
|
2808
|
+
static get watchers() { return {
|
|
2809
|
+
"value": ["valueChanged"]
|
|
2810
|
+
}; }
|
|
2811
|
+
};
|
|
2812
2812
|
EzSearch.style = ezSearchCss;
|
|
2813
2813
|
|
|
2814
2814
|
const ezTabselectorCss = "@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50% )}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px )}}:host{display:flex;position:relative;width:100%;overflow:hidden;margin-bottom:var(--space--large, 24px);--tab__box--box-shadow:var(--shadow, 0px 0px 8px 0px #000)}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.midle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, \"Sora, Algerian\");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:\"\";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px );animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5);}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px;clip-path:path(\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\")}.backward-button::after{clip-path:path(\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\")}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}";
|
|
2815
2815
|
|
|
2816
|
-
const EzTabselector = class {
|
|
2817
|
-
constructor(hostRef) {
|
|
2818
|
-
index.registerInstance(this, hostRef);
|
|
2819
|
-
this.change = index.createEvent(this, "change", 7);
|
|
2820
|
-
this.setFoucusedParam = (ev) => {
|
|
2821
|
-
if (ev.key === 'Enter') {
|
|
2822
|
-
this.selectedindex = this.foucusedindex;
|
|
2823
|
-
this.foucusedindex = undefined;
|
|
2824
|
-
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
2825
|
-
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
2826
|
-
ev.preventDefault();
|
|
2827
|
-
this.setFocusedTab(this.selectedindex);
|
|
2828
|
-
}
|
|
2829
|
-
else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
|
|
2830
|
-
let operator = undefined;
|
|
2831
|
-
if (ev.key === 'ArrowLeft') {
|
|
2832
|
-
operator = false;
|
|
2833
|
-
}
|
|
2834
|
-
else if (ev.key === 'ArrowRight') {
|
|
2835
|
-
operator = true;
|
|
2836
|
-
}
|
|
2837
|
-
else {
|
|
2838
|
-
return;
|
|
2839
|
-
}
|
|
2840
|
-
if (this.foucusedindex === undefined) {
|
|
2841
|
-
if (operator === false) {
|
|
2842
|
-
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
|
|
2843
|
-
}
|
|
2844
|
-
else {
|
|
2845
|
-
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
else {
|
|
2849
|
-
if (operator === false) {
|
|
2850
|
-
this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
|
|
2851
|
-
}
|
|
2852
|
-
else {
|
|
2853
|
-
this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
if (parseInt(this.foucusedindex) < 0) {
|
|
2857
|
-
this.foucusedindex = '0';
|
|
2858
|
-
}
|
|
2859
|
-
else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
|
|
2860
|
-
this.foucusedindex = (this._processedTabs.length - 1).toString();
|
|
2861
|
-
}
|
|
2862
|
-
this.setFoucusedBtn(true, this.foucusedindex);
|
|
2863
|
-
this.setFocusedTab(this.foucusedindex);
|
|
2864
|
-
this.change.emit();
|
|
2865
|
-
}
|
|
2866
|
-
else if (ev.key === 'Tab' || ev.key === 'Escape') {
|
|
2867
|
-
this.foucusedindex = undefined;
|
|
2868
|
-
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
2869
|
-
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
2870
|
-
ev.preventDefault();
|
|
2871
|
-
this.setFocusedTab(this.selectedindex);
|
|
2872
|
-
}
|
|
2873
|
-
// this.setFocusedTab();
|
|
2874
|
-
};
|
|
2875
|
-
}
|
|
2876
|
-
handleTabClick(tab, index) {
|
|
2877
|
-
this.selectedindex = index.toString();
|
|
2878
|
-
this.foucusedindex = undefined;
|
|
2879
|
-
this.selectedtab = tab;
|
|
2880
|
-
this.change.emit();
|
|
2881
|
-
this.setFoucusedBtn(false, this.selectedindex);
|
|
2882
|
-
}
|
|
2883
|
-
componentWillRender() {
|
|
2884
|
-
if (!this._processedTabs) {
|
|
2885
|
-
this._processedTabs = [];
|
|
2886
|
-
if (this.tabs) {
|
|
2887
|
-
this.tabs.split(',').forEach((label) => {
|
|
2888
|
-
label = label.trim();
|
|
2889
|
-
this._processedTabs.push(new Tab(label, label));
|
|
2890
|
-
});
|
|
2891
|
-
}
|
|
2892
|
-
this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
|
|
2893
|
-
const tabKey = elem.getAttribute('tabKey');
|
|
2894
|
-
const label = elem.getAttribute('label');
|
|
2895
|
-
const t = new Tab(label, tabKey);
|
|
2896
|
-
const content = elem.firstChild;
|
|
2897
|
-
if (content) {
|
|
2898
|
-
content.setAttribute('slot', 'tab' + this._processedTabs.length);
|
|
2899
|
-
this._hostElem.appendChild(content);
|
|
2900
|
-
}
|
|
2901
|
-
this._processedTabs.push(t);
|
|
2902
|
-
});
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
2905
|
-
handleSlotChange(ev) {
|
|
2906
|
-
const slot = ev.target;
|
|
2907
|
-
const content = slot.assignedElements()[0];
|
|
2908
|
-
if (content) {
|
|
2909
|
-
content.style.marginLeft = "6px";
|
|
2910
|
-
}
|
|
2911
|
-
}
|
|
2912
|
-
scrollBackward() {
|
|
2913
|
-
const container = this._scrollContainer;
|
|
2914
|
-
if (container) {
|
|
2915
|
-
container.scrollLeft -= container.clientWidth;
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
scrollFoward() {
|
|
2919
|
-
const container = this._scrollContainer;
|
|
2920
|
-
if (container) {
|
|
2921
|
-
let lastTab = null;
|
|
2922
|
-
container.querySelectorAll('.tab').forEach((tab) => {
|
|
2923
|
-
if (tab.getBoundingClientRect().right < container.clientWidth) {
|
|
2924
|
-
lastTab = tab;
|
|
2925
|
-
}
|
|
2926
|
-
});
|
|
2927
|
-
container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
componentDidRender() {
|
|
2931
|
-
this.updateScroll();
|
|
2932
|
-
}
|
|
2933
|
-
updateScroll() {
|
|
2934
|
-
const container = this._scrollContainer;
|
|
2935
|
-
if (container) {
|
|
2936
|
-
const { scrollWidth, clientWidth, scrollLeft } = container;
|
|
2937
|
-
const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
|
|
2938
|
-
this._startHidden = container.scrollLeft > 0;
|
|
2939
|
-
this._endHidden = remainingScroll > 0;
|
|
2940
|
-
if (this._startHidden) {
|
|
2941
|
-
this._backwardButton.classList.remove('hidden');
|
|
2942
|
-
}
|
|
2943
|
-
else {
|
|
2944
|
-
this._backwardButton.classList.add('hidden');
|
|
2945
|
-
}
|
|
2946
|
-
if (this._endHidden) {
|
|
2947
|
-
this._forwardButton.classList.remove('hidden');
|
|
2948
|
-
}
|
|
2949
|
-
else {
|
|
2950
|
-
this._forwardButton.classList.add('hidden');
|
|
2951
|
-
}
|
|
2952
|
-
const classNames = ['', 'startHidden', 'endHidden', 'midle'];
|
|
2953
|
-
const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
|
|
2954
|
-
classNames.forEach((name) => {
|
|
2955
|
-
if (name !== currentClass && container.classList.contains(name)) {
|
|
2956
|
-
container.classList.remove(name);
|
|
2957
|
-
}
|
|
2958
|
-
});
|
|
2959
|
-
if (currentClass && !container.classList.contains(currentClass)) {
|
|
2960
|
-
container.classList.add(currentClass);
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
domScrollHandler() {
|
|
2965
|
-
window.clearTimeout(this._scrollCallBack);
|
|
2966
|
-
this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
|
|
2967
|
-
}
|
|
2968
|
-
setFocusedTab(index) {
|
|
2969
|
-
window.clearTimeout(this._scrollCallBackTeste);
|
|
2970
|
-
this._scrollCallBackTeste = window.setTimeout(() => {
|
|
2971
|
-
const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
|
|
2972
|
-
console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
|
|
2973
|
-
console.log('tabtoscroll', tabtoscroll);
|
|
2974
|
-
tabtoscroll.scrollIntoView();
|
|
2975
|
-
}, 200);
|
|
2976
|
-
}
|
|
2977
|
-
getTextWidth(text) {
|
|
2978
|
-
if (this._textMesurement === undefined) {
|
|
2979
|
-
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
2980
|
-
}
|
|
2981
|
-
const context = this._textMesurement.getContext("2d");
|
|
2982
|
-
context.font = '14px Sora, Algerian';
|
|
2983
|
-
return Math.min(220, 24 + context.measureText(text).width) + 'px';
|
|
2984
|
-
}
|
|
2985
|
-
;
|
|
2986
|
-
setFoucusedBtn(visible, paramater) {
|
|
2987
|
-
const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
|
|
2988
|
-
tabsButtons.forEach((el) => {
|
|
2989
|
-
el.classList.remove('is-focused');
|
|
2990
|
-
if (el.id === 'tab' + paramater && visible) {
|
|
2991
|
-
el.classList.add('is-focused');
|
|
2992
|
-
}
|
|
2993
|
-
});
|
|
2994
|
-
}
|
|
2995
|
-
render() {
|
|
2996
|
-
return (index.h(index.Host, null, index.h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), index.h("div", { class: "scroll", ref: (el) => this._scrollContainer = el,
|
|
2997
|
-
// onScroll={() => this.domScrollHandler()}
|
|
2998
|
-
onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
|
|
2999
|
-
const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
|
|
3000
|
-
const tabId = "tab" + index$1;
|
|
3001
|
-
const isSelected = index$1 === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
|
|
3002
|
-
if (isSelected) {
|
|
3003
|
-
this.selectedtab = tab.tabKey;
|
|
3004
|
-
this.selectedindex = index$1.toString();
|
|
3005
|
-
}
|
|
3006
|
-
return index.h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index$1), style: labelStyle }, index.h("span", { class: "tab-label", title: tab.label }, tab.label), index.h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
3007
|
-
})), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
3008
|
-
}
|
|
3009
|
-
get _hostElem() { return index.getElement(this); }
|
|
3010
|
-
};
|
|
3011
|
-
class Tab {
|
|
3012
|
-
constructor(label, tabKey) {
|
|
3013
|
-
this.label = label;
|
|
3014
|
-
this.tabKey = tabKey;
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
2816
|
+
const EzTabselector = class {
|
|
2817
|
+
constructor(hostRef) {
|
|
2818
|
+
index.registerInstance(this, hostRef);
|
|
2819
|
+
this.change = index.createEvent(this, "change", 7);
|
|
2820
|
+
this.setFoucusedParam = (ev) => {
|
|
2821
|
+
if (ev.key === 'Enter') {
|
|
2822
|
+
this.selectedindex = this.foucusedindex;
|
|
2823
|
+
this.foucusedindex = undefined;
|
|
2824
|
+
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
2825
|
+
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
2826
|
+
ev.preventDefault();
|
|
2827
|
+
this.setFocusedTab(this.selectedindex);
|
|
2828
|
+
}
|
|
2829
|
+
else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
|
|
2830
|
+
let operator = undefined;
|
|
2831
|
+
if (ev.key === 'ArrowLeft') {
|
|
2832
|
+
operator = false;
|
|
2833
|
+
}
|
|
2834
|
+
else if (ev.key === 'ArrowRight') {
|
|
2835
|
+
operator = true;
|
|
2836
|
+
}
|
|
2837
|
+
else {
|
|
2838
|
+
return;
|
|
2839
|
+
}
|
|
2840
|
+
if (this.foucusedindex === undefined) {
|
|
2841
|
+
if (operator === false) {
|
|
2842
|
+
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
|
|
2843
|
+
}
|
|
2844
|
+
else {
|
|
2845
|
+
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
else {
|
|
2849
|
+
if (operator === false) {
|
|
2850
|
+
this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
|
|
2851
|
+
}
|
|
2852
|
+
else {
|
|
2853
|
+
this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
if (parseInt(this.foucusedindex) < 0) {
|
|
2857
|
+
this.foucusedindex = '0';
|
|
2858
|
+
}
|
|
2859
|
+
else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
|
|
2860
|
+
this.foucusedindex = (this._processedTabs.length - 1).toString();
|
|
2861
|
+
}
|
|
2862
|
+
this.setFoucusedBtn(true, this.foucusedindex);
|
|
2863
|
+
this.setFocusedTab(this.foucusedindex);
|
|
2864
|
+
this.change.emit();
|
|
2865
|
+
}
|
|
2866
|
+
else if (ev.key === 'Tab' || ev.key === 'Escape') {
|
|
2867
|
+
this.foucusedindex = undefined;
|
|
2868
|
+
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
2869
|
+
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
2870
|
+
ev.preventDefault();
|
|
2871
|
+
this.setFocusedTab(this.selectedindex);
|
|
2872
|
+
}
|
|
2873
|
+
// this.setFocusedTab();
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
handleTabClick(tab, index) {
|
|
2877
|
+
this.selectedindex = index.toString();
|
|
2878
|
+
this.foucusedindex = undefined;
|
|
2879
|
+
this.selectedtab = tab;
|
|
2880
|
+
this.change.emit();
|
|
2881
|
+
this.setFoucusedBtn(false, this.selectedindex);
|
|
2882
|
+
}
|
|
2883
|
+
componentWillRender() {
|
|
2884
|
+
if (!this._processedTabs) {
|
|
2885
|
+
this._processedTabs = [];
|
|
2886
|
+
if (this.tabs) {
|
|
2887
|
+
this.tabs.split(',').forEach((label) => {
|
|
2888
|
+
label = label.trim();
|
|
2889
|
+
this._processedTabs.push(new Tab(label, label));
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
|
|
2893
|
+
const tabKey = elem.getAttribute('tabKey');
|
|
2894
|
+
const label = elem.getAttribute('label');
|
|
2895
|
+
const t = new Tab(label, tabKey);
|
|
2896
|
+
const content = elem.firstChild;
|
|
2897
|
+
if (content) {
|
|
2898
|
+
content.setAttribute('slot', 'tab' + this._processedTabs.length);
|
|
2899
|
+
this._hostElem.appendChild(content);
|
|
2900
|
+
}
|
|
2901
|
+
this._processedTabs.push(t);
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
handleSlotChange(ev) {
|
|
2906
|
+
const slot = ev.target;
|
|
2907
|
+
const content = slot.assignedElements()[0];
|
|
2908
|
+
if (content) {
|
|
2909
|
+
content.style.marginLeft = "6px";
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
scrollBackward() {
|
|
2913
|
+
const container = this._scrollContainer;
|
|
2914
|
+
if (container) {
|
|
2915
|
+
container.scrollLeft -= container.clientWidth;
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
scrollFoward() {
|
|
2919
|
+
const container = this._scrollContainer;
|
|
2920
|
+
if (container) {
|
|
2921
|
+
let lastTab = null;
|
|
2922
|
+
container.querySelectorAll('.tab').forEach((tab) => {
|
|
2923
|
+
if (tab.getBoundingClientRect().right < container.clientWidth) {
|
|
2924
|
+
lastTab = tab;
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
componentDidRender() {
|
|
2931
|
+
this.updateScroll();
|
|
2932
|
+
}
|
|
2933
|
+
updateScroll() {
|
|
2934
|
+
const container = this._scrollContainer;
|
|
2935
|
+
if (container) {
|
|
2936
|
+
const { scrollWidth, clientWidth, scrollLeft } = container;
|
|
2937
|
+
const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
|
|
2938
|
+
this._startHidden = container.scrollLeft > 0;
|
|
2939
|
+
this._endHidden = remainingScroll > 0;
|
|
2940
|
+
if (this._startHidden) {
|
|
2941
|
+
this._backwardButton.classList.remove('hidden');
|
|
2942
|
+
}
|
|
2943
|
+
else {
|
|
2944
|
+
this._backwardButton.classList.add('hidden');
|
|
2945
|
+
}
|
|
2946
|
+
if (this._endHidden) {
|
|
2947
|
+
this._forwardButton.classList.remove('hidden');
|
|
2948
|
+
}
|
|
2949
|
+
else {
|
|
2950
|
+
this._forwardButton.classList.add('hidden');
|
|
2951
|
+
}
|
|
2952
|
+
const classNames = ['', 'startHidden', 'endHidden', 'midle'];
|
|
2953
|
+
const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
|
|
2954
|
+
classNames.forEach((name) => {
|
|
2955
|
+
if (name !== currentClass && container.classList.contains(name)) {
|
|
2956
|
+
container.classList.remove(name);
|
|
2957
|
+
}
|
|
2958
|
+
});
|
|
2959
|
+
if (currentClass && !container.classList.contains(currentClass)) {
|
|
2960
|
+
container.classList.add(currentClass);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
domScrollHandler() {
|
|
2965
|
+
window.clearTimeout(this._scrollCallBack);
|
|
2966
|
+
this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
|
|
2967
|
+
}
|
|
2968
|
+
setFocusedTab(index) {
|
|
2969
|
+
window.clearTimeout(this._scrollCallBackTeste);
|
|
2970
|
+
this._scrollCallBackTeste = window.setTimeout(() => {
|
|
2971
|
+
const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
|
|
2972
|
+
console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
|
|
2973
|
+
console.log('tabtoscroll', tabtoscroll);
|
|
2974
|
+
tabtoscroll.scrollIntoView();
|
|
2975
|
+
}, 200);
|
|
2976
|
+
}
|
|
2977
|
+
getTextWidth(text) {
|
|
2978
|
+
if (this._textMesurement === undefined) {
|
|
2979
|
+
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
2980
|
+
}
|
|
2981
|
+
const context = this._textMesurement.getContext("2d");
|
|
2982
|
+
context.font = '14px Sora, Algerian';
|
|
2983
|
+
return Math.min(220, 24 + context.measureText(text).width) + 'px';
|
|
2984
|
+
}
|
|
2985
|
+
;
|
|
2986
|
+
setFoucusedBtn(visible, paramater) {
|
|
2987
|
+
const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
|
|
2988
|
+
tabsButtons.forEach((el) => {
|
|
2989
|
+
el.classList.remove('is-focused');
|
|
2990
|
+
if (el.id === 'tab' + paramater && visible) {
|
|
2991
|
+
el.classList.add('is-focused');
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
render() {
|
|
2996
|
+
return (index.h(index.Host, null, index.h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), index.h("div", { class: "scroll", ref: (el) => this._scrollContainer = el,
|
|
2997
|
+
// onScroll={() => this.domScrollHandler()}
|
|
2998
|
+
onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
|
|
2999
|
+
const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
|
|
3000
|
+
const tabId = "tab" + index$1;
|
|
3001
|
+
const isSelected = index$1 === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
|
|
3002
|
+
if (isSelected) {
|
|
3003
|
+
this.selectedtab = tab.tabKey;
|
|
3004
|
+
this.selectedindex = index$1.toString();
|
|
3005
|
+
}
|
|
3006
|
+
return index.h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index$1), style: labelStyle }, index.h("span", { class: "tab-label", title: tab.label }, tab.label), index.h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
3007
|
+
})), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
3008
|
+
}
|
|
3009
|
+
get _hostElem() { return index.getElement(this); }
|
|
3010
|
+
};
|
|
3011
|
+
class Tab {
|
|
3012
|
+
constructor(label, tabKey) {
|
|
3013
|
+
this.label = label;
|
|
3014
|
+
this.tabKey = tabKey;
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
3017
|
EzTabselector.style = ezTabselectorCss;
|
|
3018
3018
|
|
|
3019
3019
|
const ezTextAreaCss = ":host{--ta--width:100%;--ta--border-radius:var(--border--radius-medium, 12px);--ta--font-size:var(--text--medium, 14px);--ta--font-family:var(--font-pattern, Arial);--ta--font-weight:var(--text-weight--large, 500);--ta--color:var(--title--primary, #000);--ta__input--background-color:var(--background--medium, #e0e0e0);--ta__input--border:var(--border--medium, 2px solid);--ta__input--border-color:var(--ta__input--background-color);--ta__input--focus--border-color:var(--color--primary, #008561);--ta__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ta__input--disabled--color:var(--text--disable, #AFB6C0);--ta__input--error--border-color:#CC2936;--ta__input--floating--padding-top:16px;--ta__message_box--font-size:var(--text--small, 12px);--ta__message_box--info--color:var(--color--success, #22085d);--ta__message_box--error--color:var(--color--error, #FF0000);--ta__label--floating--top:6px;--ta__label--padding-top:12px;--ta__label--padding-left:14px;--ta__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ta--width)}textarea{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);resize:none;border-radius:var(--ta--border-radius);font-family:var(--ta--font-family);font-size:var(--ta--font-size);border:var(--ta__input--border);border-color:var(--ta__input--border-color);background-color:var(--ta__input--background-color);color:var(--ta--color)}textarea:disabled{background-color:var(--ta__input--disabled--background-color);color:var(--ta__input--disabled--color)}textarea:focus{outline:none;border-color:var(--ta__input--focus--border-color)}textarea.hasError{color:var(--ta--color);border-color:var(--ta__input--error--border-color)}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ta--font-family);font-size:var(--ta__message_box--font-size);color:var(--ta__message_box--info--color)}.hasError{color:var(--ta__message_box--error--color)}.textarea__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--ta__label--padding-right));left:var(--ta--space--medium);font-family:var(--ta--font-family);font-size:var(--ta--font-size);font-weight:var(--ta--font-weight);color:var(--ta--color);top:var(--ta__label--padding-top);left:var(--ta__label--padding-left);padding-right:var(--ta__label--padding-right)}.textarea__label--floated{font-family:var(--ta--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ta__label--floating--top)}.textarea__label--disabled{color:var(--ta__input--disabled--color)}.input--with--label{padding-bottom:0;padding-top:var(--ta__input--floating--padding-top)}";
|
|
3020
3020
|
|
|
3021
|
-
const EzTextArea = class {
|
|
3022
|
-
constructor(hostRef) {
|
|
3023
|
-
index.registerInstance(this, hostRef);
|
|
3024
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
3025
|
-
/**
|
|
3026
|
-
* Deixa o campo disponível ou não para digitação.
|
|
3027
|
-
*/
|
|
3028
|
-
this.enabled = true;
|
|
3029
|
-
/**
|
|
3030
|
-
* Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
|
|
3031
|
-
*/
|
|
3032
|
-
this.rows = 4;
|
|
3033
|
-
}
|
|
3034
|
-
showError() {
|
|
3035
|
-
const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
|
|
3036
|
-
if (hasError) {
|
|
3037
|
-
this._inputElem.classList.add('hasError');
|
|
3038
|
-
this._messageBoxElem.classList.add('hasError');
|
|
3039
|
-
}
|
|
3040
|
-
else {
|
|
3041
|
-
this._inputElem.classList.remove('hasError');
|
|
3042
|
-
this._messageBoxElem.classList.remove('hasError');
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
updateInputValue() {
|
|
3046
|
-
this._inputElem.value = this.value;
|
|
3047
|
-
this.handleChange();
|
|
3048
|
-
this.adjustFloatingLabel();
|
|
3049
|
-
}
|
|
3050
|
-
adjustFloatingLabel() {
|
|
3051
|
-
if (this.label) {
|
|
3052
|
-
if (!this._inputElem.classList.contains("input--with--label")) {
|
|
3053
|
-
this._inputElem.classList.add("input--with--label");
|
|
3054
|
-
}
|
|
3055
|
-
const hasValue = this.value && this.value.toString().length > 0;
|
|
3056
|
-
const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
|
|
3057
|
-
if (hasValue || this.isFocused()) {
|
|
3058
|
-
if (!containsFloatedClass) {
|
|
3059
|
-
this._labelElem.classList.add("textarea__label--floated");
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
else {
|
|
3063
|
-
if (containsFloatedClass) {
|
|
3064
|
-
this._labelElem.classList.remove("textarea__label--floated");
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
isFocused() {
|
|
3070
|
-
return this._hostElement.shadowRoot.activeElement !== null;
|
|
3071
|
-
}
|
|
3072
|
-
//---------------------------------------------
|
|
3073
|
-
// Public methods
|
|
3074
|
-
//---------------------------------------------
|
|
3075
|
-
/**
|
|
3076
|
-
* Faz o foco no componente de input
|
|
3077
|
-
*/
|
|
3078
|
-
async setFocus() {
|
|
3079
|
-
this._inputElem.focus();
|
|
3080
|
-
}
|
|
3081
|
-
/**
|
|
3082
|
-
* Remove o foco no componente de input
|
|
3083
|
-
*/
|
|
3084
|
-
async setBlur() {
|
|
3085
|
-
this._inputElem.blur();
|
|
3086
|
-
}
|
|
3087
|
-
//---------------------------------------------
|
|
3088
|
-
// Event handlers
|
|
3089
|
-
//---------------------------------------------
|
|
3090
|
-
handleFocusout() {
|
|
3091
|
-
this.adjustFloatingLabel();
|
|
3092
|
-
}
|
|
3093
|
-
handleChange() {
|
|
3094
|
-
this.value = this._inputElem.value;
|
|
3095
|
-
}
|
|
3096
|
-
handleFocus() {
|
|
3097
|
-
if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
|
|
3098
|
-
this._labelElem.classList.add("textarea__label--floated");
|
|
3099
|
-
}
|
|
3100
|
-
}
|
|
3101
|
-
//---------------------------------------------
|
|
3102
|
-
// Lifecycle web component
|
|
3103
|
-
//---------------------------------------------
|
|
3104
|
-
componentDidLoad() {
|
|
3105
|
-
this.showError();
|
|
3106
|
-
this.adjustFloatingLabel();
|
|
3107
|
-
}
|
|
3108
|
-
render() {
|
|
3109
|
-
return (index.h(index.Host, null, this.label ?
|
|
3110
|
-
index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
3111
|
-
: null, index.h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
|
|
3112
|
-
}
|
|
3113
|
-
get _hostElement() { return index.getElement(this); }
|
|
3114
|
-
static get watchers() { return {
|
|
3115
|
-
"errormessage": ["showError"],
|
|
3116
|
-
"value": ["updateInputValue"]
|
|
3117
|
-
}; }
|
|
3118
|
-
};
|
|
3021
|
+
const EzTextArea = class {
|
|
3022
|
+
constructor(hostRef) {
|
|
3023
|
+
index.registerInstance(this, hostRef);
|
|
3024
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
3025
|
+
/**
|
|
3026
|
+
* Deixa o campo disponível ou não para digitação.
|
|
3027
|
+
*/
|
|
3028
|
+
this.enabled = true;
|
|
3029
|
+
/**
|
|
3030
|
+
* Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
|
|
3031
|
+
*/
|
|
3032
|
+
this.rows = 4;
|
|
3033
|
+
}
|
|
3034
|
+
showError() {
|
|
3035
|
+
const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
|
|
3036
|
+
if (hasError) {
|
|
3037
|
+
this._inputElem.classList.add('hasError');
|
|
3038
|
+
this._messageBoxElem.classList.add('hasError');
|
|
3039
|
+
}
|
|
3040
|
+
else {
|
|
3041
|
+
this._inputElem.classList.remove('hasError');
|
|
3042
|
+
this._messageBoxElem.classList.remove('hasError');
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
updateInputValue() {
|
|
3046
|
+
this._inputElem.value = this.value;
|
|
3047
|
+
this.handleChange();
|
|
3048
|
+
this.adjustFloatingLabel();
|
|
3049
|
+
}
|
|
3050
|
+
adjustFloatingLabel() {
|
|
3051
|
+
if (this.label) {
|
|
3052
|
+
if (!this._inputElem.classList.contains("input--with--label")) {
|
|
3053
|
+
this._inputElem.classList.add("input--with--label");
|
|
3054
|
+
}
|
|
3055
|
+
const hasValue = this.value && this.value.toString().length > 0;
|
|
3056
|
+
const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
|
|
3057
|
+
if (hasValue || this.isFocused()) {
|
|
3058
|
+
if (!containsFloatedClass) {
|
|
3059
|
+
this._labelElem.classList.add("textarea__label--floated");
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
else {
|
|
3063
|
+
if (containsFloatedClass) {
|
|
3064
|
+
this._labelElem.classList.remove("textarea__label--floated");
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
isFocused() {
|
|
3070
|
+
return this._hostElement.shadowRoot.activeElement !== null;
|
|
3071
|
+
}
|
|
3072
|
+
//---------------------------------------------
|
|
3073
|
+
// Public methods
|
|
3074
|
+
//---------------------------------------------
|
|
3075
|
+
/**
|
|
3076
|
+
* Faz o foco no componente de input
|
|
3077
|
+
*/
|
|
3078
|
+
async setFocus() {
|
|
3079
|
+
this._inputElem.focus();
|
|
3080
|
+
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Remove o foco no componente de input
|
|
3083
|
+
*/
|
|
3084
|
+
async setBlur() {
|
|
3085
|
+
this._inputElem.blur();
|
|
3086
|
+
}
|
|
3087
|
+
//---------------------------------------------
|
|
3088
|
+
// Event handlers
|
|
3089
|
+
//---------------------------------------------
|
|
3090
|
+
handleFocusout() {
|
|
3091
|
+
this.adjustFloatingLabel();
|
|
3092
|
+
}
|
|
3093
|
+
handleChange() {
|
|
3094
|
+
this.value = this._inputElem.value;
|
|
3095
|
+
}
|
|
3096
|
+
handleFocus() {
|
|
3097
|
+
if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
|
|
3098
|
+
this._labelElem.classList.add("textarea__label--floated");
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
//---------------------------------------------
|
|
3102
|
+
// Lifecycle web component
|
|
3103
|
+
//---------------------------------------------
|
|
3104
|
+
componentDidLoad() {
|
|
3105
|
+
this.showError();
|
|
3106
|
+
this.adjustFloatingLabel();
|
|
3107
|
+
}
|
|
3108
|
+
render() {
|
|
3109
|
+
return (index.h(index.Host, null, this.label ?
|
|
3110
|
+
index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
3111
|
+
: null, index.h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
|
|
3112
|
+
}
|
|
3113
|
+
get _hostElement() { return index.getElement(this); }
|
|
3114
|
+
static get watchers() { return {
|
|
3115
|
+
"errormessage": ["showError"],
|
|
3116
|
+
"value": ["updateInputValue"]
|
|
3117
|
+
}; }
|
|
3118
|
+
};
|
|
3119
3119
|
EzTextArea.style = ezTextAreaCss;
|
|
3120
3120
|
|
|
3121
|
-
function isValidNumber(strValue) {
|
|
3122
|
-
return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
|
|
3121
|
+
function isValidNumber(strValue) {
|
|
3122
|
+
return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
|
|
3123
3123
|
}
|
|
3124
3124
|
|
|
3125
3125
|
const ezTextInputCss = ":host{--it--height:42px;--it--width:100%;--it__icon--width:48px;--it--border-radius:var(--border--radius-medium, 12px);--it--font-size:var(--text--medium, 14px);--it--font-family:var(--font-pattern, Arial);--it--font-weight:var(--text-weight--large, 500);--it--color:var(--title--primary, #000);--it__input--background-color:var(--background--medium, #e0e0e0);--it__input--border:var(--border--medium, 2px solid);--it__input--border-color:var(--it__input--background-color);--it__input--focus--border-color:var(--color--primary, #008561);--it__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--it__input--disabled--color:var(--text--disable, #AFB6C0);--it__input--error--border-color:#CC2936;--it__message_box--font-size:var(--text--small, 12px);--it__message_box--info--color:var(--color--success, #22085d);--it__message_box--error--color:var(--color--error, #FF0000);--it__label--floating--top:6px;--it__label--padding-top:12px;--it__label--padding-left:14px;--it__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--it--width)}input{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);height:var(--it--height);border-radius:var(--it--border-radius);font-family:var(--it--font-family);font-size:var(--it--font-size);border:var(--it__input--border);border-color:var(--it__input--border-color);background-color:var(--it__input--background-color);color:var(--it--color)}input:disabled{background-color:var(--it__input--disabled--background-color);color:var(--it__input--disabled--color)}input:focus{outline:none;border-color:var(--it__input--focus--border-color)}input.icon--left{padding-left:var(--it__icon--width)}input.icon--right{padding-right:var(--it__icon--width)}input.hasError{color:var(--it--color);border-color:var(--it__input--error--border-color)}input.text--right{text-align:right}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--it--font-family);font-size:var(--it__message_box--font-size);color:var(--it__message_box--info--color)}.hasError{color:var(--it__message_box--error--color)}.input__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--it__label--padding-right));left:var(--it--space--medium);font-family:var(--it--font-family);font-size:var(--it--font-size);font-weight:var(--it--font-weight);color:var(--it--color);top:var(--it__label--padding-top);left:var(--it__label--padding-left);padding-right:var(--it__label--padding-right)}.input__label--floated{font-family:var(--it--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--it__label--floating--top)}.input__label--disabled{color:var(--it__input--disabled--color)}.input__label--left{left:calc(var(--it__icon--width) + 2px);width:calc(100% - var(--it__icon--width))}.input__label--right{right:var(--it__icon--width);width:calc(100% - var(--it__icon--width))}.input__label--left.input__label--right{left:calc(var(--it__icon--width) + 2px);width:calc(100% - var(--it__icon--width) * 2)}.input--with--label{padding-bottom:0}";
|
|
3126
3126
|
|
|
3127
|
-
const EzTextInput = class {
|
|
3128
|
-
constructor(hostRef) {
|
|
3129
|
-
index.registerInstance(this, hostRef);
|
|
3130
|
-
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
3131
|
-
/**
|
|
3132
|
-
* Deixa o campo disponível ou não para digitação.
|
|
3133
|
-
*/
|
|
3134
|
-
this.enabled = true;
|
|
3135
|
-
}
|
|
3136
|
-
showError() {
|
|
3137
|
-
const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
|
|
3138
|
-
if (hasError) {
|
|
3139
|
-
this._inputElem.classList.add('hasError');
|
|
3140
|
-
this._messageBoxElem.classList.add('hasError');
|
|
3141
|
-
}
|
|
3142
|
-
else {
|
|
3143
|
-
this._inputElem.classList.remove('hasError');
|
|
3144
|
-
this._messageBoxElem.classList.remove('hasError');
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
prepareMask() {
|
|
3148
|
-
if (this.mask) {
|
|
3149
|
-
if (this._maskFormatter == undefined) {
|
|
3150
|
-
this._maskFormatter = new RequestMetadata.MaskFormatter(this.mask);
|
|
3151
|
-
}
|
|
3152
|
-
else {
|
|
3153
|
-
this._maskFormatter.mask = this.mask;
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
}
|
|
3157
|
-
updateInputValue() {
|
|
3158
|
-
this._inputElem.value = this.value;
|
|
3159
|
-
this.handleChange();
|
|
3160
|
-
this.ezChange.emit();
|
|
3161
|
-
this.adjustFloatingLabel();
|
|
3162
|
-
}
|
|
3163
|
-
adjustFloatingLabel() {
|
|
3164
|
-
if (this.label) {
|
|
3165
|
-
if (!this._inputElem.classList.contains("input--with--label")) {
|
|
3166
|
-
this._inputElem.classList.add("input--with--label");
|
|
3167
|
-
}
|
|
3168
|
-
const hasValue = this.value && this.value.toString().length > 0;
|
|
3169
|
-
const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
|
|
3170
|
-
if (hasValue || this.isFocused()) {
|
|
3171
|
-
if (!containsFloatedClass) {
|
|
3172
|
-
this._labelElem.classList.add("input__label--floated");
|
|
3173
|
-
}
|
|
3174
|
-
}
|
|
3175
|
-
else {
|
|
3176
|
-
if (containsFloatedClass) {
|
|
3177
|
-
this._labelElem.classList.remove("input__label--floated");
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
}
|
|
3182
|
-
isFocused() {
|
|
3183
|
-
return this._hostElement.shadowRoot.activeElement !== null;
|
|
3184
|
-
}
|
|
3185
|
-
//---------------------------------------------
|
|
3186
|
-
// Public methods
|
|
3187
|
-
//---------------------------------------------
|
|
3188
|
-
/**
|
|
3189
|
-
* Faz o foco no componente de input
|
|
3190
|
-
*/
|
|
3191
|
-
async setFocus() {
|
|
3192
|
-
this._inputElem.focus();
|
|
3193
|
-
}
|
|
3194
|
-
/**
|
|
3195
|
-
* Remove o foco no componente de input
|
|
3196
|
-
*/
|
|
3197
|
-
async setBlur() {
|
|
3198
|
-
this._inputElem.blur();
|
|
3199
|
-
}
|
|
3200
|
-
//---------------------------------------------
|
|
3201
|
-
// Event handlers
|
|
3202
|
-
//---------------------------------------------
|
|
3203
|
-
handleFocusout() {
|
|
3204
|
-
const value = this._inputElem.value;
|
|
3205
|
-
if (value && this._maskFormatter) {
|
|
3206
|
-
try {
|
|
3207
|
-
this._inputElem.value = this._maskFormatter.format(value);
|
|
3208
|
-
}
|
|
3209
|
-
catch (e) {
|
|
3210
|
-
this.errormessage = e.message;
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
this.value = this._inputElem.value;
|
|
3214
|
-
this.adjustFloatingLabel();
|
|
3215
|
-
}
|
|
3216
|
-
isValidValue(value) {
|
|
3217
|
-
if (this.onlynumber) {
|
|
3218
|
-
return value == "" || isValidNumber(value);
|
|
3219
|
-
}
|
|
3220
|
-
if (this.restrict) {
|
|
3221
|
-
return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
|
|
3222
|
-
}
|
|
3223
|
-
return true;
|
|
3224
|
-
}
|
|
3225
|
-
handleChange() {
|
|
3226
|
-
if (!this._inputElem) {
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
|
-
const value = this._inputElem.value;
|
|
3230
|
-
if (this.isValidValue(value)) {
|
|
3231
|
-
this._lastValidValue = value;
|
|
3232
|
-
}
|
|
3233
|
-
else {
|
|
3234
|
-
this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
|
|
3235
|
-
}
|
|
3236
|
-
this.value = this._inputElem.value;
|
|
3237
|
-
}
|
|
3238
|
-
handleSlotChange(ev) {
|
|
3239
|
-
const slot = ev.target;
|
|
3240
|
-
const content = slot.assignedElements()[0];
|
|
3241
|
-
if (content) {
|
|
3242
|
-
content.style.position = "absolute";
|
|
3243
|
-
content.style.display = "flex";
|
|
3244
|
-
content.style.alignItems = "center";
|
|
3245
|
-
content.style.justifyContent = "center";
|
|
3246
|
-
content.style.overflow = "hidden";
|
|
3247
|
-
content.style.top = "0px";
|
|
3248
|
-
content.style.width = "var(--it__icon--width)";
|
|
3249
|
-
content.style.height = "var(--it--height)";
|
|
3250
|
-
if (slot.name == "leftIcon") {
|
|
3251
|
-
content.style.left = "0px";
|
|
3252
|
-
content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
|
|
3253
|
-
this._inputElem.classList.add('icon--left');
|
|
3254
|
-
if (this._labelElem) {
|
|
3255
|
-
this._labelElem.classList.add('input__label--left');
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
else if (slot.name == "rightIcon") {
|
|
3259
|
-
content.style.right = "0px";
|
|
3260
|
-
content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
|
|
3261
|
-
this._inputElem.classList.add('icon--right');
|
|
3262
|
-
if (this._labelElem) {
|
|
3263
|
-
this._labelElem.classList.add('input__label--right');
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
}
|
|
3267
|
-
this.showError();
|
|
3268
|
-
}
|
|
3269
|
-
doFocus() {
|
|
3270
|
-
if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
|
|
3271
|
-
this._labelElem.classList.add("input__label--floated");
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
//---------------------------------------------
|
|
3275
|
-
// Lifecycle web component
|
|
3276
|
-
//---------------------------------------------
|
|
3277
|
-
componentDidLoad() {
|
|
3278
|
-
if (this.onlynumber) {
|
|
3279
|
-
this._inputElem.classList.add('text--right');
|
|
3280
|
-
}
|
|
3281
|
-
this.showError();
|
|
3282
|
-
this.prepareMask();
|
|
3283
|
-
this.adjustFloatingLabel();
|
|
3284
|
-
}
|
|
3285
|
-
componentWillLoad() {
|
|
3286
|
-
this.prepareMask();
|
|
3287
|
-
if (this.value) {
|
|
3288
|
-
if (this._maskFormatter) {
|
|
3289
|
-
try {
|
|
3290
|
-
this.value = this._maskFormatter.format(this.value);
|
|
3291
|
-
}
|
|
3292
|
-
catch (e) {
|
|
3293
|
-
this.errormessage = e.message;
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
if (!this.isValidValue(this.value)) {
|
|
3297
|
-
this._lastValidValue = "";
|
|
3298
|
-
this.value = "";
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
}
|
|
3302
|
-
render() {
|
|
3303
|
-
return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
|
|
3304
|
-
index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
3305
|
-
: null, index.h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
|
|
3306
|
-
}
|
|
3307
|
-
get _hostElement() { return index.getElement(this); }
|
|
3308
|
-
static get watchers() { return {
|
|
3309
|
-
"errormessage": ["showError"],
|
|
3310
|
-
"mask": ["prepareMask"],
|
|
3311
|
-
"value": ["updateInputValue"]
|
|
3312
|
-
}; }
|
|
3313
|
-
};
|
|
3127
|
+
const EzTextInput = class {
|
|
3128
|
+
constructor(hostRef) {
|
|
3129
|
+
index.registerInstance(this, hostRef);
|
|
3130
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
3131
|
+
/**
|
|
3132
|
+
* Deixa o campo disponível ou não para digitação.
|
|
3133
|
+
*/
|
|
3134
|
+
this.enabled = true;
|
|
3135
|
+
}
|
|
3136
|
+
showError() {
|
|
3137
|
+
const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
|
|
3138
|
+
if (hasError) {
|
|
3139
|
+
this._inputElem.classList.add('hasError');
|
|
3140
|
+
this._messageBoxElem.classList.add('hasError');
|
|
3141
|
+
}
|
|
3142
|
+
else {
|
|
3143
|
+
this._inputElem.classList.remove('hasError');
|
|
3144
|
+
this._messageBoxElem.classList.remove('hasError');
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
prepareMask() {
|
|
3148
|
+
if (this.mask) {
|
|
3149
|
+
if (this._maskFormatter == undefined) {
|
|
3150
|
+
this._maskFormatter = new RequestMetadata.MaskFormatter(this.mask);
|
|
3151
|
+
}
|
|
3152
|
+
else {
|
|
3153
|
+
this._maskFormatter.mask = this.mask;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
updateInputValue() {
|
|
3158
|
+
this._inputElem.value = this.value;
|
|
3159
|
+
this.handleChange();
|
|
3160
|
+
this.ezChange.emit();
|
|
3161
|
+
this.adjustFloatingLabel();
|
|
3162
|
+
}
|
|
3163
|
+
adjustFloatingLabel() {
|
|
3164
|
+
if (this.label) {
|
|
3165
|
+
if (!this._inputElem.classList.contains("input--with--label")) {
|
|
3166
|
+
this._inputElem.classList.add("input--with--label");
|
|
3167
|
+
}
|
|
3168
|
+
const hasValue = this.value && this.value.toString().length > 0;
|
|
3169
|
+
const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
|
|
3170
|
+
if (hasValue || this.isFocused()) {
|
|
3171
|
+
if (!containsFloatedClass) {
|
|
3172
|
+
this._labelElem.classList.add("input__label--floated");
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
else {
|
|
3176
|
+
if (containsFloatedClass) {
|
|
3177
|
+
this._labelElem.classList.remove("input__label--floated");
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
isFocused() {
|
|
3183
|
+
return this._hostElement.shadowRoot.activeElement !== null;
|
|
3184
|
+
}
|
|
3185
|
+
//---------------------------------------------
|
|
3186
|
+
// Public methods
|
|
3187
|
+
//---------------------------------------------
|
|
3188
|
+
/**
|
|
3189
|
+
* Faz o foco no componente de input
|
|
3190
|
+
*/
|
|
3191
|
+
async setFocus() {
|
|
3192
|
+
this._inputElem.focus();
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Remove o foco no componente de input
|
|
3196
|
+
*/
|
|
3197
|
+
async setBlur() {
|
|
3198
|
+
this._inputElem.blur();
|
|
3199
|
+
}
|
|
3200
|
+
//---------------------------------------------
|
|
3201
|
+
// Event handlers
|
|
3202
|
+
//---------------------------------------------
|
|
3203
|
+
handleFocusout() {
|
|
3204
|
+
const value = this._inputElem.value;
|
|
3205
|
+
if (value && this._maskFormatter) {
|
|
3206
|
+
try {
|
|
3207
|
+
this._inputElem.value = this._maskFormatter.format(value);
|
|
3208
|
+
}
|
|
3209
|
+
catch (e) {
|
|
3210
|
+
this.errormessage = e.message;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
this.value = this._inputElem.value;
|
|
3214
|
+
this.adjustFloatingLabel();
|
|
3215
|
+
}
|
|
3216
|
+
isValidValue(value) {
|
|
3217
|
+
if (this.onlynumber) {
|
|
3218
|
+
return value == "" || isValidNumber(value);
|
|
3219
|
+
}
|
|
3220
|
+
if (this.restrict) {
|
|
3221
|
+
return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
|
|
3222
|
+
}
|
|
3223
|
+
return true;
|
|
3224
|
+
}
|
|
3225
|
+
handleChange() {
|
|
3226
|
+
if (!this._inputElem) {
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
const value = this._inputElem.value;
|
|
3230
|
+
if (this.isValidValue(value)) {
|
|
3231
|
+
this._lastValidValue = value;
|
|
3232
|
+
}
|
|
3233
|
+
else {
|
|
3234
|
+
this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
|
|
3235
|
+
}
|
|
3236
|
+
this.value = this._inputElem.value;
|
|
3237
|
+
}
|
|
3238
|
+
handleSlotChange(ev) {
|
|
3239
|
+
const slot = ev.target;
|
|
3240
|
+
const content = slot.assignedElements()[0];
|
|
3241
|
+
if (content) {
|
|
3242
|
+
content.style.position = "absolute";
|
|
3243
|
+
content.style.display = "flex";
|
|
3244
|
+
content.style.alignItems = "center";
|
|
3245
|
+
content.style.justifyContent = "center";
|
|
3246
|
+
content.style.overflow = "hidden";
|
|
3247
|
+
content.style.top = "0px";
|
|
3248
|
+
content.style.width = "var(--it__icon--width)";
|
|
3249
|
+
content.style.height = "var(--it--height)";
|
|
3250
|
+
if (slot.name == "leftIcon") {
|
|
3251
|
+
content.style.left = "0px";
|
|
3252
|
+
content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
|
|
3253
|
+
this._inputElem.classList.add('icon--left');
|
|
3254
|
+
if (this._labelElem) {
|
|
3255
|
+
this._labelElem.classList.add('input__label--left');
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
else if (slot.name == "rightIcon") {
|
|
3259
|
+
content.style.right = "0px";
|
|
3260
|
+
content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
|
|
3261
|
+
this._inputElem.classList.add('icon--right');
|
|
3262
|
+
if (this._labelElem) {
|
|
3263
|
+
this._labelElem.classList.add('input__label--right');
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
this.showError();
|
|
3268
|
+
}
|
|
3269
|
+
doFocus() {
|
|
3270
|
+
if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
|
|
3271
|
+
this._labelElem.classList.add("input__label--floated");
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3274
|
+
//---------------------------------------------
|
|
3275
|
+
// Lifecycle web component
|
|
3276
|
+
//---------------------------------------------
|
|
3277
|
+
componentDidLoad() {
|
|
3278
|
+
if (this.onlynumber) {
|
|
3279
|
+
this._inputElem.classList.add('text--right');
|
|
3280
|
+
}
|
|
3281
|
+
this.showError();
|
|
3282
|
+
this.prepareMask();
|
|
3283
|
+
this.adjustFloatingLabel();
|
|
3284
|
+
}
|
|
3285
|
+
componentWillLoad() {
|
|
3286
|
+
this.prepareMask();
|
|
3287
|
+
if (this.value) {
|
|
3288
|
+
if (this._maskFormatter) {
|
|
3289
|
+
try {
|
|
3290
|
+
this.value = this._maskFormatter.format(this.value);
|
|
3291
|
+
}
|
|
3292
|
+
catch (e) {
|
|
3293
|
+
this.errormessage = e.message;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
if (!this.isValidValue(this.value)) {
|
|
3297
|
+
this._lastValidValue = "";
|
|
3298
|
+
this.value = "";
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
render() {
|
|
3303
|
+
return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
|
|
3304
|
+
index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
3305
|
+
: null, index.h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
|
|
3306
|
+
}
|
|
3307
|
+
get _hostElement() { return index.getElement(this); }
|
|
3308
|
+
static get watchers() { return {
|
|
3309
|
+
"errormessage": ["showError"],
|
|
3310
|
+
"mask": ["prepareMask"],
|
|
3311
|
+
"value": ["updateInputValue"]
|
|
3312
|
+
}; }
|
|
3313
|
+
};
|
|
3314
3314
|
EzTextInput.style = ezTextInputCss;
|
|
3315
3315
|
|
|
3316
3316
|
const placeHolderCss = ":host{display:flex;width:100%;height:42px;border-radius:12px;background:var(--background--medium);background-image:linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);background-repeat:no-repeat;background-size:800px 1000px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:placeholderShimmer;animation-timing-function:linear}@keyframes placeholderShimmer{0%{background-position:-800px 0}100%{background-position:800px 0}}";
|
|
3317
3317
|
|
|
3318
|
-
const PlaceHolder = class {
|
|
3319
|
-
constructor(hostRef) {
|
|
3320
|
-
index.registerInstance(this, hostRef);
|
|
3321
|
-
}
|
|
3322
|
-
render() {
|
|
3323
|
-
return index.h(index.Host, null);
|
|
3324
|
-
}
|
|
3325
|
-
};
|
|
3318
|
+
const PlaceHolder = class {
|
|
3319
|
+
constructor(hostRef) {
|
|
3320
|
+
index.registerInstance(this, hostRef);
|
|
3321
|
+
}
|
|
3322
|
+
render() {
|
|
3323
|
+
return index.h(index.Host, null);
|
|
3324
|
+
}
|
|
3325
|
+
};
|
|
3326
3326
|
PlaceHolder.style = placeHolderCss;
|
|
3327
3327
|
|
|
3328
3328
|
exports.ez_button = EzButton;
|