@canonical/react-components 0.35.0 → 0.37.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/components/Accordion/Accordion.js +1 -1
- package/dist/components/ActionButton/ActionButton.js +1 -1
- package/dist/components/ArticlePagination/ArticlePagination.js +1 -1
- package/dist/components/Button/Button.d.ts +1 -0
- package/dist/components/Button/Button.js +2 -1
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/CheckableInput/CheckableInput.js +1 -1
- package/dist/components/CheckboxInput/CheckboxInput.js +1 -1
- package/dist/components/Chip/Chip.js +1 -1
- package/dist/components/Code/Code.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippet.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +1 -1
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +1 -1
- package/dist/components/Col/Col.js +1 -1
- package/dist/components/ContextualMenu/ContextualMenu.js +1 -2
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +1 -1
- package/dist/components/Form/Form.js +1 -1
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Label/Label.js +1 -1
- package/dist/components/Link/Link.js +1 -1
- package/dist/components/List/List.js +28 -17
- package/dist/components/MainTable/MainTable.js +98 -79
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/ModularTable/ModularTable.js +1 -1
- package/dist/components/Navigation/Navigation.d.ts +58 -0
- package/dist/components/Navigation/Navigation.js +276 -0
- package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +74 -0
- package/dist/components/Navigation/NavigationLink/index.d.ts +1 -0
- package/dist/components/Navigation/NavigationLink/index.js +15 -0
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +105 -0
- package/dist/components/Navigation/NavigationMenu/index.d.ts +1 -0
- package/dist/components/Navigation/NavigationMenu/index.js +15 -0
- package/dist/components/Navigation/index.d.ts +3 -0
- package/dist/components/Navigation/index.js +15 -0
- package/dist/components/Navigation/types.d.ts +64 -0
- package/dist/components/Navigation/types.js +5 -0
- package/dist/components/Notification/Notification.js +1 -1
- package/dist/components/PasswordToggle/PasswordToggle.js +1 -1
- package/dist/components/RadioInput/RadioInput.js +1 -1
- package/dist/components/Row/Row.js +1 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +12 -16
- package/dist/components/SearchBox/SearchBox.d.ts +6 -5
- package/dist/components/SearchBox/SearchBox.js +22 -8
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Spinner/Spinner.js +1 -1
- package/dist/components/StatusLabel/StatusLabel.d.ts +31 -0
- package/dist/components/StatusLabel/StatusLabel.js +51 -0
- package/dist/components/StatusLabel/index.d.ts +2 -0
- package/dist/components/StatusLabel/index.js +25 -0
- package/dist/components/Strip/Strip.js +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Table/Table.js +1 -1
- package/dist/components/TableCell/TableCell.js +1 -1
- package/dist/components/TableHeader/TableHeader.js +1 -1
- package/dist/components/TableRow/TableRow.js +1 -1
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Textarea/Textarea.js +1 -1
- package/dist/enums.d.ts +13 -0
- package/dist/enums.js +17 -0
- package/dist/hooks/index.d.ts +5 -2
- package/dist/hooks/index.js +26 -2
- package/dist/hooks/useClickOutside.d.ts +7 -0
- package/dist/hooks/useClickOutside.js +41 -0
- package/dist/hooks/useOnEscapePressed.d.ts +4 -0
- package/dist/hooks/useOnEscapePressed.js +27 -0
- package/dist/hooks/usePagination.d.ts +19 -0
- package/dist/hooks/usePagination.js +74 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +56 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +24 -2
- package/package.json +42 -40
package/dist/hooks/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "useClickOutside", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _useClickOutside.useClickOutside;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "useId", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -15,6 +21,18 @@ Object.defineProperty(exports, "useListener", {
|
|
|
15
21
|
return _useListener.useListener;
|
|
16
22
|
}
|
|
17
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "useOnEscapePressed", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _useOnEscapePressed.useOnEscapePressed;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "usePagination", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _usePagination.usePagination;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
18
36
|
Object.defineProperty(exports, "usePrevious", {
|
|
19
37
|
enumerable: true,
|
|
20
38
|
get: function get() {
|
|
@@ -34,12 +52,18 @@ Object.defineProperty(exports, "useWindowFitment", {
|
|
|
34
52
|
}
|
|
35
53
|
});
|
|
36
54
|
|
|
37
|
-
var
|
|
55
|
+
var _useClickOutside = require("./useClickOutside");
|
|
56
|
+
|
|
57
|
+
var _useId = require("./useId");
|
|
38
58
|
|
|
39
59
|
var _useListener = require("./useListener");
|
|
40
60
|
|
|
61
|
+
var _useOnEscapePressed = require("./useOnEscapePressed");
|
|
62
|
+
|
|
41
63
|
var _usePrevious = require("./usePrevious");
|
|
42
64
|
|
|
43
65
|
var _useThrottle = require("./useThrottle");
|
|
44
66
|
|
|
45
|
-
var
|
|
67
|
+
var _usePagination = require("./usePagination");
|
|
68
|
+
|
|
69
|
+
var _useWindowFitment = require("./useWindowFitment");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Handle clicks outside an element.
|
|
4
|
+
* @returns An id and ref to pass to the element to handle clicks
|
|
5
|
+
* outside of.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useClickOutside: <E extends HTMLElement>(onClickOutside: () => void) => [MutableRefObject<E>, string];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useClickOutside = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _useId = require("./useId");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Handle clicks outside an element.
|
|
14
|
+
* @returns An id and ref to pass to the element to handle clicks
|
|
15
|
+
* outside of.
|
|
16
|
+
*/
|
|
17
|
+
var useClickOutside = function useClickOutside(onClickOutside) {
|
|
18
|
+
var wrapperRef = (0, _react.useRef)(null);
|
|
19
|
+
var id = (0, _useId.useId)();
|
|
20
|
+
var handleClickOutside = (0, _react.useCallback)(function (evt) {
|
|
21
|
+
var _evt$target, _wrapperRef$current;
|
|
22
|
+
|
|
23
|
+
var target = evt.target; // The target might be something like an SVG node which doesn't provide
|
|
24
|
+
// the class name as a string.
|
|
25
|
+
|
|
26
|
+
var isValidTarget = typeof (evt === null || evt === void 0 ? void 0 : (_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.className) === "string";
|
|
27
|
+
|
|
28
|
+
if (!isValidTarget || wrapperRef.current && !((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(target)) && target.id !== id) {
|
|
29
|
+
onClickOutside();
|
|
30
|
+
}
|
|
31
|
+
}, [id, onClickOutside]);
|
|
32
|
+
(0, _react.useEffect)(function () {
|
|
33
|
+
document.addEventListener("click", handleClickOutside, false);
|
|
34
|
+
return function () {
|
|
35
|
+
return document.removeEventListener("click", handleClickOutside, false);
|
|
36
|
+
};
|
|
37
|
+
}, [handleClickOutside]);
|
|
38
|
+
return [wrapperRef, id];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.useClickOutside = useClickOutside;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useOnEscapePressed = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handle the escape key pressed.
|
|
12
|
+
*/
|
|
13
|
+
var useOnEscapePressed = function useOnEscapePressed(onEscape) {
|
|
14
|
+
var keyDown = (0, _react.useCallback)(function (evt) {
|
|
15
|
+
if (evt.code === "Escape") {
|
|
16
|
+
onEscape();
|
|
17
|
+
}
|
|
18
|
+
}, [onEscape]);
|
|
19
|
+
(0, _react.useEffect)(function () {
|
|
20
|
+
document.addEventListener("keydown", keyDown);
|
|
21
|
+
return function () {
|
|
22
|
+
document.removeEventListener("keydown", keyDown);
|
|
23
|
+
};
|
|
24
|
+
}, [keyDown]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useOnEscapePressed = useOnEscapePressed;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook that handles pagination.
|
|
3
|
+
* @param data - The data array to paginate.
|
|
4
|
+
* @param {Object} options
|
|
5
|
+
* @param {number} [options.itemsPerPage] - Number of items per page. Returns all items if no value has been provided.
|
|
6
|
+
* @param {number} [options.initialPage=1] - Initial page number. Defaults to 1.
|
|
7
|
+
* @param {boolean} [options.autoResetPage=false] - Whether to reset the page number to 1 when the data changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function usePagination<D, I = number | null>(data: Array<D>, options?: {
|
|
10
|
+
itemsPerPage: I;
|
|
11
|
+
initialPage?: number;
|
|
12
|
+
autoResetPage?: boolean;
|
|
13
|
+
}): {
|
|
14
|
+
pageData: Array<D>;
|
|
15
|
+
currentPage: number;
|
|
16
|
+
paginate: (pageNumber: number) => void;
|
|
17
|
+
itemsPerPage: I;
|
|
18
|
+
totalItems: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePagination = usePagination;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
+
|
|
18
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
+
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A hook that handles pagination.
|
|
24
|
+
* @param data - The data array to paginate.
|
|
25
|
+
* @param {Object} options
|
|
26
|
+
* @param {number} [options.itemsPerPage] - Number of items per page. Returns all items if no value has been provided.
|
|
27
|
+
* @param {number} [options.initialPage=1] - Initial page number. Defaults to 1.
|
|
28
|
+
* @param {boolean} [options.autoResetPage=false] - Whether to reset the page number to 1 when the data changes.
|
|
29
|
+
*/
|
|
30
|
+
function usePagination(data, options) {
|
|
31
|
+
var _data$length;
|
|
32
|
+
|
|
33
|
+
var defaultOptions = {
|
|
34
|
+
initialPage: 1,
|
|
35
|
+
autoResetPage: false
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var _Object$assign = Object.assign(defaultOptions, options),
|
|
39
|
+
itemsPerPage = _Object$assign.itemsPerPage,
|
|
40
|
+
initialPage = _Object$assign.initialPage,
|
|
41
|
+
autoResetPage = _Object$assign.autoResetPage;
|
|
42
|
+
|
|
43
|
+
var totalItems = (_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : 0;
|
|
44
|
+
var initialPageIndex = initialPage > 0 ? initialPage - 1 : 0;
|
|
45
|
+
|
|
46
|
+
var _useState = (0, _react.useState)(initialPageIndex),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
pageIndex = _useState2[0],
|
|
49
|
+
setPageIndex = _useState2[1];
|
|
50
|
+
|
|
51
|
+
var startIndex = typeof itemsPerPage === "number" ? pageIndex * itemsPerPage : 0;
|
|
52
|
+
|
|
53
|
+
var paginate = function paginate(pageNumber) {
|
|
54
|
+
return setPageIndex(pageNumber - 1);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
(0, _react.useEffect)(function () {
|
|
58
|
+
if (typeof itemsPerPage === "number" && startIndex >= totalItems) {
|
|
59
|
+
!autoResetPage && Math.floor(totalItems / itemsPerPage) > 0 ? // go to the last available page if the current page is out of bounds
|
|
60
|
+
setPageIndex(Math.floor(totalItems / itemsPerPage) - 1) : // go to the initial page if autoResetPage is true
|
|
61
|
+
setPageIndex(0);
|
|
62
|
+
}
|
|
63
|
+
}, [pageIndex, startIndex, setPageIndex, totalItems, itemsPerPage, autoResetPage]);
|
|
64
|
+
var pageData = (0, _react.useMemo)(function () {
|
|
65
|
+
return typeof itemsPerPage === "number" ? data === null || data === void 0 ? void 0 : data.slice(startIndex, startIndex + itemsPerPage) : data;
|
|
66
|
+
}, [startIndex, data, itemsPerPage]);
|
|
67
|
+
return {
|
|
68
|
+
pageData: pageData,
|
|
69
|
+
currentPage: pageIndex + 1,
|
|
70
|
+
paginate: paginate,
|
|
71
|
+
itemsPerPage: itemsPerPage,
|
|
72
|
+
totalItems: totalItems
|
|
73
|
+
};
|
|
74
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { default as List } from "./components/List";
|
|
|
19
19
|
export { default as Loader } from "./components/Loader";
|
|
20
20
|
export { default as MainTable } from "./components/MainTable";
|
|
21
21
|
export { default as ModularTable } from "./components/ModularTable";
|
|
22
|
+
export { default as Navigation } from "./components/Navigation";
|
|
22
23
|
export { default as Modal } from "./components/Modal";
|
|
23
24
|
export { default as Notification, NotificationSeverity, } from "./components/Notification";
|
|
24
25
|
export { default as Pagination } from "./components/Pagination";
|
|
@@ -31,6 +32,7 @@ export { default as Select } from "./components/Select";
|
|
|
31
32
|
export { default as Slider } from "./components/Slider";
|
|
32
33
|
export { default as Switch } from "./components/Switch";
|
|
33
34
|
export { default as Spinner } from "./components/Spinner";
|
|
35
|
+
export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
|
|
34
36
|
export { default as Strip } from "./components/Strip";
|
|
35
37
|
export { default as SummaryButton } from "./components/SummaryButton";
|
|
36
38
|
export { default as Table } from "./components/Table";
|
|
@@ -63,6 +65,7 @@ export type { ListProps } from "./components/List";
|
|
|
63
65
|
export type { MainTableProps } from "./components/MainTable";
|
|
64
66
|
export type { ModularTableProps } from "./components/ModularTable";
|
|
65
67
|
export type { ModalProps } from "./components/Modal";
|
|
68
|
+
export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, NavLinkAnchor, NavLinkBase, NavLinkButton, } from "./components/Navigation";
|
|
66
69
|
export type { NotificationProps } from "./components/Notification";
|
|
67
70
|
export type { PaginationProps } from "./components/Pagination";
|
|
68
71
|
export type { RadioInputProps } from "./components/RadioInput";
|
|
@@ -72,6 +75,7 @@ export type { SearchBoxProps } from "./components/SearchBox";
|
|
|
72
75
|
export type { SelectProps } from "./components/Select";
|
|
73
76
|
export type { SliderProps } from "./components/Slider";
|
|
74
77
|
export type { SpinnerProps } from "./components/Spinner";
|
|
78
|
+
export type { StatusLabelProps } from "./components/StatusLabel";
|
|
75
79
|
export type { StripProps } from "./components/Strip";
|
|
76
80
|
export type { SummaryButtonProps } from "./components/SummaryButton";
|
|
77
81
|
export type { TableProps } from "./components/Table";
|
|
@@ -81,6 +85,8 @@ export type { TableRowProps } from "./components/TableRow";
|
|
|
81
85
|
export type { TabsProps } from "./components/Tabs";
|
|
82
86
|
export type { TextareaProps } from "./components/Textarea";
|
|
83
87
|
export type { TooltipProps } from "./components/Tooltip";
|
|
84
|
-
export {
|
|
88
|
+
export { useClickOutside, useId, useListener, useOnEscapePressed, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
|
|
85
89
|
export type { WindowFitment } from "./hooks";
|
|
90
|
+
export { isNavigationAnchor, isNavigationButton } from "./utils";
|
|
86
91
|
export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
|
|
92
|
+
export { Theme } from "./enums";
|
package/dist/index.js
CHANGED
|
@@ -155,6 +155,12 @@ Object.defineProperty(exports, "ModularTable", {
|
|
|
155
155
|
return _ModularTable.default;
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
+
Object.defineProperty(exports, "Navigation", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function get() {
|
|
161
|
+
return _Navigation.default;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
158
164
|
Object.defineProperty(exports, "Notification", {
|
|
159
165
|
enumerable: true,
|
|
160
166
|
get: function get() {
|
|
@@ -221,6 +227,18 @@ Object.defineProperty(exports, "Spinner", {
|
|
|
221
227
|
return _Spinner.default;
|
|
222
228
|
}
|
|
223
229
|
});
|
|
230
|
+
Object.defineProperty(exports, "StatusLabel", {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function get() {
|
|
233
|
+
return _StatusLabel.default;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "StatusLabelAppearance", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function get() {
|
|
239
|
+
return _StatusLabel.StatusLabelAppearance;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
224
242
|
Object.defineProperty(exports, "Strip", {
|
|
225
243
|
enumerable: true,
|
|
226
244
|
get: function get() {
|
|
@@ -275,12 +293,36 @@ Object.defineProperty(exports, "Textarea", {
|
|
|
275
293
|
return _Textarea.default;
|
|
276
294
|
}
|
|
277
295
|
});
|
|
296
|
+
Object.defineProperty(exports, "Theme", {
|
|
297
|
+
enumerable: true,
|
|
298
|
+
get: function get() {
|
|
299
|
+
return _enums.Theme;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
278
302
|
Object.defineProperty(exports, "Tooltip", {
|
|
279
303
|
enumerable: true,
|
|
280
304
|
get: function get() {
|
|
281
305
|
return _Tooltip.default;
|
|
282
306
|
}
|
|
283
307
|
});
|
|
308
|
+
Object.defineProperty(exports, "isNavigationAnchor", {
|
|
309
|
+
enumerable: true,
|
|
310
|
+
get: function get() {
|
|
311
|
+
return _utils.isNavigationAnchor;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
Object.defineProperty(exports, "isNavigationButton", {
|
|
315
|
+
enumerable: true,
|
|
316
|
+
get: function get() {
|
|
317
|
+
return _utils.isNavigationButton;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
Object.defineProperty(exports, "useClickOutside", {
|
|
321
|
+
enumerable: true,
|
|
322
|
+
get: function get() {
|
|
323
|
+
return _hooks.useClickOutside;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
284
326
|
Object.defineProperty(exports, "useId", {
|
|
285
327
|
enumerable: true,
|
|
286
328
|
get: function get() {
|
|
@@ -293,6 +335,12 @@ Object.defineProperty(exports, "useListener", {
|
|
|
293
335
|
return _hooks.useListener;
|
|
294
336
|
}
|
|
295
337
|
});
|
|
338
|
+
Object.defineProperty(exports, "useOnEscapePressed", {
|
|
339
|
+
enumerable: true,
|
|
340
|
+
get: function get() {
|
|
341
|
+
return _hooks.useOnEscapePressed;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
296
344
|
Object.defineProperty(exports, "usePrevious", {
|
|
297
345
|
enumerable: true,
|
|
298
346
|
get: function get() {
|
|
@@ -354,6 +402,8 @@ var _MainTable = _interopRequireDefault(require("./components/MainTable"));
|
|
|
354
402
|
|
|
355
403
|
var _ModularTable = _interopRequireDefault(require("./components/ModularTable"));
|
|
356
404
|
|
|
405
|
+
var _Navigation = _interopRequireDefault(require("./components/Navigation"));
|
|
406
|
+
|
|
357
407
|
var _Modal = _interopRequireDefault(require("./components/Modal"));
|
|
358
408
|
|
|
359
409
|
var _Notification = _interopRequireWildcard(require("./components/Notification"));
|
|
@@ -378,6 +428,8 @@ var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
|
378
428
|
|
|
379
429
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|
|
380
430
|
|
|
431
|
+
var _StatusLabel = _interopRequireWildcard(require("./components/StatusLabel"));
|
|
432
|
+
|
|
381
433
|
var _Strip = _interopRequireDefault(require("./components/Strip"));
|
|
382
434
|
|
|
383
435
|
var _SummaryButton = _interopRequireDefault(require("./components/SummaryButton"));
|
|
@@ -398,6 +450,10 @@ var _Tooltip = _interopRequireDefault(require("./components/Tooltip"));
|
|
|
398
450
|
|
|
399
451
|
var _hooks = require("./hooks");
|
|
400
452
|
|
|
453
|
+
var _utils = require("./utils");
|
|
454
|
+
|
|
455
|
+
var _enums = require("./enums");
|
|
456
|
+
|
|
401
457
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
402
458
|
|
|
403
459
|
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; }
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NavLink, NavLinkAnchor, NavLinkButton } from "./components/Navigation";
|
|
1
2
|
export declare const IS_DEV: boolean;
|
|
2
3
|
/**
|
|
3
4
|
* Find substring and wrap in <strong /> tag
|
|
@@ -9,3 +10,13 @@ export declare const highlightSubString: (str?: string, subString?: string) => {
|
|
|
9
10
|
text: string;
|
|
10
11
|
match: boolean;
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Whether a navigation item is an anchor.
|
|
15
|
+
* @param link - The navigation item.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isNavigationAnchor: (link: NavLink) => link is NavLinkAnchor;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a navigation item is a button.
|
|
20
|
+
* @param link - The navigation item.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isNavigationButton: (link: NavLink) => link is NavLinkButton;
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.highlightSubString = exports.IS_DEV = void 0;
|
|
6
|
+
exports.isNavigationButton = exports.isNavigationAnchor = exports.highlightSubString = exports.IS_DEV = void 0;
|
|
7
7
|
var IS_DEV = process.env.NODE_ENV === "development";
|
|
8
8
|
/**
|
|
9
9
|
* Find substring and wrap in <strong /> tag
|
|
@@ -31,5 +31,27 @@ var highlightSubString = function highlightSubString(str, subString) {
|
|
|
31
31
|
match: newStr !== str
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Whether a navigation item is an anchor.
|
|
36
|
+
* @param link - The navigation item.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.highlightSubString = highlightSubString;
|
|
41
|
+
|
|
42
|
+
var isNavigationAnchor = function isNavigationAnchor(link) {
|
|
43
|
+
return !!link.url;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Whether a navigation item is a button.
|
|
47
|
+
* @param link - The navigation item.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
exports.isNavigationAnchor = isNavigationAnchor;
|
|
52
|
+
|
|
53
|
+
var isNavigationButton = function isNavigationButton(link) {
|
|
54
|
+
return !link.url;
|
|
55
|
+
};
|
|
34
56
|
|
|
35
|
-
exports.
|
|
57
|
+
exports.isNavigationButton = isNavigationButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,87 +22,89 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "/react-components/",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.17.
|
|
26
|
-
"@babel/eslint-parser": "7.
|
|
27
|
-
"@babel/preset-typescript": "7.
|
|
28
|
-
"@percy/cli": "1.
|
|
29
|
-
"@percy/storybook": "4.2.
|
|
30
|
-
"@storybook/addon-a11y": "6.
|
|
31
|
-
"@storybook/addon-controls": "6.
|
|
32
|
-
"@storybook/addon-docs": "6.
|
|
33
|
-
"@storybook/addons": "6.
|
|
34
|
-
"@storybook/react": "6.
|
|
35
|
-
"@storybook/theming": "6.
|
|
25
|
+
"@babel/cli": "7.17.10",
|
|
26
|
+
"@babel/eslint-parser": "7.18.2",
|
|
27
|
+
"@babel/preset-typescript": "7.17.12",
|
|
28
|
+
"@percy/cli": "1.2.1",
|
|
29
|
+
"@percy/storybook": "4.2.1",
|
|
30
|
+
"@storybook/addon-a11y": "6.5.6",
|
|
31
|
+
"@storybook/addon-controls": "6.5.6",
|
|
32
|
+
"@storybook/addon-docs": "6.5.6",
|
|
33
|
+
"@storybook/addons": "6.5.6",
|
|
34
|
+
"@storybook/react": "6.5.6",
|
|
35
|
+
"@storybook/theming": "6.5.6",
|
|
36
36
|
"@testing-library/cypress": "8.0.2",
|
|
37
|
-
"@testing-library/dom": "8.
|
|
38
|
-
"@testing-library/jest-dom": "5.16.
|
|
39
|
-
"@testing-library/react": "12.1.
|
|
37
|
+
"@testing-library/dom": "8.13.0",
|
|
38
|
+
"@testing-library/jest-dom": "5.16.4",
|
|
39
|
+
"@testing-library/react": "12.1.5",
|
|
40
40
|
"@testing-library/react-hooks": "7.0.2",
|
|
41
41
|
"@testing-library/user-event": "13.5.0",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
43
|
-
"@typescript-eslint/parser": "5.
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "5.27.0",
|
|
43
|
+
"@typescript-eslint/parser": "5.27.0",
|
|
44
44
|
"@wojtekmaj/enzyme-adapter-react-17": "0.6.7",
|
|
45
45
|
"babel-jest": "27.5.1",
|
|
46
|
-
"babel-loader": "8.2.
|
|
46
|
+
"babel-loader": "8.2.5",
|
|
47
47
|
"babel-plugin-module-resolver": "4.1.0",
|
|
48
48
|
"babel-plugin-typescript-to-proptypes": "2.0.0",
|
|
49
|
-
"concurrently": "7.1
|
|
49
|
+
"concurrently": "7.2.1",
|
|
50
50
|
"css-loader": "5.2.7",
|
|
51
|
-
"cypress": "9.
|
|
51
|
+
"cypress": "9.7.0",
|
|
52
52
|
"deepmerge": "4.2.2",
|
|
53
53
|
"enzyme": "3.11.0",
|
|
54
54
|
"enzyme-adapter-react-16": "1.15.6",
|
|
55
55
|
"enzyme-to-json": "3.6.2",
|
|
56
|
-
"eslint": "8.
|
|
56
|
+
"eslint": "8.16.0",
|
|
57
57
|
"eslint-config-prettier": "8.5.0",
|
|
58
|
-
"eslint-config-react-app": "7.0.
|
|
58
|
+
"eslint-config-react-app": "7.0.1",
|
|
59
59
|
"eslint-plugin-cypress": "2.12.1",
|
|
60
60
|
"eslint-plugin-flowtype": "8.0.3",
|
|
61
|
-
"eslint-plugin-import": "2.
|
|
61
|
+
"eslint-plugin-import": "2.26.0",
|
|
62
62
|
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
63
63
|
"eslint-plugin-prettier": "4.0.0",
|
|
64
|
-
"eslint-plugin-react": "7.
|
|
65
|
-
"eslint-plugin-react-hooks": "4.
|
|
66
|
-
"eslint-plugin-testing-library": "5.
|
|
64
|
+
"eslint-plugin-react": "7.30.0",
|
|
65
|
+
"eslint-plugin-react-hooks": "4.5.0",
|
|
66
|
+
"eslint-plugin-testing-library": "5.5.1",
|
|
67
67
|
"jest": "27.5.1",
|
|
68
68
|
"npm-package-json-lint": "5.4.2",
|
|
69
69
|
"prettier": "2.6.2",
|
|
70
70
|
"react": "17.0.2",
|
|
71
71
|
"react-docgen-typescript-loader": "3.7.2",
|
|
72
72
|
"react-dom": "17.0.2",
|
|
73
|
-
"sass": "1.
|
|
73
|
+
"sass": "1.52.2",
|
|
74
74
|
"sass-loader": "10.2.1",
|
|
75
75
|
"style-loader": "2.0.0",
|
|
76
|
-
"stylelint": "14.
|
|
76
|
+
"stylelint": "14.8.5",
|
|
77
77
|
"stylelint-config-prettier": "9.0.3",
|
|
78
78
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
79
79
|
"stylelint-order": "5.0.0",
|
|
80
80
|
"stylelint-prettier": "2.0.0",
|
|
81
|
-
"ts-jest": "27.1.
|
|
82
|
-
"tsc-alias": "1.6.
|
|
83
|
-
"typescript": "4.
|
|
84
|
-
"vanilla-framework": "3.
|
|
81
|
+
"ts-jest": "27.1.5",
|
|
82
|
+
"tsc-alias": "1.6.8",
|
|
83
|
+
"typescript": "4.7.2",
|
|
84
|
+
"vanilla-framework": "3.4.0",
|
|
85
85
|
"wait-on": "5.3.0"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@types/jest": "27.
|
|
89
|
-
"@types/node": "16.11.
|
|
90
|
-
"@types/react": "17.0.
|
|
91
|
-
"@types/react-dom": "17.0.
|
|
92
|
-
"@types/react-table": "7.7.
|
|
88
|
+
"@types/jest": "27.5.2",
|
|
89
|
+
"@types/node": "16.11.38",
|
|
90
|
+
"@types/react": "17.0.45",
|
|
91
|
+
"@types/react-dom": "17.0.17",
|
|
92
|
+
"@types/react-table": "7.7.12",
|
|
93
93
|
"classnames": "2.3.1",
|
|
94
|
-
"nanoid": "3.3.
|
|
94
|
+
"nanoid": "3.3.4",
|
|
95
95
|
"prop-types": "15.8.1",
|
|
96
|
-
"react-table": "7.
|
|
96
|
+
"react-table": "7.8.0",
|
|
97
97
|
"react-useportal": "1.0.16"
|
|
98
98
|
},
|
|
99
99
|
"resolutions": {
|
|
100
|
+
"@types/react": "17.0.45",
|
|
101
|
+
"@types/react-dom": "17.0.17",
|
|
100
102
|
"postcss": "^8.3.11"
|
|
101
103
|
},
|
|
102
104
|
"peerDependencies": {
|
|
103
105
|
"react": "17.0.2",
|
|
104
106
|
"react-dom": "17.0.2",
|
|
105
|
-
"vanilla-framework": "3.
|
|
107
|
+
"vanilla-framework": "3.4.0"
|
|
106
108
|
},
|
|
107
109
|
"scripts": {
|
|
108
110
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|