@hzab/hierarchical-statistics 0.0.6 → 1.0.0-beta

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/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # @hzab/component-boilerplate@0.1.0
2
+ - fix: 删掉@hzab/list-render-mobile
3
+ - fix: 新增移动端下拉刷新
1
4
  # @hzab/component-boilerplate@0.0.6
2
5
  - fix: 修复跳转同路由,listRender参数依赖没有更新问题
3
6
  # @hzab/component-boilerplate@0.0.5
package/README.md CHANGED
@@ -11,8 +11,8 @@
11
11
  ## 示例
12
12
 
13
13
  ```jsx
14
- import InfiniteListUIPc from "@hzab/hierarchical-statistics/src/components/InfiniteListUiPc";
15
- <InfiniteListUIPc
14
+ import InfiniteListUi from "@hzab/hierarchical-statistics/src/components/InfiniteListUi";
15
+ <InfiniteListUi
16
16
  ref={listRef}
17
17
  style={{
18
18
  maxWidth: "400px",
@@ -47,7 +47,7 @@ import InfiniteListUIPc from "@hzab/hierarchical-statistics/src/components/Infin
47
47
  dynamicHeightMode: true,
48
48
  noMoreComponent: <div>没有更多数据了</div>,
49
49
  }}
50
- ></InfiniteListUIPc>
50
+ ></InfiniteListUi>
51
51
  ```
52
52
 
53
53
  ## API
@@ -58,7 +58,7 @@ import InfiniteListUIPc from "@hzab/hierarchical-statistics/src/components/Infin
58
58
  | -------------------- | ------------------------------| ----- | --------- | ----------------------------------- |
59
59
  | listModal | Object | 是 | - | 列表数据模型DataModel,必须包含getListApi |
60
60
  | breadModel | Object | 否 | - | 回显数据模型DataModel,必须包含getApi |
61
- | showHome | boolean | 否 | - | 是否显示面包屑首页 |
61
+ | showHome | Boolean | 否 | - | 是否显示面包屑首页 |
62
62
  | onNodeClick | function(item) | 否 | - | item点击事件 |
63
63
  | onNodeSelect | function(item) | 否 | - | item选中事件 |
64
64
  | onBreadcrumbClick | function(item) | 否 | - | 回显点击事件 |
@@ -70,10 +70,10 @@ import InfiniteListUIPc from "@hzab/hierarchical-statistics/src/components/Infin
70
70
  | listStyle | CSSProperties | 否 | - | 列表外层样式 |
71
71
  | readcrumbStyle | CSSProperties | 否 | - | 面包屑外层样式 |
72
72
  | separatorStyle | CSSProperties | 否 | - | 面包屑分割符样式 |
73
- | listRenderProps | Object | 否 | - | list-render-mobile 配置 |
74
73
  | virtualPagedListProps| Object | 否 | - | virtualPagedList 配置 |
75
74
  | separator | string | 否 | - | 分隔符 默认"-" |
76
75
  | Slots | Object | 是 | - | 插槽 |
76
+ | isPullRefresh | Boolean | 否 | false | 移动端是否可以下拉刷新 |
77
77
 
78
78
 
79
79
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@hzab/hierarchical-statistics",
3
- "version": "0.0.6",
3
+ "version": "1.0.0-beta",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
7
7
  "dev": "webpack serve -c ./config/webpack.config.js --env local",
8
8
  "build": "webpack -c ./config/webpack.config.js --env production",
9
+ "publish-beta": "npm publish --beta",
9
10
  "publish-patch": "npm version patch && npm publish --access public",
10
11
  "publish-minor": "npm version minor && npm publish --access public",
11
12
  "publish-major": "npm version major && npm publish --access public",
@@ -48,7 +49,9 @@
48
49
  },
49
50
  "peerDependencies": {
50
51
  "@hzab/data-model": ">=1.7.5",
51
- "@hzab/headless-components": ">=0.0.3",
52
- "@hzab/list-render-mobile": ">=1.1.7"
52
+ "@hzab/headless-components": ">=0.0.3"
53
+ },
54
+ "dependencies": {
55
+ "react-window-pull-refresh": "^1.0.9"
53
56
  }
54
57
  }
@@ -1,8 +1,8 @@
1
1
  import "../index.less";
2
2
  const BreadcrumbUI = (props: any) => {
3
- const { readcrumbStyle, separatorStyle, separator, breadcrumbData, terminal, handleBreadcrumbClick } = props;
3
+ const { readcrumbStyle, separatorStyle, separator, breadcrumbData, handleBreadcrumbClick } = props;
4
4
  return (
5
- <div className={`breadcrumb-box ${terminal !== "pc" ? "breadcrumb-box-mobile" : ""}`} style={readcrumbStyle}>
5
+ <div className={`breadcrumb-box`} style={readcrumbStyle}>
6
6
  {breadcrumbData.map((item, index) => (
7
7
  <div className="breadcrumb-item" key={index}>
8
8
  <span
@@ -1,11 +1,12 @@
1
1
  import { ForwardedRef, forwardRef, useImperativeHandle, useRef } from "react";
2
+ import { PullToRefresh } from "react-window-pull-refresh";
2
3
  import VirtualPagedList from "@hzab/headless-components/src/VirtualPagedList";
3
4
  import { ConfigProvider, Spin, Empty, Button } from "antd";
4
5
  import { useInfiniteList } from "../../use-infinite-list";
5
6
  import Breadcrumb from "../Breadcrumb";
6
7
  import { InfiniteListProps, InfiniteListInstance } from "../../type";
7
8
  import "../index.less";
8
- const InfiniteListUIPc = (props: InfiniteListProps, ref: ForwardedRef<InfiniteListInstance>) => {
9
+ const InfiniteListUi = (props: InfiniteListProps, ref: ForwardedRef<InfiniteListInstance>) => {
9
10
  const {
10
11
  states: {
11
12
  listModal,
@@ -23,9 +24,10 @@ const InfiniteListUIPc = (props: InfiniteListProps, ref: ForwardedRef<InfiniteLi
23
24
  virtualPagedListProps,
24
25
  className,
25
26
  refreshKey,
27
+ isPullRefresh,
26
28
  },
27
- actions: { handleSelectId, handleNodeClick, handleBreadcrumbClick, fetchBreadData },
28
- } = useInfiniteList({ ...props, terminal: "pc" });
29
+ actions: { handleSelectId, handleNodeClick, handleBreadcrumbClick, fetchBreadData, handleListRefresh },
30
+ } = useInfiniteList({ ...props });
29
31
 
30
32
  useImperativeHandle(ref, () => ({
31
33
  handleNodeClick,
@@ -35,6 +37,7 @@ const InfiniteListUIPc = (props: InfiniteListProps, ref: ForwardedRef<InfiniteLi
35
37
  breadModel,
36
38
  fetchBreadData,
37
39
  breadcrumbData,
40
+ handleListRefresh,
38
41
  }));
39
42
 
40
43
  const loadData = async (pageNum) => {
@@ -46,13 +49,41 @@ const InfiniteListUIPc = (props: InfiniteListProps, ref: ForwardedRef<InfiniteLi
46
49
  isMore: res?.pagination?.total > (pageNum - 1) * listModal.query.pageSize + res?.list?.length ? true : false,
47
50
  };
48
51
  };
52
+
53
+ const JsxDom = (propJsx) => {
54
+ let jsx = <></>;
55
+ if (isPullRefresh) {
56
+ jsx = (
57
+ <PullToRefresh handleRefresh={handleListRefresh}>
58
+ <VirtualPagedList
59
+ key={refreshKey}
60
+ ref={listRef}
61
+ {...virtualPagedListProps}
62
+ renderItem={Slots.renderItem}
63
+ loadMoreItems={loadData}
64
+ />
65
+ </PullToRefresh>
66
+ );
67
+ } else {
68
+ jsx = (
69
+ <VirtualPagedList
70
+ key={refreshKey}
71
+ ref={listRef}
72
+ {...virtualPagedListProps}
73
+ renderItem={Slots.renderItem}
74
+ loadMoreItems={loadData}
75
+ />
76
+ );
77
+ }
78
+ return jsx;
79
+ };
80
+
49
81
  return (
50
82
  <div className={`infinite-level-box ${className || ""}`} style={style}>
51
83
  <Spin spinning={loading}>
52
84
  {/* 面包屑导航 */}
53
85
  <div className="infinite-level-breadcrumb-position">
54
86
  <Breadcrumb
55
- terminal="pc"
56
87
  readcrumbStyle={readcrumbStyle}
57
88
  separatorStyle={separatorStyle}
58
89
  separator={separator}
@@ -62,17 +93,11 @@ const InfiniteListUIPc = (props: InfiniteListProps, ref: ForwardedRef<InfiniteLi
62
93
  {Slots?.fixRenderCenter && <Slots.fixRenderCenter></Slots.fixRenderCenter>}
63
94
  </div>
64
95
  <div className="infinite-level-list-box" style={listStyle}>
65
- <VirtualPagedList
66
- key={refreshKey}
67
- ref={listRef}
68
- {...virtualPagedListProps}
69
- renderItem={Slots.renderItem}
70
- loadMoreItems={loadData}
71
- />
96
+ <JsxDom></JsxDom>
72
97
  </div>
73
98
  </Spin>
74
99
  </div>
75
100
  );
76
101
  };
77
102
 
78
- export default forwardRef<InfiniteListInstance, InfiniteListProps>(InfiniteListUIPc);
103
+ export default forwardRef<InfiniteListInstance, InfiniteListProps>(InfiniteListUi);
package/src/type.d.ts CHANGED
@@ -29,6 +29,8 @@ export interface InfiniteListInstance {
29
29
  breadcrumbData?: any;
30
30
  /** 面包屑数据请求方法 */
31
31
  fetchBreadData?: () => Promise<void>;
32
+ /** 列表刷新 */
33
+ handleListRefresh?: () => void;
32
34
  }
33
35
  export interface InfiniteListProps {
34
36
  /** 添加外层类名 */
@@ -58,8 +60,6 @@ export interface InfiniteListProps {
58
60
  separatorStyle?: object;
59
61
  /** 面包屑外层 自定义css 样式 */
60
62
  readcrumbStyle?: object;
61
- /** 设备是pc,还是mobile */
62
- terminal?: string;
63
63
  /** 列表外层 css 样式 */
64
64
  listStyle?: object;
65
65
  /** list modal */
@@ -70,6 +70,8 @@ export interface InfiniteListProps {
70
70
  listRenderProps?: object;
71
71
  /** virtualPagedList 配置 */
72
72
  virtualPagedListProps?: any;
73
+ /** 是否可下拉刷新 */
74
+ isPullRefresh?: boolean;
73
75
  /** 选中点击事件 */
74
76
  onNodeClick?: (node: ListItem) => void;
75
77
  /** 选中id */
@@ -29,6 +29,7 @@ export function useInfiniteList(props: InfiniteListProps) {
29
29
  breadModel,
30
30
  virtualPagedListProps,
31
31
  className,
32
+ isPullRefresh = false,
32
33
  } = props;
33
34
  const [loading, setLoading] = useState(false);
34
35
  const [selectedLoadIdNode, setSelectedLoadIdNode] = useState<number | null>(null);
@@ -111,6 +112,11 @@ export function useInfiniteList(props: InfiniteListProps) {
111
112
  setLoading(false);
112
113
  }
113
114
  };
115
+ /** 列表刷新 */
116
+ const handleListRefresh = async () => {
117
+ listModal.query = { ...listModal.query, pageNum: 1 };
118
+ setRefreshKey((pre) => pre + 1);
119
+ };
114
120
 
115
121
  useEffect(() => {
116
122
  fetchBreadData();
@@ -135,12 +141,14 @@ export function useInfiniteList(props: InfiniteListProps) {
135
141
  breadModel,
136
142
  className,
137
143
  refreshKey,
144
+ isPullRefresh,
138
145
  },
139
146
  actions: {
140
147
  handleSelectId,
141
148
  handleNodeClick,
142
149
  handleBreadcrumbClick,
143
150
  fetchBreadData,
151
+ handleListRefresh,
144
152
  },
145
153
  };
146
154
  }
@@ -1,69 +0,0 @@
1
- import { ForwardedRef, forwardRef, useImperativeHandle, useRef } from "react";
2
- import { ConfigProvider, Spin } from "antd";
3
- import ListRender from "@hzab/list-render-mobile";
4
- import { useInfiniteList } from "../../use-infinite-list";
5
- import { InfiniteListProps, InfiniteListInstance } from "../../type";
6
- import Breadcrumb from "../Breadcrumb";
7
- import "../index.less";
8
- const InfiniteListUIMobile = (props: InfiniteListProps, ref: ForwardedRef<InfiniteListInstance>) => {
9
- const {
10
- states: {
11
- readcrumbStyle,
12
- separatorStyle,
13
- separator,
14
- listRenderProps,
15
- style,
16
- listModal,
17
- breadcrumbData,
18
- Slots,
19
- loading,
20
- listRef,
21
- listStyle,
22
- breadModel,
23
- className,
24
- refreshKey,
25
- },
26
- actions: { fetchBreadData, handleSelectId, handleNodeClick, handleBreadcrumbClick },
27
- } = useInfiniteList({ ...props, terminal: "mobile" });
28
- useImperativeHandle(ref, () => ({
29
- handleNodeClick,
30
- handleSelectId,
31
- listRef: listRef?.current,
32
- listModal,
33
- breadModel,
34
- fetchBreadData,
35
- breadcrumbData,
36
- }));
37
- return (
38
- <div className={`infinite-level-box ${className || ""}`} style={style}>
39
- <Spin spinning={loading}>
40
- {/* 面包屑导航 */}
41
- <div className="infinite-level-breadcrumb-position">
42
- <Breadcrumb
43
- terminal="mobile"
44
- readcrumbStyle={readcrumbStyle}
45
- separatorStyle={separatorStyle}
46
- separator={separator}
47
- breadcrumbData={breadcrumbData}
48
- handleBreadcrumbClick={handleBreadcrumbClick}
49
- Slots={Slots}
50
- ></Breadcrumb>
51
- {Slots?.fixRenderCenter && <Slots.fixRenderCenter></Slots.fixRenderCenter>}
52
- </div>
53
-
54
- <div className="infinite-level-list-box" style={listStyle}>
55
- {/* 移动端 */}
56
- <ListRender
57
- key={refreshKey}
58
- ref={listRef}
59
- model={listModal}
60
- {...listRenderProps}
61
- ItemRender={Slots.renderItem}
62
- />
63
- </div>
64
- </Spin>
65
- </div>
66
- );
67
- };
68
-
69
- export default forwardRef<InfiniteListInstance, InfiniteListProps>(InfiniteListUIMobile);