@rebasepro/cms 0.25.1 → 0.27.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.
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
- package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +9 -2
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
- package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
- package/dist/components/CollectionsScopeContext.d.ts +5 -1
- package/dist/components/CollectionsScopeContext.js +10 -2
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DefaultAppBar.js +2 -1
- package/dist/components/DefaultAppBar.js.map +1 -1
- package/dist/components/DefaultDrawer.js +19 -6
- package/dist/components/DefaultDrawer.js.map +1 -1
- package/dist/components/DefaultMissingReference.d.ts +8 -0
- package/dist/components/DefaultMissingReference.js +13 -0
- package/dist/components/DefaultMissingReference.js.map +1 -0
- package/dist/components/EntityFormPanel.d.ts +7 -2
- package/dist/components/EntityFormPanel.js +72 -29
- package/dist/components/EntityFormPanel.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +7 -5
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/HomePage/HomePageDnD.js +3 -1
- package/dist/components/HomePage/HomePageDnD.js.map +1 -1
- package/dist/components/HomePage/SmallNavigationCard.js +25 -0
- package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
- package/dist/components/RebaseAuthGate.js +3 -2
- package/dist/components/RebaseAuthGate.js.map +1 -1
- package/dist/components/RebaseLayout.d.ts +4 -1
- package/dist/components/RebaseLayout.js +7 -1
- package/dist/components/RebaseLayout.js.map +1 -1
- package/dist/components/RebaseShell.d.ts +4 -1
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/SideDialogs.js +10 -4
- package/dist/components/SideDialogs.js.map +1 -1
- package/dist/components/app/Scaffold.js +5 -1
- package/dist/components/app/Scaffold.js.map +1 -1
- package/dist/components/field_configs.js +1 -1
- package/dist/components/history/EntityHistoryView.js +6 -4
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
- package/dist/data_export/export/export.d.ts +2 -13
- package/dist/data_export/export/export.js +1 -36
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +17 -13
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +42 -4
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +1 -1
- package/dist/form/components/FieldBlock.d.ts +8 -1
- package/dist/form/components/FieldBlock.js +16 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormSections.js +1 -1
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/components/LabelWithIcon.js +5 -2
- package/dist/form/components/LabelWithIcon.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js +8 -6
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +18 -1
- package/dist/form/form_utils.js +38 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/label_placement.d.ts +23 -0
- package/dist/form/label_placement.js +71 -0
- package/dist/form/label_placement.js.map +1 -0
- package/dist/form/resolve_form_properties.d.ts +35 -3
- package/dist/form/resolve_form_properties.js +67 -6
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/hooks/useHistory.d.ts +5 -0
- package/dist/hooks/useHistory.js +22 -6
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/index.d.ts +50 -0
- package/dist/index.js +34 -7
- package/dist/preview/components/ReferencePreview.js +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.js +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +11 -0
- package/package.json +11 -10
- package/recipes/README.md +131 -0
- package/recipes/bulk-set-status.tsx +62 -0
- package/recipes/calendar-view.tsx +123 -0
- package/recipes/custom-login.tsx +60 -0
- package/recipes/my-preferences.tsx +68 -0
- package/recipes/orders-dashboard.tsx +125 -0
- package/recipes/site-settings.tsx +63 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useMemo, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\n /** The record to edit. Omit it to create a new one. */\n entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n const shownEntity = entity ?? savedEntity;\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity) {\n if (dataLoading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <div className=\"flex flex-col items-center gap-2 text-center\">\n <Typography variant=\"label\">{t(\"entity_not_found\")}</Typography>\n <Typography variant=\"body2\" color=\"secondary\">{t(\"entity_not_found_body\")}</Typography>\n </div>\n </CenteredView>\n );\n }\n\n const editable = shownEntity === undefined || canEdit(collection, path, shownEntity);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={entityId !== undefined ? \"existing\" : \"new\"}\n initialDirtyValues={entityId === undefined ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\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I,gBAAgB,SAAS,OAAO,oBAAC,wBAAD,CAAwB,CAAA;EAC5D,OACI,oBAAC,cAAD;GAAyB;aACrB,oBAAC,YAAD;IAAY,SAAQ;IAAQ,OAAM;cAC7B,EAAE,kBAAkB;GACb,CAAA;EACF,CAAA;CAEtB;CAEA,IAAI,aAAa,KAAA,KAAa,kBAC1B,OAAO,oBAAC,cAAD;EAAyB;YAAW,oBAAC,WAAD,EAAW,OAAO,iBAAkB,CAAA;CAAe,CAAA;CAElG,IAAI,aAAa,KAAA,KAAa,CAAC,aAAa;EACxC,IAAI,aAAa,OAAO,oBAAC,wBAAD,CAAwB,CAAA;EAChD,OACI,oBAAC,cAAD;GAAyB;aACrB,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,oBAAC,YAAD;KAAY,SAAQ;eAAS,EAAE,kBAAkB;IAAc,CAAA,GAC/D,oBAAC,YAAD;KAAY,SAAQ;KAAQ,OAAM;eAAa,EAAE,uBAAuB;IAAc,CAAA,CACrF;;EACK,CAAA;CAEtB;CAEA,MAAM,WAAW,gBAAgB,KAAA,KAAa,QAAQ,YAAY,MAAM,WAAW;CAEnF,OACI,oBAAC,yBAAD;EAAqC;YACjC,oBAAC,mBAAD;GACI,GAAI;GACJ,WAAW,aAAa,WAAW;GAC7B;GACM;GACF;GACV,QAAQ;GACR,eAAe,aAAa,KAAA,IAAY,aAAa;GACrD,oBAAoB,aAAa,KAAA,IAAY,gBAAgB,WAAW;GACxE,UAAU,CAAC,YAAY,WAAW;GAClC,iBAAiB,YAAY;IACzB,eAAe,OAAO;IACtB,WAAW,iBAAiB,OAAO;GACvC;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;EACjB,CAAA;CACoB,CAAA;AAEjC"}
|
|
1
|
+
{"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${props.path ?? collection.slug}/${props.entityId ?? \"new\"}`;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope key={recordKey} {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entity={asNew.saved}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onEntityChange={(changed) => {\n // The record it created, which it edits from then on.\n setAsNew(current => current && { ...current, saved: changed });\n formProps?.onEntityChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"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AAM;IAC3B,UAAU,MAAM;GACpB;GACc;EACjB,CAAA;CACoB,CAAA;CAIjC,IAAI,aAAa,KAAA,KAAa,kBAC1B,OAAO,oBAAC,cAAD;EAAyB;YAAW,oBAAC,WAAD,EAAW,OAAO,iBAAkB,CAAA;CAAe,CAAA;CAElG,IAAI,aAAa,KAAA,KAAa,CAAC,eAAe,aAAa,OAAO,oBAAC,wBAAD,CAAwB,CAAA;CAK1F,MAAM,WAAW,gBAAgB,KAAA;CAGjC,MAAM,WAAW,WAAW,UAAU,YAAY,IAAI,IAAI,QAAQ,YAAY,MAAM,WAAW;CAE/F,OACI,oBAAC,yBAAD;EAAqC;YACjC,qBAAC,mBAAD;GACI,GAAI;GACJ,WAAW,aAAa,WAAW;GAC7B;GACM;GACF;GACV,QAAQ;GACR,eAAe,WAAW,QAAQ;GAClC,oBAAoB,WAAW,gBAAgB,WAAW;GAC1D,UAAU,CAAC,YAAY,WAAW;GAClC,iBAAiB,YAAY;IACzB,eAAe,OAAO;IACtB,WAAW,iBAAiB,OAAO;GACvC;GACA,mBAAmB,UAAU,WAAW;IACpC,YAAY,UAAU;IACtB,WAAW,mBAAmB,UAAU,MAAM;GAClD;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;aAtBlB,CAwBK,oBACG,oBAAC,OAAD;IAAO,OAAO;IAAW,MAAM;IAAS,gBAAgB;IACpD,QAAQ,oBAAC,QAAD;KAAQ,MAAM;KAAS,SAAS;KAAQ,SAAS;eAAY,EAAE,aAAa;IAAU,CAAA;cAC7F,EAAE,0BAA0B;GAC1B,CAAA,GACV,WAAW,QACG;;CACE,CAAA;AAEjC"}
|
|
@@ -9,7 +9,8 @@ import { RenameGroupDialog } from "./RenameGroupDialog.js";
|
|
|
9
9
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Container, ErrorBoundary, SearchBar } from "@rebasepro/ui";
|
|
12
|
-
import { SchemaDriftBanner, buildCollapsedDefaults, useAdminModeController, useCollapsedGroups, useCustomizationController, useRebaseRegistry, useRestoreScroll, useSlot, useTranslation } from "@rebasepro/app";
|
|
12
|
+
import { SchemaDriftBanner, buildCollapsedDefaults, useAdminModeController, useCollapsedGroups, useComponentOverride, useCustomizationController, useRebaseRegistry, useRestoreScroll, useSlot, useTranslation } from "@rebasepro/app";
|
|
13
|
+
import { studioSchemaToolEnabled } from "@rebasepro/cms-types";
|
|
13
14
|
import { DndContext, DragOverlay, MeasuringStrategy } from "@dnd-kit/core";
|
|
14
15
|
import { restrictToVerticalAxis, restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
15
16
|
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
@@ -24,6 +25,7 @@ function ContentHomePage({ additionalActions, additionalChildrenStart, additiona
|
|
|
24
25
|
const adminModeController = useAdminModeController();
|
|
25
26
|
const registry = useRebaseRegistry();
|
|
26
27
|
const { resolvedSlots } = customizationController;
|
|
28
|
+
const ResolvedCollectionCard = useComponentOverride("HomePage.CollectionCard", NavigationCardBinding);
|
|
27
29
|
const breadcrumbs = useBreadcrumbsController();
|
|
28
30
|
const { t } = useTranslation();
|
|
29
31
|
useEffect(() => {
|
|
@@ -33,9 +35,9 @@ function ContentHomePage({ additionalActions, additionalChildrenStart, additiona
|
|
|
33
35
|
const studioViewSlugs = useMemo(() => {
|
|
34
36
|
const slugs = /* @__PURE__ */ new Set();
|
|
35
37
|
(registry.studioConfig?.devViews ?? []).forEach((v) => slugs.add(v.slug));
|
|
36
|
-
if (registry
|
|
38
|
+
if (studioSchemaToolEnabled(registry)) slugs.add("schema");
|
|
37
39
|
return slugs;
|
|
38
|
-
}, [registry
|
|
40
|
+
}, [registry]);
|
|
39
41
|
const rawNavigationEntries = useMemo(() => {
|
|
40
42
|
if (adminModeController.mode === "studio") return unFilteredNavigationEntries.filter((e) => e.type === "view" && studioViewSlugs.has(e.slug) || e.type === "admin");
|
|
41
43
|
return unFilteredNavigationEntries.filter((e) => e.type !== "view" || !studioViewSlugs.has(e.slug));
|
|
@@ -277,7 +279,7 @@ function ContentHomePage({ additionalActions, additionalChildrenStart, additiona
|
|
|
277
279
|
isPreview: false,
|
|
278
280
|
minimised: true
|
|
279
281
|
})
|
|
280
|
-
}) : activeItemForOverlay ? /* @__PURE__ */ jsx(
|
|
282
|
+
}) : activeItemForOverlay ? /* @__PURE__ */ jsx(ResolvedCollectionCard, {
|
|
281
283
|
...activeItemForOverlay,
|
|
282
284
|
shrink: isHoveringNewGroupDropZone
|
|
283
285
|
}) : null
|
|
@@ -290,7 +292,7 @@ function ContentHomePage({ additionalActions, additionalChildrenStart, additiona
|
|
|
290
292
|
onToggleCollapsed: () => toggleGroupCollapsed(adminGroupData.name),
|
|
291
293
|
children: /* @__PURE__ */ jsx("div", {
|
|
292
294
|
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 ",
|
|
293
|
-
children: adminGroupData.entries.map((entry) => /* @__PURE__ */ jsx(
|
|
295
|
+
children: adminGroupData.entries.map((entry) => /* @__PURE__ */ jsx(ResolvedCollectionCard, {
|
|
294
296
|
...entry,
|
|
295
297
|
onClick: () => {
|
|
296
298
|
let event = "unmapped_event";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentHomePage.js","names":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (registry.studioConfig && registry.cmsConfig?.collectionEditor) slugs.add(\"schema\");\n return slugs;\n }, [registry.studioConfig, registry.cmsConfig?.collectionEditor]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n autoFocus\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {additionalActions}\n {additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <NavigationCardBinding\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <NavigationCardBinding\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;CAC1B,MAAM,cAAc,yB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I,GAAI;OACJ,eAAe;QACX,IAAI,QACA;QACJ,IAAI,MAAM,SAAS,cACf,QACI;aACH,IAAI,MAAM,SAAS,QACpB,QAAQ;aACP,IAAI,MAAM,SAAS,SACpB,QACI;QAER,QAAQ,qBAAqB,mBACzB,OACA,EAAE,MAAM,MAAM,KAAK,CACvB;OACJ;MACH,GAnBQ,MAAM,GAmBd,CACJ;KACA,CAAA;IACQ,CAAA;IAGpB,YAAY,SAAS,KAAK,YACvB,oBAAC,iBAAD;KAEI,OAAO,QAAQ;eAEd,QAAQ;IACI,GAJR,QAAQ,GAIA,CACpB;IAEA;IACA;GACM;MAEV,sBACG,oBAAC,mBAAD;GACI,MAAA;GACA,aAAa;GACb,oBAAoB,MACf,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,QAAQ,MAAM,MAAM,kBAAkB;GAC3C,SAAS;GACT,WAAW,YAAY;IACnB,kBAAkB,oBAAoB,OAAO;GACjD;EACH,CAAA,CAEJ;;AAEb"}
|
|
1
|
+
{"version":3,"file":"ContentHomePage.js","names":[],"sources":["../../../src/components/HomePage/ContentHomePage.tsx"],"sourcesContent":["import type { HomePageSection, NavigationEntry, NavigationGroupMapping, PluginGenericProps } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Fuse from \"fuse.js\";\nimport { Container, SearchBar } from \"@rebasepro/ui\";\nimport { AnalyticsEvent, studioSchemaToolEnabled } from \"@rebasepro/cms-types\";\nimport { FavouritesView } from \"./FavouritesView\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { NavigationGroup } from \"./NavigationGroup\";\nimport {\n NavigationGroupDroppable,\n NewGroupDropZone,\n SortableNavigationCard,\n SortableNavigationGroup,\n useHomePageDnd\n} from \"./HomePageDnD\";\nimport { DndContext, DragOverlay, MeasuringStrategy } from \"@dnd-kit/core\";\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\nimport { restrictToVerticalAxis, restrictToWindowEdges } from \"@dnd-kit/modifiers\";\nimport { RenameGroupDialog } from \"./RenameGroupDialog\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollapsedGroups, buildCollapsedDefaults, useComponentOverride, useCustomizationController, useTranslation, useSlot, useAdminModeController, useRebaseRegistry } from \"@rebasepro/app\";\nimport { useRestoreScroll } from \"@rebasepro/app\";\n\nimport { SchemaDriftBanner } from \"@rebasepro/app\";\nimport { useBreadcrumbsController } from \"../../hooks/useBreadcrumbsController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { NavigationLoadingErrorView } from \"../NavigationLoadingErrorView\";\n\nexport const DEFAULT_GROUP_NAME = \"Views\";\nexport const ADMIN_GROUP_NAME = \"Admin\";\n\nexport function ContentHomePage({\n additionalActions,\n additionalChildrenStart,\n additionalChildrenEnd,\n sections,\n hiddenGroups\n}: {\n additionalActions?: React.ReactNode;\n additionalChildrenStart?: React.ReactNode;\n additionalChildrenEnd?: React.ReactNode;\n sections?: HomePageSection[];\n hiddenGroups?: string[];\n}) {\n\n const context = useAdminContext();\n const { navigationStateController } = context;\n const customizationController = useCustomizationController();\n const adminModeController = useAdminModeController();\n const registry = useRebaseRegistry();\n\n const { resolvedSlots } = customizationController;\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n const breadcrumbs = useBreadcrumbsController();\n const { t } = useTranslation();\n\n useEffect(() => {\n breadcrumbs.set({ breadcrumbs: [] });\n }, [breadcrumbs.set]);\n\n const {\n allowDragAndDrop = false,\n navigationEntries: unFilteredNavigationEntries = [],\n groups: unFilteredGroupOrder = [],\n onNavigationEntriesUpdate = () => {}\n } = navigationStateController.topLevelNavigation || {};\n\n // Build a set of Studio-only dev view slugs so we can distinguish them from\n // admin custom views added via <RebaseCMS views={...}> or plugins.\n const studioViewSlugs = useMemo(() => {\n const slugs = new Set<string>();\n (registry.studioConfig?.devViews ?? []).forEach(v => slugs.add(v.slug));\n if (studioSchemaToolEnabled(registry)) slugs.add(\"schema\");\n return slugs;\n }, [registry]);\n\n // Studio mode shows Studio dev views + admin entries (Users/Roles).\n // Content mode shows collections, admin custom views, and admin entries — but not Studio dev views.\n const rawNavigationEntries = useMemo(() => {\n if (adminModeController.mode === \"studio\") {\n return unFilteredNavigationEntries.filter(e => (e.type === \"view\" && studioViewSlugs.has(e.slug)) || e.type === \"admin\");\n }\n return unFilteredNavigationEntries.filter(e => e.type !== \"view\" || !studioViewSlugs.has(e.slug));\n }, [unFilteredNavigationEntries, adminModeController.mode, studioViewSlugs]);\n\n const groupOrderFromNavController = useMemo(() => {\n const entryGroups = new Set(rawNavigationEntries.map(e => e.group).filter(Boolean));\n return unFilteredGroupOrder.filter(g => entryGroups.has(g));\n }, [unFilteredGroupOrder, rawNavigationEntries]);\n\n const fuse = useRef<Fuse<NavigationEntry> | null>(null);\n const [filteredUrls, setFilteredUrls] = useState<string[] | null>(null);\n const performingSearch = Boolean(filteredUrls);\n\n // Memoize filtered navigation entries to prevent unnecessary recalculations\n const filteredNavigationEntries = useMemo(() => {\n return filteredUrls\n ? rawNavigationEntries.filter((e) => filteredUrls.includes(e.url))\n : rawNavigationEntries;\n }, [filteredUrls, rawNavigationEntries]);\n\n useEffect(() => {\n fuse.current = new Fuse(rawNavigationEntries, {\n keys: [\"name\", \"description\", \"group\", \"path\"]\n });\n }, [rawNavigationEntries]);\n\n const updateSearch = useCallback((v?: string) => {\n if (!v?.trim()) {\n setFilteredUrls(null);\n return;\n }\n const results = fuse.current?.search(v.trim());\n setFilteredUrls(results ? results.map((x) => x.item.url) : []);\n }, []);\n\n /* ───────────────────────────────────────────────────────────────\n Build groups (all items) + isolate Admin\n ─────────────────────────────────────────────────────────────── */\n const [items, setItems] = useState<\n { name: string; entries: NavigationEntry[] }[]\n >([]);\n const [adminGroupData, setAdminGroupData] = useState<{\n name: string;\n entries: NavigationEntry[];\n } | null>(null);\n\n // Flag to prevent useEffect from overwriting local DnD state\n const isDndDirtyRef = useRef(false);\n const dndDirtyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Memoize the processed groups to avoid unnecessary recalculations\n const processedGroups = useMemo(() => {\n const src = filteredNavigationEntries;\n const entriesByGroup: Record<string, NavigationEntry[]> = {};\n\n src.forEach((e) => {\n const g =\n e.type === \"admin\"\n ? ADMIN_GROUP_NAME\n : e.group ?? DEFAULT_GROUP_NAME;\n (entriesByGroup[g] ??= []).push(e);\n });\n\n // Check if there are custom additional card components from plugins\n const hasPluginAdditionalCards = customizationController.resolvedSlots.some(s => s.slot === \"home.cards\");\n\n let allProcessed: { name: string; entries: NavigationEntry[] }[];\n\n if (performingSearch) {\n const ordered = [\n ...new Set(src.map((e) => e.group ?? DEFAULT_GROUP_NAME))\n ];\n allProcessed = ordered\n .map((name) => ({\n name,\n entries: entriesByGroup[name] || []\n }))\n .filter((g) => g.entries.length);\n } else {\n allProcessed = groupOrderFromNavController.map((g) => ({\n name: g,\n entries: entriesByGroup[g] || []\n }));\n Object.keys(entriesByGroup).forEach((g) => {\n if (!groupOrderFromNavController.includes(g))\n allProcessed.push({\n name: g,\n entries: entriesByGroup[g]\n });\n });\n\n // Ensure default group exists if there are plugin additional cards but no collections\n if (hasPluginAdditionalCards && !allProcessed.some(g => g.name === DEFAULT_GROUP_NAME)) {\n allProcessed.push({\n name: DEFAULT_GROUP_NAME,\n entries: []\n });\n }\n\n allProcessed = allProcessed.filter(\n (g) =>\n g.entries.length ||\n (g.name === DEFAULT_GROUP_NAME && hasPluginAdditionalCards)\n );\n }\n\n const admin = allProcessed.find((g) => g.name === ADMIN_GROUP_NAME);\n return {\n adminGroupData: admin || null,\n items: allProcessed.filter((g) => g.name !== ADMIN_GROUP_NAME && !hiddenGroups?.includes(g.name))\n };\n }, [filteredNavigationEntries, performingSearch, groupOrderFromNavController, customizationController.resolvedSlots, hiddenGroups]);\n\n // Update state only when processedGroups actually changes\n // Skip update if DnD just made a local change (dirty flag is set)\n useEffect(() => {\n if (isDndDirtyRef.current) {\n // DnD just updated the state, skip this sync\n return;\n }\n setAdminGroupData(processedGroups.adminGroupData);\n setItems(processedGroups.items);\n }, [processedGroups]);\n\n /* ───────────────────────────────────────────────────────────────\n Local update vs. persistence helpers\n ─────────────────────────────────────────────────────────────── */\n const updateItems = (\n updater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n prev: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => {\n setItems(updater); // local only\n };\n\n const persistNavigationGroups = (\n latest: { name: string; entries: NavigationEntry[] }[]\n ) => {\n // Set dirty flag to prevent useEffect from overwriting local state\n isDndDirtyRef.current = true;\n\n // Clear any existing timeout\n if (dndDirtyTimeoutRef.current) {\n clearTimeout(dndDirtyTimeoutRef.current);\n }\n\n // Clear dirty flag after a delay to allow navigation to update\n dndDirtyTimeoutRef.current = setTimeout(() => {\n isDndDirtyRef.current = false;\n }, 1000);\n\n // Map ALL groups including \"Views\"\n const draggable: NavigationGroupMapping[] = latest.map((g) => ({\n name: g.name,\n entries: g.entries.map((e) => e.slug)\n }));\n\n const all: NavigationGroupMapping[] = adminGroupData\n ? [\n ...draggable,\n {\n name: adminGroupData.name,\n entries: adminGroupData.entries.map((e) => e.slug)\n }\n ]\n : draggable;\n\n onNavigationEntriesUpdate(all);\n };\n\n // Use custom hook for collapsed groups with localStorage persistence\n const groupNames = useMemo(() => [\n ...items.map(item => item.name),\n ...(adminGroupData ? [adminGroupData.name] : [])\n ], [items, adminGroupData]);\n\n const collapsedDefaults = useMemo(\n () => buildCollapsedDefaults(registry.cmsConfig?.navigationGroupMappings, \"home\"),\n [registry.cmsConfig?.navigationGroupMappings]\n );\n const { isGroupCollapsed, toggleGroupCollapsed } = useCollapsedGroups(groupNames, \"home\", collapsedDefaults);\n\n const {\n sensors,\n collisionDetection,\n onDragStart,\n onDragOver,\n onDragEnd,\n dropAnimation,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId,\n containers,\n dndKitActiveNode,\n onDragCancel,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n } = useHomePageDnd({\n items,\n setItems: updateItems,\n disabled: !allowDragAndDrop || performingSearch,\n onPersist: persistNavigationGroups,\n onGroupMoved: (g) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_group\", {\n name: g\n }),\n onCardMovedBetweenGroups: (card) =>\n context.analyticsController?.onAnalyticsEvent?.(\"home_move_card\", {\n id: card.id\n }),\n onNewGroupDrop: () =>\n context.analyticsController?.onAnalyticsEvent?.(\n \"home_drop_new_group\"\n )\n });\n\n const {\n containerRef,\n direction\n } = useRestoreScroll();\n\n const dndDisabled = !allowDragAndDrop || performingSearch;\n\n const dndModifiers = dndKitActiveNode?.data.current?.type === \"group\"\n ? [restrictToVerticalAxis, restrictToWindowEdges]\n : [restrictToWindowEdges];\n\n const sectionProps: PluginGenericProps = { context };\n const additionalPluginChildrenStart = useSlot(\"home.children.start\", sectionProps);\n const additionalPluginChildrenEnd = useSlot(\"home.children.end\", sectionProps);\n const additionalPluginActions = useSlot(\"home.actions\", sectionProps);\n\n // Pre-compute home.cards slot contributions (cannot call useSlot inside .map loop)\n const homeCardContributions = useMemo(() => {\n return resolvedSlots\n .filter(s => s.slot === \"home.cards\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50));\n }, [resolvedSlots]);\n\n /* ───────────────────────────────────────────────────────────────\n Render\n ─────────────────────────────────────────────────────────────── */\n return (\n <div ref={containerRef} className=\"py-2 overflow-auto h-full w-full bg-surface-sheet\">\n <Container maxWidth=\"6xl\">\n <div className=\"mb-4 flex flex-col gap-2\">\n <SchemaDriftBanner />\n </div>\n {/* search & actions */}\n <div\n className=\"w-full sticky py-4 transition-all duration-400 ease-in-out top-0 z-10 flex flex-row gap-4\"\n style={{ top: direction === \"down\" ? -84 : 0 }}\n >\n <SearchBar\n onTextSearch={updateSearch}\n placeholder={t(\"search_collections\")}\n autoFocus\n size=\"small\"\n innerClassName=\"w-full\"\n className=\"w-full grow\"\n />\n {additionalActions}\n {additionalPluginActions}\n </div>\n\n {navigationStateController.navigationLoadingError &&\n <div className=\"mb-4\">\n <NavigationLoadingErrorView error={navigationStateController.navigationLoadingError}\n onRetry={navigationStateController.refreshNavigation}/>\n </div>}\n\n <FavouritesView hidden={performingSearch}/>\n\n {additionalChildrenStart}\n {additionalPluginChildrenStart}\n\n {/* ─────── DND context ─────── */}\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n measuring={{\n droppable: {\n strategy: MeasuringStrategy.Always,\n frequency: 500\n }\n }}\n onDragStart={onDragStart}\n onDragOver={onDragOver}\n onDragEnd={onDragEnd}\n onDragCancel={onDragCancel}\n modifiers={dndModifiers}\n >\n <SortableContext\n key={containers.join(\",\")}\n items={containers}\n strategy={verticalListSortingStrategy}\n >\n {items.map((groupData, groupIndex) => {\n const groupKey = groupData.name;\n const entriesInGroup = groupData.entries;\n\n const homeCardsProps = {\n group:\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey,\n context\n };\n // Render home.cards contributions inline (no hook call inside loop)\n const additionalCards = homeCardContributions.map((s, i) => (\n <ErrorBoundary key={`home_cards_${groupKey}_${i}`}>\n <s.Component {...homeCardsProps} {...(s.props ?? {})}/>\n </ErrorBoundary>\n ));\n\n if (\n entriesInGroup.length === 0 &&\n (additionalCards.length === 0 || performingSearch)\n )\n return null;\n\n return (\n <SortableNavigationGroup\n key={`group-${groupIndex}`}\n groupName={groupKey}\n disabled={dndDisabled}\n >\n <NavigationGroup\n group={\n groupKey === DEFAULT_GROUP_NAME\n ? undefined\n : groupKey\n }\n minimised={\n draggingGroupId === groupKey &&\n !isDraggingCardOnly\n }\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n dndDisabled={dndDisabled}\n onEditGroup={() => {\n if (dndDisabled) return;\n setDialogOpenForGroup(groupKey);\n }}\n collapsed={isGroupCollapsed(groupKey)}\n onToggleCollapsed={() => toggleGroupCollapsed(groupKey)}\n >\n <NavigationGroupDroppable\n id={groupKey}\n itemIds={entriesInGroup.map(\n (e) => e.url\n )}\n isPotentialCardDropTarget={\n isDraggingCardOnly\n }\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {entriesInGroup.map(\n (entry) => (\n <SortableNavigationCard\n key={entry.url}\n entry={entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (\n entry.type ===\n \"collection\"\n )\n event =\n \"home_navigate_to_collection\";\n else if (\n entry.type ===\n \"view\"\n )\n event =\n \"home_navigate_to_view\";\n else if (\n entry.type ===\n \"admin\"\n )\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n {\n path: entry.slug\n }\n );\n }}\n />\n )\n )}\n {!performingSearch &&\n groupKey.toLowerCase() !==\n ADMIN_GROUP_NAME.toLowerCase() &&\n additionalCards}\n </div>\n </NavigationGroupDroppable>\n </NavigationGroup>\n </SortableNavigationGroup>\n );\n })}\n </SortableContext>\n\n <NewGroupDropZone\n disabled={dndDisabled}\n setIsHovering={setIsHoveringNewGroupDropZone}\n />\n\n <DragOverlay adjustScale={false} dropAnimation={dropAnimation}>\n {activeGroupData &&\n draggingGroupId === activeGroupData.name ? (\n <div\n className=\"rounded-lg bg-transparent\"\n style={{\n padding: 0,\n margin: 0\n }}\n >\n <NavigationGroup\n group={\n activeGroupData.name ===\n DEFAULT_GROUP_NAME\n ? undefined\n : activeGroupData.name\n }\n isPreview={false}\n minimised\n />\n </div>\n ) : activeItemForOverlay ? (\n <ResolvedCollectionCard\n {...activeItemForOverlay}\n shrink={isHoveringNewGroupDropZone}\n />\n ) : null}\n </DragOverlay>\n </DndContext>\n\n {!performingSearch && adminGroupData && (\n <NavigationGroup\n group={adminGroupData.name}\n collapsed={isGroupCollapsed(adminGroupData.name)}\n onToggleCollapsed={() => toggleGroupCollapsed(adminGroupData.name)}\n >\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 \">\n {adminGroupData.entries.map((entry) => (\n <ResolvedCollectionCard\n key={entry.url}\n {...entry}\n onClick={() => {\n let event: AnalyticsEvent =\n \"unmapped_event\";\n if (entry.type === \"collection\")\n event =\n \"home_navigate_to_collection\";\n else if (entry.type === \"view\")\n event = \"home_navigate_to_view\";\n else if (entry.type === \"admin\")\n event =\n \"home_navigate_to_admin_view\";\n\n context.analyticsController?.onAnalyticsEvent?.(\n event,\n { path: entry.slug }\n );\n }}\n />\n ))}\n </div>\n </NavigationGroup>\n )}\n\n {sections && sections.map((section) => (\n <NavigationGroup\n key={section.key}\n group={section.title}\n >\n {section.children}\n </NavigationGroup>\n ))}\n\n {additionalPluginChildrenEnd}\n {additionalChildrenEnd}\n </Container>\n\n {dialogOpenForGroup && (\n <RenameGroupDialog\n open\n initialName={dialogOpenForGroup}\n existingGroupNames={items\n .map((g) => g.name)\n .filter((n) => n !== dialogOpenForGroup)}\n onClose={handleDialogClose}\n onRename={(newName) => {\n handleRenameGroup(dialogOpenForGroup, newName);\n }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,IAAa,qBAAqB;AAClC,IAAa,mBAAmB;AAEhC,SAAgB,gBAAgB,EAC5B,mBACA,yBACA,uBACA,UACA,gBAOD;CAEC,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,8BAA8B;CACtC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,WAAW,kBAAkB;CAEnC,MAAM,EAAE,kBAAkB;CAC1B,MAAM,yBAAyB,qBAAqB,2BAA2B,qBAAqB;CACpG,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAE,MAAM,eAAe;CAE7B,gBAAgB;EACZ,YAAY,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;CACvC,GAAG,C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AAqB,mBACzB,OACA,EAAE,MAAM,MAAM,KAAK,CACvB;OACJ;MACH,GAnBQ,MAAM,GAmBd,CACJ;KACA,CAAA;IACQ,CAAA;IAGpB,YAAY,SAAS,KAAK,YACvB,oBAAC,iBAAD;KAEI,OAAO,QAAQ;eAEd,QAAQ;IACI,GAJR,QAAQ,GAIA,CACpB;IAEA;IACA;GACM;MAEV,sBACG,oBAAC,mBAAD;GACI,MAAA;GACA,aAAa;GACb,oBAAoB,MACf,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,QAAQ,MAAM,MAAM,kBAAkB;GAC3C,SAAS;GACT,WAAW,YAAY;IACnB,kBAAkB,oBAAoB,OAAO;GACjD;EACH,CAAA,CAEJ;;AAEb"}
|
|
@@ -2,6 +2,7 @@ import { NavigationCardBinding } from "./NavigationCardBinding.js";
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { cls } from "@rebasepro/ui";
|
|
5
|
+
import { useComponentOverride } from "@rebasepro/app";
|
|
5
6
|
import { KeyboardSensor, MouseSensor, TouchSensor, closestCenter, closestCorners, getFirstCollision, pointerWithin, rectIntersection, useDndMonitor, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
6
7
|
import { SortableContext, arrayMove, defaultAnimateLayoutChanges, rectSortingStrategy, useSortable } from "@dnd-kit/sortable";
|
|
7
8
|
import { CSS } from "@dnd-kit/utilities";
|
|
@@ -56,6 +57,7 @@ function SortableNavigationCard({ entry, onClick }) {
|
|
|
56
57
|
id: entry.url,
|
|
57
58
|
animateLayoutChanges
|
|
58
59
|
});
|
|
60
|
+
const ResolvedCollectionCard = useComponentOverride("HomePage.CollectionCard", NavigationCardBinding);
|
|
59
61
|
return /* @__PURE__ */ jsx("div", {
|
|
60
62
|
ref: setNodeRef,
|
|
61
63
|
style: {
|
|
@@ -65,7 +67,7 @@ function SortableNavigationCard({ entry, onClick }) {
|
|
|
65
67
|
},
|
|
66
68
|
...draggableAttributes(attributes),
|
|
67
69
|
...listeners,
|
|
68
|
-
children: /* @__PURE__ */ jsx(
|
|
70
|
+
children: /* @__PURE__ */ jsx(ResolvedCollectionCard, {
|
|
69
71
|
...entry,
|
|
70
72
|
onClick
|
|
71
73
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomePageDnD.js","names":[],"sources":["../../../src/components/HomePage/HomePageDnD.tsx"],"sourcesContent":["import type { NavigationEntry } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n Active,\n DraggableAttributes,\n Over,\n closestCenter,\n closestCorners,\n CollisionDetection,\n DropAnimation,\n getFirstCollision,\n KeyboardSensor,\n MouseSensor,\n pointerWithin,\n rectIntersection,\n TouchSensor,\n UniqueIdentifier,\n useDndMonitor,\n useDroppable,\n useSensor,\n useSensors\n} from \"@dnd-kit/core\";\nimport {\n AnimateLayoutChanges,\n arrayMove,\n defaultAnimateLayoutChanges,\n rectSortingStrategy,\n SortableContext,\n useSortable\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\n\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\n;\nimport { cls } from \"@rebasepro/ui\";\n\nconst animateLayoutChanges: AnimateLayoutChanges = (args) =>\n defaultAnimateLayoutChanges({\n ...args,\n wasDragging: true\n });\n\nconst dropAnimationConfig: DropAnimation = {};\n\nconst cloneSerializableNavigationEntry = (entry: NavigationEntry): NavigationEntry => {\n const clonedEntry: Partial<NavigationEntry> = {\n id: entry.id,\n slug: entry.slug,\n url: entry.url,\n name: entry.name,\n type: entry.type,\n collection: entry.collection ? { ...entry.collection } : undefined,\n view: entry.view ? { ...entry.view } : undefined,\n ...(entry.group && { group: entry.group }),\n ...(entry.description && { description: entry.description })\n };\n return clonedEntry as NavigationEntry;\n};\n\nconst cloneItemsForDnd = (items: { name: string; entries: NavigationEntry[] }[]) =>\n items.map((g) => ({\n name: g.name,\n entries: g.entries.map(cloneSerializableNavigationEntry)\n }));\n\n/* ─────────────────────────────────────────────────────────── */\n/* Sortable card & group */\n\n/* ─────────────────────────────────────────────────────────── */\n\n/**\n * dnd-kit's `attributes`, minus the `role` it assumes.\n *\n * The wrapper these land on contains a `<Link>` and the card's own action\n * buttons, and dnd-kit's `role: \"button\"` therefore declared a button\n * containing a link containing more buttons. Measured on a scaffold's home\n * page: 17 focusables for 5 destinations, 13 of the 17 `[role=button]` nested\n * inside another — which is what a screen reader has to read through before it\n * reaches the collection you wanted.\n *\n * The rest is kept, and it is the part that carries meaning:\n * `aria-roledescription=\"sortable\"`, the instructions dnd-kit points\n * `aria-describedby` at, and the `tabIndex` its keyboard sensor needs — drag\n * still works from the keyboard.\n *\n * A dedicated drag handle is the better answer and the one dnd-kit documents;\n * it needs a control designed into the card, which is a visual change and not\n * this one.\n */\nfunction draggableAttributes(attributes: DraggableAttributes): Omit<DraggableAttributes, \"role\"> {\n const { role: _role, ...rest } = attributes;\n return rest;\n}\nexport function SortableNavigationCard({\n entry,\n onClick\n}: {\n entry: NavigationEntry;\n onClick?: () => void;\n}) {\n const {\n setNodeRef,\n listeners,\n attributes,\n transform,\n transition,\n isDragging\n } =\n useSortable({\n id: entry.url,\n animateLayoutChanges\n });\n\n const style = {\n transform: transform ? CSS.Transform.toString(transform) : undefined,\n transition,\n opacity: isDragging ? 0 : 1\n };\n\n return (\n <div ref={setNodeRef} style={style} {...draggableAttributes(attributes)} {...listeners}>\n <NavigationCardBinding {...entry} onClick={onClick}/>\n </div>\n );\n}\n\nexport function NavigationGroupDroppable({\n id,\n itemIds,\n children,\n isPotentialCardDropTarget = false\n}: {\n id: UniqueIdentifier;\n itemIds: UniqueIdentifier[];\n children: React.ReactNode;\n isPotentialCardDropTarget?: boolean;\n}) {\n const { setNodeRef } = useDroppable({ id });\n\n return (\n <div\n ref={setNodeRef}\n className={cls(\n isPotentialCardDropTarget\n ? \"p-2 bg-surface-raised rounded-lg\"\n : undefined,\n \"transition-all duration-200 ease-in-out\"\n )}\n >\n <SortableContext items={itemIds} strategy={rectSortingStrategy}>\n {children}\n </SortableContext>\n </div>\n );\n}\n\nexport function SortableNavigationGroup({\n groupName,\n children,\n disabled\n}: {\n groupName: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n transition,\n isDragging\n } =\n useSortable({\n id: groupName,\n animateLayoutChanges,\n disabled\n });\n\n const style = {\n transform: transform ? CSS.Transform.toString(transform) : undefined,\n transition,\n opacity: isDragging ? 0 : 1\n };\n\n return (\n <div ref={setNodeRef} style={style} {...draggableAttributes(attributes)} {...listeners}>\n {children}\n </div>\n );\n}\n\nexport function useHomePageDnd({\n items,\n setItems,\n disabled,\n onCardMovedBetweenGroups,\n onGroupMoved,\n onNewGroupDrop,\n onPersist\n}: {\n items: { name: string; entries: NavigationEntry[] }[];\n setItems: (\n newItemsOrUpdater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n currentItems: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => void;\n disabled: boolean;\n onCardMovedBetweenGroups?: (card: NavigationEntry) => void;\n onGroupMoved?: (groupName: string, oldIndex: number, newIndex: number) => void;\n onNewGroupDrop?: () => void;\n onPersist?: (latest: { name: string; entries: NavigationEntry[] }[]) => void;\n}) {\n /* ---------------- local state ---------------- */\n const dndItems = items;\n const setDndItems = setItems;\n\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const [activeIsGroup, setActiveIsGroup] = useState(false);\n const [currentDraggingGroupId, setCurrentDraggingGroupId] =\n useState<UniqueIdentifier | null>(null);\n const [dndKitActiveNode, setDndKitActiveNode] = useState<Active | null>(null);\n const [isDraggingCardOnly, setIsDraggingCardOnly] = useState(false);\n const [dialogOpenForGroup, setDialogOpenForGroup] = useState<string | null>(null);\n const [isHoveringNewGroupDropZone, setIsHoveringNewGroupDropZone] =\n useState(false);\n const [pendingNewGroupName, setPendingNewGroupName] = useState<string | null>(null);\n const [stateBeforeNewGroup, setStateBeforeNewGroup] = useState<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n\n /* store the original state before any drag modifications */\n const preDragItemsRef = useRef<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n\n /* store interim state for cross-group moves */\n const interimItemsRef = useRef<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n useEffect(() => {\n interimItemsRef.current = dndItems;\n }, [dndItems]);\n\n /* ---------------- sensors ---------------- */\n const mouseSensor = useSensor(MouseSensor, { activationConstraint: { distance: 10 } });\n const touchSensor = useSensor(TouchSensor, {\n activationConstraint: {\n delay: 150,\n tolerance: 5\n }\n });\n const keyboardSensor = useSensor(KeyboardSensor);\n const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);\n\n /* ---------------- helpers ---------------- */\n const dndContainers = dndItems.map((g) => g.name);\n\n const findDndContainer = useCallback(\n (id: UniqueIdentifier): string | undefined => {\n if (!id) return undefined;\n const group = dndItems.find((g) => g.name === id);\n if (group) return group.name;\n for (const g of dndItems) {\n if (g.entries.some((e) => e.url === id)) return g.name;\n }\n return undefined;\n },\n [dndItems]\n );\n\n /* ---------------- collision detection ---------------- */\n const lastOverId = useRef<UniqueIdentifier | null>(null);\n const recentlyMovedToNewContainer = useRef(false);\n\n const collisionDetection: CollisionDetection = useCallback(\n (args) => {\n if (disabled || !activeId) return [];\n if (activeIsGroup) {\n const groups = args.droppableContainers.filter((c) =>\n dndItems.some((g) => g.name === c.id)\n );\n if (!groups.length) return [];\n return closestCenter({\n ...args,\n droppableContainers: groups\n });\n }\n\n const pointer = pointerWithin(args);\n if (pointer.length) {\n const zone = pointer.find((c) => c.id === \"new-group-drop-zone\");\n if (zone) return [zone];\n\n const container = pointer.find((c) =>\n dndItems.some((g) => g.name === c.id)\n );\n if (container) {\n const itemsIn = dndItems.find((g) => g.name === container.id)\n ?.entries;\n if (itemsIn?.length) {\n const closest = closestCorners({\n ...args,\n droppableContainers: args.droppableContainers.filter(\n (c) => itemsIn.some((e) => e.url === c.id)\n )\n });\n if (closest.length) return closest;\n }\n return [container];\n }\n const first = getFirstCollision(pointer, \"id\");\n if (first) return [{ id: first }];\n }\n\n const rects = rectIntersection(args);\n const zoneRect = rects.find((c) => c.id === \"new-group-drop-zone\");\n if (zoneRect) return [zoneRect];\n\n let overId = getFirstCollision(rects, \"id\");\n if (overId != null) {\n const overIsContainer = dndItems.some((g) => g.name === overId);\n if (overIsContainer) {\n const itemsIn = dndItems.find((g) => g.name === overId)\n ?.entries;\n if (itemsIn?.length) {\n const closestItem = closestCorners({\n ...args,\n droppableContainers: args.droppableContainers.filter(\n (c) => itemsIn.some((e) => e.url === c.id)\n )\n })[0]?.id;\n if (closestItem) overId = closestItem;\n }\n }\n lastOverId.current = overId;\n return [{ id: overId }];\n }\n\n if (\n recentlyMovedToNewContainer.current &&\n lastOverId.current &&\n !activeIsGroup\n )\n return [{ id: lastOverId.current }];\n\n return [];\n },\n [activeId, dndItems, disabled, activeIsGroup]\n );\n\n /* ---------------- drag handlers ---------------- */\n const handleDragStart = ({ active }: { active: Active }) => {\n setDndKitActiveNode(active);\n if (disabled) return;\n\n // Capture the original state before any drag modifications\n preDragItemsRef.current = cloneItemsForDnd(dndItems);\n\n const isGroup = dndItems.some((g) => g.name === active.id);\n if (!active.data.current) active.data.current = {};\n active.data.current.type = isGroup ? \"group\" : \"item\";\n\n setActiveId(active.id);\n setActiveIsGroup(isGroup);\n setIsDraggingCardOnly(!isGroup);\n if (isGroup) setCurrentDraggingGroupId(active.id);\n recentlyMovedToNewContainer.current = false;\n };\n\n const handleDragOver = ({\n active,\n over\n }: { active: Active; over: Over | null }) => {\n if (disabled || !over) return;\n\n const activeIdNow = active.id;\n const overIdNow = over.id;\n if (activeIdNow === overIdNow) return;\n if (activeIsGroup) return;\n\n const activeCont = findDndContainer(activeIdNow);\n const overCont = findDndContainer(overIdNow);\n if (!activeCont) return;\n\n if (overCont && activeCont !== overCont) {\n recentlyMovedToNewContainer.current = true;\n lastOverId.current = overIdNow;\n\n // Update state for visual feedback during drag\n setDndItems((current) => {\n const newState = cloneItemsForDnd(current);\n const srcIdx = newState.findIndex((g) => g.name === activeCont);\n const tgtIdx = newState.findIndex((g) => g.name === overCont);\n if (srcIdx === -1 || tgtIdx === -1) return current;\n const src = newState[srcIdx];\n const tgt = newState[tgtIdx];\n const idxInSrc = src.entries.findIndex((e) => e.url === activeIdNow);\n if (idxInSrc === -1) return current;\n const [moved] = src.entries.splice(idxInSrc, 1);\n\n // Calculate insertion position - SAME logic as handleDragEnd\n const overIsContainer = overIdNow === overCont;\n if (overIsContainer) {\n tgt.entries.push(moved);\n } else {\n const overIdx = tgt.entries.findIndex((e) => e.url === overIdNow);\n if (overIdx !== -1) {\n tgt.entries.splice(overIdx, 0, moved);\n } else {\n tgt.entries.push(moved);\n }\n }\n\n return newState;\n });\n } else if (activeCont === overCont) {\n recentlyMovedToNewContainer.current = false;\n }\n };\n\n const handleDragEnd = ({\n active,\n over\n }: { active: Active; over: Over | null }) => {\n if (disabled || !over) {\n resetDragState();\n return;\n }\n\n const activeIdNow = active.id;\n const overIdNow = over.id;\n\n /* ─── group reorder ─── */\n if (activeIsGroup) {\n if (\n activeIdNow !== overIdNow &&\n dndItems.some((g) => g.name === overIdNow)\n ) {\n const from = dndItems.findIndex((g) => g.name === activeIdNow);\n const to = dndItems.findIndex((g) => g.name === overIdNow);\n if (from !== -1 && to !== -1) {\n const newState = arrayMove(dndItems, from, to);\n setDndItems(newState);\n onPersist?.(newState);\n onGroupMoved?.(activeIdNow as string, from, to);\n }\n }\n }\n /* ─── card move ─── */\n else {\n // CRITICAL: Find source container from ORIGINAL pre-drag state, not current (potentially stale) dndItems\n const findContainerInState = (id: string, state: { name: string; entries: NavigationEntry[] }[]): string | undefined => {\n const group = state.find((g) => g.name === id);\n if (group) return group.name;\n for (const g of state) {\n if (g.entries.some((e) => e.url === id)) return g.name;\n }\n return undefined;\n };\n\n const sourceState = preDragItemsRef.current || dndItems;\n const activeCont = findContainerInState(activeIdNow as string, sourceState);\n const overCont = findDndContainer(overIdNow);\n\n /* drop on new-group zone */\n if (overIdNow === \"new-group-drop-zone\") {\n if (activeCont) {\n // Save current state before making changes\n setStateBeforeNewGroup(cloneItemsForDnd(dndItems));\n\n const newState = cloneItemsForDnd(dndItems);\n const srcIdx = newState.findIndex((g) => g.name === activeCont);\n if (srcIdx !== -1) {\n const src = newState[srcIdx];\n const idxInSrc = src.entries.findIndex(\n (e) => e.url === activeIdNow\n );\n if (idxInSrc !== -1) {\n const [dragged] = src.entries.splice(idxInSrc, 1);\n if (src.entries.length === 0) newState.splice(srcIdx, 1);\n\n let tentative = \"New Group\";\n let counter = 1;\n while (newState.some((g) => g.name === tentative))\n tentative = `New Group ${counter++}`;\n\n newState.push({\n name: tentative,\n entries: [dragged]\n });\n\n // Update local state but DON'T persist yet\n setDndItems(newState);\n setPendingNewGroupName(tentative);\n setDialogOpenForGroup(tentative);\n onNewGroupDrop?.();\n }\n }\n }\n }\n /* reorder inside same container */\n else {\n const overCont = findDndContainer(overIdNow);\n if (activeCont === overCont) {\n const grpIdx = dndItems.findIndex((g) => g.name === activeCont);\n if (grpIdx !== -1) {\n const group = dndItems[grpIdx];\n const oldIdx = group.entries.findIndex(\n (e) => e.url === activeIdNow\n );\n let newIdx = group.entries.findIndex(\n (e) => e.url === overIdNow\n );\n if (newIdx === -1 && overIdNow === activeCont)\n newIdx = group.entries.length - 1;\n if (\n oldIdx !== -1 &&\n newIdx !== -1 &&\n oldIdx !== newIdx\n ) {\n const reordered = arrayMove(group.entries, oldIdx, newIdx);\n const newState = [...dndItems];\n newState[grpIdx] = {\n ...group,\n entries: reordered\n };\n setDndItems(newState);\n onPersist?.(newState);\n }\n }\n } else if (overCont && activeCont !== overCont) {\n // Card moved between different groups - use CLEAN pre-drag state\n const finalState = cloneItemsForDnd(sourceState);\n\n // Find target container from clean state too\n const finalOverId = lastOverId.current || overIdNow;\n const cleanOverCont = findContainerInState(finalOverId as string, sourceState) || overCont;\n\n const srcIdx = finalState.findIndex((g) => g.name === activeCont);\n const tgtIdx = finalState.findIndex((g) => g.name === cleanOverCont);\n\n if (srcIdx !== -1 && tgtIdx !== -1) {\n const src = finalState[srcIdx];\n const tgt = finalState[tgtIdx];\n const idxInSrc = src.entries.findIndex((e) => e.url === activeIdNow);\n\n if (idxInSrc !== -1) {\n // Remove from source\n const [moved] = src.entries.splice(idxInSrc, 1);\n\n // Calculate insertion position in target\n const overIsContainer = finalOverId === cleanOverCont;\n if (overIsContainer) {\n tgt.entries.push(moved);\n } else {\n const overIdx = tgt.entries.findIndex((e) => e.url === finalOverId);\n if (overIdx !== -1) {\n tgt.entries.splice(overIdx, 0, moved);\n } else {\n tgt.entries.push(moved);\n }\n }\n\n // Remove empty source group if needed\n if (src.entries.length === 0) {\n finalState.splice(srcIdx, 1);\n }\n\n setDndItems(finalState);\n onPersist?.(finalState);\n\n onCardMovedBetweenGroups?.(moved);\n }\n }\n } else if (recentlyMovedToNewContainer.current) {\n // This shouldn't happen but log it for debugging\n console.error(\"Move between containers detected but conditions not met\", {\n activeCont,\n overCont,\n activeIdNow,\n overIdNow\n });\n }\n }\n }\n\n resetDragState();\n };\n\n const resetDragState = () => {\n setDndKitActiveNode(null);\n setActiveId(null);\n setActiveIsGroup(false);\n setCurrentDraggingGroupId(null);\n setIsDraggingCardOnly(false);\n recentlyMovedToNewContainer.current = false;\n };\n\n const handleDragCancel = () => resetDragState();\n\n /* ---------------- group rename ---------------- */\n const handleRenameGroup = (oldName: string, newName: string) => {\n setDndItems((current) => {\n const idx = current.findIndex((g) => g.name === oldName);\n if (idx === -1) return current;\n if (current.some((g) => g.name === newName && g.name !== oldName))\n return current;\n\n const updated = [...current];\n updated[idx] = {\n ...updated[idx],\n name: newName\n };\n\n // Persist after successful rename\n onPersist?.(updated);\n return updated;\n });\n\n // Clear all pending state\n setPendingNewGroupName(null);\n setStateBeforeNewGroup(null);\n setDialogOpenForGroup(null);\n };\n\n /* Handle dialog close without renaming */\n const handleDialogClose = () => {\n // If there's a pending new group that wasn't renamed, restore previous state\n if (pendingNewGroupName && dialogOpenForGroup === pendingNewGroupName && stateBeforeNewGroup) {\n // Restore the state from before the new group was created\n setDndItems(stateBeforeNewGroup);\n }\n\n // Clear all pending state\n setPendingNewGroupName(null);\n setStateBeforeNewGroup(null);\n setDialogOpenForGroup(null);\n };\n\n /* ---------------- public API ---------------- */\n const activeItemForOverlay =\n disabled || !activeId || activeIsGroup\n ? null\n : dndItems.flatMap((g) => g.entries).find((e) => e.url === activeId) || null;\n\n const activeGroupData =\n disabled || !activeId || !activeIsGroup\n ? null\n : dndItems.find((g) => g.name === activeId) || null;\n\n return {\n sensors,\n collisionDetection,\n onDragStart: handleDragStart,\n onDragOver: handleDragOver,\n onDragEnd: handleDragEnd,\n onDragCancel: handleDragCancel,\n dropAnimation: dropAnimationConfig,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId: currentDraggingGroupId,\n containers: dndContainers,\n dndKitActiveNode,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n };\n}\n\nexport function NewGroupDropZone({\n disabled,\n setIsHovering\n}: {\n disabled: boolean;\n setIsHovering: (v: boolean) => void;\n}) {\n const {\n setNodeRef,\n isOver\n } = useDroppable({\n id: \"new-group-drop-zone\",\n disabled\n });\n const [isVisible, setIsVisible] = useState(false);\n\n useDndMonitor({\n onDragStart({ active }) {\n if (disabled) return;\n const tp = active.data.current?.type;\n setIsVisible(tp === \"item\");\n },\n onDragEnd() {\n setIsVisible(false);\n },\n onDragCancel() {\n setIsVisible(false);\n }\n });\n\n useEffect(() => {\n setIsHovering(isOver && isVisible);\n }, [isOver, isVisible, setIsHovering]);\n\n if (!isVisible || disabled) return null;\n\n return (\n <div\n ref={setNodeRef}\n className={cls(\n \"fixed right-8 top-1/2 -translate-y-1/2 w-[200px] h-[120px] border border-dashed rounded-lg flex items-center justify-center transition-all\",\n isOver\n ? \"bg-surface-raised border-hairline-strong\"\n : \"bg-surface-card border-hairline-strong\"\n )}>\n <div className=\"text-center p-4\">\n <span className=\"block font-medium text-sm\">\n Drop here to create a new group\n </span>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAoCA,IAAM,wBAA8C,SAChD,4BAA4B;CACxB,GAAG;CACH,aAAa;AACjB,CAAC;AAEL,IAAM,sBAAqC,CAAC;AAE5C,IAAM,oCAAoC,UAA4C;CAYlF,OAAO;EAVH,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,YAAY,MAAM,aAAa,EAAE,GAAG,MAAM,WAAW,IAAI,KAAA;EACzD,MAAM,MAAM,OAAO,EAAE,GAAG,MAAM,KAAK,IAAI,KAAA;EACvC,GAAI,MAAM,SAAS,EAAE,OAAO,MAAM,MAAM;EACxC,GAAI,MAAM,eAAe,EAAE,aAAa,MAAM,YAAY;CAEvD;AACX;AAEA,IAAM,oBAAoB,UACtB,MAAM,KAAK,OAAO;CACd,MAAM,EAAE;CACR,SAAS,EAAE,QAAQ,IAAI,gCAAgC;AAC3D,EAAE;;;;;;;;;;;;;;;;;;;;AA0BN,SAAS,oBAAoB,YAAoE;CAC7F,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS;CACjC,OAAO;AACX;AACA,SAAgB,uBAAuB,EACnC,OACA,WAID;CACC,MAAM,EACF,YACA,WACA,YACA,WACA,YACA,eAEA,YAAY;EACR,IAAI,MAAM;EACV;CACJ,CAAC;CAQL,OACI,oBAAC,OAAD;EAAK,KAAK;EAAmB,OAAA;GAN7B,WAAW,YAAY,IAAI,UAAU,SAAS,SAAS,IAAI,KAAA;GAC3D;GACA,SAAS,aAAa,IAAI;EAIG;EAAO,GAAI,oBAAoB,UAAU;EAAG,GAAI;YACzE,oBAAC,uBAAD;GAA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ePageDnD.js","names":[],"sources":["../../../src/components/HomePage/HomePageDnD.tsx"],"sourcesContent":["import type { NavigationEntry } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n Active,\n DraggableAttributes,\n Over,\n closestCenter,\n closestCorners,\n CollisionDetection,\n DropAnimation,\n getFirstCollision,\n KeyboardSensor,\n MouseSensor,\n pointerWithin,\n rectIntersection,\n TouchSensor,\n UniqueIdentifier,\n useDndMonitor,\n useDroppable,\n useSensor,\n useSensors\n} from \"@dnd-kit/core\";\nimport {\n AnimateLayoutChanges,\n arrayMove,\n defaultAnimateLayoutChanges,\n rectSortingStrategy,\n SortableContext,\n useSortable\n} from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\n\nimport { NavigationCardBinding } from \"./NavigationCardBinding\";\nimport { useComponentOverride } from \"@rebasepro/app\";\n;\nimport { cls } from \"@rebasepro/ui\";\n\nconst animateLayoutChanges: AnimateLayoutChanges = (args) =>\n defaultAnimateLayoutChanges({\n ...args,\n wasDragging: true\n });\n\nconst dropAnimationConfig: DropAnimation = {};\n\nconst cloneSerializableNavigationEntry = (entry: NavigationEntry): NavigationEntry => {\n const clonedEntry: Partial<NavigationEntry> = {\n id: entry.id,\n slug: entry.slug,\n url: entry.url,\n name: entry.name,\n type: entry.type,\n collection: entry.collection ? { ...entry.collection } : undefined,\n view: entry.view ? { ...entry.view } : undefined,\n ...(entry.group && { group: entry.group }),\n ...(entry.description && { description: entry.description })\n };\n return clonedEntry as NavigationEntry;\n};\n\nconst cloneItemsForDnd = (items: { name: string; entries: NavigationEntry[] }[]) =>\n items.map((g) => ({\n name: g.name,\n entries: g.entries.map(cloneSerializableNavigationEntry)\n }));\n\n/* ─────────────────────────────────────────────────────────── */\n/* Sortable card & group */\n\n/* ─────────────────────────────────────────────────────────── */\n\n/**\n * dnd-kit's `attributes`, minus the `role` it assumes.\n *\n * The wrapper these land on contains a `<Link>` and the card's own action\n * buttons, and dnd-kit's `role: \"button\"` therefore declared a button\n * containing a link containing more buttons. Measured on a scaffold's home\n * page: 17 focusables for 5 destinations, 13 of the 17 `[role=button]` nested\n * inside another — which is what a screen reader has to read through before it\n * reaches the collection you wanted.\n *\n * The rest is kept, and it is the part that carries meaning:\n * `aria-roledescription=\"sortable\"`, the instructions dnd-kit points\n * `aria-describedby` at, and the `tabIndex` its keyboard sensor needs — drag\n * still works from the keyboard.\n *\n * A dedicated drag handle is the better answer and the one dnd-kit documents;\n * it needs a control designed into the card, which is a visual change and not\n * this one.\n */\nfunction draggableAttributes(attributes: DraggableAttributes): Omit<DraggableAttributes, \"role\"> {\n const { role: _role, ...rest } = attributes;\n return rest;\n}\nexport function SortableNavigationCard({\n entry,\n onClick\n}: {\n entry: NavigationEntry;\n onClick?: () => void;\n}) {\n const {\n setNodeRef,\n listeners,\n attributes,\n transform,\n transition,\n isDragging\n } =\n useSortable({\n id: entry.url,\n animateLayoutChanges\n });\n\n const ResolvedCollectionCard = useComponentOverride(\"HomePage.CollectionCard\", NavigationCardBinding);\n\n const style = {\n transform: transform ? CSS.Transform.toString(transform) : undefined,\n transition,\n opacity: isDragging ? 0 : 1\n };\n\n return (\n <div ref={setNodeRef} style={style} {...draggableAttributes(attributes)} {...listeners}>\n <ResolvedCollectionCard {...entry} onClick={onClick}/>\n </div>\n );\n}\n\nexport function NavigationGroupDroppable({\n id,\n itemIds,\n children,\n isPotentialCardDropTarget = false\n}: {\n id: UniqueIdentifier;\n itemIds: UniqueIdentifier[];\n children: React.ReactNode;\n isPotentialCardDropTarget?: boolean;\n}) {\n const { setNodeRef } = useDroppable({ id });\n\n return (\n <div\n ref={setNodeRef}\n className={cls(\n isPotentialCardDropTarget\n ? \"p-2 bg-surface-raised rounded-lg\"\n : undefined,\n \"transition-all duration-200 ease-in-out\"\n )}\n >\n <SortableContext items={itemIds} strategy={rectSortingStrategy}>\n {children}\n </SortableContext>\n </div>\n );\n}\n\nexport function SortableNavigationGroup({\n groupName,\n children,\n disabled\n}: {\n groupName: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n const {\n attributes,\n listeners,\n setNodeRef,\n transform,\n transition,\n isDragging\n } =\n useSortable({\n id: groupName,\n animateLayoutChanges,\n disabled\n });\n\n const style = {\n transform: transform ? CSS.Transform.toString(transform) : undefined,\n transition,\n opacity: isDragging ? 0 : 1\n };\n\n return (\n <div ref={setNodeRef} style={style} {...draggableAttributes(attributes)} {...listeners}>\n {children}\n </div>\n );\n}\n\nexport function useHomePageDnd({\n items,\n setItems,\n disabled,\n onCardMovedBetweenGroups,\n onGroupMoved,\n onNewGroupDrop,\n onPersist\n}: {\n items: { name: string; entries: NavigationEntry[] }[];\n setItems: (\n newItemsOrUpdater:\n | { name: string; entries: NavigationEntry[] }[]\n | ((\n currentItems: { name: string; entries: NavigationEntry[] }[]\n ) => { name: string; entries: NavigationEntry[] }[])\n ) => void;\n disabled: boolean;\n onCardMovedBetweenGroups?: (card: NavigationEntry) => void;\n onGroupMoved?: (groupName: string, oldIndex: number, newIndex: number) => void;\n onNewGroupDrop?: () => void;\n onPersist?: (latest: { name: string; entries: NavigationEntry[] }[]) => void;\n}) {\n /* ---------------- local state ---------------- */\n const dndItems = items;\n const setDndItems = setItems;\n\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const [activeIsGroup, setActiveIsGroup] = useState(false);\n const [currentDraggingGroupId, setCurrentDraggingGroupId] =\n useState<UniqueIdentifier | null>(null);\n const [dndKitActiveNode, setDndKitActiveNode] = useState<Active | null>(null);\n const [isDraggingCardOnly, setIsDraggingCardOnly] = useState(false);\n const [dialogOpenForGroup, setDialogOpenForGroup] = useState<string | null>(null);\n const [isHoveringNewGroupDropZone, setIsHoveringNewGroupDropZone] =\n useState(false);\n const [pendingNewGroupName, setPendingNewGroupName] = useState<string | null>(null);\n const [stateBeforeNewGroup, setStateBeforeNewGroup] = useState<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n\n /* store the original state before any drag modifications */\n const preDragItemsRef = useRef<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n\n /* store interim state for cross-group moves */\n const interimItemsRef = useRef<\n { name: string; entries: NavigationEntry[] }[] | null\n >(null);\n useEffect(() => {\n interimItemsRef.current = dndItems;\n }, [dndItems]);\n\n /* ---------------- sensors ---------------- */\n const mouseSensor = useSensor(MouseSensor, { activationConstraint: { distance: 10 } });\n const touchSensor = useSensor(TouchSensor, {\n activationConstraint: {\n delay: 150,\n tolerance: 5\n }\n });\n const keyboardSensor = useSensor(KeyboardSensor);\n const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor);\n\n /* ---------------- helpers ---------------- */\n const dndContainers = dndItems.map((g) => g.name);\n\n const findDndContainer = useCallback(\n (id: UniqueIdentifier): string | undefined => {\n if (!id) return undefined;\n const group = dndItems.find((g) => g.name === id);\n if (group) return group.name;\n for (const g of dndItems) {\n if (g.entries.some((e) => e.url === id)) return g.name;\n }\n return undefined;\n },\n [dndItems]\n );\n\n /* ---------------- collision detection ---------------- */\n const lastOverId = useRef<UniqueIdentifier | null>(null);\n const recentlyMovedToNewContainer = useRef(false);\n\n const collisionDetection: CollisionDetection = useCallback(\n (args) => {\n if (disabled || !activeId) return [];\n if (activeIsGroup) {\n const groups = args.droppableContainers.filter((c) =>\n dndItems.some((g) => g.name === c.id)\n );\n if (!groups.length) return [];\n return closestCenter({\n ...args,\n droppableContainers: groups\n });\n }\n\n const pointer = pointerWithin(args);\n if (pointer.length) {\n const zone = pointer.find((c) => c.id === \"new-group-drop-zone\");\n if (zone) return [zone];\n\n const container = pointer.find((c) =>\n dndItems.some((g) => g.name === c.id)\n );\n if (container) {\n const itemsIn = dndItems.find((g) => g.name === container.id)\n ?.entries;\n if (itemsIn?.length) {\n const closest = closestCorners({\n ...args,\n droppableContainers: args.droppableContainers.filter(\n (c) => itemsIn.some((e) => e.url === c.id)\n )\n });\n if (closest.length) return closest;\n }\n return [container];\n }\n const first = getFirstCollision(pointer, \"id\");\n if (first) return [{ id: first }];\n }\n\n const rects = rectIntersection(args);\n const zoneRect = rects.find((c) => c.id === \"new-group-drop-zone\");\n if (zoneRect) return [zoneRect];\n\n let overId = getFirstCollision(rects, \"id\");\n if (overId != null) {\n const overIsContainer = dndItems.some((g) => g.name === overId);\n if (overIsContainer) {\n const itemsIn = dndItems.find((g) => g.name === overId)\n ?.entries;\n if (itemsIn?.length) {\n const closestItem = closestCorners({\n ...args,\n droppableContainers: args.droppableContainers.filter(\n (c) => itemsIn.some((e) => e.url === c.id)\n )\n })[0]?.id;\n if (closestItem) overId = closestItem;\n }\n }\n lastOverId.current = overId;\n return [{ id: overId }];\n }\n\n if (\n recentlyMovedToNewContainer.current &&\n lastOverId.current &&\n !activeIsGroup\n )\n return [{ id: lastOverId.current }];\n\n return [];\n },\n [activeId, dndItems, disabled, activeIsGroup]\n );\n\n /* ---------------- drag handlers ---------------- */\n const handleDragStart = ({ active }: { active: Active }) => {\n setDndKitActiveNode(active);\n if (disabled) return;\n\n // Capture the original state before any drag modifications\n preDragItemsRef.current = cloneItemsForDnd(dndItems);\n\n const isGroup = dndItems.some((g) => g.name === active.id);\n if (!active.data.current) active.data.current = {};\n active.data.current.type = isGroup ? \"group\" : \"item\";\n\n setActiveId(active.id);\n setActiveIsGroup(isGroup);\n setIsDraggingCardOnly(!isGroup);\n if (isGroup) setCurrentDraggingGroupId(active.id);\n recentlyMovedToNewContainer.current = false;\n };\n\n const handleDragOver = ({\n active,\n over\n }: { active: Active; over: Over | null }) => {\n if (disabled || !over) return;\n\n const activeIdNow = active.id;\n const overIdNow = over.id;\n if (activeIdNow === overIdNow) return;\n if (activeIsGroup) return;\n\n const activeCont = findDndContainer(activeIdNow);\n const overCont = findDndContainer(overIdNow);\n if (!activeCont) return;\n\n if (overCont && activeCont !== overCont) {\n recentlyMovedToNewContainer.current = true;\n lastOverId.current = overIdNow;\n\n // Update state for visual feedback during drag\n setDndItems((current) => {\n const newState = cloneItemsForDnd(current);\n const srcIdx = newState.findIndex((g) => g.name === activeCont);\n const tgtIdx = newState.findIndex((g) => g.name === overCont);\n if (srcIdx === -1 || tgtIdx === -1) return current;\n const src = newState[srcIdx];\n const tgt = newState[tgtIdx];\n const idxInSrc = src.entries.findIndex((e) => e.url === activeIdNow);\n if (idxInSrc === -1) return current;\n const [moved] = src.entries.splice(idxInSrc, 1);\n\n // Calculate insertion position - SAME logic as handleDragEnd\n const overIsContainer = overIdNow === overCont;\n if (overIsContainer) {\n tgt.entries.push(moved);\n } else {\n const overIdx = tgt.entries.findIndex((e) => e.url === overIdNow);\n if (overIdx !== -1) {\n tgt.entries.splice(overIdx, 0, moved);\n } else {\n tgt.entries.push(moved);\n }\n }\n\n return newState;\n });\n } else if (activeCont === overCont) {\n recentlyMovedToNewContainer.current = false;\n }\n };\n\n const handleDragEnd = ({\n active,\n over\n }: { active: Active; over: Over | null }) => {\n if (disabled || !over) {\n resetDragState();\n return;\n }\n\n const activeIdNow = active.id;\n const overIdNow = over.id;\n\n /* ─── group reorder ─── */\n if (activeIsGroup) {\n if (\n activeIdNow !== overIdNow &&\n dndItems.some((g) => g.name === overIdNow)\n ) {\n const from = dndItems.findIndex((g) => g.name === activeIdNow);\n const to = dndItems.findIndex((g) => g.name === overIdNow);\n if (from !== -1 && to !== -1) {\n const newState = arrayMove(dndItems, from, to);\n setDndItems(newState);\n onPersist?.(newState);\n onGroupMoved?.(activeIdNow as string, from, to);\n }\n }\n }\n /* ─── card move ─── */\n else {\n // CRITICAL: Find source container from ORIGINAL pre-drag state, not current (potentially stale) dndItems\n const findContainerInState = (id: string, state: { name: string; entries: NavigationEntry[] }[]): string | undefined => {\n const group = state.find((g) => g.name === id);\n if (group) return group.name;\n for (const g of state) {\n if (g.entries.some((e) => e.url === id)) return g.name;\n }\n return undefined;\n };\n\n const sourceState = preDragItemsRef.current || dndItems;\n const activeCont = findContainerInState(activeIdNow as string, sourceState);\n const overCont = findDndContainer(overIdNow);\n\n /* drop on new-group zone */\n if (overIdNow === \"new-group-drop-zone\") {\n if (activeCont) {\n // Save current state before making changes\n setStateBeforeNewGroup(cloneItemsForDnd(dndItems));\n\n const newState = cloneItemsForDnd(dndItems);\n const srcIdx = newState.findIndex((g) => g.name === activeCont);\n if (srcIdx !== -1) {\n const src = newState[srcIdx];\n const idxInSrc = src.entries.findIndex(\n (e) => e.url === activeIdNow\n );\n if (idxInSrc !== -1) {\n const [dragged] = src.entries.splice(idxInSrc, 1);\n if (src.entries.length === 0) newState.splice(srcIdx, 1);\n\n let tentative = \"New Group\";\n let counter = 1;\n while (newState.some((g) => g.name === tentative))\n tentative = `New Group ${counter++}`;\n\n newState.push({\n name: tentative,\n entries: [dragged]\n });\n\n // Update local state but DON'T persist yet\n setDndItems(newState);\n setPendingNewGroupName(tentative);\n setDialogOpenForGroup(tentative);\n onNewGroupDrop?.();\n }\n }\n }\n }\n /* reorder inside same container */\n else {\n const overCont = findDndContainer(overIdNow);\n if (activeCont === overCont) {\n const grpIdx = dndItems.findIndex((g) => g.name === activeCont);\n if (grpIdx !== -1) {\n const group = dndItems[grpIdx];\n const oldIdx = group.entries.findIndex(\n (e) => e.url === activeIdNow\n );\n let newIdx = group.entries.findIndex(\n (e) => e.url === overIdNow\n );\n if (newIdx === -1 && overIdNow === activeCont)\n newIdx = group.entries.length - 1;\n if (\n oldIdx !== -1 &&\n newIdx !== -1 &&\n oldIdx !== newIdx\n ) {\n const reordered = arrayMove(group.entries, oldIdx, newIdx);\n const newState = [...dndItems];\n newState[grpIdx] = {\n ...group,\n entries: reordered\n };\n setDndItems(newState);\n onPersist?.(newState);\n }\n }\n } else if (overCont && activeCont !== overCont) {\n // Card moved between different groups - use CLEAN pre-drag state\n const finalState = cloneItemsForDnd(sourceState);\n\n // Find target container from clean state too\n const finalOverId = lastOverId.current || overIdNow;\n const cleanOverCont = findContainerInState(finalOverId as string, sourceState) || overCont;\n\n const srcIdx = finalState.findIndex((g) => g.name === activeCont);\n const tgtIdx = finalState.findIndex((g) => g.name === cleanOverCont);\n\n if (srcIdx !== -1 && tgtIdx !== -1) {\n const src = finalState[srcIdx];\n const tgt = finalState[tgtIdx];\n const idxInSrc = src.entries.findIndex((e) => e.url === activeIdNow);\n\n if (idxInSrc !== -1) {\n // Remove from source\n const [moved] = src.entries.splice(idxInSrc, 1);\n\n // Calculate insertion position in target\n const overIsContainer = finalOverId === cleanOverCont;\n if (overIsContainer) {\n tgt.entries.push(moved);\n } else {\n const overIdx = tgt.entries.findIndex((e) => e.url === finalOverId);\n if (overIdx !== -1) {\n tgt.entries.splice(overIdx, 0, moved);\n } else {\n tgt.entries.push(moved);\n }\n }\n\n // Remove empty source group if needed\n if (src.entries.length === 0) {\n finalState.splice(srcIdx, 1);\n }\n\n setDndItems(finalState);\n onPersist?.(finalState);\n\n onCardMovedBetweenGroups?.(moved);\n }\n }\n } else if (recentlyMovedToNewContainer.current) {\n // This shouldn't happen but log it for debugging\n console.error(\"Move between containers detected but conditions not met\", {\n activeCont,\n overCont,\n activeIdNow,\n overIdNow\n });\n }\n }\n }\n\n resetDragState();\n };\n\n const resetDragState = () => {\n setDndKitActiveNode(null);\n setActiveId(null);\n setActiveIsGroup(false);\n setCurrentDraggingGroupId(null);\n setIsDraggingCardOnly(false);\n recentlyMovedToNewContainer.current = false;\n };\n\n const handleDragCancel = () => resetDragState();\n\n /* ---------------- group rename ---------------- */\n const handleRenameGroup = (oldName: string, newName: string) => {\n setDndItems((current) => {\n const idx = current.findIndex((g) => g.name === oldName);\n if (idx === -1) return current;\n if (current.some((g) => g.name === newName && g.name !== oldName))\n return current;\n\n const updated = [...current];\n updated[idx] = {\n ...updated[idx],\n name: newName\n };\n\n // Persist after successful rename\n onPersist?.(updated);\n return updated;\n });\n\n // Clear all pending state\n setPendingNewGroupName(null);\n setStateBeforeNewGroup(null);\n setDialogOpenForGroup(null);\n };\n\n /* Handle dialog close without renaming */\n const handleDialogClose = () => {\n // If there's a pending new group that wasn't renamed, restore previous state\n if (pendingNewGroupName && dialogOpenForGroup === pendingNewGroupName && stateBeforeNewGroup) {\n // Restore the state from before the new group was created\n setDndItems(stateBeforeNewGroup);\n }\n\n // Clear all pending state\n setPendingNewGroupName(null);\n setStateBeforeNewGroup(null);\n setDialogOpenForGroup(null);\n };\n\n /* ---------------- public API ---------------- */\n const activeItemForOverlay =\n disabled || !activeId || activeIsGroup\n ? null\n : dndItems.flatMap((g) => g.entries).find((e) => e.url === activeId) || null;\n\n const activeGroupData =\n disabled || !activeId || !activeIsGroup\n ? null\n : dndItems.find((g) => g.name === activeId) || null;\n\n return {\n sensors,\n collisionDetection,\n onDragStart: handleDragStart,\n onDragOver: handleDragOver,\n onDragEnd: handleDragEnd,\n onDragCancel: handleDragCancel,\n dropAnimation: dropAnimationConfig,\n activeItemForOverlay,\n activeGroupData,\n draggingGroupId: currentDraggingGroupId,\n containers: dndContainers,\n dndKitActiveNode,\n isDraggingCardOnly,\n dialogOpenForGroup,\n setDialogOpenForGroup,\n handleRenameGroup,\n handleDialogClose,\n isHoveringNewGroupDropZone,\n setIsHoveringNewGroupDropZone\n };\n}\n\nexport function NewGroupDropZone({\n disabled,\n setIsHovering\n}: {\n disabled: boolean;\n setIsHovering: (v: boolean) => void;\n}) {\n const {\n setNodeRef,\n isOver\n } = useDroppable({\n id: \"new-group-drop-zone\",\n disabled\n });\n const [isVisible, setIsVisible] = useState(false);\n\n useDndMonitor({\n onDragStart({ active }) {\n if (disabled) return;\n const tp = active.data.current?.type;\n setIsVisible(tp === \"item\");\n },\n onDragEnd() {\n setIsVisible(false);\n },\n onDragCancel() {\n setIsVisible(false);\n }\n });\n\n useEffect(() => {\n setIsHovering(isOver && isVisible);\n }, [isOver, isVisible, setIsHovering]);\n\n if (!isVisible || disabled) return null;\n\n return (\n <div\n ref={setNodeRef}\n className={cls(\n \"fixed right-8 top-1/2 -translate-y-1/2 w-[200px] h-[120px] border border-dashed rounded-lg flex items-center justify-center transition-all\",\n isOver\n ? \"bg-surface-raised border-hairline-strong\"\n : \"bg-surface-card border-hairline-strong\"\n )}>\n <div className=\"text-center p-4\">\n <span className=\"block font-medium text-sm\">\n Drop here to create a new group\n </span>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAM,wBAA8C,SAChD,4BAA4B;CACxB,GAAG;CACH,aAAa;AACjB,CAAC;AAEL,IAAM,sBAAqC,CAAC;AAE5C,IAAM,oCAAoC,UAA4C;CAYlF,OAAO;EAVH,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,KAAK,MAAM;EACX,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,YAAY,MAAM,aAAa,EAAE,GAAG,MAAM,WAAW,IAAI,KAAA;EACzD,MAAM,MAAM,OAAO,EAAE,GAAG,MAAM,KAAK,IAAI,KAAA;EACvC,GAAI,MAAM,SAAS,EAAE,OAAO,MAAM,MAAM;EACxC,GAAI,MAAM,eAAe,EAAE,aAAa,MAAM,YAAY;CAEvD;AACX;AAEA,IAAM,oBAAoB,UACtB,MAAM,KAAK,OAAO;CACd,MAAM,EAAE;CACR,SAAS,EAAE,QAAQ,IAAI,gCAAgC;AAC3D,EAAE;;;;;;;;;;;;;;;;;;;;AA0BN,SAAS,oBAAoB,YAAoE;CAC7F,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS;CACjC,OAAO;AACX;AACA,SAAgB,uBAAuB,EACnC,OACA,WAID;CACC,MAAM,EACF,YACA,WACA,YACA,WACA,YACA,eAEA,YAAY;EACR,IAAI,MAAM;EACV;CACJ,CAAC;CAEL,MAAM,yBAAyB,qBAAqB,2BAA2B,qBAAqB;CAQpG,OACI,oBAAC,OAAD;EAAK,KAAK;EAAmB,OAAA;GAN7B,WAAW,YAAY,IAAI,UAAU,SAAS,SAAS,IAAI,KAAA;GAC3D;GACA,SAAS,aAAa,IAAI;EAIG;EAAO,GAAI,oBAAoB,UAAU;EAAG,GAAI;YACzE,oBAAC,wBAAD;GAAwB,GAAI;GAAgB;EAAS,CAAA;CACpD,CAAA;AAEb;AAEA,SAAgB,yBAAyB,EACrC,IACA,SACA,UACA,4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,qBAErE,YAAY,mBAAmB;EAInC,uBAAuB,IAAI;EAC3B,uBAAuB,IAAI;EAC3B,sBAAsB,IAAI;CAC9B;CAaA,OAAO;EACH;EACA;EACA,aAAa;EACb,YAAY;EACZ,WAAW;EACX,cAAc;EACd,eAAe;EACf,sBAjBA,YAAY,CAAC,YAAY,gBACnB,OACA,SAAS,SAAS,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,MAAM,EAAE,QAAQ,QAAQ,KAAK;EAgB5E,iBAbA,YAAY,CAAC,YAAY,CAAC,gBACpB,OACA,SAAS,MAAM,MAAM,EAAE,SAAS,QAAQ,KAAK;EAYnD,iBAAiB;EACjB,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ;AAEA,SAAgB,iBAAiB,EAC7B,UACA,iBAID;CACC,MAAM,EACF,YACA,WACA,aAAa;EACb,IAAI;EACJ;CACJ,CAAC;CACD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAEhD,cAAc;EACV,YAAY,EAAE,UAAU;GACpB,IAAI,UAAU;GACd,MAAM,KAAK,OAAO,KAAK,SAAS;GAChC,aAAa,OAAO,MAAM;EAC9B;EACA,YAAY;GACR,aAAa,KAAK;EACtB;EACA,eAAe;GACX,aAAa,KAAK;EACtB;CACJ,CAAC;CAED,gBAAgB;EACZ,cAAc,UAAU,SAAS;CACrC,GAAG;EAAC;EAAQ;EAAW;CAAa,CAAC;CAErC,IAAI,CAAC,aAAa,UAAU,OAAO;CAEnC,OACI,oBAAC,OAAD;EACI,KAAK;EACL,WAAW,IACP,8IACA,SACM,6CACA,wCACV;YACA,oBAAC,OAAD;GAAK,WAAU;aACX,oBAAC,QAAD;IAAM,WAAU;cAA4B;GAEtC,CAAA;EACL,CAAA;CACJ,CAAA;AAEb"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography, cardClickableMixin, cardMixin, cls } from "@rebasepro/ui";
|
|
3
|
+
import { Link } from "react-router";
|
|
4
|
+
//#region src/components/HomePage/SmallNavigationCard.tsx
|
|
5
|
+
function SmallNavigationCard({ name, url, icon }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Link, {
|
|
7
|
+
tabIndex: 0,
|
|
8
|
+
className: cls(cardMixin, cardClickableMixin, "cursor-pointer flex flex-row items-center px-4 py-2 text-inherit dark:text-inherit visited:text-inherit dark:visited:text-inherit hover:text-inherit dark:hover:text-inherit "),
|
|
9
|
+
to: url,
|
|
10
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
className: "flex flex-row items-center grow gap-2 ",
|
|
12
|
+
children: [icon, /* @__PURE__ */ jsx(Typography, {
|
|
13
|
+
gutterBottom: true,
|
|
14
|
+
variant: "subtitle1",
|
|
15
|
+
component: "h2",
|
|
16
|
+
className: "mb-0 ml-3",
|
|
17
|
+
children: name
|
|
18
|
+
})]
|
|
19
|
+
})
|
|
20
|
+
}) });
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SmallNavigationCard };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=SmallNavigationCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmallNavigationCard.js","names":[],"sources":["../../../src/components/HomePage/SmallNavigationCard.tsx"],"sourcesContent":["import { cardClickableMixin, cardMixin, cls, Typography } from \"@rebasepro/ui\";\n\nimport { Link } from \"react-router\";\n\nexport type SmallNavigationCardProps = {\n name: string,\n url: string;\n icon: React.ReactElement;\n};\n\nexport function SmallNavigationCard({\n name,\n url,\n icon\n}: SmallNavigationCardProps) {\n\n return (\n <>\n\n <Link\n tabIndex={0}\n className={cls(cardMixin,\n cardClickableMixin,\n \"cursor-pointer flex flex-row items-center px-4 py-2 text-inherit dark:text-inherit visited:text-inherit dark:visited:text-inherit hover:text-inherit dark:hover:text-inherit \")}\n to={url}\n >\n\n <div className=\"flex flex-row items-center grow gap-2 \">\n {icon}\n\n <Typography gutterBottom variant=\"subtitle1\"\n component=\"h2\"\n className=\"mb-0 ml-3\">\n {name}\n </Typography>\n </div>\n\n </Link>\n\n </>);\n}\n"],"mappings":";;;;AAUA,SAAgB,oBAAoB,EAChC,MACA,KACA,QACyB;CAEzB,OACI,oBAAA,UAAA,EAAA,UAEI,oBAAC,MAAD;EACI,UAAU;EACV,WAAW,IAAI,WACX,oBACA,+KAA+K;EACnL,IAAI;YAGJ,qBAAC,OAAD;GAAK,WAAU;aAAf,CACK,MAED,oBAAC,YAAD;IAAY,cAAA;IAAa,SAAQ;IAC7B,WAAU;IACV,WAAU;cACT;GACO,CAAA,CACX;;CAEH,CAAA,EAER,CAAA;AACV"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { CircularProgressCenter } from "@rebasepro/ui";
|
|
4
|
-
import { LoginView, readEmailLinkAction, useAuthController, useRebaseRegistry } from "@rebasepro/app";
|
|
4
|
+
import { LoginView, readEmailLinkAction, useAuthController, useComponentOverride, useRebaseRegistry } from "@rebasepro/app";
|
|
5
5
|
//#region src/components/RebaseAuthGate.tsx
|
|
6
6
|
/**
|
|
7
7
|
* Auth gate component that handles the authentication flow.
|
|
@@ -23,10 +23,11 @@ import { LoginView, readEmailLinkAction, useAuthController, useRebaseRegistry }
|
|
|
23
23
|
function RebaseAuthGate({ children }) {
|
|
24
24
|
const registry = useRebaseRegistry();
|
|
25
25
|
const authController = useAuthController();
|
|
26
|
+
const ResolvedLoginView = useComponentOverride("Auth.LoginView", LoginView);
|
|
26
27
|
if (authController?.initialLoading) return /* @__PURE__ */ jsx(CircularProgressCenter, { size: "large" });
|
|
27
28
|
const openedLink = typeof window !== "undefined" ? readEmailLinkAction(window.location)?.kind : void 0;
|
|
28
29
|
const linkOpensOverSession = openedLink === "verify-email" || openedLink === "confirm-email-change" || openedLink === "magic-link";
|
|
29
|
-
if (!authController?.user || linkOpensOverSession) return /* @__PURE__ */ jsx(Fragment, { children: registry.authConfig?.loginView ?? /* @__PURE__ */ jsx(
|
|
30
|
+
if (!authController?.user || linkOpensOverSession) return /* @__PURE__ */ jsx(Fragment, { children: registry.authConfig?.loginView ?? /* @__PURE__ */ jsx(ResolvedLoginView, { authController }) });
|
|
30
31
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
31
32
|
}
|
|
32
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RebaseAuthGate.js","names":[],"sources":["../../src/components/RebaseAuthGate.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n useRebaseRegistry,\n useAuthController\n} from \"@rebasepro/app\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\nimport { LoginView, readEmailLinkAction } from \"@rebasepro/app\";\nimport type { AuthControllerExtended } from \"@rebasepro/cms-types\";\n\n/**\n * Auth gate component that handles the authentication flow.\n *\n * - Shows a loading spinner while `authController.initialLoading` is true.\n * - Shows the login view when no user is authenticated.\n * - Renders `children` when a user is authenticated.\n *\n * **Independently usable**: Use this alone when you want auth gating\n * without the full admin layout or navigation.\n *\n * @example\n * ```tsx\n * <RebaseAuthGate>\n * <MyCustomApp />\n * </RebaseAuthGate>\n * ```\n */\nexport function RebaseAuthGate({ children }: { children: React.ReactNode }) {\n const registry = useRebaseRegistry();\n const authController = useAuthController();\n\n\n if (authController?.initialLoading) {\n return <CircularProgressCenter size={\"large\"}/>;\n }\n\n // A verification link opened while signed in is verified by the session\n // itself — which keeps everything on the account — on the screen that\n // knows the link, and an address-change link is usually followed in the\n // tab that asked for the change. A magic link opened while signed in is\n // sent on to the app by that screen, without being spent. Left to the\n // app's router each was a page that does not exist.\n const openedLink = typeof window !== \"undefined\" ? readEmailLinkAction(window.location)?.kind : undefined;\n const linkOpensOverSession = openedLink === \"verify-email\"\n || openedLink === \"confirm-email-change\"\n || openedLink === \"magic-link\";\n\n if (!authController?.user || linkOpensOverSession) {\n const ActiveLoginView = registry.authConfig?.loginView ?? (\n <
|
|
1
|
+
{"version":3,"file":"RebaseAuthGate.js","names":[],"sources":["../../src/components/RebaseAuthGate.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n useRebaseRegistry,\n useAuthController,\n useComponentOverride\n} from \"@rebasepro/app\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\nimport { LoginView, readEmailLinkAction } from \"@rebasepro/app\";\nimport type { AuthControllerExtended } from \"@rebasepro/cms-types\";\n\n/**\n * Auth gate component that handles the authentication flow.\n *\n * - Shows a loading spinner while `authController.initialLoading` is true.\n * - Shows the login view when no user is authenticated.\n * - Renders `children` when a user is authenticated.\n *\n * **Independently usable**: Use this alone when you want auth gating\n * without the full admin layout or navigation.\n *\n * @example\n * ```tsx\n * <RebaseAuthGate>\n * <MyCustomApp />\n * </RebaseAuthGate>\n * ```\n */\nexport function RebaseAuthGate({ children }: { children: React.ReactNode }) {\n const registry = useRebaseRegistry();\n const authController = useAuthController();\n // `<RebaseAuth loginView>` is an element and wins; `\"Auth.LoginView\"` in\n // `<Rebase components>` replaces or wraps the built-in screen.\n const ResolvedLoginView = useComponentOverride(\"Auth.LoginView\", LoginView);\n\n if (authController?.initialLoading) {\n return <CircularProgressCenter size={\"large\"}/>;\n }\n\n // A verification link opened while signed in is verified by the session\n // itself — which keeps everything on the account — on the screen that\n // knows the link, and an address-change link is usually followed in the\n // tab that asked for the change. A magic link opened while signed in is\n // sent on to the app by that screen, without being spent. Left to the\n // app's router each was a page that does not exist.\n const openedLink = typeof window !== \"undefined\" ? readEmailLinkAction(window.location)?.kind : undefined;\n const linkOpensOverSession = openedLink === \"verify-email\"\n || openedLink === \"confirm-email-change\"\n || openedLink === \"magic-link\";\n\n if (!authController?.user || linkOpensOverSession) {\n const ActiveLoginView = registry.authConfig?.loginView ?? (\n <ResolvedLoginView authController={authController as AuthControllerExtended}/>\n );\n return <>{ActiveLoginView}</>;\n }\n\n return <>{children}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,eAAe,EAAE,YAA2C;CACxE,MAAM,WAAW,kBAAkB;CACnC,MAAM,iBAAiB,kBAAkB;CAGzC,MAAM,oBAAoB,qBAAqB,kBAAkB,SAAS;CAE1E,IAAI,gBAAgB,gBAChB,OAAO,oBAAC,wBAAD,EAAwB,MAAM,QAAS,CAAA;CASlD,MAAM,aAAa,OAAO,WAAW,cAAc,oBAAoB,OAAO,QAAQ,CAAC,EAAE,OAAO,KAAA;CAChG,MAAM,uBAAuB,eAAe,kBACrC,eAAe,0BACf,eAAe;CAEtB,IAAI,CAAC,gBAAgB,QAAQ,sBAIzB,OAAO,oBAAA,UAAA,EAAA,UAHiB,SAAS,YAAY,aACzC,oBAAC,mBAAD,EAAmC,eAA0C,CAAA,EAErD,CAAA;CAGhC,OAAO,oBAAA,UAAA,EAAG,SAAW,CAAA;AACzB"}
|
|
@@ -3,7 +3,10 @@ import type { AppView } from "@rebasepro/cms-types";
|
|
|
3
3
|
export interface RebaseLayoutProps {
|
|
4
4
|
/** Title shown in the drawer. */
|
|
5
5
|
title?: string;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Top bar. Only rendered if provided — pass `<AppBar/>` for the default
|
|
8
|
+
* one — or when `<Rebase components>` overrides `"Shell.AppBar"`.
|
|
9
|
+
*/
|
|
7
10
|
appBar?: React.ReactNode;
|
|
8
11
|
/** Custom Drawer to override the default. */
|
|
9
12
|
drawer?: React.ReactNode;
|