import{j as e}from"./assertThisInitialized-ClXgY4BW.js";import{d as P}from"./dataProvider-BSMCbdJg.js";import{r as _}from"./index-BP8_t0zE.js";import{D as W,a as k}from"./Confirm-BXDL5GEC.js";import{T as z}from"./TopToolbar-BqW7kXvQ.js";import{B}from"./Box-UI_bZnlM.js";import{S as M}from"./Stack-BmeOikgJ.js";import{T as m}from"./Typography-E7d16C50.js";import{C as i}from"./Create-DhH8wTBS.js";import{S as d,T as t,r as R}from"./SimpleForm-DxY-i_Qk.js";import{D as u}from"./DateInput-Cata5nxE.js";import{B as F}from"./Button-C3j8Wgdd.js";import{A as E}from"./AdminContext-jMMnnv4u.js";import{d as q}from"./defaultI18nProvider-C_r1y4tu.js";import{R as N}from"./ResourceContextProvider-_t2ysSg2.js";import{u as U}from"./DeleteButton-BNKEwqMZ.js";const $=(r,c,l)=>`/redirect/to/${r}/${c}`,V=()=>{console.log("Custom action result")},b=()=>e.jsx(z,{children:e.jsx(F,{color:"primary",onClick:V,label:"Custom Action"})}),I=()=>e.jsx(B,{sx:{paddingX:4,paddingY:8,width:300},children:e.jsxs(M,{spacing:2,children:[e.jsx(m,{variant:"h6",children:"Aside content"}),e.jsx(m,{children:"Additional aside content"})]})}),X={title:"Pages/Create",component:i,decorators:[r=>Y(r)],argTypes:{title:{control:"text"},actions:{control:"select",options:["default","customActions"],mapping:{default:void 0,customActions:e.jsx(b,{})}},aside:{control:"select",options:["default","createAside"],mapping:{default:void 0,createAside:e.jsx(I,{})}},redirect:{control:"select",options:["list","edit","show","disable","redirectToFunction"],mapping:{list:"list",show:"show",disable:!1,redirectToFunction:$}},disableAuthentication:{control:"boolean"},mutationOptions:{control:"text"}}},n={render:({...r})=>e.jsx(i,{...r,children:e.jsxs(d,{children:[e.jsx(t,{source:"id"}),e.jsx(t,{source:"name"}),e.jsx(u,{source:"date"})]})}),wizardName:"pageWizard",info:{pageType:"Create",readonlyPageType:!0}},s={render:({...r})=>e.jsx(i,{actions:e.jsx(b,{}),...r,children:e.jsxs(d,{children:[e.jsx(t,{source:"id"}),e.jsx(t,{source:"name"}),e.jsx(u,{source:"date"})]})})},o={render:({...r})=>e.jsx(i,{aside:e.jsx(I,{}),...r,children:e.jsxs(d,{children:[e.jsx(t,{source:"id"}),e.jsx(t,{source:"name"}),e.jsx(u,{source:"date"})]})})},a={render:()=>{const[r,c]=_.useState(!1),l=()=>{let{save:p}=U();const O=async w=>{p&&await p(w,{onSuccess:()=>c(!1)})};return e.jsxs(d,{onSubmit:O,children:[e.jsx(t,{source:"id"}),e.jsx(t,{source:"name",validate:R()}),e.jsx(u,{source:"date"})]})};return e.jsxs(e.Fragment,{children:[e.jsx(F,{onClick:()=>c(!0),label:"Open Dialog"}),e.jsxs(W,{open:r,fullWidth:!0,maxWidth:"xs",children:[e.jsx(k,{children:"Create User"}),e.jsx(i,{children:e.jsx(l,{})})]})]})}},Y=r=>e.jsx(E,{dataProvider:P,i18nProvider:q,children:e.jsx(N,{value:"users",children:e.jsx(r,{})})});var x,j,f;n.parameters={...n.parameters,docs:{...(x=n.parameters)==null?void 0:x.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Create {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Create>;
  },
  wizardName: "pageWizard",
  info: {
    pageType: "Create",
    readonlyPageType: true
  }
}`,...(f=(j=n.parameters)==null?void 0:j.docs)==null?void 0:f.source}}};var C,g,h;s.parameters={...s.parameters,docs:{...(C=s.parameters)==null?void 0:C.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Create actions={<CreateActions />} {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Create>;
  }
}`,...(h=(g=s.parameters)==null?void 0:g.docs)==null?void 0:h.source}}};var S,T,D;o.parameters={...o.parameters,docs:{...(S=o.parameters)==null?void 0:S.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Create aside={<CreateAside />} {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Create>;
  }
}`,...(D=(T=o.parameters)==null?void 0:T.docs)==null?void 0:D.source}}};var v,A,y;a.parameters={...a.parameters,docs:{...(v=a.parameters)==null?void 0:v.docs,source:{originalSource:`{
  render: () => {
    const [open, setOpen] = useState(false);
    const MyForm = () => {
      let {
        save
      } = useSaveContext();
      const onSubmit = async (values: FieldValues) => {
        if (save) {
          await save(values, {
            onSuccess: () => setOpen(false)
          });
        }
      };
      return <SimpleForm onSubmit={onSubmit}>
          <TextInput source="id" />
          <TextInput source="name" validate={required()} />
          <DateInput source="date" />
        </SimpleForm>;
    };
    return <>
        <Button onClick={() => setOpen(true)} label="Open Dialog" />

        <Dialog open={open} fullWidth maxWidth="xs">
          <DialogTitle>Create User</DialogTitle>
          <Create>
            <MyForm />
          </Create>
        </Dialog>
      </>;
  }
}`,...(y=(A=a.parameters)==null?void 0:A.docs)==null?void 0:y.source}}};const G=["Default","CustomActions","Aside","CreateDialog"],ue=Object.freeze(Object.defineProperty({__proto__:null,Aside:o,CreateDialog:a,CustomActions:s,Default:n,__namedExportsOrder:G,default:X},Symbol.toStringTag,{value:"Module"}));export{o as A,ue as C,n as D,s as a};
