muffin-admin 1.44.4 → 1.45.1
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 +2 -0
- package/dist/MuffinAdmin.js +25 -0
- package/dist/MuffinDashboard.d.ts +2 -0
- package/dist/MuffinDashboard.js +16 -0
- package/dist/MuffinResource.d.ts +2 -0
- package/dist/MuffinResource.js +19 -0
- package/dist/MuffinResourceCreate.d.ts +4 -0
- package/dist/MuffinResourceCreate.js +11 -0
- package/dist/MuffinResourceEdit.d.ts +2 -0
- package/dist/MuffinResourceEdit.js +26 -0
- package/dist/MuffinResourceList.d.ts +2 -0
- package/dist/MuffinResourceList.js +16 -0
- package/dist/MuffinResourceShow.d.ts +2 -0
- package/dist/MuffinResourceShow.js +13 -0
- package/dist/actions/LinkAction.d.ts +4 -0
- package/dist/actions/LinkAction.js +10 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/authprovider.d.ts +9 -0
- package/dist/authprovider.js +80 -0
- package/dist/buildRA.d.ts +2 -0
- package/dist/buildRA.js +63 -0
- package/dist/buttons/ActionButton.d.ts +7 -0
- package/dist/buttons/ActionButton.js +51 -0
- package/dist/buttons/LinkButton.d.ts +6 -0
- package/dist/buttons/LinkButton.js +12 -0
- package/dist/buttons/index.d.ts +2 -0
- package/dist/buttons/index.js +2 -0
- package/dist/dataprovider.d.ts +59 -0
- package/dist/dataprovider.js +106 -0
- package/dist/fields/AvatarField.d.ts +13 -0
- package/dist/fields/AvatarField.js +33 -0
- package/dist/fields/EditableBooleanField.d.ts +3 -0
- package/dist/fields/EditableBooleanField.js +5 -0
- package/dist/fields/FKField.d.ts +14 -0
- package/dist/fields/FKField.js +21 -0
- package/dist/fields/JsonField.d.ts +4 -0
- package/dist/fields/JsonField.js +11 -0
- package/dist/fields/index.d.ts +4 -0
- package/dist/fields/index.js +4 -0
- package/dist/hooks/useAction.d.ts +5 -0
- package/dist/hooks/useAction.js +6 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +35 -0
- package/dist/inputs/FKInput.d.ts +8 -0
- package/dist/inputs/FKInput.js +27 -0
- package/dist/inputs/JsonInput.d.ts +19 -0
- package/dist/inputs/JsonInput.js +69 -0
- package/dist/inputs/index.d.ts +2 -0
- package/dist/inputs/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +28 -0
- package/dist/utils.js +57 -0
- package/dist/web.d.ts +1 -0
- package/dist/web.js +3 -0
- package/package.json +31 -14
- package/src/MuffinAdmin.tsx +73 -0
- package/src/MuffinDashboard.tsx +52 -0
- package/src/MuffinResource.tsx +27 -0
- package/src/MuffinResourceCreate.tsx +24 -0
- package/src/MuffinResourceEdit.tsx +42 -0
- package/src/MuffinResourceList.tsx +46 -0
- package/src/MuffinResourceShow.tsx +39 -0
- package/src/actions/LinkAction.tsx +10 -0
- package/src/actions/index.ts +1 -0
- package/src/{authprovider.js → authprovider.ts} +27 -22
- package/src/{ui.jsx → buildRA.tsx} +30 -35
- package/src/buttons/{ActionButton.jsx → ActionButton.tsx} +18 -30
- package/src/buttons/{LinkButton.jsx → LinkButton.tsx} +11 -6
- package/src/buttons/index.ts +2 -0
- package/src/{dataprovider.js → dataprovider.ts} +8 -6
- package/src/fields/{AvatarField.jsx → AvatarField.tsx} +3 -7
- package/src/fields/EditableBooleanField.tsx +5 -0
- package/src/fields/{FKField.jsx → FKField.tsx} +2 -10
- package/src/fields/{JsonField.jsx → JsonField.tsx} +2 -3
- package/src/fields/index.ts +4 -0
- package/src/hooks/{useAction.js → useAction.ts} +2 -2
- package/src/index.tsx +25 -0
- package/src/inputs/FKInput.tsx +27 -0
- package/src/inputs/{JsonInput.jsx → JsonInput.tsx} +3 -4
- package/src/inputs/index.ts +2 -0
- package/src/types.ts +73 -0
- package/src/utils.tsx +69 -0
- package/src/web.ts +4 -0
- package/dist/cjs/admin.js +0 -80
- package/dist/cjs/authprovider.js +0 -214
- package/dist/cjs/buttons/ActionButton.js +0 -96
- package/dist/cjs/buttons/LinkButton.js +0 -34
- package/dist/cjs/dashboard.js +0 -63
- package/dist/cjs/dataprovider.js +0 -304
- package/dist/cjs/fields/AvatarField.js +0 -37
- package/dist/cjs/fields/EditableBooleanField.js +0 -25
- package/dist/cjs/fields/FKField.js +0 -35
- package/dist/cjs/fields/JsonField.js +0 -38
- package/dist/cjs/hooks/useAction.js +0 -14
- package/dist/cjs/index.js +0 -76
- package/dist/cjs/inputs/FKInput.js +0 -41
- package/dist/cjs/inputs/JsonInput.js +0 -70
- package/dist/cjs/resources.js +0 -52
- package/dist/cjs/ui.js +0 -76
- package/dist/cjs/utils.js +0 -49
- package/dist/cjs/views/create.js +0 -18
- package/dist/cjs/views/edit.js +0 -31
- package/dist/cjs/views/list.js +0 -67
- package/dist/cjs/views/show.js +0 -37
- package/dist/cjs/web.js +0 -4
- package/dist/esm/admin.js +0 -74
- package/dist/esm/authprovider.js +0 -206
- package/dist/esm/buttons/ActionButton.js +0 -83
- package/dist/esm/buttons/LinkButton.js +0 -23
- package/dist/esm/dashboard.js +0 -60
- package/dist/esm/dataprovider.js +0 -296
- package/dist/esm/fields/AvatarField.js +0 -29
- package/dist/esm/fields/EditableBooleanField.js +0 -17
- package/dist/esm/fields/FKField.js +0 -27
- package/dist/esm/fields/JsonField.js +0 -28
- package/dist/esm/hooks/useAction.js +0 -8
- package/dist/esm/index.js +0 -42
- package/dist/esm/inputs/FKInput.js +0 -33
- package/dist/esm/inputs/JsonInput.js +0 -63
- package/dist/esm/resources.js +0 -47
- package/dist/esm/ui.js +0 -70
- package/dist/esm/utils.js +0 -38
- package/dist/esm/views/create.js +0 -16
- package/dist/esm/views/edit.js +0 -29
- package/dist/esm/views/list.js +0 -64
- package/dist/esm/views/show.js +0 -35
- package/dist/esm/web.js +0 -2
- package/src/admin.jsx +0 -78
- package/src/dashboard.jsx +0 -74
- package/src/fields/EditableBooleanField.jsx +0 -11
- package/src/index.js +0 -16
- package/src/inputs/FKInput.jsx +0 -42
- package/src/resources.jsx +0 -39
- package/src/utils.js +0 -38
- package/src/views/create.jsx +0 -30
- package/src/views/edit.jsx +0 -48
- package/src/views/list.jsx +0 -86
- package/src/views/show.jsx +0 -51
- package/src/web.js +0 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import Avatar from "@mui/material/Avatar";
|
|
14
|
+
import get from "lodash/get";
|
|
15
|
+
import { useRecordContext } from "ra-core";
|
|
16
|
+
export function AvatarField(_a) {
|
|
17
|
+
var { source, alt, style, nameProp } = _a, props = __rest(_a, ["source", "alt", "style", "nameProp"]);
|
|
18
|
+
const record = useRecordContext(props);
|
|
19
|
+
const value = get(record, source), name = record[nameProp];
|
|
20
|
+
const letters = name
|
|
21
|
+
? name
|
|
22
|
+
.trim(" ")
|
|
23
|
+
.split(/\s+/)
|
|
24
|
+
.slice(0, 2)
|
|
25
|
+
.map((n) => n[0].toUpperCase())
|
|
26
|
+
.join("")
|
|
27
|
+
: "";
|
|
28
|
+
return (_jsx(Avatar, { src: value, alt: alt, style: style, children: letters }));
|
|
29
|
+
}
|
|
30
|
+
AvatarField.displayName = "AvatarField";
|
|
31
|
+
AvatarField.defaultProps = {
|
|
32
|
+
addLabel: true,
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function FKField({ refSource, refID, link, reference, source, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
refSource: any;
|
|
4
|
+
refID: any;
|
|
5
|
+
link: any;
|
|
6
|
+
reference: any;
|
|
7
|
+
source: any;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare namespace FKField {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
var defaultProps: {
|
|
12
|
+
addLabel: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { ReferenceField, TextField } from "react-admin";
|
|
14
|
+
export function FKField(_a) {
|
|
15
|
+
var { refSource, refID, link, reference, source } = _a, props = __rest(_a, ["refSource", "refID", "link", "reference", "source"]);
|
|
16
|
+
return (_jsx(ReferenceField, Object.assign({ link: link || "show", reference: reference, source: source }, props, { children: _jsxs(_Fragment, { children: [_jsx(TextField, { source: refSource }), " (#", _jsx(TextField, { source: refID || "id" }), ")"] }) })));
|
|
17
|
+
}
|
|
18
|
+
FKField.displayName = "FKField";
|
|
19
|
+
FKField.defaultProps = {
|
|
20
|
+
addLabel: true,
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import get from "lodash/get";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Button, FunctionField, useRecordContext } from "react-admin";
|
|
5
|
+
export function JsonField({ label, source }) {
|
|
6
|
+
const [expand, setExpand] = useState(false);
|
|
7
|
+
const record = useRecordContext();
|
|
8
|
+
const src = JSON.stringify(get(record, source), null, 2);
|
|
9
|
+
const retval = (_jsxs("div", { children: [_jsx("p", {}), label, _jsx(Button, { variant: "contained", color: "primary", size: "small", label: expand ? "colapse" : "expand", onClick: () => setExpand(!expand) }), _jsx("p", { children: expand && _jsx("pre", { children: src }) })] }));
|
|
10
|
+
return _jsx(FunctionField, { render: () => retval });
|
|
11
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./MuffinAdmin";
|
|
2
|
+
export * from "./MuffinResource";
|
|
3
|
+
export * from "./MuffinResourceCreate";
|
|
4
|
+
export * from "./MuffinResourceEdit";
|
|
5
|
+
export * from "./MuffinResourceList";
|
|
6
|
+
export * from "./MuffinResourceShow";
|
|
7
|
+
export * from "./authprovider";
|
|
8
|
+
export * from "./buildRA";
|
|
9
|
+
export * from "./buttons";
|
|
10
|
+
export * from "./dataprovider";
|
|
11
|
+
export * from "./fields";
|
|
12
|
+
export * from "./types";
|
|
13
|
+
export * from "./utils";
|
|
14
|
+
export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createRoot } from "react-dom/client";
|
|
11
|
+
import { buildAdmin } from "./utils";
|
|
12
|
+
export * from "./MuffinAdmin";
|
|
13
|
+
export * from "./MuffinResource";
|
|
14
|
+
export * from "./MuffinResourceCreate";
|
|
15
|
+
export * from "./MuffinResourceEdit";
|
|
16
|
+
export * from "./MuffinResourceList";
|
|
17
|
+
export * from "./MuffinResourceShow";
|
|
18
|
+
export * from "./authprovider";
|
|
19
|
+
export * from "./buildRA";
|
|
20
|
+
export * from "./buttons";
|
|
21
|
+
export * from "./dataprovider";
|
|
22
|
+
export * from "./fields";
|
|
23
|
+
export * from "./types";
|
|
24
|
+
export * from "./utils";
|
|
25
|
+
export function initAdmin(prefix = "", containerId = "root") {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const response = yield fetch(`${prefix}/ra.json`);
|
|
28
|
+
const props = yield response.json();
|
|
29
|
+
const container = document.getElementById(containerId);
|
|
30
|
+
if (!container)
|
|
31
|
+
throw new Error(`Container #${containerId} not found`);
|
|
32
|
+
const root = createRoot(container);
|
|
33
|
+
root.render(buildAdmin(["admin"], props));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { AutocompleteInput, ReferenceInput } from "react-admin";
|
|
14
|
+
export function FKInput(_a) {
|
|
15
|
+
var { refProp, refSource, fullWidth, reference, source } = _a, props = __rest(_a, ["refProp", "refSource", "fullWidth", "reference", "source"]);
|
|
16
|
+
const filterToQuery = (search) => {
|
|
17
|
+
const filters = {};
|
|
18
|
+
filters[refProp] = search;
|
|
19
|
+
return filters;
|
|
20
|
+
};
|
|
21
|
+
refSource = refSource || "id";
|
|
22
|
+
const renderText = (record) => {
|
|
23
|
+
const pk = record[refSource];
|
|
24
|
+
return (pk && `${record[refProp]} (#${pk})`) || "";
|
|
25
|
+
};
|
|
26
|
+
return (_jsx(ReferenceInput, Object.assign({ reference: reference, source: source, filterToQuery: filterToQuery }, props, { children: _jsx(AutocompleteInput, Object.assign({ source: refSource, optionText: renderText, fullWidth: fullWidth }, props)) })));
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* `JsonInput` validates if the entered value is JSON or not. If entered value is not a invalid JSON, `JsonInput` will throw an error.
|
|
4
|
+
* Default error message is: `Invalid JSON` and can be overridden using `errortext` prop.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <JsonInput source='config' label='JSON Config' errortext='Enter a valid JSON'/>
|
|
8
|
+
*
|
|
9
|
+
* or use translate function:
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <JsonInput source='config' label={translate('resources.resource_name.fields.config')} errortext={translate('myroot.validate.json')}/>
|
|
13
|
+
*
|
|
14
|
+
* By default, `JsonInput` parses and returns the entered string as object. Instead, to send string directly, please pass `parse` prop as `false`
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <JsonInput source='config' label='JSON Config' parse={false}/>
|
|
18
|
+
*/
|
|
19
|
+
export declare function JsonInput(props: any): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { TextInput } from "react-admin";
|
|
14
|
+
import isJSON from "validator/lib/isJSON";
|
|
15
|
+
const DEFAULT_ERRORTEXT = "Invalid JSON";
|
|
16
|
+
const parseFunction = (json) => {
|
|
17
|
+
let retval = json;
|
|
18
|
+
try {
|
|
19
|
+
retval = JSON.parse(json);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
// eslint-disable-next-line no-unsafe-finally
|
|
23
|
+
return retval;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* `JsonInput` validates if the entered value is JSON or not. If entered value is not a invalid JSON, `JsonInput` will throw an error.
|
|
29
|
+
* Default error message is: `Invalid JSON` and can be overridden using `errortext` prop.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <JsonInput source='config' label='JSON Config' errortext='Enter a valid JSON'/>
|
|
33
|
+
*
|
|
34
|
+
* or use translate function:
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* <JsonInput source='config' label={translate('resources.resource_name.fields.config')} errortext={translate('myroot.validate.json')}/>
|
|
38
|
+
*
|
|
39
|
+
* By default, `JsonInput` parses and returns the entered string as object. Instead, to send string directly, please pass `parse` prop as `false`
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <JsonInput source='config' label='JSON Config' parse={false}/>
|
|
43
|
+
*/
|
|
44
|
+
export function JsonInput(props) {
|
|
45
|
+
const { validate = [], errortext = DEFAULT_ERRORTEXT, multiline = true, parse = true } = props, rest = __rest(props
|
|
46
|
+
// const errorobj = { message: errortext }
|
|
47
|
+
, ["validate", "errortext", "multiline", "parse"]);
|
|
48
|
+
// const errorobj = { message: errortext }
|
|
49
|
+
const validateJSON = (value) => {
|
|
50
|
+
if (!value || typeof value === "object")
|
|
51
|
+
return undefined;
|
|
52
|
+
return isJSON(value) ? undefined : errortext;
|
|
53
|
+
};
|
|
54
|
+
validate.push(validateJSON);
|
|
55
|
+
rest.validate = validate;
|
|
56
|
+
const formatJSON = (json) => {
|
|
57
|
+
let retval = json;
|
|
58
|
+
if (retval && typeof retval === "object")
|
|
59
|
+
retval = JSON.stringify(retval, null, 2);
|
|
60
|
+
return retval;
|
|
61
|
+
};
|
|
62
|
+
rest.format = formatJSON;
|
|
63
|
+
//
|
|
64
|
+
if (parse)
|
|
65
|
+
rest.parse = parseFunction;
|
|
66
|
+
if (multiline)
|
|
67
|
+
rest.multiline = true;
|
|
68
|
+
return _jsx(TextInput, Object.assign({}, rest));
|
|
69
|
+
}
|