ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
53 lines • 1.88 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import * as React from 'react';
import { useEditController } from './useEditController';
import { EditContextProvider } from './EditContextProvider';
import { ResourceContextProvider } from '../../core';
/**
* Call useEditController and put the value in a EditContext
*
* Base class for <Edit> components, without UI.
*
* Accepts any props accepted by useEditController:
* - id: The record identifier
* - resource: The resource
*
* @example // Custom edit layout
*
* const PostEdit = () => (
* <EditBase resource="posts">
* <Grid container>
* <Grid item xs={8}>
* <SimpleForm>
* ...
* </SimpleForm>
* </Grid>
* <Grid item xs={4}>
* Edit instructions...
* </Grid>
* </Grid>
* <div>
* Post related links...
* </div>
* </EditBase>
* );
*/
export var EditBase = function (_a) {
var children = _a.children, props = __rest(_a, ["children"]);
var controllerProps = useEditController(props);
var body = (React.createElement(EditContextProvider, { value: controllerProps }, children));
return props.resource ? (
// support resource override via props
React.createElement(ResourceContextProvider, { value: props.resource }, body)) : (body);
};
//# sourceMappingURL=EditBase.js.map