@rebasepro/app 0.0.1-canary.4829d6e

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/auth/api.d.ts +66 -0
  4. package/dist/auth/index.d.ts +13 -0
  5. package/dist/auth/types.d.ts +127 -0
  6. package/dist/auth/useRebaseAuthController.d.ts +13 -0
  7. package/dist/components/AIIcon.d.ts +17 -0
  8. package/dist/components/AuthSimulationMenu.d.ts +0 -0
  9. package/dist/components/ConfirmationDialog.d.ts +9 -0
  10. package/dist/components/Debug/UIReferenceView.d.ts +13 -0
  11. package/dist/components/Debug/UIStyleGuide.d.ts +2 -0
  12. package/dist/components/Debug/collection-views/CardViewDemo.d.ts +2 -0
  13. package/dist/components/Debug/collection-views/CollectionTableDemo.d.ts +2 -0
  14. package/dist/components/Debug/collection-views/KanbanBoardDemo.d.ts +2 -0
  15. package/dist/components/Debug/collection-views/index.d.ts +3 -0
  16. package/dist/components/Debug/collection-views/sample_data.d.ts +23 -0
  17. package/dist/components/Debug/crm-dashboard/CalendarWidget.d.ts +22 -0
  18. package/dist/components/Debug/crm-dashboard/CrmDashboardDemo.d.ts +2 -0
  19. package/dist/components/Debug/crm-dashboard/DashboardMetrics.d.ts +15 -0
  20. package/dist/components/Debug/crm-dashboard/PipelineOverview.d.ts +34 -0
  21. package/dist/components/Debug/crm-dashboard/RecentActivity.d.ts +19 -0
  22. package/dist/components/Debug/crm-dashboard/TaskFilters.d.ts +30 -0
  23. package/dist/components/Debug/crm-dashboard/TaskTable.d.ts +50 -0
  24. package/dist/components/Debug/crm-dashboard/TasksView.d.ts +41 -0
  25. package/dist/components/ErrorTooltip.d.ts +3 -0
  26. package/dist/components/ErrorView.d.ts +21 -0
  27. package/dist/components/LanguageToggle.d.ts +2 -0
  28. package/dist/components/LoginView/LoginView.d.ts +113 -0
  29. package/dist/components/LoginView/index.d.ts +2 -0
  30. package/dist/components/NotFoundPage.d.ts +2 -0
  31. package/dist/components/RebaseAuth.d.ts +10 -0
  32. package/dist/components/RebaseLogo.d.ts +7 -0
  33. package/dist/components/SchemaDriftBanner.d.ts +27 -0
  34. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  35. package/dist/components/UserDisplay.d.ts +7 -0
  36. package/dist/components/UserSelectPopover.d.ts +63 -0
  37. package/dist/components/UserSettingsView.d.ts +2 -0
  38. package/dist/components/common/index.d.ts +6 -0
  39. package/dist/components/common/table_height.d.ts +5 -0
  40. package/dist/components/common/types.d.ts +66 -0
  41. package/dist/components/common/useColumnsIds.d.ts +9 -0
  42. package/dist/components/common/useDataTableController.d.ts +45 -0
  43. package/dist/components/common/useDebouncedData.d.ts +9 -0
  44. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  45. package/dist/components/index.d.ts +18 -0
  46. package/dist/contexts/AdminModeController.d.ts +4 -0
  47. package/dist/contexts/AnalyticsContext.d.ts +3 -0
  48. package/dist/contexts/AuthControllerContext.d.ts +3 -0
  49. package/dist/contexts/CollectionScopeContext.d.ts +50 -0
  50. package/dist/contexts/ComponentOverrideContext.d.ts +42 -0
  51. package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
  52. package/dist/contexts/DataDriverContext.d.ts +3 -0
  53. package/dist/contexts/DataSourcesContext.d.ts +31 -0
  54. package/dist/contexts/DatabaseAdminContext.d.ts +3 -0
  55. package/dist/contexts/DialogsProvider.d.ts +4 -0
  56. package/dist/contexts/EffectiveRoleController.d.ts +4 -0
  57. package/dist/contexts/ModeController.d.ts +4 -0
  58. package/dist/contexts/RebaseClientInstanceContext.d.ts +6 -0
  59. package/dist/contexts/RebaseDataContext.d.ts +3 -0
  60. package/dist/contexts/SnackbarProvider.d.ts +2 -0
  61. package/dist/contexts/StorageSourceContext.d.ts +3 -0
  62. package/dist/contexts/StorageSourcesContext.d.ts +25 -0
  63. package/dist/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
  64. package/dist/contexts/index.d.ts +17 -0
  65. package/dist/core/PluginLifecycleManager.d.ts +17 -0
  66. package/dist/core/PluginProviderStack.d.ts +21 -0
  67. package/dist/core/Rebase.d.ts +15 -0
  68. package/dist/core/RebaseProps.d.ts +291 -0
  69. package/dist/core/RebaseRouter.d.ts +4 -0
  70. package/dist/core/RebaseRoutes.d.ts +17 -0
  71. package/dist/core/index.d.ts +4 -0
  72. package/dist/hooks/ApiConfigContext.d.ts +24 -0
  73. package/dist/hooks/data/delete.d.ts +33 -0
  74. package/dist/hooks/data/save.d.ts +40 -0
  75. package/dist/hooks/data/useCollection.d.ts +62 -0
  76. package/dist/hooks/data/useData.d.ts +13 -0
  77. package/dist/hooks/data/useDataOrder.d.ts +12 -0
  78. package/dist/hooks/data/useFetch.d.ts +43 -0
  79. package/dist/hooks/data/useRelationSelector.d.ts +52 -0
  80. package/dist/hooks/index.d.ts +36 -0
  81. package/dist/hooks/useAdminModeController.d.ts +19 -0
  82. package/dist/hooks/useAnalyticsController.d.ts +5 -0
  83. package/dist/hooks/useAuthController.d.ts +11 -0
  84. package/dist/hooks/useAuthSubscription.d.ts +2 -0
  85. package/dist/hooks/useBackendStorageSource.d.ts +30 -0
  86. package/dist/hooks/useBridgeRegistration.d.ts +18 -0
  87. package/dist/hooks/useBrowserTitleAndIcon.d.ts +6 -0
  88. package/dist/hooks/useBuildAdminModeController.d.ts +6 -0
  89. package/dist/hooks/useBuildEffectiveRoleController.d.ts +8 -0
  90. package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
  91. package/dist/hooks/useBuildModeController.d.ts +6 -0
  92. package/dist/hooks/useClipboard.d.ts +57 -0
  93. package/dist/hooks/useCollapsedGroups.d.ts +27 -0
  94. package/dist/hooks/useComponentOverride.d.ts +32 -0
  95. package/dist/hooks/useCustomizationController.d.ts +11 -0
  96. package/dist/hooks/useDialogsController.d.ts +11 -0
  97. package/dist/hooks/useEffectiveRoleController.d.ts +7 -0
  98. package/dist/hooks/useLargeLayout.d.ts +1 -0
  99. package/dist/hooks/useModeController.d.ts +19 -0
  100. package/dist/hooks/usePermissions.d.ts +12 -0
  101. package/dist/hooks/useRebaseClient.d.ts +5 -0
  102. package/dist/hooks/useRebaseContext.d.ts +11 -0
  103. package/dist/hooks/useRebaseRegistry.d.ts +34 -0
  104. package/dist/hooks/useResolvedComponent.d.ts +47 -0
  105. package/dist/hooks/useSlot.d.ts +18 -0
  106. package/dist/hooks/useSnackbarController.d.ts +20 -0
  107. package/dist/hooks/useStorageSource.d.ts +6 -0
  108. package/dist/hooks/useStudioBridge.d.ts +79 -0
  109. package/dist/hooks/useTranslation.d.ts +17 -0
  110. package/dist/hooks/useUnsavedChangesDialog.d.ts +12 -0
  111. package/dist/hooks/useUserConfigurationPersistence.d.ts +8 -0
  112. package/dist/i18n/RebaseI18nProvider.d.ts +33 -0
  113. package/dist/index.d.ts +16 -0
  114. package/dist/index.es.js +16843 -0
  115. package/dist/index.es.js.map +1 -0
  116. package/dist/index.umd.js +17021 -0
  117. package/dist/index.umd.js.map +1 -0
  118. package/dist/internal/common.d.ts +14 -0
  119. package/dist/internal/useRestoreScroll.d.ts +15 -0
  120. package/dist/locales/de.d.ts +2 -0
  121. package/dist/locales/en.d.ts +10 -0
  122. package/dist/locales/es.d.ts +10 -0
  123. package/dist/locales/fr.d.ts +2 -0
  124. package/dist/locales/hi.d.ts +2 -0
  125. package/dist/locales/it.d.ts +2 -0
  126. package/dist/locales/pt.d.ts +7 -0
  127. package/dist/util/constants.d.ts +1 -0
  128. package/dist/util/createFormexStub.d.ts +2 -0
  129. package/dist/util/entity_cache.d.ts +22 -0
  130. package/dist/util/enums.d.ts +5 -0
  131. package/dist/util/icon_list.d.ts +5 -0
  132. package/dist/util/icons.d.ts +20 -0
  133. package/dist/util/index.d.ts +8 -0
  134. package/dist/util/previews.d.ts +4 -0
  135. package/dist/util/useStorageUploadController.d.ts +44 -0
  136. package/dist/vitePlugin.d.ts +60 -0
  137. package/dist/vitePlugin.js +113 -0
  138. package/package.json +145 -0
  139. package/src/auth/api.ts +148 -0
  140. package/src/auth/index.ts +25 -0
  141. package/src/auth/types.ts +115 -0
  142. package/src/auth/useRebaseAuthController.ts +328 -0
  143. package/src/components/AIIcon.tsx +47 -0
  144. package/src/components/AuthSimulationMenu.tsx +0 -0
  145. package/src/components/ConfirmationDialog.tsx +48 -0
  146. package/src/components/Debug/UIReferenceView.tsx +958 -0
  147. package/src/components/Debug/UIStyleGuide.tsx +156 -0
  148. package/src/components/Debug/collection-views/CardViewDemo.tsx +85 -0
  149. package/src/components/Debug/collection-views/CollectionTableDemo.tsx +107 -0
  150. package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +90 -0
  151. package/src/components/Debug/collection-views/index.ts +3 -0
  152. package/src/components/Debug/collection-views/sample_data.ts +42 -0
  153. package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +389 -0
  154. package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +1102 -0
  155. package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +133 -0
  156. package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +290 -0
  157. package/src/components/Debug/crm-dashboard/RecentActivity.tsx +215 -0
  158. package/src/components/Debug/crm-dashboard/TaskFilters.tsx +184 -0
  159. package/src/components/Debug/crm-dashboard/TaskTable.tsx +427 -0
  160. package/src/components/Debug/crm-dashboard/TasksView.tsx +234 -0
  161. package/src/components/ErrorTooltip.tsx +12 -0
  162. package/src/components/ErrorView.tsx +94 -0
  163. package/src/components/LanguageToggle.tsx +59 -0
  164. package/src/components/LoginView/LoginView.tsx +932 -0
  165. package/src/components/LoginView/index.ts +2 -0
  166. package/src/components/NotFoundPage.tsx +27 -0
  167. package/src/components/RebaseAuth.tsx +27 -0
  168. package/src/components/RebaseLogo.tsx +29 -0
  169. package/src/components/SchemaDriftBanner.tsx +102 -0
  170. package/src/components/UnsavedChangesDialog.tsx +46 -0
  171. package/src/components/UserDisplay.tsx +54 -0
  172. package/src/components/UserSelectPopover.tsx +399 -0
  173. package/src/components/UserSettingsView.tsx +318 -0
  174. package/src/components/common/index.ts +6 -0
  175. package/src/components/common/table_height.tsx +21 -0
  176. package/src/components/common/types.tsx +66 -0
  177. package/src/components/common/useColumnsIds.tsx +222 -0
  178. package/src/components/common/useDataTableController.tsx +514 -0
  179. package/src/components/common/useDebouncedData.ts +49 -0
  180. package/src/components/common/useScrollRestoration.tsx +68 -0
  181. package/src/components/index.tsx +26 -0
  182. package/src/contexts/AdminModeController.tsx +11 -0
  183. package/src/contexts/AnalyticsContext.tsx +4 -0
  184. package/src/contexts/AuthControllerContext.tsx +4 -0
  185. package/src/contexts/CollectionScopeContext.tsx +67 -0
  186. package/src/contexts/ComponentOverrideContext.tsx +81 -0
  187. package/src/contexts/CustomizationControllerContext.tsx +4 -0
  188. package/src/contexts/DataDriverContext.tsx +4 -0
  189. package/src/contexts/DataSourcesContext.tsx +36 -0
  190. package/src/contexts/DatabaseAdminContext.tsx +4 -0
  191. package/src/contexts/DialogsProvider.tsx +56 -0
  192. package/src/contexts/EffectiveRoleController.tsx +12 -0
  193. package/src/contexts/ModeController.tsx +11 -0
  194. package/src/contexts/RebaseClientInstanceContext.tsx +7 -0
  195. package/src/contexts/RebaseDataContext.tsx +4 -0
  196. package/src/contexts/SnackbarProvider.tsx +15 -0
  197. package/src/contexts/StorageSourceContext.tsx +4 -0
  198. package/src/contexts/StorageSourcesContext.tsx +30 -0
  199. package/src/contexts/UserConfigurationPersistenceContext.tsx +4 -0
  200. package/src/contexts/index.ts +17 -0
  201. package/src/core/PluginLifecycleManager.tsx +95 -0
  202. package/src/core/PluginProviderStack.tsx +40 -0
  203. package/src/core/Rebase.tsx +439 -0
  204. package/src/core/RebaseProps.tsx +320 -0
  205. package/src/core/RebaseRouter.tsx +17 -0
  206. package/src/core/RebaseRoutes.tsx +24 -0
  207. package/src/core/index.tsx +5 -0
  208. package/src/hooks/ApiConfigContext.tsx +41 -0
  209. package/src/hooks/data/delete.ts +55 -0
  210. package/src/hooks/data/save.ts +77 -0
  211. package/src/hooks/data/useCollection.tsx +176 -0
  212. package/src/hooks/data/useData.tsx +18 -0
  213. package/src/hooks/data/useDataOrder.ts +26 -0
  214. package/src/hooks/data/useFetch.tsx +140 -0
  215. package/src/hooks/data/useRelationSelector.tsx +234 -0
  216. package/src/hooks/index.tsx +45 -0
  217. package/src/hooks/useAdminModeController.tsx +23 -0
  218. package/src/hooks/useAnalyticsController.tsx +8 -0
  219. package/src/hooks/useAuthController.tsx +14 -0
  220. package/src/hooks/useAuthSubscription.ts +87 -0
  221. package/src/hooks/useBackendStorageSource.ts +288 -0
  222. package/src/hooks/useBridgeRegistration.tsx +32 -0
  223. package/src/hooks/useBrowserTitleAndIcon.tsx +23 -0
  224. package/src/hooks/useBuildAdminModeController.tsx +24 -0
  225. package/src/hooks/useBuildEffectiveRoleController.tsx +31 -0
  226. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +75 -0
  227. package/src/hooks/useBuildModeController.tsx +71 -0
  228. package/src/hooks/useClipboard.tsx +158 -0
  229. package/src/hooks/useCollapsedGroups.ts +116 -0
  230. package/src/hooks/useComponentOverride.tsx +59 -0
  231. package/src/hooks/useCustomizationController.tsx +14 -0
  232. package/src/hooks/useDialogsController.tsx +15 -0
  233. package/src/hooks/useEffectiveRoleController.tsx +10 -0
  234. package/src/hooks/useLargeLayout.tsx +65 -0
  235. package/src/hooks/useModeController.tsx +23 -0
  236. package/src/hooks/usePermissions.ts +44 -0
  237. package/src/hooks/useRebaseClient.tsx +10 -0
  238. package/src/hooks/useRebaseContext.tsx +83 -0
  239. package/src/hooks/useRebaseRegistry.tsx +91 -0
  240. package/src/hooks/useResolvedComponent.tsx +159 -0
  241. package/src/hooks/useSlot.tsx +64 -0
  242. package/src/hooks/useSnackbarController.tsx +52 -0
  243. package/src/hooks/useStorageSource.tsx +11 -0
  244. package/src/hooks/useStudioBridge.tsx +209 -0
  245. package/src/hooks/useTranslation.ts +33 -0
  246. package/src/hooks/useUnsavedChangesDialog.tsx +64 -0
  247. package/src/hooks/useUserConfigurationPersistence.tsx +11 -0
  248. package/src/i18n/RebaseI18nProvider.tsx +160 -0
  249. package/src/index.ts +25 -0
  250. package/src/internal/common.tsx +16 -0
  251. package/src/internal/useRestoreScroll.tsx +69 -0
  252. package/src/locales/de.ts +902 -0
  253. package/src/locales/en.ts +980 -0
  254. package/src/locales/es.ts +922 -0
  255. package/src/locales/fr.ts +901 -0
  256. package/src/locales/hi.ts +901 -0
  257. package/src/locales/it.ts +901 -0
  258. package/src/locales/pt.ts +909 -0
  259. package/src/util/constants.ts +7 -0
  260. package/src/util/createFormexStub.tsx +66 -0
  261. package/src/util/entity_cache.ts +239 -0
  262. package/src/util/enums.ts +32 -0
  263. package/src/util/icon_list.ts +22 -0
  264. package/src/util/icons.tsx +149 -0
  265. package/src/util/index.ts +12 -0
  266. package/src/util/previews.ts +105 -0
  267. package/src/util/useStorageUploadController.tsx +350 -0
  268. package/src/vitePlugin.ts +196 -0
@@ -0,0 +1,11 @@
1
+ import { UserConfigurationPersistence } from "@rebasepro/types";
2
+ import { useContext } from "react";
3
+ import { UserConfigurationPersistenceContext } from "../contexts/UserConfigurationPersistenceContext";
4
+
5
+ /**
6
+ * Use this controller to access the configuration that is stored externally,
7
+ * and not defined in code
8
+ *
9
+ * @group Hooks and utilities
10
+ */
11
+ export const useUserConfigurationPersistence = (): UserConfigurationPersistence | undefined => useContext(UserConfigurationPersistenceContext);
@@ -0,0 +1,160 @@
1
+ import React, { PropsWithChildren, useEffect, useRef } from "react";
2
+ import i18next, { i18n } from "i18next";
3
+ import { I18nextProvider, initReactI18next } from "react-i18next";
4
+ import { en } from "../locales/en";
5
+ import { es } from "../locales/es";
6
+ import { de } from "../locales/de";
7
+ import { fr } from "../locales/fr";
8
+ import { it } from "../locales/it";
9
+ import { hi } from "../locales/hi";
10
+ import { pt } from "../locales/pt";
11
+ import { RebaseTranslations } from "@rebasepro/types";
12
+
13
+ const REBASE_NS = "rebase_core";
14
+
15
+ export const REBASE_LOCALE_STORAGE_KEY = "rebase_locale";
16
+
17
+ /** DeepPartial helper — allows partial overrides at any nesting level */
18
+ type DeepPartial<T> = T extends object
19
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
20
+ : T;
21
+
22
+ export interface RebaseI18nProviderProps {
23
+ /** BCP-47 locale tag, e.g. "en", "es", "fr". Defaults to "en". */
24
+ locale?: string;
25
+ /**
26
+ * Override or extend any Rebase UI string, keyed by locale.
27
+ *
28
+ * @example
29
+ * translations={{
30
+ * en: { save: "Publish" },
31
+ * es: { save: "Publicar", discard: "Descartar" }
32
+ * }}
33
+ */
34
+ translations?: {
35
+ [locale: string]: DeepPartial<RebaseTranslations>;
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Initialises a dedicated i18next instance for Rebase's internal UI strings.
41
+ *
42
+ * This instance is isolated from any app-level i18next configuration the
43
+ * consumer may have. Mount this at the top of the Rebase component tree.
44
+ *
45
+ * @internal
46
+ */
47
+ export function RebaseI18nProvider({
48
+ locale = "en",
49
+ translations,
50
+ children
51
+ }: PropsWithChildren<RebaseI18nProviderProps>) {
52
+ const i18nRef = useRef<i18n | null>(null);
53
+ const [ready, setReady] = React.useState(false);
54
+
55
+ if (!i18nRef.current) {
56
+ const instance = i18next.createInstance();
57
+
58
+ // Build the initial resources: English baseline + any consumer overrides
59
+ const resources = buildResources(translations);
60
+
61
+ let initialLocale = locale;
62
+ if (typeof window !== "undefined") {
63
+ const stored = localStorage.getItem(REBASE_LOCALE_STORAGE_KEY);
64
+ if (stored) initialLocale = stored;
65
+ }
66
+
67
+ instance
68
+ .use(initReactI18next)
69
+ .init({
70
+ lng: initialLocale,
71
+ fallbackLng: "en",
72
+ ns: [REBASE_NS],
73
+ defaultNS: REBASE_NS,
74
+ resources,
75
+ interpolation: {
76
+ // React already escapes — don't double-escape
77
+ escapeValue: false
78
+ }
79
+ }, () => {
80
+ setReady(true);
81
+ });
82
+
83
+ instance.on("languageChanged", (lng) => {
84
+ if (typeof window !== "undefined") {
85
+ localStorage.setItem(REBASE_LOCALE_STORAGE_KEY, lng);
86
+ }
87
+ });
88
+
89
+ i18nRef.current = instance;
90
+ }
91
+
92
+ // When `locale` prop changes, switch language on the existing instance
93
+ // ONLY if the user hasn't explicitly set a preference
94
+ useEffect(() => {
95
+ if (i18nRef.current && i18nRef.current.language !== locale) {
96
+ const hasUserPreference = typeof window !== "undefined" && Boolean(localStorage.getItem(REBASE_LOCALE_STORAGE_KEY));
97
+ if (!hasUserPreference) {
98
+ i18nRef.current.changeLanguage(locale);
99
+ }
100
+ }
101
+ }, [locale]);
102
+
103
+ // When consumer translations prop changes, update the resource bundles
104
+ useEffect(() => {
105
+ if (!i18nRef.current) return;
106
+ const resources = buildResources(translations);
107
+ for (const [lang, bundle] of Object.entries(resources)) {
108
+ i18nRef.current.addResourceBundle(
109
+ lang,
110
+ REBASE_NS,
111
+ bundle[REBASE_NS],
112
+ true, // deep merge
113
+ true // overwrite existing keys
114
+ );
115
+ }
116
+ }, [translations]);
117
+
118
+ if (!ready || !i18nRef.current) return null;
119
+
120
+ return (
121
+ <I18nextProvider i18n={i18nRef.current}>
122
+ {children}
123
+ </I18nextProvider>
124
+ );
125
+ }
126
+
127
+ /**
128
+ * Build an i18next resources object from the English baseline plus any
129
+ * consumer-provided overrides.
130
+ */
131
+ function buildResources(
132
+ translations?: { [locale: string]: DeepPartial<RebaseTranslations> }
133
+ ): Record<string, Record<string, object>> {
134
+ const resources: Record<string, Record<string, object>> = {
135
+ en: { [REBASE_NS]: { ...en } },
136
+ es: { [REBASE_NS]: { ...es } },
137
+ de: { [REBASE_NS]: { ...de } },
138
+ fr: { [REBASE_NS]: { ...fr } },
139
+ it: { [REBASE_NS]: { ...it } },
140
+ hi: { [REBASE_NS]: { ...hi } },
141
+ pt: { [REBASE_NS]: { ...pt } }
142
+ };
143
+
144
+ if (!translations) return resources;
145
+
146
+ for (const [lang, overrides] of Object.entries(translations)) {
147
+ if (!resources[lang]) {
148
+ // For non-English/Spanish locales, start from English as the fallback base
149
+ resources[lang] = { [REBASE_NS]: { ...en } };
150
+ }
151
+ // Merge consumer overrides (shallow merge is enough since translations
152
+ // is a flat record — deepMerge option in addResourceBundle handles deeper)
153
+ resources[lang][REBASE_NS] = {
154
+ ...resources[lang][REBASE_NS],
155
+ ...overrides
156
+ };
157
+ }
158
+
159
+ return resources;
160
+ }
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ export * from "./core";
2
+ export * from "./hooks";
3
+ export * from "./auth";
4
+ export * from "./components";
5
+ export * from "./util";
6
+ export * from "./contexts";
7
+
8
+ // @internal — framework implementation details, exported only because
9
+ // @rebasepro/admin and @rebasepro/studio consume them. Named explicitly
10
+ // (not `export *`) so this file is the single place that grows or shrinks
11
+ // the internal surface — see the JSDoc on each symbol for details.
12
+ export { CONTAINER_FULL_WIDTH, ADDITIONAL_TAB_WIDTH, FORM_CONTAINER_WIDTH } from "./internal/common";
13
+ export { useRestoreScroll } from "./internal/useRestoreScroll";
14
+ export { useUnsavedChangesDialog } from "./hooks/useUnsavedChangesDialog";
15
+ export type { UnsavedChangesDialogProps } from "./components/UnsavedChangesDialog";
16
+ export { UnsavedChangesDialog } from "./components/UnsavedChangesDialog";
17
+ export * from "./i18n/RebaseI18nProvider";
18
+ export * from "./locales/en";
19
+ export * from "./locales/es";
20
+
21
+ // Studio Bridge — shared context for optional CMS↔Studio integration
22
+ export * from "./hooks/useStudioBridge";
23
+
24
+ // Self-assembling bridge registration hook
25
+ export { useBridgeRegistration } from "./hooks/useBridgeRegistration";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Layout width primitives used by the framework's own side-panel and form
3
+ * dialog sizing logic.
4
+ *
5
+ * @internal Not part of the stable public API — exported only because
6
+ * `@rebasepro/admin` and `@rebasepro/studio` need them to compute the same
7
+ * dialog widths as the framework. Do not depend on these for app code; they
8
+ * may change shape or be removed without a major version bump.
9
+ */
10
+ export const CONTAINER_FULL_WIDTH = "100vw";
11
+
12
+ /** @internal See {@link CONTAINER_FULL_WIDTH}. */
13
+ export const ADDITIONAL_TAB_WIDTH = "55vw";
14
+
15
+ /** @internal See {@link CONTAINER_FULL_WIDTH}. */
16
+ export const FORM_CONTAINER_WIDTH = "768px";
@@ -0,0 +1,69 @@
1
+ import React, { useCallback, useEffect, useRef } from "react";
2
+ import { useLocation } from "react-router-dom";
3
+
4
+ const scrollsMap: Record<string, number> = {};
5
+
6
+ /**
7
+ * Restores per-route scroll position on a scrollable container, keyed by
8
+ * router location. Used by the framework's own home page implementations.
9
+ *
10
+ * @internal Not part of the stable public API — exported only because
11
+ * `@rebasepro/admin` and `@rebasepro/studio` reuse it in their home page
12
+ * components. Its behavior (module-level scroll cache, router coupling) is
13
+ * an implementation detail and may change without a major version bump.
14
+ */
15
+ export function useRestoreScroll() {
16
+
17
+ const location = useLocation();
18
+
19
+ const containerRef = useRef<HTMLDivElement>(null);
20
+ const [scroll, setScroll] = React.useState(0);
21
+ const [direction, setDirection] = React.useState<"up" | "down">("down");
22
+
23
+ // Use ref to track previous scroll for direction calculation
24
+ // This avoids recreating handleScroll on every scroll
25
+ const prevScrollRef = useRef(0);
26
+
27
+ const handleScroll = useCallback(() => {
28
+ if (!containerRef.current || !location.key) return;
29
+ const scrollTop = containerRef.current.scrollTop;
30
+ scrollsMap[location.key] = scrollTop;
31
+ setScroll(scrollTop);
32
+ setDirection(scrollTop > prevScrollRef.current ? "down" : "up");
33
+ prevScrollRef.current = scrollTop;
34
+ }, [location.key]);
35
+
36
+ useEffect(() => {
37
+ const container = containerRef.current;
38
+ if (!container) return;
39
+ container.addEventListener("scroll", handleScroll, { passive: true });
40
+
41
+ return () => {
42
+ if (container)
43
+ container.removeEventListener("scroll", handleScroll);
44
+ };
45
+ }, [handleScroll]);
46
+
47
+ // Defer scroll restoration to next tick to allow async content to render
48
+ // This is necessary because DefaultHomePage content loads asynchronously
49
+ useEffect(() => {
50
+ const savedScroll = scrollsMap[location.key];
51
+ if (!containerRef.current || !savedScroll) return;
52
+
53
+ const timeoutId = setTimeout(() => {
54
+ if (!containerRef.current) return;
55
+ containerRef.current.scrollTo({
56
+ top: savedScroll,
57
+ behavior: "auto"
58
+ });
59
+ }, 0);
60
+
61
+ return () => clearTimeout(timeoutId);
62
+ }, [location.key]);
63
+
64
+ return {
65
+ containerRef,
66
+ scroll,
67
+ direction
68
+ };
69
+ }