@slipstream-ui/core 0.4.0 → 0.5.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/index.d.mts +296 -15
- package/dist/index.d.ts +296 -15
- package/dist/index.js +1047 -473
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1096 -530
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/app-shell.manifest.json +50 -0
- package/dist/manifests/badge.manifest.json +9 -4
- package/dist/manifests/breadcrumb.manifest.json +6 -0
- package/dist/manifests/button.manifest.json +14 -0
- package/dist/manifests/confirm-dialog.manifest.json +132 -0
- package/dist/manifests/data-table.manifest.json +50 -0
- package/dist/manifests/dialog.manifest.json +7 -0
- package/dist/manifests/drawer.manifest.json +7 -0
- package/dist/manifests/link.manifest.json +106 -0
- package/dist/manifests/page-header.manifest.json +30 -0
- package/dist/manifests/pagination.manifest.json +6 -0
- package/dist/manifests/prose.manifest.json +75 -0
- package/dist/manifests/search.manifest.json +41 -9
- package/dist/manifests/section-heading.manifest.json +108 -0
- package/dist/manifests/select.manifest.json +6 -0
- package/dist/manifests/site-footer.manifest.json +94 -0
- package/dist/manifests/site-header.manifest.json +130 -0
- package/dist/manifests/table-of-contents.manifest.json +87 -0
- package/package.json +2 -2
- package/src/components/alert/Alert.tsx +2 -2
- package/src/components/app-shell/AppShell.test.tsx +49 -1
- package/src/components/app-shell/AppShell.tsx +147 -43
- package/src/components/badge/Badge.test.tsx +21 -0
- package/src/components/badge/Badge.tsx +6 -0
- package/src/components/breadcrumb/Breadcrumb.test.tsx +16 -0
- package/src/components/breadcrumb/Breadcrumb.tsx +10 -5
- package/src/components/button/Button.test.tsx +40 -2
- package/src/components/button/Button.tsx +31 -7
- package/src/components/confirm-dialog/ConfirmDialog.test.tsx +46 -0
- package/src/components/confirm-dialog/ConfirmDialog.tsx +86 -0
- package/src/components/confirm-dialog/index.ts +1 -0
- package/src/components/data-table/DataTable.test.tsx +92 -0
- package/src/components/data-table/DataTable.tsx +98 -7
- package/src/components/dialog/Dialog.test.tsx +7 -0
- package/src/components/dialog/Dialog.tsx +4 -1
- package/src/components/drawer/Drawer.test.tsx +11 -2
- package/src/components/drawer/Drawer.tsx +5 -2
- package/src/components/input/Input.tsx +1 -0
- package/src/components/link/Link.test.tsx +60 -0
- package/src/components/link/Link.tsx +85 -0
- package/src/components/link/index.ts +1 -0
- package/src/components/page-header/PageHeader.test.tsx +17 -0
- package/src/components/page-header/PageHeader.tsx +22 -6
- package/src/components/pagination/Pagination.test.tsx +8 -0
- package/src/components/pagination/Pagination.tsx +16 -6
- package/src/components/prose/Prose.test.tsx +35 -0
- package/src/components/prose/Prose.tsx +61 -0
- package/src/components/prose/index.ts +1 -0
- package/src/components/search/Search.test.tsx +16 -0
- package/src/components/search/Search.tsx +11 -2
- package/src/components/section-heading/SectionHeading.test.tsx +32 -0
- package/src/components/section-heading/SectionHeading.tsx +54 -0
- package/src/components/section-heading/index.ts +1 -0
- package/src/components/select/Select.tsx +9 -7
- package/src/components/site-footer/SiteFooter.test.tsx +30 -0
- package/src/components/site-footer/SiteFooter.tsx +79 -0
- package/src/components/site-footer/index.ts +1 -0
- package/src/components/site-header/SiteHeader.test.tsx +53 -0
- package/src/components/site-header/SiteHeader.tsx +124 -0
- package/src/components/site-header/index.ts +1 -0
- package/src/components/switch/Switch.test.tsx +10 -0
- package/src/components/switch/Switch.tsx +8 -3
- package/src/components/table-of-contents/TableOfContents.test.tsx +31 -0
- package/src/components/table-of-contents/TableOfContents.tsx +100 -0
- package/src/components/table-of-contents/index.ts +1 -0
- package/src/components/textarea/Textarea.tsx +1 -0
- package/src/index.ts +7 -0
- package/src/manifests/app-shell.manifest.json +50 -0
- package/src/manifests/badge.manifest.json +9 -4
- package/src/manifests/breadcrumb.manifest.json +6 -0
- package/src/manifests/button.manifest.json +14 -0
- package/src/manifests/confirm-dialog.manifest.json +132 -0
- package/src/manifests/data-table.manifest.json +50 -0
- package/src/manifests/dialog.manifest.json +7 -0
- package/src/manifests/drawer.manifest.json +7 -0
- package/src/manifests/link.manifest.json +106 -0
- package/src/manifests/page-header.manifest.json +30 -0
- package/src/manifests/pagination.manifest.json +6 -0
- package/src/manifests/prose.manifest.json +75 -0
- package/src/manifests/search.manifest.json +41 -9
- package/src/manifests/section-heading.manifest.json +108 -0
- package/src/manifests/select.manifest.json +6 -0
- package/src/manifests/site-footer.manifest.json +94 -0
- package/src/manifests/site-header.manifest.json +130 -0
- package/src/manifests/table-of-contents.manifest.json +87 -0
- package/src/test/tailwind-v4.test.ts +103 -0
|
@@ -64,3 +64,13 @@ describe('Switch', () => {
|
|
|
64
64
|
expect(await axe(container)).toHaveNoViolations();
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
describe('Switch form submission', () => {
|
|
70
|
+
it('renders a hidden input while checked when name is provided', () => {
|
|
71
|
+
const { container, rerender } = render(<Switch name="notify" aria-label="Notify" defaultChecked />);
|
|
72
|
+
expect(container.querySelector('input[type="hidden"][name="notify"]')).toHaveValue('on');
|
|
73
|
+
rerender(<Switch name="notify" aria-label="Notify" checked={false} onCheckedChange={() => undefined} />);
|
|
74
|
+
expect(container.querySelector('input[type="hidden"][name="notify"]')).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -10,6 +10,8 @@ export type SwitchProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'o
|
|
|
10
10
|
defaultChecked?: boolean;
|
|
11
11
|
/** Fired when the user toggles the switch. */
|
|
12
12
|
onCheckedChange?: (checked: boolean) => void;
|
|
13
|
+
/** Name for form submission — renders a hidden "on" input while checked. */
|
|
14
|
+
name?: string;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -18,7 +20,7 @@ export type SwitchProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'o
|
|
|
18
20
|
* on/off state and keyboard users toggle with Enter or Space.
|
|
19
21
|
*/
|
|
20
22
|
const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
|
|
21
|
-
({ className, checked, defaultChecked, onCheckedChange, disabled, ...props }, ref) => {
|
|
23
|
+
({ className, checked, defaultChecked, onCheckedChange, disabled, name, ...props }, ref) => {
|
|
22
24
|
const [internalChecked, setInternalChecked] = React.useState(defaultChecked ?? false);
|
|
23
25
|
const isOn = checked ?? internalChecked;
|
|
24
26
|
|
|
@@ -28,7 +30,9 @@ const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
|
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
return (
|
|
31
|
-
|
|
33
|
+
<>
|
|
34
|
+
{name && isOn && <input type="hidden" name={name} value="on" />}
|
|
35
|
+
<button
|
|
32
36
|
type="button"
|
|
33
37
|
role="switch"
|
|
34
38
|
aria-checked={isOn}
|
|
@@ -51,7 +55,8 @@ const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
|
|
|
51
55
|
isOn ? 'translate-x-4' : 'translate-x-0'
|
|
52
56
|
)}
|
|
53
57
|
/>
|
|
54
|
-
|
|
58
|
+
</button>
|
|
59
|
+
</>
|
|
55
60
|
);
|
|
56
61
|
}
|
|
57
62
|
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { TableOfContents } from './TableOfContents';
|
|
5
|
+
|
|
6
|
+
const headings = [
|
|
7
|
+
{ id: 'intro', text: 'Introduction', level: 2 as const },
|
|
8
|
+
{ id: 'setup', text: 'Setup', level: 3 as const },
|
|
9
|
+
{ id: 'api', text: 'API', level: 2 as const },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe('TableOfContents', () => {
|
|
13
|
+
it('renders anchored headings with the active one marked', () => {
|
|
14
|
+
render(<TableOfContents headings={headings} activeId="setup" />);
|
|
15
|
+
expect(screen.getByRole('navigation', { name: 'On this page' })).toBeInTheDocument();
|
|
16
|
+
expect(screen.getByRole('link', { name: 'Setup' })).toHaveAttribute('aria-current', 'location');
|
|
17
|
+
expect(screen.getByRole('link', { name: 'Introduction' })).not.toHaveAttribute('aria-current');
|
|
18
|
+
expect(screen.getByRole('link', { name: 'API' })).toHaveAttribute('href', '#api');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('indents nested heading levels', () => {
|
|
22
|
+
render(<TableOfContents headings={headings} />);
|
|
23
|
+
const setupItem = screen.getByRole('link', { name: 'Setup' }).closest('li')!;
|
|
24
|
+
expect(setupItem.style.paddingLeft).toBe('0.75rem');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('has no accessibility violations', async () => {
|
|
28
|
+
const { container } = render(<TableOfContents headings={headings} activeId="intro" />);
|
|
29
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
|
|
6
|
+
export type TocHeading = {
|
|
7
|
+
id: string;
|
|
8
|
+
text: string;
|
|
9
|
+
level: 2 | 3 | 4;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type TableOfContentsProps = React.HTMLAttributes<HTMLElement> & {
|
|
13
|
+
headings: TocHeading[];
|
|
14
|
+
/** Controlled active heading id (otherwise use `useScrollSpy`). */
|
|
15
|
+
activeId?: string;
|
|
16
|
+
/** Accessible name. Default 'On this page'. */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Stick to the viewport while the article scrolls (default true). */
|
|
19
|
+
sticky?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* "On this page" navigation for long-form content. Renders a nested list
|
|
24
|
+
* with indentation per heading level and aria-current on the active item.
|
|
25
|
+
* Pair with `useScrollSpy` (or your own scroll tracking) for the active id.
|
|
26
|
+
*/
|
|
27
|
+
export function TableOfContents({
|
|
28
|
+
headings,
|
|
29
|
+
activeId,
|
|
30
|
+
label = 'On this page',
|
|
31
|
+
sticky = true,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: TableOfContentsProps) {
|
|
35
|
+
return (
|
|
36
|
+
<nav
|
|
37
|
+
aria-label={label}
|
|
38
|
+
className={cn('text-sm', sticky && 'sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto', className)}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
<p className="mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground">{label}</p>
|
|
42
|
+
<ul className="space-y-1 border-l border-border">
|
|
43
|
+
{headings.map((heading) => {
|
|
44
|
+
const active = heading.id === activeId;
|
|
45
|
+
return (
|
|
46
|
+
<li key={heading.id} style={{ paddingLeft: `${(heading.level - 2) * 0.75}rem` }}>
|
|
47
|
+
<a
|
|
48
|
+
href={`#${heading.id}`}
|
|
49
|
+
aria-current={active ? 'location' : undefined}
|
|
50
|
+
className={cn(
|
|
51
|
+
'-ml-px block border-l py-1 pl-3 transition-colors',
|
|
52
|
+
active
|
|
53
|
+
? 'border-primary font-medium text-primary'
|
|
54
|
+
: 'border-transparent text-muted-foreground hover:border-border hover:text-foreground'
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
{heading.text}
|
|
58
|
+
</a>
|
|
59
|
+
</li>
|
|
60
|
+
);
|
|
61
|
+
})}
|
|
62
|
+
</ul>
|
|
63
|
+
</nav>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Tracks which of the given element ids is currently in view. Returns the
|
|
69
|
+
* active id (the last heading scrolled past) and stays SSR-safe.
|
|
70
|
+
*/
|
|
71
|
+
export function useScrollSpy(ids: string[], options?: { rootMargin?: string }): string | undefined {
|
|
72
|
+
const [activeId, setActiveId] = React.useState<string | undefined>();
|
|
73
|
+
const idKey = ids.join('|');
|
|
74
|
+
const rootMargin = options?.rootMargin ?? '0px 0px -70% 0px';
|
|
75
|
+
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (idKey.length === 0 || typeof IntersectionObserver === 'undefined') return;
|
|
78
|
+
const elements = idKey
|
|
79
|
+
.split('|')
|
|
80
|
+
.map((id) => document.getElementById(id))
|
|
81
|
+
.filter((element): element is HTMLElement => element !== null);
|
|
82
|
+
if (elements.length === 0) return;
|
|
83
|
+
|
|
84
|
+
const observer = new IntersectionObserver(
|
|
85
|
+
(entries) => {
|
|
86
|
+
const visible = entries
|
|
87
|
+
.filter((entry) => entry.isIntersecting)
|
|
88
|
+
.sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
|
|
89
|
+
if (visible[0]) setActiveId(visible[0].target.id);
|
|
90
|
+
return;
|
|
91
|
+
},
|
|
92
|
+
{ rootMargin, threshold: 0 }
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
elements.forEach((element) => observer.observe(element));
|
|
96
|
+
return () => observer.disconnect();
|
|
97
|
+
}, [idKey, rootMargin]);
|
|
98
|
+
|
|
99
|
+
return activeId;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TableOfContents';
|
|
@@ -22,6 +22,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
22
22
|
'placeholder:text-muted-foreground',
|
|
23
23
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
24
24
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
25
|
+
'aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20',
|
|
25
26
|
className
|
|
26
27
|
)}
|
|
27
28
|
{...props}
|
package/src/index.ts
CHANGED
|
@@ -33,14 +33,21 @@ export * from './components/progress';
|
|
|
33
33
|
export * from './components/tabs';
|
|
34
34
|
export * from './components/tooltip';
|
|
35
35
|
export * from './components/card';
|
|
36
|
+
export * from './components/confirm-dialog';
|
|
37
|
+
export * from './components/table-of-contents';
|
|
38
|
+
export * from './components/prose';
|
|
39
|
+
export * from './components/site-footer';
|
|
40
|
+
export * from './components/site-header';
|
|
36
41
|
export * from './components/accordion';
|
|
37
42
|
export * from './components/table';
|
|
38
43
|
export * from './components/data-table';
|
|
39
44
|
export * from './components/list';
|
|
45
|
+
export * from './components/link';
|
|
40
46
|
export * from './components/text';
|
|
41
47
|
export * from './components/heading';
|
|
42
48
|
export * from './components/empty-state';
|
|
43
49
|
export * from './components/page-header';
|
|
50
|
+
export * from './components/section-heading';
|
|
44
51
|
export * from './components/metric-card';
|
|
45
52
|
export * from './components/password-input';
|
|
46
53
|
export * from './components/auth-layout';
|
|
@@ -68,6 +68,56 @@
|
|
|
68
68
|
"required": false,
|
|
69
69
|
"defaultValue": "Primary",
|
|
70
70
|
"description": "Accessible name of the nav landmark (Sidebar)."
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "children",
|
|
74
|
+
"type": "SidebarItem[]",
|
|
75
|
+
"required": false,
|
|
76
|
+
"description": "Nested items — renders a collapsible group with aria-expanded (SidebarItem)."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "collapsible",
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"required": false,
|
|
82
|
+
"defaultValue": "false",
|
|
83
|
+
"description": "Shows the collapse/expand control (Sidebar)."
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "defaultCollapsed",
|
|
87
|
+
"type": "boolean",
|
|
88
|
+
"required": false,
|
|
89
|
+
"defaultValue": "false",
|
|
90
|
+
"description": "Initial collapsed state (Sidebar)."
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "collapsed",
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"required": false,
|
|
96
|
+
"description": "Controlled collapsed state (Sidebar)."
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "onCollapsedChange",
|
|
100
|
+
"type": "(collapsed: boolean) => void",
|
|
101
|
+
"required": false,
|
|
102
|
+
"description": "Fires when the rail collapses/expands (Sidebar)."
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "defaultExpanded",
|
|
106
|
+
"type": "string[]",
|
|
107
|
+
"required": false,
|
|
108
|
+
"description": "SidebarItem hrefs of groups open initially (Sidebar)."
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "mobileBreakpoint",
|
|
112
|
+
"type": "'sm' | 'md' | 'lg'",
|
|
113
|
+
"required": false,
|
|
114
|
+
"defaultValue": "md",
|
|
115
|
+
"description": "Breakpoint where the rail becomes a drawer (AppShell).",
|
|
116
|
+
"enum": [
|
|
117
|
+
"sm",
|
|
118
|
+
"md",
|
|
119
|
+
"lg"
|
|
120
|
+
]
|
|
71
121
|
}
|
|
72
122
|
],
|
|
73
123
|
"examples": [
|
|
@@ -7,15 +7,20 @@
|
|
|
7
7
|
"props": [
|
|
8
8
|
{
|
|
9
9
|
"name": "variant",
|
|
10
|
-
"type": "'default' | 'secondary' | 'destructive' | 'outline'",
|
|
10
|
+
"type": "'default' | 'secondary' | 'destructive' | 'outline' | 'primary' | 'danger' | 'success' | 'warning' | 'info'",
|
|
11
11
|
"defaultValue": "default",
|
|
12
12
|
"required": false,
|
|
13
|
-
"description": "
|
|
13
|
+
"description": "Semantic surface; primary/danger are aliases for default/destructive.",
|
|
14
14
|
"enum": [
|
|
15
15
|
"default",
|
|
16
16
|
"secondary",
|
|
17
17
|
"destructive",
|
|
18
|
-
"outline"
|
|
18
|
+
"outline",
|
|
19
|
+
"primary",
|
|
20
|
+
"danger",
|
|
21
|
+
"success",
|
|
22
|
+
"warning",
|
|
23
|
+
"info"
|
|
19
24
|
],
|
|
20
25
|
"examples": [
|
|
21
26
|
"default",
|
|
@@ -46,7 +51,7 @@
|
|
|
46
51
|
"type": "boolean",
|
|
47
52
|
"required": false,
|
|
48
53
|
"defaultValue": "false",
|
|
49
|
-
"description": "Render the child element
|
|
54
|
+
"description": "Render the child element with badge styling."
|
|
50
55
|
}
|
|
51
56
|
],
|
|
52
57
|
"examples": [
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"type": "(item: BreadcrumbItem, index: number) => void",
|
|
30
30
|
"required": false,
|
|
31
31
|
"description": "Receives every link click with default navigation prevented — route programmatically."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "linkComponent",
|
|
35
|
+
"type": "React.ElementType",
|
|
36
|
+
"required": false,
|
|
37
|
+
"description": "Custom link element for routers (preserves prefetch/modified clicks)."
|
|
32
38
|
}
|
|
33
39
|
],
|
|
34
40
|
"examples": [
|
|
@@ -106,6 +106,20 @@
|
|
|
106
106
|
"button",
|
|
107
107
|
"submit"
|
|
108
108
|
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "loading",
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"required": false,
|
|
114
|
+
"defaultValue": "false",
|
|
115
|
+
"description": "Shows a spinner, disables the button and sets aria-busy."
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "loadingLabel",
|
|
119
|
+
"type": "string",
|
|
120
|
+
"required": false,
|
|
121
|
+
"defaultValue": "'Loading'",
|
|
122
|
+
"description": "Screen-reader text while loading; localize this for non-English apps."
|
|
109
123
|
}
|
|
110
124
|
],
|
|
111
125
|
"examples": [
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "confirm-dialog",
|
|
3
|
+
"name": "ConfirmDialog",
|
|
4
|
+
"tier": "molecule",
|
|
5
|
+
"package": "@slipstream-ui/core",
|
|
6
|
+
"importPath": "@slipstream-ui/core",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"sourceDir": "confirm-dialog",
|
|
9
|
+
"exportName": "ConfirmDialog",
|
|
10
|
+
"description": "Accessible confirmation dialog with async pending state, destructive variant and cancellable actions, built on Dialog.",
|
|
11
|
+
"designIntent": "Confirmations are copy-pasted per project (79 hand-rolled modals in the audited apps), usually without focus trapping or Escape. ConfirmDialog provides the accessible default plus a pending state for async actions.",
|
|
12
|
+
"props": [
|
|
13
|
+
{
|
|
14
|
+
"name": "open",
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"required": true,
|
|
17
|
+
"description": "Controlled visibility."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "onOpenChange",
|
|
21
|
+
"type": "(open: boolean) => void",
|
|
22
|
+
"required": true,
|
|
23
|
+
"description": "Open/close requests."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "title",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"required": true,
|
|
29
|
+
"description": "Dialog title (accessible name)."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "description",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"required": false,
|
|
35
|
+
"description": "Supporting line under the title."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "confirmLabel",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"required": false,
|
|
41
|
+
"defaultValue": "Confirm",
|
|
42
|
+
"description": "Confirm button label."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "cancelLabel",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"required": false,
|
|
48
|
+
"defaultValue": "Cancel",
|
|
49
|
+
"description": "Cancel button label."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "destructive",
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"required": false,
|
|
55
|
+
"defaultValue": "false",
|
|
56
|
+
"description": "Red confirm button for destructive actions."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "onConfirm",
|
|
60
|
+
"type": "() => void | Promise<void>",
|
|
61
|
+
"required": true,
|
|
62
|
+
"description": "Confirm handler; a promise shows a pending state."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "closeOnConfirm",
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"required": false,
|
|
68
|
+
"defaultValue": "true",
|
|
69
|
+
"description": "Close when the confirm handler resolves."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "children",
|
|
73
|
+
"type": "ReactNode",
|
|
74
|
+
"required": false,
|
|
75
|
+
"description": "Extra body content above the actions."
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"examples": [
|
|
79
|
+
{
|
|
80
|
+
"title": "Delete confirmation",
|
|
81
|
+
"code": "<ConfirmDialog\n open={open}\n onOpenChange={setOpen}\n title=\"Delete project\"\n description=\"This cannot be undone.\"\n destructive\n confirmLabel=\"Delete\"\n onConfirm={deleteProject}\n/>",
|
|
82
|
+
"description": "Async-safe destructive confirmation."
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"antiPatterns": [
|
|
86
|
+
{
|
|
87
|
+
"title": "Don't use it for multi-field forms",
|
|
88
|
+
"explanation": "ConfirmDialog is a yes/no gate; richer flows belong in Dialog.",
|
|
89
|
+
"example": "// Avoid\n<ConfirmDialog>…form…</ConfirmDialog>"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"accessibility": [
|
|
93
|
+
{
|
|
94
|
+
"feature": "Modal semantics",
|
|
95
|
+
"implementation": "Inherits Dialog's focus trap, Escape, backdrop and focus restoration",
|
|
96
|
+
"userRequirements": "Always provide a clear title"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"feature": "Pending state",
|
|
100
|
+
"implementation": "Confirm shows aria-busy while the promise runs; dismissal is blocked",
|
|
101
|
+
"userRequirements": "Return a promise for async actions"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"contentGuidelines": [
|
|
105
|
+
{
|
|
106
|
+
"contentType": "Titles",
|
|
107
|
+
"guidelines": [
|
|
108
|
+
"State the action",
|
|
109
|
+
"Confirm label repeats the verb"
|
|
110
|
+
],
|
|
111
|
+
"goodExamples": [
|
|
112
|
+
"Delete project",
|
|
113
|
+
"Publish release"
|
|
114
|
+
],
|
|
115
|
+
"badExamples": [
|
|
116
|
+
"Are you sure?"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"compositionRules": [
|
|
121
|
+
{
|
|
122
|
+
"component": "Dialog",
|
|
123
|
+
"relationship": "Built on Dialog; use Dialog directly for custom layouts",
|
|
124
|
+
"example": "<ConfirmDialog … />"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"relatedComponents": [
|
|
128
|
+
"Dialog",
|
|
129
|
+
"Button",
|
|
130
|
+
"Alert"
|
|
131
|
+
]
|
|
132
|
+
}
|
|
@@ -165,11 +165,61 @@
|
|
|
165
165
|
"'No conversations yet'"
|
|
166
166
|
]
|
|
167
167
|
},
|
|
168
|
+
{
|
|
169
|
+
"name": "selectAllLabel",
|
|
170
|
+
"type": "string",
|
|
171
|
+
"required": false,
|
|
172
|
+
"defaultValue": "'Select all rows'",
|
|
173
|
+
"description": "Accessible label for the select-all checkbox."
|
|
174
|
+
},
|
|
168
175
|
{
|
|
169
176
|
"name": "className",
|
|
170
177
|
"type": "string",
|
|
171
178
|
"required": false,
|
|
172
179
|
"description": "Additional classes for the table wrapper."
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "selectedRowIds",
|
|
183
|
+
"type": "string[]",
|
|
184
|
+
"required": false,
|
|
185
|
+
"description": "Selected row ids (controlled) — enables the leading selection column."
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "onSelectedRowIdsChange",
|
|
189
|
+
"type": "(ids: string[]) => void",
|
|
190
|
+
"required": false,
|
|
191
|
+
"description": "Fires after a row or select-all toggle."
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "isRowSelectable",
|
|
195
|
+
"type": "(row: T) => boolean",
|
|
196
|
+
"required": false,
|
|
197
|
+
"description": "Disable selection for individual rows."
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"name": "bulkActions",
|
|
201
|
+
"type": "ReactNode",
|
|
202
|
+
"required": false,
|
|
203
|
+
"description": "Rendered above the table while rows are selected."
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "manualPagination",
|
|
207
|
+
"type": "boolean",
|
|
208
|
+
"required": false,
|
|
209
|
+
"defaultValue": "false",
|
|
210
|
+
"description": "Server pagination: render data as-is, do not slice or sort."
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "total",
|
|
214
|
+
"type": "number",
|
|
215
|
+
"required": false,
|
|
216
|
+
"description": "Total row count across pages (summary + derived page count)."
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "pageCount",
|
|
220
|
+
"type": "number",
|
|
221
|
+
"required": false,
|
|
222
|
+
"description": "Total page count (manual pagination)."
|
|
173
223
|
}
|
|
174
224
|
],
|
|
175
225
|
"examples": [
|
|
@@ -78,6 +78,13 @@
|
|
|
78
78
|
"description": "Hide the header ✕ button (Escape and backdrop still close).",
|
|
79
79
|
"examples": ["false"]
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
"name": "closeLabel",
|
|
83
|
+
"type": "string",
|
|
84
|
+
"required": false,
|
|
85
|
+
"defaultValue": "'Close drawer'",
|
|
86
|
+
"description": "Accessible label for the close button."
|
|
87
|
+
},
|
|
81
88
|
{
|
|
82
89
|
"name": "initialFocusRef",
|
|
83
90
|
"type": "RefObject<HTMLElement | null>",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "link",
|
|
3
|
+
"name": "Link",
|
|
4
|
+
"tier": "atom",
|
|
5
|
+
"package": "@slipstream-ui/core",
|
|
6
|
+
"importPath": "@slipstream-ui/core",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"sourceDir": "link",
|
|
9
|
+
"exportName": "Link",
|
|
10
|
+
"description": "Inline link primitive with default/muted/underline/arrow/external variants, asChild router support and safe external handling.",
|
|
11
|
+
"designIntent": "Every codebase re-implements inline links with inconsistent variants and unsafe target=_blank. Link centralizes the variants, keeps a real <a href> (SEO, modified clicks) and adds rel=noopener plus a screen-reader note for external URLs.",
|
|
12
|
+
"props": [
|
|
13
|
+
{
|
|
14
|
+
"name": "href",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"required": false,
|
|
17
|
+
"description": "Destination URL (pass through or via asChild)."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "variant",
|
|
21
|
+
"type": "'default' | 'muted' | 'underline' | 'arrow' | 'external'",
|
|
22
|
+
"required": false,
|
|
23
|
+
"defaultValue": "default",
|
|
24
|
+
"description": "Visual style.",
|
|
25
|
+
"enum": [
|
|
26
|
+
"default",
|
|
27
|
+
"muted",
|
|
28
|
+
"underline",
|
|
29
|
+
"arrow",
|
|
30
|
+
"external"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "asChild",
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"required": false,
|
|
37
|
+
"defaultValue": "false",
|
|
38
|
+
"description": "Render the child (router Link) with link styling."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "external",
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"required": false,
|
|
44
|
+
"description": "Force external handling; absolute http(s) URLs are auto-detected, mailto/tel never open a new tab."
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"examples": [
|
|
48
|
+
{
|
|
49
|
+
"title": "Inline link",
|
|
50
|
+
"code": "<Link href=\"/docs\">Read the docs</Link>\n<Link href=\"https://github.com\" variant=\"external\">GitHub</Link>",
|
|
51
|
+
"description": "Internal links stay client-side; absolute URLs open safely in a new tab."
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"title": "Router link",
|
|
55
|
+
"code": "<Link asChild variant=\"underline\"><RouterLink href=\"/posts\">Posts</RouterLink></Link>",
|
|
56
|
+
"description": "Preserves prefetch and modified-click behavior."
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"antiPatterns": [
|
|
60
|
+
{
|
|
61
|
+
"title": "Don't use Link for buttons",
|
|
62
|
+
"explanation": "Actions belong in Button; Link is for navigation.",
|
|
63
|
+
"example": "// Avoid\n<Link href=\"#\" onClick={save}>Save</Link>\n\n// Prefer\n<Button onClick={save}>Save</Button>"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"accessibility": [
|
|
67
|
+
{
|
|
68
|
+
"feature": "Real anchors",
|
|
69
|
+
"implementation": "Renders <a href> so middle-click/modified clicks work",
|
|
70
|
+
"userRequirements": "Pass descriptive link text, not 'click here'"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"feature": "External notice",
|
|
74
|
+
"implementation": "External links get rel=noopener noreferrer and a screen-reader note",
|
|
75
|
+
"userRequirements": "Keep the sr-only note when overriding rows"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"contentGuidelines": [
|
|
79
|
+
{
|
|
80
|
+
"contentType": "Link text",
|
|
81
|
+
"guidelines": [
|
|
82
|
+
"Describe the destination",
|
|
83
|
+
"2-5 words"
|
|
84
|
+
],
|
|
85
|
+
"goodExamples": [
|
|
86
|
+
"Read the docs",
|
|
87
|
+
"View on GitHub"
|
|
88
|
+
],
|
|
89
|
+
"badExamples": [
|
|
90
|
+
"Click here"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"compositionRules": [
|
|
95
|
+
{
|
|
96
|
+
"component": "Card / List",
|
|
97
|
+
"relationship": "asChild makes whole-card links safe",
|
|
98
|
+
"example": "<Card asChild><Link href=\"/post\">…</Link></Card>"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"relatedComponents": [
|
|
102
|
+
"Button",
|
|
103
|
+
"Breadcrumb",
|
|
104
|
+
"Card"
|
|
105
|
+
]
|
|
106
|
+
}
|