@vuu-ui/vuu-table 0.13.65 → 0.13.67
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/README.md +47 -0
- package/cjs/Table.css.js +1 -1
- package/cjs/Table.js +4 -3
- package/cjs/Table.js.map +1 -1
- package/cjs/useDataSource.js +8 -0
- package/cjs/useDataSource.js.map +1 -1
- package/cjs/useMeasuredHeight.js +9 -4
- package/cjs/useMeasuredHeight.js.map +1 -1
- package/cjs/useTable.js +30 -6
- package/cjs/useTable.js.map +1 -1
- package/cjs/useTableModel.js.map +1 -1
- package/esm/Table.css.js +1 -1
- package/esm/Table.js +4 -3
- package/esm/Table.js.map +1 -1
- package/esm/useDataSource.js +8 -0
- package/esm/useDataSource.js.map +1 -1
- package/esm/useMeasuredHeight.js +10 -5
- package/esm/useMeasuredHeight.js.map +1 -1
- package/esm/useTable.js +30 -6
- package/esm/useTable.js.map +1 -1
- package/esm/useTableModel.js.map +1 -1
- package/package.json +10 -10
- package/types/useDataSource.d.ts +1 -0
- package/types/useTableModel.d.ts +4 -0
package/README.md
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Table interactions with dataSource
|
|
2
|
+
|
|
3
|
+
`dataSource` is a required prop for `Table`.
|
|
4
|
+
|
|
5
|
+
## useTable
|
|
6
|
+
|
|
7
|
+
it is used
|
|
8
|
+
|
|
9
|
+
- to initialise the rowCount state value with `dataSource.size`
|
|
10
|
+
- within tableModel hook
|
|
11
|
+
- to build columnMap, using `dataSource.columns`
|
|
12
|
+
- within dataSource hook
|
|
13
|
+
- whenever tableModel is re-initialised ...
|
|
14
|
+
- handleConfigEditedInSettingsPanel
|
|
15
|
+
- useLayoutEffectSkipFirst, triggered by changes to availableWidth, selectionModel, config
|
|
16
|
+
- applyTableConfigChange, called when calculated column created, column(s) hidden or pinned
|
|
17
|
+
|
|
18
|
+
dataSource event handlers handled in `useTable`
|
|
19
|
+
|
|
20
|
+
- onSubscribed
|
|
21
|
+
- handleConfigChange, updates tableModel when dataSource "config" event emitted
|
|
22
|
+
|
|
23
|
+
### useDataSource
|
|
24
|
+
|
|
25
|
+
dataSource.subscribe, invoken in first setRange call, passing the following parameters
|
|
26
|
+
|
|
27
|
+
- range
|
|
28
|
+
- revealSelected
|
|
29
|
+
- selectedKeyValues
|
|
30
|
+
|
|
31
|
+
dataSource.resume
|
|
32
|
+
dataSource.enable
|
|
33
|
+
|
|
34
|
+
dataSource event handlers
|
|
35
|
+
|
|
36
|
+
- `resume`
|
|
37
|
+
- DataSourceSubscribeCallback, handles:
|
|
38
|
+
- `subscribed`
|
|
39
|
+
- `viewport-update`
|
|
40
|
+
- `viewport=clear`
|
|
41
|
+
|
|
42
|
+
### useTableModel
|
|
43
|
+
|
|
44
|
+
Column Operations from Table Menu
|
|
45
|
+
|
|
46
|
+
- remove columns, directly removes column from dataSource.columns. dataSOuce fires `config` event
|
|
47
|
+
- hide column, updates tableModel config to set hidden flag true on columnDescriptor
|
package/cjs/Table.css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tableCss = ".vuuTable {\n --vuu-table-footer-height: 0px;\n --vuu-table-cell-outlineWidth: 1px;\n --table-height: var(--measured-px-height);\n --table-width: var(--measured-px-width);\n --vuu-table-embedded-control-height: calc(var(--row-height) - 3px);\n --vuu-table-col-header-height: var(--vuuTableHeaderCell-height, 25px);\n --vuu-table-col-heading-height: 25px;\n --columnResizer-color: transparent;\n --row-height: var(\n --row-height-prop,\n var(--vuu-table-row-height, var(--salt-size-base))\n );\n\n --cell-borderColor: transparent;\n --row-borderColor: var(--row-background);\n --table-background: var(--salt-container-primary-background);\n\n background: var(--table-background);\n font-family: var(\n --vuuTable-fontFamily,\n var(--salt-typography-fontFamily, sans-serif)\n );\n font-size: var(--vuuTable-fontSize, var(--salt-text-fontSize, 12px));\n position: relative;\n user-select: none;\n\n &.vuuTable-viewportRowLimit {\n height: fit-content;\n /* With a viewportRowLimit, table is content sized, not container sized. */\n .vuuTable-contentContainer {\n height: calc(var(--measured-px-height) + var(--total-header-height));\n }\n .vuuTable-scrollbarContainer {\n height: calc(\n var(--measured-px-height) + var(--horizontal-scrollbar-height)\n );\n }\n .vuuTable-scrollbarFiller {\n height: var(--horizontal-scrollbar-height);\n }\n }\n\n &.vuuTable-maxViewportRowLimit {\n /* With a maxVviewportRowLimit, table is content sized, not container sized. */\n height: fit-content;\n padding-bottom: var(--horizontal-scrollbar-height);\n\n .vuuTable-contentContainer {\n height: min(\n calc(var(--measured-px-height) + var(--total-header-height)),\n calc(var(--content-height) + var(--total-header-height))\n );\n }\n .vuuTable-scrollbarContainer {\n height: min(\n calc(var(--measured-px-height) + var(--horizontal-scrollbar-height)),\n calc(var(--content-height) + var(--horizontal-scrollbar-height))\n );\n }\n\n .vuuTable-scrollbarFiller {\n height: var(--horizontal-scrollbar-height);\n }\n }\n}\n\n.vuuTable-zebra {\n --row-background-even: var(--salt-palette-neutral-secondary-background);\n}\n\n.vuuTable-colLines {\n --cell-borderColor: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-rowLines {\n --row-borderColor: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-scrollbarContainer {\n border-bottom: none !important;\n border-top: none !important;\n height: var(--viewport-body-height);\n left: 0px;\n overflow: auto;\n position: absolute;\n top: var(--total-header-height);\n width: var(--table-width);\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar {\n width: 10px;\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar:horizontal {\n height: 10px;\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.vuuTable-scrollbarContainer::-webkit-scrollbar-thumb {\n background-clip: padding-box;\n border-radius: 10px;\n border: 2px solid rgba(0, 0, 0, 0);\n background-color: var(--vuu-color-gray-30);\n}\n\n.vuuTable-scrollbarContent {\n height: calc(var(--content-height) + var(--horizontal-scrollbar-height));\n position: absolute;\n width: var(--content-width);\n}\n\n.vuuTable-contentContainer {\n background: var(--table-background);\n height: calc(\n 100% - var(--horizontal-scrollbar-height) - var(--vuu-table-footer-height)\n );\n position: relative;\n overflow: auto;\n overscroll-behavior: none;\n width: calc(var(--table-width) - var(--vertical-scrollbar-width));\n}\n\n.vuuTable-contentContainer::-webkit-scrollbar {\n display: none;\n}\n\n.vuuTable-table {\n border: none;\n border-collapse: separate;\n border-spacing: 0;\n left: 0;\n margin: 0;\n position: absolute;\n top: 0;\n table-layout: fixed;\n width: var(--content-width);\n}\n\n.vuuTable-body {\n height: var(--content-height);\n position: relative;\n}\n\n.vuuTable-focusCellPlaceholder {\n height: var(--row-height);\n position: absolute;\n width: 50px;\n z-index: -1;\n}\n\n.vuuPinLeft,\n.vuuPinRight {\n background-color: inherit;\n position: sticky;\n z-index: 1;\n}\n\n.vuuTable-col-headings {\n background-color: var(\n --vuuTableColHeadings-background,\n var(--table-background)\n );\n padding: 0 var(--vuuTableRow-selectionDecorator-width, 0);\n position: sticky;\n top: 0;\n /* ensure header row sits atop everything else when scrolling down */\n z-index: 1;\n}\n\n.vuuTable-col-headings:hover {\n --columnResizer-height: var(--vuu-table-col-header-height);\n --columnResizer-color: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-heading {\n height: var(--vuu-table-col-heading-height);\n}\n\n.vuuTable-col-headers {\n background-color: var(\n --vuuTableColHeadings-background,\n var(--vuuTableColHeadings-background)\n );\n border-bottom: solid 1px\n var(\n --vuuTableColHeaders-borderColor,\n var(--salt-separable-secondary-borderColor)\n );\n color: var(--salt-content-secondary-foreground);\n height: var(--vuu-table-col-header-height);\n white-space: nowrap;\n\n .vuuDraggable-spacer {\n border-bottom: solid 1px #ccc;\n display: var(--vuuDraggable-display, inline-block);\n height: var(--vuu-table-col-header-height);\n }\n}\n\n.sizer-cell {\n border: none !important;\n height: 0px;\n}\n\n.vuuDraggable-vuuTable {\n --cell-borderColor: transparent;\n --vuu-table-col-header-height: var(--vuuTableHeaderCell-height, 25px);\n --vuuTableHeaderCell-background: var(--salt-container-secondary-background);\n}\n.vuuDraggable-vuuTable {\n --row-height: 25px;\n}\n\n.vuuTable-pagination {\n --vuu-table-footer-height: 32px;\n .vuuTable-col-headings {\n position: relative;\n }\n\n .vuuTable-body {\n height: calc(var(--content-height) - var(--total-header-height));\n position: relative;\n }\n\n .vuuTableRow {\n position: relative;\n top: auto;\n }\n}\n\n.vuuTable-footer {\n align-items: center;\n display: flex;\n height: var(--vuu-table-footer-height);\n justify-content: flex-end;\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n}\n\n.vuuHighlight {\n color: blue;\n}\n\n.DragColumn {\n box-shadow: var(--salt-overlayable-shadow-drag);\n}";
|
|
3
|
+
var tableCss = ".vuuTable {\n --vuu-table-footer-height: 0px;\n --vuu-table-cell-outlineWidth: 1px;\n --table-height: var(--measured-px-height);\n --table-width: var(--measured-px-width);\n --vuu-table-embedded-control-height: calc(var(--row-height) - 3px);\n --vuu-table-col-header-height: var(--vuuTableHeaderCell-height, 25px);\n --vuu-table-col-heading-height: 25px;\n --columnResizer-color: transparent;\n --row-height: var(\n --row-height-prop,\n var(--vuu-table-row-height, var(--salt-size-base))\n );\n\n --cell-borderColor: transparent;\n --row-borderColor: var(--row-background);\n --table-background: var(--salt-container-primary-background);\n\n background: var(--table-background);\n font-family: var(\n --vuuTable-fontFamily,\n var(--salt-typography-fontFamily, sans-serif)\n );\n font-size: var(--vuuTable-fontSize, var(--salt-text-fontSize, 12px));\n position: relative;\n user-select: none;\n\n &.vuuTable-viewportRowLimit {\n height: fit-content;\n /* With a viewportRowLimit, table is content sized, not container sized. */\n .vuuTable-contentContainer {\n height: calc(var(--measured-px-height) + var(--total-header-height));\n }\n .vuuTable-scrollbarContainer {\n height: calc(\n var(--measured-px-height) + var(--horizontal-scrollbar-height)\n );\n }\n .vuuTable-scrollbarFiller {\n height: var(--horizontal-scrollbar-height);\n }\n }\n\n &.vuuTable-maxViewportRowLimit {\n /* With a maxVviewportRowLimit, table is content sized, not container sized. */\n height: fit-content;\n padding-bottom: var(--horizontal-scrollbar-height);\n\n .vuuTable-contentContainer {\n height: min(\n calc(var(--measured-px-height) + var(--total-header-height)),\n calc(var(--content-height) + var(--total-header-height))\n );\n }\n .vuuTable-scrollbarContainer {\n height: min(\n calc(var(--measured-px-height) + var(--horizontal-scrollbar-height)),\n calc(var(--content-height) + var(--horizontal-scrollbar-height))\n );\n }\n\n .vuuTable-scrollbarFiller {\n height: var(--horizontal-scrollbar-height);\n }\n }\n}\n\n.vuuTable-zebra {\n --row-background-even: var(--salt-palette-neutral-secondary-background);\n}\n\n.vuuTable-colLines {\n --cell-borderColor: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-rowLines {\n --row-borderColor: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-scrollbarContainer {\n border-bottom: none !important;\n border-top: none !important;\n height: var(--viewport-body-height);\n left: 0px;\n overflow: auto;\n position: absolute;\n top: var(--total-header-height);\n width: var(--table-width);\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar {\n width: 10px;\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar:horizontal {\n height: 10px;\n}\n\n.vuuTable-scrollbarContainer::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.vuuTable-scrollbarContainer::-webkit-scrollbar-thumb {\n background-clip: padding-box;\n border-radius: 10px;\n border: 2px solid rgba(0, 0, 0, 0);\n background-color: var(--vuu-color-gray-30);\n}\n\n.vuuTable-scrollbarContent {\n height: calc(var(--content-height) + var(--horizontal-scrollbar-height));\n position: absolute;\n width: var(--content-width);\n}\n\n.vuuTable-contentContainer {\n background: var(--table-background);\n height: calc(\n 100% - var(--horizontal-scrollbar-height) - var(--vuu-table-footer-height)\n );\n position: relative;\n overflow: auto;\n overscroll-behavior: none;\n width: calc(var(--table-width) - var(--vertical-scrollbar-width));\n}\n\n.vuuTable-contentContainer::-webkit-scrollbar {\n display: none;\n}\n\n.vuuTable-table {\n border: none;\n border-collapse: separate;\n border-spacing: 0;\n left: 0;\n margin: 0;\n position: absolute;\n top: 0;\n table-layout: fixed;\n width: var(--content-width);\n}\n\n.vuuTable-body {\n height: var(--content-height);\n position: relative;\n}\n\n.vuuTable-focusCellPlaceholder {\n height: var(--row-height);\n position: absolute;\n width: 50px;\n z-index: -1;\n}\n\n.vuuPinLeft,\n.vuuPinRight {\n background-color: inherit;\n position: sticky;\n z-index: 1;\n}\n\n.vuuTable-col-headings {\n background-color: var(\n --vuuTableColHeadings-background,\n var(--table-background)\n );\n padding: 0 var(--vuuTableRow-selectionDecorator-width, 0);\n position: sticky;\n top: 0;\n /* ensure header row sits atop everything else when scrolling down */\n z-index: 1;\n}\n\n.vuuTable-col-headings:hover {\n --columnResizer-height: var(--vuu-table-col-header-height);\n --columnResizer-color: var(--salt-separable-tertiary-borderColor);\n}\n\n.vuuTable-heading {\n height: var(--vuu-table-col-heading-height);\n}\n\n.vuuTable-col-headers {\n background-color: var(\n --vuuTableColHeadings-background,\n var(--vuuTableColHeadings-background)\n );\n border-bottom: solid 1px\n var(\n --vuuTableColHeaders-borderColor,\n var(--salt-separable-secondary-borderColor)\n );\n color: var(--salt-content-secondary-foreground);\n height: var(--vuu-table-col-header-height);\n white-space: nowrap;\n\n .vuuDraggable-spacer {\n border-bottom: solid 1px #ccc;\n display: var(--vuuDraggable-display, inline-block);\n height: var(--vuu-table-col-header-height);\n }\n}\n\n.sizer-cell {\n border: none !important;\n height: 0px;\n}\n\n.vuuDraggable-vuuTable {\n --cell-borderColor: transparent;\n --vuu-table-col-header-height: var(--vuuTableHeaderCell-height, 25px);\n --vuuTableHeaderCell-background: var(--salt-container-secondary-background);\n}\n.vuuDraggable-vuuTable {\n --row-height: 25px;\n}\n\n.vuuTable-pagination {\n --vuu-table-footer-height: 32px;\n .vuuTable-col-headings {\n position: relative;\n }\n\n .vuuTable-body {\n height: calc(var(--content-height) - var(--total-header-height));\n position: relative;\n }\n\n .vuuTableRow {\n position: relative;\n top: auto;\n }\n}\n\n.vuuTable-footer {\n align-items: center;\n display: flex;\n height: var(--vuu-table-footer-height);\n justify-content: flex-end;\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n}\n\n.vuuHighlight {\n color: blue;\n}\n\n.DragColumn {\n box-shadow: var(--salt-overlayable-shadow-drag);\n}\n\n@keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 90% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n.vuuTable-emptyDisplay {\n animation: fadeIn .8s;\n align-items: center;\n display: flex;\n inset:0;\n justify-content: center;\n position: absolute\n}\n\n.vuuTable-emptyDisplay ~ .vuuTable-contentContainer {\n visibility: hidden;\n}}";
|
|
4
4
|
|
|
5
5
|
module.exports = tableCss;
|
|
6
6
|
//# sourceMappingURL=Table.css.js.map
|
package/cjs/Table.js
CHANGED
|
@@ -149,9 +149,6 @@ const TableCore = ({
|
|
|
149
149
|
};
|
|
150
150
|
const headersReady = showColumnHeaders === false || headerHeight > 0;
|
|
151
151
|
const readyToRenderTableBody = headersReady && data.length > 0;
|
|
152
|
-
if (dataSource.size === 0 && EmptyDisplay) {
|
|
153
|
-
return /* @__PURE__ */ jsxRuntime.jsx(EmptyDisplay, {});
|
|
154
|
-
}
|
|
155
152
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
156
153
|
vuuTableExtras.TableProvider,
|
|
157
154
|
{
|
|
@@ -169,6 +166,10 @@ const TableCore = ({
|
|
|
169
166
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase}-scrollbarContent` })
|
|
170
167
|
}
|
|
171
168
|
) : null,
|
|
169
|
+
dataSource.size === 0 && EmptyDisplay ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classBase}-emptyDisplay`, children: [
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx(EmptyDisplay, {}),
|
|
171
|
+
" "
|
|
172
|
+
] }) : null,
|
|
172
173
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
173
174
|
"div",
|
|
174
175
|
{
|
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 type { DataSource, SchemaColumn } 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 SelectionChangeHandler,\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 * Allow all rows be selected, use with checkbox coliumn.\n */\n allowSelectAll?: boolean;\n\n /**\n * If checkbox selection is in effect, can user select row by clicking row. If\n * false, checkbox must be clicked explicitly.\n */\n allowSelectCheckboxRow?: boolean;\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 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 allowSelectAll,\n allowSelectCheckboxRow,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\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\"\n | \"resizeStrategy\"\n | \"rowHeight\"\n | \"searchPattern\"\n | \"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 allRowsSelected,\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 onCheckBoxColumnHeaderClick,\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 allowSelectCheckboxRow,\n availableColumns,\n config,\n containerRef,\n dataSource,\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 allowSelectAll={allowSelectAll}\n allRowsSelected={allRowsSelected}\n // columns={scrollProps.columnsWithinViewport}\n columns={columns}\n customHeader={customHeader}\n headings={headings}\n onCheckBoxColumnHeaderClick={onCheckBoxColumnHeaderClick}\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 allowSelectAll,\n allowSelectCheckboxRow,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\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 resizeStrategy,\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\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 resizeStrategy={resizeStrategy}\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 allowSelectAll={allowSelectAll}\n allowSelectCheckboxRow={allowSelectCheckboxRow}\n availableColumns={availableColumns}\n config={config}\n containerRef={containerRef}\n customHeader={customHeader}\n dataSource={dataSource}\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":";;;;;;;;;;;;;;;;;;;AA0DA,MAAM,SAAY,GAAA,UAAA;AAElB,MAAM,EAAE,GAAK,EAAA,UAAA,EAAe,GAAAA,qBAAA;AA2N5B,MAAM,YAAY,CAAC;AAAA,EACjB,YAAA;AAAA,OACAC,KAAM,GAAAC,OAAA;AAAA,EACN,uBAAA;AAAA,EACA,qBAAwB,GAAA,IAAA;AAAA,EACxB,aAAA;AAAA,EACA,cAAA;AAAA,EACA,sBAAA;AAAA,EACA,gBAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;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,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,qBAAwB,GAAA,CAAA;AAAA,EACxB,cAAiB,GA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AAA;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;;;;"}
|
|
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 { DataSource, SchemaColumn } 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 SelectionChangeHandler,\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 * Allow all rows be selected, use with checkbox coliumn.\n */\n allowSelectAll?: boolean;\n\n /**\n * If checkbox selection is in effect, can user select row by clicking row. If\n * false, checkbox must be clicked explicitly.\n */\n allowSelectCheckboxRow?: boolean;\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 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 allowSelectAll,\n allowSelectCheckboxRow,\n availableColumns,\n config,\n containerRef,\n customHeader,\n dataSource,\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\"\n | \"resizeStrategy\"\n | \"rowHeight\"\n | \"searchPattern\"\n | \"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 allRowsSelected,\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 onCheckBoxColumnHeaderClick,\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 allowSelectCheckboxRow,\n availableColumns,\n config,\n containerRef,\n dataSource,\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 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\n {dataSource.size === 0 && EmptyDisplay ? (\n <div className={`${classBase}-emptyDisplay`}>\n <EmptyDisplay />{\" \"}\n </div>\n ) : null}\n\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 allowSelectAll={allowSelectAll}\n allRowsSelected={allRowsSelected}\n // columns={scrollProps.columnsWithinViewport}\n columns={columns}\n customHeader={customHeader}\n headings={headings}\n onCheckBoxColumnHeaderClick={onCheckBoxColumnHeaderClick}\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 allowSelectAll,\n allowSelectCheckboxRow,\n className: classNameProp,\n config,\n customHeader,\n dataSource,\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 resizeStrategy,\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\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 resizeStrategy={resizeStrategy}\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 allowSelectAll={allowSelectAll}\n allowSelectCheckboxRow={allowSelectCheckboxRow}\n availableColumns={availableColumns}\n config={config}\n containerRef={containerRef}\n customHeader={customHeader}\n dataSource={dataSource}\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":";;;;;;;;;;;;;;;;;;;AA0DA,MAAM,SAAY,GAAA,UAAA;AAElB,MAAM,EAAE,GAAK,EAAA,UAAA,EAAe,GAAAA,qBAAA;AA2N5B,MAAM,YAAY,CAAC;AAAA,EACjB,YAAA;AAAA,OACAC,KAAM,GAAAC,OAAA;AAAA,EACN,uBAAA;AAAA,E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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;;;;"}
|
package/cjs/useDataSource.js
CHANGED
|
@@ -130,11 +130,19 @@ const useDataSource = ({
|
|
|
130
130
|
revealSelected
|
|
131
131
|
]
|
|
132
132
|
);
|
|
133
|
+
const removeColumnDataFromCache = react.useCallback(
|
|
134
|
+
(indexOfRemovedColumn) => {
|
|
135
|
+
dataWindow.spliceDataAtIndex(indexOfRemovedColumn);
|
|
136
|
+
data.current = dataWindow.data;
|
|
137
|
+
},
|
|
138
|
+
[dataWindow]
|
|
139
|
+
);
|
|
133
140
|
return {
|
|
134
141
|
data: data.current,
|
|
135
142
|
dataRef: data,
|
|
136
143
|
getSelectedRows,
|
|
137
144
|
range: rangeRef.current,
|
|
145
|
+
removeColumnDataFromCache,
|
|
138
146
|
setRange
|
|
139
147
|
};
|
|
140
148
|
};
|
package/cjs/useDataSource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDataSource.js","sources":["../../../packages/vuu-table/src/useDataSource.ts"],"sourcesContent":["import {\n DataSourceRow,\n DataSourceSubscribedMessage,\n DataSourceSubscribeCallback,\n} from \"@vuu-ui/vuu-data-types\";\nimport { MovingWindow, NULL_RANGE, Range } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { TableProps } from \"./Table\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\n\nexport interface DataSourceHookProps\n extends Pick<\n TableProps,\n | \"dataSource\"\n | \"defaultSelectedKeyValues\"\n | \"renderBufferSize\"\n | \"revealSelected\"\n > {\n onSizeChange: (size: number) => void;\n onSubscribed: (subscription: DataSourceSubscribedMessage) => void;\n}\n\nexport const useDataSource = ({\n dataSource,\n defaultSelectedKeyValues,\n onSizeChange,\n onSubscribed,\n renderBufferSize = 0,\n revealSelected,\n}: DataSourceHookProps) => {\n const [, forceUpdate] = useState<unknown>(null);\n const data = useRef<DataSourceRow[]>([]);\n const isMounted = useRef(true);\n const hasUpdated = useRef(false);\n const rangeRef = useRef<Range>(NULL_RANGE);\n const totalRowCountRef = useRef(0);\n\n const dataWindow = useMemo(\n () => new MovingWindow(NULL_RANGE),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useMemo(() => {\n dataSource.on(\"resumed\", () => {\n // When we resume a dataSource (after switching tabs etc)\n // client will receive rows. We may not have received any\n // setRange calls at this point so dataWindow range will\n //not yet be set. If the dataWindow range is already set,\n // this is a no-op.\n const { range } = dataSource;\n if (range.to !== 0) {\n dataWindow.setRange(dataSource.range);\n }\n });\n }, [dataSource, dataWindow]);\n\n const setData = useCallback(\n (updates: DataSourceRow[]) => {\n for (const row of updates) {\n dataWindow.add(row);\n }\n data.current = dataWindow.data;\n if (isMounted.current) {\n // TODO do we ever need to worry about missing updates here ?\n forceUpdate({});\n }\n },\n [dataWindow],\n );\n\n const datasourceMessageHandler: DataSourceSubscribeCallback = useCallback(\n (message) => {\n if (message.type === \"subscribed\") {\n onSubscribed?.(message);\n } else if (message.type === \"viewport-update\") {\n if (typeof message.size === \"number\") {\n onSizeChange?.(message.size);\n const size = dataWindow.data.length;\n dataWindow.setRowCount(message.size);\n totalRowCountRef.current = message.size;\n\n if (dataWindow.data.length < size) {\n if (isMounted.current === false) {\n console.log(\"setting state whilst unmounted\");\n }\n\n forceUpdate({});\n }\n }\n if (message.rows) {\n // Removed because known to cause issues when multiple server requests\n // are handled - a newer range can be overwritten with an out-of-date\n // range. If we need this for some reason, amke sure server sends up\n // top date range\n // if (message.range) {\n // if (message.range.to !== dataWindow.range.to) {\n // dataWindow.setRange(message.range);\n // }\n // }\n setData(message.rows);\n } else if (message.size === 0) {\n setData([]);\n } else if (typeof message.size === \"number\") {\n data.current = dataWindow.data;\n hasUpdated.current = true;\n }\n } else if (message.type === \"viewport-clear\") {\n onSizeChange?.(0);\n dataWindow.setRowCount(0);\n setData([]);\n\n if (isMounted.current === false) {\n console.log(\"setting state whilst unmounted\");\n }\n\n forceUpdate({});\n } else {\n console.log(`useDataSource unexpected message ${message.type}`);\n }\n },\n [dataWindow, onSizeChange, onSubscribed, setData],\n );\n\n const getSelectedRows = useCallback(() => {\n return dataWindow.getSelectedRows();\n }, [dataWindow]);\n\n useEffect(() => {\n isMounted.current = true;\n if (dataSource.status !== \"initialising\") {\n dataSource.resume?.(datasourceMessageHandler);\n }\n return () => {\n isMounted.current = false;\n dataSource.suspend?.();\n };\n }, [dataSource, datasourceMessageHandler]);\n\n useEffect(() => {\n if (dataSource.status === \"disabled\") {\n dataSource.enable?.(datasourceMessageHandler);\n }\n }, [dataSource, datasourceMessageHandler, renderBufferSize]);\n\n const setRange = useCallback(\n (viewportRange: VuuRange) => {\n if (!rangeRef.current.equals(viewportRange)) {\n const range = Range(viewportRange.from, viewportRange.to, {\n renderBufferSize,\n rowCount: totalRowCountRef.current,\n });\n\n dataWindow.setRange(range);\n\n if (dataSource.status !== \"subscribed\") {\n dataSource?.subscribe(\n {\n range,\n revealSelected,\n selectedKeyValues: defaultSelectedKeyValues,\n },\n datasourceMessageHandler,\n );\n } else {\n dataSource.range = rangeRef.current = range;\n }\n }\n },\n [\n dataSource,\n dataWindow,\n datasourceMessageHandler,\n defaultSelectedKeyValues,\n renderBufferSize,\n revealSelected,\n ],\n );\n\n return {\n data: data.current,\n dataRef: data,\n getSelectedRows,\n range: rangeRef.current,\n setRange,\n };\n};\n"],"names":["useState","useRef","NULL_RANGE","useMemo","MovingWindow","useCallback","useEffect","Range"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,CAAA,IAAA,EAAM,cAAc,EAAI,EAAA;AAAA,UACxD,gBAAA;AAAA,UACA,UAAU,gBAAiB,CAAA;AAAA,SAC5B,CAAA;AAED,QAAA,UAAA,CAAW,SAAS,KAAK,CAAA;AAEzB,QAAI,IAAA,UAAA,CAAW,WAAW,YAAc,EAAA;AACtC,UAAY,UAAA,EAAA,SAAA;AAAA,YACV;AAAA,cACE,KAAA;AAAA,cACA,cAAA;AAAA,cACA,iBAAmB,EAAA;AAAA,aACrB;AAAA,YACA;AAAA,WACF;AAAA,SACK,MAAA;AACL,UAAW,UAAA,CAAA,KAAA,GAAQ,SAAS,OAAU,GAAA,KAAA;AAAA;AACxC;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA;AAAA,MACA,UAAA;AAAA,MACA,wBAAA;AAAA,MACA,wBAAA;AAAA,MACA,gBAAA;AAAA,MACA;AAAA;AACF,GACF;AAEA,EAAO,OAAA;AAAA,IACL,MAAM,IAAK,CAAA,OAAA;AAAA,IACX,OAAS,EAAA,IAAA;AAAA,IACT,eAAA;AAAA,IACA,OAAO,QAAS,CAAA,OAAA;AAAA,IAChB;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useDataSource.js","sources":["../../../packages/vuu-table/src/useDataSource.ts"],"sourcesContent":["import {\n DataSourceRow,\n DataSourceSubscribedMessage,\n DataSourceSubscribeCallback,\n} from \"@vuu-ui/vuu-data-types\";\nimport { MovingWindow, NULL_RANGE, Range } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { TableProps } from \"./Table\";\nimport { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\n\nexport interface DataSourceHookProps\n extends Pick<\n TableProps,\n | \"dataSource\"\n | \"defaultSelectedKeyValues\"\n | \"renderBufferSize\"\n | \"revealSelected\"\n > {\n onSizeChange: (size: number) => void;\n onSubscribed: (subscription: DataSourceSubscribedMessage) => void;\n}\n\nexport const useDataSource = ({\n dataSource,\n defaultSelectedKeyValues,\n onSizeChange,\n onSubscribed,\n renderBufferSize = 0,\n revealSelected,\n}: DataSourceHookProps) => {\n const [, forceUpdate] = useState<unknown>(null);\n const data = useRef<DataSourceRow[]>([]);\n const isMounted = useRef(true);\n const hasUpdated = useRef(false);\n const rangeRef = useRef<Range>(NULL_RANGE);\n const totalRowCountRef = useRef(0);\n\n const dataWindow = useMemo(\n () => new MovingWindow(NULL_RANGE),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useMemo(() => {\n dataSource.on(\"resumed\", () => {\n // When we resume a dataSource (after switching tabs etc)\n // client will receive rows. We may not have received any\n // setRange calls at this point so dataWindow range will\n //not yet be set. If the dataWindow range is already set,\n // this is a no-op.\n const { range } = dataSource;\n if (range.to !== 0) {\n dataWindow.setRange(dataSource.range);\n }\n });\n }, [dataSource, dataWindow]);\n\n const setData = useCallback(\n (updates: DataSourceRow[]) => {\n for (const row of updates) {\n dataWindow.add(row);\n }\n data.current = dataWindow.data;\n if (isMounted.current) {\n // TODO do we ever need to worry about missing updates here ?\n forceUpdate({});\n }\n },\n [dataWindow],\n );\n\n const datasourceMessageHandler: DataSourceSubscribeCallback = useCallback(\n (message) => {\n if (message.type === \"subscribed\") {\n onSubscribed?.(message);\n } else if (message.type === \"viewport-update\") {\n if (typeof message.size === \"number\") {\n onSizeChange?.(message.size);\n const size = dataWindow.data.length;\n dataWindow.setRowCount(message.size);\n totalRowCountRef.current = message.size;\n\n if (dataWindow.data.length < size) {\n if (isMounted.current === false) {\n console.log(\"setting state whilst unmounted\");\n }\n\n forceUpdate({});\n }\n }\n if (message.rows) {\n // Removed because known to cause issues when multiple server requests\n // are handled - a newer range can be overwritten with an out-of-date\n // range. If we need this for some reason, amke sure server sends up\n // top date range\n // if (message.range) {\n // if (message.range.to !== dataWindow.range.to) {\n // dataWindow.setRange(message.range);\n // }\n // }\n setData(message.rows);\n } else if (message.size === 0) {\n setData([]);\n } else if (typeof message.size === \"number\") {\n data.current = dataWindow.data;\n hasUpdated.current = true;\n }\n } else if (message.type === \"viewport-clear\") {\n onSizeChange?.(0);\n dataWindow.setRowCount(0);\n setData([]);\n\n if (isMounted.current === false) {\n console.log(\"setting state whilst unmounted\");\n }\n\n forceUpdate({});\n } else {\n console.log(`useDataSource unexpected message ${message.type}`);\n }\n },\n [dataWindow, onSizeChange, onSubscribed, setData],\n );\n\n const getSelectedRows = useCallback(() => {\n return dataWindow.getSelectedRows();\n }, [dataWindow]);\n\n useEffect(() => {\n isMounted.current = true;\n if (dataSource.status !== \"initialising\") {\n dataSource.resume?.(datasourceMessageHandler);\n }\n return () => {\n isMounted.current = false;\n dataSource.suspend?.();\n };\n }, [dataSource, datasourceMessageHandler]);\n\n useEffect(() => {\n if (dataSource.status === \"disabled\") {\n dataSource.enable?.(datasourceMessageHandler);\n }\n }, [dataSource, datasourceMessageHandler, renderBufferSize]);\n\n const setRange = useCallback(\n (viewportRange: VuuRange) => {\n if (!rangeRef.current.equals(viewportRange)) {\n const range = Range(viewportRange.from, viewportRange.to, {\n renderBufferSize,\n rowCount: totalRowCountRef.current,\n });\n\n dataWindow.setRange(range);\n\n if (dataSource.status !== \"subscribed\") {\n dataSource?.subscribe(\n {\n range,\n revealSelected,\n selectedKeyValues: defaultSelectedKeyValues,\n },\n datasourceMessageHandler,\n );\n } else {\n dataSource.range = rangeRef.current = range;\n }\n }\n },\n [\n dataSource,\n dataWindow,\n datasourceMessageHandler,\n defaultSelectedKeyValues,\n renderBufferSize,\n revealSelected,\n ],\n );\n\n const removeColumnDataFromCache = useCallback(\n (indexOfRemovedColumn: number) => {\n dataWindow.spliceDataAtIndex(indexOfRemovedColumn);\n data.current = dataWindow.data;\n },\n [dataWindow],\n );\n\n return {\n data: data.current,\n dataRef: data,\n getSelectedRows,\n range: rangeRef.current,\n removeColumnDataFromCache,\n setRange,\n };\n};\n"],"names":["useState","useRef","NULL_RANGE","useMemo","MovingWindow","useCallback","useEffect","Range"],"mappings":";;;;;AAsBO,MAA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,EAAI,EAAA;AAAA,UACxD,gBAAA;AAAA,UACA,UAAU,gBAAiB,CAAA;AAAA,SAC5B,CAAA;AAED,QAAA,UAAA,CAAW,SAAS,KAAK,CAAA;AAEzB,QAAI,IAAA,UAAA,CAAW,WAAW,YAAc,EAAA;AACtC,UAAY,UAAA,EAAA,SAAA;AAAA,YACV;AAAA,cACE,KAAA;AAAA,cACA,cAAA;AAAA,cACA,iBAAmB,EAAA;AAAA,aACrB;AAAA,YACA;AAAA,WACF;AAAA,SACK,MAAA;AACL,UAAW,UAAA,CAAA,KAAA,GAAQ,SAAS,OAAU,GAAA,KAAA;AAAA;AACxC;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA;AAAA,MACA,UAAA;AAAA,MACA,wBAAA;AAAA,MACA,wBAAA;AAAA,MACA,gBAAA;AAAA,MACA;AAAA;AACF,GACF;AAEA,EAAA,MAAM,yBAA4B,GAAAF,iBAAA;AAAA,IAChC,CAAC,oBAAiC,KAAA;AAChC,MAAA,UAAA,CAAW,kBAAkB,oBAAoB,CAAA;AACjD,MAAA,IAAA,CAAK,UAAU,UAAW,CAAA,IAAA;AAAA,KAC5B;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AAEA,EAAO,OAAA;AAAA,IACL,MAAM,IAAK,CAAA,OAAA;AAAA,IACX,OAAS,EAAA,IAAA;AAAA,IACT,eAAA;AAAA,IACA,OAAO,QAAS,CAAA,OAAA;AAAA,IAChB,yBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
package/cjs/useMeasuredHeight.js
CHANGED
|
@@ -8,14 +8,18 @@ const useMeasuredHeight = ({
|
|
|
8
8
|
height: heightProp = 0
|
|
9
9
|
}) => {
|
|
10
10
|
const [measuredHeight, setMeasuredHeight] = react.useState(heightProp);
|
|
11
|
+
const lastMeasuredHeight = react.useRef(-1);
|
|
11
12
|
const resizeObserver = react.useMemo(() => {
|
|
12
13
|
return new ResizeObserver((entries) => {
|
|
13
14
|
for (const entry of entries) {
|
|
14
15
|
const [{ blockSize: measuredSize }] = entry.borderBoxSize;
|
|
15
16
|
const newHeight = Math.round(measuredSize);
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (lastMeasuredHeight.current !== newHeight) {
|
|
18
|
+
if (vuuUtils.isValidNumber(newHeight)) {
|
|
19
|
+
lastMeasuredHeight.current = newHeight;
|
|
20
|
+
setMeasuredHeight(newHeight);
|
|
21
|
+
onHeightMeasured?.(newHeight);
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
});
|
|
@@ -26,7 +30,8 @@ const useMeasuredHeight = ({
|
|
|
26
30
|
if (heightProp === 0) {
|
|
27
31
|
const { height } = el.getBoundingClientRect();
|
|
28
32
|
resizeObserver.observe(el);
|
|
29
|
-
|
|
33
|
+
const measuredHeight2 = Math.round(height);
|
|
34
|
+
setMeasuredHeight(measuredHeight2);
|
|
30
35
|
}
|
|
31
36
|
} else {
|
|
32
37
|
resizeObserver.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMeasuredHeight.js","sources":["../../../packages/vuu-table/src/useMeasuredHeight.ts"],"sourcesContent":["import { isValidNumber } from \"@vuu-ui/vuu-utils\";\nimport { RefCallback, useCallback, useMemo, useState } from \"react\";\n\ninterface MeasuredHeightHookProps {\n onHeightMeasured?: (height: number) => void;\n height?: number;\n}\n\nexport const useMeasuredHeight = ({\n onHeightMeasured,\n height: heightProp = 0,\n}: MeasuredHeightHookProps) => {\n const [measuredHeight, setMeasuredHeight] = useState(heightProp);\n\n const resizeObserver = useMemo(() => {\n return new ResizeObserver((entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const [{ blockSize: measuredSize }] = entry.borderBoxSize;\n const newHeight = Math.round(measuredSize);\n if (isValidNumber(newHeight)) {\n
|
|
1
|
+
{"version":3,"file":"useMeasuredHeight.js","sources":["../../../packages/vuu-table/src/useMeasuredHeight.ts"],"sourcesContent":["import { isValidNumber } from \"@vuu-ui/vuu-utils\";\nimport { RefCallback, useCallback, useMemo, useRef, useState } from \"react\";\n\ninterface MeasuredHeightHookProps {\n onHeightMeasured?: (height: number) => void;\n height?: number;\n}\n\nexport const useMeasuredHeight = ({\n onHeightMeasured,\n height: heightProp = 0,\n}: MeasuredHeightHookProps) => {\n const [measuredHeight, setMeasuredHeight] = useState(heightProp);\n const lastMeasuredHeight = useRef(-1);\n\n const resizeObserver = useMemo(() => {\n return new ResizeObserver((entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const [{ blockSize: measuredSize }] = entry.borderBoxSize;\n const newHeight = Math.round(measuredSize);\n if (lastMeasuredHeight.current !== newHeight) {\n if (isValidNumber(newHeight)) {\n lastMeasuredHeight.current = newHeight;\n setMeasuredHeight(newHeight);\n onHeightMeasured?.(newHeight);\n }\n }\n }\n });\n }, [onHeightMeasured]);\n\n const measuredRef = useCallback<RefCallback<HTMLDivElement>>(\n (el) => {\n if (el) {\n if (heightProp === 0) {\n const { height } = el.getBoundingClientRect();\n resizeObserver.observe(el);\n // avoids tiny sub-pixel discrepancies\n const measuredHeight = Math.round(height);\n setMeasuredHeight(measuredHeight);\n }\n } else {\n resizeObserver.disconnect();\n }\n },\n [resizeObserver, heightProp],\n );\n return { measuredHeight, measuredRef };\n};\n"],"names":["useState","useRef","useMemo","isValidNumber","useCallback","measuredHeight"],"mappings":";;;;;AAQO,MAAM,oBAAoB,CAAC;AAAA,EAChC,gBAAA;AAAA,EACA,QAAQ,UAAa,GAAA;AACvB,CAA+B,KAAA;AAC7B,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIA,eAAS,UAAU,CAAA;AAC/D,EAAM,MAAA,kBAAA,GAAqBC,aAAO,CAAE,CAAA,CAAA;AAEpC,EAAM,MAAA,cAAA,GAAiBC,cAAQ,MAAM;AACnC,IAAO,OAAA,IAAI,cAAe,CAAA,CAAC,OAAmC,KAAA;AAC5D,MAAA,KAAA,MAAW,SAAS,OAAS,EAAA;AAC3B,QAAA,MAAM,CAAC,EAAE,SAAA,EAAW,YAAa,EAAC,IAAI,KAAM,CAAA,aAAA;AAC5C,QAAM,MAAA,SAAA,GAAY,IAAK,CAAA,KAAA,CAAM,YAAY,CAAA;AACzC,QAAI,IAAA,kBAAA,CAAmB,YAAY,SAAW,EAAA;AAC5C,UAAI,IAAAC,sBAAA,CAAc,SAAS,CAAG,EAAA;AAC5B,YAAA,kBAAA,CAAmB,OAAU,GAAA,SAAA;AAC7B,YAAA,iBAAA,CAAkB,SAAS,CAAA;AAC3B,YAAA,gBAAA,GAAmB,SAAS,CAAA;AAAA;AAC9B;AACF;AACF,KACD,CAAA;AAAA,GACH,EAAG,CAAC,gBAAgB,CAAC,CAAA;AAErB,EAAA,MAAM,WAAc,GAAAC,iBAAA;AAAA,IAClB,CAAC,EAAO,KAAA;AACN,MAAA,IAAI,EAAI,EAAA;AACN,QAAA,IAAI,eAAe,CAAG,EAAA;AACpB,UAAA,MAAM,EAAE,MAAA,EAAW,GAAA,EAAA,CAAG,qBAAsB,EAAA;AAC5C,UAAA,cAAA,CAAe,QAAQ,EAAE,CAAA;AAEzB,UAAMC,MAAAA,eAAAA,GAAiB,IAAK,CAAA,KAAA,CAAM,MAAM,CAAA;AACxC,UAAA,iBAAA,CAAkBA,eAAc,CAAA;AAAA;AAClC,OACK,MAAA;AACL,QAAA,cAAA,CAAe,UAAW,EAAA;AAAA;AAC5B,KACF;AAAA,IACA,CAAC,gBAAgB,UAAU;AAAA,GAC7B;AACA,EAAO,OAAA,EAAE,gBAAgB,WAAY,EAAA;AACvC;;;;"}
|
package/cjs/useTable.js
CHANGED
|
@@ -141,10 +141,9 @@ const useTable = ({
|
|
|
141
141
|
selectionModel
|
|
142
142
|
]
|
|
143
143
|
);
|
|
144
|
-
const columnMap = react.useMemo(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
144
|
+
const columnMap = react.useMemo(() => {
|
|
145
|
+
return vuuUtils.buildColumnMap(dataSource.columns);
|
|
146
|
+
}, [dataSource.columns]);
|
|
148
147
|
const onSubscribed = react.useCallback(
|
|
149
148
|
({ tableSchema }) => {
|
|
150
149
|
if (tableSchema) {
|
|
@@ -173,7 +172,14 @@ const useTable = ({
|
|
|
173
172
|
size,
|
|
174
173
|
showPaginationControls
|
|
175
174
|
});
|
|
176
|
-
const {
|
|
175
|
+
const {
|
|
176
|
+
data,
|
|
177
|
+
dataRef,
|
|
178
|
+
getSelectedRows,
|
|
179
|
+
range,
|
|
180
|
+
removeColumnDataFromCache,
|
|
181
|
+
setRange
|
|
182
|
+
} = useDataSource.useDataSource({
|
|
177
183
|
dataSource,
|
|
178
184
|
defaultSelectedKeyValues,
|
|
179
185
|
renderBufferSize,
|
|
@@ -254,6 +260,19 @@ const useTable = ({
|
|
|
254
260
|
},
|
|
255
261
|
[dataSource, tableConfig$1, applyTableConfigChange]
|
|
256
262
|
);
|
|
263
|
+
const removeColumn = react.useCallback(
|
|
264
|
+
(action) => {
|
|
265
|
+
const { column } = action;
|
|
266
|
+
const newTableConfig = {
|
|
267
|
+
...tableConfig$1,
|
|
268
|
+
columns: tableConfig$1.columns.filter((col) => col.name !== column.name)
|
|
269
|
+
};
|
|
270
|
+
const indexOfRemovedColumn = columnMap[column.name];
|
|
271
|
+
removeColumnDataFromCache(indexOfRemovedColumn);
|
|
272
|
+
applyTableConfigChange(newTableConfig);
|
|
273
|
+
},
|
|
274
|
+
[applyTableConfigChange, columnMap, removeColumnDataFromCache, tableConfig$1]
|
|
275
|
+
);
|
|
257
276
|
const hideColumns = react.useCallback(
|
|
258
277
|
(action) => {
|
|
259
278
|
const { columns: columns2 } = action;
|
|
@@ -308,13 +327,18 @@ const useTable = ({
|
|
|
308
327
|
type: "hideColumns",
|
|
309
328
|
columns: [action.column]
|
|
310
329
|
});
|
|
330
|
+
case "removeColumn":
|
|
331
|
+
return removeColumn({
|
|
332
|
+
type: "removeColumn",
|
|
333
|
+
column: action.column
|
|
334
|
+
});
|
|
311
335
|
case "pinColumn":
|
|
312
336
|
return pinColumn(action);
|
|
313
337
|
default:
|
|
314
338
|
vuuUtils.logUnhandledMessage(type, "[vuu-table] handleColumnDisplayAction");
|
|
315
339
|
}
|
|
316
340
|
},
|
|
317
|
-
[hideColumns, pinColumn]
|
|
341
|
+
[hideColumns, pinColumn, removeColumn]
|
|
318
342
|
);
|
|
319
343
|
const handleDisplaySettingsAction = react.useCallback(
|
|
320
344
|
(action) => {
|