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