muffin-admin 1.44.4 → 1.45.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 +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
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["validate", "errortext", "multiline", "parse"];
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { TextInput } from "react-admin";
|
|
6
|
-
import isJSON from "validator/lib/isJSON";
|
|
7
|
-
var DEFAULT_ERRORTEXT = "Invalid JSON";
|
|
8
|
-
var parseFunction = function parseFunction(json) {
|
|
9
|
-
var retval = json;
|
|
10
|
-
try {
|
|
11
|
-
retval = JSON.parse(json);
|
|
12
|
-
} finally {
|
|
13
|
-
return retval;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* `JsonInput` validates if the entered value is JSON or not. If entered value is not a invalid JSON, `JsonInput` will throw an error.
|
|
20
|
-
* Default error message is: `Invalid JSON` and can be overridden using `errortext` prop.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* <JsonInput source='config' label='JSON Config' errortext='Enter a valid JSON'/>
|
|
24
|
-
*
|
|
25
|
-
* or use translate function:
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* <JsonInput source='config' label={translate('resources.resource_name.fields.config')} errortext={translate('myroot.validate.json')}/>
|
|
29
|
-
*
|
|
30
|
-
* By default, `JsonInput` parses and returns the entered string as object. Instead, to send string directly, please pass `parse` prop as `false`
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* <JsonInput source='config' label='JSON Config' parse={false}/>
|
|
34
|
-
*/
|
|
35
|
-
export default function JsonInput(props) {
|
|
36
|
-
var _props$validate = props.validate,
|
|
37
|
-
validate = _props$validate === void 0 ? [] : _props$validate,
|
|
38
|
-
_props$errortext = props.errortext,
|
|
39
|
-
errortext = _props$errortext === void 0 ? DEFAULT_ERRORTEXT : _props$errortext,
|
|
40
|
-
_props$multiline = props.multiline,
|
|
41
|
-
multiline = _props$multiline === void 0 ? true : _props$multiline,
|
|
42
|
-
_props$parse = props.parse,
|
|
43
|
-
parse = _props$parse === void 0 ? true : _props$parse,
|
|
44
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
45
|
-
// const errorobj = { message: errortext }
|
|
46
|
-
|
|
47
|
-
var validateJSON = function validateJSON(value) {
|
|
48
|
-
if (!value || _typeof(value) === "object") return undefined;
|
|
49
|
-
return isJSON(value) ? undefined : errortext;
|
|
50
|
-
};
|
|
51
|
-
validate.push(validateJSON);
|
|
52
|
-
rest.validate = validate;
|
|
53
|
-
var formatJSON = function formatJSON(json) {
|
|
54
|
-
var retval = json;
|
|
55
|
-
if (retval && _typeof(retval) === "object") retval = JSON.stringify(retval, null, 2);
|
|
56
|
-
return retval;
|
|
57
|
-
};
|
|
58
|
-
rest.format = formatJSON;
|
|
59
|
-
//
|
|
60
|
-
if (parse) rest.parse = parseFunction;
|
|
61
|
-
if (multiline) rest.multiline = true;
|
|
62
|
-
return /*#__PURE__*/React.createElement(TextInput, rest);
|
|
63
|
-
}
|
package/dist/esm/resources.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["create", "edit", "icon", "list", "show"];
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { Resource } from "react-admin";
|
|
6
|
-
import * as icons from "@mui/icons-material";
|
|
7
|
-
import { checkParams, processAdmin, setupAdmin } from "./utils";
|
|
8
|
-
import "./views/list";
|
|
9
|
-
import "./views/show";
|
|
10
|
-
import "./views/edit";
|
|
11
|
-
import "./views/create";
|
|
12
|
-
|
|
13
|
-
// Initialize Resources Components
|
|
14
|
-
setupAdmin("resources", function (_ref) {
|
|
15
|
-
var resources = _ref.resources,
|
|
16
|
-
adminProps = _ref.adminProps;
|
|
17
|
-
return resources.map(function (resource) {
|
|
18
|
-
return processAdmin("resource", {
|
|
19
|
-
resource: resource,
|
|
20
|
-
adminProps: adminProps
|
|
21
|
-
}, resource.name);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Initialize a resource's component
|
|
26
|
-
setupAdmin("resource", checkParams(function (props, name) {
|
|
27
|
-
var resource = props.resource,
|
|
28
|
-
adminProps = props.adminProps;
|
|
29
|
-
var create = resource.create,
|
|
30
|
-
edit = resource.edit,
|
|
31
|
-
icon = resource.icon,
|
|
32
|
-
list = resource.list,
|
|
33
|
-
show = resource.show,
|
|
34
|
-
resProps = _objectWithoutProperties(resource, _excluded);
|
|
35
|
-
return /*#__PURE__*/React.createElement(Resource, _extends({
|
|
36
|
-
key: name,
|
|
37
|
-
name: name,
|
|
38
|
-
icon: icons[icon],
|
|
39
|
-
create: processAdmin("create", create, name),
|
|
40
|
-
edit: processAdmin("edit", {
|
|
41
|
-
edit: edit,
|
|
42
|
-
adminProps: adminProps
|
|
43
|
-
}, name),
|
|
44
|
-
list: processAdmin("list", list, name),
|
|
45
|
-
show: processAdmin("show", show, name)
|
|
46
|
-
}, resProps));
|
|
47
|
-
}));
|
package/dist/esm/ui.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { required } from "react-admin";
|
|
5
|
-
import { BooleanField, ChipField, DateField, EmailField, ImageField, FileField, NumberField, RichTextField, TextField, UrlField, SelectField, ArrayField, ReferenceField, ReferenceManyField, ReferenceArrayField } from "react-admin";
|
|
6
|
-
import { BooleanInput, NullableBooleanInput, DateInput, DateTimeInput, ImageInput, FileInput, NumberInput, PasswordInput, TextInput, AutocompleteInput, RadioButtonGroupInput, SelectInput, ArrayInput, AutocompleteArrayInput, CheckboxGroupInput, ReferenceArrayInput, ReferenceInput } from "react-admin";
|
|
7
|
-
import AvatarField from "./fields/AvatarField";
|
|
8
|
-
import FKField from "./fields/FKField";
|
|
9
|
-
import FKInput from "./inputs/FKInput";
|
|
10
|
-
import JsonField from "./fields/JsonField";
|
|
11
|
-
import JsonInput from "./inputs/JsonInput";
|
|
12
|
-
var UI = {
|
|
13
|
-
// Fields
|
|
14
|
-
BooleanField: BooleanField,
|
|
15
|
-
ChipField: ChipField,
|
|
16
|
-
DateField: DateField,
|
|
17
|
-
EmailField: EmailField,
|
|
18
|
-
ImageField: ImageField,
|
|
19
|
-
FileField: FileField,
|
|
20
|
-
NumberField: NumberField,
|
|
21
|
-
RichTextField: RichTextField,
|
|
22
|
-
TextField: TextField,
|
|
23
|
-
UrlField: UrlField,
|
|
24
|
-
SelectField: SelectField,
|
|
25
|
-
ArrayField: ArrayField,
|
|
26
|
-
ReferenceField: ReferenceField,
|
|
27
|
-
ReferenceManyField: ReferenceManyField,
|
|
28
|
-
ReferenceArrayField: ReferenceArrayField,
|
|
29
|
-
AvatarField: AvatarField,
|
|
30
|
-
JsonField: JsonField,
|
|
31
|
-
FKField: FKField,
|
|
32
|
-
// Inputs
|
|
33
|
-
BooleanInput: BooleanInput,
|
|
34
|
-
NullableBooleanInput: NullableBooleanInput,
|
|
35
|
-
DateInput: DateInput,
|
|
36
|
-
DateTimeInput: DateTimeInput,
|
|
37
|
-
ImageInput: ImageInput,
|
|
38
|
-
FileInput: FileInput,
|
|
39
|
-
NumberInput: NumberInput,
|
|
40
|
-
PasswordInput: PasswordInput,
|
|
41
|
-
TextInput: TextInput,
|
|
42
|
-
AutocompleteInput: AutocompleteInput,
|
|
43
|
-
RadioButtonGroupInput: RadioButtonGroupInput,
|
|
44
|
-
SelectInput: SelectInput,
|
|
45
|
-
ArrayInput: ArrayInput,
|
|
46
|
-
AutocompleteArrayInput: AutocompleteArrayInput,
|
|
47
|
-
CheckboxGroupInput: CheckboxGroupInput,
|
|
48
|
-
ReferenceArrayInput: ReferenceArrayInput,
|
|
49
|
-
ReferenceInput: ReferenceInput,
|
|
50
|
-
JsonInput: JsonInput,
|
|
51
|
-
FKInput: FKInput
|
|
52
|
-
};
|
|
53
|
-
export function buildRAComponent(name, props) {
|
|
54
|
-
var _props$fullWidth;
|
|
55
|
-
var Item = UI[name];
|
|
56
|
-
if (props.required) {
|
|
57
|
-
props.validate = required();
|
|
58
|
-
delete props.required;
|
|
59
|
-
}
|
|
60
|
-
props.fullWidth = (_props$fullWidth = props.fullWidth) !== null && _props$fullWidth !== void 0 ? _props$fullWidth : true;
|
|
61
|
-
if (props.children) props.children = initRAItems(props.children)[0];
|
|
62
|
-
return /*#__PURE__*/React.createElement(Item, _extends({
|
|
63
|
-
key: props.source
|
|
64
|
-
}, props));
|
|
65
|
-
}
|
|
66
|
-
export default function initRAItems(items) {
|
|
67
|
-
return items.map(function (item) {
|
|
68
|
-
return buildRAComponent.apply(void 0, _toConsumableArray(item));
|
|
69
|
-
});
|
|
70
|
-
}
|
package/dist/esm/utils.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["data", "query"];
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
/* eslint-disable no-console */
|
|
7
|
-
|
|
8
|
-
import { isValidElement } from "react";
|
|
9
|
-
import { fetchUtils } from "ra-core";
|
|
10
|
-
import { stringify } from "query-string";
|
|
11
|
-
var parts = {};
|
|
12
|
-
export var setupAdmin = function setupAdmin(part, gen) {
|
|
13
|
-
return parts[part] = gen;
|
|
14
|
-
};
|
|
15
|
-
export var checkParams = function checkParams(fn) {
|
|
16
|
-
return function (props, res) {
|
|
17
|
-
if (!props || /*#__PURE__*/isValidElement(props)) return props;
|
|
18
|
-
return fn(props, res);
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export var processAdmin = function processAdmin(type, props, res) {
|
|
22
|
-
if (process.env.NODE_ENV == "development") console.log("".concat(type).concat(res ? "-" + res : ""), props);
|
|
23
|
-
if (parts["".concat(type, "-").concat(res)]) return parts["".concat(type, "-").concat(res)](props, res);
|
|
24
|
-
if (parts[type]) return parts[type](props, res);
|
|
25
|
-
};
|
|
26
|
-
export var requestHeaders = {};
|
|
27
|
-
export var makeRequest = function makeRequest(url, params) {
|
|
28
|
-
var _ref = params || {},
|
|
29
|
-
data = _ref.data,
|
|
30
|
-
query = _ref.query,
|
|
31
|
-
opts = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
if (data) opts.body = JSON.stringify(data);
|
|
33
|
-
if (query) url = "".concat(url, "?").concat(stringify(query));
|
|
34
|
-
opts = _objectSpread(_objectSpread({}, opts), {}, {
|
|
35
|
-
headers: new Headers(_objectSpread(_objectSpread({}, requestHeaders), opts.headers))
|
|
36
|
-
});
|
|
37
|
-
return fetchUtils.fetchJson(url, opts);
|
|
38
|
-
};
|
package/dist/esm/views/create.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Create, SimpleForm, TopToolbar, ListButton } from "react-admin";
|
|
4
|
-
import initRAItems from "../ui";
|
|
5
|
-
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
6
|
-
|
|
7
|
-
// Initialize a create component
|
|
8
|
-
setupAdmin("create", checkParams(function (inputs, res) {
|
|
9
|
-
return function MACreate(props) {
|
|
10
|
-
var Actions = /*#__PURE__*/React.createElement(TopToolbar, null, /*#__PURE__*/React.createElement(ListButton, null));
|
|
11
|
-
return /*#__PURE__*/React.createElement(Create, _extends({
|
|
12
|
-
actions: Actions
|
|
13
|
-
}, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("create-inputs", inputs, res)));
|
|
14
|
-
};
|
|
15
|
-
}));
|
|
16
|
-
setupAdmin("create-inputs", initRAItems);
|
package/dist/esm/views/edit.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Edit, ListButton, ShowButton, SimpleForm, TopToolbar } from "react-admin";
|
|
4
|
-
import initRAItems from "../ui";
|
|
5
|
-
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
6
|
-
import { ActionButton } from "../buttons/ActionButton";
|
|
7
|
-
|
|
8
|
-
// Initialize an edit component
|
|
9
|
-
setupAdmin("edit", checkParams(function (props, name) {
|
|
10
|
-
var edit = props.edit,
|
|
11
|
-
adminProps = props.adminProps;
|
|
12
|
-
var actions = edit.actions,
|
|
13
|
-
inputs = edit.inputs;
|
|
14
|
-
function MAEdit(props) {
|
|
15
|
-
var Actions = function Actions() {
|
|
16
|
-
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
17
|
-
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
18
|
-
key: idx
|
|
19
|
-
}, props));
|
|
20
|
-
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(ShowButton, null));
|
|
21
|
-
};
|
|
22
|
-
return /*#__PURE__*/React.createElement(Edit, _extends({
|
|
23
|
-
actions: /*#__PURE__*/React.createElement(Actions, null),
|
|
24
|
-
mutationMode: adminProps.mutationMode || "optimistic"
|
|
25
|
-
}, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("edit-inputs", inputs, name)));
|
|
26
|
-
}
|
|
27
|
-
return MAEdit;
|
|
28
|
-
}));
|
|
29
|
-
setupAdmin("edit-inputs", initRAItems);
|
package/dist/esm/views/list.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["children", "filters", "edit", "pagination", "show", "limit", "limitMax", "actions"];
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
import React from "react";
|
|
8
|
-
import { BulkDeleteButton, Datagrid, EditButton, Filter, List, Pagination } from "react-admin";
|
|
9
|
-
import uniq from "lodash/uniq";
|
|
10
|
-
import sortBy from "lodash/sortBy";
|
|
11
|
-
import initRAItems from "../ui";
|
|
12
|
-
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
13
|
-
import { BulkActionButton } from "../buttons/ActionButton";
|
|
14
|
-
var defaultPagination = /*#__PURE__*/React.createElement(Pagination, {
|
|
15
|
-
rowsPerPageOptions: [10, 25, 50, 100]
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Initiliaze a list component
|
|
19
|
-
setupAdmin("list", checkParams(function (props, res) {
|
|
20
|
-
var children = props.children,
|
|
21
|
-
filters = props.filters,
|
|
22
|
-
edit = props.edit,
|
|
23
|
-
pagination = props.pagination,
|
|
24
|
-
show = props.show,
|
|
25
|
-
limit = props.limit,
|
|
26
|
-
limitMax = props.limitMax,
|
|
27
|
-
actions = props.actions,
|
|
28
|
-
listProps = _objectWithoutProperties(props, _excluded);
|
|
29
|
-
children = processAdmin("list-fields", children, res);
|
|
30
|
-
if (edit) children.push( /*#__PURE__*/React.createElement(EditButton, {
|
|
31
|
-
key: "edit-button"
|
|
32
|
-
}));
|
|
33
|
-
pagination = pagination || /*#__PURE__*/React.createElement(Pagination, {
|
|
34
|
-
rowsPerPageOptions: sortBy(uniq([10, 25, 50, 100, limit, limitMax]))
|
|
35
|
-
});
|
|
36
|
-
return function MAList(props) {
|
|
37
|
-
var Filters = function Filters(props) {
|
|
38
|
-
return /*#__PURE__*/React.createElement(Filter, props, processAdmin("list-filters", filters, res));
|
|
39
|
-
};
|
|
40
|
-
var Actions = processAdmin("list-bulkActions", actions);
|
|
41
|
-
props = _objectSpread(_objectSpread({}, props), listProps);
|
|
42
|
-
return /*#__PURE__*/React.createElement(List, _extends({
|
|
43
|
-
filters: /*#__PURE__*/React.createElement(Filters, null),
|
|
44
|
-
bulkActionButtons: /*#__PURE__*/React.createElement(Actions, null),
|
|
45
|
-
perPage: limit,
|
|
46
|
-
pagination: pagination || defaultPagination
|
|
47
|
-
}, props), /*#__PURE__*/React.createElement(Datagrid, {
|
|
48
|
-
rowClick: show ? "show" : null
|
|
49
|
-
}, children));
|
|
50
|
-
};
|
|
51
|
-
}));
|
|
52
|
-
setupAdmin("list-bulkActions", function (actions) {
|
|
53
|
-
return function MABulkActions(props) {
|
|
54
|
-
var buttons = actions.map(function (action, idx) {
|
|
55
|
-
var aProps = _objectSpread(_objectSpread({}, action), props);
|
|
56
|
-
return /*#__PURE__*/React.createElement(BulkActionButton, _extends({
|
|
57
|
-
key: idx
|
|
58
|
-
}, aProps));
|
|
59
|
-
});
|
|
60
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, buttons, /*#__PURE__*/React.createElement(BulkDeleteButton, props));
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
setupAdmin("list-filters", initRAItems);
|
|
64
|
-
setupAdmin("list-fields", initRAItems);
|
package/dist/esm/views/show.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { ListButton, EditButton, Show, SimpleShowLayout, TopToolbar } from "react-admin";
|
|
4
|
-
import initRAItems from "../ui";
|
|
5
|
-
import { checkParams, processAdmin, setupAdmin } from "../utils";
|
|
6
|
-
import { ActionButton } from "../buttons/ActionButton";
|
|
7
|
-
|
|
8
|
-
// Initiliaze a show component
|
|
9
|
-
setupAdmin("show", checkParams(function (_ref, resource) {
|
|
10
|
-
var actions = _ref.actions,
|
|
11
|
-
fields = _ref.fields;
|
|
12
|
-
return function MAShow(props) {
|
|
13
|
-
return /*#__PURE__*/React.createElement(Show, _extends({
|
|
14
|
-
actions: processAdmin("show-actions", {
|
|
15
|
-
actions: actions,
|
|
16
|
-
resource: resource
|
|
17
|
-
}, resource)
|
|
18
|
-
}, props), /*#__PURE__*/React.createElement(SimpleShowLayout, null, processAdmin("show-fields", fields, resource)));
|
|
19
|
-
};
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
/* Actions */
|
|
23
|
-
setupAdmin("show-actions", function (_ref2) {
|
|
24
|
-
var actions = _ref2.actions,
|
|
25
|
-
resource = _ref2.resource;
|
|
26
|
-
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
27
|
-
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
28
|
-
key: idx,
|
|
29
|
-
resource: resource
|
|
30
|
-
}, props));
|
|
31
|
-
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(EditButton, null));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
/* Fields */
|
|
35
|
-
setupAdmin("show-fields", initRAItems);
|
package/dist/esm/web.js
DELETED
package/src/admin.jsx
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Admin,
|
|
5
|
-
AppBar,
|
|
6
|
-
Layout,
|
|
7
|
-
Login,
|
|
8
|
-
ToggleThemeButton,
|
|
9
|
-
defaultTheme,
|
|
10
|
-
} from "react-admin"
|
|
11
|
-
import {
|
|
12
|
-
IconButton,
|
|
13
|
-
SvgIcon,
|
|
14
|
-
Tooltip,
|
|
15
|
-
Typography,
|
|
16
|
-
createTheme,
|
|
17
|
-
} from "@mui/material"
|
|
18
|
-
import * as icons from "@mui/icons-material"
|
|
19
|
-
|
|
20
|
-
import authProvider from "./authprovider"
|
|
21
|
-
import dataProvider from "./dataprovider"
|
|
22
|
-
import { processAdmin, setupAdmin } from "./utils"
|
|
23
|
-
|
|
24
|
-
import "./dashboard"
|
|
25
|
-
import "./resources"
|
|
26
|
-
|
|
27
|
-
const darkTheme = createTheme({
|
|
28
|
-
palette: { mode: "dark" },
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Initialize the admin
|
|
32
|
-
setupAdmin("admin", (props) => {
|
|
33
|
-
const { apiUrl, auth, adminProps, appBarLinks, dashboard, resources } = props
|
|
34
|
-
|
|
35
|
-
let appBar = (props) => (
|
|
36
|
-
<AppBar {...props}>
|
|
37
|
-
<Typography
|
|
38
|
-
variant="h6"
|
|
39
|
-
color="inherit"
|
|
40
|
-
id="react-admin-title"
|
|
41
|
-
style={{
|
|
42
|
-
flex: 1,
|
|
43
|
-
textOverflow: "ellipsis",
|
|
44
|
-
whiteSpace: "nowrap",
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
|
-
<ToggleThemeButton lightTheme={defaultTheme} darkTheme={darkTheme} />
|
|
49
|
-
{appBarLinks.map((info) => (
|
|
50
|
-
<Tooltip key={info.url} title={info.title}>
|
|
51
|
-
<IconButton color="inherit" href={info.url}>
|
|
52
|
-
<SvgIcon component={icons[info.icon]} />
|
|
53
|
-
</IconButton>
|
|
54
|
-
</Tooltip>
|
|
55
|
-
))}
|
|
56
|
-
</AppBar>
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Admin
|
|
61
|
-
authProvider={processAdmin("auth", auth)}
|
|
62
|
-
dataProvider={processAdmin("data", apiUrl)}
|
|
63
|
-
dashboard={processAdmin("dashboard", dashboard)}
|
|
64
|
-
loginPage={processAdmin("login", auth)}
|
|
65
|
-
layout={(props) => <Layout appBar={appBar} {...props} />}
|
|
66
|
-
{...adminProps}
|
|
67
|
-
>
|
|
68
|
-
{processAdmin("resources", { resources, adminProps })}
|
|
69
|
-
</Admin>
|
|
70
|
-
)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
// Initialize authentication and data providers
|
|
74
|
-
setupAdmin("auth", authProvider)
|
|
75
|
-
setupAdmin("data", dataProvider)
|
|
76
|
-
|
|
77
|
-
// Initialize login page
|
|
78
|
-
setupAdmin("login", () => Login)
|
package/src/dashboard.jsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Grid,
|
|
5
|
-
Card,
|
|
6
|
-
CardContent,
|
|
7
|
-
Typography,
|
|
8
|
-
Table,
|
|
9
|
-
TableBody,
|
|
10
|
-
TableRow,
|
|
11
|
-
TableCell,
|
|
12
|
-
} from "@mui/material"
|
|
13
|
-
|
|
14
|
-
import { setupAdmin } from "./utils"
|
|
15
|
-
|
|
16
|
-
const AdminTableView = ({ src }) => (
|
|
17
|
-
<Table>
|
|
18
|
-
<TableBody>
|
|
19
|
-
{src.map((row, idx) => (
|
|
20
|
-
<TableRow key={idx} hover>
|
|
21
|
-
{row.map((cell, idx) => (
|
|
22
|
-
<TableCell key={idx}>{cell}</TableCell>
|
|
23
|
-
))}
|
|
24
|
-
</TableRow>
|
|
25
|
-
))}
|
|
26
|
-
</TableBody>
|
|
27
|
-
</Table>
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const AdminCard = ({ src }) => {
|
|
31
|
-
if (Array.isArray(src)) {
|
|
32
|
-
return (
|
|
33
|
-
<Grid container item spacing={2}>
|
|
34
|
-
{src.map((card, idx) => (
|
|
35
|
-
<AdminCard key={idx} src={card} />
|
|
36
|
-
))}
|
|
37
|
-
</Grid>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let { title, value } = src
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Grid item xs>
|
|
45
|
-
<Card>
|
|
46
|
-
<CardContent>
|
|
47
|
-
<Typography
|
|
48
|
-
variant="h5"
|
|
49
|
-
component="h2"
|
|
50
|
-
m={2}
|
|
51
|
-
style={{ textAlign: "center" }}
|
|
52
|
-
>
|
|
53
|
-
{title}
|
|
54
|
-
</Typography>
|
|
55
|
-
{(Array.isArray(value) && <AdminTableView src={value} />) || (
|
|
56
|
-
<pre>{JSON.stringify(value, null, 2)}</pre>
|
|
57
|
-
)}
|
|
58
|
-
</CardContent>
|
|
59
|
-
</Card>
|
|
60
|
-
</Grid>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Process dashboard
|
|
65
|
-
setupAdmin("dashboard", (props) => {
|
|
66
|
-
if (!props) return
|
|
67
|
-
|
|
68
|
-
const Dashboard = () => (
|
|
69
|
-
<Grid container spacing={1}>
|
|
70
|
-
<AdminCard src={props} />
|
|
71
|
-
</Grid>
|
|
72
|
-
)
|
|
73
|
-
return Dashboard
|
|
74
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { useRecordContext } from "ra-core"
|
|
3
|
-
import { BooleanInput } from "ra-ui-materialui"
|
|
4
|
-
|
|
5
|
-
const EditableBooleanField = ({ source, alt, style, nameProp, ...props }) => {
|
|
6
|
-
const record = useRecordContext(props)
|
|
7
|
-
|
|
8
|
-
return <BooleanInput source={source} />
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default EditableBooleanField
|
package/src/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createRoot } from "react-dom/client"
|
|
2
|
-
|
|
3
|
-
import "./admin"
|
|
4
|
-
import { processAdmin } from "./utils"
|
|
5
|
-
|
|
6
|
-
export * from "./utils"
|
|
7
|
-
export { buildRAComponent } from "./ui"
|
|
8
|
-
export { ActionButton } from "./buttons/ActionButton"
|
|
9
|
-
|
|
10
|
-
export async function initAdmin(prefix = "") {
|
|
11
|
-
const response = await fetch(`${prefix}/ra.json`)
|
|
12
|
-
const props = await response.json()
|
|
13
|
-
const container = document.getElementById("root")
|
|
14
|
-
const root = createRoot(container)
|
|
15
|
-
root.render(processAdmin("admin", props))
|
|
16
|
-
}
|
package/src/inputs/FKInput.jsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { ReferenceInput, AutocompleteInput } from "react-admin"
|
|
3
|
-
|
|
4
|
-
const FKInput = ({
|
|
5
|
-
refProp,
|
|
6
|
-
refSource,
|
|
7
|
-
fullWidth,
|
|
8
|
-
reference,
|
|
9
|
-
source,
|
|
10
|
-
...props
|
|
11
|
-
}) => {
|
|
12
|
-
let filterToQuery = (search) => {
|
|
13
|
-
let filters = {}
|
|
14
|
-
filters[refProp] = search
|
|
15
|
-
return filters
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
refSource = refSource || "id"
|
|
19
|
-
|
|
20
|
-
let renderText = (record) => {
|
|
21
|
-
let pk = record[refSource]
|
|
22
|
-
return (pk && `${record[refProp]} (#${pk})`) || ""
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<ReferenceInput
|
|
27
|
-
reference={reference}
|
|
28
|
-
source={source}
|
|
29
|
-
filterToQuery={filterToQuery}
|
|
30
|
-
{...props}
|
|
31
|
-
>
|
|
32
|
-
<AutocompleteInput
|
|
33
|
-
source={refSource}
|
|
34
|
-
optionText={renderText}
|
|
35
|
-
fullWidth={fullWidth}
|
|
36
|
-
{...props}
|
|
37
|
-
/>
|
|
38
|
-
</ReferenceInput>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default FKInput
|
package/src/resources.jsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
|
|
3
|
-
import { Resource } from "react-admin"
|
|
4
|
-
import * as icons from "@mui/icons-material"
|
|
5
|
-
|
|
6
|
-
import { checkParams, processAdmin, setupAdmin } from "./utils"
|
|
7
|
-
import "./views/list"
|
|
8
|
-
import "./views/show"
|
|
9
|
-
import "./views/edit"
|
|
10
|
-
import "./views/create"
|
|
11
|
-
|
|
12
|
-
// Initialize Resources Components
|
|
13
|
-
setupAdmin("resources", ({ resources, adminProps }) =>
|
|
14
|
-
resources.map((resource) =>
|
|
15
|
-
processAdmin("resource", { resource, adminProps }, resource.name)
|
|
16
|
-
)
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
// Initialize a resource's component
|
|
20
|
-
setupAdmin(
|
|
21
|
-
"resource",
|
|
22
|
-
checkParams((props, name) => {
|
|
23
|
-
let { resource, adminProps } = props
|
|
24
|
-
let { create, edit, icon, list, show, ...resProps } = resource
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Resource
|
|
28
|
-
key={name}
|
|
29
|
-
name={name}
|
|
30
|
-
icon={icons[icon]}
|
|
31
|
-
create={processAdmin("create", create, name)}
|
|
32
|
-
edit={processAdmin("edit", { edit, adminProps }, name)}
|
|
33
|
-
list={processAdmin("list", list, name)}
|
|
34
|
-
show={processAdmin("show", show, name)}
|
|
35
|
-
{...resProps}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
)
|
package/src/utils.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
import { isValidElement } from "react"
|
|
4
|
-
import { fetchUtils } from "ra-core"
|
|
5
|
-
import { stringify } from "query-string"
|
|
6
|
-
|
|
7
|
-
const parts = {}
|
|
8
|
-
|
|
9
|
-
export const setupAdmin = (part, gen) => (parts[part] = gen)
|
|
10
|
-
|
|
11
|
-
export const checkParams = (fn) => (props, res) => {
|
|
12
|
-
if (!props || isValidElement(props)) return props
|
|
13
|
-
return fn(props, res)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const processAdmin = (type, props, res) => {
|
|
17
|
-
if (process.env.NODE_ENV == "development")
|
|
18
|
-
console.log(`${type}${res ? "-" + res : ""}`, props)
|
|
19
|
-
|
|
20
|
-
if (parts[`${type}-${res}`]) return parts[`${type}-${res}`](props, res)
|
|
21
|
-
if (parts[type]) return parts[type](props, res)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const requestHeaders = {}
|
|
25
|
-
|
|
26
|
-
export const makeRequest = (url, params) => {
|
|
27
|
-
let { data, query, ...opts } = params || {}
|
|
28
|
-
|
|
29
|
-
if (data) opts.body = JSON.stringify(data)
|
|
30
|
-
if (query) url = `${url}?${stringify(query)}`
|
|
31
|
-
|
|
32
|
-
opts = {
|
|
33
|
-
...opts,
|
|
34
|
-
headers: new Headers({ ...requestHeaders, ...opts.headers }),
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return fetchUtils.fetchJson(url, opts)
|
|
38
|
-
}
|