@nocobase/plugin-action-duplicate 1.0.0-alpha.9 → 1.0.1-alpha.2

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.
@@ -52,4 +52,4 @@
52
52
  left: -10px;
53
53
  right: -10px;
54
54
  }
55
- `]:Y}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},he),{duplicateData:{display:!1,enabled:!0,defaultTemplate:X}}),children:i.jsxs("div",{children:[Y?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:m,style:x({opacity:D&&((te=o==null?void 0:o.data)==null?void 0:te.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},xe),onClick:Z,children:h?q("Duplicating"):c||q("Duplicate")}):i.jsx(I.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:D&&((oe=o==null?void 0:o.data)==null?void 0:oe.hidden)&&.1}},t),{onClick:Z,children:h?q("Duplicating"):c||q("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:L||F,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:L||r}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},P),{visible:_,setVisible:v}),children:i.jsx(p.RecursionField,{schema:u,basePath:o.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),$=p.connect(I.Tree,p.mapProps((t,c)=>{y.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,o]=y.useState(t.defaultCheckedKeys||[]),u=m=>{o(m),c.value=m};c.onCheck=u;const b=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var D;if(b.values.duplicateMode==="quickDulicate"){const _=(D=m==null?void 0:m.children)==null?void 0:D.map(v=>g(x({},v),{disabled:!1}));return g(x({},m),{disabled:!1,children:_})}return m})})})),G=(t,c)=>{for(let o=0;o<(t==null?void 0:t.length);o++){const s=t[o],{children:u}=s,b=se(s,["children"]);c.push(b.key),u&&G(u,c)}return c},H=t=>t.reduceProperties((s,o)=>o["x-decorator"]==="FormBlockProvider"?o:H(o),null);function le(){var V,k,N,L;const{dn:t}=e.useDesignable(),{t:c}=M.useTranslation(),s=p.useField(),o=p.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:b,getEnableFieldTree:m,getOnLoadData:D,getOnCheck:_}=e.useCollectionState(u),v=T.cloneDeep(((V=o["x-component-props"])==null?void 0:V.duplicateFields)||[]),h=e.useRecord(),w=y.useCallback((l,f,a)=>{a.query("duplicateFields").take(r=>{r.componentProps.treeData=l,r.componentProps.defaultCheckedKeys=f,r.setInitialValue(f),r==null||r.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),A=l=>({run(){return B(this,null,function*(){l.query("duplicateFields").take(a=>{var P;const r=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=r,a.setInitialValue(r),(P=a==null?void 0:a.onCheck)==null||P.call(a,r)})})}}),z=l=>({run(){return B(this,null,function*(){l.query("duplicateFields").take(a=>{a.componentProps.defaultCheckedKeys=[],a.setInitialValue([]),a==null||a.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:c("Duplicate mode"),components:{Tree:$},scope:{getEnableFieldTree:m,collectionName:((k=o["x-component-props"])==null?void 0:k.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:D,getOnCheck:_,treeData:(N=o["x-component-props"])==null?void 0:N.treeData,duplicateValues:v,onFieldInputValueChange:C.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((L=o["x-component-props"])==null?void 0:L.duplicateMode)||"quickDulicate",enum:[{value:"quickDulicate",label:'{{t("Direct duplicate")}}'},{value:"continueduplicate",label:'{{t("Copy into the form and continue to fill in")}}'}]},collection:{type:"string",title:'{{ t("Target collection") }}',required:!0,description:c("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":b.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:b},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{disabled:'{{ $deps[0]==="quickDulicate" }}',value:'{{ $deps[0]==="quickDulicate"? currentCollection:collectionName }}'}}}]},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{var f;const l=y.useMemo(()=>H(o),[o]);return e.useSyncFromForm(l,((f=o["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||u,w)}},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]!=="quickDulicate" }}'}}}]},selectAll:{type:"void",title:'{{ t("Select all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]==="quickDulicate"}}'}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{const l=p.useForm();return A(l)}}},unselectAll:{type:"void",title:'{{ t("UnSelect all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode",".duplicateFields"],fulfill:{state:{visible:`{{ $deps[0]==="quickDulicate"&&$form.getValuesIn('duplicateFields').length>0 }}`}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200,marginRight:"10px"},useAction:()=>{const l=p.useForm();return z(l)}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:c("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":$,"x-component-props":{defaultCheckedKeys:v,treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection",".duplicateMode"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self,treeData) }}"}}}}]}}},onSubmit:({duplicateMode:l,collection:f,duplicateFields:a,treeData:r})=>{var F;const P=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=P,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].duplicateMode=l,o["x-component-props"].duplicateFields=P,o["x-component-props"].duplicateCollection=f,o["x-component-props"].treeData=r||((F=s.componentProps)==null?void 0:F.treeData),t.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),t.refresh()}})}const U=[{name:"Customize",Component:t=>t.children,children:[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=e.useSchemaToolbar();return t}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps(){const{name:t}=e.useCollection_deprecated(),{linkageRulesProps:c}=e.useSchemaToolbar();return g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:le,useVisible(){return p.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=p.useFieldSchema(),c=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:c,openSize:c}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}]}],re=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),pe=new e.SchemaSettings({name:"actionSettings:duplicate",items:U}),Q=t=>{const c={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"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("Duplicate")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializer,g(x({},t),{schema:c}))},de=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:Q,DuplicateAction:K},children:t.children});class J extends e.Plugin{load(){return B(this,null,function*(){this.app.use(de),this.app.addComponents({DuplicateActionInitializer:Q,DuplicateAction:K}),this.app.schemaSettingsManager.add(re),this.app.schemaSettingsManager.add(pe);const c={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const s=e.useCollection_deprecated();return(s.template!=="view"||(s==null?void 0:s.writableView))&&s.template!=="file"&&s.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureItemActions","actions.duplicate",c)})}}n.DuplicateAction=K,n.PluginActionDuplicateClient=J,n.actionDesignerCss=R,n.default=J,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
55
+ `]:Y}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},he),{duplicateData:{display:!1,enabled:!0,defaultTemplate:X}}),children:i.jsxs("div",{children:[Y?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:m,style:x({opacity:D&&((te=o==null?void 0:o.data)==null?void 0:te.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},xe),onClick:Z,children:h?q("Duplicating"):c||q("Duplicate")}):i.jsx(I.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:D&&((oe=o==null?void 0:o.data)==null?void 0:oe.hidden)&&.1}},t),{onClick:Z,children:h?q("Duplicating"):c||q("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:L||F,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:L||r}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},P),{visible:_,setVisible:v}),children:i.jsx(p.RecursionField,{schema:u,basePath:o.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),$=p.connect(I.Tree,p.mapProps((t,c)=>{y.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,o]=y.useState(t.defaultCheckedKeys||[]),u=m=>{o(m),c.value=m};c.onCheck=u;const b=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var D;if(b.values.duplicateMode==="quickDulicate"){const _=(D=m==null?void 0:m.children)==null?void 0:D.map(v=>g(x({},v),{disabled:!1}));return g(x({},m),{disabled:!1,children:_})}return m})})})),G=(t,c)=>{for(let o=0;o<(t==null?void 0:t.length);o++){const s=t[o],{children:u}=s,b=se(s,["children"]);c.push(b.key),u&&G(u,c)}return c},H=t=>t.reduceProperties((s,o)=>o["x-decorator"]==="FormBlockProvider"?o:H(o),null);function le(){var V,k,N,L;const{dn:t}=e.useDesignable(),{t:c}=M.useTranslation(),s=p.useField(),o=p.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:b,getEnableFieldTree:m,getOnLoadData:D,getOnCheck:_}=e.useCollectionState(u),v=T.cloneDeep(((V=o["x-component-props"])==null?void 0:V.duplicateFields)||[]),h=e.useRecord(),w=y.useCallback((l,f,a)=>{a.query("duplicateFields").take(r=>{r.componentProps.treeData=l,r.componentProps.defaultCheckedKeys=f,r.setInitialValue(f),r==null||r.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),A=l=>({run(){return B(this,null,function*(){l.query("duplicateFields").take(a=>{var P;const r=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=r,a.setInitialValue(r),(P=a==null?void 0:a.onCheck)==null||P.call(a,r)})})}}),z=l=>({run(){return B(this,null,function*(){l.query("duplicateFields").take(a=>{a.componentProps.defaultCheckedKeys=[],a.setInitialValue([]),a==null||a.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:c("Duplicate mode"),components:{Tree:$},scope:{getEnableFieldTree:m,collectionName:((k=o["x-component-props"])==null?void 0:k.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:D,getOnCheck:_,treeData:(N=o["x-component-props"])==null?void 0:N.treeData,duplicateValues:v,onFieldInputValueChange:C.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((L=o["x-component-props"])==null?void 0:L.duplicateMode)||"quickDulicate",enum:[{value:"quickDulicate",label:'{{t("Direct duplicate")}}'},{value:"continueduplicate",label:'{{t("Copy into the form and continue to fill in")}}'}]},collection:{type:"string",title:'{{ t("Target collection") }}',required:!0,description:c("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":b.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:b},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{disabled:'{{ $deps[0]==="quickDulicate" }}',value:'{{ $deps[0]==="quickDulicate"? currentCollection:collectionName }}'}}}]},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{var f;const l=y.useMemo(()=>H(o),[o]);return e.useSyncFromForm(l,((f=o["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||u,w)}},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]!=="quickDulicate" }}'}}}]},selectAll:{type:"void",title:'{{ t("Select all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]==="quickDulicate"}}'}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{const l=p.useForm();return A(l)}}},unselectAll:{type:"void",title:'{{ t("UnSelect all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode",".duplicateFields"],fulfill:{state:{visible:`{{ $deps[0]==="quickDulicate"&&$form.getValuesIn('duplicateFields').length>0 }}`}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200,marginRight:"10px"},useAction:()=>{const l=p.useForm();return z(l)}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:c("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":$,"x-component-props":{defaultCheckedKeys:v,treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection",".duplicateMode"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self,treeData) }}"}}}}]}}},onSubmit:({duplicateMode:l,collection:f,duplicateFields:a,treeData:r})=>{var F;const P=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=P,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].duplicateMode=l,o["x-component-props"].duplicateFields=P,o["x-component-props"].duplicateCollection=f,o["x-component-props"].treeData=r||((F=s.componentProps)==null?void 0:F.treeData),t.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),t.refresh()}})}const U=[{name:"Customize",Component:t=>t.children,children:[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=e.useSchemaToolbar();return t}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps(){const{name:t}=e.useCollection_deprecated(),{linkageRulesProps:c}=e.useSchemaToolbar();return g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:le,useVisible(){return p.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=p.useFieldSchema(),c=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:c,openSize:c}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}]}],re=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),pe=new e.SchemaSettings({name:"actionSettings:duplicate",items:U}),Q=t=>{const c={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"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("Duplicate")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializerItem,g(x({},t),{schema:c}))},de=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:Q,DuplicateAction:K},children:t.children});class J extends e.Plugin{load(){return B(this,null,function*(){this.app.use(de),this.app.addComponents({DuplicateActionInitializer:Q,DuplicateAction:K}),this.app.schemaSettingsManager.add(re),this.app.schemaSettingsManager.add(pe);const c={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const s=e.useCollection_deprecated();return(s.template!=="view"||(s==null?void 0:s.writableView))&&s.template!=="file"&&s.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureItemActions","actions.duplicate",c)})}}n.DuplicateAction=K,n.PluginActionDuplicateClient=J,n.actionDesignerCss=R,n.default=J,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -10,12 +10,12 @@
10
10
  module.exports = {
11
11
  "@formily/core": "2.3.0",
12
12
  "@formily/react": "2.3.0",
13
- "@nocobase/client": "1.0.0-alpha.9",
13
+ "@nocobase/client": "1.0.1-alpha.2",
14
14
  "antd": "5.12.8",
15
15
  "lodash": "4.17.21",
16
16
  "react": "18.2.0",
17
17
  "react-i18next": "11.18.6",
18
18
  "@emotion/css": "11.11.2",
19
- "@nocobase/server": "1.0.0-alpha.9",
20
- "@nocobase/test": "1.0.0-alpha.9"
19
+ "@nocobase/server": "1.0.1-alpha.2",
20
+ "@nocobase/test": "1.0.1-alpha.2"
21
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-action-duplicate",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.1-alpha.2",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/action-duplicate",
6
6
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-duplicate",
@@ -14,7 +14,7 @@
14
14
  "@nocobase/server": "1.x",
15
15
  "@nocobase/test": "1.x"
16
16
  },
17
- "gitHead": "562d6ae965317098df05db756d160e03363dcec5",
17
+ "gitHead": "fc5a8e3c812516f787cb22d3d198f058f45b1963",
18
18
  "keywords": [
19
19
  "Actions"
20
20
  ]