canny-ui-react 3.0.0 → 4.0.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/Badge/Badge.d.ts +21 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Charts/BarChart.d.ts +31 -0
- package/dist/components/Charts/LineChart.d.ts +25 -0
- package/dist/components/Charts/PieChart.d.ts +22 -0
- package/dist/components/Charts/ResponsiveContainer.d.ts +12 -0
- package/dist/components/Charts/chartUtils.d.ts +16 -0
- package/dist/components/Charts/index.d.ts +9 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +31 -0
- package/dist/components/ConfirmDialog/index.d.ts +4 -0
- package/dist/components/ConfirmDialog/useConfirm.d.ts +16 -0
- package/dist/components/DataTable/DataTable.d.ts +69 -0
- package/dist/components/DataTable/index.d.ts +2 -0
- package/dist/components/FileUploader/FileUploader.d.ts +19 -0
- package/dist/components/FileUploader/index.d.ts +4 -0
- package/dist/components/FileUploader/useFileDrop.d.ts +630 -0
- package/dist/components/PanelGroup/PanelGroup.d.ts +33 -0
- package/dist/components/PanelGroup/index.d.ts +2 -0
- package/dist/components/Timeline/Timeline.d.ts +55 -0
- package/dist/components/Timeline/index.d.ts +2 -0
- package/dist/components/TreeView/RichTreeView.d.ts +28 -0
- package/dist/components/TreeView/TreeView.d.ts +31 -0
- package/dist/components/TreeView/index.d.ts +4 -0
- package/dist/index.cjs +62 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6548 -5388
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type BadgeColor = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
3
|
+
export type BadgePlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
4
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
/** Numeric count shown in the indicator. */
|
|
6
|
+
count?: number;
|
|
7
|
+
/** Render a small dot instead of a number. */
|
|
8
|
+
dot?: boolean;
|
|
9
|
+
/** Cap displayed count; values above show `{max}+`. Default 99. */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** Show the indicator even when count is 0. Default false. */
|
|
12
|
+
showZero?: boolean;
|
|
13
|
+
/** Semantic color. Default `'danger'`. */
|
|
14
|
+
color?: BadgeColor;
|
|
15
|
+
/** Corner the indicator anchors to (ignored when standalone). Default `'top-right'`. */
|
|
16
|
+
placement?: BadgePlacement;
|
|
17
|
+
/** Render the indicator inline with no anchored child. */
|
|
18
|
+
standalone?: boolean;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface BarSeries {
|
|
3
|
+
/** Key into each datum for this series' value. */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Legend / tooltip label. Defaults to `key`. */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Override the series color. */
|
|
8
|
+
color?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BarChartProps<D extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
|
+
data: D[];
|
|
12
|
+
/** Key for the category label on the x-axis. */
|
|
13
|
+
xKey: string;
|
|
14
|
+
series: BarSeries[];
|
|
15
|
+
height?: number;
|
|
16
|
+
/** Stack the series instead of grouping them side by side. */
|
|
17
|
+
stacked?: boolean;
|
|
18
|
+
grid?: boolean;
|
|
19
|
+
legend?: boolean;
|
|
20
|
+
/** Format y-axis tick values. */
|
|
21
|
+
yTickFormatter?: (value: number) => string;
|
|
22
|
+
/** Format x-axis category labels. */
|
|
23
|
+
xTickFormatter?: (value: string) => string;
|
|
24
|
+
/** Custom tooltip body for a hovered category. */
|
|
25
|
+
renderTooltip?: (params: {
|
|
26
|
+
label: string;
|
|
27
|
+
datum: D;
|
|
28
|
+
}) => ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function BarChart<D extends Record<string, unknown>>({ data, xKey, series, height, stacked, grid, legend, yTickFormatter, xTickFormatter, renderTooltip, className, }: BarChartProps<D>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BarSeries } from './BarChart';
|
|
3
|
+
export interface LineChartProps<D extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
+
data: D[];
|
|
5
|
+
xKey: string;
|
|
6
|
+
series: BarSeries[];
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Fill the area under each line. */
|
|
9
|
+
area?: boolean;
|
|
10
|
+
/** Stack the series (area charts). */
|
|
11
|
+
stacked?: boolean;
|
|
12
|
+
/** Show point markers. */
|
|
13
|
+
dots?: boolean;
|
|
14
|
+
grid?: boolean;
|
|
15
|
+
legend?: boolean;
|
|
16
|
+
yTickFormatter?: (value: number) => string;
|
|
17
|
+
xTickFormatter?: (value: string) => string;
|
|
18
|
+
renderTooltip?: (params: {
|
|
19
|
+
label: string;
|
|
20
|
+
datum: D;
|
|
21
|
+
}) => ReactNode;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function LineChart<D extends Record<string, unknown>>(props: LineChartProps<D>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function AreaChart<D extends Record<string, unknown>>(props: LineChartProps<D>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface PieDatum {
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PieChartProps {
|
|
8
|
+
data: PieDatum[];
|
|
9
|
+
height?: number;
|
|
10
|
+
/** Inner radius as a fraction of the outer radius (0 = pie, 0.6 = donut). */
|
|
11
|
+
innerRadius?: number;
|
|
12
|
+
legend?: boolean;
|
|
13
|
+
/** Custom tooltip body for a hovered slice. */
|
|
14
|
+
renderTooltip?: (params: {
|
|
15
|
+
datum: PieDatum;
|
|
16
|
+
percent: number;
|
|
17
|
+
}) => ReactNode;
|
|
18
|
+
/** Center label (e.g. a total) for donut charts. */
|
|
19
|
+
centerLabel?: ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function PieChart({ data, height, innerRadius, legend, renderTooltip, centerLabel, className, }: PieChartProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ResponsiveContainerProps {
|
|
3
|
+
/** Chart height in px. */
|
|
4
|
+
height?: number;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sizing wrapper kept for `recharts` compatibility. Canny charts already fill
|
|
10
|
+
* their parent's width; this passes `height` down and stretches to 100% width.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ResponsiveContainer({ height, children, className }: ResponsiveContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
/** Default palette — token-driven series colors, cycled by index. */
|
|
3
|
+
export declare const CHART_COLORS: string[];
|
|
4
|
+
export declare function seriesColor(index: number, explicit?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Measures the host element's width with a ResizeObserver and returns a fluid
|
|
7
|
+
* width. Falls back to `fallback` when measurement is unavailable (SSR/jsdom).
|
|
8
|
+
*/
|
|
9
|
+
export declare function useChartWidth(fallback?: number): [RefObject<HTMLDivElement | null>, number];
|
|
10
|
+
/** "Nice" max + evenly spaced ticks for a [0, max] axis. */
|
|
11
|
+
export declare function niceTicks(max: number, count?: number): {
|
|
12
|
+
max: number;
|
|
13
|
+
ticks: number[];
|
|
14
|
+
};
|
|
15
|
+
/** SVG path for a (possibly donut) pie slice. Angles in radians, 0 at 12 o'clock. */
|
|
16
|
+
export declare function arcPath(cx: number, cy: number, rOuter: number, rInner: number, startAngle: number, endAngle: number): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BarChart } from './BarChart';
|
|
2
|
+
export type { BarChartProps, BarSeries } from './BarChart';
|
|
3
|
+
export { LineChart, AreaChart } from './LineChart';
|
|
4
|
+
export type { LineChartProps } from './LineChart';
|
|
5
|
+
export { PieChart } from './PieChart';
|
|
6
|
+
export type { PieChartProps, PieDatum } from './PieChart';
|
|
7
|
+
export { ResponsiveContainer } from './ResponsiveContainer';
|
|
8
|
+
export type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
9
|
+
export { CHART_COLORS } from './chartUtils';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmDialogProps {
|
|
3
|
+
/** Controlled open state. */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Called with the next open state (e.g. on Esc, backdrop, or cancel). */
|
|
6
|
+
onOpenChange: (open: boolean) => void;
|
|
7
|
+
/** Dialog heading. */
|
|
8
|
+
title: ReactNode;
|
|
9
|
+
/** Body copy. Ignored when `children` is provided. */
|
|
10
|
+
message?: ReactNode;
|
|
11
|
+
/** Custom body; overrides `message`. */
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/** Confirm button label. Default `'Confirm'`. */
|
|
14
|
+
confirmLabel?: string;
|
|
15
|
+
/** Cancel button label. Default `'Cancel'`. */
|
|
16
|
+
cancelLabel?: string;
|
|
17
|
+
/** Render the confirm button in the danger color. */
|
|
18
|
+
danger?: boolean;
|
|
19
|
+
/** Show a spinner on confirm and disable both buttons. */
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
/** Fired when the confirm button is clicked. */
|
|
22
|
+
onConfirm: () => void;
|
|
23
|
+
/** Fired when the cancel button is clicked (before close). */
|
|
24
|
+
onCancel?: () => void;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* ConfirmDialog — a small Dialog preset for destructive / confirmation prompts.
|
|
29
|
+
* Composes the base `Dialog` and `Button`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function ConfirmDialog({ open, onOpenChange, title, message, children, confirmLabel, cancelLabel, danger, loading, onConfirm, onCancel, className, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmOptions {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
message?: ReactNode;
|
|
5
|
+
confirmLabel?: string;
|
|
6
|
+
cancelLabel?: string;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Imperative confirmation. Render `confirmDialog` once in the tree, then
|
|
11
|
+
* `await confirm({ title, message })` to get a boolean.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useConfirm(): {
|
|
14
|
+
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
15
|
+
confirmDialog: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
+
export type DataTableAlign = 'left' | 'center' | 'right';
|
|
3
|
+
export type RowId = string | number;
|
|
4
|
+
export interface DataTableColumn<R = Record<string, unknown>> {
|
|
5
|
+
/** Key into the row (and the sort field). Use `renderCell` for non-primitive values. */
|
|
6
|
+
field: string;
|
|
7
|
+
/** Column header text. Defaults to `field`. */
|
|
8
|
+
headerName?: string;
|
|
9
|
+
/** Fixed width in px. */
|
|
10
|
+
width?: number;
|
|
11
|
+
/** Proportional width (flex-grow). Ignored when `width` is set. */
|
|
12
|
+
flex?: number;
|
|
13
|
+
/** Cell text alignment. */
|
|
14
|
+
align?: DataTableAlign;
|
|
15
|
+
/** Header text alignment. Defaults to `align`. */
|
|
16
|
+
headerAlign?: DataTableAlign;
|
|
17
|
+
/** Allow sorting on this column. */
|
|
18
|
+
sortable?: boolean;
|
|
19
|
+
/** Allow drag-to-resize on this column. Default `true`. */
|
|
20
|
+
resizable?: boolean;
|
|
21
|
+
/** Custom cell renderer. */
|
|
22
|
+
renderCell?: (params: {
|
|
23
|
+
row: R;
|
|
24
|
+
value: unknown;
|
|
25
|
+
field: string;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/** Derive the cell value from the row instead of `row[field]`. */
|
|
28
|
+
valueGetter?: (params: {
|
|
29
|
+
row: R;
|
|
30
|
+
field: string;
|
|
31
|
+
}) => unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface DataTableSort {
|
|
34
|
+
field: string;
|
|
35
|
+
sort: 'asc' | 'desc';
|
|
36
|
+
}
|
|
37
|
+
export interface DataTablePaginationModel {
|
|
38
|
+
/** Zero-based page index. */
|
|
39
|
+
page: number;
|
|
40
|
+
pageSize: number;
|
|
41
|
+
}
|
|
42
|
+
export interface DataTableProps<R = Record<string, unknown>> {
|
|
43
|
+
columns: DataTableColumn<R>[];
|
|
44
|
+
rows: R[];
|
|
45
|
+
/** Stable id for a row. Defaults to `row.id`. */
|
|
46
|
+
getRowId?: (row: R) => RowId;
|
|
47
|
+
/** Replace rows with skeleton placeholders. */
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
/** Total server-side row count — enables the pagination footer. */
|
|
50
|
+
rowCount?: number;
|
|
51
|
+
paginationModel?: DataTablePaginationModel;
|
|
52
|
+
onPaginationModelChange?: (model: DataTablePaginationModel) => void;
|
|
53
|
+
/** Show a leading checkbox column. */
|
|
54
|
+
checkboxSelection?: boolean;
|
|
55
|
+
rowSelectionModel?: RowId[];
|
|
56
|
+
onRowSelectionModelChange?: (ids: RowId[]) => void;
|
|
57
|
+
/** Controlled sort. Header clicks emit `onSortModelChange` (server-driven). */
|
|
58
|
+
sortModel?: DataTableSort | null;
|
|
59
|
+
onSortModelChange?: (sort: DataTableSort | null) => void;
|
|
60
|
+
onRowClick?: (row: R) => void;
|
|
61
|
+
/** Empty-state content. */
|
|
62
|
+
noRowsLabel?: ReactNode;
|
|
63
|
+
/** Turn off column resizing for every column. */
|
|
64
|
+
disableColumnResize?: boolean;
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare const DataTable: <R = Record<string, unknown>>(props: DataTableProps<R> & {
|
|
68
|
+
ref?: Ref<HTMLDivElement>;
|
|
69
|
+
}) => ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FileRejection, UseFileDropOptions } from './useFileDrop';
|
|
3
|
+
export interface FileUploaderProps extends Omit<UseFileDropOptions, 'onDrop' | 'onDropAccepted' | 'onDropRejected'> {
|
|
4
|
+
/** Fired with `(accepted, rejected)` after each drop or browse. */
|
|
5
|
+
onDrop?: (accepted: File[], rejected: FileRejection[]) => void;
|
|
6
|
+
/** Primary call-to-action line. */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** Secondary hint under the label (e.g. accepted types / max size). */
|
|
9
|
+
hint?: ReactNode;
|
|
10
|
+
/** Replace the leading icon. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Custom body; overrides the default icon + text. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** Browse-button label. Set to `false` to hide the button. */
|
|
15
|
+
buttonLabel?: ReactNode | false;
|
|
16
|
+
size?: 'sm' | 'md';
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const FileUploader: import("react").ForwardRefExoticComponent<FileUploaderProps & import("react").RefAttributes<HTMLDivElement>>;
|