@roadlittledawn/docs-design-system-react 0.8.0 → 0.10.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/README.md +25 -3
- package/USAGE.md +929 -0
- package/dist/components/Breadcrumb.d.ts +41 -0
- package/dist/components/Breadcrumb.js +49 -0
- package/dist/components/Breadcrumb.stories.d.ts +40 -0
- package/dist/components/Breadcrumb.stories.js +216 -0
- package/dist/components/Button.d.ts +1 -2
- package/dist/components/Callout.d.ts +1 -2
- package/dist/components/Card.d.ts +1 -2
- package/dist/components/CardGrid.d.ts +1 -2
- package/dist/components/CodeBlock.d.ts +1 -2
- package/dist/components/CollapserGroup.d.ts +1 -0
- package/dist/components/Heading.d.ts +1 -2
- package/dist/components/Link.d.ts +1 -2
- package/dist/components/List.d.ts +1 -2
- package/dist/components/Table.d.ts +81 -0
- package/dist/components/Table.js +93 -0
- package/dist/components/Table.stories.d.ts +44 -0
- package/dist/components/Table.stories.js +258 -0
- package/dist/components/Tabs.d.ts +4 -5
- package/dist/components/Typography.d.ts +1 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +324 -0
- package/package.json +3 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
/** Display text for the breadcrumb segment */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Optional URL for the segment; omit for the current (last) page */
|
|
6
|
+
href?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BreadcrumbProps {
|
|
9
|
+
/** Ordered list of path segments, root first */
|
|
10
|
+
items: BreadcrumbItem[];
|
|
11
|
+
/**
|
|
12
|
+
* Separator between segments. Accepts a string or any ReactNode (e.g. an SVG chevron icon).
|
|
13
|
+
* @default "/"
|
|
14
|
+
*/
|
|
15
|
+
delimiter?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Size variant controlling font size.
|
|
18
|
+
* @default "md"
|
|
19
|
+
*/
|
|
20
|
+
size?: "sm" | "md";
|
|
21
|
+
/**
|
|
22
|
+
* On narrow viewports, collapse middle segments behind an expandable ellipsis (…).
|
|
23
|
+
* The first and last segments are always visible. Click/tap the ellipsis to reveal all.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
collapseOnMobile?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* On narrow viewports, let the full breadcrumb trail scroll horizontally instead of
|
|
29
|
+
* wrapping to multiple lines. Can be combined with `collapseOnMobile`.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
scrollOnMobile?: boolean;
|
|
33
|
+
/** Additional CSS classes for consumer extensibility */
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Breadcrumb navigation component. Renders a `<nav aria-label="Breadcrumb">` with an ordered
|
|
38
|
+
* list of segments. The last (current) item receives `aria-current="page"`. Delimiter characters
|
|
39
|
+
* are marked `aria-hidden` so screen readers skip them.
|
|
40
|
+
*/
|
|
41
|
+
export declare function Breadcrumb({ items, delimiter, size, collapseOnMobile, scrollOnMobile, className, }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
/**
|
|
16
|
+
* Breadcrumb navigation component. Renders a `<nav aria-label="Breadcrumb">` with an ordered
|
|
17
|
+
* list of segments. The last (current) item receives `aria-current="page"`. Delimiter characters
|
|
18
|
+
* are marked `aria-hidden` so screen readers skip them.
|
|
19
|
+
*/
|
|
20
|
+
export function Breadcrumb(_a) {
|
|
21
|
+
var items = _a.items, _b = _a.delimiter, delimiter = _b === void 0 ? "/" : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.collapseOnMobile, collapseOnMobile = _d === void 0 ? false : _d, _e = _a.scrollOnMobile, scrollOnMobile = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? "" : _f;
|
|
22
|
+
var _g = useState(false), isExpanded = _g[0], setIsExpanded = _g[1];
|
|
23
|
+
if (items.length === 0)
|
|
24
|
+
return null;
|
|
25
|
+
var isCollapsible = collapseOnMobile && items.length > 2;
|
|
26
|
+
var navClasses = [
|
|
27
|
+
"dds-breadcrumb",
|
|
28
|
+
"dds-breadcrumb--".concat(size),
|
|
29
|
+
isCollapsible ? "dds-breadcrumb--collapsible" : "",
|
|
30
|
+
scrollOnMobile ? "dds-breadcrumb--scroll" : "",
|
|
31
|
+
className,
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join(" ");
|
|
35
|
+
var firstItem = items[0];
|
|
36
|
+
var lastItem = items[items.length - 1];
|
|
37
|
+
var middleItems = items.length > 1 ? items.slice(1, -1) : [];
|
|
38
|
+
var hasMiddle = middleItems.length > 0;
|
|
39
|
+
return (_jsx("nav", __assign({ className: navClasses, "aria-label": "Breadcrumb" }, (isCollapsible ? { "data-expanded": String(isExpanded) } : {}), { children: _jsxs("ol", { className: "dds-breadcrumb-list", children: [_jsxs("li", { className: "dds-breadcrumb-item", children: [items.length === 1 ? (_jsx("span", { className: "dds-breadcrumb-current", "aria-current": "page", children: firstItem.label })) : firstItem.href ? (_jsx("a", { href: firstItem.href, className: "dds-breadcrumb-link", children: firstItem.label })) : (_jsx("span", { className: "dds-breadcrumb-link", children: firstItem.label })), items.length > 1 && (_jsx("span", { className: "dds-breadcrumb-delimiter", "aria-hidden": "true", children: delimiter }))] }), isCollapsible && hasMiddle && (_jsxs("li", { className: "dds-breadcrumb-item dds-breadcrumb-item--ellipsis", children: [_jsx("button", { type: "button", className: "dds-breadcrumb-ellipsis", "aria-label": "Show all breadcrumb items", onClick: function () { return setIsExpanded(true); }, children: "\u2026" }), _jsx("span", { className: "dds-breadcrumb-delimiter", "aria-hidden": "true", children: delimiter })] })), hasMiddle &&
|
|
40
|
+
middleItems.map(function (item, relIndex) {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_jsxs("li", { className: [
|
|
43
|
+
"dds-breadcrumb-item",
|
|
44
|
+
isCollapsible ? "dds-breadcrumb-item--middle" : "",
|
|
45
|
+
]
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(" "), children: [item.href ? (_jsx("a", { href: item.href, className: "dds-breadcrumb-link", children: item.label })) : (_jsx("span", { className: "dds-breadcrumb-link", children: item.label })), _jsx("span", { className: "dds-breadcrumb-delimiter", "aria-hidden": "true", children: delimiter })] }, "".concat((_a = item.href) !== null && _a !== void 0 ? _a : '', "-").concat(item.label, "-").concat(relIndex)));
|
|
48
|
+
}), items.length > 1 && (_jsx("li", { className: "dds-breadcrumb-item", children: lastItem.href ? (_jsx("a", { href: lastItem.href, className: "dds-breadcrumb-link dds-breadcrumb-current", "aria-current": "page", children: lastItem.label })) : (_jsx("span", { className: "dds-breadcrumb-current", "aria-current": "page", children: lastItem.label })) }))] }) })));
|
|
49
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Breadcrumb } from "./Breadcrumb";
|
|
3
|
+
declare const meta: Meta<typeof Breadcrumb>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Breadcrumb>;
|
|
6
|
+
/**
|
|
7
|
+
* The default breadcrumb with a three-segment path and the "/" delimiter.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Default: Story;
|
|
10
|
+
/**
|
|
11
|
+
* A single-item breadcrumb — just the current page with no parent links.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SingleItem: Story;
|
|
14
|
+
/**
|
|
15
|
+
* Custom string delimiter using "›" instead of "/".
|
|
16
|
+
*/
|
|
17
|
+
export declare const CustomStringDelimiter: Story;
|
|
18
|
+
/**
|
|
19
|
+
* Custom SVG chevron as the delimiter — demonstrates ReactNode delimiter support.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SvgChevronDelimiter: Story;
|
|
22
|
+
/**
|
|
23
|
+
* Small size variant — useful in compact page headers.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SmallSize: Story;
|
|
26
|
+
/**
|
|
27
|
+
* `collapseOnMobile` — middle segments collapse to an ellipsis on narrow viewports.
|
|
28
|
+
* Resize the browser window or use a mobile emulator to see this in action.
|
|
29
|
+
* Click the "…" to expand all items.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CollapseOnMobile: Story;
|
|
32
|
+
/**
|
|
33
|
+
* `scrollOnMobile` — the breadcrumb trail scrolls horizontally on narrow viewports
|
|
34
|
+
* rather than wrapping onto multiple lines.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ScrollOnMobile: Story;
|
|
37
|
+
/**
|
|
38
|
+
* All size and delimiter variants displayed together for visual comparison.
|
|
39
|
+
*/
|
|
40
|
+
export declare const AllVariants: Story;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Breadcrumb } from "./Breadcrumb";
|
|
3
|
+
var meta = {
|
|
4
|
+
title: "Components/Breadcrumb",
|
|
5
|
+
component: Breadcrumb,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
argTypes: {
|
|
8
|
+
items: {
|
|
9
|
+
description: "Ordered array of path segments (root first). Each item requires a `label`; `href` is optional and omitted for the current page.",
|
|
10
|
+
},
|
|
11
|
+
delimiter: {
|
|
12
|
+
control: "text",
|
|
13
|
+
description: "Separator between segments. Accepts a string or any ReactNode (e.g. an SVG icon). Rendered `aria-hidden`.",
|
|
14
|
+
table: { defaultValue: { summary: '"/"' } },
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
control: { type: "select" },
|
|
18
|
+
options: ["sm", "md"],
|
|
19
|
+
description: "Font-size variant.",
|
|
20
|
+
table: { defaultValue: { summary: '"md"' } },
|
|
21
|
+
},
|
|
22
|
+
collapseOnMobile: {
|
|
23
|
+
control: "boolean",
|
|
24
|
+
description: "Collapse middle segments behind an ellipsis on narrow viewports. Click the ellipsis to expand.",
|
|
25
|
+
table: { defaultValue: { summary: "false" } },
|
|
26
|
+
},
|
|
27
|
+
scrollOnMobile: {
|
|
28
|
+
control: "boolean",
|
|
29
|
+
description: "Let the full breadcrumb scroll horizontally on narrow viewports instead of wrapping. Can be combined with `collapseOnMobile`.",
|
|
30
|
+
table: { defaultValue: { summary: "false" } },
|
|
31
|
+
},
|
|
32
|
+
className: {
|
|
33
|
+
control: "text",
|
|
34
|
+
description: "Additional CSS classes.",
|
|
35
|
+
table: { defaultValue: { summary: '""' } },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
parameters: {
|
|
39
|
+
docs: {
|
|
40
|
+
description: {
|
|
41
|
+
component: "\nThe Breadcrumb component renders a hierarchical navigation trail for documentation pages.\n\n## When to Use\n\n- To show the user's current location within a multi-level documentation hierarchy\n- To provide quick navigation back to parent sections\n- On pages nested 2 or more levels deep\n\n## When Not to Use\n\n- On top-level landing pages where hierarchy is obvious\n- For purely sequential step indicators (use a stepper/progress component instead)\n\n## Accessibility\n\n- Renders as `<nav aria-label=\"Breadcrumb\">` with an `<ol>` list so screen readers announce it correctly\n- The current (last) page item receives `aria-current=\"page\"`\n- Delimiter characters are marked `aria-hidden` and are not read aloud\n- The ellipsis expand button has an accessible `aria-label`\n ",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export default meta;
|
|
47
|
+
var docsItems = [
|
|
48
|
+
{ label: "Docs", href: "/docs" },
|
|
49
|
+
{ label: "Components", href: "/docs/components" },
|
|
50
|
+
{ label: "Breadcrumb" },
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* The default breadcrumb with a three-segment path and the "/" delimiter.
|
|
54
|
+
*/
|
|
55
|
+
export var Default = {
|
|
56
|
+
args: {
|
|
57
|
+
items: docsItems,
|
|
58
|
+
},
|
|
59
|
+
parameters: {
|
|
60
|
+
docs: {
|
|
61
|
+
source: {
|
|
62
|
+
code: "<Breadcrumb\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n/>",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A single-item breadcrumb — just the current page with no parent links.
|
|
69
|
+
*/
|
|
70
|
+
export var SingleItem = {
|
|
71
|
+
args: {
|
|
72
|
+
items: [{ label: "Getting Started" }],
|
|
73
|
+
},
|
|
74
|
+
parameters: {
|
|
75
|
+
docs: {
|
|
76
|
+
source: {
|
|
77
|
+
code: "<Breadcrumb items={[{ label: 'Getting Started' }]} />",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Custom string delimiter using "›" instead of "/".
|
|
84
|
+
*/
|
|
85
|
+
export var CustomStringDelimiter = {
|
|
86
|
+
args: {
|
|
87
|
+
items: docsItems,
|
|
88
|
+
delimiter: "›",
|
|
89
|
+
},
|
|
90
|
+
parameters: {
|
|
91
|
+
docs: {
|
|
92
|
+
source: {
|
|
93
|
+
code: "<Breadcrumb\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n delimiter=\"\u203A\"\n/>",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Custom SVG chevron as the delimiter — demonstrates ReactNode delimiter support.
|
|
100
|
+
*/
|
|
101
|
+
export var SvgChevronDelimiter = {
|
|
102
|
+
args: {
|
|
103
|
+
items: docsItems,
|
|
104
|
+
delimiter: (_jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", style: { flexShrink: 0 }, children: _jsx("polyline", { points: "9 18 15 12 9 6" }) })),
|
|
105
|
+
},
|
|
106
|
+
parameters: {
|
|
107
|
+
docs: {
|
|
108
|
+
source: {
|
|
109
|
+
code: "const ChevronRight = (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\"\n strokeLinejoin=\"round\" aria-hidden=\"true\">\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n);\n\n<Breadcrumb\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n delimiter={ChevronRight}\n/>",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Small size variant — useful in compact page headers.
|
|
116
|
+
*/
|
|
117
|
+
export var SmallSize = {
|
|
118
|
+
args: {
|
|
119
|
+
items: docsItems,
|
|
120
|
+
size: "sm",
|
|
121
|
+
},
|
|
122
|
+
parameters: {
|
|
123
|
+
docs: {
|
|
124
|
+
source: {
|
|
125
|
+
code: "<Breadcrumb\n size=\"sm\"\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n/>",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* `collapseOnMobile` — middle segments collapse to an ellipsis on narrow viewports.
|
|
132
|
+
* Resize the browser window or use a mobile emulator to see this in action.
|
|
133
|
+
* Click the "…" to expand all items.
|
|
134
|
+
*/
|
|
135
|
+
export var CollapseOnMobile = {
|
|
136
|
+
args: {
|
|
137
|
+
collapseOnMobile: true,
|
|
138
|
+
items: [
|
|
139
|
+
{ label: "Docs", href: "/docs" },
|
|
140
|
+
{ label: "Guides", href: "/docs/guides" },
|
|
141
|
+
{ label: "Components", href: "/docs/guides/components" },
|
|
142
|
+
{ label: "Navigation", href: "/docs/guides/components/navigation" },
|
|
143
|
+
{ label: "Breadcrumb" },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
parameters: {
|
|
147
|
+
docs: {
|
|
148
|
+
source: {
|
|
149
|
+
code: "<Breadcrumb\n collapseOnMobile\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Guides', href: '/docs/guides' },\n { label: 'Components', href: '/docs/guides/components' },\n { label: 'Navigation', href: '/docs/guides/components/navigation' },\n { label: 'Breadcrumb' },\n ]}\n/>",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* `scrollOnMobile` — the breadcrumb trail scrolls horizontally on narrow viewports
|
|
156
|
+
* rather than wrapping onto multiple lines.
|
|
157
|
+
*/
|
|
158
|
+
export var ScrollOnMobile = {
|
|
159
|
+
args: {
|
|
160
|
+
scrollOnMobile: true,
|
|
161
|
+
items: [
|
|
162
|
+
{ label: "Docs", href: "/docs" },
|
|
163
|
+
{ label: "Guides", href: "/docs/guides" },
|
|
164
|
+
{ label: "Components", href: "/docs/guides/components" },
|
|
165
|
+
{ label: "Navigation", href: "/docs/guides/components/navigation" },
|
|
166
|
+
{ label: "Breadcrumb" },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
parameters: {
|
|
170
|
+
docs: {
|
|
171
|
+
source: {
|
|
172
|
+
code: "<Breadcrumb\n scrollOnMobile\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Guides', href: '/docs/guides' },\n { label: 'Components', href: '/docs/guides/components' },\n { label: 'Navigation', href: '/docs/guides/components/navigation' },\n { label: 'Breadcrumb' },\n ]}\n/>",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* All size and delimiter variants displayed together for visual comparison.
|
|
179
|
+
*/
|
|
180
|
+
export var AllVariants = {
|
|
181
|
+
parameters: {
|
|
182
|
+
docs: {
|
|
183
|
+
source: {
|
|
184
|
+
code: "<div style={{ display: 'flex', flexDirection: 'column', gap: '1.5rem' }}>\n <Breadcrumb\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n />\n <Breadcrumb\n size=\"sm\"\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n />\n <Breadcrumb\n delimiter=\"\u203A\"\n items={[\n { label: 'Docs', href: '/docs' },\n { label: 'Components', href: '/docs/components' },\n { label: 'Breadcrumb' },\n ]}\n />\n</div>",
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
render: function () { return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "1.5rem" }, children: [_jsxs("div", { children: [_jsx("p", { style: {
|
|
189
|
+
color: "var(--dds-breadcrumb-current-color)",
|
|
190
|
+
fontFamily: "sans-serif",
|
|
191
|
+
fontSize: "0.75rem",
|
|
192
|
+
marginBottom: "0.25rem",
|
|
193
|
+
}, children: "Default (md)" }), _jsx(Breadcrumb, { items: [
|
|
194
|
+
{ label: "Docs", href: "/docs" },
|
|
195
|
+
{ label: "Components", href: "/docs/components" },
|
|
196
|
+
{ label: "Breadcrumb" },
|
|
197
|
+
] })] }), _jsxs("div", { children: [_jsx("p", { style: {
|
|
198
|
+
color: "var(--dds-breadcrumb-current-color)",
|
|
199
|
+
fontFamily: "sans-serif",
|
|
200
|
+
fontSize: "0.75rem",
|
|
201
|
+
marginBottom: "0.25rem",
|
|
202
|
+
}, children: "Small (sm)" }), _jsx(Breadcrumb, { size: "sm", items: [
|
|
203
|
+
{ label: "Docs", href: "/docs" },
|
|
204
|
+
{ label: "Components", href: "/docs/components" },
|
|
205
|
+
{ label: "Breadcrumb" },
|
|
206
|
+
] })] }), _jsxs("div", { children: [_jsx("p", { style: {
|
|
207
|
+
color: "var(--dds-breadcrumb-current-color)",
|
|
208
|
+
fontFamily: "sans-serif",
|
|
209
|
+
fontSize: "0.75rem",
|
|
210
|
+
marginBottom: "0.25rem",
|
|
211
|
+
}, children: "Custom delimiter \"\u203A\"" }), _jsx(Breadcrumb, { delimiter: "\u203A", items: [
|
|
212
|
+
{ label: "Docs", href: "/docs" },
|
|
213
|
+
{ label: "Components", href: "/docs/components" },
|
|
214
|
+
{ label: "Breadcrumb" },
|
|
215
|
+
] })] })] })); },
|
|
216
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
2
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
/**
|
|
4
4
|
* Visual style variant of the button
|
|
5
5
|
* @default 'primary'
|
|
@@ -14,4 +14,3 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
}
|
|
16
16
|
export declare const Button: React.FC<ButtonProps>;
|
|
17
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
export type CalloutVariant = "caution" | "important" | "tip" | "course";
|
|
3
|
-
interface CalloutProps {
|
|
3
|
+
export interface CalloutProps {
|
|
4
4
|
/** Visual style variant of the callout (caution, important, tip, or course) */
|
|
5
5
|
variant: CalloutVariant;
|
|
6
6
|
/**
|
|
@@ -14,4 +14,3 @@ interface CalloutProps {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
}
|
|
16
16
|
export declare function Callout({ variant, title, children, className, }: CalloutProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
interface CardProps {
|
|
2
|
+
export interface CardProps {
|
|
3
3
|
/** Optional title displayed at the top of the card */
|
|
4
4
|
title?: string;
|
|
5
5
|
/**
|
|
@@ -20,4 +20,3 @@ interface CardProps {
|
|
|
20
20
|
className?: string;
|
|
21
21
|
}
|
|
22
22
|
export declare function Card({ title, titleColor, backgroundColor, href, children, className, }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
interface CardGridProps {
|
|
2
|
+
export interface CardGridProps {
|
|
3
3
|
/**
|
|
4
4
|
* Number of columns in the grid
|
|
5
5
|
* @default 3
|
|
@@ -17,4 +17,3 @@ interface CardGridProps {
|
|
|
17
17
|
className?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare function CardGrid({ columns, equalHeight, children, className }: CardGridProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export {};
|
|
@@ -25,7 +25,7 @@ export interface CodeSnippet {
|
|
|
25
25
|
/** Optional line numbers to highlight (1-indexed) */
|
|
26
26
|
highlightLines?: number[];
|
|
27
27
|
}
|
|
28
|
-
interface CodeBlockProps {
|
|
28
|
+
export interface CodeBlockProps {
|
|
29
29
|
/** Single code snippet (for simple usage) */
|
|
30
30
|
code?: string;
|
|
31
31
|
/** Language for syntax highlighting */
|
|
@@ -55,4 +55,3 @@ interface CodeBlockProps {
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function registerLanguages(loader: () => Promise<void>): Promise<void>;
|
|
57
57
|
export declare function CodeBlock({ code, language, filename, highlightLines, snippets, path, className, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element | null;
|
|
58
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
interface HeadingProps {
|
|
2
|
+
export interface HeadingProps {
|
|
3
3
|
/** Optionally override auto-generation of `id` attribute */
|
|
4
4
|
id?: string;
|
|
5
5
|
/** Heading level (h1, h2, h3, or h4) */
|
|
@@ -10,4 +10,3 @@ interface HeadingProps {
|
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function Heading({ level, children, id, className }: HeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface LinkProps {
|
|
2
|
+
export interface LinkProps {
|
|
3
3
|
/** URL to link to. External links (starting with http:// or https://) open in new tab */
|
|
4
4
|
href: string;
|
|
5
5
|
/** Link content */
|
|
@@ -8,4 +8,3 @@ interface LinkProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function Link({ href, children, className }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -11,7 +11,7 @@ export interface ListProps {
|
|
|
11
11
|
/** Custom bullet icon (React node, e.g., SVG) for unordered lists. Takes precedence over bullet prop */
|
|
12
12
|
bulletIcon?: ReactNode;
|
|
13
13
|
}
|
|
14
|
-
interface ListItemProps {
|
|
14
|
+
export interface ListItemProps {
|
|
15
15
|
/** List item content */
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
/** Additional CSS classes */
|
|
@@ -23,4 +23,3 @@ export declare function ListItem({ children, className, bulletIcon }: ListItemPr
|
|
|
23
23
|
export declare const List: FC<ListProps> & {
|
|
24
24
|
Item: typeof ListItem;
|
|
25
25
|
};
|
|
26
|
-
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type SortDirection = 'asc' | 'desc' | null;
|
|
3
|
+
export interface TableProps {
|
|
4
|
+
/** Children — typically TableHead and TableBody */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Visual variant of the table.
|
|
8
|
+
* `"default"` renders all borders; `"borderless"` shows only row top/bottom borders.
|
|
9
|
+
*/
|
|
10
|
+
variant?: 'default' | 'borderless';
|
|
11
|
+
/**
|
|
12
|
+
* When true the thead sticks to the top of the scroll container while scrolling.
|
|
13
|
+
* Pair with the `style` prop (e.g. `style={{ maxHeight: '400px' }}`) to constrain
|
|
14
|
+
* the table height so that the header can stick.
|
|
15
|
+
*/
|
|
16
|
+
stickyHeader?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Background color applied to the header row.
|
|
19
|
+
* Accepts any valid CSS color value (e.g. `"#f0f4ff"`, `"var(--my-color)"`).
|
|
20
|
+
* Overrides the default token value.
|
|
21
|
+
*/
|
|
22
|
+
headerBg?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Callback fired when a sortable column header is clicked.
|
|
25
|
+
* Useful for server-side sorting. Receives the column key and new direction.
|
|
26
|
+
*/
|
|
27
|
+
onSort?: (key: string, direction: SortDirection) => void;
|
|
28
|
+
/** Additional CSS classes applied to the outer wrapper */
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Inline styles applied to the outer wrapper.
|
|
32
|
+
* Use `maxHeight` here to constrain the table height when `stickyHeader` is true.
|
|
33
|
+
*/
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
}
|
|
36
|
+
export declare function Table({ children, variant, stickyHeader, headerBg, onSort, className, style, }: TableProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export interface TableHeadProps {
|
|
38
|
+
/** Header rows — typically one TableRow containing TableHeaderCells */
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
/** Additional CSS classes */
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function TableHead({ children, className }: TableHeadProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export interface TableBodyProps {
|
|
45
|
+
/** Table body rows */
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
/** Additional CSS classes */
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function TableBody({ children, className }: TableBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export interface TableRowProps {
|
|
52
|
+
/** Cells in this row */
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
/** Additional CSS classes */
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function TableRow({ children, className }: TableRowProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
export interface TableHeaderCellProps {
|
|
59
|
+
/** Cell content / column label */
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Unique key used to identify this column when sorting.
|
|
63
|
+
* When provided the column becomes sortable.
|
|
64
|
+
*/
|
|
65
|
+
sortKey?: string;
|
|
66
|
+
/** Text alignment of the column */
|
|
67
|
+
align?: 'left' | 'center' | 'right';
|
|
68
|
+
/** Additional CSS classes */
|
|
69
|
+
className?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function TableHeaderCell({ children, sortKey, align, className, }: TableHeaderCellProps): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
export interface TableCellProps {
|
|
73
|
+
/** Cell content */
|
|
74
|
+
children?: React.ReactNode;
|
|
75
|
+
/** Text alignment */
|
|
76
|
+
align?: 'left' | 'center' | 'right';
|
|
77
|
+
/** Additional CSS classes */
|
|
78
|
+
className?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare function TableCell({ children, align, className }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, createContext, useContext } from 'react';
|
|
4
|
+
var TableContext = createContext(null);
|
|
5
|
+
function useTableContext() {
|
|
6
|
+
var ctx = useContext(TableContext);
|
|
7
|
+
if (!ctx) {
|
|
8
|
+
throw new Error('Table sub-components must be used within a Table component');
|
|
9
|
+
}
|
|
10
|
+
return ctx;
|
|
11
|
+
}
|
|
12
|
+
export function Table(_a) {
|
|
13
|
+
var children = _a.children, _b = _a.variant, variant = _b === void 0 ? 'default' : _b, _c = _a.stickyHeader, stickyHeader = _c === void 0 ? false : _c, headerBg = _a.headerBg, onSort = _a.onSort, _d = _a.className, className = _d === void 0 ? '' : _d, style = _a.style;
|
|
14
|
+
var _e = useState(null), sortKey = _e[0], setSortKey = _e[1];
|
|
15
|
+
var _f = useState(null), sortDirection = _f[0], setSortDirection = _f[1];
|
|
16
|
+
var handleSort = function (key) {
|
|
17
|
+
var nextDirection;
|
|
18
|
+
if (sortKey === key) {
|
|
19
|
+
nextDirection = sortDirection === 'asc' ? 'desc' : sortDirection === 'desc' ? null : 'asc';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
nextDirection = 'asc';
|
|
23
|
+
}
|
|
24
|
+
setSortKey(nextDirection === null ? null : key);
|
|
25
|
+
setSortDirection(nextDirection);
|
|
26
|
+
onSort === null || onSort === void 0 ? void 0 : onSort(key, nextDirection);
|
|
27
|
+
};
|
|
28
|
+
var wrapperClasses = [
|
|
29
|
+
'dds-table-wrapper',
|
|
30
|
+
stickyHeader ? 'dds-table-scrollable' : '',
|
|
31
|
+
variant === 'borderless' ? 'dds-table-borderless' : '',
|
|
32
|
+
className,
|
|
33
|
+
]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.join(' ');
|
|
36
|
+
return (_jsx(TableContext.Provider, { value: { sortKey: sortKey, sortDirection: sortDirection, onSort: handleSort, stickyHeader: stickyHeader, variant: variant, headerBg: headerBg }, children: _jsx("div", { className: wrapperClasses, style: style, children: _jsx("table", { className: "dds-table", children: children }) }) }));
|
|
37
|
+
}
|
|
38
|
+
export function TableHead(_a) {
|
|
39
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
40
|
+
var _c = useTableContext(), stickyHeader = _c.stickyHeader, headerBg = _c.headerBg;
|
|
41
|
+
var classes = ['dds-table-head', stickyHeader ? 'dds-table-head-sticky' : '', className]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join(' ');
|
|
44
|
+
var style = headerBg ? { backgroundColor: headerBg } : {};
|
|
45
|
+
return (_jsx("thead", { className: classes, style: style, children: children }));
|
|
46
|
+
}
|
|
47
|
+
export function TableBody(_a) {
|
|
48
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
49
|
+
return _jsx("tbody", { className: ['dds-table-body', className].filter(Boolean).join(' '), children: children });
|
|
50
|
+
}
|
|
51
|
+
export function TableRow(_a) {
|
|
52
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
53
|
+
return _jsx("tr", { className: ['dds-table-row', className].filter(Boolean).join(' '), children: children });
|
|
54
|
+
}
|
|
55
|
+
export function TableHeaderCell(_a) {
|
|
56
|
+
var children = _a.children, sortKey = _a.sortKey, _b = _a.align, align = _b === void 0 ? 'left' : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
57
|
+
var _d = useTableContext(), activeSortKey = _d.sortKey, sortDirection = _d.sortDirection, onSort = _d.onSort;
|
|
58
|
+
var isSortable = Boolean(sortKey);
|
|
59
|
+
var isActive = isSortable && activeSortKey === sortKey;
|
|
60
|
+
var classes = [
|
|
61
|
+
'dds-table-th',
|
|
62
|
+
isSortable ? 'dds-table-th-sortable' : '',
|
|
63
|
+
isActive ? 'dds-table-th-active' : '',
|
|
64
|
+
"dds-table-align-".concat(align),
|
|
65
|
+
className,
|
|
66
|
+
]
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join(' ');
|
|
69
|
+
var handleClick = function () {
|
|
70
|
+
if (sortKey) {
|
|
71
|
+
onSort(sortKey);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var handleKeyDown = function (e) {
|
|
75
|
+
if (isSortable && (e.key === 'Enter' || e.key === ' ')) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
handleClick();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var ariaSort = isActive
|
|
81
|
+
? sortDirection === 'asc'
|
|
82
|
+
? 'ascending'
|
|
83
|
+
: sortDirection === 'desc'
|
|
84
|
+
? 'descending'
|
|
85
|
+
: 'none'
|
|
86
|
+
: 'none';
|
|
87
|
+
return (_jsx("th", { className: classes, scope: "col", "aria-sort": isSortable ? ariaSort : undefined, onClick: isSortable ? handleClick : undefined, onKeyDown: isSortable ? handleKeyDown : undefined, tabIndex: isSortable ? 0 : undefined, children: _jsxs("span", { className: "dds-table-th-content", children: [children, isSortable && (_jsx("span", { className: "dds-table-sort-icon", "aria-hidden": "true", children: isActive && sortDirection === 'asc' ? '↑' : isActive && sortDirection === 'desc' ? '↓' : '↕' }))] }) }));
|
|
88
|
+
}
|
|
89
|
+
export function TableCell(_a) {
|
|
90
|
+
var children = _a.children, _b = _a.align, align = _b === void 0 ? 'left' : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
91
|
+
var classes = ['dds-table-td', "dds-table-align-".concat(align), className].filter(Boolean).join(' ');
|
|
92
|
+
return _jsx("td", { className: classes, children: children });
|
|
93
|
+
}
|