@astryxdesign/core 0.1.7-canary.fb9c68c → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -24
- package/dist/Collapsible/Collapsible.d.ts +1 -11
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +4 -36
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +3 -4
- package/dist/ContextMenu/index.d.ts +0 -3
- package/dist/ContextMenu/index.d.ts.map +1 -1
- package/dist/ContextMenu/index.js +1 -7
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -8
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +1 -17
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +0 -18
- package/dist/DropdownMenu/index.d.ts +1 -5
- package/dist/DropdownMenu/index.d.ts.map +1 -1
- package/dist/DropdownMenu/index.js +1 -10
- package/dist/Icon/Icon.d.ts +12 -17
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +20 -28
- package/dist/Outline/Outline.d.ts +3 -69
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +26 -129
- package/dist/Outline/useScrollSpy.d.ts +7 -27
- package/dist/Outline/useScrollSpy.d.ts.map +1 -1
- package/dist/Outline/useScrollSpy.js +70 -202
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +2 -2
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +0 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +1 -1
- package/dist/Table/index.d.ts +0 -2
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +0 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +2 -24
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +7 -18
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +3 -6
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +1 -8
- package/dist/astryx.css +2 -18
- package/dist/astryx.umd.js +48 -48
- package/dist/astryx.umd.js.map +4 -4
- package/dist/theme/Theme.js +1 -1
- package/dist/theme/defineTheme.d.ts +1 -1
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/hct.d.ts +1 -0
- package/dist/theme/hct.d.ts.map +1 -1
- package/dist/theme/hct.js +3 -0
- package/locales/en.json +0 -28
- package/locales/pseudo.json +0 -21
- package/package.json +1 -3
- package/src/CheckboxInput/CheckboxInput.doc.mjs +1 -1
- package/src/Collapsible/Collapsible.doc.mjs +0 -7
- package/src/Collapsible/Collapsible.test.tsx +0 -80
- package/src/Collapsible/Collapsible.tsx +5 -58
- package/src/ContextMenu/ContextMenu.test.tsx +1 -75
- package/src/ContextMenu/ContextMenu.tsx +5 -10
- package/src/ContextMenu/index.ts +0 -15
- package/src/DropdownMenu/DropdownMenu.doc.mjs +0 -23
- package/src/DropdownMenu/DropdownMenu.tsx +6 -11
- package/src/DropdownMenu/DropdownMenuContext.tsx +1 -29
- package/src/DropdownMenu/DropdownMenuItem.doc.mjs +1 -7
- package/src/DropdownMenu/index.ts +3 -23
- package/src/Field/Field.doc.mjs +1 -1
- package/src/Field/FieldLabel.doc.mjs +1 -1
- package/src/Icon/Icon.test.tsx +0 -46
- package/src/Icon/Icon.tsx +24 -37
- package/src/NumberInput/NumberInput.doc.mjs +2 -2
- package/src/Outline/Outline.doc.mjs +3 -123
- package/src/Outline/Outline.test.tsx +0 -735
- package/src/Outline/Outline.tsx +33 -184
- package/src/Outline/useScrollSpy.ts +72 -248
- package/src/Selector/SelectorOption.doc.mjs +1 -1
- package/src/SideNav/SideNavItem.doc.mjs +2 -2
- package/src/Switch/Switch.doc.mjs +1 -1
- package/src/TabList/Tab.tsx +1 -5
- package/src/TabList/TabList.doc.mjs +3 -3
- package/src/TabList/TabList.test.tsx +0 -66
- package/src/TabList/TabList.tsx +0 -8
- package/src/TabList/TabMenu.tsx +1 -4
- package/src/Table/Table.doc.mjs +0 -2
- package/src/Table/index.ts +0 -7
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.test.tsx +1 -90
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +5 -37
- package/src/Table/plugins/sortable/useTableSortable.test.tsx +9 -95
- package/src/Table/plugins/sortable/useTableSortable.tsx +7 -23
- package/src/Table/useBaseTablePlugins.ts +2 -6
- package/src/TextArea/TextArea.doc.mjs +1 -1
- package/src/TextInput/TextInput.doc.mjs +1 -1
- package/src/Toolbar/Toolbar.tsx +3 -10
- package/src/theme/Theme.doc.mjs +4 -4
- package/src/theme/Theme.tsx +1 -1
- package/src/theme/defineTheme.ts +1 -1
- package/src/theme/hct.ts +4 -0
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts +0 -89
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +0 -170
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +0 -69
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +0 -70
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts +0 -69
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +0 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +0 -178
- package/dist/DropdownMenu/menuItemRoles.d.ts +0 -13
- package/dist/DropdownMenu/menuItemRoles.d.ts.map +0 -1
- package/dist/DropdownMenu/menuItemRoles.js +0 -15
- package/dist/Table/plugins/tree/index.d.ts +0 -5
- package/dist/Table/plugins/tree/index.d.ts.map +0 -1
- package/dist/Table/plugins/tree/index.js +0 -4
- package/dist/Table/plugins/tree/useTableTreeData.d.ts +0 -38
- package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +0 -1
- package/dist/Table/plugins/tree/useTableTreeData.js +0 -358
- package/dist/Table/plugins/tree/useTableTreeState.d.ts +0 -51
- package/dist/Table/plugins/tree/useTableTreeState.d.ts.map +0 -1
- package/dist/Table/plugins/tree/useTableTreeState.js +0 -175
- package/scripts/postinstall.mjs +0 -93
- package/src/DropdownMenu/DropdownMenuCheckboxItem.doc.mjs +0 -95
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +0 -237
- package/src/DropdownMenu/DropdownMenuRadioGroup.doc.mjs +0 -80
- package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +0 -119
- package/src/DropdownMenu/DropdownMenuRadioItem.doc.mjs +0 -80
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +0 -232
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +0 -163
- package/src/DropdownMenu/menuItemRoles.ts +0 -22
- package/src/Table/plugins/tree/index.ts +0 -12
- package/src/Table/plugins/tree/useTableTreeData-perf.test.tsx +0 -163
- package/src/Table/plugins/tree/useTableTreeData.test.tsx +0 -594
- package/src/Table/plugins/tree/useTableTreeData.tsx +0 -495
- package/src/Table/plugins/tree/useTableTreeState.test.tsx +0 -636
- package/src/Table/plugins/tree/useTableTreeState.tsx +0 -253
- package/src/Table/useTableTreeData.doc.mjs +0 -75
- package/src/Table/useTableTreeState.doc.mjs +0 -98
- package/src/postinstall.test.mjs +0 -71
|
@@ -14,14 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
import {createContext, use} from 'react';
|
|
16
16
|
|
|
17
|
-
/** Menu size, derived from the trigger button size. */
|
|
18
|
-
export type DropdownMenuSize = 'sm' | 'md' | 'lg';
|
|
19
|
-
|
|
20
17
|
export interface DropdownMenuContextValue {
|
|
21
18
|
/** Close the menu and return focus to trigger */
|
|
22
19
|
closeMenu: () => void;
|
|
23
20
|
/** Menu size derived from button size */
|
|
24
|
-
menuSize:
|
|
21
|
+
menuSize: 'sm' | 'md' | 'lg';
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export const DropdownMenuContext =
|
|
@@ -35,28 +32,3 @@ DropdownMenuContext.displayName = 'DropdownMenuContext';
|
|
|
35
32
|
export function useDropdownMenuContext(): DropdownMenuContextValue | null {
|
|
36
33
|
return use(DropdownMenuContext);
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
// =============================================================================
|
|
40
|
-
// Radio group coordination
|
|
41
|
-
// =============================================================================
|
|
42
|
-
|
|
43
|
-
export interface DropdownMenuRadioGroupContextValue {
|
|
44
|
-
/** The currently selected value in the group. */
|
|
45
|
-
value: string | undefined;
|
|
46
|
-
/** Select a value. Called by a DropdownMenuRadioItem on activation. */
|
|
47
|
-
onChange: (value: string) => void;
|
|
48
|
-
/** Whether selecting an item should close the menu. @default true */
|
|
49
|
-
hasCloseOnSelect: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const DropdownMenuRadioGroupContext =
|
|
53
|
-
createContext<DropdownMenuRadioGroupContextValue | null>(null);
|
|
54
|
-
DropdownMenuRadioGroupContext.displayName = 'DropdownMenuRadioGroupContext';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Read the enclosing radio group's selection state.
|
|
58
|
-
* Returns null when used outside a DropdownMenuRadioGroup.
|
|
59
|
-
*/
|
|
60
|
-
export function useDropdownMenuRadioGroupContext(): DropdownMenuRadioGroupContextValue | null {
|
|
61
|
-
return use(DropdownMenuRadioGroupContext);
|
|
62
|
-
}
|
|
@@ -8,17 +8,11 @@ export const docs = {
|
|
|
8
8
|
displayName: 'Dropdown Menu Item',
|
|
9
9
|
isHiddenFromOverview: true,
|
|
10
10
|
description: 'Helper component for custom item rendering with consistent styling.',
|
|
11
|
-
playground: {
|
|
12
|
-
// Standalone DropdownMenuItem has no required props, so the properties-tab
|
|
13
|
-
// preview renders an empty row without seeded content. Seed a label and
|
|
14
|
-
// description so the preview is meaningful.
|
|
15
|
-
defaults: {label: 'Edit', description: 'Modify this item'},
|
|
16
|
-
},
|
|
17
11
|
props: [
|
|
18
12
|
{
|
|
19
13
|
name: 'icon',
|
|
20
14
|
type: 'IconType',
|
|
21
|
-
description: 'Icon to display before the label. See `astryx docs icons` for valid semantic names.',
|
|
15
|
+
description: 'Icon to display before the label. See `npx astryx docs icons` for valid semantic names.',
|
|
22
16
|
},
|
|
23
17
|
{
|
|
24
18
|
name: 'label',
|
|
@@ -18,27 +18,7 @@ export {
|
|
|
18
18
|
type DropdownMenuOption,
|
|
19
19
|
} from './DropdownMenu';
|
|
20
20
|
|
|
21
|
-
export {DropdownMenuItem, type DropdownMenuItemProps} from './DropdownMenuItem';
|
|
22
|
-
|
|
23
|
-
// Selectable items — checkbox (independent) and radio (single-select group).
|
|
24
|
-
export {
|
|
25
|
-
DropdownMenuCheckboxItem,
|
|
26
|
-
type DropdownMenuCheckboxItemProps,
|
|
27
|
-
} from './DropdownMenuCheckboxItem';
|
|
28
|
-
export {
|
|
29
|
-
DropdownMenuRadioGroup,
|
|
30
|
-
type DropdownMenuRadioGroupProps,
|
|
31
|
-
} from './DropdownMenuRadioGroup';
|
|
32
|
-
export {
|
|
33
|
-
DropdownMenuRadioItem,
|
|
34
|
-
type DropdownMenuRadioItemProps,
|
|
35
|
-
} from './DropdownMenuRadioItem';
|
|
36
|
-
|
|
37
|
-
// Menu-coordination context — public so consumers can build custom menu items
|
|
38
|
-
// that read the menu size / close the menu.
|
|
39
21
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type DropdownMenuSize,
|
|
44
|
-
} from './DropdownMenuContext';
|
|
22
|
+
DropdownMenuItem,
|
|
23
|
+
type DropdownMenuItemProps,
|
|
24
|
+
} from './DropdownMenuItem';
|
package/src/Field/Field.doc.mjs
CHANGED
|
@@ -95,7 +95,7 @@ export const docs = {
|
|
|
95
95
|
{
|
|
96
96
|
name: 'labelIcon',
|
|
97
97
|
type: 'IconType',
|
|
98
|
-
description: 'Icon to display before the label text. See `astryx docs icons` for valid semantic names.',
|
|
98
|
+
description: 'Icon to display before the label text. See `npx astryx docs icons` for valid semantic names.',
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
name: 'labelTooltip',
|
|
@@ -48,7 +48,7 @@ export const docs = {
|
|
|
48
48
|
{
|
|
49
49
|
name: 'labelIcon',
|
|
50
50
|
type: 'IconType',
|
|
51
|
-
description: 'Icon before the label text. See `astryx docs icons` for valid semantic names.',
|
|
51
|
+
description: 'Icon before the label text. See `npx astryx docs icons` for valid semantic names.',
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
name: 'labelTooltip',
|
package/src/Icon/Icon.test.tsx
CHANGED
|
@@ -96,52 +96,6 @@ describe('Icon', () => {
|
|
|
96
96
|
expect(screen.getByTestId('icon')).toBeInTheDocument();
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
it('sizes component-mode icons in rem so they scale with root font-size', () => {
|
|
100
|
-
const sizes = {
|
|
101
|
-
xsm: '0.75rem',
|
|
102
|
-
sm: '1rem',
|
|
103
|
-
md: '1.25rem',
|
|
104
|
-
lg: '1.5rem',
|
|
105
|
-
} as const;
|
|
106
|
-
for (const [size, expected] of Object.entries(sizes)) {
|
|
107
|
-
const {unmount} = render(
|
|
108
|
-
<Icon
|
|
109
|
-
icon={TestIcon}
|
|
110
|
-
size={size as keyof typeof sizes}
|
|
111
|
-
data-testid="icon"
|
|
112
|
-
/>,
|
|
113
|
-
);
|
|
114
|
-
const style = getComputedStyle(screen.getByTestId('icon'));
|
|
115
|
-
expect(style.width).toBe(expected);
|
|
116
|
-
expect(style.height).toBe(expected);
|
|
117
|
-
unmount();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('sizes registry (string-mode) icons in rem, including fontSize', () => {
|
|
122
|
-
const sizes = {
|
|
123
|
-
xsm: '0.75rem',
|
|
124
|
-
sm: '1rem',
|
|
125
|
-
md: '1.25rem',
|
|
126
|
-
lg: '1.5rem',
|
|
127
|
-
} as const;
|
|
128
|
-
for (const [size, expected] of Object.entries(sizes)) {
|
|
129
|
-
const {unmount} = render(
|
|
130
|
-
<Icon
|
|
131
|
-
icon="check"
|
|
132
|
-
size={size as keyof typeof sizes}
|
|
133
|
-
data-testid="icon"
|
|
134
|
-
/>,
|
|
135
|
-
);
|
|
136
|
-
const style = getComputedStyle(screen.getByTestId('icon'));
|
|
137
|
-
expect(style.width).toBe(expected);
|
|
138
|
-
expect(style.height).toBe(expected);
|
|
139
|
-
// fontSize is expressed in rem so 1em-based registry icons scale too.
|
|
140
|
-
expect(style.fontSize).toBe(expected);
|
|
141
|
-
unmount();
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
99
|
it('forwards ref correctly', () => {
|
|
146
100
|
const ref = vi.fn();
|
|
147
101
|
render(<Icon icon={TestIcon} ref={ref} />);
|
package/src/Icon/Icon.tsx
CHANGED
|
@@ -111,64 +111,51 @@ const colorStyles = stylex.create({
|
|
|
111
111
|
/**
|
|
112
112
|
* Size styles for direct SVG icon components.
|
|
113
113
|
* Uses width/height only — SVG components handle their own viewBox scaling.
|
|
114
|
-
*
|
|
115
|
-
* Sizes are expressed in `rem` (relative to the root font-size) so icons scale
|
|
116
|
-
* in step with text when the document font-size changes, matching the rest of
|
|
117
|
-
* the design system's rem-based type scale. Values are the px-equivalents at a
|
|
118
|
-
* 16px root: 12px → 0.75rem, 16px → 1rem, 20px → 1.25rem, 24px → 1.5rem.
|
|
119
114
|
*/
|
|
120
115
|
const sizeStyles = stylex.create({
|
|
121
116
|
xsm: {
|
|
122
|
-
width:
|
|
123
|
-
height:
|
|
117
|
+
width: 12,
|
|
118
|
+
height: 12,
|
|
124
119
|
},
|
|
125
120
|
sm: {
|
|
126
|
-
width:
|
|
127
|
-
height:
|
|
121
|
+
width: 16,
|
|
122
|
+
height: 16,
|
|
128
123
|
},
|
|
129
124
|
md: {
|
|
130
|
-
width:
|
|
131
|
-
height:
|
|
125
|
+
width: 20,
|
|
126
|
+
height: 20,
|
|
132
127
|
},
|
|
133
128
|
lg: {
|
|
134
|
-
width:
|
|
135
|
-
height:
|
|
129
|
+
width: 24,
|
|
130
|
+
height: 24,
|
|
136
131
|
},
|
|
137
132
|
});
|
|
138
133
|
|
|
139
134
|
/**
|
|
140
135
|
* Size styles for string-based (registry) icons.
|
|
141
136
|
* Includes fontSize so that 1em-based icons from the registry scale correctly.
|
|
142
|
-
*
|
|
143
|
-
* Expressed in `rem` for the same reason as {@link sizeStyles} — icons track the
|
|
144
|
-
* root font-size instead of being locked to absolute pixels.
|
|
145
137
|
*/
|
|
146
138
|
const spanSizeStyles = stylex.create({
|
|
147
|
-
/* eslint-disable @astryx/no-hardcoded-styles -- fontSize here sizes 1em-based
|
|
148
|
-
registry SVGs to the icon box; icons use their own 12/16/20/24 scale, not
|
|
149
|
-
the 14px-anchored textSizeVars type scale. Values are rem so icons track
|
|
150
|
-
the root font-size. */
|
|
151
139
|
xsm: {
|
|
152
|
-
width:
|
|
153
|
-
height:
|
|
154
|
-
fontSize:
|
|
140
|
+
width: 12,
|
|
141
|
+
height: 12,
|
|
142
|
+
fontSize: 12,
|
|
155
143
|
},
|
|
156
144
|
sm: {
|
|
157
|
-
width:
|
|
158
|
-
height:
|
|
159
|
-
fontSize:
|
|
145
|
+
width: 16,
|
|
146
|
+
height: 16,
|
|
147
|
+
fontSize: 16,
|
|
160
148
|
},
|
|
161
149
|
md: {
|
|
162
|
-
width:
|
|
163
|
-
height:
|
|
164
|
-
fontSize:
|
|
150
|
+
width: 20,
|
|
151
|
+
height: 20,
|
|
152
|
+
fontSize: 20,
|
|
165
153
|
},
|
|
166
154
|
lg: {
|
|
167
|
-
width:
|
|
168
|
-
height:
|
|
169
|
-
fontSize:
|
|
155
|
+
width: 24,
|
|
156
|
+
height: 24,
|
|
157
|
+
fontSize: 24,
|
|
170
158
|
},
|
|
171
|
-
/* eslint-enable @astryx/no-hardcoded-styles */
|
|
172
159
|
});
|
|
173
160
|
|
|
174
161
|
// =============================================================================
|
|
@@ -207,10 +194,10 @@ export interface IconProps extends Omit<
|
|
|
207
194
|
color?: IconColor;
|
|
208
195
|
/**
|
|
209
196
|
* The size of the icon.
|
|
210
|
-
* - 'xsm':
|
|
211
|
-
* - 'sm':
|
|
212
|
-
* - 'md':
|
|
213
|
-
* - 'lg':
|
|
197
|
+
* - 'xsm': 12px
|
|
198
|
+
* - 'sm': 16px
|
|
199
|
+
* - 'md': 20px
|
|
200
|
+
* - 'lg': 24px
|
|
214
201
|
* @default 'md'
|
|
215
202
|
*/
|
|
216
203
|
size?: IconSize;
|
|
@@ -82,12 +82,12 @@ export const docs = {
|
|
|
82
82
|
{
|
|
83
83
|
name: 'startIcon',
|
|
84
84
|
type: 'IconType',
|
|
85
|
-
description: 'Icon to display at the start of the input. See `astryx docs icons` for valid semantic names.',
|
|
85
|
+
description: 'Icon to display at the start of the input. See `npx astryx docs icons` for valid semantic names.',
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
name: 'labelIcon',
|
|
89
89
|
type: 'IconType',
|
|
90
|
-
description: 'Icon to display before the label text. See `astryx docs icons` for valid semantic names.',
|
|
90
|
+
description: 'Icon to display before the label text. See `npx astryx docs icons` for valid semantic names.',
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
name: 'status',
|
|
@@ -72,38 +72,6 @@ export const docs = {
|
|
|
72
72
|
description: "Density variant controlling item padding. 'compact' for dense UIs, 'default' for standard spacing.",
|
|
73
73
|
default: "'default'",
|
|
74
74
|
},
|
|
75
|
-
{
|
|
76
|
-
name: 'onNavigateStart',
|
|
77
|
-
type: '(id: string) => void',
|
|
78
|
-
description:
|
|
79
|
-
'Called with the item id when navigation begins, before the scroll starts. Pair with onNavigateEnd to drive an arrival effect (flash, ring, pulse) on the target heading.',
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: 'onNavigateEnd',
|
|
83
|
-
type: '(id: string) => void',
|
|
84
|
-
description:
|
|
85
|
-
'Called with the item id once the navigation resolves - when the smooth scroll settles, or when reduced motion turns it into an instant jump. Fires exactly once per onNavigateStart, including when the user interrupts the scroll, so a "navigating" state can never leak.',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'offset',
|
|
89
|
-
type: 'number',
|
|
90
|
-
description:
|
|
91
|
-
"Height in px of a fixed header overlaying the top of the scroll root. Shifts both the activation line and the scroll landing by the same amount, so a heading activates exactly where navigating to it puts it - below the header, not underneath it. Composes with each heading's own scroll-margin-top (the header, then the breathing room below it); it does not replace it. Leave at 0 when nothing overlays the content and let scroll-margin-top do the work.",
|
|
92
|
-
default: '0',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'scrollContainerRef',
|
|
96
|
-
type: 'React.RefObject<HTMLElement | null>',
|
|
97
|
-
description:
|
|
98
|
-
'Scroll container to track, instead of auto-detecting the nearest scrollable ancestor. Use it when content scrolls inside a split pane, modal, or dashboard panel rather than the viewport.',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'hasScrollOnClick',
|
|
102
|
-
type: 'boolean',
|
|
103
|
-
description:
|
|
104
|
-
'Whether activating an item smooth-scrolls to it. Set to false to own the scrolling yourself (virtualized content, a router): the Outline still updates the active item, the hash, and the navigate callbacks, but performs no scroll.',
|
|
105
|
-
default: 'true',
|
|
106
|
-
},
|
|
107
75
|
{
|
|
108
76
|
name: 'xstyle',
|
|
109
77
|
type: 'StyleXStyles',
|
|
@@ -169,51 +137,6 @@ function MarkdownOutline({markdown}) {
|
|
|
169
137
|
const items = useOutlineFromMarkdown(markdown);
|
|
170
138
|
return <Outline items={items} />;
|
|
171
139
|
}
|
|
172
|
-
`,
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
label: 'Scoped scroll container (split pane, modal, panel)',
|
|
176
|
-
code: `
|
|
177
|
-
import {useRef} from 'react';
|
|
178
|
-
import {Outline} from '@astryxdesign/core/Outline';
|
|
179
|
-
|
|
180
|
-
function PanelDocs() {
|
|
181
|
-
const scrollContainerRef = useRef(null);
|
|
182
|
-
|
|
183
|
-
// Without scrollContainerRef the outline auto-detects the nearest scrollable
|
|
184
|
-
// ancestor, which is the viewport here - so the highlight would never move.
|
|
185
|
-
return (
|
|
186
|
-
<div style={{display: 'flex'}}>
|
|
187
|
-
<div ref={scrollContainerRef} style={{overflowY: 'auto', height: 480}}>
|
|
188
|
-
<h2 id="overview">Overview</h2>
|
|
189
|
-
{/* ...content... */}
|
|
190
|
-
</div>
|
|
191
|
-
<Outline items={items} scrollContainerRef={scrollContainerRef} offset={64} />
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
`,
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
label: 'Navigate callbacks (flash the heading on arrival)',
|
|
199
|
-
code: `
|
|
200
|
-
import {useState} from 'react';
|
|
201
|
-
import {Outline} from '@astryxdesign/core/Outline';
|
|
202
|
-
|
|
203
|
-
function FlashOnArrival() {
|
|
204
|
-
const [flashId, setFlashId] = useState(null);
|
|
205
|
-
|
|
206
|
-
// onNavigateEnd fires once the smooth scroll settles - and once per
|
|
207
|
-
// onNavigateStart even if the user scrolls away mid-jump, so this never
|
|
208
|
-
// gets stuck.
|
|
209
|
-
return (
|
|
210
|
-
<Outline
|
|
211
|
-
items={items}
|
|
212
|
-
onNavigateStart={() => setFlashId(null)}
|
|
213
|
-
onNavigateEnd={id => setFlashId(id)}
|
|
214
|
-
/>
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
140
|
`,
|
|
218
141
|
},
|
|
219
142
|
],
|
|
@@ -221,17 +144,14 @@ function FlashOnArrival() {
|
|
|
221
144
|
],
|
|
222
145
|
usage: {
|
|
223
146
|
description:
|
|
224
|
-
'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes. Features a sliding indicator track that animates to the active heading.
|
|
147
|
+
'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes. Features a sliding indicator track that animates to the active heading.',
|
|
225
148
|
bestPractices: [
|
|
226
149
|
{guidance: true, description: 'Pass a flat ordered list of headings and let level control indentation.'},
|
|
227
150
|
{guidance: true, description: 'Use activeId when custom scroll logic owns the active section.'},
|
|
228
151
|
{guidance: true, description: 'Use density="compact" in dense sidebars where vertical space is tight.'},
|
|
229
152
|
{guidance: true, description: 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content.'},
|
|
230
|
-
{guidance: true, description: 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.'},
|
|
231
|
-
{guidance: true, description: 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.'},
|
|
232
153
|
{guidance: false, description: 'Use Outline for application navigation - use SideNav or TopNav for routes.'},
|
|
233
154
|
{guidance: false, description: 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.'},
|
|
234
|
-
{guidance: false, description: 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.'},
|
|
235
155
|
],
|
|
236
156
|
},
|
|
237
157
|
};
|
|
@@ -285,33 +205,6 @@ export const docsZh = {
|
|
|
285
205
|
description: "控制项目内边距的密度变体。'compact' 用于紧凑界面,'default' 为标准间距。",
|
|
286
206
|
default: "'default'",
|
|
287
207
|
},
|
|
288
|
-
{
|
|
289
|
-
name: 'onNavigateStart',
|
|
290
|
-
type: '(id: string) => void',
|
|
291
|
-
description: '导航开始时(滚动前)调用,传入项目 id。与 onNavigateEnd 搭配可在目标标题上实现到达效果(闪烁、描边、脉冲)。',
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
name: 'onNavigateEnd',
|
|
295
|
-
type: '(id: string) => void',
|
|
296
|
-
description: '导航结束时调用(平滑滚动停止,或减弱动效将其变为瞬时跳转)。每次 onNavigateStart 必定对应一次调用,包括用户中途手动滚动打断的情况,因此“导航中”状态不会泄漏。',
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: 'offset',
|
|
300
|
-
type: 'number',
|
|
301
|
-
description: '覆盖滚动根顶部的固定顶栏高度(px)。同时位移激活线与滚动落点,因此标题被激活的位置正是点击后停留的位置——落在顶栏下方,而非被顶栏遮住。它与每个标题自身的 scroll-margin-top 叠加(先顶栏,再留白),而非取代它。若没有元素覆盖内容,保持 0,交给 scroll-margin-top 处理。',
|
|
302
|
-
default: '0',
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
name: 'scrollContainerRef',
|
|
306
|
-
type: 'React.RefObject<HTMLElement | null>',
|
|
307
|
-
description: '要跟踪的滚动容器,替代自动探测最近的可滚动祖先。当内容在分栏、弹窗或面板中滚动而非视口时使用。',
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
name: 'hasScrollOnClick',
|
|
311
|
-
type: 'boolean',
|
|
312
|
-
description: '激活项目时是否平滑滚动。设为 false 可自行接管滚动(虚拟列表、路由):Outline 仍会更新激活项、hash 和导航回调,但不执行滚动。',
|
|
313
|
-
default: 'true',
|
|
314
|
-
},
|
|
315
208
|
{
|
|
316
209
|
name: 'xstyle',
|
|
317
210
|
type: 'StyleXStyles',
|
|
@@ -337,7 +230,7 @@ export const docsZh = {
|
|
|
337
230
|
/** @type {import('../docs-types').TranslationDoc} */
|
|
338
231
|
export const docsDense = {
|
|
339
232
|
description:
|
|
340
|
-
'Document outline/table-of-contents nav with sliding indicator track. Flat items array {id,label,level}; anchor links; density variant (default/compact); uncontrolled scroll-spy by scroll position (last heading past its
|
|
233
|
+
'Document outline/table-of-contents nav with sliding indicator track. Flat items array {id,label,level}; anchor links; density variant (default/compact); uncontrolled scroll-spy by scroll position (last heading past its scroll-margin-top line; first item at top, last at bottom); controlled with activeId; smooth-scroll on click that pins the active item until the next manual scroll.',
|
|
341
234
|
usage: {
|
|
342
235
|
description:
|
|
343
236
|
'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes.',
|
|
@@ -346,11 +239,8 @@ export const docsDense = {
|
|
|
346
239
|
{guidance: true, description: 'Use activeId when custom scroll logic owns the active section.'},
|
|
347
240
|
{guidance: true, description: 'Use density="compact" in dense sidebars where vertical space is tight.'},
|
|
348
241
|
{guidance: true, description: 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content.'},
|
|
349
|
-
{guidance: true, description: 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.'},
|
|
350
|
-
{guidance: true, description: 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.'},
|
|
351
242
|
{guidance: false, description: 'Use Outline for application navigation - use SideNav or TopNav for routes.'},
|
|
352
243
|
{guidance: false, description: 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.'},
|
|
353
|
-
{guidance: false, description: 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.'},
|
|
354
244
|
],
|
|
355
245
|
},
|
|
356
246
|
propDescriptions: {
|
|
@@ -359,11 +249,6 @@ export const docsDense = {
|
|
|
359
249
|
onActiveIdChange: 'Called when active id changes from scroll-spy or click.',
|
|
360
250
|
label: "Accessible nav label. Default: 'Table of contents'.",
|
|
361
251
|
density: "Density variant: 'default' (standard) or 'compact'. Default: 'default'.",
|
|
362
|
-
onNavigateStart: 'Called with the id when navigation begins, before the scroll.',
|
|
363
|
-
onNavigateEnd: 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
|
|
364
|
-
offset: 'Height in px of a fixed header overlaying the scroll root. Shifts BOTH the activation line and the scroll landing, so a heading activates where navigating to it lands it. Composes with (does not replace) each heading scroll-margin-top. Default: 0.',
|
|
365
|
-
scrollContainerRef: 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor. For split panes, modals, panels.',
|
|
366
|
-
hasScrollOnClick: 'Whether activating an item smooth-scrolls to it. false = you own scrolling; active id, hash and callbacks still update. Default: true.',
|
|
367
252
|
xstyle: 'StyleX styles for layout. Must be stylex.create() value.',
|
|
368
253
|
},
|
|
369
254
|
components: [
|
|
@@ -371,18 +256,13 @@ export const docsDense = {
|
|
|
371
256
|
name: 'Outline',
|
|
372
257
|
displayName: 'Outline',
|
|
373
258
|
description:
|
|
374
|
-
'Document outline nav with sliding indicator. Renders heading anchors with a density variant
|
|
259
|
+
'Document outline nav with sliding indicator. Renders heading anchors with a density variant and manages scroll-spy active state when uncontrolled.',
|
|
375
260
|
propDescriptions: {
|
|
376
261
|
items: 'Ordered OutlineItem[]: {id,label,level}. id should match target heading DOM id.',
|
|
377
262
|
activeId: 'Controlled active heading id. Disables built-in scroll-spy.',
|
|
378
263
|
onActiveIdChange: 'Called when active id changes from scroll-spy or click.',
|
|
379
264
|
label: "Accessible nav label. Default: 'Table of contents'.",
|
|
380
265
|
density: "Density variant: 'default' | 'compact'. Default: 'default'.",
|
|
381
|
-
onNavigateStart: 'Called with the id when navigation begins, before the scroll.',
|
|
382
|
-
onNavigateEnd: 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
|
|
383
|
-
offset: 'Height in px of a fixed header overlaying the scroll root. Shifts both the activation line and the scroll landing. Composes with scroll-margin-top. Default: 0.',
|
|
384
|
-
scrollContainerRef: 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor.',
|
|
385
|
-
hasScrollOnClick: 'Whether activating an item smooth-scrolls to it. Default: true.',
|
|
386
266
|
xstyle: 'StyleX styles for layout. Must be stylex.create() value.',
|
|
387
267
|
},
|
|
388
268
|
},
|