@vuu-ui/vuu-table 0.8.95 → 0.8.96

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 (56) hide show
  1. package/cjs/Table.js +8 -3
  2. package/cjs/Table.js.map +1 -1
  3. package/cjs/cell-block/CellBlock.css.js +1 -1
  4. package/cjs/cell-block/CellBlock.js +12 -2
  5. package/cjs/cell-block/CellBlock.js.map +1 -1
  6. package/cjs/cell-block/cellblock-utils.js +71 -0
  7. package/cjs/cell-block/cellblock-utils.js.map +1 -1
  8. package/cjs/cell-block/useCellBlockSelection.js +69 -74
  9. package/cjs/cell-block/useCellBlockSelection.js.map +1 -1
  10. package/cjs/table-dom-utils.js +67 -10
  11. package/cjs/table-dom-utils.js.map +1 -1
  12. package/cjs/table-header/useTableHeader.js +1 -1
  13. package/cjs/table-header/useTableHeader.js.map +1 -1
  14. package/cjs/useCellFocus.js +56 -0
  15. package/cjs/useCellFocus.js.map +1 -0
  16. package/cjs/useKeyboardNavigation.js +5 -81
  17. package/cjs/useKeyboardNavigation.js.map +1 -1
  18. package/cjs/useMeasuredHeight.js +5 -5
  19. package/cjs/useMeasuredHeight.js.map +1 -1
  20. package/cjs/useTable.js +21 -7
  21. package/cjs/useTable.js.map +1 -1
  22. package/cjs/useTableContextMenu.js +2 -1
  23. package/cjs/useTableContextMenu.js.map +1 -1
  24. package/esm/Table.js +8 -3
  25. package/esm/Table.js.map +1 -1
  26. package/esm/cell-block/CellBlock.css.js +1 -1
  27. package/esm/cell-block/CellBlock.js +13 -3
  28. package/esm/cell-block/CellBlock.js.map +1 -1
  29. package/esm/cell-block/cellblock-utils.js +68 -1
  30. package/esm/cell-block/cellblock-utils.js.map +1 -1
  31. package/esm/cell-block/useCellBlockSelection.js +68 -73
  32. package/esm/cell-block/useCellBlockSelection.js.map +1 -1
  33. package/esm/table-dom-utils.js +64 -10
  34. package/esm/table-dom-utils.js.map +1 -1
  35. package/esm/table-header/useTableHeader.js +1 -1
  36. package/esm/table-header/useTableHeader.js.map +1 -1
  37. package/esm/useCellFocus.js +54 -0
  38. package/esm/useCellFocus.js.map +1 -0
  39. package/esm/useKeyboardNavigation.js +5 -81
  40. package/esm/useKeyboardNavigation.js.map +1 -1
  41. package/esm/useMeasuredHeight.js +5 -5
  42. package/esm/useMeasuredHeight.js.map +1 -1
  43. package/esm/useTable.js +21 -7
  44. package/esm/useTable.js.map +1 -1
  45. package/esm/useTableContextMenu.js +2 -1
  46. package/esm/useTableContextMenu.js.map +1 -1
  47. package/package.json +9 -9
  48. package/types/Table.d.ts +3 -0
  49. package/types/cell-block/CellBlock.d.ts +2 -1
  50. package/types/cell-block/cellblock-utils.d.ts +20 -0
  51. package/types/cell-block/useCellBlockSelection.d.ts +7 -2
  52. package/types/table-dom-utils.d.ts +6 -1
  53. package/types/useCellFocus.d.ts +13 -0
  54. package/types/useKeyboardNavigation.d.ts +5 -5
  55. package/types/useMeasuredHeight.d.ts +2 -2
  56. package/types/useTable.d.ts +2 -1
package/cjs/Table.js CHANGED
@@ -76,6 +76,7 @@ const TableCore = ({
76
76
  rowClassNameGenerator,
77
77
  scrollProps,
78
78
  tableAttributes,
79
+ tableBodyRef,
79
80
  tableConfig,
80
81
  viewportMeasurements,
81
82
  ...tableProps
@@ -125,6 +126,8 @@ const TableCore = ({
125
126
  "--total-header-height": `${headerHeight}px`,
126
127
  "--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
127
128
  };
129
+ const headersReady = showColumnHeaders === false || headerHeight > 0;
130
+ const readyToRenderTableBody = headersReady && data.length > 0;
128
131
  return /* @__PURE__ */ jsxRuntime.jsxs(
129
132
  vuuPopups.ContextMenuProvider,
130
133
  {
@@ -173,7 +176,7 @@ const TableCore = ({
173
176
  virtualColSpan: scrollProps.virtualColSpan
174
177
  }
175
178
  ) : null,
176
- showColumnHeaders === false || headerHeight > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase}-body`, children: [
179
+ readyToRenderTableBody ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase}-body`, ref: tableBodyRef, children: [
177
180
  data.map((data2) => /* @__PURE__ */ jsxRuntime.jsx(
178
181
  Row$1,
179
182
  {
@@ -256,8 +259,10 @@ const Table = react.forwardRef(function Table2({
256
259
  });
257
260
  const containerRef = react.useRef(null);
258
261
  const [size, _setSize] = react.useState();
259
- const { rowHeight, rowRef } = useMeasuredHeight.useMeasuredHeight({ height: rowHeightProp });
260
- const { rowHeight: footerHeight, rowRef: footerRef } = useMeasuredHeight.useMeasuredHeight({});
262
+ const { measuredHeight: rowHeight, measuredRef: rowRef } = useMeasuredHeight.useMeasuredHeight({
263
+ height: rowHeightProp
264
+ });
265
+ const { measuredHeight: footerHeight, measuredRef: footerRef } = useMeasuredHeight.useMeasuredHeight({});
261
266
  const rowLimit = maxViewportRowLimit ?? viewportRowLimit;
262
267
  if (config === void 0) {
263
268
  throw Error(
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 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 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 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 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 >\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 {showColumnHeaders === false || headerHeight > 0 ? (\n <div className={`${classBase}-body`}>\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 {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 { rowHeight, rowRef } = useMeasuredHeight({ height: rowHeightProp });\n const { rowHeight: footerHeight, rowRef: footerRef } = 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,UA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,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
+ {"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 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 >\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 {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,gB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AC,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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var cellBlockCss = ".vuuCellBlock {\n background-color: #00bdff;\n opacity: 0.3;\n border: solid blue 1px;\n position: absolute;\n\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n\n &.cellblock-direction-n {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-end top);\n }\n\n &.cellblock-direction-ne {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-end top);\n }\n\n &.cellblock-direction-e {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-se {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-s {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-sw {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-w {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-nw {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-end top);\n }\n}\n\n.vuu-cellblock-start {\n anchor-name: --cellblock-start;\n}\n\n.vuuTable.vuu-cellblock-select-in-progress {\n .vuuTableCell:hover {\n anchor-name: --cellblock-end;\n }\n\n .vuuCellBlock {\n pointer-events: none;\n }\n}\n.vuu-cellblock-end {\n anchor-name: --cellblock-end;\n}\n";
3
+ var cellBlockCss = ".vuuCellBlock {\n background-color: #00bdff;\n opacity: 0.3;\n border: solid blue 1px;\n position: absolute;\n\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n\n &.cellblock-direction-n {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-end top);\n }\n\n &.cellblock-direction-ne {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-end top);\n }\n\n &.cellblock-direction-e {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-se {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-end right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-s {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-start left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-sw {\n bottom: anchor(--cellblock-end bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-w {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-start top);\n }\n\n &.cellblock-direction-nw {\n bottom: anchor(--cellblock-start bottom);\n left: anchor(--cellblock-end left);\n right: anchor(--cellblock-start right);\n top: anchor(--cellblock-end top);\n }\n}\n\n.vuu-cellblock-start {\n anchor-name: --cellblock-start;\n}\n\n.vuuTable.vuu-cellblock-select-in-progress-keyboard {\n .vuuTableCell:focus {\n anchor-name: --cellblock-end;\n }\n .vuuCellBlock {\n pointer-events: none;\n }\n}\n.vuuTable.vuu-cellblock-select-in-progress-mouse {\n .vuuTableCell:hover {\n anchor-name: --cellblock-end;\n }\n .vuuCellBlock {\n pointer-events: none;\n }\n}\n.vuu-cellblock-end {\n anchor-name: --cellblock-end;\n}\n";
4
4
 
5
5
  module.exports = cellBlockCss;
6
6
  //# sourceMappingURL=CellBlock.css.js.map
@@ -9,19 +9,29 @@ var CellBlock$1 = require('./CellBlock.css.js');
9
9
 
10
10
  const classBase = "vuuCellBlock";
11
11
  const CellBlock = react.forwardRef(
12
- function CellBlock2({ className, ...htmlAttributes }, forwardedRef) {
12
+ function CellBlock2({ className, onCopy, ...htmlAttributes }, forwardedRef) {
13
13
  const targetWindow = window.useWindow();
14
14
  styles.useComponentCssInjection({
15
15
  testId: "vuu-cell-block",
16
16
  css: CellBlock$1,
17
17
  window: targetWindow
18
18
  });
19
+ const handleKeyDown = react.useCallback(
20
+ async (evt) => {
21
+ if (evt.metaKey && evt.key === "c") {
22
+ onCopy?.();
23
+ }
24
+ },
25
+ [onCopy]
26
+ );
19
27
  return /* @__PURE__ */ jsxRuntime.jsx(
20
28
  "div",
21
29
  {
22
30
  ...htmlAttributes,
23
31
  className: cx(classBase, className),
24
- ref: forwardedRef
32
+ ref: forwardedRef,
33
+ onKeyDown: handleKeyDown,
34
+ tabIndex: 0
25
35
  }
26
36
  );
27
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CellBlock.js","sources":["../../src/cell-block/CellBlock.tsx"],"sourcesContent":["import { HTMLAttributes, forwardRef } from \"react\";\nimport cx from \"clsx\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport cellBlockCss from \"./CellBlock.css\";\n\nconst classBase = \"vuuCellBlock\";\n\nexport interface CellBlockProps extends HTMLAttributes<HTMLDivElement> {\n debugName?: string;\n}\n\nexport const CellBlock = forwardRef<HTMLDivElement, CellBlockProps>(\n function CellBlock({ className, ...htmlAttributes }, forwardedRef) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-cell-block\",\n css: cellBlockCss,\n window: targetWindow,\n });\n\n return (\n <div\n {...htmlAttributes}\n className={cx(classBase, className)}\n ref={forwardedRef}\n />\n );\n },\n);\n"],"names":["forwardRef","CellBlock","useWindow","useComponentCssInjection","cellBlockCss","jsx"],"mappings":";;;;;;;;;AAOA,MAAM,SAAY,GAAA,cAAA,CAAA;AAMX,MAAM,SAAY,GAAAA,gBAAA;AAAA,EACvB,SAASC,UAAU,CAAA,EAAE,WAAW,GAAG,cAAA,IAAkB,YAAc,EAAA;AACjE,IAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,gBAAA;AAAA,MACR,GAAK,EAAAC,WAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IACE,uBAAAC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACE,GAAG,cAAA;AAAA,QACJ,SAAA,EAAW,EAAG,CAAA,SAAA,EAAW,SAAS,CAAA;AAAA,QAClC,GAAK,EAAA,YAAA;AAAA,OAAA;AAAA,KACP,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"CellBlock.js","sources":["../../src/cell-block/CellBlock.tsx"],"sourcesContent":["import {\n HTMLAttributes,\n KeyboardEventHandler,\n forwardRef,\n useCallback,\n} from \"react\";\nimport cx from \"clsx\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport cellBlockCss from \"./CellBlock.css\";\n\nconst classBase = \"vuuCellBlock\";\n\nexport interface CellBlockProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onCopy\"> {\n debugName?: string;\n onCopy?: () => void;\n}\n\nexport const CellBlock = forwardRef<HTMLDivElement, CellBlockProps>(\n function CellBlock({ className, onCopy, ...htmlAttributes }, forwardedRef) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-cell-block\",\n css: cellBlockCss,\n window: targetWindow,\n });\n\n const handleKeyDown = useCallback<KeyboardEventHandler>(\n async (evt) => {\n if (evt.metaKey && evt.key === \"c\") {\n onCopy?.();\n }\n },\n [onCopy],\n );\n\n return (\n <div\n {...htmlAttributes}\n className={cx(classBase, className)}\n ref={forwardedRef}\n onKeyDown={handleKeyDown}\n tabIndex={0}\n />\n );\n },\n);\n"],"names":["forwardRef","CellBlock","useWindow","useComponentCssInjection","cellBlockCss","useCallback","jsx"],"mappings":";;;;;;;;;AAYA,MAAM,SAAY,GAAA,cAAA,CAAA;AAQX,MAAM,SAAY,GAAAA,gBAAA;AAAA,EACvB,SAASC,WAAU,EAAE,SAAA,EAAW,QAAQ,GAAG,cAAA,IAAkB,YAAc,EAAA;AACzE,IAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,gBAAA;AAAA,MACR,GAAK,EAAAC,WAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,MAAM,aAAgB,GAAAC,iBAAA;AAAA,MACpB,OAAO,GAAQ,KAAA;AACb,QAAA,IAAI,GAAI,CAAA,OAAA,IAAW,GAAI,CAAA,GAAA,KAAQ,GAAK,EAAA;AAClC,UAAS,MAAA,IAAA,CAAA;AAAA,SACX;AAAA,OACF;AAAA,MACA,CAAC,MAAM,CAAA;AAAA,KACT,CAAA;AAEA,IACE,uBAAAC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACE,GAAG,cAAA;AAAA,QACJ,SAAA,EAAW,EAAG,CAAA,SAAA,EAAW,SAAS,CAAA;AAAA,QAClC,GAAK,EAAA,YAAA;AAAA,QACL,SAAW,EAAA,aAAA;AAAA,QACX,QAAU,EAAA,CAAA;AAAA,OAAA;AAAA,KACZ,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -1,7 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var vuuUtils = require('@vuu-ui/vuu-utils');
4
+ var tableDomUtils = require('../table-dom-utils.js');
4
5
 
6
+ const isNullCellBox = ({ bottom, left, right, top }) => {
7
+ return bottom === -1 && left === -1 && right === -1 && top === -1;
8
+ };
9
+ const Hi = Number.MAX_SAFE_INTEGER;
5
10
  const getEndCellDirection = (startBox, endBox) => {
6
11
  const { bottom: sBottom, left: sLeft, right: sRight, top: sTop } = startBox;
7
12
  const { bottom: eBottom, left: eLeft, right: eRight, top: eTop } = endBox;
@@ -61,9 +66,75 @@ const getTableCellBlock = (startCell, endCell) => {
61
66
  rowRange
62
67
  };
63
68
  };
69
+ const refState = {
70
+ cellBlock: null,
71
+ cellBlockClassName: "",
72
+ dragState: "pending",
73
+ endBox: { bottom: -1, left: Hi, right: -1, top: Hi },
74
+ endCell: null,
75
+ endPos: [-1, -1],
76
+ mousePosX: -1,
77
+ mousePosY: -1,
78
+ mouseStartX: -1,
79
+ mouseStartY: -1,
80
+ startBox: { bottom: -1, left: -1, right: -1, top: -1 },
81
+ startCell: null,
82
+ startPos: [-1, -1]
83
+ };
84
+ const updateCellBlockClassName = (state) => {
85
+ const { cellBlock, cellBlockClassName, startBox, endBox } = state;
86
+ const endBlockDirection = getEndCellDirection(startBox, endBox);
87
+ const newCellBlockClassName = `cellblock-direction-${endBlockDirection}`;
88
+ if (newCellBlockClassName !== cellBlockClassName) {
89
+ if (cellBlockClassName) {
90
+ cellBlock?.classList.replace(cellBlockClassName, newCellBlockClassName);
91
+ } else {
92
+ cellBlock?.classList.add(newCellBlockClassName);
93
+ }
94
+ state.cellBlockClassName = newCellBlockClassName;
95
+ }
96
+ };
97
+ const getTextFromCells = (startCell, endCell) => {
98
+ const tableBody = vuuUtils.queryClosest(
99
+ startCell,
100
+ ".vuuTable-body",
101
+ true
102
+ );
103
+ const [startRow, startCol] = tableDomUtils.getTableCellPos(startCell);
104
+ const [endRow, endCol] = tableDomUtils.getTableCellPos(endCell);
105
+ const rowRange = {
106
+ from: Math.min(startRow, endRow),
107
+ to: Math.max(startRow, endRow)
108
+ };
109
+ const colRange = {
110
+ from: Math.min(startCol, endCol),
111
+ to: Math.max(startCol, endCol)
112
+ };
113
+ const results = [];
114
+ for (let rowIdx = rowRange.from; rowIdx <= rowRange.to; rowIdx++) {
115
+ const row = tableBody.querySelector(
116
+ `.vuuTableRow[aria-rowindex='${rowIdx + 1}']`
117
+ );
118
+ const rowData = [];
119
+ for (let colIdx = colRange.from; colIdx <= colRange.to; colIdx++) {
120
+ const cell = row?.querySelector(
121
+ `.vuuTableCell[aria-colindex='${colIdx + 1}']`
122
+ );
123
+ if (cell) {
124
+ rowData.push(cell.textContent ?? "");
125
+ }
126
+ }
127
+ results.push(rowData);
128
+ }
129
+ return results.map((r) => r.join(" ")).join("\n");
130
+ };
64
131
 
65
132
  exports.getEndCellDirection = getEndCellDirection;
66
133
  exports.getTableCellBlock = getTableCellBlock;
134
+ exports.getTextFromCells = getTextFromCells;
135
+ exports.isNullCellBox = isNullCellBox;
67
136
  exports.outsideBox = outsideBox;
137
+ exports.refState = refState;
68
138
  exports.setElementBox = setElementBox;
139
+ exports.updateCellBlockClassName = updateCellBlockClassName;
69
140
  //# sourceMappingURL=cellblock-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cellblock-utils.js","sources":["../../src/cell-block/cellblock-utils.ts"],"sourcesContent":["import { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { queryClosest } from \"@vuu-ui/vuu-utils\";\n\nexport type TableCellBlock = {\n columnRange: VuuRange;\n rowRange: VuuRange;\n};\n\nexport type CellBox = {\n bottom: number;\n left: number;\n right: number;\n top: number;\n};\n\ntype EndCellDirection =\n | \"self\"\n | \"n\"\n | \"ne\"\n | \"e\"\n | \"se\"\n | \"s\"\n | \"sw\"\n | \"w\"\n | \"nw\";\n\nexport const getEndCellDirection = (\n startBox: CellBox,\n endBox: CellBox,\n): EndCellDirection => {\n const { bottom: sBottom, left: sLeft, right: sRight, top: sTop } = startBox;\n const { bottom: eBottom, left: eLeft, right: eRight, top: eTop } = endBox;\n const north = eTop < sTop;\n const east = eRight > sRight;\n const south = eBottom > sBottom;\n const west = eLeft < sLeft;\n\n if (north && east) return \"ne\";\n else if (south && east) return \"se\";\n else if (south && west) return \"sw\";\n else if (north && west) return \"nw\";\n else if (north) return \"n\";\n else if (east) return \"e\";\n else if (south) return \"s\";\n else if (west) return \"w\";\n else return \"self\";\n};\n\nexport const setElementBox = (el: HTMLElement, box: CellBox) => {\n const { bottom, left, right, top } = el.getBoundingClientRect();\n box.bottom = bottom;\n box.left = left;\n box.right = right;\n box.top = top;\n};\n\nexport const outsideBox = (\n { bottom, left, right, top }: CellBox,\n x: number,\n y: number,\n) => x < left || x > right || y < top || y > bottom;\n\nconst getColIndex = ({ ariaColIndex }: HTMLDivElement) => {\n if (ariaColIndex !== null) {\n return parseInt(ariaColIndex);\n }\n throw Error(\"invalid aria-colindex in table cell\");\n};\n\nconst getRowIndex = (cell: HTMLDivElement) => {\n const row = queryClosest<HTMLDivElement>(cell, \".vuuTableRow\");\n if (row) {\n const { ariaRowIndex } = row;\n if (ariaRowIndex !== null) {\n return parseInt(ariaRowIndex);\n }\n }\n throw Error(\"invalid aria-rowindex in table row\");\n};\n\nexport const getTableCellBlock = (\n startCell: HTMLDivElement,\n endCell: HTMLDivElement,\n): TableCellBlock => {\n const colStart = getColIndex(startCell);\n const colEnd = getColIndex(endCell);\n const rowStart = getRowIndex(startCell);\n const rowEnd = getRowIndex(endCell);\n\n const columnRange = {\n from: Math.min(colStart, colEnd),\n to: Math.max(colStart, colEnd),\n };\n const rowRange = {\n from: Math.min(rowStart, rowEnd),\n to: Math.max(rowStart, rowEnd),\n };\n\n return {\n columnRange,\n rowRange,\n };\n};\n"],"names":["queryClosest"],"mappings":";;;;AA0Ba,MAAA,mBAAA,GAAsB,CACjC,QAAA,EACA,MACqB,KAAA;AACrB,EAAM,MAAA,EAAE,QAAQ,OAAS,EAAA,IAAA,EAAM,OAAO,KAAO,EAAA,MAAA,EAAQ,GAAK,EAAA,IAAA,EAAS,GAAA,QAAA,CAAA;AACnE,EAAM,MAAA,EAAE,QAAQ,OAAS,EAAA,IAAA,EAAM,OAAO,KAAO,EAAA,MAAA,EAAQ,GAAK,EAAA,IAAA,EAAS,GAAA,MAAA,CAAA;AACnE,EAAA,MAAM,QAAQ,IAAO,GAAA,IAAA,CAAA;AACrB,EAAA,MAAM,OAAO,MAAS,GAAA,MAAA,CAAA;AACtB,EAAA,MAAM,QAAQ,OAAU,GAAA,OAAA,CAAA;AACxB,EAAA,MAAM,OAAO,KAAQ,GAAA,KAAA,CAAA;AAErB,EAAI,IAAA,KAAA,IAAS,MAAa,OAAA,IAAA,CAAA;AAAA,OACjB,IAAA,KAAA,IAAS,MAAa,OAAA,IAAA,CAAA;AAAA,OACtB,IAAA,KAAA,IAAS,MAAa,OAAA,IAAA,CAAA;AAAA,OACtB,IAAA,KAAA,IAAS,MAAa,OAAA,IAAA,CAAA;AAAA,OAAA,IACtB,OAAc,OAAA,GAAA,CAAA;AAAA,OAAA,IACd,MAAa,OAAA,GAAA,CAAA;AAAA,OAAA,IACb,OAAc,OAAA,GAAA,CAAA;AAAA,OAAA,IACd,MAAa,OAAA,GAAA,CAAA;AAAA,OACV,OAAA,MAAA,CAAA;AACd,EAAA;AAEa,MAAA,aAAA,GAAgB,CAAC,EAAA,EAAiB,GAAiB,KAAA;AAC9D,EAAA,MAAM,EAAE,MAAQ,EAAA,IAAA,EAAM,OAAO,GAA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AM,MAAA,MAAA,GAAS,YAAY,OAAO,CAAA,CAAA;AAElC,EAAA,MAAM,WAAc,GAAA;AAAA,IAClB,IAAM,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,IAC/B,EAAI,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,GAC/B,CAAA;AACA,EAAA,MAAM,QAAW,GAAA;AAAA,IACf,IAAM,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,IAC/B,EAAI,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,GAC/B,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,WAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF;;;;;;;"}
1
+ {"version":3,"file":"cellblock-utils.js","sources":["../../src/cell-block/cellblock-utils.ts"],"sourcesContent":["import { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { queryClosest } from \"@vuu-ui/vuu-utils\";\nimport { getTableCellPos } from \"../table-dom-utils\";\n\nexport type TableCellBlock = {\n columnRange: VuuRange;\n rowRange: VuuRange;\n};\n\nexport type CellBox = {\n bottom: number;\n left: number;\n right: number;\n top: number;\n};\n\nexport const isNullCellBox = ({ bottom, left, right, top }: CellBox) => {\n return bottom === -1 && left === -1 && right === -1 && top === -1;\n};\n\nconst Hi = Number.MAX_SAFE_INTEGER;\n\ntype EndCellDirection =\n | \"self\"\n | \"n\"\n | \"ne\"\n | \"e\"\n | \"se\"\n | \"s\"\n | \"sw\"\n | \"w\"\n | \"nw\";\n\nexport const getEndCellDirection = (\n startBox: CellBox,\n endBox: CellBox,\n): EndCellDirection => {\n const { bottom: sBottom, left: sLeft, right: sRight, top: sTop } = startBox;\n const { bottom: eBottom, left: eLeft, right: eRight, top: eTop } = endBox;\n const north = eTop < sTop;\n const east = eRight > sRight;\n const south = eBottom > sBottom;\n const west = eLeft < sLeft;\n\n if (north && east) return \"ne\";\n else if (south && east) return \"se\";\n else if (south && west) return \"sw\";\n else if (north && west) return \"nw\";\n else if (north) return \"n\";\n else if (east) return \"e\";\n else if (south) return \"s\";\n else if (west) return \"w\";\n else return \"self\";\n};\n\nexport const setElementBox = (el: HTMLElement, box: CellBox) => {\n const { bottom, left, right, top } = el.getBoundingClientRect();\n box.bottom = bottom;\n box.left = left;\n box.right = right;\n box.top = top;\n};\n\nexport const outsideBox = (\n { bottom, left, right, top }: CellBox,\n x: number,\n y: number,\n) => x < left || x > right || y < top || y > bottom;\n\nconst getColIndex = ({ ariaColIndex }: HTMLDivElement) => {\n if (ariaColIndex !== null) {\n return parseInt(ariaColIndex);\n }\n throw Error(\"invalid aria-colindex in table cell\");\n};\n\nconst getRowIndex = (cell: HTMLDivElement) => {\n const row = queryClosest<HTMLDivElement>(cell, \".vuuTableRow\");\n if (row) {\n const { ariaRowIndex } = row;\n if (ariaRowIndex !== null) {\n return parseInt(ariaRowIndex);\n }\n }\n throw Error(\"invalid aria-rowindex in table row\");\n};\n\nexport const getTableCellBlock = (\n startCell: HTMLDivElement,\n endCell: HTMLDivElement,\n): TableCellBlock => {\n const colStart = getColIndex(startCell);\n const colEnd = getColIndex(endCell);\n const rowStart = getRowIndex(startCell);\n const rowEnd = getRowIndex(endCell);\n\n const columnRange = {\n from: Math.min(colStart, colEnd),\n to: Math.max(colStart, colEnd),\n };\n const rowRange = {\n from: Math.min(rowStart, rowEnd),\n to: Math.max(rowStart, rowEnd),\n };\n\n return {\n columnRange,\n rowRange,\n };\n};\n\nexport type RefState = {\n dragState: \"pending\" | \"active\";\n cellBlock: HTMLDivElement | null;\n cellBlockClassName: string;\n endBox: CellBox;\n endCell: HTMLDivElement | null;\n endPos: PosTuple; // used during keyboard operation\n mousePosX: number;\n mousePosY: number;\n mouseStartX: number;\n mouseStartY: number;\n startCell: HTMLDivElement | null;\n startBox: CellBox;\n startPos: PosTuple; // used during keyboard operation\n};\n\nexport type PosTuple = [number, number];\n\nexport const refState: RefState = {\n cellBlock: null,\n cellBlockClassName: \"\",\n dragState: \"pending\",\n endBox: { bottom: -1, left: Hi, right: -1, top: Hi },\n endCell: null,\n endPos: [-1, -1],\n mousePosX: -1,\n mousePosY: -1,\n mouseStartX: -1,\n mouseStartY: -1,\n startBox: { bottom: -1, left: -1, right: -1, top: -1 },\n startCell: null,\n startPos: [-1, -1],\n} as const;\n\nexport const updateCellBlockClassName = (state: RefState) => {\n const { cellBlock, cellBlockClassName, startBox, endBox } = state;\n const endBlockDirection = getEndCellDirection(startBox, endBox);\n const newCellBlockClassName = `cellblock-direction-${endBlockDirection}`;\n if (newCellBlockClassName !== cellBlockClassName) {\n if (cellBlockClassName) {\n cellBlock?.classList.replace(cellBlockClassName, newCellBlockClassName);\n } else {\n cellBlock?.classList.add(newCellBlockClassName);\n }\n state.cellBlockClassName = newCellBlockClassName;\n }\n};\n\nexport const getTextFromCells = (\n startCell: HTMLDivElement,\n endCell: HTMLDivElement,\n) => {\n const tableBody = queryClosest<HTMLDivElement>(\n startCell,\n \".vuuTable-body\",\n true,\n );\n const [startRow, startCol] = getTableCellPos(startCell);\n const [endRow, endCol] = getTableCellPos(endCell);\n\n const rowRange = {\n from: Math.min(startRow, endRow),\n to: Math.max(startRow, endRow),\n };\n\n const colRange = {\n from: Math.min(startCol, endCol),\n to: Math.max(startCol, endCol),\n };\n\n const results: string[][] = [];\n for (let rowIdx = rowRange.from; rowIdx <= rowRange.to; rowIdx++) {\n const row = tableBody.querySelector(\n `.vuuTableRow[aria-rowindex='${rowIdx + 1}']`,\n );\n const rowData = [];\n for (let colIdx = colRange.from; colIdx <= colRange.to; colIdx++) {\n const cell = row?.querySelector(\n `.vuuTableCell[aria-colindex='${colIdx + 1}']`,\n );\n if (cell) {\n rowData.push(cell.textContent ?? \"\");\n }\n }\n results.push(rowData);\n }\n return results.map((r) => r.join(\"\\t\")).join(\"\\n\");\n};\n"],"names":["queryClosest","getTableCellPos"],"mappings":";;;;;AA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QAAW,GAAA;AAAA,IACf,IAAM,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,IAC/B,EAAI,EAAA,IAAA,CAAK,GAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,GAC/B,CAAA;AAEA,EAAA,MAAM,UAAsB,EAAC,CAAA;AAC7B,EAAA,KAAA,IAAS,SAAS,QAAS,CAAA,IAAA,EAAM,MAAU,IAAA,QAAA,CAAS,IAAI,MAAU,EAAA,EAAA;AAChE,IAAA,MAAM,MAAM,SAAU,CAAA,aAAA;AAAA,MACpB,CAAA,4BAAA,EAA+B,SAAS,CAAC,CAAA,EAAA,CAAA;AAAA,KAC3C,CAAA;AACA,IAAA,MAAM,UAAU,EAAC,CAAA;AACjB,IAAA,KAAA,IAAS,SAAS,QAAS,CAAA,IAAA,EAAM,MAAU,IAAA,QAAA,CAAS,IAAI,MAAU,EAAA,EAAA;AAChE,MAAA,MAAM,OAAO,GAAK,EAAA,aAAA;AAAA,QAChB,CAAA,6BAAA,EAAgC,SAAS,CAAC,CAAA,EAAA,CAAA;AAAA,OAC5C,CAAA;AACA,MAAA,IAAI,IAAM,EAAA;AACR,QAAQ,OAAA,CAAA,IAAA,CAAK,IAAK,CAAA,WAAA,IAAe,EAAE,CAAA,CAAA;AAAA,OACrC;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,KAAK,OAAO,CAAA,CAAA;AAAA,GACtB;AACA,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,KAAK,GAAI,CAAC,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AACnD;;;;;;;;;;;"}
@@ -3,23 +3,11 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var vuuUtils = require('@vuu-ui/vuu-utils');
5
5
  var react = require('react');
6
+ var tableDomUtils = require('../table-dom-utils.js');
6
7
  var CellBlock = require('./CellBlock.js');
7
8
  var cellblockUtils = require('./cellblock-utils.js');
8
9
 
9
- const Hi = Number.MAX_SAFE_INTEGER;
10
- const refState = {
11
- cellBlock: null,
12
- cellBlockClassName: "",
13
- dragState: "pending",
14
- endBox: { bottom: -1, left: Hi, right: -1, top: Hi },
15
- endCell: null,
16
- mousePosX: -1,
17
- mousePosY: -1,
18
- mouseStartX: -1,
19
- mouseStartY: -1,
20
- startBox: { bottom: -1, left: -1, right: -1, top: -1 },
21
- startCell: null
22
- };
10
+ const clone = (posTuple) => posTuple.slice();
23
11
  const NullHandler = () => console.error("no handler installed");
24
12
  const mouseHandlers = {
25
13
  mouseMove: NullHandler,
@@ -31,22 +19,43 @@ const mouseType = (name) => name.startsWith("mouseMove") ? "mousemove" : "mouseu
31
19
  const DRAG_THRESHOLD = 5;
32
20
  const useCellBlockSelection = ({
33
21
  allowCellBlockSelection,
34
- onSelectCellBlock
22
+ columnCount = 0,
23
+ containerRef,
24
+ focusCell,
25
+ onSelectCellBlock,
26
+ rowCount = 0
35
27
  }) => {
36
28
  const [cellBlock, setCellBlock] = react.useState(null);
37
- const stateRef = react.useRef(refState);
29
+ const stateRef = react.useRef(cellblockUtils.refState);
38
30
  const handlersRef = react.useRef(mouseHandlers);
31
+ const handleCopy = react.useCallback(async () => {
32
+ const { startCell, endCell } = stateRef.current;
33
+ if (startCell && endCell) {
34
+ const tsvText = cellblockUtils.getTextFromCells(startCell, endCell);
35
+ const type = "text/plain";
36
+ const blob = new Blob([tsvText], { type });
37
+ const data = [new ClipboardItem({ [type]: blob })];
38
+ await navigator.clipboard.write(data);
39
+ }
40
+ }, []);
39
41
  const cellBlockRef = react.useCallback((el) => {
40
42
  stateRef.current.cellBlock = el;
41
43
  }, []);
42
- const createCellBlock = react.useCallback(() => {
43
- const { startBox, startCell } = stateRef.current;
44
- if (startCell) {
45
- cellblockUtils.setElementBox(startCell, startBox);
46
- startCell.classList.add("vuu-cellblock-start");
47
- setCellBlock(/* @__PURE__ */ jsxRuntime.jsx(CellBlock.CellBlock, { ref: cellBlockRef }));
48
- }
49
- }, [cellBlockRef]);
44
+ const createCellBlock = react.useCallback(
45
+ (method = "mouse") => {
46
+ const { startBox, startCell } = stateRef.current;
47
+ if (startCell) {
48
+ const table = vuuUtils.queryClosest(startCell, ".vuuTable");
49
+ if (table) {
50
+ table.classList.add(`vuu-cellblock-select-in-progress-${method}`);
51
+ }
52
+ cellblockUtils.setElementBox(startCell, startBox);
53
+ startCell.classList.add("vuu-cellblock-start");
54
+ setCellBlock(/* @__PURE__ */ jsxRuntime.jsx(CellBlock.CellBlock, { onCopy: handleCopy, ref: cellBlockRef }));
55
+ }
56
+ },
57
+ [cellBlockRef, handleCopy]
58
+ );
50
59
  const initializeStateRef = react.useCallback(() => {
51
60
  const { cellBlock: cellBlock2, cellBlockClassName, startCell, endCell } = stateRef.current;
52
61
  if (startCell) {
@@ -58,12 +67,14 @@ const useCellBlockSelection = ({
58
67
  if (cellBlock2?.classList.contains(cellBlockClassName)) {
59
68
  cellBlock2.classList.remove(cellBlockClassName);
60
69
  }
61
- const { endBox, startBox } = refState;
70
+ const { endBox, startBox } = cellblockUtils.refState;
62
71
  stateRef.current = {
63
- ...refState,
72
+ ...cellblockUtils.refState,
64
73
  cellBlock: cellBlock2,
65
74
  endBox: { ...endBox },
66
- startBox: { ...startBox }
75
+ endPos: [-1, -1],
76
+ startBox: { ...startBox },
77
+ startPos: [-1, -1]
67
78
  };
68
79
  }, []);
69
80
  const addMouseListener = react.useCallback(
@@ -78,32 +89,16 @@ const useCellBlockSelection = ({
78
89
  }, []);
79
90
  handlersRef.current.mouseMove = react.useCallback((evt) => {
80
91
  const { clientX: x, clientY: y } = evt;
81
- const { cellBlock: cellBlock2, cellBlockClassName, endBox, startBox } = stateRef.current;
92
+ const { endBox, startBox } = stateRef.current;
82
93
  if (cellblockUtils.outsideBox(startBox, x, y) && cellblockUtils.outsideBox(endBox, x, y)) {
83
94
  const cell = vuuUtils.queryClosest(
84
95
  evt.target,
85
96
  ".vuuTableCell, .vuuCellBlock"
86
97
  );
87
- const table = vuuUtils.queryClosest(cell, ".vuuTable");
88
- if (table) {
89
- table.classList.add("vuu-cellblock-select-in-progress");
90
- }
91
98
  if (cell?.classList.contains("vuuTableCell")) {
92
99
  cellblockUtils.setElementBox(cell, endBox);
93
100
  stateRef.current.endCell = cell;
94
- const endBlockDirection = cellblockUtils.getEndCellDirection(startBox, endBox);
95
- const newCellBlockClassName = `cellblock-direction-${endBlockDirection}`;
96
- if (newCellBlockClassName !== cellBlockClassName) {
97
- if (cellBlockClassName) {
98
- cellBlock2?.classList.replace(
99
- cellBlockClassName,
100
- newCellBlockClassName
101
- );
102
- } else {
103
- cellBlock2?.classList.add(newCellBlockClassName);
104
- }
105
- stateRef.current.cellBlockClassName = newCellBlockClassName;
106
- }
101
+ cellblockUtils.updateCellBlockClassName(stateRef.current);
107
102
  }
108
103
  }
109
104
  }, []);
@@ -111,16 +106,19 @@ const useCellBlockSelection = ({
111
106
  (evt) => {
112
107
  removeMouseListener("mouseMove");
113
108
  removeMouseListener("mouseUp");
114
- const { endCell, startCell } = stateRef.current;
109
+ const { cellBlock: cellBlock2, endCell, startCell } = stateRef.current;
115
110
  const table = vuuUtils.queryClosest(evt.target, ".vuuTable");
116
111
  endCell?.classList.add("vuu-cellblock-end");
117
112
  if (table) {
118
- table.classList.remove("vuu-cellblock-select-in-progress");
113
+ table.classList.remove("vuu-cellblock-select-in-progress-mouse");
119
114
  }
120
115
  if (startCell && endCell) {
121
116
  const tableCellBlock = cellblockUtils.getTableCellBlock(startCell, endCell);
122
117
  onSelectCellBlock?.(tableCellBlock);
123
118
  }
119
+ if (cellBlock2) {
120
+ cellBlock2.focus();
121
+ }
124
122
  },
125
123
  [onSelectCellBlock, removeMouseListener]
126
124
  );
@@ -135,7 +133,7 @@ const useCellBlockSelection = ({
135
133
  Math.abs(y - mouseStartY)
136
134
  );
137
135
  if (distance > DRAG_THRESHOLD) {
138
- createCellBlock();
136
+ createCellBlock("mouse");
139
137
  const { mouseMove, mouseUp } = handlersRef.current;
140
138
  removeMouseListener("mouseMovePreDrag");
141
139
  removeMouseListener("mouseUpPreDrag");
@@ -165,17 +163,15 @@ const useCellBlockSelection = ({
165
163
  },
166
164
  [addMouseListener, initializeStateRef]
167
165
  );
168
- const shiftingRef = react.useRef(false);
169
- const cellBlockEndRef = react.useRef([0, 0]);
170
166
  const nativeKeyDownHandlerRef = react.useRef(NullHandler);
171
167
  const handleNativeKeyUp = react.useCallback((evt) => {
172
168
  if (evt.key === "Shift") {
173
- const { current: pos } = cellBlockEndRef;
174
- if (pos[0] || pos[1]) {
175
- console.log(`cell selection [${pos[0]},${pos[1]}]`);
169
+ const { endCell } = stateRef.current;
170
+ const table = vuuUtils.queryClosest(evt.target, ".vuuTable");
171
+ endCell?.classList.add("vuu-cellblock-end");
172
+ if (table) {
173
+ table.classList.remove("vuu-cellblock-select-in-progress-keyboard");
176
174
  }
177
- console.log("abandon cellblock selection");
178
- shiftingRef.current = false;
179
175
  window.removeEventListener("keydown", nativeKeyDownHandlerRef.current, {
180
176
  capture: true
181
177
  });
@@ -185,33 +181,32 @@ const useCellBlockSelection = ({
185
181
  }
186
182
  }, []);
187
183
  const handleNativeKeyDown = nativeKeyDownHandlerRef.current = react.useCallback(
188
- (evt) => {
189
- if (evt.key.startsWith("Arrow")) {
190
- const { current: pos } = cellBlockEndRef;
191
- switch (evt.key) {
192
- case "ArrowRight":
193
- pos[0] += 1;
194
- break;
195
- case "ArrowLEFT":
196
- pos[0] -= 1;
197
- break;
198
- case "ArrowUP":
199
- pos[1] -= 1;
200
- break;
201
- case "ArrowDown":
202
- pos[1] += 1;
203
- break;
184
+ ({ key }) => {
185
+ if (vuuUtils.isArrowKey(key)) {
186
+ const { endBox, endPos, startBox } = stateRef.current;
187
+ if (cellblockUtils.isNullCellBox(startBox)) {
188
+ createCellBlock("keyboard");
204
189
  }
190
+ const nextCell = tableDomUtils.getNextCellPos(key, endPos, columnCount, rowCount);
191
+ stateRef.current.endPos = nextCell;
192
+ focusCell(nextCell);
193
+ const cell = tableDomUtils.getTableCell(containerRef, nextCell);
194
+ stateRef.current.endCell = cell;
195
+ cellblockUtils.setElementBox(cell, endBox);
196
+ cellblockUtils.updateCellBlockClassName(stateRef.current);
205
197
  }
206
198
  },
207
- []
199
+ [columnCount, containerRef, createCellBlock, focusCell, rowCount]
208
200
  );
209
201
  const handleKeyDown = react.useCallback(
210
202
  (evt) => {
211
203
  if (evt.key === "Shift") {
212
- shiftingRef.current = true;
204
+ initializeStateRef();
213
205
  const cell = vuuUtils.queryClosest(evt.target, ".vuuTableCell");
214
206
  if (cell) {
207
+ const startPos = tableDomUtils.getTableCellPos(cell);
208
+ stateRef.current.startPos = startPos;
209
+ stateRef.current.endPos = clone(startPos);
215
210
  const { current: state } = stateRef;
216
211
  state.startCell = cell;
217
212
  window.addEventListener("keydown", handleNativeKeyDown, {
@@ -224,7 +219,7 @@ const useCellBlockSelection = ({
224
219
  }
225
220
  }
226
221
  },
227
- [handleNativeKeyDown, handleNativeKeyUp]
222
+ [handleNativeKeyDown, handleNativeKeyUp, initializeStateRef]
228
223
  );
229
224
  return {
230
225
  cellBlock,