@dbx-tools/ui 0.9.182 → 0.9.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  // Hand edits are overwritten on the next watch; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui";
6
- export const PACKAGE_VERSION = "0.9.182";
6
+ export const PACKAGE_VERSION = "0.9.185";
package/package.json CHANGED
@@ -31,11 +31,11 @@
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "1.7.6",
33
33
  "@databricks/appkit-ui": "0.81.0",
34
- "@dbx-tools/shared-auth": "^0.9.182",
35
- "@dbx-tools/shared-core": "^0.9.182",
36
- "@dbx-tools/shared-email": "^0.9.182",
37
- "@dbx-tools/shared-email-template": "^0.9.182",
38
- "@dbx-tools/shared-search": "^0.9.182",
34
+ "@dbx-tools/shared-auth": "^0.9.185",
35
+ "@dbx-tools/shared-core": "^0.9.185",
36
+ "@dbx-tools/shared-email": "^0.9.185",
37
+ "@dbx-tools/shared-email-template": "^0.9.185",
38
+ "@dbx-tools/shared-search": "^0.9.185",
39
39
  "lucide-react": "^0.554.0",
40
40
  "shiki": "^3.0.0",
41
41
  "streamdown": "^2.5.0",
@@ -46,7 +46,7 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "version": "0.9.182",
49
+ "version": "0.9.185",
50
50
  "types": "index.ts",
51
51
  "dbxToolsConfig": {
52
52
  "tags": [
@@ -15,6 +15,7 @@ interface State {
15
15
  errorInfo: React.ErrorInfo | null;
16
16
  }
17
17
 
18
+ /** Render a diagnostic fallback when a descendant React component throws. */
18
19
  export class ErrorBoundary extends Component<Props, State> {
19
20
  constructor(props: Props) {
20
21
  super(props);
@@ -46,19 +47,19 @@ export class ErrorBoundary extends Component<Props, State> {
46
47
  <div className="min-h-screen bg-background p-4">
47
48
  <Card className="max-w-2xl mx-auto mt-8">
48
49
  <CardHeader>
49
- <CardTitle className="text-destructive">Application Error</CardTitle>
50
+ <CardTitle className="text-destructive">Application error</CardTitle>
50
51
  </CardHeader>
51
52
  <CardContent>
52
53
  <div className="space-y-4">
53
54
  <div>
54
- <h3 className="font-semibold mb-2">Error Message:</h3>
55
+ <h3 className="font-semibold mb-2">Error message</h3>
55
56
  <pre className="bg-muted p-3 rounded text-sm overflow-auto">
56
57
  {errorMessage(this.state.error)}
57
58
  </pre>
58
59
  </div>
59
60
  {this.state.errorInfo && (
60
61
  <div>
61
- <h3 className="font-semibold mb-2">Component Stack:</h3>
62
+ <h3 className="font-semibold mb-2">Component stack</h3>
62
63
  <pre className="bg-muted p-3 rounded text-sm overflow-auto">
63
64
  {this.state.errorInfo.componentStack}
64
65
  </pre>
@@ -66,7 +67,7 @@ export class ErrorBoundary extends Component<Props, State> {
66
67
  )}
67
68
  {this.state.error?.stack && (
68
69
  <div>
69
- <h3 className="font-semibold mb-2">Stack Trace:</h3>
70
+ <h3 className="font-semibold mb-2">Stack trace</h3>
70
71
  <pre className="bg-muted p-3 rounded text-sm overflow-auto max-h-96">
71
72
  {this.state.error.stack}
72
73
  </pre>
@@ -18,8 +18,8 @@ import {
18
18
  cn,
19
19
  } from "@databricks/appkit-ui/react";
20
20
  import { BracesIcon, Table2Icon } from "lucide-react";
21
- import { Fragment, useState } from "react";
22
- import { Streamdown } from "streamdown";
21
+ import { createContext, Fragment, useContext, useState } from "react";
22
+ import { Streamdown, type LinkSafetyConfig } from "streamdown";
23
23
 
24
24
  import { detectCodeLanguage, HighlightedCodeBlock, JsonBlock } from "./highlighted-code.tsx";
25
25
  import {
@@ -42,15 +42,21 @@ const MARKDOWN_CELL_CLASSES = cn(
42
42
  "[&_pre]:my-1 [&_pre]:overflow-x-auto [&_pre]:rounded",
43
43
  "[&_pre]:bg-background/60 [&_pre]:p-1.5 [&_pre]:text-[10px] [&_code]:text-[10px]",
44
44
  "[&_[data-streamdown=table-wrapper]]:my-1 [&_[data-streamdown=table-wrapper]]:gap-1",
45
- "[&_[data-streamdown=table-wrapper]]:rounded [&_[data-streamdown=table-wrapper]]:p-1",
45
+ "[&_[data-streamdown=table-wrapper]]:!rounded-none [&_[data-streamdown=table-wrapper]]:!border-0",
46
+ "[&_[data-streamdown=table-wrapper]]:!bg-transparent [&_[data-streamdown=table-wrapper]]:!p-0",
46
47
  "[&_[data-streamdown=table-header-cell]]:px-2 [&_[data-streamdown=table-header-cell]]:py-1",
47
48
  "[&_[data-streamdown=table-header-cell]]:text-[11px] [&_[data-streamdown=table-header-cell]]:leading-snug",
48
49
  "[&_[data-streamdown=table-cell]]:px-2 [&_[data-streamdown=table-cell]]:py-1",
49
50
  "[&_[data-streamdown=table-cell]]:text-[11px] [&_[data-streamdown=table-cell]]:leading-snug",
51
+ "[&_[data-streamdown=link]]:font-normal [&_[data-streamdown=link]]:text-blue-700",
52
+ "[&_[data-streamdown=link]]:decoration-blue-700/40 [&_[data-streamdown=link]]:underline-offset-2",
53
+ "[&_[data-streamdown=link]]:hover:text-blue-800 [&_[data-streamdown=link]]:hover:decoration-current",
54
+ "dark:[&_[data-streamdown=link]]:text-blue-300 dark:[&_[data-streamdown=link]]:decoration-blue-300/40 dark:[&_[data-streamdown=link]]:hover:text-blue-200",
50
55
  );
51
56
 
52
57
  const MAX_NESTED_DEPTH = 12;
53
58
  const MAX_INDENT_DEPTH = 4;
59
+ const RecordPreviewLinkSafetyContext = createContext<LinkSafetyConfig | undefined>(undefined);
54
60
 
55
61
  /** Props for {@link RecordPreview}. */
56
62
  export interface RecordPreviewProps {
@@ -58,48 +64,52 @@ export interface RecordPreviewProps {
58
64
  value: unknown;
59
65
  /** Extra classes on the outer frame. */
60
66
  className?: string;
67
+ /** Optional Streamdown confirmation behavior for detected links. */
68
+ linkSafety?: LinkSafetyConfig;
61
69
  }
62
70
 
63
71
  /** Compact labeled table of a JSON object, with a JSON/raw icon toggle. */
64
- export function RecordPreview({ value, className }: RecordPreviewProps) {
72
+ export function RecordPreview({ value, className, linkSafety }: RecordPreviewProps) {
65
73
  const [raw, setRaw] = useState(false);
66
74
  const rows = recordPreviewRows(value);
67
75
  const rawJson = formatRecordPreviewJson(value);
68
76
  return (
69
- <div
70
- className={cn(
71
- "relative min-w-0 max-w-full overflow-hidden [&_[data-slot=table-container]]:max-w-full [&_[data-slot=table-container]]:overflow-x-hidden",
72
- className,
73
- )}
74
- >
75
- <div className="sticky top-1 z-10 float-right mr-1 h-0">
76
- <Tooltip>
77
- <TooltipTrigger asChild>
78
- <Button
79
- type="button"
80
- size="icon"
81
- variant="ghost"
82
- aria-pressed={raw}
83
- aria-label={raw ? "Show table" : "Show JSON"}
84
- className="size-6 bg-background/85 backdrop-blur-sm"
85
- onClick={() => setRaw((current) => !current)}
86
- >
87
- {raw ? <Table2Icon className="size-3" /> : <BracesIcon className="size-3" />}
88
- </Button>
89
- </TooltipTrigger>
90
- <TooltipContent>{raw ? "Table" : "JSON"}</TooltipContent>
91
- </Tooltip>
77
+ <RecordPreviewLinkSafetyContext.Provider value={linkSafety}>
78
+ <div
79
+ className={cn(
80
+ "relative min-w-0 max-w-full overflow-clip [&_[data-slot=table-container]]:max-w-full [&_[data-slot=table-container]]:overflow-x-hidden",
81
+ className,
82
+ )}
83
+ >
84
+ <div className="pointer-events-none sticky top-1 z-20 flex h-0 justify-end pr-1">
85
+ <Tooltip>
86
+ <TooltipTrigger asChild>
87
+ <Button
88
+ type="button"
89
+ size="icon"
90
+ variant="ghost"
91
+ aria-pressed={raw}
92
+ aria-label={raw ? "Show table" : "Show JSON"}
93
+ className="pointer-events-auto size-6 bg-background shadow-sm ring-1 ring-border/40"
94
+ onClick={() => setRaw((current) => !current)}
95
+ >
96
+ {raw ? <Table2Icon className="size-3" /> : <BracesIcon className="size-3" />}
97
+ </Button>
98
+ </TooltipTrigger>
99
+ <TooltipContent>{raw ? "Table" : "JSON"}</TooltipContent>
100
+ </Tooltip>
101
+ </div>
102
+ {raw ? (
103
+ <JsonBlock json={rawJson} className="rounded bg-background/40 p-2 pr-8 text-[11px]" />
104
+ ) : rows.length === 0 ? (
105
+ <pre className="whitespace-pre-wrap break-words rounded bg-background/40 p-2 pr-8 font-mono text-[11px] leading-relaxed">
106
+ {rawJson}
107
+ </pre>
108
+ ) : (
109
+ <RecordTable rows={rows} />
110
+ )}
92
111
  </div>
93
- {raw ? (
94
- <JsonBlock json={rawJson} className="rounded bg-background/40 p-2 pr-8 text-[11px]" />
95
- ) : rows.length === 0 ? (
96
- <pre className="whitespace-pre-wrap break-words rounded bg-background/40 p-2 pr-8 font-mono text-[11px] leading-relaxed">
97
- {rawJson}
98
- </pre>
99
- ) : (
100
- <RecordTable rows={rows} />
101
- )}
102
- </div>
112
+ </RecordPreviewLinkSafetyContext.Provider>
103
113
  );
104
114
  }
105
115
 
@@ -348,6 +358,7 @@ function nestedRecordValue(
348
358
  }
349
359
 
350
360
  function RecordValue({ value, depth }: { value: unknown; depth: number }) {
361
+ const linkSafety = useContext(RecordPreviewLinkSafetyContext);
351
362
  if (value == null) {
352
363
  return <span className="text-muted-foreground">null</span>;
353
364
  }
@@ -365,19 +376,22 @@ function RecordValue({ value, depth }: { value: unknown; depth: number }) {
365
376
  />
366
377
  );
367
378
  }
368
- if (looksLikeMarkdown(value)) {
369
- return (
370
- <div className={MARKDOWN_CELL_CLASSES}>
371
- <Streamdown controls={false}>{markdownForPreview(value)}</Streamdown>
372
- </div>
373
- );
374
- }
375
- return <span className="whitespace-pre-wrap break-words">{value}</span>;
379
+ return (
380
+ <div className={MARKDOWN_CELL_CLASSES}>
381
+ <Streamdown controls={false} linkSafety={linkSafety}>
382
+ {markdownForPreview(value)}
383
+ </Streamdown>
384
+ </div>
385
+ );
376
386
  }
377
387
  if (Array.isArray(value)) {
378
388
  if (value.every((item) => item == null || typeof item !== "object")) {
379
389
  return (
380
- <span className="whitespace-pre-wrap break-words">{value.map(String).join(", ")}</span>
390
+ <div className={MARKDOWN_CELL_CLASSES}>
391
+ <Streamdown controls={false} linkSafety={linkSafety}>
392
+ {value.map(String).join(", ")}
393
+ </Streamdown>
394
+ </div>
381
395
  );
382
396
  }
383
397
  if (depth < MAX_NESTED_DEPTH) {