@canonical/react-components 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ApplicationLayout/AppAside/AppAside.d.ts +33 -0
- package/dist/components/ApplicationLayout/AppAside/AppAside.js +33 -0
- package/dist/components/ApplicationLayout/AppAside/AppAside.stories.d.ts +13 -0
- package/dist/components/ApplicationLayout/AppAside/AppAside.stories.js +116 -0
- package/dist/components/ApplicationLayout/AppAside/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppAside/index.js +13 -0
- package/dist/components/ApplicationLayout/AppMain/AppMain.d.ts +14 -0
- package/dist/components/ApplicationLayout/AppMain/AppMain.js +25 -0
- package/dist/components/ApplicationLayout/AppMain/AppMain.stories.d.ts +14 -0
- package/dist/components/ApplicationLayout/AppMain/AppMain.stories.js +45 -0
- package/dist/components/ApplicationLayout/AppMain/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppMain/index.js +13 -0
- package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +26 -0
- package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.js +35 -0
- package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.stories.d.ts +12 -0
- package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.stories.js +104 -0
- package/dist/components/ApplicationLayout/AppNavigation/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppNavigation/index.js +13 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +18 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.js +28 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.stories.d.ts +15 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.stories.js +52 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppNavigationBar/index.js +13 -0
- package/dist/components/ApplicationLayout/AppStatus/AppStatus.d.ts +14 -0
- package/dist/components/ApplicationLayout/AppStatus/AppStatus.js +25 -0
- package/dist/components/ApplicationLayout/AppStatus/AppStatus.stories.d.ts +13 -0
- package/dist/components/ApplicationLayout/AppStatus/AppStatus.stories.js +41 -0
- package/dist/components/ApplicationLayout/AppStatus/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/AppStatus/index.js +13 -0
- package/dist/components/ApplicationLayout/Application/Application.d.ts +15 -0
- package/dist/components/ApplicationLayout/Application/Application.js +26 -0
- package/dist/components/ApplicationLayout/Application/Application.stories.d.ts +6 -0
- package/dist/components/ApplicationLayout/Application/Application.stories.js +16 -0
- package/dist/components/ApplicationLayout/Application/index.d.ts +2 -0
- package/dist/components/ApplicationLayout/Application/index.js +13 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.d.ts +89 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.js +118 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.stories.d.ts +19 -0
- package/dist/components/ApplicationLayout/ApplicationLayout.stories.js +218 -0
- package/dist/components/ApplicationLayout/index.d.ts +7 -0
- package/dist/components/ApplicationLayout/index.js +55 -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 +22 -0
- package/dist/index.js +88 -0
- package/package.json +5 -2
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Navigation = exports.ExternalStates = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Form = _interopRequireDefault(require("../Form"));
|
|
9
|
+
var _Input = _interopRequireDefault(require("../Input"));
|
|
10
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
11
|
+
var _Row = _interopRequireDefault(require("../Row"));
|
|
12
|
+
var _Col = _interopRequireDefault(require("../Col"));
|
|
13
|
+
var _ApplicationLayout = _interopRequireDefault(require("./ApplicationLayout"));
|
|
14
|
+
var _AppAside = _interopRequireDefault(require("./AppAside"));
|
|
15
|
+
var _Panel = _interopRequireDefault(require("../Panel"));
|
|
16
|
+
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
17
|
+
var _SideNavigation = _interopRequireDefault(require("../SideNavigation"));
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
22
|
+
|
|
23
|
+
const meta = {
|
|
24
|
+
component: _ApplicationLayout.default,
|
|
25
|
+
tags: ["autodocs"]
|
|
26
|
+
};
|
|
27
|
+
var _default = exports.default = meta;
|
|
28
|
+
const Default = exports.Default = {
|
|
29
|
+
render: () => {
|
|
30
|
+
const [showAside, setShowAside] = (0, _react.useState)(true);
|
|
31
|
+
const [asidePinned, setAsidePinned] = (0, _react.useState)(false);
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_ApplicationLayout.default, {
|
|
33
|
+
logo: {
|
|
34
|
+
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
|
|
35
|
+
name: "https://assets.ubuntu.com/v1/2e04d794-logo-jaas.svg",
|
|
36
|
+
nameAlt: "JAAS",
|
|
37
|
+
href: "/"
|
|
38
|
+
},
|
|
39
|
+
navItems: [{
|
|
40
|
+
items: [{
|
|
41
|
+
icon: "drag",
|
|
42
|
+
label: "Models",
|
|
43
|
+
href: "/models"
|
|
44
|
+
}, {
|
|
45
|
+
icon: "menu",
|
|
46
|
+
label: "Controllers",
|
|
47
|
+
href: "/controllers"
|
|
48
|
+
}, {
|
|
49
|
+
icon: "user",
|
|
50
|
+
label: "Permissions",
|
|
51
|
+
href: "/users"
|
|
52
|
+
}]
|
|
53
|
+
}],
|
|
54
|
+
aside: showAside ? /*#__PURE__*/_react.default.createElement(_AppAside.default, {
|
|
55
|
+
title: "Aside panel",
|
|
56
|
+
pinned: asidePinned
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
58
|
+
controls: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
59
|
+
onClick: () => setAsidePinned(!asidePinned),
|
|
60
|
+
dense: true,
|
|
61
|
+
className: "u-no-margin"
|
|
62
|
+
}, "Pin aside"), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
63
|
+
appearance: "base",
|
|
64
|
+
className: "u-no-margin--bottom",
|
|
65
|
+
hasIcon: true,
|
|
66
|
+
onClick: () => {
|
|
67
|
+
setShowAside(false);
|
|
68
|
+
setAsidePinned(false);
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
71
|
+
name: "close"
|
|
72
|
+
}, "Close")))
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(_Form.default, {
|
|
74
|
+
stacked: true
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
76
|
+
label: "Full name",
|
|
77
|
+
type: "text",
|
|
78
|
+
name: "fullName",
|
|
79
|
+
autoComplete: "name",
|
|
80
|
+
stacked: true
|
|
81
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
82
|
+
label: "Username",
|
|
83
|
+
type: "text",
|
|
84
|
+
name: "username-stacked",
|
|
85
|
+
autoComplete: "username",
|
|
86
|
+
"aria-describedby": "exampleHelpTextMessage",
|
|
87
|
+
stacked: true,
|
|
88
|
+
help: "30 characters or fewer."
|
|
89
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
90
|
+
type: "text",
|
|
91
|
+
label: "Email address",
|
|
92
|
+
"aria-invalid": "true",
|
|
93
|
+
name: "username-stackederror",
|
|
94
|
+
autoComplete: "email",
|
|
95
|
+
required: true,
|
|
96
|
+
error: "This field is required.",
|
|
97
|
+
stacked: true
|
|
98
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
99
|
+
label: "Address line 1",
|
|
100
|
+
type: "text",
|
|
101
|
+
name: "address-optional-stacked",
|
|
102
|
+
autoComplete: "address-line1",
|
|
103
|
+
stacked: true
|
|
104
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
105
|
+
label: "Address line 2",
|
|
106
|
+
type: "text",
|
|
107
|
+
name: "address-optional-stacked",
|
|
108
|
+
autoComplete: "address-line3",
|
|
109
|
+
stacked: true
|
|
110
|
+
}), /*#__PURE__*/_react.default.createElement(_Row.default, null, /*#__PURE__*/_react.default.createElement(_Col.default, {
|
|
111
|
+
size: 12
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
113
|
+
appearance: "positive",
|
|
114
|
+
className: "u-float-right",
|
|
115
|
+
name: "add-details"
|
|
116
|
+
}, "Add details")))))) : null,
|
|
117
|
+
status: /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
118
|
+
onClick: () => setShowAside(!showAside),
|
|
119
|
+
dense: true,
|
|
120
|
+
appearance: "base",
|
|
121
|
+
className: "u-no-margin"
|
|
122
|
+
}, "Toggle aside")
|
|
123
|
+
}, /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
124
|
+
title: "Application Layout"
|
|
125
|
+
}, /*#__PURE__*/_react.default.createElement(_Row.default, null, /*#__PURE__*/_react.default.createElement(_Col.default, {
|
|
126
|
+
size: 12
|
|
127
|
+
}, "Content"))));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The pinned and collapsed states can be handled externally if you need access
|
|
133
|
+
* to these outside the application layout.
|
|
134
|
+
*/
|
|
135
|
+
const ExternalStates = exports.ExternalStates = {
|
|
136
|
+
render: () => {
|
|
137
|
+
const [menuPinned, setMenuPinned] = (0, _react.useState)(false);
|
|
138
|
+
const [menuCollapsed, setMenuCollapsed] = (0, _react.useState)(true);
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_ApplicationLayout.default, {
|
|
140
|
+
menuPinned: menuPinned,
|
|
141
|
+
onPinMenu: setMenuPinned,
|
|
142
|
+
menuCollapsed: menuCollapsed,
|
|
143
|
+
onCollapseMenu: setMenuCollapsed,
|
|
144
|
+
logo: {
|
|
145
|
+
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
|
|
146
|
+
name: "https://assets.ubuntu.com/v1/2e04d794-logo-jaas.svg",
|
|
147
|
+
nameAlt: "JAAS",
|
|
148
|
+
href: "/"
|
|
149
|
+
},
|
|
150
|
+
navItems: [{
|
|
151
|
+
items: [{
|
|
152
|
+
icon: "drag",
|
|
153
|
+
label: "Models",
|
|
154
|
+
href: "/models"
|
|
155
|
+
}, {
|
|
156
|
+
icon: "menu",
|
|
157
|
+
label: "Controllers",
|
|
158
|
+
href: "/controllers"
|
|
159
|
+
}, {
|
|
160
|
+
icon: "user",
|
|
161
|
+
label: "Permissions",
|
|
162
|
+
href: "/users"
|
|
163
|
+
}]
|
|
164
|
+
}]
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
166
|
+
title: "Application Layout"
|
|
167
|
+
}, /*#__PURE__*/_react.default.createElement(_Row.default, null, /*#__PURE__*/_react.default.createElement(_Col.default, {
|
|
168
|
+
size: 12
|
|
169
|
+
}, "Content"))));
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Menu items can either be provided as an array given to `navItems` or when
|
|
175
|
+
* more control is needed then by proving `sideNavigation`.
|
|
176
|
+
*
|
|
177
|
+
* For more details about how to provide navigation items see the
|
|
178
|
+
* [`SideNavigation`](/docs/components-sidenavigation--docs) docs.
|
|
179
|
+
*/
|
|
180
|
+
const Navigation = exports.Navigation = {
|
|
181
|
+
render: () => {
|
|
182
|
+
const [menuPinned, setMenuPinned] = (0, _react.useState)(false);
|
|
183
|
+
const [menuCollapsed, setMenuCollapsed] = (0, _react.useState)(true);
|
|
184
|
+
return /*#__PURE__*/_react.default.createElement(_ApplicationLayout.default, {
|
|
185
|
+
menuPinned: menuPinned,
|
|
186
|
+
onPinMenu: setMenuPinned,
|
|
187
|
+
menuCollapsed: menuCollapsed,
|
|
188
|
+
onCollapseMenu: setMenuCollapsed,
|
|
189
|
+
logo: {
|
|
190
|
+
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
|
|
191
|
+
name: "https://assets.ubuntu.com/v1/2e04d794-logo-jaas.svg",
|
|
192
|
+
nameAlt: "JAAS",
|
|
193
|
+
href: "/"
|
|
194
|
+
},
|
|
195
|
+
sideNavigation: /*#__PURE__*/_react.default.createElement(_SideNavigation.default, {
|
|
196
|
+
items: [{
|
|
197
|
+
items: [{
|
|
198
|
+
icon: "drag",
|
|
199
|
+
label: "Models",
|
|
200
|
+
href: "/models"
|
|
201
|
+
}, {
|
|
202
|
+
icon: "menu",
|
|
203
|
+
label: "Controllers",
|
|
204
|
+
href: "/controllers"
|
|
205
|
+
}, {
|
|
206
|
+
icon: "user",
|
|
207
|
+
label: "Permissions",
|
|
208
|
+
href: "/users"
|
|
209
|
+
}]
|
|
210
|
+
}]
|
|
211
|
+
})
|
|
212
|
+
}, /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
213
|
+
title: "Application Layout"
|
|
214
|
+
}, /*#__PURE__*/_react.default.createElement(_Row.default, null, /*#__PURE__*/_react.default.createElement(_Col.default, {
|
|
215
|
+
size: 12
|
|
216
|
+
}, "Content"))));
|
|
217
|
+
}
|
|
218
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default, type Props as ApplicationLayoutProps, } from "./ApplicationLayout";
|
|
2
|
+
export { default as AppAside, type AppAsideProps } from "./AppAside";
|
|
3
|
+
export { default as Application, type ApplicationProps } from "./Application";
|
|
4
|
+
export { default as AppMain, type AppMainProps } from "./AppMain";
|
|
5
|
+
export { default as AppNavigation, type AppNavigationProps, } from "./AppNavigation";
|
|
6
|
+
export { default as AppNavigationBar, type AppNavigationBarProps, } from "./AppNavigationBar";
|
|
7
|
+
export { default as AppStatus, type AppStatusProps } from "./AppStatus";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AppAside", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AppAside.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "AppMain", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _AppMain.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "AppNavigation", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _AppNavigation.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "AppNavigationBar", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _AppNavigationBar.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "AppStatus", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _AppStatus.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "Application", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _Application.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "default", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _ApplicationLayout.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _ApplicationLayout = _interopRequireDefault(require("./ApplicationLayout"));
|
|
49
|
+
var _AppAside = _interopRequireDefault(require("./AppAside"));
|
|
50
|
+
var _Application = _interopRequireDefault(require("./Application"));
|
|
51
|
+
var _AppMain = _interopRequireDefault(require("./AppMain"));
|
|
52
|
+
var _AppNavigation = _interopRequireDefault(require("./AppNavigation"));
|
|
53
|
+
var _AppNavigationBar = _interopRequireDefault(require("./AppNavigationBar"));
|
|
54
|
+
var _AppStatus = _interopRequireDefault(require("./AppStatus"));
|
|
55
|
+
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;
|