@canonical/maas-react-components 2.4.0 → 2.5.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.
@@ -34,4 +34,9 @@ import { ReactElement } from 'react';
34
34
  * openSidePanel({ component: EditForm, title: "Edit item", size: "wide" });
35
35
  * ```
36
36
  */
37
- export declare const SidePanel: () => ReactElement;
37
+ export declare const SidePanel: {
38
+ (): ReactElement;
39
+ Skeleton: ({ hasTitle }: {
40
+ hasTitle?: boolean;
41
+ }) => ReactElement;
42
+ };
@@ -8,3 +8,5 @@ export declare const Default: Story;
8
8
  export declare const NarrowSize: Story;
9
9
  export declare const WideSize: Story;
10
10
  export declare const LargeSize: Story;
11
+ export declare const Skeleton: Story;
12
+ export declare const SkeletonWithTitle: Story;
@@ -0,0 +1,22 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * Lazily loads a side panel component wrapped in its own Suspense boundary.
4
+ * Define the panel at module scope in the file that opens it and pass it
5
+ * straight to `openSidePanel`:
6
+ *
7
+ * @example
8
+ * const AddUser = lazySidePanel(() => import("./UserAddForm"));
9
+ * // ...
10
+ * openSidePanel({ component: AddUser, title: "Add user" });
11
+ *
12
+ * The `<SidePanel />` component from `@canonical/maas-react-components` renders
13
+ * the panel component directly, so a bare `React.lazy` panel would suspend the
14
+ * whole `<SidePanel />` on first open. That remounts `<SidePanel />`, and on
15
+ * remount its internal "close on navigation" effect runs and immediately closes
16
+ * the panel that was just opened. Giving each panel its own Suspense boundary
17
+ * keeps `<SidePanel />` mounted (and open) while the chunk loads, and shows the
18
+ * spinner inside the panel.
19
+ */
20
+ export declare const lazyLoadSidePanel: (loader: () => Promise<{
21
+ default: ComponentType;
22
+ }>, showSkeletonTitle?: boolean) => ComponentType;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/maas-react-components",
3
3
  "description": "React components for use in MAAS UI projects.",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/canonical/maas-react-components.git"