muffin-admin 3.7.0 → 3.7.2

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.
@@ -34,7 +34,7 @@ setupAdmin(["list-grid-buttons"], MuffinListGridButtons);
34
34
  function MuffinListToolbar() {
35
35
  const { actions: baseActions = [], list: { create }, } = useMuffinResourceOpts();
36
36
  const actions = baseActions.filter((a) => a.view.includes("list"));
37
- return (_jsxs(TopToolbar, { children: [_jsx(SelectColumnsButton, {}), _jsx(FilterButton, {}), actions.length && actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)), create && _jsx(CreateButton, {}), _jsx(ExportButton, {})] }));
37
+ return (_jsxs(TopToolbar, { children: [_jsx(SelectColumnsButton, {}), _jsx(FilterButton, {}), actions.length ? actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)) : null, create && _jsx(CreateButton, {}), _jsx(ExportButton, {})] }));
38
38
  }
39
39
  setupAdmin(["list-toolbar"], MuffinListToolbar);
40
40
  function MuffinListBulkActions() {
package/dist/buildRA.js CHANGED
@@ -45,7 +45,6 @@ const UI = {
45
45
  FKInput,
46
46
  };
47
47
  export function buildRAComponent(name, props) {
48
- var _a;
49
48
  const Item = UI[name];
50
49
  if (!Item)
51
50
  return null;
@@ -53,7 +52,6 @@ export function buildRAComponent(name, props) {
53
52
  props.validate = required();
54
53
  delete props.required;
55
54
  }
56
- props.fullWidth = (_a = props.fullWidth) !== null && _a !== void 0 ? _a : true;
57
55
  if (props.children)
58
56
  props.children = buildRA(props.children)[0];
59
57
  return _jsx(Item, Object.assign({}, props), props.source);
@@ -18,8 +18,9 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
22
- import { Button, Form, useListContext, useRecordContext, useResourceContext, useTranslate, } from "react-admin";
21
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { Button, FormGroupsProvider, useAugmentedForm, useListContext, useRecordContext, useResourceContext, useTranslate, } from "react-admin";
23
+ import { FormProvider } from "react-hook-form";
23
24
  import { useState } from "react";
24
25
  import { buildRA } from "../buildRA";
25
26
  import { AdminModal, PayloadButtons, useConfirmation } from "../common";
@@ -55,14 +56,6 @@ export function BulkActionButton(_a) {
55
56
  });
56
57
  return _jsx(ActionButtonBase, Object.assign({}, props, { onHandle: onHandle, isPending: isPending }));
57
58
  }
58
- export function CommonPayload({ active, onClose, onHandle, schema, title }) {
59
- const inputs = buildRA(schema);
60
- const translate = useTranslate();
61
- return (_jsx(AdminModal, { maxWidth: "sm", open: active, onClose: onClose, title: translate(title, { _: title }), children: _jsxs(Form, { onSubmit: (data) => {
62
- onClose();
63
- onHandle(data);
64
- }, children: [inputs, _jsx(PayloadButtons, { onClose: onClose })] }) }));
65
- }
66
59
  function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id, }) {
67
60
  const resource = useResourceContext();
68
61
  const [payloadActive, setPayloadActive] = useState(false);
@@ -74,3 +67,17 @@ function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id,
74
67
  onHandle();
75
68
  }, disabled: isPending, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: onHandle, onClose: () => setPayloadActive(false), title: title || label, schema: schema }))] }));
76
69
  }
70
+ export function CommonPayload({ active, onClose, onHandle, schema, title }) {
71
+ schema[0][1] = Object.assign(Object.assign({}, schema[0][1]), { autoFocus: true });
72
+ const inputs = buildRA(schema);
73
+ const translate = useTranslate();
74
+ const { form, formHandleSubmit } = useAugmentedForm({
75
+ onSubmit: (data) => {
76
+ onClose();
77
+ onHandle(data);
78
+ form.reset();
79
+ },
80
+ record: {},
81
+ });
82
+ return (_jsx(AdminModal, { maxWidth: "sm", open: active, onClose: onClose, title: translate(title, { _: title }), children: _jsx(FormProvider, Object.assign({}, form, { children: _jsx(FormGroupsProvider, { children: _jsxs("form", { onSubmit: formHandleSubmit, children: [inputs, _jsx(PayloadButtons, { onClose: onClose })] }) }) })) }));
83
+ }