@blocklet/list 0.8.13 → 0.8.16
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/lib/base.js +21 -24
- package/lib/components/{aside.js → aside/aside.js} +11 -12
- package/lib/components/aside/category-link-list.js +78 -0
- package/lib/components/aside/index.js +13 -0
- package/lib/components/category-select.js +55 -0
- package/lib/components/{button.js → custom-select/button.js} +1 -1
- package/lib/components/{custom-select.js → custom-select/custom-select.js} +8 -6
- package/lib/components/custom-select/index.js +13 -0
- package/lib/components/filter-author.js +2 -3
- package/lib/components/{empty.js → list/empty.js} +6 -8
- package/lib/components/list/index.js +13 -0
- package/lib/components/{list.js → list/list.js} +12 -12
- package/lib/components/search.js +17 -18
- package/lib/contexts/{store.js → filter.js} +90 -159
- package/lib/index.js +6 -16
- package/lib/libs/prop-types.js +34 -0
- package/lib/{tools → libs}/utils.js +6 -6
- package/package.json +60 -64
- package/src/base.js +17 -18
- package/src/components/{aside.js → aside/aside.js} +7 -8
- package/src/components/aside/category-link-list.js +53 -0
- package/src/components/aside/index.js +3 -0
- package/src/components/category-select.js +43 -0
- package/src/components/{button.js → custom-select/button.js} +0 -0
- package/src/components/{custom-select.js → custom-select/custom-select.js} +5 -4
- package/src/components/custom-select/index.js +3 -0
- package/src/components/filter-author.js +2 -3
- package/src/components/{empty.js → list/empty.js} +7 -8
- package/src/components/list/index.js +3 -0
- package/src/components/{list.js → list/list.js} +10 -10
- package/src/components/search.js +12 -12
- package/src/contexts/filter.js +196 -0
- package/src/index.js +6 -16
- package/src/libs/prop-types.js +26 -0
- package/src/{tools → libs}/utils.js +6 -6
- package/lib/components/categories.js +0 -143
- package/lib/hooks/page-state.js +0 -69
- package/src/components/categories.js +0 -129
- package/src/contexts/store.js +0 -266
- package/src/hooks/page-state.js +0 -53
package/src/hooks/page-state.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useLocalStorageState, useReactive } from 'ahooks';
|
|
2
|
-
|
|
3
|
-
const PAGE_STATE_KEY = 'page-state';
|
|
4
|
-
|
|
5
|
-
export default function usePageState(defaultValue = {}, persistence = true, path = window.location.pathname) {
|
|
6
|
-
const [pageState, setPageState] = useLocalStorageState(PAGE_STATE_KEY, {});
|
|
7
|
-
const state = useReactive(pageState);
|
|
8
|
-
if (!(path in pageState) && persistence) {
|
|
9
|
-
state[path] = defaultValue;
|
|
10
|
-
syncState();
|
|
11
|
-
}
|
|
12
|
-
function syncState() {
|
|
13
|
-
setPageState(state);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return new Proxy(
|
|
17
|
-
{},
|
|
18
|
-
{
|
|
19
|
-
get: (target, prop) => {
|
|
20
|
-
try {
|
|
21
|
-
return state[path][prop];
|
|
22
|
-
} catch {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
set: (target, prop, value) => {
|
|
27
|
-
try {
|
|
28
|
-
const data = {
|
|
29
|
-
...(state[path] || {}),
|
|
30
|
-
[prop]: value,
|
|
31
|
-
};
|
|
32
|
-
state[path] = data;
|
|
33
|
-
syncState();
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
deleteProperty: (target, prop) => {
|
|
40
|
-
try {
|
|
41
|
-
const data = { ...(state[path] || {}) };
|
|
42
|
-
delete data[prop];
|
|
43
|
-
delete state[path][prop];
|
|
44
|
-
syncState();
|
|
45
|
-
return true;
|
|
46
|
-
} catch {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
ownKeys: () => Object.keys(state[path] || {}),
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|