@canonical/react-ds-app 0.27.1-experimental.0 → 0.28.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/esm/lib/ApplicationLayout/ApplicationLayout.js +15 -0
- package/dist/esm/lib/ApplicationLayout/ApplicationLayout.js.map +1 -0
- package/dist/esm/lib/ApplicationLayout/index.js +3 -0
- package/dist/esm/lib/ApplicationLayout/index.js.map +1 -0
- package/dist/esm/lib/ApplicationLayout/styles.css +29 -0
- package/dist/esm/lib/ApplicationLayout/types.js +3 -0
- package/dist/esm/lib/ApplicationLayout/types.js.map +1 -0
- package/dist/esm/lib/ContentLayout/ContentLayout.js +19 -0
- package/dist/esm/lib/ContentLayout/ContentLayout.js.map +1 -0
- package/dist/esm/lib/ContentLayout/index.js +3 -0
- package/dist/esm/lib/ContentLayout/index.js.map +1 -0
- package/dist/esm/lib/ContentLayout/styles.css +13 -0
- package/dist/esm/lib/ContentLayout/types.js +3 -0
- package/dist/esm/lib/ContentLayout/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/SideNavigation.js +46 -0
- package/dist/esm/lib/SideNavigation/SideNavigation.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/CollapseToggle.js +17 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/CollapseToggle.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/index.js +3 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/styles.css +5 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Content/Content.js +16 -0
- package/dist/esm/lib/SideNavigation/common/Content/Content.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Content/index.js +3 -0
- package/dist/esm/lib/SideNavigation/common/Content/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Content/styles.css +33 -0
- package/dist/esm/lib/SideNavigation/common/Content/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Content/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js +16 -0
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Footer/index.js +3 -0
- package/dist/esm/lib/SideNavigation/common/Footer/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Footer/styles.css +6 -0
- package/dist/esm/lib/SideNavigation/common/Footer/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Footer/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Header/Header.js +16 -0
- package/dist/esm/lib/SideNavigation/common/Header/Header.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Header/index.js +3 -0
- package/dist/esm/lib/SideNavigation/common/Header/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Header/styles.css +37 -0
- package/dist/esm/lib/SideNavigation/common/Header/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Header/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Item/Item.js +29 -0
- package/dist/esm/lib/SideNavigation/common/Item/Item.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Item/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Item/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/Item/styles.css +54 -0
- package/dist/esm/lib/SideNavigation/common/Item/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/Item/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js +39 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/index.js +2 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/styles.css +31 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/types.js +2 -0
- package/dist/esm/lib/SideNavigation/common/NavTree/types.js.map +1 -0
- package/dist/esm/lib/SideNavigation/common/index.js +7 -0
- package/dist/esm/lib/SideNavigation/common/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/index.js +3 -0
- package/dist/esm/lib/SideNavigation/index.js.map +1 -0
- package/dist/esm/lib/SideNavigation/styles.css +25 -0
- package/dist/esm/lib/SideNavigation/types.js +2 -0
- package/dist/esm/lib/SideNavigation/types.js.map +1 -0
- package/dist/esm/lib/ViewLayout/ViewLayout.js +15 -0
- package/dist/esm/lib/ViewLayout/ViewLayout.js.map +1 -0
- package/dist/esm/lib/ViewLayout/index.js +3 -0
- package/dist/esm/lib/ViewLayout/index.js.map +1 -0
- package/dist/esm/lib/ViewLayout/styles.css +27 -0
- package/dist/esm/lib/ViewLayout/types.js +3 -0
- package/dist/esm/lib/ViewLayout/types.js.map +1 -0
- package/dist/esm/lib/index.js +4 -1
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts +13 -0
- package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts.map +1 -0
- package/dist/types/lib/ApplicationLayout/index.d.ts +3 -0
- package/dist/types/lib/ApplicationLayout/index.d.ts.map +1 -0
- package/dist/types/lib/ApplicationLayout/types.d.ts +12 -0
- package/dist/types/lib/ApplicationLayout/types.d.ts.map +1 -0
- package/dist/types/lib/ContentLayout/ContentLayout.d.ts +15 -0
- package/dist/types/lib/ContentLayout/ContentLayout.d.ts.map +1 -0
- package/dist/types/lib/ContentLayout/index.d.ts +3 -0
- package/dist/types/lib/ContentLayout/index.d.ts.map +1 -0
- package/dist/types/lib/ContentLayout/types.d.ts +17 -0
- package/dist/types/lib/ContentLayout/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts +18 -0
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts +14 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/types.d.ts +9 -0
- package/dist/types/lib/SideNavigation/common/CollapseToggle/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts +13 -0
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Content/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/Content/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts +14 -0
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts +13 -0
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Footer/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/Footer/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Footer/types.d.ts +14 -0
- package/dist/types/lib/SideNavigation/common/Footer/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts +13 -0
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Header/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/Header/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Header/types.d.ts +14 -0
- package/dist/types/lib/SideNavigation/common/Header/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts +21 -0
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Item/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/Item/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/Item/types.d.ts +17 -0
- package/dist/types/lib/SideNavigation/common/Item/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts +20 -0
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/NavTree/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/common/NavTree/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/NavTree/types.d.ts +11 -0
- package/dist/types/lib/SideNavigation/common/NavTree/types.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/common/index.d.ts +6 -0
- package/dist/types/lib/SideNavigation/common/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/index.d.ts +3 -0
- package/dist/types/lib/SideNavigation/index.d.ts.map +1 -0
- package/dist/types/lib/SideNavigation/types.d.ts +60 -0
- package/dist/types/lib/SideNavigation/types.d.ts.map +1 -0
- package/dist/types/lib/ViewLayout/ViewLayout.d.ts +13 -0
- package/dist/types/lib/ViewLayout/ViewLayout.d.ts.map +1 -0
- package/dist/types/lib/ViewLayout/index.d.ts +3 -0
- package/dist/types/lib/ViewLayout/index.d.ts.map +1 -0
- package/dist/types/lib/ViewLayout/types.d.ts +12 -0
- package/dist/types/lib/ViewLayout/types.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +4 -1
- package/dist/types/lib/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/esm/lib/Button/Button.js +0 -10
- package/dist/esm/lib/Button/Button.js.map +0 -1
- package/dist/esm/lib/Button/index.js +0 -2
- package/dist/esm/lib/Button/index.js.map +0 -1
- package/dist/esm/lib/Button/styles.css +0 -63
- package/dist/esm/lib/Button/types.js +0 -12
- package/dist/esm/lib/Button/types.js.map +0 -1
- package/dist/esm/ui/Button/Button.js +0 -10
- package/dist/esm/ui/Button/Button.js.map +0 -1
- package/dist/esm/ui/Button/index.js +0 -2
- package/dist/esm/ui/Button/index.js.map +0 -1
- package/dist/esm/ui/Button/styles.css +0 -63
- package/dist/esm/ui/Button/types.js +0 -12
- package/dist/esm/ui/Button/types.js.map +0 -1
- package/dist/esm/ui/index.js +0 -2
- package/dist/esm/ui/index.js.map +0 -1
- package/dist/types/lib/Button/Button.d.ts +0 -6
- package/dist/types/lib/Button/Button.d.ts.map +0 -1
- package/dist/types/lib/Button/index.d.ts +0 -3
- package/dist/types/lib/Button/index.d.ts.map +0 -1
- package/dist/types/lib/Button/types.d.ts +0 -18
- package/dist/types/lib/Button/types.d.ts.map +0 -1
- package/dist/types/ui/Button/Button.d.ts +0 -6
- package/dist/types/ui/Button/Button.d.ts.map +0 -1
- package/dist/types/ui/Button/index.d.ts +0 -3
- package/dist/types/ui/Button/index.d.ts.map +0 -1
- package/dist/types/ui/Button/types.d.ts +0 -18
- package/dist/types/ui/Button/types.d.ts.map +0 -1
- package/dist/types/ui/index.d.ts +0 -2
- package/dist/types/ui/index.d.ts.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds application-layout";
|
|
4
|
+
/**
|
|
5
|
+
* ApplicationLayout — the application shell.
|
|
6
|
+
*
|
|
7
|
+
* Divides the viewport between a leading navigation rail (named slot,
|
|
8
|
+
* `min-content`) and the main content area (default slot, `1fr`), per the
|
|
9
|
+
* ontology instance `apps.layout.application_layout`.
|
|
10
|
+
*/
|
|
11
|
+
const ApplicationLayout = ({ className, children, navigation, ...props }) => {
|
|
12
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [navigation != null && _jsx("div", { className: "navigation", children: navigation }), _jsx("div", { className: "content", children: children })] }));
|
|
13
|
+
};
|
|
14
|
+
export default ApplicationLayout;
|
|
15
|
+
//# sourceMappingURL=ApplicationLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationLayout.js","sourceRoot":"","sources":["../../../../src/lib/ApplicationLayout/ApplicationLayout.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,GAAG,KAAK,EACe,EAAsB,EAAE;IAC/C,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAER,UAAU,IAAI,IAAI,IAAI,cAAK,SAAS,EAAC,YAAY,YAAE,UAAU,GAAO,EACrE,cAAK,SAAS,EAAC,SAAS,YAAE,QAAQ,GAAO,IACrC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/ApplicationLayout/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0 */
|
|
2
|
+
|
|
3
|
+
.ds.application-layout {
|
|
4
|
+
/* Application shell: navigation rail (min-content) + content (1fr), per
|
|
5
|
+
the ontology instance apps.layout.application_layout. The rail/content
|
|
6
|
+
gutter follows the design reference (#421: 1rem) via the container gap
|
|
7
|
+
token; --application-layout-gap overrides (0 for a flush shell). */
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: min-content 1fr;
|
|
10
|
+
gap: var(--application-layout-gap, var(--container-gap-default, 1rem));
|
|
11
|
+
block-size: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Without a navigation slot, drop the rail column entirely so neither the
|
|
15
|
+
empty track nor the gap offsets the content. */
|
|
16
|
+
.ds.application-layout:not(:has(> .navigation)) {
|
|
17
|
+
grid-template-columns: 1fr;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* min-size 0 lets each region scroll internally instead of stretching the
|
|
21
|
+
shell beyond the viewport. The navigation slot owns its inline size. */
|
|
22
|
+
.ds.application-layout > .navigation {
|
|
23
|
+
min-block-size: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.ds.application-layout > .content {
|
|
27
|
+
min-block-size: 0;
|
|
28
|
+
min-inline-size: 0;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/ApplicationLayout/types.ts"],"names":[],"mappings":"AAAA,wDAAwD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds content-layout";
|
|
4
|
+
/**
|
|
5
|
+
* ContentLayout — the responsive content grid of a view.
|
|
6
|
+
*
|
|
7
|
+
* Lays its children (default slot) on one of the design system's grid
|
|
8
|
+
* presets, per the ontology instance `apps.layout.content_layout`:
|
|
9
|
+
* fixed-responsive breakpoint columns by default, or the intrinsic
|
|
10
|
+
* (fluid auto-fill) grid via `grid="intrinsic"`. Children are grid items;
|
|
11
|
+
* span them via `grid-column`/`grid-row` where a card needs more room.
|
|
12
|
+
*/
|
|
13
|
+
const ContentLayout = ({ className, children, grid = "responsive", ...props }) => {
|
|
14
|
+
return (_jsx("div", { className: [componentCssClassName, "grid", grid, className]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join(" "), ...props, children: children }));
|
|
17
|
+
};
|
|
18
|
+
export default ContentLayout;
|
|
19
|
+
//# sourceMappingURL=ContentLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentLayout.js","sourceRoot":"","sources":["../../../../src/lib/ContentLayout/ContentLayout.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,CAAC,EACrB,SAAS,EACT,QAAQ,EACR,IAAI,GAAG,YAAY,EACnB,GAAG,KAAK,EACW,EAAsB,EAAE;IAC3C,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;aACxD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,KACR,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/ContentLayout/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0 */
|
|
2
|
+
|
|
3
|
+
.ds.content-layout {
|
|
4
|
+
/* Column templates and gaps come from the .grid presets in
|
|
5
|
+
@canonical/styles (.responsive: breakpoint-driven 4/8/12 columns;
|
|
6
|
+
.intrinsic: fluid auto-fill groups of four minmax(--grid-col-min, 1fr)
|
|
7
|
+
columns). Knobs: --grid-gap (or per-axis --grid-row-gap /
|
|
8
|
+
--grid-column-gap), --grid-col-min for the intrinsic mode. */
|
|
9
|
+
|
|
10
|
+
/* Rows size to content; the grid grows downwards and scrolls in whatever
|
|
11
|
+
region contains it (e.g. ViewLayout's content slot). */
|
|
12
|
+
align-content: start;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/ContentLayout/types.ts"],"names":[],"mappings":"AAAA,wDAAwD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useId, useState } from "react";
|
|
3
|
+
import { Content, Footer, Header } from "./common/index.js";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
const componentCssClassName = "ds side-navigation";
|
|
6
|
+
/**
|
|
7
|
+
* SideNavigation — full-height application navigation rendered from a WD405
|
|
8
|
+
* Item tree. Owns its expand/collapse (rail) state — uncontrolled, seeded by
|
|
9
|
+
* `defaultExpanded` — and wires the header's collapse toggle to the content
|
|
10
|
+
* region it controls.
|
|
11
|
+
*
|
|
12
|
+
* Routing-agnostic: navigable items render via `LinkComponent` (default `"a"`);
|
|
13
|
+
* pass a router `Link` to integrate client-side navigation. The active item is
|
|
14
|
+
* resolved from `currentUrl`.
|
|
15
|
+
*
|
|
16
|
+
* @implements ds:apps.pattern.side-navigation
|
|
17
|
+
*/
|
|
18
|
+
const SideNavigation = ({ className, brand, applicationName, root, footerRoot, LinkComponent = "a", currentUrl,
|
|
19
|
+
// Controlled circuit — not official yet.
|
|
20
|
+
// expanded: expandedProp,
|
|
21
|
+
defaultExpanded = true,
|
|
22
|
+
// onExpandedChange,
|
|
23
|
+
...props }) => {
|
|
24
|
+
const contentId = useId();
|
|
25
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
26
|
+
const handleToggle = useCallback(() => {
|
|
27
|
+
setExpanded((current) => !current);
|
|
28
|
+
}, []);
|
|
29
|
+
// --- Controlled circuit (not official yet) -------------------------------
|
|
30
|
+
// const [uncontrolledExpanded, setUncontrolledExpanded] =
|
|
31
|
+
// useState(defaultExpanded);
|
|
32
|
+
// const isControlled = expandedProp !== undefined;
|
|
33
|
+
// const expanded = isControlled ? expandedProp : uncontrolledExpanded;
|
|
34
|
+
//
|
|
35
|
+
// const handleToggle = useCallback(() => {
|
|
36
|
+
// const next = !expanded;
|
|
37
|
+
// if (!isControlled) setUncontrolledExpanded(next);
|
|
38
|
+
// onExpandedChange?.(next);
|
|
39
|
+
// }, [expanded, isControlled, onExpandedChange]);
|
|
40
|
+
// -------------------------------------------------------------------------
|
|
41
|
+
return (_jsxs("div", { className: [componentCssClassName, !expanded && "collapsed", className]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join(" "), "data-expanded": expanded, ...props, children: [_jsx(Header, { brand: brand, applicationName: applicationName, expanded: expanded, onToggle: handleToggle, collapseControls: contentId }), _jsx(Content, { id: contentId, root: root, LinkComponent: LinkComponent, currentUrl: currentUrl }), footerRoot && (_jsx(Footer, { root: footerRoot, LinkComponent: LinkComponent, currentUrl: currentUrl }))] }));
|
|
44
|
+
};
|
|
45
|
+
export default SideNavigation;
|
|
46
|
+
//# sourceMappingURL=SideNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SideNavigation.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/SideNavigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,KAAK,EACL,eAAe,EACf,IAAI,EACJ,UAAU,EACV,aAAa,GAAG,GAAG,EACnB,UAAU;AACV,yCAAyC;AACzC,0BAA0B;AAC1B,eAAe,GAAG,IAAI;AACtB,oBAAoB;AACpB,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAE1B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;IAE1D,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QACpC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,4EAA4E;IAC5E,0DAA0D;IAC1D,+BAA+B;IAC/B,mDAAmD;IACnD,uEAAuE;IACvE,EAAE;IACF,2CAA2C;IAC3C,4BAA4B;IAC5B,sDAAsD;IACtD,8BAA8B;IAC9B,kDAAkD;IAClD,4EAA4E;IAE5E,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,CAAC,QAAQ,IAAI,WAAW,EAAE,SAAS,CAAC;aACpE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,mBACG,QAAQ,KACnB,KAAK,aAET,KAAC,MAAM,IACL,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,SAAS,GAC3B,EACF,KAAC,OAAO,IACN,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,GACtB,EACD,UAAU,IAAI,CACb,KAAC,MAAM,IACL,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,GACtB,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@canonical/react-ds-global";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds collapse-toggle";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.CollapseToggle — icon-only button that expands or collapses
|
|
7
|
+
* the navigation rail. Carries the disclosure ARIA contract: `aria-expanded`
|
|
8
|
+
* reflects the current state and `aria-controls` should point at the id of the
|
|
9
|
+
* navigation region it toggles.
|
|
10
|
+
*
|
|
11
|
+
* @implements ds:apps.subcomponent.side-navigation-collapse-toggle
|
|
12
|
+
*/
|
|
13
|
+
const CollapseToggle = ({ className, expanded = true, "aria-label": ariaLabel, ...props }) => {
|
|
14
|
+
return (_jsx("button", { type: "button", className: [componentCssClassName, className].filter(Boolean).join(" "), "aria-expanded": expanded, "aria-label": ariaLabel ?? (expanded ? "Collapse navigation" : "Expand navigation"), ...props, children: _jsx(Icon, { icon: expanded ? "collapse-side-nav" : "expand-side-nav" }) }));
|
|
15
|
+
};
|
|
16
|
+
export default CollapseToggle;
|
|
17
|
+
//# sourceMappingURL=CollapseToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollapseToggle.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/CollapseToggle/CollapseToggle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,YAAY,EAAE,SAAS,EACvB,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,gBAErB,SAAS,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAEnE,KAAK,YAET,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,GAAI,GAC3D,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/CollapseToggle/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/CollapseToggle/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NavTree } from "../NavTree/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds content";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.Content — main navigation region. Renders the direct children
|
|
7
|
+
* of its `root` Item via useNavigationTree (selection, active state, keyboard
|
|
8
|
+
* traversal). Falls back to `children` when no `root` is given.
|
|
9
|
+
*
|
|
10
|
+
* @implements ds:apps.subcomponent.side-navigation-content
|
|
11
|
+
*/
|
|
12
|
+
const Content = ({ className, root, LinkComponent = "a", currentUrl, children, ...props }) => {
|
|
13
|
+
return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: root ? (_jsx(NavTree, { root: root, currentUrl: currentUrl, LinkComponent: LinkComponent })) : (children) }));
|
|
14
|
+
};
|
|
15
|
+
export default Content;
|
|
16
|
+
//# sourceMappingURL=Content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/Content.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,SAAS,EACT,IAAI,EACJ,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,QAAQ,EACR,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,OAAO,IACN,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0 */
|
|
2
|
+
|
|
3
|
+
.ds.content {
|
|
4
|
+
position: relative;
|
|
5
|
+
flex: 1;
|
|
6
|
+
/* min-height:0 lets this flex item shrink below its content height so it can
|
|
7
|
+
scroll internally (flex items default to min-height:auto, which refuses to
|
|
8
|
+
shrink and would push the whole nav taller instead). Vertical scroll only;
|
|
9
|
+
never horizontal (long labels must not cause sideways scroll). */
|
|
10
|
+
min-height: 0;
|
|
11
|
+
overflow: hidden auto;
|
|
12
|
+
|
|
13
|
+
/* Tree structure (.group/.header/.list) is owned by NavTree's own styles.
|
|
14
|
+
Content only reserves room for the overflow fade so the last item of the
|
|
15
|
+
last group is never permanently hidden behind it. */
|
|
16
|
+
& .nav-tree > .group:last-child > .list {
|
|
17
|
+
padding-block-end: var(--overflow-gradient-height);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Overflow fade: a sticky bar pinned to the bottom of the scroll viewport,
|
|
21
|
+
painting the surface-aware gradient over content scrolling underneath. */
|
|
22
|
+
&::after {
|
|
23
|
+
content: "";
|
|
24
|
+
position: sticky;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
display: block;
|
|
27
|
+
block-size: var(--overflow-gradient-height);
|
|
28
|
+
/* Pull the bar back over the reserved padding so it overlays content. */
|
|
29
|
+
margin-block-start: calc(-1 * var(--overflow-gradient-height));
|
|
30
|
+
background: var(--surface-overflow-gradient);
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NavTree } from "../NavTree/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds footer";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.Footer — optional region pinned to the bottom, holding
|
|
7
|
+
* account-level or global actions. Drives its own useNavigationTree over its
|
|
8
|
+
* `root` (independent of Content). Falls back to `children` when no `root`.
|
|
9
|
+
*
|
|
10
|
+
* @implements ds:apps.subcomponent.side-navigation-footer
|
|
11
|
+
*/
|
|
12
|
+
const Footer = ({ className, root, LinkComponent = "a", currentUrl, children, ...props }) => {
|
|
13
|
+
return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: root ? (_jsx(NavTree, { root: root, currentUrl: currentUrl, LinkComponent: LinkComponent })) : (children) }));
|
|
14
|
+
};
|
|
15
|
+
export default Footer;
|
|
16
|
+
//# sourceMappingURL=Footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/Footer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,SAAS,EACT,IAAI,EACJ,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,QAAQ,EACR,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,OAAO,IACN,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CollapseToggle } from "../CollapseToggle/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds side-navigation-header";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.Header — top region holding the brand (the `brand` node, at the
|
|
7
|
+
* start) and the collapse toggle (at the end). The toggle is omitted when no
|
|
8
|
+
* `onToggle` handler is provided.
|
|
9
|
+
*
|
|
10
|
+
* @implements ds:apps.subcomponent.side-navigation-header
|
|
11
|
+
*/
|
|
12
|
+
const Header = ({ className, brand, applicationName, expanded, onToggle, collapseControls, ...props }) => {
|
|
13
|
+
return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("div", { className: "brand", children: brand }), applicationName != null && (_jsx("span", { className: "title p", children: applicationName })), onToggle && (_jsx(CollapseToggle, { expanded: expanded, "aria-controls": collapseControls, onClick: onToggle }))] }));
|
|
14
|
+
};
|
|
15
|
+
export default Header;
|
|
16
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Header/Header.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,SAAS,EACT,KAAK,EACL,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,OAAO,CACL,kBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAET,cAAK,SAAS,EAAC,OAAO,YAAE,KAAK,GAAO,EAGnC,eAAe,IAAI,IAAI,IAAI,CAC1B,eAAM,SAAS,EAAC,SAAS,YAAE,eAAe,GAAQ,CACnD,EACA,QAAQ,IAAI,CACX,KAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,mBACH,gBAAgB,EAC/B,OAAO,EAAE,QAAQ,GACjB,CACH,IACM,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Header/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0 */
|
|
2
|
+
|
|
3
|
+
.ds.side-navigation-header {
|
|
4
|
+
/* Shared row template with Item so the brand/logo aligns with item icons. */
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-columns: var(--sidenav-row-columns);
|
|
7
|
+
/* Baseline grid: a fixed box height of whole baseline units (5bU/40px, the
|
|
8
|
+
same row height as the items below) keeps the header on the rail's rhythm.
|
|
9
|
+
align-items: start tops every cell so the brand rectangle fills from the
|
|
10
|
+
top and the title/toggle sit at the top of the row. */
|
|
11
|
+
block-size: calc(var(--space-baseline) * 5); /* 40px — 5bU */
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
align-items: start;
|
|
14
|
+
gap: var(--dimension-100); /* 0.5rem */
|
|
15
|
+
|
|
16
|
+
/* Pin each part to its column explicitly so the toggle stays in the end
|
|
17
|
+
column even when the optional title is absent. */
|
|
18
|
+
.brand {
|
|
19
|
+
/* Start column, aligned with the item icons below. Tops-align with the rest
|
|
20
|
+
of the row (align-items: start); the brand's own margin/padding handles
|
|
21
|
+
its vertical placement, not a stretched cell. */
|
|
22
|
+
grid-column: 1;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.title {
|
|
28
|
+
/* Middle (1fr) column. Optional. */
|
|
29
|
+
grid-column: 2;
|
|
30
|
+
min-width: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
& > .ds.collapse-toggle {
|
|
34
|
+
/* End column. */
|
|
35
|
+
grid-column: 3;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Header/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "@canonical/react-ds-global";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds side-navigation-item";
|
|
5
|
+
/**
|
|
6
|
+
* SideNavigation.Item — the default renderer for a single navigation item.
|
|
7
|
+
*
|
|
8
|
+
* A flat leaf row, NOT recursive: traversal lives in NavTree's two loops. The
|
|
9
|
+
* row is `[icon] [label] [end]` over a shared grid template (so the icon aligns
|
|
10
|
+
* with the header logo). An item with a `url` renders as a link via
|
|
11
|
+
* `LinkComponent` (default `"a"`); otherwise a non-navigable label.
|
|
12
|
+
*
|
|
13
|
+
* End slot is derived, not authored:
|
|
14
|
+
* - has subitems → a disclosure caret (static affordance in PR1; expand/collapse
|
|
15
|
+
* behaviour is deferred);
|
|
16
|
+
* - leaf → the optional `slot` (a badge, count, …), or nothing.
|
|
17
|
+
*
|
|
18
|
+
* @implements ds:apps.subcomponent.side-navigation-item
|
|
19
|
+
*/
|
|
20
|
+
const Item = ({ url, label, icon, slot, disabled = false, active = false, LinkComponent = "a",
|
|
21
|
+
// NavItem fields not spread to the DOM.
|
|
22
|
+
key: _key, items, displayItemsType: _displayItemsType, Component: _Component, className, ...props }) => {
|
|
23
|
+
const Link = LinkComponent;
|
|
24
|
+
const hasSubitems = (items?.length ?? 0) > 0;
|
|
25
|
+
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "start p", children: icon ? _jsx(Icon, { icon: icon }) : null }), _jsx("span", { className: "label p", children: label }), hasSubitems ? (_jsx(Icon, { icon: "chevron-down", className: "end caret" })) : slot ? (_jsx("span", { className: "end slot", children: slot })) : null] }));
|
|
26
|
+
return (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-disabled": disabled || undefined, "data-active": active || undefined, ...props, children: url ? (_jsx(Link, { className: "row", href: disabled ? undefined : url, "aria-current": active ? "page" : undefined, children: content })) : (_jsx("span", { className: "row", "aria-current": active ? "page" : undefined, children: content })) }));
|
|
27
|
+
};
|
|
28
|
+
export default Item;
|
|
29
|
+
//# sourceMappingURL=Item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Item/Item.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,GAAG,EACH,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,KAAK,EACd,aAAa,GAAG,GAAG;AACnB,wCAAwC;AACxC,GAAG,EAAE,IAAI,EACT,KAAK,EACL,gBAAgB,EAAE,iBAAiB,EACnC,SAAS,EAAE,UAAU,EACrB,SAAS,EACT,GAAG,KAAK,EACE,EAAsB,EAAE;IAClC,MAAM,IAAI,GAAG,aAAa,CAAC;IAC3B,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAE7C,MAAM,OAAO,GAAG,CACd,8BAGE,eAAM,SAAS,EAAC,SAAS,YAAE,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,GAAQ,EACrE,eAAM,SAAS,EAAC,SAAS,YAAE,KAAK,GAAQ,EAEvC,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,IAAI,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAC,WAAW,GAAG,CACnD,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACT,eAAM,SAAS,EAAC,UAAU,YAAE,IAAI,GAAQ,CACzC,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;IAEF,OAAO,CACL,aACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,mBACxD,QAAQ,IAAI,SAAS,iBACvB,MAAM,IAAI,SAAS,KAC5B,KAAK,YAER,GAAG,CAAC,CAAC,CAAC,CACL,KAAC,IAAI,IACH,SAAS,EAAC,KAAK,EACf,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,kBAClB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAExC,OAAO,GACH,CACR,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,KAAK,kBAAe,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAC5D,OAAO,GACH,CACR,GACE,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Item/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Generated by @canonical/summon-component:react v0.1.0 */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* PR1: structural layout only. Colour/visual state (hover/active fills,
|
|
5
|
+
* text/icon colour) is deferred to PR2 (token pairings). A bare focus outline
|
|
6
|
+
* is included for keyboard focus visibility.
|
|
7
|
+
*/
|
|
8
|
+
.ds.side-navigation-item {
|
|
9
|
+
list-style: none;
|
|
10
|
+
|
|
11
|
+
/* The row: link or label. Shares the SideNavigation row template so the
|
|
12
|
+
leading icon aligns with the header logo. [icon] [label] [end].
|
|
13
|
+
Baseline grid: a fixed 5bU/40px row height (matching the header) carries the
|
|
14
|
+
vertical rhythm. Every cell top-anchors (align-items: start) so the .p line
|
|
15
|
+
boxes (icon + label) start at the same row top with equal line-height — their
|
|
16
|
+
baselines line up on the grid. No block padding — the fixed height owns it. */
|
|
17
|
+
& > .row {
|
|
18
|
+
display: grid;
|
|
19
|
+
grid-template-columns: var(--sidenav-row-columns);
|
|
20
|
+
align-items: start;
|
|
21
|
+
gap: var(--dimension-100); /* 0.5rem */
|
|
22
|
+
width: 100%;
|
|
23
|
+
block-size: calc(var(--space-baseline) * 5); /* 40px — 5bU */
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
padding-block: 0;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Leading icon → start column. A .p line box: the icon is inline and rides the
|
|
30
|
+
baseline-snapped line like a text glyph, so it shares the label baseline. */
|
|
31
|
+
& .start {
|
|
32
|
+
text-align: center;
|
|
33
|
+
|
|
34
|
+
& > .ds.icon {
|
|
35
|
+
vertical-align: sub;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Label → middle (1fr) column. .p line box, top-anchored like .start. */
|
|
40
|
+
& .label {
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Trailing caret / slot → end (auto) column, top-anchored. */
|
|
45
|
+
& .end {
|
|
46
|
+
text-align: center;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Keyboard focus visibility (structural a11y; styling refined in PR2). */
|
|
50
|
+
& > .row:focus-visible {
|
|
51
|
+
outline: 2px solid currentColor;
|
|
52
|
+
outline-offset: -2px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Item/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useNavigationTree } from "@canonical/react-hooks";
|
|
3
|
+
import { getItemId } from "@canonical/utils";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { Item } from "../Item/index.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
/**
|
|
8
|
+
* Internal: renders a navigation tree with two explicit loops (no recursion),
|
|
9
|
+
* deriving active state from useNavigationTree. Shared by Content and Footer —
|
|
10
|
+
* each region drives its own hook instance over its own root.
|
|
11
|
+
*
|
|
12
|
+
* Loop 1 — level-1 groups: each direct child of the root is a group; its
|
|
13
|
+
* label renders as a header (omitted when absent), wrapping its items.
|
|
14
|
+
* Loop 2 — level-2 items: each child of a group maps to a (flat) Item.
|
|
15
|
+
*
|
|
16
|
+
* The hook is generic over NavItem, so `icon`/`slot` survive typed onto the
|
|
17
|
+
* annotated nodes. `currentUrl` seeds initial selection and re-syncs it on
|
|
18
|
+
* navigation (the hook's `initialUrl` is mount-only), so the active item stays
|
|
19
|
+
* in sync with the consumer's router.
|
|
20
|
+
*/
|
|
21
|
+
const NavTree = ({ root, currentUrl, LinkComponent = "a", }) => {
|
|
22
|
+
const nav = useNavigationTree({ root, initialUrl: currentUrl });
|
|
23
|
+
const { index, selectItem } = nav;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (currentUrl === undefined)
|
|
26
|
+
return;
|
|
27
|
+
const match = index[currentUrl];
|
|
28
|
+
if (match)
|
|
29
|
+
selectItem(match);
|
|
30
|
+
}, [currentUrl, index, selectItem]);
|
|
31
|
+
const groups = nav.annotatedRoot.items ?? [];
|
|
32
|
+
return (_jsx("div", { className: "ds nav-tree", children: groups.map((group) => {
|
|
33
|
+
const groupId = getItemId(group);
|
|
34
|
+
const items = group.items ?? [];
|
|
35
|
+
return (_jsxs("section", { className: "group", "data-depth": group.depth, children: [group.label ? (_jsx("span", { className: "header p", children: group.label })) : null, _jsx("ul", { className: "list", children: items.map((item) => (_jsx(Item, { ...item, active: nav.getNodeStatus(item).selected, LinkComponent: LinkComponent }, getItemId(item)))) })] }, groupId));
|
|
36
|
+
}) }));
|
|
37
|
+
};
|
|
38
|
+
export default NavTree;
|
|
39
|
+
//# sourceMappingURL=NavTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavTree.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/NavTree/NavTree.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,cAAc,CAAC;AAEtB;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,IAAI,EACJ,UAAU,EACV,aAAa,GAAG,GAAG,GACN,EAAsB,EAAE;IACrC,MAAM,GAAG,GAAG,iBAAiB,CAAU,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACzE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IAElC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,KAAK;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IAEpC,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;IAE7C,OAAO,CACL,cAAK,SAAS,EAAC,aAAa,YAEzB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;YAChC,OAAO,CACL,mBAAS,SAAS,EAAC,OAAO,gBAA2B,KAAK,CAAC,KAAK,aAC7D,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CACb,eAAM,SAAS,EAAC,UAAU,YAAE,KAAK,CAAC,KAAK,GAAQ,CAChD,CAAC,CAAC,CAAC,IAAI,EACR,aAAI,SAAS,EAAC,MAAM,YAEjB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,IAAI,OAEC,IAAI,EACR,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,QAAQ,EACxC,aAAa,EAAE,aAAa,IAHvB,SAAS,CAAC,IAAI,CAAC,CAIpB,CACH,CAAC,GACC,KAdyB,OAAO,CAe7B,CACX,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/NavTree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SideNavigation NavTree — domain styles for the rendered tree structure
|
|
3
|
+
* (level-1 groups → header + level-2 item list). Owned here so Content and
|
|
4
|
+
* Footer can compose NavTree without re-declaring its internals. Structural
|
|
5
|
+
* only; colour/visual tokens are deferred to PR2.
|
|
6
|
+
*/
|
|
7
|
+
.ds.nav-tree {
|
|
8
|
+
display: contents;
|
|
9
|
+
|
|
10
|
+
& > .group {
|
|
11
|
+
> .header {
|
|
12
|
+
/* Group header sits on the baseline grid like a row: a fixed bU-multiple
|
|
13
|
+
height (4bU) with the .p label baseline-snapped, and inline padding that
|
|
14
|
+
aligns the header text with the item labels below (past the start column
|
|
15
|
+
+ its gap). */
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: baseline;
|
|
18
|
+
block-size: calc(var(--space-baseline) * 4); /* 32px — 4bU */
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
padding-inline-start: calc(var(--sidenav-start) + var(--dimension-100));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
> .list {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
list-style: none;
|
|
27
|
+
margin: 0;
|
|
28
|
+
padding: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|