muffin-admin 2.7.3 → 2.8.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.d.ts +4 -3
- package/dist/MuffinAdmin.js +19 -8
- package/dist/MuffinDashboard.d.ts +1 -4
- package/dist/MuffinDashboard.js +5 -3
- package/dist/MuffinResource.d.ts +2 -2
- package/dist/MuffinResource.js +8 -3
- package/dist/MuffinResourceCreate.d.ts +1 -4
- package/dist/MuffinResourceCreate.js +10 -6
- package/dist/MuffinResourceEdit.d.ts +1 -2
- package/dist/MuffinResourceEdit.js +16 -12
- package/dist/MuffinResourceList.d.ts +1 -2
- package/dist/MuffinResourceList.js +13 -8
- package/dist/MuffinResourceShow.d.ts +1 -2
- package/dist/MuffinResourceShow.js +5 -4
- package/dist/actions/LinkAction.js +3 -4
- package/dist/authprovider.js +3 -3
- package/dist/buildRA.d.ts +2 -3
- package/dist/buildRA.js +4 -1
- package/dist/context.d.ts +3 -0
- package/dist/context.js +2 -0
- package/dist/dataprovider.d.ts +1 -2
- package/dist/dataprovider.js +1 -1
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/useMuffinAdminOpts.d.ts +1 -0
- package/dist/hooks/useMuffinAdminOpts.js +5 -0
- package/dist/hooks/useMuffinResourceOpts.d.ts +1 -0
- package/dist/hooks/useMuffinResourceOpts.js +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.js +7 -7
- package/package.json +1 -1
- package/src/MuffinAdmin.tsx +48 -28
- package/src/MuffinDashboard.tsx +7 -5
- package/src/MuffinResource.tsx +13 -17
- package/src/MuffinResourceCreate.tsx +11 -8
- package/src/MuffinResourceEdit.tsx +28 -26
- package/src/MuffinResourceList.tsx +27 -21
- package/src/MuffinResourceShow.tsx +6 -5
- package/src/actions/LinkAction.tsx +3 -4
- package/src/authprovider.ts +3 -3
- package/src/buildRA.tsx +6 -2
- package/src/context.ts +4 -0
- package/src/dataprovider.ts +1 -2
- package/src/hooks/index.ts +3 -1
- package/src/hooks/useMuffinAdminOpts.ts +6 -0
- package/src/hooks/useMuffinResourceOpts.ts +8 -0
- package/src/index.tsx +11 -4
- package/src/utils.tsx +6 -9
package/dist/MuffinAdmin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { AdminProps } from "react-admin";
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
1
|
+
import { AdminProps, AppBarProps, LayoutProps } from "react-admin";
|
|
2
|
+
export declare function MuffinAdmin(props: AdminProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MuffinAdminLayout(props: LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function MuffinAppBar(props: AppBarProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/MuffinAdmin.js
CHANGED
|
@@ -3,20 +3,31 @@ import IconButton from "@mui/material/IconButton";
|
|
|
3
3
|
import SvgIcon from "@mui/material/SvgIcon";
|
|
4
4
|
import Tooltip from "@mui/material/Tooltip";
|
|
5
5
|
import Typography from "@mui/material/Typography";
|
|
6
|
-
import { Admin, AppBar, Layout, Login } from "react-admin";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
6
|
+
import { Admin, AppBar, Layout, Login, } from "react-admin";
|
|
7
|
+
import { useMuffinAdminOpts } from "./hooks";
|
|
8
|
+
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils";
|
|
9
|
+
export function MuffinAdmin(props) {
|
|
10
|
+
const opts = useMuffinAdminOpts();
|
|
11
|
+
const { resources = [], auth, adminProps, apiUrl } = opts;
|
|
11
12
|
document.title = (adminProps === null || adminProps === void 0 ? void 0 : adminProps.title) || "Muffin Admin";
|
|
12
|
-
const
|
|
13
|
+
const authProvider = findBuilder(["authprovider"])(auth);
|
|
14
|
+
const dataProvider = findBuilder(["dataprovider"])(apiUrl);
|
|
15
|
+
return (_jsx(Admin, Object.assign({ requireAuth: auth.required, authProvider: authProvider, dataProvider: dataProvider, layout: findBuilder(["layout"]), loginPage: findBuilder(["loginpage"]), dashboard: findBuilder(["dashboard"]), darkTheme: { palette: { mode: "dark" } } }, props, { children: resources === null || resources === void 0 ? void 0 : resources.map(({ name }) => buildAdmin(["resource", name], { name })) })));
|
|
16
|
+
}
|
|
17
|
+
setupAdmin(["admin"], MuffinAdmin);
|
|
18
|
+
export function MuffinAdminLayout(props) {
|
|
19
|
+
return _jsx(Layout, Object.assign({}, props, { appBar: findBuilder(["appbar"]) }));
|
|
20
|
+
}
|
|
21
|
+
setupAdmin(["layout"], MuffinAdminLayout);
|
|
22
|
+
export function MuffinAppBar(props) {
|
|
23
|
+
const { appBarLinks } = useMuffinAdminOpts();
|
|
24
|
+
return (_jsxs(AppBar, Object.assign({}, props, { children: [_jsx(Typography, { variant: "h6", color: "inherit", id: "react-admin-title", style: {
|
|
13
25
|
flex: 1,
|
|
14
26
|
overflow: "hidden",
|
|
15
27
|
whiteSpace: "nowrap",
|
|
16
28
|
textOverflow: "ellipsis",
|
|
17
29
|
} }), appBarLinks.map((info) => (_jsx(Tooltip, { title: info.title, children: _jsx(IconButton, { color: "inherit", href: info.url, children: _jsx(SvgIcon, { component: findIcon(info.icon) }) }) }, info.url)))] })));
|
|
18
|
-
return (_jsx(AdminPropsContext.Provider, { value: opts, children: _jsx(Admin, Object.assign({ authProvider: buildAdmin(["authprovider"], auth), dataProvider: buildAdmin(["dataprovider"], opts), layout: (props) => _jsx(Layout, Object.assign({}, props, { appBar: appBar })), loginPage: findBuilder(["loginpage"]), dashboard: dashboard ? buildAdmin(["dashboard"], dashboard) : null, requireAuth: auth.required, darkTheme: { palette: { mode: "dark" } } }, props, { children: children })) }));
|
|
19
30
|
}
|
|
20
|
-
setupAdmin(["
|
|
31
|
+
setupAdmin(["appbar"], MuffinAppBar);
|
|
21
32
|
// Initialize login page
|
|
22
33
|
setupAdmin(["loginpage"], Login);
|
package/dist/MuffinDashboard.js
CHANGED
|
@@ -7,10 +7,13 @@ import TableBody from "@mui/material/TableBody";
|
|
|
7
7
|
import TableCell from "@mui/material/TableCell";
|
|
8
8
|
import TableRow from "@mui/material/TableRow";
|
|
9
9
|
import Typography from "@mui/material/Typography";
|
|
10
|
+
import { useMuffinAdminOpts } from "./hooks";
|
|
10
11
|
import { setupAdmin } from "./utils";
|
|
11
|
-
export function MuffinDashboard(
|
|
12
|
-
|
|
12
|
+
export function MuffinDashboard() {
|
|
13
|
+
const { dashboard } = useMuffinAdminOpts();
|
|
14
|
+
return (_jsx(Grid, { container: true, spacing: 1, children: _jsx(AdminCards, { src: dashboard }) }));
|
|
13
15
|
}
|
|
16
|
+
setupAdmin(["dashboard"], MuffinDashboard);
|
|
14
17
|
function AdminCards({ src }) {
|
|
15
18
|
if (Array.isArray(src))
|
|
16
19
|
return (_jsx(Grid, { container: true, item: true, spacing: 2, children: src.map((card, idx) => (_jsx(AdminCards, { src: card }, idx))) }));
|
|
@@ -20,4 +23,3 @@ function DashboardCard({ title, value }) {
|
|
|
20
23
|
return (_jsx(Grid, { item: true, xs: true, children: _jsx(Card, { children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "h5", component: "h2", m: 2, style: { textAlign: "center" }, children: title }), (Array.isArray(value) && _jsx(AdminTableView, { src: value })) || (_jsx("pre", { children: JSON.stringify(value, null, 2) }))] }) }) }));
|
|
21
24
|
}
|
|
22
25
|
const AdminTableView = ({ src }) => (_jsx(Table, { children: _jsx(TableBody, { children: src.map((row, idx) => (_jsx(TableRow, { hover: true, children: row.map((cell, idx) => (_jsx(TableCell, { children: cell }, idx))) }, idx))) }) }));
|
|
23
|
-
setupAdmin(["dashboard"], (dashboard) => () => _jsx(MuffinDashboard, { src: dashboard }));
|
package/dist/MuffinResource.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function MuffinResource({ name,
|
|
1
|
+
import { ResourceProps } from "react-admin";
|
|
2
|
+
export declare function MuffinResource({ name, ...props }: ResourceProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/MuffinResource.js
CHANGED
|
@@ -11,9 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { Resource } from "react-admin";
|
|
14
|
-
import {
|
|
14
|
+
import { useMuffinAdminOpts } from "./hooks";
|
|
15
|
+
import { findBuilder, findIcon, setupAdmin } from "./utils";
|
|
15
16
|
export function MuffinResource(_a) {
|
|
16
|
-
var { name
|
|
17
|
-
|
|
17
|
+
var { name } = _a, props = __rest(_a, ["name"]);
|
|
18
|
+
const adminOpts = useMuffinAdminOpts();
|
|
19
|
+
const opts = adminOpts === null || adminOpts === void 0 ? void 0 : adminOpts.resources.find((r) => r.name == name);
|
|
20
|
+
if (!opts)
|
|
21
|
+
return null;
|
|
22
|
+
return (_jsx(Resource, Object.assign({ name: name, icon: findIcon(opts.icon), create: findBuilder(["create", name]), edit: findBuilder(["edit", name]), list: findBuilder(["list", name]), show: findBuilder(["show", name]) }, props), name));
|
|
18
23
|
}
|
|
19
24
|
setupAdmin(["resource"], MuffinResource);
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function MuffinResourceCreate({ inputs }: {
|
|
3
|
-
inputs: AdminResourceProps["create"];
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function MuffinResourceCreate(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Create, ListButton, SimpleForm, TopToolbar
|
|
2
|
+
import { Create, ListButton, SimpleForm, TopToolbar } from "react-admin";
|
|
3
3
|
import { buildRA } from "./buildRA";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { useMuffinResourceOpts } from "./hooks";
|
|
5
|
+
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
6
|
+
export function MuffinResourceCreate() {
|
|
7
|
+
const { name, create } = useMuffinResourceOpts();
|
|
8
|
+
if (!create)
|
|
9
|
+
return null;
|
|
10
|
+
const Actions = findBuilder(["create-actions", name]);
|
|
11
|
+
return (_jsx(Create, { actions: _jsx(Actions, {}), children: _jsx(SimpleForm, { children: buildAdmin(["create-inputs", name], create) }) }));
|
|
8
12
|
}
|
|
9
|
-
setupAdmin(["create"],
|
|
13
|
+
setupAdmin(["create"], MuffinResourceCreate);
|
|
10
14
|
setupAdmin(["create-actions"], () => (_jsx(TopToolbar, { children: _jsx(ListButton, {}) })));
|
|
11
15
|
setupAdmin(["create-inputs"], buildRA);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function MuffinResourceEdit(props: AdminResourceProps["edit"]): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function MuffinResourceEdit(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,21 +10,25 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import { DeleteButton, Edit, ListButton, SaveButton, ShowButton, SimpleForm, Toolbar, TopToolbar, useResourceContext, } from "react-admin";
|
|
13
|
+
import { DeleteButton, Edit, ListButton, SaveButton, ShowButton, SimpleForm, Toolbar, TopToolbar, } from "react-admin";
|
|
15
14
|
import { buildRA } from "./buildRA";
|
|
16
15
|
import { ActionButton } from "./buttons";
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const { adminProps: { mutationMode }, } =
|
|
21
|
-
|
|
16
|
+
import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks";
|
|
17
|
+
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
18
|
+
export function MuffinResourceEdit() {
|
|
19
|
+
const { adminProps: { mutationMode = "optimistic" }, } = useMuffinAdminOpts();
|
|
20
|
+
const { edit, name } = useMuffinResourceOpts();
|
|
21
|
+
if (!edit)
|
|
22
22
|
return null;
|
|
23
|
-
const { actions, inputs, remove } =
|
|
24
|
-
|
|
23
|
+
const { actions, inputs, remove } = edit, opts = __rest(edit, ["actions", "inputs", "remove"]);
|
|
24
|
+
const Actions = findBuilder(["edit-actions", name]);
|
|
25
|
+
return (_jsx(Edit, Object.assign({ actions: _jsx(Actions, { actions: actions }), mutationMode: mutationMode }, opts, { children: _jsx(SimpleForm, { toolbar: _jsxs(Toolbar, { children: [_jsx(SaveButton, {}), remove && (_jsx(DeleteButton, { sx: {
|
|
25
26
|
marginLeft: "auto",
|
|
26
|
-
} }))] }), children: buildAdmin(["edit-inputs",
|
|
27
|
+
} }))] }), children: buildAdmin(["edit-inputs", name], inputs) }) })));
|
|
27
28
|
}
|
|
28
|
-
setupAdmin(["edit"],
|
|
29
|
-
|
|
29
|
+
setupAdmin(["edit"], MuffinResourceEdit);
|
|
30
|
+
function MuffinResourceEditActions({ actions }) {
|
|
31
|
+
return (_jsxs(TopToolbar, { children: [actions.map((props, idx) => (_jsx(ActionButton, Object.assign({}, props), idx))), _jsx(ListButton, {}), _jsx(ShowButton, {})] }));
|
|
32
|
+
}
|
|
33
|
+
setupAdmin(["edit-actions"], MuffinResourceEditActions);
|
|
30
34
|
setupAdmin(["edit-inputs"], buildRA);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function MuffinResourceList(props: AdminResourceProps["list"]): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function MuffinResourceList(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import sortBy from "lodash/sortBy";
|
|
3
3
|
import uniq from "lodash/uniq";
|
|
4
|
-
import { BulkDeleteButton, Datagrid, EditButton, List, Pagination
|
|
4
|
+
import { BulkDeleteButton, Datagrid, EditButton, List, Pagination } from "react-admin";
|
|
5
5
|
import { buildRA } from "./buildRA";
|
|
6
6
|
import { BulkActionButton } from "./buttons";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
|
|
7
|
+
import { useMuffinResourceOpts } from "./hooks";
|
|
8
|
+
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
9
|
+
export function MuffinResourceList() {
|
|
10
|
+
const { name, list } = useMuffinResourceOpts();
|
|
11
|
+
const { fields, edit, show, limit, limitMax, filters, actions, remove, sort } = list;
|
|
12
|
+
const Actions = findBuilder(["list-actions", name]);
|
|
13
|
+
return (_jsx(List, { sort: sort, perPage: limit, filters: buildAdmin(["list-filters", name], filters), bulkActionButtons: _jsx(Actions, { actions: actions, remove: remove }), pagination: _jsx(Pagination, { rowsPerPageOptions: sortBy(uniq([10, 25, 50, 100, limit, limitMax])) }), children: _jsxs(Datagrid, { rowClick: show ? "show" : edit ? "edit" : false, children: [buildAdmin(["list-fields", name], fields), edit && _jsx(EditButton, {})] }) }));
|
|
12
14
|
}
|
|
13
|
-
setupAdmin(["list"],
|
|
15
|
+
setupAdmin(["list"], MuffinResourceList);
|
|
14
16
|
setupAdmin(["list-fields"], buildRA);
|
|
15
17
|
setupAdmin(["list-filters"], buildRA);
|
|
16
|
-
|
|
18
|
+
function MuffinResourceListActions({ actions, remove, }) {
|
|
19
|
+
return (_jsxs(_Fragment, { children: [actions.map((props) => (_jsx(BulkActionButton, Object.assign({}, props), props.id))), remove && _jsx(BulkDeleteButton, {})] }));
|
|
20
|
+
}
|
|
21
|
+
setupAdmin(["list-actions"], MuffinResourceListActions);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function MuffinResourceShow(props: AdminShowProps): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export declare function MuffinResourceShow(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,11 +3,12 @@ import { EditButton, ListButton, Show, SimpleShowLayout, TopToolbar, useResource
|
|
|
3
3
|
import { LinkAction } from "./actions";
|
|
4
4
|
import { buildRA } from "./buildRA";
|
|
5
5
|
import { ActionButton } from "./buttons";
|
|
6
|
+
import { useMuffinResourceOpts } from "./hooks";
|
|
6
7
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
7
|
-
export function MuffinResourceShow(
|
|
8
|
-
const
|
|
9
|
-
const ShowActions = findBuilder(["show-actions",
|
|
10
|
-
return (_jsx(Show, { actions: _jsx(ShowActions, Object.assign({},
|
|
8
|
+
export function MuffinResourceShow() {
|
|
9
|
+
const { show, name } = useMuffinResourceOpts();
|
|
10
|
+
const ShowActions = findBuilder(["show-actions", name]);
|
|
11
|
+
return (_jsx(Show, { actions: _jsx(ShowActions, Object.assign({}, show)), children: _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) }) }));
|
|
11
12
|
}
|
|
12
13
|
setupAdmin(["record-actions"], ({ actions }) => actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)));
|
|
13
14
|
setupAdmin(["record-links"], ({ links }) => links.map(([key, props]) => _jsx(LinkAction, Object.assign({ resource: key }, props), key)));
|
|
@@ -10,17 +10,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useContext } from "react";
|
|
14
13
|
import { useRecordContext, useResourceContext } from "react-admin";
|
|
15
14
|
import LinkButton from "../buttons/LinkButton";
|
|
16
|
-
import {
|
|
15
|
+
import { useMuffinAdminOpts } from "../hooks";
|
|
17
16
|
export function LinkAction(_a) {
|
|
18
17
|
var { field, icon } = _a, props = __rest(_a, ["field", "icon"]);
|
|
19
|
-
const
|
|
18
|
+
const { resources } = useMuffinAdminOpts();
|
|
20
19
|
const record = useRecordContext();
|
|
21
20
|
const currentResource = useResourceContext();
|
|
22
21
|
if (!record)
|
|
23
22
|
return null;
|
|
24
|
-
const resource =
|
|
23
|
+
const resource = resources.find((r) => r.name === props.resource);
|
|
25
24
|
return (_jsx(LinkButton, Object.assign({}, props, { icon: icon || (resource === null || resource === void 0 ? void 0 : resource.icon), filters: { [currentResource]: encodeURIComponent(record[field || "id"]) } })));
|
|
26
25
|
}
|
package/dist/authprovider.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Cookies from "js-cookie";
|
|
11
|
-
import {
|
|
11
|
+
import { findBuilder, makeRequest, requestHeaders, setupAdmin } from ".";
|
|
12
12
|
setupAdmin(["auth-storage-get"], ({ storage, storageName }) => () => storage == "localstorage" ? localStorage.getItem(storageName) : Cookies.get(storageName));
|
|
13
13
|
setupAdmin(["auth-storage-set"], ({ storage }) => (name, value) => {
|
|
14
14
|
if (storage == "localstorage") {
|
|
@@ -20,8 +20,8 @@ setupAdmin(["auth-storage-set"], ({ storage }) => (name, value) => {
|
|
|
20
20
|
});
|
|
21
21
|
export function MuffinAuthProvider(props) {
|
|
22
22
|
const { identityURL, authorizeURL, logoutURL, required, storageName } = props;
|
|
23
|
-
const authGet =
|
|
24
|
-
const authSet =
|
|
23
|
+
const authGet = findBuilder(["auth-storage-get"])(props);
|
|
24
|
+
const authSet = findBuilder(["auth-storage-set"])(props);
|
|
25
25
|
// Initialize request headers
|
|
26
26
|
authSet(storageName, authGet(storageName));
|
|
27
27
|
const getIdentity = () => __awaiter(this, void 0, void 0, function* () {
|
package/dist/buildRA.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const UI: Record<string, JSX.ElementType>;
|
|
3
1
|
export declare function buildRAComponent(name: any, props: any): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare function buildRA(items: any):
|
|
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;
|
package/dist/buildRA.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { ArrayField, ArrayInput, AutocompleteArrayInput, AutocompleteInput, BooleanField, BooleanInput, CheckboxGroupInput, ChipField, DateField, DateInput, DateTimeInput, EmailField, FileField, FileInput, ImageField, ImageInput, NullableBooleanInput, NumberField, NumberInput, PasswordInput, RadioButtonGroupInput, ReferenceArrayField, ReferenceArrayInput, ReferenceField, ReferenceInput, ReferenceManyField, RichTextField, SelectField, SelectInput, TextField, TextInput, UrlField, required, } from "react-admin";
|
|
3
3
|
import { AvatarField, EditableBooleanField, FKField, JsonField } from "./fields";
|
|
4
4
|
import { FKInput, JsonInput } from "./inputs";
|
|
5
|
-
|
|
5
|
+
const UI = {
|
|
6
6
|
// Fields
|
|
7
7
|
BooleanField,
|
|
8
8
|
ChipField,
|
|
@@ -61,3 +61,6 @@ export function buildRAComponent(name, props) {
|
|
|
61
61
|
export function buildRA(items) {
|
|
62
62
|
return items.map((item) => buildRAComponent(item[0], item[1]));
|
|
63
63
|
}
|
|
64
|
+
export function registerUI(name, component) {
|
|
65
|
+
UI[name] = component;
|
|
66
|
+
}
|
package/dist/context.js
ADDED
package/dist/dataprovider.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AdminOpts } from "./types";
|
|
2
1
|
import { APIParams } from "./utils";
|
|
3
|
-
export declare function MuffinDataprovider(
|
|
2
|
+
export declare function MuffinDataprovider(apiUrl: string): {
|
|
4
3
|
request: (url: string, options?: APIParams) => Promise<{
|
|
5
4
|
data: any;
|
|
6
5
|
headers: Headers;
|
package/dist/dataprovider.js
CHANGED
|
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
21
|
import { makeRequest, setupAdmin } from "./utils";
|
|
22
|
-
export function MuffinDataprovider(
|
|
22
|
+
export function MuffinDataprovider(apiUrl) {
|
|
23
23
|
function request(url, options) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (!url.startsWith("/"))
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMuffinAdminOpts(): import("..").AdminOpts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMuffinResourceOpts(): import("..").AdminResourceProps;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useResourceContext } from "react-admin";
|
|
2
|
+
import { useMuffinAdminOpts } from "./useMuffinAdminOpts";
|
|
3
|
+
export function useMuffinResourceOpts() {
|
|
4
|
+
const resource = useResourceContext();
|
|
5
|
+
const { resources } = useMuffinAdminOpts();
|
|
6
|
+
return resources.find((r) => r.name === resource);
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./utils";
|
|
1
2
|
export * from "./MuffinAdmin";
|
|
2
3
|
export * from "./MuffinDashboard";
|
|
3
4
|
export * from "./MuffinResource";
|
|
@@ -9,9 +10,9 @@ export * from "./actions";
|
|
|
9
10
|
export * from "./authprovider";
|
|
10
11
|
export * from "./buildRA";
|
|
11
12
|
export * from "./buttons";
|
|
13
|
+
export * from "./context";
|
|
12
14
|
export * from "./dataprovider";
|
|
13
15
|
export * from "./fields";
|
|
14
16
|
export * from "./hooks";
|
|
15
17
|
export * from "./types";
|
|
16
|
-
export * from "./utils";
|
|
17
18
|
export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
import { createRoot } from "react-dom/client";
|
|
11
|
-
import {
|
|
12
|
+
import { MuffinAdmin } from "./MuffinAdmin";
|
|
13
|
+
import { MuffinAdminContext } from "./context";
|
|
14
|
+
export * from "./utils";
|
|
12
15
|
export * from "./MuffinAdmin";
|
|
13
16
|
export * from "./MuffinDashboard";
|
|
14
17
|
export * from "./MuffinResource";
|
|
@@ -20,19 +23,19 @@ export * from "./actions";
|
|
|
20
23
|
export * from "./authprovider";
|
|
21
24
|
export * from "./buildRA";
|
|
22
25
|
export * from "./buttons";
|
|
26
|
+
export * from "./context";
|
|
23
27
|
export * from "./dataprovider";
|
|
24
28
|
export * from "./fields";
|
|
25
29
|
export * from "./hooks";
|
|
26
30
|
export * from "./types";
|
|
27
|
-
export * from "./utils";
|
|
28
31
|
export function initAdmin() {
|
|
29
32
|
return __awaiter(this, arguments, void 0, function* (prefix = "", containerId = "root") {
|
|
30
33
|
const response = yield fetch(`${prefix}/ra.json`);
|
|
31
|
-
const
|
|
34
|
+
const adminOpts = yield response.json();
|
|
32
35
|
const container = document.getElementById(containerId);
|
|
33
36
|
if (!container)
|
|
34
37
|
throw new Error(`Container #${containerId} not found`);
|
|
35
38
|
const root = createRoot(container);
|
|
36
|
-
root.render(
|
|
39
|
+
root.render(_jsx(MuffinAdminContext.Provider, { value: adminOpts, children: _jsx(MuffinAdmin, {}) }));
|
|
37
40
|
});
|
|
38
41
|
}
|