@starasia/admin 8.32.0 → 9.0.0

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react-router");function s(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const a=s(u),o={useLocation:()=>a.useLocation(),useParams:()=>a.useParams(),useSearchParams:()=>{const[e,t]=a.useSearchParams();return[e,t]},useNavigate:()=>{const e=a.useNavigate();return(t,r)=>{if(typeof t=="number"){e(t);return}e(t,r)}},Link:a.Link,Outlet:a.Outlet};exports.reactRouterAdapter=o;
@@ -0,0 +1,12 @@
1
+ import { StarasiaRouterAdapter } from '../router/types';
2
+
3
+ /**
4
+ * Adapter router untuk react-router (>=7).
5
+ * Hampir passthrough — react-router sudah punya semua primitive yang
6
+ * dibutuhkan kontrak StarasiaRouterAdapter.
7
+ *
8
+ * @example
9
+ * import { reactRouterAdapter } from "@starasia/admin/adapters/react-router";
10
+ * <App routerAdapter={reactRouterAdapter} router={<RouterProvider router={router} />} />
11
+ */
12
+ export declare const reactRouterAdapter: StarasiaRouterAdapter;
@@ -0,0 +1,24 @@
1
+ import * as a from "react-router";
2
+ const s = {
3
+ useLocation: () => a.useLocation(),
4
+ useParams: () => a.useParams(),
5
+ useSearchParams: () => {
6
+ const [r, e] = a.useSearchParams();
7
+ return [r, e];
8
+ },
9
+ useNavigate: () => {
10
+ const r = a.useNavigate();
11
+ return (e, t) => {
12
+ if (typeof e == "number") {
13
+ r(e);
14
+ return;
15
+ }
16
+ r(e, t);
17
+ };
18
+ },
19
+ Link: a.Link,
20
+ Outlet: a.Outlet
21
+ };
22
+ export {
23
+ s as reactRouterAdapter
24
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),r=require("@tanstack/react-router"),S={useLocation:()=>{const e=r.useLocation();return{pathname:e.pathname,search:e.searchStr??"",hash:e.hash??"",state:e.state}},useParams:()=>r.useParams({strict:!1}),useSearchParams:()=>{const e=r.useNavigate(),a=r.useLocation().searchStr??"",o=new URLSearchParams(a);return[o,(c,s)=>{const n=typeof c=="function"?c(new URLSearchParams(o)):c,i=n instanceof URLSearchParams?n:new URLSearchParams(n),u={};i.forEach((h,m)=>{u[m]=h}),e({to:".",search:u,replace:s==null?void 0:s.replace})}]},useNavigate:()=>{const e=r.useNavigate();return(t,a)=>{if(typeof t=="number"){window.history.go(t);return}e({to:t,replace:a==null?void 0:a.replace})}},Link:({to:e,children:t,...a})=>l.createElement(r.Link,{to:e,...a},t),Outlet:r.Outlet};exports.tanstackAdapter=S;
@@ -0,0 +1,20 @@
1
+ import { StarasiaRouterAdapter } from '../router/types';
2
+
3
+ /**
4
+ * Adapter router untuk TanStack Router (>=1).
5
+ *
6
+ * Karena kontrak @starasia/admin string-based (untyped), adapter ini
7
+ * "menurunkan" API typed TanStack ke string:
8
+ * - useParams / useSearch pakai `{ strict: false }`
9
+ * - navigasi pakai `to: "."` (current route) + search object
10
+ *
11
+ * ⚠️ Catatan untuk consumer TanStack:
12
+ * Route yang memakai query-param via FilterBar/useTabState/useRouteInfo
13
+ * sebaiknya punya `validateSearch` yang permisif (mengizinkan key dinamis),
14
+ * karena DS menulis search param secara dinamis.
15
+ *
16
+ * @example
17
+ * import { tanstackAdapter } from "@starasia/admin/adapters/tanstack";
18
+ * <App routerAdapter={tanstackAdapter} router={<RouterProvider router={router} />} />
19
+ */
20
+ export declare const tanstackAdapter: StarasiaRouterAdapter;
@@ -0,0 +1,42 @@
1
+ import P from "react";
2
+ import { Outlet as S, Link as f, useNavigate as o, useLocation as i, useParams as L } from "@tanstack/react-router";
3
+ const R = {
4
+ useLocation: () => {
5
+ const a = i();
6
+ return {
7
+ pathname: a.pathname,
8
+ search: a.searchStr ?? "",
9
+ hash: a.hash ?? "",
10
+ state: a.state
11
+ };
12
+ },
13
+ useParams: () => L({ strict: !1 }),
14
+ useSearchParams: () => {
15
+ const a = o(), e = i().searchStr ?? "", n = new URLSearchParams(e);
16
+ return [n, (t, c) => {
17
+ const s = typeof t == "function" ? t(new URLSearchParams(n)) : t, m = s instanceof URLSearchParams ? s : new URLSearchParams(s), h = {};
18
+ m.forEach((u, l) => {
19
+ h[l] = u;
20
+ }), a({
21
+ to: ".",
22
+ search: h,
23
+ replace: c == null ? void 0 : c.replace
24
+ });
25
+ }];
26
+ },
27
+ useNavigate: () => {
28
+ const a = o();
29
+ return (r, e) => {
30
+ if (typeof r == "number") {
31
+ window.history.go(r);
32
+ return;
33
+ }
34
+ a({ to: r, replace: e == null ? void 0 : e.replace });
35
+ };
36
+ },
37
+ Link: ({ to: a, children: r, ...e }) => P.createElement(f, { to: a, ...e }, r),
38
+ Outlet: S
39
+ };
40
+ export {
41
+ R as tanstackAdapter
42
+ };
@@ -1,4 +1,4 @@
1
- import { SetURLSearchParams } from 'react-router';
1
+ import { SetSearchParams } from '../../router/types';
2
2
  import { FilterConfig } from './FilterDrawer';
3
3
  import { IconName } from '@starasia/icon';
4
4
 
@@ -32,7 +32,7 @@ export type ChangeHandler = (params: {
32
32
  name?: string;
33
33
  type?: InputType;
34
34
  withSearchParam?: boolean;
35
- setSearchParams: SetURLSearchParams;
35
+ setSearchParams: SetSearchParams;
36
36
  searchQueries: Record<string, string>;
37
37
  dropdownSearchKey?: string;
38
38
  filterKey?: string;
@@ -1,9 +1,17 @@
1
1
  import { default as React, PropsWithChildren } from 'react';
2
2
  import { SidebarMenuItem, SidebarMenus } from '../../types';
3
3
  import { ThemeObject } from '@starasia/theme';
4
+ import { StarasiaRouterAdapter } from '../../router';
4
5
 
5
6
  interface AppProps extends PropsWithChildren {
6
7
  router: React.ReactNode;
8
+ /**
9
+ * Router adapter — menghubungkan komponen @starasia/admin ke router consumer.
10
+ * Wajib. Import dari:
11
+ * '@starasia/admin/adapters/react-router' → reactRouterAdapter
12
+ * '@starasia/admin/adapters/tanstack' → tanstackAdapter
13
+ */
14
+ routerAdapter: StarasiaRouterAdapter;
7
15
  menus: SidebarMenus;
8
16
  menuBottom?: SidebarMenuItem[];
9
17
  logo: string;
@@ -15,8 +23,8 @@ interface AppProps extends PropsWithChildren {
15
23
  photoURL?: string;
16
24
  } | null;
17
25
  }
18
- export declare const AppComponent: ({ router, menus, menuBottom, logo, appName, initialUserData, theme, }: AppProps) => React.JSX.Element;
19
- export declare const App: React.MemoExoticComponent<({ router, menus, menuBottom, logo, appName, initialUserData, theme, }: AppProps) => React.JSX.Element>;
26
+ export declare const AppComponent: ({ router, routerAdapter, menus, menuBottom, logo, appName, initialUserData, theme, }: AppProps) => React.JSX.Element;
27
+ export declare const App: React.MemoExoticComponent<({ router, routerAdapter, menus, menuBottom, logo, appName, initialUserData, theme, }: AppProps) => React.JSX.Element>;
20
28
  export * from './hooks';
21
29
  export * from './context';
22
30
  export * from './sidebarBadges';
@@ -1,14 +1,14 @@
1
- import { useSearchParams, Location } from 'react-router';
1
+ import { RouterLocation, SetSearchParams } from '../router/types';
2
2
 
3
3
  type UseRouteInfoReturn = {
4
- setSearchParams: ReturnType<typeof useSearchParams>[1];
4
+ setSearchParams: SetSearchParams;
5
5
  searchParams: URLSearchParams;
6
6
  searchQueries: Record<string, string>;
7
7
  isHasQuery: (key: string, value: string) => boolean;
8
8
  getQueryParam: (key: string) => string | null;
9
9
  getRouteParam: (key: string) => string | undefined;
10
10
  params: Record<string, string | undefined>;
11
- location: Location;
11
+ location: RouterLocation;
12
12
  id?: string;
13
13
  hasId: boolean;
14
14
  };
@@ -1,14 +1,14 @@
1
- import { useSearchParams, Location } from 'react-router';
1
+ import { RouterLocation, SetSearchParams } from '../router/types';
2
2
 
3
3
  type UseRouteParamsReturn = {
4
- setSearchParams: ReturnType<typeof useSearchParams>[1];
4
+ setSearchParams: SetSearchParams;
5
5
  searchParams: URLSearchParams;
6
6
  searchQueries: Record<string, string>;
7
7
  isHasQuery: (key: string, value: string) => boolean;
8
8
  getQueryParam: (key: string) => string | null;
9
9
  getRouteParam: (key: string) => string | undefined;
10
10
  params: Record<string, string | undefined>;
11
- location: Location;
11
+ location: RouterLocation;
12
12
  id?: string;
13
13
  hasId: boolean;
14
14
  };