@sankhyalabs/ezui 1.1.75 → 1.1.78

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 (195) hide show
  1. package/dist/cjs/ApplicationUtils-d1c1db56.js +35 -0
  2. package/dist/cjs/AssetsUtils-dd585fba.js +24 -0
  3. package/dist/cjs/CSSVarsUtils-66e86394.js +18 -0
  4. package/dist/cjs/DataUnit-fdd7c70e.js +474 -0
  5. package/dist/cjs/DateUtils-716769e0.js +46 -0
  6. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  7. package/dist/cjs/ez-application.cjs.entry.js +26 -0
  8. package/dist/cjs/ez-button_11.cjs.entry.js +111771 -0
  9. package/dist/cjs/ez-calendar.cjs.entry.js +217 -0
  10. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +634 -0
  11. package/dist/cjs/ez-combo-box.cjs.entry.js +254 -0
  12. package/dist/cjs/ez-date-time-input.cjs.entry.js +133 -0
  13. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  14. package/dist/cjs/ez-form.cjs.entry.js +1838 -0
  15. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  16. package/dist/cjs/ez-number-input.cjs.entry.js +36 -212
  17. package/dist/cjs/ez-popover.cjs.entry.js +3 -3
  18. package/dist/cjs/ez-popup.cjs.entry.js +2 -2
  19. package/dist/cjs/ez-time-input.cjs.entry.js +10 -9
  20. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  21. package/dist/cjs/ezui.cjs.js +3 -3
  22. package/dist/cjs/form-metadata.cjs.entry.js +129 -0
  23. package/dist/cjs/index-40ebb2be.js +7422 -0
  24. package/dist/cjs/{index-4d2896bb.js → index-4e4bae01.js} +3 -5
  25. package/dist/cjs/loader.cjs.js +3 -3
  26. package/dist/collection/collection-manifest.json +8 -3
  27. package/dist/collection/components/ez-application/ez-application.css +3 -0
  28. package/dist/collection/components/ez-application/ez-application.js +35 -0
  29. package/dist/collection/components/ez-button/ez-button.css +78 -44
  30. package/dist/collection/components/ez-button/ez-button.js +36 -4
  31. package/dist/collection/components/ez-calendar/ez-calendar.css +70 -3
  32. package/dist/collection/components/ez-calendar/ez-calendar.js +173 -24
  33. package/dist/collection/components/ez-check/ez-check.css +78 -78
  34. package/dist/collection/components/ez-check/ez-check.js +3 -3
  35. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +34 -34
  36. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +12 -12
  37. package/dist/collection/components/ez-combo-box/ez-combo-box.css +65 -54
  38. package/dist/collection/components/ez-combo-box/ez-combo-box.js +5 -0
  39. package/dist/collection/components/ez-date-input/ez-date-input.css +17 -3
  40. package/dist/collection/components/ez-date-input/ez-date-input.js +3 -3
  41. package/dist/collection/components/ez-date-time-input/ez-date-time-input.css +44 -0
  42. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +243 -0
  43. package/dist/collection/components/ez-form/ez-form.js +37 -35
  44. package/dist/collection/components/ez-form/store/Form.actions.js +16 -16
  45. package/dist/collection/components/ez-form/store/Form.reducer.js +17 -17
  46. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +11 -11
  47. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +12 -12
  48. package/dist/collection/components/ez-form/subcomponents/place-holder.js +1 -1
  49. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +21 -21
  50. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +1 -1
  51. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +9 -9
  52. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +21 -0
  53. package/dist/collection/components/ez-grid/controller/EzGridController.js +1 -0
  54. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +203 -0
  55. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +41 -0
  56. package/dist/collection/components/ez-grid/controller/ag-grid/i18n/pt-BR.js +75 -0
  57. package/dist/collection/components/ez-grid/controller/ag-grid/mock/Server.js +69 -0
  58. package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +12 -0
  59. package/dist/collection/components/ez-grid/ez-grid.css +15 -0
  60. package/dist/collection/components/ez-grid/ez-grid.js +414 -0
  61. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +105 -0
  62. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +354 -0
  63. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +7 -0
  64. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.js +66 -0
  65. package/dist/collection/components/ez-icon/ez-icon.css +1 -1
  66. package/dist/collection/components/ez-list/ez-list.css +227 -44
  67. package/dist/collection/components/ez-list/ez-list.js +529 -149
  68. package/dist/collection/components/ez-modal/ez-modal.css +4 -4
  69. package/dist/collection/components/ez-modal/ez-modal.js +1 -1
  70. package/dist/collection/components/ez-number-input/ez-number-input.css +1 -165
  71. package/dist/collection/components/ez-number-input/ez-number-input.js +53 -339
  72. package/dist/collection/components/ez-popover/ez-popover.css +10 -6
  73. package/dist/collection/components/ez-popup/ez-popup.css +25 -27
  74. package/dist/collection/components/ez-search/ez-search.js +6 -1
  75. package/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -1
  76. package/dist/collection/components/ez-tabselector/ez-tabselector.js +3 -3
  77. package/dist/collection/components/ez-text-area/ez-text-area.js +1 -0
  78. package/dist/collection/components/ez-text-input/ez-text-input.css +60 -60
  79. package/dist/collection/components/ez-text-input/ez-text-input.js +17 -16
  80. package/dist/collection/components/ez-time-input/ez-time-input.js +3 -2
  81. package/dist/collection/components/ez-upload/ez-upload.js +3 -3
  82. package/dist/collection/components/test-du/test-du.css +3 -0
  83. package/dist/collection/components/test-du/test-du.js +45 -0
  84. package/dist/collection/servidor.js +94 -94
  85. package/dist/collection/utils/{Application.js → ApplicationUtils.js} +4 -4
  86. package/dist/collection/utils/AssetsUtils.js +19 -0
  87. package/dist/collection/utils/CSSVarsUtils.js +6 -6
  88. package/dist/custom-elements/index.d.ts +36 -6
  89. package/dist/custom-elements/index.js +120886 -2964
  90. package/dist/esm/ApplicationUtils-01280a9d.js +33 -0
  91. package/dist/esm/AssetsUtils-3803e935.js +22 -0
  92. package/dist/esm/CSSVarsUtils-aeee9825.js +16 -0
  93. package/dist/esm/DataUnit-1cd45202.js +464 -0
  94. package/dist/esm/DateUtils-0a1bbd7a.js +44 -0
  95. package/dist/esm/ez-action-chip.entry.js +1 -1
  96. package/dist/esm/ez-application.entry.js +22 -0
  97. package/dist/esm/ez-button_11.entry.js +111757 -0
  98. package/dist/esm/ez-calendar.entry.js +213 -0
  99. package/dist/esm/ez-collapsible-box_6.entry.js +625 -0
  100. package/dist/esm/ez-combo-box.entry.js +250 -0
  101. package/dist/esm/ez-date-time-input.entry.js +129 -0
  102. package/dist/esm/ez-dialog.entry.js +1 -1
  103. package/dist/esm/ez-form.entry.js +1834 -0
  104. package/dist/esm/ez-label-chip.entry.js +1 -1
  105. package/dist/esm/ez-number-input.entry.js +36 -212
  106. package/dist/esm/ez-popover.entry.js +3 -3
  107. package/dist/esm/ez-popup.entry.js +2 -2
  108. package/dist/esm/ez-time-input.entry.js +5 -4
  109. package/dist/esm/ez-toast.entry.js +1 -1
  110. package/dist/esm/ezui.js +3 -3
  111. package/dist/esm/form-metadata.entry.js +125 -0
  112. package/dist/esm/{index-33153059.js → index-1dacecd3.js} +3 -6
  113. package/dist/esm/index-ca8700cb.js +7414 -0
  114. package/dist/esm/loader.js +3 -3
  115. package/dist/ezui/ezui.esm.js +1 -1
  116. package/dist/ezui/p-14bee38e.entry.js +1 -0
  117. package/dist/ezui/p-37a611ea.js +1 -0
  118. package/dist/ezui/p-3a09c678.entry.js +1 -0
  119. package/dist/ezui/p-43c15c94.entry.js +1 -0
  120. package/dist/ezui/{p-34d288d0.entry.js → p-516d0e0f.entry.js} +1 -1
  121. package/dist/ezui/{p-0d476efb.entry.js → p-5a86e18a.entry.js} +1 -1
  122. package/dist/ezui/{p-47406a6e.entry.js → p-5da66d3e.entry.js} +1 -1
  123. package/dist/ezui/p-7107d7ef.js +1 -0
  124. package/dist/ezui/p-72ff3c95.entry.js +1 -0
  125. package/dist/ezui/p-74f978db.entry.js +369 -0
  126. package/dist/ezui/p-88f45a83.entry.js +1 -0
  127. package/dist/ezui/p-8b099482.js +1 -0
  128. package/dist/ezui/p-8d6cdd3e.entry.js +1 -0
  129. package/dist/ezui/p-8f4851a6.js +1 -0
  130. package/dist/ezui/p-9dfd537e.js +1 -0
  131. package/dist/ezui/p-a0331955.entry.js +1 -0
  132. package/dist/ezui/p-a15093e3.entry.js +1 -0
  133. package/dist/ezui/{p-8818da66.entry.js → p-a18a2d7b.entry.js} +1 -1
  134. package/dist/ezui/p-a19f2af3.entry.js +1 -0
  135. package/dist/ezui/p-c6d469fc.entry.js +1 -0
  136. package/dist/ezui/p-c89629eb.js +1 -0
  137. package/dist/ezui/p-da929c01.js +1 -0
  138. package/dist/ezui/p-f3c5f27e.entry.js +1 -0
  139. package/dist/types/components/ez-application/ez-application.d.ts +10 -0
  140. package/dist/types/components/ez-button/ez-button.d.ts +5 -0
  141. package/dist/types/components/ez-calendar/ez-calendar.d.ts +21 -0
  142. package/dist/types/components/ez-check/ez-check.d.ts +1 -1
  143. package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +3 -3
  144. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +1 -0
  145. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +42 -0
  146. package/dist/types/components/ez-form/ez-form.d.ts +9 -9
  147. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +1 -1
  148. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +1 -1
  149. package/dist/types/components/ez-grid/controller/DataUnitBridge.d.ts +8 -0
  150. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +195 -0
  151. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +34 -0
  152. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +11 -0
  153. package/dist/types/components/ez-grid/controller/ag-grid/i18n/pt-BR.d.ts +2 -0
  154. package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +8 -0
  155. package/dist/types/components/ez-grid/ez-grid.d.ts +78 -0
  156. package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +30 -0
  157. package/dist/types/components/ez-grid/subcomponents/select-box/select-box.d.ts +9 -0
  158. package/dist/types/components/ez-list/ez-list.d.ts +70 -17
  159. package/dist/types/components/ez-number-input/ez-number-input.d.ts +29 -63
  160. package/dist/types/components/ez-search/ez-search.d.ts +2 -0
  161. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +1 -1
  162. package/dist/types/components/ez-text-input/ez-text-input.d.ts +1 -1
  163. package/dist/types/components/test-du/test-du.d.ts +6 -0
  164. package/dist/types/components.d.ts +289 -139
  165. package/dist/types/stencil-public-runtime.d.ts +6 -4
  166. package/dist/types/utils/{Application.d.ts → ApplicationUtils.d.ts} +1 -1
  167. package/dist/types/utils/AssetsUtils.d.ts +1 -0
  168. package/dist/types/utils/CSSVarsUtils.d.ts +1 -1
  169. package/package.json +10 -8
  170. package/react/components.d.ts +6 -1
  171. package/react/components.js +6 -1
  172. package/react/components.js.map +1 -1
  173. package/dist/cjs/CSSVarsUtils-f8827674.js +0 -18
  174. package/dist/cjs/RequestMetadata-2cd01e8a.js +0 -531
  175. package/dist/cjs/ez-button_16.cjs.entry.js +0 -4071
  176. package/dist/cjs/ez-list.cjs.entry.js +0 -174
  177. package/dist/cjs/ez-modal.cjs.entry.js +0 -65
  178. package/dist/collection/components/ez-numeric-input/ez-numeric-input.css +0 -13
  179. package/dist/collection/components/ez-numeric-input/ez-numeric-input.js +0 -185
  180. package/dist/esm/CSSVarsUtils-e0128b01.js +0 -16
  181. package/dist/esm/RequestMetadata-c265c9d5.js +0 -527
  182. package/dist/esm/ez-button_16.entry.js +0 -4052
  183. package/dist/esm/ez-list.entry.js +0 -170
  184. package/dist/esm/ez-modal.entry.js +0 -61
  185. package/dist/ezui/p-061d21ba.entry.js +0 -1
  186. package/dist/ezui/p-15743b09.entry.js +0 -1
  187. package/dist/ezui/p-46d07e59.entry.js +0 -1
  188. package/dist/ezui/p-4df6f855.js +0 -1
  189. package/dist/ezui/p-50464bdf.entry.js +0 -1
  190. package/dist/ezui/p-67410dfa.entry.js +0 -1
  191. package/dist/ezui/p-7be54779.entry.js +0 -1
  192. package/dist/ezui/p-7f3bc6d9.entry.js +0 -1
  193. package/dist/ezui/p-9dfccb16.js +0 -1
  194. package/dist/ezui/p-d1889704.js +0 -1
  195. package/dist/types/components/ez-numeric-input/ez-numeric-input.d.ts +0 -45
@@ -0,0 +1,1834 @@
1
+ import { h, r as registerInstance, f as forceUpdate, g as getElement } from './index-1dacecd3.js';
2
+ import { D as DependencyType, s as selectIsCollapsedFieldSet, c as collapseExpandGroup, a as selectCurrentTab, b as selectVisibleButtons, d as changeTab$1, f as formLoad, e as showHideNavigationButtons, g as DataUnit, i as invalidField$1 } from './DataUnit-1cd45202.js';
3
+ import { c as createCommonjsModule, g as getDefaultExportFromCjs } from './index-ca8700cb.js';
4
+ import { A as ApplicationUtils } from './ApplicationUtils-01280a9d.js';
5
+ import { D as DateUtils } from './DateUtils-0a1bbd7a.js';
6
+
7
+ function _defineProperty(obj, key, value) {
8
+ if (key in obj) {
9
+ Object.defineProperty(obj, key, {
10
+ value: value,
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ } else {
16
+ obj[key] = value;
17
+ }
18
+
19
+ return obj;
20
+ }
21
+
22
+ function ownKeys(object, enumerableOnly) {
23
+ var keys = Object.keys(object);
24
+
25
+ if (Object.getOwnPropertySymbols) {
26
+ var symbols = Object.getOwnPropertySymbols(object);
27
+
28
+ if (enumerableOnly) {
29
+ symbols = symbols.filter(function (sym) {
30
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
31
+ });
32
+ }
33
+
34
+ keys.push.apply(keys, symbols);
35
+ }
36
+
37
+ return keys;
38
+ }
39
+
40
+ function _objectSpread2(target) {
41
+ for (var i = 1; i < arguments.length; i++) {
42
+ var source = arguments[i] != null ? arguments[i] : {};
43
+
44
+ if (i % 2) {
45
+ ownKeys(Object(source), true).forEach(function (key) {
46
+ _defineProperty(target, key, source[key]);
47
+ });
48
+ } else if (Object.getOwnPropertyDescriptors) {
49
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
50
+ } else {
51
+ ownKeys(Object(source)).forEach(function (key) {
52
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
53
+ });
54
+ }
55
+ }
56
+
57
+ return target;
58
+ }
59
+
60
+ /**
61
+ * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
62
+ *
63
+ * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
64
+ * during build.
65
+ * @param {number} code
66
+ */
67
+ function formatProdErrorMessage(code) {
68
+ return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
69
+ }
70
+
71
+ // Inlined version of the `symbol-observable` polyfill
72
+ var $$observable = (function () {
73
+ return typeof Symbol === 'function' && Symbol.observable || '@@observable';
74
+ })();
75
+
76
+ /**
77
+ * These are private action types reserved by Redux.
78
+ * For any unknown actions, you must return the current state.
79
+ * If the current state is undefined, you must return the initial state.
80
+ * Do not reference these action types directly in your code.
81
+ */
82
+ var randomString = function randomString() {
83
+ return Math.random().toString(36).substring(7).split('').join('.');
84
+ };
85
+
86
+ var ActionTypes = {
87
+ INIT: "@@redux/INIT" + randomString(),
88
+ REPLACE: "@@redux/REPLACE" + randomString(),
89
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
90
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
91
+ }
92
+ };
93
+
94
+ /**
95
+ * @param {any} obj The object to inspect.
96
+ * @returns {boolean} True if the argument appears to be a plain object.
97
+ */
98
+ function isPlainObject(obj) {
99
+ if (typeof obj !== 'object' || obj === null) return false;
100
+ var proto = obj;
101
+
102
+ while (Object.getPrototypeOf(proto) !== null) {
103
+ proto = Object.getPrototypeOf(proto);
104
+ }
105
+
106
+ return Object.getPrototypeOf(obj) === proto;
107
+ }
108
+
109
+ /**
110
+ * Creates a Redux store that holds the state tree.
111
+ * The only way to change the data in the store is to call `dispatch()` on it.
112
+ *
113
+ * There should only be a single store in your app. To specify how different
114
+ * parts of the state tree respond to actions, you may combine several reducers
115
+ * into a single reducer function by using `combineReducers`.
116
+ *
117
+ * @param {Function} reducer A function that returns the next state tree, given
118
+ * the current state tree and the action to handle.
119
+ *
120
+ * @param {any} [preloadedState] The initial state. You may optionally specify it
121
+ * to hydrate the state from the server in universal apps, or to restore a
122
+ * previously serialized user session.
123
+ * If you use `combineReducers` to produce the root reducer function, this must be
124
+ * an object with the same shape as `combineReducers` keys.
125
+ *
126
+ * @param {Function} [enhancer] The store enhancer. You may optionally specify it
127
+ * to enhance the store with third-party capabilities such as middleware,
128
+ * time travel, persistence, etc. The only store enhancer that ships with Redux
129
+ * is `applyMiddleware()`.
130
+ *
131
+ * @returns {Store} A Redux store that lets you read the state, dispatch actions
132
+ * and subscribe to changes.
133
+ */
134
+
135
+ function createStore(reducer, preloadedState, enhancer) {
136
+ var _ref2;
137
+
138
+ if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
139
+ throw new Error(formatProdErrorMessage(0) );
140
+ }
141
+
142
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
143
+ enhancer = preloadedState;
144
+ preloadedState = undefined;
145
+ }
146
+
147
+ if (typeof enhancer !== 'undefined') {
148
+ if (typeof enhancer !== 'function') {
149
+ throw new Error(formatProdErrorMessage(1) );
150
+ }
151
+
152
+ return enhancer(createStore)(reducer, preloadedState);
153
+ }
154
+
155
+ if (typeof reducer !== 'function') {
156
+ throw new Error(formatProdErrorMessage(2) );
157
+ }
158
+
159
+ var currentReducer = reducer;
160
+ var currentState = preloadedState;
161
+ var currentListeners = [];
162
+ var nextListeners = currentListeners;
163
+ var isDispatching = false;
164
+ /**
165
+ * This makes a shallow copy of currentListeners so we can use
166
+ * nextListeners as a temporary list while dispatching.
167
+ *
168
+ * This prevents any bugs around consumers calling
169
+ * subscribe/unsubscribe in the middle of a dispatch.
170
+ */
171
+
172
+ function ensureCanMutateNextListeners() {
173
+ if (nextListeners === currentListeners) {
174
+ nextListeners = currentListeners.slice();
175
+ }
176
+ }
177
+ /**
178
+ * Reads the state tree managed by the store.
179
+ *
180
+ * @returns {any} The current state tree of your application.
181
+ */
182
+
183
+
184
+ function getState() {
185
+ if (isDispatching) {
186
+ throw new Error(formatProdErrorMessage(3) );
187
+ }
188
+
189
+ return currentState;
190
+ }
191
+ /**
192
+ * Adds a change listener. It will be called any time an action is dispatched,
193
+ * and some part of the state tree may potentially have changed. You may then
194
+ * call `getState()` to read the current state tree inside the callback.
195
+ *
196
+ * You may call `dispatch()` from a change listener, with the following
197
+ * caveats:
198
+ *
199
+ * 1. The subscriptions are snapshotted just before every `dispatch()` call.
200
+ * If you subscribe or unsubscribe while the listeners are being invoked, this
201
+ * will not have any effect on the `dispatch()` that is currently in progress.
202
+ * However, the next `dispatch()` call, whether nested or not, will use a more
203
+ * recent snapshot of the subscription list.
204
+ *
205
+ * 2. The listener should not expect to see all state changes, as the state
206
+ * might have been updated multiple times during a nested `dispatch()` before
207
+ * the listener is called. It is, however, guaranteed that all subscribers
208
+ * registered before the `dispatch()` started will be called with the latest
209
+ * state by the time it exits.
210
+ *
211
+ * @param {Function} listener A callback to be invoked on every dispatch.
212
+ * @returns {Function} A function to remove this change listener.
213
+ */
214
+
215
+
216
+ function subscribe(listener) {
217
+ if (typeof listener !== 'function') {
218
+ throw new Error(formatProdErrorMessage(4) );
219
+ }
220
+
221
+ if (isDispatching) {
222
+ throw new Error(formatProdErrorMessage(5) );
223
+ }
224
+
225
+ var isSubscribed = true;
226
+ ensureCanMutateNextListeners();
227
+ nextListeners.push(listener);
228
+ return function unsubscribe() {
229
+ if (!isSubscribed) {
230
+ return;
231
+ }
232
+
233
+ if (isDispatching) {
234
+ throw new Error(formatProdErrorMessage(6) );
235
+ }
236
+
237
+ isSubscribed = false;
238
+ ensureCanMutateNextListeners();
239
+ var index = nextListeners.indexOf(listener);
240
+ nextListeners.splice(index, 1);
241
+ currentListeners = null;
242
+ };
243
+ }
244
+ /**
245
+ * Dispatches an action. It is the only way to trigger a state change.
246
+ *
247
+ * The `reducer` function, used to create the store, will be called with the
248
+ * current state tree and the given `action`. Its return value will
249
+ * be considered the **next** state of the tree, and the change listeners
250
+ * will be notified.
251
+ *
252
+ * The base implementation only supports plain object actions. If you want to
253
+ * dispatch a Promise, an Observable, a thunk, or something else, you need to
254
+ * wrap your store creating function into the corresponding middleware. For
255
+ * example, see the documentation for the `redux-thunk` package. Even the
256
+ * middleware will eventually dispatch plain object actions using this method.
257
+ *
258
+ * @param {Object} action A plain object representing “what changed”. It is
259
+ * a good idea to keep actions serializable so you can record and replay user
260
+ * sessions, or use the time travelling `redux-devtools`. An action must have
261
+ * a `type` property which may not be `undefined`. It is a good idea to use
262
+ * string constants for action types.
263
+ *
264
+ * @returns {Object} For convenience, the same action object you dispatched.
265
+ *
266
+ * Note that, if you use a custom middleware, it may wrap `dispatch()` to
267
+ * return something else (for example, a Promise you can await).
268
+ */
269
+
270
+
271
+ function dispatch(action) {
272
+ if (!isPlainObject(action)) {
273
+ throw new Error(formatProdErrorMessage(7) );
274
+ }
275
+
276
+ if (typeof action.type === 'undefined') {
277
+ throw new Error(formatProdErrorMessage(8) );
278
+ }
279
+
280
+ if (isDispatching) {
281
+ throw new Error(formatProdErrorMessage(9) );
282
+ }
283
+
284
+ try {
285
+ isDispatching = true;
286
+ currentState = currentReducer(currentState, action);
287
+ } finally {
288
+ isDispatching = false;
289
+ }
290
+
291
+ var listeners = currentListeners = nextListeners;
292
+
293
+ for (var i = 0; i < listeners.length; i++) {
294
+ var listener = listeners[i];
295
+ listener();
296
+ }
297
+
298
+ return action;
299
+ }
300
+ /**
301
+ * Replaces the reducer currently used by the store to calculate the state.
302
+ *
303
+ * You might need this if your app implements code splitting and you want to
304
+ * load some of the reducers dynamically. You might also need this if you
305
+ * implement a hot reloading mechanism for Redux.
306
+ *
307
+ * @param {Function} nextReducer The reducer for the store to use instead.
308
+ * @returns {void}
309
+ */
310
+
311
+
312
+ function replaceReducer(nextReducer) {
313
+ if (typeof nextReducer !== 'function') {
314
+ throw new Error(formatProdErrorMessage(10) );
315
+ }
316
+
317
+ currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
318
+ // Any reducers that existed in both the new and old rootReducer
319
+ // will receive the previous state. This effectively populates
320
+ // the new state tree with any relevant data from the old one.
321
+
322
+ dispatch({
323
+ type: ActionTypes.REPLACE
324
+ });
325
+ }
326
+ /**
327
+ * Interoperability point for observable/reactive libraries.
328
+ * @returns {observable} A minimal observable of state changes.
329
+ * For more information, see the observable proposal:
330
+ * https://github.com/tc39/proposal-observable
331
+ */
332
+
333
+
334
+ function observable() {
335
+ var _ref;
336
+
337
+ var outerSubscribe = subscribe;
338
+ return _ref = {
339
+ /**
340
+ * The minimal observable subscription method.
341
+ * @param {Object} observer Any object that can be used as an observer.
342
+ * The observer object should have a `next` method.
343
+ * @returns {subscription} An object with an `unsubscribe` method that can
344
+ * be used to unsubscribe the observable from the store, and prevent further
345
+ * emission of values from the observable.
346
+ */
347
+ subscribe: function subscribe(observer) {
348
+ if (typeof observer !== 'object' || observer === null) {
349
+ throw new Error(formatProdErrorMessage(11) );
350
+ }
351
+
352
+ function observeState() {
353
+ if (observer.next) {
354
+ observer.next(getState());
355
+ }
356
+ }
357
+
358
+ observeState();
359
+ var unsubscribe = outerSubscribe(observeState);
360
+ return {
361
+ unsubscribe: unsubscribe
362
+ };
363
+ }
364
+ }, _ref[$$observable] = function () {
365
+ return this;
366
+ }, _ref;
367
+ } // When a store is created, an "INIT" action is dispatched so that every
368
+ // reducer returns their initial state. This effectively populates
369
+ // the initial state tree.
370
+
371
+
372
+ dispatch({
373
+ type: ActionTypes.INIT
374
+ });
375
+ return _ref2 = {
376
+ dispatch: dispatch,
377
+ subscribe: subscribe,
378
+ getState: getState,
379
+ replaceReducer: replaceReducer
380
+ }, _ref2[$$observable] = observable, _ref2;
381
+ }
382
+
383
+ function assertReducerShape(reducers) {
384
+ Object.keys(reducers).forEach(function (key) {
385
+ var reducer = reducers[key];
386
+ var initialState = reducer(undefined, {
387
+ type: ActionTypes.INIT
388
+ });
389
+
390
+ if (typeof initialState === 'undefined') {
391
+ throw new Error(formatProdErrorMessage(12) );
392
+ }
393
+
394
+ if (typeof reducer(undefined, {
395
+ type: ActionTypes.PROBE_UNKNOWN_ACTION()
396
+ }) === 'undefined') {
397
+ throw new Error(formatProdErrorMessage(13) );
398
+ }
399
+ });
400
+ }
401
+ /**
402
+ * Turns an object whose values are different reducer functions, into a single
403
+ * reducer function. It will call every child reducer, and gather their results
404
+ * into a single state object, whose keys correspond to the keys of the passed
405
+ * reducer functions.
406
+ *
407
+ * @param {Object} reducers An object whose values correspond to different
408
+ * reducer functions that need to be combined into one. One handy way to obtain
409
+ * it is to use ES6 `import * as reducers` syntax. The reducers may never return
410
+ * undefined for any action. Instead, they should return their initial state
411
+ * if the state passed to them was undefined, and the current state for any
412
+ * unrecognized action.
413
+ *
414
+ * @returns {Function} A reducer function that invokes every reducer inside the
415
+ * passed object, and builds a state object with the same shape.
416
+ */
417
+
418
+
419
+ function combineReducers(reducers) {
420
+ var reducerKeys = Object.keys(reducers);
421
+ var finalReducers = {};
422
+
423
+ for (var i = 0; i < reducerKeys.length; i++) {
424
+ var key = reducerKeys[i];
425
+
426
+ if (typeof reducers[key] === 'function') {
427
+ finalReducers[key] = reducers[key];
428
+ }
429
+ }
430
+
431
+ var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
432
+
433
+ var shapeAssertionError;
434
+
435
+ try {
436
+ assertReducerShape(finalReducers);
437
+ } catch (e) {
438
+ shapeAssertionError = e;
439
+ }
440
+
441
+ return function combination(state, action) {
442
+ if (state === void 0) {
443
+ state = {};
444
+ }
445
+
446
+ if (shapeAssertionError) {
447
+ throw shapeAssertionError;
448
+ }
449
+
450
+ var hasChanged = false;
451
+ var nextState = {};
452
+
453
+ for (var _i = 0; _i < finalReducerKeys.length; _i++) {
454
+ var _key = finalReducerKeys[_i];
455
+ var reducer = finalReducers[_key];
456
+ var previousStateForKey = state[_key];
457
+ var nextStateForKey = reducer(previousStateForKey, action);
458
+
459
+ if (typeof nextStateForKey === 'undefined') {
460
+ throw new Error(formatProdErrorMessage(14) );
461
+ }
462
+
463
+ nextState[_key] = nextStateForKey;
464
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
465
+ }
466
+
467
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
468
+ return hasChanged ? nextState : state;
469
+ };
470
+ }
471
+
472
+ /**
473
+ * Composes single-argument functions from right to left. The rightmost
474
+ * function can take multiple arguments as it provides the signature for
475
+ * the resulting composite function.
476
+ *
477
+ * @param {...Function} funcs The functions to compose.
478
+ * @returns {Function} A function obtained by composing the argument functions
479
+ * from right to left. For example, compose(f, g, h) is identical to doing
480
+ * (...args) => f(g(h(...args))).
481
+ */
482
+ function compose() {
483
+ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
484
+ funcs[_key] = arguments[_key];
485
+ }
486
+
487
+ if (funcs.length === 0) {
488
+ return function (arg) {
489
+ return arg;
490
+ };
491
+ }
492
+
493
+ if (funcs.length === 1) {
494
+ return funcs[0];
495
+ }
496
+
497
+ return funcs.reduce(function (a, b) {
498
+ return function () {
499
+ return a(b.apply(void 0, arguments));
500
+ };
501
+ });
502
+ }
503
+
504
+ /**
505
+ * Creates a store enhancer that applies middleware to the dispatch method
506
+ * of the Redux store. This is handy for a variety of tasks, such as expressing
507
+ * asynchronous actions in a concise manner, or logging every action payload.
508
+ *
509
+ * See `redux-thunk` package as an example of the Redux middleware.
510
+ *
511
+ * Because middleware is potentially asynchronous, this should be the first
512
+ * store enhancer in the composition chain.
513
+ *
514
+ * Note that each middleware will be given the `dispatch` and `getState` functions
515
+ * as named arguments.
516
+ *
517
+ * @param {...Function} middlewares The middleware chain to be applied.
518
+ * @returns {Function} A store enhancer applying the middleware.
519
+ */
520
+
521
+ function applyMiddleware() {
522
+ for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
523
+ middlewares[_key] = arguments[_key];
524
+ }
525
+
526
+ return function (createStore) {
527
+ return function () {
528
+ var store = createStore.apply(void 0, arguments);
529
+
530
+ var _dispatch = function dispatch() {
531
+ throw new Error(formatProdErrorMessage(15) );
532
+ };
533
+
534
+ var middlewareAPI = {
535
+ getState: store.getState,
536
+ dispatch: function dispatch() {
537
+ return _dispatch.apply(void 0, arguments);
538
+ }
539
+ };
540
+ var chain = middlewares.map(function (middleware) {
541
+ return middleware(middlewareAPI);
542
+ });
543
+ _dispatch = compose.apply(void 0, chain)(store.dispatch);
544
+ return _objectSpread2(_objectSpread2({}, store), {}, {
545
+ dispatch: _dispatch
546
+ });
547
+ };
548
+ };
549
+ }
550
+
551
+ /** A function that accepts a potential "extra argument" value to be injected later,
552
+ * and returns an instance of the thunk middleware that uses that value
553
+ */
554
+ function createThunkMiddleware(extraArgument) {
555
+ // Standard Redux middleware definition pattern:
556
+ // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
557
+ var middleware = function middleware(_ref) {
558
+ var dispatch = _ref.dispatch,
559
+ getState = _ref.getState;
560
+ return function (next) {
561
+ return function (action) {
562
+ // The thunk middleware looks for any functions that were passed to `store.dispatch`.
563
+ // If this "action" is really a function, call it and return the result.
564
+ if (typeof action === 'function') {
565
+ // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
566
+ return action(dispatch, getState, extraArgument);
567
+ } // Otherwise, pass the action down the middleware chain as usual
568
+
569
+
570
+ return next(action);
571
+ };
572
+ };
573
+ };
574
+
575
+ return middleware;
576
+ }
577
+
578
+ var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
579
+ // with whatever "extra arg" they want to inject into their thunks
580
+
581
+ thunk.withExtraArgument = createThunkMiddleware;
582
+
583
+ var actions = createCommonjsModule(function (module, exports) {
584
+
585
+ Object.defineProperty(exports, "__esModule", {
586
+ value: true
587
+ });
588
+ exports.ActionCreators = exports.ActionTypes = void 0;
589
+ var ActionTypes = {
590
+ UNDO: '@@redux-undo/UNDO',
591
+ REDO: '@@redux-undo/REDO',
592
+ JUMP_TO_FUTURE: '@@redux-undo/JUMP_TO_FUTURE',
593
+ JUMP_TO_PAST: '@@redux-undo/JUMP_TO_PAST',
594
+ JUMP: '@@redux-undo/JUMP',
595
+ CLEAR_HISTORY: '@@redux-undo/CLEAR_HISTORY'
596
+ };
597
+ exports.ActionTypes = ActionTypes;
598
+ var ActionCreators = {
599
+ undo: function undo() {
600
+ return {
601
+ type: ActionTypes.UNDO
602
+ };
603
+ },
604
+ redo: function redo() {
605
+ return {
606
+ type: ActionTypes.REDO
607
+ };
608
+ },
609
+ jumpToFuture: function jumpToFuture(index) {
610
+ return {
611
+ type: ActionTypes.JUMP_TO_FUTURE,
612
+ index: index
613
+ };
614
+ },
615
+ jumpToPast: function jumpToPast(index) {
616
+ return {
617
+ type: ActionTypes.JUMP_TO_PAST,
618
+ index: index
619
+ };
620
+ },
621
+ jump: function jump(index) {
622
+ return {
623
+ type: ActionTypes.JUMP,
624
+ index: index
625
+ };
626
+ },
627
+ clearHistory: function clearHistory() {
628
+ return {
629
+ type: ActionTypes.CLEAR_HISTORY
630
+ };
631
+ }
632
+ };
633
+ exports.ActionCreators = ActionCreators;
634
+ });
635
+
636
+ var helpers = createCommonjsModule(function (module, exports) {
637
+
638
+ Object.defineProperty(exports, "__esModule", {
639
+ value: true
640
+ });
641
+ exports.parseActions = parseActions;
642
+ exports.isHistory = isHistory;
643
+ exports.includeAction = includeAction;
644
+ exports.excludeAction = excludeAction;
645
+ exports.combineFilters = combineFilters;
646
+ exports.groupByActionTypes = groupByActionTypes;
647
+ exports.newHistory = newHistory;
648
+
649
+ // parseActions helper: takes a string (or array)
650
+ // and makes it an array if it isn't yet
651
+ function parseActions(rawActions) {
652
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
653
+
654
+ if (Array.isArray(rawActions)) {
655
+ return rawActions;
656
+ } else if (typeof rawActions === 'string') {
657
+ return [rawActions];
658
+ }
659
+
660
+ return defaultValue;
661
+ } // isHistory helper: check for a valid history object
662
+
663
+
664
+ function isHistory(history) {
665
+ return typeof history.present !== 'undefined' && typeof history.future !== 'undefined' && typeof history.past !== 'undefined' && Array.isArray(history.future) && Array.isArray(history.past);
666
+ } // includeAction helper: whitelist actions to be added to the history
667
+
668
+
669
+ function includeAction(rawActions) {
670
+ var actions = parseActions(rawActions);
671
+ return function (action) {
672
+ return actions.indexOf(action.type) >= 0;
673
+ };
674
+ } // excludeAction helper: blacklist actions from being added to the history
675
+
676
+
677
+ function excludeAction(rawActions) {
678
+ var actions = parseActions(rawActions);
679
+ return function (action) {
680
+ return actions.indexOf(action.type) < 0;
681
+ };
682
+ } // combineFilters helper: combine multiple filters to one
683
+
684
+
685
+ function combineFilters() {
686
+ for (var _len = arguments.length, filters = new Array(_len), _key = 0; _key < _len; _key++) {
687
+ filters[_key] = arguments[_key];
688
+ }
689
+
690
+ return filters.reduce(function (prev, curr) {
691
+ return function (action, currentState, previousHistory) {
692
+ return prev(action, currentState, previousHistory) && curr(action, currentState, previousHistory);
693
+ };
694
+ }, function () {
695
+ return true;
696
+ });
697
+ }
698
+
699
+ function groupByActionTypes(rawActions) {
700
+ var actions = parseActions(rawActions);
701
+ return function (action) {
702
+ return actions.indexOf(action.type) >= 0 ? action.type : null;
703
+ };
704
+ }
705
+
706
+ function newHistory(past, present, future) {
707
+ var group = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
708
+ return {
709
+ past: past,
710
+ present: present,
711
+ future: future,
712
+ group: group,
713
+ _latestUnfiltered: present,
714
+ index: past.length,
715
+ limit: past.length + future.length + 1
716
+ };
717
+ }
718
+ });
719
+
720
+ var debug = createCommonjsModule(function (module, exports) {
721
+
722
+ Object.defineProperty(exports, "__esModule", {
723
+ value: true
724
+ });
725
+ exports.set = set;
726
+ exports.start = start;
727
+ exports.end = end;
728
+ exports.log = log;
729
+
730
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
731
+
732
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
733
+
734
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
735
+
736
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
737
+
738
+ var __DEBUG__;
739
+
740
+ var displayBuffer;
741
+ var colors = {
742
+ prevState: '#9E9E9E',
743
+ action: '#03A9F4',
744
+ nextState: '#4CAF50'
745
+ };
746
+ /* istanbul ignore next: debug messaging is not tested */
747
+
748
+ function initBuffer() {
749
+ displayBuffer = {
750
+ header: [],
751
+ prev: [],
752
+ action: [],
753
+ next: [],
754
+ msgs: []
755
+ };
756
+ }
757
+ /* istanbul ignore next: debug messaging is not tested */
758
+
759
+
760
+ function printBuffer() {
761
+ var _displayBuffer = displayBuffer,
762
+ header = _displayBuffer.header,
763
+ prev = _displayBuffer.prev,
764
+ next = _displayBuffer.next,
765
+ action = _displayBuffer.action,
766
+ msgs = _displayBuffer.msgs;
767
+
768
+ if (console.group) {
769
+ var _console, _console2, _console3, _console4, _console5;
770
+
771
+ (_console = console).groupCollapsed.apply(_console, _toConsumableArray(header));
772
+
773
+ (_console2 = console).log.apply(_console2, _toConsumableArray(prev));
774
+
775
+ (_console3 = console).log.apply(_console3, _toConsumableArray(action));
776
+
777
+ (_console4 = console).log.apply(_console4, _toConsumableArray(next));
778
+
779
+ (_console5 = console).log.apply(_console5, _toConsumableArray(msgs));
780
+
781
+ console.groupEnd();
782
+ } else {
783
+ var _console6, _console7, _console8, _console9, _console10;
784
+
785
+ (_console6 = console).log.apply(_console6, _toConsumableArray(header));
786
+
787
+ (_console7 = console).log.apply(_console7, _toConsumableArray(prev));
788
+
789
+ (_console8 = console).log.apply(_console8, _toConsumableArray(action));
790
+
791
+ (_console9 = console).log.apply(_console9, _toConsumableArray(next));
792
+
793
+ (_console10 = console).log.apply(_console10, _toConsumableArray(msgs));
794
+ }
795
+ }
796
+ /* istanbul ignore next: debug messaging is not tested */
797
+
798
+
799
+ function colorFormat(text, color, obj) {
800
+ return ["%c".concat(text), "color: ".concat(color, "; font-weight: bold"), obj];
801
+ }
802
+ /* istanbul ignore next: debug messaging is not tested */
803
+
804
+
805
+ function start(action, state) {
806
+ initBuffer();
807
+
808
+ if (__DEBUG__) {
809
+ if (console.group) {
810
+ displayBuffer.header = ['%credux-undo', 'font-style: italic', 'action', action.type];
811
+ displayBuffer.action = colorFormat('action', colors.action, action);
812
+ displayBuffer.prev = colorFormat('prev history', colors.prevState, state);
813
+ } else {
814
+ displayBuffer.header = ['redux-undo action', action.type];
815
+ displayBuffer.action = ['action', action];
816
+ displayBuffer.prev = ['prev history', state];
817
+ }
818
+ }
819
+ }
820
+ /* istanbul ignore next: debug messaging is not tested */
821
+
822
+
823
+ function end(nextState) {
824
+ if (__DEBUG__) {
825
+ if (console.group) {
826
+ displayBuffer.next = colorFormat('next history', colors.nextState, nextState);
827
+ } else {
828
+ displayBuffer.next = ['next history', nextState];
829
+ }
830
+
831
+ printBuffer();
832
+ }
833
+ }
834
+ /* istanbul ignore next: debug messaging is not tested */
835
+
836
+
837
+ function log() {
838
+ if (__DEBUG__) {
839
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
840
+ args[_key] = arguments[_key];
841
+ }
842
+
843
+ displayBuffer.msgs = displayBuffer.msgs.concat([].concat(args, ['\n']));
844
+ }
845
+ }
846
+ /* istanbul ignore next: debug messaging is not tested */
847
+
848
+
849
+ function set(debug) {
850
+ __DEBUG__ = debug;
851
+ }
852
+ });
853
+
854
+ var reducer = createCommonjsModule(function (module, exports) {
855
+
856
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
857
+
858
+ Object.defineProperty(exports, "__esModule", {
859
+ value: true
860
+ });
861
+ exports["default"] = undoable;
862
+
863
+ var debug$1 = _interopRequireWildcard(debug);
864
+
865
+
866
+
867
+
868
+
869
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
870
+
871
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
872
+
873
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
874
+
875
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
876
+
877
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
878
+
879
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
880
+
881
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
882
+
883
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
884
+
885
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
886
+
887
+ function createHistory(state, ignoreInitialState) {
888
+ // ignoreInitialState essentially prevents the user from undoing to the
889
+ // beginning, in the case that the undoable reducer handles initialization
890
+ // in a way that can't be redone simply
891
+ var history = (0, helpers.newHistory)([], state, []);
892
+
893
+ if (ignoreInitialState) {
894
+ history._latestUnfiltered = null;
895
+ }
896
+
897
+ return history;
898
+ } // insert: insert `state` into history, which means adding the current state
899
+ // into `past`, setting the new `state` as `present` and erasing
900
+ // the `future`.
901
+
902
+
903
+ function insert(history, state, limit, group) {
904
+ var lengthWithoutFuture = history.past.length + 1;
905
+ debug$1.log('inserting', state);
906
+ debug$1.log('new free: ', limit - lengthWithoutFuture);
907
+ var past = history.past,
908
+ _latestUnfiltered = history._latestUnfiltered;
909
+ var isHistoryOverflow = limit && limit <= lengthWithoutFuture;
910
+ var pastSliced = past.slice(isHistoryOverflow ? 1 : 0);
911
+ var newPast = _latestUnfiltered != null ? [].concat(_toConsumableArray(pastSliced), [_latestUnfiltered]) : pastSliced;
912
+ return (0, helpers.newHistory)(newPast, state, [], group);
913
+ } // jumpToFuture: jump to requested index in future history
914
+
915
+
916
+ function jumpToFuture(history, index) {
917
+ if (index < 0 || index >= history.future.length) return history;
918
+ var past = history.past,
919
+ future = history.future,
920
+ _latestUnfiltered = history._latestUnfiltered;
921
+ var newPast = [].concat(_toConsumableArray(past), [_latestUnfiltered], _toConsumableArray(future.slice(0, index)));
922
+ var newPresent = future[index];
923
+ var newFuture = future.slice(index + 1);
924
+ return (0, helpers.newHistory)(newPast, newPresent, newFuture);
925
+ } // jumpToPast: jump to requested index in past history
926
+
927
+
928
+ function jumpToPast(history, index) {
929
+ if (index < 0 || index >= history.past.length) return history;
930
+ var past = history.past,
931
+ future = history.future,
932
+ _latestUnfiltered = history._latestUnfiltered;
933
+ var newPast = past.slice(0, index);
934
+ var newFuture = [].concat(_toConsumableArray(past.slice(index + 1)), [_latestUnfiltered], _toConsumableArray(future));
935
+ var newPresent = past[index];
936
+ return (0, helpers.newHistory)(newPast, newPresent, newFuture);
937
+ } // jump: jump n steps in the past or forward
938
+
939
+
940
+ function jump(history, n) {
941
+ if (n > 0) return jumpToFuture(history, n - 1);
942
+ if (n < 0) return jumpToPast(history, history.past.length + n);
943
+ return history;
944
+ } // helper to dynamically match in the reducer's switch-case
945
+
946
+
947
+ function actionTypeAmongClearHistoryType(actionType, clearHistoryType) {
948
+ return clearHistoryType.indexOf(actionType) > -1 ? actionType : !actionType;
949
+ } // redux-undo higher order reducer
950
+
951
+
952
+ function undoable(reducer) {
953
+ var rawConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
954
+ debug$1.set(rawConfig.debug);
955
+
956
+ var config = _objectSpread({
957
+ limit: undefined,
958
+ filter: function filter() {
959
+ return true;
960
+ },
961
+ groupBy: function groupBy() {
962
+ return null;
963
+ },
964
+ undoType: actions.ActionTypes.UNDO,
965
+ redoType: actions.ActionTypes.REDO,
966
+ jumpToPastType: actions.ActionTypes.JUMP_TO_PAST,
967
+ jumpToFutureType: actions.ActionTypes.JUMP_TO_FUTURE,
968
+ jumpType: actions.ActionTypes.JUMP,
969
+ neverSkipReducer: false,
970
+ ignoreInitialState: false,
971
+ syncFilter: false
972
+ }, rawConfig, {
973
+ initTypes: (0, helpers.parseActions)(rawConfig.initTypes, ['@@redux-undo/INIT']),
974
+ clearHistoryType: (0, helpers.parseActions)(rawConfig.clearHistoryType, [actions.ActionTypes.CLEAR_HISTORY])
975
+ }); // Allows the user to call the reducer with redux-undo specific actions
976
+
977
+
978
+ var skipReducer = config.neverSkipReducer ? function (res, action) {
979
+ for (var _len = arguments.length, slices = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
980
+ slices[_key - 2] = arguments[_key];
981
+ }
982
+
983
+ return _objectSpread({}, res, {
984
+ present: reducer.apply(void 0, [res.present, action].concat(slices))
985
+ });
986
+ } : function (res) {
987
+ return res;
988
+ };
989
+ var initialState;
990
+ return function () {
991
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
992
+ var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
993
+ debug$1.start(action, state);
994
+ var history = state;
995
+
996
+ for (var _len2 = arguments.length, slices = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
997
+ slices[_key2 - 2] = arguments[_key2];
998
+ }
999
+
1000
+ if (!initialState) {
1001
+ debug$1.log('history is uninitialized');
1002
+
1003
+ if (state === undefined) {
1004
+ var createHistoryAction = {
1005
+ type: '@@redux-undo/CREATE_HISTORY'
1006
+ };
1007
+ var start = reducer.apply(void 0, [state, createHistoryAction].concat(slices));
1008
+ history = createHistory(start, config.ignoreInitialState);
1009
+ debug$1.log('do not set initialState on probe actions');
1010
+ debug$1.end(history);
1011
+ return history;
1012
+ } else if ((0, helpers.isHistory)(state)) {
1013
+ history = initialState = config.ignoreInitialState ? state : (0, helpers.newHistory)(state.past, state.present, state.future);
1014
+ debug$1.log('initialHistory initialized: initialState is a history', initialState);
1015
+ } else {
1016
+ history = initialState = createHistory(state, config.ignoreInitialState);
1017
+ debug$1.log('initialHistory initialized: initialState is not a history', initialState);
1018
+ }
1019
+ }
1020
+
1021
+ var res;
1022
+
1023
+ switch (action.type) {
1024
+ case undefined:
1025
+ return history;
1026
+
1027
+ case config.undoType:
1028
+ res = jump(history, -1);
1029
+ debug$1.log('perform undo');
1030
+ debug$1.end(res);
1031
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1032
+
1033
+ case config.redoType:
1034
+ res = jump(history, 1);
1035
+ debug$1.log('perform redo');
1036
+ debug$1.end(res);
1037
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1038
+
1039
+ case config.jumpToPastType:
1040
+ res = jumpToPast(history, action.index);
1041
+ debug$1.log("perform jumpToPast to ".concat(action.index));
1042
+ debug$1.end(res);
1043
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1044
+
1045
+ case config.jumpToFutureType:
1046
+ res = jumpToFuture(history, action.index);
1047
+ debug$1.log("perform jumpToFuture to ".concat(action.index));
1048
+ debug$1.end(res);
1049
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1050
+
1051
+ case config.jumpType:
1052
+ res = jump(history, action.index);
1053
+ debug$1.log("perform jump to ".concat(action.index));
1054
+ debug$1.end(res);
1055
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1056
+
1057
+ case actionTypeAmongClearHistoryType(action.type, config.clearHistoryType):
1058
+ res = createHistory(history.present, config.ignoreInitialState);
1059
+ debug$1.log('perform clearHistory');
1060
+ debug$1.end(res);
1061
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1062
+
1063
+ default:
1064
+ res = reducer.apply(void 0, [history.present, action].concat(slices));
1065
+
1066
+ if (config.initTypes.some(function (actionType) {
1067
+ return actionType === action.type;
1068
+ })) {
1069
+ debug$1.log('reset history due to init action');
1070
+ debug$1.end(initialState);
1071
+ return initialState;
1072
+ }
1073
+
1074
+ if (history._latestUnfiltered === res) {
1075
+ // Don't handle this action. Do not call debug.end here,
1076
+ // because this action should not produce side effects to the console
1077
+ return history;
1078
+ }
1079
+ /* eslint-disable-next-line no-case-declarations */
1080
+
1081
+
1082
+ var filtered = typeof config.filter === 'function' && !config.filter(action, res, history);
1083
+
1084
+ if (filtered) {
1085
+ // if filtering an action, merely update the present
1086
+ var filteredState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1087
+
1088
+ if (!config.syncFilter) {
1089
+ filteredState._latestUnfiltered = history._latestUnfiltered;
1090
+ }
1091
+
1092
+ debug$1.log('filter ignored action, not storing it in past');
1093
+ debug$1.end(filteredState);
1094
+ return filteredState;
1095
+ }
1096
+ /* eslint-disable-next-line no-case-declarations */
1097
+
1098
+
1099
+ var group = config.groupBy(action, res, history);
1100
+
1101
+ if (group != null && group === history.group) {
1102
+ // if grouping with the previous action, only update the present
1103
+ var groupedState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1104
+ debug$1.log('groupBy grouped the action with the previous action');
1105
+ debug$1.end(groupedState);
1106
+ return groupedState;
1107
+ } // If the action wasn't filtered or grouped, insert normally
1108
+
1109
+
1110
+ history = insert(history, res, config.limit, group);
1111
+ debug$1.log('inserted new state into history');
1112
+ debug$1.end(history);
1113
+ return history;
1114
+ }
1115
+ };
1116
+ }
1117
+ });
1118
+
1119
+ var lib = createCommonjsModule(function (module, exports) {
1120
+
1121
+ Object.defineProperty(exports, "__esModule", {
1122
+ value: true
1123
+ });
1124
+ Object.defineProperty(exports, "ActionTypes", {
1125
+ enumerable: true,
1126
+ get: function get() {
1127
+ return actions.ActionTypes;
1128
+ }
1129
+ });
1130
+ Object.defineProperty(exports, "ActionCreators", {
1131
+ enumerable: true,
1132
+ get: function get() {
1133
+ return actions.ActionCreators;
1134
+ }
1135
+ });
1136
+ Object.defineProperty(exports, "parseActions", {
1137
+ enumerable: true,
1138
+ get: function get() {
1139
+ return helpers.parseActions;
1140
+ }
1141
+ });
1142
+ Object.defineProperty(exports, "isHistory", {
1143
+ enumerable: true,
1144
+ get: function get() {
1145
+ return helpers.isHistory;
1146
+ }
1147
+ });
1148
+ Object.defineProperty(exports, "includeAction", {
1149
+ enumerable: true,
1150
+ get: function get() {
1151
+ return helpers.includeAction;
1152
+ }
1153
+ });
1154
+ Object.defineProperty(exports, "excludeAction", {
1155
+ enumerable: true,
1156
+ get: function get() {
1157
+ return helpers.excludeAction;
1158
+ }
1159
+ });
1160
+ Object.defineProperty(exports, "combineFilters", {
1161
+ enumerable: true,
1162
+ get: function get() {
1163
+ return helpers.combineFilters;
1164
+ }
1165
+ });
1166
+ Object.defineProperty(exports, "groupByActionTypes", {
1167
+ enumerable: true,
1168
+ get: function get() {
1169
+ return helpers.groupByActionTypes;
1170
+ }
1171
+ });
1172
+ Object.defineProperty(exports, "newHistory", {
1173
+ enumerable: true,
1174
+ get: function get() {
1175
+ return helpers.newHistory;
1176
+ }
1177
+ });
1178
+ Object.defineProperty(exports, "default", {
1179
+ enumerable: true,
1180
+ get: function get() {
1181
+ return _reducer["default"];
1182
+ }
1183
+ });
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+ var _reducer = _interopRequireDefault(reducer);
1190
+
1191
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1192
+ });
1193
+
1194
+ const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
1195
+
1196
+ const inicialHistState = {
1197
+ currentTabIndex: {},
1198
+ currentRecordIndex: {},
1199
+ changes: {},
1200
+ collapsedGroups: {},
1201
+ newRecordIndex: {}
1202
+ };
1203
+ const inicialNonHistState = {
1204
+ dataLoading: {},
1205
+ invalidFields: {},
1206
+ visibleButtons: {
1207
+ previousVisible: true,
1208
+ nextVisible: true,
1209
+ addVisible: true,
1210
+ removeVisible: true,
1211
+ saveVisible: true,
1212
+ cancelVisible: true,
1213
+ reloadVisible: false
1214
+ }
1215
+ };
1216
+ function formReducer(state = inicialHistState, action) {
1217
+ switch (action.type) {
1218
+ case "FORM/COLLAPSEGROUP":
1219
+ return collapseGroup(state, action.payload);
1220
+ case "FORM/CHANGETAB":
1221
+ return changeTab(state, action.payload.formId, action.payload.index);
1222
+ case "FORM/NAVIGATE":
1223
+ return navigate(state, action.payload);
1224
+ case "FORM/INSERT":
1225
+ return insertRecord(state, action.payload);
1226
+ case "FORM/CHANGEFIELD":
1227
+ return changeFieldValue(state, action.payload);
1228
+ case "FORM/CLEAREDITION":
1229
+ return clearEdition(state, action.payload);
1230
+ case "FORM/INVALIDFIELD":
1231
+ return navigateToInvalid(state, action.payload);
1232
+ default:
1233
+ return state;
1234
+ }
1235
+ }
1236
+ function formNonHistoricReducer(state = inicialNonHistState, action) {
1237
+ switch (action.type) {
1238
+ case "FORM/DATALOADING":
1239
+ return dataLoading(state, action.payload);
1240
+ case "FORM/DATALOADED":
1241
+ return dataLoaded(state, action.payload);
1242
+ case "FORM/SAVINGCHANGES":
1243
+ return savingChanges(state, action.payload);
1244
+ case "FORM/CHANGESSAVED":
1245
+ return changesSaved(state, action.payload);
1246
+ case "FORM/REMOVINGRECORD":
1247
+ return removingRecord(state, action.payload);
1248
+ case "FORM/RECORDREMOVED":
1249
+ return recordRemoved(state, action.payload);
1250
+ case "FORM/INVALIDFIELD":
1251
+ return invalidField(state, action.payload);
1252
+ case "FORM/CLEAREDITION":
1253
+ return clearAllInvalidFields(state, action.payload);
1254
+ case "FORM/CHANGEFIELD":
1255
+ return clearInvalidField(state, action.payload);
1256
+ case "FORM/SHOWHIDENAVBTN":
1257
+ return showHideNavBtn(state, action.payload);
1258
+ default:
1259
+ return state;
1260
+ }
1261
+ }
1262
+ function collapseGroup(state, { collapseId, collapsed }) {
1263
+ const currentCollapsed = Object.assign({}, state.collapsedGroups);
1264
+ if (collapsed) {
1265
+ currentCollapsed[collapseId] = true;
1266
+ }
1267
+ else {
1268
+ delete currentCollapsed[collapseId];
1269
+ }
1270
+ return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
1271
+ }
1272
+ function changeTab(state, formId, index) {
1273
+ const currentTabIndex = Object.assign({}, state.currentTabIndex);
1274
+ currentTabIndex[formId] = index;
1275
+ return Object.assign(Object.assign({}, state), { currentTabIndex });
1276
+ }
1277
+ function navigate(state, { dataUnit, limit, backward }) {
1278
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1279
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1280
+ return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
1281
+ }
1282
+ function gotoIndex(state, dataUnit, index) {
1283
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1284
+ currentRecordIndex[dataUnit] = index;
1285
+ return Object.assign(Object.assign({}, state), { currentRecordIndex });
1286
+ }
1287
+ function insertRecord(state, { dataUnit, insertionIndex }) {
1288
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1289
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1290
+ currentRecordIndex[dataUnit] = insertionIndex;
1291
+ newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
1292
+ return Object.assign(Object.assign({}, state), { currentRecordIndex,
1293
+ newRecordIndex });
1294
+ }
1295
+ function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
1296
+ const changes = Object.assign({}, state.changes);
1297
+ const dataUnitChanges = Object.assign({}, changes[dataUnit]);
1298
+ const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
1299
+ recordChanges[fieldName] = value;
1300
+ dataUnitChanges[recordId] = recordChanges;
1301
+ changes[dataUnit] = dataUnitChanges;
1302
+ const invalidFields = Object.assign({}, state.invalidFields);
1303
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1304
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1305
+ delete errorMessages[fieldName];
1306
+ dataUnitInvalidRecords[recordId] = errorMessages;
1307
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
1308
+ return Object.assign(Object.assign({}, state), { changes,
1309
+ invalidFields, invalidFieldSelected: undefined });
1310
+ }
1311
+ function clearEdition(state, { dataUnit, recordsLimit }) {
1312
+ const changes = Object.assign({}, state.changes);
1313
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1314
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1315
+ delete changes[dataUnit];
1316
+ delete newRecordIndex[dataUnit];
1317
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1318
+ currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
1319
+ return Object.assign(Object.assign({}, state), { changes,
1320
+ newRecordIndex,
1321
+ currentRecordIndex });
1322
+ }
1323
+ function navigateToInvalid(state, payload) {
1324
+ let newState = Object.assign({}, state);
1325
+ if (newState.invalidFieldSelected === undefined) {
1326
+ newState.invalidFieldSelected = true;
1327
+ newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
1328
+ newState = changeTab(newState, payload.tabController, payload.tabIndex);
1329
+ }
1330
+ return newState;
1331
+ }
1332
+ function dataLoading(state, { dataUnit }) {
1333
+ const dataLoading = Object.assign({}, state.dataLoading);
1334
+ dataLoading[dataUnit] = true;
1335
+ return Object.assign(Object.assign({}, state), { dataLoading });
1336
+ }
1337
+ function dataLoaded(state, { dataUnit }) {
1338
+ const dataLoading = Object.assign({}, state.dataLoading);
1339
+ delete dataLoading[dataUnit];
1340
+ return Object.assign(Object.assign({}, state), { dataLoading });
1341
+ }
1342
+ function savingChanges(state, { dataUnit }) {
1343
+ const dataLoading = Object.assign({}, state.dataLoading);
1344
+ dataLoading[dataUnit] = true;
1345
+ return Object.assign(Object.assign({}, state), { dataLoading });
1346
+ }
1347
+ function changesSaved(state, { dataUnit }) {
1348
+ const dataLoading = Object.assign({}, state.dataLoading);
1349
+ delete dataLoading[dataUnit];
1350
+ return Object.assign(Object.assign({}, state), { dataLoading });
1351
+ }
1352
+ function removingRecord(state, { dataUnit }) {
1353
+ const dataLoading = Object.assign({}, state.dataLoading);
1354
+ dataLoading[dataUnit] = true;
1355
+ return Object.assign(Object.assign({}, state), { dataLoading });
1356
+ }
1357
+ function recordRemoved(state, { dataUnit }) {
1358
+ const dataLoading = Object.assign({}, state.dataLoading);
1359
+ delete dataLoading[dataUnit];
1360
+ return Object.assign(Object.assign({}, state), { dataLoading });
1361
+ }
1362
+ function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
1363
+ const invalidFields = Object.assign({}, state.invalidFields);
1364
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1365
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1366
+ errorMessages[fieldName] = errorMessage;
1367
+ dataUnitInvalidRecords[recordId] = errorMessages;
1368
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
1369
+ return Object.assign(Object.assign({}, state), { invalidFields });
1370
+ }
1371
+ function clearAllInvalidFields(state, { dataUnit }) {
1372
+ const invalidFields = Object.assign({}, state.invalidFields);
1373
+ delete invalidFields[dataUnit];
1374
+ return Object.assign(Object.assign({}, state), { invalidFields });
1375
+ }
1376
+ function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
1377
+ const invalidFields = Object.assign({}, state.invalidFields);
1378
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1379
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1380
+ delete errorMessages[fieldName];
1381
+ dataUnitInvalidRecords[recordId] = errorMessages;
1382
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
1383
+ return Object.assign(Object.assign({}, state), { invalidFields });
1384
+ }
1385
+ function showHideNavBtn(state, { buttonName, status }) {
1386
+ const visibleButtons = Object.assign({}, state.visibleButtons);
1387
+ visibleButtons[buttonName] = status;
1388
+ return Object.assign(Object.assign({}, state), { visibleButtons });
1389
+ }
1390
+
1391
+ function removeHandler(dataUnit) {
1392
+ ApplicationUtils.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
1393
+ if (ok) {
1394
+ dataUnit.remove();
1395
+ }
1396
+ });
1397
+ }
1398
+ function saveHandler(dataUnit) {
1399
+ setTimeout(() => {
1400
+ //Esse debouncing é necessário quando o usuário clica no botão de salvar
1401
+ //sem ter tirado o foco o último campo alterado.
1402
+ dataUnit.save();
1403
+ }, 50);
1404
+ }
1405
+ const NavigationBar = ({ dataUnit: du, buttonProps, enabled }) => {
1406
+ if (buttonProps.previousVisible
1407
+ || buttonProps.nextVisible
1408
+ || buttonProps.addVisible
1409
+ || buttonProps.removeVisible
1410
+ || buttonProps.saveVisible
1411
+ || buttonProps.cancelVisible
1412
+ || buttonProps.reloadVisible) {
1413
+ return h("div", { class: "col col--sd-12 align--right" },
1414
+ buttonProps.previousVisible ? h("ez-button", { key: du.name + "_previous", title: "Registro anterior", mode: "icon", enabled: enabled && du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
1415
+ buttonProps.nextVisible ? h("ez-button", { key: du.name + "_next", title: "Pr\u00F3ximo registro", mode: "icon", enabled: enabled && du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
1416
+ buttonProps.removeVisible ? h("ez-button", { key: du.name + "_remove", label: "Remover", enabled: enabled && du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
1417
+ buttonProps.addVisible ? h("ez-button", { key: du.name + "_add", label: "Adicionar", enabled: enabled, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
1418
+ buttonProps.reloadVisible ? h("ez-button", { key: du.name + "_reload", title: "Recarregar", enabled: enabled, mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
1419
+ buttonProps.cancelVisible ? h("ez-button", { key: du.name + "_cancel", label: "Cancelar", enabled: enabled && du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
1420
+ buttonProps.saveVisible ? h("ez-button", { key: du.name + "_save", label: "Salvar", enabled: enabled && du.hasChanges(), onClick: () => saveHandler(du), class: "button--primary margin-right--medium" }) : null);
1421
+ }
1422
+ else {
1423
+ return null;
1424
+ }
1425
+ };
1426
+
1427
+ function scrollToView(forceScroll, elem) {
1428
+ if (forceScroll) {
1429
+ window.requestAnimationFrame(() => elem.scrollIntoView());
1430
+ }
1431
+ }
1432
+ const Field = ({ dataUnit, field, forceScroll, enabled }) => {
1433
+ const { name, form } = field;
1434
+ const { label, userInterface, properties, required, dependencies, readOnly } = dataUnit.getFieldMetadata(name);
1435
+ const value = dataUnit.getValue(name) || null;
1436
+ const loadingData = dataUnit.isLoading();
1437
+ const formattedLabel = required ? `* ${label} (obrigatório)` : label;
1438
+ const errorMessage = dataUnit.getErrorMessage(name);
1439
+ const key = `${dataUnit.name}-${name}`;
1440
+ const isEnabled = enabled && !readOnly;
1441
+ const changeFieldHandler = (newValue) => {
1442
+ dataUnit.changeValue(name, newValue);
1443
+ };
1444
+ switch (userInterface) {
1445
+ case "LONGTEXT":
1446
+ return h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
1447
+ h("ez-text-area", { value: value || "", label: formattedLabel, onEzChange: evt => changeFieldHandler(evt.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, enabled: isEnabled }));
1448
+ case "CHECKBOX":
1449
+ case "SWITCH":
1450
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" }, loadingData ? h("place-holder", null) :
1451
+ h("ez-check", { value: value, label: label, enabled: isEnabled, mode: userInterface === "CHECKBOX" ? "regular" : "switch", onEzChange: (event) => changeFieldHandler(event.target["value"]), ref: elem => scrollToView(forceScroll, elem), key: key }));
1452
+ case "OPTIONSELECTOR":
1453
+ const optsObj = properties ? JSON.parse(getProp(properties, "options")) : {};
1454
+ const normalized = Object.keys(optsObj).map(key => { return { value: key, label: optsObj[key] }; });
1455
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
1456
+ h("ez-combo-box", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key, options: normalized }));
1457
+ case "SEARCH":
1458
+ const context = {
1459
+ __MAIN_FORM: form,
1460
+ __DATA_UNIT: dataUnit.name,
1461
+ __FIELD_NAME: name
1462
+ };
1463
+ properties.forEach(({ name, value }) => {
1464
+ context[name] = value;
1465
+ });
1466
+ let criteriaList = [];
1467
+ dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
1468
+ var _a;
1469
+ if (dependency.type === DependencyType.SEARCHING) {
1470
+ if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1471
+ let criteria = {
1472
+ expression: dependency.expression,
1473
+ paramNames: [...dependency.masterFields],
1474
+ paramResolver: name => dataUnit.getValue(name)
1475
+ };
1476
+ criteriaList.push(criteria);
1477
+ }
1478
+ }
1479
+ });
1480
+ if (criteriaList.length > 0) {
1481
+ context["CRITERIA"] = criteriaList;
1482
+ }
1483
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
1484
+ h("ez-search", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, optionLoader: (argument) => {
1485
+ if (form) {
1486
+ return form.loadSearch(argument, context);
1487
+ }
1488
+ }, ref: elem => scrollToView(forceScroll, elem), key: key }));
1489
+ case "FILE":
1490
+ const target = getProp(properties, "URL");
1491
+ const strHeaders = getProp(properties, "HEADERS");
1492
+ const headers = strHeaders ? JSON.parse(strHeaders) : {};
1493
+ const maxfiles = Number(getProp(properties, "maxfiles") || 0);
1494
+ return (h("div", { class: "col col--sd-12 padding--small" }, loadingData ? h("place-holder", null) :
1495
+ h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlUpload: target, requestHeaders: headers, maxFiles: maxfiles })));
1496
+ case "DATE":
1497
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
1498
+ h("ez-date-input", { value: !value ? null : DateUtils.clearTime(value), label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
1499
+ case "DECIMALNUMBER":
1500
+ case "INTEGERNUMBER":
1501
+ let precision = 0;
1502
+ let prettyPrecision = 0;
1503
+ if (userInterface === "DECIMALNUMBER") {
1504
+ precision = Number(getProp(properties, "precision") || 2);
1505
+ prettyPrecision = Number(getProp(properties, "prettyprecision") || precision);
1506
+ }
1507
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
1508
+ h("ez-numeric-input", { value: !value ? null : value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, precision: precision, prettyprecision: prettyPrecision, ref: elem => scrollToView(forceScroll, elem), key: key }));
1509
+ //IMAGE, DATETIME, ELAPSEDTIME, PASSWORD, MASKEDTEXT, HTML
1510
+ default:
1511
+ return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
1512
+ h("ez-text-input", { value: value, label: formattedLabel, enabled: isEnabled, loading: loadingData, onInput: (event) => changeFieldHandler(event.target["value"]), errorMessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
1513
+ }
1514
+ };
1515
+ function getProp(properties, name) {
1516
+ var _a;
1517
+ return properties ? (_a = properties.find(prop => prop.name === name)) === null || _a === void 0 ? void 0 : _a.value : null;
1518
+ }
1519
+
1520
+ const FieldSet = ({ store, formName, source, dataUnit, enabled }) => {
1521
+ const { label, fields } = source;
1522
+ const fieldSetName = formName + label;
1523
+ let isCollapsed = selectIsCollapsedFieldSet(store.getState(), formName + label);
1524
+ let fieldToScroll;
1525
+ source.fields.forEach((field) => {
1526
+ if (fieldToScroll === undefined) {
1527
+ const fieldError = dataUnit.getErrorMessage(field.name);
1528
+ if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
1529
+ fieldToScroll = field.name;
1530
+ }
1531
+ }
1532
+ });
1533
+ if (fieldToScroll) {
1534
+ isCollapsed = false;
1535
+ }
1536
+ return h("div", { class: "col col--sd-12 padding--small" },
1537
+ h("div", { class: "row margin-top--large" },
1538
+ h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
1539
+ h("ez-collapsible-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(collapseExpandGroup(fieldSetName, !isCollapsed)) }),
1540
+ isCollapsed ? null :
1541
+ h("div", { class: "col col--sd-12" }, fields.map(field => h(Field, { enabled: enabled, field: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
1542
+ };
1543
+
1544
+ function buildFormItem(source, formName, store, dataUnit, enabled) {
1545
+ if ("fields" in source) {
1546
+ return h(FieldSet, { enabled: enabled, source: source, store: store, formName: formName, dataUnit: dataUnit });
1547
+ }
1548
+ const fieldName = source.name;
1549
+ const errorMsg = dataUnit.getErrorMessage(fieldName);
1550
+ const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
1551
+ return h(Field, { enabled: enabled, field: source, dataUnit: dataUnit, forceScroll: forceScroll });
1552
+ }
1553
+ const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder, enabled }) => {
1554
+ const selectedTab = selectCurrentTab(store.getState(), parentName);
1555
+ const tabs = source.length > 1 ? source.map(form => h("ez-tab", { label: form.label, tabKey: form.name })) : null;
1556
+ const { subForms, items, name } = source[selectedTab];
1557
+ const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit, parentDataUnit);
1558
+ source[selectedTab].dataUnit = dataUnit;
1559
+ const hasSubForms = subForms && subForms.length > 0;
1560
+ const changeTabHandler = (index) => {
1561
+ store.dispatch(changeTab$1(parentName, index));
1562
+ };
1563
+ //todos os campos e subformulários precisam estar ligados a um DU
1564
+ const currentDU = dataUnit || parentDataUnit;
1565
+ let buttons = selectVisibleButtons(store.getState());
1566
+ if (currentDU.cardinality === "1") {
1567
+ buttons.addVisible = false;
1568
+ buttons.removeVisible = false;
1569
+ buttons.nextVisible = false;
1570
+ buttons.previousVisible = false;
1571
+ }
1572
+ return h("div", { class: "form-sheet" },
1573
+ tabs ? h("ez-tabselector", { selectedIndex: selectedTab, selectedTab: name, onEzChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
1574
+ dataUnit ? h(NavigationBar, { enabled: enabled, dataUnit: dataUnit, buttonProps: buttons }) : null,
1575
+ h("div", { class: "tab__container" },
1576
+ items ? items.map(item => buildFormItem(item, name, store, currentDU, enabled)) : null,
1577
+ hasSubForms ? h(FormSheet, { enabled: enabled, store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
1578
+ };
1579
+
1580
+ const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
1581
+
1582
+ let EzForm = class {
1583
+ constructor(hostRef) {
1584
+ registerInstance(this, hostRef);
1585
+ this.enabled = true;
1586
+ this.loading = false;
1587
+ this._dataUnits = new Map();
1588
+ this._duSources = new Map();
1589
+ this._tabPositionByField = new Map();
1590
+ this._duToLoad = [];
1591
+ }
1592
+ cleanPreparedMetadata() {
1593
+ this._preparedMetadata = undefined;
1594
+ }
1595
+ async validate() {
1596
+ const duSourcesNames = Array.from(this._duSources.keys());
1597
+ for (let i = 0; i < this._duSources.size; i++) {
1598
+ const duName = duSourcesNames[i];
1599
+ let du = this._dataUnits.get(duName);
1600
+ if (du === undefined) {
1601
+ const source = this._duSources.get(duName);
1602
+ du = this.buildDataUnit(source, source.parentDUName);
1603
+ }
1604
+ if (!du.validateRecords()) {
1605
+ return false;
1606
+ }
1607
+ }
1608
+ return true;
1609
+ }
1610
+ async getChanges() {
1611
+ let allChanges = [];
1612
+ const dataUnits = Array.from(this._dataUnits.values());
1613
+ for (let i = 0; i < this._dataUnits.size; i++) {
1614
+ const du = dataUnits[i];
1615
+ //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
1616
+ if (!du.parentDU) {
1617
+ const duChanges = du.getChangesToSave();
1618
+ if (duChanges) {
1619
+ allChanges = allChanges.concat(duChanges);
1620
+ }
1621
+ }
1622
+ }
1623
+ return allChanges;
1624
+ }
1625
+ async changeFieldValue(dataUnit, fieldName, value) {
1626
+ const du = this._dataUnits.get(dataUnit);
1627
+ if (du) {
1628
+ du.changeValue(fieldName, value);
1629
+ }
1630
+ }
1631
+ validateRecords(dataUnit, records, triggedBy) {
1632
+ const result = { isValid: true, message: "" };
1633
+ if (this.ignoreSaveValidation && triggedBy === "SAVE") {
1634
+ return result;
1635
+ }
1636
+ const validateField = (field) => {
1637
+ if (field.readOnly) {
1638
+ return false;
1639
+ }
1640
+ if (field.userInterface === "SWITCH" || field.userInterface === "CHECKBOX") {
1641
+ return false;
1642
+ }
1643
+ return true;
1644
+ };
1645
+ const recordValidator = record => {
1646
+ dataUnit.requiredFields.forEach(field => {
1647
+ if (validateField(field)) {
1648
+ const recordIndex = record["record__index"];
1649
+ const fieldName = field.name;
1650
+ const fieldValue = record[fieldName];
1651
+ if (fieldValue === null || fieldValue === undefined || fieldValue === "") {
1652
+ const tabPosition = this._tabPositionByField.get(dataUnit.name + field.name);
1653
+ this._store.dispatch(invalidField$1(tabPosition.tabName, tabPosition.index, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
1654
+ result.isValid = false;
1655
+ result.message = "Há pelo menos um campo obrigatório não preenchido.";
1656
+ }
1657
+ }
1658
+ });
1659
+ };
1660
+ if (dataUnit.records.length === 0) {
1661
+ recordValidator({});
1662
+ }
1663
+ else {
1664
+ let validatedRecords = {};
1665
+ records.forEach(r => {
1666
+ recordValidator(r);
1667
+ validatedRecords[r.record__id] = true;
1668
+ });
1669
+ dataUnit.records.forEach(r => {
1670
+ if (!validatedRecords[r.record__id]) {
1671
+ recordValidator(r);
1672
+ }
1673
+ });
1674
+ }
1675
+ return result;
1676
+ }
1677
+ loadMDFromExecutor(callBack) {
1678
+ const loadMetadataFunction = this.parseExecutor(this.metadataExecutor);
1679
+ if (loadMetadataFunction) {
1680
+ const result = loadMetadataFunction();
1681
+ if (result) {
1682
+ if (result instanceof Promise) {
1683
+ result.then(md => {
1684
+ callBack(md);
1685
+ });
1686
+ }
1687
+ else {
1688
+ callBack(result);
1689
+ }
1690
+ }
1691
+ }
1692
+ }
1693
+ loadMDFromElement(callBack) {
1694
+ const metadata = [];
1695
+ Array.from(this._host.children).forEach(elem => {
1696
+ if (elem.tagName === "FORM-METADATA") {
1697
+ const formMetadata = elem;
1698
+ metadata.push(formMetadata.metadata);
1699
+ }
1700
+ });
1701
+ callBack(metadata.length > 0 ? metadata : null);
1702
+ }
1703
+ updateMetadata(metadata) {
1704
+ if (metadata) {
1705
+ const processFields = (duName, form, tabController, tabIndex) => {
1706
+ var _a;
1707
+ form.items.forEach(item => {
1708
+ if ("fields" in item) {
1709
+ const fSet = item;
1710
+ fSet.fields.forEach(f => {
1711
+ f.form = this;
1712
+ this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
1713
+ });
1714
+ }
1715
+ else {
1716
+ const f = item;
1717
+ f.form = this;
1718
+ this._tabPositionByField.set(duName + f.name, { tabName: tabController, index: tabIndex });
1719
+ }
1720
+ });
1721
+ (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
1722
+ const subDu = subForm.dataUnit;
1723
+ if (subDu) {
1724
+ this._duSources.set(subDu.name, subDu);
1725
+ subDu.parentDUName = duName;
1726
+ }
1727
+ processFields(subDu ? subDu.name : duName, subForm, form.name, index);
1728
+ });
1729
+ };
1730
+ this._preparedMetadata = metadata.map((form, index) => {
1731
+ const du = form.dataUnit;
1732
+ if (form.autoLoad) {
1733
+ this._duToLoad.push(du);
1734
+ }
1735
+ this.decorateDU(du);
1736
+ const duName = du.name;
1737
+ this._duSources.set(duName, du);
1738
+ processFields(duName, form, "__MAIN__FORM__", index);
1739
+ return form;
1740
+ });
1741
+ this._store.dispatch(formLoad());
1742
+ }
1743
+ }
1744
+ parseExecutor(executor) {
1745
+ if (executor) {
1746
+ return executor instanceof Function ? executor : eval(executor);
1747
+ }
1748
+ return null;
1749
+ }
1750
+ componentWillRender() {
1751
+ if (this._store === undefined) {
1752
+ const rootReducer = combineReducers({
1753
+ "hist": undoable(formReducer),
1754
+ "nonhist": formNonHistoricReducer
1755
+ });
1756
+ this._store = createStore(rootReducer, applyMiddleware(thunk));
1757
+ this._store.subscribe(() => { forceUpdate(this); });
1758
+ if (this.slaveMode) {
1759
+ this._store.dispatch(showHideNavigationButtons("saveVisible", false));
1760
+ this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
1761
+ this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
1762
+ }
1763
+ }
1764
+ if (this._preparedMetadata === undefined) {
1765
+ if (this.metadata) {
1766
+ this.updateMetadata(this.metadata);
1767
+ }
1768
+ else {
1769
+ this.loadMDFromElement((md) => this.updateMetadata(md));
1770
+ if (!this._preparedMetadata) {
1771
+ this.loadMDFromExecutor((md) => this.updateMetadata(md));
1772
+ }
1773
+ }
1774
+ }
1775
+ }
1776
+ componentDidRender() {
1777
+ this._duToLoad.forEach(du => du.load());
1778
+ this._duToLoad = [];
1779
+ }
1780
+ loadSearch(argument, context) {
1781
+ const fieldSearchExecutor = this.parseExecutor(this.fieldSearchExecutor);
1782
+ if (fieldSearchExecutor) {
1783
+ return fieldSearchExecutor(argument, context);
1784
+ }
1785
+ else {
1786
+ return [{ value: 0, label: "Sem resultados" }];
1787
+ }
1788
+ }
1789
+ buildDataUnit(dataUnit, parentDataUnit) {
1790
+ if (dataUnit) {
1791
+ const { name, unitLabel, records, cardinality, fields } = dataUnit;
1792
+ if (!(dataUnit instanceof DataUnit)) {
1793
+ let parent;
1794
+ if (parentDataUnit instanceof DataUnit) {
1795
+ parent = parentDataUnit;
1796
+ }
1797
+ else {
1798
+ parent = this._dataUnits.get(parentDataUnit);
1799
+ }
1800
+ dataUnit = new DataUnit(name, unitLabel, cardinality, parent);
1801
+ dataUnit.fields = fields;
1802
+ this._dataUnits.set(dataUnit.name, dataUnit);
1803
+ if (records) {
1804
+ dataUnit.records = records;
1805
+ }
1806
+ }
1807
+ this.decorateDU(dataUnit);
1808
+ }
1809
+ return dataUnit;
1810
+ }
1811
+ decorateDU(dataUnit) {
1812
+ dataUnit.store = this._store;
1813
+ dataUnit.loadExecutor = this.parseExecutor(this.loadExecutor);
1814
+ dataUnit.saveExecutor = this.parseExecutor(this.saveExecutor);
1815
+ dataUnit.removeExecutor = this.parseExecutor(this.removeExecutor);
1816
+ dataUnit.recordsValidator = this;
1817
+ }
1818
+ render() {
1819
+ if (this.loading) {
1820
+ return h("place-holder", null);
1821
+ }
1822
+ else {
1823
+ return this._preparedMetadata ? h(FormSheet, { enabled: this.enabled, store: this._store, source: this._preparedMetadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
1824
+ }
1825
+ }
1826
+ static get assetsDirs() { return ["assets"]; }
1827
+ get _host() { return getElement(this); }
1828
+ static get watchers() { return {
1829
+ "metadata": ["cleanPreparedMetadata"]
1830
+ }; }
1831
+ };
1832
+ EzForm.style = ezFormCss;
1833
+
1834
+ export { EzForm as ez_form };