@donotdev/ui 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 (199) hide show
  1. package/dist/ChildRowsPicker-63M4EQUQ.js +1 -0
  2. package/dist/ChildRowsPicker-ISP365ON.js +1 -0
  3. package/dist/ChildRowsPicker-PQFE6NCR.js +1 -0
  4. package/dist/ChildRowsPicker-XXFFSMWY.js +1 -0
  5. package/dist/{GoToDialog-CICRYHHG.js → GoToDialog-KSBGOIWO.js} +1 -1
  6. package/dist/{GoToDialog-YGBON6FR.js → GoToDialog-XBK5EZF4.js} +1 -1
  7. package/dist/chunk-3CIZFGST.js +1 -0
  8. package/dist/chunk-LHMKU342.js +1 -0
  9. package/dist/chunk-MS7ZIW5Z.js +1 -0
  10. package/dist/chunk-P2DHZWPY.js +1 -0
  11. package/dist/components/auth/AuthHeader.d.ts.map +1 -1
  12. package/dist/components/auth/AuthHeader.js +0 -2
  13. package/dist/components/auth/AuthMenu.d.ts.map +1 -1
  14. package/dist/components/auth/AuthMenu.js +6 -40
  15. package/dist/components/common/icon.d.ts.map +1 -1
  16. package/dist/components/common/icon.js +2 -1
  17. package/dist/components/common/lucideIconByName.d.ts +9 -0
  18. package/dist/components/common/lucideIconByName.d.ts.map +1 -0
  19. package/dist/components/common/lucideIconByName.js +32 -0
  20. package/dist/components/layout/GameFlow.d.ts.map +1 -1
  21. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  22. package/dist/components/layout/components/Breadcrumbs.js +18 -12
  23. package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
  24. package/dist/components/layout/components/header/CacheSettings.js +6 -4
  25. package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
  26. package/dist/components/layout/components/header/SettingsMenu.js +4 -3
  27. package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
  28. package/dist/components/layout/components/header/ThemeToggle.js +2 -1
  29. package/dist/crud/components/ChildRowsPicker.d.ts +21 -0
  30. package/dist/crud/components/ChildRowsPicker.d.ts.map +1 -0
  31. package/dist/crud/components/ChildRowsPicker.js +68 -0
  32. package/dist/crud/components/CrudCardLink.d.ts +6 -6
  33. package/dist/crud/components/CrudCardLink.d.ts.map +1 -1
  34. package/dist/crud/components/CrudCardLink.js +3 -9
  35. package/dist/crud/components/EntityCardList.d.ts.map +1 -1
  36. package/dist/crud/components/EntityCardList.js +10 -26
  37. package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
  38. package/dist/crud/components/EntityDisplayRenderer.js +6 -3
  39. package/dist/crud/components/EntityFormRenderer.d.ts +4 -2
  40. package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
  41. package/dist/crud/components/EntityFormRenderer.js +160 -56
  42. package/dist/crud/components/EntityList.d.ts +6 -4
  43. package/dist/crud/components/EntityList.d.ts.map +1 -1
  44. package/dist/crud/components/EntityList.js +437 -92
  45. package/dist/crud/components/EntityRecommendations.js +1 -1
  46. package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
  47. package/dist/crud/components/EntityWorkflow.js +6 -4
  48. package/dist/crud/components/Form.d.ts +1 -1
  49. package/dist/crud/components/Form.d.ts.map +1 -1
  50. package/dist/crud/components/Form.js +2 -2
  51. package/dist/crud/components/cellEditFor.d.ts +43 -0
  52. package/dist/crud/components/cellEditFor.d.ts.map +1 -0
  53. package/dist/crud/components/cellEditFor.js +74 -0
  54. package/dist/crud/components/entityParent.d.ts +33 -0
  55. package/dist/crud/components/entityParent.d.ts.map +1 -0
  56. package/dist/crud/components/entityParent.js +76 -0
  57. package/dist/crud/components/useRecordBreadcrumb.d.ts +11 -0
  58. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -0
  59. package/dist/crud/components/useRecordBreadcrumb.js +43 -0
  60. package/dist/crud/crudImports.d.ts +12 -1
  61. package/dist/crud/crudImports.d.ts.map +1 -1
  62. package/dist/crud/crudImports.js +11 -0
  63. package/dist/dndev-next.css +782 -193
  64. package/dist/dndev.css +784 -193
  65. package/dist/index.js +4 -4
  66. package/dist/internal/common/RouteErrorFallback.d.ts.map +1 -1
  67. package/dist/internal/common/RouteErrorFallback.js +2 -4
  68. package/dist/internal/devtools/components/ConfigTab.d.ts.map +1 -1
  69. package/dist/internal/devtools/components/ConfigTab.js +1 -1
  70. package/dist/internal/devtools/components/CookieTab.d.ts.map +1 -1
  71. package/dist/internal/devtools/components/CookieTab.js +1 -5
  72. package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
  73. package/dist/internal/devtools/components/DesignTab.js +18 -7
  74. package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
  75. package/dist/internal/devtools/components/StoresTab.js +17 -3
  76. package/dist/internal/devtools/types.d.ts +3 -3
  77. package/dist/internal/devtools/types.d.ts.map +1 -1
  78. package/dist/internal/devtools/utils/maskSensitive.d.ts +1 -1
  79. package/dist/internal/devtools/utils/maskSensitive.d.ts.map +1 -1
  80. package/dist/internal/initializers/NextJsStoresInitializer.d.ts +3 -0
  81. package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
  82. package/dist/internal/initializers/NextJsStoresInitializer.js +8 -1
  83. package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
  84. package/dist/internal/layout/DnDevLayout.js +21 -21
  85. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  86. package/dist/internal/layout/components/AutoMetaTags.js +42 -38
  87. package/dist/internal/layout/components/FontPreloadLinks.d.ts +7 -4
  88. package/dist/internal/layout/components/FontPreloadLinks.d.ts.map +1 -1
  89. package/dist/internal/layout/components/FontPreloadLinks.js +12 -25
  90. package/dist/internal/layout/components/footer/FooterCopyright.d.ts +2 -0
  91. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  92. package/dist/internal/layout/components/footer/FooterCopyright.js +4 -0
  93. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +2 -1
  94. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  95. package/dist/internal/layout/components/footer/useLegalLinks.js +4 -3
  96. package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +1 -1
  97. package/dist/internal/layout/components/i18nSeoMeta.js +1 -0
  98. package/dist/internal/layout/zones/DnDevMergedBar.js +3 -3
  99. package/dist/internal/providers/UIProviders.d.ts +0 -8
  100. package/dist/internal/providers/UIProviders.d.ts.map +1 -1
  101. package/dist/internal/providers/UIProviders.js +45 -2
  102. package/dist/providers/NextJsAppProviders.d.ts +5 -1
  103. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  104. package/dist/providers/NextJsAppProviders.js +36 -6
  105. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  106. package/dist/providers/ViteAppProviders.js +42 -7
  107. package/dist/routing/404.d.ts +8 -1
  108. package/dist/routing/404.d.ts.map +1 -1
  109. package/dist/routing/404.js +9 -5
  110. package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
  111. package/dist/routing/AuthGuardFallback.js +1 -2
  112. package/dist/routing/AuthReturnTo.d.ts.map +1 -1
  113. package/dist/routing/AuthReturnTo.js +9 -2
  114. package/dist/routing/GoTo.d.ts +0 -6
  115. package/dist/routing/GoTo.d.ts.map +1 -1
  116. package/dist/routing/GoTo.js +5 -8
  117. package/dist/routing/Link.d.ts +4 -2
  118. package/dist/routing/Link.d.ts.map +1 -1
  119. package/dist/routing/Link.js +8 -5
  120. package/dist/routing/SignedInRedirect.d.ts +27 -0
  121. package/dist/routing/SignedInRedirect.d.ts.map +1 -0
  122. package/dist/routing/SignedInRedirect.js +47 -0
  123. package/dist/routing/hooks/hooks.next.d.ts +2 -0
  124. package/dist/routing/hooks/hooks.next.d.ts.map +1 -1
  125. package/dist/routing/hooks/hooks.next.js +1 -1
  126. package/dist/routing/hooks/hooks.vite.d.ts +2 -0
  127. package/dist/routing/hooks/hooks.vite.d.ts.map +1 -1
  128. package/dist/routing/hooks/hooks.vite.js +1 -1
  129. package/dist/routing/hooks/useLocation.next.d.ts +12 -0
  130. package/dist/routing/hooks/useLocation.next.d.ts.map +1 -1
  131. package/dist/routing/hooks/useLocation.next.js +17 -4
  132. package/dist/routing/hooks/useMatch.next.d.ts +6 -0
  133. package/dist/routing/hooks/useMatch.next.d.ts.map +1 -1
  134. package/dist/routing/hooks/useMatch.next.js +8 -2
  135. package/dist/routing/hooks/useNavigate.next.d.ts +6 -1
  136. package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
  137. package/dist/routing/hooks/useNavigate.next.js +13 -4
  138. package/dist/routing/hooks/useNavigate.vite.d.ts +7 -1
  139. package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
  140. package/dist/routing/hooks/useNavigate.vite.js +20 -4
  141. package/dist/routing/hooks/useRedirectGuard.next.d.ts +3 -1
  142. package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
  143. package/dist/routing/hooks/useRedirectGuard.next.js +18 -10
  144. package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
  145. package/dist/routing/hooks/useRedirectGuard.vite.js +7 -1
  146. package/dist/routing/hooks/useRoutePath.next.d.ts +23 -0
  147. package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -0
  148. package/dist/routing/hooks/useRoutePath.next.js +36 -0
  149. package/dist/routing/hooks/useRoutePath.vite.d.ts +13 -0
  150. package/dist/routing/hooks/useRoutePath.vite.d.ts.map +1 -0
  151. package/dist/routing/hooks/useRoutePath.vite.js +25 -0
  152. package/dist/routing/hooks/useUrlLanguage.next.d.ts +28 -0
  153. package/dist/routing/hooks/useUrlLanguage.next.d.ts.map +1 -0
  154. package/dist/routing/hooks/useUrlLanguage.next.js +50 -0
  155. package/dist/routing/hooks/useUrlLanguage.vite.d.ts +22 -0
  156. package/dist/routing/hooks/useUrlLanguage.vite.d.ts.map +1 -0
  157. package/dist/routing/hooks/useUrlLanguage.vite.js +41 -0
  158. package/dist/routing/index.d.ts +3 -1
  159. package/dist/routing/index.d.ts.map +1 -1
  160. package/dist/routing/index.js +2 -1
  161. package/dist/routing/parentRoute.d.ts +27 -0
  162. package/dist/routing/parentRoute.d.ts.map +1 -0
  163. package/dist/routing/parentRoute.js +43 -0
  164. package/dist/routing/useNavigation.d.ts.map +1 -1
  165. package/dist/routing/useNavigation.js +8 -27
  166. package/dist/routing/useRouteDiscovery.d.ts +2 -2
  167. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  168. package/dist/routing/useRouteDiscovery.js +6 -5
  169. package/dist/styles/index.css +781 -192
  170. package/dist/symbol-index.json +1 -1
  171. package/dist/utils/assetResolver.d.ts.map +1 -1
  172. package/dist/utils/assetResolver.js +1 -0
  173. package/dist/utils/index.d.ts +2 -0
  174. package/dist/utils/index.d.ts.map +1 -1
  175. package/dist/utils/index.js +3 -0
  176. package/dist/utils/useDeleteAccountSafe.d.ts +17 -0
  177. package/dist/utils/useDeleteAccountSafe.d.ts.map +1 -0
  178. package/dist/utils/useDeleteAccountSafe.js +52 -0
  179. package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
  180. package/dist/utils/useFormStoreSafe.js +1 -0
  181. package/dist/utils/useSeo.d.ts +10 -2
  182. package/dist/utils/useSeo.d.ts.map +1 -1
  183. package/dist/utils/useSeo.js +44 -9
  184. package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
  185. package/dist/vite-routing/AppRoutes.js +37 -4
  186. package/guidelines/COMPONENTS.md +2 -1
  187. package/guidelines/GOTCHAS.md +2 -0
  188. package/guidelines/LAYOUTS.md +4 -0
  189. package/guidelines/PAGES.md +30 -3
  190. package/guidelines/ROUTING.md +29 -0
  191. package/guidelines/SEO.md +52 -0
  192. package/package.json +9 -9
  193. package/dist/CookieConsent-5NH5DNTP.js +0 -1
  194. package/dist/CookieConsent-W7UE647Y.js +0 -1
  195. package/dist/chunk-DRFM6WXH.js +0 -1
  196. package/dist/chunk-MIPTBUWY.js +0 -1
  197. package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +0 -57
  198. package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +0 -1
  199. package/dist/internal/layout/components/NextJsAutoMetaTags.js +0 -182
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/crud/components/Form.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAa,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AACH,QAAA,MAAM,IAAI,yaAAe,CAAC;AAqB1B;;;;;;;;;;GAUG;AACH,QAAA,MAAM,SAAS,GACb,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,cAEC,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,gCAMtC,CAAC;AAYF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,QAAQ,GAAI,yBAAyB,cAAc,CAAC,cAAc,CAAC,gCAOxE,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;QA4BjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,SAAS,GAAI,yBAAyB,cAAc,CAAC,OAAO,KAAK,CAAC,uCAWvE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW,GAAI,cAAc,cAAc,CAAC,OAAO,IAAI,CAAC,uCAgB7D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,eAAe,GAAI,yBAGtB,cAAc,CAAC,oBAAoB,CAAC,uCAetC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW,GAAI,mCAIlB,cAAc,CAAC,oBAAo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EF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW,GAAI,mCAIlB,cAAc,CAAC,oBAAoB,CAAC,uCAsBtC,CAAC;AAEF;;;;;;GAMG;AACH,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,eAAe,EACf,WAAW,EACX,SAAS,EACT,YAAY,GACb,CAAC"}
@@ -62,9 +62,9 @@ const FormItemContext = createContext({});
62
62
  * @since 0.0.1
63
63
  * @author AMBROISE PARK Consulting
64
64
  */
65
- const FormItem = ({ className, ...props }) => {
65
+ const FormItem = ({ className, children, ...props }) => {
66
66
  const id = useId();
67
- return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx(Stack, { className: className, ...props }) }));
67
+ return (_jsx(FormItemContext.Provider, { value: { id }, children: _jsx(Stack, { className: className, ...props, children: children }) }));
68
68
  };
69
69
  /**
70
70
  * Hook for accessing form field context
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview Cell editor of an entity field
3
+ * @description Maps an entity field to the DataTable cell editor used by an
4
+ * `editable` EntityList. Editability and references come from the entity
5
+ * descriptor (`describeEntity`), the same rules as forms.
6
+ *
7
+ * @version 0.2.0
8
+ * @since 0.2.3
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ import type { TableCellEdit } from '@donotdev/components';
12
+ import type { AnyEntity } from '@donotdev/core';
13
+ type Translate = (key: string, options?: Record<string, unknown>) => string;
14
+ /**
15
+ * Cell editor of a list field, or `undefined` when the field is not edited in
16
+ * the table (type without a cell editor, or not editable by the viewer).
17
+ * Editability is the form's (`editableFor(viewerRole, 'edit')`): generated,
18
+ * computed, `editable: false`, create-only, role-denied and technical fields stay
19
+ * read-only. References (any field type with `validation.reference`, descriptor
20
+ * `value.kind === 'ref'`) list the referenced records by their resolved label
21
+ * (`useReferenceResolver`); a reference whose collection is not resolved yet stays
22
+ * read-only.
23
+ *
24
+ * @param entity - Entity owning the field (the extension entity for an extension column)
25
+ * @param name - Field name in `entity.fields` (unprefixed)
26
+ * @param viewerRole - Viewer's role
27
+ * @param referenceData - Resolved reference labels by collection
28
+ * @param t - Translator for option labels
29
+ * @returns The cell editor, or `undefined`
30
+ * @throws When `entity` has no field `name`
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * cellEditFor(productEntity, 'price', 'admin', {}, t);
35
+ * // { type: 'number' }
36
+ * ```
37
+ *
38
+ * @version 0.2.0
39
+ * @since 0.2.3
40
+ */
41
+ export declare function cellEditFor(entity: AnyEntity, name: string, viewerRole: string, referenceData: Record<string, Record<string, string>>, t: Translate): TableCellEdit | undefined;
42
+ export {};
43
+ //# sourceMappingURL=cellEditFor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellEditFor.d.ts","sourceRoot":"","sources":["../../../src/crud/components/cellEditFor.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAShD,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACrD,CAAC,EAAE,SAAS,GACX,aAAa,GAAG,SAAS,CAkC3B"}
@@ -0,0 +1,74 @@
1
+ // packages/ui/src/crud/components/cellEditFor.ts
2
+ import { describeEntity } from '@donotdev/core';
3
+ import { translateLabel } from '../crudImports';
4
+ /** Field types edited as free text in an editable list. */
5
+ const TEXT_TYPES = new Set(['text', 'email', 'url', 'tel', 'textarea']);
6
+ /** Field types edited as a dropdown of their `validation.options`. */
7
+ const OPTION_TYPES = new Set(['select', 'radio']);
8
+ /**
9
+ * Cell editor of a list field, or `undefined` when the field is not edited in
10
+ * the table (type without a cell editor, or not editable by the viewer).
11
+ * Editability is the form's (`editableFor(viewerRole, 'edit')`): generated,
12
+ * computed, `editable: false`, create-only, role-denied and technical fields stay
13
+ * read-only. References (any field type with `validation.reference`, descriptor
14
+ * `value.kind === 'ref'`) list the referenced records by their resolved label
15
+ * (`useReferenceResolver`); a reference whose collection is not resolved yet stays
16
+ * read-only.
17
+ *
18
+ * @param entity - Entity owning the field (the extension entity for an extension column)
19
+ * @param name - Field name in `entity.fields` (unprefixed)
20
+ * @param viewerRole - Viewer's role
21
+ * @param referenceData - Resolved reference labels by collection
22
+ * @param t - Translator for option labels
23
+ * @returns The cell editor, or `undefined`
24
+ * @throws When `entity` has no field `name`
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * cellEditFor(productEntity, 'price', 'admin', {}, t);
29
+ * // { type: 'number' }
30
+ * ```
31
+ *
32
+ * @version 0.2.0
33
+ * @since 0.2.3
34
+ */
35
+ export function cellEditFor(entity, name, viewerRole, referenceData, t) {
36
+ const field = entity.fields[name];
37
+ const descriptor = describeEntity(entity).fields[name];
38
+ if (!field || !descriptor) {
39
+ throw new Error(`cellEditFor: entity "${entity.name}" has no field "${name}".`);
40
+ }
41
+ if (!descriptor.editableFor(viewerRole, 'edit'))
42
+ return undefined;
43
+ const { value } = descriptor;
44
+ if (value.kind === 'ref' && value.ref !== undefined) {
45
+ const labels = referenceData[value.ref];
46
+ if (!labels)
47
+ return undefined;
48
+ return {
49
+ type: 'select',
50
+ options: Object.entries(labels)
51
+ .map(([id, label]) => ({ value: id, label }))
52
+ .sort((a, b) => a.label.localeCompare(b.label)),
53
+ };
54
+ }
55
+ const { type } = field;
56
+ if (TEXT_TYPES.has(type))
57
+ return { type: 'text' };
58
+ if (type === 'number')
59
+ return { type: 'number' };
60
+ if (OPTION_TYPES.has(type)) {
61
+ const raw = field.validation?.options;
62
+ const options = typeof raw === 'function' ? raw() : raw;
63
+ if (!Array.isArray(options))
64
+ return undefined;
65
+ return {
66
+ type: 'select',
67
+ options: options.map((o) => ({
68
+ value: String(o.value),
69
+ label: translateLabel(o.label, t),
70
+ })),
71
+ };
72
+ }
73
+ return undefined;
74
+ }
@@ -0,0 +1,33 @@
1
+ import type { AnyEntity, EntityListParent } from '@donotdev/core';
2
+ /** A nested list's parent once created (its id known). */
3
+ export interface SavedEntityParent extends EntityListParent {
4
+ value: string;
5
+ }
6
+ /**
7
+ * Throws when `parent.field` is not a reference field of the listed entity, or
8
+ * `parent.value` is neither a record id nor `null` (parent not created yet).
9
+ * A wrong parent would silently list nothing.
10
+ *
11
+ * @param entity - The listed (child) entity
12
+ * @param parent - The nested list's parent
13
+ */
14
+ export declare function assertEntityParent(entity: AnyEntity, parent: EntityListParent): void;
15
+ /**
16
+ * Create path of a child record with its parent prefilled.
17
+ *
18
+ * @param basePath - The list's base path
19
+ * @param parent - The nested list's parent (created)
20
+ * @returns `${basePath}/new?<field>=<id>`
21
+ */
22
+ export declare function childCreatePath(basePath: string, parent: SavedEntityParent): string;
23
+ /**
24
+ * Create-form values taken from the URL: reference fields of the entity the
25
+ * viewer may set on create, whose value is a record id. Anything else is ignored.
26
+ *
27
+ * @param entity - The entity being created
28
+ * @param params - The current URL's search params
29
+ * @param viewerRole - The viewer's role
30
+ * @returns The prefilled reference values (empty when none)
31
+ */
32
+ export declare function referencePrefillFromQuery(entity: AnyEntity, params: URLSearchParams, viewerRole: string): Record<string, string>;
33
+ //# sourceMappingURL=entityParent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityParent.d.ts","sourceRoot":"","sources":["../../../src/crud/components/entityParent.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgBlE,0DAA0D;AAC1D,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,GACvB,IAAI,CAWN;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,GACxB,MAAM,CAGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB"}
@@ -0,0 +1,76 @@
1
+ // packages/ui/src/crud/components/entityParent.ts
2
+ /**
3
+ * @fileoverview Parent / child records (nested lists)
4
+ * @description An `EntityList` with `parent` lists one parent's children and its
5
+ * add button opens `basePath/new?<field>=<id>`. `EntityFormRenderer` (create)
6
+ * prefills that reference field from the URL. `parent.value: null` (parent not
7
+ * created yet) shows the create-first message instead. URL input is untrusted: only
8
+ * reference fields of the entity the viewer may set on create, with an id-shaped
9
+ * value, are taken. Reference fields and editability come from the entity
10
+ * descriptor (`describeEntity`).
11
+ *
12
+ * @version 0.1.0
13
+ * @since 0.2.3
14
+ * @author AMBROISE PARK Consulting
15
+ */
16
+ import { describeEntity } from '@donotdev/core';
17
+ /** Record id shape accepted from a URL (Firestore ids, UUIDs, slugs). */
18
+ const RECORD_ID = /^[A-Za-z0-9_-]{1,128}$/;
19
+ /**
20
+ * True when `field` is a reference field of `entity`: descriptor
21
+ * `value.kind === 'ref'` (any field type with `validation.reference`, custom ones included).
22
+ */
23
+ const isReferenceField = (entity, field) => {
24
+ const value = Object.hasOwn(entity.fields, field)
25
+ ? describeEntity(entity).fields[field]?.value
26
+ : undefined;
27
+ return value?.kind === 'ref' && value.ref !== undefined;
28
+ };
29
+ /**
30
+ * Throws when `parent.field` is not a reference field of the listed entity, or
31
+ * `parent.value` is neither a record id nor `null` (parent not created yet).
32
+ * A wrong parent would silently list nothing.
33
+ *
34
+ * @param entity - The listed (child) entity
35
+ * @param parent - The nested list's parent
36
+ */
37
+ export function assertEntityParent(entity, parent) {
38
+ if (!isReferenceField(entity, parent.field)) {
39
+ throw new Error(`EntityList: parent.field "${parent.field}" is not a reference field of entity "${entity.name}".`);
40
+ }
41
+ if (parent.value !== null && !RECORD_ID.test(parent.value)) {
42
+ throw new Error(`EntityList: parent.value "${parent.value}" is not a record id.`);
43
+ }
44
+ }
45
+ /**
46
+ * Create path of a child record with its parent prefilled.
47
+ *
48
+ * @param basePath - The list's base path
49
+ * @param parent - The nested list's parent (created)
50
+ * @returns `${basePath}/new?<field>=<id>`
51
+ */
52
+ export function childCreatePath(basePath, parent) {
53
+ const query = new URLSearchParams({ [parent.field]: parent.value });
54
+ return `${basePath}/new?${query.toString()}`;
55
+ }
56
+ /**
57
+ * Create-form values taken from the URL: reference fields of the entity the
58
+ * viewer may set on create, whose value is a record id. Anything else is ignored.
59
+ *
60
+ * @param entity - The entity being created
61
+ * @param params - The current URL's search params
62
+ * @param viewerRole - The viewer's role
63
+ * @returns The prefilled reference values (empty when none)
64
+ */
65
+ export function referencePrefillFromQuery(entity, params, viewerRole) {
66
+ const prefill = {};
67
+ for (const [key, value] of params.entries()) {
68
+ if (Object.hasOwn(entity.fields, key) &&
69
+ isReferenceField(entity, key) &&
70
+ RECORD_ID.test(value) &&
71
+ describeEntity(entity).fields[key]?.editableFor(viewerRole, 'create') === true) {
72
+ prefill[key] = value;
73
+ }
74
+ }
75
+ return prefill;
76
+ }
@@ -0,0 +1,11 @@
1
+ import type { AnyEntity } from '@donotdev/core';
2
+ /**
3
+ * Names the shown record in the breadcrumbs: the entity's card title, formatted like
4
+ * the card (the same title `<Seo entity>` uses). Cleared when the page unmounts or the record
5
+ * has no title, unless another component replaced it meanwhile (its label stays). Client effect: the server render keeps the URL segment.
6
+ *
7
+ * @param entity - Entity of the record
8
+ * @param record - Loaded record (`undefined` / `null` while loading)
9
+ */
10
+ export declare function useRecordBreadcrumb(entity: AnyEntity, record: Record<string, unknown> | null | undefined): void;
11
+ //# sourceMappingURL=useRecordBreadcrumb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRecordBreadcrumb.d.ts","sourceRoot":"","sources":["../../../src/crud/components/useRecordBreadcrumb.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GACjD,IAAI,CAqBN"}
@@ -0,0 +1,43 @@
1
+ // packages/ui/src/crud/components/useRecordBreadcrumb.ts
2
+ /**
3
+ * @fileoverview Record name in the breadcrumbs
4
+ * @description Publishes the shown record's display name to the layout store, so the
5
+ * breadcrumb segment holding its id (`/products/<uuid>`) reads as the record's name.
6
+ *
7
+ * @version 0.1.0
8
+ * @since 0.2.3
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ import { useEffect, useRef } from 'react';
12
+ import { deriveEntitySeo, useLayout, useTranslation } from '@donotdev/core';
13
+ /**
14
+ * Names the shown record in the breadcrumbs: the entity's card title, formatted like
15
+ * the card (the same title `<Seo entity>` uses). Cleared when the page unmounts or the record
16
+ * has no title, unless another component replaced it meanwhile (its label stays). Client effect: the server render keeps the URL segment.
17
+ *
18
+ * @param entity - Entity of the record
19
+ * @param record - Loaded record (`undefined` / `null` while loading)
20
+ */
21
+ export function useRecordBreadcrumb(entity, record) {
22
+ const setRecordLabel = useLayout('setRouteRecordLabel');
23
+ // The label currently shown: cleanup clears only its own label, never one another
24
+ // component (e.g. the page) set after it.
25
+ const shown = useLayout('routeRecordLabel');
26
+ const shownRef = useRef(shown);
27
+ shownRef.current = shown;
28
+ const id = typeof record?.id === 'string' ? record.id : undefined;
29
+ const { t, language } = useTranslation([entity.namespace, 'crud']);
30
+ const label = record
31
+ ? deriveEntitySeo(entity, record, { t, locale: language }).title
32
+ : undefined;
33
+ useEffect(() => {
34
+ if (!id || !label)
35
+ return;
36
+ setRecordLabel({ id, label });
37
+ return () => {
38
+ const current = shownRef.current;
39
+ if (current?.id === id && current.label === label)
40
+ setRecordLabel(null);
41
+ };
42
+ }, [id, label, setRecordLabel]);
43
+ }
@@ -16,7 +16,11 @@ import * as crudModule from '@donotdev/crud';
16
16
  /** true when @donotdev/crud resolved with real exports */
17
17
  export declare const isCrudModuleAvailable: boolean;
18
18
  export declare const useEntityForm: typeof crudModule.useEntityForm;
19
- export declare const useFormStore: import("zustand").UseBoundStore<import("zustand").StoreApi<crudModule.FormStoreState & crudModule.FormStoreActions & import("@donotdev/stores").DoNotDevStore>>;
19
+ export declare const useFormStore: import("zustand").UseBoundStore<import("zustand").StoreApi<crudModule.FormStoreState & crudModule.FormStoreActions>>;
20
+ /** Router placeholder for useEntityForm's leave-on-save (filled by UIProviders). */
21
+ export declare const FormNavigationProvider: import("react").Provider<crudModule.FormNavigation | null>;
22
+ /** Subscribe to the existing submission error without duplicating form state. */
23
+ export declare const useFormError: (formId: string) => string | null;
20
24
  export declare const useFieldConditions: typeof crudModule.useFieldConditions;
21
25
  export declare const useCrud: typeof crudModule.useCrud;
22
26
  export declare const useCrudList: typeof crudModule.useCrudList;
@@ -27,6 +31,10 @@ export declare const useCrudFilters: typeof crudModule.useCrudFilters;
27
31
  export declare const useCrudPageSize: typeof crudModule.useCrudPageSize;
28
32
  export declare const useEntityWorkflow: typeof crudModule.useEntityWorkflow;
29
33
  export declare const useReferenceResolver: typeof crudModule.useReferenceResolver;
34
+ /** Child rows of a record, joined to the form open on it (EntityList with `parent`). */
35
+ export declare const useChildRows: typeof crudModule.useChildRows;
36
+ /** The edit form open on a parent record that its child rows join, or null. */
37
+ export declare const useJoinedForm: typeof crudModule.useJoinedForm;
30
38
  export declare const DisplayFieldRenderer: typeof crudModule.DisplayFieldRenderer;
31
39
  export declare const FormFieldRenderer: typeof crudModule.FormFieldRenderer;
32
40
  export declare const UploadProvider: typeof crudModule.UploadProvider;
@@ -34,4 +42,7 @@ export declare const EntityFilters: typeof crudModule.EntityFilters;
34
42
  export declare const CrudCard: typeof crudModule.CrudCard;
35
43
  export declare const translateFieldLabel: typeof crudModule.translateFieldLabel;
36
44
  export declare const formatValue: typeof crudModule.formatValue;
45
+ export declare const translateLabel: typeof crudModule.translateLabel;
46
+ export declare const applyFilters: typeof crudModule.applyFilters;
47
+ export declare const applySearch: typeof crudModule.applySearch;
37
48
  //# sourceMappingURL=crudImports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crudImports.d.ts","sourceRoot":"","sources":["../../src/crud/crudImports.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAE7C,0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,SAA4C,CAAC;AAG/E,eAAO,MAAM,aAAa,iCAA4B,CAAC;AACvD,eAAO,MAAM,YAAY,iKAA2B,CAAC;AACrD,eAAO,MAAM,kBAAkB,sCAAiC,CAAC;AACjE,eAAO,MAAM,OAAO,2BAAsB,CAAC;AAC3C,eAAO,MAAM,WAAW,+BAA0B,CAAC;AACnD,eAAO,MAAM,UAAU,8BAAyB,CAAC;AACjD,eAAO,MAAM,eAAe,mCAA8B,CAAC;AAC3D,eAAO,MAAM,kBAAkB,sCAAiC,CAAC;AACjE,eAAO,MAAM,cAAc,kCAA6B,CAAC;AACzD,eAAO,MAAM,eAAe,mCAA8B,CAAC;AAC3D,eAAO,MAAM,iBAAiB,qCAAgC,CAAC;AAC/D,eAAO,MAAM,oBAAoB,wCAAmC,CAAC;AAGrE,eAAO,MAAM,oBAAoB,wCAAmC,CAAC;AACrE,eAAO,MAAM,iBAAiB,qCAAgC,CAAC;AAC/D,eAAO,MAAM,cAAc,kCAA6B,CA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AO,MAAM,QAAQ,4BAAuB,CAAC;AAG7C,eAAO,MAAM,mBAAmB,uCAAkC,CAAC;AACnE,eAAO,MAAM,WAAW,+BAA0B,CAAC;AACnD,eAAO,MAAM,cAAc,kCAA6B,CAAC;AACzD,eAAO,MAAM,YAAY,gCAA2B,CAAC;AACrD,eAAO,MAAM,WAAW,+BAA0B,CAAC"}
@@ -19,6 +19,10 @@ export const isCrudModuleAvailable = typeof crudModule?.useCrud === 'function';
19
19
  // --- Hooks ---
20
20
  export const useEntityForm = crudModule?.useEntityForm;
21
21
  export const useFormStore = crudModule?.useFormStore;
22
+ /** Router placeholder for useEntityForm's leave-on-save (filled by UIProviders). */
23
+ export const FormNavigationProvider = crudModule?.FormNavigationProvider;
24
+ /** Subscribe to the existing submission error without duplicating form state. */
25
+ export const useFormError = crudModule?.useFormError;
22
26
  export const useFieldConditions = crudModule?.useFieldConditions;
23
27
  export const useCrud = crudModule?.useCrud;
24
28
  export const useCrudList = crudModule?.useCrudList;
@@ -29,6 +33,10 @@ export const useCrudFilters = crudModule?.useCrudFilters;
29
33
  export const useCrudPageSize = crudModule?.useCrudPageSize;
30
34
  export const useEntityWorkflow = crudModule?.useEntityWorkflow;
31
35
  export const useReferenceResolver = crudModule?.useReferenceResolver;
36
+ /** Child rows of a record, joined to the form open on it (EntityList with `parent`). */
37
+ export const useChildRows = crudModule?.useChildRows;
38
+ /** The edit form open on a parent record that its child rows join, or null. */
39
+ export const useJoinedForm = crudModule?.useJoinedForm;
32
40
  // --- Components ---
33
41
  export const DisplayFieldRenderer = crudModule?.DisplayFieldRenderer;
34
42
  export const FormFieldRenderer = crudModule?.FormFieldRenderer;
@@ -38,3 +46,6 @@ export const CrudCard = crudModule?.CrudCard;
38
46
  // --- Utils ---
39
47
  export const translateFieldLabel = crudModule?.translateFieldLabel;
40
48
  export const formatValue = crudModule?.formatValue;
49
+ export const translateLabel = crudModule?.translateLabel;
50
+ export const applyFilters = crudModule?.applyFilters;
51
+ export const applySearch = crudModule?.applySearch;