import{j as e}from"./assertThisInitialized-ClXgY4BW.js";import{d as R,b as j}from"./dataProvider-BSMCbdJg.js";import{G as y}from"./api-D469Uxm1.js";import{r as h,a as b}from"./ideExtension-Duoj5XVI.js";import{A as I}from"./utils-CkyKHvS2.js";import{T as i}from"./Typography-E7d16C50.js";import{R as x}from"./ReferenceArrayField-ctaku4-6.js";import{D as N}from"./Datagrid-BK2vyqjN.js";import{T as m}from"./TextField-n0Myx-gm.js";import{S as g}from"./SimpleList-DYXh3sa6.js";import{A as T}from"./AdminContext-jMMnnv4u.js";import{d as C}from"./defaultI18nProvider-C_r1y4tu.js";import{R as S}from"./ResourceContextProvider-_t2ysSg2.js";import{R as v}from"./useRecordContext-CmNI-aHo.js";import{S as D}from"./Show-CQpDTbX7.js";import{S as P,L as p}from"./SimpleShowLayout-Bj8OsoZA.js";import"./index-BP8_t0zE.js";import"./useResourceDefinitionContext-mEDLreK0.js";import"./Box-UI_bZnlM.js";import"./hooks-kyAPvxe4.js";import"./index-qEiLzbkV.js";import"./index-BCKAMao3.js";import"./Stack-BmeOikgJ.js";import"./Chip-4IhPI0f3.js";import"./useQuery-DJhJ3Hj4.js";import"./useLogout-DAYYFX4P.js";import"./Button-C3j8Wgdd.js";import"./SwitchBase-GsdOADyY.js";import"./pick-BQz50zYv.js";import"./hasIn-BUTlUeuZ.js";import"./_isIterateeCall-D0xvKagp.js";import"./identity-B2iMGpmP.js";import"./_baseUniq-BtunyI9N.js";import"./isArrayLikeObject-WBq23Ido.js";import"./useFormControl-D0zEVldg.js";import"./useDataProvider-BTi1EEZL.js";import"./useGetList-Dit6Yzrj.js";import"./usePaginationState-CSxOqUBu.js";import"./useRemoveFromStore-DvPdj666.js";import"./useResourceContext-BI9mATY-.js";import"./createSvgIcon-C1LdFc73.js";import"./useGetRecordRepresentation-DwGaoA_n.js";import"./useAuthenticated-CxLvTTH7.js";import"./useAuthState-Chcbfem2.js";import"./colorManipulator-DXmmM2jC.js";import"./ListNoResults-BHi6V5m8.js";import"./debounce-0x2xWYwC.js";import"./CardContent-C5u1opi3.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"./TextField-z9WrHgJg.js";import"./Avatar-CDOhctCa.js";import"./ListItemText-Cc_vo_cp.js";import"./listItemTextClasses-C7xWMLDP.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"./OptionalRecordContextProvider-ChL7EZ8k.js";const Ue={title:"Relations/Reference/ManyToMany",component:I,decorators:[r=>F(r)]},t={render:({subresourceName:r,idArrayAttributeName:a,...A})=>e.jsxs(e.Fragment,{children:[e.jsx(i,{variant:"body2",children:"Department people"}),e.jsx(y.InsertOnly,{children:e.jsx(x,{source:a,reference:r,children:e.jsx(N,{children:e.jsx(m,{source:"id"})})})})]}),args:{subresourceName:h("people",{title:"Child Resource",resourceId:"subresource",allowContext:!1}),idArrayAttributeName:b("department_id",{resourceId:"parentResource",attributeSelectTitle:"Reference Attribute from Parent to Child Resource"})}},o={render:({subresourceName:r,idArrayAttributeName:a,...A})=>e.jsxs(e.Fragment,{children:[e.jsx(i,{variant:"body2",children:"Department people"}),e.jsx(y.InsertOnly,{children:e.jsx(x,{source:a,reference:r,children:e.jsx(g,{leftIcon:s=>e.jsxs(i,{variant:"body1",children:["Id: ",s.id]}),primaryText:s=>s.name})})})]}),args:{subresourceName:h("people",{title:"Child Resource",resourceId:"subresource",allowContext:!1}),idArrayAttributeName:b("department_id",{resourceId:"parentResource",attributeSelectTitle:"Reference Attribute from Parent to Child Resource"})}},F=r=>e.jsx(T,{dataProvider:R,i18nProvider:C,children:e.jsx(S,{value:"departments",children:e.jsx(v,{value:j[2],children:e.jsx(D,{resource:"departments",id:2,children:e.jsxs(P,{children:[e.jsx(i,{variant:"h5",children:"Department"}),e.jsx(p,{children:e.jsx(m,{source:"id"})}),e.jsx(p,{children:e.jsx(m,{source:"name"})}),e.jsx(r,{})]})})})})});var n,c,d;t.parameters={...t.parameters,docs:{...(n=t.parameters)==null?void 0:n.docs,source:{originalSource:`{
  render: ({
    subresourceName,
    idArrayAttributeName,
    ...props
  }) => {
    return <>
                <Typography variant="body2">Department people</Typography>
                <GenerationInstructions.InsertOnly>
                    <ReferenceArrayField source={idArrayAttributeName} reference={subresourceName}>
                        <Datagrid>
                            <TextField source="id" />
                            {/*  use 'field' completion to generate other fields  */}
                        </Datagrid>
                    </ReferenceArrayField>
                </GenerationInstructions.InsertOnly>
            </>;
  },
  args: {
    subresourceName: resourceName("people", {
      title: 'Child Resource',
      resourceId: 'subresource',
      allowContext: false
    }),
    idArrayAttributeName: attributeName("department_id", {
      resourceId: 'parentResource',
      attributeSelectTitle: 'Reference Attribute from Parent to Child Resource'
    })
  }
}`,...(d=(c=t.parameters)==null?void 0:c.docs)==null?void 0:d.source}}};var u,l,f;o.parameters={...o.parameters,docs:{...(u=o.parameters)==null?void 0:u.docs,source:{originalSource:`{
  render: ({
    subresourceName,
    idArrayAttributeName,
    ...props
  }) => {
    return <>
                <Typography variant="body2">Department people</Typography>
                <GenerationInstructions.InsertOnly>
                    <ReferenceArrayField source={idArrayAttributeName} reference={subresourceName}>
                        <SimpleList leftIcon={record => <Typography variant="body1">Id: {record.id}</Typography>} primaryText={record => record.name} />
                    </ReferenceArrayField>
                </GenerationInstructions.InsertOnly>
            </>;
  },
  args: {
    subresourceName: resourceName("people", {
      title: 'Child Resource',
      resourceId: 'subresource',
      allowContext: false
    }),
    idArrayAttributeName: attributeName("department_id", {
      resourceId: 'parentResource',
      attributeSelectTitle: 'Reference Attribute from Parent to Child Resource'
    })
  }
}`,...(f=(l=o.parameters)==null?void 0:l.docs)==null?void 0:f.source}}};const Ve=["WithDatagrid","WithSimpleList"];export{t as WithDatagrid,o as WithSimpleList,Ve as __namedExportsOrder,Ue as default};
