@nocobase/plugin-snapshot-field 0.20.0-alpha.2 → 0.20.0-alpha.3

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 +1 @@
1
- (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("lodash"),require("react-i18next"),require("@ant-design/icons"),require("@formily/shared"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","lodash","react-i18next","@ant-design/icons","@formily/shared","@formily/core"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-snapshot-field"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r.lodash,r["react-i18next"],r["@ant-design/icons"],r["@formily/shared"],r["@formily/core"]))})(this,function(r,e,o,d,v,C,_,B,y,I,W){"use strict";var ie=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var w=(r,e,o)=>e in r?ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,f=(r,e)=>{for(var o in e||(e={}))H.call(e,o)&&w(r,o,e[o]);if(z)for(var o of z(e))G.call(e,o)&&w(r,o,e[o]);return r},g=(r,e)=>ce(r,le(e));var M=(r,e)=>{var o={};for(var d in r)H.call(r,d)&&e.indexOf(d)<0&&(o[d]=r[d]);if(r!=null&&z)for(var d of z(r))e.indexOf(d)<0&&G.call(r,d)&&(o[d]=r[d]);return o};var S=(r,e,o)=>(w(r,typeof e!="symbol"?e+"":e,o),o);var q=(r,e,o)=>new Promise((d,v)=>{var C=y=>{try{B(o.next(y))}catch(I){v(I)}},_=y=>{try{B(o.throw(y))}catch(I){v(I)}},B=y=>y.done?d(y.value):Promise.resolve(y.value).then(C,_);B((o=o.apply(r,e)).next())});const x="snapshot-field",{defaultProps:L}=e.interfacesProperties,R="appends",T="targetField",A=()=>{let t=e.useRecord();for(;t&&Object.keys(t.__parent).length>0;)t=t.__parent;return t};function J(){var s;const{getCollectionField:t}=e.useCollectionManager_deprecated(),i=A(),a=C.useForm().values;return(s=t(`${i.name}.${a.targetField}`))==null?void 0:s.target}function $(t,i=[]){const{getCollection:a}=e.useCollectionManager_deprecated(),s=[];return t.forEach(n=>{var c,l,u,m;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(n.type)){const P=i.filter(h=>`${h}.`.startsWith(`${n.name}.`));if(P.length){const h=a(n.target),k=P.filter(p=>p!==n.name).map(p=>p.replace(`${n.name}.`,"")).filter(p=>p);s.push({label:(l=(c=n.uiSchema)==null?void 0:c.title)!=null?l:n.name,value:n.name,children:$(h.fields,k)})}}else s.push({label:(m=(u=n.uiSchema)==null?void 0:u.title)!=null?m:n.name,value:n.name})}),s}const K={type:"void",title:"{{t('View record')}}","x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:"{{t('Detail')}}","x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"SnapshotBlockInitializers",properties:{}}}}}}}};class Q extends e.CollectionFieldInterface{constructor(){super(...arguments);S(this,"name","snapshot");S(this,"type","object");S(this,"group","advanced");S(this,"title",`{{t('Snapshot', {ns: '${x}'})}}`);S(this,"description",`{{t('When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.', {ns: '${x}'})}}`);S(this,"default",{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}});S(this,"properties",g(f({},L),{[T]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${x}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:R,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[R]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${x}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection_deprecated:J},"x-reactions":[{dependencies:[T],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}}))}schemaInitialize(a,{field:s,readPretty:n,action:c,block:l}){a.properties={viewer:_.cloneDeep(K)}}initialize(a){}usePathOptions(a){const{appends:s=[],targetCollection:n}=a,{getCollection:c}=e.useCollectionManager_deprecated(),{fields:l}=c(n),u=$(l,s);return[{label:`{{t('Snapshot data', { ns: '${x}' })}}`,value:"data",children:u}]}}const U=()=>{const t=A(),{getCollection:i}=e.useCollectionManager_deprecated(),a=i(t.name),s=e.useCompile();return a.fields.filter(n=>!!n.target&&!!n.interface).map(n=>{var c;return g(f({},n),{label:s((c=n.uiSchema)==null?void 0:c.title),value:n.name})})},X=t=>{const i=U();return o.jsx(v.Select,f({popupMatchSelectWidth:!1,options:i},t))},O=t=>{const h=t,{formItemInitializers:i="ReadPrettyFormItemInitializers",actionInitializers:a="ReadPrettyFormActionInitializers",collection:s,association:n,resource:c,template:l}=h,u=M(h,["formItemInitializers","actionInitializers","collection","association","resource","template"]),m=c||n||s;return{type:"void","x-acl-action":`${m}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":f({resource:m,collection:s,association:n,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:l||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},Y=()=>{const t=e.useSchemaInitializerItem(),b=t,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,icon:n=!0,targetCollection:c}=b,l=M(b,["onCreateBlockSchema","componentType","createBlockSchema","icon","targetCollection"]),{insert:u}=e.useSchemaInitializer(),{getTemplateSchemaByMode:m}=e.useSchemaTemplateManager(),P=c||e.useCollection_deprecated(),h=e.useBlockAssociationContext(),{block:k}=e.useBlockRequestContext(),p=k!=="TableField"?t.actionInitializers||"ReadPrettyFormActionInitializers":null;return d.createElement(e.SchemaInitializerItem,g(f({icon:n&&o.jsx(y.FormOutlined,{})},l),{key:"snapshotDetail",onClick:ue=>q(this,[ue],function*({item:F}){if(F.template){const E=yield m(F);if(F.template.componentName==="ReadPrettyFormItem"){const V=O({actionInitializers:p,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:E});F.mode==="reference"&&(V["x-template-key"]=F.template.key),u(V)}else u(E)}else u(O({actionInitializers:p,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},Z=t=>{var m;const{action:i,readPretty:a}=t,s=C.useField(),n=d.useMemo(()=>W.createForm({readPretty:a}),[]),{resource:c,service:l}=e.useBlockRequestContext(),u=d.useRef();return l.loading?o.jsx(v.Spin,{}):o.jsx(e.FormBlockContext.Provider,{value:{action:i,form:n,field:s,service:l,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?o.jsx(e.RecordProvider,{record:(m=l==null?void 0:l.data)==null?void 0:m.data,children:o.jsx("div",{ref:u,children:t.children})}):o.jsx("div",{ref:u,children:t.children})})},ee=t=>{const i=C.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},n=e.useBlockRequestContext();return o.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:t.block,props:t,field:i,service:s,resource:a,__parent:n},children:t.children})},te=t=>{const{collection:i,association:a,dataSource:s}=t,n=e.useResource(t);return o.jsx(e.CollectionManagerProvider,{dataSource:s,children:o.jsx(e.MaybeCollectionProvider,{collection:i,children:o.jsx(e.BlockAssociationContext.Provider,{value:a,children:o.jsx(e.BlockResourceContext.Provider,{value:n,children:o.jsx(ee,g(f({},t),{children:t.children}))})})})})},oe=t=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager_deprecated(t.dataSource),n=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!n.includes(t.collection)&&a!==t.collection)&&o.jsx(te,g(f({},t),{children:o.jsx(Z,f({},t))}))},re=t=>{var P,h,k;const{collectionName:i}=t,{collections:a}=e.useCollectionManager_deprecated(),s=(P=e.useHistoryCollectionsByNames([i]))==null?void 0:P[0],n=e.useHistoryCollectionsByNames((h=s==null?void 0:s.inherits)!=null?h:[]),c=e.useHistoryCollectionsByNames((k=s==null?void 0:s.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?k:[]),l=[s,...c,...n].filter(p=>p),m=[...a.filter(p=>!l.map(b=>b.name).includes(p.name)),...l];return o.jsx(e.ExtendCollectionsProvider,{collections:m,children:o.jsx(e.CollectionManagerProvider_deprecated,{children:t.children})})},N=t=>{const i=C.useFieldSchema(),{getField:a}=e.useCollection_deprecated(),s=a(i.name);return o.jsx(re,{collectionName:s==null?void 0:s.targetCollection,children:o.jsx(e.ReadPrettyRecordPicker,f({},t))})},ne=C.connect(N,C.mapReadPretty(N)),se=t=>{const c=t,{value:i,onChange:a}=c,s=M(c,["value","onChange"]),n=g(f({},s),{value:i==null?void 0:i.data,onChange:l=>a({data:l})});return o.jsx(ne,f({},n))},D=d.memo(t=>o.jsx(e.CollectionHistoryProvider,{children:o.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:se,SnapshotBlockProvider:oe,SnapshotBlockInitializersDetailItem:Y,SnapshotOwnerCollectionFieldsSelect:X},children:t.children})}));D.displayName="SnapshotFieldProvider";const ae=new e.SchemaInitializer({name:"SnapshotBlockInitializers",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${x}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"CalendarFormActionInitializers"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});class j extends e.Plugin{load(){return q(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(ae),this.app.dataSourceManager.addFieldInterfaces([Q])})}}r.SnapshotFieldPlugin=j,r.default=j,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("lodash"),require("react-i18next"),require("@ant-design/icons"),require("@formily/shared"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","lodash","react-i18next","@ant-design/icons","@formily/shared","@formily/core"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-snapshot-field"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r.lodash,r["react-i18next"],r["@ant-design/icons"],r["@formily/shared"],r["@formily/core"]))})(this,function(r,e,o,d,v,C,_,B,y,I,W){"use strict";var ie=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var w=(r,e,o)=>e in r?ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,f=(r,e)=>{for(var o in e||(e={}))H.call(e,o)&&w(r,o,e[o]);if(z)for(var o of z(e))G.call(e,o)&&w(r,o,e[o]);return r},g=(r,e)=>ce(r,le(e));var M=(r,e)=>{var o={};for(var d in r)H.call(r,d)&&e.indexOf(d)<0&&(o[d]=r[d]);if(r!=null&&z)for(var d of z(r))e.indexOf(d)<0&&G.call(r,d)&&(o[d]=r[d]);return o};var S=(r,e,o)=>(w(r,typeof e!="symbol"?e+"":e,o),o);var q=(r,e,o)=>new Promise((d,v)=>{var C=y=>{try{B(o.next(y))}catch(I){v(I)}},_=y=>{try{B(o.throw(y))}catch(I){v(I)}},B=y=>y.done?d(y.value):Promise.resolve(y.value).then(C,_);B((o=o.apply(r,e)).next())});const x="snapshot-field",{defaultProps:L}=e.interfacesProperties,R="appends",T="targetField",A=()=>{let t=e.useRecord();for(;t&&Object.keys(t.__parent).length>0;)t=t.__parent;return t};function J(){var s;const{getCollectionField:t}=e.useCollectionManager_deprecated(),i=A(),a=C.useForm().values;return(s=t(`${i.name}.${a.targetField}`))==null?void 0:s.target}function $(t,i=[]){const{getCollection:a}=e.useCollectionManager_deprecated(),s=[];return t.forEach(n=>{var c,l,u,m;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(n.type)){const P=i.filter(h=>`${h}.`.startsWith(`${n.name}.`));if(P.length){const h=a(n.target),k=P.filter(p=>p!==n.name).map(p=>p.replace(`${n.name}.`,"")).filter(p=>p);s.push({label:(l=(c=n.uiSchema)==null?void 0:c.title)!=null?l:n.name,value:n.name,children:$(h.fields,k)})}}else s.push({label:(m=(u=n.uiSchema)==null?void 0:u.title)!=null?m:n.name,value:n.name})}),s}const K={type:"void",title:"{{t('View record')}}","x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:"{{t('Detail')}}","x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"SnapshotBlockInitializers",properties:{}}}}}}}};class Q extends e.CollectionFieldInterface{constructor(){super(...arguments);S(this,"name","snapshot");S(this,"type","object");S(this,"group","advanced");S(this,"title",`{{t('Snapshot', {ns: '${x}'})}}`);S(this,"description",`{{t('When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.', {ns: '${x}'})}}`);S(this,"default",{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}});S(this,"properties",g(f({},L),{[T]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${x}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:R,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[R]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${x}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:J},"x-reactions":[{dependencies:[T],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}}))}schemaInitialize(a,{field:s,readPretty:n,action:c,block:l}){a.properties={viewer:_.cloneDeep(K)}}initialize(a){}usePathOptions(a){const{appends:s=[],targetCollection:n}=a,{getCollection:c}=e.useCollectionManager_deprecated(),{fields:l}=c(n),u=$(l,s);return[{label:`{{t('Snapshot data', { ns: '${x}' })}}`,value:"data",children:u}]}}const U=()=>{const t=A(),{getCollection:i}=e.useCollectionManager_deprecated(),a=i(t.name),s=e.useCompile();return a.fields.filter(n=>!!n.target&&!!n.interface).map(n=>{var c;return g(f({},n),{label:s((c=n.uiSchema)==null?void 0:c.title),value:n.name})})},X=t=>{const i=U();return o.jsx(v.Select,f({popupMatchSelectWidth:!1,options:i},t))},O=t=>{const h=t,{formItemInitializers:i="ReadPrettyFormItemInitializers",actionInitializers:a="ReadPrettyFormActionInitializers",collection:s,association:n,resource:c,template:l}=h,u=M(h,["formItemInitializers","actionInitializers","collection","association","resource","template"]),m=c||n||s;return{type:"void","x-acl-action":`${m}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":f({resource:m,collection:s,association:n,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:l||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},Y=()=>{const t=e.useSchemaInitializerItem(),b=t,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,icon:n=!0,targetCollection:c}=b,l=M(b,["onCreateBlockSchema","componentType","createBlockSchema","icon","targetCollection"]),{insert:u}=e.useSchemaInitializer(),{getTemplateSchemaByMode:m}=e.useSchemaTemplateManager(),P=c||e.useCollection_deprecated(),h=e.useBlockAssociationContext(),{block:k}=e.useBlockRequestContext(),p=k!=="TableField"?t.actionInitializers||"ReadPrettyFormActionInitializers":null;return d.createElement(e.SchemaInitializerItem,g(f({icon:n&&o.jsx(y.FormOutlined,{})},l),{key:"snapshotDetail",onClick:ue=>q(this,[ue],function*({item:F}){if(F.template){const E=yield m(F);if(F.template.componentName==="ReadPrettyFormItem"){const V=O({actionInitializers:p,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:E});F.mode==="reference"&&(V["x-template-key"]=F.template.key),u(V)}else u(E)}else u(O({actionInitializers:p,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},Z=t=>{var m;const{action:i,readPretty:a}=t,s=C.useField(),n=d.useMemo(()=>W.createForm({readPretty:a}),[]),{resource:c,service:l}=e.useBlockRequestContext(),u=d.useRef();return l.loading?o.jsx(v.Spin,{}):o.jsx(e.FormBlockContext.Provider,{value:{action:i,form:n,field:s,service:l,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?o.jsx(e.RecordProvider,{record:(m=l==null?void 0:l.data)==null?void 0:m.data,children:o.jsx("div",{ref:u,children:t.children})}):o.jsx("div",{ref:u,children:t.children})})},ee=t=>{const i=C.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},n=e.useBlockRequestContext();return o.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:t.block,props:t,field:i,service:s,resource:a,__parent:n},children:t.children})},te=t=>{const{collection:i,association:a,dataSource:s}=t,n=e.useResource(t);return o.jsx(e.CollectionManagerProvider,{dataSource:s,children:o.jsx(e.MaybeCollectionProvider,{collection:i,children:o.jsx(e.BlockAssociationContext.Provider,{value:a,children:o.jsx(e.BlockResourceContext.Provider,{value:n,children:o.jsx(ee,g(f({},t),{children:t.children}))})})})})},oe=t=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager_deprecated(t.dataSource),n=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!n.includes(t.collection)&&a!==t.collection)&&o.jsx(te,g(f({},t),{children:o.jsx(Z,f({},t))}))},re=t=>{var P,h,k;const{collectionName:i}=t,{collections:a}=e.useCollectionManager_deprecated(),s=(P=e.useHistoryCollectionsByNames([i]))==null?void 0:P[0],n=e.useHistoryCollectionsByNames((h=s==null?void 0:s.inherits)!=null?h:[]),c=e.useHistoryCollectionsByNames((k=s==null?void 0:s.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?k:[]),l=[s,...c,...n].filter(p=>p),m=[...a.filter(p=>!l.map(b=>b.name).includes(p.name)),...l];return o.jsx(e.ExtendCollectionsProvider,{collections:m,children:o.jsx(e.CollectionManagerProvider_deprecated,{children:t.children})})},N=t=>{const i=C.useFieldSchema(),{getField:a}=e.useCollection_deprecated(),s=a(i.name);return o.jsx(re,{collectionName:s==null?void 0:s.targetCollection,children:o.jsx(e.ReadPrettyRecordPicker,f({},t))})},ne=C.connect(N,C.mapReadPretty(N)),se=t=>{const c=t,{value:i,onChange:a}=c,s=M(c,["value","onChange"]),n=g(f({},s),{value:i==null?void 0:i.data,onChange:l=>a({data:l})});return o.jsx(ne,f({},n))},D=d.memo(t=>o.jsx(e.CollectionHistoryProvider,{children:o.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:se,SnapshotBlockProvider:oe,SnapshotBlockInitializersDetailItem:Y,SnapshotOwnerCollectionFieldsSelect:X},children:t.children})}));D.displayName="SnapshotFieldProvider";const ae=new e.SchemaInitializer({name:"SnapshotBlockInitializers",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${x}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"CalendarFormActionInitializers"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});class j extends e.Plugin{load(){return q(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(ae),this.app.dataSourceManager.addFieldInterfaces([Q])})}}r.SnapshotFieldPlugin=j,r.default=j,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -63,7 +63,7 @@ export declare class SnapshotFieldInterface extends CollectionFieldInterface {
63
63
  'x-component': string;
64
64
  'x-component-props': {
65
65
  multiple: boolean;
66
- useCollection_deprecated: typeof useRecordCollection;
66
+ useCollection: typeof useRecordCollection;
67
67
  };
68
68
  'x-reactions': {
69
69
  dependencies: string[];
@@ -1,11 +1,11 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.20.0-alpha.2",
2
+ "@nocobase/client": "0.20.0-alpha.3",
3
3
  "react": "18.2.0",
4
4
  "@formily/react": "2.3.0",
5
5
  "@formily/core": "2.3.0",
6
6
  "lodash": "4.17.21",
7
- "@nocobase/database": "0.20.0-alpha.2",
8
- "@nocobase/server": "0.20.0-alpha.2",
7
+ "@nocobase/database": "0.20.0-alpha.3",
8
+ "@nocobase/server": "0.20.0-alpha.3",
9
9
  "antd": "5.12.8",
10
10
  "react-i18next": "11.18.6",
11
11
  "@ant-design/icons": "5.2.6",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "数据表字段:关系快照",
5
5
  "description": "When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.",
6
6
  "description.zh-CN": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
7
- "version": "0.20.0-alpha.2",
7
+ "version": "0.20.0-alpha.3",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/plugins/snapshot-field",
@@ -26,7 +26,7 @@
26
26
  "@nocobase/test": "0.x",
27
27
  "@nocobase/utils": "0.x"
28
28
  },
29
- "gitHead": "6fb885dfc3554e4b0f29e9a7a1eecbbe85d0eebb",
29
+ "gitHead": "0d05e9afde96b4a328b04bd8d1ed079c3478febc",
30
30
  "keywords": [
31
31
  "Collection fields"
32
32
  ]