@canonical/react-components 0.47.0 → 0.47.2
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/__mocks__/nanoid.js +3 -3
- package/dist/components/Accordion/Accordion.js +28 -41
- package/dist/components/Accordion/AccordionSection/AccordionSection.js +18 -18
- package/dist/components/Accordion/AccordionSection/index.js +1 -1
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/ActionButton/ActionButton.js +34 -66
- package/dist/components/ActionButton/index.js +1 -1
- package/dist/components/ArticlePagination/ArticlePagination.js +10 -12
- package/dist/components/ArticlePagination/index.js +1 -1
- package/dist/components/Badge/Badge.js +24 -29
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Button/Button.js +21 -26
- package/dist/components/Button/index.js +4 -5
- package/dist/components/Card/Card.js +12 -14
- package/dist/components/Card/index.js +1 -1
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +15 -19
- package/dist/components/CheckboxInput/CheckableInput/index.js +1 -1
- package/dist/components/CheckboxInput/CheckboxInput.js +7 -10
- package/dist/components/CheckboxInput/index.js +1 -1
- package/dist/components/Chip/Chip.js +23 -33
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/Code/Code.js +14 -17
- package/dist/components/Code/index.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippet.js +9 -14
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +24 -29
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +11 -11
- package/dist/components/CodeSnippet/index.js +2 -2
- package/dist/components/Col/Col.js +24 -26
- package/dist/components/Col/index.js +4 -5
- package/dist/components/ConfirmationButton/ConfirmationButton.js +18 -21
- package/dist/components/ConfirmationButton/index.js +1 -1
- package/dist/components/ConfirmationModal/ConfirmationModal.js +11 -15
- package/dist/components/ConfirmationModal/index.js +1 -1
- package/dist/components/ContextualMenu/ContextualMenu.js +89 -107
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +4 -4
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +97 -107
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +1 -1
- package/dist/components/ContextualMenu/index.js +1 -1
- package/dist/components/EmptyState/EmptyState.js +9 -11
- package/dist/components/EmptyState/index.js +1 -1
- package/dist/components/Field/Field.js +66 -65
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Form/Form.js +9 -11
- package/dist/components/Form/index.js +1 -1
- package/dist/components/Icon/Icon.js +9 -12
- package/dist/components/Icon/index.js +4 -5
- package/dist/components/Input/Input.js +38 -45
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Label/Label.js +9 -11
- package/dist/components/Label/index.js +1 -1
- package/dist/components/Link/Link.js +12 -18
- package/dist/components/Link/index.js +1 -1
- package/dist/components/List/List.js +50 -54
- package/dist/components/List/index.js +1 -1
- package/dist/components/Loader/Loader.js +2 -3
- package/dist/components/Loader/index.js +1 -1
- package/dist/components/MainTable/MainTable.js +87 -104
- package/dist/components/MainTable/index.js +1 -1
- package/dist/components/Modal/Modal.js +45 -40
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/ModularTable/ModularTable.js +63 -77
- package/dist/components/ModularTable/index.js +1 -1
- package/dist/components/Navigation/Navigation.js +63 -97
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +32 -35
- package/dist/components/Navigation/NavigationLink/index.js +1 -1
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +26 -45
- package/dist/components/Navigation/NavigationMenu/index.js +1 -1
- package/dist/components/Navigation/index.js +1 -1
- package/dist/components/Notification/Notification.js +49 -59
- package/dist/components/Notification/index.js +4 -5
- package/dist/components/NotificationProvider/NotificationProvider.js +47 -68
- package/dist/components/NotificationProvider/index.js +7 -7
- package/dist/components/NotificationProvider/messageBuilder.js +9 -9
- package/dist/components/NotificationProvider/types.d.ts +1 -0
- package/dist/components/Pagination/Pagination.js +55 -74
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +11 -12
- package/dist/components/Pagination/PaginationButton/index.js +1 -1
- package/dist/components/Pagination/PaginationItem/PaginationItem.js +7 -7
- package/dist/components/Pagination/PaginationItem/index.js +1 -1
- package/dist/components/Pagination/index.js +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.js +25 -40
- package/dist/components/PasswordToggle/index.js +1 -1
- package/dist/components/RadioInput/RadioInput.js +6 -8
- package/dist/components/RadioInput/index.js +1 -1
- package/dist/components/Row/Row.js +7 -9
- package/dist/components/Row/index.js +1 -1
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +38 -51
- package/dist/components/SearchAndFilter/FilterPanelSection/index.js +1 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +75 -135
- package/dist/components/SearchAndFilter/index.js +1 -1
- package/dist/components/SearchAndFilter/utils.js +4 -8
- package/dist/components/SearchBox/SearchBox.js +25 -33
- package/dist/components/SearchBox/index.js +1 -1
- package/dist/components/Select/Select.js +38 -44
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Slider/Slider.js +27 -35
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/Spinner/Spinner.js +10 -15
- package/dist/components/Spinner/index.js +1 -1
- package/dist/components/StatusLabel/StatusLabel.js +11 -13
- package/dist/components/StatusLabel/index.js +4 -5
- package/dist/components/Strip/Strip.js +27 -34
- package/dist/components/Strip/index.js +1 -1
- package/dist/components/SummaryButton/SummaryButton.js +9 -8
- package/dist/components/SummaryButton/index.js +1 -1
- package/dist/components/Switch/Switch.js +7 -10
- package/dist/components/Switch/index.js +1 -1
- package/dist/components/Table/Table.js +9 -13
- package/dist/components/Table/index.js +1 -1
- package/dist/components/TableCell/TableCell.js +11 -17
- package/dist/components/TableCell/index.js +1 -1
- package/dist/components/TableHeader/TableHeader.js +7 -9
- package/dist/components/TableHeader/index.js +1 -1
- package/dist/components/TablePagination/TablePagination.d.ts +37 -0
- package/dist/components/TablePagination/TablePagination.js +125 -0
- package/dist/components/TablePagination/TablePagination.scss +40 -0
- package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +16 -0
- package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.js +66 -0
- package/dist/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
- package/dist/components/TablePagination/TablePaginationControls/index.js +13 -0
- package/dist/components/TablePagination/index.d.ts +2 -0
- package/dist/components/TablePagination/index.js +13 -0
- package/dist/components/TableRow/TableRow.js +6 -8
- package/dist/components/TableRow/index.js +1 -1
- package/dist/components/Tabs/Tabs.js +17 -17
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Textarea/Textarea.js +51 -45
- package/dist/components/Textarea/index.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/components/Tooltip/Tooltip.js +76 -79
- package/dist/components/Tooltip/index.js +4 -5
- package/dist/enums.js +2 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +16 -10
- package/dist/hooks/useId.js +1 -3
- package/dist/hooks/useListener.d.ts +2 -1
- package/dist/hooks/useListener.js +25 -24
- package/dist/hooks/useOnClickOutside.d.ts +12 -0
- package/dist/hooks/useOnClickOutside.js +45 -0
- package/dist/hooks/useOnEscapePressed.d.ts +3 -1
- package/dist/hooks/useOnEscapePressed.js +13 -6
- package/dist/hooks/usePagination.js +17 -29
- package/dist/hooks/usePrevious.js +4 -4
- package/dist/hooks/useThrottle.js +16 -25
- package/dist/hooks/useWindowFitment.js +30 -28
- package/dist/index.d.ts +3 -1
- package/dist/index.js +86 -74
- package/dist/utils.js +6 -13
- package/package.json +56 -49
- package/dist/hooks/useClickOutside.d.ts +0 -6
- package/dist/hooks/useClickOutside.js +0 -32
|
@@ -6,19 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _excluded = ["children", "className", "expanding", "responsive"];
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
responsive = _ref$responsive === void 0 ? false : _ref$responsive,
|
|
21
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
const Table = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
expanding = false,
|
|
16
|
+
responsive = false,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
22
19
|
return /*#__PURE__*/_react.default.createElement("table", _extends({
|
|
23
20
|
role: "grid",
|
|
24
21
|
className: (0, _classnames.default)(className, {
|
|
@@ -27,5 +24,4 @@ var Table = function Table(_ref) {
|
|
|
27
24
|
})
|
|
28
25
|
}, props), children);
|
|
29
26
|
};
|
|
30
|
-
var _default = Table;
|
|
31
|
-
exports.default = _default;
|
|
27
|
+
var _default = exports.default = Table;
|
|
@@ -6,23 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _excluded = ["children", "className", "hasOverflow", "expanding", "hidden", "role"];
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
hidden = _ref$hidden === void 0 ? false : _ref$hidden,
|
|
23
|
-
_ref$role = _ref.role,
|
|
24
|
-
role = _ref$role === void 0 ? "gridcell" : _ref$role,
|
|
25
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
const TableCell = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
hasOverflow = false,
|
|
16
|
+
expanding = false,
|
|
17
|
+
hidden = false,
|
|
18
|
+
role = "gridcell",
|
|
19
|
+
...props
|
|
20
|
+
} = _ref;
|
|
26
21
|
return /*#__PURE__*/_react.default.createElement("td", _extends({
|
|
27
22
|
role: role,
|
|
28
23
|
"aria-hidden": hidden,
|
|
@@ -32,5 +27,4 @@ var TableCell = function TableCell(_ref) {
|
|
|
32
27
|
})
|
|
33
28
|
}, props), children);
|
|
34
29
|
};
|
|
35
|
-
var _default = TableCell;
|
|
36
|
-
exports.default = _default;
|
|
30
|
+
var _default = exports.default = TableCell;
|
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _excluded = ["children", "sort"];
|
|
9
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
9
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const TableHeader = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
children,
|
|
13
|
+
sort,
|
|
14
|
+
...props
|
|
15
|
+
} = _ref;
|
|
17
16
|
return /*#__PURE__*/_react.default.createElement("th", _extends({
|
|
18
17
|
role: "columnheader",
|
|
19
18
|
"aria-sort": sort
|
|
20
19
|
}, props), children);
|
|
21
20
|
};
|
|
22
|
-
var _default = TableHeader;
|
|
23
|
-
exports.default = _default;
|
|
21
|
+
var _default = exports.default = TableHeader;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import "./TablePagination.scss";
|
|
3
|
+
export type Props = PropsWithChildren<{
|
|
4
|
+
/**
|
|
5
|
+
* list of data elements to be paginated. This component is un-opinionated about
|
|
6
|
+
* the structure of the data but it should be identical to the data structure
|
|
7
|
+
* reuiqred by the child table component
|
|
8
|
+
*/
|
|
9
|
+
data: unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* prop name of the child table component that receives paginated data.
|
|
12
|
+
* default value is set to @constant rows, which is the data prop for the @func MainTable component
|
|
13
|
+
*/
|
|
14
|
+
dataForwardProp?: string;
|
|
15
|
+
/**
|
|
16
|
+
* the name of the item associated to each row within the table.
|
|
17
|
+
*/
|
|
18
|
+
itemName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* custom styling for the pagination container
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* custom description to be displayed by the pagination
|
|
25
|
+
*/
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* custom per page limits express as an array of numbers.
|
|
29
|
+
*/
|
|
30
|
+
pageLimits?: number[];
|
|
31
|
+
/**
|
|
32
|
+
* place the pagination component above or below the table?
|
|
33
|
+
*/
|
|
34
|
+
position?: "above" | "below";
|
|
35
|
+
}> & HTMLAttributes<HTMLDivElement>;
|
|
36
|
+
declare const TablePagination: ({ data, className, itemName, description, position, dataForwardProp, pageLimits, children, ...divProps }: Props) => React.JSX.Element;
|
|
37
|
+
export default TablePagination;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _hooks = require("../../hooks");
|
|
10
|
+
var _Select = _interopRequireDefault(require("../Select"));
|
|
11
|
+
var _TablePaginationControls = _interopRequireDefault(require("./TablePaginationControls"));
|
|
12
|
+
require("./TablePagination.scss");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
/**
|
|
18
|
+
* Determine if we are working with a small screen.
|
|
19
|
+
* 'small screen' in this case is relative to the width of the description div
|
|
20
|
+
*/
|
|
21
|
+
const figureSmallScreen = descriptionRef => {
|
|
22
|
+
const descriptionElement = descriptionRef.current;
|
|
23
|
+
if (!descriptionElement) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return descriptionElement.getBoundingClientRect().width < 230;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Iterate direct react child components and override the value of the prop specified by @param dataForwardProp
|
|
31
|
+
* for those child components.
|
|
32
|
+
* @param children - react node children to iterate
|
|
33
|
+
* @param dataForwardProp - the name of the prop from the children components to override
|
|
34
|
+
* @param data - actual data to be passed to the prop specified by @param dataForwardProp
|
|
35
|
+
*/
|
|
36
|
+
const renderChildren = (children, dataForwardProp, data) => {
|
|
37
|
+
return _react.Children.map(children, child => {
|
|
38
|
+
return /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
39
|
+
[dataForwardProp]: data
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const DEFAULT_PAGE_LIMITS = [50, 100, 200];
|
|
44
|
+
const generatePagingOptions = pageLimits => {
|
|
45
|
+
return pageLimits.map(limit => ({
|
|
46
|
+
value: limit,
|
|
47
|
+
label: "".concat(limit, "/page")
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
const TablePagination = _ref => {
|
|
51
|
+
let {
|
|
52
|
+
data,
|
|
53
|
+
className,
|
|
54
|
+
itemName = "item",
|
|
55
|
+
description,
|
|
56
|
+
position = "above",
|
|
57
|
+
dataForwardProp = "rows",
|
|
58
|
+
pageLimits = DEFAULT_PAGE_LIMITS,
|
|
59
|
+
children,
|
|
60
|
+
...divProps
|
|
61
|
+
} = _ref;
|
|
62
|
+
const descriptionRef = (0, _react.useRef)(null);
|
|
63
|
+
const [isSmallScreen, setSmallScreen] = (0, _react.useState)(false);
|
|
64
|
+
const [pageSize, setPageSize] = (0, _react.useState)(() => {
|
|
65
|
+
return generatePagingOptions(pageLimits)[0].value;
|
|
66
|
+
});
|
|
67
|
+
const {
|
|
68
|
+
paginate,
|
|
69
|
+
currentPage,
|
|
70
|
+
pageData,
|
|
71
|
+
totalItems
|
|
72
|
+
} = (0, _hooks.usePagination)(data, {
|
|
73
|
+
itemsPerPage: pageSize,
|
|
74
|
+
autoResetPage: true
|
|
75
|
+
});
|
|
76
|
+
(0, _react.useEffect)(() => {
|
|
77
|
+
const handleResize = () => {
|
|
78
|
+
setSmallScreen(figureSmallScreen(descriptionRef));
|
|
79
|
+
};
|
|
80
|
+
window.addEventListener("resize", handleResize);
|
|
81
|
+
return () => {
|
|
82
|
+
window.removeEventListener("resize", handleResize);
|
|
83
|
+
};
|
|
84
|
+
}, [isSmallScreen]);
|
|
85
|
+
const handlePageSizeChange = e => {
|
|
86
|
+
paginate(1);
|
|
87
|
+
setPageSize(parseInt(e.target.value));
|
|
88
|
+
};
|
|
89
|
+
const getDescription = () => {
|
|
90
|
+
if (description) {
|
|
91
|
+
return description;
|
|
92
|
+
}
|
|
93
|
+
const visibleCount = pageData.length;
|
|
94
|
+
if (isSmallScreen) {
|
|
95
|
+
return "".concat(visibleCount, " out of ").concat(totalItems);
|
|
96
|
+
}
|
|
97
|
+
if (visibleCount === totalItems && visibleCount > 1) {
|
|
98
|
+
return "Showing all ".concat(totalItems, " ").concat(itemName, "s");
|
|
99
|
+
}
|
|
100
|
+
return "Showing ".concat(visibleCount, " out of ").concat(totalItems, " ").concat(itemName).concat(totalItems !== 1 ? "s" : "");
|
|
101
|
+
};
|
|
102
|
+
const totalPages = Math.ceil(data.length / pageSize);
|
|
103
|
+
const clonedChildren = renderChildren(children, dataForwardProp, pageData);
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, position === "below" && clonedChildren, /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
105
|
+
className: (0, _classnames.default)("pagination", className)
|
|
106
|
+
}, divProps, {
|
|
107
|
+
role: "navigation"
|
|
108
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
className: "description",
|
|
110
|
+
ref: descriptionRef
|
|
111
|
+
}, getDescription()), /*#__PURE__*/_react.default.createElement(_TablePaginationControls.default, {
|
|
112
|
+
onPageChange: paginate,
|
|
113
|
+
currentPage: currentPage,
|
|
114
|
+
totalPages: totalPages
|
|
115
|
+
}), /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
116
|
+
className: "items-per-page",
|
|
117
|
+
label: "Items per page",
|
|
118
|
+
labelClassName: "u-off-screen",
|
|
119
|
+
id: "itemsPerPage",
|
|
120
|
+
options: generatePagingOptions(pageLimits),
|
|
121
|
+
onChange: handlePageSizeChange,
|
|
122
|
+
value: pageSize
|
|
123
|
+
})), position === "above" && clonedChildren);
|
|
124
|
+
};
|
|
125
|
+
var _default = exports.default = TablePagination;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import "~vanilla-framework/scss/settings";
|
|
2
|
+
|
|
3
|
+
.pagination {
|
|
4
|
+
align-items: baseline;
|
|
5
|
+
display: flex;
|
|
6
|
+
margin-top: 1.2rem;
|
|
7
|
+
|
|
8
|
+
.description {
|
|
9
|
+
flex-grow: 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.back {
|
|
13
|
+
margin: 0 $spv--large;
|
|
14
|
+
|
|
15
|
+
.p-icon--chevron-down {
|
|
16
|
+
rotate: 90deg;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.next {
|
|
21
|
+
margin: 0 $spv--large;
|
|
22
|
+
|
|
23
|
+
.p-icon--chevron-down {
|
|
24
|
+
rotate: 270deg;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.pagination-input {
|
|
29
|
+
margin-right: $spv--small;
|
|
30
|
+
min-width: 0;
|
|
31
|
+
width: 3rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.pagination-select {
|
|
35
|
+
margin-bottom: 0;
|
|
36
|
+
margin-left: $spv--x-large;
|
|
37
|
+
min-width: 0;
|
|
38
|
+
width: 7rem;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Props = {
|
|
2
|
+
/**
|
|
3
|
+
* Callback function to handle a change in page number
|
|
4
|
+
*/
|
|
5
|
+
onPageChange: (pageNumber: number) => void;
|
|
6
|
+
/**
|
|
7
|
+
* The current page of the data
|
|
8
|
+
*/
|
|
9
|
+
currentPage: number;
|
|
10
|
+
/**
|
|
11
|
+
* The total number of pages that exists within the data
|
|
12
|
+
*/
|
|
13
|
+
totalPages: number;
|
|
14
|
+
};
|
|
15
|
+
declare const TablePaginationControls: ({ onPageChange, currentPage, totalPages, }: Props) => JSX.Element;
|
|
16
|
+
export default TablePaginationControls;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _Button = _interopRequireDefault(require("../../Button"));
|
|
9
|
+
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
10
|
+
var _Input = _interopRequireDefault(require("../../Input"));
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const TablePaginationControls = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
onPageChange,
|
|
16
|
+
currentPage,
|
|
17
|
+
totalPages
|
|
18
|
+
} = _ref;
|
|
19
|
+
const handleDecrementPage = currentPage => {
|
|
20
|
+
if (currentPage > 1) {
|
|
21
|
+
onPageChange(currentPage - 1);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleIncrementPage = (currentPage, totalPages) => {
|
|
25
|
+
if (currentPage < totalPages) {
|
|
26
|
+
onPageChange(currentPage + 1);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handleInputPageChange = e => {
|
|
30
|
+
const newPage = Math.min(totalPages, Math.max(1, parseInt(e.target.value)));
|
|
31
|
+
onPageChange(newPage);
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
34
|
+
"aria-label": "Previous page",
|
|
35
|
+
className: "back",
|
|
36
|
+
appearance: "base",
|
|
37
|
+
hasIcon: true,
|
|
38
|
+
disabled: currentPage === 1,
|
|
39
|
+
onClick: () => handleDecrementPage(currentPage)
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
41
|
+
name: "chevron-down"
|
|
42
|
+
})), /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
43
|
+
id: "paginationPageInput",
|
|
44
|
+
label: "Page number",
|
|
45
|
+
labelClassName: "u-off-screen",
|
|
46
|
+
className: "u-no-margin--bottom pagination-input",
|
|
47
|
+
onChange: handleInputPageChange,
|
|
48
|
+
value: currentPage,
|
|
49
|
+
type: "number"
|
|
50
|
+
}), " ", "of\xA0", totalPages, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
51
|
+
"aria-label": "Next page",
|
|
52
|
+
className: "next",
|
|
53
|
+
appearance: "base",
|
|
54
|
+
hasIcon: true,
|
|
55
|
+
disabled: currentPage === totalPages,
|
|
56
|
+
onClick: () => handleIncrementPage(currentPage, totalPages)
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
58
|
+
name: "chevron-down"
|
|
59
|
+
})));
|
|
60
|
+
};
|
|
61
|
+
TablePaginationControls.propTypes = {
|
|
62
|
+
onPageChange: _propTypes.default.func.isRequired,
|
|
63
|
+
currentPage: _propTypes.default.number.isRequired,
|
|
64
|
+
totalPages: _propTypes.default.number.isRequired
|
|
65
|
+
};
|
|
66
|
+
var _default = exports.default = TablePaginationControls;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TablePaginationControls.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _TablePaginationControls = _interopRequireDefault(require("./TablePaginationControls"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TablePagination.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _TablePagination = _interopRequireDefault(require("./TablePagination"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _excluded = ["children"];
|
|
9
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
9
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const TableRow = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
children,
|
|
13
|
+
...trProps
|
|
14
|
+
} = _ref;
|
|
16
15
|
return /*#__PURE__*/_react.default.createElement("tr", _extends({
|
|
17
16
|
role: "row"
|
|
18
17
|
}, trProps), children);
|
|
19
18
|
};
|
|
20
|
-
var _default = TableRow;
|
|
21
|
-
exports.default = _default;
|
|
19
|
+
var _default = exports.default = TableRow;
|
|
@@ -6,27 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _excluded = ["active", "className", "component", "label", "listItemClassName"];
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const Tabs = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
className,
|
|
14
|
+
links,
|
|
15
|
+
listClassName
|
|
16
|
+
} = _ref;
|
|
18
17
|
return /*#__PURE__*/_react.default.createElement("nav", {
|
|
19
18
|
className: (0, _classnames.default)("p-tabs", className)
|
|
20
19
|
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
21
20
|
className: (0, _classnames.default)("p-tabs__list", listClassName)
|
|
22
|
-
}, links.map(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
}, links.map((link, i) => {
|
|
22
|
+
const {
|
|
23
|
+
active,
|
|
24
|
+
className,
|
|
25
|
+
component,
|
|
26
|
+
label,
|
|
27
|
+
listItemClassName,
|
|
28
|
+
...rest
|
|
29
|
+
} = link;
|
|
30
|
+
const Component = component || "a";
|
|
30
31
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
31
32
|
className: (0, _classnames.default)("p-tabs__item", listItemClassName),
|
|
32
33
|
key: i
|
|
@@ -37,5 +38,4 @@ var Tabs = function Tabs(_ref) {
|
|
|
37
38
|
}, rest), label));
|
|
38
39
|
})));
|
|
39
40
|
};
|
|
40
|
-
var _default = Tabs;
|
|
41
|
-
exports.default = _default;
|
|
41
|
+
var _default = exports.default = Tabs;
|