@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.
Files changed (40) hide show
  1. package/lib/base.js +21 -24
  2. package/lib/components/{aside.js → aside/aside.js} +11 -12
  3. package/lib/components/aside/category-link-list.js +78 -0
  4. package/lib/components/aside/index.js +13 -0
  5. package/lib/components/category-select.js +55 -0
  6. package/lib/components/{button.js → custom-select/button.js} +1 -1
  7. package/lib/components/{custom-select.js → custom-select/custom-select.js} +8 -6
  8. package/lib/components/custom-select/index.js +13 -0
  9. package/lib/components/filter-author.js +2 -3
  10. package/lib/components/{empty.js → list/empty.js} +6 -8
  11. package/lib/components/list/index.js +13 -0
  12. package/lib/components/{list.js → list/list.js} +12 -12
  13. package/lib/components/search.js +17 -18
  14. package/lib/contexts/{store.js → filter.js} +90 -159
  15. package/lib/index.js +6 -16
  16. package/lib/libs/prop-types.js +34 -0
  17. package/lib/{tools → libs}/utils.js +6 -6
  18. package/package.json +60 -64
  19. package/src/base.js +17 -18
  20. package/src/components/{aside.js → aside/aside.js} +7 -8
  21. package/src/components/aside/category-link-list.js +53 -0
  22. package/src/components/aside/index.js +3 -0
  23. package/src/components/category-select.js +43 -0
  24. package/src/components/{button.js → custom-select/button.js} +0 -0
  25. package/src/components/{custom-select.js → custom-select/custom-select.js} +5 -4
  26. package/src/components/custom-select/index.js +3 -0
  27. package/src/components/filter-author.js +2 -3
  28. package/src/components/{empty.js → list/empty.js} +7 -8
  29. package/src/components/list/index.js +3 -0
  30. package/src/components/{list.js → list/list.js} +10 -10
  31. package/src/components/search.js +12 -12
  32. package/src/contexts/filter.js +196 -0
  33. package/src/index.js +6 -16
  34. package/src/libs/prop-types.js +26 -0
  35. package/src/{tools → libs}/utils.js +6 -6
  36. package/lib/components/categories.js +0 -143
  37. package/lib/hooks/page-state.js +0 -69
  38. package/src/components/categories.js +0 -129
  39. package/src/contexts/store.js +0 -266
  40. package/src/hooks/page-state.js +0 -53
@@ -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
- }