@nocobase/plugin-kanban 1.0.0-alpha.15 → 1.0.0-alpha.17

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.
@@ -308,4 +308,4 @@ Error generating stack: `+i.message+`
308
308
  color: #8c8c8c;
309
309
  fontweight: normal;
310
310
  }
311
- `,qs=D.memo(ee.RecursionField);qs.displayName="MemorizedRecursionField";const lI=ee.observer(()=>{const{t:e}=iI(),r=P.useCollection(),{setDisableCardDrag:n,cardViewerSchema:t,card:o,cardField:i,columnIndex:a,cardIndex:l}=D.useContext(Hs),u=P.useCollectionParentRecordData(),s=ee.useFieldSchema(),[f,c]=D.useState(!1),d=D.useCallback(g=>{const y=g.target;g.currentTarget.contains(y)&&c(!0),g.stopPropagation()},[]),p=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),h=D.useCallback(()=>{n(!0)},[]),S=D.useCallback(()=>{n(!1)},[]),w=D.useMemo(()=>{var g,y;return{openMode:((g=s["x-component-props"])==null?void 0:g.openMode)||"drawer",openSize:(y=s["x-component-props"])==null?void 0:y.openSize,visible:f,setVisible:c}},[s,f]),m=D.useMemo(()=>i.address.concat(`${a}.cards.${l}`),[i,a,l]),v=D.useMemo(()=>i.address.concat(`${a}.cardViewer.${l}`),[i,a,l]);return x.jsxs(x.Fragment,{children:[x.jsx(qe.Card,{onClick:d,bordered:!1,hoverable:!0,style:p,className:aI,children:x.jsx(P.DndContext,{onDragStart:h,onDragEnd:S,children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(qs,{basePath:m,schema:s,onlyRenderProperties:!0})})})}),t&&x.jsx(P.ActionContextProvider,{value:w,children:x.jsx(P.RecordProvider,{record:o,parent:u,children:x.jsx(P.DeclareVariable,{name:"$nPopupRecord",title:e("Current popup record"),value:o,collection:r,children:x.jsx(qs,{basePath:v,schema:t,onlyRenderProperties:!0})})})})]})},{displayName:"KanbanCard"}),uI=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[No.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||No.uid()]:e}}}}),sI=()=>{const{designable:e}=P.useDesignable(),{render:r}=P.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(qe.Space,{size:2,align:"center",children:r()})})}):null},Xg={wrap:uI,useInsert(){const e=ee.useFieldSchema(),{t:r}=In.useTranslation(),n=P.useAPIClient(),{refresh:t}=P.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=P.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=P.useGetAriaLabelOfDesigner();return x.jsx(rc.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:P.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return P.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:P.SchemaInitializerOpenModeSchemaItems}]},Jg=new P.CompatibleSchemaInitializer(F({name:"KanbanCardInitializers"},Xg)),cI=new P.CompatibleSchemaInitializer(F({name:"kanban:configureItemFields"},Xg),Jg),dI=ee.observer(e=>e.children,{displayName:"KanbanCardViewer"}),fI=()=>{const{name:e,title:r}=P.useCollection_deprecated(),n=P.useSchemaTemplate();return x.jsx(P.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},pI=new P.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:P.SchemaSettingsBlockTitleItem},{name:"dataScope",Component:P.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=P.useCollection_deprecated(),r=ee.useFieldSchema(),{form:n}=P.useFormBlockContext(),t=ee.useField(),{service:o}=Pa(),{dn:i}=P.useDesignable();return{collectionName:e,defaultFilter:((l=(a=r==null?void 0:r["x-decorator-props"])==null?void 0:a.params)==null?void 0:l.filter)||{},form:n,onSubmit:({filter:u})=>{var f;u=P.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run($(F({},(f=o.params)==null?void 0:f[0]),{filter:u})),i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"fixedBlock",Component:P.FixedBlockDesignerItem},{name:"template",Component:P.SchemaSettingsTemplate,useComponentProps(){const{name:e}=P.useCollection_deprecated();return{componentName:"Kanban",collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),Zg={name:"kanban:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){const e=P.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]},em=new P.CompatibleSchemaInitializer(F({name:"KanbanActionInitializers"},Zg)),vI=new P.CompatibleSchemaInitializer(F({name:"kanban:configureActions"},Zg),em),rm=e=>{const{collectionName:r,groupField:n,sortField:t,dataSource:o,params:i,association:a}=e,l={type:"void","x-acl-action":`${a||r}:list`,"x-decorator":"KanbanBlockProvider","x-decorator-props":{collection:r,dataSource:o,action:"list",groupField:n,sortField:t,params:F({paginate:!1},i)},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:kanban","x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"kanban:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[No.uid()]:{type:"array","x-component":"Kanban","x-use-component-props":"useKanbanBlockProps",properties:{card:{type:"void","x-read-pretty":!0,"x-label-disabled":!0,"x-decorator":"BlockItem","x-component":"Kanban.Card","x-component-props":{openMode:"drawer"},"x-designer":"Kanban.Card.Designer",properties:{grid:{type:"void","x-component":"Grid","x-component-props":{dndContext:!1}}}},cardViewer:{type:"void",title:'{{ t("View") }}',"x-designer":"Action.Designer","x-component":"Kanban.CardViewer","x-action":"view","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("View record") }}',"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:'{{t("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:{}}}}}}}}}}}}}};return a&&(l["x-decorator-props"].association=a),l},gI=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ma(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=ee.useField(),u=P.useCompile(),s=P.useAPIClient(),{t:f}=In.useTranslation(),{theme:c}=P.useGlobalTheme(),d=D.useContext(ee.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var C;const g=v&&n.find(b=>b.name===v),y=v&&u((C=g==null?void 0:g.uiSchema)==null?void 0:C.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",y?f("Grouped sorting based on",{ns:ft})+`「${y}」`:f("Global sorting",{ns:ft}),")"]})},S=()=>hr(this,null,function*(){var y;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{name:`f_${No.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([$(F({},g.data),{value:g.data.name,label:u((y=g.data.uiSchema)==null?void 0:y.title)})]),l.value=g.data.name}),w=()=>hr(this,null,function*(){var C;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:ft}),required:!0,"x-decorator":"FormItem","x-component":"Select",enum:p.map(b=>{var E;return{value:b.name,label:u(((E=b.uiSchema)==null?void 0:E.title)||b.name)}})},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{}}),{data:g}=yield s.request({url:`dataSourcesCollections/${i}.${o}/fields:update?filterByTk=${v.field}`,method:"post",data:F({type:"sort",interface:"sort"},v)}),y=g.data;l.dataSource=l.dataSource.concat([$(F({},y),{value:y.name,label:u((C=y.uiSchema)==null?void 0:C.title)})]),l.value=y.name});return x.jsxs(qe.Space.Compact,{style:{width:"100%"},children:[x.jsx(P.Select,$(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(qe.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(qe.Button,{disabled:!t,onClick:i==="main"?S:w,children:f("Add new")})]})},nm=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=ee.useForm(),{t:l}=In.useTranslation();return x.jsx(P.APIClientProvider,{apiClient:i,children:x.jsx(P.SchemaComponentOptions,{scope:F({},o==null?void 0:o.scope),components:F({},o==null?void 0:o.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{groupField:{title:l("Grouping field"),enum:t,required:!0,description:l("Single select and radio fields can be used as the grouping field"),"x-component":"Select","x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},onChange:()=>{a.setValuesIn("dragSortBy",null)}},"x-decorator":"FormItem"},dragSortBy:{title:l("Sorting field",{ns:ft}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:ft}),"x-component":gI,"x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},sortFields:r},"x-decorator":"FormItem","x-reactions":[u=>{var s;u.dataSource=r.map(f=>{var c,d;return $(F({},f),{disabled:f.scopeKey!==((d=(c=u.form.values)==null?void 0:c.groupField)==null?void 0:d.value)})}),u.groupField=(s=u.form.values)==null?void 0:s.groupField,u.setComponentProps({dataSource:e.dataSource,collectionName:e.collectionName||e.name,collectionFields:n,sortFields:r})},{dependencies:[".groupField"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}]}}}})})})})},mI=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=P.useSchemaInitializerItem(),{createKanbanBlock:a}=tm();return x.jsx(P.DataBlockInitializer,$(F({},i),{componentType:"Calendar",icon:x.jsx(rc.FormOutlined,{}),onCreateBlockSchema:l=>hr(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},tm=()=>{const{insert:e}=P.useSchemaInitializer(),{t:r}=In.useTranslation(),{getCollectionFields:n}=P.useCollectionManager_deprecated(),t=D.useContext(ee.SchemaOptionsContext),{theme:o}=P.useGlobalTheme(),i=P.useAPIClient();return{createKanbanBlock:u=>hr(this,[u],function*({item:l}){var p,h;console.log(l);const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(S=>["select","radioGroup"].includes(S.interface)))==null?void 0:p.map(S=>{var w;return{label:(w=S==null?void 0:S.uiSchema)==null?void 0:w.title,value:S.name,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),c=(h=s==null?void 0:s.filter(S=>["sort"].includes(S.interface)))==null?void 0:h.map(S=>{var w;return{label:(w=S==null?void 0:S.uiSchema)==null?void 0:w.title,value:S.name,scopeKey:S.scopeKey,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),d=yield P.FormDialog(r("Create kanban block"),x.jsx(nm,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(rm({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function hI(){const{insert:e}=P.useSchemaInitializer(),{t:r}=In.useTranslation(),n=D.useContext(ee.SchemaOptionsContext),{theme:t}=P.useGlobalTheme(),{getCollectionFields:o}=P.useCollectionManager_deprecated(),i=P.useAPIClient();return{createAssociationKanbanBlock:u=>hr(this,[u],function*({item:l}){var h,S;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(w=>["select","radioGroup"].includes(w.interface)))==null?void 0:h.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,uiSchema:$(F({},w.uiSchema),{name:w.name})}}),d=(S=f==null?void 0:f.filter(w=>["sort"].includes(w.interface)))==null?void 0:S.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,scopeKey:w.scopeKey,uiSchema:$(F({},w.uiSchema),{name:w.name})}}),p=yield P.FormDialog(r("Create kanban block"),x.jsx(nm,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(rm({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}En.Card=lI,En.CardAdder=P.Action,En.CardViewer=dI,En.Card.Designer=sI,En.Designer=fI;const yI=En,om=D.memo(e=>x.jsx(P.SchemaComponentOptions,{components:{Kanban:En,KanbanBlockProvider:BE,KanbanV2:yI,KanbanBlockInitializer:mI},scope:{useKanbanBlockProps:FE},children:e.children}));om.displayName="KanbanPluginProvider";class SI extends P.Plugin{load(){return hr(this,null,function*(){this.app.use(om),this.app.schemaInitializerManager.add(Jg),this.app.schemaInitializerManager.add(cI),this.app.schemaInitializerManager.add(em),this.app.schemaInitializerManager.add(vI),this.app.schemaSettingsManager.add(pI);const r=this.app.schemaInitializerManager.get("page:addBlock");r==null||r.add("dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer",useComponentProps(){const{createAssociationKanbanBlock:n}=hI(),{createKanbanBlock:t}=tm();return{onlyCurrentDataSource:!0,filterCollections({associationField:o}){return o?["hasMany","belongsToMany"].includes(o.type):!1},createBlockSchema:({item:o,fromOthersInPopup:i})=>{if(i)return t({item:o});n({item:o})},showAssociationFields:!0,hideSearch:!0}}})})}}j.default=SI,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
311
+ `,qs=D.memo(ee.RecursionField);qs.displayName="MemorizedRecursionField";const lI=ee.observer(()=>{const{t:e}=iI(),r=P.useCollection(),{setDisableCardDrag:n,cardViewerSchema:t,card:o,cardField:i,columnIndex:a,cardIndex:l}=D.useContext(Hs),u=P.useCollectionParentRecordData(),s=ee.useFieldSchema(),[f,c]=D.useState(!1),d=D.useCallback(g=>{const y=g.target;g.currentTarget.contains(y)&&c(!0),g.stopPropagation()},[]),p=D.useMemo(()=>({cursor:"pointer",overflow:"hidden"}),[]),h=D.useCallback(()=>{n(!0)},[]),S=D.useCallback(()=>{n(!1)},[]),w=D.useMemo(()=>{var g,y;return{openMode:((g=s["x-component-props"])==null?void 0:g.openMode)||"drawer",openSize:(y=s["x-component-props"])==null?void 0:y.openSize,visible:f,setVisible:c}},[s,f]),m=D.useMemo(()=>i.address.concat(`${a}.cards.${l}`),[i,a,l]),v=D.useMemo(()=>i.address.concat(`${a}.cardViewer.${l}`),[i,a,l]);return x.jsxs(x.Fragment,{children:[x.jsx(qe.Card,{onClick:d,bordered:!1,hoverable:!0,style:p,className:aI,children:x.jsx(P.DndContext,{onDragStart:h,onDragEnd:S,children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(qs,{basePath:m,schema:s,onlyRenderProperties:!0})})})}),t&&x.jsx(P.ActionContextProvider,{value:w,children:x.jsx(P.RecordProvider,{record:o,parent:u,children:x.jsx(P.DeclareVariable,{name:"$nPopupRecord",title:e("Current popup record"),value:o,collection:r,children:x.jsx(qs,{basePath:v,schema:t,onlyRenderProperties:!0})})})})]})},{displayName:"KanbanCard"}),uI=e=>(e["x-read-pretty"]=!0,{type:"void","x-component":"Grid.Row",properties:{[No.uid()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||No.uid()]:e}}}}),sI=()=>{const{designable:e}=P.useDesignable(),{render:r}=P.useSchemaInitializerRender("kanban:configureItemFields");return e?x.jsx("div",{className:"general-schema-designer",children:x.jsx("div",{className:"general-schema-designer-icons",children:x.jsx(qe.Space,{size:2,align:"center",children:r()})})}):null},Xg={wrap:uI,useInsert(){const e=ee.useFieldSchema(),{t:r}=In.useTranslation(),n=P.useAPIClient(),{refresh:t}=P.useDesignable();return o=>{const i=e.reduceProperties((l,u)=>u["x-component"]==="Grid"?u:l,null);if(!i)return;const a=P.createDesignable({t:r,api:n,refresh:t,current:i});a.loadAPIClientEvents(),a.insertBeforeEnd(o)}},Component:e=>{const{getAriaLabel:r}=P.useGetAriaLabelOfDesigner();return x.jsx(rc.MenuOutlined,$(F({},e),{role:"button","aria-label":r("schema-initializer"),style:{cursor:"pointer",fontSize:12}}))},items:[{type:"itemGroup",title:'{{t("Display fields")}}',name:"displayFields",useChildren:P.useFormItemInitializerFields},{type:"itemGroup",divider:!0,title:'{{t("Display association fields")}}',name:"displayAssociationFields",hideIfNoChildren:!0,useChildren(){return P.useAssociatedFormItemInitializerFields({readPretty:!0,block:"Kanban"})}},{name:"divider",type:"divider"},{name:"openMode",Component:P.SchemaInitializerOpenModeSchemaItems}]},Jg=new P.CompatibleSchemaInitializer(F({name:"KanbanCardInitializers"},Xg)),cI=new P.CompatibleSchemaInitializer(F({name:"kanban:configureItemFields"},Xg),Jg),dI=ee.observer(e=>e.children,{displayName:"KanbanCardViewer"}),fI=()=>{const{name:e,title:r}=P.useCollection_deprecated(),n=P.useSchemaTemplate();return x.jsx(P.GeneralSchemaDesigner,{schemaSettings:"blockSettings:kanban",template:n,title:r||e})},pI=new P.SchemaSettings({name:"blockSettings:kanban",items:[{name:"title",Component:P.SchemaSettingsBlockTitleItem},{name:"dataScope",Component:P.SchemaSettingsDataScope,useComponentProps(){var a,l;const{name:e}=P.useCollection_deprecated(),r=ee.useFieldSchema(),{form:n}=P.useFormBlockContext(),t=ee.useField(),{service:o}=Pa(),{dn:i}=P.useDesignable();return{collectionName:e,defaultFilter:((l=(a=r==null?void 0:r["x-decorator-props"])==null?void 0:a.params)==null?void 0:l.filter)||{},form:n,onSubmit:({filter:u})=>{var f;u=P.removeNullCondition(u);const s=t.decoratorProps.params||{};s.filter=u,t.decoratorProps.params=s,r["x-decorator-props"].params=s,o.run($(F({},(f=o.params)==null?void 0:f[0]),{filter:u})),i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"fixedBlock",Component:P.FixedBlockDesignerItem},{name:"template",Component:P.SchemaSettingsTemplate,useComponentProps(){const{name:e}=P.useCollection_deprecated();return{componentName:"Kanban",collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),Zg={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){const e=P.useCollection_deprecated();return e.template!=="view"||(e==null?void 0:e.writableView)}}]},em=new P.CompatibleSchemaInitializer(F({name:"KanbanActionInitializers"},Zg)),vI=new P.CompatibleSchemaInitializer(F({name:"kanban:configureActions"},Zg),em),rm=e=>{const{collectionName:r,groupField:n,sortField:t,dataSource:o,params:i,association:a}=e,l={type:"void","x-acl-action":`${a||r}:list`,"x-decorator":"KanbanBlockProvider","x-decorator-props":{collection:r,dataSource:o,action:"list",groupField:n,sortField:t,params:F({paginate:!1},i)},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:kanban","x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"kanban:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[No.uid()]:{type:"array","x-component":"Kanban","x-use-component-props":"useKanbanBlockProps",properties:{card:{type:"void","x-read-pretty":!0,"x-label-disabled":!0,"x-decorator":"BlockItem","x-component":"Kanban.Card","x-component-props":{openMode:"drawer"},"x-designer":"Kanban.Card.Designer",properties:{grid:{type:"void","x-component":"Grid","x-component-props":{dndContext:!1}}}},cardViewer:{type:"void",title:'{{ t("View") }}',"x-designer":"Action.Designer","x-component":"Kanban.CardViewer","x-action":"view","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:'{{ t("View record") }}',"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:'{{t("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:{}}}}}}}}}}}}}};return a&&(l["x-decorator-props"].association=a),l},gI=e=>{const m=e,{sortFields:r,collectionFields:n,groupField:t,collectionName:o,dataSource:i}=m,a=Ma(m,["sortFields","collectionFields","groupField","collectionName","dataSource"]),l=ee.useField(),u=P.useCompile(),s=P.useAPIClient(),{t:f}=In.useTranslation(),{theme:c}=P.useGlobalTheme(),d=D.useContext(ee.SchemaOptionsContext),p=n==null?void 0:n.filter(v=>v.interface==="integer"),h=({scopeKey:v})=>{var C;const g=v&&n.find(b=>b.name===v),y=v&&u((C=g==null?void 0:g.uiSchema)==null?void 0:C.title);return x.jsxs("span",{style:{color:"rgba(0, 0, 0, 0.25)"},children:["(",y?f("Grouped sorting based on",{ns:ft})+`「${y}」`:f("Global sorting",{ns:ft}),")"]})},S=()=>hr(this,null,function*(){var y;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{name:`f_${No.uid()}`}}),{data:g}=yield s.resource("collections.fields",o).create({values:F({type:"sort",interface:"sort"},v)});l.dataSource=l.dataSource.concat([$(F({},g.data),{value:g.data.name,label:u((y=g.data.uiSchema)==null?void 0:y.title)})]),l.value=g.data.name}),w=()=>hr(this,null,function*(){var C;const v=yield P.FormDialog(f("Create sort field"),()=>x.jsx(P.SchemaComponentOptions,{scope:d.scope,components:F({},d.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{field:{type:"string",title:f("Convert the following integer fields to sorting fields",{ns:ft}),required:!0,"x-decorator":"FormItem","x-component":"Select",enum:p.map(b=>{var E;return{value:b.name,label:u(((E=b.uiSchema)==null?void 0:E.title)||b.name)}})},scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',default:t.value,"x-disabled":!0,"x-decorator":"FormItem","x-component":"Select",enum:[t]}}}})})}),c).open({initialValues:{}}),{data:g}=yield s.request({url:`dataSourcesCollections/${i}.${o}/fields:update?filterByTk=${v.field}`,method:"post",data:F({type:"sort",interface:"sort"},v)}),y=g.data;l.dataSource=l.dataSource.concat([$(F({},y),{value:y.name,label:u((C=y.uiSchema)==null?void 0:C.title)})]),l.value=y.name});return x.jsxs(qe.Space.Compact,{style:{width:"100%"},children:[x.jsx(P.Select,$(F({options:r},a),{disabled:!t,optionRender:({label:v,data:g})=>x.jsxs(qe.Space,{children:[x.jsx("span",{children:v}),x.jsx(h,{scopeKey:g.scopeKey})]})})),x.jsx(qe.Button,{disabled:!t,onClick:i==="main"?S:w,children:f("Add new")})]})},nm=({item:e,sortFields:r,collectionFields:n,fields:t,options:o,api:i})=>{const a=ee.useForm(),{t:l}=In.useTranslation();return x.jsx(P.APIClientProvider,{apiClient:i,children:x.jsx(P.SchemaComponentOptions,{scope:F({},o==null?void 0:o.scope),components:F({},o==null?void 0:o.components),children:x.jsx(Fr.FormLayout,{layout:"vertical",children:x.jsx(P.SchemaComponent,{schema:{properties:{groupField:{title:l("Grouping field"),enum:t,required:!0,description:l("Single select and radio fields can be used as the grouping field"),"x-component":"Select","x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},onChange:()=>{a.setValuesIn("dragSortBy",null)}},"x-decorator":"FormItem"},dragSortBy:{title:l("Sorting field",{ns:ft}),required:!0,description:l("Used for sorting kanban cards, only sorting fields corresponding to grouping fields can be selected",{ns:ft}),"x-component":gI,"x-component-props":{objectValue:!0,fieldNames:{label:"label",value:"value"},sortFields:r},"x-decorator":"FormItem","x-reactions":[u=>{var s;u.dataSource=r.map(f=>{var c,d;return $(F({},f),{disabled:f.scopeKey!==((d=(c=u.form.values)==null?void 0:c.groupField)==null?void 0:d.value)})}),u.groupField=(s=u.form.values)==null?void 0:s.groupField,u.setComponentProps({dataSource:e.dataSource,collectionName:e.collectionName||e.name,collectionFields:n,sortFields:r})},{dependencies:[".groupField"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}]}}}})})})})},mI=({filterCollections:e,onlyCurrentDataSource:r,hideSearch:n,createBlockSchema:t,showAssociationFields:o})=>{const i=P.useSchemaInitializerItem(),{createKanbanBlock:a}=tm();return x.jsx(P.DataBlockInitializer,$(F({},i),{componentType:"Calendar",icon:x.jsx(rc.FormOutlined,{}),onCreateBlockSchema:l=>hr(this,null,function*(){if(t)return t(l);a(l)}),onlyCurrentDataSource:r,hideSearch:n,filter:e,showAssociationFields:o}))},tm=()=>{const{insert:e}=P.useSchemaInitializer(),{t:r}=In.useTranslation(),{getCollectionFields:n}=P.useCollectionManager_deprecated(),t=D.useContext(ee.SchemaOptionsContext),{theme:o}=P.useGlobalTheme(),i=P.useAPIClient();return{createKanbanBlock:u=>hr(this,[u],function*({item:l}){var p,h;console.log(l);const s=n(l.name,l.dataSource),f=(p=s==null?void 0:s.filter(S=>["select","radioGroup"].includes(S.interface)))==null?void 0:p.map(S=>{var w;return{label:(w=S==null?void 0:S.uiSchema)==null?void 0:w.title,value:S.name,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),c=(h=s==null?void 0:s.filter(S=>["sort"].includes(S.interface)))==null?void 0:h.map(S=>{var w;return{label:(w=S==null?void 0:S.uiSchema)==null?void 0:w.title,value:S.name,scopeKey:S.scopeKey,uiSchema:$(F({},S.uiSchema),{name:S.name})}}),d=yield P.FormDialog(r("Create kanban block"),x.jsx(nm,{item:l,sortFields:c,collectionFields:s,fields:f,options:t,api:i}),o).open({initialValues:{}});e(rm({sortField:d.dragSortBy,groupField:d.groupField.value,collectionName:l.name,dataSource:l.dataSource,params:{sort:[d.dragSortBy]}}))})}};function hI(){const{insert:e}=P.useSchemaInitializer(),{t:r}=In.useTranslation(),n=D.useContext(ee.SchemaOptionsContext),{theme:t}=P.useGlobalTheme(),{getCollectionFields:o}=P.useCollectionManager_deprecated(),i=P.useAPIClient();return{createAssociationKanbanBlock:u=>hr(this,[u],function*({item:l}){var h,S;console.log(l);const s=l.associationField,f=o(l.name,l.dataSource),c=(h=f==null?void 0:f.filter(w=>["select","radioGroup"].includes(w.interface)))==null?void 0:h.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,uiSchema:$(F({},w.uiSchema),{name:w.name})}}),d=(S=f==null?void 0:f.filter(w=>["sort"].includes(w.interface)))==null?void 0:S.map(w=>{var m;return{label:(m=w==null?void 0:w.uiSchema)==null?void 0:m.title,value:w.name,scopeKey:w.scopeKey,uiSchema:$(F({},w.uiSchema),{name:w.name})}}),p=yield P.FormDialog(r("Create kanban block"),x.jsx(nm,{item:l,sortFields:d,collectionFields:f,fields:c,options:n,api:i}),t).open({initialValues:{}});e(rm({sortField:p.dragSortBy,groupField:p.groupField.value,association:`${s.collectionName}.${s.name}`,dataSource:l.dataSource,params:{sort:[p.dragSortBy]}}))})}}En.Card=lI,En.CardAdder=P.Action,En.CardViewer=dI,En.Card.Designer=sI,En.Designer=fI;const yI=En,om=D.memo(e=>x.jsx(P.SchemaComponentOptions,{components:{Kanban:En,KanbanBlockProvider:BE,KanbanV2:yI,KanbanBlockInitializer:mI},scope:{useKanbanBlockProps:FE},children:e.children}));om.displayName="KanbanPluginProvider";class SI extends P.Plugin{load(){return hr(this,null,function*(){this.app.use(om),this.app.schemaInitializerManager.add(Jg),this.app.schemaInitializerManager.add(cI),this.app.schemaInitializerManager.add(em),this.app.schemaInitializerManager.add(vI),this.app.schemaSettingsManager.add(pI);const r=this.app.schemaInitializerManager.get("page:addBlock");r==null||r.add("dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer"}),this.app.schemaInitializerManager.addItem("popup:common:addBlock","dataBlocks.kanban",{title:'{{t("Kanban")}}',Component:"KanbanBlockInitializer",useComponentProps(){const{createAssociationKanbanBlock:n}=hI(),{createKanbanBlock:t}=tm();return{onlyCurrentDataSource:!0,filterCollections({associationField:o}){return o?["hasMany","belongsToMany"].includes(o.type):!1},createBlockSchema:({item:o,fromOthersInPopup:i})=>{if(i)return t({item:o});n({item:o})},showAssociationFields:!0,hideSearch:!0}}})})}}j.default=SI,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -11,7 +11,7 @@ module.exports = {
11
11
  "@ant-design/icons": "5.2.6",
12
12
  "@formily/react": "2.3.0",
13
13
  "@formily/shared": "2.3.0",
14
- "@nocobase/client": "1.0.0-alpha.15",
14
+ "@nocobase/client": "1.0.0-alpha.17",
15
15
  "antd": "5.12.8",
16
16
  "react": "18.2.0",
17
17
  "react-i18next": "11.18.6",
@@ -19,7 +19,7 @@ module.exports = {
19
19
  "@formily/antd-v5": "1.1.9",
20
20
  "@formily/core": "2.3.0",
21
21
  "lodash": "4.17.21",
22
- "@nocobase/server": "1.0.0-alpha.15",
23
- "@nocobase/test": "1.0.0-alpha.15",
22
+ "@nocobase/server": "1.0.0-alpha.17",
23
+ "@nocobase/test": "1.0.0-alpha.17",
24
24
  "antd-style": "3.4.5"
25
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-kanban",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.17",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/block-kanban",
6
6
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/block-kanban",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "react-intersection-observer": "^9.8.1"
19
19
  },
20
- "gitHead": "2793d371368e094ea2bba04cfbe9b9b73c44edba",
20
+ "gitHead": "a38719a9d25efc14e06e979209ff5085e049aca7",
21
21
  "keywords": [
22
22
  "Blocks"
23
23
  ]