@stenajs-webui/redux 17.6.0 → 17.7.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/common/ActionWithReducerId.d.ts +3 -3
  3. package/dist/common/EntityWithId.d.ts +3 -3
  4. package/dist/common/util/field-matcher.d.ts +1 -1
  5. package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-action-creators.d.ts +17 -17
  6. package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-actions.d.ts +52 -52
  7. package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-reducer.d.ts +4 -4
  8. package/dist/features/higher-order-reducers/entity-list-reducer/entity-list-selectors.d.ts +6 -6
  9. package/dist/features/higher-order-reducers/record-object-reducer/record-object-action-creators.d.ts +7 -7
  10. package/dist/features/higher-order-reducers/record-object-reducer/record-object-actions.d.ts +17 -17
  11. package/dist/features/higher-order-reducers/record-object-reducer/record-object-reducer.d.ts +4 -4
  12. package/dist/features/higher-order-reducers/reducer-id-gate/reducer-id-action-wrapper.d.ts +12 -12
  13. package/dist/features/higher-order-reducers/reducer-id-gate/reducer-id-gate.d.ts +9 -9
  14. package/dist/features/reducer-factories/commit-reducer/commit-action-creators.d.ts +7 -7
  15. package/dist/features/reducer-factories/commit-reducer/commit-actions.d.ts +18 -18
  16. package/dist/features/reducer-factories/commit-reducer/commit-reducer.d.ts +3 -3
  17. package/dist/features/reducer-factories/commit-reducer/commit-selectors.d.ts +7 -7
  18. package/dist/features/reducer-factories/commit-reducer/commit-state.d.ts +4 -4
  19. package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-action-creators.d.ts +11 -11
  20. package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-actions.d.ts +27 -27
  21. package/dist/features/reducer-factories/editable-entity-reducer/editable-entity-reducer.d.ts +8 -8
  22. package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-action-creators.d.ts +9 -9
  23. package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-actions.d.ts +18 -18
  24. package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-reducer.d.ts +11 -11
  25. package/dist/features/reducer-factories/entity-by-id-reducer/entity-by-id-selectors.d.ts +7 -7
  26. package/dist/features/reducer-factories/entity-crud-status-reducer/entity-crud-status-redux.d.ts +31 -31
  27. package/dist/features/reducer-factories/entity-reducer/entity-action-creators.d.ts +6 -6
  28. package/dist/features/reducer-factories/entity-reducer/entity-actions.d.ts +9 -9
  29. package/dist/features/reducer-factories/entity-reducer/entity-reducer.d.ts +4 -4
  30. package/dist/features/reducer-factories/entity-reducer/entity-selectors.d.ts +6 -6
  31. package/dist/features/reducer-factories/modified-field-reducer/modified-field-redux.d.ts +23 -23
  32. package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-action-creators.d.ts +7 -7
  33. package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-actions.d.ts +8 -8
  34. package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-reducer.d.ts +9 -9
  35. package/dist/features/reducer-factories/selected-ids-reducer/selected-ids-selectors.d.ts +6 -6
  36. package/dist/features/reducer-factories/sort-order-by-id-reducer/hooks/use-sort-order-by-id.d.ts +3 -3
  37. package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-action-creators.d.ts +7 -7
  38. package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-actions.d.ts +8 -8
  39. package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-reducer.d.ts +6 -6
  40. package/dist/features/reducer-factories/sort-order-by-id-reducer/sort-order-by-id-selectors.d.ts +8 -8
  41. package/dist/features/reducer-factories/sort-order-reducer/sort-order-action-creators.d.ts +6 -6
  42. package/dist/features/reducer-factories/sort-order-reducer/sort-order-actions.d.ts +9 -9
  43. package/dist/features/reducer-factories/sort-order-reducer/sort-order-reducer.d.ts +9 -9
  44. package/dist/features/reducer-factories/sort-order-reducer/sort-order-selectors.d.ts +6 -6
  45. package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-action-creators.d.ts +7 -7
  46. package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-actions.d.ts +13 -13
  47. package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-reducer.d.ts +10 -10
  48. package/dist/features/reducer-factories/value-by-id-reducer/value-by-id-selectors.d.ts +6 -6
  49. package/dist/index.d.ts +44 -44
  50. package/dist/index.es.js +634 -656
  51. package/dist/index.es.js.map +1 -1
  52. package/dist/index.js +1 -722
  53. package/dist/index.js.map +1 -1
  54. package/package.json +5 -6
  55. package/dist/common/util/__tests__/field-matcher.test.d.ts +0 -1
  56. package/dist/features/higher-order-reducers/entity-list-reducer/__tests__/entity-list-reducer.test.d.ts +0 -1
  57. package/dist/features/higher-order-reducers/record-object-reducer/__tests__/record-object-reducer.test.d.ts +0 -1
  58. package/dist/features/higher-order-reducers/reducer-id-gate/__tests__/reducer-id-gate.test.d.ts +0 -1
  59. package/dist/features/reducer-factories/entity-by-id-reducer/__tests__/entity-by-id-reducer.test.d.ts +0 -1
  60. package/dist/features/reducer-factories/entity-reducer/__tests__/entity-reducer.test.d.ts +0 -1
  61. package/dist/features/reducer-factories/selected-ids-reducer/__tests__/selected-ids-reducer.test.d.ts +0 -1
  62. package/dist/features/reducer-factories/sort-order-by-id-reducer/__tests__/sort-order-by-id-reducer.test.d.ts +0 -1
  63. package/dist/features/reducer-factories/sort-order-reducer/__tests__/sort-order-reducer.test.d.ts +0 -1
  64. package/dist/features/reducer-factories/value-by-id-reducer/__tests__/value-by-id-reducer.test.d.ts +0 -1
package/dist/index.es.js CHANGED
@@ -1,675 +1,653 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- var __assign = function() {
17
- __assign = Object.assign || function __assign(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
-
27
- function __spreadArray(to, from, pack) {
28
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
29
- if (ar || !(i in from)) {
30
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
31
- ar[i] = from[i];
32
- }
33
- }
34
- return to.concat(ar || Array.prototype.slice.call(from));
35
- }
36
-
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;
57
- }
58
- };
1
+ (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();const createRecordObjectReducer = (reducer) => (state = {}, action) => {
2
+ switch (action.type) {
3
+ case "RECORD_OBJECT:CLEAR_RECORD": {
4
+ const { recordId } = action;
5
+ const newState = { ...state };
6
+ delete newState[recordId];
7
+ return newState;
8
+ }
9
+ case "RECORD_OBJECT:CLEAR_ALL_RECORDS": {
10
+ return {};
11
+ }
12
+ case "RECORD_OBJECT:ACTION": {
13
+ const { recordId, action: innerAction } = action;
14
+ return {
15
+ ...state,
16
+ [recordId]: reducer(state[recordId], innerAction)
17
+ };
18
+ }
19
+ default:
20
+ return state;
21
+ }
59
22
  };
60
-
61
- var createRecordObjectActions = function () { return ({
62
- recordAction: function (recordId, action) { return ({
63
- type: "RECORD_OBJECT:ACTION",
64
- action: action,
65
- recordId: recordId,
66
- }); },
67
- clearRecord: function (recordId) { return ({
68
- type: "RECORD_OBJECT:CLEAR_RECORD",
69
- recordId: recordId,
70
- }); },
71
- clearAllRecords: function () { return ({
72
- type: "RECORD_OBJECT:CLEAR_ALL_RECORDS",
73
- }); },
74
- }); };
75
-
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
- };
89
- var reducerIdGateAction = function (reducerId, action) { return ({
90
- type: "REDUCER_ID_GATE:ACTION",
91
- action: action,
92
- reducerId: reducerId,
93
- }); };
94
- var isValidReducerIdGateAction = function (action) {
95
- return !!action.action &&
96
- action.type === "REDUCER_ID_GATE:ACTION" &&
97
- typeof action.reducerId === "string";
23
+ const createRecordObjectActions = () => ({
24
+ recordAction: (recordId, action) => ({
25
+ type: "RECORD_OBJECT:ACTION",
26
+ action,
27
+ recordId
28
+ }),
29
+ clearRecord: (recordId) => ({
30
+ type: "RECORD_OBJECT:CLEAR_RECORD",
31
+ recordId
32
+ }),
33
+ clearAllRecords: () => ({
34
+ type: "RECORD_OBJECT:CLEAR_ALL_RECORDS"
35
+ })
36
+ });
37
+ const reducerIdGate = (reducerId, reducer) => (state, action) => {
38
+ let newState = state == null ? reducer(void 0, {}) : state;
39
+ if (!isValidReducerIdGateAction(action)) {
40
+ return newState;
41
+ }
42
+ if (reducerId !== action.reducerId || action.type !== "REDUCER_ID_GATE:ACTION") {
43
+ return newState;
44
+ }
45
+ return reducer(newState, action.action);
98
46
  };
99
-
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
- };
111
- };
112
- };
113
- var wrapActionsWithReducerIdGate = function (reducerId, actionCreators) {
114
- var boundActionCreators = {};
115
- for (var key in actionCreators) {
116
- var actionCreator = actionCreators[key];
117
- boundActionCreators[key] = wrapActionWithReducerIdGate(reducerId, actionCreator);
118
- }
119
- return boundActionCreators;
47
+ const reducerIdGateAction = (reducerId, action) => ({
48
+ type: "REDUCER_ID_GATE:ACTION",
49
+ action,
50
+ reducerId
51
+ });
52
+ const isValidReducerIdGateAction = (action) => !!action.action && action.type === "REDUCER_ID_GATE:ACTION" && typeof action.reducerId === "string";
53
+ const wrapActionWithReducerIdGate = (reducerId, actionCreator) => (...args) => {
54
+ return {
55
+ type: "REDUCER_ID_GATE:ACTION",
56
+ reducerId,
57
+ action: actionCreator(...args)
58
+ };
120
59
  };
121
-
122
- var createCommitReducerActions = function (id) {
123
- return {
124
- setValues: function (values) { return ({
125
- type: "COMMIT_REDUCER.SET_VALUES",
126
- id: id,
127
- values: values,
128
- }); },
129
- commitValues: function () { return ({
130
- type: "COMMIT_REDUCER.COMMIT_VALUES",
131
- id: id,
132
- }); },
133
- clearValues: function () { return ({
134
- type: "COMMIT_REDUCER.CLEAR",
135
- id: id,
136
- }); },
137
- };
60
+ const wrapActionsWithReducerIdGate = (reducerId, actionCreators) => {
61
+ const boundActionCreators = {};
62
+ for (const key in actionCreators) {
63
+ const actionCreator = actionCreators[key];
64
+ boundActionCreators[key] = wrapActionWithReducerIdGate(reducerId, actionCreator);
65
+ }
66
+ return boundActionCreators;
138
67
  };
139
-
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;
145
- }
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;
159
- }
160
- };
68
+ const createCommitReducerActions = (id) => {
69
+ return {
70
+ setValues: (values) => ({
71
+ type: "COMMIT_REDUCER.SET_VALUES",
72
+ id,
73
+ values
74
+ }),
75
+ commitValues: () => ({
76
+ type: "COMMIT_REDUCER.COMMIT_VALUES",
77
+ id
78
+ }),
79
+ clearValues: () => ({
80
+ type: "COMMIT_REDUCER.CLEAR",
81
+ id
82
+ })
83
+ };
161
84
  };
162
-
163
- var createCommitReducerSelectors = function (id, stateSelector) {
164
- return {
165
- getWorkspaceValues: function (state) { return stateSelector(state, id).workspace; },
166
- getCommittedValues: function (state) { return stateSelector(state, id).committed; },
167
- };
85
+ const createCommitReducer = (id, initialState) => (state = initialState, action) => {
86
+ if (action.id !== id) {
87
+ return state;
88
+ }
89
+ switch (action.type) {
90
+ case `COMMIT_REDUCER.SET_VALUES`: {
91
+ const { values } = action;
92
+ return {
93
+ ...state,
94
+ workspace: {
95
+ ...state.workspace,
96
+ ...values
97
+ }
98
+ };
99
+ }
100
+ case `COMMIT_REDUCER.CLEAR`: {
101
+ return {
102
+ ...state,
103
+ workspace: {
104
+ ...initialState.workspace
105
+ }
106
+ };
107
+ }
108
+ case `COMMIT_REDUCER.COMMIT_VALUES`: {
109
+ return {
110
+ ...state,
111
+ committed: {
112
+ ...state.workspace
113
+ }
114
+ };
115
+ }
116
+ default:
117
+ return state;
118
+ }
168
119
  };
169
-
170
- var createEntityListActions = function () {
171
- return {
172
- addAtEnd: function (entity) { return ({ type: "ENTITY_LIST:ADD_AT_END", entity: entity }); },
173
- addAtStart: function (entity) { return ({
174
- entity: entity,
175
- type: "ENTITY_LIST:ADD_AT_START",
176
- }); },
177
- clearList: function () { return ({ type: "ENTITY_LIST:CLEAR_LIST" }); },
178
- removeFirst: function () { return ({ type: "ENTITY_LIST:REMOVE_FIRST" }); },
179
- removeLast: function () { return ({ type: "ENTITY_LIST:REMOVE_LAST" }); },
180
- removeAtIndex: function (index) { return ({
181
- type: "ENTITY_LIST:REMOVE_AT_INDEX",
182
- index: index,
183
- }); },
184
- removeByFieldMatch: function (fields) { return ({
185
- type: "ENTITY_LIST:REMOVE_BY_FIELD_MATCH",
186
- fields: fields,
187
- }); },
188
- remove: function (entity) { return ({ type: "ENTITY_LIST:REMOVE", entity: entity }); },
189
- setList: function (list) { return ({ type: "ENTITY_LIST:SET_LIST", list: list }); },
190
- toggle: function (entity) { return ({ type: "ENTITY_LIST:TOGGLE", entity: entity }); },
191
- actionByFieldsMatch: function (fields, action) { return ({
192
- type: "ENTITY_LIST:ACTION_BY_FIELDS_MATCH",
193
- fields: fields,
194
- action: action,
195
- }); },
196
- actionByIndex: function (index, action) { return ({
197
- type: "ENTITY_LIST:ACTION_BY_INDEX",
198
- index: index,
199
- action: action,
200
- }); },
201
- actionOnAll: function (action) { return ({
202
- type: "ENTITY_LIST:ACTION_ON_ALL",
203
- action: action,
204
- }); },
205
- };
120
+ const createCommitReducerSelectors = (id, stateSelector) => {
121
+ return {
122
+ getWorkspaceValues: (state) => stateSelector(state, id).workspace,
123
+ getCommittedValues: (state) => stateSelector(state, id).committed
124
+ };
206
125
  };
207
-
208
- var fieldsMatch = function (entity, fields) {
209
- var keys = Object.keys(fields);
210
- if (keys.length === 0) {
211
- return false;
212
- }
213
- for (var i = 0; i < keys.length; i++) {
214
- var key = keys[i];
215
- if (entity[key] !== fields[key]) {
216
- return false;
217
- }
218
- }
219
- return true;
126
+ const createEntityListActions = () => {
127
+ return {
128
+ addAtEnd: (entity) => ({ type: "ENTITY_LIST:ADD_AT_END", entity }),
129
+ addAtStart: (entity) => ({
130
+ entity,
131
+ type: "ENTITY_LIST:ADD_AT_START"
132
+ }),
133
+ clearList: () => ({ type: "ENTITY_LIST:CLEAR_LIST" }),
134
+ removeFirst: () => ({ type: "ENTITY_LIST:REMOVE_FIRST" }),
135
+ removeLast: () => ({ type: "ENTITY_LIST:REMOVE_LAST" }),
136
+ removeAtIndex: (index) => ({
137
+ type: "ENTITY_LIST:REMOVE_AT_INDEX",
138
+ index
139
+ }),
140
+ removeByFieldMatch: (fields) => ({
141
+ type: "ENTITY_LIST:REMOVE_BY_FIELD_MATCH",
142
+ fields
143
+ }),
144
+ remove: (entity) => ({ type: "ENTITY_LIST:REMOVE", entity }),
145
+ setList: (list) => ({ type: "ENTITY_LIST:SET_LIST", list }),
146
+ toggle: (entity) => ({ type: "ENTITY_LIST:TOGGLE", entity }),
147
+ actionByFieldsMatch: (fields, action) => ({
148
+ type: "ENTITY_LIST:ACTION_BY_FIELDS_MATCH",
149
+ fields,
150
+ action
151
+ }),
152
+ actionByIndex: (index, action) => ({
153
+ type: "ENTITY_LIST:ACTION_BY_INDEX",
154
+ index,
155
+ action
156
+ }),
157
+ actionOnAll: (action) => ({
158
+ type: "ENTITY_LIST:ACTION_ON_ALL",
159
+ action
160
+ })
161
+ };
220
162
  };
221
-
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;
229
- }
230
- case "ENTITY_LIST:CLEAR_LIST": {
231
- return [];
232
- }
233
- case "ENTITY_LIST:ADD_AT_END": {
234
- var entity = action.entity;
235
- return __spreadArray(__spreadArray([], state, true), [entity], false);
236
- }
237
- case "ENTITY_LIST:ADD_AT_START": {
238
- var entity = action.entity;
239
- return __spreadArray([entity], state, true);
240
- }
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
- }
252
- var list = __spreadArray([], state, true);
253
- list.pop();
254
- return list;
255
- }
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;
267
- }
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); });
271
- }
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;
315
- }
316
- };
163
+ const fieldsMatch = (entity, fields) => {
164
+ const keys = Object.keys(fields);
165
+ if (keys.length === 0) {
166
+ return false;
167
+ }
168
+ for (let i = 0; i < keys.length; i++) {
169
+ const key = keys[i];
170
+ if (entity[key] !== fields[key]) {
171
+ return false;
172
+ }
173
+ }
174
+ return true;
317
175
  };
318
-
319
- var createEntityListSelectors = function (stateSelector) { return ({
320
- getList: function (store) { return stateSelector(store); },
321
- }); };
322
-
323
- var entityByIdInitialState = { entities: {} };
324
- var createEntityByIdReducer = function () {
325
- return function (state, action) {
326
- var _a, _b;
327
- if (state === void 0) { state = entityByIdInitialState; }
328
- switch (action.type) {
329
- case "ENTITY_BY_ID:SET_ENTITY": {
330
- var entity = action.entity;
331
- return __assign(__assign({}, state), { entities: __assign(__assign({}, state.entities), (_a = {}, _a[entity.id] = entity, _a)) });
332
- }
333
- case "ENTITY_BY_ID:SET_ENTITY_FIELDS": {
334
- var id = action.id, fields = action.fields;
335
- return __assign(__assign({}, state), { entities: __assign(__assign({}, state.entities), (_b = {}, _b[id] = __assign(__assign({}, state.entities[id]), fields), _b)) });
336
- }
337
- case "ENTITY_BY_ID:CLEAR_ALL_ENTITIES": {
338
- return __assign(__assign({}, state), { entities: {} });
339
- }
340
- case "ENTITY_BY_ID:CLEAR_ENTITY": {
341
- var id = action.id;
342
- var entities = __assign({}, state.entities);
343
- delete entities[id];
344
- return __assign(__assign({}, state), { entities: entities });
345
- }
346
- default:
347
- return state;
348
- }
349
- };
176
+ const createEntityListReducer = (reducer) => (state = [], action) => {
177
+ switch (action.type) {
178
+ case "ENTITY_LIST:SET_LIST": {
179
+ const { list } = action;
180
+ return list;
181
+ }
182
+ case "ENTITY_LIST:CLEAR_LIST": {
183
+ return [];
184
+ }
185
+ case "ENTITY_LIST:ADD_AT_END": {
186
+ const { entity } = action;
187
+ return [...state, entity];
188
+ }
189
+ case "ENTITY_LIST:ADD_AT_START": {
190
+ const { entity } = action;
191
+ return [entity, ...state];
192
+ }
193
+ case "ENTITY_LIST:REMOVE_FIRST": {
194
+ if (state.length === 0) {
195
+ throw new Error("Cannot remove, list is empty.");
196
+ }
197
+ const [, ...list] = state;
198
+ return list;
199
+ }
200
+ case "ENTITY_LIST:REMOVE_LAST": {
201
+ if (state.length === 0) {
202
+ throw new Error("Cannot remove, list is empty.");
203
+ }
204
+ const list = [...state];
205
+ list.pop();
206
+ return list;
207
+ }
208
+ case "ENTITY_LIST:REMOVE_AT_INDEX": {
209
+ const { index } = action;
210
+ if (index < 0) {
211
+ throw new Error("Index is lower than 0.");
212
+ }
213
+ if (index >= state.length) {
214
+ throw new Error("Index is outside of list bounds.");
215
+ }
216
+ const list = [...state];
217
+ list.splice(index, 1);
218
+ return list;
219
+ }
220
+ case "ENTITY_LIST:REMOVE_BY_FIELD_MATCH": {
221
+ const { fields } = action;
222
+ return state.filter((item) => !fieldsMatch(item, fields));
223
+ }
224
+ case "ENTITY_LIST:REMOVE": {
225
+ const { entity } = action;
226
+ return state.filter((item) => item !== entity);
227
+ }
228
+ case "ENTITY_LIST:TOGGLE": {
229
+ const { entity } = action;
230
+ const index = state.findIndex((item) => item === entity || fieldsMatch(item, entity));
231
+ if (index >= 0) {
232
+ const list = [...state];
233
+ list.splice(index, index);
234
+ return list;
235
+ } else {
236
+ return [...state, entity];
237
+ }
238
+ }
239
+ case "ENTITY_LIST:ACTION_BY_FIELDS_MATCH": {
240
+ const { fields, action: innerAction } = action;
241
+ if (!reducer) {
242
+ throw new Error("No reducer specified, unable to handle 'actionByFieldsMatch'.");
243
+ }
244
+ return state.map((item) => fieldsMatch(item, fields) ? reducer(item, innerAction) : item);
245
+ }
246
+ case "ENTITY_LIST:ACTION_BY_INDEX": {
247
+ const { index, action: innerAction } = action;
248
+ if (!reducer) {
249
+ throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
250
+ }
251
+ return state.map((item, i) => index === i ? reducer(item, innerAction) : item);
252
+ }
253
+ case "ENTITY_LIST:ACTION_ON_ALL": {
254
+ const { action: innerAction } = action;
255
+ if (!reducer) {
256
+ throw new Error("No reducer specified, unable to handle 'actionByIndex'.");
257
+ }
258
+ return state.map((item) => reducer(item, innerAction));
259
+ }
260
+ default:
261
+ return state;
262
+ }
350
263
  };
351
-
352
- var createEntityByIdActions = function () { return ({
353
- setEntity: function (entity) { return ({
354
- type: "ENTITY_BY_ID:SET_ENTITY",
355
- entity: entity,
356
- }); },
357
- setEntityFields: function (id, fields) { return ({
358
- type: "ENTITY_BY_ID:SET_ENTITY_FIELDS",
359
- id: id,
360
- fields: fields,
361
- }); },
362
- clearEntity: function (id) { return ({
363
- type: "ENTITY_BY_ID:CLEAR_ENTITY",
364
- id: id,
365
- }); },
366
- clearAllEntities: function () { return ({
367
- type: "ENTITY_BY_ID:CLEAR_ALL_ENTITIES",
368
- }); },
369
- }); };
370
-
371
- var createEntityByIdSelectors = function (stateSelector) { return ({
372
- getState: stateSelector,
373
- }); };
374
-
375
- var createEntityReducer = function (initialEntity) {
376
- var INITIAL_STATE = initialEntity;
377
- return function (state, action) {
378
- if (state === void 0) { state = INITIAL_STATE; }
379
- switch (action.type) {
380
- case "ENTITY:SET_ENTITY": {
381
- var entity = action.entity;
382
- return entity;
383
- }
384
- case "ENTITY:SET_ENTITY_FIELDS": {
385
- var fields = action.fields;
386
- return __assign(__assign({}, state), fields);
387
- }
388
- default:
389
- return state;
390
- }
391
- };
264
+ const createEntityListSelectors = (stateSelector) => ({
265
+ getList: (store) => stateSelector(store)
266
+ });
267
+ const entityByIdInitialState = { entities: {} };
268
+ const createEntityByIdReducer = () => {
269
+ return (state = entityByIdInitialState, action) => {
270
+ switch (action.type) {
271
+ case "ENTITY_BY_ID:SET_ENTITY": {
272
+ const { entity } = action;
273
+ return {
274
+ ...state,
275
+ entities: {
276
+ ...state.entities,
277
+ [entity.id]: entity
278
+ }
279
+ };
280
+ }
281
+ case "ENTITY_BY_ID:SET_ENTITY_FIELDS": {
282
+ const { id, fields } = action;
283
+ return {
284
+ ...state,
285
+ entities: {
286
+ ...state.entities,
287
+ [id]: {
288
+ ...state.entities[id],
289
+ ...fields
290
+ }
291
+ }
292
+ };
293
+ }
294
+ case "ENTITY_BY_ID:CLEAR_ALL_ENTITIES": {
295
+ return {
296
+ ...state,
297
+ entities: {}
298
+ };
299
+ }
300
+ case "ENTITY_BY_ID:CLEAR_ENTITY": {
301
+ const { id } = action;
302
+ const entities = {
303
+ ...state.entities
304
+ };
305
+ delete entities[id];
306
+ return {
307
+ ...state,
308
+ entities
309
+ };
310
+ }
311
+ default:
312
+ return state;
313
+ }
314
+ };
392
315
  };
393
-
394
- var createEntityActions = function () { return ({
395
- setEntity: function (entity) { return ({
396
- type: "ENTITY:SET_ENTITY",
397
- entity: entity,
398
- }); },
399
- setEntityFields: function (fields) { return ({
400
- type: "ENTITY:SET_ENTITY_FIELDS",
401
- fields: fields,
402
- }); },
403
- }); };
404
-
405
- var createEntitySelectors = function (stateSelector) { return ({
406
- getEntity: function (state) { return stateSelector(state); },
407
- }); };
408
-
409
- var createEntityCrudStatusReducer = function () {
410
- return createEntityByIdReducer();
411
- };
412
- var createEntityCrudStatusActions = function () {
413
- return createEntityByIdActions();
414
- };
415
- var createEntityCrudStatusSelectors = function (stateSelector) { return createEntityByIdSelectors(stateSelector); };
416
- var createEntityCrudStatusRedux = function (stateSelector) {
417
- var reducer = createEntityCrudStatusReducer();
418
- var actions = createEntityCrudStatusActions();
419
- var selectors = createEntityCrudStatusSelectors(stateSelector);
420
- return {
421
- reducer: reducer,
422
- actions: actions,
423
- selectors: selectors,
424
- };
316
+ const createEntityByIdActions = () => ({
317
+ setEntity: (entity) => ({
318
+ type: "ENTITY_BY_ID:SET_ENTITY",
319
+ entity
320
+ }),
321
+ setEntityFields: (id, fields) => ({
322
+ type: "ENTITY_BY_ID:SET_ENTITY_FIELDS",
323
+ id,
324
+ fields
325
+ }),
326
+ clearEntity: (id) => ({
327
+ type: "ENTITY_BY_ID:CLEAR_ENTITY",
328
+ id
329
+ }),
330
+ clearAllEntities: () => ({
331
+ type: "ENTITY_BY_ID:CLEAR_ALL_ENTITIES"
332
+ })
333
+ });
334
+ const createEntityByIdSelectors = (stateSelector) => ({
335
+ getState: stateSelector
336
+ });
337
+ const createEntityReducer = (initialEntity) => {
338
+ const INITIAL_STATE2 = initialEntity;
339
+ return (state = INITIAL_STATE2, action) => {
340
+ switch (action.type) {
341
+ case "ENTITY:SET_ENTITY": {
342
+ const { entity } = action;
343
+ return entity;
344
+ }
345
+ case "ENTITY:SET_ENTITY_FIELDS": {
346
+ const { fields } = action;
347
+ return {
348
+ ...state,
349
+ ...fields
350
+ };
351
+ }
352
+ default:
353
+ return state;
354
+ }
355
+ };
425
356
  };
426
-
427
- var createModifiedFieldRedux = function (stateSelector) {
428
- var reducer = createEntityByIdReducer();
429
- var selectors = createEntityByIdSelectors(stateSelector);
430
- var actions = createEntityByIdActions();
431
- return {
432
- reducer: reducer,
433
- selectors: selectors,
434
- actions: actions,
435
- };
357
+ const createEntityActions = () => ({
358
+ setEntity: (entity) => ({
359
+ type: "ENTITY:SET_ENTITY",
360
+ entity
361
+ }),
362
+ setEntityFields: (fields) => ({
363
+ type: "ENTITY:SET_ENTITY_FIELDS",
364
+ fields
365
+ })
366
+ });
367
+ const createEntitySelectors = (stateSelector) => ({
368
+ getEntity: (state) => stateSelector(state)
369
+ });
370
+ const createEntityCrudStatusReducer = () => createEntityByIdReducer();
371
+ const createEntityCrudStatusActions = () => createEntityByIdActions();
372
+ const createEntityCrudStatusSelectors = (stateSelector) => createEntityByIdSelectors(stateSelector);
373
+ const createEntityCrudStatusRedux = (stateSelector) => {
374
+ const reducer = createEntityCrudStatusReducer();
375
+ const actions = createEntityCrudStatusActions();
376
+ const selectors = createEntityCrudStatusSelectors(stateSelector);
377
+ return {
378
+ reducer,
379
+ actions,
380
+ selectors
381
+ };
436
382
  };
437
-
438
- var createEditableEntityReducer = function (initialEntity, initialId) {
439
- var initialState = {
440
- id: initialId,
441
- editable: initialEntity,
442
- persisted: initialEntity,
443
- };
444
- return function (state, action) {
445
- if (state === void 0) { state = initialState; }
446
- switch (action.type) {
447
- case "EDITABLE_ENTITY:SET_ENTITY_ID": {
448
- var id = action.id;
449
- return __assign(__assign({}, state), { id: id });
450
- }
451
- case "EDITABLE_ENTITY:SET_ENTITY": {
452
- var entity = action.entity;
453
- return __assign(__assign({}, state), { persisted: entity, editable: entity });
454
- }
455
- case "EDITABLE_ENTITY:SET_PERSISTED_ENTITY": {
456
- var entity = action.entity;
457
- return __assign(__assign({}, state), { persisted: entity });
458
- }
459
- case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY": {
460
- var entity = action.entity;
461
- return __assign(__assign({}, state), { editable: entity });
462
- }
463
- case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS": {
464
- var fields = action.fields;
465
- return __assign(__assign({}, state), { editable: __assign(__assign({}, state.editable), fields) });
466
- }
467
- case "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY": {
468
- return __assign(__assign({}, state), { editable: state.persisted });
469
- }
470
- case "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED": {
471
- return __assign(__assign({}, state), { persisted: state.editable });
472
- }
473
- default:
474
- return state;
475
- }
476
- };
383
+ const createModifiedFieldRedux = (stateSelector) => {
384
+ const reducer = createEntityByIdReducer();
385
+ const selectors = createEntityByIdSelectors(stateSelector);
386
+ const actions = createEntityByIdActions();
387
+ return {
388
+ reducer,
389
+ selectors,
390
+ actions
391
+ };
477
392
  };
478
-
479
- var createEditableEntityActions = function () { return ({
480
- setEntityId: function (id) { return ({
481
- type: "EDITABLE_ENTITY:SET_ENTITY_ID",
482
- id: id,
483
- }); },
484
- setEntity: function (entity) { return ({ type: "EDITABLE_ENTITY:SET_ENTITY", entity: entity }); },
485
- setPersistedEntity: function (entity) { return ({
486
- type: "EDITABLE_ENTITY:SET_PERSISTED_ENTITY",
487
- entity: entity,
488
- }); },
489
- setEditableEntity: function (entity) { return ({
490
- type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY",
491
- entity: entity,
492
- }); },
493
- setEditableEntityFields: function (fields) { return ({
494
- type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS",
495
- fields: fields,
496
- }); },
497
- revertEditableEntity: function () { return ({
498
- type: "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY",
499
- }); },
500
- commitEditableEntityToPersisted: function () { return ({
501
- type: "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED",
502
- }); },
503
- }); };
504
-
505
- var createSelectedIdsReducerInitialState = function (initialSelection) {
506
- if (initialSelection === void 0) { initialSelection = []; }
507
- return ({
508
- selectedIds: initialSelection,
509
- });
510
- };
511
- var INITIAL_STATE$1 = createSelectedIdsReducerInitialState();
512
- var createSelectedIdsReducer = function (initialState) {
513
- if (initialState === void 0) { initialState = INITIAL_STATE$1; }
514
- return function (state, action) {
515
- if (state === void 0) { state = initialState; }
516
- switch (action.type) {
517
- case "SELECTED_IDS:SET_SELECTED_IDS": {
518
- var selectedIds = action.selectedIds;
519
- return __assign(__assign({}, state), { selectedIds: selectedIds });
520
- }
521
- case "SELECTED_IDS:CLEAR_SELECTED_IDS": {
522
- return __assign(__assign({}, state), { selectedIds: [] });
523
- }
524
- default:
525
- return state;
526
- }
527
- };
528
- };
529
- var selectedIdsReducer = createSelectedIdsReducer();
530
-
531
- var createSelectedIdsActions = function () { return ({
532
- setSelectedIds: function (selectedIds) { return ({
533
- selectedIds: selectedIds,
534
- type: "SELECTED_IDS:SET_SELECTED_IDS",
535
- }); },
536
- clearSelectedIds: function () { return ({
537
- type: "SELECTED_IDS:CLEAR_SELECTED_IDS",
538
- }); },
539
- }); };
540
- var selectedIdsActions = createSelectedIdsActions();
541
-
542
- var createSelectedIdsSelectors = function (stateSelector) { return ({
543
- getState: stateSelector,
544
- }); };
545
-
546
- var INITIAL_STATE = {
547
- ids: undefined,
548
- };
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
- };
562
- var sortOrderByIdReducer = createSortOrderByIdReducer();
563
-
564
- var createSortOrderByIdActions = function () {
565
- return {
566
- setSortOrder: function (ids) { return ({
567
- ids: ids,
568
- type: "SORT_ORDER_BY_ID:SET_SORT_ORDER",
569
- }); },
570
- clearSortOrder: function () { return ({
571
- type: "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER",
572
- }); },
573
- };
574
- };
575
- var sortOrderByIdActions = createSortOrderByIdActions();
576
-
577
- var createSortOrderByIdSelectors = function (rootStateProvider) {
578
- return {
579
- getSortOrderByIdState: function (state) {
580
- return rootStateProvider(state);
581
- },
582
- getSortOrder: function (state) {
583
- return rootStateProvider(state).ids;
584
- },
585
- };
393
+ const createEditableEntityReducer = (initialEntity, initialId) => {
394
+ const initialState = {
395
+ id: initialId,
396
+ editable: initialEntity,
397
+ persisted: initialEntity
398
+ };
399
+ return (state = initialState, action) => {
400
+ switch (action.type) {
401
+ case "EDITABLE_ENTITY:SET_ENTITY_ID": {
402
+ const { id } = action;
403
+ return {
404
+ ...state,
405
+ id
406
+ };
407
+ }
408
+ case "EDITABLE_ENTITY:SET_ENTITY": {
409
+ const { entity } = action;
410
+ return {
411
+ ...state,
412
+ persisted: entity,
413
+ editable: entity
414
+ };
415
+ }
416
+ case "EDITABLE_ENTITY:SET_PERSISTED_ENTITY": {
417
+ const { entity } = action;
418
+ return {
419
+ ...state,
420
+ persisted: entity
421
+ };
422
+ }
423
+ case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY": {
424
+ const { entity } = action;
425
+ return {
426
+ ...state,
427
+ editable: entity
428
+ };
429
+ }
430
+ case "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS": {
431
+ const { fields } = action;
432
+ return {
433
+ ...state,
434
+ editable: {
435
+ ...state.editable,
436
+ ...fields
437
+ }
438
+ };
439
+ }
440
+ case "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY": {
441
+ return {
442
+ ...state,
443
+ editable: state.persisted
444
+ };
445
+ }
446
+ case "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED": {
447
+ return {
448
+ ...state,
449
+ persisted: state.editable
450
+ };
451
+ }
452
+ default:
453
+ return state;
454
+ }
455
+ };
586
456
  };
587
-
588
- var createSortOrderReducerInitialState = function (sortBy, desc) {
589
- if (sortBy === void 0) { sortBy = undefined; }
590
- if (desc === void 0) { desc = false; }
591
- return ({
592
- sortBy: sortBy,
593
- desc: desc,
594
- });
595
- };
596
- var createSortOrderReducer = function (initialState) {
597
- if (initialState === void 0) { initialState = { sortBy: undefined, desc: false }; }
598
- return function (state, action) {
599
- if (state === void 0) { state = initialState; }
600
- switch (action.type) {
601
- case "SORT_ORDER:SET_SORT_BY": {
602
- var sortBy = action.sortBy, desc = action.desc;
603
- return __assign(__assign({}, state), { sortBy: sortBy, desc: desc });
604
- }
605
- case "SORT_ORDER:CLEAR_SORT_ORDER": {
606
- return __assign(__assign({}, state), { sortBy: undefined, desc: false });
607
- }
608
- default:
609
- return state;
610
- }
611
- };
457
+ const createEditableEntityActions = () => ({
458
+ setEntityId: (id) => ({
459
+ type: "EDITABLE_ENTITY:SET_ENTITY_ID",
460
+ id
461
+ }),
462
+ setEntity: (entity) => ({ type: "EDITABLE_ENTITY:SET_ENTITY", entity }),
463
+ setPersistedEntity: (entity) => ({
464
+ type: "EDITABLE_ENTITY:SET_PERSISTED_ENTITY",
465
+ entity
466
+ }),
467
+ setEditableEntity: (entity) => ({
468
+ type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY",
469
+ entity
470
+ }),
471
+ setEditableEntityFields: (fields) => ({
472
+ type: "EDITABLE_ENTITY:SET_EDITABLE_ENTITY_FIELDS",
473
+ fields
474
+ }),
475
+ revertEditableEntity: () => ({
476
+ type: "EDITABLE_ENTITY:REVERT_EDITABLE_ENTITY"
477
+ }),
478
+ commitEditableEntityToPersisted: () => ({
479
+ type: "EDITABLE_ENTITY:COMMIT_EDITABLE_ENTITY_TO_PERSISTED"
480
+ })
481
+ });
482
+ const createSelectedIdsReducerInitialState = (initialSelection = []) => ({
483
+ selectedIds: initialSelection
484
+ });
485
+ const INITIAL_STATE$1 = createSelectedIdsReducerInitialState();
486
+ const createSelectedIdsReducer = (initialState = INITIAL_STATE$1) => (state = initialState, action) => {
487
+ switch (action.type) {
488
+ case "SELECTED_IDS:SET_SELECTED_IDS": {
489
+ const { selectedIds } = action;
490
+ return {
491
+ ...state,
492
+ selectedIds
493
+ };
494
+ }
495
+ case "SELECTED_IDS:CLEAR_SELECTED_IDS": {
496
+ return {
497
+ ...state,
498
+ selectedIds: []
499
+ };
500
+ }
501
+ default:
502
+ return state;
503
+ }
612
504
  };
613
-
614
- var createSortOrderActions = function () { return ({
615
- sortBy: function (sortBy, desc) { return ({
616
- desc: desc,
617
- sortBy: sortBy,
618
- type: "SORT_ORDER:SET_SORT_BY",
619
- }); },
620
- clearSortOrder: function () { return ({
621
- type: "SORT_ORDER:CLEAR_SORT_ORDER",
622
- }); },
623
- }); };
624
-
625
- var createSortOrderSelectors = function (stateProvider) { return ({
626
- getState: stateProvider,
627
- }); };
628
-
629
- var valueByIdInitialState = { values: {} };
630
- var createValueByIdReducer = function (initialValue) {
631
- if (initialValue === void 0) { initialValue = valueByIdInitialState; }
632
- return function (state, action) {
633
- var _a;
634
- if (state === void 0) { state = initialValue; }
635
- switch (action.type) {
636
- case "VALUE_BY_ID:SET_VALUE": {
637
- var id = action.id, value = action.value;
638
- return __assign(__assign({}, state), { values: __assign(__assign({}, state.values), (_a = {}, _a[id] = value, _a)) });
639
- }
640
- case "VALUE_BY_ID:CLEAR_ALL_VALUES": {
641
- return __assign(__assign({}, state), { values: {} });
642
- }
643
- case "VALUE_BY_ID:CLEAR_VALUE": {
644
- var id = action.id;
645
- var values = __assign({}, state.values);
646
- delete values[id];
647
- return __assign(__assign({}, state), { values: values });
648
- }
649
- default:
650
- return state;
651
- }
652
- };
505
+ const selectedIdsReducer = createSelectedIdsReducer();
506
+ const createSelectedIdsActions = () => ({
507
+ setSelectedIds: (selectedIds) => ({
508
+ selectedIds,
509
+ type: "SELECTED_IDS:SET_SELECTED_IDS"
510
+ }),
511
+ clearSelectedIds: () => ({
512
+ type: "SELECTED_IDS:CLEAR_SELECTED_IDS"
513
+ })
514
+ });
515
+ const selectedIdsActions = createSelectedIdsActions();
516
+ const createSelectedIdsSelectors = (stateSelector) => ({
517
+ getState: stateSelector
518
+ });
519
+ const INITIAL_STATE = {
520
+ ids: void 0
653
521
  };
654
-
655
- var createValueByIdActions = function () { return ({
656
- setValue: function (id, value) { return ({
657
- type: "VALUE_BY_ID:SET_VALUE",
658
- id: id,
659
- value: value,
660
- }); },
661
- clearValue: function (id) { return ({
662
- type: "VALUE_BY_ID:CLEAR_VALUE",
663
- id: id,
664
- }); },
665
- clearAllValues: function () { return ({
666
- type: "VALUE_BY_ID:CLEAR_ALL_VALUES",
667
- }); },
668
- }); };
669
-
670
- var createValueByIdSelectors = function (stateSelector) { return ({
671
- getState: stateSelector,
672
- }); };
673
-
522
+ const createSortOrderByIdReducer = () => (state = INITIAL_STATE, action) => {
523
+ switch (action.type) {
524
+ case "SORT_ORDER_BY_ID:SET_SORT_ORDER":
525
+ return {
526
+ ...state,
527
+ ids: action.ids
528
+ };
529
+ case "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER":
530
+ return {
531
+ ...state,
532
+ ids: void 0
533
+ };
534
+ default:
535
+ return state;
536
+ }
537
+ };
538
+ const sortOrderByIdReducer = createSortOrderByIdReducer();
539
+ const createSortOrderByIdActions = () => {
540
+ return {
541
+ setSortOrder: (ids) => ({
542
+ ids,
543
+ type: "SORT_ORDER_BY_ID:SET_SORT_ORDER"
544
+ }),
545
+ clearSortOrder: () => ({
546
+ type: "SORT_ORDER_BY_ID:CLEAR_SORT_ORDER"
547
+ })
548
+ };
549
+ };
550
+ const sortOrderByIdActions = createSortOrderByIdActions();
551
+ const createSortOrderByIdSelectors = (rootStateProvider) => {
552
+ return {
553
+ getSortOrderByIdState: (state) => {
554
+ return rootStateProvider(state);
555
+ },
556
+ getSortOrder: (state) => {
557
+ return rootStateProvider(state).ids;
558
+ }
559
+ };
560
+ };
561
+ const createSortOrderReducerInitialState = (sortBy = void 0, desc = false) => ({
562
+ sortBy,
563
+ desc
564
+ });
565
+ const createSortOrderReducer = (initialState = { sortBy: void 0, desc: false }) => (state = initialState, action) => {
566
+ switch (action.type) {
567
+ case "SORT_ORDER:SET_SORT_BY": {
568
+ const { sortBy, desc } = action;
569
+ return {
570
+ ...state,
571
+ sortBy,
572
+ desc
573
+ };
574
+ }
575
+ case "SORT_ORDER:CLEAR_SORT_ORDER": {
576
+ return {
577
+ ...state,
578
+ sortBy: void 0,
579
+ desc: false
580
+ };
581
+ }
582
+ default:
583
+ return state;
584
+ }
585
+ };
586
+ const createSortOrderActions = () => ({
587
+ sortBy: (sortBy, desc) => ({
588
+ desc,
589
+ sortBy,
590
+ type: "SORT_ORDER:SET_SORT_BY"
591
+ }),
592
+ clearSortOrder: () => ({
593
+ type: "SORT_ORDER:CLEAR_SORT_ORDER"
594
+ })
595
+ });
596
+ const createSortOrderSelectors = (stateProvider) => ({
597
+ getState: stateProvider
598
+ });
599
+ const valueByIdInitialState = { values: {} };
600
+ const createValueByIdReducer = (initialValue = valueByIdInitialState) => {
601
+ return (state = initialValue, action) => {
602
+ switch (action.type) {
603
+ case "VALUE_BY_ID:SET_VALUE": {
604
+ const { id, value } = action;
605
+ return {
606
+ ...state,
607
+ values: {
608
+ ...state.values,
609
+ [id]: value
610
+ }
611
+ };
612
+ }
613
+ case "VALUE_BY_ID:CLEAR_ALL_VALUES": {
614
+ return {
615
+ ...state,
616
+ values: {}
617
+ };
618
+ }
619
+ case "VALUE_BY_ID:CLEAR_VALUE": {
620
+ const { id } = action;
621
+ const values = {
622
+ ...state.values
623
+ };
624
+ delete values[id];
625
+ return {
626
+ ...state,
627
+ values
628
+ };
629
+ }
630
+ default:
631
+ return state;
632
+ }
633
+ };
634
+ };
635
+ const createValueByIdActions = () => ({
636
+ setValue: (id, value) => ({
637
+ type: "VALUE_BY_ID:SET_VALUE",
638
+ id,
639
+ value
640
+ }),
641
+ clearValue: (id) => ({
642
+ type: "VALUE_BY_ID:CLEAR_VALUE",
643
+ id
644
+ }),
645
+ clearAllValues: () => ({
646
+ type: "VALUE_BY_ID:CLEAR_ALL_VALUES"
647
+ })
648
+ });
649
+ const createValueByIdSelectors = (stateSelector) => ({
650
+ getState: stateSelector
651
+ });
674
652
  export { createCommitReducer, createCommitReducerActions, createCommitReducerSelectors, createEditableEntityActions, createEditableEntityReducer, createEntityActions, createEntityByIdActions, createEntityByIdReducer, createEntityByIdSelectors, createEntityCrudStatusActions, createEntityCrudStatusReducer, createEntityCrudStatusRedux, createEntityCrudStatusSelectors, createEntityListActions, createEntityListReducer, createEntityListSelectors, createEntityReducer, createEntitySelectors, createModifiedFieldRedux, createRecordObjectActions, createRecordObjectReducer, createSelectedIdsActions, createSelectedIdsReducer, createSelectedIdsReducerInitialState, createSelectedIdsSelectors, createSortOrderActions, createSortOrderByIdActions, createSortOrderByIdReducer, createSortOrderByIdSelectors, createSortOrderReducer, createSortOrderReducerInitialState, createSortOrderSelectors, createValueByIdActions, createValueByIdReducer, createValueByIdSelectors, entityByIdInitialState, reducerIdGate, reducerIdGateAction, selectedIdsActions, selectedIdsReducer, sortOrderByIdActions, sortOrderByIdReducer, valueByIdInitialState, wrapActionWithReducerIdGate, wrapActionsWithReducerIdGate };
675
653
  //# sourceMappingURL=index.es.js.map