rich-react-component 0.3.2 → 0.4.1

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.
Files changed (36) hide show
  1. package/README.md +178 -39
  2. package/dist/base/AreaChart.d.ts +4 -0
  3. package/dist/base/BarChart.d.ts +4 -0
  4. package/dist/base/Calendar.d.ts +54 -0
  5. package/dist/base/Chart.d.ts +26 -0
  6. package/dist/base/ChartLegend.d.ts +22 -0
  7. package/dist/base/DocumentViewer.d.ts +57 -0
  8. package/dist/base/DonutChart.d.ts +4 -0
  9. package/dist/base/LineChart.d.ts +9 -0
  10. package/dist/base/PieChart.d.ts +4 -0
  11. package/dist/base/StackedBarChart.d.ts +4 -0
  12. package/dist/base/chart/CartesianChart.d.ts +31 -0
  13. package/dist/base/chart/ChartSliceSummary.d.ts +13 -0
  14. package/dist/base/chart/ChartStatus.d.ts +16 -0
  15. package/dist/base/chart/ChartTooltip.d.ts +22 -0
  16. package/dist/base/chart/CircularChartBase.d.ts +18 -0
  17. package/dist/base/chart/chartColors.d.ts +4 -0
  18. package/dist/base/chart/chartScales.d.ts +15 -0
  19. package/dist/base/chart/chartTypes.d.ts +58 -0
  20. package/dist/base/chart/useChartDimensions.d.ts +13 -0
  21. package/dist/base/chart/useChartIndexNavigation.d.ts +23 -0
  22. package/dist/base/index.d.ts +28 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3270 -2136
  26. package/dist/index.js.map +1 -1
  27. package/dist/pdf-04d5ad63.js +14755 -0
  28. package/dist/pdf-04d5ad63.js.map +1 -0
  29. package/dist/pdf-c22cffd3.cjs +13 -0
  30. package/dist/pdf-c22cffd3.cjs.map +1 -0
  31. package/dist/pdf.worker.min-ab9f616e.cjs +2 -0
  32. package/dist/pdf.worker.min-ab9f616e.cjs.map +1 -0
  33. package/dist/pdf.worker.min-e6e7e836.js +5 -0
  34. package/dist/pdf.worker.min-e6e7e836.js.map +1 -0
  35. package/dist/style.css +1 -1
  36. package/package.json +75 -72
package/README.md CHANGED
@@ -20,30 +20,36 @@ Each layer **reuses** the one below it instead of reimplementing it — `RemoteC
20
20
  npm install rich-react-component bootstrap react react-dom
21
21
  ```
22
22
 
23
- `bootstrap`, `react`, and `react-dom` are peer dependencies — the library ships no CSS of its own beyond what Bootstrap classes provide.
23
+ `bootstrap`, `react`, and `react-dom` are peer dependencies. Bootstrap is still
24
+ loaded by the application:
24
25
 
25
26
  ```tsx
26
27
  import "bootstrap/dist/css/bootstrap.min.css";
27
28
  ```
28
29
 
29
- The library ships one opt-in stylesheet: a repository-owned **Metronic Bootstrap
30
- visual skin** covering every public component. It is emitted as a separate
31
- `dist/style.css` asset, so importing the package entry point stays
32
- side-effect-free for SSR. Load it after Bootstrap and before your own overrides:
33
-
34
- ```tsx
35
- import "bootstrap/dist/css/bootstrap.min.css";
36
- import "rich-react-component/style.css";
37
- // ...then your application's own overrides
38
- ```
39
-
40
- Every rule in it is anchored on a library-owned `rrc-*` class, so importing it
41
- cannot repaint your own Bootstrap markup components emit both their Bootstrap
42
- class and their `rrc-*` class, and a consumer who skips the import keeps plain
43
- Bootstrap. It is **not** the official Metronic stylesheet: no licensed Metronic
44
- or KeenIcons asset is used. Typography prefers Inter but the package never
45
- fetches a font; supply Inter from your application and it is picked up, or opt
46
- the whole page in with `body { font-family: var(--rrc-font-sans); }`.
30
+ The library ships one opt-in stylesheet: a repository-owned **Metronic Bootstrap
31
+ visual skin** covering every public component. It is emitted as a separate
32
+ `dist/style.css` asset, so importing the package entry point stays
33
+ side-effect-free for SSR. Load it after Bootstrap:
34
+
35
+ ```tsx
36
+ import "bootstrap/dist/css/bootstrap.min.css";
37
+ import "rich-react-component/style.css";
38
+ ```
39
+
40
+ Every rule in it is anchored on a library-owned `rrc-*` class, so importing it
41
+ cannot repaint your own Bootstrap markup components emit both their Bootstrap
42
+ class and their `rrc-*` class, and a consumer who skips the import keeps plain
43
+ Bootstrap. It is **not** the official Metronic stylesheet: no licensed Metronic
44
+ or KeenIcons asset is used. Typography prefers Inter but the package never
45
+ fetches a font; supply Inter from your application and it is picked up, or opt
46
+ the whole page in with `body { font-family: var(--rrc-font-sans); }`.
47
+
48
+ The same philosophy applies to application chrome in this repository's
49
+ showcase: no separate app stylesheet is required. Reusable showcase hooks live
50
+ under `rrc-showcase-*` and are delivered through the public package stylesheet,
51
+ so the demo app consumes the component library the way an application should:
52
+ through component APIs and the package CSS entry, not a local `demo.css`.
47
53
 
48
54
  ## Quick example
49
55
 
@@ -83,7 +89,7 @@ import { RemoteComboBox } from "rich-react-component";
83
89
 
84
90
  ## What's in each layer
85
91
 
86
- **Base** (57 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`), 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`).
92
+ **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
93
 
88
94
  `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
95
 
@@ -295,25 +301,154 @@ nor Metronic ships a dark variant of those variables, and the light-mode shades
295
301
  measure about 2:1 on a dark neutral. An application with its own dark palette
296
302
  overrides the `--rrc-*` tokens, which are the documented integration point.
297
303
 
304
+ ## Charts
305
+
306
+ Six full-size chart types share one responsive, accessible foundation — no SVG,
307
+ Canvas, ResizeObserver or tooltip portal in your own code:
308
+
309
+ ```tsx
310
+ import { LineChart } from "rich-react-component";
311
+
312
+ <LineChart
313
+ title="Monthly training completion"
314
+ data={data}
315
+ xKey="month"
316
+ series={[
317
+ { key: "completed", label: "Completed" },
318
+ { key: "missing", label: "Missing" },
319
+ ]}
320
+ />
321
+ ```
322
+
323
+ `LineChart`, `AreaChart`, `BarChart` (grouped, `orientation="vertical" |
324
+ "horizontal"`), `StackedBarChart`, `DonutChart` and `PieChart` all accept
325
+ `loading`/`error`/`isEmpty`, `showLegend`/`showTooltip`/`showDataLabels`,
326
+ per-series `color`/`hidden`/`valueFormatter`, and `animate` (also forced off
327
+ under `prefers-reduced-motion`). `Chart` is the shared responsive shell itself
328
+ — public for a custom SVG/Canvas visualization that still wants the same
329
+ sizing/status chrome — and `ChartLegend` is the shared, keyboard-operable
330
+ series legend both `LineChart`/`AreaChart`/`BarChart`/`StackedBarChart` compose.
331
+
332
+ Colors always come from theme tokens — `--rrc-chart-1` … `--rrc-chart-5` for
333
+ the categorical palette, `--rrc-chart-grid`/`--rrc-chart-axis` for the grid
334
+ and axis text, `--rrc-chart-tooltip-bg`/`--rrc-chart-tooltip-text` for the
335
+ tooltip — never hardcoded in a component, so a custom color scheme repaints
336
+ charts along with everything else.
337
+
338
+ **Accessibility.** Every data point/bar/slice is a real, individually
339
+ focusable, labelled target — arrow keys move between them, Enter/Space fires
340
+ `onDataPointClick`/`onSliceClick`, exactly like a mouse click on the same
341
+ point. A visually-hidden data table (or, for the circular charts, a
342
+ name/value list) carries the same numbers for a screen reader user, so the
343
+ chart's information is never conveyed by the drawing alone.
344
+
345
+ **Known limitation.** Very large series (tens of thousands of points) are not
346
+ virtualized or canvas-rendered — plain SVG, matching the same choice already
347
+ made for `Sparkline`, rather than a new charting dependency.
348
+
349
+ ## Calendar
350
+
351
+ A month-view event calendar — locale-aware, keyboard-operable, controlled or
352
+ uncontrolled:
353
+
354
+ ```tsx
355
+ <Calendar
356
+ locale="tr-TR"
357
+ weekStartsOn={1} // 0 = Sunday, 1 = Monday
358
+ value={selectedDate}
359
+ onDateChange={setSelectedDate}
360
+ events={events} // { id, title, start, end?, variant?, color?, disabled? }
361
+ onEventClick={handleEventClick}
362
+ onMonthChange={loadMonthEvents}
363
+ />
364
+ ```
365
+
366
+ Month/weekday names come from native `Intl.DateTimeFormat` — no date library
367
+ dependency. A day with more events than `maxEventsPerDay` (default 3) shows a
368
+ "+N more" control instead of overflowing the cell; below the `md` breakpoint
369
+ an agenda list of the selected day's events renders alongside the grid, via
370
+ plain Bootstrap responsive utility classes (no `matchMedia`, so it stays
371
+ SSR-safe).
372
+
373
+ **Timezone contract.** Every comparison uses the `Date` object's own local
374
+ getters (`getFullYear`/`getMonth`/`getDate`), never `Date.UTC` or ISO-string
375
+ parsing for day-bucketing — an event never silently shifts a day across a
376
+ timezone or DST boundary.
377
+
378
+ **Known limitation.** Only `view="month"` renders in this release. The `view`
379
+ prop and the `CalendarEvent` shape already accept `"week" | "day" | "agenda" |
380
+ "scheduler"` so a future release can add them without a breaking prop change;
381
+ passing one today falls back to month view with a development-mode warning.
382
+ Drag-and-drop event moving is not supported.
383
+
384
+ ## DocumentViewer
385
+
386
+ Previews a PDF or a common image format without your application touching
387
+ PDF.js, a `<canvas>`, or a blob URL:
388
+
389
+ ```tsx
390
+ <DocumentViewer
391
+ source={documentUrl} // string URL, or a Blob/ArrayBuffer already in hand
392
+ fileName="risk-assessment.pdf"
393
+ mimeType="application/pdf"
394
+ onDownload={handleDownload}
395
+ onError={handlePreviewError}
396
+ />
397
+ ```
398
+
399
+ Supports PDF, PNG, JPEG/JPG, WEBP and GIF. Page navigation, zoom, rotate,
400
+ fit-to-width/fit-to-view and fullscreen (which reuses the existing `Modal`,
401
+ escape-to-close included) are all built in. An unsupported file type never
402
+ renders a broken viewer — it shows the file's name/type and a download action
403
+ instead. Every built-in toolbar string can be overridden through the `labels`
404
+ prop, since no central i18n catalog lives in the Base layer.
405
+
406
+ **Dependency.** PDF rendering is powered by `pdfjs-dist`, this library's first
407
+ runtime dependency — but it is only ever `import()`-ed when a PDF is actually
408
+ previewed, so it lands in its own lazy chunk (verified via the real
409
+ `vite build` output: `pdf-*.js` and `pdf.worker.min-*.js` are separate from
410
+ `index.js`) and costs nothing for an application that only renders `Calendar`
411
+ or a chart. Its Web Worker is resolved through a bundler-native asset import,
412
+ so no manual worker configuration is needed in a Vite (or comparably
413
+ capable) consumer build.
414
+
415
+ **CORS/CSP.** A remote `source` URL is loaded the same way `<img src>` already
416
+ is elsewhere in this library — the browser (or, for a PDF, `pdfjs-dist`'s own
417
+ fetch/range-request handling) loads it directly, so the usual cross-origin
418
+ rules apply: the URL's own server must allow it, and a strict CSP needs
419
+ `worker-src` (for the PDF worker) and, for a cross-origin document, an
420
+ appropriate `connect-src`/`img-src` entry.
421
+
422
+ **Known limitations.** Fullscreen reuses `Modal` rather than the native
423
+ Fullscreen API (consistent with `Modal`'s own documented not-yet-portalled
424
+ limitation). No print action, text selection/search, or annotation layer
425
+ inside a previewed PDF — page rendering only. `FilePreview` was deliberately
426
+ not added as a second export; `DocumentViewer` is the only public name.
427
+
298
428
  ## Component showcase
299
429
 
300
- A dev-only application exercises the library live — not part of the published package:
430
+ A dev-only application exercises the library live:
301
431
 
302
432
  ```bash
303
433
  npm run dev
304
434
  ```
305
435
 
306
- The showcase is a routed single-page application: a persistent shell (categorized
307
- Sidebar, header, appearance drawer) with one route per public visual component,
308
- each page showing a live Preview and the source that produced it.
309
-
310
- - `/overview/introduction` — the landing route
311
- - `/components/<category>/<component>`one route per Base component
312
- - `/remote/<component>` and `/smart/<component>` the Remote and Smart layers
313
-
314
- The demo consumes the library through its real public specifier
315
- (`rich-react-component`), never through private source paths, so the package
316
- boundary is exercised the way a consumer exercises it.
436
+ The showcase is a routed single-page application: a persistent shell
437
+ (categorized Sidebar, header, appearance drawer) with one route per public
438
+ visual component, each page showing a live Preview and the source that produced
439
+ it.
440
+
441
+ - `/overview/introduction`the landing route
442
+ - `/overview/ensa-dashboard-example`an application-style ENSA dashboard
443
+ example built from `rich-react-component` components only
444
+ - `/components/<category>/<component>` one route per Base component
445
+ - `/remote/<component>` and `/smart/<component>` the Remote and Smart layers
446
+
447
+ The demo consumes the library through its real public specifier
448
+ (`rich-react-component`) and the public stylesheet
449
+ (`rich-react-component/style.css`), never through private source paths and never
450
+ through a separate `demo.css`. Showcase-specific surface classes are
451
+ `rrc-showcase-*`, owned by the package stylesheet.
317
452
 
318
453
  ## Scripts
319
454
 
@@ -336,13 +471,17 @@ src/
336
471
  ├── smart/ # Smart layer (Phases 1-5) — may depend on base/ and remote/
337
472
  └── index.ts # public entry point
338
473
 
339
- demo/ # dev-only routed showcase application (not published)
340
- registry/ # authoritative route/category metadata + public-export inventory
341
- shell/ # persistent app shell: sidebar, header, drawers, preferences
342
- pages/ # one lazily loaded module per category
343
- ui/ # page standard and the Preview/Code example viewer
344
- mocks/ # deterministic in-memory HttpClient for the Remote demos
345
- ```
474
+ demo/ # dev-only routed showcase application (not published)
475
+ registry/ # authoritative route/category metadata + public-export inventory
476
+ shell/ # persistent app shell: sidebar, header, drawers, preferences
477
+ pages/ # one lazily loaded module per category
478
+ ui/ # page standard and the Preview/Code example viewer
479
+ mocks/ # deterministic in-memory HttpClient for the Remote demos
480
+ ```
481
+
482
+ `src/styles/showcase.css` contains the reusable `rrc-showcase-*` application
483
+ surface that the showcase uses through `rich-react-component/style.css`; it is
484
+ not imported directly by the demo app.
346
485
 
347
486
  ## Testing
348
487
 
@@ -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;