@dhis2-ui/pagination 9.10.3 → 9.11.1-beta.1
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/build/cjs/__fixtures__/index.js +8 -15
- package/build/cjs/__tests__/get-item-range.test.js +2 -6
- package/build/cjs/__tests__/page-controls.test.js +2 -7
- package/build/cjs/__tests__/page-select.test.js +3 -11
- package/build/cjs/__tests__/page-size-select.test.js +3 -11
- package/build/cjs/__tests__/page-summary.test.js +2 -8
- package/build/cjs/__tests__/pagination.test.js +8 -15
- package/build/cjs/get-default-page-summary-text.js +1 -9
- package/build/cjs/get-item-range.js +0 -6
- package/build/cjs/index.js +0 -1
- package/build/cjs/locales/index.js +3 -73
- package/build/cjs/page-controls.js +6 -17
- package/build/cjs/page-select.js +5 -17
- package/build/cjs/page-size-select.js +5 -15
- package/build/cjs/page-summary.js +3 -13
- package/build/cjs/pagination.js +2 -19
- package/build/cjs/pagination.prod.stories.js +133 -0
- package/build/es/__tests__/page-controls.test.js +1 -2
- package/build/es/__tests__/page-summary.test.js +1 -2
- package/build/es/__tests__/pagination.test.js +5 -4
- package/build/es/get-default-page-summary-text.js +0 -5
- package/build/es/get-item-range.js +0 -4
- package/build/es/page-controls.js +5 -9
- package/build/es/page-select.js +6 -9
- package/build/es/page-size-select.js +6 -8
- package/build/es/page-summary.js +2 -6
- package/build/es/pagination.js +1 -3
- package/build/es/{pagination.stories.js → pagination.prod.stories.js} +42 -24
- package/package.json +8 -8
- package/build/cjs/pagination.stories.js +0 -140
|
@@ -3,16 +3,23 @@ import React from 'react';
|
|
|
3
3
|
import * as pagers from './__fixtures__/index.js';
|
|
4
4
|
import { Pagination } from './pagination.js';
|
|
5
5
|
const subtitle = 'Allows navigation through data displayed over several pages';
|
|
6
|
-
const description =
|
|
6
|
+
const description = `
|
|
7
|
+
Pagination allows data to be split in pages. Paging large amounts of data avoids overwhelming users and should always be used wherever a lot of data is displayed. Pagination controls allow a user to browse through a set of data or navigate to a specific page depending on the type of pagination used.
|
|
7
8
|
|
|
9
|
+
**Do not rely on pagination for navigating datasets. A user should be able to search within, sort and filter datasets too, rather than needing to click through many pages looking for the right data item.**
|
|
10
|
+
|
|
11
|
+
\`\`\`js
|
|
12
|
+
import { Pagination } from '@dhis2/ui'
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
_**Note**: Dropdown menus may not display properly on this page. View these demos in the 'Canvas' tab._
|
|
16
|
+
`;
|
|
8
17
|
const logOnPageChange = page => {
|
|
9
|
-
console.log(
|
|
18
|
+
console.log(`Now navigate to page ${page}...`);
|
|
10
19
|
};
|
|
11
|
-
|
|
12
20
|
const logOnPageSizeChange = pageSize => {
|
|
13
|
-
console.log(
|
|
21
|
+
console.log(`Now change page size to ${pageSize}...`);
|
|
14
22
|
};
|
|
15
|
-
|
|
16
23
|
export default {
|
|
17
24
|
title: 'Pagination',
|
|
18
25
|
component: Pagination,
|
|
@@ -30,54 +37,63 @@ export default {
|
|
|
30
37
|
onPageSizeChange: logOnPageSizeChange
|
|
31
38
|
}
|
|
32
39
|
};
|
|
33
|
-
|
|
34
40
|
const Template = args => /*#__PURE__*/React.createElement(Pagination, args);
|
|
35
|
-
|
|
36
41
|
export const Default = Template.bind({});
|
|
37
|
-
Default.args = {
|
|
42
|
+
Default.args = {
|
|
43
|
+
...pagers.atTenthPage
|
|
38
44
|
};
|
|
39
45
|
export const Disabled = Template.bind({});
|
|
40
|
-
Disabled.args = {
|
|
46
|
+
Disabled.args = {
|
|
47
|
+
...pagers.atTenthPage,
|
|
41
48
|
disabled: true
|
|
42
49
|
};
|
|
43
50
|
export const PagerAtFirstPage = Template.bind({});
|
|
44
|
-
PagerAtFirstPage.args = {
|
|
51
|
+
PagerAtFirstPage.args = {
|
|
52
|
+
...pagers.atFirstPage
|
|
45
53
|
};
|
|
46
54
|
export const PagerAtLastPage = Template.bind({});
|
|
47
|
-
PagerAtLastPage.args = {
|
|
55
|
+
PagerAtLastPage.args = {
|
|
56
|
+
...pagers.atLastPage
|
|
48
57
|
};
|
|
49
58
|
export const NoTotal = Template.bind({});
|
|
50
|
-
NoTotal.args = {
|
|
59
|
+
NoTotal.args = {
|
|
60
|
+
...pagers.noTotal
|
|
51
61
|
};
|
|
52
62
|
export const NoTotalAtLastPage = Template.bind({});
|
|
53
|
-
NoTotalAtLastPage.args = {
|
|
63
|
+
NoTotalAtLastPage.args = {
|
|
64
|
+
...pagers.noTotalAtLastPage,
|
|
54
65
|
pageLength: 26
|
|
55
66
|
};
|
|
56
67
|
export const NoTotalAtLastPageWithoutPageLength = Template.bind({});
|
|
57
|
-
NoTotalAtLastPageWithoutPageLength.args = {
|
|
68
|
+
NoTotalAtLastPageWithoutPageLength.args = {
|
|
69
|
+
...pagers.noTotalAtLastPage
|
|
58
70
|
};
|
|
59
71
|
export const WithoutPageSizeSelect = Template.bind({});
|
|
60
|
-
WithoutPageSizeSelect.args = {
|
|
72
|
+
WithoutPageSizeSelect.args = {
|
|
73
|
+
...pagers.atTenthPage,
|
|
61
74
|
hidePageSizeSelect: true
|
|
62
75
|
};
|
|
63
76
|
export const WithoutGoToPageSelect = Template.bind({});
|
|
64
|
-
WithoutGoToPageSelect.args = {
|
|
77
|
+
WithoutGoToPageSelect.args = {
|
|
78
|
+
...pagers.atTenthPage,
|
|
65
79
|
hidePageSelect: true
|
|
66
80
|
};
|
|
67
81
|
export const WithoutPageSummary = Template.bind({});
|
|
68
|
-
WithoutPageSummary.args = {
|
|
82
|
+
WithoutPageSummary.args = {
|
|
83
|
+
...pagers.atTenthPage,
|
|
69
84
|
hidePageSummary: true
|
|
70
85
|
};
|
|
71
86
|
export const WithCustomPageSummary = Template.bind({});
|
|
72
|
-
WithCustomPageSummary.args = {
|
|
87
|
+
WithCustomPageSummary.args = {
|
|
88
|
+
...pagers.atTenthPage,
|
|
73
89
|
pageSummaryText: interpolationObject => i18n.t('You are at page {{page}} showing items {{firstItem}}-{{lastItem}}, but there are {{pageCount}} pages and {{total}} items', interpolationObject)
|
|
74
90
|
};
|
|
75
91
|
export const WithoutAnySelect = Template.bind({});
|
|
76
|
-
WithoutAnySelect.args = {
|
|
92
|
+
WithoutAnySelect.args = {
|
|
93
|
+
...pagers.atTenthPage,
|
|
77
94
|
...WithoutGoToPageSelect.args,
|
|
78
95
|
...WithoutPageSizeSelect.args
|
|
79
96
|
};
|
|
80
|
-
|
|
81
97
|
const InBox = _ref => {
|
|
82
98
|
let {
|
|
83
99
|
boxWidth,
|
|
@@ -89,17 +105,19 @@ const InBox = _ref => {
|
|
|
89
105
|
}
|
|
90
106
|
}, /*#__PURE__*/React.createElement(Pagination, args));
|
|
91
107
|
};
|
|
92
|
-
|
|
93
108
|
export const MediumWidth = InBox.bind({});
|
|
94
|
-
MediumWidth.args = {
|
|
109
|
+
MediumWidth.args = {
|
|
110
|
+
...pagers.atTenthPage,
|
|
95
111
|
boxWidth: 500
|
|
96
112
|
};
|
|
97
113
|
export const NarrowWidth = InBox.bind({});
|
|
98
|
-
NarrowWidth.args = {
|
|
114
|
+
NarrowWidth.args = {
|
|
115
|
+
...pagers.atTenthPage,
|
|
99
116
|
boxWidth: 100
|
|
100
117
|
};
|
|
101
118
|
export const RTL = args => /*#__PURE__*/React.createElement("div", {
|
|
102
119
|
dir: "rtl"
|
|
103
120
|
}, /*#__PURE__*/React.createElement(Pagination, args));
|
|
104
|
-
RTL.args = {
|
|
121
|
+
RTL.args = {
|
|
122
|
+
...pagers.atTenthPage
|
|
105
123
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/pagination",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.11.1-beta.1",
|
|
4
4
|
"description": "UI Pagination",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@dhis2/d2-i18n": "^1",
|
|
31
|
-
"react": "^16.
|
|
32
|
-
"react-dom": "^16.
|
|
31
|
+
"react": "^16.13",
|
|
32
|
+
"react-dom": "^16.13",
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
37
|
-
"@dhis2-ui/button": "9.
|
|
38
|
-
"@dhis2-ui/select": "9.
|
|
39
|
-
"@dhis2/ui-constants": "9.
|
|
40
|
-
"@dhis2/ui-icons": "9.
|
|
37
|
+
"@dhis2-ui/button": "9.11.1-beta.1",
|
|
38
|
+
"@dhis2-ui/select": "9.11.1-beta.1",
|
|
39
|
+
"@dhis2/ui-constants": "9.11.1-beta.1",
|
|
40
|
+
"@dhis2/ui-icons": "9.11.1-beta.1",
|
|
41
41
|
"classnames": "^2.3.1",
|
|
42
42
|
"prop-types": "^15.7.2"
|
|
43
43
|
},
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.WithoutPageSummary = exports.WithoutPageSizeSelect = exports.WithoutGoToPageSelect = exports.WithoutAnySelect = exports.WithCustomPageSummary = exports.RTL = exports.PagerAtLastPage = exports.PagerAtFirstPage = exports.NoTotalAtLastPageWithoutPageLength = exports.NoTotalAtLastPage = exports.NoTotal = exports.NarrowWidth = exports.MediumWidth = exports.Disabled = exports.Default = void 0;
|
|
7
|
-
|
|
8
|
-
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var pagers = _interopRequireWildcard(require("./__fixtures__/index.js"));
|
|
13
|
-
|
|
14
|
-
var _pagination = require("./pagination.js");
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
const subtitle = 'Allows navigation through data displayed over several pages';
|
|
23
|
-
const description = "\nPagination allows data to be split in pages. Paging large amounts of data avoids overwhelming users and should always be used wherever a lot of data is displayed. Pagination controls allow a user to browse through a set of data or navigate to a specific page depending on the type of pagination used.\n\n**Do not rely on pagination for navigating datasets. A user should be able to search within, sort and filter datasets too, rather than needing to click through many pages looking for the right data item.**\n\n```js\nimport { Pagination } from '@dhis2/ui'\n```\n\n_**Note**: Dropdown menus may not display properly on this page. View these demos in the 'Canvas' tab._\n";
|
|
24
|
-
|
|
25
|
-
const logOnPageChange = page => {
|
|
26
|
-
console.log("Now navigate to page ".concat(page, "..."));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const logOnPageSizeChange = pageSize => {
|
|
30
|
-
console.log("Now change page size to ".concat(pageSize, "..."));
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
var _default = {
|
|
34
|
-
title: 'Pagination',
|
|
35
|
-
component: _pagination.Pagination,
|
|
36
|
-
parameters: {
|
|
37
|
-
componentSubtitle: subtitle,
|
|
38
|
-
docs: {
|
|
39
|
-
description: {
|
|
40
|
-
component: description
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
// Default args for stories
|
|
45
|
-
args: {
|
|
46
|
-
onPageChange: logOnPageChange,
|
|
47
|
-
onPageSizeChange: logOnPageSizeChange
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.default = _default;
|
|
51
|
-
|
|
52
|
-
const Template = args => /*#__PURE__*/_react.default.createElement(_pagination.Pagination, args);
|
|
53
|
-
|
|
54
|
-
const Default = Template.bind({});
|
|
55
|
-
exports.Default = Default;
|
|
56
|
-
Default.args = { ...pagers.atTenthPage
|
|
57
|
-
};
|
|
58
|
-
const Disabled = Template.bind({});
|
|
59
|
-
exports.Disabled = Disabled;
|
|
60
|
-
Disabled.args = { ...pagers.atTenthPage,
|
|
61
|
-
disabled: true
|
|
62
|
-
};
|
|
63
|
-
const PagerAtFirstPage = Template.bind({});
|
|
64
|
-
exports.PagerAtFirstPage = PagerAtFirstPage;
|
|
65
|
-
PagerAtFirstPage.args = { ...pagers.atFirstPage
|
|
66
|
-
};
|
|
67
|
-
const PagerAtLastPage = Template.bind({});
|
|
68
|
-
exports.PagerAtLastPage = PagerAtLastPage;
|
|
69
|
-
PagerAtLastPage.args = { ...pagers.atLastPage
|
|
70
|
-
};
|
|
71
|
-
const NoTotal = Template.bind({});
|
|
72
|
-
exports.NoTotal = NoTotal;
|
|
73
|
-
NoTotal.args = { ...pagers.noTotal
|
|
74
|
-
};
|
|
75
|
-
const NoTotalAtLastPage = Template.bind({});
|
|
76
|
-
exports.NoTotalAtLastPage = NoTotalAtLastPage;
|
|
77
|
-
NoTotalAtLastPage.args = { ...pagers.noTotalAtLastPage,
|
|
78
|
-
pageLength: 26
|
|
79
|
-
};
|
|
80
|
-
const NoTotalAtLastPageWithoutPageLength = Template.bind({});
|
|
81
|
-
exports.NoTotalAtLastPageWithoutPageLength = NoTotalAtLastPageWithoutPageLength;
|
|
82
|
-
NoTotalAtLastPageWithoutPageLength.args = { ...pagers.noTotalAtLastPage
|
|
83
|
-
};
|
|
84
|
-
const WithoutPageSizeSelect = Template.bind({});
|
|
85
|
-
exports.WithoutPageSizeSelect = WithoutPageSizeSelect;
|
|
86
|
-
WithoutPageSizeSelect.args = { ...pagers.atTenthPage,
|
|
87
|
-
hidePageSizeSelect: true
|
|
88
|
-
};
|
|
89
|
-
const WithoutGoToPageSelect = Template.bind({});
|
|
90
|
-
exports.WithoutGoToPageSelect = WithoutGoToPageSelect;
|
|
91
|
-
WithoutGoToPageSelect.args = { ...pagers.atTenthPage,
|
|
92
|
-
hidePageSelect: true
|
|
93
|
-
};
|
|
94
|
-
const WithoutPageSummary = Template.bind({});
|
|
95
|
-
exports.WithoutPageSummary = WithoutPageSummary;
|
|
96
|
-
WithoutPageSummary.args = { ...pagers.atTenthPage,
|
|
97
|
-
hidePageSummary: true
|
|
98
|
-
};
|
|
99
|
-
const WithCustomPageSummary = Template.bind({});
|
|
100
|
-
exports.WithCustomPageSummary = WithCustomPageSummary;
|
|
101
|
-
WithCustomPageSummary.args = { ...pagers.atTenthPage,
|
|
102
|
-
pageSummaryText: interpolationObject => _d2I18n.default.t('You are at page {{page}} showing items {{firstItem}}-{{lastItem}}, but there are {{pageCount}} pages and {{total}} items', interpolationObject)
|
|
103
|
-
};
|
|
104
|
-
const WithoutAnySelect = Template.bind({});
|
|
105
|
-
exports.WithoutAnySelect = WithoutAnySelect;
|
|
106
|
-
WithoutAnySelect.args = { ...pagers.atTenthPage,
|
|
107
|
-
...WithoutGoToPageSelect.args,
|
|
108
|
-
...WithoutPageSizeSelect.args
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const InBox = _ref => {
|
|
112
|
-
let {
|
|
113
|
-
boxWidth,
|
|
114
|
-
...args
|
|
115
|
-
} = _ref;
|
|
116
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
117
|
-
style: {
|
|
118
|
-
width: boxWidth
|
|
119
|
-
}
|
|
120
|
-
}, /*#__PURE__*/_react.default.createElement(_pagination.Pagination, args));
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const MediumWidth = InBox.bind({});
|
|
124
|
-
exports.MediumWidth = MediumWidth;
|
|
125
|
-
MediumWidth.args = { ...pagers.atTenthPage,
|
|
126
|
-
boxWidth: 500
|
|
127
|
-
};
|
|
128
|
-
const NarrowWidth = InBox.bind({});
|
|
129
|
-
exports.NarrowWidth = NarrowWidth;
|
|
130
|
-
NarrowWidth.args = { ...pagers.atTenthPage,
|
|
131
|
-
boxWidth: 100
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
135
|
-
dir: "rtl"
|
|
136
|
-
}, /*#__PURE__*/_react.default.createElement(_pagination.Pagination, args));
|
|
137
|
-
|
|
138
|
-
exports.RTL = RTL;
|
|
139
|
-
RTL.args = { ...pagers.atTenthPage
|
|
140
|
-
};
|