@donotdev/crud 0.0.21 → 0.0.23
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.d.ts.map +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/FieldRegistry.d.ts +1 -1
- package/dist/FieldRegistry.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts +15 -0
- package/dist/adapters/FunctionsAdapter.d.ts.map +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.d.ts.map +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.d.ts +4 -1
- package/dist/components/EntityFilters.d.ts.map +1 -1
- package/dist/components/EntityFilters.js +1 -1
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
- package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledDateField.js +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMapField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMapField.js +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledFileField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledFileField.js +1 -1
- package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledImageField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
- package/dist/components/controlled/input/ControlledDurationField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledDurationField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
- package/dist/components/controlled/input/ControlledNumberField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledNumberField.js +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
- package/dist/components/controlled/input/ControlledPriceField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPriceField.js +1 -1
- package/dist/components/controlled/input/ControlledRangeField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledRangeField.js +1 -1
- package/dist/components/controlled/input/ControlledRatingField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledRatingField.js +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
- package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextField.js +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
- package/dist/components/controlled/select/ControlledRadioField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledRadioField.js +1 -1
- package/dist/components/controlled/select/ControlledReferenceField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
- package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledYearField.js +1 -1
- package/dist/components/controlled/types.d.ts.map +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.d.ts.map +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.d.ts +1 -1
- package/dist/components/form/fields/RichTextComponent.d.ts.map +1 -1
- package/dist/components/form/fields/RichTextComponent.js +1 -1
- package/dist/components/form/fields/SwitchFieldComponent.d.ts.map +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.d.ts.map +1 -1
- package/dist/contexts/UploadContext.js +1 -1
- package/dist/fieldTypeRegistry.d.ts +1 -1
- package/dist/fieldTypeRegistry.d.ts.map +1 -1
- package/dist/fieldTypeRegistry.js +1 -1
- package/dist/forms/hooks/useController.d.ts.map +1 -1
- package/dist/forms/hooks/useController.js +1 -1
- package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityField.js +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/types.d.ts +2 -2
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/buildInitialValues.d.ts.map +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/useCrudFilters.d.ts.map +1 -1
- package/dist/hooks/useEntityFavorites.js +1 -1
- package/dist/hooks/useFieldConditions.d.ts +1 -1
- package/dist/hooks/useFieldConditions.d.ts.map +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.d.ts +0 -1
- package/dist/hooks/useUnsavedChangesWarning.d.ts.map +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/useBaseCrudList.d.ts.map +1 -1
- package/dist/useBaseCrudList.js +1 -1
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.d.ts.map +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.d.ts.map +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/clientListProcessing.d.ts.map +1 -1
- package/dist/utils/collections.js +1 -1
- package/dist/utils/fileStorage.d.ts.map +1 -1
- package/dist/utils/imageProcessing.js +1 -1
- package/dist/utils/imageStorage.d.ts.map +1 -1
- package/dist/utils/imageStorage.js +1 -1
- package/dist/utils/matchesFilter.js +1 -1
- package/dist/utils/mergeWithOptimistic.d.ts +0 -8
- package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
- package/dist/utils/mergeWithOptimistic.js +1 -1
- package/dist/utils/uploadValidation.js +1 -1
- package/dist/workflows/defineWorkflow.d.ts.map +1 -1
- package/dist/workflows/defineWorkflow.js +1 -1
- package/dist/workflows/useEntityWorkflow.d.ts.map +1 -1
- package/dist/workflows/useEntityWorkflow.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.d.ts","sourceRoot":"","sources":["../src/CrudService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrudService.d.ts","sourceRoot":"","sources":["../src/CrudService.ts"],"names":[],"mappings":"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"}
|
package/dist/CrudService.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{toast as p}from"@donotdev/components";import{createSingleton as w,handleError as
|
|
1
|
+
import{toast as p}from"@donotdev/components";import{createSingleton as w,handleError as l,getQueryClient as E,getI18nInstance as y,hasProvider as C,getProvider as A,hasRestrictedVisibility as L,DEFAULT_STATUS_VALUE as T}from"@donotdev/core";import{LIST_SCHEMA_TYPE as S}from"@donotdev/core";import{CRUD_OPERATION as h}from"./types";const m=1/0,P=1e3*60*30;class D{adapter=null;store=null;security=null;currentUserId=null;_shouldShowSuccessToast(t){return t?.showSuccessToast===!0?!0:t?.showSuccessToast===!1?!1:!this.store?.getState().hideSuccessToasts}setStore(t){this.store=t}setSecurity(t){this.security=t}setCurrentUser(t){this.currentUserId=t}_getPiiFields(t){return t?.security?.piiFields??[]}_auditCrud(t,e,i,r){this.security&&this.security.audit({type:t,collection:e,docId:i,userId:r??this.currentUserId??void 0})}_rateLimitKey(t){return this.currentUserId?`${this.currentUserId}:${t}`:t}async _ensureAdapter(){this.adapter||await this.initialize()}_assertCanAccess(t,e){if(this.adapter&&e&&L(e)&&!this.adapter.serverSideOnly&&!this.adapter.dbLevelSecurity)throw new Error(`[dndev] Direct adapter cannot access "${t}": entity has restricted field visibility. Use a server-side adapter (FunctionsAdapter for Firebase, or SupabaseCrudAdapter with RLS enabled) to enforce field-level security (serverSideOnly = true | dbLevelSecurity = true).`)}async initialize(){if(!this.adapter){if(!C("crud"))throw new Error(`[dndev] No CRUD adapter configured. Call configureProviders({ crud: yourAdapter }) at app startup.
|
|
2
2
|
Examples:
|
|
3
3
|
import { FirestoreAdapter } from "@donotdev/firebase";
|
|
4
4
|
import { FunctionsAdapter } from "@donotdev/crud";
|
|
@@ -6,4 +6,4 @@ Examples:
|
|
|
6
6
|
|
|
7
7
|
configureProviders({ crud: new FirestoreAdapter() }) // Firebase direct
|
|
8
8
|
configureProviders({ crud: new FunctionsAdapter() }) // via callable functions
|
|
9
|
-
configureProviders({ crud: new SupabaseCrudAdapter(sb) }) // Supabase direct (RLS)`);this.adapter=C("crud"),this.store&&this.store.getState().setCrudService(this)}}getQueryClient(){return _()}getListQueryOptions(t,e,i,r,o=S.LIST){const s=this.adapter,a=()=>this._ensureAdapter();return{queryKey:["crud",t,"query",JSON.stringify(e)],queryFn:async()=>{if(s||await a(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.query(t,e,i,o)},staleTime:r?.staleTime??m}}getDocQueryOptions(t,e,i,r){const o=this.adapter,s=()=>this._ensureAdapter();return{queryKey:["crud",t,"get",e],queryFn:async()=>{if(o||await s(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.get(t,e,i)},staleTime:r?.staleTime??m}}_updateGetCache(t,e,i,r){const o=this.getQueryClient(),s=["crud",t,"get",e];r===h.DELETE?o.removeQueries({queryKey:s}):r===h.SET&&i?o.setQueryData(s,i):(r===h.UPDATE||r===h.ADD)&&i&&o.setQueryData(s,a=>a?{...a,...i}:i)}_updateListCaches(t,e,i,r){const o=this.getQueryClient();this._updateGetCache(t,e,i,r),o.setQueriesData({queryKey:["crud",t]},s=>{if(s&&typeof s=="object"&&"items"in s){const a=s;let c=a.items;return r===h.DELETE?(c=a.items.filter(n=>n!=null&&typeof n=="object"&&n.id!==e),{...a,items:c,total:Math.max(0,(a.total??c.length)-1)}):r===h.ADD&&i?(c=[...a.items,{...i,id:e}],{...a,items:c,total:(a.total??a.items.length)+1}):(r===h.UPDATE||r===h.SET)&&i&&a.items.some(n=>n!=null&&typeof n=="object"&&n.id===e)?(c=a.items.map(n=>n==null||typeof n!="object"||n.id!==e?n:r===h.SET?{...i,id:e}:{...n,...i}),{...a,items:c}):s}if(Array.isArray(s)){if(r===h.DELETE)return s.filter(a=>a.id!==e);if(r===h.ADD&&i)return[...s,{...i,id:e}];if((r===h.UPDATE||r===h.SET)&&i)return s.some(a=>a!=null&&typeof a=="object"&&a.id===e)?s.map(a=>a==null||typeof a!="object"||a.id!==e?a:r===h.SET?{...i,id:e}:{...a,...i}):s}return s})}_checkUniquenessFromCache(t,e,i){const r=i.metadata?.uniqueKeys;if(!r||r.length===0)return null;const o=this.getQueryClient().getQueriesData({queryKey:["crud",t]}),s=[];for(const[,c]of o)c&&typeof c=="object"&&"items"in c?s.push(...c.items):Array.isArray(c)&&s.push(...c);if(s.length===0)return null;const a=e;for(const c of r){if(!c.fields.every(u=>a[u]!=null&&a[u]!==""))continue;const n=s.find(u=>c.fields.every(l=>{const g=typeof a[l]=="string"?a[l].toLowerCase():a[l],f=typeof u[l]=="string"?u[l].toLowerCase():u[l];return g===f}));if(n){if(c.findOrCreate)return n.id;const u=c.fields.join(" + ");throw d(new Error(c.errorMessage||`Duplicate ${u}`),{userMessage:c.errorMessage||`A record with this ${u} already exists`,showNotification:!0})}}return null}_getItemFromListCache(t,e){const i=this.getQueryClient().getQueriesData({queryKey:["crud",t]});for(const[,r]of i)if(r?.items){const o=r.items.find(s=>s.id===e);if(o)return o}return null}async invalidateCollection(t){await this.getQueryClient().invalidateQueries({queryKey:["crud",t]})}async get(t,e,i,r){if(await this._ensureAdapter(),r?.noCache)return this._getFromAdapter(t,e,i);this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{return await this.getQueryClient().fetchQuery({queryKey:["crud",t,"get",e],queryFn:()=>this._getFromAdapter(t,e,i,!1),staleTime:r?.staleTime??m})}catch(o){const s=d(o,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _getFromAdapter(t,e,i,r=!0){this.store&&r&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i);const o=await this.adapter.get(t,e,i);if(o&&this.security){const s=this._getPiiFields(i);if(s.length>0)return this.security.decryptPii(o,s)}return o}catch(o){const s=d(o,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&r&&this.store.getState().setLoading(t,!1)}}async query(t,e,i,r,o=S.LIST){if(await this._ensureAdapter(),r?.noCache)return this._queryFromAdapter(t,e,i,!0,o);this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{return await this.getQueryClient().fetchQuery({queryKey:["crud",t,"query",JSON.stringify(e)],queryFn:()=>this._queryFromAdapter(t,e,i,!1,o),staleTime:r?.staleTime??m})}catch(s){const a=d(s,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _queryFromAdapter(t,e,i,r=!0,o=S.LIST){this.store&&r&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i);const s=await this.adapter.query(t,e,i,o);if(this.security&&s.items.length>0){const a=this._getPiiFields(i);a.length>0&&(s.items=s.items.map(c=>this.security.decryptPii(c,a)))}return s}catch(s){const a=d(s,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&r&&this.store.getState().setLoading(t,!1)}}_getEntityName(t){const e=y();let i=`entity-${t}`,r=e.t("name",{ns:i,defaultValue:null});return r&&r!=="name"&&r!==`${i}:name`||t.endsWith("s")&&t.length>1&&(i=`entity-${t.slice(0,-1)}`,r=e.t("name",{ns:i,defaultValue:null}),r&&r!=="name"&&r!==`${i}:name`)?r:t}async set(t,e,i,r,o){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??null;this.store&&this.store.getState().updateOptimistic(t,e,i,s);try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,r),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const a=this._getPiiFields(r),c=a.length>0&&this.security?this.security.encryptPii(i,a):i;if(await this.adapter.set(t,e,c,r),this._updateListCaches(t,e,i,h.SET),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const n=y(),u=this._getEntityName(t);p("success",n.t("messages.updateSuccess",{ns:"crud",entity:u}))}}catch(a){s&&this._updateListCaches(t,e,s,h.SET),this.store&&this.store.getState().rejectUpdate(t,e);const c=d(a,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,c),c}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,e,i,r,o){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),a=s?{...s,...i}:{...i,id:e};this.store&&this.store.getState().updateOptimistic(t,e,a,s??null);try{if(!this.adapter)throw new Error("Adapter not initialized");r&&this._assertCanAccess(t,r),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const c=r?this._getPiiFields(r):[],n=c.length>0&&this.security?this.security.encryptPii(i,c):i;if(await this.adapter.update(t,e,n),this._updateListCaches(t,e,a,h.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const u=y(),l=this._getEntityName(t);p("success",u.t("messages.updateSuccess",{ns:"crud",entity:l}))}}catch(c){s?this._updateListCaches(t,e,s,h.UPDATE):this.invalidateCollection(t),this.store&&this.store.getState().rejectUpdate(t,e);const n=d(c,{userMessage:`Failed to update ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,n),n}finally{this.store&&this.store.getState().setLoading(t,!1)}}async delete(t,e,i){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const r=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&r&&this.store.getState().deleteOptimistic(t,e,r);try{if(!this.adapter)throw new Error("Adapter not initialized");if(this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write"),await this.adapter.delete(t,e),this._updateListCaches(t,e,null,h.DELETE),this.store&&this.store.getState().confirmDelete(t,e),this._auditCrud("crud.delete",t,e),this.security?.recordAnomaly?.("bulk.deletes",this.currentUserId??void 0),this._shouldShowSuccessToast(i)){const o=y(),s=this._getEntityName(t);p("success",o.t("messages.deleteSuccess",{ns:"crud",entity:s}))}}catch(o){r&&this._updateListCaches(t,e,r,h.ADD),this.store&&this.store.getState().rejectDelete(t,e);const s=d(o,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,e,i,r){await this._ensureAdapter();const o=this._checkUniquenessFromCache(t,e,i);if(o)return o;this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=`temp_${crypto.randomUUID()}`;this.store&&this.store.getState().addOptimistic(t,s,{...e,id:s});try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const a=this._getPiiFields(i),c=a.length>0&&this.security?this.security.encryptPii(e,a):e,n=await this.adapter.add(t,c,i),u=n.id,l=n.data;if(this._updateListCaches(t,s,null,h.DELETE),this._updateListCaches(t,u,l,h.ADD),this.store&&this.store.getState().confirmOptimistic(t,s,u,l),this._auditCrud("crud.create",t,u),this._shouldShowSuccessToast(r)){const g=y(),f=this._getEntityName(t);p("success",g.t("messages.createSuccess",{ns:"crud",entity:f}))}return u}catch(a){this._updateListCaches(t,s,null,h.DELETE),this.store&&this.store.getState().rejectOptimistic(t,s);const c=d(a,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,c),c}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,e,i,r){if(!this.adapter){let o=!1,s=null;return this._ensureAdapter().then(()=>{o||(s=this._subscribeSync(t,e,i,r))}).catch(a=>{o||i(null,d(a))}),()=>{o=!0,s?.()}}return this._subscribeSync(t,e,i,r)}_subscribeSync(t,e,i,r){try{const o=this.adapter;return o?o.subscribe?(this._assertCanAccess(t,r),o.subscribe(t,e,(s,a)=>{s&&this.getQueryClient().setQueryData(["crud",t,"get",e],s),i(s,a)},r)):()=>{}:(i(null,new Error("Adapter not initialized")),()=>{})}catch(o){return i(null,d(o)),()=>{}}}subscribeToCollection(t,e,i,r){if(!this.adapter){let o=!1,s=null;return this._ensureAdapter().then(()=>{o||(s=this._subscribeToCollectionSync(t,e,i,r))}).catch(a=>{o||i([],d(a))}),()=>{o=!0,s?.()}}return this._subscribeToCollectionSync(t,e,i,r)}_subscribeToCollectionSync(t,e,i,r){try{const o=this.adapter;return o?o.subscribeToCollection?(this._assertCanAccess(t,r),o.subscribeToCollection(t,e,(s,a)=>{s&&this.getQueryClient().setQueryData(["crud",t,"query",JSON.stringify(e)],c=>c?{...c,items:s}:{items:s}),i(s,a)},r)):()=>{}:(i([],new Error("Adapter not initialized")),()=>{})}catch(o){return i([],d(o)),()=>{}}}async addOptimistic(t,e,i,r){await this._ensureAdapter();const o=this._checkUniquenessFromCache(t,e,i);if(o)return{...e,id:o};this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const s=`temp_${crypto.randomUUID()}`,a={...e,id:s,_optimistic:!0};this.store&&this.store.getState().addOptimistic(t,s,a);try{if(!this.adapter)throw new Error("Adapter not initialized");const c=await this.adapter.add(t,e,i),n=c.id,u=c.data;if(this._updateListCaches(t,s,null,h.DELETE),this._updateListCaches(t,n,u,h.ADD),this.store&&this.store.getState().confirmOptimistic(t,s,n,u),this._auditCrud("crud.create",t,n),this._shouldShowSuccessToast(r)){const l=y(),g=this._getEntityName(t);p("success",l.t("messages.createSuccess",{ns:"crud",entity:g}))}return u}catch(c){throw this._updateListCaches(t,s,null,h.DELETE),this.store&&this.store.getState().rejectOptimistic(t,s),d(c,{userMessage:`Failed to create ${t}`,showNotification:!0})}}async updateOptimistic(t,e,i,r,o){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),a=s?{...s,...i,_optimistic:!0}:{...i,id:e,_optimistic:!0};this.store&&s&&this.store.getState().updateOptimistic(t,e,a,s);try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,e,i);const{_optimistic:c,...n}=a;if(this._updateListCaches(t,e,n,h.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const u=y(),l=this._getEntityName(t);p("success",u.t("messages.updateSuccess",{ns:"crud",entity:l}))}return n}catch(c){throw s&&this._updateListCaches(t,e,s,h.UPDATE),this.store&&this.store.getState().rejectUpdate(t,e),d(c,{userMessage:`Failed to update ${t}`,showNotification:!0})}}async deleteOptimistic(t,e,i){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const r=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&r&&this.store.getState().deleteOptimistic(t,e,r);try{if(!this.adapter)throw new Error("Adapter not initialized");if(await this.adapter.delete(t,e),this._updateListCaches(t,e,null,h.DELETE),this.store&&this.store.getState().confirmDelete(t,e),this._auditCrud("crud.delete",t,e),this.security?.recordAnomaly?.("bulk.deletes",this.currentUserId??void 0),this._shouldShowSuccessToast(i)){const o=y(),s=this._getEntityName(t);p("success",o.t("messages.deleteSuccess",{ns:"crud",entity:s}))}}catch(o){throw r&&this._updateListCaches(t,e,r,h.ADD),this.store&&this.store.getState().rejectDelete(t,e),d(o,{userMessage:`Failed to delete ${t}`,showNotification:!0})}}}const T=w(()=>new L);export{T as getCrudService};
|
|
9
|
+
configureProviders({ crud: new SupabaseCrudAdapter(sb) }) // Supabase direct (RLS)`);this.adapter=A("crud"),this.store&&this.store.getState().setCrudService(this)}}getQueryClient(){return E()}getListQueryOptions(t,e,i,r,o=S.LIST){const s=this.adapter,a=()=>this._ensureAdapter();return{queryKey:["crud",t,"query",JSON.stringify(e)],queryFn:async()=>{if(s||await a(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.query(t,e,i,o)},staleTime:r?.staleTime??m}}getDocQueryOptions(t,e,i,r){const o=this.adapter,s=()=>this._ensureAdapter();return{queryKey:["crud",t,"get",e],queryFn:async()=>{if(o||await s(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.get(t,e,i)},staleTime:r?.staleTime??m}}_updateGetCache(t,e,i,r){const o=this.getQueryClient(),s=["crud",t,"get",e];r===h.DELETE?o.removeQueries({queryKey:s}):r===h.SET&&i?o.setQueryData(s,i):(r===h.UPDATE||r===h.ADD)&&i&&o.setQueryData(s,a=>a?{...a,...i}:i)}_updateListCaches(t,e,i,r){const o=this.getQueryClient();this._updateGetCache(t,e,i,r),o.setQueriesData({queryKey:["crud",t]},s=>{if(s&&typeof s=="object"&&"items"in s){const a=s;let n=a.items;return r===h.DELETE?(n=a.items.filter(c=>c!=null&&typeof c=="object"&&c.id!==e),{...a,items:n,total:Math.max(0,(a.total??n.length)-1)}):r===h.ADD&&i?(n=[...a.items,{...i,id:e}],{...a,items:n,total:(a.total??a.items.length)+1}):(r===h.UPDATE||r===h.SET)&&i&&a.items.some(c=>c!=null&&typeof c=="object"&&c.id===e)?(n=a.items.map(c=>c==null||typeof c!="object"||c.id!==e?c:r===h.SET?{...i,id:e}:{...c,...i}),{...a,items:n}):s}if(Array.isArray(s)){if(r===h.DELETE)return s.filter(a=>a.id!==e);if(r===h.ADD&&i)return[...s,{...i,id:e}];if((r===h.UPDATE||r===h.SET)&&i)return s.some(a=>a!=null&&typeof a=="object"&&a.id===e)?s.map(a=>a==null||typeof a!="object"||a.id!==e?a:r===h.SET?{...i,id:e}:{...a,...i}):s}return s})}_checkUniquenessFromCache(t,e,i){const r=i.metadata?.uniqueKeys;if(!r||r.length===0)return null;const o=this.getQueryClient().getQueriesData({queryKey:["crud",t]}),s=[];for(const[,n]of o)n&&typeof n=="object"&&"items"in n?s.push(...n.items):Array.isArray(n)&&s.push(...n);if(s.length===0)return null;const a=e;for(const n of r){if(!n.fields.every(u=>a[u]!=null&&a[u]!==""))continue;const c=s.find(u=>n.fields.every(d=>{const g=typeof a[d]=="string"?a[d].toLowerCase():a[d],f=typeof u[d]=="string"?u[d].toLowerCase():u[d];return g===f}));if(c){if(n.findOrCreate)return c.id;const u=n.fields.join(" + ");throw l(new Error(n.errorMessage||`Duplicate ${u}`),{userMessage:n.errorMessage||`A record with this ${u} already exists`,showNotification:!0})}}return null}_getItemFromListCache(t,e){const i=this.getQueryClient().getQueriesData({queryKey:["crud",t]});for(const[,r]of i)if(r?.items){const o=r.items.find(s=>s.id===e);if(o)return o}return null}async invalidateCollection(t){await this.getQueryClient().invalidateQueries({queryKey:["crud",t]})}async get(t,e,i,r){if(await this._ensureAdapter(),r?.noCache)return this._getFromAdapter(t,e,i);this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{return await this.getQueryClient().fetchQuery({queryKey:["crud",t,"get",e],queryFn:()=>this._getFromAdapter(t,e,i,!1),staleTime:r?.staleTime??m})}catch(o){const s=l(o,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _getFromAdapter(t,e,i,r=!0){this.store&&r&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i);const o=await this.adapter.get(t,e,i);if(o&&this.security){const s=this._getPiiFields(i);if(s.length>0)return this.security.decryptPii(o,s)}return o}catch(o){const s=l(o,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&r&&this.store.getState().setLoading(t,!1)}}async query(t,e,i,r,o=S.LIST){if(await this._ensureAdapter(),r?.noCache)return this._queryFromAdapter(t,e,i,!0,o);this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{return await this.getQueryClient().fetchQuery({queryKey:["crud",t,"query",JSON.stringify(e)],queryFn:()=>this._queryFromAdapter(t,e,i,!1,o),staleTime:r?.staleTime??m})}catch(s){const a=l(s,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _queryFromAdapter(t,e,i,r=!0,o=S.LIST){this.store&&r&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i);const s=await this.adapter.query(t,e,i,o);if(this.security&&s.items.length>0){const a=this._getPiiFields(i);a.length>0&&(s.items=s.items.map(n=>this.security.decryptPii(n,a)))}return s}catch(s){const a=l(s,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&r&&this.store.getState().setLoading(t,!1)}}_getEntityName(t){const e=y();let i=`entity-${t}`,r=e.t("name",{ns:i,defaultValue:null});return r&&r!=="name"&&r!==`${i}:name`||t.endsWith("s")&&t.length>1&&(i=`entity-${t.slice(0,-1)}`,r=e.t("name",{ns:i,defaultValue:null}),r&&r!=="name"&&r!==`${i}:name`)?r:t}async set(t,e,i,r,o){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??null;this.store&&this.store.getState().updateOptimistic(t,e,i,s);try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,r),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const a=this._getPiiFields(r),n=a.length>0&&this.security?this.security.encryptPii(i,a):i;if(await this.adapter.set(t,e,n,r),this._updateListCaches(t,e,i,h.SET),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const c=y(),u=this._getEntityName(t);p("success",c.t("messages.updateSuccess",{ns:"crud",entity:u}))}}catch(a){s&&this._updateListCaches(t,e,s,h.SET),this.store&&this.store.getState().rejectUpdate(t,e);const n=l(a,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,n),n}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,e,i,r,o){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),a=s?{...s,...i}:{...i,id:e};this.store&&this.store.getState().updateOptimistic(t,e,a,s??null);try{if(!this.adapter)throw new Error("Adapter not initialized");r&&this._assertCanAccess(t,r),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const n=r?this._getPiiFields(r):[],c=n.length>0&&this.security?this.security.encryptPii(i,n):i;if(await this.adapter.update(t,e,c),this._updateListCaches(t,e,a,h.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const u=y(),d=this._getEntityName(t);p("success",u.t("messages.updateSuccess",{ns:"crud",entity:d}))}}catch(n){s?this._updateListCaches(t,e,s,h.UPDATE):this.invalidateCollection(t),this.store&&this.store.getState().rejectUpdate(t,e);const c=l(n,{userMessage:`Failed to update ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,c),c}finally{this.store&&this.store.getState().setLoading(t,!1)}}async delete(t,e,i){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const r=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&r&&this.store.getState().deleteOptimistic(t,e,r);try{if(!this.adapter)throw new Error("Adapter not initialized");if(this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write"),await this.adapter.delete(t,e),this._updateListCaches(t,e,null,h.DELETE),this.store&&this.store.getState().confirmDelete(t,e),this._auditCrud("crud.delete",t,e),this.security?.recordAnomaly?.("bulk.deletes",this.currentUserId??void 0),this._shouldShowSuccessToast(i)){const o=y(),s=this._getEntityName(t);p("success",o.t("messages.deleteSuccess",{ns:"crud",entity:s}))}}catch(o){r&&this._updateListCaches(t,e,r,h.ADD),this.store&&this.store.getState().rejectDelete(t,e);const s=l(o,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,s),s}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,e,i,r){await this._ensureAdapter();const o=this._checkUniquenessFromCache(t,e,i);if(o)return o;this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const s=`temp_${crypto.randomUUID()}`;this.store&&this.store.getState().addOptimistic(t,s,{...e,id:s});try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,i),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const a=this._getPiiFields(i),n=a.length>0&&this.security?this.security.encryptPii(e,a):e,c=n;(c.status===void 0||c.status===null)&&(c.status=T);const u=await this.adapter.add(t,n,i),d=u.id,g=u.data;if(this._updateListCaches(t,s,null,h.DELETE),this._updateListCaches(t,d,g,h.ADD),this.store&&this.store.getState().confirmOptimistic(t,s,d,g),this._auditCrud("crud.create",t,d),this._shouldShowSuccessToast(r)){const f=y(),_=this._getEntityName(t);p("success",f.t("messages.createSuccess",{ns:"crud",entity:_}))}return d}catch(a){this._updateListCaches(t,s,null,h.DELETE),this.store&&this.store.getState().rejectOptimistic(t,s);const n=l(a,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,n),n}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,e,i,r){if(!this.adapter){let o=!1,s=null;return this._ensureAdapter().then(()=>{o||(s=this._subscribeSync(t,e,i,r))}).catch(a=>{o||i(null,l(a))}),()=>{o=!0,s?.()}}return this._subscribeSync(t,e,i,r)}_subscribeSync(t,e,i,r){try{const o=this.adapter;return o?o.subscribe?(this._assertCanAccess(t,r),o.subscribe(t,e,(s,a)=>{s&&this.getQueryClient().setQueryData(["crud",t,"get",e],s),i(s,a)},r)):()=>{}:(i(null,new Error("Adapter not initialized")),()=>{})}catch(o){return i(null,l(o)),()=>{}}}subscribeToCollection(t,e,i,r){if(!this.adapter){let o=!1,s=null;return this._ensureAdapter().then(()=>{o||(s=this._subscribeToCollectionSync(t,e,i,r))}).catch(a=>{o||i([],l(a))}),()=>{o=!0,s?.()}}return this._subscribeToCollectionSync(t,e,i,r)}_subscribeToCollectionSync(t,e,i,r){try{const o=this.adapter;return o?o.subscribeToCollection?(this._assertCanAccess(t,r),o.subscribeToCollection(t,e,(s,a)=>{s&&this.getQueryClient().setQueryData(["crud",t,"query",JSON.stringify(e)],n=>n?{...n,items:s}:{items:s}),i(s,a)},r)):()=>{}:(i([],new Error("Adapter not initialized")),()=>{})}catch(o){return i([],l(o)),()=>{}}}async addOptimistic(t,e,i,r){await this._ensureAdapter();const o=this._checkUniquenessFromCache(t,e,i);if(o)return{...e,id:o};this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const s=`temp_${crypto.randomUUID()}`,a={...e,id:s,_optimistic:!0};this.store&&this.store.getState().addOptimistic(t,s,a);try{if(!this.adapter)throw new Error("Adapter not initialized");const n=await this.adapter.add(t,e,i),c=n.id,u=n.data;if(this._updateListCaches(t,s,null,h.DELETE),this._updateListCaches(t,c,u,h.ADD),this.store&&this.store.getState().confirmOptimistic(t,s,c,u),this._auditCrud("crud.create",t,c),this._shouldShowSuccessToast(r)){const d=y(),g=this._getEntityName(t);p("success",d.t("messages.createSuccess",{ns:"crud",entity:g}))}return u}catch(n){throw this._updateListCaches(t,s,null,h.DELETE),this.store&&this.store.getState().rejectOptimistic(t,s),l(n,{userMessage:`Failed to create ${t}`,showNotification:!0})}}async updateOptimistic(t,e,i,r,o){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const s=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),a=s?{...s,...i,_optimistic:!0}:{...i,id:e,_optimistic:!0};this.store&&s&&this.store.getState().updateOptimistic(t,e,a,s);try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,e,i);const{_optimistic:n,...c}=a;if(this._updateListCaches(t,e,c,h.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(o)){const u=y(),d=this._getEntityName(t);p("success",u.t("messages.updateSuccess",{ns:"crud",entity:d}))}return c}catch(n){throw s&&this._updateListCaches(t,e,s,h.UPDATE),this.store&&this.store.getState().rejectUpdate(t,e),l(n,{userMessage:`Failed to update ${t}`,showNotification:!0})}}async deleteOptimistic(t,e,i){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const r=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&r&&this.store.getState().deleteOptimistic(t,e,r);try{if(!this.adapter)throw new Error("Adapter not initialized");if(await this.adapter.delete(t,e),this._updateListCaches(t,e,null,h.DELETE),this.store&&this.store.getState().confirmDelete(t,e),this._auditCrud("crud.delete",t,e),this.security?.recordAnomaly?.("bulk.deletes",this.currentUserId??void 0),this._shouldShowSuccessToast(i)){const o=y(),s=this._getEntityName(t);p("success",o.t("messages.deleteSuccess",{ns:"crud",entity:s}))}}catch(o){throw r&&this._updateListCaches(t,e,r,h.ADD),this.store&&this.store.getState().rejectDelete(t,e),l(o,{userMessage:`Failed to delete ${t}`,showNotification:!0})}}}const b=w(()=>new D);export{b as getCrudService};
|
package/dist/CrudStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAEV,SAAS,EACT,WAAW,EAIZ,MAAM,SAAS,CAAC;AAyBjB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iIAuZvB,CAAC"}
|
package/dist/CrudStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as d}from"@donotdev/core";import{OPTIMISTIC_STATUSES as u,CRUD_OPERATION as a}from"./types";const D={filters:{},showFavoritesOnly:!1};function r(){return{loading:!1,error:null,lastUpdated:0,optimistic:{},ui:{...D}}}const f={crudService:null,hideSuccessToasts:!1,collections:{}},E=d({name:"crud-store",createStore:(
|
|
1
|
+
import{createDoNotDevStore as d}from"@donotdev/core";import{OPTIMISTIC_STATUSES as u,CRUD_OPERATION as a}from"./types";const D={filters:{},showFavoritesOnly:!1};function r(){return{loading:!1,error:null,lastUpdated:0,optimistic:{},ui:{...D}}}const f={crudService:null,hideSuccessToasts:!1,collections:{}},E=d({name:"crud-store",createStore:(s,n)=>({...f,setCrudService:t=>{s({crudService:t})},setHideSuccessToasts:t=>{s({hideSuccessToasts:t})},setLoading:(t,c)=>{s(o=>{const i=o.collections[t]||r();return{collections:{...o.collections,[t]:{...i,loading:c}}}})},setError:(t,c)=>{s(o=>{const i=o.collections[t]||r();return{collections:{...o.collections,[t]:{...i,error:c,loading:!1}}}})},setFilters:(t,c)=>{s(o=>{const i=o.collections[t]||r();return{collections:{...o.collections,[t]:{...i,ui:{...i.ui,filters:c}}}}})},setShowFavoritesOnly:(t,c)=>{s(o=>{const i=o.collections[t]||r();return{collections:{...o.collections,[t]:{...i,ui:{...i.ui,showFavoritesOnly:c}}}}})},getFilters:t=>n().collections[t]?.ui?.filters||{},getShowFavoritesOnly:t=>n().collections[t]?.ui?.showFavoritesOnly||!1,clearCollection:t=>{s(c=>{const{[t]:o,...i}=c.collections;return{collections:i}})},clearError:t=>{s(c=>{const o=c.collections[t];return o?{collections:{...c.collections,[t]:{...o,error:null}}}:c})},addOptimistic:(t,c,o)=>{s(i=>{const e=i.collections[t]||r();return{collections:{...i.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:null,optimisticData:o,status:u.PENDING,operation:a.ADD}},lastUpdated:Date.now()}}}})},confirmOptimistic:(t,c,o,i)=>{s(e=>{const l=e.collections[t];if(!l)return e;const{[c]:p,...m}=l.optimistic;return{collections:{...e.collections,[t]:{...l,optimistic:m,lastUpdated:Date.now()}}}})},rejectOptimistic:(t,c)=>{s(o=>{const i=o.collections[t];if(!i)return o;const{[c]:e,...l}=i.optimistic;return{collections:{...o.collections,[t]:{...i,optimistic:l,lastUpdated:Date.now()}}}})},updateOptimistic:(t,c,o,i)=>{s(e=>{const l=e.collections[t]||r();return{collections:{...e.collections,[t]:{...l,optimistic:{...l.optimistic,[c]:{tempId:c,originalData:i,optimisticData:o,status:u.PENDING,operation:a.UPDATE}},lastUpdated:Date.now()}}}})},confirmUpdate:(t,c)=>{s(o=>{const i=o.collections[t];if(!i)return o;const{[c]:e,...l}=i.optimistic;return{collections:{...o.collections,[t]:{...i,optimistic:l}}}})},rejectUpdate:(t,c)=>{s(o=>{const i=o.collections[t];if(!i)return o;const e=i.optimistic[c];if(!e||e.operation!==a.UPDATE)return o;const{[c]:l,...p}=i.optimistic;return{collections:{...o.collections,[t]:{...i,optimistic:p,lastUpdated:Date.now()}}}})},deleteOptimistic:(t,c,o)=>{s(i=>{const e=i.collections[t];return e?{collections:{...i.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:o,optimisticData:null,status:u.PENDING,operation:a.DELETE}},lastUpdated:Date.now()}}}:i})},confirmDelete:(t,c)=>{s(o=>{const i=o.collections[t];if(!i)return o;const{[c]:e,...l}=i.optimistic;return{collections:{...o.collections,[t]:{...i,optimistic:l}}}})},rejectDelete:(t,c)=>{s(o=>{const i=o.collections[t];if(!i)return o;const e=i.optimistic[c];if(!e||e.operation!==a.DELETE)return o;const{[c]:l,...p}=i.optimistic;return{collections:{...o.collections,[t]:{...i,optimistic:p,lastUpdated:Date.now()}}}})},getLoading:t=>n().collections[t]?.loading||!1,getError:t=>n().collections[t]?.error||null,isOptimistic:(t,c)=>n().collections[t]?.optimistic[c]?.status==="pending",getOptimisticStatus:(t,c)=>n().collections[t]?.optimistic[c]?.status??null,getOptimisticData:(t,c)=>n().collections[t]?.optimistic[c]?.optimisticData??null})});export{E as useCrudStore};
|
package/dist/FieldRegistry.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @author AMBROISE PARK Consulting
|
|
8
8
|
*/
|
|
9
9
|
import type { EntityField, FieldType, ValueTypeForField } from '@donotdev/core';
|
|
10
|
+
import type { ControlledFieldProps } from './components/controlled/types';
|
|
10
11
|
import type { ComponentType, ReactElement } from 'react';
|
|
11
12
|
import type { FieldValues } from 'react-hook-form';
|
|
12
|
-
import type { ControlledFieldProps } from './components/controlled/types';
|
|
13
13
|
export type { ControlledFieldProps };
|
|
14
14
|
/**
|
|
15
15
|
* Props for uncontrolled field components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRegistry.d.ts","sourceRoot":"","sources":["../src/FieldRegistry.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"FieldRegistry.d.ts","sourceRoot":"","sources":["../src/FieldRegistry.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Firebase Functions Backend Adapter
|
|
3
|
+
* @description HTTP callable Functions adapter for secure CRUD operations
|
|
4
|
+
*
|
|
5
|
+
* **Features:**
|
|
6
|
+
* - Server-side security (admin checks, auth verification)
|
|
7
|
+
* - Schema validation on server
|
|
8
|
+
* - Idempotency keys support
|
|
9
|
+
* - Audit logs and metadata
|
|
10
|
+
* - Rate limiting
|
|
11
|
+
*
|
|
12
|
+
* @version 0.0.1
|
|
13
|
+
* @since 0.0.1
|
|
14
|
+
* @author AMBROISE PARK Consulting
|
|
15
|
+
*/
|
|
1
16
|
import type { dndevSchema, ICrudAdapter, ListSchemaType, PaginatedQueryResult } from '@donotdev/core';
|
|
2
17
|
/**
|
|
3
18
|
* Query options for Functions queries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionsAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/FunctionsAdapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FunctionsAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/FunctionsAdapter.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EACZ,cAAc,EACd,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AASxB;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnE,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAgBD,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,cAAc,QAAQ;IAE/B;;OAEG;YACW,WAAW;IAWzB;;OAEG;YACW,aAAa;IASrB,GAAG,CAAC,CAAC,EACT,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAgBd,GAAG,CAAC,CAAC,EACT,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,IAAI,CAAC;IAaV,MAAM,CAAC,CAAC,EACZ,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,IAAI,CAAC;IAmBV,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBzD,GAAG,CAAC,CAAC,EACT,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAwBnD,KAAK,CAAC,CAAC,EACX,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAC5B,UAAU,GAAE,cAAsC,GACjD,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAqEnC,SAAS,CAAC,CAAC,KAAK,MAAM,IAAI;IAS1B,qBAAqB,CAAC,CAAC,KAAK,MAAM,IAAI;CAQvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasProvider as w,getProvider as h,wrapCrudError as l,validateWithSchema as o}from"@donotdev/core";import{LIST_SCHEMA_TYPE as u}from"@donotdev/core";let c=null;class p{serverSideOnly=!0;async getCallable(){if(w("callable"))return h("callable");if(!c){const{FirebaseCallableProvider:t}=await import("@donotdev/firebase");c=new t}return c}async getCallableFn(t){const a=await this.getCallable();return async
|
|
1
|
+
import{hasProvider as w,getProvider as h,wrapCrudError as l,validateWithSchema as o}from"@donotdev/core";import{LIST_SCHEMA_TYPE as u}from"@donotdev/core";let c=null;class p{serverSideOnly=!0;async getCallable(){if(w("callable"))return h("callable");if(!c){const{FirebaseCallableProvider:t}=await import("@donotdev/firebase");c=new t}return c}async getCallableFn(t){const a=await this.getCallable();return async i=>({data:await a.call(t,i)})}async get(t,a,i){const n=`get_${t}`,s=await this.getCallableFn(n);try{const e=(await s({id:a})).data;return i?o(i,e,"FunctionsAdapter.get"):e}catch(e){throw l(e,"FunctionsAdapter","get",t,a)}}async set(t,a,i,n){const s=o(n,i,"FunctionsAdapter.set"),e=`update_${t}`,d=await this.getCallableFn(e);try{await d({id:a,payload:s})}catch(r){throw l(r,"FunctionsAdapter","set",t,a)}}async update(t,a,i){const n=`update_${t}`,s=await this.getCallableFn(n);try{await s({id:a,payload:i})}catch(e){throw l(e,"FunctionsAdapter","update",t,a)}}async delete(t,a){const i=`delete_${t}`,n=await this.getCallableFn(i);try{await n({id:a})}catch(s){throw l(s,"FunctionsAdapter","delete",t,a)}}async add(t,a,i){const n=o(i,a,"FunctionsAdapter.add"),s=`create_${t}`,e=await this.getCallableFn(s);try{const d=await e({payload:n});if(!d.data)throw l(new Error("Create function returned no data"),"FunctionsAdapter","add",t);return{id:d.data.id,data:d.data}}catch(d){throw l(d,"FunctionsAdapter","add",t)}}async query(t,a,i,n=u.LIST){const s=n===u.LIST_CARD?`listCard_${t}`:`list_${t}`,e={};a.where&&(e.where=a.where.map(r=>[r.field,r.operator,r.value])),a.orderBy&&(e.orderBy=a.orderBy.map(r=>[r.field,r.direction||"asc"])),a.limit&&(e.limit=a.limit),a.startAfter&&(e.startAfterId=a.startAfter);const d=await this.getCallableFn(s);try{const r=await d(e);if(!r.data)throw l(new Error("Query function returned no data"),"FunctionsAdapter","query",t);return{items:r.data.items,total:r.data.count,hasMore:r.data.hasMore,lastVisible:r.data.lastVisible}}catch(r){throw l(r,"FunctionsAdapter","query",t)}}subscribe(){return()=>{}}subscribeToCollection(){return()=>{}}}export{p as FunctionsAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as d}from"react/jsx-runtime";import{ActionButton as n}from"@donotdev/components";import{useCrudStore as a}from"../CrudStore";function c({requiresAuth:r=!0,user:e,disabled:t=!1,children:
|
|
1
|
+
"use client";import{jsx as d}from"react/jsx-runtime";import{ActionButton as n}from"@donotdev/components";import{useCrudStore as a}from"../CrudStore";function c({requiresAuth:r=!0,user:e,disabled:t=!1,children:s,...i}){const o=a(u=>!!u.crudService);return d(n,{...i,disabled:t||!o||r&&!e,children:s})}var l=c;export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as
|
|
1
|
+
import{jsx as o,jsxs as B}from"react/jsx-runtime";import{Trash2 as G}from"lucide-react";import{useMemo as g}from"react";import{Card as H,Stack as D,Text as V,ActionButton as J}from"@donotdev/components";import{useTranslation as I,getListCardFieldNames as K}from"@donotdev/core";import{formatValue as h}from"./DisplayFieldRenderer";import{DisplayThumbnail as L}from"./DisplayThumbnail";import{translateFieldLabel as O}from"../forms/utils/translateFieldLabel";import{useCrud as Q}from"../useCrud";function d(e){return e==="image"||e==="images"}function U(e){return g(()=>{const t=e.listCardFields;if(t&&!Array.isArray(t)){const s=t;return{titleFields:s.title??[],subtitleFields:s.subtitle??[],contentFields:s.content??[],footerFields:s.footer??[]}}const c=K(e),f=c.filter(s=>!d(e.fields[s]?.type)),v=c.filter(s=>d(e.fields[s]?.type)),C=f.length>0?[f[0]]:[],b=[...f.slice(1,4),...v];return{titleFields:C,subtitleFields:[],contentFields:b,footerFields:[]}},[e])}function N({item:e,entity:t,onClick:c,titleFields:f,subtitleFields:v,contentFields:C,footerFields:b,showDelete:s=!1,renderActions:j,elevated:R=!0,className:z}){const{t:a}=I([t.namespace,"crud"]),{t:p}=I("crud"),y=U(t),x=f??y.titleFields,S=v??y.subtitleFields,A=C??y.contentFields,m=b??y.footerFields,T=g(()=>{if(!x?.length)return e.id??"";const r=x.filter(i=>typeof i=="string").filter(i=>!d(t.fields[i]?.type)).map(i=>{const n=t.fields[i],F=e[i],u=n?h(F,n,a,{compact:!0,asString:!0}):F;return typeof u=="string"?u:String(u??"")}).filter(Boolean),l=!Array.isArray(t.listCardFields)&&t.listCardFields?.titleSeparator!=null?t.listCardFields.titleSeparator:" ";return r.join(l)||String(e.id??"")},[e,t.fields,x,t.listCardFields,a]),M=g(()=>S?.length&&S.filter(r=>typeof r=="string").filter(r=>!d(t.fields[r]?.type)).map(r=>{const l=t.fields[r],i=e[r],n=l?h(i,l,a,{compact:!0,asString:!0}):i;return typeof n=="string"?n:String(n??"")}).filter(Boolean).join(" ")||void 0,[e,t.fields,S,a]),P=g(()=>{if(!A?.length)return null;const r=A.map(l=>{const i=t.fields[l];if(!i)return null;if(d(i.type)){const n=e[l];return n==null?null:o(L,{pictures:n,alt:String(T),aspectRatio:"16/9"},l)}return B("div",{children:[o(V,{level:"small",variant:"muted",children:O(l,i,a)}),o(V,{children:h(e[l],i,a,{compact:!0})})]},l)}).filter(Boolean);return r.length>0?o(D,{direction:"column",gap:"tight",children:r}):null},[e,t.fields,A,T,a]),q=g(()=>{if(!m?.length)return;if(m.some(l=>d(t.fields[l]?.type))){const l=m.map(i=>{const n=t.fields[i];if(!n)return null;if(d(n.type)){const u=e[i];return u==null?null:o(L,{pictures:u,alt:"",aspectRatio:"1"},i)}const F=h(e[i],n,a,{compact:!0});return o("span",{children:F},i)});return o(D,{direction:"row",gap:"tight",align:"center",children:l.filter(Boolean)})}const r=m.map(l=>{const i=t.fields[l];return i?h(e[l],i,a,{compact:!0}):e[l]});return o(V,{level:"small",children:r.join(" \xB7 ")})},[e,t.fields,m,a]),E=Q(t).delete,k=o(H,{title:String(T??""),subtitle:M,content:P??void 0,footer:q,clickable:!!c,onClick:c?()=>c(e.id):void 0,elevated:R,className:z}),w=j||s?B("div",{style:{position:"absolute",top:"var(--gap-sm)",right:"var(--gap-sm)",zIndex:10,display:"flex",alignItems:"flex-start",gap:"var(--gap-xs)"},onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:[j,s&&o(J,{action:async()=>{await E(e.id)},confirmText:p("delete.confirm",{defaultValue:"Are you sure you want to delete this item?"}),confirmTitle:p("delete.title",{defaultValue:"Delete Item"}),loadingText:p("delete.loading",{defaultValue:"Deleting..."}),variant:"destructive",icon:G,"aria-label":p("delete",{defaultValue:"Delete"}),children:p("delete",{defaultValue:"Delete"})})]}):null;return w?B("div",{style:{position:"relative",height:"100%"},children:[k,w]}):k}var W=N;export{N as CrudCard,W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateFilter.d.ts","sourceRoot":"","sources":["../../src/components/DateFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateFilter.d.ts","sourceRoot":"","sources":["../../src/components/DateFilter.tsx"],"names":[],"mappings":"AAyBA,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9C,0EAA0E;IAC1E,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,yCAAyC;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,CAAC;IACvD,8CAA8C;IAC9C,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IACjE,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAa,GACd,EAAE,eAAe,2CAySjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as b,Fragment as ct}from"react/jsx-runtime";import{X as ht}from"lucide-react";import{useState as k,useMemo as ut}from"react";import{Button as S,Calendar as St,FloatingLabel as Dt,Sheet as T,Text as ft}from"@donotdev/components";import{formatDate as $t}from"@donotdev/core";function xt({label:D,fieldType:vt,value:l,onChange:f,tCrud:i,locale:O="en"}){const[M,d]=k(!1),[F,$]=k(null),j=ut(()=>l?typeof l=="object"&&l!==null&&"min"in l?{min:l.min||"",max:l.max||""}:{min:"",max:""}:{min:"",max:""},[l]),C=t=>{if(!t)return"";try{const n=new Date(t+"T00:00:00");return $t(n,O)}catch{return t}},W=()=>{const t=new Date;t.setHours(0,0,0,0);const n=t.getFullYear(),g=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=`${n}-${g}-${r}`,o=new Date(t);o.setDate(o.getDate()-1);const v=o.getFullYear(),x=String(o.getMonth()+1).padStart(2,"0"),z=String(o.getDate()).padStart(2,"0"),B=`${v}-${x}-${z}`,m=new Date(t);m.setDate(m.getDate()+1);const H=m.getFullYear(),L=String(m.getMonth()+1).padStart(2,"0"),X=String(m.getDate()).padStart(2,"0"),q=`${H}-${L}-${X}`,p=new Date(t);p.setDate(p.getDate()-7);const A=p.getFullYear(),G=String(p.getMonth()+1).padStart(2,"0"),I=String(p.getDate()).padStart(2,"0"),J=`${A}-${G}-${I}`,c=new Date(t);c.setDate(c.getDate()-30);const K=c.getFullYear(),P=String(c.getMonth()+1).padStart(2,"0"),Q=String(c.getDate()).padStart(2,"0"),R=`${K}-${P}-${Q}`,h=new Date(t);h.setDate(h.getDate()+7);const U=h.getFullYear(),Z=String(h.getMonth()+1).padStart(2,"0"),_=String(h.getDate()).padStart(2,"0"),tt=`${U}-${Z}-${_}`,u=new Date(t);u.setDate(u.getDate()+30);const et=u.getFullYear(),at=String(u.getMonth()+1).padStart(2,"0"),nt=String(u.getDate()).padStart(2,"0"),rt=`${et}-${at}-${nt}`,w=new Date(t.getFullYear(),t.getMonth(),1),lt=w.getFullYear(),it=String(w.getMonth()+1).padStart(2,"0"),dt=String(w.getDate()).padStart(2,"0"),ot=`${lt}-${it}-${dt}`,y=new Date(t.getFullYear(),t.getMonth()+1,0),gt=y.getFullYear(),st=String(y.getMonth()+1).padStart(2,"0"),mt=String(y.getDate()).padStart(2,"0"),pt=`${gt}-${st}-${mt}`;return{today:s,yesterday:B,tomorrow:q,last7Days:J,last30Days:R,next7Days:tt,next30Days:rt,thisMonthStart:ot,thisMonthEnd:pt}},a=j,E=W(),N=!!(a?.min||a?.max),Y=t=>{const n=t==="start",g=n?a?.min:a?.max;return e("div",{style:{padding:"var(--gap-md)"},children:b("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-md)"},children:[e("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--gap-tight)"},children:(n?["today","yesterday","last7Days","last30Days","thisMonthStart"]:["today","tomorrow","next7Days","next30Days","thisMonthEnd"]).map(r=>{const s=E[r];return e(S,{variant:"outline",onClick:()=>{f({min:n?s:a?.min||"",max:n?a?.max||"":s}),d(!1)},children:i(`filter.${r}`,{defaultValue:r})},r)})}),e(St,{selected:g?new Date(g+"T00:00:00"):void 0,mode:"single",onSelect:r=>{if(!r)return;const s=r.getFullYear(),o=String(r.getMonth()+1).padStart(2,"0"),v=String(r.getDate()).padStart(2,"0"),x=`${s}-${o}-${v}`;f({min:n?x:a?.min||"",max:n?a?.max||"":x}),d(!1)},defaultMonth:g?new Date(g+"T00:00:00"):new Date}),e(S,{variant:"ghost",display:"compact",onClick:()=>{f({min:n?"":a?.min||"",max:n&&a?.max||""}),d(!1)},children:i("filter.clear",{defaultValue:"Clear"})})]})})},V=b(ct,{children:[e(T,{trigger:e(S,{variant:"ghost",onClick:()=>{$("start"),d(!0)},style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?.min?C(a.min):i("filter.min",{defaultValue:"Min"})}),title:`${D} - ${i("filter.min",{defaultValue:"Min"})}`,open:M&&F==="start",onOpenChange:t=>{d(t),t||$(null)},children:Y("start")}),e(ft,{level:"small",variant:"muted",className:"dndev-range-input-separator",children:"\u2013"}),e(T,{trigger:e(S,{variant:"ghost",onClick:()=>{$("end"),d(!0)},style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?.max?C(a.max):i("filter.max",{defaultValue:"Max"})}),title:`${D} - ${i("filter.max",{defaultValue:"Max"})}`,open:M&&F==="end",onOpenChange:t=>{d(t),t||$(null)},children:Y("end")}),e(S,{variant:"ghost",display:"compact",icon:e(ht,{size:16}),onClick:()=>{f(void 0)},disabled:!N,"aria-label":i("filter.clear",{defaultValue:"Clear"})})]});return D?e(Dt,{label:D,children:e("div",{className:"dndev-range-input",children:V})}):e("div",{className:"dndev-range-input",children:V})}export{xt as DateFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DisplayFieldRenderer.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"DisplayFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DisplayFieldRenderer.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACxE,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,0BAA0B;IAC1B,KAAK,EAAE,GAAG,CAAC;IACX,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;CAC3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,WAAW,EACnB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,EACzD,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,GAAG,YAAY,CA0DvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,EACpE,IAAI,EACJ,MAAM,EACN,KAAK,EACL,CAAC,GACF,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,YAAY,CAyC7C;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as r,jsxs as s}from"react/jsx-runtime";import{Text as a,Stack as c}from"@donotdev/components";import{handleError as d}from"@donotdev/core";import{getDisplayFormatter as u}from"../fieldTypeRegistry";import{translateFieldLabel as y}from"../forms/utils";function m(t,e,o,n){const i=n?.compact??!1;if(t==null||t==="")return i?r("span",{style:{color:"var(--muted-foreground)"},children:"\u2014"}):r(a,{variant:"muted",children:"\u2014"});const l=u(e.type);if(l)try{return l(t,e,o,n)}catch(f){return d(f,{userMessage:`Error formatting field "${e.label||e.name}"`,context:{fieldType:e.type,fieldName:e.label||"unknown",operation:"display_format"},severity:"warning"}),i?r("span",{style:{color:"var(--muted-foreground)"},children:String(t)}):r(a,{variant:"muted",children:String(t)})}return d(new Error(`Display formatter not registered for field type: ${e.type}`),{userMessage:`Field type "${e.type}" is missing display formatter`,context:{fieldType:e.type,fieldName:e.label||"unknown",operation:"display_format",fix:"Add displayFormatter to registerBuiltinFieldType() in registerBuiltinFieldTypes.tsx"},severity:"warning"}),i?r("span",{style:{color:"var(--muted-foreground)"},children:String(t)}):r(a,{variant:"muted",children:String(t)})}function p({name:t,config:e,value:o,t:n}){const i=m(o,e,n,{compact:!1}),l=y(t,e,n);return s(c,{direction:"row",align:"baseline",style:{marginBottom:"var(--gap-sm)",padding:"var(--gap-sm)",minHeight:"38px",alignItems:"center"},children:[s(a,{variant:"muted",style:{fontSize:"var(--font-size-sm)",fontWeight:500,minWidth:"fit-content",flexShrink:0},children:[l,":"]}),r("div",{style:{flex:1,display:"flex",alignItems:"center"},children:typeof i=="string"?r(a,{children:i}):i})]})}var g=p;export{p as DisplayFieldRenderer,g as default,m as formatValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";function o(t){if(t==null)return null;if(typeof t=="string")return t||null;const l=Array.isArray(t)&&t.length>0?t[0]:t;if(!l||typeof l!="object")return null;const e=l.thumbUrl??l.fullUrl;return typeof e=="string"?e:null}function r({pictures:t,alt:l="",aspectRatio:e="16/9",className:a,style:s}){const i=o(t);return i?n("div",{className:a,style:{width:"100%",aspectRatio:e,borderRadius:"var(--radius-md)",overflow:"hidden",backgroundColor:"var(--muted)",position:"relative",...s},children:n("img",{src:i,alt:l,loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"}})}):null}var u=r;export{r as DisplayThumbnail,u as default};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GridCols } from '@donotdev/components';
|
|
1
2
|
import type { Entity } from '@donotdev/core';
|
|
2
3
|
export { matchesFilter } from '../utils/matchesFilter';
|
|
3
4
|
export interface EntityFiltersProps<T extends Record<string, any> & {
|
|
@@ -11,6 +12,8 @@ export interface EntityFiltersProps<T extends Record<string, any> & {
|
|
|
11
12
|
fieldsToFilter?: string[];
|
|
12
13
|
/** Layout variant: 'inline' (multi-column grid) or 'sidebar' (single column stack) */
|
|
13
14
|
variant?: 'inline' | 'sidebar';
|
|
15
|
+
/** Override responsive grid columns. Default: [2, 4, 6] for inline, 2 for sidebar. */
|
|
16
|
+
cols?: GridCols;
|
|
14
17
|
/** Optional: Data array to extract unique values and min/max from (if not provided, fetches automatically) */
|
|
15
18
|
data?: T[];
|
|
16
19
|
}
|
|
@@ -37,5 +40,5 @@ export declare function EntityFilters<T extends Record<string, any> & {
|
|
|
37
40
|
id: string;
|
|
38
41
|
} = Record<string, any> & {
|
|
39
42
|
id: string;
|
|
40
|
-
}>({ entity, data: dataProp, fieldsToFilter, variant, }: EntityFiltersProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
}>({ entity, data: dataProp, fieldsToFilter, variant, cols, }: EntityFiltersProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
41
44
|
//# sourceMappingURL=EntityFilters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFilters.d.ts","sourceRoot":"","sources":["../../src/components/EntityFilters.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityFilters.d.ts","sourceRoot":"","sources":["../../src/components/EntityFilters.tsx"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAa7C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,kBAAkB,CACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ;IAED,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IAEf,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,sFAAsF;IACtF,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAE/B,sFAAsF;IACtF,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB,8GAA8G;IAC9G,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,aAAa,CAC3B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IACrE,EAAE,EAAE,MAAM,CAAC;CACZ,EACD,EACA,MAAM,EACN,IAAI,EAAE,QAAQ,EACd,cAAc,EACd,OAAkB,EAClB,IAAI,GACL,EAAE,kBAAkB,CAAC,CAAC,CAAC,kDA0pBvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as f,jsxs as
|
|
1
|
+
"use client";import{jsx as f,jsxs as D}from"react/jsx-runtime";import{FilterX as W}from"lucide-react";import{useMemo as A}from"react";import{Button as Y,Combobox as Z,Grid as ee,Rating as te,RangeInput as ae,Slider as ie,Stack as le}from"@donotdev/components";import{useTranslation as B,handleError as R}from"@donotdev/core";import{DateFilter as ne}from"./DateFilter";import{getFilterType as $,isFilterable as re}from"../fieldTypeRegistry";import{translateFieldLabel as se,translateLabel as I}from"../forms/utils";import{useCrudFilters as oe}from"../hooks/useCrudFilters";import{useCrudCardList as me}from"../useCrudCardList";import{matchesFilter as de}from"../utils/matchesFilter";import{matchesFilter as fe}from"../utils/matchesFilter";function ue({entity:d,data:S,fieldsToFilter:T,variant:L="inline",cols:P}){const X=L==="sidebar",{t:p,i18n:q}=B("crud"),{t:w}=B([d.namespace,"crud"]),z=q?.language||"en",{data:G}=me(d,{enabled:!S}),c=S??(G?.items||[]),{filters:b,setFilters:V}=oe({collection:d.collection}),g=A(()=>(T&&T.length>0?T:d.listFields||Object.keys(d.fields)).filter(a=>{const t=d.fields[a]?.type||"text";return re(t)}),[T,d.listFields,d.fields]),_=A(()=>{const a={};return g.forEach(t=>{const o=Object.fromEntries(Object.entries(b).filter(([i])=>i!==t));if(Object.keys(o).length===0){a[t]=c;return}a[t]=c.filter(i=>Object.entries(o).every(([m,h])=>{const F=i[m],x=d.fields[m]?.type||"text";return de(F,h,x)}))}),a},[c,b,d.fields,g]),H=A(()=>{const a={};return g.forEach(t=>{const o=d.fields[t];if(!o)return;const i=o.type||"text",m=$(i);if(!m){R(new Error(`Field type "${i}" not registered in field type registry`),{userMessage:`Field type "${i}" is missing from registry`,context:{fieldType:i,fieldName:t,operation:"minmax_computation",fix:"Add to registerBuiltinFieldTypes.ts or registerFieldType()"},severity:"warning"});return}const h=m==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"||i==="time"||i==="week"||i==="month"||i==="year"),F=m==="range"&&!h,x=i==="price";if(F||x){const n=c.map(l=>l[t]).filter(l=>l!=null&&l!=="").map(l=>x&&typeof l=="object"&&l!==null?Number(l.amount):typeof l=="number"?l:Number(l)).filter(l=>!isNaN(l));n.length>0&&(a[t]={min:Math.min(...n),max:Math.max(...n)})}else if(h){const n=c.map(l=>l[t]).filter(l=>l!=null&&l!=="").map(l=>l instanceof Date?l:new Date(l)).filter(l=>!isNaN(l.getTime()));if(n.length>0){const l=new Date(Math.min(...n.map(C=>C.getTime()))),j=new Date(Math.max(...n.map(C=>C.getTime()))),O=l.toISOString().split("T")[0],v=j.toISOString().split("T")[0];a[t]={min:O||"",max:v||""}}}}),a},[c,d.fields,g]),y=(a,t)=>{const o={...b};if(!t||t==="")delete o[a];else if(Array.isArray(t))o[a]=t;else if(typeof t=="object"&&"min"in t){const i=t.min&&t.min!=="",m=t.max&&t.max!=="";!i&&!m?delete o[a]:o[a]=t}else o[a]=t;V(o)},J=()=>{V({})},M=A(()=>g.length===0?null:g.map(a=>{const t=d.fields[a];if(!t)return null;const o=se(a,t,w),i=t.type||"text",m=$(i);if(!m)return R(new Error(`Field type "${i}" not registered in field type registry`),{userMessage:`Field type "${i}" is missing from registry`,context:{fieldType:i,fieldName:a,operation:"filter_ui_render",fix:"Add to registerBuiltinFieldTypes.ts or registerFieldType()"},severity:"warning"}),null;const h=m==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"||i==="time"||i==="week"||i==="month"||i==="year"),F=m==="range"&&!h,x=m==="select",n=b[a],l=typeof n=="object"&&n!==null&&"min"in n?n:{min:"",max:""};if(m==="rating"){const r=t.validation?.max??5,s=typeof n=="string"&&n!==""?Number(n):0;return f("div",{style:{gridColumn:"span 2",gridRow:"span 1"},children:f(te,{value:s,max:r,"aria-label":o,onChange:e=>{y(a,e===s?void 0:String(e))}})},a)}if(F){const r=H[a],s=r?.min??0,e=r?.max??100,u=l.min?Number(l.min):s,N=l.max?Number(l.max):e;return D(le,{gap:"tight",style:{gridColumn:"span 2"},children:[f(ae,{type:"number",label:o,minPlaceholder:p("filter.min",{defaultValue:"Min"}),maxPlaceholder:p("filter.max",{defaultValue:"Max"}),minValue:l.min||"",maxValue:l.max||"",actualMin:s,actualMax:e,onChange:(k,U)=>{y(a,{min:k,max:U})},onClear:()=>y(a,void 0)}),f(ie,{value:[u,N],min:s,max:e,step:1,onValueChange:k=>{y(a,{min:String(k[0]),max:String(k[1])})}})]},a)}if(h){const r=i==="week"||i==="month"||i==="year"?i:"date",s=(()=>{if(n){if(typeof n=="object"&&"min"in n){const e=n;return{min:e.min&&e.min.split("T")[0]||"",max:e.max&&e.max.split("T")[0]||""}}if(typeof n=="string"){const e=n.split("T")[0]||"";return{min:e,max:e}}}})();return f("div",{style:{gridColumn:"span 2",gridRow:"span 1"},children:f(ne,{label:o,fieldType:r,value:s,locale:z,onChange:e=>{if(!e){y(a,void 0);return}typeof e=="object"&&"min"in e&&y(a,{min:e.min||"",max:e.max||""})},tCrud:p})},a)}const j=x&&t.validation&&"options"in t.validation&&t.validation?Array.isArray(t.validation.options)?t.validation.options:typeof t.validation.options=="function"?t.validation.options():[]:[],O=_[a]||c,v=new Set,C=m==="address";O.forEach(r=>{const s=r[a];if(s!=null)if(C&&typeof s=="object"&&"formatted_address"in s){const e=s;e.formatted_address&&v.add(String(e.formatted_address))}else v.add(String(s))});const E=[{value:"all",label:p("filter.selectPlaceholder",{defaultValue:"All"})}];if(j.length>0){const r=[],s=[];j.forEach(e=>{const u=typeof e=="string"?e:e.value,N=typeof e=="string"?e:e.label;v.has(u)?r.push({value:u,label:N}):s.push({value:u,label:N})}),r.sort((e,u)=>e.label.localeCompare(u.label)),s.sort((e,u)=>e.label.localeCompare(u.label)),r.forEach(e=>{E.push({value:e.value,label:I(e.label,w),disabled:!1})}),s.forEach(e=>{E.push({value:e.value,label:I(e.label,w),disabled:!0})})}else Array.from(v).sort().slice(0,100).forEach(r=>{E.push({value:r,label:r})});return f("div",{style:{gridColumn:"span 1",gridRow:"span 1"},children:f(Z,{label:o,value:typeof n=="string"?n:void 0,onValueChange:r=>{y(a,r==="all"||!r?"":String(r))},options:E,placeholder:p("filter.placeholder",{defaultValue:"Filter..."}),clearable:!0})},a)}),[g,d.fields,c,b,w,p,_]);if(!M||M.length===0)return null;const K=M.filter(Boolean),Q=Object.keys(b).length>0;return D(ee,{cols:P??(X?2:[2,4,4,6]),children:[K,f(Y,{variant:"outline",icon:f(W,{size:18}),onClick:J,disabled:!Q,style:{gridColumn:"1 / -1",gridRow:"span 1"},children:p("filter.clear",{defaultValue:"Clear Filters"})})]})}export{ue as EntityFilters,fe as matchesFilter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FormFieldRenderer.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FormFieldRenderer.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM5D,OAAO,sBAAsB,CAAC;AAM9B,UAAU,0BAA0B,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;CAC3D;AAED,UAAU,iBAAiB,CACzB,CAAC,SAAS,SAAS,CACnB,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACrC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED,UAAU,eAAe,CACvB,CAAC,SAAS,SAAS,EACnB,YAAY,SAAS,WAAW,GAAG,WAAW,CAC9C,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,SAAS,EACnB,YAAY,SAAS,WAAW,GAAG,WAAW,IAC5C,iBAAiB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAE5D;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,SAAS,SAAS,EACnB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,EACA,IAAI,EACJ,MAAM,EACN,CAAC,EACD,GAAG,KAAK,EACT,EAAE,sBAAsB,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,YAAY,CA0GxD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{handleError as C}from"@donotdev/core";import{getFieldRegistry as F}from"../FieldRegistry";import{ControlledTextField as T}from"./controlled";import{TextFieldComponent as w}from"./form/fields";import"../builtinFieldTypes";const v=F();function h({name:o,config:e,t:r,...n}){const p=l=>i=>{try{l(i)}catch(a){C(a,{userMessage:`Error updating field ${e.label||o}`,context:{fieldName:o,fieldType:e.type},severity:"warning"})}},s="control"in n&&n.control,d=e.type==="submit"||e.type==="reset";if(s&&!d){const{control:l,errors:i}=n,a=e.options?.fieldSpecific?.placeholder,y={control:l,errors:i,fieldConfig:{...e,label:e.label||o},t:r,placeholder:a,onChange:p(()=>{})},u=v.getControlledComponent(e.type);return u?t(u,{...y}):(C(new Error(`Unregistered field type: ${e.type}`),{userMessage:r("errors.unsupportedFieldType",{type:e.type}),context:{fieldName:o,fieldType:e.type},severity:"warning"}),t(T,{...y,fieldConfig:{...e,type:"text"}}))}const b=s&&d?{name:o,config:e,t:r,value:void 0,onChange:()=>{},error:void 0}:n,{value:f,onChange:x,error:c}=b,m=p(x),g=v.getUncontrolledComponent(e.type);return g?t(g,{name:o,label:e.label||o,value:f,onChange:m,error:c,t:r,config:e,...e.options}):t(w,{label:e.label||o,value:f,onChange:m,error:c||void 0,...e.options})}var E=h;export{h as FormFieldRenderer,E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as d,jsxs as i,Fragment as N}from"react/jsx-runtime";import{useState as w}from"react";import{FormProvider as C}from"react-hook-form";import{Button as s,BUTTON_VARIANT as j,Spinner as k,cn as z,Stack as a,Grid as
|
|
1
|
+
"use client";import{jsx as d,jsxs as i,Fragment as N}from"react/jsx-runtime";import{useState as w}from"react";import{FormProvider as C}from"react-hook-form";import{Button as s,BUTTON_VARIANT as j,Spinner as k,cn as z,Stack as a,Grid as F}from"@donotdev/components";import{useTranslation as I}from"@donotdev/core";const L=({title:c,onSubmit:m,children:g,formMethods:f,loading:n=!1,submitText:u,cancelText:v,showCancel:p=!1,onCancel:h,variant:o="default",columns:b=1,description:t})=>{const{t:e}=I("crud"),[r,l]=w(!1),y=u||e("form.submit","Submit"),x=v||e("form.cancel","Cancel"),S=async T=>{l(!0);try{await m(T)}finally{l(!1)}},B={1:"dndev-grid-cols-1",2:"dndev-grid-cols-1 dndev-md:grid-cols-2",3:"dndev-grid-cols-1 dndev-md:grid-cols-2 dndev-md:grid-cols-3",4:"dndev-grid-cols-1 dndev-md:grid-cols-2 dndev-md:grid-cols-4"};return d(C,{...f,children:d("form",{onSubmit:S,className:z("dndev-mx-auto",{default:"dndev-surface",card:"dndev-surface",minimal:""}[o]),style:o!=="minimal"?{padding:"var(--gap-lg)"}:void 0,role:"form","aria-labelledby":"form-title",noValidate:!0,children:i(a,{gap:"large",children:[i(a,{gap:"tight",children:[d("h2",{id:"form-title",style:{fontSize:"var(--font-size-2xl)",fontWeight:600,color:"var(--foreground)"},children:c}),t&&d("p",{style:{color:"var(--muted-foreground)"},children:t})]}),d(F,{cols:b,className:"dndev-w-full dndev-min-w-0",children:g}),i(a,{direction:"row",align:"center",justify:"end",style:{paddingTop:"var(--gap-md)",borderTop:"1px solid var(--border)"},children:[p&&d(s,{type:"button",variant:j.OUTLINE,onClick:h,disabled:n||r,children:x}),d(s,{type:"submit",disabled:n||r,style:{minWidth:"120px"},children:n||r?i(N,{children:[d(k,{className:"me-component-gap"}),r?e("form.submitting","Submitting..."):e("form.loading","Loading...")]}):y})]})]})})})};var A=L;export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledAddressField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledAddressField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledAddressField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledAddressField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA8Bd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{AddressFieldComponent as p}from"../../form/fields";import{convertValidationRules as u}from"../types";function C(a){const{control:s,errors:r,fieldConfig:t,t:d}=a,{name:e,label:c,validation:o}=t,l=(t.options||{}).fieldSpecific;return n(f,{name:e,control:s,rules:o?u(o):void 0,render:({field:i})=>n(p,{label:d(c),value:i.value??void 0,onChange:m=>i.onChange(m),error:!!r[e],helperText:r[e]?.message,required:o?.required,enableGoogleMaps:l?.enableGoogleMaps,extractDistrictCode:l?.extractDistrictCode})})}export{C as ControlledAddressField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledDateField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledDateField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledDateField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA2C7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{DateFieldComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(a){const{control:n,errors:t,fieldConfig:i,t:m}=a,{name:e,label:d,validation:o,type:s}=i,u={date:"date","datetime-local":"datetime-local",month:"month",time:"time",week:"week"}[s]||"date";return l(f,{name:e,control:n,rules:o?C(o):void 0,render:({field:r})=>l(p,{...r,label:m(d),value:r.value??null,onChange:c=>r.onChange(c),error:!!t[e],helperText:t[e]?.message,required:o?.required,mode:u})})}export{h as ControlledDateField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledFieldArrayField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledFieldArrayField.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlledFieldArrayField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledFieldArrayField.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAmBD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA2Kd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as
|
|
1
|
+
"use client";import{jsxs as n,jsx as i}from"react/jsx-runtime";import{Plus as $,Trash2 as q}from"lucide-react";import{useFieldArray as B,Controller as D}from"react-hook-form";import{Button as y}from"@donotdev/components";import{getFieldRegistry as R}from"../../../FieldRegistry";import{convertValidationRules as j}from"../types";function A(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function I(s){const{control:d,errors:h,fieldConfig:c,t:r}=s,{name:m,label:f,validation:x}=c,v=c.options?.fieldSpecific??{},o=v.fields??[],l=v.direction??"row",{fields:b,append:C,remove:w}=B({control:d,name:m}),S=R(),z=()=>{if(o.length===0)return;const a={};for(const t of o)a[t.name]=A(t.type);C(a)};return o.length===0?n("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[r(f),": no sub-fields configured"]}):n("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[n("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[n("span",{style:{fontSize:"var(--font-size-sm)",fontWeight:"var(--font-weight-medium)"},children:[r(f),x?.required&&i("span",{style:{color:"var(--destructive)",marginInlineStart:"var(--gap-tight)"},children:"*"})]}),i(y,{type:"button",variant:"ghost",display:"compact",icon:$,onClick:z,"aria-label":r(f)+" \u2014 add"})]}),b.map((a,t)=>n("div",{style:{display:"flex",flexDirection:l,gap:"var(--gap-sm)",alignItems:l==="row"?"flex-start":void 0},children:[o.map(e=>{const u=`${m}.${t}.${e.name}`,F={name:u,type:e.type,label:e.label,visibility:c.visibility,validation:{...e.validation??{},...e.required?{required:!0}:{}},options:e.options??{}},g=S.getControlledComponent(e.type);return g?i("div",{style:{flex:l==="row"?1:void 0},children:i(g,{control:d,errors:h,fieldConfig:F,t:r})},e.name):i("div",{style:{flex:l==="row"?1:void 0},children:i(D,{name:u,control:d,rules:e.validation?j(e.validation):void 0,render:({field:p})=>n("label",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-tight)"},children:[i("span",{style:{fontSize:"var(--font-size-xs)"},children:r(e.label)}),i("input",{className:"dndev-input",value:String(p.value??""),onChange:p.onChange,onBlur:p.onBlur})]})})},e.name)}),i(y,{type:"button",variant:"ghost",display:"compact",icon:q,onClick:()=>w(t),"aria-label":`Remove row ${t+1}`,style:{alignSelf:l==="row"?"center":"flex-end"}})]},a.id))]})}export{I as ControlledFieldArrayField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledGeoPointField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledGeoPointField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledGeoPointField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledGeoPointField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA4Cd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledMapField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledMapField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledMapField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledMapField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CA4C5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MapFieldComponent as f}from"../../form/fields";import{convertValidationRules as g}from"../types";function C(l){const{control:i,errors:t,fieldConfig:s,t:m}=l,{name:r,label:d,validation:o}=s;return a(p,{name:r,control:i,rules:o?g(o):void 0,render:({field:e})=>{const u=n=>{if("target"in n)try{const c=JSON.parse(n.target.value);e.onChange(c)}catch{e.onChange({})}else e.onChange(n||{})};return a(f,{label:m(d),value:e.value||{},onChange:u,error:!!t[r],helperText:t[r]?.message,required:o?.required})}})}export{C as ControlledMapField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledMultiInputField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledMultiInputField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledMultiInputField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledMultiInputField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAyCd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{MultiInputTextFieldComponent as f}from"../../form/fields";import{convertValidationRules as C}from"../types";function g(n){const{control:l,errors:v,fieldConfig:i,t:s}=n,{name:u,label:m,validation:r,options:c={}}=i;return t(p,{name:u,control:l,rules:r?C(r):void 0,render:({field:e})=>{const d=o=>{if(Array.isArray(o))e.onChange(o);else try{const a=JSON.parse(o.target.value);e.onChange(Array.isArray(a)?a:[])}catch{e.onChange([])}};return t(f,{label:s(m),value:Array.isArray(e.value)?e.value:[],onChange:d,required:r?.required,className:c.className})}})}export{g as ControlledMultiInputField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledRichTextField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledRichTextField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledRichTextField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledRichTextField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAwBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{RichTextComponent as f}from"../../form/fields";import{convertValidationRules as h}from"../types";function C(n){const{control:i,errors:r,fieldConfig:s,t:m,placeholder:c}=n,{name:e,label:d,validation:o,options:l={}}=s;return t(u,{name:e,control:i,rules:o?h(o):void 0,render:({field:a})=>t(f,{label:m(d),value:a.value??"",onChange:p=>a.onChange(p),error:r[e]?.message,helperText:r[e]?.message,required:o?.required,placeholder:c||l.placeholder,className:l.className})})}export{C as ControlledRichTextField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledTimestampField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledTimestampField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledTimestampField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/ControlledTimestampField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CAuBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{TimestampFieldComponent as u}from"../../form/fields";import{convertValidationRules as f}from"../types";function c(t){const{control:a,errors:l,fieldConfig:i,t:m}=t,{name:e,label:s,validation:r}=i;return n(p,{name:e,control:a,rules:r?f(r):void 0,render:({field:o})=>n(u,{...o,label:m(s),value:o.value??null,onChange:d=>o.onChange(d),error:!!l[e],helperText:l[e]?.message,required:r?.required})})}export{c as ControlledTimestampField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledDocumentField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/file/ControlledDocumentField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledDocumentField.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/file/ControlledDocumentField.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAC1B,YAAY,CA6Bd"}
|