@donotdev/crud 0.0.27 → 0.0.29
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.js +2 -2
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +6 -5
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/FieldRegistry.js +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/CrudCard.js +1 -1
- package/dist/components/DateFilter.js +1 -1
- package/dist/components/DisplayFieldRenderer.d.ts.map +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/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/complex/index.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/file/index.js +1 -1
- package/dist/components/controlled/index.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.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/ControlledPasswordField.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/input/index.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/select/ControlledYearField.js +1 -1
- package/dist/components/controlled/select/index.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/PhoneNumberDisplay.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/RichTextDisplay.js +2 -2
- 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.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/HiddenFieldComponent.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/components/index.js +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/contexts/index.js +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/fieldTypeRegistry.store.js +1 -1
- package/dist/forms/hooks/index.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/index.js +1 -1
- package/dist/forms/utils/buildInitialValues.js +1 -1
- package/dist/forms/utils/getFieldsForOperation.js +1 -1
- package/dist/forms/utils/index.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/index.js +1 -1
- package/dist/hooks/useCrudFilters.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/hooks/useUnsavedChangesWarning.js +1 -1
- package/dist/index.js +1 -1
- package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
- package/dist/registerBuiltinFieldTypes.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/tsconfig.tsbuildinfo +1 -1
- package/dist/types.js +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/imageStorage.js +1 -1
- package/dist/utils/imageUtils.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/scopeUtils.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/workflows/WorkflowPersistence.js +1 -1
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/package.json +3 -3
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E={PENDING:"pending",CONFIRMED:"confirmed",FAILED:"failed"},e={ADD:"add",UPDATE:"update",SET:"set",DELETE:"delete"};export{e as CRUD_OPERATION,E as OPTIMISTIC_STATUSES};
|
package/dist/useBaseCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo 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 ie}from"./useCrud";import{mergeWithOptimistic as re}from"./utils/mergeWithOptimistic";import{injectScopeFilter as ae,getCurrentScopeValue as oe}from"./utils/scopeUtils";const ne=1e3;function le(x,f,t,g={}){const K=g.enabled??!0,b=V("status"),c=b==="ready",j=V(x,g),{error:L,invalidate:_,_collection:p,_schemas:v,_cacheOptions:y,_scope:M}=j,T=te(e=>e.collections[p]?.optimistic||ie),q=Q(new Map([[1,null]])),S=Q(0),[E,k]=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 r,i;if(u.has(d))r=u.get(d)??void 0,i=s;else if(d>m&&u.has(m)){const l=d-m;r=u.get(m)??void 0,i=l*s}else r=void 0,i=d*s;return e.getListQueryOptions(p,{...n,limit:i,startAfter:r},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&&k(!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,r=S.current,{page:i,pageSize:l}=t,G=e.length;if(Math.ceil(G/l)>1||i>r){const D=s.has(i)?i:r+1;for(let C=D;C<=i;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(i+1,a.lastVisible),S.current=Math.max(r,i);const z=s.has(i)?0:(i-r-1)*l,H=z+l;e=e.slice(z,H)}const h=re(e,T),n=new Set(e.map(s=>s.id));let u=0,m=0;for(const[s,r]of Object.entries(T))r.operation===R.ADD&&!n.has(s)?u++:r.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
|
|
1
|
+
"use client";import{useEffect as K,useMemo as F,useCallback as n}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as W,FEATURE_STATUS as d,handleError as Z,isClient as B,createSchemas as H,DEGRADED_CRUD_API as J}from"@donotdev/core";import{getCrudService as Q}from"./CrudService";import{useCrudStore as u}from"./CrudStore";import{injectScope as M,injectScopeFilter as V}from"./utils/scopeUtils";const X={},$={};let _=null,E=null,b=!1;function r(){return _}function ee(l,m={}){const f=L(W.CRUD),U=u(e=>e.crudService),g=f&&!U,y=f?g?d.INITIALIZING:d.READY:d.DEGRADED,S=l==="status",p=!S&&typeof l=="object"?l:m.entity,a=S?"__status__":typeof l=="string"?l:l.collection,o=p?.scope,v=m.noCache??!1,T=m.staleTime,h=F(()=>({noCache:v,staleTime:T}),[v,T]),t=F(()=>{if(!S){if(m.schema){const e=m.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(p)return H(p)}},[S,m.schema,p?.name,a]),Y=u(e=>e.collections[a]?.loading||!1),A=u(e=>e.collections[a]?.error||null),O=null;K(()=>{if(!B()||!f||!t)return;const{crudService:e}=u.getState();e||_||E||(E=(async()=>{try{if(_||u.getState().crudService)return;const s=Q();_=s,s.setStore(u),await s.initialize(),b=!1,u.getState().setCrudService(s)}catch(s){b||(Z(s,{userMessage:"Failed to initialize CRUD service.",context:{collection:a},severity:"error"}),b=!0)}finally{E=null}})())},[f,a,t?"hasSchema":"noSchema"]);const D=g||Y,P=y===d.READY,j=n(async e=>{const s=r();return!s||!t?null:s.get(a,e,t.get,h)},[a,t?"hasSchema":"noSchema",h]),G=n(async(e,s,c)=>{const i=r();if(!i||!t)return;const C=M(s,o),k=C?.status==="draft"?t.draft:t.create;await i.set(a,e,C,k,c)},[a,t?"hasSchema":"noSchema",o?.provider]),q=n(async(e,s,c)=>{const i=r();i&&await i.update(a,e,s,t?.update,c)},[a,t]),x=n(async(e,s)=>{const c=r();c&&await c.delete(a,e,s)},[a]),z=n(async(e,s)=>{const c=r();if(!c||!t)return"";const i=M(e,o),C=i?.status==="draft"?t.draft:t.create;return c.add(a,i,C,s)},[a,t?"hasSchema":"noSchema",o?.provider]),N=n(async e=>{const s=r();if(!s||!t)return[];const c=V(e,o);return(await s.query(a,c,t.list,h)).items},[a,t?"hasSchema":"noSchema",h,o?.provider]),R=n((e,s)=>{const c=r();return!c||!t?()=>{}:c.subscribe(a,e,s,t.get)},[a,t?"hasSchema":"noSchema"]),I=n((e,s)=>{const c=r();return!c||!t?()=>{}:c.subscribeToCollection(a,e,s,t.list)},[a,t?"hasSchema":"noSchema"]),w=n(async()=>{const e=r();e&&await e.invalidateCollection(a)},[a]);return S?y:P?{status:d.READY,data:O,loading:D,error:A,get:j,set:G,update:q,delete:x,add:z,query:N,subscribe:R,subscribeToCollection:I,invalidate:w,isAvailable:!0,_collection:a,_schemas:t,_cacheOptions:h,_scope:o}:{...J,status:y,loading:D,error:A,subscribe:R,subscribeToCollection:I,invalidate:w,_collection:a,_schemas:t,_cacheOptions:h,_scope:o}}export{X as EMPTY_DATA,$ as EMPTY_OPTIMISTIC,r as getCrudServiceInstance,ee as useCrud};
|
package/dist/useCrudCardList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
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(a,t={}){const o={enabled:t.enabled,queryOptions:t.queryOptions,schema:t.schema,entity:t.entity,staleTime:t.staleTime,noCache:t.noCache},e=f(a,"listCard",null,o),s=typeof a=="string"?null:a,n=s?.collection??a,{filters:l}=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(l).length>0&&(r=h(r,l,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,l,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
|
|
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(s,e={}){const l=e.pagination??"auto",n=e.page??1,p=e.pageSize??10,c={mode:l,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(s,"list",c,u),r=typeof s=="string"?null:s,m=r?.collection??s,{filters:a}=g({collection:m}),i=e.clientSort===null?null:e.clientSort??r?.defaultSort??null,{processed:d,filteredTotal:y}=h(()=>{let t=o.items;r&&Object.keys(a).length>0&&(t=C(t,a,r)),r&&e.searchQuery&&(t=T(t,e.searchQuery,r));const f=t.length;return i&&(t=b(t,i)),{processed:t,filteredTotal:f}},[o.items,a,e.searchQuery,i,r]);return{...o,processed:d,filteredTotal:y}}export{Q as useCrudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesFilter as u}from"./matchesFilter";import{getValueType as
|
|
1
|
+
import{matchesFilter as u}from"./matchesFilter";import{getValueType as f}from"../fieldTypeRegistry.store";function d(t,i,a){const o=Object.entries(i);return o.length===0?t:t.filter(n=>o.every(([r,l])=>{const e=a.fields[r]?.type||"text";return u(n[r],l,e)}))}function c(t){if(t.search?.fields&&t.search.fields.length>0)return t.search.fields;const i=new Set(["string"]),a=[];for(const[o,n]of Object.entries(t.fields)){if(n.visibility==="hidden"||n.visibility==="technical")continue;const r=f(n.type);r&&i.has(r)&&a.push(o)}return a}function m(t,i,a){if(!i||i.trim()==="")return t;const o=i.toLowerCase(),n=c(a);return n.length===0?t.filter(r=>Object.values(r).some(l=>l==null?!1:String(l).toLowerCase().includes(o))):t.filter(r=>n.some(l=>{const e=r[l];return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(o):String(e).toLowerCase().includes(o)}))}function p(t,i){const{field:a,direction:o="asc"}=i,n=o==="desc"?-1:1;return[...t].sort((r,l)=>{const e=r[a],s=l[a];return e==null&&s==null?0:e==null?1:s==null?-1:typeof e=="number"&&typeof s=="number"?(e-s)*n:typeof e=="object"&&"amount"in e&&typeof s=="object"&&"amount"in s?(e.amount-s.amount)*n:e instanceof Date&&s instanceof Date?(e.getTime()-s.getTime())*n:String(e).localeCompare(String(s))*n})}export{d as applyFilters,m as applySearch,p as applySort,c as getSearchableFields};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCrudService as o}from"../CrudService";async function
|
|
1
|
+
import{getCrudService as o}from"../CrudService";async function p(a,e){const n=o(),s=[],t=e.range?.start??1,r=e.range?.end??28;for(let c=t;c<=r;c++){const m=String(c),i=await n.get(e.path(a),m,e.schema);i&&s.push(i)}return s}async function d(a,e,n){const s=o();for(const t of n){const r=e.idOf(t);await s.set(e.path(a),r,t,e.schema)}}async function h(a,e,n){const s=o();if(e.idFrom){const t=e.idFrom(n);return s.set(e.path(a),t,n,e.schema)}return s.add(e.path(a),n,e.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{handleError as
|
|
1
|
+
"use client";import{handleError as p,getProvider as d}from"@donotdev/core";function x(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function u(e,t={}){const{storagePath:r="uploads/files",filename:s,onProgress:o}=t,n=Date.now(),i=x(e.name),c=s||`${n}_${i}`,l=`${r}/${c}`;try{return{url:(await d("storage").upload(e,{storagePath:r,filename:c,onProgress:o?a=>o({bytesTransferred:0,totalBytes:0,progress:a}):void 0})).url,filename:e.name,size:e.size,mimeType:e.type,uploadedAt:new Date().toISOString()}}catch(a){throw p(a,{userMessage:"Failed to upload file",severity:"error",context:{filename:e.name,fileSize:e.size}})}}async function h(e,t={}){const r=[],s=e.reduce((n,i)=>n+i.size,0);let o=0;for(const n of e){const i=t.onProgress?l=>{const a=l.bytesTransferred/l.totalBytes*n.size;t.onProgress({bytesTransferred:o+a,totalBytes:s,progress:(o+a)/s*100})}:void 0,c=await u(n,{...t,onProgress:i});r.push(c),o+=n.size}return r}async function w(e){try{await d("storage").delete(e.url)}catch(t){throw p(t,{userMessage:"Failed to delete file",severity:"error",context:{url:e.url,filename:e.filename}}),t}}function v(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function f(e){const t=e.split(".");return t.length>1?t.pop().toLowerCase():""}function y(e,t){const r=t?f(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 M(e){if(e===0)return"0 B";const t=1024,r=["B","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,s)).toFixed(1))} ${r[s]}`}const m=["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"],g=[".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt",".md",".html",".csv"];function F(){return[...m,...g].join(",")}export{g as DOCUMENT_EXTENSIONS,m as DOCUMENT_MIME_TYPES,w as deleteFile,M as formatFileSize,v as generateFileId,F as getDocumentAcceptString,f as getFileExtension,y as getFileIcon,u as uploadFile,h as uploadFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function f(i,a={}){const{maxWidth:n=1920,maxHeight:h=1440,thumbWidth:c=300,thumbHeight:t=225,aspectRatio:e=4/3,quality:d=.85,crop:o}=a;return new Promise((w,l)=>{const r=new Image,s=new FileReader;s.onload=g=>{r.src=g.target?.result},s.onerror=()=>l(new Error("Failed to read file")),r.onload=async()=>{try{const{width:g,height:m}=v(o?o.width:r.width,o?o.height:r.height,n,h,e),F=await u(r,g,m,e,d,o),b=await u(r,c,t,e,.65,o);w({fullBlob:F,thumbBlob:b,width:g,height:m})}catch(g){l(g)}},r.onerror=()=>l(new Error("Failed to load image")),s.readAsDataURL(i)})}function v(i,a,n,h,c){let t=i,e=a;t>n&&(e=n/t*e,t=n),e>h&&(t=h/e*t,e=h);const d=t/e;return Math.abs(d-c)>.01&&(d>c?e=t/c:t=e*c),{width:Math.round(t),height:Math.round(e)}}async function u(i,a,n,h,c,t){const e=document.createElement("canvas"),d=e.getContext("2d");if(!d)throw new Error("Failed to get canvas context");e.width=a,e.height=n,d.fillStyle="#FFFFFF",d.fillRect(0,0,a,n);let o,w,l,r;if(t)o=t.x,w=t.y,l=t.width,r=t.height;else{const s=i.width/i.height;l=i.width,r=i.height,o=0,w=0,s>h?(l=i.height*h,o=(i.width-l)/2):s<h&&(r=i.width/h,w=(i.height-r)/2)}return d.drawImage(i,o,w,l,r,0,0,a,n),new Promise((s,g)=>{e.toBlob(m=>{m?s(m):g(new Error("Failed to convert canvas to blob"))},"image/webp",c)})}function x(i,a){return i.type.startsWith("image/")?a&&i.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{f as processImage,x as validateImageFile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as
|
|
1
|
+
import{handleError as f,getProvider as c}from"@donotdev/core";function y(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function $(e,t,a,m={}){const{storagePath:l="uploads/images",filename:h,onProgress:o}=m,w=Date.now(),r=(h||`${w}_${y(a)}`).replace(/\.[^/.]+$/,""),b=`${l}/${r}_full.webp`,d=`${l}/${r}_thumb.webp`;try{const n=new File([e],`${r}_full.webp`,{type:"image/webp"}),s=new File([t],`${r}_thumb.webp`,{type:"image/webp"});let i,p;const g=c("storage");return i=(await g.upload(n,{storagePath:l,filename:`${r}_full.webp`,onProgress:o?u=>o({bytesTransferred:0,totalBytes:0,progress:u*.5}):void 0})).url,p=(await g.upload(s,{storagePath:l,filename:`${r}_thumb.webp`,onProgress:o?u=>o({bytesTransferred:0,totalBytes:0,progress:50+u*.5}):void 0})).url,{fullUrl:i,thumbUrl:p}}catch(n){try{const s=c("storage");await s.delete(b).catch(()=>{}),await s.delete(d).catch(()=>{})}catch{}throw n}}async function _(e){try{const t=c("storage"),a=[t.delete(e.fullUrl)];e.thumbUrl&&a.push(t.delete(e.thumbUrl)),await Promise.all(a)}catch(t){throw f(t,{userMessage:"Failed to delete image",severity:"error",context:{fullUrl:e.fullUrl,thumbUrl:e.thumbUrl}}),t}}export{_ as deleteImage,$ as uploadImage};
|
package/dist/utils/imageUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
async function d(e){const t=await e.arrayBuffer(),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(
|
|
1
|
+
async function d(e){const t=await e.arrayBuffer(),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}function h(e){return URL.createObjectURL(e)}function u(e){e.startsWith("blob:")&&URL.revokeObjectURL(e)}async function l(e){return new Promise((t,r)=>{const a=new Image,i=new FileReader;i.onload=n=>{if(!n.target?.result){r(new Error("Failed to read file"));return}a.src=n.target.result},i.onerror=()=>r(new Error("Failed to read file")),a.onload=()=>{const n=document.createElement("canvas"),o=n.getContext("2d");if(!o){r(new Error("Failed to get canvas context"));return}n.width=a.height,n.height=a.width,o.translate(n.width/2,n.height/2),o.rotate(Math.PI/2),o.drawImage(a,-a.width/2,-a.height/2),n.toBlob(s=>{if(s){const c=new File([s],e.name,{type:e.type,lastModified:Date.now()});t(c)}else r(new Error("Failed to create blob from canvas"))},e.type,.95)},a.onerror=()=>r(new Error("Failed to load image")),i.readAsDataURL(e)})}class g{undoStack=[];redoStack=[];maxStackSize=50;push(t){this.undoStack.push(t),this.undoStack.length>this.maxStackSize&&this.undoStack.shift(),this.redoStack=[]}undo(){const t=this.undoStack.pop();return t?(this.redoStack.push(t),t):null}redo(){const t=this.redoStack.pop();return t?(this.undoStack.push(t),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[]}}function S(e,t){return e.filter(r=>r.hash===t)}function w(){return`img_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{g as UndoRedoManager,h as createPreviewURL,S as findDuplicatesByHash,d as generateFileHash,w as generateImageId,u as revokePreviewURL,l as rotateImage90};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFilterType as
|
|
1
|
+
import{getFilterType as N}from"../fieldTypeRegistry.store";function T(e,t,r){if(!t)return!0;if(Array.isArray(t)){if(t.length===0)return!0;if(!(N(r)==="range"&&(r==="date"||r==="datetime-local"||r==="timestamp")))return t.some(n=>{if(typeof n=="object"&&"date"in n){const g=n.date;return(e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0])===g}return String(e)===String(n)});const a=e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0];return t.some(n=>typeof n=="string"?a===n:typeof n=="object"&&"date"in n?a===n.date:!1)}if(typeof t=="object"&&"date"in t&&!("min"in t)&&!Array.isArray(t)){if(!(N(r)==="range"&&(r==="date"||r==="datetime-local"||r==="timestamp")))return!1;const a=t.date;if(!a)return!0;if(e==null)return!1;const n=e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0];if((r==="datetime-local"||r==="timestamp")&&t.time){const g=e instanceof Date?e.toISOString().slice(11,16):new Date(e).toISOString().slice(11,16);return n===a&&g===t.time}return n===a}if(typeof t=="object"&&"min"in t){const a=N(r);if(!a)return!0;const n=a==="range"&&(r==="date"||r==="datetime-local"||r==="timestamp"),g=a==="range"&&!n,S=r==="price",f=S&&e!=null&&typeof e=="object"?Number(e.amount):g&&e!=null?typeof e=="number"?e:Number(e):NaN;if(g||S){if(typeof t.min=="object"&&t.min!==null&&"date"in t.min)return!1;const i=t,l=typeof i.min=="string"&&i.min!=="",c=typeof i.max=="string"&&i.max!=="";return l&&!c?e==null||isNaN(f)?!1:f>=Number(i.min):!l&&c?e==null?!0:isNaN(f)?!1:f<=Number(i.max):l&&c?e==null||isNaN(f)?!1:f>=Number(i.min)&&f<=Number(i.max):!0}if(n){if(typeof t.min=="object"&&t.min!==null&&"date"in t.min&&!("min"in t.min)){const o=t,u=o.min,s=o.max,D=u?.date&&u.date!=="",w=s?.date&&s.date!=="";if(D&&!w){if(e==null)return!1;const m=e instanceof Date?e:new Date(e);if(isNaN(m.getTime()))return!1;const d=new Date(u.date+(u.time?`T${u.time}:00`:"T00:00:00"));return m>=d}if(!D&&w&&s){if(e==null)return!0;const m=e instanceof Date?e:new Date(e);if(isNaN(m.getTime()))return!1;const d=new Date(s.date+(s.time?`T${s.time}:00`:"T23:59:59"));return m<=d}if(D&&w&&s){if(e==null)return!1;const m=e instanceof Date?e:new Date(e);if(isNaN(m.getTime()))return!1;const d=new Date(u.date+(u.time?`T${u.time}:00`:"T00:00:00")),y=new Date(s.date+(s.time?`T${s.time}:00`:"T23:59:59"));return m>=d&&m<=y}return!0}const i=t,l=typeof i.min=="string"&&i.min!=="",c=typeof i.max=="string"&&i.max!=="";if(l&&!c){if(e==null)return!1;const o=e instanceof Date?e:new Date(e);return isNaN(o.getTime())?!1:o>=new Date(i.min)}if(!l&&c){if(e==null)return!0;const o=e instanceof Date?e:new Date(e);return isNaN(o.getTime())?!1:o<=new Date(i.max)}if(l&&c){if(e==null)return!1;const o=e instanceof Date?e:new Date(e);return isNaN(o.getTime())?!1:o>=new Date(i.min)&&o<=new Date(i.max)}return!0}}if(typeof t=="string"&&N(r)==="rating"){if(e==null)return!1;const a=Number(t),n=typeof e=="number"?e:Number(e);return isNaN(a)||isNaN(n)?!0:n>=a}const p=N(r);if(!p)return!0;if(p==="address")return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(String(t).toLowerCase()):!1;if(p==="multiselect"){if(!Array.isArray(e)||e.length===0)return!1;const a=String(t).toLowerCase();return e.some(n=>String(n).toLowerCase().includes(a))}return e==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase())}export{T as matchesFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CRUD_OPERATION as
|
|
1
|
+
import{CRUD_OPERATION as a}from"../types";function e(n,s){const o=[],p=new Set;for(const i of n){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{e as mergeWithOptimistic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i from"dompurify";function n(t){return i.sanitize(t)}export{n as sanitizeHtml};
|
package/dist/utils/scopeUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getScopeValue as
|
|
1
|
+
import{getScopeValue as t,CRUD_OPERATORS as c}from"@donotdev/core";function s(r,e){if(!e)return r;const o=t(e.provider);if(!o)throw new Error(`[CRUD] Scope provider "${e.provider}" returned null. Cannot write scoped entity without a scope value. Ensure a scope is selected before creating scoped entities.`);return{...r,[e.field]:o}}function p(r,e){const o=r??{};if(!e||typeof e.field!="string")return o;const n=t(e.provider);if(!n)throw new Error(`[CRUD] Scope provider "${e.provider}" returned null. Cannot query scoped entity without a scope value. Ensure a scope is selected before querying scoped entities.`);const i={field:e.field,operator:c.EQ,value:n};return{...o,where:o.where?[...o.where,i]:[i]}}function u(r){return r?t(r.provider):null}export{u as getCurrentScopeValue,s as injectScope,p as injectScopeFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";function
|
|
1
|
+
"use client";function u(t){return!t||typeof t!="string"?!1:t.startsWith("https://")&&!t.startsWith("blob:")}function h(t){return!(!t||typeof t!="object"||!u(t.fullUrl)||t.thumbUrl&&!u(t.thumbUrl))}function i(t,e=""){const s=[];if(t==null)return s;if(typeof t=="string")return t.startsWith("blob:")&&s.push(e||"root"),s;if(typeof t!="object")return s;if(Array.isArray(t))t.forEach((l,o)=>{const r=e?`${e}[${o}]`:`[${o}]`;s.push(...i(l,r))});else{const l=t;if(l.fullUrl!==void 0&&l.thumbUrl!==void 0){const o=l.fullUrl,r=l.thumbUrl,n=typeof o=="string"&&!u(o),c=r&&typeof r=="string"&&!u(r);if(n||c){const f=e||"root";s.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(l).forEach(([o,r])=>{const n=e?`${e}.${o}`:o;s.push(...i(r,n))})}return s}function b(t){return i(t).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,u as isStorageUrl,h as validatePicture};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a="dndev-workflow-";function r(t,o){try{const e=`${a}${t}`;localStorage.setItem(e,JSON.stringify(o))}catch{}}function c(t){try{const o=`${a}${t}`,e=localStorage.getItem(o);return e?JSON.parse(e):null}catch{return null}}function n(t){try{const o=`${a}${t}`;localStorage.removeItem(o)}catch{}}export{n as clearWorkflowState,c as loadWorkflowState,r as saveWorkflowState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function n
|
|
1
|
+
function e(n){return n}export{e as defineWorkflow};
|
package/dist/workflows/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineWorkflow as
|
|
1
|
+
import{defineWorkflow as o}from"./defineWorkflow";import{useEntityWorkflow as a}from"./useEntityWorkflow";import{saveWorkflowState as t,loadWorkflowState as r,clearWorkflowState as e}from"./WorkflowPersistence";export{e as clearWorkflowState,o as defineWorkflow,r as loadWorkflowState,t as saveWorkflowState,a as useEntityWorkflow};
|
|
@@ -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,O={}){const{onComplete:m,onStepChange:f,defaultValues:y}=O,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]),W=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 I=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:W,currentStepIndex:s,visibleSteps:n,stepData:a,allData:l,goNext:I,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.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@dnd-kit/core": "^6.3.1",
|
|
54
54
|
"@dnd-kit/sortable": "^10.0.0",
|
|
55
55
|
"@dnd-kit/utilities": "^3.2.2",
|
|
56
|
-
"@donotdev/components": "^0.0.
|
|
57
|
-
"@donotdev/core": "^0.0.
|
|
56
|
+
"@donotdev/components": "^0.0.30",
|
|
57
|
+
"@donotdev/core": "^0.0.41",
|
|
58
58
|
"@hookform/resolvers": "^5.2.2",
|
|
59
59
|
"dompurify": "^3.3.2",
|
|
60
60
|
"react-easy-crop": "^5.5.6"
|