@canonical/react-components 1.3.2 → 1.4.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/ApplicationLayout/ApplicationLayout.d.ts +5 -1
- package/dist/components/ApplicationLayout/ApplicationLayout.js +6 -1
- package/dist/components/SkipLink/SkipLink.d.ts +12 -0
- package/dist/components/SkipLink/SkipLink.js +26 -0
- package/dist/components/SkipLink/index.d.ts +2 -0
- package/dist/components/SkipLink/index.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/package.json +1 -1
|
@@ -68,6 +68,10 @@ export type BaseProps<NI = SideNavigationLinkDefaultElement, PL = PanelLogoDefau
|
|
|
68
68
|
* Classes to apply to the status area.
|
|
69
69
|
*/
|
|
70
70
|
statusClassName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Id to apply to the main area. Used for the "Skip to main content" link.
|
|
73
|
+
*/
|
|
74
|
+
mainId?: string;
|
|
71
75
|
}, HTMLProps<HTMLDivElement>>;
|
|
72
76
|
export type Props<NI = SideNavigationLinkDefaultElement, PL = PanelLogoDefaultElement> = BaseProps<NI, PL> & ExclusiveProps<{
|
|
73
77
|
navItems?: SideNavigationProps<NI>["items"];
|
|
@@ -85,5 +89,5 @@ export type Props<NI = SideNavigationLinkDefaultElement, PL = PanelLogoDefaultEl
|
|
|
85
89
|
* specific structure and states to function correctly so there will be a
|
|
86
90
|
* trade-off when using the sub-components directly.
|
|
87
91
|
*/
|
|
88
|
-
declare const ApplicationLayout: <NI = SideNavigationLinkDefaultElement, PL = PanelLogoDefaultElement>({ aside, children, dark, logo, mainClassName, menuCollapsed, menuPinned, navigationBarClassName, navigationClassName, navItems, navLinkComponent, onCollapseMenu, onPinMenu, sideNavigation, status, statusClassName, ...props }: Props<NI, PL>) => React.JSX.Element;
|
|
92
|
+
declare const ApplicationLayout: <NI = SideNavigationLinkDefaultElement, PL = PanelLogoDefaultElement>({ aside, children, dark, logo, mainClassName, menuCollapsed, menuPinned, navigationBarClassName, navigationClassName, navItems, navLinkComponent, onCollapseMenu, onPinMenu, sideNavigation, status, statusClassName, mainId, ...props }: Props<NI, PL>) => React.JSX.Element;
|
|
89
93
|
export default ApplicationLayout;
|
|
@@ -15,6 +15,7 @@ var _AppStatus = _interopRequireDefault(require("./AppStatus"));
|
|
|
15
15
|
var _Application = _interopRequireDefault(require("./Application"));
|
|
16
16
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
17
17
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
18
|
+
var _SkipLink = _interopRequireDefault(require("../SkipLink"));
|
|
18
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
20
|
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); }
|
|
20
21
|
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 && {}.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; }
|
|
@@ -47,6 +48,7 @@ const ApplicationLayout = _ref => {
|
|
|
47
48
|
sideNavigation,
|
|
48
49
|
status,
|
|
49
50
|
statusClassName,
|
|
51
|
+
mainId = "main-content",
|
|
50
52
|
...props
|
|
51
53
|
} = _ref;
|
|
52
54
|
const [internalMenuPinned, setInternalMenuPinned] = (0, _react.useState)(false);
|
|
@@ -55,7 +57,9 @@ const ApplicationLayout = _ref => {
|
|
|
55
57
|
const setMenuPinned = onPinMenu !== null && onPinMenu !== void 0 ? onPinMenu : setInternalMenuPinned;
|
|
56
58
|
const menuIsCollapsed = menuCollapsed !== null && menuCollapsed !== void 0 ? menuCollapsed : internalMenuCollapsed;
|
|
57
59
|
const setMenuCollapsed = onCollapseMenu !== null && onCollapseMenu !== void 0 ? onCollapseMenu : setInternalMenuCollapsed;
|
|
58
|
-
return /*#__PURE__*/_react.default.createElement(_Application.default, props,
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_Application.default, props, /*#__PURE__*/_react.default.createElement(_SkipLink.default, {
|
|
61
|
+
mainId: mainId
|
|
62
|
+
}), (navItems || sideNavigation) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_AppNavigationBar.default, {
|
|
59
63
|
className: navigationBarClassName
|
|
60
64
|
}, /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
61
65
|
dark: dark,
|
|
@@ -110,6 +114,7 @@ const ApplicationLayout = _ref => {
|
|
|
110
114
|
items: navItems,
|
|
111
115
|
linkComponent: navLinkComponent
|
|
112
116
|
}) : sideNavigation))), /*#__PURE__*/_react.default.createElement(_AppMain.default, {
|
|
117
|
+
id: mainId,
|
|
113
118
|
className: mainClassName
|
|
114
119
|
}, children), aside, status && /*#__PURE__*/_react.default.createElement(_AppStatus.default, {
|
|
115
120
|
className: statusClassName
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLProps } from "react";
|
|
2
|
+
export type Props = {
|
|
3
|
+
/**
|
|
4
|
+
* Id of the main content area to skip to.
|
|
5
|
+
*/
|
|
6
|
+
mainId?: string;
|
|
7
|
+
} & HTMLProps<HTMLAnchorElement>;
|
|
8
|
+
/**
|
|
9
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Skip link](https://vanillaframework.io/docs/patterns/links#skip-link) component.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SkipLink: ({ mainId }: Props) => JSX.Element;
|
|
12
|
+
export default SkipLink;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SkipLink = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/**
|
|
11
|
+
* This is a [React](https://reactjs.org/) component for the Vanilla [Skip link](https://vanillaframework.io/docs/patterns/links#skip-link) component.
|
|
12
|
+
*/
|
|
13
|
+
const SkipLink = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
mainId = "main-content"
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
18
|
+
className: "p-link--skip",
|
|
19
|
+
href: "#".concat(mainId)
|
|
20
|
+
}, "Skip to main content");
|
|
21
|
+
};
|
|
22
|
+
exports.SkipLink = SkipLink;
|
|
23
|
+
SkipLink.propTypes = {
|
|
24
|
+
mainId: _propTypes.default.string
|
|
25
|
+
};
|
|
26
|
+
var _default = exports.default = SkipLink;
|
|
@@ -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 _SkipLink.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SkipLink = _interopRequireDefault(require("./SkipLink"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export { default as SideNavigation } from "./components/SideNavigation";
|
|
|
49
49
|
export { default as SideNavigationItem } from "./components/SideNavigation/SideNavigationItem";
|
|
50
50
|
export { default as SideNavigationLink } from "./components/SideNavigation/SideNavigationLink";
|
|
51
51
|
export { default as SideNavigationText } from "./components/SideNavigation/SideNavigationText";
|
|
52
|
+
export { default as SkipLink } from "./components/SkipLink";
|
|
52
53
|
export { default as Slider } from "./components/Slider";
|
|
53
54
|
export { default as Switch } from "./components/Switch";
|
|
54
55
|
export { default as Spinner } from "./components/Spinner";
|
|
@@ -112,6 +113,7 @@ export type { SideNavigationProps } from "./components/SideNavigation";
|
|
|
112
113
|
export type { SideNavigationItemProps } from "./components/SideNavigation/SideNavigationItem";
|
|
113
114
|
export type { SideNavigationLinkProps } from "./components/SideNavigation/SideNavigationLink";
|
|
114
115
|
export type { SideNavigationTextProps } from "./components/SideNavigation/SideNavigationText";
|
|
116
|
+
export type { SkipLinkProps } from "./components/SkipLink";
|
|
115
117
|
export type { SliderProps } from "./components/Slider";
|
|
116
118
|
export type { SpinnerProps } from "./components/Spinner";
|
|
117
119
|
export type { StatusLabelProps } from "./components/StatusLabel";
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ var _exportNames = {
|
|
|
64
64
|
SideNavigationItem: true,
|
|
65
65
|
SideNavigationLink: true,
|
|
66
66
|
SideNavigationText: true,
|
|
67
|
+
SkipLink: true,
|
|
67
68
|
Slider: true,
|
|
68
69
|
Switch: true,
|
|
69
70
|
Spinner: true,
|
|
@@ -423,6 +424,12 @@ Object.defineProperty(exports, "SideNavigationText", {
|
|
|
423
424
|
return _SideNavigationText.default;
|
|
424
425
|
}
|
|
425
426
|
});
|
|
427
|
+
Object.defineProperty(exports, "SkipLink", {
|
|
428
|
+
enumerable: true,
|
|
429
|
+
get: function () {
|
|
430
|
+
return _SkipLink.default;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
426
433
|
Object.defineProperty(exports, "Slider", {
|
|
427
434
|
enumerable: true,
|
|
428
435
|
get: function () {
|
|
@@ -683,6 +690,7 @@ var _SideNavigation = _interopRequireDefault(require("./components/SideNavigatio
|
|
|
683
690
|
var _SideNavigationItem = _interopRequireDefault(require("./components/SideNavigation/SideNavigationItem"));
|
|
684
691
|
var _SideNavigationLink = _interopRequireDefault(require("./components/SideNavigation/SideNavigationLink"));
|
|
685
692
|
var _SideNavigationText = _interopRequireDefault(require("./components/SideNavigation/SideNavigationText"));
|
|
693
|
+
var _SkipLink = _interopRequireDefault(require("./components/SkipLink"));
|
|
686
694
|
var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
687
695
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
688
696
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|