muffin-admin 3.19.0 → 4.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.
@@ -18,7 +18,7 @@ export function MuffinAdmin(props) {
18
18
  deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
19
19
  ]))
20
20
  : muffinTranslations);
21
- const { basename, authProvider = findBuilder(["authprovider"])(auth), dataProvider = findBuilder(["dataprovider"])(apiUrl), catchAll, dashboard = findBuilder(["dashboard"]), disableTelemetry, error, i18nProvider = muffinI18nProvider, layout = findBuilder(["layout"]), loading, loginPage = findBuilder(["loginpage"]), authCallbackPage, notification, queryClient, requireAuth = auth.required, store = localStorageStore(), ready, theme, lightTheme, darkTheme, defaultTheme, title = "React Admin", } = props;
21
+ const { basename, authProvider = findBuilder(["auth-provider"])(auth), dataProvider = findBuilder(["data-provider"])(apiUrl), catchAll, dashboard = findBuilder(["dashboard"]), disableTelemetry, error, i18nProvider = muffinI18nProvider, layout = findBuilder(["layout"]), loading, loginPage = findBuilder(["loginpage"]), authCallbackPage, notification, queryClient, requireAuth = auth.required, store = localStorageStore(), ready, theme, lightTheme, darkTheme, defaultTheme, title = "React Admin", } = props;
22
22
  return (_jsx(AdminContext, { authProvider: authProvider, basename: basename, dataProvider: dataProvider, i18nProvider: i18nProvider, store: store, queryClient: queryClient, theme: theme, lightTheme: lightTheme, darkTheme: darkTheme, defaultTheme: defaultTheme, children: _jsx(ConfirmationProvider, { children: _jsx(AdminUI, { layout: layout, dashboard: dashboard, disableTelemetry: disableTelemetry, catchAll: catchAll, error: error, title: title, loading: loading, loginPage: loginPage, authCallbackPage: authCallbackPage, notification: notification, requireAuth: requireAuth, ready: ready, children: resources === null || resources === void 0 ? void 0 : resources.map(({ name }) => buildAdmin(["resource", name], { name })) }) }) }));
23
23
  }
24
24
  setupAdmin(["admin"], MuffinAdmin);
@@ -78,4 +78,4 @@ export function MuffinAuthProvider(props) {
78
78
  }),
79
79
  };
80
80
  }
81
- setupAdmin(["authprovider"], MuffinAuthProvider);
81
+ setupAdmin(["auth-provider"], MuffinAuthProvider);
package/dist/buildRA.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare function buildRAComponent(name: any, props: any): import("react/jsx-runtime").JSX.Element;
1
+ export declare function buildRAComponent(name: string, props: any): import("react/jsx-runtime").JSX.Element;
2
2
  export declare function buildRA(items: [string, Record<string, any>][]): import("react/jsx-runtime").JSX.Element[];
3
- export declare function registerUI(name: any, component: any): void;
3
+ export declare function registerUI(name: string, component: JSX.ElementType): void;
@@ -81,13 +81,10 @@ export function BulkActionButton(_a) {
81
81
  function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id, help, }) {
82
82
  const resource = useResourceContext();
83
83
  const [payloadActive, setPayloadActive] = useState(false);
84
- const PayloadBuilder = findBuilder(["action", "payload", id, resource]) || (schema && CommonPayload);
85
- return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: () => {
86
- if (PayloadBuilder)
87
- setPayloadActive(true);
88
- else
89
- onHandle();
90
- }, disabled: isPending, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: onHandle, onClose: () => setPayloadActive(false), title: title || label, schema: schema, help: help }))] }));
84
+ const PayloadForm = findBuilder(["action-form", id, resource]) || (schema && CommonPayload);
85
+ if (!PayloadForm)
86
+ return (_jsx(Button, { label: label, title: title, onClick: onHandle, disabled: isPending, children: buildIcon(icon) }));
87
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: () => setPayloadActive(true), disabled: isPending, children: buildIcon(icon) }), _jsx(PayloadForm, { active: payloadActive, onHandle: onHandle, onClose: () => setPayloadActive(false), title: title || label, schema: schema, help: help })] }));
91
88
  }
92
89
  export function CommonPayload({ active, onClose, onHandle, schema, title, help, }) {
93
90
  schema[0][1] = Object.assign(Object.assign({}, schema[0][1]), { autoFocus: true });
@@ -1,3 +1,4 @@
1
+ import { TID } from "./types";
1
2
  import { APIParams } from "./utils";
2
3
  export declare function MuffinDataprovider(apiUrl: string): {
3
4
  request: (url: string, options?: APIParams) => Promise<{
@@ -8,47 +9,50 @@ export declare function MuffinDataprovider(apiUrl: string): {
8
9
  data: any;
9
10
  total: number;
10
11
  }>;
11
- getOne: (resource: any, { id }: {
12
- id: any;
12
+ getOne: (resource: string, { id }: {
13
+ id: TID;
13
14
  }) => Promise<{
14
15
  data: any;
15
16
  headers: Headers;
16
17
  }>;
17
- create: (resource: any, { data }: {
18
+ create: (resource: string, { data }: {
18
19
  data: any;
19
20
  }) => Promise<{
20
21
  data: any;
21
22
  headers: Headers;
22
23
  }>;
23
- update: (resource: any, { id, data }: {
24
- id: any;
24
+ update: (resource: string, { id, data }: {
25
+ id: TID;
25
26
  data: any;
26
27
  }) => Promise<{
27
28
  data: any;
28
29
  }>;
29
- updateMany: (resource: any, { ids, data }: {
30
- ids: any;
30
+ updateMany: (resource: string, { ids, data }: {
31
+ ids: TID[];
31
32
  data: any;
32
33
  }) => Promise<{
33
- data: any;
34
+ data: TID[];
34
35
  }>;
35
- delete: (resource: any, { id }: {
36
- id: any;
36
+ delete: (resource: string, { id }: {
37
+ id: TID;
37
38
  }) => Promise<{
38
39
  data: {
39
- id: any;
40
+ id: TID;
40
41
  };
41
42
  }>;
42
- deleteMany: (resource: any, { ids }: {
43
- ids: any;
43
+ deleteMany: (resource: string, { ids }: {
44
+ ids: TID[][];
44
45
  }) => Promise<{
45
- data: any;
46
+ data: TID[][];
46
47
  }>;
47
- getMany: (resource: any, props: any) => Promise<{
48
+ getMany: (resource: string, props: {
49
+ ids: TID[];
50
+ meta: any;
51
+ }) => Promise<{
48
52
  data: any;
49
53
  total: number;
50
54
  }>;
51
- getManyReference: (resource: any, { target, id, filter, ...opts }: {
55
+ getManyReference: (resource: string, { target, id, filter, ...opts }: {
52
56
  [x: string]: any;
53
57
  target: any;
54
58
  id: any;
@@ -104,4 +104,4 @@ export function MuffinDataprovider(apiUrl) {
104
104
  };
105
105
  return methods;
106
106
  }
107
- setupAdmin(["dataprovider"], MuffinDataprovider);
107
+ setupAdmin(["data-provider"], MuffinDataprovider);