@pantheon-systems/pds-toolkit-react 1.17.1 → 1.18.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/components/charts/PieChart/PieChart.d.ts +59 -0
- package/_dist/components/charts/ProportionBar/ProportionBar.d.ts +57 -0
- package/_dist/components/charts/shared/ChartSkeleton.d.ts +5 -1
- package/_dist/css/component-css/pds-chart-wrapper.css +1 -1
- package/_dist/css/component-css/pds-index.css +2 -2
- package/_dist/css/component-css/pds-pie-chart.css +1 -0
- package/_dist/css/component-css/pds-proportion-bar.css +1 -0
- package/_dist/css/pds-components.css +2 -2
- package/_dist/index.css +1 -1
- package/_dist/index.d.ts +2 -0
- package/_dist/index.js +4509 -4103
- package/_dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { ColorPalette, LegendVariant } from '../shared/types';
|
|
3
|
+
import '../shared/chart-wrapper.css';
|
|
4
|
+
import './pie-chart.css';
|
|
5
|
+
export type PieChartVariant = 'donut' | 'pie';
|
|
6
|
+
export interface PieSlice {
|
|
7
|
+
/** Override default token color (CSS custom property or hex). Not theme-aware — use paletteIndex instead when possible. */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Display label for legend and tooltip */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Pick a specific color from the selected palette by position (1-based). Theme-aware — automatically adjusts for light/dark mode. */
|
|
12
|
+
paletteIndex?: number;
|
|
13
|
+
/** Numeric value for this slice */
|
|
14
|
+
value: number;
|
|
15
|
+
}
|
|
16
|
+
export interface PieChartLabelStrings {
|
|
17
|
+
/** Accessible description for the hidden data table */
|
|
18
|
+
accessibleTableDescription?: string;
|
|
19
|
+
/** Heading for the empty state */
|
|
20
|
+
emptyStateHeading?: string;
|
|
21
|
+
/** Message body for the empty state */
|
|
22
|
+
emptyStateMessage?: string;
|
|
23
|
+
/** Loading label for screen readers */
|
|
24
|
+
loadingLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PieChartProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
27
|
+
/** Height of the chart area in pixels. Default: 300; 80 when isThumbnail. */
|
|
28
|
+
chartHeight?: number;
|
|
29
|
+
/** Maximum width of the component in pixels. Default: 80 when isThumbnail. */
|
|
30
|
+
chartWidth?: number;
|
|
31
|
+
/** Color palette to use for slice colors (default: 'categorical') */
|
|
32
|
+
colorPalette?: ColorPalette;
|
|
33
|
+
/** Slice data */
|
|
34
|
+
data: PieSlice[];
|
|
35
|
+
/** Show loading skeleton */
|
|
36
|
+
isLoading?: boolean;
|
|
37
|
+
/** Thumbnail mode — hides legend and tooltip, renders at a small fixed size. Individual show* props can override. */
|
|
38
|
+
isThumbnail?: boolean;
|
|
39
|
+
/** Translatable UI strings for i18n. Keys: accessibleTableDescription, emptyStateHeading, emptyStateMessage, loadingLabel. */
|
|
40
|
+
labelStrings?: PieChartLabelStrings;
|
|
41
|
+
/** Legend display style (default: 'inline') */
|
|
42
|
+
legendVariant?: LegendVariant;
|
|
43
|
+
/** Show accessible data table (visually hidden). Defaults to true. */
|
|
44
|
+
showAccessibleTable?: boolean;
|
|
45
|
+
/** Show legend below the chart. Defaults to true; false when isThumbnail is set. */
|
|
46
|
+
showLegend?: boolean;
|
|
47
|
+
/** Show tooltip on hover. Defaults to true; false when isThumbnail is set. */
|
|
48
|
+
showTooltip?: boolean;
|
|
49
|
+
/** Custom value formatter for legend items. Receives the slice value, total, and label. Defaults to showing percentage. */
|
|
50
|
+
valueFormatter?: (value: number, total: number, label: string) => string;
|
|
51
|
+
/** Chart variant (default: 'pie') */
|
|
52
|
+
variant?: PieChartVariant;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* PieChart UI component
|
|
56
|
+
*
|
|
57
|
+
* Renders a responsive pie or donut chart showing proportional data across categories.
|
|
58
|
+
*/
|
|
59
|
+
export declare const PieChart: ({ chartHeight, chartWidth, className, colorPalette, data, isLoading, isThumbnail, labelStrings, legendVariant, showAccessibleTable, showLegend, showTooltip, valueFormatter, variant, ...props }: PieChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import type { ColorPalette } from '../shared/types';
|
|
3
|
+
import '../shared/chart-wrapper.css';
|
|
4
|
+
import './proportion-bar.css';
|
|
5
|
+
export interface ProportionSegment {
|
|
6
|
+
/** Override default token color (CSS custom property or hex). Not theme-aware — use paletteIndex instead when possible. */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** Display label for legend and tooltip */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Pick a specific color from the selected palette by position (1-based). Theme-aware — automatically adjusts for light/dark mode. */
|
|
11
|
+
paletteIndex?: number;
|
|
12
|
+
/** Numeric value for this segment */
|
|
13
|
+
value: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ProportionBarLabelStrings {
|
|
16
|
+
/** Accessible description for the hidden data table */
|
|
17
|
+
accessibleTableDescription?: string;
|
|
18
|
+
/** Heading for the empty state */
|
|
19
|
+
emptyStateHeading?: string;
|
|
20
|
+
/** Message body for the empty state */
|
|
21
|
+
emptyStateMessage?: string;
|
|
22
|
+
/** Loading label for screen readers */
|
|
23
|
+
loadingLabel?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ProportionBarProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
26
|
+
/** Height of the bar track in pixels (default: 16) */
|
|
27
|
+
barHeight?: number;
|
|
28
|
+
/** Maximum width of the component in pixels. The component is responsive and will shrink within this constraint. */
|
|
29
|
+
chartWidth?: number;
|
|
30
|
+
/** Color palette to use for segment colors (default: 'categorical') */
|
|
31
|
+
colorPalette?: ColorPalette;
|
|
32
|
+
/** Segment data — each segment has a label, numeric value, and optional color override */
|
|
33
|
+
data: ProportionSegment[];
|
|
34
|
+
/** Show loading skeleton */
|
|
35
|
+
isLoading?: boolean;
|
|
36
|
+
/** Thumbnail mode — hides legend and tooltip. Individual show* props can override. */
|
|
37
|
+
isThumbnail?: boolean;
|
|
38
|
+
/** Translatable UI strings for i18n. Keys: accessibleTableDescription, emptyStateHeading, emptyStateMessage, loadingLabel. */
|
|
39
|
+
labelStrings?: ProportionBarLabelStrings;
|
|
40
|
+
/** Alignment of the legend (default: 'left') */
|
|
41
|
+
legendAlignment?: 'center' | 'left';
|
|
42
|
+
/** Show accessible data table (visually hidden). Defaults to true. */
|
|
43
|
+
showAccessibleTable?: boolean;
|
|
44
|
+
/** Show legend below the bar. Defaults to true; false when isThumbnail is set. */
|
|
45
|
+
showLegend?: boolean;
|
|
46
|
+
/** Show tooltip on hover. Defaults to true; false when isThumbnail is set. */
|
|
47
|
+
showTooltip?: boolean;
|
|
48
|
+
/** Custom value formatter for legend items. Receives the segment value, total, and label. Defaults to showing percentage. */
|
|
49
|
+
valueFormatter?: (value: number, total: number, label: string) => string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ProportionBar UI component
|
|
53
|
+
*
|
|
54
|
+
* Renders a single horizontal bar divided into colored segments, showing
|
|
55
|
+
* the composition of a total. Functions as a linearized pie chart.
|
|
56
|
+
*/
|
|
57
|
+
export declare const ProportionBar: ({ barHeight, chartWidth, className, colorPalette, data, isLoading, isThumbnail, labelStrings, legendAlignment, showAccessibleTable, showLegend, showTooltip, valueFormatter, ...props }: ProportionBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { LegendVariant } from './types';
|
|
2
2
|
export interface ChartSkeletonProps {
|
|
3
|
+
/** Optional border radius for the skeleton bar area (e.g. 'var(--pds-border-radius-bar)'). When provided, a rectangular skeleton is clipped to this radius. */
|
|
4
|
+
borderRadius?: string;
|
|
3
5
|
height: number;
|
|
6
|
+
/** Alignment of the inline legend skeleton (default: 'center') */
|
|
7
|
+
legendAlignment?: 'center' | 'left';
|
|
4
8
|
legendVariant?: LegendVariant;
|
|
5
9
|
showLegend?: boolean;
|
|
6
10
|
}
|
|
7
|
-
export declare const ChartSkeleton: ({ height, legendVariant, showLegend, }: ChartSkeletonProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const ChartSkeleton: ({ borderRadius, height, legendAlignment, legendVariant, showLegend, }: ChartSkeletonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.pds-chart{font-family:var(--pds-typography-ff-default);position:relative;width:100%}.pds-chart__header{align-items:center;display:flex;justify-content:flex-end;margin-block-end:var(--pds-spacing-m)}.pds-chart--loading{display:block}.pds-chart__skeleton{display:flex;flex-direction:column;gap:var(--pds-spacing-m);height:100%;width:100%}.pds-chart__skeleton-area{flex-shrink:0}.pds-chart__skeleton-legend{align-items:center;display:flex;gap:var(--pds-spacing-s)}.pds-chart__skeleton-legend--inline{justify-content:center}.pds-chart__skeleton-legend--table{width:100%}.pds-chart--empty{align-items:center;display:flex;justify-content:center}.recharts-default-tooltip{background-color:var(--pds-color-bg-default)!important;border:var(--pds-border-width-default) solid var(--pds-color-border-default)!important;border-radius:var(--pds-border-radius-container)!important;box-shadow:var(--pds-elevation-overlay)!important;font-family:var(--pds-typography-ff-default)!important;font-size:var(--pds-typography-size-xs)!important;padding:var(--pds-spacing-4xs) var(--pds-spacing-xs)!important}.recharts-tooltip-label{color:var(--pds-color-fg-default)!important;font-weight:var(--pds-typography-fw-semibold)!important;margin:0!important}.recharts-tooltip-item-list li{padding-block:0!important}.recharts-tooltip-item-list{padding:0!important}.recharts-tooltip-item{align-items:center;color:var(--pds-color-fg-default)!important;display:flex;font-size:var(--pds-typography-size-xs)!important;gap:var(--pds-spacing-3xs);margin:0!important;padding:var(--pds-spacing-6xs) 0!important}.recharts-tooltip-item__color{border-radius:2px;display:inline-block;flex-shrink:0;height:8px;width:8px}.pds-bar-chart [aria-hidden=true]:focus,.pds-line-chart [aria-hidden=true]:focus,.recharts-surface:focus,.recharts-wrapper :focus,.recharts-wrapper:focus{outline:none}
|
|
1
|
+
.pds-chart{font-family:var(--pds-typography-ff-default);position:relative;width:100%}.pds-chart__header{align-items:center;display:flex;justify-content:flex-end;margin-block-end:var(--pds-spacing-m)}.pds-chart--loading{display:block}.pds-chart__skeleton{display:flex;flex-direction:column;gap:var(--pds-spacing-m);height:100%;width:100%}.pds-chart__skeleton-area{flex-shrink:0}.pds-chart__skeleton-legend{align-items:center;display:flex;gap:var(--pds-spacing-s)}.pds-chart__skeleton-legend--inline{justify-content:center}.pds-chart__skeleton-legend--inline-left{justify-content:flex-start}.pds-chart__skeleton-legend--table{width:100%}.pds-chart--empty{align-items:center;display:flex;justify-content:center}.recharts-default-tooltip{background-color:var(--pds-color-bg-default)!important;border:var(--pds-border-width-default) solid var(--pds-color-border-default)!important;border-radius:var(--pds-border-radius-container)!important;box-shadow:var(--pds-elevation-overlay)!important;font-family:var(--pds-typography-ff-default)!important;font-size:var(--pds-typography-size-xs)!important;padding:var(--pds-spacing-4xs) var(--pds-spacing-xs)!important}.recharts-tooltip-label{color:var(--pds-color-fg-default)!important;font-weight:var(--pds-typography-fw-semibold)!important;margin:0!important}.recharts-tooltip-item-list li{padding-block:0!important}.recharts-tooltip-item-list{padding:0!important}.recharts-tooltip-item{align-items:center;color:var(--pds-color-fg-default)!important;display:flex;font-size:var(--pds-typography-size-xs)!important;gap:var(--pds-spacing-3xs);margin:0!important;padding:var(--pds-spacing-6xs) 0!important}.recharts-tooltip-item__color{border-radius:2px;display:inline-block;flex-shrink:0;height:8px;width:8px}.pds-bar-chart [aria-hidden=true]:focus,.pds-line-chart [aria-hidden=true]:focus,.recharts-surface:focus,.recharts-wrapper :focus,.recharts-wrapper:focus{outline:none}
|