@steroidsjs/core 3.0.64 → 3.0.66
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/hooks/useList.js +10 -0
- package/package.json +1 -1
- package/reducers/list.js +4 -0
- package/ui/form/DropDownField/DropDownField.js +1 -1
package/actions/list.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ export declare const LIST_DESTROY = "@list/destroy";
|
|
|
109
109
|
export declare const LIST_TOGGLE_ITEM = "@list/toggle_item";
|
|
110
110
|
export declare const LIST_TOGGLE_ALL = "@list/toggle_all";
|
|
111
111
|
export declare const LIST_SET_LAYOUT = "@list/set_layout";
|
|
112
|
+
export declare const LIST_CHANGE_ACTION = "@list/change_action";
|
|
112
113
|
export declare const httpFetchHandler: (list: IList, query: any, { http }: {
|
|
113
114
|
http: any;
|
|
114
115
|
}) => any;
|
|
@@ -135,6 +136,11 @@ export declare const listSetLayout: (listId: any, layoutName: any) => {
|
|
|
135
136
|
listId: any;
|
|
136
137
|
layoutName: any;
|
|
137
138
|
};
|
|
139
|
+
export declare const listChangeAction: (listId: any, action: any) => {
|
|
140
|
+
type: string;
|
|
141
|
+
listId: any;
|
|
142
|
+
action: any;
|
|
143
|
+
};
|
|
138
144
|
/**
|
|
139
145
|
* Update query values and send request
|
|
140
146
|
* @param listId
|
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.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;
|
|
17
|
+
exports.toggleAll = exports.toggleItem = exports.deleteItem = exports.update = exports.add = exports.listDestroy = exports.listRefresh = exports.listLazyFetch = exports.listFetch = exports.listChangeAction = exports.listSetLayout = exports.listSetItems = exports.listInit = exports.localFetchHandler = exports.httpFetchHandler = exports.LIST_CHANGE_ACTION = 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"));
|
|
@@ -37,6 +37,7 @@ exports.LIST_DESTROY = '@list/destroy';
|
|
|
37
37
|
exports.LIST_TOGGLE_ITEM = '@list/toggle_item';
|
|
38
38
|
exports.LIST_TOGGLE_ALL = '@list/toggle_all';
|
|
39
39
|
exports.LIST_SET_LAYOUT = '@list/set_layout';
|
|
40
|
+
exports.LIST_CHANGE_ACTION = '@list/change_action';
|
|
40
41
|
//const STORAGE_LAYOUT_KEY_PREFIX = 'listLayout_';
|
|
41
42
|
var lazyTimers = {};
|
|
42
43
|
var createList = function (listId, props) { return ({
|
|
@@ -142,6 +143,12 @@ var listSetLayout = function (listId, layoutName) { return ({
|
|
|
142
143
|
layoutName: layoutName
|
|
143
144
|
}); };
|
|
144
145
|
exports.listSetLayout = listSetLayout;
|
|
146
|
+
var listChangeAction = function (listId, action) { return ({
|
|
147
|
+
type: exports.LIST_CHANGE_ACTION,
|
|
148
|
+
listId: listId,
|
|
149
|
+
action: action
|
|
150
|
+
}); };
|
|
151
|
+
exports.listChangeAction = listChangeAction;
|
|
145
152
|
/*export const initSSR = (listId, props) => (dispatch, getState, {http, clientStorage}) => {
|
|
146
153
|
const state = getState()
|
|
147
154
|
const stateList = _get(state, ['list', 'lists', listId]);
|
package/hooks/useList.js
CHANGED
|
@@ -275,6 +275,16 @@ function useList(config) {
|
|
|
275
275
|
(0, list_2.listSetItems)(config.listId, config.items),
|
|
276
276
|
]);
|
|
277
277
|
}, [dispatch, config.items, config.listId]);
|
|
278
|
+
// Check change action
|
|
279
|
+
var prevAction = (0, react_use_1.usePrevious)(config.action);
|
|
280
|
+
(0, react_use_1.useUpdateEffect)(function () {
|
|
281
|
+
if (prevAction && !(0, isEqual_1["default"])(config.action, prevAction)) {
|
|
282
|
+
dispatch([
|
|
283
|
+
(0, list_2.listChangeAction)(config.listId, config.action),
|
|
284
|
+
(0, list_2.listLazyFetch)(config.listId),
|
|
285
|
+
]);
|
|
286
|
+
}
|
|
287
|
+
}, [dispatch, config.listId, config.action, prevAction]);
|
|
278
288
|
// Destroy
|
|
279
289
|
(0, react_use_1.useUnmount)(function () {
|
|
280
290
|
var autoDestroy = typeof config.autoDestroy === 'boolean'
|
package/package.json
CHANGED
package/reducers/list.js
CHANGED
|
@@ -133,6 +133,10 @@ var reducerMap = (_a = {},
|
|
|
133
133
|
var _a;
|
|
134
134
|
return (__assign(__assign({}, state), { lists: __assign(__assign({}, state.lists), (_a = {}, _a[action.listId] = __assign(__assign({}, state.lists[action.listId]), { layoutName: action.layoutName }), _a)) }));
|
|
135
135
|
},
|
|
136
|
+
_a[list_1.LIST_CHANGE_ACTION] = function (state, action) {
|
|
137
|
+
var _a;
|
|
138
|
+
return (__assign(__assign({}, state), { lists: __assign(__assign({}, state.lists), (_a = {}, _a[action.listId] = __assign(__assign({}, state.lists[action.listId]), { action: action.action }), _a)) }));
|
|
139
|
+
},
|
|
136
140
|
_a);
|
|
137
141
|
exports["default"] = (function (state, action) {
|
|
138
142
|
if (state === void 0) { state = initialState; }
|
|
@@ -240,7 +240,7 @@ function DropDownField(props) {
|
|
|
240
240
|
var viewProps = (0, react_1.useMemo)(function () { return (__assign({ isAutoComplete: isAutoComplete, items: items, hoveredId: hoveredId, selectedIds: selectedIds, inputRef: inputRef, autoCompleteInputForwardedRef: autoCompleteInputForwardedRef, searchInputProps: searchInputProps, isOpened: isOpened, isLoading: isLoading, onOpen: onOpen, selectedItems: selectedItems,
|
|
241
241
|
// TODO onFocus
|
|
242
242
|
// TODO onBlur
|
|
243
|
-
onReset: onReset, onClose: onClose, renderItem: renderItem, onItemRemove: onItemRemove, hasGroup: hasGroup, multiple: props.multiple, isSearchAutoFocus: props.isSearchAutoFocus, itemToSelectAll: normalizedItemToSelectAll, className: props.className, viewProps: props.viewProps, dropDownProps: dropDownProps, style: props.style, size: props.size, color: props.color, outline: props.outline, placeholder: props.placeholder, showReset: props.showReset, showEllipses: props.showEllipses, errors: props.errors, disabled: props.disabled, maxHeight: props.maxHeight }, dataProvider)); }, [isAutoComplete, items, hoveredId, selectedIds, searchInputProps,
|
|
243
|
+
onReset: onReset, onClose: onClose, renderItem: renderItem, onItemRemove: onItemRemove, onItemSelect: onItemSelect, hasGroup: hasGroup, multiple: props.multiple, isSearchAutoFocus: props.isSearchAutoFocus, itemToSelectAll: normalizedItemToSelectAll, className: props.className, viewProps: props.viewProps, dropDownProps: dropDownProps, style: props.style, size: props.size, color: props.color, outline: props.outline, placeholder: props.placeholder, showReset: props.showReset, showEllipses: props.showEllipses, errors: props.errors, disabled: props.disabled, maxHeight: props.maxHeight }, dataProvider)); }, [isAutoComplete, items, hoveredId, selectedIds, searchInputProps,
|
|
244
244
|
isOpened, isLoading, onOpen, selectedItems, onReset, onClose, renderItem, dropDownProps,
|
|
245
245
|
onItemRemove, hasGroup, props.multiple, props.isSearchAutoFocus, props.className,
|
|
246
246
|
props.style, props.size, props.color, props.outline, props.placeholder, props.showReset,
|