@ultralabs/glass 0.0.0-stage → 0.1.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 (137) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/DESIGN.md +682 -0
  3. package/LICENSE +21 -0
  4. package/README.md +690 -2
  5. package/dist/esm/index.js +20991 -0
  6. package/dist/types/src/charts/ULCartesianChart.d.ts +177 -0
  7. package/dist/types/src/charts/ULDonutChart.d.ts +65 -0
  8. package/dist/types/src/charts/ULFunnelChart.d.ts +64 -0
  9. package/dist/types/src/charts/ULHeatmapChart.d.ts +40 -0
  10. package/dist/types/src/charts/ULRadarChart.d.ts +19 -0
  11. package/dist/types/src/charts/ULRadialChart.d.ts +48 -0
  12. package/dist/types/src/charts/ULScatterChart.d.ts +49 -0
  13. package/dist/types/src/charts/core.d.ts +287 -0
  14. package/dist/types/src/charts/decimate.d.ts +8 -0
  15. package/dist/types/src/charts/nav.d.ts +368 -0
  16. package/dist/types/src/charts/quadtree.d.ts +9 -0
  17. package/dist/types/src/charts/scales.d.ts +59 -0
  18. package/dist/types/src/charts/timeseries.d.ts +56 -0
  19. package/dist/types/src/components/ULAnchoredSurface/ULAnchoredSurface.d.ts +72 -0
  20. package/dist/types/src/components/ULBatch2/carousel.d.ts +31 -0
  21. package/dist/types/src/components/ULBatch2/hovercard.d.ts +40 -0
  22. package/dist/types/src/components/ULBatch2/layout.d.ts +16 -0
  23. package/dist/types/src/components/ULBatch2/menubar.d.ts +29 -0
  24. package/dist/types/src/components/ULBatch2/navmenu.d.ts +51 -0
  25. package/dist/types/src/components/ULBatch2/resizable.d.ts +48 -0
  26. package/dist/types/src/components/ULBatch2/typography.d.ts +55 -0
  27. package/dist/types/src/components/ULButton/ULButton.d.ts +87 -0
  28. package/dist/types/src/components/ULContainers/ULCard.d.ts +54 -0
  29. package/dist/types/src/components/ULContainers/ULDialog.d.ts +57 -0
  30. package/dist/types/src/components/ULContainers/ULLayout.d.ts +81 -0
  31. package/dist/types/src/components/ULContainers/ULMenu.d.ts +99 -0
  32. package/dist/types/src/components/ULContainers/ULOverlays.d.ts +113 -0
  33. package/dist/types/src/components/ULContainers/contextTarget.d.ts +91 -0
  34. package/dist/types/src/components/ULData/ULData.d.ts +225 -0
  35. package/dist/types/src/components/ULData/ULKpi.d.ts +159 -0
  36. package/dist/types/src/components/ULField/ULField.d.ts +93 -0
  37. package/dist/types/src/components/ULForms/fieldContext.d.ts +39 -0
  38. package/dist/types/src/components/ULForms/forms.d.ts +143 -0
  39. package/dist/types/src/components/ULIsland/ULIsland.d.ts +39 -0
  40. package/dist/types/src/components/ULIsland/headerConfig.d.ts +43 -0
  41. package/dist/types/src/components/ULIsland/navIndicator.d.ts +26 -0
  42. package/dist/types/src/components/ULListbox/ULListbox.d.ts +75 -0
  43. package/dist/types/src/components/ULPickers/ULPickers.d.ts +141 -0
  44. package/dist/types/src/components/ULSegmented/ULSegmented.d.ts +50 -0
  45. package/dist/types/src/components/ULSelection/ULSelection.d.ts +71 -0
  46. package/dist/types/src/components/ULSlider/ULSlider.d.ts +43 -0
  47. package/dist/types/src/components/ULSpinner/ULSpinner.d.ts +8 -0
  48. package/dist/types/src/components/ULStructure/kbd.d.ts +22 -0
  49. package/dist/types/src/components/ULStructure/structure.d.ts +154 -0
  50. package/dist/types/src/components/ULTabs/ULTabs.d.ts +28 -0
  51. package/dist/types/src/components/ULTooltip/anchoredTooltip.d.ts +22 -0
  52. package/dist/types/src/components/actions/actions.d.ts +175 -0
  53. package/dist/types/src/components/actions/core.d.ts +346 -0
  54. package/dist/types/src/components/dashboard/blocks.d.ts +583 -0
  55. package/dist/types/src/components/dashboard/blocks2.d.ts +297 -0
  56. package/dist/types/src/components/dashboard/columnsDrag.d.ts +27 -0
  57. package/dist/types/src/components/shared/ULCheckMark.d.ts +9 -0
  58. package/dist/types/src/components/shared/dev.d.ts +13 -0
  59. package/dist/types/src/components/shared/icons.d.ts +23 -0
  60. package/dist/types/src/glass/ULGlass.d.ts +78 -0
  61. package/dist/types/src/glass/ULGlassGroup.d.ts +16 -0
  62. package/dist/types/src/glass/accent.d.ts +31 -0
  63. package/dist/types/src/glass/contrast.d.ts +78 -0
  64. package/dist/types/src/glass/engine.d.ts +177 -0
  65. package/dist/types/src/glass/glassDebug.d.ts +27 -0
  66. package/dist/types/src/glass/material.d.ts +49 -0
  67. package/dist/types/src/glass/radius.d.ts +2 -0
  68. package/dist/types/src/hooks/useAnchoredMorph.d.ts +20 -0
  69. package/dist/types/src/hooks/usePointerLight.d.ts +6 -0
  70. package/dist/types/src/hooks/useReducedMotion.d.ts +3 -0
  71. package/dist/types/src/index.d.ts +150 -0
  72. package/dist/types/src/island/sectionAccent.d.ts +18 -0
  73. package/dist/types/src/live/ULLiveStatus.d.ts +18 -0
  74. package/dist/types/src/live/liveQueue.d.ts +13 -0
  75. package/dist/types/src/live/liveSource.d.ts +149 -0
  76. package/dist/types/src/live/liveStore.d.ts +72 -0
  77. package/dist/types/src/motion/anchoredMorph.d.ts +175 -0
  78. package/dist/types/src/motion/goo.d.ts +3 -0
  79. package/dist/types/src/motion/lensBubble.d.ts +143 -0
  80. package/dist/types/src/motion/lensSelect.d.ts +31 -0
  81. package/dist/types/src/motion/overlayStack.d.ts +13 -0
  82. package/dist/types/src/motion/placement.d.ts +18 -0
  83. package/dist/types/src/motion/spring.d.ts +20 -0
  84. package/dist/types/src/motion/topLayer.d.ts +13 -0
  85. package/dist/types/src/motion/viewSwap.d.ts +33 -0
  86. package/dist/types/src/motion/virtualAnchor.d.ts +28 -0
  87. package/dist/ul-glass.css +10519 -0
  88. package/dist/ul-glass.js +21034 -0
  89. package/dist/ul-glass.min.js +14 -0
  90. package/dist/ul-glass.min.js.map +7 -0
  91. package/icons/arrow-up-down.svg +5 -0
  92. package/icons/bell.svg +3 -0
  93. package/icons/bold.svg +2 -0
  94. package/icons/calendar.svg +5 -0
  95. package/icons/check.svg +2 -0
  96. package/icons/chevron-down.svg +2 -0
  97. package/icons/chevron-left.svg +2 -0
  98. package/icons/chevron-right.svg +2 -0
  99. package/icons/chevrons-right.svg +3 -0
  100. package/icons/circle-check.svg +3 -0
  101. package/icons/circle-x.svg +4 -0
  102. package/icons/circle.svg +2 -0
  103. package/icons/copy.svg +3 -0
  104. package/icons/ellipsis.svg +4 -0
  105. package/icons/eye.svg +3 -0
  106. package/icons/filter.svg +2 -0
  107. package/icons/flags/LICENSE.md +2 -0
  108. package/icons/flags/cs.svg +1 -0
  109. package/icons/flags/de.svg +1 -0
  110. package/icons/flags/en.svg +1 -0
  111. package/icons/flags/sk.svg +1 -0
  112. package/icons/folder-kanban.svg +5 -0
  113. package/icons/icons.json +1 -0
  114. package/icons/inbox.svg +3 -0
  115. package/icons/info.svg +4 -0
  116. package/icons/layout-dashboard.svg +5 -0
  117. package/icons/layout-grid.svg +5 -0
  118. package/icons/loader-circle.svg +2 -0
  119. package/icons/lock.svg +3 -0
  120. package/icons/mail.svg +3 -0
  121. package/icons/menu.svg +4 -0
  122. package/icons/minus.svg +2 -0
  123. package/icons/panel-left-close.svg +4 -0
  124. package/icons/plus.svg +3 -0
  125. package/icons/refresh-cw.svg +5 -0
  126. package/icons/search.svg +3 -0
  127. package/icons/shield-check.svg +3 -0
  128. package/icons/shopping-bag.svg +4 -0
  129. package/icons/sparkles.svg +6 -0
  130. package/icons/trash-2.svg +6 -0
  131. package/icons/triangle-alert.svg +4 -0
  132. package/icons/upload.svg +4 -0
  133. package/icons/users.svg +5 -0
  134. package/icons/x.svg +3 -0
  135. package/package.json +65 -4
  136. package/tokens/tokens.css +799 -0
  137. package/tokens/tokens.json +1017 -0
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Chart core (React): text, palette cues, responsive size, tween (draw-in + morph), the panel frame with header, toolbar,
3
+ * legend, states, data table, live region, and the snapped hover layer (crosshair + beads + value tooltip).
4
+ * Rules: the panel is the only glass surface (lite); the plot never refracts; pointer moves never set React state; the
5
+ * hover layer writes one transform per frame and touches content only when the snapped point changes.
6
+ */
7
+ import * as React from 'react';
8
+ import { type Accent } from '../glass/accent.js';
9
+ import { type ContextMenuProps, type ContextTarget } from '../components/ULContainers/contextTarget.js';
10
+ import { type ScatterShape } from './scales.js';
11
+ import './charts.css';
12
+ declare const T: {
13
+ en: {
14
+ table: string;
15
+ chart: string;
16
+ loading: string;
17
+ empty: string;
18
+ emptyHint: string;
19
+ error: string;
20
+ stale: string;
21
+ other: string;
22
+ series: string;
23
+ csv: string;
24
+ copy: string;
25
+ download: string;
26
+ total: string;
27
+ nav: string;
28
+ from: string;
29
+ to: string;
30
+ low: string;
31
+ high: string;
32
+ pinned: string;
33
+ category: string;
34
+ share: string;
35
+ win: string;
36
+ loss: string;
37
+ };
38
+ sk: {
39
+ table: string;
40
+ chart: string;
41
+ loading: string;
42
+ empty: string;
43
+ emptyHint: string;
44
+ error: string;
45
+ stale: string;
46
+ other: string;
47
+ series: string;
48
+ csv: string;
49
+ copy: string;
50
+ download: string;
51
+ total: string;
52
+ nav: string;
53
+ from: string;
54
+ to: string;
55
+ low: string;
56
+ high: string;
57
+ pinned: string;
58
+ category: string;
59
+ share: string;
60
+ win: string;
61
+ loss: string;
62
+ };
63
+ de: {
64
+ table: string;
65
+ chart: string;
66
+ loading: string;
67
+ empty: string;
68
+ emptyHint: string;
69
+ error: string;
70
+ stale: string;
71
+ other: string;
72
+ series: string;
73
+ csv: string;
74
+ copy: string;
75
+ download: string;
76
+ total: string;
77
+ nav: string;
78
+ from: string;
79
+ to: string;
80
+ low: string;
81
+ high: string;
82
+ pinned: string;
83
+ category: string;
84
+ share: string;
85
+ win: string;
86
+ loss: string;
87
+ };
88
+ cs: {
89
+ table: string;
90
+ chart: string;
91
+ loading: string;
92
+ empty: string;
93
+ emptyHint: string;
94
+ error: string;
95
+ stale: string;
96
+ other: string;
97
+ series: string;
98
+ csv: string;
99
+ copy: string;
100
+ download: string;
101
+ total: string;
102
+ nav: string;
103
+ from: string;
104
+ to: string;
105
+ low: string;
106
+ high: string;
107
+ pinned: string;
108
+ category: string;
109
+ share: string;
110
+ win: string;
111
+ loss: string;
112
+ };
113
+ };
114
+ export type ChartTextKey = keyof typeof T.en;
115
+ export declare const chartText: (k: ChartTextKey, locale?: string) => string;
116
+ /** Secondary cue per series slot (colour is never the only signal): line dash and fill pattern id. Slot 0 is solid. */
117
+ export declare const SERIES_DASH: string[];
118
+ export declare const SERIES_SLOTS = 6;
119
+ export declare const slotOf: (i: number) => number;
120
+ /** <defs> patterns for fills; referenced as url(#{id}-p{slot}). */
121
+ export declare function ChartPatterns({ id }: {
122
+ id: string;
123
+ }): React.JSX.Element;
124
+ export type PatternMode = 'auto' | 'on' | 'off';
125
+ export interface PatternPolicy {
126
+ mode: PatternMode;
127
+ fills: boolean;
128
+ dash(slot: number, order: number): string;
129
+ state: 'on' | 'auto-fills' | 'auto-lines' | 'off';
130
+ }
131
+ /**
132
+ * auto: series 3+ (order ≥ 2) get a dash on line marks; fills (areas, bars, slices) get patterns only with more than 4
133
+ * series / categories or under prefers-contrast: more / forced-colors. on: every cue. off: none (colour + legend only).
134
+ */
135
+ export declare function usePatternPolicy(mode: PatternMode | undefined, count: number): PatternPolicy;
136
+ /** Legend / tooltip key: a short line with the series dash, or a swatch that mirrors the fill pattern. */
137
+ export declare function SeriesKey({ slot, mark, dash, pattern, shape }: {
138
+ slot: number;
139
+ mark?: 'line' | 'fill';
140
+ dash?: string;
141
+ pattern?: boolean;
142
+ shape?: ScatterShape;
143
+ }): React.JSX.Element;
144
+ /** Width of the plot box from a ResizeObserver; state changes only when the integer width changes (no thrash). */
145
+ export declare function useWidth(ref: React.RefObject<HTMLElement | null>, fallback?: number): number;
146
+ export interface TweenFrame {
147
+ v: (number | null)[][];
148
+ w: number[];
149
+ d: number[];
150
+ }
151
+ /**
152
+ * Interpolates values (v), series weights (w: legend in/out) and domains (d: axes rescale) together.
153
+ * Same key = same data: no animation. A new target mid-flight starts from the current frame (interruptible).
154
+ * Different shape (length change): jumps, the caller fades. Reduced motion: jumps (caller fades).
155
+ */
156
+ /** Test hook (no UI): morph starts and the first value of every applied frame. Read by the chart test cards. */
157
+ export declare const chartStats: {
158
+ morphs: number;
159
+ frames: number;
160
+ log: {
161
+ from: number | null;
162
+ to: number | null;
163
+ first: number | null;
164
+ }[];
165
+ last: number | null;
166
+ };
167
+ export declare function useChartTween(target: TweenFrame, key: string, enabled?: boolean): {
168
+ frame: TweenFrame;
169
+ morphing: boolean;
170
+ };
171
+ /** One-time draw-in on mount: lines by stroke-dashoffset, bars grow (clip from the baseline), areas reveal left → right. Reduced motion: a short fade. */
172
+ export declare function useDrawIn(svg: React.RefObject<SVGSVGElement | null>, horizontal?: boolean): void;
173
+ /** Reduced-motion data change: a short fade instead of the morph. */
174
+ export declare function useChangeFade(el: React.RefObject<Element | null>, key: string): void;
175
+ export interface HoverRow {
176
+ slot: number;
177
+ name: string;
178
+ value: string;
179
+ mark?: 'line' | 'fill';
180
+ dash?: string;
181
+ }
182
+ export interface HoverPoint {
183
+ index: number;
184
+ x: number;
185
+ y: number;
186
+ title: string;
187
+ rows: HoverRow[];
188
+ beads: {
189
+ slot: number;
190
+ x: number;
191
+ y: number;
192
+ }[];
193
+ }
194
+ export interface HoverApi {
195
+ layer: React.ReactNode;
196
+ /** Snap to a point. Writes content only when the index (or pin state) changes; otherwise nothing. */
197
+ show(p: HoverPoint | null): void;
198
+ pin(on: boolean): void;
199
+ readonly pinned: boolean;
200
+ readonly index: number | null;
201
+ }
202
+ /**
203
+ * The value tooltip follows the slider value-tooltip rule (CLAUDE.md exception): sticky, no spring while tracking, same
204
+ * opaque shape + arrow as createAnchoredTooltip, never glass. One transform write per frame on the positioner.
205
+ */
206
+ export declare function useHoverLayer(opts: {
207
+ width: number;
208
+ height: number;
209
+ plot: {
210
+ l: number;
211
+ t: number;
212
+ r: number;
213
+ b: number;
214
+ };
215
+ orient?: 'v' | 'h';
216
+ crosshair?: boolean; /** bar charts: crosshair becomes a band of this size */
217
+ band?: number;
218
+ }): HoverApi;
219
+ export interface LegendItem {
220
+ key: string;
221
+ name: string;
222
+ slot: number;
223
+ mark?: 'line' | 'fill';
224
+ on: boolean;
225
+ dash?: string;
226
+ pattern?: boolean;
227
+ shape?: ScatterShape;
228
+ }
229
+ export declare function ChartLegend({ items, onToggle, onFocusSeries, label }: {
230
+ items: LegendItem[];
231
+ onToggle?: (key: string) => void;
232
+ onFocusSeries?: (key: string | null) => void;
233
+ label: string;
234
+ }): React.JSX.Element;
235
+ export declare function ChartSkeleton({ shape, height }: {
236
+ shape: 'line' | 'area' | 'bar' | 'hbar' | 'donut' | 'combo' | 'gauge' | 'radar' | 'scatter' | 'grid' | 'funnel' | 'treemap';
237
+ height: number;
238
+ }): React.JSX.Element;
239
+ export type ChartState = 'ready' | 'loading' | 'empty' | 'error';
240
+ export interface ChartTable {
241
+ columns: string[];
242
+ rows: (string | number)[][];
243
+ rowHeader?: boolean;
244
+ }
245
+ export interface ChartFrameProps {
246
+ /** Chart title (panel heading, names the figure). */ title: React.ReactNode; /** Short description under the title. */
247
+ description?: React.ReactNode; /** Text summary for screen readers (read before the data table). */
248
+ summary: string; /** "en" | "sk" | "de" | "cs" for numbers, dates and built-in strings. Default "en". */
249
+ locale?: string; /** Accent colour of the panel; series colours derive from it (--ul-chart-s0…s5). */
250
+ accent?: Accent; /** Wrap in the one glass chart panel. Default true; false for embedding in another surface. */
251
+ panel?: boolean; /** Extra class on the panel. */
252
+ className?: string;
253
+ /** "ready" | "loading" | "empty" | "error" — skeleton, empty and error states keep the panel size. */ state?: ChartState; /** Error state Retry action. */
254
+ onRetry?: () => unknown; /** Error state text. Default localised. */
255
+ errorMessage?: React.ReactNode; /** Empty state content. Default localised "No data". */
256
+ empty?: {
257
+ title?: React.ReactNode;
258
+ description?: React.ReactNode;
259
+ action?: React.ReactNode;
260
+ };
261
+ /** Stale badge (true or a custom label) when the data is old. */ stale?: boolean | string; /** Plot height in px. */
262
+ height: number; /** Skeleton shape shown while loading. */
263
+ skeleton: Parameters<typeof ChartSkeleton>[0]['shape'];
264
+ /** Data table definition (columns + rows) for the table view and CSV. */ table: ChartTable; /** Legend element (ChartLegend). */
265
+ legend?: React.ReactNode; /** "auto" (default) | "on" | "off" — dash / hatch cues per the patterns policy. */
266
+ patterns?: PatternPolicy['state']; /** Show the toolbar (table, copy, CSV). Default true. */
267
+ toolbar?: boolean; /** Base file name of the CSV export. */
268
+ filename?: string; /** Open with the data table shown. Default false. */
269
+ defaultTable?: boolean; /** Ref of the polite live region (announcements of the chart). */
270
+ liveRef?: React.Ref<HTMLDivElement>;
271
+ /** Chart body. */ children: React.ReactNode; /** Content under the plot. */
272
+ footer?: React.ReactNode;
273
+ }
274
+ export declare const tableToCsv: (t: ChartTable) => string;
275
+ export declare const tableToTsv: (t: ChartTable) => string;
276
+ export declare function ChartFrame(p: ChartFrameProps): React.JSX.Element;
277
+ export declare function ChartDataTable({ table, caption, height }: {
278
+ table: ChartTable;
279
+ caption: string;
280
+ height: number;
281
+ }): React.JSX.Element;
282
+ export declare function withChartMenu<D>(node: React.ReactElement, ctx: ContextMenuProps<D>, resolve: (hit: Element, root: HTMLElement) => Omit<ContextTarget<D>, 'component'> | null): React.JSX.Element;
283
+ /** Splits ContextMenuProps off a props object. */
284
+ /** Target type carried by a props type's contextMenu spec (inferred per chart: points, cells, tiles, steps …). */
285
+ export type CtxTargetOf<P> = P extends ContextMenuProps<infer T> ? T : unknown;
286
+ export declare function splitChartCtx<P extends ContextMenuProps<any>, T = CtxTargetOf<P>>(p: P): [ContextMenuProps<T>, Omit<P, keyof ContextMenuProps<T>>];
287
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Largest-Triangle-Three-Buckets decimation (Steinarsson) for drawing only: tooltip, keyboard and table keep every point.
3
+ * Output: sorted indices, exactly `threshold` long when n > threshold (first, last, one per bucket); the global minimum
4
+ * and maximum are always kept (they replace their bucket's pick). Null values are kept so gaps survive.
5
+ */
6
+ export declare function lttb(xs: ArrayLike<number>, ys: ArrayLike<number | null>, threshold: number): number[];
7
+ /** Canvas renderer switch point (token --ul-chart-canvas-at, default 5000 points). */
8
+ export declare function canvasThreshold(): number;
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Shared mark navigation for index-based charts (radial, gauge, radar, scatter, heatmap, funnel, histogram, treemap):
3
+ * pointer → mark (data-mark attribute or a picker such as the quadtree), keyboard walk, Enter / click pin, Esc unpin, the
4
+ * polite live text, and the focus hook for the mark highlight. One implementation; the chart supplies pointAt and moves.
5
+ * Pointer moves never set React state; the hover layer writes content only when the mark changes.
6
+ */
7
+ import * as React from 'react';
8
+ import type { Accent } from '../glass/accent.js';
9
+ import type { ContextMenuProps } from '../components/ULContainers/contextTarget.js';
10
+ import type { ChartPointTarget } from './ULCartesianChart.js';
11
+ import type { PatternMode, ChartState } from './core.js';
12
+ import type { HoverApi, HoverPoint } from './core.js';
13
+ export type NavKey = 'next' | 'prev' | 'up' | 'down' | 'home' | 'end';
14
+ export interface MarkNavOptions {
15
+ hover: HoverApi;
16
+ count: number;
17
+ /** Hidden marks (legend off) are skipped. */
18
+ visible?: (i: number) => boolean;
19
+ pointAt: (i: number) => HoverPoint;
20
+ liveRef: React.RefObject<HTMLDivElement | null>;
21
+ /** Highlight hook (dims the other marks). */
22
+ onFocusMark?: (i: number | null) => void;
23
+ /** Custom moves (grid rows, series walk, nearest neighbour). Return null to fall back to index order. */
24
+ move?: (cur: number | null, k: NavKey, e: React.KeyboardEvent) => number | null | undefined;
25
+ /** Pointer picker in plot coordinates (quadtree). Default: closest [data-mark] element. */
26
+ pick?: (x: number, y: number, target: EventTarget | null) => number | null;
27
+ /** Live text for a mark. Default: title + rows. */
28
+ say?: (p: HoverPoint) => string;
29
+ /** Extra keys (zoom, brush); return true when handled. */
30
+ onKey?: (e: React.KeyboardEvent) => boolean;
31
+ }
32
+ export declare const markOf: (t: EventTarget | null) => number | null;
33
+ export declare const sayPoint: (p: HoverPoint) => string;
34
+ export declare function useMarkNav(o: MarkNavOptions): {
35
+ show: (i: number | null, say?: boolean) => void;
36
+ bind: {
37
+ onPointerMove: (e: React.PointerEvent) => void;
38
+ onPointerLeave: () => void;
39
+ onClick: (e: React.MouseEvent) => void;
40
+ onKeyDown: (e: React.KeyboardEvent) => void;
41
+ onBlur: () => void;
42
+ };
43
+ };
44
+ /** Props every advanced chart shares (frame, states, toolbar, patterns, context menu). */
45
+ export interface ChartBaseProps extends ContextMenuProps<ChartPointTarget> {
46
+ /** Chart title (panel heading, names the figure). */ title: React.ReactNode; /** Short description under the title. */
47
+ description?: React.ReactNode; /** Text summary for screen readers (read before the data table). */
48
+ summary?: string; /** Plot height in px. */
49
+ height?: number; /** "en" | "sk" | "de" | "cs" for numbers, dates and built-in strings. Default "en". */
50
+ locale?: string;
51
+ /** Intl.NumberFormat options for values (tooltip, table, legend). */ valueFormat?: Intl.NumberFormatOptions; /** Formats values for ticks, tooltip and table: Intl options or (v) => string. */
52
+ format?: (v: number) => string;
53
+ /** Accent colour of the panel; series colours derive from it (--ul-chart-s0…s5). */ accent?: Accent; /** Wrap in the one glass chart panel. Default true; false for embedding in another surface. */
54
+ panel?: boolean; /** Extra class on the panel. */
55
+ className?: string; /** Show the legend (toggles series). Default true for more than one series. */
56
+ legend?: boolean; /** Show the toolbar (table, copy, CSV). Default true. */
57
+ toolbar?: boolean; /** Base file name of the CSV export. */
58
+ filename?: string;
59
+ /** "ready" | "loading" | "empty" | "error" — skeleton, empty and error states keep the panel size. */ state?: ChartState; /** Error state Retry action. */
60
+ onRetry?: () => unknown; /** Error state text. Default localised. */
61
+ errorMessage?: React.ReactNode; /** Empty state content. Default localised "No data". */
62
+ empty?: {
63
+ title?: React.ReactNode;
64
+ description?: React.ReactNode;
65
+ action?: React.ReactNode;
66
+ }; /** Stale badge (true or a custom label) when the data is old. */
67
+ stale?: boolean | string; /** Open with the data table shown. Default false. */
68
+ defaultTable?: boolean;
69
+ /** "auto" (default) | "on" | "off" — dash / hatch cues per the patterns policy. */ patterns?: PatternMode;
70
+ }
71
+ export declare const baseFrame: (p: ChartBaseProps, n: number) => {
72
+ title: React.ReactNode;
73
+ description: React.ReactNode;
74
+ locale: string | undefined;
75
+ accent: Accent | undefined;
76
+ panel: boolean | undefined;
77
+ className: string | undefined;
78
+ onRetry: (() => unknown) | undefined;
79
+ errorMessage: React.ReactNode;
80
+ empty: {
81
+ title?: React.ReactNode;
82
+ description?: React.ReactNode;
83
+ action?: React.ReactNode;
84
+ } | undefined;
85
+ stale: string | boolean | undefined;
86
+ toolbar: boolean | undefined;
87
+ filename: string | undefined;
88
+ defaultTable: boolean | undefined;
89
+ state: ChartState | undefined;
90
+ };
91
+ /** One-time draw-in on mount; reduced motion = short fade. */
92
+ export declare function useDrawOnce(svg: React.RefObject<SVGSVGElement | null>, run: (root: SVGSVGElement, dur: number, ease: string) => void): void;
93
+ /** Highlight one mark (others dim through CSS svg[data-hot]). */
94
+ export declare const focusMarkIn: (svg: SVGSVGElement | null, i: number | null) => void;
95
+ export declare const ctxResolve: (plotSel: string, hoverIndex: () => number | null, point: (i: number, hit: Element) => {
96
+ kind: string;
97
+ id?: string;
98
+ data: ChartPointTarget & Record<string, unknown>;
99
+ } | null) => (hit: Element) => {
100
+ el: HTMLElement;
101
+ kind: string;
102
+ id?: string;
103
+ data: ChartPointTarget & Record<string, unknown>;
104
+ } | null;
105
+ export interface Box {
106
+ l: number;
107
+ t: number;
108
+ r: number;
109
+ b: number;
110
+ }
111
+ export declare function ChartAxes({ W, H, plot, xs, ys, xTicks, yTicks, xFmt, yFmt, xGrid }: {
112
+ W: number;
113
+ H: number;
114
+ plot: Box;
115
+ xs: (v: number) => number;
116
+ ys: (v: number) => number;
117
+ xTicks: number[];
118
+ yTicks: number[];
119
+ xFmt: (v: number) => string;
120
+ yFmt: (v: number) => string;
121
+ xGrid?: boolean;
122
+ }): React.JSX.Element;
123
+ /** Left margin that fits the widest y tick label. */
124
+ export declare const leftFor: (labels: string[]) => number;
125
+ export interface BrushRect {
126
+ x0: number;
127
+ y0: number;
128
+ x1: number;
129
+ y1: number;
130
+ }
131
+ /**
132
+ * Drag selection drawn straight to the DOM (no React state per move). mode 'x' spans the plot height.
133
+ * The readout uses the opaque value-tooltip shape (nothing inside the panel samples glass). Esc cancels.
134
+ */
135
+ export declare function useBrush(o: {
136
+ mode: 'x' | 'xy';
137
+ plot: Box;
138
+ W: number;
139
+ H: number;
140
+ enabled?: boolean;
141
+ label: (r: BrushRect) => string;
142
+ onEnd: (r: BrushRect | null) => void;
143
+ minPx?: number;
144
+ }): {
145
+ cancel(): boolean;
146
+ /** True right after a brush ended (the click that follows is not a pin). */
147
+ swallowClick(): boolean;
148
+ readonly active: boolean;
149
+ bind: {
150
+ onPointerDown: (e: React.PointerEvent) => void;
151
+ onPointerMove: (e: React.PointerEvent) => boolean;
152
+ onPointerUp: () => void;
153
+ };
154
+ layer: React.JSX.Element;
155
+ };
156
+ export type ColorScheme = 'sequential' | 'diverging';
157
+ export interface ColorScale {
158
+ q(v: number | null | undefined): number;
159
+ lo: number;
160
+ hi: number;
161
+ edges: number[];
162
+ scheme: ColorScheme;
163
+ steps: number;
164
+ }
165
+ /** Quantised, colour-blind-safe scale over the --ul-chart-seq-* / --ul-chart-div-* tokens (7 steps). Diverging is symmetric around mid. */
166
+ export declare function colorScale(values: (number | null | undefined)[], scheme?: ColorScheme, domain?: [number, number], mid?: number, steps?: number): ColorScale;
167
+ export declare function ColorLegend({ scale, fmt: fmt0, label, locale }: {
168
+ scale: ColorScale;
169
+ fmt: (v: number) => string;
170
+ label: string;
171
+ locale?: string;
172
+ }): React.JSX.Element;
173
+ /** ONE flattened hover indicator (ring) shared by every cell / bar / tile: a single element moved by transform. Never glass. */
174
+ export declare function useCellIndicator(): {
175
+ place(r: {
176
+ x: number;
177
+ y: number;
178
+ w: number;
179
+ h: number;
180
+ rx?: number;
181
+ } | null): void;
182
+ layer: React.JSX.Element;
183
+ };
184
+ /** Stroke arc (angles in radians, 0 = 12 o'clock, clockwise). */
185
+ export declare function arcStroke(cx: number, cy: number, r: number, a0: number, a1: number): string;
186
+ export declare const polar: (cx: number, cy: number, r: number, a: number) => [number, number];
187
+ declare const A: {
188
+ en: {
189
+ min: string;
190
+ max: string;
191
+ target: string;
192
+ compare: string;
193
+ value: string;
194
+ axis: string;
195
+ x: string;
196
+ y: string;
197
+ size: string;
198
+ trend: string;
199
+ selected: string;
200
+ step: string;
201
+ conversion: string;
202
+ dropoff: string;
203
+ of: string;
204
+ bin: string;
205
+ count: string;
206
+ bins: string;
207
+ all: string;
208
+ path: string;
209
+ reset: string;
210
+ zin: string;
211
+ zout: string;
212
+ range: string;
213
+ live: string;
214
+ paused: string;
215
+ newPts: string;
216
+ resume: string;
217
+ overview: string;
218
+ row: string;
219
+ col: string;
220
+ less: string;
221
+ more: string;
222
+ band: string;
223
+ share: string;
224
+ gaugeNav: string;
225
+ zoomNav: string;
226
+ stale: string;
227
+ points: string;
228
+ from: string;
229
+ to: string;
230
+ drill: string;
231
+ };
232
+ sk: {
233
+ min: string;
234
+ max: string;
235
+ target: string;
236
+ compare: string;
237
+ value: string;
238
+ axis: string;
239
+ x: string;
240
+ y: string;
241
+ size: string;
242
+ trend: string;
243
+ selected: string;
244
+ step: string;
245
+ conversion: string;
246
+ dropoff: string;
247
+ of: string;
248
+ bin: string;
249
+ count: string;
250
+ bins: string;
251
+ all: string;
252
+ path: string;
253
+ reset: string;
254
+ zin: string;
255
+ zout: string;
256
+ range: string;
257
+ live: string;
258
+ paused: string;
259
+ newPts: string;
260
+ resume: string;
261
+ overview: string;
262
+ row: string;
263
+ col: string;
264
+ less: string;
265
+ more: string;
266
+ band: string;
267
+ share: string;
268
+ gaugeNav: string;
269
+ zoomNav: string;
270
+ stale: string;
271
+ points: string;
272
+ from: string;
273
+ to: string;
274
+ drill: string;
275
+ };
276
+ de: {
277
+ min: string;
278
+ max: string;
279
+ target: string;
280
+ compare: string;
281
+ value: string;
282
+ axis: string;
283
+ x: string;
284
+ y: string;
285
+ size: string;
286
+ trend: string;
287
+ selected: string;
288
+ step: string;
289
+ conversion: string;
290
+ dropoff: string;
291
+ of: string;
292
+ bin: string;
293
+ count: string;
294
+ bins: string;
295
+ all: string;
296
+ path: string;
297
+ reset: string;
298
+ zin: string;
299
+ zout: string;
300
+ range: string;
301
+ live: string;
302
+ paused: string;
303
+ newPts: string;
304
+ resume: string;
305
+ overview: string;
306
+ row: string;
307
+ col: string;
308
+ less: string;
309
+ more: string;
310
+ band: string;
311
+ share: string;
312
+ gaugeNav: string;
313
+ zoomNav: string;
314
+ stale: string;
315
+ points: string;
316
+ from: string;
317
+ to: string;
318
+ drill: string;
319
+ };
320
+ cs: {
321
+ min: string;
322
+ max: string;
323
+ target: string;
324
+ compare: string;
325
+ value: string;
326
+ axis: string;
327
+ x: string;
328
+ y: string;
329
+ size: string;
330
+ trend: string;
331
+ selected: string;
332
+ step: string;
333
+ conversion: string;
334
+ dropoff: string;
335
+ of: string;
336
+ bin: string;
337
+ count: string;
338
+ bins: string;
339
+ all: string;
340
+ path: string;
341
+ reset: string;
342
+ zin: string;
343
+ zout: string;
344
+ range: string;
345
+ live: string;
346
+ paused: string;
347
+ newPts: string;
348
+ resume: string;
349
+ overview: string;
350
+ row: string;
351
+ col: string;
352
+ less: string;
353
+ more: string;
354
+ band: string;
355
+ share: string;
356
+ gaugeNav: string;
357
+ zoomNav: string;
358
+ stale: string;
359
+ points: string;
360
+ from: string;
361
+ to: string;
362
+ drill: string;
363
+ };
364
+ };
365
+ export type AdvTextKey = keyof typeof A.en;
366
+ export declare const advText: (k: AdvTextKey, locale?: string, n?: number | string) => string;
367
+ export declare const cssTok: (k: string, f: number) => number;
368
+ export {};
@@ -0,0 +1,9 @@
1
+ /** Point quadtree for nearest-point search (scatter hover, keyboard, brush). Built once per layout; no per-point listeners. */
2
+ export interface QuadTree {
3
+ nearest(x: number, y: number, maxDist?: number): number;
4
+ within(x0: number, y0: number, x1: number, y1: number): number[];
5
+ size: number;
6
+ }
7
+ export declare function buildQuadtree(xs: ArrayLike<number>, ys: ArrayLike<number>, skip?: (i: number) => boolean): QuadTree;
8
+ /** Brute-force reference (tests). */
9
+ export declare function nearestBrute(xs: ArrayLike<number>, ys: ArrayLike<number>, x: number, y: number): number;