@rebasepro/cms 0.27.0 → 0.28.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 (63) hide show
  1. package/dist/collection_editor/serializable_utils.js +5 -2
  2. package/dist/collection_editor/serializable_utils.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +17 -0
  4. package/dist/collection_editor/ui/collection_editor/EnumForm.js +31 -17
  5. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  6. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +6 -5
  7. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +3 -2
  9. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +32 -16
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/DetailViewBinding.js +4 -3
  13. package/dist/components/DetailViewBinding.js.map +1 -1
  14. package/dist/components/EditViewBinding.js +23 -5
  15. package/dist/components/EditViewBinding.js.map +1 -1
  16. package/dist/components/EntityPreviewBinding.js +1 -0
  17. package/dist/components/EntityPreviewBinding.js.map +1 -1
  18. package/dist/components/SelectableTable/filters/StringNumberFilterField.js +3 -3
  19. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  20. package/dist/components/SidePanelBinding.js +7 -6
  21. package/dist/components/SidePanelBinding.js.map +1 -1
  22. package/dist/components/app/Scaffold.js +16 -1
  23. package/dist/components/app/Scaffold.js.map +1 -1
  24. package/dist/components/history/EntityHistoryView.js +2 -1
  25. package/dist/components/history/EntityHistoryView.js.map +1 -1
  26. package/dist/data_export/export/export.js +3 -3
  27. package/dist/data_export/export/export.js.map +1 -1
  28. package/dist/data_import/import/ImportCollectionAction.js +10 -12
  29. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  30. package/dist/data_import/utils/id_column.d.ts +19 -0
  31. package/dist/data_import/utils/id_column.js +19 -1
  32. package/dist/data_import/utils/id_column.js.map +1 -1
  33. package/dist/data_import/utils/transforms.js +24 -7
  34. package/dist/data_import/utils/transforms.js.map +1 -1
  35. package/dist/form/EntityForm.d.ts +1 -1
  36. package/dist/form/EntityForm.js +14 -4
  37. package/dist/form/EntityForm.js.map +1 -1
  38. package/dist/form/EntityFormBinding.js +12 -8
  39. package/dist/form/EntityFormBinding.js.map +1 -1
  40. package/dist/form/components/FieldBlock.js +2 -1
  41. package/dist/form/components/FieldBlock.js.map +1 -1
  42. package/dist/form/field_bindings/KeyValueFieldBinding.js +3 -1
  43. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  44. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +0 -2
  45. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  46. package/dist/form/field_bindings/TextFieldBinding.js +3 -2
  47. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  48. package/dist/form/validation.js +12 -1
  49. package/dist/form/validation.js.map +1 -1
  50. package/dist/hooks/navigation/url_segments.d.ts +33 -0
  51. package/dist/hooks/navigation/url_segments.js +56 -0
  52. package/dist/hooks/navigation/url_segments.js.map +1 -0
  53. package/dist/hooks/navigation/useBuildUrlController.js +4 -2
  54. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  55. package/dist/hooks/useBuildSidePanel.js +6 -5
  56. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  57. package/dist/hooks/useHistory.js +4 -3
  58. package/dist/hooks/useHistory.js.map +1 -1
  59. package/dist/routes/RebaseRoute.js +20 -30
  60. package/dist/routes/RebaseRoute.js.map +1 -1
  61. package/dist/util/navigation_utils.js +4 -3
  62. package/dist/util/navigation_utils.js.map +1 -1
  63. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"useHistory.js","names":[],"sources":["../../src/hooks/useHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { useApiBase, useApiConfig, useRlsSimulation } from \"@rebasepro/app\";\nimport { simulationHeaders } from \"@rebasepro/types\";\nimport type { EntityHistoryEntry } from \"@rebasepro/types\";\n\n/**\n * What the history REST endpoint returns. The fourth declaration of this shape\n * — the two drivers had one each and disagreed on `updated_at` — now an alias\n * of the one in `@rebasepro/types`.\n */\nexport type HistoryEntryData = EntityHistoryEntry;\n\nexport interface UseEntityHistoryResult {\n entries: HistoryEntryData[];\n total: number;\n isLoading: boolean;\n hasMore: boolean;\n error?: Error;\n loadMore: () => void;\n revert: (historyId: string) => Promise<Record<string, unknown>>;\n}\n\n/**\n * Hook to fetch entity history from the backend REST API.\n * Replaces the old subcollection-based approach with a proper API call.\n *\n * While access is simulated (\"Simulate access\") every request carries the\n * simulation, as the data views' `client.simulate()` does: the history is read\n * as the simulated identity, and the server refuses a revert as the simulated\n * write it would be.\n */\nexport function useHistory(params: {\n slug: string;\n entityId: string | number | undefined;\n enabled?: boolean;\n pageSize?: number;\n /**\n * Bumped by the caller when the record is saved. A save is the one event\n * that adds a revision, and nothing else here would notice it: without\n * this the open panel keeps showing the list it fetched when it opened,\n * so the revision you just created never appears.\n */\n refreshToken?: number;\n}): UseEntityHistoryResult {\n const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n const { simulation } = useRlsSimulation();\n const simulated = useMemo(() => simulationHeaders(simulation), [simulation]);\n\n const [entries, setEntries] = useState<HistoryEntryData[]>([]);\n const [total, setTotal] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const [offset, setOffset] = useState(0);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n // Track the current entity identity so we can detect stale responses.\n // `refreshToken` is part of the identity on purpose: a save makes the list\n // we are holding a stale page of a longer list, which is the same problem\n // as having moved to a different record.\n // So is the simulation: another identity reads another history.\n const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}/${JSON.stringify(simulated)}`;\n const currentEntityRef = useRef<string | undefined>(undefined);\n\n const fetchEntries = useCallback(async (\n currentOffset: number,\n signal?: AbortSignal\n ) => {\n if (!apiConfig?.apiUrl || !entityId || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;\n const response = await fetch(url, { headers,\nsignal });\n\n // Check if the request was aborted or the entity changed while in-flight\n if (signal?.aborted) return;\n if (currentEntityRef.current !== entityKey) return;\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);\n }\n\n const result = await response.json();\n\n if (currentOffset === 0) {\n setEntries(result.data);\n } else {\n setEntries(prev => [...prev, ...result.data]);\n }\n\n setTotal(result.meta.total);\n setHasMore(result.meta.hasMore);\n } catch (err) {\n // Don't set error state for intentional aborts\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [apiConfig, apiBase, slug, entityId, entityKey, enabled, pageSize, simulated]);\n\n // Single unified effect: reset state when entity changes, fetch when offset changes.\n // Uses AbortController to cancel stale requests on entity change or unmount.\n useEffect(() => {\n const isNewEntity = currentEntityRef.current !== entityKey;\n\n if (isNewEntity) {\n // Reset state for new entity\n currentEntityRef.current = entityKey;\n setEntries([]);\n setTotal(0);\n setHasMore(true);\n setOffset(0);\n }\n\n if (!enabled || !entityId) return;\n\n const abortController = new AbortController();\n // When entity changed, always fetch from offset 0\n const effectiveOffset = isNewEntity ? 0 : offset;\n fetchEntries(effectiveOffset, abortController.signal);\n\n return () => {\n abortController.abort();\n };\n }, [fetchEntries, offset, enabled, entityId, entityKey, refreshTrigger]);\n\n const loadMore = useCallback(() => {\n // `entries` already holds every page up to the current offset; adding\n // the offset to it counted those pages twice and stopped the scroll\n // short of the oldest revisions.\n if (!isLoading && hasMore && entries.length < total) {\n setOffset(prev => prev + pageSize);\n }\n }, [isLoading, hasMore, pageSize, entries.length, total]);\n\n const revert = useCallback(async (historyId: string): Promise<Record<string, unknown>> => {\n if (!apiConfig?.apiUrl || !entityId) {\n throw new Error(\"Cannot revert: missing API configuration or entity ID\");\n }\n\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;\n const response = await fetch(url, { method: \"POST\",\nheaders });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);\n }\n\n const result = await response.json();\n\n // Refresh the history list after revert by resetting the entity ref\n // and triggering the effect.\n currentEntityRef.current = undefined;\n setRefreshTrigger(prev => prev + 1);\n\n // Return the reverted entity data so callers can update the form\n return result.data as Record<string, unknown>;\n }, [apiConfig, apiBase, slug, entityId, simulated]);\n\n return useMemo(() => ({\n entries,\n total,\n isLoading,\n hasMore,\n error,\n loadMore,\n revert\n }), [entries, total, isLoading, hasMore, error, loadMore, revert]);\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,WAAW,QAYA;CACvB,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM,WAAW,IAAI,iBAAiB;CACxE,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,EAAE,eAAe,iBAAiB;CACxC,MAAM,YAAY,cAAc,kBAAkB,UAAU,GAAG,CAAC,UAAU,CAAC;CAE3E,MAAM,CA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EAAQ,CAAC;EAED,IAAI,CAAC,SAAS,IAAI;GACd,MAAM,YAAY,MAAM,SAAS,KAAK,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,SAAS,WAAW,EAAE,EAAE;GACjG,MAAM,IAAI,MAAM,UAAU,OAAO,WAAW,qBAAqB,SAAS,OAAO,EAAE;EACvF;EAEA,MAAM,SAAS,MAAM,SAAS,KAAK;EAInC,iBAAiB,UAAU,KAAA;EAC3B,mBAAkB,SAAQ,OAAO,CAAC;EAGlC,OAAO,OAAO;CAClB,GAAG;EAAC;EAAW;EAAS;EAAM;EAAU;CAAS,CAAC;CAElD,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAS;EAAO;EAAW;EAAS;EAAO;EAAU;CAAM,CAAC;AACrE"}
1
+ {"version":3,"file":"useHistory.js","names":[],"sources":["../../src/hooks/useHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { useApiBase, useApiConfig, useRlsSimulation } from \"@rebasepro/app\";\nimport { simulationHeaders } from \"@rebasepro/types\";\nimport type { EntityHistoryEntry } from \"@rebasepro/types\";\n\n/**\n * What the history REST endpoint returns. The fourth declaration of this shape\n * — the two drivers had one each and disagreed on `updated_at` — now an alias\n * of the one in `@rebasepro/types`.\n */\nexport type HistoryEntryData = EntityHistoryEntry;\n\nexport interface UseEntityHistoryResult {\n entries: HistoryEntryData[];\n total: number;\n isLoading: boolean;\n hasMore: boolean;\n error?: Error;\n loadMore: () => void;\n revert: (historyId: string) => Promise<Record<string, unknown>>;\n}\n\n/**\n * Hook to fetch entity history from the backend REST API.\n * Replaces the old subcollection-based approach with a proper API call.\n *\n * While access is simulated (\"Simulate access\") every request carries the\n * simulation, as the data views' `client.simulate()` does: the history is read\n * as the simulated identity, and the server refuses a revert as the simulated\n * write it would be.\n */\nexport function useHistory(params: {\n slug: string;\n entityId: string | number | undefined;\n enabled?: boolean;\n pageSize?: number;\n /**\n * Bumped by the caller when the record is saved. A save is the one event\n * that adds a revision, and nothing else here would notice it: without\n * this the open panel keeps showing the list it fetched when it opened,\n * so the revision you just created never appears.\n */\n refreshToken?: number;\n}): UseEntityHistoryResult {\n const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n const { simulation } = useRlsSimulation();\n const simulated = useMemo(() => simulationHeaders(simulation), [simulation]);\n\n const [entries, setEntries] = useState<HistoryEntryData[]>([]);\n const [total, setTotal] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const [offset, setOffset] = useState(0);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n // Track the current entity identity so we can detect stale responses.\n // `refreshToken` is part of the identity on purpose: a save makes the list\n // we are holding a stale page of a longer list, which is the same problem\n // as having moved to a different record.\n // So is the simulation: another identity reads another history.\n const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}/${JSON.stringify(simulated)}`;\n const currentEntityRef = useRef<string | undefined>(undefined);\n\n const fetchEntries = useCallback(async (\n currentOffset: number,\n signal?: AbortSignal\n ) => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId) || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;\n const response = await fetch(url, { headers,\nsignal });\n\n // Check if the request was aborted or the entity changed while in-flight\n if (signal?.aborted) return;\n if (currentEntityRef.current !== entityKey) return;\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);\n }\n\n const result = await response.json();\n\n if (currentOffset === 0) {\n setEntries(result.data);\n } else {\n setEntries(prev => [...prev, ...result.data]);\n }\n\n setTotal(result.meta.total);\n setHasMore(result.meta.hasMore);\n } catch (err) {\n // Don't set error state for intentional aborts\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [apiConfig, apiBase, slug, entityId, entityKey, enabled, pageSize, simulated]);\n\n // Single unified effect: reset state when entity changes, fetch when offset changes.\n // Uses AbortController to cancel stale requests on entity change or unmount.\n useEffect(() => {\n const isNewEntity = currentEntityRef.current !== entityKey;\n\n if (isNewEntity) {\n // Reset state for new entity\n currentEntityRef.current = entityKey;\n setEntries([]);\n setTotal(0);\n setHasMore(true);\n setOffset(0);\n }\n\n if (!enabled || !hasEntityId(entityId)) return;\n\n const abortController = new AbortController();\n // When entity changed, always fetch from offset 0\n const effectiveOffset = isNewEntity ? 0 : offset;\n fetchEntries(effectiveOffset, abortController.signal);\n\n return () => {\n abortController.abort();\n };\n }, [fetchEntries, offset, enabled, entityId, entityKey, refreshTrigger]);\n\n const loadMore = useCallback(() => {\n // `entries` already holds every page up to the current offset; adding\n // the offset to it counted those pages twice and stopped the scroll\n // short of the oldest revisions.\n if (!isLoading && hasMore && entries.length < total) {\n setOffset(prev => prev + pageSize);\n }\n }, [isLoading, hasMore, pageSize, entries.length, total]);\n\n const revert = useCallback(async (historyId: string): Promise<Record<string, unknown>> => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId)) {\n throw new Error(\"Cannot revert: missing API configuration or entity ID\");\n }\n\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;\n const response = await fetch(url, { method: \"POST\",\nheaders });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);\n }\n\n const result = await response.json();\n\n // Refresh the history list after revert by resetting the entity ref\n // and triggering the effect.\n currentEntityRef.current = undefined;\n setRefreshTrigger(prev => prev + 1);\n\n // Return the reverted entity data so callers can update the form\n return result.data as Record<string, unknown>;\n }, [apiConfig, apiBase, slug, entityId, simulated]);\n\n return useMemo(() => ({\n entries,\n total,\n isLoading,\n hasMore,\n error,\n loadMore,\n revert\n }), [entries, total, isLoading, hasMore, error, loadMore, revert]);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,WAAW,QAYA;CACvB,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM,WAAW,IAAI,iBAAiB;CACxE,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,EAAE,eAAe,iBAAiB;CACxC,MAAM,YAAY,cAAc,kBAAkB,UAAU,GAAG,CAAC,UAAU,CAAC;CAE3E,MAAM,CAAC,SAAS,cAAc,SAA6B,CAAC,CAAC;CAC7D,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC;CACpC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,CAAC,OAAO,YAAY,SAA4B;CACtD,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC;CAOtD,MAAM,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,gBAAgB,EAAE,GAAG,KAAK,UAAU,SAAS;CACtF,MAAM,mBAAmB,OAA2B,KAAA,CAAS;CAE7D,MAAM,eAAe,YAAY,OAC7B,eACA,WACC;EACD,IAAI,CAAC,WAAW,UAAU,CAAC,YAAY,QAAQ,KAAK,CAAC,SAAS;EAE9D,aAAa,IAAI;EACjB,SAAS,KAAA,CAAS;EAElB,IAAI;GACA,MAAM,QAAQ,MAAM,U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
3
3
  import { useUrlController } from "../hooks/navigation/contexts/UrlContext.js";
4
4
  import { LazyCollectionViewBinding, LazyDetailViewBinding, LazyEditViewBinding } from "../components/lazy_record_views.js";
5
5
  import { isPathWithinRecord } from "../util/navigation_utils.js";
6
+ import { decodeUrlPath, encodeUrlPathSegment, getPathAfterRecord } from "../hooks/navigation/url_segments.js";
6
7
  import { useBreadcrumbsController } from "../hooks/useBreadcrumbsController.js";
7
8
  import { resolveCollectionOpenMode } from "../util/collection_open_mode.js";
8
9
  import { NavigationLoadingErrorView } from "../components/NavigationLoadingErrorView.js";
@@ -124,13 +125,8 @@ function RebaseRouteContent() {
124
125
  else if (thirdEntry.type === "custom_view") selectedTab = thirdEntry.view.key;
125
126
  }
126
127
  if (!selectedTab && navigationEntries.length === 2 && lastEntityEntry) {
127
- const entityIdStr = String(lastEntityEntry.entityId);
128
- const entityIdIdx = pathname.lastIndexOf(`/${entityIdStr}`);
129
- if (entityIdIdx >= 0) {
130
- const afterEntity = pathname.substring(entityIdIdx + 1 + entityIdStr.length);
131
- const trailingSegment = afterEntity.startsWith("/") ? afterEntity.substring(1) : afterEntity;
132
- if (trailingSegment.length > 0) selectedTab = trailingSegment;
133
- }
128
+ const trailingSegment = getPathAfterRecord(pathname, urlController.buildUrlCollectionPath(lastEntityEntry.path));
129
+ if (trailingSegment) selectedTab = trailingSegment;
134
130
  }
135
131
  return /* @__PURE__ */ jsx(ResolvedCollectionView, {
136
132
  ...collection,
@@ -173,15 +169,12 @@ function EntityFullScreenRoute({ pathname, navigationEntries, isNew, isCopy }) {
173
169
  const lastEntityEntry = [...navigationEntries].reverse().find((entry) => entry.type === "entity");
174
170
  const lastCustomView = [...lastEntityEntry ? navigationEntries.slice(navigationEntries.indexOf(lastEntityEntry) + 1) : []].reverse().find((entry) => entry.type === "custom_view" || entry.type === "collection");
175
171
  const entityId = lastEntityEntry && "entityId" in lastEntityEntry ? lastEntityEntry.entityId : void 0;
172
+ const recordUrl = lastEntityEntry && entityId !== void 0 && !isNew ? urlController.buildUrlCollectionPath(lastEntityEntry.path) : void 0;
173
+ const basePath = lastEntityEntry && recordUrl !== void 0 ? urlController.buildUrlCollectionPath(lastEntityEntry.slug) : pathname;
176
174
  let urlTab = getSelectedTabFromUrl(isNew, lastCustomView);
177
- if (!urlTab && entityId && !isNew) {
178
- const entityIdStr = String(entityId);
179
- const entityIdIdx = pathname.lastIndexOf(`/${entityIdStr}`);
180
- if (entityIdIdx >= 0) {
181
- const afterEntity = pathname.substring(entityIdIdx + 1 + entityIdStr.length);
182
- const trailingSegment = afterEntity.startsWith("/") ? afterEntity.substring(1) : afterEntity;
183
- if (trailingSegment.length > 0 && trailingSegment !== "edit") urlTab = trailingSegment;
184
- }
175
+ if (!urlTab && recordUrl !== void 0) {
176
+ const trailingSegment = getPathAfterRecord(pathname, recordUrl);
177
+ if (trailingSegment && trailingSegment !== "edit") urlTab = trailingSegment;
185
178
  }
186
179
  const [selectedTab, setSelectedTab] = useState(urlTab);
187
180
  const parentCollectionSlugs = collectionRegistry.getParentCollectionSlugs(navigationPath);
@@ -189,16 +182,18 @@ function EntityFullScreenRoute({ pathname, navigationEntries, isNew, isCopy }) {
189
182
  useEffect(() => {
190
183
  if (urlTab !== selectedTab) setSelectedTab(urlTab);
191
184
  }, [urlTab]);
192
- const basePath = !entityId || isNew ? pathname : pathname.substring(0, pathname.lastIndexOf(`/${entityId}`));
193
- const entityPath = basePath + `/${entityId}`;
185
+ const recordTabUrl = (id, tab) => `${basePath}/${encodeUrlPathSegment(String(id))}${tab ? "/" + encodeUrlPathSegment(tab) : ""}`;
186
+ const entityPath = decodeUrlPath(recordUrl ?? `${basePath}/${entityId}`);
187
+ const decodedBasePath = decodeUrlPath(basePath);
194
188
  const blocker = useNavigationBlocker(useCallback(({ currentLocation, nextLocation }) => {
195
- if (isPathWithinRecord(nextLocation.pathname, entityPath)) return false;
189
+ const nextPathname = decodeUrlPath(nextLocation.pathname);
190
+ if (isPathWithinRecord(nextPathname, entityPath)) return false;
196
191
  const nextHash = nextLocation.hash;
197
192
  if (nextHash === "#side" || nextHash === "#new_side") return false;
198
193
  const currentHash = currentLocation.hash;
199
- if ((currentHash === "#side" || currentHash === "#new_side") && (nextLocation.pathname === basePath || isPathWithinRecord(nextLocation.pathname, entityPath))) return false;
194
+ if ((currentHash === "#side" || currentHash === "#new_side") && (nextPathname === decodedBasePath || isPathWithinRecord(nextPathname, entityPath))) return false;
200
195
  return blocked.current;
201
- }, [entityPath, basePath]));
196
+ }, [entityPath, decodedBasePath]));
202
197
  const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === "collection");
203
198
  if (isNew && !lastCollectionEntry) {
204
199
  if (!collectionRegistry.initialised) return /* @__PURE__ */ jsx(CircularProgressCenter, {});
@@ -237,9 +232,7 @@ function EntityFullScreenRoute({ pathname, navigationEntries, isNew, isCopy }) {
237
232
  },
238
233
  onTabChange: (params) => {
239
234
  setSelectedTab(params.selectedTab);
240
- const newSelectedTab = params.selectedTab;
241
- if (newSelectedTab) navigate(`${basePath}/${entityId}/${newSelectedTab}${hash}`, { replace: true });
242
- else navigate(`${basePath}/${entityId}${hash}`, { replace: true });
235
+ navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });
243
236
  },
244
237
  parentCollectionSlugs,
245
238
  parentEntityIds
@@ -260,17 +253,14 @@ function EntityFullScreenRoute({ pathname, navigationEntries, isNew, isCopy }) {
260
253
  },
261
254
  onSaved: (params) => {
262
255
  const newSelectedTab = params.selectedTab;
263
- const newEntityId = params.entityId;
256
+ const newEntityId = params.entityId ?? params.entity.id;
264
257
  const savedHash = isNew ? "" : hash;
265
- if (newSelectedTab) navigate(`${basePath}/${newEntityId}/${newSelectedTab}${savedHash}`, { replace: true });
266
- else navigate(`${basePath}/${newEntityId}${savedHash}`, { replace: true });
258
+ navigate(`${recordTabUrl(newEntityId, newSelectedTab)}${savedHash}`, { replace: true });
267
259
  },
268
260
  onTabChange: (params) => {
269
261
  setSelectedTab(params.selectedTab);
270
- if (isNew) return;
271
- const newSelectedTab = params.selectedTab;
272
- if (newSelectedTab) navigate(`${basePath}/${entityId}/${newSelectedTab}${hash}`, { replace: true });
273
- else navigate(`${basePath}/${entityId}${hash}`, { replace: true });
262
+ if (isNew || entityId === void 0) return;
263
+ navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });
274
264
  },
275
265
  parentCollectionSlugs,
276
266
  parentEntityIds
@@ -1 +1 @@
1
- {"version":3,"file":"RebaseRoute.js","names":[],"sources":["../../src/routes/RebaseRoute.tsx"],"sourcesContent":["\nimport type { ViewMode, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n// Lazy: the table, the record views and the form behind them are not needed\n// until a collection opens, and a static import here preloaded all of them on\n// the login screen. See components/lazy_record_views.ts.\nimport {\n LazyCollectionViewBinding as CollectionViewBinding,\n LazyDetailViewBinding as DetailViewBinding,\n LazyEditViewBinding as EditViewBinding\n} from \"../components/lazy_record_views\";\nimport { ErrorView, NotFoundPage, useCustomizationController, useTranslation, useUserConfigurationPersistence, useComponentOverride, useNavigationBlocker } from \"@rebasepro/app\";\nimport { resolveCollectionOpenMode } from \"../util/collection_open_mode\";\nimport { isPathWithinRecord } from \"../util/navigation_utils\";\nimport { UnsavedChangesDialog } from \"@rebasepro/app\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { NavigationViewCollectionInternal, NavigationViewEntityCustomInternal, NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { NavigationLoadingErrorView } from \"../components/NavigationLoadingErrorView\";\n\nexport function RebaseRoute() {\n return <Suspense fallback={<CircularProgressCenter/>}>\n <RebaseRouteContent/>\n </Suspense>;\n}\n\nfunction RebaseRouteContent() {\n\n const location = useLocation();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const breadcrumbs = useBreadcrumbsController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const navigationState = useNavigationStateController();\n\n const hash = location.hash;\n // `#new_side` is a new record in the side panel, drawn by the side panel\n // (`useBuildSidePanel`); under it this route shows the collection, as it\n // does for `#side`. It contains `#new`, which made a pasted\n // `/c/products#new_side` draw a second, full-screen new form under the panel.\n const isNewInSidePanel = hash.includes(\"#new_side\");\n const isSidePanel = hash.includes(\"#side\") || isNewInSidePanel;\n const isNew = hash.includes(\"#new\") && !isNewInSidePanel;\n const isCopy = hash.includes(\"#copy\");\n const isFullScreen = hash.includes(\"#full\");\n\n const pathname = location.pathname;\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n const navigationEntries = getNavigationEntriesFromPath({\n path: navigationPath,\n collections: collectionRegistry.collections ?? []\n });\n\n useEffect(() => {\n breadcrumbs.set({\n breadcrumbs: navigationEntries.map((entry) => {\n\n if (entry.type === \"entity\") {\n return ({\n title: String(entry.entityId),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"custom_view\") {\n return ({\n title: String(entry.view.name ?? entry.view.key),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"collection\") {\n return ({\n title: entry.collection.name,\n url: urlController.buildUrlCollectionPath(entry.path),\n id: entry.path\n });\n } else {\n throw new Error(\"Unexpected navigation entry type\");\n }\n })\n });\n }, [navigationEntries.map(entry => entry.path).join(\",\")]);\n\n // The collections failed to load, so this URL cannot resolve to anything:\n // say why, rather than spin until a registry that will never fill does, or\n // report the collection as unregistered.\n if (navigationState.navigationLoadingError && !navigationEntries.some((entry) => entry.type === \"collection\")) {\n return <CenteredView>\n <NavigationLoadingErrorView error={navigationState.navigationLoadingError}\n onRetry={navigationState.refreshNavigation}/>\n </CenteredView>;\n }\n\n if (isNew) {\n // New entities always use full-screen mode, even for split-layout collections\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={true}\n isCopy={false}\n />;\n }\n\n if (navigationEntries.length === 1 && navigationEntries[0].type === \"collection\") {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(navigationEntries[0].id);\n if (!collection)\n collection = collectionRegistry.getCollection(navigationEntries[0].slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={navigationEntries[0].slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>\n }\n\n if (isSidePanel) {\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n if (lastCollectionEntry) {\n let collection: AdminCollection<any> | undefined;\n const firstEntry = navigationEntries[0] as NavigationViewCollectionInternal<any>;\n collection = collectionRegistry.getCollection(firstEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstEntry.slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={firstEntry.slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n // Check if this is a simple entity route (collection + entity) for a split-layout collection.\n // If so, render the collection view with the entity shown in the split detail panel\n // instead of the full-screen editor. This keeps the master-detail UX with clean URLs.\n //\n // Also handles subcollection tabs: /c/customers/39/orders produces 3 entries\n // (collection→entity→subcollection). We extract the subcollection slug as selectedTab.\n const lastEntityEntry = navigationEntries.find((entry) => entry.type === \"entity\");\n const firstCollectionEntry = navigationEntries[0];\n if (\n !isFullScreen &&\n !isCopy &&\n firstCollectionEntry?.type === \"collection\" &&\n lastEntityEntry?.type === \"entity\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3)\n ) {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(firstCollectionEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstCollectionEntry.slug);\n\n const effectiveOpenMode = collection\n ? resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n })\n : undefined;\n if (collection && effectiveOpenMode === \"split\") {\n // Extract subcollection tab from the 3rd entry if present\n let selectedTab: string | undefined;\n if (navigationEntries.length === 3) {\n const thirdEntry = navigationEntries[2];\n if (thirdEntry.type === \"collection\") {\n selectedTab = thirdEntry.collection.slug;\n } else if (thirdEntry.type === \"custom_view\") {\n selectedTab = thirdEntry.view.key;\n }\n }\n // Fallback: check for unregistered tabs (e.g. __json, __rebase_history)\n // that aren't parsed as navigation entries\n if (!selectedTab && (navigationEntries.length === 2) && lastEntityEntry) {\n const entityIdStr = String(lastEntityEntry.entityId);\n const entityIdIdx = pathname.lastIndexOf(`/${entityIdStr}`);\n if (entityIdIdx >= 0) {\n const afterEntity = pathname.substring(entityIdIdx + 1 + entityIdStr.length);\n const trailingSegment = afterEntity.startsWith(\"/\") ? afterEntity.substring(1) : afterEntity;\n if (trailingSegment.length > 0) {\n selectedTab = trailingSegment;\n }\n }\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n selectedEntityId={lastEntityEntry.entityId}\n selectedTab={selectedTab}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={isNew}\n isCopy={isCopy}\n />;\n\n}\n\nfunction getSelectedTabFromUrl(isNew: boolean, lastCustomView: NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined) {\n if (isNew) {\n return undefined;\n } else if (lastCustomView) {\n if (lastCustomView.type === \"custom_view\") {\n return lastCustomView.view.key;\n } else if (lastCustomView.type === \"collection\") {\n return lastCustomView.id ?? lastCustomView.slug;\n }\n }\n return undefined;\n}\n\nfunction EntityFullScreenRoute({\n pathname,\n navigationEntries,\n isNew,\n isCopy\n}: {\n pathname: string;\n navigationEntries: NavigationViewInternal[],\n isNew: boolean,\n isCopy: boolean\n}) {\n\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const location = useLocation();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // defaultValues may be carried via location.state when openNewDocument() is called\n // for full-screen mode. We read it once on mount — after that, the form owns its state.\n const defaultValues = (location.state as { defaultValues?: Record<string, unknown> } | null)?.defaultValues;\n\n // Preserve the current hash (e.g. #full) across tab/save navigations\n const hash = location.hash;\n\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n // is navigating away blocked\n const blocked = useRef(false);\n\n const lastEntityEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"entity\");\n const navigationEntriesAfterEntity = lastEntityEntry ? navigationEntries.slice(navigationEntries.indexOf(lastEntityEntry) + 1) : [];\n\n const lastCustomView = [...navigationEntriesAfterEntity].reverse().find(\n (entry) => entry.type === \"custom_view\" || entry.type === \"collection\"\n ) as NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined;\n\n const entityId = lastEntityEntry && \"entityId\" in lastEntityEntry ? lastEntityEntry.entityId : undefined;\n\n // Derive tab from navigation entries (works for registered custom views)\n let urlTab = getSelectedTabFromUrl(isNew, lastCustomView);\n\n // Fallback: internal tabs like __json or __rebase_history aren't registered as\n // entity views, so the navigation parser ignores them. Check the raw pathname\n // for a trailing segment after the entity ID to catch those cases.\n if (!urlTab && entityId && !isNew) {\n const entityIdStr = String(entityId);\n const entityIdIdx = pathname.lastIndexOf(`/${entityIdStr}`);\n if (entityIdIdx >= 0) {\n const afterEntity = pathname.substring(entityIdIdx + 1 + entityIdStr.length);\n const trailingSegment = afterEntity.startsWith(\"/\") ? afterEntity.substring(1) : afterEntity;\n if (trailingSegment.length > 0 && trailingSegment !== \"edit\") {\n urlTab = trailingSegment;\n }\n }\n }\n\n const [selectedTab, setSelectedTab] = useState<string | undefined>(urlTab);\n\n const parentCollectionSlugs = collectionRegistry.getParentCollectionSlugs(navigationPath);\n const parentEntityIds = collectionRegistry.getParentEntityIds(navigationPath);\n useEffect(() => {\n if (urlTab !== selectedTab) {\n setSelectedTab(urlTab);\n }\n }, [urlTab]);\n\n const basePath = !entityId || isNew\n ? pathname\n : pathname.substring(0, pathname.lastIndexOf(`/${entityId}`));\n\n const entityPath = basePath + `/${entityId}`;\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n // Inside this record — a tab, `/edit`. By path segment: a bare\n // prefix let Back to `/c/products/12` out of `/c/products/1` without\n // asking.\n if (isPathWithinRecord(nextLocation.pathname, entityPath))\n return false;\n\n // Side panel overlay navigations preserve the underlying form via\n // base_location in router state — no data is lost in either direction.\n\n // Opening a side panel (e.g. clicking a relation arrow)\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\")\n return false;\n\n // Closing a side panel (navigate(-1) back to the form's own path)\n const currentHash = currentLocation.hash;\n if ((currentHash === \"#side\" || currentHash === \"#new_side\") &&\n (nextLocation.pathname === basePath ||\n isPathWithinRecord(nextLocation.pathname, entityPath)))\n return false;\n\n return blocked.current;\n }, [entityPath, basePath]));\n\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n\n if (isNew && !lastCollectionEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n throw new Error(\"INTERNAL: No collection found in the navigation\");\n }\n\n if (!isNew && !lastEntityEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <NotFoundPage/>;\n }\n\n const rawCollection = isNew\n ? (lastCollectionEntry && \"collection\" in lastCollectionEntry ? lastCollectionEntry.collection : undefined)!\n : (lastEntityEntry && \"parentCollection\" in lastEntityEntry ? lastEntityEntry.parentCollection : undefined)!;\n const collection = collectionRegistry.getCollection(rawCollection.slug) || rawCollection;\n const fullIdPath = isNew ? lastCollectionEntry!.slug : lastEntityEntry!.slug;\n const collectionPath = urlController.resolveDatabasePathsFrom(fullIdPath);\n const isEditRoute = pathname.endsWith(\"/edit\") || pathname.split(\"/\").pop() === \"edit\";\n // Determine if this is a detail-view-first collection showing the view page\n const isDetailMode = collection.defaultEntityAction === \"view\" && !isNew && !isCopy && entityId && !isEditRoute;\n\n // A record is full screen either because its collection has no list to show\n // beside it, or because the user folded that list away. Only the second is\n // reversible, and it is reversible by dropping `#full` alone: this is the\n // same URL the split route reads, so the same conditions decide it.\n const splitListAvailable = !isNew && !isCopy && entityId !== undefined &&\n navigationEntries[0]?.type === \"collection\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3) &&\n resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n }) === \"split\";\n\n const showList = splitListAvailable\n ? () => navigate({\n pathname,\n search: location.search,\n hash: \"\"\n })\n : undefined;\n\n if (isDetailMode) {\n return <>\n <DetailViewBinding\n key={collection.slug + \"_view_\" + entityId}\n entityId={entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n onEditClick={() => {\n const editUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`) + \"/edit\";\n navigate(editUrl + hash);\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n const newSelectedTab = params.selectedTab;\n if (newSelectedTab) {\n navigate(`${basePath}/${entityId}/${newSelectedTab}${hash}`, { replace: true });\n } else {\n navigate(`${basePath}/${entityId}${hash}`, { replace: true });\n }\n }}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n </>;\n }\n\n return <>\n <EditViewBinding\n key={collection.slug + \"_\" + (isNew ? \"new\" : (isCopy ? entityId + \"_copy\" : entityId))}\n entityId={isNew ? undefined : entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n copy={isCopy}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n defaultValues={isNew ? defaultValues : undefined}\n onValuesModified={(modified) => blocked.current = modified}\n navigateBack={() => {\n const detailUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`);\n navigate(detailUrl + hash);\n }}\n onSaved={(params) => {\n const newSelectedTab = params.selectedTab;\n const newEntityId = params.entityId;\n const savedHash = isNew ? \"\" : hash;\n if (newSelectedTab) {\n navigate(`${basePath}/${newEntityId}/${newSelectedTab}${savedHash}`, { replace: true });\n } else {\n navigate(`${basePath}/${newEntityId}${savedHash}`, { replace: true });\n }\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n if (isNew) {\n return;\n }\n const newSelectedTab = params.selectedTab;\n if (newSelectedTab) {\n navigate(`${basePath}/${entityId}/${newSelectedTab}${hash}`, { replace: true });\n } else {\n navigate(`${basePath}/${entityId}${hash}`, { replace: true });\n }\n }}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => blocker?.proceed?.()}\n handleCancel={() => blocker?.reset?.()}\n body={t(\"unsaved_changes_in_entity\")}/>\n </>;\n}\n\n/**\n * Shown when a URL names a collection the registry cannot resolve.\n *\n * This used to be `return null`, which renders an empty pane inside the app\n * chrome: the sidebar, the nav highlight and the breadcrumb all still work,\n * because those read the collections array directly, while the view itself is\n * blank. Nothing is thrown, and the only trace is a `console.debug` — so the\n * panel looks like it lost its data rather than like it failed to find the\n * collection, and there is no string to search for.\n *\n * A slug containing slashes went unresolvable this way and cost an afternoon to\n * find. The lookup is fixed; this is the part that made it expensive.\n */\nfunction UnresolvedCollectionView({ path }: { path: string }) {\n const { t } = useTranslation();\n // Warn, not debug: this is a route that renders nothing useful, and it\n // should be visible at the console's default level.\n useEffect(() => {\n console.warn(\n `[rebase] No collection is registered for \"${path}\", so this route has nothing to render. ` +\n \"Check that the collection is in the collections array and that its slug matches the URL.\"\n );\n }, [path]);\n\n return <CenteredView>\n <ErrorView\n title={t(\"collection_not_found\")}\n error={t(\"collection_not_found_body\", { path })}\n tooltip={t(\"collection_not_found_hint\")}/>\n </CenteredView>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,SAAgB,cAAc;CAC1B,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,oBAAD,CAAoB,CAAA;CACd,CAAA;AACd;AAEA,SAAS,qBAAqB;CAE1B,MAAM,WAAW,YAAY;CAC7B,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,cAAc,yBAAyB;CAC7C,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,yBAAyB,qBAAqB,mBAAmB,yBAAqB;CAC5F,MAAM,kBAAkB,6BAA6B;CAErD,MAAM,OAAO,SAAS;CAKtB,MAAM,mBAAmB,KAAK,SAAS,WAAW;CAClD,MAAM,cAAc,KAAK,SAAS,OAAO,KAAK;CAC9C,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,CAAC;CACxC,MAAM,SAAS,KAAK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seRoute.js","names":[],"sources":["../../src/routes/RebaseRoute.tsx"],"sourcesContent":["\nimport type { ViewMode, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n// Lazy: the table, the record views and the form behind them are not needed\n// until a collection opens, and a static import here preloaded all of them on\n// the login screen. See components/lazy_record_views.ts.\nimport {\n LazyCollectionViewBinding as CollectionViewBinding,\n LazyDetailViewBinding as DetailViewBinding,\n LazyEditViewBinding as EditViewBinding\n} from \"../components/lazy_record_views\";\nimport { ErrorView, NotFoundPage, useCustomizationController, useTranslation, useUserConfigurationPersistence, useComponentOverride, useNavigationBlocker } from \"@rebasepro/app\";\nimport { resolveCollectionOpenMode } from \"../util/collection_open_mode\";\nimport { isPathWithinRecord } from \"../util/navigation_utils\";\nimport { UnsavedChangesDialog } from \"@rebasepro/app\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { NavigationViewCollectionInternal, NavigationViewEntityCustomInternal, NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { NavigationLoadingErrorView } from \"../components/NavigationLoadingErrorView\";\nimport { decodeUrlPath, encodeUrlPathSegment, getPathAfterRecord } from \"../hooks/navigation/url_segments\";\n\nexport function RebaseRoute() {\n return <Suspense fallback={<CircularProgressCenter/>}>\n <RebaseRouteContent/>\n </Suspense>;\n}\n\nfunction RebaseRouteContent() {\n\n const location = useLocation();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const breadcrumbs = useBreadcrumbsController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const navigationState = useNavigationStateController();\n\n const hash = location.hash;\n // `#new_side` is a new record in the side panel, drawn by the side panel\n // (`useBuildSidePanel`); under it this route shows the collection, as it\n // does for `#side`. It contains `#new`, which made a pasted\n // `/c/products#new_side` draw a second, full-screen new form under the panel.\n const isNewInSidePanel = hash.includes(\"#new_side\");\n const isSidePanel = hash.includes(\"#side\") || isNewInSidePanel;\n const isNew = hash.includes(\"#new\") && !isNewInSidePanel;\n const isCopy = hash.includes(\"#copy\");\n const isFullScreen = hash.includes(\"#full\");\n\n const pathname = location.pathname;\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n const navigationEntries = getNavigationEntriesFromPath({\n path: navigationPath,\n collections: collectionRegistry.collections ?? []\n });\n\n useEffect(() => {\n breadcrumbs.set({\n breadcrumbs: navigationEntries.map((entry) => {\n\n if (entry.type === \"entity\") {\n return ({\n title: String(entry.entityId),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"custom_view\") {\n return ({\n title: String(entry.view.name ?? entry.view.key),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"collection\") {\n return ({\n title: entry.collection.name,\n url: urlController.buildUrlCollectionPath(entry.path),\n id: entry.path\n });\n } else {\n throw new Error(\"Unexpected navigation entry type\");\n }\n })\n });\n }, [navigationEntries.map(entry => entry.path).join(\",\")]);\n\n // The collections failed to load, so this URL cannot resolve to anything:\n // say why, rather than spin until a registry that will never fill does, or\n // report the collection as unregistered.\n if (navigationState.navigationLoadingError && !navigationEntries.some((entry) => entry.type === \"collection\")) {\n return <CenteredView>\n <NavigationLoadingErrorView error={navigationState.navigationLoadingError}\n onRetry={navigationState.refreshNavigation}/>\n </CenteredView>;\n }\n\n if (isNew) {\n // New entities always use full-screen mode, even for split-layout collections\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={true}\n isCopy={false}\n />;\n }\n\n if (navigationEntries.length === 1 && navigationEntries[0].type === \"collection\") {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(navigationEntries[0].id);\n if (!collection)\n collection = collectionRegistry.getCollection(navigationEntries[0].slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={navigationEntries[0].slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>\n }\n\n if (isSidePanel) {\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n if (lastCollectionEntry) {\n let collection: AdminCollection<any> | undefined;\n const firstEntry = navigationEntries[0] as NavigationViewCollectionInternal<any>;\n collection = collectionRegistry.getCollection(firstEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstEntry.slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={firstEntry.slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n // Check if this is a simple entity route (collection + entity) for a split-layout collection.\n // If so, render the collection view with the entity shown in the split detail panel\n // instead of the full-screen editor. This keeps the master-detail UX with clean URLs.\n //\n // Also handles subcollection tabs: /c/customers/39/orders produces 3 entries\n // (collection→entity→subcollection). We extract the subcollection slug as selectedTab.\n const lastEntityEntry = navigationEntries.find((entry) => entry.type === \"entity\");\n const firstCollectionEntry = navigationEntries[0];\n if (\n !isFullScreen &&\n !isCopy &&\n firstCollectionEntry?.type === \"collection\" &&\n lastEntityEntry?.type === \"entity\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3)\n ) {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(firstCollectionEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstCollectionEntry.slug);\n\n const effectiveOpenMode = collection\n ? resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n })\n : undefined;\n if (collection && effectiveOpenMode === \"split\") {\n // Extract subcollection tab from the 3rd entry if present\n let selectedTab: string | undefined;\n if (navigationEntries.length === 3) {\n const thirdEntry = navigationEntries[2];\n if (thirdEntry.type === \"collection\") {\n selectedTab = thirdEntry.collection.slug;\n } else if (thirdEntry.type === \"custom_view\") {\n selectedTab = thirdEntry.view.key;\n }\n }\n // Fallback: check for unregistered tabs (e.g. __json, __rebase_history)\n // that aren't parsed as navigation entries\n if (!selectedTab && (navigationEntries.length === 2) && lastEntityEntry) {\n const trailingSegment = getPathAfterRecord(pathname, urlController.buildUrlCollectionPath(lastEntityEntry.path));\n if (trailingSegment) {\n selectedTab = trailingSegment;\n }\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n selectedEntityId={lastEntityEntry.entityId}\n selectedTab={selectedTab}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={isNew}\n isCopy={isCopy}\n />;\n\n}\n\nfunction getSelectedTabFromUrl(isNew: boolean, lastCustomView: NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined) {\n if (isNew) {\n return undefined;\n } else if (lastCustomView) {\n if (lastCustomView.type === \"custom_view\") {\n return lastCustomView.view.key;\n } else if (lastCustomView.type === \"collection\") {\n return lastCustomView.id ?? lastCustomView.slug;\n }\n }\n return undefined;\n}\n\nfunction EntityFullScreenRoute({\n pathname,\n navigationEntries,\n isNew,\n isCopy\n}: {\n pathname: string;\n navigationEntries: NavigationViewInternal[],\n isNew: boolean,\n isCopy: boolean\n}) {\n\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const location = useLocation();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // defaultValues may be carried via location.state when openNewDocument() is called\n // for full-screen mode. We read it once on mount — after that, the form owns its state.\n const defaultValues = (location.state as { defaultValues?: Record<string, unknown> } | null)?.defaultValues;\n\n // Preserve the current hash (e.g. #full) across tab/save navigations\n const hash = location.hash;\n\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n // is navigating away blocked\n const blocked = useRef(false);\n\n const lastEntityEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"entity\");\n const navigationEntriesAfterEntity = lastEntityEntry ? navigationEntries.slice(navigationEntries.indexOf(lastEntityEntry) + 1) : [];\n\n const lastCustomView = [...navigationEntriesAfterEntity].reverse().find(\n (entry) => entry.type === \"custom_view\" || entry.type === \"collection\"\n ) as NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined;\n\n const entityId = lastEntityEntry && \"entityId\" in lastEntityEntry ? lastEntityEntry.entityId : undefined;\n\n // The record's own URL, and the URL of the collection that holds it. Built\n // from the data path, so the id in them is percent-encoded once, however\n // the pathname spells it.\n const recordUrl = lastEntityEntry && entityId !== undefined && !isNew\n ? urlController.buildUrlCollectionPath(lastEntityEntry.path)\n : undefined;\n const basePath = lastEntityEntry && recordUrl !== undefined\n ? urlController.buildUrlCollectionPath(lastEntityEntry.slug)\n : pathname;\n\n // Derive tab from navigation entries (works for registered custom views)\n let urlTab = getSelectedTabFromUrl(isNew, lastCustomView);\n\n // Fallback: internal tabs like __json or __rebase_history aren't registered as\n // entity views, so the navigation parser ignores them. Check the raw pathname\n // for a trailing segment after the entity ID to catch those cases.\n if (!urlTab && recordUrl !== undefined) {\n const trailingSegment = getPathAfterRecord(pathname, recordUrl);\n if (trailingSegment && trailingSegment !== \"edit\") {\n urlTab = trailingSegment;\n }\n }\n\n const [selectedTab, setSelectedTab] = useState<string | undefined>(urlTab);\n\n const parentCollectionSlugs = collectionRegistry.getParentCollectionSlugs(navigationPath);\n const parentEntityIds = collectionRegistry.getParentEntityIds(navigationPath);\n useEffect(() => {\n if (urlTab !== selectedTab) {\n setSelectedTab(urlTab);\n }\n }, [urlTab]);\n\n // The URL of a record in this collection, or of one of its tabs.\n const recordTabUrl = (id: string | number, tab?: string) =>\n `${basePath}/${encodeUrlPathSegment(String(id))}${tab ? \"/\" + encodeUrlPathSegment(tab) : \"\"}`;\n\n // Compared decoded: a location's pathname spells an id the way whoever\n // wrote it encoded it, and these paths are built here.\n const entityPath = decodeUrlPath(recordUrl ?? `${basePath}/${entityId}`);\n const decodedBasePath = decodeUrlPath(basePath);\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n const nextPathname = decodeUrlPath(nextLocation.pathname);\n // Inside this record — a tab, `/edit`. By path segment: a bare\n // prefix let Back to `/c/products/12` out of `/c/products/1` without\n // asking.\n if (isPathWithinRecord(nextPathname, entityPath))\n return false;\n\n // Side panel overlay navigations preserve the underlying form via\n // base_location in router state — no data is lost in either direction.\n\n // Opening a side panel (e.g. clicking a relation arrow)\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\")\n return false;\n\n // Closing a side panel (navigate(-1) back to the form's own path)\n const currentHash = currentLocation.hash;\n if ((currentHash === \"#side\" || currentHash === \"#new_side\") &&\n (nextPathname === decodedBasePath ||\n isPathWithinRecord(nextPathname, entityPath)))\n return false;\n\n return blocked.current;\n }, [entityPath, decodedBasePath]));\n\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n\n if (isNew && !lastCollectionEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n throw new Error(\"INTERNAL: No collection found in the navigation\");\n }\n\n if (!isNew && !lastEntityEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <NotFoundPage/>;\n }\n\n const rawCollection = isNew\n ? (lastCollectionEntry && \"collection\" in lastCollectionEntry ? lastCollectionEntry.collection : undefined)!\n : (lastEntityEntry && \"parentCollection\" in lastEntityEntry ? lastEntityEntry.parentCollection : undefined)!;\n const collection = collectionRegistry.getCollection(rawCollection.slug) || rawCollection;\n const fullIdPath = isNew ? lastCollectionEntry!.slug : lastEntityEntry!.slug;\n const collectionPath = urlController.resolveDatabasePathsFrom(fullIdPath);\n const isEditRoute = pathname.endsWith(\"/edit\") || pathname.split(\"/\").pop() === \"edit\";\n // Determine if this is a detail-view-first collection showing the view page\n const isDetailMode = collection.defaultEntityAction === \"view\" && !isNew && !isCopy && entityId && !isEditRoute;\n\n // A record is full screen either because its collection has no list to show\n // beside it, or because the user folded that list away. Only the second is\n // reversible, and it is reversible by dropping `#full` alone: this is the\n // same URL the split route reads, so the same conditions decide it.\n const splitListAvailable = !isNew && !isCopy && entityId !== undefined &&\n navigationEntries[0]?.type === \"collection\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3) &&\n resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n }) === \"split\";\n\n const showList = splitListAvailable\n ? () => navigate({\n pathname,\n search: location.search,\n hash: \"\"\n })\n : undefined;\n\n if (isDetailMode) {\n return <>\n <DetailViewBinding\n key={collection.slug + \"_view_\" + entityId}\n entityId={entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n onEditClick={() => {\n const editUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`) + \"/edit\";\n navigate(editUrl + hash);\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n </>;\n }\n\n return <>\n <EditViewBinding\n key={collection.slug + \"_\" + (isNew ? \"new\" : (isCopy ? entityId + \"_copy\" : entityId))}\n entityId={isNew ? undefined : entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n copy={isCopy}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n defaultValues={isNew ? defaultValues : undefined}\n onValuesModified={(modified) => blocked.current = modified}\n navigateBack={() => {\n const detailUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`);\n navigate(detailUrl + hash);\n }}\n onSaved={(params) => {\n const newSelectedTab = params.selectedTab;\n const newEntityId = params.entityId ?? params.entity.id;\n const savedHash = isNew ? \"\" : hash;\n navigate(`${recordTabUrl(newEntityId, newSelectedTab)}${savedHash}`, { replace: true });\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n if (isNew || entityId === undefined) {\n return;\n }\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => blocker?.proceed?.()}\n handleCancel={() => blocker?.reset?.()}\n body={t(\"unsaved_changes_in_entity\")}/>\n </>;\n}\n\n/**\n * Shown when a URL names a collection the registry cannot resolve.\n *\n * This used to be `return null`, which renders an empty pane inside the app\n * chrome: the sidebar, the nav highlight and the breadcrumb all still work,\n * because those read the collections array directly, while the view itself is\n * blank. Nothing is thrown, and the only trace is a `console.debug` — so the\n * panel looks like it lost its data rather than like it failed to find the\n * collection, and there is no string to search for.\n *\n * A slug containing slashes went unresolvable this way and cost an afternoon to\n * find. The lookup is fixed; this is the part that made it expensive.\n */\nfunction UnresolvedCollectionView({ path }: { path: string }) {\n const { t } = useTranslation();\n // Warn, not debug: this is a route that renders nothing useful, and it\n // should be visible at the console's default level.\n useEffect(() => {\n console.warn(\n `[rebase] No collection is registered for \"${path}\", so this route has nothing to render. ` +\n \"Check that the collection is in the collections array and that its slug matches the URL.\"\n );\n }, [path]);\n\n return <CenteredView>\n <ErrorView\n title={t(\"collection_not_found\")}\n error={t(\"collection_not_found_body\", { path })}\n tooltip={t(\"collection_not_found_hint\")}/>\n </CenteredView>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAc;CAC1B,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,oBAAD,CAAoB,CAAA;CACd,CAAA;AACd;AAEA,SAAS,qBAAqB;CAE1B,MAAM,WAAW,YAAY;CAC7B,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,cAAc,yBAAyB;CAC7C,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,yBAAyB,qBAAqB,mBAAmB,yBAAqB;CAC5F,MAAM,kBAAkB,6BAA6B;CAErD,MAAM,OAAO,SAAS;CAKtB,MAAM,mBAAmB,KAAK,SAAS,WAAW;CAClD,MAAM,cAAc,KAAK,SAAS,OAAO,KAAK;CAC9C,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,CAAC;CACxC,MAAM,SAAS,KAAK,SAAS,OAAO;CACpC,MAAM,eAAe,KAAK,SAAS,OAAO;CAE1C,MAAM,WAAW,SAAS;CAG1B,MAAM,oBAAoB,6BAA6B;EACnD,MAHmB,cAAc,kBAAkB,QAG7C;EACN,aAAa,mBAAmB,eAAe,CAAC;CACpD,CAAC;CAED,gBAAgB;EACZ,YAAY,IAAI,EACZ,aAAa,kBAAkB,KAAK,UAAU;GAE1C,IAAI,MAAM,SAAS,UACf,OAAQ;IACJ,OAAO,OAAO,MAAM,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AAS,SAAS,WAAW,UAAU,SA4BhF,GAED,oBAAC,sBAAD;EACI,MAAM,SAAS,UAAU;EACzB,gBAAgB,SAAS,UAAU;EACnC,oBAAoB,SAAS,QAAQ;EACrC,MAAM,EAAE,2BAA2B;CAAG,CAAA,CAC5C,EAAA,CAAA;AACN;;;;;;;;;;;;;;AAeA,SAAS,yBAAyB,EAAE,QAA0B;CAC1D,MAAM,EAAE,MAAM,eAAe;CAG7B,gBAAgB;EACZ,QAAQ,KACJ,6CAA6C,KAAK,iIAEtD;CACJ,GAAG,CAAC,IAAI,CAAC;CAET,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD;EACI,OAAO,EAAE,sBAAsB;EAC/B,OAAO,EAAE,6BAA6B,EAAE,KAAK,CAAC;EAC9C,SAAS,EAAE,2BAA2B;CAAG,CAAA,EACnC,CAAA;AAClB"}
@@ -1,4 +1,5 @@
1
1
  import { withListState } from "./view_mode.js";
2
+ import { hasEntityId } from "@rebasepro/common";
2
3
  import { addInitialSlash, getCollectionBySlugWithin, getCollectionPathsCombinations, getLastSegment as getLastSegment$1, removeInitialAndTrailingSlashes as removeInitialAndTrailingSlashes$1, removeInitialSlash, removeTrailingSlash as removeTrailingSlash$1, resolveCollectionPathIds as resolveCollectionPathIds$1 } from "@rebasepro/app";
3
4
  //#region src/util/navigation_utils.ts
4
5
  /**
@@ -19,10 +20,10 @@ function navigateToEntity({ openEntityMode, collection, entityId, copy, path, se
19
20
  defaultValues
20
21
  });
21
22
  else {
22
- let to = navigation.buildUrlCollectionPath(entityId ? `${path ?? path}/${entityId}` : path ?? path);
23
- if (entityId && selectedTab) to += `/${selectedTab}`;
23
+ let to = navigation.buildUrlCollectionPath(hasEntityId(entityId) ? `${path}/${entityId}` : path);
24
+ if (hasEntityId(entityId) && selectedTab) to += `/${selectedTab}`;
24
25
  to = withListState(to);
25
- if (!entityId) to += "#new";
26
+ if (!hasEntityId(entityId)) to += "#new";
26
27
  if (copy) to += "#copy";
27
28
  const navigateOptions = {};
28
29
  if (replace !== void 0) navigateOptions.replace = replace;
@@ -1 +1 @@
1
- {"version":3,"file":"navigation_utils.js","names":[],"sources":["../../src/util/navigation_utils.ts"],"sourcesContent":["\nimport type { UrlController, SidePanelBindingProps, SidePanelController, NavigateOptions, AdminCollection } from \"@rebasepro/cms-types\";\nimport { withListState } from \"./view_mode\";\n\n// Canonical path utilities — single source of truth in @rebasepro/common\nexport { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, addInitialSlash, getLastSegment, resolveCollectionPathIds, getCollectionBySlugWithin, getCollectionPathsCombinations } from \"@rebasepro/app\";\n\n/**\n * Navigate to a entity using either a side panel or full-screen mode.\n * This is an admin-specific UI concern and lives here (not in common).\n */\nexport function navigateToEntity({\n openEntityMode,\n collection,\n entityId,\n copy,\n path,\n selectedTab,\n defaultValues,\n sidePanelController,\n onClose,\n onUpdate,\n navigation,\n replace\n}:\n\n {\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n collection?: AdminCollection;\n entityId?: string | number;\n selectedTab?: string;\n copy?: boolean;\n /**\n * Pre-populate the new entity form with these values.\n * Only applied when entityId is not set (i.e. \"new\" mode).\n *\n * Side panel: passed through SidePanelBindingProps → EditViewBinding.\n * Full screen: carried via React Router location.state so the route\n * component can read it on mount without polluting the URL.\n */\n defaultValues?: Record<string, unknown>;\n path: string;\n sidePanelController: SidePanelController;\n onClose?: () => void;\n /**\n * Called when the side panel or dialog saves the record. A full-screen\n * record replaces the view that opened it, and that view reads\n * everything again when it comes back, so nothing is called there.\n */\n onUpdate?: SidePanelBindingProps[\"onUpdate\"];\n navigation: UrlController;\n replace?: boolean;\n }) {\n\n // No CMS route serves this page (a collection embedded in the host app's\n // own page): there is no URL to go to, so the record opens over the page.\n const mode = navigation.routesMounted === false && openEntityMode !== \"dialog\"\n ? \"side_panel\"\n : openEntityMode;\n\n if (mode === \"side_panel\" || mode === \"dialog\") {\n\n sidePanelController.open({\n entityId,\n path: path,\n copy,\n selectedTab,\n collection,\n updateUrl: mode !== \"dialog\",\n onClose,\n onUpdate,\n defaultValues\n });\n\n } else {\n let to = navigation.buildUrlCollectionPath(entityId ? `${path ?? path}/${entityId}` : path ?? path);\n if (entityId && selectedTab) {\n to += `/${selectedTab}`;\n }\n // The whole list state, not just the view mode: a record opened from a\n // search must come back to that search.\n to = withListState(to);\n if (!entityId) {\n to += \"#new\";\n }\n if (copy) {\n to += \"#copy\";\n }\n // Use React Router location.state to carry defaultValues — the correct SPA\n // approach. No URL size limits, no encoding, nothing in the address bar.\n // EntityFullScreenRoute reads location.state.defaultValues on mount.\n const navigateOptions: NavigateOptions = {};\n if (replace !== undefined) {\n navigateOptions.replace = replace;\n }\n if (defaultValues) {\n navigateOptions.state = { defaultValues };\n }\n const hasOptions = Object.keys(navigateOptions).length > 0;\n navigation.navigate(to, hasOptions ? navigateOptions : undefined);\n }\n\n}\n\n/**\n * Whether `pathname` is the record at `entityPath` or somewhere below it — one\n * of its tabs, its `/edit`. A path segment, not a string prefix:\n * `/c/products/12` is another record, not a place inside `/c/products/1`.\n */\nexport function isPathWithinRecord(pathname: string, entityPath: string): boolean {\n return pathname === entityPath || pathname.startsWith(`${entityPath}/`);\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,iBAAiB,EAC7B,gBACA,YACA,UACA,MACA,MACA,aACA,eACA,qBACA,SACA,UACA,YACA,WA6BG;CAIH,MAAM,OAAO,WAAW,kBAAkB,SAAS,mBAAmB,WAChE,eACA;CAEN,IAAI,SAAS,gBAAgB,SAAS,UAElC,oBAAoB,KAAK;EACrB;EACM;EACN;EACA;EACA;EACA,WAAW,SAAS;EACpB;EACA;EACA;CACJ,CAAC;MAEE;EACH,IAAI,KAAK,WAAW,uBAAuB,WAAW,GAAG,QAAQ,KAAK,GAAG,aAAa,QAAQ,IAAI;EAClG,IAAI,YAAY,aACZ,MAAM,IAAI;EAId,KAAK,cAAc,EAAE;EACrB,IAAI,CAAC,UACD,MAAM;EAEV,IAAI,MACA,MAAM;EAKV,MAAM,kBAAmC,CAAC;EAC1C,IAAI,YAAY,KAAA,GACZ,gBAAgB,UAAU;EAE9B,IAAI,eACA,gBAAgB,QAAQ,EAAE,cAAc;EAE5C,MAAM,aAAa,OAAO,KAAK,eAAe,CAAC,CAAC,SAAS;EACzD,WAAW,SAAS,IAAI,aAAa,kBAAkB,KAAA,CAAS;CACpE;AAEJ;;;;;;AAOA,SAAgB,mBAAmB,UAAkB,YAA6B;CAC9E,OAAO,aAAa,cAAc,SAAS,WAAW,GAAG,WAAW,EAAE;AAC1E"}
1
+ {"version":3,"file":"navigation_utils.js","names":[],"sources":["../../src/util/navigation_utils.ts"],"sourcesContent":["\nimport type { UrlController, SidePanelBindingProps, SidePanelController, NavigateOptions, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { withListState } from \"./view_mode\";\n\n// Canonical path utilities — single source of truth in @rebasepro/common\nexport { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, addInitialSlash, getLastSegment, resolveCollectionPathIds, getCollectionBySlugWithin, getCollectionPathsCombinations } from \"@rebasepro/app\";\n\n/**\n * Navigate to a entity using either a side panel or full-screen mode.\n * This is an admin-specific UI concern and lives here (not in common).\n */\nexport function navigateToEntity({\n openEntityMode,\n collection,\n entityId,\n copy,\n path,\n selectedTab,\n defaultValues,\n sidePanelController,\n onClose,\n onUpdate,\n navigation,\n replace\n}:\n\n {\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n collection?: AdminCollection;\n entityId?: string | number;\n selectedTab?: string;\n copy?: boolean;\n /**\n * Pre-populate the new entity form with these values.\n * Only applied when entityId is not set (i.e. \"new\" mode).\n *\n * Side panel: passed through SidePanelBindingProps → EditViewBinding.\n * Full screen: carried via React Router location.state so the route\n * component can read it on mount without polluting the URL.\n */\n defaultValues?: Record<string, unknown>;\n path: string;\n sidePanelController: SidePanelController;\n onClose?: () => void;\n /**\n * Called when the side panel or dialog saves the record. A full-screen\n * record replaces the view that opened it, and that view reads\n * everything again when it comes back, so nothing is called there.\n */\n onUpdate?: SidePanelBindingProps[\"onUpdate\"];\n navigation: UrlController;\n replace?: boolean;\n }) {\n\n // No CMS route serves this page (a collection embedded in the host app's\n // own page): there is no URL to go to, so the record opens over the page.\n const mode = navigation.routesMounted === false && openEntityMode !== \"dialog\"\n ? \"side_panel\"\n : openEntityMode;\n\n if (mode === \"side_panel\" || mode === \"dialog\") {\n\n sidePanelController.open({\n entityId,\n path: path,\n copy,\n selectedTab,\n collection,\n updateUrl: mode !== \"dialog\",\n onClose,\n onUpdate,\n defaultValues\n });\n\n } else {\n let to = navigation.buildUrlCollectionPath(hasEntityId(entityId) ? `${path}/${entityId}` : path);\n if (hasEntityId(entityId) && selectedTab) {\n to += `/${selectedTab}`;\n }\n // The whole list state, not just the view mode: a record opened from a\n // search must come back to that search.\n to = withListState(to);\n if (!hasEntityId(entityId)) {\n to += \"#new\";\n }\n if (copy) {\n to += \"#copy\";\n }\n // Use React Router location.state to carry defaultValues — the correct SPA\n // approach. No URL size limits, no encoding, nothing in the address bar.\n // EntityFullScreenRoute reads location.state.defaultValues on mount.\n const navigateOptions: NavigateOptions = {};\n if (replace !== undefined) {\n navigateOptions.replace = replace;\n }\n if (defaultValues) {\n navigateOptions.state = { defaultValues };\n }\n const hasOptions = Object.keys(navigateOptions).length > 0;\n navigation.navigate(to, hasOptions ? navigateOptions : undefined);\n }\n\n}\n\n/**\n * Whether `pathname` is the record at `entityPath` or somewhere below it — one\n * of its tabs, its `/edit`. A path segment, not a string prefix:\n * `/c/products/12` is another record, not a place inside `/c/products/1`.\n */\nexport function isPathWithinRecord(pathname: string, entityPath: string): boolean {\n return pathname === entityPath || pathname.startsWith(`${entityPath}/`);\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,iBAAiB,EAC7B,gBACA,YACA,UACA,MACA,MACA,aACA,eACA,qBACA,SACA,UACA,YACA,WA6BG;CAIH,MAAM,OAAO,WAAW,kBAAkB,SAAS,mBAAmB,WAChE,eACA;CAEN,IAAI,SAAS,gBAAgB,SAAS,UAElC,oBAAoB,KAAK;EACrB;EACM;EACN;EACA;EACA;EACA,WAAW,SAAS;EACpB;EACA;EACA;CACJ,CAAC;MAEE;EACH,IAAI,KAAK,WAAW,uBAAuB,YAAY,QAAQ,IAAI,GAAG,KAAK,GAAG,aAAa,IAAI;EAC/F,IAAI,YAAY,QAAQ,KAAK,aACzB,MAAM,IAAI;EAId,KAAK,cAAc,EAAE;EACrB,IAAI,CAAC,YAAY,QAAQ,GACrB,MAAM;EAEV,IAAI,MACA,MAAM;EAKV,MAAM,kBAAmC,CAAC;EAC1C,IAAI,YAAY,KAAA,GACZ,gBAAgB,UAAU;EAE9B,IAAI,eACA,gBAAgB,QAAQ,EAAE,cAAc;EAE5C,MAAM,aAAa,OAAO,KAAK,eAAe,CAAC,CAAC,SAAS;EACzD,WAAW,SAAS,IAAI,aAAa,kBAAkB,KAAA,CAAS;CACpE;AAEJ;;;;;;AAOA,SAAgB,mBAAmB,UAAkB,YAA6B;CAC9E,OAAO,aAAa,cAAc,SAAS,WAAW,GAAG,WAAW,EAAE;AAC1E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/cms",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Rebase CMS — content management views, forms, and routing",
5
5
  "keywords": [
6
6
  "rebase",
@@ -93,14 +93,14 @@
93
93
  "react-use-measure": "^2.1.7",
94
94
  "read-excel-file": "^9.3.10",
95
95
  "zod": "^4.4.3",
96
- "@rebasepro/app": "0.27.0",
97
- "@rebasepro/common": "0.27.0",
98
- "@rebasepro/cms-types": "0.27.0",
99
- "@rebasepro/forms": "0.27.0",
100
- "@rebasepro/inference": "0.27.0",
101
- "@rebasepro/types": "0.27.0",
102
- "@rebasepro/utils": "0.27.0",
103
- "@rebasepro/ui": "0.27.0"
96
+ "@rebasepro/app": "0.28.0",
97
+ "@rebasepro/common": "0.28.0",
98
+ "@rebasepro/cms-types": "0.28.0",
99
+ "@rebasepro/forms": "0.28.0",
100
+ "@rebasepro/inference": "0.28.0",
101
+ "@rebasepro/types": "0.28.0",
102
+ "@rebasepro/ui": "0.28.0",
103
+ "@rebasepro/utils": "0.28.0"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^19.2.7",