@ynput/ayon-frontend-shared 0.3.49 → 0.3.51

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 (108) hide show
  1. package/dist/Slicer.cjs.js +1 -1
  2. package/dist/Slicer.es.js +13 -11
  3. package/dist/Slicer.es.js.map +1 -1
  4. package/dist/_virtual/index.cjs10.js +1 -1
  5. package/dist/_virtual/index.cjs11.js +1 -1
  6. package/dist/_virtual/index.cjs12.js +1 -1
  7. package/dist/_virtual/index.cjs5.js +1 -1
  8. package/dist/_virtual/index.cjs6.js +1 -1
  9. package/dist/_virtual/index.es10.js +3 -3
  10. package/dist/_virtual/index.es11.js +5 -5
  11. package/dist/_virtual/index.es12.js +5 -5
  12. package/dist/_virtual/index.es5.js +5 -2
  13. package/dist/_virtual/index.es5.js.map +1 -1
  14. package/dist/_virtual/index.es6.js +2 -5
  15. package/dist/_virtual/index.es6.js.map +1 -1
  16. package/dist/components.cjs.js +1 -1
  17. package/dist/components.es.js +112 -109
  18. package/dist/components.es.js.map +1 -1
  19. package/dist/node_modules/rehype/node_modules/unified/lib/index.cjs.js +1 -1
  20. package/dist/node_modules/rehype/node_modules/unified/lib/index.es.js +2 -2
  21. package/dist/node_modules/rehype/node_modules/vfile/lib/index.cjs.js +1 -1
  22. package/dist/node_modules/rehype/node_modules/vfile/lib/index.es.js +1 -1
  23. package/dist/node_modules/rehype-parse/lib/index.cjs.js +1 -1
  24. package/dist/node_modules/rehype-parse/lib/index.es.js +1 -1
  25. package/dist/node_modules/remove-accents/index.cjs.js +1 -1
  26. package/dist/node_modules/remove-accents/index.es.js +1 -1
  27. package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.cjs.js +1 -1
  28. package/dist/shared/node_modules/react-transition-group/esm/CSSTransition.es.js +1 -1
  29. package/dist/shared/node_modules/react-transition-group/esm/Transition.cjs.js +1 -1
  30. package/dist/shared/node_modules/react-transition-group/esm/Transition.es.js +1 -1
  31. package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.cjs.js +1 -1
  32. package/dist/shared/node_modules/react-transition-group/esm/utils/PropTypes.es.js +1 -1
  33. package/dist/shared/src/api/generated/graphql.cjs.js +1 -1
  34. package/dist/shared/src/api/generated/graphql.cjs.js.map +1 -1
  35. package/dist/shared/src/api/generated/graphql.es.js +1 -1
  36. package/dist/shared/src/api/generated/graphql.es.js.map +1 -1
  37. package/dist/shared/src/api/queries/columnStats/columnStats.cjs.js +1 -1
  38. package/dist/shared/src/api/queries/columnStats/columnStats.cjs.js.map +1 -1
  39. package/dist/shared/src/api/queries/columnStats/columnStats.es.js +56 -44
  40. package/dist/shared/src/api/queries/columnStats/columnStats.es.js.map +1 -1
  41. package/dist/shared/src/api/queries/columnStats/groupCounts.cjs.js +1 -1
  42. package/dist/shared/src/api/queries/columnStats/groupCounts.cjs.js.map +1 -1
  43. package/dist/shared/src/api/queries/columnStats/groupCounts.es.js +10 -8
  44. package/dist/shared/src/api/queries/columnStats/groupCounts.es.js.map +1 -1
  45. package/dist/shared/src/components/LinksManager/LinksManager.cjs.js.map +1 -1
  46. package/dist/shared/src/components/LinksManager/LinksManager.es.js.map +1 -1
  47. package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js +1 -1
  48. package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js.map +1 -1
  49. package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js +220 -216
  50. package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js.map +1 -1
  51. package/dist/shared/src/containers/DetailsPanel/components/DetailsPanelMoreMenu/hooks/useMenuOptions.cjs.js +1 -1
  52. package/dist/shared/src/containers/DetailsPanel/components/DetailsPanelMoreMenu/hooks/useMenuOptions.cjs.js.map +1 -1
  53. package/dist/shared/src/containers/DetailsPanel/components/DetailsPanelMoreMenu/hooks/useMenuOptions.es.js +1 -1
  54. package/dist/shared/src/containers/DetailsPanel/components/DetailsPanelMoreMenu/hooks/useMenuOptions.es.js.map +1 -1
  55. package/dist/shared/src/containers/Feed/components/FeedSearchFilter.cjs.js +2 -2
  56. package/dist/shared/src/containers/Feed/components/FeedSearchFilter.cjs.js.map +1 -1
  57. package/dist/shared/src/containers/Feed/components/FeedSearchFilter.es.js +138 -127
  58. package/dist/shared/src/containers/Feed/components/FeedSearchFilter.es.js.map +1 -1
  59. package/dist/shared/src/containers/Feed/context/FeedContext.cjs.js.map +1 -1
  60. package/dist/shared/src/containers/Feed/context/FeedContext.es.js.map +1 -1
  61. package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js +1 -1
  62. package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js.map +1 -1
  63. package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js +56 -55
  64. package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js.map +1 -1
  65. package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.cjs.js +1 -1
  66. package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.cjs.js.map +1 -1
  67. package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.es.js +249 -254
  68. package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.es.js.map +1 -1
  69. package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupCounts.cjs.js.map +1 -1
  70. package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupCounts.es.js.map +1 -1
  71. package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js +1 -1
  72. package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js.map +1 -1
  73. package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js +41 -40
  74. package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js.map +1 -1
  75. package/dist/shared/src/containers/Slicer/components/Slicer.cjs.js +2 -2
  76. package/dist/shared/src/containers/Slicer/components/Slicer.cjs.js.map +1 -1
  77. package/dist/shared/src/containers/Slicer/components/Slicer.es.js +55 -47
  78. package/dist/shared/src/containers/Slicer/components/Slicer.es.js.map +1 -1
  79. package/dist/shared/src/containers/Slicer/hooks/useSlicerCounts.cjs.js +2 -0
  80. package/dist/shared/src/containers/Slicer/hooks/useSlicerCounts.cjs.js.map +1 -0
  81. package/dist/shared/src/containers/Slicer/hooks/useSlicerCounts.es.js +319 -0
  82. package/dist/shared/src/containers/Slicer/hooks/useSlicerCounts.es.js.map +1 -0
  83. package/dist/shared/src/containers/Slicer/hooks/useTableDataBySlice.cjs.js +1 -1
  84. package/dist/shared/src/containers/Slicer/hooks/useTableDataBySlice.cjs.js.map +1 -1
  85. package/dist/shared/src/containers/Slicer/hooks/useTableDataBySlice.es.js +118 -104
  86. package/dist/shared/src/containers/Slicer/hooks/useTableDataBySlice.es.js.map +1 -1
  87. package/dist/shared/src/context/DetailsPanelContext.cjs.js +1 -1
  88. package/dist/shared/src/context/DetailsPanelContext.cjs.js.map +1 -1
  89. package/dist/shared/src/context/DetailsPanelContext.es.js +57 -55
  90. package/dist/shared/src/context/DetailsPanelContext.es.js.map +1 -1
  91. package/dist/shared/src/util/confirmDelete.cjs.js +1 -1
  92. package/dist/shared/src/util/confirmDelete.cjs.js.map +1 -1
  93. package/dist/shared/src/util/confirmDelete.es.js +28 -24
  94. package/dist/shared/src/util/confirmDelete.es.js.map +1 -1
  95. package/dist/types/components/index.d.ts +1 -0
  96. package/dist/types/containers/Feed/components/FeedSearchFilter.d.ts +2 -2
  97. package/dist/types/containers/ProjectTreeTable/hooks/useGroupCounts.d.ts +2 -3
  98. package/dist/types/containers/ProjectTreeTable/types/overviewContext.d.ts +8 -0
  99. package/dist/types/containers/ProjectTreeTable/types/table.d.ts +0 -1
  100. package/dist/types/containers/SimpleTable/SimpleTable.types.d.ts +1 -0
  101. package/dist/types/containers/Slicer/components/Slicer.d.ts +2 -0
  102. package/dist/types/containers/Slicer/hooks/index.d.ts +1 -0
  103. package/dist/types/containers/Slicer/hooks/useSlicerCounts.d.ts +17 -0
  104. package/dist/types/containers/Slicer/hooks/useTableDataBySlice.d.ts +5 -1
  105. package/dist/types/util/confirmDelete.d.ts +3 -1
  106. package/dist/util.cjs.js +1 -1
  107. package/dist/util.es.js +77 -76
  108. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleTable.cjs.js","sources":["../../../../../src/containers/SimpleTable/SimpleTable.tsx"],"sourcesContent":["import { FC, useMemo, useRef, MouseEvent as ReactMouseEvent, useCallback, useEffect } from 'react'\nimport * as Styled from './SimpleTable.styled'\nimport {\n useReactTable,\n getCoreRowModel,\n getFilteredRowModel,\n getExpandedRowModel,\n ColumnDef,\n flexRender,\n Row,\n FilterFn,\n SortingFn,\n sortingFns,\n Table,\n RowData,\n OnChangeFn,\n RowSelectionState,\n functionalUpdate,\n} from '@tanstack/react-table'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport clsx from 'clsx'\nimport useRowKeydown, { RowKeyboardEvent } from './hooks/useRowKeydown'\n\nimport { rankItem, compareItems, rankings } from '@tanstack/match-sorter-utils'\nimport { useSimpleTableContext } from './context/SimpleTableContext'\nimport { SimpleTableCellTemplate, SimpleTableCellTemplateProps } from './SimpleTableRowTemplate'\nimport { EmptyPlaceholder } from '@shared/components'\nimport { RowPinningState } from '@tanstack/react-table'\nimport {\n SimpleTableProps,\n SimpleTableRow,\n SimpleTableRowContextMenuBuilder,\n} from './SimpleTable.types'\nimport { useCreateContextMenu } from '../ContextMenu'\n\nconst toMenuItems = (items: ReturnType<SimpleTableRowContextMenuBuilder>) => {\n if (!items) return []\n return Array.isArray(items) ? items.filter(Boolean) : [items]\n}\n\n// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)\nconst fuzzyFilter: FilterFn<any> = (row, columnId, searchValue, addMeta) => {\n const cellValue = row.getValue(columnId)\n // convert non-string cell values to string\n let searchString =\n typeof cellValue === 'string'\n ? cellValue\n : Array.isArray(cellValue)\n ? cellValue.join(' ')\n : JSON.stringify(cellValue)\n\n // combine label and parents into a single string for searching if columnId is 'label'\n if (columnId === 'label') {\n searchString = [row.original.label, row.original.name, ...(row.original.parents || [])].join(\n ' ',\n )\n }\n\n // Rank the item with CONTAINS threshold to avoid overly permissive fuzzy matches\n // This ensures the search term must be a substring, not just scattered characters\n const itemRank = rankItem(searchString, searchValue, { threshold: rankings.CONTAINS })\n\n // Store the itemRank info\n addMeta({\n itemRank,\n })\n\n // Return if the item should be filtered in/out\n return itemRank.passed\n}\n\n// Define a custom fuzzy sort function that will sort by rank if the row has ranking information\nconst fuzzySort: SortingFn<any> = (rowA, rowB, columnId) => {\n let dir = 0\n\n // Only sort by rank if the column has ranking information\n if (rowA.columnFiltersMeta[columnId]) {\n dir = compareItems(\n rowA.columnFiltersMeta[columnId]?.itemRank!,\n rowB.columnFiltersMeta[columnId]?.itemRank!,\n )\n }\n\n // Provide an alphanumeric fallback for when the item ranks are equal\n return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir\n}\n\n// Helper function to get row range for shift-selection\n// Operates on the provided list of rows (e.g., filtered and sorted rows)\nfunction getRowRange<TData extends RowData>(\n rows: Array<Row<TData>>,\n idA: string,\n idB: string,\n): Array<Row<TData>> {\n const range: Array<Row<TData>> = []\n // If idA and idB are the same, or one is not found, handle appropriately\n if (idA === idB) {\n const singleRow = rows.find((row) => row.id === idA)\n return singleRow ? [singleRow] : []\n }\n\n let indexA = -1\n let indexB = -1\n\n for (let i = 0; i < rows.length; i++) {\n if (rows[i].id === idA) indexA = i\n if (rows[i].id === idB) indexB = i\n if (indexA !== -1 && indexB !== -1) break\n }\n\n if (indexA === -1 || indexB === -1) return [] // One or both IDs not found\n\n const start = Math.min(indexA, indexB)\n const end = Math.max(indexA, indexB)\n\n for (let i = start; i <= end; i++) {\n range.push(rows[i])\n }\n return range\n}\n\nconst SimpleTable: FC<SimpleTableProps> = ({\n data = [],\n isLoading,\n error,\n isExpandable,\n isMultiSelect = true,\n enableClickToDeselect = true,\n enableNonFolderIndent = true,\n forceUpdateTable,\n globalFilter,\n meta,\n rowHeight,\n imgRatio,\n onScrollBottom,\n onRename,\n renamingId,\n onSubmitRename,\n onCancelRename,\n onRowDoubleClick,\n rowContextMenuBuilders = [],\n children,\n pt,\n fitContent,\n ...props\n}) => {\n const {\n rowSelection,\n expanded,\n setExpanded,\n onExpandedChange,\n onRowSelectionChange,\n rowPinning,\n onRowPinningChange,\n } = useSimpleTableContext()\n const lastSelectedIdRef = useRef<string | null>(null)\n const tableRef = useRef<Table<SimpleTableRow> | null>(null)\n const [showRowContextMenu] = useCreateContextMenu()\n\n // Refs for values used inside the columns memo.\n // Assigning synchronously (not via useEffect) means the cell function always reads\n // the latest value at render time, while the columns memo itself has a minimal dep\n // array and stays as a stable reference — critical because flexRender calls\n // React.createElement with the cell function, so a new reference = remount = broken dblclick.\n const onRowDoubleClickRef = useRef(onRowDoubleClick)\n onRowDoubleClickRef.current = onRowDoubleClick\n const renamingIdRef = useRef(renamingId)\n renamingIdRef.current = renamingId\n const onSubmitRenameRef = useRef(onSubmitRename)\n onSubmitRenameRef.current = onSubmitRename\n const onCancelRenameRef = useRef(onCancelRename)\n onCancelRenameRef.current = onCancelRename\n const onRenameRef = useRef(onRename)\n onRenameRef.current = onRename\n\n // stable data reference\n const tableData = useMemo(() => {\n if (!isLoading) return data\n\n // show loading placeholders\n return Array.from({ length: 10 }, (_, i) => ({\n id: `placeholder-${i}`,\n name: `placeholder-${i}`,\n label: `placeholder-${i}`,\n icon: null,\n img: null,\n subRows: [],\n data: {\n id: `placeholder-${i}`,\n },\n }))\n }, [isLoading, data, forceUpdateTable])\n\n // Define the core selection logic using useCallback for stability\n const handleSelectionLogic = useCallback(\n (\n tableInstance: Table<SimpleTableRow>,\n rowId: string,\n isShift: boolean,\n isCtrlOrMeta: boolean,\n ) => {\n const currentId = rowId\n const allProcessableRows = tableInstance.getFilteredRowModel().flatRows\n const currentRow = allProcessableRows.find((r) => r.id === currentId)\n\n if (!currentRow) return\n\n // Prevent selection of disabled rows\n if (currentRow.original.isDisabled) return\n\n // If click-to-deselect is enabled and only one row is selected and it's the current row\n if (\n enableClickToDeselect &&\n !isShift &&\n !isCtrlOrMeta &&\n Object.keys(tableInstance.getState().rowSelection).length === 1 &&\n tableInstance.getState().rowSelection[currentId]\n ) {\n tableInstance.setRowSelection({})\n lastSelectedIdRef.current = null\n return\n }\n\n if (isMultiSelect && isShift && lastSelectedIdRef.current) {\n const lastId = lastSelectedIdRef.current\n const anchorRow = allProcessableRows.find((r) => r.id === lastId)\n\n if (!anchorRow) {\n tableInstance.setRowSelection({ [currentId]: true })\n } else {\n const rowsToToggle = getRowRange(allProcessableRows, currentId, lastId)\n const newSelection: RowSelectionState = {}\n rowsToToggle.forEach((r) => (newSelection[r.id] = true))\n tableInstance.setRowSelection(newSelection)\n }\n } else if (isMultiSelect && isCtrlOrMeta) {\n // write a concrete object from live state; toggleSelected()'s functional updater runs\n // against a stale rowSelection closure and drops the other selected rows\n const selection = { ...tableInstance.getState().rowSelection }\n if (selection[currentId]) {\n delete selection[currentId]\n } else {\n selection[currentId] = true\n }\n tableInstance.setRowSelection(selection)\n } else {\n // If it's already selected and it's the only one, don't update selection to avoid unnecessary re-renders\n const selection = tableInstance.getState().rowSelection\n if (!(Object.keys(selection).length === 1 && selection[currentId])) {\n tableInstance.setRowSelection({ [currentId]: true })\n }\n }\n lastSelectedIdRef.current = currentId\n },\n [isMultiSelect, enableClickToDeselect],\n )\n\n // Callback for useRowKeydown's handleRowSelect prop\n // Uses tableRef to access the table instance, avoiding direct dependency on 'table' variable at definition time\n const handleRowSelectForKeydown = useCallback(\n (\n event: RowKeyboardEvent, // Use the specific keyboard event type from the hook\n selectedRow: Row<SimpleTableRow>,\n ) => {\n if (!tableRef.current) {\n console.warn('tableRef not yet available in handleRowSelectForKeydown')\n return\n }\n\n // Extract modifier keys from the event\n const isShiftKey = event.shiftKey\n const isCtrlKey = event.ctrlKey || event.metaKey\n\n handleSelectionLogic(\n tableRef.current, // Pass the main table instance\n selectedRow.id,\n isShiftKey,\n isCtrlKey,\n )\n },\n [handleSelectionLogic], // Depends only on handleSelectionLogic\n )\n\n // Handle arrow key navigation\n const handleArrowNavigation = useCallback(\n (direction: 'up' | 'down', currentRow: Row<SimpleTableRow>, event: RowKeyboardEvent) => {\n if (!tableRef.current) return\n\n // Use the row model which respects expanded state, not filtered model\n const visibleRows = tableRef.current.getRowModel().rows\n const currentIndex = visibleRows.findIndex((r) => r.id === currentRow.id)\n\n if (currentIndex === -1) return\n\n let nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1\n\n // Check bounds\n if (nextIndex < 0 || nextIndex >= visibleRows.length) return\n\n // Skip disabled rows\n while (nextIndex >= 0 && nextIndex < visibleRows.length) {\n const nextRow = visibleRows[nextIndex]\n if (!nextRow.original.isDisabled) {\n // Found a valid row\n // Select the next row\n handleSelectionLogic(\n tableRef.current,\n nextRow.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n\n // Focus the next row's cell. Scope to this table's container: row ids are\n // entity ids that can also exist in other SimpleTables on the page (slicer),\n // so a document-wide getElementById would steal focus to a duplicate.\n requestAnimationFrame(() => {\n const container = tableContainerRef.current\n const nextRowElement = container\n ? container.querySelector(`#${CSS.escape(nextRow.id)}`)\n : document.getElementById(nextRow.id)\n const nextCell = nextRowElement?.querySelector('[tabindex=\"0\"]') as HTMLElement\n if (nextCell) {\n nextCell.focus()\n nextCell.scrollIntoView({ block: 'nearest', behavior: 'smooth' })\n }\n })\n return\n }\n // Move to next row if current is disabled\n nextIndex = direction === 'down' ? nextIndex + 1 : nextIndex - 1\n }\n },\n [handleSelectionLogic],\n )\n\n // handleRenameForKeydown reads from onRenameRef so it has empty deps and is\n // permanently stable — keeping handleRowKeyDown and therefore columns stable.\n const handleRenameForKeydown = useCallback(\n (e: RowKeyboardEvent, row: Row<SimpleTableRow>) => {\n if (!row.original.isDisabled) onRenameRef.current?.(row.id, row)\n },\n [], // eslint-disable-line react-hooks/exhaustive-deps\n )\n\n const { handleRowKeyDown } = useRowKeydown<SimpleTableRow>({\n handleRowSelect: handleRowSelectForKeydown,\n handleArrowNavigation,\n handleRename: handleRenameForKeydown,\n })\n\n const columns = useMemo<ColumnDef<SimpleTableRow>[]>(\n () => [\n {\n accessorKey: 'label',\n header: undefined,\n filterFn: 'fuzzy',\n sortingFn: fuzzySort, //sort by fuzzy rank (falls back to alphanumeric)\n cell: ({ row, getValue, table: cellTableInstance }) => {\n const cellMeta = cellTableInstance.options.meta\n\n const handleCellClick = (event: ReactMouseEvent<HTMLElement, MouseEvent>) => {\n // Prevent row selection if clicking on an interactive element within the cell\n if (\n event.target instanceof HTMLInputElement ||\n event.target instanceof HTMLButtonElement ||\n event.target instanceof HTMLTextAreaElement ||\n event.target instanceof HTMLSelectElement ||\n event.target instanceof HTMLAnchorElement ||\n (event.target as HTMLElement).closest('button, a, input, textarea, select')\n ) {\n return\n }\n handleSelectionLogic(\n cellTableInstance, // Pass the cell's table instance\n row.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n }\n\n const props: SimpleTableCellTemplateProps & {\n onClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n onDoubleClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n } = {\n className: clsx({\n selected: row.getIsSelected(),\n loading: cellMeta?.isLoading,\n disabled: row.original.isDisabled, // you can't select disabled rows\n inactive: row.original.inactive, // false: archived items but still selectable\n }),\n onKeyDown: (e) => {\n if (e.target instanceof HTMLInputElement) return\n // Corrected typo: handleRowKeydown -> handleRowKeyDown\n handleRowKeyDown(e, row)\n },\n depth: row.depth,\n tabIndex: 0,\n value: getValue<string>(),\n parents: row.original.parents,\n icon: row.original.icon || undefined,\n iconColor: row.original.iconColor,\n iconFilled: row.original.iconFilled,\n img: row.original.img,\n imgShape: row.original.imgShape,\n imgRatio: imgRatio,\n isRowExpandable: row.getCanExpand(),\n enableNonFolderIndent,\n isRowExpanded: row.getIsExpanded(),\n isTableExpandable: cellMeta?.isExpandable,\n onExpandClick: row.getToggleExpandedHandler(),\n startContent: row.original.startContent,\n endContent: row.original.endContent,\n isDisabled: row.original.isDisabled,\n disabledMessage: row.original.disabledMessage,\n isRenaming: row.id === renamingIdRef.current,\n onSubmitRename: onSubmitRenameRef.current\n ? (v) => onSubmitRenameRef.current!(row.id, v)\n : undefined,\n onCancelRename: onCancelRenameRef.current,\n ...pt?.cell,\n onClick: handleCellClick, // Added onClick handler\n onDoubleClick: (e) => onRowDoubleClickRef.current?.(row.id, row),\n }\n\n // Use children function if provided, otherwise default to SimpleTableCellTemplate\n return cellMeta?.children ? (\n cellMeta.children(props, row, cellTableInstance)\n ) : (\n <SimpleTableCellTemplate {...props} {...pt?.cell} />\n )\n },\n },\n ],\n [\n forceUpdateTable,\n handleSelectionLogic,\n handleRowKeyDown,\n enableClickToDeselect,\n enableNonFolderIndent,\n imgRatio,\n ],\n )\n\n const handleRowSelectionChangeCallback: OnChangeFn<RowSelectionState> = useCallback(\n (updater) => {\n onRowSelectionChange(functionalUpdate(updater, rowSelection))\n },\n [onRowSelectionChange],\n )\n\n const handleRowPinningChangeCallback: OnChangeFn<RowPinningState> = useCallback(\n (updater) => {\n onRowPinningChange?.(functionalUpdate(updater, rowPinning || {}))\n },\n [onRowPinningChange],\n )\n\n const handleExpandedChange = useCallback(\n (updater: any) => {\n setExpanded?.((old) => {\n const newExpanded = updater instanceof Function ? updater(old) : updater\n onExpandedChange?.(newExpanded)\n return newExpanded\n })\n },\n [setExpanded],\n )\n\n const table = useReactTable({\n data: tableData,\n columns,\n state: {\n expanded,\n rowSelection,\n globalFilter,\n rowPinning,\n },\n onRowSelectionChange: handleRowSelectionChangeCallback,\n onRowPinningChange: handleRowPinningChangeCallback,\n filterFns: {\n fuzzy: fuzzyFilter,\n },\n globalFilterFn: 'fuzzy',\n enableRowSelection: true, //enable row selection for all rows\n enableRowPinning: !!onRowPinningChange,\n getRowId: (row) => row.id,\n enableSubRowSelection: false, //disable sub row selection\n onExpandedChange: handleExpandedChange,\n getSubRows: (row) => row.subRows,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getExpandedRowModel: getExpandedRowModel(),\n filterFromLeafRows: true,\n // debugTable: true,\n // @ts-expect-error: updateData is not required\n meta: useMemo(\n () => ({\n isExpandable: !!isExpandable,\n isLoading: isLoading,\n children: children,\n ...meta,\n }),\n [isExpandable, isLoading, children, meta],\n ),\n })\n\n // Update tableRef whenever the table instance changes.\n // This ensures handleRowSelectForKeydown uses the current table instance.\n useEffect(() => {\n tableRef.current = table\n }, [table])\n\n const { rows } = table.getRowModel()\n\n const handleRowContextMenu = useCallback(\n (rowId: string, rowIndex: number, e: ReactMouseEvent<HTMLTableRowElement>) => {\n if (!tableRef.current) return\n const row = rows[rowIndex]\n if (!row || row.original === undefined) return\n\n e.preventDefault()\n e.stopPropagation()\n\n const selectedIds = Object.keys(rowSelection)\n\n const nextSelectedRows = selectedIds.includes(rowId) ? selectedIds : [rowId]\n\n if (!selectedIds.includes(rowId)) {\n // convert array to RowSelectionState object\n const nextSelection: RowSelectionState = { [rowId]: true }\n onRowSelectionChange?.(nextSelection)\n }\n\n const menuItems = rowContextMenuBuilders.flatMap((builder) =>\n toMenuItems(\n builder(e as any, {\n rowId,\n rowIndex,\n row,\n selectedRows: nextSelectedRows,\n isSelected: nextSelectedRows.includes(rowId),\n }),\n ),\n )\n\n if (menuItems.length > 0) {\n showRowContextMenu(e as any, menuItems)\n }\n },\n [rowContextMenuBuilders, rows, rowSelection, onRowSelectionChange, showRowContextMenu],\n )\n\n //The virtualizer needs to know the scrollable container element\n const tableContainerRef = useRef<HTMLDivElement>(null)\n\n const rowVirtualizer = useVirtualizer({\n count: rows.length,\n estimateSize: () => rowHeight || 34, //estimate row height for accurate scrollbar dragging\n getScrollElement: () => tableContainerRef.current,\n //measure dynamic row height, except in firefox because it measures table border height incorrectly\n measureElement: rowHeight\n ? () => rowHeight\n : typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1\n ? (element) => element?.getBoundingClientRect().height\n : undefined,\n overscan: 5,\n })\n\n // Memoize the ref callback to prevent infinite re-renders\n const measureElementRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n rowVirtualizer.measureElement(node)\n }\n },\n [rowVirtualizer],\n )\n\n // Handle scroll to bottom detection\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLDivElement>) => {\n if (!onScrollBottom) return\n\n const target = event.currentTarget\n const { scrollTop, scrollHeight, clientHeight } = target\n\n // Check if we're near the bottom (within 100px)\n const isNearBottom = scrollHeight - scrollTop - clientHeight < 100\n\n if (isNearBottom && !isLoading) {\n onScrollBottom()\n }\n },\n [onScrollBottom, isLoading],\n )\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // if the click is outside of any row, clear selection\n if (enableClickToDeselect && !(e.target as HTMLElement).closest('tr')) {\n table.setRowSelection({})\n lastSelectedIdRef.current = null\n }\n }\n\n return (\n <Styled.TableContainer\n ref={tableContainerRef}\n onScroll={handleScroll}\n onClick={handleContainerClick}\n {...props}\n className={clsx(props.className, { isLoading, fitContent })}\n >\n {!error && (\n <table>\n <tbody\n style={{\n height: `${rowVirtualizer?.getTotalSize()}px`, //tells scrollbar how big the table is\n }}\n >\n {rowVirtualizer?.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index] as Row<SimpleTableRow>\n return (\n <tr\n data-index={virtualRow.index} //needed for dynamic row height measurement\n ref={measureElementRef} //measure dynamic row height\n key={row.id}\n id={row.id}\n onContextMenu={(e) => handleRowContextMenu(row.id, virtualRow.index, e)}\n {...pt?.row}\n style={{\n transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll\n ...pt?.row?.style, // custom styles to be passed\n }}\n >\n {row.getVisibleCells().map((cell) => {\n return (\n <td key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n )\n })}\n </tr>\n )\n })}\n </tbody>\n </table>\n )}\n {!!error && <EmptyPlaceholder error={error} />}\n </Styled.TableContainer>\n )\n}\n\nexport default SimpleTable\n"],"names":["toMenuItems","items","fuzzyFilter","row","columnId","searchValue","addMeta","cellValue","searchString","itemRank","rankItem","rankings","fuzzySort","rowA","rowB","dir","compareItems","sortingFns","getRowRange","rows","idA","idB","range","singleRow","indexA","indexB","i","start","end","SimpleTable","data","isLoading","error","isExpandable","isMultiSelect","enableClickToDeselect","enableNonFolderIndent","forceUpdateTable","globalFilter","meta","rowHeight","imgRatio","onScrollBottom","onRename","renamingId","onSubmitRename","onCancelRename","onRowDoubleClick","rowContextMenuBuilders","children","pt","fitContent","props","rowSelection","expanded","setExpanded","onExpandedChange","onRowSelectionChange","rowPinning","onRowPinningChange","useSimpleTableContext","lastSelectedIdRef","useRef","tableRef","showRowContextMenu","useCreateContextMenu","onRowDoubleClickRef","renamingIdRef","onSubmitRenameRef","onCancelRenameRef","onRenameRef","tableData","useMemo","_","handleSelectionLogic","useCallback","tableInstance","rowId","isShift","isCtrlOrMeta","currentId","allProcessableRows","currentRow","r","lastId","rowsToToggle","newSelection","selection","handleRowSelectForKeydown","event","selectedRow","isShiftKey","isCtrlKey","handleArrowNavigation","direction","visibleRows","currentIndex","nextIndex","nextRow","container","tableContainerRef","nextCell","handleRenameForKeydown","handleRowKeyDown","useRowKeydown","columns","getValue","cellTableInstance","cellMeta","handleCellClick","clsx","e","v","jsx","SimpleTableCellTemplate","handleRowSelectionChangeCallback","updater","functionalUpdate","handleRowPinningChangeCallback","handleExpandedChange","old","newExpanded","table","useReactTable","getCoreRowModel","getFilteredRowModel","getExpandedRowModel","useEffect","handleRowContextMenu","rowIndex","selectedIds","nextSelectedRows","nextSelection","menuItems","builder","rowVirtualizer","useVirtualizer","element","measureElementRef","node","handleScroll","target","scrollTop","scrollHeight","clientHeight","handleContainerClick","jsxs","Styled.TableContainer","virtualRow","cell","flexRender","EmptyPlaceholder"],"mappings":"owiBAoCA,MAAMA,GAAeC,GACdA,EACE,MAAM,QAAQA,CAAK,EAAIA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AAgB,aAAA,CAAc,IAAA,EAG1C,SAAAA,GAAgB,gBAAA,EAAkB,IAAKa,GAAe,CACrD,MAAMjJ,EAAMgB,EAAKiI,EAAW,KAAK,EACjC,OACEnC,EAAAA,kBAAAA,IAAC,KAAA,CACC,aAAYmC,EAAW,MACvB,IAAKV,GAEL,GAAIvI,EAAI,GACR,cAAgB4G,GAAMiB,GAAqB7H,EAAI,GAAIiJ,EAAW,MAAOrC,CAAC,EACrE,GAAG7D,GAAI,IACR,MAAO,CACL,UAAW,cAAckG,EAAW,KAAK,MACzC,GAAGlG,GAAI,KAAK,KAAA,EAGb,SAAA/C,EAAI,gBAAA,EAAkB,IAAKkJ,GAExBpC,EAAAA,kBAAAA,IAAC,KAAA,CACE,SAAAqC,EAAAA,WAAWD,EAAK,OAAO,UAAU,KAAMA,EAAK,WAAA,CAAY,CAAA,EADlDA,EAAK,EAEd,CAEH,CAAA,EAfIlJ,EAAI,EAAA,CAkBf,CAAC,CAAA,CAAA,EAEL,EAED,CAAC,CAAC6B,GAASiF,EAAAA,kBAAAA,IAACsC,GAAAA,kBAAiB,MAAAvH,CAAA,CAAc,CAAA,CAAA,CAAA,CAGlD"}
1
+ {"version":3,"file":"SimpleTable.cjs.js","sources":["../../../../../src/containers/SimpleTable/SimpleTable.tsx"],"sourcesContent":["import { FC, useMemo, useRef, MouseEvent as ReactMouseEvent, useCallback, useEffect } from 'react'\nimport * as Styled from './SimpleTable.styled'\nimport {\n useReactTable,\n getCoreRowModel,\n getFilteredRowModel,\n getExpandedRowModel,\n ColumnDef,\n flexRender,\n Row,\n FilterFn,\n SortingFn,\n sortingFns,\n Table,\n RowData,\n OnChangeFn,\n RowSelectionState,\n functionalUpdate,\n} from '@tanstack/react-table'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport clsx from 'clsx'\nimport useRowKeydown, { RowKeyboardEvent } from './hooks/useRowKeydown'\n\nimport { rankItem, compareItems, rankings } from '@tanstack/match-sorter-utils'\nimport { useSimpleTableContext } from './context/SimpleTableContext'\nimport { SimpleTableCellTemplate, SimpleTableCellTemplateProps } from './SimpleTableRowTemplate'\nimport { EmptyPlaceholder } from '@shared/components'\nimport { RowPinningState } from '@tanstack/react-table'\nimport {\n SimpleTableProps,\n SimpleTableRow,\n SimpleTableRowContextMenuBuilder,\n} from './SimpleTable.types'\nimport { useCreateContextMenu } from '../ContextMenu'\n\nconst toMenuItems = (items: ReturnType<SimpleTableRowContextMenuBuilder>) => {\n if (!items) return []\n return Array.isArray(items) ? items.filter(Boolean) : [items]\n}\n\n// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)\nconst fuzzyFilter: FilterFn<any> = (row, columnId, searchValue, addMeta) => {\n const cellValue = row.getValue(columnId)\n // convert non-string cell values to string\n let searchString =\n typeof cellValue === 'string'\n ? cellValue\n : Array.isArray(cellValue)\n ? cellValue.join(' ')\n : JSON.stringify(cellValue)\n\n // combine label and parents into a single string for searching if columnId is 'label'\n if (columnId === 'label') {\n searchString = [row.original.label, row.original.name, ...(row.original.parents || [])].join(\n ' ',\n )\n }\n\n // Rank the item with CONTAINS threshold to avoid overly permissive fuzzy matches\n // This ensures the search term must be a substring, not just scattered characters\n const itemRank = rankItem(searchString, searchValue, { threshold: rankings.CONTAINS })\n\n // Store the itemRank info\n addMeta({\n itemRank,\n })\n\n // Return if the item should be filtered in/out\n return itemRank.passed\n}\n\n// Define a custom fuzzy sort function that will sort by rank if the row has ranking information\nconst fuzzySort: SortingFn<any> = (rowA, rowB, columnId) => {\n let dir = 0\n\n // Only sort by rank if the column has ranking information\n if (rowA.columnFiltersMeta[columnId]) {\n dir = compareItems(\n rowA.columnFiltersMeta[columnId]?.itemRank!,\n rowB.columnFiltersMeta[columnId]?.itemRank!,\n )\n }\n\n // Provide an alphanumeric fallback for when the item ranks are equal\n return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir\n}\n\n// Helper function to get row range for shift-selection\n// Operates on the provided list of rows (e.g., filtered and sorted rows)\nfunction getRowRange<TData extends RowData>(\n rows: Array<Row<TData>>,\n idA: string,\n idB: string,\n): Array<Row<TData>> {\n const range: Array<Row<TData>> = []\n // If idA and idB are the same, or one is not found, handle appropriately\n if (idA === idB) {\n const singleRow = rows.find((row) => row.id === idA)\n return singleRow ? [singleRow] : []\n }\n\n let indexA = -1\n let indexB = -1\n\n for (let i = 0; i < rows.length; i++) {\n if (rows[i].id === idA) indexA = i\n if (rows[i].id === idB) indexB = i\n if (indexA !== -1 && indexB !== -1) break\n }\n\n if (indexA === -1 || indexB === -1) return [] // One or both IDs not found\n\n const start = Math.min(indexA, indexB)\n const end = Math.max(indexA, indexB)\n\n for (let i = start; i <= end; i++) {\n range.push(rows[i])\n }\n return range\n}\n\nconst SimpleTable: FC<SimpleTableProps> = ({\n data = [],\n isLoading,\n error,\n isExpandable,\n isMultiSelect = true,\n enableClickToDeselect = true,\n enableNonFolderIndent = true,\n forceUpdateTable,\n globalFilter,\n meta,\n rowHeight,\n imgRatio,\n onScrollBottom,\n onRename,\n renamingId,\n onSubmitRename,\n onCancelRename,\n onRowDoubleClick,\n rowContextMenuBuilders = [],\n children,\n pt,\n fitContent,\n ...props\n}) => {\n const {\n rowSelection,\n expanded,\n setExpanded,\n onExpandedChange,\n onRowSelectionChange,\n rowPinning,\n onRowPinningChange,\n } = useSimpleTableContext()\n const lastSelectedIdRef = useRef<string | null>(null)\n const tableRef = useRef<Table<SimpleTableRow> | null>(null)\n const [showRowContextMenu] = useCreateContextMenu()\n\n // Refs for values used inside the columns memo.\n // Assigning synchronously (not via useEffect) means the cell function always reads\n // the latest value at render time, while the columns memo itself has a minimal dep\n // array and stays as a stable reference — critical because flexRender calls\n // React.createElement with the cell function, so a new reference = remount = broken dblclick.\n const onRowDoubleClickRef = useRef(onRowDoubleClick)\n onRowDoubleClickRef.current = onRowDoubleClick\n const renamingIdRef = useRef(renamingId)\n renamingIdRef.current = renamingId\n const onSubmitRenameRef = useRef(onSubmitRename)\n onSubmitRenameRef.current = onSubmitRename\n const onCancelRenameRef = useRef(onCancelRename)\n onCancelRenameRef.current = onCancelRename\n const onRenameRef = useRef(onRename)\n onRenameRef.current = onRename\n\n // stable data reference\n const tableData = useMemo(() => {\n if (!isLoading) return data\n\n // show loading placeholders\n return Array.from({ length: 10 }, (_, i) => ({\n id: `placeholder-${i}`,\n name: `placeholder-${i}`,\n label: `placeholder-${i}`,\n icon: null,\n img: null,\n subRows: [],\n data: {\n id: `placeholder-${i}`,\n },\n }))\n }, [isLoading, data, forceUpdateTable])\n\n // Define the core selection logic using useCallback for stability\n const handleSelectionLogic = useCallback(\n (\n tableInstance: Table<SimpleTableRow>,\n rowId: string,\n isShift: boolean,\n isCtrlOrMeta: boolean,\n ) => {\n const currentId = rowId\n const allProcessableRows = tableInstance.getFilteredRowModel().flatRows\n const currentRow = allProcessableRows.find((r) => r.id === currentId)\n\n if (!currentRow) return\n\n // Prevent selection of disabled rows\n if (currentRow.original.isDisabled) return\n\n // If click-to-deselect is enabled and only one row is selected and it's the current row\n if (\n enableClickToDeselect &&\n !isShift &&\n !isCtrlOrMeta &&\n Object.keys(tableInstance.getState().rowSelection).length === 1 &&\n tableInstance.getState().rowSelection[currentId]\n ) {\n tableInstance.setRowSelection({})\n lastSelectedIdRef.current = null\n return\n }\n\n if (isMultiSelect && isShift && lastSelectedIdRef.current) {\n const lastId = lastSelectedIdRef.current\n const anchorRow = allProcessableRows.find((r) => r.id === lastId)\n\n if (!anchorRow) {\n tableInstance.setRowSelection({ [currentId]: true })\n } else {\n const rowsToToggle = getRowRange(allProcessableRows, currentId, lastId)\n const newSelection: RowSelectionState = {}\n rowsToToggle.forEach((r) => (newSelection[r.id] = true))\n tableInstance.setRowSelection(newSelection)\n }\n } else if (isMultiSelect && isCtrlOrMeta) {\n // write a concrete object from live state; toggleSelected()'s functional updater runs\n // against a stale rowSelection closure and drops the other selected rows\n const selection = { ...tableInstance.getState().rowSelection }\n if (selection[currentId]) {\n delete selection[currentId]\n } else {\n selection[currentId] = true\n }\n tableInstance.setRowSelection(selection)\n } else {\n // If it's already selected and it's the only one, don't update selection to avoid unnecessary re-renders\n const selection = tableInstance.getState().rowSelection\n if (!(Object.keys(selection).length === 1 && selection[currentId])) {\n tableInstance.setRowSelection({ [currentId]: true })\n }\n }\n lastSelectedIdRef.current = currentId\n },\n [isMultiSelect, enableClickToDeselect],\n )\n\n // Callback for useRowKeydown's handleRowSelect prop\n // Uses tableRef to access the table instance, avoiding direct dependency on 'table' variable at definition time\n const handleRowSelectForKeydown = useCallback(\n (\n event: RowKeyboardEvent, // Use the specific keyboard event type from the hook\n selectedRow: Row<SimpleTableRow>,\n ) => {\n if (!tableRef.current) {\n console.warn('tableRef not yet available in handleRowSelectForKeydown')\n return\n }\n\n // Extract modifier keys from the event\n const isShiftKey = event.shiftKey\n const isCtrlKey = event.ctrlKey || event.metaKey\n\n handleSelectionLogic(\n tableRef.current, // Pass the main table instance\n selectedRow.id,\n isShiftKey,\n isCtrlKey,\n )\n },\n [handleSelectionLogic], // Depends only on handleSelectionLogic\n )\n\n // Handle arrow key navigation\n const handleArrowNavigation = useCallback(\n (direction: 'up' | 'down', currentRow: Row<SimpleTableRow>, event: RowKeyboardEvent) => {\n if (!tableRef.current) return\n\n // Use the row model which respects expanded state, not filtered model\n const visibleRows = tableRef.current.getRowModel().rows\n const currentIndex = visibleRows.findIndex((r) => r.id === currentRow.id)\n\n if (currentIndex === -1) return\n\n let nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1\n\n // Check bounds\n if (nextIndex < 0 || nextIndex >= visibleRows.length) return\n\n // Skip disabled rows\n while (nextIndex >= 0 && nextIndex < visibleRows.length) {\n const nextRow = visibleRows[nextIndex]\n if (!nextRow.original.isDisabled) {\n // Found a valid row\n // Select the next row\n handleSelectionLogic(\n tableRef.current,\n nextRow.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n\n // Focus the next row's cell. Scope to this table's container: row ids are\n // entity ids that can also exist in other SimpleTables on the page (slicer),\n // so a document-wide getElementById would steal focus to a duplicate.\n requestAnimationFrame(() => {\n const container = tableContainerRef.current\n const nextRowElement = container\n ? container.querySelector(`#${CSS.escape(nextRow.id)}`)\n : document.getElementById(nextRow.id)\n const nextCell = nextRowElement?.querySelector('[tabindex=\"0\"]') as HTMLElement\n if (nextCell) {\n nextCell.focus()\n nextCell.scrollIntoView({ block: 'nearest', behavior: 'smooth' })\n }\n })\n return\n }\n // Move to next row if current is disabled\n nextIndex = direction === 'down' ? nextIndex + 1 : nextIndex - 1\n }\n },\n [handleSelectionLogic],\n )\n\n // handleRenameForKeydown reads from onRenameRef so it has empty deps and is\n // permanently stable — keeping handleRowKeyDown and therefore columns stable.\n const handleRenameForKeydown = useCallback(\n (e: RowKeyboardEvent, row: Row<SimpleTableRow>) => {\n if (!row.original.isDisabled) onRenameRef.current?.(row.id, row)\n },\n [], // eslint-disable-line react-hooks/exhaustive-deps\n )\n\n const { handleRowKeyDown } = useRowKeydown<SimpleTableRow>({\n handleRowSelect: handleRowSelectForKeydown,\n handleArrowNavigation,\n handleRename: handleRenameForKeydown,\n })\n\n const columns = useMemo<ColumnDef<SimpleTableRow>[]>(\n () => [\n {\n accessorKey: 'label',\n header: undefined,\n filterFn: 'fuzzy',\n sortingFn: fuzzySort, //sort by fuzzy rank (falls back to alphanumeric)\n cell: ({ row, getValue, table: cellTableInstance }) => {\n const cellMeta = cellTableInstance.options.meta\n\n const handleCellClick = (event: ReactMouseEvent<HTMLElement, MouseEvent>) => {\n // Prevent row selection if clicking on an interactive element within the cell\n if (\n event.target instanceof HTMLInputElement ||\n event.target instanceof HTMLButtonElement ||\n event.target instanceof HTMLTextAreaElement ||\n event.target instanceof HTMLSelectElement ||\n event.target instanceof HTMLAnchorElement ||\n (event.target as HTMLElement).closest('button, a, input, textarea, select')\n ) {\n return\n }\n handleSelectionLogic(\n cellTableInstance, // Pass the cell's table instance\n row.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n }\n\n const props: SimpleTableCellTemplateProps & {\n onClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n onDoubleClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n } = {\n className: clsx({\n selected: row.getIsSelected(),\n loading: cellMeta?.isLoading,\n disabled: row.original.isDisabled, // you can't select disabled rows\n inactive: row.original.inactive, // false: archived items but still selectable\n }),\n onKeyDown: (e) => {\n if (e.target instanceof HTMLInputElement) return\n // Corrected typo: handleRowKeydown -> handleRowKeyDown\n handleRowKeyDown(e, row)\n },\n depth: row.depth,\n tabIndex: 0,\n value: getValue<string>(),\n parents: row.original.parents,\n icon: row.original.icon || undefined,\n iconColor: row.original.iconColor,\n iconFilled: row.original.iconFilled,\n img: row.original.img,\n imgShape: row.original.imgShape,\n imgRatio: imgRatio,\n isRowExpandable: row.getCanExpand(),\n enableNonFolderIndent,\n isRowExpanded: row.getIsExpanded(),\n isTableExpandable: cellMeta?.isExpandable,\n onExpandClick: row.getToggleExpandedHandler(),\n startContent: row.original.startContent,\n endContent: row.original.endContent,\n badge: row.original.badge,\n isDisabled: row.original.isDisabled,\n disabledMessage: row.original.disabledMessage,\n isRenaming: row.id === renamingIdRef.current,\n onSubmitRename: onSubmitRenameRef.current\n ? (v) => onSubmitRenameRef.current!(row.id, v)\n : undefined,\n onCancelRename: onCancelRenameRef.current,\n ...pt?.cell,\n onClick: handleCellClick, // Added onClick handler\n onDoubleClick: (e) => onRowDoubleClickRef.current?.(row.id, row),\n }\n\n // Use children function if provided, otherwise default to SimpleTableCellTemplate\n return cellMeta?.children ? (\n cellMeta.children(props, row, cellTableInstance)\n ) : (\n <SimpleTableCellTemplate {...props} {...pt?.cell} />\n )\n },\n },\n ],\n [\n forceUpdateTable,\n handleSelectionLogic,\n handleRowKeyDown,\n enableClickToDeselect,\n enableNonFolderIndent,\n imgRatio,\n ],\n )\n\n const handleRowSelectionChangeCallback: OnChangeFn<RowSelectionState> = useCallback(\n (updater) => {\n onRowSelectionChange(functionalUpdate(updater, rowSelection))\n },\n [onRowSelectionChange],\n )\n\n const handleRowPinningChangeCallback: OnChangeFn<RowPinningState> = useCallback(\n (updater) => {\n onRowPinningChange?.(functionalUpdate(updater, rowPinning || {}))\n },\n [onRowPinningChange],\n )\n\n const handleExpandedChange = useCallback(\n (updater: any) => {\n setExpanded?.((old) => {\n const newExpanded = updater instanceof Function ? updater(old) : updater\n onExpandedChange?.(newExpanded)\n return newExpanded\n })\n },\n [setExpanded],\n )\n\n const table = useReactTable({\n data: tableData,\n columns,\n state: {\n expanded,\n rowSelection,\n globalFilter,\n rowPinning,\n },\n onRowSelectionChange: handleRowSelectionChangeCallback,\n onRowPinningChange: handleRowPinningChangeCallback,\n filterFns: {\n fuzzy: fuzzyFilter,\n },\n globalFilterFn: 'fuzzy',\n enableRowSelection: true, //enable row selection for all rows\n enableRowPinning: !!onRowPinningChange,\n getRowId: (row) => row.id,\n enableSubRowSelection: false, //disable sub row selection\n onExpandedChange: handleExpandedChange,\n getSubRows: (row) => row.subRows,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getExpandedRowModel: getExpandedRowModel(),\n filterFromLeafRows: true,\n // debugTable: true,\n // @ts-expect-error: updateData is not required\n meta: useMemo(\n () => ({\n isExpandable: !!isExpandable,\n isLoading: isLoading,\n children: children,\n ...meta,\n }),\n [isExpandable, isLoading, children, meta],\n ),\n })\n\n // Update tableRef whenever the table instance changes.\n // This ensures handleRowSelectForKeydown uses the current table instance.\n useEffect(() => {\n tableRef.current = table\n }, [table])\n\n const { rows } = table.getRowModel()\n\n const handleRowContextMenu = useCallback(\n (rowId: string, rowIndex: number, e: ReactMouseEvent<HTMLTableRowElement>) => {\n if (!tableRef.current) return\n const row = rows[rowIndex]\n if (!row || row.original === undefined) return\n\n e.preventDefault()\n e.stopPropagation()\n\n const selectedIds = Object.keys(rowSelection)\n\n const nextSelectedRows = selectedIds.includes(rowId) ? selectedIds : [rowId]\n\n if (!selectedIds.includes(rowId)) {\n // convert array to RowSelectionState object\n const nextSelection: RowSelectionState = { [rowId]: true }\n onRowSelectionChange?.(nextSelection)\n }\n\n const menuItems = rowContextMenuBuilders.flatMap((builder) =>\n toMenuItems(\n builder(e as any, {\n rowId,\n rowIndex,\n row,\n selectedRows: nextSelectedRows,\n isSelected: nextSelectedRows.includes(rowId),\n }),\n ),\n )\n\n if (menuItems.length > 0) {\n showRowContextMenu(e as any, menuItems)\n }\n },\n [rowContextMenuBuilders, rows, rowSelection, onRowSelectionChange, showRowContextMenu],\n )\n\n //The virtualizer needs to know the scrollable container element\n const tableContainerRef = useRef<HTMLDivElement>(null)\n\n const rowVirtualizer = useVirtualizer({\n count: rows.length,\n estimateSize: () => rowHeight || 34, //estimate row height for accurate scrollbar dragging\n getScrollElement: () => tableContainerRef.current,\n //measure dynamic row height, except in firefox because it measures table border height incorrectly\n measureElement: rowHeight\n ? () => rowHeight\n : typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1\n ? (element) => element?.getBoundingClientRect().height\n : undefined,\n overscan: 5,\n })\n\n // Memoize the ref callback to prevent infinite re-renders\n const measureElementRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n rowVirtualizer.measureElement(node)\n }\n },\n [rowVirtualizer],\n )\n\n // Handle scroll to bottom detection\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLDivElement>) => {\n if (!onScrollBottom) return\n\n const target = event.currentTarget\n const { scrollTop, scrollHeight, clientHeight } = target\n\n // Check if we're near the bottom (within 100px)\n const isNearBottom = scrollHeight - scrollTop - clientHeight < 100\n\n if (isNearBottom && !isLoading) {\n onScrollBottom()\n }\n },\n [onScrollBottom, isLoading],\n )\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // if the click is outside of any row, clear selection\n if (enableClickToDeselect && !(e.target as HTMLElement).closest('tr')) {\n table.setRowSelection({})\n lastSelectedIdRef.current = null\n }\n }\n\n return (\n <Styled.TableContainer\n ref={tableContainerRef}\n onScroll={handleScroll}\n onClick={handleContainerClick}\n {...props}\n className={clsx(props.className, { isLoading, fitContent })}\n >\n {!error && (\n <table>\n <tbody\n style={{\n height: `${rowVirtualizer?.getTotalSize()}px`, //tells scrollbar how big the table is\n }}\n >\n {rowVirtualizer?.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index] as Row<SimpleTableRow>\n return (\n <tr\n data-index={virtualRow.index} //needed for dynamic row height measurement\n ref={measureElementRef} //measure dynamic row height\n key={row.id}\n id={row.id}\n onContextMenu={(e) => handleRowContextMenu(row.id, virtualRow.index, e)}\n {...pt?.row}\n style={{\n transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll\n ...pt?.row?.style, // custom styles to be passed\n }}\n >\n {row.getVisibleCells().map((cell) => {\n return (\n <td key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n )\n })}\n </tr>\n )\n })}\n </tbody>\n </table>\n )}\n {!!error && <EmptyPlaceholder error={error} />}\n </Styled.TableContainer>\n )\n}\n\nexport default SimpleTable\n"],"names":["toMenuItems","items","fuzzyFilter","row","columnId","searchValue","addMeta","cellValue","searchString","itemRank","rankItem","rankings","fuzzySort","rowA","rowB","dir","compareItems","sortingFns","getRowRange","rows","idA","idB","range","singleRow","indexA","indexB","i","start","end","SimpleTable","data","isLoading","error","isExpandable","isMultiSelect","enableClickToDeselect","enableNonFolderIndent","forceUpdateTable","globalFilter","meta","rowHeight","imgRatio","onScrollBottom","onRename","renamingId","onSubmitRename","onCancelRename","onRowDoubleClick","rowContextMenuBuilders","children","pt","fitContent","props","rowSelection","expanded","setExpanded","onExpandedChange","onRowSelectionChange","rowPinning","onRowPinningChange","useSimpleTableContext","lastSelectedIdRef","useRef","tableRef","showRowContextMenu","useCreateContextMenu","onRowDoubleClickRef","renamingIdRef","onSubmitRenameRef","onCancelRenameRef","onRenameRef","tableData","useMemo","_","handleSelectionLogic","useCallback","tableInstance","rowId","isShift","isCtrlOrMeta","currentId","allProcessableRows","currentRow","r","lastId","rowsToToggle","newSelection","selection","handleRowSelectForKeydown","event","selectedRow","isShiftKey","isCtrlKey","handleArrowNavigation","direction","visibleRows","currentIndex","nextIndex","nextRow","container","tableContainerRef","nextCell","handleRenameForKeydown","handleRowKeyDown","useRowKeydown","columns","getValue","cellTableInstance","cellMeta","handleCellClick","clsx","e","v","jsx","SimpleTableCellTemplate","handleRowSelectionChangeCallback","updater","functionalUpdate","handleRowPinningChangeCallback","handleExpandedChange","old","newExpanded","table","useReactTable","getCoreRowModel","getFilteredRowModel","getExpandedRowModel","useEffect","handleRowContextMenu","rowIndex","selectedIds","nextSelectedRows","nextSelection","menuItems","builder","rowVirtualizer","useVirtualizer","element","measureElementRef","node","handleScroll","target","scrollTop","scrollHeight","clientHeight","handleContainerClick","jsxs","Styled.TableContainer","virtualRow","cell","flexRender","EmptyPlaceholder"],"mappings":"owiBAoCA,MAAMA,GAAeC,GACdA,EACE,MAAM,QAAQA,CAAK,EAAIA,EAAM,OAAO,OAAO,EAAI,CAACA,CAAK,EADzC,CAAA,EAKfC,GAA6B,CAACC,EAAKC,EAAUC,EAAaC,IAAY,CAC1E,MAAMC,EAAYJ,EAAI,SAASC,CAAQ,EAEvC,IAAII,EACF,OAAOD,GAAc,SACjBA,EACA,MAAM,QAAQA,CAAS,EACvBA,EAAU,KAAK,GAAG,EAClB,KAAK,UAAUA,CAAS,EAG1BH,IAAa,UACfI,EAAe,CAACL,EAAI,SAAS,MAAOA,EAAI,SAAS,KAAM,GAAIA,EAAI,SAAS,SAAW,CAAA,CAAG,EAAE,KACtF,GAAA,GAMJ,MAAMM,EAAWC,EAAAA,SAASF,EAAcH,EAAa,CAAE,UAAWM,EAAAA,SAAS,SAAU,EAGrF,OAAAL,EAAQ,CACN,SAAAG,CAAA,CACD,EAGMA,EAAS,MAClB,EAGMG,GAA4B,CAACC,EAAMC,EAAMV,IAAa,CAC1D,IAAIW,EAAM,EAGV,OAAIF,EAAK,kBAAkBT,CAAQ,IACjCW,EAAMC,EAAAA,aACJH,EA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C,CAAC6B,GAASiF,EAAAA,kBAAAA,IAACsC,GAAAA,kBAAiB,MAAAvH,CAAA,CAAc,CAAA,CAAA,CAAA,CAGlD"}
@@ -1,7 +1,7 @@
1
1
  import { j as y } from "../../../../_virtual/jsx-runtime.es.js";
2
- import { useRef as R, useMemo as H, useCallback as g, useEffect as yt } from "react";
3
- import { TableContainer as Ct } from "./SimpleTable.styled.es.js";
4
- import { functionalUpdate as ot, useReactTable as bt, getExpandedRowModel as wt, getFilteredRowModel as Et, getCoreRowModel as Mt, flexRender as Ft, sortingFns as Kt } from "@tanstack/react-table";
2
+ import { useRef as R, useMemo as H, useCallback as f, useEffect as yt } from "react";
3
+ import { TableContainer as bt } from "./SimpleTable.styled.es.js";
4
+ import { functionalUpdate as ot, useReactTable as Ct, getExpandedRowModel as wt, getFilteredRowModel as Et, getCoreRowModel as Mt, flexRender as Ft, sortingFns as Kt } from "@tanstack/react-table";
5
5
  import { useVirtualizer as kt } from "@tanstack/react-virtual";
6
6
  import it from "clsx";
7
7
  import Tt from "./hooks/useRowKeydown.es.js";
@@ -303,25 +303,25 @@ import "../../components/Menu/Menu.styled.es.js";
303
303
  import "../../components/Menu/MenuItem.es.js";
304
304
  import "../../components/ReviewablesSelector/ReviewablesSelector.es.js";
305
305
  import "../../components/ColumnHeaderMenuUI.es.js";
306
- const Vt = (e) => e ? Array.isArray(e) ? e.filter(Boolean) : [e] : [], $t = (e, a, d, f) => {
306
+ const Vt = (e) => e ? Array.isArray(e) ? e.filter(Boolean) : [e] : [], $t = (e, a, d, g) => {
307
307
  const s = e.getValue(a);
308
308
  let u = typeof s == "string" ? s : Array.isArray(s) ? s.join(" ") : JSON.stringify(s);
309
309
  a === "label" && (u = [e.original.label, e.original.name, ...e.original.parents || []].join(
310
310
  " "
311
311
  ));
312
312
  const h = zt(u, d, { threshold: Dt.CONTAINS });
313
- return f({
313
+ return g({
314
314
  itemRank: h
315
315
  }), h.passed;
316
316
  }, Ot = (e, a, d) => {
317
- let f = 0;
318
- return e.columnFiltersMeta[d] && (f = jt(
317
+ let g = 0;
318
+ return e.columnFiltersMeta[d] && (g = jt(
319
319
  e.columnFiltersMeta[d]?.itemRank,
320
320
  a.columnFiltersMeta[d]?.itemRank
321
- )), f === 0 ? Kt.alphanumeric(e, a, d) : f;
321
+ )), g === 0 ? Kt.alphanumeric(e, a, d) : g;
322
322
  };
323
323
  function qt(e, a, d) {
324
- const f = [];
324
+ const g = [];
325
325
  if (a === d) {
326
326
  const c = e.find((E) => E.id === a);
327
327
  return c ? [c] : [];
@@ -332,14 +332,14 @@ function qt(e, a, d) {
332
332
  if (s === -1 || u === -1) return [];
333
333
  const h = Math.min(s, u), w = Math.max(s, u);
334
334
  for (let c = h; c <= w; c++)
335
- f.push(e[c]);
336
- return f;
335
+ g.push(e[c]);
336
+ return g;
337
337
  }
338
338
  const Em = ({
339
339
  data: e = [],
340
340
  isLoading: a,
341
341
  error: d,
342
- isExpandable: f,
342
+ isExpandable: g,
343
343
  isMultiSelect: s = !0,
344
344
  enableClickToDeselect: u = !0,
345
345
  enableNonFolderIndent: h = !0,
@@ -368,7 +368,7 @@ const Em = ({
368
368
  onRowSelectionChange: K,
369
369
  rowPinning: G,
370
370
  onRowPinningChange: A
371
- } = At(), b = R(null), x = R(null), [Q] = Pt(), U = R(B);
371
+ } = At(), C = R(null), x = R(null), [Q] = Pt(), U = R(B);
372
372
  U.current = B;
373
373
  const W = R(O);
374
374
  W.current = O;
@@ -388,16 +388,16 @@ const Em = ({
388
388
  data: {
389
389
  id: `placeholder-${o}`
390
390
  }
391
- })) : e, [a, e, w]), C = g(
391
+ })) : e, [a, e, w]), b = f(
392
392
  (t, o, i, m) => {
393
393
  const n = o, p = t.getFilteredRowModel().flatRows, r = p.find((l) => l.id === n);
394
394
  if (r && !r.original.isDisabled) {
395
395
  if (u && !i && !m && Object.keys(t.getState().rowSelection).length === 1 && t.getState().rowSelection[n]) {
396
- t.setRowSelection({}), b.current = null;
396
+ t.setRowSelection({}), C.current = null;
397
397
  return;
398
398
  }
399
- if (s && i && b.current) {
400
- const l = b.current;
399
+ if (s && i && C.current) {
400
+ const l = C.current;
401
401
  if (!p.find((S) => S.id === l))
402
402
  t.setRowSelection({ [n]: !0 });
403
403
  else {
@@ -411,18 +411,18 @@ const Em = ({
411
411
  const l = t.getState().rowSelection;
412
412
  Object.keys(l).length === 1 && l[n] || t.setRowSelection({ [n]: !0 });
413
413
  }
414
- b.current = n;
414
+ C.current = n;
415
415
  }
416
416
  },
417
417
  [s, u]
418
- ), pt = g(
418
+ ), pt = f(
419
419
  (t, o) => {
420
420
  if (!x.current) {
421
421
  console.warn("tableRef not yet available in handleRowSelectForKeydown");
422
422
  return;
423
423
  }
424
424
  const i = t.shiftKey, m = t.ctrlKey || t.metaKey;
425
- C(
425
+ b(
426
426
  x.current,
427
427
  // Pass the main table instance
428
428
  o.id,
@@ -430,9 +430,9 @@ const Em = ({
430
430
  m
431
431
  );
432
432
  },
433
- [C]
433
+ [b]
434
434
  // Depends only on handleSelectionLogic
435
- ), lt = g(
435
+ ), lt = f(
436
436
  (t, o, i) => {
437
437
  if (!x.current) return;
438
438
  const m = x.current.getRowModel().rows, n = m.findIndex((r) => r.id === o.id);
@@ -442,7 +442,7 @@ const Em = ({
442
442
  for (; p >= 0 && p < m.length; ) {
443
443
  const r = m[p];
444
444
  if (!r.original.isDisabled) {
445
- C(
445
+ b(
446
446
  x.current,
447
447
  r.id,
448
448
  i.shiftKey,
@@ -456,8 +456,8 @@ const Em = ({
456
456
  p = t === "down" ? p + 1 : p - 1;
457
457
  }
458
458
  },
459
- [C]
460
- ), at = g(
459
+ [b]
460
+ ), at = f(
461
461
  (t, o) => {
462
462
  o.original.isDisabled || Z.current?.(o.id, o);
463
463
  },
@@ -477,7 +477,7 @@ const Em = ({
477
477
  //sort by fuzzy rank (falls back to alphanumeric)
478
478
  cell: ({ row: t, getValue: o, table: i }) => {
479
479
  const m = i.options.meta, n = (r) => {
480
- r.target instanceof HTMLInputElement || r.target instanceof HTMLButtonElement || r.target instanceof HTMLTextAreaElement || r.target instanceof HTMLSelectElement || r.target instanceof HTMLAnchorElement || r.target.closest("button, a, input, textarea, select") || C(
480
+ r.target instanceof HTMLInputElement || r.target instanceof HTMLButtonElement || r.target instanceof HTMLTextAreaElement || r.target instanceof HTMLSelectElement || r.target instanceof HTMLAnchorElement || r.target.closest("button, a, input, textarea, select") || b(
481
481
  i,
482
482
  // Pass the cell's table instance
483
483
  t.id,
@@ -513,6 +513,7 @@ const Em = ({
513
513
  onExpandClick: t.getToggleExpandedHandler(),
514
514
  startContent: t.original.startContent,
515
515
  endContent: t.original.endContent,
516
+ badge: t.original.badge,
516
517
  isDisabled: t.original.isDisabled,
517
518
  disabledMessage: t.original.disabledMessage,
518
519
  isRenaming: t.id === W.current,
@@ -529,23 +530,23 @@ const Em = ({
529
530
  ],
530
531
  [
531
532
  w,
532
- C,
533
+ b,
533
534
  I,
534
535
  u,
535
536
  h,
536
537
  V
537
538
  ]
538
- ), ct = g(
539
+ ), ct = f(
539
540
  (t) => {
540
541
  K(ot(t, F));
541
542
  },
542
543
  [K]
543
- ), dt = g(
544
+ ), dt = f(
544
545
  (t) => {
545
546
  A?.(ot(t, G || {}));
546
547
  },
547
548
  [A]
548
- ), ut = g(
549
+ ), ut = f(
549
550
  (t) => {
550
551
  v?.((o) => {
551
552
  const i = t instanceof Function ? t(o) : t;
@@ -553,7 +554,7 @@ const Em = ({
553
554
  });
554
555
  },
555
556
  [v]
556
- ), k = bt({
557
+ ), k = Ct({
557
558
  data: mt,
558
559
  columns: st,
559
560
  state: {
@@ -584,18 +585,18 @@ const Em = ({
584
585
  // @ts-expect-error: updateData is not required
585
586
  meta: H(
586
587
  () => ({
587
- isExpandable: !!f,
588
+ isExpandable: !!g,
588
589
  isLoading: a,
589
590
  children: Y,
590
591
  ...E
591
592
  }),
592
- [f, a, Y, E]
593
+ [g, a, Y, E]
593
594
  )
594
595
  });
595
596
  yt(() => {
596
597
  x.current = k;
597
598
  }, [k]);
598
- const { rows: T } = k.getRowModel(), ft = g(
599
+ const { rows: T } = k.getRowModel(), gt = f(
599
600
  (t, o, i) => {
600
601
  if (!x.current) return;
601
602
  const m = T[o];
@@ -628,12 +629,12 @@ const Em = ({
628
629
  //measure dynamic row height, except in firefox because it measures table border height incorrectly
629
630
  measureElement: z ? () => z : typeof window < "u" && navigator.userAgent.indexOf("Firefox") === -1 ? (t) => t?.getBoundingClientRect().height : void 0,
630
631
  overscan: 5
631
- }), gt = g(
632
+ }), ft = f(
632
633
  (t) => {
633
634
  t && j.measureElement(t);
634
635
  },
635
636
  [j]
636
- ), Rt = g(
637
+ ), Rt = f(
637
638
  (t) => {
638
639
  if (!D) return;
639
640
  const o = t.currentTarget, { scrollTop: i, scrollHeight: m, clientHeight: n } = o;
@@ -641,10 +642,10 @@ const Em = ({
641
642
  },
642
643
  [D, a]
643
644
  ), ht = (t) => {
644
- u && !t.target.closest("tr") && (k.setRowSelection({}), b.current = null);
645
+ u && !t.target.closest("tr") && (k.setRowSelection({}), C.current = null);
645
646
  };
646
647
  return /* @__PURE__ */ y.jsxs(
647
- Ct,
648
+ bt,
648
649
  {
649
650
  ref: P,
650
651
  onScroll: Rt,
@@ -665,9 +666,9 @@ const Em = ({
665
666
  "tr",
666
667
  {
667
668
  "data-index": t.index,
668
- ref: gt,
669
+ ref: ft,
669
670
  id: o.id,
670
- onContextMenu: (i) => ft(o.id, t.index, i),
671
+ onContextMenu: (i) => gt(o.id, t.index, i),
671
672
  ...M?.row,
672
673
  style: {
673
674
  transform: `translateY(${t.start}px)`,
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleTable.es.js","sources":["../../../../../src/containers/SimpleTable/SimpleTable.tsx"],"sourcesContent":["import { FC, useMemo, useRef, MouseEvent as ReactMouseEvent, useCallback, useEffect } from 'react'\nimport * as Styled from './SimpleTable.styled'\nimport {\n useReactTable,\n getCoreRowModel,\n getFilteredRowModel,\n getExpandedRowModel,\n ColumnDef,\n flexRender,\n Row,\n FilterFn,\n SortingFn,\n sortingFns,\n Table,\n RowData,\n OnChangeFn,\n RowSelectionState,\n functionalUpdate,\n} from '@tanstack/react-table'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport clsx from 'clsx'\nimport useRowKeydown, { RowKeyboardEvent } from './hooks/useRowKeydown'\n\nimport { rankItem, compareItems, rankings } from '@tanstack/match-sorter-utils'\nimport { useSimpleTableContext } from './context/SimpleTableContext'\nimport { SimpleTableCellTemplate, SimpleTableCellTemplateProps } from './SimpleTableRowTemplate'\nimport { EmptyPlaceholder } from '@shared/components'\nimport { RowPinningState } from '@tanstack/react-table'\nimport {\n SimpleTableProps,\n SimpleTableRow,\n SimpleTableRowContextMenuBuilder,\n} from './SimpleTable.types'\nimport { useCreateContextMenu } from '../ContextMenu'\n\nconst toMenuItems = (items: ReturnType<SimpleTableRowContextMenuBuilder>) => {\n if (!items) return []\n return Array.isArray(items) ? items.filter(Boolean) : [items]\n}\n\n// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)\nconst fuzzyFilter: FilterFn<any> = (row, columnId, searchValue, addMeta) => {\n const cellValue = row.getValue(columnId)\n // convert non-string cell values to string\n let searchString =\n typeof cellValue === 'string'\n ? cellValue\n : Array.isArray(cellValue)\n ? cellValue.join(' ')\n : JSON.stringify(cellValue)\n\n // combine label and parents into a single string for searching if columnId is 'label'\n if (columnId === 'label') {\n searchString = [row.original.label, row.original.name, ...(row.original.parents || [])].join(\n ' ',\n )\n }\n\n // Rank the item with CONTAINS threshold to avoid overly permissive fuzzy matches\n // This ensures the search term must be a substring, not just scattered characters\n const itemRank = rankItem(searchString, searchValue, { threshold: rankings.CONTAINS })\n\n // Store the itemRank info\n addMeta({\n itemRank,\n })\n\n // Return if the item should be filtered in/out\n return itemRank.passed\n}\n\n// Define a custom fuzzy sort function that will sort by rank if the row has ranking information\nconst fuzzySort: SortingFn<any> = (rowA, rowB, columnId) => {\n let dir = 0\n\n // Only sort by rank if the column has ranking information\n if (rowA.columnFiltersMeta[columnId]) {\n dir = compareItems(\n rowA.columnFiltersMeta[columnId]?.itemRank!,\n rowB.columnFiltersMeta[columnId]?.itemRank!,\n )\n }\n\n // Provide an alphanumeric fallback for when the item ranks are equal\n return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir\n}\n\n// Helper function to get row range for shift-selection\n// Operates on the provided list of rows (e.g., filtered and sorted rows)\nfunction getRowRange<TData extends RowData>(\n rows: Array<Row<TData>>,\n idA: string,\n idB: string,\n): Array<Row<TData>> {\n const range: Array<Row<TData>> = []\n // If idA and idB are the same, or one is not found, handle appropriately\n if (idA === idB) {\n const singleRow = rows.find((row) => row.id === idA)\n return singleRow ? [singleRow] : []\n }\n\n let indexA = -1\n let indexB = -1\n\n for (let i = 0; i < rows.length; i++) {\n if (rows[i].id === idA) indexA = i\n if (rows[i].id === idB) indexB = i\n if (indexA !== -1 && indexB !== -1) break\n }\n\n if (indexA === -1 || indexB === -1) return [] // One or both IDs not found\n\n const start = Math.min(indexA, indexB)\n const end = Math.max(indexA, indexB)\n\n for (let i = start; i <= end; i++) {\n range.push(rows[i])\n }\n return range\n}\n\nconst SimpleTable: FC<SimpleTableProps> = ({\n data = [],\n isLoading,\n error,\n isExpandable,\n isMultiSelect = true,\n enableClickToDeselect = true,\n enableNonFolderIndent = true,\n forceUpdateTable,\n globalFilter,\n meta,\n rowHeight,\n imgRatio,\n onScrollBottom,\n onRename,\n renamingId,\n onSubmitRename,\n onCancelRename,\n onRowDoubleClick,\n rowContextMenuBuilders = [],\n children,\n pt,\n fitContent,\n ...props\n}) => {\n const {\n rowSelection,\n expanded,\n setExpanded,\n onExpandedChange,\n onRowSelectionChange,\n rowPinning,\n onRowPinningChange,\n } = useSimpleTableContext()\n const lastSelectedIdRef = useRef<string | null>(null)\n const tableRef = useRef<Table<SimpleTableRow> | null>(null)\n const [showRowContextMenu] = useCreateContextMenu()\n\n // Refs for values used inside the columns memo.\n // Assigning synchronously (not via useEffect) means the cell function always reads\n // the latest value at render time, while the columns memo itself has a minimal dep\n // array and stays as a stable reference — critical because flexRender calls\n // React.createElement with the cell function, so a new reference = remount = broken dblclick.\n const onRowDoubleClickRef = useRef(onRowDoubleClick)\n onRowDoubleClickRef.current = onRowDoubleClick\n const renamingIdRef = useRef(renamingId)\n renamingIdRef.current = renamingId\n const onSubmitRenameRef = useRef(onSubmitRename)\n onSubmitRenameRef.current = onSubmitRename\n const onCancelRenameRef = useRef(onCancelRename)\n onCancelRenameRef.current = onCancelRename\n const onRenameRef = useRef(onRename)\n onRenameRef.current = onRename\n\n // stable data reference\n const tableData = useMemo(() => {\n if (!isLoading) return data\n\n // show loading placeholders\n return Array.from({ length: 10 }, (_, i) => ({\n id: `placeholder-${i}`,\n name: `placeholder-${i}`,\n label: `placeholder-${i}`,\n icon: null,\n img: null,\n subRows: [],\n data: {\n id: `placeholder-${i}`,\n },\n }))\n }, [isLoading, data, forceUpdateTable])\n\n // Define the core selection logic using useCallback for stability\n const handleSelectionLogic = useCallback(\n (\n tableInstance: Table<SimpleTableRow>,\n rowId: string,\n isShift: boolean,\n isCtrlOrMeta: boolean,\n ) => {\n const currentId = rowId\n const allProcessableRows = tableInstance.getFilteredRowModel().flatRows\n const currentRow = allProcessableRows.find((r) => r.id === currentId)\n\n if (!currentRow) return\n\n // Prevent selection of disabled rows\n if (currentRow.original.isDisabled) return\n\n // If click-to-deselect is enabled and only one row is selected and it's the current row\n if (\n enableClickToDeselect &&\n !isShift &&\n !isCtrlOrMeta &&\n Object.keys(tableInstance.getState().rowSelection).length === 1 &&\n tableInstance.getState().rowSelection[currentId]\n ) {\n tableInstance.setRowSelection({})\n lastSelectedIdRef.current = null\n return\n }\n\n if (isMultiSelect && isShift && lastSelectedIdRef.current) {\n const lastId = lastSelectedIdRef.current\n const anchorRow = allProcessableRows.find((r) => r.id === lastId)\n\n if (!anchorRow) {\n tableInstance.setRowSelection({ [currentId]: true })\n } else {\n const rowsToToggle = getRowRange(allProcessableRows, currentId, lastId)\n const newSelection: RowSelectionState = {}\n rowsToToggle.forEach((r) => (newSelection[r.id] = true))\n tableInstance.setRowSelection(newSelection)\n }\n } else if (isMultiSelect && isCtrlOrMeta) {\n // write a concrete object from live state; toggleSelected()'s functional updater runs\n // against a stale rowSelection closure and drops the other selected rows\n const selection = { ...tableInstance.getState().rowSelection }\n if (selection[currentId]) {\n delete selection[currentId]\n } else {\n selection[currentId] = true\n }\n tableInstance.setRowSelection(selection)\n } else {\n // If it's already selected and it's the only one, don't update selection to avoid unnecessary re-renders\n const selection = tableInstance.getState().rowSelection\n if (!(Object.keys(selection).length === 1 && selection[currentId])) {\n tableInstance.setRowSelection({ [currentId]: true })\n }\n }\n lastSelectedIdRef.current = currentId\n },\n [isMultiSelect, enableClickToDeselect],\n )\n\n // Callback for useRowKeydown's handleRowSelect prop\n // Uses tableRef to access the table instance, avoiding direct dependency on 'table' variable at definition time\n const handleRowSelectForKeydown = useCallback(\n (\n event: RowKeyboardEvent, // Use the specific keyboard event type from the hook\n selectedRow: Row<SimpleTableRow>,\n ) => {\n if (!tableRef.current) {\n console.warn('tableRef not yet available in handleRowSelectForKeydown')\n return\n }\n\n // Extract modifier keys from the event\n const isShiftKey = event.shiftKey\n const isCtrlKey = event.ctrlKey || event.metaKey\n\n handleSelectionLogic(\n tableRef.current, // Pass the main table instance\n selectedRow.id,\n isShiftKey,\n isCtrlKey,\n )\n },\n [handleSelectionLogic], // Depends only on handleSelectionLogic\n )\n\n // Handle arrow key navigation\n const handleArrowNavigation = useCallback(\n (direction: 'up' | 'down', currentRow: Row<SimpleTableRow>, event: RowKeyboardEvent) => {\n if (!tableRef.current) return\n\n // Use the row model which respects expanded state, not filtered model\n const visibleRows = tableRef.current.getRowModel().rows\n const currentIndex = visibleRows.findIndex((r) => r.id === currentRow.id)\n\n if (currentIndex === -1) return\n\n let nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1\n\n // Check bounds\n if (nextIndex < 0 || nextIndex >= visibleRows.length) return\n\n // Skip disabled rows\n while (nextIndex >= 0 && nextIndex < visibleRows.length) {\n const nextRow = visibleRows[nextIndex]\n if (!nextRow.original.isDisabled) {\n // Found a valid row\n // Select the next row\n handleSelectionLogic(\n tableRef.current,\n nextRow.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n\n // Focus the next row's cell. Scope to this table's container: row ids are\n // entity ids that can also exist in other SimpleTables on the page (slicer),\n // so a document-wide getElementById would steal focus to a duplicate.\n requestAnimationFrame(() => {\n const container = tableContainerRef.current\n const nextRowElement = container\n ? container.querySelector(`#${CSS.escape(nextRow.id)}`)\n : document.getElementById(nextRow.id)\n const nextCell = nextRowElement?.querySelector('[tabindex=\"0\"]') as HTMLElement\n if (nextCell) {\n nextCell.focus()\n nextCell.scrollIntoView({ block: 'nearest', behavior: 'smooth' })\n }\n })\n return\n }\n // Move to next row if current is disabled\n nextIndex = direction === 'down' ? nextIndex + 1 : nextIndex - 1\n }\n },\n [handleSelectionLogic],\n )\n\n // handleRenameForKeydown reads from onRenameRef so it has empty deps and is\n // permanently stable — keeping handleRowKeyDown and therefore columns stable.\n const handleRenameForKeydown = useCallback(\n (e: RowKeyboardEvent, row: Row<SimpleTableRow>) => {\n if (!row.original.isDisabled) onRenameRef.current?.(row.id, row)\n },\n [], // eslint-disable-line react-hooks/exhaustive-deps\n )\n\n const { handleRowKeyDown } = useRowKeydown<SimpleTableRow>({\n handleRowSelect: handleRowSelectForKeydown,\n handleArrowNavigation,\n handleRename: handleRenameForKeydown,\n })\n\n const columns = useMemo<ColumnDef<SimpleTableRow>[]>(\n () => [\n {\n accessorKey: 'label',\n header: undefined,\n filterFn: 'fuzzy',\n sortingFn: fuzzySort, //sort by fuzzy rank (falls back to alphanumeric)\n cell: ({ row, getValue, table: cellTableInstance }) => {\n const cellMeta = cellTableInstance.options.meta\n\n const handleCellClick = (event: ReactMouseEvent<HTMLElement, MouseEvent>) => {\n // Prevent row selection if clicking on an interactive element within the cell\n if (\n event.target instanceof HTMLInputElement ||\n event.target instanceof HTMLButtonElement ||\n event.target instanceof HTMLTextAreaElement ||\n event.target instanceof HTMLSelectElement ||\n event.target instanceof HTMLAnchorElement ||\n (event.target as HTMLElement).closest('button, a, input, textarea, select')\n ) {\n return\n }\n handleSelectionLogic(\n cellTableInstance, // Pass the cell's table instance\n row.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n }\n\n const props: SimpleTableCellTemplateProps & {\n onClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n onDoubleClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n } = {\n className: clsx({\n selected: row.getIsSelected(),\n loading: cellMeta?.isLoading,\n disabled: row.original.isDisabled, // you can't select disabled rows\n inactive: row.original.inactive, // false: archived items but still selectable\n }),\n onKeyDown: (e) => {\n if (e.target instanceof HTMLInputElement) return\n // Corrected typo: handleRowKeydown -> handleRowKeyDown\n handleRowKeyDown(e, row)\n },\n depth: row.depth,\n tabIndex: 0,\n value: getValue<string>(),\n parents: row.original.parents,\n icon: row.original.icon || undefined,\n iconColor: row.original.iconColor,\n iconFilled: row.original.iconFilled,\n img: row.original.img,\n imgShape: row.original.imgShape,\n imgRatio: imgRatio,\n isRowExpandable: row.getCanExpand(),\n enableNonFolderIndent,\n isRowExpanded: row.getIsExpanded(),\n isTableExpandable: cellMeta?.isExpandable,\n onExpandClick: row.getToggleExpandedHandler(),\n startContent: row.original.startContent,\n endContent: row.original.endContent,\n isDisabled: row.original.isDisabled,\n disabledMessage: row.original.disabledMessage,\n isRenaming: row.id === renamingIdRef.current,\n onSubmitRename: onSubmitRenameRef.current\n ? (v) => onSubmitRenameRef.current!(row.id, v)\n : undefined,\n onCancelRename: onCancelRenameRef.current,\n ...pt?.cell,\n onClick: handleCellClick, // Added onClick handler\n onDoubleClick: (e) => onRowDoubleClickRef.current?.(row.id, row),\n }\n\n // Use children function if provided, otherwise default to SimpleTableCellTemplate\n return cellMeta?.children ? (\n cellMeta.children(props, row, cellTableInstance)\n ) : (\n <SimpleTableCellTemplate {...props} {...pt?.cell} />\n )\n },\n },\n ],\n [\n forceUpdateTable,\n handleSelectionLogic,\n handleRowKeyDown,\n enableClickToDeselect,\n enableNonFolderIndent,\n imgRatio,\n ],\n )\n\n const handleRowSelectionChangeCallback: OnChangeFn<RowSelectionState> = useCallback(\n (updater) => {\n onRowSelectionChange(functionalUpdate(updater, rowSelection))\n },\n [onRowSelectionChange],\n )\n\n const handleRowPinningChangeCallback: OnChangeFn<RowPinningState> = useCallback(\n (updater) => {\n onRowPinningChange?.(functionalUpdate(updater, rowPinning || {}))\n },\n [onRowPinningChange],\n )\n\n const handleExpandedChange = useCallback(\n (updater: any) => {\n setExpanded?.((old) => {\n const newExpanded = updater instanceof Function ? updater(old) : updater\n onExpandedChange?.(newExpanded)\n return newExpanded\n })\n },\n [setExpanded],\n )\n\n const table = useReactTable({\n data: tableData,\n columns,\n state: {\n expanded,\n rowSelection,\n globalFilter,\n rowPinning,\n },\n onRowSelectionChange: handleRowSelectionChangeCallback,\n onRowPinningChange: handleRowPinningChangeCallback,\n filterFns: {\n fuzzy: fuzzyFilter,\n },\n globalFilterFn: 'fuzzy',\n enableRowSelection: true, //enable row selection for all rows\n enableRowPinning: !!onRowPinningChange,\n getRowId: (row) => row.id,\n enableSubRowSelection: false, //disable sub row selection\n onExpandedChange: handleExpandedChange,\n getSubRows: (row) => row.subRows,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getExpandedRowModel: getExpandedRowModel(),\n filterFromLeafRows: true,\n // debugTable: true,\n // @ts-expect-error: updateData is not required\n meta: useMemo(\n () => ({\n isExpandable: !!isExpandable,\n isLoading: isLoading,\n children: children,\n ...meta,\n }),\n [isExpandable, isLoading, children, meta],\n ),\n })\n\n // Update tableRef whenever the table instance changes.\n // This ensures handleRowSelectForKeydown uses the current table instance.\n useEffect(() => {\n tableRef.current = table\n }, [table])\n\n const { rows } = table.getRowModel()\n\n const handleRowContextMenu = useCallback(\n (rowId: string, rowIndex: number, e: ReactMouseEvent<HTMLTableRowElement>) => {\n if (!tableRef.current) return\n const row = rows[rowIndex]\n if (!row || row.original === undefined) return\n\n e.preventDefault()\n e.stopPropagation()\n\n const selectedIds = Object.keys(rowSelection)\n\n const nextSelectedRows = selectedIds.includes(rowId) ? selectedIds : [rowId]\n\n if (!selectedIds.includes(rowId)) {\n // convert array to RowSelectionState object\n const nextSelection: RowSelectionState = { [rowId]: true }\n onRowSelectionChange?.(nextSelection)\n }\n\n const menuItems = rowContextMenuBuilders.flatMap((builder) =>\n toMenuItems(\n builder(e as any, {\n rowId,\n rowIndex,\n row,\n selectedRows: nextSelectedRows,\n isSelected: nextSelectedRows.includes(rowId),\n }),\n ),\n )\n\n if (menuItems.length > 0) {\n showRowContextMenu(e as any, menuItems)\n }\n },\n [rowContextMenuBuilders, rows, rowSelection, onRowSelectionChange, showRowContextMenu],\n )\n\n //The virtualizer needs to know the scrollable container element\n const tableContainerRef = useRef<HTMLDivElement>(null)\n\n const rowVirtualizer = useVirtualizer({\n count: rows.length,\n estimateSize: () => rowHeight || 34, //estimate row height for accurate scrollbar dragging\n getScrollElement: () => tableContainerRef.current,\n //measure dynamic row height, except in firefox because it measures table border height incorrectly\n measureElement: rowHeight\n ? () => rowHeight\n : typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1\n ? (element) => element?.getBoundingClientRect().height\n : undefined,\n overscan: 5,\n })\n\n // Memoize the ref callback to prevent infinite re-renders\n const measureElementRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n rowVirtualizer.measureElement(node)\n }\n },\n [rowVirtualizer],\n )\n\n // Handle scroll to bottom detection\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLDivElement>) => {\n if (!onScrollBottom) return\n\n const target = event.currentTarget\n const { scrollTop, scrollHeight, clientHeight } = target\n\n // Check if we're near the bottom (within 100px)\n const isNearBottom = scrollHeight - scrollTop - clientHeight < 100\n\n if (isNearBottom && !isLoading) {\n onScrollBottom()\n }\n },\n [onScrollBottom, isLoading],\n )\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // if the click is outside of any row, clear selection\n if (enableClickToDeselect && !(e.target as HTMLElement).closest('tr')) {\n table.setRowSelection({})\n lastSelectedIdRef.current = null\n }\n }\n\n return (\n <Styled.TableContainer\n ref={tableContainerRef}\n onScroll={handleScroll}\n onClick={handleContainerClick}\n {...props}\n className={clsx(props.className, { isLoading, fitContent })}\n >\n {!error && (\n <table>\n <tbody\n style={{\n height: `${rowVirtualizer?.getTotalSize()}px`, //tells scrollbar how big the table is\n }}\n >\n {rowVirtualizer?.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index] as Row<SimpleTableRow>\n return (\n <tr\n data-index={virtualRow.index} //needed for dynamic row height measurement\n ref={measureElementRef} //measure dynamic row height\n key={row.id}\n id={row.id}\n onContextMenu={(e) => handleRowContextMenu(row.id, virtualRow.index, e)}\n {...pt?.row}\n style={{\n transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll\n ...pt?.row?.style, // custom styles to be passed\n }}\n >\n {row.getVisibleCells().map((cell) => {\n return (\n <td key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n )\n })}\n </tr>\n )\n })}\n </tbody>\n </table>\n )}\n {!!error && <EmptyPlaceholder error={error} />}\n </Styled.TableContainer>\n )\n}\n\nexport default SimpleTable\n"],"names":["toMenuItems","items","fuzzyFilter","row","columnId","searchValue","addMeta","cellValue","searchString","itemRank","rankItem","rankings","fuzzySort","rowA","rowB","dir","compareItems","sortingFns","getRowRange","rows","idA","idB","range","singleRow","indexA","indexB","i","start","end","SimpleTable","data","isLoading","error","isExpandable","isMultiSelect","enableClickToDeselect","enableNonFolderIndent","forceUpdateTable","globalFilter","meta","rowHeight","imgRatio","onScrollBottom","onRename","renamingId","onSubmitRename","onCancelRename","onRowDoubleClick","rowContextMenuBuilders","children","pt","fitContent","props","rowSelection","expanded","setExpanded","onExpandedChange","onRowSelectionChange","rowPinning","onRowPinningChange","useSimpleTableContext","lastSelectedIdRef","useRef","tableRef","showRowContextMenu","useCreateContextMenu","onRowDoubleClickRef","renamingIdRef","onSubmitRenameRef","onCancelRenameRef","onRenameRef","tableData","useMemo","_","handleSelectionLogic","useCallback","tableInstance","rowId","isShift","isCtrlOrMeta","currentId","allProcessableRows","currentRow","r","lastId","rowsToToggle","newSelection","selection","handleRowSelectForKeydown","event","selectedRow","isShiftKey","isCtrlKey","handleArrowNavigation","direction","visibleRows","currentIndex","nextIndex","nextRow","container","tableContainerRef","nextCell","handleRenameForKeydown","e","handleRowKeyDown","useRowKeydown","columns","getValue","cellTableInstance","cellMeta","handleCellClick","clsx","v","jsx","SimpleTableCellTemplate","handleRowSelectionChangeCallback","updater","functionalUpdate","handleRowPinningChangeCallback","handleExpandedChange","old","newExpanded","table","useReactTable","getCoreRowModel","getFilteredRowModel","getExpandedRowModel","useEffect","handleRowContextMenu","rowIndex","selectedIds","nextSelectedRows","nextSelection","menuItems","builder","rowVirtualizer","useVirtualizer","element","measureElementRef","node","handleScroll","target","scrollTop","scrollHeight","clientHeight","handleContainerClick","jsxs","Styled.TableContainer","virtualRow","cell","flexRender","EmptyPlaceholder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAMA,KAAc,CAACC,MACdA,IACE,MAAM,QAAQA,CAAK,IAAIA,EAAM,OAAO,OAAO,IAAI,CAACA,CAAK,IADzC,C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}
1
+ {"version":3,"file":"SimpleTable.es.js","sources":["../../../../../src/containers/SimpleTable/SimpleTable.tsx"],"sourcesContent":["import { FC, useMemo, useRef, MouseEvent as ReactMouseEvent, useCallback, useEffect } from 'react'\nimport * as Styled from './SimpleTable.styled'\nimport {\n useReactTable,\n getCoreRowModel,\n getFilteredRowModel,\n getExpandedRowModel,\n ColumnDef,\n flexRender,\n Row,\n FilterFn,\n SortingFn,\n sortingFns,\n Table,\n RowData,\n OnChangeFn,\n RowSelectionState,\n functionalUpdate,\n} from '@tanstack/react-table'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport clsx from 'clsx'\nimport useRowKeydown, { RowKeyboardEvent } from './hooks/useRowKeydown'\n\nimport { rankItem, compareItems, rankings } from '@tanstack/match-sorter-utils'\nimport { useSimpleTableContext } from './context/SimpleTableContext'\nimport { SimpleTableCellTemplate, SimpleTableCellTemplateProps } from './SimpleTableRowTemplate'\nimport { EmptyPlaceholder } from '@shared/components'\nimport { RowPinningState } from '@tanstack/react-table'\nimport {\n SimpleTableProps,\n SimpleTableRow,\n SimpleTableRowContextMenuBuilder,\n} from './SimpleTable.types'\nimport { useCreateContextMenu } from '../ContextMenu'\n\nconst toMenuItems = (items: ReturnType<SimpleTableRowContextMenuBuilder>) => {\n if (!items) return []\n return Array.isArray(items) ? items.filter(Boolean) : [items]\n}\n\n// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)\nconst fuzzyFilter: FilterFn<any> = (row, columnId, searchValue, addMeta) => {\n const cellValue = row.getValue(columnId)\n // convert non-string cell values to string\n let searchString =\n typeof cellValue === 'string'\n ? cellValue\n : Array.isArray(cellValue)\n ? cellValue.join(' ')\n : JSON.stringify(cellValue)\n\n // combine label and parents into a single string for searching if columnId is 'label'\n if (columnId === 'label') {\n searchString = [row.original.label, row.original.name, ...(row.original.parents || [])].join(\n ' ',\n )\n }\n\n // Rank the item with CONTAINS threshold to avoid overly permissive fuzzy matches\n // This ensures the search term must be a substring, not just scattered characters\n const itemRank = rankItem(searchString, searchValue, { threshold: rankings.CONTAINS })\n\n // Store the itemRank info\n addMeta({\n itemRank,\n })\n\n // Return if the item should be filtered in/out\n return itemRank.passed\n}\n\n// Define a custom fuzzy sort function that will sort by rank if the row has ranking information\nconst fuzzySort: SortingFn<any> = (rowA, rowB, columnId) => {\n let dir = 0\n\n // Only sort by rank if the column has ranking information\n if (rowA.columnFiltersMeta[columnId]) {\n dir = compareItems(\n rowA.columnFiltersMeta[columnId]?.itemRank!,\n rowB.columnFiltersMeta[columnId]?.itemRank!,\n )\n }\n\n // Provide an alphanumeric fallback for when the item ranks are equal\n return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir\n}\n\n// Helper function to get row range for shift-selection\n// Operates on the provided list of rows (e.g., filtered and sorted rows)\nfunction getRowRange<TData extends RowData>(\n rows: Array<Row<TData>>,\n idA: string,\n idB: string,\n): Array<Row<TData>> {\n const range: Array<Row<TData>> = []\n // If idA and idB are the same, or one is not found, handle appropriately\n if (idA === idB) {\n const singleRow = rows.find((row) => row.id === idA)\n return singleRow ? [singleRow] : []\n }\n\n let indexA = -1\n let indexB = -1\n\n for (let i = 0; i < rows.length; i++) {\n if (rows[i].id === idA) indexA = i\n if (rows[i].id === idB) indexB = i\n if (indexA !== -1 && indexB !== -1) break\n }\n\n if (indexA === -1 || indexB === -1) return [] // One or both IDs not found\n\n const start = Math.min(indexA, indexB)\n const end = Math.max(indexA, indexB)\n\n for (let i = start; i <= end; i++) {\n range.push(rows[i])\n }\n return range\n}\n\nconst SimpleTable: FC<SimpleTableProps> = ({\n data = [],\n isLoading,\n error,\n isExpandable,\n isMultiSelect = true,\n enableClickToDeselect = true,\n enableNonFolderIndent = true,\n forceUpdateTable,\n globalFilter,\n meta,\n rowHeight,\n imgRatio,\n onScrollBottom,\n onRename,\n renamingId,\n onSubmitRename,\n onCancelRename,\n onRowDoubleClick,\n rowContextMenuBuilders = [],\n children,\n pt,\n fitContent,\n ...props\n}) => {\n const {\n rowSelection,\n expanded,\n setExpanded,\n onExpandedChange,\n onRowSelectionChange,\n rowPinning,\n onRowPinningChange,\n } = useSimpleTableContext()\n const lastSelectedIdRef = useRef<string | null>(null)\n const tableRef = useRef<Table<SimpleTableRow> | null>(null)\n const [showRowContextMenu] = useCreateContextMenu()\n\n // Refs for values used inside the columns memo.\n // Assigning synchronously (not via useEffect) means the cell function always reads\n // the latest value at render time, while the columns memo itself has a minimal dep\n // array and stays as a stable reference — critical because flexRender calls\n // React.createElement with the cell function, so a new reference = remount = broken dblclick.\n const onRowDoubleClickRef = useRef(onRowDoubleClick)\n onRowDoubleClickRef.current = onRowDoubleClick\n const renamingIdRef = useRef(renamingId)\n renamingIdRef.current = renamingId\n const onSubmitRenameRef = useRef(onSubmitRename)\n onSubmitRenameRef.current = onSubmitRename\n const onCancelRenameRef = useRef(onCancelRename)\n onCancelRenameRef.current = onCancelRename\n const onRenameRef = useRef(onRename)\n onRenameRef.current = onRename\n\n // stable data reference\n const tableData = useMemo(() => {\n if (!isLoading) return data\n\n // show loading placeholders\n return Array.from({ length: 10 }, (_, i) => ({\n id: `placeholder-${i}`,\n name: `placeholder-${i}`,\n label: `placeholder-${i}`,\n icon: null,\n img: null,\n subRows: [],\n data: {\n id: `placeholder-${i}`,\n },\n }))\n }, [isLoading, data, forceUpdateTable])\n\n // Define the core selection logic using useCallback for stability\n const handleSelectionLogic = useCallback(\n (\n tableInstance: Table<SimpleTableRow>,\n rowId: string,\n isShift: boolean,\n isCtrlOrMeta: boolean,\n ) => {\n const currentId = rowId\n const allProcessableRows = tableInstance.getFilteredRowModel().flatRows\n const currentRow = allProcessableRows.find((r) => r.id === currentId)\n\n if (!currentRow) return\n\n // Prevent selection of disabled rows\n if (currentRow.original.isDisabled) return\n\n // If click-to-deselect is enabled and only one row is selected and it's the current row\n if (\n enableClickToDeselect &&\n !isShift &&\n !isCtrlOrMeta &&\n Object.keys(tableInstance.getState().rowSelection).length === 1 &&\n tableInstance.getState().rowSelection[currentId]\n ) {\n tableInstance.setRowSelection({})\n lastSelectedIdRef.current = null\n return\n }\n\n if (isMultiSelect && isShift && lastSelectedIdRef.current) {\n const lastId = lastSelectedIdRef.current\n const anchorRow = allProcessableRows.find((r) => r.id === lastId)\n\n if (!anchorRow) {\n tableInstance.setRowSelection({ [currentId]: true })\n } else {\n const rowsToToggle = getRowRange(allProcessableRows, currentId, lastId)\n const newSelection: RowSelectionState = {}\n rowsToToggle.forEach((r) => (newSelection[r.id] = true))\n tableInstance.setRowSelection(newSelection)\n }\n } else if (isMultiSelect && isCtrlOrMeta) {\n // write a concrete object from live state; toggleSelected()'s functional updater runs\n // against a stale rowSelection closure and drops the other selected rows\n const selection = { ...tableInstance.getState().rowSelection }\n if (selection[currentId]) {\n delete selection[currentId]\n } else {\n selection[currentId] = true\n }\n tableInstance.setRowSelection(selection)\n } else {\n // If it's already selected and it's the only one, don't update selection to avoid unnecessary re-renders\n const selection = tableInstance.getState().rowSelection\n if (!(Object.keys(selection).length === 1 && selection[currentId])) {\n tableInstance.setRowSelection({ [currentId]: true })\n }\n }\n lastSelectedIdRef.current = currentId\n },\n [isMultiSelect, enableClickToDeselect],\n )\n\n // Callback for useRowKeydown's handleRowSelect prop\n // Uses tableRef to access the table instance, avoiding direct dependency on 'table' variable at definition time\n const handleRowSelectForKeydown = useCallback(\n (\n event: RowKeyboardEvent, // Use the specific keyboard event type from the hook\n selectedRow: Row<SimpleTableRow>,\n ) => {\n if (!tableRef.current) {\n console.warn('tableRef not yet available in handleRowSelectForKeydown')\n return\n }\n\n // Extract modifier keys from the event\n const isShiftKey = event.shiftKey\n const isCtrlKey = event.ctrlKey || event.metaKey\n\n handleSelectionLogic(\n tableRef.current, // Pass the main table instance\n selectedRow.id,\n isShiftKey,\n isCtrlKey,\n )\n },\n [handleSelectionLogic], // Depends only on handleSelectionLogic\n )\n\n // Handle arrow key navigation\n const handleArrowNavigation = useCallback(\n (direction: 'up' | 'down', currentRow: Row<SimpleTableRow>, event: RowKeyboardEvent) => {\n if (!tableRef.current) return\n\n // Use the row model which respects expanded state, not filtered model\n const visibleRows = tableRef.current.getRowModel().rows\n const currentIndex = visibleRows.findIndex((r) => r.id === currentRow.id)\n\n if (currentIndex === -1) return\n\n let nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1\n\n // Check bounds\n if (nextIndex < 0 || nextIndex >= visibleRows.length) return\n\n // Skip disabled rows\n while (nextIndex >= 0 && nextIndex < visibleRows.length) {\n const nextRow = visibleRows[nextIndex]\n if (!nextRow.original.isDisabled) {\n // Found a valid row\n // Select the next row\n handleSelectionLogic(\n tableRef.current,\n nextRow.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n\n // Focus the next row's cell. Scope to this table's container: row ids are\n // entity ids that can also exist in other SimpleTables on the page (slicer),\n // so a document-wide getElementById would steal focus to a duplicate.\n requestAnimationFrame(() => {\n const container = tableContainerRef.current\n const nextRowElement = container\n ? container.querySelector(`#${CSS.escape(nextRow.id)}`)\n : document.getElementById(nextRow.id)\n const nextCell = nextRowElement?.querySelector('[tabindex=\"0\"]') as HTMLElement\n if (nextCell) {\n nextCell.focus()\n nextCell.scrollIntoView({ block: 'nearest', behavior: 'smooth' })\n }\n })\n return\n }\n // Move to next row if current is disabled\n nextIndex = direction === 'down' ? nextIndex + 1 : nextIndex - 1\n }\n },\n [handleSelectionLogic],\n )\n\n // handleRenameForKeydown reads from onRenameRef so it has empty deps and is\n // permanently stable — keeping handleRowKeyDown and therefore columns stable.\n const handleRenameForKeydown = useCallback(\n (e: RowKeyboardEvent, row: Row<SimpleTableRow>) => {\n if (!row.original.isDisabled) onRenameRef.current?.(row.id, row)\n },\n [], // eslint-disable-line react-hooks/exhaustive-deps\n )\n\n const { handleRowKeyDown } = useRowKeydown<SimpleTableRow>({\n handleRowSelect: handleRowSelectForKeydown,\n handleArrowNavigation,\n handleRename: handleRenameForKeydown,\n })\n\n const columns = useMemo<ColumnDef<SimpleTableRow>[]>(\n () => [\n {\n accessorKey: 'label',\n header: undefined,\n filterFn: 'fuzzy',\n sortingFn: fuzzySort, //sort by fuzzy rank (falls back to alphanumeric)\n cell: ({ row, getValue, table: cellTableInstance }) => {\n const cellMeta = cellTableInstance.options.meta\n\n const handleCellClick = (event: ReactMouseEvent<HTMLElement, MouseEvent>) => {\n // Prevent row selection if clicking on an interactive element within the cell\n if (\n event.target instanceof HTMLInputElement ||\n event.target instanceof HTMLButtonElement ||\n event.target instanceof HTMLTextAreaElement ||\n event.target instanceof HTMLSelectElement ||\n event.target instanceof HTMLAnchorElement ||\n (event.target as HTMLElement).closest('button, a, input, textarea, select')\n ) {\n return\n }\n handleSelectionLogic(\n cellTableInstance, // Pass the cell's table instance\n row.id,\n event.shiftKey,\n event.ctrlKey || event.metaKey,\n )\n }\n\n const props: SimpleTableCellTemplateProps & {\n onClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n onDoubleClick?: (event: ReactMouseEvent<HTMLElement, MouseEvent>) => void\n } = {\n className: clsx({\n selected: row.getIsSelected(),\n loading: cellMeta?.isLoading,\n disabled: row.original.isDisabled, // you can't select disabled rows\n inactive: row.original.inactive, // false: archived items but still selectable\n }),\n onKeyDown: (e) => {\n if (e.target instanceof HTMLInputElement) return\n // Corrected typo: handleRowKeydown -> handleRowKeyDown\n handleRowKeyDown(e, row)\n },\n depth: row.depth,\n tabIndex: 0,\n value: getValue<string>(),\n parents: row.original.parents,\n icon: row.original.icon || undefined,\n iconColor: row.original.iconColor,\n iconFilled: row.original.iconFilled,\n img: row.original.img,\n imgShape: row.original.imgShape,\n imgRatio: imgRatio,\n isRowExpandable: row.getCanExpand(),\n enableNonFolderIndent,\n isRowExpanded: row.getIsExpanded(),\n isTableExpandable: cellMeta?.isExpandable,\n onExpandClick: row.getToggleExpandedHandler(),\n startContent: row.original.startContent,\n endContent: row.original.endContent,\n badge: row.original.badge,\n isDisabled: row.original.isDisabled,\n disabledMessage: row.original.disabledMessage,\n isRenaming: row.id === renamingIdRef.current,\n onSubmitRename: onSubmitRenameRef.current\n ? (v) => onSubmitRenameRef.current!(row.id, v)\n : undefined,\n onCancelRename: onCancelRenameRef.current,\n ...pt?.cell,\n onClick: handleCellClick, // Added onClick handler\n onDoubleClick: (e) => onRowDoubleClickRef.current?.(row.id, row),\n }\n\n // Use children function if provided, otherwise default to SimpleTableCellTemplate\n return cellMeta?.children ? (\n cellMeta.children(props, row, cellTableInstance)\n ) : (\n <SimpleTableCellTemplate {...props} {...pt?.cell} />\n )\n },\n },\n ],\n [\n forceUpdateTable,\n handleSelectionLogic,\n handleRowKeyDown,\n enableClickToDeselect,\n enableNonFolderIndent,\n imgRatio,\n ],\n )\n\n const handleRowSelectionChangeCallback: OnChangeFn<RowSelectionState> = useCallback(\n (updater) => {\n onRowSelectionChange(functionalUpdate(updater, rowSelection))\n },\n [onRowSelectionChange],\n )\n\n const handleRowPinningChangeCallback: OnChangeFn<RowPinningState> = useCallback(\n (updater) => {\n onRowPinningChange?.(functionalUpdate(updater, rowPinning || {}))\n },\n [onRowPinningChange],\n )\n\n const handleExpandedChange = useCallback(\n (updater: any) => {\n setExpanded?.((old) => {\n const newExpanded = updater instanceof Function ? updater(old) : updater\n onExpandedChange?.(newExpanded)\n return newExpanded\n })\n },\n [setExpanded],\n )\n\n const table = useReactTable({\n data: tableData,\n columns,\n state: {\n expanded,\n rowSelection,\n globalFilter,\n rowPinning,\n },\n onRowSelectionChange: handleRowSelectionChangeCallback,\n onRowPinningChange: handleRowPinningChangeCallback,\n filterFns: {\n fuzzy: fuzzyFilter,\n },\n globalFilterFn: 'fuzzy',\n enableRowSelection: true, //enable row selection for all rows\n enableRowPinning: !!onRowPinningChange,\n getRowId: (row) => row.id,\n enableSubRowSelection: false, //disable sub row selection\n onExpandedChange: handleExpandedChange,\n getSubRows: (row) => row.subRows,\n getCoreRowModel: getCoreRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n getExpandedRowModel: getExpandedRowModel(),\n filterFromLeafRows: true,\n // debugTable: true,\n // @ts-expect-error: updateData is not required\n meta: useMemo(\n () => ({\n isExpandable: !!isExpandable,\n isLoading: isLoading,\n children: children,\n ...meta,\n }),\n [isExpandable, isLoading, children, meta],\n ),\n })\n\n // Update tableRef whenever the table instance changes.\n // This ensures handleRowSelectForKeydown uses the current table instance.\n useEffect(() => {\n tableRef.current = table\n }, [table])\n\n const { rows } = table.getRowModel()\n\n const handleRowContextMenu = useCallback(\n (rowId: string, rowIndex: number, e: ReactMouseEvent<HTMLTableRowElement>) => {\n if (!tableRef.current) return\n const row = rows[rowIndex]\n if (!row || row.original === undefined) return\n\n e.preventDefault()\n e.stopPropagation()\n\n const selectedIds = Object.keys(rowSelection)\n\n const nextSelectedRows = selectedIds.includes(rowId) ? selectedIds : [rowId]\n\n if (!selectedIds.includes(rowId)) {\n // convert array to RowSelectionState object\n const nextSelection: RowSelectionState = { [rowId]: true }\n onRowSelectionChange?.(nextSelection)\n }\n\n const menuItems = rowContextMenuBuilders.flatMap((builder) =>\n toMenuItems(\n builder(e as any, {\n rowId,\n rowIndex,\n row,\n selectedRows: nextSelectedRows,\n isSelected: nextSelectedRows.includes(rowId),\n }),\n ),\n )\n\n if (menuItems.length > 0) {\n showRowContextMenu(e as any, menuItems)\n }\n },\n [rowContextMenuBuilders, rows, rowSelection, onRowSelectionChange, showRowContextMenu],\n )\n\n //The virtualizer needs to know the scrollable container element\n const tableContainerRef = useRef<HTMLDivElement>(null)\n\n const rowVirtualizer = useVirtualizer({\n count: rows.length,\n estimateSize: () => rowHeight || 34, //estimate row height for accurate scrollbar dragging\n getScrollElement: () => tableContainerRef.current,\n //measure dynamic row height, except in firefox because it measures table border height incorrectly\n measureElement: rowHeight\n ? () => rowHeight\n : typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1\n ? (element) => element?.getBoundingClientRect().height\n : undefined,\n overscan: 5,\n })\n\n // Memoize the ref callback to prevent infinite re-renders\n const measureElementRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n rowVirtualizer.measureElement(node)\n }\n },\n [rowVirtualizer],\n )\n\n // Handle scroll to bottom detection\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLDivElement>) => {\n if (!onScrollBottom) return\n\n const target = event.currentTarget\n const { scrollTop, scrollHeight, clientHeight } = target\n\n // Check if we're near the bottom (within 100px)\n const isNearBottom = scrollHeight - scrollTop - clientHeight < 100\n\n if (isNearBottom && !isLoading) {\n onScrollBottom()\n }\n },\n [onScrollBottom, isLoading],\n )\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // if the click is outside of any row, clear selection\n if (enableClickToDeselect && !(e.target as HTMLElement).closest('tr')) {\n table.setRowSelection({})\n lastSelectedIdRef.current = null\n }\n }\n\n return (\n <Styled.TableContainer\n ref={tableContainerRef}\n onScroll={handleScroll}\n onClick={handleContainerClick}\n {...props}\n className={clsx(props.className, { isLoading, fitContent })}\n >\n {!error && (\n <table>\n <tbody\n style={{\n height: `${rowVirtualizer?.getTotalSize()}px`, //tells scrollbar how big the table is\n }}\n >\n {rowVirtualizer?.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index] as Row<SimpleTableRow>\n return (\n <tr\n data-index={virtualRow.index} //needed for dynamic row height measurement\n ref={measureElementRef} //measure dynamic row height\n key={row.id}\n id={row.id}\n onContextMenu={(e) => handleRowContextMenu(row.id, virtualRow.index, e)}\n {...pt?.row}\n style={{\n transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll\n ...pt?.row?.style, // custom styles to be passed\n }}\n >\n {row.getVisibleCells().map((cell) => {\n return (\n <td key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n )\n })}\n </tr>\n )\n })}\n </tbody>\n </table>\n )}\n {!!error && <EmptyPlaceholder error={error} />}\n </Styled.TableContainer>\n )\n}\n\nexport default SimpleTable\n"],"names":["toMenuItems","items","fuzzyFilter","row","columnId","searchValue","addMeta","cellValue","searchString","itemRank","rankItem","rankings","fuzzySort","rowA","rowB","dir","compareItems","sortingFns","getRowRange","rows","idA","idB","range","singleRow","indexA","indexB","i","start","end","SimpleTable","data","isLoading","error","isExpandable","isMultiSelect","enableClickToDeselect","enableNonFolderIndent","forceUpdateTable","globalFilter","meta","rowHeight","imgRatio","onScrollBottom","onRename","renamingId","onSubmitRename","onCancelRename","onRowDoubleClick","rowContextMenuBuilders","children","pt","fitContent","props","rowSelection","expanded","setExpanded","onExpandedChange","onRowSelectionChange","rowPinning","onRowPinningChange","useSimpleTableContext","lastSelectedIdRef","useRef","tableRef","showRowContextMenu","useCreateContextMenu","onRowDoubleClickRef","renamingIdRef","onSubmitRenameRef","onCancelRenameRef","onRenameRef","tableData","useMemo","_","handleSelectionLogic","useCallback","tableInstance","rowId","isShift","isCtrlOrMeta","currentId","allProcessableRows","currentRow","r","lastId","rowsToToggle","newSelection","selection","handleRowSelectForKeydown","event","selectedRow","isShiftKey","isCtrlKey","handleArrowNavigation","direction","visibleRows","currentIndex","nextIndex","nextRow","container","tableContainerRef","nextCell","handleRenameForKeydown","e","handleRowKeyDown","useRowKeydown","columns","getValue","cellTableInstance","cellMeta","handleCellClick","clsx","v","jsx","SimpleTableCellTemplate","handleRowSelectionChangeCallback","updater","functionalUpdate","handleRowPinningChangeCallback","handleExpandedChange","old","newExpanded","table","useReactTable","getCoreRowModel","getFilteredRowModel","getExpandedRowModel","useEffect","handleRowContextMenu","rowIndex","selectedIds","nextSelectedRows","nextSelection","menuItems","builder","rowVirtualizer","useVirtualizer","element","measureElementRef","node","handleScroll","target","scrollTop","scrollHeight","clientHeight","handleContainerClick","jsxs","Styled.TableContainer","virtualRow","cell","flexRender","EmptyPlaceholder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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