@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.
Files changed (186) hide show
  1. package/README.md +72 -72
  2. package/dist/{ezui/DataUnit-285bec19.js → cjs/DataUnit-28b290cb.js} +382 -369
  3. package/dist/{ezui/index-919090de.js → cjs/RequestMetadata-2cd01e8a.js} +4 -383
  4. package/dist/cjs/ez-action-chip.cjs.entry.js +52 -0
  5. package/dist/cjs/ez-button_14.cjs.entry.js +3341 -0
  6. package/dist/cjs/ez-label-chip.cjs.entry.js +131 -0
  7. package/dist/cjs/ez-modal.cjs.entry.js +115 -0
  8. package/dist/cjs/ez-number-input.cjs.entry.js +248 -0
  9. package/dist/cjs/ez-time-input.cjs.entry.js +180 -0
  10. package/dist/cjs/ezui.cjs.js +19 -0
  11. package/dist/cjs/form-metadata.cjs.entry.js +74 -0
  12. package/dist/cjs/index-9403fe8f.js +1322 -0
  13. package/dist/cjs/index.cjs.js +2 -0
  14. package/dist/cjs/loader.cjs.js +21 -0
  15. package/dist/collection/collection-manifest.json +31 -0
  16. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -0
  17. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -0
  18. package/dist/collection/components/ez-button/ez-button.css +94 -0
  19. package/dist/collection/components/ez-button/ez-button.js +125 -0
  20. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -0
  21. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -0
  22. package/dist/collection/components/ez-check/ez-check.css +266 -0
  23. package/dist/collection/components/ez-check/ez-check.js +168 -0
  24. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +68 -0
  25. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -0
  26. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -0
  27. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -0
  28. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -0
  29. package/dist/collection/components/ez-date-input/ez-date-input.css +39 -0
  30. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -0
  31. package/dist/collection/components/ez-form/ez-form.css +19 -0
  32. package/dist/collection/components/ez-form/ez-form.js +368 -0
  33. package/dist/collection/components/ez-form/store/Form.actions.js +132 -0
  34. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -0
  35. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -0
  36. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +207 -0
  37. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -0
  38. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +24 -0
  39. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -0
  40. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -0
  41. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -0
  42. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -0
  43. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -0
  44. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -0
  45. package/dist/collection/components/ez-icon/ez-icon.css +37 -0
  46. package/dist/collection/components/ez-icon/ez-icon.js +56 -0
  47. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -0
  48. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -0
  49. package/dist/collection/components/ez-modal/ez-modal.css +87 -0
  50. package/dist/collection/components/ez-modal/ez-modal.js +224 -0
  51. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -0
  52. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -0
  53. package/dist/collection/components/ez-popover/ez-popover.css +39 -0
  54. package/dist/collection/components/ez-popover/ez-popover.js +323 -0
  55. package/dist/collection/components/ez-search/ez-search.css +296 -0
  56. package/dist/{ezui/ez-search.entry.js → collection/components/ez-search/ez-search.js} +527 -334
  57. package/dist/collection/components/ez-tabselector/ez-tabselector.css +126 -0
  58. package/dist/{ezui/ez-tabselector.entry.js → collection/components/ez-tabselector/ez-tabselector.js} +283 -209
  59. package/dist/collection/components/ez-text-area/ez-text-area.css +140 -0
  60. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -0
  61. package/dist/collection/components/ez-text-input/ez-text-input.css +170 -0
  62. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -0
  63. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -0
  64. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -0
  65. package/dist/collection/index.js +1 -0
  66. package/dist/collection/servidor.js +101 -0
  67. package/dist/collection/utils/FloatingManager.js +16 -0
  68. package/dist/collection/utils/utils.js +6 -0
  69. package/dist/custom-elements/index.js +5071 -0
  70. package/dist/esm/DataUnit-69e518fa.js +378 -0
  71. package/dist/esm/RequestMetadata-c265c9d5.js +527 -0
  72. package/dist/{ezui → esm}/ez-action-chip.entry.js +42 -42
  73. package/dist/esm/ez-button_14.entry.js +3324 -0
  74. package/dist/{ezui → esm}/ez-label-chip.entry.js +121 -121
  75. package/dist/{ezui → esm}/ez-modal.entry.js +105 -96
  76. package/dist/{ezui → esm}/ez-number-input.entry.js +238 -238
  77. package/dist/{ezui → esm}/ez-time-input.entry.js +170 -170
  78. package/dist/esm/ezui.js +17 -0
  79. package/dist/{ezui → esm}/form-metadata.entry.js +66 -66
  80. package/dist/esm/index-95bb3fd9.js +1293 -0
  81. package/dist/esm/index.js +1 -0
  82. package/dist/esm/loader.js +17 -0
  83. package/dist/esm/polyfills/core-js.js +11 -0
  84. package/dist/esm/polyfills/css-shim.js +1 -0
  85. package/dist/esm/polyfills/dom.js +79 -0
  86. package/dist/esm/polyfills/es5-html-element.js +1 -0
  87. package/dist/esm/polyfills/index.js +34 -0
  88. package/dist/esm/polyfills/system.js +6 -0
  89. package/dist/ezui/ezui.esm.js +1 -122
  90. package/dist/ezui/index.esm.js +0 -1
  91. package/dist/ezui/p-10ef58b3.js +1 -0
  92. package/dist/ezui/p-185c57f4.js +1 -0
  93. package/dist/ezui/p-22b82efb.entry.js +1 -0
  94. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  95. package/dist/ezui/p-9dfccb16.js +1 -0
  96. package/dist/ezui/p-b0974f4f.entry.js +1 -0
  97. package/dist/ezui/p-db11c600.entry.js +1 -0
  98. package/dist/ezui/p-dd4331b7.entry.js +1 -0
  99. package/dist/ezui/p-f6fd31ab.entry.js +1 -0
  100. package/dist/ezui/p-fa260f22.entry.js +1 -0
  101. package/dist/index.cjs.js +1 -0
  102. package/dist/index.js +1 -0
  103. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  104. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  105. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  106. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  107. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  108. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  109. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  110. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  111. package/dist/types/components/ez-form/ez-form.d.ts +31 -27
  112. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
  113. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
  114. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
  115. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +55 -48
  116. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  117. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  118. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  119. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  120. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  121. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  122. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -7
  123. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  124. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  125. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -26
  126. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  127. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  128. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  129. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  130. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  131. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  132. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  133. package/dist/types/components.d.ts +8 -0
  134. package/dist/types/index.d.ts +1 -1
  135. package/dist/types/utils/utils.d.ts +2 -2
  136. package/loader/cdn.js +3 -0
  137. package/loader/index.cjs.js +3 -0
  138. package/loader/index.d.ts +13 -0
  139. package/loader/index.es2017.js +3 -0
  140. package/loader/index.js +4 -0
  141. package/loader/package.json +10 -0
  142. package/package.json +114 -114
  143. package/react/components.d.ts +22 -0
  144. package/react/components.js +25 -0
  145. package/react/components.js.map +1 -0
  146. package/react/react-component-lib/createComponent.d.ts +10 -0
  147. package/react/react-component-lib/createComponent.js +59 -0
  148. package/react/react-component-lib/createComponent.js.map +1 -0
  149. package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
  150. package/react/react-component-lib/createOverlayComponent.js +89 -0
  151. package/react/react-component-lib/createOverlayComponent.js.map +1 -0
  152. package/react/react-component-lib/index.d.ts +2 -0
  153. package/react/react-component-lib/index.js +3 -0
  154. package/react/react-component-lib/index.js.map +1 -0
  155. package/react/react-component-lib/interfaces.d.ts +29 -0
  156. package/react/react-component-lib/interfaces.js +1 -0
  157. package/react/react-component-lib/interfaces.js.map +1 -0
  158. package/react/react-component-lib/utils/attachProps.d.ts +12 -0
  159. package/react/react-component-lib/utils/attachProps.js +96 -0
  160. package/react/react-component-lib/utils/attachProps.js.map +1 -0
  161. package/react/react-component-lib/utils/case.d.ts +2 -0
  162. package/react/react-component-lib/utils/case.js +7 -0
  163. package/react/react-component-lib/utils/case.js.map +1 -0
  164. package/react/react-component-lib/utils/dev.d.ts +2 -0
  165. package/react/react-component-lib/utils/dev.js +13 -0
  166. package/react/react-component-lib/utils/dev.js.map +1 -0
  167. package/react/react-component-lib/utils/index.d.ts +7 -0
  168. package/react/react-component-lib/utils/index.js +21 -0
  169. package/react/react-component-lib/utils/index.js.map +1 -0
  170. package/dist/ezui/app-globals-0f993ce5.js +0 -3
  171. package/dist/ezui/css-shim-003e9264.js +0 -4
  172. package/dist/ezui/dom-1b195079.js +0 -73
  173. package/dist/ezui/ez-button.entry.js +0 -47
  174. package/dist/ezui/ez-calendar.entry.js +0 -102
  175. package/dist/ezui/ez-check.entry.js +0 -62
  176. package/dist/ezui/ez-collapsable-box.entry.js +0 -32
  177. package/dist/ezui/ez-combo-box.entry.js +0 -181
  178. package/dist/ezui/ez-date-input.entry.js +0 -77
  179. package/dist/ezui/ez-form.entry.js +0 -1907
  180. package/dist/ezui/ez-icon.entry.js +0 -17
  181. package/dist/ezui/ez-popover.entry.js +0 -112
  182. package/dist/ezui/ez-text-area.entry.js +0 -105
  183. package/dist/ezui/ez-text-input.entry.js +0 -202
  184. package/dist/ezui/index-39044be2.js +0 -2832
  185. package/dist/ezui/place-holder.entry.js +0 -15
  186. package/dist/ezui/shadow-css-c1ad5fdc.js +0 -383
@@ -1,375 +1,388 @@
1
- function changeFieldValue(dataUnit, recordId, fieldName, value) {
2
- return {
3
- type: 'FORM/CHANGEFIELD',
4
- payload: { dataUnit, recordId, fieldName, value }
5
- };
6
- }
7
- function changeTab(formId, index) {
8
- return {
9
- type: 'FORM/CHANGETAB',
10
- payload: { formId, index }
11
- };
12
- }
13
- function clearEdition(dataUnit, recordsLimit) {
14
- return {
15
- type: 'FORM/CLEAREDITION',
16
- payload: {
17
- dataUnit,
18
- recordsLimit
19
- }
20
- };
21
- }
22
- function collapseExpandGroup(collapseId, collapsed) {
23
- return {
24
- type: 'FORM/COLLAPSEGROUP',
25
- payload: { collapseId, collapsed }
26
- };
27
- }
28
- function previousRecord(dataUnit) {
29
- return {
30
- type: 'FORM/NAVIGATE',
31
- payload: {
32
- dataUnit,
33
- limit: 0,
34
- backward: true
35
- }
36
- };
37
- }
38
- function nextRecord(dataUnit, limit) {
39
- return {
40
- type: 'FORM/NAVIGATE',
41
- payload: {
42
- dataUnit,
43
- limit,
44
- backward: false
45
- }
46
- };
47
- }
48
- function insertRecord(dataUnit, insertionIndex) {
49
- return {
50
- type: 'FORM/INSERT',
51
- payload: {
52
- dataUnit,
53
- insertionIndex
54
- }
55
- };
56
- }
57
- function formLoad() {
58
- return {
59
- type: 'FORM/LOAD'
60
- };
61
- }
62
- function dataLoading(dataUnit) {
63
- return {
64
- type: 'FORM/DATALOADING',
65
- payload: {
66
- dataUnit
67
- }
68
- };
69
- }
70
- function savingChanges(dataUnit) {
71
- return {
72
- type: 'FORM/SAVINGCHANGES',
73
- payload: {
74
- dataUnit
75
- }
76
- };
77
- }
78
- function dataLoaded(dataUnit) {
79
- return {
80
- type: 'FORM/DATALOADED',
81
- payload: {
82
- dataUnit
83
- }
84
- };
85
- }
86
- function changesSaved(dataUnit) {
87
- return {
88
- type: 'FORM/CHANGESSAVED',
89
- payload: {
90
- dataUnit
91
- }
92
- };
93
- }
94
- function removingRecord(dataUnit) {
95
- return {
96
- type: 'FORM/REMOVINGRECORD',
97
- payload: {
98
- dataUnit
99
- }
100
- };
101
- }
102
- function recordRemoved(dataUnit) {
103
- return {
104
- type: 'FORM/RECORDREMOVED',
105
- payload: {
106
- dataUnit
107
- }
108
- };
109
- }
110
- 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
- };
1
+ 'use strict';
2
+
3
+ function changeFieldValue(dataUnit, recordId, fieldName, value) {
4
+ return {
5
+ type: 'FORM/CHANGEFIELD',
6
+ payload: { dataUnit, recordId, fieldName, value }
7
+ };
8
+ }
9
+ function changeTab(formId, index) {
10
+ return {
11
+ type: 'FORM/CHANGETAB',
12
+ payload: { formId, index }
13
+ };
14
+ }
15
+ function clearEdition(dataUnit, recordsLimit) {
16
+ return {
17
+ type: 'FORM/CLEAREDITION',
18
+ payload: {
19
+ dataUnit,
20
+ recordsLimit
21
+ }
22
+ };
23
+ }
24
+ function collapseExpandGroup(collapseId, collapsed) {
25
+ return {
26
+ type: 'FORM/COLLAPSEGROUP',
27
+ payload: { collapseId, collapsed }
28
+ };
29
+ }
30
+ function previousRecord(dataUnit) {
31
+ return {
32
+ type: 'FORM/NAVIGATE',
33
+ payload: {
34
+ dataUnit,
35
+ limit: 0,
36
+ backward: true
37
+ }
38
+ };
39
+ }
40
+ function nextRecord(dataUnit, limit) {
41
+ return {
42
+ type: 'FORM/NAVIGATE',
43
+ payload: {
44
+ dataUnit,
45
+ limit,
46
+ backward: false
47
+ }
48
+ };
49
+ }
50
+ function insertRecord(dataUnit, insertionIndex) {
51
+ return {
52
+ type: 'FORM/INSERT',
53
+ payload: {
54
+ dataUnit,
55
+ insertionIndex
56
+ }
57
+ };
58
+ }
59
+ function formLoad() {
60
+ return {
61
+ type: 'FORM/LOAD'
62
+ };
63
+ }
64
+ function dataLoading(dataUnit) {
65
+ return {
66
+ type: 'FORM/DATALOADING',
67
+ payload: {
68
+ dataUnit
69
+ }
70
+ };
71
+ }
72
+ function savingChanges(dataUnit) {
73
+ return {
74
+ type: 'FORM/SAVINGCHANGES',
75
+ payload: {
76
+ dataUnit
77
+ }
78
+ };
79
+ }
80
+ function dataLoaded(dataUnit) {
81
+ return {
82
+ type: 'FORM/DATALOADED',
83
+ payload: {
84
+ dataUnit
85
+ }
86
+ };
87
+ }
88
+ function changesSaved(dataUnit) {
89
+ return {
90
+ type: 'FORM/CHANGESSAVED',
91
+ payload: {
92
+ dataUnit
93
+ }
94
+ };
95
+ }
96
+ function removingRecord(dataUnit) {
97
+ return {
98
+ type: 'FORM/REMOVINGRECORD',
99
+ payload: {
100
+ dataUnit
101
+ }
102
+ };
103
+ }
104
+ function recordRemoved(dataUnit) {
105
+ return {
106
+ type: 'FORM/RECORDREMOVED',
107
+ payload: {
108
+ dataUnit
109
+ }
110
+ };
111
+ }
112
+ function invalidField(tabController, tabIndex, dataUnit, recordIndex, recordId, fieldName, errorMessage) {
113
+ return {
114
+ type: 'FORM/INVALIDFIELD',
115
+ payload: {
116
+ tabController,
117
+ tabIndex,
118
+ dataUnit,
119
+ recordId,
120
+ recordIndex,
121
+ fieldName,
122
+ errorMessage
123
+ }
124
+ };
125
+ }
126
+ function showHideNavigationButtons(buttonName, status) {
127
+ return {
128
+ type: 'FORM/SHOWHIDENAVBTN',
129
+ payload: {
130
+ buttonName,
131
+ status
132
+ }
133
+ };
123
134
  }
124
135
 
125
- //histórico
126
- const selectCurrentTab = (state, formName) => {
127
- const data = state.hist.present.currentTabIndex;
128
- return data[formName] || 0;
129
- };
130
- const selectIsCollapsedFieldSet = (state, fieldSetName) => {
131
- const data = state.hist.present.collapsedGroups;
132
- return data[fieldSetName];
133
- };
134
- const selectRecordChanges = (state, dataUnit, recordId) => {
135
- const data = selectDataUnitChanges(state, dataUnit);
136
- return data ? data[recordId] : undefined;
137
- };
138
- const selectDataUnitChanges = (state, dataUnit) => {
139
- const data = state.hist.present.changes;
140
- return data[dataUnit];
141
- };
142
- const selectCurrentRecordIndex = (state, dataUnit) => {
143
- const data = state.hist.present.currentRecordIndex;
144
- return data[dataUnit] || 0;
145
- };
146
- const selectNewRecordIndex = (state, dataUnit) => {
147
- const data = state.hist.present.newRecordIndex;
148
- return data[dataUnit] || 0;
149
- };
150
- const selectUndoState = state => { return { canUndo: state.hist.past.length > 0, canRedo: state.hist.future.length > 0 }; };
151
- //não histórico
152
- const selectLoadingData = (state, dataUnit) => {
153
- const data = state.nonhist.dataLoading;
154
- return data[dataUnit];
155
- };
156
- const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
157
- const data = state.nonhist.invalidFields;
158
- const dataUnitMessages = data[dataUnit] || {};
159
- const recordMessages = dataUnitMessages[recordId] || {};
160
- return recordMessages[fieldName] || "";
161
- };
162
- const selectInvalidFields = (state, dataUnit, recordId) => {
163
- const data = state.nonhist.invalidFields;
164
- const dataUnitMessages = data[dataUnit] || {};
165
- const recordMessages = dataUnitMessages[recordId] || {};
166
- return Object.keys(recordMessages);
136
+ //histórico
137
+ const selectCurrentTab = (state, formName) => {
138
+ const data = state.hist.present.currentTabIndex;
139
+ return data[formName] || 0;
140
+ };
141
+ const selectIsCollapsedFieldSet = (state, fieldSetName) => {
142
+ const data = state.hist.present.collapsedGroups;
143
+ return data[fieldSetName];
144
+ };
145
+ const selectRecordChanges = (state, dataUnit, recordId) => {
146
+ const data = selectDataUnitChanges(state, dataUnit);
147
+ return data ? data[recordId] : undefined;
148
+ };
149
+ const selectDataUnitChanges = (state, dataUnit) => {
150
+ const data = state.hist.present.changes;
151
+ return data[dataUnit];
152
+ };
153
+ const selectCurrentRecordIndex = (state, dataUnit) => {
154
+ const data = state.hist.present.currentRecordIndex;
155
+ return data[dataUnit] || 0;
156
+ };
157
+ const selectNewRecordIndex = (state, dataUnit) => {
158
+ const data = state.hist.present.newRecordIndex;
159
+ return data[dataUnit] || 0;
160
+ };
161
+ //não histórico
162
+ const selectLoadingData = (state, dataUnit) => {
163
+ const data = state.nonhist.dataLoading;
164
+ return data[dataUnit];
165
+ };
166
+ const selectErrorMessage = (state, dataUnit, recordId, fieldName) => {
167
+ const data = state.nonhist.invalidFields;
168
+ const dataUnitMessages = data[dataUnit] || {};
169
+ const recordMessages = dataUnitMessages[recordId] || {};
170
+ return recordMessages[fieldName] || "";
167
171
  };
172
+ const selectVisibleButtons = state => state.nonhist.visibleButtons;
168
173
 
169
- class DataUnit {
170
- constructor(name, cardinality = '1') {
171
- this.name = name;
172
- this.cardinality = cardinality;
173
- }
174
- set store(store) {
175
- this._store = store;
176
- }
177
- isLoading() {
178
- return selectLoadingData(this._store.getState(), this.name);
179
- }
180
- hasChanges() {
181
- const state = this._store.getState();
182
- return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
183
- }
184
- hasNext() {
185
- return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
186
- }
187
- hasPrevious() {
188
- return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
189
- }
190
- hasCurrentRecord() {
191
- return this.getCurrentRecord() != undefined;
192
- }
193
- previous() {
194
- this._store.dispatch(previousRecord(this.name));
195
- }
196
- next() {
197
- this._store.dispatch(nextRecord(this.name, this.records.length));
198
- }
199
- getValue(fieldName) {
200
- const currentRecord = this.getCurrentRecord();
201
- if (!currentRecord) {
202
- return undefined;
203
- }
204
- const changes = this.getRecordChanges(currentRecord);
205
- return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
206
- }
207
- getErrorMessage(fieldName) {
208
- const currentRecord = this.getCurrentRecord();
209
- if (!currentRecord) {
210
- return "";
211
- }
212
- return selectErrorMessage(this._store.getState(), this.name, currentRecord.record__id, fieldName);
213
- }
214
- changeValue(fieldName, newValue) {
215
- if (this.records.length == 0) {
216
- this.insert();
217
- }
218
- if (this._changeDeboucing) {
219
- window.clearTimeout(this._changeDeboucing);
220
- }
221
- this._changeDeboucing = window.setTimeout(() => {
222
- const currentRecord = this.getCurrentRecord();
223
- this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
224
- }, 100);
225
- }
226
- cancel() {
227
- this.records = this.records.filter(r => !r.record__id.startsWith('NEW_'));
228
- this._store.dispatch(clearEdition(this.name, this.records.length - 1));
229
- }
230
- insert() {
231
- const insertionIndex = this.records.length;
232
- const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
233
- this.records.push({ record__id: 'NEW_' + (newRecordIndex + 1) });
234
- this._store.dispatch(insertRecord(this.name, insertionIndex));
235
- }
236
- save() {
237
- if (!this.validateRecords()) {
238
- return;
239
- }
240
- this._store.dispatch(savingChanges(this.name));
241
- let saveResult;
242
- if (this.saveExecutor) {
243
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
244
- const changesByRecord = Object.keys(duChanges).map(record__id => {
245
- const record = { record__id };
246
- const recordChanges = duChanges[record__id];
247
- Object.keys(recordChanges).forEach(fieldName => { record[fieldName] = recordChanges[fieldName]; });
248
- return record;
249
- });
250
- const changesToSave = [{
251
- dataUnit: this.name,
252
- records: changesByRecord
253
- }];
254
- saveResult = this.saveExecutor(changesToSave);
255
- }
256
- if (saveResult instanceof Promise) {
257
- saveResult.then(r => this.processSaveResult(r));
258
- }
259
- else {
260
- this.processSaveResult(saveResult);
261
- }
262
- }
263
- load() {
264
- this._store.dispatch(dataLoading(this.name));
265
- let result;
266
- if (this.loadExecutor) {
267
- result = this.loadExecutor({ dataUnit: this.name });
268
- }
269
- if (result instanceof Promise) {
270
- result.then(r => this.processLoadResult(r));
271
- }
272
- else {
273
- this.processLoadResult(result);
274
- }
275
- }
276
- remove() {
277
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
278
- this._store.dispatch(removingRecord(this.name));
279
- let removeResult;
280
- if (this.removeExecutor) {
281
- const record = this.getCurrentRecord();
282
- removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
283
- }
284
- else {
285
- removeResult = true;
286
- }
287
- if (removeResult) {
288
- if (removeResult instanceof Promise) {
289
- removeResult.then(r => this.processRemoveResult(r, currentIndex));
290
- }
291
- else {
292
- this.processRemoveResult(removeResult, currentIndex);
293
- }
294
- }
295
- }
296
- processSaveResult(result) {
297
- if (result) {
298
- if (result instanceof Array) {
299
- result.forEach(item => this.processSaveResult(item));
300
- }
301
- else {
302
- if (result.dataUnit === this.name) {
303
- result.records.forEach(savedRecord => {
304
- let rID = savedRecord.oldRecord__id;
305
- delete savedRecord.oldRecord__id;
306
- if (rID === undefined) {
307
- rID = savedRecord.record__id;
308
- }
309
- this.records.forEach((r, index) => {
310
- if (r.record__id === rID) {
311
- this.records[index] = Object.assign(r, savedRecord);
312
- }
313
- });
314
- });
315
- }
316
- }
317
- }
318
- this._store.dispatch(clearEdition(this.name, this.records.length - 1));
319
- this._store.dispatch(changesSaved(this.name));
320
- }
321
- processLoadResult(records) {
322
- this.records = records;
323
- this._store.dispatch(clearEdition(this.name, this.records.length - 1));
324
- this._store.dispatch(dataLoaded(this.name));
325
- }
326
- processRemoveResult(removed, recordIndex) {
327
- if (removed) {
328
- this.records.splice(recordIndex, 1);
329
- this._store.dispatch(clearEdition(this.name, this.records.length - 1));
330
- }
331
- this._store.dispatch(recordRemoved(this.name));
332
- }
333
- set records(records) {
334
- this._records = records;
335
- }
336
- get records() {
337
- if (!this._records) {
338
- this._records = [];
339
- }
340
- return this._records;
341
- }
342
- getCurrentRecord() {
343
- const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
344
- return this.records[currentIndex];
345
- }
346
- getRecordChanges(currentRecord = undefined) {
347
- if (currentRecord === undefined) {
348
- currentRecord = this.getCurrentRecord();
349
- }
350
- return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
351
- }
352
- validateRecords() {
353
- if (!this.recordsValidator) {
354
- return true;
355
- }
356
- const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
357
- const recordsToValidate = [];
358
- this.records.forEach((record, i) => {
359
- const changes = duChanges[record.record__id];
360
- if (changes) {
361
- recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
362
- }
363
- });
364
- if (recordsToValidate.length == 0) {
365
- return true;
366
- }
367
- const result = this.recordsValidator.validateRecords(this, recordsToValidate);
368
- if (result.message) {
369
- alert(result.message);
370
- }
371
- return result.isValid;
372
- }
174
+ class DataUnit {
175
+ constructor(name, unitLabel, cardinality = '1') {
176
+ this.name = name;
177
+ this.unitLabel = unitLabel;
178
+ this.cardinality = cardinality;
179
+ }
180
+ set store(store) {
181
+ this._store = store;
182
+ }
183
+ isLoading() {
184
+ return selectLoadingData(this._store.getState(), this.name);
185
+ }
186
+ hasChanges() {
187
+ const state = this._store.getState();
188
+ return selectDataUnitChanges(state, this.name) !== undefined || selectNewRecordIndex(state, this.name) > 0;
189
+ }
190
+ hasNext() {
191
+ return selectCurrentRecordIndex(this._store.getState(), this.name) < (this.records.length - 1);
192
+ }
193
+ hasPrevious() {
194
+ return selectCurrentRecordIndex(this._store.getState(), this.name) > 0;
195
+ }
196
+ hasCurrentRecord() {
197
+ return this.getCurrentRecord() != undefined;
198
+ }
199
+ previous() {
200
+ this._store.dispatch(previousRecord(this.name));
201
+ }
202
+ next() {
203
+ this._store.dispatch(nextRecord(this.name, this.records.length));
204
+ }
205
+ getValue(fieldName) {
206
+ const currentRecord = this.getCurrentRecord();
207
+ if (!currentRecord) {
208
+ return undefined;
209
+ }
210
+ const changes = this.getRecordChanges(currentRecord);
211
+ return changes && changes[fieldName] !== undefined ? changes[fieldName] : currentRecord[fieldName] || null;
212
+ }
213
+ getErrorMessage(fieldName) {
214
+ const currentRecord = this.getCurrentRecord();
215
+ return selectErrorMessage(this._store.getState(), this.name, currentRecord === null || currentRecord === void 0 ? void 0 : currentRecord.record__id, fieldName);
216
+ }
217
+ changeValue(fieldName, newValue) {
218
+ if (this.records.length == 0) {
219
+ this.insert();
220
+ }
221
+ if (this._changeDeboucing) {
222
+ window.clearTimeout(this._changeDeboucing);
223
+ }
224
+ this._changeDeboucing = window.setTimeout(() => {
225
+ const currentRecord = this.getCurrentRecord();
226
+ this._store.dispatch(changeFieldValue(this.name, currentRecord.record__id, fieldName, newValue));
227
+ }, 100);
228
+ }
229
+ cancel() {
230
+ this.records = this.records.filter(r => !r.record__id.startsWith('NEW_'));
231
+ this._store.dispatch(clearEdition(this.name, this.records.length - 1));
232
+ }
233
+ insert() {
234
+ const insertionIndex = this.records.length;
235
+ const newRecordIndex = selectNewRecordIndex(this._store.getState(), this.name);
236
+ this.records.push({ record__id: 'NEW_' + (newRecordIndex + 1) });
237
+ this._store.dispatch(insertRecord(this.name, insertionIndex));
238
+ }
239
+ getChangesToSave() {
240
+ const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
241
+ if (duChanges) {
242
+ const changesByRecord = Object.keys(duChanges).map(record__id => {
243
+ const record = { record__id };
244
+ const recordChanges = duChanges[record__id];
245
+ Object.keys(recordChanges).forEach(fieldName => { record[fieldName] = recordChanges[fieldName]; });
246
+ return record;
247
+ });
248
+ return [{
249
+ dataUnit: this.name,
250
+ records: changesByRecord
251
+ }];
252
+ }
253
+ return undefined;
254
+ }
255
+ save() {
256
+ if (!this.validateRecords()) {
257
+ return;
258
+ }
259
+ this._store.dispatch(savingChanges(this.name));
260
+ let saveResult;
261
+ if (this.saveExecutor) {
262
+ saveResult = this.saveExecutor(this.getChangesToSave());
263
+ }
264
+ if (saveResult instanceof Promise) {
265
+ saveResult.then(r => this.processSaveResult(r));
266
+ }
267
+ else {
268
+ this.processSaveResult(saveResult);
269
+ }
270
+ }
271
+ load() {
272
+ this._store.dispatch(dataLoading(this.name));
273
+ let result;
274
+ if (this.loadExecutor) {
275
+ result = this.loadExecutor({ dataUnit: this.name });
276
+ }
277
+ if (result instanceof Promise) {
278
+ result.then(r => this.processLoadResult(r));
279
+ }
280
+ else {
281
+ this.processLoadResult(result);
282
+ }
283
+ }
284
+ remove() {
285
+ const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
286
+ this._store.dispatch(removingRecord(this.name));
287
+ let removeResult;
288
+ if (this.removeExecutor) {
289
+ const record = this.getCurrentRecord();
290
+ removeResult = this.removeExecutor({ dataUnit: this.name, recordId: record.record__id, record });
291
+ }
292
+ else {
293
+ removeResult = true;
294
+ }
295
+ if (removeResult) {
296
+ if (removeResult instanceof Promise) {
297
+ removeResult.then(r => this.processRemoveResult(r, currentIndex));
298
+ }
299
+ else {
300
+ this.processRemoveResult(removeResult, currentIndex);
301
+ }
302
+ }
303
+ }
304
+ processSaveResult(result) {
305
+ if (result) {
306
+ if (result instanceof Array) {
307
+ result.forEach(item => this.processSaveResult(item));
308
+ }
309
+ else {
310
+ if (result.dataUnit === this.name) {
311
+ result.records.forEach(savedRecord => {
312
+ let rID = savedRecord.oldRecord__id;
313
+ delete savedRecord.oldRecord__id;
314
+ if (rID === undefined) {
315
+ rID = savedRecord.record__id;
316
+ }
317
+ this.records.forEach((r, index) => {
318
+ if (r.record__id === rID) {
319
+ this.records[index] = Object.assign(r, savedRecord);
320
+ }
321
+ });
322
+ });
323
+ }
324
+ }
325
+ }
326
+ this._store.dispatch(clearEdition(this.name, this.records.length - 1));
327
+ this._store.dispatch(changesSaved(this.name));
328
+ }
329
+ processLoadResult(records) {
330
+ this.records = records;
331
+ this._store.dispatch(clearEdition(this.name, this.records.length - 1));
332
+ this._store.dispatch(dataLoaded(this.name));
333
+ }
334
+ processRemoveResult(removed, recordIndex) {
335
+ if (removed) {
336
+ this.records.splice(recordIndex, 1);
337
+ this._store.dispatch(clearEdition(this.name, this.records.length - 1));
338
+ }
339
+ this._store.dispatch(recordRemoved(this.name));
340
+ }
341
+ set records(records) {
342
+ this._records = records;
343
+ }
344
+ get records() {
345
+ if (!this._records) {
346
+ this._records = [];
347
+ }
348
+ return this._records;
349
+ }
350
+ getCurrentRecord() {
351
+ const currentIndex = selectCurrentRecordIndex(this._store.getState(), this.name);
352
+ return this.records[currentIndex];
353
+ }
354
+ getRecordChanges(currentRecord = undefined) {
355
+ if (currentRecord === undefined) {
356
+ currentRecord = this.getCurrentRecord();
357
+ }
358
+ return currentRecord ? selectRecordChanges(this._store.getState(), this.name, currentRecord.record__id) : undefined;
359
+ }
360
+ validateRecords() {
361
+ if (!this.recordsValidator) {
362
+ return true;
363
+ }
364
+ const duChanges = selectDataUnitChanges(this._store.getState(), this.name);
365
+ const recordsToValidate = [];
366
+ this.records.forEach((record, i) => {
367
+ const changes = duChanges[record.record__id];
368
+ if (changes) {
369
+ recordsToValidate.push(Object.assign(Object.assign(Object.assign({}, record), changes), { record__index: i, record__changedfields: Object.keys(changes) }));
370
+ }
371
+ });
372
+ const result = this.recordsValidator.validateRecords(this, recordsToValidate);
373
+ if (result.message) {
374
+ alert(result.message);
375
+ }
376
+ return result.isValid;
377
+ }
373
378
  }
374
379
 
375
- export { DataUnit as D, selectCurrentTab as a, changeTab as b, collapseExpandGroup as c, formLoad as f, invalidField as i, selectIsCollapsedFieldSet as s };
380
+ exports.DataUnit = DataUnit;
381
+ exports.changeTab = changeTab;
382
+ exports.collapseExpandGroup = collapseExpandGroup;
383
+ exports.formLoad = formLoad;
384
+ exports.invalidField = invalidField;
385
+ exports.selectCurrentTab = selectCurrentTab;
386
+ exports.selectIsCollapsedFieldSet = selectIsCollapsedFieldSet;
387
+ exports.selectVisibleButtons = selectVisibleButtons;
388
+ exports.showHideNavigationButtons = showHideNavigationButtons;