@sragatiping/cuboid 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.
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +50 -0
- package/dist/components/CodeSnippet/CodeSnippet.stories.d.ts +17 -0
- package/dist/components/CodeSnippet/__fixtures__/device-profile-report.d.ts +422 -0
- package/dist/components/CodeSnippet/index.d.ts +2 -0
- package/dist/components/CodeSnippet/tokenizer.d.ts +49 -0
- package/dist/components/DataGrid/DataGrid.d.ts +11 -0
- package/dist/components/DataGrid/index.d.ts +2 -0
- package/dist/components/Graph/GraphCanvas.d.ts +15 -0
- package/dist/components/Graph/GraphCanvas.stories.d.ts +20 -0
- package/dist/components/Graph/GraphCard.d.ts +31 -0
- package/dist/components/Graph/GraphEdge.d.ts +27 -0
- package/dist/components/Graph/GraphHandle.d.ts +16 -0
- package/dist/components/Graph/GraphRow.d.ts +14 -0
- package/dist/components/Graph/context.d.ts +36 -0
- package/dist/components/Graph/index.d.ts +10 -0
- package/dist/components/JsonGraph/DeviceProfileReport.stories.d.ts +11 -0
- package/dist/components/JsonGraph/JsonCardTitle.d.ts +12 -0
- package/dist/components/JsonGraph/JsonFieldRow.d.ts +15 -0
- package/dist/components/JsonGraph/JsonGraph.stories.d.ts +19 -0
- package/dist/components/JsonGraph/JsonInputHandle.d.ts +30 -0
- package/dist/components/JsonGraph/JsonObjectRow.d.ts +22 -0
- package/dist/components/JsonGraph/index.d.ts +8 -0
- package/dist/components/JsonGraph/treeLayout.d.ts +114 -0
- package/dist/components/JsonViewer/JsonViewer.d.ts +15 -0
- package/dist/components/JsonViewer/index.d.ts +2 -0
- package/dist/components/core/ActionMenu/ActionMenu.d.ts +28 -0
- package/dist/components/core/ActionMenu/ActionMenu.stories.d.ts +10 -0
- package/dist/components/core/ActionMenu/ActionMenuItem.d.ts +22 -0
- package/dist/components/core/ActionMenu/ActionMenuList.d.ts +32 -0
- package/dist/components/core/ActionMenu/actionMenuCssVars.d.ts +2 -0
- package/dist/components/core/ActionMenu/actionMenuKeyboard.d.ts +4 -0
- package/dist/components/core/ActionMenu/index.d.ts +6 -0
- package/dist/components/core/Breadcrumb/BreadcrumbLink.d.ts +12 -0
- package/dist/components/core/Breadcrumb/Breadcrumbs.d.ts +13 -0
- package/dist/components/core/Breadcrumb/Breadcrumbs.stories.d.ts +6 -0
- package/dist/components/core/Breadcrumb/index.d.ts +4 -0
- package/dist/components/core/Button/Button.d.ts +22 -0
- package/dist/components/core/Button/Button.stories.d.ts +6 -0
- package/dist/components/core/Button/index.d.ts +2 -0
- package/dist/components/core/Icon/Icon.d.ts +13 -0
- package/dist/components/core/Icon/Icon.stories.d.ts +6 -0
- package/dist/components/core/Icon/index.d.ts +2 -0
- package/dist/components/core/IconButton/IconButton.d.ts +28 -0
- package/dist/components/core/IconButton/IconButton.stories.d.ts +6 -0
- package/dist/components/core/IconButton/index.d.ts +3 -0
- package/dist/components/core/Link/Link.d.ts +18 -0
- package/dist/components/core/Link/Link.stories.d.ts +6 -0
- package/dist/components/core/Link/index.d.ts +2 -0
- package/dist/components/core/Overlay/Overlay.d.ts +21 -0
- package/dist/components/core/Overlay/Overlay.stories.d.ts +10 -0
- package/dist/components/core/Overlay/index.d.ts +2 -0
- package/dist/components/core/Pill/Pill.d.ts +25 -0
- package/dist/components/core/Pill/Pill.stories.d.ts +6 -0
- package/dist/components/core/Pill/index.d.ts +3 -0
- package/dist/components/core/Popover/Popover.d.ts +39 -0
- package/dist/components/core/Popover/Popover.stories.d.ts +10 -0
- package/dist/components/core/Popover/index.d.ts +2 -0
- package/dist/components/core/ResizeHandle/ResizeHandle.d.ts +21 -0
- package/dist/components/core/ResizeHandle/index.d.ts +2 -0
- package/dist/components/core/Sheet/Sheet.d.ts +55 -0
- package/dist/components/core/Sheet/Sheet.stories.d.ts +14 -0
- package/dist/components/core/Sheet/index.d.ts +4 -0
- package/dist/components/core/Sidebar/Sidebar.d.ts +68 -0
- package/dist/components/core/Sidebar/Sidebar.stories.d.ts +11 -0
- package/dist/components/core/Sidebar/index.d.ts +2 -0
- package/dist/components/core/Sidebar/sidebarCssVars.d.ts +2 -0
- package/dist/components/core/SiteHeader/SiteHeader.d.ts +17 -0
- package/dist/components/core/SiteHeader/SiteHeader.stories.d.ts +6 -0
- package/dist/components/core/SiteHeader/index.d.ts +2 -0
- package/dist/components/core/SplitLayout/SplitLayout.d.ts +24 -0
- package/dist/components/core/SplitLayout/SplitLayout.stories.d.ts +6 -0
- package/dist/components/core/SplitLayout/index.d.ts +2 -0
- package/dist/components/core/Stack/Stack.d.ts +43 -0
- package/dist/components/core/Stack/Stack.stories.d.ts +15 -0
- package/dist/components/core/Stack/index.d.ts +3 -0
- package/dist/components/core/Text/Text.d.ts +29 -0
- package/dist/components/core/Text/Text.stories.d.ts +8 -0
- package/dist/components/core/Text/index.d.ts +2 -0
- package/dist/components/core/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/core/Tooltip/Tooltip.stories.d.ts +10 -0
- package/dist/components/core/Tooltip/index.d.ts +2 -0
- package/dist/components/core/index.d.ts +34 -0
- package/dist/icons/Icons.stories.d.ts +6 -0
- package/dist/icons/index.d.ts +13 -0
- package/dist/icons/manifest.json.d.ts +2489 -0
- package/dist/icons/material/config.d.ts +4 -0
- package/dist/icons/material/createMaterialIcon.d.ts +7 -0
- package/dist/icons/material/index.d.ts +231 -0
- package/dist/icons/material/source.d.ts +220 -0
- package/dist/index.cjs.js +10 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.es.js +8135 -0
- package/dist/index.es.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/theme/ThemeContext.d.ts +20 -0
- package/dist/theme/defaultTheme.d.ts +2 -0
- package/dist/theme/figma/buildFigmaTheme.d.ts +7 -0
- package/dist/theme/output/base.json.d.ts +208 -0
- package/dist/theme/output/theme.json.d.ts +1898 -0
- package/dist/theme/types.d.ts +610 -0
- package/dist/theme/utils.d.ts +6 -0
- package/dist/utils/flattenJson.d.ts +18 -0
- package/dist/utils/parseLengthPx.d.ts +2 -0
- package/dist/utils/responsive.d.ts +8 -0
- package/package.json +71 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
export interface GraphRowProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A row inside a GraphCard.
|
|
9
|
+
*
|
|
10
|
+
* position: relative so a GraphHandle placed inside this row can use
|
|
11
|
+
* position: absolute to anchor itself to the row's left or right edge,
|
|
12
|
+
* vertically centred at the row's midpoint.
|
|
13
|
+
*/
|
|
14
|
+
export declare function GraphRow({ children, style, className }: GraphRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/** A position in canvas space (same coordinate system as card x/y props). */
|
|
3
|
+
export interface HandlePos {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* All registered handle positions keyed by "nodeId:handleId".
|
|
9
|
+
* Read by GraphEdge to know where to draw bezier endpoints.
|
|
10
|
+
*/
|
|
11
|
+
export type HandleRegistry = Record<string, HandlePos>;
|
|
12
|
+
export interface CanvasContextValue {
|
|
13
|
+
/** Ref to the outermost viewport div — used for coordinate conversion. */
|
|
14
|
+
viewportRef: RefObject<HTMLDivElement | null>;
|
|
15
|
+
/** Ref to the SVG element — GraphEdge portals paths into this. */
|
|
16
|
+
svgRef: RefObject<SVGSVGElement | null>;
|
|
17
|
+
/** Current pan offset in pixels. */
|
|
18
|
+
panX: number;
|
|
19
|
+
panY: number;
|
|
20
|
+
/** Current zoom level (1 = 100%). */
|
|
21
|
+
zoom: number;
|
|
22
|
+
/** All currently registered handle positions (canvas space). */
|
|
23
|
+
handles: HandleRegistry;
|
|
24
|
+
/** Called by GraphHandle on mount to publish its canvas-space position. */
|
|
25
|
+
registerHandle: (key: string, pos: HandlePos) => void;
|
|
26
|
+
/** Called by GraphHandle on unmount. */
|
|
27
|
+
unregisterHandle: (key: string) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare const CanvasContext: import('react').Context<CanvasContextValue | null>;
|
|
30
|
+
export declare function useCanvasContext(): CanvasContextValue;
|
|
31
|
+
export interface CardContextValue {
|
|
32
|
+
/** The id passed to <GraphCard id="…"> */
|
|
33
|
+
cardId: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const CardContext: import('react').Context<CardContextValue | null>;
|
|
36
|
+
export declare function useCardContext(): CardContextValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { GraphCanvas } from './GraphCanvas';
|
|
2
|
+
export { GraphCard } from './GraphCard';
|
|
3
|
+
export { GraphRow } from './GraphRow';
|
|
4
|
+
export { GraphHandle } from './GraphHandle';
|
|
5
|
+
export { GraphEdge } from './GraphEdge';
|
|
6
|
+
export type { GraphCanvasProps } from './GraphCanvas';
|
|
7
|
+
export type { GraphCardProps } from './GraphCard';
|
|
8
|
+
export type { GraphRowProps } from './GraphRow';
|
|
9
|
+
export type { GraphHandleProps, HandleSide } from './GraphHandle';
|
|
10
|
+
export type { GraphEdgeProps, EdgeEndpoint } from './GraphEdge';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
/**
|
|
3
|
+
* Real-world graph built from the fictional NexusGuard device-profile report.
|
|
4
|
+
*
|
|
5
|
+
* Card positions are computed by `treeLayout` — no manual coordinate maths here.
|
|
6
|
+
* Each `rowCount` is: 1 title + number of field rows + number of object rows.
|
|
7
|
+
*/
|
|
8
|
+
declare const meta: Meta;
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj;
|
|
11
|
+
export declare const DeviceProfileReport: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
export interface JsonCardTitleProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Semi-bold card heading. Theme defaults, fully overrideable via `style`.
|
|
8
|
+
*
|
|
9
|
+
* Sets `position: relative` so a `JsonInputHandle` placed inside it can
|
|
10
|
+
* anchor itself to the title row's left edge rather than the card's midpoint.
|
|
11
|
+
*/
|
|
12
|
+
export declare function JsonCardTitle({ children, style }: JsonCardTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface JsonFieldRowProps {
|
|
3
|
+
/** The field key — rendered in `foreground.default`. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The field value — rendered in `foreground.muted`. */
|
|
6
|
+
value: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A key + value pair row.
|
|
11
|
+
*
|
|
12
|
+
* Key is in `foreground.default`, value in `foreground.muted`.
|
|
13
|
+
* 8px gap separates key from value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function JsonFieldRow({ label, value, style }: JsonFieldRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
/**
|
|
3
|
+
* JsonGraph — JSON-specific content layer on top of the generic Graph primitives.
|
|
4
|
+
*
|
|
5
|
+
* `GraphCard` provides the canvas positioning, themed shell (border, shadow,
|
|
6
|
+
* padding, gap). The Json* components define *what goes inside*:
|
|
7
|
+
*
|
|
8
|
+
* - `JsonCardTitle` — card heading
|
|
9
|
+
* - `JsonFieldRow` — primitive key + value pair
|
|
10
|
+
* - `JsonObjectRow` — nested-object link row with inset background and a handle slot
|
|
11
|
+
*
|
|
12
|
+
* Consumers compose these freely inside any `GraphCard`. Themes are inherited
|
|
13
|
+
* from the nearest `ThemeProvider`.
|
|
14
|
+
*/
|
|
15
|
+
declare const meta: Meta;
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj;
|
|
18
|
+
export declare const TwoCards: Story;
|
|
19
|
+
export declare const ThreeCards: Story;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface JsonInputHandleProps {
|
|
2
|
+
/** Handle id — must be unique within the card. Edge references: "cardId:handleId". */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Inner dot fill colour. Defaults to the theme's blue accent. */
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An input handle pre-positioned for use inside `<JsonCardTitle>`.
|
|
9
|
+
*
|
|
10
|
+
* Place it as the **first child** of `<JsonCardTitle>` and it will sit on
|
|
11
|
+
* the card's left outer edge, vertically centred with the title text:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <GraphCard id="email" x={x} y={y}>
|
|
15
|
+
* <JsonCardTitle>
|
|
16
|
+
* <JsonInputHandle id="in" />
|
|
17
|
+
* Email Details
|
|
18
|
+
* </JsonCardTitle>
|
|
19
|
+
* <JsonFieldRow label="email" value="user@example.com" />
|
|
20
|
+
* </GraphCard>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ### Why the negative left offset?
|
|
24
|
+
* `JsonCardTitle` is inside `GraphCard` which has `padding: space[3]` (12px).
|
|
25
|
+
* An absolutely-positioned element at `left: 0` inside `JsonCardTitle` would
|
|
26
|
+
* sit 12px in from the card's outer edge. The `calc(-1 * space[3])` offset
|
|
27
|
+
* cancels the card padding so the handle protrudes from the card's true left
|
|
28
|
+
* border — consistent with handles on `GraphRow` object rows.
|
|
29
|
+
*/
|
|
30
|
+
export declare function JsonInputHandle({ id, color }: JsonInputHandleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
export interface JsonObjectRowProps {
|
|
3
|
+
/**
|
|
4
|
+
* The field key that links to a nested object or array card.
|
|
5
|
+
* Rendered as plain text — the row's inset background signals it's a link.
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* Slot for a `<GraphHandle side="right" />`.
|
|
10
|
+
* The row reserves right-padding automatically so the dot doesn't overlap text.
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A row that represents a link to a nested object or array card.
|
|
17
|
+
*
|
|
18
|
+
* Uses `base.gray[0]` (canvas/inset) background to visually distinguish
|
|
19
|
+
* nested-object rows from plain key-value rows. Place a `<GraphHandle>`
|
|
20
|
+
* as children to attach an edge to the target card.
|
|
21
|
+
*/
|
|
22
|
+
export declare function JsonObjectRow({ label, children, style }: JsonObjectRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { JsonCardTitle } from './JsonCardTitle';
|
|
2
|
+
export { JsonFieldRow } from './JsonFieldRow';
|
|
3
|
+
export { JsonObjectRow } from './JsonObjectRow';
|
|
4
|
+
export { JsonInputHandle } from './JsonInputHandle';
|
|
5
|
+
export type { JsonCardTitleProps } from './JsonCardTitle';
|
|
6
|
+
export type { JsonFieldRowProps } from './JsonFieldRow';
|
|
7
|
+
export type { JsonObjectRowProps } from './JsonObjectRow';
|
|
8
|
+
export type { JsonInputHandleProps } from './JsonInputHandle';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure tree-layout utilities — no React, no DOM.
|
|
3
|
+
*
|
|
4
|
+
* Two layout strategies, both placing cards left-to-right without overlaps:
|
|
5
|
+
*
|
|
6
|
+
* `treeLayout` — centres each parent over its children group.
|
|
7
|
+
* Good for balanced/symmetric trees.
|
|
8
|
+
*
|
|
9
|
+
* `topAnchoredLayout` — anchors each child's y to the top edge of the
|
|
10
|
+
* object-row handle that connects to it in the parent.
|
|
11
|
+
* Edges always flow left → down-right (never upward).
|
|
12
|
+
* Good for JSON objects where reading order matters.
|
|
13
|
+
*
|
|
14
|
+
* Card height formula (shared):
|
|
15
|
+
* height = cardPadding + rowCount × rowHeight + (rowCount − 1) × rowGap
|
|
16
|
+
*/
|
|
17
|
+
export interface LayoutOptions {
|
|
18
|
+
/** Horizontal distance between column left-edges. Default: 420 */
|
|
19
|
+
columnWidth?: number;
|
|
20
|
+
/** Vertical gap between sibling cards in the same column. Default: 24 */
|
|
21
|
+
siblingGap?: number;
|
|
22
|
+
/** Card top + bottom padding combined (= GraphCard `padding × 2`). Default: 24 */
|
|
23
|
+
cardPadding?: number;
|
|
24
|
+
/** Approximate height of one row in pixels. Default: 29 */
|
|
25
|
+
rowHeight?: number;
|
|
26
|
+
/** Gap between rows inside a card (= GraphCard `gap`). Default: 4 */
|
|
27
|
+
rowGap?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface CardPosition {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
33
|
+
export interface LayoutNode {
|
|
34
|
+
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Total rows in this card — title + field rows + object rows.
|
|
37
|
+
* All row types are treated as the same height for layout purposes.
|
|
38
|
+
*/
|
|
39
|
+
rowCount: number;
|
|
40
|
+
/** IDs of child cards, top-to-bottom order. */
|
|
41
|
+
children?: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface AnchoredChild {
|
|
44
|
+
id: string;
|
|
45
|
+
/**
|
|
46
|
+
* 0-based index of the object-row in the parent card that connects to this
|
|
47
|
+
* child. Count from the top: title = 0, first row = 1, etc.
|
|
48
|
+
*
|
|
49
|
+
* The child card is placed so its top-left corner aligns with (or is below)
|
|
50
|
+
* the top edge of this row, creating a left→down-right edge flow.
|
|
51
|
+
*/
|
|
52
|
+
handleRowIndex: number;
|
|
53
|
+
}
|
|
54
|
+
export interface AnchoredLayoutNode {
|
|
55
|
+
id: string;
|
|
56
|
+
/** Total rows in this card — title + field rows + object rows. */
|
|
57
|
+
rowCount: number;
|
|
58
|
+
children?: AnchoredChild[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Computes non-overlapping canvas positions for a tree of cards.
|
|
62
|
+
*
|
|
63
|
+
* @param nodes All nodes in the tree (any order).
|
|
64
|
+
* @param rootId ID of the root node to start layout from.
|
|
65
|
+
* @param options Visual tuning — defaults match GraphCard / JsonFieldRow tokens.
|
|
66
|
+
* @returns `Map<id, { x, y }>` — canvas-space positions ready to pass
|
|
67
|
+
* as `x` / `y` props to `<GraphCard>`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const pos = treeLayout([
|
|
72
|
+
* { id: "root", rowCount: 8, children: ["data", "key"] },
|
|
73
|
+
* { id: "data", rowCount: 13, children: ["battery", "ng"] },
|
|
74
|
+
* { id: "key", rowCount: 9 },
|
|
75
|
+
* { id: "battery", rowCount: 3 },
|
|
76
|
+
* { id: "ng", rowCount: 8 },
|
|
77
|
+
* ], "root");
|
|
78
|
+
*
|
|
79
|
+
* const at = (id: string) => pos.get(id)!;
|
|
80
|
+
* // <GraphCard id="root" x={at("root").x} y={at("root").y}>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function treeLayout(nodes: LayoutNode[], rootId: string, options?: LayoutOptions): Map<string, CardPosition>;
|
|
84
|
+
/**
|
|
85
|
+
* Computes canvas positions for a tree where each child is anchored to the
|
|
86
|
+
* top edge of the parent object-row that connects to it.
|
|
87
|
+
*
|
|
88
|
+
* This means edges always flow left → down-right: the bezier leaves the
|
|
89
|
+
* parent handle at row N and arrives at the child card which starts at or
|
|
90
|
+
* below that same y. Reading order (top-to-bottom) is preserved.
|
|
91
|
+
*
|
|
92
|
+
* A per-column `nextY` cursor prevents cards in the same column from
|
|
93
|
+
* overlapping when a previous subtree pushes them further down.
|
|
94
|
+
*
|
|
95
|
+
* @param nodes All nodes in the tree.
|
|
96
|
+
* @param rootId ID of the root node.
|
|
97
|
+
* @param options Visual tuning — same defaults as `treeLayout`.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const pos = topAnchoredLayout([
|
|
102
|
+
* { id: "root", rowCount: 8, children: [
|
|
103
|
+
* { id: "data", handleRowIndex: 6 }, // 6th row in root card
|
|
104
|
+
* { id: "key", handleRowIndex: 7 },
|
|
105
|
+
* ]},
|
|
106
|
+
* { id: "data", rowCount: 13, children: [
|
|
107
|
+
* { id: "battery", handleRowIndex: 10 },
|
|
108
|
+
* ]},
|
|
109
|
+
* { id: "key", rowCount: 9 },
|
|
110
|
+
* { id: "battery", rowCount: 3 },
|
|
111
|
+
* ], "root");
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function topAnchoredLayout(nodes: AnchoredLayoutNode[], rootId: string, options?: LayoutOptions): Map<string, CardPosition>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CubeTheme } from '../../theme/types';
|
|
2
|
+
export type JsonViewerMode = "table" | "code";
|
|
3
|
+
export interface JsonViewerProps {
|
|
4
|
+
/** The JSON data to display */
|
|
5
|
+
data: unknown;
|
|
6
|
+
/** Which view to start in (defaults to "code") */
|
|
7
|
+
defaultMode?: JsonViewerMode;
|
|
8
|
+
/** Override any theme tokens for this instance */
|
|
9
|
+
theme?: CubeTheme;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Top-level component that toggles between CodeSnippet and DataGrid views.
|
|
13
|
+
* Toggle UI and wiring TBD — requirements coming soon.
|
|
14
|
+
*/
|
|
15
|
+
export declare function JsonViewer({ data, defaultMode }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PopoverElevation, PopoverPlacement } from '../Popover';
|
|
3
|
+
import { CubeTheme } from '../../../theme/types';
|
|
4
|
+
export interface ActionMenuProps {
|
|
5
|
+
/** Anchor control — `Button`, `IconButton`, etc. */
|
|
6
|
+
trigger: React.ReactElement;
|
|
7
|
+
/** Menu rows and optional `ActionMenuList.*` regions. */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
placement?: PopoverPlacement;
|
|
12
|
+
elevation?: PopoverElevation;
|
|
13
|
+
/** Close after a menu item is activated. @default true */
|
|
14
|
+
closeOnSelect?: boolean;
|
|
15
|
+
/** Accessible name when the menu has no visible title. */
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
/** id of an element that labels the menu. */
|
|
18
|
+
"aria-labelledby"?: string;
|
|
19
|
+
theme?: CubeTheme;
|
|
20
|
+
className?: string;
|
|
21
|
+
listClassName?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Composed dropdown menu — Figma `ActionMenu`.
|
|
25
|
+
*
|
|
26
|
+
* Wires trigger + `Popover` + `ActionMenuList` with menu keyboard support.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ActionMenu({ trigger, children, open: openProp, onOpenChange, placement, elevation, closeOnSelect, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, theme, className, listClassName, }: ActionMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ActionMenu } from './ActionMenu';
|
|
3
|
+
declare const meta: Meta<typeof ActionMenu>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof ActionMenu>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Controlled: Story;
|
|
8
|
+
export declare const WithSections: Story;
|
|
9
|
+
export declare const WithHeaderAndFooter: Story;
|
|
10
|
+
export declare const ListOnly: Story;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
export interface ActionMenuItemProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
subtext?: React.ReactNode;
|
|
6
|
+
subtextIcon?: React.ReactNode;
|
|
7
|
+
/** Marks the current selection — shows trailing checkmark by default. */
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
/** @default true when `selected` */
|
|
10
|
+
showSelectionCheck?: boolean;
|
|
11
|
+
leadingIcon?: React.ReactNode;
|
|
12
|
+
/** Icon-only row — hides the label; use `aria-label` or string `children` for the accessible name. */
|
|
13
|
+
iconOnly?: boolean;
|
|
14
|
+
/** Renders a trailing chevron for submenu affordance. */
|
|
15
|
+
hasSubmenu?: boolean;
|
|
16
|
+
trailingIcon?: React.ReactNode;
|
|
17
|
+
/** Keep the menu open after this item is activated (filter / multi-step menus). */
|
|
18
|
+
keepOpenOnSelect?: boolean;
|
|
19
|
+
theme?: CubeTheme;
|
|
20
|
+
}
|
|
21
|
+
/** Single row in an `ActionMenuList` — maps to Figma `ActionMenuItem`. */
|
|
22
|
+
export declare function ActionMenuItem({ children, subtext, subtextIcon, selected, showSelectionCheck, leadingIcon, iconOnly, hasSubmenu, trailingIcon, keepOpenOnSelect, theme, className, disabled, type, "aria-label": ariaLabel, ...rest }: ActionMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
export interface ActionMenuListProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Accessible name when the menu has no visible title. */
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
/** id of an element that labels the menu. */
|
|
8
|
+
"aria-labelledby"?: string;
|
|
9
|
+
theme?: CubeTheme;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
13
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
14
|
+
}
|
|
15
|
+
export interface ActionMenuListRegionProps {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
theme?: CubeTheme;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export interface ActionMenuListSectionProps extends ActionMenuListRegionProps {
|
|
22
|
+
label: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
declare function ActionMenuListHeader({ children, theme, className, style, }: ActionMenuListRegionProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare function ActionMenuListFooter({ children, theme, className, style, }: ActionMenuListRegionProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare function ActionMenuListSection({ label, children, theme, className, style, }: ActionMenuListSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const ActionMenuList: React.ForwardRefExoticComponent<ActionMenuListProps & React.RefAttributes<HTMLDivElement>> & {
|
|
28
|
+
Header: typeof ActionMenuListHeader;
|
|
29
|
+
Footer: typeof ActionMenuListFooter;
|
|
30
|
+
Section: typeof ActionMenuListSection;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
export declare function getEnabledMenuItems(container: HTMLElement | null): HTMLButtonElement[];
|
|
3
|
+
export declare function focusInitialMenuItem(container: HTMLElement | null): void;
|
|
4
|
+
export declare function handleMenuListKeyDown(event: KeyboardEvent<HTMLElement>, container: HTMLElement | null): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ActionMenu } from './ActionMenu';
|
|
2
|
+
export type { ActionMenuProps } from './ActionMenu';
|
|
3
|
+
export { ActionMenuItem } from './ActionMenuItem';
|
|
4
|
+
export type { ActionMenuItemProps } from './ActionMenuItem';
|
|
5
|
+
export { ActionMenuList } from './ActionMenuList';
|
|
6
|
+
export type { ActionMenuListProps, ActionMenuListRegionProps, ActionMenuListSectionProps, } from './ActionMenuList';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
export type BreadcrumbLinkState = "rest" | "hover" | "active";
|
|
4
|
+
export interface BreadcrumbLinkProps {
|
|
5
|
+
href?: string;
|
|
6
|
+
/** Current page — renders as non-interactive text (maps to Figma `active`). */
|
|
7
|
+
current?: boolean;
|
|
8
|
+
theme?: CubeTheme;
|
|
9
|
+
className?: string;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function BreadcrumbLink({ href, current, theme, className, children, ...rest }: BreadcrumbLinkProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "children">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CubeTheme } from '../../../theme/types';
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
label: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BreadcrumbsProps {
|
|
7
|
+
items: BreadcrumbItem[];
|
|
8
|
+
/** Accessible label for the navigation landmark. */
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
theme?: CubeTheme;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function Breadcrumbs({ items, "aria-label": ariaLabel, theme, className, }: BreadcrumbsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
export type ButtonSize = "xs" | "sm" | "md" | "lg";
|
|
4
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "rounded";
|
|
5
|
+
/** `rounded` = pill radius; use with any `variant`, or use `variant="rounded"` for Figma neutral pill. */
|
|
6
|
+
export type ButtonShape = "default" | "rounded";
|
|
7
|
+
export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
8
|
+
size?: ButtonSize;
|
|
9
|
+
variant?: ButtonVariant;
|
|
10
|
+
/** Pill / stadium shape (Figma control `style: rounded`) */
|
|
11
|
+
shape?: ButtonShape;
|
|
12
|
+
/** If true, the button fills the container width */
|
|
13
|
+
block?: boolean;
|
|
14
|
+
/** Icon placed before the label */
|
|
15
|
+
leadingIcon?: React.ReactNode;
|
|
16
|
+
/** Icon placed after the label */
|
|
17
|
+
trailingIcon?: React.ReactNode;
|
|
18
|
+
/** Override any theme tokens */
|
|
19
|
+
theme?: CubeTheme;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare function Button({ size, variant, shape, block, leadingIcon, trailingIcon, theme, children, disabled, style, ...rest }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
export type IconSize = "xs" | "sm" | "md" | "lg";
|
|
4
|
+
export interface IconProps {
|
|
5
|
+
/** SVG element — use `fill="currentColor"` (or stroke) so color inherits from context. */
|
|
6
|
+
children: React.ReactElement;
|
|
7
|
+
size?: IconSize;
|
|
8
|
+
/** When set, exposes `role="img"` + `aria-label`; otherwise the icon is decorative. */
|
|
9
|
+
label?: string;
|
|
10
|
+
theme?: CubeTheme;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function Icon({ children, size, label, theme, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme } from '../../../theme/types';
|
|
3
|
+
import { default as themeOutput } from '../../../theme/output/theme.json';
|
|
4
|
+
import { TooltipPlacement } from '../Tooltip';
|
|
5
|
+
/** Keys of `color.iconButton` in tokens / `theme.json` — add a variant in JSON + matching CSS module class `IconButton--<name>`. */
|
|
6
|
+
export type IconButtonVariant = keyof typeof themeOutput.iconButton;
|
|
7
|
+
export type IconButtonSize = "xs" | "sm" | "md" | "lg";
|
|
8
|
+
export interface IconButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
9
|
+
/** Icon only — pass a single SVG or element using `currentColor` for fills. */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** Maps to `sizes.iconButton` (hit area, radius, icon glyph — no label padding). */
|
|
12
|
+
size?: IconButtonSize;
|
|
13
|
+
variant?: IconButtonVariant;
|
|
14
|
+
/** Selected / toggled visual state (sets `aria-pressed` when not `undefined`) */
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Optional tooltip label (hover + focus). The control still needs a concise **accessible name**
|
|
18
|
+
* via `aria-label` (or `aria-labelledby`); the tooltip is wired with `aria-describedby` when open.
|
|
19
|
+
* When both `disabled` and `tooltip` are set, the button stays focusable/hoverable and uses
|
|
20
|
+
* `aria-disabled` instead of the native `disabled` attribute so the tooltip can show.
|
|
21
|
+
*/
|
|
22
|
+
tooltip?: React.ReactNode;
|
|
23
|
+
tooltipPlacement?: TooltipPlacement;
|
|
24
|
+
tooltipCompact?: boolean;
|
|
25
|
+
tooltipShowDelay?: number;
|
|
26
|
+
theme?: CubeTheme;
|
|
27
|
+
}
|
|
28
|
+
export declare function IconButton({ size, variant, selected, theme, children, disabled, style, type, className: userClassName, tooltip, tooltipPlacement, tooltipCompact, tooltipShowDelay, "aria-pressed": ariaPressedProp, onClick, onKeyDown, ...rest }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeTheme, LinkFunctionalColors } from '../../../theme/types';
|
|
3
|
+
export type LinkVariant = keyof LinkFunctionalColors;
|
|
4
|
+
export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "children"> {
|
|
5
|
+
href: string;
|
|
6
|
+
/**
|
|
7
|
+
* `inline` — inside body copy; inherits font from parent.
|
|
8
|
+
* `standalone` — nav, footer, contact rows.
|
|
9
|
+
*/
|
|
10
|
+
variant?: LinkVariant;
|
|
11
|
+
/** Opens in a new tab with `rel="noopener noreferrer"`. */
|
|
12
|
+
external?: boolean;
|
|
13
|
+
/** Show ↗ icon when `external` (default true). */
|
|
14
|
+
showExternalIcon?: boolean;
|
|
15
|
+
theme?: CubeTheme;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare function Link({ href, variant, external, showExternalIcon, theme, children, className, target, rel, ...rest }: LinkProps): import("react/jsx-runtime").JSX.Element;
|