muffin-admin 3.18.8 → 3.20.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.
- package/dist/MuffinAdmin.js +1 -1
- package/dist/MuffinResourceCreate.d.ts +3 -1
- package/dist/MuffinResourceCreate.js +7 -4
- package/dist/MuffinResourceEdit.d.ts +4 -3
- package/dist/MuffinResourceEdit.js +8 -8
- package/dist/MuffinResourceList.d.ts +2 -1
- package/dist/MuffinResourceList.js +2 -2
- package/dist/MuffinResourceShow.d.ts +5 -4
- package/dist/MuffinResourceShow.js +9 -9
- package/dist/authprovider.js +1 -1
- package/dist/buildRA.d.ts +2 -2
- package/dist/buttons/ActionButton.js +1 -1
- package/dist/dataprovider.d.ts +20 -16
- package/dist/dataprovider.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/utils.d.ts +4 -3
- package/package.json +2 -1
- package/src/MuffinAdmin.tsx +2 -2
- package/src/MuffinDashboard.tsx +2 -2
- package/src/MuffinResourceCreate.tsx +13 -6
- package/src/MuffinResourceEdit.tsx +7 -3
- package/src/MuffinResourceList.tsx +3 -1
- package/src/MuffinResourceShow.tsx +16 -5
- package/src/authprovider.ts +1 -1
- package/src/buildRA.tsx +2 -2
- package/src/buttons/ActionButton.tsx +2 -3
- package/src/dataprovider.ts +10 -9
- package/src/fields/AvatarField.tsx +1 -1
- package/src/types.ts +38 -0
- package/src/utils.tsx +5 -4
package/dist/MuffinAdmin.js
CHANGED
|
@@ -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(["
|
|
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);
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export declare function MuffinResourceCreate({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MuffinCreateToolbar({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Create, ListButton, SimpleForm, TopToolbar } from "react-admin";
|
|
3
3
|
import { buildRA } from "./buildRA";
|
|
4
4
|
import { useMuffinResourceOpts } from "./hooks";
|
|
5
5
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
6
|
-
export function MuffinResourceCreate() {
|
|
6
|
+
export function MuffinResourceCreate({ children }) {
|
|
7
7
|
const { name, create } = useMuffinResourceOpts();
|
|
8
8
|
if (!create)
|
|
9
9
|
return null;
|
|
10
10
|
const ActionsToolbar = findBuilder(["create-toolbar", name]);
|
|
11
|
-
return (
|
|
11
|
+
return (_jsxs(Create, { actions: _jsx(ActionsToolbar, {}), children: [children, _jsx(SimpleForm, { children: buildAdmin(["create-inputs", name], create) })] }));
|
|
12
12
|
}
|
|
13
13
|
setupAdmin(["create"], MuffinResourceCreate);
|
|
14
14
|
setupAdmin(["create-inputs"], buildRA);
|
|
15
|
-
|
|
15
|
+
export function MuffinCreateToolbar({ children }) {
|
|
16
|
+
return (_jsxs(TopToolbar, { children: [children, _jsx(ListButton, {})] }));
|
|
17
|
+
}
|
|
18
|
+
setupAdmin(["create-toolbar"], MuffinCreateToolbar);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export declare function MuffinEdit({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MuffinEditToolbar({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function MuffinEditActions({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,30 +4,30 @@ import { buildRA } from "./buildRA";
|
|
|
4
4
|
import { ActionButton } from "./buttons";
|
|
5
5
|
import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks";
|
|
6
6
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
7
|
-
export function MuffinEdit() {
|
|
7
|
+
export function MuffinEdit({ children }) {
|
|
8
8
|
const { adminProps: { mutationMode = "optimistic" }, } = useMuffinAdminOpts();
|
|
9
9
|
const { edit, name } = useMuffinResourceOpts();
|
|
10
10
|
if (!edit)
|
|
11
11
|
return null;
|
|
12
12
|
const { inputs, remove } = edit;
|
|
13
13
|
const ActionsToolbar = findBuilder(["edit-toolbar", name]);
|
|
14
|
-
return (
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return (_jsxs(Edit, { actions: _jsx(ActionsToolbar, {}), mutationMode: mutationMode, children: [children, _jsx(SimpleForm, { toolbar: _jsxs(Toolbar, { children: [_jsx(SaveButton, {}), remove && (_jsx(DeleteButton, { sx: {
|
|
15
|
+
marginLeft: "auto",
|
|
16
|
+
} }))] }), children: buildAdmin(["edit-inputs", name], inputs) })] }));
|
|
17
17
|
}
|
|
18
18
|
setupAdmin(["edit"], MuffinEdit);
|
|
19
19
|
setupAdmin(["edit-inputs"], buildRA);
|
|
20
|
-
export function MuffinEditToolbar() {
|
|
20
|
+
export function MuffinEditToolbar({ children }) {
|
|
21
21
|
const resource = useResourceContext();
|
|
22
22
|
const Actions = findBuilder(["edit-actions", resource]);
|
|
23
|
-
return (_jsxs(TopToolbar, { children: [_jsx(Actions, {}), _jsx(ListButton, {}), _jsx(ShowButton, {})] }));
|
|
23
|
+
return (_jsxs(TopToolbar, { children: [_jsx(Actions, {}), children, _jsx(ListButton, {}), _jsx(ShowButton, {})] }));
|
|
24
24
|
}
|
|
25
25
|
setupAdmin(["edit-toolbar"], MuffinEditToolbar);
|
|
26
|
-
export function MuffinEditActions() {
|
|
26
|
+
export function MuffinEditActions({ children }) {
|
|
27
27
|
const { edit, actions: baseActions = [] } = useMuffinResourceOpts();
|
|
28
28
|
if (!edit)
|
|
29
29
|
return null;
|
|
30
30
|
const actions = baseActions.filter((a) => { var _a; return (_a = a.view) === null || _a === void 0 ? void 0 : _a.includes("edit"); });
|
|
31
|
-
return (
|
|
31
|
+
return (_jsxs(_Fragment, { children: [children, actions.map((props, idx) => (_jsx(ActionButton, Object.assign({}, props), idx)))] }));
|
|
32
32
|
}
|
|
33
33
|
setupAdmin(["edit-actions"], MuffinEditActions);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export declare function MuffinList({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,12 +7,12 @@ import { BulkActionButton, ListActionButton } from "./buttons";
|
|
|
7
7
|
import { HelpLink } from "./common/HelpLink";
|
|
8
8
|
import { useMuffinResourceOpts } from "./hooks";
|
|
9
9
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
10
|
-
export function MuffinList() {
|
|
10
|
+
export function MuffinList({ children }) {
|
|
11
11
|
const { name, list } = useMuffinResourceOpts();
|
|
12
12
|
const { limit, limitMax, filters, sort } = list;
|
|
13
13
|
const DataGrid = findBuilder(["list-grid", name]);
|
|
14
14
|
const Toolbar = findBuilder(["list-toolbar", name]);
|
|
15
|
-
return (
|
|
15
|
+
return (_jsxs(List, { sort: sort, perPage: limit, actions: _jsx(Toolbar, {}), filters: buildAdmin(["list-filters", name], filters), pagination: _jsx(Pagination, { rowsPerPageOptions: sortBy(uniq([10, 25, 50, 100, limit, limitMax])) }), children: [children, _jsx(DataGrid, {})] }));
|
|
16
16
|
}
|
|
17
17
|
setupAdmin(["list"], MuffinList);
|
|
18
18
|
setupAdmin(["list-fields"], buildRA);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export declare function MuffinShow({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MuffinShowToolbar({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function MuffinShowActions({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function MuffinShowLinks({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { EditButton, ListButton, Show, SimpleShowLayout, TopToolbar } from "react-admin";
|
|
3
3
|
import { LinkAction } from "./actions";
|
|
4
4
|
import { buildRA } from "./buildRA";
|
|
5
5
|
import { ActionButton } from "./buttons";
|
|
6
6
|
import { useMuffinResourceOpts } from "./hooks";
|
|
7
7
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
8
|
-
export function MuffinShow() {
|
|
8
|
+
export function MuffinShow({ children }) {
|
|
9
9
|
const { show, name } = useMuffinResourceOpts();
|
|
10
10
|
const ActionsToolbar = findBuilder(["show-toolbar", name]);
|
|
11
|
-
return (
|
|
11
|
+
return (_jsxs(Show, { actions: _jsx(ActionsToolbar, {}), children: [children, _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) })] }));
|
|
12
12
|
}
|
|
13
13
|
setupAdmin(["show"], (props) => _jsx(MuffinShow, Object.assign({}, props)));
|
|
14
14
|
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields));
|
|
15
|
-
export function MuffinShowToolbar() {
|
|
15
|
+
export function MuffinShowToolbar({ children }) {
|
|
16
16
|
const { show, name } = useMuffinResourceOpts();
|
|
17
17
|
const { edit } = show;
|
|
18
18
|
const Links = findBuilder(["show-links", name]);
|
|
19
19
|
const Actions = findBuilder(["show-actions", name]);
|
|
20
|
-
return (_jsxs(TopToolbar, { children: [_jsx(Links, {}), _jsx(Actions, {}), _jsx(ListButton, {}), edit && _jsx(EditButton, {})] }));
|
|
20
|
+
return (_jsxs(TopToolbar, { children: [_jsx(Links, {}), _jsx(Actions, {}), children, _jsx(ListButton, {}), edit && _jsx(EditButton, {})] }));
|
|
21
21
|
}
|
|
22
22
|
setupAdmin(["show-toolbar"], MuffinShowToolbar);
|
|
23
|
-
export function MuffinShowActions() {
|
|
23
|
+
export function MuffinShowActions({ children }) {
|
|
24
24
|
const { actions: baseActions = [] } = useMuffinResourceOpts();
|
|
25
25
|
const actions = baseActions.filter((a) => { var _a; return (_a = a.view) === null || _a === void 0 ? void 0 : _a.includes("show"); });
|
|
26
|
-
return actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id));
|
|
26
|
+
return (_jsxs(_Fragment, { children: [children, actions.map((props) => (_jsx(ActionButton, Object.assign({}, props), props.id)))] }));
|
|
27
27
|
}
|
|
28
28
|
setupAdmin(["show-actions"], MuffinShowActions);
|
|
29
|
-
export function MuffinShowLinks() {
|
|
29
|
+
export function MuffinShowLinks({ children }) {
|
|
30
30
|
const { show } = useMuffinResourceOpts();
|
|
31
31
|
const { links } = show;
|
|
32
|
-
return (
|
|
32
|
+
return (_jsxs("div", { style: { marginRight: "auto" }, children: [links.map(([key, props]) => (_jsx(LinkAction, Object.assign({ resource: key }, props), key))), children] }));
|
|
33
33
|
}
|
|
34
34
|
setupAdmin(["show-links"], MuffinShowLinks);
|
package/dist/authprovider.js
CHANGED
package/dist/buildRA.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function buildRAComponent(name:
|
|
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:
|
|
3
|
+
export declare function registerUI(name: string, component: JSX.ElementType): void;
|
|
@@ -81,7 +81,7 @@ 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
|
|
84
|
+
const PayloadBuilder = findBuilder(["action-payload", id, resource]) || (schema && CommonPayload);
|
|
85
85
|
return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: () => {
|
|
86
86
|
if (PayloadBuilder)
|
|
87
87
|
setPayloadActive(true);
|
package/dist/dataprovider.d.ts
CHANGED
|
@@ -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:
|
|
12
|
-
id:
|
|
12
|
+
getOne: (resource: string, { id }: {
|
|
13
|
+
id: TID;
|
|
13
14
|
}) => Promise<{
|
|
14
15
|
data: any;
|
|
15
16
|
headers: Headers;
|
|
16
17
|
}>;
|
|
17
|
-
create: (resource:
|
|
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:
|
|
24
|
-
id:
|
|
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:
|
|
30
|
-
ids:
|
|
30
|
+
updateMany: (resource: string, { ids, data }: {
|
|
31
|
+
ids: TID[];
|
|
31
32
|
data: any;
|
|
32
33
|
}) => Promise<{
|
|
33
|
-
data:
|
|
34
|
+
data: TID[];
|
|
34
35
|
}>;
|
|
35
|
-
delete: (resource:
|
|
36
|
-
id:
|
|
36
|
+
delete: (resource: string, { id }: {
|
|
37
|
+
id: TID;
|
|
37
38
|
}) => Promise<{
|
|
38
39
|
data: {
|
|
39
|
-
id:
|
|
40
|
+
id: TID;
|
|
40
41
|
};
|
|
41
42
|
}>;
|
|
42
|
-
deleteMany: (resource:
|
|
43
|
-
ids:
|
|
43
|
+
deleteMany: (resource: string, { ids }: {
|
|
44
|
+
ids: TID[][];
|
|
44
45
|
}) => Promise<{
|
|
45
|
-
data:
|
|
46
|
+
data: TID[][];
|
|
46
47
|
}>;
|
|
47
|
-
getMany: (resource:
|
|
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:
|
|
55
|
+
getManyReference: (resource: string, { target, id, filter, ...opts }: {
|
|
52
56
|
[x: string]: any;
|
|
53
57
|
target: any;
|
|
54
58
|
id: any;
|
package/dist/dataprovider.js
CHANGED