@vuu-ui/vuu-table 0.13.33 → 0.13.35
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.
- package/cjs/Row.js +1 -0
- package/cjs/Row.js.map +1 -1
- package/cjs/Table.js +4 -0
- package/cjs/Table.js.map +1 -1
- package/cjs/header-cell/HeaderCell.js +7 -2
- package/cjs/header-cell/HeaderCell.js.map +1 -1
- package/cjs/useTable.js +24 -3
- package/cjs/useTable.js.map +1 -1
- package/cjs/useTableModel.js +2 -0
- package/cjs/useTableModel.js.map +1 -1
- package/esm/Row.js +1 -0
- package/esm/Row.js.map +1 -1
- package/esm/Table.js +4 -0
- package/esm/Table.js.map +1 -1
- package/esm/header-cell/HeaderCell.js +7 -2
- package/esm/header-cell/HeaderCell.js.map +1 -1
- package/esm/useTable.js +24 -3
- package/esm/useTable.js.map +1 -1
- package/esm/useTableModel.js +2 -0
- package/esm/useTableModel.js.map +1 -1
- package/package.json +10 -10
- package/types/Table.d.ts +8 -2
- package/types/useTableModel.d.ts +1 -0
package/cjs/Row.js
CHANGED
package/cjs/Row.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../../packages/vuu-table/src/Row.tsx"],"sourcesContent":["import { RowProps, RuntimeColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n RowSelected,\n isGroupColumn,\n isJsonColumn,\n isJsonGroup,\n isNotHidden,\n metadataKeys,\n queryClosest,\n} from \"@vuu-ui/vuu-utils\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport { MouseEvent, forwardRef, memo, useCallback } from \"react\";\nimport { TableCell, TableGroupCell } from \"./table-cell\";\n\nimport rowCss from \"./Row.css\";\nimport { VirtualColSpan } from \"./VirtualColSpan\";\n\nconst { COUNT, DEPTH, IDX, IS_EXPANDED, IS_LEAF, SELECTED } = metadataKeys;\nconst classBase = \"vuuTableRow\";\n\n// A dummy Table Row rendered once and not visible. We measure this to\n// determine height of Row(s) and monitor it for size changes (in\n// case of runtime density switch). This allows ListItem height to\n// be controlled purely through CSS.\nexport const RowProxy = forwardRef<HTMLDivElement, { height?: number }>(\n function RowProxy({ height }, forwardedRef) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table-row\",\n css: rowCss,\n window: targetWindow,\n });\n\n return (\n <div\n aria-hidden\n className={cx(classBase, `${classBase}-proxy`)}\n ref={forwardedRef}\n style={{ height }}\n />\n );\n },\n);\n\n// export const Row = memo(\nexport const Row = memo(\n ({\n className: classNameProp,\n classNameGenerator,\n columnMap,\n columns,\n groupToggleTarget = \"group-column\",\n highlighted,\n row,\n offset,\n onCellEdit,\n onClick,\n onDataEdited,\n onToggleGroup,\n searchPattern,\n showBookends = true,\n virtualColSpan = 0,\n zebraStripes = false,\n ...htmlAttributes\n }: RowProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table-row\",\n css: rowCss,\n window: targetWindow,\n });\n\n const {\n [COUNT]: childRowCount,\n [DEPTH]: depth,\n [IDX]: rowIndex,\n [IS_EXPANDED]: isExpanded,\n [IS_LEAF]: isLeaf,\n [SELECTED]: selectionStatus,\n } = row;\n\n const handleRowClick = useCallback(\n (evt: MouseEvent<HTMLDivElement>) => {\n const rangeSelect = evt.shiftKey;\n const keepExistingSelection = evt.ctrlKey || evt.metaKey; /* mac only */\n onClick?.(evt, row, rangeSelect, keepExistingSelection);\n },\n [onClick, row],\n );\n\n const { True, First, Last } = RowSelected;\n\n const className = cx(\n classBase,\n classNameProp,\n classNameGenerator?.(row, columnMap),\n {\n [`${classBase}-even`]: zebraStripes && rowIndex % 2 === 0,\n [`${classBase}-highlighted`]: highlighted,\n [`${classBase}-selected`]: selectionStatus & True,\n [`${classBase}-selectedStart`]: selectionStatus & First,\n [`${classBase}-selectedEnd`]: selectionStatus & Last,\n },\n );\n\n const canExpand = isLeaf === false && childRowCount > 0;\n const ariaExpanded = isExpanded ? true : canExpand ? false : undefined;\n const ariaLevel = isLeaf && depth === 1 ? undefined : depth;\n\n // const style = { transform: `translate3d(0px, ${offset}px, 0px)` };\n const style = { top: offset };\n\n const handleGroupCellClick = useCallback(\n (evt: MouseEvent, column: RuntimeColumnDescriptor) => {\n if (isGroupColumn(column) || isJsonGroup(column, row, columnMap)) {\n const toggleIconClicked =\n queryClosest(evt.target, \".vuuToggleIconButton\") !== null;\n if (groupToggleTarget === \"toggle-icon\") {\n if (!toggleIconClicked) {\n return;\n }\n }\n if (toggleIconClicked) {\n // prevent evt bubbling, will suppress selection hook.\n // Clicking the toggle icon directly never triggers row selection\n evt.stopPropagation();\n }\n onToggleGroup?.(row, column);\n }\n },\n [columnMap, groupToggleTarget, onToggleGroup, row],\n );\n\n return (\n <div\n {...htmlAttributes}\n aria-expanded={ariaExpanded}\n aria-level={ariaLevel}\n role=\"row\"\n className={className}\n onClick={handleRowClick}\n style={style}\n >\n {showBookends ? (\n <span className={`${classBase}-selectionDecorator vuuStickyLeft`} />\n ) : null}\n <VirtualColSpan width={virtualColSpan} />\n {columns.filter(isNotHidden).map((column) => {\n const isGroup = isGroupColumn(column);\n const isJsonCell = isJsonColumn(column);\n const Cell = isGroup && !isJsonCell ? TableGroupCell : TableCell;\n\n return (\n <Cell\n column={column}\n columnMap={columnMap}\n key={column.name}\n onClick={isGroup || isJsonCell ? handleGroupCellClick : undefined}\n onDataEdited={onDataEdited}\n row={row}\n searchPattern={searchPattern}\n />\n );\n })}\n {showBookends ? (\n <span className={`${classBase}-selectionDecorator vuuStickyRight`} />\n ) : null}\n </div>\n );\n },\n);\nRow.displayName = \"Row\";\n"],"names":["metadataKeys","forwardRef","RowProxy","useWindow","useComponentCssInjection","rowCss","jsx","memo","useCallback","RowSelected","isGroupColumn","isJsonGroup","queryClosest","jsxs","VirtualColSpan","isNotHidden","isJsonColumn","TableGroupCell","TableCell"],"mappings":";;;;;;;;;;;;;AAmBA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BAAe,EAAA,EAAA,KAAA,EAAO,cAAgB,EAAA,CAAA;AAAA,UACtC,QAAQ,MAAO,CAAAC,oBAAW,CAAE,CAAA,GAAA,CAAI,CAAC,MAAW,KAAA;AAC3C,YAAM,MAAA,OAAA,GAAUL,uBAAc,MAAM,CAAA;AACpC,YAAM,MAAA,UAAA,GAAaM,sBAAa,MAAM,CAAA;AACtC,YAAA,MAAM,IAAO,GAAA,OAAA,IAAW,CAAC,UAAA,GAAaC,6BAAiB,GAAAC,mBAAA;AAEvD,YACE,uBAAAZ,cAAA;AAAA,cAAC,IAAA;AAAA,cAAA;AAAA,gBACC,MAAA;AAAA,gBACA,SAAA;AAAA,gBAEA,OAAA,EAAS,OAAW,IAAA,UAAA,GAAa,oBAAuB,GAAA,KAAA,CAAA;AAAA,gBACxD,YAAA;AAAA,gBACA,GAAA;AAAA,gBACA;AAAA,eAAA;AAAA,cAJK,MAAO,CAAA;AAAA,aAKd;AAAA,WAEH,CAAA;AAAA,UACA,+BACEA,cAAA,CAAA,MAAA,EAAA,EAAK,WAAW,CAAG,EAAA,SAAS,sCAAsC,CACjE,GAAA;AAAA;AAAA;AAAA,KACN;AAAA;AAGN;AACA,GAAA,CAAI,WAAc,GAAA,KAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../../packages/vuu-table/src/Row.tsx"],"sourcesContent":["import { RowProps, RuntimeColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n RowSelected,\n isGroupColumn,\n isJsonColumn,\n isJsonGroup,\n isNotHidden,\n metadataKeys,\n queryClosest,\n} from \"@vuu-ui/vuu-utils\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport { MouseEvent, forwardRef, memo, useCallback } from \"react\";\nimport { TableCell, TableGroupCell } from \"./table-cell\";\n\nimport rowCss from \"./Row.css\";\nimport { VirtualColSpan } from \"./VirtualColSpan\";\n\nconst { COUNT, DEPTH, IDX, IS_EXPANDED, IS_LEAF, SELECTED } = metadataKeys;\nconst classBase = \"vuuTableRow\";\n\n// A dummy Table Row rendered once and not visible. We measure this to\n// determine height of Row(s) and monitor it for size changes (in\n// case of runtime density switch). This allows ListItem height to\n// be controlled purely through CSS.\nexport const RowProxy = forwardRef<HTMLDivElement, { height?: number }>(\n function RowProxy({ height }, forwardedRef) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table-row\",\n css: rowCss,\n window: targetWindow,\n });\n\n return (\n <div\n aria-hidden\n className={cx(classBase, `${classBase}-proxy`)}\n ref={forwardedRef}\n style={{ height }}\n />\n );\n },\n);\n\n// export const Row = memo(\nexport const Row = memo(\n ({\n className: classNameProp,\n classNameGenerator,\n columnMap,\n columns,\n groupToggleTarget = \"group-column\",\n highlighted,\n row,\n offset,\n onCellEdit,\n onClick,\n onDataEdited,\n onToggleGroup,\n searchPattern,\n showBookends = true,\n virtualColSpan = 0,\n zebraStripes = false,\n ...htmlAttributes\n }: RowProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-table-row\",\n css: rowCss,\n window: targetWindow,\n });\n\n const {\n [COUNT]: childRowCount,\n [DEPTH]: depth,\n [IDX]: rowIndex,\n [IS_EXPANDED]: isExpanded,\n [IS_LEAF]: isLeaf,\n [SELECTED]: selectionStatus,\n } = row;\n\n const handleRowClick = useCallback(\n (evt: MouseEvent<HTMLDivElement>) => {\n const rangeSelect = evt.shiftKey;\n const keepExistingSelection = evt.ctrlKey || evt.metaKey; /* mac only */\n onClick?.(evt, row, rangeSelect, keepExistingSelection);\n },\n [onClick, row],\n );\n\n const { True, First, Last } = RowSelected;\n\n const className = cx(\n classBase,\n classNameProp,\n classNameGenerator?.(row, columnMap),\n {\n [`${classBase}-even`]: zebraStripes && rowIndex % 2 === 0,\n [`${classBase}-highlighted`]: highlighted,\n [`${classBase}-selected`]: selectionStatus & True,\n [`${classBase}-selectedStart`]: selectionStatus & First,\n [`${classBase}-selectedEnd`]: selectionStatus & Last,\n },\n );\n\n const canExpand = isLeaf === false && childRowCount > 0;\n const ariaExpanded = isExpanded ? true : canExpand ? false : undefined;\n const ariaLevel = isLeaf && depth === 1 ? undefined : depth;\n\n // const style = { transform: `translate3d(0px, ${offset}px, 0px)` };\n const style = { top: offset };\n\n const handleGroupCellClick = useCallback(\n (evt: MouseEvent, column: RuntimeColumnDescriptor) => {\n if (isGroupColumn(column) || isJsonGroup(column, row, columnMap)) {\n const toggleIconClicked =\n queryClosest(evt.target, \".vuuToggleIconButton\") !== null;\n if (groupToggleTarget === \"toggle-icon\") {\n if (!toggleIconClicked) {\n return;\n }\n }\n if (toggleIconClicked) {\n // prevent evt bubbling, will suppress selection hook.\n // Clicking the toggle icon directly never triggers row selection\n evt.stopPropagation();\n }\n onToggleGroup?.(row, column);\n }\n },\n [columnMap, groupToggleTarget, onToggleGroup, row],\n );\n\n return (\n <div\n {...htmlAttributes}\n aria-expanded={ariaExpanded}\n aria-selected={selectionStatus & True ? \"true\" : undefined}\n aria-level={ariaLevel}\n role=\"row\"\n className={className}\n onClick={handleRowClick}\n style={style}\n >\n {showBookends ? (\n <span className={`${classBase}-selectionDecorator vuuStickyLeft`} />\n ) : null}\n <VirtualColSpan width={virtualColSpan} />\n {columns.filter(isNotHidden).map((column) => {\n const isGroup = isGroupColumn(column);\n const isJsonCell = isJsonColumn(column);\n const Cell = isGroup && !isJsonCell ? TableGroupCell : TableCell;\n\n return (\n <Cell\n column={column}\n columnMap={columnMap}\n key={column.name}\n onClick={isGroup || isJsonCell ? handleGroupCellClick : undefined}\n onDataEdited={onDataEdited}\n row={row}\n searchPattern={searchPattern}\n />\n );\n })}\n {showBookends ? (\n <span className={`${classBase}-selectionDecorator vuuStickyRight`} />\n ) : null}\n </div>\n );\n },\n);\nRow.displayName = \"Row\";\n"],"names":["metadataKeys","forwardRef","RowProxy","useWindow","useComponentCssInjection","rowCss","jsx","memo","useCallback","RowSelected","isGroupColumn","isJsonGroup","queryCl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KAAA;AAAA,QAEC,QAAA,EAAA;AAAA,UAAA,YAAA,kCACE,MAAK,EAAA,EAAA,SAAA,EAAW,CAAG,EAAA,SAAS,qCAAqC,CAChE,GAAA,IAAA;AAAA,0BACJP,cAAA,CAACQ,6BAAe,EAAA,EAAA,KAAA,EAAO,cAAgB,EAAA,CAAA;AAAA,UACtC,QAAQ,MAAO,CAAAC,oBAAW,CAAE,CAAA,GAAA,CAAI,CAAC,MAAW,KAAA;AAC3C,YAAM,MAAA,OAAA,GAAUL,uBAAc,MAAM,CAAA;AACpC,YAAM,MAAA,UAAA,GAAaM,sBAAa,MAAM,CAAA;AACtC,YAAA,MAAM,IAAO,GAAA,OAAA,IAAW,CAAC,UAAA,GAAaC,6BAAiB,GAAAC,mBAAA;AAEvD,YACE,uBAAAZ,cAAA;AAAA,cAAC,IAAA;AAAA,cAAA;AAAA,gBACC,MAAA;AAAA,gBACA,SAAA;AAAA,gBAEA,OAAA,EAAS,OAAW,IAAA,UAAA,GAAa,oBAAuB,GAAA,KAAA,CAAA;AAAA,gBACxD,YAAA;AAAA,gBACA,GAAA;AAAA,gBACA;AAAA,eAAA;AAAA,cAJK,MAAO,CAAA;AAAA,aAKd;AAAA,WAEH,CAAA;AAAA,UACA,+BACEA,cAAA,CAAA,MAAA,EAAA,EAAK,WAAW,CAAG,EAAA,SAAS,sCAAsC,CACjE,GAAA;AAAA;AAAA;AAAA,KACN;AAAA;AAGN;AACA,GAAA,CAAI,WAAc,GAAA,KAAA;;;;;"}
|
package/cjs/Table.js
CHANGED
|
@@ -50,6 +50,7 @@ const TableCore = ({
|
|
|
50
50
|
onSelectionChange,
|
|
51
51
|
renderBufferSize = 0,
|
|
52
52
|
revealSelected,
|
|
53
|
+
rowActionHandlers,
|
|
53
54
|
rowHeight,
|
|
54
55
|
rowToObject,
|
|
55
56
|
scrollingApiRef,
|
|
@@ -153,6 +154,7 @@ const TableCore = ({
|
|
|
153
154
|
{
|
|
154
155
|
dataSource,
|
|
155
156
|
menuActionHandler: handleColumnAction,
|
|
157
|
+
rowActionHandlers,
|
|
156
158
|
children: [
|
|
157
159
|
showPaginationControls !== true ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
158
160
|
"div",
|
|
@@ -283,6 +285,7 @@ const Table = react.forwardRef(function Table2({
|
|
|
283
285
|
onSelectionChange,
|
|
284
286
|
renderBufferSize,
|
|
285
287
|
revealSelected,
|
|
288
|
+
rowActionHandlers,
|
|
286
289
|
rowHeight: rowHeightProp,
|
|
287
290
|
rowToObject,
|
|
288
291
|
scrollingApiRef,
|
|
@@ -411,6 +414,7 @@ const Table = react.forwardRef(function Table2({
|
|
|
411
414
|
onSelectionChange,
|
|
412
415
|
renderBufferSize: showPaginationControls ? 0 : Math.max(5, renderBufferSize ?? 0),
|
|
413
416
|
revealSelected,
|
|
417
|
+
rowActionHandlers,
|
|
414
418
|
rowHeight,
|
|
415
419
|
rowToObject,
|
|
416
420
|
scrollingApiRef,
|
package/cjs/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../../packages/vuu-table/src/Table.tsx"],"sourcesContent":["import { useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport {\n DataSource,\n SchemaColumn,\n Selection,\n SelectionChangeHandler,\n} from \"@vuu-ui/vuu-data-types\";\nimport { TableProvider } from \"@vuu-ui/vuu-table-extras\";\nimport {\n CustomHeader,\n DataCellEditNotification,\n GroupToggleTarget,\n RowProps,\n ShowColumnHeaderMenus,\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 ContextPanelProvider,\n DragStartHandler,\n MeasuredContainer,\n MeasuredContainerProps,\n MeasuredSize,\n dragStrategy,\n reduceSizeHeight,\n} from \"@vuu-ui/vuu-ui-controls\";\nimport {\n RowToObjectMapper,\n lowerCase,\n metadataKeys,\n useId,\n} from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport {\n CSSProperties,\n ComponentType,\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 { TableCellBlock } from \"./cell-block/cellblock-utils\";\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\";\n\nconst classBase = \"vuuTable\";\n\nconst { IDX, RENDER_IDX } = metadataKeys;\n\nexport type TableNavigationStyle = \"none\" | \"cell\" | \"row\" | \"tree\";\n\nexport interface TableProps\n extends Omit<\n MeasuredContainerProps,\n \"onDragStart\" | \"onDrop\" | \"onSelect\" | \"searchPattern\"\n > {\n /**\n * A react function componnet that will be rendered if there are no rows to display\n */\n EmptyDisplay?: ComponentType;\n Row?: FC<RowProps>;\n /**\n * Allow a block of cells to be selected. Typically to be copied.\n */\n allowCellBlockSelection?: 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\n /**\n * define rows ro be initially selected based on row index positions\n */\n defaultSelectedIndexValues?: Selection;\n /**\n * define rows ro be initially selected based on row key value. Not all DataSource\n * implementations support this feature.\n */\n defaultSelectedKeyValues?: string[];\n\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 * When rows are grouped, user can click group row(s) to expand/collapse display of child rows.\n * This allows precise configuration of where user may click to trigger toggle/collapse. When\n * row selection is also supported, clicking outside the region specified here will select or\n * deselect the row.\n * - toggle-icon - the small toggle icon must be clicked directly\n * - group-column (default) - user can click anywhere within the group column, i.e on the icon or the column text\n */\n groupToggleTarget?: GroupToggleTarget;\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 * `tree` is a specialised navigation behaviour only useful where table is being\n * used to present purely grouped data (see TreeTable)\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\n /**\n * In a Table with editable cells, this callback will be invoked every time\n * a user performs any edit operation on an editable field.\n */\n onDataEdited?: DataCellEditNotification;\n\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 /**\n * When a row is selected and onSelect provided, onSelect will be invoked with a\n * DataSourceRowObject, derived from the internal representation of a data row,\n * DataSourceRow. The data attribute of DataSourceRowObject is a simple map of\n * column.name : value.\n * This prop allows a custom function to be provided to make the conversion from\n * DataSourceRow to DataSourceRowObject. It will very rarely be needed. It is\n * used by the Treetable.\n */\n rowToObject?: RowToObjectMapper;\n\n /**\n * Only applicable to grouped data. If there are selected rows which are not top-level\n * items and group items above are not already expanded, expand all group items in\n * the hierarchy above selected item. Selected items will thus always be visible, initially.\n * This affects items set at load time via defaultSelectedKeyValues as well as items\n * selected programatically (ie not directly by user).\n * Nodes can of course be collapsed by user at runtime which may hide selected rows.\n * Note: this is not supported by all DataSource implementations\n */\n revealSelected?: boolean;\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 * If a search has been applied against data, this is the search text used.\n * Will be used to highlight matching text.\n */\n searchPattern?: string;\n /**\n * Selection Bookends style the left and right edge of a selection block.\n * They are optional, value currently defaults to 4.\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. If true, all available Column Menu\n * actions will be available via the menu. Alternatively, a map of specific column menu\n * permissions can be provided to allow control over which menu items are presented.\n */\n showColumnHeaderMenus?: ShowColumnHeaderMenus;\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 EmptyDisplay,\n Row = DefaultRow,\n allowCellBlockSelection,\n allowDragColumnHeader = true,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\n defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus = false,\n groupToggleTarget,\n highlightedIndex: highlightedIndexProp,\n id: idProp,\n lowerCaseSearchPattern,\n navigationStyle = \"cell\",\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited: onDataEditedProp,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize = 0,\n revealSelected,\n rowHeight,\n rowToObject,\n scrollingApiRef,\n selectionBookendWidth = 0,\n selectionModel = \"extended\",\n showColumnHeaders = true,\n showColumnHeaderMenus = true,\n showPaginationControls,\n size,\n}: Omit<\n TableProps,\n \"maxViewportRowLimit\" | \"rowHeight\" | \"searchPattern\" | \"viewportRowLimit\"\n> & {\n containerRef: RefObject<HTMLDivElement | null>;\n /**\n * We lowercase this once, on entry, which is the format in which it will be used.\n */\n lowerCaseSearchPattern: Lowercase<string>;\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 handleColumnAction,\n headerState: { height: headerHeight, count: headerCount },\n headings,\n highlightedIndex,\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 defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus,\n highlightedIndex: highlightedIndexProp,\n id,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited: onDataEditedProp,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n revealSelected,\n rowHeight,\n rowToObject,\n scrollingApiRef,\n selectionBookendWidth,\n selectionModel,\n showColumnHeaders,\n showColumnHeaderMenus,\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 if (dataSource.size === 0 && EmptyDisplay) {\n return <EmptyDisplay />;\n }\n\n return (\n <TableProvider\n dataSource={dataSource}\n menuActionHandler={handleColumnAction}\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 columns={columns}\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 const ariaRowIndex = data[IDX] + headerCount + 1;\n return (\n <Row\n aria-rowindex={ariaRowIndex}\n classNameGenerator={rowClassNameGenerator}\n columnMap={columnMap}\n columns={scrollProps.columnsWithinViewport}\n groupToggleTarget={groupToggleTarget}\n highlighted={highlightedIndex === ariaRowIndex}\n key={data[RENDER_IDX]}\n onClick={onRowClick}\n onDataEdited={onDataEdited}\n row={data}\n offset={showPaginationControls ? 0 : getRowOffset(data)}\n onToggleGroup={onToggleGroup}\n showBookends={selectionBookendWidth > 0}\n searchPattern={lowerCaseSearchPattern}\n virtualColSpan={scrollProps.virtualColSpan}\n zebraStripes={tableAttributes.zebraStripes}\n />\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 aria-hidden={true}\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 </TableProvider>\n );\n};\n\nexport const Table = forwardRef(function Table(\n {\n EmptyDisplay,\n Row,\n allowCellBlockSelection,\n allowDragColumnHeader,\n allowDragDrop,\n availableColumns,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\n defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus,\n groupToggleTarget,\n height,\n highlightedIndex,\n id,\n maxViewportRowLimit,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n revealSelected,\n rowHeight: rowHeightProp,\n rowToObject,\n scrollingApiRef,\n searchPattern = \"\",\n selectionBookendWidth = 4,\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 if (defaultSelectedIndexValues && defaultSelectedKeyValues) {\n throw Error(\n `defaultSelectedIndexValues and defaultSelectedKeyValues can not be used in combination. Use at most one.`,\n );\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>(undefined);\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 <ContextPanelProvider>\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 ...styleProp,\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 EmptyDisplay={EmptyDisplay}\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 defaultSelectedIndexValues={defaultSelectedIndexValues}\n defaultSelectedKeyValues={defaultSelectedKeyValues}\n disableFocus={disableFocus}\n groupToggleTarget={groupToggleTarget}\n highlightedIndex={highlightedIndex}\n id={id}\n navigationStyle={navigationStyle}\n onAvailableColumnsChange={onAvailableColumnsChange}\n onConfigChange={onConfigChange}\n onDataEdited={onDataEdited}\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 revealSelected={revealSelected}\n rowHeight={rowHeight}\n rowToObject={rowToObject}\n scrollingApiRef={scrollingApiRef}\n lowerCaseSearchPattern={lowerCase(searchPattern)}\n selectionBookendWidth={selectionBookendWidth}\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 </ContextPanelProvider>\n );\n});\n"],"names":["metadataKeys","Row","DefaultRow","useId","useTable","jsxs","TableProvider","jsx","TableHeader","data","forwardRef","Table","useWindow","useComponentCssInjection","tableCss","useRef","useState","useMeasuredHeight","useCallback","size","useMemo","ContextPanelProvider","MeasuredContainer","useForkRef","RowProxy","lowerCase","reduceSizeHeight","PaginationControl"],"mappings":";;;;;;;;;;;;;;;;;;;AA6DA,MAAM,SAAY,GAAA,UAAA;AAElB,MAAM,EAAE,GAAK,EAAA,UAAA,EAAe,GAAAA,qBAAA;AA+M5B,MAAM,YAAY,CAAC;AAAA,EACjB,YAAA;AAAA,OACAC,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,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,YAAe,GAAA,KAAA;AAAA,EACf,iBAAA;AAAA,EACA,gBAAkB,EAAA,oBAAA;AAAA,EAClB,EAAI,EAAA,MAAA;AAAA,EACJ,sBAAA;AAAA,EACA,eAAkB,GAAA,MAAA;AAAA,EAClB,wBAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAc,EAAA,gBAAA;AAAA,EACd,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,cAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;A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A;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,cAAA;AAAA,YACA,SAAA;AAAA,YACA,WAAA;AAAA,YACA,eAAA;AAAA,YACA,sBAAA,EAAwBwB,mBAAU,aAAa,CAAA;AAAA,YAC/C,qBAAA;AAAA,YACA,cAAA;AAAA,YACA,iBAAA;AAAA,YACA,qBAAA;AAAA,YACA,sBAAA;AAAA,YACA,IAAA,EAAMC,8BAAiB,CAAA,IAAA,EAAM,YAAY;AAAA;AAAA,SAEzC,GAAA,IAAA;AAAA,QACH,sBACC,mBAAAnB,cAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,CAAG,EAAA,SAAS,CAAW,OAAA,CAAA,EAAA,GAAA,EAAK,SAC1C,EAAA,QAAA,kBAAAA,cAAA,CAACoB,mCAAkB,EAAA,EAAA,UAAA,EAAwB,GAC7C,CACE,GAAA;AAAA;AAAA;AAAA,GAER,EAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../../packages/vuu-table/src/Table.tsx"],"sourcesContent":["import { useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport type {\n DataSource,\n SchemaColumn,\n Selection,\n SelectionChangeHandler,\n} from \"@vuu-ui/vuu-data-types\";\nimport { TableProvider } from \"@vuu-ui/vuu-table-extras\";\nimport {\n CustomHeader,\n DataCellEditNotification,\n GroupToggleTarget,\n RowActionHandler,\n RowProps,\n ShowColumnHeaderMenus,\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 ContextPanelProvider,\n DragStartHandler,\n MeasuredContainer,\n MeasuredContainerProps,\n MeasuredSize,\n dragStrategy,\n reduceSizeHeight,\n} from \"@vuu-ui/vuu-ui-controls\";\nimport {\n RowToObjectMapper,\n lowerCase,\n metadataKeys,\n useId,\n} from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport {\n CSSProperties,\n ComponentType,\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 { TableCellBlock } from \"./cell-block/cellblock-utils\";\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\";\n\nconst classBase = \"vuuTable\";\n\nconst { IDX, RENDER_IDX } = metadataKeys;\n\nexport type TableNavigationStyle = \"none\" | \"cell\" | \"row\" | \"tree\";\n\nexport interface TableProps\n extends Omit<\n MeasuredContainerProps,\n \"onDragStart\" | \"onDrop\" | \"onSelect\" | \"searchPattern\"\n > {\n /**\n * A react function componnet that will be rendered if there are no rows to display\n */\n EmptyDisplay?: ComponentType;\n Row?: FC<RowProps>;\n /**\n * Allow a block of cells to be selected. Typically to be copied.\n */\n allowCellBlockSelection?: 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\n /**\n * define rows ro be initially selected based on row index positions\n */\n defaultSelectedIndexValues?: Selection;\n /**\n * define rows ro be initially selected based on row key value. Not all DataSource\n * implementations support this feature.\n */\n defaultSelectedKeyValues?: string[];\n\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 * When rows are grouped, user can click group row(s) to expand/collapse display of child rows.\n * This allows precise configuration of where user may click to trigger toggle/collapse. When\n * row selection is also supported, clicking outside the region specified here will select or\n * deselect the row.\n * - toggle-icon - the small toggle icon must be clicked directly\n * - group-column (default) - user can click anywhere within the group column, i.e on the icon or the column text\n */\n groupToggleTarget?: GroupToggleTarget;\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 * `tree` is a specialised navigation behaviour only useful where table is being\n * used to present purely grouped data (see TreeTable)\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\n /**\n * In a Table with editable cells, this callback will be invoked every time\n * a user performs any edit operation on an editable field.\n */\n onDataEdited?: DataCellEditNotification;\n\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 /**\n * Provide functionality for custom row actions. e.g. buttons embedded within row cells.\n * These will be available to any custom renderers via TableContext. e.g. a Row may\n * provide a 'Delete' or 'Cancel' button. Implement this functionality in a rowActionHandler.\n */\n rowActionHandlers?: Record<string, RowActionHandler>;\n /**\n * When a row is selected and onSelect provided, onSelect will be invoked with a\n * DataSourceRowObject, derived from the internal representation of a data row,\n * DataSourceRow. The data attribute of DataSourceRowObject is a simple map of\n * column.name : value.\n * This prop allows a custom function to be provided to make the conversion from\n * DataSourceRow to DataSourceRowObject. It will very rarely be needed. It is\n * used by the Treetable.\n */\n rowToObject?: RowToObjectMapper;\n\n /**\n * Only applicable to grouped data. If there are selected rows which are not top-level\n * items and group items above are not already expanded, expand all group items in\n * the hierarchy above selected item. Selected items will thus always be visible, initially.\n * This affects items set at load time via defaultSelectedKeyValues as well as items\n * selected programatically (ie not directly by user).\n * Nodes can of course be collapsed by user at runtime which may hide selected rows.\n * Note: this is not supported by all DataSource implementations\n */\n revealSelected?: boolean;\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 * If a search has been applied against data, this is the search text used.\n * Will be used to highlight matching text.\n */\n searchPattern?: string;\n /**\n * Selection Bookends style the left and right edge of a selection block.\n * They are optional, value currently defaults to 4.\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. If true, all available Column Menu\n * actions will be available via the menu. Alternatively, a map of specific column menu\n * permissions can be provided to allow control over which menu items are presented.\n */\n showColumnHeaderMenus?: ShowColumnHeaderMenus;\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 EmptyDisplay,\n Row = DefaultRow,\n allowCellBlockSelection,\n allowDragColumnHeader = true,\n allowDragDrop,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\n defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus = false,\n groupToggleTarget,\n highlightedIndex: highlightedIndexProp,\n id: idProp,\n lowerCaseSearchPattern,\n navigationStyle = \"cell\",\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited: onDataEditedProp,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize = 0,\n revealSelected,\n rowActionHandlers,\n rowHeight,\n rowToObject,\n scrollingApiRef,\n selectionBookendWidth = 0,\n selectionModel = \"extended\",\n showColumnHeaders = true,\n showColumnHeaderMenus = true,\n showPaginationControls,\n size,\n}: Omit<\n TableProps,\n \"maxViewportRowLimit\" | \"rowHeight\" | \"searchPattern\" | \"viewportRowLimit\"\n> & {\n containerRef: RefObject<HTMLDivElement | null>;\n /**\n * We lowercase this once, on entry, which is the format in which it will be used.\n */\n lowerCaseSearchPattern: Lowercase<string>;\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 handleColumnAction,\n headerState: { height: headerHeight, count: headerCount },\n headings,\n highlightedIndex,\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 defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus,\n highlightedIndex: highlightedIndexProp,\n id,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited: onDataEditedProp,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick: onRowClickProp,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n revealSelected,\n rowHeight,\n rowToObject,\n scrollingApiRef,\n selectionBookendWidth,\n selectionModel,\n showColumnHeaders,\n showColumnHeaderMenus,\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 if (dataSource.size === 0 && EmptyDisplay) {\n return <EmptyDisplay />;\n }\n\n return (\n <TableProvider\n dataSource={dataSource}\n menuActionHandler={handleColumnAction}\n rowActionHandlers={rowActionHandlers}\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 columns={columns}\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 const ariaRowIndex = data[IDX] + headerCount + 1;\n return (\n <Row\n aria-rowindex={ariaRowIndex}\n classNameGenerator={rowClassNameGenerator}\n columnMap={columnMap}\n columns={scrollProps.columnsWithinViewport}\n groupToggleTarget={groupToggleTarget}\n highlighted={highlightedIndex === ariaRowIndex}\n key={data[RENDER_IDX]}\n onClick={onRowClick}\n onDataEdited={onDataEdited}\n row={data}\n offset={showPaginationControls ? 0 : getRowOffset(data)}\n onToggleGroup={onToggleGroup}\n showBookends={selectionBookendWidth > 0}\n searchPattern={lowerCaseSearchPattern}\n virtualColSpan={scrollProps.virtualColSpan}\n zebraStripes={tableAttributes.zebraStripes}\n />\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 aria-hidden={true}\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 </TableProvider>\n );\n};\n\nexport const Table = forwardRef(function Table(\n {\n EmptyDisplay,\n Row,\n allowCellBlockSelection,\n allowDragColumnHeader,\n allowDragDrop,\n availableColumns,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\n defaultSelectedIndexValues,\n defaultSelectedKeyValues,\n disableFocus,\n groupToggleTarget,\n height,\n highlightedIndex,\n id,\n maxViewportRowLimit,\n navigationStyle,\n onAvailableColumnsChange,\n onConfigChange,\n onDataEdited,\n onDragStart,\n onDrop,\n onHighlight,\n onRowClick,\n onSelect,\n onSelectCellBlock,\n onSelectionChange,\n renderBufferSize,\n revealSelected,\n rowActionHandlers,\n rowHeight: rowHeightProp,\n rowToObject,\n scrollingApiRef,\n searchPattern = \"\",\n selectionBookendWidth = 4,\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 if (defaultSelectedIndexValues && defaultSelectedKeyValues) {\n throw Error(\n `defaultSelectedIndexValues and defaultSelectedKeyValues can not be used in combination. Use at most one.`,\n );\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>(undefined);\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 <ContextPanelProvider>\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 ...styleProp,\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 EmptyDisplay={EmptyDisplay}\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 defaultSelectedIndexValues={defaultSelectedIndexValues}\n defaultSelectedKeyValues={defaultSelectedKeyValues}\n disableFocus={disableFocus}\n groupToggleTarget={groupToggleTarget}\n highlightedIndex={highlightedIndex}\n id={id}\n navigationStyle={navigationStyle}\n onAvailableColumnsChange={onAvailableColumnsChange}\n onConfigChange={onConfigChange}\n onDataEdited={onDataEdited}\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 revealSelected={revealSelected}\n rowActionHandlers={rowActionHandlers}\n rowHeight={rowHeight}\n rowToObject={rowToObject}\n scrollingApiRef={scrollingApiRef}\n lowerCaseSearchPattern={lowerCase(searchPattern)}\n selectionBookendWidth={selectionBookendWidth}\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 </ContextPanelProvider>\n );\n});\n"],"names":["metadataKeys","Row","DefaultRow","useId","useTable","jsxs","TableProvider","jsx","TableHeader","data","forwardRef","Table","useWindow","useComponentCssInjection","tableCss","useRef","useState","useMeasuredHeight","useCallback","size","useMemo","ContextPanelProvider","MeasuredContainer","useForkRef","RowProxy","lowerCase","reduceSizeHeight","PaginationControl"],"mappings":";;;;;;;;;;;;;;;;;;;AA8DA,MAAM,SAAY,GAAA,UAAA;AAElB,MAAM,EAAE,GAAK,EAAA,UAAA,EAAe,GAAAA,qBAAA;AAqN5B,MAAM,YAAY,CAAC;AAAA,EACjB,YAAA;AAAA,OACAC,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,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,YAAe,GAAA,KAAA;AAAA,EACf,iBAAA;AAAA,EACA,gBAAkB,EAAA,oBAAA;AAAA,EAClB,EAAI,EAAA,MAAA;AAA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,KAAA;AAAA,YACA,uBAAA;AAAA,YACA,qBAAA;AAAA,YACA,aAAA;AAAA,YACA,gBAAA;AAAA,YACA,MAAA;AAAA,YACA,YAAA;AAAA,YACA,YAAA;AAAA,YACA,UAAA;AAAA,YACA,0BAAA;AAAA,YACA,wBAAA;AAAA,YACA,YAAA;AAAA,YACA,iBAAA;AAAA,YACA,gBAAA;AAAA,YACA,EAAA;AAAA,YACA,eAAA;AAAA,YACA,wBAAA;AAAA,YACA,cAAA;AAAA,YACA,YAAA;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,cAAA;AAAA,YACA,iBAAA;AAAA,YACA,SAAA;AAAA,YACA,WAAA;AAAA,YACA,eAAA;AAAA,YACA,sBAAA,EAAwBwB,mBAAU,aAAa,CAAA;AAAA,YAC/C,qBAAA;AAAA,YACA,cAAA;AAAA,YACA,iBAAA;AAAA,YACA,qBAAA;AAAA,YACA,sBAAA;AAAA,YACA,IAAA,EAAMC,8BAAiB,CAAA,IAAA,EAAM,YAAY;AAAA;AAAA,SAEzC,GAAA,IAAA;AAAA,QACH,sBACC,mBAAAnB,cAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,CAAG,EAAA,SAAS,CAAW,OAAA,CAAA,EAAA,GAAA,EAAK,SAC1C,EAAA,QAAA,kBAAAA,cAAA,CAACoB,mCAAkB,EAAA,EAAA,UAAA,EAAwB,GAC7C,CACE,GAAA;AAAA;AAAA;AAAA,GAER,EAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -37,7 +37,11 @@ const HeaderCell = ({
|
|
|
37
37
|
});
|
|
38
38
|
const dragDropSortHook = allowDragColumnHeader ? vuuUtils.useSortable : doNothing;
|
|
39
39
|
const { ref: sortableRef } = dragDropSortHook({ id, index });
|
|
40
|
-
const {
|
|
40
|
+
const {
|
|
41
|
+
allowColumnHeaderMenu = true,
|
|
42
|
+
HeaderCellContentRenderer,
|
|
43
|
+
HeaderCellLabelRenderer
|
|
44
|
+
} = column;
|
|
41
45
|
const rootRef = react.useRef(null);
|
|
42
46
|
const { isResizing, ...resizeProps } = useTableColumnResize.useTableColumnResize({
|
|
43
47
|
column,
|
|
@@ -54,7 +58,7 @@ const HeaderCell = ({
|
|
|
54
58
|
}
|
|
55
59
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase}-label`, children: column.label ?? column.name });
|
|
56
60
|
const columnContent = HeaderCellContentRenderer ? [/* @__PURE__ */ jsxRuntime.jsx(HeaderCellContentRenderer, { column }, "content")] : [];
|
|
57
|
-
if (showColumnHeaderMenus) {
|
|
61
|
+
if (showColumnHeaderMenus && allowColumnHeaderMenu) {
|
|
58
62
|
const menuPermissions = showColumnHeaderMenus === true ? void 0 : showColumnHeaderMenus;
|
|
59
63
|
const columnMenu = /* @__PURE__ */ jsxRuntime.jsx(vuuTableExtras.ColumnMenu, { column, menuPermissions });
|
|
60
64
|
if (column.align === "right") {
|
|
@@ -72,6 +76,7 @@ const HeaderCell = ({
|
|
|
72
76
|
}, [
|
|
73
77
|
HeaderCellContentRenderer,
|
|
74
78
|
HeaderCellLabelRenderer,
|
|
79
|
+
allowColumnHeaderMenu,
|
|
75
80
|
column,
|
|
76
81
|
showColumnHeaderMenus
|
|
77
82
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderCell.js","sources":["../../../../packages/vuu-table/src/header-cell/HeaderCell.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { ColumnMenu } from \"@vuu-ui/vuu-table-extras\";\nimport { HeaderCellProps } from \"@vuu-ui/vuu-table-types\";\nimport { useSortable } from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport {\n KeyboardEventHandler,\n MouseEventHandler,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport { SortIndicator } from \"../column-header-pill\";\nimport { ColumnResizer, useTableColumnResize } from \"../column-resizing\";\nimport { useCell } from \"../useCell\";\n\nimport { useForkRef } from \"@salt-ds/core\";\nimport headerCellCss from \"./HeaderCell.css\";\n\nconst classBase = \"vuuTableHeaderCell\";\n\nconst doNothing = () => {\n // dummy hook\n return { ref: { current: null } };\n};\n\nexport const HeaderCell = ({\n allowDragColumnHeader = true,\n className: classNameProp,\n column,\n id,\n index,\n onClick,\n onResize,\n showColumnHeaderMenus = true,\n ...htmlAttributes\n}: HeaderCellProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-header-cell\",\n css: headerCellCss,\n window: targetWindow,\n });\n const dragDropSortHook = allowDragColumnHeader ? useSortable : doNothing;\n const { ref: sortableRef } = dragDropSortHook({ id, index });\n const { HeaderCellContentRenderer
|
|
1
|
+
{"version":3,"file":"HeaderCell.js","sources":["../../../../packages/vuu-table/src/header-cell/HeaderCell.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { ColumnMenu } from \"@vuu-ui/vuu-table-extras\";\nimport { HeaderCellProps } from \"@vuu-ui/vuu-table-types\";\nimport { useSortable } from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport {\n KeyboardEventHandler,\n MouseEventHandler,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport { SortIndicator } from \"../column-header-pill\";\nimport { ColumnResizer, useTableColumnResize } from \"../column-resizing\";\nimport { useCell } from \"../useCell\";\n\nimport { useForkRef } from \"@salt-ds/core\";\nimport headerCellCss from \"./HeaderCell.css\";\n\nconst classBase = \"vuuTableHeaderCell\";\n\nconst doNothing = () => {\n // dummy hook\n return { ref: { current: null } };\n};\n\nexport const HeaderCell = ({\n allowDragColumnHeader = true,\n className: classNameProp,\n column,\n id,\n index,\n onClick,\n onResize,\n showColumnHeaderMenus = true,\n ...htmlAttributes\n}: HeaderCellProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-header-cell\",\n css: headerCellCss,\n window: targetWindow,\n });\n const dragDropSortHook = allowDragColumnHeader ? useSortable : doNothing;\n const { ref: sortableRef } = dragDropSortHook({ id, index });\n const {\n allowColumnHeaderMenu = true,\n HeaderCellContentRenderer,\n HeaderCellLabelRenderer,\n } = column;\n const rootRef = useRef<HTMLDivElement>(null);\n const { isResizing, ...resizeProps } = useTableColumnResize({\n column,\n onResize,\n rootRef,\n });\n\n const headerItems = useMemo(() => {\n const sortIndicator = <SortIndicator column={column} />;\n const columnLabel = HeaderCellLabelRenderer ? (\n <HeaderCellLabelRenderer\n className={`${classBase}-label`}\n column={column}\n />\n ) : (\n <div className={`${classBase}-label`}>{column.label ?? column.name}</div>\n );\n const columnContent = HeaderCellContentRenderer\n ? [<HeaderCellContentRenderer column={column} key=\"content\" />]\n : [];\n\n if (showColumnHeaderMenus && allowColumnHeaderMenu) {\n const menuPermissions =\n showColumnHeaderMenus === true ? undefined : showColumnHeaderMenus;\n const columnMenu = (\n <ColumnMenu column={column} menuPermissions={menuPermissions} />\n );\n\n if (column.align === \"right\") {\n return [sortIndicator, columnLabel, columnContent, columnMenu];\n } else {\n return [columnMenu, columnLabel, sortIndicator, columnContent];\n }\n } else {\n if (column.align === \"right\") {\n return [sortIndicator, columnLabel, columnContent];\n } else {\n return [columnLabel, sortIndicator, columnContent];\n }\n }\n }, [\n HeaderCellContentRenderer,\n HeaderCellLabelRenderer,\n allowColumnHeaderMenu,\n column,\n showColumnHeaderMenus,\n ]);\n\n const handleClick = useCallback<MouseEventHandler<HTMLDivElement>>(\n (evt) => {\n !isResizing && onClick?.(evt);\n },\n [isResizing, onClick],\n );\n\n const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(\n (evt) => {\n if (evt.key === \"Enter\") {\n onClick?.(evt);\n }\n },\n [onClick],\n );\n\n const { className, style } = useCell(column, classBase, true);\n\n return (\n <div\n {...htmlAttributes}\n aria-colindex={column.ariaColIndex}\n aria-label={`${column.label ?? column.name} column header`}\n className={cx(className, classNameProp, {\n [`${classBase}-resizing`]: isResizing,\n [`${classBase}-noMenu`]: showColumnHeaderMenus === false,\n })}\n data-column-name={column.name}\n data-index={index}\n id={id}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n ref={useForkRef<HTMLDivElement>(rootRef, sortableRef)}\n role=\"columnheader\"\n style={style}\n >\n {...headerItems}\n {column.resizeable !== false ? <ColumnResizer {...resizeProps} /> : null}\n </div>\n );\n};\n"],"names":["useWindow","useComponentCssInjection","headerCellCss","useSortable","useRef","useTableColumnResize","useMemo","jsx","SortIndicator","ColumnMenu","useCallback","useCell","jsxs","useForkRef","ColumnResizer"],"mappings":";;;;;;;;;;;;;;;;AAoBA,MAAM,SAAY,GAAA,oBAAA;AAElB,MAAM,YAAY,MAAM;AAEtB,EAAA,OAAO,EAAE,GAAA,EAAK,EAAE,OAAA,EAAS,MAAO,EAAA;AAClC,CAAA;AAEO,MAAM,aAAa,CAAC;AAAA,EACzB,qBAAwB,GAAA,IAAA;AAAA,EACxB,SAAW,EAAA,aAAA;AAAA,EACX,MAAA;AAAA,EACA,EAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,qBAAwB,GAAA,IAAA;AAAA,EACxB,GAAG;AACL,CAAuB,KAAA;AACrB,EAAA,MAAM,eAAeA,gBAAU,EAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,iBAAA;AAAA,IACR,GAAK,EAAAC,YAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AACD,EAAM,MAAA,gBAAA,GAAmB,wBAAwBC,oBAAc,GAAA,SAAA;AAC/D,EAAM,MAAA,EAAE,KAAK,WAAY,EAAA,GAAI,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AAA,QAC3B,CAAC,CAAA,EAAG,SAAS,CAAA,OAAA,CAAS,GAAG,qBAA0B,KAAA;AAAA,OACpD,CAAA;AAAA,MACD,oBAAkB,MAAO,CAAA,IAAA;AAAA,MACzB,YAAY,EAAA,KAAA;AAAA,MACZ,EAAA;AAAA,MACA,OAAS,EAAA,WAAA;AAAA,MACT,SAAW,EAAA,aAAA;AAAA,MACX,GAAA,EAAKC,eAA2B,CAAA,OAAA,EAAS,WAAW,CAAA;AAAA,MACpD,IAAK,EAAA,cAAA;AAAA,MACL,KAAA;AAAA,MAEC,QAAA,EAAA;AAAA,QAAG,GAAA,WAAA;AAAA,QACH,OAAO,UAAe,KAAA,KAAA,kCAASC,2BAAe,EAAA,EAAA,GAAG,aAAa,CAAK,GAAA;AAAA;AAAA;AAAA,GACtE;AAEJ;;;;"}
|
package/cjs/useTable.js
CHANGED
|
@@ -109,15 +109,23 @@ const useTable = ({
|
|
|
109
109
|
vuuUtils.useLayoutEffectSkipFirst(() => {
|
|
110
110
|
dispatchTableModelAction({
|
|
111
111
|
availableWidth,
|
|
112
|
+
selectionModel,
|
|
112
113
|
type: "init",
|
|
113
114
|
tableConfig: tableConfigRef.current,
|
|
114
115
|
dataSource
|
|
115
116
|
});
|
|
116
|
-
}, [
|
|
117
|
+
}, [
|
|
118
|
+
availableWidth,
|
|
119
|
+
config,
|
|
120
|
+
dataSource,
|
|
121
|
+
dispatchTableModelAction,
|
|
122
|
+
selectionModel
|
|
123
|
+
]);
|
|
117
124
|
const applyTableConfigChange = react.useCallback(
|
|
118
125
|
(config2) => {
|
|
119
126
|
dispatchTableModelAction({
|
|
120
127
|
availableWidth,
|
|
128
|
+
selectionModel,
|
|
121
129
|
type: "init",
|
|
122
130
|
tableConfig: config2,
|
|
123
131
|
dataSource
|
|
@@ -125,7 +133,13 @@ const useTable = ({
|
|
|
125
133
|
tableConfigRef.current = config2;
|
|
126
134
|
onConfigChange?.(stripInternalProperties(config2));
|
|
127
135
|
},
|
|
128
|
-
[
|
|
136
|
+
[
|
|
137
|
+
availableWidth,
|
|
138
|
+
dataSource,
|
|
139
|
+
dispatchTableModelAction,
|
|
140
|
+
onConfigChange,
|
|
141
|
+
selectionModel
|
|
142
|
+
]
|
|
129
143
|
);
|
|
130
144
|
const columnMap = react.useMemo(
|
|
131
145
|
() => vuuUtils.buildColumnMap(dataSource.columns),
|
|
@@ -187,13 +201,20 @@ const useTable = ({
|
|
|
187
201
|
dispatchTableModelAction({
|
|
188
202
|
availableWidth,
|
|
189
203
|
dataSource,
|
|
204
|
+
selectionModel,
|
|
190
205
|
tableConfig: tableConfig2,
|
|
191
206
|
type: "init"
|
|
192
207
|
});
|
|
193
208
|
tableConfigRef.current = tableConfig2;
|
|
194
209
|
onConfigChange?.(stripInternalProperties(tableConfig2));
|
|
195
210
|
},
|
|
196
|
-
[
|
|
211
|
+
[
|
|
212
|
+
availableWidth,
|
|
213
|
+
dataSource,
|
|
214
|
+
dispatchTableModelAction,
|
|
215
|
+
onConfigChange,
|
|
216
|
+
selectionModel
|
|
217
|
+
]
|
|
197
218
|
);
|
|
198
219
|
const handleDataSourceConfigChanged = react.useCallback(
|
|
199
220
|
(dataSourceConfig) => {
|