@helixds/react 0.1.0 → 0.2.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/AGENTS.md +4 -1
- package/dist/archetypes/actions-navigation.md +62 -0
- package/dist/archetypes/data-display.md +68 -0
- package/dist/archetypes/feedback-status.md +54 -0
- package/dist/archetypes/form-selection.md +61 -0
- package/dist/archetypes/foundation.md +56 -0
- package/dist/archetypes/layout.md +53 -0
- package/dist/archetypes/overlays.md +54 -0
- package/dist/archetypes/text-input.md +58 -0
- package/dist/components/Badge/Badge.types.d.ts +1 -1
- package/dist/components/Combobox/Combobox.d.ts +17 -0
- package/dist/components/Combobox/Combobox.doc.d.ts +4 -0
- package/dist/components/Combobox/Combobox.doc.js +41 -0
- package/dist/components/Combobox/Combobox.js +141 -0
- package/dist/components/Combobox/Combobox.types.d.ts +31 -0
- package/dist/components/Combobox/Combobox.types.js +2 -0
- package/dist/components/Combobox/index.d.ts +9 -0
- package/dist/components/Combobox/index.js +2 -0
- package/dist/components/Icon/Icon.doc.js +2 -2
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Icon/Icon.types.d.ts +1 -1
- package/dist/components/Icon/iconStroke.d.ts +1 -1
- package/dist/components/Icon/iconStroke.js +1 -1
- package/dist/components/Menu/Menu.doc.js +4 -4
- package/dist/components/Menu/Menu.js +3 -3
- package/dist/components/Menu/Menu.types.d.ts +1 -1
- package/dist/components/Modal/Modal.doc.js +1 -1
- package/dist/components/Modal/Modal.types.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/dist/components/MultiSelect/MultiSelect.doc.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +4 -4
- package/dist/components/Popover/Popover.d.ts +14 -0
- package/dist/components/Popover/Popover.doc.d.ts +4 -0
- package/dist/components/Popover/Popover.doc.js +47 -0
- package/dist/components/Popover/Popover.js +157 -0
- package/dist/components/Popover/Popover.types.d.ts +27 -0
- package/dist/components/Popover/Popover.types.js +2 -0
- package/dist/components/Popover/index.d.ts +9 -0
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.doc.js +2 -2
- package/dist/components/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/components/Select/Select.doc.js +2 -2
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/SidePanel/SidePanel.doc.js +1 -1
- package/dist/components/SidePanel/SidePanel.types.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +13 -0
- package/dist/components/Tabs/Tabs.doc.d.ts +4 -0
- package/dist/components/Tabs/Tabs.doc.js +47 -0
- package/dist/components/Tabs/Tabs.js +61 -0
- package/dist/components/Tabs/Tabs.types.d.ts +33 -0
- package/dist/components/Tabs/Tabs.types.js +2 -0
- package/dist/components/Tabs/index.d.ts +9 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Toast/Toast.doc.js +1 -1
- package/dist/components/Toast/Toast.js +2 -2
- package/dist/components/Toast/toastStore.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.doc.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +5 -5
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/contracts/Accordion.json +5 -4
- package/dist/contracts/AppShell.json +111 -28
- package/dist/contracts/Avatar.json +3 -2
- package/dist/contracts/AvatarGroup.json +1 -0
- package/dist/contracts/Badge.json +2 -1
- package/dist/contracts/Button.json +2 -1
- package/dist/contracts/Card.json +3 -2
- package/dist/contracts/Chart.json +2 -1
- package/dist/contracts/Checkbox.json +1 -0
- package/dist/contracts/CheckboxGroup.json +1 -0
- package/dist/contracts/Chip.json +3 -2
- package/dist/contracts/ChipGroup.json +1 -0
- package/dist/contracts/Combobox.json +431 -0
- package/dist/contracts/FAB.json +3 -2
- package/dist/contracts/Icon.json +10 -9
- package/dist/contracts/IconButton.json +2 -1
- package/dist/contracts/Input.json +2 -1
- package/dist/contracts/Menu.json +7 -6
- package/dist/contracts/Modal.json +5 -4
- package/dist/contracts/MultiSelect.json +6 -5
- package/dist/contracts/NavItem.json +2 -1
- package/dist/contracts/PageHeader.json +1 -0
- package/dist/contracts/Popover.json +322 -0
- package/dist/contracts/RadioButton.json +1 -0
- package/dist/contracts/RadioGroup.json +1 -0
- package/dist/contracts/SegmentedControl.json +4 -3
- package/dist/contracts/Select.json +9 -9
- package/dist/contracts/SideNav.json +2 -1
- package/dist/contracts/SidePanel.json +5 -4
- package/dist/contracts/Switch.json +1 -0
- package/dist/contracts/Table.json +1 -0
- package/dist/contracts/Tabs.json +353 -0
- package/dist/contracts/Textarea.json +2 -1
- package/dist/contracts/Toast.json +6 -5
- package/dist/contracts/Tooltip.json +4 -3
- package/dist/contracts/TopBar.json +2 -0
- package/dist/contracts/manifest.json +1539 -44
- package/dist/index.d.ts +9 -0
- package/dist/index.js +6 -0
- package/dist/layout/AppShell/AppShell.d.ts +1 -1
- package/dist/layout/AppShell/AppShell.doc.js +5 -0
- package/dist/layout/AppShell/AppShell.js +109 -2
- package/dist/layout/AppShell/AppShell.types.d.ts +6 -0
- package/dist/layout/AppShell/AppShellContext.d.ts +17 -0
- package/dist/layout/AppShell/AppShellContext.js +4 -0
- package/dist/layout/SideNav/SideNav.doc.js +1 -0
- package/dist/layout/TopBar/TopBar.js +7 -1
- package/dist/lib/useDialogTransition.d.ts +1 -1
- package/dist/lib/useDialogTransition.js +1 -1
- package/dist/lib/useDisclosureTransition.d.ts +1 -1
- package/dist/lib/useDisclosureTransition.js +1 -1
- package/dist/patterns/expand-collapse-chevron.md +1 -1
- package/dist/patterns/motion-effects.md +2 -4
- package/package.json +26 -4
- package/src/globals.css +338 -22
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { Textarea } from './components/Textarea/index.js';
|
|
|
15
15
|
export { Select } from './components/Select/index.js';
|
|
16
16
|
export { MultiSelect } from './components/MultiSelect/index.js';
|
|
17
17
|
export { Menu } from './components/Menu/index.js';
|
|
18
|
+
export { Combobox } from './components/Combobox/index.js';
|
|
18
19
|
export { Checkbox } from './components/Checkbox/index.js';
|
|
19
20
|
export { CheckboxGroup } from './components/CheckboxGroup/index.js';
|
|
20
21
|
export { RadioGroup } from './components/RadioGroup/index.js';
|
|
@@ -33,6 +34,8 @@ export { Modal } from './components/Modal/index.js';
|
|
|
33
34
|
export { SidePanel } from './components/SidePanel/index.js';
|
|
34
35
|
export { Toast, toast } from './components/Toast/index.js';
|
|
35
36
|
export { SegmentedControl } from './components/SegmentedControl/index.js';
|
|
37
|
+
export { Popover } from './components/Popover/index.js';
|
|
38
|
+
export { Tabs } from './components/Tabs/index.js';
|
|
36
39
|
export { Chart } from './components/Chart/index.js';
|
|
37
40
|
export { TopBar } from './layout/TopBar/index.js';
|
|
38
41
|
export { SideNav } from './layout/SideNav/index.js';
|
|
@@ -48,6 +51,7 @@ export { doc as TextareaDoc } from './components/Textarea/Textarea.doc.js';
|
|
|
48
51
|
export { doc as SelectDoc } from './components/Select/Select.doc.js';
|
|
49
52
|
export { doc as MultiSelectDoc } from './components/MultiSelect/MultiSelect.doc.js';
|
|
50
53
|
export { doc as MenuDoc } from './components/Menu/Menu.doc.js';
|
|
54
|
+
export { doc as ComboboxDoc } from './components/Combobox/Combobox.doc.js';
|
|
51
55
|
export { doc as CheckboxDoc } from './components/Checkbox/Checkbox.doc.js';
|
|
52
56
|
export { doc as CheckboxGroupDoc } from './components/CheckboxGroup/CheckboxGroup.doc.js';
|
|
53
57
|
export { doc as RadioGroupDoc } from './components/RadioGroup/RadioGroup.doc.js';
|
|
@@ -66,6 +70,8 @@ export { doc as ModalDoc } from './components/Modal/Modal.doc.js';
|
|
|
66
70
|
export { doc as SidePanelDoc } from './components/SidePanel/SidePanel.doc.js';
|
|
67
71
|
export { doc as ToastDoc } from './components/Toast/Toast.doc.js';
|
|
68
72
|
export { doc as SegmentedControlDoc } from './components/SegmentedControl/SegmentedControl.doc.js';
|
|
73
|
+
export { doc as PopoverDoc } from './components/Popover/Popover.doc.js';
|
|
74
|
+
export { doc as TabsDoc } from './components/Tabs/Tabs.doc.js';
|
|
69
75
|
export { doc as ChartDoc } from './components/Chart/Chart.doc.js';
|
|
70
76
|
export { doc as TopBarDoc } from './layout/TopBar/TopBar.doc.js';
|
|
71
77
|
export { doc as SideNavDoc } from './layout/SideNav/SideNav.doc.js';
|
|
@@ -81,6 +87,7 @@ export type { TextareaProps, TextareaResize } from './components/Textarea/index.
|
|
|
81
87
|
export type { SelectProps, SelectOption, SelectOptionGroup } from './components/Select/index.js';
|
|
82
88
|
export type { MultiSelectProps, MultiSelectOption, MultiSelectOptionGroup } from './components/MultiSelect/index.js';
|
|
83
89
|
export type { MenuProps, MenuOption, MenuOptionGroup } from './components/Menu/index.js';
|
|
90
|
+
export type { ComboboxProps, ComboboxOption } from './components/Combobox/index.js';
|
|
84
91
|
export type { CheckboxProps } from './components/Checkbox/index.js';
|
|
85
92
|
export type { CheckboxGroupProps, CheckboxOption, CheckboxGroupOrientation } from './components/CheckboxGroup/index.js';
|
|
86
93
|
export type { RadioGroupProps, RadioOption, RadioOrientation } from './components/RadioGroup/index.js';
|
|
@@ -99,6 +106,8 @@ export type { ModalProps } from './components/Modal/index.js';
|
|
|
99
106
|
export type { SidePanelProps } from './components/SidePanel/index.js';
|
|
100
107
|
export type { ToastProps, ToastVariant, ToastRecord, ToastOptions } from './components/Toast/index.js';
|
|
101
108
|
export type { SegmentedControlProps, SegmentedControlOption } from './components/SegmentedControl/index.js';
|
|
109
|
+
export type { PopoverProps, PopoverPlacement } from './components/Popover/index.js';
|
|
110
|
+
export type { TabsProps, TabsOption } from './components/Tabs/index.js';
|
|
102
111
|
export type { ChartProps, ChartSeries, ChartVariant } from './components/Chart/index.js';
|
|
103
112
|
export type { TopBarProps } from './layout/TopBar/index.js';
|
|
104
113
|
export type { SideNavProps } from './layout/SideNav/index.js';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { Textarea } from './components/Textarea/index.js';
|
|
|
10
10
|
export { Select } from './components/Select/index.js';
|
|
11
11
|
export { MultiSelect } from './components/MultiSelect/index.js';
|
|
12
12
|
export { Menu } from './components/Menu/index.js';
|
|
13
|
+
export { Combobox } from './components/Combobox/index.js';
|
|
13
14
|
export { Checkbox } from './components/Checkbox/index.js';
|
|
14
15
|
export { CheckboxGroup } from './components/CheckboxGroup/index.js';
|
|
15
16
|
export { RadioGroup } from './components/RadioGroup/index.js';
|
|
@@ -28,6 +29,8 @@ export { Modal } from './components/Modal/index.js';
|
|
|
28
29
|
export { SidePanel } from './components/SidePanel/index.js';
|
|
29
30
|
export { Toast, toast } from './components/Toast/index.js';
|
|
30
31
|
export { SegmentedControl } from './components/SegmentedControl/index.js';
|
|
32
|
+
export { Popover } from './components/Popover/index.js';
|
|
33
|
+
export { Tabs } from './components/Tabs/index.js';
|
|
31
34
|
export { Chart } from './components/Chart/index.js';
|
|
32
35
|
// Layout
|
|
33
36
|
export { TopBar } from './layout/TopBar/index.js';
|
|
@@ -45,6 +48,7 @@ export { doc as TextareaDoc } from './components/Textarea/Textarea.doc.js';
|
|
|
45
48
|
export { doc as SelectDoc } from './components/Select/Select.doc.js';
|
|
46
49
|
export { doc as MultiSelectDoc } from './components/MultiSelect/MultiSelect.doc.js';
|
|
47
50
|
export { doc as MenuDoc } from './components/Menu/Menu.doc.js';
|
|
51
|
+
export { doc as ComboboxDoc } from './components/Combobox/Combobox.doc.js';
|
|
48
52
|
export { doc as CheckboxDoc } from './components/Checkbox/Checkbox.doc.js';
|
|
49
53
|
export { doc as CheckboxGroupDoc } from './components/CheckboxGroup/CheckboxGroup.doc.js';
|
|
50
54
|
export { doc as RadioGroupDoc } from './components/RadioGroup/RadioGroup.doc.js';
|
|
@@ -63,6 +67,8 @@ export { doc as ModalDoc } from './components/Modal/Modal.doc.js';
|
|
|
63
67
|
export { doc as SidePanelDoc } from './components/SidePanel/SidePanel.doc.js';
|
|
64
68
|
export { doc as ToastDoc } from './components/Toast/Toast.doc.js';
|
|
65
69
|
export { doc as SegmentedControlDoc } from './components/SegmentedControl/SegmentedControl.doc.js';
|
|
70
|
+
export { doc as PopoverDoc } from './components/Popover/Popover.doc.js';
|
|
71
|
+
export { doc as TabsDoc } from './components/Tabs/Tabs.doc.js';
|
|
66
72
|
export { doc as ChartDoc } from './components/Chart/Chart.doc.js';
|
|
67
73
|
export { doc as TopBarDoc } from './layout/TopBar/TopBar.doc.js';
|
|
68
74
|
export { doc as SideNavDoc } from './layout/SideNav/SideNav.doc.js';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import type { AppShellProps } from './AppShell.types.js';
|
|
9
9
|
declare const AppShell: {
|
|
10
|
-
({ sidenav, topbar, children, className }: AppShellProps): React.JSX.Element;
|
|
10
|
+
({ sidenav, topbar, children, sidenavExpanded, defaultSidenavExpanded, onSidenavExpandedChange, className, }: AppShellProps): React.JSX.Element;
|
|
11
11
|
displayName: string;
|
|
12
12
|
};
|
|
13
13
|
export { AppShell };
|
|
@@ -4,14 +4,19 @@ export const doc = {
|
|
|
4
4
|
contract: 'contracts/components/AppShell.json',
|
|
5
5
|
a11y: [
|
|
6
6
|
'app-shell-main is the page\'s one <main> landmark.',
|
|
7
|
+
'Below 768px the SideNav collapses; the TopBar\'s menu button (aria-label "Navigation menu", aria-expanded, aria-controls) opens it over the content and moves focus to its current link.',
|
|
8
|
+
'Escape, following a link, a press outside or tabbing out of the open nav closes it; Escape returns focus to the menu button.',
|
|
7
9
|
],
|
|
8
10
|
variants: [],
|
|
9
11
|
sizes: [],
|
|
10
12
|
tokens: [
|
|
11
13
|
{ part: 'app-shell-root', label: 'fill', token: '--helix-color-fill-page', kind: 'color' },
|
|
14
|
+
{ part: 'app-shell-nav', label: 'top (collapsed, open)', token: '--helix-topBar-height', kind: 'space' },
|
|
15
|
+
{ part: 'app-shell-nav', label: 'slide duration', token: '--helix-duration-slow', kind: 'other' },
|
|
12
16
|
],
|
|
13
17
|
features: [
|
|
14
18
|
'sidenav/topbar — pass a SideNav/TopBar instance, or omit either for a shell with no nav or no chrome bar',
|
|
19
|
+
'sidenavExpanded / defaultSidenavExpanded / onSidenavExpandedChange — below 768px of the shell\'s width the SideNav collapses behind a menu button in the TopBar; controlled or uncontrolled, like Accordion\'s expanded',
|
|
15
20
|
'Renders the full-height flex structure itself — no consumer ever writes display:flex; height:100vh again. Exactly one viewport tall; only main scrolls',
|
|
16
21
|
],
|
|
17
22
|
examples: [
|
|
@@ -1,8 +1,115 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { cn } from '../../lib/utils.js';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { AppShellNavContext } from './AppShellContext.js';
|
|
5
|
+
/** primitive.breakpoint.tablet — below it the SideNav collapses. CSS reads the same value in its
|
|
6
|
+
* @container query (container queries can't read a var() either). */
|
|
7
|
+
const COLLAPSE_BELOW_PX = 768;
|
|
8
|
+
const FOCUSABLE = 'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
9
|
+
const AppShell = ({ sidenav, topbar, children, sidenavExpanded, defaultSidenavExpanded = false, onSidenavExpandedChange, className, }) => {
|
|
10
|
+
const [uncontrolledExpanded, setUncontrolledExpanded] = React.useState(defaultSidenavExpanded);
|
|
11
|
+
const isControlled = sidenavExpanded !== undefined;
|
|
12
|
+
const expanded = isControlled ? sidenavExpanded : uncontrolledExpanded;
|
|
13
|
+
// The collapse needs the TopBar's menu button to open the nav again — with no topbar the shell
|
|
14
|
+
// keeps the old narrow-screen layout (nav stacked on top) instead.
|
|
15
|
+
const collapsible = Boolean(sidenav && topbar);
|
|
16
|
+
const rootRef = React.useRef(null);
|
|
17
|
+
const navRef = React.useRef(null);
|
|
18
|
+
const toggleRef = React.useRef(null);
|
|
19
|
+
const togglePressed = React.useRef(false);
|
|
20
|
+
const focusOnOpen = React.useRef(false);
|
|
21
|
+
const navId = React.useId();
|
|
22
|
+
// Whether the shell is narrow enough for the nav to be collapsed — the CSS decides what shows,
|
|
23
|
+
// this only gates the keyboard/focus behavior that belongs to the collapsed nav.
|
|
24
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
25
|
+
React.useLayoutEffect(() => {
|
|
26
|
+
const root = rootRef.current;
|
|
27
|
+
if (!root || !collapsible || typeof ResizeObserver === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
const update = () => setNarrow(root.getBoundingClientRect().width < COLLAPSE_BELOW_PX);
|
|
30
|
+
update();
|
|
31
|
+
const observer = new ResizeObserver(update);
|
|
32
|
+
observer.observe(root);
|
|
33
|
+
return () => observer.disconnect();
|
|
34
|
+
}, [collapsible]);
|
|
35
|
+
const setExpanded = React.useCallback((next) => {
|
|
36
|
+
if (!isControlled)
|
|
37
|
+
setUncontrolledExpanded(next);
|
|
38
|
+
onSidenavExpandedChange?.(next);
|
|
39
|
+
}, [isControlled, onSidenavExpandedChange]);
|
|
40
|
+
const open = narrow && expanded;
|
|
41
|
+
const close = React.useCallback((returnFocus) => {
|
|
42
|
+
setExpanded(false);
|
|
43
|
+
if (returnFocus)
|
|
44
|
+
toggleRef.current?.focus();
|
|
45
|
+
}, [setExpanded]);
|
|
46
|
+
const toggle = React.useCallback(() => {
|
|
47
|
+
togglePressed.current = false;
|
|
48
|
+
focusOnOpen.current = !expanded;
|
|
49
|
+
setExpanded(!expanded);
|
|
50
|
+
}, [expanded, setExpanded]);
|
|
51
|
+
// Opening from the menu button moves focus into the nav — it comes before the TopBar in the DOM,
|
|
52
|
+
// so Tab alone would never reach it. Its current page link first, else its first link.
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
if (!open || !focusOnOpen.current)
|
|
55
|
+
return;
|
|
56
|
+
focusOnOpen.current = false;
|
|
57
|
+
const nav = navRef.current;
|
|
58
|
+
const target = nav?.querySelector('[aria-current="page"]') ?? nav?.querySelector(FOCUSABLE);
|
|
59
|
+
target?.focus();
|
|
60
|
+
}, [open]);
|
|
61
|
+
// Escape closes it (focus back on the menu button); a press anywhere outside the nav closes it.
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (!open)
|
|
64
|
+
return;
|
|
65
|
+
const onKeyDown = (event) => {
|
|
66
|
+
if (event.key !== 'Escape')
|
|
67
|
+
return;
|
|
68
|
+
const active = document.activeElement;
|
|
69
|
+
if (navRef.current?.contains(active) || active === toggleRef.current) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
close(true);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const onPointerDown = (event) => {
|
|
75
|
+
const target = event.target;
|
|
76
|
+
if (navRef.current?.contains(target) || toggleRef.current?.contains(target))
|
|
77
|
+
return;
|
|
78
|
+
close(false);
|
|
79
|
+
};
|
|
80
|
+
document.addEventListener('keydown', onKeyDown);
|
|
81
|
+
document.addEventListener('pointerdown', onPointerDown);
|
|
82
|
+
return () => {
|
|
83
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
84
|
+
document.removeEventListener('pointerdown', onPointerDown);
|
|
85
|
+
};
|
|
86
|
+
}, [open, close]);
|
|
87
|
+
// Focus leaving the open nav (Tab past its last link lands on the menu button) closes it — unless
|
|
88
|
+
// it left because the menu button is being pressed, whose click does the toggling itself.
|
|
89
|
+
const handleNavBlur = (event) => {
|
|
90
|
+
if (!open || togglePressed.current)
|
|
91
|
+
return;
|
|
92
|
+
if (navRef.current?.contains(event.relatedTarget))
|
|
93
|
+
return;
|
|
94
|
+
close(false);
|
|
95
|
+
};
|
|
96
|
+
// Following a link in the collapsed nav closes it.
|
|
97
|
+
const handleNavClick = (event) => {
|
|
98
|
+
if (open && event.target.closest('a[href]'))
|
|
99
|
+
close(false);
|
|
100
|
+
};
|
|
101
|
+
const navContext = React.useMemo(() => collapsible
|
|
102
|
+
? {
|
|
103
|
+
navId,
|
|
104
|
+
expanded,
|
|
105
|
+
toggle,
|
|
106
|
+
toggleRef,
|
|
107
|
+
onTogglePointerDown: () => {
|
|
108
|
+
togglePressed.current = true;
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
: null, [collapsible, navId, expanded, toggle]);
|
|
112
|
+
return (_jsx(AppShellNavContext.Provider, { value: navContext, children: _jsxs("div", { ref: rootRef, "data-helix-part": "app-shell-root", "data-collapsible": collapsible ? 'true' : undefined, className: cn(className), children: [sidenav && (_jsx("div", { ref: navRef, id: navId, "data-helix-part": "app-shell-nav", "data-expanded": expanded ? 'true' : 'false', onBlur: handleNavBlur, onClick: handleNavClick, children: sidenav })), _jsxs("div", { "data-helix-part": "app-shell-content", children: [topbar, _jsx("main", { "data-helix-part": "app-shell-main", children: children })] })] }) }));
|
|
6
113
|
};
|
|
7
114
|
AppShell.displayName = 'AppShell';
|
|
8
115
|
export { AppShell };
|
|
@@ -12,6 +12,12 @@ export interface AppShellProps {
|
|
|
12
12
|
topbar?: React.ReactNode;
|
|
13
13
|
/** The page's main content. */
|
|
14
14
|
children: React.ReactNode;
|
|
15
|
+
/** Controlled: whether the collapsed SideNav is open (below 768px only). Leave unset for uncontrolled (see `defaultSidenavExpanded`). */
|
|
16
|
+
sidenavExpanded?: boolean;
|
|
17
|
+
/** Initial open state of the collapsed SideNav, for uncontrolled usage. Default: false */
|
|
18
|
+
defaultSidenavExpanded?: boolean;
|
|
19
|
+
/** Fires whenever the collapsed SideNav opens or closes — the menu button, Escape, following a nav link or tabbing out of it. */
|
|
20
|
+
onSidenavExpandedChange?: (expanded: boolean) => void;
|
|
15
21
|
/** Additional className for the root. */
|
|
16
22
|
className?: string;
|
|
17
23
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** What a TopBar inside an AppShell needs to draw the menu button of the collapsed SideNav. */
|
|
3
|
+
export interface AppShellNavContextValue {
|
|
4
|
+
/** id of app-shell-nav — the menu button's aria-controls. */
|
|
5
|
+
navId: string;
|
|
6
|
+
/** Whether the collapsed SideNav is open — the menu button's aria-expanded. */
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
/** Opens/closes the collapsed SideNav. */
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
/** The menu button, so focus can return to it when the nav closes. */
|
|
11
|
+
toggleRef: React.RefObject<HTMLButtonElement | null>;
|
|
12
|
+
/** Marks a pointer press on the menu button, so the nav's focus-out doesn't close it just before the click toggles it. */
|
|
13
|
+
onTogglePointerDown: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const AppShellNavContext: React.Context<AppShellNavContextValue | null>;
|
|
16
|
+
export declare const useAppShellNav: () => AppShellNavContextValue | null;
|
|
17
|
+
//# sourceMappingURL=AppShellContext.d.ts.map
|
|
@@ -10,6 +10,7 @@ export const doc = {
|
|
|
10
10
|
tokens: [
|
|
11
11
|
{ part: 'side-nav-root', label: 'width', token: '--helix-sideNav-width', kind: 'space' },
|
|
12
12
|
{ part: 'side-nav-root', label: 'fill', token: '--helix-sideNav-fill', kind: 'color' },
|
|
13
|
+
{ part: 'side-nav-root', label: 'border-right', token: '--helix-sideNav-border', kind: 'color' },
|
|
13
14
|
{ part: 'side-nav-footer', label: 'border-top', token: '--helix-sideNav-border', kind: 'color' },
|
|
14
15
|
],
|
|
15
16
|
features: [
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { IconMenu2 } from '@tabler/icons-react';
|
|
3
4
|
import { cn } from '../../lib/utils.js';
|
|
5
|
+
import { IconButton } from '../../components/IconButton/index.js';
|
|
6
|
+
import { useAppShellNav } from '../AppShell/AppShellContext.js';
|
|
4
7
|
const TopBar = ({ start, end, className }) => {
|
|
5
|
-
|
|
8
|
+
// Inside an AppShell with a sidenav: the menu button that opens the collapsed SideNav. CSS only
|
|
9
|
+
// shows it below 768px of the shell's width.
|
|
10
|
+
const shellNav = useAppShellNav();
|
|
11
|
+
return (_jsxs("header", { "data-helix-part": "topbar-root", className: cn(className), children: [shellNav && (_jsx("div", { "data-helix-part": "topbar-menu", children: _jsx(IconButton, { ref: shellNav.toggleRef, variant: "ghost", size: "m", icon: IconMenu2, label: "Navigation menu", "aria-expanded": shellNav.expanded, "aria-controls": shellNav.navId, onPointerDown: shellNav.onTogglePointerDown, onClick: shellNav.toggle }) })), start && _jsx("div", { "data-helix-part": "topbar-start", children: start }), end && _jsx("div", { "data-helix-part": "topbar-end", children: end })] }));
|
|
6
12
|
};
|
|
7
13
|
TopBar.displayName = 'TopBar';
|
|
8
14
|
export { TopBar };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export type DialogTransitionState = 'closed' | 'open' | 'closing';
|
|
3
3
|
/**
|
|
4
|
-
* Shared open/close choreography for Modal and SidePanel — see
|
|
4
|
+
* Shared open/close choreography for Modal and SidePanel — see the Modal contract. Native `<dialog>` has no
|
|
5
5
|
* built-in "animate out, then actually close" behavior, so this orchestrates it in JS: `showModal()`
|
|
6
6
|
* immediately, then a `data-state="open"` flip one animation frame later (so the transition actually
|
|
7
7
|
* plays); on close, `data-state="closing"` first, then the real `.close()` after the component's own
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { resolveTokenPx } from './resolveTokenPx.js';
|
|
3
3
|
/**
|
|
4
|
-
* Shared open/close choreography for Modal and SidePanel — see
|
|
4
|
+
* Shared open/close choreography for Modal and SidePanel — see the Modal contract. Native `<dialog>` has no
|
|
5
5
|
* built-in "animate out, then actually close" behavior, so this orchestrates it in JS: `showModal()`
|
|
6
6
|
* immediately, then a `data-state="open"` flip one animation frame later (so the transition actually
|
|
7
7
|
* plays); on close, `data-state="closing"` first, then the real `.close()` after the component's own
|
|
@@ -7,7 +7,7 @@ export type DisclosureTransitionState = 'closed' | 'open' | 'closing';
|
|
|
7
7
|
* Why this exists: naively binding `<details open={isExpanded}>` and letting the browser's own click
|
|
8
8
|
* toggle drive it looks fine expanding, but collapsing never animates — the browser removes the `open`
|
|
9
9
|
* attribute synchronously the instant a click fires, which hides the panel's content before any CSS
|
|
10
|
-
* transition on grid-template-rows/opacity/filter gets a chance to run (same root cause
|
|
10
|
+
* transition on grid-template-rows/opacity/filter gets a chance to run (same root cause the Modal contract already
|
|
11
11
|
* solved for Modal/SidePanel's native <dialog>). The fix is the same shape: intercept the toggle, keep
|
|
12
12
|
* `open` true and drive a `data-state="closing"` attribute through the real collapse transition, and only
|
|
13
13
|
* flip `open` to false for real once the collapse duration token has elapsed.
|
|
@@ -7,7 +7,7 @@ import { resolveTokenPx } from './resolveTokenPx.js';
|
|
|
7
7
|
* Why this exists: naively binding `<details open={isExpanded}>` and letting the browser's own click
|
|
8
8
|
* toggle drive it looks fine expanding, but collapsing never animates — the browser removes the `open`
|
|
9
9
|
* attribute synchronously the instant a click fires, which hides the panel's content before any CSS
|
|
10
|
-
* transition on grid-template-rows/opacity/filter gets a chance to run (same root cause
|
|
10
|
+
* transition on grid-template-rows/opacity/filter gets a chance to run (same root cause the Modal contract already
|
|
11
11
|
* solved for Modal/SidePanel's native <dialog>). The fix is the same shape: intercept the toggle, keep
|
|
12
12
|
* `open` true and drive a `data-state="closing"` attribute through the real collapse transition, and only
|
|
13
13
|
* flip `open` to false for real once the collapse duration token has elapsed.
|
|
@@ -65,7 +65,7 @@ import { Icon } from '../Icon';
|
|
|
65
65
|
Until 2026-09-12, `Select.json`'s `select-chevron` was documented here as the one static exception —
|
|
66
66
|
`Select` wrapped a real native `<select>` (ADR-001), and a native listbox's open/closed state was never
|
|
67
67
|
exposed to CSS, so there was nothing to hook a rotation to. That's no longer true: `Select` was rebuilt on
|
|
68
|
-
the new `Menu` primitive (
|
|
68
|
+
the new `Menu` primitive (Menu's contract) — its trigger is a real `<button>` whose own React state (and
|
|
69
69
|
`aria-expanded`) knows exactly when the popup is open. The chevron now flips for real, using this exact
|
|
70
70
|
pattern, keyed off `[aria-expanded="true"]` on the trigger itself rather than a `data-state` attribute on a
|
|
71
71
|
separate `-root` part (see `globals.css`'s `[data-helix-part="select-trigger"][aria-expanded="true"] ~
|
|
@@ -7,9 +7,8 @@ when: "Deciding whether a component should use a Motion-based animation, and how
|
|
|
7
7
|
|
|
8
8
|
# Pattern: Motion effects
|
|
9
9
|
|
|
10
|
-
Governed by [ADR-007](../../docs/ADR/ADR-007-motion-engine.md) (
|
|
11
|
-
|
|
12
|
-
day after real debugging cost). Read ADR-007's two hard rules before using any of this — this file is the
|
|
10
|
+
Governed by [ADR-007](../../docs/ADR/ADR-007-motion-engine.md) (Motion replaced `liquid-gooey` the same
|
|
11
|
+
day it was adopted, after real debugging cost). Read ADR-007's two hard rules before using any of this — this file is the
|
|
13
12
|
day-to-day reference, the ADR is the reasoning.
|
|
14
13
|
|
|
15
14
|
## What's available
|
|
@@ -92,7 +91,6 @@ Switch/NavItem drift happened.
|
|
|
92
91
|
component's chevron icon (Accordion's `scaleY` flip). Plain CSS, not Motion, so it lives in its own
|
|
93
92
|
file rather than this table — read it before adding a chevron to any new expand/collapse component.
|
|
94
93
|
- [ADR-007](../../docs/ADR/ADR-007-motion-engine.md) — why Motion, what replaced `liquid-gooey` and why.
|
|
95
|
-
- [ADR-006](../../docs/ADR/ADR-006-liquid-motion-effects.md) — superseded, historical reasoning only.
|
|
96
94
|
- [ADR-005](../../docs/ADR/ADR-005-elevation-policy.md) — which components may ever carry a shadow (FAB's
|
|
97
95
|
`box-shadow` is now plain CSS, no special resolution needed).
|
|
98
96
|
- `packages/core/src/lib/resolveTokenPx.ts` — shared `getComputedStyle`-based numeric token resolver, used
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helixds/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Accessible React 19 design system — native HTML components, Tailwind CSS v4 and DTCG design tokens, with JSON contracts and an MCP server so AI coding agents use it without guessing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Marta Conde",
|
|
8
|
-
"homepage": "https://github.
|
|
8
|
+
"homepage": "https://martacondedesign.github.io/helixds/",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/MartaCondeDesign/helixds.git",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"./contracts/*": "./dist/contracts/*.json",
|
|
36
36
|
"./prop-map.md": "./dist/prop-map.md",
|
|
37
37
|
"./patterns/*": "./dist/patterns/*.md",
|
|
38
|
+
"./archetypes/*": "./dist/archetypes/*.md",
|
|
38
39
|
"./AGENTS.md": "./AGENTS.md",
|
|
39
40
|
"./package.json": "./package.json"
|
|
40
41
|
},
|
|
@@ -58,13 +59,34 @@
|
|
|
58
59
|
"echarts": "^6.1.0",
|
|
59
60
|
"motion": "13.2.0",
|
|
60
61
|
"tailwind-merge": "^2.5.0",
|
|
61
|
-
"@helixds/tokens": "0.
|
|
62
|
+
"@helixds/tokens": "0.2.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@types/react": "^19.0.0",
|
|
65
66
|
"@types/react-dom": "^19.0.0",
|
|
66
67
|
"typescript": "*"
|
|
67
68
|
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"react",
|
|
71
|
+
"design-system",
|
|
72
|
+
"component-library",
|
|
73
|
+
"ui",
|
|
74
|
+
"ui-components",
|
|
75
|
+
"tailwindcss",
|
|
76
|
+
"tailwind",
|
|
77
|
+
"accessibility",
|
|
78
|
+
"a11y",
|
|
79
|
+
"wcag",
|
|
80
|
+
"design-tokens",
|
|
81
|
+
"dtcg",
|
|
82
|
+
"dark-mode",
|
|
83
|
+
"storybook",
|
|
84
|
+
"ai",
|
|
85
|
+
"ai-agents",
|
|
86
|
+
"mcp",
|
|
87
|
+
"claude-code",
|
|
88
|
+
"cursor"
|
|
89
|
+
],
|
|
68
90
|
"scripts": {
|
|
69
91
|
"build": "tsc --project tsconfig.json && node scripts/fix-esm-imports.mjs && node scripts/copy-agent-docs.mjs",
|
|
70
92
|
"dev": "tsc --watch --project tsconfig.json",
|