@erxes/ui 4.0.0-v2.1 → 4.0.0-v2.11

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 (318) hide show
  1. package/AGENTS.md +58 -0
  2. package/CATALOG.md +251 -0
  3. package/README.md +25 -2
  4. package/dist/components/accordion.d.ts +1 -0
  5. package/dist/components/accordion.js +1 -0
  6. package/dist/components/alert-dialog.d.ts +4 -0
  7. package/dist/components/alert-dialog.js +4 -0
  8. package/dist/components/alert.d.ts +1 -0
  9. package/dist/components/alert.js +1 -0
  10. package/dist/components/avatar.d.ts +2 -0
  11. package/dist/components/avatar.js +1 -0
  12. package/dist/components/background-gradient-animation.d.ts +4 -1
  13. package/dist/components/background-gradient-animation.js +4 -1
  14. package/dist/components/badge.d.ts +3 -0
  15. package/dist/components/badge.js +2 -0
  16. package/dist/components/breadcrumb.d.ts +1 -0
  17. package/dist/components/breadcrumb.js +1 -0
  18. package/dist/components/button.d.ts +6 -1
  19. package/dist/components/button.js +5 -1
  20. package/dist/components/calendar.d.ts +5 -0
  21. package/dist/components/calendar.js +4 -0
  22. package/dist/components/card.d.ts +1 -0
  23. package/dist/components/card.js +1 -0
  24. package/dist/components/chart-config.d.ts +4 -1
  25. package/dist/components/charts.d.ts +6 -0
  26. package/dist/components/charts.js +12 -3
  27. package/dist/components/checkbox.d.ts +1 -0
  28. package/dist/components/checkbox.js +1 -0
  29. package/dist/components/choicebox-group.d.ts +1 -0
  30. package/dist/components/choicebox-group.js +1 -0
  31. package/dist/components/collapsible.d.ts +1 -0
  32. package/dist/components/collapsible.js +1 -0
  33. package/dist/components/color-picker.d.ts +1 -0
  34. package/dist/components/color-picker.js +13 -6
  35. package/dist/components/combobox.d.ts +6 -1
  36. package/dist/components/combobox.js +9 -1
  37. package/dist/components/command-bar.d.ts +4 -0
  38. package/dist/components/command-bar.js +4 -0
  39. package/dist/components/command.d.ts +4 -0
  40. package/dist/components/command.js +4 -0
  41. package/dist/components/context-menu.d.ts +1 -0
  42. package/dist/components/context-menu.js +1 -0
  43. package/dist/components/copy-text.d.ts +1 -0
  44. package/dist/components/copy-text.js +1 -0
  45. package/dist/components/date-picker-value.d.ts +5 -9
  46. package/dist/components/date-picker-value.js +15 -34
  47. package/dist/components/date-picker.d.ts +4 -4
  48. package/dist/components/date-picker.js +9 -7
  49. package/dist/components/date-text-input.d.ts +2 -4
  50. package/dist/components/date-text-input.js +11 -9
  51. package/dist/components/dialog.d.ts +4 -0
  52. package/dist/components/dialog.js +5 -1
  53. package/dist/components/drag-handle.d.ts +1 -0
  54. package/dist/components/drag-handle.js +1 -0
  55. package/dist/components/dropdown-menu.d.ts +1 -0
  56. package/dist/components/dropdown-menu.js +1 -0
  57. package/dist/components/empty.d.ts +6 -1
  58. package/dist/components/empty.js +25 -2
  59. package/dist/components/form.d.ts +6 -2
  60. package/dist/components/form.js +8 -2
  61. package/dist/components/hover-card.d.ts +1 -0
  62. package/dist/components/hover-card.js +1 -0
  63. package/dist/components/icon-tip.d.ts +7 -0
  64. package/dist/components/icon-tip.js +16 -0
  65. package/dist/components/info-card.d.ts +4 -0
  66. package/dist/components/info-card.js +4 -0
  67. package/dist/components/input-group.d.ts +5 -4
  68. package/dist/components/input-group.js +5 -4
  69. package/dist/components/input.d.ts +1 -0
  70. package/dist/components/input.js +1 -0
  71. package/dist/components/kbd.d.ts +2 -1
  72. package/dist/components/kbd.js +2 -1
  73. package/dist/components/label.d.ts +1 -1
  74. package/dist/components/label.js +1 -1
  75. package/dist/components/multiselect.d.ts +1 -0
  76. package/dist/components/multiselect.js +3 -2
  77. package/dist/components/on-demand.d.ts +6 -0
  78. package/dist/components/on-demand.js +6 -0
  79. package/dist/components/popover.d.ts +4 -0
  80. package/dist/components/popover.js +4 -0
  81. package/dist/components/radio-group.d.ts +1 -0
  82. package/dist/components/radio-group.js +1 -0
  83. package/dist/components/scroll-area.d.ts +1 -0
  84. package/dist/components/scroll-area.js +1 -0
  85. package/dist/components/select.d.ts +5 -1
  86. package/dist/components/select.js +7 -1
  87. package/dist/components/separator.d.ts +4 -0
  88. package/dist/components/separator.js +4 -0
  89. package/dist/components/sheet.d.ts +4 -0
  90. package/dist/components/sheet.js +8 -4
  91. package/dist/components/sidebar/panel.js +29 -7
  92. package/dist/components/sidebar.d.ts +1 -0
  93. package/dist/components/sidebar.js +1 -0
  94. package/dist/components/skeleton.d.ts +1 -0
  95. package/dist/components/skeleton.js +1 -0
  96. package/dist/components/spinner.d.ts +1 -0
  97. package/dist/components/spinner.js +1 -0
  98. package/dist/components/string-array.js +1 -0
  99. package/dist/components/switch.d.ts +1 -0
  100. package/dist/components/switch.js +1 -0
  101. package/dist/components/table.d.ts +4 -0
  102. package/dist/components/table.js +4 -0
  103. package/dist/components/tabs.d.ts +8 -1
  104. package/dist/components/tabs.js +8 -1
  105. package/dist/components/text-overflow.d.ts +4 -1
  106. package/dist/components/text-overflow.js +4 -1
  107. package/dist/components/textarea.d.ts +1 -0
  108. package/dist/components/textarea.js +1 -0
  109. package/dist/components/toaster.d.ts +4 -1
  110. package/dist/components/toaster.js +5 -2
  111. package/dist/components/toggle-group.d.ts +5 -0
  112. package/dist/components/toggle-group.js +19 -11
  113. package/dist/components/toggle.d.ts +1 -0
  114. package/dist/components/toggle.js +1 -0
  115. package/dist/components/tooltip.d.ts +4 -0
  116. package/dist/components/tooltip.js +4 -0
  117. package/dist/components/upload.d.ts +4 -0
  118. package/dist/components/upload.js +20 -11
  119. package/dist/federation.d.ts +8 -1
  120. package/dist/federation.js +12 -2
  121. package/dist/hooks/use-item-keys.d.ts +11 -0
  122. package/dist/hooks/use-item-keys.js +24 -0
  123. package/dist/hooks/use-page-hotkey.d.ts +12 -0
  124. package/dist/hooks/use-page-hotkey.js +22 -0
  125. package/dist/hooks/use-toast.d.ts +5 -0
  126. package/dist/hooks/use-toast.js +5 -0
  127. package/dist/index.d.ts +33 -6
  128. package/dist/index.js +31 -4
  129. package/dist/lib/format.d.ts +60 -0
  130. package/dist/lib/format.js +86 -0
  131. package/dist/lib/money.d.ts +13 -0
  132. package/dist/lib/money.js +21 -0
  133. package/dist/lib/stored.d.ts +13 -0
  134. package/dist/lib/stored.js +41 -0
  135. package/dist/lib/text.d.ts +11 -0
  136. package/dist/lib/text.js +18 -0
  137. package/dist/modules/attachments/use-carousel.js +5 -10
  138. package/dist/modules/blocks/hooks/useBarcodeSizeForm.d.ts +1 -1
  139. package/dist/modules/blocks/utils/parseBlocks.d.ts +1 -1
  140. package/dist/modules/blocks/utils/parseBlocks.js +1 -1
  141. package/dist/modules/conditions/ConditionValueInput.d.ts +10 -0
  142. package/dist/modules/conditions/ConditionValueInput.js +166 -0
  143. package/dist/modules/conditions/ConditionsEditor.d.ts +11 -0
  144. package/dist/modules/conditions/ConditionsEditor.js +209 -0
  145. package/dist/modules/conditions/LazyConditionsEditor.d.ts +10 -0
  146. package/dist/modules/conditions/LazyConditionsEditor.js +11 -0
  147. package/dist/modules/conditions/PathPicker.d.ts +8 -0
  148. package/dist/modules/conditions/PathPicker.js +51 -0
  149. package/dist/modules/conditions/conditions.d.ts +66 -0
  150. package/dist/modules/conditions/conditions.js +136 -0
  151. package/dist/modules/display/components/EmailDisplay.d.ts +4 -0
  152. package/dist/modules/display/components/EmailDisplay.js +6 -3
  153. package/dist/modules/display/components/PhoneDisplay.d.ts +4 -0
  154. package/dist/modules/display/components/PhoneDisplay.js +4 -0
  155. package/dist/modules/display/components/RelativeDateDisplay.d.ts +7 -5
  156. package/dist/modules/display/components/RelativeDateDisplay.js +10 -8
  157. package/dist/modules/display/components/SexDisplay.d.ts +1 -0
  158. package/dist/modules/display/components/SexDisplay.js +1 -0
  159. package/dist/modules/filter/components/Filter.d.ts +4 -0
  160. package/dist/modules/filter/components/Filter.js +4 -0
  161. package/dist/modules/filter/components/FilterBar.js +5 -7
  162. package/dist/modules/filter/components/FilterDialog.js +4 -5
  163. package/dist/modules/filter/components/FilterPopover.js +1 -1
  164. package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
  165. package/dist/modules/filter/components/FilterProvider.js +22 -16
  166. package/dist/modules/filter/hooks/useFilterContext.d.ts +1 -0
  167. package/dist/modules/filter/hooks/useFilterContext.js +1 -0
  168. package/dist/modules/filter/types/filter.d.ts +0 -1
  169. package/dist/modules/hotkey/components/PopoverScoped.d.ts +5 -0
  170. package/dist/modules/hotkey/components/PopoverScoped.js +5 -0
  171. package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.d.ts +1 -0
  172. package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.js +1 -0
  173. package/dist/modules/hotkey/hooks/useScopedHotkeys.d.ts +5 -1
  174. package/dist/modules/hotkey/hooks/useScopedHotkeys.js +5 -1
  175. package/dist/modules/icons/components/IconComponent.d.ts +4 -0
  176. package/dist/modules/icons/components/IconComponent.js +4 -0
  177. package/dist/modules/icons/components/IconPicker.d.ts +4 -0
  178. package/dist/modules/icons/components/IconPicker.js +7 -5
  179. package/dist/modules/icons/providers/IconsProvider.d.ts +1 -0
  180. package/dist/modules/icons/providers/IconsProvider.js +1 -0
  181. package/dist/modules/inputs/components/EmailField.d.ts +4 -1
  182. package/dist/modules/inputs/components/EmailField.js +4 -1
  183. package/dist/modules/inputs/components/FullNameField.d.ts +6 -0
  184. package/dist/modules/inputs/components/FullNameField.js +20 -8
  185. package/dist/modules/inputs/components/PhoneField.d.ts +4 -1
  186. package/dist/modules/inputs/components/PhoneField.js +4 -1
  187. package/dist/modules/inputs/components/SexField.d.ts +1 -0
  188. package/dist/modules/inputs/components/SexField.js +1 -0
  189. package/dist/modules/layout/components/AppLayout.d.ts +6 -6
  190. package/dist/modules/layout/components/AppLayout.js +12 -13
  191. package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
  192. package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
  193. package/dist/modules/layout/components/Page.d.ts +5 -0
  194. package/dist/modules/layout/components/Page.js +5 -0
  195. package/dist/modules/layout/components/PageHeader.d.ts +4 -1
  196. package/dist/modules/layout/components/PageHeader.js +9 -3
  197. package/dist/modules/list/DisplayMenu.d.ts +24 -0
  198. package/dist/modules/list/DisplayMenu.js +87 -0
  199. package/dist/modules/list/ListFilter.d.ts +63 -0
  200. package/dist/modules/list/ListFilter.js +44 -0
  201. package/dist/modules/list/ViewBar.d.ts +13 -0
  202. package/dist/modules/list/ViewBar.js +30 -0
  203. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +5 -0
  204. package/dist/modules/list/filter/AdvancedFilterDialog.js +52 -0
  205. package/dist/modules/list/filter/FieldMenus.d.ts +5 -0
  206. package/dist/modules/list/filter/FieldMenus.js +184 -0
  207. package/dist/modules/list/filter/ListFilterBar.d.ts +6 -0
  208. package/dist/modules/list/filter/ListFilterBar.js +246 -0
  209. package/dist/modules/list/filter/RecordCount.d.ts +7 -0
  210. package/dist/modules/list/filter/RecordCount.js +22 -0
  211. package/dist/modules/list/filter/RuleChips.d.ts +2 -0
  212. package/dist/modules/list/filter/RuleChips.js +157 -0
  213. package/dist/modules/list/filter/fieldIcons.d.ts +7 -0
  214. package/dist/modules/list/filter/fieldIcons.js +16 -0
  215. package/dist/modules/list/filter/filterRules.d.ts +46 -0
  216. package/dist/modules/list/filter/filterRules.js +166 -0
  217. package/dist/modules/list/filter/listFilterContext.d.ts +29 -0
  218. package/dist/modules/list/filter/listFilterContext.js +34 -0
  219. package/dist/modules/list/filter/listFilterQuery.d.ts +16 -0
  220. package/dist/modules/list/filter/listFilterQuery.js +22 -0
  221. package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +4 -3
  222. package/dist/modules/navigation-menu/components/NavigationMenu.js +7 -7
  223. package/dist/modules/pickers/EntityPicker.d.ts +37 -0
  224. package/dist/modules/pickers/EntityPicker.js +67 -0
  225. package/dist/modules/pickers/LookupPicker.d.ts +51 -0
  226. package/dist/modules/pickers/LookupPicker.js +84 -0
  227. package/dist/modules/pickers/SelectMember.d.ts +41 -0
  228. package/dist/modules/pickers/SelectMember.js +122 -0
  229. package/dist/modules/pickers/members.d.ts +30 -0
  230. package/dist/modules/pickers/members.js +18 -0
  231. package/dist/modules/record-field/components/NumberField.d.ts +5 -0
  232. package/dist/modules/record-field/components/NumberField.js +14 -7
  233. package/dist/modules/record-field/components/TextField.d.ts +4 -0
  234. package/dist/modules/record-field/components/TextField.js +14 -3
  235. package/dist/modules/record-field/meta-inputs/components/PhoneInput.d.ts +5 -0
  236. package/dist/modules/record-field/meta-inputs/components/PhoneInput.js +5 -0
  237. package/dist/modules/record-list/RecordList.d.ts +18 -0
  238. package/dist/modules/record-list/RecordList.js +23 -0
  239. package/dist/modules/record-list/RecordListProvider.d.ts +30 -0
  240. package/dist/modules/record-list/RecordListProvider.js +57 -0
  241. package/dist/modules/record-list/RecordListRoot.d.ts +28 -0
  242. package/dist/modules/record-list/RecordListRoot.js +124 -0
  243. package/dist/modules/record-list/selection.d.ts +22 -0
  244. package/dist/modules/record-list/selection.js +54 -0
  245. package/dist/modules/record-panel/PanelDescriptionEditor.d.ts +9 -0
  246. package/dist/modules/record-panel/PanelDescriptionEditor.js +39 -0
  247. package/dist/modules/record-panel/PanelDescriptionField.d.ts +13 -0
  248. package/dist/modules/record-panel/PanelDescriptionField.js +39 -0
  249. package/dist/modules/record-panel/PanelField.d.ts +17 -0
  250. package/dist/modules/record-panel/PanelField.js +47 -0
  251. package/dist/modules/record-panel/PanelForm.d.ts +28 -0
  252. package/dist/modules/record-panel/PanelForm.js +88 -0
  253. package/dist/modules/record-panel/PanelLabel.d.ts +10 -0
  254. package/dist/modules/record-panel/PanelLabel.js +55 -0
  255. package/dist/modules/record-panel/PanelSection.d.ts +12 -0
  256. package/dist/modules/record-panel/PanelSection.js +24 -0
  257. package/dist/modules/record-panel/panelExpansion.d.ts +10 -0
  258. package/dist/modules/record-panel/panelExpansion.js +7 -0
  259. package/dist/modules/record-panel/useSaveOnLeave.d.ts +14 -0
  260. package/dist/modules/record-panel/useSaveOnLeave.js +42 -0
  261. package/dist/modules/record-table/components/RecordTable.d.ts +6 -0
  262. package/dist/modules/record-table/components/RecordTable.js +6 -0
  263. package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
  264. package/dist/modules/record-table/components/RecordTableCell.js +16 -2
  265. package/dist/modules/record-table/components/RecordTableCellInline.d.ts +5 -0
  266. package/dist/modules/record-table/components/RecordTableCellInline.js +8 -7
  267. package/dist/modules/record-table/components/RecordTableCursor.js +30 -28
  268. package/dist/modules/record-table/components/RecordTableProvider.js +12 -7
  269. package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
  270. package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
  271. package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
  272. package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
  273. package/dist/modules/record-table/types/RecordTableCursorTypes.d.ts +1 -0
  274. package/dist/modules/record-table/types/RecordTableCursorTypes.js +1 -0
  275. package/dist/modules/records/ContactLink.d.ts +13 -0
  276. package/dist/modules/records/ContactLink.js +77 -0
  277. package/dist/modules/records/contacts.d.ts +35 -0
  278. package/dist/modules/records/contacts.js +10 -0
  279. package/dist/modules/records/openRecord.d.ts +44 -0
  280. package/dist/modules/records/openRecord.js +48 -0
  281. package/dist/state/sidebarPanelState.d.ts +5 -1
  282. package/dist/state/sidebarPanelState.js +11 -3
  283. package/dist/state/themeState.d.ts +13 -2
  284. package/dist/state/themeState.js +18 -4
  285. package/dist/theme.css +5 -2
  286. package/dist/types/SexCode.d.ts +1 -0
  287. package/dist/types/SexCode.js +1 -0
  288. package/dist/types/UIConfig.d.ts +131 -3
  289. package/dist/utils/IsUndefinedOrNull.d.ts +1 -0
  290. package/dist/utils/IsUndefinedOrNull.js +1 -0
  291. package/dist/utils/file-storage.d.ts +1 -0
  292. package/dist/utils/file-storage.js +1 -0
  293. package/dist/utils/format/formatPhoneNumber.d.ts +4 -0
  294. package/dist/utils/format/formatPhoneNumber.js +4 -0
  295. package/dist/utils/getPluginAssetsUrl.d.ts +5 -0
  296. package/dist/utils/getPluginAssetsUrl.js +5 -0
  297. package/dist/utils/host-component.d.ts +10 -0
  298. package/dist/utils/host-component.js +34 -0
  299. package/dist/utils/json.d.ts +3 -2
  300. package/dist/utils/json.js +3 -2
  301. package/dist/utils/plugin-runtime.d.ts +21 -17
  302. package/dist/utils/plugin-runtime.js +59 -12
  303. package/dist/utils/plugin-styles.d.ts +7 -0
  304. package/dist/utils/plugin-styles.js +54 -0
  305. package/dist/utils/record-timeline.d.ts +10 -9
  306. package/dist/utils/record-timeline.js +12 -17
  307. package/exports.txt +226 -0
  308. package/package.json +13 -3
  309. package/dist/constants/IntlLanguages.d.ts +0 -74
  310. package/dist/constants/IntlLanguages.js +0 -76
  311. package/dist/hooks/use-query-state.d.ts +0 -16
  312. package/dist/hooks/use-query-state.js +0 -122
  313. package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
  314. package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
  315. package/dist/types/Theme.d.ts +0 -1
  316. package/dist/types/Theme.js +0 -0
  317. package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
  318. package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
@@ -1,6 +1,16 @@
1
+ import { TContactContentType } from "../modules/records/contacts.js";
2
+ import { RecordRef } from "../modules/records/openRecord.js";
1
3
  import { Icon } from "@tabler/icons-react";
2
- /** A property input's own settings, stored with the custom field; each input defines its keys. */
4
+ import { UseQueryOptions } from "@tanstack/react-query";
5
+ /**
6
+ * A property input's own settings, stored with the custom field.
7
+ * Each input defines its keys.
8
+ */
3
9
  export type TPropertyInputMeta = Record<string, unknown>;
10
+ /**
11
+ * Props of a plugin's activity row component in `widgets.activityRows`.
12
+ * The shape comes from erxes 3.x; web doesn't read `widgets` from a plugin's config.
13
+ */
4
14
  export type TActivityRowProps = {
5
15
  activity: {
6
16
  _id: string;
@@ -11,6 +21,11 @@ export type TActivityRowProps = {
11
21
  metadata?: Record<string, unknown>;
12
22
  };
13
23
  };
24
+ /**
25
+ * Props of a custom property input in `widgets.propertyInputs`.
26
+ * It edits the field's value as text and its own settings as `meta`. The shape comes from
27
+ * erxes 3.x; web doesn't read `widgets` from a plugin's config.
28
+ */
14
29
  export type TPropertyInputProps = {
15
30
  value: string;
16
31
  onValueChange: (value: string) => void;
@@ -18,18 +33,131 @@ export type TPropertyInputProps = {
18
33
  onMetaChange: (meta: TPropertyInputMeta) => void;
19
34
  disabled?: boolean;
20
35
  };
36
+ /** The schematic a dashboard widget shows in the widget catalog. */
21
37
  export type TDashboardWidgetPreview = 'bar' | 'line' | 'area' | 'pie' | 'table' | 'list' | 'kpi' | 'heatmap' | 'progress';
38
+ /** What a record section is given: the customer or company it shows on. */
39
+ export type TRecordSectionProps = {
40
+ contentType: TContactContentType;
41
+ contentId: string;
42
+ };
43
+ /**
44
+ * A plugin's section on a customer's or company's detail in core's panel.
45
+ * It sits under core's own sections, e.g. the customer's deals. One that crashes shows its
46
+ * error, not the panel's.
47
+ */
48
+ export type TRecordSection = {
49
+ contentType: TContactContentType;
50
+ /** The section's heading. */
51
+ title: string;
52
+ icon: React.ElementType;
53
+ component: React.ComponentType<TRecordSectionProps>;
54
+ };
55
+ /** What each slot of a plugin record is given: the record. */
56
+ export type TRecordSlotProps = RecordRef;
57
+ /**
58
+ * The customers and companies a record is about.
59
+ * Its relation tabs list records of these.
60
+ */
61
+ export type TRecordContacts = {
62
+ customerIds: string[];
63
+ companyIds: string[];
64
+ };
65
+ /** A plugin record type's own tab, after core's Detail or Activity tab. */
66
+ export type TRecordTab = {
67
+ value: string;
68
+ label: string;
69
+ icon: Icon;
70
+ after?: 'detail' | 'activity';
71
+ component: React.ComponentType<TRecordSlotProps>;
72
+ };
73
+ /**
74
+ * Props of a plugin record type's `New` slot, the draft form.
75
+ * The draft is saved as the record on Save.
76
+ */
77
+ export type TRecordDraftProps = {
78
+ /** What its opener passed (`useOpenRecord().openNew(type, defaults)`), e.g. a stage. */
79
+ defaults: Record<string, unknown>;
80
+ /** Call with the saved record's id: the record takes the draft's place in the panel. */
81
+ onCreated: (id: string) => void;
82
+ /** Leaves the draft: back to the record it came from, else closes the panel. */
83
+ onCancel: () => void;
84
+ };
85
+ /**
86
+ * A record type a plugin shows in core's side panel. Core draws the panel as it draws a
87
+ * customer's: header with Back, expand and close, the tabs (Detail, the type's own `tabs`,
88
+ * every allowed plugin's relation tabs for it, Activity), resizing, the address
89
+ * `?panel=/detail/<contentType>/<id>`, drafts. The plugin fills the slots. Open one with
90
+ * `useOpenRecord().open({ contentType, contentId })`, a draft with `openNew(contentType)`.
91
+ */
92
+ export type TPanelRecordType = {
93
+ /** `<plugin name>:<thing>`, e.g. `sales:deal`; it must start with the plugin's `name`. */
94
+ contentType: string;
95
+ /** What one is called, e.g. "Deal": a draft's header reads "New deal". */
96
+ title: string;
97
+ icon: React.ElementType;
98
+ /**
99
+ * The record's own page, where the panel's expand button leads: a route of the plugin's,
100
+ * under its `path`, that renders `<RecordPage contentType contentId />`.
101
+ */
102
+ detailPath: (contentId: string) => string;
103
+ /** The header's title: the record's name, editable in place if the plugin wants. */
104
+ Title: React.ComponentType<TRecordSlotProps>;
105
+ /** The header's own actions (a "more" menu), before expand and close. */
106
+ Actions?: React.ComponentType<TRecordSlotProps>;
107
+ /** The Detail tab: `PanelSection`s of `PanelField` rows. */
108
+ Detail: React.ComponentType<TRecordSlotProps>;
109
+ tabs?: TRecordTab[];
110
+ /** A record not created yet; without it, the type has no drafts. */
111
+ New?: React.ComponentType<TRecordDraftProps>;
112
+ /**
113
+ * The record's customers and companies, as query options (often the record's own query with
114
+ * `select`). Without it, plugins' relation tabs don't show on this type.
115
+ */
116
+ contacts?: (contentId: string) => UseQueryOptions<TRecordContacts, Error, TRecordContacts>;
117
+ /** A timeline type of the plugin's manifest (`timelines`): core's Activity tab shows it. */
118
+ activity?: string;
119
+ };
120
+ /** Props of a relation tab: the record it shows on, and its contacts. */
121
+ export type TRelationTabProps = TRecordSlotProps & TRecordContacts;
122
+ /**
123
+ * A plugin's tab on other records' panels, listing its own records.
124
+ * It lists the plugin's own records of the same customers and companies: a customer's deals.
125
+ * Shown on core's customers and companies (their contacts are themselves), and on the plugin
126
+ * record types `hosts` names that give `contacts` (a task's deals). A record clicked in it opens
127
+ * on top in the same panel (`useOpenRecord().open`), and Back returns.
128
+ */
129
+ export type TRelationTab = {
130
+ /** Unique within the plugin, e.g. `deals`. */
131
+ name: string;
132
+ title: string;
133
+ icon: Icon;
134
+ /** Plugin record types it also shows on (`tasks:task`); customers and companies always. */
135
+ hosts?: string[];
136
+ component: React.ComponentType<TRelationTabProps>;
137
+ };
138
+ /**
139
+ * A plugin UI's `CONFIG`, exported from its `./config` remote.
140
+ * web reads `name`, `path`, `icon`, `modules`, `checkAccess`, `recordSections`, `recordTypes`
141
+ * and `relationTabs`; its first module renders under `/<path>/*`. The other fields come from
142
+ * erxes 3.x and web ignores them.
143
+ */
22
144
  export type IUIConfig = {
23
145
  name: string;
24
146
  path: string;
25
147
  icon?: React.ElementType;
148
+ /** Sections on core's customer and company detail, shown to members who may use the plugin. */
149
+ recordSections?: TRecordSection[];
150
+ /** The plugin's records core's side panel opens, for members who may use the plugin. */
151
+ recordTypes?: TPanelRecordType[];
152
+ /** Tabs on other records' panels listing the plugin's records of their contacts. */
153
+ relationTabs?: TRelationTab[];
26
154
  i18n?: boolean;
27
155
  i18nNamespace?: string;
28
156
  hasFloatingWidget?: boolean;
29
157
  /**
30
158
  * erxes platform versions this plugin is built for, as a semver range
31
- * (e.g. `'~3.2'`, `'>=3.2.25 <3.4'`). Core warns — and still loads the
32
- * plugin — when the running platform is outside the range.
159
+ * (e.g. `'~3.2'`, `'>=3.2.25 <3.4'`). Core warns, and still loads the
160
+ * plugin, when the running platform is outside the range.
33
161
  */
34
162
  platform?: string;
35
163
  navigationGroup?: {
@@ -1 +1,2 @@
1
+ /** True for `null` and `undefined`, and narrows the value's type. */
1
2
  export declare const isUndefinedOrNull: (value: unknown) => value is null | undefined;
@@ -1,3 +1,4 @@
1
1
  // src/utils/IsUndefinedOrNull.ts
2
+ /** True for `null` and `undefined`, and narrows the value's type. */
2
3
  const isUndefinedOrNull = (value) => value === void 0 || value === null;
3
4
  export { isUndefinedOrNull };
@@ -12,6 +12,7 @@ export interface FileStorageAdapter {
12
12
  /** Deletes a file by the address `upload` returned. */
13
13
  remove?(address: string): Promise<void>;
14
14
  }
15
+ /** Sets where uploads go; web calls it at startup and plugins don't. */
15
16
  export declare const setFileStorage: (next: FileStorageAdapter | null) => void;
16
17
  export declare const storeFile: (file: File, options?: Parameters<FileStorageAdapter['upload']>[1]) => Promise<string>;
17
18
  export declare const removeStoredFile: (address: string) => Promise<void>;
@@ -1,5 +1,6 @@
1
1
  // src/utils/file-storage.ts
2
2
  let adapter = null;
3
+ /** Sets where uploads go; web calls it at startup and plugins don't. */
3
4
  const setFileStorage = (next) => {
4
5
  adapter = next;
5
6
  };
@@ -1,4 +1,8 @@
1
1
  import { CountryCode } from "libphonenumber-js";
2
+ /**
3
+ * A phone number formatted as people write it, even half typed.
4
+ * `defaultCountry` decides how a number without a `+` code reads.
5
+ */
2
6
  export declare const formatPhoneNumber: ({ defaultCountry, value }: {
3
7
  defaultCountry?: CountryCode;
4
8
  value: string;
@@ -1,5 +1,9 @@
1
1
  import { AsYouType } from "libphonenumber-js";
2
2
  // src/utils/format/formatPhoneNumber.ts
3
+ /**
4
+ * A phone number formatted as people write it, even half typed.
5
+ * `defaultCountry` decides how a number without a `+` code reads.
6
+ */
3
7
  const formatPhoneNumber = ({ defaultCountry, value }) => {
4
8
  return new AsYouType({ defaultCountry }).input(value);
5
9
  };
@@ -1 +1,6 @@
1
+ /**
2
+ * A file's URL in a plugin UI's deployed `assets` folder.
3
+ * `getPluginAssetsUrl('hr', 'logo.svg')` resolves next to the `hr_ui` remote entry. For a plugin
4
+ * web hasn't registered, it returns `url` unchanged.
5
+ */
1
6
  export declare const getPluginAssetsUrl: (pluginName: string, url: string) => string;
@@ -1,5 +1,10 @@
1
1
  import { getInstance } from "@module-federation/enhanced/runtime";
2
2
  // src/utils/getPluginAssetsUrl.ts
3
+ /**
4
+ * A file's URL in a plugin UI's deployed `assets` folder.
5
+ * `getPluginAssetsUrl('hr', 'logo.svg')` resolves next to the `hr_ui` remote entry. For a plugin
6
+ * web hasn't registered, it returns `url` unchanged.
7
+ */
3
8
  const getPluginAssetsUrl = (pluginName, url) => {
4
9
  const remote = (getInstance()?.options.remotes)?.find((r) => r.name === `${pluginName}_ui`);
5
10
  if (remote && "entry" in remote && typeof remote.entry === "string") return `${remote.entry.replace("remoteEntry.js", "assets")}/${url}`;
@@ -0,0 +1,10 @@
1
+ import { ComponentType } from "react";
2
+ /**
3
+ * A component the host app (web) provides at startup and plugin UIs render: core's timeline,
4
+ * a record's own page, a list's filter. erxes-ui is a Module Federation singleton, so every
5
+ * plugin gets the host's. Outside erxes nothing is registered and it renders nothing.
6
+ */
7
+ export declare const hostComponent: <P extends object>() => {
8
+ set: (component: ComponentType<P> | null) => void;
9
+ Host: (props: P) => import("react").JSX.Element | null;
10
+ };
@@ -0,0 +1,34 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Suspense, useSyncExternalStore } from "react";
3
+ // src/utils/host-component.tsx
4
+ /**
5
+ * A component the host app (web) provides at startup and plugin UIs render: core's timeline,
6
+ * a record's own page, a list's filter. erxes-ui is a Module Federation singleton, so every
7
+ * plugin gets the host's. Outside erxes nothing is registered and it renders nothing.
8
+ */
9
+ const hostComponent = () => {
10
+ let registered = null;
11
+ const listeners = /* @__PURE__ */ new Set();
12
+ const subscribe = (listener) => {
13
+ listeners.add(listener);
14
+ return () => listeners.delete(listener);
15
+ };
16
+ const read = () => registered;
17
+ const set = (component) => {
18
+ registered = component;
19
+ listeners.forEach((listener) => listener());
20
+ };
21
+ const Host = (props) => {
22
+ const Component = useSyncExternalStore(subscribe, read, read);
23
+ if (!Component) return null;
24
+ return /* @__PURE__ */ jsx(Suspense, {
25
+ fallback: null,
26
+ children: /* @__PURE__ */ jsx(Component, { ...props })
27
+ });
28
+ };
29
+ return {
30
+ set,
31
+ Host
32
+ };
33
+ };
34
+ export { hostComponent };
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * A JSON string that decodes to `schema`: `jsonOf(schema).safeParse(text)` fails
4
- * on text that isn't JSON the same way it fails on JSON of the wrong shape.
3
+ * A zod schema for a JSON string that decodes to `schema`.
4
+ * `jsonOf(schema).safeParse(text)` fails on text that isn't JSON the same way it fails on JSON
5
+ * of the wrong shape.
5
6
  */
6
7
  export declare const jsonOf: <S extends z.ZodType>(schema: S) => z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>, S>;
@@ -1,8 +1,9 @@
1
1
  import { z } from "zod";
2
2
  // src/utils/json.ts
3
3
  /**
4
- * A JSON string that decodes to `schema`: `jsonOf(schema).safeParse(text)` fails
5
- * on text that isn't JSON the same way it fails on JSON of the wrong shape.
4
+ * A zod schema for a JSON string that decodes to `schema`.
5
+ * `jsonOf(schema).safeParse(text)` fails on text that isn't JSON the same way it fails on JSON
6
+ * of the wrong shape.
6
7
  */
7
8
  const jsonOf = (schema) => z.string().transform((text, ctx) => {
8
9
  try {
@@ -1,17 +1,5 @@
1
1
  import { z } from "zod";
2
- /**
3
- * How plugin UIs reach their own API and hear about changes. The host app
4
- * (web) provides the runtime; erxes-ui is a Module Federation singleton,
5
- * so every plugin UI gets the host's.
6
- *
7
- * - `pluginFetch('hr', '/leaves')` calls the plugin's API (its address comes
8
- * from the plugin's manifest) with a 5-minute token core issues for this
9
- * member and this plugin only. The plugin verifies it with core's public
10
- * keys; core's session cookie never leaves core.
11
- * - `useLiveSignal('hr', ['leaves'], refetch)` runs when the plugin says a
12
- * topic changed (`core_live_signal` / `POST /core/v1/plugins/live`), and
13
- * after reconnecting, over the one stream the browser keeps with core.
14
- */
2
+ /** A member's short-lived token for one plugin's API, and its address. */
15
3
  export interface PluginSession {
16
4
  token: string;
17
5
  /** ISO time the token stops working. */
@@ -19,21 +7,37 @@ export interface PluginSession {
19
7
  /** The plugin API's address, from its manifest. */
20
8
  apiUrl: string | null;
21
9
  }
10
+ /**
11
+ * A message on core's live stream: a plugin's changed topics, or resync.
12
+ * `resync` comes after a reconnect, when signals sent meanwhile were missed.
13
+ */
22
14
  export type PluginLiveMessage = {
23
15
  plugin: string;
24
16
  topics: string[];
25
17
  } | {
26
18
  resync: true;
27
19
  };
20
+ /**
21
+ * What the host gives plugin UIs: plugin API sessions and the live stream.
22
+ * web provides it with `setPluginRuntime`; plugins call `pluginFetch`, `pluginJson` and
23
+ * `useLiveSignal`, which use it.
24
+ */
28
25
  export interface PluginRuntime {
29
26
  session(plugin: string): Promise<PluginSession>;
30
27
  subscribe(listener: (message: PluginLiveMessage) => void): () => void;
31
28
  }
29
+ /**
30
+ * Sets the plugin runtime; web calls it at startup and plugins don't.
31
+ * It drops every cached plugin session.
32
+ */
32
33
  export declare const setPluginRuntime: (next: PluginRuntime | null) => void;
34
+ /** The host's plugin runtime, or null outside erxes. */
33
35
  export declare const getPluginRuntime: () => PluginRuntime | null;
34
36
  /**
35
37
  * `fetch` against a plugin's API as the signed-in member. Relative paths are
36
- * resolved against the plugin's API address; a 401 renews the token once.
38
+ * resolved against the plugin's API address; a 401 renews the token once and
39
+ * sends the call again, so `init.body` must be one that can be sent twice
40
+ * (text, an ArrayBuffer, a Blob or FormData, not a stream).
37
41
  */
38
42
  export declare const pluginFetch: (plugin: string, path: string, init?: RequestInit) => Promise<Response>;
39
43
  /**
@@ -44,8 +48,8 @@ export declare const pluginJson: <S extends z.ZodType>(plugin: string, path: str
44
48
  json?: unknown;
45
49
  }) => Promise<z.infer<S>>;
46
50
  /**
47
- * Runs `onSignal(topics)` when the plugin announces a change to any of
48
- * `topics` — and after a reconnect (with every topic), since signals sent
49
- * meanwhile were missed.
51
+ * Runs `onSignal` when a plugin says one of `topics` changed, to refetch.
52
+ * It also runs after a reconnect, with every topic, since signals sent meanwhile were missed.
53
+ * Outside erxes it never runs.
50
54
  */
51
55
  export declare const useLiveSignal: (plugin: string, topics: string | string[], onSignal: (topics: string[]) => void) => void;
@@ -4,28 +4,74 @@ import { z } from "zod";
4
4
  // src/utils/plugin-runtime.ts
5
5
  let runtime = null;
6
6
  const sessions = /* @__PURE__ */ new Map();
7
+ /** A token is replaced this long before it ends, so no call carries one about to expire. */
8
+ const RENEW_BEFORE_MS = 3e4;
9
+ /**
10
+ * Sets the plugin runtime; web calls it at startup and plugins don't.
11
+ * It drops every cached plugin session.
12
+ */
7
13
  const setPluginRuntime = (next) => {
8
14
  runtime = next;
9
15
  sessions.clear();
10
16
  };
17
+ /** The host's plugin runtime, or null outside erxes. */
11
18
  const getPluginRuntime = () => runtime;
12
19
  const need = () => {
13
20
  if (!runtime) throw new Error("erxes plugin runtime is not available (open the plugin inside erxes)");
14
21
  return runtime;
15
22
  };
16
- /** A cached session, renewed 30 seconds before it ends. */
17
- const sessionOf = (plugin, fresh = false) => {
18
- const cached = sessions.get(plugin);
19
- if (cached && !fresh) return cached.then((session) => new Date(session.expiresAt).getTime() - Date.now() > 3e4 ? session : sessionOf(plugin, true));
20
- const request = need().session(plugin);
23
+ const Lifetime = jsonOf(z.object({
24
+ iat: z.number(),
25
+ exp: z.number()
26
+ }));
27
+ /** A JWT's claims as text; '' for a token that isn't one (its lifetime then comes from `expiresAt`). */
28
+ const claimsText = (token) => {
29
+ try {
30
+ return atob((token.split(".")[1] ?? "").replaceAll("-", "+").replaceAll("_", "/"));
31
+ } catch {
32
+ return "";
33
+ }
34
+ };
35
+ /**
36
+ * How long a token lasts, from its own claims (both core's clock), so a
37
+ * browser whose clock is set wrong still renews on time.
38
+ */
39
+ const lifetimeMs = (session) => {
40
+ const claims = Lifetime.safeParse(claimsText(session.token));
41
+ return claims.success ? (claims.data.exp - claims.data.iat) * 1e3 : new Date(session.expiresAt).getTime() - Date.now();
42
+ };
43
+ const renew = (plugin) => {
44
+ const request = need().session(plugin).then((session) => ({
45
+ session,
46
+ endsAt: Date.now() + lifetimeMs(session)
47
+ }));
21
48
  sessions.set(plugin, request);
22
- request.catch(() => sessions.delete(plugin));
49
+ request.catch(() => {
50
+ if (sessions.get(plugin) === request) sessions.delete(plugin);
51
+ });
23
52
  return request;
24
53
  };
54
+ /**
55
+ * This member's session for `plugin`, renewed 30 seconds before it ends.
56
+ * `refused` is a token the plugin just turned down: it is replaced once, for
57
+ * every call that failed with it at the same time.
58
+ */
59
+ const sessionOf = async (plugin, refused) => {
60
+ const cached = sessions.get(plugin);
61
+ if (cached) {
62
+ const held = await cached.catch(() => null);
63
+ if (held && held.session.token !== refused && held.endsAt - Date.now() > RENEW_BEFORE_MS) return held.session;
64
+ const renewing = sessions.get(plugin);
65
+ if (renewing && renewing !== cached) return (await renewing).session;
66
+ }
67
+ return (await renew(plugin)).session;
68
+ };
25
69
  const join = (base, path) => `${base.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
26
70
  /**
27
71
  * `fetch` against a plugin's API as the signed-in member. Relative paths are
28
- * resolved against the plugin's API address; a 401 renews the token once.
72
+ * resolved against the plugin's API address; a 401 renews the token once and
73
+ * sends the call again, so `init.body` must be one that can be sent twice
74
+ * (text, an ArrayBuffer, a Blob or FormData, not a stream).
29
75
  */
30
76
  const pluginFetch = async (plugin, path, init = {}) => {
31
77
  const send = async (session) => {
@@ -38,8 +84,9 @@ const pluginFetch = async (plugin, path, init = {}) => {
38
84
  credentials: "omit"
39
85
  });
40
86
  };
41
- const response = await send(await sessionOf(plugin));
42
- return response.status === 401 ? send(await sessionOf(plugin, true)) : response;
87
+ const session = await sessionOf(plugin);
88
+ const response = await send(session);
89
+ return response.status === 401 ? send(await sessionOf(plugin, session.token)) : response;
43
90
  };
44
91
  const errorBody = z.object({ message: z.string() });
45
92
  /**
@@ -66,9 +113,9 @@ const pluginJson = async (plugin, path, schema, init = {}) => {
66
113
  return jsonOf(schema).parse(text || "null");
67
114
  };
68
115
  /**
69
- * Runs `onSignal(topics)` when the plugin announces a change to any of
70
- * `topics` — and after a reconnect (with every topic), since signals sent
71
- * meanwhile were missed.
116
+ * Runs `onSignal` when a plugin says one of `topics` changed, to refetch.
117
+ * It also runs after a reconnect, with every topic, since signals sent meanwhile were missed.
118
+ * Outside erxes it never runs.
72
119
  */
73
120
  const useLiveSignal = (plugin, topics, onSignal) => {
74
121
  const handler = useRef(onSignal);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Adds a plugin UI's compiled Tailwind to the page, minus what web has.
3
+ * Pass `css` from `import css from './styles.css?inline'`. It keeps the utilities layer without
4
+ * the classes the page already has, and the `@property` and `@keyframes` rules. Calling it again
5
+ * for the same plugin replaces its sheet.
6
+ */
7
+ export declare const addPluginStyles: (plugin: string, css: string) => void;
@@ -0,0 +1,54 @@
1
+ // src/utils/plugin-styles.ts
2
+ const sheets = /* @__PURE__ */ new Map();
3
+ /** The class a rule is for: `md\:flex` in `.md\:flex`, `space-y-2` in `:where(.space-y-2 > …)`. */
4
+ const CLASS = /\.((?:\\[\da-f]{1,6} ?|\\.|[\w-])+)/i;
5
+ const classOf = (rule) => rule instanceof CSSStyleRule ? CLASS.exec(rule.selectorText)?.[1] : void 0;
6
+ const collectClasses = (rules, into) => {
7
+ for (const rule of rules) {
8
+ const name = classOf(rule);
9
+ if (name) into.add(name);
10
+ else if (rule instanceof CSSGroupingRule) collectClasses(rule.cssRules, into);
11
+ }
12
+ };
13
+ /** Another origin's sheet can't be read; web's own and inline ones can. */
14
+ const sameOrigin = (sheet) => !sheet.href || new URL(sheet.href).origin === window.location.origin;
15
+ /** Every class the page's other style sheets style. */
16
+ const pageClasses = (except) => {
17
+ const classes = /* @__PURE__ */ new Set();
18
+ for (const sheet of [...document.styleSheets, ...document.adoptedStyleSheets]) if (sheet !== except && sameOrigin(sheet)) collectClasses(sheet.cssRules, classes);
19
+ return classes;
20
+ };
21
+ /** Deletes the rules for classes the page has, and the groups that leave empty. */
22
+ const dropKnown = (group, known) => {
23
+ for (let index = group.cssRules.length - 1; index >= 0; index--) {
24
+ const rule = group.cssRules[index];
25
+ const name = rule && classOf(rule);
26
+ if (name !== void 0 && known.has(name)) group.deleteRule(index);
27
+ else if (rule instanceof CSSGroupingRule && !(rule instanceof CSSStyleRule)) {
28
+ dropKnown(rule, known);
29
+ if (rule.cssRules.length === 0) group.deleteRule(index);
30
+ }
31
+ }
32
+ };
33
+ /** What a plugin sheet keeps besides its utilities: the custom properties and keyframes they use. */
34
+ const isSupport = (rule) => rule instanceof CSSPropertyRule || rule instanceof CSSKeyframesRule || rule instanceof CSSLayerStatementRule || rule instanceof CSSLayerBlockRule && rule.name === "properties";
35
+ /**
36
+ * Adds a plugin UI's compiled Tailwind to the page, minus what web has.
37
+ * Pass `css` from `import css from './styles.css?inline'`. It keeps the utilities layer without
38
+ * the classes the page already has, and the `@property` and `@keyframes` rules. Calling it again
39
+ * for the same plugin replaces its sheet.
40
+ */
41
+ const addPluginStyles = (plugin, css) => {
42
+ const previous = sheets.get(plugin);
43
+ const sheet = new CSSStyleSheet();
44
+ sheet.replaceSync(css);
45
+ for (let index = sheet.cssRules.length - 1; index >= 0; index--) {
46
+ const rule = sheet.cssRules[index];
47
+ const utilities = rule instanceof CSSLayerBlockRule && rule.name === "utilities";
48
+ if (rule && !utilities && !isSupport(rule)) sheet.deleteRule(index);
49
+ }
50
+ dropKnown(sheet, pageClasses(previous));
51
+ sheets.set(plugin, sheet);
52
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets.filter((adopted) => adopted !== previous), sheet];
53
+ };
54
+ export { addPluginStyles };
@@ -1,14 +1,15 @@
1
- import { ComponentType } from "react";
2
- /**
3
- * Core's timeline, for plugin UIs: `<RecordTimeline type="hr.employee" id={employee.id} />`
4
- * shows notes, mentions, pins, reactions, logged calls and the plugin's own
5
- * entries for one of its records (the type must be in the plugin's manifest
6
- * `timelines`). The host app (web) registers the component; erxes-ui is a
7
- * Module Federation singleton, so every plugin gets the host's.
8
- */
1
+ /** Which record `RecordTimeline` shows: its timeline type and id. */
9
2
  export type RecordTimelineProps = {
10
3
  type: string;
11
4
  id: string;
12
5
  };
13
- export declare const setRecordTimeline: (component: ComponentType<RecordTimelineProps> | null) => void;
6
+ /** Registers core's timeline; web calls it at startup and plugins don't. */
7
+ export declare const setRecordTimeline: (component: import("react").ComponentType<RecordTimelineProps> | null) => void;
8
+ /**
9
+ * Core's timeline of notes, calls and events for a plugin's record.
10
+ * `<RecordTimeline type="hr.employee" id={employee.id} />` shows notes, mentions, pins,
11
+ * reactions, logged calls and the plugin's own entries. The type must be in the plugin's
12
+ * manifest `timelines`. The host app (web) registers the component; outside erxes it renders
13
+ * nothing.
14
+ */
14
15
  export declare const RecordTimeline: (props: RecordTimelineProps) => import("react").JSX.Element | null;
@@ -1,19 +1,14 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useSyncExternalStore } from "react";
1
+ import { hostComponent } from "./host-component.js";
3
2
  // src/utils/record-timeline.tsx
4
- let registered = null;
5
- const listeners = /* @__PURE__ */ new Set();
6
- const setRecordTimeline = (component) => {
7
- registered = component;
8
- listeners.forEach((listener) => listener());
9
- };
10
- const subscribe = (listener) => {
11
- listeners.add(listener);
12
- return () => listeners.delete(listener);
13
- };
14
- const RecordTimeline = (props) => {
15
- const Component = useSyncExternalStore(subscribe, () => registered, () => registered);
16
- if (!Component) return null;
17
- return /* @__PURE__ */ jsx(Component, { ...props });
18
- };
3
+ const timeline = hostComponent();
4
+ /** Registers core's timeline; web calls it at startup and plugins don't. */
5
+ const setRecordTimeline = timeline.set;
6
+ /**
7
+ * Core's timeline of notes, calls and events for a plugin's record.
8
+ * `<RecordTimeline type="hr.employee" id={employee.id} />` shows notes, mentions, pins,
9
+ * reactions, logged calls and the plugin's own entries. The type must be in the plugin's
10
+ * manifest `timelines`. The host app (web) registers the component; outside erxes it renders
11
+ * nothing.
12
+ */
13
+ const RecordTimeline = timeline.Host;
19
14
  export { RecordTimeline, setRecordTimeline };