@akanjs/ui 0.9.3 → 0.9.5

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/Link/CsrLink.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { CsrLinkProps } from "./types";
2
- export default function CsrLink({ className, children, href, replace, activeClassName, ...props }: CsrLinkProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function CsrLink({ className, children, href, replace, activeClassName, scrollToTop, ...props }: CsrLinkProps): import("react/jsx-runtime").JSX.Element;
package/Link/types.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface CsrLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
12
12
  children?: ReactNode;
13
13
  replace?: boolean;
14
14
  activeClassName?: string;
15
+ scrollToTop?: boolean;
15
16
  }
16
17
  export interface NextLinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps | "href">, LinkProps {
17
18
  href: string;
@@ -24,7 +24,7 @@ interface ClientPathWrapperProps extends Omit<HTMLAttributes<HTMLDivElement>, "s
24
24
  children?: any;
25
25
  layoutStyle?: "web" | "mobile";
26
26
  }
27
- export declare const ClientPathWrapper: ({ bind, wrapperRef, pageType, location, prefix, children, layoutStyle, ...props }: ClientPathWrapperProps) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const ClientPathWrapper: ({ className, bind, wrapperRef, pageType, location, prefix, children, layoutStyle, ...props }: ClientPathWrapperProps) => import("react/jsx-runtime").JSX.Element;
28
28
  interface ClientBridgeProps {
29
29
  env: BaseClientEnv;
30
30
  lang?: string;
@@ -56,11 +56,11 @@ interface WrapperProps {
56
56
  crystalize: boolean;
57
57
  }) => Promise<{
58
58
  id: string;
59
- }>;
59
+ }> | undefined;
60
60
  fetchSelf?: (props: {
61
61
  crystalize: boolean;
62
62
  }) => Promise<{
63
63
  id: string;
64
- }>;
64
+ }> | undefined;
65
65
  }
66
66
  export {};
@@ -26,7 +26,15 @@ var import_client = require("@akanjs/client");
26
26
  var import_next = require("@akanjs/next");
27
27
  var import_store = require("@akanjs/store");
28
28
  var import_browser = require("@capacitor/browser");
29
- function CsrLink({ className, children, href, replace, activeClassName, ...props }) {
29
+ function CsrLink({
30
+ className,
31
+ children,
32
+ href,
33
+ replace,
34
+ activeClassName,
35
+ scrollToTop,
36
+ ...props
37
+ }) {
30
38
  const prefix = import_store.st.use.prefix();
31
39
  const currentPath = import_store.st.use.path();
32
40
  const { lang } = (0, import_next.usePage)();
@@ -40,9 +48,9 @@ function CsrLink({ className, children, href, replace, activeClassName, ...props
40
48
  if (isExternal)
41
49
  void import_browser.Browser.open({ url: href, presentationStyle: "popover" });
42
50
  else if (replace)
43
- import_client.router.replace(href);
51
+ import_client.router.replace(href, { scrollToTop });
44
52
  else
45
- import_client.router.push(href);
53
+ import_client.router.push(href, { scrollToTop });
46
54
  },
47
55
  children
48
56
  }
@@ -50,6 +50,7 @@ const ClientWrapper = ({ children, theme }) => {
50
50
  };
51
51
  Client.Wrapper = ClientWrapper;
52
52
  const ClientPathWrapper = ({
53
+ className,
53
54
  bind,
54
55
  wrapperRef,
55
56
  pageType = "current",
@@ -87,7 +88,7 @@ const ClientPathWrapper = ({
87
88
  import_web.a.div,
88
89
  {
89
90
  ...bind && pathRoute.pageState.gesture && gestureEnabled ? bind() : {},
90
- className: (0, import_client.clsx)("group/path size-full"),
91
+ className: (0, import_client.clsx)("group/path", className),
91
92
  ref: wrapperRef,
92
93
  ...props,
93
94
  "data-lang": lang,
@@ -33,8 +33,8 @@ const CommonWrapper = ({
33
33
  environment,
34
34
  render,
35
35
  fetchPing,
36
- fetchMe = fetch.me,
37
- fetchSelf = fetch.getSelf
36
+ fetchMe = (props) => fetch.me?.(props),
37
+ fetchSelf = (props) => fetch.getSelf?.(props)
38
38
  }) => {
39
39
  const account = (0, import_client.getAccount)();
40
40
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
@@ -46,14 +46,14 @@ const CommonWrapper = ({
46
46
  loader: async () => {
47
47
  const mePromise = (async () => {
48
48
  try {
49
- return account.me ? await fetchMe?.({ crystalize: false }) : null;
49
+ return account.me ? await fetchMe({ crystalize: false }) : null;
50
50
  } catch (e) {
51
51
  return null;
52
52
  }
53
53
  })();
54
54
  const selfPromise = (async () => {
55
55
  try {
56
- return account.self ? await fetchSelf?.({ crystalize: false }) : null;
56
+ return account.self ? await fetchSelf({ crystalize: false }) : null;
57
57
  } catch (e) {
58
58
  return null;
59
59
  }
@@ -4,7 +4,15 @@ import { clsx, getPathInfo, router } from "@akanjs/client";
4
4
  import { usePage } from "@akanjs/next";
5
5
  import { st } from "@akanjs/store";
6
6
  import { Browser } from "@capacitor/browser";
7
- function CsrLink({ className, children, href, replace, activeClassName, ...props }) {
7
+ function CsrLink({
8
+ className,
9
+ children,
10
+ href,
11
+ replace,
12
+ activeClassName,
13
+ scrollToTop,
14
+ ...props
15
+ }) {
8
16
  const prefix = st.use.prefix();
9
17
  const currentPath = st.use.path();
10
18
  const { lang } = usePage();
@@ -18,9 +26,9 @@ function CsrLink({ className, children, href, replace, activeClassName, ...props
18
26
  if (isExternal)
19
27
  void Browser.open({ url: href, presentationStyle: "popover" });
20
28
  else if (replace)
21
- router.replace(href);
29
+ router.replace(href, { scrollToTop });
22
30
  else
23
- router.push(href);
31
+ router.push(href, { scrollToTop });
24
32
  },
25
33
  children
26
34
  }
@@ -33,6 +33,7 @@ const ClientWrapper = ({ children, theme }) => {
33
33
  };
34
34
  Client.Wrapper = ClientWrapper;
35
35
  const ClientPathWrapper = ({
36
+ className,
36
37
  bind,
37
38
  wrapperRef,
38
39
  pageType = "current",
@@ -70,7 +71,7 @@ const ClientPathWrapper = ({
70
71
  a.div,
71
72
  {
72
73
  ...bind && pathRoute.pageState.gesture && gestureEnabled ? bind() : {},
73
- className: clsx("group/path size-full"),
74
+ className: clsx("group/path", className),
74
75
  ref: wrapperRef,
75
76
  ...props,
76
77
  "data-lang": lang,
@@ -11,8 +11,8 @@ const CommonWrapper = ({
11
11
  environment,
12
12
  render,
13
13
  fetchPing,
14
- fetchMe = fetch.me,
15
- fetchSelf = fetch.getSelf
14
+ fetchMe = (props) => fetch.me?.(props),
15
+ fetchSelf = (props) => fetch.getSelf?.(props)
16
16
  }) => {
17
17
  const account = getAccount();
18
18
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -24,14 +24,14 @@ const CommonWrapper = ({
24
24
  loader: async () => {
25
25
  const mePromise = (async () => {
26
26
  try {
27
- return account.me ? await fetchMe?.({ crystalize: false }) : null;
27
+ return account.me ? await fetchMe({ crystalize: false }) : null;
28
28
  } catch (e) {
29
29
  return null;
30
30
  }
31
31
  })();
32
32
  const selfPromise = (async () => {
33
33
  try {
34
- return account.self ? await fetchSelf?.({ crystalize: false }) : null;
34
+ return account.self ? await fetchSelf({ crystalize: false }) : null;
35
35
  } catch (e) {
36
36
  return null;
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/ui",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"