@donotdev/crud 0.0.16 → 0.0.18

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.
Files changed (201) hide show
  1. package/dist/CrudService.d.ts.map +1 -1
  2. package/dist/CrudService.js +2 -2
  3. package/dist/CrudStore.d.ts.map +1 -1
  4. package/dist/CrudStore.js +1 -1
  5. package/dist/FieldRegistry.d.ts.map +1 -1
  6. package/dist/FieldRegistry.js +1 -1
  7. package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
  8. package/dist/adapters/FunctionsAdapter.js +1 -1
  9. package/dist/components/CrudButton.js +1 -1
  10. package/dist/components/CrudCard.d.ts.map +1 -1
  11. package/dist/components/CrudCard.js +1 -1
  12. package/dist/components/DateFilter.js +1 -1
  13. package/dist/components/DisplayFieldRenderer.js +1 -1
  14. package/dist/components/DisplayThumbnail.js +1 -1
  15. package/dist/components/EntityFilters.d.ts +1 -34
  16. package/dist/components/EntityFilters.d.ts.map +1 -1
  17. package/dist/components/EntityFilters.js +1 -1
  18. package/dist/components/FormFieldRenderer.js +1 -1
  19. package/dist/components/FormLayout.js +1 -1
  20. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  21. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  22. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts +18 -0
  23. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -0
  24. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -0
  25. package/dist/components/controlled/complex/ControlledGeoPointField.js +1 -1
  26. package/dist/components/controlled/complex/ControlledMapField.js +1 -1
  27. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  28. package/dist/components/controlled/complex/ControlledRichTextField.js +1 -1
  29. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  30. package/dist/components/controlled/complex/index.d.ts +1 -0
  31. package/dist/components/controlled/complex/index.d.ts.map +1 -1
  32. package/dist/components/controlled/complex/index.js +1 -1
  33. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  34. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  35. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  36. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  37. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  38. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  39. package/dist/components/controlled/file/index.js +1 -1
  40. package/dist/components/controlled/index.js +1 -1
  41. package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
  42. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  43. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  44. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  45. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  46. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  47. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  48. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  49. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  50. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  51. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  52. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  53. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  54. package/dist/components/controlled/input/index.js +1 -1
  55. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  56. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  57. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  58. package/dist/components/controlled/select/ControlledRadioField.js +1 -1
  59. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  60. package/dist/components/controlled/select/index.js +1 -1
  61. package/dist/components/controlled/types.js +1 -1
  62. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  63. package/dist/components/fields/display/BadgeFieldDisplay.js +1 -1
  64. package/dist/components/fields/display/ButtonFieldDisplay.js +1 -1
  65. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  66. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  67. package/dist/components/fields/display/DropdownDisplay.js +1 -1
  68. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  69. package/dist/components/fields/display/GeoPointFieldDisplay.js +1 -1
  70. package/dist/components/fields/display/HiddenFieldDisplay.js +1 -1
  71. package/dist/components/fields/display/ImageFieldDisplay.js +1 -1
  72. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  73. package/dist/components/fields/display/MapFieldDisplay.js +1 -1
  74. package/dist/components/fields/display/MultiDropdownDisplay.js +1 -1
  75. package/dist/components/fields/display/MultiInputTextFieldDisplay.js +1 -1
  76. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  77. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  78. package/dist/components/fields/display/PhoneNumberDisplay.js +1 -1
  79. package/dist/components/fields/display/RadioFieldDisplay.js +1 -1
  80. package/dist/components/fields/display/RangeFieldDisplay.js +1 -1
  81. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  82. package/dist/components/fields/display/RichTextDisplay.js +2 -2
  83. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  84. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  85. package/dist/components/fields/display/TimestampFieldDisplay.js +1 -1
  86. package/dist/components/fields/display/index.js +1 -1
  87. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  88. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  89. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  90. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  91. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  92. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  93. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  94. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  95. package/dist/components/form/fields/DocumentFieldComponent.d.ts.map +1 -1
  96. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  97. package/dist/components/form/fields/DropdownComponent.js +1 -1
  98. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  99. package/dist/components/form/fields/FileFieldComponent.d.ts.map +1 -1
  100. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  101. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  102. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  103. package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
  104. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  105. package/dist/components/form/fields/MapFieldComponent.js +1 -1
  106. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  107. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  108. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  109. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  110. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  111. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  112. package/dist/components/form/fields/RadioFieldComponent.js +1 -1
  113. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  114. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  115. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  116. package/dist/components/form/fields/RichTextComponent.js +1 -1
  117. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  118. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  119. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  120. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  121. package/dist/components/form/fields/index.js +1 -1
  122. package/dist/components/form/fields/internal/TiptapEditor.d.ts.map +1 -1
  123. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  124. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  125. package/dist/components/index.d.ts +2 -1
  126. package/dist/components/index.d.ts.map +1 -1
  127. package/dist/components/index.js +1 -1
  128. package/dist/contexts/UploadContext.js +1 -1
  129. package/dist/contexts/index.js +1 -1
  130. package/dist/fieldTypeRegistry.js +1 -1
  131. package/dist/forms/hooks/index.js +1 -1
  132. package/dist/forms/hooks/useController.js +1 -1
  133. package/dist/forms/hooks/useEntityField.d.ts +15 -24
  134. package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
  135. package/dist/forms/hooks/useEntityField.js +1 -1
  136. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  137. package/dist/forms/hooks/useEntityForm.js +1 -1
  138. package/dist/forms/index.js +1 -1
  139. package/dist/forms/types.d.ts +13 -0
  140. package/dist/forms/types.d.ts.map +1 -1
  141. package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
  142. package/dist/forms/utils/buildInitialValues.js +1 -1
  143. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  144. package/dist/forms/utils/index.js +1 -1
  145. package/dist/forms/utils/isFieldEditable.js +1 -1
  146. package/dist/forms/utils/translateFieldLabel.js +1 -1
  147. package/dist/forms/utils/validateEntity.js +1 -1
  148. package/dist/hooks/useCrudFilters.js +1 -1
  149. package/dist/hooks/useEntityFavorites.js +1 -1
  150. package/dist/hooks/useFileUpload.d.ts.map +1 -1
  151. package/dist/hooks/useFileUpload.js +1 -1
  152. package/dist/hooks/useRelatedItems.js +1 -1
  153. package/dist/index.d.ts +4 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +1 -1
  156. package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
  157. package/dist/registerBuiltinFieldTypes.js +1 -1
  158. package/dist/stores/FormStore.js +1 -1
  159. package/dist/stores/UploadStore.d.ts.map +1 -1
  160. package/dist/stores/UploadStore.js +1 -1
  161. package/dist/stores/index.js +1 -1
  162. package/dist/tsconfig.tsbuildinfo +1 -1
  163. package/dist/types.js +1 -1
  164. package/dist/useBaseCrudList.d.ts.map +1 -1
  165. package/dist/useBaseCrudList.js +1 -1
  166. package/dist/useCrud.js +1 -1
  167. package/dist/useCrudCardList.d.ts +14 -19
  168. package/dist/useCrudCardList.d.ts.map +1 -1
  169. package/dist/useCrudCardList.js +1 -1
  170. package/dist/useCrudList.d.ts +19 -18
  171. package/dist/useCrudList.d.ts.map +1 -1
  172. package/dist/useCrudList.js +1 -1
  173. package/dist/utils/clientListProcessing.d.ts +82 -0
  174. package/dist/utils/clientListProcessing.d.ts.map +1 -0
  175. package/dist/utils/clientListProcessing.js +1 -0
  176. package/dist/utils/collections.js +1 -1
  177. package/dist/utils/fileStorage.d.ts.map +1 -1
  178. package/dist/utils/fileStorage.js +1 -1
  179. package/dist/utils/imageProcessing.js +1 -1
  180. package/dist/utils/imageStorage.d.ts.map +1 -1
  181. package/dist/utils/imageStorage.js +1 -1
  182. package/dist/utils/imageUtils.js +1 -1
  183. package/dist/utils/matchesFilter.d.ts +45 -0
  184. package/dist/utils/matchesFilter.d.ts.map +1 -0
  185. package/dist/utils/matchesFilter.js +1 -0
  186. package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
  187. package/dist/utils/mergeWithOptimistic.js +1 -1
  188. package/dist/utils/sanitizeHtml.js +1 -1
  189. package/dist/utils/scopeUtils.js +1 -1
  190. package/dist/utils/uploadValidation.d.ts.map +1 -1
  191. package/dist/utils/uploadValidation.js +1 -1
  192. package/package.json +8 -5
  193. package/dist/components/__tests__/EntityFilters.test.d.ts +0 -2
  194. package/dist/components/__tests__/EntityFilters.test.d.ts.map +0 -1
  195. package/dist/components/__tests__/EntityFilters.test.js +0 -1
  196. package/dist/components/__tests__/FormFieldRenderer.test.d.ts +0 -2
  197. package/dist/components/__tests__/FormFieldRenderer.test.d.ts.map +0 -1
  198. package/dist/components/__tests__/FormFieldRenderer.test.js +0 -1
  199. package/dist/hooks/useFormNavigationGuard.d.ts +0 -34
  200. package/dist/hooks/useFormNavigationGuard.d.ts.map +0 -1
  201. package/dist/hooks/useFormNavigationGuard.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CrudService.d.ts","sourceRoot":"","sources":["../src/CrudService.ts"],"names":[],"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AAO,CAAC,cAAc;IAqCtB,qBAAqB,CAAC,CAAC,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EAC5C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI;IAkCb,uFAAuF;IACvF,OAAO,CAAC,0BAA0B;IA2C5B,aAAa,CAAC,CAAC,SAAS;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EAC3C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAsFxB,gBAAgB,CAAC,CAAC,EACtB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,CAAC,CAAC;IA4FP,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC;CA6EjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mBAE1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import{toast as p}from"@donotdev/components";import{createSingleton as w,handleError as d,getQueryClient as _,getI18nInstance as y,hasProvider as E,getProvider as C,hasRestrictedVisibility as A,validateWithSchema as L}from"@donotdev/core";import{LIST_SCHEMA_TYPE as f}from"@donotdev/core";import{CRUD_OPERATION as h}from"./types";const m=1/0,q=1e3*60*30;class T{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&&A(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(!E("crud"))throw new Error(`[dndev] No CRUD adapter configured. Call configureProviders({ crud: yourAdapter }) at app startup.
1
+ import{toast as m}from"@donotdev/components";import{createSingleton as A,handleError as f,getQueryClient as L,getI18nInstance as c,hasProvider as D,getProvider as T,hasRestrictedVisibility as q}from"@donotdev/core";import{LIST_SCHEMA_TYPE as _}from"@donotdev/core";import{CRUD_OPERATION as y}from"./types";const S=1/0,Q=1e3*60*30;class F{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,s,i){this.security&&this.security.audit({type:t,collection:e,docId:s,userId:i??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&&q(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(!D("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=f.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],S=typeof u[l]=="string"?u[l].toLowerCase():u[l];return g===S}));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");return this._assertCanAccess(t,i),await this.adapter.get(t,e,i)}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=f.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=f.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");return this._assertCanAccess(t,i),await this.adapter.query(t,e,i,o)}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),L(r,i,`CrudService.update(${t})`)),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(),S=this._getEntityName(t);p("success",g.t("messages.createSuccess",{ns:"crud",entity:S}))}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 D=w(()=>new T);export{D as getCrudService};
9
+ configureProviders({ crud: new SupabaseCrudAdapter(sb) }) // Supabase direct (RLS)`);this.adapter=T("crud"),this.store&&this.store.getState().setCrudService(this)}}getQueryClient(){return L()}getListQueryOptions(t,e,s,i,a=_.LIST){const r=this.adapter,u=()=>this._ensureAdapter();return{queryKey:["crud",t,"query",JSON.stringify(e)],queryFn:async()=>{if(r||await u(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.query(t,e,s,a)},staleTime:i?.staleTime??S}}getDocQueryOptions(t,e,s,i){const a=this.adapter,r=()=>this._ensureAdapter();return{queryKey:["crud",t,"get",e],queryFn:async()=>{if(a||await r(),!this.adapter)throw new Error("Adapter not initialized");return this.adapter.get(t,e,s)},staleTime:i?.staleTime??S}}_updateGetCache(t,e,s,i){const a=this.getQueryClient(),r=["crud",t,"get",e];i===y.DELETE?a.removeQueries({queryKey:r}):i===y.SET&&s?a.setQueryData(r,s):(i===y.UPDATE||i===y.ADD)&&s&&a.setQueryData(r,u=>u?{...u,...s}:s)}_updateListCaches(t,e,s,i){const a=this.getQueryClient();this._updateGetCache(t,e,s,i),a.setQueriesData({queryKey:["crud",t]},r=>{if(r&&typeof r=="object"&&"items"in r){const u=r;let h=u.items;return i===y.DELETE?(h=u.items.filter(d=>d!=null&&typeof d=="object"&&d.id!==e),{...u,items:h,total:Math.max(0,(u.total??h.length)-1)}):i===y.ADD&&s?(h=[...u.items,{...s,id:e}],{...u,items:h,total:(u.total??u.items.length)+1}):(i===y.UPDATE||i===y.SET)&&s&&u.items.some(n=>n!=null&&typeof n=="object"&&n.id===e)?(h=u.items.map(n=>n==null||typeof n!="object"||n.id!==e?n:i===y.SET?{...s,id:e}:{...n,...s}),{...u,items:h}):r}if(Array.isArray(r)){if(i===y.DELETE)return r.filter(u=>u.id!==e);if(i===y.ADD&&s)return[...r,{...s,id:e}];if((i===y.UPDATE||i===y.SET)&&s)return r.some(h=>h!=null&&typeof h=="object"&&h.id===e)?r.map(h=>h==null||typeof h!="object"||h.id!==e?h:i===y.SET?{...s,id:e}:{...h,...s}):r}return r})}_checkUniquenessFromCache(t,e,s){const a=s.metadata?.uniqueKeys;if(!a||a.length===0)return null;const u=this.getQueryClient().getQueriesData({queryKey:["crud",t]}),h=[];for(const[,n]of u)n&&typeof n=="object"&&"items"in n?h.push(...n.items):Array.isArray(n)&&h.push(...n);if(h.length===0)return null;const d=e;for(const n of a){if(!n.fields.every(p=>d[p]!=null&&d[p]!==""))continue;const g=h.find(p=>n.fields.every(w=>{const C=typeof d[w]=="string"?d[w].toLowerCase():d[w],E=typeof p[w]=="string"?p[w].toLowerCase():p[w];return C===E}));if(g){if(n.findOrCreate)return g.id;const p=n.fields.join(" + ");throw f(new Error(n.errorMessage||`Duplicate ${p}`),{userMessage:n.errorMessage||`A record with this ${p} already exists`,showNotification:!0})}}return null}_getItemFromListCache(t,e){const i=this.getQueryClient().getQueriesData({queryKey:["crud",t]});for(const[,a]of i)if(a?.items){const r=a.items.find(u=>u.id===e);if(r)return r}return null}async invalidateCollection(t){await this.getQueryClient().invalidateQueries({queryKey:["crud",t]})}async get(t,e,s,i){if(await this._ensureAdapter(),i?.noCache)return this._getFromAdapter(t,e,s);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,s,!1),staleTime:i?.staleTime??S})}catch(a){const r=f(a,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _getFromAdapter(t,e,s,i=!0){this.store&&i&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");return this._assertCanAccess(t,s),await this.adapter.get(t,e,s)}catch(a){const r=f(a,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&i&&this.store.getState().setLoading(t,!1)}}async query(t,e,s,i,a=_.LIST){if(await this._ensureAdapter(),i?.noCache)return this._queryFromAdapter(t,e,s,!0,a);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,s,!1,a),staleTime:i?.staleTime??S})}catch(r){const u=f(r,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,u),u}finally{this.store&&this.store.getState().setLoading(t,!1)}}async _queryFromAdapter(t,e,s,i=!0,a=_.LIST){this.store&&i&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");return this._assertCanAccess(t,s),await this.adapter.query(t,e,s,a)}catch(r){const u=f(r,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,u),u}finally{this.store&&i&&this.store.getState().setLoading(t,!1)}}_getEntityName(t){const e=c();let s=`entity-${t}`,i=e.t("name",{ns:s,defaultValue:null});return i&&i!=="name"&&i!==`${s}:name`||t.endsWith("s")&&t.length>1&&(s=`entity-${t.slice(0,-1)}`,i=e.t("name",{ns:s,defaultValue:null}),i&&i!=="name"&&i!==`${s}:name`)?i:t}async set(t,e,s,i,a){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const u=this.getQueryClient().getQueryData(["crud",t,"get",e])??null;this.store&&this.store.getState().updateOptimistic(t,e,s,u);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 h=this._getPiiFields(i),d=h.length>0&&this.security?this.security.encryptPii(s,h):s;if(await this.adapter.set(t,e,d,i),this._updateListCaches(t,e,s,y.SET),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(a)){const n=c(),o=this._getEntityName(t);m("success",n.t("messages.updateSuccess",{ns:"crud",entity:o}))}}catch(h){u&&this._updateListCaches(t,e,u,y.SET),this.store&&this.store.getState().rejectUpdate(t,e);const d=f(h,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,d),d}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,e,s,i,a){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const u=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),h=u?{...u,...s}:{...s,id:e};this.store&&this.store.getState().updateOptimistic(t,e,h,u??null);try{if(!this.adapter)throw new Error("Adapter not initialized");i&&this._assertCanAccess(t,i),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const d=i?this._getPiiFields(i):[],n=d.length>0&&this.security?this.security.encryptPii(s,d):s;if(await this.adapter.update(t,e,n),this._updateListCaches(t,e,h,y.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(a)){const o=c(),g=this._getEntityName(t);m("success",o.t("messages.updateSuccess",{ns:"crud",entity:g}))}}catch(d){u?this._updateListCaches(t,e,u,y.UPDATE):this.invalidateCollection(t),this.store&&this.store.getState().rejectUpdate(t,e);const n=f(d,{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,s){await this._ensureAdapter(),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const a=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&a&&this.store.getState().deleteOptimistic(t,e,a);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,y.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(s)){const r=c(),u=this._getEntityName(t);m("success",r.t("messages.deleteSuccess",{ns:"crud",entity:u}))}}catch(r){a&&this._updateListCaches(t,e,a,y.ADD),this.store&&this.store.getState().rejectDelete(t,e);const u=f(r,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,u),u}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,e,s,i){await this._ensureAdapter();const a=this._checkUniquenessFromCache(t,e,s);if(a)return a;this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));const r=`temp_${crypto.randomUUID()}`;this.store&&this.store.getState().addOptimistic(t,r,{...e,id:r});try{if(!this.adapter)throw new Error("Adapter not initialized");this._assertCanAccess(t,s),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const u=this._getPiiFields(s),h=u.length>0&&this.security?this.security.encryptPii(e,u):e,d=await this.adapter.add(t,h,s),n=d.id,o=d.data;if(this._updateListCaches(t,r,null,y.DELETE),this._updateListCaches(t,n,o,y.ADD),this.store&&this.store.getState().confirmOptimistic(t,r,n,o),this._auditCrud("crud.create",t,n),this._shouldShowSuccessToast(i)){const g=c(),p=this._getEntityName(t);m("success",g.t("messages.createSuccess",{ns:"crud",entity:p}))}return n}catch(u){this._updateListCaches(t,r,null,y.DELETE),this.store&&this.store.getState().rejectOptimistic(t,r);const h=f(u,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,h),h}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,e,s,i){if(!this.adapter){let a=!1,r=null;return this._ensureAdapter().then(()=>{a||(r=this._subscribeSync(t,e,s,i))}).catch(u=>{a||s(null,f(u))}),()=>{a=!0,r?.()}}return this._subscribeSync(t,e,s,i)}_subscribeSync(t,e,s,i){try{const a=this.adapter;return a?a.subscribe?(this._assertCanAccess(t,i),a.subscribe(t,e,(r,u)=>{r&&this.getQueryClient().setQueryData(["crud",t,"get",e],r),s(r,u)},i)):()=>{}:(s(null,new Error("Adapter not initialized")),()=>{})}catch(a){return s(null,f(a)),()=>{}}}subscribeToCollection(t,e,s,i){if(!this.adapter){let a=!1,r=null;return this._ensureAdapter().then(()=>{a||(r=this._subscribeToCollectionSync(t,e,s,i))}).catch(u=>{a||s([],f(u))}),()=>{a=!0,r?.()}}return this._subscribeToCollectionSync(t,e,s,i)}_subscribeToCollectionSync(t,e,s,i){try{const a=this.adapter;return a?a.subscribeToCollection?(this._assertCanAccess(t,i),a.subscribeToCollection(t,e,(r,u)=>{r&&this.getQueryClient().setQueryData(["crud",t,"query",JSON.stringify(e)],h=>h?{...h,items:r}:{items:r}),s(r,u)},i)):()=>{}:(s([],new Error("Adapter not initialized")),()=>{})}catch(a){return s([],f(a)),()=>{}}}async addOptimistic(t,e,s,i){await this._ensureAdapter();const a=this._checkUniquenessFromCache(t,e,s);if(a)return{...e,id:a};this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const r=`temp_${crypto.randomUUID()}`,u={...e,id:r,_optimistic:!0};this.store&&this.store.getState().addOptimistic(t,r,u);try{if(!this.adapter)throw new Error("Adapter not initialized");const h=await this.adapter.add(t,e,s),d=h.id,n=h.data;if(this._updateListCaches(t,r,null,y.DELETE),this._updateListCaches(t,d,n,y.ADD),this.store&&this.store.getState().confirmOptimistic(t,r,d,n),this._auditCrud("crud.create",t,d),this._shouldShowSuccessToast(i)){const o=c(),g=this._getEntityName(t);m("success",o.t("messages.createSuccess",{ns:"crud",entity:g}))}return n}catch(h){throw this._updateListCaches(t,r,null,y.DELETE),this.store&&this.store.getState().rejectOptimistic(t,r),f(h,{userMessage:`Failed to create ${t}`,showNotification:!0})}}async updateOptimistic(t,e,s,i,a){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const u=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e),h=u?{...u,...s,_optimistic:!0}:{...s,id:e,_optimistic:!0};this.store&&u&&this.store.getState().updateOptimistic(t,e,h,u);try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,e,s);const{_optimistic:d,...n}=h;if(this._updateListCaches(t,e,n,y.UPDATE),this.store&&this.store.getState().confirmUpdate(t,e),this._auditCrud("crud.update",t,e),this._shouldShowSuccessToast(a)){const o=c(),g=this._getEntityName(t);m("success",o.t("messages.updateSuccess",{ns:"crud",entity:g}))}return n}catch(d){throw u&&this._updateListCaches(t,e,u,y.UPDATE),this.store&&this.store.getState().rejectUpdate(t,e),f(d,{userMessage:`Failed to update ${t}`,showNotification:!0})}}async deleteOptimistic(t,e,s){await this._ensureAdapter(),this.security&&await this.security.checkRateLimit(this._rateLimitKey(t),"write");const a=this.getQueryClient().getQueryData(["crud",t,"get",e])??this._getItemFromListCache(t,e);this.store&&a&&this.store.getState().deleteOptimistic(t,e,a);try{if(!this.adapter)throw new Error("Adapter not initialized");if(await this.adapter.delete(t,e),this._updateListCaches(t,e,null,y.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(s)){const r=c(),u=this._getEntityName(t);m("success",r.t("messages.deleteSuccess",{ns:"crud",entity:u}))}}catch(r){throw a&&this._updateListCaches(t,e,a,y.ADD),this.store&&this.store.getState().rejectDelete(t,e),f(r,{userMessage:`Failed to delete ${t}`,showNotification:!0})}}}const O=A(()=>new F);export{O as getCrudService};
@@ -1 +1 @@
1
- {"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEV,SAAS,EACT,WAAW,EAIZ,MAAM,SAAS,CAAC;AA0BjB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iIAiZvB,CAAC"}
1
+ {"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAEV,SAAS,EACT,WAAW,EAIZ,MAAM,SAAS,CAAC;AA0BjB;;;;;;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:(l,n)=>({...f,setCrudService:t=>{l({crudService:t})},setHideSuccessToasts:t=>{l({hideSuccessToasts:t})},setLoading:(t,c)=>{l(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,loading:c}}}})},setError:(t,c)=>{l(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,error:c,loading:!1}}}})},setFilters:(t,c)=>{l(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,ui:{...o.ui,filters:c}}}}})},setShowFavoritesOnly:(t,c)=>{l(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,ui:{...o.ui,showFavoritesOnly:c}}}}})},getFilters:t=>n().collections[t]?.ui?.filters||{},getShowFavoritesOnly:t=>n().collections[t]?.ui?.showFavoritesOnly||!1,clearCollection:t=>{l(c=>{const{[t]:i,...o}=c.collections;return{collections:o}})},clearError:t=>{l(c=>{const i=c.collections[t];return i?{collections:{...c.collections,[t]:{...i,error:null}}}:c})},addOptimistic:(t,c,i)=>{l(o=>{const e=o.collections[t]||r();return{collections:{...o.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:null,optimisticData:i,status:u.PENDING,operation:a.ADD}},lastUpdated:Date.now()}}}})},confirmOptimistic:(t,c,i,o)=>{l(e=>{const s=e.collections[t];if(!s)return e;const{[c]:p,...m}=s.optimistic;return{collections:{...e.collections,[t]:{...s,optimistic:m,lastUpdated:Date.now()}}}})},rejectOptimistic:(t,c)=>{l(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...s}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:s,lastUpdated:Date.now()}}}})},updateOptimistic:(t,c,i,o)=>{l(e=>{const s=e.collections[t]||r();return{collections:{...e.collections,[t]:{...s,optimistic:{...s.optimistic,[c]:{tempId:c,originalData:o,optimisticData:i,status:u.PENDING,operation:a.UPDATE}},lastUpdated:Date.now()}}}})},confirmUpdate:(t,c)=>{l(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...s}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:s}}}})},rejectUpdate:(t,c)=>{l(i=>{const o=i.collections[t];if(!o)return i;const e=o.optimistic[c];if(!e||e.operation!==a.UPDATE)return i;const{[c]:s,...p}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:p,lastUpdated:Date.now()}}}})},deleteOptimistic:(t,c,i)=>{l(o=>{const e=o.collections[t];return e?{collections:{...o.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:i,optimisticData:null,status:u.PENDING,operation:a.DELETE}},lastUpdated:Date.now()}}}:o})},confirmDelete:(t,c)=>{l(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...s}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:s}}}})},rejectDelete:(t,c)=>{l(i=>{const o=i.collections[t];if(!o)return i;const e=o.optimistic[c];if(!e||e.operation!==a.DELETE)return i;const{[c]:s,...p}=o.optimistic;return{collections:{...i.collections,[t]:{...o,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};
1
+ import{createDoNotDevStore as d}from"@donotdev/core";import{OPTIMISTIC_STATUSES as m,CRUD_OPERATION as a}from"./types";const S={filters:{},showFavoritesOnly:!1};function r(){return{loading:!1,error:null,lastUpdated:0,optimistic:{},ui:{...S}}}const D={crudService:null,hideSuccessToasts:!1,collections:{}},E=d({name:"crud-store",createStore:(n,s)=>({...D,setCrudService:t=>{n({crudService:t})},setHideSuccessToasts:t=>{n({hideSuccessToasts:t})},setLoading:(t,c)=>{n(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,loading:c}}}})},setError:(t,c)=>{n(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,error:c,loading:!1}}}})},setFilters:(t,c)=>{n(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,ui:{...o.ui,filters:c}}}}})},setShowFavoritesOnly:(t,c)=>{n(i=>{const o=i.collections[t]||r();return{collections:{...i.collections,[t]:{...o,ui:{...o.ui,showFavoritesOnly:c}}}}})},getFilters:t=>s().collections[t]?.ui?.filters||{},getShowFavoritesOnly:t=>s().collections[t]?.ui?.showFavoritesOnly||!1,clearCollection:t=>{n(c=>{const{[t]:i,...o}=c.collections;return{collections:o}})},clearError:t=>{n(c=>{const i=c.collections[t];return i?{collections:{...c.collections,[t]:{...i,error:null}}}:c})},addOptimistic:(t,c,i)=>{n(o=>{const e=o.collections[t]||r();return{collections:{...o.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:null,optimisticData:i,status:m.PENDING,operation:a.ADD}},lastUpdated:Date.now()}}}})},confirmOptimistic:(t,c,i,o)=>{n(e=>{const l=e.collections[t];if(!l)return e;const{[c]:p,...u}=l.optimistic;return{collections:{...e.collections,[t]:{...l,optimistic:u,lastUpdated:Date.now()}}}})},rejectOptimistic:(t,c)=>{n(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...l}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:l,lastUpdated:Date.now()}}}})},updateOptimistic:(t,c,i,o)=>{n(e=>{const l=e.collections[t]||r();return{collections:{...e.collections,[t]:{...l,optimistic:{...l.optimistic,[c]:{tempId:c,originalData:o,optimisticData:i,status:m.PENDING,operation:a.UPDATE}},lastUpdated:Date.now()}}}})},confirmUpdate:(t,c)=>{n(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...l}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:l}}}})},rejectUpdate:(t,c)=>{n(i=>{const o=i.collections[t];if(!o)return i;const e=o.optimistic[c];if(!e||e.operation!==a.UPDATE)return i;const{[c]:l,...p}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:p,lastUpdated:Date.now()}}}})},deleteOptimistic:(t,c,i)=>{n(o=>{const e=o.collections[t];return e?{collections:{...o.collections,[t]:{...e,optimistic:{...e.optimistic,[c]:{tempId:c,originalData:i,optimisticData:null,status:m.PENDING,operation:a.DELETE}},lastUpdated:Date.now()}}}:o})},confirmDelete:(t,c)=>{n(i=>{const o=i.collections[t];if(!o)return i;const{[c]:e,...l}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:l}}}})},rejectDelete:(t,c)=>{n(i=>{const o=i.collections[t];if(!o)return i;const e=o.optimistic[c];if(!e||e.operation!==a.DELETE)return i;const{[c]:l,...p}=o.optimistic;return{collections:{...i.collections,[t]:{...o,optimistic:p,lastUpdated:Date.now()}}}})},getLoading:t=>s().collections[t]?.loading||!1,getError:t=>s().collections[t]?.error||null,isOptimistic:(t,c)=>s().collections[t]?.optimistic[c]?.status==="pending",getOptimisticStatus:(t,c)=>s().collections[t]?.optimistic[c]?.status??null,getOptimisticData:(t,c)=>s().collections[t]?.optimistic[c]?.optimisticData??null})});export{E as useCrudStore};
@@ -1 +1 @@
1
- {"version":3,"file":"FieldRegistry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terMetadata=new Map;registerComponent(e,t,n){this.components.set(e,{controlled:t,uncontrolled:n})}register(e){const{type:t,controlledComponent:n,uncontrolledComponent:p,displayFormatter:l,filterable:i,filterType:a}=e;this.components.set(t,{controlled:n,uncontrolled:p}),l&&this.displayFormatters.set(t,l),(i!==void 0||a!==void 0)&&this.filterMetadata.set(t,{filterable:i??!1,filterType:a})}getControlledComponent(e){return this.components.get(e)?.controlled}getUncontrolledComponent(e){return this.components.get(e)?.uncontrolled}getDisplayFormatter(e){return this.displayFormatters.get(e)}getFilterType(e){return this.filterMetadata.get(e)?.filterType}isFilterable(e){return this.filterMetadata.get(e)?.filterable??!1}has(e){return this.components.has(e)}getRegisteredTypes(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.displayFormatters.clear(),this.filterMetadata.clear()}}let o=null;function s(){return o||(o=new c),o}function d(r){s().register(r)}function m(r){return s().has(r)}export{s as getFieldRegistry,m as isFieldTypeRegistered,d as registerFieldType};
1
+ "use client";class d{components=new Map;displayFormatters=new Map;filterMetadata=new Map;registerComponent(e,t,n){this.components.set(e,{controlled:t,uncontrolled:n})}register(e){const{type:t,controlledComponent:n,uncontrolledComponent:p,displayFormatter:i,filterable:o,filterType:l}=e;this.components.set(t,{controlled:n,uncontrolled:p}),i&&this.displayFormatters.set(t,i),(o!==void 0||l!==void 0)&&this.filterMetadata.set(t,{filterable:o??!1,filterType:l})}getControlledComponent(e){return this.components.get(e)?.controlled}getUncontrolledComponent(e){return this.components.get(e)?.uncontrolled}getDisplayFormatter(e){return this.displayFormatters.get(e)}getFilterType(e){return this.filterMetadata.get(e)?.filterType}isFilterable(e){return this.filterMetadata.get(e)?.filterable??!1}has(e){return this.components.has(e)}getRegisteredTypes(){return Array.from(this.components.keys())}clear(){this.components.clear(),this.displayFormatters.clear(),this.filterMetadata.clear()}}let s=null;function a(){return s||(s=new d),s}function c(r){a().register(r)}function f(r){return a().has(r)}export{a as getFieldRegistry,f as isFieldTypeRegistered,c as registerFieldType};
@@ -1 +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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 n=>({data:await a.call(t,n)})}async get(t,a,n){const i=`get_${t}`,s=await this.getCallableFn(i);try{const e=(await s({id:a})).data;return n?o(n,e,"FunctionsAdapter.get"):e}catch(e){throw l(e,"FunctionsAdapter","get",t,a)}}async set(t,a,n,i){const s=o(i,n,"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,n){const i=`update_${t}`,s=await this.getCallableFn(i);try{await s({id:a,payload:n})}catch(e){throw l(e,"FunctionsAdapter","update",t,a)}}async delete(t,a){const n=`delete_${t}`,i=await this.getCallableFn(n);try{await i({id:a})}catch(s){throw l(s,"FunctionsAdapter","delete",t,a)}}async add(t,a,n){const i=o(n,a,"FunctionsAdapter.add"),s=`create_${t}`,e=await this.getCallableFn(s);try{const d=await e({payload:i});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,n,i=u.LIST){const s=i===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
+ import{hasProvider as p,getProvider as f,wrapCrudError as o,validateWithSchema as c}from"@donotdev/core";import{LIST_SCHEMA_TYPE as u}from"@donotdev/core";let l=null;class b{serverSideOnly=!0;async getCallable(){if(p("callable"))return f("callable");if(!l){const{FirebaseCallableProvider:t}=await import("@donotdev/firebase");l=new t}return l}async getCallableFn(t){const a=await this.getCallable();return async n=>({data:await a.call(t,n)})}async get(t,a,n){const i=`get_${t}`,d=await this.getCallableFn(i);try{const s=(await d({id:a})).data;return n?c(n,s,"FunctionsAdapter.get"):s}catch(r){throw o(r,"FunctionsAdapter","get",t,a)}}async set(t,a,n,i){const d=c(i,n,"FunctionsAdapter.set"),r=`update_${t}`,s=await this.getCallableFn(r);try{await s({id:a,payload:d})}catch(e){throw o(e,"FunctionsAdapter","set",t,a)}}async update(t,a,n){const i=`update_${t}`,d=await this.getCallableFn(i);try{await d({id:a,payload:n})}catch(r){throw o(r,"FunctionsAdapter","update",t,a)}}async delete(t,a){const n=`delete_${t}`,i=await this.getCallableFn(n);try{await i({id:a})}catch(d){throw o(d,"FunctionsAdapter","delete",t,a)}}async add(t,a,n){const i=c(n,a,"FunctionsAdapter.add"),d=`create_${t}`,r=await this.getCallableFn(d);try{const s=await r({payload:i});if(!s.data)throw o(new Error("Create function returned no data"),"FunctionsAdapter","add",t);return{id:s.data.id,data:s.data}}catch(s){throw o(s,"FunctionsAdapter","add",t)}}async query(t,a,n,i=u.LIST){const d=i===u.LIST_CARD?`listCard_${t}`:`list_${t}`,r={};a.where&&(r.where=a.where.map(e=>[e.field,e.operator,e.value])),a.orderBy&&(r.orderBy=a.orderBy.map(e=>[e.field,e.direction||"asc"])),a.limit&&(r.limit=a.limit),a.startAfter&&(r.startAfterId=a.startAfter);const s=await this.getCallableFn(d);try{const e=await s(r);if(!e.data)throw o(new Error("Query function returned no data"),"FunctionsAdapter","query",t);return{items:e.data.items,total:e.data.count,hasMore:e.data.hasMore,lastVisible:e.data.lastVisible}}catch(e){throw o(e,"FunctionsAdapter","query",t)}}subscribe(){return()=>{}}subscribeToCollection(){return()=>{}}}export{b 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:o,...i}){const s=a(u=>!!u.crudService);return d(n,{...i,disabled:t||!s||r&&!e,children:o})}var l=c;export{l as default};
1
+ "use client";import{jsx as n}from"react/jsx-runtime";import{ActionButton as d}from"@donotdev/components";import{useCrudStore as l}from"../CrudStore";function a({requiresAuth:t=!0,user:e,disabled:r=!1,children:i,...o}){const s=l(u=>!!u.crudService);return n(d,{...o,disabled:r||!s||t&&!e,children:i})}var p=a;export{p as default};
@@ -1 +1 @@
1
- {"version":3,"file":"CrudCard.d.ts","sourceRoot":"","sources":["../../src/components/CrudCard.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,gBAAgB,CAAC;AA4C7E;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,OAAO,EACP,WAAW,EAAE,eAAe,EAC5B,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,EAC9B,UAAkB,EAClB,aAAa,EACb,QAAe,EACf,SAAS,GACV,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,2CA+LnC;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"CrudCard.d.ts","sourceRoot":"","sources":["../../src/components/CrudCard.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,gBAAgB,CAAC;AA4C7E;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,OAAO,EACP,WAAW,EAAE,eAAe,EAC5B,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,EAC9B,UAAkB,EAClB,aAAa,EACb,QAAe,EACf,SAAS,GACV,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,2CAqMnC;AAED,eAAe,QAAQ,CAAC"}
@@ -1 +1 @@
1
- import{jsx as o,jsxs as T}from"react/jsx-runtime";import{useMemo as g}from"react";import{Trash2 as G}from"lucide-react";import{Card as H,Stack as j,Text as B,ActionButton as J}from"@donotdev/components";import{useTranslation as I,getListCardFieldNames as K}from"@donotdev/core";import{formatValue as h}from"./DisplayFieldRenderer";import{translateFieldLabel as O}from"../forms/utils/translateFieldLabel";import{DisplayThumbnail as N}from"./DisplayThumbnail";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 L({item:e,entity:t,onClick:c,titleFields:f,subtitleFields:v,contentFields:C,footerFields:b,showDelete:s=!1,renderActions:V,elevated:M=!0,className:P}){const{t:a}=I([t.namespace,"crud"]),{t:p}=I("crud"),F=U(t),x=f??F.titleFields,S=v??F.subtitleFields,A=C??F.contentFields,m=b??F.footerFields,D=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],y=e[i],u=n?h(y,n,a,{compact:!0,asString:!0}):y;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]),R=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]),q=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(N,{pictures:n,alt:String(D),aspectRatio:"16/9"},l)}return T("div",{children:[o(B,{level:"small",variant:"muted",children:O(l,i,a)}),o(B,{children:h(e[l],i,a,{compact:!0})})]},l)}).filter(Boolean);return r.length>0?o(j,{direction:"column",gap:"tight",children:r}):null},[e,t.fields,A,D,a]),z=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(N,{pictures:u,alt:"",aspectRatio:"1"},i)}const y=h(e[i],n,a,{compact:!0});return o("span",{children:y},i)});return o(j,{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(B,{level:"small",children:r.join(" \xB7 ")})},[e,t.fields,m,a]),E=Q(t).delete,k=o(H,{title:String(D??""),subtitle:R,content:q??void 0,footer:z,clickable:!!c,onClick:c?()=>c(e.id):void 0,elevated:M,className:P}),w=V||s?T("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:[V,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?T("div",{style:{position:"relative",height:"100%"},children:[k,w]}):k}var W=L;export{L as CrudCard,W as default};
1
+ import{jsx as i,jsxs as A}from"react/jsx-runtime";import{useMemo as F}from"react";import{Trash2 as G}from"lucide-react";import{Card as H,Stack as R,Text as B,ActionButton as J}from"@donotdev/components";import{useTranslation as k,getListCardFieldNames as K}from"@donotdev/core";import{formatValue as v}from"./DisplayFieldRenderer";import{translateFieldLabel as O}from"../forms/utils/translateFieldLabel";import{DisplayThumbnail as y}from"./DisplayThumbnail";import{useCrud as Q}from"../useCrud";function u(t){return t==="image"||t==="images"}function U(t){return F(()=>{const e=t.listCardFields;if(e&&!Array.isArray(e)){const o=e;return{titleFields:o.title??[],subtitleFields:o.subtitle??[],contentFields:o.content??[],footerFields:o.footer??[]}}const f=K(t),g=f.filter(o=>!u(t.fields[o]?.type)),x=f.filter(o=>u(t.fields[o]?.type)),S=g.length>0?[g[0]]:[],C=[...g.slice(1,4),...x];return{titleFields:S,subtitleFields:[],contentFields:C,footerFields:[]}},[t])}function W({item:t,entity:e,onClick:f,titleFields:g,subtitleFields:x,contentFields:S,footerFields:C,showDelete:o=!1,renderActions:D,elevated:M=!0,className:P}){const{t:n}=k([e.namespace,"crud"]),{t:m}=k("crud"),b=U(e),T=g??b.titleFields,I=x??b.subtitleFields,j=S??b.contentFields,h=C??b.footerFields,V=F(()=>{if(!T?.length)return t.id??"";const c=T.filter(l=>typeof l=="string").filter(l=>!u(e.fields[l]?.type)).map(l=>{const s=e.fields[l],a=t[l],p=s?v(a,s,n,{compact:!0,asString:!0}):a;return typeof p=="string"?p:String(p??"")}).filter(Boolean),r=!Array.isArray(e.listCardFields)&&e.listCardFields?.titleSeparator!=null?e.listCardFields.titleSeparator:" ";return c.join(r)||String(t.id??"")},[t,e.fields,T,e.listCardFields,n]),_=F(()=>I?.length&&I.filter(r=>typeof r=="string").filter(r=>!u(e.fields[r]?.type)).map(r=>{const l=e.fields[r],s=t[r],a=l?v(s,l,n,{compact:!0,asString:!0}):s;return typeof a=="string"?a:String(a??"")}).filter(Boolean).join(" ")||void 0,[t,e.fields,I,n]),z=F(()=>{if(!j?.length)return null;const c=j.map(r=>{const l=e.fields[r];if(!l)return null;if(u(l.type)){const s=t[r];return s==null?null:i(y,{pictures:s,alt:String(V),aspectRatio:"16/9"},r)}return A("div",{children:[i(B,{level:"small",variant:"muted",children:O(r,l,n)}),i(B,{children:v(t[r],l,n,{compact:!0})})]},r)}).filter(Boolean);return c.length>0?i(R,{direction:"column",gap:"tight",children:c}):null},[t,e.fields,j,V,n]),q=F(()=>{if(!h?.length)return;if(h.some(r=>u(e.fields[r]?.type))){const r=h.map(l=>{const s=e.fields[l];if(!s)return null;if(u(s.type)){const p=t[l];return p==null?null:i(y,{pictures:p,alt:"",aspectRatio:"1"},l)}const a=v(t[l],s,n,{compact:!0});return i("span",{children:a},l)});return i(R,{direction:"row",gap:"tight",align:"center",children:r.filter(Boolean)})}const c=h.map(r=>{const l=e.fields[r];return l?v(t[r],l,n,{compact:!0}):t[r]});return i(B,{level:"small",children:c.join(" \xB7 ")})},[t,e.fields,h,n]),E=Q(e).delete,w=i(H,{title:String(V??""),subtitle:_,content:z??void 0,footer:q,clickable:!!f,onClick:f?()=>f(t.id):void 0,elevated:M,className:P}),L=D||o?A("div",{style:{position:"absolute",top:"var(--gap-sm)",right:"var(--gap-sm)",zIndex:10,display:"flex",alignItems:"flex-start",gap:"var(--gap-xs)"},onClick:d=>d.stopPropagation(),onMouseDown:d=>d.stopPropagation(),children:[D,o&&i(J,{action:async()=>{await E(t.id)},confirmText:m("delete.confirm",{defaultValue:"Are you sure you want to delete this item?"}),confirmTitle:m("delete.title",{defaultValue:"Delete Item"}),loadingText:m("delete.loading",{defaultValue:"Deleting..."}),variant:"destructive",icon:G,"aria-label":m("delete",{defaultValue:"Delete"}),children:m("delete",{defaultValue:"Delete"})})]}):null;return L?A("div",{style:{position:"relative",height:"100%"},children:[w,L]}):w}var st=W;export{W as CrudCard,st as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as b,Fragment as ct}from"react/jsx-runtime";import{useState as k,useMemo as pt}from"react";import{X as Dt}from"lucide-react";import{Button as S,Calendar as St,FloatingLabel as ht,Sheet as T,Text as $t}from"@donotdev/components";import{formatDate as ft}from"@donotdev/core";function yt({label:h,fieldType:xt,value:l,onChange:$,tCrud:i,locale:j="en"}){const[w,s]=k(!1),[F,f]=k(null),E=pt(()=>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 ft(n,j)}catch{return t}},N=()=>{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"),d=`${n}-${g}-${r}`,o=new Date(t);o.setDate(o.getDate()-1);const x=o.getFullYear(),y=String(o.getMonth()+1).padStart(2,"0"),B=String(o.getDate()).padStart(2,"0"),H=`${x}-${y}-${B}`,m=new Date(t);m.setDate(m.getDate()+1);const I=m.getFullYear(),L=String(m.getMonth()+1).padStart(2,"0"),W=String(m.getDate()).padStart(2,"0"),X=`${I}-${L}-${W}`,u=new Date(t);u.setDate(u.getDate()-7);const q=u.getFullYear(),A=String(u.getMonth()+1).padStart(2,"0"),G=String(u.getDate()).padStart(2,"0"),J=`${q}-${A}-${G}`,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}`,p=new Date(t);p.setDate(p.getDate()+7);const U=p.getFullYear(),Z=String(p.getMonth()+1).padStart(2,"0"),_=String(p.getDate()).padStart(2,"0"),tt=`${U}-${Z}-${_}`,D=new Date(t);D.setDate(D.getDate()+30);const et=D.getFullYear(),at=String(D.getMonth()+1).padStart(2,"0"),nt=String(D.getDate()).padStart(2,"0"),rt=`${et}-${at}-${nt}`,M=new Date(t.getFullYear(),t.getMonth(),1),lt=M.getFullYear(),it=String(M.getMonth()+1).padStart(2,"0"),st=String(M.getDate()).padStart(2,"0"),ot=`${lt}-${it}-${st}`,v=new Date(t.getFullYear(),t.getMonth()+1,0),gt=v.getFullYear(),dt=String(v.getMonth()+1).padStart(2,"0"),mt=String(v.getDate()).padStart(2,"0"),ut=`${gt}-${dt}-${mt}`;return{today:d,yesterday:H,tomorrow:X,last7Days:J,last30Days:R,next7Days:tt,next30Days:rt,thisMonthStart:ot,thisMonthEnd:ut}},e=E,O=N(),z=!!(e?.min||e?.max),Y=t=>{const n=t==="start",g=n?e?.min:e?.max;return a("div",{style:{padding:"var(--gap-md)"},children:b("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-md)"},children:[a("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 d=O[r];return a(S,{variant:"outline",onClick:()=>{$({min:n?d:e?.min||"",max:n?e?.max||"":d}),s(!1)},children:i(`filter.${r}`,{defaultValue:r})},r)})}),a(St,{selected:g?new Date(g+"T00:00:00"):void 0,mode:"single",onSelect:r=>{if(!r)return;const d=r.getFullYear(),o=String(r.getMonth()+1).padStart(2,"0"),x=String(r.getDate()).padStart(2,"0"),y=`${d}-${o}-${x}`;$({min:n?y:e?.min||"",max:n?e?.max||"":y}),s(!1)},defaultMonth:g?new Date(g+"T00:00:00"):new Date}),a(S,{variant:"ghost",display:"compact",onClick:()=>{$({min:n?"":e?.min||"",max:n&&e?.max||""}),s(!1)},children:i("filter.clear",{defaultValue:"Clear"})})]})})},V=b(ct,{children:[a(T,{trigger:a(S,{variant:"outline",onClick:()=>{f("start"),s(!0)},style:{flex:1},children:e?.min?C(e.min):i("filter.min",{defaultValue:"Min"})}),title:`${h} - ${i("filter.min",{defaultValue:"Min"})}`,open:w&&F==="start",onOpenChange:t=>{s(t),t||f(null)},children:Y("start")}),a($t,{level:"small",variant:"muted",style:{display:"flex",alignItems:"center"},children:"\u2013"}),a(T,{trigger:a(S,{variant:"outline",onClick:()=>{f("end"),s(!0)},style:{flex:1},children:e?.max?C(e.max):i("filter.max",{defaultValue:"Max"})}),title:`${h} - ${i("filter.max",{defaultValue:"Max"})}`,open:w&&F==="end",onOpenChange:t=>{s(t),t||f(null)},children:Y("end")}),a(S,{variant:"ghost",display:"compact",icon:a(Dt,{size:16}),onClick:()=>{$(void 0)},disabled:!z,"aria-label":i("filter.clear",{defaultValue:"Clear"})})]});return h?a(ht,{label:h,className:"dndev-range-input",children:V}):a("div",{className:"dndev-range-input",children:V})}export{yt as DateFilter};
1
+ "use client";import{jsx as a,jsxs as k,Fragment as Dt}from"react/jsx-runtime";import{useState as T,useMemo as yt}from"react";import{X as ht}from"lucide-react";import{Button as S,Calendar as St,FloatingLabel as ut,Sheet as E,Text as pt}from"@donotdev/components";import{formatDate as ft}from"@donotdev/core";function vt({label:u,fieldType:xt,value:s,onChange:p,tCrud:o,locale:_="en"}){const[w,l]=T(!1),[F,f]=T(null),b=yt(()=>s?typeof s=="object"&&s!==null&&"min"in s?{min:s.min||"",max:s.max||""}:{min:"",max:""}:{min:"",max:""},[s]),v=t=>{if(!t)return"";try{const n=new Date(t+"T00:00:00");return ft(n,_)}catch{return t}},C=()=>{const t=new Date;t.setHours(0,0,0,0);const n=t.getFullYear(),c=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),g=`${n}-${c}-${r}`,i=new Date(t);i.setDate(i.getDate()-1);const M=i.getFullYear(),x=String(i.getMonth()+1).padStart(2,"0"),z=String(i.getDate()).padStart(2,"0"),A=`${M}-${x}-${z}`,d=new Date(t);d.setDate(d.getDate()+1);const B=d.getFullYear(),H=String(d.getMonth()+1).padStart(2,"0"),I=String(d.getDate()).padStart(2,"0"),L=`${B}-${H}-${I}`,m=new Date(t);m.setDate(m.getDate()-7);const O=m.getFullYear(),P=String(m.getMonth()+1).padStart(2,"0"),W=String(m.getDate()).padStart(2,"0"),X=`${O}-${P}-${W}`,D=new Date(t);D.setDate(D.getDate()-30);const q=D.getFullYear(),G=String(D.getMonth()+1).padStart(2,"0"),J=String(D.getDate()).padStart(2,"0"),K=`${q}-${G}-${J}`,y=new Date(t);y.setDate(y.getDate()+7);const Q=y.getFullYear(),U=String(y.getMonth()+1).padStart(2,"0"),Z=String(y.getDate()).padStart(2,"0"),tt=`${Q}-${U}-${Z}`,h=new Date(t);h.setDate(h.getDate()+30);const et=h.getFullYear(),at=String(h.getMonth()+1).padStart(2,"0"),nt=String(h.getDate()).padStart(2,"0"),rt=`${et}-${at}-${nt}`,$=new Date(t.getFullYear(),t.getMonth(),1),st=$.getFullYear(),ot=String($.getMonth()+1).padStart(2,"0"),lt=String($.getDate()).padStart(2,"0"),it=`${st}-${ot}-${lt}`,Y=new Date(t.getFullYear(),t.getMonth()+1,0),ct=Y.getFullYear(),gt=String(Y.getMonth()+1).padStart(2,"0"),dt=String(Y.getDate()).padStart(2,"0"),mt=`${ct}-${gt}-${dt}`;return{today:g,yesterday:A,tomorrow:L,last7Days:X,last30Days:K,next7Days:tt,next30Days:rt,thisMonthStart:it,thisMonthEnd:mt}},e=b,N=C(),R=!!(e?.min||e?.max),V=t=>{const n=t==="start",c=n?e?.min:e?.max;return a("div",{style:{padding:"var(--gap-md)"},children:k("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-md)"},children:[a("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 g=N[r];return a(S,{variant:"outline",onClick:()=>{p({min:n?g:e?.min||"",max:n?e?.max||"":g}),l(!1)},children:o(`filter.${r}`,{defaultValue:r})},r)})}),a(St,{selected:c?new Date(c+"T00:00:00"):void 0,mode:"single",onSelect:r=>{if(!r)return;const g=r.getFullYear(),i=String(r.getMonth()+1).padStart(2,"0"),M=String(r.getDate()).padStart(2,"0"),x=`${g}-${i}-${M}`;p({min:n?x:e?.min||"",max:n?e?.max||"":x}),l(!1)},defaultMonth:c?new Date(c+"T00:00:00"):new Date}),a(S,{variant:"ghost",display:"compact",onClick:()=>{p({min:n?"":e?.min||"",max:n&&e?.max||""}),l(!1)},children:o("filter.clear",{defaultValue:"Clear"})})]})})},j=k(Dt,{children:[a(E,{trigger:a(S,{variant:"outline",onClick:()=>{f("start"),l(!0)},style:{flex:1},children:e?.min?v(e.min):o("filter.min",{defaultValue:"Min"})}),title:`${u} - ${o("filter.min",{defaultValue:"Min"})}`,open:w&&F==="start",onOpenChange:t=>{l(t),t||f(null)},children:V("start")}),a(pt,{level:"small",variant:"muted",style:{display:"flex",alignItems:"center"},children:"\u2013"}),a(E,{trigger:a(S,{variant:"outline",onClick:()=>{f("end"),l(!0)},style:{flex:1},children:e?.max?v(e.max):o("filter.max",{defaultValue:"Max"})}),title:`${u} - ${o("filter.max",{defaultValue:"Max"})}`,open:w&&F==="end",onOpenChange:t=>{l(t),t||f(null)},children:V("end")}),a(S,{variant:"ghost",display:"compact",icon:a(ht,{size:16}),onClick:()=>{p(void 0)},disabled:!R,"aria-label":o("filter.clear",{defaultValue:"Clear"})})]});return u?a(ut,{label:u,className:"dndev-range-input",children:j}):a("div",{className:"dndev-range-input",children:j})}export{vt as DateFilter};
@@ -1 +1 @@
1
- "use client";import{jsx as t,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{translateFieldLabel as u}from"../forms/utils";import{getDisplayFormatter as y}from"../fieldTypeRegistry";function m(r,e,o,n){const i=n?.compact??!1;if(r==null||r==="")return i?t("span",{style:{color:"var(--muted-foreground)"},children:"\u2014"}):t(a,{variant:"muted",children:"\u2014"});const l=y(e.type);if(l)try{return l(r,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?t("span",{style:{color:"var(--muted-foreground)"},children:String(r)}):t(a,{variant:"muted",children:String(r)})}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?t("span",{style:{color:"var(--muted-foreground)"},children:String(r)}):t(a,{variant:"muted",children:String(r)})}function p({name:r,config:e,value:o,t:n}){const i=m(o,e,n,{compact:!1}),l=u(r,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,":"]}),t("div",{style:{flex:1,display:"flex",alignItems:"center"},children:typeof i=="string"?t(a,{children:i}):i})]})}var g=p;export{p as DisplayFieldRenderer,g as default,m as formatValue};
1
+ "use client";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{Text as a,Stack as p}from"@donotdev/components";import{handleError as d}from"@donotdev/core";import{translateFieldLabel as f}from"../forms/utils";import{getDisplayFormatter as y}from"../fieldTypeRegistry";function c(r,e,o,n){const i=n?.compact??!1;if(r==null||r==="")return i?t("span",{style:{color:"var(--muted-foreground)"},children:"\u2014"}):t(a,{variant:"muted",children:"\u2014"});const l=y(e.type);if(l)try{return l(r,e,o,n)}catch(m){return d(m,{userMessage:`Error formatting field "${e.label||e.name}"`,context:{fieldType:e.type,fieldName:e.label||"unknown",operation:"display_format"},severity:"warning"}),i?t("span",{style:{color:"var(--muted-foreground)"},children:String(r)}):t(a,{variant:"muted",children:String(r)})}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?t("span",{style:{color:"var(--muted-foreground)"},children:String(r)}):t(a,{variant:"muted",children:String(r)})}function u({name:r,config:e,value:o,t:n}){const i=c(o,e,n,{compact:!1}),l=f(r,e,n);return s(p,{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,":"]}),t("div",{style:{flex:1,display:"flex",alignItems:"center"},children:typeof i=="string"?t(a,{children:i}):i})]})}var b=u;export{u as DisplayFieldRenderer,b as default,c as formatValue};
@@ -1 +1 @@
1
- "use client";import{jsx as i}from"react/jsx-runtime";function s(r){if(r==null)return null;if(typeof r=="string")return r||null;const l=Array.isArray(r)&&r.length>0?r[0]:r;if(!l||typeof l!="object")return null;const t=l.thumbUrl??l.fullUrl;return typeof t=="string"?t:null}function n({pictures:r,alt:l="",aspectRatio:t="16/9",className:a,style:o}){const e=s(r);return e?i("div",{className:a,style:{width:"100%",aspectRatio:t,borderRadius:"var(--radius-md)",overflow:"hidden",backgroundColor:"var(--muted)",position:"relative",...o},children:i("img",{src:e,alt:l,loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"}})}):null}var u=n;export{n as DisplayThumbnail,u as default};
1
+ "use client";import{jsx as e}from"react/jsx-runtime";function u(r){if(r==null)return null;if(typeof r=="string")return r||null;const l=Array.isArray(r)&&r.length>0?r[0]:r;if(!l||typeof l!="object")return null;const t=l.thumbUrl??l.fullUrl;return typeof t=="string"?t:null}function a({pictures:r,alt:l="",aspectRatio:t="16/9",className:o,style:i}){const n=u(r);return n?e("div",{className:o,style:{width:"100%",aspectRatio:t,borderRadius:"var(--radius-md)",overflow:"hidden",backgroundColor:"var(--muted)",position:"relative",...i},children:e("img",{src:n,alt:l,loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover"}})}):null}var d=a;export{a as DisplayThumbnail,d as default};
@@ -1,38 +1,5 @@
1
1
  import type { Entity } from '@donotdev/core';
2
- /**
3
-
4
- * Shared filter utility - checks if an item matches a filter value
5
-
6
- *
7
-
8
- * Pattern for null/undefined handling:
9
-
10
- * - MIN / undefined → Only show items with defined values >= MIN (exclude null/undefined)
11
-
12
- * - undefined / MAX → Show items with value <= MAX OR null/undefined (include null/undefined)
13
-
14
- * - MIN / MAX → Show items with MIN <= value <= MAX (exclude null/undefined)
15
-
16
- */
17
- export declare function matchesFilter(itemValue: any, filterValue: string | {
18
- min?: string;
19
- max?: string;
20
- } | string[] | {
21
- date: string;
22
- time?: string;
23
- } | {
24
- min?: {
25
- date: string;
26
- time?: string;
27
- };
28
- max?: {
29
- date: string;
30
- time?: string;
31
- };
32
- } | {
33
- date: string;
34
- time?: string;
35
- }[], fieldType: string): boolean;
2
+ export { matchesFilter } from '../utils/matchesFilter';
36
3
  export interface EntityFiltersProps<T extends Record<string, any> & {
37
4
  id: string;
38
5
  } = Record<string, any> & {
@@ -1 +1 @@
1
- {"version":3,"file":"EntityFilters.d.ts","sourceRoot":"","sources":["../../src/components/EntityFilters.tsx"],"names":[],"mappings":"AAyDA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAS7C;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,GAAG,EAEd,WAAW,EACP,MAAM,GACN;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,MAAM,EAAE,GACR;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B;IACE,GAAG,CAAC,EAAE;QAAE,IAAI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C,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,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,GACnB,EAAE,kBAAkB,CAAC,CAAC,CAAC,kDA+nBvB"}
@@ -1 +1 @@
1
- "use client";import{jsx as F,jsxs as P}from"react/jsx-runtime";import{useMemo as z}from"react";import{FilterX as Y}from"lucide-react";import{Button as Z,Combobox as U,Grid as ee,RangeInput as te,Slider as ne,Stack as ie}from"@donotdev/components";import{DateFilter as re}from"./DateFilter";import{useTranslation as q,handleError as H}from"@donotdev/core";import{translateFieldLabel as ae,translateLabel as J}from"../forms/utils";import{getFilterType as I,isFilterable as le}from"../fieldTypeRegistry";import{useCrudFilters as oe}from"../hooks/useCrudFilters";import{useCrudCardList as se}from"../useCrudCardList";function K(e,l,s){if(!l)return!0;if(Array.isArray(l)){if(l.length===0)return!0;if(!(I(s)==="range"&&(s==="date"||s==="datetime-local"||s==="timestamp")))return l.some(o=>{if(typeof o=="object"&&"date"in o){const C=o.date;return(e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0])===C}return String(e)===String(o)});const b=e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0];return l.some(o=>typeof o=="string"?b===o:typeof o=="object"&&"date"in o?b===o.date:!1)}if(typeof l=="object"&&"date"in l&&!("min"in l)&&!Array.isArray(l)){if(!(I(s)==="range"&&(s==="date"||s==="datetime-local"||s==="timestamp")))return!1;const b=l.date;if(!b)return!0;if(e==null)return!1;const o=e instanceof Date?e.toISOString().split("T")[0]:new Date(e).toISOString().split("T")[0];if((s==="datetime-local"||s==="timestamp")&&l.time){const C=e instanceof Date?e.toISOString().slice(11,16):new Date(e).toISOString().slice(11,16);return o===b&&C===l.time}return o===b}if(typeof l=="object"&&"min"in l){const b=I(s);if(!b)return!0;const o=b==="range"&&(s==="date"||s==="datetime-local"||s==="timestamp"),C=b==="range"&&!o,j=s==="price",S=j&&e!=null&&typeof e=="object"?Number(e.amount):C&&e!=null?typeof e=="number"?e:Number(e):NaN;if(C||j){if(typeof l.min=="object"&&l.min!==null&&"date"in l.min)return!1;const f=l,d=typeof f.min=="string"&&f.min!=="",x=typeof f.max=="string"&&f.max!=="";return d&&!x?e==null||isNaN(S)?!1:S>=Number(f.min):!d&&x?e==null?!0:isNaN(S)?!1:S<=Number(f.max):d&&x?e==null||isNaN(S)?!1:S>=Number(f.min)&&S<=Number(f.max):!0}if(o){if(typeof l.min=="object"&&l.min!==null&&"date"in l.min&&!("min"in l.min)){const g=l,c=g.min,T=g.max,k=c?.date&&c.date!=="",N=T?.date&&T.date!=="";if(k&&!N){if(e==null)return!1;const w=e instanceof Date?e:new Date(e);if(isNaN(w.getTime()))return!1;const D=new Date(c.date+(c.time?`T${c.time}:00`:"T00:00:00"));return w>=D}if(!k&&N&&T){if(e==null)return!0;const w=e instanceof Date?e:new Date(e);if(isNaN(w.getTime()))return!1;const D=new Date(T.date+(T.time?`T${T.time}:00`:"T23:59:59"));return w<=D}if(k&&N&&T){if(e==null)return!1;const w=e instanceof Date?e:new Date(e);if(isNaN(w.getTime()))return!1;const D=new Date(c.date+(c.time?`T${c.time}:00`:"T00:00:00")),X=new Date(T.date+(T.time?`T${T.time}:00`:"T23:59:59"));return w>=D&&w<=X}return!0}const f=l,d=typeof f.min=="string"&&f.min!=="",x=typeof f.max=="string"&&f.max!=="";if(d&&!x){if(e==null)return!1;const g=e instanceof Date?e:new Date(e);return isNaN(g.getTime())?!1:g>=new Date(f.min)}if(!d&&x){if(e==null)return!0;const g=e instanceof Date?e:new Date(e);return isNaN(g.getTime())?!1:g<=new Date(f.max)}if(d&&x){if(e==null)return!1;const g=e instanceof Date?e:new Date(e);return isNaN(g.getTime())?!1:g>=new Date(f.min)&&g<=new Date(f.max)}return!0}}const A=I(s);if(!A)return!0;if(A==="address")return e==null?!1:typeof e=="object"&&"formatted_address"in e?String(e.formatted_address).toLowerCase().includes(String(l).toLowerCase()):!1;if(A==="multiselect"){if(!Array.isArray(e)||e.length===0)return!1;const b=String(l).toLowerCase();return e.some(o=>String(o).toLowerCase().includes(b))}return e==null?!1:String(e).toLowerCase().includes(String(l).toLowerCase())}function me({entity:e,data:l,fieldsToFilter:s,variant:A="inline"}){const b=A==="sidebar",{t:o,i18n:C}=q("crud"),{t:j}=q([e.namespace,"crud"]),S=C?.language||"en",{data:f}=se(e,{enabled:!l}),d=l??(f?.items||[]),{filters:x,setFilters:g}=oe({collection:e.collection}),c=z(()=>(s&&s.length>0?s:e.listFields||Object.keys(e.fields)).filter(a=>{const n=e.fields[a]?.type||"text";return le(n)}),[s,e.listFields,e.fields]),T=z(()=>{const a={};return c.forEach(n=>{const p=Object.fromEntries(Object.entries(x).filter(([i])=>i!==n));if(Object.keys(p).length===0){a[n]=d;return}a[n]=d.filter(i=>Object.entries(p).every(([h,O])=>{const L=i[h],E=e.fields[h]?.type||"text";return K(L,O,E)}))}),a},[d,x,e.fields,c]),k=z(()=>{const a={};return c.forEach(n=>{const p=e.fields[n];if(!p)return;const i=p.type||"text",h=I(i);if(!h){H(new Error(`Field type "${i}" not registered in field type registry`),{userMessage:`Field type "${i}" is missing from registry`,context:{fieldType:i,fieldName:n,operation:"minmax_computation",fix:"Add to registerBuiltinFieldTypes.ts or registerFieldType()"},severity:"warning"});return}const O=h==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"||i==="time"||i==="week"||i==="month"||i==="year"),L=h==="range"&&!O,E=i==="price";if(L||E){const m=d.map(r=>r[n]).filter(r=>r!=null&&r!=="").map(r=>E&&typeof r=="object"&&r!==null?Number(r.amount):typeof r=="number"?r:Number(r)).filter(r=>!isNaN(r));m.length>0&&(a[n]={min:Math.min(...m),max:Math.max(...m)})}else if(O){const m=d.map(r=>r[n]).filter(r=>r!=null&&r!=="").map(r=>r instanceof Date?r:new Date(r)).filter(r=>!isNaN(r.getTime()));if(m.length>0){const r=new Date(Math.min(...m.map(V=>V.getTime()))),_=new Date(Math.max(...m.map(V=>V.getTime()))),G=r.toISOString().split("T")[0],M=_.toISOString().split("T")[0];a[n]={min:G||"",max:M||""}}}}),a},[d,e.fields,c]),N=(a,n)=>{const p={...x};if(!n||n==="")delete p[a];else if(Array.isArray(n))p[a]=n;else if(typeof n=="object"&&"min"in n){const i=n.min&&n.min!=="",h=n.max&&n.max!=="";!i&&!h?delete p[a]:p[a]=n}else p[a]=n;g(p)},w=()=>{g({})},D=z(()=>c.length===0?null:c.map(a=>{const n=e.fields[a];if(!n)return null;const p=ae(a,n,j),i=n.type||"text",h=I(i);if(!h)return H(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 O=h==="range"&&(i==="date"||i==="datetime-local"||i==="timestamp"||i==="time"||i==="week"||i==="month"||i==="year"),L=h==="range"&&!O,E=h==="select",m=x[a],r=typeof m=="object"&&m!==null&&"min"in m?m:{min:"",max:""};if(L){const u=k[a],y=u?.min??0,t=u?.max??100,v=r.min?Number(r.min):y,B=r.max?Number(r.max):t;return P(ie,{gap:"tight",style:{gridColumn:"span 2"},children:[F(te,{type:"number",label:p,minPlaceholder:o("filter.min",{defaultValue:"Min"}),maxPlaceholder:o("filter.max",{defaultValue:"Max"}),minValue:r.min||"",maxValue:r.max||"",actualMin:y,actualMax:t,onChange:(R,W)=>{N(a,{min:R,max:W})},onClear:()=>N(a,void 0)}),F(ne,{value:[v,B],min:y,max:t,step:1,onValueChange:R=>{N(a,{min:String(R[0]),max:String(R[1])})}})]},a)}if(O){const u=i==="week"||i==="month"||i==="year"?i:"date",y=(()=>{if(m){if(typeof m=="object"&&"min"in m){const t=m;return{min:t.min&&t.min.split("T")[0]||"",max:t.max&&t.max.split("T")[0]||""}}if(typeof m=="string"){const t=m.split("T")[0]||"";return{min:t,max:t}}}})();return F("div",{style:{gridColumn:"span 2",gridRow:b?void 0:"span 1"},children:F(re,{label:p,fieldType:u,value:y,locale:S,onChange:t=>{if(!t){N(a,void 0);return}typeof t=="object"&&"min"in t&&N(a,{min:t.min||"",max:t.max||""})},tCrud:o})},a)}const _=E&&n.validation&&"options"in n.validation&&n.validation?Array.isArray(n.validation.options)?n.validation.options:typeof n.validation.options=="function"?n.validation.options():[]:[],G=T[a]||d,M=new Set,V=h==="address";G.forEach(u=>{const y=u[a];if(y!=null)if(V&&typeof y=="object"&&"formatted_address"in y){const t=y;t.formatted_address&&M.add(String(t.formatted_address))}else M.add(String(y))});const $=[{value:"all",label:o("filter.selectPlaceholder",{defaultValue:"All"})}];if(_.length>0){const u=[],y=[];_.forEach(t=>{const v=typeof t=="string"?t:t.value,B=typeof t=="string"?t:t.label;M.has(v)?u.push({value:v,label:B}):y.push({value:v,label:B})}),u.sort((t,v)=>t.label.localeCompare(v.label)),y.sort((t,v)=>t.label.localeCompare(v.label)),u.forEach(t=>{$.push({value:t.value,label:J(t.label,j),disabled:!1})}),y.forEach(t=>{$.push({value:t.value,label:J(t.label,j),disabled:!0})})}else Array.from(M).sort().slice(0,100).forEach(u=>{$.push({value:u,label:u})});return F("div",{style:{gridColumn:"span 2",gridRow:"span 1"},children:F(U,{label:p,value:typeof m=="string"?m:void 0,onValueChange:u=>{N(a,u==="all"||!u?"":String(u))},options:$,placeholder:o("filter.placeholder",{defaultValue:"Filter..."}),clearable:!0})},a)}),[c,e.fields,d,x,j,o,T]);if(!D||D.length===0)return null;const X=D.filter(Boolean),Q=Object.keys(x).length>0;return P(ee,{cols:A==="sidebar"?2:[2,4,6,8],children:[X,F(Z,{variant:"outline",icon:F(Y,{size:18}),onClick:w,disabled:!Q,style:{gridColumn:"1 / -1",gridRow:"span 1"},children:o("filter.clear",{defaultValue:"Clear Filters"})})]})}export{me as EntityFilters,K as matchesFilter};
1
+ "use client";import{jsx as p,jsxs as B}from"react/jsx-runtime";import{useMemo as w}from"react";import{FilterX as Z}from"lucide-react";import{Button as N,Combobox as ee,Grid as te,RangeInput as ne,Slider as ie,Stack as re}from"@donotdev/components";import{DateFilter as se}from"./DateFilter";import{useTranslation as L,handleError as $}from"@donotdev/core";import{translateFieldLabel as le,translateLabel as I}from"../forms/utils";import{getFilterType as z,isFilterable as oe}from"../fieldTypeRegistry";import{useCrudFilters as ae}from"../hooks/useCrudFilters";import{useCrudCardList as ce}from"../useCrudCardList";import{matchesFilter as de}from"../utils/matchesFilter";import{matchesFilter as Ve}from"../utils/matchesFilter";function Ae({entity:c,data:k,fieldsToFilter:S,variant:_="inline"}){const G=_==="sidebar",{t:g,i18n:X}=L("crud"),{t:j}=L([c.namespace,"crud"]),q=X?.language||"en",{data:H}=ce(c,{enabled:!k}),f=k??(H?.items||[]),{filters:x,setFilters:R}=ae({collection:c.collection}),h=w(()=>(S&&S.length>0?S:c.listFields||Object.keys(c.fields)).filter(t=>{const n=c.fields[t]?.type||"text";return oe(n)}),[S,c.listFields,c.fields]),v=w(()=>{const i={};return h.forEach(t=>{const l=Object.fromEntries(Object.entries(x).filter(([n])=>n!==t));if(Object.keys(l).length===0){i[t]=f;return}i[t]=f.filter(n=>Object.entries(l).every(([d,b])=>{const F=n[d],s=c.fields[d]?.type||"text";return de(F,b,s)}))}),i},[f,x,c.fields,h]),J=w(()=>{const i={};return h.forEach(t=>{const l=c.fields[t];if(!l)return;const n=l.type||"text",d=z(n);if(!d){$(new Error(`Field type "${n}" not registered in field type registry`),{userMessage:`Field type "${n}" is missing from registry`,context:{fieldType:n,fieldName:t,operation:"minmax_computation",fix:"Add to registerBuiltinFieldTypes.ts or registerFieldType()"},severity:"warning"});return}const b=d==="range"&&(n==="date"||n==="datetime-local"||n==="timestamp"||n==="time"||n==="week"||n==="month"||n==="year"),F=d==="range"&&!b,C=n==="price";if(F||C){const s=f.map(r=>r[t]).filter(r=>r!=null&&r!=="").map(r=>C&&typeof r=="object"&&r!==null?Number(r.amount):typeof r=="number"?r:Number(r)).filter(r=>!isNaN(r));s.length>0&&(i[t]={min:Math.min(...s),max:Math.max(...s)})}else if(b){const s=f.map(r=>r[t]).filter(r=>r!=null&&r!=="").map(r=>r instanceof Date?r:new Date(r)).filter(r=>!isNaN(r.getTime()));if(s.length>0){const r=new Date(Math.min(...s.map(T=>T.getTime()))),u=new Date(Math.max(...s.map(T=>T.getTime()))),P=r.toISOString().split("T")[0],E=u.toISOString().split("T")[0];i[t]={min:P||"",max:E||""}}}}),i},[f,c.fields,h]),y=(i,t)=>{const l={...x};if(!t||t==="")delete l[i];else if(Array.isArray(t))l[i]=t;else if(typeof t=="object"&&"min"in t){const n=t.min&&t.min!=="",d=t.max&&t.max!=="";!n&&!d?delete l[i]:l[i]=t}else l[i]=t;R(l)},K=()=>{R({})},V=w(()=>h.length===0?null:h.map(i=>{const t=c.fields[i];if(!t)return null;const l=le(i,t,j),n=t.type||"text",d=z(n);if(!d)return $(new Error(`Field type "${n}" not registered in field type registry`),{userMessage:`Field type "${n}" is missing from registry`,context:{fieldType:n,fieldName:i,operation:"filter_ui_render",fix:"Add to registerBuiltinFieldTypes.ts or registerFieldType()"},severity:"warning"}),null;const b=d==="range"&&(n==="date"||n==="datetime-local"||n==="timestamp"||n==="time"||n==="week"||n==="month"||n==="year"),F=d==="range"&&!b,C=d==="select",s=x[i],u=typeof s=="object"&&s!==null&&"min"in s?s:{min:"",max:""};if(F){const o=J[i],a=o?.min??0,e=o?.max??100,m=u.min?Number(u.min):a,O=u.max?Number(u.max):e;return B(re,{gap:"tight",style:{gridColumn:"span 2"},children:[p(ne,{type:"number",label:l,minPlaceholder:g("filter.min",{defaultValue:"Min"}),maxPlaceholder:g("filter.max",{defaultValue:"Max"}),minValue:u.min||"",maxValue:u.max||"",actualMin:a,actualMax:e,onChange:(M,Y)=>{y(i,{min:M,max:Y})},onClear:()=>y(i,void 0)}),p(ie,{value:[m,O],min:a,max:e,step:1,onValueChange:M=>{y(i,{min:String(M[0]),max:String(M[1])})}})]},i)}if(b){const o=n==="week"||n==="month"||n==="year"?n:"date",a=(()=>{if(s){if(typeof s=="object"&&"min"in s){const e=s;return{min:e.min&&e.min.split("T")[0]||"",max:e.max&&e.max.split("T")[0]||""}}if(typeof s=="string"){const e=s.split("T")[0]||"";return{min:e,max:e}}}})();return p("div",{style:{gridColumn:"span 2",gridRow:G?void 0:"span 1"},children:p(se,{label:l,fieldType:o,value:a,locale:q,onChange:e=>{if(!e){y(i,void 0);return}typeof e=="object"&&"min"in e&&y(i,{min:e.min||"",max:e.max||""})},tCrud:g})},i)}const E=C&&t.validation&&"options"in t.validation&&t.validation?Array.isArray(t.validation.options)?t.validation.options:typeof t.validation.options=="function"?t.validation.options():[]:[],T=v[i]||f,D=new Set,W=d==="address";T.forEach(o=>{const a=o[i];if(a!=null)if(W&&typeof a=="object"&&"formatted_address"in a){const e=a;e.formatted_address&&D.add(String(e.formatted_address))}else D.add(String(a))});const A=[{value:"all",label:g("filter.selectPlaceholder",{defaultValue:"All"})}];if(E.length>0){const o=[],a=[];E.forEach(e=>{const m=typeof e=="string"?e:e.value,O=typeof e=="string"?e:e.label;D.has(m)?o.push({value:m,label:O}):a.push({value:m,label:O})}),o.sort((e,m)=>e.label.localeCompare(m.label)),a.sort((e,m)=>e.label.localeCompare(m.label)),o.forEach(e=>{A.push({value:e.value,label:I(e.label,j),disabled:!1})}),a.forEach(e=>{A.push({value:e.value,label:I(e.label,j),disabled:!0})})}else Array.from(D).sort().slice(0,100).forEach(o=>{A.push({value:o,label:o})});return p("div",{style:{gridColumn:"span 2",gridRow:"span 1"},children:p(ee,{label:l,value:typeof s=="string"?s:void 0,onValueChange:o=>{y(i,o==="all"||!o?"":String(o))},options:A,placeholder:g("filter.placeholder",{defaultValue:"Filter..."}),clearable:!0})},i)}),[h,c.fields,f,x,j,g,v]);if(!V||V.length===0)return null;const Q=V.filter(Boolean),U=Object.keys(x).length>0;return B(te,{cols:_==="sidebar"?2:[2,4,6,8],children:[Q,p(N,{variant:"outline",icon:p(Z,{size:18}),onClick:K,disabled:!U,style:{gridColumn:"1 / -1",gridRow:"span 1"},children:g("filter.clear",{defaultValue:"Clear Filters"})})]})}export{Ae as EntityFilters,Ve as matchesFilter};
@@ -1 +1 @@
1
- "use client";import{jsx as n}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:r,config:e,t,...o}){const p=l=>i=>{try{l(i)}catch(a){C(a,{userMessage:`Error updating field ${e.label||r}`,context:{fieldName:r,fieldType:e.type},severity:"warning"})}},s="control"in o&&o.control,d=e.type==="submit"||e.type==="reset";if(s&&!d){const{control:l,errors:i}=o,a=e.options?.fieldSpecific?.placeholder,y={control:l,errors:i,fieldConfig:{...e,label:e.label||r},t,placeholder:a,onChange:p(()=>{})},u=v.getControlledComponent(e.type);return u?n(u,{...y}):(C(new Error(`Unregistered field type: ${e.type}`),{userMessage:t("errors.unsupportedFieldType",{type:e.type}),context:{fieldName:r,fieldType:e.type},severity:"warning"}),n(T,{...y,fieldConfig:{...e,type:"text"}}))}const b=s&&d?{name:r,config:e,t,value:void 0,onChange:()=>{},error:void 0}:o,{value:f,onChange:x,error:c}=b,m=p(x),g=v.getUncontrolledComponent(e.type);return g?n(g,{name:r,label:e.label||r,value:f,onChange:m,error:c,t,config:e,...e.options}):n(w,{label:e.label||r,value:f,onChange:m,error:c||void 0,...e.options})}var E=h;export{h as FormFieldRenderer,E as default};
1
+ "use client";import{jsx as l}from"react/jsx-runtime";import{handleError as h}from"@donotdev/core";import{getFieldRegistry as T}from"../FieldRegistry";import{ControlledTextField as S}from"./controlled";import{TextFieldComponent as g}from"./form/fields";import"../builtinFieldTypes";const x=T();function w({name:r,config:e,t,...o}){const s=n=>d=>{try{n(d)}catch(C){h(C,{userMessage:`Error updating field ${e.label||r}`,context:{fieldName:r,fieldType:e.type},severity:"warning"})}},i="control"in o&&o.control,p=e.type==="submit"||e.type==="reset";if(i&&!p){const{control:n,errors:d}=o,F=e.options?.fieldSpecific?.placeholder,f={control:n,errors:d,fieldConfig:{...e,label:e.label||r},t,placeholder:F,onChange:s(()=>{})},m=x.getControlledComponent(e.type);return m?l(m,{...f}):(h(new Error(`Unregistered field type: ${e.type}`),{userMessage:t("errors.unsupportedFieldType",{type:e.type}),context:{fieldName:r,fieldType:e.type},severity:"warning"}),l(S,{...f,fieldConfig:{...e,type:"text"}}))}const b=i&&p?{name:r,config:e,t,value:void 0,onChange:()=>{},error:void 0}:o,{value:a,onChange:v,error:u}=b,y=s(v),c=x.getUncontrolledComponent(e.type);return c?l(c,{name:r,label:e.label||r,value:a,onChange:y,error:u,t,config:e,...e.options}):l(g,{label:e.label||r,value:a,onChange:y,error:u||void 0,...e.options})}var R=w;export{w as FormFieldRenderer,R 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 A}from"@donotdev/components";import{useTranslation as B}from"@donotdev/core";const F=({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:l})=>{const{t:e}=B("dndev"),[r,t]=w(!1),y=u||e("form.submit","Submit"),x=v||e("form.cancel","Cancel"),S=async T=>{t(!0);try{await m(T)}finally{t(!1)}},L={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}),l&&d("p",{style:{color:"var(--muted-foreground)"},children:l})]}),d(A,{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 I=F;export{I as default};
1
+ "use client";import{jsx as e,jsxs as r,Fragment as N}from"react/jsx-runtime";import{useState as j}from"react";import{FormProvider as w}from"react-hook-form";import{Button as s,BUTTON_VARIANT as C,Spinner as F,cn as _,Stack as i,Grid as I}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";const k=({title:m,onSubmit:c,children:f,formMethods:u,loading:n=!1,submitText:g,cancelText:v,showCancel:p=!1,onCancel:b,variant:l="default",columns:h=1,description:o})=>{const{t:d}=L("dndev"),[t,a]=j(!1),y=g||d("form.submit","Submit"),S=v||d("form.cancel","Cancel"),x=async T=>{a(!0);try{await c(T)}finally{a(!1)}},z={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 e(w,{...u,children:e("form",{onSubmit:x,className:_("dndev-mx-auto",{default:"dndev-surface",card:"dndev-surface",minimal:""}[l]),style:l!=="minimal"?{padding:"var(--gap-lg)"}:void 0,role:"form","aria-labelledby":"form-title",noValidate:!0,children:r(i,{gap:"large",children:[r(i,{gap:"tight",children:[e("h2",{id:"form-title",style:{fontSize:"var(--font-size-2xl)",fontWeight:600,color:"var(--foreground)"},children:m}),o&&e("p",{style:{color:"var(--muted-foreground)"},children:o})]}),e(I,{cols:h,className:"dndev-w-full dndev-min-w-0",children:f}),r(i,{direction:"row",align:"center",justify:"end",style:{paddingTop:"var(--gap-md)",borderTop:"1px solid var(--border)"},children:[p&&e(s,{type:"button",variant:C.OUTLINE,onClick:b,disabled:n||t,children:S}),e(s,{type:"submit",disabled:n||t,style:{minWidth:"120px"},children:n||t?r(N,{children:[e(F,{className:"me-component-gap"}),t?d("form.submitting","Submitting..."):d("form.loading","Loading...")]}):y})]})]})})})};var E=k;export{E as default};
@@ -1 +1 @@
1
- "use client";import{jsx as n}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{AddressFieldComponent as f}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(p,{name:e,control:s,rules:o?u(o):void 0,render:({field:i})=>n(f,{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
+ "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as f}from"react-hook-form";import{AddressFieldComponent as m}from"../../form/fields";import{convertValidationRules as u}from"../types";function h(s){const{control:a,errors:r,fieldConfig:n,t:d}=s,{name:e,label:c,validation:o}=n,t=(n.options||{}).fieldSpecific;return l(f,{name:e,control:a,rules:o?u(o):void 0,render:({field:i})=>l(m,{label:d(c),value:i.value??void 0,onChange:p=>i.onChange(p),error:!!r[e],helperText:r[e]?.message,required:o?.required,enableGoogleMaps:t?.enableGoogleMaps,extractDistrictCode:t?.extractDistrictCode})})}export{h as ControlledAddressField};
@@ -1 +1 @@
1
- "use client";import{jsx as r}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{DateFieldComponent as c}from"../../form/fields";import{convertValidationRules as C}from"../types";function h(a){const{control:n,errors:l,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 r(p,{name:e,control:n,rules:o?C(o):void 0,render:({field:t})=>r(c,{...t,label:m(d),value:t.value??null,onChange:f=>t.onChange(f),error:!!l[e],helperText:l[e]?.message,required:o?.required,mode:u})})}export{h as ControlledDateField};
1
+ "use client";import{jsx as n}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{DateFieldComponent as f}from"../../form/fields";import{convertValidationRules as C}from"../types";function j(a){const{control:l,errors:r,fieldConfig:m,t:i}=a,{name:e,label:d,validation:o,type:s}=m,c={date:"date","datetime-local":"datetime-local",month:"month",time:"time",week:"week"}[s]||"date";return n(p,{name:e,control:l,rules:o?C(o):void 0,render:({field:t})=>n(f,{...t,label:i(d),value:t.value??null,onChange:u=>t.onChange(u),error:!!r[e],helperText:r[e]?.message,required:o?.required,mode:c})})}export{j as ControlledDateField};
@@ -0,0 +1,18 @@
1
+ import type { FieldType } from '@donotdev/core';
2
+ import type { ControlledFieldProps } from '../types';
3
+ import type { ReactElement } from 'react';
4
+ /** Sub-field definition inside fieldSpecific.fields */
5
+ export interface SubFieldDef {
6
+ name: string;
7
+ type: FieldType;
8
+ label: string;
9
+ required?: boolean;
10
+ options?: Record<string, unknown>;
11
+ validation?: Record<string, unknown>;
12
+ }
13
+ /**
14
+ * ControlledFieldArrayField — nested object array with per-row sub-fields.
15
+ * Each sub-field is rendered via the field type registry so custom types work automatically.
16
+ */
17
+ export declare function ControlledFieldArrayField(props: ControlledFieldProps): ReactElement;
18
+ //# sourceMappingURL=ControlledFieldArrayField.d.ts.map
@@ -0,0 +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;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,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"}
@@ -0,0 +1 @@
1
+ "use client";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{Plus as j,Trash2 as R}from"lucide-react";import{useFieldArray as $,Controller as q}from"react-hook-form";import{Button as y}from"@donotdev/components";import{getFieldRegistry as A}from"../../../FieldRegistry";import{convertValidationRules as B}from"../types";function D(s){switch(s){case"number":return 0;case"boolean":return!1;default:return""}}function N(s){const{control:d,errors:h,fieldConfig:c,t:o}=s,{name:m,label:p,validation:b}=c,f=c.options?.fieldSpecific??{},r=f.fields??[],l=f.direction??"row",{fields:x,append:C,remove:S}=$({control:d,name:m}),w=A(),z=()=>{if(r.length===0)return;const a={};for(const i of r)a[i.name]=D(i.type);C(a)};return r.length===0?t("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[o(p),": no sub-fields configured"]}):t("div",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-sm)"},children:[t("div",{style:{display:"flex",alignItems:"center",gap:"var(--gap-sm)"},children:[t("span",{style:{fontSize:"var(--font-size-sm)",fontWeight:"var(--font-weight-medium)"},children:[o(p),b?.required&&n("span",{style:{color:"var(--destructive)",marginInlineStart:"var(--gap-tight)"},children:"*"})]}),n(y,{type:"button",variant:"ghost",display:"compact",icon:j,onClick:z,"aria-label":o(p)+" \u2014 add"})]}),x.map((a,i)=>t("div",{style:{display:"flex",flexDirection:l,gap:"var(--gap-sm)",alignItems:l==="row"?"flex-start":void 0},children:[r.map(e=>{const g=`${m}.${i}.${e.name}`,F={name:g,type:e.type,label:e.label,visibility:c.visibility,validation:{...e.validation??{},...e.required?{required:!0}:{}},options:e.options??{}},v=w.getControlledComponent(e.type);return v?n("div",{style:{flex:l==="row"?1:void 0},children:n(v,{control:d,errors:h,fieldConfig:F,t:o})},e.name):n("div",{style:{flex:l==="row"?1:void 0},children:n(q,{name:g,control:d,rules:e.validation?B(e.validation):void 0,render:({field:u})=>t("label",{style:{display:"flex",flexDirection:"column",gap:"var(--gap-tight)"},children:[n("span",{style:{fontSize:"var(--font-size-xs)"},children:o(e.label)}),n("input",{className:"dndev-input",value:String(u.value??""),onChange:u.onChange,onBlur:u.onBlur})]})})},e.name)}),n(y,{type:"button",variant:"ghost",display:"compact",icon:R,onClick:()=>S(i),"aria-label":`Remove row ${i+1}`,style:{alignSelf:l==="row"?"center":"flex-end"}})]},a.id))]})}export{N as ControlledFieldArrayField};
@@ -1 +1 @@
1
- "use client";import{jsx as l}from"react/jsx-runtime";import{Controller as c}from"react-hook-form";import{GeoPointFieldComponent as f}from"../../form/fields";import{convertValidationRules as p}from"../types";function C(a){const{control:i,errors:t,fieldConfig:s,t:m}=a,{name:o,label:d,validation:n}=s;return l(c,{name:o,control:i,rules:n?p(n):void 0,render:({field:e})=>{const g=r=>{if("target"in r)try{const u=JSON.parse(r.target.value);e.onChange(u)}catch{e.onChange({lat:0,lng:0})}else e.onChange(r||{lat:0,lng:0})};return l(f,{label:m(d),value:e.value||{lat:0,lng:0},onChange:g,error:!!t[o],helperText:t[o]?.message,required:n?.required})}})}export{C as ControlledGeoPointField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{GeoPointFieldComponent as p}from"../../form/fields";import{convertValidationRules as C}from"../types";function b(l){const{control:i,errors:t,fieldConfig:s,t:g}=l,{name:n,label:m,validation:o}=s;return a(u,{name:n,control:i,rules:o?C(o):void 0,render:({field:e})=>{const c=r=>{if("target"in r)try{const d=JSON.parse(r.target.value);e.onChange(d)}catch{e.onChange({lat:0,lng:0})}else e.onChange(r||{lat:0,lng:0})};return a(p,{label:g(m),value:e.value||{lat:0,lng:0},onChange:c,error:!!t[n],helperText:t[n]?.message,required:o?.required})}})}export{b as ControlledGeoPointField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}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:a,fieldConfig:s,t:m}=l,{name:r,label:d,validation:o}=s;return n(p,{name:r,control:i,rules:o?g(o):void 0,render:({field:e})=>{const u=t=>{if("target"in t)try{const c=JSON.parse(t.target.value);e.onChange(c)}catch{e.onChange({})}else e.onChange(t||{})};return n(f,{label:m(d),value:e.value||{},onChange:u,error:!!a[r],helperText:a[r]?.message,required:o?.required})}})}export{C as ControlledMapField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{MapFieldComponent as g}from"../../form/fields";import{convertValidationRules as C}from"../types";function b(l){const{control:i,errors:t,fieldConfig:s,t:m}=l,{name:r,label:c,validation:n}=s;return a(u,{name:r,control:i,rules:n?C(n):void 0,render:({field:e})=>{const p=o=>{if("target"in o)try{const d=JSON.parse(o.target.value);e.onChange(d)}catch{e.onChange({})}else e.onChange(o||{})};return a(g,{label:m(c),value:e.value||{},onChange:p,error:!!t[r],helperText:t[r]?.message,required:n?.required})}})}export{b as ControlledMapField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}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 v(t){const{control:l,errors:g,fieldConfig:i,t:s}=t,{name:u,label:m,validation:e,options:c={}}=i;return n(p,{name:u,control:l,rules:e?C(e):void 0,render:({field:r})=>{const d=a=>{if(Array.isArray(a))r.onChange(a);else try{const o=JSON.parse(a.target.value);r.onChange(Array.isArray(o)?o:[])}catch{r.onChange([])}};return n(f,{label:s(m),value:Array.isArray(r.value)?r.value:[],onChange:d,required:e?.required,className:c.className})}})}export{v as ControlledMultiInputField};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{MultiInputTextFieldComponent as C}from"../../form/fields";import{convertValidationRules as g}from"../types";function x(a){const{control:l,errors:h,fieldConfig:s,t:i}=a,{name:u,label:c,validation:e,options:m={}}=s;return t(d,{name:u,control:l,rules:e?g(e):void 0,render:({field:r})=>{const p=n=>{if(Array.isArray(n))r.onChange(n);else try{const o=JSON.parse(n.target.value);r.onChange(Array.isArray(o)?o:[])}catch{r.onChange([])}};return t(C,{label:i(c),value:Array.isArray(r.value)?r.value:[],onChange:p,required:e?.required,className:m.className})}})}export{x as ControlledMultiInputField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}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(t){const{control:i,errors:r,fieldConfig:s,t:m,placeholder:c}=t,{name:e,label:d,validation:o,options:l={}}=s;return n(u,{name:e,control:i,rules:o?h(o):void 0,render:({field:a})=>n(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
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{RichTextComponent as h}from"../../form/fields";import{convertValidationRules as f}from"../types";function R(a){const{control:i,errors:r,fieldConfig:s,t:m,placeholder:c}=a,{name:e,label:d,validation:o,options:l={}}=s;return t(u,{name:e,control:i,rules:o?f(o):void 0,render:({field:n})=>t(h,{label:m(d),value:n.value??"",onChange:p=>n.onChange(p),error:r[e]?.message,helperText:r[e]?.message,required:o?.required,placeholder:c||l.placeholder,className:l.className})})}export{R as ControlledRichTextField};
@@ -1 +1 @@
1
- "use client";import{jsx as n}from"react/jsx-runtime";import{Controller as u}from"react-hook-form";import{TimestampFieldComponent as p}from"../../form/fields";import{convertValidationRules as f}from"../types";function c(a){const{control:i,errors:l,fieldConfig:t,t:m}=a,{name:e,label:s,validation:r}=t;return n(u,{name:e,control:i,rules:r?f(r):void 0,render:({field:o})=>n(p,{...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
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{TimestampFieldComponent as p}from"../../form/fields";import{convertValidationRules as c}from"../types";function x(l){const{control:i,errors:n,fieldConfig:a,t:m}=l,{name:e,label:s,validation:r}=a;return t(d,{name:e,control:i,rules:r?c(r):void 0,render:({field:o})=>t(p,{...o,label:m(s),value:o.value??null,onChange:u=>o.onChange(u),error:!!n[e],helperText:n[e]?.message,required:r?.required})})}export{x as ControlledTimestampField};
@@ -1,4 +1,5 @@
1
1
  export { ControlledAddressField } from './ControlledAddressField';
2
+ export { ControlledFieldArrayField, type SubFieldDef, } from './ControlledFieldArrayField';
2
3
  export { ControlledDateField } from './ControlledDateField';
3
4
  export { ControlledGeoPointField } from './ControlledGeoPointField';
4
5
  export { ControlledMapField } from './ControlledMapField';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/controlled/complex/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,yBAAyB,EACzB,KAAK,WAAW,GACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1 +1 @@
1
- import{ControlledAddressField as o}from"./ControlledAddressField";import{ControlledDateField as l}from"./ControlledDateField";import{ControlledGeoPointField as e}from"./ControlledGeoPointField";import{ControlledMapField as t}from"./ControlledMapField";import{ControlledMultiInputField as d}from"./ControlledMultiInputField";import{ControlledRichTextField as r}from"./ControlledRichTextField";import{ControlledTimestampField as i}from"./ControlledTimestampField";export{o as ControlledAddressField,l as ControlledDateField,e as ControlledGeoPointField,t as ControlledMapField,d as ControlledMultiInputField,r as ControlledRichTextField,i as ControlledTimestampField};
1
+ import{ControlledAddressField as r}from"./ControlledAddressField";import{ControlledFieldArrayField as t}from"./ControlledFieldArrayField";import{ControlledDateField as i}from"./ControlledDateField";import{ControlledGeoPointField as m}from"./ControlledGeoPointField";import{ControlledMapField as x}from"./ControlledMapField";import{ControlledMultiInputField as f}from"./ControlledMultiInputField";import{ControlledRichTextField as a}from"./ControlledRichTextField";import{ControlledTimestampField as u}from"./ControlledTimestampField";export{r as ControlledAddressField,i as ControlledDateField,t as ControlledFieldArrayField,m as ControlledGeoPointField,x as ControlledMapField,f as ControlledMultiInputField,a as ControlledRichTextField,u as ControlledTimestampField};
@@ -1 +1 @@
1
- "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as p}from"react-hook-form";import{DocumentFieldComponent as c}from"../../form/fields";import{convertValidationRules as f}from"../types";function g(i){const{control:m,errors:r,fieldConfig:l,t:s}=i,{name:e,label:u,validation:o}=l,n=l.options||{};return a(p,{name:e,control:m,rules:o?f(o):void 0,render:({field:t})=>a(c,{name:e,label:s(u),value:t.value??null,onChange:d=>t.onChange(d),error:!!r[e],helperText:r[e]?.message,required:o?.required,multiple:!1,maxFiles:1,maxSize:n.maxSize,storagePath:n.storagePath})})}export{g as ControlledDocumentField};
1
+ "use client";import{jsx as a}from"react/jsx-runtime";import{Controller as d}from"react-hook-form";import{DocumentFieldComponent as p}from"../../form/fields";import{convertValidationRules as f}from"../types";function v(i){const{control:m,errors:r,fieldConfig:n,t:s}=i,{name:e,label:u,validation:o}=n,t=n.options||{};return a(d,{name:e,control:m,rules:o?f(o):void 0,render:({field:l})=>a(p,{name:e,label:s(u),value:l.value??null,onChange:c=>l.onChange(c),error:!!r[e],helperText:r[e]?.message,required:o?.required,multiple:!1,maxFiles:1,maxSize:t.maxSize,storagePath:t.storagePath})})}export{v as ControlledDocumentField};