@astryxdesign/core 0.7.15-canary.gf890983 → 0.7.15
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/CHANGELOG.md +72 -2
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +5 -4
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +10 -23
- package/dist/Item/Item.js +2 -2
- package/dist/Layer/useTouchTrigger.d.ts +12 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +22 -3
- package/dist/Outline/useScrollSpy.d.ts.map +1 -1
- package/dist/Outline/useScrollSpy.js +22 -18
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +6 -32
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +5 -10
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +6 -5
- package/dist/Stepper/Step.js +8 -8
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
- package/dist/Text/TruncationTooltip.d.ts.map +1 -1
- package/dist/Text/TruncationTooltip.js +10 -1
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +31 -6
- package/dist/Token/Token.js +2 -2
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +1 -1
- package/dist/TreeList/TreeListItem.js +2 -2
- package/dist/gestures/GestureHost.d.ts +38 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +95 -1
- package/dist/gestures/contextRequest.d.ts +43 -0
- package/dist/gestures/contextRequest.d.ts.map +1 -0
- package/dist/gestures/contextRequest.js +167 -0
- package/dist/hooks/useClickableContainer.d.ts +1 -1
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +2 -2
- package/dist/hooks/useCommittedRef.d.ts +20 -0
- package/dist/hooks/useCommittedRef.d.ts.map +1 -0
- package/dist/hooks/useCommittedRef.js +38 -0
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +23 -27
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +2 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -1
- package/dist/internal/committed-ref.d.ts +15 -0
- package/dist/internal/committed-ref.d.ts.map +1 -0
- package/dist/internal/committed-ref.js +15 -0
- package/dist/internal/touch.d.ts +2 -1
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +1 -0
- package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
- package/dist/keyboard/keyboardHeight.js +13 -9
- package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
- package/dist/keyboard/useMobileKeyboard.js +8 -7
- package/dist/privateAttributes/press.stylex.d.ts +40 -10
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/press.stylex.js +46 -10
- package/locales/en.json +4 -0
- package/locales/pseudo.json +3 -0
- package/package.json +10 -5
- package/src/BottomSheet/BottomSheetPanel.tsx +5 -4
- package/src/CheckboxInput/CheckboxInput.tsx +20 -60
- package/src/Item/Item.tsx +2 -2
- package/src/Layer/useTouchTrigger.ts +30 -1
- package/src/Outline/useScrollSpy.ts +22 -22
- package/src/RadioList/RadioListItem.tsx +19 -79
- package/src/Resizable/ResizeHandle.tsx +5 -6
- package/src/Resizable/useResizable.ts +5 -5
- package/src/Stepper/Step.tsx +6 -6
- package/src/Stepper/Stepper.doc.mjs +8 -2
- package/src/Table/plugins/sortable/useTableSortableState.tsx +10 -4
- package/src/Text/TruncationTooltip.tsx +16 -1
- package/src/Toast/ToastViewport.tsx +31 -5
- package/src/Token/Token.tsx +2 -2
- package/src/Tooltip/useTooltip.tsx +1 -0
- package/src/TreeList/TreeListItem.tsx +2 -2
- package/src/gestures/GestureHost.ts +125 -1
- package/src/gestures/README.md +21 -0
- package/src/gestures/contextRequest.ts +206 -0
- package/src/hooks/useClickableContainer.ts +2 -2
- package/src/hooks/useCommittedRef.ts +39 -0
- package/src/hooks/useMenuPress.ts +59 -62
- package/src/i18n/generated-locales/en.generated.ts +1 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
- package/src/internal/committed-ref.ts +15 -0
- package/src/internal/touch.ts +3 -0
- package/src/keyboard/keyboardHeight.ts +15 -17
- package/src/keyboard/useMobileKeyboard.ts +8 -7
- package/src/privateAttributes/press.stylex.ts +109 -10
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { armClickGuard } from "../utils/clickGuard.js";
|
|
19
19
|
import { matchesMediaQuery } from "../utils/coarsePointer.js";
|
|
20
20
|
import { subscribeInput } from "../utils/inputStream.js";
|
|
21
|
-
import { isNode } from "../utils/nodeType.js";
|
|
21
|
+
import { isElement, isHTMLElement, isNode } from "../utils/nodeType.js";
|
|
22
22
|
import { layoutViewportHeight } from "../utils/layoutViewport.js";
|
|
23
23
|
import { PRESS_SLOP_PX } from "../utils/pressGesture.js";
|
|
24
24
|
import { caretAt } from "../utils/selectionLock.js";
|
|
@@ -251,21 +251,25 @@ export function getKeyboardHeight(win) {
|
|
|
251
251
|
* with `inputmode="none"` brings up none.
|
|
252
252
|
*/
|
|
253
253
|
export function isTextEntryControl(element) {
|
|
254
|
-
|
|
254
|
+
// Reads the kind by name, so an element of another window (a same-origin
|
|
255
|
+
// iframe, a Picture-in-Picture window) passes too.
|
|
256
|
+
if (!isHTMLElement(element) || element.getAttribute('inputmode') === 'none') {
|
|
255
257
|
return false;
|
|
256
258
|
}
|
|
257
|
-
if (element
|
|
258
|
-
|
|
259
|
+
if (element.localName === 'textarea') {
|
|
260
|
+
const textArea = element;
|
|
261
|
+
return !textArea.disabled && !textArea.readOnly;
|
|
259
262
|
}
|
|
260
|
-
if (element
|
|
261
|
-
|
|
263
|
+
if (element.localName === 'input') {
|
|
264
|
+
const input = element;
|
|
265
|
+
return !input.disabled && !input.readOnly && !NON_TEXT_INPUT_TYPES.has((input.getAttribute('type') ?? 'text').toLowerCase());
|
|
262
266
|
}
|
|
263
|
-
return element
|
|
267
|
+
return element.matches('[contenteditable]:not([contenteditable="false"])');
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
/** The text-entry control inside `container` that `target` is or labels. */
|
|
267
271
|
export function findTextEntryControl(target, container) {
|
|
268
|
-
if (!(target
|
|
272
|
+
if (!isElement(target)) {
|
|
269
273
|
return null;
|
|
270
274
|
}
|
|
271
275
|
const direct = target.closest('input, textarea, [contenteditable]:not([contenteditable="false"])');
|
|
@@ -273,7 +277,7 @@ export function findTextEntryControl(target, container) {
|
|
|
273
277
|
return direct;
|
|
274
278
|
}
|
|
275
279
|
const label = target.closest('label');
|
|
276
|
-
const control = label
|
|
280
|
+
const control = isHTMLElement(label) ? label.control : null;
|
|
277
281
|
return container.contains(control) && isTextEntryControl(control) ? control : null;
|
|
278
282
|
}
|
|
279
283
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMobileKeyboard.d.ts","sourceRoot":"","sources":["../../src/keyboard/useMobileKeyboard.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,EAA2C,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useMobileKeyboard.d.ts","sourceRoot":"","sources":["../../src/keyboard/useMobileKeyboard.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AAEH,OAAO,EAA2C,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAmC/E,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAW1B,uEAAuE;AACvE,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;CACvD;AAyBD,yDAAyD;AACzD,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACxC,EACE,IAAI,EACJ,KAAK,EAAE,aAAqB,EAC5B,MAAqB,EACrB,SAAgB,EAChB,UAAiB,EACjB,MAAa,EACb,kBAA0B,GAC3B,GAAE,qBAA0B,GAC5B,cAAc,CA42BhB"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
16
|
import { flushSync } from 'react-dom';
|
|
17
17
|
import { useAttachment } from "../hooks/useAttachment.js";
|
|
18
|
+
import { useCommittedRef } from "../hooks/useCommittedRef.js";
|
|
18
19
|
import { useMediaQuery } from "../hooks/useMediaQuery.js";
|
|
19
20
|
import { animatorFor } from "../motion/animator.js";
|
|
20
21
|
import { KEYBOARD_SPRING } from "../motion/uikit/springs.js";
|
|
@@ -113,12 +114,12 @@ export function useMobileKeyboard(targetRef, {
|
|
|
113
114
|
const [keyboardInset, setKeyboardInset] = useState(0);
|
|
114
115
|
const hasKeyboardLayoutRef = useRef(false);
|
|
115
116
|
const retainKeyboardLayoutRef = useRef(false);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
isEnabledRef
|
|
120
|
-
isExpandedRef
|
|
121
|
-
isOpenRef
|
|
117
|
+
// The committed options, which the listeners and the dismissal read. They
|
|
118
|
+
// are current before any layout effect, where an earlier sibling can move
|
|
119
|
+
// focus.
|
|
120
|
+
const isEnabledRef = useCommittedRef(isEnabled);
|
|
121
|
+
const isExpandedRef = useCommittedRef(isExpanded);
|
|
122
|
+
const isOpenRef = useCommittedRef(isOpen);
|
|
122
123
|
// Touch-only work, the ride and the reveal-pan watch, attaches only under a
|
|
123
124
|
// coarse primary pointer (the touch query). Under a fine one, the hook
|
|
124
125
|
// registers no touch listener.
|
|
@@ -140,7 +141,7 @@ export function useMobileKeyboard(targetRef, {
|
|
|
140
141
|
preventScroll: true
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
}, [targetRef]);
|
|
144
|
+
}, [isEnabledRef, targetRef]);
|
|
144
145
|
|
|
145
146
|
// Syncs the on-screen keyboard with closing: a target that closes blurs its
|
|
146
147
|
// focused field, which dismisses the keyboard.
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file privateAttributes/press.stylex.ts
|
|
3
3
|
* @input StyleX, the overlay color tokens, the touch press strength
|
|
4
|
-
* (`pressVars`)
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the hover tone, and `overDividers` for a row of a List with dividers. Also
|
|
9
|
-
* `controlPressLayerStyles`, what Button adds to that layer (`control`),
|
|
10
|
-
* and `rowPressPaintStyles`, a CheckboxList row's press paint for its box.
|
|
4
|
+
* (`pressVars`), the theme's exit motion tokens and the indicator scope
|
|
5
|
+
* marker
|
|
6
|
+
* @output Ready-made press styles for list rows, Button and the layer over a
|
|
7
|
+
* selection control's box. No package entry exports them.
|
|
11
8
|
* @position Owner module of the private press attribute: the press controller
|
|
12
|
-
* (utils/pressFeedback.ts) writes it, and this file reads it.
|
|
13
|
-
*
|
|
14
|
-
* compose its styles; utils/interactionOverlay.cell.test.ts tests the row layer.
|
|
9
|
+
* (utils/pressFeedback.ts) writes it, and this file reads it.
|
|
10
|
+
* utils/interactionOverlay.cell.test.ts tests the row layer.
|
|
15
11
|
*/
|
|
16
12
|
import * as stylex from '@stylexjs/stylex';
|
|
17
13
|
export declare const rowPressLayerStyles: Readonly<{
|
|
@@ -174,5 +170,39 @@ export declare const rowPressPaintStyles: Readonly<{
|
|
|
174
170
|
readonly checkboxRow: Readonly<{
|
|
175
171
|
readonly '--_checkbox-row-press-paint': stylex.StyleXClassNameFor<"--_checkbox-row-press-paint", "none" | "var(--_press-paint-image)">;
|
|
176
172
|
}>;
|
|
173
|
+
readonly radioRow: Readonly<{
|
|
174
|
+
readonly '--_radio-row-press': stylex.StyleXClassNameFor<"--_radio-row-press", "light-dark(#05365919, #FFFFFF19)" | "transparent" | null>;
|
|
175
|
+
}>;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Ready-made press paint for a selection control. `handDown` goes on
|
|
179
|
+
* CheckboxInput's row. `activeFill` and `image` go on the layer over the box
|
|
180
|
+
* or a RadioList option's circle. They read the press attribute off the
|
|
181
|
+
* indicator scope marker, as the hover tint does.
|
|
182
|
+
*/
|
|
183
|
+
export declare const indicatorPressPaintStyles: Readonly<{
|
|
184
|
+
readonly handDown: Readonly<{
|
|
185
|
+
readonly '--_indicator-press-image': stylex.StyleXClassNameFor<"--_indicator-press-image", unknown>;
|
|
186
|
+
readonly '--_indicator-active-press': stylex.StyleXClassNameFor<"--_indicator-active-press", unknown>;
|
|
187
|
+
}>;
|
|
188
|
+
readonly activeFill: Readonly<{
|
|
189
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
190
|
+
readonly backgroundColor: {
|
|
191
|
+
readonly [x: string]: "transparent" | {
|
|
192
|
+
readonly default: stylex.StyleXVar<"light-dark(#05365919, #FFFFFF19)">;
|
|
193
|
+
readonly "@media (pointer: coarse)": "transparent";
|
|
194
|
+
};
|
|
195
|
+
readonly default: "transparent";
|
|
196
|
+
};
|
|
197
|
+
}>;
|
|
198
|
+
}>;
|
|
199
|
+
readonly image: Readonly<{
|
|
200
|
+
readonly '::after': stylex.StyleXClassNameFor<"::after", {
|
|
201
|
+
readonly backgroundImage: {
|
|
202
|
+
readonly [x: string]: "var(--_press-paint-image)" | null;
|
|
203
|
+
readonly default: null;
|
|
204
|
+
};
|
|
205
|
+
}>;
|
|
206
|
+
}>;
|
|
177
207
|
}>;
|
|
178
208
|
//# sourceMappingURL=press.stylex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"press.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/press.stylex.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"press.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/press.stylex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AA2G3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuP9B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;EAiBlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;EAyB9B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;EAiDpC,CAAC"}
|
|
@@ -6,17 +6,13 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @file privateAttributes/press.stylex.ts
|
|
8
8
|
* @input StyleX, the overlay color tokens, the touch press strength
|
|
9
|
-
* (`pressVars`)
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the hover tone, and `overDividers` for a row of a List with dividers. Also
|
|
14
|
-
* `controlPressLayerStyles`, what Button adds to that layer (`control`),
|
|
15
|
-
* and `rowPressPaintStyles`, a CheckboxList row's press paint for its box.
|
|
9
|
+
* (`pressVars`), the theme's exit motion tokens and the indicator scope
|
|
10
|
+
* marker
|
|
11
|
+
* @output Ready-made press styles for list rows, Button and the layer over a
|
|
12
|
+
* selection control's box. No package entry exports them.
|
|
16
13
|
* @position Owner module of the private press attribute: the press controller
|
|
17
|
-
* (utils/pressFeedback.ts) writes it, and this file reads it.
|
|
18
|
-
*
|
|
19
|
-
* compose its styles; utils/interactionOverlay.cell.test.ts tests the row layer.
|
|
14
|
+
* (utils/pressFeedback.ts) writes it, and this file reads it.
|
|
15
|
+
* utils/interactionOverlay.cell.test.ts tests the row layer.
|
|
20
16
|
*/
|
|
21
17
|
|
|
22
18
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -26,6 +22,8 @@ import "../motion/reducedMotion.stylex.js";
|
|
|
26
22
|
import { reducedMotionFadeConsts } from "../motion/reducedMotion.stylex.js";
|
|
27
23
|
import "../utils/interactionOverlay.stylex.js";
|
|
28
24
|
import { pressVars } from "../utils/interactionOverlay.stylex.js";
|
|
25
|
+
import "../Indicator/indicator.markers.stylex.js";
|
|
26
|
+
import { indicatorScope } from "../Indicator/indicator.markers.stylex.js";
|
|
29
27
|
|
|
30
28
|
// The overlay's arm selectors (interactionOverlay.stylex.ts), restated here:
|
|
31
29
|
// StyleX resolves a style's keys within its own file.
|
|
@@ -39,6 +37,18 @@ const PRESSED_FADING = '[data-astryx-press="fading"]';
|
|
|
39
37
|
* row's own `::before` and its stacking are untouched.
|
|
40
38
|
*/
|
|
41
39
|
const PRESSED_ANY = ':is([data-astryx-press="on"],[data-astryx-press="fading"])';
|
|
40
|
+
/** The element is pressed, and the press controller does not paint the press. */
|
|
41
|
+
const ACTIVE_UNPAINTED = `:active:not(${PRESSED_ON},${PRESSED_FADING})`;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The nested controls that keep their own press, each at `:active`. It is
|
|
45
|
+
* INTERACTIVE_SELECTORS (hooks/useClickableContainer.ts), which StyleX cannot
|
|
46
|
+
* import, less the read-only ones. A RadioList row's own radio is the row's
|
|
47
|
+
* action, so its press is the row's. CSS cannot tell it from a nested radio
|
|
48
|
+
* input, so a nested one presses the circle too.
|
|
49
|
+
* RadioListItem.press.source-build.test.mjs keeps the two lists equal.
|
|
50
|
+
*/
|
|
51
|
+
const NESTED_CONTROL_ACTIVE = 'button:not([aria-readonly="true"]):active,' + 'a:not([aria-readonly="true"]):active,' + 'input:not([type="radio"],[aria-readonly="true"]):active,' + 'select:not([aria-readonly="true"]):active,' + 'textarea:not([aria-readonly="true"]):active,' + '[role="button"]:not([aria-readonly="true"]):active,' + '[role="link"]:not([aria-readonly="true"]):active,' + '[role="checkbox"]:not([aria-readonly="true"]):active,' + '[role="radio"]:not([aria-readonly="true"]):active,' + '[role="switch"]:not([aria-readonly="true"]):active,' + '[role="tab"]:not([aria-readonly="true"]):active,' + '[role="menuitem"]:not([aria-readonly="true"]):active,' + '[role="option"]:not([aria-readonly="true"]):active,' + '[role="combobox"]:not([aria-readonly="true"]):active,' + '[role="listbox"]:not([aria-readonly="true"]):active,' + '[role="slider"]:not([aria-readonly="true"]):active,' + '[role="spinbutton"]:not([aria-readonly="true"]):active,' + '[data-pressable-container]:not([aria-readonly="true"]):active';
|
|
42
52
|
const PRESS_ALPHA = pressVars['--astryx-press-alpha'];
|
|
43
53
|
const hoverImage = `linear-gradient(${colorVars['--color-overlay-hover']}, ${colorVars['--color-overlay-hover']})`;
|
|
44
54
|
const pressedImage = `linear-gradient(${colorVars['--color-overlay-pressed']}, ${colorVars['--color-overlay-pressed']})`;
|
|
@@ -133,5 +143,31 @@ export const rowPressPaintStyles = {
|
|
|
133
143
|
checkboxRow: {
|
|
134
144
|
"--_checkbox-row-press-paint": "x1ectg7s x1u7ooqu x1b9k41a",
|
|
135
145
|
$$css: true
|
|
146
|
+
},
|
|
147
|
+
radioRow: {
|
|
148
|
+
"--_radio-row-press": "x19rtxe xkwazwr",
|
|
149
|
+
$$css: true
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Ready-made press paint for a selection control. `handDown` goes on
|
|
155
|
+
* CheckboxInput's row. `activeFill` and `image` go on the layer over the box
|
|
156
|
+
* or a RadioList option's circle. They read the press attribute off the
|
|
157
|
+
* indicator scope marker, as the hover tint does.
|
|
158
|
+
*/
|
|
159
|
+
export const indicatorPressPaintStyles = {
|
|
160
|
+
handDown: {
|
|
161
|
+
"--_indicator-press-image": "x1dueop1 x189o2zt",
|
|
162
|
+
"--_indicator-active-press": "x1qwhovg x858ff1",
|
|
163
|
+
$$css: true
|
|
164
|
+
},
|
|
165
|
+
activeFill: {
|
|
166
|
+
ks3ayO: "xyhc2n1 xur6jaf xtawv5c",
|
|
167
|
+
$$css: true
|
|
168
|
+
},
|
|
169
|
+
image: {
|
|
170
|
+
kNctxI: "x178sc5r x1d4iov5",
|
|
171
|
+
$$css: true
|
|
136
172
|
}
|
|
137
173
|
};
|
package/locales/en.json
CHANGED
|
@@ -2570,5 +2570,9 @@
|
|
|
2570
2570
|
"@astryx.navigationStack.back": {
|
|
2571
2571
|
"defaultMessage": "Back",
|
|
2572
2572
|
"description": "Label of the back button in a lab NavigationStack's bar when the screen it returns to has no title of its own. Returns to the previous screen; keep it short, as on an iOS navigation bar."
|
|
2573
|
+
},
|
|
2574
|
+
"@astryx.searchField.cancel": {
|
|
2575
|
+
"defaultMessage": "Cancel",
|
|
2576
|
+
"description": "Accessible name of a lab SearchField's close button, which ends the search: it clears the query, ends editing and deactivates the field."
|
|
2573
2577
|
}
|
|
2574
2578
|
}
|
package/locales/pseudo.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.15
|
|
3
|
+
"version": "0.7.15",
|
|
4
4
|
"displayName": "Astryx Core",
|
|
5
5
|
"description": "The component library. Accessible, themeable React components with built-in spacing, dark mode, and StyleX styling.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -888,6 +888,11 @@
|
|
|
888
888
|
"source": "./src/internal/virtualization.ts",
|
|
889
889
|
"types": "./dist/internal/virtualization.d.ts",
|
|
890
890
|
"default": "./dist/internal/virtualization.js"
|
|
891
|
+
},
|
|
892
|
+
"./internal/committed-ref": {
|
|
893
|
+
"source": "./src/internal/committed-ref.ts",
|
|
894
|
+
"types": "./dist/internal/committed-ref.d.ts",
|
|
895
|
+
"default": "./dist/internal/committed-ref.js"
|
|
891
896
|
}
|
|
892
897
|
},
|
|
893
898
|
"files": [
|
|
@@ -920,9 +925,6 @@
|
|
|
920
925
|
"react-dom": ">=19.0.0"
|
|
921
926
|
},
|
|
922
927
|
"devDependencies": {
|
|
923
|
-
"@astryxdesign/a11y-spec": "0.7.15-canary.gf890983",
|
|
924
|
-
"@astryxdesign/cli": "0.7.15-canary.gf890983",
|
|
925
|
-
"@astryxdesign/interaction-harness": "0.7.15-canary.gf890983",
|
|
926
928
|
"@babel/cli": "^7.29.7",
|
|
927
929
|
"@babel/core": "^7.29.7",
|
|
928
930
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -934,7 +936,10 @@
|
|
|
934
936
|
"@testing-library/react": "^16.3.3",
|
|
935
937
|
"@types/babel__core": "^7.20.5",
|
|
936
938
|
"tailwindcss": "^4.3.2",
|
|
937
|
-
"temporal-polyfill": "^1.0.6"
|
|
939
|
+
"temporal-polyfill": "^1.0.6",
|
|
940
|
+
"@astryxdesign/cli": "0.7.15",
|
|
941
|
+
"@astryxdesign/interaction-harness": "0.0.0",
|
|
942
|
+
"@astryxdesign/a11y-spec": "0.0.0"
|
|
938
943
|
},
|
|
939
944
|
"dependencies": {
|
|
940
945
|
"intl-messageformat": "^11.2.9"
|
|
@@ -821,9 +821,9 @@ export function BottomSheetPanel({
|
|
|
821
821
|
|
|
822
822
|
// Everything derived from the snap points keys off their identity, not the
|
|
823
823
|
// array's: the resolver's identity is the hook's signal that the stops
|
|
824
|
-
// changed, so it must not churn on a re-render the drag caused. The
|
|
825
|
-
// reads the points through a ref, so
|
|
826
|
-
//
|
|
824
|
+
// changed, so it must not churn on a re-render the drag caused. The resolver
|
|
825
|
+
// reads the points through a ref, so it resolves them at call time —
|
|
826
|
+
// against whatever the viewport is then, not what it was at memo time.
|
|
827
827
|
const snapPointsKey = snapPointsKeyFor(snapPoints);
|
|
828
828
|
const snapPointsRef = useRef(snapPoints);
|
|
829
829
|
snapPointsRef.current = snapPoints;
|
|
@@ -831,7 +831,7 @@ export function BottomSheetPanel({
|
|
|
831
831
|
if (snapPointsKey === '') {
|
|
832
832
|
return {snapHeights: undefined, ignoredSnapPointsMessage: ''};
|
|
833
833
|
}
|
|
834
|
-
const ignored = (
|
|
834
|
+
const ignored = (snapPoints ?? []).filter(
|
|
835
835
|
point => !isValidSnapPoint(point),
|
|
836
836
|
);
|
|
837
837
|
return {
|
|
@@ -842,6 +842,7 @@ export function BottomSheetPanel({
|
|
|
842
842
|
? ''
|
|
843
843
|
: `snapPoints ignored ${JSON.stringify(ignored)}. A snap point is a viewport fraction above 0 and up to 1 (0.5 is half the screen), a px length ('320px'), or a percentage ('50%').`,
|
|
844
844
|
};
|
|
845
|
+
// eslint-disable-next-line @eslint-react/exhaustive-deps -- keyed by the snap points' identity, not the array's
|
|
845
846
|
}, [snapPointsKey]);
|
|
846
847
|
useDevWarning(
|
|
847
848
|
'BottomSheet',
|
|
@@ -62,6 +62,7 @@ import {themeProps} from '../utils/themeProps';
|
|
|
62
62
|
import {useMergedRefs} from '../hooks/useMergedRefs';
|
|
63
63
|
import {useTouchHitArea} from '../utils/touchHitArea';
|
|
64
64
|
import {pressBoxProps} from '../privateAttributes/pressBox.stylex';
|
|
65
|
+
import {indicatorPressPaintStyles} from '../privateAttributes/press.stylex';
|
|
65
66
|
import {registerBoxHold} from '../utils/boxHold';
|
|
66
67
|
import {touchHitAreaStyles} from '../internal/touchHitArea.stylex';
|
|
67
68
|
import {
|
|
@@ -76,19 +77,6 @@ registerEnglishFallback(english);
|
|
|
76
77
|
// none of its code.
|
|
77
78
|
registerBoxHold();
|
|
78
79
|
|
|
79
|
-
/** Written by the press controller while the row is pressed. */
|
|
80
|
-
const PRESSED_ON = '[data-astryx-press="on"]';
|
|
81
|
-
/** Written by the press controller for the press's release. */
|
|
82
|
-
const PRESSED_FADING = '[data-astryx-press="fading"]';
|
|
83
|
-
/** The row is pressed, and the press controller does not paint the press. */
|
|
84
|
-
const ACTIVE_UNPAINTED = `:active:not(${PRESSED_ON},${PRESSED_FADING})`;
|
|
85
|
-
|
|
86
|
-
// The touch press's paint, declared by the shared overlay styles on the
|
|
87
|
-
// element the controller writes to (`pressedAlpha`) at the press's strength,
|
|
88
|
-
// 1 while on and 1 → 0 over the release, and inherited resolved by the layer
|
|
89
|
-
// that paints it. See interactionOverlay.stylex.ts.
|
|
90
|
-
const pressedOverlayImage = 'var(--_press-paint-image)';
|
|
91
|
-
|
|
92
80
|
const styles = stylex.create({
|
|
93
81
|
container: {
|
|
94
82
|
display: 'flex',
|
|
@@ -102,27 +90,6 @@ const styles = stylex.create({
|
|
|
102
90
|
hitAreaHost: {
|
|
103
91
|
position: {default: null, '@media (pointer: coarse)': 'relative'},
|
|
104
92
|
},
|
|
105
|
-
// An indicator in another package may not name this row's private press
|
|
106
|
-
// attribute. So the row hands its touch press image down to an indicator
|
|
107
|
-
// that paints its own press, but only in its own press states. A pressed
|
|
108
|
-
// outer row hands down nothing, as for the built-in box. The
|
|
109
|
-
// property has no default: a layered stylesheet ranks a default above the
|
|
110
|
-
// arms. Only this row declares it. A menu item paints its own press, so a
|
|
111
|
-
// mapped indicator there paints none.
|
|
112
|
-
indicatorPressImage: {
|
|
113
|
-
'--_indicator-press-image': {
|
|
114
|
-
default: null,
|
|
115
|
-
[PRESSED_ON]: 'var(--_press-paint-image)',
|
|
116
|
-
[PRESSED_FADING]: 'var(--_press-paint-image)',
|
|
117
|
-
},
|
|
118
|
-
// While the controller paints the press, the indicator's `:active` fill
|
|
119
|
-
// stays off, so a mouse's press paints once.
|
|
120
|
-
'--_indicator-active-press': {
|
|
121
|
-
default: null,
|
|
122
|
-
[PRESSED_ON]: 'transparent',
|
|
123
|
-
[PRESSED_FADING]: 'transparent',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
93
|
// Under a row that owns the press (CheckboxRowPressContext), this row is
|
|
127
94
|
// never pressed. So it hands down that row's press paint, which the
|
|
128
95
|
// built-in box reads too.
|
|
@@ -143,12 +110,12 @@ const styles = stylex.create({
|
|
|
143
110
|
// replacement keeps the pressed feedback. An indicator with
|
|
144
111
|
// `indicatorPressScope` paints its own press from what the row hands down,
|
|
145
112
|
// so this layer stays off over it. The press controller writes the press
|
|
146
|
-
// attribute on the row for every pointer: a finger, a mouse and a pen.
|
|
147
|
-
// layer reads it off the scope marker,
|
|
148
|
-
// paints only a press the controller does
|
|
149
|
-
// pointer it is dropped. Under a row that owns
|
|
150
|
-
// (CheckboxRowPressContext), the row's own checkbox paints that
|
|
151
|
-
// paint instead (indicatorRowPressOverlay).
|
|
113
|
+
// attribute on the row for every pointer: a finger, a mouse and a pen. The
|
|
114
|
+
// layer's paint (`indicatorPressPaintStyles`) reads it off the scope marker,
|
|
115
|
+
// as the hover tint does. `:active` paints only a press the controller does
|
|
116
|
+
// not paint, and under a coarse pointer it is dropped. Under a row that owns
|
|
117
|
+
// the press (CheckboxRowPressContext), the row's own checkbox paints that
|
|
118
|
+
// row's press paint instead (indicatorRowPressOverlay).
|
|
152
119
|
indicatorPressOverlay: {
|
|
153
120
|
'::after': {
|
|
154
121
|
// `when.descendant` takes a pseudo-class; `:is(*)` matches any marked
|
|
@@ -161,24 +128,6 @@ const styles = stylex.create({
|
|
|
161
128
|
inset: 0,
|
|
162
129
|
borderRadius: radiusVars['--radius-inner'],
|
|
163
130
|
pointerEvents: 'none',
|
|
164
|
-
backgroundColor: {
|
|
165
|
-
default: 'transparent',
|
|
166
|
-
[stylex.when.ancestor(ACTIVE_UNPAINTED, indicatorScope)]: {
|
|
167
|
-
default: colorVars['--color-overlay-pressed'],
|
|
168
|
-
'@media (pointer: coarse)': 'transparent',
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
// The controller's press paints as an image layer over the colour. An
|
|
172
|
-
// image change is discrete, so no transition can delay the onset. Only
|
|
173
|
-
// the strength moves: the row's `pressedAlpha` arms set it to 1 while
|
|
174
|
-
// on, and 1 → 0 over the release. This holds for every pointer, because
|
|
175
|
-
// the controller writes the attribute only for a press it paints.
|
|
176
|
-
backgroundImage: {
|
|
177
|
-
default: null,
|
|
178
|
-
[stylex.when.ancestor(PRESSED_ON, indicatorScope)]: pressedOverlayImage,
|
|
179
|
-
[stylex.when.ancestor(PRESSED_FADING, indicatorScope)]:
|
|
180
|
-
pressedOverlayImage,
|
|
181
|
-
},
|
|
182
131
|
},
|
|
183
132
|
},
|
|
184
133
|
// The row's own checkbox when its row owns the press
|
|
@@ -565,10 +514,13 @@ export function CheckboxInput({
|
|
|
565
514
|
// Hover and focus reach the checkbox visual through this ancestor
|
|
566
515
|
// marker rather than props, so the whole row drives it.
|
|
567
516
|
!isDisabled && indicatorScope,
|
|
517
|
+
// An indicator in another package may not name the private press
|
|
518
|
+
// attribute. So the row hands its press image down to an indicator
|
|
519
|
+
// that paints its own press (`indicatorPressPaintStyles.handDown`).
|
|
568
520
|
!isDisabled &&
|
|
569
521
|
(isRowPressSurface
|
|
570
522
|
? styles.indicatorRowPressImage
|
|
571
|
-
:
|
|
523
|
+
: indicatorPressPaintStyles.handDown),
|
|
572
524
|
// The touch press's strength and release live on the row the
|
|
573
525
|
// controller writes to; the layer over the checkbox box inherits
|
|
574
526
|
// and paints it. Under a row that owns the press, the box inherits
|
|
@@ -584,7 +536,15 @@ export function CheckboxInput({
|
|
|
584
536
|
styles.checkboxWrapper,
|
|
585
537
|
wrapperSizeStyles[size],
|
|
586
538
|
!isDisabled && styles.indicatorPressOverlay,
|
|
587
|
-
|
|
539
|
+
// Under a row that owns the press, the row's own overlay paints
|
|
540
|
+
// instead of the owner's press paint.
|
|
541
|
+
!isDisabled &&
|
|
542
|
+
(isRowPressSurface
|
|
543
|
+
? styles.indicatorRowPressOverlay
|
|
544
|
+
: [
|
|
545
|
+
indicatorPressPaintStyles.activeFill,
|
|
546
|
+
indicatorPressPaintStyles.image,
|
|
547
|
+
]),
|
|
588
548
|
)}
|
|
589
549
|
{...focusProps}>
|
|
590
550
|
<input
|
package/src/Item/Item.tsx
CHANGED
|
@@ -63,7 +63,7 @@ import {useMergedRefs} from '../hooks/useMergedRefs';
|
|
|
63
63
|
import {computeTargetAndRel} from '../Link/computeTargetAndRel';
|
|
64
64
|
import {useLinkComponent} from '../Link/useLinkComponent';
|
|
65
65
|
import {
|
|
66
|
-
|
|
66
|
+
cancelNestedPress,
|
|
67
67
|
PRESSABLE_CONTAINER_ATTRIBUTE,
|
|
68
68
|
useClickableContainerProxy,
|
|
69
69
|
} from '../hooks/useClickableContainer';
|
|
@@ -717,7 +717,7 @@ export function Item({
|
|
|
717
717
|
const hasOwnAction =
|
|
718
718
|
(onClick != null || href != null) && !hasParentRole && !isLinkRoot;
|
|
719
719
|
const pressOnRow = (event: React.PointerEvent<HTMLElement>) =>
|
|
720
|
-
|
|
720
|
+
cancelNestedPress(
|
|
721
721
|
event,
|
|
722
722
|
event.currentTarget,
|
|
723
723
|
href != null ? actionLinkRef.current : actionButtonRef.current,
|
|
@@ -61,6 +61,8 @@ import {
|
|
|
61
61
|
matchesInteractiveSelectors,
|
|
62
62
|
} from '../hooks/useClickableContainer';
|
|
63
63
|
import {isDisabledControl} from '../utils/pressDisabled';
|
|
64
|
+
import {isElement, isHTMLElement} from '../utils/nodeType';
|
|
65
|
+
import {findTextEntryControl} from '../keyboard/keyboardHeight';
|
|
64
66
|
import {
|
|
65
67
|
isTextEntrySincePointer,
|
|
66
68
|
useInteractionModalityTrackingFor,
|
|
@@ -100,6 +102,11 @@ export interface TapRecognizer {
|
|
|
100
102
|
): boolean;
|
|
101
103
|
/** Stops waiting for a press still waiting for its tap. */
|
|
102
104
|
forget(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Whether a touch or pen press still waits for its tap, with no key press
|
|
107
|
+
* or new press since. A focus at that time is the press's own focus.
|
|
108
|
+
*/
|
|
109
|
+
isTouchPressCurrent(): boolean;
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
/** One tap recognizer for a trigger, released on unmount. Internal. */
|
|
@@ -112,6 +119,7 @@ export function useTapRecognizer(): TapRecognizer {
|
|
|
112
119
|
|
|
113
120
|
function createTapRecognizer(): TapRecognizer {
|
|
114
121
|
let stopWaiting: (() => void) | null = null;
|
|
122
|
+
let waitingGesture: number | null = null;
|
|
115
123
|
const forget = () => {
|
|
116
124
|
stopWaiting?.();
|
|
117
125
|
stopWaiting = null;
|
|
@@ -129,6 +137,7 @@ function createTapRecognizer(): TapRecognizer {
|
|
|
129
137
|
// advances the gesture, so a keyboard activation that later fires
|
|
130
138
|
// `click` on the trigger (Enter on a button) is not mistaken for it.
|
|
131
139
|
const gesture = currentGesture();
|
|
140
|
+
waitingGesture = gesture;
|
|
132
141
|
const stop = () => {
|
|
133
142
|
trigger.removeEventListener('click', handleTap);
|
|
134
143
|
trigger.removeEventListener('pointercancel', stop);
|
|
@@ -148,6 +157,8 @@ function createTapRecognizer(): TapRecognizer {
|
|
|
148
157
|
return true;
|
|
149
158
|
},
|
|
150
159
|
forget,
|
|
160
|
+
isTouchPressCurrent: () =>
|
|
161
|
+
stopWaiting != null && waitingGesture === currentGesture(),
|
|
151
162
|
};
|
|
152
163
|
}
|
|
153
164
|
|
|
@@ -420,6 +431,12 @@ export function useTouchTriggerInternal(
|
|
|
420
431
|
* ends a hold that the press started.
|
|
421
432
|
*/
|
|
422
433
|
onReleaseInLayer?: () => void,
|
|
434
|
+
/**
|
|
435
|
+
* Whether a tap on a text-entry control inside the trigger only focuses
|
|
436
|
+
* that control, so no tooltip covers text the person starts to type. Only
|
|
437
|
+
* useTooltip passes it.
|
|
438
|
+
*/
|
|
439
|
+
isTextEntryTapIgnored = false,
|
|
423
440
|
): UseTouchTriggerInternalReturn {
|
|
424
441
|
const {
|
|
425
442
|
touchTrigger,
|
|
@@ -548,9 +565,21 @@ export function useTouchTriggerInternal(
|
|
|
548
565
|
const answerTapRef = useRef<(tapEvent: Event | null) => void>(() => {});
|
|
549
566
|
answerTapRef.current = (tapEvent: Event | null) => {
|
|
550
567
|
const trigger = triggerRef.current;
|
|
568
|
+
const tapped = isElement(tapEvent?.target) ? tapEvent.target : null;
|
|
569
|
+
// A disabled field keeps its reason's tap, and a trigger that is itself
|
|
570
|
+
// a field keeps its own tap.
|
|
571
|
+
if (isTextEntryTapIgnored && tapped != null && isHTMLElement(trigger)) {
|
|
572
|
+
const field = findTextEntryControl(tapped, trigger);
|
|
573
|
+
if (
|
|
574
|
+
field != null &&
|
|
575
|
+
field !== trigger &&
|
|
576
|
+
!tapLandsOnDisabledControl(tapped)
|
|
577
|
+
) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
551
581
|
// A tap that landed in a disabled control is that control's: its reason
|
|
552
582
|
// opens. Every other tap is the trigger's to decide.
|
|
553
|
-
const tapped = tapEvent?.target instanceof Element ? tapEvent.target : null;
|
|
554
583
|
const mode =
|
|
555
584
|
touchTrigger === 'auto'
|
|
556
585
|
? tapped != null && tapLandsOnDisabledControl(tapped)
|