@foris/avocado-suite 1.10.3 → 1.11.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.
@@ -1,18 +1,45 @@
1
- import { FC } from 'react';
2
- export interface IDonutItem {
3
- name: string;
4
- percentage: number;
5
- value: number;
6
- }
1
+ import { type FC, type ReactNode } from 'react';
2
+ import { type DonutCenterMode, type DonutSegment, type DonutSize, type IDonutItem } from './donut.util';
7
3
  export interface DonutProps {
8
- /** overwrite className */
4
+ /** Overwrite className */
9
5
  className?: string;
10
- /** data */
11
- data: IDonutItem[];
12
- /** height */
13
- height?: string;
14
- /** width */
6
+ /** Slices of the ring; proportions come from `value`. */
7
+ segments?: DonutSegment[];
8
+ /** @deprecated Use `segments`. Proportions come from `percentage`, as in the SVG Donut. */
9
+ data?: IDonutItem[];
10
+ /** Ring diameter: `xs` 40, `sm` 56, `md` 96, `lg` 160 px, or `auto` to fill the parent. @default 'sm' */
11
+ size?: DonutSize;
12
+ /** Show the content inside the hole. @default true, false with legacy props */
13
+ showCenter?: boolean;
14
+ /** Custom center content; replaces `centerValue` and `centerLabel`. */
15
+ children?: ReactNode;
16
+ /**
17
+ * `fixed` shows `centerValue` (or the first segment share); `activeSegment` shows the hovered
18
+ * slice label and falls back to `centerValue`, so without it the center is empty until hover.
19
+ * @default 'activeSegment' from 160 px, 'fixed' below
20
+ */
21
+ centerMode?: DonutCenterMode;
22
+ /** Main center text, e.g. a total. */
23
+ centerValue?: string;
24
+ /** Secondary text below `centerValue`. */
25
+ centerLabel?: string;
26
+ /** Enable hover on the slices. @default true from 160 px, false below */
27
+ interactive?: boolean;
28
+ /** Show the hovered slice value and share outside the ring. Requires `interactive`. @default true from 160 px */
29
+ showCallout?: boolean;
30
+ /** Chart adapters only: Recharts nodes rendered inside the PieChart (e.g. Legend). */
31
+ chartChildren?: ReactNode;
32
+ /** Chart adapters only: slice highlighted before user interaction. */
33
+ defaultIndex?: number;
34
+ /** Chart adapters only: caps `size="auto"`. */
35
+ autoMaxDiameter?: number;
36
+ /** Chart adapters only: height reserved below the ring when `size="auto"`. */
37
+ autoLegendReserve?: number;
38
+ /** @deprecated Use `size`. Without `size`: px maps to a diameter, relative values to `'auto'`, none to 300 px. */
15
39
  width?: string;
40
+ /** @deprecated Use `size`. See `width`. */
41
+ height?: string;
16
42
  }
17
43
  declare const Donut: FC<DonutProps>;
18
44
  export default Donut;
45
+ export type { DonutSegment, DonutSize, DonutCenterMode, IDonutItem, } from './donut.util';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { IDonutItem } from '../Donut';
2
+ import { type IDonutItem } from '../donut.util';
3
3
  export interface DonutLabelsProps {
4
4
  /** overwrite className */
5
5
  className?: string;
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { IDonutItem } from '../Donut';
2
+ import { type IDonutItem } from '../donut.util';
3
3
  export interface DonutLegendProps {
4
4
  /** overwrite className */
5
5
  className?: string;
@@ -0,0 +1,58 @@
1
+ import type { Color } from '../../../../avocado-icons';
2
+ export declare const DONUT_PALETTE: `${Color}`[];
3
+ /** Colors of the SVG Donut (core `$donutColors`), kept for the deprecated `data` API. */
4
+ export declare const LEGACY_DONUT_COLORS: `${Color}`[];
5
+ export declare const DONUT_ANALYTIC_THRESHOLD = 160;
6
+ export declare const ACTIVE_CENTER_MAX_FONT_SIZE = 14;
7
+ /** Size of the legacy SVG Donut when no dimension was passed. */
8
+ export declare const LEGACY_DONUT_DIAMETER = 300;
9
+ export declare const DONUT_SIZE_MAP: {
10
+ readonly xs: 40;
11
+ readonly sm: 56;
12
+ readonly md: 96;
13
+ readonly lg: 160;
14
+ };
15
+ export type DonutSize = keyof typeof DONUT_SIZE_MAP | 'auto';
16
+ export type DonutCenterMode = 'fixed' | 'activeSegment';
17
+ export interface DonutSegment {
18
+ label: string;
19
+ value: number;
20
+ /** Design-system color name, e.g. `'success-50'`. Defaults to the palette by index. */
21
+ color?: `${Color}`;
22
+ }
23
+ /** Item consumed by `DonutLegend` and `DonutLabels`. */
24
+ export interface IDonutItem {
25
+ name: string;
26
+ percentage: number;
27
+ value: number;
28
+ /** Design-system color name. Defaults to the legacy SVG Donut colors by index. */
29
+ color?: `${Color}`;
30
+ }
31
+ interface DonutBehavior {
32
+ interactive: boolean;
33
+ showCallout: boolean;
34
+ centerMode: DonutCenterMode;
35
+ }
36
+ interface DonutLayout {
37
+ containerSize: number;
38
+ innerRadius: number;
39
+ outerRadius: number;
40
+ }
41
+ export declare const toColorVar: (color: `${Color}`) => string;
42
+ export declare const getSegmentColor: ({ color }: DonutSegment, index: number) => `${Color}`;
43
+ export declare const getDonutItemColor: ({ color }: IDonutItem, index: number) => `${Color}`;
44
+ export declare const resolveAutoDiameter: (width: number, height: number, { maxDiameter, legendReserve }?: {
45
+ maxDiameter?: number | undefined;
46
+ legendReserve?: number | undefined;
47
+ }) => number;
48
+ export declare const resolveLegacySize: (width?: string, height?: string) => DonutSize | number;
49
+ export declare const fromLegacyData: (data: IDonutItem[]) => DonutSegment[];
50
+ export declare const resolveDonutDiameter: (size: DonutSize | number, autoDiameter?: number) => number;
51
+ export declare const getDonutLayout: (diameter: number, showCallout: boolean) => DonutLayout;
52
+ export declare const getCenterFontSize: (diameter: number, innerDiameter: number, centerMode: DonutCenterMode) => number;
53
+ export declare const getDatumPercent: (datum: DonutSegment, segments: DonutSegment[]) => number;
54
+ export declare const resolveDonutBehavior: (analytic: boolean, overrides?: Partial<DonutBehavior>) => DonutBehavior;
55
+ /** Maps `segments` to the items of `DonutLegend` and `DonutLabels`, keeping the ring colors. */
56
+ export declare const toDonutLegendItems: (segments: DonutSegment[]) => IDonutItem[];
57
+ export declare const getDonutAriaLabel: (segments: DonutSegment[], centerText?: string) => string;
58
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -14,6 +14,19 @@ export type HeaderNavigationVisual = {
14
14
  src: string;
15
15
  alt: string;
16
16
  };
17
+ /** Solid preset, or a decorative photo with a fixed contrast overlay shape. */
18
+ export type HeaderNavigationImageBackground = {
19
+ type: 'image';
20
+ src: string;
21
+ /**
22
+ * CSS color for the tinted overlay gradient (`rgb()`, `hsl()`, hex, or
23
+ * `var(--color-*)`). When omitted, the packaged brand gradient on
24
+ * `web-cyan-100` is used. Also paints the header surface when the photograph
25
+ * is loading or fails.
26
+ */
27
+ overlayColor?: string;
28
+ };
29
+ export type HeaderNavigationBackground = 'default' | 'brand' | HeaderNavigationImageBackground;
17
30
  /** Reusable page navigation, with content and actions supplied by its host. */
18
31
  export interface HeaderNavigationProps extends HTMLAttributes<HTMLElement> {
19
32
  /** Page title, rendered as the primary heading. */
@@ -28,8 +41,8 @@ export interface HeaderNavigationProps extends HTMLAttributes<HTMLElement> {
28
41
  menuLabel?: string;
29
42
  /** Disables the overflow trigger. */
30
43
  menuDisabled?: boolean;
31
- /** Gray by default; brand selects the Figma blue in either theme. */
32
- background?: 'default' | 'brand';
44
+ /** Gray by default, brand blue, or a full-bleed hero photograph. */
45
+ background?: HeaderNavigationBackground;
33
46
  /** Optional leading icon or image. */
34
47
  leadingVisual?: HeaderNavigationVisual;
35
48
  /** Displays the packaged pattern when true, or a caller-provided pattern URL. */
@@ -1,2 +1,2 @@
1
1
  export { default } from './HeaderNavigation';
2
- export type { HeaderNavigationProps, HeaderNavigationVisual, } from './HeaderNavigation';
2
+ export type { HeaderNavigationBackground, HeaderNavigationImageBackground, HeaderNavigationProps, HeaderNavigationVisual, } from './HeaderNavigation';
package/dist/index.d.ts CHANGED
@@ -82,8 +82,10 @@ export type { DataCardProps, DataCardV1Props, DataCardV1Variant, DataCardV2Props
82
82
  export type { DividerProps } from './components/divider/Divider';
83
83
  export type { DropzoneDisplay, DropzoneProps, DropzoneUploadStatus, } from './components/dropzone/Dropzone';
84
84
  export type { FileUploadProps } from './components/file-upload/FileUpload';
85
+ export type { DonutProps, DonutSegment, DonutSize, DonutCenterMode, IDonutItem, } from './components/donut/Donut';
86
+ export { toDonutLegendItems } from './components/donut/donut.util';
85
87
  export type { HeadingProps } from './components/heading/Heading';
86
- export type { HeaderNavigationProps, HeaderNavigationVisual, } from './components/header-navigation';
88
+ export type { HeaderNavigationBackground, HeaderNavigationImageBackground, HeaderNavigationProps, HeaderNavigationVisual, } from './components/header-navigation';
87
89
  export type { ContextualNavigationProps, ContextualNavigationItem, } from './components/contextual-navigation';
88
90
  export type { LinkProps } from './components/link/Link';
89
91
  export type { MatrixTableAlign, MatrixTableColumn, MatrixTableGroupColumn, MatrixTablePinnedSide, MatrixTableProps, } from './components/matrix-table';