@sragatiping/cuboid 0.1.0 → 0.1.4
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/dist/components/ApiResponseViewer/ApiResponseViewer.d.ts +24 -0
- package/dist/components/ApiResponseViewer/ApiResponseViewer.stories.d.ts +13 -0
- package/dist/components/ApiResponseViewer/index.d.ts +3 -0
- package/dist/components/ApiResponseViewer/status.d.ts +8 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +18 -0
- package/dist/components/CodeBlock/CodeBlock.stories.d.ts +12 -0
- package/dist/components/CodeBlock/CodeSurface.d.ts +48 -0
- package/dist/components/CodeBlock/CodeSurface.stories.d.ts +15 -0
- package/dist/components/CodeBlock/CodeViewingDocs.d.ts +7 -0
- package/dist/components/CodeBlock/JsonCodeView.d.ts +17 -0
- package/dist/components/CodeBlock/JsonCodeView.stories.d.ts +19 -0
- package/dist/components/CodeBlock/__fixtures__/dev-server-diagnostics.d.ts +145 -0
- package/dist/components/CodeBlock/__fixtures__/source-samples.d.ts +10 -0
- package/dist/components/CodeBlock/constants.d.ts +11 -0
- package/dist/components/CodeBlock/highlight/css.d.ts +1 -0
- package/dist/components/CodeBlock/highlight/html.d.ts +1 -0
- package/dist/components/CodeBlock/highlight/index.d.ts +5 -0
- package/dist/components/CodeBlock/highlight/javascript.d.ts +5 -0
- package/dist/components/CodeBlock/highlight/shared.d.ts +15 -0
- package/dist/components/CodeBlock/index.d.ts +14 -0
- package/dist/components/CodeBlock/syntax.d.ts +37 -0
- package/dist/components/{CodeSnippet → CodeBlock}/tokenizer.d.ts +0 -5
- package/dist/components/CodeBlock/types.d.ts +27 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +9 -50
- package/dist/components/JsonViewer/JsonViewer.d.ts +1 -1
- package/dist/components/core/Box/Box.d.ts +24 -0
- package/dist/components/core/Box/Box.stories.d.ts +9 -0
- package/dist/components/core/Box/boxTypes.d.ts +6 -0
- package/dist/components/core/Box/index.d.ts +2 -0
- package/dist/components/core/Callout/Callout.d.ts +17 -0
- package/dist/components/core/Callout/Callout.stories.d.ts +10 -0
- package/dist/components/core/Callout/index.d.ts +2 -0
- package/dist/components/core/Container/Container.d.ts +23 -0
- package/dist/components/core/Container/Container.stories.d.ts +10 -0
- package/dist/components/core/Container/index.d.ts +2 -0
- package/dist/components/core/Divider/Divider.d.ts +17 -0
- package/dist/components/core/Divider/Divider.stories.d.ts +9 -0
- package/dist/components/core/Divider/index.d.ts +2 -0
- package/dist/components/core/Highlight/Highlight.d.ts +16 -0
- package/dist/components/core/Highlight/Highlight.stories.d.ts +8 -0
- package/dist/components/core/Highlight/index.d.ts +2 -0
- package/dist/components/core/Link/Link.d.ts +10 -5
- package/dist/components/core/Pill/Pill.d.ts +12 -6
- package/dist/components/core/Pill/Pill.stories.d.ts +3 -0
- package/dist/components/core/Pill/index.d.ts +1 -1
- package/dist/components/core/Popover/Popover.d.ts +1 -1
- package/dist/components/core/Stack/Stack.d.ts +12 -21
- package/dist/components/core/Stack/index.d.ts +1 -1
- package/dist/components/core/Text/Text.d.ts +7 -7
- package/dist/components/core/index.d.ts +11 -1
- package/dist/index.cjs.js +7 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.es.js +4029 -3342
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/theme/globalColor.d.ts +25 -0
- package/dist/theme/output/base.json.d.ts +28 -56
- package/dist/theme/output/theme.json.d.ts +579 -1016
- package/dist/theme/themeCubeOverride.d.ts +11 -0
- package/dist/theme/types.d.ts +64 -19
- package/package.json +9 -4
- package/src/theme/output/components.css +1945 -0
- package/src/theme/output/theme.css +247 -0
- package/dist/components/CodeSnippet/CodeSnippet.stories.d.ts +0 -17
- package/dist/components/CodeSnippet/__fixtures__/device-profile-report.d.ts +0 -422
- package/dist/components/JsonGraph/DeviceProfileReport.stories.d.ts +0 -11
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JsonCodeViewProps } from '../CodeBlock';
|
|
2
|
+
import { CubeTheme } from '../../theme/types';
|
|
3
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
4
|
+
export type ApiResponseHeaders = Record<string, string> | ReadonlyArray<readonly [string, string]>;
|
|
5
|
+
export interface ApiResponseViewerProps {
|
|
6
|
+
/** Parsed response body — rendered with {@link JsonCodeView}. */
|
|
7
|
+
body: unknown;
|
|
8
|
+
/** HTTP status code. */
|
|
9
|
+
status: number;
|
|
10
|
+
method?: HttpMethod;
|
|
11
|
+
url?: string;
|
|
12
|
+
headers?: ApiResponseHeaders;
|
|
13
|
+
/** Round-trip duration in milliseconds. */
|
|
14
|
+
durationMs?: number;
|
|
15
|
+
theme?: CubeTheme;
|
|
16
|
+
/** Props forwarded to the body {@link JsonCodeView} (except `data`). */
|
|
17
|
+
codeView?: Omit<JsonCodeViewProps, "data">;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* HTTP response shell — status summary, optional headers, JSON body via
|
|
22
|
+
* {@link JsonCodeView}. Intended for API debug panels and network inspectors.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ApiResponseViewer({ body, status, method, url, headers, durationMs, theme, codeView, "aria-label": ariaLabel, }: ApiResponseViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ApiResponseViewer } from './ApiResponseViewer';
|
|
3
|
+
declare const meta: Meta<typeof ApiResponseViewer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ApiResponseViewer>;
|
|
6
|
+
/** Dev-server diagnostics returned from a local tooling endpoint. */
|
|
7
|
+
export declare const DevServerDiagnostics: Story;
|
|
8
|
+
/** Compact success payload without headers. */
|
|
9
|
+
export declare const Success200: Story;
|
|
10
|
+
/** Client error with minimal detail. */
|
|
11
|
+
export declare const NotFound404: Story;
|
|
12
|
+
/** Server error response. */
|
|
13
|
+
export declare const ServerError500: Story;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PillShade } from '../core/Pill';
|
|
2
|
+
import { HttpMethod } from './ApiResponseViewer';
|
|
3
|
+
/** Maps HTTP methods to pill shades — read vs write semantics (Postman-style). */
|
|
4
|
+
export declare function methodPillShade(method: HttpMethod): PillShade;
|
|
5
|
+
/** Maps HTTP status code ranges to pill shades for quick visual scanning. */
|
|
6
|
+
export declare function statusPillShade(status: number): PillShade;
|
|
7
|
+
/** Common reason phrase for a status code, or the numeric code as a string. */
|
|
8
|
+
export declare function statusReasonPhrase(status: number): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeSurfaceProps } from './CodeSurface';
|
|
2
|
+
import { CodeBlockLanguage } from './highlight';
|
|
3
|
+
export interface CodeBlockProps extends Pick<CodeSurfaceProps, "height" | "maxHeight" | "theme" | "linkify" | "onLinkClick" | "watchlist" | "defaultWatchlist" | "onWatchlistChange" | "surfaceVariant" | "aria-label"> {
|
|
4
|
+
/** Source text to display. */
|
|
5
|
+
code: string;
|
|
6
|
+
/**
|
|
7
|
+
* Highlighting grammar.
|
|
8
|
+
* @default "text"
|
|
9
|
+
*/
|
|
10
|
+
language?: CodeBlockLanguage;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generic source display — JavaScript, HTML, CSS, and plain text.
|
|
14
|
+
* Tokenizes source into lines and renders via {@link CodeSurface}.
|
|
15
|
+
*
|
|
16
|
+
* For JSON API payloads use {@link JsonCodeView} instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare function CodeBlock({ code, language, height, maxHeight, theme, linkify, onLinkClick, watchlist, defaultWatchlist, onWatchlistChange, surfaceVariant, "aria-label": ariaLabel, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { CodeBlock } from './CodeBlock';
|
|
3
|
+
declare const meta: Meta<typeof CodeBlock>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof CodeBlock>;
|
|
6
|
+
export declare const JavaScript: Story;
|
|
7
|
+
export declare const TypeScript: Story;
|
|
8
|
+
export declare const Html: Story;
|
|
9
|
+
export declare const Css: Story;
|
|
10
|
+
export declare const PlainText: Story;
|
|
11
|
+
/** ~200 lines — windowed rendering inside a fixed height. */
|
|
12
|
+
export declare const LargeVirtualised: Story;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../theme/types';
|
|
3
|
+
import { SurfaceLine, SurfaceToken } from './types';
|
|
4
|
+
export interface CodeSurfaceGutterIcons {
|
|
5
|
+
collapsed?: React.ReactNode;
|
|
6
|
+
expanded?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface CodeSurfaceProps {
|
|
9
|
+
/** Visible lines to render (may be a window when virtualised). */
|
|
10
|
+
lines: SurfaceLine[];
|
|
11
|
+
/**
|
|
12
|
+
* Total line count used to size the line-number gutter.
|
|
13
|
+
* Often the fully-expanded count, which can differ from `lines.length`
|
|
14
|
+
* when nodes are collapsed.
|
|
15
|
+
*/
|
|
16
|
+
gutterLineCount: number;
|
|
17
|
+
/**
|
|
18
|
+
* Optional per-token colour override. When omitted, syntax colours come from
|
|
19
|
+
* theme CSS variables via {@link CodeSurface.module.css}.
|
|
20
|
+
*/
|
|
21
|
+
tokenColor?: (type: string) => string;
|
|
22
|
+
onToggleCollapse?: (collapseKey: string) => void;
|
|
23
|
+
gutterIcons?: CodeSurfaceGutterIcons;
|
|
24
|
+
indent?: string;
|
|
25
|
+
height?: string;
|
|
26
|
+
maxHeight?: string;
|
|
27
|
+
/** Render detected URLs and emails as clickable links. @default true */
|
|
28
|
+
linkify?: boolean;
|
|
29
|
+
onLinkClick?: (href: string, token: SurfaceToken, event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 1-indexed line numbers on the watchlist (controlled).
|
|
32
|
+
* Pass with `onWatchlistChange` or use `defaultWatchlist` for uncontrolled mode.
|
|
33
|
+
*/
|
|
34
|
+
watchlist?: ReadonlySet<number> | readonly number[];
|
|
35
|
+
/** Initial watchlist when uncontrolled. */
|
|
36
|
+
defaultWatchlist?: readonly number[];
|
|
37
|
+
/** Called when the user toggles a watchlist marker in the gutter. Enables watchlist UI. */
|
|
38
|
+
onWatchlistChange?: (watchlist: Set<number>) => void;
|
|
39
|
+
theme?: CubeTheme;
|
|
40
|
+
/**
|
|
41
|
+
* `embedded` omits border and radius — use when nesting inside a parent shell
|
|
42
|
+
* (e.g. {@link ApiResponseViewer}).
|
|
43
|
+
* @default "default"
|
|
44
|
+
*/
|
|
45
|
+
surfaceVariant?: "default" | "embedded";
|
|
46
|
+
"aria-label"?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function CodeSurface({ lines, gutterLineCount, tokenColor, onToggleCollapse, gutterIcons, indent, height, maxHeight, linkify, onLinkClick, watchlist: watchlistProp, defaultWatchlist, onWatchlistChange, theme, surfaceVariant, "aria-label": ariaLabel, }: CodeSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { CodeSurface } from './CodeSurface';
|
|
3
|
+
declare const meta: Meta<typeof CodeSurface>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof CodeSurface>;
|
|
6
|
+
/** Realistic JSON — URLs/emails in string values are clickable (`linkify` default). */
|
|
7
|
+
export declare const ProjectMetadata: Story;
|
|
8
|
+
/** 5 000 flat lines — windowed rendering */
|
|
9
|
+
export declare const LargeVirtualised: Story;
|
|
10
|
+
/** Collapse toggles in the gutter */
|
|
11
|
+
export declare const WithCollapseToggles: Story;
|
|
12
|
+
/** Click gutter dots to mark lines — watchMark dot when active, watchMarkHover preview on hover. */
|
|
13
|
+
export declare const WithWatchlist: Story;
|
|
14
|
+
/** Partial instance override — swaps surface tokens from the built theme (no ad-hoc hex). */
|
|
15
|
+
export declare const InsetSurfaceOverride: Story;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type CodeViewingDocsFocus = "overview" | "codeBlock" | "jsonCodeView" | "apiResponseViewer";
|
|
2
|
+
export declare function CodeViewingDocsSubtitle({ focus }: {
|
|
3
|
+
focus: CodeViewingDocsFocus;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function CodeViewingArchitectureSection({ focus, }: {
|
|
6
|
+
focus?: CodeViewingDocsFocus;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeSurfaceGutterIcons, CodeSurfaceProps } from './CodeSurface';
|
|
2
|
+
export interface JsonCodeViewProps extends Pick<CodeSurfaceProps, "height" | "maxHeight" | "theme" | "linkify" | "onLinkClick" | "watchlist" | "defaultWatchlist" | "onWatchlistChange" | "indent" | "aria-label" | "surfaceVariant"> {
|
|
3
|
+
/** Any JSON-serialisable value to render as syntax-coloured code lines. */
|
|
4
|
+
data: unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Start with all collapsible nodes collapsed.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
defaultCollapsed?: boolean;
|
|
10
|
+
/** Custom chevron icons for collapse toggles in the gutter. */
|
|
11
|
+
gutterIcons?: CodeSurfaceGutterIcons;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* JSON → tokenized lines → {@link CodeSurface}.
|
|
15
|
+
* Use for API response bodies, debug panels, and large structured payloads.
|
|
16
|
+
*/
|
|
17
|
+
export declare function JsonCodeView({ data, defaultCollapsed, gutterIcons, height, maxHeight, theme, linkify, onLinkClick, watchlist, defaultWatchlist, onWatchlistChange, indent, surfaceVariant, "aria-label": ariaLabel, }: JsonCodeViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { JsonCodeView } from './JsonCodeView';
|
|
3
|
+
declare const meta: Meta<typeof JsonCodeView>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof JsonCodeView>;
|
|
6
|
+
/** Dev-server diagnostics snapshot — all nodes expanded by default */
|
|
7
|
+
export declare const DevServerDiagnostics: Story;
|
|
8
|
+
/** Same snapshot starting fully collapsed — expand sections individually */
|
|
9
|
+
export declare const DevServerCollapsed: Story;
|
|
10
|
+
/** Build output with chunk list — array expand/collapse */
|
|
11
|
+
export declare const BuildOutput: Story;
|
|
12
|
+
/** TypeScript compiler options — nested config object */
|
|
13
|
+
export declare const TypeScriptConfig: Story;
|
|
14
|
+
/** Top-level project metadata — shallow object, includes clickable URLs */
|
|
15
|
+
export declare const ProjectMetadata: Story;
|
|
16
|
+
/** Full viewport height — simulates a page layout slot */
|
|
17
|
+
export declare const FullViewportHeight: Story;
|
|
18
|
+
/** Watchlist gutter — click dots to mark lines */
|
|
19
|
+
export declare const WithWatchlist: Story;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fictional dev-server diagnostics snapshot — package manifest, Vite output,
|
|
3
|
+
* TypeScript config, and ESLint results. All package names and versions are
|
|
4
|
+
* illustrative.
|
|
5
|
+
*/
|
|
6
|
+
declare const devServerDiagnostics: {
|
|
7
|
+
project: {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
private: boolean;
|
|
11
|
+
type: string;
|
|
12
|
+
repository: string;
|
|
13
|
+
license: string;
|
|
14
|
+
engines: {
|
|
15
|
+
node: string;
|
|
16
|
+
npm: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
scripts: {
|
|
20
|
+
dev: string;
|
|
21
|
+
build: string;
|
|
22
|
+
preview: string;
|
|
23
|
+
lint: string;
|
|
24
|
+
"test:unit": string;
|
|
25
|
+
storybook: string;
|
|
26
|
+
};
|
|
27
|
+
devServer: {
|
|
28
|
+
host: string;
|
|
29
|
+
port: number;
|
|
30
|
+
https: boolean;
|
|
31
|
+
open: boolean;
|
|
32
|
+
hmr: {
|
|
33
|
+
protocol: string;
|
|
34
|
+
host: string;
|
|
35
|
+
port: number;
|
|
36
|
+
overlay: boolean;
|
|
37
|
+
};
|
|
38
|
+
config: {
|
|
39
|
+
root: string;
|
|
40
|
+
base: string;
|
|
41
|
+
resolve: {
|
|
42
|
+
alias: {
|
|
43
|
+
"@": string;
|
|
44
|
+
"@theme": string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
server: {
|
|
48
|
+
cors: boolean;
|
|
49
|
+
strictPort: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
build: {
|
|
54
|
+
tool: string;
|
|
55
|
+
duration_ms: number;
|
|
56
|
+
mode: string;
|
|
57
|
+
sourcemap: boolean;
|
|
58
|
+
chunks: {
|
|
59
|
+
file: string;
|
|
60
|
+
size_kb: number;
|
|
61
|
+
modules: number;
|
|
62
|
+
isEntry: boolean;
|
|
63
|
+
}[];
|
|
64
|
+
warnings: string[];
|
|
65
|
+
};
|
|
66
|
+
dependencies: {
|
|
67
|
+
react: string;
|
|
68
|
+
"react-dom": string;
|
|
69
|
+
clsx: string;
|
|
70
|
+
};
|
|
71
|
+
devDependencies: {
|
|
72
|
+
vite: string;
|
|
73
|
+
typescript: string;
|
|
74
|
+
vitest: string;
|
|
75
|
+
eslint: string;
|
|
76
|
+
"@storybook/react-vite": string;
|
|
77
|
+
"@types/react": string;
|
|
78
|
+
};
|
|
79
|
+
typescript: {
|
|
80
|
+
version: string;
|
|
81
|
+
strict: boolean;
|
|
82
|
+
compilerOptions: {
|
|
83
|
+
target: string;
|
|
84
|
+
module: string;
|
|
85
|
+
moduleResolution: string;
|
|
86
|
+
jsx: string;
|
|
87
|
+
noEmit: boolean;
|
|
88
|
+
skipLibCheck: boolean;
|
|
89
|
+
paths: {
|
|
90
|
+
"@/*": string[];
|
|
91
|
+
"@theme/*": string[];
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
diagnostics: {
|
|
95
|
+
errors: number;
|
|
96
|
+
warnings: number;
|
|
97
|
+
files_checked: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
eslint: {
|
|
101
|
+
version: string;
|
|
102
|
+
config: string;
|
|
103
|
+
results: {
|
|
104
|
+
file: string;
|
|
105
|
+
messages: {
|
|
106
|
+
ruleId: string;
|
|
107
|
+
severity: number;
|
|
108
|
+
message: string;
|
|
109
|
+
line: number;
|
|
110
|
+
column: number;
|
|
111
|
+
}[];
|
|
112
|
+
errorCount: number;
|
|
113
|
+
warningCount: number;
|
|
114
|
+
}[];
|
|
115
|
+
summary: {
|
|
116
|
+
errorCount: number;
|
|
117
|
+
warningCount: number;
|
|
118
|
+
fixableWarningCount: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
vitest: {
|
|
122
|
+
version: string;
|
|
123
|
+
environment: string;
|
|
124
|
+
lastRun: string;
|
|
125
|
+
duration_ms: number;
|
|
126
|
+
suites: number;
|
|
127
|
+
tests: number;
|
|
128
|
+
passed: number;
|
|
129
|
+
failed: number;
|
|
130
|
+
skipped: number;
|
|
131
|
+
coverage: {
|
|
132
|
+
lines: number;
|
|
133
|
+
branches: number;
|
|
134
|
+
functions: number;
|
|
135
|
+
statements: number;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
env: {
|
|
139
|
+
NODE_ENV: string;
|
|
140
|
+
VITE_API_BASE_URL: string;
|
|
141
|
+
VITE_ENABLE_MOCKS: string;
|
|
142
|
+
CI: null;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export default devServerDiagnostics;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Sample JavaScript for CodeBlock stories. */
|
|
2
|
+
export declare const sampleJavaScript = "import { fetchUser } from \"./api\";\n\nexport async function loadProfile(userId) {\n // Fetch the latest profile from the API\n const response = await fetchUser(userId);\n\n if (!response.ok) {\n throw new Error(`Failed to load ${userId}`);\n }\n\n return {\n id: response.id,\n name: response.name,\n active: true,\n };\n}\n";
|
|
3
|
+
/** Sample TypeScript for CodeBlock stories. */
|
|
4
|
+
export declare const sampleTypeScript = "export interface UserProfile {\n id: string;\n name: string;\n role: \"admin\" | \"member\";\n}\n\nexport async function getProfile(id: string): Promise<UserProfile | null> {\n const rows = await db.query<UserProfile>(\"SELECT * FROM users WHERE id = $1\", [id]);\n return rows[0] ?? null;\n}\n";
|
|
5
|
+
/** Sample HTML for CodeBlock stories. */
|
|
6
|
+
export declare const sampleHtml = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>Cube Docs</title>\n <link rel=\"stylesheet\" href=\"/theme.css\" />\n </head>\n <body>\n <main class=\"docs\">\n <h1>Welcome</h1>\n <p>Install with <code>npm install @sragatiping/cuboid</code>.</p>\n </main>\n </body>\n</html>\n";
|
|
7
|
+
/** Sample CSS for CodeBlock stories. */
|
|
8
|
+
export declare const sampleCss = ".docs {\n max-width: 48rem;\n margin-inline: auto;\n padding: var(--cube-stack-gap-lg);\n}\n\n.docs h1 {\n color: var(--cube-colors-functional-foreground-default);\n font-size: 1.5rem;\n}\n\n.docs code {\n font-family: var(--cube-typography-text-inline-code-fontFamily);\n background: var(--cube-colors-functional-background-neutral-muted);\n}\n";
|
|
9
|
+
/** Long sample for virtual-scroll demo. */
|
|
10
|
+
export declare function buildLongJavaScript(lineCount?: number): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Fixed row height — must match CodeSurface row styles (1.625rem at 16px root). */
|
|
2
|
+
export declare const CODE_SURFACE_ROW_HEIGHT_PX = 26;
|
|
3
|
+
/** Enable windowed rendering when line count exceeds this in a constrained container. */
|
|
4
|
+
export declare const CODE_SURFACE_VIRTUAL_THRESHOLD = 80;
|
|
5
|
+
/** Extra rows rendered above/below the visible window. */
|
|
6
|
+
export declare const CODE_SURFACE_OVERSCAN = 8;
|
|
7
|
+
export declare const CODE_SURFACE_SCROLL_CLASS = "cube-code-surface-scroll";
|
|
8
|
+
export declare const CODE_SURFACE_SCROLL_STYLE_ID = "cube-code-surface-scroll-styles";
|
|
9
|
+
export declare const CODE_SURFACE_INDENT = "1.5rem";
|
|
10
|
+
export declare const CODE_SURFACE_WATCH_DOT_PX = 6;
|
|
11
|
+
export declare const CODE_SURFACE_SCROLL_CSS = "\n .cube-code-surface-scroll::-webkit-scrollbar { width: 4px; height: 4px; }\n .cube-code-surface-scroll::-webkit-scrollbar-track { background: transparent; }\n .cube-code-surface-scroll::-webkit-scrollbar-thumb {\n background: rgba(0,0,0,0.18);\n border-radius: 3px;\n }\n .cube-code-surface-scroll::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function highlightCss(code: string): import('..').SurfaceLine[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function highlightHtml(code: string): import('..').SurfaceLine[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SurfaceLine } from '../types';
|
|
2
|
+
/** Languages supported by {@link highlightSource}. */
|
|
3
|
+
export type CodeBlockLanguage = "javascript" | "typescript" | "jsx" | "tsx" | "html" | "css" | "text";
|
|
4
|
+
/** Tokenize source text into {@link SurfaceLine}s for {@link CodeSurface}. */
|
|
5
|
+
export declare function highlightSource(code: string, language?: CodeBlockLanguage): SurfaceLine[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function highlightJavaScript(code: string): import('..').SurfaceLine[];
|
|
2
|
+
export declare function highlightTypeScript(code: string): import('..').SurfaceLine[];
|
|
3
|
+
/** JSX/TSX v1 — same rules as JS/TS; tag highlighting comes in a later pass. */
|
|
4
|
+
export declare const highlightJsx: typeof highlightJavaScript;
|
|
5
|
+
export declare const highlightTsx: typeof highlightTypeScript;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SurfaceLine, SurfaceToken } from '../types';
|
|
2
|
+
export interface HighlightState {
|
|
3
|
+
/** True while inside an unclosed block comment (JS/CSS). */
|
|
4
|
+
inBlockComment: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface SourceRule {
|
|
7
|
+
type: string;
|
|
8
|
+
/** Must match from the start of the remaining slice (`^`). */
|
|
9
|
+
pattern: RegExp;
|
|
10
|
+
/** When matched, update highlight state before continuing. */
|
|
11
|
+
onMatch?: (state: HighlightState, value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function coalesceAdjacent(tokens: SurfaceToken[], type: string): SurfaceToken[];
|
|
14
|
+
export declare function tokenizeLine(line: string, rules: SourceRule[], state: HighlightState): SurfaceToken[];
|
|
15
|
+
export declare function linesFromSource(code: string, highlightLine: (line: string, state: HighlightState) => SurfaceToken[]): SurfaceLine[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { CodeSurface } from './CodeSurface';
|
|
2
|
+
export type { CodeSurfaceProps, CodeSurfaceGutterIcons } from './CodeSurface';
|
|
3
|
+
export { CodeBlock } from './CodeBlock';
|
|
4
|
+
export type { CodeBlockProps } from './CodeBlock';
|
|
5
|
+
export { JsonCodeView } from './JsonCodeView';
|
|
6
|
+
export type { JsonCodeViewProps } from './JsonCodeView';
|
|
7
|
+
export { highlightSource } from './highlight';
|
|
8
|
+
export type { CodeBlockLanguage } from './highlight';
|
|
9
|
+
export { buildLines, getAllCollapsiblePaths, } from './tokenizer';
|
|
10
|
+
export type { CodeLine, Token, TokenType } from './tokenizer';
|
|
11
|
+
export type { SurfaceLine, SurfaceToken } from './types';
|
|
12
|
+
export { CODE_SURFACE_ROW_HEIGHT_PX, CODE_SURFACE_VIRTUAL_THRESHOLD, } from './constants';
|
|
13
|
+
export { annotateBracketDepth, BRACKET_DEPTH_CYCLE, classifyJsonString, isLinkifiableTokenType, JSON_STRING_EMAIL_PATTERN, JSON_STRING_URL_PATTERN, jsonTokenColor, JSON_SYNTAX_TOKEN, linkHrefForSurfaceToken, syntaxCssVar, syntaxTokenClass, unquoteJsonStringLiteral, } from './syntax';
|
|
14
|
+
export type { JsonClassifiedStringType, JsonSyntaxKey, JsonSyntaxTokenType, } from './syntax';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SyntaxColors } from '../../theme/types';
|
|
2
|
+
import { SurfaceLine, SurfaceToken } from './types';
|
|
3
|
+
export type JsonSyntaxKey = keyof SyntaxColors | "foregroundMuted";
|
|
4
|
+
export declare const JSON_SYNTAX_TOKEN: {
|
|
5
|
+
readonly key: "key";
|
|
6
|
+
readonly string: "string";
|
|
7
|
+
readonly string_url: "stringUrl";
|
|
8
|
+
readonly string_email: "stringEmail";
|
|
9
|
+
readonly string_uuid: "stringUuid";
|
|
10
|
+
readonly number: "numberLiteral";
|
|
11
|
+
readonly boolean: "booleanLiteral";
|
|
12
|
+
readonly null: "nullLiteral";
|
|
13
|
+
readonly bracket: "bracket";
|
|
14
|
+
readonly operator: "foregroundMuted";
|
|
15
|
+
readonly punctuation: "foregroundMuted";
|
|
16
|
+
readonly ellipsis: "foregroundMuted";
|
|
17
|
+
};
|
|
18
|
+
export type JsonSyntaxTokenType = keyof typeof JSON_SYNTAX_TOKEN;
|
|
19
|
+
export declare function syntaxCssVar(key: Exclude<JsonSyntaxKey, "foregroundMuted">): string;
|
|
20
|
+
/** Inline colour fallback when `tokenColor` prop is used (default path uses CSS classes). */
|
|
21
|
+
export declare function jsonTokenColor(type: string, syntax: SyntaxColors, mutedForeground: string): string;
|
|
22
|
+
/** Cycle length for alternating bracket colours (maps to `.tokenBracketDepthN` in CSS). */
|
|
23
|
+
export declare const BRACKET_DEPTH_CYCLE = 2;
|
|
24
|
+
/**
|
|
25
|
+
* Assign `bracketDepth` on each delimiter. Run on the full line list before
|
|
26
|
+
* virtual scroll slicing so depth stays correct across the file.
|
|
27
|
+
*/
|
|
28
|
+
export declare function annotateBracketDepth(lines: SurfaceLine[]): SurfaceLine[];
|
|
29
|
+
export declare function syntaxTokenClass(token: SurfaceToken | string): string;
|
|
30
|
+
/** Classified JSON string value token types. */
|
|
31
|
+
export type JsonClassifiedStringType = "string" | "string_url" | "string_email" | "string_uuid";
|
|
32
|
+
export declare const JSON_STRING_URL_PATTERN: RegExp;
|
|
33
|
+
export declare const JSON_STRING_EMAIL_PATTERN: RegExp;
|
|
34
|
+
export declare function classifyJsonString(raw: string): JsonClassifiedStringType;
|
|
35
|
+
export declare function unquoteJsonStringLiteral(display: string): string;
|
|
36
|
+
export declare function isLinkifiableTokenType(type: string): boolean;
|
|
37
|
+
export declare function linkHrefForSurfaceToken(token: Pick<SurfaceToken, "type" | "value">): string | undefined;
|
|
@@ -31,11 +31,6 @@ export interface CodeLine {
|
|
|
31
31
|
* Drives which chevron is rendered (▶ vs ▼).
|
|
32
32
|
*/
|
|
33
33
|
isCollapsed?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* "summary" rows are the `… N lines` placeholder emitted between the opening
|
|
36
|
-
* and closing bracket of a collapsed node. Rendered with a muted highlight.
|
|
37
|
-
*/
|
|
38
|
-
kind?: "summary";
|
|
39
34
|
}
|
|
40
35
|
/**
|
|
41
36
|
* Build the full list of visible CodeLines for the given data and collapse state.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language-agnostic line model for CodeSurface.
|
|
3
|
+
* Producers (JsonCodeView {@link buildLines}, CodeBlock highlighters) build these;
|
|
4
|
+
* CodeSurface only renders them.
|
|
5
|
+
*/
|
|
6
|
+
export interface SurfaceToken {
|
|
7
|
+
type: string;
|
|
8
|
+
value: string;
|
|
9
|
+
/**
|
|
10
|
+
* Nesting index for `{ } [ ] ( )` — set by {@link annotateBracketDepth} in `./syntax`.
|
|
11
|
+
* Drives alternating bracket colours in CodeSurface.
|
|
12
|
+
*/
|
|
13
|
+
bracketDepth?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SurfaceLine {
|
|
16
|
+
/** 1-indexed line number shown in the gutter. */
|
|
17
|
+
lineNumber: number;
|
|
18
|
+
/** Nesting depth — drives visual indentation. */
|
|
19
|
+
depth: number;
|
|
20
|
+
tokens: SurfaceToken[];
|
|
21
|
+
/**
|
|
22
|
+
* When set, the gutter shows a collapse toggle for this line.
|
|
23
|
+
* The parent passes `onToggleCollapse` to handle clicks.
|
|
24
|
+
*/
|
|
25
|
+
collapseKey?: string;
|
|
26
|
+
isCollapsed?: boolean;
|
|
27
|
+
}
|
|
@@ -1,50 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
defaultCollapsed?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Replace the built-in chevron icons with your own SVG components.
|
|
14
|
-
* You are responsible for sizing and coloring them.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* import { ChevronRight, ChevronDown } from "lucide-react";
|
|
19
|
-
*
|
|
20
|
-
* <CodeSnippet
|
|
21
|
-
* data={data}
|
|
22
|
-
* icons={{
|
|
23
|
-
* collapsed: <ChevronRight size={16} />,
|
|
24
|
-
* expanded: <ChevronDown size={16} />,
|
|
25
|
-
* }}
|
|
26
|
-
* />
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
icons?: {
|
|
30
|
-
/** Shown when the node is collapsed. Defaults to a Material Design ChevronRight. */
|
|
31
|
-
collapsed?: React.ReactNode;
|
|
32
|
-
/** Shown when the node is expanded. Defaults to a Material Design ExpandMore. */
|
|
33
|
-
expanded?: React.ReactNode;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Fix the component to an exact height — content scrolls inside.
|
|
37
|
-
* Accepts any valid CSS value (e.g. "400px", "50vh", "20rem").
|
|
38
|
-
*/
|
|
39
|
-
height?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Cap the component height — content scrolls only when it exceeds this value.
|
|
42
|
-
* Accepts any valid CSS value (e.g. "400px", "50vh", "20rem").
|
|
43
|
-
*/
|
|
44
|
-
maxHeight?: string;
|
|
45
|
-
/** Override any theme tokens for this instance */
|
|
46
|
-
theme?: CubeTheme;
|
|
47
|
-
/** Accessible label for the code region */
|
|
48
|
-
"aria-label"?: string;
|
|
49
|
-
}
|
|
50
|
-
export declare function CodeSnippet({ data, defaultCollapsed, icons, height, maxHeight, theme, "aria-label": ariaLabel, }: CodeSnippetProps): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { JsonCodeViewProps } from '../CodeBlock/JsonCodeView';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use {@link JsonCodeView} from `@sragatiping/cuboid` / `components/CodeBlock`.
|
|
4
|
+
*/
|
|
5
|
+
export type CodeSnippetProps = JsonCodeViewProps;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use {@link JsonCodeView} — JSON data + collapse → {@link CodeSurface}.
|
|
8
|
+
*/
|
|
9
|
+
export declare function CodeSnippet(props: CodeSnippetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ export interface JsonViewerProps {
|
|
|
9
9
|
theme?: CubeTheme;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Top-level component that toggles between
|
|
12
|
+
* Top-level component that toggles between JsonCodeView and DataGrid views.
|
|
13
13
|
* Toggle UI and wiring TBD — requirements coming soon.
|
|
14
14
|
*/
|
|
15
15
|
export declare function JsonViewer({ data, defaultMode }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { StackProps } from '../Stack';
|
|
3
|
+
import { BoxBackground, BoxBorder, BoxBorderRadius, BoxForeground, BoxOverflow } from './boxTypes';
|
|
4
|
+
export type { BoxBackground, BoxBorder, BoxBorderRadius, BoxForeground, BoxOverflow, } from './boxTypes';
|
|
5
|
+
export interface BoxProps extends StackProps {
|
|
6
|
+
/** Functional background role. */
|
|
7
|
+
background?: BoxBackground;
|
|
8
|
+
/** Border style — `none` (default), `default`, or `muted`. */
|
|
9
|
+
border?: BoxBorder;
|
|
10
|
+
/** Corner radius from `sizes.borderRadius`. */
|
|
11
|
+
borderRadius?: BoxBorderRadius;
|
|
12
|
+
/** Shorthand overflow — use `overflowX` / `overflowY` in `style` to override an axis. */
|
|
13
|
+
overflow?: BoxOverflow;
|
|
14
|
+
/** Functional foreground role for inherited text colour. */
|
|
15
|
+
foreground?: BoxForeground;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generic styled surface + flex layout primitive.
|
|
19
|
+
*
|
|
20
|
+
* Surface styles use global `--cube-*` tokens via CSS module modifiers (same
|
|
21
|
+
* pattern as {@link Button}). Local `theme` overrides re-bind those `--cube-*`
|
|
22
|
+
* names on this element only.
|
|
23
|
+
*/
|
|
24
|
+
export declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Box } from './Box';
|
|
3
|
+
declare const meta: Meta<typeof Box>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Box>;
|
|
6
|
+
export declare const Playground: Story;
|
|
7
|
+
export declare const InsetSurface: Story;
|
|
8
|
+
export declare const HorizontalLayout: Story;
|
|
9
|
+
export declare const NestedInStack: Story;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BackgroundColors, BorderRadiusTokens, ForegroundColors } from '../../../theme/types';
|
|
2
|
+
export type BoxBackground = Exclude<keyof BackgroundColors, "neutral"> | "neutralMuted" | "neutralEmphasis";
|
|
3
|
+
export type BoxBorder = "none" | "default" | "muted";
|
|
4
|
+
export type BoxBorderRadius = keyof BorderRadiusTokens;
|
|
5
|
+
export type BoxForeground = keyof ForegroundColors;
|
|
6
|
+
export type BoxOverflow = "visible" | "hidden" | "auto" | "scroll";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme, GlobalColorPath } from '../../../theme/types';
|
|
3
|
+
export type { GlobalColorPath as CalloutBackground };
|
|
4
|
+
export interface CalloutProps {
|
|
5
|
+
/**
|
|
6
|
+
* Surface color from `colors.global` (dot-path), or any CSS color string.
|
|
7
|
+
* @default "canvas.inset"
|
|
8
|
+
* @example "canvas.inset" | "bg.gray.light.02" | "#eef6ff"
|
|
9
|
+
*/
|
|
10
|
+
background?: GlobalColorPath;
|
|
11
|
+
theme?: CubeTheme;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/** Inset block for blockquotes, notes, and asides. */
|
|
17
|
+
export declare function Callout({ background, theme, className, style, children, }: CalloutProps): import("react/jsx-runtime").JSX.Element;
|