@canonical/react-components 0.37.9 → 0.38.0
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/components/ModularTable/ModularTable.d.ts +5 -1
- package/dist/components/ModularTable/ModularTable.js +8 -4
- package/dist/components/Pagination/Pagination.d.ts +5 -1
- package/dist/components/Pagination/Pagination.js +13 -3
- package/dist/components/Slider/Slider.js +3 -1
- package/dist/types/react-table-config.d.js +3 -1
- package/package.json +3 -3
|
@@ -19,6 +19,10 @@ export declare type Props<D extends Record<string, unknown>> = PropsWithSpread<{
|
|
|
19
19
|
* Optional extra row to display underneath the main table content.
|
|
20
20
|
*/
|
|
21
21
|
footer?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Optional argument to make the tables be sortable and use the `useSortBy` plugin.
|
|
24
|
+
*/
|
|
25
|
+
sortable?: Boolean;
|
|
22
26
|
/**
|
|
23
27
|
* This function is used to resolve any props needed for a particular column's header cell.
|
|
24
28
|
*/
|
|
@@ -33,5 +37,5 @@ export declare type Props<D extends Record<string, unknown>> = PropsWithSpread<{
|
|
|
33
37
|
getCellProps?: (cell: Cell<D>) => Partial<TableCellProps & HTMLProps<HTMLTableCellElement>>;
|
|
34
38
|
getRowId?: UseTableOptions<D>["getRowId"];
|
|
35
39
|
}, HTMLProps<HTMLTableElement>>;
|
|
36
|
-
declare function ModularTable({ data, columns, emptyMsg, footer, getHeaderProps, getRowProps, getCellProps, getRowId, ...props }: Props<Record<string, unknown>>): JSX.Element;
|
|
40
|
+
declare function ModularTable({ data, columns, emptyMsg, footer, sortable, getHeaderProps, getRowProps, getCellProps, getRowId, ...props }: Props<Record<string, unknown>>): JSX.Element;
|
|
37
41
|
export default ModularTable;
|
|
@@ -19,7 +19,7 @@ var _TableCell = _interopRequireDefault(require("../TableCell"));
|
|
|
19
19
|
|
|
20
20
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
21
21
|
|
|
22
|
-
var _excluded = ["data", "columns", "emptyMsg", "footer", "getHeaderProps", "getRowProps", "getCellProps", "getRowId"];
|
|
22
|
+
var _excluded = ["data", "columns", "emptyMsg", "footer", "sortable", "getHeaderProps", "getRowProps", "getCellProps", "getRowId"];
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
|
|
@@ -40,6 +40,7 @@ function ModularTable(_ref) {
|
|
|
40
40
|
columns = _ref.columns,
|
|
41
41
|
emptyMsg = _ref.emptyMsg,
|
|
42
42
|
footer = _ref.footer,
|
|
43
|
+
sortable = _ref.sortable,
|
|
43
44
|
getHeaderProps = _ref.getHeaderProps,
|
|
44
45
|
getRowProps = _ref.getRowProps,
|
|
45
46
|
getCellProps = _ref.getCellProps,
|
|
@@ -50,7 +51,7 @@ function ModularTable(_ref) {
|
|
|
50
51
|
columns: columns,
|
|
51
52
|
data: data,
|
|
52
53
|
getRowId: getRowId || undefined
|
|
53
|
-
}),
|
|
54
|
+
}, sortable ? _reactTable.useSortBy : undefined),
|
|
54
55
|
getTableProps = _useTable.getTableProps,
|
|
55
56
|
getTableBodyProps = _useTable.getTableBodyProps,
|
|
56
57
|
headerGroups = _useTable.headerGroups,
|
|
@@ -60,11 +61,14 @@ function ModularTable(_ref) {
|
|
|
60
61
|
var showEmpty = !!emptyMsg && (!rows || rows.length === 0);
|
|
61
62
|
return /*#__PURE__*/_react.default.createElement(_Table.default, _extends({}, getTableProps(), props), /*#__PURE__*/_react.default.createElement("thead", null, headerGroups.map(function (headerGroup) {
|
|
62
63
|
return /*#__PURE__*/_react.default.createElement(_TableRow.default, headerGroup.getHeaderGroupProps(), headerGroup.headers.map(function (column) {
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(_TableHeader.default,
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(_TableHeader.default, _extends({
|
|
65
|
+
sort: column.isSorted ? column.isSortedDesc ? "descending" : "ascending" : "none"
|
|
66
|
+
}, column.getHeaderProps([{
|
|
64
67
|
className: column.className
|
|
65
68
|
}, {
|
|
66
69
|
className: column.getCellIcon ? "p-table__cell--icon-placeholder" : ""
|
|
67
|
-
}, _objectSpread({}, getHeaderProps === null || getHeaderProps === void 0 ? void 0 : getHeaderProps(column))
|
|
70
|
+
}, _objectSpread({}, getHeaderProps === null || getHeaderProps === void 0 ? void 0 : getHeaderProps(column)), // Only call this if we want it to be sortable too.
|
|
71
|
+
sortable ? column.getSortByToggleProps() : {}])), column.render("Header"));
|
|
68
72
|
}));
|
|
69
73
|
})), /*#__PURE__*/_react.default.createElement("tbody", getTableBodyProps(), rows.map(function (row) {
|
|
70
74
|
// This function is responsible for lazily preparing a row for rendering.
|
|
@@ -25,6 +25,10 @@ export declare type Props = PropsWithSpread<{
|
|
|
25
25
|
* The number of pages at which to truncate the pagination items.
|
|
26
26
|
*/
|
|
27
27
|
truncateThreshold?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Whether or not the pagination is ceneterd on the page.
|
|
30
|
+
*/
|
|
31
|
+
centered?: boolean;
|
|
28
32
|
}, HTMLProps<HTMLElement>>;
|
|
29
|
-
declare const Pagination: ({ itemsPerPage, totalItems, paginate, currentPage, scrollToTop, truncateThreshold, ...navProps }: Props) => JSX.Element;
|
|
33
|
+
declare const Pagination: ({ itemsPerPage, totalItems, paginate, currentPage, scrollToTop, truncateThreshold, centered, ...navProps }: Props) => JSX.Element;
|
|
30
34
|
export default Pagination;
|
|
@@ -5,16 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
10
12
|
var _PaginationButton = _interopRequireDefault(require("./PaginationButton"));
|
|
11
13
|
|
|
12
14
|
var _PaginationItem = _interopRequireDefault(require("./PaginationItem"));
|
|
13
15
|
|
|
14
|
-
var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold"];
|
|
16
|
+
var _excluded = ["itemsPerPage", "totalItems", "paginate", "currentPage", "scrollToTop", "truncateThreshold", "centered"];
|
|
15
17
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
20
|
+
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); }
|
|
21
|
+
|
|
18
22
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
23
|
|
|
20
24
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -121,6 +125,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
121
125
|
scrollToTop = _ref.scrollToTop,
|
|
122
126
|
_ref$truncateThreshol = _ref.truncateThreshold,
|
|
123
127
|
truncateThreshold = _ref$truncateThreshol === void 0 ? 10 : _ref$truncateThreshol,
|
|
128
|
+
centered = _ref.centered,
|
|
124
129
|
navProps = _objectWithoutProperties(_ref, _excluded);
|
|
125
130
|
|
|
126
131
|
// return early if no pagination is required
|
|
@@ -139,8 +144,13 @@ var Pagination = function Pagination(_ref) {
|
|
|
139
144
|
scrollToTop && scrollTop();
|
|
140
145
|
};
|
|
141
146
|
|
|
142
|
-
return /*#__PURE__*/_react.default.createElement("nav",
|
|
143
|
-
className: "p-pagination"
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement("nav", _extends({
|
|
148
|
+
className: "p-pagination",
|
|
149
|
+
"aria-label": "Pagination"
|
|
150
|
+
}, navProps), /*#__PURE__*/_react.default.createElement("ol", {
|
|
151
|
+
className: (0, _classnames.default)("p-pagination__items", {
|
|
152
|
+
"u-align--center": centered
|
|
153
|
+
})
|
|
144
154
|
}, /*#__PURE__*/_react.default.createElement(_PaginationButton.default, {
|
|
145
155
|
key: "back",
|
|
146
156
|
direction: "back",
|
|
@@ -53,9 +53,11 @@ var Slider = function Slider(_ref) {
|
|
|
53
53
|
var style = {};
|
|
54
54
|
|
|
55
55
|
if ((_navigator = navigator) !== null && _navigator !== void 0 && (_navigator$userAgent = _navigator.userAgent) !== null && _navigator$userAgent !== void 0 && _navigator$userAgent.includes("AppleWebKit")) {
|
|
56
|
+
var _inputProps$value;
|
|
57
|
+
|
|
56
58
|
// Range inputs on Webkit browsers don't have a built-in "filled" portion,
|
|
57
59
|
// so instead it is handled here as a background.
|
|
58
|
-
var val = inputProps.value
|
|
60
|
+
var val = (_inputProps$value = inputProps.value) !== null && _inputProps$value !== void 0 ? _inputProps$value : inputProps.defaultValue;
|
|
59
61
|
var filledPercentage = "".concat((Number(val) - min) / (max - min) * 100, "%");
|
|
60
62
|
style = {
|
|
61
63
|
background: "linear-gradient(\n to right,\n ".concat(FILLED_COLOR, " 0%,\n ").concat(FILLED_COLOR, " ").concat(filledPercentage, ",\n ").concat(EMPTY_COLOR, " ").concat(filledPercentage, ",\n ").concat(EMPTY_COLOR, " 100%\n )")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"ts-jest": "27.1.5",
|
|
80
80
|
"tsc-alias": "1.7.0",
|
|
81
81
|
"typescript": "4.7.4",
|
|
82
|
-
"vanilla-framework": "3.
|
|
82
|
+
"vanilla-framework": "3.11.0",
|
|
83
83
|
"wait-on": "5.3.0",
|
|
84
84
|
"webpack": "5.74.0"
|
|
85
85
|
},
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^17.0.2 || ^18.0.0",
|
|
105
105
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
106
|
-
"vanilla-framework": "3.
|
|
106
|
+
"vanilla-framework": "3.11.0"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|