@instructure/ui-pagination 11.6.0 → 11.6.1-snapshot-129
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 +42 -296
- package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +2 -2
- package/es/Pagination/{PaginationButton → v1/PaginationButton}/index.js +1 -1
- package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +1 -1
- package/es/Pagination/{index.js → v1/index.js} +1 -1
- package/es/Pagination/v2/PaginationArrowButton/index.js +109 -0
- package/es/Pagination/v2/PaginationArrowButton/props.js +30 -0
- package/es/Pagination/v2/PaginationButton/index.js +77 -0
- package/es/Pagination/v2/PaginationButton/props.js +29 -0
- package/es/Pagination/v2/PaginationPageInput/index.js +189 -0
- package/es/Pagination/v2/PaginationPageInput/props.js +26 -0
- package/es/Pagination/v2/PaginationPageInput/styles.js +56 -0
- package/es/Pagination/v2/index.js +481 -0
- package/es/Pagination/v2/props.js +26 -0
- package/es/Pagination/v2/styles.js +58 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/es/exports/b.js +24 -0
- package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +8 -8
- package/lib/Pagination/{PaginationButton → v1/PaginationButton}/index.js +2 -2
- package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +2 -2
- package/lib/Pagination/{index.js → v1/index.js} +6 -6
- package/lib/Pagination/v2/PaginationArrowButton/index.js +115 -0
- package/lib/Pagination/v2/PaginationArrowButton/props.js +35 -0
- package/lib/Pagination/v2/PaginationButton/index.js +83 -0
- package/lib/Pagination/v2/PaginationButton/props.js +34 -0
- package/lib/Pagination/v2/PaginationPageInput/index.js +194 -0
- package/lib/Pagination/v2/PaginationPageInput/props.js +31 -0
- package/lib/Pagination/v2/PaginationPageInput/styles.js +62 -0
- package/lib/Pagination/v2/index.js +496 -0
- package/lib/Pagination/v2/props.js +31 -0
- package/lib/Pagination/v2/styles.js +64 -0
- package/lib/{index.js → exports/a.js} +3 -3
- package/lib/exports/b.js +18 -0
- package/package.json +48 -25
- package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.tsx +2 -2
- package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.ts +1 -1
- package/src/Pagination/{PaginationButton → v1/PaginationButton}/index.tsx +1 -1
- package/src/Pagination/{PaginationButton → v1/PaginationButton}/props.ts +1 -1
- package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.tsx +1 -1
- package/src/Pagination/{index.tsx → v1/index.tsx} +1 -1
- package/src/Pagination/v2/PaginationArrowButton/index.tsx +120 -0
- package/src/Pagination/v2/PaginationArrowButton/props.ts +74 -0
- package/src/Pagination/v2/PaginationButton/index.tsx +82 -0
- package/src/Pagination/v2/PaginationButton/props.ts +77 -0
- package/src/Pagination/v2/PaginationPageInput/index.tsx +242 -0
- package/src/Pagination/v2/PaginationPageInput/props.ts +95 -0
- package/src/Pagination/v2/PaginationPageInput/styles.ts +62 -0
- package/src/Pagination/v2/README.md +417 -0
- package/src/Pagination/v2/index.tsx +665 -0
- package/src/Pagination/v2/props.ts +245 -0
- package/src/Pagination/v2/styles.ts +64 -0
- package/src/exports/a.ts +29 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/v1/PaginationArrowButton/index.d.ts.map +1 -0
- package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.d.ts +1 -1
- package/types/Pagination/v1/PaginationArrowButton/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationButton/index.d.ts.map +1 -0
- package/types/Pagination/{PaginationButton → v1/PaginationButton}/props.d.ts +1 -1
- package/types/Pagination/v1/PaginationButton/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/index.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/props.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/styles.d.ts.map +1 -0
- package/types/Pagination/v1/PaginationPageInput/theme.d.ts.map +1 -0
- package/types/Pagination/v1/index.d.ts.map +1 -0
- package/types/Pagination/v1/props.d.ts.map +1 -0
- package/types/Pagination/v1/styles.d.ts.map +1 -0
- package/types/Pagination/v1/theme.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationArrowButton/index.d.ts +27 -0
- package/types/Pagination/v2/PaginationArrowButton/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationArrowButton/props.d.ts +17 -0
- package/types/Pagination/v2/PaginationArrowButton/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationButton/index.d.ts +26 -0
- package/types/Pagination/v2/PaginationButton/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationButton/props.d.ts +30 -0
- package/types/Pagination/v2/PaginationButton/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/index.d.ts +50 -0
- package/types/Pagination/v2/PaginationPageInput/index.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/props.d.ts +45 -0
- package/types/Pagination/v2/PaginationPageInput/props.d.ts.map +1 -0
- package/types/Pagination/v2/PaginationPageInput/styles.d.ts +16 -0
- package/types/Pagination/v2/PaginationPageInput/styles.d.ts.map +1 -0
- package/types/Pagination/v2/index.d.ts +106 -0
- package/types/Pagination/v2/index.d.ts.map +1 -0
- package/types/Pagination/v2/props.d.ts +138 -0
- package/types/Pagination/v2/props.d.ts.map +1 -0
- package/types/Pagination/v2/styles.d.ts +16 -0
- package/types/Pagination/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +5 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
- package/src/index.ts +0 -29
- package/types/Pagination/PaginationArrowButton/index.d.ts.map +0 -1
- package/types/Pagination/PaginationArrowButton/props.d.ts.map +0 -1
- package/types/Pagination/PaginationButton/index.d.ts.map +0 -1
- package/types/Pagination/PaginationButton/props.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/index.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/props.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/styles.d.ts.map +0 -1
- package/types/Pagination/PaginationPageInput/theme.d.ts.map +0 -1
- package/types/Pagination/index.d.ts.map +0 -1
- package/types/Pagination/props.d.ts.map +0 -1
- package/types/Pagination/styles.d.ts.map +0 -1
- package/types/Pagination/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.d.ts.map +0 -1
- /package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
- /package/es/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
- /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
- /package/es/Pagination/{props.js → v1/props.js} +0 -0
- /package/es/Pagination/{styles.js → v1/styles.js} +0 -0
- /package/es/Pagination/{theme.js → v1/theme.js} +0 -0
- /package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
- /package/lib/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
- /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
- /package/lib/Pagination/{props.js → v1/props.js} +0 -0
- /package/lib/Pagination/{styles.js → v1/styles.js} +0 -0
- /package/lib/Pagination/{theme.js → v1/theme.js} +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.ts +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.ts +0 -0
- /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.ts +0 -0
- /package/src/Pagination/{README.md → v1/README.md} +0 -0
- /package/src/Pagination/{props.ts → v1/props.ts} +0 -0
- /package/src/Pagination/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Pagination/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationButton → v1/PaginationButton}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.d.ts +0 -0
- /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.d.ts +0 -0
- /package/types/Pagination/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Pagination/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Pagination/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Pagination/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["label", "direction", "buttonRef"];
|
|
3
|
+
/*
|
|
4
|
+
* The MIT License (MIT)
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { Component } from 'react';
|
|
28
|
+
import { IconButton } from '@instructure/ui-buttons/latest';
|
|
29
|
+
import { PresentationContent } from '@instructure/ui-a11y-content';
|
|
30
|
+
import { Tooltip } from '@instructure/ui-tooltip/latest';
|
|
31
|
+
import { ChevronLeftInstUIIcon, ChevronRightInstUIIcon, ChevronsLeftInstUIIcon, ChevronsRightInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
|
|
32
|
+
import { allowedProps } from "./props.js";
|
|
33
|
+
/**
|
|
34
|
+
---
|
|
35
|
+
parent: Pagination
|
|
36
|
+
id: Pagination.Navigation
|
|
37
|
+
---
|
|
38
|
+
**/
|
|
39
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
40
|
+
class PaginationArrowButton extends Component {
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
this.ref = null;
|
|
44
|
+
this.handleRef = el => {
|
|
45
|
+
this.ref = el;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
get margin() {
|
|
49
|
+
switch (this.props.direction) {
|
|
50
|
+
case 'first':
|
|
51
|
+
return '0 xx-small 0 0';
|
|
52
|
+
case 'last':
|
|
53
|
+
return '0 0 0 xx-small';
|
|
54
|
+
default:
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
get Icon() {
|
|
59
|
+
switch (this.props.direction) {
|
|
60
|
+
case 'first':
|
|
61
|
+
return ChevronsLeftInstUIIcon;
|
|
62
|
+
case 'prev':
|
|
63
|
+
return ChevronLeftInstUIIcon;
|
|
64
|
+
case 'next':
|
|
65
|
+
return ChevronRightInstUIIcon;
|
|
66
|
+
case 'last':
|
|
67
|
+
return ChevronsRightInstUIIcon;
|
|
68
|
+
default:
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
renderIcon() {
|
|
73
|
+
const icon = this.Icon;
|
|
74
|
+
if (!icon) return null;
|
|
75
|
+
return renderIconWithProps(icon, 'md', 'actionTertiaryBaseColor');
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const _this$props = this.props,
|
|
79
|
+
label = _this$props.label,
|
|
80
|
+
direction = _this$props.direction,
|
|
81
|
+
buttonRef = _this$props.buttonRef,
|
|
82
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
83
|
+
return _jsx(Tooltip, {
|
|
84
|
+
elementRef: this.handleRef,
|
|
85
|
+
on: ['hover', 'focus'],
|
|
86
|
+
renderTip: _jsx(PresentationContent, {
|
|
87
|
+
children: label
|
|
88
|
+
}),
|
|
89
|
+
children: _jsx(IconButton, {
|
|
90
|
+
...props,
|
|
91
|
+
size: "small",
|
|
92
|
+
withBackground: false,
|
|
93
|
+
withBorder: false,
|
|
94
|
+
screenReaderLabel: label,
|
|
95
|
+
rel: props.href || props.to ? direction : void 0,
|
|
96
|
+
elementRef: buttonRef,
|
|
97
|
+
margin: this.margin,
|
|
98
|
+
"data-cid": "PaginationArrowButton",
|
|
99
|
+
children: this.renderIcon()
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
PaginationArrowButton.displayName = "PaginationArrowButton";
|
|
105
|
+
PaginationArrowButton.componentId = 'Pagination.Navigation';
|
|
106
|
+
PaginationArrowButton.allowedProps = allowedProps;
|
|
107
|
+
PaginationArrowButton.defaultProps = {};
|
|
108
|
+
export default PaginationArrowButton;
|
|
109
|
+
export { PaginationArrowButton };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['direction', 'label', 'buttonRef'
|
|
26
|
+
|
|
27
|
+
// we don't want to pass onClick
|
|
28
|
+
// 'onClick'
|
|
29
|
+
];
|
|
30
|
+
export { allowedProps };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Component } from 'react';
|
|
26
|
+
import { BaseButton } from '@instructure/ui-buttons/latest';
|
|
27
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
28
|
+
import { allowedProps } from "./props.js";
|
|
29
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
30
|
+
/**
|
|
31
|
+
---
|
|
32
|
+
parent: Pagination
|
|
33
|
+
id: Pagination.Page
|
|
34
|
+
---
|
|
35
|
+
**/
|
|
36
|
+
|
|
37
|
+
class PaginationButton extends Component {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
super(...args);
|
|
40
|
+
this.ref = null;
|
|
41
|
+
this.handleRef = el => {
|
|
42
|
+
this.ref = el;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
const exclude = this.props.current ? ['onClick', 'href'] : [];
|
|
47
|
+
const props = omitProps(this.props, PaginationButton.allowedProps, exclude);
|
|
48
|
+
|
|
49
|
+
// wrapped in an unstyled <li> for better a11y
|
|
50
|
+
return _jsx("li", {
|
|
51
|
+
style: {
|
|
52
|
+
all: 'unset'
|
|
53
|
+
},
|
|
54
|
+
children: _jsx(BaseButton, {
|
|
55
|
+
color: "primary",
|
|
56
|
+
"data-cid": "PaginationButton",
|
|
57
|
+
withBackground: this.props.current,
|
|
58
|
+
withBorder: this.props.current,
|
|
59
|
+
...props,
|
|
60
|
+
"aria-current": this.props.current ? 'page' : void 0,
|
|
61
|
+
elementRef: this.handleRef,
|
|
62
|
+
...(this.props.screenReaderLabel ? {
|
|
63
|
+
'aria-label': this.props.screenReaderLabel
|
|
64
|
+
} : {}),
|
|
65
|
+
children: this.props.children
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
PaginationButton.displayName = "PaginationButton";
|
|
71
|
+
PaginationButton.componentId = 'Pagination.Page';
|
|
72
|
+
PaginationButton.allowedProps = allowedProps;
|
|
73
|
+
PaginationButton.defaultProps = {
|
|
74
|
+
current: false
|
|
75
|
+
};
|
|
76
|
+
export default PaginationButton;
|
|
77
|
+
export { PaginationButton };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['children', 'current', 'screenReaderLabel'
|
|
26
|
+
// we don't want to pass onClick
|
|
27
|
+
// 'onClick'
|
|
28
|
+
];
|
|
29
|
+
export { allowedProps };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
var _dec, _class, _PaginationPageInput;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { Component } from 'react';
|
|
27
|
+
import { withStyle } from '@instructure/emotion';
|
|
28
|
+
import { Text } from '@instructure/ui-text/latest';
|
|
29
|
+
import { NumberInput } from '@instructure/ui-number-input/latest';
|
|
30
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
31
|
+
import generateStyle from "./styles.js";
|
|
32
|
+
import { allowedProps } from "./props.js";
|
|
33
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
parent: Pagination
|
|
37
|
+
id: Pagination.PageInput
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
let PaginationPageInput = (_dec = withStyle(generateStyle, 'PaginationPageInput'), _dec(_class = (_PaginationPageInput = class PaginationPageInput extends Component {
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
this.ref = null;
|
|
44
|
+
this.handleRef = el => {
|
|
45
|
+
this.ref = el;
|
|
46
|
+
};
|
|
47
|
+
this.handleInputRef = el => {
|
|
48
|
+
if (typeof this.props.inputRef === 'function') {
|
|
49
|
+
this.props.inputRef(el);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.handleChange = (_event, value) => {
|
|
53
|
+
let newValue = value;
|
|
54
|
+
|
|
55
|
+
// if the last character was not a number, don't accept it
|
|
56
|
+
if (value.length > 0 && isNaN(value.slice(-1))) {
|
|
57
|
+
newValue = value.slice(0, -1);
|
|
58
|
+
}
|
|
59
|
+
this.setState({
|
|
60
|
+
number: newValue ? Number(newValue) : this.MIN,
|
|
61
|
+
value: newValue
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
this.handleDecrement = event => {
|
|
65
|
+
this.setNewPage(event, Math.floor(this.currentPage - 1));
|
|
66
|
+
};
|
|
67
|
+
this.handleIncrement = event => {
|
|
68
|
+
this.setNewPage(event, Math.floor(this.currentPage + 1));
|
|
69
|
+
};
|
|
70
|
+
this.handleBlur = event => {
|
|
71
|
+
if (Math.round(this.state.number) !== this.currentPage) {
|
|
72
|
+
this.setNewPage(event, Math.round(this.state.number));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this.state = this.initialState;
|
|
76
|
+
}
|
|
77
|
+
get currentPage() {
|
|
78
|
+
return this.props.currentPageIndex + 1;
|
|
79
|
+
}
|
|
80
|
+
get initialState() {
|
|
81
|
+
return {
|
|
82
|
+
number: this.currentPage,
|
|
83
|
+
value: `${this.currentPage}`
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
get MIN() {
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
get MAX() {
|
|
90
|
+
return this.props.numberOfPages;
|
|
91
|
+
}
|
|
92
|
+
componentDidMount() {
|
|
93
|
+
var _this$props$makeStyle, _this$props;
|
|
94
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
95
|
+
}
|
|
96
|
+
componentDidUpdate(prevProps) {
|
|
97
|
+
var _this$props$makeStyle2, _this$props2;
|
|
98
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
99
|
+
|
|
100
|
+
// when the current page changes from outside (e.g.: from arrow buttons),
|
|
101
|
+
// we update the initial state
|
|
102
|
+
if (this.props.currentPageIndex !== prevProps.currentPageIndex) {
|
|
103
|
+
this.resetInitialState();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
resetInitialState() {
|
|
107
|
+
this.setState(this.initialState);
|
|
108
|
+
}
|
|
109
|
+
handleKeyDown(event) {
|
|
110
|
+
const key = event.key;
|
|
111
|
+
if (key.toLowerCase() === 'enter') {
|
|
112
|
+
const _this$state = this.state,
|
|
113
|
+
value = _this$state.value,
|
|
114
|
+
number = _this$state.number;
|
|
115
|
+
|
|
116
|
+
// If it is invalid, we reset the input to the current page
|
|
117
|
+
if (value === '' || isNaN(value)) {
|
|
118
|
+
this.resetInitialState();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.setNewPage(event, number);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
getNumberWithinRange(n) {
|
|
125
|
+
if (n < this.MIN) return this.MIN;
|
|
126
|
+
if (n > this.MAX) return this.MAX;
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
setNewPage(event, n) {
|
|
130
|
+
const number = this.getNumberWithinRange(n);
|
|
131
|
+
this.setState({
|
|
132
|
+
number,
|
|
133
|
+
value: `${number}`
|
|
134
|
+
});
|
|
135
|
+
this.props.onChange(event, number - 1);
|
|
136
|
+
}
|
|
137
|
+
renderLabel() {
|
|
138
|
+
const _this$props3 = this.props,
|
|
139
|
+
label = _this$props3.label,
|
|
140
|
+
numberOfPages = _this$props3.numberOfPages,
|
|
141
|
+
styles = _this$props3.styles;
|
|
142
|
+
return typeof label === 'function' && label(numberOfPages) ? _jsx(Text, {
|
|
143
|
+
variant: "content",
|
|
144
|
+
children: _jsx("span", {
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.inputLabel,
|
|
146
|
+
children: label(numberOfPages)
|
|
147
|
+
})
|
|
148
|
+
}) : null;
|
|
149
|
+
}
|
|
150
|
+
renderScreenReaderLabel() {
|
|
151
|
+
const _this$props4 = this.props,
|
|
152
|
+
screenReaderLabel = _this$props4.screenReaderLabel,
|
|
153
|
+
numberOfPages = _this$props4.numberOfPages;
|
|
154
|
+
return _jsx(ScreenReaderContent, {
|
|
155
|
+
children: screenReaderLabel(this.currentPage, numberOfPages)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
const _this$props5 = this.props,
|
|
160
|
+
styles = _this$props5.styles,
|
|
161
|
+
disabled = _this$props5.disabled;
|
|
162
|
+
return _jsxs("span", {
|
|
163
|
+
css: styles === null || styles === void 0 ? void 0 : styles.paginationPageInput,
|
|
164
|
+
ref: this.handleRef,
|
|
165
|
+
"data-cid": "PaginationPageInput",
|
|
166
|
+
children: [_jsx("span", {
|
|
167
|
+
css: styles === null || styles === void 0 ? void 0 : styles.numberInput,
|
|
168
|
+
children: _jsx(NumberInput, {
|
|
169
|
+
renderLabel: this.renderScreenReaderLabel(),
|
|
170
|
+
onBlur: this.handleBlur,
|
|
171
|
+
onChange: this.handleChange,
|
|
172
|
+
onDecrement: this.handleDecrement,
|
|
173
|
+
onIncrement: this.handleIncrement,
|
|
174
|
+
onKeyDown: this.handleKeyDown.bind(this),
|
|
175
|
+
interaction: disabled ? 'disabled' : 'enabled',
|
|
176
|
+
showArrows: false,
|
|
177
|
+
value: this.state.value,
|
|
178
|
+
width: "100%",
|
|
179
|
+
textAlign: "center",
|
|
180
|
+
inputRef: this.handleInputRef
|
|
181
|
+
})
|
|
182
|
+
}), this.renderLabel()]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}, _PaginationPageInput.displayName = "PaginationPageInput", _PaginationPageInput.componentId = 'Pagination.PageInput', _PaginationPageInput.allowedProps = allowedProps, _PaginationPageInput.defaultProps = {
|
|
186
|
+
disabled: false
|
|
187
|
+
}, _PaginationPageInput)) || _class);
|
|
188
|
+
export default PaginationPageInput;
|
|
189
|
+
export { PaginationPageInput };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['numberOfPages', 'currentPageIndex', 'onChange', 'screenReaderLabel', 'label', 'disabled', 'inputRef'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} sharedTokens Shared token object that stores common values for the theme.
|
|
33
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
34
|
+
* @return {Object} The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = componentTheme => {
|
|
37
|
+
return {
|
|
38
|
+
paginationPageInput: {
|
|
39
|
+
label: 'paginationPageInput',
|
|
40
|
+
display: 'inline-flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
margin: `0 ${componentTheme.inputSpacing}`
|
|
43
|
+
},
|
|
44
|
+
numberInput: {
|
|
45
|
+
label: 'paginationPageInput__input',
|
|
46
|
+
width: componentTheme.inputWidth
|
|
47
|
+
},
|
|
48
|
+
inputLabel: {
|
|
49
|
+
label: 'paginationPageInput__inputLabel',
|
|
50
|
+
marginInlineStart: componentTheme.inputSpacing,
|
|
51
|
+
whiteSpace: 'nowrap',
|
|
52
|
+
color: componentTheme.labelColor
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export default generateStyle;
|