@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,132 @@
|
|
|
1
|
+
export function changeFieldValue(dataUnit, recordId, fieldName, value) {
|
|
2
|
+
return {
|
|
3
|
+
type: 'FORM/CHANGEFIELD',
|
|
4
|
+
payload: { dataUnit, recordId, fieldName, value }
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function changeTab(formId, index) {
|
|
8
|
+
return {
|
|
9
|
+
type: 'FORM/CHANGETAB',
|
|
10
|
+
payload: { formId, index }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function clearEdition(dataUnit, recordsLimit) {
|
|
14
|
+
return {
|
|
15
|
+
type: 'FORM/CLEAREDITION',
|
|
16
|
+
payload: {
|
|
17
|
+
dataUnit,
|
|
18
|
+
recordsLimit
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function collapseExpandGroup(collapseId, collapsed) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'FORM/COLLAPSEGROUP',
|
|
25
|
+
payload: { collapseId, collapsed }
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function previousRecord(dataUnit) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'FORM/NAVIGATE',
|
|
31
|
+
payload: {
|
|
32
|
+
dataUnit,
|
|
33
|
+
limit: 0,
|
|
34
|
+
backward: true
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function nextRecord(dataUnit, limit) {
|
|
39
|
+
return {
|
|
40
|
+
type: 'FORM/NAVIGATE',
|
|
41
|
+
payload: {
|
|
42
|
+
dataUnit,
|
|
43
|
+
limit,
|
|
44
|
+
backward: false
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function insertRecord(dataUnit, insertionIndex) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'FORM/INSERT',
|
|
51
|
+
payload: {
|
|
52
|
+
dataUnit,
|
|
53
|
+
insertionIndex
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function formLoad() {
|
|
58
|
+
return {
|
|
59
|
+
type: 'FORM/LOAD'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function dataLoading(dataUnit) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'FORM/DATALOADING',
|
|
65
|
+
payload: {
|
|
66
|
+
dataUnit
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function savingChanges(dataUnit) {
|
|
71
|
+
return {
|
|
72
|
+
type: 'FORM/SAVINGCHANGES',
|
|
73
|
+
payload: {
|
|
74
|
+
dataUnit
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function dataLoaded(dataUnit) {
|
|
79
|
+
return {
|
|
80
|
+
type: 'FORM/DATALOADED',
|
|
81
|
+
payload: {
|
|
82
|
+
dataUnit
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function changesSaved(dataUnit) {
|
|
87
|
+
return {
|
|
88
|
+
type: 'FORM/CHANGESSAVED',
|
|
89
|
+
payload: {
|
|
90
|
+
dataUnit
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function removingRecord(dataUnit) {
|
|
95
|
+
return {
|
|
96
|
+
type: 'FORM/REMOVINGRECORD',
|
|
97
|
+
payload: {
|
|
98
|
+
dataUnit
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function recordRemoved(dataUnit) {
|
|
103
|
+
return {
|
|
104
|
+
type: 'FORM/RECORDREMOVED',
|
|
105
|
+
payload: {
|
|
106
|
+
dataUnit
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export function invalidField(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
|
|
111
|
+
return {
|
|
112
|
+
type: 'FORM/INVALIDFIELD',
|
|
113
|
+
payload: {
|
|
114
|
+
tabController,
|
|
115
|
+
tabIndex,
|
|
116
|
+
dataUnit,
|
|
117
|
+
recordId,
|
|
118
|
+
recordIndex,
|
|
119
|
+
fieldName,
|
|
120
|
+
errorMessage
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export function showHideNavigationButtons(buttonName, status) {
|
|
125
|
+
return {
|
|
126
|
+
type: 'FORM/SHOWHIDENAVBTN',
|
|
127
|
+
payload: {
|
|
128
|
+
buttonName,
|
|
129
|
+
status
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const inicialHistState = {
|
|
2
|
+
currentTabIndex: {},
|
|
3
|
+
currentRecordIndex: {},
|
|
4
|
+
changes: {},
|
|
5
|
+
collapsedGroups: {},
|
|
6
|
+
newRecordIndex: {}
|
|
7
|
+
};
|
|
8
|
+
const inicialNonHistState = {
|
|
9
|
+
dataLoading: {},
|
|
10
|
+
invalidFields: {},
|
|
11
|
+
visibleButtons: {
|
|
12
|
+
previousVisible: true,
|
|
13
|
+
nextVisible: true,
|
|
14
|
+
addVisible: true,
|
|
15
|
+
removeVisible: true,
|
|
16
|
+
saveVisible: true,
|
|
17
|
+
cancelVisible: true,
|
|
18
|
+
reloadVisible: true
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export default function formReducer(state = inicialHistState, action) {
|
|
22
|
+
switch (action.type) {
|
|
23
|
+
case 'FORM/COLLAPSEGROUP':
|
|
24
|
+
return collapseGroup(state, action.payload);
|
|
25
|
+
case 'FORM/CHANGETAB':
|
|
26
|
+
return changeTab(state, action.payload.formId, action.payload.index);
|
|
27
|
+
case 'FORM/NAVIGATE':
|
|
28
|
+
return navigate(state, action.payload);
|
|
29
|
+
case 'FORM/INSERT':
|
|
30
|
+
return insertRecord(state, action.payload);
|
|
31
|
+
case 'FORM/CHANGEFIELD':
|
|
32
|
+
return changeFieldValue(state, action.payload);
|
|
33
|
+
case 'FORM/CLEAREDITION':
|
|
34
|
+
return clearEdition(state, action.payload);
|
|
35
|
+
case 'FORM/INVALIDFIELD':
|
|
36
|
+
return navigateToInvalid(state, action.payload);
|
|
37
|
+
default:
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function formNonHistoricReducer(state = inicialNonHistState, action) {
|
|
42
|
+
switch (action.type) {
|
|
43
|
+
case 'FORM/DATALOADING':
|
|
44
|
+
return dataLoading(state, action.payload);
|
|
45
|
+
case 'FORM/DATALOADED':
|
|
46
|
+
return dataLoaded(state, action.payload);
|
|
47
|
+
case 'FORM/SAVINGCHANGES':
|
|
48
|
+
return savingChanges(state, action.payload);
|
|
49
|
+
case 'FORM/CHANGESSAVED':
|
|
50
|
+
return changesSaved(state, action.payload);
|
|
51
|
+
case 'FORM/REMOVINGRECORD':
|
|
52
|
+
return removingRecord(state, action.payload);
|
|
53
|
+
case 'FORM/RECORDREMOVED':
|
|
54
|
+
return recordRemoved(state, action.payload);
|
|
55
|
+
case 'FORM/INVALIDFIELD':
|
|
56
|
+
return invalidField(state, action.payload);
|
|
57
|
+
case 'FORM/CLEAREDITION':
|
|
58
|
+
return clearAllInvalidFields(state, action.payload);
|
|
59
|
+
case 'FORM/CHANGEFIELD':
|
|
60
|
+
return clearInvalidField(state, action.payload);
|
|
61
|
+
case 'FORM/SHOWHIDENAVBTN':
|
|
62
|
+
return showHideNavBtn(state, action.payload);
|
|
63
|
+
default:
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function collapseGroup(state, { collapseId, collapsed }) {
|
|
68
|
+
const currentCollapsed = Object.assign({}, state.collapsedGroups);
|
|
69
|
+
if (collapsed) {
|
|
70
|
+
currentCollapsed[collapseId] = true;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
delete currentCollapsed[collapseId];
|
|
74
|
+
}
|
|
75
|
+
return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
|
|
76
|
+
}
|
|
77
|
+
function changeTab(state, formId, index) {
|
|
78
|
+
const currentTabIndex = Object.assign({}, state.currentTabIndex);
|
|
79
|
+
currentTabIndex[formId] = index;
|
|
80
|
+
return Object.assign(Object.assign({}, state), { currentTabIndex });
|
|
81
|
+
}
|
|
82
|
+
function navigate(state, { dataUnit, limit, backward }) {
|
|
83
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
84
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
85
|
+
return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
|
|
86
|
+
}
|
|
87
|
+
function gotoIndex(state, dataUnit, index) {
|
|
88
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
89
|
+
currentRecordIndex[dataUnit] = index;
|
|
90
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex });
|
|
91
|
+
}
|
|
92
|
+
function insertRecord(state, { dataUnit, insertionIndex }) {
|
|
93
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
94
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
95
|
+
currentRecordIndex[dataUnit] = insertionIndex;
|
|
96
|
+
newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
|
|
97
|
+
return Object.assign(Object.assign({}, state), { currentRecordIndex,
|
|
98
|
+
newRecordIndex });
|
|
99
|
+
}
|
|
100
|
+
function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
|
|
101
|
+
const changes = Object.assign({}, state.changes);
|
|
102
|
+
const dataUnitChanges = Object.assign({}, changes[dataUnit]);
|
|
103
|
+
const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
|
|
104
|
+
recordChanges[fieldName] = value;
|
|
105
|
+
dataUnitChanges[recordId] = recordChanges;
|
|
106
|
+
changes[dataUnit] = dataUnitChanges;
|
|
107
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
108
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
109
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
110
|
+
delete errorMessages[fieldName];
|
|
111
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
112
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
113
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
114
|
+
invalidFields, invalidFieldSelected: undefined });
|
|
115
|
+
}
|
|
116
|
+
function clearEdition(state, { dataUnit, recordsLimit }) {
|
|
117
|
+
const changes = Object.assign({}, state.changes);
|
|
118
|
+
const newRecordIndex = Object.assign({}, state.newRecordIndex);
|
|
119
|
+
const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
|
|
120
|
+
delete changes[dataUnit];
|
|
121
|
+
delete newRecordIndex[dataUnit];
|
|
122
|
+
const recIndex = currentRecordIndex[dataUnit] || 0;
|
|
123
|
+
currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
|
|
124
|
+
return Object.assign(Object.assign({}, state), { changes,
|
|
125
|
+
newRecordIndex,
|
|
126
|
+
currentRecordIndex });
|
|
127
|
+
}
|
|
128
|
+
function navigateToInvalid(state, payload) {
|
|
129
|
+
let newState = Object.assign({}, state);
|
|
130
|
+
if (newState.invalidFieldSelected === undefined) {
|
|
131
|
+
newState.invalidFieldSelected = true;
|
|
132
|
+
newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
|
|
133
|
+
newState = changeTab(newState, payload.tabController, payload.tabIndex);
|
|
134
|
+
}
|
|
135
|
+
return newState;
|
|
136
|
+
}
|
|
137
|
+
function dataLoading(state, { dataUnit }) {
|
|
138
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
139
|
+
dataLoading[dataUnit] = true;
|
|
140
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
141
|
+
}
|
|
142
|
+
function dataLoaded(state, { dataUnit }) {
|
|
143
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
144
|
+
delete dataLoading[dataUnit];
|
|
145
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
146
|
+
}
|
|
147
|
+
function savingChanges(state, { dataUnit }) {
|
|
148
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
149
|
+
dataLoading[dataUnit] = true;
|
|
150
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
151
|
+
}
|
|
152
|
+
function changesSaved(state, { dataUnit }) {
|
|
153
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
154
|
+
delete dataLoading[dataUnit];
|
|
155
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
156
|
+
}
|
|
157
|
+
function removingRecord(state, { dataUnit }) {
|
|
158
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
159
|
+
dataLoading[dataUnit] = true;
|
|
160
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
161
|
+
}
|
|
162
|
+
function recordRemoved(state, { dataUnit }) {
|
|
163
|
+
const dataLoading = Object.assign({}, state.dataLoading);
|
|
164
|
+
delete dataLoading[dataUnit];
|
|
165
|
+
return Object.assign(Object.assign({}, state), { dataLoading });
|
|
166
|
+
}
|
|
167
|
+
function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
|
|
168
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
169
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
170
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
171
|
+
errorMessages[fieldName] = errorMessage;
|
|
172
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
173
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
174
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
175
|
+
}
|
|
176
|
+
function clearAllInvalidFields(state, { dataUnit }) {
|
|
177
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
178
|
+
delete invalidFields[dataUnit];
|
|
179
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
180
|
+
}
|
|
181
|
+
function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
|
|
182
|
+
const invalidFields = Object.assign({}, state.invalidFields);
|
|
183
|
+
const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
|
|
184
|
+
const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
|
|
185
|
+
delete errorMessages[fieldName];
|
|
186
|
+
dataUnitInvalidRecords[recordId] = errorMessages;
|
|
187
|
+
invalidFields[dataUnit] = dataUnitInvalidRecords;
|
|
188
|
+
return Object.assign(Object.assign({}, state), { invalidFields });
|
|
189
|
+
}
|
|
190
|
+
function showHideNavBtn(state, { buttonName, status }) {
|
|
191
|
+
const visibleButtons = Object.assign({}, state.visibleButtons);
|
|
192
|
+
visibleButtons[buttonName] = status;
|
|
193
|
+
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
194
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//histórico
|
|
2
|
+
export const selectCurrentTab = (state, formName) => {
|
|
3
|
+
const data = state.hist.present.currentTabIndex;
|
|
4
|
+
return data[formName] || 0;
|
|
5
|
+
};
|
|
6
|
+
export const selectIsCollapsedFieldSet = (state, fieldSetName) => {
|
|
7
|
+
const data = state.hist.present.collapsedGroups;
|
|
8
|
+
return data[fieldSetName];
|
|
9
|
+
};
|
|
10
|
+
export const selectRecordChanges = (state, dataUnit, recordId) => {
|
|
11
|
+
const data = selectDataUnitChanges(state, dataUnit);
|
|
12
|
+
return data ? data[recordId] : undefined;
|
|
13
|
+
};
|
|
14
|
+
export const selectDataUnitChanges = (state, dataUnit) => {
|
|
15
|
+
const data = state.hist.present.changes;
|
|
16
|
+
return data[dataUnit];
|
|
17
|
+
};
|
|
18
|
+
export const selectCurrentRecordIndex = (state, dataUnit) => {
|
|
19
|
+
const data = state.hist.present.currentRecordIndex;
|
|
20
|
+
return data[dataUnit] || 0;
|
|
21
|
+
};
|
|
22
|
+
export const selectNewRecordIndex = (state, dataUnit) => {
|
|
23
|
+
const data = state.hist.present.newRecordIndex;
|
|
24
|
+
return data[dataUnit] || 0;
|
|
25
|
+
};
|
|
26
|
+
export const selectUndoState = state => { return { canUndo: state.hist.past.length > 0, canRedo: state.hist.future.length > 0 }; };
|
|
27
|
+
//não histórico
|
|
28
|
+
export const selectLoadingData = (state, dataUnit) => {
|
|
29
|
+
const data = state.nonhist.dataLoading;
|
|
30
|
+
return data[dataUnit];
|
|
31
|
+
};
|
|
32
|
+
export const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
|
|
33
|
+
const data = state.nonhist.invalidFields;
|
|
34
|
+
const dataUnitMessages = data[dataUnit] || {};
|
|
35
|
+
const recordMessages = dataUnitMessages[recordId] || {};
|
|
36
|
+
return recordMessages[fieldName] || "";
|
|
37
|
+
};
|
|
38
|
+
export const selectInvalidFields = (state, dataUnit, recordId) => {
|
|
39
|
+
const data = state.nonhist.invalidFields;
|
|
40
|
+
const dataUnitMessages = data[dataUnit] || {};
|
|
41
|
+
const recordMessages = dataUnitMessages[recordId] || {};
|
|
42
|
+
return Object.keys(recordMessages);
|
|
43
|
+
};
|
|
44
|
+
export const selectVisibleButtons = state => state.nonhist.visibleButtons;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { changeFieldValue, changesSaved, clearEdition, dataLoaded, dataLoading, insertRecord, nextRecord, previousRecord, recordRemoved, removingRecord, savingChanges } from '../store/Form.actions';
|
|
2
|
+
import { selectRecordChanges, selectCurrentRecordIndex, selectLoadingData, selectNewRecordIndex, selectDataUnitChanges, selectErrorMessage } from '../store/Form.selectors';
|
|
3
|
+
export default class DataUnit {
|
|
4
|
+
constructor(name, unitLabel, cardinality = '1') {
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.unitLabel = unitLabel;
|
|
7
|
+
this.cardinality = cardinality;
|
|
8
|
+
}
|
|
9
|
+
set store(store) {
|
|
10
|
+
this._store = store;
|
|
11
|
+
}
|
|
12
|
+
isLoading() {
|
|
13
|
+
return selectLoadingData(this._store.getState(), this.name);
|
|
14
|
+
}
|
|
15
|
+
hasChanges() {
|
|
16
|
+
const state = this._store.getState();
|
|
17
|
+
return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
|
|
18
|
+
}
|
|
19
|
+
hasNext() {
|
|
20
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
|
|
21
|
+
}
|
|
22
|
+
hasPrevious() {
|
|
23
|
+
return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
|
|
24
|
+
}
|
|
25
|
+
hasCurrentRecord() {
|
|
26
|
+
return this.getCurrentRecord() != undefined;
|
|
27
|
+
}
|
|
28
|
+
previous() {
|
|
29
|
+
this._store.dispatch(previousRecord(this.name));
|
|
30
|
+
}
|
|
31
|
+
next() {
|
|
32
|
+
this._store.dispatch(nextRecord(this.name, this.records.length));
|
|
33
|
+
}
|
|
34
|
+
getValue(fieldName) {
|
|
35
|
+
const currentRecord = this.getCurrentRecord();
|
|
36
|
+
if (!currentRecord) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const changes = this.getRecordChanges(currentRecord);
|
|
40
|
+
return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
|
|
41
|
+
}
|
|
42
|
+
getErrorMessage(fieldName) {
|
|
43
|
+
const currentRecord = this.getCurrentRecord();
|
|
44
|
+
return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
|
|
45
|
+
}
|
|
46
|
+
changeValue(fieldName, newValue) {
|
|
47
|
+
if (this.records.length == 0) {
|
|
48
|
+
this.insert();
|
|
49
|
+
}
|
|
50
|
+
if (this._changeDeboucing) {
|
|
51
|
+
window.clearTimeout(this._changeDeboucing);
|
|
52
|
+
}
|
|
53
|
+
this._changeDeboucing = window.setTimeout(() => {
|
|
54
|
+
const currentRecord = this.getCurrentRecord();
|
|
55
|
+
this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
|
|
56
|
+
}, 100);
|
|
57
|
+
}
|
|
58
|
+
cancel() {
|
|
59
|
+
this.records = this.records.filter(r => !r.record__id.startsWith('NEW_'));
|
|
60
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
61
|
+
}
|
|
62
|
+
insert() {
|
|
63
|
+
const insertionIndex = this.records.length;
|
|
64
|
+
const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
|
|
65
|
+
this.records.push({ record__id: 'NEW_' + (newRecordIndex + 1) });
|
|
66
|
+
this._store.dispatch(insertRecord(this.name, insertionIndex));
|
|
67
|
+
}
|
|
68
|
+
getChangesToSave() {
|
|
69
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
70
|
+
if (duChanges) {
|
|
71
|
+
const changesByRecord = Object.keys(duChanges).map(record__id => {
|
|
72
|
+
const record = { record__id };
|
|
73
|
+
const recordChanges = duChanges[record__id];
|
|
74
|
+
Object.keys(recordChanges).forEach(fieldName => { record[fieldName] = recordChanges[fieldName]; });
|
|
75
|
+
return record;
|
|
76
|
+
});
|
|
77
|
+
return [{
|
|
78
|
+
dataUnit: this.name,
|
|
79
|
+
records: changesByRecord
|
|
80
|
+
}];
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
save() {
|
|
85
|
+
if (!this.validateRecords()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this._store.dispatch(savingChanges(this.name));
|
|
89
|
+
let saveResult;
|
|
90
|
+
if (this.saveExecutor) {
|
|
91
|
+
saveResult = this.saveExecutor(this.getChangesToSave());
|
|
92
|
+
}
|
|
93
|
+
if (saveResult instanceof Promise) {
|
|
94
|
+
saveResult.then(r => this.processSaveResult(r));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.processSaveResult(saveResult);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
load() {
|
|
101
|
+
this._store.dispatch(dataLoading(this.name));
|
|
102
|
+
let result;
|
|
103
|
+
if (this.loadExecutor) {
|
|
104
|
+
result = this.loadExecutor({ dataUnit: this.name });
|
|
105
|
+
}
|
|
106
|
+
if (result instanceof Promise) {
|
|
107
|
+
result.then(r => this.processLoadResult(r));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.processLoadResult(result);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
remove() {
|
|
114
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
115
|
+
this._store.dispatch(removingRecord(this.name));
|
|
116
|
+
let removeResult;
|
|
117
|
+
if (this.removeExecutor) {
|
|
118
|
+
const record = this.getCurrentRecord();
|
|
119
|
+
removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
removeResult = true;
|
|
123
|
+
}
|
|
124
|
+
if (removeResult) {
|
|
125
|
+
if (removeResult instanceof Promise) {
|
|
126
|
+
removeResult.then(r => this.processRemoveResult(r, currentIndex));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.processRemoveResult(removeResult, currentIndex);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
processSaveResult(result) {
|
|
134
|
+
if (result) {
|
|
135
|
+
if (result instanceof Array) {
|
|
136
|
+
result.forEach(item => this.processSaveResult(item));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (result.dataUnit === this.name) {
|
|
140
|
+
result.records.forEach(savedRecord => {
|
|
141
|
+
let rID = savedRecord.oldRecord__id;
|
|
142
|
+
delete savedRecord.oldRecord__id;
|
|
143
|
+
if (rID === undefined) {
|
|
144
|
+
rID = savedRecord.record__id;
|
|
145
|
+
}
|
|
146
|
+
this.records.forEach((r, index) => {
|
|
147
|
+
if (r.record__id === rID) {
|
|
148
|
+
this.records[index] = Object.assign(r, savedRecord);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
156
|
+
this._store.dispatch(changesSaved(this.name));
|
|
157
|
+
}
|
|
158
|
+
processLoadResult(records) {
|
|
159
|
+
this.records = records;
|
|
160
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
161
|
+
this._store.dispatch(dataLoaded(this.name));
|
|
162
|
+
}
|
|
163
|
+
processRemoveResult(removed, recordIndex) {
|
|
164
|
+
if (removed) {
|
|
165
|
+
this.records.splice(recordIndex, 1);
|
|
166
|
+
this._store.dispatch(clearEdition(this.name, this.records.length - 1));
|
|
167
|
+
}
|
|
168
|
+
this._store.dispatch(recordRemoved(this.name));
|
|
169
|
+
}
|
|
170
|
+
set records(records) {
|
|
171
|
+
this._records = records;
|
|
172
|
+
}
|
|
173
|
+
get records() {
|
|
174
|
+
if (!this._records) {
|
|
175
|
+
this._records = [];
|
|
176
|
+
}
|
|
177
|
+
return this._records;
|
|
178
|
+
}
|
|
179
|
+
getCurrentRecord() {
|
|
180
|
+
const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
|
|
181
|
+
return this.records[currentIndex];
|
|
182
|
+
}
|
|
183
|
+
getRecordChanges(currentRecord = undefined) {
|
|
184
|
+
if (currentRecord === undefined) {
|
|
185
|
+
currentRecord = this.getCurrentRecord();
|
|
186
|
+
}
|
|
187
|
+
return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
|
|
188
|
+
}
|
|
189
|
+
validateRecords() {
|
|
190
|
+
if (!this.recordsValidator) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
|
|
194
|
+
const recordsToValidate = [];
|
|
195
|
+
this.records.forEach((record, i) => {
|
|
196
|
+
const changes = duChanges[record.record__id];
|
|
197
|
+
if (changes) {
|
|
198
|
+
recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
const result = this.recordsValidator.validateRecords(this, recordsToValidate);
|
|
202
|
+
if (result.message) {
|
|
203
|
+
alert(result.message);
|
|
204
|
+
}
|
|
205
|
+
return result.isValid;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class Form {
|
|
2
|
+
}
|
|
3
|
+
export class Field {
|
|
4
|
+
}
|
|
5
|
+
export class FieldSet {
|
|
6
|
+
}
|
|
7
|
+
export class UIProperty {
|
|
8
|
+
}
|
|
9
|
+
export class FieldDependency {
|
|
10
|
+
}
|
|
11
|
+
export var DependencyType;
|
|
12
|
+
(function (DependencyType) {
|
|
13
|
+
DependencyType["SEARCHING"] = "SEARCHING";
|
|
14
|
+
DependencyType["REQUIREMENT"] = "REQUIREMENT";
|
|
15
|
+
DependencyType["VISIBILITY"] = "REQUIREMENT";
|
|
16
|
+
})(DependencyType || (DependencyType = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 42px;
|
|
5
|
+
border-radius: 12px;
|
|
6
|
+
background: var(--background--medium);
|
|
7
|
+
background-image: linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);
|
|
8
|
+
background-repeat: no-repeat;
|
|
9
|
+
background-size: 800px 1000px;
|
|
10
|
+
animation-duration: 1s;
|
|
11
|
+
animation-fill-mode: forwards;
|
|
12
|
+
animation-iteration-count: infinite;
|
|
13
|
+
animation-name: placeholderShimmer;
|
|
14
|
+
animation-timing-function: linear;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes placeholderShimmer{
|
|
18
|
+
0%{
|
|
19
|
+
background-position: -800px 0;
|
|
20
|
+
}
|
|
21
|
+
100%{
|
|
22
|
+
background-position: 800px 0;
|
|
23
|
+
}
|
|
24
|
+
}
|