import{j as e}from"./assertThisInitialized-ClXgY4BW.js";import{d as g,b as j}from"./dataProvider-BSMCbdJg.js";import{G as b}from"./api-D469Uxm1.js";import{r as h,a as x}from"./ideExtension-Duoj5XVI.js";import{A as I}from"./utils-CkyKHvS2.js";import{T as s}from"./Typography-E7d16C50.js";import{R}from"./ReferenceManyField-Do-6y4r4.js";import{D as T}from"./Datagrid-BK2vyqjN.js";import{T as n}from"./TextField-n0Myx-gm.js";import{S as C}from"./SimpleList-DYXh3sa6.js";import{A as S}from"./AdminContext-jMMnnv4u.js";import{d as v}from"./defaultI18nProvider-C_r1y4tu.js";import{R as N}from"./ResourceContextProvider-_t2ysSg2.js";import{R as D}from"./useRecordContext-CmNI-aHo.js";import{S as M}from"./Show-CQpDTbX7.js";import{S as F,L as m}from"./SimpleShowLayout-Bj8OsoZA.js";import"./index-BP8_t0zE.js";import"./useResourceDefinitionContext-mEDLreK0.js";import"./debounce-0x2xWYwC.js";import"./useGetList-Dit6Yzrj.js";import"./useQuery-DJhJ3Hj4.js";import"./useLogout-DAYYFX4P.js";import"./Button-C3j8Wgdd.js";import"./useDataProvider-BTi1EEZL.js";import"./hooks-kyAPvxe4.js";import"./usePaginationState-CSxOqUBu.js";import"./useRemoveFromStore-DvPdj666.js";import"./useResourceContext-BI9mATY-.js";import"./ListNoResults-BHi6V5m8.js";import"./pick-BQz50zYv.js";import"./hasIn-BUTlUeuZ.js";import"./_isIterateeCall-D0xvKagp.js";import"./identity-B2iMGpmP.js";import"./useAuthenticated-CxLvTTH7.js";import"./useAuthState-Chcbfem2.js";import"./colorManipulator-DXmmM2jC.js";import"./CardContent-C5u1opi3.js";import"./SwitchBase-GsdOADyY.js";import"./_baseUniq-BtunyI9N.js";import"./isArrayLikeObject-WBq23Ido.js";import"./useFormControl-D0zEVldg.js";import"./createSvgIcon-C1LdFc73.js";import"./getFieldLabelTranslationArgs-DwcCC9dO.js";import"./ExpandMore-Bu7ZqolT.js";import"./createSvgIcon-BeVLBbd8.js";import"./TopToolbar-BqW7kXvQ.js";import"./Toolbar-C8uTbHq-.js";import"./Confirm-BXDL5GEC.js";import"./Modal-CloRq8hE.js";import"./useMutation-DBpLFNEy.js";import"./undoableEventEmitter-DTIdLI-s.js";import"./useRefresh-BVYjI9Ho.js";import"./index-qEiLzbkV.js";import"./index-BCKAMao3.js";import"./TextField-z9WrHgJg.js";import"./Avatar-CDOhctCa.js";import"./ListItemText-Cc_vo_cp.js";import"./listItemTextClasses-C7xWMLDP.js";import"./useGetRecordRepresentation-DwGaoA_n.js";import"./PreferencesEditorContext-oPOmBo-a.js";import"./useRedirect-BE8GZC2N.js";import"./useGetOne-Ddk2GsYy.js";import"./EditButton-DudJBc_J.js";import"./Card-Cv9uZOGS.js";import"./Title-Db_cbkJo.js";import"./warning-3oRADCZr.js";import"./Stack-BmeOikgJ.js";import"./OptionalRecordContextProvider-ChL7EZ8k.js";const Ke={title:"Relations/Reference/ManyToOne",component:I,decorators:[r=>k(r)]},t={render:({subresourceName:r,subresourceBackReference:i,...y})=>e.jsxs(e.Fragment,{children:[e.jsx(s,{variant:"body2",children:"Department people"}),e.jsx(b.InsertOnly,{children:e.jsx(R,{target:i,reference:r,children:e.jsx(T,{children:e.jsx(n,{source:"id"})})})})]}),args:{subresourceName:h("people",{title:"Child Resource",resourceId:"subresource",allowContext:!1}),subresourceBackReference:x("department_id",{resourceId:"subresource",attributeSelectTitle:"Reference Attribute from Child Resource to Main Resource"})}},o={render:({subresourceName:r,subresourceBackReference:i,...y})=>e.jsxs(e.Fragment,{children:[e.jsx(s,{variant:"body2",children:"Department people"}),e.jsx(b.InsertOnly,{children:e.jsx(R,{target:i,reference:r,children:e.jsx(C,{leftIcon:a=>e.jsxs(s,{variant:"body1",children:["Id: ",a.id]}),primaryText:a=>a.name})})})]}),args:{subresourceName:h("people",{title:"Child Resource",resourceId:"subresource",allowContext:!1}),subresourceBackReference:x("department_id",{resourceId:"subresource",attributeSelectTitle:"Reference Attribute from Child Resource to Main Resource"})}},k=r=>e.jsx(S,{dataProvider:g,i18nProvider:v,children:e.jsx(N,{value:"departments",children:e.jsx(D,{value:j[2],children:e.jsx(M,{resource:"departments",id:2,children:e.jsxs(F,{children:[e.jsx(s,{variant:"h5",children:"Department"}),e.jsx(m,{children:e.jsx(n,{source:"id"})}),e.jsx(m,{children:e.jsx(n,{source:"name"})}),e.jsx(r,{})]})})})})});var p,c,u;t.parameters={...t.parameters,docs:{...(p=t.parameters)==null?void 0:p.docs,source:{originalSource:`{
  render: ({
    subresourceName,
    subresourceBackReference,
    ...props
  }) => {
    return <>
                <Typography variant="body2">Department people</Typography>
                <GenerationInstructions.InsertOnly>
                    <ReferenceManyField target={subresourceBackReference} reference={subresourceName}>
                        <Datagrid>
                            <TextField source="id" />
                            {/*  use 'field' completion to generate other fields  */}
                        </Datagrid>
                    </ReferenceManyField>
                </GenerationInstructions.InsertOnly>
            </>;
  },
  args: {
    subresourceName: resourceName("people", {
      title: 'Child Resource',
      resourceId: 'subresource',
      allowContext: false
    }),
    subresourceBackReference: attributeName("department_id", {
      resourceId: 'subresource',
      attributeSelectTitle: 'Reference Attribute from Child Resource to Main Resource'
    })
  }
}`,...(u=(c=t.parameters)==null?void 0:c.docs)==null?void 0:u.source}}};var d,l,f;o.parameters={...o.parameters,docs:{...(d=o.parameters)==null?void 0:d.docs,source:{originalSource:`{
  render: ({
    subresourceName,
    subresourceBackReference,
    ...props
  }) => {
    return <>
                <Typography variant="body2">Department people</Typography>
                <GenerationInstructions.InsertOnly>
                    <ReferenceManyField target={subresourceBackReference} reference={subresourceName}>
                        <SimpleList leftIcon={record => <Typography variant="body1">Id: {record.id}</Typography>} primaryText={record => record.name} />
                    </ReferenceManyField>
                </GenerationInstructions.InsertOnly>
            </>;
  },
  args: {
    subresourceName: resourceName("people", {
      title: 'Child Resource',
      resourceId: 'subresource',
      allowContext: false
    }),
    subresourceBackReference: attributeName("department_id", {
      resourceId: 'subresource',
      attributeSelectTitle: 'Reference Attribute from Child Resource to Main Resource'
    })
  }
}`,...(f=(l=o.parameters)==null?void 0:l.docs)==null?void 0:f.source}}};const Qe=["WithDatagrid","WithSimpleList"];export{t as WithDatagrid,o as WithSimpleList,Qe as __namedExportsOrder,Ke as default};
