import{j as e}from"./assertThisInitialized-ClXgY4BW.js";import{a as d}from"./dataProvider-BSMCbdJg.js";import{G as m,r as c}from"./api-D469Uxm1.js";import{r as l}from"./ideExtension-Duoj5XVI.js";import{u}from"./useCreate-CQ5Hl1r5.js";import{B as p}from"./Button-C3j8Wgdd.js";import{A as x}from"./AdminContext-jMMnnv4u.js";import{d as f}from"./defaultI18nProvider-C_r1y4tu.js";import"./index-BP8_t0zE.js";import"./useMutation-DBpLFNEy.js";import"./useLogout-DAYYFX4P.js";import"./useDataProvider-BTi1EEZL.js";import"./PreferencesEditorContext-oPOmBo-a.js";import"./index-qEiLzbkV.js";import"./index-BCKAMao3.js";const k={title:"DataProvider/UseCreate",parameters:{layout:"centered"},decorators:[r=>C(r)]},a={render:()=>{let[r,{data:t,isLoading:i}]=u(l("users",{allowContext:!1}),{data:c({name:"New user"})});return e.jsxs(m.Exclude,{children:[e.jsx(p,{label:"Create",onClick:()=>r()}),e.jsx("p",{}),i&&"Loading",t&&e.jsxs(e.Fragment,{children:["Created: ",t.name]})]})}},C=r=>e.jsx(x,{dataProvider:d,i18nProvider:f,children:e.jsx(r,{})});var o,s,n;a.parameters={...a.parameters,docs:{...(o=a.parameters)==null?void 0:o.docs,source:{originalSource:`{
  render: () => {
    let [create, {
      data,
      isLoading
    }] = useCreate(resourceName('users', {
      allowContext: false
    }), {
      data: replaceOnGenerate({
        name: 'New user'
      }, {})
    });
    return <GenerationInstructions.Exclude>
            <Button label="Create" onClick={() => create()} />
            <p />
            {isLoading && 'Loading'}
            {data && <>Created: {data.name}</>}
        </GenerationInstructions.Exclude>;
  }
}`,...(n=(s=a.parameters)==null?void 0:s.docs)==null?void 0:n.source}}};const y=["Default"];export{a as Default,y as __namedExportsOrder,k as default};
