@canonical/react-ds-app 0.40.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 (109) hide show
  1. package/README.md +9 -3
  2. package/dist/esm/lib/ContentLayout/styles.css +1 -1
  3. package/dist/esm/lib/SideNavigation/SideNavigation.js +1 -7
  4. package/dist/esm/lib/SideNavigation/SideNavigation.js.map +1 -1
  5. package/dist/esm/lib/SideNavigation/common/Item/Item.js +1 -1
  6. package/dist/esm/lib/SideNavigation/helpItem.js.map +1 -1
  7. package/dist/esm/lib/SidePanel/Context.js +12 -0
  8. package/dist/esm/lib/SidePanel/Context.js.map +1 -0
  9. package/dist/esm/lib/SidePanel/Provider.js +90 -0
  10. package/dist/esm/lib/SidePanel/Provider.js.map +1 -0
  11. package/dist/esm/lib/SidePanel/common/Content/Content.js +26 -0
  12. package/dist/esm/lib/SidePanel/common/Content/Content.js.map +1 -0
  13. package/dist/esm/lib/SidePanel/common/Content/index.js +2 -0
  14. package/dist/esm/lib/SidePanel/common/Content/index.js.map +1 -0
  15. package/dist/esm/lib/SidePanel/common/Content/styles.css +49 -0
  16. package/dist/esm/lib/SidePanel/common/Content/types.js +2 -0
  17. package/dist/esm/lib/SidePanel/common/Content/types.js.map +1 -0
  18. package/dist/esm/lib/SidePanel/common/Footer/Footer.js +19 -0
  19. package/dist/esm/lib/SidePanel/common/Footer/Footer.js.map +1 -0
  20. package/dist/esm/lib/SidePanel/common/Footer/index.js +2 -0
  21. package/dist/esm/lib/SidePanel/common/Footer/index.js.map +1 -0
  22. package/dist/esm/lib/SidePanel/common/Footer/styles.css +36 -0
  23. package/dist/esm/lib/SidePanel/common/Footer/types.js +2 -0
  24. package/dist/esm/lib/SidePanel/common/Footer/types.js.map +1 -0
  25. package/dist/esm/lib/SidePanel/common/Header/Header.js +39 -0
  26. package/dist/esm/lib/SidePanel/common/Header/Header.js.map +1 -0
  27. package/dist/esm/lib/SidePanel/common/Header/index.js +2 -0
  28. package/dist/esm/lib/SidePanel/common/Header/index.js.map +1 -0
  29. package/dist/esm/lib/SidePanel/common/Header/styles.css +94 -0
  30. package/dist/esm/lib/SidePanel/common/Header/types.js +2 -0
  31. package/dist/esm/lib/SidePanel/common/Header/types.js.map +1 -0
  32. package/dist/esm/lib/SidePanel/common/index.js +4 -0
  33. package/dist/esm/lib/SidePanel/common/index.js.map +1 -0
  34. package/dist/esm/lib/SidePanel/hooks/index.js +4 -0
  35. package/dist/esm/lib/SidePanel/hooks/index.js.map +1 -0
  36. package/dist/esm/lib/SidePanel/hooks/types.js +2 -0
  37. package/dist/esm/lib/SidePanel/hooks/types.js.map +1 -0
  38. package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js +9 -0
  39. package/dist/esm/lib/SidePanel/hooks/useSidePanelContext.js.map +1 -0
  40. package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js +134 -0
  41. package/dist/esm/lib/SidePanel/hooks/useSidePanelDialog.js.map +1 -0
  42. package/dist/esm/lib/SidePanel/index.js +4 -0
  43. package/dist/esm/lib/SidePanel/index.js.map +1 -0
  44. package/dist/esm/lib/SidePanel/styles.css +192 -0
  45. package/dist/esm/lib/SidePanel/types.js +2 -0
  46. package/dist/esm/lib/SidePanel/types.js.map +1 -0
  47. package/dist/esm/lib/SidePanel/withSidePanel.js +98 -0
  48. package/dist/esm/lib/SidePanel/withSidePanel.js.map +1 -0
  49. package/dist/esm/lib/index.js +1 -0
  50. package/dist/esm/lib/index.js.map +1 -1
  51. package/dist/types/lib/ApplicationLayout/ApplicationLayout.d.ts.map +1 -1
  52. package/dist/types/lib/ContentLayout/ContentLayout.d.ts.map +1 -1
  53. package/dist/types/lib/ContentLayout/types.d.ts +1 -1
  54. package/dist/types/lib/SideNavigation/SideNavigation.d.ts.map +1 -1
  55. package/dist/types/lib/SideNavigation/common/CollapseToggle/CollapseToggle.d.ts.map +1 -1
  56. package/dist/types/lib/SideNavigation/common/Content/Content.d.ts.map +1 -1
  57. package/dist/types/lib/SideNavigation/common/ContextSwitcher/ContextSwitcher.d.ts.map +1 -1
  58. package/dist/types/lib/SideNavigation/common/Footer/Footer.d.ts.map +1 -1
  59. package/dist/types/lib/SideNavigation/common/Group/Group.d.ts.map +1 -1
  60. package/dist/types/lib/SideNavigation/common/GroupHeader/GroupHeader.d.ts.map +1 -1
  61. package/dist/types/lib/SideNavigation/common/Header/Header.d.ts.map +1 -1
  62. package/dist/types/lib/SideNavigation/common/Item/Item.d.ts.map +1 -1
  63. package/dist/types/lib/SideNavigation/common/ItemButton/ItemButton.d.ts.map +1 -1
  64. package/dist/types/lib/SideNavigation/common/ItemExpandable/ItemExpandable.d.ts.map +1 -1
  65. package/dist/types/lib/SideNavigation/common/NavTree/NavTree.d.ts.map +1 -1
  66. package/dist/types/lib/SideNavigation/helpItem.d.ts.map +1 -1
  67. package/dist/types/lib/SideNavigation/hooks/useCollapseShortcut/useCollapseShortcut.d.ts.map +1 -1
  68. package/dist/types/lib/SidePanel/Context.d.ts +12 -0
  69. package/dist/types/lib/SidePanel/Context.d.ts.map +1 -0
  70. package/dist/types/lib/SidePanel/Provider.d.ts +13 -0
  71. package/dist/types/lib/SidePanel/Provider.d.ts.map +1 -0
  72. package/dist/types/lib/SidePanel/common/Content/Content.d.ts +9 -0
  73. package/dist/types/lib/SidePanel/common/Content/Content.d.ts.map +1 -0
  74. package/dist/types/lib/SidePanel/common/Content/index.d.ts +3 -0
  75. package/dist/types/lib/SidePanel/common/Content/index.d.ts.map +1 -0
  76. package/dist/types/lib/SidePanel/common/Content/types.d.ts +21 -0
  77. package/dist/types/lib/SidePanel/common/Content/types.d.ts.map +1 -0
  78. package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts +9 -0
  79. package/dist/types/lib/SidePanel/common/Footer/Footer.d.ts.map +1 -0
  80. package/dist/types/lib/SidePanel/common/Footer/index.d.ts +3 -0
  81. package/dist/types/lib/SidePanel/common/Footer/index.d.ts.map +1 -0
  82. package/dist/types/lib/SidePanel/common/Footer/types.d.ts +14 -0
  83. package/dist/types/lib/SidePanel/common/Footer/types.d.ts.map +1 -0
  84. package/dist/types/lib/SidePanel/common/Header/Header.d.ts +9 -0
  85. package/dist/types/lib/SidePanel/common/Header/Header.d.ts.map +1 -0
  86. package/dist/types/lib/SidePanel/common/Header/index.d.ts +3 -0
  87. package/dist/types/lib/SidePanel/common/Header/index.d.ts.map +1 -0
  88. package/dist/types/lib/SidePanel/common/Header/types.d.ts +35 -0
  89. package/dist/types/lib/SidePanel/common/Header/types.d.ts.map +1 -0
  90. package/dist/types/lib/SidePanel/common/index.d.ts +4 -0
  91. package/dist/types/lib/SidePanel/common/index.d.ts.map +1 -0
  92. package/dist/types/lib/SidePanel/hooks/index.d.ts +4 -0
  93. package/dist/types/lib/SidePanel/hooks/index.d.ts.map +1 -0
  94. package/dist/types/lib/SidePanel/hooks/types.d.ts +28 -0
  95. package/dist/types/lib/SidePanel/hooks/types.d.ts.map +1 -0
  96. package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts +8 -0
  97. package/dist/types/lib/SidePanel/hooks/useSidePanelContext.d.ts.map +1 -0
  98. package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts +12 -0
  99. package/dist/types/lib/SidePanel/hooks/useSidePanelDialog.d.ts.map +1 -0
  100. package/dist/types/lib/SidePanel/index.d.ts +4 -0
  101. package/dist/types/lib/SidePanel/index.d.ts.map +1 -0
  102. package/dist/types/lib/SidePanel/types.d.ts +97 -0
  103. package/dist/types/lib/SidePanel/types.d.ts.map +1 -0
  104. package/dist/types/lib/SidePanel/withSidePanel.d.ts +76 -0
  105. package/dist/types/lib/SidePanel/withSidePanel.d.ts.map +1 -0
  106. package/dist/types/lib/ViewLayout/ViewLayout.d.ts.map +1 -1
  107. package/dist/types/lib/index.d.ts +1 -0
  108. package/dist/types/lib/index.d.ts.map +1 -1
  109. package/package.json +28 -27
@@ -0,0 +1,21 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ type OwnProps = {
3
+ /** Panel body. This is the only region that scrolls. */
4
+ children: ReactNode;
5
+ /**
6
+ * Grow the content to take the space the header and footer leave, so a
7
+ * short panel pushes its footer to the bottom edge. Defaults to false: the
8
+ * content keeps its natural height and the footer follows it, so the
9
+ * actions sit next to the text they refer to rather than at a distance.
10
+ */
11
+ fill?: boolean;
12
+ };
13
+ /**
14
+ * Props for SidePanel.Content.
15
+ *
16
+ * Props extend the native props of the `<div>` root, so every attribute it
17
+ * accepts (data-*, aria-*, event handlers, …) reaches the DOM.
18
+ */
19
+ export type ContentProps = OwnProps & Omit<ComponentProps<"div">, keyof OwnProps>;
20
+ export {};
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Content/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,KAAK,QAAQ,GAAG;IACd,wDAAwD;IACxD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GACjC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type React from "react";
2
+ import type { FooterProps } from "./types.js";
3
+ import "./styles.css";
4
+ declare function Footer({ children, className, ...props }: FooterProps): React.ReactElement;
5
+ declare namespace Footer {
6
+ var displayName: string;
7
+ }
8
+ export default Footer;
9
+ //# sourceMappingURL=Footer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Footer.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/Footer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,cAAc,CAAC;wBAWN,EACd,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY;;;;eAgBpB,MAAM"}
@@ -0,0 +1,3 @@
1
+ export { default as Footer } from "./Footer.js";
2
+ export type { FooterProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ type OwnProps = {
3
+ /** Actions for the panel, laid out inline and aligned to the end edge. */
4
+ children: ReactNode;
5
+ };
6
+ /**
7
+ * Props for SidePanel.Footer.
8
+ *
9
+ * Props extend the native props of the `<div>` root, so every attribute it
10
+ * accepts (data-*, aria-*, event handlers, …) reaches the DOM.
11
+ */
12
+ export type FooterProps = OwnProps & Omit<ComponentProps<"div">, keyof OwnProps>;
13
+ export {};
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Footer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,KAAK,QAAQ,GAAG;IACd,0EAA0E;IAC1E,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type React from "react";
2
+ import type { HeaderProps } from "./types.js";
3
+ import "./styles.css";
4
+ declare function Header({ children, className, dismissLabel, undismissible, ...props }: HeaderProps): React.ReactElement;
5
+ declare namespace Header {
6
+ var displayName: string;
7
+ }
8
+ export default Header;
9
+ //# sourceMappingURL=Header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/Header.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,cAAc,CAAC;wBAyBN,EACd,QAAQ,EACR,SAAS,EACT,YAA4B,EAC5B,aAAqB,EACrB,GAAG,KAAK,EACT,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY;;;;eAkCpB,MAAM"}
@@ -0,0 +1,3 @@
1
+ export { default as Header } from "./Header.js";
2
+ export type { HeaderProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ type OwnProps = {
3
+ /**
4
+ * Title content. Names the panel for assistive technology.
5
+ *
6
+ * The title is deliberately not a heading element: the panel is a layer on
7
+ * top of the page, not part of its document outline, so it names the dialog
8
+ * through `aria-labelledby` instead.
9
+ *
10
+ * Content only — the element is fixed: `children` renders inside a
11
+ * Header-owned `<span class="title">` carrying the `id` that
12
+ * `aria-labelledby` points at, so the wrapper cannot be swapped for a
13
+ * consumer element.
14
+ */
15
+ children: ReactNode;
16
+ /**
17
+ * Accessible name for the close button.
18
+ * @default "Close panel"
19
+ */
20
+ dismissLabel?: string;
21
+ /**
22
+ * Hide the close button, for a panel dismissed only from its footer.
23
+ * @default false
24
+ */
25
+ undismissible?: boolean;
26
+ };
27
+ /**
28
+ * Props for SidePanel.Header.
29
+ *
30
+ * Props extend the native props of the `<div>` root, so every attribute it
31
+ * accepts (data-*, aria-*, event handlers, …) reaches the DOM.
32
+ */
33
+ export type HeaderProps = OwnProps & Omit<ComponentProps<"div">, keyof OwnProps>;
34
+ export {};
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/SidePanel/common/Header/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,KAAK,QAAQ,GAAG;IACd;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -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.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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,28 @@
1
+ import type React from "react";
2
+ import type { RefObject } from "react";
3
+ import type { SidePanelProviderProps } from "../types.js";
4
+ /**
5
+ * The props the dialog hook receives: every SidePanel prop except `children`,
6
+ * which the provider renders itself rather than handing to the hook.
7
+ */
8
+ export type UseSidePanelDialogProps = Omit<SidePanelProviderProps, "children">;
9
+ /**
10
+ * What the dialog hook hands back. Helpers and plumbing only — the hook holds
11
+ * no open state, so there is no state object to return; the dialog's native
12
+ * state is the only source of truth.
13
+ */
14
+ export type UseSidePanelDialogResult = {
15
+ /** The consumer's class name, for the provider to merge with its own. */
16
+ className: string | undefined;
17
+ /** Close the panel — the same action the imperative handle exposes. */
18
+ close: () => void;
19
+ /** Every remaining native dialog attribute, spread onto the element. */
20
+ dialogProps: Omit<UseSidePanelDialogProps, "onKeyDown" | "onClose" | "ref" | "className">;
21
+ /** The dialog the provider renders; open/close run through it. */
22
+ dialogRef: RefObject<HTMLDialogElement | null>;
23
+ /** Keydown wiring: consumer handler first, then Escape dismissal. */
24
+ handleKeyDown: (event: React.KeyboardEvent<HTMLDialogElement>) => void;
25
+ /** The dialog's `close` event funnels here, whatever caused it. */
26
+ handleClose: (event: React.SyntheticEvent<HTMLDialogElement>) => void;
27
+ };
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,yEAAyE;IACzE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,uEAAuE;IACvE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,wEAAwE;IACxE,WAAW,EAAE,IAAI,CACf,uBAAuB,EACvB,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,CAC9C,CAAC;IACF,kEAAkE;IAClE,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,qEAAqE;IACrE,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACvE,mEAAmE;IACnE,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { SidePanelContextValue } from "../types.js";
2
+ /**
3
+ * Read the panel API. Returns `null` outside a SidePanel so that a part can
4
+ * degrade — `Header` simply omits its close button — rather than throwing.
5
+ */
6
+ export declare const useSidePanelContext: () => SidePanelContextValue | null;
7
+ export default useSidePanelContext;
8
+ //# sourceMappingURL=useSidePanelContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSidePanelContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/useSidePanelContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,qBAAqB,GAAG,IAC1C,CAAC;eAEP,mBAAmB"}
@@ -0,0 +1,12 @@
1
+ import type { UseSidePanelDialogProps, UseSidePanelDialogResult } from "./types.js";
2
+ /**
3
+ * The dialog behaviour of the SidePanel provider: open/close bookkeeping,
4
+ * focus handoff, Escape, and the imperative handle. It holds no open state —
5
+ * the dialog's native state is the only source of truth — and returns only
6
+ * the plumbing the provider needs: the element ref, the `close` action, the
7
+ * consumer's class name, the remaining native attributes, and the event
8
+ * wiring.
9
+ */
10
+ declare const useSidePanelDialog: ({ onKeyDown, onClose, ref, className, ...dialogProps }: UseSidePanelDialogProps) => UseSidePanelDialogResult;
11
+ export default useSidePanelDialog;
12
+ //# sourceMappingURL=useSidePanelDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSidePanelDialog.d.ts","sourceRoot":"","sources":["../../../../../src/lib/SidePanel/hooks/useSidePanelDialog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,2DAMrB,uBAAuB,KAAG,wBA0I5B,CAAC;eAEa,kBAAkB"}
@@ -0,0 +1,4 @@
1
+ export { default as SidePanel } from "./Provider.js";
2
+ export * from "./types.js";
3
+ export { default as withSidePanel } from "./withSidePanel.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/SidePanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,97 @@
1
+ import type { ComponentProps, MouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
2
+ /** The small API a SidePanel threads down to its header, content and footer. */
3
+ export interface SidePanelContextValue {
4
+ /** Close the panel. */
5
+ close: () => void;
6
+ /** Id the panel is labelled by. `Header` puts it on its title. */
7
+ titleId: string;
8
+ }
9
+ /**
10
+ * The imperative handle a SidePanel exposes through its `ref`.
11
+ *
12
+ * The panel is controlled through this handle rather than an `open` prop: the
13
+ * `<dialog>` element's own open state is the only source of truth, and the
14
+ * handle drives it directly — nothing to mirror, nothing to desync.
15
+ */
16
+ export interface SidePanelHandle {
17
+ /** Open the panel and move focus into it. A no-op while already open. */
18
+ open: () => void;
19
+ /**
20
+ * Close the panel and hand focus back to where it was before the panel
21
+ * opened. A no-op while already closed.
22
+ */
23
+ close: () => void;
24
+ /** Open the panel if closed, or close it if open. */
25
+ toggle: () => void;
26
+ /** The underlying `<dialog>`, for anything the handle does not cover. */
27
+ element: HTMLDialogElement | null;
28
+ }
29
+ type OwnProps = {
30
+ /**
31
+ * Panel contents. Compose from `SidePanel.Header`, `SidePanel.Content` and
32
+ * `SidePanel.Footer`; the header and footer stay put while the content
33
+ * scrolls. The header is required: its title names the panel, and the
34
+ * provider warns in development when it is missing.
35
+ */
36
+ children: ReactNode;
37
+ /**
38
+ * The panel's imperative handle, and the only way the panel opens:
39
+ * `ref.current?.open()`, with `ref.current?.close()` closing it, and
40
+ * `ref.current?.toggle()` switching it between those states.
41
+ */
42
+ ref: Ref<SidePanelHandle>;
43
+ };
44
+ /**
45
+ * Props for the SidePanel provider.
46
+ *
47
+ * The panel is opened and closed through the imperative `ref` handle, not an
48
+ * `open` prop: the dialog's native open state is the single source of truth.
49
+ * Do not set the native `open` attribute — it is omitted from the surface
50
+ * precisely so the panel's bookkeeping (focus handoff) cannot be bypassed.
51
+ *
52
+ * Props extend the native props of the `<dialog>` root, so every attribute it
53
+ * accepts reaches the DOM. That includes the dialog's own `onClose`: pass your
54
+ * own to hear about every close. The panel's bookkeeping runs after the handler.
55
+ *
56
+ * The panel is always named by its header's title, so `children` must include
57
+ * a `SidePanel.Header` — the provider warns in development when it does not.
58
+ */
59
+ export type SidePanelProviderProps = OwnProps & Omit<ComponentProps<"dialog">, keyof OwnProps | "open">;
60
+ /**
61
+ * The one requirement {@link withSidePanel} places on the component it wraps:
62
+ * it must accept an `onClick` handler. A trigger that accepts
63
+ * `onClick` but never forwards it to a clickable element never toggles its
64
+ * panel. An `onClick` the consumer passes still runs: the HOC calls it first,
65
+ * then toggles the panel, unless the handler calls `event.preventDefault()`.
66
+ */
67
+ export type WithSidePanelTriggerProps = {
68
+ onClick?(event: MouseEvent): void;
69
+ };
70
+ /**
71
+ * What {@link withSidePanel} hands a {@link WithSidePanelRender} function: a
72
+ * props object.
73
+ */
74
+ export type WithSidePanelRenderProps = {
75
+ /** Closes the panel. What a footer button wires its `onClick` to. */
76
+ close: () => void;
77
+ /**
78
+ * The handle on the panel the trigger toggles. The factory MUST set it on
79
+ * the `<SidePanel>` it returns — `<SidePanel ref={ref}>`. `SidePanel`
80
+ * requires its `ref`, so a factory that forgets it fails to compile.
81
+ */
82
+ ref: RefObject<SidePanelHandle | null>;
83
+ };
84
+ /**
85
+ * **Every factory must attach the `ref` it receives to the `<SidePanel>` it
86
+ * returns.** The trigger toggles the panel through that ref. `SidePanel`
87
+ * requires its `ref`, so a factory that forgets it fails to compile:
88
+ *
89
+ * `({ ref }) => <SidePanel ref={ref}>…</SidePanel>`
90
+ *
91
+ * or, with a footer button that closes the panel:
92
+ *
93
+ * `({ close, ref }) => <SidePanel ref={ref}><SidePanel.Footer><Button onClick={close}>Done</Button></SidePanel.Footer></SidePanel>`
94
+ */
95
+ export type WithSidePanelRender = (props: WithSidePanelRenderProps) => ReactElement<SidePanelProviderProps>;
96
+ export {};
97
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/SidePanel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EACT,GAAG,EACH,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,uBAAuB;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,qDAAqD;IACrD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,yEAAyE;IACzE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACnC;AAED,KAAK,QAAQ,GAAG;IACd;;;;;OAKG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAC3C,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,qEAAqE;IACrE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;OAIG;IACH,GAAG,EAAE,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,KAAK,EAAE,wBAAwB,KAC5B,YAAY,CAAC,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,76 @@
1
+ import type { ComponentType } from "react";
2
+ import type { WithSidePanelRender, WithSidePanelTriggerProps } from "./types.js";
3
+ /**
4
+ * Wraps a trigger with a panel it toggles. Click the trigger → the panel
5
+ * opens; click it again → the panel closes.
6
+ *
7
+ * **The wrapped component must accept `onClick`** and forward it to the
8
+ * clickable element at its root — the HOC composes its toggle handler onto
9
+ * the trigger itself, with no wrapper element in between. An `onClick` the
10
+ * consumer passes keeps working: it runs first, then the panel toggles, unless
11
+ * the handler calls `event.preventDefault()`, which cancels the toggle.
12
+ *
13
+ * The second argument is a function: the HOC calls it with a props object
14
+ * carrying `close` and `ref`, and it returns a complete `<SidePanel>`
15
+ * element — sections, props and all:
16
+ *
17
+ * ```tsx
18
+ * const ToggleButton = withSidePanel(
19
+ * Button,
20
+ * ({ ref }) => (
21
+ * <SidePanel ref={ref}>
22
+ * <SidePanel.Header>Filters</SidePanel.Header>
23
+ * <SidePanel.Content>…</SidePanel.Content>
24
+ * </SidePanel>
25
+ * ),
26
+ * );
27
+ * <ToggleButton>Filters</ToggleButton>;
28
+ * ```
29
+ *
30
+ * Everything `SidePanel` accepts lives on the element the function returns —
31
+ * `aria-label`, `onClose`, `className` — so the
32
+ * consumer sees the real panel, not an options bag. **One duty comes with
33
+ * that freedom: the factory must attach the `ref` it receives to the
34
+ * `<SidePanel>`** (`<SidePanel ref={ref}>`). The trigger toggles the panel
35
+ * through that ref — and `SidePanel` requires its `ref`, so a factory that
36
+ * forgets it fails to compile.
37
+ *
38
+ * **How it closes:** the trigger toggles it; the header's X button and
39
+ * Escape dismiss it too — the HOC has no state to be told about, the
40
+ * dialog's native open state is the only one. A footer button can close it
41
+ * as well — wire one to the `close` the function receives:
42
+ *
43
+ * ```tsx
44
+ * const machinePanel: WithSidePanelRender = ({ close, ref }) => (
45
+ * <SidePanel ref={ref}>
46
+ * <SidePanel.Header>Add machine</SidePanel.Header>
47
+ * <SidePanel.Footer>
48
+ * <Button onClick={close}>Cancel</Button>
49
+ * </SidePanel.Footer>
50
+ * </SidePanel>
51
+ * );
52
+ *
53
+ * const AddMachine = withSidePanel(Button, machinePanel);
54
+ * ```
55
+ *
56
+ * `withSidePanel` is meant for static content and belongs at module scope,
57
+ * called once. The function it is handed is invoked on every render of the
58
+ * trigger, but at module scope it can only see module-level values, so what
59
+ * it returns is the same on every render. If the panel must show data from
60
+ * the parent — for example a different machine depending on which is
61
+ * selected — don't call this HOC inside the component; compose `SidePanel`
62
+ * directly and drive it through its `ref`.
63
+ *
64
+ * A pure composition wrapper: it renders the wrapped component and the panel
65
+ * as siblings, so it carries no root element of its own. The panel is
66
+ * `position: fixed`, so where in the tree they sit does not move it — but
67
+ * providers above that spot must still cover the panel's content.
68
+ *
69
+ * `import { withSidePanel } from "@canonical/react-ds-app";`
70
+ *
71
+ * @param Trigger The component that toggles the panel (e.g. `Button`). It must accept `onClick` and forward it to its root element; clicking it toggles the panel.
72
+ * @param panel A {@link WithSidePanelRender} function: it receives `{ close, ref }`, must attach `ref` to the `<SidePanel>` it returns, and the trigger toggles it.
73
+ */
74
+ declare const withSidePanel: <TProps extends WithSidePanelTriggerProps>(Trigger: ComponentType<TProps>, panel: WithSidePanelRender) => ComponentType<TProps>;
75
+ export default withSidePanel;
76
+ //# sourceMappingURL=withSidePanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withSidePanel.d.ts","sourceRoot":"","sources":["../../../../src/lib/SidePanel/withSidePanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAEV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,QAAA,MAAM,aAAa,GAAI,MAAM,SAAS,yBAAyB,WACpD,aAAa,CAAC,MAAM,CAAC,SACvB,mBAAmB,KACzB,aAAa,CAAC,MAAM,CAmCtB,CAAC;eAEa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewLayout.d.ts","sourceRoot":"","sources":["../../../../src/lib/ViewLayout/ViewLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,cAAc,CAAC;AAItB;;;;;;GAMG;AACH,QAAA,MAAM,UAAU,GAAI,0CAKjB,eAAe,KAAG,KAAK,CAAC,YAU1B,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"ViewLayout.d.ts","sourceRoot":"","sources":["../../../../src/lib/ViewLayout/ViewLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,cAAc,CAAC;AAItB;;;;;;GAMG;AACH,QAAA,MAAM,UAAU,6CAKb,eAAe,KAAG,KAAK,CAAC,YAU1B,CAAC;eAEa,UAAU"}
@@ -1,5 +1,6 @@
1
1
  export * from "./ApplicationLayout/index.js";
2
2
  export * from "./ContentLayout/index.js";
3
3
  export * from "./SideNavigation/index.js";
4
+ export * from "./SidePanel/index.js";
4
5
  export * from "./ViewLayout/index.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-ds-app",
3
- "version": "0.40.0",
3
+ "version": "0.43.0",
4
4
  "type": "module",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -13,13 +13,13 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/canonical/pragma"
16
+ "url": "https://github.com/canonical/pragma-web"
17
17
  },
18
18
  "license": "LGPL-3.0",
19
19
  "bugs": {
20
- "url": "https://github.com/canonical/pragma/issues"
20
+ "url": "https://github.com/canonical/pragma-web/issues"
21
21
  },
22
- "homepage": "https://github.com/canonical/pragma#readme",
22
+ "homepage": "https://github.com/canonical/pragma-web#readme",
23
23
  "scripts": {
24
24
  "build": "bun run build:package",
25
25
  "build:all": "bun run build:package && bun run build:storybook",
@@ -39,13 +39,13 @@
39
39
  "test:vitest:watch": "vitest"
40
40
  },
41
41
  "dependencies": {
42
- "@canonical/ds-assets": "^0.40.0",
43
- "@canonical/ds-types": "^0.40.0",
44
- "@canonical/ds-utils": "^0.40.0",
45
- "@canonical/react-ds-global": "^0.40.0",
46
- "@canonical/react-hooks": "^0.40.0",
47
- "@canonical/storybook-config": "^0.40.0",
48
- "@canonical/styles": "^0.40.0",
42
+ "@canonical/ds-assets": "^0.43.0",
43
+ "@canonical/ds-types": "^0.43.0",
44
+ "@canonical/ds-utils": "^0.43.0",
45
+ "@canonical/react-ds-global": "^0.43.0",
46
+ "@canonical/react-hooks": "^0.43.0",
47
+ "@canonical/storybook-config": "^0.43.0",
48
+ "@canonical/styles": "^0.43.0",
49
49
  "react": "^19.2.4",
50
50
  "react-dom": "^19.2.4"
51
51
  },
@@ -62,19 +62,20 @@
62
62
  }
63
63
  },
64
64
  "devDependencies": {
65
- "@biomejs/biome": "2.5.13",
66
- "@canonical/biome-config": "^0.40.0",
67
- "@canonical/design-tokens": "0.10.0",
68
- "@canonical/router-core": "^0.40.0",
69
- "@canonical/router-react": "^0.40.0",
70
- "@canonical/storybook-addon-utils": "^0.40.0",
71
- "@canonical/storybook-helpers": "^0.40.0",
72
- "@canonical/typescript-config-react": "^0.40.0",
73
- "@canonical/vitest-config-react": "^0.40.0",
74
- "@canonical/webarchitect": "^0.40.0",
65
+ "@biomejs/biome": "2.5.14",
66
+ "@canonical/biome-config": "0.43.0",
67
+ "@canonical/design-tokens": "0.43.0",
68
+ "@canonical/react-ds-global-form": "^0.43.0",
69
+ "@canonical/router-core": "^0.43.0",
70
+ "@canonical/router-react": "^0.43.0",
71
+ "@canonical/storybook-addon-utils": "^0.43.0",
72
+ "@canonical/storybook-helpers": "^0.43.0",
73
+ "@canonical/typescript-config-react": "^0.43.0",
74
+ "@canonical/vitest-config-react": "^0.43.0",
75
+ "@canonical/webarchitect": "0.43.0",
75
76
  "@chromatic-com/storybook": "^5.0.1",
76
- "@storybook/addon-docs": "^10.3.1",
77
- "@storybook/react-vite": "^10.3.1",
77
+ "@storybook/addon-docs": "^10.6.0",
78
+ "@storybook/react-vite": "^10.6.0",
78
79
  "@testing-library/jest-dom": "^7.0.0",
79
80
  "@testing-library/react": "^16.3.2",
80
81
  "@types/node": "^26.0.0",
@@ -84,10 +85,10 @@
84
85
  "copyfiles": "^2.4.1",
85
86
  "globals": "^17.4.0",
86
87
  "jsdom": "^28.1.0",
87
- "storybook": "^10.3.1",
88
- "typescript": "^5.9.3",
88
+ "storybook": "^10.6.0",
89
+ "typescript": "^7.0.2",
89
90
  "vite": "^8.0.1",
90
- "vitest": "^4.0.18"
91
+ "vitest": "^5.0.0"
91
92
  },
92
- "gitHead": "9136b71518260c5f33e7619da087198c931e4c13"
93
+ "gitHead": "581682464ef71de3f77dc2dc8bbe2b7e493bb05e"
93
94
  }