@nocobase/plugin-action-duplicate 1.2.2-alpha → 1.2.4-alpha

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.
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@emotion/css"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@emotion/css","@formily/react","antd","react","react-i18next","@formily/core","lodash"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-action-duplicate"]={},n["@nocobase/client"],n.jsxRuntime,n["@emotion/css"],n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/core"],n.lodash))})(this,function(n,e,i,d,p,I,y,M,C,T){"use strict";var fe=Object.defineProperty,ye=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var ie=(n,e,i)=>e in n?fe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,x=(n,e)=>{for(var i in e||(e={}))ce.call(e,i)&&ie(n,i,e[i]);if(j)for(var i of j(e))ae.call(e,i)&&ie(n,i,e[i]);return n},g=(n,e)=>ye(n,Ce(e));var se=(n,e)=>{var i={};for(var d in n)ce.call(n,d)&&e.indexOf(d)<0&&(i[d]=n[d]);if(n!=null&&j)for(var d of j(n))e.indexOf(d)<0&&ae.call(n,d)&&(i[d]=n[d]);return i};var B=(n,e,i)=>new Promise((d,p)=>{var I=C=>{try{M(i.next(C))}catch(T){p(T)}},y=C=>{try{M(i.throw(C))}catch(T){p(T)}},M=C=>C.done?d(C.value):Promise.resolve(C.value).then(I,y);M((i=i.apply(n,e)).next())});const R=d.css`
10
+ (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@emotion/css"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@emotion/css","@formily/react","antd","react","react-i18next","@formily/core","lodash"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-action-duplicate"]={},n["@nocobase/client"],n.jsxRuntime,n["@emotion/css"],n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/core"],n.lodash))})(this,function(n,e,i,p,r,M,y,q,C,I){"use strict";var ye=Object.defineProperty,Ce=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ce=(n,e,i)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,x=(n,e)=>{for(var i in e||(e={}))ae.call(e,i)&&ce(n,i,e[i]);if(j)for(var i of j(e))se.call(e,i)&&ce(n,i,e[i]);return n},g=(n,e)=>Ce(n,be(e));var le=(n,e)=>{var i={};for(var p in n)ae.call(n,p)&&e.indexOf(p)<0&&(i[p]=n[p]);if(n!=null&&j)for(var p of j(n))e.indexOf(p)<0&&se.call(n,p)&&(i[p]=n[p]);return i};var z=(n,e,i)=>new Promise((p,r)=>{var M=C=>{try{q(i.next(C))}catch(I){r(I)}},y=C=>{try{q(i.throw(C))}catch(I){r(I)}},q=C=>C.done?p(C.value):Promise.resolve(C.value).then(M,y);q((i=i.apply(n,e)).next())});const $=p.css`
11
11
  position: relative;
12
12
  &:hover {
13
13
  .general-schema-designer {
@@ -45,11 +45,11 @@
45
45
  }
46
46
  }
47
47
  }
48
- `,K=p.observer(t=>{var ee,te,oe;const{children:c}=t,{message:s}=I.App.useApp(),o=p.useField(),u=p.useFieldSchema(),b=e.useAPIClient(),m=o.disabled||t.disabled,{designable:D}=e.useDesignable(),[_,v]=y.useState(!1),[h,w]=y.useState(!1),{service:A,__parent:z,block:V}=e.useBlockRequestContext(),{duplicateFields:k,duplicateMode:N="quickDulicate",duplicateCollection:L}=u["x-component-props"],l=e.useRecord(),f=e.useCollectionParentRecordData(),{id:a,__collection:r}=l,P=e.useActionContext(),{name:F}=e.useCollection_deprecated(),{getCollectionFields:ue}=e.useCollectionManager_deprecated(),{t:q}=M.useTranslation(),me=ue(r||F),he=e.useFormBlockContext(),W=e.useACLActionParamsContext(),xe=y.useMemo(()=>{var S;return{opacity:D&&(((S=o==null?void 0:o.data)==null?void 0:S.hidden)||!W)&&.1}},[D,(ee=o==null?void 0:o.data)==null?void 0:ee.hidden]),X={key:"duplicate",dataId:a,default:!0,fields:(k==null?void 0:k.filter(S=>me.find(O=>S.includes(O.name))))||[],collection:r||F},Y=u["x-component"]==="Action.Link",ge=()=>B(this,null,function*(){var S,O,ne;w(!0);try{const E=yield e.fetchTemplateData(b,X,q);yield b.resource(r||F).create({values:x({},E)}),s.success(q("Saved successfully")),V==="form"?(O=(S=z==null?void 0:z.service)==null?void 0:S.refresh)==null||O.call(S):yield(ne=A==null?void 0:A.refresh)==null?void 0:ne.call(A),w(!1)}catch(E){w(!1),console.error(E)}}),Z=()=>{!m&&!h&&W&&((k==null?void 0:k.length)>0?N==="quickDulicate"?ge():v(!0):s.error(q("Please configure the duplicate fields")))};return i.jsx("div",{className:d.cx(R,{[d.css`
48
+ `,K=r.observer(t=>{var te,oe,ne;const{children:c}=t,{message:s}=M.App.useApp(),o=r.useField(),d=r.useFieldSchema(),v=e.useAPIClient(),u=o.disabled||t.disabled,{designable:b}=e.useDesignable(),[T,A]=y.useState(!1),[m,_]=y.useState(!1),{service:P,__parent:w,block:L,resource:B}=e.useBlockRequestContext(),{duplicateFields:D,duplicateMode:V="quickDulicate",duplicateCollection:l}=d["x-component-props"],f=e.useRecord(),a=e.useCollectionParentRecordData(),{id:h,__collection:k}=f,N=e.useActionContext(),{name:E}=e.useCollection_deprecated(),{getCollectionFields:me}=e.useCollectionManager_deprecated(),{t:F}=q.useTranslation(),he=me(k||E),xe=e.useFormBlockContext(),X=e.useACLActionParamsContext(),ge=y.useMemo(()=>{var S;return{opacity:b&&(((S=o==null?void 0:o.data)==null?void 0:S.hidden)||!X)&&.1}},[b,(te=o==null?void 0:o.data)==null?void 0:te.hidden]),Y={key:"duplicate",dataId:h,default:!0,fields:(D==null?void 0:D.filter(S=>he.find(O=>S.includes(O.name))))||[],collection:k||E},Z=d["x-component"]==="Action.Link",fe=()=>z(this,null,function*(){var S,O,ie;_(!0);try{const R=yield e.fetchTemplateData(v,Y,F);yield B.create({values:x({},R)}),s.success(F("Saved successfully")),L==="form"?(O=(S=w==null?void 0:w.service)==null?void 0:S.refresh)==null||O.call(S):yield(ie=P==null?void 0:P.refresh)==null?void 0:ie.call(P),_(!1)}catch(R){_(!1),console.error(R)}}),ee=()=>{!u&&!m&&X&&((D==null?void 0:D.length)>0?V==="quickDulicate"?fe():A(!0):s.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:p.cx($,{[p.css`
49
49
  .general-schema-designer {
50
50
  top: -10px;
51
51
  bottom: -10px;
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.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"}})});
55
+ `]:Z}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},xe),{duplicateData:{display:!1,enabled:!0,defaultTemplate:Y}}),children:i.jsxs("div",{children:[Z?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:u,style:x({opacity:b&&((oe=o==null?void 0:o.data)==null?void 0:oe.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},ge),onClick:ee,children:m?F("Duplicating"):c||F("Duplicate")}):i.jsx(M.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:b&&((ne=o==null?void 0:o.data)==null?void 0:ne.hidden)&&.1}},t),{onClick:ee,children:m?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:l||E,children:i.jsx(e.RecordProvider,{record:g(x({},a),{__collection:l||k}),children:i.jsx(e.ActionContextProvider,{value:g(x({},N),{visible:T,setVisible:A}),children:i.jsx(r.RecursionField,{schema:d,basePath:o.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),G=r.connect(M.Tree,r.mapProps((t,c)=>{y.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,o]=y.useState(t.defaultCheckedKeys||[]),d=u=>{o(u),c.value=u};c.onCheck=d;const v=r.useForm();return g(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var b;if(v.values.duplicateMode==="quickDulicate"){const T=(b=u==null?void 0:u.children)==null?void 0:b.map(A=>g(x({},A),{disabled:!1}));return g(x({},u),{disabled:!1,children:T})}return u})})})),H=(t,c)=>{for(let o=0;o<(t==null?void 0:t.length);o++){const s=t[o],{children:d}=s,v=le(s,["children"]);c.push(v.key),d&&H(d,c)}return c},U=t=>t.reduceProperties((s,o)=>o["x-decorator"]==="FormBlockProvider"?o:U(o),null);function re(){var L,B,D,V;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),s=r.useField(),o=r.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:v,getEnableFieldTree:u,getOnLoadData:b,getOnCheck:T}=e.useCollectionState(d),A=I.cloneDeep(((L=o["x-component-props"])==null?void 0:L.duplicateFields)||[]),m=e.useRecord(),_=y.useCallback((l,f,a)=>{a.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=f,h.setInitialValue(f),h==null||h.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),P=l=>({run(){return z(this,null,function*(){l.query("duplicateFields").take(a=>{var k;const h=H(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=h,a.setInitialValue(h),(k=a==null?void 0:a.onCheck)==null||k.call(a,h)})})}}),w=l=>({run(){return z(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:G},scope:{getEnableFieldTree:u,collectionName:((B=o["x-component-props"])==null?void 0:B.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:b,getOnCheck:T,treeData:(D=o["x-component-props"])==null?void 0:D.treeData,duplicateValues:A,onFieldInputValueChange:C.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((V=o["x-component-props"])==null?void 0:V.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":v.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:v},"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(()=>U(o),[o]);return e.useSyncFromForm(l,((f=o["x-component-props"])==null?void 0:f.duplicateCollection)||(m==null?void 0:m.__collection)||d,_)}},"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 P(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 w(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":G,"x-component-props":{defaultCheckedKeys:A,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:h})=>{var N;const k=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=k,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].duplicateMode=l,o["x-component-props"].duplicateFields=k,o["x-component-props"].duplicateCollection=f,o["x-component-props"].treeData=h||((N=s.componentProps)==null?void 0:N.treeData),t.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),t.refresh()}})}const Q=[{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:re,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}}]}],pe=new e.SchemaSettings({name:"ActionSettings:duplicate",items:Q}),de=new e.SchemaSettings({name:"actionSettings:duplicate",items:Q}),J=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}))},ue=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:J,DuplicateAction:K},children:t.children});class W extends e.Plugin{load(){return z(this,null,function*(){this.app.use(ue),this.app.addComponents({DuplicateActionInitializer:J,DuplicateAction:K}),this.app.schemaSettingsManager.add(pe),this.app.schemaSettingsManager.add(de);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=W,n.actionDesignerCss=$,n.default=W,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.2.2-alpha",
13
+ "@nocobase/client": "1.2.4-alpha",
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.2.2-alpha",
20
- "@nocobase/test": "1.2.2-alpha"
19
+ "@nocobase/server": "1.2.4-alpha",
20
+ "@nocobase/test": "1.2.4-alpha"
21
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-action-duplicate",
3
- "version": "1.2.2-alpha",
3
+ "version": "1.2.4-alpha",
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": "d968839548b92e4d4c20614fdb44a17494f84439",
17
+ "gitHead": "bacfa9133d38339862eee143c516432c2327099e",
18
18
  "keywords": [
19
19
  "Actions"
20
20
  ]