@astryxdesign/core 0.7.14 → 0.7.15-canary.g79b95eb
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/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +11 -2
- package/dist/Calendar/getInitialFocusDate.d.ts +8 -3
- package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -1
- package/dist/Calendar/getInitialFocusDate.js +42 -7
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +9 -4
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +3 -8
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +3 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +6 -3
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +23 -9
- package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeTimeSegment.js +22 -8
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +7 -5
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -1
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +5 -1
- package/dist/Item/Item.d.ts +1 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +4 -2
- package/dist/Link/useLinkify.d.ts.map +1 -1
- package/dist/Link/useLinkify.js +3 -2
- package/dist/List/List.d.ts +4 -1
- package/dist/List/List.d.ts.map +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +8 -0
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +19 -4
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +43 -15
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +108 -18
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedTouchTracking.js +5 -0
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +7 -3
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +2 -0
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +85 -12
- package/dist/astryx.css +11 -10
- package/dist/gestures/GestureHost.d.ts +5 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +54 -28
- package/dist/hooks/menuPressGesture.d.ts +39 -2
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +92 -5
- package/dist/hooks/scrollOwnerRegistry.d.ts +0 -1
- package/dist/hooks/scrollOwnerRegistry.d.ts.map +1 -1
- package/dist/hooks/scrollOwnerRegistry.js +4 -1
- package/dist/hooks/useClickableContainer.d.ts +6 -4
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +11 -8
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +6 -0
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +35 -2
- package/dist/hooks/useStreamingText.d.ts.map +1 -1
- package/dist/hooks/useStreamingText.js +38 -23
- package/dist/i18n/generated-english/DateInput/useTypedDate.generated.js +2 -2
- package/dist/i18n/generated-locales/en.generated.js +2 -2
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -2
- package/dist/motion/uikit/segmented.d.ts +35 -7
- package/dist/motion/uikit/segmented.d.ts.map +1 -1
- package/dist/motion/uikit/segmented.js +39 -11
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/press.stylex.js +1 -1
- package/dist/privateAttributes/pressBox.stylex.d.ts +12 -4
- package/dist/privateAttributes/pressBox.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/pressBox.stylex.js +21 -4
- package/dist/privateAttributes/tokenRemove.stylex.d.ts +5 -0
- package/dist/privateAttributes/tokenRemove.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/tokenRemove.stylex.js +25 -0
- package/dist/theme/defineTheme.d.ts +0 -1
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/utils/inputAge.d.ts +5 -2
- package/dist/utils/inputAge.d.ts.map +1 -1
- package/dist/utils/inputAge.js +4 -1
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +60 -9
- package/locales/en.json +3 -3
- package/locales/pseudo.json +2 -2
- package/package.json +5 -5
- package/src/Calendar/Calendar.tsx +11 -1
- package/src/Calendar/getInitialFocusDate.ts +70 -8
- package/src/CheckboxInput/CheckboxInput.doc.mjs +16 -2
- package/src/CheckboxInput/CheckboxInput.tsx +32 -23
- package/src/CheckboxList/CheckboxList.doc.mjs +1 -1
- package/src/CheckboxList/CheckboxListItem.tsx +3 -6
- package/src/DateInput/useTypedDate.ts +9 -6
- package/src/DateTimeInput/DateTimeInput.tsx +7 -3
- package/src/DateTimeInput/NativeDateSegment.tsx +28 -10
- package/src/DateTimeInput/NativeTimeSegment.tsx +19 -9
- package/src/Drawer/Drawer.tsx +7 -5
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +3 -0
- package/src/Item/Item.doc.mjs +2 -1
- package/src/Item/Item.tsx +7 -3
- package/src/Link/useLinkify.tsx +7 -9
- package/src/List/List.doc.mjs +9 -21
- package/src/List/List.tsx +4 -1
- package/src/List/ListItem.doc.mjs +4 -2
- package/src/Markdown/Markdown.tsx +7 -0
- package/src/RadioList/RadioListItem.tsx +60 -30
- package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +115 -19
- package/src/SegmentedControl/useSegmentedTouchTracking.ts +5 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +5 -1
- package/src/Token/Token.tsx +2 -0
- package/src/Tokenizer/Tokenizer.tsx +102 -7
- package/src/gestures/GestureHost.ts +62 -32
- package/src/hooks/menuPressGesture.ts +116 -9
- package/src/hooks/scrollOwnerRegistry.ts +8 -1
- package/src/hooks/useClickableContainer.ts +11 -8
- package/src/hooks/useFocusTrap.ts +6 -0
- package/src/hooks/useMenuPress.ts +32 -2
- package/src/hooks/useStreamingText.ts +30 -25
- package/src/i18n/generated-english/DateInput/useTypedDate.generated.ts +2 -2
- package/src/i18n/generated-locales/en.generated.ts +2 -2
- package/src/i18n/generated-locales/pseudo.generated.ts +2 -2
- package/src/motion/MEASUREMENTS.md +2 -3
- package/src/motion/uikit/segmented.ts +35 -10
- package/src/privateAttributes/press.stylex.ts +2 -8
- package/src/privateAttributes/pressBox.stylex.ts +23 -4
- package/src/privateAttributes/tokenRemove.stylex.ts +27 -0
- package/src/theme/defineTheme.ts +0 -1
- package/src/theme/useThemeName.doc.mjs +69 -0
- package/src/utils/inputAge.ts +5 -2
- package/src/utils/pressFeedback.ts +80 -9
|
@@ -35,6 +35,7 @@ export const MENU_PRESS_HANDOFF_PX = UIKIT_MENU_PRESS_HANDOFF_PX;
|
|
|
35
35
|
|
|
36
36
|
/** @internal */
|
|
37
37
|
|
|
38
|
+
// The idle gesture: both the released and the internal shape.
|
|
38
39
|
export const IDLE_MENU_PRESS = {
|
|
39
40
|
phase: 'idle'
|
|
40
41
|
};
|
|
@@ -139,6 +140,67 @@ export function menuPressTransition(gesture, event) {
|
|
|
139
140
|
return stepOpen(gesture, event);
|
|
140
141
|
case 'tracking':
|
|
141
142
|
return stepTracking(gesture, event);
|
|
143
|
+
case 'withdrawn':
|
|
144
|
+
return stepWithdrawn(gesture, event);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A finger's or pen's gesture withdrawn by the window's blur, or a mouse's
|
|
150
|
+
* ended as a cancel, which keeps its click.
|
|
151
|
+
*/
|
|
152
|
+
function withdraw(pointerType, litRow, fromTrigger = false) {
|
|
153
|
+
if (!isFinger(pointerType)) {
|
|
154
|
+
return idle({
|
|
155
|
+
type: 'settle',
|
|
156
|
+
stray: false,
|
|
157
|
+
dismiss: false
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
gesture: fromTrigger ? {
|
|
162
|
+
phase: 'withdrawn',
|
|
163
|
+
pointerType,
|
|
164
|
+
fromTrigger: true
|
|
165
|
+
} : {
|
|
166
|
+
phase: 'withdrawn',
|
|
167
|
+
pointerType
|
|
168
|
+
},
|
|
169
|
+
effect: litRow != null ? {
|
|
170
|
+
type: 'withdraw',
|
|
171
|
+
clear: true
|
|
172
|
+
} : {
|
|
173
|
+
type: 'withdraw'
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function stepWithdrawn(gesture, event) {
|
|
178
|
+
switch (event.type) {
|
|
179
|
+
case 'up':
|
|
180
|
+
// The withdrawn finger lifts: nothing acts, and the click the browser
|
|
181
|
+
// reports for it is still this gesture's, so it is swallowed. Its
|
|
182
|
+
// listeners come off as the gesture ends. A tap on the trigger keeps
|
|
183
|
+
// its click, which opens the menu: the pointer model's open, or a
|
|
184
|
+
// scroll view's open at the lift.
|
|
185
|
+
return idle({
|
|
186
|
+
type: 'settle',
|
|
187
|
+
stray: gesture.fromTrigger !== true,
|
|
188
|
+
dismiss: false
|
|
189
|
+
});
|
|
190
|
+
case 'cancel':
|
|
191
|
+
return idle({
|
|
192
|
+
type: 'settle',
|
|
193
|
+
stray: false,
|
|
194
|
+
dismiss: false
|
|
195
|
+
});
|
|
196
|
+
case 'down':
|
|
197
|
+
case 'move':
|
|
198
|
+
case 'opened':
|
|
199
|
+
case 'withdraw':
|
|
200
|
+
return {
|
|
201
|
+
gesture,
|
|
202
|
+
effect: NONE
|
|
203
|
+
};
|
|
142
204
|
}
|
|
143
205
|
}
|
|
144
206
|
function stepIdle(gesture, event) {
|
|
@@ -209,6 +271,8 @@ function stepTriggerPress(gesture, event) {
|
|
|
209
271
|
stray: false,
|
|
210
272
|
dismiss: false
|
|
211
273
|
});
|
|
274
|
+
case 'withdraw':
|
|
275
|
+
return withdraw(gesture.pointerType, null, true);
|
|
212
276
|
case 'down':
|
|
213
277
|
case 'move':
|
|
214
278
|
return {
|
|
@@ -302,6 +366,8 @@ function stepOpen(gesture, event) {
|
|
|
302
366
|
stray: false,
|
|
303
367
|
dismiss: false
|
|
304
368
|
});
|
|
369
|
+
case 'withdraw':
|
|
370
|
+
return withdraw(gesture.pointerType, null);
|
|
305
371
|
case 'down':
|
|
306
372
|
case 'opened':
|
|
307
373
|
return {
|
|
@@ -330,12 +396,19 @@ function stepTracking(gesture, event) {
|
|
|
330
396
|
return release(gesture.pointerType, event);
|
|
331
397
|
case 'cancel':
|
|
332
398
|
// The browser took the gesture (a scroll, a second finger): nothing
|
|
333
|
-
// acts, the menu stays, and no click follows a cancelled pointer.
|
|
399
|
+
// acts, the menu stays, and no click follows a cancelled pointer. A
|
|
400
|
+
// row a finger lit loses its highlight, as UIKit clears it when the
|
|
401
|
+
// list starts scrolling. A mouse's highlight stays where it was.
|
|
334
402
|
return idle({
|
|
335
403
|
type: 'settle',
|
|
336
404
|
stray: false,
|
|
337
|
-
dismiss: false
|
|
405
|
+
dismiss: false,
|
|
406
|
+
...(gesture.row != null && isFinger(gesture.pointerType) ? {
|
|
407
|
+
clear: true
|
|
408
|
+
} : {})
|
|
338
409
|
});
|
|
410
|
+
case 'withdraw':
|
|
411
|
+
return withdraw(gesture.pointerType, gesture.row);
|
|
339
412
|
case 'down':
|
|
340
413
|
case 'opened':
|
|
341
414
|
return {
|
|
@@ -348,8 +421,8 @@ function stepTracking(gesture, event) {
|
|
|
348
421
|
// ---------------------------------------------------------------------------
|
|
349
422
|
// The released public shape (`@astryxdesign/core/hooks`). The machine's own
|
|
350
423
|
// types above carry the finger's handoff and are not public contract. The
|
|
351
|
-
// handoff positions and `
|
|
352
|
-
// `menuPressStep` keeps the settle rule, as released.
|
|
424
|
+
// handoff positions, `handoffFrom` and the settle `clear` stay internal: a
|
|
425
|
+
// caller of `menuPressStep` keeps the settle rule, as released.
|
|
353
426
|
// ---------------------------------------------------------------------------
|
|
354
427
|
|
|
355
428
|
/**
|
|
@@ -370,10 +443,24 @@ export function menuPressStep(gesture, event) {
|
|
|
370
443
|
} = menuPressTransition(gesture, released);
|
|
371
444
|
return {
|
|
372
445
|
gesture: publicGesture(next),
|
|
373
|
-
effect
|
|
446
|
+
effect: effect.type === 'settle' ? {
|
|
447
|
+
type: 'settle',
|
|
448
|
+
stray: effect.stray,
|
|
449
|
+
dismiss: effect.dismiss
|
|
450
|
+
} : effect.type === 'withdraw' ?
|
|
451
|
+
// Unreachable from the released events, which carry no `withdraw`.
|
|
452
|
+
{
|
|
453
|
+
type: 'none'
|
|
454
|
+
} : effect
|
|
374
455
|
};
|
|
375
456
|
}
|
|
376
457
|
function publicGesture(gesture) {
|
|
458
|
+
if (gesture.phase === 'withdrawn') {
|
|
459
|
+
// Unreachable from the released events, which carry no `withdraw`.
|
|
460
|
+
return {
|
|
461
|
+
phase: 'idle'
|
|
462
|
+
};
|
|
463
|
+
}
|
|
377
464
|
if (gesture.phase !== 'open') {
|
|
378
465
|
return gesture;
|
|
379
466
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollOwnerRegistry.d.ts","sourceRoot":"","sources":["../../src/hooks/scrollOwnerRegistry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scrollOwnerRegistry.d.ts","sourceRoot":"","sources":["../../src/hooks/scrollOwnerRegistry.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,yBAAyB,CAAC;IAClC,KAAK,EAAE,yBAAyB,CAAC;CAClC;AASD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,0BAA0B,GAChC,IAAI,CAEN;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAEhE;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,GACnB,0BAA0B,GAAG,SAAS,CAExC;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,GACvB,WAAW,GAAG,IAAI,CASpB"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
/** Private DOM registry used by future axis-aware Sticky consumers. */
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { sharedWeakMap } from "../utils/sharedRealm.js";
|
|
6
|
+
// Every copy of Core uses this one map. A copied AppShell then sees the
|
|
7
|
+
// scroll regions that package components register, and the reverse.
|
|
8
|
+
const owners = sharedWeakMap('hooks/scroll-owner-registry/owners', 1);
|
|
6
9
|
export function registerScrollOwner(element, state) {
|
|
7
10
|
owners.set(element, state);
|
|
8
11
|
}
|
|
@@ -61,10 +61,12 @@ export declare function innermostInteractive(el: Element, rootEl: Element | null
|
|
|
61
61
|
*/
|
|
62
62
|
export declare function hasInteractiveAncestor(el: Element, rootEl: Element): boolean;
|
|
63
63
|
/**
|
|
64
|
-
* The
|
|
65
|
-
* other than the container's own action does not activate
|
|
66
|
-
* it ends the press controller's paint on `container`.
|
|
67
|
-
*
|
|
64
|
+
* The press half of a container's press rule. A press that starts on a nested
|
|
65
|
+
* interactive element other than the container's own action does not activate
|
|
66
|
+
* the container. So it ends the press controller's paint on `container`. The
|
|
67
|
+
* rule covers a finger's press on every container. On a container that owns a
|
|
68
|
+
* control's box (pressBox.stylex.ts), it covers a mouse's and a pen's press
|
|
69
|
+
* too. A press on the container's surface or on `ownAction` is left alone.
|
|
68
70
|
* Not part of the package's public API.
|
|
69
71
|
*/
|
|
70
72
|
export declare function cancelNestedTouchPress(event: PointerEvent<HTMLElement>, container: HTMLElement | null, ownAction: Element | null): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickableContainer.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickableContainer.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useClickableContainer.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickableContainer.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAMf;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAmBvB,CAAC;AAIZ;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAKrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,aAAa,GAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAqC,GACzE,OAAO,GAAG,IAAI,CAShB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAE5E;AASD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,Y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import { useCallback, useEffect } from 'react';
|
|
|
21
21
|
import { isLayerSurface } from "../Layer/layerSurfacePress.js";
|
|
22
22
|
import { isSafeUrl } from "../utils/safeUrl.js";
|
|
23
23
|
import { cancelPress } from "../utils/pressFeedback.js";
|
|
24
|
+
import { pressBoxesIn } from "../privateAttributes/pressBox.stylex.js";
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* The attribute this hook sets on the container it makes clickable. A click
|
|
@@ -95,15 +96,17 @@ function belongsToSomethingElse(element) {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
* The
|
|
99
|
-
* other than the container's own action does not activate
|
|
100
|
-
* it ends the press controller's paint on `container`.
|
|
101
|
-
*
|
|
99
|
+
* The press half of a container's press rule. A press that starts on a nested
|
|
100
|
+
* interactive element other than the container's own action does not activate
|
|
101
|
+
* the container. So it ends the press controller's paint on `container`. The
|
|
102
|
+
* rule covers a finger's press on every container. On a container that owns a
|
|
103
|
+
* control's box (pressBox.stylex.ts), it covers a mouse's and a pen's press
|
|
104
|
+
* too. A press on the container's surface or on `ownAction` is left alone.
|
|
102
105
|
* Not part of the package's public API.
|
|
103
106
|
*/
|
|
104
107
|
export function cancelNestedTouchPress(event, container, ownAction) {
|
|
105
108
|
const target = event.target;
|
|
106
|
-
if (event.pointerType !== 'touch'
|
|
109
|
+
if (container == null || event.pointerType !== 'touch' && pressBoxesIn(container).length === 0 || !(target instanceof Element) || target === event.currentTarget || !hasInteractiveAncestor(target, container) ||
|
|
107
110
|
// The container's own action, such as the control it delegates to: a
|
|
108
111
|
// press on it activates the container.
|
|
109
112
|
ownAction?.contains(target) === true) {
|
|
@@ -265,9 +268,9 @@ export function useClickableContainerProxy({
|
|
|
265
268
|
}
|
|
266
269
|
}, [containerRef, href, disabled]);
|
|
267
270
|
|
|
268
|
-
// The press-state counterpart of onClick's rule
|
|
269
|
-
//
|
|
270
|
-
// pen
|
|
271
|
+
// The press-state counterpart of onClick's rule: a press that would not
|
|
272
|
+
// activate the container shows no press on it. That holds for a finger on
|
|
273
|
+
// every container, and for a mouse or a pen on one that owns a control's box.
|
|
271
274
|
const onPointerDown = useCallback(event => {
|
|
272
275
|
if (disabled) {
|
|
273
276
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"AAoCA;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAY7E;AAwDD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,EAAE,CAI1E;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,WAAW,EAAE,CAgBf;AAwGD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACjD,QAAQ,EAAE,OAAO,GAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"AAoCA;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAY7E;AAwDD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,WAAW,GAAG,WAAW,EAAE,CAI1E;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,OAAO,GAAG,IAAI,GACrB,WAAW,EAAE,CAgBf;AAwGD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACjD,QAAQ,EAAE,OAAO,GAChB,IAAI,CA2LN;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IACrE;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAExC;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC9D,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAAC,CAAC,CAAC,CAEvB;AAED;;GAEG;AACH,UAAU,wBAAyB,SAAQ,mBAAmB;IAC5D;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC5C;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC9C;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACjD;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACtE,OAAO,EAAE,wBAAwB,GAChC,kBAAkB,CAAC,CAAC,CAAC,CAsJvB"}
|
|
@@ -347,6 +347,12 @@ export function useFocusRegionContainment(containerRef, isActive) {
|
|
|
347
347
|
return;
|
|
348
348
|
}
|
|
349
349
|
if (event.key === 'Tab') {
|
|
350
|
+
if (event.ctrlKey || event.metaKey) {
|
|
351
|
+
// Ctrl+Tab and Meta+Tab switch tabs or apps. They do not move
|
|
352
|
+
// focus, so the region leaves them to the browser and the page.
|
|
353
|
+
// Alt+Tab stays: Safari moves focus to each item on Option+Tab.
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
350
356
|
if (event.defaultPrevented) {
|
|
351
357
|
// A control that handles Tab itself (an editor that indents) keeps
|
|
352
358
|
// focus where it is.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuPress.d.ts","sourceRoot":"","sources":["../../src/hooks/useMenuPress.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAML,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAyBpD,OAAO,EAAC,iBAAiB,EAAC,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,mCAAmC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,MAAwB,CAAC;AAC/D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,MAAyB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AA+C9C,oFAAoF;AACpF,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAUhD;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,4DAA4D;AAC5D,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,uEAAuE;IACvE,UAAU,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC3C;;;OAGG;IACH,YAAY,EAAE,MAAM,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ur withdrew a finger's gesture. It stays tracked to
|
|
444
|
+
// its release, but nothing drives the menu any more (the hold, the
|
|
445
|
+
// autoscroll, the page lock). A row a finger lit clears.
|
|
446
|
+
longPressApiRef.current?.cancel();
|
|
447
|
+
stopAutoscroll();
|
|
448
|
+
touchMovePreventerRef.current?.();
|
|
449
|
+
touchMovePreventerRef.current = null;
|
|
450
|
+
if (effect.clear === true) {
|
|
451
|
+
highlight(null);
|
|
452
|
+
}
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
441
455
|
case 'settle':
|
|
442
456
|
{
|
|
457
|
+
// A finger's lit row clears on a cancel, on every surface. The
|
|
458
|
+
// machine sets `clear` only for a finger or pen, so a mouse keeps its
|
|
459
|
+
// highlight.
|
|
460
|
+
if (effect.clear === true) {
|
|
461
|
+
highlight(null);
|
|
462
|
+
}
|
|
443
463
|
endGesture();
|
|
444
464
|
if (effect.stray) {
|
|
445
465
|
armClickGuard(doc, {
|
|
@@ -453,7 +473,7 @@ export function useMenuPress(input) {
|
|
|
453
473
|
return;
|
|
454
474
|
}
|
|
455
475
|
}
|
|
456
|
-
}, [activate, endGesture, getDocument, highlight]);
|
|
476
|
+
}, [activate, endGesture, getDocument, highlight, stopAutoscroll]);
|
|
457
477
|
const step = useCallback((event, native) => {
|
|
458
478
|
const result = menuPressTransition(gestureRef.current, event);
|
|
459
479
|
gestureRef.current = result.gesture;
|
|
@@ -580,6 +600,14 @@ export function useMenuPress(input) {
|
|
|
580
600
|
});
|
|
581
601
|
};
|
|
582
602
|
const onOtherPointerDown = event => {
|
|
603
|
+
// Any press ends a withdrawn gesture: its finger lifted where the
|
|
604
|
+
// page could not see it, and the new press's click must act.
|
|
605
|
+
if (gestureRef.current.phase === 'withdrawn') {
|
|
606
|
+
stepRef.current({
|
|
607
|
+
type: 'cancel'
|
|
608
|
+
});
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
583
611
|
// A second pointer ends the gesture: two fingers are a pinch or a
|
|
584
612
|
// scroll, never a pick.
|
|
585
613
|
if (event.pointerId !== pointerIdRef.current) {
|
|
@@ -590,8 +618,13 @@ export function useMenuPress(input) {
|
|
|
590
618
|
}
|
|
591
619
|
};
|
|
592
620
|
const onBlur = () => {
|
|
621
|
+
// A finger's or pen's gesture is withdrawn, not ended. The browser can
|
|
622
|
+
// keep the touch alive past the blur, so the gesture stays tracked on
|
|
623
|
+
// these listeners until its release. That release acts on nothing, and
|
|
624
|
+
// its click is swallowed. A mouse press ends as a cancel and keeps its
|
|
625
|
+
// click.
|
|
593
626
|
stepRef.current({
|
|
594
|
-
type: '
|
|
627
|
+
type: 'withdraw'
|
|
595
628
|
});
|
|
596
629
|
};
|
|
597
630
|
doc.addEventListener('pointermove', onMove, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamingText.d.ts","sourceRoot":"","sources":["../../src/hooks/useStreamingText.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAuCD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAU3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"useStreamingText.d.ts","sourceRoot":"","sources":["../../src/hooks/useStreamingText.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAuCD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAU3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,CAkGR"}
|
|
@@ -129,28 +129,39 @@ export function useStreamingText(targetText, isStreaming, options) {
|
|
|
129
129
|
const tick = speed === 'fast' ? base / 20 : base / 10;
|
|
130
130
|
return Math.max(4, Math.round(tick));
|
|
131
131
|
}, [token, speed]);
|
|
132
|
-
|
|
132
|
+
|
|
133
|
+
// Where the reveal restarts: at 0 on a clear (a new message), at the whole
|
|
134
|
+
// text on a stream's end. Adjusted during render, and only then, never per
|
|
135
|
+
// chunk. State, not refs: a render React discards takes its adjustment with
|
|
136
|
+
// it. The frame clock alone advances `revealed`, which counts only within
|
|
137
|
+
// its restart's epoch.
|
|
138
|
+
const [restart, setRestart] = useState({
|
|
139
|
+
epoch: 0,
|
|
140
|
+
len: 0
|
|
141
|
+
});
|
|
142
|
+
const [revealed, setRevealed] = useState({
|
|
143
|
+
epoch: 0,
|
|
144
|
+
len: 0
|
|
145
|
+
});
|
|
146
|
+
const displayedLen = revealed.epoch === restart.epoch ? revealed.len : restart.len;
|
|
133
147
|
const targetRef = useRef(targetText);
|
|
134
|
-
const displayedLenRef = useRef(0);
|
|
135
148
|
const lastTickRef = useRef(0);
|
|
136
149
|
const rafRef = useRef(null);
|
|
137
150
|
targetRef.current = targetText;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (targetText.length === 0 && displayedLen !== 0) {
|
|
144
|
-
displayedLenRef.current = 0;
|
|
145
|
-
setDisplayedLen(0);
|
|
146
|
-
}
|
|
151
|
+
if (targetText.length === 0 && displayedLen !== 0) {
|
|
152
|
+
setRestart(previous => ({
|
|
153
|
+
epoch: previous.epoch + 1,
|
|
154
|
+
len: 0
|
|
155
|
+
}));
|
|
147
156
|
}
|
|
148
|
-
const
|
|
149
|
-
if (isStreaming !==
|
|
150
|
-
|
|
157
|
+
const [wasStreaming, setWasStreaming] = useState(isStreaming);
|
|
158
|
+
if (isStreaming !== wasStreaming) {
|
|
159
|
+
setWasStreaming(isStreaming);
|
|
151
160
|
if (!isStreaming && targetText.length > 0) {
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
setRestart(previous => ({
|
|
162
|
+
epoch: previous.epoch + 1,
|
|
163
|
+
len: targetText.length
|
|
164
|
+
}));
|
|
154
165
|
}
|
|
155
166
|
}
|
|
156
167
|
|
|
@@ -169,12 +180,16 @@ export function useStreamingText(targetText, isStreaming, options) {
|
|
|
169
180
|
if (elapsed >= tickMs) {
|
|
170
181
|
lastTickRef.current = now;
|
|
171
182
|
const target = targetRef.current;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
setRevealed(previous => {
|
|
184
|
+
const currentLen = previous.epoch === restart.epoch ? previous.len : restart.len;
|
|
185
|
+
if (currentLen >= target.length) {
|
|
186
|
+
return previous;
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
epoch: restart.epoch,
|
|
190
|
+
len: Math.min(currentLen + charsPerTick, target.length)
|
|
191
|
+
};
|
|
192
|
+
});
|
|
178
193
|
}
|
|
179
194
|
rafRef.current = requestAnimationFrame(tick);
|
|
180
195
|
}
|
|
@@ -185,7 +200,7 @@ export function useStreamingText(targetText, isStreaming, options) {
|
|
|
185
200
|
rafRef.current = null;
|
|
186
201
|
}
|
|
187
202
|
};
|
|
188
|
-
}, [isStreaming, charsPerTick, tickMs, speed, prefersReducedMotion]);
|
|
203
|
+
}, [isStreaming, charsPerTick, tickMs, speed, prefersReducedMotion, restart]);
|
|
189
204
|
if (!isStreaming || speed === 'instant' || prefersReducedMotion) {
|
|
190
205
|
return targetText;
|
|
191
206
|
}
|
|
@@ -10,7 +10,7 @@ const english = {
|
|
|
10
10
|
"@astryx.dateInput.calendarDescription": "Dates use the {calendar}",
|
|
11
11
|
"@astryx.dateInput.formatHint": "e.g., {example}",
|
|
12
12
|
"@astryx.dateInput.invalidDate": "Invalid date",
|
|
13
|
-
"@astryx.dateInput.nonexistentDate": "
|
|
14
|
-
"@astryx.dateInput.outOfRangeDate": "{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {
|
|
13
|
+
"@astryx.dateInput.nonexistentDate": "{named, select, yes {Enter a real date ({calendar})} other {Enter a real date}}",
|
|
14
|
+
"@astryx.dateInput.outOfRangeDate": "{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {Enter an available date}}"
|
|
15
15
|
};
|
|
16
16
|
export default english;
|
|
@@ -311,8 +311,8 @@ const runtimeCatalog = {
|
|
|
311
311
|
'@astryx.dateInput.toggleCalendarClose': 'Close calendar',
|
|
312
312
|
'@astryx.dateInput.clear': 'Clear {label}',
|
|
313
313
|
'@astryx.dateInput.invalidDate': 'Invalid date',
|
|
314
|
-
'@astryx.dateInput.nonexistentDate': '
|
|
315
|
-
'@astryx.dateInput.outOfRangeDate': '{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {
|
|
314
|
+
'@astryx.dateInput.nonexistentDate': '{named, select, yes {Enter a real date ({calendar})} other {Enter a real date}}',
|
|
315
|
+
'@astryx.dateInput.outOfRangeDate': '{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {Enter an available date}}',
|
|
316
316
|
'@astryx.dateInput.formatHint': 'e.g., {example}',
|
|
317
317
|
'@astryx.dateInput.calendarDescription': 'Dates use the {calendar}',
|
|
318
318
|
'@astryx.dateInput.resetPicking': 'Reset',
|
|
@@ -311,8 +311,8 @@ const runtimeCatalog = {
|
|
|
311
311
|
'@astryx.dateInput.toggleCalendarClose': '⟦Çłóšé çàłéñðàř⟧',
|
|
312
312
|
'@astryx.dateInput.clear': '⟦Çłéàř {label}⟧',
|
|
313
313
|
'@astryx.dateInput.invalidDate': '⟦Íñṽàłíð ðàţé⟧',
|
|
314
|
-
'@astryx.dateInput.nonexistentDate': '
|
|
315
|
-
'@astryx.dateInput.outOfRangeDate': '⟦{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {
|
|
314
|
+
'@astryx.dateInput.nonexistentDate': '⟦{named, select, yes {Enter a real date ({calendar})} other {Enter a real date}}⟧',
|
|
315
|
+
'@astryx.dateInput.outOfRangeDate': '⟦{bounds, select, both {Enter a date from {min} to {max}} min {Enter a date on or after {min}} max {Enter a date on or before {max}} other {Enter an available date}}⟧',
|
|
316
316
|
'@astryx.dateInput.formatHint': '⟦é.ĝ., {example}⟧',
|
|
317
317
|
'@astryx.dateInput.calendarDescription': '⟦Ðàţéš úšé ţĥé {calendar}⟧',
|
|
318
318
|
'@astryx.dateInput.resetPicking': '⟦Řéšéţ⟧',
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
* cross-fade needs a second copy of each title. Under Reduce Motion, UIKit's
|
|
9
9
|
* lens fades in at the new segment and scales from 0.88. Astryx allows no
|
|
10
10
|
* scaling there, so the animator's Reduce Motion cross-fade replaces it.
|
|
11
|
-
* UIKit's lens also
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* UIKit's lens also stretches along a slide; that stretch is not modeled.
|
|
12
|
+
* The lens chases a dragging finger on the shared `springs.fingerTracking`
|
|
13
|
+
* role, which matches the values UIKit reports for this control. A flick
|
|
14
|
+
* carries the selection no further than a slow drag: UIKit projects no
|
|
15
|
+
* flick, so the release position alone decides.
|
|
15
16
|
*/
|
|
16
17
|
export declare const segmentedControl: {
|
|
17
18
|
/**
|
|
@@ -44,12 +45,39 @@ export declare const segmentedControl: {
|
|
|
44
45
|
* 11 pt past its center (312 vs 301), Oct 23 2026
|
|
45
46
|
*/
|
|
46
47
|
readonly dragOvershoot: 11;
|
|
48
|
+
/**
|
|
49
|
+
* How much a finger's press on the selected segment grows the lens, in pt
|
|
50
|
+
* (width, height). The growth is the same at every control size.
|
|
51
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
52
|
+
* iPhone 17 Pro, per-frame lens bounds of a held selected segment:
|
|
53
|
+
* 96 × 27 to 120 × 43 (three segments), 71 × 27 to 95 × 43 (four
|
|
54
|
+
* segments), 126 × 40 to 150 × 56 (a 390 × 44 control), Oct 23 2026
|
|
55
|
+
*/
|
|
56
|
+
readonly liftGrowth: readonly [24, 16];
|
|
57
|
+
/**
|
|
58
|
+
* The lens growing by `liftGrowth` under a finger that presses the
|
|
59
|
+
* selected segment, and shrinking back after the release. It is critically
|
|
60
|
+
* damped and reaches 99 % in about 0.27 s.
|
|
61
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
62
|
+
* iPhone 17 Pro, UIViewSpringAnimationBehaviorSettings read on the lens
|
|
63
|
+
* while it lifts and settles (dampingRatio 1.0, response 0.25),
|
|
64
|
+
* Oct 23 2026
|
|
65
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
66
|
+
* iPhone 17 Pro, per-frame lens bounds of a 600 ms hold of the selected
|
|
67
|
+
* segment, spring fit with (1.0, 0.25): lift rms 0.16 pt (width) and
|
|
68
|
+
* 0.13 pt (height), settle rms 0.05 pt and 0.03 pt, each starting about
|
|
69
|
+
* 16 ms after the touch event, Nov 2 2026
|
|
70
|
+
*/
|
|
71
|
+
readonly lift: {
|
|
72
|
+
readonly response: 0.25;
|
|
73
|
+
readonly dampingRatio: 1;
|
|
74
|
+
};
|
|
47
75
|
};
|
|
48
76
|
/**
|
|
49
77
|
* Registers this table with the motion registry (motion/roles.ts). The
|
|
50
|
-
* slide's
|
|
51
|
-
*
|
|
52
|
-
* a second call does nothing.
|
|
78
|
+
* slide's and the lift's springs become internal motion roles. The drag
|
|
79
|
+
* overshoot and the lift's growth are not motion, so they stay internal
|
|
80
|
+
* constants. Nothing registers on import, and a second call does nothing.
|
|
53
81
|
*/
|
|
54
82
|
export declare function registerSegmentedTable(): void;
|
|
55
83
|
//# sourceMappingURL=segmented.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/segmented.ts"],"names":[],"mappings":"AAkBA
|
|
1
|
+
{"version":3,"file":"segmented.d.ts","sourceRoot":"","sources":["../../../src/motion/uikit/segmented.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;;;;;;;;;;;;;;OAgBG;;;;;IAEH;;;;;;;OAOG;;IAEH;;;;;;;OAOG;;IAEH;;;;;;;;;;;;;OAaG;;;;;CAEK,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @file segmented.ts
|
|
5
5
|
* @input Nothing; data only
|
|
6
6
|
* @output Exports `segmentedControl`, UISegmentedControl's selection slide
|
|
7
|
-
* spring
|
|
8
|
-
* registers the
|
|
7
|
+
* spring, its drag overshoot and its lift; and `registerSegmentedTable`,
|
|
8
|
+
* which registers the two springs as internal motion roles
|
|
9
9
|
* @position The segmented-control domain of the UIKit constants table
|
|
10
10
|
* (motion/uikit); read by SegmentedControl's touch presentation
|
|
11
11
|
*
|
|
@@ -26,10 +26,11 @@ import { registerMotionTable } from "../roles.js";
|
|
|
26
26
|
* cross-fade needs a second copy of each title. Under Reduce Motion, UIKit's
|
|
27
27
|
* lens fades in at the new segment and scales from 0.88. Astryx allows no
|
|
28
28
|
* scaling there, so the animator's Reduce Motion cross-fade replaces it.
|
|
29
|
-
* UIKit's lens also
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* UIKit's lens also stretches along a slide; that stretch is not modeled.
|
|
30
|
+
* The lens chases a dragging finger on the shared `springs.fingerTracking`
|
|
31
|
+
* role, which matches the values UIKit reports for this control. A flick
|
|
32
|
+
* carries the selection no further than a slow drag: UIKit projects no
|
|
33
|
+
* flick, so the release position alone decides.
|
|
33
34
|
*/
|
|
34
35
|
export const segmentedControl = {
|
|
35
36
|
/**
|
|
@@ -61,17 +62,44 @@ export const segmentedControl = {
|
|
|
61
62
|
* iPhone 17 Pro, a drag 60 pt past the last segment: the lens stops about
|
|
62
63
|
* 11 pt past its center (312 vs 301), Oct 23 2026
|
|
63
64
|
*/
|
|
64
|
-
dragOvershoot: 11
|
|
65
|
+
dragOvershoot: 11,
|
|
66
|
+
/**
|
|
67
|
+
* How much a finger's press on the selected segment grows the lens, in pt
|
|
68
|
+
* (width, height). The growth is the same at every control size.
|
|
69
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
70
|
+
* iPhone 17 Pro, per-frame lens bounds of a held selected segment:
|
|
71
|
+
* 96 × 27 to 120 × 43 (three segments), 71 × 27 to 95 × 43 (four
|
|
72
|
+
* segments), 126 × 40 to 150 × 56 (a 390 × 44 control), Oct 23 2026
|
|
73
|
+
*/
|
|
74
|
+
liftGrowth: [24, 16],
|
|
75
|
+
/**
|
|
76
|
+
* The lens growing by `liftGrowth` under a finger that presses the
|
|
77
|
+
* selected segment, and shrinking back after the release. It is critically
|
|
78
|
+
* damped and reaches 99 % in about 0.27 s.
|
|
79
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
80
|
+
* iPhone 17 Pro, UIViewSpringAnimationBehaviorSettings read on the lens
|
|
81
|
+
* while it lifts and settles (dampingRatio 1.0, response 0.25),
|
|
82
|
+
* Oct 23 2026
|
|
83
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
84
|
+
* iPhone 17 Pro, per-frame lens bounds of a 600 ms hold of the selected
|
|
85
|
+
* segment, spring fit with (1.0, 0.25): lift rms 0.16 pt (width) and
|
|
86
|
+
* 0.13 pt (height), settle rms 0.05 pt and 0.03 pt, each starting about
|
|
87
|
+
* 16 ms after the touch event, Nov 2 2026
|
|
88
|
+
*/
|
|
89
|
+
lift: {
|
|
90
|
+
response: 0.25,
|
|
91
|
+
dampingRatio: 1
|
|
92
|
+
}
|
|
65
93
|
};
|
|
66
94
|
|
|
67
95
|
/**
|
|
68
96
|
* Registers this table with the motion registry (motion/roles.ts). The
|
|
69
|
-
* slide's
|
|
70
|
-
*
|
|
71
|
-
* a second call does nothing.
|
|
97
|
+
* slide's and the lift's springs become internal motion roles. The drag
|
|
98
|
+
* overshoot and the lift's growth are not motion, so they stay internal
|
|
99
|
+
* constants. Nothing registers on import, and a second call does nothing.
|
|
72
100
|
*/
|
|
73
101
|
export function registerSegmentedTable() {
|
|
74
102
|
registerMotionTable('segmented', segmentedControl, {
|
|
75
|
-
roles: ['selectionSpring']
|
|
103
|
+
roles: ['selectionSpring', 'lift']
|
|
76
104
|
});
|
|
77
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"press.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/press.stylex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AA4E3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuP9B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;EAiBlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;
|
|
1
|
+
{"version":3,"file":"press.stylex.d.ts","sourceRoot":"","sources":["../../src/privateAttributes/press.stylex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AA4E3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuP9B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;EAiBlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;EAU9B,CAAC"}
|