@canonical/maas-react-components 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@canonical/maas-react-components.es.js +482 -449
- package/dist/@canonical/maas-react-components.umd.js +14 -14
- package/dist/maas-react-components.css +1 -1
- package/dist/src/lib/components/GenericTable/GenericTable.d.ts +1 -1
- package/dist/src/lib/elements/Placeholder/Placeholder.d.ts +39 -9
- package/dist/src/lib/elements/Placeholder/Placeholder.stories.d.ts +7 -2
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ type GenericTableProps<T extends GenericTableData> = {
|
|
|
46
46
|
* @param {(originalRow: T, index: number) => T[] | undefined} [props.getSubRows] - Function that returns the T.prop that contains nested T data
|
|
47
47
|
* @param {string[]} [props.groupBy] - Column IDs to group rows by
|
|
48
48
|
* @param {boolean} props.isLoading - Loading state to display placeholder content
|
|
49
|
-
* @param {"spinner" | "skeleton"} [props.loadingVariant="spinner"] - Loading display style; "spinner" shows a single spinner row, "skeleton" renders skeletonRowCount
|
|
49
|
+
* @param {"spinner" | "skeleton"} [props.loadingVariant="spinner"] - Loading display style; "spinner" shows a single spinner row, "skeleton" renders skeletonRowCount pulsing skeleton rows using meta.skeleton per column when defined, falling back to a default Placeholder block
|
|
50
50
|
* @param {number} [props.skeletonRowCount=10] - Number of skeleton rows to render when loadingVariant="skeleton"
|
|
51
51
|
* @param {ReactNode} [props.noData] - Content to display when no data is available
|
|
52
52
|
* @param {PaginationBarProps} [props.pagination] - Pagination configuration
|
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
1
|
+
import { CSSProperties, HTMLAttributes, ReactElement, ReactNode } from 'react';
|
|
2
|
+
type PlaceholderProps = {
|
|
3
3
|
className?: string;
|
|
4
|
+
width?: CSSProperties["width"];
|
|
5
|
+
height?: CSSProperties["height"];
|
|
6
|
+
/** @deprecated */
|
|
4
7
|
isPending?: boolean;
|
|
5
|
-
|
|
6
|
-
text?: never;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
} | {
|
|
8
|
+
/** @deprecated */
|
|
9
9
|
text?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** @deprecated */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
variant?: "block" | "text";
|
|
13
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "children">;
|
|
14
|
+
/**
|
|
15
|
+
* Placeholder - A pulsing skeleton block used to represent loading content
|
|
16
|
+
*
|
|
17
|
+
* Renders a rectangular block with a pulse animation that matches the dimensions
|
|
18
|
+
* of the content it is replacing. Use `width` and `height` to control the size
|
|
19
|
+
* explicitly, or rely on the default block layout for full-width skeletons.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} props - Component props
|
|
22
|
+
* @param {string} [props.className] - Additional CSS class names applied to the root element
|
|
23
|
+
* @param {CSSProperties["width"]} [props.width] - Width of the skeleton block; accepts any valid CSS value (e.g. "200px", "100%", "12rem"). When omitted the block stretches to fill its container
|
|
24
|
+
* @param {CSSProperties["height"]} [props.height] - Height of the skeleton block; accepts any valid CSS value (e.g. "1rem", "48px", "3em"). When omitted the block collapses unless content or a sizer provides height
|
|
25
|
+
* @param {"block" | "text"} [props.variant="text"] - Rendering variant. `"block"` renders a standalone skeleton div; `"text"` is the legacy variant that requires `isPending` to be set
|
|
26
|
+
* @param {HTMLAttributes<HTMLDivElement>} [props.style] - Any HTML div attributes (e.g. `style`, `data-*`, `aria-*`) are forwarded to the root element. `style` is merged with the component's internal width/height styles, with consumer values taking precedence
|
|
27
|
+
* @param {boolean} [props.isPending] - @deprecated Use conditional rendering at the call-site instead. When `true` the skeleton is shown; when `false` the `children` are rendered. Will be removed in a future major version
|
|
28
|
+
* @param {string} [props.text] - @deprecated Width is now controlled via the `width` prop. When provided the text is rendered in a visually-hidden sizer span that gives the block its natural content width. Will be removed in a future major version
|
|
29
|
+
* @param {ReactNode} [props.children] - @deprecated Pass children outside the Placeholder and control visibility at the call-site. Will be removed in a future major version
|
|
30
|
+
*
|
|
31
|
+
* @returns {ReactElement} The rendered skeleton block, or the children when `isPending` is `false`
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Standalone skeleton block
|
|
35
|
+
* <Placeholder width="200px" height="1rem" />
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Composed loading state
|
|
39
|
+
* {isLoading ? <Placeholder width="100%" height="1.5rem" /> : <p>{content}</p>}
|
|
40
|
+
*/
|
|
41
|
+
export declare const Placeholder: ({ className, width, height, isPending, text, children, variant, style, ...divProps }: PlaceholderProps) => ReactElement;
|
|
42
|
+
export {};
|
|
@@ -2,5 +2,10 @@ import { Meta, StoryObj } from '@storybook/react';
|
|
|
2
2
|
import { Placeholder } from './Placeholder';
|
|
3
3
|
declare const meta: Meta<typeof Placeholder>;
|
|
4
4
|
export default meta;
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
5
|
+
type Story = StoryObj<typeof Placeholder>;
|
|
6
|
+
export declare const TextLine: Story;
|
|
7
|
+
export declare const Paragraph: Story;
|
|
8
|
+
export declare const Block: Story;
|
|
9
|
+
export declare const Complex: Story;
|
|
10
|
+
export declare const LegacyTextProp: Story;
|
|
11
|
+
export declare const LegacyChildrenProp: Story;
|
package/package.json
CHANGED