@astryxdesign/core 0.7.2-canary.e2909cf → 0.7.2-canary.fbc03f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +5 -2
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +5 -2
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +46 -3
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -0
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +21 -0
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +15 -4
- package/dist/Field/Field.d.ts +1 -1
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +8 -4
- package/dist/Grid/GridSpan.d.ts.map +1 -1
- package/dist/Grid/GridSpan.js +1 -0
- package/dist/MetadataList/MetadataList.d.ts.map +1 -1
- package/dist/MetadataList/MetadataList.js +5 -1
- package/dist/MetadataList/MetadataListContext.d.ts +1 -1
- package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
- package/dist/RadioList/RadioList.d.ts +1 -1
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +6 -2
- package/dist/ToggleButton/ToggleButton.d.ts +3 -2
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +12 -1
- package/dist/astryx.css +1 -0
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +18 -13
- package/package.json +3 -3
- package/src/Avatar/Avatar.doc.mjs +5 -3
- package/src/AvatarGroup/AvatarGroup.doc.mjs +3 -2
- package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
- package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +3 -1
- package/src/ContextMenu/ContextMenu.tsx +4 -1
- package/src/DropdownMenu/DropdownMenu.tsx +45 -2
- package/src/DropdownMenu/DropdownMenuContext.tsx +24 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +185 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +17 -3
- package/src/Field/Field.doc.mjs +14 -8
- package/src/Field/Field.spec.md +217 -0
- package/src/Field/Field.test.tsx +60 -2
- package/src/Field/Field.tsx +17 -8
- package/src/Grid/GridSpan.tsx +3 -0
- package/src/MetadataList/MetadataList.doc.mjs +2 -2
- package/src/MetadataList/MetadataList.test.tsx +38 -0
- package/src/MetadataList/MetadataList.tsx +8 -1
- package/src/MetadataList/MetadataListContext.tsx +1 -1
- package/src/RadioList/RadioList.fr10.test.tsx +45 -2
- package/src/RadioList/RadioList.tsx +4 -1
- package/src/Slider/Slider.spec.md +39 -18
- package/src/TimeInput/TimeInput.fr10.test.tsx +15 -0
- package/src/ToggleButton/ToggleButton.test.tsx +95 -0
- package/src/ToggleButton/ToggleButton.tsx +12 -1
- package/src/docPropLiterals.test.ts +36 -10
- package/src/hooks/useMenuHover.ts +18 -13
|
@@ -34,13 +34,20 @@ an additive target for the interactive control surface.
|
|
|
34
34
|
|
|
35
35
|
## Compatibility and migration
|
|
36
36
|
|
|
37
|
-
- Released default preserved: `
|
|
37
|
+
- Released default preserved: `no` — FR5 changes the released `onChangeEnd`
|
|
38
|
+
payload; every other released default is unchanged
|
|
38
39
|
- Compatibility class: additive target and state reflection; default styling,
|
|
39
40
|
DOM semantics, and public props remain unchanged, and the one keyboard change
|
|
40
41
|
AR1 names — the horizontal arrows follow the track's direction under RTL —
|
|
41
42
|
ships as a behavior fix
|
|
43
|
+
- `onChangeEnd` payload (FR5): a new contract decision (`spec:AST-017/FR33`),
|
|
44
|
+
not a correction. Released victim: an owner that moves `value` only from
|
|
45
|
+
`onChangeEnd`, with no `onChange`, moves by keyboard today and does not under
|
|
46
|
+
FR5, so the change is breaking (`spec:AST-017/FR1`) and ships as
|
|
47
|
+
`[breaking]` in a declared minor (`spec:AST-017/FR31`).
|
|
42
48
|
- Controlled/uncontrolled behavior: unchanged; Slider remains controlled
|
|
43
|
-
- Migration decision:
|
|
49
|
+
- Migration decision: an owner that moves `value` only from `onChangeEnd`
|
|
50
|
+
moves it from `onChange` instead (FR5)
|
|
44
51
|
|
|
45
52
|
Consumer migration instructions belong in consumer docs and release notes.
|
|
46
53
|
|
|
@@ -64,18 +71,20 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
64
71
|
|
|
65
72
|
## Public concepts
|
|
66
73
|
|
|
67
|
-
The record adds one public theming target
|
|
68
|
-
|
|
74
|
+
The record adds one public theming target, names the keyboard model (AR1), and
|
|
75
|
+
states which value `onChangeEnd` carries (FR5) without adding or changing a
|
|
76
|
+
component prop or value domain. Consumer props,
|
|
69
77
|
modes, states, and usage remain documented in `Slider.doc.mjs`.
|
|
70
78
|
|
|
71
79
|
## Behavioral and layout contract
|
|
72
80
|
|
|
73
|
-
| ID | Candidate invariant
|
|
74
|
-
| --- |
|
|
75
|
-
| FR1 | The current render places a filled range, one or two thumbs, and optional tick marks over the background track.
|
|
76
|
-
| FR2 | `Slider`, `Interactive control`, `Track`, and `Thumb` carry the `slider`, `slider-control`, `slider-track`, and `slider-thumb` targets respectively.
|
|
77
|
-
| FR3 | Filled range, tick marks, mark labels, and adjacent text value display are stable rendered parts without their own current Slider target.
|
|
78
|
-
| FR4 | Label and status presentation continue to use Field and FieldStatus; value tooltips continue to use Tooltip.
|
|
81
|
+
| ID | Candidate invariant | Basis | Review state |
|
|
82
|
+
| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | -------------------------------------------------- |
|
|
83
|
+
| FR1 | The current render places a filled range, one or two thumbs, and optional tick marks over the background track. | Current source, docs, and focused tests | Verified current behavior; no new behavior decided |
|
|
84
|
+
| FR2 | `Slider`, `Interactive control`, `Track`, and `Thumb` carry the `slider`, `slider-control`, `slider-track`, and `slider-thumb` targets respectively. | Current source, public docs, and DEC-1 | Approved additive target contract |
|
|
85
|
+
| FR3 | Filled range, tick marks, mark labels, and adjacent text value display are stable rendered parts without their own current Slider target. | Current source and public docs | Verified current asymmetry; not ratified as policy |
|
|
86
|
+
| FR4 | Label and status presentation continue to use Field and FieldStatus; value tooltips continue to use Tooltip. | Current source and focused tests | Verified composition boundary |
|
|
87
|
+
| FR5 | `onChangeEnd` fires once when an interaction ends — a pointer drag or track press is released or cancelled, or a keyboard step (arrow, Page, Home, End) completes — and carries the value the owner renders after its synchronous response to that interaction's `onChange` calls, including any clamp, snap, or rejection; it never carries a value Slider emitted that the owner did not render. A range reports both values the same way. | Maintainer decision (DEC-3) | Approved |
|
|
79
88
|
|
|
80
89
|
### Observed current target asymmetry
|
|
81
90
|
|
|
@@ -106,6 +115,8 @@ either component's remaining target shape.
|
|
|
106
115
|
|
|
107
116
|
- ORD1: an arrow or Page key result snaps to the nearest step, then clamps to
|
|
108
117
|
the bounds; Home and End go to `min` and `max` (AR1).
|
|
118
|
+
- ORD2: within one interaction, Slider calls `onChange`, the owner responds and
|
|
119
|
+
renders, then `onChangeEnd` reports the rendered value (FR5).
|
|
109
120
|
- The anatomy decision (DEC-1) introduces no value, snapping, geometry,
|
|
110
121
|
interaction, or styling precedence rule of its own.
|
|
111
122
|
|
|
@@ -214,14 +225,15 @@ separately listed value tooltip retains Tooltip's target.
|
|
|
214
225
|
|
|
215
226
|
## Verification map
|
|
216
227
|
|
|
217
|
-
| Contract | Verification | Representative states
|
|
218
|
-
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
219
|
-
| FR1 | `Slider.test.tsx` structure, range, and marks suites | Single, range, horizontal, vertical, marks
|
|
220
|
-
| AR1 | Slider accessibility contract (`internal/a11y-spec`, pending) bound to Slider, in jsdom and Chromium; `Slider.test.tsx` keyboard suites, including "follows the mirrored track under RTL: ArrowLeft increases, ArrowRight decreases, Up/Down unchanged" and "keeps ArrowLeft decreasing on a vertical track under RTL"; the Page, Home/End and Up/Down cases under the contract | Single and range; horizontal LTR and RTL; vertical; disabled; formatted value
|
|
221
|
-
| FR2 | `Slider.test.tsx`, `themingTargets.test.ts`, generated probe theme, and Chromium | Root, horizontal/vertical control, disabled control, track, and thumb
|
|
222
|
-
| FR3 | Source and consumer-doc review | Filled range, marks, labels, adjacent text value
|
|
223
|
-
| FR4 | Source inspection; focused tests cover label, status, and disabled-reason Tooltip only | Label, status, value tooltip, disabled reason
|
|
224
|
-
|
|
|
228
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
229
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
|
|
230
|
+
| FR1 | `Slider.test.tsx` structure, range, and marks suites | Single, range, horizontal, vertical, marks | Removing or misaligning stable parts breaks existing role, position, or mark assertions. | `audit:Slider/anatomy` |
|
|
231
|
+
| AR1 | Slider accessibility contract (`internal/a11y-spec`, pending) bound to Slider, in jsdom and Chromium; `Slider.test.tsx` keyboard suites, including "follows the mirrored track under RTL: ArrowLeft increases, ArrowRight decreases, Up/Down unchanged" and "keeps ArrowLeft decreasing on a vertical track under RTL"; the Page, Home/End and Up/Down cases under the contract | Single and range; horizontal LTR and RTL; vertical; disabled; formatted value | A thumb loses its role, name or value properties; an arrow, Page, Home or End key stops stepping or steps against the mirrored track; a range thumb crosses the other | `audit:Slider/accessibility` |
|
|
232
|
+
| FR2 | `Slider.test.tsx`, `themingTargets.test.ts`, generated probe theme, and Chromium | Root, horizontal/vertical control, disabled control, track, and thumb | A target class/state is missing, undocumented, or placed outside its owning anatomy. | `audit:Slider/theming` |
|
|
233
|
+
| FR3 | Source and consumer-doc review | Filled range, marks, labels, adjacent text value | A missing target is inaccurately documented as present or intentionally permanent. | `audit:Slider/theming` |
|
|
234
|
+
| FR4 | Source inspection; focused tests cover label, status, and disabled-reason Tooltip only | Label, status, value tooltip, disabled reason | Shared composition or its accessible association disappears; value-tooltip composition still lacks focused coverage. | `audit:Slider/anatomy` |
|
|
235
|
+
| FR5 | Pending: `Slider.test.tsx` change-end cases driven by an owner that renders, clamps, or rejects the emitted value (not yet in the suite) | Single and range; pointer release before and after the owner re-renders; each keyboard step | `onChangeEnd` reports a value the owner did not render, fires more than once per interaction, or skips a completed keyboard step | `audit:Slider/accessibility` |
|
|
236
|
+
| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and four current local targets | Missing, extra, prefixed, stale, or unclaimed mappings fail repository validation. | `audit:Slider/theming` |
|
|
225
237
|
|
|
226
238
|
The focused Slider suite asserts the `slider-control` target's orientation and
|
|
227
239
|
disabled state. Source/metadata guards cover all four target declarations. The
|
|
@@ -250,6 +262,15 @@ A thumb already plays the slider role as one composite control, so it carries th
|
|
|
250
262
|
|
|
251
263
|
Rejected: keeping ArrowRight as "increase" under RTL; a Tab stop or arrow model per range thumb that differs from the single thumb.
|
|
252
264
|
|
|
265
|
+
### DEC-3 — `onChangeEnd` reports the value the owner renders
|
|
266
|
+
|
|
267
|
+
**Reference:** `component:Slider/DEC-3`
|
|
268
|
+
**Decider:** `cixzhang`, `2026-10-16`
|
|
269
|
+
|
|
270
|
+
`onChangeEnd` marks the end of an interaction, so it reports what the slider shows when the interaction ends: the controlled value after the owner has answered `onChange`. An owner that clamps, snaps, or rejects a value therefore receives the value it kept, and the commit agrees with the thumb (FR5).
|
|
271
|
+
|
|
272
|
+
Rejected: reporting the last value Slider emitted through `onChange`.
|
|
273
|
+
|
|
253
274
|
## Open questions
|
|
254
275
|
|
|
255
276
|
- **OQ1 — After a joint ProgressBar and Slider family audit, should any shared
|
|
@@ -191,6 +191,21 @@ for (const [surface, presentation, selector] of SURFACES) {
|
|
|
191
191
|
expect(own?.textContent).toContain('Start');
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
+
it('puts hidden, inert, and dir on the control', () => {
|
|
195
|
+
render(
|
|
196
|
+
<TimeInput
|
|
197
|
+
label="Start"
|
|
198
|
+
presentation={presentation}
|
|
199
|
+
hidden
|
|
200
|
+
inert
|
|
201
|
+
dir="rtl"
|
|
202
|
+
/>,
|
|
203
|
+
);
|
|
204
|
+
expect(control(selector)).toHaveAttribute('hidden');
|
|
205
|
+
expect(control(selector)).toHaveAttribute('inert');
|
|
206
|
+
expect(control(selector)).toHaveAttribute('dir', 'rtl');
|
|
207
|
+
});
|
|
208
|
+
|
|
194
209
|
it('keeps control* on the control box in a horizontal-labels FormLayout', () => {
|
|
195
210
|
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
196
211
|
const {container} = render(
|
|
@@ -497,6 +497,78 @@ describe('ToggleButton', () => {
|
|
|
497
497
|
expect(button).not.toHaveAttribute('aria-busy', 'true');
|
|
498
498
|
await act(async () => {});
|
|
499
499
|
});
|
|
500
|
+
|
|
501
|
+
// family:buttons FR5: a caller onClick on a standalone ToggleButton runs
|
|
502
|
+
// before onPressedChange and pressedChangeAction, never replaces the toggle
|
|
503
|
+
// request, and cancels it only by calling preventDefault() itself.
|
|
504
|
+
describe('with a caller onClick', () => {
|
|
505
|
+
it('runs the caller onClick first, then requests the next state and runs the Action', async () => {
|
|
506
|
+
const calls: string[] = [];
|
|
507
|
+
render(
|
|
508
|
+
<ToggleButton
|
|
509
|
+
label="Compact"
|
|
510
|
+
isPressed={false}
|
|
511
|
+
onClick={() => calls.push('onClick')}
|
|
512
|
+
onPressedChange={next => calls.push(`onPressedChange:${next}`)}
|
|
513
|
+
pressedChangeAction={next => {
|
|
514
|
+
calls.push(`pressedChangeAction:${next}`);
|
|
515
|
+
}}
|
|
516
|
+
/>,
|
|
517
|
+
);
|
|
518
|
+
|
|
519
|
+
fireEvent.click(screen.getByRole('button', {name: 'Compact'}));
|
|
520
|
+
await act(async () => {});
|
|
521
|
+
|
|
522
|
+
expect(calls).toEqual([
|
|
523
|
+
'onClick',
|
|
524
|
+
'onPressedChange:true',
|
|
525
|
+
'pressedChangeAction:true',
|
|
526
|
+
]);
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it('requests no next state when the caller onClick calls preventDefault', async () => {
|
|
530
|
+
const onPressedChange = vi.fn();
|
|
531
|
+
const pressedChangeAction = vi.fn();
|
|
532
|
+
render(
|
|
533
|
+
<ToggleButton
|
|
534
|
+
label="Compact"
|
|
535
|
+
isPressed={false}
|
|
536
|
+
onClick={event => event.preventDefault()}
|
|
537
|
+
onPressedChange={onPressedChange}
|
|
538
|
+
pressedChangeAction={pressedChangeAction}
|
|
539
|
+
/>,
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
const button = screen.getByRole('button', {name: 'Compact'});
|
|
543
|
+
fireEvent.click(button);
|
|
544
|
+
await act(async () => {});
|
|
545
|
+
|
|
546
|
+
expect(onPressedChange).not.toHaveBeenCalled();
|
|
547
|
+
expect(pressedChangeAction).not.toHaveBeenCalled();
|
|
548
|
+
expect(button).toHaveAttribute('aria-pressed', 'false');
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('still requests the next state when the click was already prevented before the caller onClick ran', () => {
|
|
552
|
+
const onPressedChange = vi.fn();
|
|
553
|
+
render(
|
|
554
|
+
<div onClickCapture={event => event.preventDefault()}>
|
|
555
|
+
<ToggleButton
|
|
556
|
+
label="Compact"
|
|
557
|
+
isPressed={false}
|
|
558
|
+
onClick={() => {}}
|
|
559
|
+
onPressedChange={onPressedChange}
|
|
560
|
+
/>
|
|
561
|
+
</div>,
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
fireEvent.click(screen.getByRole('button', {name: 'Compact'}));
|
|
565
|
+
|
|
566
|
+
expect(onPressedChange).toHaveBeenCalledExactlyOnceWith(
|
|
567
|
+
true,
|
|
568
|
+
expect.anything(),
|
|
569
|
+
);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
500
572
|
});
|
|
501
573
|
|
|
502
574
|
// =============================================================================
|
|
@@ -721,6 +793,29 @@ describe.each(['single', 'multiple'] as const)(
|
|
|
721
793
|
expect(onPressedChange).not.toHaveBeenCalled();
|
|
722
794
|
expect(pressedChangeAction).not.toHaveBeenCalled();
|
|
723
795
|
});
|
|
796
|
+
|
|
797
|
+
// family:buttons FR11: a member's selection request comes from the group,
|
|
798
|
+
// and a caller onClick on the member must not replace it.
|
|
799
|
+
it('still asks the group to toggle a member that receives an onClick', async () => {
|
|
800
|
+
const onChange = vi.fn();
|
|
801
|
+
const onClick = vi.fn();
|
|
802
|
+
const groupProps =
|
|
803
|
+
type === 'single'
|
|
804
|
+
? {type, value: null, onChange}
|
|
805
|
+
: {type, value: [], onChange};
|
|
806
|
+
render(
|
|
807
|
+
<ToggleButtonGroup {...groupProps} label="View">
|
|
808
|
+
<ToggleButton value="grid" label="Grid" onClick={onClick} />
|
|
809
|
+
</ToggleButtonGroup>,
|
|
810
|
+
);
|
|
811
|
+
|
|
812
|
+
await userEvent.setup().click(screen.getByRole('button', {name: 'Grid'}));
|
|
813
|
+
|
|
814
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
815
|
+
expect(onChange).toHaveBeenCalledExactlyOnceWith(
|
|
816
|
+
type === 'single' ? 'grid' : ['grid'],
|
|
817
|
+
);
|
|
818
|
+
});
|
|
724
819
|
},
|
|
725
820
|
);
|
|
726
821
|
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* @position Thin wrapper over Button; adds controlled toggle pattern
|
|
10
10
|
*
|
|
11
11
|
* ToggleButton wraps Button with `isPressed` and adds:
|
|
12
|
-
* - `onPressedChange` from internal `onClick
|
|
12
|
+
* - `onPressedChange` from internal `onClick`, after any caller `onClick`;
|
|
13
|
+
* `pressedChangeAction` via Button
|
|
13
14
|
* - `pressedIcon` for outline-to-filled icon swap
|
|
14
15
|
* - Font weight shift on press with width reservation to prevent layout shift
|
|
15
16
|
* - Group integration via ToggleButtonGroupContext
|
|
@@ -258,6 +259,7 @@ export function ToggleButton({
|
|
|
258
259
|
xstyle,
|
|
259
260
|
className,
|
|
260
261
|
style,
|
|
262
|
+
onClick: onClickProp,
|
|
261
263
|
...props
|
|
262
264
|
}: ToggleButtonProps): ReactNode {
|
|
263
265
|
const group = useToggleButtonGroup();
|
|
@@ -287,11 +289,20 @@ export function ToggleButton({
|
|
|
287
289
|
if (isDisabled) {
|
|
288
290
|
return;
|
|
289
291
|
}
|
|
292
|
+
// A caller onClick (a trigger wrapper often supplies one) runs first and
|
|
293
|
+
// never replaces the toggle's own request (family:buttons FR5, FR11).
|
|
294
|
+
const wasPrevented = event.defaultPrevented;
|
|
295
|
+
onClickProp?.(event);
|
|
290
296
|
if (group && value != null) {
|
|
291
297
|
group.toggle(value);
|
|
292
298
|
event.preventDefault();
|
|
293
299
|
return;
|
|
294
300
|
}
|
|
301
|
+
// A standalone toggle is cancelled only by the caller's own
|
|
302
|
+
// preventDefault(); Button then skips pressedChangeAction too.
|
|
303
|
+
if (!wasPrevented && event.defaultPrevented) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
295
306
|
|
|
296
307
|
onPressedChangeProp?.(nextPressed, event);
|
|
297
308
|
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
4
4
|
/**
|
|
5
5
|
* @file Guards doc prop types against opaque named unions (#1645).
|
|
6
|
-
* @input Every {Name}.doc.mjs plus the TypeScript sources they describe
|
|
6
|
+
* @input Every {Name}.doc.mjs plus the TypeScript sources they describe,
|
|
7
|
+
* including same-file private aliases used by exported literal unions.
|
|
7
8
|
* @output Fails when a documented prop type hides its legal literal values.
|
|
8
9
|
* @position Repo-wide doc-shape guard, sibling of docPropReferences.test.ts.
|
|
9
10
|
*
|
|
@@ -188,18 +189,34 @@ for (const file of findFiles(SRC_DIR, ['.ts', '.tsx'])) {
|
|
|
188
189
|
// markers the comment-stripped `src` has already removed.
|
|
189
190
|
const rawTypeRhs = new Map<string, string>();
|
|
190
191
|
for (const m of raw.matchAll(
|
|
191
|
-
|
|
192
|
+
/\btype ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,
|
|
192
193
|
)) {
|
|
193
194
|
rawTypeRhs.set(m[1], m[2]);
|
|
194
195
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
const declarations = [
|
|
197
|
+
...src.matchAll(
|
|
198
|
+
/\b(export )?type ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,
|
|
199
|
+
),
|
|
200
|
+
];
|
|
201
|
+
// Resolve same-file literal aliases before registering exported types.
|
|
202
|
+
// Repeat until no new literal unions are found.
|
|
203
|
+
const fileLiterals = new Map<string, string>();
|
|
204
|
+
let previousSize: number;
|
|
205
|
+
do {
|
|
206
|
+
previousSize = fileLiterals.size;
|
|
207
|
+
for (const [, , name, rhsRaw] of declarations) {
|
|
208
|
+
const rhs = rhsRaw
|
|
209
|
+
.replace(/\s+/g, ' ')
|
|
210
|
+
.trim()
|
|
211
|
+
.split('|')
|
|
212
|
+
.map(part => fileLiterals.get(part.trim()) ?? part.trim())
|
|
213
|
+
.join(' | ');
|
|
214
|
+
|
|
215
|
+
if (!LITERAL_UNION.test(rhs)) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
201
218
|
const deprecated = deprecatedLiteralMembers(rawTypeRhs.get(name) ?? '');
|
|
202
|
-
|
|
219
|
+
fileLiterals.set(
|
|
203
220
|
name,
|
|
204
221
|
rhs
|
|
205
222
|
.replace(/^\|\s*/, '')
|
|
@@ -209,8 +226,17 @@ for (const file of findFiles(SRC_DIR, ['.ts', '.tsx'])) {
|
|
|
209
226
|
.filter(member => !deprecated.has(member))
|
|
210
227
|
.join(' | '),
|
|
211
228
|
);
|
|
229
|
+
}
|
|
230
|
+
} while (fileLiterals.size !== previousSize);
|
|
231
|
+
for (const [, exported, name, rhsRaw] of declarations) {
|
|
232
|
+
if (!exported) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const literals = fileLiterals.get(name);
|
|
236
|
+
if (literals !== undefined) {
|
|
237
|
+
literalUnions.set(name, literals);
|
|
212
238
|
} else {
|
|
213
|
-
namedBodies.set(name,
|
|
239
|
+
namedBodies.set(name, rhsRaw.replace(/\s+/g, ' ').trim());
|
|
214
240
|
}
|
|
215
241
|
}
|
|
216
242
|
for (const m of src.matchAll(
|
|
@@ -230,19 +230,6 @@ export function useMenuHover<T extends HTMLElement = HTMLElement>(
|
|
|
230
230
|
const hoverOpenedAtRef = useRef(0);
|
|
231
231
|
const prevIsOpenRef = useRef(isOpen);
|
|
232
232
|
|
|
233
|
-
// Catches every close, whatever caused it. A layout effect, not render: it
|
|
234
|
-
// must land before the browser hit-tests the vanished panel and fires the
|
|
235
|
-
// mouseenter REOPEN_SUPPRESS_MS exists to swallow.
|
|
236
|
-
useIsomorphicLayoutEffect(() => {
|
|
237
|
-
const wasOpen = prevIsOpenRef.current;
|
|
238
|
-
prevIsOpenRef.current = isOpen;
|
|
239
|
-
if (wasOpen && !isOpen) {
|
|
240
|
-
hoverModeRef.current = false;
|
|
241
|
-
hoverOpenedAtRef.current = 0;
|
|
242
|
-
closedAtRef.current = Date.now();
|
|
243
|
-
}
|
|
244
|
-
}, [isOpen]);
|
|
245
|
-
|
|
246
233
|
const clearTimeouts = useCallback(() => {
|
|
247
234
|
if (showTimerRef.current) {
|
|
248
235
|
clearTimeout(showTimerRef.current);
|
|
@@ -256,6 +243,24 @@ export function useMenuHover<T extends HTMLElement = HTMLElement>(
|
|
|
256
243
|
safeTriangleCleanupRef.current = null;
|
|
257
244
|
}, []);
|
|
258
245
|
|
|
246
|
+
// Catches every close, whatever caused it. A layout effect, not render: it
|
|
247
|
+
// must land before the browser hit-tests the vanished panel and fires the
|
|
248
|
+
// mouseenter REOPEN_SUPPRESS_MS exists to swallow.
|
|
249
|
+
useIsomorphicLayoutEffect(() => {
|
|
250
|
+
const wasOpen = prevIsOpenRef.current;
|
|
251
|
+
prevIsOpenRef.current = isOpen;
|
|
252
|
+
if (wasOpen && !isOpen) {
|
|
253
|
+
// A hover-open scheduled before the close must not fire afterwards and
|
|
254
|
+
// reopen what just closed from elsewhere — e.g. the root menu's light
|
|
255
|
+
// dismiss closing a submenu flyout mid hover-intent (#6893). A fresh
|
|
256
|
+
// mouseenter still opens; only the stale timer is cancelled.
|
|
257
|
+
clearTimeouts();
|
|
258
|
+
hoverModeRef.current = false;
|
|
259
|
+
hoverOpenedAtRef.current = 0;
|
|
260
|
+
closedAtRef.current = Date.now();
|
|
261
|
+
}
|
|
262
|
+
}, [isOpen, clearTimeouts]);
|
|
263
|
+
|
|
259
264
|
// useListFocus needs an onEscape that is defined in terms of its own listRef;
|
|
260
265
|
// the indirection avoids the use-before-declare.
|
|
261
266
|
const escapeHandlerRef = useRef<() => void>(() => {});
|