akanjs 3.3.0-rc.24 → 3.3.0-rc.25
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/package.json +1 -1
- package/types/ui/recipe/badgeRecipe.d.ts +2 -2
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/ui/recipe/inputRecipe.d.ts +2 -2
- package/types/webkit/isDragLift.d.ts +5 -0
- package/types/webkit/useCsrRefs.d.ts +1 -1
- package/webkit/isDragLift.ts +7 -0
- package/webkit/useCsrTransitions.ts +13 -7
package/package.json
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const badgeRecipe: (variants?: Omit<({
|
|
3
3
|
size?: "lg" | "md" | "sm" | "xs" | undefined;
|
|
4
4
|
outline?: boolean | undefined;
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
|
|
6
6
|
} & {
|
|
7
7
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
8
8
|
className?: never;
|
|
9
9
|
}) | ({
|
|
10
10
|
size?: "lg" | "md" | "sm" | "xs" | undefined;
|
|
11
11
|
outline?: boolean | undefined;
|
|
12
|
-
variant?: "
|
|
12
|
+
variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
|
|
13
13
|
} & {
|
|
14
14
|
class?: never;
|
|
15
15
|
className?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const buttonRecipe: (variants?: Omit<({
|
|
3
3
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
|
|
4
4
|
outline?: boolean | undefined;
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
|
|
6
6
|
shape?: "default" | "circle" | "square" | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -10,7 +10,7 @@ export declare const buttonRecipe: (variants?: Omit<({
|
|
|
10
10
|
}) | ({
|
|
11
11
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
|
|
12
12
|
outline?: boolean | undefined;
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
|
|
14
14
|
shape?: "default" | "circle" | "square" | undefined;
|
|
15
15
|
} & {
|
|
16
16
|
class?: never;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const inputRecipe: (variants?: Omit<({
|
|
3
3
|
kind?: "field" | "select" | "area" | undefined;
|
|
4
4
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
5
|
-
tone?: "
|
|
5
|
+
tone?: "default" | "error" | "primary" | undefined;
|
|
6
6
|
} & {
|
|
7
7
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
8
8
|
className?: never;
|
|
9
9
|
}) | ({
|
|
10
10
|
kind?: "field" | "select" | "area" | undefined;
|
|
11
11
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
12
|
-
tone?: "
|
|
12
|
+
tone?: "default" | "error" | "primary" | undefined;
|
|
13
13
|
} & {
|
|
14
14
|
class?: never;
|
|
15
15
|
className?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a drag ended because the finger or the button let go. A drag the browser or the system takes over (a native
|
|
3
|
+
* scroll, an edge gesture) ends in `pointercancel` with the finger still down, so only a lift may act on its release.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isDragLift: (event: Event | undefined) => boolean;
|
|
@@ -17,8 +17,8 @@ export declare const useCsrRefs: () => {
|
|
|
17
17
|
pageContentRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
18
|
prevPageContentRef: import("react").RefObject<HTMLDivElement | null>;
|
|
19
19
|
onBack: import("react").RefObject<{
|
|
20
|
-
stack?: (() => Promise<void>) | undefined;
|
|
21
20
|
none?: (() => Promise<void>) | undefined;
|
|
21
|
+
stack?: (() => Promise<void>) | undefined;
|
|
22
22
|
fade?: (() => Promise<void>) | undefined;
|
|
23
23
|
bottomUp?: (() => Promise<void>) | undefined;
|
|
24
24
|
scaleOut?: (() => Promise<void>) | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const liftTypes = new Set(["pointerup", "touchend", "mouseup"]);
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether a drag ended because the finger or the button let go. A drag the browser or the system takes over (a native
|
|
5
|
+
* scroll, an edge gesture) ends in `pointercancel` with the finger still down, so only a lift may act on its release.
|
|
6
|
+
*/
|
|
7
|
+
export const isDragLift = (event: Event | undefined) => !!event && liftTypes.has(event.type);
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { clamp } from "akanjs/common";
|
|
14
14
|
import { type RefObject, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
15
15
|
import { CsrSlide, type CsrSlideFrame } from "./csrSlide";
|
|
16
|
+
import { isDragLift } from "./isDragLift";
|
|
16
17
|
import { STACK_TRANSITION_DURATION_MS } from "./useFrameRuntime";
|
|
17
18
|
|
|
18
19
|
const linearEasing = (t: number) => t;
|
|
@@ -468,7 +469,7 @@ const useStackTrans = (routeState: RouteState): UseCsrTransition => {
|
|
|
468
469
|
const dragOriginRef = useRef(0);
|
|
469
470
|
|
|
470
471
|
const pageBind = useDrag(
|
|
471
|
-
({ first, last, movement: [mx, my], velocity: [vx], direction: [dx], initial: [ix], cancel }) => {
|
|
472
|
+
({ first, last, movement: [mx, my], velocity: [vx], direction: [dx], initial: [ix], cancel, event }) => {
|
|
472
473
|
if (first) {
|
|
473
474
|
gestureIntent.current = "pending";
|
|
474
475
|
stackBackConfigRef.current = null;
|
|
@@ -503,7 +504,8 @@ const useStackTrans = (routeState: RouteState): UseCsrTransition => {
|
|
|
503
504
|
else if (unit > transUnitRange[0]) void transUnit.start(transUnitRange[0], { immediate: true });
|
|
504
505
|
else if (!last) void transUnit.start(unit, { immediate: true });
|
|
505
506
|
if (last) {
|
|
506
|
-
const shouldComplete =
|
|
507
|
+
const shouldComplete =
|
|
508
|
+
isDragLift(event) && (unit > threshold || (dx > 0 && vx > STACK_VELOCITY_DISMISS_THRESHOLD));
|
|
507
509
|
const target = shouldComplete ? transUnitRange[0] : transUnitRange[1];
|
|
508
510
|
const duration = getVelocityAwareDuration(target - unit, vx, shouldComplete ? 150 : 180);
|
|
509
511
|
if (shouldComplete) stackBackConfigRef.current = { duration };
|
|
@@ -519,7 +521,8 @@ const useStackTrans = (routeState: RouteState): UseCsrTransition => {
|
|
|
519
521
|
});
|
|
520
522
|
}
|
|
521
523
|
},
|
|
522
|
-
|
|
524
|
+
|
|
525
|
+
{ filterTaps: true, pointer: { capture: false } },
|
|
523
526
|
);
|
|
524
527
|
|
|
525
528
|
return {
|
|
@@ -585,7 +588,7 @@ const useBottomUpTrans = (routeState: RouteState): UseCsrTransition => {
|
|
|
585
588
|
usePlayOnForward(spring, routeState, { duration: 220, easing: linearEasing });
|
|
586
589
|
|
|
587
590
|
const pageBind = useDrag(
|
|
588
|
-
({ first, last, movement: [, my], initial: [, iy], cancel }) => {
|
|
591
|
+
({ first, last, movement: [, my], initial: [, iy], cancel, event }) => {
|
|
589
592
|
if (iy > initThreshold) {
|
|
590
593
|
cancel();
|
|
591
594
|
return;
|
|
@@ -594,12 +597,15 @@ const useBottomUpTrans = (routeState: RouteState): UseCsrTransition => {
|
|
|
594
597
|
if (my < transUnitRange[1]) void transUnit.start(transUnitRange[1], { immediate: true });
|
|
595
598
|
else if (my > transUnitRange[0]) void transUnit.start(transUnitRange[0], { immediate: true });
|
|
596
599
|
else if (!last) void transUnit.start(my, { immediate: true });
|
|
597
|
-
|
|
598
|
-
if (!
|
|
600
|
+
if (!last) return;
|
|
601
|
+
if (!isDragLift(event) || my <= threshold) {
|
|
602
|
+
void transUnit.start(transUnitRange[1]);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
599
605
|
clientRouter.back();
|
|
600
606
|
void clientRouter.navigation().catch(() => transUnit.start(transUnitRange[1]));
|
|
601
607
|
},
|
|
602
|
-
{ axis: "y", filterTaps: true, threshold: 10 },
|
|
608
|
+
{ axis: "y", filterTaps: true, threshold: 10, pointer: { capture: false } },
|
|
603
609
|
);
|
|
604
610
|
|
|
605
611
|
return {
|