@nocobase/plugin-calendar 1.4.26 → 1.4.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,4 +100,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
100
100
  border-bottom-left-radius: 0;
101
101
  border-bottom-right-radius: 0;
102
102
  }
103
- `;Xc.displayName="GlobalStyle";const cS=()=>{const e=x.useDataBlockHeight(),{heightProps:t}=x.useBlockHeightProps(),{title:r}=t,{token:n}=we.theme.useToken();if(!e)return;const a=2*n.paddingLG,o=r?n.fontSizeLG*n.lineHeightLG+n.padding*2-1:0;return e-a-o},fS=x.genStyleHook("nb-calendar",e=>{const{componentCls:t}=e;return{[t]:{".rbc-btn":{color:"inherit",font:"inherit",margin:"0"},"button.rbc-btn":{overflow:"visible",textTransform:"none",WebkitAppearance:"button",cursor:"pointer"},"button[disabled].rbc-btn":{cursor:"not-allowed"},"button.rbc-input::-moz-focus-inner":{border:"0",padding:"0"},".rbc-button-link":{border:"none",backgroundColor:"transparent"},".rbc-calendar":{boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"stretch",height:"100%"},".rbc-calendar *,\n.rbc-calendar *:before,\n.rbc-calendar *:after":{boxSizing:"inherit"},".rbc-abs-full,\n.rbc-row-bg":{overflow:"hidden",position:"absolute",top:"0",left:"0",right:"0",bottom:"0"},".rbc-ellipsis,\n.rbc-event-label,\n.rbc-row-segment .rbc-event-content,\n.rbc-show-more":{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},".rbc-rtl":{direction:"rtl"},".rbc-off-range":{color:e.colorTextDisabled},".rbc-header":{overflow:"hidden",flex:"1 0 0%",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:`${e.paddingXXS}px ${e.paddingSM}px`,verticalAlign:"middle",minHeight:e.sizeXL,color:e.colorText,margin:`0 ${e.marginXXS}px`,borderBottom:`2px solid ${e.colorBorderSecondary}`},".rbc-rtl .rbc-header + .rbc-header":{borderLeftWidth:"0",borderRight:`1px solid ${e.colorBorderSecondary}`},".rbc-header > a,\n.rbc-header > a:active,\n.rbc-header > a:visited":{color:"inherit",textDecoration:"none"},".rbc-row-content":{position:"relative",userSelect:"none",WebkitUserSelect:"none",zIndex:4},".rbc-row-content-scrollable":{display:"flex",flexDirection:"column",height:"100%"},".rbc-row-content-scrollable .rbc-row-content-scroll-container":{height:"100%",overflowY:"scroll",msOverflowStyle:"none",scrollbarWidth:"none"},".rbc-row-content-scrollable .rbc-row-content-scroll-container::-webkit-scrollbar":{display:"none"},".rbc-toolbar":{display:"flex",flexWrap:"wrap",justifyContent:"center",alignItems:"center",marginBottom:e.marginXS,fontSize:e.fontSize},".rbc-toolbar .rbc-toolbar-label":{flexGrow:1,padding:`0 ${e.paddingXS}px`,textAlign:"center"},".rbc-toolbar button":{outline:"none",fontSize:e.fontSize,lineHeight:[e.lineHeight,"normal"],height:e.controlHeight,color:e.colorTextLabel,display:"inline-block",margin:"0",position:"relative",zIndex:1,textAlign:"center",verticalAlign:"middle",background:"none",backgroundImage:"none",border:`1px solid ${e.colorBorder}`,padding:`${e.paddingXXS}px ${e.paddingSM+e.paddingXXS}px`,borderRadius:e.borderRadiusXS,whiteSpace:"nowrap"},".rbc-toolbar button:active,\n.rbc-toolbar button.rbc-active":{zIndex:2,color:"#1890ff",borderColor:"#1890ff"},".rbc-toolbar button:active:hover,\n.rbc-toolbar button:active:focus,\n.rbc-toolbar button.rbc-active:hover,\n.rbc-toolbar button.rbc-active:focus":{zIndex:2,color:"#40a9ff",borderColor:"#40a9ff"},".rbc-toolbar button:hover":{zIndex:2,color:"#40a9ff",borderColor:"#40a9ff"},".rbc-btn-group":{display:"inline-block",whiteSpace:"nowrap"},".rbc-btn-group > button:first-child:not(:last-child)":{borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-btn-group > button:last-child:not(:first-child)":{borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-rtl .rbc-btn-group > button:first-child:not(:last-child)":{borderRadius:"4px",borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-rtl .rbc-btn-group > button:last-child:not(:first-child)":{borderRadius:"4px",borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-btn-group > button:not(:first-child):not(:last-child)":{borderRadius:"0"},".rbc-btn-group button + button":{marginLeft:"-1px"},".rbc-rtl .rbc-btn-group button + button":{marginLeft:"0",marginRight:"-1px"},".rbc-btn-group + .rbc-btn-group,\n.rbc-btn-group + button":{marginLeft:"10px"},".rbc-event":{border:"none",boxSizing:"border-box",boxShadow:"none",margin:"0",padding:"2px 5px",backgroundColor:e.colorBorderSecondary,borderRadius:e.borderRadiusXS,cursor:"pointer",fontSize:e.fontSizeSM,width:"100%",textAlign:"left","&:hover":{backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText}},".rbc-slot-selecting .rbc-event":{cursor:"inherit",pointerEvents:"none"},".rbc-event.rbc-selected":{backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText},".rbc-event-label":{fontSize:"80%"},".rbc-event-overlaps":{boxShadow:"-1px 1px 5px 0px rgba(51, 51, 51, 0.5)"},".rbc-event-continues-prior":{borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-event-continues-after":{borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-event-continues-earlier":{borderTopLeftRadius:"0",borderTopRightRadius:"0"},".rbc-event-continues-later":{borderBottomLeftRadius:"0",borderBottomRightRadius:"0"},".rbc-row":{display:"flex",flexDirection:"row"},".rbc-row-segment":{padding:"0 4px 1px 4px"},".rbc-selected-cell":{backgroundColor:"rgba(0, 0, 0, 0.1)"},".rbc-show-more":{zIndex:4,fontWeight:"bold",fontSize:"85%",height:"auto",lineHeight:"normal",color:"inherit",padding:"2px 5px"},".rbc-month-view":{position:"relative",display:"flex",flexDirection:"column",flex:"1 0 0",width:"100%",userSelect:"none",WebkitUserSelect:"none",height:"68vh",".rbc-day-bg":{borderTop:`2px solid ${e.colorBorderSecondary}`},".rbc-today":{borderColor:`${e.colorPrimaryBorder} !important`,backgroundColor:`${e.colorPrimaryBg} !important`},".rbc-header":{borderBottom:"0 !important"}},".rbc-month-header":{display:"flex",flexDirection:"row"},".rbc-month-row":{display:"flex",position:"relative",flexDirection:"column",flex:"1 0 0",flexBasis:"0px",overflow:"hidden",height:"100%"},".rbc-date-cell":{flex:"1 1 0",minWidth:"0",paddingLeft:"12px",paddingTop:"4px"},".rbc-date-cell.rbc-now span":{color:"#1890ff"},".rbc-date-cell a,\n.rbc-date-cell a:active,\n.rbc-date-cell a:visited":{color:"inherit",textDecoration:"none"},".rbc-date-cell a:hover":{color:"#1890ff"},".rbc-date-cell .rbc-date-solar":{fontWeight:500},".rbc-date-cell .rbc-date-lunar":{paddingLeft:"12px"},".rbc-date-cell:not(.rbc-off-range) .rbc-date-lunar":{color:"#aaa"},".rbc-date-cell .rbc-date-lunar:hover":{color:"inherit"},".rbc-row-bg":{display:"flex",flexDirection:"row",flex:"1 0 0",overflow:"hidden"},".rbc-day-bg":{flex:"1 0 0%",margin:"0 4px","&:hover":{background:e.colorFillQuaternary}},".rbc-agenda-view":{display:"flex",flexDirection:"column",flex:"1 0 0",overflow:"auto"},".rbc-agenda-view table.rbc-agenda-table":{width:"100%",border:"1px solid #f0f0f0",borderSpacing:"0",borderCollapse:"collapse"},".rbc-agenda-view table.rbc-agenda-table tbody > tr > td":{padding:"5px 10px",verticalAlign:"top"},".rbc-agenda-view table.rbc-agenda-table .rbc-agenda-time-cell":{paddingLeft:"15px",paddingRight:"15px",textTransform:"lowercase"},".rbc-agenda-view table.rbc-agenda-table tbody > tr > td + td":{borderLeft:"1px solid #f0f0f0"},".rbc-rtl .rbc-agenda-view table.rbc-agenda-table tbody > tr > td + td":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-agenda-view table.rbc-agenda-table tbody > tr + tr":{borderTop:"1px solid #f0f0f0"},".rbc-agenda-view table.rbc-agenda-table thead > tr > th":{padding:"3px 5px",textAlign:"left",borderBottom:"1px solid #f0f0f0"},".rbc-rtl .rbc-agenda-view table.rbc-agenda-table thead > tr > th":{textAlign:"right"},".rbc-agenda-time-cell":{textTransform:"lowercase"},".rbc-agenda-time-cell .rbc-continues-after:after":{content:"' »'"},".rbc-agenda-time-cell .rbc-continues-prior:before":{content:"'« '"},".rbc-agenda-date-cell,\n.rbc-agenda-time-cell":{whiteSpace:"nowrap"},".rbc-agenda-event-cell":{width:"100%"},".rbc-time-column":{display:"flex",flexDirection:"column",minHeight:"100%"},".rbc-time-column .rbc-timeslot-group":{flex:1},".rbc-timeslot-group":{borderBottom:"1px solid #f0f0f0",minHeight:"40px",lineHeight:"39px",display:"flex",flexFlow:"column nowrap","&:hover":{background:"#f0f0f0"}},".rbc-time-gutter,\n.rbc-header-gutter":{flex:"none"},".rbc-label":{padding:"0 5px"},".rbc-day-slot":{position:"relative"},".rbc-day-slot .rbc-events-container":{bottom:"0",left:"0",position:"absolute",right:"0",marginRight:"10px",top:"0"},".rbc-day-slot .rbc-events-container.rbc-rtl":{left:"10px",right:"0"},".rbc-day-slot .rbc-event":{border:"1px solid #265985",display:"flex",maxHeight:"100%",minHeight:"20px",flexFlow:"column wrap",alignItems:"flex-start",overflow:"hidden",position:"absolute"},".rbc-day-slot .rbc-event-label":{flex:"none",paddingRight:"5px",width:"auto"},".rbc-day-slot .rbc-event-content":{width:"100%",flex:"1 1 0",wordWrap:"break-word",lineHeight:1,height:"100%",minHeight:"1em"},".rbc-time-header-gutter":{lineHeight:"40px"},".rbc-time-header-cell":{minHeight:"32px !important"},".rbc-time-header-cell .rbc-header":{display:"flex"},".rbc-time-header-cell .rbc-header.rbc-today":{borderColor:e.colorPrimaryBorder,backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText},".rbc-time-header-cell .rbc-header a":{display:"flex",flexDirection:"column"},".rbc-time-header-cell .rbc-date-wrap":{display:"flex",alignItems:"center"},".rbc-time-header-cell .rbc-date-solar":{fontSize:"18px"},".rbc-time-header-cell .rbc-date-lunar":{marginLeft:"4px"},".rbc-time-header-cell .rbc-header:not(.rbc-today) .rbc-date-lunar":{color:"#aaa"},".rbc-calendar.view-week":{".rbc-time-header-cell":{marginTop:"-32px",marginBottom:"4px"},".rbc-time-view":{paddingTop:"32px",borderTop:"0"},".rbc-header":{padding:"4px 8px"},".rbc-time-header-content":{padding:"4px 0"},".rbc-time-header-gutter":{padding:"0",paddingTop:"2px","> div":{borderTop:"2px solid #f0f0f0",padding:"0 5px"}}},".rbc-time-view-resources .rbc-time-gutter,\n.rbc-time-view-resources .rbc-time-header-gutter":{position:"sticky",left:"0",backgroundColor:"white",borderRight:"1px solid #f0f0f0",zIndex:10,marginRight:"-1px"},".rbc-time-view-resources .rbc-time-header":{overflow:"hidden"},".rbc-time-view-resources .rbc-time-header-content":{minWidth:"auto",flex:"1 0 0",flexBasis:"0px"},".rbc-time-view-resources .rbc-time-header-cell-single-day":{display:"none"},".rbc-time-view-resources .rbc-day-slot":{minWidth:"140px"},".rbc-time-view-resources .rbc-header,\n.rbc-time-view-resources .rbc-day-bg":{width:"140px",flex:"1 1 0",flexBasis:"0 px"},".rbc-time-header-content + .rbc-time-header-content":{marginLeft:"-1px"},".rbc-time-slot":{flex:"1 0 0"},".rbc-time-slot.rbc-now":{fontWeight:"bold"},".rbc-day-header":{textAlign:"center"},".rbc-slot-selection":{zIndex:10,position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"75%",width:"100%",padding:"3px"},".rbc-slot-selecting":{cursor:"move"},".rbc-time-view":{display:"flex",flexDirection:"column",flex:1,width:"100%",borderTop:"1px solid #f0f0f0",minHeight:"0"},".rbc-time-view .rbc-time-gutter":{whiteSpace:"nowrap"},".rbc-time-view .rbc-allday-cell":{boxSizing:"content-box",width:"100%",height:"100%",position:"relative"},".rbc-time-view .rbc-allday-cell + .rbc-allday-cell":{borderLeft:"1px solid #f0f0f0"},".rbc-time-view .rbc-allday-events":{position:"relative",zIndex:4},".rbc-time-view .rbc-row":{boxSizing:"border-box",minHeight:"20px"},".rbc-time-header":{display:"flex",flex:"0 0 auto",flexDirection:"row"},".rbc-time-header.rbc-overflowing":{borderRight:"1px solid #f0f0f0"},".rbc-rtl .rbc-time-header.rbc-overflowing":{borderRightWidth:"0",borderLeft:"1px solid #f0f0f0"},".rbc-time-header > .rbc-row:first-child":{borderBottom:"1px solid #f0f0f0"},".rbc-time-header > .rbc-row.rbc-row-resource":{borderBottom:"1px solid #f0f0f0"},".rbc-time-header-cell-single-day":{display:"none"},".rbc-time-header-content":{flex:1,minWidth:"0",flexDirection:"column"},".rbc-rtl .rbc-time-header-content":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-time-header-content > .rbc-row.rbc-row-resource":{borderBottom:"1px solid #f0f0f0",flexShrink:0},".rbc-time-content":{display:"flex",flex:"1 0 0%",alignItems:"flex-start",width:"100%",borderTop:"1px solid #f0f0f0",overflowY:"auto",position:"relative"},".rbc-time-content > .rbc-time-gutter":{flex:"none"},".rbc-rtl .rbc-time-content > * + * > *":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-time-content > .rbc-day-slot":{width:"100%",userSelect:"none",WebkitUserSelect:"none"},".rbc-current-time-indicator":{position:"absolute",zIndex:3,left:"0",right:"0",height:"1px",backgroundColor:"#74ad31",pointerEvents:"none"},"@media only screen and (max-width: 800px)":{".view-type-calendar .action-buttons":{position:"relative !important",left:"0 !important",".filter-action-button":{left:"0 !important"}},".rbc-toolbar .rbc-toolbar-label":{position:"absolute",top:"28px",left:"50%",transform:"translateX(-50%)"},".rbc-toolbar":{justifyContent:"space-between !important"},".rbc-header":{padding:"4px !important"}}}}}),dS={type:"void","x-component":"AssociationField.AddNewer","x-action":"create",title:'{{ t("Add record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:addNew:addBlock"},properties:{tab1:{type:"void",title:'{{t("Add new")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}},hS=["month","week","day"],mS=tS(Ie),Jc=(e,t)=>{for(const r of t)if(r.value===e)return r.color;return""},Ii=b.createContext({close:()=>{},allowDeleteEvent:!1});function pS(e){const t=q.useFieldSchema(),r=b.useMemo(()=>t.reduceProperties((n,a)=>a["x-component"].endsWith(".ActionBar")?a:n,null),[]);return N.jsx(zr.Provider,{value:e,children:N.jsx(q.RecursionField,{name:r.name,schema:r})})}const vS=(e,t,r,n)=>{var l,u;const{t:a}=$e(),{fields:o}=x.useCollection(),i=(l=o.find(c=>c.name===(t==null?void 0:t.title)))==null?void 0:l.uiSchema,s=o.find(c=>c.name===(t==null?void 0:t.colorFieldName));return b.useMemo(()=>{var d;if(!Array.isArray(e))return{events:[],enumList:[]};const c=((d=s==null?void 0:s.uiSchema)==null?void 0:d.enum)||[],f=[];return e.forEach(h=>{const{cron:p,exclude:m=[]}=h,g=Ie(pt.get(h,t.start)||Ie()),v=Ie(pt.get(h,t.end)||g),w=v.diff(g,"millisecond",!0),T=Ie(r);let S=T.clone().startOf("month"),y=S.clone().endOf("month");n==="month"&&(S=S.startOf("week"),y=y.endOf("week"));const O=(D=g.clone())=>{if(D.isBefore(g)||!D.isBetween(S,y)&&!v.isBetween(S,y))return;let E=!1;if(m==null?void 0:m.some(M=>M.endsWith("_after")?(M=M.replace(/_after$/,""),E=!0,D.isSameOrAfter(M)):D.isSame(M)))return E;const _=x.getLabelFormatValue(i,pt.get(h,t.title),!0),k={id:pt.get(h,t.id||"id"),colorFieldValue:h[t.colorFieldName],title:_||a("Untitle"),start:D.toDate(),end:D.add(w,"millisecond").toDate()};f.push(k)};if(p==="every_week"){let D=g.clone().year(S.year()).month(S.month()).date(S.date()).day(g.day());for(;D.isBefore(y)&&!O(D.clone());)D=D.add(1,"week")}else if(p==="every_month")O(g.clone().year(T.year()).month(T.month()));else if(p==="every_year")O(g.clone().year(T.year()));else{if(O(),!p)return;try{const D=xh.parseExpression(p,{startDate:S.toDate(),endDate:y.toDate(),iterator:!0,currentDate:g.toDate(),utc:!0});for(;D.hasNext();){const{value:E}=D.next();if(O(Ie(E.toDate())))break}}catch(D){console.error(D)}}}),{events:f,enumList:c}},[i,e,t.colorFieldName,t.start,t.end,t.id,t.title,r,n,a,(u=s==null?void 0:s.uiSchema)==null?void 0:u.enum])},gS=e=>{const t=q.useFieldSchema(),{insertAfterBegin:r}=x.useDesignable();return b.useCallback(a=>{t.reduceProperties((i,s)=>s["x-component"]==="AssociationField."+e?s:i,null)||r(pt.cloneDeep(a))},[e])},Dt=x.withDynamicSchemaProps(q.observer(e=>{var L,V;const[t,r]=b.useState(!1),{openPopup:n}=x.usePopupUtils({setVisible:r}),{dataSource:a,fieldNames:o,showLunar:i,defaultView:s}=x.useProps(e),l=cS(),[u,c]=b.useState(new Date),[f,d]=b.useState(e.defaultView||"month"),{events:h,enumList:p}=vS(a,o,u,f),[m,g]=b.useState({}),{wrapSSR:v,hashId:w,componentCls:T}=fS(),S=x.useCollectionParentRecordData(),y=q.useFieldSchema(),O=q.useField(),{token:D}=x.useToken(),{parseAction:E}=x.useACLRoleContext(),C=x.useCollection(),_=E(`${C.name}:create`),k=(L=o==null?void 0:o.start)==null?void 0:L[0],M=(V=o==null?void 0:o.end)==null?void 0:V[0],W=gS("AddNewer"),U=x.useActionContext(),[Q,G]=b.useState(!1),[Z,se]=b.useState(void 0);b.useEffect(()=>{d(e.defaultView)},[e.defaultView]);const be=b.useMemo(()=>({toolbar:$=>N.jsx(pS,Je(re({},$),{showLunar:i})),month:{dateHeader:$=>N.jsx(sS,Je(re({},$),{showLunar:i}))}}),[i]),Be={allDay:"",previous:N.jsx("div",{children:N.jsx(mt.LeftOutlined,{})}),next:N.jsx("div",{children:N.jsx(mt.RightOutlined,{})}),today:He("Today"),month:He("Month"),week:He("Week"),work_week:He("Work week"),day:He("Day"),agenda:He("Agenda"),date:He("Date"),time:He("Time"),event:He("Event"),noEventsInRange:He("None"),showMore:$=>He("{{count}} more items",{count:$})},A=$=>{if($.colorFieldValue){const B=D[`${Jc($.colorFieldValue,p)}7`],K=D[`${Jc($.colorFieldValue,p)}1`];return{style:{color:B,backgroundColor:K,border:"none"}}}},P=()=>{var xt,ct,Lt;const $=x.useFormBlockContext();let B=Z.start,K=Z.end;const X=C.getField(k),Ne=C.getField(M);return b.useEffect(()=>{var Wr,$a,Nn,In,Fa,La,dt;const ft=$.form;if(!(!ft||(Wr=$.service)!=null&&Wr.loading)&&Z){const ht=re(re({},($a=X==null?void 0:X.uiSchema)==null?void 0:$a["x-component-props"]),(In=(Nn=$.form)==null?void 0:Nn.query(k).take())==null?void 0:In.componentProps),zt=re(re({},(Fa=Ne==null?void 0:Ne.uiSchema)==null?void 0:Fa["x-component-props"]),(dt=(La=$.form)==null?void 0:La.query(M).take())==null?void 0:dt.componentProps);B=x.handleDateChangeOnForm(Z.start,ht.dateOnly,ht.utc,ht.picker,ht.showTime,ht.gtm),K=x.handleDateChangeOnForm(Z.end,zt.dateOnly,zt.utc,zt.picker,zt.showTime,zt.gtm),ft.initialValues[k]||ft.setInitialValuesIn([k],B),ft.initialValues[M]||ft.setInitialValuesIn([M],K)}},[$.form,(ct=(xt=$.service)==null?void 0:xt.data)==null?void 0:ct.data,(Lt=$.service)==null?void 0:Lt.loading]),{form:$.form}};return v(N.jsxs("div",{className:`${w} ${T}`,style:{height:l||700},children:[N.jsxs(x.PopupContextProvider,{visible:t,setVisible:r,children:[N.jsx(Xc,{}),N.jsx(x.RecordProvider,{record:m,parent:S,children:N.jsx(oS,{})}),N.jsx(Z1,{popup:!0,selectable:!0,events:h,eventPropGetter:A,view:f,views:hS,date:u,step:60,showMultiDayTimes:!0,messages:Be,onNavigate:c,onView:d,onSelectSlot:$=>{se($),_&&(W(dS),G(!0))},onDoubleClickEvent:()=>{console.log("onDoubleClickEvent")},onSelectEvent:$=>{const B=a==null?void 0:a.find(K=>K[o.id]===$.id);B&&(B.__event=Je(re({},$),{start:Ni(Ie($.start)),end:Ni(Ie($.end))}),g(B),n({recordData:B,customActionSchema:Zc(y)}))},formats:{monthHeaderFormat:"YYYY-M",agendaDateFormat:"M-DD",dayHeaderFormat:"YYYY-M-DD",dayRangeHeaderFormat:({start:$,end:B},K,X)=>Yc.eq($,B,"month")?X.format($,"YYYY-M",K):`${X.format($,"YYYY-M",K)} - ${X.format(B,"YYYY-M",K)}`},components:be,localizer:mS})]}),N.jsx(x.ActionContextProvider,{value:Je(re({},U),{visible:Q,setVisible:G}),children:N.jsx(x.CollectionProvider,{name:C.name,children:N.jsx(x.SchemaComponentOptions,{scope:{useCreateFormBlockProps:P},children:N.jsx(q.RecursionField,{onlyRenderProperties:!0,basePath:O==null?void 0:O.address,schema:y,filterProperties:$=>$["x-component"]==="AssociationField.AddNewer"})})})})]}))},{displayName:"Calendar"})),bS=()=>{const{name:e,title:t}=x.useCollection(),r=x.useSchemaTemplate();return N.jsx(x.GeneralSchemaDesigner,{schemaSettings:"blockSettings:calendar",template:r,title:t||e})},{Text:yS}=we.Typography,wS=q.observer(()=>{var E,C,_;const{visible:e,setVisible:t,setSubmitted:r}=x.useActionContext(),D=x.useRecord(),{exclude:n=[],cron:a}=D,o=Wi(D,["exclude","cron"]),{close:i}=b.useContext(Ii),{context:s,closePopup:l}=x.usePopupUtils(),u=((E=s==null?void 0:s.params)==null?void 0:E.popupuid)||"",c=x.getStoredPopupContext(u)||{record:null,service:null},f=b.useMemo(()=>{var k,M;return Ni(Ie((M=(k=c.record)==null?void 0:k.data)==null?void 0:M.__event.start))},[(_=(C=c.record)==null?void 0:C.data)==null?void 0:_.__event.start]),d=!c.record,h=x.useFilterByTk(),{resource:p,service:m,__parent:g}=x.useBlockRequestContext(),[v,w]=b.useState(d?"all":f),[T,S]=b.useState(!1),y=()=>mr(this,null,function*(){var k,M,W;S(!0),v==="all"||!a?yield p.destroy({filterByTk:h}):yield p.update({filterByTk:h,values:{exclude:(n||[]).concat(v)}}),S(!1),(M=(k=g==null?void 0:g.service)==null?void 0:k.refresh)==null||M.call(k),(W=m==null?void 0:m.refresh)==null||W.call(m),t==null||t(!1,!0),i(),r==null||r(!0)}),{t:O}=$e();return Vt.createPortal(N.jsx(we.Modal,{title:a?O("Delete events"):null,open:e,onCancel:()=>t(!1),onOk:()=>y(),confirmLoading:T,children:a?N.jsx(we.Radio.Group,{value:v,onChange:k=>w(k.target.value),children:N.jsxs(we.Space,{direction:"vertical",children:[N.jsx(we.Radio,{value:f,disabled:d,children:O("This event")}),N.jsx(we.Radio,{value:`${f}_after`,disabled:d,children:O("This and following events")}),N.jsx(we.Radio,{value:"all",children:O("All events")})]})}):N.jsx(yS,{strong:!0,style:{fontSize:"18px"},children:O("Delete this event?")})}),document.body)},{displayName:"DeleteEvent"}),SS=q.observer(e=>{const{visible:t,setVisible:r}=x.useActionContext(),n=x.useCollectionRecordData(),a=x.useCollection(),{isPopupVisibleControlledByURL:o}=x.usePopupSettings(),i=o()?null:r,s=b.useCallback(()=>{r(!1)},[r]);return N.jsx(x.PopupContextProvider,{visible:t,setVisible:i,children:N.jsx(Ii.Provider,{value:{close:s,allowDeleteEvent:!0},children:N.jsx(x.VariablePopupRecordProvider,{recordData:n,collection:a,children:e.children})})})},{displayName:"Event"}),OS=q.observer(()=>{const{DesignableBar:e}=x.useDesignable(),{onNavigate:t}=b.useContext(zr);return N.jsxs(we.Button.Group,{children:[N.jsx(we.Button,{icon:N.jsx(mt.LeftOutlined,{}),onClick:()=>t(ge.PREVIOUS)}),N.jsx(we.Button,{icon:N.jsx(mt.RightOutlined,{}),onClick:()=>t(ge.NEXT)}),N.jsx(e,{})]})},{displayName:"Nav"}),TS=q.observer(()=>{const{DesignableBar:e}=x.useDesignable(),{date:t,view:r,label:n,showLunar:a}=b.useContext(zr),o=b.useMemo(()=>{if(!(!a||r!=="day"))return N.jsx("span",{children:Kc(t)})},[r,t,a]);return N.jsxs(we.Button.Group,{style:{fontSize:"1.75em",fontWeight:300},children:[N.jsx("span",{children:n}),N.jsx("span",{style:{marginLeft:"4px"},children:o}),N.jsx(e,{})]})},{displayName:"Title"}),DS=q.observer(e=>{const{DesignableBar:t}=x.useDesignable(),{onNavigate:r}=b.useContext(zr),{t:n}=$e();return N.jsxs(we.Button,{onClick:()=>{r(ge.TODAY)},children:[n("Today"),N.jsx(t,{})]})},{displayName:"Today"}),xS=q.observer(e=>{const{DesignableBar:t}=x.useDesignable(),{views:r,view:n,onView:a,localizer:{messages:o}}=b.useContext(zr);return N.jsxs("div",{className:"ant-btn-group",children:[N.jsx(we.Select,{popupMatchSelectWidth:!1,value:n,onChange:a,children:r.map(i=>N.jsx(we.Select.Option,{value:i,children:o[i]},i))}),N.jsx(t,{})]})},{displayName:"ViewSelect"});Dt.ActionBar=x.ActionBar,Dt.Event=SS,Dt.DeleteEvent=wS,Dt.Title=TS,Dt.Today=DS,Dt.Nav=OS,Dt.ViewSelect=xS,Dt.Designer=bS;const ES=Dt;function Qc(e){var o;const{filter:t,parseVariableLoading:r}=x.useParsedFilter({filterOption:(o=e.params)==null?void 0:o.filter}),n=b.useMemo(()=>{var u,c;const i=[],s=(u=e.fieldNames)==null?void 0:u.start,l=(c=e.fieldNames)==null?void 0:c.end;return Array.isArray(s)&&s.length>=2&&i.push(s[0]),Array.isArray(l)&&l.length>=2&&i.push(l[0]),i},[e.fieldNames]);return{params:b.useMemo(()=>Je(re({},e.params),{appends:[...n,...e.params.appends||[]],paginate:!1,filter:t}),[n,JSON.stringify(t),e.params]),parseVariableLoading:r}}const $i=b.createContext({});$i.displayName="CalendarBlockContext";const CS=e=>{var s;const{fieldNames:t,showLunar:r,defaultView:n}=e,a=q.useField(),{resource:o,service:i}=x.useBlockRequestContext();return N.jsx(x.FixedBlockWrapper,{children:N.jsx($i.Provider,{value:{field:a,service:i,resource:o,fieldNames:t,showLunar:r,defaultView:n,fixedBlock:(s=a==null?void 0:a.decoratorProps)==null?void 0:s.fixedBlock},children:e.children})})},MS=e=>q.useFieldSchema()["x-use-decorator-props"]?{params:e.params,parseVariableLoading:e.parseVariableLoading}:Qc(e),_S=x.withDynamicSchemaProps(e=>{const{params:t,parseVariableLoading:r}=MS(e);return r?null:N.jsx(x.BlockProvider,Je(re({name:"calendar"},e),{params:t,children:N.jsx(CS,re({},e))}))},{displayName:"CalendarBlockProvider"}),Pn=()=>b.useContext($i),kS=()=>{var r;const e=Pn(),t=q.useField();return b.useEffect(()=>{var n,a,o;(n=e==null?void 0:e.service)!=null&&n.loading||(t.componentProps.dataSource=(o=(a=e==null?void 0:e.service)==null?void 0:a.data)==null?void 0:o.data)},[(r=e==null?void 0:e.service)==null?void 0:r.loading]),{fieldNames:e.fieldNames,showLunar:e.showLunar,defaultView:e.defaultView,fixedBlock:e.fixedBlock}},AS=()=>{const e=q.useField(),{t}=$e(),r=q.useFieldSchema(),{dn:n}=x.useDesignable();return N.jsx(x.SchemaSettingsSwitchItem,{title:t("Show lunar"),checked:e.decoratorProps.showLunar,onChange:a=>{e.decoratorProps.showLunar=a,r["x-decorator-props"].showLunar=a,n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":e.decoratorProps}}),n.refresh()}})},PS=new x.SchemaSettings({name:"blockSettings:calendar",items:[{name:"title",Component:x.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:x.SchemaSettingsBlockHeightItem},{name:"titleField",Component:x.SchemaSettingsSelectItem,useComponentProps(){var u;const{t:e}=$e(),t=q.useFieldSchema(),r=((u=t==null?void 0:t["x-decorator-props"])==null?void 0:u.fieldNames)||{},{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{name:o,title:i}=x.useCollection(),s=q.useField(),{dn:l}=x.useDesignable();return{title:e("Title field"),value:r.title,options:a(o,"string"),onChange:c=>{const f=s.decoratorProps.fieldNames||{};f.title=c,s.decoratorProps.params=f,t["x-decorator-props"].params=f,t["x-decorator-props"].fieldNames=f,n.refresh(),l.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":s.decoratorProps}}),l.refresh()}}}},{name:"colorField",Component:x.SchemaSettingsSelectItem,useComponentProps(){var c;const{t:e}=$e(),t=q.useFieldSchema(),r=((c=t==null?void 0:t["x-decorator-props"])==null?void 0:c.fieldNames)||{},{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{name:o}=x.useCollection(),i=q.useField(),{dn:s}=x.useDesignable(),l=a(o,"string"),u=[{label:e("Not selected"),value:""},...l.filter(f=>f.interface==="radioGroup"||f.interface==="select")];return{title:e("Background color field"),value:r.colorFieldName||"",options:u,onChange:f=>{var h;const d=((h=t["x-decorator-props"])==null?void 0:h.fieldNames)||{};d.colorFieldName=f,i.decoratorProps.fieldNames=d,t["x-decorator-props"].fieldNames=d,n.refresh(),s.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}}),s.refresh()}}}},{name:"defaultView",Component:x.SchemaSettingsSelectItem,useComponentProps(){const{t:e}=$e(),t=q.useFieldSchema(),r=q.useField(),{dn:n}=x.useDesignable();return{title:e("Default view"),value:r.decoratorProps.defaultView||"month",options:[{value:"month",label:"月"},{value:"week",label:"周"},{value:"day",label:"天"}],onChange:a=>{r.decoratorProps.defaultView=a,t["x-decorator-props"].defaultView=a,n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),n.refresh()}}}},{name:"showLunar",Component:AS},{name:"startDateField",Component:x.SchemaSettingsCascaderItem,useComponentProps(){var l;const{getCollectionFieldsOptions:e}=x.useCollectionManager_deprecated(),{t}=$e(),r=q.useFieldSchema(),n=((l=r==null?void 0:r["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=q.useField(),{dn:o}=x.useDesignable(),{service:i}=Pn(),{name:s}=x.useCollection();return{title:t("Start date field"),value:n.start,options:e(s,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"]}),onChange:u=>{const c=a.decoratorProps.fieldNames||{};c.start=u,a.decoratorProps.fieldNames=c,r["x-decorator-props"].fieldNames=c,i.refresh(),o.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":a.decoratorProps}}),o.refresh()}}}},{name:"endDateField",Component:x.SchemaSettingsCascaderItem,useComponentProps(){var l;const{t:e}=$e(),t=q.useFieldSchema(),r=q.useField(),{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{dn:o}=x.useDesignable(),{name:i}=x.useCollection(),s=((l=t==null?void 0:t["x-decorator-props"])==null?void 0:l.fieldNames)||{};return{title:e("End date field"),value:s.end,options:a(i,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"]}),onChange:u=>{const c=r.decoratorProps.fieldNames||{};c.end=u,r.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,n.refresh(),o.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),o.refresh()}}}},{name:"dataScope",Component:x.SchemaSettingsDataScope,useComponentProps(){var o,i;const{name:e}=x.useCollection(),t=q.useFieldSchema(),{form:r}=x.useFormBlockContext(),n=q.useField(),{dn:a}=x.useDesignable();return{collectionName:e,defaultFilter:((i=(o=t==null?void 0:t["x-decorator-props"])==null?void 0:o.params)==null?void 0:i.filter)||{},form:r,onSubmit:({filter:s})=>{s=x.removeNullCondition(s);const l=n.decoratorProps.params||{};l.filter=s,n.decoratorProps.params=l,t["x-decorator-props"].params=l,a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}})}}}},{name:"divider",type:"divider"},{name:"template",Component:x.SchemaSettingsTemplate,useComponentProps(){var a,o;const{name:e}=x.useCollection(),t=q.useFieldSchema(),{componentNamePrefix:r}=x.useBlockTemplateContext(),n=((a=t==null?void 0:t["x-decorator-props"])==null?void 0:a.resource)||((o=t==null?void 0:t["x-decorator-props"])==null?void 0:o.association);return{componentName:`${r}Calendar`,collectionName:e,resourceName:n}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});Y("Calendar collection"),Y("Repeats"),Y("Daily"),Y("Weekly"),Y("Monthly"),Y("Yearly"),x.getConfigurableProperties("title","name","inherits","category","description","presetFields");class NS extends x.CollectionTemplate{constructor(){super(...arguments);Wt(this,"name","calendar");Wt(this,"title",Y("Calendar collection"));Wt(this,"order",2);Wt(this,"color","orange");Wt(this,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,sortable:!0,fields:[{name:"cron",type:"string",uiSchema:{type:"string",title:Y("Repeats"),"x-component":"CronSet","x-component-props":"allowClear",enum:[{label:Y("Daily"),value:"0 0 0 * * ?"},{label:Y("Weekly"),value:"every_week"},{label:Y("Monthly"),value:"every_month"},{label:Y("Yearly"),value:"every_year"}]},interface:"select"},{name:"exclude",type:"json"}]});Wt(this,"availableFieldInterfaces",{include:[]});Wt(this,"configurableProperties",x.getConfigurableProperties("title","name","inherits","category","description","presetFields"))}}function IS(e){const{params:t,parseVariableLoading:r}=Qc(e);let n;return e.association&&(n=x.useParentRecordCommon(e.association)),{params:t,parentRecord:n,parseVariableLoading:r}}const Ia=e=>{const t=x.useSchemaInitializerItem();return N.jsx(x.InitializerWithSwitch,Je(re(re({},t),e),{item:t,type:"x-action"}))},ef={title:Y("Configure actions"),icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"today",title:Y("Today"),Component:Ia,schema:{title:Y("Today"),"x-component":"CalendarV2.Today","x-action":"calendar:today","x-align":"left"}},{name:"turnPages",title:Y("Turn pages"),Component:Ia,schema:{title:Y("Turn pages"),"x-component":"CalendarV2.Nav","x-action":"calendar:nav","x-align":"left"}},{name:"title",title:Y("Title"),Component:Ia,schema:{title:Y("Title"),"x-component":"CalendarV2.Title","x-action":"calendar:title","x-align":"left"}},{name:"selectView",title:Y("Select view"),Component:Ia,schema:{title:Y("Select view"),"x-component":"CalendarV2.ViewSelect","x-action":"calendar:viewSelect","x-align":"right","x-designer":"Action.Designer"}},{name:"filter",title:Y("Filter"),Component:"FilterActionInitializer",schema:{"x-align":"right"}},{name:"addNew",title:Y("Add new"),Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>x.useActionAvailable("create")},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},tf=new x.CompatibleSchemaInitializer(re({name:"CalendarActionInitializers"},ef)),$S=new x.CompatibleSchemaInitializer(re({name:"calendar:configureActions"},ef),tf),FS=e=>{const t={title:'{{ t("Delete Event") }}',"x-action":"deleteEvent","x-acl-action":"destroy","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"DeleteOutlined"},properties:{modal:{"x-component":"CalendarV2.DeleteEvent"}}};return N.jsx(x.ActionInitializerItem,Je(re({},e),{schema:t}))},rf={name:"deleteEvent",title:Y("Delete Event"),Component:FS,schema:{"x-component":"Action","x-decorator":"ACLActionProvider"},useVisible(){const{allowDeleteEvent:e}=b.useContext(Ii);return x.useCollection_deprecated().template==="calendar"&&e}},LS=new x.SchemaInitializer({title:Y("Configure actions"),name:"CalendarFormActionInitializers",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",name:"enableActions",title:Y("Enable actions"),children:[{name:"edit",title:Y("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible:()=>x.useActionAvailable("update")},{name:"delete",title:Y("Delete"),Component:"DestroyActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider"},useVisible:()=>x.useActionAvailable("destroy")},rf]},{name:"divider",type:"divider"},{type:"subMenu",name:"customize",title:Y("Customize"),children:[{name:"popup",title:Y("Popup"),Component:"CustomizeActionInitializer",schema:{type:"void",title:Y("Popup"),"x-action":"customize:popup","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:popup","x-component":"Action","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:Y("Popup"),"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:Y("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}}}}},{name:"updateRecord",title:Y("Update record"),Component:"CustomizeActionInitializer",schema:{title:Y("Update record"),"x-component":"Action","x-use-component-props":"useCustomizeUpdateActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:updateRecord","x-acl-action":"update","x-action":"customize:update","x-action-settings":{assignedValues:{},onSuccess:{manualClose:!0,redirecting:!1,successMessage:Y("Updated successfully")},triggerWorkflows:[]}},useVisible:()=>x.useActionAvailable("update")},{name:"customRequest",title:Y("Custom request"),Component:"CustomRequestInitializer"}]}]}),Fi=e=>{const{collectionName:t,dataSource:r,fieldNames:n,association:a}=e;return{type:"void","x-acl-action":`${a||t}:list`,"x-decorator":"CalendarBlockProvider","x-use-decorator-props":"useCalendarBlockDecoratorProps","x-decorator-props":{collection:t,dataSource:r,association:a,action:"list",fieldNames:re({id:"id"},n),params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:calendar","x-component":"CardItem",properties:{[mf.uid()]:{type:"void","x-component":"CalendarV2","x-use-component-props":"useCalendarBlockProps",properties:{toolBar:{type:"void","x-component":"CalendarV2.ActionBar","x-component-props":{style:{marginBottom:24}},"x-initializer":"calendar:configureActions"},event:{type:"void","x-component":"CalendarV2.Event",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:Y("View record"),properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:common:addBlock"},properties:{tab1:{type:"void",title:Y("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer-props":{actionInitializers:"details:configureActions"},"x-initializer":"popup:common:addBlock"}}}}}}}}}}}}}},zS=({filterCollections:e,onlyCurrentDataSource:t,hideSearch:r,createBlockSchema:n,showAssociationFields:a})=>{const o=x.useSchemaInitializerItem(),{createCalendarBlock:i}=nf();return N.jsx(x.DataBlockInitializer,Je(re({},o),{componentType:"Calendar",icon:N.jsx(mt.CalendarOutlined,{}),onCreateBlockSchema:s=>mr(this,null,function*(){if(n)return n(s);i(s)}),onlyCurrentDataSource:t,hideSearch:r,filter:e,showAssociationFields:a}))},nf=()=>{const{insert:e}=x.useSchemaInitializer(),{t}=$e(),{getCollectionField:r,getCollectionFieldsOptions:n}=x.useCollectionManager_deprecated(),a=b.useContext(q.SchemaOptionsContext),{theme:o}=x.useGlobalTheme();return{createCalendarBlock:l=>mr(this,[l],function*({item:s}){const u=n(s.name,"string",{dataSource:s.dataSource}),c=n(s.name,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"],dataSource:s.dataSource}),f=yield x.FormDialog(t("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:a.scope,components:re({},a.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:t("Title field"),enum:u,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:t("Start date field"),enum:c,required:!0,default:r(`${s.name}.createdAt`)?"createdAt":null,"x-component":"Cascader","x-decorator":"FormItem"},end:{title:t("End date field"),enum:c,"x-component":"Cascader","x-decorator":"FormItem"}}}})})}),o).open({initialValues:{}});e(Fi({collectionName:s.name,dataSource:s.dataSource,fieldNames:re({},f)}))})}},WS=()=>{const e=x.useSchemaInitializerItem(),p=e,{onCreateBlockSchema:t,componentType:r,createBlockSchema:n}=p,a=Wi(p,["onCreateBlockSchema","componentType","createBlockSchema"]),{insert:o}=x.useSchemaInitializer(),{getTemplateSchemaByMode:i}=x.useSchemaTemplateManager(),{t:s}=$e(),l=b.useContext(q.SchemaOptionsContext),{getCollection:u}=x.useCollectionManager_deprecated(),c=e.field,f=u(c.target),d=`${c.collectionName}.${c.name}`,{theme:h}=x.useGlobalTheme();return N.jsx(x.SchemaInitializerItem,Je(re({icon:N.jsx(mt.TableOutlined,{})},a),{onClick:g=>mr(this,[g],function*({item:m}){var v,w,T,S;if(m.template){const y=yield i(m);o(y)}else{const y=(w=(v=f==null?void 0:f.fields)==null?void 0:v.filter(E=>E.type==="string"))==null?void 0:w.map(E=>{var C;return{label:(C=E==null?void 0:E.uiSchema)==null?void 0:C.title,value:E.name}}),O=(S=(T=f==null?void 0:f.fields)==null?void 0:T.filter(E=>E.type==="date"))==null?void 0:S.map(E=>{var C;return{label:(C=E==null?void 0:E.uiSchema)==null?void 0:C.title,value:E.name}}),D=yield x.FormDialog(s("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:l.scope,components:re({},l.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:s("Title field"),enum:y,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:s("Start date field"),enum:O,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:s("End date field"),enum:O,"x-component":"Select","x-decorator":"FormItem"}}}})})}),h).open({initialValues:{}});o(Fi({association:d,dataSource:m.dataSource,fieldNames:re({},D)}))}}),items:x.useRecordCollectionDataSourceItems("Calendar",e,c.target,d)}))};function VS(){const{insert:e}=x.useSchemaInitializer(),{getCollection:t}=x.useCollectionManager_deprecated(),{t:r}=$e(),n=b.useContext(q.SchemaOptionsContext),{theme:a}=x.useGlobalTheme();return{createAssociationCalendarBlock:s=>mr(this,[s],function*({item:i}){var h,p,m,g;const l=i.associationField,u=t(l.target),c=(p=(h=u==null?void 0:u.fields)==null?void 0:h.filter(v=>v.type==="string"))==null?void 0:p.map(v=>{var w;return{label:(w=v==null?void 0:v.uiSchema)==null?void 0:w.title,value:v.name}}),f=(g=(m=u==null?void 0:u.fields)==null?void 0:m.filter(v=>v.type==="date"))==null?void 0:g.map(v=>{var w;return{label:(w=v==null?void 0:v.uiSchema)==null?void 0:w.title,value:v.name}}),d=yield x.FormDialog(r("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:n.scope,components:re({},n.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:r("Title field"),enum:c,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:r("Start date field"),enum:f,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:r("End date field"),enum:f,"x-component":"Select","x-decorator":"FormItem"}}}})})}),a).open({initialValues:{}});e(Fi({association:`${l.collectionName}.${l.name}`,dataSource:i.dataSource,fieldNames:re({},d)}))})}}class af extends x.Plugin{load(){return mr(this,null,function*(){this.app.dataSourceManager.addCollectionTemplates([NS]),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer",useComponentProps(){const{createAssociationCalendarBlock:t}=VS(),{createCalendarBlock:r}=nf();return{onlyCurrentDataSource:!0,filterCollections({associationField:n}){return n?["hasMany","belongsToMany"].includes(n.type):!1},createBlockSchema:({item:n,fromOthersInPopup:a})=>{if(a)return r({item:n});t({item:n})},showAssociationFields:!0,hideSearch:!0}}}),this.app.addComponents({CalendarBlockProvider:_S,CalendarBlockInitializer:zS,RecordAssociationCalendarBlockInitializer:WS,CalendarV2:ES}),this.app.addScopes({useCalendarBlockProps:kS,useCalendarBlockDecoratorProps:IS}),this.schemaSettingsManager.add(PS),this.app.schemaInitializerManager.add(tf),this.app.schemaInitializerManager.add($S),this.app.schemaInitializerManager.add(LS),this.app.schemaInitializerManager.get("details:configureActions").add("enableActions.deleteEvent",rf)})}}R.PluginCalendarClient=af,R.default=af,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
103
+ `;Xc.displayName="GlobalStyle";const cS=()=>{const e=x.useDataBlockHeight(),{heightProps:t}=x.useBlockHeightProps(),{title:r}=t,{token:n}=we.theme.useToken();if(!e)return;const a=2*n.paddingLG,o=r?n.fontSizeLG*n.lineHeightLG+n.padding*2-1:0;return e-a-o},fS=x.genStyleHook("nb-calendar",e=>{const{componentCls:t}=e;return{[t]:{".rbc-btn":{color:"inherit",font:"inherit",margin:"0"},"button.rbc-btn":{overflow:"visible",textTransform:"none",WebkitAppearance:"button",cursor:"pointer"},"button[disabled].rbc-btn":{cursor:"not-allowed"},"button.rbc-input::-moz-focus-inner":{border:"0",padding:"0"},".rbc-button-link":{border:"none",backgroundColor:"transparent"},".rbc-calendar":{boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"stretch",height:"100%"},".rbc-calendar *,\n.rbc-calendar *:before,\n.rbc-calendar *:after":{boxSizing:"inherit"},".rbc-abs-full,\n.rbc-row-bg":{overflow:"hidden",position:"absolute",top:"0",left:"0",right:"0",bottom:"0"},".rbc-ellipsis,\n.rbc-event-label,\n.rbc-row-segment .rbc-event-content,\n.rbc-show-more":{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},".rbc-rtl":{direction:"rtl"},".rbc-off-range":{color:e.colorTextDisabled},".rbc-header":{overflow:"hidden",flex:"1 0 0%",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:`${e.paddingXXS}px ${e.paddingSM}px`,verticalAlign:"middle",minHeight:e.sizeXL,color:e.colorText,margin:`0 ${e.marginXXS}px`,borderBottom:`2px solid ${e.colorBorderSecondary}`},".rbc-rtl .rbc-header + .rbc-header":{borderLeftWidth:"0",borderRight:`1px solid ${e.colorBorderSecondary}`},".rbc-header > a,\n.rbc-header > a:active,\n.rbc-header > a:visited":{color:"inherit",textDecoration:"none"},".rbc-row-content":{position:"relative",userSelect:"none",WebkitUserSelect:"none",zIndex:4},".rbc-row-content-scrollable":{display:"flex",flexDirection:"column",height:"100%"},".rbc-row-content-scrollable .rbc-row-content-scroll-container":{height:"100%",overflowY:"scroll",msOverflowStyle:"none",scrollbarWidth:"none"},".rbc-row-content-scrollable .rbc-row-content-scroll-container::-webkit-scrollbar":{display:"none"},".rbc-toolbar":{display:"flex",flexWrap:"wrap",justifyContent:"center",alignItems:"center",marginBottom:e.marginXS,fontSize:e.fontSize},".rbc-toolbar .rbc-toolbar-label":{flexGrow:1,padding:`0 ${e.paddingXS}px`,textAlign:"center"},".rbc-toolbar button":{outline:"none",fontSize:e.fontSize,lineHeight:[e.lineHeight,"normal"],height:e.controlHeight,color:e.colorTextLabel,display:"inline-block",margin:"0",position:"relative",zIndex:1,textAlign:"center",verticalAlign:"middle",background:"none",backgroundImage:"none",border:`1px solid ${e.colorBorder}`,padding:`${e.paddingXXS}px ${e.paddingSM+e.paddingXXS}px`,borderRadius:e.borderRadiusXS,whiteSpace:"nowrap"},".rbc-toolbar button:active,\n.rbc-toolbar button.rbc-active":{zIndex:2,color:"#1890ff",borderColor:"#1890ff"},".rbc-toolbar button:active:hover,\n.rbc-toolbar button:active:focus,\n.rbc-toolbar button.rbc-active:hover,\n.rbc-toolbar button.rbc-active:focus":{zIndex:2,color:"#40a9ff",borderColor:"#40a9ff"},".rbc-toolbar button:hover":{zIndex:2,color:"#40a9ff",borderColor:"#40a9ff"},".rbc-btn-group":{display:"inline-block",whiteSpace:"nowrap"},".rbc-btn-group > button:first-child:not(:last-child)":{borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-btn-group > button:last-child:not(:first-child)":{borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-rtl .rbc-btn-group > button:first-child:not(:last-child)":{borderRadius:"4px",borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-rtl .rbc-btn-group > button:last-child:not(:first-child)":{borderRadius:"4px",borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-btn-group > button:not(:first-child):not(:last-child)":{borderRadius:"0"},".rbc-btn-group button + button":{marginLeft:"-1px"},".rbc-rtl .rbc-btn-group button + button":{marginLeft:"0",marginRight:"-1px"},".rbc-btn-group + .rbc-btn-group,\n.rbc-btn-group + button":{marginLeft:"10px"},".rbc-event":{border:"none",boxSizing:"border-box",boxShadow:"none",margin:"0",padding:"2px 5px",backgroundColor:e.colorBorderSecondary,borderRadius:e.borderRadiusXS,cursor:"pointer",fontSize:e.fontSizeSM,width:"100%",textAlign:"left","&:hover":{backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText}},".rbc-slot-selecting .rbc-event":{cursor:"inherit",pointerEvents:"none"},".rbc-event.rbc-selected":{backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText},".rbc-event-label":{fontSize:"80%"},".rbc-event-overlaps":{boxShadow:"-1px 1px 5px 0px rgba(51, 51, 51, 0.5)"},".rbc-event-continues-prior":{borderTopLeftRadius:"0",borderBottomLeftRadius:"0"},".rbc-event-continues-after":{borderTopRightRadius:"0",borderBottomRightRadius:"0"},".rbc-event-continues-earlier":{borderTopLeftRadius:"0",borderTopRightRadius:"0"},".rbc-event-continues-later":{borderBottomLeftRadius:"0",borderBottomRightRadius:"0"},".rbc-row":{display:"flex",flexDirection:"row"},".rbc-row-segment":{padding:"0 4px 1px 4px"},".rbc-selected-cell":{backgroundColor:"rgba(0, 0, 0, 0.1)"},".rbc-show-more":{zIndex:4,fontWeight:"bold",fontSize:"85%",height:"auto",lineHeight:"normal",color:"inherit",padding:"2px 5px"},".rbc-month-view":{position:"relative",display:"flex",flexDirection:"column",flex:"1 0 0",width:"100%",userSelect:"none",WebkitUserSelect:"none",height:"68vh",".rbc-day-bg":{borderTop:`2px solid ${e.colorBorderSecondary}`},".rbc-today":{borderColor:`${e.colorPrimaryBorder} !important`,backgroundColor:`${e.colorPrimaryBg} !important`},".rbc-header":{borderBottom:"0 !important"}},".rbc-month-header":{display:"flex",flexDirection:"row"},".rbc-month-row":{display:"flex",position:"relative",flexDirection:"column",flex:"1 0 0",flexBasis:"0px",overflow:"hidden",height:"100%"},".rbc-date-cell":{flex:"1 1 0",minWidth:"0",paddingLeft:"12px",paddingTop:"4px"},".rbc-date-cell.rbc-now span":{color:"#1890ff"},".rbc-date-cell a,\n.rbc-date-cell a:active,\n.rbc-date-cell a:visited":{color:"inherit",textDecoration:"none"},".rbc-date-cell a:hover":{color:"#1890ff"},".rbc-date-cell .rbc-date-solar":{fontWeight:500},".rbc-date-cell .rbc-date-lunar":{paddingLeft:"12px"},".rbc-date-cell:not(.rbc-off-range) .rbc-date-lunar":{color:"#aaa"},".rbc-date-cell .rbc-date-lunar:hover":{color:"inherit"},".rbc-row-bg":{display:"flex",flexDirection:"row",flex:"1 0 0",overflow:"hidden"},".rbc-day-bg":{flex:"1 0 0%",margin:"0 4px","&:hover":{background:e.colorFillQuaternary}},".rbc-agenda-view":{display:"flex",flexDirection:"column",flex:"1 0 0",overflow:"auto"},".rbc-agenda-view table.rbc-agenda-table":{width:"100%",border:"1px solid #f0f0f0",borderSpacing:"0",borderCollapse:"collapse"},".rbc-agenda-view table.rbc-agenda-table tbody > tr > td":{padding:"5px 10px",verticalAlign:"top"},".rbc-agenda-view table.rbc-agenda-table .rbc-agenda-time-cell":{paddingLeft:"15px",paddingRight:"15px",textTransform:"lowercase"},".rbc-agenda-view table.rbc-agenda-table tbody > tr > td + td":{borderLeft:"1px solid #f0f0f0"},".rbc-rtl .rbc-agenda-view table.rbc-agenda-table tbody > tr > td + td":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-agenda-view table.rbc-agenda-table tbody > tr + tr":{borderTop:"1px solid #f0f0f0"},".rbc-agenda-view table.rbc-agenda-table thead > tr > th":{padding:"3px 5px",textAlign:"left",borderBottom:"1px solid #f0f0f0"},".rbc-rtl .rbc-agenda-view table.rbc-agenda-table thead > tr > th":{textAlign:"right"},".rbc-agenda-time-cell":{textTransform:"lowercase"},".rbc-agenda-time-cell .rbc-continues-after:after":{content:"' »'"},".rbc-agenda-time-cell .rbc-continues-prior:before":{content:"'« '"},".rbc-agenda-date-cell,\n.rbc-agenda-time-cell":{whiteSpace:"nowrap"},".rbc-agenda-event-cell":{width:"100%"},".rbc-time-column":{display:"flex",flexDirection:"column",minHeight:"100%"},".rbc-time-column .rbc-timeslot-group":{flex:1},".rbc-timeslot-group":{borderBottom:"1px solid #f0f0f0",minHeight:"40px",lineHeight:"39px",display:"flex",flexFlow:"column nowrap","&:hover":{background:"#f0f0f0"}},".rbc-time-gutter,\n.rbc-header-gutter":{flex:"none"},".rbc-label":{padding:"0 5px"},".rbc-day-slot":{position:"relative"},".rbc-day-slot .rbc-events-container":{bottom:"0",left:"0",position:"absolute",right:"0",marginRight:"10px",top:"0"},".rbc-day-slot .rbc-events-container.rbc-rtl":{left:"10px",right:"0"},".rbc-day-slot .rbc-event":{border:"1px solid #265985",display:"flex",maxHeight:"100%",minHeight:"20px",flexFlow:"column wrap",alignItems:"flex-start",overflow:"hidden",position:"absolute"},".rbc-day-slot .rbc-event-label":{flex:"none",paddingRight:"5px",width:"auto"},".rbc-day-slot .rbc-event-content":{width:"100%",flex:"1 1 0",wordWrap:"break-word",lineHeight:1,height:"100%",minHeight:"1em"},".rbc-time-header-gutter":{lineHeight:"40px"},".rbc-time-header-cell":{minHeight:"32px !important"},".rbc-time-header-cell .rbc-header":{display:"flex"},".rbc-time-header-cell .rbc-header.rbc-today":{borderColor:e.colorPrimaryBorder,backgroundColor:e.colorPrimaryBg,color:e.colorPrimaryText},".rbc-time-header-cell .rbc-header a":{display:"flex",flexDirection:"column"},".rbc-time-header-cell .rbc-date-wrap":{display:"flex",alignItems:"center"},".rbc-time-header-cell .rbc-date-solar":{fontSize:"18px"},".rbc-time-header-cell .rbc-date-lunar":{marginLeft:"4px"},".rbc-time-header-cell .rbc-header:not(.rbc-today) .rbc-date-lunar":{color:"#aaa"},".rbc-calendar.view-week":{".rbc-time-header-cell":{marginTop:"-32px",marginBottom:"4px"},".rbc-time-view":{paddingTop:"32px",borderTop:"0"},".rbc-header":{padding:"4px 8px"},".rbc-time-header-content":{padding:"4px 0"},".rbc-time-header-gutter":{padding:"0",paddingTop:"2px","> div":{borderTop:"2px solid #f0f0f0",padding:"0 5px"}}},".rbc-time-view-resources .rbc-time-gutter,\n.rbc-time-view-resources .rbc-time-header-gutter":{position:"sticky",left:"0",backgroundColor:"white",borderRight:"1px solid #f0f0f0",zIndex:10,marginRight:"-1px"},".rbc-time-view-resources .rbc-time-header":{overflow:"hidden"},".rbc-time-view-resources .rbc-time-header-content":{minWidth:"auto",flex:"1 0 0",flexBasis:"0px"},".rbc-time-view-resources .rbc-time-header-cell-single-day":{display:"none"},".rbc-time-view-resources .rbc-day-slot":{minWidth:"140px"},".rbc-time-view-resources .rbc-header,\n.rbc-time-view-resources .rbc-day-bg":{width:"140px",flex:"1 1 0",flexBasis:"0 px"},".rbc-time-header-content + .rbc-time-header-content":{marginLeft:"-1px"},".rbc-time-slot":{flex:"1 0 0"},".rbc-time-slot.rbc-now":{fontWeight:"bold"},".rbc-day-header":{textAlign:"center"},".rbc-slot-selection":{zIndex:10,position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"75%",width:"100%",padding:"3px"},".rbc-slot-selecting":{cursor:"move"},".rbc-time-view":{display:"flex",flexDirection:"column",flex:1,width:"100%",borderTop:"1px solid #f0f0f0",minHeight:"0"},".rbc-time-view .rbc-time-gutter":{whiteSpace:"nowrap"},".rbc-time-view .rbc-allday-cell":{boxSizing:"content-box",width:"100%",height:"100%",position:"relative"},".rbc-time-view .rbc-allday-cell + .rbc-allday-cell":{borderLeft:"1px solid #f0f0f0"},".rbc-time-view .rbc-allday-events":{position:"relative",zIndex:4},".rbc-time-view .rbc-row":{boxSizing:"border-box",minHeight:"20px"},".rbc-time-header":{display:"flex",flex:"0 0 auto",flexDirection:"row"},".rbc-time-header.rbc-overflowing":{borderRight:"1px solid #f0f0f0"},".rbc-rtl .rbc-time-header.rbc-overflowing":{borderRightWidth:"0",borderLeft:"1px solid #f0f0f0"},".rbc-time-header > .rbc-row:first-child":{borderBottom:"1px solid #f0f0f0"},".rbc-time-header > .rbc-row.rbc-row-resource":{borderBottom:"1px solid #f0f0f0"},".rbc-time-header-cell-single-day":{display:"none"},".rbc-time-header-content":{flex:1,minWidth:"0",flexDirection:"column"},".rbc-rtl .rbc-time-header-content":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-time-header-content > .rbc-row.rbc-row-resource":{borderBottom:"1px solid #f0f0f0",flexShrink:0},".rbc-time-content":{display:"flex",flex:"1 0 0%",alignItems:"flex-start",width:"100%",borderTop:"1px solid #f0f0f0",overflowY:"auto",position:"relative"},".rbc-time-content > .rbc-time-gutter":{flex:"none"},".rbc-rtl .rbc-time-content > * + * > *":{borderLeftWidth:"0",borderRight:"1px solid #f0f0f0"},".rbc-time-content > .rbc-day-slot":{width:"100%",userSelect:"none",WebkitUserSelect:"none"},".rbc-current-time-indicator":{position:"absolute",zIndex:3,left:"0",right:"0",height:"1px",backgroundColor:"#74ad31",pointerEvents:"none"},"@media only screen and (max-width: 800px)":{".view-type-calendar .action-buttons":{position:"relative !important",left:"0 !important",".filter-action-button":{left:"0 !important"}},".rbc-toolbar .rbc-toolbar-label":{position:"absolute",top:"28px",left:"50%",transform:"translateX(-50%)"},".rbc-toolbar":{justifyContent:"space-between !important"},".rbc-header":{padding:"4px !important"}}}}}),dS={type:"void","x-component":"AssociationField.AddNewer","x-action":"create",title:'{{ t("Add record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:addNew:addBlock"},properties:{tab1:{type:"void",title:'{{t("Add new")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}},hS=["month","week","day"],mS=tS(Ie),Jc=(e,t)=>{for(const r of t)if(r.value===e)return r.color;return""},Ii=b.createContext({close:()=>{},allowDeleteEvent:!1});function pS(e){const t=q.useFieldSchema(),r=b.useMemo(()=>t.reduceProperties((n,a)=>a["x-component"].endsWith(".ActionBar")?a:n,null),[]);return N.jsx(zr.Provider,{value:e,children:N.jsx(q.RecursionField,{name:r.name,schema:r})})}const vS=(e,t,r,n)=>{var l,u;const{t:a}=$e(),{fields:o}=x.useCollection(),i=(l=o.find(c=>c.name===(t==null?void 0:t.title)))==null?void 0:l.uiSchema,s=o.find(c=>c.name===(t==null?void 0:t.colorFieldName));return b.useMemo(()=>{var d;if(!Array.isArray(e))return{events:[],enumList:[]};const c=((d=s==null?void 0:s.uiSchema)==null?void 0:d.enum)||[],f=[];return e.forEach(h=>{const{cron:p,exclude:m=[]}=h,g=Ie(pt.get(h,t.start)||Ie()),v=Ie(pt.get(h,t.end)||g),w=v.diff(g,"millisecond",!0),T=Ie(r);let S=T.clone().startOf("month"),y=S.clone().endOf("month");n==="month"&&(S=S.startOf("week"),y=y.endOf("week"));const O=(D=g.clone())=>{if(D.isBefore(g)||!D.isBetween(S,y)&&!v.isBetween(S,y))return;let E=!1;if(m==null?void 0:m.some(M=>M.endsWith("_after")?(M=M.replace(/_after$/,""),E=!0,D.isSameOrAfter(M)):D.isSame(M)))return E;const _=x.getLabelFormatValue(i,pt.get(h,t.title),!0),k={id:pt.get(h,t.id||"id"),colorFieldValue:h[t.colorFieldName],title:_||a("Untitle"),start:D.toDate(),end:D.add(w,"millisecond").toDate()};f.push(k)};if(p==="every_week"){let D=g.clone().year(S.year()).month(S.month()).date(S.date()).day(g.day());for(;D.isBefore(y)&&!O(D.clone());)D=D.add(1,"week")}else if(p==="every_month")O(g.clone().year(T.year()).month(T.month()));else if(p==="every_year")O(g.clone().year(T.year()));else{if(O(),!p)return;try{const D=xh.parseExpression(p,{startDate:S.toDate(),endDate:y.toDate(),iterator:!0,currentDate:g.toDate(),utc:!0});for(;D.hasNext();){const{value:E}=D.next();if(O(Ie(E.toDate())))break}}catch(D){console.error(D)}}}),{events:f,enumList:c}},[i,e,t.colorFieldName,t.start,t.end,t.id,t.title,r,n,a,(u=s==null?void 0:s.uiSchema)==null?void 0:u.enum])},gS=e=>{const t=q.useFieldSchema(),{insertAfterBegin:r}=x.useDesignable();return b.useCallback(a=>{t.reduceProperties((i,s)=>s["x-component"]==="AssociationField."+e?s:i,null)||r(pt.cloneDeep(a))},[e])},Dt=x.withDynamicSchemaProps(q.observer(e=>{var L,V;const[t,r]=b.useState(!1),{openPopup:n}=x.usePopupUtils({setVisible:r}),{dataSource:a,fieldNames:o,showLunar:i,defaultView:s}=x.useProps(e),l=cS(),[u,c]=b.useState(new Date),[f,d]=b.useState(e.defaultView||"month"),{events:h,enumList:p}=vS(a,o,u,f),[m,g]=b.useState({}),{wrapSSR:v,hashId:w,componentCls:T}=fS(),S=x.useCollectionParentRecordData(),y=q.useFieldSchema(),O=q.useField(),{token:D}=x.useToken(),{parseAction:E}=x.useACLRoleContext(),C=x.useCollection(),_=E(`${C.name}:create`),k=(L=o==null?void 0:o.start)==null?void 0:L[0],M=(V=o==null?void 0:o.end)==null?void 0:V[0],W=gS("AddNewer"),U=x.useActionContext(),[Q,G]=b.useState(!1),[Z,se]=b.useState(void 0);b.useEffect(()=>{d(e.defaultView)},[e.defaultView]);const be=b.useMemo(()=>({toolbar:$=>N.jsx(pS,Je(re({},$),{showLunar:i})),month:{dateHeader:$=>N.jsx(sS,Je(re({},$),{showLunar:i}))}}),[i]),Be={allDay:"",previous:N.jsx("div",{children:N.jsx(mt.LeftOutlined,{})}),next:N.jsx("div",{children:N.jsx(mt.RightOutlined,{})}),today:He("Today"),month:He("Month"),week:He("Week"),work_week:He("Work week"),day:He("Day"),agenda:He("Agenda"),date:He("Date"),time:He("Time"),event:He("Event"),noEventsInRange:He("None"),showMore:$=>He("{{count}} more items",{count:$})},A=$=>{if($.colorFieldValue){const B=D[`${Jc($.colorFieldValue,p)}7`],K=D[`${Jc($.colorFieldValue,p)}1`];return{style:{color:B,backgroundColor:K,border:"none"}}}},P=()=>{var xt,ct,Lt;const $=x.useFormBlockContext();let B=Z.start,K=Z.end;const X=C.getField(k),Ne=C.getField(M);return b.useEffect(()=>{var Wr,$a,Nn,In,Fa,La,dt;const ft=$.form;if(!(!ft||(Wr=$.service)!=null&&Wr.loading)&&Z){const ht=re(re({},($a=X==null?void 0:X.uiSchema)==null?void 0:$a["x-component-props"]),(In=(Nn=$.form)==null?void 0:Nn.query(k).take())==null?void 0:In.componentProps),zt=re(re({},(Fa=Ne==null?void 0:Ne.uiSchema)==null?void 0:Fa["x-component-props"]),(dt=(La=$.form)==null?void 0:La.query(M).take())==null?void 0:dt.componentProps);B=x.handleDateChangeOnForm(Z.start,ht.dateOnly,ht.utc,ht.picker,ht.showTime,ht.gtm),K=x.handleDateChangeOnForm(Z.end,zt.dateOnly,zt.utc,zt.picker,zt.showTime,zt.gtm),ft.initialValues[k]||ft.setInitialValuesIn([k],B),ft.initialValues[M]||ft.setInitialValuesIn([M],K)}},[$.form,(ct=(xt=$.service)==null?void 0:xt.data)==null?void 0:ct.data,(Lt=$.service)==null?void 0:Lt.loading]),{form:$.form}};return v(N.jsxs("div",{className:`${w} ${T}`,style:{height:l||700},children:[N.jsxs(x.PopupContextProvider,{visible:t,setVisible:r,children:[N.jsx(Xc,{}),N.jsx(x.RecordProvider,{record:m,parent:S,children:N.jsx(oS,{})}),N.jsx(Z1,{popup:!0,selectable:!0,events:h,eventPropGetter:A,view:f,views:hS,date:u,step:60,showMultiDayTimes:!0,messages:Be,onNavigate:c,onView:d,onSelectSlot:$=>{se($),_&&(W(dS),G(!0))},onDoubleClickEvent:()=>{console.log("onDoubleClickEvent")},onSelectEvent:$=>{const B=a==null?void 0:a.find(K=>K[o.id]===$.id);B&&(B.__event=Je(re({},$),{start:Ni(Ie($.start)),end:Ni(Ie($.end))}),g(B),n({recordData:B,customActionSchema:Zc(y)}))},formats:{monthHeaderFormat:"YYYY-M",agendaDateFormat:"M-DD",dayHeaderFormat:"YYYY-M-DD",dayRangeHeaderFormat:({start:$,end:B},K,X)=>Yc.eq($,B,"month")?X.format($,"YYYY-M",K):`${X.format($,"YYYY-M",K)} - ${X.format(B,"YYYY-M",K)}`},components:be,localizer:mS})]}),N.jsx(x.ActionContextProvider,{value:Je(re({},U),{visible:Q,setVisible:G}),children:N.jsx(x.CollectionProvider,{name:C.name,children:N.jsx(x.SchemaComponentOptions,{scope:{useCreateFormBlockProps:P},children:N.jsx(q.RecursionField,{onlyRenderProperties:!0,basePath:O==null?void 0:O.address,schema:y,filterProperties:$=>$["x-component"]==="AssociationField.AddNewer"})})})})]}))},{displayName:"Calendar"})),bS=()=>{const{name:e,title:t}=x.useCollection(),r=x.useSchemaTemplate();return N.jsx(x.GeneralSchemaDesigner,{schemaSettings:"blockSettings:calendar",template:r,title:t||e})},{Text:yS}=we.Typography,wS=q.observer(()=>{var E,C,_;const{visible:e,setVisible:t,setSubmitted:r}=x.useActionContext(),D=x.useRecord(),{exclude:n=[],cron:a}=D,o=Wi(D,["exclude","cron"]),{close:i}=b.useContext(Ii),{context:s,closePopup:l}=x.usePopupUtils(),u=((E=s==null?void 0:s.params)==null?void 0:E.popupuid)||"",c=x.getStoredPopupContext(u)||{record:null,service:null},f=b.useMemo(()=>{var k,M;return Ni(Ie((M=(k=c.record)==null?void 0:k.data)==null?void 0:M.__event.start))},[(_=(C=c.record)==null?void 0:C.data)==null?void 0:_.__event.start]),d=!c.record,h=x.useFilterByTk(),{resource:p,service:m,__parent:g}=x.useBlockRequestContext(),[v,w]=b.useState(d?"all":f),[T,S]=b.useState(!1),y=()=>mr(this,null,function*(){var k,M,W;S(!0),v==="all"||!a?yield p.destroy({filterByTk:h}):yield p.update({filterByTk:h,values:{exclude:(n||[]).concat(v)}}),S(!1),(M=(k=g==null?void 0:g.service)==null?void 0:k.refresh)==null||M.call(k),(W=m==null?void 0:m.refresh)==null||W.call(m),t==null||t(!1,!0),i(),r==null||r(!0)}),{t:O}=$e();return Vt.createPortal(N.jsx(we.Modal,{title:a?O("Delete events"):null,open:e,onCancel:()=>t(!1),onOk:()=>y(),confirmLoading:T,children:a?N.jsx(we.Radio.Group,{value:v,onChange:k=>w(k.target.value),children:N.jsxs(we.Space,{direction:"vertical",children:[N.jsx(we.Radio,{value:f,disabled:d,children:O("This event")}),N.jsx(we.Radio,{value:`${f}_after`,disabled:d,children:O("This and following events")}),N.jsx(we.Radio,{value:"all",children:O("All events")})]})}):N.jsx(yS,{strong:!0,style:{fontSize:"18px"},children:O("Delete this event?")})}),document.body)},{displayName:"DeleteEvent"}),SS=q.observer(e=>{const{visible:t,setVisible:r}=x.useActionContext(),n=x.useCollectionRecordData(),a=x.useCollection(),{isPopupVisibleControlledByURL:o}=x.usePopupSettings(),i=o()?null:r,s=b.useCallback(()=>{r(!1)},[r]);return N.jsx(x.PopupContextProvider,{visible:t,setVisible:i,children:N.jsx(Ii.Provider,{value:{close:s,allowDeleteEvent:!0},children:N.jsx(x.VariablePopupRecordProvider,{recordData:n,collection:a,children:e.children})})})},{displayName:"Event"}),OS=q.observer(()=>{const{DesignableBar:e}=x.useDesignable(),{onNavigate:t}=b.useContext(zr);return N.jsxs(we.Button.Group,{children:[N.jsx(we.Button,{icon:N.jsx(mt.LeftOutlined,{}),onClick:()=>t(ge.PREVIOUS)}),N.jsx(we.Button,{icon:N.jsx(mt.RightOutlined,{}),onClick:()=>t(ge.NEXT)}),N.jsx(e,{})]})},{displayName:"Nav"}),TS=q.observer(()=>{const{DesignableBar:e}=x.useDesignable(),{date:t,view:r,label:n,showLunar:a}=b.useContext(zr),o=b.useMemo(()=>{if(!(!a||r!=="day"))return N.jsx("span",{children:Kc(t)})},[r,t,a]);return N.jsxs(we.Button.Group,{style:{fontSize:"1.75em",fontWeight:300},children:[N.jsx("span",{children:n}),N.jsx("span",{style:{marginLeft:"4px"},children:o}),N.jsx(e,{})]})},{displayName:"Title"}),DS=q.observer(e=>{const{DesignableBar:t}=x.useDesignable(),{onNavigate:r}=b.useContext(zr),{t:n}=$e();return N.jsxs(we.Button,{onClick:()=>{r(ge.TODAY)},children:[n("Today"),N.jsx(t,{})]})},{displayName:"Today"}),xS=q.observer(e=>{const{DesignableBar:t}=x.useDesignable(),{views:r,view:n,onView:a,localizer:{messages:o}}=b.useContext(zr);return N.jsxs("div",{className:"ant-btn-group",children:[N.jsx(we.Select,{popupMatchSelectWidth:!1,value:n,onChange:a,children:r.map(i=>N.jsx(we.Select.Option,{value:i,children:o[i]},i))}),N.jsx(t,{})]})},{displayName:"ViewSelect"});Dt.ActionBar=x.ActionBar,Dt.Event=SS,Dt.DeleteEvent=wS,Dt.Title=TS,Dt.Today=DS,Dt.Nav=OS,Dt.ViewSelect=xS,Dt.Designer=bS;const ES=Dt;function Qc(e){var o;const{filter:t,parseVariableLoading:r}=x.useParsedFilter({filterOption:(o=e.params)==null?void 0:o.filter}),n=b.useMemo(()=>{var u,c;const i=[],s=(u=e.fieldNames)==null?void 0:u.start,l=(c=e.fieldNames)==null?void 0:c.end;return Array.isArray(s)&&s.length>=2&&i.push(s[0]),Array.isArray(l)&&l.length>=2&&i.push(l[0]),i},[e.fieldNames]);return{params:b.useMemo(()=>Je(re({},e.params),{appends:[...n,...e.params.appends||[]],paginate:!1,filter:t}),[n,JSON.stringify(t),e.params]),parseVariableLoading:r}}const $i=b.createContext({});$i.displayName="CalendarBlockContext";const CS=e=>{var s;const{fieldNames:t,showLunar:r,defaultView:n}=e,a=q.useField(),{resource:o,service:i}=x.useBlockRequestContext();return N.jsx(x.FixedBlockWrapper,{children:N.jsx($i.Provider,{value:{field:a,service:i,resource:o,fieldNames:t,showLunar:r,defaultView:n,fixedBlock:(s=a==null?void 0:a.decoratorProps)==null?void 0:s.fixedBlock},children:e.children})})},MS=e=>q.useFieldSchema()["x-use-decorator-props"]?{params:e.params,parseVariableLoading:e.parseVariableLoading}:Qc(e),_S=x.withDynamicSchemaProps(e=>{const{params:t,parseVariableLoading:r}=MS(e);return r?null:N.jsx(x.BlockProvider,Je(re({name:"calendar"},e),{params:t,children:N.jsx(CS,re({},e))}))},{displayName:"CalendarBlockProvider"}),Pn=()=>b.useContext($i),kS=()=>{var r;const e=Pn(),t=q.useField();return b.useEffect(()=>{var n,a,o;(n=e==null?void 0:e.service)!=null&&n.loading||(t.componentProps.dataSource=(o=(a=e==null?void 0:e.service)==null?void 0:a.data)==null?void 0:o.data)},[(r=e==null?void 0:e.service)==null?void 0:r.loading]),{fieldNames:e.fieldNames,showLunar:e.showLunar,defaultView:e.defaultView,fixedBlock:e.fixedBlock}},AS=()=>{const e=q.useField(),{t}=$e(),r=q.useFieldSchema(),{dn:n}=x.useDesignable();return N.jsx(x.SchemaSettingsSwitchItem,{title:t("Show lunar"),checked:e.decoratorProps.showLunar,onChange:a=>{e.decoratorProps.showLunar=a,r["x-decorator-props"].showLunar=a,n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":e.decoratorProps}}),n.refresh()}})},PS=new x.SchemaSettings({name:"blockSettings:calendar",items:[{name:"title",Component:x.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:x.SchemaSettingsBlockHeightItem},{name:"titleField",Component:x.SchemaSettingsSelectItem,useComponentProps(){var u;const{t:e}=$e(),t=q.useFieldSchema(),r=((u=t==null?void 0:t["x-decorator-props"])==null?void 0:u.fieldNames)||{},{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{name:o,title:i}=x.useCollection(),s=q.useField(),{dn:l}=x.useDesignable();return{title:e("Title field"),value:r.title,options:a(o,"string"),onChange:c=>{const f=s.decoratorProps.fieldNames||{};f.title=c,s.decoratorProps.params=f,t["x-decorator-props"].params=f,t["x-decorator-props"].fieldNames=f,n.refresh(),l.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":s.decoratorProps}}),l.refresh()}}}},{name:"colorField",Component:x.SchemaSettingsSelectItem,useComponentProps(){var c;const{t:e}=$e(),t=q.useFieldSchema(),r=((c=t==null?void 0:t["x-decorator-props"])==null?void 0:c.fieldNames)||{},{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{name:o}=x.useCollection(),i=q.useField(),{dn:s}=x.useDesignable(),l=a(o,"string"),u=[{label:e("Not selected"),value:""},...l.filter(f=>f.interface==="radioGroup"||f.interface==="select")];return{title:e("Background color field"),value:r.colorFieldName||"",options:u,onChange:f=>{var h;const d=((h=t["x-decorator-props"])==null?void 0:h.fieldNames)||{};d.colorFieldName=f,i.decoratorProps.fieldNames=d,t["x-decorator-props"].fieldNames=d,n.refresh(),s.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}}),s.refresh()}}}},{name:"defaultView",Component:x.SchemaSettingsSelectItem,useComponentProps(){const{t:e}=$e(),t=q.useFieldSchema(),r=q.useField(),{dn:n}=x.useDesignable();return{title:e("Default view"),value:r.decoratorProps.defaultView||"month",options:[{value:"month",label:e("Month")},{value:"week",label:e("Week")},{value:"day",label:e("Day")}],onChange:a=>{r.decoratorProps.defaultView=a,t["x-decorator-props"].defaultView=a,n.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),n.refresh()}}}},{name:"showLunar",Component:AS},{name:"startDateField",Component:x.SchemaSettingsCascaderItem,useComponentProps(){var l;const{getCollectionFieldsOptions:e}=x.useCollectionManager_deprecated(),{t}=$e(),r=q.useFieldSchema(),n=((l=r==null?void 0:r["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=q.useField(),{dn:o}=x.useDesignable(),{service:i}=Pn(),{name:s}=x.useCollection();return{title:t("Start date field"),value:n.start,options:e(s,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"]}),onChange:u=>{const c=a.decoratorProps.fieldNames||{};c.start=u,a.decoratorProps.fieldNames=c,r["x-decorator-props"].fieldNames=c,i.refresh(),o.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":a.decoratorProps}}),o.refresh()}}}},{name:"endDateField",Component:x.SchemaSettingsCascaderItem,useComponentProps(){var l;const{t:e}=$e(),t=q.useFieldSchema(),r=q.useField(),{service:n}=Pn(),{getCollectionFieldsOptions:a}=x.useCollectionManager_deprecated(),{dn:o}=x.useDesignable(),{name:i}=x.useCollection(),s=((l=t==null?void 0:t["x-decorator-props"])==null?void 0:l.fieldNames)||{};return{title:e("End date field"),value:s.end,options:a(i,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"]}),onChange:u=>{const c=r.decoratorProps.fieldNames||{};c.end=u,r.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,n.refresh(),o.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":r.decoratorProps}}),o.refresh()}}}},{name:"dataScope",Component:x.SchemaSettingsDataScope,useComponentProps(){var o,i;const{name:e}=x.useCollection(),t=q.useFieldSchema(),{form:r}=x.useFormBlockContext(),n=q.useField(),{dn:a}=x.useDesignable();return{collectionName:e,defaultFilter:((i=(o=t==null?void 0:t["x-decorator-props"])==null?void 0:o.params)==null?void 0:i.filter)||{},form:r,onSubmit:({filter:s})=>{s=x.removeNullCondition(s);const l=n.decoratorProps.params||{};l.filter=s,n.decoratorProps.params=l,t["x-decorator-props"].params=l,a.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}})}}}},{name:"divider",type:"divider"},{name:"template",Component:x.SchemaSettingsTemplate,useComponentProps(){var a,o;const{name:e}=x.useCollection(),t=q.useFieldSchema(),{componentNamePrefix:r}=x.useBlockTemplateContext(),n=((a=t==null?void 0:t["x-decorator-props"])==null?void 0:a.resource)||((o=t==null?void 0:t["x-decorator-props"])==null?void 0:o.association);return{componentName:`${r}Calendar`,collectionName:e,resourceName:n}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});Y("Calendar collection"),Y("Repeats"),Y("Daily"),Y("Weekly"),Y("Monthly"),Y("Yearly"),x.getConfigurableProperties("title","name","inherits","category","description","presetFields");class NS extends x.CollectionTemplate{constructor(){super(...arguments);Wt(this,"name","calendar");Wt(this,"title",Y("Calendar collection"));Wt(this,"order",2);Wt(this,"color","orange");Wt(this,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,sortable:!0,fields:[{name:"cron",type:"string",uiSchema:{type:"string",title:Y("Repeats"),"x-component":"CronSet","x-component-props":"allowClear",enum:[{label:Y("Daily"),value:"0 0 0 * * ?"},{label:Y("Weekly"),value:"every_week"},{label:Y("Monthly"),value:"every_month"},{label:Y("Yearly"),value:"every_year"}]},interface:"select"},{name:"exclude",type:"json"}]});Wt(this,"availableFieldInterfaces",{include:[]});Wt(this,"configurableProperties",x.getConfigurableProperties("title","name","inherits","category","description","presetFields"))}}function IS(e){const{params:t,parseVariableLoading:r}=Qc(e);let n;return e.association&&(n=x.useParentRecordCommon(e.association)),{params:t,parentRecord:n,parseVariableLoading:r}}const Ia=e=>{const t=x.useSchemaInitializerItem();return N.jsx(x.InitializerWithSwitch,Je(re(re({},t),e),{item:t,type:"x-action"}))},ef={title:Y("Configure actions"),icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"today",title:Y("Today"),Component:Ia,schema:{title:Y("Today"),"x-component":"CalendarV2.Today","x-action":"calendar:today","x-align":"left"}},{name:"turnPages",title:Y("Turn pages"),Component:Ia,schema:{title:Y("Turn pages"),"x-component":"CalendarV2.Nav","x-action":"calendar:nav","x-align":"left"}},{name:"title",title:Y("Title"),Component:Ia,schema:{title:Y("Title"),"x-component":"CalendarV2.Title","x-action":"calendar:title","x-align":"left"}},{name:"selectView",title:Y("Select view"),Component:Ia,schema:{title:Y("Select view"),"x-component":"CalendarV2.ViewSelect","x-action":"calendar:viewSelect","x-align":"right","x-designer":"Action.Designer"}},{name:"filter",title:Y("Filter"),Component:"FilterActionInitializer",schema:{"x-align":"right"}},{name:"addNew",title:Y("Add new"),Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>x.useActionAvailable("create")},{name:"customRequest",title:'{{t("Custom request")}}',Component:"CustomRequestInitializer",schema:{"x-action":"customize:table:request:global"}}]},tf=new x.CompatibleSchemaInitializer(re({name:"CalendarActionInitializers"},ef)),$S=new x.CompatibleSchemaInitializer(re({name:"calendar:configureActions"},ef),tf),FS=e=>{const t={title:'{{ t("Delete Event") }}',"x-action":"deleteEvent","x-acl-action":"destroy","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"DeleteOutlined"},properties:{modal:{"x-component":"CalendarV2.DeleteEvent"}}};return N.jsx(x.ActionInitializerItem,Je(re({},e),{schema:t}))},rf={name:"deleteEvent",title:Y("Delete Event"),Component:FS,schema:{"x-component":"Action","x-decorator":"ACLActionProvider"},useVisible(){const{allowDeleteEvent:e}=b.useContext(Ii);return x.useCollection_deprecated().template==="calendar"&&e}},LS=new x.SchemaInitializer({title:Y("Configure actions"),name:"CalendarFormActionInitializers",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",name:"enableActions",title:Y("Enable actions"),children:[{name:"edit",title:Y("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible:()=>x.useActionAvailable("update")},{name:"delete",title:Y("Delete"),Component:"DestroyActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider"},useVisible:()=>x.useActionAvailable("destroy")},rf]},{name:"divider",type:"divider"},{type:"subMenu",name:"customize",title:Y("Customize"),children:[{name:"popup",title:Y("Popup"),Component:"CustomizeActionInitializer",schema:{type:"void",title:Y("Popup"),"x-action":"customize:popup","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:popup","x-component":"Action","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:Y("Popup"),"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:Y("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}}}}},{name:"updateRecord",title:Y("Update record"),Component:"CustomizeActionInitializer",schema:{title:Y("Update record"),"x-component":"Action","x-use-component-props":"useCustomizeUpdateActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:updateRecord","x-acl-action":"update","x-action":"customize:update","x-action-settings":{assignedValues:{},onSuccess:{manualClose:!0,redirecting:!1,successMessage:Y("Updated successfully")},triggerWorkflows:[]}},useVisible:()=>x.useActionAvailable("update")},{name:"customRequest",title:Y("Custom request"),Component:"CustomRequestInitializer"}]}]}),Fi=e=>{const{collectionName:t,dataSource:r,fieldNames:n,association:a}=e;return{type:"void","x-acl-action":`${a||t}:list`,"x-decorator":"CalendarBlockProvider","x-use-decorator-props":"useCalendarBlockDecoratorProps","x-decorator-props":{collection:t,dataSource:r,association:a,action:"list",fieldNames:re({id:"id"},n),params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:calendar","x-component":"CardItem",properties:{[mf.uid()]:{type:"void","x-component":"CalendarV2","x-use-component-props":"useCalendarBlockProps",properties:{toolBar:{type:"void","x-component":"CalendarV2.ActionBar","x-component-props":{style:{marginBottom:24}},"x-initializer":"calendar:configureActions"},event:{type:"void","x-component":"CalendarV2.Event",properties:{drawer:{type:"void","x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:Y("View record"),properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:common:addBlock"},properties:{tab1:{type:"void",title:Y("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer-props":{actionInitializers:"details:configureActions"},"x-initializer":"popup:common:addBlock"}}}}}}}}}}}}}},zS=({filterCollections:e,onlyCurrentDataSource:t,hideSearch:r,createBlockSchema:n,showAssociationFields:a})=>{const o=x.useSchemaInitializerItem(),{createCalendarBlock:i}=nf();return N.jsx(x.DataBlockInitializer,Je(re({},o),{componentType:"Calendar",icon:N.jsx(mt.CalendarOutlined,{}),onCreateBlockSchema:s=>mr(this,null,function*(){if(n)return n(s);i(s)}),onlyCurrentDataSource:t,hideSearch:r,filter:e,showAssociationFields:a}))},nf=()=>{const{insert:e}=x.useSchemaInitializer(),{t}=$e(),{getCollectionField:r,getCollectionFieldsOptions:n}=x.useCollectionManager_deprecated(),a=b.useContext(q.SchemaOptionsContext),{theme:o}=x.useGlobalTheme();return{createCalendarBlock:l=>mr(this,[l],function*({item:s}){const u=n(s.name,"string",{dataSource:s.dataSource}),c=n(s.name,["date","datetime","dateOnly","datetimeNoTz","unixTimestamp"],{association:["o2o","obo","oho","m2o"],dataSource:s.dataSource}),f=yield x.FormDialog(t("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:a.scope,components:re({},a.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:t("Title field"),enum:u,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:t("Start date field"),enum:c,required:!0,default:r(`${s.name}.createdAt`)?"createdAt":null,"x-component":"Cascader","x-decorator":"FormItem"},end:{title:t("End date field"),enum:c,"x-component":"Cascader","x-decorator":"FormItem"}}}})})}),o).open({initialValues:{}});e(Fi({collectionName:s.name,dataSource:s.dataSource,fieldNames:re({},f)}))})}},WS=()=>{const e=x.useSchemaInitializerItem(),p=e,{onCreateBlockSchema:t,componentType:r,createBlockSchema:n}=p,a=Wi(p,["onCreateBlockSchema","componentType","createBlockSchema"]),{insert:o}=x.useSchemaInitializer(),{getTemplateSchemaByMode:i}=x.useSchemaTemplateManager(),{t:s}=$e(),l=b.useContext(q.SchemaOptionsContext),{getCollection:u}=x.useCollectionManager_deprecated(),c=e.field,f=u(c.target),d=`${c.collectionName}.${c.name}`,{theme:h}=x.useGlobalTheme();return N.jsx(x.SchemaInitializerItem,Je(re({icon:N.jsx(mt.TableOutlined,{})},a),{onClick:g=>mr(this,[g],function*({item:m}){var v,w,T,S;if(m.template){const y=yield i(m);o(y)}else{const y=(w=(v=f==null?void 0:f.fields)==null?void 0:v.filter(E=>E.type==="string"))==null?void 0:w.map(E=>{var C;return{label:(C=E==null?void 0:E.uiSchema)==null?void 0:C.title,value:E.name}}),O=(S=(T=f==null?void 0:f.fields)==null?void 0:T.filter(E=>E.type==="date"))==null?void 0:S.map(E=>{var C;return{label:(C=E==null?void 0:E.uiSchema)==null?void 0:C.title,value:E.name}}),D=yield x.FormDialog(s("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:l.scope,components:re({},l.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:s("Title field"),enum:y,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:s("Start date field"),enum:O,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:s("End date field"),enum:O,"x-component":"Select","x-decorator":"FormItem"}}}})})}),h).open({initialValues:{}});o(Fi({association:d,dataSource:m.dataSource,fieldNames:re({},D)}))}}),items:x.useRecordCollectionDataSourceItems("Calendar",e,c.target,d)}))};function VS(){const{insert:e}=x.useSchemaInitializer(),{getCollection:t}=x.useCollectionManager_deprecated(),{t:r}=$e(),n=b.useContext(q.SchemaOptionsContext),{theme:a}=x.useGlobalTheme();return{createAssociationCalendarBlock:s=>mr(this,[s],function*({item:i}){var h,p,m,g;const l=i.associationField,u=t(l.target),c=(p=(h=u==null?void 0:u.fields)==null?void 0:h.filter(v=>v.type==="string"))==null?void 0:p.map(v=>{var w;return{label:(w=v==null?void 0:v.uiSchema)==null?void 0:w.title,value:v.name}}),f=(g=(m=u==null?void 0:u.fields)==null?void 0:m.filter(v=>v.type==="date"))==null?void 0:g.map(v=>{var w;return{label:(w=v==null?void 0:v.uiSchema)==null?void 0:w.title,value:v.name}}),d=yield x.FormDialog(r("Create calendar block"),()=>N.jsx(x.SchemaComponentOptions,{scope:n.scope,components:re({},n.components),children:N.jsx(Wa.FormLayout,{layout:"vertical",children:N.jsx(x.SchemaComponent,{schema:{properties:{title:{title:r("Title field"),enum:c,required:!0,"x-component":"Select","x-decorator":"FormItem"},start:{title:r("Start date field"),enum:f,required:!0,default:"createdAt","x-component":"Select","x-decorator":"FormItem"},end:{title:r("End date field"),enum:f,"x-component":"Select","x-decorator":"FormItem"}}}})})}),a).open({initialValues:{}});e(Fi({association:`${l.collectionName}.${l.name}`,dataSource:i.dataSource,fieldNames:re({},d)}))})}}class af extends x.Plugin{load(){return mr(this,null,function*(){this.app.dataSourceManager.addCollectionTemplates([NS]),this.app.schemaInitializerManager.addItem("page:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.calendar",{title:Y("Calendar"),Component:"CalendarBlockInitializer",useComponentProps(){const{createAssociationCalendarBlock:t}=VS(),{createCalendarBlock:r}=nf();return{onlyCurrentDataSource:!0,filterCollections({associationField:n}){return n?["hasMany","belongsToMany"].includes(n.type):!1},createBlockSchema:({item:n,fromOthersInPopup:a})=>{if(a)return r({item:n});t({item:n})},showAssociationFields:!0,hideSearch:!0}}}),this.app.addComponents({CalendarBlockProvider:_S,CalendarBlockInitializer:zS,RecordAssociationCalendarBlockInitializer:WS,CalendarV2:ES}),this.app.addScopes({useCalendarBlockProps:kS,useCalendarBlockDecoratorProps:IS}),this.schemaSettingsManager.add(PS),this.app.schemaInitializerManager.add(tf),this.app.schemaInitializerManager.add($S),this.app.schemaInitializerManager.add(LS),this.app.schemaInitializerManager.get("details:configureActions").add("enableActions.deleteEvent",rf)})}}R.PluginCalendarClient=af,R.default=af,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -8,10 +8,10 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.4.26",
11
+ "@nocobase/client": "1.4.28",
12
12
  "react-i18next": "11.18.6",
13
- "@nocobase/server": "1.4.26",
14
- "@nocobase/test": "1.4.26",
13
+ "@nocobase/server": "1.4.28",
14
+ "@nocobase/test": "1.4.28",
15
15
  "react": "18.2.0",
16
16
  "@ant-design/icons": "5.2.6",
17
17
  "@formily/react": "2.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-calendar",
3
- "version": "1.4.26",
3
+ "version": "1.4.28",
4
4
  "displayName": "Calendar",
5
5
  "displayName.zh-CN": "日历",
6
6
  "description": "Provides callendar collection template and block for managing date data, typically for date/time related information such as events, appointments, tasks, and so on.",
@@ -36,7 +36,7 @@
36
36
  "url": "git+https://github.com/nocobase/nocobase.git",
37
37
  "directory": "packages/plugins/calendar"
38
38
  },
39
- "gitHead": "6e9064d9d028901b0fce51fae363dfaabf6edcc6",
39
+ "gitHead": "260a61dc3ac950026860dc7d164a26dd3ce81a0e",
40
40
  "keywords": [
41
41
  "Collections",
42
42
  "Blocks"