@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Popover, read its contract: node_modules/@helixds/react/dist/contracts/Popover.json
|
|
4
|
+
* (every prop, which are required, when not to use it, the import line). Do not guess Helix props.
|
|
5
|
+
* Guide: node_modules/@helixds/react/AGENTS.md
|
|
6
|
+
*/
|
|
7
|
+
import type * as React from 'react';
|
|
8
|
+
export type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
export interface PopoverProps {
|
|
10
|
+
/** The panel's visible title — also its accessible name (aria-labelledby). */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The panel's content: text and, optionally, actions. */
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/** The control that opens and closes the panel (a Button or IconButton). Must forward onClick, ref-less ARIA attributes and focus to its DOM node. */
|
|
15
|
+
trigger: React.ReactElement;
|
|
16
|
+
/** Preferred side of the trigger — flips when there isn't room and is clamped to the viewport (the Tooltip contract). Default: 'bottom' */
|
|
17
|
+
placement?: PopoverPlacement;
|
|
18
|
+
/** Controlled open state. */
|
|
19
|
+
expanded?: boolean;
|
|
20
|
+
/** Uncontrolled initial open state. Default: false */
|
|
21
|
+
defaultExpanded?: boolean;
|
|
22
|
+
/** Called when the panel opens or closes (trigger, Escape, outside click). */
|
|
23
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
24
|
+
/** Additional className for the root. */
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Popover.types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Popover, read its contract: node_modules/@helixds/react/dist/contracts/Popover.json
|
|
4
|
+
* (every prop, which are required, when not to use it, the import line). Do not guess Helix props.
|
|
5
|
+
* Guide: node_modules/@helixds/react/AGENTS.md
|
|
6
|
+
*/
|
|
7
|
+
export { Popover } from './Popover.js';
|
|
8
|
+
export type { PopoverProps, PopoverPlacement } from './Popover.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,7 +3,7 @@ export const doc = {
|
|
|
3
3
|
purpose: 'Lets users switch between a small, fixed set of mutually exclusive modes or views, with no associated content panel.',
|
|
4
4
|
contract: 'contracts/components/SegmentedControl.json',
|
|
5
5
|
a11y: [
|
|
6
|
-
'`role="radiogroup"` on the root, `role="radio"` + `aria-checked` on each option — not `tablist`/`tab`, since there is no associated panel that changes content (see
|
|
6
|
+
'`role="radiogroup"` on the root, `role="radio"` + `aria-checked` on each option — not `tablist`/`tab`, since there is no associated panel that changes content (see the SegmentedControl contract).',
|
|
7
7
|
'Roving `tabIndex` — only the checked option is in the Tab order; arrow keys move both focus and selection between options.',
|
|
8
8
|
'`label` is required and becomes the group\'s `aria-label` — this control has no visible legend.',
|
|
9
9
|
],
|
|
@@ -30,7 +30,7 @@ export const doc = {
|
|
|
30
30
|
'value / defaultValue — controlled or uncontrolled selection',
|
|
31
31
|
'onChange — selection change handler',
|
|
32
32
|
'disabled — disables the whole group; individual options can also disable themselves',
|
|
33
|
-
'The sliding pill reuses NavItem/Switch\'s Motion layoutId + SPRING_SNAPPY pattern — see
|
|
33
|
+
'The sliding pill reuses NavItem/Switch\'s Motion layoutId + SPRING_SNAPPY pattern — see the SegmentedControl contract.',
|
|
34
34
|
],
|
|
35
35
|
examples: [
|
|
36
36
|
{
|
|
@@ -21,7 +21,7 @@ export function SegmentedControl({ label, options, value, defaultValue, onChange
|
|
|
21
21
|
onChange?.(optionValue);
|
|
22
22
|
};
|
|
23
23
|
// Roving tabindex + arrow-key navigation, hand-rolled — these are buttons, not native radio inputs,
|
|
24
|
-
// so the browser doesn't give this behavior away for free the way it does for RadioGroup (
|
|
24
|
+
// so the browser doesn't give this behavior away for free the way it does for RadioGroup (the SegmentedControl contract).
|
|
25
25
|
const handleKeyDown = (e, index) => {
|
|
26
26
|
const enabled = options.filter(o => !(o.disabled || disabled));
|
|
27
27
|
if (enabled.length === 0)
|
|
@@ -4,7 +4,7 @@ export const doc = {
|
|
|
4
4
|
contract: 'contracts/components/Select.json',
|
|
5
5
|
a11y: [
|
|
6
6
|
'The `label` prop is required. Use `placeholder` as a prompt, not as the selected value.',
|
|
7
|
-
'The trigger is a real `<button>`, not a native `<select>` — the dropdown is Helix\'s own `Menu` primitive (
|
|
7
|
+
'The trigger is a real `<button>`, not a native `<select>` — the dropdown is Helix\'s own `Menu` primitive (the Menu contract), keeping real DOM focus on the button and driving the popup via `aria-haspopup`/`aria-expanded`/`aria-controls`/`aria-activedescendant`.',
|
|
8
8
|
'Keyboard nav (Arrow Up/Down, Home/End, Enter/Space, Escape) is hand-rolled on the trigger, not native — see the contract\'s own keyboardNav list.',
|
|
9
9
|
],
|
|
10
10
|
variants: [],
|
|
@@ -48,7 +48,7 @@ export const doc = {
|
|
|
48
48
|
{ part: 'select-chevron', label: 'flip.easing.collapse', token: '--helix-select-easing-collapse', kind: 'space' },
|
|
49
49
|
],
|
|
50
50
|
features: [
|
|
51
|
-
'Button trigger + Helix-styled Menu popup (
|
|
51
|
+
'Button trigger + Helix-styled Menu popup (the Menu contract) — no native OS dropdown chrome, matches Helix\'s own visual language',
|
|
52
52
|
'One fixed size, deliberately — no size prop. 32px (semantic.size.m), the same height Menu items and Input/Textarea\'s own default use, so nothing needs picking.',
|
|
53
53
|
'fullWidth — stretches to container width',
|
|
54
54
|
'labelEnd on an option — short secondary text (a value, count or percentage) on the end edge of that option in the list; the trigger shows only the label',
|
|
@@ -57,7 +57,7 @@ export function Select({ label, options, value, defaultValue, onChange, placehol
|
|
|
57
57
|
};
|
|
58
58
|
// Hand-rolled roving keyboard nav on the trigger — Menu itself is deliberately non-focusable
|
|
59
59
|
// (real DOM focus stays on this button throughout, aria-activedescendant tracks the highlighted
|
|
60
|
-
// option), the same interaction model a native <select> gives away for free. See
|
|
60
|
+
// option), the same interaction model a native <select> gives away for free. See the Menu contract.
|
|
61
61
|
const handleTriggerKeyDown = (e) => {
|
|
62
62
|
if (disabled)
|
|
63
63
|
return;
|
|
@@ -3,7 +3,7 @@ export const doc = {
|
|
|
3
3
|
purpose: 'A modal panel anchored to the right edge of the viewport, for a persistent secondary task alongside the main page.',
|
|
4
4
|
contract: 'contracts/components/SidePanel.json',
|
|
5
5
|
a11y: [
|
|
6
|
-
'Same native <dialog> + showModal() primitive as Modal — focus trap, Escape-to-close, top-layer stacking (see
|
|
6
|
+
'Same native <dialog> + showModal() primitive as Modal — focus trap, Escape-to-close, top-layer stacking (see the Modal contract). No backdrop scrim, unlike Modal — the page behind stays visible.',
|
|
7
7
|
'The title is referenced via aria-labelledby, giving the panel its accessible name.',
|
|
8
8
|
'SidePanel never closes itself — it always calls onDismiss and expects the consumer to set expanded to false.',
|
|
9
9
|
],
|
|
@@ -14,7 +14,7 @@ export interface SidePanelProps {
|
|
|
14
14
|
label: string;
|
|
15
15
|
/** The panel's body content. */
|
|
16
16
|
children: React.ReactNode;
|
|
17
|
-
/** Whether the panel is open. Always controlled — see
|
|
17
|
+
/** Whether the panel is open. Always controlled — see the Modal contract. */
|
|
18
18
|
expanded: boolean;
|
|
19
19
|
/** Called when the panel should close (close button, Escape, or a backdrop click). SidePanel never closes itself — set `expanded` to false in response. */
|
|
20
20
|
onDismiss: () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Tabs, read its contract: node_modules/@helixds/react/dist/contracts/Tabs.json
|
|
4
|
+
* (every prop, which are required, when not to use it, the import line). Do not guess Helix props.
|
|
5
|
+
* Guide: node_modules/@helixds/react/AGENTS.md
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import type { TabsProps } from './Tabs.types.js';
|
|
9
|
+
export declare function Tabs({ label, options, value, defaultValue, onChange, children, className }: TabsProps): React.JSX.Element;
|
|
10
|
+
export declare namespace Tabs {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Tabs.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const doc = {
|
|
2
|
+
name: 'Tabs',
|
|
3
|
+
purpose: 'Switches between sections of related content inside one page: a row of tabs, with an optional panel slot under it for whatever the selected tab shows.',
|
|
4
|
+
contract: 'contracts/components/Tabs.json',
|
|
5
|
+
a11y: [
|
|
6
|
+
'`role="tablist"` on the row, `role="tab"` + `aria-selected` + `aria-controls` on each tab, `role="tabpanel"` + `aria-labelledby` on the panel slot, labelled by the selected tab (the Tabs contract). With no children there is no tabpanel and no `aria-controls`.',
|
|
7
|
+
'Roving `tabIndex` with automatic activation — only the selected tab is in the Tab order; Arrow Left/Right (wrapping) and Home/End move focus and select at once. Disabled tabs are skipped.',
|
|
8
|
+
'The panel has `tabIndex={0}`, so Tab moves from the tab row into the panel even when it holds no focusable element.',
|
|
9
|
+
'`label` is required and becomes the tablist\'s `aria-label` — the row has no visible heading.',
|
|
10
|
+
],
|
|
11
|
+
variants: [],
|
|
12
|
+
sizes: [],
|
|
13
|
+
tokens: [
|
|
14
|
+
{ part: 'tabs-tab-label', label: 'Default text', token: '--helix-tabs-text-default', kind: 'color', colorRole: 'text' },
|
|
15
|
+
{ part: 'tabs-tab-label', label: 'Selected text', token: '--helix-tabs-text-selected', kind: 'color', colorRole: 'text', meta: 'aria-selected="true", and hover' },
|
|
16
|
+
{ part: 'tabs-tab-label', label: 'Disabled text', token: '--helix-tabs-text-disabled', kind: 'color', colorRole: 'text', state: 'disabled' },
|
|
17
|
+
{ part: 'tabs-indicator', label: 'Indicator', token: '--helix-tabs-indicator', kind: 'color', colorRole: 'background' },
|
|
18
|
+
{ part: 'tabs-indicator', label: 'indicator.height', token: '--helix-tabs-indicatorWidth', kind: 'space' },
|
|
19
|
+
{ part: 'tabs-list', label: 'Bottom border', token: '--helix-tabs-border', kind: 'color', colorRole: 'border' },
|
|
20
|
+
{ part: 'tabs-list', label: 'border width', token: '--helix-tabs-borderWidth', kind: 'space' },
|
|
21
|
+
{ part: 'tabs-list', label: 'gap', token: '--helix-tabs-gap', kind: 'space', axis: 'horizontal' },
|
|
22
|
+
{ part: 'tabs-tab', label: 'tab.height', token: '--helix-tabs-height', kind: 'space', meta: 'semantic.size.m' },
|
|
23
|
+
{ part: 'tabs-tab', label: 'tab.paddingX', token: '--helix-tabs-paddingX', kind: 'space', axis: 'horizontal' },
|
|
24
|
+
{ part: 'tabs-tab', label: 'tab.fontSize', token: '--helix-tabs-fontSize', kind: 'typography' },
|
|
25
|
+
{ part: 'tabs-tab', label: 'tab.fontWeight', token: '--helix-tabs-fontWeight', kind: 'typography' },
|
|
26
|
+
{ part: 'tabs-panel', label: 'space above the panel', token: '--helix-tabs-panelGap', kind: 'space', padding: 'top' },
|
|
27
|
+
],
|
|
28
|
+
features: [
|
|
29
|
+
'label — required, the tablist\'s accessible name',
|
|
30
|
+
'options — array of { value, label, icon?, disabled? }',
|
|
31
|
+
'children — the panel slot: any content, swapped by the consumer from `value`; leave it out for only the tab row',
|
|
32
|
+
'value / defaultValue — controlled or uncontrolled; defaults to the first enabled tab',
|
|
33
|
+
'onChange — called when the selected tab changes',
|
|
34
|
+
'The indicator slides between tabs with Motion layoutId + SPRING_SNAPPY, like NavItem and SegmentedControl.',
|
|
35
|
+
],
|
|
36
|
+
examples: [
|
|
37
|
+
{
|
|
38
|
+
label: 'Default',
|
|
39
|
+
code: `<Tabs label="Project" options={[{ value: 'overview', label: 'Overview' }, { value: 'activity', label: 'Activity' }, { value: 'settings', label: 'Settings' }]} value={tab} onChange={setTab}>\n {tab === 'overview' ? <Overview /> : tab === 'activity' ? <Activity /> : <Settings />}\n</Tabs>`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: 'Tabs only',
|
|
43
|
+
code: `<Tabs label="Project" options={options} value={tab} onChange={setTab} />`,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Tabs.doc.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { motion, MotionConfig } from 'motion/react';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
|
+
import { Icon } from '../Icon/index.js';
|
|
6
|
+
import { SPRING_SNAPPY } from '../../lib/motionPresets.js';
|
|
7
|
+
export function Tabs({ label, options, value, defaultValue, onChange, children, className }) {
|
|
8
|
+
// One id per instance: it scopes the tab/panel ids and the indicator's layoutId, so two Tabs on the
|
|
9
|
+
// same page never share Motion's FLIP animation.
|
|
10
|
+
const uid = `helix-tabs-${React.useId()}`;
|
|
11
|
+
const layoutId = `${uid}-indicator`;
|
|
12
|
+
const panelId = `${uid}-panel`;
|
|
13
|
+
// The panel is a slot: no children, no tabpanel — Tabs is then only the tab row.
|
|
14
|
+
const hasPanel = children !== undefined && children !== null && children !== false;
|
|
15
|
+
const isControlled = value !== undefined;
|
|
16
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue ?? options.find(o => !o.disabled)?.value);
|
|
17
|
+
const current = isControlled ? value : internalValue;
|
|
18
|
+
const tabRefs = React.useRef(new Map());
|
|
19
|
+
const select = (optionValue) => {
|
|
20
|
+
if (optionValue === current)
|
|
21
|
+
return;
|
|
22
|
+
if (!isControlled)
|
|
23
|
+
setInternalValue(optionValue);
|
|
24
|
+
onChange?.(optionValue);
|
|
25
|
+
};
|
|
26
|
+
// APG tabs with automatic activation (the Tabs contract): the arrow keys move focus and select in one step.
|
|
27
|
+
// Roving tabindex is hand-rolled — these are buttons, nothing native gives it for free.
|
|
28
|
+
const handleKeyDown = (e, optionValue) => {
|
|
29
|
+
const enabled = options.filter(o => !o.disabled);
|
|
30
|
+
if (enabled.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
const index = enabled.findIndex(o => o.value === optionValue);
|
|
33
|
+
let nextIndex;
|
|
34
|
+
if (e.key === 'ArrowRight')
|
|
35
|
+
nextIndex = (index + 1) % enabled.length;
|
|
36
|
+
else if (e.key === 'ArrowLeft')
|
|
37
|
+
nextIndex = (index - 1 + enabled.length) % enabled.length;
|
|
38
|
+
else if (e.key === 'Home')
|
|
39
|
+
nextIndex = 0;
|
|
40
|
+
else if (e.key === 'End')
|
|
41
|
+
nextIndex = enabled.length - 1;
|
|
42
|
+
else
|
|
43
|
+
return;
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
const next = enabled[nextIndex];
|
|
46
|
+
select(next.value);
|
|
47
|
+
tabRefs.current.get(next.value)?.focus();
|
|
48
|
+
};
|
|
49
|
+
// MotionConfig scoped locally — Motion doesn't honor prefers-reduced-motion on its own (ADR-007).
|
|
50
|
+
return (_jsx(MotionConfig, { reducedMotion: "user", children: _jsxs("div", { "data-helix-part": "tabs-root", className: cn(className), children: [_jsx("div", { "data-helix-part": "tabs-list", role: "tablist", "aria-label": label, children: options.map(opt => {
|
|
51
|
+
const isSelected = opt.value === current;
|
|
52
|
+
return (_jsxs("button", { ref: el => {
|
|
53
|
+
if (el)
|
|
54
|
+
tabRefs.current.set(opt.value, el);
|
|
55
|
+
else
|
|
56
|
+
tabRefs.current.delete(opt.value);
|
|
57
|
+
}, type: "button", role: "tab", id: `${uid}-tab-${opt.value}`, "aria-selected": isSelected, "aria-controls": hasPanel && isSelected ? panelId : undefined, tabIndex: isSelected ? 0 : -1, disabled: opt.disabled, "data-helix-part": "tabs-tab", onClick: () => select(opt.value), onKeyDown: e => handleKeyDown(e, opt.value), children: [opt.icon && (_jsx("span", { "data-helix-part": "tabs-tab-icon", children: _jsx(Icon, { icon: opt.icon, size: 16 }) })), _jsx("span", { "data-helix-part": "tabs-tab-label", children: opt.label }), isSelected && (_jsx(motion.span, { "data-helix-part": "tabs-indicator", layoutId: layoutId, "aria-hidden": "true", transition: SPRING_SNAPPY }))] }, opt.value));
|
|
58
|
+
}) }), hasPanel && (_jsx("div", { id: panelId, role: "tabpanel", "aria-labelledby": current !== undefined ? `${uid}-tab-${current}` : undefined, tabIndex: 0, "data-helix-part": "tabs-panel", children: children }))] }) }));
|
|
59
|
+
}
|
|
60
|
+
Tabs.displayName = 'Tabs';
|
|
61
|
+
//# sourceMappingURL=Tabs.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Tabs, read its contract: node_modules/@helixds/react/dist/contracts/Tabs.json
|
|
4
|
+
* (every prop, which are required, when not to use it, the import line). Do not guess Helix props.
|
|
5
|
+
* Guide: node_modules/@helixds/react/AGENTS.md
|
|
6
|
+
*/
|
|
7
|
+
import type * as React from 'react';
|
|
8
|
+
import type { HelixIconComponent } from '../Icon/index.js';
|
|
9
|
+
export interface TabsOption {
|
|
10
|
+
value: string;
|
|
11
|
+
/** The tab's visible text. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Optional icon before the label: the Tabler icon component (not an element), rendered through Icon. */
|
|
14
|
+
icon?: HelixIconComponent;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TabsProps {
|
|
18
|
+
/** Accessible name for the tab row (aria-label on the tablist). */
|
|
19
|
+
label: string;
|
|
20
|
+
options: TabsOption[];
|
|
21
|
+
/** Controlled selected tab. */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** Uncontrolled initial tab. Defaults to the first enabled option. */
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
onChange?: (value: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* The panel: a free slot under the tab row, wrapped in one role="tabpanel" labelled by the selected tab.
|
|
28
|
+
* Put anything in it and swap it with `value`/`onChange`. Leave it out and Tabs is only the tab row.
|
|
29
|
+
*/
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=Tabs.types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Tabs, read its contract: node_modules/@helixds/react/dist/contracts/Tabs.json
|
|
4
|
+
* (every prop, which are required, when not to use it, the import line). Do not guess Helix props.
|
|
5
|
+
* Guide: node_modules/@helixds/react/AGENTS.md
|
|
6
|
+
*/
|
|
7
|
+
export { Tabs } from './Tabs.js';
|
|
8
|
+
export type { TabsProps, TabsOption } from './Tabs.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -19,7 +19,7 @@ export const doc = {
|
|
|
19
19
|
{ part: 'toast', label: 'fill', token: '--helix-toast-fill', kind: 'color' },
|
|
20
20
|
{ part: 'toast-title', label: 'text', token: '--helix-toast-text', kind: 'color' },
|
|
21
21
|
{ part: 'toast-description', label: 'text', token: '--helix-toast-textDescription', kind: 'color' },
|
|
22
|
-
{ part: 'toast-icon', label: 'color (per variant)', token: '--helix-badge-icon-{variant}', kind: 'color', meta: 'Reused from Badge — the only place variant color shows, per
|
|
22
|
+
{ part: 'toast-icon', label: 'color (per variant)', token: '--helix-badge-icon-{variant}', kind: 'color', meta: 'Reused from Badge — the only place variant color shows, per the Toast contract.' },
|
|
23
23
|
{ part: 'toast', label: 'shadow', token: '--helix-toast-shadow', kind: 'shadow' },
|
|
24
24
|
],
|
|
25
25
|
features: [
|
|
@@ -9,7 +9,7 @@ import { resolveTokenPx } from '../../lib/resolveTokenPx.js';
|
|
|
9
9
|
import { subscribeToasts, removeToast, toast } from './toastStore.js';
|
|
10
10
|
export { toast } from './toastStore.js';
|
|
11
11
|
// Real Filled Tabler icons, fixed per variant — not caller-supplied like Badge's own `icon` prop
|
|
12
|
-
// (
|
|
12
|
+
// (the Toast contract). neutral/info share IconInfoCircleFilled; danger uses the hexagon shape explicitly
|
|
13
13
|
// asked for over Tabler's more common 8-sided IconAlertOctagonFilled.
|
|
14
14
|
const ICON_BY_VARIANT = {
|
|
15
15
|
neutral: IconInfoCircleFilled,
|
|
@@ -86,7 +86,7 @@ const Toast = ({ className }) => {
|
|
|
86
86
|
const depthById = new Map(ordered.slice(0, MAX_VISIBLE).map((r, i) => [r.id, i]));
|
|
87
87
|
// Both offsets are measured (offsetHeight), not `peek * depth` / `100% * depth` — fixed multiples
|
|
88
88
|
// broke as soon as two toasts had different heights (a 2-line description vs. a 1-line one), since
|
|
89
|
-
// each only knows its own height, not the one actually sitting above it. See
|
|
89
|
+
// each only knows its own height, not the one actually sitting above it. See the Toast contract / the approved
|
|
90
90
|
// preview's own bugfix for the spread case; the collapsed "peek" case has the same root cause and
|
|
91
91
|
// needs the same treatment (reported separately, after the spread fix already shipped).
|
|
92
92
|
React.useLayoutEffect(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plain module-level pub-sub, not React context — see
|
|
2
|
+
* Plain module-level pub-sub, not React context — see the Toast contract. `toast.*` needs to work from anywhere
|
|
3
3
|
* (an event handler, a fetch `.then()`, code with no component tree access at all), which a
|
|
4
4
|
* context-based store can't offer since it only exists inside whatever subtree provides it.
|
|
5
5
|
*/
|
|
@@ -22,7 +22,7 @@ export const doc = {
|
|
|
22
22
|
],
|
|
23
23
|
features: [
|
|
24
24
|
'label — the tooltip text (short, plain text only)',
|
|
25
|
-
'placement — top/bottom/left/right, a preference: auto-flips to the opposite side (and clamps sideways) if that would clip the viewport (see
|
|
25
|
+
'placement — top/bottom/left/right, a preference: auto-flips to the opposite side (and clamps sideways) if that would clip the viewport (see the Tooltip contract)',
|
|
26
26
|
'expanded — forces the content visible or hidden regardless of hover/focus, for a controlled/always-shown case',
|
|
27
27
|
],
|
|
28
28
|
examples: [
|
|
@@ -3,10 +3,10 @@ import * as React from 'react';
|
|
|
3
3
|
import { cn } from '../../lib/utils.js';
|
|
4
4
|
let idCounter = 0;
|
|
5
5
|
// Keeps the tooltip content this many px clear of the viewport edge — "would clip" means "would land
|
|
6
|
-
// inside this gutter", not just literal negative coordinates. See
|
|
6
|
+
// inside this gutter", not just literal negative coordinates. See the Tooltip contract.
|
|
7
7
|
const EDGE_GUTTER = 8;
|
|
8
8
|
/**
|
|
9
|
-
* Flip + clamp collision detection — see
|
|
9
|
+
* Flip + clamp collision detection — see the Tooltip contract. Runs regardless of hover/focus state: the content is
|
|
10
10
|
* always laid out (`visibility: hidden`, never `display: none`), so it's measurable before it's ever
|
|
11
11
|
* shown. Recomputed on mount, on resize, and on any ancestor scroll (capture phase).
|
|
12
12
|
*/
|
|
@@ -75,16 +75,16 @@ const Tooltip = ({ label, children, placement = 'top', expanded, className }) =>
|
|
|
75
75
|
const contentRef = React.useRef(null);
|
|
76
76
|
const { placement: resolvedPlacement, shift } = useAutoPlacement(rootRef, contentRef, placement);
|
|
77
77
|
// `expanded` is undefined by default (normal :hover/:focus-within driven show/hide, no attribute
|
|
78
|
-
// set at all); true/false force it on/off regardless of interaction — see
|
|
78
|
+
// set at all); true/false force it on/off regardless of interaction — see the Tooltip contract.
|
|
79
79
|
// Escape dismisses the tooltip but leaves focus on the trigger (WCAG 1.4.13 dismissible, 2.4.3 focus
|
|
80
80
|
// order): blurring it instead would drop a keyboard user back to the top of the page. The dismissal
|
|
81
81
|
// lasts until focus or the pointer leaves, so the next hover/focus shows it again.
|
|
82
82
|
const [dismissed, setDismissed] = React.useState(false);
|
|
83
83
|
const forcedState = expanded !== undefined ? (expanded ? 'true' : 'false') : dismissed ? 'false' : undefined;
|
|
84
84
|
const handleKeyDown = (event) => {
|
|
85
|
-
// The one piece of JS this component needs for show/hide (
|
|
85
|
+
// The one piece of JS this component needs for show/hide (the Tooltip contract) — CSS :hover/:focus-within
|
|
86
86
|
// can't hear a keypress. Visibility otherwise stays in CSS. (Auto-placement above is separate —
|
|
87
|
-
// see
|
|
87
|
+
// see the Tooltip contract — and runs independently of show/hide.)
|
|
88
88
|
if (event.key === 'Escape')
|
|
89
89
|
setDismissed(true);
|
|
90
90
|
};
|
|
@@ -11,7 +11,7 @@ export interface TooltipProps {
|
|
|
11
11
|
label: string;
|
|
12
12
|
/** The trigger — whatever the tooltip describes (an icon, an avatar, an icon-only button). Must accept and forward `aria-describedby` to its rendered DOM node. */
|
|
13
13
|
children: React.ReactElement;
|
|
14
|
-
/** Which side of the trigger the content renders on. Fixed offset, no auto-flip on viewport edge (see
|
|
14
|
+
/** Which side of the trigger the content renders on. Fixed offset, no auto-flip on viewport edge (see the Tooltip contract). Default: 'top' */
|
|
15
15
|
placement?: TooltipPlacement;
|
|
16
16
|
/** Forces the content visible (`true`) or hidden (`false`) regardless of hover/focus — for a controlled/always-shown case. Leave unset for the normal hover/focus-driven behavior. */
|
|
17
17
|
expanded?: boolean;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
"purpose": "A single collapsible disclosure — a header that expands/collapses a panel of content, with no JS height measurement needed.",
|
|
8
8
|
"import": "import { Accordion } from '@helixds/react';",
|
|
9
|
+
"archetype": "data-display",
|
|
9
10
|
|
|
10
11
|
"neverUseFor": [
|
|
11
12
|
"A single always-visible section — just render the content directly",
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
"Hiding required/critical content the user must always see"
|
|
14
15
|
],
|
|
15
16
|
|
|
16
|
-
"rationale": "Accordion is built on native <details>/<summary
|
|
17
|
+
"rationale": "Accordion is built on native <details>/<summary>, so toggling, keyboard activation and the expanded state come from the browser with no hand-rolled ARIA. The panel's height is measured in JS and animated as an explicit pixel height, not with a grid-template-rows 0fr/1fr transition, because fr interpolation didn't move at the same pace in both directions and the collapse looked laggy. The chevron and the panel share one duration by design: duration-expand, duration-collapse and duration-chevron are all 250ms, so the chevron finishes turning exactly when the panel finishes opening or closing. Change all three together, or the sync breaks. They stay three tokens rather than one because the panel and the chevron are separate parts that could diverge in a later redesign, and each token names the CSS property it drives. 250ms sits between semantic.duration slow (200ms) and slower (300ms) on purpose, quick enough for repeated toggling and slow enough to read as a reveal, not a snap. It stays a component literal: one component reusing a value doesn't meet the bar of 3+ components sharing it that would justify a new semantic rung.",
|
|
17
18
|
|
|
18
19
|
"governance": {
|
|
19
20
|
"mayExtendLocally": [
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
],
|
|
24
25
|
"mustEscalateToDS": [
|
|
25
26
|
"Replacing <details>/<summary> with a div + button disclosure",
|
|
26
|
-
"Changing the open/close animation timing or easing (
|
|
27
|
+
"Changing the open/close animation timing or easing (see rationale)",
|
|
27
28
|
"Adding exclusive 'only one open' group behavior or new visual variants"
|
|
28
29
|
]
|
|
29
30
|
},
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
{ "part": "accordion-title", "element": "span", "description": "The header's text label." },
|
|
43
44
|
{ "part": "accordion-chevron", "element": "span", "description": "Wraps a Tabler chevron-down icon (via the Icon component) — flips vertically (scaleY) between closed (v) and open (^). This is the canonical Helix expand/collapse chevron treatment — see .ai/maps/patterns/expand-collapse-chevron.md before adding a chevron to any other hand-rolled disclosure component." },
|
|
44
45
|
{ "part": "accordion-panel", "element": "div", "description": "JS-measured explicit pixel height on open/close, not grid-template-rows 0fr/1fr — 'fr' unit interpolation didn't track the same visual pace in both directions, which read as a laggy collapse." },
|
|
45
|
-
{ "part": "accordion-panel-inner", "element": "div", "description": "
|
|
46
|
+
{ "part": "accordion-panel-inner", "element": "div", "description": "Holds the content and its padding; fades and un-blurs it in on open and back out on close, on the same duration as the panel's height. The clipping is done by accordion-panel (overflow: hidden)." }
|
|
46
47
|
],
|
|
47
48
|
|
|
48
49
|
"props": [
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
"sizing": {
|
|
59
60
|
"width": { "default": "fill", "note": "Fills its container width, matching Card." },
|
|
60
|
-
"height": { "mode": "content-driven", "note": "Header height is content-driven; panel height
|
|
61
|
+
"height": { "mode": "content-driven", "note": "Header height is content-driven; panel height is measured in JS and animated as an explicit pixel height, no fixed rung." }
|
|
61
62
|
},
|
|
62
63
|
|
|
63
64
|
"tokenPolicy": {
|