@nocobase/plugin-snapshot-field 1.0.0-alpha.9 → 1.0.1-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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (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,y,z,B,C,I,L){"use strict";var ce=Object.defineProperty,le=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var _=(r,e,o)=>e in r?ce(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)&&_(r,o,e[o]);if(w)for(var o of w(e))W.call(e,o)&&_(r,o,e[o]);return r},S=(r,e)=>le(r,de(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&&w)for(var d of w(r))e.indexOf(d)<0&&W.call(r,d)&&(o[d]=r[d]);return o};var g=(r,e,o)=>(_(r,typeof e!="symbol"?e+"":e,o),o);var A=(r,e,o)=>new Promise((d,v)=>{var y=C=>{try{B(o.next(C))}catch(I){v(I)}},z=C=>{try{B(o.throw(C))}catch(I){v(I)}},B=C=>C.done?d(C.value):Promise.resolve(C.value).then(y,z);B((o=o.apply(r,e)).next())});const P="snapshot-field",{defaultProps:J}=e.interfacesProperties,q="appends",T="targetField",$=()=>{let t=e.useRecord();for(;t!=null&&t.__parent&&Object.keys(t.__parent).length>0;)t=t.__parent;return t};function K(){var s;const{getCollectionField:t}=e.useCollectionManager_deprecated(),i=$(),a=y.useForm().values;return(s=t(`${i.name}.${a.targetField}`))==null?void 0:s.target}function O(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 k=i.filter(h=>`${h}.`.startsWith(`${n.name}.`));if(k.length){const h=a(n.target),x=k.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:O(h.fields,x)})}}else s.push({label:(m=(u=n.uiSchema)==null?void 0:u.title)!=null?m:n.name,value:n.name})}),s}const Q={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":"popup:snapshot:addBlock",properties:{}}}}}}}};class U extends e.CollectionFieldInterface{constructor(){super(...arguments);g(this,"name","snapshot");g(this,"type","object");g(this,"group","advanced");g(this,"title",`{{t('Snapshot', {ns: '${P}'})}}`);g(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: '${P}'})}}`);g(this,"default",{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}});g(this,"properties",S(f({},J),{[T]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${P}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:q,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[q]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${P}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:K},"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:z.cloneDeep(Q)}}initialize(a){}usePathOptions(a){const{appends:s=[],targetCollection:n}=a,{getCollection:c}=e.useCollectionManager_deprecated(),{fields:l}=c(n),u=O(l,s);return[{label:`{{t('Snapshot data', { ns: '${P}' })}}`,value:"data",children:u}]}}const X=()=>{const t=$(),{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 S(f({},n),{label:s((c=n.uiSchema)==null?void 0:c.title),value:n.name})})},Y=t=>{const i=X();return o.jsx(v.Select,f({popupMatchSelectWidth:!1,options:i},t))},R=t=>{const h=t,{formItemInitializers:i="details:configureFields",actionInitializers:a="details:configureActions",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-use-component-props":"useFormBlockProps","x-read-pretty":!0,properties:{grid:l||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},Z=()=>{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(),k=c||e.useCollection_deprecated(),h=e.useAssociationName(),{block:x}=e.useBlockRequestContext(),p=x!=="TableField"?t.actionInitializers||"details:configureActions":null;return d.createElement(e.SchemaInitializerItem,S(f({icon:n&&o.jsx(C.FormOutlined,{})},l),{key:"snapshotDetail",onClick:me=>A(this,[me],function*({item:F}){if(F.template){const V=yield m(F);if(F.template.componentName==="ReadPrettyFormItem"){const G=R({actionInitializers:p,association:h,collection:k.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:V});F.mode==="reference"&&(G["x-template-key"]=F.template.key),u(G)}else u(V)}else u(R({actionInitializers:p,association:h,collection:k.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},ee=t=>{var m;const{action:i,readPretty:a}=t,s=y.useField(),n=d.useMemo(()=>L.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})})},te=t=>{const i=y.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})},oe=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(te,S(f({},t),{children:t.children}))})})})})},re=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(oe,S(f({},t),{children:o.jsx(ee,f({},t))}))},ne=t=>{var k,h,x;const{collectionName:i}=t,{collections:a}=e.useCollectionManager_deprecated(),s=(k=e.useHistoryCollectionsByNames([i]))==null?void 0:k[0],n=e.useHistoryCollectionsByNames((h=s==null?void 0:s.inherits)!=null?h:[]),c=e.useHistoryCollectionsByNames((x=s==null?void 0:s.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?x:[]),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})})},D=t=>{const i=y.useFieldSchema(),{getField:a}=e.useCollection_deprecated(),s=a(i.name);return o.jsx(ne,{collectionName:s==null?void 0:s.targetCollection,children:o.jsx(e.ReadPrettyRecordPicker,f({},t))})},se=y.connect(D,y.mapReadPretty(D)),ae=t=>{const c=t,{value:i,onChange:a}=c,s=M(c,["value","onChange"]),n=S(f({},s),{value:i==null?void 0:i.data,onChange:l=>a({data:l})});return o.jsx(se,f({},n))},N=d.memo(t=>o.jsx(e.CollectionHistoryProvider,{children:o.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ae,SnapshotBlockProvider:re,SnapshotBlockInitializersDetailItem:Z,SnapshotOwnerCollectionFieldsSelect:Y},children:t.children})}));N.displayName="SnapshotFieldProvider";const j=new e.CompatibleSchemaInitializer({name:"SnapshotBlockInitializers",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${P}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"details:configureActions"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]}),ie=new e.CompatibleSchemaInitializer({name:"popup:snapshot:addBlock",wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${P}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"details:configureActions"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},j);class E extends e.Plugin{load(){return A(this,null,function*(){this.app.use(N),this.app.schemaInitializerManager.add(j),this.app.schemaInitializerManager.add(ie),this.app.dataSourceManager.addFieldInterfaces([U])})}}r.PluginSnapshotFieldClient=E,r.default=E,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ (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,t,d,v,g,w,b,C,I,J){"use strict";var le=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var z=(r,e,t)=>e in r?le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))W.call(e,t)&&z(r,t,e[t]);if(_)for(var t of _(e))L.call(e,t)&&z(r,t,e[t]);return r},S=(r,e)=>de(r,pe(e));var M=(r,e)=>{var t={};for(var d in r)W.call(r,d)&&e.indexOf(d)<0&&(t[d]=r[d]);if(r!=null&&_)for(var d of _(r))e.indexOf(d)<0&&L.call(r,d)&&(t[d]=r[d]);return t};var P=(r,e,t)=>(z(r,typeof e!="symbol"?e+"":e,t),t);var q=(r,e,t)=>new Promise((d,v)=>{var g=C=>{try{b(t.next(C))}catch(I){v(I)}},w=C=>{try{b(t.throw(C))}catch(I){v(I)}},b=C=>C.done?d(C.value):Promise.resolve(C.value).then(g,w);b((t=t.apply(r,e)).next())});const k="snapshot-field",{defaultProps:K}=e.interfacesProperties,T="appends",A="targetField",$=()=>{let o=e.useRecord();for(;o!=null&&o.__parent&&Object.keys(o.__parent).length>0;)o=o.__parent;return o};function Q(){var s;const{getCollectionField:o}=e.useCollectionManager_deprecated(),i=$(),a=g.useForm().values;return(s=o(`${i.name}.${a.targetField}`))==null?void 0:s.target}function O(o,i=[]){const{getCollection:a}=e.useCollectionManager_deprecated(),s=[];return o.forEach(n=>{var c,l,u,h;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(n.type)){const y=i.filter(f=>`${f}.`.startsWith(`${n.name}.`));if(y.length){const f=a(n.target),x=y.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:O(f.fields,x)})}}else s.push({label:(h=(u=n.uiSchema)==null?void 0:u.title)!=null?h:n.name,value:n.name})}),s}const U={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":"popup:snapshot:addBlock",properties:{}}}}}}}};class X extends e.CollectionFieldInterface{constructor(){super(...arguments);P(this,"name","snapshot");P(this,"type","object");P(this,"group","advanced");P(this,"title",`{{t('Snapshot', {ns: '${k}'})}}`);P(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: '${k}'})}}`);P(this,"default",{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}});P(this,"properties",S(m({},K),{[A]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${k}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:T,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[T]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${k}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:Q},"x-reactions":[{dependencies:[A],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}}))}schemaInitialize(a,{field:s,readPretty:n,action:c,block:l}){a.properties={viewer:w.cloneDeep(U)}}initialize(a){}usePathOptions(a){const{appends:s=[],targetCollection:n}=a,{getCollection:c}=e.useCollectionManager_deprecated(),{fields:l}=c(n),u=O(l,s);return[{label:`{{t('Snapshot data', { ns: '${k}' })}}`,value:"data",children:u}]}}const Y=()=>{const o=$(),{getCollection:i}=e.useCollectionManager_deprecated(),a=i(o.name),s=e.useCompile();return a.fields.filter(n=>!!n.target&&!!n.interface).map(n=>{var c;return S(m({},n),{label:s((c=n.uiSchema)==null?void 0:c.title),value:n.name})})},Z=o=>{const i=Y();return t.jsx(v.Select,m({popupMatchSelectWidth:!1,options:i},o))},N=o=>{const f=o,{formItemInitializers:i="details:configureFields",actionInitializers:a="details:configureActions",collection:s,association:n,resource:c,template:l}=f,u=M(f,["formItemInitializers","actionInitializers","collection","association","resource","template"]),h=c||n||s;return{type:"void","x-acl-action":`${h}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":m({resource:h,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-use-component-props":"useFormBlockProps","x-read-pretty":!0,properties:{grid:l||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},ee=()=>{const o=e.useSchemaInitializerItem(),B=o,{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:h}=e.useSchemaTemplateManager(),y=c||e.useCollection_deprecated(),f=e.useAssociationName(),{block:x}=e.useBlockRequestContext(),p=x!=="TableField"?o.actionInitializers||"details:configureActions":null;return d.createElement(e.SchemaInitializerItem,S(m({icon:n&&t.jsx(C.FormOutlined,{})},l),{key:"snapshotDetail",onClick:he=>q(this,[he],function*({item:F}){if(F.template){const H=yield h(F);if(F.template.componentName==="ReadPrettyFormItem"){const G=N({actionInitializers:p,association:f,collection:y.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:H});F.mode==="reference"&&(G["x-template-key"]=F.template.key),u(G)}else u(H)}else u(N({actionInitializers:p,association:f,collection:y.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},oe=o=>{var h;const{action:i,readPretty:a}=o,s=g.useField(),n=d.useMemo(()=>J.createForm({readPretty:a}),[]),{resource:c,service:l}=e.useBlockRequestContext(),u=d.useRef();return l.loading?t.jsx(v.Spin,{}):t.jsx(e.FormBlockContext.Provider,{value:{action:i,form:n,field:s,service:l,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?t.jsx(e.RecordProvider,{record:(h=l==null?void 0:l.data)==null?void 0:h.data,children:t.jsx("div",{ref:u,children:o.children})}):t.jsx("div",{ref:u,children:o.children})})},te=o=>{const i=g.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},n=e.useBlockRequestContext();return t.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:o.block,props:o,field:i,service:s,resource:a,__parent:n},children:o.children})},re=o=>{const{collection:i,association:a,dataSource:s}=o,n=e.useResource(o);return t.jsx(e.CollectionManagerProvider,{dataSource:s,children:t.jsx(e.MaybeCollectionProvider,{collection:i,children:t.jsx(e.BlockAssociationContext.Provider,{value:a,children:t.jsx(e.BlockResourceContext.Provider,{value:n,children:t.jsx(te,S(m({},o),{children:o.children}))})})})})},ne=o=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager_deprecated(o.dataSource),n=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!n.includes(o.collection)&&a!==o.collection)&&t.jsx(re,S(m({},o),{children:t.jsx(oe,m({},o))}))},se=o=>{var y,f,x;const{collectionName:i}=o,{collections:a}=e.useCollectionManager_deprecated(),s=(y=e.useHistoryCollectionsByNames([i]))==null?void 0:y[0],n=e.useHistoryCollectionsByNames((f=s==null?void 0:s.inherits)!=null?f:[]),c=e.useHistoryCollectionsByNames((x=s==null?void 0:s.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?x:[]),l=[s,...c,...n].filter(p=>p),h=[...a.filter(p=>!l.map(B=>B.name).includes(p.name)),...l];return t.jsx(e.ExtendCollectionsProvider,{collections:h,children:t.jsx(e.CollectionManagerProvider_deprecated,{children:o.children})})},R=o=>{const i=g.useFieldSchema(),{getField:a}=e.useCollection_deprecated(),s=a(i.name);return t.jsx(se,{collectionName:s==null?void 0:s.targetCollection,children:t.jsx(e.ReadPrettyRecordPicker,m({},o))})},ae=g.connect(R,g.mapReadPretty(R)),ie=o=>{const c=o,{value:i,onChange:a}=c,s=M(c,["value","onChange"]),n=S(m({},s),{value:i==null?void 0:i.data,onChange:l=>a({data:l})});return t.jsx(ae,m({},n))},D=d.memo(o=>t.jsx(e.CollectionHistoryProvider,{children:t.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ie,SnapshotBlockProvider:ne,SnapshotBlockInitializersDetailItem:ee,SnapshotOwnerCollectionFieldsSelect:Z},children:o.children})}));D.displayName="SnapshotFieldProvider";const j={wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${k}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"details:configureActions"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},E=new e.CompatibleSchemaInitializer(m({name:"SnapshotBlockInitializers"},j)),ce=new e.CompatibleSchemaInitializer(m({name:"popup:snapshot:addBlock"},j),E);class V extends e.Plugin{load(){return q(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(E),this.app.schemaInitializerManager.add(ce),this.app.dataSourceManager.addFieldInterfaces([X])})}}r.PluginSnapshotFieldClient=V,r.default=V,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -8,13 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.0.0-alpha.9",
11
+ "@nocobase/client": "1.0.1-alpha.1",
12
12
  "react": "18.2.0",
13
13
  "@formily/react": "2.3.0",
14
14
  "@formily/core": "2.3.0",
15
15
  "lodash": "4.17.21",
16
- "@nocobase/database": "1.0.0-alpha.9",
17
- "@nocobase/server": "1.0.0-alpha.9",
16
+ "@nocobase/database": "1.0.1-alpha.1",
17
+ "@nocobase/server": "1.0.1-alpha.1",
18
18
  "antd": "5.12.8",
19
19
  "react-i18next": "11.18.6",
20
20
  "@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": "1.0.0-alpha.9",
7
+ "version": "1.0.1-alpha.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/field-snapshot",
@@ -15,7 +15,7 @@
15
15
  "@formily/react": "2.x",
16
16
  "@formily/shared": "2.x",
17
17
  "antd": "5.x",
18
- "rc-tree-select": "5.5.5",
18
+ "rc-tree-select": "5.20.0",
19
19
  "react": "18.x",
20
20
  "react-i18next": "^11.15.1"
21
21
  },
@@ -26,7 +26,7 @@
26
26
  "@nocobase/test": "1.x",
27
27
  "@nocobase/utils": "1.x"
28
28
  },
29
- "gitHead": "562d6ae965317098df05db756d160e03363dcec5",
29
+ "gitHead": "d24aa16987a4068f857ae073fcce18f3cb490660",
30
30
  "keywords": [
31
31
  "Collection fields"
32
32
  ]