import{j as e}from"./assertThisInitialized-ClXgY4BW.js";import{d as M}from"./dataProvider-BSMCbdJg.js";import{r as f}from"./index-BP8_t0zE.js";import{E as R,u as q}from"./EditView-DCTtH4Lg.js";import{E as z}from"./EditBase-zpPedF3-.js";import{u as L}from"./checkMinimumRequiredProps-BCJG0Ked.js";import{B as N}from"./Box-UI_bZnlM.js";import{S as W}from"./Stack-BmeOikgJ.js";import{T as j}from"./Typography-E7d16C50.js";import{L as $}from"./List-D8wQapDP.js";import{S as p,T as i}from"./SimpleForm-DxY-i_Qk.js";import{D as l}from"./DateInput-Cata5nxE.js";import{A as V}from"./AdminContext-jMMnnv4u.js";import{d as X}from"./defaultI18nProvider-C_r1y4tu.js";import{R as Y}from"./ResourceContextProvider-_t2ysSg2.js";import{T as G}from"./TopToolbar-BqW7kXvQ.js";import{B as H}from"./Button-C3j8Wgdd.js";import{C as J}from"./CreateButton-BoKnyQsN.js";import{D as K}from"./Datagrid-BK2vyqjN.js";import{T as Q}from"./TextField-n0Myx-gm.js";var x=function(){return x=Object.assign||function(r){for(var o,t=1,n=arguments.length;t<n;t++){o=arguments[t];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},x.apply(this,arguments)},U=function(r,o){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&o.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)o.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},m=function(r){L("Edit",["children"],r);var o=r.resource,t=r.id,n=r.mutationMode,s=r.mutationOptions,D=r.queryOptions,P=r.redirect,w=r.transform,k=r.disableAuthentication,B=U(r,["resource","id","mutationMode","mutationOptions","queryOptions","redirect","transform","disableAuthentication"]);return f.createElement(z,{resource:o,id:t,mutationMode:n,mutationOptions:s,queryOptions:D,redirect:P,transform:w,disableAuthentication:k},f.createElement(R,x({},B)))};const Z=()=>{console.log("Custom action result")},F=()=>e.jsx(G,{children:e.jsx(H,{color:"primary",onClick:Z,label:"Custom Action"})}),I=()=>e.jsx(N,{sx:{paddingX:4,paddingY:8,width:300},children:e.jsxs(W,{spacing:2,children:[e.jsx(j,{variant:"h6",children:"Aside content"}),e.jsx(j,{children:"Additional aside content"})]})}),ee=(r,o,t)=>`/redirect/to/${r}/${o}`,re={title:"Pages/Edit",component:m,decorators:[r=>te(r)],args:{id:2},argTypes:{title:{control:"text"},actions:{control:"select",options:["default","customActions"],mapping:{default:void 0,customActions:e.jsx(F,{})}},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:ee}},disableAuthentication:{control:"boolean"},mutationMode:{control:"select",options:["pessimistic","optimistic","undoable"]},mutationOptions:{control:"text"}}},a={render:({...r})=>e.jsx(m,{resource:"users",...r,children:e.jsxs(p,{children:[e.jsx(i,{source:"id"}),e.jsx(i,{source:"name"}),e.jsx(l,{source:"date"})]})}),wizardName:"pageWizard",info:{pageType:"Edit",readonlyPageType:!0}},d={render:({...r})=>e.jsx(m,{actions:e.jsx(F,{}),...r,children:e.jsxs(p,{children:[e.jsx(i,{source:"id"}),e.jsx(i,{source:"name"}),e.jsx(l,{source:"date"})]})})},c={render:({...r})=>e.jsx(m,{aside:e.jsx(I,{}),...r,children:e.jsxs(p,{children:[e.jsx(i,{source:"id"}),e.jsx(i,{source:"name"}),e.jsx(l,{source:"date"})]})})},u={render:({...r})=>{const o=()=>{const{record:t}=q();return t?e.jsx($,{resource:"tasks",filter:{user_id:t.id},actions:e.jsx(e.Fragment,{children:e.jsx(J,{state:{record:{user_id:t.id}}})}),children:e.jsx(K,{children:e.jsx(Q,{source:"name"})})}):e.jsx(e.Fragment,{})};return e.jsx(m,{resource:"users",...r,children:e.jsxs(p,{children:[e.jsx(i,{source:"id"}),e.jsx(i,{source:"name"}),e.jsx(l,{source:"date"}),e.jsx(o,{})]})})}},te=r=>e.jsx(V,{dataProvider:M,i18nProvider:X,children:e.jsx(Y,{value:"users",children:e.jsx(r,{})})});var g,h,T;a.parameters={...a.parameters,docs:{...(g=a.parameters)==null?void 0:g.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Edit resource={"users"} {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Edit>;
  },
  wizardName: "pageWizard",
  info: {
    pageType: "Edit",
    readonlyPageType: true
  }
}`,...(T=(h=a.parameters)==null?void 0:h.docs)==null?void 0:T.source}}};var E,b,y;d.parameters={...d.parameters,docs:{...(E=d.parameters)==null?void 0:E.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Edit actions={<CustomEditActions />} {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Edit>;
  }
}`,...(y=(b=d.parameters)==null?void 0:b.docs)==null?void 0:y.source}}};var O,S,A;c.parameters={...c.parameters,docs:{...(O=c.parameters)==null?void 0:O.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    return <Edit aside={<CustomEditAside />} {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />
        </SimpleForm>
      </Edit>;
  }
}`,...(A=(S=c.parameters)==null?void 0:S.docs)==null?void 0:A.source}}};var C,_,v;u.parameters={...u.parameters,docs:{...(C=u.parameters)==null?void 0:C.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    const TasksTable = () => {
      const {
        record: user
      } = useEditContext();
      if (!user) return <></>;
      return <List resource="tasks" filter={{
        user_id: user.id
      }} actions={<>
              <CreateButton state={{
          record: {
            user_id: user.id
          }
        }} />
            </>}>
          <Datagrid>
            <TextField source="name" />
          </Datagrid>
        </List>;
    };
    return <Edit resource="users" {...props}>
        <SimpleForm>
          <TextInput source="id" />
          <TextInput source="name" />
          <DateInput source="date" />

          <TasksTable />
        </SimpleForm>
      </Edit>;
  }
}`,...(v=(_=u.parameters)==null?void 0:_.docs)==null?void 0:v.source}}};const ne=["Default","CustomActions","Aside","SubResource"],Se=Object.freeze(Object.defineProperty({__proto__:null,Aside:c,CustomActions:d,Default:a,SubResource:u,__namedExportsOrder:ne,default:re},Symbol.toStringTag,{value:"Module"}));export{d as C,a as D,Se as E};
