@stenajs-webui/redux 16.0.0 → 17.1.0
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/index.js
CHANGED
|
@@ -38,27 +38,29 @@ function __spreadArray(to, from, pack) {
|
|
|
38
38
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
var createRecordObjectReducer = function (reducer) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
var createRecordObjectReducer = function (reducer) {
|
|
42
|
+
return function (state, action) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (state === void 0) { state = {}; }
|
|
45
|
+
switch (action.type) {
|
|
46
|
+
case "RECORD_OBJECT:CLEAR_RECORD": {
|
|
47
|
+
var recordId = action.recordId;
|
|
48
|
+
var newState = __assign({}, state);
|
|
49
|
+
delete newState[recordId];
|
|
50
|
+
return newState;
|
|
51
|
+
}
|
|
52
|
+
case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
case "RECORD_OBJECT:ACTION": {
|
|
56
|
+
var recordId = action.recordId, innerAction = action.action;
|
|
57
|
+
return __assign(__assign({}, state), (_a = {}, _a[recordId] = reducer(state[recordId], innerAction), _a));
|
|
58
|
+
}
|
|
59
|
+
default:
|
|
60
|
+
return state;
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}; };
|
|
62
|
+
};
|
|
63
|
+
};
|
|
62
64
|
|
|
63
65
|
var createRecordObjectActions = function () { return ({
|
|
64
66
|
recordAction: function (recordId, action) { return ({
|
|
@@ -75,17 +77,19 @@ var createRecordObjectActions = function () { return ({
|
|
|
75
77
|
}); },
|
|
76
78
|
}); };
|
|
77
79
|
|
|
78
|
-
var reducerIdGate = function (reducerId, reducer) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
var reducerIdGate = function (reducerId, reducer) {
|
|
81
|
+
return function (state, action) {
|
|
82
|
+
var newState = state == null ? reducer(undefined, {}) : state;
|
|
83
|
+
if (!isValidReducerIdGateAction(action)) {
|
|
84
|
+
return newState;
|
|
85
|
+
}
|
|
86
|
+
if (reducerId !== action.reducerId ||
|
|
87
|
+
action.type !== "REDUCER_ID_GATE:ACTION") {
|
|
88
|
+
return newState;
|
|
89
|
+
}
|
|
90
|
+
return reducer(newState, action.action);
|
|
91
|
+
};
|
|
92
|
+
};
|
|
89
93
|
var reducerIdGateAction = function (reducerId, action) { return ({
|
|
90
94
|
type: "REDUCER_ID_GATE:ACTION",
|
|
91
95
|
action: action,
|
|
@@ -97,17 +101,19 @@ var isValidReducerIdGateAction = function (action) {
|
|
|
97
101
|
typeof action.reducerId === "string";
|
|
98
102
|
};
|
|
99
103
|
|
|
100
|
-
var wrapActionWithReducerIdGate = function (reducerId, actionCreator) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
var wrapActionWithReducerIdGate = function (reducerId, actionCreator) {
|
|
105
|
+
return function () {
|
|
106
|
+
var args = [];
|
|
107
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
108
|
+
args[_i] = arguments[_i];
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
type: "REDUCER_ID_GATE:ACTION",
|
|
112
|
+
reducerId: reducerId,
|
|
113
|
+
action: actionCreator.apply(void 0, args),
|
|
114
|
+
};
|
|
109
115
|
};
|
|
110
|
-
};
|
|
116
|
+
};
|
|
111
117
|
var wrapActionsWithReducerIdGate = function (reducerId, actionCreators) {
|
|
112
118
|
var boundActionCreators = {};
|
|
113
119
|
for (var key in actionCreators) {
|
|
@@ -135,26 +141,28 @@ var createCommitReducerActions = function (id) {
|
|
|
135
141
|
};
|
|
136
142
|
};
|
|
137
143
|
|
|
138
|
-
var createCommitReducer = function (id, initialState) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
switch (action.type) {
|
|
144
|
-
case "COMMIT_REDUCER.SET_VALUES": {
|
|
145
|
-
var values = action.values;
|
|
146
|
-
return __assign(__assign({}, state), { workspace: __assign(__assign({}, state.workspace), values) });
|
|
147
|
-
}
|
|
148
|
-
case "COMMIT_REDUCER.CLEAR": {
|
|
149
|
-
return __assign(__assign({}, state), { workspace: __assign({}, initialState.workspace) });
|
|
144
|
+
var createCommitReducer = function (id, initialState) {
|
|
145
|
+
return function (state, action) {
|
|
146
|
+
if (state === void 0) { state = initialState; }
|
|
147
|
+
if (action.id !== id) {
|
|
148
|
+
return state;
|
|
150
149
|
}
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
switch (action.type) {
|
|
151
|
+
case "COMMIT_REDUCER.SET_VALUES": {
|
|
152
|
+
var values = action.values;
|
|
153
|
+
return __assign(__assign({}, state), { workspace: __assign(__assign({}, state.workspace), values) });
|
|
154
|
+
}
|
|
155
|
+
case "COMMIT_REDUCER.CLEAR": {
|
|
156
|
+
return __assign(__assign({}, state), { workspace: __assign({}, initialState.workspace) });
|
|
157
|
+
}
|
|
158
|
+
case "COMMIT_REDUCER.COMMIT_VALUES": {
|
|
159
|
+
return __assign(__assign({}, state), { committed: __assign({}, state.workspace) });
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
return state;
|
|
153
163
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
}; };
|
|
164
|
+
};
|
|
165
|
+
};
|
|
158
166
|
|
|
159
167
|
var createCommitReducerSelectors = function (id, stateSelector) {
|
|
160
168
|
return {
|
|
@@ -215,100 +223,102 @@ var fieldsMatch = function (entity, fields) {
|
|
|
215
223
|
return true;
|
|
216
224
|
};
|
|
217
225
|
|
|
218
|
-
var createEntityListReducer = function (reducer) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
case "ENTITY_LIST:CLEAR_LIST": {
|
|
226
|
-
return [];
|
|
227
|
-
}
|
|
228
|
-
case "ENTITY_LIST:ADD_AT_END": {
|
|
229
|
-
var entity = action.entity;
|
|
230
|
-
return __spreadArray(__spreadArray([], state, true), [entity], false);
|
|
231
|
-
}
|
|
232
|
-
case "ENTITY_LIST:ADD_AT_START": {
|
|
233
|
-
var entity = action.entity;
|
|
234
|
-
return __spreadArray([entity], state, true);
|
|
235
|
-
}
|
|
236
|
-
case "ENTITY_LIST:REMOVE_FIRST": {
|
|
237
|
-
if (state.length === 0) {
|
|
238
|
-
throw new Error("Cannot remove, list is empty.");
|
|
226
|
+
var createEntityListReducer = function (reducer) {
|
|
227
|
+
return function (state, action) {
|
|
228
|
+
if (state === void 0) { state = []; }
|
|
229
|
+
switch (action.type) {
|
|
230
|
+
case "ENTITY_LIST:SET_LIST": {
|
|
231
|
+
var list = action.list;
|
|
232
|
+
return list;
|
|
239
233
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
case "ENTITY_LIST:REMOVE_LAST": {
|
|
244
|
-
if (state.length === 0) {
|
|
245
|
-
throw new Error("Cannot remove, list is empty.");
|
|
234
|
+
case "ENTITY_LIST:CLEAR_LIST": {
|
|
235
|
+
return [];
|
|
246
236
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
case "ENTITY_LIST:REMOVE_AT_INDEX": {
|
|
252
|
-
var index = action.index;
|
|
253
|
-
if (index < 0) {
|
|
254
|
-
throw new Error("Index is lower than 0.");
|
|
237
|
+
case "ENTITY_LIST:ADD_AT_END": {
|
|
238
|
+
var entity = action.entity;
|
|
239
|
+
return __spreadArray(__spreadArray([], state, true), [entity], false);
|
|
255
240
|
}
|
|
256
|
-
|
|
257
|
-
|
|
241
|
+
case "ENTITY_LIST:ADD_AT_START": {
|
|
242
|
+
var entity = action.entity;
|
|
243
|
+
return __spreadArray([entity], state, true);
|
|
258
244
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
case "ENTITY_LIST:TOGGLE": {
|
|
272
|
-
var entity_2 = action.entity;
|
|
273
|
-
var index = state.findIndex(function (item) { return item === entity_2 || fieldsMatch(item, entity_2); });
|
|
274
|
-
if (index >= 0) {
|
|
245
|
+
case "ENTITY_LIST:REMOVE_FIRST": {
|
|
246
|
+
if (state.length === 0) {
|
|
247
|
+
throw new Error("Cannot remove, list is empty.");
|
|
248
|
+
}
|
|
249
|
+
var list = state.slice(1);
|
|
250
|
+
return list;
|
|
251
|
+
}
|
|
252
|
+
case "ENTITY_LIST:REMOVE_LAST": {
|
|
253
|
+
if (state.length === 0) {
|
|
254
|
+
throw new Error("Cannot remove, list is empty.");
|
|
255
|
+
}
|
|
275
256
|
var list = __spreadArray([], state, true);
|
|
276
|
-
list.
|
|
257
|
+
list.pop();
|
|
277
258
|
return list;
|
|
278
259
|
}
|
|
279
|
-
|
|
280
|
-
|
|
260
|
+
case "ENTITY_LIST:REMOVE_AT_INDEX": {
|
|
261
|
+
var index = action.index;
|
|
262
|
+
if (index < 0) {
|
|
263
|
+
throw new Error("Index is lower than 0.");
|
|
264
|
+
}
|
|
265
|
+
if (index >= state.length) {
|
|
266
|
+
throw new Error("Index is outside of list bounds.");
|
|
267
|
+
}
|
|
268
|
+
var list = __spreadArray([], state, true);
|
|
269
|
+
list.splice(index, 1);
|
|
270
|
+
return list;
|
|
281
271
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (!reducer) {
|
|
286
|
-
throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
|
|
287
|
-
}
|
|
288
|
-
return state.map(function (item) {
|
|
289
|
-
return fieldsMatch(item, fields_2) ? reducer(item, innerAction_1) : item;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
case "ENTITY_LIST:ACTION_BY_INDEX": {
|
|
293
|
-
var index_1 = action.index, innerAction_2 = action.action;
|
|
294
|
-
if (!reducer) {
|
|
295
|
-
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
296
|
-
}
|
|
297
|
-
return state.map(function (item, i) {
|
|
298
|
-
return index_1 === i ? reducer(item, innerAction_2) : item;
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
case "ENTITY_LIST:ACTION_ON_ALL": {
|
|
302
|
-
var innerAction_3 = action.action;
|
|
303
|
-
if (!reducer) {
|
|
304
|
-
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
272
|
+
case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
|
|
273
|
+
var fields_1 = action.fields;
|
|
274
|
+
return state.filter(function (item) { return !fieldsMatch(item, fields_1); });
|
|
305
275
|
}
|
|
306
|
-
|
|
276
|
+
case "ENTITY_LIST:REMOVE": {
|
|
277
|
+
var entity_1 = action.entity;
|
|
278
|
+
return state.filter(function (item) { return item !== entity_1; });
|
|
279
|
+
}
|
|
280
|
+
case "ENTITY_LIST:TOGGLE": {
|
|
281
|
+
var entity_2 = action.entity;
|
|
282
|
+
var index = state.findIndex(function (item) { return item === entity_2 || fieldsMatch(item, entity_2); });
|
|
283
|
+
if (index >= 0) {
|
|
284
|
+
var list = __spreadArray([], state, true);
|
|
285
|
+
list.splice(index, index);
|
|
286
|
+
return list;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return __spreadArray(__spreadArray([], state, true), [entity_2], false);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
|
|
293
|
+
var fields_2 = action.fields, innerAction_1 = action.action;
|
|
294
|
+
if (!reducer) {
|
|
295
|
+
throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
|
|
296
|
+
}
|
|
297
|
+
return state.map(function (item) {
|
|
298
|
+
return fieldsMatch(item, fields_2) ? reducer(item, innerAction_1) : item;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
case "ENTITY_LIST:ACTION_BY_INDEX": {
|
|
302
|
+
var index_1 = action.index, innerAction_2 = action.action;
|
|
303
|
+
if (!reducer) {
|
|
304
|
+
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
305
|
+
}
|
|
306
|
+
return state.map(function (item, i) {
|
|
307
|
+
return index_1 === i ? reducer(item, innerAction_2) : item;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
case "ENTITY_LIST:ACTION_ON_ALL": {
|
|
311
|
+
var innerAction_3 = action.action;
|
|
312
|
+
if (!reducer) {
|
|
313
|
+
throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
|
|
314
|
+
}
|
|
315
|
+
return state.map(function (item) { return reducer(item, innerAction_3); });
|
|
316
|
+
}
|
|
317
|
+
default:
|
|
318
|
+
return state;
|
|
307
319
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
}; };
|
|
320
|
+
};
|
|
321
|
+
};
|
|
312
322
|
|
|
313
323
|
var createEntityListSelectors = function (stateSelector) { return ({
|
|
314
324
|
getList: function (store) { return stateSelector(store); },
|
|
@@ -540,17 +550,19 @@ var createSelectedIdsSelectors = function (stateSelector) { return ({
|
|
|
540
550
|
var INITIAL_STATE = {
|
|
541
551
|
ids: undefined,
|
|
542
552
|
};
|
|
543
|
-
var createSortOrderByIdReducer = function () {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
553
|
+
var createSortOrderByIdReducer = function () {
|
|
554
|
+
return function (state, action) {
|
|
555
|
+
if (state === void 0) { state = INITIAL_STATE; }
|
|
556
|
+
switch (action.type) {
|
|
557
|
+
case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
|
|
558
|
+
return __assign(__assign({}, state), { ids: action.ids });
|
|
559
|
+
case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
|
|
560
|
+
return __assign(__assign({}, state), { ids: undefined });
|
|
561
|
+
default:
|
|
562
|
+
return state;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
};
|
|
554
566
|
var sortOrderByIdReducer = createSortOrderByIdReducer();
|
|
555
567
|
|
|
556
568
|
var createSortOrderByIdActions = function () {
|