rich-react-component 0.3.2 → 0.4.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/README.md +125 -1
- package/dist/base/AreaChart.d.ts +4 -0
- package/dist/base/BarChart.d.ts +4 -0
- package/dist/base/Calendar.d.ts +54 -0
- package/dist/base/Chart.d.ts +26 -0
- package/dist/base/ChartLegend.d.ts +22 -0
- package/dist/base/DocumentViewer.d.ts +57 -0
- package/dist/base/DonutChart.d.ts +4 -0
- package/dist/base/LineChart.d.ts +9 -0
- package/dist/base/PieChart.d.ts +4 -0
- package/dist/base/StackedBarChart.d.ts +4 -0
- package/dist/base/chart/CartesianChart.d.ts +31 -0
- package/dist/base/chart/ChartSliceSummary.d.ts +13 -0
- package/dist/base/chart/ChartStatus.d.ts +16 -0
- package/dist/base/chart/ChartTooltip.d.ts +22 -0
- package/dist/base/chart/CircularChartBase.d.ts +18 -0
- package/dist/base/chart/chartColors.d.ts +4 -0
- package/dist/base/chart/chartScales.d.ts +15 -0
- package/dist/base/chart/chartTypes.d.ts +58 -0
- package/dist/base/chart/useChartDimensions.d.ts +13 -0
- package/dist/base/chart/useChartIndexNavigation.d.ts +23 -0
- package/dist/base/index.d.ts +28 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3270 -2136
- package/dist/index.js.map +1 -1
- package/dist/pdf-04d5ad63.js +14755 -0
- package/dist/pdf-04d5ad63.js.map +1 -0
- package/dist/pdf-c22cffd3.cjs +13 -0
- package/dist/pdf-c22cffd3.cjs.map +1 -0
- package/dist/pdf.worker.min-ab9f616e.cjs +2 -0
- package/dist/pdf.worker.min-ab9f616e.cjs.map +1 -0
- package/dist/pdf.worker.min-e6e7e836.js +5 -0
- package/dist/pdf.worker.min-e6e7e836.js.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +75 -72
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ import { RemoteComboBox } from "rich-react-component";
|
|
|
83
83
|
|
|
84
84
|
## What's in each layer
|
|
85
85
|
|
|
86
|
-
**Base** (
|
|
86
|
+
**Base** (67 components) — form fields (`Input`, `NumberInput`, `PasswordInput`, `FileInput`, `CheckBox`, `Switch`, `RadioGroup`, `Select`, `MultiSelect`, `DatePicker`, `TimePicker`, `DateTimePicker`, `ComboBox`, `AutoComplete`, `FormField`), feedback (`Modal`, `Toast`, `Confirm`, `Alert`, `Spinner`, `Badge`, `Skeleton`), data display (`DataGrid`, `Pagination`, `Avatar`, `Tag`, `Rating`, `ProgressBar`, `ListItem`, `Sparkline`, `Statistic`), data visualization (`Chart`, `ChartLegend`, `LineChart`, `AreaChart`, `BarChart`, `StackedBarChart`, `DonutChart`, `PieChart`), scheduling (`Calendar`), documents (`DocumentViewer`), navigation (`Breadcrumb`, `Menu`, `Stepper`, `Tabs`, `Navbar`, `Sidebar`, `PageHeader`), layout (`Card`, `Divider`, `Stack`, `Flex`, `Container`, `Row`, `Col`), typography (`Text`), and more (`Button`, `IconButton`, `Tooltip`, `Popover`, `Accordion`, `Icon`, `RichComponentBase`, `ContextMenu`).
|
|
87
87
|
|
|
88
88
|
`DataGrid` columns are declarative by default (`{ field: "conversion", header: "CONV.", align: "end" }`) — `render` stays available as the escape hatch for genuinely custom cells, and `format`/`formatter` cover the common presentation cases (`dataGridFormatters` exports the built-in `text`/`date`/`currency`/`boolean` set). `Card` accepts `title`/`subtitle`/`icon`/`avatar`/`actions`/`loading` directly, with `header` remaining as the raw escape hatch. `Tabs` supports `variant` (`default`/`underline`/`pill`/`card`/`button`), `orientation`, `size`, `stretch`, and per-item `icon`/`badge`, with roving-tabindex keyboard navigation.
|
|
89
89
|
|
|
@@ -295,6 +295,130 @@ nor Metronic ships a dark variant of those variables, and the light-mode shades
|
|
|
295
295
|
measure about 2:1 on a dark neutral. An application with its own dark palette
|
|
296
296
|
overrides the `--rrc-*` tokens, which are the documented integration point.
|
|
297
297
|
|
|
298
|
+
## Charts
|
|
299
|
+
|
|
300
|
+
Six full-size chart types share one responsive, accessible foundation — no SVG,
|
|
301
|
+
Canvas, ResizeObserver or tooltip portal in your own code:
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
import { LineChart } from "rich-react-component";
|
|
305
|
+
|
|
306
|
+
<LineChart
|
|
307
|
+
title="Monthly training completion"
|
|
308
|
+
data={data}
|
|
309
|
+
xKey="month"
|
|
310
|
+
series={[
|
|
311
|
+
{ key: "completed", label: "Completed" },
|
|
312
|
+
{ key: "missing", label: "Missing" },
|
|
313
|
+
]}
|
|
314
|
+
/>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
`LineChart`, `AreaChart`, `BarChart` (grouped, `orientation="vertical" |
|
|
318
|
+
"horizontal"`), `StackedBarChart`, `DonutChart` and `PieChart` all accept
|
|
319
|
+
`loading`/`error`/`isEmpty`, `showLegend`/`showTooltip`/`showDataLabels`,
|
|
320
|
+
per-series `color`/`hidden`/`valueFormatter`, and `animate` (also forced off
|
|
321
|
+
under `prefers-reduced-motion`). `Chart` is the shared responsive shell itself
|
|
322
|
+
— public for a custom SVG/Canvas visualization that still wants the same
|
|
323
|
+
sizing/status chrome — and `ChartLegend` is the shared, keyboard-operable
|
|
324
|
+
series legend both `LineChart`/`AreaChart`/`BarChart`/`StackedBarChart` compose.
|
|
325
|
+
|
|
326
|
+
Colors always come from theme tokens — `--rrc-chart-1` … `--rrc-chart-5` for
|
|
327
|
+
the categorical palette, `--rrc-chart-grid`/`--rrc-chart-axis` for the grid
|
|
328
|
+
and axis text, `--rrc-chart-tooltip-bg`/`--rrc-chart-tooltip-text` for the
|
|
329
|
+
tooltip — never hardcoded in a component, so a custom color scheme repaints
|
|
330
|
+
charts along with everything else.
|
|
331
|
+
|
|
332
|
+
**Accessibility.** Every data point/bar/slice is a real, individually
|
|
333
|
+
focusable, labelled target — arrow keys move between them, Enter/Space fires
|
|
334
|
+
`onDataPointClick`/`onSliceClick`, exactly like a mouse click on the same
|
|
335
|
+
point. A visually-hidden data table (or, for the circular charts, a
|
|
336
|
+
name/value list) carries the same numbers for a screen reader user, so the
|
|
337
|
+
chart's information is never conveyed by the drawing alone.
|
|
338
|
+
|
|
339
|
+
**Known limitation.** Very large series (tens of thousands of points) are not
|
|
340
|
+
virtualized or canvas-rendered — plain SVG, matching the same choice already
|
|
341
|
+
made for `Sparkline`, rather than a new charting dependency.
|
|
342
|
+
|
|
343
|
+
## Calendar
|
|
344
|
+
|
|
345
|
+
A month-view event calendar — locale-aware, keyboard-operable, controlled or
|
|
346
|
+
uncontrolled:
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
<Calendar
|
|
350
|
+
locale="tr-TR"
|
|
351
|
+
weekStartsOn={1} // 0 = Sunday, 1 = Monday
|
|
352
|
+
value={selectedDate}
|
|
353
|
+
onDateChange={setSelectedDate}
|
|
354
|
+
events={events} // { id, title, start, end?, variant?, color?, disabled? }
|
|
355
|
+
onEventClick={handleEventClick}
|
|
356
|
+
onMonthChange={loadMonthEvents}
|
|
357
|
+
/>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Month/weekday names come from native `Intl.DateTimeFormat` — no date library
|
|
361
|
+
dependency. A day with more events than `maxEventsPerDay` (default 3) shows a
|
|
362
|
+
"+N more" control instead of overflowing the cell; below the `md` breakpoint
|
|
363
|
+
an agenda list of the selected day's events renders alongside the grid, via
|
|
364
|
+
plain Bootstrap responsive utility classes (no `matchMedia`, so it stays
|
|
365
|
+
SSR-safe).
|
|
366
|
+
|
|
367
|
+
**Timezone contract.** Every comparison uses the `Date` object's own local
|
|
368
|
+
getters (`getFullYear`/`getMonth`/`getDate`), never `Date.UTC` or ISO-string
|
|
369
|
+
parsing for day-bucketing — an event never silently shifts a day across a
|
|
370
|
+
timezone or DST boundary.
|
|
371
|
+
|
|
372
|
+
**Known limitation.** Only `view="month"` renders in this release. The `view`
|
|
373
|
+
prop and the `CalendarEvent` shape already accept `"week" | "day" | "agenda" |
|
|
374
|
+
"scheduler"` so a future release can add them without a breaking prop change;
|
|
375
|
+
passing one today falls back to month view with a development-mode warning.
|
|
376
|
+
Drag-and-drop event moving is not supported.
|
|
377
|
+
|
|
378
|
+
## DocumentViewer
|
|
379
|
+
|
|
380
|
+
Previews a PDF or a common image format without your application touching
|
|
381
|
+
PDF.js, a `<canvas>`, or a blob URL:
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
<DocumentViewer
|
|
385
|
+
source={documentUrl} // string URL, or a Blob/ArrayBuffer already in hand
|
|
386
|
+
fileName="risk-assessment.pdf"
|
|
387
|
+
mimeType="application/pdf"
|
|
388
|
+
onDownload={handleDownload}
|
|
389
|
+
onError={handlePreviewError}
|
|
390
|
+
/>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Supports PDF, PNG, JPEG/JPG, WEBP and GIF. Page navigation, zoom, rotate,
|
|
394
|
+
fit-to-width/fit-to-view and fullscreen (which reuses the existing `Modal`,
|
|
395
|
+
escape-to-close included) are all built in. An unsupported file type never
|
|
396
|
+
renders a broken viewer — it shows the file's name/type and a download action
|
|
397
|
+
instead. Every built-in toolbar string can be overridden through the `labels`
|
|
398
|
+
prop, since no central i18n catalog lives in the Base layer.
|
|
399
|
+
|
|
400
|
+
**Dependency.** PDF rendering is powered by `pdfjs-dist`, this library's first
|
|
401
|
+
runtime dependency — but it is only ever `import()`-ed when a PDF is actually
|
|
402
|
+
previewed, so it lands in its own lazy chunk (verified via the real
|
|
403
|
+
`vite build` output: `pdf-*.js` and `pdf.worker.min-*.js` are separate from
|
|
404
|
+
`index.js`) and costs nothing for an application that only renders `Calendar`
|
|
405
|
+
or a chart. Its Web Worker is resolved through a bundler-native asset import,
|
|
406
|
+
so no manual worker configuration is needed in a Vite (or comparably
|
|
407
|
+
capable) consumer build.
|
|
408
|
+
|
|
409
|
+
**CORS/CSP.** A remote `source` URL is loaded the same way `<img src>` already
|
|
410
|
+
is elsewhere in this library — the browser (or, for a PDF, `pdfjs-dist`'s own
|
|
411
|
+
fetch/range-request handling) loads it directly, so the usual cross-origin
|
|
412
|
+
rules apply: the URL's own server must allow it, and a strict CSP needs
|
|
413
|
+
`worker-src` (for the PDF worker) and, for a cross-origin document, an
|
|
414
|
+
appropriate `connect-src`/`img-src` entry.
|
|
415
|
+
|
|
416
|
+
**Known limitations.** Fullscreen reuses `Modal` rather than the native
|
|
417
|
+
Fullscreen API (consistent with `Modal`'s own documented not-yet-portalled
|
|
418
|
+
limitation). No print action, text selection/search, or annotation layer
|
|
419
|
+
inside a previewed PDF — page rendering only. `FilePreview` was deliberately
|
|
420
|
+
not added as a second export; `DocumentViewer` is the only public name.
|
|
421
|
+
|
|
298
422
|
## Component showcase
|
|
299
423
|
|
|
300
424
|
A dev-only application exercises the library live — not part of the published package:
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CartesianChartCoreProps } from './chart/CartesianChart';
|
|
2
|
+
export type AreaChartProps = Omit<CartesianChartCoreProps, "kind" | "orientation" | "stacked">;
|
|
3
|
+
/** Same API and interaction model as `LineChart`, filled to its baseline. See `CartesianChart`. */
|
|
4
|
+
export declare function AreaChart(props: AreaChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CartesianChartCoreProps } from './chart/CartesianChart';
|
|
2
|
+
export type BarChartProps = Omit<CartesianChartCoreProps, "kind" | "stacked">;
|
|
3
|
+
/** Grouped bars — each series in a category sits side by side. For stacked segments, use `StackedBarChart`. */
|
|
4
|
+
export declare function BarChart(props: BarChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type CalendarView = "month" | "week" | "day" | "agenda" | "scheduler";
|
|
3
|
+
export type CalendarEventVariant = "primary" | "success" | "warning" | "danger" | "info" | "secondary";
|
|
4
|
+
export interface CalendarEvent {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
start: Date | string;
|
|
8
|
+
end?: Date | string;
|
|
9
|
+
allDay?: boolean;
|
|
10
|
+
color?: string;
|
|
11
|
+
variant?: CalendarEventVariant;
|
|
12
|
+
description?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface CalendarProps {
|
|
17
|
+
value?: Date | null;
|
|
18
|
+
defaultValue?: Date | null;
|
|
19
|
+
onDateChange?: (date: Date) => void;
|
|
20
|
+
events?: CalendarEvent[];
|
|
21
|
+
/**
|
|
22
|
+
* Only `"month"` is implemented in this release. The type accepts the rest
|
|
23
|
+
* of the family so a future release can add them without a breaking prop
|
|
24
|
+
* change; passing one today falls back to `"month"` with a dev warning
|
|
25
|
+
* (known limitation — no week/day/agenda/scheduler view yet).
|
|
26
|
+
*/
|
|
27
|
+
view?: CalendarView;
|
|
28
|
+
/** BCP 47 locale for month/weekday names via `Intl.DateTimeFormat`. */
|
|
29
|
+
locale?: string;
|
|
30
|
+
/** 0 = Sunday, 1 = Monday. */
|
|
31
|
+
weekStartsOn?: 0 | 1;
|
|
32
|
+
min?: Date;
|
|
33
|
+
max?: Date;
|
|
34
|
+
disabledDates?: (date: Date) => boolean;
|
|
35
|
+
maxEventsPerDay?: number;
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
error?: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
"aria-label"?: string;
|
|
40
|
+
todayLabel?: string;
|
|
41
|
+
moreLabel?: (count: number) => string;
|
|
42
|
+
noEventsLabel?: string;
|
|
43
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
44
|
+
onEventClick?: (event: CalendarEvent) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Month-view event calendar. Composes `Button`/`IconButton`/`Skeleton`/`Alert`
|
|
48
|
+
* for chrome rather than reimplementing them (doc: reuse, don't duplicate).
|
|
49
|
+
*
|
|
50
|
+
* Known limitations: only `view="month"` renders; no week/day/agenda/
|
|
51
|
+
* scheduler view and no drag-and-drop event moving yet — the `view` prop and
|
|
52
|
+
* `CalendarEvent` shape are deliberately future-proof for both.
|
|
53
|
+
*/
|
|
54
|
+
export declare function Calendar({ value, defaultValue, onDateChange, events, view, locale, weekStartsOn, min, max, disabledDates, maxEventsPerDay, loading, error, className, "aria-label": ariaLabel, todayLabel, moreLabel, noEventsLabel, onMonthChange, onEventClick, }: CalendarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChartCommonProps } from './chart/chartTypes';
|
|
3
|
+
export interface ChartProps extends ChartCommonProps {
|
|
4
|
+
/** Render prop — receives the measured surface size once a real width is known (never called at width 0). */
|
|
5
|
+
children: (size: {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}) => ReactNode;
|
|
9
|
+
/** No data to plot (distinct from `loading`/`error`) — renders `emptyMessage` instead of an empty SVG. */
|
|
10
|
+
isEmpty?: boolean;
|
|
11
|
+
legend?: ReactNode;
|
|
12
|
+
/** Visually-hidden textual/table fallback for screen reader and keyboard users who don't perceive the SVG (doc: chart data needs a non-visual summary). */
|
|
13
|
+
summary?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Low-level responsive shell every concrete chart (LineChart, BarChart, ...)
|
|
17
|
+
* composes for sizing + loading/empty/error chrome (doc: "Chart" is part of
|
|
18
|
+
* the public surface in its own right, for a consumer building a custom
|
|
19
|
+
* visualization without reimplementing that infrastructure).
|
|
20
|
+
*
|
|
21
|
+
* Deliberately not `role="img"`: a chart's data points are individually
|
|
22
|
+
* focusable (keyboard navigation between them), and `img` tells assistive
|
|
23
|
+
* tech to ignore all descendants. `group` plus the visually-hidden `summary`
|
|
24
|
+
* is what stays correct for an interactive chart.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Chart({ title, height, loading, error, emptyMessage, disabled, className, animate, "aria-label": ariaLabel, isEmpty, legend, summary, children, }: ChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChartSeries } from './chart/chartTypes';
|
|
2
|
+
export interface ChartLegendItem {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
color: string;
|
|
6
|
+
hidden?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ChartLegendProps {
|
|
9
|
+
items: readonly ChartLegendItem[];
|
|
10
|
+
/** Toggles one series' visibility. Omit to render a read-only legend. */
|
|
11
|
+
onToggle?: (key: string) => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Series swatches + labels, shared by every chart (doc section 5 — public,
|
|
16
|
+
* reused rather than reimplemented per chart type). Each item is a real
|
|
17
|
+
* `<button>` when `onToggle` is supplied, so toggling a series is keyboard-
|
|
18
|
+
* and screen-reader-accessible, not a `<div onClick>`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ChartLegend({ items, onToggle, className }: ChartLegendProps): import("react").JSX.Element;
|
|
21
|
+
/** Convenience: builds legend items straight from a chart's series list + resolved colors — the shape every concrete chart needs. */
|
|
22
|
+
export declare function legendItemsFromSeries(series: readonly ChartSeries[], colorOverrides: string[] | undefined, hiddenKeys: ReadonlySet<string>): ChartLegendItem[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type DocumentViewerSource = string | Blob | ArrayBuffer;
|
|
2
|
+
export type DocumentViewerErrorKind = "unsupported" | "password-protected" | "corrupted" | "network" | "unknown";
|
|
3
|
+
export interface DocumentViewerError {
|
|
4
|
+
kind: DocumentViewerErrorKind;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DocumentViewerLabels {
|
|
8
|
+
loading?: string;
|
|
9
|
+
unsupported?: string;
|
|
10
|
+
passwordProtected?: string;
|
|
11
|
+
corrupted?: string;
|
|
12
|
+
networkError?: string;
|
|
13
|
+
download?: string;
|
|
14
|
+
zoomIn?: string;
|
|
15
|
+
zoomOut?: string;
|
|
16
|
+
fitToWidth?: string;
|
|
17
|
+
fitToView?: string;
|
|
18
|
+
rotate?: string;
|
|
19
|
+
fullscreen?: string;
|
|
20
|
+
exitFullscreen?: string;
|
|
21
|
+
previousPage?: string;
|
|
22
|
+
nextPage?: string;
|
|
23
|
+
page?: string;
|
|
24
|
+
of?: string;
|
|
25
|
+
openInNewTab?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface DocumentViewerProps {
|
|
28
|
+
source: DocumentViewerSource;
|
|
29
|
+
fileName?: string;
|
|
30
|
+
/** MIME type, when known. Falls back to a safe guess from `fileName`'s extension when omitted. */
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Viewer surface height. Defaults to a fixed comfortable reading height rather than growing unbounded with page content. */
|
|
34
|
+
height?: number | string;
|
|
35
|
+
initialPage?: number;
|
|
36
|
+
toolbar?: boolean;
|
|
37
|
+
allowFullscreen?: boolean;
|
|
38
|
+
allowNewTab?: boolean;
|
|
39
|
+
/** No central i18n catalog lives in Base (doc: Smart owns the one exception) — override the visible strings here instead. */
|
|
40
|
+
labels?: DocumentViewerLabels;
|
|
41
|
+
/** Called instead of the built-in download behavior when supplied. */
|
|
42
|
+
onDownload?: () => void;
|
|
43
|
+
onError?: (error: DocumentViewerError) => void;
|
|
44
|
+
onPageChange?: (page: number, totalPages: number) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Previews PDF and common image formats without leaking SVG/canvas/portal
|
|
48
|
+
* plumbing to the consumer — a document/file card, a native `<embed>`, a
|
|
49
|
+
* third-party viewer, or a bespoke zoom/rotate/pagination toolbar are never
|
|
50
|
+
* something a consumer of this library builds by hand.
|
|
51
|
+
*
|
|
52
|
+
* `pdfjs-dist` is imported lazily (only once a PDF `source` is actually
|
|
53
|
+
* rendered), so an app that only ever previews images never pays for it.
|
|
54
|
+
* SVG/HTML/script sources are never rendered directly — anything outside the
|
|
55
|
+
* five supported formats below falls back to a file-info + download panel.
|
|
56
|
+
*/
|
|
57
|
+
export declare function DocumentViewer({ source, fileName, mimeType, className, height, initialPage, toolbar, allowFullscreen, allowNewTab, labels, onDownload, onError, onPageChange, }: DocumentViewerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CircularChartBaseProps } from './chart/CircularChartBase';
|
|
2
|
+
export type DonutChartProps = Omit<CircularChartBaseProps, "variant">;
|
|
3
|
+
/** A `PieChart` with a cutout center — `centerLabel`/`centerValue` render inside it. */
|
|
4
|
+
export declare function DonutChart(props: DonutChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CartesianChartCoreProps } from './chart/CartesianChart';
|
|
2
|
+
export type LineChartProps = Omit<CartesianChartCoreProps, "kind" | "orientation" | "stacked">;
|
|
3
|
+
/**
|
|
4
|
+
* `<LineChart title="..." data={data} xKey="month" series={[...]} />` — a
|
|
5
|
+
* consumer never touches SVG, ResizeObserver or a tooltip portal (doc section
|
|
6
|
+
* 5). Composes the shared `CartesianChart` renderer with `AreaChart`,
|
|
7
|
+
* `BarChart` and `StackedBarChart`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function LineChart(props: LineChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CircularChartBaseProps } from './chart/CircularChartBase';
|
|
2
|
+
export type PieChartProps = Omit<CircularChartBaseProps, "variant" | "innerRadiusRatio" | "centerLabel" | "centerValue">;
|
|
3
|
+
/** A single metric broken into categories (`nameKey`/`valueKey` over `data`). For a cutout center, use `DonutChart`. */
|
|
4
|
+
export declare function PieChart(props: PieChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CartesianChartCoreProps } from './chart/CartesianChart';
|
|
2
|
+
export type StackedBarChartProps = Omit<CartesianChartCoreProps, "kind" | "stacked">;
|
|
3
|
+
/** Every visible series stacks into one column per category. See `BarChart` for grouped bars. */
|
|
4
|
+
export declare function StackedBarChart(props: StackedBarChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChartCommonProps, ChartDatum, ChartInteraction, ChartSeries, ChartValue } from './chartTypes';
|
|
2
|
+
export interface CartesianChartCoreProps extends ChartCommonProps {
|
|
3
|
+
kind: "line" | "area" | "bar";
|
|
4
|
+
data: ChartDatum[];
|
|
5
|
+
xKey: string;
|
|
6
|
+
series: ChartSeries[];
|
|
7
|
+
xAxisLabel?: string;
|
|
8
|
+
yAxisLabel?: string;
|
|
9
|
+
showGrid?: boolean;
|
|
10
|
+
showDataLabels?: boolean;
|
|
11
|
+
xFormatter?: (value: ChartValue) => string;
|
|
12
|
+
yFormatter?: (value: number) => string;
|
|
13
|
+
/** Bar/StackedBar only. */
|
|
14
|
+
orientation?: "vertical" | "horizontal";
|
|
15
|
+
/** Bar only — StackedBarChart always passes `true` and hides the prop from its own public API. */
|
|
16
|
+
stacked?: boolean;
|
|
17
|
+
onDataPointClick?: (interaction: ChartInteraction) => void;
|
|
18
|
+
onLegendItemClick?: (seriesKey: string, hidden: boolean) => void;
|
|
19
|
+
locale?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Shared renderer behind LineChart/AreaChart/BarChart/StackedBarChart (doc:
|
|
23
|
+
* compose, don't reimplement per chart type — the only real differences
|
|
24
|
+
* between them are the mark shape and, for bars, orientation/stacking).
|
|
25
|
+
*
|
|
26
|
+
* Plain SVG, no charting dependency (the same call already made for
|
|
27
|
+
* `Sparkline`): a public API shaped around `data`/`xKey`/`series` stays
|
|
28
|
+
* implementation-agnostic, and the repository's Base layer has zero runtime
|
|
29
|
+
* dependencies today.
|
|
30
|
+
*/
|
|
31
|
+
export declare function CartesianChart({ kind, title, data, xKey, series, height, loading, error, emptyMessage, disabled, showLegend, showTooltip, showGrid, showDataLabels, animate, xAxisLabel, yAxisLabel, xFormatter, yFormatter, orientation, stacked, colors, className, onDataPointClick, onLegendItemClick, locale, "aria-label": ariaLabel, }: CartesianChartCoreProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ChartSliceSummaryProps {
|
|
2
|
+
items: readonly {
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
}[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Visually-hidden textual/table fallback of a circular chart's data (doc:
|
|
9
|
+
* "ekran okuyucu için tablo veya metinsel veri özeti") — name/value pairs,
|
|
10
|
+
* the shape Donut/Pie slices actually have (`CartesianChart` builds its own
|
|
11
|
+
* equivalent table inline, since its shape — a series per column — differs).
|
|
12
|
+
*/
|
|
13
|
+
export declare function ChartSliceSummary({ items }: ChartSliceSummaryProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChartStatusProps } from './chartTypes';
|
|
3
|
+
export interface ChartStatusOverlayProps extends ChartStatusProps {
|
|
4
|
+
height: number;
|
|
5
|
+
emptyMessage?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Loading/error/empty presentation shared by every chart (doc: "Chart,
|
|
9
|
+
* ChartLegend, ChartTooltip, ChartEmptyState" common infrastructure — kept as
|
|
10
|
+
* one internal piece rather than three, since none of the three states is
|
|
11
|
+
* ever shown without the others in this family).
|
|
12
|
+
*
|
|
13
|
+
* Not part of the public surface: each concrete chart decides when to render
|
|
14
|
+
* it, so there is nothing here a consumer would use standalone.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ChartStatusOverlay({ loading, error, emptyMessage, height }: ChartStatusOverlayProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ChartTooltipPayloadItem {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
color: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ChartTooltipPayload {
|
|
8
|
+
label: string;
|
|
9
|
+
items: ChartTooltipPayloadItem[];
|
|
10
|
+
}
|
|
11
|
+
export interface ChartTooltipProps {
|
|
12
|
+
payload: ChartTooltipPayload;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Summary of the currently focused/hovered data point (doc: tooltip).
|
|
17
|
+
* Deliberately not a cursor-following floating panel: that would need its own
|
|
18
|
+
* portal/collision-avoidance system duplicating `Popup`'s, for marginal gain —
|
|
19
|
+
* a fixed slot next to the chart (positioned by CSS, `.rrc-chart__tooltip`) is
|
|
20
|
+
* equally readable and stays keyboard- and touch-friendly without one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ChartTooltip({ payload, className }: ChartTooltipProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChartCommonProps, ChartDatum, ChartSliceInteraction } from './chartTypes';
|
|
3
|
+
export interface CircularChartBaseProps extends ChartCommonProps {
|
|
4
|
+
variant: "donut" | "pie";
|
|
5
|
+
data: ChartDatum[];
|
|
6
|
+
nameKey: string;
|
|
7
|
+
valueKey: string;
|
|
8
|
+
/** Donut only — ratio of the inner cutout radius to the outer radius. Ignored (forced to 0) for `variant="pie"`. */
|
|
9
|
+
innerRadiusRatio?: number;
|
|
10
|
+
/** Donut only — rendered in the center cutout. */
|
|
11
|
+
centerLabel?: ReactNode;
|
|
12
|
+
centerValue?: ReactNode;
|
|
13
|
+
valueFormatter?: (value: number) => string;
|
|
14
|
+
showDataLabels?: boolean;
|
|
15
|
+
onSliceClick?: (interaction: ChartSliceInteraction) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Shared renderer for DonutChart and PieChart. */
|
|
18
|
+
export declare function CircularChartBase({ variant, data, nameKey, valueKey, innerRadiusRatio, centerLabel, centerValue, valueFormatter, showDataLabels, showLegend, colors, onSliceClick, ...chartProps }: CircularChartBaseProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChartSeries } from './chartTypes';
|
|
2
|
+
export declare function resolveChartColor(index: number, explicit: string | undefined, overrides: string[] | undefined): string;
|
|
3
|
+
/** Resolves a color for every series in order — the shape `ChartLegend` and every concrete chart need. */
|
|
4
|
+
export declare function chartSeriesColorList(series: readonly ChartSeries[], overrides: string[] | undefined): string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal scale/tick math, written in-house rather than adding a dependency
|
|
3
|
+
* (d3-scale et al.) — the same call this repo already made for `Sparkline`.
|
|
4
|
+
* A handful of pure functions is enough for a band + linear axis and stays
|
|
5
|
+
* inside the library's zero-runtime-dependency footprint for the Base layer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function linearScale(domain: [number, number], range: [number, number]): (value: number) => number;
|
|
8
|
+
/** "Nice" round tick values spanning at least [min, max] — the standard d3-style rounding step. */
|
|
9
|
+
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
10
|
+
/** Evenly divides `size` into `count` bands, returning each band's start offset and width. */
|
|
11
|
+
export declare function bandScale(count: number, size: number, paddingRatio?: number): {
|
|
12
|
+
bandWidth: number;
|
|
13
|
+
offset: (index: number) => number;
|
|
14
|
+
};
|
|
15
|
+
export declare function defaultNumberFormatter(locale?: string): (value: number) => string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Small, semantic contracts shared by every chart in the family (doc section
|
|
4
|
+
* 13 — compose small parts rather than one "MassiveChartProps"). Every
|
|
5
|
+
* concrete chart (LineChart, BarChart, DonutChart, ...) extends the subset
|
|
6
|
+
* that applies to it.
|
|
7
|
+
*/
|
|
8
|
+
export type ChartValue = string | number | Date;
|
|
9
|
+
export type ChartTone = "primary" | "success" | "warning" | "danger" | "info" | "secondary";
|
|
10
|
+
/** A row of chart data. Cartesian charts index it by `xKey` + each series' `key`; circular charts by `nameKey`/`valueKey`. */
|
|
11
|
+
export type ChartDatum = Record<string, ChartValue | null | undefined>;
|
|
12
|
+
export interface ChartSeries {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
/** Explicit color — a CSS color or a `var(--rrc-*)` reference. Omitted: the chart's palette token assigns one by index. */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** Series sharing a `stackId` stack on top of each other in BarChart/StackedBarChart. */
|
|
18
|
+
stackId?: string;
|
|
19
|
+
/** Initial visibility; the legend can still toggle it (uncontrolled unless `hiddenSeriesKeys` is passed). */
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
valueFormatter?: (value: number) => string;
|
|
22
|
+
}
|
|
23
|
+
export interface ChartInteraction {
|
|
24
|
+
seriesKey: string;
|
|
25
|
+
datum: ChartDatum;
|
|
26
|
+
value: number;
|
|
27
|
+
index: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ChartSliceInteraction {
|
|
30
|
+
key: string;
|
|
31
|
+
label: string;
|
|
32
|
+
value: number;
|
|
33
|
+
index: number;
|
|
34
|
+
datum: ChartDatum;
|
|
35
|
+
}
|
|
36
|
+
/** Shared status/infrastructure props every chart composes via `Chart`/`ChartStatus` (doc: don't reimplement per chart type). */
|
|
37
|
+
export interface ChartStatusProps {
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
/** Non-empty renders the error state instead of the chart. */
|
|
40
|
+
error?: ReactNode;
|
|
41
|
+
/** Shown when `data` (or every series in it) is empty. */
|
|
42
|
+
emptyMessage?: ReactNode;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ChartCommonProps extends ChartStatusProps {
|
|
46
|
+
title?: string;
|
|
47
|
+
/** Fixed height; width is measured from the container (ResizeObserver, SSR-safe fallback). */
|
|
48
|
+
height?: number;
|
|
49
|
+
className?: string;
|
|
50
|
+
showLegend?: boolean;
|
|
51
|
+
showTooltip?: boolean;
|
|
52
|
+
/** Disables the CSS entrance animation; also forced off under `prefers-reduced-motion`. */
|
|
53
|
+
animate?: boolean;
|
|
54
|
+
/** Accessible name for the chart region; falls back to `title`. */
|
|
55
|
+
"aria-label"?: string;
|
|
56
|
+
/** Palette override, applied to series/slices in order before any per-item `color`. */
|
|
57
|
+
colors?: string[];
|
|
58
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measures the chart's own container width (doc: responsive width, no global
|
|
3
|
+
* breakpoint). Reuses `useElementResize` (ResizeObserver with a window-resize
|
|
4
|
+
* fallback, already SSR-safe) instead of a second measurement strategy.
|
|
5
|
+
*
|
|
6
|
+
* Starts at 0 so the very first server/client render emits no SVG at all
|
|
7
|
+
* (avoids a divide-by-zero layout before the real width is known); the
|
|
8
|
+
* measured width lands on the next paint, which is invisible to the user.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useChartDimensions(): {
|
|
11
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
12
|
+
width: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
export interface UseChartIndexNavigationOptions {
|
|
3
|
+
count: number;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
onActivate?: (index: number) => void;
|
|
6
|
+
onSelect?: (index: number) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface ChartIndexNavigation {
|
|
9
|
+
activeIndex: number;
|
|
10
|
+
setActiveIndex: (index: number) => void;
|
|
11
|
+
clearActive: () => void;
|
|
12
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Roving index navigation shared by every chart shape: Left/Right (or the
|
|
16
|
+
* next/previous data point) moves the focused/hover point, Home/End jump to
|
|
17
|
+
* the ends, Enter/Space fires the same callback a mouse click on that point
|
|
18
|
+
* would (doc: "veri noktasına tıklama" and "klavye ile veri noktaları arasında
|
|
19
|
+
* hareket" are one interaction model, not two). Used for x-categories in the
|
|
20
|
+
* cartesian charts (Line/Area/Bar/StackedBar) and for slices in the circular
|
|
21
|
+
* ones (Donut/Pie) — the math is identical, only what "index" means differs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useChartIndexNavigation({ count, disabled, onActivate, onSelect }: UseChartIndexNavigationOptions): ChartIndexNavigation;
|
package/dist/base/index.d.ts
CHANGED
|
@@ -59,6 +59,34 @@ export * from './IconButton';
|
|
|
59
59
|
export * from './ListItem';
|
|
60
60
|
export * from './Sparkline';
|
|
61
61
|
export * from './Statistic';
|
|
62
|
+
/**
|
|
63
|
+
* Chart family (doc: full-size Line/Area/Bar/StackedBar/Donut/Pie, distinct
|
|
64
|
+
* from the compact `Sparkline`). `Chart` is the shared responsive/status
|
|
65
|
+
* shell every concrete chart composes and is itself public for a consumer
|
|
66
|
+
* building a custom visualization; `ChartLegend` is the shared series legend.
|
|
67
|
+
* The per-chart-type render logic (`chart/*Base.tsx`) stays internal.
|
|
68
|
+
*/
|
|
69
|
+
export { Chart } from './Chart';
|
|
70
|
+
export type { ChartProps } from './Chart';
|
|
71
|
+
export { ChartLegend, legendItemsFromSeries } from './ChartLegend';
|
|
72
|
+
export type { ChartLegendItem, ChartLegendProps } from './ChartLegend';
|
|
73
|
+
export { LineChart } from './LineChart';
|
|
74
|
+
export type { LineChartProps } from './LineChart';
|
|
75
|
+
export { AreaChart } from './AreaChart';
|
|
76
|
+
export type { AreaChartProps } from './AreaChart';
|
|
77
|
+
export { BarChart } from './BarChart';
|
|
78
|
+
export type { BarChartProps } from './BarChart';
|
|
79
|
+
export { StackedBarChart } from './StackedBarChart';
|
|
80
|
+
export type { StackedBarChartProps } from './StackedBarChart';
|
|
81
|
+
export { DonutChart } from './DonutChart';
|
|
82
|
+
export type { DonutChartProps } from './DonutChart';
|
|
83
|
+
export { PieChart } from './PieChart';
|
|
84
|
+
export type { PieChartProps } from './PieChart';
|
|
85
|
+
export type { ChartCommonProps, ChartDatum, ChartInteraction, ChartSeries, ChartSliceInteraction, ChartStatusProps, ChartTone, ChartValue, } from './chart/chartTypes';
|
|
86
|
+
export { Calendar } from './Calendar';
|
|
87
|
+
export type { CalendarEvent, CalendarEventVariant, CalendarProps, CalendarView } from './Calendar';
|
|
88
|
+
export { DocumentViewer } from './DocumentViewer';
|
|
89
|
+
export type { DocumentViewerError, DocumentViewerErrorKind, DocumentViewerLabels, DocumentViewerProps, DocumentViewerSource, } from './DocumentViewer';
|
|
62
90
|
export { AppearanceProvider, useAppearance, createAppearanceInitScript, THEME_MODES, SIDEBAR_PRESENTATIONS, SIDEBAR_TONES } from './Appearance';
|
|
63
91
|
export type { AppearanceContextValue, AppearanceInitScriptOptions, AppearanceProviderProps, AppearanceSettings, AppearanceStorage, ResolvedTheme, SidebarPresentation, SidebarTone, ThemeMode, } from './Appearance';
|
|
64
92
|
export * from './appearanceSchemes';
|