@nocobase/plugin-action-duplicate 0.20.0-alpha.8 → 0.21.0-alpha.1
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.
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/client';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class PluginActionDuplicateClient extends Plugin {
|
|
3
3
|
load(): Promise<void>;
|
|
4
4
|
}
|
|
5
|
-
export default
|
|
5
|
+
export default PluginActionDuplicateClient;
|
|
6
6
|
export * from './DuplicateAction';
|
package/dist/client/index.js
CHANGED
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
left: -10px;
|
|
44
44
|
right: -10px;
|
|
45
45
|
}
|
|
46
|
-
`]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:f(x({},ue),{duplicateData:{display:!1,enabled:!0,defaultTemplate:W}}),children:i.jsxs("div",{children:[X?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")}):i.jsx(I.Button,f(x({role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:l||N,children:i.jsx(e.RecordProvider,{record:f(x({},g),{__collection:l||y}),parent:a,children:i.jsx(e.ActionContextProvider,{value:f(x({},V),{visible:T,setVisible:v}),children:i.jsx(r.RecursionField,{schema:d,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=r.connect(I.Tree,r.mapProps((t,c)=>{k.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=k.useState(t.defaultCheckedKeys||[]),d=u=>{n(u),c.value=u};c.onCheck=d;const D=r.useForm();return f(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var S;if(D.values.duplicateMode==="quickDulicate"){const T=(S=u==null?void 0:u.children)==null?void 0:S.map(v=>f(x({},v),{disabled:!1}));return f(x({},u),{disabled:!1,children:T})}return u})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:d}=s,D=ce(s,["children"]);c.push(D.key),d&&G(d,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var B,b,L;const{dn:t}=e.useDesignable(),{t:c}=F.useTranslation(),s=r.useField(),n=r.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:D,getEnableFieldTree:u,getOnLoadData:S,getOnCheck:T}=e.useCollectionState(d),v=M.cloneDeep(n["x-component-props"].duplicateFields||[]),m=e.useRecord(),z=k.useCallback((l,g,a)=>{a.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=g,h.setInitialValue(g),h==null||h.onCheck(g),a.setValues(f(x({},a.values),{treeData:l}))})},[]),A=l=>({run(){return w(this,null,function*(){l.query("duplicateFields").take(a=>{var y;const h=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=h,a.setInitialValue(h),(y=a==null?void 0:a.onCheck)==null||y.call(a,h)})})}}),_=l=>({run(){return w(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:R},scope:{getEnableFieldTree:u,collectionName:((B=n["x-component-props"])==null?void 0:B.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:S,getOnCheck:T,treeData:(b=n["x-component-props"])==null?void 0:b.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=n["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":D.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:D},"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 g;const l=k.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((g=n["x-component-props"])==null?void 0:g.duplicateCollection)||(m==null?void 0:m.__collection)||d,z)}},"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=r.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=r.useForm();return _(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":R,"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:g,duplicateFields:a,treeData:h})=>{var V;const y=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=y,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=y,n["x-component-props"].duplicateCollection=g,n["x-component-props"].treeData=h||((V=s.componentProps)==null?void 0:V.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n["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 f(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return r.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=r.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}}]}],se=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),le=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":"TabPaneInitializers",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":"
|
|
46
|
+
`]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:f(x({},ue),{duplicateData:{display:!1,enabled:!0,defaultTemplate:W}}),children:i.jsxs("div",{children:[X?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")}):i.jsx(I.Button,f(x({role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:l||N,children:i.jsx(e.RecordProvider,{record:f(x({},g),{__collection:l||y}),parent:a,children:i.jsx(e.ActionContextProvider,{value:f(x({},V),{visible:T,setVisible:v}),children:i.jsx(r.RecursionField,{schema:d,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=r.connect(I.Tree,r.mapProps((t,c)=>{k.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=k.useState(t.defaultCheckedKeys||[]),d=u=>{n(u),c.value=u};c.onCheck=d;const D=r.useForm();return f(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var S;if(D.values.duplicateMode==="quickDulicate"){const T=(S=u==null?void 0:u.children)==null?void 0:S.map(v=>f(x({},v),{disabled:!1}));return f(x({},u),{disabled:!1,children:T})}return u})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:d}=s,D=ce(s,["children"]);c.push(D.key),d&&G(d,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var B,b,L;const{dn:t}=e.useDesignable(),{t:c}=F.useTranslation(),s=r.useField(),n=r.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:D,getEnableFieldTree:u,getOnLoadData:S,getOnCheck:T}=e.useCollectionState(d),v=M.cloneDeep(n["x-component-props"].duplicateFields||[]),m=e.useRecord(),z=k.useCallback((l,g,a)=>{a.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=g,h.setInitialValue(g),h==null||h.onCheck(g),a.setValues(f(x({},a.values),{treeData:l}))})},[]),A=l=>({run(){return w(this,null,function*(){l.query("duplicateFields").take(a=>{var y;const h=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=h,a.setInitialValue(h),(y=a==null?void 0:a.onCheck)==null||y.call(a,h)})})}}),_=l=>({run(){return w(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:R},scope:{getEnableFieldTree:u,collectionName:((B=n["x-component-props"])==null?void 0:B.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:S,getOnCheck:T,treeData:(b=n["x-component-props"])==null?void 0:b.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=n["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":D.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:D},"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 g;const l=k.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((g=n["x-component-props"])==null?void 0:g.duplicateCollection)||(m==null?void 0:m.__collection)||d,z)}},"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=r.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=r.useForm();return _(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":R,"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:g,duplicateFields:a,treeData:h})=>{var V;const y=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=y,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=y,n["x-component-props"].duplicateCollection=g,n["x-component-props"].treeData=h||((V=s.componentProps)==null?void 0:V.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n["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 f(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return r.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=r.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}}]}],se=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),le=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":"TabPaneInitializers",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,f(x({},t),{schema:c}))},re=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:Q,DuplicateAction:K},children:t.children});class J extends e.Plugin{load(){return w(this,null,function*(){this.app.use(re),this.app.addComponents({DuplicateActionInitializer:Q,DuplicateAction:K}),this.app.schemaSettingsManager.add(se),this.app.schemaSettingsManager.add(le);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)})}}o.DuplicateAction=K,o.PluginActionDuplicateClient=J,o.actionDesignerCss=E,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"@formily/core": "2.3.0",
|
|
3
3
|
"@formily/react": "2.3.0",
|
|
4
|
-
"@nocobase/client": "0.
|
|
4
|
+
"@nocobase/client": "0.21.0-alpha.1",
|
|
5
5
|
"antd": "5.12.8",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"react": "18.2.0",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
9
|
"@emotion/css": "11.11.2",
|
|
10
|
-
"@nocobase/server": "0.
|
|
11
|
-
"@nocobase/test": "0.
|
|
10
|
+
"@nocobase/server": "0.21.0-alpha.1",
|
|
11
|
+
"@nocobase/test": "0.21.0-alpha.1"
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-action-duplicate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-alpha.1",
|
|
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": "0.x",
|
|
15
15
|
"@nocobase/test": "0.x"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff",
|
|
18
18
|
"keywords": [
|
|
19
19
|
"Actions"
|
|
20
20
|
]
|