@donotdev/crud 0.1.42 → 0.1.44
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.
- package/dist/CrudService.bulk.js +1 -1
- package/dist/CrudService.bulkAcross.js +1 -1
- package/dist/CrudService.cache.js +1 -1
- package/dist/CrudService.internal.js +2 -2
- package/dist/CrudService.mutations.js +1 -1
- package/dist/CrudService.optimistic.js +1 -1
- package/dist/CrudService.queries.js +1 -1
- package/dist/CrudService.subscriptions.js +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.d.ts.map +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.js +1 -1
- package/dist/components/DisplayThumbnail.js +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/YearFilter.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledRadioField.js +1 -1
- package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
- package/dist/components/controlled/types.js +1 -1
- package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
- package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
- package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
- package/dist/components/fields/display/DateFieldDisplay.js +1 -1
- package/dist/components/fields/display/DropdownDisplay.js +1 -1
- package/dist/components/fields/display/FileFieldDisplay.js +1 -1
- package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
- package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
- package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
- package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
- package/dist/components/fields/display/MapFieldDisplay.js +1 -1
- package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
- package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
- package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
- package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
- package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
- package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
- package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
- package/dist/components/fields/display/TextAreaDisplay.js +1 -1
- package/dist/components/fields/display/TextFieldDisplay.js +1 -1
- package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
- package/dist/components/fields/display/index.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.d.ts +12 -10
- package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/AddressFieldComponent.js +1 -1
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
- package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
- package/dist/components/form/fields/ComboboxComponent.js +1 -1
- package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/DurationFieldComponent.js +1 -1
- package/dist/components/form/fields/FileFieldComponent.js +1 -1
- package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
- package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MapFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/PriceFieldComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/RatingFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
- package/dist/components/form/internal/ImageViewerDialog.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/fieldTypeRegistry.store.js +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/isFieldEditable.js +1 -1
- package/dist/forms/utils/translateFieldLabel.js +1 -1
- package/dist/forms/utils/validateEntity.js +1 -1
- package/dist/hooks/useCrudFilters.js +1 -1
- package/dist/hooks/useCrudPageSize.js +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useFieldConditions.js +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useReferenceResolver.js +1 -1
- package/dist/hooks/useRelatedItems.js +1 -1
- package/dist/index.js +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/UploadStore.js +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/clientListProcessing.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.js +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/sanitizeHtml.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/package.json +3 -3
package/dist/useBaseCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as P,useCallback as X,useRef as Q,useState as Z,useEffect as $}from"react";import{useQuery as ee}from"@donotdev/core";import{useCrudStore as te}from"./CrudStore";import{CRUD_OPERATION as R}from"./types";import{useCrud as V,getCrudServiceInstance as
|
|
1
|
+
import{useMemo as P,useCallback as X,useRef as Q,useState as Z,useEffect as $}from"react";import{useQuery as ee}from"@donotdev/core";import{useCrudStore as te}from"./CrudStore";import{CRUD_OPERATION as R}from"./types";import{useCrud as V,getCrudServiceInstance as se,EMPTY_OPTIMISTIC as re}from"./useCrud";import{mergeWithOptimistic as ie}from"./utils/mergeWithOptimistic";import{injectScopeFilter as ae,getCurrentScopeValue as oe}from"./utils/scopeUtils";const ne=1e3;function le(j,f,t,g={}){const K=g.enabled??!0,b=V("status"),c=b==="ready",k=V(j,g),{error:L,invalidate:_,_collection:p,_schemas:v,_cacheOptions:y,_scope:M}=k,T=te(e=>e.collections[p]?.optimistic||re),q=Q(new Map([[1,null]])),S=Q(0),[E,x]=Z(!1),o=t?.mode==="auto"?E?"server":"client":t?.mode??"client",B=oe(M),O=P(()=>{if(!c||!v)return null;const e=se();if(!e)return null;const h=f==="listCard"?v.listCard:v.list,n=ae(g.queryOptions,M);if(!t)return e.getListQueryOptions(p,n,h,y,f);if(o==="client"){const l=t.mode==="auto"&&!n?.limit?{...n,limit:ne}:n;return e.getListQueryOptions(p,l,h,y,f)}const u=q.current,m=S.current,{page:d,pageSize:s}=t;let i,r;if(u.has(d))i=u.get(d)??void 0,r=s;else if(d>m&&u.has(m)){const l=d-m;i=u.get(m)??void 0,r=l*s}else i=void 0,r=d*s;return e.getListQueryOptions(p,{...n,limit:r,startAfter:i},h,y,f)},[c,p,y,v?"hasSchema":"noSchema",f,o,t?.page,t?.pageSize,g.queryOptions,M?.provider,B]),{data:a,isLoading:N,isFetching:U,error:W,refetch:w}=ee({queryKey:O?.queryKey??["crud",p,"disabled"],queryFn:O?.queryFn??(()=>Promise.resolve({items:[]})),staleTime:O?.staleTime,enabled:K&&!!O});$(()=>{t?.mode==="auto"&&!E&&a&&a.total!=null&&a.total>a.items.length&&x(!0)},[a,t?.mode,E]);const A=P(()=>{if(!a||!c)return{items:[],total:void 0};let e=a.items;if(o==="server"&&t&&e.length>0){const s=q.current,i=S.current,{page:r,pageSize:l}=t,G=e.length;if(Math.ceil(G/l)>1||r>i){const D=s.has(r)?r:i+1;for(let C=D;C<=r;C++){const F=(C-D+1)*l-1;if(F<e.length){const J=e[F];s.set(C+1,J.id)}}}a.lastVisible&&s.set(r+1,a.lastVisible),S.current=Math.max(i,r);const z=s.has(r)?0:(r-i-1)*l,H=z+l;e=e.slice(z,H)}const h=ie(e,T),n=new Set(e.map(s=>s.id));let u=0,m=0;for(const[s,i]of Object.entries(T))i.operation===R.ADD&&!n.has(s)?u++:i.operation===R.DELETE&&n.has(s)&&m++;const d=(a.total??e.length)+u-m;return{items:h,total:d}},[a,T,c,o,t?.page,t?.pageSize]),I=X(async()=>{c&&(o==="server"&&(q.current=new Map([[1,null]]),S.current=0),await _(),await w())},[_,w,c,o]);if(!c){const e=async()=>{};return{status:b,data:{items:[],total:void 0},items:[],loading:!0,fetching:!1,error:L,mutate:e,refresh:e,isAvailable:!1,effectiveMode:o}}const Y=A?.items??[];return{status:b,data:A,items:Y,loading:N,fetching:U,error:W??L,mutate:I,refresh:I,isAvailable:!0,effectiveMode:o}}export{le as useBaseCrudList};
|
package/dist/useCrud.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as K,useMemo as k,useCallback as i}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as W,FEATURE_STATUS as f,handleError as Z,isClient as B,createSchemas as H,DEGRADED_CRUD_API as J,getGlobalSingleton as Q}from"@donotdev/core";import{getCrudService as V}from"./CrudService";import{useCrudStore as u}from"./CrudStore";import{injectScope as C,injectScopeFilter as X}from"./utils/scopeUtils";const $={},ee={};function w(){return Q("crud-service",()=>({service:null,initPromise:null,errorNotified:!1}))}function c(){return w().service}function te(l,d={}){const p=L(W.CRUD),F=u(e=>e.crudService),y=p&&!F,v=p?y?f.INITIALIZING:f.READY:f.DEGRADED,S=l==="status",b=!S&&typeof l=="object"?l:d.entity,a=S?"__status__":typeof l=="string"?l:l.collection,
|
|
1
|
+
"use client";import{useEffect as K,useMemo as k,useCallback as i}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as W,FEATURE_STATUS as f,handleError as Z,isClient as B,createSchemas as H,DEGRADED_CRUD_API as J,getGlobalSingleton as Q}from"@donotdev/core";import{getCrudService as V}from"./CrudService";import{useCrudStore as u}from"./CrudStore";import{injectScope as C,injectScopeFilter as X}from"./utils/scopeUtils";const $={},ee={};function w(){return Q("crud-service",()=>({service:null,initPromise:null,errorNotified:!1}))}function c(){return w().service}function te(l,d={}){const p=L(W.CRUD),F=u(e=>e.crudService),y=p&&!F,v=p?y?f.INITIALIZING:f.READY:f.DEGRADED,S=l==="status",b=!S&&typeof l=="object"?l:d.entity,a=S?"__status__":typeof l=="string"?l:l.collection,o=b?.scope,_=d.noCache??!1,g=d.staleTime,m=k(()=>({noCache:_,staleTime:g}),[_,g]),t=k(()=>{if(!S){if(d.schema){const e=d.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(b)return H(b)}},[S,d.schema,b?.name,a]),M=u(e=>e.collections[a]?.loading||!1),A=u(e=>e.collections[a]?.error||null),N=null;K(()=>{if(!B()||!p||!t)return;const{crudService:e}=u.getState(),s=w();e||s.service||s.initPromise||(s.initPromise=(async()=>{try{if(s.service||u.getState().crudService)return;const r=V();s.service=r,r.setStore(u),await r.initialize(),s.errorNotified=!1,u.getState().setCrudService(r)}catch(r){s.errorNotified||(Z(r,{userMessage:"Failed to initialize CRUD service.",context:{collection:a},severity:"error"}),s.errorNotified=!0)}finally{s.initPromise=null}})())},[p,a,t?"hasSchema":"noSchema"]);const E=y||M,U=v===f.READY,Y=i(async e=>{const s=c();return!s||!t?null:s.get(a,e,t.get,m)},[a,t?"hasSchema":"noSchema",m]),G=i(async(e,s,r)=>{const n=c();if(!n||!t)return;const h=C(s,o),z=h?.status==="draft"?t.draft:t.create;await n.set(a,e,h,z,r)},[a,t?"hasSchema":"noSchema",o?.provider]),O=i(async(e,s,r)=>{const n=c();n&&await n.update(a,e,s,t?.update,r)},[a,t]),j=i(async(e,s)=>{const r=c();r&&await r.delete(a,e,s)},[a]),q=i(async(e,s)=>{const r=c();if(!r||!t)return"";const n=C(e,o),h=n?.status==="draft"?t.draft:t.create;return r.add(a,n,h,s)},[a,t?"hasSchema":"noSchema",o?.provider]),T=i(async(e,s)=>{const r=c();return r?r.bulkAcross(e,s):{results:{}}},[]),D=i(async(e,s)=>{const r=c();if(!r||!t)return{insertedIds:[],updatedIds:[],deletedIds:[]};const n={inserts:e.inserts?.map(h=>C(h,o)),updates:e.updates,deletes:e.deletes};return r.bulk(a,n,{create:t.create,draft:t.draft,update:t.update},s)},[a,t?"hasSchema":"noSchema",o?.provider]),x=i(async e=>{const s=c();if(!s||!t)return[];const r=X(e,o);return(await s.query(a,r,t.list,m)).items},[a,t?"hasSchema":"noSchema",m,o?.provider]),I=i((e,s)=>{const r=c();return!r||!t?()=>{}:r.subscribe(a,e,s,t.get)},[a,t?"hasSchema":"noSchema"]),R=i((e,s)=>{const r=c();return!r||!t?()=>{}:r.subscribeToCollection(a,e,s,t.list)},[a,t?"hasSchema":"noSchema"]),P=i(async()=>{const e=c();e&&await e.invalidateCollection(a)},[a]);return S?v:U?{status:f.READY,data:N,loading:E,error:A,get:Y,set:G,update:O,delete:j,add:q,bulk:D,bulkAcross:T,query:x,subscribe:I,subscribeToCollection:R,invalidate:P,isAvailable:!0,_collection:a,_schemas:t,_cacheOptions:m,_scope:o}:{...J,status:v,loading:E,error:A,subscribe:I,subscribeToCollection:R,invalidate:P,bulk:D,bulkAcross:T,_collection:a,_schemas:t,_cacheOptions:m,_scope:o}}export{$ as EMPTY_DATA,ee as EMPTY_OPTIMISTIC,c as getCrudServiceInstance,te as useCrud};
|
package/dist/useCrudCardList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as d}from"react";import{useCrudFilters as p}from"./hooks/useCrudFilters";import{useBaseCrudList as f}from"./useBaseCrudList";import{applyFilters as h,applySearch as y,applySort as g}from"./utils/clientListProcessing";function C(
|
|
1
|
+
import{useMemo as d}from"react";import{useCrudFilters as p}from"./hooks/useCrudFilters";import{useBaseCrudList as f}from"./useBaseCrudList";import{applyFilters as h,applySearch as y,applySort as g}from"./utils/clientListProcessing";function C(l,t={}){const o={enabled:t.enabled,queryOptions:t.queryOptions,schema:t.schema,entity:t.entity,staleTime:t.staleTime,noCache:t.noCache},e=f(l,"listCard",null,o),s=typeof l=="string"?null:l,n=s?.collection??l,{filters:a}=p({collection:n}),i=t.clientSort===null?null:t.clientSort??s?.defaultSort??null,{processed:u,filteredTotal:c}=d(()=>{let r=e.items;s&&Object.keys(a).length>0&&(r=h(r,a,s)),s&&t.searchQuery&&(r=y(r,t.searchQuery,s));const m=r.length;return i&&(r=g(r,i)),{processed:r,filteredTotal:m}},[e.items,a,t.searchQuery,i,s]);return{status:e.status,data:e.data?{items:e.data.items}:null,items:e.items,processed:u,filteredTotal:c,loading:e.loading,fetching:e.fetching,error:e.error,mutate:e.mutate,refresh:e.refresh,isAvailable:e.isAvailable}}export{C as useCrudCardList};
|
package/dist/useCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as h}from"react";import{useCrudFilters as g}from"./hooks/useCrudFilters";import{useBaseCrudList as S}from"./useBaseCrudList";import{applyFilters as
|
|
1
|
+
import{useMemo as h}from"react";import{useCrudFilters as g}from"./hooks/useCrudFilters";import{useBaseCrudList as S}from"./useBaseCrudList";import{applyFilters as C,applySearch as T,applySort as b}from"./utils/clientListProcessing";function Q(l,e={}){const i=e.pagination??"auto",n=e.page??1,p=e.pageSize??10,c={mode:i,page:n,pageSize:p},u={enabled:e.enabled,queryOptions:e.queryOptions,schema:e.schema,entity:e.entity,staleTime:e.staleTime,noCache:e.noCache},o=S(l,"list",c,u),r=typeof l=="string"?null:l,m=r?.collection??l,{filters:s}=g({collection:m}),a=e.clientSort===null?null:e.clientSort??r?.defaultSort??null,{processed:d,filteredTotal:y}=h(()=>{let t=o.items;r&&Object.keys(s).length>0&&(t=C(t,s,r)),r&&e.searchQuery&&(t=T(t,e.searchQuery,r));const f=t.length;return a&&(t=b(t,a)),{processed:t,filteredTotal:f}},[o.items,s,e.searchQuery,a,r]);return{...o,processed:d,filteredTotal:y}}export{Q as useCrudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,r,l){const i=Object.entries(r);return i.length===0?t:t.filter(n=>i.every(([
|
|
1
|
+
import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,r,l){const i=Object.entries(r);return i.length===0?t:t.filter(n=>i.every(([s,c])=>{const e=l.fields[s]?.type||"text";return u(n[s],c,e)}))}function a(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const r=new Set(["string"]),l=[];for(const[i,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const s=f(n.type);s&&r.has(s)&&l.push(i)}return l}function p(t,r,l){if(!r||r.trim()==="")return t;const i=r.toLowerCase(),n=a(l);return n.length===0?t.filter(s=>Object.values(s).some(c=>c==null?!1:String(c).toLowerCase().includes(i))):t.filter(s=>n.some(c=>{const e=s[c];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(i):String(e).toLowerCase().includes(i)}))}function m(t,r){if(typeof r=="function")return[...t].sort(r);const{field:l,direction:i="asc"}=r,n=i==="desc"?-1:1;return[...t].sort((s,c)=>{const e=s[l],o=c[l];return e==null&&o==null?0:e==null?1:o==null?-1:typeof e=="number"&&typeof o=="number"?(e-o)*n:typeof e=="object"&&"amount"in e&&typeof o=="object"&&"amount"in o?(e.amount-o.amount)*n:e instanceof Date&&o instanceof Date?(e.getTime()-o.getTime())*n:String(e).localeCompare(String(o))*n})}export{d as applyFilters,p as applySearch,m as applySort,a as getSearchableFields};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCrudService as
|
|
1
|
+
import{getCrudService as i}from"../CrudService";async function p(o,t){const a=i(),e=[],s=t.range?.start??1,r=t.range?.end??28;for(let c=s;c<=r;c++){const m=String(c),n=await a.get(t.path(o),m,t.schema);n&&e.push(n)}return e}async function d(o,t,a){const e=i();for(const s of a){const r=t.idOf(s);await e.set(t.path(o),r,s,t.schema)}}async function h(o,t,a){const e=i();if(t.idFrom){const s=t.idFrom(a);return e.set(t.path(o),s,a,t.schema)}return e.add(t.path(o),a,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{handleError as d,getProvider as u}from"@donotdev/core";function h(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function f(e,t={}){const{storagePath:r,filename:n,onProgress:o,signal:s}=t,i=Date.now(),c=h(e.name),a=n||`${i}_${c}`,l=r?`${r}/${a}`:a;try{return{url:(await u("storage").upload(e,{storagePath:r,filename:a,onProgress:o?p=>o({bytesTransferred:0,totalBytes:0,progress:p}):void 0,signal:s})).url,filename:e.name,size:e.size,mimeType:e.type,uploadedAt:new Date().toISOString()}}catch(p){throw d(p,{userMessage:"Failed to upload file",severity:"error",context:{filename:e.name,fileSize:e.size}})}}async function w(e,t={}){const r=[],n=e.reduce((s,i)=>s+i.size,0);let o=0;for(const s of e){if(t.signal?.aborted)throw new Error("Upload cancelled");const i=t.onProgress?a=>{const l=a.bytesTransferred/a.totalBytes*s.size;t.onProgress({bytesTransferred:o+l,totalBytes:n,progress:(o+l)/n*100})}:void 0,c=await f(s,{...t,onProgress:i});r.push(c),o+=s.size}return r}async function v(e){try{await u("storage").delete(e.url)}catch(t){throw d(t,{userMessage:"Failed to delete file",severity:"error",context:{url:e.url,filename:e.filename}}),t}}function y(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function m(e){const t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function M(e,t){const r=t?m(t):"";if(e){if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";if(e==="application/pdf")return"pdf";if(e.includes("word")||e.includes("document"))return"doc";if(e.includes("excel")||e.includes("spreadsheet"))return"xls";if(e.includes("powerpoint")||e.includes("presentation"))return"ppt"}switch(r){case"pdf":return"pdf";case"doc":case"docx":return"doc";case"xls":case"xlsx":case"csv":return"xls";case"ppt":case"pptx":return"ppt";case"md":case"txt":return"text";case"html":case"htm":return"html";case"zip":case"rar":case"7z":return"archive";default:return"file"}}function
|
|
1
|
+
"use client";import{handleError as d,getProvider as u}from"@donotdev/core";function h(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function f(e,t={}){const{storagePath:r,filename:n,onProgress:o,signal:s}=t,i=Date.now(),c=h(e.name),a=n||`${i}_${c}`,l=r?`${r}/${a}`:a;try{return{url:(await u("storage").upload(e,{storagePath:r,filename:a,onProgress:o?p=>o({bytesTransferred:0,totalBytes:0,progress:p}):void 0,signal:s})).url,filename:e.name,size:e.size,mimeType:e.type,uploadedAt:new Date().toISOString()}}catch(p){throw d(p,{userMessage:"Failed to upload file",severity:"error",context:{filename:e.name,fileSize:e.size}})}}async function w(e,t={}){const r=[],n=e.reduce((s,i)=>s+i.size,0);let o=0;for(const s of e){if(t.signal?.aborted)throw new Error("Upload cancelled");const i=t.onProgress?a=>{const l=a.bytesTransferred/a.totalBytes*s.size;t.onProgress({bytesTransferred:o+l,totalBytes:n,progress:(o+l)/n*100})}:void 0,c=await f(s,{...t,onProgress:i});r.push(c),o+=s.size}return r}async function v(e){try{await u("storage").delete(e.url)}catch(t){throw d(t,{userMessage:"Failed to delete file",severity:"error",context:{url:e.url,filename:e.filename}}),t}}function y(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function m(e){const t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function M(e,t){const r=t?m(t):"";if(e){if(e.startsWith("image/"))return"image";if(e.startsWith("video/"))return"video";if(e.startsWith("audio/"))return"audio";if(e==="application/pdf")return"pdf";if(e.includes("word")||e.includes("document"))return"doc";if(e.includes("excel")||e.includes("spreadsheet"))return"xls";if(e.includes("powerpoint")||e.includes("presentation"))return"ppt"}switch(r){case"pdf":return"pdf";case"doc":case"docx":return"doc";case"xls":case"xlsx":case"csv":return"xls";case"ppt":case"pptx":return"ppt";case"md":case"txt":return"text";case"html":case"htm":return"html";case"zip":case"rar":case"7z":return"archive";default:return"file"}}function z(e){if(e===0)return"0 B";const t=1024,r=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,n)).toFixed(1))} ${r[n]}`}const g=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/markdown","text/html","text/csv"],x=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"];function F(){return[...g,...x].join(",")}export{x as DOCUMENT_EXTENSIONS,g as DOCUMENT_MIME_TYPES,v as deleteFile,z as formatFileSize,y as generateFileId,F as getDocumentAcceptString,m as getFileExtension,M as getFileIcon,f as uploadFile,w as uploadFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const F=new WeakMap;function W(t){return JSON.stringify({maxWidth:t.maxWidth,maxHeight:t.maxHeight,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,aspectRatio:t.aspectRatio,quality:t.quality,crop:t.crop})}async function H(t,a={}){const
|
|
1
|
+
const F=new WeakMap;function W(t){return JSON.stringify({maxWidth:t.maxWidth,maxHeight:t.maxHeight,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,aspectRatio:t.aspectRatio,quality:t.quality,crop:t.crop})}async function H(t,a={}){const n=W(a),h=F.get(t);if(h?.has(n))return h.get(n);const{maxWidth:d=1920,maxHeight:e=1440,thumbWidth:i=300,thumbHeight:o=225,aspectRatio:l=4/3,quality:m=.85,crop:r}=a;return new Promise((g,c)=>{const s=new Image,w=new FileReader;w.onload=u=>{s.src=u.target?.result},w.onerror=()=>c(new Error("Failed to read file")),s.onload=async()=>{try{const{width:u,height:f}=M(r?r.width:s.width,r?r.height:s.height,d,e,l),y=await x(s,u,f,l,m,r),v=await x(s,i,o,l,.65,r),p={fullBlob:y,thumbBlob:v,width:u,height:f};let b=F.get(t);b||(b=new Map,F.set(t,b)),b.set(n,p),g(p)}catch(u){c(u)}},s.onerror=()=>c(new Error("Failed to load image")),w.readAsDataURL(t)})}function M(t,a,n,h,d){let e=t,i=a;e>n&&(i=n/e*i,e=n),i>h&&(e=h/i*e,i=h);const o=e/i;return Math.abs(o-d)>.01&&(o>d?i=e/d:e=i*d),{width:Math.round(e),height:Math.round(i)}}async function x(t,a,n,h,d,e){const i=document.createElement("canvas"),o=i.getContext("2d");if(!o)throw new Error("Failed to get canvas context");i.width=a,i.height=n,o.fillStyle="#FFFFFF",o.fillRect(0,0,a,n);let l,m,r,g;if(e)l=e.x,m=e.y,r=e.width,g=e.height;else{const c=t.width/t.height;r=t.width,g=t.height,l=0,m=0,c>h?(r=t.height*h,l=(t.width-r)/2):c<h&&(g=t.width/h,m=(t.height-g)/2)}return o.drawImage(t,l,m,r,g,0,0,a,n),new Promise((c,s)=>{i.toBlob(w=>{w?c(w):s(new Error("Failed to convert canvas to blob"))},"image/webp",d)})}function E(t,a){return t.type.startsWith("image/")?a&&t.size>a?{valid:!1,error:`File size exceeds ${(a/1048576).toFixed(1)}MB limit`}:{valid:!0}:{valid:!1,error:"File must be an image"}}export{H as processImage,E as validateImageFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFilterType as N}from"../fieldTypeRegistry.store";function S(
|
|
1
|
+
import{getFilterType as N}from"../fieldTypeRegistry.store";function S(t,n,e){if(!n)return!0;if(Array.isArray(n)){if(n.length===0)return!0;if(!(N(e)==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return n.some(a=>{if(typeof a=="object"&&"date"in a){const D=a.date;if(t==null)return!1;const m=t instanceof Date?t:new Date(t);return isNaN(m.getTime())?!1:m.toISOString().split("T")[0]===D}return String(t)===String(a)});if(t==null)return!1;const i=t instanceof Date?t:new Date(t);if(isNaN(i.getTime()))return!1;const o=i.toISOString().split("T")[0];return n.some(a=>typeof a=="string"?o===a:typeof a=="object"&&"date"in a?o===a.date:!1)}if(typeof n=="object"&&"date"in n&&!("min"in n)&&!Array.isArray(n)){if(!(N(e)==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp")))return!1;const i=n.date;if(!i)return!0;if(t==null)return!1;const o=t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0];if((e==="datetime-local"||e==="timestamp")&&n.time){const a=t instanceof Date?t.toISOString().slice(11,16):new Date(t).toISOString().slice(11,16);return o===i&&a===n.time}return o===i}if(typeof n=="object"&&"min"in n){const i=N(e);if(!i)return!0;const o=i==="range"&&(e==="date"||e==="datetime-local"||e==="timestamp"),a=i==="range"&&!o,D=e==="price",m=D&&t!=null&&typeof t=="object"?Number(t.amount):a&&t!=null?typeof t=="number"?t:Number(t):NaN;if(a||D){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min)return!1;const r=n,c=typeof r.min=="string"&&r.min!=="",g=typeof r.max=="string"&&r.max!=="";return c&&!g?t==null||isNaN(m)?!1:m>=Number(r.min):!c&&g?t==null?!0:isNaN(m)?!1:m<=Number(r.max):c&&g?t==null||isNaN(m)?!1:m>=Number(r.min)&&m<=Number(r.max):!0}if(o){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min&&!("min"in n.min)){const s=n,l=s.min,u=s.max,w=l?.date&&l.date!=="",y=u?.date&&u.date!=="";if(w&&!y){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00"));return f>=d}if(!w&&y&&u){if(t==null)return!0;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f<=d}if(w&&y&&u){if(t==null)return!1;const f=t instanceof Date?t:new Date(t);if(isNaN(f.getTime()))return!1;const d=new Date(l.date+(l.time?`T${l.time}:00`:"T00:00:00")),T=new Date(u.date+(u.time?`T${u.time}:00`:"T23:59:59"));return f>=d&&f<=T}return!0}const r=n,c=typeof r.min=="string"&&r.min!=="",g=typeof r.max=="string"&&r.max!=="";if(c&&!g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(r.min)}if(!c&&g){if(t==null)return!0;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s<=new Date(r.max)}if(c&&g){if(t==null)return!1;const s=t instanceof Date?t:new Date(t);return isNaN(s.getTime())?!1:s>=new Date(r.min)&&s<=new Date(r.max)}return!0}}if(typeof n=="string"&&N(e)==="rating"){if(t==null)return!1;const i=Number(n),o=typeof t=="number"?t:Number(t);return isNaN(i)||isNaN(o)?!1:o>=i}const p=N(e);if(!p)return!0;if(p==="address")return t==null?!1:typeof t=="object"&&"formatted_address"in t?String(t.formatted_address).toLowerCase().includes(String(n).toLowerCase()):!1;if(p==="multiselect"){if(!Array.isArray(t)||t.length===0)return!1;const i=String(n).toLowerCase();return t.some(o=>String(o).toLowerCase().includes(i))}return t==null?!1:String(t).toLowerCase().includes(String(n).toLowerCase())}export{S as matchesFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CRUD_OPERATION as a}from"../types";function
|
|
1
|
+
import{CRUD_OPERATION as a}from"../types";function n(e,s){const o=[],p=new Set;for(const i of e){const t=s[i.id];t?.operation!==a.DELETE&&(t?.operation===a.UPDATE&&t.optimisticData?o.push(t.optimisticData):o.push(i),p.add(i.id))}for(const[i,t]of Object.entries(s))t.operation===a.ADD&&!p.has(i)&&t.optimisticData&&o.push(t.optimisticData);return o}export{n as mergeWithOptimistic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"dompurify";const r=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","a","strong","b","em","i","u","s","code","br","span","sub","sup","mark","table","thead","tbody","tr","th","td","img","div","figure","figcaption","details","summary"],a=["href","target","rel","src","alt","width","height","class","colspan","rowspan"],i=/<\/?(?:embed|source|track|area|wbr)[^>]*>/gi;function s(t){return e.sanitize(t,{ALLOWED_TAGS:r,ALLOWED_ATTR:a}).replace(i,"")}export{s as sanitizeHtml};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function
|
|
1
|
+
"use client";function u(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!u(r.fullUrl)||r.thumbUrl&&!u(r.thumbUrl))}function i(r,n=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(n||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((s,o)=>{const l=n?`${n}[${o}]`:`[${o}]`;t.push(...i(s,l))});else{const s=r;if(s.fullUrl!==void 0&&s.thumbUrl!==void 0){const o=s.fullUrl,l=s.thumbUrl,e=typeof o=="string"&&!u(o),c=l&&typeof l=="string"&&!u(l);if(e||c){const f=n||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(s).forEach(([o,l])=>{const e=n?`${n}.${o}`:o;t.push(...i(l,e))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,u as isStorageUrl,h as validatePicture};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e
|
|
1
|
+
function n(e){return e}export{n as defineWorkflow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as g,useCallback as p,useMemo as h,useEffect as L,useRef as M}from"react";import{evaluateCondition as R}from"@donotdev/core";import{saveWorkflowState as K,loadWorkflowState as j,clearWorkflowState as C}from"./WorkflowPersistence";function V(e,I={}){const{onComplete:m,onStepChange:f,defaultValues:y}=I,w=M(m);w.current=m;const[a,v]=g(()=>{if(e.persist){const t=j(e.persistKey??e.id);if(t)return t.stepData}if(y){const t={};for(const r of e.steps)if(r.entity&&r.fields){const o={};for(const i of r.fields)i in y&&(o[i]=y[i]);Object.keys(o).length>0&&(t[r.id]=o)}return t}return{}}),[s,S]=g(()=>{if(e.persist){const t=j(e.persistKey??e.id);if(t)return t.currentStepIndex}return 0}),[k,x]=g(!1),l=h(()=>{const t={};for(const[r,o]of Object.entries(a))for(const[i,c]of Object.entries(o))t[i]=c,t[`${r}.${i}`]=c;return t},[a]),n=h(()=>e.steps.filter(t=>t.conditions?.visible?R(t.conditions.visible,l):!0),[e.steps,l]),O=n[s]??n[0],b=s===0,d=s===n.length-1;L(()=>{e.persist&&K(e.persistKey??e.id,{currentStepIndex:s,stepData:a,savedAt:Date.now()})},[e.persist,e.persistKey,e.id,s,a]);const W=p(async t=>{const r=n[s];if(!r)return!1;if(t&&v(i=>({...i,[r.id]:{...i[r.id],...t}})),r.validation?.validate){const i={...l,...t??{}};if(r.validation.validate(i)!==!0)return!1}if(r.after){const i={};await r.after({data:t??a[r.id]??{},allData:{...l,...t??{}},next:{prefill:c=>{const u=n[s+1];u&&(i[u.id]=c)}}}),Object.keys(i).length>0&&v(c=>{const u={...c};for(const[D,G]of Object.entries(i))u[D]={...u[D],...G};return u})}if(d){x(!0);try{const i={...l,...t??{}},c=w.current??e.onComplete;return c&&await c(i),e.persist&&C(e.persistKey??e.id),!0}catch{return!1}finally{x(!1)}}const o=s+1;return S(o),f?.(s,o),!0},[n,s,l,a,d,e,f]),N=p(()=>{if(b)return;const t=s-1;S(t),f?.(s,t)},[s,b,f]),A=p(()=>{if(!n[s]?.allowSkip||d)return;const t=s+1;S(t),f?.(s,t)},[n,s,d,f]),E=p(t=>{t>=0&&t<n.length&&(f?.(s,t),S(t))},[n.length,s,f]),P=p(()=>{e.persist&&K(e.persistKey??e.id,{currentStepIndex:s,stepData:a,savedAt:Date.now()})},[e,s,a]),$=p(()=>{C(e.persistKey??e.id)},[e]),F=p((t,r)=>{v(o=>({...o,[t]:{...o[t],...r}}))},[]);return{currentStep:O,currentStepIndex:s,visibleSteps:n,stepData:a,allData:l,goNext:W,goPrevious:N,skipStep:A,goToStep:E,isFirst:b,isLast:d,isSubmitting:k,canGoNext:!k,persistNow:P,clearPersisted:$,prefillStep:F}}export{V as useEntityWorkflow};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/crud",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@dnd-kit/core": "^6.3.1",
|
|
58
58
|
"@dnd-kit/sortable": "^10.0.0",
|
|
59
59
|
"@dnd-kit/utilities": "^3.2.2",
|
|
60
|
-
"@donotdev/components": "^0.1.
|
|
61
|
-
"@donotdev/core": "^0.1.
|
|
60
|
+
"@donotdev/components": "^0.1.44",
|
|
61
|
+
"@donotdev/core": "^0.1.44",
|
|
62
62
|
"dompurify": "^3.3.2",
|
|
63
63
|
"react-easy-crop": "^5.5.6"
|
|
64
64
|
},
|