@stenajs-webui/redux 15.7.0 → 17.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # v17.0.0 (Fri Jun 17 2022)
2
+
3
+ #### 💥 Breaking Change
4
+
5
+ - Upgrade and apply prettier. [#467](https://github.com/StenaIT/stenajs-webui/pull/467) ([@mattias800](https://github.com/mattias800))
6
+
7
+ #### 🔩 Dependency Updates
8
+
9
+ - Update Typescript, React, Jest, etc. [#466](https://github.com/StenaIT/stenajs-webui/pull/466) ([@mattias800](https://github.com/mattias800))
10
+
11
+ #### Authors: 1
12
+
13
+ - Mattias Andersson ([@mattias800](https://github.com/mattias800))
14
+
15
+ ---
16
+
1
17
  # v15.1.0 (Fri Feb 25 2022)
2
18
 
3
19
  #### 🚀 Enhancement
@@ -5,4 +5,4 @@ export interface EditableEntityState<T> {
5
5
  persisted: T;
6
6
  editable: T;
7
7
  }
8
- export declare const createEditableEntityReducer: <T>(initialEntity: T, initialId?: string | undefined) => Reducer<EditableEntityState<T>, EditableEntityAction<T>>;
8
+ export declare const createEditableEntityReducer: <T>(initialEntity: T, initialId?: string) => Reducer<EditableEntityState<T>, EditableEntityAction<T>>;
package/dist/index.es.js CHANGED
@@ -34,27 +34,29 @@ function __spreadArray(to, from, pack) {
34
34
  return to.concat(ar || Array.prototype.slice.call(from));
35
35
  }
36
36
 
37
- var createRecordObjectReducer = function (reducer) { return function (state, action) {
38
- var _a;
39
- if (state === void 0) { state = {}; }
40
- switch (action.type) {
41
- case "RECORD_OBJECT:CLEAR_RECORD": {
42
- var recordId = action.recordId;
43
- var newState = __assign({}, state);
44
- delete newState[recordId];
45
- return newState;
46
- }
47
- case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
48
- return {};
49
- }
50
- case "RECORD_OBJECT:ACTION": {
51
- var recordId = action.recordId, innerAction = action.action;
52
- return __assign(__assign({}, state), (_a = {}, _a[recordId] = reducer(state[recordId], innerAction), _a));
37
+ var createRecordObjectReducer = function (reducer) {
38
+ return function (state, action) {
39
+ var _a;
40
+ if (state === void 0) { state = {}; }
41
+ switch (action.type) {
42
+ case "RECORD_OBJECT:CLEAR_RECORD": {
43
+ var recordId = action.recordId;
44
+ var newState = __assign({}, state);
45
+ delete newState[recordId];
46
+ return newState;
47
+ }
48
+ case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
49
+ return {};
50
+ }
51
+ case "RECORD_OBJECT:ACTION": {
52
+ var recordId = action.recordId, innerAction = action.action;
53
+ return __assign(__assign({}, state), (_a = {}, _a[recordId] = reducer(state[recordId], innerAction), _a));
54
+ }
55
+ default:
56
+ return state;
53
57
  }
54
- default:
55
- return state;
56
- }
57
- }; };
58
+ };
59
+ };
58
60
 
59
61
  var createRecordObjectActions = function () { return ({
60
62
  recordAction: function (recordId, action) { return ({
@@ -71,17 +73,19 @@ var createRecordObjectActions = function () { return ({
71
73
  }); },
72
74
  }); };
73
75
 
74
- var reducerIdGate = function (reducerId, reducer) { return function (state, action) {
75
- var newState = state == null ? reducer(undefined, {}) : state;
76
- if (!isValidReducerIdGateAction(action)) {
77
- return newState;
78
- }
79
- if (reducerId !== action.reducerId ||
80
- action.type !== "REDUCER_ID_GATE:ACTION") {
81
- return newState;
82
- }
83
- return reducer(newState, action.action);
84
- }; };
76
+ var reducerIdGate = function (reducerId, reducer) {
77
+ return function (state, action) {
78
+ var newState = state == null ? reducer(undefined, {}) : state;
79
+ if (!isValidReducerIdGateAction(action)) {
80
+ return newState;
81
+ }
82
+ if (reducerId !== action.reducerId ||
83
+ action.type !== "REDUCER_ID_GATE:ACTION") {
84
+ return newState;
85
+ }
86
+ return reducer(newState, action.action);
87
+ };
88
+ };
85
89
  var reducerIdGateAction = function (reducerId, action) { return ({
86
90
  type: "REDUCER_ID_GATE:ACTION",
87
91
  action: action,
@@ -93,17 +97,19 @@ var isValidReducerIdGateAction = function (action) {
93
97
  typeof action.reducerId === "string";
94
98
  };
95
99
 
96
- var wrapActionWithReducerIdGate = function (reducerId, actionCreator) { return function () {
97
- var args = [];
98
- for (var _i = 0; _i < arguments.length; _i++) {
99
- args[_i] = arguments[_i];
100
- }
101
- return {
102
- type: "REDUCER_ID_GATE:ACTION",
103
- reducerId: reducerId,
104
- action: actionCreator.apply(void 0, args),
100
+ var wrapActionWithReducerIdGate = function (reducerId, actionCreator) {
101
+ return function () {
102
+ var args = [];
103
+ for (var _i = 0; _i < arguments.length; _i++) {
104
+ args[_i] = arguments[_i];
105
+ }
106
+ return {
107
+ type: "REDUCER_ID_GATE:ACTION",
108
+ reducerId: reducerId,
109
+ action: actionCreator.apply(void 0, args),
110
+ };
105
111
  };
106
- }; };
112
+ };
107
113
  var wrapActionsWithReducerIdGate = function (reducerId, actionCreators) {
108
114
  var boundActionCreators = {};
109
115
  for (var key in actionCreators) {
@@ -131,26 +137,28 @@ var createCommitReducerActions = function (id) {
131
137
  };
132
138
  };
133
139
 
134
- var createCommitReducer = function (id, initialState) { return function (state, action) {
135
- if (state === void 0) { state = initialState; }
136
- if (action.id !== id) {
137
- return state;
138
- }
139
- switch (action.type) {
140
- case "COMMIT_REDUCER.SET_VALUES": {
141
- var values = action.values;
142
- return __assign(__assign({}, state), { workspace: __assign(__assign({}, state.workspace), values) });
143
- }
144
- case "COMMIT_REDUCER.CLEAR": {
145
- return __assign(__assign({}, state), { workspace: __assign({}, initialState.workspace) });
140
+ var createCommitReducer = function (id, initialState) {
141
+ return function (state, action) {
142
+ if (state === void 0) { state = initialState; }
143
+ if (action.id !== id) {
144
+ return state;
146
145
  }
147
- case "COMMIT_REDUCER.COMMIT_VALUES": {
148
- return __assign(__assign({}, state), { committed: __assign({}, state.workspace) });
146
+ switch (action.type) {
147
+ case "COMMIT_REDUCER.SET_VALUES": {
148
+ var values = action.values;
149
+ return __assign(__assign({}, state), { workspace: __assign(__assign({}, state.workspace), values) });
150
+ }
151
+ case "COMMIT_REDUCER.CLEAR": {
152
+ return __assign(__assign({}, state), { workspace: __assign({}, initialState.workspace) });
153
+ }
154
+ case "COMMIT_REDUCER.COMMIT_VALUES": {
155
+ return __assign(__assign({}, state), { committed: __assign({}, state.workspace) });
156
+ }
157
+ default:
158
+ return state;
149
159
  }
150
- default:
151
- return state;
152
- }
153
- }; };
160
+ };
161
+ };
154
162
 
155
163
  var createCommitReducerSelectors = function (id, stateSelector) {
156
164
  return {
@@ -211,100 +219,102 @@ var fieldsMatch = function (entity, fields) {
211
219
  return true;
212
220
  };
213
221
 
214
- var createEntityListReducer = function (reducer) { return function (state, action) {
215
- if (state === void 0) { state = []; }
216
- switch (action.type) {
217
- case "ENTITY_LIST:SET_LIST": {
218
- var list = action.list;
219
- return list;
220
- }
221
- case "ENTITY_LIST:CLEAR_LIST": {
222
- return [];
223
- }
224
- case "ENTITY_LIST:ADD_AT_END": {
225
- var entity = action.entity;
226
- return __spreadArray(__spreadArray([], state, true), [entity], false);
227
- }
228
- case "ENTITY_LIST:ADD_AT_START": {
229
- var entity = action.entity;
230
- return __spreadArray([entity], state, true);
231
- }
232
- case "ENTITY_LIST:REMOVE_FIRST": {
233
- if (state.length === 0) {
234
- throw new Error("Cannot remove, list is empty.");
222
+ var createEntityListReducer = function (reducer) {
223
+ return function (state, action) {
224
+ if (state === void 0) { state = []; }
225
+ switch (action.type) {
226
+ case "ENTITY_LIST:SET_LIST": {
227
+ var list = action.list;
228
+ return list;
235
229
  }
236
- var list = state.slice(1);
237
- return list;
238
- }
239
- case "ENTITY_LIST:REMOVE_LAST": {
240
- if (state.length === 0) {
241
- throw new Error("Cannot remove, list is empty.");
230
+ case "ENTITY_LIST:CLEAR_LIST": {
231
+ return [];
242
232
  }
243
- var list = __spreadArray([], state, true);
244
- list.pop();
245
- return list;
246
- }
247
- case "ENTITY_LIST:REMOVE_AT_INDEX": {
248
- var index = action.index;
249
- if (index < 0) {
250
- throw new Error("Index is lower than 0.");
233
+ case "ENTITY_LIST:ADD_AT_END": {
234
+ var entity = action.entity;
235
+ return __spreadArray(__spreadArray([], state, true), [entity], false);
251
236
  }
252
- if (index >= state.length) {
253
- throw new Error("Index is outside of list bounds.");
237
+ case "ENTITY_LIST:ADD_AT_START": {
238
+ var entity = action.entity;
239
+ return __spreadArray([entity], state, true);
254
240
  }
255
- var list = __spreadArray([], state, true);
256
- list.splice(index, 1);
257
- return list;
258
- }
259
- case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
260
- var fields_1 = action.fields;
261
- return state.filter(function (item) { return !fieldsMatch(item, fields_1); });
262
- }
263
- case "ENTITY_LIST:REMOVE": {
264
- var entity_1 = action.entity;
265
- return state.filter(function (item) { return item !== entity_1; });
266
- }
267
- case "ENTITY_LIST:TOGGLE": {
268
- var entity_2 = action.entity;
269
- var index = state.findIndex(function (item) { return item === entity_2 || fieldsMatch(item, entity_2); });
270
- if (index >= 0) {
241
+ case "ENTITY_LIST:REMOVE_FIRST": {
242
+ if (state.length === 0) {
243
+ throw new Error("Cannot remove, list is empty.");
244
+ }
245
+ var list = state.slice(1);
246
+ return list;
247
+ }
248
+ case "ENTITY_LIST:REMOVE_LAST": {
249
+ if (state.length === 0) {
250
+ throw new Error("Cannot remove, list is empty.");
251
+ }
271
252
  var list = __spreadArray([], state, true);
272
- list.splice(index, index);
253
+ list.pop();
273
254
  return list;
274
255
  }
275
- else {
276
- return __spreadArray(__spreadArray([], state, true), [entity_2], false);
256
+ case "ENTITY_LIST:REMOVE_AT_INDEX": {
257
+ var index = action.index;
258
+ if (index < 0) {
259
+ throw new Error("Index is lower than 0.");
260
+ }
261
+ if (index >= state.length) {
262
+ throw new Error("Index is outside of list bounds.");
263
+ }
264
+ var list = __spreadArray([], state, true);
265
+ list.splice(index, 1);
266
+ return list;
277
267
  }
278
- }
279
- case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
280
- var fields_2 = action.fields, innerAction_1 = action.action;
281
- if (!reducer) {
282
- throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
283
- }
284
- return state.map(function (item) {
285
- return fieldsMatch(item, fields_2) ? reducer(item, innerAction_1) : item;
286
- });
287
- }
288
- case "ENTITY_LIST:ACTION_BY_INDEX": {
289
- var index_1 = action.index, innerAction_2 = action.action;
290
- if (!reducer) {
291
- throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
292
- }
293
- return state.map(function (item, i) {
294
- return index_1 === i ? reducer(item, innerAction_2) : item;
295
- });
296
- }
297
- case "ENTITY_LIST:ACTION_ON_ALL": {
298
- var innerAction_3 = action.action;
299
- if (!reducer) {
300
- throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
268
+ case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
269
+ var fields_1 = action.fields;
270
+ return state.filter(function (item) { return !fieldsMatch(item, fields_1); });
301
271
  }
302
- return state.map(function (item) { return reducer(item, innerAction_3); });
272
+ case "ENTITY_LIST:REMOVE": {
273
+ var entity_1 = action.entity;
274
+ return state.filter(function (item) { return item !== entity_1; });
275
+ }
276
+ case "ENTITY_LIST:TOGGLE": {
277
+ var entity_2 = action.entity;
278
+ var index = state.findIndex(function (item) { return item === entity_2 || fieldsMatch(item, entity_2); });
279
+ if (index >= 0) {
280
+ var list = __spreadArray([], state, true);
281
+ list.splice(index, index);
282
+ return list;
283
+ }
284
+ else {
285
+ return __spreadArray(__spreadArray([], state, true), [entity_2], false);
286
+ }
287
+ }
288
+ case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
289
+ var fields_2 = action.fields, innerAction_1 = action.action;
290
+ if (!reducer) {
291
+ throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
292
+ }
293
+ return state.map(function (item) {
294
+ return fieldsMatch(item, fields_2) ? reducer(item, innerAction_1) : item;
295
+ });
296
+ }
297
+ case "ENTITY_LIST:ACTION_BY_INDEX": {
298
+ var index_1 = action.index, innerAction_2 = action.action;
299
+ if (!reducer) {
300
+ throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
301
+ }
302
+ return state.map(function (item, i) {
303
+ return index_1 === i ? reducer(item, innerAction_2) : item;
304
+ });
305
+ }
306
+ case "ENTITY_LIST:ACTION_ON_ALL": {
307
+ var innerAction_3 = action.action;
308
+ if (!reducer) {
309
+ throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
310
+ }
311
+ return state.map(function (item) { return reducer(item, innerAction_3); });
312
+ }
313
+ default:
314
+ return state;
303
315
  }
304
- default:
305
- return state;
306
- }
307
- }; };
316
+ };
317
+ };
308
318
 
309
319
  var createEntityListSelectors = function (stateSelector) { return ({
310
320
  getList: function (store) { return stateSelector(store); },
@@ -536,17 +546,19 @@ var createSelectedIdsSelectors = function (stateSelector) { return ({
536
546
  var INITIAL_STATE = {
537
547
  ids: undefined,
538
548
  };
539
- var createSortOrderByIdReducer = function () { return function (state, action) {
540
- if (state === void 0) { state = INITIAL_STATE; }
541
- switch (action.type) {
542
- case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
543
- return __assign(__assign({}, state), { ids: action.ids });
544
- case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
545
- return __assign(__assign({}, state), { ids: undefined });
546
- default:
547
- return state;
548
- }
549
- }; };
549
+ var createSortOrderByIdReducer = function () {
550
+ return function (state, action) {
551
+ if (state === void 0) { state = INITIAL_STATE; }
552
+ switch (action.type) {
553
+ case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
554
+ return __assign(__assign({}, state), { ids: action.ids });
555
+ case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
556
+ return __assign(__assign({}, state), { ids: undefined });
557
+ default:
558
+ return state;
559
+ }
560
+ };
561
+ };
550
562
  var sortOrderByIdReducer = createSortOrderByIdReducer();
551
563
 
552
564
  var createSortOrderByIdActions = function () {