xladmin 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -31,22 +31,22 @@ You also need one router adapter:
31
31
  - `FormDialog`
32
32
  - `FieldEditor`
33
33
  - `NavLink`
34
- - `createAxiosXLAdminClient(...)`
35
- - `createFetchXLAdminClient(...)`
36
- - `createBrowserXLAdminRouter(...)`
34
+ - `createAxiosAdminClient(...)`
35
+ - `createFetchAdminClient(...)`
36
+ - `createBrowserAdminRouter(...)`
37
37
  - admin types, i18n helpers, and default theme
38
38
 
39
39
  ## Minimal Example
40
40
 
41
41
  ```tsx
42
42
  import {useEffect, useMemo, useState} from 'react';
43
- import {Shell, OverviewPage, createAxiosXLAdminClient, type AdminModelMeta, type AdminModelsBlockMeta} from 'xladmin';
43
+ import {Shell, OverviewPage, createAxiosAdminClient, type AdminModelMeta, type AdminModelsBlockMeta} from 'xladmin';
44
44
  import axios from 'axios';
45
45
 
46
46
  const api = axios.create({baseURL: '/api/admin'});
47
47
 
48
48
  export function AdminApp() {
49
- const client = useMemo(() => createAxiosXLAdminClient(api), []);
49
+ const client = useMemo(() => createAxiosAdminClient(api), []);
50
50
  const [models, setModels] = useState<AdminModelMeta[]>([]);
51
51
  const [blocks, setBlocks] = useState<AdminModelsBlockMeta[]>([]);
52
52
 
package/dist/cache.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { XLAdminClient } from './client';
1
+ import type { AdminClient } from './client';
2
2
  import type { AdminDetailResponse, AdminListResponse } from './types';
3
3
  type ClientCacheBucket = {
4
4
  detailResponseCache: Map<string, AdminDetailResponse>;
@@ -14,9 +14,9 @@ export declare function buildListCacheKey(slug: string, params: {
14
14
  limit?: number;
15
15
  offset?: number;
16
16
  } & Record<string, unknown>): string;
17
- export declare function getClientCacheBucket(client: XLAdminClient): ClientCacheBucket;
18
- export declare function getModelCacheVersion(client: XLAdminClient, slug: string): number;
19
- export declare function setCachedListResponse(client: XLAdminClient, key: string, response: AdminListResponse): void;
20
- export declare function setCachedDetailResponse(client: XLAdminClient, key: string, response: AdminDetailResponse): void;
21
- export declare function invalidateModelCache(client: XLAdminClient, slug: string): void;
17
+ export declare function getClientCacheBucket(client: AdminClient): ClientCacheBucket;
18
+ export declare function getModelCacheVersion(client: AdminClient, slug: string): number;
19
+ export declare function setCachedListResponse(client: AdminClient, key: string, response: AdminListResponse): void;
20
+ export declare function setCachedDetailResponse(client: AdminClient, key: string, response: AdminDetailResponse): void;
21
+ export declare function invalidateModelCache(client: AdminClient, slug: string): void;
22
22
  export {};
package/dist/client.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import type { AdminChoicesResponse, AdminDeletePreviewResponse, AdminDetailResponse, AdminListResponse, AdminModelMeta, AdminModelsResponse, AdminObjectActionResponse } from './types';
2
- export type XLAdminRequestOptions = {
2
+ export type AdminRequestOptions = {
3
3
  signal?: AbortSignal;
4
4
  };
5
- export type XLAdminSelectionScope = {
5
+ export type AdminSelectionScope = {
6
6
  q?: string;
7
7
  filters?: Record<string, string>;
8
8
  };
9
- export type XLAdminSelectionOptions = {
9
+ export type AdminSelectionOptions = {
10
10
  selectAll?: boolean;
11
- selectionScope?: XLAdminSelectionScope;
11
+ selectionScope?: AdminSelectionScope;
12
12
  };
13
- export type XLAdminClient = {
13
+ export type AdminClient = {
14
14
  getModels: () => Promise<AdminModelsResponse>;
15
15
  getModel: (slug: string) => Promise<AdminModelMeta>;
16
16
  getItems: (slug: string, params?: {
@@ -24,37 +24,37 @@ export type XLAdminClient = {
24
24
  patchItem: (slug: string, id: string | number, payload: Record<string, unknown>) => Promise<AdminDetailResponse>;
25
25
  deleteItem: (slug: string, id: string | number) => Promise<void>;
26
26
  getDeletePreview: (slug: string, id: string | number) => Promise<AdminDeletePreviewResponse>;
27
- bulkDelete: (slug: string, ids: Array<string | number>, options?: XLAdminSelectionOptions) => Promise<{
27
+ bulkDelete: (slug: string, ids: Array<string | number>, options?: AdminSelectionOptions) => Promise<{
28
28
  deleted: number;
29
29
  }>;
30
- getBulkDeletePreview: (slug: string, ids: Array<string | number>, options?: XLAdminSelectionOptions) => Promise<AdminDeletePreviewResponse>;
31
- runBulkAction: (slug: string, actionSlug: string, ids: Array<string | number>, payload?: Record<string, unknown>, options?: XLAdminSelectionOptions) => Promise<{
30
+ getBulkDeletePreview: (slug: string, ids: Array<string | number>, options?: AdminSelectionOptions) => Promise<AdminDeletePreviewResponse>;
31
+ runBulkAction: (slug: string, actionSlug: string, ids: Array<string | number>, payload?: Record<string, unknown>, options?: AdminSelectionOptions) => Promise<{
32
32
  processed: number;
33
33
  } & Record<string, unknown>>;
34
34
  runObjectAction: (slug: string, id: string | number, actionSlug: string, payload?: Record<string, unknown>) => Promise<AdminObjectActionResponse>;
35
- getChoices: (slug: string, fieldName: string, q?: string, ids?: Array<string | number>, options?: XLAdminRequestOptions) => Promise<AdminChoicesResponse>;
36
- getFilterChoices: (slug: string, filterSlug: string, q?: string, ids?: Array<string | number>, options?: XLAdminRequestOptions) => Promise<AdminChoicesResponse>;
35
+ getChoices: (slug: string, fieldName: string, q?: string, ids?: Array<string | number>, options?: AdminRequestOptions) => Promise<AdminChoicesResponse>;
36
+ getFilterChoices: (slug: string, filterSlug: string, q?: string, ids?: Array<string | number>, options?: AdminRequestOptions) => Promise<AdminChoicesResponse>;
37
37
  };
38
- type XLAdminTransportResponse<T> = T | {
38
+ type AdminTransportResponse<T> = T | {
39
39
  data: T;
40
40
  };
41
- export type XLAdminTransport = {
42
- get: <T>(url: string, options?: XLAdminRequestOptions & {
41
+ export type AdminTransport = {
42
+ get: <T>(url: string, options?: AdminRequestOptions & {
43
43
  params?: Record<string, unknown>;
44
- }) => Promise<XLAdminTransportResponse<T>>;
45
- post: <T>(url: string, body?: Record<string, unknown>, options?: XLAdminRequestOptions) => Promise<XLAdminTransportResponse<T>>;
46
- patch: <T>(url: string, body: Record<string, unknown>, options?: XLAdminRequestOptions) => Promise<XLAdminTransportResponse<T>>;
47
- delete: (url: string, options?: XLAdminRequestOptions) => Promise<unknown>;
44
+ }) => Promise<AdminTransportResponse<T>>;
45
+ post: <T>(url: string, body?: Record<string, unknown>, options?: AdminRequestOptions) => Promise<AdminTransportResponse<T>>;
46
+ patch: <T>(url: string, body: Record<string, unknown>, options?: AdminRequestOptions) => Promise<AdminTransportResponse<T>>;
47
+ delete: (url: string, options?: AdminRequestOptions) => Promise<unknown>;
48
48
  };
49
- export type XLAdminAxiosLike = XLAdminTransport;
50
- export type XLAdminFetchClientConfig = {
49
+ export type AdminAxiosLike = AdminTransport;
50
+ export type AdminFetchClientConfig = {
51
51
  baseUrl: string;
52
52
  fetch?: typeof globalThis.fetch;
53
53
  headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
54
54
  credentials?: RequestCredentials;
55
55
  };
56
- export declare function createXLAdminClient(transport: XLAdminTransport): XLAdminClient;
57
- export declare function createAxiosXLAdminClient(api: XLAdminAxiosLike): XLAdminClient;
58
- export declare function createFetchXLAdminClient(config: XLAdminFetchClientConfig): XLAdminClient;
59
- export declare function createFetchXLAdminTransport(config: XLAdminFetchClientConfig): XLAdminTransport;
56
+ export declare function createAdminClient(transport: AdminTransport): AdminClient;
57
+ export declare function createAxiosAdminClient(api: AdminAxiosLike): AdminClient;
58
+ export declare function createFetchAdminClient(config: AdminFetchClientConfig): AdminClient;
59
+ export declare function createFetchAdminTransport(config: AdminFetchClientConfig): AdminTransport;
60
60
  export {};
@@ -1,11 +1,11 @@
1
- import type { XLAdminClient } from '@xladmin-core/client';
1
+ import type { AdminClient } from '@xladmin-core/client';
2
2
  import type { AdminFieldMeta } from '@xladmin-core/types';
3
3
  type AdminFieldEditorProps = {
4
4
  field: AdminFieldMeta;
5
5
  value: unknown;
6
6
  onChange: (value: unknown) => void;
7
7
  slug: string;
8
- client: XLAdminClient;
8
+ client: AdminClient;
9
9
  readOnly?: boolean;
10
10
  };
11
11
  export type FieldEditorProps = AdminFieldEditorProps;
@@ -1,4 +1,4 @@
1
- import type { XLAdminClient } from '../client';
1
+ import type { AdminClient } from '../client';
2
2
  import type { AdminModelMeta } from '../types';
3
3
  type AdminFormDialogProps = {
4
4
  open: boolean;
@@ -8,7 +8,7 @@ type AdminFormDialogProps = {
8
8
  slug: string;
9
9
  mode: 'create' | 'patch';
10
10
  meta: AdminModelMeta;
11
- client: XLAdminClient;
11
+ client: AdminClient;
12
12
  initialValues?: Record<string, unknown>;
13
13
  itemId?: string | number;
14
14
  };
@@ -1,16 +1,16 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { XLAdminClient } from '../client';
3
- import type { XLAdminRouter } from '../router';
2
+ import type { AdminClient } from '../client';
3
+ import type { AdminRouter } from '../router';
4
4
  type AdminModelPageProps = {
5
- client: XLAdminClient;
5
+ client: AdminClient;
6
6
  basePath: string;
7
7
  slug: string;
8
- router?: XLAdminRouter;
8
+ router?: AdminRouter;
9
9
  renderBeforePagination?: (context: ModelPageToolbarContext) => ReactNode;
10
10
  };
11
11
  export type ModelPageProps = AdminModelPageProps;
12
12
  export type ModelPageToolbarContext = {
13
- client: XLAdminClient;
13
+ client: AdminClient;
14
14
  slug: string;
15
15
  meta: {
16
16
  slug: string;
@@ -1,12 +1,12 @@
1
1
  import type { CSSProperties, ReactNode } from 'react';
2
- import type { XLAdminRouter } from '../router';
2
+ import type { AdminRouter } from '../router';
3
3
  type AdminNavLinkProps = {
4
4
  href: string;
5
5
  children: ReactNode;
6
6
  style?: CSSProperties;
7
7
  title?: string;
8
8
  onClick?: () => void;
9
- router?: XLAdminRouter;
9
+ router?: AdminRouter;
10
10
  };
11
11
  export type NavLinkProps = AdminNavLinkProps;
12
12
  export declare function NavLink({ href, children, style, title, onClick, router }: NavLinkProps): import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import 'dayjs/locale/en.js';
2
2
  import 'dayjs/locale/ru.js';
3
- import type { XLAdminClient } from '../client';
4
- import type { XLAdminRouter } from '../router';
3
+ import type { AdminClient } from '../client';
4
+ import type { AdminRouter } from '../router';
5
5
  type AdminObjectPageProps = {
6
- client: XLAdminClient;
6
+ client: AdminClient;
7
7
  slug: string;
8
8
  id: string;
9
- router?: XLAdminRouter;
9
+ router?: AdminRouter;
10
10
  };
11
11
  export type ObjectPageProps = AdminObjectPageProps;
12
12
  export declare function ObjectPage({ client, slug, id, router }: ObjectPageProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
- import type { XLAdminClient } from '../client';
1
+ import type { AdminClient } from '../client';
2
2
  type AdminHomeProps = {
3
- client: XLAdminClient;
3
+ client: AdminClient;
4
4
  basePath: string;
5
5
  };
6
6
  export type OverviewPageProps = AdminHomeProps;
@@ -1,17 +1,17 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import { type Theme } from '@mui/material/styles';
3
- import type { XLAdminClient } from '../client';
4
- import type { XLAdminRouter } from '../router';
3
+ import type { AdminClient } from '../client';
4
+ import type { AdminRouter } from '../router';
5
5
  import type { AdminModelMeta, AdminModelsBlockMeta } from '../types';
6
6
  type AdminShellProps = {
7
- client: XLAdminClient;
7
+ client: AdminClient;
8
8
  models: AdminModelMeta[];
9
9
  blocks: AdminModelsBlockMeta[];
10
10
  basePath: string;
11
11
  locale?: string | null;
12
12
  children: ReactNode;
13
13
  theme?: Theme;
14
- router?: XLAdminRouter;
14
+ router?: AdminRouter;
15
15
  };
16
16
  export type ShellProps = AdminShellProps;
17
17
  export declare function Shell({ client, models, blocks, basePath, locale, children, theme, router }: ShellProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import type { XLAdminClient } from '@xladmin-core/client';
1
+ import type { AdminClient } from '@xladmin-core/client';
2
2
  import type { AdminListFilterMeta } from '@xladmin-core/types';
3
3
  type ListFiltersSidebarProps = {
4
- client: XLAdminClient;
4
+ client: AdminClient;
5
5
  slug: string;
6
6
  filters: AdminListFilterMeta[];
7
7
  values: Record<string, string>;
@@ -1,13 +1,13 @@
1
- import type { XLAdminClient } from '@xladmin-core/client';
1
+ import type { AdminClient } from '@xladmin-core/client';
2
2
  import type { AdminTranslationKey } from '@xladmin-core/i18n';
3
- import type { XLAdminRouter } from '@xladmin-core/router';
3
+ import type { AdminRouter } from '@xladmin-core/router';
4
4
  import type { AdminDeletePreviewResponse, AdminListResponse } from '@xladmin-core/types';
5
5
  type UseModelPageControllerOptions = {
6
- client: XLAdminClient;
6
+ client: AdminClient;
7
7
  slug: string;
8
8
  pathname: string;
9
9
  locationSearch: string;
10
- router: XLAdminRouter;
10
+ router: AdminRouter;
11
11
  t: (key: AdminTranslationKey, params?: Record<string, string | number>) => string;
12
12
  };
13
13
  export declare function useModelPageController({ client, slug, pathname, locationSearch, router, t, }: UseModelPageControllerOptions): {
@@ -1,10 +1,10 @@
1
- import type { XLAdminClient } from '@xladmin-core/client';
1
+ import type { AdminClient } from '@xladmin-core/client';
2
2
  import type { AdminFieldMeta } from '@xladmin-core/types';
3
3
  type ObjectFieldProps = {
4
4
  field: AdminFieldMeta;
5
5
  value: unknown;
6
6
  slug: string;
7
- client: XLAdminClient;
7
+ client: AdminClient;
8
8
  onFieldChange: (fieldName: string, nextValue: unknown) => void;
9
9
  };
10
10
  export declare const ObjectField: import("react").NamedExoticComponent<ObjectFieldProps>;
@@ -1,13 +1,13 @@
1
- import type { XLAdminClient } from '@xladmin-core/client';
1
+ import type { AdminClient } from '@xladmin-core/client';
2
2
  import type { AdminTranslationKey } from '@xladmin-core/i18n';
3
- import type { XLAdminRouter } from '@xladmin-core/router';
3
+ import type { AdminRouter } from '@xladmin-core/router';
4
4
  import type { AdminDeletePreviewResponse, AdminDetailResponse } from '@xladmin-core/types';
5
5
  type UseObjectPageControllerOptions = {
6
- client: XLAdminClient;
6
+ client: AdminClient;
7
7
  slug: string;
8
8
  id: string;
9
9
  listPath: string;
10
- router: XLAdminRouter;
10
+ router: AdminRouter;
11
11
  t: (key: AdminTranslationKey, params?: Record<string, string | number>) => string;
12
12
  };
13
13
  export declare function useObjectPageController({ client, slug, id, listPath, router, t, }: UseObjectPageControllerOptions): {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { createAxiosXLAdminClient, createFetchXLAdminClient, createFetchXLAdminTransport, createXLAdminClient, type XLAdminAxiosLike, type XLAdminClient, type XLAdminFetchClientConfig, type XLAdminRequestOptions, type XLAdminTransport, } from './client';
2
- export { XLAdminRouterProvider, buildUrlWithParams, createBrowserXLAdminRouter, handleNavLinkClick, type XLAdminAnchorProps, type XLAdminLocation, type XLAdminRouter, useXLAdminLocation, useXLAdminRouter, } from './router';
1
+ export { createAxiosAdminClient, createFetchAdminClient, createFetchAdminTransport, createAdminClient, type AdminAxiosLike, type AdminClient, type AdminFetchClientConfig, type AdminRequestOptions, type AdminTransport, } from './client';
2
+ export { AdminRouterProvider, buildUrlWithParams, createBrowserAdminRouter, handleNavLinkClick, type AdminAnchorProps, type AdminLocation, type AdminRouter, useAdminLocation, useAdminRouter, } from './router';
3
3
  export { FormDialog, type FormDialogProps } from './components/FormDialog';
4
4
  export { OverviewPage, type OverviewPageProps } from './components/OverviewPage';
5
5
  export { ModelPage, type ModelPageProps, type ModelPageToolbarContext } from './components/ModelPage';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { createAxiosXLAdminClient, createFetchXLAdminClient, createFetchXLAdminTransport, createXLAdminClient, type XLAdminAxiosLike, type XLAdminClient, type XLAdminFetchClientConfig, type XLAdminRequestOptions, type XLAdminTransport, } from './client';
2
- export { XLAdminRouterProvider, buildUrlWithParams, createBrowserXLAdminRouter, handleNavLinkClick, type XLAdminAnchorProps, type XLAdminLocation, type XLAdminRouter, useXLAdminLocation, useXLAdminRouter, } from './router';
1
+ export { createAxiosAdminClient, createFetchAdminClient, createFetchAdminTransport, createAdminClient, type AdminAxiosLike, type AdminClient, type AdminFetchClientConfig, type AdminRequestOptions, type AdminTransport, } from './client';
2
+ export { AdminRouterProvider, buildUrlWithParams, createBrowserAdminRouter, handleNavLinkClick, type AdminAnchorProps, type AdminLocation, type AdminRouter, useAdminLocation, useAdminRouter, } from './router';
3
3
  export { FormDialog, type FormDialogProps } from './components/FormDialog';
4
4
  export { OverviewPage, type OverviewPageProps } from './components/OverviewPage';
5
5
  export { ModelPage, type ModelPageProps, type ModelPageToolbarContext } from './components/ModelPage';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/client.ts
2
- function createXLAdminClient(transport) {
2
+ function createAdminClient(transport) {
3
3
  return {
4
4
  async getModels() {
5
5
  return await transportGet(transport, "/xladmin/models/");
@@ -81,13 +81,13 @@ function createXLAdminClient(transport) {
81
81
  }
82
82
  };
83
83
  }
84
- function createAxiosXLAdminClient(api) {
85
- return createXLAdminClient(api);
84
+ function createAxiosAdminClient(api) {
85
+ return createAdminClient(api);
86
86
  }
87
- function createFetchXLAdminClient(config) {
88
- return createXLAdminClient(createFetchXLAdminTransport(config));
87
+ function createFetchAdminClient(config) {
88
+ return createAdminClient(createFetchAdminTransport(config));
89
89
  }
90
- function createFetchXLAdminTransport(config) {
90
+ function createFetchAdminTransport(config) {
91
91
  var _a;
92
92
  const fetchImpl = (_a = config.fetch) != null ? _a : globalThis.fetch;
93
93
  if (!fetchImpl) {
@@ -210,12 +210,12 @@ function buildSelectionPayload(ids, payload, options) {
210
210
  // src/router.tsx
211
211
  import { createContext, useContext, useMemo, useRef, useSyncExternalStore } from "react";
212
212
  import { jsx } from "react/jsx-runtime";
213
- var XLAdminRouterContext = createContext(null);
213
+ var AdminRouterContext = createContext(null);
214
214
  var browserRouterInstance = null;
215
- function XLAdminRouterProvider({ router, children }) {
216
- return /* @__PURE__ */ jsx(XLAdminRouterContext.Provider, { value: router, children });
215
+ function AdminRouterProvider({ router, children }) {
216
+ return /* @__PURE__ */ jsx(AdminRouterContext.Provider, { value: router, children });
217
217
  }
218
- function createBrowserXLAdminRouter(browserWindow = window) {
218
+ function createBrowserAdminRouter(browserWindow = window) {
219
219
  return {
220
220
  getLocation: () => ({
221
221
  pathname: browserWindow.location.pathname,
@@ -241,8 +241,8 @@ function createBrowserXLAdminRouter(browserWindow = window) {
241
241
  }
242
242
  };
243
243
  }
244
- function useXLAdminRouter(router) {
245
- const contextRouter = useContext(XLAdminRouterContext);
244
+ function useAdminRouter(router) {
245
+ const contextRouter = useContext(AdminRouterContext);
246
246
  return useMemo(() => {
247
247
  if (router) {
248
248
  return router;
@@ -251,13 +251,13 @@ function useXLAdminRouter(router) {
251
251
  return contextRouter;
252
252
  }
253
253
  if (browserRouterInstance === null) {
254
- browserRouterInstance = createBrowserXLAdminRouter();
254
+ browserRouterInstance = createBrowserAdminRouter();
255
255
  }
256
256
  return browserRouterInstance;
257
257
  }, [contextRouter, router]);
258
258
  }
259
- function useXLAdminLocation(router) {
260
- const resolvedRouter = useXLAdminRouter(router);
259
+ function useAdminLocation(router) {
260
+ const resolvedRouter = useAdminRouter(router);
261
261
  const snapshotRef = useRef(null);
262
262
  const getSnapshot = useMemo(() => () => {
263
263
  const nextLocation = resolvedRouter.getLocation();
@@ -303,15 +303,7 @@ function handleNavLinkClick(event, { href, onClick, router }) {
303
303
 
304
304
  // src/components/FormDialog.tsx
305
305
  import { useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
306
- import {
307
- Alert,
308
- Box,
309
- Button,
310
- Dialog,
311
- DialogActions,
312
- DialogContent,
313
- DialogTitle
314
- } from "@mui/material";
306
+ import { Alert, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
315
307
  import { LocalizationProvider } from "@mui/x-date-pickers";
316
308
  import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
317
309
 
@@ -603,13 +595,7 @@ function trimAdminValue(value, maxLength) {
603
595
 
604
596
  // src/components/FieldEditor.tsx
605
597
  import { memo, useCallback, useEffect as useEffect2, useMemo as useMemo3, useState as useState2 } from "react";
606
- import {
607
- Autocomplete,
608
- CircularProgress,
609
- FormControlLabel,
610
- Switch,
611
- TextField
612
- } from "@mui/material";
598
+ import { Autocomplete, CircularProgress, FormControlLabel, Switch, TextField } from "@mui/material";
613
599
  import { DatePicker, DateTimePicker } from "@mui/x-date-pickers";
614
600
  import dayjs from "dayjs";
615
601
 
@@ -1286,12 +1272,15 @@ function getStorageKey(blockSlug) {
1286
1272
  // src/components/NavLink.tsx
1287
1273
  import { jsx as jsx7 } from "react/jsx-runtime";
1288
1274
  function NavLink({ href, children, style, title, onClick, router }) {
1289
- const resolvedRouter = useXLAdminRouter(router);
1275
+ const resolvedRouter = useAdminRouter(router);
1290
1276
  return /* @__PURE__ */ jsx7(
1291
1277
  "a",
1292
1278
  {
1293
1279
  href,
1294
- style,
1280
+ style: {
1281
+ color: "inherit",
1282
+ ...style
1283
+ },
1295
1284
  title,
1296
1285
  onClick: (event) => handleNavLinkClick(event, { href, onClick, router: resolvedRouter }),
1297
1286
  children
@@ -3103,8 +3092,8 @@ function ModelPage({ client, basePath, slug, router, renderBeforePagination }) {
3103
3092
  const locale = useAdminLocale();
3104
3093
  const t = useAdminTranslation();
3105
3094
  const selectAllLabel = locale === "ru" ? "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435" : "Select All";
3106
- const resolvedRouter = useXLAdminRouter(router);
3107
- const location = useXLAdminLocation(resolvedRouter);
3095
+ const resolvedRouter = useAdminRouter(router);
3096
+ const location = useAdminLocation(resolvedRouter);
3108
3097
  const theme = useTheme2();
3109
3098
  const isMobile = useMediaQuery2(theme.breakpoints.down("md"));
3110
3099
  const controller = useModelPageController({
@@ -3139,7 +3128,7 @@ function ModelPage({ client, basePath, slug, router, renderBeforePagination }) {
3139
3128
  appliedFilters: controller.appliedFilters,
3140
3129
  refresh: controller.refresh
3141
3130
  });
3142
- return /* @__PURE__ */ jsx19(XLAdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsxs12(Stack9, { spacing: 1.5, sx: { height: "100%", minHeight: 0 }, children: [
3131
+ return /* @__PURE__ */ jsx19(AdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsxs12(Stack9, { spacing: 1.5, sx: { height: "100%", minHeight: 0 }, children: [
3143
3132
  /* @__PURE__ */ jsx19(
3144
3133
  MainHeader,
3145
3134
  {
@@ -3541,18 +3530,7 @@ function resolveFieldSortable(field) {
3541
3530
  // src/components/ObjectPage.tsx
3542
3531
  import ArrowBackIcon from "@mui/icons-material/ArrowBack";
3543
3532
  import MoreVertIcon2 from "@mui/icons-material/MoreVert";
3544
- import {
3545
- Alert as Alert6,
3546
- Box as Box12,
3547
- Button as Button5,
3548
- IconButton as IconButton4,
3549
- Menu as Menu2,
3550
- MenuItem as MenuItem3,
3551
- Paper as Paper8,
3552
- Stack as Stack12,
3553
- Typography as Typography6,
3554
- useMediaQuery as useMediaQuery3
3555
- } from "@mui/material";
3533
+ import { Alert as Alert6, Box as Box12, Button as Button5, IconButton as IconButton4, Menu as Menu2, MenuItem as MenuItem3, Paper as Paper8, Stack as Stack12, Typography as Typography6, useMediaQuery as useMediaQuery3 } from "@mui/material";
3556
3534
  import { LocalizationProvider as LocalizationProvider2 } from "@mui/x-date-pickers";
3557
3535
  import { AdapterDayjs as AdapterDayjs2 } from "@mui/x-date-pickers/AdapterDayjs";
3558
3536
  import { useTheme as useTheme3 } from "@mui/material/styles";
@@ -3931,8 +3909,8 @@ function ObjectPage({ client, slug, id, router }) {
3931
3909
  var _a, _b;
3932
3910
  const locale = useAdminLocale();
3933
3911
  const t = useAdminTranslation();
3934
- const resolvedRouter = useXLAdminRouter(router);
3935
- const location = useXLAdminLocation(resolvedRouter);
3912
+ const resolvedRouter = useAdminRouter(router);
3913
+ const location = useAdminLocation(resolvedRouter);
3936
3914
  const pathname = location.pathname;
3937
3915
  const theme = useTheme3();
3938
3916
  const isPhone = useMediaQuery3(theme.breakpoints.down("sm"));
@@ -3955,7 +3933,7 @@ function ObjectPage({ client, slug, id, router }) {
3955
3933
  if (!controller.data || !controller.meta) {
3956
3934
  return /* @__PURE__ */ jsx23(ObjectPageSkeleton, {});
3957
3935
  }
3958
- return /* @__PURE__ */ jsx23(XLAdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsxs15(LocalizationProvider2, { dateAdapter: AdapterDayjs2, adapterLocale: locale, children: [
3936
+ return /* @__PURE__ */ jsx23(AdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsxs15(LocalizationProvider2, { dateAdapter: AdapterDayjs2, adapterLocale: locale, children: [
3959
3937
  /* @__PURE__ */ jsxs15(Stack12, { spacing: 1.5, sx: { height: "100%", minHeight: 0 }, children: [
3960
3938
  /* @__PURE__ */ jsx23(
3961
3939
  MainHeader,
@@ -4297,7 +4275,7 @@ var defaultAdminTheme = createTheme({
4297
4275
  import { Box as Box13 } from "@mui/material";
4298
4276
  import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
4299
4277
  function Main({ children }) {
4300
- const { pathname } = useXLAdminLocation();
4278
+ const { pathname } = useAdminLocation();
4301
4279
  const { pendingPath, pendingView } = useShellContext();
4302
4280
  const normalizeAdminPath2 = (path) => {
4303
4281
  const normalizedPath = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
@@ -4342,7 +4320,7 @@ import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
4342
4320
  var Sidebar = memo8(function Sidebar2({ models, blocks, basePath }) {
4343
4321
  var _a;
4344
4322
  const t = useAdminTranslation();
4345
- const { pathname } = useXLAdminLocation();
4323
+ const { pathname } = useAdminLocation();
4346
4324
  const { pendingPath, startPendingNavigation } = useShellContext();
4347
4325
  const effectivePathname = pendingPath != null ? pendingPath : pathname;
4348
4326
  const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
@@ -4413,8 +4391,8 @@ function normalizeAdminPath(path) {
4413
4391
  function Shell({ client, models, blocks, basePath, locale, children, theme, router }) {
4414
4392
  void client;
4415
4393
  const activeTheme = theme != null ? theme : defaultAdminTheme;
4416
- const resolvedRouter = useXLAdminRouter(router);
4417
- const location = useXLAdminLocation(resolvedRouter);
4394
+ const resolvedRouter = useAdminRouter(router);
4395
+ const location = useAdminLocation(resolvedRouter);
4418
4396
  const pathname = location.pathname;
4419
4397
  const isDesktopSidebar = useMediaQuery4(activeTheme.breakpoints.up("lg"));
4420
4398
  const [isMobileSidebarOpen, setIsMobileSidebarOpen] = useState11(false);
@@ -4450,7 +4428,7 @@ function Shell({ client, models, blocks, basePath, locale, children, theme, rout
4450
4428
  setPendingView(view);
4451
4429
  }
4452
4430
  }), [isDesktopSidebar, pathname, pendingPath, pendingView]);
4453
- return /* @__PURE__ */ jsx26(XLAdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsx26(ThemeProvider, { theme: activeTheme, children: /* @__PURE__ */ jsx26(AdminLocaleProvider, { locale, children: /* @__PURE__ */ jsx26(AdminDataProvider, { value: { locale: locale === "en" ? "en" : "ru", models, blocks }, children: /* @__PURE__ */ jsxs18(ShellContextProvider, { value: shellContextValue, children: [
4431
+ return /* @__PURE__ */ jsx26(AdminRouterProvider, { router: resolvedRouter, children: /* @__PURE__ */ jsx26(ThemeProvider, { theme: activeTheme, children: /* @__PURE__ */ jsx26(AdminLocaleProvider, { locale, children: /* @__PURE__ */ jsx26(AdminDataProvider, { value: { locale: locale === "en" ? "en" : "ru", models, blocks }, children: /* @__PURE__ */ jsxs18(ShellContextProvider, { value: shellContextValue, children: [
4454
4432
  /* @__PURE__ */ jsx26(CssBaseline, {}),
4455
4433
  /* @__PURE__ */ jsx26(
4456
4434
  GlobalStyles,
@@ -4572,6 +4550,7 @@ function Shell({ client, models, blocks, basePath, locale, children, theme, rout
4572
4550
  }
4573
4551
  export {
4574
4552
  AdminLocaleProvider,
4553
+ AdminRouterProvider,
4575
4554
  DeletePreviewDialog,
4576
4555
  FieldEditor,
4577
4556
  FormDialog,
@@ -4584,19 +4563,18 @@ export {
4584
4563
  OverviewPage,
4585
4564
  Shell,
4586
4565
  Sidebar,
4587
- XLAdminRouterProvider,
4588
4566
  buildUrlWithParams,
4589
- createAxiosXLAdminClient,
4590
- createBrowserXLAdminRouter,
4591
- createFetchXLAdminClient,
4592
- createFetchXLAdminTransport,
4593
- createXLAdminClient,
4567
+ createAdminClient,
4568
+ createAxiosAdminClient,
4569
+ createBrowserAdminRouter,
4570
+ createFetchAdminClient,
4571
+ createFetchAdminTransport,
4594
4572
  defaultAdminTheme,
4595
4573
  handleNavLinkClick,
4596
4574
  normalizeAdminLocale,
4597
4575
  translateAdmin,
4598
4576
  useAdminLocale,
4599
- useAdminTranslation,
4600
- useXLAdminLocation,
4601
- useXLAdminRouter
4577
+ useAdminLocation,
4578
+ useAdminRouter,
4579
+ useAdminTranslation
4602
4580
  };
package/dist/router.d.ts CHANGED
@@ -1,31 +1,31 @@
1
1
  import type { CSSProperties, MouseEvent as ReactMouseEvent, ReactNode } from 'react';
2
- export type XLAdminLocation = {
2
+ export type AdminLocation = {
3
3
  pathname: string;
4
4
  search: string;
5
5
  };
6
- export type XLAdminRouter = {
7
- getLocation: () => XLAdminLocation;
6
+ export type AdminRouter = {
7
+ getLocation: () => AdminLocation;
8
8
  subscribe: (listener: () => void) => () => void;
9
9
  push: (href: string) => void;
10
10
  replace: (href: string) => void;
11
11
  back: () => void;
12
12
  };
13
- type XLAdminRouterProviderProps = {
14
- router: XLAdminRouter;
13
+ type AdminRouterProviderProps = {
14
+ router: AdminRouter;
15
15
  children: ReactNode;
16
16
  };
17
17
  type NavigateLinkOptions = {
18
18
  href: string;
19
19
  onClick?: () => void;
20
- router: XLAdminRouter;
20
+ router: AdminRouter;
21
21
  };
22
- export declare function XLAdminRouterProvider({ router, children }: XLAdminRouterProviderProps): import("react/jsx-runtime").JSX.Element;
23
- export declare function createBrowserXLAdminRouter(browserWindow?: Window): XLAdminRouter;
24
- export declare function useXLAdminRouter(router?: XLAdminRouter): XLAdminRouter;
25
- export declare function useXLAdminLocation(router?: XLAdminRouter): XLAdminLocation;
22
+ export declare function AdminRouterProvider({ router, children }: AdminRouterProviderProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function createBrowserAdminRouter(browserWindow?: Window): AdminRouter;
24
+ export declare function useAdminRouter(router?: AdminRouter): AdminRouter;
25
+ export declare function useAdminLocation(router?: AdminRouter): AdminLocation;
26
26
  export declare function buildUrlWithParams(pathname: string, query: string, sort: string, page: number, filters: Record<string, string>): string;
27
27
  export declare function handleNavLinkClick(event: ReactMouseEvent<HTMLAnchorElement>, { href, onClick, router }: NavigateLinkOptions): void;
28
- export type XLAdminAnchorProps = {
28
+ export type AdminAnchorProps = {
29
29
  href: string;
30
30
  children: ReactNode;
31
31
  style?: CSSProperties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xladmin",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Framework-agnostic React + MUI admin frontend for xladmin.",
5
5
  "license": "MIT",
6
6
  "type": "module",