@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.
Files changed (111) hide show
  1. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js +1 -1
  2. package/dist/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.js.map +1 -1
  3. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.d.ts +7 -1
  4. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +9 -2
  5. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  6. package/dist/collection_editor/useLiveSchemaEditing.js +4 -1
  7. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  8. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +1 -1
  9. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  10. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +1 -2
  11. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  12. package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +1 -2
  13. package/dist/components/CollectionTableBinding/internal/EntityTableCell.js.map +1 -1
  14. package/dist/components/CollectionViewBinding/CollectionViewActions.js +1 -1
  15. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  16. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +2 -28
  17. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  18. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.d.ts +12 -0
  19. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js +33 -0
  20. package/dist/components/CollectionViewBinding/DefaultCollectionEmptyState.js.map +1 -0
  21. package/dist/components/CollectionsScopeContext.d.ts +5 -1
  22. package/dist/components/CollectionsScopeContext.js +10 -2
  23. package/dist/components/CollectionsScopeContext.js.map +1 -1
  24. package/dist/components/DefaultAppBar.js +2 -1
  25. package/dist/components/DefaultAppBar.js.map +1 -1
  26. package/dist/components/DefaultDrawer.js +19 -6
  27. package/dist/components/DefaultDrawer.js.map +1 -1
  28. package/dist/components/DefaultMissingReference.d.ts +8 -0
  29. package/dist/components/DefaultMissingReference.js +13 -0
  30. package/dist/components/DefaultMissingReference.js.map +1 -0
  31. package/dist/components/EntityFormPanel.d.ts +7 -2
  32. package/dist/components/EntityFormPanel.js +72 -29
  33. package/dist/components/EntityFormPanel.js.map +1 -1
  34. package/dist/components/HomePage/ContentHomePage.js +7 -5
  35. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  36. package/dist/components/HomePage/HomePageDnD.js +3 -1
  37. package/dist/components/HomePage/HomePageDnD.js.map +1 -1
  38. package/dist/components/HomePage/SmallNavigationCard.js +25 -0
  39. package/dist/components/HomePage/SmallNavigationCard.js.map +1 -0
  40. package/dist/components/RebaseAuthGate.js +3 -2
  41. package/dist/components/RebaseAuthGate.js.map +1 -1
  42. package/dist/components/RebaseLayout.d.ts +4 -1
  43. package/dist/components/RebaseLayout.js +7 -1
  44. package/dist/components/RebaseLayout.js.map +1 -1
  45. package/dist/components/RebaseShell.d.ts +4 -1
  46. package/dist/components/RebaseShell.js.map +1 -1
  47. package/dist/components/SideDialogs.js +10 -4
  48. package/dist/components/SideDialogs.js.map +1 -1
  49. package/dist/components/app/Scaffold.js +5 -1
  50. package/dist/components/app/Scaffold.js.map +1 -1
  51. package/dist/components/field_configs.js +1 -1
  52. package/dist/components/history/EntityHistoryView.js +6 -4
  53. package/dist/components/history/EntityHistoryView.js.map +1 -1
  54. package/dist/components/history/LastEditedByIndicator.d.ts +2 -1
  55. package/dist/data_export/export/export.d.ts +2 -13
  56. package/dist/data_export/export/export.js +1 -36
  57. package/dist/data_export/export/export.js.map +1 -1
  58. package/dist/form/EntityForm.d.ts +1 -1
  59. package/dist/form/EntityForm.js +17 -13
  60. package/dist/form/EntityForm.js.map +1 -1
  61. package/dist/form/EntityFormBinding.d.ts +1 -1
  62. package/dist/form/EntityFormBinding.js +42 -4
  63. package/dist/form/EntityFormBinding.js.map +1 -1
  64. package/dist/form/PropertyFieldBinding.js +1 -1
  65. package/dist/form/components/FieldBlock.d.ts +8 -1
  66. package/dist/form/components/FieldBlock.js +16 -2
  67. package/dist/form/components/FieldBlock.js.map +1 -1
  68. package/dist/form/components/FormSections.js +1 -1
  69. package/dist/form/components/FormSections.js.map +1 -1
  70. package/dist/form/components/LabelWithIcon.js +5 -2
  71. package/dist/form/components/LabelWithIcon.js.map +1 -1
  72. package/dist/form/field_bindings/DateTimeFieldBinding.js +2 -1
  73. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  74. package/dist/form/field_bindings/ReadOnlyFieldBinding.js +28 -1
  75. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  76. package/dist/form/field_bindings/RelationFieldBinding.js +7 -3
  77. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  78. package/dist/form/field_bindings/SelectFieldBinding.js +63 -42
  79. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  80. package/dist/form/field_bindings/SwitchFieldBinding.js +2 -1
  81. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  82. package/dist/form/field_bindings/TextFieldBinding.js +8 -6
  83. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  84. package/dist/form/form_utils.d.ts +18 -1
  85. package/dist/form/form_utils.js +38 -2
  86. package/dist/form/form_utils.js.map +1 -1
  87. package/dist/form/index.d.ts +1 -1
  88. package/dist/form/label_placement.d.ts +23 -0
  89. package/dist/form/label_placement.js +71 -0
  90. package/dist/form/label_placement.js.map +1 -0
  91. package/dist/form/resolve_form_properties.d.ts +35 -3
  92. package/dist/form/resolve_form_properties.js +67 -6
  93. package/dist/form/resolve_form_properties.js.map +1 -1
  94. package/dist/hooks/useHistory.d.ts +5 -0
  95. package/dist/hooks/useHistory.js +22 -6
  96. package/dist/hooks/useHistory.js.map +1 -1
  97. package/dist/index.d.ts +50 -0
  98. package/dist/index.js +34 -7
  99. package/dist/preview/components/ReferencePreview.js +1 -1
  100. package/dist/preview/components/ReferencePreview.js.map +1 -1
  101. package/dist/preview/components/RelationPreview.js +1 -1
  102. package/dist/preview/components/RelationPreview.js.map +1 -1
  103. package/dist/types/components/EntityFormProps.d.ts +11 -0
  104. package/package.json +11 -10
  105. package/recipes/README.md +131 -0
  106. package/recipes/bulk-set-status.tsx +62 -0
  107. package/recipes/calendar-view.tsx +123 -0
  108. package/recipes/custom-login.tsx +60 -0
  109. package/recipes/my-preferences.tsx +68 -0
  110. package/recipes/orders-dashboard.tsx +125 -0
  111. package/recipes/site-settings.tsx +63 -0
@@ -1 +1 @@
1
- {"version":3,"file":"EntityTableCell.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCell.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { cls, Tooltip, iconSize } from \"@rebasepro/ui\";\nimport { ErrorBoundary, MinusCircleIcon } from \"@rebasepro/ui\";\nimport { getRowHeight, TableSize } from \"@rebasepro/app\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { TableCellOpener, TableCellOpenerKind } from \"./TableCellOpener\";\nimport { RowEntityPreviewLayout } from \"../../EntityPreviewNesting\";\n\nexport interface EntityTableCellOpener {\n kind: TableCellOpenerKind;\n open: boolean;\n /** See {@link TableCellOpener}'s `focusOnSelect`. */\n focusOnSelect: boolean;\n label: string;\n /**\n * Whether the editor should now be open, and the cell's rect for editors\n * positioned against it. The cell is selected before this is called.\n */\n onToggle: (open: boolean, cellRect: DOMRect | undefined) => void;\n}\n\ninterface EntityTableCellProps {\n children: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * The value is used only to check changes and force re-renders\n */\n value?: unknown;\n disabled: boolean;\n savedTimestamp?: number;\n error?: Error;\n allowScroll?: boolean;\n align: \"right\" | \"left\" | \"center\";\n size: TableSize;\n disabledTooltip?: string;\n width: number;\n showExpandIcon?: boolean;\n removePadding?: boolean;\n fullHeight?: boolean;\n selected?: boolean;\n hideOverflow?: boolean;\n /**\n * The control that opens the cell's editor, revealed on hover and kept\n * shown while the cell is selected. The cell keeps a slot for it at its\n * trailing edge either way, so it never moves the value.\n */\n opener?: EntityTableCellOpener;\n /** The cell's element, for editors that float and are positioned against it. */\n cellRef?: React.RefObject<HTMLDivElement | null>;\n onSelect?: (cellRect: DOMRect | undefined) => void;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, string | number | undefined>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n/**\n * One ResizeObserver for every table cell, instead of one per cell.\n *\n * A cell measures its content only to know whether it overflows the row (to\n * fade it, or let it scroll). Each cell ran `react-use-measure` for that: a\n * ResizeObserver, two window listeners, a `getComputedStyle` walk up every\n * ancestor and an extra render once the first measurement landed — ~460 of\n * each for one screen of a 20-column table, and more with every row scrolled\n * in. The observer is created on first use and lives for the page; a cell\n * registers on mount and unregisters on unmount, so nothing is retained for\n * a cell that is gone.\n */\nlet sharedHeightObserver: ResizeObserver | undefined;\nconst heightListeners = new Map<Element, (height: number) => void>();\n\nfunction observeHeight(element: Element, onHeight: (height: number) => void): () => void {\n if (typeof ResizeObserver === \"undefined\") return () => undefined;\n if (!sharedHeightObserver) {\n sharedHeightObserver = new ResizeObserver((entries) => {\n for (const entry of entries)\n heightListeners.get(entry.target)?.(entry.contentRect.height);\n });\n }\n heightListeners.set(element, onHeight);\n sharedHeightObserver.observe(element);\n return () => {\n heightListeners.delete(element);\n sharedHeightObserver?.unobserve(element);\n };\n}\n\n/** How many cells are being measured right now — for tests. */\nexport function measuredTableCellCount(): number {\n return heightListeners.size;\n}\n\n/**\n * Whether the element given to the returned ref is taller than `maxHeight`.\n * State changes only when the answer does, so a cell whose content fits is\n * never drawn again by its measurement.\n */\nfunction useOverflowsHeight(maxHeight: number): [(element: HTMLDivElement | null) => void, boolean] {\n const [overflowing, setOverflowing] = useState(false);\n const heightRef = useRef(0);\n const maxHeightRef = useRef(maxHeight);\n const stopRef = useRef<(() => void) | undefined>(undefined);\n\n useEffect(() => {\n maxHeightRef.current = maxHeight;\n setOverflowing(heightRef.current > maxHeight);\n }, [maxHeight]);\n\n useEffect(() => () => {\n stopRef.current?.();\n stopRef.current = undefined;\n }, []);\n\n const ref = useCallback((element: HTMLDivElement | null) => {\n stopRef.current?.();\n stopRef.current = undefined;\n if (!element) return;\n stopRef.current = observeHeight(element, (height) => {\n heightRef.current = height;\n setOverflowing(height > maxHeightRef.current);\n });\n }, []);\n\n return [ref, overflowing];\n}\n\ntype TableCellInnerProps = {\n justifyContent: string;\n scrollable: boolean;\n faded: boolean;\n fullHeight: boolean;\n children: React.ReactNode;\n}\n\nconst TableCellInner = ({\n justifyContent,\n scrollable,\n faded,\n fullHeight,\n children\n}: TableCellInnerProps) => {\n return (\n <div className={cls(\"flex flex-col max-h-full w-full\",\n {\n \"items-start\": faded || scrollable\n })}\n style={{\n justifyContent,\n height: fullHeight ? \"100%\" : undefined,\n overflow: scrollable ? \"auto\" : undefined,\n WebkitMaskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined,\n maskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined\n }}\n >\n {children}\n </div>\n );\n};\n\nexport const EntityTableCell = React.memo<EntityTableCellProps>(\n function EntityTableCell({\n children,\n actions,\n size,\n selected,\n disabled,\n disabledTooltip,\n savedTimestamp,\n error,\n align,\n allowScroll,\n removePadding,\n fullHeight,\n opener,\n cellRef,\n onSelect,\n width,\n hideOverflow = true,\n showExpandIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: EntityTableCellProps) {\n\n const internalRef = useRef<HTMLDivElement>(null);\n const ref = cellRef ?? internalRef;\n\n const maxHeight = useMemo(() => getRowHeight(size), [size]);\n const [measureRef, isOverflowing] = useOverflowsHeight(maxHeight);\n\n const [onHover, setOnHover] = useState(false);\n const [showSaved, setShowSaved] = useState(false);\n\n const showError = !disabled && Boolean(error);\n\n useEffect(() => {\n if (savedTimestamp && savedTimestamp > 0) {\n setShowSaved(true);\n const handler = setTimeout(() => {\n setShowSaved(false);\n }, 400);\n return () => {\n clearTimeout(handler);\n };\n }\n return undefined;\n }, [savedTimestamp]);\n\n let p = 0;\n if (!removePadding) {\n switch (size) {\n case \"l\":\n case \"xl\":\n p = 4;\n break;\n case \"m\":\n p = 2;\n break;\n case \"s\":\n default:\n p = 1;\n break;\n }\n }\n\n let justifyContent;\n switch (align) {\n case \"right\":\n justifyContent = \"flex-end\";\n break;\n case \"center\":\n justifyContent = \"center\";\n break;\n case \"left\":\n default:\n justifyContent = \"flex-start\";\n }\n\n // const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {\n // if (event.detail === 3) {\n // doOpenPopup();\n // }\n // }, [doOpenPopup]);\n\n const onSelectCallback = useCallback(() => {\n if (!onSelect) return;\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n if (disabled) {\n onSelect(undefined);\n } else if (!selected && cellRect) {\n onSelect(cellRect);\n }\n }, [ref, onSelect, selected, disabled]);\n\n const onOpenerToggle = useCallback((open: boolean) => {\n if (!opener) return;\n const cellRect = ref.current?.getBoundingClientRect();\n if (open) onSelectCallback();\n opener.onToggle(open, cellRect);\n }, [opener, onSelectCallback, ref]);\n\n const onFocus = useCallback((event: React.SyntheticEvent<HTMLDivElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onSelectCallback();\n }, [onSelectCallback]);\n\n const isSelected = !showError && selected;\n\n const scrollable = !disabled && allowScroll && isOverflowing;\n const faded = !disabled && !allowScroll && isOverflowing;\n\n const setOnHoverTrue = useCallback(() => setOnHover(true), []);\n const setOnHoverFalse = useCallback(() => setOnHover(false), []);\n\n const borderClass = showError\n ? \"border-red-500\"\n : isSelected\n ? \"border-primary\"\n : \"border-transparent\";\n\n // A reference or relation inside a cell is drawn as a line of its row,\n // never as the form's card, which is taller than any row.\n const content = <RowEntityPreviewLayout><ErrorBoundary>\n\n {fullHeight && !faded && children}\n\n {(!fullHeight || faded) && <TableCellInner\n fullHeight={fullHeight ?? false}\n justifyContent={justifyContent}\n scrollable={scrollable ?? false}\n faded={faded}>\n\n {!fullHeight && <div ref={measureRef}\n style={{\n display: \"flex\",\n width: \"100%\",\n justifyContent,\n height: fullHeight ? \"100%\" : undefined\n }}>\n {children}\n </div>}\n\n </TableCellInner>}\n </ErrorBoundary></RowEntityPreviewLayout>;\n\n const result = <>\n <div\n className={cls(\n \"group/cell transition-colors duration-500\",\n `flex relative h-full rounded-md p-${p} border-4`,\n showSaved ? \"bg-primary/20 dark:bg-primary/20\" : (onHover && !disabled ? \"bg-surface-hover\" : \"\"),\n hideOverflow ? \"overflow-hidden\" : \"\",\n isSelected && !showSaved ? \"bg-surface-raised\" : \"\",\n borderClass\n )}\n ref={ref}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined,\n width: width ?? \"100%\",\n textAlign: align\n }}\n tabIndex={selected || disabled ? undefined : 0}\n onFocus={onFocus}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n >\n\n {opener\n // The value and the opener side by side. The wrapper takes\n // over what the cell itself does for a cell without one:\n // aligning the value, and centring it when it fits.\n ? <div className={\"flex flex-1 min-w-0 self-stretch\"}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined\n }}>\n {content}\n </div>\n : content}\n\n {opener && <div className={\"shrink-0 self-center flex items-center pl-1\"}>\n <TableCellOpener kind={opener.kind}\n open={opener.open}\n selected={Boolean(selected)}\n focusOnSelect={opener.focusOnSelect}\n label={opener.label}\n onToggle={onOpenerToggle}/>\n </div>}\n\n {actions}\n\n {/*{disabled && onHover && disabledTooltip &&*/}\n {/* <div className=\"absolute top-1 right-1 text-xs\">*/}\n {/* <Tooltip title={disabledTooltip}>*/}\n {/* <MinusCircleIcon size={iconSize.smallest} color={\"disabled\"} className={\"text-text-disabled\"} />*/}\n {/* </Tooltip>*/}\n {/* </div>}*/}\n\n </div>\n </>;\n\n // Wrap with sortable outer div when sortable props are provided\n // Remove tabIndex from attributes to avoid capturing focus before cell content\n const { tabIndex: _tabIndex, ...sortableAttrsWithoutTabIndex } = sortableAttributes ?? {};\n const sortableContent = sortableNodeRef ? (\n <div\n ref={sortableNodeRef}\n style={sortableStyle}\n className={cls(\n \"flex-shrink-0\",\n frozen && \"sticky left-0 z-10 bg-surface-card\"\n )}\n {...sortableAttrsWithoutTabIndex}\n >\n {showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result}\n </div>\n ) : (\n showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result\n );\n\n return sortableContent;\n }\n // Compared by every prop, its children included. It used to compare a\n // hand-picked list with `value` standing in for what the cell shows, so a\n // cell whose content changed without its value — a new preview for a\n // changed property, an additional column's new builder — kept showing the\n // old one. Its parents (`PropertyTableCell`, the table's cell renderer)\n // are memoised and draw it only when something changed.\n) as React.FunctionComponent<EntityTableCellProps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,IAAI;AACJ,IAAM,kCAAkB,IAAI,IAAuC;AAEnE,SAAS,cAAc,SAAkB,UAAgD;CACrF,IAAI,OAAO,mBAAmB,aAAa,aAAa,KAAA;CACxD,IAAI,CAAC,sBACD,uBAAuB,IAAI,gBAAgB,YAAY;EACnD,KAAK,MAAM,SAAS,SAChB,gBAAgB,IAAI,MAAM,MAAM,CAAC,GAAG,MAAM,YAAY,MAAM;CACpE,CAAC;CAEL,gBAAgB,IAAI,SAAS,QAAQ;CACrC,qBAAqB,QA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;KACb,UAAU,QAAQ,QAAQ;KAC1B,eAAe,OAAO;KACtB,OAAO,OAAO;KACd,UAAU;IAAgB,CAAA;GAC7B,CAAA;GAEJ;EASA;IACP,CAAA;CAIF,MAAM,EAAE,UAAU,WAAW,GAAG,iCAAiC,sBAAsB,CAAC;CA+BxF,OA9BwB,kBACpB,oBAAC,OAAD;EACI,KAAK;EACL,OAAO;EACP,WAAW,IACP,iBACA,UAAU,oCACd;EACA,GAAI;YAEH,YACG,oBAAC,cAAD;GACI,WAAW;GACX,OAAO;GACP,OAAO,OAAO,WAAW;aACxB;EACS,CAAA,IACd;CACH,CAAA,IAEL,YACI,oBAAC,cAAD;EACI,WAAW;EACX,OAAO;EACP,OAAO,OAAO,WAAW;YACxB;CACS,CAAA,IACd;AAIZ,CAOJ"}
1
+ {"version":3,"file":"EntityTableCell.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCell.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { cls, Tooltip, iconSize } from \"@rebasepro/ui\";\nimport { ErrorBoundary, MinusCircleIcon } from \"@rebasepro/ui\";\nimport { getRowHeight, TableSize } from \"@rebasepro/app\";\nimport { ErrorTooltip } from \"@rebasepro/app\";\nimport { TableCellOpener, TableCellOpenerKind } from \"./TableCellOpener\";\nimport { RowEntityPreviewLayout } from \"../../EntityPreviewNesting\";\n\nexport interface EntityTableCellOpener {\n kind: TableCellOpenerKind;\n open: boolean;\n /** See {@link TableCellOpener}'s `focusOnSelect`. */\n focusOnSelect: boolean;\n label: string;\n /**\n * Whether the editor should now be open, and the cell's rect for editors\n * positioned against it. The cell is selected before this is called.\n */\n onToggle: (open: boolean, cellRect: DOMRect | undefined) => void;\n}\n\nexport interface EntityTableCellProps {\n children: React.ReactNode;\n actions?: React.ReactNode;\n /**\n * The value is used only to check changes and force re-renders\n */\n value?: unknown;\n disabled: boolean;\n savedTimestamp?: number;\n error?: Error;\n allowScroll?: boolean;\n align: \"right\" | \"left\" | \"center\";\n size: TableSize;\n disabledTooltip?: string;\n width: number;\n showExpandIcon?: boolean;\n removePadding?: boolean;\n fullHeight?: boolean;\n selected?: boolean;\n hideOverflow?: boolean;\n /**\n * The control that opens the cell's editor, revealed on hover and kept\n * shown while the cell is selected. The cell keeps a slot for it at its\n * trailing edge either way, so it never moves the value.\n */\n opener?: EntityTableCellOpener;\n /** The cell's element, for editors that float and are positioned against it. */\n cellRef?: React.RefObject<HTMLDivElement | null>;\n onSelect?: (cellRect: DOMRect | undefined) => void;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, string | number | undefined>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n/**\n * One ResizeObserver for every table cell, instead of one per cell.\n *\n * A cell measures its content only to know whether it overflows the row (to\n * fade it, or let it scroll). Each cell ran `react-use-measure` for that: a\n * ResizeObserver, two window listeners, a `getComputedStyle` walk up every\n * ancestor and an extra render once the first measurement landed — ~460 of\n * each for one screen of a 20-column table, and more with every row scrolled\n * in. The observer is created on first use and lives for the page; a cell\n * registers on mount and unregisters on unmount, so nothing is retained for\n * a cell that is gone.\n */\nlet sharedHeightObserver: ResizeObserver | undefined;\nconst heightListeners = new Map<Element, (height: number) => void>();\n\nfunction observeHeight(element: Element, onHeight: (height: number) => void): () => void {\n if (typeof ResizeObserver === \"undefined\") return () => undefined;\n if (!sharedHeightObserver) {\n sharedHeightObserver = new ResizeObserver((entries) => {\n for (const entry of entries)\n heightListeners.get(entry.target)?.(entry.contentRect.height);\n });\n }\n heightListeners.set(element, onHeight);\n sharedHeightObserver.observe(element);\n return () => {\n heightListeners.delete(element);\n sharedHeightObserver?.unobserve(element);\n };\n}\n\n/** How many cells are being measured right now — for tests. */\nexport function measuredTableCellCount(): number {\n return heightListeners.size;\n}\n\n/**\n * Whether the element given to the returned ref is taller than `maxHeight`.\n * State changes only when the answer does, so a cell whose content fits is\n * never drawn again by its measurement.\n */\nfunction useOverflowsHeight(maxHeight: number): [(element: HTMLDivElement | null) => void, boolean] {\n const [overflowing, setOverflowing] = useState(false);\n const heightRef = useRef(0);\n const maxHeightRef = useRef(maxHeight);\n const stopRef = useRef<(() => void) | undefined>(undefined);\n\n useEffect(() => {\n maxHeightRef.current = maxHeight;\n setOverflowing(heightRef.current > maxHeight);\n }, [maxHeight]);\n\n useEffect(() => () => {\n stopRef.current?.();\n stopRef.current = undefined;\n }, []);\n\n const ref = useCallback((element: HTMLDivElement | null) => {\n stopRef.current?.();\n stopRef.current = undefined;\n if (!element) return;\n stopRef.current = observeHeight(element, (height) => {\n heightRef.current = height;\n setOverflowing(height > maxHeightRef.current);\n });\n }, []);\n\n return [ref, overflowing];\n}\n\ntype TableCellInnerProps = {\n justifyContent: string;\n scrollable: boolean;\n faded: boolean;\n fullHeight: boolean;\n children: React.ReactNode;\n}\n\nconst TableCellInner = ({\n justifyContent,\n scrollable,\n faded,\n fullHeight,\n children\n}: TableCellInnerProps) => {\n return (\n <div className={cls(\"flex flex-col max-h-full w-full\",\n {\n \"items-start\": faded || scrollable\n })}\n style={{\n justifyContent,\n height: fullHeight ? \"100%\" : undefined,\n overflow: scrollable ? \"auto\" : undefined,\n WebkitMaskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined,\n maskImage: faded\n ? \"linear-gradient(to bottom, black 60%, transparent 100%)\"\n : undefined\n }}\n >\n {children}\n </div>\n );\n};\n\nexport const EntityTableCell = React.memo<EntityTableCellProps>(\n function EntityTableCell({\n children,\n actions,\n size,\n selected,\n disabled,\n disabledTooltip,\n savedTimestamp,\n error,\n align,\n allowScroll,\n removePadding,\n fullHeight,\n opener,\n cellRef,\n onSelect,\n width,\n hideOverflow = true,\n showExpandIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: EntityTableCellProps) {\n\n const internalRef = useRef<HTMLDivElement>(null);\n const ref = cellRef ?? internalRef;\n\n const maxHeight = useMemo(() => getRowHeight(size), [size]);\n const [measureRef, isOverflowing] = useOverflowsHeight(maxHeight);\n\n const [onHover, setOnHover] = useState(false);\n const [showSaved, setShowSaved] = useState(false);\n\n const showError = !disabled && Boolean(error);\n\n useEffect(() => {\n if (savedTimestamp && savedTimestamp > 0) {\n setShowSaved(true);\n const handler = setTimeout(() => {\n setShowSaved(false);\n }, 400);\n return () => {\n clearTimeout(handler);\n };\n }\n return undefined;\n }, [savedTimestamp]);\n\n let p = 0;\n if (!removePadding) {\n switch (size) {\n case \"l\":\n case \"xl\":\n p = 4;\n break;\n case \"m\":\n p = 2;\n break;\n case \"s\":\n default:\n p = 1;\n break;\n }\n }\n\n let justifyContent;\n switch (align) {\n case \"right\":\n justifyContent = \"flex-end\";\n break;\n case \"center\":\n justifyContent = \"center\";\n break;\n case \"left\":\n default:\n justifyContent = \"flex-start\";\n }\n\n // const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {\n // if (event.detail === 3) {\n // doOpenPopup();\n // }\n // }, [doOpenPopup]);\n\n const onSelectCallback = useCallback(() => {\n if (!onSelect) return;\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n if (disabled) {\n onSelect(undefined);\n } else if (!selected && cellRect) {\n onSelect(cellRect);\n }\n }, [ref, onSelect, selected, disabled]);\n\n const onOpenerToggle = useCallback((open: boolean) => {\n if (!opener) return;\n const cellRect = ref.current?.getBoundingClientRect();\n if (open) onSelectCallback();\n opener.onToggle(open, cellRect);\n }, [opener, onSelectCallback, ref]);\n\n const onFocus = useCallback((event: React.SyntheticEvent<HTMLDivElement>) => {\n event.stopPropagation();\n event.preventDefault();\n onSelectCallback();\n }, [onSelectCallback]);\n\n const isSelected = !showError && selected;\n\n const scrollable = !disabled && allowScroll && isOverflowing;\n const faded = !disabled && !allowScroll && isOverflowing;\n\n const setOnHoverTrue = useCallback(() => setOnHover(true), []);\n const setOnHoverFalse = useCallback(() => setOnHover(false), []);\n\n const borderClass = showError\n ? \"border-red-500\"\n : isSelected\n ? \"border-primary\"\n : \"border-transparent\";\n\n // A reference or relation inside a cell is drawn as a line of its row,\n // never as the form's card, which is taller than any row.\n const content = <RowEntityPreviewLayout><ErrorBoundary>\n\n {fullHeight && !faded && children}\n\n {(!fullHeight || faded) && <TableCellInner\n fullHeight={fullHeight ?? false}\n justifyContent={justifyContent}\n scrollable={scrollable ?? false}\n faded={faded}>\n\n {!fullHeight && <div ref={measureRef}\n style={{\n display: \"flex\",\n width: \"100%\",\n justifyContent,\n height: fullHeight ? \"100%\" : undefined\n }}>\n {children}\n </div>}\n\n </TableCellInner>}\n </ErrorBoundary></RowEntityPreviewLayout>;\n\n const result = <>\n <div\n className={cls(\n \"group/cell transition-colors duration-500\",\n `flex relative h-full rounded-md p-${p} border-4`,\n showSaved ? \"bg-primary/20 dark:bg-primary/20\" : (onHover && !disabled ? \"bg-surface-hover\" : \"\"),\n hideOverflow ? \"overflow-hidden\" : \"\",\n isSelected && !showSaved ? \"bg-surface-raised\" : \"\",\n borderClass\n )}\n ref={ref}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined,\n width: width ?? \"100%\",\n textAlign: align\n }}\n tabIndex={selected || disabled ? undefined : 0}\n onFocus={onFocus}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n >\n\n {opener\n // The value and the opener side by side. The wrapper takes\n // over what the cell itself does for a cell without one:\n // aligning the value, and centring it when it fits.\n ? <div className={\"flex flex-1 min-w-0 self-stretch\"}\n style={{\n justifyContent,\n alignItems: disabled || !isOverflowing ? \"center\" : undefined\n }}>\n {content}\n </div>\n : content}\n\n {opener && <div className={\"shrink-0 self-center flex items-center pl-1\"}>\n <TableCellOpener kind={opener.kind}\n open={opener.open}\n selected={Boolean(selected)}\n focusOnSelect={opener.focusOnSelect}\n label={opener.label}\n onToggle={onOpenerToggle}/>\n </div>}\n\n {actions}\n\n {/*{disabled && onHover && disabledTooltip &&*/}\n {/* <div className=\"absolute top-1 right-1 text-xs\">*/}\n {/* <Tooltip title={disabledTooltip}>*/}\n {/* <MinusCircleIcon size={iconSize.smallest} color={\"disabled\"} className={\"text-text-disabled\"} />*/}\n {/* </Tooltip>*/}\n {/* </div>}*/}\n\n </div>\n </>;\n\n // Wrap with sortable outer div when sortable props are provided\n // Remove tabIndex from attributes to avoid capturing focus before cell content\n const { tabIndex: _tabIndex, ...sortableAttrsWithoutTabIndex } = sortableAttributes ?? {};\n const sortableContent = sortableNodeRef ? (\n <div\n ref={sortableNodeRef}\n style={sortableStyle}\n className={cls(\n \"flex-shrink-0\",\n frozen && \"sticky left-0 z-10 bg-surface-card\"\n )}\n {...sortableAttrsWithoutTabIndex}\n >\n {showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result}\n </div>\n ) : (\n showError ? (\n <ErrorTooltip\n className={\"flex h-full w-full\"}\n align={\"start\"}\n title={error?.message ?? \"Error\"}>\n {result}\n </ErrorTooltip>\n ) : result\n );\n\n return sortableContent;\n }\n // Compared by every prop, its children included. It used to compare a\n // hand-picked list with `value` standing in for what the cell shows, so a\n // cell whose content changed without its value — a new preview for a\n // changed property, an additional column's new builder — kept showing the\n // old one. Its parents (`PropertyTableCell`, the table's cell renderer)\n // are memoised and draw it only when something changed.\n) as React.FunctionComponent<EntityTableCellProps>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,IAAI;AACJ,IAAM,kCAAkB,IAAI,IAAuC;AAEnE,SAAS,cAAc,SAAkB,UAAgD;CACrF,IAAI,OAAO,mBAAmB,aAAa,aAAa,KAAA;CACxD,IAAI,CAAC,sBACD,uBAAuB,IAAI,gBAAgB,YAAY;EACnD,KAAK,MAAM,SAAS,SAChB,gBAAgB,IAAI,MAAM,MAAM,CAAC,GAAG,MAAM,YAAY,MAAM;CACpE,C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vB,oBAAC,iBAAD;KAAiB,MAAM,OAAO;KAC1B,MAAM,OAAO;KACb,UAAU,QAAQ,QAAQ;KAC1B,eAAe,OAAO;KACtB,OAAO,OAAO;KACd,UAAU;IAAgB,CAAA;GAC7B,CAAA;GAEJ;EASA;IACP,CAAA;CAIF,MAAM,EAAE,UAAU,WAAW,GAAG,iCAAiC,sBAAsB,CAAC;CA+BxF,OA9BwB,kBACpB,oBAAC,OAAD;EACI,KAAK;EACL,OAAO;EACP,WAAW,IACP,iBACA,UAAU,oCACd;EACA,GAAI;YAEH,YACG,oBAAC,cAAD;GACI,WAAW;GACX,OAAO;GACP,OAAO,OAAO,WAAW;aACxB;EACS,CAAA,IACd;CACH,CAAA,IAEL,YACI,oBAAC,cAAD;EACI,WAAW;EACX,OAAO;EACP,OAAO,OAAO,WAAW;YACxB;CACS,CAAA,IACd;AAIZ,CAOJ"}
@@ -114,7 +114,7 @@ function CollectionViewActions({ collection, relativePath, parentCollectionSlugs
114
114
  fallback: null,
115
115
  children: /* @__PURE__ */ jsx(ImportCollectionAction, { ...actionProps })
116
116
  }) }),
117
- /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
117
+ collection.exportable !== false && /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
118
118
  fallback: null,
119
119
  children: /* @__PURE__ */ jsx(ExportCollectionAction, { ...actionProps })
120
120
  }) }),
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useLargeLayout, useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, PlusIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: SelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canCreate, canDelete } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const toolbarLabels = useToolbarLabels();\n // Labelled controls on a wide layout whose toolbar has room for them;\n // their icon-only forms otherwise.\n const labelled = largeLayout && !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = canCreate(collection, path) &&\n onNewClick && (labelled\n ? <Button\n id={`add_entity_${path}`}\n onClick={onNewClick}\n startIcon={<PlusIcon size={iconSize.small}/>}\n size=\"small\"\n variant=\"filled\"\n color=\"primary\">\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n // In the compact split-list toolbar the add action is the one filled\n // control: a rounded square, so it reads as a button and not a badge.\n : <IconButton\n id={`add_entity_${path}`}\n onClick={onNewClick}\n variant=\"filled\"\n shape=\"square\"\n size=\"small\"\n aria-label={t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n >\n <PlusIcon size={iconSize.small}/>\n </IconButton>);\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"lg:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={t(\"delete_selected\")}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n const actionProps: CollectionActionsProps<M> = {\n path,\n relativePath,\n parentCollectionSlugs,\nparentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {multipleDeleteButton}\n {linkButton}\n {addButton}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AACpI,IAAM,yBAAyB,gBAAgB,OAAO,oCAA2B,CAAC,MAAK,OAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAgCpI,SAAgB,sBAAyD,EACrE,YACA,cACA,uBAAuB,iBACvB,YACA,oBACA,uBACA,eACA,kBACA,MACA,qBACA,iBACA,yBACA,SACA,UACA,mBAC8B;CAC9B,MAAM,UAAU,gBAAgB;CAEhC,MAAM,EAAE,WAAW,cAAc,eAAe;CAEhD,MAAM,cAAc,eAAe;CACnC,MAAM,gBAAgB,iBAAiB;CAGvC,MAAM,WAAW,eAAe,CAAC,WAAW;CAC5C,MAAM,EAAE,MAAM,eAAe;CAG7B,MAAM,6BAA6B,8BAA8B;CACjE,MAAM,sBAAsB,QA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,WAAU;YAAf;GACK,CAAC,UACE,mBAEA,oBAAC,SAAD;IACI,MAAM;IACN,cAAc;IACd,SACI,oBAAC,YAAD;KAAY,cAAY,EAAE,cAAc;KAAG,MAAK;eAC5C,oBAAC,kBAAD,EAAkB,MAAM,SAAS,SAAU,CAAA;IACnC,CAAA;cAEhB,oBAAC,OAAD;KAAK,WAAU;eACV;IACA,CAAA;GACA,CAAA;GAEZ;GACA;GACA;EACA;;AAEb"}
1
+ {"version":3,"file":"CollectionViewActions.js","names":[],"sources":["../../../src/components/CollectionViewBinding/CollectionViewActions.tsx"],"sourcesContent":["\n\nimport React, { Suspense } from \"react\";\n\nimport { useLargeLayout, useTranslation, useSlot, resolveComponentRef } from \"@rebasepro/app\";\nimport { CollectionActionsProps, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Button, IconButton, Tooltip, Popover, iconSize, lazyChunk } from \"@rebasepro/ui\";\nimport { ErrorBoundary, Link2Icon, MoreVerticalIcon, PlusIcon, Trash2Icon, Unlink2Icon } from \"@rebasepro/ui\";\nimport { usePermissions } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\n// Lazy-load import/export — pulls in exceljs only on demand\nconst ImportCollectionAction = lazyChunk(() => import(\"../../data_import/import\").then(m => ({ default: m.ImportCollectionAction })));\nconst ExportCollectionAction = lazyChunk(() => import(\"../../data_export/export\").then(m => ({ default: m.ExportCollectionAction })));\nimport { EditorCollectionAction } from \"../../collection_editor/ui/EditorCollectionAction\";\nimport { useCollectionEditorController } from \"../../collection_editor/useCollectionEditorController\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useToolbarLabels } from \"../CollectionTableBinding/internal/CollectionTableToolbar\";\n\nexport type CollectionViewActionsProps<M extends Record<string, unknown>> = {\n collection: AdminCollection<M>;\n path: string;\n relativePath: string;\n parentCollectionSlugs: string[], parentEntityIds: string[];\n selectionEnabled: boolean;\n onNewClick: () => void;\n /**\n * Attach a row that already exists to this parent. Only supplied for a\n * junction-backed tab, where the parent owns the link rather than the row.\n */\n onAddExistingClick?: () => void;\n onMultipleDeleteClick: () => void;\n /**\n * The rows are shared with other records through a junction, so removing\n * them unlinks them from this record and deletes nothing. The bin says so.\n */\n removeUnlinks?: boolean;\n selectionController: SelectionController<M>;\n tableController: EntityTableController<M>;\n collectionEntitiesCount?: number;\n compact?: boolean;\n children?: React.ReactNode;\n openNewDocument: (defaultValues?: Record<string, unknown>) => void;\n}\n\nexport function CollectionViewActions<M extends Record<string, unknown>>({\n collection,\n relativePath,\n parentCollectionSlugs, parentEntityIds,\n onNewClick,\n onAddExistingClick,\n onMultipleDeleteClick,\n removeUnlinks,\n selectionEnabled,\n path,\n selectionController,\n tableController,\n collectionEntitiesCount,\n compact,\n children,\n openNewDocument\n}: CollectionViewActionsProps<M>) {\n const context = useAdminContext();\n\n const { canCreate, canDelete } = usePermissions();\n\n const largeLayout = useLargeLayout();\n const toolbarLabels = useToolbarLabels();\n // Labelled controls on a wide layout whose toolbar has room for them;\n // their icon-only forms otherwise.\n const labelled = largeLayout && !compact && toolbarLabels;\n const { t } = useTranslation();\n\n // Check if the collection editor context is available (ConfigControllerProvider present)\n const collectionEditorController = useCollectionEditorController();\n const hasCollectionEditor = Boolean(collectionEditorController?.editCollection);\n\n const { selectedCount, hasSelection } = selectionController;\n\n const addButton = canCreate(collection, path) &&\n onNewClick && (labelled\n ? <Button\n id={`add_entity_${path}`}\n onClick={onNewClick}\n startIcon={<PlusIcon size={iconSize.small}/>}\n size=\"small\"\n variant=\"filled\"\n color=\"primary\">\n {t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </Button>\n // In the compact split-list toolbar the add action is the one filled\n // control: a rounded square, so it reads as a button and not a badge.\n : <IconButton\n id={`add_entity_${path}`}\n onClick={onNewClick}\n variant=\"filled\"\n shape=\"square\"\n size=\"small\"\n aria-label={t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n >\n <PlusIcon size={iconSize.small}/>\n </IconButton>);\n\n // On a junction-backed tab, creating a row is only half of what \"add\" means:\n // the far more common act is attaching one that already exists. There was no\n // way to do that at all — the junction row was only ever written alongside an\n // insert — so a shared vocabulary could only ever grow.\n const linkButton = onAddExistingClick && (labelled\n ? <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n startIcon={<Link2Icon size={iconSize.small}/>}\n size=\"small\"\n variant=\"outlined\"\n color=\"neutral\">\n {t(\"add_existing\")}\n </Button>\n : <Tooltip title={t(\"add_existing\")}>\n <Button\n id={`link_entity_${path}`}\n onClick={onAddExistingClick}\n variant=\"outlined\"\n color=\"neutral\"\n size=\"small\">\n <Link2Icon size={iconSize.small}/>\n </Button>\n </Tooltip>);\n\n const multipleDeleteEnabled = canDelete(collection, path, null);\n\n // Only once something is selected. A permanently-disabled bin sat in every\n // collection toolbar — and in the split view, where the toolbar is a narrow\n // strip above the list, it was a third of the visible controls doing\n // nothing. It appears the moment you tick a row, which is when you want it.\n\n // `undefined` is \"every matching row, and nobody knows how many\" — a full\n // selection against an accessor with no `count`. Rendering it as 0 would\n // say the opposite of what is true.\n const countLabel = selectedCount === undefined ? \"…\" : selectedCount.toLocaleString();\n\n let multipleDeleteButton: React.ReactNode | undefined;\n if (hasSelection) {\n const RemoveIcon = removeUnlinks ? Unlink2Icon : Trash2Icon;\n const button = labelled\n // `min-w`, not `w`. A fixed 80px was enough for the one- and\n // two-digit counts you could reach by ticking rows; \"select all\n // matching\" put six digits in here, and a flex child over its width\n // compresses — so the bin itself was what gave way, shrinking to a\n // sliver beside the number. The width is a floor now, so the\n // control still holds its place in the toolbar when the count is\n // short, and `shrink-0` means the icon can never be the thing that\n // gives.\n ? <Button\n variant={\"text\"}\n disabled={!multipleDeleteEnabled}\n startIcon={<RemoveIcon size={iconSize.small} className={\"shrink-0\"}/>}\n onClick={onMultipleDeleteClick}\n color={\"neutral\"}\n className=\"lg:min-w-20\"\n >\n ({countLabel})\n </Button>\n : <IconButton aria-label={t(\"delete_selected\")}\n size={\"small\"}\n disabled={!multipleDeleteEnabled}\n onClick={onMultipleDeleteClick}>\n <RemoveIcon size={iconSize.small}/>\n </IconButton>;\n multipleDeleteButton =\n <Tooltip\n title={multipleDeleteEnabled\n ? (removeUnlinks ? t(\"remove_from_record\") : t(\"delete\"))\n : t(\"delete_not_allowed\")}>\n {button}\n </Tooltip>\n }\n\n const actionProps: CollectionActionsProps<M> = {\n path,\n relativePath,\n parentCollectionSlugs,\nparentEntityIds,\n collection,\n selectionController,\n context,\n tableController,\n collectionEntitiesCount,\n openNewDocument\n };\n\n const actions = toArray(collection.Actions)\n .map((actionRef, i) => {\n const Action = resolveComponentRef(actionRef);\n if (!Action) return null;\n return (\n <ErrorBoundary key={`actions_${i}`}>\n <Suspense fallback={null}>\n <Action {...actionProps}/>\n </Suspense>\n </ErrorBoundary>\n );\n });\n\n const pluginActions = useSlot(\"collection.actions\", actionProps as CollectionActionsProps);\n\n const secondaryActions = (\n <>\n {children}\n <ErrorBoundary>\n {actions}\n {pluginActions}\n </ErrorBoundary>\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ImportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n {collection.exportable !== false && (\n <ErrorBoundary>\n <Suspense fallback={null}>\n <ExportCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </Suspense>\n </ErrorBoundary>\n )}\n {hasCollectionEditor && (\n <ErrorBoundary>\n <EditorCollectionAction {...(actionProps as CollectionActionsProps)}/>\n </ErrorBoundary>\n )}\n </>\n );\n\n const [overflowOpen, setOverflowOpen] = React.useState(false);\n\n return (\n <div className=\"flex items-center gap-1\">\n {!compact ? (\n secondaryActions\n ) : (\n <Popover\n open={overflowOpen}\n onOpenChange={setOverflowOpen}\n trigger={\n <IconButton aria-label={t(\"more_actions\")} size=\"small\">\n <MoreVerticalIcon size={iconSize.smallest}/>\n </IconButton>\n }>\n <div className=\"flex flex-row items-center gap-1 p-2\">\n {secondaryActions}\n </div>\n </Popover>\n )}\n {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OACI,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;IAAU,UAAU;cAChB,oBAAC,QAAD,EAAQ,GAAI,YAAa,CAAA;GACnB,CAAA,EACC,GAJK,WAAW,GAIhB;EAEvB,CAQS,GANS,QAAQ,sBAAsB,WAOvC,CACU,EAAA,CAAA;EACf,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EACd,WAAW,eAAe,SACvB,oBAAC,eAAD,EAAA,UACI,oBAAC,UAAD;GAAU,UAAU;aAChB,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA;EAC/D,CAAA,EACC,CAAA;EAElB,uBACG,oBAAC,eAAD,EAAA,UACI,oBAAC,wBAAD,EAAwB,GAAK,YAAwC,CAAA,EAC1D,CAAA;CAErB,EAAA,CAAA;CAGN,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAE5D,OACI,qBAAC,OAAD;EAAK,WAAU;YAAf;GACK,CAAC,UACE,mBAEA,oBAAC,SAAD;IACI,MAAM;IACN,cAAc;IACd,SACI,oBAAC,YAAD;KAAY,cAAY,EAAE,cAAc;KAAG,MAAK;eAC5C,oBAAC,kBAAD,EAAkB,MAAM,SAAS,SAAU,CAAA;IACnC,CAAA;cAEhB,oBAAC,OAAD;KAAK,WAAU;eACV;IACA,CAAA;GACA,CAAA;GAEZ;GACA;GACA;EACA;;AAEb"}
@@ -25,6 +25,7 @@ import { useChildViewSource } from "../../hooks/useChildViewSource.js";
25
25
  import { SplitListView } from "./SplitListView.js";
26
26
  import { CollectionBoardViewBinding } from "./CollectionBoardViewBinding.js";
27
27
  import { ViewModeToggle } from "./ViewModeToggle.js";
28
+ import { DefaultCollectionEmptyState } from "./DefaultCollectionEmptyState.js";
28
29
  import { resolveCellProperty } from "../../form/resolve_cell_property.js";
29
30
  import { PopupFormField } from "../CollectionTableBinding/internal/popup_field/PopupFormField.js";
30
31
  import { DeleteEntityDialog } from "../DeleteEntityDialog.js";
@@ -32,7 +33,7 @@ import { CollectionViewStartActions } from "./CollectionViewStartActions.js";
32
33
  import React, { useCallback, useEffect, useMemo, useState } from "react";
33
34
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
34
35
  import { deepEqual, shallowEqual } from "fast-equals";
35
- import { Alert, ArrowRightToLineIcon, Button, ErrorBoundary, IconButton, PlusIcon, Popover, SearchIcon, TextField, Tooltip, Typography, cls, focusedDisabled, iconSize } from "@rebasepro/ui";
36
+ import { Alert, ArrowRightToLineIcon, Button, ErrorBoundary, IconButton, Popover, SearchIcon, TextField, Tooltip, Typography, cls, focusedDisabled, iconSize } from "@rebasepro/ui";
36
37
  import { getEntityChildViews, serializeOrderBy } from "@rebasepro/common";
37
38
  import { CollectionScopeProvider, getRedundantChildViewColumnIds, populateFetchCache, resolveComponentRef, saveEntityWithCallbacks, useAnalyticsController, useAuthController, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataTableController, useLargeLayout, usePermissions, useScrollRestoration, useSlot, useTranslation, useUserConfigurationPersistence } from "@rebasepro/app";
38
39
  import { EntityReference, getCollectionDataPath } from "@rebasepro/types";
@@ -1023,33 +1024,6 @@ var CollectionViewBinding = React.memo(function CollectionViewBinding(props) {
1023
1024
  return content;
1024
1025
  });
1025
1026
  /**
1026
- * Default empty state shown when a collection has no entities.
1027
- * Used as the fallback for the `"Collection.EmptyState"` component override.
1028
- *
1029
- * @internal
1030
- */
1031
- function DefaultCollectionEmptyState({ canCreate, onNewClick, isSearching, isFiltered, searchString }) {
1032
- const { t } = useTranslation();
1033
- if (canCreate) return /* @__PURE__ */ jsxs("div", {
1034
- className: "flex flex-col items-center justify-center",
1035
- children: [/* @__PURE__ */ jsx(Typography, {
1036
- variant: "subtitle2",
1037
- children: t("so_empty")
1038
- }), /* @__PURE__ */ jsxs(Button, {
1039
- onClick: onNewClick,
1040
- className: "mt-4",
1041
- children: [/* @__PURE__ */ jsx(PlusIcon, {}), t("create_your_first_entry")]
1042
- })]
1043
- });
1044
- let message = t("no_entries_found");
1045
- if (isSearching) message = t("no_results_search", { search: searchString });
1046
- else if (isFiltered) message = t("no_results_filter");
1047
- return /* @__PURE__ */ jsx(Typography, {
1048
- variant: "label",
1049
- children: message
1050
- });
1051
- }
1052
- /**
1053
1027
  * Inflight count request deduplication map.
1054
1028
  * Keyed by `path|filterKey|sort|search` so that concurrent
1055
1029
  * callers (e.g. React StrictMode double-mount) share the same promise.