@helixds/react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +292 -0
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/components/Accordion/Accordion.d.ts +14 -0
- package/dist/components/Accordion/Accordion.doc.d.ts +4 -0
- package/dist/components/Accordion/Accordion.doc.js +27 -0
- package/dist/components/Accordion/Accordion.js +76 -0
- package/dist/components/Accordion/Accordion.types.d.ts +24 -0
- package/dist/components/Accordion/Accordion.types.js +2 -0
- package/dist/components/Accordion/index.d.ts +9 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Avatar/Avatar.d.ts +14 -0
- package/dist/components/Avatar/Avatar.doc.d.ts +4 -0
- package/dist/components/Avatar/Avatar.doc.js +34 -0
- package/dist/components/Avatar/Avatar.js +14 -0
- package/dist/components/Avatar/Avatar.types.d.ts +20 -0
- package/dist/components/Avatar/Avatar.types.js +2 -0
- package/dist/components/Avatar/index.d.ts +9 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +14 -0
- package/dist/components/AvatarGroup/AvatarGroup.doc.d.ts +4 -0
- package/dist/components/AvatarGroup/AvatarGroup.doc.js +30 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +15 -0
- package/dist/components/AvatarGroup/AvatarGroup.types.d.ts +21 -0
- package/dist/components/AvatarGroup/AvatarGroup.types.js +2 -0
- package/dist/components/AvatarGroup/index.d.ts +9 -0
- package/dist/components/AvatarGroup/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +16 -0
- package/dist/components/Badge/Badge.doc.d.ts +4 -0
- package/dist/components/Badge/Badge.doc.js +69 -0
- package/dist/components/Badge/Badge.js +23 -0
- package/dist/components/Badge/Badge.types.d.ts +22 -0
- package/dist/components/Badge/Badge.types.js +2 -0
- package/dist/components/Badge/index.d.ts +9 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Button/Button.d.ts +11 -0
- package/dist/components/Button/Button.doc.d.ts +4 -0
- package/dist/components/Button/Button.doc.js +98 -0
- package/dist/components/Button/Button.js +80 -0
- package/dist/components/Button/Button.types.d.ts +29 -0
- package/dist/components/Button/Button.types.js +2 -0
- package/dist/components/Button/index.d.ts +9 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.doc.d.ts +4 -0
- package/dist/components/Card/Card.doc.js +44 -0
- package/dist/components/Card/Card.js +9 -0
- package/dist/components/Card/Card.types.d.ts +19 -0
- package/dist/components/Card/Card.types.js +2 -0
- package/dist/components/Card/index.d.ts +9 -0
- package/dist/components/Card/index.js +2 -0
- package/dist/components/Chart/Chart.d.ts +14 -0
- package/dist/components/Chart/Chart.doc.d.ts +4 -0
- package/dist/components/Chart/Chart.doc.js +49 -0
- package/dist/components/Chart/Chart.js +184 -0
- package/dist/components/Chart/Chart.types.d.ts +21 -0
- package/dist/components/Chart/Chart.types.js +2 -0
- package/dist/components/Chart/index.d.ts +9 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +12 -0
- package/dist/components/Checkbox/Checkbox.doc.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.doc.js +54 -0
- package/dist/components/Checkbox/Checkbox.js +23 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +22 -0
- package/dist/components/Checkbox/Checkbox.types.js +2 -0
- package/dist/components/Checkbox/index.d.ts +9 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +13 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.doc.d.ts +4 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.doc.js +56 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.js +27 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +28 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.js +2 -0
- package/dist/components/CheckboxGroup/index.d.ts +9 -0
- package/dist/components/CheckboxGroup/index.js +2 -0
- package/dist/components/Chip/Chip.d.ts +11 -0
- package/dist/components/Chip/Chip.doc.d.ts +4 -0
- package/dist/components/Chip/Chip.doc.js +105 -0
- package/dist/components/Chip/Chip.js +30 -0
- package/dist/components/Chip/Chip.types.d.ts +31 -0
- package/dist/components/Chip/Chip.types.js +2 -0
- package/dist/components/Chip/index.d.ts +9 -0
- package/dist/components/Chip/index.js +2 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +12 -0
- package/dist/components/ChipGroup/ChipGroup.doc.d.ts +4 -0
- package/dist/components/ChipGroup/ChipGroup.doc.js +31 -0
- package/dist/components/ChipGroup/ChipGroup.js +9 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +27 -0
- package/dist/components/ChipGroup/ChipGroup.types.js +2 -0
- package/dist/components/ChipGroup/index.d.ts +9 -0
- package/dist/components/ChipGroup/index.js +2 -0
- package/dist/components/FAB/FAB.d.ts +11 -0
- package/dist/components/FAB/FAB.doc.d.ts +4 -0
- package/dist/components/FAB/FAB.doc.js +52 -0
- package/dist/components/FAB/FAB.js +133 -0
- package/dist/components/FAB/FAB.types.d.ts +37 -0
- package/dist/components/FAB/FAB.types.js +2 -0
- package/dist/components/FAB/index.d.ts +9 -0
- package/dist/components/FAB/index.js +2 -0
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/Icon/Icon.doc.d.ts +4 -0
- package/dist/components/Icon/Icon.doc.js +38 -0
- package/dist/components/Icon/Icon.js +15 -0
- package/dist/components/Icon/Icon.types.d.ts +47 -0
- package/dist/components/Icon/Icon.types.js +2 -0
- package/dist/components/Icon/createIconAdapter.d.ts +24 -0
- package/dist/components/Icon/createIconAdapter.js +28 -0
- package/dist/components/Icon/iconStroke.d.ts +20 -0
- package/dist/components/Icon/iconStroke.js +54 -0
- package/dist/components/Icon/index.d.ts +12 -0
- package/dist/components/Icon/index.js +4 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/IconButton/IconButton.doc.d.ts +4 -0
- package/dist/components/IconButton/IconButton.doc.js +76 -0
- package/dist/components/IconButton/IconButton.js +20 -0
- package/dist/components/IconButton/IconButton.types.d.ts +25 -0
- package/dist/components/IconButton/IconButton.types.js +2 -0
- package/dist/components/IconButton/index.d.ts +9 -0
- package/dist/components/IconButton/index.js +2 -0
- package/dist/components/Input/Input.d.ts +11 -0
- package/dist/components/Input/Input.doc.d.ts +4 -0
- package/dist/components/Input/Input.doc.js +68 -0
- package/dist/components/Input/Input.js +48 -0
- package/dist/components/Input/Input.types.d.ts +36 -0
- package/dist/components/Input/Input.types.js +2 -0
- package/dist/components/Input/index.d.ts +9 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Menu/Menu.doc.d.ts +4 -0
- package/dist/components/Menu/Menu.doc.js +46 -0
- package/dist/components/Menu/Menu.js +105 -0
- package/dist/components/Menu/Menu.types.d.ts +34 -0
- package/dist/components/Menu/Menu.types.js +2 -0
- package/dist/components/Menu/index.d.ts +9 -0
- package/dist/components/Menu/index.js +2 -0
- package/dist/components/Modal/Modal.d.ts +14 -0
- package/dist/components/Modal/Modal.doc.d.ts +4 -0
- package/dist/components/Modal/Modal.doc.js +52 -0
- package/dist/components/Modal/Modal.js +30 -0
- package/dist/components/Modal/Modal.types.d.ts +36 -0
- package/dist/components/Modal/Modal.types.js +2 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +2 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +17 -0
- package/dist/components/MultiSelect/MultiSelect.doc.d.ts +4 -0
- package/dist/components/MultiSelect/MultiSelect.doc.js +37 -0
- package/dist/components/MultiSelect/MultiSelect.js +165 -0
- package/dist/components/MultiSelect/MultiSelect.types.d.ts +50 -0
- package/dist/components/MultiSelect/MultiSelect.types.js +2 -0
- package/dist/components/MultiSelect/index.d.ts +9 -0
- package/dist/components/MultiSelect/index.js +2 -0
- package/dist/components/NavItem/NavItem.d.ts +14 -0
- package/dist/components/NavItem/NavItem.doc.d.ts +4 -0
- package/dist/components/NavItem/NavItem.doc.js +31 -0
- package/dist/components/NavItem/NavItem.js +21 -0
- package/dist/components/NavItem/NavItem.types.d.ts +20 -0
- package/dist/components/NavItem/NavItem.types.js +2 -0
- package/dist/components/NavItem/index.d.ts +9 -0
- package/dist/components/NavItem/index.js +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +14 -0
- package/dist/components/RadioButton/RadioButton.doc.d.ts +4 -0
- package/dist/components/RadioButton/RadioButton.doc.js +35 -0
- package/dist/components/RadioButton/RadioButton.js +15 -0
- package/dist/components/RadioButton/RadioButton.types.d.ts +33 -0
- package/dist/components/RadioButton/RadioButton.types.js +2 -0
- package/dist/components/RadioButton/index.d.ts +9 -0
- package/dist/components/RadioButton/index.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -0
- package/dist/components/RadioGroup/RadioGroup.doc.d.ts +4 -0
- package/dist/components/RadioGroup/RadioGroup.doc.js +80 -0
- package/dist/components/RadioGroup/RadioGroup.js +19 -0
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +28 -0
- package/dist/components/RadioGroup/RadioGroup.types.js +2 -0
- package/dist/components/RadioGroup/index.d.ts +9 -0
- package/dist/components/RadioGroup/index.js +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +13 -0
- package/dist/components/SegmentedControl/SegmentedControl.doc.d.ts +4 -0
- package/dist/components/SegmentedControl/SegmentedControl.doc.js +50 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +64 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +26 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.js +2 -0
- package/dist/components/SegmentedControl/index.d.ts +9 -0
- package/dist/components/SegmentedControl/index.js +2 -0
- package/dist/components/Select/Select.d.ts +13 -0
- package/dist/components/Select/Select.doc.d.ts +4 -0
- package/dist/components/Select/Select.doc.js +66 -0
- package/dist/components/Select/Select.js +138 -0
- package/dist/components/Select/Select.types.d.ts +36 -0
- package/dist/components/Select/Select.types.js +2 -0
- package/dist/components/Select/index.d.ts +9 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidePanel/SidePanel.d.ts +14 -0
- package/dist/components/SidePanel/SidePanel.doc.d.ts +4 -0
- package/dist/components/SidePanel/SidePanel.doc.js +29 -0
- package/dist/components/SidePanel/SidePanel.js +19 -0
- package/dist/components/SidePanel/SidePanel.types.d.ts +28 -0
- package/dist/components/SidePanel/SidePanel.types.js +2 -0
- package/dist/components/SidePanel/index.d.ts +9 -0
- package/dist/components/SidePanel/index.js +2 -0
- package/dist/components/Switch/Switch.d.ts +13 -0
- package/dist/components/Switch/Switch.doc.d.ts +4 -0
- package/dist/components/Switch/Switch.doc.js +56 -0
- package/dist/components/Switch/Switch.js +45 -0
- package/dist/components/Switch/Switch.types.d.ts +21 -0
- package/dist/components/Switch/Switch.types.js +2 -0
- package/dist/components/Switch/index.d.ts +9 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Table/Table.d.ts +34 -0
- package/dist/components/Table/Table.doc.d.ts +4 -0
- package/dist/components/Table/Table.doc.js +48 -0
- package/dist/components/Table/Table.js +17 -0
- package/dist/components/Table/Table.types.d.ts +30 -0
- package/dist/components/Table/Table.types.js +2 -0
- package/dist/components/Table/index.d.ts +9 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Textarea/Textarea.d.ts +9 -0
- package/dist/components/Textarea/Textarea.doc.d.ts +4 -0
- package/dist/components/Textarea/Textarea.doc.js +60 -0
- package/dist/components/Textarea/Textarea.js +24 -0
- package/dist/components/Textarea/Textarea.types.d.ts +22 -0
- package/dist/components/Textarea/Textarea.types.js +2 -0
- package/dist/components/Textarea/index.d.ts +9 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/Toast/Toast.d.ts +16 -0
- package/dist/components/Toast/Toast.doc.d.ts +4 -0
- package/dist/components/Toast/Toast.doc.js +37 -0
- package/dist/components/Toast/Toast.js +134 -0
- package/dist/components/Toast/Toast.types.d.ts +11 -0
- package/dist/components/Toast/Toast.types.js +2 -0
- package/dist/components/Toast/index.d.ts +10 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/toastStore.d.ts +36 -0
- package/dist/components/Toast/toastStore.js +57 -0
- package/dist/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/components/Tooltip/Tooltip.doc.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.doc.js +33 -0
- package/dist/components/Tooltip/Tooltip.js +105 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +21 -0
- package/dist/components/Tooltip/Tooltip.types.js +2 -0
- package/dist/components/Tooltip/index.d.ts +9 -0
- package/dist/components/Tooltip/index.js +2 -0
- package/dist/contracts/Accordion.json +174 -0
- package/dist/contracts/AppShell.json +118 -0
- package/dist/contracts/Avatar.json +157 -0
- package/dist/contracts/AvatarGroup.json +169 -0
- package/dist/contracts/Badge.json +212 -0
- package/dist/contracts/Button.json +295 -0
- package/dist/contracts/Card.json +125 -0
- package/dist/contracts/Chart.json +167 -0
- package/dist/contracts/Checkbox.json +333 -0
- package/dist/contracts/CheckboxGroup.json +200 -0
- package/dist/contracts/Chip.json +320 -0
- package/dist/contracts/ChipGroup.json +182 -0
- package/dist/contracts/FAB.json +215 -0
- package/dist/contracts/Icon.json +306 -0
- package/dist/contracts/IconButton.json +213 -0
- package/dist/contracts/Input.json +400 -0
- package/dist/contracts/Menu.json +197 -0
- package/dist/contracts/Modal.json +192 -0
- package/dist/contracts/MultiSelect.json +244 -0
- package/dist/contracts/NavItem.json +148 -0
- package/dist/contracts/PageHeader.json +134 -0
- package/dist/contracts/RadioButton.json +202 -0
- package/dist/contracts/RadioGroup.json +228 -0
- package/dist/contracts/SegmentedControl.json +193 -0
- package/dist/contracts/Select.json +241 -0
- package/dist/contracts/SideNav.json +138 -0
- package/dist/contracts/SidePanel.json +153 -0
- package/dist/contracts/Switch.json +201 -0
- package/dist/contracts/Table.json +130 -0
- package/dist/contracts/Textarea.json +353 -0
- package/dist/contracts/Toast.json +186 -0
- package/dist/contracts/Tooltip.json +168 -0
- package/dist/contracts/TopBar.json +127 -0
- package/dist/contracts/manifest.json +675 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +73 -0
- package/dist/layout/AppShell/AppShell.d.ts +14 -0
- package/dist/layout/AppShell/AppShell.doc.d.ts +4 -0
- package/dist/layout/AppShell/AppShell.doc.js +27 -0
- package/dist/layout/AppShell/AppShell.js +9 -0
- package/dist/layout/AppShell/AppShell.types.d.ts +18 -0
- package/dist/layout/AppShell/AppShell.types.js +2 -0
- package/dist/layout/AppShell/index.d.ts +9 -0
- package/dist/layout/AppShell/index.js +2 -0
- package/dist/layout/PageHeader/PageHeader.d.ts +14 -0
- package/dist/layout/PageHeader/PageHeader.doc.d.ts +4 -0
- package/dist/layout/PageHeader/PageHeader.doc.js +30 -0
- package/dist/layout/PageHeader/PageHeader.js +10 -0
- package/dist/layout/PageHeader/PageHeader.types.d.ts +21 -0
- package/dist/layout/PageHeader/PageHeader.types.js +2 -0
- package/dist/layout/PageHeader/index.d.ts +9 -0
- package/dist/layout/PageHeader/index.js +2 -0
- package/dist/layout/SideNav/SideNav.d.ts +14 -0
- package/dist/layout/SideNav/SideNav.doc.d.ts +4 -0
- package/dist/layout/SideNav/SideNav.doc.js +32 -0
- package/dist/layout/SideNav/SideNav.js +9 -0
- package/dist/layout/SideNav/SideNav.types.d.ts +18 -0
- package/dist/layout/SideNav/SideNav.types.js +2 -0
- package/dist/layout/SideNav/index.d.ts +9 -0
- package/dist/layout/SideNav/index.js +2 -0
- package/dist/layout/TopBar/TopBar.d.ts +14 -0
- package/dist/layout/TopBar/TopBar.doc.d.ts +4 -0
- package/dist/layout/TopBar/TopBar.doc.js +28 -0
- package/dist/layout/TopBar/TopBar.js +9 -0
- package/dist/layout/TopBar/TopBar.types.d.ts +16 -0
- package/dist/layout/TopBar/TopBar.types.js +2 -0
- package/dist/layout/TopBar/index.d.ts +9 -0
- package/dist/layout/TopBar/index.js +2 -0
- package/dist/lib/component-doc.d.ts +34 -0
- package/dist/lib/component-doc.js +2 -0
- package/dist/lib/motionPresets.d.ts +37 -0
- package/dist/lib/motionPresets.js +35 -0
- package/dist/lib/resolveTokenPx.d.ts +11 -0
- package/dist/lib/resolveTokenPx.js +17 -0
- package/dist/lib/useDialogTransition.d.ts +21 -0
- package/dist/lib/useDialogTransition.js +86 -0
- package/dist/lib/useDisclosureTransition.d.ts +19 -0
- package/dist/lib/useDisclosureTransition.js +41 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +6 -0
- package/dist/patterns/action-bar.md +127 -0
- package/dist/patterns/border-always.md +40 -0
- package/dist/patterns/data-analytics.md +15 -0
- package/dist/patterns/disabled-state.md +80 -0
- package/dist/patterns/empty-state.md +130 -0
- package/dist/patterns/expand-collapse-chevron.md +101 -0
- package/dist/patterns/form-field-group.md +139 -0
- package/dist/patterns/form-field-spacing.md +99 -0
- package/dist/patterns/group-spacing.md +54 -0
- package/dist/patterns/motion-effects.md +100 -0
- package/dist/patterns/same-row-sizing.md +52 -0
- package/dist/patterns/search-filter.md +118 -0
- package/dist/patterns/show-hide-parts.md +53 -0
- package/dist/patterns/stat-card.md +105 -0
- package/dist/patterns/status-row.md +130 -0
- package/dist/patterns/view-toggle.md +81 -0
- package/dist/prop-map.md +80 -0
- package/package.json +70 -3
- package/src/globals.css +3195 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using IconButton, read its contract: node_modules/@helixds/react/dist/contracts/IconButton.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 { IconButton } from './IconButton.js';
|
|
8
|
+
export type { IconButtonProps, IconButtonVariant, IconButtonSize } from './IconButton.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Input, read its contract: node_modules/@helixds/react/dist/contracts/Input.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 { InputProps } from './Input.types.js';
|
|
9
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
10
|
+
export { Input };
|
|
11
|
+
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Machine-readable component documentation for the Helix Input. */
|
|
2
|
+
export const doc = {
|
|
3
|
+
name: 'Input',
|
|
4
|
+
purpose: 'Allows users to enter a single line of free-form text.',
|
|
5
|
+
contract: 'contracts/components/Input.json',
|
|
6
|
+
a11y: [
|
|
7
|
+
'The `label` prop is required. Use `hideLabel` only when a visible label would be redundant.',
|
|
8
|
+
'Pair `invalid` with `errorMessage` so screen readers get a clear validation message.',
|
|
9
|
+
],
|
|
10
|
+
variants: [],
|
|
11
|
+
sizes: [],
|
|
12
|
+
tokens: [
|
|
13
|
+
{ part: 'input-wrapper', label: 'Default fill', token: '--helix-input-fill-default', kind: 'color' },
|
|
14
|
+
{ part: 'input-wrapper', label: 'Default border', token: '--helix-input-border-default', kind: 'color' },
|
|
15
|
+
{ part: 'input-wrapper', label: 'Default border', token: '--helix-input-border-hover', kind: 'color', state: 'hover' },
|
|
16
|
+
{ part: 'input-wrapper', label: 'Focus border', token: '--helix-input-border-focus', kind: 'color' },
|
|
17
|
+
{ part: 'input-wrapper', label: 'Disabled fill', token: '--helix-input-fill-disabled', kind: 'color', state: 'disabled' },
|
|
18
|
+
{ part: 'input-wrapper', label: 'Disabled border', token: '--helix-input-border-disabled', kind: 'color', state: 'disabled' },
|
|
19
|
+
{ part: 'input-field', label: 'Value text', token: '--helix-input-text-value', kind: 'color' },
|
|
20
|
+
{ part: 'input-field', label: 'Placeholder text', token: '--helix-input-text-placeholder', kind: 'color' },
|
|
21
|
+
{ part: 'input-field', label: 'Disabled text', token: '--helix-input-text-disabled', kind: 'color', state: 'disabled' },
|
|
22
|
+
{ part: 'input-label', label: 'label', token: '--helix-primitive-fontSize-s', kind: 'typography', meta: 'Label' },
|
|
23
|
+
{ part: 'input-label', label: 'label.weight', token: '--helix-primitive-fontWeight-medium', kind: 'typography', meta: 'Medium' },
|
|
24
|
+
{ part: 'input-field', label: 'value', token: '--helix-primitive-fontSize-s', kind: 'typography', meta: 'Body small' },
|
|
25
|
+
{ part: 'input-description', label: 'description', token: '--helix-primitive-fontSize-s', kind: 'typography', meta: 'Body xsmall' },
|
|
26
|
+
{ part: 'input-error', label: 'error', token: '--helix-primitive-fontSize-s', kind: 'typography', meta: 'Body xsmall' },
|
|
27
|
+
{ part: 'input-field', label: 'field.height', token: '--helix-input-height-m', kind: 'space', meta: 'One size (semantic.size.m) — form fields share one size set' },
|
|
28
|
+
{ part: 'input-root', label: 'gap.label.field', token: '--helix-input-gap-label', kind: 'space', axis: 'vertical' },
|
|
29
|
+
{ part: 'input-root', label: 'gap.description.field', token: '--helix-input-gap-description', kind: 'space', axis: 'vertical' },
|
|
30
|
+
{ part: 'input-field', label: 'padding.top', value: '0', kind: 'space', axis: 'vertical' },
|
|
31
|
+
{ part: 'input-field', label: 'padding.bottom', value: '0', kind: 'space', axis: 'vertical' },
|
|
32
|
+
{ part: 'input-field', label: 'padding.start', token: '--helix-primitive-spacing-75', kind: 'space', axis: 'horizontal' },
|
|
33
|
+
{ part: 'input-field', label: 'padding.end', token: '--helix-primitive-spacing-75', kind: 'space', axis: 'horizontal' },
|
|
34
|
+
{ part: 'input-icon', label: 'padding.start', token: '--helix-primitive-spacing-75', kind: 'space', axis: 'horizontal', meta: 'Outer edge — wrapper to icon' },
|
|
35
|
+
{ part: 'input-icon', label: 'gap.icon.text', token: '--helix-primitive-spacing-25', kind: 'space', axis: 'horizontal', meta: 'Icon to typed text' },
|
|
36
|
+
{ part: 'input-icon-end', label: 'padding.end', token: '--helix-primitive-spacing-75', kind: 'space', axis: 'horizontal', meta: 'Outer edge — icon to wrapper' },
|
|
37
|
+
{ part: 'input-icon-end', label: 'gap.icon.text', token: '--helix-primitive-spacing-25', kind: 'space', axis: 'horizontal', meta: 'Typed text to icon' },
|
|
38
|
+
{ part: 'input-wrapper', label: 'input.root', token: '--helix-input-radius', kind: 'radius' },
|
|
39
|
+
{ part: 'input-root', label: 'display', value: 'flex' },
|
|
40
|
+
{ part: 'input-root', label: 'flex-direction', value: 'column' },
|
|
41
|
+
{ part: 'input-root', label: 'width', value: 'fit-content' },
|
|
42
|
+
{ part: 'input-wrapper', label: 'position', value: 'relative' },
|
|
43
|
+
{ part: 'input-wrapper', label: 'align-items', value: 'center' },
|
|
44
|
+
{ part: 'input-field', label: 'background', value: 'transparent' },
|
|
45
|
+
{ part: 'input-field', label: 'border', value: 'none' },
|
|
46
|
+
{ part: 'input-field', label: 'outline', value: 'none' },
|
|
47
|
+
{ part: 'input-field', label: 'font-family', value: 'inherit' },
|
|
48
|
+
{ part: 'input-field', label: 'min-width', value: '0' },
|
|
49
|
+
{ part: 'input-field', label: 'flex', value: '1' },
|
|
50
|
+
{ part: 'input-field', label: 'cursor.disabled', value: 'not-allowed' },
|
|
51
|
+
{ part: 'input-icon', label: 'display.icon', value: 'flex' },
|
|
52
|
+
{ part: 'input-icon', label: 'height.icon', value: '100%' },
|
|
53
|
+
],
|
|
54
|
+
features: [
|
|
55
|
+
'label / hideLabel — accessible label support',
|
|
56
|
+
'One size, m — no size prop: Input, Select, MultiSelect and Textarea share one size set',
|
|
57
|
+
'invalid / errorMessage — validation state and helper copy',
|
|
58
|
+
'icon / iconEnd — leading and trailing adornments',
|
|
59
|
+
'isLoading — async validation state',
|
|
60
|
+
'fullWidth — expands to container width',
|
|
61
|
+
],
|
|
62
|
+
examples: [
|
|
63
|
+
{ label: 'Default', code: `<Input label="Email" placeholder="you@example.com" />` },
|
|
64
|
+
{ label: 'With helper text', code: `<Input label="Username" description="Used for your public profile" />` },
|
|
65
|
+
{ label: 'Invalid', code: `<Input label="Email" invalid errorMessage="Enter a valid email address" />` },
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=Input.doc.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../../lib/utils.js';
|
|
4
|
+
import { Icon } from '../Icon/index.js';
|
|
5
|
+
let idCounter = 0;
|
|
6
|
+
// Form fields ship one size, m (owner's decision 2026-10-21 — Input, Select, MultiSelect and Textarea share
|
|
7
|
+
// one size set): its icons are 16px, like Select's chevron in the same row.
|
|
8
|
+
const FIELD_ICON_SIZE = 16;
|
|
9
|
+
// isLoading: the same spinner Button and IconButton draw, at the field's icon size, where iconEnd sits
|
|
10
|
+
// (owner's decision 2026-10-20 — before it the field only locked silently).
|
|
11
|
+
const Spinner = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" }) }));
|
|
12
|
+
const Input = React.forwardRef(({ label, hideLabel = false, invalid = false, isLoading = false, fullWidth = false, icon, iconEnd, description, errorMessage, invalidAttempt, id, disabled, className, onKeyDown, ...props }, ref) => {
|
|
13
|
+
const [uid] = React.useState(() => id ?? `helix-input-${++idCounter}`);
|
|
14
|
+
const descId = description && !invalid ? `${uid}-desc` : undefined;
|
|
15
|
+
const errorId = invalid && errorMessage ? `${uid}-error` : undefined;
|
|
16
|
+
const describedBy = [descId, errorId].filter(Boolean).join(' ') || undefined;
|
|
17
|
+
const wrapperRef = React.useRef(null);
|
|
18
|
+
const prevShakeSignal = React.useRef({ invalid, invalidAttempt });
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
const prev = prevShakeSignal.current;
|
|
21
|
+
// Shake on a false->true edge, OR on `invalidAttempt` changing while already
|
|
22
|
+
// invalid — the edge alone misses a consumer that sets invalid(false) then
|
|
23
|
+
// invalid(true) synchronously in one handler (React 18 batches that to a
|
|
24
|
+
// no-op re-render when it was already true), which is the common "resubmit
|
|
25
|
+
// while still invalid" shape.
|
|
26
|
+
const becameInvalid = invalid && !prev.invalid;
|
|
27
|
+
const retriedInvalid = invalid && invalidAttempt !== undefined && invalidAttempt !== prev.invalidAttempt;
|
|
28
|
+
if (becameInvalid || retriedInvalid) {
|
|
29
|
+
const el = wrapperRef.current;
|
|
30
|
+
if (el) {
|
|
31
|
+
// Remove-reflow-reapply so the shake restarts even on a repeat trigger.
|
|
32
|
+
el.removeAttribute('data-shaking');
|
|
33
|
+
void el.offsetWidth;
|
|
34
|
+
el.setAttribute('data-shaking', 'true');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
prevShakeSignal.current = { invalid, invalidAttempt };
|
|
38
|
+
}, [invalid, invalidAttempt]);
|
|
39
|
+
return (_jsxs("div", { "data-helix-part": "input-root", "data-full-width": fullWidth ? 'true' : undefined, "data-disabled": disabled ? 'true' : undefined, className: cn(className), children: [_jsxs("label", { "data-helix-part": "input-label", htmlFor: uid, style: hideLabel ? { position: 'absolute', width: 1, height: 1, overflow: 'hidden', clip: 'rect(0,0,0,0)', whiteSpace: 'nowrap' } : undefined, children: [label, props.required && _jsx("span", { "data-helix-part": "input-required", "aria-hidden": "true", children: " *" })] }), _jsxs("div", { ref: wrapperRef, "data-helix-part": "input-wrapper", "data-invalid": invalid ? 'true' : undefined, "data-disabled": disabled ? 'true' : undefined, "data-loading": isLoading ? 'true' : undefined, onAnimationEnd: () => wrapperRef.current?.removeAttribute('data-shaking'), children: [icon && (_jsx("span", { "data-helix-part": "input-icon", children: _jsx(Icon, { icon: icon, size: FIELD_ICON_SIZE }) })), _jsx("input", { ref: ref, id: uid, "data-helix-part": "input-field", disabled: disabled || isLoading, "aria-invalid": invalid ? 'true' : undefined, "aria-required": props.required ? 'true' : undefined, "aria-busy": isLoading ? 'true' : undefined, "aria-describedby": describedBy, ...props, onKeyDown: e => {
|
|
40
|
+
onKeyDown?.(e);
|
|
41
|
+
// Contract a11y.keyboardNav: Escape blurs the field (unless the consumer handled it).
|
|
42
|
+
if (e.key === 'Escape' && !e.defaultPrevented)
|
|
43
|
+
e.currentTarget.blur();
|
|
44
|
+
} }), isLoading ? (_jsx("span", { "data-helix-part": "input-spinner", children: _jsx(Spinner, { size: FIELD_ICON_SIZE }) })) : iconEnd && (_jsx("span", { "data-helix-part": "input-icon-end", children: _jsx(Icon, { icon: iconEnd, size: FIELD_ICON_SIZE }) }))] }), description && !invalid && (_jsx("p", { id: descId, "data-helix-part": "input-description", children: description })), invalid && errorMessage && (_jsx("p", { id: errorId, "data-helix-part": "input-error", role: "alert", children: errorMessage }))] }));
|
|
45
|
+
});
|
|
46
|
+
Input.displayName = 'Input';
|
|
47
|
+
export { Input };
|
|
48
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Input, read its contract: node_modules/@helixds/react/dist/contracts/Input.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 InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
10
|
+
/** Visible or sr-only label. Required for a11y. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Hide the label visually (still announced by screen readers). */
|
|
13
|
+
hideLabel?: boolean;
|
|
14
|
+
/** Field value fails validation. */
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
/** Marks field as required. */
|
|
17
|
+
required?: boolean;
|
|
18
|
+
/** Async validation in progress. */
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
/** Leading icon — a Tabler icon component, passed by reference (e.g. IconSearch). Always 16px — form fields have one size, m. */
|
|
21
|
+
icon?: HelixIconComponent;
|
|
22
|
+
/** Trailing icon. 16px, like `icon`. */
|
|
23
|
+
iconEnd?: HelixIconComponent;
|
|
24
|
+
/** Helper text shown below the field. */
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Error text shown when invalid=true. */
|
|
27
|
+
errorMessage?: string;
|
|
28
|
+
/** Bump this (e.g. an attempt counter) on each failed validation to retrigger the error shake even
|
|
29
|
+
* when `invalid` was already true — a plain `invalid` false→true edge won't fire again on its own
|
|
30
|
+
* if a consumer sets it back to true without an intervening render where it was false (common with
|
|
31
|
+
* React 18 batching: `setInvalid(false); setInvalid(true)` inside one handler collapses to a no-op). */
|
|
32
|
+
invalidAttempt?: number;
|
|
33
|
+
/** Expand to 100% of container width. */
|
|
34
|
+
fullWidth?: boolean;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Input.types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Input, read its contract: node_modules/@helixds/react/dist/contracts/Input.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 { Input } from './Input.js';
|
|
8
|
+
export type { InputProps } from './Input.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Menu, read its contract: node_modules/@helixds/react/dist/contracts/Menu.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 { MenuProps } from './Menu.types.js';
|
|
9
|
+
export declare function optionId(menuId: string, value: string): string;
|
|
10
|
+
export declare function Menu({ id, expanded, anchorRef, options, value, multiple, values, activeValue, onSelect, className }: MenuProps): React.ReactPortal | null;
|
|
11
|
+
export declare namespace Menu {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Menu.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const doc = {
|
|
2
|
+
name: 'Menu',
|
|
3
|
+
purpose: 'A Helix-styled, portaled popup listbox anchored to a trigger — the internal primitive Select uses instead of a native <select> dropdown.',
|
|
4
|
+
contract: 'contracts/components/Menu.json',
|
|
5
|
+
a11y: [
|
|
6
|
+
'`role="listbox"` on the root, `role="option"` + `aria-selected` on each item — hand-rolled, see ADR-013.',
|
|
7
|
+
'Menu is deliberately non-focusable — the consumer\'s trigger owns real keyboard focus and drives selection via `aria-activedescendant`, matching how Select\'s own button trigger works.',
|
|
8
|
+
'Portaled to `document.body` so it always renders above ancestor `overflow`/`z-index` — same reasoning Toast already established (ADR-011).',
|
|
9
|
+
],
|
|
10
|
+
variants: [],
|
|
11
|
+
sizes: [],
|
|
12
|
+
tokens: [
|
|
13
|
+
{ part: 'menu', label: 'Background', token: '--helix-menu-fill', kind: 'color' },
|
|
14
|
+
{ part: 'menu', label: 'Border', token: '--helix-menu-border', kind: 'color' },
|
|
15
|
+
{ part: 'menu', label: 'Elevation', token: '--helix-menu-shadow', kind: 'shadow', meta: 'semantic.shadow.m — documented as "popovers, menus"' },
|
|
16
|
+
{ part: 'menu', label: 'menu.radius', token: '--helix-menu-radius', kind: 'radius' },
|
|
17
|
+
{ part: 'menu', label: 'menu.padding', token: '--helix-menu-padding', kind: 'space' },
|
|
18
|
+
{ part: 'menu-item', label: 'item.height', token: '--helix-menu-item-height', kind: 'space' },
|
|
19
|
+
{ part: 'menu-item', label: 'Default text', token: '--helix-menu-item-text', kind: 'color' },
|
|
20
|
+
{ part: 'menu-item', label: 'Hover fill', token: '--helix-menu-item-fill-hover', kind: 'color', state: 'hover', meta: 'Same token NavItem\'s own hover already uses — one shared neutral hover, not a one-off.' },
|
|
21
|
+
{ part: 'menu-item', label: 'Selected fill', token: '--helix-menu-item-fill-selected', kind: 'color' },
|
|
22
|
+
{ part: 'menu-item', label: 'Selected text', token: '--helix-menu-item-text-selected', kind: 'color' },
|
|
23
|
+
{ part: 'menu-item', label: 'Disabled text', token: '--helix-menu-item-text-disabled', kind: 'color', state: 'disabled' },
|
|
24
|
+
{ part: 'menu-group-label', label: 'Text color', token: '--helix-menu-groupLabel-text', kind: 'color' },
|
|
25
|
+
{ part: 'menu-group-label', label: 'fontSize', token: '--helix-menu-groupLabel-fontSize', kind: 'typography', meta: 'semantic.textStyle.label-uppercase — no added letter-spacing, review feedback removed it' },
|
|
26
|
+
{ part: 'menu-group-label', label: 'fontWeight', token: '--helix-menu-groupLabel-fontWeight', kind: 'typography' },
|
|
27
|
+
{ part: 'menu-group-divider', label: 'Divider color', token: '--helix-menu-groupDivider-color', kind: 'color' },
|
|
28
|
+
{ part: 'menu-group-divider', label: 'Margin above', token: '--helix-menu-groupDivider-marginTop', kind: 'space', meta: '8px, to whatever precedes it' },
|
|
29
|
+
{ part: 'menu-group-divider', label: 'Margin below', token: '--helix-menu-groupDivider-marginBottom', kind: 'space', meta: '16px, to the group label right after it — asymmetric on purpose, per review feedback' },
|
|
30
|
+
],
|
|
31
|
+
features: [
|
|
32
|
+
'options — flat MenuOption[] or grouped MenuOptionGroup[] ({ label, options })',
|
|
33
|
+
'labelEnd — optional per-option secondary text on the end edge (menu-item-label-end), muted, tabular figures',
|
|
34
|
+
'value — selected value, drives aria-selected + the blue highlight',
|
|
35
|
+
'activeValue — keyboard-highlighted value, drives the gray highlight (consumer owns the keyboard handling, e.g. Select)',
|
|
36
|
+
'Positioning: always opens below the anchor, never flips above — horizontal clamp only, adapted from Tooltip\'s clamp (ADR-009).',
|
|
37
|
+
'Not exported as a top-level app-facing pattern yet — currently consumed only by Select internally, per ADR-013\'s scope.',
|
|
38
|
+
],
|
|
39
|
+
examples: [
|
|
40
|
+
{
|
|
41
|
+
label: 'Internal usage (via Select)',
|
|
42
|
+
code: `<Menu id="my-listbox" expanded={isExpanded} anchorRef={triggerRef} options={options} value={value} onSelect={setValue} />`,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=Menu.doc.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
|
+
import { resolveTokenPx } from '../../lib/resolveTokenPx.js';
|
|
6
|
+
function isGroup(opt) {
|
|
7
|
+
return 'options' in opt;
|
|
8
|
+
}
|
|
9
|
+
export function optionId(menuId, value) {
|
|
10
|
+
return `${menuId}-option-${value}`;
|
|
11
|
+
}
|
|
12
|
+
// Keeps the menu this many px clear of the viewport edge — same principle as Tooltip's own
|
|
13
|
+
// EDGE_GUTTER (ADR-009), horizontal clamp only: always opens below the anchor — never flips above,
|
|
14
|
+
// even when there isn't room below (the page scrolls instead) — and is clamped so it never overflows
|
|
15
|
+
// the left/right edge for an anchor sitting near either side of the viewport. See ADR-013.
|
|
16
|
+
const EDGE_GUTTER = 8;
|
|
17
|
+
function usePosition(expanded, anchorRef, menuRef) {
|
|
18
|
+
const [style, setStyle] = React.useState({ visibility: 'hidden' });
|
|
19
|
+
const recalculate = React.useCallback(() => {
|
|
20
|
+
const anchor = anchorRef.current;
|
|
21
|
+
const menu = menuRef.current;
|
|
22
|
+
if (!anchor || !menu)
|
|
23
|
+
return;
|
|
24
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
25
|
+
const menuRect = menu.getBoundingClientRect();
|
|
26
|
+
const vw = window.innerWidth;
|
|
27
|
+
const top = anchorRect.bottom + 4;
|
|
28
|
+
const maxLeft = vw - menuRect.width - EDGE_GUTTER;
|
|
29
|
+
const left = Math.min(Math.max(anchorRect.left, EDGE_GUTTER), Math.max(maxLeft, EDGE_GUTTER));
|
|
30
|
+
setStyle({ position: 'fixed', top, left, width: anchorRect.width, visibility: 'visible' });
|
|
31
|
+
}, [anchorRef, menuRef]);
|
|
32
|
+
React.useLayoutEffect(() => {
|
|
33
|
+
if (!expanded)
|
|
34
|
+
return;
|
|
35
|
+
const anchor = anchorRef.current;
|
|
36
|
+
const menu = menuRef.current;
|
|
37
|
+
// Set the real width directly on the DOM node, synchronously, before the first height
|
|
38
|
+
// measurement — width otherwise only lands a render cycle later (via the setStyle below), so
|
|
39
|
+
// the very first recalculate() would measure the menu at its unconstrained natural width,
|
|
40
|
+
// which can wrap option labels differently and misplace it horizontally on first open.
|
|
41
|
+
if (anchor && menu) {
|
|
42
|
+
menu.style.width = `${anchor.getBoundingClientRect().width}px`;
|
|
43
|
+
}
|
|
44
|
+
recalculate();
|
|
45
|
+
window.addEventListener('resize', recalculate);
|
|
46
|
+
window.addEventListener('scroll', recalculate, true);
|
|
47
|
+
return () => {
|
|
48
|
+
window.removeEventListener('resize', recalculate);
|
|
49
|
+
window.removeEventListener('scroll', recalculate, true);
|
|
50
|
+
};
|
|
51
|
+
}, [expanded, recalculate, anchorRef, menuRef]);
|
|
52
|
+
return style;
|
|
53
|
+
}
|
|
54
|
+
// Keeps the menu on screen for its close transition after `expanded` turns false (transitions.dev
|
|
55
|
+
// "menu dropdown": grows in from its trigger, settles out to a near-resting scale). Under reduced
|
|
56
|
+
// motion there is no transition to wait for, so it goes at once.
|
|
57
|
+
function usePresence(expanded, menuRef) {
|
|
58
|
+
const [closing, setClosing] = React.useState(false);
|
|
59
|
+
// Decided during render, not in an effect — an effect would commit one frame with the menu already
|
|
60
|
+
// gone before bringing it back to animate out.
|
|
61
|
+
const [wasExpanded, setWasExpanded] = React.useState(expanded);
|
|
62
|
+
if (expanded !== wasExpanded) {
|
|
63
|
+
setWasExpanded(expanded);
|
|
64
|
+
setClosing(!expanded && !window.matchMedia('(prefers-reduced-motion: reduce)').matches);
|
|
65
|
+
}
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if (!closing)
|
|
68
|
+
return;
|
|
69
|
+
const timer = window.setTimeout(() => setClosing(false), resolveTokenPx('--helix-menu-duration-close', menuRef.current));
|
|
70
|
+
return () => window.clearTimeout(timer);
|
|
71
|
+
}, [closing, menuRef]);
|
|
72
|
+
return closing;
|
|
73
|
+
}
|
|
74
|
+
export function Menu({ id, expanded, anchorRef, options, value, multiple = false, values, activeValue, onSelect, className }) {
|
|
75
|
+
const menuRef = React.useRef(null);
|
|
76
|
+
const style = usePosition(expanded, anchorRef, menuRef);
|
|
77
|
+
const closing = usePresence(expanded, menuRef);
|
|
78
|
+
// A listbox needs an accessible name (WCAG 4.1.2), taken from the control that opens it: its <label>
|
|
79
|
+
// (Select/MultiSelect: "Role", not the trigger's current value), else its aria-label, else its text.
|
|
80
|
+
const [name, setName] = React.useState();
|
|
81
|
+
React.useLayoutEffect(() => {
|
|
82
|
+
const anchor = anchorRef.current;
|
|
83
|
+
if (!expanded || !anchor)
|
|
84
|
+
return;
|
|
85
|
+
// The anchor may be a whole field (an input's wrapper, so the list spans it edge to edge): then the
|
|
86
|
+
// label is the one of the control inside it.
|
|
87
|
+
const control = anchor.labels ? anchor : anchor.querySelector('input, select, textarea, button');
|
|
88
|
+
const label = control?.labels?.[0];
|
|
89
|
+
setName((label?.textContent ?? anchor.getAttribute('aria-label') ?? anchor.textContent ?? '').trim() || undefined);
|
|
90
|
+
}, [expanded, anchorRef]);
|
|
91
|
+
if (!expanded && !closing)
|
|
92
|
+
return null;
|
|
93
|
+
// Width rule (contract sizing.width): 150px minimum for word options, none when every option is a
|
|
94
|
+
// number (1, 2, 1000…).
|
|
95
|
+
const flat = options.flatMap(o => ('options' in o ? o.options : [o]));
|
|
96
|
+
const numericOnly = flat.length > 0 && flat.every(o => /^[\d\s.,%+-]+$/.test(o.label.trim()));
|
|
97
|
+
const renderOption = (opt) => (_jsx("button", { type: "button", id: optionId(id, opt.value), "data-helix-part": "menu-item", role: "option", "aria-selected": multiple ? (values ?? []).includes(opt.value) : opt.value === value, "data-active": opt.value === activeValue ? '' : undefined, disabled: opt.disabled, onClick: () => !opt.disabled && onSelect(opt.value),
|
|
98
|
+
// Keeps focus on the trigger — Menu is deliberately non-focusable (see ADR-013: the consumer's
|
|
99
|
+
// trigger button owns real keyboard focus and drives aria-activedescendant; mousedown here would
|
|
100
|
+
// otherwise steal it).
|
|
101
|
+
onMouseDown: e => e.preventDefault(), children: opt.labelEnd === undefined ? opt.label : (_jsxs(_Fragment, { children: [_jsx("span", { "data-helix-part": "menu-item-label", children: opt.label }), _jsx("span", { "data-helix-part": "menu-item-label-end", children: opt.labelEnd })] })) }, opt.value));
|
|
102
|
+
return createPortal(_jsx("div", { ref: menuRef, id: id, "data-helix-part": "menu", ...(numericOnly ? { 'data-numeric': '' } : {}), "data-state": expanded ? undefined : 'closing', ...(expanded ? {} : { 'aria-hidden': true, inert: true }), role: "listbox", "aria-multiselectable": multiple || undefined, "aria-label": name, style: style, className: cn(className), children: options.map((opt, i) => isGroup(opt) ? (_jsxs(React.Fragment, { children: [i > 0 && _jsx("div", { "data-helix-part": "menu-group-divider", role: "separator", "aria-hidden": "true" }), _jsx("div", { "data-helix-part": "menu-group-label", children: opt.label }), opt.options.map(renderOption)] }, opt.label)) : (renderOption(opt))) }), document.body);
|
|
103
|
+
}
|
|
104
|
+
Menu.displayName = 'Menu';
|
|
105
|
+
//# sourceMappingURL=Menu.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Menu, read its contract: node_modules/@helixds/react/dist/contracts/Menu.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
|
+
export interface MenuOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** Short secondary text aligned to the end of the option — a value, count or percentage. */
|
|
12
|
+
labelEnd?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface MenuOptionGroup {
|
|
16
|
+
label: string;
|
|
17
|
+
options: MenuOption[];
|
|
18
|
+
}
|
|
19
|
+
export interface MenuProps {
|
|
20
|
+
id: string;
|
|
21
|
+
expanded: boolean;
|
|
22
|
+
anchorRef: React.RefObject<HTMLElement | null>;
|
|
23
|
+
options: (MenuOption | MenuOptionGroup)[];
|
|
24
|
+
value?: string;
|
|
25
|
+
/** Multi-selection (ADR-019): the listbox gets aria-multiselectable and every value in `values` is
|
|
26
|
+
* marked selected. `value` is ignored when this is set. */
|
|
27
|
+
multiple?: boolean;
|
|
28
|
+
/** Selected values when `multiple` is set. */
|
|
29
|
+
values?: string[];
|
|
30
|
+
activeValue?: string;
|
|
31
|
+
onSelect: (value: string) => void;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Menu.types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Menu, read its contract: node_modules/@helixds/react/dist/contracts/Menu.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 { Menu, optionId } from './Menu.js';
|
|
8
|
+
export type { MenuProps, MenuOption, MenuOptionGroup } from './Menu.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Modal, read its contract: node_modules/@helixds/react/dist/contracts/Modal.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 { ModalProps } from './Modal.types.js';
|
|
9
|
+
declare const Modal: {
|
|
10
|
+
({ label, children, expanded, onDismiss, showCloseButton, closeOnBackdropClick, primaryActionLabel, onPrimaryAction, secondaryActionLabel, onSecondaryAction, tertiaryActionLabel, onTertiaryAction, className, }: ModalProps): React.JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export { Modal };
|
|
14
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const doc = {
|
|
2
|
+
name: 'Modal',
|
|
3
|
+
purpose: 'A centered modal overlay that interrupts the page for a focused task or decision.',
|
|
4
|
+
contract: 'contracts/components/Modal.json',
|
|
5
|
+
a11y: [
|
|
6
|
+
'Built on native <dialog> opened via showModal() — backdrop, focus trap, Escape-to-close, and top-layer stacking all come from the browser (see ADR-010).',
|
|
7
|
+
'The title is referenced via aria-labelledby, giving the modal its accessible name.',
|
|
8
|
+
'Modal never closes itself — it always calls onDismiss and expects the consumer to set expanded to false.',
|
|
9
|
+
],
|
|
10
|
+
variants: [],
|
|
11
|
+
sizes: [],
|
|
12
|
+
tokens: [
|
|
13
|
+
{ part: 'modal-root', label: 'fill', token: '--helix-modal-fill', kind: 'color' },
|
|
14
|
+
{ part: 'modal-root', label: 'overlay', token: '--helix-modal-overlay', kind: 'color' },
|
|
15
|
+
{ part: 'modal-root', label: 'shadow', token: '--helix-modal-shadow', kind: 'shadow' },
|
|
16
|
+
{ part: 'modal-root', label: 'radius', token: '--helix-modal-radius', kind: 'radius' },
|
|
17
|
+
{ part: 'modal-title', label: 'title text', token: '--helix-modal-text', kind: 'color', colorRole: 'text' },
|
|
18
|
+
{ part: 'modal-body', label: 'body text', token: '--helix-modal-text', kind: 'color', colorRole: 'text', meta: 'Set on modal-root, inherited by header, body and footer' },
|
|
19
|
+
{ part: 'modal-title', label: 'fontSize', token: '--helix-modal-titleFontSize', kind: 'typography' },
|
|
20
|
+
{ part: 'modal-title', label: 'fontWeight', token: '--helix-modal-titleFontWeight', kind: 'typography' },
|
|
21
|
+
{ part: 'modal-header', label: 'padding.top', token: '--helix-modal-padding', kind: 'space', paddingSides: ['top'], axis: 'vertical' },
|
|
22
|
+
{ part: 'modal-header', label: 'padding.start', token: '--helix-modal-padding', kind: 'space', paddingSides: ['start'], axis: 'horizontal' },
|
|
23
|
+
{ part: 'modal-header', label: 'padding.end', token: '--helix-modal-closeInset', kind: 'space', paddingSides: ['end'], axis: 'horizontal', meta: 'calc(closeInset × 2 + 40px) — keeps the title clear of the close button' },
|
|
24
|
+
{ part: 'modal-body', label: 'padding', token: '--helix-modal-padding', kind: 'space', padding: 'all' },
|
|
25
|
+
{ part: 'modal-footer', label: 'padding.start', token: '--helix-modal-padding', kind: 'space', paddingSides: ['start'], axis: 'horizontal' },
|
|
26
|
+
{ part: 'modal-footer', label: 'padding.end', token: '--helix-modal-padding', kind: 'space', paddingSides: ['end'], axis: 'horizontal' },
|
|
27
|
+
{ part: 'modal-footer', label: 'padding.bottom', token: '--helix-modal-padding', kind: 'space', paddingSides: ['bottom'], axis: 'vertical' },
|
|
28
|
+
{ part: 'modal-footer', label: 'gap.footer-start.footer-end', token: '--helix-modal-footerGap', kind: 'space', axis: 'horizontal', meta: 'Between the start and end action groups' },
|
|
29
|
+
{ part: 'modal-footer-end', label: 'gap.actions', token: '--helix-modal-footerGap', kind: 'space', axis: 'horizontal', meta: 'Between the footer buttons' },
|
|
30
|
+
{ part: 'modal-close', label: 'inset.top', token: '--helix-modal-closeInset', kind: 'space', axis: 'vertical' },
|
|
31
|
+
{ part: 'modal-close', label: 'inset.end', token: '--helix-modal-closeInset', kind: 'space', axis: 'horizontal' },
|
|
32
|
+
{ part: 'modal-root', label: 'min-height', value: '400px', kind: 'other', meta: 'Per-component characteristic, not a token — same policy as min/max-width' },
|
|
33
|
+
{ part: 'modal-root', label: 'duration.open', token: '--helix-modal-duration-open', kind: 'other' },
|
|
34
|
+
{ part: 'modal-root', label: 'duration.close', token: '--helix-modal-duration-close', kind: 'other' },
|
|
35
|
+
{ part: 'modal-root', label: 'easing', token: '--helix-modal-easing', kind: 'other' },
|
|
36
|
+
{ part: 'modal-root', label: 'animation.scale-enter', token: '--helix-modal-scale-enter', kind: 'other', meta: 'Scale the dialog enters from and exits to' },
|
|
37
|
+
],
|
|
38
|
+
features: [
|
|
39
|
+
'label — the modal\'s title / accessible name',
|
|
40
|
+
'expanded / onDismiss — always controlled, no uncontrolled form',
|
|
41
|
+
'showCloseButton — toggles the header\'s X button',
|
|
42
|
+
'closeOnBackdropClick — toggles dismissal on a backdrop click',
|
|
43
|
+
'primaryActionLabel / onPrimaryAction / secondaryActionLabel / onSecondaryAction — an optional right-aligned footer action pair',
|
|
44
|
+
'tertiaryActionLabel / onTertiaryAction — an optional third action, pinned to the footer\'s bottom-left corner (Button\'s ghost variant)',
|
|
45
|
+
],
|
|
46
|
+
examples: [
|
|
47
|
+
{ label: 'Basic', code: `<Modal label="Project settings" expanded={isOpen} onDismiss={() => setIsOpen(false)}>...</Modal>` },
|
|
48
|
+
{ label: 'With actions', code: `<Modal label="Delete project" expanded={isOpen} onDismiss={close} primaryActionLabel="Delete" onPrimaryAction={handleDelete} secondaryActionLabel="Cancel" onSecondaryAction={close}>...</Modal>` },
|
|
49
|
+
{ label: 'With a tertiary action', code: `<Modal label="Delete project" expanded={isOpen} onDismiss={close} tertiaryActionLabel="Learn more" onTertiaryAction={openHelp} primaryActionLabel="Delete" onPrimaryAction={handleDelete} secondaryActionLabel="Cancel" onSecondaryAction={close}>...</Modal>` },
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Modal.doc.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { IconX } from '@tabler/icons-react';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
|
+
import { Button } from '../Button/index.js';
|
|
6
|
+
import { IconButton } from '../IconButton/index.js';
|
|
7
|
+
import { useDialogTransition } from '../../lib/useDialogTransition.js';
|
|
8
|
+
let idCounter = 0;
|
|
9
|
+
const Modal = ({ label, children, expanded, onDismiss, showCloseButton = true, closeOnBackdropClick = true, primaryActionLabel, onPrimaryAction, secondaryActionLabel, onSecondaryAction, tertiaryActionLabel, onTertiaryAction, className, }) => {
|
|
10
|
+
const titleId = `helix-modal-title-${++idCounter}`;
|
|
11
|
+
const { ref, state } = useDialogTransition(expanded, '--helix-modal-duration-close', onDismiss, closeOnBackdropClick);
|
|
12
|
+
const hasFooter = !!primaryActionLabel || !!secondaryActionLabel || !!tertiaryActionLabel;
|
|
13
|
+
if (process.env.NODE_ENV !== 'production' && !showCloseButton && !hasFooter) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn('Modal: showCloseButton is false and no footer action (primaryActionLabel/secondaryActionLabel/tertiaryActionLabel) was given — this modal has no visible way to dismiss it (Escape and closeOnBackdropClick still work, if enabled, but there is no on-screen affordance). Add at least one footer action or re-enable showCloseButton.');
|
|
16
|
+
}
|
|
17
|
+
return (_jsxs("dialog", { ref: ref, "data-helix-part": "modal-root", "data-state": state, "aria-labelledby": titleId, className: cn(className), children: [_jsx("div", { "data-helix-part": "modal-header", children: _jsx("h2", { "data-helix-part": "modal-title", id: titleId, children: label }) }), showCloseButton && (
|
|
18
|
+
// Wrapped, not passed data-helix-part directly: IconButton spreads ...props AFTER its own
|
|
19
|
+
// hardcoded data-helix-part="icon-button" (see IconButton.tsx), so a same-named prop here
|
|
20
|
+
// would silently overwrite it and detach every IconButton CSS rule — hover included — since
|
|
21
|
+
// they're all keyed off that exact attribute. The wrapper span carries the positioning
|
|
22
|
+
// instead, leaving IconButton's own anatomy attribute intact.
|
|
23
|
+
_jsx("span", { "data-helix-part": "modal-close", children: _jsx(IconButton, { icon: IconX, label: "Close", size: "l", variant: "ghost", onClick: onDismiss }) })), _jsx("div", { "data-helix-part": "modal-body", children: children }), hasFooter && (_jsxs("div", { "data-helix-part": "modal-footer", children: [_jsx("div", { "data-helix-part": "modal-footer-start", children: tertiaryActionLabel && (
|
|
24
|
+
// "Tertiary" maps to Button's `ghost` variant — Helix's Button has no separate
|
|
25
|
+
// `tertiary` variant token today.
|
|
26
|
+
_jsx(Button, { variant: "ghost", onClick: () => onTertiaryAction?.(), children: tertiaryActionLabel })) }), _jsxs("div", { "data-helix-part": "modal-footer-end", children: [secondaryActionLabel && (_jsx(Button, { variant: "secondary", onClick: () => onSecondaryAction?.(), children: secondaryActionLabel })), primaryActionLabel && (_jsx(Button, { variant: "primary", onClick: () => onPrimaryAction?.(), children: primaryActionLabel }))] })] }))] }));
|
|
27
|
+
};
|
|
28
|
+
Modal.displayName = 'Modal';
|
|
29
|
+
export { Modal };
|
|
30
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Modal, read its contract: node_modules/@helixds/react/dist/contracts/Modal.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 interface ModalProps {
|
|
9
|
+
/** The modal's title — rendered visibly and used as its accessible name. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** The modal's body content. */
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
/** Whether the modal is open. Always controlled — see ADR-010. */
|
|
14
|
+
expanded: boolean;
|
|
15
|
+
/** Called when the modal should close (close button, Escape, or a backdrop click). Modal never closes itself — set `expanded` to false in response. */
|
|
16
|
+
onDismiss: () => void;
|
|
17
|
+
/** Whether to render the header's close (X) button. Default: true */
|
|
18
|
+
showCloseButton?: boolean;
|
|
19
|
+
/** Whether clicking the backdrop dismisses the modal. Default: true */
|
|
20
|
+
closeOnBackdropClick?: boolean;
|
|
21
|
+
/** Label for the footer's primary (rightmost) action button. Omit to render no footer action buttons. */
|
|
22
|
+
primaryActionLabel?: string;
|
|
23
|
+
/** Handler for the primary action button. */
|
|
24
|
+
onPrimaryAction?: () => void;
|
|
25
|
+
/** Label for the footer's secondary action button, to the primary's left. */
|
|
26
|
+
secondaryActionLabel?: string;
|
|
27
|
+
/** Handler for the secondary action button. */
|
|
28
|
+
onSecondaryAction?: () => void;
|
|
29
|
+
/** Label for a tertiary action button, pinned to the footer's bottom-left corner, separate from the primary/secondary group. */
|
|
30
|
+
tertiaryActionLabel?: string;
|
|
31
|
+
/** Handler for the tertiary action button. */
|
|
32
|
+
onTertiaryAction?: () => void;
|
|
33
|
+
/** Additional className for the root. */
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Modal.types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @helixds/react — agent note
|
|
3
|
+
* Before using Modal, read its contract: node_modules/@helixds/react/dist/contracts/Modal.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 { Modal } from './Modal.js';
|
|
8
|
+
export type { ModalProps } from './Modal.types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|