@canonical/react-components 0.56.0 → 0.58.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/Panel/Panel.d.ts +123 -0
- package/dist/components/Panel/Panel.js +92 -0
- package/dist/components/Panel/Panel.stories.d.ts +17 -0
- package/dist/components/Panel/Panel.stories.js +60 -0
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.js +13 -0
- package/dist/components/SideNavigation/SideNavigation.d.ts +50 -0
- package/dist/components/SideNavigation/SideNavigation.js +90 -0
- package/dist/components/SideNavigation/SideNavigation.stories.d.ts +14 -0
- package/dist/components/SideNavigation/SideNavigation.stories.js +62 -0
- package/dist/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +27 -0
- package/dist/components/SideNavigation/SideNavigationBase/SideNavigationBase.js +31 -0
- package/dist/components/SideNavigation/SideNavigationBase/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationBase/index.js +13 -0
- package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +20 -0
- package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.js +33 -0
- package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.stories.d.ts +22 -0
- package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.stories.js +68 -0
- package/dist/components/SideNavigation/SideNavigationItem/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationItem/index.js +13 -0
- package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +13 -0
- package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.js +27 -0
- package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.stories.d.ts +7 -0
- package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.stories.js +32 -0
- package/dist/components/SideNavigation/SideNavigationLink/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationLink/index.js +13 -0
- package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +7 -0
- package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.js +24 -0
- package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.stories.d.ts +6 -0
- package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.stories.js +25 -0
- package/dist/components/SideNavigation/SideNavigationText/index.d.ts +1 -0
- package/dist/components/SideNavigation/SideNavigationText/index.js +13 -0
- package/dist/components/SideNavigation/index.d.ts +5 -0
- package/dist/components/SideNavigation/index.js +34 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +40 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +9 -2
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PropsWithSpread } from "../../types";
|
|
3
|
+
import type { ComponentType, ElementType, HTMLProps, PropsWithChildren, ReactNode } from "react";
|
|
4
|
+
import type { ExclusiveProps } from "../../types";
|
|
5
|
+
export type LogoDefaultElement = HTMLProps<HTMLAnchorElement>;
|
|
6
|
+
type PanelLogo<L = LogoDefaultElement> = ReactNode | PropsWithSpread<{
|
|
7
|
+
/**
|
|
8
|
+
* The url of the icon image.
|
|
9
|
+
*/
|
|
10
|
+
icon: string;
|
|
11
|
+
/**
|
|
12
|
+
* The alt text for the icon image.
|
|
13
|
+
*/
|
|
14
|
+
iconAlt?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The url of the name image.
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* The alt text for the name image.
|
|
21
|
+
*/
|
|
22
|
+
nameAlt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The element or component to use for displaying the logo e.g. `a` or `NavLink`.
|
|
25
|
+
* @default a
|
|
26
|
+
*/
|
|
27
|
+
component?: ElementType | ComponentType<L>;
|
|
28
|
+
}, L>;
|
|
29
|
+
type PanelToggle = {
|
|
30
|
+
/**
|
|
31
|
+
* The panel toggle label.
|
|
32
|
+
*/
|
|
33
|
+
label: string;
|
|
34
|
+
/**
|
|
35
|
+
* The function to call when clicking the panel toggle.
|
|
36
|
+
*/
|
|
37
|
+
onClick: () => void;
|
|
38
|
+
};
|
|
39
|
+
type LogoProps<L = LogoDefaultElement> = {
|
|
40
|
+
/**
|
|
41
|
+
* The panel logo content or attributes.
|
|
42
|
+
*/
|
|
43
|
+
logo?: PanelLogo<L>;
|
|
44
|
+
};
|
|
45
|
+
type TitleProps = {
|
|
46
|
+
/**
|
|
47
|
+
* The panel title.
|
|
48
|
+
*/
|
|
49
|
+
title: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Classes to apply to the title element.
|
|
52
|
+
*/
|
|
53
|
+
titleClassName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The element to use for the panel title e.g. `h1`.
|
|
56
|
+
* @default h4
|
|
57
|
+
*/
|
|
58
|
+
titleComponent?: ElementType;
|
|
59
|
+
/**
|
|
60
|
+
* An ID for the title element.
|
|
61
|
+
*/
|
|
62
|
+
titleId?: string;
|
|
63
|
+
};
|
|
64
|
+
type HeaderProps<L = LogoDefaultElement> = ExclusiveProps<{
|
|
65
|
+
/**
|
|
66
|
+
* This prop can be used to replace the header area of the panel when the default implementation is not sufficient.
|
|
67
|
+
*/
|
|
68
|
+
header: ReactNode;
|
|
69
|
+
}, {
|
|
70
|
+
/**
|
|
71
|
+
* Content that will be displayed in the controls area.
|
|
72
|
+
*/
|
|
73
|
+
controls?: ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* Classes that will be applied to the controls element.
|
|
76
|
+
*/
|
|
77
|
+
controlsClassName?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the header should be sticky.
|
|
80
|
+
*/
|
|
81
|
+
stickyHeader?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The panel toggle attributes.
|
|
84
|
+
*/
|
|
85
|
+
toggle?: PanelToggle;
|
|
86
|
+
} & ExclusiveProps<LogoProps<L>, TitleProps>>;
|
|
87
|
+
export type Props<L = LogoDefaultElement> = {
|
|
88
|
+
/**
|
|
89
|
+
* The panel content.
|
|
90
|
+
*/
|
|
91
|
+
children?: PropsWithChildren["children"];
|
|
92
|
+
/**
|
|
93
|
+
* Classes that are applied to the content container (when using `wrapContent`).
|
|
94
|
+
*/
|
|
95
|
+
contentClassName?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Classes that are applied to the top level panel element.
|
|
98
|
+
*/
|
|
99
|
+
className?: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* Whether to use the dark theme.
|
|
102
|
+
*/
|
|
103
|
+
dark?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the panel should wrap the content in the `p-panel__content` element.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
wrapContent?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* A ref to pass to the top level panel element.
|
|
111
|
+
*/
|
|
112
|
+
forwardRef?: React.Ref<HTMLDivElement> | null;
|
|
113
|
+
} & HeaderProps<L>;
|
|
114
|
+
/**
|
|
115
|
+
* This is a [React](https://reactjs.org/) component for panels in the
|
|
116
|
+
* [Vanilla](https://vanillaframework.io/docs/) layouts.
|
|
117
|
+
*
|
|
118
|
+
* The Panel component can be used in many areas of the application layout. It
|
|
119
|
+
* can be the child element of `AppAside`, `AppMain`, `AppNavigation`, `AppNavigationBar`
|
|
120
|
+
* and `AppStatus`.
|
|
121
|
+
*/
|
|
122
|
+
declare const Panel: <L = LogoDefaultElement>({ forwardRef, children, className, contentClassName, controlsClassName, controls, dark, header, logo, stickyHeader, title, titleClassName, titleComponent: TitleComponent, titleId, toggle, wrapContent, ...props }: Props<L>) => React.JSX.Element;
|
|
123
|
+
export default Panel;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _utils = require("../../utils");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
const generateLogo = logo => {
|
|
13
|
+
if ((0, _utils.isReactNode)(logo)) {
|
|
14
|
+
return logo;
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
icon,
|
|
18
|
+
iconAlt,
|
|
19
|
+
name,
|
|
20
|
+
nameAlt,
|
|
21
|
+
component: Component = "a",
|
|
22
|
+
...props
|
|
23
|
+
} = logo;
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(Component, _extends({
|
|
25
|
+
className: "p-panel__logo"
|
|
26
|
+
}, props), /*#__PURE__*/_react.default.createElement("img", {
|
|
27
|
+
className: "p-panel__logo-icon",
|
|
28
|
+
src: icon,
|
|
29
|
+
alt: iconAlt,
|
|
30
|
+
width: "24",
|
|
31
|
+
height: "24"
|
|
32
|
+
}), /*#__PURE__*/_react.default.createElement("img", {
|
|
33
|
+
className: "p-panel__logo-name is-fading-when-collapsed",
|
|
34
|
+
src: name,
|
|
35
|
+
alt: nameAlt,
|
|
36
|
+
height: "16"
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This is a [React](https://reactjs.org/) component for panels in the
|
|
42
|
+
* [Vanilla](https://vanillaframework.io/docs/) layouts.
|
|
43
|
+
*
|
|
44
|
+
* The Panel component can be used in many areas of the application layout. It
|
|
45
|
+
* can be the child element of `AppAside`, `AppMain`, `AppNavigation`, `AppNavigationBar`
|
|
46
|
+
* and `AppStatus`.
|
|
47
|
+
*/
|
|
48
|
+
const Panel = _ref => {
|
|
49
|
+
let {
|
|
50
|
+
forwardRef,
|
|
51
|
+
children,
|
|
52
|
+
className,
|
|
53
|
+
contentClassName,
|
|
54
|
+
controlsClassName,
|
|
55
|
+
controls,
|
|
56
|
+
dark,
|
|
57
|
+
header,
|
|
58
|
+
logo,
|
|
59
|
+
stickyHeader,
|
|
60
|
+
title,
|
|
61
|
+
titleClassName,
|
|
62
|
+
titleComponent: TitleComponent = "h4",
|
|
63
|
+
titleId,
|
|
64
|
+
toggle,
|
|
65
|
+
wrapContent = true,
|
|
66
|
+
...props
|
|
67
|
+
} = _ref;
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
|
|
69
|
+
className: (0, _classnames.default)("p-panel", className, {
|
|
70
|
+
"is-dark": dark
|
|
71
|
+
}),
|
|
72
|
+
ref: forwardRef
|
|
73
|
+
}), logo || title || controls || toggle ? /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
+
className: (0, _classnames.default)("p-panel__header", {
|
|
75
|
+
"is-sticky": stickyHeader
|
|
76
|
+
})
|
|
77
|
+
}, logo ? generateLogo(logo) : /*#__PURE__*/_react.default.createElement(TitleComponent, {
|
|
78
|
+
className: (0, _classnames.default)("p-panel__title", titleClassName),
|
|
79
|
+
id: titleId
|
|
80
|
+
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: (0, _classnames.default)("p-panel__controls", controlsClassName)
|
|
82
|
+
}, toggle ? /*#__PURE__*/_react.default.createElement("span", {
|
|
83
|
+
role: "button",
|
|
84
|
+
tabIndex: 0,
|
|
85
|
+
className: "p-panel__toggle",
|
|
86
|
+
onClick: () => toggle.onClick(),
|
|
87
|
+
onKeyDown: () => toggle.onClick()
|
|
88
|
+
}, toggle.label) : null, controls)) : header, children && wrapContent ? /*#__PURE__*/_react.default.createElement("div", {
|
|
89
|
+
className: (0, _classnames.default)("p-panel__content", contentClassName)
|
|
90
|
+
}, children) : children);
|
|
91
|
+
};
|
|
92
|
+
var _default = exports.default = Panel;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Panel from "./Panel";
|
|
3
|
+
declare const meta: Meta<typeof Panel>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Panel>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Header: Story;
|
|
8
|
+
/**
|
|
9
|
+
* The logo may be provided as attributes to use the standard logo. If this is
|
|
10
|
+
* not sufficient the a `ReactNode` can be passed to the `logo` prop instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Logo: Story;
|
|
13
|
+
/**
|
|
14
|
+
* If the default header does not meet your needs then a `ReactNode` can be
|
|
15
|
+
* passed to the `header` prop to replace the header.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CustomHeader: Story;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Logo = exports.Header = exports.Default = exports.CustomHeader = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Panel = _interopRequireDefault(require("./Panel"));
|
|
9
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
10
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const meta = {
|
|
13
|
+
component: _Panel.default,
|
|
14
|
+
tags: ["autodocs"]
|
|
15
|
+
};
|
|
16
|
+
var _default = exports.default = meta;
|
|
17
|
+
const Default = exports.Default = {
|
|
18
|
+
args: {
|
|
19
|
+
children: "Panel content",
|
|
20
|
+
title: "Panel"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const Header = exports.Header = {
|
|
24
|
+
args: {
|
|
25
|
+
controls: /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
26
|
+
appearance: "positive"
|
|
27
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
28
|
+
name: "plus",
|
|
29
|
+
light: true
|
|
30
|
+
}), " Create"),
|
|
31
|
+
title: "Panel title",
|
|
32
|
+
titleComponent: "h1"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The logo may be provided as attributes to use the standard logo. If this is
|
|
38
|
+
* not sufficient the a `ReactNode` can be passed to the `logo` prop instead.
|
|
39
|
+
*/
|
|
40
|
+
const Logo = exports.Logo = {
|
|
41
|
+
args: {
|
|
42
|
+
logo: {
|
|
43
|
+
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
|
|
44
|
+
name: "https://assets.ubuntu.com/v1/a85f7947-juju_black-text-only.svg",
|
|
45
|
+
nameAlt: "Juju"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* If the default header does not meet your needs then a `ReactNode` can be
|
|
52
|
+
* passed to the `header` prop to replace the header.
|
|
53
|
+
*/
|
|
54
|
+
const CustomHeader = exports.CustomHeader = {
|
|
55
|
+
args: {
|
|
56
|
+
header: /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
+
className: "p-panel__header"
|
|
58
|
+
}, "This header replaces the entire header area")
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as PanelProps, type LogoDefaultElement as PanelLogoDefaultElement, } from "./Panel";
|
|
@@ -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 _Panel.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Panel = _interopRequireDefault(require("./Panel"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
import type { PropsWithSpread } from "../../types";
|
|
3
|
+
import { type HTMLProps } from "react";
|
|
4
|
+
import type { SideNavigationItemProps } from "./SideNavigationItem";
|
|
5
|
+
import type { SideNavigationLinkDefaultElement, SideNavigationLinkProps } from "./SideNavigationLink";
|
|
6
|
+
export type NavItem<L = SideNavigationLinkDefaultElement> = SideNavigationItemProps<L> | ReactNode | null;
|
|
7
|
+
export type NavItemGroup<L = SideNavigationLinkDefaultElement> = NavItem<L>[];
|
|
8
|
+
export type NavGroup<L = SideNavigationLinkDefaultElement> = PropsWithSpread<{
|
|
9
|
+
/**
|
|
10
|
+
* The navigation items.
|
|
11
|
+
*/
|
|
12
|
+
items: NavItemGroup<L>;
|
|
13
|
+
}, HTMLProps<HTMLUListElement>>;
|
|
14
|
+
export type Props<L = SideNavigationLinkDefaultElement> = PropsWithSpread<{
|
|
15
|
+
/**
|
|
16
|
+
* The navigation content. This can be used instead of supplying `items`.
|
|
17
|
+
*/
|
|
18
|
+
children?: PropsWithChildren["children"];
|
|
19
|
+
/**
|
|
20
|
+
* Whether to use the dark theme.
|
|
21
|
+
*/
|
|
22
|
+
dark?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the navigation items contain icons.
|
|
25
|
+
*/
|
|
26
|
+
hasIcons?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The navigation items.
|
|
29
|
+
*/
|
|
30
|
+
items?: (NavGroup<L> | null)[];
|
|
31
|
+
/**
|
|
32
|
+
* The component or element to use for the link elements e.g. `a` or `NavLink`.
|
|
33
|
+
* @default a
|
|
34
|
+
*/
|
|
35
|
+
linkComponent?: SideNavigationLinkProps["component"];
|
|
36
|
+
/**
|
|
37
|
+
* Classes to apply to the navigation list(s).
|
|
38
|
+
*/
|
|
39
|
+
listClassName?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Classes to apply to the nav element.
|
|
42
|
+
*/
|
|
43
|
+
navClassName?: string;
|
|
44
|
+
}, HTMLProps<HTMLDivElement>>;
|
|
45
|
+
/**
|
|
46
|
+
* This is a [React](https://reactjs.org/) component for side navigation, used
|
|
47
|
+
* in the [Vanilla](https://vanillaframework.io/docs/) layouts.
|
|
48
|
+
*/
|
|
49
|
+
declare const SideNavigation: <L = SideNavigationLinkDefaultElement>({ children, className, dark, hasIcons, items, linkComponent, listClassName, navClassName, ...props }: Props<L>) => React.JSX.Element;
|
|
50
|
+
export default SideNavigation;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _SideNavigationItem = _interopRequireDefault(require("./SideNavigationItem"));
|
|
10
|
+
var _utils = require("../../utils");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
const generateItem = (item, index, linkComponent, dark) => {
|
|
14
|
+
if ((0, _utils.isReactNode)(item)) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationItem.default, {
|
|
16
|
+
key: index
|
|
17
|
+
}, item);
|
|
18
|
+
}
|
|
19
|
+
if ("nonInteractive" in item) {
|
|
20
|
+
var _item$dark;
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationItem.default, _extends({}, item, {
|
|
22
|
+
dark: (_item$dark = item.dark) !== null && _item$dark !== void 0 ? _item$dark : dark,
|
|
23
|
+
key: index
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
if ("children" in item) {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationItem.default, _extends({
|
|
28
|
+
key: index
|
|
29
|
+
}, item));
|
|
30
|
+
}
|
|
31
|
+
if ("label" in item) {
|
|
32
|
+
var _item$component, _item$dark2;
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationItem.default, _extends({
|
|
34
|
+
component: (_item$component = item.component) !== null && _item$component !== void 0 ? _item$component : linkComponent,
|
|
35
|
+
dark: (_item$dark2 = item.dark) !== null && _item$dark2 !== void 0 ? _item$dark2 : dark
|
|
36
|
+
}, item, {
|
|
37
|
+
key: index
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
const generateItems = (groups, listClassName, linkComponent, dark) => {
|
|
43
|
+
return groups === null || groups === void 0 ? void 0 : groups.filter(Boolean).map((group, g) => {
|
|
44
|
+
let items;
|
|
45
|
+
let props = {};
|
|
46
|
+
if (typeof group === "object" && "items" in group) {
|
|
47
|
+
({
|
|
48
|
+
items,
|
|
49
|
+
...props
|
|
50
|
+
} = group);
|
|
51
|
+
} else {
|
|
52
|
+
items = group;
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement("ul", _extends({}, props, {
|
|
55
|
+
className: (0, _classnames.default)("p-side-navigation__list", listClassName, "className" in group ? group.className : null),
|
|
56
|
+
key: g
|
|
57
|
+
}), items.filter(Boolean).map((item, i) => generateItem(item, i, linkComponent, dark)));
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const getHasIcons = groups => groups === null || groups === void 0 ? void 0 : groups.some(group => {
|
|
61
|
+
var _ref;
|
|
62
|
+
return (_ref = group && "items" in group ? group.items : group) === null || _ref === void 0 ? void 0 : _ref.some(item => (0, _utils.isReactNode)(item) ? false : item && "icon" in item && !!item.icon);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* This is a [React](https://reactjs.org/) component for side navigation, used
|
|
67
|
+
* in the [Vanilla](https://vanillaframework.io/docs/) layouts.
|
|
68
|
+
*/
|
|
69
|
+
const SideNavigation = _ref2 => {
|
|
70
|
+
let {
|
|
71
|
+
children,
|
|
72
|
+
className,
|
|
73
|
+
dark,
|
|
74
|
+
hasIcons,
|
|
75
|
+
items,
|
|
76
|
+
linkComponent,
|
|
77
|
+
listClassName,
|
|
78
|
+
navClassName,
|
|
79
|
+
...props
|
|
80
|
+
} = _ref2;
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
82
|
+
className: (0, _classnames.default)(className, {
|
|
83
|
+
"p-side-navigation--icons": hasIcons || getHasIcons(items),
|
|
84
|
+
"is-dark": dark
|
|
85
|
+
})
|
|
86
|
+
}, props), /*#__PURE__*/_react.default.createElement("nav", {
|
|
87
|
+
className: navClassName
|
|
88
|
+
}, children !== null && children !== void 0 ? children : generateItems(items, listClassName, linkComponent, dark)));
|
|
89
|
+
};
|
|
90
|
+
var _default = exports.default = SideNavigation;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SideNavigation from "./SideNavigation";
|
|
3
|
+
declare const meta: Meta<typeof SideNavigation>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SideNavigation>;
|
|
6
|
+
/**
|
|
7
|
+
* Menu items can be provided as links, text or custom components. To provide attributes to individual menus then each menu can be provided as a object containing an items array: `{ className: "menu-one", items: [...] }`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Default: Story;
|
|
10
|
+
/**
|
|
11
|
+
* `children` can be provided instead of `items` in cases where custom content
|
|
12
|
+
* is required.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CustomContent: Story;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Default = exports.CustomContent = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Badge = _interopRequireDefault(require("../Badge"));
|
|
9
|
+
var _SideNavigation = _interopRequireDefault(require("./SideNavigation"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const meta = {
|
|
12
|
+
component: _SideNavigation.default,
|
|
13
|
+
tags: ["autodocs"]
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = meta;
|
|
16
|
+
/**
|
|
17
|
+
* Menu items can be provided as links, text or custom components. To provide attributes to individual menus then each menu can be provided as a object containing an items array: `{ className: "menu-one", items: [...] }`.
|
|
18
|
+
*/
|
|
19
|
+
const Default = exports.Default = {
|
|
20
|
+
args: {
|
|
21
|
+
items: [{
|
|
22
|
+
className: "menu-one",
|
|
23
|
+
items: [{
|
|
24
|
+
icon: "drag",
|
|
25
|
+
label: "Models",
|
|
26
|
+
href: "/models",
|
|
27
|
+
status: /*#__PURE__*/_react.default.createElement(_Badge.default, {
|
|
28
|
+
value: 9,
|
|
29
|
+
isNegative: true
|
|
30
|
+
})
|
|
31
|
+
}, {
|
|
32
|
+
icon: "menu",
|
|
33
|
+
label: "Controllers",
|
|
34
|
+
nonInteractive: true
|
|
35
|
+
}, {
|
|
36
|
+
icon: "user",
|
|
37
|
+
label: "Permissions",
|
|
38
|
+
href: "/users"
|
|
39
|
+
}]
|
|
40
|
+
}, {
|
|
41
|
+
className: "menu-two",
|
|
42
|
+
items: [{
|
|
43
|
+
icon: "information",
|
|
44
|
+
label: "Docs",
|
|
45
|
+
href: "/docs"
|
|
46
|
+
}, {
|
|
47
|
+
label: "Logout",
|
|
48
|
+
href: "/logout"
|
|
49
|
+
}]
|
|
50
|
+
}]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `children` can be provided instead of `items` in cases where custom content
|
|
56
|
+
* is required.
|
|
57
|
+
*/
|
|
58
|
+
const CustomContent = exports.CustomContent = {
|
|
59
|
+
args: {
|
|
60
|
+
children: /*#__PURE__*/_react.default.createElement("div", null, "Custom menu content.")
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PropsWithSpread } from "../../../types";
|
|
3
|
+
import type { ComponentType, ElementType, ReactNode } from "react";
|
|
4
|
+
export type Props<C> = PropsWithSpread<{
|
|
5
|
+
/**
|
|
6
|
+
* The component or element to use for the element e.g. `span` or `NavLink`.
|
|
7
|
+
*/
|
|
8
|
+
component: ElementType | ComponentType<C>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to use the dark theme.
|
|
11
|
+
*/
|
|
12
|
+
dark?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The navigation item's icon.
|
|
15
|
+
*/
|
|
16
|
+
icon?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The navigation item's label.
|
|
19
|
+
*/
|
|
20
|
+
label: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The navigation item's status.
|
|
23
|
+
*/
|
|
24
|
+
status?: ReactNode;
|
|
25
|
+
}, C>;
|
|
26
|
+
declare const SideNavigationBase: <C>({ component: Component, dark, icon, label, status, ...props }: Props<C>) => React.JSX.Element;
|
|
27
|
+
export default SideNavigationBase;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const SideNavigationBase = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
component: Component,
|
|
13
|
+
dark,
|
|
14
|
+
icon,
|
|
15
|
+
label,
|
|
16
|
+
status,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(Component, props, icon ? /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
20
|
+
name: icon,
|
|
21
|
+
light: dark,
|
|
22
|
+
className: "p-side-navigation__icon"
|
|
23
|
+
}) : null, /*#__PURE__*/_react.default.createElement("span", {
|
|
24
|
+
className: "p-side-navigation__label"
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
26
|
+
className: "p-side-navigation__label"
|
|
27
|
+
}, label)), status ? /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
className: "p-side-navigation__status"
|
|
29
|
+
}, status) : null);
|
|
30
|
+
};
|
|
31
|
+
var _default = exports.default = SideNavigationBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as SideNavigationBaseProps, } from "./SideNavigationBase";
|
|
@@ -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 _SideNavigationBase.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SideNavigationBase = _interopRequireDefault(require("./SideNavigationBase"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HTMLProps, PropsWithChildren } from "react";
|
|
3
|
+
import type { SideNavigationLinkProps } from "../SideNavigationLink";
|
|
4
|
+
import type { SideNavigationLinkDefaultElement } from "../SideNavigationLink";
|
|
5
|
+
import { SideNavigationTextProps } from "../SideNavigationText";
|
|
6
|
+
type ItemProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The item content.
|
|
9
|
+
*/
|
|
10
|
+
children: NonNullable<PropsWithChildren["children"]>;
|
|
11
|
+
} & HTMLProps<HTMLLIElement>;
|
|
12
|
+
type ContentProps<L = SideNavigationLinkDefaultElement> = SideNavigationLinkProps<L> | (SideNavigationTextProps & {
|
|
13
|
+
/**
|
|
14
|
+
* Whether this should be a content-only item.
|
|
15
|
+
*/
|
|
16
|
+
nonInteractive: true;
|
|
17
|
+
});
|
|
18
|
+
export type Props<L = SideNavigationLinkDefaultElement> = ItemProps | ContentProps<L>;
|
|
19
|
+
declare const SideNavigationItem: <L = SideNavigationLinkDefaultElement>(props: Props<L>) => React.JSX.Element;
|
|
20
|
+
export default SideNavigationItem;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _SideNavigationLink = _interopRequireDefault(require("../SideNavigationLink"));
|
|
9
|
+
var _SideNavigationText = _interopRequireDefault(require("../SideNavigationText"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
const SideNavigationItem = props => {
|
|
13
|
+
let content;
|
|
14
|
+
let liProps = {};
|
|
15
|
+
if ("nonInteractive" in props) {
|
|
16
|
+
const {
|
|
17
|
+
nonInteractive: _,
|
|
18
|
+
...textProps
|
|
19
|
+
} = props;
|
|
20
|
+
content = /*#__PURE__*/_react.default.createElement(_SideNavigationText.default, textProps);
|
|
21
|
+
} else if (!("children" in props)) {
|
|
22
|
+
content = /*#__PURE__*/_react.default.createElement(_SideNavigationLink.default, props);
|
|
23
|
+
} else {
|
|
24
|
+
({
|
|
25
|
+
children: content,
|
|
26
|
+
...liProps
|
|
27
|
+
} = props);
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement("li", _extends({
|
|
30
|
+
className: "p-side-navigation__item"
|
|
31
|
+
}, liProps), content);
|
|
32
|
+
};
|
|
33
|
+
var _default = exports.default = SideNavigationItem;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SideNavigationItem from "./SideNavigationItem";
|
|
3
|
+
declare const meta: Meta<typeof SideNavigationItem>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SideNavigationItem>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
/**
|
|
8
|
+
* The navigation item can appear as a link and accept the props from [`SideNavigationLink`](/docs/components-sidenavigation-sidenavigationlink--docs).
|
|
9
|
+
*/
|
|
10
|
+
export declare const Links: Story;
|
|
11
|
+
/**
|
|
12
|
+
* By providing the `nonInteractive` prop the navigation item will appear as a
|
|
13
|
+
* text entry and accept the props from
|
|
14
|
+
* [`SideNavigationText`](/docs/components-sidenavigation-sidenavigationtext--docs).
|
|
15
|
+
*/
|
|
16
|
+
export declare const Text: Story;
|
|
17
|
+
/**
|
|
18
|
+
* The navigation item can display custom content by providing the `children` prop.
|
|
19
|
+
* In this case, any other attributes provided to the object will be given to
|
|
20
|
+
* the list item.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CustomContent: Story;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Text = exports.Links = exports.Default = exports.CustomContent = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _SideNavigation = _interopRequireDefault(require("../SideNavigation"));
|
|
9
|
+
var _SideNavigationItem = _interopRequireDefault(require("./SideNavigationItem"));
|
|
10
|
+
var _SideNavigationText = _interopRequireDefault(require("../SideNavigationText"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
const meta = {
|
|
14
|
+
component: _SideNavigationItem.default,
|
|
15
|
+
render: args => /*#__PURE__*/_react.default.createElement(_SideNavigation.default, {
|
|
16
|
+
dark: false,
|
|
17
|
+
items: [{
|
|
18
|
+
items: [/*#__PURE__*/_react.default.createElement(_SideNavigationItem.default, _extends({}, args, {
|
|
19
|
+
dark: false
|
|
20
|
+
}))]
|
|
21
|
+
}]
|
|
22
|
+
}),
|
|
23
|
+
tags: ["autodocs"]
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = meta;
|
|
26
|
+
const Default = exports.Default = {
|
|
27
|
+
args: {
|
|
28
|
+
icon: "drag",
|
|
29
|
+
label: "Models",
|
|
30
|
+
href: "/models"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The navigation item can appear as a link and accept the props from [`SideNavigationLink`](/docs/components-sidenavigation-sidenavigationlink--docs).
|
|
36
|
+
*/
|
|
37
|
+
const Links = exports.Links = {
|
|
38
|
+
args: {
|
|
39
|
+
icon: "drag",
|
|
40
|
+
label: "Models",
|
|
41
|
+
href: "/models"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* By providing the `nonInteractive` prop the navigation item will appear as a
|
|
47
|
+
* text entry and accept the props from
|
|
48
|
+
* [`SideNavigationText`](/docs/components-sidenavigation-sidenavigationtext--docs).
|
|
49
|
+
*/
|
|
50
|
+
const Text = exports.Text = {
|
|
51
|
+
args: {
|
|
52
|
+
icon: "drag",
|
|
53
|
+
label: "Models",
|
|
54
|
+
nonInteractive: true
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The navigation item can display custom content by providing the `children` prop.
|
|
60
|
+
* In this case, any other attributes provided to the object will be given to
|
|
61
|
+
* the list item.
|
|
62
|
+
*/
|
|
63
|
+
const CustomContent = exports.CustomContent = {
|
|
64
|
+
args: {
|
|
65
|
+
className: "custom-class",
|
|
66
|
+
children: /*#__PURE__*/_react.default.createElement(_SideNavigationText.default, null, "This item has been given a custom class")
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as SideNavigationItemProps, } from "./SideNavigationItem";
|
|
@@ -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 _SideNavigationItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SideNavigationItem = _interopRequireDefault(require("./SideNavigationItem"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HTMLProps } from "react";
|
|
3
|
+
import type { SideNavigationBaseProps } from "../SideNavigationBase";
|
|
4
|
+
export type LinkDefaultElement = HTMLProps<HTMLAnchorElement>;
|
|
5
|
+
export type Props<L = LinkDefaultElement> = Omit<SideNavigationBaseProps<L>, "component"> & {
|
|
6
|
+
/**
|
|
7
|
+
* The component or element to use for the link element e.g. `a` or `NavLink`.
|
|
8
|
+
* @default a
|
|
9
|
+
*/
|
|
10
|
+
component?: SideNavigationBaseProps<L>["component"];
|
|
11
|
+
};
|
|
12
|
+
declare const SideNavigationLink: <L = LinkDefaultElement>({ component, ...props }: Props<L>) => React.JSX.Element;
|
|
13
|
+
export default SideNavigationLink;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _SideNavigationBase = _interopRequireDefault(require("../SideNavigationBase"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
const SideNavigationLink = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
component,
|
|
15
|
+
...props
|
|
16
|
+
} = _ref;
|
|
17
|
+
let className = null;
|
|
18
|
+
if ("className" in props && typeof props.className === "string") {
|
|
19
|
+
className = props.className;
|
|
20
|
+
delete props.className;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationBase.default, _extends({
|
|
23
|
+
className: (0, _classnames.default)("p-side-navigation__link", className),
|
|
24
|
+
component: component !== null && component !== void 0 ? component : "a"
|
|
25
|
+
}, props));
|
|
26
|
+
};
|
|
27
|
+
var _default = exports.default = SideNavigationLink;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SideNavigationLink from "./SideNavigationLink";
|
|
3
|
+
declare const meta: Meta<typeof SideNavigationLink>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SideNavigationLink>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const CustomComponent: Story;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Default = exports.CustomComponent = void 0;
|
|
7
|
+
var _Badge = _interopRequireDefault(require("../../Badge"));
|
|
8
|
+
var _SideNavigationLink = _interopRequireDefault(require("./SideNavigationLink"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const meta = {
|
|
12
|
+
component: _SideNavigationLink.default,
|
|
13
|
+
tags: ["autodocs"]
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = meta;
|
|
16
|
+
const Default = exports.Default = {
|
|
17
|
+
args: {
|
|
18
|
+
icon: "drag",
|
|
19
|
+
label: "Models",
|
|
20
|
+
status: /*#__PURE__*/_react.default.createElement(_Badge.default, {
|
|
21
|
+
value: 9,
|
|
22
|
+
isNegative: true
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const CustomComponent = exports.CustomComponent = {
|
|
27
|
+
args: {
|
|
28
|
+
component: props => /*#__PURE__*/_react.default.createElement("button", props),
|
|
29
|
+
icon: "drag",
|
|
30
|
+
label: "Models"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type LinkDefaultElement as SideNavigationLinkDefaultElement, type Props as SideNavigationLinkProps, } from "./SideNavigationLink";
|
|
@@ -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 _SideNavigationLink.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SideNavigationLink = _interopRequireDefault(require("./SideNavigationLink"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HTMLProps } from "react";
|
|
3
|
+
import type { SideNavigationBaseProps } from "../SideNavigationBase";
|
|
4
|
+
export type TextDefaultElement = HTMLProps<HTMLSpanElement>;
|
|
5
|
+
export type Props = Omit<SideNavigationBaseProps<TextDefaultElement>, "component" | "label">;
|
|
6
|
+
declare const SideNavigationText: ({ children, className, ...props }: Props) => React.JSX.Element;
|
|
7
|
+
export default SideNavigationText;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _SideNavigationBase = _interopRequireDefault(require("../SideNavigationBase"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
const SideNavigationText = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
} = _ref;
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_SideNavigationBase.default, _extends({
|
|
19
|
+
className: (0, _classnames.default)("p-side-navigation__text", className),
|
|
20
|
+
component: "span",
|
|
21
|
+
label: children
|
|
22
|
+
}, props));
|
|
23
|
+
};
|
|
24
|
+
var _default = exports.default = SideNavigationText;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import SideNavigationText from "./SideNavigationText";
|
|
3
|
+
declare const meta: Meta<typeof SideNavigationText>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SideNavigationText>;
|
|
6
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Badge = _interopRequireDefault(require("../../Badge"));
|
|
9
|
+
var _SideNavigationText = _interopRequireDefault(require("./SideNavigationText"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const meta = {
|
|
12
|
+
component: _SideNavigationText.default,
|
|
13
|
+
tags: ["autodocs"]
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = meta;
|
|
16
|
+
const Default = exports.Default = {
|
|
17
|
+
args: {
|
|
18
|
+
icon: "drag",
|
|
19
|
+
children: "Models",
|
|
20
|
+
status: /*#__PURE__*/_react.default.createElement(_Badge.default, {
|
|
21
|
+
value: 9,
|
|
22
|
+
isNegative: true
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, type Props as SideNavigationTextProps, } from "./SideNavigationText";
|
|
@@ -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 _SideNavigationText.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SideNavigationText = _interopRequireDefault(require("./SideNavigationText"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default } from "./SideNavigation";
|
|
2
|
+
export type { Props as SideNavigationProps } from "./SideNavigation";
|
|
3
|
+
export { default as SideNavigationItem } from "./SideNavigationItem";
|
|
4
|
+
export { default as SideNavigationText } from "./SideNavigationText";
|
|
5
|
+
export { default as SideNavigationLink, type SideNavigationLinkDefaultElement, } from "./SideNavigationLink";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "SideNavigationItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _SideNavigationItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SideNavigationLink", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _SideNavigationLink.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SideNavigationText", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _SideNavigationText.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "default", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _SideNavigation.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _SideNavigation = _interopRequireDefault(require("./SideNavigation"));
|
|
31
|
+
var _SideNavigationItem = _interopRequireDefault(require("./SideNavigationItem"));
|
|
32
|
+
var _SideNavigationText = _interopRequireDefault(require("./SideNavigationText"));
|
|
33
|
+
var _SideNavigationLink = _interopRequireDefault(require("./SideNavigationLink"));
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/index.d.ts
CHANGED
|
@@ -31,12 +31,17 @@ export { default as Notification, NotificationSeverity, } from "./components/Not
|
|
|
31
31
|
export { NotificationConsumer, NotificationProvider, useNotify, info, success, failure, queue, } from "./components/NotificationProvider";
|
|
32
32
|
export { default as LoginPageLayout } from "./components/LoginPageLayout";
|
|
33
33
|
export { default as Pagination } from "./components/Pagination";
|
|
34
|
+
export { default as Panel } from "./components/Panel";
|
|
34
35
|
export { default as PasswordToggle } from "./components/PasswordToggle";
|
|
35
36
|
export { default as RadioInput } from "./components/RadioInput";
|
|
36
37
|
export { default as Row } from "./components/Row";
|
|
37
38
|
export { default as SearchAndFilter } from "./components/SearchAndFilter";
|
|
38
39
|
export { default as SearchBox } from "./components/SearchBox";
|
|
39
40
|
export { default as Select } from "./components/Select";
|
|
41
|
+
export { default as SideNavigation } from "./components/SideNavigation";
|
|
42
|
+
export { default as SideNavigationItem } from "./components/SideNavigation/SideNavigationItem";
|
|
43
|
+
export { default as SideNavigationLink } from "./components/SideNavigation/SideNavigationLink";
|
|
44
|
+
export { default as SideNavigationText } from "./components/SideNavigation/SideNavigationText";
|
|
40
45
|
export { default as Slider } from "./components/Slider";
|
|
41
46
|
export { default as Switch } from "./components/Switch";
|
|
42
47
|
export { default as Spinner } from "./components/Spinner";
|
|
@@ -82,11 +87,16 @@ export type { NotificationProps } from "./components/Notification";
|
|
|
82
87
|
export type { NotificationAction, NotificationType, QueuedNotification, NotificationHelper, } from "./components/NotificationProvider";
|
|
83
88
|
export type { LoginPageLayoutProps } from "./components/LoginPageLayout";
|
|
84
89
|
export type { PaginationProps } from "./components/Pagination";
|
|
90
|
+
export type { PanelProps } from "./components/Panel";
|
|
85
91
|
export type { RadioInputProps } from "./components/RadioInput";
|
|
86
92
|
export type { RowProps } from "./components/Row";
|
|
87
93
|
export type { SearchAndFilterProps } from "./components/SearchAndFilter";
|
|
88
94
|
export type { SearchBoxProps } from "./components/SearchBox";
|
|
89
95
|
export type { SelectProps } from "./components/Select";
|
|
96
|
+
export type { SideNavigationProps } from "./components/SideNavigation";
|
|
97
|
+
export type { SideNavigationItemProps } from "./components/SideNavigation/SideNavigationItem";
|
|
98
|
+
export type { SideNavigationLinkProps } from "./components/SideNavigation/SideNavigationLink";
|
|
99
|
+
export type { SideNavigationTextProps } from "./components/SideNavigation/SideNavigationText";
|
|
90
100
|
export type { SliderProps } from "./components/Slider";
|
|
91
101
|
export type { SpinnerProps } from "./components/Spinner";
|
|
92
102
|
export type { StatusLabelProps } from "./components/StatusLabel";
|
package/dist/index.js
CHANGED
|
@@ -46,12 +46,17 @@ var _exportNames = {
|
|
|
46
46
|
queue: true,
|
|
47
47
|
LoginPageLayout: true,
|
|
48
48
|
Pagination: true,
|
|
49
|
+
Panel: true,
|
|
49
50
|
PasswordToggle: true,
|
|
50
51
|
RadioInput: true,
|
|
51
52
|
Row: true,
|
|
52
53
|
SearchAndFilter: true,
|
|
53
54
|
SearchBox: true,
|
|
54
55
|
Select: true,
|
|
56
|
+
SideNavigation: true,
|
|
57
|
+
SideNavigationItem: true,
|
|
58
|
+
SideNavigationLink: true,
|
|
59
|
+
SideNavigationText: true,
|
|
55
60
|
Slider: true,
|
|
56
61
|
Switch: true,
|
|
57
62
|
Spinner: true,
|
|
@@ -302,6 +307,12 @@ Object.defineProperty(exports, "Pagination", {
|
|
|
302
307
|
return _Pagination.default;
|
|
303
308
|
}
|
|
304
309
|
});
|
|
310
|
+
Object.defineProperty(exports, "Panel", {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
get: function () {
|
|
313
|
+
return _Panel.default;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
305
316
|
Object.defineProperty(exports, "PasswordToggle", {
|
|
306
317
|
enumerable: true,
|
|
307
318
|
get: function () {
|
|
@@ -338,6 +349,30 @@ Object.defineProperty(exports, "Select", {
|
|
|
338
349
|
return _Select.default;
|
|
339
350
|
}
|
|
340
351
|
});
|
|
352
|
+
Object.defineProperty(exports, "SideNavigation", {
|
|
353
|
+
enumerable: true,
|
|
354
|
+
get: function () {
|
|
355
|
+
return _SideNavigation.default;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
Object.defineProperty(exports, "SideNavigationItem", {
|
|
359
|
+
enumerable: true,
|
|
360
|
+
get: function () {
|
|
361
|
+
return _SideNavigationItem.default;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
Object.defineProperty(exports, "SideNavigationLink", {
|
|
365
|
+
enumerable: true,
|
|
366
|
+
get: function () {
|
|
367
|
+
return _SideNavigationLink.default;
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
Object.defineProperty(exports, "SideNavigationText", {
|
|
371
|
+
enumerable: true,
|
|
372
|
+
get: function () {
|
|
373
|
+
return _SideNavigationText.default;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
341
376
|
Object.defineProperty(exports, "Slider", {
|
|
342
377
|
enumerable: true,
|
|
343
378
|
get: function () {
|
|
@@ -574,12 +609,17 @@ var _Notification = _interopRequireWildcard(require("./components/Notification")
|
|
|
574
609
|
var _NotificationProvider = require("./components/NotificationProvider");
|
|
575
610
|
var _LoginPageLayout = _interopRequireDefault(require("./components/LoginPageLayout"));
|
|
576
611
|
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
|
612
|
+
var _Panel = _interopRequireDefault(require("./components/Panel"));
|
|
577
613
|
var _PasswordToggle = _interopRequireDefault(require("./components/PasswordToggle"));
|
|
578
614
|
var _RadioInput = _interopRequireDefault(require("./components/RadioInput"));
|
|
579
615
|
var _Row = _interopRequireDefault(require("./components/Row"));
|
|
580
616
|
var _SearchAndFilter = _interopRequireDefault(require("./components/SearchAndFilter"));
|
|
581
617
|
var _SearchBox = _interopRequireDefault(require("./components/SearchBox"));
|
|
582
618
|
var _Select = _interopRequireDefault(require("./components/Select"));
|
|
619
|
+
var _SideNavigation = _interopRequireDefault(require("./components/SideNavigation"));
|
|
620
|
+
var _SideNavigationItem = _interopRequireDefault(require("./components/SideNavigation/SideNavigationItem"));
|
|
621
|
+
var _SideNavigationLink = _interopRequireDefault(require("./components/SideNavigation/SideNavigationLink"));
|
|
622
|
+
var _SideNavigationText = _interopRequireDefault(require("./components/SideNavigation/SideNavigationText"));
|
|
583
623
|
var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
584
624
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
585
625
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|
package/dist/types/index.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NavLink, NavLinkAnchor, NavLinkButton } from "./components/Navigation";
|
|
2
|
+
import { ReactNode } from "react";
|
|
2
3
|
export declare const IS_DEV: boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Find substring and wrap in <strong /> tag
|
|
@@ -20,3 +21,7 @@ export declare const isNavigationAnchor: (link: NavLink) => link is NavLinkAncho
|
|
|
20
21
|
* @param link - The navigation item.
|
|
21
22
|
*/
|
|
22
23
|
export declare const isNavigationButton: (link: NavLink) => link is NavLinkButton;
|
|
24
|
+
/**
|
|
25
|
+
* A typeguard for whether an element is a ReactNode.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isReactNode: (element: unknown) => element is ReactNode;
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isNavigationButton = exports.isNavigationAnchor = exports.highlightSubString = exports.IS_DEV = void 0;
|
|
6
|
+
exports.isReactNode = exports.isNavigationButton = exports.isNavigationAnchor = exports.highlightSubString = exports.IS_DEV = void 0;
|
|
7
|
+
var _react = require("react");
|
|
7
8
|
const IS_DEV = exports.IS_DEV = process.env.NODE_ENV === "development";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -40,4 +41,10 @@ const isNavigationAnchor = link => !!link.url;
|
|
|
40
41
|
*/
|
|
41
42
|
exports.isNavigationAnchor = isNavigationAnchor;
|
|
42
43
|
const isNavigationButton = link => !link.url;
|
|
43
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A typeguard for whether an element is a ReactNode.
|
|
47
|
+
*/
|
|
48
|
+
exports.isNavigationButton = isNavigationButton;
|
|
49
|
+
const isReactNode = element => /*#__PURE__*/(0, _react.isValidElement)(element);
|
|
50
|
+
exports.isReactNode = isReactNode;
|