@pinnacle0/web-ui 0.5.16 → 0.5.17
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.
|
@@ -10,18 +10,6 @@ export interface Props<T extends object> {
|
|
|
10
10
|
}>;
|
|
11
11
|
itemWidth: number;
|
|
12
12
|
pageSize: number;
|
|
13
|
+
onPageChange?: (pageIndex: number) => void;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
currentItemIndex: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class PagedList<T extends object> extends React.PureComponent<Props<T>, State> {
|
|
18
|
-
static displayName: string;
|
|
19
|
-
constructor(props: Props<T>);
|
|
20
|
-
getUpperLimit: () => number;
|
|
21
|
-
goPreviousPage: () => void;
|
|
22
|
-
goNextPage: () => void;
|
|
23
|
-
goCurrentPage: () => void;
|
|
24
|
-
getRowKey: (record: T, index: number) => string | number;
|
|
25
|
-
render(): React.JSX.Element;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
15
|
+
export declare const PagedList: <T extends object>({ dataSource, rowKey, renderItem, itemWidth, pageSize, onPageChange }: Props<T>) => React.JSX.Element;
|
package/core/PagedList/index.js
CHANGED
|
@@ -1,81 +1,68 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
16
17
|
import React from "react";
|
|
18
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
17
19
|
import { classNames } from "../../util/ClassNames";
|
|
18
20
|
import { i18n } from "../../internal/i18n/core";
|
|
19
21
|
import "./index.less";
|
|
20
|
-
export var PagedList =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
_this.state = {
|
|
49
|
-
currentItemIndex: 0,
|
|
50
|
-
};
|
|
51
|
-
return _this;
|
|
52
|
-
}
|
|
53
|
-
PagedList.prototype.render = function () {
|
|
54
|
-
var _a;
|
|
55
|
-
var _this = this;
|
|
56
|
-
var dataSource = (_a = this.props, _a.dataSource), renderItem = _a.renderItem, itemWidth = _a.itemWidth, pageSize = _a.pageSize;
|
|
57
|
-
var currentItemIndex = this.state.currentItemIndex;
|
|
58
|
-
var isNextDisabled = currentItemIndex === 0;
|
|
59
|
-
var isPreviousDisabled = currentItemIndex >= this.getUpperLimit();
|
|
60
|
-
var t = i18n();
|
|
61
|
-
var Component = renderItem;
|
|
62
|
-
return (React.createElement("div", { className: "g-paged-list" },
|
|
63
|
-
React.createElement("div", { className: "list-wrap", style: { width: itemWidth * pageSize } },
|
|
64
|
-
React.createElement("div", { className: "list", style: { transform: "translateX(".concat(currentItemIndex * itemWidth, "px)") } }, dataSource.map(function (_, index) { return (React.createElement("div", { style: { flex: "0 0 ".concat(itemWidth, "px") }, key: _this.getRowKey(_, index) },
|
|
65
|
-
React.createElement(Component, { index: index, item: _ }))); })),
|
|
66
|
-
dataSource.length === 0 && React.createElement("div", { className: "no-data" }, t.noData)),
|
|
67
|
-
React.createElement("div", { className: "navigation" },
|
|
68
|
-
React.createElement("div", { onClick: isNextDisabled ? undefined : this.goNextPage, className: classNames({ disabled: isNextDisabled }) },
|
|
69
|
-
React.createElement("div", { className: "next-button" }),
|
|
70
|
-
React.createElement("div", null, t.nextPage)),
|
|
71
|
-
React.createElement("div", { onClick: isPreviousDisabled ? undefined : this.goPreviousPage, className: isPreviousDisabled ? "disabled" : "" },
|
|
72
|
-
React.createElement("div", { className: "previous-button" }),
|
|
73
|
-
React.createElement("div", null, t.prevPage)),
|
|
74
|
-
React.createElement("div", { onClick: isNextDisabled ? undefined : this.goCurrentPage, className: classNames({ disabled: isNextDisabled }) },
|
|
75
|
-
React.createElement("div", { className: "current-button" }),
|
|
76
|
-
React.createElement("div", null, t.currentPage)))));
|
|
22
|
+
export var PagedList = ReactUtil.memo("PagedList", function (_a) {
|
|
23
|
+
var dataSource = _a.dataSource, rowKey = _a.rowKey, renderItem = _a.renderItem, itemWidth = _a.itemWidth, pageSize = _a.pageSize, onPageChange = _a.onPageChange;
|
|
24
|
+
var _b = __read(React.useState(0), 2), currentItemIndex = _b[0], setCurrentItemIndex = _b[1];
|
|
25
|
+
var t = i18n();
|
|
26
|
+
var Component = renderItem;
|
|
27
|
+
var isNextDisabled = currentItemIndex === 0;
|
|
28
|
+
var upperLimit = dataSource.length - pageSize;
|
|
29
|
+
var isPreviousDisabled = currentItemIndex >= upperLimit;
|
|
30
|
+
var currentPageIndex = React.useMemo(function () { return Math.floor(currentItemIndex / pageSize); }, [currentItemIndex, pageSize]);
|
|
31
|
+
var goPreviousPage = function () {
|
|
32
|
+
setCurrentItemIndex(Math.max(0, Math.min(currentItemIndex + pageSize, upperLimit)));
|
|
33
|
+
};
|
|
34
|
+
var goNextPage = function () {
|
|
35
|
+
setCurrentItemIndex(Math.max(0, currentItemIndex - pageSize));
|
|
36
|
+
};
|
|
37
|
+
var goCurrentPage = function () { return setCurrentItemIndex(0); };
|
|
38
|
+
var getRowKey = function (record, index) {
|
|
39
|
+
if (rowKey === "index") {
|
|
40
|
+
return index;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof rowKey === "function") {
|
|
43
|
+
return rowKey(record, index);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return record[rowKey];
|
|
47
|
+
}
|
|
77
48
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
49
|
+
React.useEffect(function () {
|
|
50
|
+
onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(currentPageIndex);
|
|
51
|
+
}, [currentPageIndex, onPageChange]);
|
|
52
|
+
return (React.createElement("div", { className: "g-paged-list" },
|
|
53
|
+
React.createElement("div", { className: "list-wrap", style: { width: itemWidth * pageSize } },
|
|
54
|
+
React.createElement("div", { className: "list", style: { transform: "translateX(".concat(currentItemIndex * itemWidth, "px)") } }, dataSource.map(function (_, index) { return (React.createElement("div", { style: { flex: "0 0 ".concat(itemWidth, "px") }, key: getRowKey(_, index) },
|
|
55
|
+
React.createElement(Component, { index: index, item: _ }))); })),
|
|
56
|
+
dataSource.length === 0 && React.createElement("div", { className: "no-data" }, t.noData)),
|
|
57
|
+
React.createElement("div", { className: "navigation" },
|
|
58
|
+
React.createElement("div", { onClick: isNextDisabled ? undefined : goNextPage, className: classNames({ disabled: isNextDisabled }) },
|
|
59
|
+
React.createElement("div", { className: "next-button" }),
|
|
60
|
+
React.createElement("div", null, t.nextPage)),
|
|
61
|
+
React.createElement("div", { onClick: isPreviousDisabled ? undefined : goPreviousPage, className: isPreviousDisabled ? "disabled" : "" },
|
|
62
|
+
React.createElement("div", { className: "previous-button" }),
|
|
63
|
+
React.createElement("div", null, t.prevPage)),
|
|
64
|
+
React.createElement("div", { onClick: isNextDisabled ? undefined : goCurrentPage, className: classNames({ disabled: isNextDisabled }) },
|
|
65
|
+
React.createElement("div", { className: "current-button" }),
|
|
66
|
+
React.createElement("div", null, t.currentPage)))));
|
|
67
|
+
});
|
|
81
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/PagedList/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/PagedList/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAE9C,OAAO,cAAc,CAAC;AAWtB,MAAM,CAAC,IAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,UAAmB,EAA6E;QAA5E,UAAU,gBAAA,EAAE,MAAM,YAAA,EAAE,UAAU,gBAAA,EAAE,SAAS,eAAA,EAAE,QAAQ,cAAA,EAAE,YAAY,kBAAA;IAChI,IAAA,KAAA,OAA0C,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,EAA1D,gBAAgB,QAAA,EAAE,mBAAmB,QAAqB,CAAC;IAClE,IAAM,CAAC,GAAG,IAAI,EAAE,CAAC;IACjB,IAAM,SAAS,GAAG,UAAU,CAAC;IAC7B,IAAM,cAAc,GAAG,gBAAgB,KAAK,CAAC,CAAC;IAC9C,IAAM,UAAU,GAAG,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC;IAChD,IAAM,kBAAkB,GAAG,gBAAgB,IAAI,UAAU,CAAC;IAC1D,IAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,c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
|
-
{"version":3,"file":"StyleProvider.js","sourceRoot":"","sources":["../../src/core/StyleProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,aAAa,IAAI,iBAAiB,EAAE,kCAAkC,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"StyleProvider.js","sourceRoot":"","sources":["../../src/core/StyleProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,aAAa,IAAI,iBAAiB,EAAE,kCAAkC,EAAC,MAAM,qBAAqB,CAAC;AAM3G,MAAM,CAAC,IAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,eAAe,EAAE,UAAC,EAAiB;QAAhB,QAAQ,cAAA;IACnE,OAAO,CACH,oBAAC,iBAAiB,IAAC,YAAY,EAAC,MAAM,EAAC,YAAY,EAAE,CAAC,kCAAkC,CAAC,IACpF,QAAQ,CACO,CACvB,CAAC;AACN,CAAC,CAAC,CAAC"}
|