@pingux/astro 2.119.0-alpha.2 → 2.119.0-alpha.4
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/cjs/components/Button/Buttons.styles.d.ts +40 -0
- package/lib/cjs/components/Button/Buttons.styles.js +4 -0
- package/lib/cjs/components/ListView/ListView.stories.d.ts +3 -0
- package/lib/cjs/components/ListView/ListView.stories.js +2 -1
- package/lib/cjs/components/Pagination/Pagination.d.ts +4 -0
- package/lib/cjs/components/Pagination/Pagination.js +78 -0
- package/lib/cjs/components/Pagination/Pagination.mdx +68 -0
- package/lib/cjs/components/Pagination/Pagination.stories.d.ts +39 -0
- package/lib/cjs/components/Pagination/Pagination.stories.js +159 -0
- package/lib/cjs/components/Pagination/Pagination.styles.d.ts +17 -0
- package/lib/cjs/components/Pagination/Pagination.styles.js +27 -0
- package/lib/cjs/components/Pagination/Pagination.test.d.ts +1 -0
- package/lib/cjs/components/Pagination/Pagination.test.js +208 -0
- package/lib/cjs/components/Pagination/PaginationProvider.d.ts +4 -0
- package/lib/cjs/components/Pagination/PaginationProvider.js +38 -0
- package/lib/cjs/components/Pagination/index.d.ts +2 -0
- package/lib/cjs/components/Pagination/index.js +33 -0
- package/lib/cjs/context/PaginationContext/index.d.ts +10 -0
- package/lib/cjs/context/PaginationContext/index.js +20 -0
- package/lib/cjs/fonts.d.ts +2 -0
- package/lib/cjs/fonts.js +11 -0
- package/lib/cjs/hooks/index.d.ts +2 -0
- package/lib/cjs/hooks/index.js +14 -0
- package/lib/cjs/hooks/usePagination/index.d.ts +1 -0
- package/lib/cjs/hooks/usePagination/index.js +14 -0
- package/lib/cjs/hooks/usePagination/usePagination.d.ts +682 -0
- package/lib/cjs/hooks/usePagination/usePagination.js +178 -0
- package/lib/cjs/hooks/usePaginationState/index.d.ts +1 -0
- package/lib/cjs/hooks/usePaginationState/index.js +14 -0
- package/lib/cjs/hooks/usePaginationState/usePaginationState.d.ts +4 -0
- package/lib/cjs/hooks/usePaginationState/usePaginationState.js +18 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +24 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +3 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
- package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +1 -1
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +17 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +17 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.js +7 -1
- package/lib/cjs/styles/variants/variants.js +3 -1
- package/lib/cjs/types/pagination.d.ts +46 -0
- package/lib/cjs/types/pagination.js +6 -0
- package/lib/components/Button/Buttons.styles.js +4 -0
- package/lib/components/ListView/ListView.stories.js +1 -1
- package/lib/components/Pagination/Pagination.js +64 -0
- package/lib/components/Pagination/Pagination.mdx +68 -0
- package/lib/components/Pagination/Pagination.stories.js +141 -0
- package/lib/components/Pagination/Pagination.styles.js +19 -0
- package/lib/components/Pagination/Pagination.test.js +205 -0
- package/lib/components/Pagination/PaginationProvider.js +24 -0
- package/lib/components/Pagination/index.js +2 -0
- package/lib/context/PaginationContext/index.js +11 -0
- package/lib/fonts.js +2 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/usePagination/index.js +1 -0
- package/lib/hooks/usePagination/usePagination.js +170 -0
- package/lib/hooks/usePaginationState/index.js +1 -0
- package/lib/hooks/usePaginationState/usePaginationState.js +10 -0
- package/lib/index.js +3 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
- package/lib/styles/themes/next-gen/convertedComponentList.js +1 -1
- package/lib/styles/themes/next-gen/variants/button.js +7 -1
- package/lib/styles/variants/variants.js +3 -1
- package/lib/types/pagination.js +1 -0
- package/package.json +1 -1
- package/lib/cjs/fonts.jsx +0 -137
- package/lib/fonts.jsx +0 -137
@@ -0,0 +1,178 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
12
|
+
_Object$defineProperty(exports, "__esModule", {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
exports["default"] = void 0;
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
18
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
19
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
20
|
+
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
|
21
|
+
var _react = require("react");
|
22
|
+
var _PaginationContext = require("../../context/PaginationContext");
|
23
|
+
var _useProgressiveState5 = _interopRequireDefault(require("../useProgressiveState"));
|
24
|
+
var _excluded = ["currentPageIndex", "nextButtonProps", "offsetCount", "offsetMenuProps", "offsetOptions", "onOffsetCountChange", "onPageIndexChange", "previousButtonProps", "totalCount"];
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
27
|
+
var getRangeString = function getRangeString(_ref) {
|
28
|
+
var _context, _context2;
|
29
|
+
var first = _ref.first,
|
30
|
+
last = _ref.last,
|
31
|
+
total = _ref.total;
|
32
|
+
return (0, _concat["default"])(_context = (0, _concat["default"])(_context2 = "".concat(first + 1, "-")).call(_context2, Math.min(last + 1, total), " of ")).call(_context, total);
|
33
|
+
};
|
34
|
+
var getNewIndexOnOffsetChange = function getNewIndexOnOffsetChange(_ref2) {
|
35
|
+
var first = _ref2.first,
|
36
|
+
newOffset = _ref2.newOffset;
|
37
|
+
var newLast = Math.floor(first / newOffset);
|
38
|
+
return newLast;
|
39
|
+
};
|
40
|
+
var defaultOffsetOptions = [10, 25, 50];
|
41
|
+
var usePagination = function usePagination(props) {
|
42
|
+
var currentPageIndexProp = props.currentPageIndex,
|
43
|
+
nextButtonProps = props.nextButtonProps,
|
44
|
+
offsetCountProp = props.offsetCount,
|
45
|
+
offsetMenuProps = props.offsetMenuProps,
|
46
|
+
_props$offsetOptions = props.offsetOptions,
|
47
|
+
offsetOptions = _props$offsetOptions === void 0 ? defaultOffsetOptions : _props$offsetOptions,
|
48
|
+
onOffsetCountChange = props.onOffsetCountChange,
|
49
|
+
onPageIndexChange = props.onPageIndexChange,
|
50
|
+
previousButtonProps = props.previousButtonProps,
|
51
|
+
totalCount = props.totalCount,
|
52
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
53
|
+
var isMountedRef = (0, _react.useRef)(false);
|
54
|
+
var initialIndexValue = currentPageIndexProp || 0;
|
55
|
+
var initialOffsetValue = offsetCountProp || 10;
|
56
|
+
var _useProgressiveState = (0, _useProgressiveState5["default"])(currentPageIndexProp, initialIndexValue),
|
57
|
+
_useProgressiveState2 = (0, _slicedToArray2["default"])(_useProgressiveState, 2),
|
58
|
+
currentPageIndex = _useProgressiveState2[0],
|
59
|
+
setCurrentPageIndex = _useProgressiveState2[1];
|
60
|
+
var _useProgressiveState3 = (0, _useProgressiveState5["default"])(offsetCountProp, initialOffsetValue),
|
61
|
+
_useProgressiveState4 = (0, _slicedToArray2["default"])(_useProgressiveState3, 2),
|
62
|
+
offsetCount = _useProgressiveState4[0],
|
63
|
+
setOffsetCount = _useProgressiveState4[1];
|
64
|
+
var _useState = (0, _react.useState)(currentPageIndex),
|
65
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
66
|
+
firstRenderedIndex = _useState2[0],
|
67
|
+
setFirstRenderedIndex = _useState2[1];
|
68
|
+
var _useState3 = (0, _react.useState)((currentPageIndex + 1) * offsetCount - 1),
|
69
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
70
|
+
lastRenderedIndex = _useState4[0],
|
71
|
+
setLastRenderedIndex = _useState4[1];
|
72
|
+
(0, _react.useEffect)(function () {
|
73
|
+
var calculatedLastIndex = (currentPageIndex + 1) * offsetCount - 1;
|
74
|
+
setFirstRenderedIndex(currentPageIndex * offsetCount);
|
75
|
+
setLastRenderedIndex(Math.min(calculatedLastIndex, totalCount));
|
76
|
+
}, [currentPageIndex, offsetCount, totalCount]);
|
77
|
+
(0, _react.useEffect)(function () {
|
78
|
+
if (isMountedRef.current) {
|
79
|
+
var newIndex = getNewIndexOnOffsetChange({
|
80
|
+
newOffset: offsetCount,
|
81
|
+
first: firstRenderedIndex
|
82
|
+
});
|
83
|
+
setCurrentPageIndex(newIndex);
|
84
|
+
if (onPageIndexChange) {
|
85
|
+
onPageIndexChange(newIndex);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}, [offsetCount]);
|
89
|
+
(0, _react.useEffect)(function () {
|
90
|
+
isMountedRef.current = true;
|
91
|
+
}, []);
|
92
|
+
var lastIndex = Math.ceil(totalCount / offsetCount);
|
93
|
+
var isFirstIndex = currentPageIndex === 0;
|
94
|
+
var isLastIndex = lastIndex - 1 === currentPageIndex;
|
95
|
+
var popoverButtonString = (0, _react.useMemo)(function () {
|
96
|
+
return getRangeString({
|
97
|
+
first: firstRenderedIndex,
|
98
|
+
last: lastRenderedIndex,
|
99
|
+
total: totalCount
|
100
|
+
});
|
101
|
+
}, [firstRenderedIndex, lastRenderedIndex, totalCount]);
|
102
|
+
var setOffsetCountCallback = (0, _react.useCallback)(function (keys) {
|
103
|
+
if (keys !== null && keys !== void 0 && keys.currentKey) {
|
104
|
+
setOffsetCount((0, _parseInt2["default"])(keys.currentKey, 10));
|
105
|
+
if (onOffsetCountChange && isMountedRef.current) {
|
106
|
+
onOffsetCountChange((0, _parseInt2["default"])(keys.currentKey, 10));
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}, [setOffsetCount, onOffsetCountChange, isMountedRef]);
|
110
|
+
var paginationState = (0, _react.useMemo)(function () {
|
111
|
+
return {
|
112
|
+
isFirstIndex: isFirstIndex,
|
113
|
+
isLastIndex: isLastIndex,
|
114
|
+
firstRenderedIndex: firstRenderedIndex,
|
115
|
+
lastRenderedIndex: lastRenderedIndex,
|
116
|
+
offsetCount: offsetCount,
|
117
|
+
totalCount: totalCount,
|
118
|
+
currentPageIndex: currentPageIndex,
|
119
|
+
popoverButtonString: popoverButtonString,
|
120
|
+
setOffsetCount: setOffsetCountCallback,
|
121
|
+
offsetOptions: offsetOptions
|
122
|
+
};
|
123
|
+
}, [isFirstIndex, isLastIndex, firstRenderedIndex, lastRenderedIndex, offsetCount, totalCount, currentPageIndex, popoverButtonString, setOffsetCountCallback, offsetOptions]);
|
124
|
+
var contextState = (0, _react.useMemo)(function () {
|
125
|
+
return {
|
126
|
+
firstRenderedIndex: firstRenderedIndex,
|
127
|
+
lastRenderedIndex: lastRenderedIndex,
|
128
|
+
offsetCount: offsetCount,
|
129
|
+
totalCount: totalCount,
|
130
|
+
currentPageIndex: currentPageIndex
|
131
|
+
};
|
132
|
+
}, [firstRenderedIndex, lastRenderedIndex, offsetCount, totalCount, currentPageIndex]);
|
133
|
+
var _useContext = (0, _react.useContext)(_PaginationContext.PaginationContext),
|
134
|
+
setPaginationState = _useContext.setPaginationState;
|
135
|
+
(0, _react.useEffect)(function () {
|
136
|
+
if (setPaginationState) {
|
137
|
+
setPaginationState(_objectSpread({}, contextState));
|
138
|
+
}
|
139
|
+
}, [contextState, setPaginationState]);
|
140
|
+
var nextIndex = function nextIndex() {
|
141
|
+
if (!isLastIndex) {
|
142
|
+
setCurrentPageIndex(currentPageIndex + 1);
|
143
|
+
if (onPageIndexChange) {
|
144
|
+
onPageIndexChange(currentPageIndex + 1);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
};
|
148
|
+
var previousIndex = function previousIndex() {
|
149
|
+
if (!isFirstIndex) {
|
150
|
+
setCurrentPageIndex(currentPageIndex - 1);
|
151
|
+
if (onPageIndexChange) {
|
152
|
+
onPageIndexChange(currentPageIndex - 1);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
};
|
156
|
+
var nextButtonPropsSpread = _objectSpread(_objectSpread({
|
157
|
+
'aria-label': 'Next Page'
|
158
|
+
}, nextButtonProps), {}, {
|
159
|
+
isDisabled: isLastIndex,
|
160
|
+
onPress: nextIndex
|
161
|
+
});
|
162
|
+
var previousButtonPropsSpread = _objectSpread(_objectSpread({
|
163
|
+
'aria-label': 'Previous Page'
|
164
|
+
}, previousButtonProps), {}, {
|
165
|
+
isDisabled: isFirstIndex,
|
166
|
+
onPress: previousIndex
|
167
|
+
});
|
168
|
+
var containerProps = _objectSpread({}, others);
|
169
|
+
return {
|
170
|
+
state: paginationState,
|
171
|
+
previousButtonProps: previousButtonPropsSpread,
|
172
|
+
nextButtonProps: nextButtonPropsSpread,
|
173
|
+
containerProps: containerProps,
|
174
|
+
offsetMenuProps: offsetMenuProps
|
175
|
+
};
|
176
|
+
};
|
177
|
+
var _default = usePagination;
|
178
|
+
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './usePaginationState';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
_Object$defineProperty(exports, "default", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function get() {
|
11
|
+
return _usePaginationState["default"];
|
12
|
+
}
|
13
|
+
});
|
14
|
+
var _usePaginationState = _interopRequireDefault(require("./usePaginationState"));
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports["default"] = void 0;
|
8
|
+
var _react = require("react");
|
9
|
+
var _PaginationContext = require("../../context/PaginationContext");
|
10
|
+
var usePaginationState = function usePaginationState() {
|
11
|
+
var _useContext = (0, _react.useContext)(_PaginationContext.PaginationContext),
|
12
|
+
paginationState = _useContext.paginationState;
|
13
|
+
return {
|
14
|
+
paginationState: paginationState
|
15
|
+
};
|
16
|
+
};
|
17
|
+
var _default = usePaginationState;
|
18
|
+
exports["default"] = _default;
|
package/lib/cjs/index.d.ts
CHANGED
@@ -134,6 +134,8 @@ export * from './components/NumberField';
|
|
134
134
|
export { default as OverlayPanel } from './components/OverlayPanel';
|
135
135
|
export * from './components/OverlayPanel';
|
136
136
|
export { default as PageHeader } from './components/PageHeader';
|
137
|
+
export { default as Pagination } from './components/Pagination';
|
138
|
+
export { default as PaginationProvider } from './components/Pagination/PaginationProvider';
|
137
139
|
export { default as PanelHeader } from './components/PanelHeader';
|
138
140
|
export { default as PanelHeaderCloseButton } from './components/PanelHeader/controls/PanelHeaderCloseButton';
|
139
141
|
export { default as PanelHeaderMenu } from './components/PanelHeader/controls/PanelHeaderMenu';
|
@@ -206,6 +208,7 @@ export { default as TooltipTrigger } from './components/TooltipTrigger';
|
|
206
208
|
export * from './components/TooltipTrigger';
|
207
209
|
export { default as TreeView } from './components/TreeView';
|
208
210
|
export * from './components/TreeView';
|
211
|
+
export { PaginationContext } from './context/PaginationContext';
|
209
212
|
export { default as NextGenDarkTheme } from './styles/themeOverrides/nextGenDarkMode';
|
210
213
|
export { default as OnyxDarkTheme } from './styles/themeOverrides/nextGenDarkMode';
|
211
214
|
export { default as NextGenTheme } from './styles/themes/next-gen';
|
package/lib/cjs/index.js
CHANGED
@@ -101,6 +101,8 @@ var _exportNames = {
|
|
101
101
|
NumberField: true,
|
102
102
|
OverlayPanel: true,
|
103
103
|
PageHeader: true,
|
104
|
+
Pagination: true,
|
105
|
+
PaginationProvider: true,
|
104
106
|
PanelHeader: true,
|
105
107
|
PanelHeaderCloseButton: true,
|
106
108
|
PanelHeaderMenu: true,
|
@@ -142,6 +144,7 @@ var _exportNames = {
|
|
142
144
|
TimeZonePicker: true,
|
143
145
|
TooltipTrigger: true,
|
144
146
|
TreeView: true,
|
147
|
+
PaginationContext: true,
|
145
148
|
NextGenDarkTheme: true,
|
146
149
|
OnyxDarkTheme: true,
|
147
150
|
NextGenTheme: true,
|
@@ -675,6 +678,24 @@ _Object$defineProperty(exports, "PageHeader", {
|
|
675
678
|
return _PageHeader["default"];
|
676
679
|
}
|
677
680
|
});
|
681
|
+
_Object$defineProperty(exports, "Pagination", {
|
682
|
+
enumerable: true,
|
683
|
+
get: function get() {
|
684
|
+
return _Pagination["default"];
|
685
|
+
}
|
686
|
+
});
|
687
|
+
_Object$defineProperty(exports, "PaginationContext", {
|
688
|
+
enumerable: true,
|
689
|
+
get: function get() {
|
690
|
+
return _PaginationContext.PaginationContext;
|
691
|
+
}
|
692
|
+
});
|
693
|
+
_Object$defineProperty(exports, "PaginationProvider", {
|
694
|
+
enumerable: true,
|
695
|
+
get: function get() {
|
696
|
+
return _PaginationProvider["default"];
|
697
|
+
}
|
698
|
+
});
|
678
699
|
_Object$defineProperty(exports, "PanelHeader", {
|
679
700
|
enumerable: true,
|
680
701
|
get: function get() {
|
@@ -1639,6 +1660,8 @@ _forEachInstanceProperty(_context47 = _Object$keys(_OverlayPanel)).call(_context
|
|
1639
1660
|
});
|
1640
1661
|
});
|
1641
1662
|
var _PageHeader = _interopRequireDefault(require("./components/PageHeader"));
|
1663
|
+
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
1664
|
+
var _PaginationProvider = _interopRequireDefault(require("./components/Pagination/PaginationProvider"));
|
1642
1665
|
var _PanelHeader = _interopRequireDefault(require("./components/PanelHeader"));
|
1643
1666
|
var _PanelHeaderCloseButton = _interopRequireDefault(require("./components/PanelHeader/controls/PanelHeaderCloseButton"));
|
1644
1667
|
var _PanelHeaderMenu = _interopRequireDefault(require("./components/PanelHeader/controls/PanelHeaderMenu"));
|
@@ -2031,6 +2054,7 @@ _forEachInstanceProperty(_context79 = _Object$keys(_TreeView)).call(_context79,
|
|
2031
2054
|
}
|
2032
2055
|
});
|
2033
2056
|
});
|
2057
|
+
var _PaginationContext = require("./context/PaginationContext");
|
2034
2058
|
var _nextGenDarkMode = _interopRequireDefault(require("./styles/themeOverrides/nextGenDarkMode"));
|
2035
2059
|
var _nextGen = _interopRequireDefault(require("./styles/themes/next-gen"));
|
2036
2060
|
var _types = require("./types");
|
@@ -5,7 +5,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.nextGenOnlyComponents = exports["default"] = exports.componentSpecificNextGenBlacklist = exports.astroBlacklistStory = void 0;
|
8
|
-
var nextGenConvertedComponents = ['DataTable', 'Message', 'Button', 'Badge', 'IconButton', 'CheckboxField', 'Messages', 'PopoverMenu', 'TextField', 'PasswordField', 'SearchField', 'SelectField', 'Modal', 'RadioField', 'MultiValuesField', 'TextAreaField', 'RadioGroupField', 'Tabs', 'ProgressBar', 'NavBar', 'OverlayPanel', 'AstroProvider', 'ListView', 'NavigationHeader', 'Avatar', 'MultivaluesField', 'Text', 'Link', 'Card', 'IconWrapper', 'ComboBoxField', 'CodeView', 'Sticker Sheet', 'NextGen ListViewItem', 'Skeleton'];
|
8
|
+
var nextGenConvertedComponents = ['DataTable', 'Message', 'Button', 'Badge', 'IconButton', 'CheckboxField', 'Messages', 'PopoverMenu', 'TextField', 'PasswordField', 'SearchField', 'SelectField', 'Modal', 'RadioField', 'MultiValuesField', 'TextAreaField', 'RadioGroupField', 'Tabs', 'ProgressBar', 'NavBar', 'OverlayPanel', 'AstroProvider', 'ListView', 'NavigationHeader', 'Avatar', 'MultivaluesField', 'Text', 'Link', 'Card', 'IconWrapper', 'ComboBoxField', 'CodeView', 'Sticker Sheet', 'NextGen ListViewItem', 'Skeleton', 'Pagination'];
|
9
9
|
var componentSpecificNextGenBlacklist = {
|
10
10
|
AstroProvider: ['Default', 'With Custom Theme Override'],
|
11
11
|
Badge: ['Status Badge Variants', 'Badge With Left Slot And Icon', 'Callout Badges', 'Removable'],
|
@@ -1086,6 +1086,23 @@ declare const _default: {
|
|
1086
1086
|
};
|
1087
1087
|
transition: string;
|
1088
1088
|
};
|
1089
|
+
paginationMenu: {
|
1090
|
+
px: string;
|
1091
|
+
py: string;
|
1092
|
+
color: string;
|
1093
|
+
transition: string;
|
1094
|
+
fontSize: string;
|
1095
|
+
textDecoration: string;
|
1096
|
+
'&.is-pressed': {
|
1097
|
+
textDecoration: string;
|
1098
|
+
outline: string;
|
1099
|
+
color: string;
|
1100
|
+
};
|
1101
|
+
'&.is-focused': {
|
1102
|
+
textDecoration: string;
|
1103
|
+
outline: string;
|
1104
|
+
};
|
1105
|
+
};
|
1089
1106
|
};
|
1090
1107
|
forms: {
|
1091
1108
|
input: import("theme-ui").ThemeUICSSObject;
|
@@ -853,5 +853,22 @@ declare const buttons: {
|
|
853
853
|
};
|
854
854
|
transition: string;
|
855
855
|
};
|
856
|
+
paginationMenu: {
|
857
|
+
px: string;
|
858
|
+
py: string;
|
859
|
+
color: string;
|
860
|
+
transition: string;
|
861
|
+
fontSize: string;
|
862
|
+
textDecoration: string;
|
863
|
+
'&.is-pressed': {
|
864
|
+
textDecoration: string;
|
865
|
+
outline: string;
|
866
|
+
color: string;
|
867
|
+
};
|
868
|
+
'&.is-focused': {
|
869
|
+
textDecoration: string;
|
870
|
+
outline: string;
|
871
|
+
};
|
872
|
+
};
|
856
873
|
};
|
857
874
|
export default buttons;
|
@@ -153,6 +153,11 @@ var link = {
|
|
153
153
|
outline: 'none'
|
154
154
|
}
|
155
155
|
};
|
156
|
+
var paginationMenu = _objectSpread(_objectSpread({}, link), {}, {
|
157
|
+
px: '0px',
|
158
|
+
py: '0px',
|
159
|
+
color: 'text.primary'
|
160
|
+
});
|
156
161
|
var withIcon = _objectSpread(_objectSpread({}, secondary), {}, {
|
157
162
|
display: 'inline-flex'
|
158
163
|
});
|
@@ -350,7 +355,8 @@ var buttons = {
|
|
350
355
|
primaryWithIcon: primaryWithIcon,
|
351
356
|
iconButtons: iconButtons,
|
352
357
|
modalCloseButton: modalCloseButton,
|
353
|
-
aiChat: aiChat
|
358
|
+
aiChat: aiChat,
|
359
|
+
paginationMenu: paginationMenu
|
354
360
|
};
|
355
361
|
var _default = buttons;
|
356
362
|
exports["default"] = _default;
|
@@ -45,6 +45,7 @@ var _Message = _interopRequireDefault(require("../../components/Messages/Message
|
|
45
45
|
var _Modal = _interopRequireDefault(require("../../components/Modal/Modal.styles"));
|
46
46
|
var _NavBar = _interopRequireDefault(require("../../components/NavBar/NavBar.styles"));
|
47
47
|
var _OverlayPanel = _interopRequireDefault(require("../../components/OverlayPanel/OverlayPanel.styles"));
|
48
|
+
var _Pagination = _interopRequireDefault(require("../../components/Pagination/Pagination.styles"));
|
48
49
|
var _PanelHeader = _interopRequireDefault(require("../../components/PanelHeader/PanelHeader.styles"));
|
49
50
|
var _PopoverMenu = _interopRequireDefault(require("../../components/PopoverMenu/PopoverMenu.styles"));
|
50
51
|
var _ProgressBar = _interopRequireDefault(require("../../components/ProgressBar/ProgressBar.styles"));
|
@@ -96,8 +97,9 @@ var _default = _objectSpread({
|
|
96
97
|
modal: _Modal["default"],
|
97
98
|
navBar: _NavBar["default"],
|
98
99
|
overlayPanel: _OverlayPanel["default"],
|
99
|
-
|
100
|
+
pagination: _Pagination["default"],
|
100
101
|
panelHeader: _PanelHeader["default"],
|
102
|
+
popoverMenu: _PopoverMenu["default"],
|
101
103
|
progressBar: _ProgressBar["default"],
|
102
104
|
rockerButton: _RockerButton["default"],
|
103
105
|
scrollBox: _ScrollBox["default"],
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
import { ButtonProps } from './button';
|
3
|
+
import { PopoverMenuProps } from './popoverMenu';
|
4
|
+
type PaginationState = {
|
5
|
+
currentPageIndex: number;
|
6
|
+
firstRenderedIndex: number;
|
7
|
+
isFirstIndex: boolean;
|
8
|
+
isLastIndex: boolean;
|
9
|
+
lastRenderedIndex: number;
|
10
|
+
offsetCount: number;
|
11
|
+
offsetOptions: number[];
|
12
|
+
popoverButtonString: string;
|
13
|
+
setOffsetCount: (keys?: object) => void;
|
14
|
+
totalCount: number;
|
15
|
+
};
|
16
|
+
export type PaginationContextState = {
|
17
|
+
firstRenderedIndex: number;
|
18
|
+
lastRenderedIndex: number;
|
19
|
+
offsetCount: number;
|
20
|
+
totalCount: number;
|
21
|
+
currentPageIndex: number;
|
22
|
+
};
|
23
|
+
export interface PaginationContextProps {
|
24
|
+
paginationState: PaginationContextState;
|
25
|
+
setPaginationState?: (paginationState: PaginationContextState) => void;
|
26
|
+
}
|
27
|
+
export interface PaginationProviderProps {
|
28
|
+
children: ReactNode;
|
29
|
+
}
|
30
|
+
export interface PaginationProps {
|
31
|
+
currentPageIndex?: number;
|
32
|
+
nextButtonProps?: ButtonProps;
|
33
|
+
offsetMenuProps?: object;
|
34
|
+
offsetCount?: number;
|
35
|
+
offsetOptions?: number[];
|
36
|
+
onOffsetCountChange?: (index: number) => void;
|
37
|
+
onPageIndexChange?: (index: number) => void;
|
38
|
+
previousButtonProps?: ButtonProps;
|
39
|
+
setCurrentPageIndex?: () => void;
|
40
|
+
totalCount: number;
|
41
|
+
}
|
42
|
+
export interface RangeSelectPopoverProps extends PopoverMenuProps {
|
43
|
+
buttonProps?: ButtonProps;
|
44
|
+
state: PaginationState;
|
45
|
+
}
|
46
|
+
export {};
|
@@ -276,6 +276,9 @@ var exampleText = _objectSpread(_objectSpread({}, base), {}, {
|
|
276
276
|
background: 'none',
|
277
277
|
'&.is-focused': _objectSpread({}, defaultFocus)
|
278
278
|
});
|
279
|
+
var paginationMenu = _objectSpread(_objectSpread({}, link), {}, {
|
280
|
+
fontWeight: 0
|
281
|
+
});
|
279
282
|
export default {
|
280
283
|
colorBlock: colorBlock,
|
281
284
|
colorBlockPrimary: colorBlockPrimary,
|
@@ -296,6 +299,7 @@ export default {
|
|
296
299
|
inlinePrimaryWithIcon: inlinePrimaryWithIcon,
|
297
300
|
inlineWithIcon: inlineWithIcon,
|
298
301
|
link: link,
|
302
|
+
paginationMenu: paginationMenu,
|
299
303
|
primary: primary,
|
300
304
|
primaryWithIcon: primaryWithIcon,
|
301
305
|
quiet: quiet,
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["setOffsetCount", "offsetOptions"];
|
4
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
5
|
+
import React, { forwardRef } from 'react';
|
6
|
+
import ChevronLeftIcon from '@pingux/mdi-react/ChevronLeftIcon';
|
7
|
+
import ChevronRightIcon from '@pingux/mdi-react/ChevronRightIcon';
|
8
|
+
import { useLocalOrForwardRef } from '../../hooks';
|
9
|
+
import usePagination from '../../hooks/usePagination';
|
10
|
+
import { Box, Button, Icon, IconButton, Item, Menu, OverlayProvider, PopoverMenu } from '../../index';
|
11
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
|
+
var RangeSelectPopover = /*#__PURE__*/forwardRef(function (props, ref) {
|
13
|
+
var state = props.state,
|
14
|
+
buttonProps = props.buttonProps;
|
15
|
+
var setOffsetCount = state.setOffsetCount,
|
16
|
+
offsetOptions = state.offsetOptions,
|
17
|
+
others = _objectWithoutProperties(state, _excluded);
|
18
|
+
var menuRef = useLocalOrForwardRef(ref);
|
19
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Box, {
|
20
|
+
sx: {
|
21
|
+
flexGrow: 1
|
22
|
+
}
|
23
|
+
}, ___EmotionJSX(PopoverMenu, {
|
24
|
+
ref: menuRef
|
25
|
+
}, ___EmotionJSX(Button, _extends({}, buttonProps, {
|
26
|
+
variant: "paginationMenu"
|
27
|
+
}), state.popoverButtonString), ___EmotionJSX(Menu, _extends({
|
28
|
+
onSelectionChange: setOffsetCount,
|
29
|
+
selectionMode: "single"
|
30
|
+
}, others), _mapInstanceProperty(offsetOptions).call(offsetOptions, function (option) {
|
31
|
+
return ___EmotionJSX(Item, {
|
32
|
+
key: option,
|
33
|
+
textValue: "".concat(option)
|
34
|
+
}, "Show", ' ', option, ' ', "Results");
|
35
|
+
})))));
|
36
|
+
});
|
37
|
+
var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
38
|
+
var _usePagination = usePagination(props),
|
39
|
+
state = _usePagination.state,
|
40
|
+
previousButtonProps = _usePagination.previousButtonProps,
|
41
|
+
nextButtonProps = _usePagination.nextButtonProps,
|
42
|
+
containerProps = _usePagination.containerProps,
|
43
|
+
offsetMenuProps = _usePagination.offsetMenuProps;
|
44
|
+
var paginationRef = useLocalOrForwardRef(ref);
|
45
|
+
return ___EmotionJSX(Box, _extends({
|
46
|
+
isRow: true,
|
47
|
+
variant: "pagination.container"
|
48
|
+
}, containerProps, {
|
49
|
+
ref: paginationRef
|
50
|
+
}), ___EmotionJSX(Box, {
|
51
|
+
variant: "pagination.wrapper",
|
52
|
+
isRow: true
|
53
|
+
}, ___EmotionJSX(RangeSelectPopover, _extends({}, offsetMenuProps, {
|
54
|
+
state: state
|
55
|
+
})), ___EmotionJSX(Box, {
|
56
|
+
variant: "pagination.iconWrapper",
|
57
|
+
isRow: true
|
58
|
+
}, ___EmotionJSX(IconButton, previousButtonProps, ___EmotionJSX(Icon, {
|
59
|
+
icon: ChevronLeftIcon
|
60
|
+
})), ___EmotionJSX(IconButton, nextButtonProps, ___EmotionJSX(Icon, {
|
61
|
+
icon: ChevronRightIcon
|
62
|
+
})))));
|
63
|
+
});
|
64
|
+
export default Pagination;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Meta } from '@storybook/addon-docs';
|
2
|
+
|
3
|
+
<Meta title="Components/Pagination/Pagination" />
|
4
|
+
|
5
|
+
# Pagination
|
6
|
+
|
7
|
+
The Pagination component allows users to navigate through large datasets by dividing them into smaller, more manageable pages. It provides controls for navigating between pages and selecting the number of items displayed per page.
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
- Customizable offset options to control the number of items displayed per page.
|
12
|
+
- Next/Previous navigation buttons for seamless page transitions.
|
13
|
+
- Works in both controlled and uncontrolled states.
|
14
|
+
- Integrates with `PaginationContext` for managing state.
|
15
|
+
|
16
|
+
### Required Components
|
17
|
+
|
18
|
+
This component requires the following components:
|
19
|
+
- `PaginationProvider`
|
20
|
+
- `ListView` (optional for displaying paginated data)
|
21
|
+
|
22
|
+
### Accessibility
|
23
|
+
|
24
|
+
This component adheres to the [WCAG 2.1 - 2.4.4 Link Purpose (In Context)](https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context.html) accessibility guidelines.
|
25
|
+
|
26
|
+
#### Keyboard Navigation
|
27
|
+
|
28
|
+
| Key | Functions |
|
29
|
+
|---------------|-----------------------------------|
|
30
|
+
| Tab | Moves focus between controls. |
|
31
|
+
| Enter | Activates the focused control. |
|
32
|
+
|
33
|
+
#### Screen Readers
|
34
|
+
|
35
|
+
This component uses the following attributes to assist screen readers:
|
36
|
+
- **`aria-label`**: Provides an accessible name for the pagination controls.
|
37
|
+
- **`aria-disabled`**: Indicates when navigation buttons are disabled.
|
38
|
+
- **`aria-live`**: Updates screen readers with changes in pagination state.
|
39
|
+
|
40
|
+
### Usage
|
41
|
+
|
42
|
+
```tsx
|
43
|
+
import { Pagination, PaginationProvider } from '@pingux/astro';
|
44
|
+
|
45
|
+
<PaginationProvider>
|
46
|
+
<Pagination totalCount={250} />
|
47
|
+
<ListView
|
48
|
+
items={animals.slice(paginationState.firstRenderedIndex, paginationState.lastRenderedIndex).map(item => ({
|
49
|
+
name: item.name,
|
50
|
+
key: item.name,
|
51
|
+
id: item.name,
|
52
|
+
}))}
|
53
|
+
>
|
54
|
+
{(item) => (
|
55
|
+
<Item key={item.name}>
|
56
|
+
<ListViewItem
|
57
|
+
data={{
|
58
|
+
text: item.name,
|
59
|
+
icon: FormSelectIcon,
|
60
|
+
}}
|
61
|
+
iconProps={{
|
62
|
+
color: 'text.secondary',
|
63
|
+
}}
|
64
|
+
/>
|
65
|
+
</Item>
|
66
|
+
)}
|
67
|
+
</ListView>
|
68
|
+
</PaginationProvider>
|