@canonical/react-ds-app 0.45.0 → 0.48.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/README.md +2 -0
- package/dist/esm/lib/ApplicationLayout/ApplicationLayout.js +2 -0
- package/dist/esm/lib/ApplicationLayout/ApplicationLayout.js.map +1 -1
- package/dist/esm/lib/ContentLayout/ContentLayout.js +2 -0
- package/dist/esm/lib/ContentLayout/ContentLayout.js.map +1 -1
- package/dist/esm/lib/SideNavigation/SideNavigation.js +16 -15
- package/dist/esm/lib/SideNavigation/SideNavigation.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/CollapseToggle/CollapseToggle.js +1 -1
- package/dist/esm/lib/SideNavigation/common/Content/Content.js +14 -11
- package/dist/esm/lib/SideNavigation/common/Content/Content.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Content/styles.css +9 -0
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.js +5 -4
- package/dist/esm/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js +4 -3
- package/dist/esm/lib/SideNavigation/common/Footer/Footer.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/Group/Group.js +6 -3
- package/dist/esm/lib/SideNavigation/common/Group/Group.js.map +1 -1
- package/dist/esm/lib/SideNavigation/common/GroupHeader/GroupHeader.js +1 -1
- package/dist/esm/lib/SideNavigation/common/Header/Header.js +1 -1
- package/dist/esm/lib/SideNavigation/common/Item/Item.js +1 -1
- package/dist/esm/lib/SideNavigation/common/ItemButton/ItemButton.js +1 -1
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/ItemExpandable.js +1 -1
- package/dist/esm/lib/SideNavigation/common/ItemExpandable/styles.css +1 -1
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js +12 -14
- package/dist/esm/lib/SideNavigation/common/NavTree/NavTree.js.map +1 -1
- package/dist/esm/lib/SideNavigation/styles.css +2 -5
- package/dist/esm/lib/SidePanel/Provider.js +13 -3
- package/dist/esm/lib/SidePanel/Provider.js.map +1 -1
- package/dist/esm/lib/SidePanel/common/Content/Content.js +41 -3
- package/dist/esm/lib/SidePanel/common/Content/Content.js.map +1 -1
- package/dist/esm/lib/SidePanel/common/Content/styles.css +85 -0
- package/dist/esm/lib/SidePanel/common/Footer/Footer.js +5 -0
- package/dist/esm/lib/SidePanel/common/Footer/Footer.js.map +1 -1
- package/dist/esm/lib/SidePanel/common/Footer/styles.css +4 -15
- package/dist/esm/lib/SidePanel/common/Header/styles.css +4 -5
- package/dist/esm/lib/SidePanel/styles.css +11 -4
- package/dist/esm/lib/ViewLayout/ViewLayout.js +2 -0
- package/dist/esm/lib/ViewLayout/ViewLayout.js.map +1 -1
- package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts +2 -0
- package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
- package/dist/types/lib/ContentLayout/ContentLayout.d.ts +2 -0
- package/dist/types/lib/ContentLayout/ContentLayout.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts +14 -13
- package/dist/types/lib/SideNavigation/SideNavigation.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts +11 -9
- package/dist/types/lib/SideNavigation/common/Content/Content.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts +7 -1
- package/dist/types/lib/SideNavigation/common/Content/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts +4 -3
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/types.d.ts +2 -2
- package/dist/types/lib/SideNavigation/common/ContextSwitcher/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts +4 -3
- package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Group/Group.d.ts +4 -3
- package/dist/types/lib/SideNavigation/common/Group/Group.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/Group/types.d.ts +5 -0
- package/dist/types/lib/SideNavigation/common/Group/types.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/common/GroupHeader/GroupHeader.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/Header/Header.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/Item/Item.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/ItemButton/ItemButton.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/ItemExpandable/ItemExpandable.d.ts +1 -1
- package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/lib/SideNavigation/types.d.ts +9 -9
- package/dist/types/lib/SideNavigation/types.d.ts.map +1 -1
- package/dist/types/lib/SidePanel/Provider.d.ts.map +1 -1
- package/dist/types/lib/SidePanel/common/Content/Content.d.ts +1 -1
- package/dist/types/lib/SidePanel/common/Content/Content.d.ts.map +1 -1
- package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts.map +1 -1
- package/dist/types/lib/ViewLayout/ViewLayout.d.ts +2 -0
- package/dist/types/lib/ViewLayout/ViewLayout.d.ts.map +1 -1
- package/package.json +21 -21
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ import "@canonical/styles";
|
|
|
20
20
|
|
|
21
21
|
Each component brings its own stylesheet when you import it.
|
|
22
22
|
|
|
23
|
+
Testing with Jest? `@canonical/react-ds-global`'s [Testing with Jest](../ds-global/README.md#testing-with-jest) section covers the ESM transform, the stylesheet stub, the mapper entry this package needs and the jsdom dialog stub.
|
|
24
|
+
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
27
|
```tsx
|
|
@@ -7,6 +7,8 @@ const componentCssClassName = "ds application-layout";
|
|
|
7
7
|
* Divides the viewport between a leading navigation rail (named slot,
|
|
8
8
|
* `min-content`) and the main content area (default slot, `1fr`), per the
|
|
9
9
|
* ontology instance `apps.layout.application_layout`.
|
|
10
|
+
*
|
|
11
|
+
* @implements ds:apps.layout.application_layout
|
|
10
12
|
*/
|
|
11
13
|
const ApplicationLayout = ({ className, children, navigation, ...props }) => {
|
|
12
14
|
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 })] }));
|
|
@@ -1 +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
|
|
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;;;;;;;;GAQG;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"}
|
|
@@ -9,6 +9,8 @@ const componentCssClassName = "ds content-layout";
|
|
|
9
9
|
* fixed-responsive breakpoint columns by default, or the intrinsic
|
|
10
10
|
* (fluid auto-fill) grid via `grid="intrinsic"`. Children are grid items;
|
|
11
11
|
* span them via `grid-column`/`grid-row` where a card needs more room.
|
|
12
|
+
*
|
|
13
|
+
* @implements ds:apps.layout.content_layout
|
|
12
14
|
*/
|
|
13
15
|
const ContentLayout = ({ className, children, grid = "responsive", ...props }) => {
|
|
14
16
|
return (_jsx("div", { className: [componentCssClassName, "grid", grid, className]
|
|
@@ -1 +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
|
|
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;;;;;;;;;;GAUG;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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useId, useState } from "react";
|
|
3
|
-
import { Content,
|
|
3
|
+
import { Content, Footer, Header } from "./common/index.js";
|
|
4
4
|
import { DEFAULT_MESSAGES } from "./constants.js";
|
|
5
5
|
import { useCollapseShortcut } from "./hooks/useCollapseShortcut/index.js";
|
|
6
6
|
import "./styles.css";
|
|
@@ -11,17 +11,18 @@ const componentCssClassName = "ds side-navigation";
|
|
|
11
11
|
* `defaultExpanded` — and wires the header's collapse toggle to the content
|
|
12
12
|
* region it controls.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* ContextSwitcher
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `<nav>` and defaults to
|
|
14
|
+
* Three regions: Header (branding, collapse toggle), Content (the
|
|
15
|
+
* optional ContextSwitcher, then the main `<nav>` landmark) and Footer
|
|
16
|
+
* (user profile, settings and non-navigational actions). The context
|
|
17
|
+
* switcher is a `role="menu"` select-like widget — not navigation — so it
|
|
18
|
+
* sits before the landmark, not inside it, and hides with Content when
|
|
19
|
+
* collapsed. The root element is a plain `<div>` and the component's
|
|
20
|
+
* single *navigation* landmark is Content's `<nav>`, so screen readers
|
|
21
|
+
* announce exactly one navigation region; the regions themselves are
|
|
22
|
+
* `<header>`/`<footer>` elements, which additionally expose
|
|
23
|
+
* banner/contentinfo landmarks. The footer always renders, empty without
|
|
24
|
+
* `footerRoot`. `aria-label` is forwarded to the `<nav>` and defaults to
|
|
25
|
+
* `"Main navigation"`.
|
|
25
26
|
*
|
|
26
27
|
* A visually hidden "Skip to main content" link is the first element in the
|
|
27
28
|
* component's DOM order, so keyboard users can bypass the navigation block;
|
|
@@ -31,12 +32,12 @@ const componentCssClassName = "ds side-navigation";
|
|
|
31
32
|
* pass a router `Link` to integrate client-side navigation. The active item is
|
|
32
33
|
* resolved from `currentUrl`.
|
|
33
34
|
*
|
|
34
|
-
* Consumption pattern: data-driven only. Pass props and all
|
|
35
|
+
* Consumption pattern: data-driven only. Pass props and all three regions
|
|
35
36
|
* build; row-level and region components are private
|
|
36
37
|
* (`cs:react.component.subcomponent_export_api` — no dot-static exports),
|
|
37
38
|
* and render exclusively from data.
|
|
38
39
|
*
|
|
39
|
-
* @implements ds:apps.
|
|
40
|
+
* @implements ds:apps.component.side_navigation
|
|
40
41
|
*/
|
|
41
42
|
const SideNavigation = ({ className, brand, applicationName, root, contextSwitcher, footerRoot, LinkComponent = "a", currentUrl, skipTo = "#main-content", defaultExpanded: defaultExpandedProp, keyboardShortcut = true, "aria-label": ariaLabel, messages: messagesProp, ...props }) => {
|
|
42
43
|
const contentId = useId();
|
|
@@ -61,7 +62,7 @@ const SideNavigation = ({ className, brand, applicationName, root, contextSwitch
|
|
|
61
62
|
// Ctrl+B rail-collapse shortcut — on unless
|
|
62
63
|
// `keyboardShortcut` opts out. See hooks/useCollapseShortcut.
|
|
63
64
|
useCollapseShortcut({ condition: keyboardShortcut, onTrigger: handleToggle });
|
|
64
|
-
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-expanded": expanded, ...props, children: [_jsx("a", { className: "skip-link", href: skipTo, children: messages.skipToContent() }), _jsx(Header, { brand: brand, applicationName: applicationName, expanded: expanded, onToggle: handleToggle, collapseControls: contentId, collapseToggleMessages: messages }),
|
|
65
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-expanded": expanded, ...props, children: [_jsx("a", { className: "skip-link", href: skipTo, children: messages.skipToContent() }), _jsx(Header, { brand: brand, applicationName: applicationName, expanded: expanded, onToggle: handleToggle, collapseControls: contentId, collapseToggleMessages: messages }), _jsx(Content, { id: contentId, root: root, contextSwitcher: contextSwitcher, LinkComponent: LinkComponent, currentUrl: currentUrl, "aria-label": ariaLabel ?? messages.navigation() }), _jsx(Footer, { root: footerRoot, LinkComponent: LinkComponent, currentUrl: currentUrl })] }));
|
|
65
66
|
};
|
|
66
67
|
export default SideNavigation;
|
|
67
68
|
//# sourceMappingURL=SideNavigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNavigation.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/SideNavigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SideNavigation.js","sourceRoot":"","sources":["../../../../src/lib/SideNavigation/SideNavigation.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,KAAK,EACL,eAAe,EACf,IAAI,EACJ,eAAe,EACf,UAAU,EACV,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,MAAM,GAAG,eAAe,EACxB,eAAe,EAAE,mBAAmB,EACpC,gBAAgB,GAAG,IAAI,EACvB,YAAY,EAAE,SAAS,EACvB,QAAQ,EAAE,YAAY,EACtB,GAAG,KAAK,EACY,EAAsB,EAAE;IAC5C,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,YAAY,EAAE,CAAC;IAE1D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,mBAAmB,IAAI,IAAI,CAAC,CAAC;IAEtE,+CAA+C;IAC/C,2EAA2E;IAC3E,0EAA0E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Aa,EAC5B,UAAU,EAAE,UAAU,GACtB,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -27,7 +27,7 @@ const CollapseToggleTrigger = ({ className, expanded = true, messages: messagesP
|
|
|
27
27
|
* type across state changes, so the button — and with it keyboard focus
|
|
28
28
|
* and hover state — survives every toggle instead of remounting.
|
|
29
29
|
*
|
|
30
|
-
* @implements ds:apps.subcomponent.
|
|
30
|
+
* @implements ds:apps.subcomponent.side_navigation-collapse_toggle
|
|
31
31
|
*/
|
|
32
32
|
const CollapseToggle = ({ expanded = true, messages, ...props }) => {
|
|
33
33
|
const { collapse, expand } = { ...DEFAULT_MESSAGES, ...messages };
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ContextSwitcher } from "../ContextSwitcher/index.js";
|
|
2
3
|
import { NavTree } from "../NavTree/index.js";
|
|
3
4
|
import "./styles.css";
|
|
4
5
|
const componentCssClassName = "ds side-navigation-content";
|
|
5
6
|
/**
|
|
6
|
-
* SideNavigation.Content — the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* SideNavigation.Content — the scrolling region between Header and Footer.
|
|
8
|
+
* It holds the optional context switcher and, after it, the component's
|
|
9
|
+
* only `<nav>` landmark. The switcher is a `role="menu"` widget, not
|
|
10
|
+
* navigation, so it sits outside the landmark. Navigation rows are links
|
|
11
|
+
* and expandable items exclusively (actions are Footer's job). Data-only —
|
|
12
|
+
* rows render exclusively from the `root` tree (row components are
|
|
13
|
+
* private; there is no children escape hatch into the landmark).
|
|
14
|
+
* `aria-label` names the `<nav>`; with no `root`, the landmark renders
|
|
15
|
+
* empty (the landmark contract stays stable).
|
|
13
16
|
*
|
|
14
|
-
* @implements ds:apps.subcomponent.
|
|
17
|
+
* @implements ds:apps.subcomponent.side_navigation-content
|
|
15
18
|
*/
|
|
16
|
-
const Content = ({ className, root, LinkComponent = "a", currentUrl, ...props }) => {
|
|
17
|
-
return (
|
|
19
|
+
const Content = ({ className, root, contextSwitcher, LinkComponent = "a", currentUrl, "aria-label": ariaLabel, ...props }) => {
|
|
20
|
+
return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [contextSwitcher ? _jsx(ContextSwitcher, { ...contextSwitcher }) : null, _jsx("nav", { "aria-label": ariaLabel, children: root ? (_jsx(NavTree, { root: root, currentUrl: currentUrl, LinkComponent: LinkComponent })) : null })] }));
|
|
18
21
|
};
|
|
19
22
|
export default Content;
|
|
20
23
|
//# sourceMappingURL=Content.js.map
|
|
@@ -1 +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,4BAA4B,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Content/Content.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,SAAS,EACT,IAAI,EACJ,eAAe,EACf,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,YAAY,EAAE,SAAS,EACvB,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAER,eAAe,CAAC,CAAC,CAAC,KAAC,eAAe,OAAK,eAAe,GAAI,CAAC,CAAC,CAAC,IAAI,EAClE,4BAAiB,SAAS,YACvB,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,OAAO,IACN,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC,CAAC,CAAC,IAAI,GACJ,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -56,5 +56,14 @@
|
|
|
56
56
|
flex: 0 0 auto;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/* The navigation landmark inside the region (anatomy:
|
|
61
|
+
SideNavigation.Content > Nav). The context switcher sits before it,
|
|
62
|
+
outside the landmark; the groups keep the region's 0.5rem rhythm. */
|
|
63
|
+
& > nav {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: var(--dimension-100);
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
}
|
|
@@ -12,7 +12,7 @@ const ContextItemContent = ({ item, }) => {
|
|
|
12
12
|
if (renderLabel != null) {
|
|
13
13
|
return (_jsxs("span", { className: "create-context", children: [_jsx(Icon, { icon: "plus" }), _jsx("span", { className: "label", children: renderLabel })] }));
|
|
14
14
|
}
|
|
15
|
-
return (_jsxs("span", { className: ["content", isCurrent && "current"].filter(Boolean).join(" "), children: [_jsx("span", { className: "name", children: item.label }),
|
|
15
|
+
return (_jsxs("span", { className: ["content", isCurrent && "current"].filter(Boolean).join(" "), children: [_jsx("span", { className: "name", children: item.label }), _jsx("span", { className: "description", children: description }), badge ? _jsx("span", { className: "badge", children: badge }) : null] }));
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* SideNavigation.ContextSwitcher — a dropdown for products that divide
|
|
@@ -23,10 +23,11 @@ const ContextItemContent = ({ item, }) => {
|
|
|
23
23
|
* `SideNavigation.GroupHeader` as a sibling above the dropdown field.
|
|
24
24
|
*
|
|
25
25
|
* Not part of the `NavRoot`/`NavGroup` content-tree data model — it
|
|
26
|
-
* embeds via `SideNavigation`'s `contextSwitcher` prop slot
|
|
27
|
-
*
|
|
26
|
+
* embeds via `SideNavigation`'s `contextSwitcher` prop slot and renders
|
|
27
|
+
* inside Content, before the `<nav>` landmark, hiding with Content on the
|
|
28
|
+
* collapsed rail.
|
|
28
29
|
*
|
|
29
|
-
* @implements ds:apps.subcomponent.
|
|
30
|
+
* @implements ds:apps.subcomponent.side_navigation-context_switcher
|
|
30
31
|
*/
|
|
31
32
|
const ContextSwitcher = ({ title, currentContext, contexts, onContextChange, onCreateContext, createContextLabel = "Create context", className, open, onOpenChange, preferredDirections, distance, gutter, maxWidth, autoFit, ...props }) => {
|
|
32
33
|
const contextItems = contexts.map((context) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextSwitcher.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,qCAAqC,CAAC;AAiBpE;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,EAC1B,IAAI,GAGL,EAAsB,EAAE;IACvB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAClD,IAAuB,CAAC;IAE1B,yDAAyD;IACzD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,CACL,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACpB,eAAM,SAAS,EAAC,OAAO,YAAE,WAAW,GAAQ,IACvC,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,gBACE,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAExE,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,CAAC,KAAK,GAAQ,
|
|
1
|
+
{"version":3,"file":"ContextSwitcher.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,qCAAqC,CAAC;AAiBpE;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,EAC1B,IAAI,GAGL,EAAsB,EAAE;IACvB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAClD,IAAuB,CAAC;IAE1B,yDAAyD;IACzD,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,CACL,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACpB,eAAM,SAAS,EAAC,OAAO,YAAE,WAAW,GAAQ,IACvC,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,gBACE,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAExE,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,CAAC,KAAK,GAAQ,EAC1C,eAAM,SAAS,EAAC,aAAa,YAAE,WAA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
|
|
36
|
-
* SideNavigation.Footer —
|
|
37
|
-
*
|
|
36
|
+
* SideNavigation.Footer — the region pinned to the bottom, reserved for
|
|
37
|
+
* user-related content. It always renders; without items it is an empty
|
|
38
|
+
* `<footer>`. Data-only: `root` is the footer's only data
|
|
38
39
|
* surface — free-form leaves (`LeafFooterItem`, buttons via
|
|
39
40
|
* `control`/`onClick`) and depth-1 expandables (`ExpandableFooterItem`,
|
|
40
41
|
* whose children disclose through the same native `<details>` disclosure
|
|
41
42
|
* the content tree uses). A certificate-user application, for instance,
|
|
42
43
|
* composes the `certificate` icon and omits the logout item itself.
|
|
43
44
|
*
|
|
44
|
-
* @implements ds:apps.subcomponent.
|
|
45
|
+
* @implements ds:apps.subcomponent.side_navigation-footer
|
|
45
46
|
*/
|
|
46
47
|
const Footer = ({ className, root, LinkComponent = "a", currentUrl, ...props }) => {
|
|
47
48
|
const list = root?.items ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Footer/Footer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAQ1D;;;;;;;;;;GAUG;AACH,MAAM,SAAS,GAAG,CAAC,EACjB,IAAI,EACJ,UAAU,EACV,aAAa,GACE,EAAsB,EAAE;IACvC,0EAA0E;IAC1E,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAEpD,MAAM,IAAI,GACR,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI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C3C,KAAC,cAAc,IAEb,OAAO,EAAE,KAAK,CAAC,KAAK,EACpB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,oBAAoB;gBACpB,yDAAyD;gBACzD,2DAA2D;gBAC3D,uDAAuD;gBACvD,4DAA4D;gBAC5D,4DAA4D;gBAC5D,qCAAqC;gBACrC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAC/B,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,UAAU,CACtD,YAEA,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,KAAC,SAAS,IAER,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,IAHvB,KAAK,CAAC,KAAK,CAIhB,CACH,CAAC,IAtBG,KAAK,CAAC,KAAK,CAuBD,CAClB,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IAER,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,IAHvB,KAAK,CAAC,KAAK,CAIhB,CACH,CACF,GACE,CACN,CAAC,CAAC,CAAC,IAAI,GACD,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -5,10 +5,13 @@ const componentCssClassName = "ds side-navigation-group";
|
|
|
5
5
|
/**
|
|
6
6
|
* SideNavigation.Group — a named collection of navigation entries, with an
|
|
7
7
|
* optional SideNavigation.GroupHeader. One of NavTree's direct content
|
|
8
|
-
* entries.
|
|
8
|
+
* entries. Starts with a divider when `divider` is set (every group but
|
|
9
|
+
* the first).
|
|
9
10
|
*
|
|
10
|
-
* @implements ds:apps.subcomponent.
|
|
11
|
+
* @implements ds:apps.subcomponent.side_navigation-item_group
|
|
11
12
|
*/
|
|
12
|
-
const Group = ({ label,
|
|
13
|
+
const Group = ({ label,
|
|
14
|
+
// The divider is hidden for now (operator, 2026-11-28); restore the render below.
|
|
15
|
+
divider: _divider = false, children, className, ...props }) => (_jsxs("section", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [label != null && _jsx(GroupHeader, { children: label }), _jsx("ul", { className: "list", children: children })] }));
|
|
13
16
|
export default Group;
|
|
14
17
|
//# sourceMappingURL=Group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Group/Group.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/Group/Group.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,KAAK;AACL,kFAAkF;AAClF,OAAO,EAAE,QAAQ,GAAG,KAAK,EACzB,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACG,EAAsB,EAAE,CAAC,CACpC,mBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAGR,KAAK,IAAI,IAAI,IAAI,KAAC,WAAW,cAAE,KAAK,GAAe,EACpD,aAAI,SAAS,EAAC,MAAM,YAAE,QAAQ,GAAM,IAC5B,CACX,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -6,7 +6,7 @@ const componentCssClassName = "ds side-navigation-group-header";
|
|
|
6
6
|
* SideNavigation.Group's entries. Purely presentational; rendered by Group
|
|
7
7
|
* when its `label` is set.
|
|
8
8
|
*
|
|
9
|
-
* @implements ds:apps.subcomponent.
|
|
9
|
+
* @implements ds:apps.subcomponent.side_navigation-group_header
|
|
10
10
|
*/
|
|
11
11
|
const GroupHeader = ({ children, className, ...props }) => (_jsx("span", { className: [componentCssClassName, className].filter(Boolean).join(" "),
|
|
12
12
|
// `title` — native tooltip fallback for a truncated header.
|
|
@@ -9,7 +9,7 @@ const componentCssClassName = "ds side-navigation-header";
|
|
|
9
9
|
* switches to a centred column — the toggle relocates below the logo rather
|
|
10
10
|
* than beside it — driven by `data-expanded` on the root.
|
|
11
11
|
*
|
|
12
|
-
* @implements ds:apps.subcomponent.
|
|
12
|
+
* @implements ds:apps.subcomponent.side_navigation-header
|
|
13
13
|
*/
|
|
14
14
|
const Header = ({ className, brand, applicationName, expanded, onToggle, collapseControls, collapseToggleMessages, ...props }) => {
|
|
15
15
|
return (_jsxs("header", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-expanded": expanded, ...props, children: [_jsxs("div", { className: "brand-container", children: [_jsx("div", { className: "brand", children: brand }), applicationName != null && (_jsx("h1", { className: "title", children: applicationName }))] }), onToggle && (_jsx(CollapseToggle, { expanded: expanded, "aria-controls": collapseControls, messages: collapseToggleMessages, onClick: onToggle }))] }));
|
|
@@ -14,7 +14,7 @@ const componentCssClassName = "ds side-navigation-item";
|
|
|
14
14
|
* composed via `children`, matching `Button`'s own convention — pass
|
|
15
15
|
* anything, not only text.
|
|
16
16
|
*
|
|
17
|
-
* @implements ds:apps.subcomponent.
|
|
17
|
+
* @implements ds:apps.subcomponent.side_navigation-item
|
|
18
18
|
*/
|
|
19
19
|
const Item = ({ url, children, icon, slot, disabled = false, active = false, LinkComponent = "a", className, ...props }) => {
|
|
20
20
|
const Link = LinkComponent;
|
|
@@ -11,7 +11,7 @@ const componentCssClassName = "ds side-navigation-item-button";
|
|
|
11
11
|
* `children`. Content is composed via `children`,
|
|
12
12
|
* matching `Button`'s own convention.
|
|
13
13
|
*
|
|
14
|
-
* @implements ds:apps.subcomponent.
|
|
14
|
+
* @implements ds:apps.subcomponent.side_navigation-item_button
|
|
15
15
|
*/
|
|
16
16
|
const ItemButton = ({ children, icon, slot, className, ...props }) => (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), children: _jsxs("button", { className: "row", ...props, type: "button", children: [_jsx("span", { className: "start", children: icon ? _jsx(Icon, { width: 16, height: 16, icon: icon }) : null }), _jsx("span", { className: "label", title: typeof children === "string" ? children : undefined, children: children }), slot ? _jsx("span", { className: "end slot", children: slot }) : null] }) }));
|
|
17
17
|
export default ItemButton;
|
|
@@ -21,7 +21,7 @@ const componentCssClassName = "ds side-navigation-item-expandable";
|
|
|
21
21
|
* among the `children` collapses the disclosure. The content tree does not
|
|
22
22
|
* opt in: its branch stays open so the active row remains visible.
|
|
23
23
|
*
|
|
24
|
-
* @implements ds:apps.subcomponent.
|
|
24
|
+
* @implements ds:apps.subcomponent.side_navigation-item_expandable
|
|
25
25
|
*/
|
|
26
26
|
const ItemExpandable = ({ heading, icon, disabled = false, defaultExpanded = false, collapseOnChildClick = false, children, className, ...props }) => {
|
|
27
27
|
// Uncontrolled: the <details> owns its open state and React never
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
/* Collapsed rail: sub-items degrade into a floating popover on the
|
|
123
123
|
inline-end; the expanded state keeps its inline disclosure. */
|
|
124
124
|
.ds.side-navigation[data-expanded="false"]
|
|
125
|
-
|
|
125
|
+
.ds.side-navigation-item-expandable {
|
|
126
126
|
position: relative;
|
|
127
127
|
|
|
128
128
|
.children {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getItemId } from "@canonical/ds-utils";
|
|
3
3
|
import { useNavigationTree } from "@canonical/react-hooks";
|
|
4
|
-
import {
|
|
4
|
+
import { useEffect } from "react";
|
|
5
5
|
import { Group } from "../Group/index.js";
|
|
6
6
|
import { Item } from "../Item/index.js";
|
|
7
7
|
import { ItemExpandable } from "../ItemExpandable/index.js";
|
|
@@ -63,19 +63,17 @@ const NavTree = ({ root, currentUrl, LinkComponent = "a", className, ...props })
|
|
|
63
63
|
if (match)
|
|
64
64
|
selectItem(match);
|
|
65
65
|
}, [currentUrl, index, selectItem]);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}) })) }, sectionId));
|
|
78
|
-
}) }));
|
|
66
|
+
// Empty groups render nothing, so they are dropped before the loop: the
|
|
67
|
+
// divider index then counts rendered groups only.
|
|
68
|
+
const sections = (nav.annotatedRoot.items ?? []).filter((section) => (section.items ?? []).length > 0);
|
|
69
|
+
return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: sections.map((section, sectionIndex) => (_jsx(Group, { label: section.label, divider: sectionIndex > 0, children: (section.items ?? []).map((entry, entryIndex) => {
|
|
70
|
+
const children = entry.items ?? [];
|
|
71
|
+
if (children.length > 0) {
|
|
72
|
+
const { parentUrl: _parentUrl, depth: _depth, items: _items, key: _key, slot: _slot, url: _url, label, ...expandableFields } = entry;
|
|
73
|
+
return (_jsx(ItemExpandable, { ...expandableFields, heading: label, defaultExpanded: nav.getNodeStatus(entry).inSelectedBranch, children: children.map((child, childIndex) => renderEntry(child, nav.getNodeStatus(child).selected, LinkComponent, childIndex)) }, stableKey(entry, entryIndex)));
|
|
74
|
+
}
|
|
75
|
+
return renderEntry(entry, nav.getNodeStatus(entry).selected, LinkComponent, entryIndex);
|
|
76
|
+
}) }, getItemId(section)))) }));
|
|
79
77
|
};
|
|
80
78
|
export default NavTree;
|
|
81
79
|
//# sourceMappingURL=NavTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavTree.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/NavTree/NavTree.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NavTree.js","sourceRoot":"","sources":["../../../../../../src/lib/SideNavigation/common/NavTree/NavTree.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,IAAwB,EAAE,KAAa,EAAU,EAAE,CACpE,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,GAAG,CAClB,KAAyB,EACzB,MAAe,EACf,aAA4B,EAC5B,KAAa,EACO,EAAE;IACtB,MAAM,EACJ,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,IAAI,EACT,KAAK,EACL,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,KAAC,IAAI,OAEC,IAAI,EACR,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,YAE3B,KAAK,IALD,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAMvB,CACR,CAAC;AACJ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C,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;gBAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;gBAEnC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxB,MAAM,EACJ,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,IAAI,EACT,KAAK,EACL,GAAG,gBAAgB,EACpB,GAAG,KAAK,CAAC;oBACV,OAAO,CACL,KAAC,cAAc,OAET,gBAAgB,EACpB,OAAO,EAAE,KAAK,EACd,eAAe,EAAE,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,gBAAgB,YAEzD,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAClC,WAAW,CACT,KAAK,EACL,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,QAAQ,EACjC,aAAa,EACb,UAAU,CACX,CACF,IAZI,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAalB,CAClB,CAAC;gBACJ,CAAC;gBAED,OAAO,WAAW,CAChB,KAAK,EACL,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,QAAQ,EACjC,aAAa,EACb,UAAU,CACX,CAAC;YACJ,CAAC,CAAC,IA5CG,SAAS,CAAC,OAAO,CAAC,CA6CjB,CACT,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -130,15 +130,12 @@
|
|
|
130
130
|
inline-size: var(--sidenav-rail-inline-size-collapsed);
|
|
131
131
|
justify-content: space-between;
|
|
132
132
|
|
|
133
|
+
/* Content holds the context switcher too: label-driven rows,
|
|
134
|
+
nothing survives icon-only degradation. */
|
|
133
135
|
& > .ds.side-navigation-content {
|
|
134
136
|
display: none;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
/* Label-driven rows — nothing survives icon-only degradation. */
|
|
138
|
-
& > .ds.side-navigation-context-switcher {
|
|
139
|
-
display: none;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
139
|
/* Footer (icon-only) and ItemExpandable (popover) keep rendering —
|
|
143
140
|
their collapsed anatomy lives in their own stylesheets. */
|
|
144
141
|
}
|
|
@@ -29,9 +29,16 @@ const componentCssClassName = "ds side-panel";
|
|
|
29
29
|
* Compose the body from `SidePanel.Header`, `SidePanel.Content` and
|
|
30
30
|
* `SidePanel.Footer`. The panel lays them out as a flex column: header and
|
|
31
31
|
* footer keep their size, and the content pane takes the rest and scrolls
|
|
32
|
-
* within it.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* within it. 2px lines mark the pane's edges while content is hidden past
|
|
33
|
+
* them — the start line once the pane scrolls away from the top, the end
|
|
34
|
+
* line until it bottoms out, both together in between — drawn CSS-first:
|
|
35
|
+
* engines with scroll-driven animations paint them with or without
|
|
36
|
+
* JavaScript, and engines without fall back to measurement by the
|
|
37
|
+
* `useScrollOverflow` hook; engines with neither paint nothing. The content
|
|
38
|
+
* pane is a tab stop, so keyboard users can scroll it; opening the panel
|
|
39
|
+
* still focuses the panel itself, so from there Tab reaches the close
|
|
40
|
+
* button, then the content, then the footer's actions. The actions
|
|
41
|
+
* line up at the inline-start edge — render the primary action first.
|
|
35
42
|
*
|
|
36
43
|
* There are two consumption patterns, `withSidePanel` and `SidePanel`.
|
|
37
44
|
* `withSidePanel` is meant for static content: the call belongs at module
|
|
@@ -59,6 +66,9 @@ const componentCssClassName = "ds side-panel";
|
|
|
59
66
|
* this clipping. When it must overlap the panel, give its overlay layer a
|
|
60
67
|
* z-index higher than `--side-panel-z-index`.
|
|
61
68
|
*
|
|
69
|
+
* The panel's width comes from the `--side-panel-inline-size` custom
|
|
70
|
+
* property, 465px by default.
|
|
71
|
+
*
|
|
62
72
|
* `import { SidePanel } from "@canonical/react-ds-app";`
|
|
63
73
|
*
|
|
64
74
|
* @implements ds:apps.pattern.side_panel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/lib/SidePanel/Provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/lib/SidePanel/Provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACR,GAAG,KAAK,EACe,EAAsB,EAAE;IAC/C,MAAM,EACJ,SAAS,EACT,KAAK,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,GACZ,GAAG,kBAAkB,CAAC,KAAK,CAAC,CA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jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useScrollOverflow } from "@canonical/react-hooks";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
2
4
|
import "./styles.css";
|
|
3
5
|
const componentCssClassName = "ds side-panel-content";
|
|
6
|
+
/**
|
|
7
|
+
* Whether the engine paints the pane's edge lines with scroll-driven
|
|
8
|
+
* animations — the CSS-first mechanism in styles.css. Client-only: the
|
|
9
|
+
* server and engines without the feature report false, so the pane measures
|
|
10
|
+
* with JavaScript until the probe says the CSS owns the lines.
|
|
11
|
+
*/
|
|
12
|
+
const useScrollTimelineSupport = () => {
|
|
13
|
+
const [supported, setSupported] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setSupported(typeof CSS !== "undefined" &&
|
|
16
|
+
typeof CSS.supports === "function" &&
|
|
17
|
+
CSS.supports("animation-timeline", "scroll()"));
|
|
18
|
+
}, []);
|
|
19
|
+
return supported;
|
|
20
|
+
};
|
|
4
21
|
/**
|
|
5
22
|
* Body of a SidePanel, and the only part of it that scrolls: however tall its
|
|
6
23
|
* children are, the header and footer stay visible.
|
|
7
24
|
*
|
|
25
|
+
* While content is hidden past an edge, the pane marks that edge with a 2px
|
|
26
|
+
* line — the top line once the pane scrolls away from the top, the bottom
|
|
27
|
+
* line until it bottoms out, both together in between, neither when
|
|
28
|
+
* everything fits. The lines are CSS-first: engines with scroll-driven
|
|
29
|
+
* animations paint them by animating the pane's borders against its own
|
|
30
|
+
* scroll progress, with or without JavaScript. Engines without fall back to
|
|
31
|
+
* measurement: `useScrollOverflow` reports the two edge states, and the pane
|
|
32
|
+
* publishes them as `data-overflow-top` and `data-overflow-bottom` for the
|
|
33
|
+
* CSS to draw. Engines with neither paint nothing: without a measurement
|
|
34
|
+
* there is no truthful answer about which edges overflow.
|
|
35
|
+
*
|
|
8
36
|
* The pane is its own scroll container, so it is a tab stop: a keyboard
|
|
9
37
|
* user tabs to it and scrolls it with the arrow and page keys, even when it
|
|
10
38
|
* holds nothing focusable.
|
|
11
39
|
*
|
|
12
40
|
* @implements ds:apps.subcomponent.side_panel-content
|
|
13
41
|
*/
|
|
14
|
-
const Content = ({ children, className, fill = false, ...props }) => {
|
|
15
|
-
|
|
42
|
+
const Content = ({ children, className, fill = false, ref, ...props }) => {
|
|
43
|
+
// The edge lines are CSS-first: where scroll-driven animations run,
|
|
44
|
+
// styles.css paints them and the measurement must stand down; everywhere
|
|
45
|
+
// else the hook drives. The probe starts pessimistic, so the very first
|
|
46
|
+
// frame is measured either way and the lines are never a frame late.
|
|
47
|
+
const cssDriven = useScrollTimelineSupport();
|
|
48
|
+
// The overflow measurement needs its own look at the pane element, and a
|
|
49
|
+
// consumer ref must keep receiving it too: the hook fans the element out
|
|
50
|
+
// to both. Stood down, it clears the flags it measured on mount, so the
|
|
51
|
+
// edge attributes below exist only while JavaScript drives the lines.
|
|
52
|
+
const { ref: paneRef, overflowTop, overflowBottom, } = useScrollOverflow(ref, { enabled: !cssDriven });
|
|
53
|
+
return (_jsx("div", { ref: paneRef, className: [componentCssClassName, fill && "fill", className]
|
|
16
54
|
.filter(Boolean)
|
|
17
|
-
.join(" "),
|
|
55
|
+
.join(" "), "data-overflow-top": overflowTop || undefined, "data-overflow-bottom": overflowBottom || undefined,
|
|
18
56
|
// A scroll container a keyboard user cannot focus cannot be scrolled,
|
|
19
57
|
// so the pane is a tab stop. Set before the spread, so the native prop
|
|
20
58
|
// can still take it out of the tab order.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/Content.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/Content.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO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