@donotdev/crud 0.2.2 → 0.3.0

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 (373) hide show
  1. package/dist/CrudService.bulk.d.ts +17 -16
  2. package/dist/CrudService.bulk.d.ts.map +1 -1
  3. package/dist/CrudService.bulk.js +1 -1
  4. package/dist/CrudService.bulkAcross.d.ts +15 -8
  5. package/dist/CrudService.bulkAcross.d.ts.map +1 -1
  6. package/dist/CrudService.bulkAcross.js +1 -1
  7. package/dist/CrudService.bulkReconciliation.d.ts +4 -0
  8. package/dist/CrudService.bulkReconciliation.d.ts.map +1 -0
  9. package/dist/CrudService.bulkReconciliation.js +1 -0
  10. package/dist/CrudService.cache.d.ts +22 -3
  11. package/dist/CrudService.cache.d.ts.map +1 -1
  12. package/dist/CrudService.cache.js +1 -1
  13. package/dist/CrudService.d.ts +42 -11
  14. package/dist/CrudService.d.ts.map +1 -1
  15. package/dist/CrudService.internal.d.ts +3 -2
  16. package/dist/CrudService.internal.d.ts.map +1 -1
  17. package/dist/CrudService.internal.js +2 -2
  18. package/dist/CrudService.js +1 -1
  19. package/dist/CrudService.mutations.d.ts +3 -3
  20. package/dist/CrudService.mutations.d.ts.map +1 -1
  21. package/dist/CrudService.mutations.js +1 -1
  22. package/dist/CrudService.optimistic.d.ts +2 -2
  23. package/dist/CrudService.optimistic.d.ts.map +1 -1
  24. package/dist/CrudService.optimistic.js +1 -1
  25. package/dist/CrudService.queries.d.ts.map +1 -1
  26. package/dist/CrudService.queries.js +1 -1
  27. package/dist/CrudService.subscriptions.d.ts.map +1 -1
  28. package/dist/CrudService.subscriptions.js +1 -1
  29. package/dist/CrudService.writeRules.d.ts +57 -0
  30. package/dist/CrudService.writeRules.d.ts.map +1 -0
  31. package/dist/CrudService.writeRules.js +1 -0
  32. package/dist/CrudService.writeSchema.d.ts +64 -0
  33. package/dist/CrudService.writeSchema.d.ts.map +1 -0
  34. package/dist/CrudService.writeSchema.js +1 -0
  35. package/dist/CrudStore.d.ts +10 -1
  36. package/dist/CrudStore.d.ts.map +1 -1
  37. package/dist/CrudStore.js +1 -1
  38. package/dist/FieldRegistry.d.ts +1 -1
  39. package/dist/FieldRegistry.d.ts.map +1 -1
  40. package/dist/adapters/FunctionsAdapter.d.ts +3 -3
  41. package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
  42. package/dist/adapters/FunctionsAdapter.js +1 -1
  43. package/dist/components/CrudButton.d.ts +3 -2
  44. package/dist/components/CrudButton.d.ts.map +1 -1
  45. package/dist/components/CrudButton.js +1 -1
  46. package/dist/components/CrudCard.d.ts +2 -2
  47. package/dist/components/CrudCard.d.ts.map +1 -1
  48. package/dist/components/CrudCard.js +1 -1
  49. package/dist/components/DateFilter.js +1 -1
  50. package/dist/components/DisplayFieldRenderer.d.ts +5 -2
  51. package/dist/components/DisplayFieldRenderer.d.ts.map +1 -1
  52. package/dist/components/DisplayFieldRenderer.js +1 -1
  53. package/dist/components/DisplayThumbnail.d.ts.map +1 -1
  54. package/dist/components/DisplayThumbnail.js +1 -1
  55. package/dist/components/EntityFilters.d.ts +26 -4
  56. package/dist/components/EntityFilters.d.ts.map +1 -1
  57. package/dist/components/EntityFilters.js +1 -1
  58. package/dist/components/FormFieldRenderer.d.ts +21 -12
  59. package/dist/components/FormFieldRenderer.d.ts.map +1 -1
  60. package/dist/components/FormFieldRenderer.js +1 -1
  61. package/dist/components/FormLayout.d.ts.map +1 -1
  62. package/dist/components/FormLayout.js +1 -1
  63. package/dist/components/SortableCardList.d.ts +47 -0
  64. package/dist/components/SortableCardList.d.ts.map +1 -0
  65. package/dist/components/SortableCardList.js +1 -0
  66. package/dist/components/YearFilter.js +1 -1
  67. package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
  68. package/dist/components/controlled/complex/ControlledAddressField.js +1 -1
  69. package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
  70. package/dist/components/controlled/complex/ControlledDateField.js +1 -1
  71. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts +9 -0
  72. package/dist/components/controlled/complex/ControlledFieldArrayField.d.ts.map +1 -1
  73. package/dist/components/controlled/complex/ControlledFieldArrayField.js +1 -1
  74. package/dist/components/controlled/complex/ControlledGeoPointField.d.ts.map +1 -1
  75. package/dist/components/controlled/complex/ControlledMapField.d.ts.map +1 -1
  76. package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
  77. package/dist/components/controlled/complex/ControlledMultiInputField.js +1 -1
  78. package/dist/components/controlled/complex/ControlledRichTextField.d.ts.map +1 -1
  79. package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
  80. package/dist/components/controlled/complex/ControlledTimestampField.js +1 -1
  81. package/dist/components/controlled/fieldOptions.d.ts +48 -0
  82. package/dist/components/controlled/fieldOptions.d.ts.map +1 -0
  83. package/dist/components/controlled/fieldOptions.js +1 -0
  84. package/dist/components/controlled/file/ControlledDocumentField.js +1 -1
  85. package/dist/components/controlled/file/ControlledFileField.js +1 -1
  86. package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
  87. package/dist/components/controlled/file/ControlledImageField.js +1 -1
  88. package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts.map +1 -1
  89. package/dist/components/controlled/file/ControlledMultiDocumentField.js +1 -1
  90. package/dist/components/controlled/file/ControlledMultiFileField.d.ts.map +1 -1
  91. package/dist/components/controlled/file/ControlledMultiFileField.js +1 -1
  92. package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
  93. package/dist/components/controlled/file/ControlledMultiImageField.js +1 -1
  94. package/dist/components/controlled/input/ControlledCheckboxField.d.ts.map +1 -1
  95. package/dist/components/controlled/input/ControlledCurrencyField.d.ts.map +1 -1
  96. package/dist/components/controlled/input/ControlledCurrencyField.js +1 -1
  97. package/dist/components/controlled/input/ControlledDurationField.d.ts.map +1 -1
  98. package/dist/components/controlled/input/ControlledDurationField.js +1 -1
  99. package/dist/components/controlled/input/ControlledGdprConsentField.d.ts.map +1 -1
  100. package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -1
  101. package/dist/components/controlled/input/ControlledNumberField.d.ts.map +1 -1
  102. package/dist/components/controlled/input/ControlledNumberField.js +1 -1
  103. package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
  104. package/dist/components/controlled/input/ControlledPasswordField.js +1 -1
  105. package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
  106. package/dist/components/controlled/input/ControlledPhoneField.js +1 -1
  107. package/dist/components/controlled/input/ControlledPriceField.d.ts.map +1 -1
  108. package/dist/components/controlled/input/ControlledPriceField.js +1 -1
  109. package/dist/components/controlled/input/ControlledRangeField.d.ts.map +1 -1
  110. package/dist/components/controlled/input/ControlledRangeField.js +1 -1
  111. package/dist/components/controlled/input/ControlledRatingField.d.ts.map +1 -1
  112. package/dist/components/controlled/input/ControlledRatingField.js +1 -1
  113. package/dist/components/controlled/input/ControlledSwitchField.d.ts.map +1 -1
  114. package/dist/components/controlled/input/ControlledSwitchField.js +1 -1
  115. package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
  116. package/dist/components/controlled/input/ControlledTextField.js +1 -1
  117. package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
  118. package/dist/components/controlled/input/ControlledTextareaField.js +1 -1
  119. package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
  120. package/dist/components/controlled/select/ControlledComboboxField.js +1 -1
  121. package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
  122. package/dist/components/controlled/select/ControlledDropdownField.js +1 -1
  123. package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
  124. package/dist/components/controlled/select/ControlledMultiDropdownField.js +1 -1
  125. package/dist/components/controlled/select/ControlledRadioField.d.ts.map +1 -1
  126. package/dist/components/controlled/select/ControlledReferenceField.d.ts.map +1 -1
  127. package/dist/components/controlled/select/ControlledReferenceField.js +1 -1
  128. package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -1
  129. package/dist/components/controlled/select/ControlledYearField.js +1 -1
  130. package/dist/components/controlled/types.d.ts.map +1 -1
  131. package/dist/components/fields/display/AvatarFieldDisplay.d.ts.map +1 -1
  132. package/dist/components/fields/display/AvatarFieldDisplay.js +1 -1
  133. package/dist/components/fields/display/BadgeFieldDisplay.d.ts.map +1 -1
  134. package/dist/components/fields/display/ButtonFieldDisplay.d.ts.map +1 -1
  135. package/dist/components/fields/display/CheckboxFieldDisplay.d.ts.map +1 -1
  136. package/dist/components/fields/display/CheckboxFieldDisplay.js +1 -1
  137. package/dist/components/fields/display/DateFieldDisplay.d.ts.map +1 -1
  138. package/dist/components/fields/display/DateFieldDisplay.js +1 -1
  139. package/dist/components/fields/display/DropdownDisplay.d.ts.map +1 -1
  140. package/dist/components/fields/display/FileFieldDisplay.d.ts.map +1 -1
  141. package/dist/components/fields/display/FileFieldDisplay.js +1 -1
  142. package/dist/components/fields/display/GeoPointFieldDisplay.d.ts.map +1 -1
  143. package/dist/components/fields/display/HiddenFieldDisplay.d.ts.map +1 -1
  144. package/dist/components/fields/display/ImageFieldDisplay.d.ts.map +1 -1
  145. package/dist/components/fields/display/LinkFieldDisplay.d.ts.map +1 -1
  146. package/dist/components/fields/display/LinkFieldDisplay.js +1 -1
  147. package/dist/components/fields/display/MapFieldDisplay.d.ts.map +1 -1
  148. package/dist/components/fields/display/MultiDropdownDisplay.d.ts.map +1 -1
  149. package/dist/components/fields/display/MultiInputTextFieldDisplay.d.ts.map +1 -1
  150. package/dist/components/fields/display/NumberFieldDisplay.d.ts.map +1 -1
  151. package/dist/components/fields/display/NumberFieldDisplay.js +1 -1
  152. package/dist/components/fields/display/PasswordFieldDisplay.d.ts.map +1 -1
  153. package/dist/components/fields/display/PasswordFieldDisplay.js +1 -1
  154. package/dist/components/fields/display/PhoneNumberDisplay.d.ts.map +1 -1
  155. package/dist/components/fields/display/RadioFieldDisplay.d.ts.map +1 -1
  156. package/dist/components/fields/display/RangeFieldDisplay.d.ts.map +1 -1
  157. package/dist/components/fields/display/ReferenceFieldDisplay.d.ts.map +1 -1
  158. package/dist/components/fields/display/ReferenceFieldDisplay.js +1 -1
  159. package/dist/components/fields/display/RichTextDisplay.d.ts.map +1 -1
  160. package/dist/components/fields/display/TextAreaDisplay.d.ts.map +1 -1
  161. package/dist/components/fields/display/TextAreaDisplay.js +1 -1
  162. package/dist/components/fields/display/TextFieldDisplay.d.ts.map +1 -1
  163. package/dist/components/fields/display/TextFieldDisplay.js +1 -1
  164. package/dist/components/fields/display/TimestampFieldDisplay.d.ts.map +1 -1
  165. package/dist/components/form/fields/AddressFieldComponent.d.ts +3 -1
  166. package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -1
  167. package/dist/components/form/fields/AddressFieldComponent.js +1 -1
  168. package/dist/components/form/fields/AvatarFieldComponent.d.ts.map +1 -1
  169. package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
  170. package/dist/components/form/fields/BadgeFieldComponent.d.ts.map +1 -1
  171. package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
  172. package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
  173. package/dist/components/form/fields/CheckboxFieldComponent.d.ts.map +1 -1
  174. package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
  175. package/dist/components/form/fields/ComboboxComponent.d.ts +2 -0
  176. package/dist/components/form/fields/ComboboxComponent.d.ts.map +1 -1
  177. package/dist/components/form/fields/ComboboxComponent.js +1 -1
  178. package/dist/components/form/fields/CurrencyFieldComponent.d.ts +2 -0
  179. package/dist/components/form/fields/CurrencyFieldComponent.d.ts.map +1 -1
  180. package/dist/components/form/fields/CurrencyFieldComponent.js +1 -1
  181. package/dist/components/form/fields/DateFieldComponent.d.ts +2 -0
  182. package/dist/components/form/fields/DateFieldComponent.d.ts.map +1 -1
  183. package/dist/components/form/fields/DateFieldComponent.js +1 -1
  184. package/dist/components/form/fields/DocumentFieldComponent.js +1 -1
  185. package/dist/components/form/fields/DropdownComponent.d.ts +2 -0
  186. package/dist/components/form/fields/DropdownComponent.d.ts.map +1 -1
  187. package/dist/components/form/fields/DropdownComponent.js +1 -1
  188. package/dist/components/form/fields/DurationFieldComponent.d.ts.map +1 -1
  189. package/dist/components/form/fields/DurationFieldComponent.js +1 -1
  190. package/dist/components/form/fields/FileFieldComponent.js +1 -1
  191. package/dist/components/form/fields/GdprConsentFieldComponent.d.ts.map +1 -1
  192. package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -1
  193. package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
  194. package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
  195. package/dist/components/form/fields/ImageFieldComponent.js +1 -1
  196. package/dist/components/form/fields/MapFieldComponent.d.ts.map +1 -1
  197. package/dist/components/form/fields/MultiDropdownComponent.d.ts +2 -0
  198. package/dist/components/form/fields/MultiDropdownComponent.d.ts.map +1 -1
  199. package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
  200. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts +2 -0
  201. package/dist/components/form/fields/MultiInputTextFieldComponent.d.ts.map +1 -1
  202. package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
  203. package/dist/components/form/fields/NumberFieldComponent.d.ts +2 -0
  204. package/dist/components/form/fields/NumberFieldComponent.d.ts.map +1 -1
  205. package/dist/components/form/fields/NumberFieldComponent.js +1 -1
  206. package/dist/components/form/fields/PasswordFieldComponent.d.ts +2 -0
  207. package/dist/components/form/fields/PasswordFieldComponent.d.ts.map +1 -1
  208. package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
  209. package/dist/components/form/fields/PhoneNumberComponent.d.ts +11 -1
  210. package/dist/components/form/fields/PhoneNumberComponent.d.ts.map +1 -1
  211. package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
  212. package/dist/components/form/fields/PriceFieldComponent.d.ts +2 -0
  213. package/dist/components/form/fields/PriceFieldComponent.d.ts.map +1 -1
  214. package/dist/components/form/fields/PriceFieldComponent.js +1 -1
  215. package/dist/components/form/fields/RangeFieldComponent.js +1 -1
  216. package/dist/components/form/fields/RatingFieldComponent.js +1 -1
  217. package/dist/components/form/fields/ReferenceFieldComponent.d.ts +3 -1
  218. package/dist/components/form/fields/ReferenceFieldComponent.d.ts.map +1 -1
  219. package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
  220. package/dist/components/form/fields/RichTextComponent.js +1 -1
  221. package/dist/components/form/fields/SwitchFieldComponent.d.ts.map +1 -1
  222. package/dist/components/form/fields/SwitchFieldComponent.js +1 -1
  223. package/dist/components/form/fields/TextAreaComponent.d.ts +2 -0
  224. package/dist/components/form/fields/TextAreaComponent.d.ts.map +1 -1
  225. package/dist/components/form/fields/TextAreaComponent.js +1 -1
  226. package/dist/components/form/fields/TextFieldComponent.d.ts +3 -1
  227. package/dist/components/form/fields/TextFieldComponent.d.ts.map +1 -1
  228. package/dist/components/form/fields/TextFieldComponent.js +1 -1
  229. package/dist/components/form/fields/TimestampFieldComponent.d.ts +2 -0
  230. package/dist/components/form/fields/TimestampFieldComponent.d.ts.map +1 -1
  231. package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
  232. package/dist/components/form/fields/internal/InlineFieldRow.d.ts +24 -0
  233. package/dist/components/form/fields/internal/InlineFieldRow.d.ts.map +1 -0
  234. package/dist/components/form/fields/internal/InlineFieldRow.js +1 -0
  235. package/dist/components/form/fields/internal/TiptapEditor.d.ts.map +1 -1
  236. package/dist/components/form/fields/internal/TiptapEditor.js +2 -2
  237. package/dist/components/form/internal/ImageViewerDialog.js +1 -1
  238. package/dist/components/index.d.ts +2 -0
  239. package/dist/components/index.d.ts.map +1 -1
  240. package/dist/components/index.js +1 -1
  241. package/dist/fieldTypeRegistry.d.ts +2 -2
  242. package/dist/fieldTypeRegistry.d.ts.map +1 -1
  243. package/dist/fieldTypeRegistry.js +1 -1
  244. package/dist/fieldTypeRegistry.store.d.ts +0 -2
  245. package/dist/fieldTypeRegistry.store.d.ts.map +1 -1
  246. package/dist/fieldTypeRegistry.store.js +1 -1
  247. package/dist/fieldTypeRegistry.types.d.ts +8 -9
  248. package/dist/fieldTypeRegistry.types.d.ts.map +1 -1
  249. package/dist/forms/FormNavigation.d.ts +24 -0
  250. package/dist/forms/FormNavigation.d.ts.map +1 -0
  251. package/dist/forms/FormNavigation.js +1 -0
  252. package/dist/forms/childRows.d.ts +184 -0
  253. package/dist/forms/childRows.d.ts.map +1 -0
  254. package/dist/forms/childRows.js +1 -0
  255. package/dist/forms/extend.d.ts +88 -0
  256. package/dist/forms/extend.d.ts.map +1 -0
  257. package/dist/forms/extend.js +1 -0
  258. package/dist/forms/hooks/useController.js +1 -1
  259. package/dist/forms/hooks/useEntityField.d.ts +11 -5
  260. package/dist/forms/hooks/useEntityField.d.ts.map +1 -1
  261. package/dist/forms/hooks/useEntityField.js +1 -1
  262. package/dist/forms/hooks/useEntityForm.d.ts +50 -5
  263. package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
  264. package/dist/forms/hooks/useEntityForm.js +1 -1
  265. package/dist/forms/hooks/useFormDraftState.d.ts +53 -0
  266. package/dist/forms/hooks/useFormDraftState.d.ts.map +1 -0
  267. package/dist/forms/hooks/useFormDraftState.js +1 -0
  268. package/dist/forms/index.d.ts +6 -2
  269. package/dist/forms/index.d.ts.map +1 -1
  270. package/dist/forms/index.js +1 -1
  271. package/dist/forms/types.d.ts +171 -25
  272. package/dist/forms/types.d.ts.map +1 -1
  273. package/dist/forms/utils/buildInitialValues.d.ts +32 -17
  274. package/dist/forms/utils/buildInitialValues.d.ts.map +1 -1
  275. package/dist/forms/utils/buildInitialValues.js +1 -1
  276. package/dist/forms/utils/conditionAwareResolver.d.ts +35 -0
  277. package/dist/forms/utils/conditionAwareResolver.d.ts.map +1 -0
  278. package/dist/forms/utils/conditionAwareResolver.js +1 -0
  279. package/dist/forms/utils/emptyValue.d.ts +34 -0
  280. package/dist/forms/utils/emptyValue.d.ts.map +1 -0
  281. package/dist/forms/utils/emptyValue.js +1 -0
  282. package/dist/forms/utils/getFieldsForOperation.d.ts +30 -19
  283. package/dist/forms/utils/getFieldsForOperation.d.ts.map +1 -1
  284. package/dist/forms/utils/getFieldsForOperation.js +1 -1
  285. package/dist/forms/utils/index.d.ts +1 -0
  286. package/dist/forms/utils/index.d.ts.map +1 -1
  287. package/dist/forms/utils/index.js +1 -1
  288. package/dist/forms/utils/isFieldEditable.d.ts +21 -22
  289. package/dist/forms/utils/isFieldEditable.d.ts.map +1 -1
  290. package/dist/forms/utils/isFieldEditable.js +1 -1
  291. package/dist/forms/utils/translateFieldLabel.d.ts +1 -9
  292. package/dist/forms/utils/translateFieldLabel.d.ts.map +1 -1
  293. package/dist/forms/utils/translateFieldLabel.js +1 -1
  294. package/dist/forms/utils/validateEntity.js +1 -1
  295. package/dist/forms/utils/writableFields.d.ts +19 -0
  296. package/dist/forms/utils/writableFields.d.ts.map +1 -0
  297. package/dist/forms/utils/writableFields.js +1 -0
  298. package/dist/hooks/index.d.ts +2 -0
  299. package/dist/hooks/index.d.ts.map +1 -1
  300. package/dist/hooks/index.js +1 -1
  301. package/dist/hooks/useChildRows.d.ts +161 -0
  302. package/dist/hooks/useChildRows.d.ts.map +1 -0
  303. package/dist/hooks/useChildRows.js +1 -0
  304. package/dist/hooks/useCrudFilters.d.ts +21 -1
  305. package/dist/hooks/useCrudFilters.d.ts.map +1 -1
  306. package/dist/hooks/useCrudFilters.js +1 -1
  307. package/dist/hooks/useCrudPageSize.js +1 -1
  308. package/dist/hooks/useEntityFavorites.js +1 -1
  309. package/dist/hooks/useExtensionRows.d.ts +24 -0
  310. package/dist/hooks/useExtensionRows.d.ts.map +1 -0
  311. package/dist/hooks/useExtensionRows.js +1 -0
  312. package/dist/hooks/useFieldConditions.d.ts +2 -2
  313. package/dist/hooks/useFieldConditions.d.ts.map +1 -1
  314. package/dist/hooks/useFieldConditions.js +1 -1
  315. package/dist/hooks/useFileUpload.js +1 -1
  316. package/dist/hooks/useReferenceResolver.d.ts +4 -1
  317. package/dist/hooks/useReferenceResolver.d.ts.map +1 -1
  318. package/dist/hooks/useReferenceResolver.js +1 -1
  319. package/dist/hooks/useRelatedItems.js +1 -1
  320. package/dist/index.d.ts +6 -5
  321. package/dist/index.d.ts.map +1 -1
  322. package/dist/index.js +1 -1
  323. package/dist/registerBuiltinFieldTypes.d.ts +4 -2
  324. package/dist/registerBuiltinFieldTypes.d.ts.map +1 -1
  325. package/dist/registerBuiltinFieldTypes.js +1 -1
  326. package/dist/stores/FormStore.d.ts +116 -5
  327. package/dist/stores/FormStore.d.ts.map +1 -1
  328. package/dist/stores/FormStore.js +1 -1
  329. package/dist/stores/UploadStore.js +1 -1
  330. package/dist/stores/index.d.ts +1 -1
  331. package/dist/stores/index.d.ts.map +1 -1
  332. package/dist/stores/index.js +1 -1
  333. package/dist/symbol-index.json +1 -1
  334. package/dist/tsconfig.tsbuildinfo +1 -1
  335. package/dist/types.d.ts +40 -7
  336. package/dist/types.d.ts.map +1 -1
  337. package/dist/useBaseCrudList.d.ts.map +1 -1
  338. package/dist/useBaseCrudList.js +1 -1
  339. package/dist/useCrud.d.ts +20 -9
  340. package/dist/useCrud.d.ts.map +1 -1
  341. package/dist/useCrud.js +1 -1
  342. package/dist/useCrudCardList.js +1 -1
  343. package/dist/useCrudDoc.d.ts.map +1 -1
  344. package/dist/useCrudDoc.js +1 -1
  345. package/dist/useCrudList.js +1 -1
  346. package/dist/utils/clientListProcessing.d.ts +9 -12
  347. package/dist/utils/clientListProcessing.d.ts.map +1 -1
  348. package/dist/utils/clientListProcessing.js +1 -1
  349. package/dist/utils/collections.d.ts.map +1 -1
  350. package/dist/utils/collections.js +1 -1
  351. package/dist/utils/filterUrl.d.ts +45 -0
  352. package/dist/utils/filterUrl.d.ts.map +1 -0
  353. package/dist/utils/filterUrl.js +1 -0
  354. package/dist/utils/imageProcessing.js +1 -1
  355. package/dist/utils/matchesFilter.d.ts +27 -3
  356. package/dist/utils/matchesFilter.d.ts.map +1 -1
  357. package/dist/utils/matchesFilter.js +1 -1
  358. package/dist/utils/referenceEntity.d.ts +11 -0
  359. package/dist/utils/referenceEntity.d.ts.map +1 -0
  360. package/dist/utils/referenceEntity.js +1 -0
  361. package/dist/utils/uploadValidation.js +1 -1
  362. package/dist/utils/useRowTranslator.d.ts +21 -0
  363. package/dist/utils/useRowTranslator.d.ts.map +1 -0
  364. package/dist/utils/useRowTranslator.js +1 -0
  365. package/dist/workflows/defineWorkflow.js +1 -1
  366. package/dist/workflows/useEntityWorkflow.js +1 -1
  367. package/guidelines/COMPONENTS.md +87 -10
  368. package/guidelines/CRUD.md +336 -17
  369. package/guidelines/GOTCHAS.md +19 -1
  370. package/package.json +8 -8
  371. package/dist/builtinFieldTypes.d.ts +0 -23
  372. package/dist/builtinFieldTypes.d.ts.map +0 -1
  373. package/dist/builtinFieldTypes.js +0 -1
@@ -24,8 +24,14 @@ export const productEntity = defineEntity({
24
24
  });
25
25
  ```
26
26
 
27
+ **Import from `@donotdev/core`, never `@donotdev/core/server`.** Entity files load in the browser (Vite, Next client) and on the Next server (`llms.txt` route). The root export resolves per platform: full root in the browser, client-free server entry under Next's `react-server` condition. Vite empties `/server` imports in client bundles, so `/server` in an entity file breaks the app.
28
+
27
29
  **Auto-added fields:** `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`, `status`.
28
30
 
31
+ **Field help:** `hint: 'hints.slug'` (a key of the entity namespace) puts an (i) after the field's label in entity forms: hover or focus shows the translated text, a tap pins it on touch screens. Opt-in: no `hint`, no (i). Shown by the fields with a floating label (text, textarea, number, currency, password, phone, select, combobox, multiselect, reference, year, date, timestamp, multi-text, address, price); checkbox, switch, radio, rating, range and upload fields do not show it yet.
32
+
33
+ **Reference fields** (`type: 'reference'`, `validation: { reference: 'brands' }`) show labels, not ids, in `EntityList` and the form combobox with no app code. `defineEntity()` registers every entity under its collection, and the reference reads the target entity with its own schema (access, visibility, field mapping). Label: `options.fieldSpecific.labelFields` or `displayField`, else the first of `name`, `title`, `label`, `displayName`. A collection with no defined entity keeps showing the raw id (dev warning).
34
+
29
35
  See `lookup_symbol("defineEntity")` for all options (scope, access, ownership, uniqueKeys, validation).
30
36
 
31
37
  ### Status Field (auto-added)
@@ -40,7 +46,18 @@ The `status` field is auto-added by `defineEntity()` with sensible defaults:
40
46
  | `required` | `true` | Yes |
41
47
 
42
48
  **Default options:** `draft`, `available`, `deleted` - always present, cannot be removed.
43
- **Default value:** `available`.
49
+ **Default value:** `available`. A form, `add()` or a bulk insert is a draft only when you pass `status: 'draft'`; a draft skips `required` validation only: what is filled in keeps its format (`TOTO` is not a phone number, even in a draft).
50
+
51
+ **Validation rules (schemas from `createSchemas`):**
52
+ - **Required** = filled in: `null`, `undefined` and `''` are rejected (forms and grids store an emptied field as `null`).
53
+ - **create** (status other than `draft`): every required field filled in, every value in format.
54
+ - **draft** (`status: 'draft'`, created or edited): required fields may be empty; values in format.
55
+ - **update** (edit of a non-draft record): only the fields that change are validated (rule 2); a field left out or unchanged is not checked, so a record with a legacy empty required field saves until that field is edited. A required field the edit empties is rejected. Leaving `draft` or `deleted` for a strict status checks the whole record (rule 5).
56
+ - **CRUD rules (SSOT: `@donotdev/core`, `core/schemas/src/common/crud/`).** Every write (forms, `useCrud`, `bulk`, `bulkAcross`, child rows, server functions, entity store) goes through `prepareCreate` / `prepareUpdate` / `prepareRemove`; reads through `hiddenStatusesFor` / `isReadableBy`. No site composes a rule itself.
57
+ **Status matrix (SSOT: `STATUS_MATRIX`, `@donotdev/types`).** One table says what each status can do: `draft` (read: admin, saveIncomplete, holdIncomplete), `available` (read: guest, isDefault), `deleted` (read: admin, holdIncomplete, isRemoved). App-added statuses behave like `available`. Code asks it (`statusCan(status, capability)`, `statusReadableBy(status, role)`, `statusesThat(capability)`), never names a status; the entity-derived types (rows, forms, inputs) read the same columns.
58
+ 1. Create validates everything. 2. Update validates what changes (a required field it sends cannot be emptied, except on a draft). 3. `delete(id)` is the hard delete; `remove(id)` the logical delete (the `isRemoved` status, nothing else validated). 4. A row is read only by roles that reach its status's `read` role. 5. A status that `saveIncomplete` saves without its required fields; leaving a status that may `holdIncomplete` for one that may not checks the whole record. 6. Apps add statuses; they are strict like `available`. 7. No status sent → the `isDefault` status; the caller overrides it (`defaultValues.status`, payload `status`). 8. Fields the entity does not have are not written and warn the user (client toast, server log). 9. Field behaviour comes from the entity (`editable`, `visibility`, `computed` / `generated`).
59
+ An update needs the stored row (its status, and the whole-record check): writers take the caller's (`bulkAcross` update `stored`, the form's `record`), else the cache, else read it once.
60
+ - **`tel`:** international (`+` country code, 8 to 15 digits, as E.164: `+33 6 12 34 56 78`, `+33612345678`) or French national (`06 12 34 56 78`, `0612345678`, `06.12.34.56.78`); spaces, dots or dashes between digits. `validation.pattern` replaces the rule. The phone field stores `<dial code> <number>`, nothing when no number is typed.
44
61
 
45
62
  If you don't define `status` in your fields at all, the full default is added automatically. If you define it, your properties are merged on top of defaults:
46
63
 
@@ -68,6 +85,22 @@ fields: {
68
85
 
69
86
  > `draft` and `deleted` items are hidden from non-admin users (server-side filtering).
70
87
 
88
+ ### SEO (`seo`, since 0.2.3)
89
+
90
+ `<Seo entity data>` and llms.txt title/describe a record with the card's text (`listCardFields`, formatted like the card: same `formatFieldText` from `@donotdev/core`). Override per entity:
91
+
92
+ ```typescript
93
+ seo: {
94
+ title: (item, t) => t('seo.title', { size: item.size }), // null → no title
95
+ description: (item, t) => null,
96
+ // schema.org Offer availability by status; `available` → InStock built in, unmapped → omitted.
97
+ // Read from the guest record: needs a `status` field with visibility: 'guest' (the base one is admin-only)
98
+ availability: { promoted: 'InStock', reserved: 'SoldOut', signed: 'SoldOut' },
99
+ },
100
+ ```
101
+
102
+ Full rules: `packages/ui/guidelines/SEO.md` (Entity-derived).
103
+
71
104
  ---
72
105
 
73
106
  ## 2. Provider Setup (once)
@@ -124,6 +157,143 @@ Drop components on a page. Entity drives the UI - no configuration needed.
124
157
 
125
158
  Use `lookup_symbol("ComponentName")` for full props.
126
159
 
160
+ **`EntityList` rows:** open-link icon (real `<a href>`, Ctrl/Cmd-click opens a tab; with `onClick` it is a button) · checkbox (bulk select; the header selects every filtered row across pages) · the list fields, **edited in their cells by default** (text, number, select, radio, reference). Checked rows take one value per field from the bulk bar, or are deleted together ("Delete selected", one `bulk({ deletes })`); Save writes every cell change in one `bulk({ updates })`; rows that fail stay pending (still marked) with an error count, saved rows leave the pending set. `editable={false}`: read-only list — read-only cells, no Add, no row selection and no delete; a row click (or the open icon) opens the record.
161
+
162
+ **Nested list (parent → children)**, e.g. the products of a brand on the brand page:
163
+
164
+ ```tsx
165
+ <EntityList entity={productEntity} basePath="/produits" parent={{ field: 'brandId', value: brandId }} />
166
+ ```
167
+
168
+ Lists only that parent's children (server-side `where`), hides the parent column and filter; the add button opens `/produits/new?brandId=…` and `EntityFormRenderer` (create) prefills `brandId` from the URL. `parent.field` must be a `reference` field (throws otherwise). URL prefill only accepts reference fields the viewer may set on create, with an id-shaped value. When an edit form is open on that parent record, the list joins it instead — see [Child rows](#child-rows-saved-with-their-record).
169
+
170
+ **Overrides (optional):** `extraColumns` — app columns after the list fields, `{ key, title, render(row), align? }`, `render` gets the row with its unsaved edits applied (computed values); `actions` — app toolbar content (it can call `useChildRows` on the same entity + parent). Web only: the Expo `EntityList` throws when given either.
171
+
172
+ ---
173
+
174
+ ## Child rows (saved with their record)
175
+
176
+ On a record's page, its child rows (1:N, including link tables N:M with data on the link) are edited, added and removed, kept with the record's unsaved edits, and saved by the record's Save. Opt-in by usage: nothing changes for pages that do not put an editable child list next to an open edit form of its parent.
177
+
178
+ ```tsx
179
+ // Zero wiring: the form's default writer saves the campaign and its products.
180
+ <EntityFormRenderer entity={campaignEntity} defaultValues={campaign} successPath={null} />
181
+ <EntityList entity={campaignProductEntity} parent={{ field: 'campaignId', value: campaign?.id ?? null }} />
182
+ ```
183
+
184
+ - **Join (automatic).** The parent collection is the child field's `validation.reference`. A mounted `useEntityForm` in edit mode (also inside `EntityFormRenderer`) registers its record in `FormStore`; child rows of that record join the **latest** form opened on it (when it closes, the previous one is the target again). Joined edits live in that form's draft: autosaved, restored with it ("Draft restored" toast), reset by its Discard / `resetForm`, kept when the save fails (also after an optimistic leave).
185
+ - **`EntityList` with `parent`, joined** (the list is `editable`, the default, and an edit form is open on the parent; `editable={false}` lists never join): no own Save, delete waits for the form's Save, pending count + Discard shown, every line of the parent shown (no filters section, search, export or pagination). Add, never a navigation: link table (the child has exactly one reference field besides the parent's) → dialog with `EntityFilters` (for the viewer's role, with its own filter state: the lists of that collection keep theirs) + text search + selectable list of the other side's records, deleted (`status: 'deleted'`) and already-linked ones excluded, multi-select → unsaved rows (the other side's entity must be defined with `defineEntity`, throws otherwise); any other child → one blank row (schema defaults). Without an open form on the parent: exactly the standalone behaviour above (own Save, immediate delete, add opens the create page).
186
+ - **Create mode:** `parent.value: null` (record not saved yet) → the list only shows "Create the draft before adding …" (`crud:childRows.createFirst`). Rows are added after the first save.
187
+ - **Saving.** `form.handleSubmit()` **without** `onValid` (or `EntityFormRenderer` without `onSubmit`) is the default writer: the record (update, or add on create) with the fields the form writes for the viewer (inputs editable for them, `editable: 'computed'` fields, `<name>I18n` companions; on create also the caller's `defaultValues.status` when the viewer may not edit status), plus the joined rows (inserts with pre-minted ids, updates, deletes), in **one `bulkAcross`**. **With** `onValid` the app writes as before and takes the rows' writes from `form.pendingWrites()` (one batch per child collection); if joined rows have edits and `pendingWrites()` was not read during the submit, the submit fails with an explicit error (no silent loss). `EntityFormRenderer`'s `onSubmit` has no form handle: omit it when rows join, or build the page with `useEntityForm`.
188
+ - **Validation (reactive, the record form's rules):** a grid is a shortcut onto the same records. Every add / update is checked with the CRUD rules (extension rows the same, merged with their stored extension; a missing extension: its defaults and edits): an added row with `prepareCreate`, an edited row with `prepareUpdate` on its stored row (only the changed fields, unless it is a draft or leaves draft for a visible status). Only fields the viewer can see are checked; only rows with edits. `rows.errors[rowId][fieldKey]` holds the translated message (`crud:childRows.required` / `invalidValue`); the list marks those cells (DataTable `cellErrors`). A Save with invalid rows is blocked before the optimistic leave with **one** message, the count of rows to fix (`crud:childRows.invalidRows`): the form error (formId set), else a toast; `rows.save()` rejects with it.
189
+ - **After success:** joined edits are cleared and the rows refetched, also when the save stays on the page (`successPath: null`). Edits made while the write was in flight stay.
190
+ - **Partial failure (non-atomic adapters):** after a rejected save the rows refetch; rows that were written leave the edits, rows that were not stay unsaved (same rule as the standalone list). Atomicity is the adapter's (`{ execution: 'atomic' }`) or the app's choice (app writer).
191
+ - **Entity rules:** `entity.access` gates add / edit / remove for the viewer (the form's `viewerRole`, or `useChildRows`' `viewerRole` option); only fields the viewer may write are set; drafts read back from browser storage are validated (shape, writable fields, value types, record-id shape) and edits of rows that no longer exist are dropped.
192
+
193
+ **Custom display — `useChildRows(entity, parent?, options?)`** (`@donotdev/crud`; no `parent` = every record of the entity, standalone, never joined; `options`: `viewerRole`, `extend` — see [1:1 extension](#11-extension-extend)): the same rows for any UI. Every `useChildRows` on the same form + child entity + parent sees the same rows (the page's button and the table agree).
194
+
195
+ ```tsx
196
+ const rows = useChildRows(supplyOrderLineEntity, { field: 'supplyOrderId', value: order.id });
197
+ rows.items; // saved rows + unsaved edits applied, added rows, removed rows hidden
198
+ rows.add([{ productId, unitsOrdered: 6 }]); // returns the new ids
199
+ rows.update(id, { unitsOrdered: 12 }); // ordering: update(id, { sortOrder })
200
+ rows.remove(ids); // logical delete on Save; rows.delete(ids): hard delete
201
+ rows.discard();
202
+ rows.hasEdits; rows.pendingCount; rows.loading; rows.error; rows.access; // { create, update, delete }
203
+ rows.joined; // true when an open form edits the parent record
204
+ rows.save(); // standalone only (no form): writes this instance's edits (one bulk; with extend one bulkAcross); throws when joined or while rows.errors is not empty
205
+ rows.errors; // { [rowId]: { [fieldKey]: message } }, updated on every change
206
+ rows.base; rows.edits; rows.extensionFields; // table data under edits.changes, the edits, visible extension fields
207
+ ```
208
+
209
+ `form.pendingWrites()` also carries the form's own 1:1 extensions (below).
210
+
211
+ App writer with joined rows:
212
+
213
+ ```tsx
214
+ const form = useEntityForm(campaignEntity, { formId: 'campaign', operation: 'edit', defaultValues: campaign, viewerRole, successPath: null });
215
+ const save = form.handleSubmit(async (values) => {
216
+ await bulkAcross([
217
+ { collection: campaignEntity.collection, updates: [{ id: campaign.id, patch: toPatch(values) }], schemas: { update } },
218
+ ...form.pendingWrites(),
219
+ ]);
220
+ });
221
+ ```
222
+
223
+ Standalone `useChildRows` (no form on the parent): edits stay in memory for that instance (not persisted); `save()` writes exactly the edits it snapshots in one `bulk` (partial success: rows that fail stay unsaved). On success what it sent leaves the edits at once (no wait for a refetch); edits made during the save stay pending; on failure everything stays. `useJoinedForm(entity, parent)` returns the open form the rows join, or `null`.
224
+
225
+ ---
226
+
227
+ ## 1:1 extension (`extend`)
228
+
229
+ A record split across two tables (e.g. `products` public + `product_offers` private, unique `productId`) is read, edited and saved as one.
230
+
231
+ ```tsx
232
+ const extend = { offer: { entity: productOfferEntity, field: 'productId' } };
233
+ useChildRows(productEntity, { field: 'brandId', value: brand.id }, { extend }); // a brand's products
234
+ useChildRows(productEntity, undefined, { extend }); // all products
235
+ useEntityForm(productEntity, { formId: 'product', operation: 'edit', defaultValues: product, viewerRole, extend });
236
+ <EntityList entity={productEntity} parent={{ field: 'brandId', value: brand.id }} extend={extend} />
237
+ ```
238
+
239
+ - **Spec:** `extend: { [key]: { entity, field } }` — `field` is the extension entity's `reference` to the extended collection (throws otherwise); `key` must not contain `.` nor be a field of the extended entity. Keep the same keys while mounted (throws when they change); use the same `extend` on every `useChildRows` of the same rows.
240
+ - **Read:** one batched query per loaded set (`field in [ids]`, chunked by 30 — Firestore's `in` limit), cached under the extension collection (refetched when it is invalidated, merged with its optimistic writes). Rows get the extension under the key (`row.offer.priceExclVat`, `row.offer === null` when missing) and as flat `offer.priceExclVat` values. The form reads the edited record's extension and waits for it before initializing.
241
+ - **Fields:** extension fields are addressed with the key prefix — `offer.priceExclVat` — in `form.fields` (`FormFieldRenderer`, values under `values.offer`), list cells, edits (`rows.update(id, { 'offer.priceExclVat': 12 })`), validation, drafts and uploads. No name collisions (id, status, audit fields stay apart). The extension's id, link field, `status` and backend-generated fields are never shown nor written by the viewer. Extension fields' `conditions` read the extension's values (`RenderableField.scope`).
242
+ - **Stable ids:** every id a write mints (a new record on create, a missing extension row) is the same on repeated `pendingWrites()` calls and retries until the write succeeds (kept in `FormStore.mintedIds`, released on success / once the row is loaded), so a retry never inserts twice.
243
+ - **Write:** extension patches go in the same writes — the form's default writer and `form.pendingWrites()`, the joined rows, `rows.save()`: update of the existing extension row, or **insert of a missing one on Save** (link field = the record; schema defaults). On create the extension insert depends on the record insert (`dependsOn`): the default writer pre-mints the record id; an app writer passes it: `form.pendingWrites({ recordId })`. An added child row always gets its extension (when the viewer may create it).
244
+ - **Validation:** like the record's own fields (edit = the update schema, draft = the draft schema, insert = the create schema; a missing extension is inserted, so its required fields apply).
245
+ - **Entity rules:** a viewer without `access.read` on the extension entity gets no extension fields (same as a hidden field), never an error and never its data (nothing is read). Without `access.create` / `access.update` its fields are read-only (no insert / update).
246
+ - **`EntityList` with `extend`:** the list is a display of `useChildRows` — joined to an open parent form as above, or standalone: filters, search, pagination, export and its own Save (rows and extensions in one `bulkAcross`; deletes wait for that Save). Extension columns = the extension entity's `listFields` (all its visible fields without), prefixed. Web only (Expo throws).
247
+
248
+ ---
249
+
250
+ ## Custom Forms: `useEntityForm` Contract
251
+
252
+ Prefer `EntityFormRenderer` from `@donotdev/ui` for a complete entity form. Use `useEntityForm` from `@donotdev/crud` when a custom layout is needed.
253
+
254
+ **Translations are automatic. Do not pass `t` for normal framework usage.** `useEntityForm` binds `[entity.namespace, 'crud']` itself, including language changes and SSR request language. Each entity form resolves its own namespace, including several entities on one page.
255
+
256
+ ```tsx
257
+ import { useAuth } from '@donotdev/auth';
258
+ import { useEntityForm } from '@donotdev/crud';
259
+
260
+ const viewerRole = useAuth('userRole');
261
+ const form = useEntityForm(productEntity, {
262
+ formId: 'product-create',
263
+ operation: 'create',
264
+ viewerRole,
265
+ });
266
+ ```
267
+
268
+ **Override only when intentional:** To bypass the default entity + CRUD namespace resolution, supply your own `t`. It replaces the default translator completely; it is not merged with it.
269
+
270
+ ```tsx
271
+ const { t: tCustom } = useTranslation('custom-form');
272
+ const form = useEntityForm(productEntity, {
273
+ formId: 'product-custom',
274
+ operation: 'create',
275
+ viewerRole,
276
+ t: tCustom,
277
+ });
278
+ ```
279
+
280
+ - **Each entity gets its own translator automatically.** A page editing shop settings and admin settings needs no translation wiring for either form.
281
+ - **Pass `form.t` to field renderers.** `FormFieldRenderer` takes `name`, `config`, `control` and `t`; `DisplayFieldRenderer` takes `name`, `config`, `value` and `t`. Labels, hints, select options and field-array child fields need the same entity translator. Never copy entity strings/options into page locales to hide a missing `t`.
282
+ - **Pass the real `viewerRole`.** Omission means `'guest'`, not the signed-in user's role: a guest form writes only guest-visible fields. Use the returned fields' `editable` / `written` flags and `useFieldConditions` for live visibility/required/disabled/readonly conditions in custom layouts.
283
+ - **Form state = the fields the form writes** (`FormValues<E, Op>`, from the entity descriptor): inputs editable for the viewer and operation, `editable: 'computed'` fields, their `<name>I18n` companions, and `id` on edit. Generated, `editable: false` and role-denied fields never enter form state, the local draft or the payload; `form.getValues('<such field>')` is `undefined`. Technical fields (`visibility: 'technical'`) never enter it on create; on edit only a technical field with a role in `editable` (`editable: 'admin'`) does, for a viewer who sees technical fields (admin and above) and holds that role (an optional key in `FormValues<E, 'edit'>`); technical fields with `editable` unset / `true` / `'create-only'` never do. So the scope field (`entity.scope`: technical, `create-only`) is never in form state: the save injects it (`injectScope`). With `extend`, each 1:1 extension's values sit under its key (`values.offer`, typed `FormValues<E, Op, X>`: the extension's written fields without its link field and `status`, with `id` when its row exists; key optional). The resolver validates and outputs only these fields, so `handleSubmit(onValid)` passes `onValid` a `FormValues<E, Op, X>`; `EntityFormRenderer`'s `onSubmit` / `onSecondarySubmit` get the same projection. Form state (React Hook Form's `TFieldValues`: `control`, `watch`, `getValues`, `setValue`, `onInvalid`'s errors) is typed `EntityFormState<E, X>` = `FormValues<E, FieldOperation, X>` (both operations); `Op` keys only the submitted values (RHF's `TTransformedValues`: `onValid`'s argument). RHF's types are invariant in their field values and covariant in the submitted ones, so every form of `E`, `create` or `edit`, is an `EntityFormReturn<E>`: helpers take `<E extends AnyEntity>(form: EntityFormReturn<E>)`, components typed `control: Control<EntityFormState<E>>` take its `control`; a helper taking a form with `extend` declares `X` (`EntityFormReturn<E, FieldOperation, X>`). `useEntityField`, `useFieldConditions` and `FormFieldRenderer` take any form of `E`.
284
+ - **`form.record`** is the stored row the edit started from (`defaultValues` on edit, 1:1 extension rows under their key; `undefined` on create). It is saved with the local draft and restored with it: read a concurrency token from `form.record` (`form.record?.revision`), not from form state, so a restored draft keeps its base version. A restored draft whose base row's `updatedAt` differs from the stored row's is a **conflict**: a persistent warning (`crud:draft.conflict`) with Discard; `form.record` stays the draft's base, so a revision-checked save refuses instead of overwriting. A draft saved for edits made after a successful save has no base row: on return, the stored row is the base. Display fields the form does not write from `form.record` (`EntityFormRenderer` does: technical, `editable: false` and role-denied fields read-only from the record; computed fields read-only from form state).
285
+ - **`defaultValues`:** on edit the stored row as read (`InferEntityRow<E>`, accepted as-is: no `?? ''` needed); on create `Partial<CreateInput<E>>` (caller defaults, e.g. `status: 'draft'`, a parent reference).
286
+ - **`editable: 'computed'`** fields are shown read-only and written: the value a field component sets with `setValue` is saved by the default writer and passed to `onValid`.
287
+ - **Give each form a stable, unique `formId`.** This scopes drafts, upload orchestration and form status; several forms on one page must not share it.
288
+ - **Edit stored values.** Read with `useCrudDoc(entity, id, { translate: false })` before passing `defaultValues`; do not save translated record content back as the default-language value.
289
+ - **Submit through `form.handleSubmit`.** It validates/orchestrates the form; your submit callback performs the CRUD write (or omit it: `form.handleSubmit()` is the default writer, record + joined child rows in one `bulkAcross` — see [Child rows](#child-rows-saved-with-their-record); with a callback, add `form.pendingWrites()` to your write when child rows join the form or `extend` is set; record + 1:1 extensions with `extend`, see [1:1 extension](#11-extension-extend)). Reject on a failed write so submission does not acknowledge it as saved. Success acknowledges the editor snapshot taken before async validation, with pending upload previews replaced by the submitted stored assets. Upload normalization alone stays clean; later edits (including changes to upload fields) stay visible, dirty and in the local draft. Right before your callback runs, the editor is written to the local draft (no 3s autosave wait), so a rejected write keeps every edit even if the page has unmounted; success clears it.
290
+ - **Saving leaves the page by default (optimistic).** Once validation and uploads pass, the form navigates to `successPath` before your callback runs: omitted = the previous breadcrumb (nearest existing parent route, else `/`), a path = that path. If the callback rejects, it navigates back to the page it left and the draft restores the edits. Same option on `EntityFormRenderer` (`successPath`). Router access comes from `@donotdev/ui` (`UIProviders` fills crud's `FormNavigationProvider`); without it the form stays. Pass `successPath: null` to stay: dialogs, wizards, settings pages, create flows that open the new record, pages with other unsaved state (e.g. pending table edits), and **every** form of a nested submit (leaving unmounts the inner form and cancels its save). Per submit: `form.handleSubmit(onValid, onInvalid, { successPath })` overrides the hook option for that submit (key present wins, `undefined` = previous breadcrumb) — e.g. Save on a draft passes `null`, Publish on the same form passes nothing.
291
+ - **Page state saved by the same Save goes in the form's draft.** `const [ids, setIds] = useFormDraftState(form, 'productIds', initialIds, { parse })` is `useState` kept in the form's draft: autosaved with it, written at submit, restored with the form ("Draft restored" toast), reset by Discard / `resetForm`, cleared on success, kept on failure (also after the page left optimistically). Use it for product lists or pending table edits a page Save writes; values must be JSON. A value different from `initial` is an edit (it keeps the draft like a dirty field). `parse` (required) validates the value read back from browser storage (untrusted, possibly from an older page version) and may adjust it (e.g. drop pending edits that already equal the loaded record); if it throws, the slot keeps `initial` and a warning is logged.
292
+ - **A draft exists only while the page holds edits.** Edited = a field dirty in React Hook Form (against `defaultValues`, which always stay the base: the stored record on edit, the caller/schema defaults on create), a `useFormDraftState` slot different from its initial value, or joined child rows with edits. Autosave and the submit-time save write the draft only then, and clear it otherwise. A restored draft is applied as dirty edits on top of the base (`isDirty` / `dirtyFields` are right at once); one with no edit against the base is cleared without a toast.
293
+ - **Create defaults do not disable drafts.** With `operation: 'create'`, caller defaults override schema defaults, then restored drafts merge onto that base (nested objects merge; arrays replace). Discard restores the schema/caller base. Draft autosaving is browser-local only, including edits made while a submission is pending; it performs no CRUD writes. Leaving the page (unmount) writes a pending 3s autosave immediately, so an accidental leave keeps the last edits; the "Draft restored" toast offers Discard on return. There is no leave-time prompt.
294
+
295
+ **GOTCHA:** Do not override `t` with the page translator merely because it is in scope. That bypasses the entity namespace. Use the returned `form.t` for entity fields; keep the page's translator for page headings and actions.
296
+
127
297
  ---
128
298
 
129
299
  ## 5. Visibility & Access
@@ -209,11 +379,39 @@ You never need to configure pagination mode. It just works.
209
379
 
210
380
  Server mode fetches only `pageSize` items per request - not the whole collection.
211
381
 
382
+ ### Reading Data to Render (CSR + SSR)
383
+
384
+ Data a page **renders** comes from the read hooks, never from `useCrud` actions in a `useEffect`.
385
+ The hooks read through the CRUD cache, which the server fills during the render (Next.js SSR):
386
+ the first HTML carries the content (SEO, AI search). Effects never run on the server, so
387
+ `get(id)` / `query()` in a `useEffect` ships a loader instead of the page.
388
+
389
+ | Render | Hook |
390
+ |--------|------|
391
+ | One record (detail / edit page) | `useCrudDoc(entity, id)` - pass `null` to wait (e.g. `id === 'new'`) |
392
+ | A list (admin, filters, search) | `useCrudList(entity, options)` |
393
+ | A public list (cards) | `useCrudCardList(entity, options)` |
394
+
395
+ ```tsx
396
+ // Correct: server-rendered, reactive to every edit
397
+ const { data: product, loading, notFound } = useCrudDoc(productEntity, id);
398
+
399
+ // WRONG: client-only, the server HTML is a spinner
400
+ const { get } = useCrud(productEntity);
401
+ useEffect(() => { get(id).then(setProduct); }, [id, get]);
402
+ ```
403
+
404
+ **Next: who the server read is for.** The generated per-request layout (visitors with an auth cookie) passes the request's cookies to
405
+ `NextJsAppProviders` (CLI template), so server reads run as the visitor (their access token) and
406
+ the first paint is final. Nothing to do in pages.
407
+
408
+ `get` / `query` stay for imperative reads in event handlers (button click, submit, export).
409
+
212
410
  ---
213
411
 
214
- ## 8. Bulk / Transactional CRUD
412
+ ## 8. Bulk CRUD (partial success)
215
413
 
216
- For multi-row saves (wizard forms, reorder lists, "apply to selected", import flows). One call, one transaction, one toast.
414
+ For multi-row saves (editable lists, "apply to selected", reorder lists). One call, one toast. Update 100 rows: if 90 work and 10 fail, the 90 stay written and `failed` says which 10 and why.
217
415
 
218
416
  ```tsx
219
417
  const { bulk } = useCrud<Event>(eventEntity);
@@ -223,22 +421,23 @@ await bulk({
223
421
  updates: editedEvents.map(e => ({ id: e.id, patch: e })),
224
422
  deletes: removedEventIds,
225
423
  });
226
- // { insertedIds, updatedIds, deletedIds } — input order preserved per bucket.
424
+ // { insertedIds, updatedIds, deletedIds, failed } — written ids in input order per bucket;
425
+ // failed: [{ op: 'update', id: 'e7', error: 'Update affected 0 rows: … access denied' }]
227
426
  ```
228
427
 
229
428
  **Non-negotiable semantics:**
230
429
 
231
430
  | # | Guarantee |
232
431
  |---|-----------|
233
- | 1 | **Atomic.** All ops commit or none do. Adapter uses one transaction (Firestore `writeBatch` / Postgres `crud_bulk` RPC / GraphQL mutation / REST `POST /:col/bulk`). |
234
- | 2 | **One round-trip.** Single network call. |
235
- | 3 | **One toast.** Success once if any op succeeded. `{ showSuccessToast: false }` suppresses. |
432
+ | 1 | **Partial success, no rollback.** Each row succeeds or fails on its own; written rows stay written; `failed` lists the others with the reason. Supabase writes directly under RLS (no edge function): deletes `.in(id)`, inserts as one array insert, updates grouped by identical patch ("one value on N rows" = one request); rows RLS skips are reported failed. Firestore `writeBatch`, GraphQL and REST endpoints commit their batch as one unit (`failed` is empty, or the call throws). |
433
+ | 2 | **Few round-trips.** One adapter call; Supabase chunks ids (100) and runs requests 6 at a time. |
434
+ | 3 | **One toast.** Error toast with the failed count when rows failed, else success once if any op succeeded. `{ showSuccessToast: false }` suppresses the success toast. |
236
435
  | 4 | **One audit entry.** `crud.bulk` with `{ inserts, updates, deletes }` counts. Anomaly detection on `bulk.deletes` fires on the bulk count, not the row count. |
237
436
  | 5 | **One rate-limit hit.** Checked at entry, not per op. |
238
- | 6 | **Validation up-front.** Inserts against `create` schema, updates against `update` schema. Any failure rejects before any write. |
437
+ | 6 | **Validation up-front.** Inserts against `create` schema before the adapter call. |
239
438
  | 7 | **Collision rejection.** Same id in `updates` + `deletes`, or `inserts` + `updates`, throws `BulkCollisionError` before any write. |
240
439
  | 8 | **Empty bulk is a no-op.** `bulk({})` returns zeroed result without hitting the wire. |
241
- | 9 | **Optimistic.** Store applies all 3 buckets atomically; rolls back all on rejection. |
440
+ | 9 | **Optimistic.** Store applies all 3 buckets; confirms the rows written, reverts only the rows in `failed`. If the call throws (batch not attempted: no session, collision), everything is reverted. |
242
441
 
243
442
  Catch the specific error for collision handling:
244
443
 
@@ -260,6 +459,98 @@ try {
260
459
 
261
460
  See `lookup_symbol("BulkOperations")`, `lookup_symbol("BulkResult")`, `lookup_symbol("BulkCollisionError")`.
262
461
 
462
+ ### Cross-collection `bulkAcross`
463
+
464
+ **Toasts:** one success toast `crud:messages.updateSuccess` named after the first batch's collection (the primary record, like `bulk`), or `options.successMessage` (translated by the caller); the error toast is named the same way.
465
+
466
+ By default `bulkAcross(batches, options?)` is ordered partial-success bulk, **not a database
467
+ transaction**. Each batch supplies its collection, schemas and optional
468
+ `dependsOn`; independent batches run in parallel waves. Success returns
469
+ `{ results: Record<string, BulkResult> }` unchanged.
470
+
471
+ A rejection or non-empty `failed` stops subsequent waves. All bounded timeout
472
+ outcomes in the started wave settle before all optimistic changes are reverted;
473
+ only then are collections invalidated/refetched. Raw attempts are observed, not
474
+ awaited indefinitely. Any raw attempt settling after rollback or successful
475
+ confirmation queues an authoritative refetch, serialized behind initial/late
476
+ refetches, with no stale optimistic patches. Late refetch errors are caught and
477
+ reported, never substituted for the original write error. The call rejects through
478
+ the existing `handleError` normalization (not guaranteed error identity), rather
479
+ than returning partial results. Written rows remain written: a product insert
480
+ survives a dependent offer failure. Optimistic rollback is not database rollback.
481
+ Refetch failures cannot guarantee a fresh cache.
482
+
483
+ Cross-collection bulk writes use the existing timeout without automatic retry:
484
+ a timeout/network failure may have committed already. Late reconciliation prevents
485
+ stale cache races, not duplicate writes; do not blindly resubmit the whole operation. A forever-pending
486
+ raw attempt does not delay caller completion/loading cleanup after bounded outcomes
487
+ and initial refetches; its commit status remains unknown until settlement. Refetch
488
+ completion behavior is unchanged. Global retry policy/provider guarantees are
489
+ separate preexisting work.
490
+
491
+ For a single database commit, request `{ execution: 'atomic' }`. The configured
492
+ adapter must advertise the atomic capability or the call rejects before optimistic
493
+ changes, including for empty requests. The service preflights the complete request,
494
+ then executes its snapshot-bound plan once without retry; legacy void preflight uses
495
+ `execute(prepared)`. Malformed non-void plans reject before optimism.
496
+ `AtomicBulkError.outcome` is `not-committed` only
497
+ when definitive; `unknown` requires authoritative reconciliation, not replay.
498
+ Pre-mint referenced IDs; no automatic reference remapping occurs. Provider-owned
499
+ emulator and security-rule tests remain the gate for deployment guarantees. See
500
+ `docs/architecture/BULK_ACROSS.md`.
501
+
502
+ **F05 — request-aware acknowledgements.** `validateBulkOutcome` uses additive
503
+ `BulkOutcomeSchema` to preserve per-row `failed` (insert index; update/delete ID)
504
+ and checks exactly one outcome per submitted operation, counts, multiplicity and
505
+ update/delete order before confirmations or downstream waves. Omitted `failed`
506
+ is legacy complete-success only after those checks; malformed/incomplete replies
507
+ mean unknown commit status, not proof of rollback. Cleanup removes this call's
508
+ pending optimistic entries before authoritative refetch; original write errors
509
+ must survive reconciliation errors. Functions/REST/GraphQL decoding preserves
510
+ failures when present. The legacy GraphQL selection/SDL exposes only success ID
511
+ arrays: partial replies without failure identities reject, rather than silently
512
+ succeed. Server-generated insert ID correspondence/order remains unprovable
513
+ without an input-index echo; explicit insert IDs are not a universal provider
514
+ guarantee. F05 does not close these legacy provider protocol gaps.
515
+
516
+ ---
517
+
518
+ ## 9. Filters (`EntityFilters`, `useCrudFilters`, `applyFilters`)
519
+
520
+ `EntityFilters` (`@donotdev/crud`) builds one filter per filterable field of `fieldsToFilter` (default: `listFields`, else all fields) visible to `viewerRole`, and reads/writes the filter state of `useCrudFilters({ collection: filterKey ?? entity.collection })`. `useCrudList` / `useCrudCardList` (and `EntityList` / `EntityCardList`) apply the state of their collection with `applyFilters`: every field filter must match (AND across fields).
521
+
522
+ **Matching per filter type** (`getFilterType(field.type)`, `matchesFilter`):
523
+
524
+ | Filter type | Field types | UI | Match |
525
+ |---|---|---|---|
526
+ | `select` | `select`, `combobox`, `radio`, `boolean`, `checkbox`, `switch` | Multi-select of `validation.options` (translated labels; else the values in the data) | Exact, case-sensitive value; several selected values = OR (`['serum', 'essence']`) |
527
+ | `multiselect` | `multiselect` | Multi-select of `validation.options` | Any of the row's items is selected (`['dry','oily']` matches `['oily']`) |
528
+ | `reference` | `reference` (custom types with `validation.reference`: register `filterType: 'reference'`) | Multi-select of the ids in the data, labelled like list cells (`useReferenceResolver`: `labelFields` / `displayField`; raw id until resolved or when the document is unknown) | Exact id; several = OR |
529
+ | `text`, `address` | text-like types, `address` | One value among the data's values | Case-insensitive substring (`address`: of `formatted_address`) |
530
+ | `range` | number, price (`amount`), date, year... | Min/max | Inclusive; min-only excludes empty values, max-only keeps them |
531
+ | `rating` | `rating` | Stars | At least the value |
532
+
533
+ Options are counted per stored value from the rows matching the other filters (array values: per item) and disabled at 0. Chips show the option's translated label / the reference's resolved label. A multi-select shows its selection: the label of one value, `filters.selected` (`{{count}} selected`, pluralised) for several. A filter state value may be a string or an array for option fields (`setFilters({ type: 'toner' })` still works); `EntityFilters` writes arrays.
534
+
535
+ **Wildcard value** (`field.filter.wildcard`, since 0.3.0): a stored value meaning "every option".
536
+
537
+ ```typescript
538
+ skinTypes: { name: 'skinTypes', type: 'multiselect', filter: { wildcard: 'all' }, validation: { options: [...] }, ... }
539
+ ```
540
+
541
+ `all` is not offered as a filter choice; a row holding it (value or array item) matches any selection of that field and counts for every option. Applies to `select`, `multiselect` and `reference` filters (`applyFilters`, `EntityFilters`; direct `matchesFilter` callers pass `field.filter` as 4th argument).
542
+
543
+ **URL sync** (since 0.3.0): a filter state syncs with the URL when its key is the collection of an entity defined with `defineEntity` (the page list's state). Pickers and dialogs with a custom `filterKey` never touch the URL.
544
+
545
+ | | |
546
+ |---|---|
547
+ | Write | `setFilters` → `history.replaceState` after 500ms (router state and hash kept), dropped if the page changed meanwhile. Only the entity's own `f_*` params are rewritten. |
548
+ | Read | Page mount (`useCrudFilters` effect: render never writes the store; the first client render already shows the URL's filters), and every URL change: back/forward, router navigations, links (Navigation API `currententrychange`; without it, `popstate` + mount). A URL without params clears the state. Server render and hydration: no filters (no hydration mismatch), the URL's apply right after. |
549
+ | Format | `f_<field>=<value>` percent-encoded (commas safe). Option fields (`select`, `multiselect`, `reference`): one param per value, always read back as an array (`?f_type=serum&f_type=essence`). Ranges: `f_<field>_min` / `f_<field>_max`. Text: one param, a string. Field types decide, not the value. |
550
+ | Opt-out / in | `useCrudFilters({ collection: 'products', urlSync: false })` (or `<EntityFilters urlSync={false} />`); a custom key: `<EntityFilters filterKey="products#dialog" urlSync />` (`useCrudFilters` needs `entity` then). Store level: `useCrudStore.getState().setFilterUrlSync(key, entity \| null)`. |
551
+
552
+ One URL-synced state per page: another collection's list on the same page reads the same `f_<field>` params when field names coincide (e.g. `f_status`); set `urlSync: false` on it.
553
+
263
554
  ---
264
555
 
265
556
  ## What's Available
@@ -297,12 +588,15 @@ See `lookup_symbol("BulkOperations")`, `lookup_symbol("BulkResult")`, `lookup_sy
297
588
  > Put destructured methods in dependency arrays, never the whole object.
298
589
  >
299
590
  > ```tsx
300
- > const { query, add } = useCrud<Car>(carEntity); // Correct
301
- > useEffect(() => { query({...}).then(setRows); }, [query]); // Stable dep
591
+ > const { query, add } = useCrud<Car>(carEntity); // Correct
592
+ > const onExport = useCallback(() => query({...}).then(download), [query]); // Stable dep
302
593
  >
303
- > const crud = useCrud(carEntity); // WRONG
304
- > useEffect(() => { crud.query(...); }, [crud]); // Infinite loop
594
+ > const crud = useCrud(carEntity); // WRONG
595
+ > const onExport = useCallback(() => crud.query({...}), [crud]); // New callback every render
305
596
  > ```
597
+ >
598
+ > Rendering data? Use `useCrudDoc` / `useCrudList` / `useCrudCardList`, not `get`/`query`
599
+ > in a `useEffect` (see [Reading Data to Render](#reading-data-to-render-csr--ssr)).
306
600
 
307
601
  | Hook | One-liner |
308
602
  |------|-----------|
@@ -310,8 +604,9 @@ See `lookup_symbol("BulkOperations")`, `lookup_symbol("BulkResult")`, `lookup_sy
310
604
  | `useCrudDoc` | One document, reactive to every edit/delete (detail pages) |
311
605
  | `useCrudList` | Real-time list with search, filters, sort applied |
312
606
  | `useCrudCardList` | Same as `useCrudList`, optimized for public card views |
313
- | `useCrudFilters` | Filter state per collection, auto-consumed by list hooks |
607
+ | `useCrudFilters` | Filter state per collection (URL-synced for entity collections, see [Filters](#9-filters-entityfilters-usecrudfilters-applyfilters)), auto-consumed by list hooks |
314
608
  | `useEntityForm` | Form state for custom form layouts |
609
+ | `useChildRows` | A record's child rows, joined to the form open on it and saved by its Save |
315
610
  | `useEntityField` | Single-field control for custom form layouts |
316
611
  | `useEntityFavorites` | Local favorites (localStorage) |
317
612
  | `useRelatedItems` | Fetch related items by reference field |
@@ -323,10 +618,10 @@ See `lookup_symbol("BulkOperations")`, `lookup_symbol("BulkResult")`, `lookup_sy
323
618
  | Utility | One-liner |
324
619
  |---------|-----------|
325
620
  | `formatValue` | Format any field value for display |
326
- | `applyFilters` / `applySearch` / `applySort` | Processing pipeline (what `useCrudList` does internally) |
621
+ | `applyFilters` / `applySearch` / `applySort` | Processing pipeline (what `useCrudList` does internally); `matchesFilter` one value ([Filters](#9-filters-entityfilters-usecrudfilters-applyfilters)) |
327
622
  | `registerFieldType` | Register custom field type |
328
623
  | `validateEntity` | Validate entity data against schemas |
329
- | `isFieldEditable` / `getFieldsForOperation` | Field visibility helpers |
624
+ | `isFieldEditable(entity, field, role, op)` / `getFieldsForOperation` | Field editability / form fields, from the entity descriptor |
330
625
 
331
626
  ### Routing (`@donotdev/ui`)
332
627
 
@@ -354,6 +649,10 @@ See `lookup_symbol("BulkOperations")`, `lookup_symbol("BulkResult")`, `lookup_sy
354
649
  | **Complex** | `geopoint`, `address`, `map`, `array` |
355
650
  | **Special** | `avatar`, `badge`, `hidden`, `submit`, `reset` |
356
651
 
652
+ **Field options placement** (as typed by `UIFieldOptions`):
653
+ - Upload types (`file`, `files`, `document`, `documents`, `image`, `images`): `options.fieldSpecific.maxSize` (bytes), `options.fieldSpecific.storagePath`. Top-level `options.maxSize` / `options.storagePath` are ignored.
654
+ - `range`: `options.showValue` (top level, not under `fieldSpecific`).
655
+
357
656
  ---
358
657
 
359
658
  ## Custom Field Types (escape hatch)
@@ -383,7 +682,11 @@ registerFieldType({
383
682
  });
384
683
  ```
385
684
 
386
- Then use in entity: `tier: { name: 'tier', label: 'tier', type: 'statusTier', visibility: 'guest' }`
685
+ Then use in entity, with its value shape: `tier: { name: 'tier', label: 'tier', type: 'statusTier', visibility: 'guest', validation: { schema: v.picklist(['basic', 'premium']) } }`
686
+
687
+ `registerFieldType` is UI-only (client code, invisible to server functions and generators): the entity says the stored value. A custom type needs `validation.schema` (Valibot schema of the stored value) or `validation.reference` (referenced collection: the value is an id). Without either, `defineEntity` throws, naming `entity.field`. Value order, everywhere: `validation.schema` > `validation.reference` > built-in type (`BUILTIN_VALUES`, `@donotdev/core`).
688
+
689
+ Custom display formatters render cards/lists only: entity SEO (`deriveEntitySeo`, also on the Next server) shows a custom type's raw value. For a translated label in both, use the field's `options.displayValue` (or the entity `seo.title`).
387
690
 
388
691
  See `lookup_symbol("registerFieldType")`, `lookup_symbol("ControlledFieldProps")`.
389
692
 
@@ -399,6 +702,22 @@ See `lookup_symbol("registerFieldType")`, `lookup_symbol("ControlledFieldProps")
399
702
 
400
703
  Status labels: entity namespace -> `crud` namespace fallback.
401
704
 
705
+ ### Translated content (`i18n: true`, since 0.2.3)
706
+
707
+ Labels above are UI strings. **Record values** (a product description) are translated per field:
708
+
709
+ ```typescript
710
+ description: { name: 'description', label: 'fields.description', type: 'textarea', visibility: 'guest', i18n: true },
711
+ ```
712
+
713
+ - Types: `text`, `textarea`, `richtext`, `field-array`. Any other type throws when schemas are built.
714
+ - Storage: the field keeps the **default language** (`i18n.fallbackLanguage`). The other languages live in the companion `descriptionI18n` (`{ en: '…', de: '…' }`); Supabase column `description_i18n jsonb NOT NULL DEFAULT '{}'` (the SQL generator emits it; existing tables need the `ADD COLUMN`), Firestore nested map. Same visibility as the field.
715
+ - Reads: `useCrudDoc`, `useCrudList`, `useCrudCardList` (and reference labels) return the field in the **current language**. Missing or empty translation → the stored default-language value. The cache keeps stored rows, so a language switch re-renders without a request. Client sort/filter/search see the current language.
716
+ - **Edit forms: `translate: false`** (`useCrudDoc(entity, id, { translate: false })`), or the form would load a translation and save it as the default-language value.
717
+ - Writes: send `descriptionI18n` with the other fields (validated per language like the field, never required). The default language is never stored in the map.
718
+ - Column not migrated yet (Supabase): the read gets Postgres 42703, the adapter leaves that `_i18n` column out for the table, retries, and warns once. The page serves the default language, no error. Other missing columns still throw. Firestore: a document without the map is valid. GraphQL adapter: not covered (selects every schema field).
719
+ - Not translated: `useCrud().get/query` (stored rows), server sort/where (default language only), slugs.
720
+
402
721
  ---
403
722
 
404
723
  **Define entity -> register provider -> register functions -> drop components. Entity is the SSOT - everything flows from it.**
@@ -6,6 +6,10 @@ Common mistakes related to entity definition, forms, fields, and CRUD operations
6
6
 
7
7
  ## CRUD [Phase 2, 3]
8
8
 
9
+ **GOTCHA: Do not override `useEntityForm` translations accidentally.** The hook automatically binds `[entity.namespace, 'crud']`; normal usage requires no `t` option, even on multi-entity pages. Pass its returned `form.t` to field renderers. Supply your own `options.t` only to intentionally bypass that namespace resolution: it replaces the default translator completely. Passing a page-bound `t` can therefore hide entity labels/options. Never copy entity strings into page locales. The hook still defaults `viewerRole` to `'guest'`, so pass the actual role. See CRUD → Custom Forms.
10
+
11
+ **Never `get(id)` / `query()` in a `useEffect` to render data.** Effects don't run on the server: on Next.js (SSR) the page HTML is a loader, invisible to crawlers and AI search. Use `useCrudDoc(entity, id)` for one record, `useCrudList` / `useCrudCardList` for lists: they read through the CRUD cache, which the server fills during the render.
12
+
9
13
  **Hidden fields are auto-added by `defineEntity()` - don't define them manually:**
10
14
  - `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`
11
15
 
@@ -25,6 +29,20 @@ status: { visibility: 'technical' }
25
29
 
26
30
  **Scope field is auto-added** when `scope` is configured. Don't manually define the scope field (e.g., `companyId`).
27
31
 
32
+ **Empty is `null`, never `''`.** Entity forms store an empty text input as `null` (form state, validated data, adapter payload); `''` exists only in the DOM. An optional field left empty passes its format rules; a `required` field left empty fails.
33
+
34
+ **Field `type` is a closed union.** Built-ins plus the custom types declared in `CustomFieldOptionsMap` (module augmentation of `@donotdev/core`). A typo or an undeclared custom type fails typecheck; a declared type with no `registerFieldType()` throws at render. No text-input fallback.
35
+
36
+ **`datetime-local` stores an ISO instant, displays local time.** The form shows the viewer's local wall time and saves `toISOString()` (UTC). Do not convert in the app.
37
+
38
+ **Filters on option fields are exact, not substring.** `select` / `radio` / `multiselect` / `reference` filters match the stored code or id exactly (`toner` never matches `toner_pad`); only text filters are substring. A stored "suits everything" value (`['all']`) needs `filter: { wildcard: 'all' }` on the field, never an extra filter option. See CRUD.md "Filters".
39
+
40
+ **Picker / dialog filters: give `EntityFilters` a `filterKey`.** Without it, the dialog shares (and URL-syncs) the page list's filter state. A custom key never touches the URL unless `urlSync` is set. See CRUD.md "Filters" (URL sync).
41
+
42
+ **Several forms on one record: give each a stable `formId`.** The auto-saved draft key includes it.
43
+
44
+ **A field the form does not render must not be `required` without a value.** Form validation uses the static `validation`: a required field hidden by `visibility` (role), `editable` or `conditions.visible` fails on submit unless its value comes in through `defaultValues`. The scope field is the exception: the form injects it from the scope provider before validating, as `add()` does.
45
+
28
46
  **Custom form fields MUST use framework's `useController`:**
29
47
 
30
48
  ```typescript
@@ -41,6 +59,6 @@ import { useController } from '@donotdev/crud';
41
59
 
42
60
  **File uploads are deferred** - files upload on form submit, not on selection. Images show optimistic blob URLs.
43
61
 
44
- **Generated/computed fields are auto-excluded from forms.** Fields with `editable: 'generated'` (DB-generated columns) or `editable: 'computed'` (UI-derived values) are silently filtered out by `getFieldsForOperation`. They won't appear in create or edit forms. Use `'generated'` for PostgreSQL `GENERATED ALWAYS` columns. Use `'computed'` for fields derived from other form values (still included in write payloads).
62
+ **Generated fields are excluded from forms; computed fields are shown read-only.** Fields with `editable: 'generated'` (DB-generated columns) are left out of create and edit forms and never written. Fields with `editable: 'computed'` (UI-derived values) are shown read-only by `getFieldsForOperation` (`editable: false`, `written: true`), kept in form state and written by the default writer. Use `'generated'` for PostgreSQL `GENERATED ALWAYS` columns. Use `'computed'` for fields derived from other form values.
45
63
 
46
64
  **Entity namespace defaults to `entity-{name}`** (lowercase). Translation files must match: `locales/entity-product_en.json`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/crud",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,20 +56,20 @@
56
56
  "@dnd-kit/core": "^6.3.1",
57
57
  "@dnd-kit/sortable": "^10.0.0",
58
58
  "@dnd-kit/utilities": "^3.2.2",
59
- "@donotdev/components": "^0.2.2",
60
- "@donotdev/core": "^0.2.2",
59
+ "@donotdev/components": "^0.3.0",
60
+ "@donotdev/core": "^0.3.0",
61
61
  "react-easy-crop": "^5.5.7"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@hookform/resolvers": "^5.9.2",
65
- "@tiptap/extension-placeholder": "^3.33.0",
66
- "@tiptap/pm": "^3.33.0",
67
- "@tiptap/react": "^3.33.0",
68
- "@tiptap/starter-kit": "^3.33.0",
65
+ "@tiptap/extension-placeholder": "^3.33.1",
66
+ "@tiptap/pm": "^3.33.1",
67
+ "@tiptap/react": "^3.33.1",
68
+ "@tiptap/starter-kit": "^3.33.1",
69
69
  "lucide-react": "^0.575.0",
70
70
  "react": "^19.3.1",
71
71
  "react-dom": "^19.3.1",
72
- "react-hook-form": "^7.91.0",
72
+ "react-hook-form": "^7.92.0",
73
73
  "valibot": "^1.5.0"
74
74
  },
75
75
  "peerDependenciesMeta": {
@@ -1,23 +0,0 @@
1
- /**
2
- * @fileoverview Built-in Field Type Registrations — legacy compatibility shim.
3
- *
4
- * Registration is now handled at the source: `fieldTypeRegistry.ts` imports
5
- * `registerBuiltinFieldTypes.tsx` as a side-effect, guaranteeing built-ins are
6
- * available for every code path (display, form, filter, Expo).
7
- *
8
- * This file is kept solely for backward compatibility — existing consumers that
9
- * import `registerBuiltinFieldTypes` from `@donotdev/crud` still get a no-op
10
- * function that won't break their startup code.
11
- *
12
- * For custom field types, use `registerFieldType()` from `@donotdev/crud`.
13
- *
14
- * @version 0.1.0
15
- * @since 0.0.1
16
- * @author AMBROISE PARK Consulting
17
- */
18
- /**
19
- * @deprecated No-op. Built-in registration is now automatic (lazy on first access).
20
- * Kept for API compatibility with consumers that call this at app startup.
21
- */
22
- export declare function registerBuiltinFieldTypes(): void;
23
- //# sourceMappingURL=builtinFieldTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builtinFieldTypes.d.ts","sourceRoot":"","sources":["../src/builtinFieldTypes.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
@@ -1 +0,0 @@
1
- "use client";function e(){}export{e as registerBuiltinFieldTypes};