@sankhyalabs/ezui 1.1.4 → 1.1.8
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/{ezui/DataUnit-285bec19.js → cjs/DataUnit-28b290cb.js} +382 -369
- package/dist/{ezui/index-919090de.js → cjs/RequestMetadata-2cd01e8a.js} +4 -383
- package/dist/cjs/ez-action-chip.cjs.entry.js +52 -0
- package/dist/cjs/ez-button_14.cjs.entry.js +3341 -0
- package/dist/cjs/ez-label-chip.cjs.entry.js +131 -0
- package/dist/cjs/ez-modal.cjs.entry.js +115 -0
- package/dist/cjs/ez-number-input.cjs.entry.js +248 -0
- package/dist/cjs/ez-time-input.cjs.entry.js +180 -0
- package/dist/cjs/ezui.cjs.js +19 -0
- package/dist/cjs/form-metadata.cjs.entry.js +74 -0
- package/dist/cjs/index-9403fe8f.js +1322 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -0
- package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -0
- package/dist/collection/components/ez-button/ez-button.css +94 -0
- package/dist/collection/components/ez-button/ez-button.js +125 -0
- package/dist/collection/components/ez-calendar/ez-calendar.css +210 -0
- package/dist/collection/components/ez-calendar/ez-calendar.js +215 -0
- package/dist/collection/components/ez-check/ez-check.css +266 -0
- package/dist/collection/components/ez-check/ez-check.js +168 -0
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +68 -0
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -0
- package/dist/collection/components/ez-date-input/ez-date-input.css +39 -0
- package/dist/collection/components/ez-date-input/ez-date-input.js +172 -0
- package/dist/collection/components/ez-form/ez-form.css +19 -0
- package/dist/collection/components/ez-form/ez-form.js +368 -0
- package/dist/collection/components/ez-form/store/Form.actions.js +132 -0
- package/dist/collection/components/ez-form/store/Form.reducer.js +194 -0
- package/dist/collection/components/ez-form/store/Form.selectors.js +44 -0
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +207 -0
- package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -0
- package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +24 -0
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -0
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -0
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -0
- package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -0
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -0
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -0
- package/dist/collection/components/ez-icon/ez-icon.css +37 -0
- package/dist/collection/components/ez-icon/ez-icon.js +56 -0
- package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -0
- package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -0
- package/dist/collection/components/ez-modal/ez-modal.css +87 -0
- package/dist/collection/components/ez-modal/ez-modal.js +224 -0
- package/dist/collection/components/ez-number-input/ez-number-input.css +144 -0
- package/dist/collection/components/ez-number-input/ez-number-input.js +465 -0
- package/dist/collection/components/ez-popover/ez-popover.css +39 -0
- package/dist/collection/components/ez-popover/ez-popover.js +323 -0
- package/dist/collection/components/ez-search/ez-search.css +296 -0
- package/dist/{ezui/ez-search.entry.js → collection/components/ez-search/ez-search.js} +527 -334
- package/dist/collection/components/ez-tabselector/ez-tabselector.css +126 -0
- package/dist/{ezui/ez-tabselector.entry.js → collection/components/ez-tabselector/ez-tabselector.js} +283 -209
- package/dist/collection/components/ez-text-area/ez-text-area.css +140 -0
- package/dist/collection/components/ez-text-area/ez-text-area.js +267 -0
- package/dist/collection/components/ez-text-input/ez-text-input.css +170 -0
- package/dist/collection/components/ez-text-input/ez-text-input.js +395 -0
- package/dist/collection/components/ez-time-input/ez-time-input.css +155 -0
- package/dist/collection/components/ez-time-input/ez-time-input.js +326 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/servidor.js +101 -0
- package/dist/collection/utils/FloatingManager.js +16 -0
- package/dist/collection/utils/utils.js +6 -0
- package/dist/custom-elements/index.js +5071 -0
- package/dist/esm/DataUnit-69e518fa.js +378 -0
- package/dist/esm/RequestMetadata-c265c9d5.js +527 -0
- package/dist/{ezui → esm}/ez-action-chip.entry.js +42 -42
- package/dist/esm/ez-button_14.entry.js +3324 -0
- package/dist/{ezui → esm}/ez-label-chip.entry.js +121 -121
- package/dist/{ezui → esm}/ez-modal.entry.js +105 -96
- package/dist/{ezui → esm}/ez-number-input.entry.js +238 -238
- package/dist/{ezui → esm}/ez-time-input.entry.js +170 -170
- package/dist/esm/ezui.js +17 -0
- package/dist/{ezui → esm}/form-metadata.entry.js +66 -66
- package/dist/esm/index-95bb3fd9.js +1293 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/ezui/ezui.esm.js +1 -122
- package/dist/ezui/index.esm.js +0 -1
- package/dist/ezui/p-10ef58b3.js +1 -0
- package/dist/ezui/p-185c57f4.js +1 -0
- package/dist/ezui/p-22b82efb.entry.js +1 -0
- package/dist/ezui/p-77fdb4fd.entry.js +1 -0
- package/dist/ezui/p-9dfccb16.js +1 -0
- package/dist/ezui/p-b0974f4f.entry.js +1 -0
- package/dist/ezui/p-db11c600.entry.js +1 -0
- package/dist/ezui/p-dd4331b7.entry.js +1 -0
- package/dist/ezui/p-f6fd31ab.entry.js +1 -0
- package/dist/ezui/p-fa260f22.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- 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 +31 -27
- package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
- package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
- package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +55 -48
- 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 -7
- 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 -26
- 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/components.d.ts +8 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +2 -2
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +13 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +114 -114
- package/react/components.d.ts +22 -0
- package/react/components.js +25 -0
- package/react/components.js.map +1 -0
- package/react/react-component-lib/createComponent.d.ts +10 -0
- package/react/react-component-lib/createComponent.js +59 -0
- package/react/react-component-lib/createComponent.js.map +1 -0
- package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
- package/react/react-component-lib/createOverlayComponent.js +89 -0
- package/react/react-component-lib/createOverlayComponent.js.map +1 -0
- package/react/react-component-lib/index.d.ts +2 -0
- package/react/react-component-lib/index.js +3 -0
- package/react/react-component-lib/index.js.map +1 -0
- package/react/react-component-lib/interfaces.d.ts +29 -0
- package/react/react-component-lib/interfaces.js +1 -0
- package/react/react-component-lib/interfaces.js.map +1 -0
- package/react/react-component-lib/utils/attachProps.d.ts +12 -0
- package/react/react-component-lib/utils/attachProps.js +96 -0
- package/react/react-component-lib/utils/attachProps.js.map +1 -0
- package/react/react-component-lib/utils/case.d.ts +2 -0
- package/react/react-component-lib/utils/case.js +7 -0
- package/react/react-component-lib/utils/case.js.map +1 -0
- package/react/react-component-lib/utils/dev.d.ts +2 -0
- package/react/react-component-lib/utils/dev.js +13 -0
- package/react/react-component-lib/utils/dev.js.map +1 -0
- package/react/react-component-lib/utils/index.d.ts +7 -0
- package/react/react-component-lib/utils/index.js +21 -0
- package/react/react-component-lib/utils/index.js.map +1 -0
- package/dist/ezui/app-globals-0f993ce5.js +0 -3
- package/dist/ezui/css-shim-003e9264.js +0 -4
- package/dist/ezui/dom-1b195079.js +0 -73
- package/dist/ezui/ez-button.entry.js +0 -47
- package/dist/ezui/ez-calendar.entry.js +0 -102
- package/dist/ezui/ez-check.entry.js +0 -62
- package/dist/ezui/ez-collapsable-box.entry.js +0 -32
- package/dist/ezui/ez-combo-box.entry.js +0 -181
- package/dist/ezui/ez-date-input.entry.js +0 -77
- package/dist/ezui/ez-form.entry.js +0 -1907
- package/dist/ezui/ez-icon.entry.js +0 -17
- package/dist/ezui/ez-popover.entry.js +0 -112
- package/dist/ezui/ez-text-area.entry.js +0 -105
- package/dist/ezui/ez-text-input.entry.js +0 -202
- package/dist/ezui/index-39044be2.js +0 -2832
- package/dist/ezui/place-holder.entry.js +0 -15
- package/dist/ezui/shadow-css-c1ad5fdc.js +0 -383
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
--it__input--background-color: var(--background--medium, #e0e0e0);
|
|
5
|
+
--it__input--border-color: var(--it__input--background-color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.text-input{
|
|
9
|
+
--it__input--background-color: inherit;
|
|
10
|
+
--it__input--border-color: inherit;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.btn-open-cal{
|
|
14
|
+
outline: none;
|
|
15
|
+
border: none;
|
|
16
|
+
background-color: unset;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.btn-open-cal:disabled{
|
|
21
|
+
cursor: unset;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.btn-open-cal::after{
|
|
25
|
+
content: '';
|
|
26
|
+
display: flex;
|
|
27
|
+
background-color: var(--text--primary, #008561);
|
|
28
|
+
width: 15px;
|
|
29
|
+
height: 16px;
|
|
30
|
+
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");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.btn-open-cal:disabled:after{
|
|
34
|
+
background-color: var(--text--disable, #AFB6C0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.btn-open-cal:enabled:hover::after{
|
|
38
|
+
background-color: var(--color--primary, #4e4e4e);
|
|
39
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Component, Host, h, Prop, Watch, Event } from '@stencil/core';
|
|
2
|
+
import { DateUtils } from '@sankhyalabs/core';
|
|
3
|
+
export class EzDateInput {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Deixa o campo disponível ou não para uso.
|
|
7
|
+
*/
|
|
8
|
+
this.enabled = true;
|
|
9
|
+
}
|
|
10
|
+
setLabel() {
|
|
11
|
+
this._textInput.label = this.label;
|
|
12
|
+
}
|
|
13
|
+
setErrorMessage() {
|
|
14
|
+
this._textInput.errormessage = this.errormessage;
|
|
15
|
+
}
|
|
16
|
+
applyValueToInput() {
|
|
17
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
18
|
+
}
|
|
19
|
+
changeValue(newValue) {
|
|
20
|
+
newValue = newValue == null ? null : DateUtils.clearTime(newValue);
|
|
21
|
+
this._textInput.errormessage = "";
|
|
22
|
+
if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
|
|
23
|
+
this.value = newValue;
|
|
24
|
+
this.ezChange.emit();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
showCalendar() {
|
|
28
|
+
this.parseDate();
|
|
29
|
+
this._calendar.value = this.value;
|
|
30
|
+
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
31
|
+
//posição errada no futuro. Preferi fazer simples no começo,
|
|
32
|
+
//porque não quis onerar o text input com essa funcionalidade...
|
|
33
|
+
const top = this._textInput.errormessage ? '0px' : '-17px';
|
|
34
|
+
this._calendar.show(top);
|
|
35
|
+
}
|
|
36
|
+
hideCalendar() {
|
|
37
|
+
this.changeValue(this._calendar.value);
|
|
38
|
+
this._calendar.hide();
|
|
39
|
+
}
|
|
40
|
+
parseDate() {
|
|
41
|
+
const strValue = this._textInput.value;
|
|
42
|
+
const parsedDate = DateUtils.strToDate(strValue);
|
|
43
|
+
if (parsedDate || !strValue) {
|
|
44
|
+
if (this.value === parsedDate) {
|
|
45
|
+
this.changeValue(this.value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.changeValue(parsedDate);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this._textInput.errormessage = "O valor digitado não é uma data válida";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getTextValue(d) {
|
|
56
|
+
return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
return (h(Host, null,
|
|
60
|
+
h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { if (event.key === 'H' || event.key === 'h')
|
|
61
|
+
this.changeValue(new Date()); }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errormessage: this.errormessage },
|
|
62
|
+
h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })),
|
|
63
|
+
h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
64
|
+
}
|
|
65
|
+
static get is() { return "ez-date-input"; }
|
|
66
|
+
static get encapsulation() { return "shadow"; }
|
|
67
|
+
static get originalStyleUrls() { return {
|
|
68
|
+
"$": ["ez-date-input.css"]
|
|
69
|
+
}; }
|
|
70
|
+
static get styleUrls() { return {
|
|
71
|
+
"$": ["ez-date-input.css"]
|
|
72
|
+
}; }
|
|
73
|
+
static get properties() { return {
|
|
74
|
+
"label": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"mutable": false,
|
|
77
|
+
"complexType": {
|
|
78
|
+
"original": "string",
|
|
79
|
+
"resolved": "string",
|
|
80
|
+
"references": {}
|
|
81
|
+
},
|
|
82
|
+
"required": false,
|
|
83
|
+
"optional": false,
|
|
84
|
+
"docs": {
|
|
85
|
+
"tags": [],
|
|
86
|
+
"text": "Label \u00E9 o t\u00EDtulo do campo"
|
|
87
|
+
},
|
|
88
|
+
"attribute": "label",
|
|
89
|
+
"reflect": true
|
|
90
|
+
},
|
|
91
|
+
"value": {
|
|
92
|
+
"type": "unknown",
|
|
93
|
+
"mutable": true,
|
|
94
|
+
"complexType": {
|
|
95
|
+
"original": "Date",
|
|
96
|
+
"resolved": "Date",
|
|
97
|
+
"references": {
|
|
98
|
+
"Date": {
|
|
99
|
+
"location": "global"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"required": false,
|
|
104
|
+
"optional": false,
|
|
105
|
+
"docs": {
|
|
106
|
+
"tags": [],
|
|
107
|
+
"text": "A data informada pelo usu\u00E1rio"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"enabled": {
|
|
111
|
+
"type": "boolean",
|
|
112
|
+
"mutable": false,
|
|
113
|
+
"complexType": {
|
|
114
|
+
"original": "boolean",
|
|
115
|
+
"resolved": "boolean",
|
|
116
|
+
"references": {}
|
|
117
|
+
},
|
|
118
|
+
"required": false,
|
|
119
|
+
"optional": false,
|
|
120
|
+
"docs": {
|
|
121
|
+
"tags": [],
|
|
122
|
+
"text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para uso."
|
|
123
|
+
},
|
|
124
|
+
"attribute": "enabled",
|
|
125
|
+
"reflect": true,
|
|
126
|
+
"defaultValue": "true"
|
|
127
|
+
},
|
|
128
|
+
"errormessage": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"mutable": true,
|
|
131
|
+
"complexType": {
|
|
132
|
+
"original": "string",
|
|
133
|
+
"resolved": "string",
|
|
134
|
+
"references": {}
|
|
135
|
+
},
|
|
136
|
+
"required": false,
|
|
137
|
+
"optional": false,
|
|
138
|
+
"docs": {
|
|
139
|
+
"tags": [],
|
|
140
|
+
"text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
|
|
141
|
+
},
|
|
142
|
+
"attribute": "errormessage",
|
|
143
|
+
"reflect": true
|
|
144
|
+
}
|
|
145
|
+
}; }
|
|
146
|
+
static get events() { return [{
|
|
147
|
+
"method": "ezChange",
|
|
148
|
+
"name": "ezChange",
|
|
149
|
+
"bubbles": true,
|
|
150
|
+
"cancelable": true,
|
|
151
|
+
"composed": true,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": ""
|
|
155
|
+
},
|
|
156
|
+
"complexType": {
|
|
157
|
+
"original": "string",
|
|
158
|
+
"resolved": "string",
|
|
159
|
+
"references": {}
|
|
160
|
+
}
|
|
161
|
+
}]; }
|
|
162
|
+
static get watchers() { return [{
|
|
163
|
+
"propName": "label",
|
|
164
|
+
"methodName": "setLabel"
|
|
165
|
+
}, {
|
|
166
|
+
"propName": "errormessage",
|
|
167
|
+
"methodName": "setErrorMessage"
|
|
168
|
+
}, {
|
|
169
|
+
"propName": "value",
|
|
170
|
+
"methodName": "applyValueToInput"
|
|
171
|
+
}]; }
|
|
172
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
ez-form {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.form-sheet {
|
|
8
|
+
display: flex;
|
|
9
|
+
width: 100%;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tab__container {
|
|
15
|
+
display: flex;
|
|
16
|
+
width: 100%;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { Component, h, Element, forceUpdate, Prop, Method } from '@stencil/core';
|
|
2
|
+
import { createStore, applyMiddleware, combineReducers } from 'redux';
|
|
3
|
+
import thunk from 'redux-thunk';
|
|
4
|
+
import { formLoad, invalidField, showHideNavigationButtons } from './store/Form.actions';
|
|
5
|
+
import undoable from 'redux-undo';
|
|
6
|
+
import formReducer, { formNonHistoricReducer } from './store/Form.reducer';
|
|
7
|
+
import { FormSheet } from './subcomponents/structure/FormSheet';
|
|
8
|
+
import DataUnit from './subcomponents/DataUnit';
|
|
9
|
+
export class EzForm {
|
|
10
|
+
constructor() {
|
|
11
|
+
this._dataUnits = [];
|
|
12
|
+
this._requiredFieldsByDU = {};
|
|
13
|
+
}
|
|
14
|
+
async validate() {
|
|
15
|
+
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
16
|
+
if (!this._dataUnits[i].validateRecords()) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getChanges() {
|
|
22
|
+
let allChanges = [];
|
|
23
|
+
for (let i = 0; i < this._dataUnits.length; i++) {
|
|
24
|
+
const duChanges = this._dataUnits[i].getChangesToSave();
|
|
25
|
+
if (duChanges) {
|
|
26
|
+
allChanges = allChanges.concat(duChanges);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return allChanges;
|
|
30
|
+
}
|
|
31
|
+
validateRecords(dataUnit, records) {
|
|
32
|
+
const result = { isValid: true, message: '' };
|
|
33
|
+
const reqFields = this._requiredFieldsByDU[dataUnit.name];
|
|
34
|
+
const recordValidator = record => {
|
|
35
|
+
reqFields.forEach(field => {
|
|
36
|
+
const recordIndex = record["record__index"];
|
|
37
|
+
const fieldName = field.name;
|
|
38
|
+
const fieldValue = record[fieldName];
|
|
39
|
+
if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
|
|
40
|
+
this._store.dispatch(invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
|
|
41
|
+
result.isValid = false;
|
|
42
|
+
result.message = "Há pelo menos um campo obrigatório não preenchido.";
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
if (records.length == 0) {
|
|
47
|
+
recordValidator({});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
records.forEach(recordValidator);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
componentWillRender() {
|
|
55
|
+
if (this._store === undefined) {
|
|
56
|
+
const rootReducer = combineReducers({
|
|
57
|
+
"hist": undoable(formReducer),
|
|
58
|
+
"nonhist": formNonHistoricReducer
|
|
59
|
+
});
|
|
60
|
+
this._store = createStore(rootReducer, applyMiddleware(thunk));
|
|
61
|
+
this._store.subscribe(() => { forceUpdate(this); });
|
|
62
|
+
if (this.slavemode) {
|
|
63
|
+
this._store.dispatch(showHideNavigationButtons("saveVisible", false));
|
|
64
|
+
this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
|
|
65
|
+
this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
loadMDFromExecutor(callBack) {
|
|
70
|
+
if (this._loadMetadataFunction) {
|
|
71
|
+
const result = this._loadMetadataFunction();
|
|
72
|
+
if (result) {
|
|
73
|
+
if (result instanceof Promise) {
|
|
74
|
+
result.then(md => {
|
|
75
|
+
callBack(md);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
callBack(result);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
loadMDFromElement(callBack) {
|
|
85
|
+
const metadata = [];
|
|
86
|
+
Array.from(this._host.children).forEach(elem => {
|
|
87
|
+
if (elem.tagName === "FORM-METADATA") {
|
|
88
|
+
const formMetadata = elem;
|
|
89
|
+
metadata.push(formMetadata.metadata);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
callBack(metadata.length > 0 ? metadata : null);
|
|
93
|
+
}
|
|
94
|
+
updateMetadata(metadata) {
|
|
95
|
+
if (metadata) {
|
|
96
|
+
const processFields = (duName, form, tabController, tabIndex) => {
|
|
97
|
+
var _a;
|
|
98
|
+
let requiredFields = this._requiredFieldsByDU[duName];
|
|
99
|
+
if (requiredFields === undefined) {
|
|
100
|
+
requiredFields = [];
|
|
101
|
+
this._requiredFieldsByDU[duName] = requiredFields;
|
|
102
|
+
}
|
|
103
|
+
form.items.forEach(item => {
|
|
104
|
+
if ("fields" in item) {
|
|
105
|
+
const fSet = item;
|
|
106
|
+
fSet.fields.forEach(f => {
|
|
107
|
+
f.tabControler = tabController;
|
|
108
|
+
f.tabIndex = tabIndex;
|
|
109
|
+
if (f.required) {
|
|
110
|
+
requiredFields.push(f);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const f = item;
|
|
116
|
+
f.tabControler = tabController;
|
|
117
|
+
f.tabIndex = tabIndex;
|
|
118
|
+
if (f.required) {
|
|
119
|
+
requiredFields.push(f);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
(_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
|
|
124
|
+
const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
|
|
125
|
+
processFields(subDU, subForm, form.name, index);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
this.metadata = metadata;
|
|
129
|
+
metadata.map((form, index) => {
|
|
130
|
+
processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
|
|
131
|
+
});
|
|
132
|
+
this._store.dispatch(formLoad());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
parseExecutor(executor) {
|
|
136
|
+
if (executor) {
|
|
137
|
+
return executor instanceof Function ? executor : eval(executor);
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
componentDidLoad() {
|
|
142
|
+
this._loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
|
|
143
|
+
this._loadDataFunction = this.parseExecutor(this.loadexecutor);
|
|
144
|
+
this._saveFunction = this.parseExecutor(this.saveexecutor);
|
|
145
|
+
this._removeFunction = this.parseExecutor(this.removeexecutor);
|
|
146
|
+
this._fieldSearchFunction = this.parseExecutor(this.fieldsearchexecutor);
|
|
147
|
+
if (this.metadata) {
|
|
148
|
+
this.updateMetadata(this.metadata);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.loadMDFromElement((md) => this.updateMetadata(md));
|
|
152
|
+
if (!this.metadata) {
|
|
153
|
+
this.loadMDFromExecutor((md) => this.updateMetadata(md));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
buildDataUnit(dataUnit) {
|
|
158
|
+
if (dataUnit) {
|
|
159
|
+
const { name, unitLabel, records, cardinality } = dataUnit;
|
|
160
|
+
if (!(dataUnit instanceof DataUnit)) {
|
|
161
|
+
dataUnit = new DataUnit(name, unitLabel, cardinality);
|
|
162
|
+
this._dataUnits.push(dataUnit);
|
|
163
|
+
if (records) {
|
|
164
|
+
dataUnit.records = records;
|
|
165
|
+
}
|
|
166
|
+
dataUnit.store = this._store;
|
|
167
|
+
dataUnit.loadExecutor = this._loadDataFunction;
|
|
168
|
+
dataUnit.saveExecutor = this._saveFunction;
|
|
169
|
+
dataUnit.removeExecutor = this._removeFunction;
|
|
170
|
+
dataUnit.recordsValidator = this;
|
|
171
|
+
dataUnit.fieldSearchExecutor = this._fieldSearchFunction;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return dataUnit;
|
|
175
|
+
}
|
|
176
|
+
render() {
|
|
177
|
+
return this.metadata ? h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
|
|
178
|
+
}
|
|
179
|
+
static get is() { return "ez-form"; }
|
|
180
|
+
static get originalStyleUrls() { return {
|
|
181
|
+
"$": ["ez-form.css"]
|
|
182
|
+
}; }
|
|
183
|
+
static get styleUrls() { return {
|
|
184
|
+
"$": ["ez-form.css"]
|
|
185
|
+
}; }
|
|
186
|
+
static get properties() { return {
|
|
187
|
+
"metadataexecutor": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"mutable": false,
|
|
190
|
+
"complexType": {
|
|
191
|
+
"original": "string | Function",
|
|
192
|
+
"resolved": "Function | string",
|
|
193
|
+
"references": {
|
|
194
|
+
"Function": {
|
|
195
|
+
"location": "global"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"required": false,
|
|
200
|
+
"optional": false,
|
|
201
|
+
"docs": {
|
|
202
|
+
"tags": [],
|
|
203
|
+
"text": ""
|
|
204
|
+
},
|
|
205
|
+
"attribute": "metadataexecutor",
|
|
206
|
+
"reflect": false
|
|
207
|
+
},
|
|
208
|
+
"loadexecutor": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"mutable": false,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "string | Function",
|
|
213
|
+
"resolved": "Function | string",
|
|
214
|
+
"references": {
|
|
215
|
+
"Function": {
|
|
216
|
+
"location": "global"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": ""
|
|
225
|
+
},
|
|
226
|
+
"attribute": "loadexecutor",
|
|
227
|
+
"reflect": false
|
|
228
|
+
},
|
|
229
|
+
"saveexecutor": {
|
|
230
|
+
"type": "string",
|
|
231
|
+
"mutable": false,
|
|
232
|
+
"complexType": {
|
|
233
|
+
"original": "string | Function",
|
|
234
|
+
"resolved": "Function | string",
|
|
235
|
+
"references": {
|
|
236
|
+
"Function": {
|
|
237
|
+
"location": "global"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"required": false,
|
|
242
|
+
"optional": false,
|
|
243
|
+
"docs": {
|
|
244
|
+
"tags": [],
|
|
245
|
+
"text": ""
|
|
246
|
+
},
|
|
247
|
+
"attribute": "saveexecutor",
|
|
248
|
+
"reflect": false
|
|
249
|
+
},
|
|
250
|
+
"removeexecutor": {
|
|
251
|
+
"type": "string",
|
|
252
|
+
"mutable": false,
|
|
253
|
+
"complexType": {
|
|
254
|
+
"original": "string | Function",
|
|
255
|
+
"resolved": "Function | string",
|
|
256
|
+
"references": {
|
|
257
|
+
"Function": {
|
|
258
|
+
"location": "global"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"required": false,
|
|
263
|
+
"optional": false,
|
|
264
|
+
"docs": {
|
|
265
|
+
"tags": [],
|
|
266
|
+
"text": ""
|
|
267
|
+
},
|
|
268
|
+
"attribute": "removeexecutor",
|
|
269
|
+
"reflect": false
|
|
270
|
+
},
|
|
271
|
+
"fieldsearchexecutor": {
|
|
272
|
+
"type": "string",
|
|
273
|
+
"mutable": false,
|
|
274
|
+
"complexType": {
|
|
275
|
+
"original": "string | Function",
|
|
276
|
+
"resolved": "Function | string",
|
|
277
|
+
"references": {
|
|
278
|
+
"Function": {
|
|
279
|
+
"location": "global"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"required": false,
|
|
284
|
+
"optional": false,
|
|
285
|
+
"docs": {
|
|
286
|
+
"tags": [],
|
|
287
|
+
"text": ""
|
|
288
|
+
},
|
|
289
|
+
"attribute": "fieldsearchexecutor",
|
|
290
|
+
"reflect": false
|
|
291
|
+
},
|
|
292
|
+
"metadata": {
|
|
293
|
+
"type": "unknown",
|
|
294
|
+
"mutable": true,
|
|
295
|
+
"complexType": {
|
|
296
|
+
"original": "Array<Form>",
|
|
297
|
+
"resolved": "Form[]",
|
|
298
|
+
"references": {
|
|
299
|
+
"Array": {
|
|
300
|
+
"location": "global"
|
|
301
|
+
},
|
|
302
|
+
"Form": {
|
|
303
|
+
"location": "import",
|
|
304
|
+
"path": "./subcomponents/FormMetadata"
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
"required": false,
|
|
309
|
+
"optional": false,
|
|
310
|
+
"docs": {
|
|
311
|
+
"tags": [],
|
|
312
|
+
"text": ""
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"slavemode": {
|
|
316
|
+
"type": "boolean",
|
|
317
|
+
"mutable": false,
|
|
318
|
+
"complexType": {
|
|
319
|
+
"original": "boolean",
|
|
320
|
+
"resolved": "boolean",
|
|
321
|
+
"references": {}
|
|
322
|
+
},
|
|
323
|
+
"required": false,
|
|
324
|
+
"optional": false,
|
|
325
|
+
"docs": {
|
|
326
|
+
"tags": [],
|
|
327
|
+
"text": ""
|
|
328
|
+
},
|
|
329
|
+
"attribute": "slavemode",
|
|
330
|
+
"reflect": false
|
|
331
|
+
}
|
|
332
|
+
}; }
|
|
333
|
+
static get methods() { return {
|
|
334
|
+
"validate": {
|
|
335
|
+
"complexType": {
|
|
336
|
+
"signature": "() => Promise<boolean>",
|
|
337
|
+
"parameters": [],
|
|
338
|
+
"references": {
|
|
339
|
+
"Promise": {
|
|
340
|
+
"location": "global"
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
"return": "Promise<boolean>"
|
|
344
|
+
},
|
|
345
|
+
"docs": {
|
|
346
|
+
"text": "",
|
|
347
|
+
"tags": []
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"getChanges": {
|
|
351
|
+
"complexType": {
|
|
352
|
+
"signature": "() => Promise<any[]>",
|
|
353
|
+
"parameters": [],
|
|
354
|
+
"references": {
|
|
355
|
+
"Promise": {
|
|
356
|
+
"location": "global"
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
"return": "Promise<any[]>"
|
|
360
|
+
},
|
|
361
|
+
"docs": {
|
|
362
|
+
"text": "",
|
|
363
|
+
"tags": []
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}; }
|
|
367
|
+
static get elementRef() { return "_host"; }
|
|
368
|
+
}
|