@vuu-ui/vuu-table 0.8.99 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/cjs/Table.js +2 -2
  2. package/cjs/Table.js.map +1 -1
  3. package/cjs/table-dom-utils.js +42 -13
  4. package/cjs/table-dom-utils.js.map +1 -1
  5. package/cjs/table-header/TableHeader.js +105 -66
  6. package/cjs/table-header/TableHeader.js.map +1 -1
  7. package/cjs/table-header/useTableHeader.js +9 -1
  8. package/cjs/table-header/useTableHeader.js.map +1 -1
  9. package/cjs/useCellFocus.js +3 -3
  10. package/cjs/useCellFocus.js.map +1 -1
  11. package/cjs/useKeyboardNavigation.js +21 -21
  12. package/cjs/useKeyboardNavigation.js.map +1 -1
  13. package/cjs/useSelection.js +2 -1
  14. package/cjs/useSelection.js.map +1 -1
  15. package/cjs/useTable.js +21 -7
  16. package/cjs/useTable.js.map +1 -1
  17. package/cjs/useTableScroll.js +2 -2
  18. package/cjs/useTableScroll.js.map +1 -1
  19. package/esm/Table.js +2 -2
  20. package/esm/Table.js.map +1 -1
  21. package/esm/table-dom-utils.js +39 -14
  22. package/esm/table-dom-utils.js.map +1 -1
  23. package/esm/table-header/TableHeader.js +106 -67
  24. package/esm/table-header/TableHeader.js.map +1 -1
  25. package/esm/table-header/useTableHeader.js +9 -1
  26. package/esm/table-header/useTableHeader.js.map +1 -1
  27. package/esm/useCellFocus.js +3 -3
  28. package/esm/useCellFocus.js.map +1 -1
  29. package/esm/useKeyboardNavigation.js +22 -22
  30. package/esm/useKeyboardNavigation.js.map +1 -1
  31. package/esm/useSelection.js +3 -2
  32. package/esm/useSelection.js.map +1 -1
  33. package/esm/useTable.js +21 -7
  34. package/esm/useTable.js.map +1 -1
  35. package/esm/useTableScroll.js +4 -4
  36. package/esm/useTableScroll.js.map +1 -1
  37. package/package.json +9 -9
  38. package/types/table-dom-utils.d.ts +5 -1
  39. package/types/table-header/TableHeader.d.ts +1 -1
  40. package/types/table-header/useTableHeader.d.ts +5 -3
  41. package/types/useKeyboardNavigation.d.ts +2 -1
  42. package/types/useTable.d.ts +7 -2
package/cjs/Table.js CHANGED
@@ -62,7 +62,7 @@ const TableCore = ({
62
62
  focusCellPlaceholderRef,
63
63
  getRowOffset,
64
64
  handleContextMenuAction,
65
- headerHeight,
65
+ headerState: { height: headerHeight, count: headerCount },
66
66
  headings,
67
67
  highlightedIndex,
68
68
  menuBuilder,
@@ -183,7 +183,7 @@ const TableCore = ({
183
183
  data.map((data2) => /* @__PURE__ */ jsxRuntime.jsx(
184
184
  Row$1,
185
185
  {
186
- "aria-rowindex": data2[0] + 1,
186
+ "aria-rowindex": data2[0] + headerCount + 1,
187
187
  classNameGenerator: rowClassNameGenerator,
188
188
  columnMap,
189
189
  columns: scrollProps.columnsWithinViewport,
package/cjs/Table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../src/Table.tsx"],"sourcesContent":["import {\n DataSource,\n SchemaColumn,\n SelectionChangeHandler,\n} from \"@vuu-ui/vuu-data-types\";\nimport { ContextMenuProvider } from \"@vuu-ui/vuu-popups\";\nimport {\n CustomHeader,\n RowProps,\n TableConfig,\n TableConfigChangeHandler,\n TableRowClickHandler,\n TableRowSelectHandler,\n TableSelectionModel,\n} from \"@vuu-ui/vuu-table-types\";\nimport type { DragDropState } from \"@vuu-ui/vuu-ui-controls\";\nimport {\n DragStartHandler,\n MeasuredContainer,\n MeasuredContainerProps,\n MeasuredSize,\n dragStrategy,\n reduceSizeHeight,\n} from \"@vuu-ui/vuu-ui-controls\";\nimport { metadataKeys, useId } from \"@vuu-ui/vuu-utils\";\nimport { useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport {\n CSSProperties,\n FC,\n ForwardedRef,\n RefObject,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Row as DefaultRow, RowProxy } from \"./Row\";\nimport { PaginationControl } from \"./pagination\";\nimport { TableHeader } from \"./table-header\";\nimport { useMeasuredHeight } from \"./useMeasuredHeight\";\nimport { useTable } from \"./useTable\";\nimport { ScrollingAPI } from \"./useTableScroll\";\n\nimport tableCss from \"./Table.css\";\nimport { TableCellBlock } from \"./cell-block/cellblock-utils\";\n\nconst classBase = \"vuuTable\";\n\nconst { IDX, RENDER_IDX } = metadataKeys;\n\nexport type TableNavigationStyle = \"none\" | \"cell\" | \"row\";\n\nexport interface TableProps\n extends Omit<MeasuredContainerProps, \"onDragStart\" | \"onDrop\" | \"onSelect\"> {\n Row?: FC<RowProps>;\n /**\n * Allow a block of cells to be selected. Typically to be copied.\n */\n allowCellBlockSelection?: boolean;\n allowConfigEditing?: boolean;\n /**\n * Allow column headers to be dragged to re-arrange\n */\n allowDragColumnHeader?: boolean;\n /**\n * Allow rows to be draggable\n */\n allowDragDrop?: boolean | dragStrategy;\n\n /**\n * required if a fully featured column picker is to be available\n */\n availableColumns?: SchemaColumn[];\n /**\n * Provide configuration settings for Table. At minimun, column\n * descriptors must be provided.\n */\n config: TableConfig;\n dataSource: DataSource;\n disableFocus?: boolean;\n /**\n * Allows additional custom element(s) to be embedded immediately below column headers.\n * Could be used to present inline filters for example.\n * Accepts either a React Element or a Function Component or an array of these. If a React\n * Function Component is used, it will be passed the props described in BaseRowProps.\n */\n customHeader?: CustomHeader | CustomHeader[];\n /**\n * Defined how focus navigation within data cells will be handled by table.\n * Default is cell.\n */\n highlightedIndex?: number;\n\n /**\n * Behaves in most respects like viewportRowLimit except that, when there are fewer\n * rows available than the limit set here, the Table height will reduce. This can be\n * useful where a Table is used in a dropdown control.\n */\n maxViewportRowLimit?: number;\n\n /**\n * Determines bahaviour of keyboard navigation , either row focused or cell focused.\n */\n navigationStyle?: TableNavigationStyle;\n /**\n * required if a fully featured column picker is to be available.\n * Available columns can be changed by the addition or removal of\n * one or more calculated columns.\n */\n onAvailableColumnsChange?: (columns: SchemaColumn[]) => void;\n /**\n * This callback will be invoked any time a config attribute of TableConfig\n * is changed. By persisting this value and providing it to the Table as a\n * prop, table state can be persisted across sessions.\n */\n onConfigChange?: TableConfigChangeHandler;\n onDragStart?: DragStartHandler;\n onDrop?: (dragDropState: DragDropState) => void;\n\n onHighlight?: (idx: number) => void;\n /**\n * callback invoked when user 'clicks' a table row. CLick triggered either\n * via mouse click or keyboard (default ENTER);\n */\n onRowClick?: TableRowClickHandler;\n onSelect?: TableRowSelectHandler;\n /**\n * Triggered when a block of cells is selected. CellBlock selection can be\n * effected with either mouse or keyboard.\n * - mouse: hold down mouse and drag over selection area\n * - keyboard: press and hold shift key from start cell, then use arrow keys\n * to extend selection block.\n *\n * This callback is invoked when mouse is released or shift key released.\n */\n onSelectCellBlock?: (cellBlock: TableCellBlock) => void;\n\n onSelectionChange?: SelectionChangeHandler;\n renderBufferSize?: number;\n /**\n * Pixel height of rows. If specified here, this will take precedence over CSS\n * values and Table will not respond to density changes.\n */\n rowHeight?: number;\n /**\n * imperative API for scrolling table\n */\n scrollingApiRef?: ForwardedRef<ScrollingAPI>;\n\n /**\n * Selection Bookends style the left and right edge of a selection block.\n * They are optional, value defaults to zero.\n * TODO this should just live in CSS\n */\n selectionBookendWidth?: number;\n /**\n * Selection behaviour for Table:\n * `none` selection disabled\n * `single` no more than one row may be selected\n * `extended` (default) multiple rows can be selected\n * `checkbox` same behaviour as extended, with checkbox column for selection\n */\n selectionModel?: TableSelectionModel;\n /**\n * if false, table rendered without headers. Useful when table is being included in a\n * composite component.\n */\n showColumnHeaders?: boolean;\n /**\n * if false, column headers will not display menu icon. Menu items are still available\n * from contexct menu\n */\n showColumnHeaderMenus?: boolean;\n /**\n * if true, pagination will be used to navigate data, scrollbars will not be rendered\n */\n showPaginationControls?: boolean;\n\n /**\n * As an alternative to sizing the Table height via CSS or via an explicit height value,\n * specify the number of rows to be displayed within the Viewport. The actual height\n * will then be the product of viewportRowLimit and rowHeight. Row Height will be\n * determined in the usual way, it can be specified explicitly in a prop or set via\n * CSS. If both explicit height and viewportRowLimit are provided by props, rowHeight\n * will be derived from these. Do not pass props for all three values - height,\n * rowHeight and viewportRowLimit. That will be rejected.\n * Use maxViewportRowLimit rather than viewportRowLimit if the height of the table\n * should be reduced when fewer rows are actually available than the limit specified.\n */\n viewportRowLimit?: number;\n}\n\nconst TableCore = ({\n Row = DefaultRow,\n allowCellBlockSelection,\n allowDragColumnHeader = true,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\n disableFocus = false,\n highlightedIndex: highlightedIndexProp,\n id: idProp,\n navigationStyle = \"cell\",\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize = 0,\n rowHeight,\n scrollingApiRef,\n selectionModel = \"extended\",\n showColumnHeaders = true,\n showColumnHeaderMenus = true,\n showPaginationControls,\n size,\n}: Omit<\n TableProps,\n \"maxViewportRowLimit\" | \"rowHeight\" | \"viewportRowLimit\"\n> & {\n containerRef: RefObject<HTMLDivElement>;\n rowHeight: number;\n size: MeasuredSize;\n}) => {\n const id = useId(idProp);\n const {\n cellBlock,\n columnMap,\n columns,\n data,\n draggableRow,\n focusCellPlaceholderKeyDown,\n focusCellPlaceholderRef,\n getRowOffset,\n handleContextMenuAction,\n headerHeight,\n headings,\n highlightedIndex,\n menuBuilder,\n onDataEdited,\n onHeaderHeightMeasured,\n onMoveColumn,\n onMoveGroupColumn,\n onRemoveGroupColumn,\n onResizeColumn,\n onRowClick,\n onSortColumn,\n onToggleGroup,\n rowClassNameGenerator,\n scrollProps,\n tableAttributes,\n tableBodyRef,\n tableConfig,\n viewportMeasurements,\n ...tableProps\n } = useTable({\n allowCellBlockSelection,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n dataSource,\n disableFocus,\n highlightedIndex: highlightedIndexProp,\n id,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n rowHeight,\n scrollingApiRef,\n selectionModel,\n showColumnHeaders,\n showPaginationControls,\n size,\n });\n\n const contentContainerClassName = cx(`${classBase}-contentContainer`, {\n [`${classBase}-colLines`]: tableAttributes.columnSeparators,\n [`${classBase}-rowLines`]: tableAttributes.rowSeparators,\n [`${classBase}-zebra`]: tableAttributes.zebraStripes,\n });\n\n const cssScrollbarSize = {\n \"--horizontal-scrollbar-height\": `${viewportMeasurements.horizontalScrollbarHeight}px`,\n \"--vertical-scrollbar-width\": `${viewportMeasurements.verticalScrollbarWidth}px`,\n } as CSSProperties;\n\n const cssVariables = {\n ...cssScrollbarSize,\n \"--content-height\": `${viewportMeasurements.contentHeight}px`,\n \"--content-width\": `${viewportMeasurements.contentWidth}px`,\n \"--pinned-width-left\": `${viewportMeasurements.pinnedWidthLeft}px`,\n \"--pinned-width-right\": `${viewportMeasurements.pinnedWidthRight}px`,\n \"--total-header-height\": `${headerHeight}px`,\n \"--viewport-body-height\": `${viewportMeasurements.viewportBodyHeight}px`,\n } as CSSProperties;\n\n const headersReady = showColumnHeaders === false || headerHeight > 0;\n const readyToRenderTableBody = headersReady && data.length > 0;\n\n return (\n <ContextMenuProvider\n menuActionHandler={handleContextMenuAction}\n menuBuilder={menuBuilder}\n >\n {showPaginationControls !== true ? (\n <div\n className={`${classBase}-scrollbarContainer`}\n ref={scrollProps.scrollbarContainerRef}\n style={cssVariables}\n tabIndex={-1}\n >\n <div className={`${classBase}-scrollbarContent`} />\n </div>\n ) : null}\n <div\n className={contentContainerClassName}\n ref={scrollProps.contentContainerRef}\n style={cssVariables}\n >\n <div\n {...tableProps}\n className={`${classBase}-table`}\n role=\"table\"\n tabIndex={disableFocus ? undefined : -1}\n >\n {showColumnHeaders ? (\n <TableHeader\n allowDragColumnHeader={allowDragColumnHeader}\n columns={scrollProps.columnsWithinViewport}\n customHeader={customHeader}\n headings={headings}\n onHeightMeasured={onHeaderHeightMeasured}\n onMoveColumn={onMoveColumn}\n onMoveGroupColumn={onMoveGroupColumn}\n onRemoveGroupColumn={onRemoveGroupColumn}\n onResizeColumn={onResizeColumn}\n onSortColumn={onSortColumn}\n showColumnHeaderMenus={showColumnHeaderMenus}\n tableConfig={tableConfig}\n tableId={id}\n virtualColSpan={scrollProps.virtualColSpan}\n />\n ) : null}\n {readyToRenderTableBody ? (\n <div className={`${classBase}-body`} ref={tableBodyRef}>\n {data.map((data) => (\n <Row\n aria-rowindex={data[0] + 1}\n classNameGenerator={rowClassNameGenerator}\n columnMap={columnMap}\n columns={scrollProps.columnsWithinViewport}\n highlighted={highlightedIndex === data[IDX]}\n key={data[RENDER_IDX]}\n onClick={onRowClick}\n onDataEdited={onDataEdited}\n row={data}\n offset={showPaginationControls ? 0 : getRowOffset(data)}\n onToggleGroup={onToggleGroup}\n virtualColSpan={scrollProps.virtualColSpan}\n zebraStripes={tableAttributes.zebraStripes}\n />\n ))}\n {/* \n The focusCellPlaceholder allows us to deal with the situation where a cell \n that has focus is scrolled out of the viewport. That cell, along with the \n containing row, will be recycled to render another DataRow. The html table \n cell must not retain focus once it is re-used but we need to track the \n original focus, in case user uses arrow key to resume navigation. \n The placeholder is fixed in place at the location where the focused cell \n was last rendered. It assumes focus. If we get an arrowkey mousedown event \n on the placeholder, the user has resumed navigation whilst the focused cell \n is offscreen. We scroll back to the focus location and pass focus back to \n the correct target cell.\n */}\n <div\n className={`${classBase}-focusCellPlaceholder`}\n onKeyDown={focusCellPlaceholderKeyDown}\n ref={focusCellPlaceholderRef}\n tabIndex={-1}\n />\n\n {cellBlock}\n </div>\n ) : null}\n </div>\n </div>\n {/* \n This keeps the heights of content container and scrollbar container aligned for\n cases where we rely on height: fit-content. (ScrollbarContainer isn't taken into \n account because its absolutely positioned).\n */}\n <div\n className={`${classBase}-scrollbarFiller`}\n style={cssScrollbarSize}\n />\n {draggableRow}\n </ContextMenuProvider>\n );\n};\n\nexport const Table = forwardRef(function Table(\n {\n Row,\n allowCellBlockSelection,\n allowDragColumnHeader,\n allowDragDrop,\n availableColumns,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\n disableFocus,\n height,\n highlightedIndex,\n id,\n maxViewportRowLimit,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n rowHeight: rowHeightProp,\n scrollingApiRef,\n selectionModel,\n showColumnHeaders,\n showColumnHeaderMenus,\n showPaginationControls,\n style: styleProp,\n viewportRowLimit,\n width,\n ...htmlAttributes\n }: TableProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table\",\n css: tableCss,\n window: targetWindow,\n });\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [size, _setSize] = useState<MeasuredSize>();\n // TODO this will rerender entire table, move footer into seperate component\n const { measuredHeight: rowHeight, measuredRef: rowRef } = useMeasuredHeight({\n height: rowHeightProp,\n });\n const { measuredHeight: footerHeight, measuredRef: footerRef } =\n useMeasuredHeight({});\n\n const rowLimit = maxViewportRowLimit ?? viewportRowLimit;\n\n if (config === undefined) {\n throw Error(\n \"vuu Table requires config prop. Minimum config is list of Column Descriptors\",\n );\n }\n if (dataSource === undefined) {\n throw Error(\"vuu Table requires dataSource prop\");\n }\n\n if (showPaginationControls && renderBufferSize !== undefined) {\n console.warn(\n `Table: When pagination controls are used, renderBufferSize is ignored`,\n );\n }\n\n if (rowLimit && height && rowHeightProp) {\n console.warn(\n `Table: when viewportRowLimit, rowHeight and height are used in combination, height is ignored`,\n );\n height = rowLimit * rowHeightProp;\n } else if (rowLimit && rowHeightProp) {\n height = rowLimit * rowHeightProp;\n } else if (rowLimit) {\n height = rowLimit * rowHeight;\n }\n\n const sizeRef = useRef<MeasuredSize>();\n const setSize = useCallback(\n (size: MeasuredSize) => {\n if (viewportRowLimit && !rowHeight) {\n sizeRef.current = size;\n } else if (\n size.height !== sizeRef.current?.height ||\n size.width !== sizeRef.current?.width\n ) {\n _setSize(size);\n }\n },\n [rowHeight, viewportRowLimit],\n );\n useMemo(() => {\n if (sizeRef.current && rowHeight) {\n const size = {\n ...sizeRef.current,\n height: rowHeight * (viewportRowLimit as number),\n };\n sizeRef.current = size;\n _setSize(size);\n }\n }, [rowHeight, viewportRowLimit]);\n\n // TODO render TableHeader here and measure before row construction begins\n // TODO we could have MeasuredContainer render a Provider and make size available via a context hook ?\n return (\n <MeasuredContainer\n {...htmlAttributes}\n className={cx(classBase, classNameProp, {\n [`${classBase}-pagination`]: showPaginationControls,\n [`${classBase}-maxViewportRowLimit`]: maxViewportRowLimit,\n [`${classBase}-viewportRowLimit`]: viewportRowLimit,\n })}\n height={height}\n id={id}\n onResize={setSize}\n ref={useForkRef(containerRef, forwardedRef)}\n style={\n {\n \"--row-height-prop\": rowHeight > 0 ? `${rowHeight}px` : undefined,\n } as CSSProperties\n }\n width={width}\n >\n <RowProxy ref={rowRef} height={rowHeightProp} />\n {size &&\n rowHeight &&\n (footerHeight || showPaginationControls !== true) ? (\n <TableCore\n Row={Row}\n allowCellBlockSelection={allowCellBlockSelection}\n allowDragColumnHeader={allowDragColumnHeader}\n allowDragDrop={allowDragDrop}\n availableColumns={availableColumns}\n config={config}\n containerRef={containerRef}\n customHeader={customHeader}\n dataSource={dataSource}\n disableFocus={disableFocus}\n highlightedIndex={highlightedIndex}\n id={id}\n navigationStyle={navigationStyle}\n onAvailableColumnsChange={onAvailableColumnsChange}\n onConfigChange={onConfigChange}\n onDragStart={onDragStart}\n onDrop={onDrop}\n onHighlight={onHighlight}\n onRowClick={onRowClick}\n onSelect={onSelect}\n onSelectCellBlock={onSelectCellBlock}\n onSelectionChange={onSelectionChange}\n renderBufferSize={\n showPaginationControls ? 0 : Math.max(5, renderBufferSize ?? 0)\n }\n rowHeight={rowHeight}\n scrollingApiRef={scrollingApiRef}\n selectionModel={selectionModel}\n showColumnHeaders={showColumnHeaders}\n showColumnHeaderMenus={showColumnHeaderMenus}\n showPaginationControls={showPaginationControls}\n size={reduceSizeHeight(size, footerHeight)}\n />\n ) : null}\n {showPaginationControls ? (\n <div className={`${classBase}-footer`} ref={footerRef}>\n <PaginationControl dataSource={dataSource} />\n </div>\n ) : null}\n </MeasuredContainer>\n );\n});\n"],"names":["metadataKeys","Row","DefaultRow","useId","useTable","jsxs","ContextMenuProvider","jsx","TableHeader","data","forwardRef","Table","useWindow","useComponentCssInjection","tableCss","useRef","useState","useMeasuredHeight","useCallback","size","useMemo","MeasuredContainer","useForkRef","RowProxy","reduceSizeHeight","PaginationControl"],"mappings":";;;;;;;;;;;;;;;;;;;AAkDA,MAAM,SAAY,GAAA,UAAA,CAAA;AAElB,MAAM,EAAE,GAAK,EAAA,UAAA,EAAe,GAAAA,qBAAA,CAAA;AAgJ5B,MAAM,YAAY,CAAC;AAAA,OACjBC,KAAM,GAAAC,OAAA;AAAA,EACN,uBAAA;AAAA,EACA,qBAAwB,GAAA,IAAA;AAAA,EACxB,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAe,GAAA,KAAA;AAAA,EACf,gBAAkB,EAAA,oBAAA;AAAA,EAClB,EAAI,EAAA,MAAA;AAAA,EACJ,eAAkB,GAAA,MAAA;AAAA,EAClB,wBAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAY,EAAA,cAAA;AAAA,EACZ,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAmB,GAAA,CAAA;AAAA,EACnB,SAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAiB,GAAA,UAAA;AAAA,EACjB,iBAAoB,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GAAA,IAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GACN,CAAA;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["../src/Table.tsx"],"sourcesContent":["import {\n DataSource,\n SchemaColumn,\n SelectionChangeHandler,\n} from \"@vuu-ui/vuu-data-types\";\nimport { ContextMenuProvider } from \"@vuu-ui/vuu-popups\";\nimport {\n CustomHeader,\n RowProps,\n TableConfig,\n TableConfigChangeHandler,\n TableRowClickHandler,\n TableRowSelectHandler,\n TableSelectionModel,\n} from \"@vuu-ui/vuu-table-types\";\nimport type { DragDropState } from \"@vuu-ui/vuu-ui-controls\";\nimport {\n DragStartHandler,\n MeasuredContainer,\n MeasuredContainerProps,\n MeasuredSize,\n dragStrategy,\n reduceSizeHeight,\n} from \"@vuu-ui/vuu-ui-controls\";\nimport { metadataKeys, useId } from \"@vuu-ui/vuu-utils\";\nimport { useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport {\n CSSProperties,\n FC,\n ForwardedRef,\n RefObject,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Row as DefaultRow, RowProxy } from \"./Row\";\nimport { PaginationControl } from \"./pagination\";\nimport { TableHeader } from \"./table-header\";\nimport { useMeasuredHeight } from \"./useMeasuredHeight\";\nimport { useTable } from \"./useTable\";\nimport { ScrollingAPI } from \"./useTableScroll\";\n\nimport tableCss from \"./Table.css\";\nimport { TableCellBlock } from \"./cell-block/cellblock-utils\";\n\nconst classBase = \"vuuTable\";\n\nconst { IDX, RENDER_IDX } = metadataKeys;\n\nexport type TableNavigationStyle = \"none\" | \"cell\" | \"row\";\n\nexport interface TableProps\n extends Omit<MeasuredContainerProps, \"onDragStart\" | \"onDrop\" | \"onSelect\"> {\n Row?: FC<RowProps>;\n /**\n * Allow a block of cells to be selected. Typically to be copied.\n */\n allowCellBlockSelection?: boolean;\n allowConfigEditing?: boolean;\n /**\n * Allow column headers to be dragged to re-arrange\n */\n allowDragColumnHeader?: boolean;\n /**\n * Allow rows to be draggable\n */\n allowDragDrop?: boolean | dragStrategy;\n\n /**\n * required if a fully featured column picker is to be available\n */\n availableColumns?: SchemaColumn[];\n /**\n * Provide configuration settings for Table. At minimun, column\n * descriptors must be provided.\n */\n config: TableConfig;\n dataSource: DataSource;\n disableFocus?: boolean;\n /**\n * Allows additional custom element(s) to be embedded immediately below column headers.\n * Could be used to present inline filters for example.\n * Accepts either a React Element or a Function Component or an array of these. If a React\n * Function Component is used, it will be passed the props described in BaseRowProps.\n */\n customHeader?: CustomHeader | CustomHeader[];\n /**\n * Defined how focus navigation within data cells will be handled by table.\n * Default is cell.\n */\n highlightedIndex?: number;\n\n /**\n * Behaves in most respects like viewportRowLimit except that, when there are fewer\n * rows available than the limit set here, the Table height will reduce. This can be\n * useful where a Table is used in a dropdown control.\n */\n maxViewportRowLimit?: number;\n\n /**\n * Determines bahaviour of keyboard navigation , either row focused or cell focused.\n */\n navigationStyle?: TableNavigationStyle;\n /**\n * required if a fully featured column picker is to be available.\n * Available columns can be changed by the addition or removal of\n * one or more calculated columns.\n */\n onAvailableColumnsChange?: (columns: SchemaColumn[]) => void;\n /**\n * This callback will be invoked any time a config attribute of TableConfig\n * is changed. By persisting this value and providing it to the Table as a\n * prop, table state can be persisted across sessions.\n */\n onConfigChange?: TableConfigChangeHandler;\n onDragStart?: DragStartHandler;\n onDrop?: (dragDropState: DragDropState) => void;\n\n onHighlight?: (idx: number) => void;\n /**\n * callback invoked when user 'clicks' a table row. CLick triggered either\n * via mouse click or keyboard (default ENTER);\n */\n onRowClick?: TableRowClickHandler;\n onSelect?: TableRowSelectHandler;\n /**\n * Triggered when a block of cells is selected. CellBlock selection can be\n * effected with either mouse or keyboard.\n * - mouse: hold down mouse and drag over selection area\n * - keyboard: press and hold shift key from start cell, then use arrow keys\n * to extend selection block.\n *\n * This callback is invoked when mouse is released or shift key released.\n */\n onSelectCellBlock?: (cellBlock: TableCellBlock) => void;\n\n onSelectionChange?: SelectionChangeHandler;\n renderBufferSize?: number;\n /**\n * Pixel height of rows. If specified here, this will take precedence over CSS\n * values and Table will not respond to density changes.\n */\n rowHeight?: number;\n /**\n * imperative API for scrolling table\n */\n scrollingApiRef?: ForwardedRef<ScrollingAPI>;\n\n /**\n * Selection Bookends style the left and right edge of a selection block.\n * They are optional, value defaults to zero.\n * TODO this should just live in CSS\n */\n selectionBookendWidth?: number;\n /**\n * Selection behaviour for Table:\n * `none` selection disabled\n * `single` no more than one row may be selected\n * `extended` (default) multiple rows can be selected\n * `checkbox` same behaviour as extended, with checkbox column for selection\n */\n selectionModel?: TableSelectionModel;\n /**\n * if false, table rendered without headers. Useful when table is being included in a\n * composite component.\n */\n showColumnHeaders?: boolean;\n /**\n * if false, column headers will not display menu icon. Menu items are still available\n * from contexct menu\n */\n showColumnHeaderMenus?: boolean;\n /**\n * if true, pagination will be used to navigate data, scrollbars will not be rendered\n */\n showPaginationControls?: boolean;\n\n /**\n * As an alternative to sizing the Table height via CSS or via an explicit height value,\n * specify the number of rows to be displayed within the Viewport. The actual height\n * will then be the product of viewportRowLimit and rowHeight. Row Height will be\n * determined in the usual way, it can be specified explicitly in a prop or set via\n * CSS. If both explicit height and viewportRowLimit are provided by props, rowHeight\n * will be derived from these. Do not pass props for all three values - height,\n * rowHeight and viewportRowLimit. That will be rejected.\n * Use maxViewportRowLimit rather than viewportRowLimit if the height of the table\n * should be reduced when fewer rows are actually available than the limit specified.\n */\n viewportRowLimit?: number;\n}\n\nconst TableCore = ({\n Row = DefaultRow,\n allowCellBlockSelection,\n allowDragColumnHeader = true,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\n disableFocus = false,\n highlightedIndex: highlightedIndexProp,\n id: idProp,\n navigationStyle = \"cell\",\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize = 0,\n rowHeight,\n scrollingApiRef,\n selectionModel = \"extended\",\n showColumnHeaders = true,\n showColumnHeaderMenus = true,\n showPaginationControls,\n size,\n}: Omit<\n TableProps,\n \"maxViewportRowLimit\" | \"rowHeight\" | \"viewportRowLimit\"\n> & {\n containerRef: RefObject<HTMLDivElement>;\n rowHeight: number;\n size: MeasuredSize;\n}) => {\n const id = useId(idProp);\n const {\n cellBlock,\n columnMap,\n columns,\n data,\n draggableRow,\n focusCellPlaceholderKeyDown,\n focusCellPlaceholderRef,\n getRowOffset,\n handleContextMenuAction,\n headerState: { height: headerHeight, count: headerCount },\n headings,\n highlightedIndex,\n menuBuilder,\n onDataEdited,\n onHeaderHeightMeasured,\n onMoveColumn,\n onMoveGroupColumn,\n onRemoveGroupColumn,\n onResizeColumn,\n onRowClick,\n onSortColumn,\n onToggleGroup,\n rowClassNameGenerator,\n scrollProps,\n tableAttributes,\n tableBodyRef,\n tableConfig,\n viewportMeasurements,\n ...tableProps\n } = useTable({\n allowCellBlockSelection,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n dataSource,\n disableFocus,\n highlightedIndex: highlightedIndexProp,\n id,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n rowHeight,\n scrollingApiRef,\n selectionModel,\n showColumnHeaders,\n showPaginationControls,\n size,\n });\n\n const contentContainerClassName = cx(`${classBase}-contentContainer`, {\n [`${classBase}-colLines`]: tableAttributes.columnSeparators,\n [`${classBase}-rowLines`]: tableAttributes.rowSeparators,\n [`${classBase}-zebra`]: tableAttributes.zebraStripes,\n });\n\n const cssScrollbarSize = {\n \"--horizontal-scrollbar-height\": `${viewportMeasurements.horizontalScrollbarHeight}px`,\n \"--vertical-scrollbar-width\": `${viewportMeasurements.verticalScrollbarWidth}px`,\n } as CSSProperties;\n\n const cssVariables = {\n ...cssScrollbarSize,\n \"--content-height\": `${viewportMeasurements.contentHeight}px`,\n \"--content-width\": `${viewportMeasurements.contentWidth}px`,\n \"--pinned-width-left\": `${viewportMeasurements.pinnedWidthLeft}px`,\n \"--pinned-width-right\": `${viewportMeasurements.pinnedWidthRight}px`,\n \"--total-header-height\": `${headerHeight}px`,\n \"--viewport-body-height\": `${viewportMeasurements.viewportBodyHeight}px`,\n } as CSSProperties;\n\n const headersReady = showColumnHeaders === false || headerHeight > 0;\n const readyToRenderTableBody = headersReady && data.length > 0;\n\n return (\n <ContextMenuProvider\n menuActionHandler={handleContextMenuAction}\n menuBuilder={menuBuilder}\n >\n {showPaginationControls !== true ? (\n <div\n className={`${classBase}-scrollbarContainer`}\n ref={scrollProps.scrollbarContainerRef}\n style={cssVariables}\n tabIndex={-1}\n >\n <div className={`${classBase}-scrollbarContent`} />\n </div>\n ) : null}\n <div\n className={contentContainerClassName}\n ref={scrollProps.contentContainerRef}\n style={cssVariables}\n >\n <div\n {...tableProps}\n className={`${classBase}-table`}\n role=\"table\"\n tabIndex={disableFocus ? undefined : -1}\n >\n {showColumnHeaders ? (\n <TableHeader\n allowDragColumnHeader={allowDragColumnHeader}\n columns={scrollProps.columnsWithinViewport}\n customHeader={customHeader}\n headings={headings}\n onHeightMeasured={onHeaderHeightMeasured}\n onMoveColumn={onMoveColumn}\n onMoveGroupColumn={onMoveGroupColumn}\n onRemoveGroupColumn={onRemoveGroupColumn}\n onResizeColumn={onResizeColumn}\n onSortColumn={onSortColumn}\n showColumnHeaderMenus={showColumnHeaderMenus}\n tableConfig={tableConfig}\n tableId={id}\n virtualColSpan={scrollProps.virtualColSpan}\n />\n ) : null}\n {readyToRenderTableBody ? (\n <div className={`${classBase}-body`} ref={tableBodyRef}>\n {data.map((data) => (\n <Row\n aria-rowindex={data[0] + headerCount + 1}\n classNameGenerator={rowClassNameGenerator}\n columnMap={columnMap}\n columns={scrollProps.columnsWithinViewport}\n highlighted={highlightedIndex === data[IDX]}\n key={data[RENDER_IDX]}\n onClick={onRowClick}\n onDataEdited={onDataEdited}\n row={data}\n offset={showPaginationControls ? 0 : getRowOffset(data)}\n onToggleGroup={onToggleGroup}\n virtualColSpan={scrollProps.virtualColSpan}\n zebraStripes={tableAttributes.zebraStripes}\n />\n ))}\n {/* \n The focusCellPlaceholder allows us to deal with the situation where a cell \n that has focus is scrolled out of the viewport. That cell, along with the \n containing row, will be recycled to render another DataRow. The html table \n cell must not retain focus once it is re-used but we need to track the \n original focus, in case user uses arrow key to resume navigation. \n The placeholder is fixed in place at the location where the focused cell \n was last rendered. It assumes focus. If we get an arrowkey mousedown event \n on the placeholder, the user has resumed navigation whilst the focused cell \n is offscreen. We scroll back to the focus location and pass focus back to \n the correct target cell.\n */}\n <div\n className={`${classBase}-focusCellPlaceholder`}\n onKeyDown={focusCellPlaceholderKeyDown}\n ref={focusCellPlaceholderRef}\n tabIndex={-1}\n />\n\n {cellBlock}\n </div>\n ) : null}\n </div>\n </div>\n {/* \n This keeps the heights of content container and scrollbar container aligned for\n cases where we rely on height: fit-content. (ScrollbarContainer isn't taken into \n account because its absolutely positioned).\n */}\n <div\n className={`${classBase}-scrollbarFiller`}\n style={cssScrollbarSize}\n />\n {draggableRow}\n </ContextMenuProvider>\n );\n};\n\nexport const Table = forwardRef(function Table(\n {\n Row,\n allowCellBlockSelection,\n allowDragColumnHeader,\n allowDragDrop,\n availableColumns,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\n disableFocus,\n height,\n highlightedIndex,\n id,\n maxViewportRowLimit,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n rowHeight: rowHeightProp,\n scrollingApiRef,\n selectionModel,\n showColumnHeaders,\n showColumnHeaderMenus,\n showPaginationControls,\n style: styleProp,\n viewportRowLimit,\n width,\n ...htmlAttributes\n }: TableProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table\",\n css: tableCss,\n window: targetWindow,\n });\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [size, _setSize] = useState<MeasuredSize>();\n // TODO this will rerender entire table, move footer into seperate component\n const { measuredHeight: rowHeight, measuredRef: rowRef } = useMeasuredHeight({\n height: rowHeightProp,\n });\n const { measuredHeight: footerHeight, measuredRef: footerRef } =\n useMeasuredHeight({});\n\n const rowLimit = maxViewportRowLimit ?? viewportRowLimit;\n\n if (config === undefined) {\n throw Error(\n \"vuu Table requires config prop. Minimum config is list of Column Descriptors\",\n );\n }\n if (dataSource === undefined) {\n throw Error(\"vuu Table requires dataSource prop\");\n }\n\n if (showPaginationControls && renderBufferSize !== undefined) {\n console.warn(\n `Table: When pagination controls are used, renderBufferSize is ignored`,\n );\n }\n\n if (rowLimit && height && rowHeightProp) {\n console.warn(\n `Table: when viewportRowLimit, rowHeight and height are used in combination, height is ignored`,\n );\n height = rowLimit * rowHeightProp;\n } else if (rowLimit && rowHeightProp) {\n height = rowLimit * rowHeightProp;\n } else if (rowLimit) {\n height = rowLimit * rowHeight;\n }\n\n const sizeRef = useRef<MeasuredSize>();\n const setSize = useCallback(\n (size: MeasuredSize) => {\n if (viewportRowLimit && !rowHeight) {\n sizeRef.current = size;\n } else if (\n size.height !== sizeRef.current?.height ||\n size.width !== sizeRef.current?.width\n ) {\n _setSize(size);\n }\n },\n [rowHeight, viewportRowLimit],\n );\n useMemo(() => {\n if (sizeRef.current && rowHeight) {\n const size = {\n ...sizeRef.current,\n height: rowHeight * (viewportRowLimit as number),\n };\n sizeRef.current = size;\n _setSize(size);\n }\n }, [rowHeight, viewportRowLimit]);\n\n // TODO render TableHeader here and measure before row construction begins\n // TODO we could have MeasuredContainer render a Provider and make size available via a context hook ?\n return (\n <MeasuredContainer\n {...htmlAttributes}\n className={cx(classBase, classNameProp, {\n [`${classBase}-pagination`]: showPaginationControls,\n [`${classBase}-maxViewportRowLimit`]: maxViewportRowLimit,\n [`${classBase}-viewportRowLimit`]: viewportRowLimit,\n })}\n height={height}\n id={id}\n onResize={setSize}\n ref={useForkRef(containerRef, forwardedRef)}\n style={\n {\n \"--row-height-prop\": rowHeight > 0 ? `${rowHeight}px` : undefined,\n } as CSSProperties\n }\n width={width}\n >\n <RowProxy ref={rowRef} height={rowHeightProp} />\n {size &&\n rowHeight &&\n (footerHeight || showPaginationControls !== true) ? (\n <TableCore\n Row={Row}\n allowCellBlockSelection={allowCellBlockSelection}\n allowDragColumnHeader={allowDragColumnHeader}\n allowDragDrop={allowDragDrop}\n availableColumns={availableColumns}\n config={config}\n containerRef={containerRef}\n customHeader={customHeader}\n dataSource={dataSource}\n disableFocus={disableFocus}\n highlightedIndex={highlightedIndex}\n id={id}\n navigationStyle={navigationStyle}\n onAvailableColumnsChange={onAvailableColumnsChange}\n onConfigChange={onConfigChange}\n onDragStart={onDragStart}\n onDrop={onDrop}\n onHighlight={onHighlight}\n onRowClick={onRowClick}\n onSelect={onSelect}\n onSelectCellBlock={onSelectCellBlock}\n onSelectionChange={onSelectionChange}\n renderBufferSize={\n showPaginationControls ? 0 : Math.max(5, renderBufferSize ?? 0)\n }\n rowHeight={rowHeight}\n scrollingApiRef={scrollingApiRef}\n selectionModel={selectionModel}\n showColumnHeaders={showColumnHeaders}\n showColumnHeaderMenus={showColumnHeaderMenus}\n showPaginationControls={showPaginationControls}\n size={reduceSizeHeight(size, footerHeight)}\n />\n ) : null}\n {showPaginationControls ? (\n <div className={`${classBase}-footer`} ref={footerRef}>\n <PaginationControl dataSource={dataSource} />\n </div>\n ) : null}\n </MeasuredContainer>\n );\n});\n"],"names":["metadataKeys","Row","DefaultRow","useId","useTable","jsxs","ContextMenuProvider","jsx","TableHeader","data","forwardRef","Table","useWindow","useComponentCssInjection","tableCss","useRef","useState","useMeasuredHeight","useCallback","size","useMemo","MeasuredContainer","useForkRef","RowProxy","reduce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A;AAAA,YACA,aAAA;AAAA,YACA,gBAAA;AAAA,YACA,MAAA;AAAA,YACA,YAAA;AAAA,YACA,YAAA;AAAA,YACA,UAAA;AAAA,YACA,YAAA;AAAA,YACA,gBAAA;AAAA,YACA,EAAA;AAAA,YACA,eAAA;AAAA,YACA,wBAAA;AAAA,YACA,cAAA;AAAA,YACA,WAAA;AAAA,YACA,MAAA;AAAA,YACA,WAAA;AAAA,YACA,UAAA;AAAA,YACA,QAAA;AAAA,YACA,iBAAA;AAAA,YACA,iBAAA;AAAA,YACA,kBACE,sBAAyB,GAAA,CAAA,GAAI,KAAK,GAAI,CAAA,CAAA,EAAG,oBAAoB,CAAC,CAAA;AAAA,YAEhE,SAAA;AAAA,YACA,eAAA;AAAA,YACA,cAAA;AAAA,YACA,iBAAA;AAAA,YACA,qBAAA;AAAA,YACA,sBAAA;AAAA,YACA,IAAA,EAAMuB,8BAAiB,CAAA,IAAA,EAAM,YAAY,CAAA;AAAA,WAAA;AAAA,SAEzC,GAAA,IAAA;AAAA,QACH,sBACC,mBAAAjB,cAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,CAAG,EAAA,SAAS,CAAW,OAAA,CAAA,EAAA,GAAA,EAAK,SAC1C,EAAA,QAAA,kBAAAA,cAAA,CAACkB,mCAAkB,EAAA,EAAA,UAAA,EAAwB,GAC7C,CACE,GAAA,IAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GACN,CAAA;AAEJ,CAAC;;;;"}
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const NULL_CELL_POS = [-1, -1];
4
- const headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell[aria-colindex='${colIdx + 1}']`;
5
- const dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx + 1}'] > [aria-colindex='${colIdx + 1}']`;
4
+ const headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell[aria-colindex='${colIdx}']`;
5
+ const dataCellQuery = (rowIdx, colIdx) => `.vuuTable-table [aria-rowindex='${rowIdx}'] > [aria-colindex='${colIdx}']`;
6
6
  const getTableCell = (containerRef, [rowIdx, colIdx]) => {
7
- const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
7
+ const cssQuery = dataCellQuery(rowIdx, colIdx);
8
8
  const cell = containerRef.current?.querySelector(
9
9
  cssQuery
10
10
  );
@@ -23,26 +23,47 @@ const cellDropdownShowing = (cell) => {
23
23
  return false;
24
24
  };
25
25
  const cellIsTextInput = (cell) => cell.querySelector(".vuuTableInputCell") !== null;
26
- const getIndexFromRowElement = (rowElement) => {
26
+ const getAriaRowIndex = (rowElement) => {
27
27
  const rowIndex = rowElement?.ariaRowIndex;
28
28
  if (rowIndex != null) {
29
- const index = parseInt(rowIndex) - 1;
29
+ const index = parseInt(rowIndex);
30
30
  if (!isNaN(index)) {
31
31
  return index;
32
32
  }
33
33
  }
34
34
  return -1;
35
35
  };
36
- const getIndexFromCellElement = (cellElement) => {
37
- const colIndex = cellElement?.ariaColIndex;
36
+ const getAriaColIndex = (rowElement) => {
37
+ const colIndex = rowElement?.ariaColIndex;
38
38
  if (colIndex != null) {
39
- const index = parseInt(colIndex) - 1;
39
+ const index = parseInt(colIndex);
40
40
  if (!isNaN(index)) {
41
41
  return index;
42
42
  }
43
43
  }
44
44
  return -1;
45
45
  };
46
+ const getRowElementByAriaIndex = (container, rowIndex) => {
47
+ if (rowIndex === -1) {
48
+ return null;
49
+ } else {
50
+ const activeRow = container.querySelector(
51
+ `[aria-rowindex="${rowIndex}"]`
52
+ );
53
+ if (activeRow) {
54
+ return activeRow;
55
+ } else {
56
+ throw Error(
57
+ `getRowElementAtIndex no row found for index index ${rowIndex}`
58
+ );
59
+ }
60
+ }
61
+ };
62
+ const getIndexFromRowElement = (rowElement) => {
63
+ const ariaRowIndex = getAriaRowIndex(rowElement);
64
+ return ariaRowIndex === -1 ? -1 : ariaRowIndex - 1;
65
+ };
66
+ const getIndexFromCellElement = (cellElement) => getAriaColIndex(cellElement);
46
67
  const getTableCellPos = (tableCell) => {
47
68
  const colIdx = getIndexFromCellElement(tableCell);
48
69
  if (tableCell.role === "columnHeader") {
@@ -55,9 +76,13 @@ const getTableCellPos = (tableCell) => {
55
76
  }
56
77
  return NULL_CELL_POS;
57
78
  };
79
+ const getAriaCellPos = (tableCell) => {
80
+ const focusedRow = tableCell.closest("[role='row']");
81
+ return [getAriaRowIndex(focusedRow), getAriaColIndex(tableCell)];
82
+ };
58
83
  const closestRow = (el) => el.closest('[role="row"]');
59
84
  const closestRowIndex = (el) => getIndexFromRowElement(closestRow(el));
60
- function getNextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
85
+ function getNextCellPos(key, [rowIdx, colIdx], columnCount, maxRowIndex) {
61
86
  if (key === "ArrowUp") {
62
87
  if (rowIdx > -1) {
63
88
  return [rowIdx - 1, colIdx];
@@ -66,20 +91,20 @@ function getNextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
66
91
  }
67
92
  } else if (key === "ArrowDown") {
68
93
  if (rowIdx === -1) {
69
- return [0, colIdx];
70
- } else if (rowIdx === rowCount - 1) {
94
+ return [1, colIdx];
95
+ } else if (rowIdx === maxRowIndex) {
71
96
  return [rowIdx, colIdx];
72
97
  } else {
73
98
  return [rowIdx + 1, colIdx];
74
99
  }
75
100
  } else if (key === "ArrowRight") {
76
- if (colIdx < columnCount - 1) {
101
+ if (colIdx < columnCount) {
77
102
  return [rowIdx, colIdx + 1];
78
103
  } else {
79
104
  return [rowIdx, colIdx];
80
105
  }
81
106
  } else if (key === "ArrowLeft") {
82
- if (colIdx > 0) {
107
+ if (colIdx > 1) {
83
108
  return [rowIdx, colIdx - 1];
84
109
  } else {
85
110
  return [rowIdx, colIdx];
@@ -114,9 +139,13 @@ exports.cellIsEditable = cellIsEditable;
114
139
  exports.cellIsTextInput = cellIsTextInput;
115
140
  exports.closestRowIndex = closestRowIndex;
116
141
  exports.dataCellQuery = dataCellQuery;
142
+ exports.getAriaCellPos = getAriaCellPos;
143
+ exports.getAriaColIndex = getAriaColIndex;
144
+ exports.getAriaRowIndex = getAriaRowIndex;
117
145
  exports.getIndexFromCellElement = getIndexFromCellElement;
118
146
  exports.getIndexFromRowElement = getIndexFromRowElement;
119
147
  exports.getNextCellPos = getNextCellPos;
148
+ exports.getRowElementByAriaIndex = getRowElementByAriaIndex;
120
149
  exports.getTableCell = getTableCell;
121
150
  exports.getTableCellPos = getTableCellPos;
122
151
  exports.headerCellQuery = headerCellQuery;
@@ -1 +1 @@
1
- {"version":3,"file":"table-dom-utils.js","sources":["../src/table-dom-utils.ts"],"sourcesContent":["import { RefObject } from \"react\";\nimport { ScrollDirection } from \"./useTableScroll\";\nimport type { ArrowKey, PageKey } from \"@vuu-ui/vuu-utils\";\nimport type { CellPos } from \"@vuu-ui/vuu-table-types\";\n\nconst NULL_CELL_POS: CellPos = [-1, -1];\n\nexport type NavigationKey = PageKey | ArrowKey;\n\nexport const headerCellQuery = (colIdx: number) =>\n `.vuuTable-col-headers .vuuTableHeaderCell[aria-colindex='${colIdx + 1}']`;\n\nexport const dataCellQuery = (rowIdx: number, colIdx: number) =>\n `.vuuTable-body > [aria-rowindex='${rowIdx + 1}'] > [aria-colindex='${colIdx + 1}']`;\n\nexport const getTableCell = (\n containerRef: RefObject<HTMLElement>,\n [rowIdx, colIdx]: CellPos,\n) => {\n const cssQuery =\n rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);\n const cell = containerRef.current?.querySelector(\n cssQuery,\n ) as HTMLTableCellElement;\n\n if (cellIsEditable(cell)) {\n // Dropdown gets focus, Input does not\n const focusableContent = cell.querySelector(\"button\") as HTMLElement;\n return focusableContent || cell;\n } else {\n return cell;\n }\n};\n\nexport const cellIsEditable = (cell: HTMLDivElement | null) =>\n cell?.classList.contains(\"vuuTableCell-editable\");\n\nexport const cellDropdownShowing = (cell: HTMLDivElement | null) => {\n if (cellIsEditable(cell)) {\n return cell?.querySelector('.saltDropdown[aria-expanded=\"true\"]') !== null;\n }\n return false;\n};\n\nexport const cellIsTextInput = (cell: HTMLElement) =>\n cell.querySelector(\".vuuTableInputCell\") !== null;\n\nexport const getIndexFromRowElement = (rowElement: HTMLElement | null) => {\n const rowIndex = rowElement?.ariaRowIndex;\n if (rowIndex != null) {\n const index = parseInt(rowIndex) - 1;\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const getIndexFromCellElement = (cellElement: HTMLElement | null) => {\n const colIndex = cellElement?.ariaColIndex;\n if (colIndex != null) {\n const index = parseInt(colIndex) - 1;\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const getTableCellPos = (tableCell: HTMLDivElement): CellPos => {\n const colIdx = getIndexFromCellElement(tableCell);\n if (tableCell.role === \"columnHeader\") {\n return [-1, colIdx];\n } else {\n const focusedRow = tableCell.closest(\"[role='row']\") as HTMLElement;\n if (focusedRow) {\n return [getIndexFromRowElement(focusedRow), colIdx];\n }\n }\n return NULL_CELL_POS;\n};\n\nconst closestRow = (el: HTMLElement) =>\n el.closest('[role=\"row\"]') as HTMLElement;\n\nexport const closestRowIndex = (el: HTMLElement) =>\n getIndexFromRowElement(closestRow(el));\n\nexport function getNextCellPos(\n key: ArrowKey,\n [rowIdx, colIdx]: CellPos,\n columnCount: number,\n rowCount: number,\n): CellPos {\n if (key === \"ArrowUp\") {\n if (rowIdx > -1) {\n return [rowIdx - 1, colIdx];\n } else {\n return [rowIdx, colIdx];\n }\n } else if (key === \"ArrowDown\") {\n if (rowIdx === -1) {\n return [0, colIdx];\n } else if (rowIdx === rowCount - 1) {\n return [rowIdx, colIdx];\n } else {\n return [rowIdx + 1, colIdx];\n }\n } else if (key === \"ArrowRight\") {\n if (colIdx < columnCount - 1) {\n return [rowIdx, colIdx + 1];\n } else {\n return [rowIdx, colIdx];\n }\n } else if (key === \"ArrowLeft\") {\n if (colIdx > 0) {\n return [rowIdx, colIdx - 1];\n } else {\n return [rowIdx, colIdx];\n }\n }\n return [rowIdx, colIdx];\n}\n\nconst NO_SCROLL_NECESSARY = [undefined, undefined] as const;\n\nexport const howFarIsRowOutsideViewport = (\n rowEl: HTMLElement,\n totalHeaderHeight: number,\n contentContainer = rowEl.closest(\".vuuTable-contentContainer\"),\n): readonly [ScrollDirection | undefined, number | undefined] => {\n //TODO lots of scope for optimisation here\n if (contentContainer) {\n // TODO take totalHeaderHeight into consideration\n const viewport = contentContainer?.getBoundingClientRect();\n const upperBoundary = viewport.top + totalHeaderHeight;\n const row = rowEl.getBoundingClientRect();\n if (row) {\n if (row.bottom > viewport.bottom) {\n return [\"down\", row.bottom - viewport.bottom];\n } else if (row.top < upperBoundary) {\n return [\"up\", row.top - upperBoundary];\n } else {\n return NO_SCROLL_NECESSARY;\n }\n } else {\n throw Error(\"Whats going on, row not found\");\n }\n } else {\n throw Error(\"Whats going on, scrollbar container not found\");\n }\n};\n"],"names":[],"mappings":";;AAKA,MAAM,aAAA,GAAyB,CAAC,CAAA,CAAA,EAAI,CAAE,CAAA,CAAA,CAAA;AAI/B,MAAM,eAAkB,GAAA,CAAC,MAC9B,KAAA,CAAA,yDAAA,EAA4D,SAAS,CAAC,CAAA,EAAA,EAAA;AAE3D,MAAA,aAAA,GAAgB,CAAC,MAAgB,EAAA,MAAA,KAC5C,oCAAoC,MAAS,GAAA,CAAC,CAAwB,qBAAA,EAAA,MAAA,GAAS,CAAC,CAAA,EAAA,EAAA;AAE3E,MAAM,eAAe,CAC1B,YAAA,EACA,CAAC,MAAA,EAAQ,MAAM,CACZ,KAAA;AACH,EAAM,MAAA,QAAA,GACJ,WAAW,CAAK,CAAA,GAAA,eAAA,CAAgB,MAAM,CAAI,GAAA,aAAA,CAAc,QAAQ,MAAM,CAAA,CAAA;AACxE,EAAM,MAAA,IAAA,GAAO,aAAa,OAAS,EAAA,aAAA;AAAA,IACjC,QAAA;AAAA,GACF,CAAA;AAEA,EAAI,IAAA,cAAA,CAAe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,MAAA,IAAW,GAAI,CAAA,GAAA,GAAM,aAAe,EAAA;AAClC,QAAA,OAAO,CAAC,IAAA,EAAM,GAAI,CAAA,GAAA,GAAM,aAAa,CAAA,CAAA;AAAA,OAChC,MAAA;AACL,QAAO,OAAA,mBAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AACL,MAAA,MAAM,MAAM,+BAA+B,CAAA,CAAA;AAAA,KAC7C;AAAA,GACK,MAAA;AACL,IAAA,MAAM,MAAM,+CAA+C,CAAA,CAAA;AAAA,GAC7D;AACF;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"table-dom-utils.js","sources":["../src/table-dom-utils.ts"],"sourcesContent":["import { RefObject } from \"react\";\nimport { ScrollDirection } from \"./useTableScroll\";\nimport type { ArrowKey, PageKey } from \"@vuu-ui/vuu-utils\";\nimport type { CellPos } from \"@vuu-ui/vuu-table-types\";\n\nconst NULL_CELL_POS: CellPos = [-1, -1];\n\nexport type NavigationKey = PageKey | ArrowKey;\n\nexport const headerCellQuery = (colIdx: number) =>\n `.vuuTable-col-headers .vuuTableHeaderCell[aria-colindex='${colIdx}']`;\n\nexport const dataCellQuery = (rowIdx: number, colIdx: number) =>\n `.vuuTable-table [aria-rowindex='${rowIdx}'] > [aria-colindex='${colIdx}']`;\n\nexport const getTableCell = (\n containerRef: RefObject<HTMLElement>,\n [rowIdx, colIdx]: CellPos,\n) => {\n const cssQuery = dataCellQuery(rowIdx, colIdx);\n const cell = containerRef.current?.querySelector(\n cssQuery,\n ) as HTMLTableCellElement;\n\n if (cellIsEditable(cell)) {\n // Dropdown gets focus, Input does not\n const focusableContent = cell.querySelector(\"button\") as HTMLElement;\n return focusableContent || cell;\n } else {\n return cell;\n }\n};\n\nexport const cellIsEditable = (cell: HTMLDivElement | null) =>\n cell?.classList.contains(\"vuuTableCell-editable\");\n\nexport const cellDropdownShowing = (cell: HTMLDivElement | null) => {\n if (cellIsEditable(cell)) {\n return cell?.querySelector('.saltDropdown[aria-expanded=\"true\"]') !== null;\n }\n return false;\n};\n\nexport const cellIsTextInput = (cell: HTMLElement) =>\n cell.querySelector(\".vuuTableInputCell\") !== null;\n\nexport const getAriaRowIndex = (rowElement: HTMLElement | null) => {\n const rowIndex = rowElement?.ariaRowIndex;\n if (rowIndex != null) {\n const index = parseInt(rowIndex);\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const getAriaColIndex = (rowElement: HTMLElement | null) => {\n const colIndex = rowElement?.ariaColIndex;\n if (colIndex != null) {\n const index = parseInt(colIndex);\n if (!isNaN(index)) {\n return index;\n }\n }\n return -1;\n};\n\nexport const getRowElementByAriaIndex = (\n container: HTMLDivElement | EventTarget,\n rowIndex: number,\n) => {\n if (rowIndex === -1) {\n return null;\n } else {\n const activeRow = (container as HTMLElement).querySelector(\n `[aria-rowindex=\"${rowIndex}\"]`,\n ) as HTMLElement;\n\n if (activeRow) {\n return activeRow;\n } else {\n throw Error(\n `getRowElementAtIndex no row found for index index ${rowIndex}`,\n );\n }\n }\n};\n\nexport const getIndexFromRowElement = (rowElement: HTMLElement | null) => {\n const ariaRowIndex = getAriaRowIndex(rowElement);\n return ariaRowIndex === -1 ? -1 : ariaRowIndex - 1;\n};\n\nexport const getIndexFromCellElement = (cellElement: HTMLElement | null) =>\n getAriaColIndex(cellElement);\n\nexport const getTableCellPos = (tableCell: HTMLDivElement): CellPos => {\n const colIdx = getIndexFromCellElement(tableCell);\n if (tableCell.role === \"columnHeader\") {\n return [-1, colIdx];\n } else {\n const focusedRow = tableCell.closest(\"[role='row']\") as HTMLElement;\n if (focusedRow) {\n return [getIndexFromRowElement(focusedRow), colIdx];\n }\n }\n return NULL_CELL_POS;\n};\n\nexport const getAriaCellPos = (tableCell: HTMLDivElement): CellPos => {\n const focusedRow = tableCell.closest(\"[role='row']\") as HTMLElement;\n return [getAriaRowIndex(focusedRow), getAriaColIndex(tableCell)];\n};\n\nconst closestRow = (el: HTMLElement) =>\n el.closest('[role=\"row\"]') as HTMLElement;\n\nexport const closestRowIndex = (el: HTMLElement) =>\n getIndexFromRowElement(closestRow(el));\n\nexport function getNextCellPos(\n key: ArrowKey,\n [rowIdx, colIdx]: CellPos,\n columnCount: number,\n maxRowIndex: number,\n): CellPos {\n if (key === \"ArrowUp\") {\n if (rowIdx > -1) {\n return [rowIdx - 1, colIdx];\n } else {\n return [rowIdx, colIdx];\n }\n } else if (key === \"ArrowDown\") {\n if (rowIdx === -1) {\n return [1, colIdx];\n } else if (rowIdx === maxRowIndex) {\n return [rowIdx, colIdx];\n } else {\n return [rowIdx + 1, colIdx];\n }\n } else if (key === \"ArrowRight\") {\n if (colIdx < columnCount) {\n return [rowIdx, colIdx + 1];\n } else {\n return [rowIdx, colIdx];\n }\n } else if (key === \"ArrowLeft\") {\n if (colIdx > 1) {\n return [rowIdx, colIdx - 1];\n } else {\n return [rowIdx, colIdx];\n }\n }\n return [rowIdx, colIdx];\n}\n\nconst NO_SCROLL_NECESSARY = [undefined, undefined] as const;\n\nexport const howFarIsRowOutsideViewport = (\n rowEl: HTMLElement,\n totalHeaderHeight: number,\n contentContainer = rowEl.closest(\".vuuTable-contentContainer\"),\n): readonly [ScrollDirection | undefined, number | undefined] => {\n //TODO lots of scope for optimisation here\n if (contentContainer) {\n // TODO take totalHeaderHeight into consideration\n const viewport = contentContainer?.getBoundingClientRect();\n const upperBoundary = viewport.top + totalHeaderHeight;\n const row = rowEl.getBoundingClientRect();\n if (row) {\n if (row.bottom > viewport.bottom) {\n return [\"down\", row.bottom - viewport.bottom];\n } else if (row.top < upperBoundary) {\n return [\"up\", row.top - upperBoundary];\n } else {\n return NO_SCROLL_NECESSARY;\n }\n } else {\n throw Error(\"Whats going on, row not found\");\n }\n } else {\n throw Error(\"Whats going on, scrollbar container not found\");\n }\n};\n"],"names":[],"mappings":";;AAKA,MAAM,aAAA,GAAyB,CAAC,CAAA,CAAA,EAAI,CAAE,CAAA,CAAA,CAAA;AAI/B,MAAM,eAAkB,GAAA,CAAC,MAC9B,KAAA,C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,CAAA,MAAA,GAAS,SAAS,MAAM,CAAA,CAAA;AAAA,OAC9C,MAAA,IAAW,GAAI,CAAA,GAAA,GAAM,aAAe,EAAA;AAClC,QAAA,OAAO,CAAC,IAAA,EAAM,GAAI,CAAA,GAAA,GAAM,aAAa,CAAA,CAAA;AAAA,OAChC,MAAA;AACL,QAAO,OAAA,mBAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AACL,MAAA,MAAM,MAAM,+BAA+B,CAAA,CAAA;AAAA,KAC7C;AAAA,GACK,MAAA;AACL,IAAA,MAAM,MAAM,+CAA+C,CAAA,CAAA;AAAA,GAC7D;AACF;;;;;;;;;;;;;;;;;;;"}
@@ -27,90 +27,129 @@ const TableHeader = react.memo(
27
27
  tableId,
28
28
  virtualColSpan = 0
29
29
  }) => {
30
- const {
31
- draggableColumn,
32
- draggedColumnIndex,
33
- onClick,
34
- onMouseDown,
35
- setContainerRef
36
- } = useTableHeader.useTableHeader({
37
- allowDragColumnHeader,
38
- columns,
39
- onHeightMeasured,
40
- onMoveColumn,
41
- onSortColumn,
42
- tableConfig
43
- });
44
- const customHeaders = react.useMemo(() => {
45
- const createElement = (Component, key) => /* @__PURE__ */ jsxRuntime.jsx(
30
+ const [customHeaders, customHeaderCount] = react.useMemo(() => {
31
+ const offset = headings.length;
32
+ const createElement = (Component, index) => /* @__PURE__ */ jsxRuntime.jsx(
46
33
  Component,
47
34
  {
35
+ ariaRowIndex: offset + index + 2,
36
+ ariaRole: "row",
48
37
  columns,
49
38
  virtualColSpan
50
39
  },
51
- key
40
+ index
52
41
  );
42
+ const enrichElementWithAria = (el, rowIndex) => {
43
+ const offset2 = headings.length;
44
+ return react.cloneElement(el, {
45
+ "aria-rowindex": rowIndex + offset2 + 2,
46
+ ariaRole: "row"
47
+ });
48
+ };
53
49
  if (customHeader === void 0) {
54
- return null;
50
+ return [null, 0];
55
51
  } else if (Array.isArray(customHeader)) {
56
52
  if (customHeader.some(react.isValidElement)) {
57
- return /* @__PURE__ */ jsxRuntime.jsx(HeaderProvider.HeaderProvider, { columns, virtualColSpan, children: customHeader.map(
58
- (header, i) => react.isValidElement(header) ? header : createElement(header, i)
53
+ const header = /* @__PURE__ */ jsxRuntime.jsx(HeaderProvider.HeaderProvider, { columns, virtualColSpan, children: customHeader.map(
54
+ (header2, i) => react.isValidElement(header2) ? enrichElementWithAria(header2, i) : createElement(header2, i)
59
55
  ) });
56
+ return [header, customHeader.length];
60
57
  } else {
61
- return customHeader.map(createElement);
58
+ return [customHeader.map(createElement), customHeader.length];
62
59
  }
63
60
  } else if (react.isValidElement(customHeader)) {
64
- return /* @__PURE__ */ jsxRuntime.jsx(HeaderProvider.HeaderProvider, { columns, virtualColSpan, children: customHeader });
61
+ const header = /* @__PURE__ */ jsxRuntime.jsx(HeaderProvider.HeaderProvider, { columns, virtualColSpan, children: enrichElementWithAria(customHeader, 0) });
62
+ return [header, 1];
65
63
  } else {
66
- return createElement(customHeader);
64
+ return [createElement(customHeader, 0), 1];
67
65
  }
68
- }, [columns, customHeader, virtualColSpan]);
69
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase}-col-headings`, ref: setContainerRef, children: [
70
- headings.map((colHeaders, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
71
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase}-col-headers`, role: "row", children: [
72
- virtualColSpan > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
73
- "div",
74
- {
75
- role: "cell",
76
- className: "vuuTableCell",
77
- style: { width: virtualColSpan }
78
- }
79
- ) : null,
80
- columns.filter(vuuUtils.isNotHidden).map(
81
- (col, i) => vuuUtils.isGroupColumn(col) ? /* @__PURE__ */ jsxRuntime.jsx(
82
- GroupHeaderCell.GroupHeaderCell,
66
+ }, [columns, customHeader, headings.length, virtualColSpan]);
67
+ const {
68
+ draggableColumn,
69
+ draggedColumnIndex,
70
+ onClick,
71
+ onMouseDown,
72
+ setContainerRef
73
+ } = useTableHeader.useTableHeader({
74
+ allowDragColumnHeader,
75
+ columns,
76
+ customHeaderCount,
77
+ headings,
78
+ onHeightMeasured,
79
+ onMoveColumn,
80
+ onSortColumn,
81
+ tableConfig
82
+ });
83
+ return /* @__PURE__ */ jsxRuntime.jsxs(
84
+ "div",
85
+ {
86
+ className: `${classBase}-col-headings`,
87
+ ref: setContainerRef,
88
+ role: "rowgroup",
89
+ children: [
90
+ headings.map((colHeaders, i) => /* @__PURE__ */ jsxRuntime.jsx(
91
+ "div",
83
92
  {
84
- "aria-colindex": col.index,
85
- column: col,
86
- "data-index": i,
87
- onMoveColumn: onMoveGroupColumn,
88
- onRemoveColumn: onRemoveGroupColumn,
89
- onResize: onResizeColumn
93
+ className: "vuuTable-heading",
94
+ role: "row",
95
+ "aria-rowindex": i + 1,
96
+ children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j))
90
97
  },
91
- col.name
92
- ) : /* @__PURE__ */ jsxRuntime.jsx(
93
- HeaderCell.HeaderCell,
98
+ i
99
+ )),
100
+ /* @__PURE__ */ jsxRuntime.jsxs(
101
+ "div",
94
102
  {
95
- "aria-colindex": col.index,
96
- className: cx({
97
- "vuuDraggable-dragAway": i === draggedColumnIndex
98
- }),
99
- column: col,
100
- "data-index": i,
101
- id: `${tableId}-col-${i}`,
102
- onClick,
103
- onMouseDown,
104
- onResize: onResizeColumn,
105
- showMenu: showColumnHeaderMenus
106
- },
107
- col.name
108
- )
109
- ),
110
- draggableColumn
111
- ] }),
112
- customHeaders
113
- ] });
103
+ className: `${classBase}-col-headers`,
104
+ role: "row",
105
+ "aria-rowindex": headings.length + 1,
106
+ children: [
107
+ virtualColSpan > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
108
+ "div",
109
+ {
110
+ role: "cell",
111
+ className: "vuuTableCell",
112
+ style: { width: virtualColSpan }
113
+ }
114
+ ) : null,
115
+ columns.filter(vuuUtils.isNotHidden).map(
116
+ (col, i) => vuuUtils.isGroupColumn(col) ? /* @__PURE__ */ jsxRuntime.jsx(
117
+ GroupHeaderCell.GroupHeaderCell,
118
+ {
119
+ "aria-colindex": col.index,
120
+ column: col,
121
+ "data-index": i,
122
+ onMoveColumn: onMoveGroupColumn,
123
+ onRemoveColumn: onRemoveGroupColumn,
124
+ onResize: onResizeColumn
125
+ },
126
+ col.name
127
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
128
+ HeaderCell.HeaderCell,
129
+ {
130
+ "aria-colindex": col.index,
131
+ className: cx({
132
+ "vuuDraggable-dragAway": i === draggedColumnIndex
133
+ }),
134
+ column: col,
135
+ "data-index": i,
136
+ id: `${tableId}-col-${i}`,
137
+ onClick,
138
+ onMouseDown,
139
+ onResize: onResizeColumn,
140
+ showMenu: showColumnHeaderMenus
141
+ },
142
+ col.name
143
+ )
144
+ ),
145
+ draggableColumn
146
+ ]
147
+ }
148
+ ),
149
+ customHeaders
150
+ ]
151
+ }
152
+ );
114
153
  }
115
154
  );
116
155
  TableHeader.displayName = "TableHeader";
@@ -1 +1 @@
1
- {"version":3,"file":"TableHeader.js","sources":["../../src/table-header/TableHeader.tsx"],"sourcesContent":["import { VuuSortType } from \"@vuu-ui/vuu-protocol-types\";\nimport {\n ColumnDescriptor,\n CustomHeader,\n RuntimeColumnDescriptor,\n TableColumnResizeHandler,\n TableConfig,\n TableHeadings,\n} from \"@vuu-ui/vuu-table-types\";\nimport { isGroupColumn, isNotHidden } from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport { isValidElement, memo, useMemo } from \"react\";\nimport { GroupHeaderCell, HeaderCell } from \"../header-cell\";\nimport { useTableHeader } from \"./useTableHeader\";\nimport { HeaderProvider } from \"./HeaderProvider\";\n\nexport type ColumnSortHandler = (\n column: ColumnDescriptor,\n addToExistingSort: boolean,\n sortType?: VuuSortType,\n) => void;\n\nexport interface TableHeaderProps {\n allowDragColumnHeader: boolean;\n classBase?: string;\n columns: RuntimeColumnDescriptor[];\n customHeader?: CustomHeader | CustomHeader[];\n headings: TableHeadings;\n onHeightMeasured: (height: number) => void;\n onResizeColumn: TableColumnResizeHandler;\n onMoveColumn: (columns: ColumnDescriptor[]) => void;\n onMoveGroupColumn: (columns: ColumnDescriptor[]) => void;\n onRemoveGroupColumn: (column: RuntimeColumnDescriptor) => void;\n onSortColumn: ColumnSortHandler;\n showColumnHeaderMenus: boolean;\n tableConfig: TableConfig;\n tableId: string;\n virtualColSpan?: number;\n}\n\nexport const TableHeader = memo(\n ({\n allowDragColumnHeader,\n classBase = \"vuuTable\",\n columns,\n customHeader,\n headings,\n onHeightMeasured,\n onMoveColumn,\n onMoveGroupColumn,\n onRemoveGroupColumn,\n onResizeColumn,\n onSortColumn,\n showColumnHeaderMenus,\n tableConfig,\n tableId,\n virtualColSpan = 0,\n }: TableHeaderProps) => {\n const {\n draggableColumn,\n draggedColumnIndex,\n onClick,\n onMouseDown,\n setContainerRef,\n } = useTableHeader({\n allowDragColumnHeader,\n columns,\n onHeightMeasured,\n onMoveColumn,\n onSortColumn,\n tableConfig,\n });\n\n const customHeaders = useMemo(() => {\n const createElement = (Component: CustomHeader, key?: number) => (\n <Component\n columns={columns}\n key={key}\n virtualColSpan={virtualColSpan}\n />\n );\n if (customHeader === undefined) {\n return null;\n } else if (Array.isArray(customHeader)) {\n if (customHeader.some(isValidElement)) {\n return (\n <HeaderProvider columns={columns} virtualColSpan={virtualColSpan}>\n {customHeader.map((header, i) =>\n isValidElement(header) ? header : createElement(header, i),\n )}\n </HeaderProvider>\n );\n } else {\n return customHeader.map(createElement);\n }\n } else if (isValidElement(customHeader)) {\n return (\n <HeaderProvider columns={columns} virtualColSpan={virtualColSpan}>\n {customHeader}\n </HeaderProvider>\n );\n } else {\n return createElement(customHeader);\n }\n }, [columns, customHeader, virtualColSpan]);\n\n return (\n <div className={`${classBase}-col-headings`} ref={setContainerRef}>\n {headings.map((colHeaders, i) => (\n <div className=\"vuuTable-heading\" key={i}>\n {colHeaders.map(({ label, width }, j) => (\n <div key={j} className=\"vuuTable-headingCell\" style={{ width }}>\n {label}\n </div>\n ))}\n </div>\n ))}\n <div className={`${classBase}-col-headers`} role=\"row\">\n {virtualColSpan > 0 ? (\n <div\n role=\"cell\"\n className=\"vuuTableCell\"\n style={{ width: virtualColSpan }}\n />\n ) : null}\n {columns.filter(isNotHidden).map((col, i) =>\n isGroupColumn(col) ? (\n <GroupHeaderCell\n aria-colindex={col.index}\n column={col}\n data-index={i}\n key={col.name}\n onMoveColumn={onMoveGroupColumn}\n onRemoveColumn={onRemoveGroupColumn}\n onResize={onResizeColumn}\n />\n ) : (\n <HeaderCell\n aria-colindex={col.index}\n className={cx({\n \"vuuDraggable-dragAway\": i === draggedColumnIndex,\n })}\n column={col}\n data-index={i}\n id={`${tableId}-col-${i}`}\n key={col.name}\n onClick={onClick}\n onMouseDown={onMouseDown}\n onResize={onResizeColumn}\n showMenu={showColumnHeaderMenus}\n />\n ),\n )}\n {draggableColumn}\n </div>\n {customHeaders}\n </div>\n );\n },\n);\nTableHeader.displayName = \"TableHeader\";\n"],"names":["memo","useTableHeader","useMemo","jsx","isValidElement","HeaderProvider","isNotHidden","isGroupColumn","GroupHeaderCell","HeaderCell"],"mappings":";;;;;;;;;;;AAwCO,MAAM,WAAc,GAAAA,UAAA;AAAA,EACzB,CAAC;AAAA,IACC,qBAAA;AAAA,IACA,SAAY,GAAA,UAAA;AAAA,IACZ,OAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAA;AAAA,IACA,iBAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,qBAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAiB,GAAA,CAAA;AAAA,GACK,KAAA;AACtB,IAA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EAAA,iBAAA;AAAA,cACd,cAAgB,EAAA,mBAAA;AAAA,cAChB,QAAU,EAAA,cAAA;AAAA,aAAA;AAAA,YAHL,GAAI,CAAA,IAAA;AAAA,WAMX,mBAAAL,cAAA;AAAA,YAACM,qBAAA;AAAA,YAAA;AAAA,cACC,iBAAe,GAAI,CAAA,KAAA;AAAA,cACnB,WAAW,EAAG,CAAA;AAAA,gBACZ,yBAAyB,CAAM,KAAA,kBAAA;AAAA,eAChC,CAAA;AAAA,cACD,MAAQ,EAAA,GAAA;AAAA,cACR,YAAY,EAAA,CAAA;AAAA,cACZ,EAAI,EAAA,CAAA,EAAG,OAAO,CAAA,KAAA,EAAQ,CAAC,CAAA,CAAA;AAAA,cAEvB,OAAA;AAAA,cACA,WAAA;AAAA,cACA,QAAU,EAAA,cAAA;AAAA,cACV,QAAU,EAAA,qBAAA;AAAA,aAAA;AAAA,YAJL,GAAI,CAAA,IAAA;AAAA,WAKX;AAAA,SAEJ;AAAA,QACC,eAAA;AAAA,OACH,EAAA,CAAA;AAAA,MACC,aAAA;AAAA,KACH,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,EAAA;AACA,WAAA,CAAY,WAAc,GAAA,aAAA;;;;"}
1
+ {"version":3,"file":"TableHeader.js","sources":["../../src/table-header/TableHeader.tsx"],"sourcesContent":["import { VuuSortType } from \"@vuu-ui/vuu-protocol-types\";\nimport {\n ColumnDescriptor,\n CustomHeader,\n RuntimeColumnDescriptor,\n TableColumnResizeHandler,\n TableConfig,\n TableHeadings,\n} from \"@vuu-ui/vuu-table-types\";\nimport { isGroupColumn, isNotHidden } from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport { cloneElement, isValidElement, memo, useMemo } from \"react\";\nimport { GroupHeaderCell, HeaderCell } from \"../header-cell\";\nimport { useTableHeader } from \"./useTableHeader\";\nimport { HeaderProvider } from \"./HeaderProvider\";\n\nexport type ColumnSortHandler = (\n column: ColumnDescriptor,\n addToExistingSort: boolean,\n sortType?: VuuSortType,\n) => void;\n\nexport interface TableHeaderProps {\n allowDragColumnHeader: boolean;\n classBase?: string;\n columns: RuntimeColumnDescriptor[];\n customHeader?: CustomHeader | CustomHeader[];\n headings: TableHeadings;\n onHeightMeasured: (height: number, count: number) => void;\n onResizeColumn: TableColumnResizeHandler;\n onMoveColumn: (columns: ColumnDescriptor[]) => void;\n onMoveGroupColumn: (columns: ColumnDescriptor[]) => void;\n onRemoveGroupColumn: (column: RuntimeColumnDescriptor) => void;\n onSortColumn: ColumnSortHandler;\n showColumnHeaderMenus: boolean;\n tableConfig: TableConfig;\n tableId: string;\n virtualColSpan?: number;\n}\n\nexport const TableHeader = memo(\n ({\n allowDragColumnHeader,\n classBase = \"vuuTable\",\n columns,\n customHeader,\n headings,\n onHeightMeasured,\n onMoveColumn,\n onMoveGroupColumn,\n onRemoveGroupColumn,\n onResizeColumn,\n onSortColumn,\n showColumnHeaderMenus,\n tableConfig,\n tableId,\n virtualColSpan = 0,\n }: TableHeaderProps) => {\n const [customHeaders, customHeaderCount] = useMemo<\n [JSX.Element | JSX.Element[] | null, number]\n >(() => {\n const offset = headings.length;\n const createElement = (Component: CustomHeader, index: number) => (\n <Component\n ariaRowIndex={offset + index + 2}\n ariaRole=\"row\"\n columns={columns}\n key={index}\n virtualColSpan={virtualColSpan}\n />\n );\n\n const enrichElementWithAria = (el: JSX.Element, rowIndex: number) => {\n const offset = headings.length;\n return cloneElement(el, {\n \"aria-rowindex\": rowIndex + offset + 2,\n ariaRole: \"row\",\n });\n };\n\n if (customHeader === undefined) {\n return [null, 0];\n } else if (Array.isArray(customHeader)) {\n if (customHeader.some(isValidElement)) {\n const header = (\n <HeaderProvider columns={columns} virtualColSpan={virtualColSpan}>\n {customHeader.map((header, i) =>\n isValidElement(header)\n ? enrichElementWithAria(header, i)\n : createElement(header, i),\n )}\n </HeaderProvider>\n );\n return [header, customHeader.length];\n } else {\n return [customHeader.map(createElement), customHeader.length];\n }\n } else if (isValidElement(customHeader)) {\n // TODO rowIndex and role\n const header = (\n <HeaderProvider columns={columns} virtualColSpan={virtualColSpan}>\n {enrichElementWithAria(customHeader, 0)}\n </HeaderProvider>\n );\n return [header, 1];\n } else {\n return [createElement(customHeader, 0), 1];\n }\n }, [columns, customHeader, headings.length, virtualColSpan]);\n\n const {\n draggableColumn,\n draggedColumnIndex,\n onClick,\n onMouseDown,\n setContainerRef,\n } = useTableHeader({\n allowDragColumnHeader,\n columns,\n customHeaderCount,\n headings,\n onHeightMeasured,\n onMoveColumn,\n onSortColumn,\n tableConfig,\n });\n\n return (\n <div\n className={`${classBase}-col-headings`}\n ref={setContainerRef}\n role=\"rowgroup\"\n >\n {headings.map((colHeaders, i) => (\n <div\n className=\"vuuTable-heading\"\n key={i}\n role=\"row\"\n aria-rowindex={i + 1}\n >\n {colHeaders.map(({ label, width }, j) => (\n <div key={j} className=\"vuuTable-headingCell\" style={{ width }}>\n {label}\n </div>\n ))}\n </div>\n ))}\n <div\n className={`${classBase}-col-headers`}\n role=\"row\"\n aria-rowindex={headings.length + 1}\n >\n {virtualColSpan > 0 ? (\n <div\n role=\"cell\"\n className=\"vuuTableCell\"\n style={{ width: virtualColSpan }}\n />\n ) : null}\n {columns.filter(isNotHidden).map((col, i) =>\n isGroupColumn(col) ? (\n <GroupHeaderCell\n aria-colindex={col.index}\n column={col}\n data-index={i}\n key={col.name}\n onMoveColumn={onMoveGroupColumn}\n onRemoveColumn={onRemoveGroupColumn}\n onResize={onResizeColumn}\n />\n ) : (\n <HeaderCell\n aria-colindex={col.index}\n className={cx({\n \"vuuDraggable-dragAway\": i === draggedColumnIndex,\n })}\n column={col}\n data-index={i}\n id={`${tableId}-col-${i}`}\n key={col.name}\n onClick={onClick}\n onMouseDown={onMouseDown}\n onResize={onResizeColumn}\n showMenu={showColumnHeaderMenus}\n />\n ),\n )}\n {draggableColumn}\n </div>\n {customHeaders}\n </div>\n );\n },\n);\nTableHeader.displayName = \"TableHeader\";\n"],"names":["memo","useMemo","jsx","offset","cloneElement","isValidElement","HeaderProvider","header","useTableHeader","jsxs","isNotHidden","isGroupColumn","GroupHeaderCell","HeaderCell"],"mappings":";;;;;;;;;;;AAwCO,MAAM,WAAc,GAAAA,UAAA;AAAA,EACzB,CAAC;AAAA,IACC,qBAAA;AAAA,IACA,SAAY,GAAA,UAAA;AAAA,IACZ,OAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAA;AAAA,IACA,iBAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,qBAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAiB,GAAA,CAAA;AAAA,GACK,KAAA;AACtB,IAAA,MAAM,CAAC,aAAA,EAAe,iBAAiB,CAAA,GAAIC,cAEzC,MAAM;AACN,MAAA,MAAM,SAAS,QAAS,CAAA,MAAA,CAAA;AACxB,MAAM,MAAA,aAAA,GAAgB,CAAC,SAAA,EAAyB,KAC9C,qBAAAC,cAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACC,YAAA,EAAc,SAAS,KAAQ,GAAA,CAAA;AAAA,UAC/B,QAAS,EAAA,KAAA;AAAA,UACT,OAAA;AAAA,UAEA,cAAA;AAAA,SAAA;AAAA,QADK,KAAA;AAAA,OAEP,CAAA;AAGF,MAAM,MAAA,qBAAA,GAAwB,CAAC,EAAA,EAAiB,QAAqB,KAAA;AACnE,QAAA,MAAMC,UAAS,QAAS,CAAA,MAAA,CAAA;AACxB,QAAA,OAAOC,mBAAa,EAAI,EAAA;AAAA,UACtB,eAAA,EAAiB,WAAWD,OAAS,GAAA,CAAA;AAAA,UACrC,QAAU,EAAA,KAAA;AAAA,SACX,CAAA,CAAA;AAAA,OACH,CAAA;AAEA,MAAA,IAAI,iBAAiB,KAAW,CAAA,EAAA;AAC9B,QAAO,OAAA,CAAC,MAAM,CAAC,CAAA,CAAA;AAAA,OACN,MAAA,IAAA,KAAA,CAAM,OA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AE,CAAA,GAAA;AAAA,kBAAI,CAAC,GAAA,EAAK,CACrC,KAAAC,sBAAA,CAAc,GAAG,CACf,mBAAAT,cAAA;AAAA,oBAACU,+BAAA;AAAA,oBAAA;AAAA,sBACC,iBAAe,GAAI,CAAA,KAAA;AAAA,sBACnB,MAAQ,EAAA,GAAA;AAAA,sBACR,YAAY,EAAA,CAAA;AAAA,sBAEZ,YAAc,EAAA,iBAAA;AAAA,sBACd,cAAgB,EAAA,mBAAA;AAAA,sBAChB,QAAU,EAAA,cAAA;AAAA,qBAAA;AAAA,oBAHL,GAAI,CAAA,IAAA;AAAA,mBAMX,mBAAAV,cAAA;AAAA,oBAACW,qBAAA;AAAA,oBAAA;AAAA,sBACC,iBAAe,GAAI,CAAA,KAAA;AAAA,sBACnB,WAAW,EAAG,CAAA;AAAA,wBACZ,yBAAyB,CAAM,KAAA,kBAAA;AAAA,uBAChC,CAAA;AAAA,sBACD,MAAQ,EAAA,GAAA;AAAA,sBACR,YAAY,EAAA,CAAA;AAAA,sBACZ,EAAI,EAAA,CAAA,EAAG,OAAO,CAAA,KAAA,EAAQ,CAAC,CAAA,CAAA;AAAA,sBAEvB,OAAA;AAAA,sBACA,WAAA;AAAA,sBACA,QAAU,EAAA,cAAA;AAAA,sBACV,QAAU,EAAA,qBAAA;AAAA,qBAAA;AAAA,oBAJL,GAAI,CAAA,IAAA;AAAA,mBAKX;AAAA,iBAEJ;AAAA,gBACC,eAAA;AAAA,eAAA;AAAA,aAAA;AAAA,WACH;AAAA,UACC,aAAA;AAAA,SAAA;AAAA,OAAA;AAAA,KACH,CAAA;AAAA,GAEJ;AACF,EAAA;AACA,WAAA,CAAY,WAAc,GAAA,aAAA;;;;"}
@@ -9,6 +9,8 @@ var core = require('@salt-ds/core');
9
9
  const useTableHeader = ({
10
10
  allowDragColumnHeader,
11
11
  columns,
12
+ customHeaderCount,
13
+ headings,
12
14
  onHeightMeasured,
13
15
  onMoveColumn,
14
16
  onSortColumn,
@@ -16,8 +18,14 @@ const useTableHeader = ({
16
18
  }) => {
17
19
  const containerRef = react.useRef(null);
18
20
  const scrollingContainerRef = react.useRef(null);
21
+ const handleHeightMeasured = react.useCallback(
22
+ (height) => {
23
+ onHeightMeasured(height, customHeaderCount + headings.length + 1);
24
+ },
25
+ [customHeaderCount, headings, onHeightMeasured]
26
+ );
19
27
  const { measuredRef: rowRef } = useMeasuredHeight.useMeasuredHeight({
20
- onHeightMeasured
28
+ onHeightMeasured: handleHeightMeasured
21
29
  });
22
30
  const setContainerRef = react.useCallback((el) => {
23
31
  containerRef.current = el;