akanjs 3.3.0-rc.22 → 3.3.0-rc.23
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/nativeNavigation.d.ts +2 -0
- package/types/webkit/useCsrRefs.d.ts +1 -1
- package/webkit/nativeNavigation.ts +29 -0
- package/webkit/useCsrValues.ts +2 -0
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;
|
|
@@ -34,6 +34,8 @@ export declare class NativeNavigation {
|
|
|
34
34
|
openDeepLink(url: string): void;
|
|
35
35
|
openPushLink(url: unknown): void;
|
|
36
36
|
back(): void;
|
|
37
|
+
/** The frame's word that a move was sent back to the page on screen before it showed, as a refusing guard does. */
|
|
38
|
+
static turnedBack(): void;
|
|
37
39
|
static isMacBackKey({ key, metaKey, altKey, ctrlKey, shiftKey, }: Pick<KeyboardEvent, "key" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">): boolean;
|
|
38
40
|
}
|
|
39
41
|
export {};
|
|
@@ -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;
|
|
@@ -27,6 +27,9 @@ interface NativeNavigationOptions {
|
|
|
27
27
|
|
|
28
28
|
/** A native shell's deep links, push taps and Android back button, for the CSR frame that owns the history. */
|
|
29
29
|
export class NativeNavigation {
|
|
30
|
+
|
|
31
|
+
static #fallingBack: { navigation: NativeNavigation; path: string; navigations: number; redirects: number } | null =
|
|
32
|
+
null;
|
|
30
33
|
#mountedAt = Date.now();
|
|
31
34
|
#handled: { href: string; handledAt: number } | null = null;
|
|
32
35
|
#didResetStack = false;
|
|
@@ -95,6 +98,7 @@ export class NativeNavigation {
|
|
|
95
98
|
* is history, or the index is still to come. Otherwise the system takes it and shows its own back-to-home animation.
|
|
96
99
|
*/
|
|
97
100
|
syncBack(force = false) {
|
|
101
|
+
this.#leaveIfSentBack();
|
|
98
102
|
if (!isNativeApp() || !app.isSupported("setBackEnabled")) return;
|
|
99
103
|
const backState = this.options.backState();
|
|
100
104
|
const enabled =
|
|
@@ -155,6 +159,31 @@ export class NativeNavigation {
|
|
|
155
159
|
return;
|
|
156
160
|
}
|
|
157
161
|
clientRouter.backOrFallback(window.__AKAN_MOBILE_TARGET__?.indexPath ?? "/", { scrollToTop: false });
|
|
162
|
+
NativeNavigation.#fallingBack = {
|
|
163
|
+
navigation: this,
|
|
164
|
+
path: backState.path,
|
|
165
|
+
navigations: clientRouter.navigationCount(),
|
|
166
|
+
redirects: clientRouter.redirectCount(),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The frame's word that a move was sent back to the page on screen before it showed, as a refusing guard does. */
|
|
171
|
+
static turnedBack() {
|
|
172
|
+
const fallingBack = NativeNavigation.#fallingBack;
|
|
173
|
+
if (fallingBack) fallingBack.navigation.#leaveIfSentBack();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#leaveIfSentBack() {
|
|
177
|
+
const fallingBack = NativeNavigation.#fallingBack;
|
|
178
|
+
if (fallingBack?.navigation !== this) return;
|
|
179
|
+
const redirects = clientRouter.redirectCount() - fallingBack.redirects;
|
|
180
|
+
if (clientRouter.navigationCount() - fallingBack.navigations !== redirects) {
|
|
181
|
+
NativeNavigation.#fallingBack = null;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!redirects || this.options.historyIdx() > 0 || this.options.backState().path !== fallingBack.path) return;
|
|
185
|
+
NativeNavigation.#fallingBack = null;
|
|
186
|
+
void app.exit().catch(() => undefined);
|
|
158
187
|
}
|
|
159
188
|
|
|
160
189
|
#leavesApp(path: string) {
|
package/webkit/useCsrValues.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { isNativeApp, openExternalUrl } from "akanjs/client/native";
|
|
19
19
|
import { useCallback, useMemo, useState } from "react";
|
|
20
20
|
import { CsrRefresh } from "./csrRefresh";
|
|
21
|
+
import { NativeNavigation } from "./nativeNavigation";
|
|
21
22
|
import { useCsrKeyboard } from "./useCsrKeyboard";
|
|
22
23
|
import { type CsrLocationState, useCsrLocationState } from "./useCsrLocationState";
|
|
23
24
|
import { type CsrNavigation, useCsrNavigation } from "./useCsrNavigation";
|
|
@@ -66,6 +67,7 @@ const useCsrRouter = ({
|
|
|
66
67
|
|
|
67
68
|
const cancelled: NavigationIntent | null = cancelPendingNavigation();
|
|
68
69
|
if (location.href === href) {
|
|
70
|
+
if (cancelled) NativeNavigation.turnedBack();
|
|
69
71
|
if (!pageContentRef.current) return;
|
|
70
72
|
pageContentRef.current.scrollTop = getScrollTop(location);
|
|
71
73
|
return;
|