@canonical/react-components 2.16.1 → 3.0.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.
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _Card = _interopRequireDefault(require("../Card"));
|
|
10
10
|
var _Col = _interopRequireDefault(require("../Col"));
|
|
11
11
|
var _Navigation = _interopRequireDefault(require("../Navigation"));
|
|
12
12
|
var _Row = _interopRequireDefault(require("../Row"));
|
|
13
13
|
var _enums = require("../../enums");
|
|
14
14
|
require("./LoginPageLayout.scss");
|
|
15
|
-
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); }
|
|
16
|
-
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; }
|
|
17
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
16
|
const defaultLogo = {
|
|
19
17
|
src: "https://assets.ubuntu.com/v1/82818827-CoF_white.svg",
|
|
@@ -30,20 +28,6 @@ const LoginPageLayout = _ref => {
|
|
|
30
28
|
title,
|
|
31
29
|
logo = defaultLogo
|
|
32
30
|
} = _ref;
|
|
33
|
-
(0, _react.useLayoutEffect)(() => {
|
|
34
|
-
var _document$querySelect;
|
|
35
|
-
const bodyInitiallyContainsIsPaper = (_document$querySelect = document.querySelector("body")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.classList.contains("is-paper");
|
|
36
|
-
if (!bodyInitiallyContainsIsPaper) {
|
|
37
|
-
var _document$querySelect2;
|
|
38
|
-
(_document$querySelect2 = document.querySelector("body")) === null || _document$querySelect2 === void 0 || _document$querySelect2.classList.add("is-paper");
|
|
39
|
-
}
|
|
40
|
-
return () => {
|
|
41
|
-
if (!bodyInitiallyContainsIsPaper) {
|
|
42
|
-
var _document$querySelect3;
|
|
43
|
-
(_document$querySelect3 = document.querySelector("body")) === null || _document$querySelect3 === void 0 || _document$querySelect3.classList.remove("is-paper");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
47
31
|
return /*#__PURE__*/_react.default.createElement(_Row.default, {
|
|
48
32
|
className: "p-strip page-row"
|
|
49
33
|
}, /*#__PURE__*/_react.default.createElement(_Col.default, {
|
|
@@ -64,18 +64,19 @@ const Modal = _ref => {
|
|
|
64
64
|
(0, _react.useEffect)(() => {
|
|
65
65
|
modalRef.current.focus();
|
|
66
66
|
}, [modalRef]);
|
|
67
|
+
const hasCloseButton = !!close;
|
|
67
68
|
(0, _react.useEffect)(() => {
|
|
68
69
|
var _focusableModalElemen;
|
|
69
70
|
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
70
71
|
let focusIndex = 0;
|
|
71
72
|
// when the close button is rendered, focus on the 2nd content element and not the close btn.
|
|
72
|
-
if (
|
|
73
|
+
if (hasCloseButton && focusableModalElements.current.length > 1) {
|
|
73
74
|
focusIndex = 1;
|
|
74
75
|
}
|
|
75
76
|
(_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 || _focusableModalElemen.focus({
|
|
76
77
|
preventScroll: true
|
|
77
78
|
});
|
|
78
|
-
}, [
|
|
79
|
+
}, [hasCloseButton]);
|
|
79
80
|
(0, _react.useEffect)(() => {
|
|
80
81
|
const keyDown = event => {
|
|
81
82
|
const listener = keyListenersMap.get(event.code);
|
|
@@ -129,7 +130,7 @@ const Modal = _ref => {
|
|
|
129
130
|
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
130
131
|
className: "p-modal__title",
|
|
131
132
|
id: titleId
|
|
132
|
-
}, title),
|
|
133
|
+
}, title), hasCloseButton && /*#__PURE__*/_react.default.createElement("button", {
|
|
133
134
|
type: "button",
|
|
134
135
|
className: "p-modal__close",
|
|
135
136
|
"aria-label": "Close active modal",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _pt from "prop-types";
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
import Card from "../Card";
|
|
4
4
|
import Col from "../Col";
|
|
5
5
|
import Navigation from "../Navigation";
|
|
@@ -21,20 +21,6 @@ var LoginPageLayout = _ref => {
|
|
|
21
21
|
title,
|
|
22
22
|
logo = defaultLogo
|
|
23
23
|
} = _ref;
|
|
24
|
-
useLayoutEffect(() => {
|
|
25
|
-
var _document$querySelect;
|
|
26
|
-
var bodyInitiallyContainsIsPaper = (_document$querySelect = document.querySelector("body")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.classList.contains("is-paper");
|
|
27
|
-
if (!bodyInitiallyContainsIsPaper) {
|
|
28
|
-
var _document$querySelect2;
|
|
29
|
-
(_document$querySelect2 = document.querySelector("body")) === null || _document$querySelect2 === void 0 || _document$querySelect2.classList.add("is-paper");
|
|
30
|
-
}
|
|
31
|
-
return () => {
|
|
32
|
-
if (!bodyInitiallyContainsIsPaper) {
|
|
33
|
-
var _document$querySelect3;
|
|
34
|
-
(_document$querySelect3 = document.querySelector("body")) === null || _document$querySelect3 === void 0 || _document$querySelect3.classList.remove("is-paper");
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}, []);
|
|
38
24
|
return /*#__PURE__*/React.createElement(Row, {
|
|
39
25
|
className: "p-strip page-row"
|
|
40
26
|
}, /*#__PURE__*/React.createElement(Col, {
|
|
@@ -58,18 +58,19 @@ export var Modal = _ref => {
|
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
modalRef.current.focus();
|
|
60
60
|
}, [modalRef]);
|
|
61
|
+
var hasCloseButton = !!close;
|
|
61
62
|
useEffect(() => {
|
|
62
63
|
var _focusableModalElemen;
|
|
63
64
|
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
64
65
|
var focusIndex = 0;
|
|
65
66
|
// when the close button is rendered, focus on the 2nd content element and not the close btn.
|
|
66
|
-
if (
|
|
67
|
+
if (hasCloseButton && focusableModalElements.current.length > 1) {
|
|
67
68
|
focusIndex = 1;
|
|
68
69
|
}
|
|
69
70
|
(_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 || _focusableModalElemen.focus({
|
|
70
71
|
preventScroll: true
|
|
71
72
|
});
|
|
72
|
-
}, [
|
|
73
|
+
}, [hasCloseButton]);
|
|
73
74
|
useEffect(() => {
|
|
74
75
|
var keyDown = event => {
|
|
75
76
|
var listener = keyListenersMap.get(event.code);
|
|
@@ -123,7 +124,7 @@ export var Modal = _ref => {
|
|
|
123
124
|
}, /*#__PURE__*/React.createElement("h2", {
|
|
124
125
|
className: "p-modal__title",
|
|
125
126
|
id: titleId
|
|
126
|
-
}, title),
|
|
127
|
+
}, title), hasCloseButton && /*#__PURE__*/React.createElement("button", {
|
|
127
128
|
type: "button",
|
|
128
129
|
className: "p-modal__close",
|
|
129
130
|
"aria-label": "Close active modal",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"tsc-alias": "1.8.10",
|
|
94
94
|
"typescript": "5.7.3",
|
|
95
95
|
"typescript-eslint": "8.24.1",
|
|
96
|
-
"vanilla-framework": "4.
|
|
96
|
+
"vanilla-framework": "4.33.0",
|
|
97
97
|
"wait-on": "8.0.2",
|
|
98
98
|
"webpack": "5.98.0"
|
|
99
99
|
},
|