@canonical/react-components 0.40.1 → 0.42.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/__mocks__/nanoid.js +0 -2
- package/dist/components/Accordion/Accordion.js +13 -37
- package/dist/components/Accordion/AccordionSection/AccordionSection.js +8 -14
- package/dist/components/Accordion/AccordionSection/index.js +0 -2
- package/dist/components/Accordion/index.js +0 -2
- package/dist/components/ActionButton/ActionButton.js +36 -68
- package/dist/components/ActionButton/index.js +0 -2
- package/dist/components/ArticlePagination/ArticlePagination.js +5 -15
- package/dist/components/ArticlePagination/index.js +0 -2
- package/dist/components/Badge/Badge.js +10 -28
- package/dist/components/Badge/index.js +0 -2
- package/dist/components/Button/Button.js +12 -25
- package/dist/components/Button/index.js +0 -4
- package/dist/components/Card/Card.js +6 -17
- package/dist/components/Card/index.js +0 -2
- package/dist/components/CheckboxInput/CheckableInput/CheckableInput.js +6 -20
- package/dist/components/CheckboxInput/CheckableInput/index.js +0 -2
- package/dist/components/CheckboxInput/CheckboxInput.js +3 -13
- package/dist/components/CheckboxInput/index.js +0 -2
- package/dist/components/Chip/Chip.js +18 -35
- package/dist/components/Chip/index.js +0 -2
- package/dist/components/Code/Code.js +5 -23
- package/dist/components/Code/index.js +0 -2
- package/dist/components/CodeSnippet/CodeSnippet.js +2 -12
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +10 -18
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +5 -14
- package/dist/components/CodeSnippet/index.js +0 -3
- package/dist/components/Col/Col.js +15 -25
- package/dist/components/Col/index.js +0 -4
- package/dist/components/ContextualMenu/ContextualMenu.js +70 -105
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +51 -88
- package/dist/components/ContextualMenu/ContextualMenuDropdown/index.js +0 -2
- package/dist/components/ContextualMenu/index.js +0 -2
- package/dist/components/Field/Field.js +35 -51
- package/dist/components/Field/index.js +0 -2
- package/dist/components/Form/Form.js +4 -14
- package/dist/components/Form/index.js +0 -2
- package/dist/components/Icon/Icon.js +3 -14
- package/dist/components/Icon/index.js +0 -4
- package/dist/components/Input/Input.js +21 -39
- package/dist/components/Input/index.js +0 -2
- package/dist/components/Label/Label.js +7 -13
- package/dist/components/Label/index.js +0 -2
- package/dist/components/Link/Link.js +10 -22
- package/dist/components/Link/index.js +0 -2
- package/dist/components/List/List.js +18 -31
- package/dist/components/List/index.js +0 -2
- package/dist/components/Loader/Loader.js +0 -7
- package/dist/components/Loader/index.js +0 -2
- package/dist/components/MainTable/MainTable.js +60 -112
- package/dist/components/MainTable/index.js +0 -2
- package/dist/components/Modal/Modal.js +7 -34
- package/dist/components/Modal/index.js +0 -2
- package/dist/components/ModularTable/ModularTable.d.ts +9 -1
- package/dist/components/ModularTable/ModularTable.js +74 -63
- package/dist/components/ModularTable/index.js +0 -2
- package/dist/components/Navigation/Navigation.js +46 -82
- package/dist/components/Navigation/NavigationLink/NavigationLink.js +15 -30
- package/dist/components/Navigation/NavigationLink/index.js +0 -2
- package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +12 -35
- package/dist/components/Navigation/NavigationMenu/index.js +0 -2
- package/dist/components/Navigation/index.js +0 -2
- package/dist/components/Notification/Notification.d.ts +6 -1
- package/dist/components/Notification/Notification.js +31 -46
- package/dist/components/Notification/index.js +0 -4
- package/dist/components/Pagination/Pagination.js +14 -44
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +7 -14
- package/dist/components/Pagination/PaginationButton/index.js +0 -2
- package/dist/components/Pagination/PaginationItem/PaginationItem.js +3 -8
- package/dist/components/Pagination/PaginationItem/index.js +0 -2
- package/dist/components/Pagination/index.js +0 -2
- package/dist/components/PasswordToggle/PasswordToggle.js +21 -50
- package/dist/components/PasswordToggle/index.js +0 -2
- package/dist/components/RadioInput/RadioInput.js +1 -11
- package/dist/components/RadioInput/index.js +0 -2
- package/dist/components/Row/Row.js +2 -12
- package/dist/components/Row/index.js +0 -2
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +27 -49
- package/dist/components/SearchAndFilter/FilterPanelSection/index.js +0 -2
- package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +9 -1
- package/dist/components/SearchAndFilter/SearchAndFilter.js +84 -105
- package/dist/components/SearchAndFilter/index.js +0 -2
- package/dist/components/SearchAndFilter/utils.js +1 -7
- package/dist/components/SearchBox/SearchBox.js +18 -38
- package/dist/components/SearchBox/index.js +0 -2
- package/dist/components/Select/Select.js +20 -33
- package/dist/components/Select/index.js +0 -2
- package/dist/components/Slider/Slider.js +16 -32
- package/dist/components/Slider/index.js +0 -2
- package/dist/components/Spinner/Spinner.js +8 -19
- package/dist/components/Spinner/index.js +0 -2
- package/dist/components/StatusLabel/StatusLabel.js +4 -15
- package/dist/components/StatusLabel/index.js +0 -4
- package/dist/components/Strip/Strip.js +25 -36
- package/dist/components/Strip/index.js +0 -2
- package/dist/components/SummaryButton/SummaryButton.js +4 -10
- package/dist/components/SummaryButton/index.js +0 -2
- package/dist/components/Switch/Switch.js +3 -12
- package/dist/components/Switch/index.js +0 -2
- package/dist/components/Table/Table.js +6 -16
- package/dist/components/Table/index.js +0 -2
- package/dist/components/TableCell/TableCell.js +10 -20
- package/dist/components/TableCell/index.js +0 -2
- package/dist/components/TableHeader/TableHeader.js +2 -11
- package/dist/components/TableHeader/index.js +0 -2
- package/dist/components/TableRow/TableRow.js +1 -10
- package/dist/components/TableRow/index.js +0 -2
- package/dist/components/Tabs/Tabs.js +7 -17
- package/dist/components/Tabs/index.js +0 -2
- package/dist/components/Textarea/Textarea.js +23 -36
- package/dist/components/Textarea/index.js +0 -2
- package/dist/components/Tooltip/Tooltip.js +42 -87
- package/dist/components/Tooltip/index.js +0 -4
- package/dist/enums.js +4 -6
- package/dist/hooks/index.js +0 -8
- package/dist/hooks/useClickOutside.js +2 -7
- package/dist/hooks/useId.js +0 -4
- package/dist/hooks/useListener.js +0 -8
- package/dist/hooks/useOnEscapePressed.js +0 -3
- package/dist/hooks/usePagination.js +13 -25
- package/dist/hooks/usePrevious.js +0 -3
- package/dist/hooks/useThrottle.js +1 -15
- package/dist/hooks/useWindowFitment.d.ts +12 -0
- package/dist/hooks/useWindowFitment.js +22 -17
- package/dist/index.js +0 -52
- package/dist/utils.js +3 -10
- package/package.json +36 -35
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.usePagination = usePagination;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
|
|
12
9
|
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
10
|
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
|
|
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
|
-
|
|
11
|
+
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; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* A hook that handles pagination.
|
|
24
16
|
* @param data - The data array to paginate.
|
|
@@ -27,37 +19,33 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
27
19
|
* @param {number} [options.initialPage=1] - Initial page number. Defaults to 1.
|
|
28
20
|
* @param {boolean} [options.autoResetPage=false] - Whether to reset the page number to 1 when the data changes.
|
|
29
21
|
*/
|
|
22
|
+
|
|
30
23
|
function usePagination(data, options) {
|
|
31
24
|
var _data$length;
|
|
32
|
-
|
|
33
25
|
var defaultOptions = {
|
|
34
26
|
initialPage: 1,
|
|
35
27
|
autoResetPage: false
|
|
36
28
|
};
|
|
37
|
-
|
|
38
29
|
var _Object$assign = Object.assign(defaultOptions, options),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
itemsPerPage = _Object$assign.itemsPerPage,
|
|
31
|
+
initialPage = _Object$assign.initialPage,
|
|
32
|
+
autoResetPage = _Object$assign.autoResetPage;
|
|
43
33
|
var totalItems = (_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : 0;
|
|
44
34
|
var initialPageIndex = initialPage > 0 ? initialPage - 1 : 0;
|
|
45
|
-
|
|
46
35
|
var _useState = (0, _react.useState)(initialPageIndex),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
pageIndex = _useState2[0],
|
|
38
|
+
setPageIndex = _useState2[1];
|
|
51
39
|
var startIndex = typeof itemsPerPage === "number" ? pageIndex * itemsPerPage : 0;
|
|
52
|
-
|
|
53
40
|
var paginate = function paginate(pageNumber) {
|
|
54
41
|
return setPageIndex(pageNumber - 1);
|
|
55
42
|
};
|
|
56
|
-
|
|
57
43
|
(0, _react.useEffect)(function () {
|
|
58
44
|
if (typeof itemsPerPage === "number" && startIndex >= totalItems) {
|
|
59
|
-
!autoResetPage && Math.floor(totalItems / itemsPerPage) > 0 ?
|
|
60
|
-
|
|
45
|
+
!autoResetPage && Math.floor(totalItems / itemsPerPage) > 0 ?
|
|
46
|
+
// go to the last available page if the current page is out of bounds
|
|
47
|
+
setPageIndex(Math.floor(totalItems / itemsPerPage) - 1) :
|
|
48
|
+
// go to the initial page if autoResetPage is true
|
|
61
49
|
setPageIndex(0);
|
|
62
50
|
}
|
|
63
51
|
}, [pageIndex, startIndex, setPageIndex, totalItems, itemsPerPage, autoResetPage]);
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.usePrevious = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* A hook to handle storing the previous value of anything.
|
|
12
10
|
* @param value - The value to watch.
|
|
@@ -21,5 +19,4 @@ var usePrevious = function usePrevious(value) {
|
|
|
21
19
|
}, [value]);
|
|
22
20
|
return ref.current;
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
exports.usePrevious = usePrevious;
|
|
@@ -4,24 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useThrottle = exports.THROTTLE_DELAY = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
-
|
|
12
9
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
10
|
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
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
-
|
|
18
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
13
|
+
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; }
|
|
22
14
|
var THROTTLE_DELAY = 1000 / 60;
|
|
23
15
|
exports.THROTTLE_DELAY = THROTTLE_DELAY;
|
|
24
|
-
|
|
25
16
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
26
17
|
|
|
27
18
|
/**
|
|
@@ -39,22 +30,18 @@ var useThrottle = function useThrottle(callback) {
|
|
|
39
30
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
31
|
args[_key] = arguments[_key];
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
lastArgs.current = args;
|
|
44
|
-
|
|
45
34
|
var callCallback = function callCallback() {
|
|
46
35
|
callback.apply(void 0, _toConsumableArray(lastArgs.current));
|
|
47
36
|
lastCall.current = Date.now();
|
|
48
37
|
timeout.current = null;
|
|
49
38
|
};
|
|
50
|
-
|
|
51
39
|
var createTimeout = function createTimeout() {
|
|
52
40
|
timeout.current = window.setTimeout(function () {
|
|
53
41
|
callCallback();
|
|
54
42
|
timeout.current = null;
|
|
55
43
|
}, delay);
|
|
56
44
|
};
|
|
57
|
-
|
|
58
45
|
if (!lastCall.current) {
|
|
59
46
|
// Initially call the callback and start a timeout for the next call.
|
|
60
47
|
callCallback();
|
|
@@ -75,5 +62,4 @@ var useThrottle = function useThrottle(callback) {
|
|
|
75
62
|
}, []);
|
|
76
63
|
return throttle;
|
|
77
64
|
};
|
|
78
|
-
|
|
79
65
|
exports.useThrottle = useThrottle;
|
|
@@ -2,24 +2,36 @@ export type WindowFitment = {
|
|
|
2
2
|
fromTop: {
|
|
3
3
|
fitsAbove: boolean;
|
|
4
4
|
fitsBelow: boolean;
|
|
5
|
+
spaceAbove: number;
|
|
6
|
+
spaceBelow: number;
|
|
5
7
|
};
|
|
6
8
|
fromBottom: {
|
|
7
9
|
fitsAbove: boolean;
|
|
8
10
|
fitsBelow: boolean;
|
|
11
|
+
spaceAbove: number;
|
|
12
|
+
spaceBelow: number;
|
|
9
13
|
};
|
|
10
14
|
fromLeft: {
|
|
11
15
|
fitsLeft: boolean;
|
|
12
16
|
fitsRight: boolean;
|
|
17
|
+
spaceLeft: number;
|
|
18
|
+
spaceRight: number;
|
|
13
19
|
};
|
|
14
20
|
fromRight: {
|
|
15
21
|
fitsLeft: boolean;
|
|
16
22
|
fitsRight: boolean;
|
|
23
|
+
spaceLeft: number;
|
|
24
|
+
spaceRight: number;
|
|
17
25
|
};
|
|
18
26
|
fromCenter: {
|
|
19
27
|
fitsLeft: boolean;
|
|
20
28
|
fitsRight: boolean;
|
|
21
29
|
fitsAbove: boolean;
|
|
22
30
|
fitsBelow: boolean;
|
|
31
|
+
spaceLeft: number;
|
|
32
|
+
spaceRight: number;
|
|
33
|
+
spaceAbove: number;
|
|
34
|
+
spaceBelow: number;
|
|
23
35
|
fitsCentered: {
|
|
24
36
|
fitsAbove: boolean;
|
|
25
37
|
fitsBelow: boolean;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useWindowFitment = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _useListener = require("./useListener");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* A hook to determine if an element fits on the window.
|
|
14
11
|
* @param targetNode The element to try and fit on the window.
|
|
@@ -27,7 +24,6 @@ var useWindowFitment = function useWindowFitment(targetNode, referenceNode, call
|
|
|
27
24
|
var htmlRef = (0, _react.useRef)(document.querySelector("html"));
|
|
28
25
|
var update = (0, _react.useCallback)(function (evt) {
|
|
29
26
|
var referenceCoordinates;
|
|
30
|
-
|
|
31
27
|
if (fromMouse) {
|
|
32
28
|
if (evt) {
|
|
33
29
|
referenceCoordinates = {
|
|
@@ -41,17 +37,15 @@ var useWindowFitment = function useWindowFitment(targetNode, referenceNode, call
|
|
|
41
37
|
} else if (referenceNode) {
|
|
42
38
|
referenceCoordinates = referenceNode.getBoundingClientRect();
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
if (shouldCheck && targetNode && referenceCoordinates) {
|
|
46
41
|
var _targetNode$getBoundi = targetNode.getBoundingClientRect(),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
targetHeight = _targetNode$getBoundi.height,
|
|
43
|
+
targetWidth = _targetNode$getBoundi.width;
|
|
50
44
|
var _referenceCoordinates = referenceCoordinates,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
referenceHeight = _referenceCoordinates.height,
|
|
46
|
+
referenceLeft = _referenceCoordinates.left,
|
|
47
|
+
referenceTop = _referenceCoordinates.top,
|
|
48
|
+
referenceWidth = _referenceCoordinates.width;
|
|
55
49
|
var referenceBottom = referenceTop + referenceHeight;
|
|
56
50
|
var referenceRight = referenceLeft + referenceWidth;
|
|
57
51
|
var referenceCenterX = referenceLeft + referenceWidth / 2;
|
|
@@ -67,25 +61,37 @@ var useWindowFitment = function useWindowFitment(targetNode, referenceNode, call
|
|
|
67
61
|
callback({
|
|
68
62
|
fromTop: {
|
|
69
63
|
fitsAbove: referenceTop - heightIncludingSpace > windowTop,
|
|
70
|
-
fitsBelow: referenceTop + heightIncludingSpace < windowBottom
|
|
64
|
+
fitsBelow: referenceTop + heightIncludingSpace < windowBottom,
|
|
65
|
+
spaceAbove: Math.abs(windowTop - referenceTop),
|
|
66
|
+
spaceBelow: windowBottom - referenceTop
|
|
71
67
|
},
|
|
72
68
|
fromBottom: {
|
|
73
69
|
fitsAbove: referenceBottom - heightIncludingSpace > windowTop,
|
|
74
|
-
fitsBelow: referenceBottom + heightIncludingSpace < windowBottom
|
|
70
|
+
fitsBelow: referenceBottom + heightIncludingSpace < windowBottom,
|
|
71
|
+
spaceAbove: Math.abs(windowTop - referenceBottom),
|
|
72
|
+
spaceBelow: windowBottom - referenceBottom
|
|
75
73
|
},
|
|
76
74
|
fromLeft: {
|
|
77
75
|
fitsLeft: referenceLeft - widthIncludingSpace > windowLeft,
|
|
78
|
-
fitsRight: referenceLeft + widthIncludingSpace < windowRight
|
|
76
|
+
fitsRight: referenceLeft + widthIncludingSpace < windowRight,
|
|
77
|
+
spaceLeft: Math.abs(windowLeft - referenceLeft),
|
|
78
|
+
spaceRight: windowRight - referenceLeft
|
|
79
79
|
},
|
|
80
80
|
fromRight: {
|
|
81
81
|
fitsLeft: referenceRight - widthIncludingSpace > windowLeft,
|
|
82
|
-
fitsRight: referenceRight + widthIncludingSpace < windowRight
|
|
82
|
+
fitsRight: referenceRight + widthIncludingSpace < windowRight,
|
|
83
|
+
spaceLeft: Math.abs(windowLeft - referenceRight),
|
|
84
|
+
spaceRight: windowRight - referenceRight
|
|
83
85
|
},
|
|
84
86
|
fromCenter: {
|
|
85
87
|
fitsLeft: referenceCenterX - widthIncludingSpace > windowLeft,
|
|
86
88
|
fitsRight: referenceCenterX + widthIncludingSpace < windowRight,
|
|
87
89
|
fitsAbove: referenceCenterY - heightIncludingSpace > windowTop,
|
|
88
90
|
fitsBelow: referenceCenterY + heightIncludingSpace < windowBottom,
|
|
91
|
+
spaceAbove: Math.abs(windowTop - referenceCenterY),
|
|
92
|
+
spaceBelow: windowBottom - referenceCenterY,
|
|
93
|
+
spaceLeft: Math.abs(windowLeft - referenceCenterX),
|
|
94
|
+
spaceRight: windowRight - referenceCenterX,
|
|
89
95
|
fitsCentered: {
|
|
90
96
|
fitsLeft: referenceCenterX - widthFromCenter > windowLeft,
|
|
91
97
|
fitsRight: referenceCenterX + widthFromCenter < windowRight,
|
|
@@ -105,5 +111,4 @@ var useWindowFitment = function useWindowFitment(targetNode, referenceNode, call
|
|
|
105
111
|
}
|
|
106
112
|
}, [fromMouse, update]);
|
|
107
113
|
};
|
|
108
|
-
|
|
109
114
|
exports.useWindowFitment = useWindowFitment;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -371,105 +370,54 @@ Object.defineProperty(exports, "useWindowFitment", {
|
|
|
371
370
|
return _hooks.useWindowFitment;
|
|
372
371
|
}
|
|
373
372
|
});
|
|
374
|
-
|
|
375
373
|
var _Accordion = _interopRequireDefault(require("./components/Accordion"));
|
|
376
|
-
|
|
377
374
|
var _ActionButton = _interopRequireDefault(require("./components/ActionButton"));
|
|
378
|
-
|
|
379
375
|
var _ArticlePagination = _interopRequireDefault(require("./components/ArticlePagination"));
|
|
380
|
-
|
|
381
376
|
var _Badge = _interopRequireDefault(require("./components/Badge"));
|
|
382
|
-
|
|
383
377
|
var _Button = _interopRequireWildcard(require("./components/Button"));
|
|
384
|
-
|
|
385
378
|
var _Card = _interopRequireDefault(require("./components/Card"));
|
|
386
|
-
|
|
387
379
|
var _CheckboxInput = _interopRequireDefault(require("./components/CheckboxInput"));
|
|
388
|
-
|
|
389
380
|
var _Chip = _interopRequireDefault(require("./components/Chip"));
|
|
390
|
-
|
|
391
381
|
var _Code = _interopRequireDefault(require("./components/Code"));
|
|
392
|
-
|
|
393
382
|
var _CodeSnippet = _interopRequireWildcard(require("./components/CodeSnippet"));
|
|
394
|
-
|
|
395
383
|
var _Col = _interopRequireDefault(require("./components/Col"));
|
|
396
|
-
|
|
397
384
|
var _ContextualMenu = _interopRequireDefault(require("./components/ContextualMenu"));
|
|
398
|
-
|
|
399
385
|
var _Field = _interopRequireDefault(require("./components/Field"));
|
|
400
|
-
|
|
401
386
|
var _Form = _interopRequireDefault(require("./components/Form"));
|
|
402
|
-
|
|
403
387
|
var _Icon = _interopRequireWildcard(require("./components/Icon"));
|
|
404
|
-
|
|
405
388
|
var _Input = _interopRequireDefault(require("./components/Input"));
|
|
406
|
-
|
|
407
389
|
var _Label = _interopRequireDefault(require("./components/Label"));
|
|
408
|
-
|
|
409
390
|
var _Link = _interopRequireDefault(require("./components/Link"));
|
|
410
|
-
|
|
411
391
|
var _List = _interopRequireDefault(require("./components/List"));
|
|
412
|
-
|
|
413
392
|
var _Loader = _interopRequireDefault(require("./components/Loader"));
|
|
414
|
-
|
|
415
393
|
var _MainTable = _interopRequireDefault(require("./components/MainTable"));
|
|
416
|
-
|
|
417
394
|
var _ModularTable = _interopRequireDefault(require("./components/ModularTable"));
|
|
418
|
-
|
|
419
395
|
var _Navigation = _interopRequireDefault(require("./components/Navigation"));
|
|
420
|
-
|
|
421
396
|
var _Modal = _interopRequireDefault(require("./components/Modal"));
|
|
422
|
-
|
|
423
397
|
var _Notification = _interopRequireWildcard(require("./components/Notification"));
|
|
424
|
-
|
|
425
398
|
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
|
426
|
-
|
|
427
399
|
var _PasswordToggle = _interopRequireDefault(require("./components/PasswordToggle"));
|
|
428
|
-
|
|
429
400
|
var _RadioInput = _interopRequireDefault(require("./components/RadioInput"));
|
|
430
|
-
|
|
431
401
|
var _Row = _interopRequireDefault(require("./components/Row"));
|
|
432
|
-
|
|
433
402
|
var _SearchAndFilter = _interopRequireDefault(require("./components/SearchAndFilter"));
|
|
434
|
-
|
|
435
403
|
var _SearchBox = _interopRequireDefault(require("./components/SearchBox"));
|
|
436
|
-
|
|
437
404
|
var _Select = _interopRequireDefault(require("./components/Select"));
|
|
438
|
-
|
|
439
405
|
var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
440
|
-
|
|
441
406
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
442
|
-
|
|
443
407
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|
|
444
|
-
|
|
445
408
|
var _StatusLabel = _interopRequireWildcard(require("./components/StatusLabel"));
|
|
446
|
-
|
|
447
409
|
var _Strip = _interopRequireDefault(require("./components/Strip"));
|
|
448
|
-
|
|
449
410
|
var _SummaryButton = _interopRequireDefault(require("./components/SummaryButton"));
|
|
450
|
-
|
|
451
411
|
var _Table = _interopRequireDefault(require("./components/Table"));
|
|
452
|
-
|
|
453
412
|
var _TableCell = _interopRequireDefault(require("./components/TableCell"));
|
|
454
|
-
|
|
455
413
|
var _TableHeader = _interopRequireDefault(require("./components/TableHeader"));
|
|
456
|
-
|
|
457
414
|
var _TableRow = _interopRequireDefault(require("./components/TableRow"));
|
|
458
|
-
|
|
459
415
|
var _Tabs = _interopRequireDefault(require("./components/Tabs"));
|
|
460
|
-
|
|
461
416
|
var _Textarea = _interopRequireDefault(require("./components/Textarea"));
|
|
462
|
-
|
|
463
417
|
var _Tooltip = _interopRequireDefault(require("./components/Tooltip"));
|
|
464
|
-
|
|
465
418
|
var _hooks = require("./hooks");
|
|
466
|
-
|
|
467
419
|
var _utils = require("./utils");
|
|
468
|
-
|
|
469
420
|
var _enums = require("./enums");
|
|
470
|
-
|
|
471
421
|
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); }
|
|
472
|
-
|
|
473
422
|
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; }
|
|
474
|
-
|
|
475
423
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/utils.js
CHANGED
|
@@ -5,15 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
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
10
|
* Find substring and wrap in <strong /> tag
|
|
10
11
|
* @param {string} str - The string to search
|
|
11
12
|
* @param {string} subString - The substring to find
|
|
12
13
|
* @return {Obj} newStr - Object with text and match bool
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
exports.IS_DEV = IS_DEV;
|
|
16
|
-
|
|
17
16
|
var highlightSubString = function highlightSubString(str, subString) {
|
|
18
17
|
if (typeof str !== "string" || typeof subString !== "string") {
|
|
19
18
|
return {
|
|
@@ -21,7 +20,6 @@ var highlightSubString = function highlightSubString(str, subString) {
|
|
|
21
20
|
match: false
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
var caseInsensitiveRegex = new RegExp(subString, "gi");
|
|
26
24
|
var newStr = str.replace(caseInsensitiveRegex, function (match) {
|
|
27
25
|
return "<strong>".concat(match, "</strong>");
|
|
@@ -31,27 +29,22 @@ var highlightSubString = function highlightSubString(str, subString) {
|
|
|
31
29
|
match: newStr !== str
|
|
32
30
|
};
|
|
33
31
|
};
|
|
32
|
+
|
|
34
33
|
/**
|
|
35
34
|
* Whether a navigation item is an anchor.
|
|
36
35
|
* @param link - The navigation item.
|
|
37
36
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
37
|
exports.highlightSubString = highlightSubString;
|
|
41
|
-
|
|
42
38
|
var isNavigationAnchor = function isNavigationAnchor(link) {
|
|
43
39
|
return !!link.url;
|
|
44
40
|
};
|
|
41
|
+
|
|
45
42
|
/**
|
|
46
43
|
* Whether a navigation item is a button.
|
|
47
44
|
* @param link - The navigation item.
|
|
48
45
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
46
|
exports.isNavigationAnchor = isNavigationAnchor;
|
|
52
|
-
|
|
53
47
|
var isNavigationButton = function isNavigationButton(link) {
|
|
54
48
|
return !link.url;
|
|
55
49
|
};
|
|
56
|
-
|
|
57
50
|
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.42.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://canonical.github.io/react-components",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.
|
|
26
|
-
"@babel/eslint-parser": "7.
|
|
27
|
-
"@babel/preset-typescript": "7.
|
|
28
|
-
"@percy/cli": "1.
|
|
29
|
-
"@percy/storybook": "4.3.
|
|
25
|
+
"@babel/cli": "7.21.5",
|
|
26
|
+
"@babel/eslint-parser": "7.21.3",
|
|
27
|
+
"@babel/preset-typescript": "7.21.5",
|
|
28
|
+
"@percy/cli": "1.24.0",
|
|
29
|
+
"@percy/storybook": "4.3.6",
|
|
30
30
|
"@storybook/addon-a11y": "6.5.16",
|
|
31
31
|
"@storybook/addon-controls": "6.5.16",
|
|
32
32
|
"@storybook/addon-docs": "6.5.16",
|
|
@@ -36,74 +36,75 @@
|
|
|
36
36
|
"@storybook/react": "6.5.16",
|
|
37
37
|
"@storybook/theming": "6.5.16",
|
|
38
38
|
"@testing-library/cypress": "9.0.0",
|
|
39
|
-
"@testing-library/dom": "
|
|
39
|
+
"@testing-library/dom": "9.2.0",
|
|
40
40
|
"@testing-library/jest-dom": "5.16.5",
|
|
41
|
-
"@testing-library/react": "
|
|
42
|
-
"@testing-library/react-hooks": "8.0.1",
|
|
41
|
+
"@testing-library/react": "13.4.0",
|
|
43
42
|
"@testing-library/user-event": "14.4.3",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
45
|
-
"@typescript-eslint/parser": "5.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "5.59.1",
|
|
44
|
+
"@typescript-eslint/parser": "5.59.1",
|
|
46
45
|
"babel-jest": "27.5.1",
|
|
47
46
|
"babel-loader": "9.1.2",
|
|
48
47
|
"babel-plugin-module-resolver": "5.0.0",
|
|
49
|
-
"babel-plugin-typescript-to-proptypes": "2.
|
|
48
|
+
"babel-plugin-typescript-to-proptypes": "2.1.0",
|
|
50
49
|
"concurrently": "7.6.0",
|
|
51
50
|
"css-loader": "6.7.3",
|
|
52
|
-
"cypress": "12.
|
|
53
|
-
"deepmerge": "4.3.
|
|
54
|
-
"eslint": "8.
|
|
55
|
-
"eslint-config-prettier": "8.
|
|
51
|
+
"cypress": "12.11.0",
|
|
52
|
+
"deepmerge": "4.3.1",
|
|
53
|
+
"eslint": "8.39.0",
|
|
54
|
+
"eslint-config-prettier": "8.8.0",
|
|
56
55
|
"eslint-config-react-app": "7.0.1",
|
|
57
|
-
"eslint-plugin-cypress": "2.
|
|
56
|
+
"eslint-plugin-cypress": "2.13.3",
|
|
58
57
|
"eslint-plugin-flowtype": "8.0.3",
|
|
59
58
|
"eslint-plugin-import": "2.27.5",
|
|
60
59
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
61
60
|
"eslint-plugin-prettier": "4.2.1",
|
|
62
61
|
"eslint-plugin-react": "7.32.2",
|
|
63
62
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
64
|
-
"eslint-plugin-testing-library": "5.10.
|
|
63
|
+
"eslint-plugin-testing-library": "5.10.3",
|
|
65
64
|
"jest": "27.5.1",
|
|
66
65
|
"npm-package-json-lint": "5.4.2",
|
|
67
|
-
"prettier": "2.8.
|
|
68
|
-
"react": "
|
|
66
|
+
"prettier": "2.8.8",
|
|
67
|
+
"react": "18.2.0",
|
|
69
68
|
"react-docgen-typescript-loader": "3.7.2",
|
|
70
|
-
"react-dom": "
|
|
71
|
-
"sass": "1.
|
|
69
|
+
"react-dom": "18.2.0",
|
|
70
|
+
"sass": "1.62.1",
|
|
72
71
|
"sass-loader": "10.4.1",
|
|
73
|
-
"style-loader": "3.3.
|
|
72
|
+
"style-loader": "3.3.2",
|
|
74
73
|
"stylelint": "14.16.1",
|
|
75
|
-
"stylelint-config-prettier": "9.0.
|
|
74
|
+
"stylelint-config-prettier": "9.0.5",
|
|
76
75
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
77
76
|
"stylelint-order": "5.0.0",
|
|
78
77
|
"stylelint-prettier": "2.0.0",
|
|
79
78
|
"ts-jest": "27.1.5",
|
|
80
|
-
"tsc-alias": "1.8.
|
|
79
|
+
"tsc-alias": "1.8.6",
|
|
81
80
|
"typescript": "4.9.5",
|
|
82
|
-
"vanilla-framework": "3.
|
|
81
|
+
"vanilla-framework": "3.14.0",
|
|
83
82
|
"wait-on": "5.3.0",
|
|
84
|
-
"webpack": "5.
|
|
83
|
+
"webpack": "5.81.0"
|
|
85
84
|
},
|
|
86
85
|
"dependencies": {
|
|
87
86
|
"@types/jest": "27.5.2",
|
|
88
|
-
"@types/node": "18.
|
|
89
|
-
"@types/react": "18.0
|
|
90
|
-
"@types/react-dom": "17.0.
|
|
87
|
+
"@types/node": "18.16.3",
|
|
88
|
+
"@types/react": "18.2.0",
|
|
89
|
+
"@types/react-dom": "17.0.20",
|
|
91
90
|
"@types/react-table": "7.7.14",
|
|
92
91
|
"classnames": "2.3.2",
|
|
93
|
-
"nanoid": "3.3.
|
|
92
|
+
"nanoid": "3.3.6",
|
|
94
93
|
"prop-types": "15.8.1",
|
|
95
94
|
"react-table": "7.8.0",
|
|
96
|
-
"react-useportal": "1.0.
|
|
95
|
+
"react-useportal": "1.0.18"
|
|
97
96
|
},
|
|
98
97
|
"resolutions": {
|
|
99
|
-
"@types/react": "18.0
|
|
100
|
-
"@types/react-dom": "17.0.
|
|
98
|
+
"@types/react": "18.2.0",
|
|
99
|
+
"@types/react-dom": "17.0.20",
|
|
101
100
|
"postcss": "^8.3.11"
|
|
102
101
|
},
|
|
103
102
|
"peerDependencies": {
|
|
103
|
+
"@types/react": "^17.0.2 || ^18.0.0",
|
|
104
|
+
"@types/react-dom": "^17.0.2 || ^18.0.0",
|
|
104
105
|
"react": "^17.0.2 || ^18.0.0",
|
|
105
106
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
106
|
-
"vanilla-framework": "3.
|
|
107
|
+
"vanilla-framework": "3.14.0"
|
|
107
108
|
},
|
|
108
109
|
"scripts": {
|
|
109
110
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|