@canonical/react-ds-app 0.42.0 → 0.43.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.
Files changed (86) hide show
  1. package/README.md +9 -3
  2. package/dist/esm/lib/SidePanel/Context.js +12 -0
  3. package/dist/esm/lib/SidePanel/Context.js.map +1 -0
  4. package/dist/esm/lib/SidePanel/Provider.js +90 -0
  5. package/dist/esm/lib/SidePanel/Provider.js.map +1 -0
  6. package/dist/esm/lib/SidePanel/common/Content/Content.js +26 -0
  7. package/dist/esm/lib/SidePanel/common/Content/Content.js.map +1 -0
  8. package/dist/esm/lib/SidePanel/common/Content/index.js +2 -0
  9. package/dist/esm/lib/SidePanel/common/Content/index.js.map +1 -0
  10. package/dist/esm/lib/SidePanel/common/Content/styles.css +49 -0
  11. package/dist/esm/lib/SidePanel/common/Content/types.js +2 -0
  12. package/dist/esm/lib/SidePanel/common/Content/types.js.map +1 -0
  13. package/dist/esm/lib/SidePanel/common/Footer/Footer.js +19 -0
  14. package/dist/esm/lib/SidePanel/common/Footer/Footer.js.map +1 -0
  15. package/dist/esm/lib/SidePanel/common/Footer/index.js +2 -0
  16. package/dist/esm/lib/SidePanel/common/Footer/index.js.map +1 -0
  17. package/dist/esm/lib/SidePanel/common/Footer/styles.css +36 -0
  18. package/dist/esm/lib/SidePanel/common/Footer/types.js +2 -0
  19. package/dist/esm/lib/SidePanel/common/Footer/types.js.map +1 -0
  20. package/dist/esm/lib/SidePanel/common/Header/Header.js +39 -0
  21. package/dist/esm/lib/SidePanel/common/Header/Header.js.map +1 -0
  22. package/dist/esm/lib/SidePanel/common/Header/index.js +2 -0
  23. package/dist/esm/lib/SidePanel/common/Header/index.js.map +1 -0
  24. package/dist/esm/lib/SidePanel/common/Header/styles.css +94 -0
  25. package/dist/esm/lib/SidePanel/common/Header/types.js +2 -0
  26. package/dist/esm/lib/SidePanel/common/Header/types.js.map +1 -0
  27. package/dist/esm/lib/SidePanel/common/index.js +4 -0
  28. package/dist/esm/lib/SidePanel/common/index.js.map +1 -0
  29. package/dist/esm/lib/SidePanel/hooks/index.js +4 -0
  30. package/dist/esm/lib/SidePanel/hooks/index.js.map +1 -0
  31. package/dist/esm/lib/SidePanel/hooks/types.js +2 -0
  32. package/dist/esm/lib/SidePanel/hooks/types.js.map +1 -0
  33. package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js +9 -0
  34. package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js.map +1 -0
  35. package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js +134 -0
  36. package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js.map +1 -0
  37. package/dist/esm/lib/SidePanel/index.js +4 -0
  38. package/dist/esm/lib/SidePanel/index.js.map +1 -0
  39. package/dist/esm/lib/SidePanel/styles.css +192 -0
  40. package/dist/esm/lib/SidePanel/types.js +2 -0
  41. package/dist/esm/lib/SidePanel/types.js.map +1 -0
  42. package/dist/esm/lib/SidePanel/withSidePanel.js +98 -0
  43. package/dist/esm/lib/SidePanel/withSidePanel.js.map +1 -0
  44. package/dist/esm/lib/index.js +1 -0
  45. package/dist/esm/lib/index.js.map +1 -1
  46. package/dist/types/lib/SidePanel/Context.d.ts +12 -0
  47. package/dist/types/lib/SidePanel/Context.d.ts.map +1 -0
  48. package/dist/types/lib/SidePanel/Provider.d.ts +13 -0
  49. package/dist/types/lib/SidePanel/Provider.d.ts.map +1 -0
  50. package/dist/types/lib/SidePanel/common/Content/Content.d.ts +9 -0
  51. package/dist/types/lib/SidePanel/common/Content/Content.d.ts.map +1 -0
  52. package/dist/types/lib/SidePanel/common/Content/index.d.ts +3 -0
  53. package/dist/types/lib/SidePanel/common/Content/index.d.ts.map +1 -0
  54. package/dist/types/lib/SidePanel/common/Content/types.d.ts +21 -0
  55. package/dist/types/lib/SidePanel/common/Content/types.d.ts.map +1 -0
  56. package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts +9 -0
  57. package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts.map +1 -0
  58. package/dist/types/lib/SidePanel/common/Footer/index.d.ts +3 -0
  59. package/dist/types/lib/SidePanel/common/Footer/index.d.ts.map +1 -0
  60. package/dist/types/lib/SidePanel/common/Footer/types.d.ts +14 -0
  61. package/dist/types/lib/SidePanel/common/Footer/types.d.ts.map +1 -0
  62. package/dist/types/lib/SidePanel/common/Header/Header.d.ts +9 -0
  63. package/dist/types/lib/SidePanel/common/Header/Header.d.ts.map +1 -0
  64. package/dist/types/lib/SidePanel/common/Header/index.d.ts +3 -0
  65. package/dist/types/lib/SidePanel/common/Header/index.d.ts.map +1 -0
  66. package/dist/types/lib/SidePanel/common/Header/types.d.ts +35 -0
  67. package/dist/types/lib/SidePanel/common/Header/types.d.ts.map +1 -0
  68. package/dist/types/lib/SidePanel/common/index.d.ts +4 -0
  69. package/dist/types/lib/SidePanel/common/index.d.ts.map +1 -0
  70. package/dist/types/lib/SidePanel/hooks/index.d.ts +4 -0
  71. package/dist/types/lib/SidePanel/hooks/index.d.ts.map +1 -0
  72. package/dist/types/lib/SidePanel/hooks/types.d.ts +28 -0
  73. package/dist/types/lib/SidePanel/hooks/types.d.ts.map +1 -0
  74. package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts +8 -0
  75. package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts.map +1 -0
  76. package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts +12 -0
  77. package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts.map +1 -0
  78. package/dist/types/lib/SidePanel/index.d.ts +4 -0
  79. package/dist/types/lib/SidePanel/index.d.ts.map +1 -0
  80. package/dist/types/lib/SidePanel/types.d.ts +97 -0
  81. package/dist/types/lib/SidePanel/types.d.ts.map +1 -0
  82. package/dist/types/lib/SidePanel/withSidePanel.d.ts +76 -0
  83. package/dist/types/lib/SidePanel/withSidePanel.d.ts.map +1 -0
  84. package/dist/types/lib/index.d.ts +1 -0
  85. package/dist/types/lib/index.d.ts.map +1 -1
  86. package/package.json +23 -22
package/README.md CHANGED
@@ -9,10 +9,16 @@ Application-level UI components for the Pragma design system. This package provi
9
9
  ## Installation
10
10
 
11
11
  ```bash
12
- bun add @canonical/react-ds-app
12
+ bun add @canonical/react-ds-app @canonical/styles
13
13
  ```
14
14
 
15
- The package builds on top of `@canonical/react-ds-global`.
15
+ Import the design system's styles **first** in your application's entry, before anything that imports a component:
16
+
17
+ ```ts
18
+ import "@canonical/styles";
19
+ ```
20
+
21
+ Each component brings its own stylesheet when you import it.
16
22
 
17
23
  ## Usage
18
24
 
@@ -52,7 +58,7 @@ The component layers follow the design system's tier tree, flat, one name per ti
52
58
 
53
59
  Once both are layered, no selector this package declares is also declared by `@canonical/react-ds-global`, so nothing changes hands. What the layer buys is the answer to the next collision, and that answer is fixed rather than emitted: today specificity settles the `.application-layout` near-miss, one seat apart; a global rule written at the same seat as this package's would have been settled by whichever bundle a loader emitted last, and is now settled by layer, in this package's favour, whatever the emit order and without a longer selector or an `!important`.
54
60
 
55
- The guarantee needs `@canonical/styles` on the page, and needs its statement first. An order statement is what fixes the relative order of two sublayers; without it they fall back to the order they first appear in, and a bundle that emits this package before `@canonical/react-ds-global` hands the win back to the global tier. One nuance, measured: `ds.components.apps` is not a name the statement contains yet — it still names the retired `ds.components.app`, and gains the second level in full with the rework of the styles package — but a sublayer the statement does not name is appended after every name it fixed, so with the statement on the page this package already beats `@canonical/react-ds-global` in both emit orders. Nothing under `src/lib` imports `@canonical/styles` — an application imports it once, as the installation instructions above say.
61
+ The guarantee needs `@canonical/styles` on the page, and needs its statement first. An order statement is what fixes the relative order of two sublayers; without it they fall back to the order they first appear in, and a bundle that emits this package before `@canonical/react-ds-global` hands the win back to the global tier. The statement names `ds.components.apps` above `ds.components.global`, so with the statement on the page this package beats `@canonical/react-ds-global` in both emit orders. Nothing under `src/lib` imports `@canonical/styles` — an application imports it once, as the installation instructions above say.
56
62
 
57
63
  An application's own **unlayered** CSS now beats every rule in this package, whatever the selectors on either side, because an unlayered author rule outranks every layered one. That is CSS working as designed, and it is the deliberate escape hatch: an application that needs to override a component writes a plain rule and it wins. An application that does *not* want to win by accident puts its CSS in `@layer app`.
58
64
 
@@ -0,0 +1,12 @@
1
+ import { createContext } from "react";
2
+ /**
3
+ * The shared side panel API threaded to the composed subcomponents. There is
4
+ * ONE panel instance per dialog — the subcomponents are render-only and read
5
+ * this context rather than being handed props, so a composed `SidePanel.Header`
6
+ * names the panel and closes it without the consumer wiring either by hand.
7
+ * Defaults to `null` so a part rendered outside a panel degrades rather than
8
+ * throws.
9
+ */
10
+ const Context = createContext(null);
11
+ export default Context;
12
+ //# sourceMappingURL=Context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../../src/lib/SidePanel/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;;;;GAOG;AACH,MAAM,OAAO,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AAElE,eAAe,OAAO,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, isValidElement, useId, useMemo } from "react";
3
+ import Context from "./Context.js";
4
+ import { Content, Footer, Header } from "./common/index.js";
5
+ import { useSidePanelDialog } from "./hooks/index.js";
6
+ import "./styles.css";
7
+ const componentCssClassName = "ds side-panel";
8
+ /**
9
+ * A panel docked to the inline-end edge of the viewport, for work that
10
+ * accompanies the current view rather than interrupting it.
11
+ *
12
+ * Structurally, the component is a context provider that renders the panel's
13
+ * markup: it wraps the `<dialog>` in the context its composed parts read,
14
+ * and keeps every piece of panel behaviour — open/close bookkeeping, focus
15
+ * handoff, the imperative handle — in `useSidePanelDialog`.
16
+ *
17
+ * It renders a **non-modal** `<dialog>` opened with `show()`, so the
18
+ * application behind stays clickable and tabbable.
19
+ *
20
+ * The panel is controlled through its `ref`: `open()` shows it and moves focus
21
+ * in, `close()` hides it and hands focus back, and `toggle()` switches between
22
+ * those states. The ref is required, since the handle is the only way in — a
23
+ * panel with no ref is a panel that can never open. The dialog's native open
24
+ * state is the single source of truth — there is no `open` prop to mirror it.
25
+ *
26
+ * The panel forwards the native dialog `onClose`: pass your own to hear about
27
+ * every close, whatever caused it — the handle's `close()`, Escape, or anything else.
28
+ *
29
+ * Compose the body from `SidePanel.Header`, `SidePanel.Content` and
30
+ * `SidePanel.Footer`. The panel lays them out as a flex column: header and
31
+ * footer keep their size, and the content pane takes the rest and scrolls
32
+ * within it. The content pane is a tab stop, so keyboard users can scroll it;
33
+ * opening the panel still focuses the panel itself, so from there Tab reaches
34
+ * the close button, then the content, then the footer's actions.
35
+ *
36
+ * There are two consumption patterns, `withSidePanel` and `SidePanel`.
37
+ * `withSidePanel` is meant for static content: the call belongs at module
38
+ * scope, where the function it is handed can only see module-level values, so
39
+ * the panel it returns is the same on every render. If the panel must show
40
+ * data from the parent — for example a different machine's details depending
41
+ * on which machine is selected — compose `SidePanel` directly and drive it
42
+ * through its `ref`. Otherwise, use `withSidePanel`.
43
+ *
44
+ * The panel is always named by its header's title, so the header is required
45
+ * — a panel composed without one gets a development warning. Note the title
46
+ * is not a heading element: the panel is a layer on top of the page, not
47
+ * part of its document outline.
48
+ *
49
+ * The panel is `position: fixed` and therefore out of the document flow: an
50
+ * `overflow: hidden` ancestor does not clip it
51
+ *
52
+ * Because the content pane scrolls and the panel is transformed, a
53
+ * `position: fixed` overlay rendered inside the panel is clipped at the
54
+ * pane's edge and positioned relative to the panel rather than the viewport.
55
+ * `Popover` currently follows that pattern, so keep it within the content
56
+ * pane's bounds.
57
+ *
58
+ * `ContextualMenu` instead portals its surface to `document.body`, escaping
59
+ * this clipping. When it must overlap the panel, give its overlay layer a
60
+ * z-index higher than `--side-panel-z-index`.
61
+ *
62
+ * `import { SidePanel } from "@canonical/react-ds-app";`
63
+ *
64
+ * @implements ds:apps.pattern.side_panel
65
+ */
66
+ const Provider = ({ children, ...props }) => {
67
+ const { className, close, dialogProps, dialogRef, handleKeyDown, handleClose, } = useSidePanelDialog(props);
68
+ // The header's title carries this id, and the dialog is labelled by it.
69
+ const titleId = useId();
70
+ // Memoised so the parts reading the context do not re-render every time
71
+ // the provider does.
72
+ const contextValue = useMemo(() => ({ close, titleId }), [close, titleId]);
73
+ // The header is required: its title is the panel's accessible name, and a
74
+ // panel without one cannot be named. Direct children only — a Header wrapped
75
+ // in a fragment escapes this check, and the warning is a nudge, not a gate.
76
+ if (typeof process !== "undefined" &&
77
+ process.env.NODE_ENV !== "production" &&
78
+ !Children.toArray(children).some((child) => isValidElement(child) && child.type === Header)) {
79
+ console.warn("SidePanel: the panel needs a SidePanel.Header — its title is the panel's accessible name.");
80
+ }
81
+ return (_jsx(Context.Provider, { value: contextValue, children: _jsx("dialog", { ref: dialogRef, className: [componentCssClassName, className].filter(Boolean).join(" "), "aria-labelledby": titleId,
82
+ // Focusable so that opening can place focus on the panel itself.
83
+ tabIndex: -1, onKeyDown: handleKeyDown, onClose: handleClose, ...dialogProps, children: children }) }));
84
+ };
85
+ Provider.Content = Content;
86
+ Provider.Footer = Footer;
87
+ Provider.Header = Header;
88
+ Provider.displayName = "SidePanel";
89
+ export default Provider;
90
+ //# sourceMappingURL=Provider.js.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;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,CAAC;IAC9B,wEAAwE;IACxE,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,wEAAwE;IACxE,qBAAqB;IACrB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3E,0EAA0E;IAC1E,6EAA6E;IAC7E,4EAA4E;IAC5E,IACE,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACrC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC9B,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAC1D,EACD,CAAC;QACD,OAAO,CAAC,IAAI,CACV,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACnC,iBACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,qBAOtD,OAAO;YACxB,iEAAiE;YACjE,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,WAAW,KAChB,WAAW,YAEd,QAAQ,GACF,GACQ,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3B,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AAEzB,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;AAEnC,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "./styles.css";
3
+ const componentCssClassName = "ds side-panel-content";
4
+ /**
5
+ * Body of a SidePanel, and the only part of it that scrolls: however tall its
6
+ * children are, the header and footer stay visible.
7
+ *
8
+ * The pane is its own scroll container, so it is a tab stop: a keyboard
9
+ * user tabs to it and scrolls it with the arrow and page keys, even when it
10
+ * holds nothing focusable.
11
+ *
12
+ * @implements ds:apps.subcomponent.side_panel-content
13
+ */
14
+ const Content = ({ children, className, fill = false, ...props }) => {
15
+ return (_jsx("div", { className: [componentCssClassName, fill && "fill", className]
16
+ .filter(Boolean)
17
+ .join(" "),
18
+ // A scroll container a keyboard user cannot focus cannot be scrolled,
19
+ // so the pane is a tab stop. Set before the spread, so the native prop
20
+ // can still take it out of the tab order.
21
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: focus is what makes the scroll region keyboard-operable.
22
+ tabIndex: 0, ...props, children: children }));
23
+ };
24
+ Content.displayName = "SidePanel.Content";
25
+ export default Content;
26
+ //# sourceMappingURL=Content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/Content.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,KAAK,EACZ,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,IAAI,IAAI,MAAM,EAAE,SAAS,CAAC;aAC1D,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC;QACZ,sEAAsE;QACtE,uEAAuE;QACvE,0CAA0C;QAC1C,4GAA4G;QAC5G,QAAQ,EAAE,CAAC,KACP,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAE1C,eAAe,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as Content } from "./Content.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,49 @@
1
+ /* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
2
+
3
+ @layer ds.components.apps {
4
+ .ds.side-panel-content {
5
+ /*
6
+ Natural height by default: the footer follows the content, so its actions
7
+ stay next to the text they refer to instead of being pushed to the bottom
8
+ edge of a short panel. Shrinks when the content is taller than the space
9
+ the header and footer leave — `overflow` below drops a flex item's
10
+ automatic minimum size to zero, so it can shrink below its content.
11
+ */
12
+ flex: 0 1 auto;
13
+
14
+ /* Opt-in: take the space the header and footer leave, so a short panel fills. */
15
+ &.fill {
16
+ flex-grow: 1;
17
+ }
18
+
19
+ /*
20
+ The scroll region, and the only one: the header and footer sit outside it
21
+ in the panel's flex column, so they stay visible without sticky
22
+ positioning.
23
+ */
24
+ overflow-y: auto;
25
+ /* Don't hand the scroll to the page behind once the content bottoms out. */
26
+ overscroll-behavior: contain;
27
+
28
+ /*
29
+ Inline padding, not margin: the pane must span the full panel width, so
30
+ its scrollbar hugs the panel edge and the focus ring below reaches it,
31
+ while the padding keeps the text clear of both.
32
+ */
33
+ padding-block: var(--side-panel-content-padding-block);
34
+ padding-inline: var(--side-panel-padding-inline);
35
+
36
+ /*
37
+ Focusable (Content.tsx sets `tabIndex`) so keyboard users can scroll it.
38
+ The panel clips its overflow, and the pane reaches the panel edges, so an
39
+ outset ring would be cut off: draw it inside the pane instead. The ring is
40
+ declared in full, because only a known width can be inset by exactly that
41
+ much — the user-agent ring's width varies by browser.
42
+ */
43
+ &:focus-visible {
44
+ outline: var(--side-panel-focus-ring-width) solid
45
+ var(--side-panel-color-focus-ring);
46
+ outline-offset: calc(-1 * var(--side-panel-focus-ring-width));
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "./styles.css";
3
+ const componentCssClassName = "ds side-panel-footer";
4
+ /**
5
+ * Footer for SidePanel. Never scrolls: it stays visible below
6
+ * `SidePanel.Content`, which scrolls on its own, so its actions are always
7
+ * reachable.
8
+ *
9
+ * @implements ds:apps.subcomponent.side_panel-footer
10
+ */
11
+ const Footer = ({ children, className, ...props }) => {
12
+ // A <div>, not a <footer>: a <footer> inside a <dialog> is exposed as a
13
+ // page-level contentinfo landmark, and the panel is non-modal, so the page's
14
+ // own contentinfo stays reachable beside it and would be duplicated.
15
+ return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: children }));
16
+ };
17
+ Footer.displayName = "SidePanel.Footer";
18
+ export default Footer;
19
+ //# sourceMappingURL=Footer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Footer.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/Footer.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,wEAAwE;IACxE,6EAA6E;IAC7E,qEAAqE;IACrE,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAER,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAExC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as Footer } from "./Footer.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,36 @@
1
+ /* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
2
+
3
+ @layer ds.components.apps {
4
+ .ds.side-panel-footer {
5
+ /*
6
+ Never shrinks. It stays visible because only the content pane scrolls —
7
+ the footer sits beside it in the panel's flex column, not over it.
8
+ */
9
+ flex: none;
10
+
11
+ /*
12
+ Closes the scroll region, marking where the content pane ends and the
13
+ actions begin.
14
+
15
+ The colour is the panel's to own, and is read without a local fallback so
16
+ the two cannot state different defaults: `--side-panel-color-border` is
17
+ declared in the panel's `:root` block.
18
+ */
19
+ border-block-start: var(--dimension-stroke-thickness-medium) solid
20
+ var(--side-panel-color-border);
21
+ /*
22
+ Inset by margin rather than padding: a border spans the padding box, so
23
+ padding would run the hairline edge to edge. The margin keeps it stopping
24
+ short of both panel edges, in line with the text column.
25
+ */
26
+ margin-inline: var(--side-panel-padding-inline);
27
+
28
+ display: flex;
29
+ justify-content: flex-end;
30
+ align-items: center;
31
+ gap: var(--side-panel-footer-gap);
32
+ flex-wrap: wrap;
33
+
34
+ padding-block: var(--side-panel-footer-padding-block);
35
+ }
36
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from "@canonical/react-ds-global";
3
+ import { useSidePanelContext } from "../../hooks/index.js";
4
+ import "./styles.css";
5
+ const componentCssClassName = "ds side-panel-header";
6
+ /**
7
+ * Header for SidePanel. Required: its title is the panel's accessible name,
8
+ * so a panel is not complete without one. Never scrolls: it stays visible
9
+ * above `SidePanel.Content`, which scrolls on its own.
10
+ *
11
+ * Owns the title the panel is labelled by, and the close button — which is
12
+ * wired through context, so rendering this outside a SidePanel yields a plain
13
+ * title rather than an error.
14
+ *
15
+ * The title is not a heading element: headings structure the page's document
16
+ * outline, and a panel opens from anywhere in it, so no heading level would be
17
+ * right everywhere. The title names the panel through `aria-labelledby`
18
+ * instead, which is what a screen reader announces when the panel opens.
19
+ *
20
+ * You choose the title's content, not the element it renders in: `children`
21
+ * always lands inside a Header-owned `<span class="title">`, which carries the
22
+ * `id` the panel's `aria-labelledby` points at — so the wrapper is fixed and
23
+ * not replaceable.
24
+ *
25
+ * @implements ds:apps.subcomponent.side_panel-header
26
+ */
27
+ const Header = ({ children, className, dismissLabel = "Close panel", undismissible = false, ...props }) => {
28
+ const context = useSidePanelContext();
29
+ // A <div>, not a <header>: a <header> inside a <dialog> is exposed as a
30
+ // page-level banner landmark, and the panel is non-modal, so the page's
31
+ // own banner stays reachable beside it and would be duplicated.
32
+ return (_jsxs("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsx("span", { className: "title p", id: context?.titleId, children: children }), context && !undismissible && (_jsx(Button, { className: "close", icon: "close", importance: "tertiary",
33
+ // A typeless <button> is type="submit": inside a <form> the panel
34
+ // would submit it. This control only closes the panel.
35
+ type: "button", onClick: context.close, "aria-label": dismissLabel }))] }));
36
+ };
37
+ Header.displayName = "SidePanel.Header";
38
+ export default Header;
39
+ //# sourceMappingURL=Header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/Header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,QAAQ,EACR,SAAS,EACT,YAAY,GAAG,aAAa,EAC5B,aAAa,GAAG,KAAK,EACrB,GAAG,KAAK,EACI,EAAsB,EAAE;IACpC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,wEAAwE;IACxE,wEAAwE;IACxE,gEAAgE;IAChE,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,aAET,eAAM,SAAS,EAAC,SAAS,EAAC,EAAE,EAAE,OAAO,EAAE,OAAO,YAC3C,QAAQ,GACJ,EACN,OAAO,IAAI,CAAC,aAAa,IAAI,CAC5B,KAAC,MAAM,IACL,SAAS,EAAC,OAAO,EACjB,IAAI,EAAC,OAAO,EACZ,UAAU,EAAC,UAAU;gBACrB,kEAAkE;gBAClE,uDAAuD;gBACvD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,CAAC,KAAK,gBAGV,YAAY,GACxB,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAExC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as Header } from "./Header.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,94 @@
1
+ /* Layer: ds.components.apps (@canonical/styles README, "Cascade layers"). */
2
+
3
+ @layer ds.components.apps {
4
+ .ds.side-panel-header {
5
+ /*
6
+ Title type — heading-2 for now. The tier is provisional: to change it,
7
+ swap the tier in these five lines and nothing else.
8
+
9
+ Declared here, not on :root: a var() inside a custom property resolves
10
+ where it is declared, and the typography tokens are redefined per
11
+ context (.app, .site, .docs). On :root these would capture the
12
+ page-level tier; here they resolve inside the panel's own context.
13
+ */
14
+ --side-panel-title-font-family: var(--typography-heading-2-font-family);
15
+ --side-panel-title-font-size: var(--typography-heading-2-font-size);
16
+ --side-panel-title-font-weight: var(--typography-heading-2-font-weight);
17
+ --side-panel-title-letter-spacing: var(
18
+ --typography-heading-2-letter-spacing
19
+ );
20
+ --side-panel-title-line-height: var(
21
+ --typography-heading-2-line-height-dimension
22
+ );
23
+
24
+ /*
25
+ Never shrinks. It stays visible because only the content pane scrolls —
26
+ the header sits beside it in the panel's flex column, not over it.
27
+ */
28
+ flex: none;
29
+
30
+ display: flex;
31
+ /*
32
+ Baseline-aligned: the close button sits on the title's baseline. The
33
+ browser lines the two baselines up itself, so nothing here needs to know
34
+ where the typography engine puts the title's baseline or where Button's
35
+ density seat puts its own.
36
+ */
37
+ align-items: baseline;
38
+ gap: var(--side-panel-header-gap);
39
+
40
+ padding-block: var(--side-panel-header-padding-block);
41
+ /*
42
+ Inline padding, not margin: nothing here needs the header's box itself
43
+ inset, and padding keeps it full panel width. The footer is the
44
+ exception — its border spans the padding box, so it insets with margin
45
+ (see Footer/styles.css).
46
+ */
47
+ padding-inline: var(--side-panel-padding-inline);
48
+
49
+ /*
50
+ The title is heading text beside a control, not a control: its line box
51
+ is taller than the density seat line, so the typography engine seats it
52
+ rather than the density seat. It carries `.p`, the engine's class hook
53
+ for an element that is not `p` or `h1`–`h6`; this rule feeds the engine
54
+ the title's type in place of the paragraph values `.p` brings.
55
+ */
56
+ > .title {
57
+ flex: 1 1 auto;
58
+ --font-size: var(--side-panel-title-font-size);
59
+ --font-weight: var(--side-panel-title-font-weight);
60
+ --line-height: var(--side-panel-title-line-height);
61
+ /* No element-owned space below, even inside an `.editorial` ancestor. */
62
+ --space-after: 0;
63
+ font-family: var(--side-panel-title-font-family);
64
+ letter-spacing: var(--side-panel-title-letter-spacing);
65
+ }
66
+
67
+ > .close {
68
+ flex: 0 0 auto;
69
+ /*
70
+ Button tightens padding-inline-start when it has an icon, which suits an
71
+ icon+label button but leaves an icon-only one lopsided (8px vs 16px).
72
+ Equalise both sides through Button's own custom-property API, as
73
+ Modal's header does.
74
+ */
75
+ --button-padding-inline-start: var(--dimension-100);
76
+ --button-padding-inline-end: var(--dimension-100);
77
+
78
+ /*
79
+ An icon-only button has no text, so it has no baseline of its own and
80
+ the browser would make one up from the icon's box. A zero-width
81
+ character gives it a line of text in its seat line, so its baseline
82
+ lands where a label's would. The pseudo-element is a flex item like the
83
+ icon, so the gap is cancelled to keep the button's size.
84
+
85
+ Temporary: remove once icon-only buttons carry a seated baseline of
86
+ their own.
87
+ */
88
+ &::before {
89
+ content: "\200b";
90
+ margin-inline-end: calc(-1 * var(--button-gap));
91
+ }
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from "./Content/index.js";
2
+ export * from "./Footer/index.js";
3
+ export * from "./Header/index.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./types.js";
2
+ export { default as useSidePanelContext } from "./useSidePanelContext.js";
3
+ export { default as useSidePanelDialog } from "./useSidePanelDialog.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { useContext } from "react";
2
+ import Context from "../Context.js";
3
+ /**
4
+ * Read the panel API. Returns `null` outside a SidePanel so that a part can
5
+ * degrade — `Header` simply omits its close button — rather than throwing.
6
+ */
7
+ export const useSidePanelContext = () => useContext(Context);
8
+ export default useSidePanelContext;
9
+ //# sourceMappingURL=useSidePanelContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSidePanelContext.js","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/useSidePanelContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,eAAe,CAAC;AAGpC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAiC,EAAE,CACpE,UAAU,CAAC,OAAO,CAAC,CAAC;AAEtB,eAAe,mBAAmB,CAAC"}