@astryxdesign/core 0.7.6-canary.2a905bb → 0.7.6-canary.2fa4cef
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/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +36 -9
- package/dist/BottomSheet/useSheetGestures.d.ts +36 -6
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +67 -10
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +27 -2
- package/dist/Layer/useTouchTrigger.d.ts +16 -2
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +56 -7
- package/dist/Toast/useToast.d.ts.map +1 -1
- package/dist/Toast/useToast.js +8 -2
- package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButton.js +8 -2
- package/dist/gestures/haptics.d.ts.map +1 -1
- package/dist/gestures/haptics.js +1 -5
- package/dist/hooks/useClickableContainer.d.ts +24 -4
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +41 -14
- package/dist/theme/Theme.d.ts +10 -0
- package/dist/theme/Theme.d.ts.map +1 -1
- package/dist/theme/Theme.js +8 -4
- package/dist/utils/pressDisabled.d.ts +21 -0
- package/dist/utils/pressDisabled.d.ts.map +1 -0
- package/dist/utils/pressDisabled.js +32 -0
- package/package.json +4 -4
- package/src/BottomSheet/BottomSheetPanel.tsx +39 -8
- package/src/BottomSheet/useSheetGestures.ts +92 -15
- package/src/FileInput/FileInput.tsx +29 -1
- package/src/HoverCard/HoverCard.doc.mjs +3 -3
- package/src/HoverCard/HoverCard.spec.md +16 -14
- package/src/HoverCard/useHoverCard.doc.mjs +1 -1
- package/src/Layer/useTouchTrigger.ts +70 -10
- package/src/Toast/useToast.tsx +8 -3
- package/src/ToggleButton/ToggleButton.tsx +9 -3
- package/src/Tooltip/Tooltip.doc.mjs +3 -3
- package/src/Tooltip/Tooltip.spec.md +17 -17
- package/src/Tooltip/useTooltip.doc.mjs +1 -1
- package/src/gestures/haptics.ts +1 -8
- package/src/hooks/useClickableContainer.ts +48 -17
- package/src/theme/Theme.tsx +8 -4
- package/src/utils/pressDisabled.ts +32 -0
|
@@ -575,6 +575,33 @@ export function FileInput({
|
|
|
575
575
|
.filter(Boolean)
|
|
576
576
|
.join(' ') || undefined;
|
|
577
577
|
|
|
578
|
+
// The native input keeps taking the caller's base props (the shared FR10
|
|
579
|
+
// contract), but it is `aria-hidden` and never focused, so a caller's
|
|
580
|
+
// `aria-*` props are also set on the trigger, the field's focusable control,
|
|
581
|
+
// where assistive tech reads them. The ones the trigger composes itself are
|
|
582
|
+
// not copied, and a caller's description is joined to its own, first.
|
|
583
|
+
const {
|
|
584
|
+
'aria-describedby': callerDescribedBy,
|
|
585
|
+
'aria-label': _callerLabel,
|
|
586
|
+
'aria-labelledby': _callerLabelledBy,
|
|
587
|
+
'aria-hidden': _callerHidden,
|
|
588
|
+
'aria-disabled': _callerDisabled,
|
|
589
|
+
'aria-busy': _callerBusy,
|
|
590
|
+
'aria-invalid': _callerInvalid,
|
|
591
|
+
...otherRest
|
|
592
|
+
} = rest as typeof rest & Record<string, unknown>;
|
|
593
|
+
const triggerAriaProps: Record<string, unknown> = {};
|
|
594
|
+
for (const [key, value] of Object.entries(otherRest)) {
|
|
595
|
+
// Booleans and numbers are valid ARIA values too: React serializes them.
|
|
596
|
+
if (key.startsWith('aria-') && value != null) {
|
|
597
|
+
triggerAriaProps[key] = value;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const triggerDescribedBy =
|
|
601
|
+
[callerDescribedBy, ariaDescribedBy]
|
|
602
|
+
.filter(Boolean)
|
|
603
|
+
.join(' ') || undefined;
|
|
604
|
+
|
|
578
605
|
const defaultPlaceholder = isMultiple
|
|
579
606
|
? t('@astryx.fileInput.placeholderMultiple')
|
|
580
607
|
: t('@astryx.fileInput.placeholder');
|
|
@@ -946,8 +973,9 @@ export function FileInput({
|
|
|
946
973
|
: label
|
|
947
974
|
}
|
|
948
975
|
aria-busy={isBusy || undefined}
|
|
949
|
-
aria-describedby={ariaDescribedBy}
|
|
950
976
|
aria-invalid={status?.type === 'error' ? 'true' : undefined}
|
|
977
|
+
{...triggerAriaProps}
|
|
978
|
+
aria-describedby={triggerDescribedBy}
|
|
951
979
|
/>
|
|
952
980
|
</VisuallyHidden>
|
|
953
981
|
<input
|
|
@@ -104,7 +104,7 @@ export const docs = {
|
|
|
104
104
|
name: 'touchTrigger',
|
|
105
105
|
type: "'auto' | 'tap' | 'none'",
|
|
106
106
|
description:
|
|
107
|
-
'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (a button, link, or form control), whose tap belongs to the control. tap always opens. none never opens on touch. A tap-opened card is dismissed by a tap outside it.',
|
|
107
|
+
'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (a button, link, or form control), whose tap belongs to the control; an aria-disabled control performs none, so a tap on it opens its reason. tap always opens. none never opens on touch. A tap-opened card is dismissed by a tap outside it.',
|
|
108
108
|
default: "'auto'",
|
|
109
109
|
},
|
|
110
110
|
{
|
|
@@ -289,7 +289,7 @@ export const docsZh = {
|
|
|
289
289
|
name: 'touchTrigger',
|
|
290
290
|
type: "'auto' | 'tap' | 'none'",
|
|
291
291
|
description:
|
|
292
|
-
'在没有悬停的触摸设备上,轻点的行为。auto
|
|
292
|
+
'在没有悬停的触摸设备上,轻点的行为。auto:轻点即打开,除非触发元素本身会执行操作(按钮、链接、表单控件),此时轻点归该控件所有;设置了 aria-disabled 的控件不执行操作,因此轻点它会显示其原因。tap:始终轻点打开。none:触摸永不打开。轻点打开的卡片可通过点击卡片外部关闭。',
|
|
293
293
|
default: "'auto'",
|
|
294
294
|
},
|
|
295
295
|
{
|
|
@@ -439,7 +439,7 @@ export const docsDense = {
|
|
|
439
439
|
hideDelay: 'Hide delay in ms.',
|
|
440
440
|
focusTrigger: 'Controls when focus events trigger hover card.',
|
|
441
441
|
touchTrigger:
|
|
442
|
-
'Tap behavior where there is no hover. auto = tap opens unless the trigger acts (button/link/control); tap = always opens; none = never on touch. Tap-opened cards close on a tap outside.',
|
|
442
|
+
'Tap behavior where there is no hover. auto = tap opens unless the trigger acts (button/link/control; an aria-disabled control does not act); tap = always opens; none = never on touch. Tap-opened cards close on a tap outside.',
|
|
443
443
|
isEnabled: 'Enable/disable hover + focus triggers.',
|
|
444
444
|
label:
|
|
445
445
|
'Accessible name for the popup. With label: named role="dialog"; without: role="group".',
|
|
@@ -14,6 +14,8 @@ verified_by:
|
|
|
14
14
|
[
|
|
15
15
|
packages/core/src/HoverCard/HoverCard.test.tsx,
|
|
16
16
|
packages/core/src/Layer/layerDismissalFamilies.test.tsx,
|
|
17
|
+
packages/core/src/Layer/useTouchTrigger.test.ts,
|
|
18
|
+
packages/core/src/Layer/touchTriggerTargets.test.tsx,
|
|
17
19
|
apps/storybook/stories/HoverCard.stories.tsx,
|
|
18
20
|
scripts/check-knowledge.mjs,
|
|
19
21
|
]
|
|
@@ -161,7 +163,7 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
161
163
|
| FR2 | Trigger wiring: a single string or number child is wrapped in a focusable inline span; element `children` attach to their first element inside an inline-safe wrapper. | Current source and tests |
|
|
162
164
|
| FR3 | With `label`, the card is `role="dialog"` named by `label`; the trigger gets `aria-haspopup="dialog"` and, only when its role supports it, `aria-expanded`, each replacing the trigger's own value while the card is wired, plus `aria-controls` naming the card while open, merged with the trigger's own; the trigger's own values return on cleanup. Without `label`, the card is `role="group"` and the trigger's `aria-describedby` gains the card's id. | Current source and tests |
|
|
163
165
|
| FR4 | On a hover-capable pointer, entering the trigger opens the card after `delay` ms; leaving the trigger or the card closes it after `hideDelay` ms, and moving between them keeps it open. Any focus on the trigger, keyboard, pointer, or programmatic, opens it per `focusTrigger`, except the focus a tap leaves behind, the refocus after an Escape dismiss (FR6), and the refocus after a controlled close (FR7). Implementation gap: under `auto` the tab order is read only when the trigger's listeners attach, on mount and on a re-render that re-attaches them, so a trigger rendered with `tabindex="-1"` does not open on focus until such a re-render follows its move into the tab order (Current-state impact). | WCAG 1.4.13; tests |
|
|
164
|
-
| FR5 | On touch, a completed tap opens it per `touchTrigger` when the finger lifts; a touch that becomes a scroll does not. Under `auto`, a tap that already acts leaves it shut, decided as `component:Tooltip` DEC-1 decides it: the innermost control from the tapped element outward, the trigger included, decides, and
|
|
166
|
+
| FR5 | On touch, a completed tap opens it per `touchTrigger` when the finger lifts; a touch that becomes a scroll does not. Under `auto`, a tap that already acts leaves it shut, decided as `component:Tooltip` DEC-1 decides it: the innermost control from the tapped element outward, the trigger included, decides, and an `aria-disabled` control, or a label for a disabled control, is not an action (DEC-1). Implementation gap: the walk ships with `component:Tooltip` CLN-0024 in the next minor; until then `auto` asks only whether the trigger itself performs an action, apart from a disabled control (Compatibility and migration). A tap on the card's own content keeps it open; a second tap on the trigger, a tap outside, or a scroll starting outside closes it. Under `pressTrigger="toggle"`, FR9 decides what a tap does and `touchTrigger` is ignored. | Current source and tests |
|
|
165
167
|
| FR6 | Escape closes a visible card through the shared dismissal stack when it is the topmost layer in the page, so a layer underneath stays open. Implementation gap: a card rendered into another document, such as an iframe or a Picture-in-Picture window, with no layer beneath it is never closed by Escape (Current-state impact). When focus was inside the card, it returns to the trigger, and that refocus does not reopen the card. | WCAG 1.4.13; tests |
|
|
166
168
|
| FR7 | `isOpen` forces the card shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled card answers Escape by calling `onOpenChange(false)` without hiding, and setting `isOpen={false}` while focus is inside the card returns focus to the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, focus on the trigger still opens the card, and Escape then only reports `onOpenChange(false)` (Current-state impact). `isEnabled={false}` disables the triggers. `onOpenChange` reports each show and hide. | Current source and tests |
|
|
167
169
|
| FR8 | Content renders only while open; server markup and the first client render match, including a default-open card. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
|
|
@@ -248,14 +250,14 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
248
250
|
|
|
249
251
|
## Verification map
|
|
250
252
|
|
|
251
|
-
| Contract | Verification
|
|
252
|
-
| ------------------- |
|
|
253
|
-
| FR1, FR2, FR8 | `HoverCard.test.tsx` render, wrapper, portal, theme font, and SSR tests
|
|
254
|
-
| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests
|
|
255
|
-
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; tap-destination cases an evidence gap until built
|
|
256
|
-
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case
|
|
257
|
-
| FR9, FR10, AR3 | Evidence gap until built: a press-toggle suite in `HoverCard.test.tsx` and a controlled pinned case in `layerDismissalFamilies.test.tsx`
|
|
258
|
-
| Theming anatomy map | `scripts/check-knowledge.mjs`
|
|
253
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
254
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
|
255
|
+
| FR1, FR2, FR8 | `HoverCard.test.tsx` render, wrapper, portal, theme font, and SSR tests | Text and element triggers; default open | A stray target, lost font, or hydration mismatch fails. | `audit:HoverCard/anatomy` |
|
|
256
|
+
| FR3, AR1 | `HoverCard.test.tsx` role and trigger-attribute tests | Labelled and unlabelled; supported and unsupported roles | Wrong role, or trigger attributes that are not replaced and restored as stated, fail. | `audit:HoverCard/accessibility` |
|
|
257
|
+
| FR4–FR6, AR2 | `HoverCard.test.tsx` hover, Escape, refocus, and touch tests; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases; tap-destination cases an evidence gap until built | Hover, focus, tap, Escape from trigger and content; a trigger inside a link or a clickable card; a disabled control inside a clickable row | A card that cannot be reached or dismissed, or that opens on a tap that already acts, fails. | `audit:HoverCard/behavior` |
|
|
258
|
+
| FR7 | `HoverCard.test.tsx` isEnabled, isDefaultOpen, and onOpenChange tests; `layerDismissalFamilies.test.tsx` controlled HoverCard case | Disabled, default open | Wrong state reporting fails. | `audit:HoverCard/behavior` |
|
|
259
|
+
| FR9, FR10, AR3 | Evidence gap until built: a press-toggle suite in `HoverCard.test.tsx` and a controlled pinned case in `layerDismissalFamilies.test.tsx` | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave and presses on the card keep the pin; labelled and unlabelled; non-button trigger; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:HoverCard/behavior` |
|
|
260
|
+
| Theming anatomy map | `scripts/check-knowledge.mjs` | Consumer anatomy and current target | Missing, extra, or stale mappings fail validation. | `audit:HoverCard/theming` |
|
|
259
261
|
|
|
260
262
|
Read from source, with no focused test yet:
|
|
261
263
|
|
|
@@ -282,11 +284,11 @@ information, such as a timestamp's details. `touchTrigger="auto"`, the
|
|
|
282
284
|
default until `touchTrigger` folds into `pressTrigger` at the next minor, is
|
|
283
285
|
the fallback: under it, a tap that already acts does not open the card. The
|
|
284
286
|
walk that decides it starts at the tapped element and the innermost control
|
|
285
|
-
decides;
|
|
286
|
-
element that acts only through a role-less `onClick` is a
|
|
287
|
-
`component:Tooltip` DEC-1 states. The deprecation of
|
|
288
|
-
the fold are `component:Tooltip` DEP-0016 and CLN-0024,
|
|
289
|
-
unchanged.
|
|
287
|
+
decides; an `aria-disabled` control, or a label for a disabled control, is not
|
|
288
|
+
an action; and an element that acts only through a role-less `onClick` is a
|
|
289
|
+
caller fix, as `component:Tooltip` DEC-1 states. The deprecation of
|
|
290
|
+
`touchTrigger="tap"` and the fold are `component:Tooltip` DEP-0016 and CLN-0024,
|
|
291
|
+
which apply here unchanged.
|
|
290
292
|
|
|
291
293
|
Rejected: judging the trigger alone, which lets one tap open a name's card over
|
|
292
294
|
the card the same tap opened.
|
|
@@ -12,7 +12,7 @@ export const docs = {
|
|
|
12
12
|
{name: 'delay', type: 'number', description: 'Delay before showing the hover card on hover, in milliseconds.', default: '300'},
|
|
13
13
|
{name: 'hideDelay', type: 'number', description: 'Delay before hiding after mouse or focus leaves, in milliseconds.', default: '200'},
|
|
14
14
|
{name: 'focusTrigger', type: "'auto' | 'always' | 'never'", description: 'When focus should open the hover card. auto only attaches focus listeners to naturally focusable elements.', default: "'auto'"},
|
|
15
|
-
{name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own; tap always opens; none never opens on touch.', default: "'auto'"},
|
|
15
|
+
{name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (an aria-disabled control performs none); tap always opens; none never opens on touch.', default: "'auto'"},
|
|
16
16
|
{name: 'isEnabled', type: 'boolean', description: 'Whether hover and focus triggers are enabled.', default: 'true'},
|
|
17
17
|
{name: 'label', type: 'string', description: 'Accessible name for the hover card popup. When provided, the popup is exposed as a named role="dialog"; when omitted, it falls back to role="group" (a group may validly be unnamed).'},
|
|
18
18
|
{name: 'isOpen', type: 'boolean', description: 'Controlled open state. true force-shows, false force-hides, undefined lets hover/focus manage visibility.'},
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* @file useTouchTrigger.ts
|
|
7
7
|
* @input Touch trigger mode, layer open state, trigger ref, show/hide callbacks
|
|
8
8
|
* @output Exports useTouchTrigger hook, isActionTrigger, LayerTouchTrigger type,
|
|
9
|
-
* TOUCH_POINTER_TYPES and useTapStop (internal:
|
|
9
|
+
* tapLandsOnDisabledControl, TOUCH_POINTER_TYPES and useTapStop (internal:
|
|
10
|
+
* not re-exported from index)
|
|
10
11
|
* @position Layer hook; shared touch behavior for useTooltip and useHoverCard
|
|
11
12
|
*
|
|
12
13
|
* SYNC: When modified, update:
|
|
13
14
|
* - /packages/core/src/Layer/index.ts
|
|
15
|
+
* - /packages/core/src/hooks/useClickableContainer.ts (innermostInteractive)
|
|
14
16
|
*
|
|
15
17
|
* Hover is the one trigger a touch screen cannot express. A tap synthesizes
|
|
16
18
|
* `mouseenter`, so an untreated hover layer either opens on every tap and
|
|
@@ -24,7 +26,10 @@
|
|
|
24
26
|
* action — an info icon, an abbreviation, a truncated label — has nothing to
|
|
25
27
|
* lose, so the tap opens the layer and the next tap outside dismisses it. That
|
|
26
28
|
* is `auto`; `tap` and `none` state the choice outright, which is what an
|
|
27
|
-
* icon-button whose only job is to reveal the layer needs.
|
|
29
|
+
* icon-button whose only job is to reveal the layer needs. An `aria-disabled`
|
|
30
|
+
* control performs no action: a tap that lands in one, or on a label for a
|
|
31
|
+
* disabled control, opens the layer, so its reason has a touch path. (A
|
|
32
|
+
* natively `disabled` control receives no click at all.)
|
|
28
33
|
*
|
|
29
34
|
* A touch decides nothing until it is a tap. A finger landing on the trigger
|
|
30
35
|
* may be starting a scroll, a pinch or a long press, and only the browser
|
|
@@ -47,6 +52,11 @@ import {
|
|
|
47
52
|
type RefObject,
|
|
48
53
|
} from 'react';
|
|
49
54
|
import {currentGesture} from './gestureCounter';
|
|
55
|
+
import {
|
|
56
|
+
innermostInteractive,
|
|
57
|
+
matchesInteractiveSelectors,
|
|
58
|
+
} from '../hooks/useClickableContainer';
|
|
59
|
+
import {isDisabledControl} from '../utils/pressDisabled';
|
|
50
60
|
import {useInteractionModalityTrackingFor} from '../utils/interactionModality';
|
|
51
61
|
|
|
52
62
|
/**
|
|
@@ -128,15 +138,25 @@ const ACTION_ROLES = new Set([
|
|
|
128
138
|
* with no role) gets both: the layer opens and the handler runs.
|
|
129
139
|
*/
|
|
130
140
|
export function isActionTrigger(element: HTMLElement): boolean {
|
|
141
|
+
// A disabled control performs no action: its tap is free to open the layer
|
|
142
|
+
// that explains why it is disabled.
|
|
143
|
+
if (isDisabledControl(element)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
131
146
|
const role = element.getAttribute('role');
|
|
132
147
|
if (role != null && role !== '') {
|
|
133
148
|
return ACTION_ROLES.has(role);
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
switch (element.tagName) {
|
|
152
|
+
case 'LABEL': {
|
|
153
|
+
// A label acts by operating its control, so a label for a disabled one
|
|
154
|
+
// performs none.
|
|
155
|
+
const control = (element as HTMLLabelElement).control;
|
|
156
|
+
return control == null || !isDisabledControl(control);
|
|
157
|
+
}
|
|
137
158
|
case 'BUTTON':
|
|
138
159
|
case 'INPUT':
|
|
139
|
-
case 'LABEL':
|
|
140
160
|
case 'SELECT':
|
|
141
161
|
case 'SUMMARY':
|
|
142
162
|
case 'TEXTAREA':
|
|
@@ -149,6 +169,41 @@ export function isActionTrigger(element: HTMLElement): boolean {
|
|
|
149
169
|
}
|
|
150
170
|
}
|
|
151
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Whether this element takes a tap itself, as a disabled control does: an
|
|
174
|
+
* `aria-disabled` (or `:disabled`) control, or a label for one.
|
|
175
|
+
*/
|
|
176
|
+
function isDisabledTarget(element: Element): boolean {
|
|
177
|
+
if (isDisabledControl(element)) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
if (element.tagName === 'LABEL') {
|
|
181
|
+
const control = (element as HTMLLabelElement).control;
|
|
182
|
+
return control != null && isDisabledControl(control);
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Whether a tap landed in a disabled control: walking out from the tapped
|
|
189
|
+
* element on the clickable containers' own walk (`innermostInteractive`),
|
|
190
|
+
* with labels counted, the innermost interactive element is an
|
|
191
|
+
* `aria-disabled` control or a label for a disabled control. That element
|
|
192
|
+
* takes the tap: the layer opens with its reason, and nothing activates.
|
|
193
|
+
* Every other tap is left to the trigger (`isActionTrigger`).
|
|
194
|
+
*/
|
|
195
|
+
export function tapLandsOnDisabledControl(tapped: Element): boolean {
|
|
196
|
+
const innermost = innermostInteractive(
|
|
197
|
+
tapped,
|
|
198
|
+
null,
|
|
199
|
+
element =>
|
|
200
|
+
matchesInteractiveSelectors(element) ||
|
|
201
|
+
element.tagName === 'LABEL' ||
|
|
202
|
+
isDisabledControl(element),
|
|
203
|
+
);
|
|
204
|
+
return innermost != null && isDisabledTarget(innermost);
|
|
205
|
+
}
|
|
206
|
+
|
|
152
207
|
/**
|
|
153
208
|
* Whether typing into this element edits it. Reads the attribute as well as
|
|
154
209
|
* the property: jsdom does not implement `isContentEditable`, and an editor
|
|
@@ -350,14 +405,19 @@ export function useTouchTrigger(
|
|
|
350
405
|
|
|
351
406
|
// What a tap on the trigger does. It runs from the tap's `click`, after the
|
|
352
407
|
// render that armed it, so it reads the latest props through this ref.
|
|
353
|
-
const answerTapRef = useRef<() => void>(() => {});
|
|
354
|
-
answerTapRef.current = () => {
|
|
408
|
+
const answerTapRef = useRef<(tapEvent: Event) => void>(() => {});
|
|
409
|
+
answerTapRef.current = (tapEvent: Event) => {
|
|
355
410
|
const trigger = triggerRef.current;
|
|
411
|
+
// A tap that landed in a disabled control is that control's: its reason
|
|
412
|
+
// opens. Every other tap is the trigger's to decide.
|
|
413
|
+
const tapped = tapEvent.target instanceof Element ? tapEvent.target : null;
|
|
356
414
|
const mode =
|
|
357
415
|
touchTrigger === 'auto'
|
|
358
|
-
?
|
|
359
|
-
? '
|
|
360
|
-
:
|
|
416
|
+
? tapped != null && tapLandsOnDisabledControl(tapped)
|
|
417
|
+
? 'tap'
|
|
418
|
+
: trigger != null && isActionTrigger(trigger)
|
|
419
|
+
? 'none'
|
|
420
|
+
: 'tap'
|
|
361
421
|
: touchTrigger;
|
|
362
422
|
|
|
363
423
|
if (mode === 'none' || !isEnabled) {
|
|
@@ -409,10 +469,10 @@ export function useTouchTrigger(
|
|
|
409
469
|
forgetPendingTapRef.current = null;
|
|
410
470
|
}
|
|
411
471
|
};
|
|
412
|
-
const handleTap = () => {
|
|
472
|
+
const handleTap = (tapEvent: Event) => {
|
|
413
473
|
forget();
|
|
414
474
|
if (currentGesture() === gesture) {
|
|
415
|
-
answerTapRef.current();
|
|
475
|
+
answerTapRef.current(tapEvent);
|
|
416
476
|
}
|
|
417
477
|
};
|
|
418
478
|
trigger.addEventListener('click', handleTap);
|
package/src/Toast/useToast.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {createRoot} from 'react-dom/client';
|
|
|
7
7
|
import {dataAttr} from '../naming';
|
|
8
8
|
import {ToastContext, type ToastContextValue} from './ToastContext';
|
|
9
9
|
import {ToastViewport} from './ToastViewport';
|
|
10
|
+
import {ThemeNestingContext} from '../theme/Theme';
|
|
10
11
|
import {warnOnce} from '../utils/devWarning';
|
|
11
12
|
import type {
|
|
12
13
|
ToastOptions,
|
|
@@ -101,10 +102,14 @@ function getFallbackContext(): ToastContextValue {
|
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
fallbackRoot = createRoot(container);
|
|
105
|
+
// This root sits inside the app, so a <Theme> in toast content is nested:
|
|
106
|
+
// it themes its own subtree and leaves the app's <html> sync alone.
|
|
104
107
|
fallbackRoot.render(
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
+
<ThemeNestingContext value={true}>
|
|
109
|
+
<ToastViewport>
|
|
110
|
+
<FallbackCapture />
|
|
111
|
+
</ToastViewport>
|
|
112
|
+
</ThemeNestingContext>,
|
|
108
113
|
);
|
|
109
114
|
|
|
110
115
|
// Proxy that queues calls until real context is captured
|
|
@@ -29,7 +29,7 @@ import {Button, type ButtonSize} from '../Button';
|
|
|
29
29
|
import type {Elevation} from '../utils/types';
|
|
30
30
|
import {useToggleButtonGroup} from './ToggleButtonGroup';
|
|
31
31
|
import type {BaseProps} from '../BaseProps';
|
|
32
|
-
import {themeProps} from '../utils/themeProps';
|
|
32
|
+
import {themeDataAttributes, themeProps} from '../utils/themeProps';
|
|
33
33
|
import {mergeProps} from '../utils/mergeProps';
|
|
34
34
|
|
|
35
35
|
// =============================================================================
|
|
@@ -352,7 +352,6 @@ export function ToggleButton({
|
|
|
352
352
|
isLoading={isLoading}
|
|
353
353
|
isInterruptible
|
|
354
354
|
isIconOnly={isIconOnly}
|
|
355
|
-
aria-pressed={isPressed}
|
|
356
355
|
icon={resolvedIcon}
|
|
357
356
|
tooltip={tooltip}
|
|
358
357
|
{...mergeProps(
|
|
@@ -366,7 +365,14 @@ export function ToggleButton({
|
|
|
366
365
|
style={style}
|
|
367
366
|
onClick={handleClick}
|
|
368
367
|
clickAction={clickAction}
|
|
369
|
-
{...props}
|
|
368
|
+
{...props}
|
|
369
|
+
// The pressed state this component owns wins over a caller's
|
|
370
|
+
// same-named attributes (public-component-api INV5).
|
|
371
|
+
aria-pressed={isPressed}
|
|
372
|
+
{...themeDataAttributes({
|
|
373
|
+
isPressed: isPressed ? 'true' : 'false',
|
|
374
|
+
elevation,
|
|
375
|
+
})}>
|
|
370
376
|
{labelContent}
|
|
371
377
|
</Button>
|
|
372
378
|
);
|
|
@@ -84,7 +84,7 @@ export const docs = {
|
|
|
84
84
|
name: 'touchTrigger',
|
|
85
85
|
type: "'auto' | 'tap' | 'none'",
|
|
86
86
|
description:
|
|
87
|
-
'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (a button, link, or form control), whose tap belongs to the control. tap always opens; use it for an info icon rendered as a button, whose only job is to reveal the tooltip. none never opens on touch.',
|
|
87
|
+
'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (a button, link, or form control), whose tap belongs to the control; an aria-disabled control performs none, so a tap on it opens its reason. tap always opens; use it for an info icon rendered as a button, whose only job is to reveal the tooltip. none never opens on touch.',
|
|
88
88
|
default: "'auto'",
|
|
89
89
|
},
|
|
90
90
|
{
|
|
@@ -197,7 +197,7 @@ export const docsZh = {
|
|
|
197
197
|
name: 'touchTrigger',
|
|
198
198
|
type: "'auto' | 'tap' | 'none'",
|
|
199
199
|
description:
|
|
200
|
-
'在没有悬停的触摸设备上,轻点的行为。auto
|
|
200
|
+
'在没有悬停的触摸设备上,轻点的行为。auto:轻点即打开,除非触发元素本身会执行操作(按钮、链接、表单控件),此时轻点归该控件所有;设置了 aria-disabled 的控件不执行操作,因此轻点它会显示其原因。tap:始终轻点打开——适用于以按钮形式呈现、唯一作用就是显示工具提示的信息图标。none:触摸永不打开。',
|
|
201
201
|
default: "'auto'",
|
|
202
202
|
},
|
|
203
203
|
{
|
|
@@ -274,7 +274,7 @@ export const docsDense = {
|
|
|
274
274
|
delay: 'Show delay in ms.',
|
|
275
275
|
hideDelay: 'Hide delay in ms.',
|
|
276
276
|
focusTrigger: 'Controls when focus events trigger tooltip.',
|
|
277
|
-
touchTrigger: 'Tap behavior where there is no hover. auto = tap opens unless the trigger acts (button/link/control); tap = always opens (info icon rendered as a button); none = never on touch.',
|
|
277
|
+
touchTrigger: 'Tap behavior where there is no hover. auto = tap opens unless the trigger acts (button/link/control; an aria-disabled control does not act); tap = always opens (info icon rendered as a button); none = never on touch.',
|
|
278
278
|
isEnabled: 'Enables/disables tooltip triggers.',
|
|
279
279
|
onOpenChange: 'Callback when visibility changes; true=shown, false=hidden.',
|
|
280
280
|
hasHoverIndication: 'Dashed underline on trigger element.',
|
|
@@ -15,6 +15,7 @@ verified_by:
|
|
|
15
15
|
packages/core/src/Tooltip/Tooltip.test.tsx,
|
|
16
16
|
packages/core/src/Layer/__tests__/TouchTrigger.a11y.chromium.spec.ts,
|
|
17
17
|
packages/core/src/Tooltip/useTooltip.test.tsx,
|
|
18
|
+
packages/core/src/Layer/touchTriggerTargets.test.tsx,
|
|
18
19
|
packages/core/src/Tooltip/__tests__/Tooltip.a11y.test.tsx,
|
|
19
20
|
packages/core/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts,
|
|
20
21
|
packages/core/src/Tooltip/__tests__/TooltipHoverBridge.a11y.chromium.spec.ts,
|
|
@@ -129,8 +130,7 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
129
130
|
- **A tap inside a control still opens the tooltip.** The shipped
|
|
130
131
|
`touchTrigger="auto"` asks only whether the trigger itself performs an action,
|
|
131
132
|
so a truncated label inside a link opens its tooltip on the tap that follows
|
|
132
|
-
the link
|
|
133
|
-
with CLN-0024 and the disabled-control restoration as a patch (FR5, DEC-1).
|
|
133
|
+
the link. The walk ships with CLN-0024 (FR5, DEC-1).
|
|
134
134
|
- **Press-to-pin is not built.** `pressTrigger`, its toggle (FR9), the trigger
|
|
135
135
|
wiring and announcement (FR10), and a pinned tooltip's Escape priority
|
|
136
136
|
(`spec:AST-003` FR4) are specified and not implemented, and the codemod
|
|
@@ -209,7 +209,7 @@ Consumer migration instructions belong in consumer docs and release notes.
|
|
|
209
209
|
| FR2 | Trigger wiring: a single string or number child is wrapped in a focusable inline span; element `children` attach to their first element; `anchorRef` attaches to that element. The trigger's `aria-describedby` gains the tooltip id, merged with and later restored to any existing value. Implementation gap: the wiring runs only when the trigger's listeners attach, so a trigger element replaced after mount, or a trigger whose own `aria-describedby` changes, loses it until a re-render re-attaches them (Current-state impact). | Current source and tests |
|
|
210
210
|
| FR3 | On a hover-capable pointer, entering the trigger opens after `delay` ms; leaving closes after `hideDelay` ms. With `hideDelay` 0 a short bridge lets the pointer move onto the surface without closing it, and the surface stays open while hovered. | WCAG 1.4.13; tests |
|
|
211
211
|
| FR4 | Focus that matches `:focus-visible` opens the tooltip per `focusTrigger`: keyboard focus, programmatic focus that follows keyboard input (AR4), pointer focus on a text-entry trigger, which browsers mark focus-visible, and programmatic focus on a text-entry trigger unless a finger or pen pressed that trigger and the last input was a pointer press, and on any other trigger unless the last input was a pointer (after keyboard input, as in AR4, or before any input). Implementation gap: script focus after a pointer press that focused nothing opens it, because the hook reads `:focus-visible` alone (Current-state impact). Focus a tap leaves behind, and other pointer focus, does not. Focus leaving the trigger schedules the hide as a pointer leave does. Under `focusTrigger="auto"`, focus opens the tooltip on any focusable trigger. Implementation gap: `auto` recognizes only an explicit non-negative `tabindex`, HTML links, buttons, form fields, and editable elements, so a `<summary>` or an SVG link never opens on keyboard focus; and it reads the tab order only when it attaches the trigger's listeners, on mount and again when `focusTrigger`, `isEnabled`, `isOpen`, `delay`, `hideDelay`, or `onOpenChange` changes, so a trigger rendered with `tabindex="-1"` does not open on focus until such a re-render follows its move into the tab order (Current-state impact). | Current source and tests |
|
|
212
|
-
| FR5 | On touch, a completed tap opens per `touchTrigger` when the finger lifts; a touch that becomes a scroll, or a press the browser does not count as a tap, does not open it. Under `auto`, a tap that already acts leaves it shut: walking out from the tapped element, the trigger included, the innermost button, link, label, form control, option, menu item, or row or card made clickable with `useClickableContainer` decides, and
|
|
212
|
+
| FR5 | On touch, a completed tap opens per `touchTrigger` when the finger lifts; a touch that becomes a scroll, or a press the browser does not count as a tap, does not open it. Under `auto`, a tap that already acts leaves it shut: walking out from the tapped element, the trigger included, the innermost button, link, label, form control, option, menu item, or row or card made clickable with `useClickableContainer` decides, and an `aria-disabled` control, or a label for a disabled control, is not an action, so a disabled control's reason opens on a tap even inside a clickable row or card (DEC-1). Implementation gap: the walk ships with CLN-0024 in the next minor; until then `auto` asks only whether the trigger itself performs an action, apart from a disabled control (Compatibility and migration). A second tap on the trigger, a tap outside, or a scroll starting outside closes it. Under `pressTrigger="toggle"`, FR9 decides what a tap does and `touchTrigger` is ignored. | Current source and tests |
|
|
213
213
|
| FR6 | Escape closes a visible tooltip; Escape during text composition is ignored. Escape routing follows `family:overlay-dismissal`: a visible topmost tooltip in the page handles that Escape, so a layer underneath stays open for that press. Implementation gap: a tooltip rendered into another document, such as an iframe or a Picture-in-Picture window, with no layer beneath it is never closed by Escape (Current-state impact). `spec:AST-003` FR4, accepted and not yet implemented, makes an unpinned tooltip passive and gives a pinned one Escape first (Current-state impact). Outside `pressTrigger="toggle"`, pressing an uncontrolled tooltip's trigger closes it; a press that focuses a text-entry trigger reopens it through FR4. | WCAG 1.4.13; tests |
|
|
214
214
|
| FR7 | `isOpen` forces the tooltip shown or hidden, and `isOpen={true}` suppresses hover and focus hiding; a controlled tooltip answers Escape by calling `onOpenChange(false)` without hiding, and is not closed by pressing the trigger. `isDefaultOpen` opens it on mount, still dismissible. Implementation gap: with `isOpen={false}`, any focus FR4 opens on, keyboard focus or a click into a text-field trigger, still opens the tooltip and reports `onOpenChange(true)`, and Escape then only reports `onOpenChange(false)`, so it stays until focus or the pointer leaves the trigger or the tooltip, or the caller re-renders with a new `onOpenChange` (Current-state impact). `isEnabled={false}` disables triggers and drops a pending open. | Current source and tests |
|
|
215
215
|
| FR8 | `onOpenChange` reports each show and hide. `hasHoverIndication` (`auto`: a single string or number child) adds a hover cue to the inline trigger. | Current source and tests |
|
|
@@ -291,16 +291,16 @@ has no arrow element.
|
|
|
291
291
|
|
|
292
292
|
## Verification map
|
|
293
293
|
|
|
294
|
-
| Contract | Verification
|
|
295
|
-
| ------------------- |
|
|
296
|
-
| FR1 | `Tooltip.test.tsx` role/content suite
|
|
297
|
-
| FR2–FR8 | `Tooltip.test.tsx`; `useTooltip.test.tsx`
|
|
298
|
-
| AR1–AR4 | `Tooltip.a11y.test.tsx`; `Tooltip.a11y.chromium.spec.ts`; `TooltipHoverBridge.a11y.chromium.spec.ts`; `TooltipFocusReturn.a11y.chromium.spec.ts`
|
|
299
|
-
| AR5 | `Tooltip.a11y.test.tsx`; `Tooltip.a11y.chromium.spec.ts`
|
|
300
|
-
| FR5 | `Tooltip.test.tsx` touch suite; `TouchTrigger.a11y.chromium.spec.ts`; `useTouchTrigger.test.ts
|
|
301
|
-
| FR9, FR10, AR6 | Evidence gap until built: a press-toggle suite in `Tooltip.test.tsx` and `useTooltip.test.tsx`, and a real-touch and keyboard case in `TouchTrigger.a11y.chromium.spec.ts`
|
|
302
|
-
| DEP-0016, CLN-0024 | Evidence gap until built: the codemod's tests and fixtures beside its transform, and the codemod verify workflow
|
|
303
|
-
| Theming anatomy map | `scripts/check-knowledge.mjs`
|
|
294
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
295
|
+
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
296
|
+
| FR1 | `Tooltip.test.tsx` role/content suite | Rendered surface and supplied content | Removing the surface or content fails existing tooltip role and text assertions. | `audit:Tooltip/anatomy` |
|
|
297
|
+
| FR2–FR8 | `Tooltip.test.tsx`; `useTooltip.test.tsx` | Hover, focus, tap, Escape, controlled, default open | Wrong open or close for an input fails. | `audit:Tooltip/behavior` |
|
|
298
|
+
| AR1–AR4 | `Tooltip.a11y.test.tsx`; `Tooltip.a11y.chromium.spec.ts`; `TooltipHoverBridge.a11y.chromium.spec.ts`; `TooltipFocusReturn.a11y.chromium.spec.ts` | Real-browser hover bridge and focus return | A tooltip that vanishes on the way to it or strands focus fails. | `audit:Tooltip/accessibility` |
|
|
299
|
+
| AR5 | `Tooltip.a11y.test.tsx`; `Tooltip.a11y.chromium.spec.ts` | Wrapped, text, anchor, and hook triggers | A lost role, description, keyboard-focus show, or Escape dismissal fails; focus-leave hide, hover show, and leave hide run as advisory rows (Current-state impact). | `audit:Tooltip/accessibility` |
|
|
300
|
+
| FR5 | `Tooltip.test.tsx` touch suite; `TouchTrigger.a11y.chromium.spec.ts`; `useTouchTrigger.test.ts` and `touchTriggerTargets.test.tsx` disabled-control cases, with tap-destination cases an evidence gap until built | Tap open, scroll, second tap, tap outside; a trigger inside a link, a clickable row, or a clickable card; a trigger in running text; a disabled control inside a clickable row | A tap that fails to open or close as stated, opens the tooltip on a tap that already acts, or leaves a disabled control's reason shut fails. | `audit:Tooltip/behavior` |
|
|
301
|
+
| FR9, FR10, AR6 | Evidence gap until built: a press-toggle suite in `Tooltip.test.tsx` and `useTooltip.test.tsx`, and a real-touch and keyboard case in `TouchTrigger.a11y.chromium.spec.ts` | Click, Enter, Space, and tap pin; second press, press outside, focus leaving, and Escape close; pointer leave keeps the pin; controlled; non-button trigger; a truncated Text trigger whose tooltip repeats its text; a toggle trigger inside a ClickableCard, an Item row, and a `<label>` | A press that does not pin or close as stated, a pin lost on pointer leave, a missing or stale `aria-expanded` or `aria-controls`, a second announcement, a non-button trigger without the warning or its tap fallback, an own-text trigger that warns, gets `aria-expanded`, or is announced, or a pinning press that also activates the card, row, or labelled control around the trigger, fails. | `audit:Tooltip/behavior` |
|
|
302
|
+
| DEP-0016, CLN-0024 | Evidence gap until built: the codemod's tests and fixtures beside its transform, and the codemod verify workflow | `touchTrigger="tap"` on an icon and a span, and on an own-text trigger, an info-only button, a button with its own action, a link, and an unknown element, under each codemod; `"auto"` and `"none"`; `pressTrigger` beside `touchTrigger`; spreads and dynamic values | A rewrite that changes behavior; under DEP-0016's codemod, a rewritten own-text, button, link, or unknown-element site; under CLN-0024's codemod, a rewritten button, link, or unknown-element site, or an identifiable own-text site left unrewritten; a reported site without its manual-migration note (all three options for a button or link); a missed static use; or a silently skipped dynamic one fails. | `audit:Tooltip/api` |
|
|
303
|
+
| Theming anatomy map | `scripts/check-knowledge.mjs` | Canonical anatomy and current target | Missing, extra, prefixed, or stale mappings fail repository validation. | `audit:Tooltip/theming` |
|
|
304
304
|
|
|
305
305
|
Read from source, with no focused test yet:
|
|
306
306
|
|
|
@@ -340,10 +340,10 @@ truncated label inside a link follows the link, while a truncated label in
|
|
|
340
340
|
running text opens its tooltip. Whether a tap acts is decided by walking out
|
|
341
341
|
from the tapped element: the innermost control on that path decides, whether a
|
|
342
342
|
button, link, label, form control, option, menu item, or row or card made
|
|
343
|
-
clickable with `useClickableContainer`, the trigger included.
|
|
344
|
-
|
|
345
|
-
inside a clickable row or card. An element that acts only
|
|
346
|
-
`onClick` is a caller fix: it needs a role.
|
|
343
|
+
clickable with `useClickableContainer`, the trigger included. An `aria-disabled`
|
|
344
|
+
control, or a label for a disabled control, is not an action, so its reason
|
|
345
|
+
opens on a tap, even inside a clickable row or card. An element that acts only
|
|
346
|
+
through a role-less `onClick` is a caller fix: it needs a role.
|
|
347
347
|
|
|
348
348
|
The walk ships with the fold at the next minor (CLN-0024).
|
|
349
349
|
`touchTrigger="tap"` is deprecated in favor of the toggle (DEP-0016).
|
|
@@ -12,7 +12,7 @@ export const docs = {
|
|
|
12
12
|
{name: 'delay', type: 'number', description: 'Delay before showing on hover, in milliseconds.', default: '200'},
|
|
13
13
|
{name: 'hideDelay', type: 'number', description: 'Delay before hiding after mouse or focus leaves, in milliseconds.', default: '0'},
|
|
14
14
|
{name: 'focusTrigger', type: "'auto' | 'always' | 'never'", description: 'When focus should open the tooltip. auto only attaches focus listeners to naturally focusable elements.', default: "'auto'"},
|
|
15
|
-
{name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own; tap always opens (an info icon rendered as a button); none never opens on touch.', default: "'auto'"},
|
|
15
|
+
{name: 'touchTrigger', type: "'auto' | 'tap' | 'none'", description: 'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own (an aria-disabled control performs none); tap always opens (an info icon rendered as a button); none never opens on touch.', default: "'auto'"},
|
|
16
16
|
{name: 'isEnabled', type: 'boolean', description: 'Whether hover and focus triggers are enabled.', default: 'true'},
|
|
17
17
|
{name: 'isOpen', type: 'boolean', description: 'Controlled open state. true force-shows, false force-hides, undefined lets hover/focus manage visibility.'},
|
|
18
18
|
{name: 'isDefaultOpen', type: 'boolean', description: 'Whether the tooltip should be shown on mount.', default: 'false'},
|
package/src/gestures/haptics.ts
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
HAPTIC_VIBRATION_PATTERNS,
|
|
39
39
|
type HapticFeedbackKind,
|
|
40
40
|
} from '../motion/uikit/gestures';
|
|
41
|
+
import {isDisabledControl} from '../utils/pressDisabled';
|
|
41
42
|
|
|
42
43
|
/** Marks the hidden switch, so click handlers can recognize and ignore it. */
|
|
43
44
|
export const HAPTIC_SWITCH_ATTRIBUTE = 'data-astryx-haptic-switch';
|
|
@@ -79,14 +80,6 @@ const VISUALLY_HIDDEN =
|
|
|
79
80
|
|
|
80
81
|
let nextLabelId = 0;
|
|
81
82
|
|
|
82
|
-
/** A native disabled control, or one marked `aria-disabled`. */
|
|
83
|
-
function isDisabledControl(control: HTMLElement): boolean {
|
|
84
|
-
return (
|
|
85
|
-
control.matches(':disabled') ||
|
|
86
|
-
control.getAttribute('aria-disabled') === 'true'
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
83
|
/** Whether `input` is a switch checkbox, which plays the tap haptic itself. */
|
|
91
84
|
function isSwitch(input: HTMLInputElement): boolean {
|
|
92
85
|
return input.type === 'checkbox' && input.hasAttribute('switch');
|