@astryxdesign/core 0.7.9-canary.8fdf6be → 0.7.9-canary.97b1bb0
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/DateInput/wheelStrip.js +2 -2
- package/dist/InputGroup/InputGroupText.d.ts +2 -1
- package/dist/InputGroup/InputGroupText.d.ts.map +1 -1
- package/dist/InputGroup/InputGroupText.js +2 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
- package/dist/Slider/sliderTouchController.js +2 -2
- package/dist/Switch/useSwitchTouch.js +4 -4
- package/dist/animator/createAnimator.js +2 -2
- package/dist/internal/touch.d.ts +10 -5
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +15 -7
- package/dist/motion/animator.d.ts +5 -5
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +7 -6
- package/package.json +4 -4
- package/src/DateInput/wheelStrip.ts +2 -2
- package/src/InputGroup/InputGroupText.doc.mjs +45 -3
- package/src/InputGroup/InputGroupText.tsx +2 -1
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +3 -3
- package/src/Slider/sliderTouchController.ts +2 -2
- package/src/Switch/useSwitchTouch.ts +4 -4
- package/src/animator/createAnimator.ts +3 -3
- package/src/internal/touch.ts +16 -8
- package/src/motion/README.md +3 -3
- package/src/motion/animator.ts +7 -7
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { canVibrate, playHaptic } from "../gestures/haptics.js";
|
|
19
|
-
import {
|
|
19
|
+
import { createMotionEngine } from "../motion/animator.js";
|
|
20
20
|
import { reducedMotionFade } from "../motion/reducedMotion.js";
|
|
21
21
|
import { picker } from "../motion/uikit/picker.js";
|
|
22
22
|
import { nearestIndex, reachesRow, tickTimes } from "./wheelPhysics.js";
|
|
@@ -55,7 +55,7 @@ function now() {
|
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
export function createWheelStrip(initialLayout) {
|
|
58
|
-
const animator =
|
|
58
|
+
const animator = createMotionEngine(null);
|
|
59
59
|
let layout = initialLayout;
|
|
60
60
|
let running = null;
|
|
61
61
|
let nearestListener = null;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SYNC: When modified, update these files to stay in sync:
|
|
8
8
|
* - /packages/core/src/InputGroup/InputGroup.doc.mjs
|
|
9
|
+
* - /packages/core/src/InputGroup/InputGroupText.doc.mjs
|
|
9
10
|
* - /packages/core/src/InputGroup/index.ts
|
|
10
11
|
* - /packages/cli/assets/templates/blocks/components/InputGroup/
|
|
11
12
|
*/
|
|
@@ -24,7 +25,7 @@ export interface InputGroupTextProps extends BaseProps<HTMLDivElement> {
|
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* ```
|
|
27
|
-
* <InputGroup label="
|
|
28
|
+
* <InputGroup label="Website">
|
|
28
29
|
* <InputGroupText>https://</InputGroupText>
|
|
29
30
|
* <TextInput label="URL" isLabelHidden value={url} onChange={setUrl} />
|
|
30
31
|
* </InputGroup>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputGroupText.d.ts","sourceRoot":"","sources":["../../src/InputGroup/InputGroupText.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"InputGroupText.d.ts","sourceRoot":"","sources":["../../src/InputGroup/InputGroupText.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,EAAC,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAmD5C,MAAM,WAAW,mBAAoB,SAAQ,SAAS,CAAC,cAAc,CAAC;IACpE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,GAAG,EACH,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,mBAAmB,qBAerB;yBAtBe,cAAc"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* SYNC: When modified, update these files to stay in sync:
|
|
12
12
|
* - /packages/core/src/InputGroup/InputGroup.doc.mjs
|
|
13
|
+
* - /packages/core/src/InputGroup/InputGroupText.doc.mjs
|
|
13
14
|
* - /packages/core/src/InputGroup/index.ts
|
|
14
15
|
* - /packages/cli/assets/templates/blocks/components/InputGroup/
|
|
15
16
|
*/
|
|
@@ -49,7 +50,7 @@ const styles = {
|
|
|
49
50
|
*
|
|
50
51
|
* @example
|
|
51
52
|
* ```
|
|
52
|
-
* <InputGroup label="
|
|
53
|
+
* <InputGroup label="Website">
|
|
53
54
|
* <InputGroupText>https://</InputGroupText>
|
|
54
55
|
* <TextInput label="URL" isLabelHidden value={url} onChange={setUrl} />
|
|
55
56
|
* </InputGroup>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* - /packages/core/src/SegmentedControl/useSegmentedTouchTracking.ts
|
|
17
17
|
*/
|
|
18
18
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
19
|
-
import {
|
|
19
|
+
import { createMotionEngine } from "../motion/animator.js";
|
|
20
20
|
import { registerSegmentedTable, segmentedControl } from "../motion/uikit/segmented.js";
|
|
21
21
|
import { registerSpringsTable, springs } from "../motion/uikit/springs.js";
|
|
22
22
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
@@ -361,7 +361,7 @@ export class SegmentedSelectionMotion {
|
|
|
361
361
|
|
|
362
362
|
/** The ::after: the surface fading out under Reduced Motion. */
|
|
363
363
|
|
|
364
|
-
constructor(animator =
|
|
364
|
+
constructor(animator = createMotionEngine(null, {
|
|
365
365
|
pseudoElement: '::before'
|
|
366
366
|
}), options = {}) {
|
|
367
367
|
this.animator = animator;
|
|
@@ -371,7 +371,7 @@ export class SegmentedSelectionMotion {
|
|
|
371
371
|
registerSpringsTable();
|
|
372
372
|
registerSegmentedTable();
|
|
373
373
|
this.now = options.now ?? defaultNow;
|
|
374
|
-
this.after = options.afterAnimator ??
|
|
374
|
+
this.after = options.afterAnimator ?? createMotionEngine(null, {
|
|
375
375
|
pseudoElement: '::after',
|
|
376
376
|
initial: {
|
|
377
377
|
opacity: 0
|
|
@@ -21,7 +21,7 @@ import { PRESS_PROFILES, createPressTracker } from "../gestures/PressTracker.js"
|
|
|
21
21
|
import { lockSelection } from "../gestures/selectionLock.js";
|
|
22
22
|
import { TapGestureRecognizer } from "../gestures/TapGestureRecognizer.js";
|
|
23
23
|
import { isRtlElement } from "../hooks/isRtlElement.js";
|
|
24
|
-
import {
|
|
24
|
+
import { createMotionEngine } from "../motion/animator.js";
|
|
25
25
|
import { projectDistance } from "../motion/projection.js";
|
|
26
26
|
import { resolveMotion } from "../motion/resolveMotion.js";
|
|
27
27
|
import { solveSpring, toSpring } from "../motion/spring.js";
|
|
@@ -995,7 +995,7 @@ export class SliderTouchController {
|
|
|
995
995
|
animatorFor(element) {
|
|
996
996
|
let animator = this.animators.get(element);
|
|
997
997
|
if (animator == null) {
|
|
998
|
-
animator =
|
|
998
|
+
animator = createMotionEngine(element);
|
|
999
999
|
this.animators.set(element, animator);
|
|
1000
1000
|
}
|
|
1001
1001
|
return animator;
|
|
@@ -20,7 +20,7 @@ import { getGestureHost } from "../gestures/GestureHost.js";
|
|
|
20
20
|
import { createPressTracker } from "../gestures/PressTracker.js";
|
|
21
21
|
import { isRtlElement } from "../hooks/isRtlElement.js";
|
|
22
22
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
23
|
-
import {
|
|
23
|
+
import { createMotionEngine } from "../motion/animator.js";
|
|
24
24
|
import { solveSpring, toSpring } from "../motion/spring.js";
|
|
25
25
|
import { UIKIT_GESTURES } from "../motion/uikit/gestures.js";
|
|
26
26
|
import { registerSwitchTable, switchControl } from "../motion/uikit/switch.js";
|
|
@@ -203,10 +203,10 @@ export class SwitchTouchController {
|
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
registerSwitchTable();
|
|
206
|
-
this.thumb =
|
|
206
|
+
this.thumb = createMotionEngine(elements.thumb);
|
|
207
207
|
// The layer rests clear (its class's opacity 0) while the visuals show
|
|
208
208
|
// the value; from here its opacity is the animator's.
|
|
209
|
-
this.fade =
|
|
209
|
+
this.fade = createMotionEngine(elements.track, {
|
|
210
210
|
pseudoElement: '::after',
|
|
211
211
|
initial: {
|
|
212
212
|
opacity: 0
|
|
@@ -215,7 +215,7 @@ export class SwitchTouchController {
|
|
|
215
215
|
this.fade.set({
|
|
216
216
|
opacity: 0
|
|
217
217
|
});
|
|
218
|
-
this.shadow =
|
|
218
|
+
this.shadow = createMotionEngine(elements.thumb, {
|
|
219
219
|
pseudoElement: '::after',
|
|
220
220
|
initial: {
|
|
221
221
|
opacity: 0
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* - /packages/core/src/animator/createAnimator.doc.mjs
|
|
17
17
|
* - /packages/core/src/hooks/useAnimator.ts
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import { createMotionEngine, SETTLE_THRESHOLD } from "../motion/animator.js";
|
|
20
20
|
import { coast } from "../motion/coast.js";
|
|
21
21
|
import { solveDecay } from "../motion/decay.js";
|
|
22
22
|
import { registerSpringsTable, springs } from "../motion/uikit/springs.js";
|
|
@@ -125,7 +125,7 @@ async function settledOrTakenOver(moving) {
|
|
|
125
125
|
* no behavior of its own. Not exported from the package.
|
|
126
126
|
*/
|
|
127
127
|
export function createAttachableAnimator() {
|
|
128
|
-
const motion =
|
|
128
|
+
const motion = createMotionEngine(null);
|
|
129
129
|
// Calls do nothing while no element is attached, before the ref attaches
|
|
130
130
|
// or after it lets go. They also do nothing after destroy, and animate and
|
|
131
131
|
// decay then resolve at once.
|
package/dist/internal/touch.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file touch.ts
|
|
3
3
|
* @input The gesture core: the arena, the recognizers, and their geometry;
|
|
4
|
-
* the pan, the motion
|
|
5
|
-
*
|
|
4
|
+
* the pan, the motion engine and math, and the touch-presentation and
|
|
5
|
+
* direction helpers that Lab components read
|
|
6
6
|
* @output `@astryxdesign/core/internal/touch`: the gesture core's primitives
|
|
7
|
-
*
|
|
7
|
+
* and the motion, touch-presentation and direction modules for Lab
|
|
8
|
+
* components, re-exported by name
|
|
8
9
|
* @position An internal entry reserved for Astryx's own packages:
|
|
9
10
|
* undocumented, outside the public API and its compatibility promise
|
|
10
11
|
* (spec:AST-017 FR21), versioned in lockstep with Core, and allowed only in
|
|
@@ -29,11 +30,15 @@ export { PanGestureRecognizer } from '../gestures/PanGestureRecognizer.js';
|
|
|
29
30
|
export type { PanGestureRecognizerOptions } from '../gestures/PanGestureRecognizer.js';
|
|
30
31
|
export type { GestureEventContext, GestureTouch, PointerKind, } from '../gestures/types.js';
|
|
31
32
|
export { useGestureRecognizer } from '../gestures/useGestureRecognizer.js';
|
|
32
|
-
export {
|
|
33
|
-
export type { Animator as
|
|
33
|
+
export { createMotionEngine } from '../motion/animator.js';
|
|
34
|
+
export type { Animator as MotionEngine, AnimatorOptions as MotionEngineOptions, MotionCurve, } from '../motion/animator.js';
|
|
34
35
|
export { cubicBezier } from '../motion/bezier.js';
|
|
35
36
|
export { mapProgress } from '../motion/progress.js';
|
|
36
37
|
export { parseCssEasing, parseMotionRoleValue } from '../motion/roles.js';
|
|
37
38
|
export { rubberBand, rubberBandInverse, rubberBandSlope, } from '../motion/rubberBand.js';
|
|
38
39
|
export { scroll } from '../motion/uikit/scroll.js';
|
|
40
|
+
export { isRtlElement } from '../hooks/isRtlElement.js';
|
|
41
|
+
export { UIKIT_GESTURES } from '../motion/uikit/gestures.js';
|
|
42
|
+
export { useTouchPresentation } from '../utils/touchPresentation.js';
|
|
43
|
+
export { TOUCH_QUERY } from '../utils/touchQueries.js';
|
|
39
44
|
//# sourceMappingURL=touch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"touch.d.ts","sourceRoot":"","sources":["../../src/internal/touch.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"touch.d.ts","sourceRoot":"","sources":["../../src/internal/touch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,YAAY,GACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAOtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AACtE,YAAY,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAClF,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACtD,YAAY,EACV,QAAQ,IAAI,YAAY,EACxB,eAAe,IAAI,mBAAmB,EACtC,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAI9C,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC"}
|
package/dist/internal/touch.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file touch.ts
|
|
5
5
|
* @input The gesture core: the arena, the recognizers, and their geometry;
|
|
6
|
-
* the pan, the motion
|
|
7
|
-
*
|
|
6
|
+
* the pan, the motion engine and math, and the touch-presentation and
|
|
7
|
+
* direction helpers that Lab components read
|
|
8
8
|
* @output `@astryxdesign/core/internal/touch`: the gesture core's primitives
|
|
9
|
-
*
|
|
9
|
+
* and the motion, touch-presentation and direction modules for Lab
|
|
10
|
+
* components, re-exported by name
|
|
10
11
|
* @position An internal entry reserved for Astryx's own packages:
|
|
11
12
|
* undocumented, outside the public API and its compatibility promise
|
|
12
13
|
* (spec:AST-017 FR21), versioned in lockstep with Core, and allowed only in
|
|
@@ -30,17 +31,24 @@ export { TapGestureRecognizer } from "../gestures/TapGestureRecognizer.js";
|
|
|
30
31
|
export { DEFAULT_ENVIRONMENT } from "../gestures/types.js";
|
|
31
32
|
|
|
32
33
|
// Lab's useRefreshControl reads these: its pull's pan and the hook that
|
|
33
|
-
// starts it. It also reads the motion
|
|
34
|
+
// starts it. It also reads the motion engine and math, and the scroll
|
|
34
35
|
// view's bounce spring, for its pull, settle and end. Its indicator fades
|
|
35
36
|
// along the settle's curve, and the motion-role parsers read the theme's
|
|
36
37
|
// tokens for its end.
|
|
37
38
|
export { PanGestureRecognizer } from "../gestures/PanGestureRecognizer.js";
|
|
38
39
|
export { useGestureRecognizer } from "../gestures/useGestureRecognizer.js";
|
|
39
|
-
// The
|
|
40
|
+
// The motion engine's factory. The public one, `createAnimator`, plays
|
|
40
41
|
// only the theme's state-change motion.
|
|
41
|
-
export {
|
|
42
|
+
export { createMotionEngine } from "../motion/animator.js";
|
|
42
43
|
export { cubicBezier } from "../motion/bezier.js";
|
|
43
44
|
export { mapProgress } from "../motion/progress.js";
|
|
44
45
|
export { parseCssEasing, parseMotionRoleValue } from "../motion/roles.js";
|
|
45
46
|
export { rubberBand, rubberBandInverse, rubberBandSlope } from "../motion/rubberBand.js";
|
|
46
|
-
export { scroll } from "../motion/uikit/scroll.js";
|
|
47
|
+
export { scroll } from "../motion/uikit/scroll.js";
|
|
48
|
+
|
|
49
|
+
// Lab components also read the UIKit gesture table, the touch presentation
|
|
50
|
+
// and its query, and an element's direction.
|
|
51
|
+
export { isRtlElement } from "../hooks/isRtlElement.js";
|
|
52
|
+
export { UIKIT_GESTURES } from "../motion/uikit/gestures.js";
|
|
53
|
+
export { useTouchPresentation } from "../utils/touchPresentation.js";
|
|
54
|
+
export { TOUCH_QUERY } from "../utils/touchQueries.js";
|
|
@@ -100,9 +100,6 @@ export interface MotionCurve {
|
|
|
100
100
|
*/
|
|
101
101
|
readonly isTransition?: boolean;
|
|
102
102
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Options of `createMotionAnimator`.
|
|
105
|
-
*/
|
|
106
103
|
/** How `set` puts values in place. */
|
|
107
104
|
export interface SetOptions {
|
|
108
105
|
/**
|
|
@@ -117,6 +114,9 @@ export interface SetOptions {
|
|
|
117
114
|
*/
|
|
118
115
|
promote?: boolean;
|
|
119
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Options of `createMotionEngine`.
|
|
119
|
+
*/
|
|
120
120
|
export interface AnimatorOptions {
|
|
121
121
|
/**
|
|
122
122
|
* Animates a pseudo-element of the element instead (`'::backdrop'` of a
|
|
@@ -302,7 +302,7 @@ export declare function defaultIsCoarsePointer(): boolean;
|
|
|
302
302
|
*
|
|
303
303
|
* @example
|
|
304
304
|
* ```
|
|
305
|
-
* const animator =
|
|
305
|
+
* const animator = createMotionEngine(sheet);
|
|
306
306
|
* // finger lifts at 1200 px/s heading for the detent at 0 (a component
|
|
307
307
|
* // passes the spring of its motion role):
|
|
308
308
|
* animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
|
|
@@ -311,5 +311,5 @@ export declare function defaultIsCoarsePointer(): boolean;
|
|
|
311
311
|
* animator.stop(['y']);
|
|
312
312
|
* ```
|
|
313
313
|
*/
|
|
314
|
-
export declare function
|
|
314
|
+
export declare function createMotionEngine(element: HTMLElement | null, options?: AnimatorOptions): Animator;
|
|
315
315
|
//# sourceMappingURL=animator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../../src/motion/animator.ts"],"names":[],"mappings":"AAwLA,OAAO,EAAwB,KAAK,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAUvE;;GAEG;AACH,MAAM,MAAM,cAAc,GACxB,GAAG,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,MAAM,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,YAA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OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,GAAE,eAAoB,GAC5B,QAAQ,CAu+FV"}
|
package/dist/motion/animator.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @file animator.ts
|
|
5
5
|
* @input An element, target values, and a spring, momentum curves (coast.ts)
|
|
6
6
|
* or any closed-form curve
|
|
7
|
-
* @output Exports `
|
|
7
|
+
* @output Exports `createMotionEngine`, a compositor animator for
|
|
8
8
|
* translate, rotate, scale and opacity, and its option, handle and
|
|
9
9
|
* transition types. It reads presentation values and velocities from the
|
|
10
10
|
* analytic curves. It retargets with the velocity kept, freezes in place on
|
|
@@ -214,10 +214,11 @@ import { themeReducesMotion } from "../privateAttributes/reducedMotion.stylex.js
|
|
|
214
214
|
* the property's presentation value (`get`) to continue without a jump.
|
|
215
215
|
*/
|
|
216
216
|
|
|
217
|
+
/** How `set` puts values in place. */
|
|
218
|
+
|
|
217
219
|
/**
|
|
218
|
-
* Options of `
|
|
220
|
+
* Options of `createMotionEngine`.
|
|
219
221
|
*/
|
|
220
|
-
/** How `set` puts values in place. */
|
|
221
222
|
|
|
222
223
|
/**
|
|
223
224
|
* One `animate` / `decay` call's animations.
|
|
@@ -428,7 +429,7 @@ export function animatorFor(element, options = {}) {
|
|
|
428
429
|
const key = options.pseudoElement ?? '';
|
|
429
430
|
let animator = byPseudo.get(key);
|
|
430
431
|
if (animator == null) {
|
|
431
|
-
animator =
|
|
432
|
+
animator = createMotionEngine(element, options);
|
|
432
433
|
byPseudo.set(key, animator);
|
|
433
434
|
}
|
|
434
435
|
return animator;
|
|
@@ -532,7 +533,7 @@ const REDUCED_TRANSITION = {
|
|
|
532
533
|
*
|
|
533
534
|
* @example
|
|
534
535
|
* ```
|
|
535
|
-
* const animator =
|
|
536
|
+
* const animator = createMotionEngine(sheet);
|
|
536
537
|
* // finger lifts at 1200 px/s heading for the detent at 0 (a component
|
|
537
538
|
* // passes the spring of its motion role):
|
|
538
539
|
* animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
|
|
@@ -541,7 +542,7 @@ const REDUCED_TRANSITION = {
|
|
|
541
542
|
* animator.stop(['y']);
|
|
542
543
|
* ```
|
|
543
544
|
*/
|
|
544
|
-
export function
|
|
545
|
+
export function createMotionEngine(element, options = {}) {
|
|
545
546
|
const now = options.now ?? defaultNow;
|
|
546
547
|
const frameSource = options.requestFrame ?? (typeof requestAnimationFrame === 'function' ? callback => {
|
|
547
548
|
requestAnimationFrame(() => callback());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/core",
|
|
3
|
-
"version": "0.7.9-canary.
|
|
3
|
+
"version": "0.7.9-canary.97b1bb0",
|
|
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",
|
|
@@ -880,9 +880,9 @@
|
|
|
880
880
|
"react-dom": ">=19.0.0"
|
|
881
881
|
},
|
|
882
882
|
"devDependencies": {
|
|
883
|
-
"@astryxdesign/a11y-spec": "0.7.9-canary.
|
|
884
|
-
"@astryxdesign/cli": "0.7.9-canary.
|
|
885
|
-
"@astryxdesign/interaction-harness": "0.7.9-canary.
|
|
883
|
+
"@astryxdesign/a11y-spec": "0.7.9-canary.97b1bb0",
|
|
884
|
+
"@astryxdesign/cli": "0.7.9-canary.97b1bb0",
|
|
885
|
+
"@astryxdesign/interaction-harness": "0.7.9-canary.97b1bb0",
|
|
886
886
|
"@babel/cli": "^7.29.7",
|
|
887
887
|
"@babel/core": "^7.29.7",
|
|
888
888
|
"@babel/preset-react": "^7.29.7",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {canVibrate, playHaptic} from '../gestures/haptics';
|
|
19
|
-
import {
|
|
19
|
+
import {createMotionEngine, type MotionCurve} from '../motion/animator';
|
|
20
20
|
import {reducedMotionFade} from '../motion/reducedMotion';
|
|
21
21
|
import {picker} from '../motion/uikit/picker';
|
|
22
22
|
import {
|
|
@@ -132,7 +132,7 @@ function now(): number {
|
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
export function createWheelStrip(initialLayout: WheelLayout): WheelStrip {
|
|
135
|
-
const animator =
|
|
135
|
+
const animator = createMotionEngine(null);
|
|
136
136
|
let layout = initialLayout;
|
|
137
137
|
let running: Running | null = null;
|
|
138
138
|
let nearestListener: ((position: number) => void) | null = null;
|
|
@@ -7,7 +7,42 @@ export const docs = {
|
|
|
7
7
|
subComponentOf: 'InputGroup',
|
|
8
8
|
displayName: 'Input Group Text',
|
|
9
9
|
isHiddenFromOverview: true,
|
|
10
|
-
description:
|
|
10
|
+
description:
|
|
11
|
+
'A prefix or suffix text element rendered inside InputGroup. Displays text or icons.',
|
|
12
|
+
usage: {
|
|
13
|
+
description:
|
|
14
|
+
"Use InputGroupText inside InputGroup for a short fixed prefix or suffix, such as a currency symbol, a protocol, or a unit, or for a decorative icon. It is plain text, not a control, and it is not part of the input's accessible name.",
|
|
15
|
+
bestPractices: [
|
|
16
|
+
{
|
|
17
|
+
guidance: true,
|
|
18
|
+
description:
|
|
19
|
+
'Keep the text short, such as $, https://, or kg. It stays on one line and does not shrink.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
guidance: true,
|
|
23
|
+
description:
|
|
24
|
+
'Put what a screen reader user needs in the input\'s own label, such as "Amount in USD" beside a $ prefix. The addon is read as plain text in reading order.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
guidance: false,
|
|
28
|
+
description:
|
|
29
|
+
'Put buttons, links, or other controls inside InputGroupText. Use a Button addon for an action.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
guidance: false,
|
|
33
|
+
description:
|
|
34
|
+
'Use InputGroupText outside InputGroup. Its borders and corners join an InputGroup row.',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
anatomy: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Text cell',
|
|
40
|
+
required: true,
|
|
41
|
+
description:
|
|
42
|
+
'A non-interactive cell that holds text or an icon and joins the borders of its neighbours in the row.',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
11
46
|
props: [
|
|
12
47
|
{
|
|
13
48
|
name: 'children',
|
|
@@ -18,7 +53,8 @@ export const docs = {
|
|
|
18
53
|
{
|
|
19
54
|
name: 'xstyle',
|
|
20
55
|
type: 'StyleXStyles',
|
|
21
|
-
description:
|
|
56
|
+
description:
|
|
57
|
+
'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value: not an inline style object like style={{}}.',
|
|
22
58
|
},
|
|
23
59
|
{
|
|
24
60
|
name: 'className',
|
|
@@ -30,6 +66,11 @@ export const docs = {
|
|
|
30
66
|
type: 'React.CSSProperties',
|
|
31
67
|
description: 'Inline styles.',
|
|
32
68
|
},
|
|
69
|
+
{
|
|
70
|
+
name: 'ref',
|
|
71
|
+
type: 'React.Ref<HTMLDivElement>',
|
|
72
|
+
description: 'Ref forwarded to the text cell element.',
|
|
73
|
+
},
|
|
33
74
|
],
|
|
34
75
|
};
|
|
35
76
|
|
|
@@ -40,8 +81,9 @@ export const docsDense = {
|
|
|
40
81
|
description: 'prefix/suffix text/icon element',
|
|
41
82
|
propDescriptions: {
|
|
42
83
|
children: 'text or icon content',
|
|
43
|
-
xstyle: 'StyleX styles',
|
|
84
|
+
xstyle: 'StyleX styles (stylex.create() value)',
|
|
44
85
|
className: 'CSS class name(s)',
|
|
45
86
|
style: 'inline styles',
|
|
87
|
+
ref: 'ref to the text cell',
|
|
46
88
|
},
|
|
47
89
|
};
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* SYNC: When modified, update these files to stay in sync:
|
|
12
12
|
* - /packages/core/src/InputGroup/InputGroup.doc.mjs
|
|
13
|
+
* - /packages/core/src/InputGroup/InputGroupText.doc.mjs
|
|
13
14
|
* - /packages/core/src/InputGroup/index.ts
|
|
14
15
|
* - /packages/cli/assets/templates/blocks/components/InputGroup/
|
|
15
16
|
*/
|
|
@@ -81,7 +82,7 @@ export interface InputGroupTextProps extends BaseProps<HTMLDivElement> {
|
|
|
81
82
|
*
|
|
82
83
|
* @example
|
|
83
84
|
* ```
|
|
84
|
-
* <InputGroup label="
|
|
85
|
+
* <InputGroup label="Website">
|
|
85
86
|
* <InputGroupText>https://</InputGroupText>
|
|
86
87
|
* <TextInput label="URL" isLabelHidden value={url} onChange={setUrl} />
|
|
87
88
|
* </InputGroup>
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
type RefObject,
|
|
26
26
|
} from 'react';
|
|
27
27
|
import {
|
|
28
|
-
|
|
28
|
+
createMotionEngine,
|
|
29
29
|
type AnimateOptions,
|
|
30
30
|
type Animator,
|
|
31
31
|
type MotionCurve,
|
|
@@ -539,7 +539,7 @@ export class SegmentedSelectionMotion {
|
|
|
539
539
|
private readonly after: Animator;
|
|
540
540
|
|
|
541
541
|
constructor(
|
|
542
|
-
private readonly animator: Animator =
|
|
542
|
+
private readonly animator: Animator = createMotionEngine(null, {
|
|
543
543
|
pseudoElement: '::before',
|
|
544
544
|
}),
|
|
545
545
|
options: SegmentedSelectionMotionOptions = {},
|
|
@@ -552,7 +552,7 @@ export class SegmentedSelectionMotion {
|
|
|
552
552
|
this.now = options.now ?? defaultNow;
|
|
553
553
|
this.after =
|
|
554
554
|
options.afterAnimator ??
|
|
555
|
-
|
|
555
|
+
createMotionEngine(null, {
|
|
556
556
|
pseudoElement: '::after',
|
|
557
557
|
initial: {opacity: 0},
|
|
558
558
|
});
|
|
@@ -29,7 +29,7 @@ import {TapGestureRecognizer} from '../gestures/TapGestureRecognizer';
|
|
|
29
29
|
import type {PointerKind} from '../gestures/types';
|
|
30
30
|
import {isRtlElement} from '../hooks/isRtlElement';
|
|
31
31
|
import {
|
|
32
|
-
|
|
32
|
+
createMotionEngine,
|
|
33
33
|
type Animator,
|
|
34
34
|
type MotionCurve,
|
|
35
35
|
type MotionHandle,
|
|
@@ -1186,7 +1186,7 @@ export class SliderTouchController {
|
|
|
1186
1186
|
private animatorFor(element: HTMLElement): Animator {
|
|
1187
1187
|
let animator = this.animators.get(element);
|
|
1188
1188
|
if (animator == null) {
|
|
1189
|
-
animator =
|
|
1189
|
+
animator = createMotionEngine(element);
|
|
1190
1190
|
this.animators.set(element, animator);
|
|
1191
1191
|
}
|
|
1192
1192
|
return animator;
|
|
@@ -23,7 +23,7 @@ import type {GestureTouch} from '../gestures/types';
|
|
|
23
23
|
import {isRtlElement} from '../hooks/isRtlElement';
|
|
24
24
|
import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
|
|
25
25
|
import {
|
|
26
|
-
|
|
26
|
+
createMotionEngine,
|
|
27
27
|
type Animator,
|
|
28
28
|
type MotionCurve,
|
|
29
29
|
} from '../motion/animator';
|
|
@@ -282,15 +282,15 @@ export class SwitchTouchController {
|
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
284
|
registerSwitchTable();
|
|
285
|
-
this.thumb =
|
|
285
|
+
this.thumb = createMotionEngine(elements.thumb);
|
|
286
286
|
// The layer rests clear (its class's opacity 0) while the visuals show
|
|
287
287
|
// the value; from here its opacity is the animator's.
|
|
288
|
-
this.fade =
|
|
288
|
+
this.fade = createMotionEngine(elements.track, {
|
|
289
289
|
pseudoElement: '::after',
|
|
290
290
|
initial: {opacity: 0},
|
|
291
291
|
});
|
|
292
292
|
this.fade.set({opacity: 0});
|
|
293
|
-
this.shadow =
|
|
293
|
+
this.shadow = createMotionEngine(elements.thumb, {
|
|
294
294
|
pseudoElement: '::after',
|
|
295
295
|
initial: {opacity: 0},
|
|
296
296
|
});
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import {
|
|
21
|
-
|
|
21
|
+
createMotionEngine,
|
|
22
22
|
SETTLE_THRESHOLD,
|
|
23
|
-
type Animator as
|
|
23
|
+
type Animator as MotionEngine,
|
|
24
24
|
type MotionCurve,
|
|
25
25
|
type MotionProperty,
|
|
26
26
|
type MotionValues,
|
|
@@ -199,7 +199,7 @@ export function createAttachableAnimator(): {
|
|
|
199
199
|
readonly animator: Animator;
|
|
200
200
|
readonly attach: (element: HTMLElement | null) => void;
|
|
201
201
|
} {
|
|
202
|
-
const motion:
|
|
202
|
+
const motion: MotionEngine = createMotionEngine(null);
|
|
203
203
|
// Calls do nothing while no element is attached, before the ref attaches
|
|
204
204
|
// or after it lets go. They also do nothing after destroy, and animate and
|
|
205
205
|
// decay then resolve at once.
|
package/src/internal/touch.ts
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file touch.ts
|
|
5
5
|
* @input The gesture core: the arena, the recognizers, and their geometry;
|
|
6
|
-
* the pan, the motion
|
|
7
|
-
*
|
|
6
|
+
* the pan, the motion engine and math, and the touch-presentation and
|
|
7
|
+
* direction helpers that Lab components read
|
|
8
8
|
* @output `@astryxdesign/core/internal/touch`: the gesture core's primitives
|
|
9
|
-
*
|
|
9
|
+
* and the motion, touch-presentation and direction modules for Lab
|
|
10
|
+
* components, re-exported by name
|
|
10
11
|
* @position An internal entry reserved for Astryx's own packages:
|
|
11
12
|
* undocumented, outside the public API and its compatibility promise
|
|
12
13
|
* (spec:AST-017 FR21), versioned in lockstep with Core, and allowed only in
|
|
@@ -43,7 +44,7 @@ export {TapGestureRecognizer} from '../gestures/TapGestureRecognizer';
|
|
|
43
44
|
export {DEFAULT_ENVIRONMENT} from '../gestures/types';
|
|
44
45
|
|
|
45
46
|
// Lab's useRefreshControl reads these: its pull's pan and the hook that
|
|
46
|
-
// starts it. It also reads the motion
|
|
47
|
+
// starts it. It also reads the motion engine and math, and the scroll
|
|
47
48
|
// view's bounce spring, for its pull, settle and end. Its indicator fades
|
|
48
49
|
// along the settle's curve, and the motion-role parsers read the theme's
|
|
49
50
|
// tokens for its end.
|
|
@@ -55,12 +56,12 @@ export type {
|
|
|
55
56
|
PointerKind,
|
|
56
57
|
} from '../gestures/types';
|
|
57
58
|
export {useGestureRecognizer} from '../gestures/useGestureRecognizer';
|
|
58
|
-
// The
|
|
59
|
+
// The motion engine's factory. The public one, `createAnimator`, plays
|
|
59
60
|
// only the theme's state-change motion.
|
|
60
|
-
export {
|
|
61
|
+
export {createMotionEngine} from '../motion/animator';
|
|
61
62
|
export type {
|
|
62
|
-
Animator as
|
|
63
|
-
AnimatorOptions as
|
|
63
|
+
Animator as MotionEngine,
|
|
64
|
+
AnimatorOptions as MotionEngineOptions,
|
|
64
65
|
MotionCurve,
|
|
65
66
|
} from '../motion/animator';
|
|
66
67
|
export {cubicBezier} from '../motion/bezier';
|
|
@@ -72,3 +73,10 @@ export {
|
|
|
72
73
|
rubberBandSlope,
|
|
73
74
|
} from '../motion/rubberBand';
|
|
74
75
|
export {scroll} from '../motion/uikit/scroll';
|
|
76
|
+
|
|
77
|
+
// Lab components also read the UIKit gesture table, the touch presentation
|
|
78
|
+
// and its query, and an element's direction.
|
|
79
|
+
export {isRtlElement} from '../hooks/isRtlElement';
|
|
80
|
+
export {UIKIT_GESTURES} from '../motion/uikit/gestures';
|
|
81
|
+
export {useTouchPresentation} from '../utils/touchPresentation';
|
|
82
|
+
export {TOUCH_QUERY} from '../utils/touchQueries';
|
package/src/motion/README.md
CHANGED
|
@@ -69,7 +69,7 @@ the timings that decide who gets a touch are not roles.
|
|
|
69
69
|
## Animator
|
|
70
70
|
|
|
71
71
|
```
|
|
72
|
-
import {
|
|
72
|
+
import {createMotionEngine} from '../motion/animator';
|
|
73
73
|
import {coast} from '../motion/coast';
|
|
74
74
|
import {solveSpringTowardRamp, toSpring} from '../motion/spring';
|
|
75
75
|
import {resolveMotion} from '../motion/resolveMotion';
|
|
@@ -78,7 +78,7 @@ import {registerSpringsTable, springs} from '../motion/uikit';
|
|
|
78
78
|
// Once, so the springs are registered as their roles:
|
|
79
79
|
registerSpringsTable();
|
|
80
80
|
|
|
81
|
-
const animator =
|
|
81
|
+
const animator = createMotionEngine(sheet);
|
|
82
82
|
// The animator plays a motion role (spec:AST-094 FR4), its table value, as the
|
|
83
83
|
// per-role tables stay internal (DEC-15); math on a spring reads the role with
|
|
84
84
|
// resolveMotion.
|
|
@@ -175,7 +175,7 @@ await handle.finished; // true if it ran to the end, false if interrupted
|
|
|
175
175
|
- `animatorFor(element)` returns the one animator for an element, so code
|
|
176
176
|
that animates it from several places (a swipe on x, a removal on y)
|
|
177
177
|
composes in one `translate` track.
|
|
178
|
-
- `
|
|
178
|
+
- `createMotionEngine(dialog, {pseudoElement: '::backdrop'})` drives a
|
|
179
179
|
pseudo-element; with no inline style to hold it, a static filling animation
|
|
180
180
|
holds its end value until the next animation replaces it, while the
|
|
181
181
|
pseudo-element exists. A dialog's `::backdrop` is made again each time the
|
package/src/motion/animator.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @file animator.ts
|
|
5
5
|
* @input An element, target values, and a spring, momentum curves (coast.ts)
|
|
6
6
|
* or any closed-form curve
|
|
7
|
-
* @output Exports `
|
|
7
|
+
* @output Exports `createMotionEngine`, a compositor animator for
|
|
8
8
|
* translate, rotate, scale and opacity, and its option, handle and
|
|
9
9
|
* transition types. It reads presentation values and velocities from the
|
|
10
10
|
* analytic curves. It retargets with the velocity kept, freezes in place on
|
|
@@ -299,9 +299,6 @@ export interface MotionCurve {
|
|
|
299
299
|
readonly isTransition?: boolean;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
/**
|
|
303
|
-
* Options of `createMotionAnimator`.
|
|
304
|
-
*/
|
|
305
302
|
/** How `set` puts values in place. */
|
|
306
303
|
export interface SetOptions {
|
|
307
304
|
/**
|
|
@@ -317,6 +314,9 @@ export interface SetOptions {
|
|
|
317
314
|
promote?: boolean;
|
|
318
315
|
}
|
|
319
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Options of `createMotionEngine`.
|
|
319
|
+
*/
|
|
320
320
|
export interface AnimatorOptions {
|
|
321
321
|
/**
|
|
322
322
|
* Animates a pseudo-element of the element instead (`'::backdrop'` of a
|
|
@@ -811,7 +811,7 @@ export function animatorFor(
|
|
|
811
811
|
const key = options.pseudoElement ?? '';
|
|
812
812
|
let animator = byPseudo.get(key);
|
|
813
813
|
if (animator == null) {
|
|
814
|
-
animator =
|
|
814
|
+
animator = createMotionEngine(element, options);
|
|
815
815
|
byPseudo.set(key, animator);
|
|
816
816
|
}
|
|
817
817
|
return animator;
|
|
@@ -928,7 +928,7 @@ const REDUCED_TRANSITION: SpringTransition = {
|
|
|
928
928
|
*
|
|
929
929
|
* @example
|
|
930
930
|
* ```
|
|
931
|
-
* const animator =
|
|
931
|
+
* const animator = createMotionEngine(sheet);
|
|
932
932
|
* // finger lifts at 1200 px/s heading for the detent at 0 (a component
|
|
933
933
|
* // passes the spring of its motion role):
|
|
934
934
|
* animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
|
|
@@ -937,7 +937,7 @@ const REDUCED_TRANSITION: SpringTransition = {
|
|
|
937
937
|
* animator.stop(['y']);
|
|
938
938
|
* ```
|
|
939
939
|
*/
|
|
940
|
-
export function
|
|
940
|
+
export function createMotionEngine(
|
|
941
941
|
element: HTMLElement | null,
|
|
942
942
|
options: AnimatorOptions = {},
|
|
943
943
|
): Animator {
|