@glyphjs/components 0.1.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.
@@ -0,0 +1,546 @@
1
+ import { GlyphComponentProps, GlyphComponentDefinition, GraphNode, GraphEdge } from '@glyphjs/types';
2
+ import { ReactElement } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ interface CalloutData {
6
+ type: 'info' | 'warning' | 'error' | 'tip';
7
+ title?: string;
8
+ content: string;
9
+ }
10
+ /**
11
+ * Renders a styled callout box with variant-specific icon, optional title,
12
+ * and content text. Styling is driven by `--glyph-callout-{type}-bg` and
13
+ * `--glyph-callout-{type}-border` CSS custom properties so consumers can
14
+ * re-theme via the Glyph theme system.
15
+ */
16
+ declare function Callout({ data }: GlyphComponentProps<CalloutData>): ReactElement;
17
+
18
+ declare const calloutDefinition: GlyphComponentDefinition<CalloutData>;
19
+
20
+ /** Matches z.infer<typeof chartSchema> without importing zod. */
21
+ interface ChartData {
22
+ type: 'line' | 'bar' | 'area' | 'ohlc';
23
+ series: {
24
+ name: string;
25
+ data: DataRecord[];
26
+ }[];
27
+ xAxis?: {
28
+ key: string;
29
+ label?: string;
30
+ };
31
+ yAxis?: {
32
+ key: string;
33
+ label?: string;
34
+ };
35
+ legend?: boolean;
36
+ }
37
+ type DataRecord = Record<string, number | string>;
38
+
39
+ /**
40
+ * Renders a D3-powered chart supporting line, bar, area, and OHLC types.
41
+ * Uses CSS variables for theming and includes accessibility features.
42
+ */
43
+ declare function Chart({ data, container: containerCtx, }: GlyphComponentProps<ChartData>): ReactElement;
44
+
45
+ declare const chartDefinition: GlyphComponentDefinition;
46
+
47
+ interface StepItem {
48
+ title: string;
49
+ status?: 'pending' | 'active' | 'completed';
50
+ content: string;
51
+ }
52
+ interface StepsData {
53
+ steps: StepItem[];
54
+ }
55
+ /**
56
+ * Renders a vertical list of steps with status indicators.
57
+ * Each step displays a circle (pending), highlighted circle (active),
58
+ * or a checkmark (completed).
59
+ *
60
+ * Theming is driven by CSS custom properties:
61
+ * - `--glyph-steps-pending-color`
62
+ * - `--glyph-steps-active-color`
63
+ * - `--glyph-steps-completed-color`
64
+ * - `--glyph-steps-connector-color`
65
+ */
66
+ declare function Steps({ data }: GlyphComponentProps<StepsData>): ReactElement;
67
+
68
+ declare const stepsDefinition: GlyphComponentDefinition<StepsData>;
69
+
70
+ interface TableColumn {
71
+ key: string;
72
+ label: string;
73
+ sortable?: boolean;
74
+ filterable?: boolean;
75
+ type?: 'string' | 'number' | 'date' | 'boolean';
76
+ }
77
+ interface TableAggregation {
78
+ column: string;
79
+ function: 'sum' | 'avg' | 'count' | 'min' | 'max';
80
+ }
81
+ interface TableData {
82
+ columns: TableColumn[];
83
+ rows: Record<string, unknown>[];
84
+ aggregation?: TableAggregation[];
85
+ }
86
+ /**
87
+ * Renders an interactive data table with optional sorting, filtering,
88
+ * and aggregation. Styling is driven by `--glyph-table-*` CSS custom
89
+ * properties so consumers can re-theme via the Glyph theme system.
90
+ */
91
+ declare function Table({ data, container }: GlyphComponentProps<TableData>): ReactElement;
92
+
93
+ declare const tableDefinition: GlyphComponentDefinition<TableData>;
94
+
95
+ /** Shape of the validated `data` for a `ui:tabs` block. */
96
+ interface TabsData {
97
+ tabs: {
98
+ label: string;
99
+ content: string;
100
+ }[];
101
+ }
102
+ /**
103
+ * `ui:tabs` component.
104
+ *
105
+ * Renders a tabbed interface following the WAI-ARIA Tabs pattern.
106
+ * - Tab navigation via click.
107
+ * - Keyboard: ArrowLeft / ArrowRight to cycle tabs, Home / End for first / last.
108
+ * - ARIA roles: tablist, tab, tabpanel with proper aria-selected, aria-controls,
109
+ * and aria-labelledby attributes.
110
+ */
111
+ declare function Tabs({ data, block }: GlyphComponentProps<TabsData>): react_jsx_runtime.JSX.Element;
112
+
113
+ declare const tabsDefinition: GlyphComponentDefinition<TabsData>;
114
+
115
+ interface TimelineEvent {
116
+ date: string;
117
+ title: string;
118
+ description?: string;
119
+ type?: string;
120
+ }
121
+ interface TimelineData {
122
+ events: TimelineEvent[];
123
+ orientation?: 'vertical' | 'horizontal';
124
+ }
125
+ /**
126
+ * Renders an interactive timeline visualization using D3 for positioning.
127
+ *
128
+ * Events are placed along a central axis using a D3 time scale derived
129
+ * from parsed event dates. In vertical orientation events alternate
130
+ * left / right; in horizontal orientation they flow left to right.
131
+ *
132
+ * Theming is controlled via CSS custom properties prefixed with
133
+ * `--glyph-timeline-*`.
134
+ */
135
+ declare function Timeline({ data }: GlyphComponentProps<TimelineData>): ReactElement;
136
+
137
+ declare const timelineDefinition: GlyphComponentDefinition<TimelineData>;
138
+
139
+ interface GraphNodeData {
140
+ id: string;
141
+ label: string;
142
+ type?: string;
143
+ style?: Record<string, string>;
144
+ group?: string;
145
+ }
146
+ interface GraphEdgeData {
147
+ from: string;
148
+ to: string;
149
+ label?: string;
150
+ type?: string;
151
+ style?: Record<string, string>;
152
+ }
153
+ interface GraphData {
154
+ type: 'dag' | 'flowchart' | 'mindmap' | 'force';
155
+ nodes: GraphNodeData[];
156
+ edges: GraphEdgeData[];
157
+ layout?: 'top-down' | 'left-right' | 'bottom-up' | 'radial' | 'force';
158
+ }
159
+ declare function Graph({ data, outgoingRefs, onNavigate, container, }: GlyphComponentProps<GraphData>): ReactElement;
160
+
161
+ interface PositionedNode extends GraphNode {
162
+ x: number;
163
+ y: number;
164
+ width: number;
165
+ height: number;
166
+ }
167
+ interface PositionedEdge extends GraphEdge {
168
+ points: {
169
+ x: number;
170
+ y: number;
171
+ }[];
172
+ }
173
+ interface LayoutResult {
174
+ nodes: PositionedNode[];
175
+ edges: PositionedEdge[];
176
+ width: number;
177
+ height: number;
178
+ }
179
+ type LayoutDirection = 'top-down' | 'left-right' | 'bottom-up' | 'radial' | 'force';
180
+ /**
181
+ * Uses dagre to compute hierarchical layout positions for nodes and edges.
182
+ * Supports top-down, left-right, bottom-up, and radial directions.
183
+ * The radial direction uses top-down dagre as a base.
184
+ */
185
+ declare function computeDagreLayout(nodes: GraphNode[], edges: GraphEdge[], direction?: LayoutDirection): LayoutResult;
186
+ /**
187
+ * Uses D3 force simulation to compute physics-based layout positions.
188
+ * Runs the simulation synchronously for a fixed number of ticks.
189
+ */
190
+ declare function computeForceLayout(nodes: GraphNode[], edges: GraphEdge[]): LayoutResult;
191
+
192
+ declare const graphDefinition: GlyphComponentDefinition<GraphData>;
193
+
194
+ interface Attribute {
195
+ name: string;
196
+ type: string;
197
+ primaryKey?: boolean;
198
+ }
199
+ interface Entity {
200
+ id: string;
201
+ label: string;
202
+ attributes?: Attribute[];
203
+ }
204
+ interface Relationship {
205
+ from: string;
206
+ to: string;
207
+ label?: string;
208
+ cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
209
+ }
210
+ interface RelationData {
211
+ entities: Entity[];
212
+ relationships: Relationship[];
213
+ layout?: 'top-down' | 'left-right';
214
+ }
215
+ declare function Relation({ data }: GlyphComponentProps<RelationData>): ReactElement;
216
+
217
+ declare const relationDefinition: GlyphComponentDefinition<RelationData>;
218
+
219
+ interface KpiMetric {
220
+ label: string;
221
+ value: string;
222
+ delta?: string;
223
+ trend?: 'up' | 'down' | 'flat';
224
+ sentiment?: 'positive' | 'negative' | 'neutral';
225
+ unit?: string;
226
+ }
227
+ interface KpiData {
228
+ title?: string;
229
+ metrics: KpiMetric[];
230
+ columns?: number;
231
+ }
232
+ declare function Kpi({ data, block, container }: GlyphComponentProps<KpiData>): ReactElement;
233
+
234
+ declare const kpiDefinition: GlyphComponentDefinition<KpiData>;
235
+
236
+ interface AccordionSection {
237
+ title: string;
238
+ content: string;
239
+ }
240
+ interface AccordionData {
241
+ title?: string;
242
+ sections: AccordionSection[];
243
+ defaultOpen?: number[];
244
+ multiple?: boolean;
245
+ }
246
+ declare function Accordion({ data, block }: GlyphComponentProps<AccordionData>): ReactElement;
247
+
248
+ declare const accordionDefinition: GlyphComponentDefinition<AccordionData>;
249
+
250
+ interface ComparisonOption {
251
+ name: string;
252
+ description?: string;
253
+ }
254
+ interface ComparisonFeature {
255
+ name: string;
256
+ values: string[];
257
+ }
258
+ interface ComparisonData {
259
+ title?: string;
260
+ options: ComparisonOption[];
261
+ features: ComparisonFeature[];
262
+ }
263
+ declare function Comparison({ data, block, container, }: GlyphComponentProps<ComparisonData>): ReactElement;
264
+
265
+ declare const comparisonDefinition: GlyphComponentDefinition<ComparisonData>;
266
+
267
+ interface CodeDiffData {
268
+ language?: string;
269
+ before: string;
270
+ after: string;
271
+ beforeLabel?: string;
272
+ afterLabel?: string;
273
+ }
274
+ declare function CodeDiff({ data, block }: GlyphComponentProps<CodeDiffData>): ReactElement;
275
+
276
+ type DiffLineKind = 'add' | 'del' | 'eq';
277
+ interface DiffLine {
278
+ kind: DiffLineKind;
279
+ text: string;
280
+ oldLineNo?: number;
281
+ newLineNo?: number;
282
+ }
283
+ /**
284
+ * Computes a line-based diff between two strings.
285
+ * Uses a longest common subsequence (LCS) approach via dynamic programming.
286
+ * Returns a minimal edit script as an array of DiffLine entries.
287
+ */
288
+ declare function computeDiff(before: string, after: string): DiffLine[];
289
+
290
+ declare const codeDiffDefinition: GlyphComponentDefinition<CodeDiffData>;
291
+
292
+ type FlowchartNodeType = 'start' | 'end' | 'process' | 'decision';
293
+ interface FlowchartNodeData {
294
+ id: string;
295
+ type: FlowchartNodeType;
296
+ label: string;
297
+ }
298
+ interface FlowchartEdgeData {
299
+ from: string;
300
+ to: string;
301
+ label?: string;
302
+ }
303
+ interface FlowchartData {
304
+ title?: string;
305
+ nodes: FlowchartNodeData[];
306
+ edges: FlowchartEdgeData[];
307
+ direction: 'top-down' | 'left-right';
308
+ }
309
+ declare function Flowchart({ data, container }: GlyphComponentProps<FlowchartData>): ReactElement;
310
+
311
+ declare const flowchartDefinition: GlyphComponentDefinition<FlowchartData>;
312
+
313
+ interface FileNode {
314
+ name: string;
315
+ annotation?: string;
316
+ children?: FileNode[];
317
+ }
318
+ interface FileTreeData {
319
+ root?: string;
320
+ tree: FileNode[];
321
+ defaultExpanded: boolean;
322
+ }
323
+ declare function FileTree({ data }: GlyphComponentProps<FileTreeData>): ReactElement;
324
+
325
+ declare const fileTreeDefinition: GlyphComponentDefinition<FileTreeData>;
326
+
327
+ type MessageType = 'message' | 'reply' | 'self';
328
+ interface Actor {
329
+ id: string;
330
+ label: string;
331
+ }
332
+ interface Message {
333
+ from: string;
334
+ to: string;
335
+ label: string;
336
+ type: MessageType;
337
+ }
338
+ interface SequenceData {
339
+ title?: string;
340
+ actors: Actor[];
341
+ messages: Message[];
342
+ }
343
+ declare function Sequence({ data, container }: GlyphComponentProps<SequenceData>): ReactElement;
344
+
345
+ declare const sequenceDefinition: GlyphComponentDefinition<SequenceData>;
346
+
347
+ interface ArchitectureNode {
348
+ id: string;
349
+ label: string;
350
+ icon?: string;
351
+ type?: 'zone';
352
+ children?: ArchitectureNode[];
353
+ style?: Record<string, string>;
354
+ }
355
+ interface ArchitectureEdge {
356
+ from: string;
357
+ to: string;
358
+ label?: string;
359
+ type?: 'sync' | 'async' | 'data';
360
+ style?: Record<string, string>;
361
+ }
362
+ interface ArchitectureData {
363
+ title?: string;
364
+ children: ArchitectureNode[];
365
+ edges: ArchitectureEdge[];
366
+ layout?: 'top-down' | 'left-right' | 'bottom-up';
367
+ }
368
+ interface PositionedArchNode {
369
+ id: string;
370
+ label: string;
371
+ icon?: string;
372
+ x: number;
373
+ y: number;
374
+ width: number;
375
+ height: number;
376
+ zoneId?: string;
377
+ }
378
+ interface PositionedZone {
379
+ id: string;
380
+ label: string;
381
+ x: number;
382
+ y: number;
383
+ width: number;
384
+ height: number;
385
+ depth: number;
386
+ }
387
+ interface PositionedArchEdge {
388
+ from: string;
389
+ to: string;
390
+ label?: string;
391
+ type?: 'sync' | 'async' | 'data';
392
+ style?: Record<string, string>;
393
+ points: {
394
+ x: number;
395
+ y: number;
396
+ }[];
397
+ }
398
+ interface ArchitectureLayout {
399
+ nodes: PositionedArchNode[];
400
+ zones: PositionedZone[];
401
+ edges: PositionedArchEdge[];
402
+ width: number;
403
+ height: number;
404
+ }
405
+ declare function computeArchitectureLayout(data: ArchitectureData): Promise<ArchitectureLayout>;
406
+
407
+ declare function Architecture({ data, container, }: GlyphComponentProps<ArchitectureData>): ReactElement;
408
+
409
+ declare const architectureDefinition: GlyphComponentDefinition<ArchitectureData>;
410
+
411
+ interface MindMapNode {
412
+ label: string;
413
+ children?: MindMapNode[];
414
+ }
415
+ interface MindMapData {
416
+ root: string;
417
+ children: MindMapNode[];
418
+ layout: 'radial' | 'tree';
419
+ }
420
+ declare function MindMap({ data, container }: GlyphComponentProps<MindMapData>): ReactElement;
421
+
422
+ declare const mindMapDefinition: GlyphComponentDefinition<MindMapData>;
423
+
424
+ interface EquationStep {
425
+ expression: string;
426
+ annotation?: string;
427
+ }
428
+ interface EquationData {
429
+ expression?: string;
430
+ label?: string;
431
+ steps?: EquationStep[];
432
+ }
433
+ declare function Equation({ data }: GlyphComponentProps<EquationData>): ReactElement;
434
+
435
+ declare const equationDefinition: GlyphComponentDefinition<EquationData>;
436
+
437
+ interface QuizMultipleChoice {
438
+ type: 'multiple-choice';
439
+ question: string;
440
+ options: string[];
441
+ answer: number;
442
+ explanation?: string;
443
+ }
444
+ interface QuizTrueFalse {
445
+ type: 'true-false';
446
+ question: string;
447
+ answer: boolean;
448
+ explanation?: string;
449
+ }
450
+ interface QuizMultiSelect {
451
+ type: 'multi-select';
452
+ question: string;
453
+ options: string[];
454
+ answer: number[];
455
+ explanation?: string;
456
+ }
457
+ type QuizQuestion = QuizMultipleChoice | QuizTrueFalse | QuizMultiSelect;
458
+ interface QuizData {
459
+ questions: QuizQuestion[];
460
+ showScore?: boolean;
461
+ title?: string;
462
+ }
463
+ declare function Quiz({ data, block }: GlyphComponentProps<QuizData>): ReactElement;
464
+
465
+ declare const quizDefinition: GlyphComponentDefinition<QuizData>;
466
+
467
+ interface CardAction {
468
+ label: string;
469
+ url: string;
470
+ }
471
+ interface CardItem {
472
+ title: string;
473
+ subtitle?: string;
474
+ image?: string;
475
+ icon?: string;
476
+ body?: string;
477
+ actions?: CardAction[];
478
+ }
479
+ interface CardData {
480
+ title?: string;
481
+ cards: CardItem[];
482
+ variant?: 'default' | 'outlined' | 'elevated';
483
+ columns?: number;
484
+ }
485
+ declare function Card({ data, block, container }: GlyphComponentProps<CardData>): ReactElement;
486
+
487
+ declare const cardDefinition: GlyphComponentDefinition<CardData>;
488
+
489
+ interface StatItem {
490
+ type: 'stat';
491
+ label: string;
492
+ value: string;
493
+ description?: string;
494
+ }
495
+ interface FactItem {
496
+ type: 'fact';
497
+ icon?: string;
498
+ text: string;
499
+ }
500
+ interface ProgressItem {
501
+ type: 'progress';
502
+ label: string;
503
+ value: number;
504
+ color?: string;
505
+ }
506
+ interface TextItem {
507
+ type: 'text';
508
+ content: string;
509
+ }
510
+ interface PieSlice {
511
+ label: string;
512
+ value: number;
513
+ color?: string;
514
+ }
515
+ interface PieItem {
516
+ type: 'pie';
517
+ label?: string;
518
+ slices: PieSlice[];
519
+ donut?: boolean;
520
+ size?: number;
521
+ }
522
+ interface DividerItem {
523
+ type: 'divider';
524
+ style?: 'solid' | 'dashed' | 'dotted';
525
+ }
526
+ interface RatingItem {
527
+ type: 'rating';
528
+ label: string;
529
+ value: number;
530
+ max?: number;
531
+ description?: string;
532
+ }
533
+ type InfographicItem = StatItem | FactItem | ProgressItem | TextItem | PieItem | DividerItem | RatingItem;
534
+ interface InfographicSection {
535
+ heading?: string;
536
+ items: InfographicItem[];
537
+ }
538
+ interface InfographicData {
539
+ title?: string;
540
+ sections: InfographicSection[];
541
+ }
542
+ declare function Infographic({ data, block, container, }: GlyphComponentProps<InfographicData>): ReactElement;
543
+
544
+ declare const infographicDefinition: GlyphComponentDefinition<InfographicData>;
545
+
546
+ export { Accordion, type AccordionData, type AccordionSection, Architecture, type ArchitectureData, type ArchitectureLayout, Callout, type CalloutData, Card, type CardAction, type CardData, type CardItem, Chart, CodeDiff, type CodeDiffData, Comparison, type ComparisonData, type ComparisonFeature, type ComparisonOption, type DiffLine, type DiffLineKind, type DividerItem, Equation, type EquationData, type EquationStep, FileTree, type FileTreeData, Flowchart, type FlowchartData, Graph, type GraphData, Infographic, type InfographicData, type InfographicItem, type InfographicSection, Kpi, type KpiData, type KpiMetric, type LayoutResult, MindMap, type MindMapData, type PieItem, type PieSlice, type PositionedArchEdge, type PositionedArchNode, type PositionedEdge, type PositionedNode, type PositionedZone, Quiz, type QuizData, type QuizQuestion, type RatingItem, Relation, type RelationData, Sequence, type SequenceData, Steps, type StepsData, Table, type TableData, Tabs, type TabsData, Timeline, type TimelineData, accordionDefinition, architectureDefinition, calloutDefinition, cardDefinition, chartDefinition, codeDiffDefinition, comparisonDefinition, computeArchitectureLayout, computeDagreLayout, computeDiff, computeForceLayout, equationDefinition, fileTreeDefinition, flowchartDefinition, graphDefinition, infographicDefinition, kpiDefinition, mindMapDefinition, quizDefinition, relationDefinition, sequenceDefinition, stepsDefinition, tableDefinition, tabsDefinition, timelineDefinition };