@steroidsjs/core 2.2.98 → 2.2.100
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/actions/list.d.ts +6 -0
- package/actions/list.js +8 -1
- package/package.json +1 -1
- package/reducers/list.js +11 -2
package/actions/list.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const LIST_BEFORE_FETCH = "@list/before_fetch";
|
|
|
28
28
|
export declare const LIST_AFTER_FETCH = "@list/after_fetch";
|
|
29
29
|
export declare const LIST_ITEM_ADD = "@list/item_add";
|
|
30
30
|
export declare const LIST_ITEM_UPDATE = "@list/item_update";
|
|
31
|
+
export declare const LIST_ITEM_DELETE = "@list/item_delete";
|
|
31
32
|
export declare const LIST_DESTROY = "@list/destroy";
|
|
32
33
|
export declare const LIST_TOGGLE_ITEM = "@list/toggle_item";
|
|
33
34
|
export declare const LIST_TOGGLE_ALL = "@list/toggle_all";
|
|
@@ -96,6 +97,11 @@ export declare const update: (listId: any, item: any, condition: any) => {
|
|
|
96
97
|
listId: any;
|
|
97
98
|
type: string;
|
|
98
99
|
};
|
|
100
|
+
export declare const deleteItem: (listId: any, condition: any) => {
|
|
101
|
+
condition: any;
|
|
102
|
+
listId: any;
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
99
105
|
export declare const toggleItem: (listId: any, itemId: any) => {
|
|
100
106
|
listId: any;
|
|
101
107
|
itemId: any;
|
package/actions/list.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
exports.__esModule = true;
|
|
17
|
-
exports.toggleAll = exports.toggleItem = exports.update = exports.add = exports.listDestroy = exports.listRefresh = exports.listLazyFetch = exports.listFetch = exports.listSetLayout = exports.listSetItems = exports.listInit = exports.localFetchHandler = exports.httpFetchHandler = exports.LIST_SET_LAYOUT = exports.LIST_TOGGLE_ALL = exports.LIST_TOGGLE_ITEM = exports.LIST_DESTROY = exports.LIST_ITEM_UPDATE = exports.LIST_ITEM_ADD = exports.LIST_AFTER_FETCH = exports.LIST_BEFORE_FETCH = exports.LIST_SET_ITEMS = exports.LIST_INIT = void 0;
|
|
17
|
+
exports.toggleAll = exports.toggleItem = exports.deleteItem = exports.update = exports.add = exports.listDestroy = exports.listRefresh = exports.listLazyFetch = exports.listFetch = exports.listSetLayout = exports.listSetItems = exports.listInit = exports.localFetchHandler = exports.httpFetchHandler = exports.LIST_SET_LAYOUT = exports.LIST_TOGGLE_ALL = exports.LIST_TOGGLE_ITEM = exports.LIST_DESTROY = exports.LIST_ITEM_DELETE = exports.LIST_ITEM_UPDATE = exports.LIST_ITEM_ADD = exports.LIST_AFTER_FETCH = exports.LIST_BEFORE_FETCH = exports.LIST_SET_ITEMS = exports.LIST_INIT = void 0;
|
|
18
18
|
var get_1 = __importDefault(require("lodash-es/get"));
|
|
19
19
|
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
20
20
|
var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
|
|
@@ -32,6 +32,7 @@ exports.LIST_BEFORE_FETCH = '@list/before_fetch';
|
|
|
32
32
|
exports.LIST_AFTER_FETCH = '@list/after_fetch';
|
|
33
33
|
exports.LIST_ITEM_ADD = '@list/item_add';
|
|
34
34
|
exports.LIST_ITEM_UPDATE = '@list/item_update';
|
|
35
|
+
exports.LIST_ITEM_DELETE = '@list/item_delete';
|
|
35
36
|
exports.LIST_DESTROY = '@list/destroy';
|
|
36
37
|
exports.LIST_TOGGLE_ITEM = '@list/toggle_item';
|
|
37
38
|
exports.LIST_TOGGLE_ALL = '@list/toggle_all';
|
|
@@ -286,6 +287,12 @@ var update = function (listId, item, condition) { return ({
|
|
|
286
287
|
type: exports.LIST_ITEM_UPDATE
|
|
287
288
|
}); };
|
|
288
289
|
exports.update = update;
|
|
290
|
+
var deleteItem = function (listId, condition) { return ({
|
|
291
|
+
condition: condition,
|
|
292
|
+
listId: listId,
|
|
293
|
+
type: exports.LIST_ITEM_DELETE
|
|
294
|
+
}); };
|
|
295
|
+
exports.deleteItem = deleteItem;
|
|
289
296
|
var toggleItem = function (listId, itemId) { return ({
|
|
290
297
|
listId: listId,
|
|
291
298
|
itemId: itemId,
|
package/package.json
CHANGED
package/reducers/list.js
CHANGED
|
@@ -10,6 +10,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
14
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
15
|
+
to[j] = from[i];
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
13
18
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
19
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
20
|
};
|
|
@@ -80,6 +85,10 @@ var reducerMap = (_a = {},
|
|
|
80
85
|
return item;
|
|
81
86
|
}) }), _a)) }));
|
|
82
87
|
},
|
|
88
|
+
_a[list_1.LIST_ITEM_DELETE] = function (state, action) {
|
|
89
|
+
var _a;
|
|
90
|
+
return (__assign(__assign({}, state), { lists: __assign(__assign({}, state.lists), (_a = {}, _a[action.listId] = __assign(__assign({}, state.lists[action.listId]), { items: state.lists[action.listId].items.filter(function (item) { return !isMatch_1["default"](item, action.condition); }) }), _a)) }));
|
|
91
|
+
},
|
|
83
92
|
_a[list_1.LIST_DESTROY] = function (state, action) {
|
|
84
93
|
delete state.lists[action.listId];
|
|
85
94
|
return __assign(__assign({}, state), { lists: __assign({}, state.lists) });
|
|
@@ -89,10 +98,10 @@ var reducerMap = (_a = {},
|
|
|
89
98
|
var selectedIds = get_1["default"](state, ['selectedIds', action.listId]) || [];
|
|
90
99
|
var index = selectedIds.indexOf(action.itemId);
|
|
91
100
|
if (index === -1) {
|
|
92
|
-
selectedIds
|
|
101
|
+
selectedIds = __spreadArray(__spreadArray([], selectedIds), [action.itemId]);
|
|
93
102
|
}
|
|
94
103
|
else {
|
|
95
|
-
selectedIds.
|
|
104
|
+
selectedIds = selectedIds.filter(function (selectedId) { return selectedId !== action.itemId; });
|
|
96
105
|
}
|
|
97
106
|
return __assign(__assign({}, state), { selectedIds: __assign(__assign({}, state.selectedIds), (_a = {}, _a[action.listId] = [].concat(selectedIds), _a)) });
|
|
98
107
|
},
|