@entropic-bond/crud-panel 4.1.0 → 4.1.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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{
|
|
5
5
|
${s}
|
|
6
6
|
}
|
|
7
|
-
`)}}static propInfo(n,t){return U.createInstance(n).getPropInfo(t)}},U._factoryMap={},U);Xt([se],ot.prototype,"_id",2);let it=ot;function se(n,t){return Zt()(n,t)}function Zt(n){return function(t,s){Object.getOwnPropertyDescriptor(t,"_persistentProperties")||(t._persistentProperties?t._persistentProperties=[...t._persistentProperties]:t._persistentProperties=[]);const l=t._persistentProperties.find(c=>c.name===s);l?Object.assign(l,n):t._persistentProperties.push({name:s,...n})}}function er(n,t){return s=>{it.registerFactory(n,s,t),s.prototype.__className=n}}const st=class me{static registerCloudStorage(t,s){me._cloudStorageFactoryMap[t]=s}static createInstance(t){const s=me._cloudStorageFactoryMap[t];if(!s)throw new Error(`You should register the ${t} cloud storage provider prior to use it`);return s()}get className(){return this.__className}static useCloudStorage(t){me._defaultCloudStorage=t}static get defaultCloudStorage(){if(!me._defaultCloudStorage)throw new Error("You should define a default cloud storage provider prior to use it");return me._defaultCloudStorage}};st._cloudStorageFactoryMap={};let ye=st;function tr(n,t){return ye.registerCloudStorage(n,t),s=>{s.prototype.__className=n}}var rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor,or=(n,t,s,l)=>{for(var c=l>1?void 0:l?nr(t,s):t,y=n.length-1,D;y>=0;y--)(D=n[y])&&(c=(l?D(t,s,c):D(c))||c);return l&&c&&rr(t,s,c),c};let Ve=class extends ye{constructor(n=""){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=n}simulateDelay(n){return this._simulateDelay=n,this}resolveWithDelay(n){if(this._simulateDelay<=0)return Promise.resolve(n);const t=new Promise(s=>{setTimeout(()=>s(n),this._simulateDelay)});return this._pendingPromises.push(t),t.finally(()=>this._pendingPromises=this._pendingPromises.filter(s=>s===t)),t}save(n,t){const s=n;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[n]=JSON.stringify(t),this._onProgress&&this._onProgress(100,100);const l=t instanceof File?t.name:s;return this.resolveWithDelay(l)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:n=>this._onProgress=n}}getUrl(n){return Promise.resolve(this._pathToMockFiles+n)}delete(n){return delete this.mockFileSystem[n],this.resolveWithDelay()}};Ve=or([tr("MockCloudStorage",()=>new Ve)],Ve);var ir=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,ae=(n,t,s,l)=>{for(var c=l>1?void 0:l?sr(t,s):t,y=n.length-1,D;y>=0;y--)(D=n[y])&&(c=(l?D(t,s,c):D(c))||c);return l&&c&&ir(t,s,c),c};let te=class extends it{constructor(){super(...arguments),this._onChange=new J}async save({data:n,fileName:t,progress:s,cloudStorageProvider:l}={}){const c=n||this._pendingData;c&&(this._reference&&await this.delete(),this.provider=l||ye.defaultCloudStorage,this._originalFileName=t||(c instanceof File?c.name:void 0),this._reference=await this.provider.save(this.id,c,s),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw new Error("Cannot delete a not stored file");await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(n){this._provider=n,this._cloudStorageProviderName=n.className}get provider(){if(!this._provider)try{this._provider=ye.createInstance(this._cloudStorageProviderName)}catch{this._provider=ye.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(n){return this._pendingData=n,this._originalFileName=n instanceof File?n.name:void 0,this._mimeType=n instanceof Blob?n.type:void 0,this._onChange.notify({event:1,pendingData:n,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(n){return this._onChange.subscribe(n)}};ae([se],te.prototype,"_reference",2),ae([se],te.prototype,"_url",2),ae([se],te.prototype,"_cloudStorageProviderName",2),ae([se],te.prototype,"_originalFileName",2),ae([se],te.prototype,"_mimeType",2),te=ae([er("StoredFile")],te);function ar(n,t="-"){if(!n)return"";const s=n.slice(1).replace(/( |[A-Z])/g,l=>l===" "?"-":t+l[0].toLowerCase());return n[0].toLocaleLowerCase()+s.replace(/--/g,"-")}class ur{constructor(){this._stages={},this._onProgress=new J}notifyBusy(t,s){this.pushStage({name:s??"",progress:t?0:1,total:1})}pushStage(t){this._stages[t.name]=t;const s=Object.values(this._stages).reduce((l,c,y,D)=>l+c.progress/c.total/D.length,0);this._onProgress.notify({busy:s<1,overallProgress:s,stages:this._stages}),s>=1&&(this._stages={})}onProgress(t){return this._onProgress.subscribe(t)}}const re=class re{constructor(t){this.progressController=new ur,this.onChangeHdl=new J,this.onErrorHdl=new J,this.validator={},this.setDocument(t||this.createDocument())}allRequiredPropertiesFilled(){return this.nonFilledRequiredProperties.length<=0}get nonFilledRequiredProperties(){return this.requiredProperties.filter(t=>this.validateProp(t))}get requiredProperties(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.document.getPersistentProperties().filter(t=>this.document.isRequired(t.name)).map(t=>t.name)}addValidator(t,s,l){this.validator[t]={func:s,errorMessage:l}}removeValidator(t){delete this.validator[t]}failedValidationError(t){var s;return(s=this.validator[t])==null?void 0:s.errorMessage}validateProp(t){if(!this.document)throw new Error(re.errorMessages.missedDocument);const s=this.document[t];return this.validator[t]?!this.validator[t].func(s):!this.document.isPropValueValid(t)}storeDoc(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.model.save(this.document)}deleteDoc(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.model.delete(this.document.id)}queryDocs(t){let s=this.model.find();return t&&(s=s.limit(t)),s}findDocs(t){}async setFilter(t){return this._filter=t,this.onChangeHdl.notify({action:"filterChange"}),this}resetFilter(){return this._filter=void 0,this.onChangeHdl.notify({action:"filterChange"}),this}onChange(t){return this.onChangeHdl.subscribe(t)}onError(t){return this.onErrorHdl.subscribe(t)}notifyChange(t){this.onChangeHdl.notify(t)}newDocument(){return this.setDocument(this.createDocument())}async storeDocument(){const t="Saving main document";try{this.progressController.notifyBusy(!0,t),await this.storeDoc(),this.onChangeHdl.notify({documentCollection:await this.documentCollection(),action:"saved"})}catch(s){if(this.onChangeHdl.notify({error:this.errorToError(s)}),this.onErrorHdl.notify(this.errorToError(s)),this.throwOnError)throw s}finally{this.progressController.notifyBusy(!1,t)}}async deleteDocument(){const t="Delete main document";try{this.progressController.notifyBusy(!0,t),await this.deleteDoc(),this.onChangeHdl.notify({documentCollection:await this.documentCollection(),action:"deleted"})}catch(s){if(this.onChangeHdl.notify({error:this.errorToError(s)}),this.onErrorHdl.notify(this.errorToError(s)),this.throwOnError)throw s}finally{this.progressController.notifyBusy(!1,t)}}async documentCollection(t){const s="Retrieving document collection";let l=[];try{this.progressController.notifyBusy(!0,s);const c=this.findDocs(t);c?l=await c:l=await this.queryDocs(t).get()}catch(c){if(this.onChangeHdl.notify({error:this.errorToError(c)}),this.onErrorHdl.notify(this.errorToError(c)),this.throwOnError)throw c}finally{this.progressController.notifyBusy(!1,s)}return l}filter(t){return t.filter(s=>{var l;return((l=this._filter)==null?void 0:l.call(this,s))??!0})}onProgress(t){return this.progressController.onProgress(t)}get model(){return this._model||(this._model=this.getModel())}setDocument(t){return this._document!==t&&(this.unsubscribeDocument&&this.unsubscribeDocument(),t&&(this.unsubscribeDocument=t.onChange(s=>this.onChangeHdl.notify({documentProps:s}))),this._document=t,this.onChangeHdl.notify({documentChanged:this._document})),this}set document(t){this.setDocument(t)}get document(){return this._document}managedThrow(t){if(this.onChangeHdl.notify({error:this.errorToError(t)}),this.onErrorHdl.notify(this.errorToError(t)),this.throwOnError)throw this.errorToError(t)}errorToError(t){return t instanceof Error?t:typeof t=="string"?new Error(t):"code"in t?new Error(t.code):"message"in t?new Error(t.error):new Error(JSON.stringify(t))}get throwOnError(){return this.onErrorHdl.subscribersCount===0}};re.errorMessages={missedDocument:"No document to save"};let xe=re;function cr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var We={exports:{}},g={};/**
|
|
7
|
+
`)}}static propInfo(n,t){return U.createInstance(n).getPropInfo(t)}},U._factoryMap={},U);Xt([se],ot.prototype,"_id",2);let it=ot;function se(n,t){return Zt()(n,t)}function Zt(n){return function(t,s){Object.getOwnPropertyDescriptor(t,"_persistentProperties")||(t._persistentProperties?t._persistentProperties=[...t._persistentProperties]:t._persistentProperties=[]);const l=t._persistentProperties.find(c=>c.name===s);l?Object.assign(l,n):t._persistentProperties.push({name:s,...n})}}function er(n,t){return s=>{it.registerFactory(n,s,t),s.prototype.__className=n}}const st=class me{static registerCloudStorage(t,s){me._cloudStorageFactoryMap[t]=s}static createInstance(t){const s=me._cloudStorageFactoryMap[t];if(!s)throw new Error(`You should register the ${t} cloud storage provider prior to use it`);return s()}get className(){return this.__className}static useCloudStorage(t){me._defaultCloudStorage=t}static get defaultCloudStorage(){if(!me._defaultCloudStorage)throw new Error("You should define a default cloud storage provider prior to use it");return me._defaultCloudStorage}};st._cloudStorageFactoryMap={};let ye=st;function tr(n,t){return ye.registerCloudStorage(n,t),s=>{s.prototype.__className=n}}var rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor,or=(n,t,s,l)=>{for(var c=l>1?void 0:l?nr(t,s):t,y=n.length-1,D;y>=0;y--)(D=n[y])&&(c=(l?D(t,s,c):D(c))||c);return l&&c&&rr(t,s,c),c};let Ve=class extends ye{constructor(n=""){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=n}simulateDelay(n){return this._simulateDelay=n,this}resolveWithDelay(n){if(this._simulateDelay<=0)return Promise.resolve(n);const t=new Promise(s=>{setTimeout(()=>s(n),this._simulateDelay)});return this._pendingPromises.push(t),t.finally(()=>this._pendingPromises=this._pendingPromises.filter(s=>s===t)),t}save(n,t){const s=n;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[n]=JSON.stringify(t),this._onProgress&&this._onProgress(100,100);const l=t instanceof File?t.name:s;return this.resolveWithDelay(l)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:n=>this._onProgress=n}}getUrl(n){return Promise.resolve(this._pathToMockFiles+n)}delete(n){return delete this.mockFileSystem[n],this.resolveWithDelay()}};Ve=or([tr("MockCloudStorage",()=>new Ve)],Ve);var ir=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,ae=(n,t,s,l)=>{for(var c=l>1?void 0:l?sr(t,s):t,y=n.length-1,D;y>=0;y--)(D=n[y])&&(c=(l?D(t,s,c):D(c))||c);return l&&c&&ir(t,s,c),c};let te=class extends it{constructor(){super(...arguments),this._onChange=new J}async save({data:n,fileName:t,progress:s,cloudStorageProvider:l}={}){const c=n||this._pendingData;c&&(this._reference&&await this.delete(),this.provider=l||ye.defaultCloudStorage,this._originalFileName=t||(c instanceof File?c.name:void 0),this._reference=await this.provider.save(this.id,c,s),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw new Error("Cannot delete a not stored file");await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(n){this._provider=n,this._cloudStorageProviderName=n.className}get provider(){if(!this._provider)try{this._provider=ye.createInstance(this._cloudStorageProviderName)}catch{this._provider=ye.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(n){return this._pendingData=n,this._originalFileName=n instanceof File?n.name:void 0,this._mimeType=n instanceof Blob?n.type:void 0,this._onChange.notify({event:1,pendingData:n,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(n){return this._onChange.subscribe(n)}};ae([se],te.prototype,"_reference",2),ae([se],te.prototype,"_url",2),ae([se],te.prototype,"_cloudStorageProviderName",2),ae([se],te.prototype,"_originalFileName",2),ae([se],te.prototype,"_mimeType",2),te=ae([er("StoredFile")],te);function ar(n,t="-"){if(!n)return"";const s=n.slice(1).replace(/( |[A-Z])/g,l=>l===" "?"-":t+l[0].toLowerCase());return n[0].toLocaleLowerCase()+s.replace(/--/g,"-")}class ur{constructor(){this._stages={},this._onProgress=new J}notifyBusy(t,s){this.pushStage({name:s??"",progress:t?0:1,total:1})}pushStage(t){this._stages[t.name]=t;const s=Object.values(this._stages).reduce((l,c,y,D)=>l+c.progress/c.total/D.length,0);this._onProgress.notify({busy:s<1,overallProgress:s,stages:this._stages}),s>=1&&(this._stages={})}onProgress(t){return this._onProgress.subscribe(t)}}const re=class re{constructor(t){this.progressController=new ur,this.onChangeHdl=new J,this.onErrorHdl=new J,this.validator={},this.setDocument(t||this.createDocument())}allRequiredPropertiesFilled(){return this.nonFilledRequiredProperties.length<=0}get nonFilledRequiredProperties(){return this.requiredProperties.filter(t=>this.validateProp(t))}get requiredProperties(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.document.getPersistentProperties().filter(t=>this.document.isRequired(t.name)).map(t=>t.name).concat(Object.keys(this.validator))}addValidator(t,s,l){this.validator[t]={func:s,errorMessage:l}}removeValidator(t){delete this.validator[t]}failedValidationError(t){var s;return(s=this.validator[t])==null?void 0:s.errorMessage}validateProp(t){if(!this.document)throw new Error(re.errorMessages.missedDocument);const s=this.document[t];return this.validator[t]?!this.validator[t].func(s):!this.document.isPropValueValid(t)}storeDoc(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.model.save(this.document)}deleteDoc(){if(!this.document)throw new Error(re.errorMessages.missedDocument);return this.model.delete(this.document.id)}queryDocs(t){let s=this.model.find();return t&&(s=s.limit(t)),s}findDocs(t){}async setFilter(t){return this._filter=t,this.onChangeHdl.notify({action:"filterChange"}),this}resetFilter(){return this._filter=void 0,this.onChangeHdl.notify({action:"filterChange"}),this}onChange(t){return this.onChangeHdl.subscribe(t)}onError(t){return this.onErrorHdl.subscribe(t)}notifyChange(t){this.onChangeHdl.notify(t)}newDocument(){return this.setDocument(this.createDocument())}async storeDocument(){const t="Saving main document";try{this.progressController.notifyBusy(!0,t),await this.storeDoc(),this.onChangeHdl.notify({documentCollection:await this.documentCollection(),action:"saved"})}catch(s){if(this.onChangeHdl.notify({error:this.errorToError(s)}),this.onErrorHdl.notify(this.errorToError(s)),this.throwOnError)throw s}finally{this.progressController.notifyBusy(!1,t)}}async deleteDocument(){const t="Delete main document";try{this.progressController.notifyBusy(!0,t),await this.deleteDoc(),this.onChangeHdl.notify({documentCollection:await this.documentCollection(),action:"deleted"})}catch(s){if(this.onChangeHdl.notify({error:this.errorToError(s)}),this.onErrorHdl.notify(this.errorToError(s)),this.throwOnError)throw s}finally{this.progressController.notifyBusy(!1,t)}}async documentCollection(t){const s="Retrieving document collection";let l=[];try{this.progressController.notifyBusy(!0,s);const c=this.findDocs(t);c?l=await c:l=await this.queryDocs(t).get()}catch(c){if(this.onChangeHdl.notify({error:this.errorToError(c)}),this.onErrorHdl.notify(this.errorToError(c)),this.throwOnError)throw c}finally{this.progressController.notifyBusy(!1,s)}return l}filter(t){return t.filter(s=>{var l;return((l=this._filter)==null?void 0:l.call(this,s))??!0})}onProgress(t){return this.progressController.onProgress(t)}get model(){return this._model||(this._model=this.getModel())}setDocument(t){return this._document!==t&&(this.unsubscribeDocument&&this.unsubscribeDocument(),t&&(this.unsubscribeDocument=t.onChange(s=>this.onChangeHdl.notify({documentProps:s}))),this._document=t,this.onChangeHdl.notify({documentChanged:this._document})),this}set document(t){this.setDocument(t)}get document(){return this._document}managedThrow(t){if(this.onChangeHdl.notify({error:this.errorToError(t)}),this.onErrorHdl.notify(this.errorToError(t)),this.throwOnError)throw this.errorToError(t)}errorToError(t){return t instanceof Error?t:typeof t=="string"?new Error(t):"code"in t?new Error(t.code):"message"in t?new Error(t.error):new Error(JSON.stringify(t))}get throwOnError(){return this.onErrorHdl.subscribersCount===0}};re.errorMessages={missedDocument:"No document to save"};let xe=re;function cr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var We={exports:{}},g={};/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react.production.min.js
|
|
10
10
|
*
|
|
@@ -43,3 +43,4 @@ Check the render method of \``+e+"`."}return""}function on(e){if(e!==void 0){var
|
|
|
43
43
|
Check your code at `+r+":"+i+"."}return""}function sn(e){return e!=null?on(e.__source):""}var Nt={};function an(e){var r=It();if(!r){var i=typeof e=="string"?e:e.displayName||e.name;i&&(r=`
|
|
44
44
|
|
|
45
45
|
Check the top-level render call using <`+i+">.")}return r}function Ft(e,r){if(!(!e._store||e._store.validated||e.key!=null)){e._store.validated=!0;var i=an(r);if(!Nt[i]){Nt[i]=!0;var a="";e&&e._owner&&e._owner!==L.current&&(a=" It was passed a child from "+Z(e._owner.type)+"."),pe(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,a),pe(null)}}}function $t(e,r){if(typeof e=="object"){if(Te(e))for(var i=0;i<e.length;i++){var a=e[i];de(a)&&Ft(a,r)}else if(de(e))e._store&&(e._store.validated=!0);else if(e){var u=ce(e);if(typeof u=="function"&&u!==e.entries)for(var p=u.call(e),d;!(d=p.next()).done;)de(d.value)&&Ft(d.value,r)}}}function Mt(e){{var r=e.type;if(r==null||typeof r=="string")return;var i;if(typeof r=="function")i=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===z||r.$$typeof===W))i=r.propTypes;else return;if(i){var a=Z(r);nn(i,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!Xe){Xe=!0;var u=Z(r);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function un(e){{for(var r=Object.keys(e.props),i=0;i<r.length;i++){var a=r[i];if(a!=="children"&&a!=="key"){pe(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),pe(null);break}}e.ref!==null&&(pe(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),pe(null))}}function Lt(e,r,i){var a=Et(e);if(!a){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var p=sn(r);p?u+=p:u+=It();var d;e===null?d="null":Te(e)?d="array":e!==void 0&&e.$$typeof===l?(d="<"+(Z(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,h("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,u)}var m=Er.apply(this,arguments);if(m==null)return m;if(a)for(var b=2;b<arguments.length;b++)$t(arguments[b],e);return e===y?un(m):Mt(m),m}var Ut=!1;function cn(e){var r=Lt.bind(null,e);return r.type=e,Ut||(Ut=!0,X("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.")),Object.defineProperty(r,"type",{enumerable:!1,get:function(){return X("Factory.type is deprecated. Access the class directly before passing it to createFactory."),Object.defineProperty(this,"type",{value:e}),e}}),r}function ln(e,r,i){for(var a=wr.apply(this,arguments),u=2;u<arguments.length;u++)$t(arguments[u],a.type);return Mt(a),a}function fn(e,r){var i=G.transition;G.transition={};var a=G.transition;G.transition._updatedFibers=new Set;try{e()}finally{if(G.transition=i,i===null&&a._updatedFibers){var u=a._updatedFibers.size;u>10&&X("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."),a._updatedFibers.clear()}}}var Vt=!1,Me=null;function dn(e){if(Me===null)try{var r=("require"+Math.random()).slice(0,7),i=n&&n[r];Me=i.call(n,"timers").setImmediate}catch{Me=function(u){Vt===!1&&(Vt=!0,typeof MessageChannel>"u"&&h("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var p=new MessageChannel;p.port1.onmessage=u,p.port2.postMessage(void 0)}}return Me(e)}var he=0,xt=!1;function pn(e){{var r=he;he++,A.current===null&&(A.current=[]);var i=A.isBatchingLegacy,a;try{if(A.isBatchingLegacy=!0,a=e(),!i&&A.didScheduleLegacyUpdate){var u=A.current;u!==null&&(A.didScheduleLegacyUpdate=!1,tt(u))}}catch(T){throw Le(r),T}finally{A.isBatchingLegacy=i}if(a!==null&&typeof a=="object"&&typeof a.then=="function"){var p=a,d=!1,m={then:function(T,j){d=!0,p.then(function(N){Le(r),he===0?Ze(N,T,j):T(N)},function(N){Le(r),j(N)})}};return!xt&&typeof Promise<"u"&&Promise.resolve().then(function(){}).then(function(){d||(xt=!0,h("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),m}else{var b=a;if(Le(r),he===0){var C=A.current;C!==null&&(tt(C),A.current=null);var S={then:function(T,j){A.current===null?(A.current=[],Ze(b,T,j)):T(b)}};return S}else{var O={then:function(T,j){T(b)}};return O}}}}function Le(e){e!==he-1&&h("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),he=e}function Ze(e,r,i){{var a=A.current;if(a!==null)try{tt(a),dn(function(){a.length===0?(A.current=null,r(e)):Ze(e,r,i)})}catch(u){i(u)}else r(e)}}var et=!1;function tt(e){if(!et){et=!0;var r=0;try{for(;r<e.length;r++){var i=e[r];do i=i(!0);while(i!==null)}e.length=0}catch(a){throw e=e.slice(r+1),a}finally{et=!1}}}var hn=Lt,mn=ln,yn=cn,vn={map:Ae,forEach:Dr,count:Or,toArray:Tr,only:kr};t.Children=vn,t.Component=_,t.Fragment=y,t.Profiler=F,t.PureComponent=$,t.StrictMode=D,t.Suspense=H,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,t.cloneElement=mn,t.createContext=jr,t.createElement=hn,t.createFactory=yn,t.createRef=pr,t.forwardRef=Fr,t.isValidElement=de,t.lazy=Nr,t.memo=$r,t.startTransition=fn,t.unstable_act=pn,t.useCallback=Hr,t.useContext=Mr,t.useDebugValue=qr,t.useDeferredValue=Gr,t.useEffect=xr,t.useId=Jr,t.useImperativeHandle=zr,t.useInsertionEffect=Wr,t.useLayoutEffect=Yr,t.useMemo=Br,t.useReducer=Ur,t.useRef=Vr,t.useState=Lr,t.useSyncExternalStore=Qr,t.useTransition=Kr,t.version=s,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}(ve,ve.exports)),ve.exports}process.env.NODE_ENV==="production"?We.exports=lr():We.exports=fr();var ue=We.exports;const V=cr(ue);class dr extends ue.Component{constructor(t){super(t),this.unfilteredDocuments=[],this.state={documents:[],mode:0}}async componentDidMount(){const{controller:t}=this.props;this.unsubscriber=t.onChange(s=>{s.documentCollection&&(this.unfilteredDocuments=s.documentCollection,this.setState({documents:t.filter(this.unfilteredDocuments)})),s.action==="filterChange"?this.setState({documents:t.filter(this.unfilteredDocuments)}):this.setState({})}),this.unfilteredDocuments=await t.documentCollection(),this.setState({documents:t.filter(this.unfilteredDocuments)})}componentWillUnmount(){var t;(t=this.unsubscriber)==null||t.call(this)}newDocument(){this.props.controller.newDocument(),this.setState({mode:1})}editDocument(t){this.props.controller.setDocument(t),this.setState({mode:2})}async storeDocument(t){const{controller:s,layout:l}=this.props;s.setDocument(t),await s.storeDocument(),l==="formAndItems"?this.newDocument():this.setState({mode:0})}invokeContentViewChild(t){const{children:s,layout:l,controller:c}=this.props,{mode:y}=this.state,D=l!=="formAndItems";if(!c.document)return;const F={controller:c,submitButtonCaption:y==2?t==null?void 0:t.updateButtonLabel:t==null?void 0:t.addButtonLabel,onSubmit:x=>this.storeDocument(x),onCancel:D?()=>this.setState({mode:0}):()=>this.newDocument()};return typeof s[0]=="function"?ue.cloneElement(s[0](F),{key:c.document.id}):ue.cloneElement(s[0],{key:c.document.id,...F})}invokeDetailViewChild(t){const{children:s,controller:l}=this.props,c={document:t,onSelect:y=>this.editDocument(y),onDelete:y=>l.setDocument(y).deleteDocument()};return typeof s[1]=="function"?ue.cloneElement(s[1](c),{key:t.id}):ue.cloneElement(s[1],{key:t.id,...c})}render(){var W;const{mode:t,documents:s}=this.state,{className:l,cardAddButton:c,controller:y}=this.props,D=ar((W=y.document)==null?void 0:W.className);let F=this.props.labels||{};const x=this.props.layout||"itemsAlways";typeof F=="function"&&(F=F(y));const{addNewDocumentLabel:B,singularDocumentInCollectionCaption:z,documentsInCollectionCaption:H,noDocumentsFoundLabel:ne}=F;return V.createElement("div",{className:`crud-panel ${D} ${l||""}`},t===0&&x!=="formAndItems"&&!c&&V.createElement("div",{className:"header"},this.props.header?typeof this.props.header=="function"?this.props.header(y,()=>this.newDocument(),F):this.props.header:V.createElement("button",{onClick:()=>this.newDocument()},B)),(x==="formAndItems"||t===1||t===2)&&V.createElement("div",{className:"content-panel"},this.invokeContentViewChild(F)),(x==="itemsAlways"||x==="formAndItems"||t===0)&&V.createElement("div",{className:"collection-panel"},(s==null?void 0:s.length)>0&&V.createElement("h3",null,s.length>1?H:z||H),V.createElement("div",{className:"documents"},c&&V.createElement("div",{className:"crud-card card-add-button clickable",onClick:()=>this.newDocument()},V.createElement("div",{className:"button-element"},c),V.createElement("div",{className:"add-label"},B)),s!=null&&s.length?s.map(q=>this.invokeDetailViewChild(q)):V.createElement("p",null,ne))),V.createElement("div",{className:"footer"},this.props.footer&&typeof this.props.footer=="function"?this.props.footer(y,()=>this.newDocument(),F):this.props.footer))}}ee.CrudController=xe,ee.CrudPanel=dr,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
|
|
46
|
+
//# sourceMappingURL=entropic-bond-crud-panel.umd.cjs.map
|