@astryxdesign/core 0.7.2 → 0.7.3-canary.0bf23bd
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/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +8 -4
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +7 -0
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +19 -24
- package/dist/ClickableCard/ClickableCard.d.ts +2 -2
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +11 -9
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +11 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +23 -5
- package/dist/DateInput/DateInput.d.ts +4 -4
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +27 -20
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +14 -8
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +14 -10
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +9 -4
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +52 -10
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +34 -1
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.js +15 -0
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts +21 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +375 -42
- package/dist/DropdownMenu/menuRegionStops.d.ts +2 -2
- package/dist/DropdownMenu/menuRegionStops.js +2 -2
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +14 -12
- package/dist/Link/Link.d.ts +2 -3
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +11 -19
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +48 -15
- package/dist/MultiSelector/MultiSelector.d.ts +4 -4
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts +2 -0
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.js +48 -0
- package/dist/MultiSelector/MultiSelector.js +25 -18
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +8 -4
- package/dist/Selector/Selector.d.ts +4 -4
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +23 -14
- package/dist/Selector/SelectorOption.d.ts.map +1 -1
- package/dist/Selector/SelectorOption.js +1 -0
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +7 -14
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +25 -17
- package/dist/Switch/switch.markers.stylex.d.ts +2 -0
- package/dist/Switch/switch.markers.stylex.d.ts.map +1 -1
- package/dist/Switch/switch.markers.stylex.js +6 -0
- package/dist/TimeInput/TimeInput.d.ts +2 -1
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +8 -3
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +36 -14
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +11 -2
- package/dist/TopNav/TopNav.d.ts.map +1 -1
- package/dist/TopNav/TopNav.js +2 -2
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +1 -0
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +14 -2
- package/dist/astryx.css +8 -2
- package/dist/hooks/useMenuPress.d.ts +11 -1
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +43 -5
- package/dist/utils/disabledInteraction.d.ts +21 -0
- package/dist/utils/disabledInteraction.d.ts.map +1 -0
- package/dist/utils/disabledInteraction.js +33 -0
- package/dist/utils/timeParser.d.ts +4 -0
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +9 -2
- package/package.json +4 -4
- package/scripts/agent-doc-state.mjs +35 -8
- package/src/Banner/Banner.spec.md +37 -32
- package/src/BottomSheet/BottomSheet.spec.md +13 -6
- package/src/BottomSheet/BottomSheet.test.tsx +29 -0
- package/src/BottomSheet/BottomSheet.tsx +8 -4
- package/src/BottomSheet/BottomSheetSwitcher.spec.md +121 -51
- package/src/BottomSheet/BottomSheetSwitcher.test.tsx +26 -0
- package/src/BottomSheet/BottomSheetSwitcher.tsx +6 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +44 -5
- package/src/CheckboxInput/CheckboxInput.tsx +16 -26
- package/src/CheckboxInput/__tests__/Checkbox.a11y.states.ts +3 -3
- package/src/CheckboxList/CheckboxList.test.tsx +9 -6
- package/src/ClickableCard/ClickableCard.doc.mjs +2 -2
- package/src/ClickableCard/ClickableCard.test.tsx +5 -4
- package/src/ClickableCard/ClickableCard.tsx +9 -9
- package/src/CodeBlock/CodeBlock.highlightStyles.test.tsx +87 -0
- package/src/CodeBlock/CodeBlock.tsx +11 -1
- package/src/ComplexSelector/ComplexSelector.focusableDisabled.test.tsx +76 -0
- package/src/ComplexSelector/ComplexSelector.tsx +21 -4
- package/src/ContextMenu/ContextMenu.test.tsx +41 -0
- package/src/DateInput/DateInput.doc.mjs +9 -8
- package/src/DateInput/DateInput.test.tsx +88 -13
- package/src/DateInput/DateInput.tsx +49 -21
- package/src/DateInput/DateInputTouch.test.tsx +22 -1
- package/src/DateInput/NativeDateField.test.tsx +29 -3
- package/src/DateInput/NativeDateField.tsx +20 -7
- package/src/DateInput/TouchDateField.tsx +24 -9
- package/src/DateRangeInput/DateRangeInput.spec.md +13 -13
- package/src/Dialog/Dialog.test.tsx +39 -0
- package/src/Dialog/Dialog.tsx +9 -4
- package/src/DropdownMenu/DropdownMenu.spec.md +33 -2
- package/src/DropdownMenu/DropdownMenu.tsx +79 -8
- package/src/DropdownMenu/DropdownMenuContext.public.test.ts +22 -0
- package/src/DropdownMenu/DropdownMenuContext.tsx +39 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +16 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +623 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +556 -99
- package/src/DropdownMenu/__tests__/SubMenuHeaderFooter.a11y.chromium.spec.ts +267 -0
- package/src/DropdownMenu/menuRegionStops.ts +2 -2
- package/src/DropdownMenu/modules/useMenuPress.spec.md +9 -0
- package/src/FieldStatus/FieldStatus.spec.md +3 -2
- package/src/FileInput/FileInput.test.tsx +30 -7
- package/src/FileInput/FileInput.tsx +21 -11
- package/src/Link/Link.test.tsx +21 -7
- package/src/Link/Link.tsx +16 -24
- package/src/Link/__tests__/Link.a11y.states.ts +1 -1
- package/src/Markdown/Markdown.rerender.test.tsx +143 -0
- package/src/Markdown/Markdown.tsx +89 -35
- package/src/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.ts +71 -0
- package/src/MultiSelector/MultiSelector.doc.mjs +5 -5
- package/src/MultiSelector/MultiSelector.focusableDisabled.test.tsx +121 -0
- package/src/MultiSelector/MultiSelector.test.tsx +49 -7
- package/src/MultiSelector/MultiSelector.tsx +53 -29
- package/src/Popover/Popover.test.tsx +15 -0
- package/src/Popover/Popover.tsx +19 -8
- package/src/PowerSearch/PowerSearchFilterEditor.test.tsx +3 -2
- package/src/PowerSearch/PowerSearchToken.test.tsx +7 -5
- package/src/Selector/Selector.doc.mjs +4 -4
- package/src/Selector/Selector.focusableDisabled.test.tsx +127 -0
- package/src/Selector/Selector.spec.md +11 -11
- package/src/Selector/Selector.test.tsx +64 -6
- package/src/Selector/Selector.tsx +51 -21
- package/src/Selector/SelectorOption.tsx +4 -0
- package/src/SideNav/SideNav.test.tsx +35 -0
- package/src/Slider/Slider.spec.md +11 -11
- package/src/Slider/Slider.test.tsx +3 -3
- package/src/Slider/Slider.tsx +8 -15
- package/src/Switch/Switch.test.tsx +85 -8
- package/src/Switch/Switch.tsx +26 -16
- package/src/Switch/__tests__/Switch.a11y.states.ts +2 -2
- package/src/Switch/switch.markers.stylex.ts +4 -0
- package/src/Table/Table.spec.md +2 -0
- package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.spec.md +244 -0
- package/src/Table/plugins/selection/useTableSelection.test.tsx +5 -3
- package/src/Table/plugins/virtualization/useTableVirtualization.spec.md +266 -0
- package/src/TimeInput/TimeInput.doc.mjs +5 -3
- package/src/TimeInput/TimeInput.test.tsx +20 -0
- package/src/TimeInput/TimeInput.tsx +2 -1
- package/src/Token/Token.test.tsx +26 -4
- package/src/Token/Token.tsx +6 -2
- package/src/Tokenizer/Tokenizer.spec.md +28 -28
- package/src/Tooltip/Tooltip.test.tsx +51 -6
- package/src/Tooltip/Tooltip.tsx +41 -18
- package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +129 -0
- package/src/Tooltip/__tests__/Tooltip.a11y.renders.tsx +86 -0
- package/src/Tooltip/__tests__/Tooltip.a11y.states.ts +132 -0
- package/src/Tooltip/__tests__/Tooltip.a11y.test.tsx +126 -0
- package/src/Tooltip/__tests__/TooltipHoverBridge.a11y.chromium.spec.ts +74 -0
- package/src/Tooltip/useTooltip.test.tsx +23 -0
- package/src/Tooltip/useTooltip.tsx +22 -9
- package/src/TopNav/TopNav.tsx +11 -1
- package/src/TopNav/TopNavHeading.tsx +1 -0
- package/src/TopNav/__tests__/TopNavMobileLongHeading.a11y.chromium.spec.ts +74 -0
- package/src/Typeahead/Typeahead.test.tsx +89 -0
- package/src/Typeahead/Typeahead.tsx +15 -2
- package/src/hooks/useMenuPress.ts +45 -7
- package/src/utils/disabledInteraction.ts +40 -0
- package/src/utils/timeParser.test.ts +11 -0
- package/src/utils/timeParser.ts +9 -2
|
@@ -212,7 +212,7 @@ export const docs = {
|
|
|
212
212
|
name: 'increment',
|
|
213
213
|
type: 'number',
|
|
214
214
|
description:
|
|
215
|
-
'Number of minutes to add or subtract when the user presses the up or down arrow key.',
|
|
215
|
+
'Number of minutes to add or subtract when the user presses the up or down arrow key. Steps are whole minutes; a fractional value leaves the time unchanged.',
|
|
216
216
|
default: '1',
|
|
217
217
|
},
|
|
218
218
|
{
|
|
@@ -392,7 +392,8 @@ export const docsZh = {
|
|
|
392
392
|
{
|
|
393
393
|
name: 'increment',
|
|
394
394
|
type: 'number',
|
|
395
|
-
description:
|
|
395
|
+
description:
|
|
396
|
+
'用户按上或下方向键时增加或减少的分钟数。步长为整分钟;传入小数时时间保持不变。',
|
|
396
397
|
default: '1',
|
|
397
398
|
},
|
|
398
399
|
{
|
|
@@ -623,7 +624,8 @@ export const docsDense = {
|
|
|
623
624
|
hasClear: 'Shows clear button when value set+not disabled.',
|
|
624
625
|
hourFormat:
|
|
625
626
|
"Display format. '12h' shows AM/PM; '24h' uses 24-hour notation.",
|
|
626
|
-
increment:
|
|
627
|
+
increment:
|
|
628
|
+
'Minutes to add/subtract on arrow up/down. Whole minutes only; a fractional value leaves the time unchanged.',
|
|
627
629
|
presentation:
|
|
628
630
|
"picker surface: 'adaptive-native' (default) = typed field fine / browser/OS coarse (hasSeconds or increment!=1 retains typed); 'native' = browser/OS always, no fallback; 'adaptive-bottom-sheet' = typed fine / Astryx wheel sheet coarse; 'bottom-sheet' = sheet always; 'text-input'/'popover' = typed field only.",
|
|
629
631
|
nativePicker:
|
|
@@ -65,6 +65,26 @@ describe('TimeInput', () => {
|
|
|
65
65
|
expect(onChange).toHaveBeenCalledWith('14:31');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
it('does not step into a fractional minute when increment is fractional', () => {
|
|
69
|
+
const onChange = vi.fn();
|
|
70
|
+
render(
|
|
71
|
+
<TimeInput
|
|
72
|
+
label="Time"
|
|
73
|
+
value={'14:30' as ISOTimeString}
|
|
74
|
+
increment={0.5}
|
|
75
|
+
onChange={onChange}
|
|
76
|
+
/>,
|
|
77
|
+
);
|
|
78
|
+
const input = screen.getByLabelText('Time');
|
|
79
|
+
|
|
80
|
+
// `increment` is documented as minutes and typed `number`. A fractional one
|
|
81
|
+
// used to reach formatISOTime unrounded, which pads "30.5" to two
|
|
82
|
+
// characters and leaves it, so the arrow key handed the consumer a value
|
|
83
|
+
// that is no longer a time at all.
|
|
84
|
+
fireEvent.keyDown(input, {key: 'ArrowUp'});
|
|
85
|
+
expect(onChange).toHaveBeenCalledWith('14:30');
|
|
86
|
+
});
|
|
87
|
+
|
|
68
88
|
it('displays formatted time in 12h format', () => {
|
|
69
89
|
render(
|
|
70
90
|
<TimeInput
|
|
@@ -286,7 +286,8 @@ export interface TimeInputProps extends Omit<
|
|
|
286
286
|
hourFormat?: TimeInputHourFormat;
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
* Increment in minutes when using arrow keys.
|
|
289
|
+
* Increment in minutes when using arrow keys. Steps are whole minutes: a
|
|
290
|
+
* fractional value leaves the time unchanged.
|
|
290
291
|
* @default 1
|
|
291
292
|
*/
|
|
292
293
|
increment?: number;
|
package/src/Token/Token.test.tsx
CHANGED
|
@@ -134,8 +134,10 @@ describe('Token', () => {
|
|
|
134
134
|
/>,
|
|
135
135
|
);
|
|
136
136
|
const button = screen.getByRole('button', {name: 'Disabled'});
|
|
137
|
-
expect(button).
|
|
137
|
+
expect(button).not.toHaveAttribute('disabled');
|
|
138
|
+
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
138
139
|
expect(button.tagName).toBe('BUTTON');
|
|
140
|
+
fireEvent.click(button);
|
|
139
141
|
// Container click is also disabled
|
|
140
142
|
const container = screen.getByTestId('token');
|
|
141
143
|
fireEvent.click(container);
|
|
@@ -254,14 +256,34 @@ describe('Token accessibility', () => {
|
|
|
254
256
|
).toBeInTheDocument();
|
|
255
257
|
});
|
|
256
258
|
|
|
257
|
-
it('
|
|
259
|
+
it('keeps both buttons focusable and inert when isDisabled is true', async () => {
|
|
260
|
+
const user = userEvent.setup();
|
|
261
|
+
const handleClick = vi.fn();
|
|
262
|
+
const handleRemove = vi.fn();
|
|
258
263
|
render(
|
|
259
|
-
<Token
|
|
264
|
+
<Token
|
|
265
|
+
label="Token"
|
|
266
|
+
onClick={handleClick}
|
|
267
|
+
onRemove={handleRemove}
|
|
268
|
+
isDisabled
|
|
269
|
+
/>,
|
|
260
270
|
);
|
|
261
271
|
const buttons = screen.getAllByRole('button');
|
|
272
|
+
expect(buttons).toHaveLength(2);
|
|
262
273
|
for (const button of buttons) {
|
|
263
|
-
expect(button).
|
|
274
|
+
expect(button).not.toHaveAttribute('disabled');
|
|
275
|
+
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
276
|
+
// A wrapping Popover listens for clicks on the button itself.
|
|
277
|
+
const nativeClick = vi.fn();
|
|
278
|
+
button.addEventListener('click', nativeClick);
|
|
279
|
+
await user.tab();
|
|
280
|
+
expect(button).toHaveFocus();
|
|
281
|
+
await user.keyboard('{Enter} ');
|
|
282
|
+
expect(nativeClick).not.toHaveBeenCalled();
|
|
283
|
+
fireEvent.click(button);
|
|
264
284
|
}
|
|
285
|
+
expect(handleClick).not.toHaveBeenCalled();
|
|
286
|
+
expect(handleRemove).not.toHaveBeenCalled();
|
|
265
287
|
});
|
|
266
288
|
|
|
267
289
|
it('does not fire onClick or onRemove when disabled', () => {
|
package/src/Token/Token.tsx
CHANGED
|
@@ -41,6 +41,7 @@ import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
|
|
|
41
41
|
import {usePressFeedback} from '../hooks/usePressFeedback';
|
|
42
42
|
import {useTranslator} from '../i18n';
|
|
43
43
|
import type {TokenColorMap} from './index';
|
|
44
|
+
import {disabledInteractionProps} from '../utils/disabledInteraction';
|
|
44
45
|
|
|
45
46
|
// =============================================================================
|
|
46
47
|
// Types
|
|
@@ -321,7 +322,9 @@ export function Token({
|
|
|
321
322
|
e.stopPropagation();
|
|
322
323
|
onRemove(e);
|
|
323
324
|
}}
|
|
324
|
-
disabled
|
|
325
|
+
// Focusable while disabled (spec:AST-085 FR1), but inert (FR2).
|
|
326
|
+
aria-disabled={isDisabled || undefined}
|
|
327
|
+
{...(isDisabled ? disabledInteractionProps() : null)}
|
|
325
328
|
{...focusOutlineProps.focusVisible(styles.removeButton)}>
|
|
326
329
|
<Icon icon="close" size="xsm" color="inherit" />
|
|
327
330
|
</button>
|
|
@@ -455,7 +458,8 @@ export function Token({
|
|
|
455
458
|
<button
|
|
456
459
|
type="button"
|
|
457
460
|
onClick={effectiveOnClick}
|
|
458
|
-
disabled={isDisabled}
|
|
461
|
+
aria-disabled={isDisabled || undefined}
|
|
462
|
+
{...(isDisabled ? disabledInteractionProps() : null)}
|
|
459
463
|
{...stylex.props(styles.invisibleButton)}>
|
|
460
464
|
<span
|
|
461
465
|
{...stylex.props(
|
|
@@ -166,23 +166,23 @@ pending.
|
|
|
166
166
|
|
|
167
167
|
### Representative states
|
|
168
168
|
|
|
169
|
-
| State | Required invariant | Allowed variation
|
|
170
|
-
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
171
|
-
| Empty field | The mounted inner input is the opening control; a full-width menu stays aligned to the outer field. | Placeholder and bootstrap results may vary.
|
|
172
|
-
| Focus bootstrap, choices remain | A committed selection is removed from the displayed cohort; the input and popup remain active on the next valid remaining choice. | Internal cohort storage and projection may vary.
|
|
173
|
-
| Focus bootstrap, selected choice was last | The nearest preceding remaining choice becomes active without changing the displayed order. | Option identity representation may vary.
|
|
174
|
-
| Focus bootstrap, no choices or max reached | The popup closes and no active descendant remains; pending work cannot reopen it. | Source cancellation mechanism may vary.
|
|
175
|
-
| Source pending or replaced | Busy semantics identify pending work; stale work cannot add choices or reopen a terminal popup. | A settled current cohort may be retained internally.
|
|
176
|
-
| Disabled | No choice can be committed; an open popup closes and clears its active descendant while disabled-reason focusability remains available where configured. |
|
|
177
|
-
| One or many tokens | The same input remains after tokens and moves with wrapping; full-width placement does not follow that movement. | Token labels, wrapping rows, and custom content may vary.
|
|
178
|
-
| At `maxEntries` | The input identity remains mounted but its zero-width/hidden box is unusable as geometry; opening falls back to the outer field. | Search remains unavailable under current behavior.
|
|
179
|
-
| Token removal or clear | Input identity survives and current refocus behavior remains. | Token count and input position change.
|
|
180
|
-
| `unfocusedInline` | Blurred OverflowList and focused direct-token layouts resolve the same live input identity; a collapsed input is not used as geometry. | Visible token count may vary with width.
|
|
181
|
-
| `unfocusedLayer`, focused | The live wrapper/input may be reparented into the context layer without descriptor churn. | Corrective portal location may vary.
|
|
182
|
-
| `unfocusedLayer`, unfocused | The hidden-layer input is unusable for a new open; the ordinary-flow outer-field fallback is used. | Placeholder token count may vary.
|
|
183
|
-
| Default or custom token edit | The actual activated token/control is captured before edit state changes; if no usable descendant control exists, input then outer-field fallback applies. | Custom token markup may vary.
|
|
184
|
-
| LTR or RTL | Physical proximity selects an edge only for a narrower surface; logical start wins ties and full-width placement. | Collision may move the final rendered surface.
|
|
185
|
-
| SSR, hydration, or unmount | No server geometry read occurs; first client open prepares normally; unmount clears identities and pending show work. | Hydration timing may vary.
|
|
169
|
+
| State | Required invariant | Allowed variation |
|
|
170
|
+
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
171
|
+
| Empty field | The mounted inner input is the opening control; a full-width menu stays aligned to the outer field. | Placeholder and bootstrap results may vary. |
|
|
172
|
+
| Focus bootstrap, choices remain | A committed selection is removed from the displayed cohort; the input and popup remain active on the next valid remaining choice. | Internal cohort storage and projection may vary. |
|
|
173
|
+
| Focus bootstrap, selected choice was last | The nearest preceding remaining choice becomes active without changing the displayed order. | Option identity representation may vary. |
|
|
174
|
+
| Focus bootstrap, no choices or max reached | The popup closes and no active descendant remains; pending work cannot reopen it. | Source cancellation mechanism may vary. |
|
|
175
|
+
| Source pending or replaced | Busy semantics identify pending work; stale work cannot add choices or reopen a terminal popup. | A settled current cohort may be retained internally. |
|
|
176
|
+
| Disabled | No choice can be committed; an open popup closes and clears its active descendant while disabled-reason focusability remains available where configured. | The disabled representation follows `spec:AST-085`. |
|
|
177
|
+
| One or many tokens | The same input remains after tokens and moves with wrapping; full-width placement does not follow that movement. | Token labels, wrapping rows, and custom content may vary. |
|
|
178
|
+
| At `maxEntries` | The input identity remains mounted but its zero-width/hidden box is unusable as geometry; opening falls back to the outer field. | Search remains unavailable under current behavior. |
|
|
179
|
+
| Token removal or clear | Input identity survives and current refocus behavior remains. | Token count and input position change. |
|
|
180
|
+
| `unfocusedInline` | Blurred OverflowList and focused direct-token layouts resolve the same live input identity; a collapsed input is not used as geometry. | Visible token count may vary with width. |
|
|
181
|
+
| `unfocusedLayer`, focused | The live wrapper/input may be reparented into the context layer without descriptor churn. | Corrective portal location may vary. |
|
|
182
|
+
| `unfocusedLayer`, unfocused | The hidden-layer input is unusable for a new open; the ordinary-flow outer-field fallback is used. | Placeholder token count may vary. |
|
|
183
|
+
| Default or custom token edit | The actual activated token/control is captured before edit state changes; if no usable descendant control exists, input then outer-field fallback applies. | Custom token markup may vary. |
|
|
184
|
+
| LTR or RTL | Physical proximity selects an edge only for a narrower surface; logical start wins ties and full-width placement. | Collision may move the final rendered surface. |
|
|
185
|
+
| SSR, hydration, or unmount | No server geometry read occurs; first client open prepares normally; unmount clears identities and pending show work. | Hydration timing may vary. |
|
|
186
186
|
|
|
187
187
|
### Transformation and precedence order
|
|
188
188
|
|
|
@@ -282,8 +282,8 @@ consumer docs, and Changeset together. Exact-head browser evidence must exercise
|
|
|
282
282
|
next remaining option active.
|
|
283
283
|
2. The fallback when the committed option was last, plus terminal closure for no
|
|
284
284
|
remaining choice and `maxEntries`.
|
|
285
|
-
3. Escape, Tab or outside focus departure, transition to
|
|
286
|
-
|
|
285
|
+
3. Escape, Tab or outside focus departure, transition to the disabled state,
|
|
286
|
+
and pending or stale source settlement without a
|
|
287
287
|
later reopen.
|
|
288
288
|
4. The unchanged path when `hasEntriesOnFocus` is off and direct single-select
|
|
289
289
|
BaseTypeahead selection still closes.
|
|
@@ -297,15 +297,15 @@ become Tokenizer policy.
|
|
|
297
297
|
|
|
298
298
|
## Verification map
|
|
299
299
|
|
|
300
|
-
| Contract | Verification
|
|
301
|
-
| ---------------- |
|
|
302
|
-
| FR1–FR3 | Existing Tokenizer/BaseTypeahead unit tests plus source inspection
|
|
303
|
-
| FR4–FR8 | Focused descriptor identity/capture tests when implemented
|
|
304
|
-
| FR9–FR12 | Layer unit tests and real-Chromium geometry checks when implemented
|
|
305
|
-
| FR13–FR15, AR5 | Focused Tokenizer/BaseTypeahead tests and exact-head Chromium interaction evidence
|
|
306
|
-
| PR1–PR5 | Instrumented reads, pending-frame cleanup tests, and first-frame Chromium capture
|
|
307
|
-
| AR1–AR5 | Existing interaction suites plus focused pointer/keyboard/browser checks
|
|
308
|
-
| Record structure | `scripts/check-knowledge.mjs`
|
|
300
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
301
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
|
|
302
|
+
| FR1–FR3 | Existing Tokenizer/BaseTypeahead unit tests plus source inspection | empty, tokens, remove, clear, max, wrapping, both overflow modes | Input remounts, suggestion menu changes anchor/width semantics, or overflow ownership is misstated. | `audit:Tokenizer/current` |
|
|
303
|
+
| FR4–FR8 | Focused descriptor identity/capture tests when implemented | add, default/custom token edit, max, hidden layer, reparent, stale node, unmount, SSR | Descriptor leaks publicly, captures a transient result/pointer, misses custom controls, or uses unusable geometry. | `audit:Tokenizer/opening-anchor` |
|
|
304
|
+
| FR9–FR12 | Layer unit tests and real-Chromium geometry checks when implemented | full/equal/narrow surface, start/end/tie, LTR/RTL, collision, stale fallback | Full-width follows inner input, tie is physical, collision runs early, or stale identity flashes. | `audit:Tokenizer/placement` |
|
|
305
|
+
| FR13–FR15, AR5 | Focused Tokenizer/BaseTypeahead tests and exact-head Chromium interaction evidence | pointer/keyboard commit, first/middle/last choice, rejected/deferred control, loading, disabled, max, exhaustion, Escape, Tab, outside focus | Selected values remain available, order changes, focus leaves the combobox, active descendant names no option, stale work reopens, or a terminal state stays interactive. | `audit:Tokenizer/multi-select` |
|
|
306
|
+
| PR1–PR5 | Instrumented reads, pending-frame cleanup tests, and first-frame Chromium capture | open, close before frame, reopen opposite side, resize while open | Render-time/repeated reads, observer/pointer tracking, uncancelled frame, or first-frame jump occurs. | `audit:Tokenizer/performance` |
|
|
307
|
+
| AR1–AR5 | Existing interaction suites plus focused pointer/keyboard/browser checks; native-disabled assertions pending conformance (`spec:AST-085`) | add/edit, focus/refocus, overflow, disabled, dismissal, retained bootstrap selection | Modality changes placement, semantics/focus regress, active descendant becomes invalid, or visible placement is wrong before fallback. | `audit:Tokenizer/accessibility` |
|
|
308
|
+
| Record structure | `scripts/check-knowledge.mjs` | Template-v3 current record and current-only frontmatter links | Invalid metadata, authority, or relationship references fail repository validation. | `audit:Tokenizer/knowledge` |
|
|
309
309
|
|
|
310
310
|
## Decision log
|
|
311
311
|
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
fireEvent,
|
|
26
26
|
waitFor,
|
|
27
27
|
} from '@testing-library/react';
|
|
28
|
+
import {useRef} from 'react';
|
|
28
29
|
import {Tooltip} from './Tooltip';
|
|
29
30
|
import {useTooltip} from './useTooltip';
|
|
30
31
|
import {__resetInteractionModalityForTest} from '../utils/interactionModality';
|
|
@@ -84,17 +85,15 @@ describe('Tooltip', () => {
|
|
|
84
85
|
expect(screen.getByRole('button', {name: 'Trigger'})).toBeInTheDocument();
|
|
85
86
|
});
|
|
86
87
|
|
|
87
|
-
it('
|
|
88
|
+
it('renders the content prop inside the tooltip layer', () => {
|
|
88
89
|
render(
|
|
89
90
|
<Tooltip content="Tooltip text">
|
|
90
91
|
<button type="button">Trigger</button>
|
|
91
92
|
</Tooltip>,
|
|
92
93
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const trigger = screen.getByRole('button', {name: 'Trigger'});
|
|
97
|
-
expect(trigger.getAttribute('aria-describedby')).toBe(layer.id);
|
|
94
|
+
expect(screen.getByRole('tooltip', {hidden: true})).toHaveTextContent(
|
|
95
|
+
'Tooltip text',
|
|
96
|
+
);
|
|
98
97
|
});
|
|
99
98
|
|
|
100
99
|
it('calls onOpenChange(true) when shown via hover', async () => {
|
|
@@ -604,3 +603,49 @@ describe('Tooltip', () => {
|
|
|
604
603
|
});
|
|
605
604
|
});
|
|
606
605
|
});
|
|
606
|
+
|
|
607
|
+
describe('Tooltip sibling mode (anchorRef)', () => {
|
|
608
|
+
// SideNavItem's collapsed rail tooltip renders the Tooltip inside the very
|
|
609
|
+
// element anchorRef points at. React attaches an ancestor's ref after its
|
|
610
|
+
// descendants' layout effects, so on mount the tooltip's effect used to see
|
|
611
|
+
// a null anchor and never retried (#7692).
|
|
612
|
+
it('attaches to an anchor it is rendered inside of', async () => {
|
|
613
|
+
const onOpenChange = vi.fn();
|
|
614
|
+
function AnchorInside() {
|
|
615
|
+
const anchorRef = useRef<HTMLDivElement>(null);
|
|
616
|
+
return (
|
|
617
|
+
<div ref={anchorRef}>
|
|
618
|
+
<button type="button">Inner</button>
|
|
619
|
+
<Tooltip
|
|
620
|
+
content="Sibling tooltip"
|
|
621
|
+
anchorRef={anchorRef}
|
|
622
|
+
delay={0}
|
|
623
|
+
onOpenChange={onOpenChange}
|
|
624
|
+
/>
|
|
625
|
+
</div>
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const {unmount} = render(<AnchorInside />);
|
|
630
|
+
const anchor = screen.getByRole('button', {name: 'Inner'})
|
|
631
|
+
.parentElement as HTMLElement;
|
|
632
|
+
|
|
633
|
+
// The anchor is described by the tooltip once the commit has attached refs.
|
|
634
|
+
await waitFor(() => {
|
|
635
|
+
expect(anchor.getAttribute('aria-describedby')).not.toBe('');
|
|
636
|
+
});
|
|
637
|
+
const layer = screen.getByRole('tooltip', {hidden: true});
|
|
638
|
+
expect(anchor.getAttribute('aria-describedby')).toBe(layer.id);
|
|
639
|
+
|
|
640
|
+
// Hovering the anchor opens the tooltip: the interaction listeners were
|
|
641
|
+
// attached to the late anchor too.
|
|
642
|
+
fireEvent.mouseEnter(anchor);
|
|
643
|
+
await waitFor(() => {
|
|
644
|
+
expect(onOpenChange).toHaveBeenCalledWith(true);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
// Unmounting detaches: the aria-describedby the tooltip added is removed.
|
|
648
|
+
unmount();
|
|
649
|
+
expect(anchor.getAttribute('aria-describedby')).toBe(null);
|
|
650
|
+
});
|
|
651
|
+
});
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -242,28 +242,51 @@ export function Tooltip({
|
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
const attach = (el: HTMLElement) => {
|
|
246
|
+
// Use combined ref for position + interaction
|
|
247
|
+
tooltip.ref(el);
|
|
248
|
+
|
|
249
|
+
// Set aria-describedby, merging with existing
|
|
250
|
+
const existingDescribedBy = el.getAttribute('aria-describedby');
|
|
251
|
+
el.setAttribute(
|
|
252
|
+
'aria-describedby',
|
|
253
|
+
mergeIds(existingDescribedBy, tooltip.describedBy) ?? '',
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
return () => {
|
|
257
|
+
tooltip.ref(null);
|
|
258
|
+
if (existingDescribedBy) {
|
|
259
|
+
el.setAttribute('aria-describedby', existingDescribedBy);
|
|
260
|
+
} else {
|
|
261
|
+
el.removeAttribute('aria-describedby');
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
|
|
245
266
|
const el = anchorRef.current;
|
|
246
|
-
if (
|
|
247
|
-
return;
|
|
267
|
+
if (el) {
|
|
268
|
+
return attach(el);
|
|
248
269
|
}
|
|
249
270
|
|
|
250
|
-
//
|
|
251
|
-
tooltip
|
|
252
|
-
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return () => {
|
|
261
|
-
tooltip.ref(null);
|
|
262
|
-
if (existingDescribedBy) {
|
|
263
|
-
el.setAttribute('aria-describedby', existingDescribedBy);
|
|
264
|
-
} else {
|
|
265
|
-
el.removeAttribute('aria-describedby');
|
|
271
|
+
// React attaches an ancestor's ref after its descendants' layout effects,
|
|
272
|
+
// so a tooltip rendered inside its own anchor (SideNavItem's collapsed
|
|
273
|
+
// rail tooltip) still sees null here on mount, and this effect's deps
|
|
274
|
+
// never change to re-run it. Re-check once the commit has attached all
|
|
275
|
+
// refs; if the anchor is still gone, this tooltip has no anchor, as before.
|
|
276
|
+
let detach: (() => void) | undefined;
|
|
277
|
+
let cancelled = false;
|
|
278
|
+
queueMicrotask(() => {
|
|
279
|
+
if (cancelled) {
|
|
280
|
+
return;
|
|
266
281
|
}
|
|
282
|
+
const el = anchorRef.current;
|
|
283
|
+
if (el) {
|
|
284
|
+
detach = attach(el);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
return () => {
|
|
288
|
+
cancelled = true;
|
|
289
|
+
detach?.();
|
|
267
290
|
};
|
|
268
291
|
}, [anchorRef, tooltip.ref, tooltip.describedBy]);
|
|
269
292
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Tooltip.a11y.chromium.spec.ts
|
|
5
|
+
* @input Built tooltip stories and TOOLTIP_PATTERN in real Chromium
|
|
6
|
+
* @output Browser evidence for every tooltip expectation across Tooltip's and useTooltip's representative states
|
|
7
|
+
* @position Chromium lane of the Tooltip binding
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
expect,
|
|
12
|
+
test,
|
|
13
|
+
type CDPSession,
|
|
14
|
+
type Locator,
|
|
15
|
+
type Page,
|
|
16
|
+
} from '@playwright/test';
|
|
17
|
+
import {
|
|
18
|
+
TOOLTIP_PATTERN,
|
|
19
|
+
blockingResults,
|
|
20
|
+
checkAccessibilitySpec,
|
|
21
|
+
formatFailures,
|
|
22
|
+
neverExercised,
|
|
23
|
+
summarize,
|
|
24
|
+
type BindingResult,
|
|
25
|
+
} from '@astryxdesign/a11y-spec';
|
|
26
|
+
import {
|
|
27
|
+
createChromiumHarness,
|
|
28
|
+
holdMotionStill,
|
|
29
|
+
} from '@astryxdesign/a11y-spec/chromium';
|
|
30
|
+
import {
|
|
31
|
+
DEFAULT_STORYBOOK_DIR,
|
|
32
|
+
serveStorybook,
|
|
33
|
+
type StaticServer,
|
|
34
|
+
} from '@astryxdesign/a11y-spec/storybook';
|
|
35
|
+
import {
|
|
36
|
+
TOOLTIP_BINDING_STATES,
|
|
37
|
+
type TooltipBindingState,
|
|
38
|
+
} from './Tooltip.a11y.states';
|
|
39
|
+
|
|
40
|
+
let storybook: StaticServer;
|
|
41
|
+
|
|
42
|
+
test.beforeAll(async () => {
|
|
43
|
+
storybook = await serveStorybook(
|
|
44
|
+
process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test.afterAll(async () => {
|
|
49
|
+
await storybook?.close();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function storyUrl(storyId: string): string {
|
|
53
|
+
return `${storybook.origin}/iframe.html?id=${storyId}&viewMode=story`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function mountState(
|
|
57
|
+
page: Page,
|
|
58
|
+
state: TooltipBindingState,
|
|
59
|
+
): Promise<{subject: Locator; related: Record<string, Locator>}> {
|
|
60
|
+
await page.goto(storyUrl(state.storyId), {waitUntil: 'load'});
|
|
61
|
+
await holdMotionStill(page);
|
|
62
|
+
const root = page.locator('#storybook-root');
|
|
63
|
+
const subject =
|
|
64
|
+
state.triggerRole == null
|
|
65
|
+
? root.getByText(state.triggerText, {exact: true})
|
|
66
|
+
: root.getByRole(state.triggerRole, {
|
|
67
|
+
name: state.triggerText,
|
|
68
|
+
exact: true,
|
|
69
|
+
});
|
|
70
|
+
await expect(subject).toBeVisible();
|
|
71
|
+
return {
|
|
72
|
+
subject,
|
|
73
|
+
related: {
|
|
74
|
+
// The layer may mount the tooltip outside the story root, and it stays
|
|
75
|
+
// in the page while hidden, so it is found page-wide, hidden included.
|
|
76
|
+
tooltip: page.getByRole('tooltip', {includeHidden: true}),
|
|
77
|
+
before: root.getByRole('button', {
|
|
78
|
+
name: 'Before the trigger',
|
|
79
|
+
exact: true,
|
|
80
|
+
}),
|
|
81
|
+
after: root.getByRole('button', {
|
|
82
|
+
name: 'After the trigger',
|
|
83
|
+
exact: true,
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function runState(
|
|
90
|
+
page: Page,
|
|
91
|
+
cdp: CDPSession,
|
|
92
|
+
state: TooltipBindingState,
|
|
93
|
+
): Promise<BindingResult> {
|
|
94
|
+
return checkAccessibilitySpec({
|
|
95
|
+
spec: TOOLTIP_PATTERN,
|
|
96
|
+
binding: 'Tooltip',
|
|
97
|
+
state: state.id,
|
|
98
|
+
facts: state.facts,
|
|
99
|
+
mount: async () => {
|
|
100
|
+
const {subject, related} = await mountState(page, state);
|
|
101
|
+
return createChromiumHarness({page, cdp, subject, related});
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
test('every tooltip expectation is exercised by a Tooltip state', async ({
|
|
107
|
+
page,
|
|
108
|
+
}) => {
|
|
109
|
+
test.setTimeout(3 * 60 * 1000);
|
|
110
|
+
const cdp = await page.context().newCDPSession(page);
|
|
111
|
+
const results: BindingResult[] = [];
|
|
112
|
+
for (const state of TOOLTIP_BINDING_STATES) {
|
|
113
|
+
results.push(await runState(page, cdp, state));
|
|
114
|
+
}
|
|
115
|
+
expect(neverExercised(results)).toEqual([]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
for (const state of TOOLTIP_BINDING_STATES) {
|
|
119
|
+
test(`Tooltip [${state.id}] — ${state.summary}`, async ({page}) => {
|
|
120
|
+
test.setTimeout(2 * 60 * 1000);
|
|
121
|
+
const cdp = await page.context().newCDPSession(page);
|
|
122
|
+
const result = await runState(page, cdp, state);
|
|
123
|
+
const report = summarize(TOOLTIP_PATTERN, [result]);
|
|
124
|
+
// Required rows block (AST-020 FR9); advisory rows report.
|
|
125
|
+
expect(formatFailures(blockingResults([result]))).toBe('');
|
|
126
|
+
expect(report.unrunLayers).toEqual([]);
|
|
127
|
+
expect(report.counts.unexpectedPass).toBe(0);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file Tooltip.a11y.renders.tsx
|
|
7
|
+
* @input One tooltip binding state from Tooltip.a11y.states.ts
|
|
8
|
+
* @output The React tree every lane renders for that state (the jsdom test directly, the story through Storybook): a page button before the trigger, the trigger and its tooltip, and a page button after it
|
|
9
|
+
* @position Shared fixture for the Tooltip and useTooltip binding
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {useRef, type ReactElement} from 'react';
|
|
13
|
+
import {Button} from '../../Button/Button';
|
|
14
|
+
import {isRenderable} from '../../utils/isRenderable';
|
|
15
|
+
import {Tooltip} from '../Tooltip';
|
|
16
|
+
import {useTooltip} from '../useTooltip';
|
|
17
|
+
import type {TooltipBindingState} from './Tooltip.a11y.states';
|
|
18
|
+
|
|
19
|
+
const HINT_ID = 'tooltip-a11y-hint';
|
|
20
|
+
|
|
21
|
+
type TriggerState = Pick<
|
|
22
|
+
TooltipBindingState,
|
|
23
|
+
'attachment' | 'triggerText' | 'content' | 'hint'
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
/** A caller button the tooltip attaches to through `anchorRef`. */
|
|
27
|
+
function AnchorRefTrigger({state}: {state: TriggerState}): ReactElement {
|
|
28
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<button
|
|
32
|
+
ref={anchorRef}
|
|
33
|
+
type="button"
|
|
34
|
+
aria-describedby={state.hint == null ? undefined : HINT_ID}>
|
|
35
|
+
{state.triggerText}
|
|
36
|
+
</button>
|
|
37
|
+
<Tooltip anchorRef={anchorRef} content={state.content} />
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A caller button wired by hand through `useTooltip`. */
|
|
43
|
+
function HookTrigger({state}: {state: TriggerState}): ReactElement {
|
|
44
|
+
const tooltip = useTooltip();
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<button
|
|
48
|
+
ref={tooltip.ref}
|
|
49
|
+
type="button"
|
|
50
|
+
aria-describedby={tooltip.describedBy}>
|
|
51
|
+
{state.triggerText}
|
|
52
|
+
</button>
|
|
53
|
+
{tooltip.renderTooltip(state.content)}
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function Trigger({state}: {state: TriggerState}): ReactElement {
|
|
59
|
+
switch (state.attachment) {
|
|
60
|
+
case 'wrapped-element':
|
|
61
|
+
return (
|
|
62
|
+
<Tooltip content={state.content}>
|
|
63
|
+
<Button label={state.triggerText} />
|
|
64
|
+
</Tooltip>
|
|
65
|
+
);
|
|
66
|
+
case 'text':
|
|
67
|
+
return <Tooltip content={state.content}>{state.triggerText}</Tooltip>;
|
|
68
|
+
case 'anchor-ref':
|
|
69
|
+
return <AnchorRefTrigger state={state} />;
|
|
70
|
+
case 'hook':
|
|
71
|
+
return <HookTrigger state={state} />;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function renderTooltipState(state: TriggerState): ReactElement {
|
|
76
|
+
return (
|
|
77
|
+
<div style={{padding: 64}}>
|
|
78
|
+
<button type="button">Before the trigger</button>{' '}
|
|
79
|
+
<Trigger state={state} />
|
|
80
|
+
{isRenderable(state.hint) ? (
|
|
81
|
+
<span id={HINT_ID}> {state.hint}</span>
|
|
82
|
+
) : null}{' '}
|
|
83
|
+
<button type="button">After the trigger</button>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|