@donotdev/crud 0.0.4 → 0.0.5

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 (150) hide show
  1. package/dist/CrudService.d.ts +7 -3
  2. package/dist/CrudService.d.ts.map +1 -1
  3. package/dist/CrudService.js +1 -1
  4. package/dist/CrudStore.d.ts +6 -1
  5. package/dist/CrudStore.d.ts.map +1 -1
  6. package/dist/CrudStore.js +1 -1
  7. package/dist/FieldRegistry.d.ts +126 -0
  8. package/dist/FieldRegistry.d.ts.map +1 -0
  9. package/dist/FieldRegistry.js +1 -0
  10. package/dist/adapters/FirestoreAdapter.d.ts.map +1 -1
  11. package/dist/adapters/FirestoreAdapter.js +1 -1
  12. package/dist/builtinFieldTypes.d.ts +5 -0
  13. package/dist/builtinFieldTypes.d.ts.map +1 -0
  14. package/dist/builtinFieldTypes.js +1 -0
  15. package/dist/components/ControlledFields.d.ts +42 -24
  16. package/dist/components/ControlledFields.d.ts.map +1 -1
  17. package/dist/components/ControlledFields.js +1 -1
  18. package/dist/components/DisplayFieldRenderer.d.ts +36 -0
  19. package/dist/components/DisplayFieldRenderer.d.ts.map +1 -0
  20. package/dist/components/DisplayFieldRenderer.js +1 -0
  21. package/dist/components/EntityFormRenderer.d.ts +36 -8
  22. package/dist/components/EntityFormRenderer.d.ts.map +1 -1
  23. package/dist/components/EntityFormRenderer.js +5 -1
  24. package/dist/components/FormFieldRenderer.d.ts +3 -16
  25. package/dist/components/FormFieldRenderer.d.ts.map +1 -1
  26. package/dist/components/FormFieldRenderer.js +1 -1
  27. package/dist/components/form/fields/AddressFieldComponent.d.ts +3 -1
  28. package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
  29. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  30. package/dist/components/form/fields/CheckboxFieldComponent.d.ts +2 -0
  31. package/dist/components/form/fields/CheckboxFieldComponent.d.ts.map +1 -1
  32. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  33. package/dist/components/form/fields/ComboboxComponent.d.ts +43 -0
  34. package/dist/components/form/fields/ComboboxComponent.d.ts.map +1 -0
  35. package/dist/components/form/fields/ComboboxComponent.js +1 -0
  36. package/dist/components/form/fields/CurrencyFieldComponent.d.ts +41 -0
  37. package/dist/components/form/fields/CurrencyFieldComponent.d.ts.map +1 -0
  38. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -0
  39. package/dist/components/form/fields/DateFieldComponent.d.ts +2 -0
  40. package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
  41. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  42. package/dist/components/form/fields/DropdownComponent.d.ts.map +1 -1
  43. package/dist/components/form/fields/DropdownComponent.js +1 -1
  44. package/dist/components/form/fields/FileFieldComponent.d.ts +2 -0
  45. package/dist/components/form/fields/FileFieldComponent.d.ts.map +1 -1
  46. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  47. package/dist/components/form/fields/GeoPointFieldComponent.d.ts +2 -0
  48. package/dist/components/form/fields/GeoPointFieldComponent.d.ts.map +1 -1
  49. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  50. package/dist/components/form/fields/ImageFieldComponent.d.ts +32 -17
  51. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  52. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  53. package/dist/components/form/fields/MapFieldComponent.d.ts +2 -0
  54. package/dist/components/form/fields/MapFieldComponent.d.ts.map +1 -1
  55. package/dist/components/form/fields/MapFieldComponent.js +1 -1
  56. package/dist/components/form/fields/MultiDropdownComponent.d.ts +2 -2
  57. package/dist/components/form/fields/MultiDropdownComponent.d.ts.map +1 -1
  58. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  59. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts +2 -0
  60. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts.map +1 -1
  61. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  62. package/dist/components/form/fields/NumberFieldComponent.d.ts.map +1 -1
  63. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  64. package/dist/components/form/fields/PasswordFieldComponent.d.ts.map +1 -1
  65. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  66. package/dist/components/form/fields/PhoneNumberComponent.d.ts +31 -17
  67. package/dist/components/form/fields/PhoneNumberComponent.d.ts.map +1 -1
  68. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  69. package/dist/components/form/fields/RadioFieldComponent.d.ts.map +1 -1
  70. package/dist/components/form/fields/RadioFieldComponent.js +1 -1
  71. package/dist/components/form/fields/RangeFieldComponent.d.ts.map +1 -1
  72. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  73. package/dist/components/form/fields/ReferenceFieldComponent.d.ts +7 -2
  74. package/dist/components/form/fields/ReferenceFieldComponent.d.ts.map +1 -1
  75. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  76. package/dist/components/form/fields/SwitchFieldComponent.d.ts +28 -0
  77. package/dist/components/form/fields/SwitchFieldComponent.d.ts.map +1 -0
  78. package/dist/components/form/fields/SwitchFieldComponent.js +1 -0
  79. package/dist/components/form/fields/TextAreaComponent.d.ts.map +1 -1
  80. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  81. package/dist/components/form/fields/TextFieldComponent.d.ts.map +1 -1
  82. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  83. package/dist/components/form/fields/TimestampFieldComponent.d.ts +2 -0
  84. package/dist/components/form/fields/TimestampFieldComponent.d.ts.map +1 -1
  85. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  86. package/dist/components/form/fields/index.d.ts +7 -1
  87. package/dist/components/form/fields/index.d.ts.map +1 -1
  88. package/dist/components/form/fields/index.js +1 -1
  89. package/dist/components/form/internal/ImageViewerDialog.d.ts +25 -0
  90. package/dist/components/form/internal/ImageViewerDialog.d.ts.map +1 -0
  91. package/dist/components/form/internal/ImageViewerDialog.js +1 -0
  92. package/dist/components/index.d.ts +2 -0
  93. package/dist/components/index.d.ts.map +1 -1
  94. package/dist/components/index.js +1 -1
  95. package/dist/context/FormUploadContext.d.ts +36 -0
  96. package/dist/context/FormUploadContext.d.ts.map +1 -0
  97. package/dist/context/FormUploadContext.js +1 -0
  98. package/dist/context/index.d.ts +2 -0
  99. package/dist/context/index.d.ts.map +1 -0
  100. package/dist/context/index.js +1 -0
  101. package/dist/forms/hooks/index.d.ts +11 -0
  102. package/dist/forms/hooks/index.d.ts.map +1 -0
  103. package/dist/forms/hooks/index.js +1 -0
  104. package/dist/forms/hooks/useEntityField.d.ts +67 -0
  105. package/dist/forms/hooks/useEntityField.d.ts.map +1 -0
  106. package/dist/forms/hooks/useEntityField.js +1 -0
  107. package/dist/forms/hooks/useEntityForm.d.ts +89 -0
  108. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -0
  109. package/dist/forms/hooks/useEntityForm.js +1 -0
  110. package/dist/forms/index.d.ts +37 -0
  111. package/dist/forms/index.d.ts.map +1 -0
  112. package/dist/forms/index.js +1 -0
  113. package/dist/forms/types.d.ts +185 -0
  114. package/dist/forms/types.d.ts.map +1 -0
  115. package/dist/forms/types.js +0 -0
  116. package/dist/forms/utils/createEntitySchema.d.ts +53 -0
  117. package/dist/forms/utils/createEntitySchema.d.ts.map +1 -0
  118. package/dist/forms/utils/createEntitySchema.js +1 -0
  119. package/dist/forms/utils/getFieldsForOperation.d.ts +87 -0
  120. package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -0
  121. package/dist/forms/utils/getFieldsForOperation.js +1 -0
  122. package/dist/forms/utils/index.d.ts +14 -0
  123. package/dist/forms/utils/index.d.ts.map +1 -0
  124. package/dist/forms/utils/index.js +1 -0
  125. package/dist/forms/utils/isFieldEditable.d.ts +43 -0
  126. package/dist/forms/utils/isFieldEditable.d.ts.map +1 -0
  127. package/dist/forms/utils/isFieldEditable.js +1 -0
  128. package/dist/forms/utils/normalizeToFieldConfig.d.ts +47 -0
  129. package/dist/forms/utils/normalizeToFieldConfig.d.ts.map +1 -0
  130. package/dist/forms/utils/normalizeToFieldConfig.js +1 -0
  131. package/dist/forms/utils/validateEntity.d.ts +77 -0
  132. package/dist/forms/utils/validateEntity.d.ts.map +1 -0
  133. package/dist/forms/utils/validateEntity.js +1 -0
  134. package/dist/index.d.ts +4 -1
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +1 -1
  137. package/dist/tsconfig.tsbuildinfo +1 -1
  138. package/dist/useCrud.d.ts +67 -15
  139. package/dist/useCrud.d.ts.map +1 -1
  140. package/dist/useCrud.js +1 -1
  141. package/dist/utils/imageProcessing.d.ts +49 -0
  142. package/dist/utils/imageProcessing.d.ts.map +1 -0
  143. package/dist/utils/imageProcessing.js +1 -0
  144. package/dist/utils/imageStorage.d.ts +35 -0
  145. package/dist/utils/imageStorage.d.ts.map +1 -0
  146. package/dist/utils/imageStorage.js +1 -0
  147. package/dist/utils/imageUtils.d.ts +86 -0
  148. package/dist/utils/imageUtils.d.ts.map +1 -0
  149. package/dist/utils/imageUtils.js +1 -0
  150. package/package.json +10 -7
@@ -1,5 +1,9 @@
1
1
  import type { QueryOptions } from './adapters/FirestoreAdapter';
2
- import type { BackendType } from './CrudStore';
2
+ import type { BackendType, CrudState, CrudActions } from './CrudStore';
3
+ /** Store API type for CrudService - typed instead of any */
4
+ type CrudStoreApi = {
5
+ getState: () => CrudState & CrudActions;
6
+ };
3
7
  export type { QueryOptions };
4
8
  import type { dndevSchema } from '@donotdev/core';
5
9
  export interface CrudServiceInterface {
@@ -12,7 +16,7 @@ export interface CrudServiceInterface {
12
16
  query<T>(collection: string, options: QueryOptions, schema: dndevSchema<T>): Promise<T[]>;
13
17
  subscribe<T>(collection: string, id: string, callback: (data: T | null, error?: Error) => void, schema: dndevSchema<T>): () => void;
14
18
  subscribeToCollection<T>(collection: string, options: QueryOptions, callback: (data: T[], error?: Error) => void, schema: dndevSchema<T>): () => void;
15
- setStore(store: any): void;
19
+ setStore(store: CrudStoreApi): void;
16
20
  }
17
21
  /**
18
22
  * Complete CRUD orchestrator
@@ -25,7 +29,7 @@ declare class CrudService implements CrudServiceInterface {
25
29
  private adapter;
26
30
  private backend;
27
31
  private store;
28
- setStore(store: any): void;
32
+ setStore(store: CrudStoreApi): void;
29
33
  initialize(backend: BackendType): Promise<void>;
30
34
  get<T>(collection: string, id: string, schema: dndevSchema<T>): Promise<T | null>;
31
35
  set<T>(collection: string, id: string, data: T, schema: dndevSchema<T>): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"CrudService.d.ts","sourceRoot":"","sources":["../src/CrudService.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,GAAG,CAAC,CAAC,EACH,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACrB,GAAG,CAAC,CAAC,EACH,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EA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ACV,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,IAAI,CAAC;IAwCV,MAAM,CAAC,CAAC,EACZ,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GACf,OAAO,CAAC,IAAI,CAAC;IAsDV,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCrD,GAAG,CAAC,CAAC,EACT,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,MAAM,CAAC;IAyCZ,KAAK,CAAC,CAAC,EACX,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,EAAE,CAAC;IAqDf,SAAS,CAAC,CAAC,EACT,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EACjD,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI;IA8Bb,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;CAuCd;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mBAE1B,CAAC"}
@@ -1 +1 @@
1
- import{toast as o}from"@donotdev/components";import{createSingleton as n,handleError as h}from"@donotdev/core";import{FirestoreAdapter as u}from"./adapters/FirestoreAdapter";import{FunctionsAdapter as g}from"./adapters/FunctionsAdapter";class p{adapter=null;backend=null;store=null;setStore(t){this.store=t}async initialize(t){if(!(this.backend===t&&this.adapter)){if(this.backend=t,t==="functions")this.adapter=new g;else if(t==="firestore")this.adapter=new u;else throw new Error(`Unknown backend: ${t}`);this.store&&(this.store.getState().setBackend(t),this.store.getState().setCrudService(this))}}async get(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.get(t,s,i);return this.store&&e&&this.store.getState().setData(t,s,e),e}catch(e){const r=h(e,{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 set(t,s,i,e){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.set(t,s,i,e),this.store&&this.store.getState().setData(t,s,i),o("success",`${t} saved successfully`)}catch(r){const a=h(r,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));let e=null;this.store&&(e=this.store.getState().getData(t,s)),this.store&&e&&this.store.getState().setData(t,s,{...e,...i});try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,s,i),o("success",`${t} updated successfully`)}catch(r){this.store&&e&&this.store.getState().setData(t,s,e);const a=h(r,{userMessage:`Failed to update ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async delete(t,s){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.delete(t,s),this.store&&this.store.getState().removeData(t,s),o("success",`${t} deleted successfully`)}catch(i){const e=h(i,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,e),e}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.add(t,s,i);return this.store&&e&&this.store.getState().setData(t,e,{...s,id:e}),o("success",`${t} created successfully`),e}catch(e){const r=h(e,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}async query(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.query(t,s,i);if(this.store)for(const r of e){const a=r.id;a&&this.store.getState().setData(t,a,r)}return e}catch(e){const r=h(e,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribe(t,s,(r,a)=>{r&&this.store&&this.store.getState().setData(t,s,r),i(r,a)},e):(i(null,new Error("Adapter not initialized")),()=>{})}catch(r){return i(null,h(r)),()=>{}}}subscribeToCollection(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribeToCollection(t,s,(r,a)=>{if(r&&this.store)for(const d of r){const f=d.id;f&&this.store.getState().setData(t,f,d)}i(r,a)},e):(i([],new Error("Adapter not initialized")),()=>{})}catch(r){return i([],h(r)),()=>{}}}}const A=n(()=>new p);export{A as getCrudService};
1
+ import{toast as d}from"@donotdev/components";import{createSingleton as u,handleError as h}from"@donotdev/core";import{FirestoreAdapter as g}from"./adapters/FirestoreAdapter";import{FunctionsAdapter as p}from"./adapters/FunctionsAdapter";class w{adapter=null;backend=null;store=null;setStore(t){this.store=t}async initialize(t){if(!(this.backend===t&&this.adapter)){if(this.backend=t,t==="functions")this.adapter=new p;else if(t==="firestore")this.adapter=new g;else throw new Error(`Unknown backend: ${t}`);this.store&&(this.store.getState().setBackend(t),this.store.getState().setCrudService(this))}}async get(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.get(t,s,i);return this.store&&e&&this.store.getState().setData(t,s,e),e}catch(e){const r=h(e,{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 set(t,s,i,e){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.set(t,s,i,e),this.store&&this.store.getState().setData(t,s,i),d("success",`${t} saved successfully`)}catch(r){const a=h(r,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));let e=null;this.store&&(e=this.store.getState().getData(t,s)),this.store&&e&&this.store.getState().setData(t,s,{...e,...i});try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,s,i),d("success",`${t} updated successfully`)}catch(r){this.store&&e&&this.store.getState().setData(t,s,e);const a=h(r,{userMessage:`Failed to update ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async delete(t,s){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.delete(t,s),this.store&&this.store.getState().removeData(t,s),d("success",`${t} deleted successfully`)}catch(i){const e=h(i,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,e),e}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.add(t,s,i);return this.store&&e&&this.store.getState().setData(t,e,{...s,id:e}),d("success",`${t} created successfully`),e}catch(e){const r=h(e,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}async query(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.query(t,s,i);if(this.store){const r=[];for(const a of e){const o=a;o.id&&r.push({id:o.id,data:a})}r.length>0&&this.store.getState().setDataBatch(t,r)}return e}catch(e){const r=h(e,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribe(t,s,(r,a)=>{r&&this.store&&this.store.getState().setData(t,s,r),i(r,a)},e):(i(null,new Error("Adapter not initialized")),()=>{})}catch(r){return i(null,h(r)),()=>{}}}subscribeToCollection(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribeToCollection(t,s,(r,a)=>{if(r&&this.store){const o=[];for(const f of r){const n=f;n.id&&o.push({id:n.id,data:f})}o.length>0&&this.store.getState().setDataBatch(t,o)}i(r,a)},e):(i([],new Error("Adapter not initialized")),()=>{})}catch(r){return i([],h(r)),()=>{}}}}const A=u(()=>new w);export{A as getCrudService};
@@ -37,6 +37,11 @@ export interface CrudActions {
37
37
  setLoading: (collection: string, loading: boolean) => void;
38
38
  setError: (collection: string, error: Error | null) => void;
39
39
  setData: (collection: string, id: string, data: unknown) => void;
40
+ /** Batch update multiple documents in a single state update (performance) */
41
+ setDataBatch: (collection: string, items: Array<{
42
+ id: string;
43
+ data: unknown;
44
+ }>) => void;
40
45
  removeData: (collection: string, id: string) => void;
41
46
  clearCollection: (collection: string) => void;
42
47
  clearError: (collection: string) => void;
@@ -51,5 +56,5 @@ export interface CrudActions {
51
56
  * @since 0.0.1
52
57
  * @author AMBROISE PARK Consulting
53
58
  */
54
- export declare const useCrudStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CrudState & CrudActions & import("@donotdev/core").DoNotDevStore>>;
59
+ export declare const useCrudStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CrudState & CrudActions & import("@donotdev/stores").DoNotDevStore>>;
55
60
  //# sourceMappingURL=CrudStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IAExB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAGzC,WAAW,EAAE,MAAM,CACjB,MAAM,EACN;QACE,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;KACrB,CACF,CAAC;CACH;AAQ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M,KAAK,KAAK,GAAG,IAAI,CAAC;IAC/C,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,iIA6LvB,CAAC"}
package/dist/CrudStore.js CHANGED
@@ -1 +1 @@
1
- import{createDoNotDevStore as i}from"@donotdev/core";const d={backend:null,crudService:null,collections:{}},u=i({name:"crud-store",createStore:(r,n)=>({...d,setCrudService:o=>{r({crudService:o})},setBackend:o=>{r({backend:o})},setLoading:(o,l)=>{r(e=>{const t=e.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...e.collections,[o]:{...t,loading:l}}}})},setError:(o,l)=>{r(e=>{const t=e.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...e.collections,[o]:{...t,error:l,loading:!1}}}})},setData:(o,l,e)=>{r(t=>{const c=t.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...t.collections,[o]:{...c,data:{...c.data,[l]:e},lastUpdated:Date.now(),error:null}}}})},removeData:(o,l)=>{r(e=>{const t=e.collections[o];if(!t)return e;const{[l]:c,...a}=t.data;return{collections:{...e.collections,[o]:{...t,data:a,lastUpdated:Date.now()}}}})},clearCollection:o=>{r(l=>{const{[o]:e,...t}=l.collections;return{collections:t}})},clearError:o=>{r(l=>{const e=l.collections[o];return e?{collections:{...l.collections,[o]:{...e,error:null}}}:l})},getLoading:o=>n().collections[o]?.loading||!1,getError:o=>n().collections[o]?.error||null,getData:(o,l)=>n().collections[o]?.data[l]||null})});export{u as useCrudStore};
1
+ import{createDoNotDevStore as d}from"@donotdev/core";const s={backend:null,crudService:null,collections:{}},S=d({name:"crud-store",createStore:(r,a)=>({...s,setCrudService:o=>{r({crudService:o})},setBackend:o=>{r({backend:o})},setLoading:(o,l)=>{r(t=>{const e=t.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...t.collections,[o]:{...e,loading:l}}}})},setError:(o,l)=>{r(t=>{const e=t.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...t.collections,[o]:{...e,error:l,loading:!1}}}})},setData:(o,l,t)=>{r(e=>{const n=e.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...e.collections,[o]:{...n,data:{...n.data,[l]:t},lastUpdated:Date.now(),error:null}}}})},setDataBatch:(o,l)=>{l.length!==0&&r(t=>{const e=t.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0},n={...e.data};for(const{id:c,data:i}of l)n[c]=i;return{collections:{...t.collections,[o]:{...e,data:n,lastUpdated:Date.now(),error:null}}}})},removeData:(o,l)=>{r(t=>{const e=t.collections[o];if(!e)return t;const{[l]:n,...c}=e.data;return{collections:{...t.collections,[o]:{...e,data:c,lastUpdated:Date.now()}}}})},clearCollection:o=>{r(l=>{const{[o]:t,...e}=l.collections;return{collections:e}})},clearError:o=>{r(l=>{const t=l.collections[o];return t?{collections:{...l.collections,[o]:{...t,error:null}}}:l})},getLoading:o=>a().collections[o]?.loading||!1,getError:o=>a().collections[o]?.error||null,getData:(o,l)=>a().collections[o]?.data[l]||null})});export{S as useCrudStore};
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @fileoverview Field Type Registry
3
+ * @description UI component registry for field types. Schemas handled by @donotdev/core.
4
+ *
5
+ * @version 0.0.1
6
+ * @since 0.0.1
7
+ * @author AMBROISE PARK Consulting
8
+ */
9
+ import type { ComponentType } from 'react';
10
+ import type { Control, ControllerRenderProps, FieldErrors, FieldValues, Path } from 'react-hook-form';
11
+ import type { BaseSchema, BaseIssue } from 'valibot';
12
+ import type { FieldConfig, FieldType, EntityField, ValueTypeForField } from '@donotdev/core';
13
+ /**
14
+ * Props for controlled field components (react-hook-form)
15
+ */
16
+ export interface ControlledFieldProps<T extends FieldValues = FieldValues, FT extends FieldType = FieldType> {
17
+ control: Control<T>;
18
+ errors: FieldErrors<T>;
19
+ fieldConfig: FieldConfig<FT>;
20
+ t: (key: string, options?: Record<string, unknown>) => string;
21
+ onChange?: (value: ValueTypeForField<FT>) => void;
22
+ placeholder?: string;
23
+ /** Field object from react-hook-form (provided by framework, no need to use useController) */
24
+ field?: ControllerRenderProps<T, Path<T>>;
25
+ /** Field state from react-hook-form (provided by framework, no need to use useController) */
26
+ fieldState?: {
27
+ error?: {
28
+ message?: string;
29
+ };
30
+ isDirty: boolean;
31
+ isTouched: boolean;
32
+ invalid: boolean;
33
+ };
34
+ }
35
+ /**
36
+ * Props for uncontrolled field components
37
+ */
38
+ export interface UncontrolledFieldProps<FT extends FieldType = FieldType> {
39
+ name: string;
40
+ label?: string;
41
+ value: ValueTypeForField<FT>;
42
+ onChange: (value: ValueTypeForField<FT>) => void;
43
+ error?: string;
44
+ helperText?: string;
45
+ t: (key: string) => string;
46
+ config: FieldConfig<FT>;
47
+ }
48
+ /**
49
+ * Schema generator function type
50
+ */
51
+ export type SchemaGenerator = (field: EntityField<FieldType>) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
52
+ /**
53
+ * Full registration for custom field types
54
+ */
55
+ export interface FieldTypeRegistration<FT extends string = string> {
56
+ type: FT;
57
+ controlledComponent: ComponentType<ControlledFieldProps<any, any>>;
58
+ uncontrolledComponent?: ComponentType<UncontrolledFieldProps>;
59
+ schemaGenerator: SchemaGenerator;
60
+ }
61
+ /**
62
+ * Field Registry - UI components only
63
+ * Schemas are handled by @donotdev/core
64
+ */
65
+ declare class FieldRegistry {
66
+ private readonly components;
67
+ /**
68
+ * Register UI components for a field type (built-in types)
69
+ * Does NOT register schema - use for types where schema is in @donotdev/core
70
+ */
71
+ registerComponent(type: string, controlled: ComponentType<ControlledFieldProps<any, any>>, uncontrolled?: ComponentType<UncontrolledFieldProps>): void;
72
+ /**
73
+ * Register a custom field type with UI components AND schema
74
+ * Use this for custom types not in @donotdev/core
75
+ */
76
+ register<FT extends string>(registration: FieldTypeRegistration<FT>): void;
77
+ /**
78
+ * Get controlled component
79
+ */
80
+ getControlledComponent(type: string): ComponentType<ControlledFieldProps> | undefined;
81
+ /**
82
+ * Get uncontrolled component
83
+ */
84
+ getUncontrolledComponent(type: string): ComponentType<UncontrolledFieldProps> | undefined;
85
+ /**
86
+ * Check if type is registered
87
+ */
88
+ has(type: string): boolean;
89
+ /**
90
+ * Get all registered types
91
+ */
92
+ getRegisteredTypes(): string[];
93
+ /**
94
+ * Clear (testing)
95
+ */
96
+ clear(): void;
97
+ }
98
+ /**
99
+ * Get the field registry singleton
100
+ */
101
+ export declare function getFieldRegistry(): FieldRegistry;
102
+ /**
103
+ * Register a custom field type
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import * as v from 'valibot';
108
+ * import { registerFieldType } from '@donotdev/crud';
109
+ *
110
+ * registerFieldType({
111
+ * type: 'ratp',
112
+ * controlledComponent: ControlledRatpField,
113
+ * schemaGenerator: (field) => {
114
+ * const schema = v.object({ line: v.string(), station: v.string() });
115
+ * return field.validation?.required ? schema : v.optional(schema);
116
+ * },
117
+ * });
118
+ * ```
119
+ */
120
+ export declare function registerFieldType<FT extends string>(registration: FieldTypeRegistration<FT>): void;
121
+ /**
122
+ * Check if a field type is registered
123
+ */
124
+ export declare function isFieldTypeRegistered(type: string): boolean;
125
+ export {};
126
+ //# sourceMappingURL=FieldRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldRegistry.d.ts","sourceRoot":"","sources":["../src/FieldRegistry.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,iBAAiB,EA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AGd;AAKD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,MAAM,EACjD,YAAY,EAAE,qBAAqB,CAAC,EAAE,CAAC,GACtC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D"}
@@ -0,0 +1 @@
1
+ "use client";import{registerSchemaGenerator as l,hasCustomSchemaGenerator as p}from"@donotdev/core";class m{components=new Map;registerComponent(e,t,o){this.components.set(e,{controlled:t,uncontrolled:o})}register(e){const{type:t,controlledComponent:o,uncontrolledComponent:i,schemaGenerator:c}=e;this.components.set(t,{controlled:o,uncontrolled:i}),p(t)||l(t,c)}getControlledComponent(e){return this.components.get(e)?.controlled}getUncontrolledComponent(e){return this.components.get(e)?.uncontrolled}has(e){return this.components.has(e)}getRegisteredTypes(){return Array.from(this.components.keys())}clear(){this.components.clear()}}let r=null;function s(){return r||(r=new m),r}function g(n){s().register(n)}function u(n){return s().has(n)}export{s as getFieldRegistry,u as isFieldTypeRegistered,g as registerFieldType};
@@ -1 +1 @@
1
- {"version":3,"file":"FirestoreAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/FirestoreAdapter.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAoBL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAQ5B;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,IAAI,GACJ,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,GAAG,GACH,IAAI,GACJ,gBAAgB,GAChB,IAAI,GACJ,QAAQ,CAAC;AAEb;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,C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AAC,GACrB,OAAO,CAAC,MAAM,CAAC;IAcZ,KAAK,CAAC,CAAC,EACX,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,EAAE,CAAC;IAoEf,SAAS,CAAC,CAAC,EACT,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EACjC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,WAAW;IA2Bd,qBAAqB,CAAC,CAAC,EACrB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,8BAA8B,CAAC,CAAC,CAAC,EAC3C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,WAAW;CAgDf"}
@@ -1 +1 @@
1
- import*as d from"valibot";import{handleError as F}from"@donotdev/core";import{getFirestore as D,doc as u,getDoc as x,getDocs as q,setDoc as z,updateDoc as E,deleteDoc as v,addDoc as B,collection as C,query as y,where as m,orderBy as g,limit as w,onSnapshot as A}from"@donotdev/firebase";import{transformFirestoreData as h,prepareForFirestore as p}from"@donotdev/firebase";class P{firestore;ensureFirestore(){if(this.firestore)return!0;try{return this.firestore=D(),!0}catch{return!1}}getCollectionRef(o){return!this.ensureFirestore()||!this.firestore?null:C(this.firestore,o)}async get(o,e,r){if(!this.ensureFirestore()||!this.firestore)return null;try{const s=u(this.firestore,o,e),t=await x(s);if(!t.exists())return null;let i=t.data();return i=h(i),{...d.parse(r,i),id:e}}catch{return null}}async set(o,e,r,s){if(!(!this.ensureFirestore()||!this.firestore))try{d.parse(s,r);const t=u(this.firestore,o,e),i=p(r);await z(t,i)}catch(t){throw t}}async update(o,e,r){if(!(!this.ensureFirestore()||!this.firestore))try{const s=u(this.firestore,o,e),t=p(r);await E(s,t)}catch(s){throw s}}async delete(o,e){if(!(!this.ensureFirestore()||!this.firestore))try{const r=u(this.firestore,o,e);await v(r)}catch(r){throw r}}async add(o,e,r){if(!this.ensureFirestore())return"";try{d.parse(r,e);const s=this.getCollectionRef(o);if(!s)return"";const t=p(e);return(await B(s,t)).id}catch(s){throw s}}async query(o,e,r){if(!this.ensureFirestore())return[];const s=this.getCollectionRef(o);if(!s)return[];try{const t=[];if(e.where)for(const n of e.where)t.push(m(n.field,n.operator,n.value));if(e.orderBy)for(const n of e.orderBy)t.push(g(n.field,n.direction||"asc"));e.limit&&t.push(w(e.limit));const i=y(s,...t),c=await q(i),a=[];return c.forEach(n=>{try{let l=n.data();if(!l)return;l=h(l);const f=d.parse(r,l);a.push({...f,id:n.id})}catch(l){F(l,{context:{operation:"FirestoreAdapter.query.parse",docId:n.id,collection:o}})}}),a}catch(t){throw F(t,{context:{operation:"FirestoreAdapter.query",collection:o,options:e}}),t}}subscribe(o,e,r,s){if(!this.ensureFirestore()||!this.firestore)return()=>{};const t=u(this.firestore,o,e);return A(t,i=>{try{if(!i.exists()){r(null);return}let c=i.data();c=h(c);const a=d.parse(s,c);r({...a,id:e})}catch(c){r(null,c)}},i=>{r(null,i)})}subscribeToCollection(o,e,r,s){if(!this.ensureFirestore())return()=>{};const t=this.getCollectionRef(o);if(!t)return()=>{};try{const i=[];if(e.where)for(const a of e.where)i.push(m(a.field,a.operator,a.value));if(e.orderBy)for(const a of e.orderBy)i.push(g(a.field,a.direction||"asc"));e.limit&&i.push(w(e.limit));const c=y(t,...i);return A(c,a=>{try{const n=[];a.forEach(l=>{let f=l.data();f=h(f);const R=d.parse(s,f);n.push({...R,id:l.id})}),r(n)}catch(n){r([],n)}},a=>{r([],a)})}catch(i){return r([],i),()=>{}}}}export{P as FirestoreAdapter};
1
+ import*as u from"valibot";import{handleError as p}from"@donotdev/core";import{getFirestore as A,doc as l,getDoc as q,getDocs as x,setDoc as v,updateDoc as B,deleteDoc as C,addDoc as z,collection as E,query as F,where as w,orderBy as g,limit as R,onSnapshot as m}from"@donotdev/firebase";import{transformFirestoreData as d,prepareForFirestore as y}from"@donotdev/firebase";class G{firestore;ensureFirestore(){if(this.firestore)return!0;try{return this.firestore=A(),!0}catch{return!1}}getCollectionRef(s){return!this.ensureFirestore()||!this.firestore?null:E(this.firestore,s)}async get(s,r,e){if(!this.ensureFirestore()||!this.firestore)return null;try{const o=l(this.firestore,s,r),t=await q(o);if(!t.exists())return null;let i=t.data();return i=d(i),{...u.parse(e,i),id:r}}catch(o){return p(o,{context:{operation:"FirestoreAdapter.get",collection:s,docId:r},severity:"warning"}),null}}async set(s,r,e,o){if(!(!this.ensureFirestore()||!this.firestore))try{u.parse(o,e);const t=l(this.firestore,s,r),i=y(e);await v(t,i)}catch(t){throw t}}async update(s,r,e){if(!(!this.ensureFirestore()||!this.firestore))try{const o=l(this.firestore,s,r),t=y(e);await B(o,t)}catch(o){throw o}}async delete(s,r){if(!(!this.ensureFirestore()||!this.firestore))try{const e=l(this.firestore,s,r);await C(e)}catch(e){throw e}}async add(s,r,e){if(!this.ensureFirestore())return"";try{u.parse(e,r);const o=this.getCollectionRef(s);if(!o)return"";const t=y(r);return(await z(o,t)).id}catch(o){throw o}}async query(s,r,e){if(!this.ensureFirestore())return[];const o=this.getCollectionRef(s);if(!o)return[];try{const t=[];if(r.where)for(const a of r.where)t.push(w(a.field,a.operator,a.value));if(r.orderBy)for(const a of r.orderBy)t.push(g(a.field,a.direction||"asc"));r.limit&&t.push(R(r.limit));const i=F(o,...t),c=await x(i),n=[];return c.forEach(a=>{try{let f=a.data();if(!f)return;f=d(f);const h=u.parse(e,f);n.push({...h,id:a.id})}catch(f){p(f,{context:{operation:"FirestoreAdapter.query.parse",docId:a.id,collection:s},showNotification:!1})}}),n}catch(t){throw p(t,{context:{operation:"FirestoreAdapter.query",collection:s,options:r}}),t}}subscribe(s,r,e,o){if(!this.ensureFirestore()||!this.firestore)return()=>{};const t=l(this.firestore,s,r);return m(t,i=>{try{if(!i.exists()){e(null);return}let c=i.data();c=d(c);const n=u.parse(o,c);e({...n,id:r})}catch(c){e(null,c)}},i=>{e(null,i)})}subscribeToCollection(s,r,e,o){if(!this.ensureFirestore())return()=>{};const t=this.getCollectionRef(s);if(!t)return()=>{};try{const i=[];if(r.where)for(const n of r.where)i.push(w(n.field,n.operator,n.value));if(r.orderBy)for(const n of r.orderBy)i.push(g(n.field,n.direction||"asc"));r.limit&&i.push(R(r.limit));const c=F(t,...i);return m(c,n=>{try{const a=[];n.forEach(f=>{let h=f.data();h=d(h);const D=u.parse(o,h);a.push({...D,id:f.id})}),e(a)}catch(a){e([],a)}},n=>{e([],n)})}catch(i){return e([],i),()=>{}}}}export{G as FirestoreAdapter};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Register built-in field types (UI components only)
3
+ */
4
+ export declare function registerBuiltinFieldTypes(): void;
5
+ //# sourceMappingURL=builtinFieldTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtinFieldTypes.d.ts","sourceRoot":"","sources":["../src/builtinFieldTypes.tsx"],"names":[],"mappings":"AAmJA;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAiGhD"}
@@ -0,0 +1 @@
1
+ "use client";import{jsx as s}from"react/jsx-runtime";import{getFieldRegistry as u}from"./FieldRegistry";import{ControlledCheckboxField as g,ControlledComboboxField as F,ControlledDateField as a,ControlledDropdownField as f,ControlledFileField as b,ControlledGeoPointField as h,ControlledImageField as x,ControlledMapField as v,ControlledMultiDropdownField as T,ControlledMultiInputField as w,ControlledNumberField as y,ControlledPasswordField as U,ControlledPhoneField as k,ControlledRangeField as R,ControlledRadioField as A,ControlledReferenceField as B,ControlledTextField as i,ControlledTextareaField as M,ControlledTimestampField as D,ControlledAddressField as I,ControlledSwitchField as P,ControlledMultiImageField as j}from"./components/ControlledFields";import{AvatarFieldComponent as H,BadgeFieldComponent as S,ButtonFieldComponent as p,HiddenFieldComponent as G,TextAreaComponent as N,TextFieldComponent as _}from"./components/form/fields";const q=e=>{const{name:t,value:o,onChange:r,error:n,t:d,config:l,...C}=e;return s(H,{config:l,value:o,onChange:r,error:!!n,helperText:n||void 0,t:d,...l.options,...C})},z=e=>{const{name:t,value:o,onChange:r,error:n,t:d,config:l,...C}=e;return s(S,{config:l,value:o,onChange:r,error:!!n,helperText:n||void 0,t:d,...l.options,...C})},E=e=>{const{name:t,label:o,onChange:r,config:n}=e;return s(p,{label:o||t,type:"submit",onClick:()=>r(void 0),...n.options})},J=e=>{const{name:t,label:o,onChange:r,config:n}=e;return s(p,{label:o||t,type:"reset",onClick:()=>r(void 0),...n.options})},K=e=>{const{name:t,value:o}=e;return s(G,{name:t,value:o})},L=e=>{const{name:t,label:o,value:r,onChange:n,error:d,config:l}=e;return s(N,{label:o||t,value:r,onChange:n,error:d||void 0,...l.options})},m=e=>{const{name:t,label:o,value:r,onChange:n,error:d,config:l}=e;return s(_,{label:o||t,value:r,onChange:n,error:d||void 0,...l.options})};let c=!1;function O(){if(c)return;c=!0;const e=u();e.registerComponent("text",i,m),e.registerComponent("email",i,m),e.registerComponent("url",i,m),e.registerComponent("color",i,m),e.registerComponent("textarea",M,L),e.registerComponent("password",U),e.registerComponent("number",y),e.registerComponent("range",R),e.registerComponent("boolean",g),e.registerComponent("checkbox",g),e.registerComponent("switch",P),e.registerComponent("date",a),e.registerComponent("datetime-local",a),e.registerComponent("time",a),e.registerComponent("week",a),e.registerComponent("month",a),e.registerComponent("timestamp",D),e.registerComponent("file",b),e.registerComponent("image",x),e.registerComponent("images",j),e.registerComponent("geopoint",h),e.registerComponent("address",I),e.registerComponent("map",v),e.registerComponent("array",w),e.registerComponent("select",f),e.registerComponent("combobox",F),e.registerComponent("multiselect",T),e.registerComponent("radio",A),e.registerComponent("reference",B),e.registerComponent("tel",k),e.registerComponent("avatar",i,q),e.registerComponent("badge",i,z),e.registerComponent("hidden",i,K),e.registerComponent("submit",i,E),e.registerComponent("reset",i,J)}typeof window<"u"&&O();export{O as registerBuiltinFieldTypes};
@@ -1,31 +1,49 @@
1
- import { type Control, type FieldErrors, type FieldValues } from 'react-hook-form';
2
- import type { FieldConfig, FieldType } from '@donotdev/core';
1
+ import { type Control, type ControllerRenderProps, type FieldErrors, type FieldValues, type Path } from 'react-hook-form';
2
+ import type { FieldConfig, FieldType, ValueTypeForField } from '@donotdev/core';
3
3
  import type { ReactElement } from 'react';
4
- export interface ControlledFieldProps<T extends FieldValues = any, FT extends FieldType = FieldType> {
4
+ export interface ControlledFieldProps<T extends FieldValues = FieldValues, FT extends FieldType = FieldType> {
5
5
  control: Control<T>;
6
6
  errors: FieldErrors<T>;
7
7
  fieldConfig: FieldConfig<FT>;
8
- t: (key: string) => string;
9
- onChange?: (value: any) => void;
8
+ t: (key: string, options?: Record<string, unknown>) => string;
9
+ onChange?: (value: ValueTypeForField<FT>) => void;
10
10
  placeholder?: string;
11
- [key: string]: any;
11
+ /** Field object from react-hook-form (provided by framework, no need to use useController) */
12
+ field?: ControllerRenderProps<T, Path<T>>;
13
+ /** Field state from react-hook-form (provided by framework, no need to use useController) */
14
+ fieldState?: {
15
+ error?: {
16
+ message?: string;
17
+ };
18
+ isDirty: boolean;
19
+ isTouched: boolean;
20
+ invalid: boolean;
21
+ };
12
22
  }
13
- export declare const ControlledCheckboxField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
14
- export declare const ControlledDateField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
15
- export declare const ControlledDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
16
- export declare const ControlledFileField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
17
- export declare const ControlledGeoPointField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
18
- export declare const ControlledImageField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
19
- export declare const ControlledMapField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
20
- export declare const ControlledMultiDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
21
- export declare const ControlledMultiInputField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
22
- export declare const ControlledNumberField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
23
- export declare const ControlledPhoneField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
24
- export declare const ControlledRangeField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
25
- export declare const ControlledRadioField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
26
- export declare const ControlledReferenceField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
27
- export declare const ControlledTextField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
28
- export declare const ControlledPasswordField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
29
- export declare const ControlledTimestampField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
30
- export declare const ControlledAddressField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
23
+ export declare const ControlledCheckboxField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
24
+ /**
25
+ * ControlledSwitchField - Switch with custom value mapping
26
+ * Supports uncheckedValue/checkedValue for string values like 'Manual'/'Automatic'
27
+ */
28
+ export declare function ControlledSwitchField(props: ControlledFieldProps): ReactElement;
29
+ export declare const ControlledDateField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
30
+ export declare const ControlledDropdownField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
31
+ export declare const ControlledComboboxField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
32
+ export declare const ControlledFileField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
33
+ export declare const ControlledGeoPointField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
34
+ export declare const ControlledImageField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
35
+ export declare const ControlledMultiImageField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
36
+ export declare const ControlledMapField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
37
+ export declare const ControlledMultiDropdownField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
38
+ export declare const ControlledMultiInputField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
39
+ export declare const ControlledNumberField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
40
+ export declare const ControlledPhoneField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
41
+ export declare const ControlledRangeField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
42
+ export declare const ControlledRadioField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
43
+ export declare const ControlledReferenceField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
44
+ export declare const ControlledTextField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
45
+ export declare const ControlledPasswordField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
46
+ export declare const ControlledTimestampField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
47
+ export declare const ControlledAddressField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
48
+ export declare const ControlledTextareaField: (props: ControlledFieldProps<FieldValues, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "hidden" | "address" | "avatar" | "badge" | "checkbox" | "combobox" | "date" | "datetime-local" | "geopoint" | "image" | "images" | "multiselect" | "radio" | "range" | "reset" | "select" | "switch" | "tel" | "text" | "textarea" | "time" | "timestamp" | "toggle">) => ReactElement;
31
49
  //# sourceMappingURL=ControlledFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ControlledFields.d.ts","sourceRoot":"","sources":["../../src/components/ControlledFields.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,WAAW,EAChB,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;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;AAEJ,eAAO,MAAM,uBAAuB,8bA7c/B,YAidJ,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as V}from"react";import{Controller as $}from"react-hook-form";import{handleError as P}from"@donotdev/core";import{CheckboxFieldComponent as j,DateFieldComponent as G,DropdownComponent as O,FileFieldComponent as B,GeoPointFieldComponent as S,ImageFieldComponent as _,MultiDropdownComponent as q,MultiInputTextFieldComponent as z,NumberFieldComponent as H,PhoneNumberComponent as J,PasswordFieldComponent as K,RadioFieldComponent as L,RangeFieldComponent as Q,MapFieldComponent as U,ReferenceFieldComponent as W,TextFieldComponent as X,TimestampFieldComponent as Y,AddressFieldComponent as Z}from"./form/fields";function ee(e){if(e){if(e instanceof RegExp)return e;try{const r=/^\/(.*)\/([gimyus]*)$/.exec(e);if(r){const[,l,a]=r;if(l)return new RegExp(l,a)}return new RegExp(e)}catch{return}}}function oe(e){if(!e)return{};const r={...e};return e.pattern&&typeof e.pattern=="string"&&(r.pattern={value:ee(e.pattern)||/.*/,message:e.messages?.pattern||"Invalid format"}),r}function o(e,r,l){return function(c){const{control:g,errors:x,fieldConfig:u,t:ie,onChange:d,placeholder:R,...v}=c,{name:t,label:p,options:s={},validation:F}=u,w=t,b=F?oe(F):void 0;return C($,{name:w,control:g,rules:b,render:({field:M})=>{const{value:m,onChange:y,...N}=M,D=(()=>{try{return r?r(m):m}catch(n){return P(n,{userMessage:`Error transforming value for field ${p||t}`,context:{fieldName:t,fieldType:u.type},severity:"warning"}),m}})(),E=n=>{try{const f=l?l(n):n;y(f),d&&d(n)}catch(f){P(f,{userMessage:`Error updating field ${p||t}`,context:{fieldName:t,fieldType:u.type},severity:"warning"}),y(n),d&&d(n)}},{prefixIcon:h,suffixIcon:A,fieldSpecific:I,...T}=s||{},k={...N,...v,label:p,value:D,onChange:E,error:!!x[t],helperText:x[t]?.message||void 0,placeholder:R||s.placeholder,clearable:s.clearable,className:s.className,...I||{},...T,...h&&{prefixIcon:h},...A&&{suffixIcon:A}};return C(e,{...k})}})}}function i(e,r){return function(a){const c=V(()=>{try{return r(a)}catch{return a}},[a]);return C(e,{...c})}}const re=i(O,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),te=i(q,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),ne=i(W,e=>e),le=i(L,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),ae=i(J,e=>({...e,phoneNumbers:Array.isArray(e.value)?e.value:[],onPhoneNumberChange:e.onChange})),me=o(j,e=>!!e,e=>e?.target?.checked),fe=o(G,e=>e??null,e=>e?.target?.value),Ce=o(re,e=>e??null,e=>e?.target?.value),ge=o(B,e=>e??null,e=>e?.target?.value),xe=o(S,e=>e||{lat:0,lng:0},e=>e?.target?.value),Fe=o(_,e=>e??null,e=>e?.target?.value),ye=o(U,e=>e||{},e=>e?.target?.value),he=o(te,e=>Array.isArray(e)?e:[],e=>e?.target?.value),Ae=o(z,e=>Array.isArray(e)?e:[],e=>e),Pe=o(H,e=>e??"",e=>{if(e?.target?.value===""||e?.target?.value===null)return null;try{return parseFloat(e?.target?.value)}catch{return 0}}),Re=o(ae,e=>Array.isArray(e)?e:[],e=>e),ve=o(Q,e=>e??null,e=>e),we=o(le,e=>e??null,e=>e),be=o(ne,e=>e??null,e=>e),Me=o(X,e=>e??"",e=>e?.target?.value),Ne=o(K,e=>e??"",e=>e?.target?.value),De=o(Y,e=>e??null,e=>e),Ee=o(Z,e=>e??null,e=>e);export{Ee as ControlledAddressField,me as ControlledCheckboxField,fe as ControlledDateField,Ce as ControlledDropdownField,ge as ControlledFileField,xe as ControlledGeoPointField,Fe as ControlledImageField,ye as ControlledMapField,he as ControlledMultiDropdownField,Ae as ControlledMultiInputField,Pe as ControlledNumberField,Ne as ControlledPasswordField,Re as ControlledPhoneField,we as ControlledRadioField,ve as ControlledRangeField,be as ControlledReferenceField,Me as ControlledTextField,De as ControlledTimestampField};
1
+ "use client";import{jsx as L}from"react/jsx-runtime";import{useMemo as v}from"react";import{Controller as _,useWatch as Y,useFormContext as Z}from"react-hook-form";import{handleError as j}from"@donotdev/core";import{CheckboxFieldComponent as ee,ComboboxComponent as ne,DateFieldComponent as te,DropdownComponent as oe,FileFieldComponent as re,GeoPointFieldComponent as le,ImageFieldComponent as $,MultiDropdownComponent as ie,MultiInputTextFieldComponent as se,NumberFieldComponent as de,PhoneNumberComponent as ce,PasswordFieldComponent as ae,RadioFieldComponent as ue,RangeFieldComponent as pe,MapFieldComponent as fe,ReferenceFieldComponent as me,TextFieldComponent as Ce,TextAreaComponent as he,TimestampFieldComponent as ge,AddressFieldComponent as xe,SwitchFieldComponent as Fe}from"./form/fields";function be(e){if(e){if(e instanceof RegExp)return e;try{const t=/^\/(.*)\/([gimyus]*)$/.exec(e);if(t){const[,l,a]=t;if(l)return new RegExp(l,a)}return new RegExp(e)}catch{return}}}function ye(e){if(!e)return{};const t={};return e.required!==void 0&&(t.required=e.required),e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),e.minLength!==void 0&&(t.minLength=e.minLength),e.maxLength!==void 0&&(t.maxLength=e.maxLength),e.pattern&&typeof e.pattern=="string"&&(t.pattern={value:be(e.pattern)||/.*/,message:"Invalid format"}),t}function n(e,t,l){return function(f){const{control:g,errors:A,fieldConfig:m,t:x,onChange:d,placeholder:M}=f,{name:i,label:r,options:u={},validation:C}=m,F="dependsOn"in m?m.dependsOn:void 0,T=i,D=C?ye(C):void 0,{fieldSpecific:h}=u||{},q=Z()?.setValue,k=Y({control:g}),G=F&&k?k[F.field]:void 0,B=v(()=>{const s=C?.options;if(!s)return[];if(typeof s=="function")return s(k||{});if(typeof s=="object"&&"type"in s&&s.type==="range"){const{start:b,end:w,step:O=1,reverse:E=!1}=s,V=[];if(E)for(let c=w;c>=b;c-=O){const p=String(c);V.push({value:p,label:p})}else for(let c=b;c<=w;c+=O){const p=String(c);V.push({value:p,label:p})}return V}return s},[C?.options,k,G]);return L(_,{name:T,control:g,rules:D,render:({field:s})=>{const{value:b,onChange:w,ref:O,...E}=s,V=(()=>{try{return t?t(b):b}catch(o){return j(o,{userMessage:`Error transforming value for field ${r||i}`,context:{fieldName:i,fieldType:m.type},severity:"warning"}),b}})(),c=o=>{try{const P=l?l(o):o;if(F&&q){const R=h?.setParentOnChange;if(typeof R=="function"){const S=R(P,k||{});S!=null&&q(F.field,S,{shouldValidate:!0,shouldDirty:!0})}}w(P),d&&d(o)}catch(P){j(P,{userMessage:`Error updating field ${r||i}`,context:{fieldName:i,fieldType:m.type},severity:"warning"}),w(o),d&&d(o)}},{prefixIcon:p,suffixIcon:W,...z}=u||{},N=o=>{const{children:P,...R}=o;return R},H=N(E),J=h?N(h):void 0,K=N(z),Q=typeof r=="string"&&r.includes(":")?x(r.split(":")[1]??r,{ns:r.split(":")[0]}):x(r),U=B.map(o=>({...o,label:typeof o.label=="string"&&o.label.includes(":")?x(o.label.split(":")[1]??o.label,{ns:o.label.split(":")[0]}):x(o.label)})),X={...H,label:Q,value:V,onChange:c,error:!!A[i],helperText:A[i]?.message||void 0,placeholder:M||u.placeholder,clearable:u.clearable,className:u.className,options:U,required:C?.required||!1,...J||{},...K,...p&&{prefixIcon:p},...W&&{suffixIcon:W}};return L(e,{...X})}})}}function y(e,t){return function(a){const f=v(()=>{try{return t(a)}catch{return a}},[a]);return L(e,{...f})}}const Ae=y(oe,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),ke=y(ne,e=>{const{children:t,...l}=e;return{...l,options:Array.isArray(e.options)?e.options:[],creatable:e.creatable??!1}}),we=y(ie,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),Ve=y(me,e=>e),Pe=y(ue,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),Ee=n(ee,e=>!!e,e=>e?.target?.checked);function Ne(e){const{control:t,errors:l,fieldConfig:a,t:f,onChange:g}=e,{name:A,label:m,options:x={}}=a,d=x.fieldSpecific,M=d?.uncheckedValue??!1,i=d?.checkedValue??!0,r=d?.uncheckedLabel,u=d?.checkedLabel;return L(_,{name:A,control:t,render:({field:{value:C,onChange:F}})=>{const T=C===i,D=h=>{const I=h?i:M;F(I),g&&g(I)};return L(Fe,{label:f(m),checked:T,onChange:h=>D(h.target.checked),uncheckedLabel:r?f(r):void 0,checkedLabel:u?f(u):void 0,helperText:l[A]?.message})}})}const Se=n(te,e=>e??null,e=>e?.target?.value),qe=n(Ae,e=>e??null,e=>e?.target?.value),We=n(ke,e=>e??"",e=>e?.target?.value),ve=n(re,e=>e??null,e=>e?.target?.value),_e=n(le,e=>e||{lat:0,lng:0},e=>e?.target?.value),je=n($,e=>e??null,e=>e),Le=y($,e=>({...e,multiple:!0})),$e=n(Le,e=>Array.isArray(e)?e:e?[e]:[],e=>e),Ge=n(fe,e=>e||{},e=>e?.target?.value),Be=n(we,e=>Array.isArray(e)?e:[],e=>e?.target?.value),ze=n(se,e=>Array.isArray(e)?e:[],e=>e),He=n(de,e=>e??"",e=>{if(e?.target?.value===""||e?.target?.value===null)return null;try{return parseFloat(e?.target?.value)}catch{return 0}}),Je=n(ce,e=>typeof e=="string"?e:"",e=>e?.target?.value||""),Ke=n(pe,e=>e??null,e=>e),Qe=n(Pe,e=>e??null,e=>e),Ue=n(Ve,e=>e??null,e=>e),Xe=n(Ce,e=>e??"",e=>e?.target?.value),Ye=n(ae,e=>e??"",e=>e?.target?.value),Ze=n(ge,e=>e??null,e=>e),en=n(xe,e=>e??null,e=>e),nn=n(he,e=>e??"",e=>e?.target?.value);export{en as ControlledAddressField,Ee as ControlledCheckboxField,We as ControlledComboboxField,Se as ControlledDateField,qe as ControlledDropdownField,ve as ControlledFileField,_e as ControlledGeoPointField,je as ControlledImageField,Ge as ControlledMapField,Be as ControlledMultiDropdownField,$e as ControlledMultiImageField,ze as ControlledMultiInputField,He as ControlledNumberField,Ye as ControlledPasswordField,Je as ControlledPhoneField,Qe as ControlledRadioField,Ke as ControlledRangeField,Ue as ControlledReferenceField,Ne as ControlledSwitchField,Xe as ControlledTextField,nn as ControlledTextareaField,Ze as ControlledTimestampField};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview DisplayFieldRenderer component
3
+ * @description Renders field values as read-only display (not editable inputs)
4
+ * Used when editable=false or user doesn't have edit permissions
5
+ *
6
+ * @version 0.0.1
7
+ * @since 0.0.1
8
+ * @author AMBROISE PARK Consulting
9
+ */
10
+ import type { ReactElement } from 'react';
11
+ import type { FieldConfig, FieldType } from '@donotdev/core';
12
+ export interface DisplayFieldRendererProps<T extends FieldType = FieldType> {
13
+ /** Field identifier */
14
+ name: string;
15
+ /** Field configuration */
16
+ config: FieldConfig<T>;
17
+ /** Current field value */
18
+ value: any;
19
+ /** Translation function */
20
+ t: (key: string, options?: Record<string, any>) => string;
21
+ }
22
+ /**
23
+ * DisplayFieldRenderer - Renders a field value as read-only display
24
+ *
25
+ * Used when:
26
+ * - editable: false (field is never editable)
27
+ * - editable: 'admin' and viewer is not admin
28
+ * - editable: 'create-only' and viewing existing record
29
+ *
30
+ * @version 0.0.1
31
+ * @since 0.0.1
32
+ * @author AMBROISE PARK Consulting
33
+ */
34
+ export declare function DisplayFieldRenderer<T extends FieldType = FieldType>({ name, config, value, t, }: DisplayFieldRendererProps<T>): ReactElement;
35
+ export default DisplayFieldRenderer;
36
+ //# sourceMappingURL=DisplayFieldRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisplayFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/DisplayFieldRenderer.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IACxE,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,0BAA0B;IAC1B,KAAK,EAAE,GAAG,CAAC;IACX,2BAA2B;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;CAC3D;AAkND;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,EACpE,IAAI,EACJ,MAAM,EACN,KAAK,EACL,CAAC,GACF,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,YAAY,CAqC7C;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ "use client";import{jsx as t,jsxs as o}from"react/jsx-runtime";import{Text as n,Stack as c}from"@donotdev/components";function m(r,a){if(r==null||r==="")return t(n,{variant:"muted",children:"\u2014"});switch(a.type){case"timestamp":case"date":case"datetime-local":try{const e=r instanceof Date?r:new Date(r);return a.type==="date"?e.toLocaleDateString():e.toLocaleString()}catch{return String(r)}case"boolean":case"checkbox":return r?"Yes":"No";case"number":case"range":return typeof r=="number"?r.toLocaleString():String(r);case"select":case"radio":const d=a.validation?.options;return Array.isArray(d)&&d.find(i=>i.value===r)?.label||String(r);case"multiselect":if(Array.isArray(r)){const e=a.validation?.options;if(Array.isArray(e))return r.map(s=>e.find(l=>l.value===s)?.label||s).join(", ")}return String(r);case"image":return typeof r=="string"?t("img",{src:r,alt:a.label,style:{maxWidth:"200px",maxHeight:"150px",objectFit:"cover",borderRadius:"var(--radius-md)"}}):Array.isArray(r)?o(c,{direction:"row",gap:"tight",style:{flexWrap:"wrap"},children:[r.slice(0,4).map((e,i)=>{const s=typeof e=="object"&&e.thumbUrl?e.thumbUrl:e;return t("img",{src:s,alt:`${a.label} ${i+1}`,style:{width:"60px",height:"60px",objectFit:"cover",borderRadius:"var(--radius-sm)"}},i)}),r.length>4&&o(n,{variant:"muted",children:["+",r.length-4," more"]})]}):t(n,{variant:"muted",children:"\u2014"});case"file":return typeof r=="string"?t("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"View file"}):t(n,{variant:"muted",children:"\u2014"});case"reference":return String(r);case"geopoint":return r&&typeof r=="object"&&"lat"in r&&"lng"in r?`${r.lat.toFixed(6)}, ${r.lng.toFixed(6)}`:t(n,{variant:"muted",children:"\u2014"});case"address":return r&&typeof r=="object"&&"formatted_address"in r?r.formatted_address:String(r);case"map":if(r&&typeof r=="object"){const e=Object.entries(r);return e.length===0?t(n,{variant:"muted",children:"\u2014"}):o(c,{direction:"column",gap:"tight",children:[e.slice(0,5).map(([i,s])=>o(n,{style:{fontSize:"var(--font-size-sm)"},children:[o("strong",{children:[i,":"]})," ",String(s)]},i)),e.length>5&&o(n,{variant:"muted",children:["+",e.length-5," more"]})]})}return t(n,{variant:"muted",children:"\u2014"});case"array":return Array.isArray(r)?r.length===0?t(n,{variant:"muted",children:"\u2014"}):r.join(", "):t(n,{variant:"muted",children:"\u2014"});case"password":return"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";case"email":return t("a",{href:`mailto:${r}`,style:{color:"var(--primary)"},children:r});case"tel":return t("a",{href:`tel:${r}`,style:{color:"var(--primary)"},children:r});case"url":return t("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--primary)"},children:r});case"color":return o(c,{direction:"row",gap:"tight",align:"center",children:[t("div",{style:{width:"20px",height:"20px",backgroundColor:r,borderRadius:"var(--radius-sm)",border:"1px solid var(--border)"}}),t(n,{children:r})]});default:return String(r)}}function p({name:r,config:a,value:d,t:e}){const i=m(d,a);return o(c,{direction:"column",gap:"tight",style:{marginBottom:"var(--gap-sm)"},children:[t(n,{variant:"muted",style:{fontSize:"var(--font-size-sm)",fontWeight:500},children:a.label||r}),t("div",{style:{padding:"var(--gap-sm)",backgroundColor:"var(--muted)",borderRadius:"var(--radius-md)",border:"1px solid var(--border)",minHeight:"38px",display:"flex",alignItems:"center"},children:typeof i=="string"?t(n,{children:i}):i})]})}var y=p;export{p as DisplayFieldRenderer,y as default};