@canonical/react-components 0.57.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/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 +8 -0
- package/dist/index.js +32 -0
- package/package.json +1 -1
|
@@ -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
|
@@ -38,6 +38,10 @@ export { default as Row } from "./components/Row";
|
|
|
38
38
|
export { default as SearchAndFilter } from "./components/SearchAndFilter";
|
|
39
39
|
export { default as SearchBox } from "./components/SearchBox";
|
|
40
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";
|
|
41
45
|
export { default as Slider } from "./components/Slider";
|
|
42
46
|
export { default as Switch } from "./components/Switch";
|
|
43
47
|
export { default as Spinner } from "./components/Spinner";
|
|
@@ -89,6 +93,10 @@ export type { RowProps } from "./components/Row";
|
|
|
89
93
|
export type { SearchAndFilterProps } from "./components/SearchAndFilter";
|
|
90
94
|
export type { SearchBoxProps } from "./components/SearchBox";
|
|
91
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";
|
|
92
100
|
export type { SliderProps } from "./components/Slider";
|
|
93
101
|
export type { SpinnerProps } from "./components/Spinner";
|
|
94
102
|
export type { StatusLabelProps } from "./components/StatusLabel";
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,10 @@ var _exportNames = {
|
|
|
53
53
|
SearchAndFilter: true,
|
|
54
54
|
SearchBox: true,
|
|
55
55
|
Select: true,
|
|
56
|
+
SideNavigation: true,
|
|
57
|
+
SideNavigationItem: true,
|
|
58
|
+
SideNavigationLink: true,
|
|
59
|
+
SideNavigationText: true,
|
|
56
60
|
Slider: true,
|
|
57
61
|
Switch: true,
|
|
58
62
|
Spinner: true,
|
|
@@ -345,6 +349,30 @@ Object.defineProperty(exports, "Select", {
|
|
|
345
349
|
return _Select.default;
|
|
346
350
|
}
|
|
347
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
|
+
});
|
|
348
376
|
Object.defineProperty(exports, "Slider", {
|
|
349
377
|
enumerable: true,
|
|
350
378
|
get: function () {
|
|
@@ -588,6 +616,10 @@ var _Row = _interopRequireDefault(require("./components/Row"));
|
|
|
588
616
|
var _SearchAndFilter = _interopRequireDefault(require("./components/SearchAndFilter"));
|
|
589
617
|
var _SearchBox = _interopRequireDefault(require("./components/SearchBox"));
|
|
590
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"));
|
|
591
623
|
var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
592
624
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
593
625
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|