@nocobase/plugin-action-duplicate 0.20.0-alpha.9 → 0.21.0-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.
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '@nocobase/client';
2
- export declare class PluginDuplicateClient extends Plugin {
2
+ export declare class PluginActionDuplicateClient extends Plugin {
3
3
  load(): Promise<void>;
4
4
  }
5
- export default PluginDuplicateClient;
5
+ export default PluginActionDuplicateClient;
6
6
  export * from './DuplicateAction';
@@ -1,4 +1,4 @@
1
- (function(o,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):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-action-duplicate"]={},o["@nocobase/client"],o.jsxRuntime,o["@emotion/css"],o["@formily/react"],o.antd,o.react,o["react-i18next"],o["@formily/core"],o.lodash))})(this,function(o,e,i,p,r,I,k,F,C,M){"use strict";var he=Object.defineProperty,xe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var oe=(o,e,i)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,x=(o,e)=>{for(var i in e||(e={}))ne.call(e,i)&&oe(o,i,e[i]);if(j)for(var i of j(e))ie.call(e,i)&&oe(o,i,e[i]);return o},f=(o,e)=>xe(o,ge(e));var ce=(o,e)=>{var i={};for(var p in o)ne.call(o,p)&&e.indexOf(p)<0&&(i[p]=o[p]);if(o!=null&&j)for(var p of j(o))e.indexOf(p)<0&&ie.call(o,p)&&(i[p]=o[p]);return i};var w=(o,e,i)=>new Promise((p,r)=>{var I=C=>{try{F(i.next(C))}catch(M){r(M)}},k=C=>{try{F(i.throw(C))}catch(M){r(M)}},F=C=>C.done?p(C.value):Promise.resolve(C.value).then(I,k);F((i=i.apply(o,e)).next())});const E=p.css`
1
+ (function(o,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):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-action-duplicate"]={},o["@nocobase/client"],o.jsxRuntime,o["@emotion/css"],o["@formily/react"],o.antd,o.react,o["react-i18next"],o["@formily/core"],o.lodash))})(this,function(o,e,i,d,p,M,b,q,y,T){"use strict";var he=Object.defineProperty,xe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var oe=(o,e,i)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,x=(o,e)=>{for(var i in e||(e={}))ne.call(e,i)&&oe(o,i,e[i]);if(j)for(var i of j(e))ie.call(e,i)&&oe(o,i,e[i]);return o},g=(o,e)=>xe(o,ge(e));var ce=(o,e)=>{var i={};for(var d in o)ne.call(o,d)&&e.indexOf(d)<0&&(i[d]=o[d]);if(o!=null&&j)for(var d of j(o))e.indexOf(d)<0&&ie.call(o,d)&&(i[d]=o[d]);return i};var L=(o,e,i)=>new Promise((d,p)=>{var M=y=>{try{q(i.next(y))}catch(T){p(T)}},b=y=>{try{q(i.throw(y))}catch(T){p(T)}},q=y=>y.done?d(y.value):Promise.resolve(y.value).then(M,b);q((i=i.apply(o,e)).next())});const E=d.css`
2
2
  position: relative;
3
3
  &:hover {
4
4
  .general-schema-designer {
@@ -36,11 +36,11 @@
36
36
  }
37
37
  }
38
38
  }
39
- `,K=r.observer(t=>{var Z,ee;const{children:c}=t,{message:s}=I.App.useApp(),n=r.useField(),d=r.useFieldSchema(),D=e.useAPIClient(),u=n.disabled||t.disabled,{designable:S}=e.useDesignable(),[T,v]=k.useState(!1),[m,z]=k.useState(!1),{service:A,__parent:_,block:B}=e.useBlockRequestContext(),{duplicateFields:b,duplicateMode:L="quickDulicate",duplicateCollection:l}=d["x-component-props"],g=e.useRecord(),a=e.useCollectionParentRecordData(),{id:h,__collection:y}=g,V=e.useActionContext(),{name:N}=e.useCollection_deprecated(),{getCollectionFields:pe}=e.useCollectionManager_deprecated(),{t:P}=F.useTranslation(),de=pe(y||N),ue=e.useFormBlockContext(),W={key:"duplicate",dataId:h,default:!0,fields:(b==null?void 0:b.filter(q=>de.find(O=>q.includes(O.name))))||[],collection:y||N},X=d["x-component"]==="Action.Link",me=()=>w(this,null,function*(){var q,O,te;z(!0);try{const $=yield e.fetchTemplateData(D,W,P);yield D.resource(y||N).create({values:x({},$)}),s.success(P("Saved successfully")),B==="form"?(O=(q=_==null?void 0:_.service)==null?void 0:q.refresh)==null||O.call(q):yield(te=A==null?void 0:A.refresh)==null?void 0:te.call(A),z(!1)}catch($){z(!1),console.error($)}}),Y=()=>{!u&&!m&&((b==null?void 0:b.length)>0?L==="quickDulicate"?me():v(!0):s.error(P("Please configure the duplicate fields")))};return i.jsx("div",{className:p.cx(E,{[p.css`
39
+ `,K=p.observer(t=>{var Z,ee;const{children:c}=t,{message:s}=M.App.useApp(),n=p.useField(),u=p.useFieldSchema(),C=e.useAPIClient(),m=n.disabled||t.disabled,{designable:k}=e.useDesignable(),[z,S]=b.useState(!1),[h,_]=b.useState(!1),{service:v,__parent:w,block:V}=e.useBlockRequestContext(),{duplicateFields:D,duplicateMode:N="quickDulicate",duplicateCollection:B}=u["x-component-props"],l=e.useRecord(),f=e.useCollectionParentRecordData(),{id:a,__collection:r}=l,A=e.useActionContext(),{name:P}=e.useCollection_deprecated(),{getCollectionFields:pe}=e.useCollectionManager_deprecated(),{t:F}=q.useTranslation(),de=pe(r||P),ue=e.useFormBlockContext(),W={key:"duplicate",dataId:a,default:!0,fields:(D==null?void 0:D.filter(I=>de.find(O=>I.includes(O.name))))||[],collection:r||P},X=u["x-component"]==="Action.Link",me=()=>L(this,null,function*(){var I,O,te;_(!0);try{const $=yield e.fetchTemplateData(C,W,F);yield C.resource(r||P).create({values:x({},$)}),s.success(F("Saved successfully")),V==="form"?(O=(I=w==null?void 0:w.service)==null?void 0:I.refresh)==null||O.call(I):yield(te=v==null?void 0:v.refresh)==null?void 0:te.call(v),_(!1)}catch($){_(!1),console.error($)}}),Y=()=>{!m&&!h&&((D==null?void 0:D.length)>0?N==="quickDulicate"?me():S(!0):s.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:d.cx(E,{[d.css`
40
40
  .general-schema-designer {
41
41
  top: -10px;
42
42
  bottom: -10px;
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":"CreateFormBlockInitializers",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("TableActionColumnInitializers","actions.duplicate",c)})}}o.DuplicateAction=K,o.PluginDuplicateClient=J,o.actionDesignerCss=E,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
46
+ `]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:g(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:m,style:{opacity:k&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")}):i.jsx(M.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:k&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:B||P,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:B||r}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},A),{visible:z,setVisible:S}),children:i.jsx(p.RecursionField,{schema:u,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=p.connect(M.Tree,p.mapProps((t,c)=>{b.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=b.useState(t.defaultCheckedKeys||[]),u=m=>{n(m),c.value=m};c.onCheck=u;const C=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var k;if(C.values.duplicateMode==="quickDulicate"){const z=(k=m==null?void 0:m.children)==null?void 0:k.map(S=>g(x({},S),{disabled:!1}));return g(x({},m),{disabled:!1,children:z})}return m})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:u}=s,C=ce(s,["children"]);c.push(C.key),u&&G(u,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var V,D,N,B;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),s=p.useField(),n=p.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:C,getEnableFieldTree:m,getOnLoadData:k,getOnCheck:z}=e.useCollectionState(u),S=T.cloneDeep(((V=n["x-component-props"])==null?void 0:V.duplicateFields)||[]),h=e.useRecord(),_=b.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}))})},[]),v=l=>({run(){return L(this,null,function*(){l.query("duplicateFields").take(a=>{var A;const r=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=r,a.setInitialValue(r),(A=a==null?void 0:a.onCheck)==null||A.call(a,r)})})}}),w=l=>({run(){return L(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:m,collectionName:((D=n["x-component-props"])==null?void 0:D.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:k,getOnCheck:z,treeData:(N=n["x-component-props"])==null?void 0:N.treeData,duplicateValues:S,onFieldInputValueChange:y.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((B=n["x-component-props"])==null?void 0:B.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":C.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:C},"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=b.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((f=n["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||u,_)}},"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 v(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 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":R,"x-component-props":{defaultCheckedKeys:S,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 P;const A=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=A,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=A,n["x-component-props"].duplicateCollection=f,n["x-component-props"].treeData=r||((P=s.componentProps)==null?void 0:P.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 g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,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}}]}],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,g(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 L(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"}})});
@@ -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.20.0-alpha.9",
4
+ "@nocobase/client": "0.21.0-alpha.2",
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.20.0-alpha.9",
11
- "@nocobase/test": "0.20.0-alpha.9"
10
+ "@nocobase/server": "0.21.0-alpha.2",
11
+ "@nocobase/test": "0.21.0-alpha.2"
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-action-duplicate",
3
- "version": "0.20.0-alpha.9",
3
+ "version": "0.21.0-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": "0.x",
15
15
  "@nocobase/test": "0.x"
16
16
  },
17
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5",
17
+ "gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb",
18
18
  "keywords": [
19
19
  "Actions"
20
20
  ]