@donotdev/crud 0.0.19 → 0.0.21
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.d.ts.map +1 -1
- package/dist/CrudService.js +2 -2
- package/dist/CrudStore.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.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/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/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/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/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/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/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/fieldTypeRegistry.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/getFieldsForOperation.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/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.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/useBaseCrudList.d.ts +9 -2
- package/dist/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.d.ts +9 -2
- package/dist/useCrudList.d.ts.map +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.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/defineWorkflow.js +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/package.json +5 -5
|
@@ -2,8 +2,13 @@ import type { Entity, FeatureStatus, ListSchemaType, QueryOptions } from '@donot
|
|
|
2
2
|
import type { UseCrudOptions } from './useCrud';
|
|
3
3
|
/** Pagination configuration */
|
|
4
4
|
export interface PaginationConfig {
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Pagination mode:
|
|
7
|
+
* - `'auto'` (default) — fetches up to 1000 client-side. If total > 1000, auto-switches to server pagination.
|
|
8
|
+
* - `'client'` — fetches all (up to limit), paginates in browser. Best for < 1000 items.
|
|
9
|
+
* - `'server'` — fetches one page at a time via cursor. Required for very large collections.
|
|
10
|
+
*/
|
|
11
|
+
mode: 'auto' | 'client' | 'server';
|
|
7
12
|
/** Page number for server-side pagination (1-indexed) */
|
|
8
13
|
page: number;
|
|
9
14
|
/** Page size for server-side pagination */
|
|
@@ -35,6 +40,8 @@ export interface UseBaseCrudListReturn<T> {
|
|
|
35
40
|
/** Alias for mutate (manual refresh) */
|
|
36
41
|
refresh: () => Promise<void>;
|
|
37
42
|
isAvailable: boolean;
|
|
43
|
+
/** Effective pagination mode after auto-detection. 'client' or 'server'. */
|
|
44
|
+
effectiveMode: 'client' | 'server';
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
40
47
|
* Internal base hook for list operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseCrudList.d.ts","sourceRoot":"","sources":["../src/useBaseCrudList.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"useBaseCrudList.d.ts","sourceRoot":"","sources":["../src/useBaseCrudList.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQhD,+BAA+B;AAC/B,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACnC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,kCAAkC;AAClC,MAAM,WAAW,sBAAsB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAClE,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5C,mDAAmD;IACnD,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,wCAAwC;IACxC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,4EAA4E;IAC5E,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACvE,kBAAkB,EAAE,MAAM,GAAG,MAAM,EACnC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,gBAAgB,GAAG,IAAI,EACnC,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,GACtC,qBAAqB,CAAC,CAAC,CAAC,CAwQ1B"}
|
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{useCrud as R,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";import{CRUD_OPERATION as V}from"./types";const ne=1e3;function le(j,f,t,g={}){const K=g.enabled??!0,b=R("status"),c=b==="ready",k=R(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===V.ADD&&!n.has(s)?u++:i.operation===V.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:!1,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 m,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,d={}){const f=L(W.CRUD),U=u(e=>e.crudService),g=f&&!U,y=f?g?m.INITIALIZING:m.READY:m.DEGRADED,S=l==="status",p=!S&&typeof l=="object"?l:d.entity,a=S?"__status__":typeof l=="string"?l:l.collection,o=p?.scope,v=d.noCache??!1,T=d.staleTime,h=F(()=>({noCache:v,staleTime:T}),[v,T]),t=F(()=>{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(p)return H(p)}},[S,d.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===m.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:m.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 d}from"react";import{useBaseCrudList as p}from"./useBaseCrudList";import{useCrudFilters as f}from"./hooks/useCrudFilters";import{applyFilters as h,applySearch as y,applySort as g}from"./utils/clientListProcessing";function C(
|
|
1
|
+
import{useMemo as d}from"react";import{useBaseCrudList as p}from"./useBaseCrudList";import{useCrudFilters as f}from"./hooks/useCrudFilters";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=p(l,"listCard",null,o),s=typeof l=="string"?null:l,n=s?.collection??l,{filters:a}=f({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.d.ts
CHANGED
|
@@ -5,8 +5,13 @@ import type { ClientSortConfig } from './utils/clientListProcessing';
|
|
|
5
5
|
export interface UseCrudListOptions<T> extends UseCrudOptions<T> {
|
|
6
6
|
/** Automatically fetch data on mount (default: true) */
|
|
7
7
|
enabled?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Pagination mode:
|
|
10
|
+
* - `'auto'` (default) — fetches up to 1000 client-side. If total > 1000, auto-switches to server pagination.
|
|
11
|
+
* - `'client'` — forces client-side (fetches all, paginates in browser).
|
|
12
|
+
* - `'server'` — forces server-side (cursor pagination, one page at a time).
|
|
13
|
+
*/
|
|
14
|
+
pagination?: 'auto' | 'client' | 'server';
|
|
10
15
|
/** Page number for server-side pagination (1-indexed, default: 1) */
|
|
11
16
|
page?: number;
|
|
12
17
|
/** Page size for server-side pagination (default: 10) */
|
|
@@ -40,6 +45,8 @@ export interface UseCrudListReturn<T> {
|
|
|
40
45
|
/** Alias for mutate (manual refresh) */
|
|
41
46
|
refresh: () => Promise<void>;
|
|
42
47
|
isAvailable: boolean;
|
|
48
|
+
/** Effective pagination mode after auto-detection ('client' or 'server'). */
|
|
49
|
+
effectiveMode: 'client' | 'server';
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* React hook for fetching and managing a list of entities
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrudList.d.ts","sourceRoot":"","sources":["../src/useCrudList.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC9D,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB
|
|
1
|
+
{"version":3,"file":"useCrudList.d.ts","sourceRoot":"","sources":["../src/useCrudList.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC9D,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5C,4FAA4F;IAC5F,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,wEAAwE;IACxE,SAAS,EAAE,CAAC,EAAE,CAAC;IACf,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,wCAAwC;IACxC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,6EAA6E;IAC7E,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACnE,kBAAkB,EAAE,MAAM,GAAG,MAAM,EACnC,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GAClC,iBAAiB,CAAC,CAAC,CAAC,CAwEtB"}
|
package/dist/useCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as h}from"react";import{useBaseCrudList as g}from"./useBaseCrudList";import{useCrudFilters as S}from"./hooks/useCrudFilters";import{applyFilters as
|
|
1
|
+
import{useMemo as h}from"react";import{useBaseCrudList as g}from"./useBaseCrudList";import{useCrudFilters as S}from"./hooks/useCrudFilters";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=g(l,"list",c,u),r=typeof l=="string"?null:l,m=r?.collection??l,{filters:s}=S({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{getCrudService as
|
|
1
|
+
import{getCrudService as i}from"../CrudService";async function p(a,t){const e=i(),s=[],o=t.range?.start??1,c=t.range?.end??28;for(let r=o;r<=c;r++){const m=String(r),n=await e.get(t.path(a),m,t.schema);n&&s.push(n)}return s}async function d(a,t,e){const s=i();for(const o of e){const c=t.idOf(o);await s.set(t.path(a),c,o,t.schema)}}async function h(a,t,e){const s=i();if(t.idFrom){const o=t.idFrom(e);return s.set(t.path(a),o,e,t.schema)}return s.add(t.path(a),e,t.schema)}export{h as appendToCollection,p as loadDeterministicRange,d as upsertDeterministic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function f(a
|
|
1
|
+
async function f(i,a={}){const{maxWidth:n=1920,maxHeight:h=1440,thumbWidth:s=300,thumbHeight:t=225,aspectRatio:e=4/3,quality:d=.85,crop:o}=a;return new Promise((w,l)=>{const r=new Image,c=new FileReader;c.onload=g=>{r.src=g.target?.result},c.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,s,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")),c.readAsDataURL(i)})}function v(i,a,n,h,s){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-s)>.01&&(d>s?e=t/s:t=e*s),{width:Math.round(t),height:Math.round(e)}}async function u(i,a,n,h,s,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 c=i.width/i.height;l=i.width,r=i.height,o=0,w=0,c>h?(l=i.height*h,o=(i.width-l)/2):c<h&&(r=i.width/h,w=(i.height-r)/2)}return d.drawImage(i,o,w,l,r,0,0,a,n),new Promise((c,g)=>{e.toBlob(m=>{m?c(m):g(new Error("Failed to convert canvas to blob"))},"image/webp",s)})}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 _,hasProvider as
|
|
1
|
+
import{handleError as _,hasProvider as g,getProvider as w}from"@donotdev/core";function v(e){return e.replace(/[^a-zA-Z0-9.-]/g,"_").replace(/_{2,}/g,"_").toLowerCase()}async function B(e,t,o,d={}){const{storagePath:i="uploads/images",filename:f,onProgress:a}=d,y=Date.now(),r=(f||`${y}_${v(o)}`).replace(/\.[^/.]+$/,""),b=`${i}/${r}_full.webp`,h=`${i}/${r}_thumb.webp`;try{const c=new File([e],`${r}_full.webp`,{type:"image/webp"}),s=new File([t],`${r}_thumb.webp`,{type:"image/webp"});let n,u;if(g("storage")){const l=w("storage");n=(await l.upload(c,{storagePath:i,filename:`${r}_full.webp`,onProgress:a?m=>a({bytesTransferred:0,totalBytes:0,progress:m*.5}):void 0})).url,u=(await l.upload(s,{storagePath:i,filename:`${r}_thumb.webp`,onProgress:a?m=>a({bytesTransferred:0,totalBytes:0,progress:50+m*.5}):void 0})).url}else{const{uploadFileResumable:l}=await import("@donotdev/firebase"),m=a?p=>{a({bytesTransferred:p.bytesTransferred,totalBytes:p.totalBytes*2,progress:p.progress*.5})}:void 0,{promise:U}=l(c,{basePath:i,filename:`${r}_full.webp`,onProgress:m,metadata:{contentType:"image/webp"}});n=(await U).url;const P=a?p=>{a({bytesTransferred:p.bytesTransferred+e.size,totalBytes:e.size+t.size,progress:50+p.progress*.5})}:void 0,{promise:$}=l(s,{basePath:i,filename:`${r}_thumb.webp`,onProgress:P,metadata:{contentType:"image/webp"}});u=(await $).url}return{fullUrl:n,thumbUrl:u}}catch(c){try{if(g("storage")){const s=w("storage");await s.delete(b).catch(()=>{}),await s.delete(h).catch(()=>{})}else{const{getFileUrl:s,deleteFileByUrl:n}=await import("@donotdev/firebase"),u=await s(b).catch(()=>null),l=await s(h).catch(()=>null);u&&await n(u).catch(()=>{}),l&&await n(l).catch(()=>{})}}catch{}throw c}}async function F(e){try{if(g("storage")){const t=w("storage"),o=[t.delete(e.fullUrl)];e.thumbUrl&&o.push(t.delete(e.thumbUrl)),await Promise.all(o)}else{const{deleteFileByUrl:t}=await import("@donotdev/firebase"),o=[t(e.fullUrl)];e.thumbUrl&&o.push(t(e.thumbUrl)),await Promise.all(o)}}catch(t){throw _(t,{userMessage:"Failed to delete image",severity:"error",context:{fullUrl:e.fullUrl,thumbUrl:e.thumbUrl}}),t}}export{F as deleteImage,B as uploadImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFilterType as N}from"../fieldTypeRegistry";function T(
|
|
1
|
+
import{getFilterType as N}from"../fieldTypeRegistry";function T(t,n,i){if(!n)return!0;if(Array.isArray(n)){if(n.length===0)return!0;if(!(N(i)==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp")))return n.some(e=>{if(typeof e=="object"&&"date"in e){const g=e.date;return(t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0])===g}return String(t)===String(e)});const a=t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0];return n.some(e=>typeof e=="string"?a===e:typeof e=="object"&&"date"in e?a===e.date:!1)}if(typeof n=="object"&&"date"in n&&!("min"in n)&&!Array.isArray(n)){if(!(N(i)==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp")))return!1;const a=n.date;if(!a)return!0;if(t==null)return!1;const e=t instanceof Date?t.toISOString().split("T")[0]:new Date(t).toISOString().split("T")[0];if((i==="datetime-local"||i==="timestamp")&&n.time){const g=t instanceof Date?t.toISOString().slice(11,16):new Date(t).toISOString().slice(11,16);return e===a&&g===n.time}return e===a}if(typeof n=="object"&&"min"in n){const a=N(i);if(!a)return!0;const e=a==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"),g=a==="range"&&!e,S=i==="price",f=S&&t!=null&&typeof t=="object"?Number(t.amount):g&&t!=null?typeof t=="number"?t:Number(t):NaN;if(g||S){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min)return!1;const r=n,l=typeof r.min=="string"&&r.min!=="",c=typeof r.max=="string"&&r.max!=="";return l&&!c?t==null||isNaN(f)?!1:f>=Number(r.min):!l&&c?t==null?!0:isNaN(f)?!1:f<=Number(r.max):l&&c?t==null||isNaN(f)?!1:f>=Number(r.min)&&f<=Number(r.max):!0}if(e){if(typeof n.min=="object"&&n.min!==null&&"date"in n.min&&!("min"in n.min)){const o=n,u=o.min,s=o.max,D=u?.date&&u.date!=="",w=s?.date&&s.date!=="";if(D&&!w){if(t==null)return!1;const m=t instanceof Date?t:new Date(t);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(t==null)return!0;const m=t instanceof Date?t:new Date(t);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(t==null)return!1;const m=t instanceof Date?t:new Date(t);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 r=n,l=typeof r.min=="string"&&r.min!=="",c=typeof r.max=="string"&&r.max!=="";if(l&&!c){if(t==null)return!1;const o=t instanceof Date?t:new Date(t);return isNaN(o.getTime())?!1:o>=new Date(r.min)}if(!l&&c){if(t==null)return!0;const o=t instanceof Date?t:new Date(t);return isNaN(o.getTime())?!1:o<=new Date(r.max)}if(l&&c){if(t==null)return!1;const o=t instanceof Date?t:new Date(t);return isNaN(o.getTime())?!1:o>=new Date(r.min)&&o<=new Date(r.max)}return!0}}if(typeof n=="string"&&N(i)==="rating"){if(t==null)return!1;const a=Number(n),e=typeof t=="number"?t:Number(t);return isNaN(a)||isNaN(e)?!0:e>=a}const p=N(i);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 a=String(n).toLowerCase();return t.some(e=>String(e).toLowerCase().includes(a))}return t==null?!1:String(t).toLowerCase().includes(String(n).toLowerCase())}export{T 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
|
-
const r=/<script[\s\S]*?<\/script>/gi,e=/\s+on\w+\s*=\s*["'
|
|
1
|
+
const r=/<script[\s\S]*?<\/script>/gi,e=/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,i=/\s+(?:xlink:)?href\s*=\s*["']\s*javascript:[^"']*["']/gi,c=/\s+src\s*=\s*["']\s*javascript:[^"']*["']/gi;function t(s){return s.replace(r,"").replace(e,"").replace(i,"").replace(c,"")}export{t 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 o(r){return!r||typeof r!="string"?!1:r.startsWith("https://")&&!r.startsWith("blob:")}function h(r){return!(!r||typeof r!="object"||!o(r.fullUrl)||r.thumbUrl&&!o(r.thumbUrl))}function i(r,l=""){const t=[];if(r==null)return t;if(typeof r=="string")return r.startsWith("blob:")&&t.push(l||"root"),t;if(typeof r!="object")return t;if(Array.isArray(r))r.forEach((e,s)=>{const n=l?`${l}[${s}]`:`[${s}]`;t.push(...i(e,n))});else{const e=r;if(e.fullUrl!==void 0&&e.thumbUrl!==void 0){const s=e.fullUrl,n=e.thumbUrl,u=typeof s=="string"&&!o(s),c=n&&typeof n=="string"&&!o(n);if(u||c){const f=l||"root";t.push(`${f}.fullUrl or ${f}.thumbUrl contains blob URL`)}}else Object.entries(e).forEach(([s,n])=>{const u=l?`${l}.${s}`:s;t.push(...i(n,u))})}return t}function b(r){return i(r).length>0}export{i as checkForBlobUrls,b as hasBlobUrls,o 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.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -53,19 +53,19 @@
|
|
|
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.24",
|
|
57
|
+
"@donotdev/core": "^0.0.30",
|
|
58
58
|
"@hookform/resolvers": "^5.2.2",
|
|
59
59
|
"react-easy-crop": "^5.5.6"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@donotdev/firebase": "^0.0.
|
|
62
|
+
"@donotdev/firebase": "^0.0.16",
|
|
63
63
|
"@tiptap/extension-placeholder": "^3.19.0",
|
|
64
64
|
"@tiptap/pm": "^3.19.0",
|
|
65
65
|
"@tiptap/react": "^3.19.0",
|
|
66
66
|
"@tiptap/starter-kit": "^3.19.0",
|
|
67
67
|
"firebase": "^12.9.0",
|
|
68
|
-
"lucide-react": "^0.
|
|
68
|
+
"lucide-react": "^0.575.0",
|
|
69
69
|
"react": "^19.2.4",
|
|
70
70
|
"react-dom": "^19.2.4",
|
|
71
71
|
"react-hook-form": "^7.71.2",
|