import{j as r}from"./assertThisInitialized-ClXgY4BW.js";import{r as h}from"./index-BP8_t0zE.js";import{e as g,b as y,x as j,M as w,t as D,v}from"./defaultI18nProvider-C_r1y4tu.js";import{a as I}from"./utils-CkyKHvS2.js";import{D as C,d as S}from"./Datagrid-BK2vyqjN.js";import{B as R}from"./Box-UI_bZnlM.js";import{D as T}from"./Drawer-DxQ4FZ07.js";import{S as B}from"./Stack-BmeOikgJ.js";import{T as k}from"./Typography-E7d16C50.js";import{I as z}from"./Button-C3j8Wgdd.js";import{L as u}from"./List-D8wQapDP.js";import{T as m}from"./TextField-n0Myx-gm.js";import{E}from"./EditBase-zpPedF3-.js";import{S as P,T as b}from"./SimpleForm-DxY-i_Qk.js";import{D as N}from"./DateInput-Cata5nxE.js";import{B as _,R as F}from"./ReferenceInput-DMhWsfVF.js";import{N as L}from"./NumberInput-D5bldgKh.js";import{R as M}from"./ResourceContextProvider-_t2ysSg2.js";import"./index-BCKAMao3.js";import"./dataProvider-BSMCbdJg.js";import"./useResourceDefinitionContext-mEDLreK0.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"./createSvgIcon-C1LdFc73.js";import"./useResourceContext-BI9mATY-.js";import"./getFieldLabelTranslationArgs-DwcCC9dO.js";import"./colorManipulator-DXmmM2jC.js";import"./ExpandMore-Bu7ZqolT.js";import"./createSvgIcon-BeVLBbd8.js";import"./useAuthenticated-CxLvTTH7.js";import"./useAuthState-Chcbfem2.js";import"./useQuery-DJhJ3Hj4.js";import"./useLogout-DAYYFX4P.js";import"./ListNoResults-BHi6V5m8.js";import"./useGetList-Dit6Yzrj.js";import"./useDataProvider-BTi1EEZL.js";import"./useRemoveFromStore-DvPdj666.js";import"./debounce-0x2xWYwC.js";import"./hooks-kyAPvxe4.js";import"./CardContent-C5u1opi3.js";import"./useRecordContext-CmNI-aHo.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"./ListView-BNoLT4yC.js";import"./Title-Db_cbkJo.js";import"./PreferencesEditorContext-oPOmBo-a.js";import"./TextField-z9WrHgJg.js";import"./warning-3oRADCZr.js";import"./FormGroupsProvider-B1X-6k0S.js";import"./cloneDeep-BX3t29rH.js";import"./_copyObject-Dr_k0OJK.js";import"./CreateButton-BoKnyQsN.js";import"./merge-2TaxnYbe.js";import"./index-qEiLzbkV.js";import"./Clear-2k3OxyE6.js";import"./MenuItem-CP3dxiK8.js";import"./listItemTextClasses-C7xWMLDP.js";import"./ListItemText-Cc_vo_cp.js";import"./Card-Cv9uZOGS.js";import"./ListBase-CEqRUlEo.js";import"./useGetRecordRepresentation-DwGaoA_n.js";import"./useGetOne-Ddk2GsYy.js";import"./useUpdate-B6txAJ-A.js";import"./useRedirect-BE8GZC2N.js";import"./CircularProgress-CoZCnRya.js";import"./DeleteButton-BNKEwqMZ.js";import"./OptionalRecordContextProvider-ChL7EZ8k.js";import"./Chip-4IhPI0f3.js";import"./usePaginationState-CSxOqUBu.js";import"./useReference-jPRH6tHJ.js";const ut={title:"Pages/MasterDetails",component:u,decorators:[o=>V(o)],args:{perPage:5,exporter:!1},parameters:{docs:{canvas:{}}}},a={render:({...o})=>{const s=g(),n=y(),p=h.useCallback(()=>{n("/users")},[n]),t=j("/users/:id",s.pathname),x=({id:e})=>r.jsx("div",{style:{padding:"64px 20px 0px 20px",width:"360px"},children:r.jsxs(E,{id:e,children:[r.jsxs(B,{direction:"row",p:2,children:[r.jsx(k,{variant:"h6",flex:"1",children:"User"}),r.jsx(z,{onClick:p,size:"small",children:r.jsx(S,{})})]}),r.jsxs(P,{children:[r.jsx(b,{source:"name"}),r.jsx(N,{source:"date"}),r.jsx(_,{source:"active"}),r.jsx(L,{source:"day_offs"}),r.jsx(F,{source:"department_id",reference:"departments"})]})]})}),f=e=>{let i={};return t&&t&&e.id===parseInt(t.params.id)&&(i={...i,backgroundColor:"#f5f5f5"}),i};return r.jsxs(R,{display:"flex",children:[r.jsx(u,{sx:{flexGrow:1,transition:e=>e.transitions.create(["all"],{duration:e.transitions.duration.enteringScreen}),marginRight:t?"400px":0},...o,children:r.jsxs(C,{rowClick:"edit",rowSx:f,children:[r.jsx(m,{source:"id"}),r.jsx(m,{source:"name"})]})}),r.jsx(T,{anchor:"right",variant:"persistent",sx:{zIndex:100},open:!!t,onClose:p,children:!!t&&r.jsx(x,{id:t.params.id})})]})},wizardName:"pageWizard",info:{pageType:"MasterDetails",readonlyPageType:!0}},V=o=>{const s=()=>{let n=[{name:"departments",recordRepresentation:"name"},{name:"users",recordRepresentation:"name"}];return r.jsx(I,{resources:n,children:r.jsx(M,{value:"users",children:r.jsx(o,{})})})};return r.jsx(w,{initialEntries:["/users/1"],children:r.jsx(D,{children:r.jsx(v,{path:"/users/*",element:r.jsx(s,{})})})})};var c,d,l;a.parameters={...a.parameters,docs:{...(c=a.parameters)==null?void 0:c.docs,source:{originalSource:`{
  render: ({
    ...props
  }) => {
    const location = useLocation();
    const navigate = useNavigate();
    const handleClose = useCallback(() => {
      navigate("/users");
    }, [navigate]);
    const match = matchPath("/users/:id", location.pathname);
    const DetailsView = ({
      id
    }: {
      id: string;
    }) => {
      return <div style={{
        padding: "64px 20px 0px 20px",
        width: "360px"
      }}>
          <EditBase id={id}>
            <Stack direction="row" p={2}>
              <Typography variant="h6" flex="1">
                User
              </Typography>
              <IconButton onClick={handleClose} size="small">
                <CloseIcon />
              </IconButton>
            </Stack>
            <SimpleForm>
              <TextInput source="name" />
              <DateInput source="date" />
              <BooleanInput source="active" />
              <NumberInput source="day_offs" />
              <ReferenceInput source="department_id" reference="departments" />
            </SimpleForm>
          </EditBase>
        </div>;
    };
    const rowSx = (record: RaRecord): SxProps => {
      let style = {};
      if (!match) return style;
      if (match && record.id === parseInt((match as any).params.id)) {
        style = {
          ...style,
          backgroundColor: "#f5f5f5"
        };
      }
      return style;
    };
    return <Box display="flex">
        <List sx={{
        flexGrow: 1,
        transition: (theme: any) => theme.transitions.create(["all"], {
          duration: theme.transitions.duration.enteringScreen
        }),
        marginRight: !!match ? "400px" : 0
      }} {...props}>
          <Datagrid rowClick="edit" rowSx={rowSx}>
            <TextField source="id" />
            <TextField source="name" />
          </Datagrid>
        </List>
        <Drawer anchor="right" variant="persistent" sx={{
        zIndex: 100
      }} open={!!match} onClose={handleClose}>
          {!!match && <DetailsView id={(match as any).params.id} />}
        </Drawer>
      </Box>;
  },
  wizardName: "pageWizard",
  info: {
    pageType: "MasterDetails",
    readonlyPageType: true
  }
}`,...(l=(d=a.parameters)==null?void 0:d.docs)==null?void 0:l.source}}};const xt=["Default"];export{a as Default,xt as __namedExportsOrder,ut as default};
