@rebasepro/cms 0.25.0-canary.ge06257e → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/collection_editor/liveSchemaClient.d.ts +3 -3
  2. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +52 -48
  4. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js +22 -22
  6. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  7. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js +14 -14
  8. package/dist/collection_editor/ui/collection_editor/properties/NumberPropertyField.js.map +1 -1
  9. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js +24 -24
  10. package/dist/collection_editor/ui/collection_editor/properties/StringPropertyField.js.map +1 -1
  11. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js +1 -1
  12. package/dist/components/CollectionTableBinding/internal/EntityTableCellActions.js.map +1 -1
  13. package/dist/components/DeleteEntityDialog.js +9 -9
  14. package/dist/components/DeleteEntityDialog.js.map +1 -1
  15. package/dist/components/PropertyConfigBadge.js +1 -1
  16. package/dist/components/PropertyConfigBadge.js.map +1 -1
  17. package/dist/components/ReferenceTable/SelectionTableBinding.js +4 -3
  18. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  19. package/dist/components/RelationSelector.js +2 -2
  20. package/dist/components/RelationSelector.js.map +1 -1
  21. package/dist/components/app/Scaffold.js.map +1 -1
  22. package/dist/editor/editor.js +2 -2
  23. package/dist/editor/editor.js.map +1 -1
  24. package/dist/editor/extensions/drag-and-drop.js +1 -1
  25. package/dist/editor/extensions/drag-and-drop.js.map +1 -1
  26. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteEntityDialog.js","names":[],"sources":["../../src/components/DeleteEntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveSelection } from \"../selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveSelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveSelection<M>({\n selection,\n accessor: dataClient.collection<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? (t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() }) ?? `Reading rows… ${loaded}`)\n : (t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n }) ?? `Reading rows… ${loaded} of ${total}`)\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }) ?? `Deleted ${completed} of ${total}`)\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? (t(\"unlink_entity_confirm_title\", { entityName }) ?? `Remove this ${entityName} from this record?`)\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\") ?? \"Remove these from this record?\"}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\") ?? \"Delete every row matching the current filter?\";\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n }) ?? `Delete ${selectionCount.toLocaleString()} ${collection.name}?`;\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })\n ?? `It stays in ${collection.name} and remains available to other records.`}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")\n ?? \"This cannot be undone. Each row is deleted individually, so this may take a while.\"}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,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D;OACI,QAAQ;OACI;OACN;MAAM,CAAA;KACf,CAAA;KACJ,CAAC,gBAAgB,YAAY,YAAY,oBAAC,OAAD;MAAK,WAAW;gBACtD,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAChC,EAAE,+BAA+B,KAC3B;MACC,CAAA;KACX,CAAA;IACM;;GACf,qBAAC,eAAD,EAAA,UAAA;IAEK,WAAW,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;IAC/C,YAAY,oBAAC,YAAD;KAAY,SAAS;KAAW,OAAO;eAAc;IAAqB,CAAA;IAEvF,oBAAC,QAAD;KAAQ,SAAS;KACb,SAAQ;eACP,EAAE,QAAQ;IACP,CAAA;IACR,oBAAC,QAAD;KACI,WAAA;KACA,UAAU;KACV,SAAS;KACT,SAAQ;eACP,EAAE,IAAI;IACH,CAAA;GACG,EAAA,CAAA;EAEX;;AAEhB"}
1
+ {"version":3,"file":"DeleteEntityDialog.js","names":[],"sources":["../../src/components/DeleteEntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveSelection } from \"../selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveSelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveSelection<M>({\n selection,\n accessor: dataClient.collection<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() })\n : t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n })\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }))\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? t(\"unlink_entity_confirm_title\", { entityName })\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\")}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\");\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n });\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,MACA,gBACA,0BACA,MACA,UAAU,YACiB;CAC3B,MAAM,aAAa,QAAQ;CAC3B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAA6B,KAAA,CAAS;CACtE,MAAM,eAAe,OAAO,EAAE,SAAS,MAAM,CAAC;CAE9C,MAAM,UAAU,gBAAgB;CAKhC,MAAM,EAAE,cAAc,cAAc,cAAc;EAC9C,IAAI,CAAC,QACD,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,CAAC,YAAY,MAAM,GACnB,OAAO;GAAE,cAAc;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,OAAO,SAAS,cAAc,OAAO,SAAS,WAAW,GACzD,OAAO;GAAE,cAAc,OAAO,SAAS;GACnC,WAAW,KAAA;EAAU;EAC7B,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW;EAAO;CAC1B,GAAG,CAAC,MAAM,CAAC;;CAGX,MAAM,iBAAiB,cAAc,KAAA,IAC/B,IACA,UAAU,SAAS,aACf,UAAU,SAAS,SACnB,UAAU,UAAU,KAAA,IAChB,KAAA,IACA,KAAK,IAAI,GAAG,UAAU,QAAQ,UAAU,SAAS,MAAM;CAErE,MAAM,eAAe,kBAAkB;EACnC,aAAa,QAAQ,UAAU;EAC/B,QAAQ;CAC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OAAS,OAAO;iBAChC,EAAE,8BAA8B,EAAE,gBAAgB,WAAW,KAAK,CAAC;MAC5D,CAAA;KACX,CAAA;KACJ,gBAAgB,oBAAC,OAAD;MAAK,WAAW;gBAC7B,oBAAC,mBAAD;OACI,QAAQ;OACI;OACN;MAAM,CAAA;KACf,CAAA;KACJ,CAAC,gBAAgB,YAAY,YAAY,oBAAC,OAAD;MAAK,WAAW;gBACtD,oBAAC,YAAD;OAAY,SAAS;OAAS,OAAO;iBAChC,EAAE,+BAA+B;MAC1B,CAAA;KACX,CAAA;IACM;;GACf,qBAAC,eAAD,EAAA,UAAA;IAEK,WAAW,oBAAC,kBAAD,EAAkB,MAAM,WAAY,CAAA;IAC/C,YAAY,oBAAC,YAAD;KAAY,SAAS;KAAW,OAAO;eAAc;IAAqB,CAAA;IAEvF,oBAAC,QAAD;KAAQ,SAAS;KACb,SAAQ;eACP,EAAE,QAAQ;IACP,CAAA;IACR,oBAAC,QAAD;KACI,WAAA;KACA,UAAU;KACV,SAAS;KACT,SAAQ;eACP,EAAE,IAAI;IACH,CAAA;GACG,EAAA,CAAA;EAEX;;AAEhB"}
@@ -9,7 +9,7 @@ function PropertyConfigBadge({ propertyConfig, disabled, size = "medium" }) {
9
9
  const defaultPropertyConfig = typeof propertyConfig?.property === "object" ? getDefaultFieldConfig(propertyConfig.property) : void 0;
10
10
  return /* @__PURE__ */ jsx("div", {
11
11
  className: classes,
12
- style: { background: !disabled ? propertyConfig?.color ?? defaultPropertyConfig?.color ?? "#888" : void 0 },
12
+ style: { background: !disabled ? propertyConfig?.color ?? defaultPropertyConfig?.color ?? "#838991" : void 0 },
13
13
  children: propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)
14
14
  });
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyConfigBadge.js","names":[],"sources":["../../src/components/PropertyConfigBadge.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { getDefaultFieldConfig } from \"./field_configs\";\nimport { getIconForWidget } from \"../util/property_utils\";\n\nexport function PropertyConfigBadge({\n propertyConfig,\n disabled,\n size = \"medium\"\n}: {\n propertyConfig: PropertyConfig | undefined,\n disabled?: boolean,\n size?: \"extraSmall\" | \"small\" | \"medium\"\n}): React.ReactNode {\n const sizeClasses = size === \"extraSmall\" ? \"h-5 w-5\" : size === \"small\" ? \"h-6 w-6\" : \"h-8 w-8\";\n const iconSize = size === \"extraSmall\" ? 14 : size === \"small\" ? \"smallest\" : \"small\";\n const classes = `${sizeClasses} flex-shrink-0 flex items-center justify-center rounded-full shadow-2xs text-white ` + (disabled ? \"bg-surface-400 dark:bg-surface-600\" : \"\");\n\n const defaultPropertyConfig = typeof propertyConfig?.property === \"object\" ? getDefaultFieldConfig(propertyConfig.property as Property) : undefined;\n\n return <div\n className={classes}\n style={{\n background: !disabled ? (propertyConfig?.color ?? defaultPropertyConfig?.color ?? \"#888\") : undefined\n }}>\n {propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)}\n </div>\n}\n"],"mappings":";;;;AAKA,SAAgB,oBAAoB,EAChC,gBACA,UACA,OAAO,YAKS;CAChB,MAAM,cAAc,SAAS,eAAe,YAAY,SAAS,UAAU,YAAY;CACvF,MAAM,WAAW,SAAS,eAAe,KAAK,SAAS,UAAU,aAAa;CAC9E,MAAM,UAAU,GAAG,YAAY,wFAAwF,WAAW,uCAAuC;CAEzK,MAAM,wBAAwB,OAAO,gBAAgB,aAAa,WAAW,sBAAsB,eAAe,QAAoB,IAAI,KAAA;CAE1I,OAAO,oBAAC,OAAD;EACH,WAAW;EACX,OAAO,EACH,YAAY,CAAC,WAAY,gBAAgB,SAAS,uBAAuB,SAAS,SAAU,KAAA,EAChG;YACC,gBAAgB,OAAO,iBAAiB,gBAAgB,QAAQ,IAAI,iBAAiB,uBAAuB,QAAQ;CACpH,CAAA;AACT"}
1
+ {"version":3,"file":"PropertyConfigBadge.js","names":[],"sources":["../../src/components/PropertyConfigBadge.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { getDefaultFieldConfig } from \"./field_configs\";\nimport { getIconForWidget } from \"../util/property_utils\";\n\nexport function PropertyConfigBadge({\n propertyConfig,\n disabled,\n size = \"medium\"\n}: {\n propertyConfig: PropertyConfig | undefined,\n disabled?: boolean,\n size?: \"extraSmall\" | \"small\" | \"medium\"\n}): React.ReactNode {\n const sizeClasses = size === \"extraSmall\" ? \"h-5 w-5\" : size === \"small\" ? \"h-6 w-6\" : \"h-8 w-8\";\n const iconSize = size === \"extraSmall\" ? 14 : size === \"small\" ? \"smallest\" : \"small\";\n const classes = `${sizeClasses} flex-shrink-0 flex items-center justify-center rounded-full shadow-2xs text-white ` + (disabled ? \"bg-surface-400 dark:bg-surface-600\" : \"\");\n\n const defaultPropertyConfig = typeof propertyConfig?.property === \"object\" ? getDefaultFieldConfig(propertyConfig.property as Property) : undefined;\n\n return <div\n className={classes}\n style={{\n background: !disabled ? (propertyConfig?.color ?? defaultPropertyConfig?.color ?? \"#838991\") : undefined\n }}>\n {propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)}\n </div>\n}\n"],"mappings":";;;;AAKA,SAAgB,oBAAoB,EAChC,gBACA,UACA,OAAO,YAKS;CAChB,MAAM,cAAc,SAAS,eAAe,YAAY,SAAS,UAAU,YAAY;CACvF,MAAM,WAAW,SAAS,eAAe,KAAK,SAAS,UAAU,aAAa;CAC9E,MAAM,UAAU,GAAG,YAAY,wFAAwF,WAAW,uCAAuC;CAEzK,MAAM,wBAAwB,OAAO,gBAAgB,aAAa,WAAW,sBAAsB,eAAe,QAAoB,IAAI,KAAA;CAE1I,OAAO,oBAAC,OAAD;EACH,WAAW;EACX,OAAO,EACH,YAAY,CAAC,WAAY,gBAAgB,SAAS,uBAAuB,SAAS,YAAa,KAAA,EACnG;YACC,gBAAgB,OAAO,iBAAiB,gBAAgB,QAAQ,IAAI,iBAAiB,uBAAuB,QAAQ;CACpH,CAAA;AACT"}
@@ -29,6 +29,7 @@ function SelectionTableBindingInternal({ onSingleEntitySelected, onMultipleEntit
29
29
  const sidePanelController = useSidePanel();
30
30
  const urlController = useUrlController();
31
31
  const analyticsController = useAnalyticsController();
32
+ const { t } = useTranslation();
32
33
  const path = urlController.resolveDatabasePathsFrom(pathInput);
33
34
  const dataClient = useData();
34
35
  const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = useState([]);
@@ -167,7 +168,7 @@ function SelectionTableBindingInternal({ onSingleEntitySelected, onMultipleEntit
167
168
  size: "small",
168
169
  collectionOrView: collection,
169
170
  className: "text-surface-300 dark:text-surface-600"
170
- }), collection.singularName ? `Select ${collection.singularName}` : `Select from ${collection.name}`]
171
+ }), collection.singularName ? t("select_specific", { name: collection.singularName }) : t("select_from", { name: collection.name })]
171
172
  }),
172
173
  defaultSize: collection.defaultSize,
173
174
  properties: collection.properties,
@@ -190,7 +191,7 @@ function SelectionTableBindingInternal({ onSingleEntitySelected, onMultipleEntit
190
191
  }), /* @__PURE__ */ jsx(Button, {
191
192
  onClick: onDone,
192
193
  variant: "filled",
193
- children: "Done"
194
+ children: t("done")
194
195
  })]
195
196
  })]
196
197
  })
@@ -215,7 +216,7 @@ function EntitySelectionDialogActions({ collection, path, onClear, onNewClick })
215
216
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
216
217
  onClick: onClear,
217
218
  variant: "text",
218
- children: "Clear"
219
+ children: t("clear")
219
220
  }), addButton] });
220
221
  }
221
222
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionTableBinding.js","names":[],"sources":["../../../src/components/ReferenceTable/SelectionTableBinding.tsx"],"sourcesContent":["\nimport React, { MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\n\nimport {\n CollectionRowActions,\n CollectionTableBinding\n} from \"../CollectionTableBinding\";\nimport {\n CollectionScopeProvider,\n useAuthController,\n useCustomizationController,\n useData,\n useDataTableController,\n useLargeLayout,\n usePermissions,\n useTranslation\n} from \"@rebasepro/app\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { Button, DialogActions, PlusIcon, Typography } from \"@rebasepro/ui\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { useSelectionController } from \"../CollectionViewBinding/useSelectionController\";\n\nimport { useColumnIds } from \"@rebasepro/app\";\nimport { useSideDialogContext } from \"../SideDialogs\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { useSidePanel } from \"../../hooks/useSidePanel\";\nimport { findEntitiesByIds } from \"../../util/find_entities_by_ids\";\n\n/** Stable identity, so the effect that propagates the picks does not re-fire. */\nconst EMPTY_ENTITIES: Entity<any>[] = [];\n\n/**\n * @group Components\n */\nexport interface SelectionProps<M extends Record<string, unknown>> {\n\n /**\n * Allow multiple selection of values\n */\n multiselect?: boolean;\n\n /**\n * Entity collection config\n */\n collection?: AdminCollection<M>;\n\n /**\n * Absolute path of the collection.\n * May be not set if this hook is being used in a component and the path is\n * dynamic. If not set, the dialog won't open.\n */\n path: string;\n\n /**\n * If you are opening the dialog for the first time, you can select some\n * entity ids to be displayed first.\n */\n selectedEntityIds?: (string | number)[];\n\n /**\n * If `multiselect` is set to `false`, you will get the selected entity\n * in this callback.\n * @param entity\n * @callback\n */\n onSingleEntitySelected?(entity: Entity<any> | null): void;\n\n /**\n * If `multiselect` is set to `true`, you will get the selected entities\n * in this callback.\n * @param entities\n * @callback\n */\n onMultipleEntitiesSelected?(entities: Entity<any>[]): void;\n\n /**\n * Called once, with the final selection, when the user presses Done.\n *\n * `onMultipleEntitiesSelected` reports every tick as it happens, which is\n * right when the selection *is* the value (a reference field). Use this\n * one instead when acting on the selection writes something — linking\n * rows, say — so a row ticked and then unticked, or a selection cleared,\n * is never acted on.\n * @param entities\n * @callback\n */\n onSelectionDone?(entities: Entity<M>[]): void;\n\n /**\n * Allow selection of entities that pass the given filter only.\n */\n fixedFilter?: FilterValues<string>;\n\n /**\n * Use this description to indicate the user what to do in this dialog.\n */\n description?: React.ReactNode;\n\n /**\n * Maximum number of entities that can be selected.\n */\n maxSelection?: number;\n\n}\n\n/**\n * This component allows to select entities from a given collection.\n * You probably want to open this dialog as a side view using {@link useSelectionTableBinding}\n * @group Components\n */\nexport function SelectionTableBinding<M extends Record<string, unknown>>(\n props: SelectionProps<M>\n) {\n if (!props.collection) {\n return <ErrorView\n error={\"Could not find collection\"}/>\n }\n return <SelectionTableBindingInternal {...props} collection={props.collection} />;\n}\n\nfunction SelectionTableBindingInternal<M extends Record<string, unknown>>(\n {\n onSingleEntitySelected,\n onMultipleEntitiesSelected,\n onSelectionDone,\n multiselect,\n collection,\n path: pathInput,\n selectedEntityIds: selectedEntityIdsProp,\n description,\n fixedFilter,\n maxSelection\n }: SelectionProps<M> & { collection: AdminCollection<M> }) {\n\n const sideDialogContext = useSideDialogContext();\n const sidePanelController = useSidePanel();\n const urlController = useUrlController();\n const analyticsController = useAnalyticsController();\n\n const path = urlController.resolveDatabasePathsFrom(pathInput);\n\n const dataClient = useData();\n\n const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = useState<Entity<any>[]>([]);\n\n // Explicitly `<M>`: the hook defaults to `Record<string, unknown>`, and the\n // controller is handed to a table typed `SelectionController<M>`. `Entity<M>`\n // sits on both sides of that interface (`selectedEntities` out,\n // `toggleEntitySelection` in), so the default was never actually assignable\n // here — it only looked fine while the surrounding props gave TypeScript no\n // reason to bind `M` to this component's own parameter.\n const selectionController = useSelectionController<M>();\n\n // The rows picked in this dialog.\n //\n // This surface never enters query mode: it offers no \"select all matching\",\n // because pointing a reference field at every row of a collection is not\n // something anyone means to do, and `maxSelection` could not be enforced\n // against a count nobody has read yet. Every write below goes through\n // `setSelectedEntities`, so the query branch is unreachable here.\n const selectedEntities = selectionController.selection.type === \"entities\"\n ? selectionController.selection.entities\n : EMPTY_ENTITIES;\n\n // Track whether the selection has been initialized to avoid\n // firing onMultipleEntitiesSelected during the initial mount/fetch.\n const selectionInitializedRef = useRef(false);\n\n // Propagate selection changes to the parent callback.\n // This runs after the selectionController state updates, ensuring\n // we always send the correct, non-stale selection to the parent.\n useEffect(() => {\n if (!selectionInitializedRef.current) return;\n if (onMultipleEntitiesSelected) {\n onMultipleEntitiesSelected(selectedEntities);\n }\n }, [selectedEntities]);\n\n /**\n * Fetch initially selected ids\n */\n useEffect(() => {\n let unmounted = false;\n const selectedEntityIds = selectedEntityIdsProp?.map(id => id?.toString()).filter(Boolean);\n if (selectedEntityIds && selectedEntityIds.length > 0 && collection) {\n // One request per 1,000 ids, not one per id (see findEntitiesByIds).\n findEntitiesByIds(dataClient.collection<M>(path), collection, selectedEntityIds)\n .then((found) => {\n if (!unmounted) {\n // In the order given; an id with no row is dropped.\n const result = selectedEntityIds\n .map(id => found.get(id))\n .filter((e): e is Entity<any> => !!e);\n selectionController.setSelectedEntities(result);\n setEntitiesDisplayedFirst(result);\n // Mark initialized after the initial fetch completes\n selectionInitializedRef.current = true;\n }\n });\n } else {\n selectionController.setSelectedEntities([]);\n setEntitiesDisplayedFirst([]);\n selectionInitializedRef.current = true;\n }\n return () => {\n unmounted = true;\n };\n }, [dataClient, path, selectedEntityIdsProp, collection, selectionController.setSelectedEntities]);\n\n const onClear = () => {\n analyticsController.onAnalyticsEvent?.(\"reference_selection_clear\", {\n path\n });\n selectionController.setSelectedEntities([]);\n if (!multiselect && onSingleEntitySelected) {\n onSingleEntitySelected(null);\n }\n };\n\n const onEntityClick = useCallback((entity: Entity<any>) => {\n if (!multiselect && onSingleEntitySelected) {\n analyticsController.onAnalyticsEvent?.(\"reference_selected_single\", {\n path,\n entityId: entity.id\n });\n onSingleEntitySelected(entity);\n sideDialogContext.close(false);\n } else {\n // For multiselect, delegate to the selection controller's toggle.\n // The useEffect above will propagate the change to onMultipleEntitiesSelected.\n analyticsController.onAnalyticsEvent?.(\"reference_selection_toggle\", {\n path,\n entityId: entity.id\n });\n if (selectedEntities.map((e) => e.id).indexOf(entity.id) > -1) {\n selectionController.setSelectedEntities(\n selectedEntities.filter((item: Entity<any>) => item.id !== entity.id)\n );\n } else {\n if (maxSelection && selectedEntities.length >= maxSelection) return;\n selectionController.setSelectedEntities([...selectedEntities, entity]);\n }\n }\n }, [multiselect, onSingleEntitySelected, analyticsController, path, sideDialogContext, selectionController, selectedEntities, maxSelection]);\n\n // create a new entity from within the reference dialog\n const onNewClick = () => {\n analyticsController.onAnalyticsEvent?.(\"reference_selection_new_entity\", {\n path\n });\n sidePanelController.open({\n path: path,\n collection,\n // No URL, for the reason `RelationSelector` does the same: this\n // panel is a step inside the selection dialog, which is itself a\n // step inside whatever form opened it. `useUnsavedChangesDialog`\n // blocks on a *pathname* change, and this panel's path is a\n // different collection from the one being edited — so closing it\n // raced the panel clearing its own dirty flag and answered a\n // successful save with \"There are unsaved changes\", leaving the URL\n // on the target collection. A record that does not exist yet has no\n // address worth restoring anyway.\n updateUrl: false,\n onUpdate: ({ entity }) => {\n setEntitiesDisplayedFirst([entity, ...entitiesDisplayedFirst]);\n onEntityClick(entity);\n },\n closeOnSave: true\n });\n };\n\n const tableRowActionsBuilder = ({\n entity,\n size,\n width,\n frozen\n }: {\n entity: Entity<any>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => {\n const isSelected = selectionController.isEntitySelected(entity);\n return <CollectionRowActions\n width={width}\n frozen={frozen}\n entity={entity}\n size={size}\n isSelected={isSelected}\n selectionEnabled={multiselect}\n hideId={collection?.hideIdFromCollection}\n path={path}\n selectionController={selectionController}\n openEntityMode={\"side_panel\"}\n />;\n\n };\n\n const onDone = useCallback((event: React.SyntheticEvent) => {\n event.stopPropagation();\n onSelectionDone?.(selectedEntities);\n sideDialogContext.close(false);\n }, [sideDialogContext, onSelectionDone, selectedEntities]);\n\n const displayedColumnIds = useColumnIds(collection, false);\n\n const tableController = useDataTableController<M>({\n path,\n collection,\n entitiesDisplayedFirst,\n fixedFilter,\n updateUrl: false\n });\n\n return (\n\n <CollectionScopeProvider collection={collection}>\n <div className=\"flex flex-col h-full\">\n\n <div className=\"grow\">\n {entitiesDisplayedFirst &&\n <CollectionTableBinding\n additionalFields={collection.additionalFields}\n displayedColumnIds={displayedColumnIds}\n onEntityClick={onEntityClick}\n tableController={tableController}\n enablePopupIcon={false}\n tableRowActionsBuilder={tableRowActionsBuilder}\n openEntityMode={\"side_panel\"}\n title={<Typography variant={\"subtitle2\"} className={\"flex flex-row gap-2\"}>\n <IconForView\n size={\"small\"}\n collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {collection.singularName\n ? `Select ${collection.singularName}`\n : `Select from ${collection.name}`}\n </Typography>}\n defaultSize={collection.defaultSize}\n properties={collection.properties}\n fixedFilter={fixedFilter}\n inlineEditing={false}\n selectionController={selectionController}\n actions={<EntitySelectionDialogActions\n collection={collection}\n path={path}\n onNewClick={onNewClick}\n onClear={onClear}/>\n }\n />}\n </div>\n <DialogActions translucent={false}>\n {description &&\n <Typography variant={\"body2\"}\n className=\"grow text-left\">\n {description}\n </Typography>}\n <Button\n onClick={onDone}\n variant=\"filled\">\n Done\n </Button>\n </DialogActions>\n </div>\n </CollectionScopeProvider>\n\n );\n\n}\n\nfunction EntitySelectionDialogActions({\n collection,\n path,\n onClear,\n onNewClick\n}: {\n collection: AdminCollection<any>,\n path: string,\n onClear: () => void,\n onNewClick: () => void\n}) {\n\n const { canCreate } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const { t } = useTranslation();\n\n const onClick: MouseEventHandler<HTMLButtonElement> | undefined = onNewClick\n ? (e) => {\n e.preventDefault();\n onNewClick();\n }\n : undefined;\n const addButton = canCreate(collection, path) &&\n onClick && (largeLayout\n ? <Button\n onClick={onClick}\n startIcon={<PlusIcon/>}>\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n : <Button\n onClick={onClick}>\n <PlusIcon/>\n </Button>);\n\n return (\n <>\n <Button onClick={onClear}\n variant={\"text\"}>\n Clear\n </Button>\n {addButton}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,IAAM,iBAAgC,CAAC;;;;;;AAiFvC,SAAgB,sBACZ,OACF;CACE,IAAI,CAAC,MAAM,YACP,OAAO,oBAAC,WAAD,EACH,OAAO,4BAA6B,CAAA;CAE5C,OAAO,oBAAC,+BAAD;EAA+B,GAAI;EAAO,YAAY,MAAM;CAAa,CAAA;AACpF;AAEA,SAAS,8BACL,EACI,wBACA,4BACA,iBACA,aACA,YACA,MAAM,WACN,mBAAmB,uBACnB,aACA,aACA,gBACuD;CAE3D,MAAM,oBAAoB,qBAAqB;CAC/C,MAAM,sBAAsB,aAAa;CACzC,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,sBAAsB,uBAAuB;CAEnD,MAAM,OAAO,cAAc,yBAAyB,SAAS;CAE7D,MAAM,aAAa,QAAQ;CAE3B,MAAM,CAAC,wBAAwB,6BAA6B,SAAwB,CAAC,CAAC;CAQtF,MAAM,sBAAsB,uBAA0B;CAStD,MAAM,mBAAmB,oBAAoB,UAAU,SAAS,aAC1D,oBAAoB,UAAU,WAC9B;CAIN,MAAM,0BAA0B,OAAO,KAAK;CAK5C,gBAAgB;EACZ,IAAI,CAAC,wBAAwB,SAAS;EACtC,IAAI,4BACA,2BAA2B,gBAAgB;CAEnD,GAAG,CAAC,gBAAgB,CAAC;;;;CAKrB,gBAAgB;EACZ,IAAI,YAAY;EAChB,MAAM,oBAAoB,uBAAuB,KAAI,OAAM,IAAI,SAAS,CAAC,CAAC,CAAC,OAAO,OAAO;EACzF,IAAI,qBAAqB,kBAAkB,SAAS,KAAK,YAErD,kBAAkB,WAAW,WAAc,IAAI,GAAG,YAAY,iBAAiB,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;KAAY,SAAS;KACjB,WAAU;eACT;IACO,CAAA,GAChB,oBAAC,QAAD;KACI,SAAS;KACT,SAAQ;eAAS;IAEb,CAAA,CACG;KACd;;CACoB,CAAA;AAIjC;AAEA,SAAS,6BAA6B,EAClC,YACA,MACA,SACA,cAMD;CAEC,MAAM,EAAE,cAAc,eAAe;CAErC,MAAM,cAAc,eAAe;CACnC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,UAA4D,cAC3D,MAAM;EACL,EAAE,eAAe;EACjB,WAAW;CACf,IACE,KAAA;CACN,MAAM,YAAY,UAAU,YAAY,IAAI,KACxC,YAAY,cACN,oBAAC,QAAD;EACW;EACT,WAAW,oBAAC,UAAD,CAAU,CAAA;YACpB,EAAE,gBAAgB,EAAE,MAAM,WAAW,gBAAgB,WAAW,KAAK,CAAC;CACnE,CAAA,IACN,oBAAC,QAAD;EACW;YACT,oBAAC,UAAD,CAAU,CAAA;CACN,CAAA;CAEhB,OACI,qBAAA,UAAA,EAAA,UAAA,CACI,oBAAC,QAAD;EAAQ,SAAS;EACb,SAAS;YAAQ;CAEb,CAAA,GACP,SACH,EAAA,CAAA;AAEV"}
1
+ {"version":3,"file":"SelectionTableBinding.js","names":[],"sources":["../../../src/components/ReferenceTable/SelectionTableBinding.tsx"],"sourcesContent":["\nimport React, { MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection } from \"@rebasepro/cms-types\";\n\nimport {\n CollectionRowActions,\n CollectionTableBinding\n} from \"../CollectionTableBinding\";\nimport {\n CollectionScopeProvider,\n useAuthController,\n useCustomizationController,\n useData,\n useDataTableController,\n useLargeLayout,\n usePermissions,\n useTranslation\n} from \"@rebasepro/app\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { Button, DialogActions, PlusIcon, Typography } from \"@rebasepro/ui\";\nimport { IconForView } from \"@rebasepro/app\";\nimport { useSelectionController } from \"../CollectionViewBinding/useSelectionController\";\n\nimport { useColumnIds } from \"@rebasepro/app\";\nimport { useSideDialogContext } from \"../SideDialogs\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { useSidePanel } from \"../../hooks/useSidePanel\";\nimport { findEntitiesByIds } from \"../../util/find_entities_by_ids\";\n\n/** Stable identity, so the effect that propagates the picks does not re-fire. */\nconst EMPTY_ENTITIES: Entity<any>[] = [];\n\n/**\n * @group Components\n */\nexport interface SelectionProps<M extends Record<string, unknown>> {\n\n /**\n * Allow multiple selection of values\n */\n multiselect?: boolean;\n\n /**\n * Entity collection config\n */\n collection?: AdminCollection<M>;\n\n /**\n * Absolute path of the collection.\n * May be not set if this hook is being used in a component and the path is\n * dynamic. If not set, the dialog won't open.\n */\n path: string;\n\n /**\n * If you are opening the dialog for the first time, you can select some\n * entity ids to be displayed first.\n */\n selectedEntityIds?: (string | number)[];\n\n /**\n * If `multiselect` is set to `false`, you will get the selected entity\n * in this callback.\n * @param entity\n * @callback\n */\n onSingleEntitySelected?(entity: Entity<any> | null): void;\n\n /**\n * If `multiselect` is set to `true`, you will get the selected entities\n * in this callback.\n * @param entities\n * @callback\n */\n onMultipleEntitiesSelected?(entities: Entity<any>[]): void;\n\n /**\n * Called once, with the final selection, when the user presses Done.\n *\n * `onMultipleEntitiesSelected` reports every tick as it happens, which is\n * right when the selection *is* the value (a reference field). Use this\n * one instead when acting on the selection writes something — linking\n * rows, say — so a row ticked and then unticked, or a selection cleared,\n * is never acted on.\n * @param entities\n * @callback\n */\n onSelectionDone?(entities: Entity<M>[]): void;\n\n /**\n * Allow selection of entities that pass the given filter only.\n */\n fixedFilter?: FilterValues<string>;\n\n /**\n * Use this description to indicate the user what to do in this dialog.\n */\n description?: React.ReactNode;\n\n /**\n * Maximum number of entities that can be selected.\n */\n maxSelection?: number;\n\n}\n\n/**\n * This component allows to select entities from a given collection.\n * You probably want to open this dialog as a side view using {@link useSelectionTableBinding}\n * @group Components\n */\nexport function SelectionTableBinding<M extends Record<string, unknown>>(\n props: SelectionProps<M>\n) {\n if (!props.collection) {\n return <ErrorView\n error={\"Could not find collection\"}/>\n }\n return <SelectionTableBindingInternal {...props} collection={props.collection} />;\n}\n\nfunction SelectionTableBindingInternal<M extends Record<string, unknown>>(\n {\n onSingleEntitySelected,\n onMultipleEntitiesSelected,\n onSelectionDone,\n multiselect,\n collection,\n path: pathInput,\n selectedEntityIds: selectedEntityIdsProp,\n description,\n fixedFilter,\n maxSelection\n }: SelectionProps<M> & { collection: AdminCollection<M> }) {\n\n const sideDialogContext = useSideDialogContext();\n const sidePanelController = useSidePanel();\n const urlController = useUrlController();\n const analyticsController = useAnalyticsController();\n const { t } = useTranslation();\n\n const path = urlController.resolveDatabasePathsFrom(pathInput);\n\n const dataClient = useData();\n\n const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = useState<Entity<any>[]>([]);\n\n // Explicitly `<M>`: the hook defaults to `Record<string, unknown>`, and the\n // controller is handed to a table typed `SelectionController<M>`. `Entity<M>`\n // sits on both sides of that interface (`selectedEntities` out,\n // `toggleEntitySelection` in), so the default was never actually assignable\n // here — it only looked fine while the surrounding props gave TypeScript no\n // reason to bind `M` to this component's own parameter.\n const selectionController = useSelectionController<M>();\n\n // The rows picked in this dialog.\n //\n // This surface never enters query mode: it offers no \"select all matching\",\n // because pointing a reference field at every row of a collection is not\n // something anyone means to do, and `maxSelection` could not be enforced\n // against a count nobody has read yet. Every write below goes through\n // `setSelectedEntities`, so the query branch is unreachable here.\n const selectedEntities = selectionController.selection.type === \"entities\"\n ? selectionController.selection.entities\n : EMPTY_ENTITIES;\n\n // Track whether the selection has been initialized to avoid\n // firing onMultipleEntitiesSelected during the initial mount/fetch.\n const selectionInitializedRef = useRef(false);\n\n // Propagate selection changes to the parent callback.\n // This runs after the selectionController state updates, ensuring\n // we always send the correct, non-stale selection to the parent.\n useEffect(() => {\n if (!selectionInitializedRef.current) return;\n if (onMultipleEntitiesSelected) {\n onMultipleEntitiesSelected(selectedEntities);\n }\n }, [selectedEntities]);\n\n /**\n * Fetch initially selected ids\n */\n useEffect(() => {\n let unmounted = false;\n const selectedEntityIds = selectedEntityIdsProp?.map(id => id?.toString()).filter(Boolean);\n if (selectedEntityIds && selectedEntityIds.length > 0 && collection) {\n // One request per 1,000 ids, not one per id (see findEntitiesByIds).\n findEntitiesByIds(dataClient.collection<M>(path), collection, selectedEntityIds)\n .then((found) => {\n if (!unmounted) {\n // In the order given; an id with no row is dropped.\n const result = selectedEntityIds\n .map(id => found.get(id))\n .filter((e): e is Entity<any> => !!e);\n selectionController.setSelectedEntities(result);\n setEntitiesDisplayedFirst(result);\n // Mark initialized after the initial fetch completes\n selectionInitializedRef.current = true;\n }\n });\n } else {\n selectionController.setSelectedEntities([]);\n setEntitiesDisplayedFirst([]);\n selectionInitializedRef.current = true;\n }\n return () => {\n unmounted = true;\n };\n }, [dataClient, path, selectedEntityIdsProp, collection, selectionController.setSelectedEntities]);\n\n const onClear = () => {\n analyticsController.onAnalyticsEvent?.(\"reference_selection_clear\", {\n path\n });\n selectionController.setSelectedEntities([]);\n if (!multiselect && onSingleEntitySelected) {\n onSingleEntitySelected(null);\n }\n };\n\n const onEntityClick = useCallback((entity: Entity<any>) => {\n if (!multiselect && onSingleEntitySelected) {\n analyticsController.onAnalyticsEvent?.(\"reference_selected_single\", {\n path,\n entityId: entity.id\n });\n onSingleEntitySelected(entity);\n sideDialogContext.close(false);\n } else {\n // For multiselect, delegate to the selection controller's toggle.\n // The useEffect above will propagate the change to onMultipleEntitiesSelected.\n analyticsController.onAnalyticsEvent?.(\"reference_selection_toggle\", {\n path,\n entityId: entity.id\n });\n if (selectedEntities.map((e) => e.id).indexOf(entity.id) > -1) {\n selectionController.setSelectedEntities(\n selectedEntities.filter((item: Entity<any>) => item.id !== entity.id)\n );\n } else {\n if (maxSelection && selectedEntities.length >= maxSelection) return;\n selectionController.setSelectedEntities([...selectedEntities, entity]);\n }\n }\n }, [multiselect, onSingleEntitySelected, analyticsController, path, sideDialogContext, selectionController, selectedEntities, maxSelection]);\n\n // create a new entity from within the reference dialog\n const onNewClick = () => {\n analyticsController.onAnalyticsEvent?.(\"reference_selection_new_entity\", {\n path\n });\n sidePanelController.open({\n path: path,\n collection,\n // No URL, for the reason `RelationSelector` does the same: this\n // panel is a step inside the selection dialog, which is itself a\n // step inside whatever form opened it. `useUnsavedChangesDialog`\n // blocks on a *pathname* change, and this panel's path is a\n // different collection from the one being edited — so closing it\n // raced the panel clearing its own dirty flag and answered a\n // successful save with \"There are unsaved changes\", leaving the URL\n // on the target collection. A record that does not exist yet has no\n // address worth restoring anyway.\n updateUrl: false,\n onUpdate: ({ entity }) => {\n setEntitiesDisplayedFirst([entity, ...entitiesDisplayedFirst]);\n onEntityClick(entity);\n },\n closeOnSave: true\n });\n };\n\n const tableRowActionsBuilder = ({\n entity,\n size,\n width,\n frozen\n }: {\n entity: Entity<any>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => {\n const isSelected = selectionController.isEntitySelected(entity);\n return <CollectionRowActions\n width={width}\n frozen={frozen}\n entity={entity}\n size={size}\n isSelected={isSelected}\n selectionEnabled={multiselect}\n hideId={collection?.hideIdFromCollection}\n path={path}\n selectionController={selectionController}\n openEntityMode={\"side_panel\"}\n />;\n\n };\n\n const onDone = useCallback((event: React.SyntheticEvent) => {\n event.stopPropagation();\n onSelectionDone?.(selectedEntities);\n sideDialogContext.close(false);\n }, [sideDialogContext, onSelectionDone, selectedEntities]);\n\n const displayedColumnIds = useColumnIds(collection, false);\n\n const tableController = useDataTableController<M>({\n path,\n collection,\n entitiesDisplayedFirst,\n fixedFilter,\n updateUrl: false\n });\n\n return (\n\n <CollectionScopeProvider collection={collection}>\n <div className=\"flex flex-col h-full\">\n\n <div className=\"grow\">\n {entitiesDisplayedFirst &&\n <CollectionTableBinding\n additionalFields={collection.additionalFields}\n displayedColumnIds={displayedColumnIds}\n onEntityClick={onEntityClick}\n tableController={tableController}\n enablePopupIcon={false}\n tableRowActionsBuilder={tableRowActionsBuilder}\n openEntityMode={\"side_panel\"}\n title={<Typography variant={\"subtitle2\"} className={\"flex flex-row gap-2\"}>\n <IconForView\n size={\"small\"}\n collectionOrView={collection}\n className={\"text-surface-300 dark:text-surface-600\"}/>\n {collection.singularName\n ? t(\"select_specific\", { name: collection.singularName })\n : t(\"select_from\", { name: collection.name })}\n </Typography>}\n defaultSize={collection.defaultSize}\n properties={collection.properties}\n fixedFilter={fixedFilter}\n inlineEditing={false}\n selectionController={selectionController}\n actions={<EntitySelectionDialogActions\n collection={collection}\n path={path}\n onNewClick={onNewClick}\n onClear={onClear}/>\n }\n />}\n </div>\n <DialogActions translucent={false}>\n {description &&\n <Typography variant={\"body2\"}\n className=\"grow text-left\">\n {description}\n </Typography>}\n <Button\n onClick={onDone}\n variant=\"filled\">\n {t(\"done\")}\n </Button>\n </DialogActions>\n </div>\n </CollectionScopeProvider>\n\n );\n\n}\n\nfunction EntitySelectionDialogActions({\n collection,\n path,\n onClear,\n onNewClick\n}: {\n collection: AdminCollection<any>,\n path: string,\n onClear: () => void,\n onNewClick: () => void\n}) {\n\n const { canCreate } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const { t } = useTranslation();\n\n const onClick: MouseEventHandler<HTMLButtonElement> | undefined = onNewClick\n ? (e) => {\n e.preventDefault();\n onNewClick();\n }\n : undefined;\n const addButton = canCreate(collection, path) &&\n onClick && (largeLayout\n ? <Button\n onClick={onClick}\n startIcon={<PlusIcon/>}>\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n : <Button\n onClick={onClick}>\n <PlusIcon/>\n </Button>);\n\n return (\n <>\n <Button onClick={onClear}\n variant={\"text\"}>\n {t(\"clear\")}\n </Button>\n {addButton}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,IAAM,iBAAgC,CAAC;;;;;;AAiFvC,SAAgB,sBACZ,OACF;CACE,IAAI,CAAC,MAAM,YACP,OAAO,o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Ac,eAAe;CACnC,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,UAA4D,cAC3D,MAAM;EACL,EAAE,eAAe;EACjB,WAAW;CACf,IACE,KAAA;CACN,MAAM,YAAY,UAAU,YAAY,IAAI,KACxC,YAAY,cACN,oBAAC,QAAD;EACW;EACT,WAAW,oBAAC,UAAD,CAAU,CAAA;YACpB,EAAE,gBAAgB,EAAE,MAAM,WAAW,gBAAgB,WAAW,KAAK,CAAC;CACnE,CAAA,IACN,oBAAC,QAAD;EACW;YACT,oBAAC,UAAD,CAAU,CAAA;CACN,CAAA;CAEhB,OACI,qBAAA,UAAA,EAAA,UAAA,CACI,oBAAC,QAAD;EAAQ,SAAS;EACb,SAAS;YACR,EAAE,OAAO;CACN,CAAA,GACP,SACH,EAAA,CAAA;AAEV"}
@@ -440,9 +440,9 @@ var RelationSelector = React$1.forwardRef(({ value, size = "medium", onValueChan
440
440
  }), /* @__PURE__ */ jsxs("div", {
441
441
  className: "flex items-center flex-shrink-0",
442
442
  children: [!multiple && selectedItems.length === 1 && selectedItems[0]?.data && /* @__PURE__ */ jsx(Tooltip, {
443
- title: `Open ${selectedItems[0].label}`,
443
+ title: t("relation_open_record", { label: selectedItems[0].label }),
444
444
  children: /* @__PURE__ */ jsx(IconButton, {
445
- "aria-label": `Open ${selectedItems[0].label}`,
445
+ "aria-label": t("relation_open_record", { label: selectedItems[0].label }),
446
446
  component: "div",
447
447
  size: "small",
448
448
  className: "opacity-60 hover:opacity-100",