@photon-ai/pho-ui 4.7.1 → 4.9.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.
Files changed (69) hide show
  1. package/dist/chunks/bar-chart-ht70KKj3.js +19 -0
  2. package/dist/chunks/bar-chart-ht70KKj3.js.map +1 -0
  3. package/dist/chunks/{basic-page-BUmntB7L.js → basic-page-DzT8yecB.js} +174 -173
  4. package/dist/chunks/basic-page-DzT8yecB.js.map +1 -0
  5. package/dist/chunks/chart-B5c8gmlj.js +1338 -0
  6. package/dist/chunks/chart-B5c8gmlj.js.map +1 -0
  7. package/dist/chunks/code-block-CbcE994O.js +516 -0
  8. package/dist/chunks/code-block-CbcE994O.js.map +1 -0
  9. package/dist/chunks/{data-table-Mog6m3d9.js → data-table-B1dmrN6r.js} +89 -94
  10. package/dist/chunks/data-table-B1dmrN6r.js.map +1 -0
  11. package/dist/chunks/ghost-search-CNVs9k1o.js +34 -0
  12. package/dist/chunks/ghost-search-CNVs9k1o.js.map +1 -0
  13. package/dist/chunks/line-chart-Cm_Ac7f4.js +22 -0
  14. package/dist/chunks/line-chart-Cm_Ac7f4.js.map +1 -0
  15. package/dist/chunks/{trace-CjOi3_IP.js → trace-D1fOFzJt.js} +633 -622
  16. package/dist/chunks/trace-D1fOFzJt.js.map +1 -0
  17. package/dist/components/bar-chart.js +1 -1
  18. package/dist/components/chart.js +8 -5
  19. package/dist/components/code-block.js +12 -3
  20. package/dist/components/data-table.js +8 -8
  21. package/dist/components/line-chart.js +1 -1
  22. package/dist/components/trace.js +1 -1
  23. package/dist/index.js +175 -162
  24. package/dist/motion.js +14 -13
  25. package/dist/motion.js.map +1 -1
  26. package/dist/primitives.js +1 -1
  27. package/dist/sections/basic-page.js +2 -2
  28. package/dist/src/components/bar-chart/bar-chart.d.ts +9 -1
  29. package/dist/src/components/chart/chart.d.ts +25 -0
  30. package/dist/src/components/chart/format.d.ts +9 -5
  31. package/dist/src/components/chart/index.d.ts +7 -4
  32. package/dist/src/components/chart/scale.d.ts +2 -2
  33. package/dist/src/components/chart/shell.d.ts +20 -13
  34. package/dist/src/components/chart/skeleton.d.ts +11 -0
  35. package/dist/src/components/chart/theme.d.ts +8 -0
  36. package/dist/src/components/chart/types.d.ts +39 -2
  37. package/dist/src/components/chart/use-measure.d.ts +2 -1
  38. package/dist/src/components/code-block/code-block.d.ts +23 -11
  39. package/dist/src/components/code-block/highlight.d.ts +24 -0
  40. package/dist/src/components/code-block/index.d.ts +4 -1
  41. package/dist/src/components/code-block/languages.d.ts +64 -0
  42. package/dist/src/components/code-block/pho-theme.d.ts +18 -0
  43. package/dist/src/components/code-block/tokens.d.ts +14 -0
  44. package/dist/src/components/data-table/chrome.d.ts +25 -0
  45. package/dist/src/components/data-table/data-table.d.ts +1 -2
  46. package/dist/src/components/line-chart/line-chart.d.ts +12 -3
  47. package/dist/src/components/trace/trace.d.ts +15 -4
  48. package/dist/src/motion/index.d.ts +6 -0
  49. package/dist/src/sections/basic-page/basic-page.d.ts +2 -0
  50. package/package.json +4 -1
  51. package/src/styles/theme.css +17 -4
  52. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js +0 -75
  53. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js.map +0 -1
  54. package/dist/chunks/bar-chart-DIALC2_z.js +0 -190
  55. package/dist/chunks/bar-chart-DIALC2_z.js.map +0 -1
  56. package/dist/chunks/basic-page-BUmntB7L.js.map +0 -1
  57. package/dist/chunks/code-block-BuFfh0zH.js +0 -197
  58. package/dist/chunks/code-block-BuFfh0zH.js.map +0 -1
  59. package/dist/chunks/data-table-Mog6m3d9.js.map +0 -1
  60. package/dist/chunks/ghost-search-AmVXd0zE.js +0 -25
  61. package/dist/chunks/ghost-search-AmVXd0zE.js.map +0 -1
  62. package/dist/chunks/legend-C0mU7dqd.js +0 -60
  63. package/dist/chunks/legend-C0mU7dqd.js.map +0 -1
  64. package/dist/chunks/line-chart-VuMYKzW3.js +0 -453
  65. package/dist/chunks/line-chart-VuMYKzW3.js.map +0 -1
  66. package/dist/chunks/trace-CjOi3_IP.js.map +0 -1
  67. package/dist/chunks/use-measure-C-i54AC6.js +0 -629
  68. package/dist/chunks/use-measure-C-i54AC6.js.map +0 -1
  69. package/dist/src/components/chart/axes.d.ts +0 -22
@@ -1,5 +1,5 @@
1
- import { ComponentProps, PointerEvent, ReactNode, RefObject } from 'react';
2
- /** The inner box the marks draw in, once the axes have taken their bands. */
1
+ import { ComponentProps, ReactNode, RefObject } from 'react';
2
+ /** The bands around the plot, and the inner box the marks draw in. */
3
3
  export interface ChartLayout {
4
4
  width: number;
5
5
  height: number;
@@ -9,6 +9,13 @@ export interface ChartLayout {
9
9
  bottom: number;
10
10
  innerWidth: number;
11
11
  innerHeight: number;
12
+ /** The same bands in the shape visx takes. */
13
+ margin: {
14
+ top: number;
15
+ right: number;
16
+ bottom: number;
17
+ left: number;
18
+ };
12
19
  }
13
20
  /** The plot's box for a measured width and the y-axis labels it must fit. */
14
21
  export declare function chartLayout(width: number, height: number, yLabels: ReadonlyArray<string>): ChartLayout;
@@ -18,25 +25,25 @@ export interface ChartShellProps extends Omit<ComponentProps<"div">, "children">
18
25
  /** The figure's spoken summary. */
19
26
  description: string;
20
27
  height: number;
21
- /** The measured width; 0 before the browser has measured. */
22
- width: number;
23
28
  containerRef: RefObject<HTMLDivElement | null>;
24
29
  legend?: ReactNode;
25
- tooltip?: ReactNode;
26
30
  loading?: boolean;
27
31
  empty?: ReactNode;
28
32
  /** The frame says `empty` instead of drawing. */
29
33
  showEmpty?: boolean;
30
- /** The pointer over the plot — the chart snaps to the nearest bucket. */
31
- onPlotPointerMove?: (event: PointerEvent<SVGSVGElement>) => void;
32
- onPlotPointerLeave?: () => void;
34
+ /** What stands in for the plot while the first data is on its way. */
35
+ placeholder?: ReactNode;
36
+ /**
37
+ * The figure itself — the svg and its tooltip. Presentational to
38
+ * assistive tech: the frame's label and description speak for it.
39
+ */
33
40
  children?: ReactNode;
34
41
  }
35
42
  /**
36
43
  * The frame every chart draws in: a fixed-height plot box holding the
37
- * SVG (`role="img"`, labelled and described for assistive tech), the
38
- * tooltip layer over it, the legend on its own line below. Width comes
39
- * from the parent; `height` covers the plot and the x-axis band, so a
40
- * card never grows a nested scroll.
44
+ * figure (`role="img"`, labelled and described for assistive tech), the
45
+ * legend on its own line below. Width comes from the parent; `height`
46
+ * covers the plot and the x-axis band, so a card never grows a nested
47
+ * scroll.
41
48
  */
42
- export declare function ChartShell({ label, description, height, width, containerRef, legend, tooltip, loading, empty, showEmpty, onPlotPointerMove, onPlotPointerLeave, className, children, ...props }: ChartShellProps): import("react").JSX.Element;
49
+ export declare function ChartShell({ label, description, height, containerRef, legend, loading, empty, showEmpty, placeholder, className, children, ...props }: ChartShellProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { ChartLayout } from './shell';
2
+ /**
3
+ * Bones in the shape of a chart, for a first load with nothing to hold:
4
+ * the frame's own coordinate system — hairline rows, a baseline, a label
5
+ * bone at every row on the left and a few along the bottom — with a
6
+ * dozen columns standing on the baseline in the plot's box. A refetch
7
+ * never shows this; the chart keeps its last render at half opacity.
8
+ */
9
+ export declare function ChartSkeleton({ layout }: {
10
+ layout: ChartLayout;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { XYChartTheme } from '@visx/xychart';
2
+ /**
3
+ * The visx theme for a chart's furniture: gridlines one step off the
4
+ * surface, description-ink ticks, and the series colours in part order
5
+ * as the fallback palette. Everything is a CSS custom property, so the
6
+ * theme follows light and dark without a second copy.
7
+ */
8
+ export declare function buildPhoTheme(colors: ReadonlyArray<string>): XYChartTheme;
@@ -12,7 +12,7 @@ export interface ChartBreakdownItem {
12
12
  }
13
13
  /**
14
14
  * One bucket on the time axis. Series values sit beside `x` under the
15
- * keys the `series` name — `{ x, inbound: 12, outbound: 4 }`.
15
+ * keys the series name — `{ x, inbound: 12, outbound: 4 }`.
16
16
  */
17
17
  export interface ChartDatum {
18
18
  /** When the bucket starts: a `Date` or epoch milliseconds. */
@@ -27,6 +27,8 @@ export interface ChartDatum {
27
27
  export type ChartValueKey<T> = {
28
28
  [K in keyof T]-?: K extends "x" | "breakdown" ? never : T[K] extends number | null | undefined ? K : never;
29
29
  }[keyof T] & string;
30
+ /** Straight segments, or a monotone curve that never overshoots a sample. */
31
+ export type ChartCurve = "linear" | "monotone";
30
32
  export interface ChartSeries<T extends ChartDatum = ChartDatum> {
31
33
  /** The field of each datum this series plots. */
32
34
  key: ChartValueKey<T>;
@@ -65,7 +67,7 @@ export interface ChartBaseProps<T extends ChartDatum> extends Omit<ComponentProp
65
67
  locale?: string;
66
68
  /** Show the legend. On for two or more series; a lone series is named by its title. */
67
69
  legend?: boolean;
68
- /** Where the y-axis starts: at zero, or at the data's low end. @default "zero" */
70
+ /** Where the y-axis starts: at zero, or at the data's low end. Bars always start at zero. @default "zero" */
69
71
  baseline?: "zero" | "auto";
70
72
  /** A heading over a datum's `breakdown` list in the tooltip. */
71
73
  breakdownTitle?: ReactNode;
@@ -74,3 +76,38 @@ export interface ChartBaseProps<T extends ChartDatum> extends Omit<ComponentProp
74
76
  /** What the frame says with no buckets to draw. */
75
77
  empty?: ReactNode;
76
78
  }
79
+ /**
80
+ * The composable root: the frame, the scales, the axes, the tooltip and
81
+ * the legend, drawn around whatever `Chart.Bar` and `Chart.Line` parts
82
+ * it is given.
83
+ */
84
+ export interface ChartProps<T extends ChartDatum> extends Omit<ChartBaseProps<T>, "series"> {
85
+ /** The series: `Chart.Bar` and `Chart.Line` parts, in drawing (and legend) order. */
86
+ children?: ReactNode;
87
+ /** Stack the bar parts in one column per bucket, first part at the bottom. */
88
+ stacked?: boolean;
89
+ }
90
+ /** One bar series: the field it plots and its name. */
91
+ export interface ChartBarProps {
92
+ /** The field of each datum this series plots. */
93
+ dataKey: string;
94
+ /** The name in the legend and the tooltip. */
95
+ label: string;
96
+ /** Defaults to the next categorical slot, in part order. */
97
+ color?: ChartColor;
98
+ }
99
+ /** One line series: the field it plots, its name, and how it is drawn. */
100
+ export interface ChartLineProps {
101
+ /** The field of each datum this series plots. */
102
+ dataKey: string;
103
+ /** The name in the legend and the tooltip. */
104
+ label: string;
105
+ /** Defaults to the next categorical slot, in part order. */
106
+ color?: ChartColor;
107
+ /** A dashed stroke — a min / max beside an average. */
108
+ dashed?: boolean;
109
+ /** @default "linear" */
110
+ curve?: ChartCurve;
111
+ /** A soft fill under the line, at 10% of its colour. */
112
+ area?: boolean;
113
+ }
@@ -1,4 +1,5 @@
1
- import { RefObject } from 'react';
1
+ import { useEffect, RefObject } from 'react';
2
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
2
3
  /**
3
4
  * The width of the element the ref lands on, kept current through a
4
5
  * ResizeObserver. Nothing runs on the server: the first render is 0 wide
@@ -1,7 +1,8 @@
1
1
  import { ComponentProps, ReactNode, Ref } from 'react';
2
+ import { CodeBlockLanguage } from './languages';
2
3
  /**
3
4
  * Code Block — a read-only panel for a request body, a response, an
4
- * event's JSON. Mono text on the code surface, a title row with expand,
5
+ * event's JSON, an install command. Mono text on the code surface, a title row with expand,
5
6
  * wrap, and copy controls. Past `maxLines` the body either scrolls
6
7
  * inside that height (`overflow="scroll"`, the default) or folds with a
7
8
  * footer button (`overflow="expand"`).
@@ -10,19 +11,30 @@ import { ComponentProps, ReactNode, Ref } from 'react';
10
11
  * - Wide lines scroll sideways inside the panel; the page never does.
11
12
  * Wrapping is a toggle (`wrap` / `defaultWrap`), off by default so a
12
13
  * body reads the way it was sent.
13
- * - `language="json"` colors keys, strings, numbers, and keywords with a
14
- * built-in tokenizer — no highlighter library at runtime — on the
15
- * `--color-pho-code-*` tokens, which carry light and dark.
14
+ * - `language` colors the text with Shiki's grammar for it, fetched on
15
+ * first use, on the `--color-pho-code-*` tokens, which carry light and
16
+ * dark. JSON has a synchronous face too — a built-in tokenizer paints
17
+ * it in the first render, and the grammar agrees with it — so a body
18
+ * never flashes plain. Other languages read plain for the frame their
19
+ * grammar takes to arrive.
20
+ * - Without a `title` there is no title row: the controls float over the
21
+ * panel's top-right corner, the way a snippet on a page wears a copy
22
+ * button.
16
23
  * - A body that isn't a string (an object) is pretty-printed as JSON.
17
24
  */
18
- export type CodeBlockLanguage = "json" | "text";
19
25
  export type CodeBlockOverflow = "scroll" | "expand";
20
26
  export interface CodeBlockProps extends Omit<ComponentProps<"div">, "title" | "children"> {
21
27
  /** The text. An object is pretty-printed as JSON (two-space indent). */
22
28
  code?: string | object | null;
23
- /** `json` colors the text; `text` leaves it plain. @default "text" */
29
+ /**
30
+ * What the text is, so the panel can color it: `json`, `typescript`,
31
+ * `bash`, `python`, … or `text` for none. @default "text"
32
+ */
24
33
  language?: CodeBlockLanguage;
25
- /** The title row's words — "Request body", "Response". */
34
+ /**
35
+ * The title row's words — "Request body", "Response". Without one the
36
+ * row goes and the controls float over the top-right corner.
37
+ */
26
38
  title?: ReactNode;
27
39
  /** Past this many lines the panel folds or clips. @default 30 */
28
40
  maxLines?: number;
@@ -38,9 +50,9 @@ export interface CodeBlockProps extends Omit<ComponentProps<"div">, "title" | "c
38
50
  /** Wrap long lines at first (uncontrolled). @default false */
39
51
  defaultWrap?: boolean;
40
52
  onWrapChange?: (wrap: boolean) => void;
41
- /** The expand toggle in the title row when `overflow` is `scroll`. @default true */
53
+ /** The expand toggle when `overflow` is `scroll`. @default true */
42
54
  expandToggle?: boolean;
43
- /** The wrap toggle in the title row. @default true */
55
+ /** The wrap toggle. @default true */
44
56
  wrapToggle?: boolean;
45
57
  /**
46
58
  * A gutter of line numbers. Off by default; turn on for a long
@@ -48,11 +60,11 @@ export interface CodeBlockProps extends Omit<ComponentProps<"div">, "title" | "c
48
60
  * @default false
49
61
  */
50
62
  lineNumbers?: boolean;
51
- /** The copy control in the title row. @default true */
63
+ /** The copy control. @default true */
52
64
  copy?: boolean;
53
65
  /** What the panel says with no code. @default "Nothing to show." */
54
66
  empty?: ReactNode;
55
- /** More controls in the title row, before the built-in ones. */
67
+ /** More controls beside the built-in ones, before them. */
56
68
  actions?: ReactNode;
57
69
  ref?: Ref<HTMLDivElement>;
58
70
  }
@@ -0,0 +1,24 @@
1
+ import { CodeLine } from './tokens';
2
+ /** Fetch a language's grammar ahead of the first body that needs it. */
3
+ export declare function preloadLanguage(language: string): Promise<void>;
4
+ /** Whether `language` can be tokenized right now, without waiting. */
5
+ export declare function isLanguageReady(language: string): boolean;
6
+ /**
7
+ * Tokenize a body with a grammar that is already loaded. `null` when the
8
+ * language is plain text or its grammar is not here yet — see
9
+ * `preloadLanguage` / `highlight`.
10
+ */
11
+ export declare function highlightSync(code: string, language: string): CodeLine[] | null;
12
+ /** Plain lines — what a body reads as with no grammar. */
13
+ export declare function plainLines(code: string): CodeLine[];
14
+ /**
15
+ * Tokenize a body, fetching the highlighter and the grammar first if
16
+ * need be. A language the panel does not know resolves to plain lines.
17
+ */
18
+ export declare function highlight(code: string, language: string): Promise<CodeLine[]>;
19
+ /**
20
+ * The highlighted lines of a body, or `null` while its grammar is on the
21
+ * way (and always for plain text). A grammar already here highlights in
22
+ * the same render, no flash.
23
+ */
24
+ export declare function useHighlight(code: string, language: string): CodeLine[] | null;
@@ -1,2 +1,5 @@
1
- export { CodeBlock, type CodeBlockProps, type CodeBlockLanguage, type CodeBlockOverflow, } from './code-block';
1
+ export { CodeBlock, type CodeBlockProps, type CodeBlockOverflow, } from './code-block';
2
+ export { CODE_GRAMMARS, LANGUAGE_ALIASES, resolveGrammar, type CodeBlockLanguage, type CodeGrammar, type CodeLanguageAlias, } from './languages';
3
+ export { highlight, highlightSync, isLanguageReady, preloadLanguage, useHighlight, } from './highlight';
4
+ export { CODE_TOKEN_CLASS, type CodeLine, type CodeToken, type CodeTokenType, } from './tokens';
2
5
  export { tokenizeJson, type JsonToken, type JsonTokenType, } from './tokenize-json';
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The languages a code panel can color, each a grammar fetched on first
3
+ * use — a page that shows JSON never downloads the TypeScript grammar.
4
+ * Keyed by the name Shiki knows the grammar by; `LANGUAGE_ALIASES` lets a
5
+ * panel say `ts` or `sh`.
6
+ */
7
+ export declare const CODE_GRAMMARS: {
8
+ json: () => Promise<typeof import("@shikijs/langs/json")>;
9
+ jsonc: () => Promise<typeof import("@shikijs/langs/jsonc")>;
10
+ javascript: () => Promise<typeof import("@shikijs/langs/javascript")>;
11
+ typescript: () => Promise<typeof import("@shikijs/langs/typescript")>;
12
+ jsx: () => Promise<typeof import("@shikijs/langs/jsx")>;
13
+ tsx: () => Promise<typeof import("@shikijs/langs/tsx")>;
14
+ shellscript: () => Promise<typeof import("@shikijs/langs/shellscript")>;
15
+ python: () => Promise<typeof import("@shikijs/langs/python")>;
16
+ swift: () => Promise<typeof import("@shikijs/langs/swift")>;
17
+ go: () => Promise<typeof import("@shikijs/langs/go")>;
18
+ ruby: () => Promise<typeof import("@shikijs/langs/ruby")>;
19
+ php: () => Promise<typeof import("@shikijs/langs/php")>;
20
+ java: () => Promise<typeof import("@shikijs/langs/java")>;
21
+ kotlin: () => Promise<typeof import("@shikijs/langs/kotlin")>;
22
+ csharp: () => Promise<typeof import("@shikijs/langs/csharp")>;
23
+ rust: () => Promise<typeof import("@shikijs/langs/rust")>;
24
+ html: () => Promise<typeof import("@shikijs/langs/html")>;
25
+ css: () => Promise<typeof import("@shikijs/langs/css")>;
26
+ xml: () => Promise<typeof import("@shikijs/langs/xml")>;
27
+ yaml: () => Promise<typeof import("@shikijs/langs/yaml")>;
28
+ toml: () => Promise<typeof import("@shikijs/langs/toml")>;
29
+ dotenv: () => Promise<typeof import("@shikijs/langs/dotenv")>;
30
+ sql: () => Promise<typeof import("@shikijs/langs/sql")>;
31
+ graphql: () => Promise<typeof import("@shikijs/langs/graphql")>;
32
+ http: () => Promise<typeof import("@shikijs/langs/http")>;
33
+ markdown: () => Promise<typeof import("@shikijs/langs/markdown")>;
34
+ diff: () => Promise<typeof import("@shikijs/langs/diff")>;
35
+ };
36
+ export type CodeGrammar = keyof typeof CODE_GRAMMARS;
37
+ /** Shorter names, and the ones people reach for first. */
38
+ export declare const LANGUAGE_ALIASES: {
39
+ readonly js: "javascript";
40
+ readonly ts: "typescript";
41
+ readonly bash: "shellscript";
42
+ readonly sh: "shellscript";
43
+ readonly shell: "shellscript";
44
+ readonly zsh: "shellscript";
45
+ readonly py: "python";
46
+ readonly rb: "ruby";
47
+ readonly kt: "kotlin";
48
+ readonly cs: "csharp";
49
+ readonly rs: "rust";
50
+ readonly yml: "yaml";
51
+ readonly md: "markdown";
52
+ readonly htm: "html";
53
+ };
54
+ export type CodeLanguageAlias = keyof typeof LANGUAGE_ALIASES;
55
+ /**
56
+ * What `language` accepts: a grammar, an alias, or `text` for none. Plain
57
+ * text is the default — a panel colors only what it is told the shape of.
58
+ */
59
+ export type CodeBlockLanguage = "text" | CodeGrammar | CodeLanguageAlias;
60
+ /**
61
+ * The grammar behind a `language`, or `null` for plain text and names the
62
+ * panel does not know (which read as text instead of throwing).
63
+ */
64
+ export declare function resolveGrammar(language: string): CodeGrammar | null;
@@ -0,0 +1,18 @@
1
+ import { ThemeRegistrationRaw } from 'shiki/core';
2
+ import { CodeTokenType } from './tokens';
3
+ /**
4
+ * Pho's Shiki theme — not a palette but a routing table. Every TextMate
5
+ * scope resolves to one of the panel's token kinds, and each kind's
6
+ * "color" is the design token's own variable, so the theme has no light
7
+ * and dark of its own: the `--color-pho-code-*` tokens carry both, and
8
+ * the renderer turns each color back into the kind's class. Only the
9
+ * kinds a body needs to read — keys, strings, numbers, keywords,
10
+ * punctuation, comments, calls, types. Operators, variables, and
11
+ * everything else stay in the panel's ink.
12
+ */
13
+ export declare const PHO_THEME_NAME = "pho";
14
+ /** The color a token kind "has" in the theme: its token's variable. */
15
+ export declare function tokenColor(type: Exclude<CodeTokenType, "plain">): string;
16
+ /** The token kind behind a Shiki color, or `plain` for the panel's ink. */
17
+ export declare function tokenTypeOf(color: string | undefined): CodeTokenType;
18
+ export declare const phoTheme: ThemeRegistrationRaw;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The token vocabulary a code panel colors with — one class per kind, on
3
+ * the `--color-pho-code-*` tokens, which carry light and dark. The JSON
4
+ * tokenizer speaks the first five; Shiki's grammars reach the rest.
5
+ */
6
+ export type CodeTokenType = "key" | "string" | "number" | "keyword" | "punctuation" | "comment" | "function" | "type" | "plain";
7
+ export interface CodeToken {
8
+ type: CodeTokenType;
9
+ text: string;
10
+ }
11
+ /** One line of a highlighted body. */
12
+ export type CodeLine = CodeToken[];
13
+ /** The class a token kind wears; `plain` wears the panel's own ink. */
14
+ export declare const CODE_TOKEN_CLASS: Record<CodeTokenType, string | undefined>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The table chrome `DataTable` and `Trace.Logs` share, kept apart from
3
+ * `data-table.tsx` so a consumer of the classes alone (the trace's log
4
+ * list) does not carry the table engine into its chunk.
5
+ *
6
+ * - The frame is `BasicPage.Card`'s box minus its dividers; rows draw
7
+ * their own.
8
+ * - A header cell is description ink at the row's size, regular weight,
9
+ * 40px tall on every size: a label row, not a banner. Its padding is the
10
+ * cell's own (`px-5` in a table, the row's in a grid), so it stays out.
11
+ * - The body's top border is the line under the header; the rows divide
12
+ * themselves.
13
+ */
14
+ /** Same chrome as `BasicPage.Card`, minus its dividers — rows draw their own. */
15
+ export declare const DATA_TABLE_SURFACE = "rounded-base border border-pho-secondary bg-pho-primary";
16
+ /** A header cell: ink, height, weight. Pad it where it sits. */
17
+ export declare const DATA_TABLE_HEADER_CELL = "text-pho-description h-10 text-left align-middle font-normal whitespace-nowrap";
18
+ /** The body: the line under the header, and one between every two rows. */
19
+ export declare const DATA_TABLE_BODY = "divide-pho-secondary border-pho-secondary divide-y border-t";
20
+ export type DataTableSize = "sm" | "base" | "lg";
21
+ /**
22
+ * The type each size sets on the table, so cells and header move together:
23
+ * 13px dense, the body's 14px, 16px for rows that carry two lines.
24
+ */
25
+ export declare const DATA_TABLE_TEXT: Record<DataTableSize, string>;
@@ -1,5 +1,6 @@
1
1
  import { ComponentProps, KeyboardEvent, MouseEvent, ReactNode, Ref } from 'react';
2
2
  import { ColumnDef, RowData, SortingState } from '@tanstack/react-table';
3
+ import { DATA_TABLE_SURFACE } from './chrome';
3
4
  /**
4
5
  * DataTable — a table of records with column semantics: sortable headers,
5
6
  * aligned cells, rows that are links into a subpage. TanStack Table (v9)
@@ -265,7 +266,5 @@ export interface TableSearchStore {
265
266
  export declare function createTableSearchStore(): TableSearchStore;
266
267
  export declare const TableSearchContext: import('react').Context<TableSearchStore | null>;
267
268
  export { GhostSearch, type GhostSearchProps } from '../../utils/ghost-search';
268
- /** Same chrome as `BasicPage.Card`, minus its dividers — rows draw their own. */
269
- declare const DATA_TABLE_SURFACE = "rounded-base border border-pho-secondary bg-pho-primary";
270
269
  declare function DataTable<TData extends RowData>({ columns, data, getRowId, rowHref, onRowClick, current, selected, onSelectedChange, defaultSort, sort, onSortChange, search, toolbar, group, animateHeight, loading, empty, layout, size, className, ...props }: DataTableProps<TData>): import("react").JSX.Element;
271
270
  export { DataTable, DATA_TABLE_SURFACE };
@@ -1,11 +1,20 @@
1
- import { ChartBaseProps, ChartDatum } from '../chart/types';
1
+ import { ChartBaseProps, ChartCurve, ChartDatum } from '../chart/types';
2
+ /**
3
+ * LineChart — series over time as lines: latency percentiles, one line
4
+ * per destination, a min / average / max where the bounds are dashed.
5
+ *
6
+ * A preset on `Chart`: the `series` array becomes one `Chart.Line` per
7
+ * entry, in order; `curve` applies to every line and `area` washes the
8
+ * surface under the first. The marks, axes, tooltip and legend are the
9
+ * root's.
10
+ */
2
11
  export interface LineChartProps<T extends ChartDatum> extends ChartBaseProps<T> {
3
12
  /** Straight segments, or a monotone curve that never overshoots a sample. @default "linear" */
4
- curve?: "linear" | "monotone";
13
+ curve?: ChartCurve;
5
14
  /** A soft fill under the first series (a lone one, as a rule). */
6
15
  area?: boolean;
7
16
  }
8
- export declare function LineChart<T extends ChartDatum>({ data, series, label, description, height, width: fixedWidth, valueFormat, timeFormat, locale, legend, baseline, curve, area, breakdownTitle, loading, empty, className, ...props }: LineChartProps<T>): import("react").JSX.Element;
17
+ export declare function LineChart<T extends ChartDatum>({ series, curve, area, ...props }: LineChartProps<T>): import("react").JSX.Element;
9
18
  export declare namespace LineChart {
10
19
  var displayName: string;
11
20
  }
@@ -94,16 +94,27 @@ export interface TraceLogsProps extends Omit<ComponentProps<"section">, "childre
94
94
  logs?: readonly TraceLog[] | null;
95
95
  /** The spans, to name the one each line was written in. */
96
96
  spans?: readonly Pick<TraceWaterfallSpan, "id" | "name">[];
97
- /** @default "Logs" */
97
+ /**
98
+ * Lines not here yet: the header over bone rows, `true` for five or a
99
+ * count. The list is `aria-busy` meanwhile.
100
+ */
101
+ loading?: boolean | number;
102
+ /**
103
+ * @deprecated The card head this named is gone — `DataTable`'s header
104
+ * row replaced it. Kept so an existing caller still compiles; renders
105
+ * as a visually-hidden caption instead of disappearing.
106
+ */
98
107
  title?: ReactNode;
99
108
  ref?: Ref<HTMLElement>;
100
109
  }
101
110
  /**
102
111
  * The log lines that belong to the trace, each at its offset from the
103
- * start, in the mono face. Renders nothing when there are none — a
104
- * trace with no logs shows no empty block.
112
+ * start, in the mono face, under `DataTable`'s header row (its `sm`
113
+ * size: description ink, regular weight, 40px on one baseline). Renders
114
+ * nothing when there are none — a trace with no logs shows no empty
115
+ * block.
105
116
  */
106
- declare function Logs({ logs, spans, title, className, ...props }: TraceLogsProps): import("react").JSX.Element | null;
117
+ declare function Logs({ logs, spans, loading, title, className, ...props }: TraceLogsProps): import("react").JSX.Element | null;
107
118
  export declare const Trace: {
108
119
  Waterfall: typeof Waterfall & {
109
120
  Footer: typeof WaterfallFooter;
@@ -88,6 +88,12 @@ export declare const EASE_STACK = "cubic-bezier(0.22, 1, 0.36, 1)";
88
88
  export declare const RISE_PX = 12;
89
89
  /** Rise distance for the condensed bar — it comes from nearer still. */
90
90
  export declare const BAR_RISE_PX = -8;
91
+ /**
92
+ * How far a view that widens starts inside its frame, and one that
93
+ * narrows starts outside it — a chart's range switch. A tenth: enough to
94
+ * read as the picture opening or closing, never as a zoom.
95
+ */
96
+ export declare const SPAN_SCALE = 0.9;
91
97
  /** Press depth for small controls. */
92
98
  export declare const PRESS_SCALE = 0.96;
93
99
  /** Press depth for rows and full-size surfaces — shallower. */
@@ -2,6 +2,7 @@ import { AnchorHTMLAttributes, ComponentProps, ReactNode, Ref } from 'react';
2
2
  import { ButtonLinkProps, ButtonProps } from '../../components/button';
3
3
  import { Form as FormElement } from '../../components/form';
4
4
  import { DataTable } from '../../components/data-table';
5
+ import { CodeBlock } from '../../components/code-block';
5
6
  /**
6
7
  * Bordered card that stacks rows with hairline dividers. `gap-0` is the
7
8
  * card's own: Stack used to force `gap-3` onto a bare Card and open 12px
@@ -1051,6 +1052,7 @@ export declare const BasicPage: {
1051
1052
  Aside: typeof Aside;
1052
1053
  Search: typeof Search;
1053
1054
  Table: typeof DataTable;
1055
+ Code: typeof CodeBlock;
1054
1056
  CondenseScope: typeof CondenseScope;
1055
1057
  Breadcrumbs: typeof Breadcrumbs;
1056
1058
  Crumb: typeof Crumb;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photon-ai/pho-ui",
3
- "version": "4.7.1",
3
+ "version": "4.9.0",
4
4
  "description": "Pho Design System — Photon's React component library, built on Base UI",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -501,7 +501,9 @@
501
501
  },
502
502
  "dependencies": {
503
503
  "@base-ui/react": "^1.7.0",
504
+ "@shikijs/langs": "4.4.3",
504
505
  "@tanstack/react-table": "^9.2.3",
506
+ "@visx/xychart": "^4.0.0",
505
507
  "clsx": "^2.1.1",
506
508
  "cmdk": "^1.1.1",
507
509
  "country-flag-icons": "^1.6.20",
@@ -511,6 +513,7 @@
511
513
  "libphonenumber-js": "^1.13.11",
512
514
  "motion": "^13.1.0",
513
515
  "react-day-picker": "^10.0.1",
516
+ "shiki": "4.4.3",
514
517
  "tailwind-merge": "^3.6.0"
515
518
  },
516
519
  "scripts": {
@@ -488,13 +488,16 @@
488
488
  }
489
489
  }
490
490
 
491
- /* ============================ Code (logs) ============================ */
492
- /* logs: the read-only code panel (CodeBlock) and its JSON tokens. The
491
+ /* ============================== Code ============================== */
492
+ /* The read-only code panel (CodeBlock) and its syntax tokens. The
493
493
  surface is a well one step off the card: the page gray in light, a
494
494
  step below the card in dark. Syntax inks come from the accent set
495
495
  above, darkened for white and lifted (and softened) for dark so a
496
- body reads at the mono size in both. `--color-*` so text-, bg-, and
497
- border- utilities all exist. */
496
+ body reads at the mono size in both. Eight kinds and no more — key,
497
+ string, number, keyword, punctuation, comment, function, type — so a
498
+ body reads as prose with a few things picked out, not as confetti;
499
+ Shiki's grammars route every scope to one of them. `--color-*` so
500
+ text-, bg-, and border- utilities all exist. */
498
501
  --color-pho-code-bg: light-dark(oklch(0.985 0 0), oklch(0.13 0 0));
499
502
  --color-pho-code-fg: light-dark(oklch(0 0 0 / 0.85), oklch(1 0 0 / 0.85));
500
503
  --color-pho-code-key: light-dark(
@@ -517,4 +520,14 @@
517
520
  oklch(0 0 0 / 0.55),
518
521
  oklch(1 0 0 / 0.55)
519
522
  );
523
+ /* A comment steps back further than punctuation: read it on purpose. */
524
+ --color-pho-code-comment: light-dark(
525
+ oklch(0 0 0 / 0.42),
526
+ oklch(1 0 0 / 0.42)
527
+ );
528
+ /* Calls in the olive of a function name (the yellow, grounded for
529
+ white); types in a teal off the sky. Both one step quieter than the
530
+ keys and keywords around them. */
531
+ --color-pho-code-function: light-dark(oklch(0.5 0.1 90), oklch(0.86 0.1 105));
532
+ --color-pho-code-type: light-dark(oklch(0.52 0.09 215), oklch(0.8 0.1 200));
520
533
  }
@@ -1,75 +0,0 @@
1
- "use client";
2
- import { t as e } from "./createReactComponent-BqCmnqfX.js";
3
- var a = [
4
- ["path", {
5
- d: "M16 4l4 0l0 4",
6
- key: "svg-0"
7
- }],
8
- ["path", {
9
- d: "M14 10l6 -6",
10
- key: "svg-1"
11
- }],
12
- ["path", {
13
- d: "M8 20l-4 0l0 -4",
14
- key: "svg-2"
15
- }],
16
- ["path", {
17
- d: "M4 20l6 -6",
18
- key: "svg-3"
19
- }],
20
- ["path", {
21
- d: "M16 20l4 0l0 -4",
22
- key: "svg-4"
23
- }],
24
- ["path", {
25
- d: "M14 14l6 6",
26
- key: "svg-5"
27
- }],
28
- ["path", {
29
- d: "M8 4l-4 0l0 4",
30
- key: "svg-6"
31
- }],
32
- ["path", {
33
- d: "M4 4l6 6",
34
- key: "svg-7"
35
- }]
36
- ], t = e("outline", "arrows-maximize", "ArrowsMaximize", a), l = [
37
- ["path", {
38
- d: "M5 9l4 0l0 -4",
39
- key: "svg-0"
40
- }],
41
- ["path", {
42
- d: "M3 3l6 6",
43
- key: "svg-1"
44
- }],
45
- ["path", {
46
- d: "M5 15l4 0l0 4",
47
- key: "svg-2"
48
- }],
49
- ["path", {
50
- d: "M3 21l6 -6",
51
- key: "svg-3"
52
- }],
53
- ["path", {
54
- d: "M19 9l-4 0l0 -4",
55
- key: "svg-4"
56
- }],
57
- ["path", {
58
- d: "M15 9l6 -6",
59
- key: "svg-5"
60
- }],
61
- ["path", {
62
- d: "M19 15l-4 0l0 4",
63
- key: "svg-6"
64
- }],
65
- ["path", {
66
- d: "M15 15l6 6",
67
- key: "svg-7"
68
- }]
69
- ], i = e("outline", "arrows-minimize", "ArrowsMinimize", l);
70
- export {
71
- t as n,
72
- i as t
73
- };
74
-
75
- //# sourceMappingURL=IconArrowsMinimize-BfPUGuCB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IconArrowsMinimize-BfPUGuCB.js","names":["__iconNode"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowsMaximize.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowsMinimize.mjs"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M16 4l4 0l0 4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M14 10l6 -6\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M8 20l-4 0l0 -4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M4 20l6 -6\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M16 20l4 0l0 -4\", \"key\": \"svg-4\" }], [\"path\", { \"d\": \"M14 14l6 6\", \"key\": \"svg-5\" }], [\"path\", { \"d\": \"M8 4l-4 0l0 4\", \"key\": \"svg-6\" }], [\"path\", { \"d\": \"M4 4l6 6\", \"key\": \"svg-7\" }]];\nconst IconArrowsMaximize = createReactComponent(\"outline\", \"arrows-maximize\", \"ArrowsMaximize\", __iconNode);\n\nexport { __iconNode, IconArrowsMaximize as default };\n//# sourceMappingURL=IconArrowsMaximize.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M5 9l4 0l0 -4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M3 3l6 6\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M5 15l4 0l0 4\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M3 21l6 -6\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M19 9l-4 0l0 -4\", \"key\": \"svg-4\" }], [\"path\", { \"d\": \"M15 9l6 -6\", \"key\": \"svg-5\" }], [\"path\", { \"d\": \"M19 15l-4 0l0 4\", \"key\": \"svg-6\" }], [\"path\", { \"d\": \"M15 15l6 6\", \"key\": \"svg-7\" }]];\nconst IconArrowsMinimize = createReactComponent(\"outline\", \"arrows-minimize\", \"ArrowsMinimize\", __iconNode);\n\nexport { __iconNode, IconArrowsMinimize as default };\n//# sourceMappingURL=IconArrowsMinimize.mjs.map\n"],"x_google_ignoreList":[0,1],"mappings":";;AASA,IAAMA,IAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAiB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAe,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAmB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAmB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAiB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAC,GACna,IAAqB,EAAqB,WAAW,mBAAmB,kBAAkBA,CAAU,GCDpG,IAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAiB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAY,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAiB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAmB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAmB,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAC,GACla,IAAqB,EAAqB,WAAW,mBAAmB,kBAAkB,CAAU"}