@veritone-ce/design-system 2.6.0-alpha.0 → 2.6.0-alpha.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/dist/cjs/Pagination/index.js +1 -1
- package/dist/cjs/bundled_modules/@babel/runtime/helpers/esm/extends.js +20 -0
- package/dist/cjs/bundled_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +18 -0
- package/dist/cjs/bundled_modules/@mui/material/usePagination/usePagination.js +121 -0
- package/dist/esm/Pagination/index.js +1 -1
- package/dist/esm/bundled_modules/@babel/runtime/helpers/esm/extends.js +16 -0
- package/dist/esm/bundled_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +14 -0
- package/dist/esm/bundled_modules/@mui/material/usePagination/usePagination.js +117 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var styles_module = require('./styles.module.scss.js');
|
|
|
9
9
|
var index = require('../Button/index.js');
|
|
10
10
|
var index$1 = require('../IconButton/index.js');
|
|
11
11
|
var internal = require('../Icon/internal.js');
|
|
12
|
-
var usePagination$1 = require('../
|
|
12
|
+
var usePagination$1 = require('../bundled_modules/@mui/material/usePagination/usePagination.js');
|
|
13
13
|
|
|
14
14
|
const usePagination = usePagination$1.default;
|
|
15
15
|
function Pagination(props) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _extends() {
|
|
6
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
7
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
8
|
+
var source = arguments[i];
|
|
9
|
+
for (var key in source) {
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
11
|
+
target[key] = source[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
return _extends.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.default = _extends;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
6
|
+
if (source == null) return {};
|
|
7
|
+
var target = {};
|
|
8
|
+
var sourceKeys = Object.keys(source);
|
|
9
|
+
var key, i;
|
|
10
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
11
|
+
key = sourceKeys[i];
|
|
12
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
13
|
+
target[key] = source[key];
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.default = _objectWithoutPropertiesLoose;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _extends = require('../../../@babel/runtime/helpers/esm/extends.js');
|
|
7
|
+
var objectWithoutPropertiesLoose = require('../../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js');
|
|
8
|
+
var utils = require('@mui/utils');
|
|
9
|
+
|
|
10
|
+
const _excluded = ["boundaryCount", "componentName", "count", "defaultPage", "disabled", "hideNextButton", "hidePrevButton", "onChange", "page", "showFirstButton", "showLastButton", "siblingCount"];
|
|
11
|
+
function usePagination(props = {}) {
|
|
12
|
+
// keep default values in sync with @default tags in Pagination.propTypes
|
|
13
|
+
const {
|
|
14
|
+
boundaryCount = 1,
|
|
15
|
+
componentName = 'usePagination',
|
|
16
|
+
count = 1,
|
|
17
|
+
defaultPage = 1,
|
|
18
|
+
disabled = false,
|
|
19
|
+
hideNextButton = false,
|
|
20
|
+
hidePrevButton = false,
|
|
21
|
+
onChange: handleChange,
|
|
22
|
+
page: pageProp,
|
|
23
|
+
showFirstButton = false,
|
|
24
|
+
showLastButton = false,
|
|
25
|
+
siblingCount = 1
|
|
26
|
+
} = props,
|
|
27
|
+
other = objectWithoutPropertiesLoose.default(props, _excluded);
|
|
28
|
+
const [page, setPageState] = utils.unstable_useControlled({
|
|
29
|
+
controlled: pageProp,
|
|
30
|
+
default: defaultPage,
|
|
31
|
+
name: componentName,
|
|
32
|
+
state: 'page'
|
|
33
|
+
});
|
|
34
|
+
const handleClick = (event, value) => {
|
|
35
|
+
if (!pageProp) {
|
|
36
|
+
setPageState(value);
|
|
37
|
+
}
|
|
38
|
+
if (handleChange) {
|
|
39
|
+
handleChange(event, value);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// https://dev.to/namirsab/comment/2050
|
|
44
|
+
const range = (start, end) => {
|
|
45
|
+
const length = end - start + 1;
|
|
46
|
+
return Array.from({
|
|
47
|
+
length
|
|
48
|
+
}, (_, i) => start + i);
|
|
49
|
+
};
|
|
50
|
+
const startPages = range(1, Math.min(boundaryCount, count));
|
|
51
|
+
const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
|
|
52
|
+
const siblingsStart = Math.max(Math.min(
|
|
53
|
+
// Natural start
|
|
54
|
+
page - siblingCount,
|
|
55
|
+
// Lower boundary when page is high
|
|
56
|
+
count - boundaryCount - siblingCount * 2 - 1),
|
|
57
|
+
// Greater than startPages
|
|
58
|
+
boundaryCount + 2);
|
|
59
|
+
const siblingsEnd = Math.min(Math.max(
|
|
60
|
+
// Natural end
|
|
61
|
+
page + siblingCount,
|
|
62
|
+
// Upper boundary when page is low
|
|
63
|
+
boundaryCount + siblingCount * 2 + 2),
|
|
64
|
+
// Less than endPages
|
|
65
|
+
endPages.length > 0 ? endPages[0] - 2 : count - 1);
|
|
66
|
+
|
|
67
|
+
// Basic list of items to render
|
|
68
|
+
// e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']
|
|
69
|
+
const itemList = [...(showFirstButton ? ['first'] : []), ...(hidePrevButton ? [] : ['previous']), ...startPages,
|
|
70
|
+
// Start ellipsis
|
|
71
|
+
// eslint-disable-next-line no-nested-ternary
|
|
72
|
+
...(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []),
|
|
73
|
+
// Sibling pages
|
|
74
|
+
...range(siblingsStart, siblingsEnd),
|
|
75
|
+
// End ellipsis
|
|
76
|
+
// eslint-disable-next-line no-nested-ternary
|
|
77
|
+
...(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), ...endPages, ...(hideNextButton ? [] : ['next']), ...(showLastButton ? ['last'] : [])];
|
|
78
|
+
|
|
79
|
+
// Map the button type to its page number
|
|
80
|
+
const buttonPage = type => {
|
|
81
|
+
switch (type) {
|
|
82
|
+
case 'first':
|
|
83
|
+
return 1;
|
|
84
|
+
case 'previous':
|
|
85
|
+
return page - 1;
|
|
86
|
+
case 'next':
|
|
87
|
+
return page + 1;
|
|
88
|
+
case 'last':
|
|
89
|
+
return count;
|
|
90
|
+
default:
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Convert the basic item list to PaginationItem props objects
|
|
96
|
+
const items = itemList.map(item => {
|
|
97
|
+
return typeof item === 'number' ? {
|
|
98
|
+
onClick: event => {
|
|
99
|
+
handleClick(event, item);
|
|
100
|
+
},
|
|
101
|
+
type: 'page',
|
|
102
|
+
page: item,
|
|
103
|
+
selected: item === page,
|
|
104
|
+
disabled,
|
|
105
|
+
'aria-current': item === page ? 'true' : undefined
|
|
106
|
+
} : {
|
|
107
|
+
onClick: event => {
|
|
108
|
+
handleClick(event, buttonPage(item));
|
|
109
|
+
},
|
|
110
|
+
type: item,
|
|
111
|
+
page: buttonPage(item),
|
|
112
|
+
selected: false,
|
|
113
|
+
disabled: disabled || item.indexOf('ellipsis') === -1 && (item === 'next' || item === 'last' ? page >= count : page <= 1)
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
return _extends.default({
|
|
117
|
+
items
|
|
118
|
+
}, other);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.default = usePagination;
|
|
@@ -5,7 +5,7 @@ import css from './styles.module.scss.js';
|
|
|
5
5
|
import Button from '../Button/index.js';
|
|
6
6
|
import IconButton from '../IconButton/index.js';
|
|
7
7
|
import { NavigateBeforeIcon, NavigateNextIcon } from '../Icon/internal.js';
|
|
8
|
-
import usePagination$1 from '../
|
|
8
|
+
import usePagination$1 from '../bundled_modules/@mui/material/usePagination/usePagination.js';
|
|
9
9
|
|
|
10
10
|
const usePagination = usePagination$1;
|
|
11
11
|
function Pagination(props) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for (var key in source) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
+
target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
return _extends.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { _extends as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2
|
+
if (source == null) return {};
|
|
3
|
+
var target = {};
|
|
4
|
+
var sourceKeys = Object.keys(source);
|
|
5
|
+
var key, i;
|
|
6
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
7
|
+
key = sourceKeys[i];
|
|
8
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
9
|
+
target[key] = source[key];
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { _objectWithoutPropertiesLoose as default };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from '../../../@babel/runtime/helpers/esm/extends.js';
|
|
3
|
+
import _objectWithoutPropertiesLoose from '../../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js';
|
|
4
|
+
import { unstable_useControlled } from '@mui/utils';
|
|
5
|
+
|
|
6
|
+
const _excluded = ["boundaryCount", "componentName", "count", "defaultPage", "disabled", "hideNextButton", "hidePrevButton", "onChange", "page", "showFirstButton", "showLastButton", "siblingCount"];
|
|
7
|
+
function usePagination(props = {}) {
|
|
8
|
+
// keep default values in sync with @default tags in Pagination.propTypes
|
|
9
|
+
const {
|
|
10
|
+
boundaryCount = 1,
|
|
11
|
+
componentName = 'usePagination',
|
|
12
|
+
count = 1,
|
|
13
|
+
defaultPage = 1,
|
|
14
|
+
disabled = false,
|
|
15
|
+
hideNextButton = false,
|
|
16
|
+
hidePrevButton = false,
|
|
17
|
+
onChange: handleChange,
|
|
18
|
+
page: pageProp,
|
|
19
|
+
showFirstButton = false,
|
|
20
|
+
showLastButton = false,
|
|
21
|
+
siblingCount = 1
|
|
22
|
+
} = props,
|
|
23
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
24
|
+
const [page, setPageState] = unstable_useControlled({
|
|
25
|
+
controlled: pageProp,
|
|
26
|
+
default: defaultPage,
|
|
27
|
+
name: componentName,
|
|
28
|
+
state: 'page'
|
|
29
|
+
});
|
|
30
|
+
const handleClick = (event, value) => {
|
|
31
|
+
if (!pageProp) {
|
|
32
|
+
setPageState(value);
|
|
33
|
+
}
|
|
34
|
+
if (handleChange) {
|
|
35
|
+
handleChange(event, value);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// https://dev.to/namirsab/comment/2050
|
|
40
|
+
const range = (start, end) => {
|
|
41
|
+
const length = end - start + 1;
|
|
42
|
+
return Array.from({
|
|
43
|
+
length
|
|
44
|
+
}, (_, i) => start + i);
|
|
45
|
+
};
|
|
46
|
+
const startPages = range(1, Math.min(boundaryCount, count));
|
|
47
|
+
const endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
|
|
48
|
+
const siblingsStart = Math.max(Math.min(
|
|
49
|
+
// Natural start
|
|
50
|
+
page - siblingCount,
|
|
51
|
+
// Lower boundary when page is high
|
|
52
|
+
count - boundaryCount - siblingCount * 2 - 1),
|
|
53
|
+
// Greater than startPages
|
|
54
|
+
boundaryCount + 2);
|
|
55
|
+
const siblingsEnd = Math.min(Math.max(
|
|
56
|
+
// Natural end
|
|
57
|
+
page + siblingCount,
|
|
58
|
+
// Upper boundary when page is low
|
|
59
|
+
boundaryCount + siblingCount * 2 + 2),
|
|
60
|
+
// Less than endPages
|
|
61
|
+
endPages.length > 0 ? endPages[0] - 2 : count - 1);
|
|
62
|
+
|
|
63
|
+
// Basic list of items to render
|
|
64
|
+
// e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']
|
|
65
|
+
const itemList = [...(showFirstButton ? ['first'] : []), ...(hidePrevButton ? [] : ['previous']), ...startPages,
|
|
66
|
+
// Start ellipsis
|
|
67
|
+
// eslint-disable-next-line no-nested-ternary
|
|
68
|
+
...(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []),
|
|
69
|
+
// Sibling pages
|
|
70
|
+
...range(siblingsStart, siblingsEnd),
|
|
71
|
+
// End ellipsis
|
|
72
|
+
// eslint-disable-next-line no-nested-ternary
|
|
73
|
+
...(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), ...endPages, ...(hideNextButton ? [] : ['next']), ...(showLastButton ? ['last'] : [])];
|
|
74
|
+
|
|
75
|
+
// Map the button type to its page number
|
|
76
|
+
const buttonPage = type => {
|
|
77
|
+
switch (type) {
|
|
78
|
+
case 'first':
|
|
79
|
+
return 1;
|
|
80
|
+
case 'previous':
|
|
81
|
+
return page - 1;
|
|
82
|
+
case 'next':
|
|
83
|
+
return page + 1;
|
|
84
|
+
case 'last':
|
|
85
|
+
return count;
|
|
86
|
+
default:
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Convert the basic item list to PaginationItem props objects
|
|
92
|
+
const items = itemList.map(item => {
|
|
93
|
+
return typeof item === 'number' ? {
|
|
94
|
+
onClick: event => {
|
|
95
|
+
handleClick(event, item);
|
|
96
|
+
},
|
|
97
|
+
type: 'page',
|
|
98
|
+
page: item,
|
|
99
|
+
selected: item === page,
|
|
100
|
+
disabled,
|
|
101
|
+
'aria-current': item === page ? 'true' : undefined
|
|
102
|
+
} : {
|
|
103
|
+
onClick: event => {
|
|
104
|
+
handleClick(event, buttonPage(item));
|
|
105
|
+
},
|
|
106
|
+
type: item,
|
|
107
|
+
page: buttonPage(item),
|
|
108
|
+
selected: false,
|
|
109
|
+
disabled: disabled || item.indexOf('ellipsis') === -1 && (item === 'next' || item === 'last' ? page >= count : page <= 1)
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
return _extends({
|
|
113
|
+
items
|
|
114
|
+
}, other);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { usePagination as default };
|