@economic/taco 2.14.1 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/dist/components/Icon/components/AiChatSolid.d.ts +3 -0
  2. package/dist/components/Icon/components/AiStars.d.ts +3 -0
  3. package/dist/components/Icon/components/EnvelopeSolid.d.ts +3 -0
  4. package/dist/components/Icon/components/PhoneSolid.d.ts +3 -0
  5. package/dist/components/Icon/components/QuestionMarkBold.d.ts +3 -0
  6. package/dist/components/Icon/components/index.d.ts +1 -1
  7. package/dist/components/Input/Input.d.ts +1 -1
  8. package/dist/components/Menu/components/Item.d.ts +1 -1
  9. package/dist/components/Menu/components/Link.d.ts +1 -1
  10. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  11. package/dist/components/Select2/components/Option.d.ts +2 -2
  12. package/dist/components/Select2/components/Search.d.ts +1 -1
  13. package/dist/components/Tag/Tag.d.ts +1 -1
  14. package/dist/components/Tooltip/Tooltip.d.ts +4 -0
  15. package/dist/esm/index.css +13 -3
  16. package/dist/esm/packages/taco/src/components/Field/Field.js +19 -3
  17. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Icon/components/AiChatSolid.js +19 -0
  19. package/dist/esm/packages/taco/src/components/Icon/components/AiChatSolid.js.map +1 -0
  20. package/dist/esm/packages/taco/src/components/Icon/components/AiStars.js +30 -0
  21. package/dist/esm/packages/taco/src/components/Icon/components/AiStars.js.map +1 -0
  22. package/dist/esm/packages/taco/src/components/Icon/components/EnvelopeSolid.js +19 -0
  23. package/dist/esm/packages/taco/src/components/Icon/components/EnvelopeSolid.js.map +1 -0
  24. package/dist/esm/packages/taco/src/components/Icon/components/PhoneSolid.js +17 -0
  25. package/dist/esm/packages/taco/src/components/Icon/components/PhoneSolid.js.map +1 -0
  26. package/dist/esm/packages/taco/src/components/Icon/components/QuestionMarkBold.js +17 -0
  27. package/dist/esm/packages/taco/src/components/Icon/components/QuestionMarkBold.js.map +1 -0
  28. package/dist/esm/packages/taco/src/components/Icon/components/index.js +10 -0
  29. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Table3/Table3.js +21 -3
  31. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  32. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js +6 -5
  33. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +2 -2
  35. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +1 -6
  37. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +1 -1
  39. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +3 -1
  40. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/hooks/useParentStylesheets.js +2 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/hooks/useParentStylesheets.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +2 -2
  44. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js +1 -1
  46. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js +4 -0
  48. package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js.map +1 -1
  49. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +20 -0
  50. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -0
  51. package/dist/index.css +13 -3
  52. package/dist/taco.cjs.development.js +185 -46
  53. package/dist/taco.cjs.development.js.map +1 -1
  54. package/dist/taco.cjs.production.min.js +1 -1
  55. package/dist/taco.cjs.production.min.js.map +1 -1
  56. package/package.json +2 -2
  57. package/types.json +20454 -10652
@@ -1 +1 @@
1
- {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { FONT_SIZE } from './components/toolbar/FontSize';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\n// Cast the old forwardRef to the new one\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const { emptyState: EmptyState, customSettings, toolbarLeft, toolbarRight } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (eventOriginatedFromCombobox || (dialog && !dialog?.contains(internalRef.current))) {\n return;\n }\n\n tableMeta.hoverState.handleKeyDown(event);\n tableMeta.currentRow.handleKeyDown(\n event,\n table.getRowModel().rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing,\n internalRef\n );\n tableMeta.rowClick.handleKeyDown(event, table);\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.currentRow.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,\n 'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,\n 'text-base': tableMeta.fontSize.size === FONT_SIZE.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle ? <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style> : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.hoverState.isPaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {table.getFooterGroups().map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))}\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","fixedForwardRef","React","forwardRef","Table","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","hoverState","currentRow","getRowModel","rows","editing","isEditing","rowClick","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","undefined","handleFocus","currentRowIndex","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FONT_SIZE","small","medium","large","style","cssGridStyle","useCssGrid","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","horizontallyScrolled","isPaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAMjC;MACaE,eAAe,GAAGC,cAAK,CAACC;AAErC,MAAMC,KAAK,gBAAGH,eAAe,CAAC,SAASI,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EAC/G,MAAM;IAAEC,UAAU,EAAEC,UAAU;IAAEC,cAAc;IAAEC,WAAW;IA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AAM,CAACN,UAAU,EAAE,CAAC,CAEvE,CAAC,CAET,CAAC,EACDvG,MAAM,gBACHd,6BAAC4H,OAAO;IAACC,aAAa,EAAEhH,KAAK,CAAC4B,WAAW,EAAE,CAACC,IAAI,CAAC5B,MAAM;IAAEA,MAAM,EAAEA,MAAM;IAAED,KAAK,EAAEA;IAAS,GACzF,IAAI,CACN,GACN,IAAI,CACT,gBAEHb;IAAK8D,SAAS,EAAC;KAA0CvD,UAAU,gBAAGP,6BAACO,UAAU,OAAG,GAAG,IAAI,CAC9F,CACC,CACP;AAEX,CAAC,CAAC;MAOWJ,MAAM,gBAAGJ,eAAe,CAAC,SAASI,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EACvH,MAAMyH,mBAAmB,GAAGC,MAAM,CAAC3H,KAAK,CAAC4H,QAAQ,CAAC;;;EAGlD,MAAMvB,GAAG,GAAGzG,cAAK,CAACiI,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAO9H,6BAACE,KAAK,oBAAYE,KAAK;IAAEqG,GAAG,EAAEA,GAAG;IAAEpG,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACR,MAAM,GAAGA,MAAM;AACtBQ,MAAM,CAACL,KAAK,GAAGA,KAAK;;;;"}
1
+ {"version":3,"file":"Table3.js","sources":["../../../../../../../src/components/Table3/Table3.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, TableMeta } from '@tanstack/react-table';\nimport { FocusScope } from '@react-aria/focus';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { useCssGrid } from './hooks/useCssGrid';\nimport { useTable } from './hooks/useTable';\nimport { useTableRenderStrategy } from './strategies';\nimport { Table3ColumnProps, Table3GroupProps, Table3Props, Table3Ref } from './types';\nimport { Toolbar } from './components/toolbar/Toolbar';\nimport { useColumnFreezingStyle } from './hooks/features/useColumnFreezing';\nimport { useTableRefInstanceSetup } from './hooks/useTableRefInstanceSetup';\nimport { Summary } from './components/columns/footer/Summary';\nimport { useCssVars } from './hooks/useCssVars';\nimport './style.css';\nimport { useHeaderOffsetStyle } from './hooks/features/useHeaderOffsetStyle';\nimport { FONT_SIZE } from './components/toolbar/FontSize';\n\nfunction Column<TType = unknown>(_: Table3ColumnProps<TType>) {\n return null;\n}\nColumn.displayName = 'Table3Column';\n\nfunction Group(_: Table3GroupProps) {\n return null;\n}\nGroup.displayName = 'Table3Group';\n\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\n// Cast the old forwardRef to the new one\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nconst Table = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const { emptyState: EmptyState, customSettings, toolbarLeft, toolbarRight, defaultCurrentRowIndex } = props;\n const internalRef = useMergedRef<Table3Ref>(ref);\n\n const { table, length } = useTable<TType>(props);\n useTableRefInstanceSetup(table, internalRef);\n\n React.useEffect(() => {\n if (props.autoFocus) {\n internalRef.current?.focus();\n }\n }, []);\n\n const { renderBody, scrollToIndex } = useTableRenderStrategy<TType>(props, table, internalRef);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n const bodyRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n // On a very first render, the tanstack table rendered without any rows,\n // so we delaying default row scrolling logic with using of requestAnimation frame\n const animationFrameId = requestAnimationFrame(() => {\n if (defaultCurrentRowIndex) {\n scrollToIndex(defaultCurrentRowIndex, { align: 'center' });\n }\n });\n\n return () => {\n cancelAnimationFrame(animationFrameId);\n };\n }, []);\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const dialog = target.closest('[role=\"dialog\"]');\n const eventOriginatedFromCombobox = !!target.closest('[role=\"combobox\"]');\n\n // Don't trigger global shortcuts on the table if event originated from a combobox or if table is\n // outside the dialog\n if (eventOriginatedFromCombobox || (dialog && !dialog?.contains(internalRef.current))) {\n return;\n }\n\n tableMeta.hoverState.handleKeyDown(event);\n tableMeta.currentRow.handleKeyDown(\n event,\n table.getRowModel().rows.length,\n scrollToIndex,\n tableMeta.editing.isEditing,\n internalRef\n );\n tableMeta.rowClick.handleKeyDown(event, table);\n tableMeta.rowSelection.handleKeyDown(event, table);\n tableMeta.editing.handleKeyDown(event);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n // See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143\n // scrollToIndex function changes when row count changes, so it is important to update handlers with new\n // scrollToIndex function.\n [scrollToIndex, tableMeta.editing.isEditing, internalRef.current]\n );\n\n const handleBlur = tableMeta.editing.isEnabled\n ? (event: React.FocusEvent) => {\n tableMeta.editing.handleBlur(event);\n }\n : undefined;\n\n const handleFocus =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.FocusEvent) => {\n tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);\n }\n : undefined;\n\n // mouse capture fires before focus, so we can prevent propagation and stop double setting of the active row\n const handleMouseCapture =\n tableMeta.currentRow.currentRowIndex === undefined\n ? (event: React.MouseEvent) => {\n tableMeta.currentRow.handleMouseCapture(event, table.getRowModel().rows.length);\n }\n : undefined;\n\n const handleScroll = async (event: React.MouseEvent<HTMLDivElement>) => {\n tableMeta.columnFreezing.handleScroll(event);\n };\n\n const className = cn(\n 'border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none',\n '[&[data-resizing=\"true\"]]:select-none',\n {\n 'text-xs': tableMeta.fontSize.size === FONT_SIZE.small,\n 'text-sm': tableMeta.fontSize.size === FONT_SIZE.medium,\n 'text-base': tableMeta.fontSize.size === FONT_SIZE.large,\n }\n );\n\n // Print tables have \"_print\" as the postfix for the table id, so we can use the it to determine\n // if the table is a print table or not.\n const { style: cssGridStyle } = useCssGrid<TType>(\n table,\n tableMeta.isPrinting,\n tableMeta.rowActions.actionsForRowLength,\n tableMeta.fontSize.size\n );\n const { style: cssVars } = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);\n\n const style = {\n ...cssVars,\n ...cssGridStyle,\n // create a new stacking context so our internal z-indexes don't effect external components\n // https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context\n opacity: 0.999,\n };\n\n const columnFreezingStyle = useColumnFreezingStyle(props.id, table);\n const headerOffsetStyle = useHeaderOffsetStyle(props.id, table);\n const isServerLoadingAndNotReady = tableMeta.isUsingServer && props.length === undefined;\n const isPrinting = tableMeta.isPrinting;\n\n return (\n <>\n {columnFreezingStyle ? <style data-taco=\"table3-column-freezing-styles\">{columnFreezingStyle}</style> : null}\n {headerOffsetStyle && !isPrinting ? (\n <style data-taco=\"table3-column-header-offset-styles\">{headerOffsetStyle}</style>\n ) : null}\n <Toolbar\n table={table}\n tableProps={props}\n total={length}\n left={toolbarLeft}\n right={toolbarRight}\n customSettings={customSettings}\n scrollToIndex={scrollToIndex}\n />\n <div\n className={className}\n id={props.id}\n data-font-size={tableMeta.fontSize.size}\n data-editing={tableMeta.editing.isEditing}\n data-horizontally-scrolled={tableMeta.columnFreezing.horizontallyScrolled}\n data-pause-hover={tableMeta?.hoverState.isPaused}\n data-resizing={!!state.columnSizingInfo.isResizingColumn}\n data-taco=\"table2\"\n onBlur={handleBlur}\n onFocus={handleFocus}\n onScroll={handleScroll}\n ref={internalRef}\n role=\"table\"\n style={style}\n tabIndex={-1}>\n {isServerLoadingAndNotReady ? null : (\n <div className=\"group/header contents\" data-taco=\"table2-header\" role=\"rowgroup\">\n {table.getHeaderGroups().map(headerGroup => (\n <div className=\"contents\" key={headerGroup.id} role=\"row\">\n {headerGroup.headers.map((header, index) => {\n // We need to render separator if column is not the last in array, if index is not equal to freeze column index,\n // if next element is not placeholder and if column itself is not placeholder.\n const hasSeparator =\n index !== tableMeta.columnFreezing.frozenColumnIndex &&\n index !== headerGroup.headers.length - 1 &&\n (!headerGroup.headers[index + 1]?.isPlaceholder || !header.isPlaceholder);\n return (\n <React.Fragment key={header.id}>\n {flexRender(header.column.columnDef.header, {\n ...header.getContext(),\n scrollToIndex,\n hasSeparator,\n })}\n </React.Fragment>\n );\n })}\n </div>\n ))}\n </div>\n )}\n {table.getRowModel().rows.length ? (\n <>\n <FocusScope autoFocus={tableMeta.editing.isEditing}>\n <div\n onMouseDownCapture={handleMouseCapture}\n className=\"group/body contents\"\n data-taco=\"table2-body\"\n role=\"rowgroup\"\n ref={bodyRef}>\n {renderBody()}\n </div>\n </FocusScope>\n {/* This div makes sure that there is always a free space between the rows and footer when\n table height exceeds the cumulative height of all rows. See useCSSGrid.ts */}\n {/* By vertically translating the div a pixel down, we hide the div border below footer so that\n the footer border doesn't appear an extra pixel thick */}\n <div className=\"border-grey-300 col-span-full translate-y-px border-t\" />\n {tableMeta.enableFooter ? (\n <div className=\"group/footer contents\" data-taco=\"table2-footer\" role=\"rowgroup\">\n {\n // Render the footer cell only for individual columns, excluding column groups.\n table\n .getFooterGroups()\n .slice(0, 1)\n .map(footerGroup => (\n <div className=\"contents\" key={footerGroup.id} role=\"row\">\n {footerGroup.headers.map(footer => (\n <React.Fragment key={footer.id}>\n {flexRender(footer.column.columnDef.footer, footer.getContext())}\n </React.Fragment>\n ))}\n </div>\n ))\n }\n {length ? (\n <Summary currentLength={table.getRowModel().rows.length} length={length} table={table} />\n ) : null}\n </div>\n ) : null}\n </>\n ) : (\n <div className=\"col-span-full min-h-[theme(spacing.8)]\">{EmptyState ? <EmptyState /> : null}</div>\n )}\n </div>\n </>\n );\n});\n\ntype Table3WithStatics = (<TType = unknown>(props: Table3Props<TType> & React.RefAttributes<Table3Ref>) => JSX.Element) & {\n Column: typeof Column;\n Group: typeof Group;\n};\n\nexport const Table3 = fixedForwardRef(function Table3<TType = unknown>(props: Table3Props<TType>, ref: React.Ref<Table3Ref>) {\n const stringifiedChildren = String(props.children);\n // we force a remount (using key) when the child columns change because there are too many places to add children as an effect\n // this is cheaper from a complexity perspective, and probably performance wise as well\n const key = React.useMemo(() => String('tableKey_' + stringifiedChildren), [stringifiedChildren]);\n return <Table<TType> {...props} key={key} ref={ref} />;\n}) as Table3WithStatics;\nTable3.Column = Column;\nTable3.Group = Group;\n\n// hooks\nexport { useTable3DataLoader } from './hooks/useTableDataLoader';\n\n// types\nexport type {\n useTable3DataFetcher,\n useTable3DataOptions,\n useTable3DataFetcherValues as useTableDataValues,\n} from './hooks/useTableDataLoader';\n\nexport type {\n Table3Ref,\n Table3Props,\n Table3Preset,\n Table3Settings,\n Table3SettingsHandler,\n Table3RowHeight,\n Table3FilterComparator,\n Table3FilterHandler,\n Table3LoadPageHandler,\n Table3LoadAllHandler,\n Table3RowGotoHandler,\n Table3SortHandler,\n Table3Shortcuts,\n Table3ShortcutHandlerFn,\n Table3ShortcutHandlerObject,\n Table3FontSize,\n Table3SortDirection,\n Table3SortFn,\n Table3RowActionRenderer,\n Table3RowSelectionHandler,\n Table3RowExpansionRenderer,\n Table3RowDropHandler,\n Table3RowDragHandler,\n Table3RowClickHandler,\n Table3ColumnProps,\n Table3ColumnAlignment,\n Table3ColumnDataType,\n Table3ColumnHeaderMenu,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n Table3ColumnRenderer,\n Table3ColumnControlRenderer,\n Table3ColumnControlProps,\n} from './types';\n"],"names":["Column","_","displayName","Group","fixedForwardRef","React","forwardRef","Table","Table3","props","ref","emptyState","EmptyState","customSettings","toolbarLeft","toolbarRight","defaultCurrentRowIndex","internalRef","useMergedRef","table","length","useTable","useTableRefInstanceSetup","useEffect","autoFocus","_internalRef$current","current","focus","renderBody","scrollToIndex","useTableRenderStrategy","tableMeta","options","meta","state","getState","bodyRef","useRef","animationFrameId","requestAnimationFrame","align","cancelAnimationFrame","handleKeyDown","event","target","dialog","closest","eventOriginatedFromCombobox","contains","hoverState","currentRow","getRowModel","rows","editing","isEditing","rowClick","rowSelection","document","addEventListener","removeEventListener","handleBlur","isEnabled","undefined","handleFocus","currentRowIndex","handleMouseCapture","handleScroll","columnFreezing","Promise","resolve","e","reject","className","cn","fontSize","size","FONT_SIZE","small","medium","large","style","cssGridStyle","useCssGrid","isPrinting","rowActions","actionsForRowLength","cssVars","useCssVars","rowHeight","height","opacity","columnFreezingStyle","useColumnFreezingStyle","id","headerOffsetStyle","useHeaderOffsetStyle","isServerLoadingAndNotReady","isUsingServer","Toolbar","tableProps","total","left","right","horizontallyScrolled","isPaused","columnSizingInfo","isResizingColumn","onBlur","onFocus","onScroll","role","tabIndex","getHeaderGroups","map","headerGroup","key","headers","header","index","hasSeparator","frozenColumnIndex","_headerGroup$headers","isPlaceholder","Fragment","flexRender","column","columnDef","getContext","FocusScope","onMouseDownCapture","enableFooter","getFooterGroups","slice","footerGroup","footer","Summary","currentLength","stringifiedChildren","String","children","useMemo"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAASA,MAAMA,CAAkBC,CAA2B;EACxD,OAAO,IAAI;AACf;AACAD,MAAM,CAACE,WAAW,GAAG,cAAc;AAEnC,SAASC,KAAKA,CAACF,CAAmB;EAC9B,OAAO,IAAI;AACf;AACAE,KAAK,CAACD,WAAW,GAAG,aAAa;AAMjC;MACaE,eAAe,GAAGC,cAAK,CAACC;AAErC,MAAMC,KAAK,gBAAGH,eAAe,CAAC,SAASI,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EAC/G,MAAM;IAAEC,UAAU,EAAEC,UAAU;IAAEC,cAAc;IAAEC,WAAW;IAAEC,YAAY;IAAEC;GAAwB,GAAGP,KAAK;EAC3G,MAAMQ,WAAW,GAAGC,YAAY,CAAYR,GAAG,CAAC;EAEhD,MAAM;IAAES,KAAK;IAAEC;GAAQ,GAAGC,Q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;IAAC2C,GAAG,EAAEkB,WAAW,CAACxC,EAAE;IAAEiB,IAAI,EAAC;KAC/CuB,WAAW,CAACjB,OAAO,CAACH,GAAG,CAACqB,MAAM,iBAC3BjI,6BAACA,cAAK,CAACsH,QAAQ;IAACR,GAAG,EAAEmB,MAAM,CAACzC;KACvB+B,UAAU,CAACU,MAAM,CAACT,MAAM,CAACC,SAAS,CAACQ,MAAM,EAAEA,MAAM,CAACP,UAAU,EAAE,CAAC,CAEvE,CAAC,CAET,CAAC,EAET3G,MAAM,gBACHf,6BAACkI,OAAO;IAACC,aAAa,EAAErH,KAAK,CAACgC,WAAW,EAAE,CAACC,IAAI,CAAChC,MAAM;IAAEA,MAAM,EAAEA,MAAM;IAAED,KAAK,EAAEA;IAAS,GACzF,IAAI,CACN,GACN,IAAI,CACT,gBAEHd;IAAKmE,SAAS,EAAC;KAA0C5D,UAAU,gBAAGP,6BAACO,UAAU,OAAG,GAAG,IAAI,CAC9F,CACC,CACP;AAEX,CAAC,CAAC;MAOWJ,MAAM,gBAAGJ,eAAe,CAAC,SAASI,MAAMA,CAAkBC,KAAyB,EAAEC,GAAyB;EACvH,MAAM+H,mBAAmB,GAAGC,MAAM,CAACjI,KAAK,CAACkI,QAAQ,CAAC;;;EAGlD,MAAMxB,GAAG,GAAG9G,cAAK,CAACuI,OAAO,CAAC,MAAMF,MAAM,CAAC,WAAW,GAAGD,mBAAmB,CAAC,EAAE,CAACA,mBAAmB,CAAC,CAAC;EACjG,oBAAOpI,6BAACE,KAAK,oBAAYE,KAAK;IAAE0G,GAAG,EAAEA,GAAG;IAAEzG,GAAG,EAAEA;KAAO;AAC1D,CAAC;AACDF,MAAM,CAACR,MAAM,GAAGA,MAAM;AACtBQ,MAAM,CAACL,KAAK,GAAGA,KAAK;;;;"}
@@ -39,11 +39,11 @@ const MemoedGroup = /*#__PURE__*/React__default.memo(function MemoedGroup(props)
39
39
  meta,
40
40
  table
41
41
  } = props;
42
- const containerClassName = cn('sticky px-2 mb-[2px]', {
43
- 'h-10': !isPrinting
44
- }, colSpan > 1 ? `col-span-${colSpan}` : '');
42
+ const containerClassName = cn('px-2 z-10 hover:z-20', colSpan > 1 ? `col-span-${colSpan}` : '', {
43
+ sticky: !isPrinting
44
+ });
45
45
  const innerClassName = cn('font-bold box-content group/column relative', 'px-[var(--table3-cell-padding-x)]', {
46
- 'h-full items-center': !isPrinting,
46
+ 'h-10 items-center': !isPrinting,
47
47
  'pb-2': isPrinting,
48
48
  'border-b-2': !!children
49
49
  }, meta.headerClassName);
@@ -53,7 +53,8 @@ const MemoedGroup = /*#__PURE__*/React__default.memo(function MemoedGroup(props)
53
53
  return /*#__PURE__*/React__default.createElement("div", {
54
54
  className: containerClassName,
55
55
  "data-taco": "table3-column-group",
56
- "data-align": align
56
+ "data-align": align,
57
+ role: "columnheader"
57
58
  }, /*#__PURE__*/React__default.createElement("div", {
58
59
  className: innerClassName
59
60
  }, /*#__PURE__*/React__default.createElement(Tooltip, {
@@ -1 +1 @@
1
- {"version":3,"file":"Group.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Group.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\n\nimport { HeaderProps, HeaderSeparator } from './Header';\nimport { ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport function Group<TType = unknown>(props: HeaderProps<TType>) {\n const { children, column, header, table, hasSeparator } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta, []) as ColumnMeta<TType, unknown>;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const memoedProps = {\n align: 'center' as Table3ColumnAlignment,\n children: children ?? columnMeta.header,\n colSpan: header.colSpan,\n hasSeparator,\n id: header.id,\n index: header.index,\n isPrinting: tableMeta.isPrinting,\n length: table.getRowModel().rows.length,\n meta: columnMeta,\n table,\n };\n\n return <MemoedGroup<TType> {...memoedProps} />;\n}\n\n// Memoization\nexport type MemoedGroupProps<TType = unknown> = Omit<HeaderProps<TType>, 'column' | 'header' | 'scrollToIndex'> & {\n align?: Table3ColumnAlignment;\n colSpan: number;\n hasSeparator?: boolean;\n id: string;\n index: number;\n isPrinting: boolean;\n length: number;\n meta: ColumnMeta<TType, unknown>;\n};\n\nconst MemoedGroup = React.memo(function MemoedGroup<TType = unknown>(props: MemoedGroupProps<TType>) {\n const { align, children, colSpan, hasSeparator, id, isPrinting, meta, table } = props;\n\n const containerClassName = cn(\n 'sticky px-2 mb-[2px]',\n {\n 'h-10': !isPrinting,\n },\n colSpan > 1 ? `col-span-${colSpan}` : ''\n );\n\n const innerClassName = cn(\n 'font-bold box-content group/column relative',\n 'px-[var(--table3-cell-padding-x)]',\n {\n 'h-full items-center': !isPrinting,\n 'pb-2': isPrinting,\n 'border-b-2': !!children,\n },\n meta.headerClassName\n );\n\n if (table.options.debugAll) {\n console.log('header group render', id);\n }\n\n return (\n <div className={containerClassName} data-taco=\"table3-column-group\" data-align={align}>\n <div className={innerClassName}>\n <Tooltip title={String(meta?.tooltip ?? children)} placement=\"top\">\n <span className={cn({ truncate: !isPrinting })}>{children}</span>\n </Tooltip>\n {hasSeparator ? <HeaderSeparator /> : null}\n </div>\n </div>\n );\n}) as <TType = unknown>(props: MemoedGroupProps<TType>) => JSX.Element;\n"],"names":["Group","props","children","column","header","table","hasSeparator","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","colSpan","id","index","isPrinting","length","getRowModel","rows","MemoedGroup","memo","containerClassName","cn","innerClassName","headerClassName","debugAll","console","log","className","Tooltip","title","String","_meta$tooltip","tooltip","placement","truncate","HeaderSeparator"],"mappings":";;;;;SAQgBA,KAAKA,CAAkBC,KAAyB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;GAAc,GAAGL,KAAK;EAC/D,MAAMM,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMN,MAAM,CAACO,SAAS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;IAAKwB,SAAS,EAAEP,kBAAkB;iBAAY,qBAAqB;kBAAaV;kBAC5EP;IAAKwB,SAAS,EAAEL;kBACZnB,6BAACyB,OAAO;IAACC,KAAK,EAAEC,MAAM,EAAAC,aAAA,GAACzB,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE0B,OAAO,cAAAD,aAAA,cAAAA,aAAA,GAAIlC,QAAQ,CAAC;IAAEoC,SAAS,EAAC;kBACzD9B;IAAMwB,SAAS,EAAEN,EAAE,CAAC;MAAEa,QAAQ,EAAE,CAACpB;KAAY;KAAIjB,QAAQ,CAAQ,CAC3D,EACTI,YAAY,gBAAGE,6BAACgC,eAAe,OAAG,GAAG,IAAI,CACxC,CACJ;AAEd,CAAC,CAAqE;;;;"}
1
+ {"version":3,"file":"Group.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Group.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\n\nimport { HeaderProps, HeaderSeparator } from './Header';\nimport { ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport function Group<TType = unknown>(props: HeaderProps<TType>) {\n const { children, column, header, table, hasSeparator } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta, []) as ColumnMeta<TType, unknown>;\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const memoedProps = {\n align: 'center' as Table3ColumnAlignment,\n children: children ?? columnMeta.header,\n colSpan: header.colSpan,\n hasSeparator,\n id: header.id,\n index: header.index,\n isPrinting: tableMeta.isPrinting,\n length: table.getRowModel().rows.length,\n meta: columnMeta,\n table,\n };\n\n return <MemoedGroup<TType> {...memoedProps} />;\n}\n\n// Memoization\nexport type MemoedGroupProps<TType = unknown> = Omit<HeaderProps<TType>, 'column' | 'header' | 'scrollToIndex'> & {\n align?: Table3ColumnAlignment;\n colSpan: number;\n hasSeparator?: boolean;\n id: string;\n index: number;\n isPrinting: boolean;\n length: number;\n meta: ColumnMeta<TType, unknown>;\n};\n\nconst MemoedGroup = React.memo(function MemoedGroup<TType = unknown>(props: MemoedGroupProps<TType>) {\n const { align, children, colSpan, hasSeparator, id, isPrinting, meta, table } = props;\n\n const containerClassName = cn('px-2 z-10 hover:z-20', colSpan > 1 ? `col-span-${colSpan}` : '', { sticky: !isPrinting });\n\n const innerClassName = cn(\n 'font-bold box-content group/column relative',\n 'px-[var(--table3-cell-padding-x)]',\n {\n 'h-10 items-center': !isPrinting,\n 'pb-2': isPrinting,\n 'border-b-2': !!children,\n },\n meta.headerClassName\n );\n\n if (table.options.debugAll) {\n console.log('header group render', id);\n }\n\n return (\n <div className={containerClassName} data-taco=\"table3-column-group\" data-align={align} role=\"columnheader\">\n <div className={innerClassName}>\n <Tooltip title={String(meta?.tooltip ?? children)} placement=\"top\">\n <span className={cn({ truncate: !isPrinting })}>{children}</span>\n </Tooltip>\n {hasSeparator ? <HeaderSeparator /> : null}\n </div>\n </div>\n );\n}) as <TType = unknown>(props: MemoedGroupProps<TType>) => JSX.Element;\n"],"names":["Group","props","children","column","header","table","hasSeparator","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","colSpan","id","index","isPrinting","length","getRowModel","rows","MemoedGroup","memo","containerClassName","cn","sticky","innerClassName","headerClassName","debugAll","console","log","className","role","Tooltip","title","String","_meta$tooltip","tooltip","placement","truncate","HeaderSeparator"],"mappings":";;;;;SAQgBA,KAAKA,CAAkBC,KAAyB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;GAAc,GAAGL,KAAK;EAC/D,MAAMM,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMN,MAAM,CAACO,SAAS,CAACC,IAAI,EAAE,EAAE,CAA+B;EAC/F,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACF,IAAwB;EAExD,MAAMG,WAAW,GAAG;IAChBC,KAAK,EAAE,QAAiC;I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KAAK,EAAEC,MAAM,EAAAC,aAAA,GAAC3B,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE4B,OAAO,cAAAD,aAAA,cAAAA,aAAA,GAAIpC,QAAQ,CAAC;IAAEsC,SAAS,EAAC;kBACzDhC;IAAMyB,SAAS,EAAEP,EAAE,CAAC;MAAEe,QAAQ,EAAE,CAACtB;KAAY;KAAIjB,QAAQ,CAAQ,CAC3D,EACTI,YAAY,gBAAGE,6BAACkC,eAAe,OAAG,GAAG,IAAI,CACxC,CACJ;AAEd,CAAC,CAAqE;;;;"}
@@ -102,9 +102,9 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
102
102
  sortDirection,
103
103
  table
104
104
  } = props;
105
- const className = cn('sticky font-bold border-b-2 box-content group/column relative', '[[role="table"][data-resizing="true"]_&]:pointer-events-none', 'px-[var(--table3-cell-padding-x)]', {
105
+ const className = cn('font-bold border-b-2 box-content group/column relative', '[[role="table"][data-resizing="true"]_&]:pointer-events-none', 'px-[var(--table3-cell-padding-x)]', {
106
106
  '!border-white': isPlaceholder,
107
- 'h-10 items-center': !isPrinting,
107
+ 'h-10 items-center sticky': !isPrinting,
108
108
  'pb-2': isPrinting,
109
109
  'cursor-pointer select-none': canSort,
110
110
  'hover:bg-grey-100': !isPlaceholder && (canSort || canResize || hasMenu),
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Header.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, HeaderContext, TableMeta } from '@tanstack/react-table';\nimport { Menu, isMenuAvailable, isGotoAvailable } from './Menu';\nimport { Resizer } from './Resizer';\nimport { Table3ColumnAlignment, Table3SortDirection, TableStrategy } from '../../../types';\nimport { getSortAttributes, SortIndicator } from './SortIndicator';\nimport { isFrozenColumn, isInternalColumn } from '../../../util/columns';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport const SORT_DIRECTION: Record<string, Table3SortDirection> = {\n ASC: 'asc',\n DESC: 'desc',\n};\n\nexport type HeaderSortDirection = Table3SortDirection | false;\nexport type SortToggleHandler = (sortDirection: HeaderSortDirection) => void;\n\nexport type HeaderProps<TType = unknown> = HeaderContext<TType, unknown> & {\n children?: string | JSX.Element;\n hasSeparator?: boolean;\n};\n\nexport function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { children, column, header, hasSeparator, scrollToIndex, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const columnMeta = React.useMemo(() => column.columnDef.meta, []) as ColumnMeta<TType, unknown>;\n const canSort = column.getCanSort();\n const hasGoto = isGotoAvailable(table, header);\n\n // passing header or column results in re-renders on scroll, so anything from those objects as memoed props\n const handleHide = React.useMemo(() => header.column.getToggleVisibilityHandler(), []);\n const handleResize = React.useMemo(() => header.getResizeHandler(), []);\n const handleSort = React.useMemo(() => header.column.getToggleSortingHandler(), []);\n const handleSortToggle = React.useCallback((sortDirection: HeaderSortDirection) => {\n // When sorting is not applied, sortDirection is false.\n if (sortDirection === false) {\n header.column.clearSorting();\n } else {\n header.column.toggleSorting(sortDirection === SORT_DIRECTION.DESC);\n }\n }, []);\n\n const sorting = table.getState().sorting;\n const filters = table.getState().columnFilters;\n const search = table.getState().globalFilter;\n\n const handleGoto = React.useMemo(() => {\n if (hasGoto) {\n return ((query: string) => tableMeta.rowGoto.handleGoto(header.id, query, sorting, filters, search)) as (\n query: string\n ) => Promise<number>;\n }\n\n return undefined;\n }, [hasGoto, JSON.stringify(sorting), JSON.stringify(filters), search]);\n\n const memoedProps = {\n align: columnMeta.align,\n canFreeze: tableMeta.columnFreezing.isEnabled,\n canHide: column.getCanHide(),\n canResize: column.getCanResize(),\n canSort,\n children: children ?? columnMeta.header,\n colSpan: header.colSpan,\n hasMenu: isMenuAvailable<TType>(table, header),\n hasSeparator,\n id: header.id,\n index: header.index,\n isFrozen: isFrozenColumn(header, table),\n isPlaceholder: header.isPlaceholder,\n isPrinting: tableMeta.isPrinting,\n isResizing: column.getIsResizing(),\n length: table.getRowModel().rows.length,\n meta: columnMeta,\n onGoto: handleGoto,\n onHide: handleHide,\n onResize: handleResize,\n onSort: handleSort as (event: unknown) => void,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection: column.getIsSorted(),\n table,\n };\n\n return <MemoedHeader<TType> {...memoedProps} />;\n}\n\n// Memoization\nexport type MemoedHeaderProps<TType = unknown> = Omit<HeaderProps<TType>, 'column' | 'header'> & {\n align?: Table3ColumnAlignment;\n canFreeze: boolean;\n canHide: boolean;\n canResize: boolean;\n canSort: boolean;\n colSpan: number;\n hasMenu: boolean;\n hasSeparator?: boolean;\n id: string;\n index: number;\n isFrozen: boolean;\n isPlaceholder: boolean;\n isPrinting: boolean;\n isResizing: boolean;\n length: number;\n meta: ColumnMeta<TType, unknown>;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onResize: (event: unknown) => void;\n onSort: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n};\n\nconst MemoedHeader = React.memo(function MemoedHeader<TType = unknown>(props: MemoedHeaderProps<TType>) {\n const {\n align,\n children,\n canFreeze,\n canHide,\n canResize,\n canSort,\n colSpan,\n hasMenu,\n hasSeparator,\n id,\n index,\n isFrozen,\n isPlaceholder,\n isPrinting,\n isResizing,\n length,\n meta,\n onGoto: handleGoto,\n onHide: handleHide,\n onResize: handleResize,\n onSort: handleSort,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n\n const className = cn(\n 'sticky font-bold border-b-2 box-content group/column relative',\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n 'px-[var(--table3-cell-padding-x)]',\n {\n '!border-white': isPlaceholder,\n 'h-10 items-center': !isPrinting,\n 'pb-2': isPrinting,\n 'cursor-pointer select-none': canSort,\n 'hover:bg-grey-100': !isPlaceholder && (canSort || canResize || hasMenu),\n 'focus-within:bg-grey-100': hasMenu,\n '!pointer-events-all !bg-grey-100': !isPlaceholder && isResizing,\n // z-indexes\n 'z-10 hover:z-20': !isFrozen && !isResizing,\n 'z-20': !isFrozen && isResizing,\n // when column is frozen, we need to increase it's z-index when it's hovered,\n // so that resize handler appears on top of next frozen cell, and didn't get cut by it.\n '!z-30 hover:!z-40': isFrozen,\n '!z-40': isFrozen && isResizing,\n },\n colSpan > 1 ? `col-span-${colSpan}` : '',\n meta.headerClassName\n );\n\n const [internalRef, setInternalRef] = React.useState<HTMLDivElement | null>(null);\n\n React.useLayoutEffect(() => {\n if (internalRef && length) {\n // the actions column size gets set by the column itself\n if (isInternalColumn(id)) {\n return;\n }\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [id]: internalRef.getBoundingClientRect().width,\n }));\n }\n }, [internalRef, length]);\n\n if (table.options.debugAll) {\n console.log('header render', id);\n }\n return (\n <div\n {...(canSort ? getSortAttributes(handleSort, sortDirection) : undefined)}\n className={className}\n data-align={align}\n data-column-index={index}\n role=\"columnheader\"\n ref={setInternalRef}>\n {isPlaceholder ? null : (\n <>\n {isInternalColumn(id) ? (\n children\n ) : (\n <Tooltip title={String(meta?.tooltip ?? children)} placement=\"top\">\n <span className={cn({ truncate: !isPrinting })}>{children}</span>\n </Tooltip>\n )}\n {canSort ? <SortIndicator direction={sortDirection} /> : null}\n {hasMenu ? (\n <Menu\n canFreeze={canFreeze}\n canHide={canHide}\n canSort={canSort}\n className={cn({\n 'ml-auto': align !== 'right',\n 'ml-2': align === 'right',\n })}\n index={index}\n menu={meta.menu}\n onGoto={handleGoto}\n onHide={handleHide}\n onSortToggle={handleSortToggle}\n scrollToIndex={scrollToIndex}\n sortDirection={sortDirection}\n table={table}\n />\n ) : null}\n </>\n )}\n {/* Header separator need to go before Resizer to prevent it's overlapping */}\n {hasSeparator ? <HeaderSeparator /> : null}\n {!isPlaceholder && canResize ? <Resizer isResizing={isResizing} onResize={handleResize} /> : null}\n </div>\n );\n}) as <TType = unknown>(props: MemoedHeaderProps<TType>) => JSX.Element;\n\nexport function HeaderSeparator() {\n return (\n <div\n data-taco=\"header-separator\"\n className={cn(\n 'invisible absolute right-[0.5px] top-0 flex h-full w-2 touch-none select-none justify-center py-2 group-hover/header:visible'\n )}>\n <div className={cn('bg-grey-300 h-full w-[1px]')} />\n </div>\n );\n}\n"],"names":["SORT_DIRECTION","ASC","DESC","Header","props","children","column","header","hasSeparator","scrollToIndex","table","tableMeta","options","meta","columnMeta","React","useMemo","columnDef","canSort","getCanSort","hasGoto","isGotoAvailable","handleHide","getToggleVisibilityHandler","handleResize","getResizeHandler","handleSort","getToggleSortingHandler","handleSortToggle","useCallback","sortDirection","clearSorting","toggleSorting","sorting","getState","filters","columnFilters","search","globalFilter","handleGoto","query","rowGoto","id","undefined","JSON","stringify","memoedProps","align","canFreeze","columnFreezing","isEnabled","canHide","getCanHide","canResize","getCanResize","colSpan","hasMenu","isMenuAvailable","index","isFrozen","isFrozenColumn","isPlaceholder","isPrinting","isResizing","getIsResizing","length","getRowModel","rows","onGoto","onHide","onResize","onSort","onSortToggle","getIsSorted","MemoedHeader","memo","className","cn","headerClassName","internalRef","setInternalRef","useState","useLayoutEffect","isInternalColumn","setColumnSizing","sizes","getBoundingClientRect","width","debugAll","console","log","getSortAttributes","role","ref","Tooltip","title","String","_meta$tooltip","tooltip","placement","truncate","SortIndicator","direction","Menu","menu","HeaderSeparator","Resizer"],"mappings":";;;;;;;;MAUaA,cAAc,GAAwC;EAC/DC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;;SAWMC,MAAMA,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,aAAa;IAAEC;GAAO,GAAGN,KAAK;EAC9E,MAAMO,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAwB;EACxD,MAAMC,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMV,MA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,OAAO;MAC5B,MAAM,EAAEA,KAAK,KAAK;KACrB,CAAC;IACFW,KAAK,EAAEA,KAAK;IACZ8C,IAAI,EAAE3F,IAAI,CAAC2F,IAAI;IACfpC,MAAM,EAAE7B,UAAU;IAClB8B,MAAM,EAAE/C,UAAU;IAClBkD,YAAY,EAAE5C,gBAAgB;IAC9BnB,aAAa,EAAEA,aAAa;IAC5BqB,aAAa,EAAEA,aAAa;IAC5BpB,KAAK,EAAEA;IACT,GACF,IAAI,CAEf,EAEAF,YAAY,gBAAGO,6BAAC0F,eAAe,OAAG,GAAG,IAAI,EACzC,CAAC5C,aAAa,IAAIR,SAAS,gBAAGtC,6BAAC2F,OAAO;IAAC3C,UAAU,EAAEA,UAAU;IAAEO,QAAQ,EAAE9C;IAAgB,GAAG,IAAI,CAC/F;AAEd,CAAC,CAAsE;SAEvDiF,eAAeA;EAC3B,oBACI1F;iBACc,kBAAkB;IAC5B6D,SAAS,EAAEC,EAAE,CACT,8HAA8H;kBAElI9D;IAAK6D,SAAS,EAAEC,EAAE,CAAC,4BAA4B;IAAK,CAClD;AAEd;;;;"}
1
+ {"version":3,"file":"Header.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Header.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, HeaderContext, TableMeta } from '@tanstack/react-table';\nimport { Menu, isMenuAvailable, isGotoAvailable } from './Menu';\nimport { Resizer } from './Resizer';\nimport { Table3ColumnAlignment, Table3SortDirection, TableStrategy } from '../../../types';\nimport { getSortAttributes, SortIndicator } from './SortIndicator';\nimport { isFrozenColumn, isInternalColumn } from '../../../util/columns';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport const SORT_DIRECTION: Record<string, Table3SortDirection> = {\n ASC: 'asc',\n DESC: 'desc',\n};\n\nexport type HeaderSortDirection = Table3SortDirection | false;\nexport type SortToggleHandler = (sortDirection: HeaderSortDirection) => void;\n\nexport type HeaderProps<TType = unknown> = HeaderContext<TType, unknown> & {\n children?: string | JSX.Element;\n hasSeparator?: boolean;\n};\n\nexport function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { children, column, header, hasSeparator, scrollToIndex, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const columnMeta = React.useMemo(() => column.columnDef.meta, []) as ColumnMeta<TType, unknown>;\n const canSort = column.getCanSort();\n const hasGoto = isGotoAvailable(table, header);\n\n // passing header or column results in re-renders on scroll, so anything from those objects as memoed props\n const handleHide = React.useMemo(() => header.column.getToggleVisibilityHandler(), []);\n const handleResize = React.useMemo(() => header.getResizeHandler(), []);\n const handleSort = React.useMemo(() => header.column.getToggleSortingHandler(), []);\n const handleSortToggle = React.useCallback((sortDirection: HeaderSortDirection) => {\n // When sorting is not applied, sortDirection is false.\n if (sortDirection === false) {\n header.column.clearSorting();\n } else {\n header.column.toggleSorting(sortDirection === SORT_DIRECTION.DESC);\n }\n }, []);\n\n const sorting = table.getState().sorting;\n const filters = table.getState().columnFilters;\n const search = table.getState().globalFilter;\n\n const handleGoto = React.useMemo(() => {\n if (hasGoto) {\n return ((query: string) => tableMeta.rowGoto.handleGoto(header.id, query, sorting, filters, search)) as (\n query: string\n ) => Promise<number>;\n }\n\n return undefined;\n }, [hasGoto, JSON.stringify(sorting), JSON.stringify(filters), search]);\n\n const memoedProps = {\n align: columnMeta.align,\n canFreeze: tableMeta.columnFreezing.isEnabled,\n canHide: column.getCanHide(),\n canResize: column.getCanResize(),\n canSort,\n children: children ?? columnMeta.header,\n colSpan: header.colSpan,\n hasMenu: isMenuAvailable<TType>(table, header),\n hasSeparator,\n id: header.id,\n index: header.index,\n isFrozen: isFrozenColumn(header, table),\n isPlaceholder: header.isPlaceholder,\n isPrinting: tableMeta.isPrinting,\n isResizing: column.getIsResizing(),\n length: table.getRowModel().rows.length,\n meta: columnMeta,\n onGoto: handleGoto,\n onHide: handleHide,\n onResize: handleResize,\n onSort: handleSort as (event: unknown) => void,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection: column.getIsSorted(),\n table,\n };\n\n return <MemoedHeader<TType> {...memoedProps} />;\n}\n\n// Memoization\nexport type MemoedHeaderProps<TType = unknown> = Omit<HeaderProps<TType>, 'column' | 'header'> & {\n align?: Table3ColumnAlignment;\n canFreeze: boolean;\n canHide: boolean;\n canResize: boolean;\n canSort: boolean;\n colSpan: number;\n hasMenu: boolean;\n hasSeparator?: boolean;\n id: string;\n index: number;\n isFrozen: boolean;\n isPlaceholder: boolean;\n isPrinting: boolean;\n isResizing: boolean;\n length: number;\n meta: ColumnMeta<TType, unknown>;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onResize: (event: unknown) => void;\n onSort: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n};\n\nconst MemoedHeader = React.memo(function MemoedHeader<TType = unknown>(props: MemoedHeaderProps<TType>) {\n const {\n align,\n children,\n canFreeze,\n canHide,\n canResize,\n canSort,\n colSpan,\n hasMenu,\n hasSeparator,\n id,\n index,\n isFrozen,\n isPlaceholder,\n isPrinting,\n isResizing,\n length,\n meta,\n onGoto: handleGoto,\n onHide: handleHide,\n onResize: handleResize,\n onSort: handleSort,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n\n const className = cn(\n 'font-bold border-b-2 box-content group/column relative',\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n 'px-[var(--table3-cell-padding-x)]',\n {\n '!border-white': isPlaceholder,\n 'h-10 items-center sticky': !isPrinting,\n 'pb-2': isPrinting,\n 'cursor-pointer select-none': canSort,\n 'hover:bg-grey-100': !isPlaceholder && (canSort || canResize || hasMenu),\n 'focus-within:bg-grey-100': hasMenu,\n '!pointer-events-all !bg-grey-100': !isPlaceholder && isResizing,\n // z-indexes\n 'z-10 hover:z-20': !isFrozen && !isResizing,\n 'z-20': !isFrozen && isResizing,\n // when column is frozen, we need to increase it's z-index when it's hovered,\n // so that resize handler appears on top of next frozen cell, and didn't get cut by it.\n '!z-30 hover:!z-40': isFrozen,\n '!z-40': isFrozen && isResizing,\n },\n colSpan > 1 ? `col-span-${colSpan}` : '',\n meta.headerClassName\n );\n\n const [internalRef, setInternalRef] = React.useState<HTMLDivElement | null>(null);\n\n React.useLayoutEffect(() => {\n if (internalRef && length) {\n // the actions column size gets set by the column itself\n if (isInternalColumn(id)) {\n return;\n }\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [id]: internalRef.getBoundingClientRect().width,\n }));\n }\n }, [internalRef, length]);\n\n if (table.options.debugAll) {\n console.log('header render', id);\n }\n return (\n <div\n {...(canSort ? getSortAttributes(handleSort, sortDirection) : undefined)}\n className={className}\n data-align={align}\n data-column-index={index}\n role=\"columnheader\"\n ref={setInternalRef}>\n {isPlaceholder ? null : (\n <>\n {isInternalColumn(id) ? (\n children\n ) : (\n <Tooltip title={String(meta?.tooltip ?? children)} placement=\"top\">\n <span className={cn({ truncate: !isPrinting })}>{children}</span>\n </Tooltip>\n )}\n {canSort ? <SortIndicator direction={sortDirection} /> : null}\n {hasMenu ? (\n <Menu\n canFreeze={canFreeze}\n canHide={canHide}\n canSort={canSort}\n className={cn({\n 'ml-auto': align !== 'right',\n 'ml-2': align === 'right',\n })}\n index={index}\n menu={meta.menu}\n onGoto={handleGoto}\n onHide={handleHide}\n onSortToggle={handleSortToggle}\n scrollToIndex={scrollToIndex}\n sortDirection={sortDirection}\n table={table}\n />\n ) : null}\n </>\n )}\n {/* Header separator need to go before Resizer to prevent it's overlapping */}\n {hasSeparator ? <HeaderSeparator /> : null}\n {!isPlaceholder && canResize ? <Resizer isResizing={isResizing} onResize={handleResize} /> : null}\n </div>\n );\n}) as <TType = unknown>(props: MemoedHeaderProps<TType>) => JSX.Element;\n\nexport function HeaderSeparator() {\n return (\n <div\n data-taco=\"header-separator\"\n className={cn(\n 'invisible absolute right-[0.5px] top-0 flex h-full w-2 touch-none select-none justify-center py-2 group-hover/header:visible'\n )}>\n <div className={cn('bg-grey-300 h-full w-[1px]')} />\n </div>\n );\n}\n"],"names":["SORT_DIRECTION","ASC","DESC","Header","props","children","column","header","hasSeparator","scrollToIndex","table","tableMeta","options","meta","columnMeta","React","useMemo","columnDef","canSort","getCanSort","hasGoto","isGotoAvailable","handleHide","getToggleVisibilityHandler","handleResize","getResizeHandler","handleSort","getToggleSortingHandler","handleSortToggle","useCallback","sortDirection","clearSorting","toggleSorting","sorting","getState","filters","columnFilters","search","globalFilter","handleGoto","query","rowGoto","id","undefined","JSON","stringify","memoedProps","align","canFreeze","columnFreezing","isEnabled","canHide","getCanHide","canResize","getCanResize","colSpan","hasMenu","isMenuAvailable","index","isFrozen","isFrozenColumn","isPlaceholder","isPrinting","isResizing","getIsResizing","length","getRowModel","rows","onGoto","onHide","onResize","onSort","onSortToggle","getIsSorted","MemoedHeader","memo","className","cn","headerClassName","internalRef","setInternalRef","useState","useLayoutEffect","isInternalColumn","setColumnSizing","sizes","getBoundingClientRect","width","debugAll","console","log","getSortAttributes","role","ref","Tooltip","title","String","_meta$tooltip","tooltip","placement","truncate","SortIndicator","direction","Menu","menu","HeaderSeparator","Resizer"],"mappings":";;;;;;;;MAUaA,cAAc,GAAwC;EAC/DC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;;SAWMC,MAAMA,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,aAAa;IAAEC;GAAO,GAAGN,KAAK;EAC9E,MAAMO,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAwB;EACxD,MAAMC,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMV,MAAM,CAACW,SAAS,CAACJ,IAAI,EAAE,EAAE,CAA+B;EAC/F,MAAMK,OAAO,GAAGZ,MAAM,CAACa,UAAU,EAAE;EACnC,MAAMC,OAAO,GAAGC,eAAe,CAACX,KAAK,EAAEH,MAAM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AM,EAAE/C,UAAU;IAClBkD,YAAY,EAAE5C,gBAAgB;IAC9BnB,aAAa,EAAEA,aAAa;IAC5BqB,aAAa,EAAEA,aAAa;IAC5BpB,KAAK,EAAEA;IACT,GACF,IAAI,CAEf,EAEAF,YAAY,gBAAGO,6BAAC0F,eAAe,OAAG,GAAG,IAAI,EACzC,CAAC5C,aAAa,IAAIR,SAAS,gBAAGtC,6BAAC2F,OAAO;IAAC3C,UAAU,EAAEA,UAAU;IAAEO,QAAQ,EAAE9C;IAAgB,GAAG,IAAI,CAC/F;AAEd,CAAC,CAAsE;SAEvDiF,eAAeA;EAC3B,oBACI1F;iBACc,kBAAkB;IAC5B6D,SAAS,EAAEC,EAAE,CACT,8HAA8H;kBAElI9D;IAAK6D,SAAS,EAAEC,EAAE,CAAC,4BAA4B;IAAK,CAClD;AAEd;;;;"}
@@ -5,7 +5,6 @@ import { useLocalization } from '../../../../Provider/Localization.js';
5
5
  import { Menu as Menu$1 } from '../../../../Menu/Menu.js';
6
6
  import { _finallyRethrows, _catch } from '../../../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
7
7
  import { GotoPopover } from './Goto.js';
8
- import { FONT_SIZE } from '../../toolbar/FontSize.js';
9
8
  import { SORT_DIRECTION } from './Header.js';
10
9
  import { isInternalColumn } from '../../../util/columns.js';
11
10
 
@@ -44,7 +43,6 @@ function Menu(props) {
44
43
  } = useLocalization();
45
44
  const [popover, setPopover] = React__default.useState(undefined);
46
45
  const [sortDirectionState, setSortDirectionState] = React__default.useState(sortDirection);
47
- const isFontSizeLarge = tableMeta.fontSize.size === FONT_SIZE.large;
48
46
  const handleSortMenuRadioGroupChange = newSortDirection => {
49
47
  setSortDirectionState(newSortDirection);
50
48
  handleSortToggle(newSortDirection);
@@ -87,10 +85,7 @@ function Menu(props) {
87
85
  }
88
86
  }
89
87
  const className = cn('-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden', 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto', 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto', 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto', {
90
- '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement,
91
- // Icon inside button uses em values therefore text-sm is required to prevent icon from overflowing
92
- // button's boundaries
93
- '!text-sm': isFontSizeLarge
88
+ '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement
94
89
  }, props.className);
95
90
  const memoedMenuItems = React__default.useMemo(() => {
96
91
  const menuItems = [];
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Header as RTHeader, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../Menu/Menu';\nimport { isInternalColumn } from '../../../util/columns';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Table3ColumnHeaderMenu, TableStrategy } from '../../../types';\nimport { GotoPopover } from './Goto';\nimport { HeaderSortDirection, SORT_DIRECTION, SortToggleHandler } from './Header';\nimport { RadioGroupItemValue } from '../../../../RadioGroup/RadioGroup';\nimport { FONT_SIZE } from '../../toolbar/FontSize';\n\nexport function isGotoAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>) {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return !!(tableMeta.rowGoto.isEnabled && header.column.getCanSort() && header.column.getIsSorted());\n}\n\nexport function isMenuAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>): boolean {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return (\n !!header.column.columnDef.meta?.menu ||\n !!tableMeta.columnFreezing.isEnabled ||\n (!!table.options.enableHiding && !!header.column.getCanHide()) ||\n isGotoAvailable(table, header)\n );\n}\n\nexport type MenuProps<TType = unknown> = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFreeze: boolean;\n canHide: boolean;\n canSort: boolean;\n index: number;\n menu?: Table3ColumnHeaderMenu;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n table: RTable<TType>;\n};\n\nexport function Menu<TType = unknown>(props: MenuProps<TType>) {\n const {\n canFreeze,\n canHide,\n canSort,\n index,\n menu,\n onGoto: handleGoto,\n onHide: handleHide,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n const [sortDirectionState, setSortDirectionState] = React.useState<HeaderSortDirection>(sortDirection);\n\n const isFontSizeLarge = tableMeta.fontSize.size === FONT_SIZE.large;\n\n const handleSortMenuRadioGroupChange = (newSortDirection: RadioGroupItemValue) => {\n setSortDirectionState(newSortDirection as HeaderSortDirection);\n handleSortToggle(newSortDirection as HeaderSortDirection);\n };\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'goto': {\n if (handleGoto) {\n const goto = async (query: string) => {\n try {\n const index = await handleGoto(query);\n tableMeta.currentRow.setCurrentRowIndex(index);\n scrollToIndex(index + 2, { align: 'center' });\n } catch {\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden',\n 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto',\n 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto',\n 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto',\n {\n '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement,\n // Icon inside button uses em values therefore text-sm is required to prevent icon from overflowing\n // button's boundaries\n '!text-sm': isFontSizeLarge,\n },\n props.className\n );\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = event => setTimeout(() => handleHide(event), 1);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table3.columns.menu.hideColumn}\n </MenuPrimitive.Item>\n );\n }\n\n // We rely on canSort value instead of onSort function's value because some columns might have sorting disabled,\n // so even though onSort is truthy, we don't want to show sorting menu.\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortMenuRadioGroupChange} value={sortDirectionState}>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.ASC}>\n {texts.table3.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.DESC}>\n {texts.table3.columns.menu.sortingOrder.descending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={false}>\n {texts.table3.columns.menu.sortingOrder.unsorted}\n </MenuPrimitive.RadioGroup.Item>\n </MenuPrimitive.RadioGroup>\n </MenuPrimitive.SubMenu>\n )}>\n {texts.table3.columns.menu.sorting}\n </MenuPrimitive.Item>\n );\n }\n\n if (handleGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut=\"g\">\n {texts.table3.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canFreeze) {\n const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;\n const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={handleClick}>\n {frozenIndex === 0\n ? texts.table3.columns.menu.freezeFirstColumn\n : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(frozenIndex + 1))}\n </MenuPrimitive.Item>\n );\n\n if (tableMeta.columnFreezing.frozenColumnIndex !== undefined) {\n const handleClick = () => {\n tableMeta.columnFreezing.setFrozenColumnIndex(undefined);\n };\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={handleClick}>\n {texts.table3.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n }\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<MenuPrimitive.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n return menuItems.map((item, key) => React.cloneElement(item, { key }));\n }, [\n menu,\n index,\n canFreeze,\n canHide,\n canSort,\n handleGoto,\n handleSortToggle,\n sortDirection,\n tableMeta.columnFreezing.frozenColumnIndex,\n ]);\n\n return (\n <IconButton\n className={className}\n icon=\"more\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <MenuPrimitive {...menuProps}>\n <MenuPrimitive.Content>{memoedMenuItems}</MenuPrimitive.Content>\n </MenuPrimitive>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n />\n );\n}\n"],"names":["isGotoAvailable","table","header","isInternalColumn","id","tableMeta","options","meta","rowGoto","isEnabled","column","getCanSort","getIsSorted","isMenuAvailable","_header$column$column","columnDef","menu","columnFreezing","enableHiding","getCanHide","Menu","props","canFreeze","canHide","canSort","index","onGoto","handleGoto","onHide","handleHide","onSortToggle","handleSortToggle","scrollToIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","sortDirectionState","setSortDirectionState","isFontSizeLarge","fontSize","size","FONT_SIZE","large","handleSortMenuRadioGroupChange","newSortDirection","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","currentRow","setCurrentRowIndex","align","_wasThrown","_result","_temp","e","reject","GotoPopover","open","onChange","className","cn","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table3","columns","hideColumn","subMenu","SubMenu","RadioGroup","value","SORT_DIRECTION","ASC","sortingOrder","ascending","DESC","descending","unsorted","sorting","shortcut","gotoRow","frozenIndex","frozenInternalColumnCount","setFrozenColumnIndex","freezeFirstColumn","freezeUptoColumn","replace","String","frozenColumnIndex","unfreezeColumns","customMenu","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","IconButton","menuProps","Content","onClickCapture","preventDefault"],"mappings":";;;;;;;;;;;SAagBA,eAAeA,CAAkBC,KAAoB,EAAEC,MAAgC;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC7B,OAAO,KAAK;;EAGhB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EAExD,OAAO,CAAC,EAAEF,SAAS,CAACG,OAAO,CAACC,SAAS,IAAIP,MAAM,CAACQ,MAAM,CAACC,UAAU,EAAE,IAAIT,MAAM,CAACQ,MAAM,CAACE,WAAW,EAAE,CAAC;AACvG;SAEgBC,eAAeA,CAAkBZ,KAAoB,EAAEC,MAAgC;;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC7B,OAAO,KAAK;;EAGhB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EAExD,O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SAAS,OAAG,CAAC;;QAG/C1C,SAAS,CAACI,IAAI,CAAC,GAAGiC,WAAW,CAAC;;;IAItC,OAAOrC,SAAS,CAAC2C,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,kBAAK/E,cAAK,CAACgF,YAAY,CAACF,IAAI,EAAE;MAAEC;KAAK,CAAC,CAAC;GACzE,EAAE,CACCrG,IAAI,EACJS,KAAK,EACLH,SAAS,EACTC,OAAO,EACPC,OAAO,EACPG,UAAU,EACVI,gBAAgB,EAChBE,aAAa,EACb5B,SAAS,CAACY,cAAc,CAACwF,iBAAiB,CAC7C,CAAC;EAEF,oBACInE,6BAACiF,UAAU;IACPnD,SAAS,EAAEA,SAAS;IACpBW,IAAI,EAAC,MAAM;IACX/D,IAAI,EACAkC,cAAc,GACRV,SAAS,GACTgF,SAAS,iBACLlF,6BAACuC,MAAa,oBAAK2C,SAAS,gBACxBlF,6BAACuC,MAAa,CAAC4C,OAAO,QAAEnD,eAAe,CAAyB,CAEvE;IAEXlC,OAAO,EAAEc,cAAc;IACvBwE,cAAc,EAAEhD,KAAK,IAAIA,KAAK,CAACiD,cAAc;IAC/C;AAEV;;;;"}
1
+ {"version":3,"file":"Menu.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/header/Menu.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Header as RTHeader, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu as MenuPrimitive } from '../../../../Menu/Menu';\nimport { isInternalColumn } from '../../../util/columns';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Table3ColumnHeaderMenu, TableStrategy } from '../../../types';\nimport { GotoPopover } from './Goto';\nimport { HeaderSortDirection, SORT_DIRECTION, SortToggleHandler } from './Header';\nimport { RadioGroupItemValue } from '../../../../RadioGroup/RadioGroup';\n\nexport function isGotoAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>) {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return !!(tableMeta.rowGoto.isEnabled && header.column.getCanSort() && header.column.getIsSorted());\n}\n\nexport function isMenuAvailable<TType = unknown>(table: RTable<TType>, header: RTHeader<TType, unknown>): boolean {\n if (isInternalColumn(header.id)) {\n return false;\n }\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n return (\n !!header.column.columnDef.meta?.menu ||\n !!tableMeta.columnFreezing.isEnabled ||\n (!!table.options.enableHiding && !!header.column.getCanHide()) ||\n isGotoAvailable(table, header)\n );\n}\n\nexport type MenuProps<TType = unknown> = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n canFreeze: boolean;\n canHide: boolean;\n canSort: boolean;\n index: number;\n menu?: Table3ColumnHeaderMenu;\n onGoto?: (query: string) => Promise<number>;\n onHide: (event: unknown) => void;\n onSortToggle: SortToggleHandler;\n scrollToIndex: TableStrategy['scrollToIndex'];\n sortDirection: HeaderSortDirection;\n table: RTable<TType>;\n};\n\nexport function Menu<TType = unknown>(props: MenuProps<TType>) {\n const {\n canFreeze,\n canHide,\n canSort,\n index,\n menu,\n onGoto: handleGoto,\n onHide: handleHide,\n onSortToggle: handleSortToggle,\n scrollToIndex,\n sortDirection,\n table,\n } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n const [popover, setPopover] = React.useState<string | undefined>(undefined);\n const [sortDirectionState, setSortDirectionState] = React.useState<HeaderSortDirection>(sortDirection);\n\n const handleSortMenuRadioGroupChange = (newSortDirection: RadioGroupItemValue) => {\n setSortDirectionState(newSortDirection as HeaderSortDirection);\n handleSortToggle(newSortDirection as HeaderSortDirection);\n };\n\n let popoverElement;\n\n if (popover) {\n const handleClosePopover = () => setPopover(undefined);\n\n switch (popover) {\n case 'goto': {\n if (handleGoto) {\n const goto = async (query: string) => {\n try {\n const index = await handleGoto(query);\n tableMeta.currentRow.setCurrentRowIndex(index);\n scrollToIndex(index + 2, { align: 'center' });\n } catch {\n //\n } finally {\n handleClosePopover();\n }\n };\n popoverElement = props => <GotoPopover {...props} open onChange={handleClosePopover} onGoto={goto} />;\n }\n }\n }\n }\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden',\n 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto',\n 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto',\n 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto',\n {\n '!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement,\n },\n props.className\n );\n\n const memoedMenuItems = React.useMemo(() => {\n const menuItems: JSX.Element[] = [];\n\n if (canHide) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = event => setTimeout(() => handleHide(event), 1);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table3.columns.menu.hideColumn}\n </MenuPrimitive.Item>\n );\n }\n\n // We rely on canSort value instead of onSort function's value because some columns might have sorting disabled,\n // so even though onSort is truthy, we don't want to show sorting menu.\n if (canSort) {\n menuItems.push(\n <MenuPrimitive.Item\n icon=\"sort-by\"\n subMenu={() => (\n <MenuPrimitive.SubMenu>\n <MenuPrimitive.RadioGroup onChange={handleSortMenuRadioGroupChange} value={sortDirectionState}>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.ASC}>\n {texts.table3.columns.menu.sortingOrder.ascending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={SORT_DIRECTION.DESC}>\n {texts.table3.columns.menu.sortingOrder.descending}\n </MenuPrimitive.RadioGroup.Item>\n <MenuPrimitive.RadioGroup.Item value={false}>\n {texts.table3.columns.menu.sortingOrder.unsorted}\n </MenuPrimitive.RadioGroup.Item>\n </MenuPrimitive.RadioGroup>\n </MenuPrimitive.SubMenu>\n )}>\n {texts.table3.columns.menu.sorting}\n </MenuPrimitive.Item>\n );\n }\n\n if (handleGoto) {\n menuItems.push(\n <MenuPrimitive.Item icon=\"move\" onClick={() => setPopover('goto')} shortcut=\"g\">\n {texts.table3.columns.menu.gotoRow}...\n </MenuPrimitive.Item>\n );\n }\n\n if (canFreeze) {\n const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;\n const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-freeze\" onClick={handleClick}>\n {frozenIndex === 0\n ? texts.table3.columns.menu.freezeFirstColumn\n : texts.table3.columns.menu.freezeUptoColumn.replace('[TOTAL]', String(frozenIndex + 1))}\n </MenuPrimitive.Item>\n );\n\n if (tableMeta.columnFreezing.frozenColumnIndex !== undefined) {\n const handleClick = () => {\n tableMeta.columnFreezing.setFrozenColumnIndex(undefined);\n };\n\n menuItems.push(\n <MenuPrimitive.Item icon=\"column-unfreeze\" onClick={handleClick}>\n {texts.table3.columns.menu.unfreezeColumns}\n </MenuPrimitive.Item>\n );\n }\n }\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<MenuPrimitive.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n return menuItems.map((item, key) => React.cloneElement(item, { key }));\n }, [\n menu,\n index,\n canFreeze,\n canHide,\n canSort,\n handleGoto,\n handleSortToggle,\n sortDirection,\n tableMeta.columnFreezing.frozenColumnIndex,\n ]);\n\n return (\n <IconButton\n className={className}\n icon=\"more\"\n menu={\n popoverElement\n ? undefined\n : menuProps => (\n <MenuPrimitive {...menuProps}>\n <MenuPrimitive.Content>{memoedMenuItems}</MenuPrimitive.Content>\n </MenuPrimitive>\n )\n }\n popover={popoverElement}\n onClickCapture={event => event.preventDefault()}\n />\n );\n}\n"],"names":["isGotoAvailable","table","header","isInternalColumn","id","tableMeta","options","meta","rowGoto","isEnabled","column","getCanSort","getIsSorted","isMenuAvailable","_header$column$column","columnDef","menu","columnFreezing","enableHiding","getCanHide","Menu","props","canFreeze","canHide","canSort","index","onGoto","handleGoto","onHide","handleHide","onSortToggle","handleSortToggle","scrollToIndex","sortDirection","texts","useLocalization","popover","setPopover","React","useState","undefined","sortDirectionState","setSortDirectionState","handleSortMenuRadioGroupChange","newSortDirection","popoverElement","handleClosePopover","goto","query","Promise","resolve","then","currentRow","setCurrentRowIndex","align","_wasThrown","_result","_temp","e","reject","GotoPopover","open","onChange","className","cn","memoedMenuItems","useMemo","menuItems","handleClick","event","setTimeout","push","MenuPrimitive","Item","icon","onClick","table3","columns","hideColumn","subMenu","SubMenu","RadioGroup","value","SORT_DIRECTION","ASC","sortingOrder","ascending","DESC","descending","unsorted","sorting","shortcut","gotoRow","frozenIndex","frozenInternalColumnCount","setFrozenColumnIndex","freezeFirstColumn","freezeUptoColumn","replace","String","frozenColumnIndex","unfreezeColumns","customMenu","trigger","customItems","Children","toArray","children","length","Separator","map","item","key","cloneElement","IconButton","menuProps","Content","onClickCapture","preventDefault"],"mappings":";;;;;;;;;;SAYgBA,eAAeA,CAAkBC,KAAoB,EAAEC,MAAgC;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC7B,OAAO,KAAK;;EAGhB,MAAMC,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EAExD,OAAO,CAAC,EAAEF,SAAS,CAACG,OAAO,CAACC,SAAS,IAAIP,MAAM,CAACQ,MAAM,CAACC,UAAU,EAAE,IAAIT,MAAM,CAACQ,MAAM,CAACE,WAAW,EAAE,CAAC;AACvG;SAEgBC,eAAeA,CAAkBZ,KAAoB,EAAEC,MAAgC;;EACnG,IAAIC,gBAAgB,CAACD,MAAM,CAACE,EAAE,CAAC,EAAE;IAC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S,CAACI,IAAI,CAAC,GAAGiC,WAAW,CAAC;;;IAItC,OAAOrC,SAAS,CAAC2C,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,kBAAK1E,cAAK,CAAC2E,YAAY,CAACF,IAAI,EAAE;MAAEC;KAAK,CAAC,CAAC;GACzE,EAAE,CACChG,IAAI,EACJS,KAAK,EACLH,SAAS,EACTC,OAAO,EACPC,OAAO,EACPG,UAAU,EACVI,gBAAgB,EAChBE,aAAa,EACb5B,SAAS,CAACY,cAAc,CAACmF,iBAAiB,CAC7C,CAAC;EAEF,oBACI9D,6BAAC4E,UAAU;IACPnD,SAAS,EAAEA,SAAS;IACpBW,IAAI,EAAC,MAAM;IACX1D,IAAI,EACA6B,cAAc,GACRL,SAAS,GACT2E,SAAS,iBACL7E,6BAACkC,MAAa,oBAAK2C,SAAS,gBACxB7E,6BAACkC,MAAa,CAAC4C,OAAO,QAAEnD,eAAe,CAAyB,CAEvE;IAEX7B,OAAO,EAAES,cAAc;IACvBwE,cAAc,EAAEhD,KAAK,IAAIA,KAAK,CAACiD,cAAc;IAC/C;AAEV;;;;"}
@@ -4,11 +4,11 @@ import { IconButton } from '../../../../IconButton/IconButton.js';
4
4
  import { useLocalization } from '../../../../Provider/Localization.js';
5
5
  import { Shortcut } from '../../../../Shortcut/Shortcut.js';
6
6
  import { Menu } from '../../../../Menu/Menu.js';
7
- import { FONT_SIZE } from '../../toolbar/FontSize.js';
8
7
  import { Header } from '../header/Header.js';
9
8
  import { RowContext } from '../../rows/RowContext.js';
10
9
  import { DisplayCell } from '../cell/DisplayCell.js';
11
10
  import { Footer } from '../footer/Footer.js';
11
+ import { FONT_SIZE } from '../../toolbar/FontSize.js';
12
12
 
13
13
  const COLUMN_ID = '__actions';
14
14
  const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
@@ -6,7 +6,9 @@ import { RowContext, useRowContext } from './RowContext.js';
6
6
  import { focusableSelector } from '../../util/editing.js';
7
7
 
8
8
  const FOCUS_MANAGER_OPTIONS = {
9
- tabbable: true
9
+ tabbable: true,
10
+ // Filter out all focusable elelemnts which are not in current row
11
+ accept: element => !!element.closest('[role="row"][data-current="true"]')
10
12
  };
11
13
  function Row(props) {
12
14
  const focusManager = useFocusManager();
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/rows/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { Row as RTRow, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { RowContext, useRowContext } from './RowContext';\nimport { useDropTarget } from '../../../../utils/hooks/useDropTarget';\nimport { Table3RowClickHandler, Table3RowDropHandler } from '../../types';\nimport { useFocusManager } from '@react-aria/focus';\nimport { focusableSelector } from '../../util/editing';\n\nconst FOCUS_MANAGER_OPTIONS = { tabbable: true };\n\ntype RowProps<TType = unknown> = Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop'> & {\n index: number;\n isLastRow: boolean;\n measureRef: (el: HTMLElement | null) => void;\n onClick?: Table3RowClickHandler<TType>;\n onDrop?: Table3RowDropHandler<TType>;\n row: RTRow<TType>;\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const focusManager = useFocusManager();\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;\n const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];\n const isFirstRow = props.index === 0;\n // we use non-css hovered state to determine whether to render actions or not, for performance\n const [isHovered, setIsHovered] = React.useState(false);\n\n // tab behaviour is consistent across normal mode and edit mode, handle it here\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped()) {\n return;\n }\n\n if (event.key === 'Tab') {\n tableMeta.hoverState.pause(true);\n let focusedElement: Element;\n\n if (event.shiftKey) {\n // looping backwards\n focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n // override default behaviour, since we're handling focus internally now\n event.preventDefault();\n } else {\n // there are no previous elements to focus, go up a row or go outside the table\n if (!isFirstRow) {\n event.preventDefault();\n tableMeta.currentRow.setCurrentRowIndex(props.index - 1);\n setTimeout(() => focusManager.focusLast(FOCUS_MANAGER_OPTIONS), 1);\n }\n }\n } else {\n // looping forwards\n focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n // override default behaviour, since we're handling focus internally now\n event.preventDefault();\n } else {\n // there are no next elements to focus, go down a row or go outside the table\n if (!props.isLastRow) {\n event.preventDefault();\n tableMeta.currentRow.setCurrentRowIndex(props.index + 1);\n setTimeout(() => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS), 1);\n }\n }\n }\n }\n };\n\n // rows are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the row\n const memoedProps = {\n // aria-grabbed is being deprecated but there is no current alternative api, we use it until there is\n 'aria-grabbed': isDraggingRow ? true : tableMeta.rowDrag.isEnabled ? false : undefined,\n 'data-current': isCurrentRow,\n 'data-selected': props.row.getIsSelected(),\n draggable: tableMeta.rowDrag.isEnabled,\n index: props.index,\n onClick: tableMeta.rowClick.handleClick,\n onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,\n onKeyDown: handleKeyDown,\n };\n\n let output = <MemoedRow<TType> {...props} {...memoedProps} />;\n\n if (tableMeta.editing.isEditing && (isCurrentRow || (isHovered && !tableMeta.hoverState.isPaused))) {\n output = (\n <EditingRow\n {...props}\n {...memoedProps}\n isFirstRow={isFirstRow}\n setCurrentRowIndex={tableMeta.currentRow.setCurrentRowIndex}\n />\n );\n }\n\n // we store the row index in context because in a virtualised table the row index and the\n // react table row index do not match when, for example, sorting is applied\n const contextValue = React.useMemo(() => ({ isHovered, setIsHovered, rowIndex: props.index }), [isHovered, props.index]);\n\n return <RowContext.Provider value={contextValue}>{output}</RowContext.Provider>;\n}\n\n// turns out we might need some kind of \"state\" for the focused column, but it doesn't need to be react state that re-renders\nlet lastIndex;\n\nfunction getColumnIndex(focusedElement: Element) {\n if (focusedElement) {\n return focusedElement.closest('[role=cell]')?.getAttribute('data-column-index');\n }\n\n return null;\n}\n\n// This code is needed to avoid multiple rows being hovered at the same time (it happens since we use non-css hovering)\nlet previouslyHoveredIndex: number | undefined;\nconst unhoverPreviousRow = (tableRef: React.RefObject<HTMLDivElement>) => {\n if (previouslyHoveredIndex !== undefined) {\n const mouseoutEvent = new MouseEvent('mouseout', { view: window, bubbles: true, cancelable: true });\n const previouslyHovered = tableRef?.current?.querySelector(`[data-row-index=\"${previouslyHoveredIndex}\"]`);\n previouslyHovered?.dispatchEvent(mouseoutEvent);\n }\n};\n\nfunction EditingRow(props) {\n const { isFirstRow, isLastRow, onKeyDown, setCurrentRowIndex, virtualiser, ...attributes } = props;\n const focusManager = useFocusManager();\n const tableMeta = props.table.options.meta as TableMeta<unknown>;\n\n const handleClickCapture = (event: React.FocusEvent) => {\n lastIndex = getColumnIndex(event.target);\n };\n\n const handleArrowLeftKey = event => {\n let focusedElement: Element;\n\n if (event.key === 'ArrowLeft') {\n // We need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowLeft\" or \"META + ArrowLeft\" should focus first focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // looping backwards\n focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // there are no previous elements to focus, go up a row (if there are rows above)\n if (!isFirstRow) {\n event.preventDefault();\n tableMeta.hoverState.pause(true);\n tableMeta.currentRow.setCurrentRowIndex(props.index - 1);\n setTimeout(() => {\n focusManager.focusLast(FOCUS_MANAGER_OPTIONS);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n }\n }\n }\n }\n };\n\n const handleArrowRightKey = event => {\n let focusedElement: Element;\n\n if (event.key === 'ArrowRight') {\n // We need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowRight\" or \"META + ArrowRight\" should focus last focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusLast(FOCUS_MANAGER_OPTIONS);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // looping forwards\n focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // there are no next elements to focus, go down a row or go outside the table\n if (!props.isLastRow) {\n event.preventDefault();\n tableMeta.hoverState.pause(true);\n tableMeta.currentRow.setCurrentRowIndex(props.index + 1);\n setTimeout(() => {\n focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n }\n }\n }\n }\n };\n\n React.useEffect(() => {\n // if some row stuck in hovered state, we heed to unhover it when hover state is paused\n if (tableMeta.hoverState.isPaused) {\n unhoverPreviousRow(props.tableRef);\n }\n }, [tableMeta.hoverState.isPaused]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {\n return;\n }\n\n onKeyDown(event); // handles tab behaviour\n handleArrowLeftKey(event);\n handleArrowRightKey(event);\n };\n\n // this ensures we focus either on a field or on the same column when keyboard navigating up/down\n React.useEffect(() => {\n if (tableMeta.currentRow.currentRowIndex === props.index) {\n if (lastIndex !== undefined) {\n const lastIndexCell = props.tableRef.current?.querySelector(\n `[role=\"row\"][data-current=\"true\"] [data-column-index=\"${lastIndex}\"]`\n );\n lastIndexCell?.querySelector(focusableSelector)?.focus();\n } else {\n focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n }\n }\n // Need to subscribe to current row index and check is it a current row,\n // for a situation where hovered row is the next row after current row...\n // In this case row will not be re-rendered if user switch to next row, because hovered row also renders EditingRow.\n }, [tableMeta.currentRow.currentRowIndex]);\n\n return <MemoedRow {...attributes} onClickCapture={handleClickCapture} onKeyDown={handleKeyDown} />;\n}\n\n// Memoization\n\nexport type MemoedRowProps<TType = unknown> = RowProps<TType> & {\n 'aria-grabbed'?: boolean;\n 'data-current': boolean;\n 'data-selected': boolean;\n draggable: boolean;\n index: number;\n};\n\nconst clickableElements = ['input', 'button', 'a', 'select', 'option', 'label', 'textarea'];\n\nconst MemoedRow = React.memo(function MemoedRow<TType = unknown>(props: MemoedRowProps<TType>) {\n const { index, isLastRow: _1, measureRef, onClick, onClickCapture, onDrop, row, table, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { setIsHovered } = useRowContext();\n\n // we measure the first cell (since the row has display: contents) so that the virtualiser height is correct\n React.useEffect(() => {\n const firstCell = ref.current?.querySelector('[role=cell]:first-child');\n\n if (firstCell) {\n measureRef(firstCell as HTMLElement);\n }\n }, [ref.current]);\n\n // we use capture because it also picks up clicks on e.g. select checkboxes\n const handleClickCapture = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (typeof onClickCapture === 'function') {\n onClickCapture(event);\n }\n\n // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable\n requestAnimationFrame(() => tableMeta.currentRow.setCurrentRowIndex(index));\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (typeof onClick === 'function') {\n const clickedElement = event.target as HTMLElement;\n\n if (\n !ref.current?.contains(event.target as HTMLElement) ||\n clickableElements.includes(clickedElement.tagName.toLowerCase()) ||\n clickedElement.closest(clickableElements.map(tag => `[role=row] ${tag}`).join(','))\n ) {\n return;\n }\n\n onClick(row.original);\n }\n };\n\n const handleMouseEnter = () => {\n // When user moving mouse to fast, then some of the rows are getting stuck in hover state,\n // because mouseleave event never got triggered, to avoid this to happen we're saving the index of last hovered row,\n // so that we can unhover it when new row got hovered, and saving it in a variable outside of react to save in performance,\n // since it would be very performance heavy to use state which is bound to mouse events.\n if (previouslyHoveredIndex !== undefined) {\n if (previouslyHoveredIndex !== index) {\n unhoverPreviousRow(tableRef);\n previouslyHoveredIndex = index;\n }\n } else {\n previouslyHoveredIndex = index;\n }\n setIsHovered(true);\n };\n const handleMouseLeave = () => {\n if (previouslyHoveredIndex === index) {\n previouslyHoveredIndex = undefined;\n }\n setIsHovered(false);\n };\n\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => onDrop?.(event, row.original));\n\n const className = cn(\n 'group/row contents',\n // resizing column requires dragging, which means the mouse might (on rare occasions) move over rows and trigger hover state\n // that in turn triggers rendering of e.g. row actions, which could cause janky ui - so don't allow mouse interaction when resizing\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n {\n 'hover:cursor-pointer': typeof onClick === 'function',\n }\n );\n\n return (\n <div\n {...attributes}\n {...(onDrop ? dropTargetProps : undefined)}\n className={className}\n data-row-index={index}\n data-dragged-over={isDraggedOver}\n onClick={handleClick}\n onClickCapture={handleClickCapture}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n role=\"row\"\n ref={ref}\n />\n );\n}) as <TType = unknown>(props: MemoedRowProps<TType>) => JSX.Element;\n"],"names":["FOCUS_MANAGER_OPTIONS","tabbable","Row","props","focusManager","useFocusManager","tableMeta","table","options","meta","isCurrentRow","currentRow","currentRowIndex","index","isDraggingRow","rowDrag","dragging","row","id","isFirstRow","isHovered","setIsHovered","React","useState","handleKeyDown","event","isDefaultPrevented","isPropagationStopped","key","hoverState","pause","focusedElement","shiftKey","focusPrevious","preventDefault","setCurrentRowIndex","setTimeout","focusLast","focusNext","isLastRow","focusFirst","memoedProps","isEnabled","undefined","getIsSelected","draggable","onClick","rowClick","handleClick","onDrop","rowDrop","handleDrop","onKeyDown","output","MemoedRow","editing","isEditing","isPaused","EditingRow","contextValue","useMemo","rowIndex","RowContext","Provider","value","lastIndex","getColumnIndex","_focusedElement$close","closest","getAttribute","previouslyHoveredIndex","unhoverPreviousRow","tableRef","_tableRef$current","mouseoutEvent","MouseEvent","view","window","bubbles","cancelable","previouslyHovered","current","querySelector","dispatchEvent","virtualiser","attributes","handleClickCapture","target","handleArrowLeftKey","stopPropagation","ctrlKey","metaKey","blur","handleArrowRightKey","useEffect","detailModeEditing","_props$tableRef$curre","_lastIndexCell$queryS","lastIndexCell","focusableSelector","focus","onClickCapture","clickableElements","memo","_1","measureRef","ref","useRef","useRowContext","firstCell","_ref$current","requestAnimationFrame","_ref$current2","clickedElement","contains","includes","tagName","toLowerCase","map","tag","join","original","handleMouseEnter","handleMouseLeave","isDraggedOver","dropTargetProps","useDropTarget","className","cn","onMouseEnter","onMouseLeave","role"],"mappings":";;;;;;;AASA,MAAMA,qBAAqB,GAAG;EAAEC,QAAQ,EAAE;CAAM;SAahCC,GAAGA,CAAkBC,KAAsB;EACvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;EACtC,MAAMC,SAAS,GAAGH,KAAK,CAACI,KAAK,CAACC,OAAO,CAACC,IAAwB;EAC9D,MAAMC,YAAY,GAAGJ,SAAS,CAACK,UAAU,CAACC,eAAe,KAAKT,KAAK,CAACU,KAAK;EACzE,MAAMC,aAAa,GAAGR,SAAS,CAACS,OAAO,CAACC,QAAQ,CAACb,KAAK,CAACc,GAAG,CAACC,EAAE,CAAC;EAC9D,MAAMC,UAAU,GAAGhB,KAAK,CAACU,KAAK,KAAK,CAAC;;EAEpC,MAAM,CAACO,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAGvD,MAAMC,aAAa,GAAIC,KAA0B;IAC7C,IAAIA,KAAK,CAACC,kB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AAE,CAChB,oBAAoB;;;EAGpB,8DAA8D,EAC9D;IACI,sBAAsB,EAAE,OAAOlF,OAAO,KAAK;GAC9C,CACJ;EAED,oBACIxB,sDACQ+D,UAAU,EACTpC,MAAM,GAAG4E,eAAe,GAAGlF,SAAS;IACzCoF,SAAS,EAAEA,SAAS;sBACJlH,KAAK;yBACF+G,aAAa;IAChC9E,OAAO,EAAEE,WAAW;IACpBqD,cAAc,EAAEf,kBAAkB;IAClC2C,YAAY,EAAEP,gBAAgB;IAC9BQ,YAAY,EAAEP,gBAAgB;IAC9BQ,IAAI,EAAC,KAAK;IACVzB,GAAG,EAAEA;KACP;AAEV,CAAC,CAAmE;;;;"}
1
+ {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/rows/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { Row as RTRow, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { RowContext, useRowContext } from './RowContext';\nimport { useDropTarget } from '../../../../utils/hooks/useDropTarget';\nimport { Table3RowClickHandler, Table3RowDropHandler } from '../../types';\nimport { useFocusManager } from '@react-aria/focus';\nimport { focusableSelector } from '../../util/editing';\n\nconst FOCUS_MANAGER_OPTIONS = {\n tabbable: true,\n // Filter out all focusable elelemnts which are not in current row\n accept: (element: Element) => !!element.closest('[role=\"row\"][data-current=\"true\"]'),\n};\n\ntype RowProps<TType = unknown> = Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop'> & {\n index: number;\n isLastRow: boolean;\n measureRef: (el: HTMLElement | null) => void;\n onClick?: Table3RowClickHandler<TType>;\n onDrop?: Table3RowDropHandler<TType>;\n row: RTRow<TType>;\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const focusManager = useFocusManager();\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;\n const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];\n const isFirstRow = props.index === 0;\n // we use non-css hovered state to determine whether to render actions or not, for performance\n const [isHovered, setIsHovered] = React.useState(false);\n\n // tab behaviour is consistent across normal mode and edit mode, handle it here\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped()) {\n return;\n }\n\n if (event.key === 'Tab') {\n tableMeta.hoverState.pause(true);\n let focusedElement: Element;\n\n if (event.shiftKey) {\n // looping backwards\n focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n // override default behaviour, since we're handling focus internally now\n event.preventDefault();\n } else {\n // there are no previous elements to focus, go up a row or go outside the table\n if (!isFirstRow) {\n event.preventDefault();\n tableMeta.currentRow.setCurrentRowIndex(props.index - 1);\n setTimeout(() => focusManager.focusLast(FOCUS_MANAGER_OPTIONS), 1);\n }\n }\n } else {\n // looping forwards\n focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n // override default behaviour, since we're handling focus internally now\n event.preventDefault();\n } else {\n // there are no next elements to focus, go down a row or go outside the table\n if (!props.isLastRow) {\n event.preventDefault();\n tableMeta.currentRow.setCurrentRowIndex(props.index + 1);\n setTimeout(() => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS), 1);\n }\n }\n }\n }\n };\n\n // rows are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the row\n const memoedProps = {\n // aria-grabbed is being deprecated but there is no current alternative api, we use it until there is\n 'aria-grabbed': isDraggingRow ? true : tableMeta.rowDrag.isEnabled ? false : undefined,\n 'data-current': isCurrentRow,\n 'data-selected': props.row.getIsSelected(),\n draggable: tableMeta.rowDrag.isEnabled,\n index: props.index,\n onClick: tableMeta.rowClick.handleClick,\n onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,\n onKeyDown: handleKeyDown,\n };\n\n let output = <MemoedRow<TType> {...props} {...memoedProps} />;\n\n if (tableMeta.editing.isEditing && (isCurrentRow || (isHovered && !tableMeta.hoverState.isPaused))) {\n output = (\n <EditingRow\n {...props}\n {...memoedProps}\n isFirstRow={isFirstRow}\n setCurrentRowIndex={tableMeta.currentRow.setCurrentRowIndex}\n />\n );\n }\n\n // we store the row index in context because in a virtualised table the row index and the\n // react table row index do not match when, for example, sorting is applied\n const contextValue = React.useMemo(() => ({ isHovered, setIsHovered, rowIndex: props.index }), [isHovered, props.index]);\n\n return <RowContext.Provider value={contextValue}>{output}</RowContext.Provider>;\n}\n\n// turns out we might need some kind of \"state\" for the focused column, but it doesn't need to be react state that re-renders\nlet lastIndex;\n\nfunction getColumnIndex(focusedElement: Element) {\n if (focusedElement) {\n return focusedElement.closest('[role=cell]')?.getAttribute('data-column-index');\n }\n\n return null;\n}\n\n// This code is needed to avoid multiple rows being hovered at the same time (it happens since we use non-css hovering)\nlet previouslyHoveredIndex: number | undefined;\nconst unhoverPreviousRow = (tableRef: React.RefObject<HTMLDivElement>) => {\n if (previouslyHoveredIndex !== undefined) {\n const mouseoutEvent = new MouseEvent('mouseout', { view: window, bubbles: true, cancelable: true });\n const previouslyHovered = tableRef?.current?.querySelector(`[data-row-index=\"${previouslyHoveredIndex}\"]`);\n previouslyHovered?.dispatchEvent(mouseoutEvent);\n }\n};\n\nfunction EditingRow(props) {\n const { isFirstRow, isLastRow, onKeyDown, setCurrentRowIndex, virtualiser, ...attributes } = props;\n const focusManager = useFocusManager();\n const tableMeta = props.table.options.meta as TableMeta<unknown>;\n\n const handleClickCapture = (event: React.FocusEvent) => {\n lastIndex = getColumnIndex(event.target);\n };\n\n const handleArrowLeftKey = event => {\n let focusedElement: Element;\n\n if (event.key === 'ArrowLeft') {\n // We need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowLeft\" or \"META + ArrowLeft\" should focus first focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // looping backwards\n focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // there are no previous elements to focus, go up a row (if there are rows above)\n if (!isFirstRow) {\n event.preventDefault();\n tableMeta.hoverState.pause(true);\n tableMeta.currentRow.setCurrentRowIndex(props.index - 1);\n setTimeout(() => {\n focusManager.focusLast(FOCUS_MANAGER_OPTIONS);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n }\n }\n }\n }\n };\n\n const handleArrowRightKey = event => {\n let focusedElement: Element;\n\n if (event.key === 'ArrowRight') {\n // We need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowRight\" or \"META + ArrowRight\" should focus last focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusLast(FOCUS_MANAGER_OPTIONS);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // looping forwards\n focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);\n\n if (focusedElement) {\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // there are no next elements to focus, go down a row or go outside the table\n if (!props.isLastRow) {\n event.preventDefault();\n tableMeta.hoverState.pause(true);\n tableMeta.currentRow.setCurrentRowIndex(props.index + 1);\n setTimeout(() => {\n focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n }\n }\n }\n }\n };\n\n React.useEffect(() => {\n // if some row stuck in hovered state, we heed to unhover it when hover state is paused\n if (tableMeta.hoverState.isPaused) {\n unhoverPreviousRow(props.tableRef);\n }\n }, [tableMeta.hoverState.isPaused]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {\n return;\n }\n\n onKeyDown(event); // handles tab behaviour\n handleArrowLeftKey(event);\n handleArrowRightKey(event);\n };\n\n // this ensures we focus either on a field or on the same column when keyboard navigating up/down\n React.useEffect(() => {\n if (tableMeta.currentRow.currentRowIndex === props.index) {\n if (lastIndex !== undefined) {\n const lastIndexCell = props.tableRef.current?.querySelector(\n `[role=\"row\"][data-current=\"true\"] [data-column-index=\"${lastIndex}\"]`\n );\n lastIndexCell?.querySelector(focusableSelector)?.focus();\n } else {\n focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);\n }\n }\n // Need to subscribe to current row index and check is it a current row,\n // for a situation where hovered row is the next row after current row...\n // In this case row will not be re-rendered if user switch to next row, because hovered row also renders EditingRow.\n }, [tableMeta.currentRow.currentRowIndex]);\n\n return <MemoedRow {...attributes} onClickCapture={handleClickCapture} onKeyDown={handleKeyDown} />;\n}\n\n// Memoization\n\nexport type MemoedRowProps<TType = unknown> = RowProps<TType> & {\n 'aria-grabbed'?: boolean;\n 'data-current': boolean;\n 'data-selected': boolean;\n draggable: boolean;\n index: number;\n};\n\nconst clickableElements = ['input', 'button', 'a', 'select', 'option', 'label', 'textarea'];\n\nconst MemoedRow = React.memo(function MemoedRow<TType = unknown>(props: MemoedRowProps<TType>) {\n const { index, isLastRow: _1, measureRef, onClick, onClickCapture, onDrop, row, table, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { setIsHovered } = useRowContext();\n\n // we measure the first cell (since the row has display: contents) so that the virtualiser height is correct\n React.useEffect(() => {\n const firstCell = ref.current?.querySelector('[role=cell]:first-child');\n\n if (firstCell) {\n measureRef(firstCell as HTMLElement);\n }\n }, [ref.current]);\n\n // we use capture because it also picks up clicks on e.g. select checkboxes\n const handleClickCapture = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (typeof onClickCapture === 'function') {\n onClickCapture(event);\n }\n\n // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable\n requestAnimationFrame(() => tableMeta.currentRow.setCurrentRowIndex(index));\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (typeof onClick === 'function') {\n const clickedElement = event.target as HTMLElement;\n\n if (\n !ref.current?.contains(event.target as HTMLElement) ||\n clickableElements.includes(clickedElement.tagName.toLowerCase()) ||\n clickedElement.closest(clickableElements.map(tag => `[role=row] ${tag}`).join(','))\n ) {\n return;\n }\n\n onClick(row.original);\n }\n };\n\n const handleMouseEnter = () => {\n // When user moving mouse to fast, then some of the rows are getting stuck in hover state,\n // because mouseleave event never got triggered, to avoid this to happen we're saving the index of last hovered row,\n // so that we can unhover it when new row got hovered, and saving it in a variable outside of react to save in performance,\n // since it would be very performance heavy to use state which is bound to mouse events.\n if (previouslyHoveredIndex !== undefined) {\n if (previouslyHoveredIndex !== index) {\n unhoverPreviousRow(tableRef);\n previouslyHoveredIndex = index;\n }\n } else {\n previouslyHoveredIndex = index;\n }\n setIsHovered(true);\n };\n const handleMouseLeave = () => {\n if (previouslyHoveredIndex === index) {\n previouslyHoveredIndex = undefined;\n }\n setIsHovered(false);\n };\n\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => onDrop?.(event, row.original));\n\n const className = cn(\n 'group/row contents',\n // resizing column requires dragging, which means the mouse might (on rare occasions) move over rows and trigger hover state\n // that in turn triggers rendering of e.g. row actions, which could cause janky ui - so don't allow mouse interaction when resizing\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n {\n 'hover:cursor-pointer': typeof onClick === 'function',\n }\n );\n\n return (\n <div\n {...attributes}\n {...(onDrop ? dropTargetProps : undefined)}\n className={className}\n data-row-index={index}\n data-dragged-over={isDraggedOver}\n onClick={handleClick}\n onClickCapture={handleClickCapture}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n role=\"row\"\n ref={ref}\n />\n );\n}) as <TType = unknown>(props: MemoedRowProps<TType>) => JSX.Element;\n"],"names":["FOCUS_MANAGER_OPTIONS","tabbable","accept","element","closest","Row","props","focusManager","useFocusManager","tableMeta","table","options","meta","isCurrentRow","currentRow","currentRowIndex","index","isDraggingRow","rowDrag","dragging","row","id","isFirstRow","isHovered","setIsHovered","React","useState","handleKeyDown","event","isDefaultPrevented","isPropagationStopped","key","hoverState","pause","focusedElement","shiftKey","focusPrevious","preventDefault","setCurrentRowIndex","setTimeout","focusLast","focusNext","isLastRow","focusFirst","memoedProps","isEnabled","undefined","getIsSelected","draggable","onClick","rowClick","handleClick","onDrop","rowDrop","handleDrop","onKeyDown","output","MemoedRow","editing","isEditing","isPaused","EditingRow","contextValue","useMemo","rowIndex","RowContext","Provider","value","lastIndex","getColumnIndex","_focusedElement$close","getAttribute","previouslyHoveredIndex","unhoverPreviousRow","tableRef","_tableRef$current","mouseoutEvent","MouseEvent","view","window","bubbles","cancelable","previouslyHovered","current","querySelector","dispatchEvent","virtualiser","attributes","handleClickCapture","target","handleArrowLeftKey","stopPropagation","ctrlKey","metaKey","blur","handleArrowRightKey","useEffect","detailModeEditing","_props$tableRef$curre","_lastIndexCell$queryS","lastIndexCell","focusableSelector","focus","onClickCapture","clickableElements","memo","_1","measureRef","ref","useRef","useRowContext","firstCell","_ref$current","requestAnimationFrame","_ref$current2","clickedElement","contains","includes","tagName","toLowerCase","map","tag","join","original","handleMouseEnter","handleMouseLeave","isDraggedOver","dropTargetProps","useDropTarget","className","cn","onMouseEnter","onMouseLeave","role"],"mappings":";;;;;;;AASA,MAAMA,qBAAqB,GAAG;EAC1BC,QAAQ,EAAE,IAAI;;EAEdC,MAAM,EAAGC,OAAgB,IAAK,CAAC,CAACA,OAAO,CAACC,OAAO,CAAC,mCAAmC;CACtF;SAaeC,GAAGA,CAAkBC,KAAsB;EACvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;EACtC,MAAMC,SAAS,GAAGH,KAAK,CAACI,KAAK,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,GAAGxD,KAAK;;KAErC,MAAM;MACHwD,sBAAsB,GAAGxD,KAAK;;IAElCQ,YAAY,CAAC,IAAI,CAAC;GACrB;EACD,MAAMqG,gBAAgB,GAAGA;IACrB,IAAIrD,sBAAsB,KAAKxD,KAAK,EAAE;MAClCwD,sBAAsB,GAAG1B,SAAS;;IAEtCtB,YAAY,CAAC,KAAK,CAAC;GACtB;EAED,MAAM,CAACsG,aAAa,EAAEC,eAAe,CAAC,GAAGC,aAAa,CAACpG,KAAK,IAAIwB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAGxB,KAAK,EAAER,GAAG,CAACuG,QAAQ,CAAC,CAAC;EAE9F,MAAMM,SAAS,GAAGC,EAAE,CAChB,oBAAoB;;;EAGpB,8DAA8D,EAC9D;IACI,sBAAsB,EAAE,OAAOjF,OAAO,KAAK;GAC9C,CACJ;EAED,oBACIxB,sDACQ8D,UAAU,EACTnC,MAAM,GAAG2E,eAAe,GAAGjF,SAAS;IACzCmF,SAAS,EAAEA,SAAS;sBACJjH,KAAK;yBACF8G,aAAa;IAChC7E,OAAO,EAAEE,WAAW;IACpBoD,cAAc,EAAEf,kBAAkB;IAClC2C,YAAY,EAAEP,gBAAgB;IAC9BQ,YAAY,EAAEP,gBAAgB;IAC9BQ,IAAI,EAAC,KAAK;IACVzB,GAAG,EAAEA;KACP;AAEV,CAAC,CAAmE;;;;"}
@@ -24,7 +24,8 @@ const PRINT_STYLES = `
24
24
  overflow-y: hidden !important;
25
25
  }
26
26
 
27
- [role="table"] [role="columnheader"] {
27
+ // all column headers except column group column header
28
+ [role="table"] [role="columnheader"]:not([data-taco='table3-column-group']) {
28
29
  border-bottom-width: 1px !important;
29
30
  }
30
31