@vuu-ui/vuu-table 0.8.12 → 0.8.13-debug
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/index.js +3450 -1
- package/cjs/index.js.map +4 -4
- package/esm/index.js +3511 -1
- package/esm/index.js.map +4 -4
- package/index.css +596 -1
- package/index.css.map +3 -3
- package/package.json +9 -9
- package/types/vuu-table/src/{table-next/Row.d.ts → Row.d.ts} +5 -5
- package/types/vuu-table/src/Table.d.ts +72 -0
- package/types/vuu-table/src/cell-renderers/cell-utils.d.ts +7 -0
- package/types/vuu-table/src/cell-renderers/checkbox-cell/CheckboxCell.d.ts +3 -0
- package/types/vuu-table/src/cell-renderers/checkbox-cell/index.d.ts +1 -0
- package/types/vuu-table/src/cell-renderers/dropdown-cell/DropdownCell.d.ts +4 -0
- package/types/vuu-table/src/cell-renderers/index.d.ts +5 -0
- package/types/vuu-table/src/{table-next/cell-renderers → cell-renderers}/input-cell/InputCell.d.ts +1 -1
- package/types/vuu-table/src/cell-renderers/lookup-cell/LookupCell.d.ts +3 -0
- package/types/vuu-table/src/cell-renderers/lookup-cell/index.d.ts +1 -0
- package/types/vuu-table/src/cell-renderers/toggle-cell/ToggleCell.d.ts +4 -0
- package/types/vuu-table/src/cell-renderers/toggle-cell/index.d.ts +1 -0
- package/types/vuu-table/src/{table-next/column-header-pill → column-header-pill}/ColumnHeaderPill.d.ts +3 -3
- package/types/vuu-table/src/{table-next/column-header-pill → column-header-pill}/GroupColumnPill.d.ts +2 -2
- package/types/vuu-table/src/{table-next/column-header-pill → column-header-pill}/SortIndicator.d.ts +2 -2
- package/types/vuu-table/src/{table-next/column-menu → column-menu}/ColumnMenu.d.ts +2 -2
- package/types/vuu-table/src/{table-next/column-resizing → column-resizing}/useTableColumnResize.d.ts +2 -2
- package/types/vuu-table/src/{table-next/context-menu → context-menu}/index.d.ts +1 -1
- package/types/vuu-table/src/{table-next/context-menu/useTableContextMenu.d.ts → context-menu/useHandleTableContextMenu.d.ts} +3 -3
- package/types/vuu-table/src/header-cell/GroupHeaderCellNext.d.ts +10 -0
- package/types/vuu-table/src/{table-next/header-cell → header-cell}/HeaderCell.d.ts +2 -2
- package/types/vuu-table/src/{table-next/header-cell → header-cell}/index.d.ts +0 -1
- package/types/vuu-table/src/index.d.ts +9 -4
- package/types/vuu-table/src/{table-next/table-cell → table-cell}/TableCell.d.ts +1 -1
- package/types/vuu-table/src/{table-next/table-cell → table-cell}/TableGroupCell.d.ts +1 -1
- package/types/vuu-table/src/{table-next/table-config.d.ts → table-config.d.ts} +1 -1
- package/types/vuu-table/src/{table-next/table-dom-utils.d.ts → table-dom-utils.d.ts} +3 -1
- package/types/vuu-table/src/table-header/TableHeader.d.ts +18 -0
- package/types/vuu-table/src/table-header/useTableHeader.d.ts +15 -0
- package/types/vuu-table/src/useCell.d.ts +6 -0
- package/types/vuu-table/src/useCellEditing.d.ts +10 -0
- package/types/vuu-table/src/useControlledTableNavigation.d.ts +7 -0
- package/types/vuu-table/src/{table-next/useDataSource.d.ts → useDataSource.d.ts} +5 -3
- package/types/vuu-table/src/{table-next/useKeyboardNavigation.d.ts → useKeyboardNavigation.d.ts} +9 -2
- package/types/vuu-table/src/useSelection.d.ts +14 -0
- package/types/vuu-table/src/useTable.d.ts +66 -0
- package/types/vuu-table/src/useTableContextMenu.d.ts +11 -0
- package/types/vuu-table/src/{table-next/useTableModel.d.ts → useTableModel.d.ts} +12 -14
- package/types/vuu-table/src/{table-next/useTableViewport.d.ts → useTableViewport.d.ts} +2 -2
- package/types/vuu-table/src/{table-next/useVirtualViewport.d.ts → useVirtualViewport.d.ts} +2 -2
- package/types/vuu-ui-controls/src/drag-drop/DragDropState.d.ts +15 -0
- package/types/vuu-ui-controls/src/drag-drop/dragDropTypesNext.d.ts +91 -0
- package/LICENSE +0 -201
- package/types/vuu-layout/src/Component.d.ts +0 -7
- package/types/vuu-layout/src/DraggableLayout.d.ts +0 -7
- package/types/vuu-layout/src/dock-layout/DockLayout.d.ts +0 -10
- package/types/vuu-layout/src/dock-layout/Drawer.d.ts +0 -18
- package/types/vuu-layout/src/dock-layout/index.d.ts +0 -2
- package/types/vuu-layout/src/drag-drop/BoxModel.d.ts +0 -143
- package/types/vuu-layout/src/drag-drop/DragState.d.ts +0 -46
- package/types/vuu-layout/src/drag-drop/Draggable.d.ts +0 -24
- package/types/vuu-layout/src/drag-drop/DropMenu.d.ts +0 -10
- package/types/vuu-layout/src/drag-drop/DropTarget.d.ts +0 -61
- package/types/vuu-layout/src/drag-drop/DropTargetRenderer.d.ts +0 -18
- package/types/vuu-layout/src/drag-drop/dragDropTypes.d.ts +0 -51
- package/types/vuu-layout/src/drag-drop/index.d.ts +0 -4
- package/types/vuu-layout/src/flexbox/Flexbox.d.ts +0 -5
- package/types/vuu-layout/src/flexbox/FlexboxLayout.d.ts +0 -6
- package/types/vuu-layout/src/flexbox/FluidGrid.d.ts +0 -7
- package/types/vuu-layout/src/flexbox/FluidGridLayout.d.ts +0 -6
- package/types/vuu-layout/src/flexbox/Splitter.d.ts +0 -13
- package/types/vuu-layout/src/flexbox/flexbox-utils.d.ts +0 -12
- package/types/vuu-layout/src/flexbox/flexboxTypes.d.ts +0 -51
- package/types/vuu-layout/src/flexbox/index.d.ts +0 -4
- package/types/vuu-layout/src/flexbox/useResponsiveSizing.d.ts +0 -10
- package/types/vuu-layout/src/flexbox/useSplitterResizing.d.ts +0 -2
- package/types/vuu-layout/src/index.d.ts +0 -22
- package/types/vuu-layout/src/layout-action.d.ts +0 -22
- package/types/vuu-layout/src/layout-header/Header.d.ts +0 -13
- package/types/vuu-layout/src/layout-header/index.d.ts +0 -1
- package/types/vuu-layout/src/layout-persistence/LayoutPersistenceManager.d.ts +0 -53
- package/types/vuu-layout/src/layout-persistence/LocalLayoutPersistenceManager.d.ts +0 -18
- package/types/vuu-layout/src/layout-persistence/data.d.ts +0 -3
- package/types/vuu-layout/src/layout-persistence/index.d.ts +0 -4
- package/types/vuu-layout/src/layout-persistence/useLayoutContextMenuItems.d.ts +0 -8
- package/types/vuu-layout/src/layout-provider/LayoutProvider.d.ts +0 -15
- package/types/vuu-layout/src/layout-provider/LayoutProviderContext.d.ts +0 -9
- package/types/vuu-layout/src/layout-provider/index.d.ts +0 -2
- package/types/vuu-layout/src/layout-provider/useLayoutDragDrop.d.ts +0 -4
- package/types/vuu-layout/src/layout-reducer/flexUtils.d.ts +0 -22
- package/types/vuu-layout/src/layout-reducer/index.d.ts +0 -4
- package/types/vuu-layout/src/layout-reducer/insert-layout-element.d.ts +0 -8
- package/types/vuu-layout/src/layout-reducer/layout-reducer.d.ts +0 -3
- package/types/vuu-layout/src/layout-reducer/layoutTypes.d.ts +0 -168
- package/types/vuu-layout/src/layout-reducer/layoutUtils.d.ts +0 -31
- package/types/vuu-layout/src/layout-reducer/move-layout-element.d.ts +0 -3
- package/types/vuu-layout/src/layout-reducer/remove-layout-element.d.ts +0 -3
- package/types/vuu-layout/src/layout-reducer/replace-layout-element.d.ts +0 -6
- package/types/vuu-layout/src/layout-reducer/resize-flex-children.d.ts +0 -4
- package/types/vuu-layout/src/layout-reducer/wrap-layout-element.d.ts +0 -9
- package/types/vuu-layout/src/layout-view/View.d.ts +0 -11
- package/types/vuu-layout/src/layout-view/ViewContext.d.ts +0 -30
- package/types/vuu-layout/src/layout-view/index.d.ts +0 -4
- package/types/vuu-layout/src/layout-view/useView.d.ts +0 -21
- package/types/vuu-layout/src/layout-view/useViewActionDispatcher.d.ts +0 -9
- package/types/vuu-layout/src/layout-view/useViewResize.d.ts +0 -7
- package/types/vuu-layout/src/layout-view/viewTypes.d.ts +0 -21
- package/types/vuu-layout/src/measured-container/MeasuredContainer.d.ts +0 -9
- package/types/vuu-layout/src/measured-container/index.d.ts +0 -2
- package/types/vuu-layout/src/measured-container/useMeasuredContainer.d.ts +0 -22
- package/types/vuu-layout/src/measured-container/useResizeObserver.d.ts +0 -15
- package/types/vuu-layout/src/overflow-container/OverflowContainer.d.ts +0 -17
- package/types/vuu-layout/src/overflow-container/index.d.ts +0 -2
- package/types/vuu-layout/src/overflow-container/overflow-utils.d.ts +0 -49
- package/types/vuu-layout/src/overflow-container/useOverflowContainer.d.ts +0 -20
- package/types/vuu-layout/src/palette/Palette.d.ts +0 -22
- package/types/vuu-layout/src/palette/index.d.ts +0 -1
- package/types/vuu-layout/src/placeholder/Placeholder.d.ts +0 -12
- package/types/vuu-layout/src/placeholder/index.d.ts +0 -1
- package/types/vuu-layout/src/registry/ComponentRegistry.d.ts +0 -13
- package/types/vuu-layout/src/registry/index.d.ts +0 -1
- package/types/vuu-layout/src/responsive/breakpoints.d.ts +0 -4
- package/types/vuu-layout/src/responsive/index.d.ts +0 -3
- package/types/vuu-layout/src/responsive/use-breakpoints.d.ts +0 -7
- package/types/vuu-layout/src/responsive/useResizeObserver.d.ts +0 -13
- package/types/vuu-layout/src/responsive/utils.d.ts +0 -6
- package/types/vuu-layout/src/stack/Stack.d.ts +0 -4
- package/types/vuu-layout/src/stack/StackLayout.d.ts +0 -7
- package/types/vuu-layout/src/stack/index.d.ts +0 -3
- package/types/vuu-layout/src/stack/stackTypes.d.ts +0 -21
- package/types/vuu-layout/src/toolbar/Toolbar.d.ts +0 -19
- package/types/vuu-layout/src/toolbar/index.d.ts +0 -1
- package/types/vuu-layout/src/toolbar/toolbar-dom-utils.d.ts +0 -3
- package/types/vuu-layout/src/toolbar/useKeyboardNavigation.d.ts +0 -32
- package/types/vuu-layout/src/toolbar/useSelection.d.ts +0 -22
- package/types/vuu-layout/src/toolbar/useToolbar.d.ts +0 -28
- package/types/vuu-layout/src/tools/config-wrapper/ConfigWrapper.d.ts +0 -2
- package/types/vuu-layout/src/tools/config-wrapper/index.d.ts +0 -1
- package/types/vuu-layout/src/tools/devtools-box/layout-configurator.d.ts +0 -31
- package/types/vuu-layout/src/tools/devtools-tree/layout-tree-viewer.d.ts +0 -5
- package/types/vuu-layout/src/tools/index.d.ts +0 -3
- package/types/vuu-layout/src/use-persistent-state.d.ts +0 -11
- package/types/vuu-layout/src/utils/index.d.ts +0 -6
- package/types/vuu-layout/src/utils/pathUtils.d.ts +0 -31
- package/types/vuu-layout/src/utils/propUtils.d.ts +0 -5
- package/types/vuu-layout/src/utils/react-utils.d.ts +0 -4
- package/types/vuu-layout/src/utils/refUtils.d.ts +0 -2
- package/types/vuu-layout/src/utils/styleUtils.d.ts +0 -3
- package/types/vuu-layout/src/utils/typeOf.d.ts +0 -4
- package/types/vuu-table/src/table/ColumnResizer.d.ts +0 -8
- package/types/vuu-table/src/table/DragVisualizer.d.ts +0 -8
- package/types/vuu-table/src/table/RowBasedTable.d.ts +0 -4
- package/types/vuu-table/src/table/SortIndicator.d.ts +0 -7
- package/types/vuu-table/src/table/Table.d.ts +0 -9
- package/types/vuu-table/src/table/TableCell.d.ts +0 -4
- package/types/vuu-table/src/table/TableGroupCell.d.ts +0 -4
- package/types/vuu-table/src/table/TableGroupHeaderCell.d.ts +0 -13
- package/types/vuu-table/src/table/TableHeaderCell.d.ts +0 -11
- package/types/vuu-table/src/table/TableRow.d.ts +0 -16
- package/types/vuu-table/src/table/cell-renderers/index.d.ts +0 -1
- package/types/vuu-table/src/table/cell-renderers/json-cell/JsonCell.d.ts +0 -1
- package/types/vuu-table/src/table/cell-renderers/json-cell/index.d.ts +0 -1
- package/types/vuu-table/src/table/context-menu/buildContextMenuDescriptors.d.ts +0 -4
- package/types/vuu-table/src/table/context-menu/index.d.ts +0 -2
- package/types/vuu-table/src/table/context-menu/useTableContextMenu.d.ts +0 -16
- package/types/vuu-table/src/table/dataTableTypes.d.ts +0 -109
- package/types/vuu-table/src/table/filter-indicator.d.ts +0 -13
- package/types/vuu-table/src/table/index.d.ts +0 -10
- package/types/vuu-table/src/table/keyUtils.d.ts +0 -19
- package/types/vuu-table/src/table/useDataSource.d.ts +0 -41
- package/types/vuu-table/src/table/useDraggableColumn.d.ts +0 -9
- package/types/vuu-table/src/table/useKeyboardNavigation.d.ts +0 -22
- package/types/vuu-table/src/table/useMeasuredContainer.d.ts +0 -30
- package/types/vuu-table/src/table/useMeasuredSize.d.ts +0 -26
- package/types/vuu-table/src/table/useResizeObserver.d.ts +0 -15
- package/types/vuu-table/src/table/useSelection.d.ts +0 -9
- package/types/vuu-table/src/table/useTable.d.ts +0 -62
- package/types/vuu-table/src/table/useTableColumnResize.d.ts +0 -17
- package/types/vuu-table/src/table/useTableModel.d.ts +0 -80
- package/types/vuu-table/src/table/useTableScroll.d.ts +0 -29
- package/types/vuu-table/src/table/useVirtualViewport.d.ts +0 -17
- package/types/vuu-table/src/table-next/TableNext.d.ts +0 -4
- package/types/vuu-table/src/table-next/cell-renderers/dropdown-cell/DropdownCell.d.ts +0 -4
- package/types/vuu-table/src/table-next/cell-renderers/index.d.ts +0 -2
- package/types/vuu-table/src/table-next/header-cell/GroupHeaderCell.d.ts +0 -9
- package/types/vuu-table/src/table-next/header-cell/GroupHeaderCellNext.d.ts +0 -9
- package/types/vuu-table/src/table-next/index.d.ts +0 -5
- package/types/vuu-table/src/table-next/useCell.d.ts +0 -6
- package/types/vuu-table/src/table-next/useCellEditing.d.ts +0 -7
- package/types/vuu-table/src/table-next/useTableContextMenu.d.ts +0 -8
- package/types/vuu-table/src/table-next/useTableNext.d.ts +0 -66
- /package/types/vuu-table/src/{table-next/cell-renderers → cell-renderers}/dropdown-cell/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/cell-renderers → cell-renderers}/input-cell/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/column-header-pill → column-header-pill}/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/column-menu → column-menu}/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/column-resizing → column-resizing}/ColumnResizer.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/column-resizing → column-resizing}/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/context-menu → context-menu}/buildContextMenuDescriptors.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/moving-window.d.ts → moving-window.d.ts} +0 -0
- /package/types/vuu-table/src/{table-next/table-cell → table-cell}/index.d.ts +0 -0
- /package/types/vuu-table/src/{table-next/useInitialValue.d.ts → useInitialValue.d.ts} +0 -0
- /package/types/vuu-table/src/{table-next/useResizeObserver.d.ts → useResizeObserver.d.ts} +0 -0
- /package/types/vuu-table/src/{table-next/useTableScroll.d.ts → useTableScroll.d.ts} +0 -0
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,3451 @@
|
|
|
1
|
-
"use strict";var Cl=Object.create;var Gt=Object.defineProperty;var bl=Object.getOwnPropertyDescriptor;var gl=Object.getOwnPropertyNames;var hl=Object.getPrototypeOf,vl=Object.prototype.hasOwnProperty;var yl=(e,t)=>{for(var o in t)Gt(e,o,{get:t[o],enumerable:!0})},Yo=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of gl(t))!vl.call(e,r)&&r!==o&&Gt(e,r,{get:()=>t[r],enumerable:!(n=bl(t,r))||n.enumerable});return e};var W=(e,t,o)=>(o=e!=null?Cl(hl(e)):{},Yo(t||!e||!e.__esModule?Gt(o,"default",{value:e,enumerable:!0}):o,e)),Tl=e=>Yo(Gt({},"__esModule",{value:!0}),e);var vi={};yl(vi,{ColumnResizer:()=>ft,GroupHeaderCellNext:()=>At,Table:()=>Ms,TableNext:()=>rl,buildContextMenuDescriptors:()=>Ct,isShowColumnSettings:()=>is,isShowTableSettings:()=>as,updateTableConfig:()=>jt,useMeasuredContainer:()=>ko,useSelection:()=>Mt,useTableColumnResize:()=>yt,useTableContextMenu:()=>bt,useTableModel:()=>No,useTableViewport:()=>Rt});module.exports=Tl(vi);var Be=require("react");var jo=require("react/jsx-runtime"),Zo=()=>{},wl="vuuColumnResizer",ft=({onDrag:e,onDragEnd:t=Zo,onDragStart:o=Zo})=>{let n=(0,Be.useRef)(0),r=(0,Be.useCallback)(i=>{i.stopPropagation&&i.stopPropagation(),i.preventDefault&&i.preventDefault();let a=Math.round(i.clientX),c=a-n.current;n.current=a,c!==0&&e(i,c)},[e]),l=(0,Be.useCallback)(i=>{window.removeEventListener("mouseup",l),window.removeEventListener("mousemove",r),t(i)},[t,r]),s=(0,Be.useCallback)(i=>{o(i),n.current=Math.round(i.clientX),window.addEventListener("mouseup",l),window.addEventListener("mousemove",r),i.stopPropagation&&i.stopPropagation(),i.preventDefault&&i.preventDefault()},[o,r,l]);return(0,jo.jsx)("div",{className:wl,"data-align":"end",onMouseDown:s})};var qo=require("@vuu-ui/vuu-utils"),Ct=e=>(t,o)=>{let n=[];if(e===void 0)return n;if(t==="header"||t==="column-menu")n.push(...Dl(o,e)),n.push(...xl(o,e)),n.push(...Ml(o,e)),n.push(...Rl(o)),n.push({action:"column-settings",icon:"cog",label:"Column Settings",options:o}),n.push({action:"table-settings",icon:"cog",label:"DataGrid Settings",options:o});else if(t==="filter"){let{column:r,filter:l}=o,s=(l==null?void 0:l.column)===(r==null?void 0:r.name);n.push({label:"Edit filter",action:"filter-edit",options:o}),n.push({label:"Remove filter",action:"filter-remove-column",options:o}),r&&!s&&n.push({label:"Remove all filters",action:"remove-filters",options:o})}return n};function Dl(e,{sort:{sortDefs:t}}){let{column:o}=e,n=[];if(o===void 0)return n;let r=t.length>0;return o.sorted==="A"?n.push({label:"Reverse Sort (DSC)",action:"sort-dsc",options:e}):o.sorted==="D"?n.push({label:"Reverse Sort (ASC)",action:"sort-asc",options:e}):typeof o.sorted=="number"?(o.sorted>0?n.push({label:"Reverse Sort (DSC)",action:"sort-add-dsc",options:e}):n.push({label:"Reverse Sort (ASC)",action:"sort-add-asc",options:e}),r&&Math.abs(o.sorted)<t.length&&n.push({label:"Remove from sort",action:"sort-remove",options:e}),n.push({label:"New Sort",children:[{label:"Ascending",action:"sort-asc",options:e},{label:"Descending",action:"sort-dsc",options:e}]})):r?(n.push({label:"Add to sort",children:[{label:"Ascending",action:"sort-add-asc",options:e},{label:"Descending",action:"sort-add-dsc",options:e}]}),n.push({label:"New Sort",children:[{label:"Ascending",action:"sort-asc",options:e},{label:"Descending",action:"sort-dsc",options:e}]})):n.push({label:"Sort",children:[{label:"Ascending",action:"sort-asc",options:e},{label:"Descending",action:"sort-dsc",options:e}]}),n}function Ml(e,t){let{column:o}=e;if(o===void 0||t.groupBy.length===0)return[];let{name:n,label:r=n}=o;return[{label:`Aggregate ${r}`,children:[{label:"Count",action:"agg-count",options:e},{label:"Distinct",action:"agg-distinct",options:e}].concat((0,qo.isNumericColumn)(o)?[{label:"Sum",action:"agg-sum",options:e},{label:"Avg",action:"agg-avg",options:e},{label:"High",action:"agg-high",options:e},{label:"Low",action:"agg-low",options:e}]:[])}]}var yo=(e,t)=>({label:`Pin ${t}`,action:`column-pin-${t}`,options:e}),go=e=>yo(e,"left"),ho=e=>yo(e,"floating"),vo=e=>yo(e,"right");function Rl(e){let{column:t}=e;if(t===void 0)return[];let{pin:o}=t,n=[{label:"Hide column",action:"column-hide",options:e},{label:"Remove column",action:"column-remove",options:e}];return o===void 0?n.push({label:"Pin column",children:[go(e),ho(e),vo(e)]}):o==="left"?n.push({label:"Unpin column",action:"column-unpin",options:e},{label:"Pin column",children:[ho(e),vo(e)]}):o==="right"?n.push({label:"Unpin column",action:"column-unpin",options:e},{label:"Pin column",children:[go(e),ho(e)]}):o==="floating"&&n.push({label:"Unpin column",action:"column-unpin",options:e},{label:"Pin column",children:[go(e),vo(e)]}),n}function xl(e,{groupBy:t}){let{column:o}=e,n=[];if(o===void 0)return n;let{name:r,label:l=r}=o;return t.length===0?n.push({label:`Group by ${l}`,action:"group",options:e}):n.push({label:`Add ${l} to group by`,action:"group-add",options:e}),n}var en=require("@vuu-ui/vuu-utils"),B=require("@vuu-ui/vuu-utils"),Pl=(e,t)=>{if(e.filterStruct&&t){let[o,n]=(0,en.removeColumnFromFilter)(t,e.filterStruct);return{filter:n,filterStruct:o}}else return e},{Average:Hl,Count:El,Distinct:Sl,High:Al,Low:Ll,Sum:Kl}=B.AggregationType,bt=({dataSource:e,onPersistentColumnOperation:t})=>n=>{let r=n.options;if(r.column&&e){let{column:l}=r;switch(n.menuId){case"sort-asc":return e.sort=(0,B.setSortColumn)(e.sort,l,"A"),!0;case"sort-dsc":return e.sort=(0,B.setSortColumn)(e.sort,l,"D"),!0;case"sort-add-asc":return e.sort=(0,B.addSortColumn)(e.sort,l,"A"),!0;case"sort-add-dsc":return e.sort=(0,B.addSortColumn)(e.sort,l,"D"),!0;case"group":return e.groupBy=(0,B.addGroupColumn)(e.groupBy,l),!0;case"group-add":return e.groupBy=(0,B.addGroupColumn)(e.groupBy,l),!0;case"column-hide":return t({type:"hideColumns",columns:[l]}),!0;case"column-remove":return e.columns=e.columns.filter(s=>s!==l.name),!0;case"filter-remove-column":return e.filter=Pl(e.filter,l),!0;case"remove-filters":return e.filter={filter:""},!0;case"agg-avg":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,Hl),!0;case"agg-high":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,Al),!0;case"agg-low":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,Ll),!0;case"agg-count":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,El),!0;case"agg-distinct":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,Sl),!0;case"agg-sum":return e.aggregations=(0,B.setAggregations)(e.aggregations,l,Kl),!0;case"column-pin-floating":return t({type:"pinColumn",column:l,pin:"floating"}),!0;case"column-pin-left":return t({type:"pinColumn",column:l,pin:"left"}),!0;case"column-pin-right":return t({type:"pinColumn",column:l,pin:"right"}),!0;case"column-unpin":return t({type:"pinColumn",column:l,pin:void 0}),!0;case"column-settings":return t({type:"columnSettings",column:l}),!0;case"table-settings":return t({type:"tableSettings"}),!0;default:}}return!1};var Yn=require("@vuu-ui/vuu-popups"),_t=require("@salt-ds/core");var re=require("@vuu-ui/vuu-utils"),Xe=require("react");var j=require("@vuu-ui/vuu-utils"),an=W(require("classnames")),ht=require("react");var Wt=require("@vuu-ui/vuu-utils"),on=require("@vuu-ui/vuu-ui-controls"),nn=W(require("classnames")),ve=require("react");var gt=require("react/jsx-runtime"),{KEY:tn}=Wt.metadataKeys,To=(0,ve.memo)(({className:e,column:t,columnMap:o,onClick:n,row:r})=>{let l=(0,ve.useRef)(null),{align:s,CellRenderer:i,key:a,pin:c,editable:u,resizing:p,valueFormatter:m}=t,[C,h]=(0,ve.useState)(!1),v=m(r[a]),[T,x]=(0,ve.useState)(v),g=()=>{var H;(H=l.current)==null||H.focus()},f=H=>{H.key==="Enter"&&h(!0)},M=(0,ve.useCallback)(H=>{n==null||n(H,t)},[t,n]),D=()=>{h(!0)},w=(H="",y="",R=!0,A=!1)=>{var S;h(!1),A?x(H):y!==H&&x(y),R===!1&&((S=l.current)==null||S.focus())},d=(0,nn.default)(e,{vuuAlignRight:s==="right",vuuPinFloating:c==="floating",vuuPinLeft:c==="left",vuuPinRight:c==="right","vuuTableCell-resizing":p})||void 0,b=(0,Wt.getColumnStyle)(t);return u?(0,gt.jsx)("div",{className:d,"data-editable":!0,role:"cell",style:b,onKeyDown:f,children:(0,gt.jsx)(on.EditableLabel,{editing:C,value:T,onChange:x,onMouseDownCapture:g,onEnterEditMode:D,onExitEditMode:w,onKeyDown:f,ref:l,tabIndex:0},"title")}):(0,gt.jsx)("div",{className:d,role:"cell",style:b,onClick:M,children:i?(0,gt.jsx)(i,{column:t,columnMap:o,row:r}):v})},kl);To.displayName="TableCell";function kl(e,t){return e.column===t.column&&e.onClick===t.onClick&&e.row[tn]===t.row[tn]&&e.row[e.column.key]===t.row[t.column.key]}var _e=require("@vuu-ui/vuu-utils"),rn=require("react");var Ue=require("react/jsx-runtime"),{IS_LEAF:Nl}=_e.metadataKeys,ln=({column:e,onClick:t,row:o})=>{let{columns:n}=e,[r,l]=(0,_e.getGroupValueAndOffset)(n,o),s=(0,rn.useCallback)(u=>{t==null||t(u,e)},[e,t]),i=(0,_e.getColumnStyle)(e),a=o[Nl],c=Array(l).fill(0).map((u,p)=>(0,Ue.jsx)("span",{className:"vuuTableGroupCell-spacer"},p));return(0,Ue.jsxs)("div",{className:"vuuTableGroupCell vuuPinLeft",onClick:a?void 0:s,role:"cell",style:i,children:[c,a?null:(0,Ue.jsx)("span",{className:"vuuTableGroupCell-toggle","data-icon":"triangle-right"}),(0,Ue.jsx)("span",{children:r})]})};var vt=require("react/jsx-runtime"),{IDX:zl,IS_EXPANDED:Il,SELECTED:Vl}=j.metadataKeys,{True:sn,First:$l,Last:Fl}=j.RowSelected,Je="vuuTableRow",cn=(0,ht.memo)(function({columnMap:t,columns:o,offset:n,onClick:r,onToggleGroup:l,virtualColSpan:s=0,row:i}){let{[zl]:a,[Il]:c,[Vl]:u}=i,p=(0,an.default)(Je,{[`${Je}-even`]:a%2===0,[`${Je}-expanded`]:c,[`${Je}-selected`]:u&sn,[`${Je}-selectedStart`]:u&$l,[`${Je}-selectedEnd`]:u&Fl}),m=(0,ht.useCallback)(h=>{let v=h.shiftKey,T=h.ctrlKey||h.metaKey;r==null||r(i,v,T)},[r,i]),C=(0,ht.useCallback)((h,v)=>{((0,j.isGroupColumn)(v)||(0,j.isJsonGroup)(v,i))&&(h.stopPropagation(),l==null||l(i,v))},[l,i]);return(0,vt.jsxs)("div",{"aria-selected":u&sn?!0:void 0,"aria-rowindex":a,className:p,onClick:m,role:"row",style:{transform:`translate3d(0px, ${n}px, 0px)`},children:[s>0?(0,vt.jsx)("div",{role:"cell",style:{width:s}}):null,o.filter(j.notHidden).map(h=>{let v=(0,j.isGroupColumn)(h),T=(0,j.isJsonColumn)(h);return(0,vt.jsx)(v?ln:To,{column:h,columnMap:t,onClick:v||T?C:void 0,row:i},h.name)})]})});var wo=W(require("classnames")),mn=require("react");var Le=require("react"),yt=({column:e,onResize:t,rootRef:o})=>{let n=(0,Le.useRef)(0),r=(0,Le.useRef)(!1),{name:l}=e,s=(0,Le.useCallback)(()=>{if(t&&o.current){console.log("handleResizeStart");let{width:c}=o.current.getBoundingClientRect();n.current=Math.round(c),r.current=!0,t==null||t("begin",l)}},[l,t,o]),i=(0,Le.useCallback)((c,u)=>{if(o.current&&t){let{width:p}=o.current.getBoundingClientRect(),m=Math.round(p)+u;m!==n.current&&m>0&&(t("resize",l,m),n.current=m)}},[l,t,o]),a=(0,Le.useCallback)(()=>{t&&(t("end",l,n.current),setTimeout(()=>{r.current=!1},100))},[l,t]);return{isResizing:r.current,onDrag:i,onDragStart:s,onDragEnd:a}};var ue=require("react/jsx-runtime"),Me="vuuTable-groupHeaderCell",un=({column:e,onClick:t,...o})=>(0,ue.jsx)("span",{...o,className:`${Me}-close`,"data-icon":"close-circle",onClick:()=>t==null?void 0:t(e)}),Ol=e=>{let{children:t,column:o,className:n}=e;return(0,ue.jsxs)("div",{className:(0,wo.default)(`${Me}-col`,n),role:"columnheader",children:[(0,ue.jsx)("span",{className:`${Me}-label`,children:o.name}),t]})},pn=({column:e,className:t,onRemoveColumn:o,onResize:n,...r})=>{let l=(0,mn.useRef)(null),{isResizing:s,...i}=yt({column:e,onResize:n,rootRef:l}),a=(0,wo.default)(Me,t,{vuuPinLeft:e.pin==="left",[`${Me}-right`]:e.align==="right",[`${Me}-resizing`]:e.resizing,[`${Me}-pending`]:e.groupConfirmed===!1}),{columns:c}=e;return(0,ue.jsx)("div",{className:a,ref:l,...r,children:(0,ue.jsxs)("div",{className:`${Me}-inner`,children:[c.map(u=>(0,ue.jsx)(Ol,{column:u,children:c.length>1?(0,ue.jsx)(un,{column:u,onClick:o}):null},u.key)),(0,ue.jsx)(un,{"data-align":"end",onClick:o}),e.resizeable!==!1?(0,ue.jsx)(ft,{...i}):null]})})};var yn=W(require("classnames")),ke=require("react");var Do=W(require("classnames"));var Ke=require("react/jsx-runtime"),dn="vuuSortIndicator",fn=({sorted:e})=>{if(!e)return null;let t=typeof e=="number"?e<0?"dsc":"asc":e==="A"?"asc":"dsc";return typeof e=="number"?(0,Ke.jsxs)("div",{className:(0,Do.default)(dn,"multi-col",t),children:[(0,Ke.jsx)("span",{"data-icon":`sorted-${t}`}),(0,Ke.jsx)("span",{className:"vuuSortPosition",children:Math.abs(e)})]}):(0,Ke.jsx)("div",{className:(0,Do.default)(dn,"single-col"),children:(0,Ke.jsx)("span",{"data-icon":`sorted-${t}`})})};var Tn=require("@vuu-ui/vuu-popups");var Cn=require("@vuu-ui/vuu-popups"),bn=W(require("classnames")),gn=require("react");var vn=require("react/jsx-runtime");var hn=({column:e,filter:t})=>{let[o]=(0,Cn.useContextMenu)(),n=(0,gn.useCallback)(r=>{r.stopPropagation(),o(r,"filter",{column:e,filter:t})},[e,t,o]);return e.filter?(0,vn.jsx)("div",{className:(0,bn.default)("vuuFilterIndicator"),"data-icon":"filter",onClick:n}):null};var Re=require("react/jsx-runtime"),Tt="vuuTable-headerCell",wn=({column:e,className:t,onClick:o,onDragStart:n,onResize:r,...l})=>{let s=(0,ke.useRef)(null),{isResizing:i,...a}=yt({column:e,onResize:r,rootRef:s}),[c]=(0,Tn.useContextMenu)(),u=(0,ke.useRef)(null),p=T=>{c(T,"header",{column:e})},m=(0,ke.useCallback)(T=>!i&&(o==null?void 0:o(T)),[i,o]),C=(0,ke.useCallback)(T=>{u.current=window.setTimeout(()=>{n==null||n(T),u.current=null},500)},[n]),h=(0,ke.useCallback)(()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),v=(0,yn.default)(Tt,t,{vuuPinFloating:e.pin==="floating",vuuPinLeft:e.pin==="left",vuuPinRight:e.pin==="right",vuuEndPin:e.endPin,[`${Tt}-resizing`]:e.resizing,[`${Tt}-right`]:e.align==="right"});return(0,Re.jsx)("div",{className:v,...l,onClick:m,onContextMenu:p,onMouseDown:C,onMouseUp:h,ref:s,children:(0,Re.jsxs)("div",{className:`${Tt}-inner`,children:[(0,Re.jsx)(hn,{column:e}),(0,Re.jsx)("div",{className:`${Tt}-label`,children:e.label}),(0,Re.jsx)(fn,{sorted:e.sorted}),e.resizeable!==!1?(0,Re.jsx)(ft,{...a}):null]})})};var me=require("react/jsx-runtime"),Mo="vuuTable",{RENDER_IDX:Gl}=re.metadataKeys,Dn=({columns:e,columnsWithinViewport:t,data:o,getRowOffset:n,headings:r,onColumnResize:l,onHeaderCellDragStart:s,onContextMenu:i,onRemoveColumnFromGroupBy:a,onRowClick:c,onSort:u,onToggleGroup:p,tableId:m,virtualColSpan:C=0,rowCount:h})=>{let v=(0,Xe.useCallback)(f=>{s==null||s(f)},[s]),T=(0,Xe.useMemo)(()=>e.filter(re.notHidden),[e]),x=(0,Xe.useMemo)(()=>(0,re.buildColumnMap)(e),[e]),g=(0,Xe.useCallback)(f=>{var H;let D=f.target.closest(".vuuTable-headerCell"),w=parseInt((H=D==null?void 0:D.dataset.idx)!=null?H:"-1"),d=(0,re.visibleColumnAtIndex)(e,w),b=f.shiftKey;d&&u(d,b)},[e,u]);return(0,me.jsxs)("div",{"aria-rowcount":h,className:`${Mo}-table`,role:"table",children:[(0,me.jsxs)("div",{className:`${Mo}-headers`,role:"rowGroup",children:[r.map((f,M)=>(0,me.jsx)("div",{className:"vuuTable-heading",children:f.map(({label:D,width:w},d)=>(0,me.jsx)("div",{className:"vuuTable-headingCell",style:{width:w},children:D},d))},M)),(0,me.jsx)("div",{role:"row",children:T.map((f,M)=>{let D=(0,re.getColumnStyle)(f);return(0,re.isGroupColumn)(f)?(0,me.jsx)(pn,{column:f,"data-idx":M,onRemoveColumn:a,onResize:l,role:"columnHeader",style:D},M):(0,me.jsx)(wn,{column:f,"data-idx":M,id:`${m}-${M}`,onClick:g,onDragStart:v,onResize:l,role:"columnHeader",style:D},M)})})]}),(0,me.jsx)("div",{className:`${Mo}-body`,onContextMenu:i,role:"rowGroup",children:o==null?void 0:o.map(f=>(0,me.jsx)(cn,{columnMap:x,columns:t,offset:n(f),onClick:c,virtualColSpan:C,onToggleGroup:p,row:f},f[Gl]))})]})};var Xn=require("@vuu-ui/vuu-popups"),fe=require("@vuu-ui/vuu-utils"),V=require("react");var Bt=require("@vuu-ui/vuu-data-react"),xe=require("@vuu-ui/vuu-utils"),$=require("react"),{SELECTED:wt}=xe.metadataKeys;function Mn({dataSource:e,onConfigChange:t,onFeatureEnabled:o,onFeatureInvocation:n,onSizeChange:r,onSubscribed:l,range:s={from:0,to:0},renderBufferSize:i=0,viewportRowCount:a}){let[,c]=(0,$.useState)(null),u=(0,$.useRef)(!0),p=(0,$.useRef)(!1),m=(0,$.useRef)({from:0,to:0}),C=(0,$.useRef)(null),h=(0,$.useRef)([]),v=(0,$.useMemo)(()=>new Ro((0,xe.getFullRange)(s)),[]),T=(0,$.useCallback)(w=>{for(let d of w)v.add(d);h.current=v.data,p.current=!0},[v]),x=(0,$.useCallback)(w=>{w.type==="subscribed"?l==null||l(w):w.type==="viewport-update"?(typeof w.size=="number"&&(r==null||r(w.size),v.setRowCount(w.size)),w.rows?T(w.rows):typeof w.size=="number"&&(h.current=v.data,p.current=!0)):(0,Bt.isVuuFeatureAction)(w)?o==null||o(w):(0,Bt.isVuuFeatureInvocation)(w)?n==null||n(w):console.log(`useDataSource unexpected message ${w.type}`)},[v,o,n,r,l,T]);(0,$.useEffect)(()=>()=>{C.current&&(cancelAnimationFrame(C.current),C.current=null),u.current=!1},[]);let g=(0,$.useCallback)(()=>{u.current&&(p.current&&(c({}),p.current=!1),C.current=requestAnimationFrame(g))},[c]);(0,$.useEffect)(()=>{C.current=requestAnimationFrame(g)},[g]);let f=(0,$.useCallback)(w=>{let{from:d}=e.range,b={from:d,to:d+w},H=(0,xe.getFullRange)(b,i);v.setRange(H),e.range=m.current=H,e.emit("range",b)},[e,v,i]),M=(0,$.useCallback)(w=>{let d=(0,xe.getFullRange)(w,i);v.setRange(d),e.range=m.current=d,e.emit("range",w)},[e,v,i]),D=(0,$.useCallback)(()=>v.getSelectedRows(),[v]);return(0,$.useEffect)(()=>{e==null||e.subscribe({range:m.current},x)},[e,x,t]),(0,$.useEffect)(()=>{console.log(`adjust range as rowCount chnaged ${a}`),f(a)},[f,a]),{data:h.current,getSelectedRows:D,range:m.current,setRange:M,dataSource:e}}var Ro=class{constructor({from:t,to:o}){this.rowCount=0;this.setRowCount=t=>{t<this.data.length&&(this.data.length=t),this.rowCount=t};this.range=new xe.WindowRange(t,o),this.data=new Array(o-t),this.rowCount=0}add(t){var n;let[o]=t;if(this.isWithinRange(o)){let r=o-this.range.from;this.data[r]=t;let l=t[wt],s=(n=this.data[r-1])==null?void 0:n[wt];s===0&&l?this.data[r-1][wt]=2:s===2&&!l&&(this.data[r-1][wt]=0)}}getAtIndex(t){return this.range.isWithin(t)&&this.data[t-this.range.from]!=null?this.data[t-this.range.from]:void 0}isWithinRange(t){return this.range.isWithin(t)}setRange({from:t,to:o}){if(t!==this.range.from||o!==this.range.to){let[n,r]=this.range.overlap(t,o),l=new Array(Math.max(0,o-t));for(let s=n;s<r;s++){let i=this.getAtIndex(s);if(i){let a=s-t;l[a]=i}}this.data=l,this.range.from=t,this.range.to=o}}getSelectedRows(){return this.data.filter(t=>t[wt]!==0)}};var Rn=require("@vuu-ui/vuu-ui-controls"),Qe=require("react"),xn=({onDrop:e})=>{let t=(0,Qe.useRef)(),o=(0,Qe.useRef)(null),n=(0,Qe.useCallback)(()=>{console.log("handleDropSettle"),t.current=void 0,o.current=null},[]),{draggable:r,draggedItemIndex:l,onMouseDown:s}=(0,Rn.useDragDropNext)({allowDragDrop:!0,draggableClassName:"vuuTable-headerCell",orientation:"horizontal",containerRef:o,itemQuery:".vuuTable-headerCell",onDrop:e,onDropSettle:n}),i=(0,Qe.useCallback)(a=>{let{clientX:c,clientY:u}=a;console.log("useDraggableColumn handleHeaderCellDragStart means mouseDown fired on a column in RowBasedTable");let m=a.target.closest(".vuuTable-headerCell");o.current=m==null?void 0:m.closest("[role='row']");let{dataset:{idx:C="-1"}}=m;t.current={clientX:c,clientY:u,idx:C},s==null||s(a)},[s]);return{draggable:r,draggedItemIndex:l,onHeaderCellDragStart:i}};var An=require("@vuu-ui/vuu-utils"),O=require("react");function Wl(e,...t){let o=new Set(e);for(let n of t)for(let r of n)o.add(r);return o}var xo="ArrowUp",Po="ArrowDown",Ho="ArrowLeft",Eo="ArrowRight";var So="Home",Ao="End",Lo="PageUp",Ko="PageDown";var Bl=new Set(["Enter","Delete"," "]),Ul=new Set(["Tab"]),_l=new Set(["ArrowRight","ArrowLeft"]),Pn=new Set([So,Ao,Lo,Ko,Po,Ho,Eo,xo]),Jl=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),za=Wl(Bl,Pn,_l,Jl,Ul);var Xl=["Home","End","PageUp","PageDown"],Hn=e=>Xl.includes(e),En=e=>Pn.has(e);var Sn=e=>`.vuuTable-headers .vuuTable-headerCell:nth-child(${e+1})`,Ql=(e,t)=>`.vuuTable-body > [aria-rowindex='${e}'] > [role='cell']:nth-child(${t+1})`,Yl=[-1,-1];function Zl(e,[t,o],n,r){return e===xo?t>-1?[t-1,o]:[t,o]:e===Po?t===-1?[0,o]:t===r-1?[t,o]:[t+1,o]:e===Eo?o<n-1?[t,o+1]:[t,o]:e===Ho?o>0?[t,o-1]:[t,o]:[t,o]}var Ln=({columnCount:e=0,containerRef:t,disableHighlightOnFocus:o,data:n,requestScroll:r,rowCount:l=0,viewportRange:s})=>{var H;let{from:i,to:a}=s,c=(0,O.useRef)([-1,-1]),u=(0,O.useRef)(),p=(0,O.useRef)([-1,0]),m=(0,O.useCallback)(([y,R])=>{var S;let A=y===-1?Sn(R):Ql(y,R);return(S=t.current)==null?void 0:S.querySelector(A)},[t]),C=y=>y==null?void 0:y.closest("[role='columnHeader'],[role='cell']"),h=y=>{var R,A;if(y.role==="columnHeader")return[-1,parseInt((R=y.dataset.idx)!=null?R:"-1",10)];{let S=y.closest("[role='row']");if(S){let k=parseInt((A=S.ariaRowIndex)!=null?A:"-1",10),te=Array.from(S.childNodes).indexOf(y);return[k,te]}}return Yl},v=(0,O.useCallback)(y=>{var R;if(t.current){let A=m(y);A?(A!==u.current&&((R=u.current)==null||R.setAttribute("tabindex",""),u.current=A,A.setAttribute("tabindex","0")),A.focus()):(0,An.withinRange)(y[0],s)||(u.current=void 0,r==null||r({type:"scroll-page",direction:"up"}))}},[t,m,r,s]),T=(0,O.useCallback)((y,R,A=!1)=>{let S=[y,R];p.current=S,v(S),A&&(c.current=S)},[v]),x=(0,O.useCallback)(()=>{var y;(y=u.current)==null||y.setAttribute("tabindex",""),u.current=void 0},[]),g=(0,O.useCallback)(async(y,R)=>{switch(y){case Ko:r==null||r({type:"scroll-page",direction:"down"});break;case Lo:r==null||r({type:"scroll-page",direction:"up"});break;case So:r==null||r({type:"scroll-end",direction:"home"});break;case Ao:r==null||r({type:"scroll-end",direction:"end"});break}return R},[r]),f=(0,O.useCallback)(()=>{var y;if(o!==!0&&(y=t.current)!=null&&y.contains(document.activeElement)){let R=C(document.activeElement);R&&(c.current=h(R))}},[o,t]),M=(0,O.useCallback)(async y=>{let[R,A]=Hn(y)?await g(y,p.current):Zl(y,p.current,e,l),[S,k]=p.current;(R!==S||A!==k)&&T(R,A,!0)},[e,g,l,T]),D=(0,O.useCallback)(y=>{n.length>0&&En(y.key)&&(y.preventDefault(),y.stopPropagation(),M(y.key))},[n,M]),w=(0,O.useCallback)(y=>{let R=y.target,A=C(R);if(A){let[S,k]=h(A);T(S,k)}},[T]),d=(0,O.useMemo)(()=>({onClick:w,onFocus:f,onKeyDown:D}),[w,f,D]);(0,O.useLayoutEffect)(()=>{let{current:y}=p,R=y[0]>=i&&y[0]<=a;u.current&&!R?x():!u.current&&R&&v(y)},[v,i,a,x]);let b=((H=t.current)==null?void 0:H.firstChild)!=null;return(0,O.useEffect)(()=>{var y;if(b&&u.current===void 0){let R=(y=t.current)==null?void 0:y.querySelector(Sn(0));R&&(R.setAttribute("tabindex","0"),u.current=R)}},[t,b]),d};var ye=require("@vuu-ui/vuu-utils"),Pe=require("react");var ze=require("react");var Ne=new Map,kn=(e,t,o)=>{switch(o){case"height":return t.height;case"clientHeight":return e.clientHeight;case"clientWidth":return e.clientWidth;case"contentHeight":return t.contentHeight;case"contentWidth":return t.contentWidth;case"scrollHeight":return Math.ceil(e.scrollHeight);case"scrollWidth":return Math.ceil(e.scrollWidth);case"width":return t.width;default:return 0}},Kn=new ResizeObserver(e=>{for(let t of e){let{target:o,borderBoxSize:n,contentBoxSize:r}=t,l=Ne.get(o);if(l){let[{blockSize:s,inlineSize:i}]=n,[{blockSize:a,inlineSize:c}]=r,{onResize:u,measurements:p}=l,m=!1;for(let[C,h]of Object.entries(p)){let v=kn(o,{height:s,width:i,contentHeight:a,contentWidth:c},C);v!==h&&(m=!0,p[C]=v)}m&&u&&u(p)}}});function Nn(e,t,o,n=!1){let r=(0,ze.useRef)(t),l=(0,ze.useCallback)(s=>{let{width:i,height:a}=s.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=s;return r.current.reduce((p,m)=>(p[m]=kn(s,{width:i,height:a,contentHeight:u,contentWidth:c},m),p),{})},[]);(0,ze.useEffect)(()=>{let s=e.current;async function i(){Ne.set(s,{measurements:{}}),await document.fonts.ready;let a=Ne.get(s);if(a){let c=l(s);a.measurements=c,Kn.observe(s),n&&o(c)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}if(s){if(Ne.has(s))throw Error("useResizeObserver attemping to observe same element twice");i()}return()=>{s&&Ne.has(s)&&(Kn.unobserve(s),Ne.delete(s))}},[l,e]),(0,ze.useEffect)(()=>{let s=e.current,i=Ne.get(s);if(i){if(r.current!==t){r.current=t;let a=l(s);i.measurements=a}i.onResize=o}},[t,l,e,o])}var jl=["clientHeight","clientWidth"],zn=e=>Number.isFinite(e),ql={height:"100%",width:"100%"},es=(e,t)=>(0,ye.isValidNumber)(e)&&(0,ye.isValidNumber)(t)?{height:`${e}px`,width:`${t}px`}:ql,ts=(e,t)=>{if((0,ye.isValidNumber)(e)&&(0,ye.isValidNumber)(t))return{height:e,width:t}},ko=({defaultHeight:e=0,defaultWidth:t=0,height:o,width:n})=>{let r=(0,Pe.useRef)(null),[l,s]=(0,Pe.useState)({css:es(o,n),inner:ts(o,n),outer:{height:o!=null?o:"100%",width:n!=null?n:"100%"}});(0,Pe.useMemo)(()=>{s(a=>{let{inner:c,outer:u}=a;if((0,ye.isValidNumber)(o)&&(0,ye.isValidNumber)(n)&&c&&u){let{height:p,width:m}=c,{height:C,width:h}=u;if(C!==o||h!==n){let v=(0,ye.isValidNumber)(C)?C-p:0,T=(0,ye.isValidNumber)(h)?h-m:0;return{...a,outer:{height:o,width:n},inner:{height:o-v,width:n-T}}}}return a})},[o,n]);let i=(0,Pe.useCallback)(({clientWidth:a,clientHeight:c})=>{s(u=>{let{css:p,inner:m,outer:C}=u;return zn(c)&&zn(a)&&(a!==(m==null?void 0:m.width)||c!==(m==null?void 0:m.height))?{css:p,outer:C,inner:{width:Math.floor(a)||t,height:Math.floor(c)||e}}:u})},[e,t]);return Nn(r,jl,i,!0),{containerRef:r,cssSize:l.css,outerSize:l.outer,innerSize:l.inner}};var He=require("@vuu-ui/vuu-utils"),Dt=require("react"),{IDX:os}=He.metadataKeys,ns=[],Mt=({selectionModel:e,onSelect:t,onSelectionChange:o})=>{let n=(0,Dt.useRef)(-1),r=(0,Dt.useRef)(ns);return(0,Dt.useCallback)((s,i,a)=>{let{[os]:c}=s,{current:u}=n,{current:p}=r,C=((0,He.isRowSelected)(s)?He.deselectItem:He.selectItem)(e,p,c,i,a,u);r.current=C,n.current=c,t==null||t(s),o==null||o(C)},[t,o,e])};var E=require("@vuu-ui/vuu-utils"),In=require("react"),rs=100,Vn=E.metadataKeys.count,ls=({serverDataType:e})=>e===void 0,ss=e=>{var t;if((0,E.isTypeDescriptor)(e.type))return(0,E.getCellRenderer)((t=e.type)==null?void 0:t.renderer)},$n=(e,t)=>{if(e.serverDataType)return e.serverDataType;if(t){let o=t.columns.find(n=>n.name===e.name);if(o)return o.serverDataType}return"string"},is=e=>e.type==="columnSettings",as=e=>e.type==="tableSettings",cs=(e,t)=>{switch(t.type){case"init":return Fn(t);case"moveColumn":return ps(e,t);case"resizeColumn":return Cs(e,t);case"setTableSchema":return bs(e,t);case"hideColumns":return ds(e,t);case"showColumns":return fs(e,t);case"pinColumn":return gs(e,t);case"updateColumnProp":return Ye(e,t);case"tableConfig":return On(e,t);default:return console.log(`unhandled action ${t.type}`),e}},No=(e,t)=>{let[o,n]=(0,In.useReducer)(cs,{tableConfig:e,dataSourceConfig:t},Fn);return{columns:o.columns,dispatchColumnAction:n,headings:o.headings}};function Fn({dataSourceConfig:e,tableConfig:t}){let o=t.columns.map(zo(t)),n=o.some(E.isPinned)?(0,E.sortPinnedColumns)(o):o,r={columns:n,headings:(0,E.getTableHeadings)(n)};if(e){let{columns:l,...s}=e;return On(r,{type:"tableConfig",...s})}else return r}var us=e=>(0,E.isCalculatedColumn)(e.name)?(0,E.getCalculatedColumnName)(e):e.name,ms=(e,t)=>t==="uppercase"?e.toUpperCase():t==="capitalize"?e[0].toUpperCase()+e.slice(1).toLowerCase():e,zo=e=>(t,o)=>{let n=$n(t,e.tableSchema),{columnDefaultWidth:r=rs,columnFormatHeader:l}=e,{align:s=(0,E.getDefaultAlignment)(n),key:i,name:a,label:c=us(t),width:u=r,...p}=t,m={...p,align:s,CellRenderer:ss(t),label:ms(c,l),key:i!=null?i:o+Vn,name:a,originalIdx:o,serverDataType:n,valueFormatter:(0,E.getValueFormatter)(t),width:u};return(0,E.isGroupColumn)(m)&&(m.columns=m.columns.map(C=>zo(e)(C,C.key))),m};function ps(e,{column:t,moveBy:o,moveTo:n}){let{columns:r}=e;if(typeof o=="number"){let l=r.indexOf(t),s=r.slice(),[i]=s.splice(l,1);return s.splice(l+o,0,i),{...e,columns:s}}else if(typeof n=="number")return{...e,columns:(0,E.moveItemDeprecated)(r,t,n)};return e}function ds(e,{columns:t}){return t.some(o=>o.hidden!==!0)?t.reduce((o,n)=>n.hidden!==!0?Ye(o,{type:"updateColumnProp",column:n,hidden:!0}):o,e):e}function fs(e,{columns:t}){return t.some(o=>o.hidden)?t.reduce((o,n)=>n.hidden?Ye(o,{type:"updateColumnProp",column:n,hidden:!1}):o,e):e}function Cs(e,{column:t,phase:o,width:n}){let r="updateColumnProp",l=o!=="end";switch(o){case"begin":return Ye(e,{type:r,column:t,resizing:l});case"end":return Ye(e,{type:r,column:t,resizing:l,width:n});case"resize":return Ye(e,{type:r,column:t,width:n});default:throw Error(`useTableModel.resizeColumn, invalid resizePhase ${o}`)}}function bs(e,{tableSchema:t}){let{columns:o}=e;if(o.some(ls)){let n=o.map(r=>{var s;let l=$n(r,t);return{...r,align:(s=r.align)!=null?s:(0,E.getDefaultAlignment)(l),serverDataType:l}});return{...e,columns:n,tableSchema:t}}else return{...e,tableSchema:t}}function gs(e,t){let{columns:o}=e,{column:n,pin:r}=t;return o=(0,E.updateColumn)(o,n.name,{pin:r}),o=(0,E.sortPinnedColumns)(o),console.log({withPins:o}),{...e,columns:o}}function Ye(e,t){let{columns:o}=e,{align:n,column:r,hidden:l,label:s,resizing:i,width:a}=t,c={};return(n==="left"||n==="right")&&(c.align=n),typeof s=="string"&&(c.label=s),typeof i=="boolean"&&(c.resizing=i),typeof l=="boolean"&&(c.hidden=l),typeof a=="number"&&(c.width=a),o=(0,E.updateColumn)(o,r.name,c),{...e,columns:o}}function On(e,{columns:t,confirmed:o,filter:n,groupBy:r,sort:l}){let s=t&&t.length>0,i=r!==void 0,a=typeof(n==null?void 0:n.filter)=="string",c=l&&l.sortDefs.length>0,u=e;return s&&(u={...e,columns:t.map((p,m)=>{let C=(0,E.getColumnName)(p),h=m+Vn,v=(0,E.findColumn)(u.columns,C);return v?v.key===h?v:{...v,key:h}:zo(e)({name:p},m)})}),i&&(u={...e,columns:(0,E.applyGroupByToColumns)(u.columns,r,o)}),c&&(u={...e,columns:(0,E.applySortToColumns)(u.columns,l)}),a?u={...e,columns:(0,E.applyFilterToColumns)(u.columns,n)}:u.columns.some(E.isFilteredColumn)&&(u={...e,columns:(0,E.stripFilterFromColumns)(u.columns)}),u}var X=require("react"),Gn=e=>{let{scrollLeft:t,scrollTop:o}=e,{clientHeight:n,clientWidth:r,scrollHeight:l,scrollWidth:s}=e,i=t/(s-r),a=o/(l-n);return[i,a]},hs=e=>{let{clientHeight:t,clientWidth:o,scrollHeight:n,scrollWidth:r}=e;return[r-o,n-t]},Wn=({onAttach:e,onDetach:t})=>{let o=(0,X.useRef)(null);return(0,X.useCallback)(r=>{if(r)o.current=r,e==null||e(r);else if(o.current){let{current:l}=o;o.current=r,t==null||t(l)}},[e,t])},Bn=({onHorizontalScroll:e,onVerticalScroll:t,viewport:o})=>{let n=(0,X.useRef)(!1),r=(0,X.useRef)({scrollTop:0,scrollLeft:0}),l=(0,X.useRef)(null),s=(0,X.useRef)(null),{maxScrollContainerScrollHorizontal:i,maxScrollContainerScrollVertical:a}=o,c=(0,X.useCallback)(()=>{let{current:g}=s,{current:f}=l,{current:M}=n;if(M)n.current=!1;else if(g&&f){let[D,w]=Gn(f),[d,b]=hs(g),H=Math.round(D*d),y=Math.round(w*b);console.log(`pctScrollTop ${w}, maxScrollTop ${b} rootScrollTop ${y}`),g.scrollTo({left:H,top:y,behavior:"auto"})}},[]),u=(0,X.useCallback)(()=>{let{current:g}=s,{current:f}=l,{current:M}=r;if(g&&f){let{scrollLeft:D,scrollTop:w}=g,[d,b]=Gn(g);n.current=!0,f.scrollLeft=Math.round(d*i),f.scrollTop=Math.round(b*a),M.scrollTop!==w&&(M.scrollTop=w,t==null||t(w,b)),M.scrollLeft!==D&&(M.scrollLeft=D,e==null||e(D))}},[i,a,e,t]),p=(0,X.useCallback)(g=>{l.current=g,g.addEventListener("scroll",c,{passive:!0})},[c]),m=(0,X.useCallback)(g=>{l.current=null,g.removeEventListener("scroll",c)},[c]),C=(0,X.useCallback)(g=>{s.current=g,g.addEventListener("scroll",u,{passive:!0})},[u]),h=(0,X.useCallback)(g=>{s.current=null,g.removeEventListener("scroll",u)},[u]),v=Wn({onAttach:C,onDetach:h}),T=Wn({onAttach:p,onDetach:m}),x=(0,X.useCallback)(g=>{let{current:f}=s;if(f){if(n.current=!1,g.type==="scroll-page"){let{clientHeight:M,scrollLeft:D,scrollTop:w}=f,{direction:d}=g,b=d==="down"?M:-M,H=Math.min(Math.max(0,w+b),a);f.scrollTo({top:H,left:D,behavior:"auto"})}else if(g.type==="scroll-end"){let{direction:M}=g,D=M==="end"?a:0;f.scrollTo({top:D,left:f.scrollLeft,behavior:"auto"})}}},[a]);return{scrollbarContainerRef:T,contentContainerRef:v,requestScroll:x}};var Te=require("react"),Ut=require("@vuu-ui/vuu-utils"),vs=15e5,ys={contentHeight:0,contentWidth:0,getRowAtPosition:()=>-1,getRowOffset:()=>-1,horizontalScrollbarHeight:0,maxScrollContainerScrollHorizontal:0,maxScrollContainerScrollVertical:0,pinnedWidthLeft:0,pinnedWidthRight:0,rowCount:0,setPctScrollTop:()=>{},totalHeaderHeight:0,verticalScrollbarWidth:0,viewportBodyHeight:0},Ts=e=>{let t=0,o=0,n=0;for(let r of e){let{hidden:l,pin:s,width:i}=r,a=l?0:i;s==="left"?t+=a:s==="right"?o+=a:n+=a}return{pinnedWidthLeft:t+4,pinnedWidthRight:o+4,unpinnedWidth:n}},Rt=({columns:e,headerHeight:t,headings:o,rowCount:n,rowHeight:r,size:l})=>{let s=(0,Te.useRef)(0),a=Math.min(n,vs)*r,u=n*r-a,{pinnedWidthLeft:p,pinnedWidthRight:m,unpinnedWidth:C}=(0,Te.useMemo)(()=>Ts(e),[e]),[h,v]=(0,Te.useMemo)(()=>(0,Ut.actualRowPositioning)(r),[r]),[T,x]=(0,Te.useMemo)(()=>u?(0,Ut.virtualRowPositioning)(r,u,s):[h,v],[v,h,u,r]),g=(0,Te.useCallback)(f=>{s.current=f},[]);return(0,Te.useMemo)(()=>{var f;if(l){let M=o.length,D=15,w=p+C+m,d=w>l.width?D:0,b=t*(1+M),H=a-(((f=l==null?void 0:l.height)!=null?f:0)-d)+b,y=w-l.width+p,R=(l.height-t)/r,A=Number.isInteger(R)?R+1:Math.ceil(R),S=l.height-b,k=a>S?D:0;return{contentHeight:a,getRowAtPosition:x,getRowOffset:T,horizontalScrollbarHeight:d,maxScrollContainerScrollHorizontal:y,maxScrollContainerScrollVertical:H,pinnedWidthLeft:p,pinnedWidthRight:m,rowCount:A,contentWidth:w,setPctScrollTop:g,totalHeaderHeight:b,verticalScrollbarWidth:k,viewportBodyHeight:S}}else return ys},[l,o.length,p,C,m,a,t,r,x,T,g])};var xt=require("@vuu-ui/vuu-utils"),q=require("react"),Un=({columns:e,getRowAtPosition:t,setRange:o,viewportMeasurements:n})=>{let r=(0,q.useRef)(-1),{rowCount:l,contentWidth:s,maxScrollContainerScrollHorizontal:i}=n,a=s-i,c=(0,q.useRef)(0),[u,p]=(0,q.useMemo)(()=>(0,xt.getColumnsInViewport)(e,c.current,c.current+a),[a,e]),m=(0,q.useRef)(p);(0,q.useEffect)(()=>{h(u)},[u]);let[C,h]=(0,q.useState)(u),v=(0,q.useCallback)(x=>{c.current=x;let[g,f]=(0,xt.getColumnsInViewport)(e,x,x+a);(0,xt.itemsChanged)(C,g)&&(m.current=f,h(g))},[a,e,C]),T=(0,q.useCallback)(x=>{let g=t(x);g!==r.current&&(r.current=g,console.log("setRange from handleVerticalScroll"),o({from:g,to:g+l}))},[t,o,l]);return{columnsWithinViewport:C,onHorizontalScroll:v,onVerticalScroll:T,virtualColSpan:m.current}};var ws=[],{KEY:Ds,IS_EXPANDED:_n,IS_LEAF:Jn}=fe.metadataKeys,Qn=({config:e,dataSource:t,headerHeight:o,onConfigChange:n,onFeatureEnabled:r,onFeatureInvocation:l,onSelectionChange:s,renderBufferSize:i=0,rowHeight:a,selectionModel:c,...u})=>{var $t,Ft;let[p,m]=(0,V.useState)(t.size),C=(0,V.useRef)(!1),h=(0,V.useRef)();if(h.current=t,t===void 0)throw Error("no data source provided to Vuu Table");let v=ko(u),T=(0,V.useCallback)(K=>{m(K)},[]),{columns:x,dispatchColumnAction:g,headings:f}=No(e,t.config),{getRowAtPosition:M,getRowOffset:D,setPctScrollTop:w,...d}=Rt({columns:x,headerHeight:o,headings:f,rowCount:p,rowHeight:a,size:v.innerSize}),b=(0,V.useCallback)(({tableSchema:K})=>{K?(C.current=!0,g({type:"setTableSchema",tableSchema:K})):console.log("usbscription message with no schema")},[g]),H=(0,V.useCallback)(K=>{t.select(K),s==null||s(K)},[t,s]),y=Mt({onSelectionChange:H,selectionModel:c}),{data:R,getSelectedRows:A,range:S,setRange:k}=Mn({dataSource:t,onFeatureEnabled:r,onFeatureInvocation:l,onSubscribed:b,onSizeChange:T,renderBufferSize:i,viewportRowCount:d.rowCount}),te=(0,V.useRef)();te.current=R;let Ae=(0,V.useCallback)(K=>{C.current=!0,console.log("onPersistentColumnOperation, dispatchColumnAction",{action:K}),g(K)},[g]),ct=bt({dataSource:t,onPersistentColumnOperation:Ae}),kt=(0,V.useCallback)((K,F=!1,Z)=>{t&&(t.sort=(0,fe.applySort)(t.sort,K,F,Z))},[t]),Nt=(0,V.useCallback)((K,F,Z)=>{let G=x.find(ae=>ae.name===F);if(G)K==="end"&&(C.current=!0),g({type:"resizeColumn",phase:K,column:G,width:Z});else throw Error(`useDataTable.handleColumnResize, column ${F} not found`)},[x,g]),ie=(0,V.useCallback)((K,F)=>{let Z=(0,fe.isJsonGroup)(F,K),G=K[Ds];if(K[_n]){if(t.closeTreeNode(G,!0),Z){let ae=x.indexOf(F);t.getRowsAtDepth(ae+1).some(ce=>ce[_n]||ce[Jn])||g({type:"hideColumns",columns:x.slice(ae+2)})}}else if(t.openTreeNode(G),Z){let ae=t.getChildRows(G),de=x.indexOf(F)+1,ce=[x[de]];ae.some(be=>be[Jn])&&ce.push(x[de+1]),ce.some(be=>be.hidden)&&g({type:"showColumns",columns:ce})}},[x,t,g]),{onVerticalScroll:Ge,onHorizontalScroll:We,columnsWithinViewport:pe,virtualColSpan:oe}=Un({columns:x,getRowAtPosition:M,setRange:k,viewportMeasurements:d}),ut=(0,V.useCallback)((K,F)=>{w(F),Ge(K)},[Ge,w]),{requestScroll:mt,...pt}=Bn({onHorizontalScroll:We,onVerticalScroll:ut,viewport:d,viewportHeight:((Ft=($t=v.innerSize)==null?void 0:$t.height)!=null?Ft:0)-o}),Y=Ln({columnCount:x.length,containerRef:v.containerRef,data:R,requestScroll:mt,rowCount:t==null?void 0:t.size,viewportRange:S}),Ce=(0,V.useCallback)(K=>{K?t&&t.groupBy.includes(K.name)&&(t.groupBy=t.groupBy.filter(F=>F!==K.name)):t.groupBy=[]},[t]),zt=(0,V.useCallback)((K,F)=>{let Z=t.columns[K],G=(0,fe.moveItemDeprecated)(t.columns,Z,F);G!==t.columns&&(t.columns=G,g({type:"tableConfig",columns:G}))},[t,g]),ao=xn({onDrop:zt});(0,V.useEffect)(()=>{h.current&&(C.current=!0,g({type:"init",tableConfig:e,dataSourceConfig:h.current.config}))},[e,g]),(0,V.useEffect)(()=>{t.on("config",(K,F)=>{C.current=!0,g({type:"tableConfig",...K,confirmed:F})})},[t,g]),(0,V.useMemo)(()=>{C.current&&(n==null||n({...e,columns:x}),C.current=!1)},[x,e,n]);let[It]=(0,Xn.useContextMenu)(),Vt=(0,V.useCallback)(K=>{var ce;let{current:F}=te,{current:Z}=h,G=K.target,ae=G==null?void 0:G.closest("div[role='cell']"),de=G==null?void 0:G.closest(".vuuTableRow");if(ae&&de&&F&&Z){let{columns:be,selectedRowsCount:co}=Z,uo=(0,fe.buildColumnMap)(be),mo=parseInt((ce=de.ariaRowIndex)!=null?ce:"-1"),po=Array.from(de.childNodes).indexOf(ae),fo=F.find(([Co])=>Co===mo),Ot=be[po];It(K,"grid",{columnMap:uo,columnName:Ot,row:fo,selectedRows:co===0?ws:A(),viewport:t==null?void 0:t.viewport})}},[t==null?void 0:t.viewport,A,It]);return{columns:x,columnsWithinViewport:pe,containerMeasurements:v,containerProps:Y,data:R,dispatchColumnAction:g,getRowOffset:D,handleContextMenuAction:ct,headings:f,onColumnResize:Nt,onContextMenu:Vt,onRemoveColumnFromGroupBy:Ce,onRowClick:y,onSort:kt,onToggleGroup:ie,virtualColSpan:oe,scrollProps:pt,rowCount:p,viewportMeasurements:d,...ao}};var Zn=W(require("classnames"));var jn=require("@vuu-ui/vuu-utils"),we=require("react/jsx-runtime"),Ie="vuuTable",Ms=({allowConfigEditing:e=!1,className:t,config:o,dataSource:n,headerHeight:r=25,height:l,id:s,onConfigChange:i,onFeatureEnabled:a,onFeatureInvocation:c,onSelect:u,onSelectionChange:p,onShowConfigEditor:m,renderBufferSize:C=0,rowHeight:h=20,selectionModel:v="extended",style:T,width:x,...g})=>{let f=(0,_t.useIdMemo)(s),{containerMeasurements:{containerRef:M,innerSize:D,outerSize:w},containerProps:d,dispatchColumnAction:b,draggable:H,draggedItemIndex:y,handleContextMenuAction:R,scrollProps:A,viewportMeasurements:S,...k}=Qn({config:o,dataSource:n,renderBufferSize:C,headerHeight:r,height:l,onConfigChange:i,onFeatureEnabled:a,onFeatureInvocation:c,onSelectionChange:p,rowHeight:h,selectionModel:v,width:x});console.log({tableProps:k});let te={...w,"--content-height":`${S.contentHeight}px`,"--horizontal-scrollbar-height":`${S.horizontalScrollbarHeight}px`,"--content-width":`${S.contentWidth}px`,"--pinned-width-left":`${S.pinnedWidthLeft}px`,"--pinned-width-right":`${S.pinnedWidthRight}px`,"--header-height":`${r}px`,"--row-height":`${h}px`,"--table-height":`${D==null?void 0:D.height}px`,"--table-width":`${D==null?void 0:D.width}px`,"--total-header-height":`${S.totalHeaderHeight}px`,"--vertical-scrollbar-width":`${S.verticalScrollbarWidth}px`,"--viewport-body-height":`${S.viewportBodyHeight}px`},Ae=(0,Zn.default)(Ie,t,{[`${Ie}-zebra`]:o.zebraStripes,[`${Ie}-loading`]:(0,jn.isDataLoading)(k.columns)});return(0,we.jsx)(Yn.ContextMenuProvider,{menuActionHandler:R,menuBuilder:Ct(n),children:(0,we.jsxs)("div",{...g,...d,className:Ae,id:f,ref:M,style:te,tabIndex:-1,children:[D?(0,we.jsx)("div",{className:`${Ie}-scrollbarContainer`,ref:A.scrollbarContainerRef,children:(0,we.jsx)("div",{className:`${Ie}-scrollbarContent`})}):null,D?(0,we.jsxs)("div",{className:`${Ie}-contentContainer`,ref:A.contentContainerRef,children:[(0,we.jsx)(Dn,{...k,headerHeight:r,tableId:f}),H]}):null,e&&D?(0,we.jsx)(_t.Button,{className:`${Ie}-settings`,"data-icon":"settings",onClick:m,variant:"secondary"}):null]})})};var qn=W(require("classnames")),je=require("@vuu-ui/vuu-utils");var Ze=require("react/jsx-runtime"),Pt="vuuJsonCell",{IS_EXPANDED:Rs,KEY:xs}=je.metadataKeys,Ps=e=>{let t=e.lastIndexOf("|");return t===-1?"":e.slice(t+1)},Hs=({column:e,row:t})=>{let{key:o}=e,n=t[o],r=!1;(0,je.isJsonAttribute)(n)&&(n=n.slice(0,-1),r=!0);let l=Ps(t[xs]),s=(0,qn.default)({[`${Pt}-name`]:l===n,[`${Pt}-value`]:l!==n,[`${Pt}-group`]:r});if(r){let i=t[Rs]?"minus-box":"plus-box";return(0,Ze.jsxs)("span",{className:s,children:[(0,Ze.jsx)("span",{className:`${Pt}-value`,children:n}),(0,Ze.jsx)("span",{className:`${Pt}-toggle`,"data-icon":i})]})}else return n?(0,Ze.jsx)("span",{className:s,children:n}):null};console.log("register JsonCell");(0,je.registerComponent)("json",Hs,"cell-renderer",{description:"JSON formatter",label:"JSON formatter",serverDataType:"json"});var Ss=W(require("classnames")),As=require("react");var qe=require("react");var tr=require("react/jsx-runtime"),er=()=>{},Es="vuuColumnResizerNext",Ht=({onDrag:e,onDragEnd:t=er,onDragStart:o=er})=>{let n=(0,qe.useRef)(0),r=(0,qe.useCallback)(i=>{i.stopPropagation&&i.stopPropagation(),i.preventDefault&&i.preventDefault();let a=Math.round(i.clientX),c=a-n.current;n.current=a,c!==0&&e(i,c)},[e]),l=(0,qe.useCallback)(i=>{window.removeEventListener("mouseup",l),window.removeEventListener("mousemove",r),t(i)},[t,r]),s=(0,qe.useCallback)(i=>{o(i),n.current=Math.round(i.clientX),window.addEventListener("mouseup",l),window.addEventListener("mousemove",r),i.stopPropagation&&i.stopPropagation(),i.preventDefault&&i.preventDefault()},[o,r,l]);return(0,tr.jsx)("div",{className:Es,onMouseDown:s})};var Ee=require("react"),Et=({column:e,onResize:t,rootRef:o})=>{let n=(0,Ee.useRef)(0),[r,l]=(0,Ee.useState)(!1),{name:s}=e,i=(0,Ee.useCallback)(()=>{if(console.log("onResizeStart"),t&&o.current){console.log("handleResizeStart");let{width:u}=o.current.getBoundingClientRect();n.current=Math.round(u),l(!0),t==null||t("begin",s)}},[s,t,o]),a=(0,Ee.useCallback)((u,p)=>{if(o.current&&t){let{width:m}=o.current.getBoundingClientRect(),C=Math.round(m)+p;C!==n.current&&C>0&&(t("resize",s,C),n.current=C)}},[s,t,o]),c=(0,Ee.useCallback)(()=>{t&&(t("end",s,n.current),setTimeout(()=>{l(!1)},80))},[s,t]);return{isResizing:r,onDrag:a,onDragStart:i,onDragEnd:c}};var or=require("@vuu-ui/vuu-utils"),nr=W(require("classnames")),rr=require("react"),De=(e,t,o)=>(0,rr.useMemo)(()=>{let n=(0,nr.default)(t,{vuuPinFloating:e.pin==="floating",vuuPinLeft:e.pin==="left",vuuPinRight:e.pin==="right",vuuEndPin:o&&e.endPin,[`${t}-editable`]:e.editable,[`${t}-right`]:e.align==="right"}),r=(0,or.getColumnStyle)(e);return{className:n,style:r}},[e,t,o]);var sr=W(require("classnames")),ir=require("react");var Jt=require("react/jsx-runtime"),lr="vuuColumnHeaderPill",Ve=({children:e,className:t,column:o,onRemove:n,removable:r,...l})=>{if(r&&typeof n!="function")throw Error("ColumnHeaderPill onRemove prop must be provided if Pill is removable");let s=(0,ir.useCallback)(i=>{i.preventDefault(),i.stopPropagation(),n==null||n(o)},[o,n]);return(0,Jt.jsxs)("div",{...l,className:(0,sr.default)(lr,t),children:[e,r?(0,Jt.jsx)("span",{className:`${lr}-removeButton`,role:"button","data-icon":"cross",onClick:s}):null]})};var et=require("react/jsx-runtime"),Io=({column:e,...t})=>{let{name:o,sorted:n}=e,r=typeof n=="number"?n<0?"arrow-down":"arrow-up":n==="A"?"arrow-up":n==="D"?"arrow-down":void 0;return(0,et.jsxs)(Ve,{...t,column:e,children:[(0,et.jsx)("span",{className:"vuuGroupColumnPill-label",children:o}),r!==void 0?(0,et.jsx)("span",{"data-icon":r}):null,typeof n=="number"?(0,et.jsx)("span",{className:"vuuSortPosition",children:Math.abs(n)}):null]})};var St=require("react/jsx-runtime"),ar=({column:e})=>{if(!e.sorted)return null;let t=typeof e.sorted=="number"?e.sorted<0?"arrow-down":"arrow-up":e.sorted==="A"?"arrow-up":"arrow-down";return(0,St.jsxs)(Ve,{column:e,children:[(0,St.jsx)("span",{"data-icon":t}),typeof e.sorted=="number"?(0,St.jsx)("span",{className:"vuuSortPosition",children:Math.abs(e.sorted)}):null]})};var cr=require("react/jsx-runtime"),Ls=require("react");var ur=W(require("classnames")),ot=require("react");var Xt=require("@vuu-ui/vuu-layout");var tt=require("react/jsx-runtime"),mr=require("react"),Vo="vuuTableNextGroupHeaderCell",Ks=(e,t)=>e===t?e:t,At=({column:e,className:t,onRemoveColumn:o,onResize:n,...r})=>{let l=(0,ot.useRef)(null),{isResizing:s,...i}=Et({column:e,onResize:n,rootRef:l}),[a,c]=(0,ot.useState)(e.columns),{className:u,style:p}=De(e,Vo,!0),m=a.length>1?{removable:!0,onRemove:o}:void 0,C=(0,ot.useCallback)((h,v)=>{c(T=>{let x=T.slice(),[g]=x.splice(h,1);return v===-1?x.concat(g):(x.splice(v,0,g),x)})},[]);return(0,Xt.useLayoutEffectSkipFirst)(()=>{c(h=>Ks(h,e.columns))},[e.columns]),(0,tt.jsxs)("div",{...r,className:(0,ur.default)(u,"vuuTableNextHeaderCell",t,{[`${Vo}-pending`]:e.groupConfirmed===!1}),ref:l,role:"columnheader",style:p,children:[(0,tt.jsx)(Xt.OverflowContainer,{allowDragDrop:!0,className:`${Vo}-inner`,height:24,onMoveItem:C,overflowPosition:"start",children:a.map(h=>(0,mr.createElement)(Io,{...m,column:h,key:h.key}))}),(0,tt.jsx)(Ve,{column:e,removable:!0,onRemove:o}),e.resizeable!==!1?(0,tt.jsx)(Ht,{...i}):null]})};var Qt=require("react");var pr=require("@vuu-ui/vuu-popups"),dr=W(require("classnames")),$e=require("react");var Cr=require("react/jsx-runtime"),ks=e=>{if(e){let{bottom:t,left:o}=e.getBoundingClientRect();return{x:o,y:t+6}}},fr=({className:e,column:t,...o})=>{let n=(0,$e.useRef)(null),[r,l]=(0,$e.useState)(!1),[s]=(0,pr.useContextMenu)(),i=(0,$e.useCallback)(()=>{l(!1)},[]),a=(0,$e.useCallback)(c=>{l(!0),s(c,"column-menu",{column:t,ContextMenuProps:{onClose:i,position:ks(n.current)}})},[t,i,s]);return(0,Cr.jsx)("span",{...o,className:(0,dr.default)("vuuTable-columnMenu",e,{"vuuTable-columnMenu-open":r}),"data-icon":"more-vert",onClick:a,ref:n})};var br=W(require("classnames"));var Fe=require("react/jsx-runtime"),$o="vuuTableNextHeaderCell",gr=({className:e,column:t,onClick:o,onResize:n,...r})=>{var v;let l=(0,Qt.useRef)(null),{isResizing:s,...i}=Et({column:t,onResize:n,rootRef:l}),a=(0,Qt.useCallback)(T=>{console.log(`click isResizing ${s}`),!s&&(o==null||o(T))},[s,o]),{className:c,style:u}=De(t,$o,!0),p=(0,Fe.jsx)(fr,{column:t}),m=(0,Fe.jsx)("div",{className:`${$o}-label`,children:(v=t.label)!=null?v:t.name}),C=(0,Fe.jsx)(ar,{column:t}),h=t.align==="right"?[C,m,p]:[p,m,C];return(0,Fe.jsxs)("div",{...r,className:(0,br.default)(c,e,{[`${$o}-resizing`]:s}),onClick:a,ref:l,role:"columnheader",style:u,children:[...h,t.resizeable!==!1?(0,Fe.jsx)(Ht,{...i}):null]})};var ol=require("@vuu-ui/vuu-popups"),it=require("@vuu-ui/vuu-utils"),Xo=W(require("classnames")),no=require("react");var ee=require("@vuu-ui/vuu-utils"),Dr=W(require("classnames")),Lt=require("react");var hr=require("@vuu-ui/vuu-utils"),Fo=require("react");var Oo=require("react/jsx-runtime"),{IDX:Ns}=hr.metadataKeys,zs="vuuTableNextCell",vr=({column:e,columnMap:t,onClick:o,onDataEdited:n,row:r})=>{let{className:l,style:s}=De(e,zs),{CellRenderer:i,name:a,valueFormatter:c}=e,u=t[a],p=(0,Fo.useCallback)(C=>(n==null||n(r[Ns],a,C),!0),[a,n,r]),m=(0,Fo.useCallback)(C=>{o==null||o(C,e)},[e,o]);return(0,Oo.jsx)("div",{className:l,onClick:o?m:void 0,role:"cell",style:s,children:i?(0,Oo.jsx)(i,{column:e,columnMap:t,onCommit:p,row:r}):c(r[u])})};var Yt=require("@vuu-ui/vuu-utils"),yr=require("react");var Tr=W(require("classnames"));var nt=require("react/jsx-runtime"),{IS_LEAF:Is}=Yt.metadataKeys,Go="vuuTableNextGroupCell",wr=({column:e,onClick:t,row:o})=>{let{columns:n}=e,[r,l]=(0,Yt.getGroupValueAndOffset)(n,o),{className:s,style:i}=De(e,Go),a=(0,yr.useCallback)(p=>{t==null||t(p,e)},[e,t]),c=o[Is],u=Array(l).fill(0).map((p,m)=>(0,nt.jsx)("span",{className:`${Go}-spacer`},m));return(0,nt.jsxs)("div",{className:(0,Tr.default)(s,"vuuTableNextCell"),role:"cell",style:i,onClick:c?void 0:a,children:[u,c?null:(0,nt.jsx)("span",{className:`${Go}-toggle`,"data-icon":"triangle-right"}),(0,nt.jsx)("span",{children:r})]})};var Zt=require("react/jsx-runtime"),Mr=require("react"),{IDX:Vs,IS_EXPANDED:$s,SELECTED:Fs}=ee.metadataKeys,Se="vuuTableNextRow",Wo=(0,Lt.memo)(({className:e,columnMap:t,columns:o,row:n,offset:r,onClick:l,onDataEdited:s,onToggleGroup:i,zebraStripes:a=!1,...c})=>{let{[Vs]:u,[$s]:p,[Fs]:m}=n,C=(0,Lt.useCallback)(M=>{let D=M.shiftKey,w=M.ctrlKey||M.metaKey;l==null||l(n,D,w)},[l,n]),{True:h,First:v,Last:T}=ee.RowSelected,x=(0,Dr.default)(Se,e,{[`${Se}-even`]:a&&u%2===0,[`${Se}-expanded`]:p,[`${Se}-selected`]:m&h,[`${Se}-selectedStart`]:m&v,[`${Se}-selectedEnd`]:m&T}),g={transform:`translate3d(0px, ${r}px, 0px)`},f=(0,Lt.useCallback)((M,D)=>{((0,ee.isGroupColumn)(D)||(0,ee.isJsonGroup)(D,n))&&(M.stopPropagation(),i==null||i(n,D))},[i,n]);return(0,Mr.createElement)("div",{...c,"aria-rowindex":n[0],key:`row-${n[0]}`,role:"row",className:x,onClick:C,style:g},(0,Zt.jsx)("span",{className:`${Se}-selectionDecorator vuuStickyLeft`}),o.filter(ee.notHidden).map(M=>{let D=(0,ee.isGroupColumn)(M),w=(0,ee.isJsonColumn)(M);return(0,Zt.jsx)(D?wr:vr,{column:M,columnMap:t,onClick:D||w?f:void 0,onDataEdited:s,row:n},M.key)}),(0,Zt.jsx)("span",{className:`${Se}-selectionDecorator vuuStickyRight`}))});Wo.displayName="Row";var jr=require("@vuu-ui/vuu-layout"),qr=require("@vuu-ui/vuu-table-extras"),el=require("@vuu-ui/vuu-ui-controls");var U=require("react");var Bo=e=>`.vuuTableNext-col-headers .vuuTableNextHeaderCell:nth-child(${e})`,Uo=(e,t)=>`.vuuTableNext-body > [aria-rowindex='${e}'] > [role='cell']:nth-child(${t+1})`,Rr=(e,[t,o])=>{var l;let n=t===-1?Bo(o):Uo(t,o),r=(l=e.current)==null?void 0:l.querySelector(n);return Os(r)&&r.querySelector("button")||r},Os=e=>e.classList.contains("vuuTableNextCell-editable"),xr=e=>e.querySelector(".vuuTableInputCell")!==null;var Pr=new Set(["Home","End","PageUp","PageDown","ArrowDown","ArrowUp"]),_o=new Set(Pr);_o.add("ArrowLeft");_o.add("ArrowRight");var Gs=(e,t)=>{switch(t){case"cell":return _o.has(e);case"row":return Pr.has(e);default:return!1}},Ws=["Home","End","PageUp","PageDown"],Bs=e=>Ws.includes(e),Us=[-1,-1],_s=[void 0,void 0],Js=e=>{var o,n;let t=(o=e.closest(".vuuTableNext"))==null?void 0:o.querySelector(".vuuTableNext-scrollbarContainer");if(t){let r=t==null?void 0:t.getBoundingClientRect(),l=(n=e.closest(".vuuTableNextCell"))==null?void 0:n.getBoundingClientRect();if(l)return l.bottom>r.bottom?["down",l.bottom-r.bottom]:l.top<r.top?["up",l.top-r.top]:l.right<r.right?["right",l.right-r.right]:l.left<r.left?["left",l.left-r.left]:_s;throw Error("Whats going on, cell not found")}else throw Error("Whats going on, scrollbar container not found")};function Xs(e,[t,o],n,r){return e==="ArrowUp"?t>-1?[t-1,o]:[t,o]:e==="ArrowDown"?t===-1?[0,o]:t===r-1?[t,o]:[t+1,o]:e==="ArrowRight"?o<n-1?[t,o+1]:[t,o]:e==="ArrowLeft"?o>1?[t,o-1]:[t,o]:[t,o]}var Hr=({columnCount:e=0,containerRef:t,disableHighlightOnFocus:o,navigationStyle:n,requestScroll:r,rowCount:l=0,viewportRowCount:s})=>{var w;let i=(0,U.useRef)([-1,-1]),a=(0,U.useRef)(),c=(0,U.useRef)([-1,0]),u=d=>d==null?void 0:d.closest("[role='columnHeader'],[role='cell']"),p=d=>{var b,H;if(d.role==="columnHeader")return[-1,parseInt((b=d.dataset.idx)!=null?b:"-1",10)];{let y=d.closest("[role='row']");if(y){let R=parseInt((H=y.ariaRowIndex)!=null?H:"-1",10),A=Array.from(y.childNodes).indexOf(d);return[R,A]}}return Us},m=(0,U.useCallback)(d=>{var b;if(t.current){let H=Rr(t,d);if(H){H!==a.current&&((b=a.current)==null||b.removeAttribute("tabindex"),a.current=H,H.setAttribute("tabindex","0"));let[y,R]=Js(H);y&&R&&(r==null||r({type:"scroll-distance",distance:R,direction:y})),H.focus()}}},[t,r]),C=(0,U.useCallback)((d,b,H=!1)=>{let y=[d,b];c.current=y,m(y),H&&(i.current=y)},[m]),h=(0,U.useCallback)((d,[b,H])=>new Promise(y=>{let R=b;switch(d){case"PageDown":R=Math.min(l-1,b+s),r==null||r({type:"scroll-page",direction:"down"});break;case"PageUp":R=Math.max(0,b-s),r==null||r({type:"scroll-page",direction:"up"});break;case"Home":R=0,r==null||r({type:"scroll-end",direction:"home"});break;case"End":R=l-1,r==null||r({type:"scroll-end",direction:"end"});break}setTimeout(()=>{y([R,H])},90)}),[r,l,s]),v=(0,U.useCallback)(()=>{var d;if(o!==!0&&(d=t.current)!=null&&d.contains(document.activeElement)){let b=u(document.activeElement);b&&(i.current=p(b))}},[o,t]),T=(0,U.useCallback)(async d=>{let[b,H]=Bs(d)?await h(d,c.current):Xs(d,c.current,e,l);console.log(`nextRowIdx ${b} nextColIdx ${H}`);let[y,R]=c.current;(b!==y||H!==R)&&C(b,H,!0)},[e,h,l,C]),x=(0,U.useCallback)(d=>{l>0&&Gs(d.key,n)&&(d.preventDefault(),d.stopPropagation(),T(d.key))},[l,n,T]),g=(0,U.useCallback)(d=>{let b=d.target,H=u(b);if(H){let[y,R]=p(H);C(y,R)}},[C]),f=(0,U.useCallback)(()=>{T("ArrowDown")},[T]),M=(0,U.useMemo)(()=>({navigate:f,onClick:g,onFocus:v,onKeyDown:x}),[g,v,x,f]),D=((w=t.current)==null?void 0:w.firstChild)!=null;return(0,U.useEffect)(()=>{if(D&&a.current===void 0){let{current:d}=t,b=(d==null?void 0:d.querySelector(Bo(0)))||(d==null?void 0:d.querySelector(Uo(0,0)));b&&(b.setAttribute("tabindex","0"),a.current=b)}},[t,D]),M};var _=require("@vuu-ui/vuu-utils"),z=require("react");var jt=(e,t)=>{switch(t.type){case"col-size":return{...e,columns:e.columns.map(o=>o.name===t.column.name?{...o,width:t.width}:o)};case"column-prop":return{...e,columns:e.columns.map(o=>o.name===t.column.name?{...o,[t.property]:t.value}:o)};default:return e}};var to=require("@vuu-ui/vuu-data-react/src"),Oe=require("@vuu-ui/vuu-utils"),J=require("react");var eo=require("@vuu-ui/vuu-utils"),{SELECTED:Qs}=eo.metadataKeys,qt=class{constructor({from:t,to:o}){this.rowCount=0;this.setRowCount=t=>{t<this.data.length&&(this.data.length=t),this.rowCount=t};this.range=new eo.WindowRange(t,o),this.data=new Array(o-t),this.rowCount=0}add(t){let[o]=t;if(this.isWithinRange(o)){let n=o-this.range.from;this.data[n]=t}}getAtIndex(t){return this.range.isWithin(t)&&this.data[t-this.range.from]!=null?this.data[t-this.range.from]:void 0}isWithinRange(t){return this.range.isWithin(t)}setRange({from:t,to:o}){if(t!==this.range.from||o!==this.range.to){let[n,r]=this.range.overlap(t,o),l=new Array(Math.max(0,o-t));for(let s=n;s<r;s++){let i=this.getAtIndex(s);if(i){let a=s-t;l[a]=i}}this.data=l,this.range.from=t,this.range.to=o}}getSelectedRows(){return this.data.filter(t=>t[Qs]!==0)}};var Er=({dataSource:e,onFeatureEnabled:t,onFeatureInvocation:o,onSizeChange:n,onSubscribed:r,range:l=Oe.NULL_RANGE,renderBufferSize:s=0})=>{let[,i]=(0,J.useState)(null),a=(0,J.useRef)([]),c=(0,J.useRef)(!0),u=(0,J.useRef)(!1),p=(0,J.useRef)(Oe.NULL_RANGE),m=(0,J.useMemo)(()=>new qt((0,Oe.getFullRange)(l,s)),[]),C=(0,J.useCallback)(T=>{for(let x of T)m.add(x);a.current=m.data,c.current&&i({})},[m]),h=(0,J.useCallback)(T=>{T.type==="subscribed"?r==null||r(T):T.type==="viewport-update"?(typeof T.size=="number"&&(n==null||n(T.size),m.setRowCount(T.size)),T.rows?C(T.rows):typeof T.size=="number"&&(a.current=m.data,u.current=!0)):(0,to.isVuuFeatureAction)(T)?t==null||t(T):(0,to.isVuuFeatureInvocation)(T)?o==null||o(T):console.log(`useDataSource unexpected message ${T.type}`)},[m,t,o,n,r,C]);(0,J.useEffect)(()=>()=>{c.current=!0,c.current=!1},[]),(0,J.useEffect)(()=>{e==null||e.subscribe({range:(0,Oe.getFullRange)(l,s)},h)},[e,h,l,s]);let v=(0,J.useCallback)(T=>{let x=(0,Oe.getFullRange)(T,s);m.setRange(x),e.range=p.current=x,e.emit("range",T)},[e,m,s]);return{data:a.current,range:p.current,setRange:v}};var oo=require("react"),Sr=e=>{let t=(0,oo.useRef)(e);return(0,oo.useMemo)(()=>t.current,[])};var Ar=require("@vuu-ui/vuu-utils"),Lr=require("react"),Kr=require("@vuu-ui/vuu-popups"),kr=({columns:e,data:t})=>{let[o]=(0,Kr.useContextMenu)();return(0,Lr.useCallback)(r=>{var a;let l=r.target,s=l==null?void 0:l.closest("div[role='cell']"),i=l==null?void 0:l.closest("div[role='row']");if(s&&i){let c=(0,Ar.buildColumnMap)(e),u=parseInt((a=i.ariaRowIndex)!=null?a:"-1"),p=Array.from(i.childNodes).indexOf(s),m=t.find(([h])=>h===u),C=e[p];o(r,"grid",{columnMap:c,columnName:C,row:m})}},[e,t,o])};var Nr=require("@vuu-ui/vuu-utils"),Kt=require("react");var zr=({navigate:e})=>{let t=(0,Kt.useCallback)(()=>{e()},[e]),o=(0,Kt.useCallback)(l=>{let s=l.target,i=s.querySelector("input");i&&(i.focus(),i.select()),s.addEventListener("vuu-commit",t,!0)},[t]),n=(0,Kt.useCallback)(l=>{let s=l.target,i=s.querySelector("input");i&&(i.focus(),i.select()),s.addEventListener("vuu-commit",t,!0)},[t]);return{onKeyDown:(0,Kt.useCallback)(l=>{xr(l.target)&&((0,Nr.isCharacterKey)(l.key)?o(l):l.key==="Enter"&&n(l))},[o,n])}};var L=require("@vuu-ui/vuu-utils"),Ir=require("@vuu-ui/vuu-ui-controls"),Vr=require("react"),{info:Jo}=(0,L.logger)("useTableModel"),Ys=100,Zs=L.metadataKeys.count,js=({serverDataType:e})=>e===void 0,qs=e=>{var t;if((0,L.isTypeDescriptor)(e.type))return(0,L.getCellRenderer)((t=e.type)==null?void 0:t.renderer)},ei=(e,t)=>{var n;let o=t.columns.find(({name:r})=>r===e.name);return o?o.serverDataType:(n=e.serverDataType)!=null?n:"string"},ti=["int","long","double"],$r=e=>e===void 0?void 0:ti.includes(e)?"right":"left",Fr=e=>e.type==="columnSettings",Or=e=>e.type==="tableSettings",oi=(e,t)=>{switch(Jo==null||Jo(`TableModelReducer ${t.type}`),t.type){case"init":return Wr(t);case"moveColumn":return ri(e,t);case"resizeColumn":return ii(e,t);case"setTableSchema":return ai(e,t);case"hideColumns":return li(e,t);case"showColumns":return si(e,t);case"pinColumn":return ci(e,t);case"updateColumnProp":return lt(e,t);case"tableConfig":return Ur(e,t);default:return console.log(`unhandled action ${t.type}`),e}},Gr=(e,t)=>{let[o,n]=(0,Vr.useReducer)(oi,{tableConfig:e,dataSourceConfig:t},Wr),{columns:r,headings:l,tableConfig:s,...i}=o;return{columns:r,dispatchColumnAction:n,headings:l,tableAttributes:i,tableConfig:s}};function Wr({dataSourceConfig:e,tableConfig:t}){let{columns:o,...n}=t,r=o.filter((0,L.subscribedOnly)(e==null?void 0:e.columns)).map(Br(n)),l=r.some(L.isPinned)?(0,L.sortPinnedColumns)(r):r,s={columns:l,headings:(0,L.getTableHeadings)(l),tableConfig:t,...n};if(e){let{columns:i,...a}=e;s=Ur(s,{type:"tableConfig",...a})}return s}var ni=(e,t)=>t==="uppercase"?e.toUpperCase():t==="capitalize"?e[0].toUpperCase()+e.slice(1).toLowerCase():e,Br=e=>(t,o)=>{let{columnDefaultWidth:n=Ys,columnFormatHeader:r}=e,{align:l=$r(t.serverDataType),key:s,name:i,label:a=(0,L.getColumnLabel)(t),width:c=n,...u}=t,p={...u,align:l,CellRenderer:qs(t),clientSideEditValidationCheck:(0,L.hasValidationRules)(t.type)?(0,Ir.buildValidationChecker)(t.type.renderer.rules):void 0,label:ni(a,r),key:s!=null?s:o+Zs,name:i,originalIdx:o,valueFormatter:(0,L.getValueFormatter)(t),width:c};return(0,L.isGroupColumn)(p)&&(p.columns=p.columns.map(m=>Br(e)(m,m.key))),p};function ri(e,{column:t,moveBy:o,moveTo:n}){let{columns:r}=e;if(typeof o=="number"){let l=r.indexOf(t),s=r.slice(),[i]=s.splice(l,1);return s.splice(l+o,0,i),{...e,columns:s}}else if(typeof n=="number"){let l=r.indexOf(t);return{...e,columns:(0,L.moveItem)(r,l,n)}}return e}function li(e,{columns:t}){return t.some(o=>o.hidden!==!0)?t.reduce((o,n)=>n.hidden!==!0?lt(o,{type:"updateColumnProp",column:n,hidden:!0}):o,e):e}function si(e,{columns:t}){return t.some(o=>o.hidden)?t.reduce((o,n)=>n.hidden?lt(o,{type:"updateColumnProp",column:n,hidden:!1}):o,e):e}function ii(e,{column:t,phase:o,width:n}){let r="updateColumnProp",l=o!=="end";switch(o){case"begin":return lt(e,{type:r,column:t,resizing:l});case"end":return lt(e,{type:r,column:t,resizing:l,width:n});case"resize":return lt(e,{type:r,column:t,width:n});default:throw Error(`useTableModel.resizeColumn, invalid resizePhase ${o}`)}}function ai(e,{tableSchema:t}){let{columns:o}=e;if(o.some(js)){let n=o.map(r=>{var s;let l=ei(r,t);return{...r,align:(s=r.align)!=null?s:$r(l),serverDataType:l}});return{...e,columns:n}}else return e}function ci(e,t){let{columns:o}=e,{column:n,pin:r}=t,l=o.find(s=>s.name===n.name);return l?(o=rt(o,{...l,pin:r}),o=(0,L.sortPinnedColumns)(o),{...e,columns:o}):e}function lt(e,t){let{columns:o}=e,{align:n,column:r,hidden:l,label:s,resizing:i,width:a}=t,c=o.find(u=>u.name===r.name);return c&&((n==="left"||n==="right")&&(o=rt(o,{...c,align:n})),typeof s=="string"&&(o=rt(o,{...c,label:s})),typeof i=="boolean"&&(o=rt(o,{...c,resizing:i})),typeof l=="boolean"&&(o=rt(o,{...c,hidden:l})),typeof a=="number"&&(o=rt(o,{...c,width:a}))),{...e,columns:o}}function Ur(e,{confirmed:t,filter:o,groupBy:n,sort:r}){let l=n!==void 0,s=typeof(o==null?void 0:o.filter)=="string",i=r&&r.sortDefs.length>0,a=e;return l&&(a={...e,columns:(0,L.applyGroupByToColumns)(a.columns,n,t)}),i&&(a={...e,columns:(0,L.applySortToColumns)(a.columns,r)}),s?a={...e,columns:(0,L.applyFilterToColumns)(a.columns,o)}:a.columns.some(L.isFilteredColumn)&&(a={...e,columns:(0,L.stripFilterFromColumns)(a.columns)}),a}function rt(e,t){return e.map(o=>o.name===t.name?t:o)}var Q=require("react"),_r=e=>{let{scrollLeft:t,scrollTop:o}=e,{clientHeight:n,clientWidth:r,scrollHeight:l,scrollWidth:s}=e,i=t/(s-r),a=o/(l-n);return[i,a]},Jr=({onAttach:e,onDetach:t})=>{let o=(0,Q.useRef)(null);return(0,Q.useCallback)(r=>{if(r)o.current=r,e==null||e(r);else if(o.current){let{current:l}=o;o.current=r,t==null||t(l)}},[e,t])},Xr=({maxScrollLeft:e,maxScrollTop:t,onHorizontalScroll:o,onVerticalScroll:n,rowHeight:r,viewportRowCount:l})=>{let s=(0,Q.useRef)(!1),i=(0,Q.useRef)({scrollTop:0,scrollLeft:0}),a=(0,Q.useRef)(null),c=(0,Q.useRef)(null),u=(0,Q.useCallback)(()=>{let{current:f}=c,{current:M}=a,{current:D}=s;if(D)s.current=!1;else if(f&&M){let[w,d]=_r(M),b=Math.round(w*e),H=Math.round(d*t);f.scrollTo({left:b,top:H,behavior:"auto"})}},[e,t]),p=(0,Q.useCallback)(()=>{let{current:f}=c,{current:M}=a,{current:D}=i;if(f&&M){let{scrollLeft:w,scrollTop:d}=f,[b,H]=_r(f);s.current=!0,M.scrollLeft=Math.round(b*e),M.scrollTop=Math.round(H*t),D.scrollTop!==d&&(D.scrollTop=d,n==null||n(d,H)),D.scrollLeft!==w&&(D.scrollLeft=w,o==null||o(w))}},[e,t,o,n]),m=(0,Q.useCallback)(f=>{a.current=f,f.addEventListener("scroll",u,{passive:!0})},[u]),C=(0,Q.useCallback)(f=>{a.current=null,f.removeEventListener("scroll",u)},[u]),h=(0,Q.useCallback)(f=>{c.current=f,f.addEventListener("scroll",p,{passive:!0})},[p]),v=(0,Q.useCallback)(f=>{c.current=null,f.removeEventListener("scroll",p)},[p]),T=Jr({onAttach:h,onDetach:v}),x=Jr({onAttach:m,onDetach:C}),g=(0,Q.useCallback)(f=>{let{current:M}=c;if(M){let{scrollLeft:D,scrollTop:w}=M;if(s.current=!1,f.type==="scroll-distance"){let d=D,b=w;f.direction==="up"||f.direction==="down"?b=Math.min(Math.max(0,w+f.distance),t):d=Math.min(Math.max(0,D+f.distance),e),M.scrollTo({top:b,left:d,behavior:"auto"})}else if(f.type==="scroll-page"){let{direction:d}=f,b=l*(d==="down"?r:-r),H=Math.min(Math.max(0,w+b),t);M.scrollTo({top:H,left:D,behavior:"auto"})}else if(f.type==="scroll-end"){let{direction:d}=f,b=d==="end"?t:0;M.scrollTo({top:b,left:M.scrollLeft,behavior:"auto"})}}},[e,t,r,l]);return{scrollbarContainerRef:x,contentContainerRef:T,requestScroll:g}};var st=require("react"),Qr=({columns:e,getRowAtPosition:t,setRange:o,viewportMeasurements:n})=>{let r=(0,st.useRef)(0),{contentWidth:l,rowCount:s}=n,i=(0,st.useCallback)(a=>{let c=t(a);c!==r.current&&(r.current=c,o({from:c,to:c+s}))},[t,o,s]);return(0,st.useEffect)(()=>{let{current:a}=r,c={from:a,to:a+s};o(c)},[o,s]),{onVerticalScroll:i}};var{KEY:ui,IS_EXPANDED:Yr,IS_LEAF:Zr}=_.metadataKeys,mi=(e,t)=>({...e,columns:e.columns.concat(t)}),tl=({availableColumns:e,config:t,containerRef:o,dataSource:n,headerHeight:r=25,navigationStyle:l="cell",onAvailableColumnsChange:s,onConfigChange:i,onFeatureEnabled:a,onFeatureInvocation:c,onRowClick:u,onSelect:p,onSelectionChange:m,renderBufferSize:C=0,rowHeight:h=20,selectionModel:v})=>{let[T,x]=(0,z.useState)(n.size);if(n===void 0)throw Error("no data source provided to Vuu Table");let[g,f]=(0,z.useState)(),M=(0,z.useCallback)(P=>{f(P)},[]),D=(0,z.useMemo)(()=>Ct(n),[n]),w=(0,z.useCallback)(P=>{x(P)},[]),{columns:d,dispatchColumnAction:b,headings:H,tableAttributes:y,tableConfig:R}=Gr(t,n.config);(0,jr.useLayoutEffectSkipFirst)(()=>{b({type:"init",dataSourceConfig:n.config,tableConfig:R})},[R,n.config,b]);let[A,S]=(0,z.useState)(),[k,te]=(0,z.useMemo)(()=>{let P=(N,I)=>{let ne=(0,_.updateColumn)(d,N,{width:I});S(ne)};return[A!=null?A:d,P]},[d,A]),Ae=(0,z.useMemo)(()=>(0,_.buildColumnMap)(n.columns),[n.columns]),{getRowAtPosition:ct,getRowOffset:kt,setPctScrollTop:Nt,...ie}=Rt({columns:k,headerHeight:r,headings:H,rowCount:T,rowHeight:h,size:g}),Ge=Sr({from:0,to:ie.rowCount}),We=(0,z.useCallback)(({tableSchema:P})=>{P||console.log("usbscription message with no schema")},[]),{data:pe,range:oe,setRange:ut}=Er({dataSource:n,onFeatureEnabled:a,onFeatureInvocation:c,renderBufferSize:C,onSizeChange:w,onSubscribed:We,range:Ge}),mt=(0,z.useCallback)(P=>{b({type:"init",tableConfig:P,dataSourceConfig:n.config}),i==null||i(P)},[n.config,b,i]),pt=(0,z.useCallback)(P=>{n.config={...n.config,...P}},[n]),Y=(0,z.useCallback)(P=>{n.columns=n.columns.concat(P.name);let N=mi(R,P);b({type:"init",tableConfig:N,dataSourceConfig:n.config}),console.log("dispatch onConfigChange",{newTableConfig:N}),i==null||i(N)},[n,b,i,R]);(0,z.useEffect)(()=>{n.on("config",(P,N)=>{b({type:"tableConfig",...P,confirmed:N})})},[n,b]);let{showColumnSettingsPanel:Ce,showTableSettingsPanel:zt}=(0,qr.useTableAndColumnSettings)({availableColumns:e!=null?e:R.columns.map(({name:P,serverDataType:N="string"})=>({name:P,serverDataType:N})),onAvailableColumnsChange:s,onConfigChange:mt,onCreateCalculatedColumn:Y,onDataSourceConfigChange:pt,tableConfig:R}),ao=(0,z.useCallback)(P=>{Fr(P)?Ce(P):Or(P)?zt():b(P)},[b,Ce,zt]),It=bt({dataSource:n,onPersistentColumnOperation:ao}),Vt=(0,z.useCallback)((P,N=!1,I)=>{n&&(n.sort=(0,_.applySort)(n.sort,P,N,I))},[n]),$t=(0,z.useCallback)((P,N,I)=>{let ne=k.find(ge=>ge.name===N);if(ne)P==="resize"?(0,_.isValidNumber)(I)&&te(N,I):P==="end"?(0,_.isValidNumber)(I)&&(b({type:"resizeColumn",phase:P,column:ne,width:I}),i==null||i(jt(R,{type:"col-size",column:ne,width:I}))):(S(void 0),b({type:"resizeColumn",phase:P,column:ne,width:I}));else throw Error(`useDataTable.handleColumnResize, column ${N} not found`)},[k,R,b,i,te]),Ft=(0,z.useCallback)((P,N)=>{let I=(0,_.isJsonGroup)(N,P),ne=P[ui];if(P[Yr]){if(n.closeTreeNode(ne,!0),I){let ge=k.indexOf(N);n.getRowsAtDepth(ge+1).some(he=>he[Yr]||he[Zr])||b({type:"hideColumns",columns:k.slice(ge+2)})}}else if(n.openTreeNode(ne),I){let ge=n.getChildRows(ne),dt=k.indexOf(N)+1,he=[k[dt]];ge.some(bo=>bo[Zr])&&he.push(k[dt+1]),he.some(bo=>bo.hidden)&&b({type:"showColumns",columns:he})}},[k,n,b]),{onVerticalScroll:K}=Qr({columns:k,getRowAtPosition:ct,setRange:ut,viewportMeasurements:ie}),F=(0,z.useCallback)(P=>{K(P)},[K]),{requestScroll:Z,...G}=Xr({maxScrollLeft:ie.maxScrollContainerScrollHorizontal,maxScrollTop:ie.maxScrollContainerScrollVertical,rowHeight:h,onVerticalScroll:F,viewportRowCount:ie.rowCount}),{navigate:ae,onKeyDown:de,...ce}=Hr({columnCount:k.filter(P=>P.hidden!==!0).length,containerRef:o,navigationStyle:l,requestScroll:Z,rowCount:n==null?void 0:n.size,viewportRange:oe,viewportRowCount:ie.rowCount}),{onKeyDown:be}=zr({navigate:ae}),co=(0,z.useCallback)(P=>{de(P),P.defaultPrevented||be(P)},[de,be]),uo=kr({columns:k,data:pe}),mo=(0,z.useCallback)(P=>{var he;let I=P.target.closest(".vuuTableNextHeaderCell"),ne=parseInt((he=I==null?void 0:I.dataset.index)!=null?he:"-1"),ge=(0,_.visibleColumnAtIndex)(k,ne),dt=P.shiftKey;ge&&Vt(ge,dt)},[k,Vt]),po=(0,z.useCallback)(P=>{(0,_.isGroupColumn)(P)?n.groupBy=[]:n&&n.groupBy.includes(P.name)&&(n.groupBy=n.groupBy.filter(N=>N!==P.name))},[n]),fo=(0,z.useCallback)(P=>{n.select(P),m==null||m(P)},[n,m]),Ot=Mt({onSelect:p,onSelectionChange:fo,selectionModel:v}),Co=(0,z.useCallback)((P,N,I)=>{Ot(P,N,I),u==null||u(P)},[u,Ot]);(0,z.useEffect)(()=>{n.on("config",(P,N)=>{b({type:"tableConfig",...P,confirmed:N})})},[n,b]);let ml=(0,z.useCallback)((P,N)=>{let I=k[P];b({type:"moveColumn",column:I,moveTo:N})},[k,b]),pl=(0,z.useCallback)((P,N,I)=>n.applyEdit(P,N,I),[n]),{onMouseDown:dl,...fl}=(0,el.useDragDropNext)({allowDragDrop:!0,containerRef:o,draggableClassName:"vuuTableNext",onDrop:ml,orientation:"horizontal",itemQuery:".vuuTableNextHeaderCell"});return{...ce,onKeyDown:co,columnMap:Ae,columns:k,data:pe,handleContextMenuAction:It,headerProps:{onClick:mo,onMouseDown:dl,onResize:$t},menuBuilder:D,onContextMenu:uo,onDataEdited:pl,onRemoveGroupColumn:po,onResize:M,onRowClick:Co,onToggleGroup:Ft,scrollProps:G,tableAttributes:y,viewportMeasurements:ie,dragDropHook:fl}};var ro=require("@vuu-ui/vuu-layout"),nl=require("@salt-ds/core");var se=require("react/jsx-runtime"),Qo=require("react"),le="vuuTableNext",{IDX:pi,RENDER_IDX:di}=it.metadataKeys,rl=(0,no.forwardRef)(function({Row:t=Wo,availableColumns:o,className:n,config:r,dataSource:l,id:s,navigationStyle:i="cell",onAvailableColumnsChange:a,onConfigChange:c,onFeatureEnabled:u,onFeatureInvocation:p,onRowClick:m,onSelect:C,onSelectionChange:h,onShowConfigEditor:v,renderBufferSize:T=0,rowHeight:x=20,selectionModel:g="extended",showColumnHeaders:f=!0,headerHeight:M=f?25:0,style:D,...w},d){let b=(0,ro.useId)(s),H=(0,no.useRef)(null),{columnMap:y,columns:R,data:A,dragDropHook:S,handleContextMenuAction:k,headerProps:te,onDataEdited:Ae,onRemoveGroupColumn:ct,onResize:kt,onRowClick:Nt,onToggleGroup:ie,menuBuilder:Ge,scrollProps:We,tableAttributes:pe,viewportMeasurements:oe,...ut}=tl({availableColumns:o,config:r,containerRef:H,dataSource:l,headerHeight:M,navigationStyle:i,onAvailableColumnsChange:a,onConfigChange:c,onFeatureEnabled:u,onFeatureInvocation:p,onRowClick:m,onSelect:C,onSelectionChange:h,renderBufferSize:T,rowHeight:x,selectionModel:g}),mt=()=>({...D,"--content-height":`${oe.contentHeight}px`,"--horizontal-scrollbar-height":`${oe.horizontalScrollbarHeight}px`,"--content-width":`${oe.contentWidth}px`,"--pinned-width-left":`${oe.pinnedWidthLeft}px`,"--pinned-width-right":`${oe.pinnedWidthRight}px`,"--header-height":`${M}px`,"--row-height":`${x}px`,"--total-header-height":`${oe.totalHeaderHeight}px`,"--vertical-scrollbar-width":`${oe.verticalScrollbarWidth}px`,"--viewport-body-height":`${oe.viewportBodyHeight}px`}),pt=(0,Xo.default)(le,n,{[`${le}-colLines`]:pe.columnSeparators,[`${le}-rowLines`]:pe.rowSeparators,[`${le}-highlight`]:pe.showHighlightedRow,[`${le}-zebra`]:pe.zebraStripes});return(0,se.jsx)(ol.ContextMenuProvider,{menuActionHandler:k,menuBuilder:Ge,children:(0,se.jsxs)(ro.MeasuredContainer,{...w,className:pt,onResize:kt,ref:(0,nl.useForkRef)(H,d),style:mt(),children:[(0,se.jsx)("div",{className:`${le}-scrollbarContainer`,ref:We.scrollbarContainerRef,children:(0,se.jsx)("div",{className:`${le}-scrollbarContent`})}),(0,se.jsx)("div",{className:`${le}-contentContainer`,ref:We.contentContainerRef,children:(0,se.jsxs)("div",{...ut,className:`${le}-table`,tabIndex:-1,children:[f?(0,se.jsx)("div",{className:`${le}-col-headings`,children:(0,se.jsxs)("div",{className:`${le}-col-headers`,role:"row",children:[R.filter(it.notHidden).map((Y,Ce)=>(0,it.isGroupColumn)(Y)?(0,Qo.createElement)(At,{...te,column:Y,"data-index":Ce,key:Y.name,onRemoveColumn:ct}):(0,Qo.createElement)(gr,{...te,className:(0,Xo.default)({"vuuDraggable-dragAway":Ce===S.draggedItemIndex}),column:Y,"data-index":Ce,id:`${b}-col-${Ce}`,key:Y.name})),S.draggable]})}):null,(0,se.jsx)("div",{className:`${le}-body`,children:A.map(Y=>(0,se.jsx)(t,{columnMap:y,columns:R,onClick:Nt,onDataEdited:Ae,row:Y,offset:x*Y[pi]+M,onToggleGroup:ie,zebraStripes:pe.zebraStripes},Y[di]))})]})})]})})});var ll=require("@vuu-ui/vuu-ui-controls"),at=require("@vuu-ui/vuu-utils");var lo=require("react"),sl=require("react/jsx-runtime"),fi="vuuTableDropdownCell",Ci=["Enter"," "],bi=({column:e,columnMap:t,row:o})=>{var a,c,u;let n=(0,at.isTypeDescriptor)(e.type)&&(0,at.isColumnTypeRenderer)((a=e.type)==null?void 0:a.renderer)?(u=(c=e.type)==null?void 0:c.renderer)==null?void 0:u.values:[],r=t[e.name],[l,s]=(0,lo.useState)(o[r]),i=(0,lo.useCallback)((p,m)=>{m&&s(m)},[]);return(0,sl.jsx)(ll.Dropdown,{className:fi,onSelectionChange:i,openKeys:Ci,selected:l,source:n,width:e.width-17})};(0,at.registerComponent)("dropdown-cell",bi,"cell-renderer",{});var il=require("@vuu-ui/vuu-utils"),al=require("@salt-ds/core"),cl=require("@vuu-ui/vuu-ui-controls"),ul=W(require("classnames"));var io=require("react/jsx-runtime"),so="vuuTableInputCell",gi=()=>(console.warn("onCommit handler has not been provided to InputCell cell renderer"),!0),hi=({column:e,columnMap:t,onCommit:o=gi,row:n})=>{let r=t[e.name],{align:l="left",clientSideEditValidationCheck:s,valueFormatter:i}=e,{warningMessage:a,...c}=(0,cl.useEditableText)({initialValue:i(n[r]),onCommit:o,clientSideEditValidationCheck:s}),u=a&&l==="left"?(0,io.jsx)("span",{className:`${so}-icon`,"data-icon":"error"}):void 0,p=a&&l==="right"?(0,io.jsx)("span",{className:`${so}-icon`,"data-icon":"error"}):void 0;return(0,io.jsx)(al.Input,{...c,className:(0,ul.default)(so,{[`${so}-error`]:a!==void 0}),endAdornment:u,startAdornment:p})};(0,il.registerComponent)("input-cell",hi,"cell-renderer",{});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
CheckboxCell: () => CheckboxCell,
|
|
34
|
+
DropdownCell: () => DropdownCell,
|
|
35
|
+
GroupHeaderCellNext: () => GroupHeaderCellNext,
|
|
36
|
+
HeaderCell: () => HeaderCell,
|
|
37
|
+
InputCell: () => InputCell,
|
|
38
|
+
LookupCell: () => LookupCell,
|
|
39
|
+
Table: () => Table,
|
|
40
|
+
ToggleCell: () => ToggleCell,
|
|
41
|
+
isShowColumnSettings: () => isShowColumnSettings,
|
|
42
|
+
isShowTableSettings: () => isShowTableSettings,
|
|
43
|
+
updateTableConfig: () => updateTableConfig,
|
|
44
|
+
useControlledTableNavigation: () => useControlledTableNavigation,
|
|
45
|
+
useTableModel: () => useTableModel,
|
|
46
|
+
useTableViewport: () => useTableViewport
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(src_exports);
|
|
49
|
+
|
|
50
|
+
// src/header-cell/GroupHeaderCellNext.tsx
|
|
51
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
52
|
+
var import_react5 = require("react");
|
|
53
|
+
|
|
54
|
+
// src/column-resizing/ColumnResizer.tsx
|
|
55
|
+
var import_react = require("react");
|
|
56
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
+
var NOOP = () => void 0;
|
|
58
|
+
var baseClass = "vuuColumnResizerNext";
|
|
59
|
+
var ColumnResizer = ({
|
|
60
|
+
onDrag,
|
|
61
|
+
onDragEnd = NOOP,
|
|
62
|
+
onDragStart = NOOP
|
|
63
|
+
}) => {
|
|
64
|
+
const position = (0, import_react.useRef)(0);
|
|
65
|
+
const onMouseMove = (0, import_react.useCallback)(
|
|
66
|
+
(e) => {
|
|
67
|
+
if (e.stopPropagation) {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
}
|
|
70
|
+
if (e.preventDefault) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
}
|
|
73
|
+
const x = Math.round(e.clientX);
|
|
74
|
+
const moveBy = x - position.current;
|
|
75
|
+
position.current = x;
|
|
76
|
+
if (moveBy !== 0) {
|
|
77
|
+
onDrag(e, moveBy);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[onDrag]
|
|
81
|
+
);
|
|
82
|
+
const onMouseUp = (0, import_react.useCallback)(
|
|
83
|
+
(e) => {
|
|
84
|
+
window.removeEventListener("mouseup", onMouseUp);
|
|
85
|
+
window.removeEventListener("mousemove", onMouseMove);
|
|
86
|
+
onDragEnd(e);
|
|
87
|
+
},
|
|
88
|
+
[onDragEnd, onMouseMove]
|
|
89
|
+
);
|
|
90
|
+
const handleMouseDown = (0, import_react.useCallback)(
|
|
91
|
+
(e) => {
|
|
92
|
+
onDragStart(e);
|
|
93
|
+
position.current = Math.round(e.clientX);
|
|
94
|
+
window.addEventListener("mouseup", onMouseUp);
|
|
95
|
+
window.addEventListener("mousemove", onMouseMove);
|
|
96
|
+
if (e.stopPropagation) {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
}
|
|
99
|
+
if (e.preventDefault) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
[onDragStart, onMouseMove, onMouseUp]
|
|
104
|
+
);
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: baseClass, onMouseDown: handleMouseDown });
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/column-resizing/useTableColumnResize.tsx
|
|
109
|
+
var import_react2 = require("react");
|
|
110
|
+
var useTableColumnResize = ({
|
|
111
|
+
column,
|
|
112
|
+
onResize,
|
|
113
|
+
rootRef
|
|
114
|
+
}) => {
|
|
115
|
+
const widthRef = (0, import_react2.useRef)(0);
|
|
116
|
+
const [isResizing, setResizing] = (0, import_react2.useState)(false);
|
|
117
|
+
const { name } = column;
|
|
118
|
+
const handleResizeStart = (0, import_react2.useCallback)(() => {
|
|
119
|
+
if (onResize && rootRef.current) {
|
|
120
|
+
const { width } = rootRef.current.getBoundingClientRect();
|
|
121
|
+
widthRef.current = Math.round(width);
|
|
122
|
+
setResizing(true);
|
|
123
|
+
onResize == null ? void 0 : onResize("begin", name);
|
|
124
|
+
}
|
|
125
|
+
}, [name, onResize, rootRef]);
|
|
126
|
+
const handleResize = (0, import_react2.useCallback)(
|
|
127
|
+
(_evt, moveBy) => {
|
|
128
|
+
if (rootRef.current) {
|
|
129
|
+
if (onResize) {
|
|
130
|
+
const { width } = rootRef.current.getBoundingClientRect();
|
|
131
|
+
const newWidth = Math.round(width) + moveBy;
|
|
132
|
+
if (newWidth !== widthRef.current && newWidth > 0) {
|
|
133
|
+
onResize("resize", name, newWidth);
|
|
134
|
+
widthRef.current = newWidth;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
[name, onResize, rootRef]
|
|
140
|
+
);
|
|
141
|
+
const handleResizeEnd = (0, import_react2.useCallback)(() => {
|
|
142
|
+
if (onResize) {
|
|
143
|
+
onResize("end", name, widthRef.current);
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
setResizing(false);
|
|
146
|
+
}, 80);
|
|
147
|
+
}
|
|
148
|
+
}, [name, onResize]);
|
|
149
|
+
return {
|
|
150
|
+
isResizing,
|
|
151
|
+
onDrag: handleResize,
|
|
152
|
+
onDragStart: handleResizeStart,
|
|
153
|
+
onDragEnd: handleResizeEnd
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/useCell.ts
|
|
158
|
+
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
159
|
+
var import_classnames = __toESM(require("classnames"));
|
|
160
|
+
var import_react3 = require("react");
|
|
161
|
+
var useCell = (column, classBase11, isHeader) => (
|
|
162
|
+
// TODO measure perf without the memo, might not be worth the cost
|
|
163
|
+
(0, import_react3.useMemo)(() => {
|
|
164
|
+
const className = (0, import_classnames.default)(classBase11, {
|
|
165
|
+
vuuPinFloating: column.pin === "floating",
|
|
166
|
+
vuuPinLeft: column.pin === "left",
|
|
167
|
+
vuuPinRight: column.pin === "right",
|
|
168
|
+
vuuEndPin: isHeader && column.endPin,
|
|
169
|
+
// [`${classBase}-resizing`]: column.resizing,
|
|
170
|
+
[`${classBase11}-editable`]: column.editable,
|
|
171
|
+
[`${classBase11}-right`]: column.align === "right"
|
|
172
|
+
});
|
|
173
|
+
const style = (0, import_vuu_utils.getColumnStyle)(column);
|
|
174
|
+
return {
|
|
175
|
+
className,
|
|
176
|
+
style
|
|
177
|
+
};
|
|
178
|
+
}, [column, classBase11, isHeader])
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
// src/column-header-pill/ColumnHeaderPill.tsx
|
|
182
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
183
|
+
var import_react4 = require("react");
|
|
184
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
185
|
+
var classBase = "vuuColumnHeaderPill";
|
|
186
|
+
var ColumnHeaderPill = ({
|
|
187
|
+
children,
|
|
188
|
+
className,
|
|
189
|
+
column,
|
|
190
|
+
onRemove,
|
|
191
|
+
removable,
|
|
192
|
+
...htmlAttributes
|
|
193
|
+
}) => {
|
|
194
|
+
if (removable && typeof onRemove !== "function") {
|
|
195
|
+
throw Error(
|
|
196
|
+
"ColumnHeaderPill onRemove prop must be provided if Pill is removable"
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
const handleClickRemove = (0, import_react4.useCallback)(
|
|
200
|
+
(evt) => {
|
|
201
|
+
evt.preventDefault();
|
|
202
|
+
evt.stopPropagation();
|
|
203
|
+
onRemove == null ? void 0 : onRemove(column);
|
|
204
|
+
},
|
|
205
|
+
[column, onRemove]
|
|
206
|
+
);
|
|
207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ...htmlAttributes, className: (0, import_classnames2.default)(classBase, className), children: [
|
|
208
|
+
children,
|
|
209
|
+
removable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
210
|
+
"span",
|
|
211
|
+
{
|
|
212
|
+
className: `${classBase}-removeButton`,
|
|
213
|
+
role: "button",
|
|
214
|
+
"data-icon": "cross",
|
|
215
|
+
onClick: handleClickRemove
|
|
216
|
+
}
|
|
217
|
+
) : null
|
|
218
|
+
] });
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/column-header-pill/GroupColumnPill.tsx
|
|
222
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
223
|
+
var GroupColumnPill = ({
|
|
224
|
+
column,
|
|
225
|
+
...columnHeaderProps
|
|
226
|
+
}) => {
|
|
227
|
+
const { name, sorted } = column;
|
|
228
|
+
const icon = typeof sorted === "number" ? sorted < 0 ? "arrow-down" : "arrow-up" : sorted === "A" ? "arrow-up" : sorted === "D" ? "arrow-down" : void 0;
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ColumnHeaderPill, { ...columnHeaderProps, column, children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuGroupColumnPill-label", children: name }),
|
|
231
|
+
icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-icon": icon }) : null,
|
|
232
|
+
typeof sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuSortPosition", children: Math.abs(sorted) }) : null
|
|
233
|
+
] });
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// src/column-header-pill/SortIndicator.tsx
|
|
237
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
238
|
+
var SortIndicator = ({ column }) => {
|
|
239
|
+
if (!column.sorted) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const icon = typeof column.sorted === "number" ? column.sorted < 0 ? "arrow-down" : "arrow-up" : column.sorted === "A" ? "arrow-up" : "arrow-down";
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ColumnHeaderPill, { column, children: [
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-icon": icon }),
|
|
245
|
+
typeof column.sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "vuuSortPosition", children: Math.abs(column.sorted) }) : null
|
|
246
|
+
] });
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/header-cell/GroupHeaderCellNext.tsx
|
|
250
|
+
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
251
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
252
|
+
var import_react6 = require("react");
|
|
253
|
+
var classBase2 = "vuuTableGroupHeaderCell";
|
|
254
|
+
var switchIfChanged = (columns, newColumns) => {
|
|
255
|
+
if (columns === newColumns) {
|
|
256
|
+
return columns;
|
|
257
|
+
} else {
|
|
258
|
+
return newColumns;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var GroupHeaderCellNext = ({
|
|
262
|
+
column: groupColumn,
|
|
263
|
+
className: classNameProp,
|
|
264
|
+
onMoveColumn,
|
|
265
|
+
onRemoveColumn,
|
|
266
|
+
onResize,
|
|
267
|
+
...htmlAttributes
|
|
268
|
+
}) => {
|
|
269
|
+
const rootRef = (0, import_react5.useRef)(null);
|
|
270
|
+
const { isResizing, ...resizeProps } = useTableColumnResize({
|
|
271
|
+
column: groupColumn,
|
|
272
|
+
onResize,
|
|
273
|
+
rootRef
|
|
274
|
+
});
|
|
275
|
+
const [columns, setColumns] = (0, import_react5.useState)(groupColumn.columns);
|
|
276
|
+
const { className, style } = useCell(groupColumn, classBase2, true);
|
|
277
|
+
const columnPillProps = columns.length > 1 ? {
|
|
278
|
+
removable: true,
|
|
279
|
+
onRemove: onRemoveColumn
|
|
280
|
+
} : void 0;
|
|
281
|
+
const handleMoveItem = (0, import_react5.useCallback)(
|
|
282
|
+
(fromIndex, toIndex) => {
|
|
283
|
+
setColumns((cols) => {
|
|
284
|
+
const newCols = cols.slice();
|
|
285
|
+
const [tab] = newCols.splice(fromIndex, 1);
|
|
286
|
+
if (toIndex === -1) {
|
|
287
|
+
const result = newCols.concat(tab);
|
|
288
|
+
onMoveColumn == null ? void 0 : onMoveColumn(result);
|
|
289
|
+
return result;
|
|
290
|
+
} else {
|
|
291
|
+
newCols.splice(toIndex, 0, tab);
|
|
292
|
+
onMoveColumn == null ? void 0 : onMoveColumn(newCols);
|
|
293
|
+
return newCols;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
[onMoveColumn]
|
|
298
|
+
);
|
|
299
|
+
(0, import_vuu_layout.useLayoutEffectSkipFirst)(() => {
|
|
300
|
+
setColumns((cols) => switchIfChanged(cols, groupColumn.columns));
|
|
301
|
+
}, [groupColumn.columns]);
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
303
|
+
"div",
|
|
304
|
+
{
|
|
305
|
+
...htmlAttributes,
|
|
306
|
+
className: (0, import_classnames3.default)(className, classNameProp, {
|
|
307
|
+
[`${classBase2}-pending`]: groupColumn.groupConfirmed === false
|
|
308
|
+
}),
|
|
309
|
+
ref: rootRef,
|
|
310
|
+
role: "columnheader",
|
|
311
|
+
style,
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
314
|
+
import_vuu_layout.OverflowContainer,
|
|
315
|
+
{
|
|
316
|
+
allowDragDrop: true,
|
|
317
|
+
className: `${classBase2}-inner`,
|
|
318
|
+
height: 24,
|
|
319
|
+
onMoveItem: handleMoveItem,
|
|
320
|
+
overflowPosition: "start",
|
|
321
|
+
children: columns.map((column) => {
|
|
322
|
+
return /* @__PURE__ */ (0, import_react6.createElement)(
|
|
323
|
+
GroupColumnPill,
|
|
324
|
+
{
|
|
325
|
+
...columnPillProps,
|
|
326
|
+
column,
|
|
327
|
+
key: column.key
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
334
|
+
ColumnHeaderPill,
|
|
335
|
+
{
|
|
336
|
+
column: groupColumn,
|
|
337
|
+
removable: true,
|
|
338
|
+
onRemove: onRemoveColumn
|
|
339
|
+
}
|
|
340
|
+
),
|
|
341
|
+
groupColumn.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ColumnResizer, { ...resizeProps }) : null
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// src/header-cell/HeaderCell.tsx
|
|
348
|
+
var import_react8 = require("react");
|
|
349
|
+
|
|
350
|
+
// src/column-menu/ColumnMenu.tsx
|
|
351
|
+
var import_vuu_popups = require("@vuu-ui/vuu-popups");
|
|
352
|
+
var import_classnames4 = __toESM(require("classnames"));
|
|
353
|
+
var import_react7 = require("react");
|
|
354
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
355
|
+
var getPosition = (element) => {
|
|
356
|
+
if (element) {
|
|
357
|
+
const { bottom, left } = element.getBoundingClientRect();
|
|
358
|
+
return { x: left, y: bottom + 6 };
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var ColumnMenu = ({
|
|
362
|
+
className,
|
|
363
|
+
column,
|
|
364
|
+
...props
|
|
365
|
+
}) => {
|
|
366
|
+
const rootRef = (0, import_react7.useRef)(null);
|
|
367
|
+
const [menuOpen, setMenuOpen] = (0, import_react7.useState)(false);
|
|
368
|
+
const [showContextMenu] = (0, import_vuu_popups.useContextMenu)();
|
|
369
|
+
const handleMenuClose = (0, import_react7.useCallback)(() => {
|
|
370
|
+
setMenuOpen(false);
|
|
371
|
+
}, []);
|
|
372
|
+
const showColumnMenu = (0, import_react7.useCallback)(
|
|
373
|
+
(e) => {
|
|
374
|
+
setMenuOpen(true);
|
|
375
|
+
showContextMenu(e, "column-menu", {
|
|
376
|
+
column,
|
|
377
|
+
ContextMenuProps: {
|
|
378
|
+
onClose: handleMenuClose,
|
|
379
|
+
position: getPosition(rootRef.current)
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
[column, handleMenuClose, showContextMenu]
|
|
384
|
+
);
|
|
385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
386
|
+
"span",
|
|
387
|
+
{
|
|
388
|
+
...props,
|
|
389
|
+
className: (0, import_classnames4.default)("vuuTable-columnMenu", className, {
|
|
390
|
+
"vuuTable-columnMenu-open": menuOpen
|
|
391
|
+
}),
|
|
392
|
+
"data-icon": "more-vert",
|
|
393
|
+
onClick: showColumnMenu,
|
|
394
|
+
ref: rootRef
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// src/header-cell/HeaderCell.tsx
|
|
400
|
+
var import_classnames5 = __toESM(require("classnames"));
|
|
401
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
402
|
+
var classBase3 = "vuuTableHeaderCell";
|
|
403
|
+
var HeaderCell = ({
|
|
404
|
+
className: classNameProp,
|
|
405
|
+
column,
|
|
406
|
+
onClick,
|
|
407
|
+
onResize,
|
|
408
|
+
...htmlAttributes
|
|
409
|
+
}) => {
|
|
410
|
+
var _a;
|
|
411
|
+
const { HeaderCellContentRenderer, HeaderCellLabelRenderer } = column;
|
|
412
|
+
const rootRef = (0, import_react8.useRef)(null);
|
|
413
|
+
const { isResizing, ...resizeProps } = useTableColumnResize({
|
|
414
|
+
column,
|
|
415
|
+
onResize,
|
|
416
|
+
rootRef
|
|
417
|
+
});
|
|
418
|
+
const handleClick = (0, import_react8.useCallback)(
|
|
419
|
+
(evt) => {
|
|
420
|
+
!isResizing && (onClick == null ? void 0 : onClick(evt));
|
|
421
|
+
},
|
|
422
|
+
[isResizing, onClick]
|
|
423
|
+
);
|
|
424
|
+
const { className, style } = useCell(column, classBase3, true);
|
|
425
|
+
const columnMenu = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ColumnMenu, { column });
|
|
426
|
+
const columnLabel = HeaderCellLabelRenderer ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderCellLabelRenderer, { className: `${classBase3}-label`, column }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `${classBase3}-label`, children: (_a = column.label) != null ? _a : column.name });
|
|
427
|
+
const columnContent = HeaderCellContentRenderer ? [/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderCellContentRenderer, { column }, "content")] : [];
|
|
428
|
+
const sortIndicator = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SortIndicator, { column });
|
|
429
|
+
const headerItems = column.align === "right" ? [sortIndicator, columnLabel].concat(columnContent).concat(columnMenu) : [columnMenu, columnLabel, sortIndicator].concat(columnContent);
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
431
|
+
"div",
|
|
432
|
+
{
|
|
433
|
+
...htmlAttributes,
|
|
434
|
+
className: (0, import_classnames5.default)(className, classNameProp, {
|
|
435
|
+
[`${classBase3}-resizing`]: isResizing
|
|
436
|
+
}),
|
|
437
|
+
onClick: handleClick,
|
|
438
|
+
ref: rootRef,
|
|
439
|
+
role: "columnheader",
|
|
440
|
+
style,
|
|
441
|
+
children: [
|
|
442
|
+
...headerItems,
|
|
443
|
+
column.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ColumnResizer, { ...resizeProps }) : null
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
// src/Table.tsx
|
|
450
|
+
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
451
|
+
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
452
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
453
|
+
var import_core2 = require("@salt-ds/core");
|
|
454
|
+
var import_classnames9 = __toESM(require("classnames"));
|
|
455
|
+
var import_react25 = require("react");
|
|
456
|
+
|
|
457
|
+
// src/Row.tsx
|
|
458
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
459
|
+
var import_classnames7 = __toESM(require("classnames"));
|
|
460
|
+
var import_react11 = require("react");
|
|
461
|
+
|
|
462
|
+
// src/table-cell/TableCell.tsx
|
|
463
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
464
|
+
var import_react9 = require("react");
|
|
465
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
466
|
+
var classBase4 = "vuuTableCell";
|
|
467
|
+
var TableCell = ({
|
|
468
|
+
column,
|
|
469
|
+
columnMap,
|
|
470
|
+
onClick,
|
|
471
|
+
onDataEdited,
|
|
472
|
+
row
|
|
473
|
+
}) => {
|
|
474
|
+
const { className, style } = useCell(column, classBase4);
|
|
475
|
+
const { CellRenderer, name, valueFormatter } = column;
|
|
476
|
+
const dataIdx = columnMap[name];
|
|
477
|
+
const handleDataItemEdited = (0, import_react9.useCallback)(
|
|
478
|
+
(value) => {
|
|
479
|
+
if (onDataEdited) {
|
|
480
|
+
let typedValue = value;
|
|
481
|
+
if ((0, import_vuu_utils2.isNumericColumn)(column) && typeof value === "string") {
|
|
482
|
+
typedValue = column.serverDataType === "double" ? parseFloat(value) : parseInt(value);
|
|
483
|
+
}
|
|
484
|
+
return onDataEdited == null ? void 0 : onDataEdited(row, name, typedValue);
|
|
485
|
+
} else {
|
|
486
|
+
throw Error(
|
|
487
|
+
"TableCell onDataEdited prop not supplied for an editable cell"
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
[column, name, onDataEdited, row]
|
|
492
|
+
);
|
|
493
|
+
const handleClick = (0, import_react9.useCallback)(
|
|
494
|
+
(evt) => {
|
|
495
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
496
|
+
},
|
|
497
|
+
[column, onClick]
|
|
498
|
+
);
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
500
|
+
"div",
|
|
501
|
+
{
|
|
502
|
+
className,
|
|
503
|
+
onClick: onClick ? handleClick : void 0,
|
|
504
|
+
role: "cell",
|
|
505
|
+
style,
|
|
506
|
+
children: CellRenderer ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
507
|
+
CellRenderer,
|
|
508
|
+
{
|
|
509
|
+
column,
|
|
510
|
+
columnMap,
|
|
511
|
+
onCommit: handleDataItemEdited,
|
|
512
|
+
row
|
|
513
|
+
}
|
|
514
|
+
) : valueFormatter(row[dataIdx])
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// src/table-cell/TableGroupCell.tsx
|
|
520
|
+
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
521
|
+
var import_react10 = require("react");
|
|
522
|
+
var import_classnames6 = __toESM(require("classnames"));
|
|
523
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
524
|
+
var { IS_LEAF } = import_vuu_utils3.metadataKeys;
|
|
525
|
+
var classBase5 = "vuuTableGroupCell";
|
|
526
|
+
var TableGroupCell = ({ column, onClick, row }) => {
|
|
527
|
+
const { columns } = column;
|
|
528
|
+
const [value, offset] = (0, import_vuu_utils3.getGroupValueAndOffset)(columns, row);
|
|
529
|
+
const { className, style } = useCell(column, classBase5);
|
|
530
|
+
const handleClick = (0, import_react10.useCallback)(
|
|
531
|
+
(evt) => {
|
|
532
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
533
|
+
},
|
|
534
|
+
[column, onClick]
|
|
535
|
+
);
|
|
536
|
+
const isLeaf = row[IS_LEAF];
|
|
537
|
+
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${classBase5}-spacer` }, i));
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
539
|
+
"div",
|
|
540
|
+
{
|
|
541
|
+
className: (0, import_classnames6.default)(className, "vuuTableCell"),
|
|
542
|
+
role: "cell",
|
|
543
|
+
style,
|
|
544
|
+
onClick: isLeaf ? void 0 : handleClick,
|
|
545
|
+
children: [
|
|
546
|
+
spacers,
|
|
547
|
+
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${classBase5}-toggle`, "data-icon": "triangle-right" }),
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: value })
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
// src/Row.tsx
|
|
555
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
556
|
+
var import_react12 = require("react");
|
|
557
|
+
var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils4.metadataKeys;
|
|
558
|
+
var classBase6 = "vuuTableRow";
|
|
559
|
+
var Row = (0, import_react11.memo)(
|
|
560
|
+
({
|
|
561
|
+
className: classNameProp,
|
|
562
|
+
columnMap,
|
|
563
|
+
columns,
|
|
564
|
+
highlighted,
|
|
565
|
+
row,
|
|
566
|
+
offset,
|
|
567
|
+
onClick,
|
|
568
|
+
onDataEdited,
|
|
569
|
+
onToggleGroup,
|
|
570
|
+
zebraStripes = false,
|
|
571
|
+
...htmlAttributes
|
|
572
|
+
}) => {
|
|
573
|
+
const {
|
|
574
|
+
[IDX]: rowIndex,
|
|
575
|
+
[IS_EXPANDED]: isExpanded,
|
|
576
|
+
[SELECTED]: selectionStatus
|
|
577
|
+
} = row;
|
|
578
|
+
const handleRowClick = (0, import_react11.useCallback)(
|
|
579
|
+
(evt) => {
|
|
580
|
+
const rangeSelect = evt.shiftKey;
|
|
581
|
+
const keepExistingSelection = evt.ctrlKey || evt.metaKey;
|
|
582
|
+
onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
|
|
583
|
+
},
|
|
584
|
+
[onClick, row]
|
|
585
|
+
);
|
|
586
|
+
const { True, First, Last } = import_vuu_utils4.RowSelected;
|
|
587
|
+
const className = (0, import_classnames7.default)(classBase6, classNameProp, {
|
|
588
|
+
[`${classBase6}-even`]: zebraStripes && rowIndex % 2 === 0,
|
|
589
|
+
[`${classBase6}-expanded`]: isExpanded,
|
|
590
|
+
[`${classBase6}-highlighted`]: highlighted,
|
|
591
|
+
[`${classBase6}-selected`]: selectionStatus & True,
|
|
592
|
+
[`${classBase6}-selectedStart`]: selectionStatus & First,
|
|
593
|
+
[`${classBase6}-selectedEnd`]: selectionStatus & Last
|
|
594
|
+
});
|
|
595
|
+
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
596
|
+
const handleGroupCellClick = (0, import_react11.useCallback)(
|
|
597
|
+
(evt, column) => {
|
|
598
|
+
if ((0, import_vuu_utils4.isGroupColumn)(column) || (0, import_vuu_utils4.isJsonGroup)(column, row)) {
|
|
599
|
+
evt.stopPropagation();
|
|
600
|
+
onToggleGroup == null ? void 0 : onToggleGroup(row, column);
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
[onToggleGroup, row]
|
|
604
|
+
);
|
|
605
|
+
return /* @__PURE__ */ (0, import_react12.createElement)(
|
|
606
|
+
"div",
|
|
607
|
+
{
|
|
608
|
+
...htmlAttributes,
|
|
609
|
+
"aria-rowindex": row[0],
|
|
610
|
+
key: `row-${row[0]}`,
|
|
611
|
+
role: "row",
|
|
612
|
+
className,
|
|
613
|
+
onClick: handleRowClick,
|
|
614
|
+
style
|
|
615
|
+
},
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase6}-selectionDecorator vuuStickyLeft` }),
|
|
617
|
+
columns.filter(import_vuu_utils4.isNotHidden).map((column) => {
|
|
618
|
+
const isGroup = (0, import_vuu_utils4.isGroupColumn)(column);
|
|
619
|
+
const isJsonCell = (0, import_vuu_utils4.isJsonColumn)(column);
|
|
620
|
+
const Cell = isGroup ? TableGroupCell : TableCell;
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
622
|
+
Cell,
|
|
623
|
+
{
|
|
624
|
+
column,
|
|
625
|
+
columnMap,
|
|
626
|
+
onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
|
|
627
|
+
onDataEdited,
|
|
628
|
+
row
|
|
629
|
+
},
|
|
630
|
+
column.key
|
|
631
|
+
);
|
|
632
|
+
}),
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase6}-selectionDecorator vuuStickyRight` })
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
Row.displayName = "Row";
|
|
638
|
+
|
|
639
|
+
// src/useTable.ts
|
|
640
|
+
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
641
|
+
var import_vuu_table_extras = require("@vuu-ui/vuu-table-extras");
|
|
642
|
+
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
643
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
644
|
+
var import_react23 = require("react");
|
|
645
|
+
|
|
646
|
+
// src/context-menu/buildContextMenuDescriptors.ts
|
|
647
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
648
|
+
var buildContextMenuDescriptors = (dataSource) => (location, options) => {
|
|
649
|
+
const descriptors = [];
|
|
650
|
+
if (dataSource === void 0) {
|
|
651
|
+
return descriptors;
|
|
652
|
+
}
|
|
653
|
+
if (location === "header" || location === "column-menu") {
|
|
654
|
+
descriptors.push(
|
|
655
|
+
...buildSortMenuItems(options, dataSource)
|
|
656
|
+
);
|
|
657
|
+
descriptors.push(
|
|
658
|
+
...buildGroupMenuItems(options, dataSource)
|
|
659
|
+
);
|
|
660
|
+
descriptors.push(
|
|
661
|
+
...buildAggregationMenuItems(options, dataSource)
|
|
662
|
+
);
|
|
663
|
+
descriptors.push(...buildColumnDisplayMenuItems(options));
|
|
664
|
+
descriptors.push({
|
|
665
|
+
action: "column-settings",
|
|
666
|
+
icon: "cog",
|
|
667
|
+
label: `Column Settings`,
|
|
668
|
+
options
|
|
669
|
+
});
|
|
670
|
+
descriptors.push({
|
|
671
|
+
action: "table-settings",
|
|
672
|
+
icon: "cog",
|
|
673
|
+
label: `DataGrid Settings`,
|
|
674
|
+
options
|
|
675
|
+
});
|
|
676
|
+
} else if (location === "filter") {
|
|
677
|
+
const { column, filter } = options;
|
|
678
|
+
const colIsOnlyFilter = (filter == null ? void 0 : filter.column) === (column == null ? void 0 : column.name);
|
|
679
|
+
descriptors.push({
|
|
680
|
+
label: "Edit filter",
|
|
681
|
+
action: "filter-edit",
|
|
682
|
+
options
|
|
683
|
+
});
|
|
684
|
+
descriptors.push({
|
|
685
|
+
label: "Remove filter",
|
|
686
|
+
action: "filter-remove-column",
|
|
687
|
+
options
|
|
688
|
+
});
|
|
689
|
+
if (column && !colIsOnlyFilter) {
|
|
690
|
+
descriptors.push({
|
|
691
|
+
label: `Remove all filters`,
|
|
692
|
+
action: "remove-filters",
|
|
693
|
+
options
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return descriptors;
|
|
698
|
+
};
|
|
699
|
+
function buildSortMenuItems(options, { sort: { sortDefs } }) {
|
|
700
|
+
const { column } = options;
|
|
701
|
+
const menuItems = [];
|
|
702
|
+
if (column === void 0) {
|
|
703
|
+
return menuItems;
|
|
704
|
+
}
|
|
705
|
+
const hasSort = sortDefs.length > 0;
|
|
706
|
+
if (column.sorted === "A") {
|
|
707
|
+
menuItems.push({
|
|
708
|
+
label: "Reverse Sort (DSC)",
|
|
709
|
+
action: "sort-dsc",
|
|
710
|
+
options
|
|
711
|
+
});
|
|
712
|
+
} else if (column.sorted === "D") {
|
|
713
|
+
menuItems.push({
|
|
714
|
+
label: "Reverse Sort (ASC)",
|
|
715
|
+
action: "sort-asc",
|
|
716
|
+
options
|
|
717
|
+
});
|
|
718
|
+
} else if (typeof column.sorted === "number") {
|
|
719
|
+
if (column.sorted > 0) {
|
|
720
|
+
menuItems.push({
|
|
721
|
+
label: "Reverse Sort (DSC)",
|
|
722
|
+
action: "sort-add-dsc",
|
|
723
|
+
options
|
|
724
|
+
});
|
|
725
|
+
} else {
|
|
726
|
+
menuItems.push({
|
|
727
|
+
label: "Reverse Sort (ASC)",
|
|
728
|
+
action: "sort-add-asc",
|
|
729
|
+
options
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
if (hasSort && Math.abs(column.sorted) < sortDefs.length) {
|
|
733
|
+
menuItems.push({
|
|
734
|
+
label: "Remove from sort",
|
|
735
|
+
action: "sort-remove",
|
|
736
|
+
options
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
menuItems.push({
|
|
740
|
+
label: "New Sort",
|
|
741
|
+
children: [
|
|
742
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
743
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
744
|
+
]
|
|
745
|
+
});
|
|
746
|
+
} else if (hasSort) {
|
|
747
|
+
menuItems.push({
|
|
748
|
+
label: "Add to sort",
|
|
749
|
+
children: [
|
|
750
|
+
{ label: "Ascending", action: "sort-add-asc", options },
|
|
751
|
+
{ label: "Descending", action: "sort-add-dsc", options }
|
|
752
|
+
]
|
|
753
|
+
});
|
|
754
|
+
menuItems.push({
|
|
755
|
+
label: "New Sort",
|
|
756
|
+
children: [
|
|
757
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
758
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
759
|
+
]
|
|
760
|
+
});
|
|
761
|
+
} else {
|
|
762
|
+
menuItems.push({
|
|
763
|
+
label: "Sort",
|
|
764
|
+
children: [
|
|
765
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
766
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
767
|
+
]
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
return menuItems;
|
|
771
|
+
}
|
|
772
|
+
function buildAggregationMenuItems(options, dataSource) {
|
|
773
|
+
const { column } = options;
|
|
774
|
+
if (column === void 0 || dataSource.groupBy.length === 0) {
|
|
775
|
+
return [];
|
|
776
|
+
}
|
|
777
|
+
const { name, label = name } = column;
|
|
778
|
+
return [
|
|
779
|
+
{
|
|
780
|
+
label: `Aggregate ${label}`,
|
|
781
|
+
children: [
|
|
782
|
+
{ label: "Count", action: "agg-count", options },
|
|
783
|
+
{ label: "Distinct", action: "agg-distinct", options }
|
|
784
|
+
].concat(
|
|
785
|
+
(0, import_vuu_utils5.isNumericColumn)(column) ? [
|
|
786
|
+
{ label: "Sum", action: "agg-sum", options },
|
|
787
|
+
{ label: "Avg", action: "agg-avg", options },
|
|
788
|
+
{ label: "High", action: "agg-high", options },
|
|
789
|
+
{ label: "Low", action: "agg-low", options }
|
|
790
|
+
] : []
|
|
791
|
+
)
|
|
792
|
+
}
|
|
793
|
+
];
|
|
794
|
+
}
|
|
795
|
+
var pinColumn = (options, pinLocation) => ({
|
|
796
|
+
label: `Pin ${pinLocation}`,
|
|
797
|
+
action: `column-pin-${pinLocation}`,
|
|
798
|
+
options
|
|
799
|
+
});
|
|
800
|
+
var pinLeft = (options) => pinColumn(options, "left");
|
|
801
|
+
var pinFloating = (options) => pinColumn(options, "floating");
|
|
802
|
+
var pinRight = (options) => pinColumn(options, "right");
|
|
803
|
+
function buildColumnDisplayMenuItems(options) {
|
|
804
|
+
const { column } = options;
|
|
805
|
+
if (column === void 0) {
|
|
806
|
+
return [];
|
|
807
|
+
}
|
|
808
|
+
const { pin } = column;
|
|
809
|
+
const menuItems = [
|
|
810
|
+
{
|
|
811
|
+
label: `Hide column`,
|
|
812
|
+
action: "column-hide",
|
|
813
|
+
options
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
label: `Remove column`,
|
|
817
|
+
action: "column-remove",
|
|
818
|
+
options
|
|
819
|
+
}
|
|
820
|
+
];
|
|
821
|
+
if (pin === void 0) {
|
|
822
|
+
menuItems.push({
|
|
823
|
+
label: `Pin column`,
|
|
824
|
+
children: [pinLeft(options), pinFloating(options), pinRight(options)]
|
|
825
|
+
});
|
|
826
|
+
} else if (pin === "left") {
|
|
827
|
+
menuItems.push(
|
|
828
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
829
|
+
{
|
|
830
|
+
label: `Pin column`,
|
|
831
|
+
children: [pinFloating(options), pinRight(options)]
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
} else if (pin === "right") {
|
|
835
|
+
menuItems.push(
|
|
836
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
837
|
+
{
|
|
838
|
+
label: `Pin column`,
|
|
839
|
+
children: [pinLeft(options), pinFloating(options)]
|
|
840
|
+
}
|
|
841
|
+
);
|
|
842
|
+
} else if (pin === "floating") {
|
|
843
|
+
menuItems.push(
|
|
844
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
845
|
+
{
|
|
846
|
+
label: `Pin column`,
|
|
847
|
+
children: [pinLeft(options), pinRight(options)]
|
|
848
|
+
}
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
return menuItems;
|
|
852
|
+
}
|
|
853
|
+
function buildGroupMenuItems(options, { groupBy }) {
|
|
854
|
+
const { column } = options;
|
|
855
|
+
const menuItems = [];
|
|
856
|
+
if (column === void 0) {
|
|
857
|
+
return menuItems;
|
|
858
|
+
}
|
|
859
|
+
const { name, label = name } = column;
|
|
860
|
+
if (groupBy.length === 0) {
|
|
861
|
+
menuItems.push({
|
|
862
|
+
label: `Group by ${label}`,
|
|
863
|
+
action: "group",
|
|
864
|
+
options
|
|
865
|
+
});
|
|
866
|
+
} else {
|
|
867
|
+
menuItems.push({
|
|
868
|
+
label: `Add ${label} to group by`,
|
|
869
|
+
action: "group-add",
|
|
870
|
+
options
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
return menuItems;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// src/context-menu/useHandleTableContextMenu.ts
|
|
877
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
878
|
+
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
879
|
+
var removeFilterColumn = (dataSourceFilter, column) => {
|
|
880
|
+
if (dataSourceFilter.filterStruct && column) {
|
|
881
|
+
const [filterStruct, filter] = (0, import_vuu_utils6.removeColumnFromFilter)(
|
|
882
|
+
column,
|
|
883
|
+
dataSourceFilter.filterStruct
|
|
884
|
+
);
|
|
885
|
+
return {
|
|
886
|
+
filter,
|
|
887
|
+
filterStruct
|
|
888
|
+
};
|
|
889
|
+
} else {
|
|
890
|
+
return dataSourceFilter;
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils7.AggregationType;
|
|
894
|
+
var useHandleTableContextMenu = ({
|
|
895
|
+
dataSource,
|
|
896
|
+
onPersistentColumnOperation
|
|
897
|
+
}) => {
|
|
898
|
+
const handleContextMenuAction = (action) => {
|
|
899
|
+
const gridOptions = action.options;
|
|
900
|
+
if (gridOptions.column && dataSource) {
|
|
901
|
+
const { column } = gridOptions;
|
|
902
|
+
switch (action.menuId) {
|
|
903
|
+
case "sort-asc":
|
|
904
|
+
return dataSource.sort = (0, import_vuu_utils7.setSortColumn)(dataSource.sort, column, "A"), true;
|
|
905
|
+
case "sort-dsc":
|
|
906
|
+
return dataSource.sort = (0, import_vuu_utils7.setSortColumn)(dataSource.sort, column, "D"), true;
|
|
907
|
+
case "sort-add-asc":
|
|
908
|
+
return dataSource.sort = (0, import_vuu_utils7.addSortColumn)(dataSource.sort, column, "A"), true;
|
|
909
|
+
case "sort-add-dsc":
|
|
910
|
+
return dataSource.sort = (0, import_vuu_utils7.addSortColumn)(dataSource.sort, column, "D"), true;
|
|
911
|
+
case "group":
|
|
912
|
+
return dataSource.groupBy = (0, import_vuu_utils7.addGroupColumn)(dataSource.groupBy, column), true;
|
|
913
|
+
case "group-add":
|
|
914
|
+
return dataSource.groupBy = (0, import_vuu_utils7.addGroupColumn)(dataSource.groupBy, column), true;
|
|
915
|
+
case "column-hide":
|
|
916
|
+
return onPersistentColumnOperation({ type: "hideColumns", columns: [column] }), true;
|
|
917
|
+
case "column-remove":
|
|
918
|
+
return dataSource.columns = dataSource.columns.filter((name) => name !== column.name), true;
|
|
919
|
+
case "filter-remove-column":
|
|
920
|
+
return dataSource.filter = removeFilterColumn(dataSource.filter, column), true;
|
|
921
|
+
case "remove-filters":
|
|
922
|
+
return dataSource.filter = { filter: "" }, true;
|
|
923
|
+
case "agg-avg":
|
|
924
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, Average), true;
|
|
925
|
+
case "agg-high":
|
|
926
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, High), true;
|
|
927
|
+
case "agg-low":
|
|
928
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, Low), true;
|
|
929
|
+
case "agg-count":
|
|
930
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, Count), true;
|
|
931
|
+
case "agg-distinct":
|
|
932
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, Distinct), true;
|
|
933
|
+
case "agg-sum":
|
|
934
|
+
return dataSource.aggregations = (0, import_vuu_utils7.setAggregations)(dataSource.aggregations, column, Sum), true;
|
|
935
|
+
case "column-pin-floating":
|
|
936
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "floating" }), true;
|
|
937
|
+
case "column-pin-left":
|
|
938
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "left" }), true;
|
|
939
|
+
case "column-pin-right":
|
|
940
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "right" }), true;
|
|
941
|
+
case "column-unpin":
|
|
942
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: void 0 }), true;
|
|
943
|
+
case "column-settings":
|
|
944
|
+
return onPersistentColumnOperation({ type: "columnSettings", column }), true;
|
|
945
|
+
case "table-settings":
|
|
946
|
+
return onPersistentColumnOperation({ type: "tableSettings" }), true;
|
|
947
|
+
default:
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return false;
|
|
951
|
+
};
|
|
952
|
+
return handleContextMenuAction;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
// src/table-config.ts
|
|
956
|
+
var updateTableConfig = (config, action) => {
|
|
957
|
+
switch (action.type) {
|
|
958
|
+
case "col-size":
|
|
959
|
+
return {
|
|
960
|
+
...config,
|
|
961
|
+
columns: config.columns.map(
|
|
962
|
+
(col) => col.name === action.column.name ? { ...col, width: action.width } : col
|
|
963
|
+
)
|
|
964
|
+
};
|
|
965
|
+
case "column-prop":
|
|
966
|
+
return {
|
|
967
|
+
...config,
|
|
968
|
+
columns: config.columns.map(
|
|
969
|
+
(col) => col.name === action.column.name ? { ...col, [action.property]: action.value } : col
|
|
970
|
+
)
|
|
971
|
+
};
|
|
972
|
+
default:
|
|
973
|
+
return config;
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/useCellEditing.ts
|
|
978
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
979
|
+
var import_react13 = require("react");
|
|
980
|
+
|
|
981
|
+
// src/table-dom-utils.ts
|
|
982
|
+
var headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell:nth-child(${colIdx})`;
|
|
983
|
+
var dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
984
|
+
var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
985
|
+
var _a;
|
|
986
|
+
const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
|
|
987
|
+
const cell = (_a = containerRef.current) == null ? void 0 : _a.querySelector(
|
|
988
|
+
cssQuery
|
|
989
|
+
);
|
|
990
|
+
if (cellIsEditable(cell)) {
|
|
991
|
+
const focusableContent = cell.querySelector("button");
|
|
992
|
+
return focusableContent || cell;
|
|
993
|
+
} else {
|
|
994
|
+
return cell;
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
var cellIsEditable = (cell) => cell.classList.contains("vuuTableCell-editable");
|
|
998
|
+
var cellIsTextInput = (cell) => cell.querySelector(".vuuTableInputCell") !== null;
|
|
999
|
+
function getRowIndex(rowEl) {
|
|
1000
|
+
if (rowEl) {
|
|
1001
|
+
const idx = rowEl.ariaRowIndex;
|
|
1002
|
+
if (idx !== null) {
|
|
1003
|
+
return parseInt(idx, 10);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return -1;
|
|
1007
|
+
}
|
|
1008
|
+
var closestRow = (el) => el.closest('[role="row"]');
|
|
1009
|
+
var closestRowIndex = (el) => getRowIndex(closestRow(el));
|
|
1010
|
+
|
|
1011
|
+
// src/useCellEditing.ts
|
|
1012
|
+
var useCellEditing = ({ navigate }) => {
|
|
1013
|
+
const commitHandler = (0, import_react13.useCallback)(() => {
|
|
1014
|
+
navigate();
|
|
1015
|
+
}, [navigate]);
|
|
1016
|
+
const editInput = (0, import_react13.useCallback)(
|
|
1017
|
+
(evt) => {
|
|
1018
|
+
const cellEl = evt.target;
|
|
1019
|
+
const input = cellEl.matches("input") ? cellEl : cellEl.querySelector("input");
|
|
1020
|
+
if (input) {
|
|
1021
|
+
input.focus();
|
|
1022
|
+
input.select();
|
|
1023
|
+
}
|
|
1024
|
+
},
|
|
1025
|
+
[]
|
|
1026
|
+
);
|
|
1027
|
+
const focusInput = (0, import_react13.useCallback)(
|
|
1028
|
+
(evt) => {
|
|
1029
|
+
const cellEl = evt.target;
|
|
1030
|
+
const input = cellEl.querySelector("input");
|
|
1031
|
+
if (input) {
|
|
1032
|
+
input.focus();
|
|
1033
|
+
input.select();
|
|
1034
|
+
}
|
|
1035
|
+
},
|
|
1036
|
+
[]
|
|
1037
|
+
);
|
|
1038
|
+
const handleKeyDown = (0, import_react13.useCallback)(
|
|
1039
|
+
(e) => {
|
|
1040
|
+
const el = e.target;
|
|
1041
|
+
if (cellIsTextInput(el)) {
|
|
1042
|
+
if ((0, import_vuu_utils8.isCharacterKey)(e.key)) {
|
|
1043
|
+
editInput(e);
|
|
1044
|
+
} else if (e.key === "Enter") {
|
|
1045
|
+
focusInput(e);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
[editInput, focusInput]
|
|
1050
|
+
);
|
|
1051
|
+
const handleDoubleClick = (0, import_react13.useCallback)(
|
|
1052
|
+
(e) => {
|
|
1053
|
+
const el = e.target;
|
|
1054
|
+
if (el.matches("input") || el.querySelector("input")) {
|
|
1055
|
+
editInput(e);
|
|
1056
|
+
e.stopPropagation();
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
1059
|
+
[editInput]
|
|
1060
|
+
);
|
|
1061
|
+
const handleBlur = (0, import_react13.useCallback)(
|
|
1062
|
+
(e) => {
|
|
1063
|
+
const el = e.target;
|
|
1064
|
+
el.removeEventListener("vuu-commit", commitHandler, true);
|
|
1065
|
+
},
|
|
1066
|
+
[commitHandler]
|
|
1067
|
+
);
|
|
1068
|
+
const handleFocus = (0, import_react13.useCallback)(
|
|
1069
|
+
(e) => {
|
|
1070
|
+
const el = e.target;
|
|
1071
|
+
el.addEventListener("vuu-commit", commitHandler, true);
|
|
1072
|
+
},
|
|
1073
|
+
[commitHandler]
|
|
1074
|
+
);
|
|
1075
|
+
return {
|
|
1076
|
+
onBlur: handleBlur,
|
|
1077
|
+
onDoubleClick: handleDoubleClick,
|
|
1078
|
+
onFocus: handleFocus,
|
|
1079
|
+
onKeyDown: handleKeyDown
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
// src/useDataSource.ts
|
|
1084
|
+
var import_vuu_data = require("@vuu-ui/vuu-data");
|
|
1085
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
1086
|
+
var import_react14 = require("react");
|
|
1087
|
+
|
|
1088
|
+
// src/moving-window.ts
|
|
1089
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
1090
|
+
var { SELECTED: SELECTED2 } = import_vuu_utils9.metadataKeys;
|
|
1091
|
+
var MovingWindow = class {
|
|
1092
|
+
constructor({ from, to }) {
|
|
1093
|
+
this.rowCount = 0;
|
|
1094
|
+
this.setRowCount = (rowCount) => {
|
|
1095
|
+
if (rowCount < this.data.length) {
|
|
1096
|
+
this.data.length = rowCount;
|
|
1097
|
+
}
|
|
1098
|
+
this.rowCount = rowCount;
|
|
1099
|
+
};
|
|
1100
|
+
this.range = new import_vuu_utils9.WindowRange(from, to);
|
|
1101
|
+
this.data = new Array(Math.max(0, to - from));
|
|
1102
|
+
this.rowCount = 0;
|
|
1103
|
+
}
|
|
1104
|
+
add(data) {
|
|
1105
|
+
const [index] = data;
|
|
1106
|
+
if (this.isWithinRange(index)) {
|
|
1107
|
+
const internalIndex = index - this.range.from;
|
|
1108
|
+
this.data[internalIndex] = data;
|
|
1109
|
+
if (data[SELECTED2]) {
|
|
1110
|
+
const previousRow = this.data[internalIndex - 1];
|
|
1111
|
+
if ((0, import_vuu_utils9.isRowSelectedLast)(previousRow)) {
|
|
1112
|
+
this.data[internalIndex - 1] = previousRow.slice();
|
|
1113
|
+
this.data[internalIndex - 1][SELECTED2] -= 4;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
getAtIndex(index) {
|
|
1119
|
+
return this.range.isWithin(index) && this.data[index - this.range.from] != null ? this.data[index - this.range.from] : void 0;
|
|
1120
|
+
}
|
|
1121
|
+
isWithinRange(index) {
|
|
1122
|
+
return this.range.isWithin(index);
|
|
1123
|
+
}
|
|
1124
|
+
setRange({ from, to }) {
|
|
1125
|
+
if (from !== this.range.from || to !== this.range.to) {
|
|
1126
|
+
const [overlapFrom, overlapTo] = this.range.overlap(from, to);
|
|
1127
|
+
const newData = new Array(Math.max(0, to - from));
|
|
1128
|
+
for (let i = overlapFrom; i < overlapTo; i++) {
|
|
1129
|
+
const data = this.getAtIndex(i);
|
|
1130
|
+
if (data) {
|
|
1131
|
+
const index = i - from;
|
|
1132
|
+
newData[index] = data;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
this.data = newData;
|
|
1136
|
+
this.range.from = from;
|
|
1137
|
+
this.range.to = to;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
getSelectedRows() {
|
|
1141
|
+
return this.data.filter((row) => row[SELECTED2] !== 0);
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
// src/useDataSource.ts
|
|
1146
|
+
var useDataSource = ({
|
|
1147
|
+
dataSource,
|
|
1148
|
+
onFeatureInvocation,
|
|
1149
|
+
onSizeChange,
|
|
1150
|
+
onSubscribed,
|
|
1151
|
+
range = import_vuu_utils10.NULL_RANGE,
|
|
1152
|
+
renderBufferSize = 0
|
|
1153
|
+
}) => {
|
|
1154
|
+
const [, forceUpdate] = (0, import_react14.useState)(null);
|
|
1155
|
+
const data = (0, import_react14.useRef)([]);
|
|
1156
|
+
const isMounted = (0, import_react14.useRef)(true);
|
|
1157
|
+
const hasUpdated = (0, import_react14.useRef)(false);
|
|
1158
|
+
const rangeRef = (0, import_react14.useRef)(import_vuu_utils10.NULL_RANGE);
|
|
1159
|
+
const dataWindow = (0, import_react14.useMemo)(
|
|
1160
|
+
() => new MovingWindow((0, import_vuu_utils10.getFullRange)(range, renderBufferSize)),
|
|
1161
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1162
|
+
[]
|
|
1163
|
+
);
|
|
1164
|
+
const setData = (0, import_react14.useCallback)(
|
|
1165
|
+
(updates) => {
|
|
1166
|
+
for (const row of updates) {
|
|
1167
|
+
dataWindow.add(row);
|
|
1168
|
+
}
|
|
1169
|
+
data.current = dataWindow.data;
|
|
1170
|
+
if (isMounted.current) {
|
|
1171
|
+
forceUpdate({});
|
|
1172
|
+
} else {
|
|
1173
|
+
console.log(`ignore update as we're not mounted`);
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
[dataWindow]
|
|
1177
|
+
);
|
|
1178
|
+
const datasourceMessageHandler = (0, import_react14.useCallback)(
|
|
1179
|
+
(message) => {
|
|
1180
|
+
if (message.type === "subscribed") {
|
|
1181
|
+
onSubscribed == null ? void 0 : onSubscribed(message);
|
|
1182
|
+
} else if (message.type === "viewport-update") {
|
|
1183
|
+
if (typeof message.size === "number") {
|
|
1184
|
+
onSizeChange == null ? void 0 : onSizeChange(message.size);
|
|
1185
|
+
dataWindow.setRowCount(message.size);
|
|
1186
|
+
}
|
|
1187
|
+
if (message.rows) {
|
|
1188
|
+
setData(message.rows);
|
|
1189
|
+
} else if (typeof message.size === "number") {
|
|
1190
|
+
data.current = dataWindow.data;
|
|
1191
|
+
hasUpdated.current = true;
|
|
1192
|
+
}
|
|
1193
|
+
} else if ((0, import_vuu_data.isVuuFeatureInvocation)(message)) {
|
|
1194
|
+
onFeatureInvocation == null ? void 0 : onFeatureInvocation(message);
|
|
1195
|
+
} else {
|
|
1196
|
+
console.log(`useDataSource unexpected message ${message.type}`);
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
[dataWindow, onFeatureInvocation, onSizeChange, onSubscribed, setData]
|
|
1200
|
+
);
|
|
1201
|
+
const getSelectedRows = (0, import_react14.useCallback)(() => {
|
|
1202
|
+
return dataWindow.getSelectedRows();
|
|
1203
|
+
}, [dataWindow]);
|
|
1204
|
+
(0, import_react14.useEffect)(() => {
|
|
1205
|
+
var _a;
|
|
1206
|
+
isMounted.current = true;
|
|
1207
|
+
(_a = dataSource.resume) == null ? void 0 : _a.call(dataSource);
|
|
1208
|
+
return () => {
|
|
1209
|
+
var _a2;
|
|
1210
|
+
isMounted.current = false;
|
|
1211
|
+
(_a2 = dataSource.suspend) == null ? void 0 : _a2.call(dataSource);
|
|
1212
|
+
};
|
|
1213
|
+
}, [dataSource]);
|
|
1214
|
+
(0, import_react14.useEffect)(() => {
|
|
1215
|
+
var _a;
|
|
1216
|
+
if (dataSource.status === "disabled") {
|
|
1217
|
+
(_a = dataSource.enable) == null ? void 0 : _a.call(dataSource, datasourceMessageHandler);
|
|
1218
|
+
} else {
|
|
1219
|
+
dataSource == null ? void 0 : dataSource.subscribe(
|
|
1220
|
+
{ range: (0, import_vuu_utils10.getFullRange)(range, renderBufferSize) },
|
|
1221
|
+
datasourceMessageHandler
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
1225
|
+
const setRange = (0, import_react14.useCallback)(
|
|
1226
|
+
(range2) => {
|
|
1227
|
+
const fullRange = (0, import_vuu_utils10.getFullRange)(range2, renderBufferSize);
|
|
1228
|
+
dataWindow.setRange(fullRange);
|
|
1229
|
+
dataSource.range = rangeRef.current = fullRange;
|
|
1230
|
+
dataSource.emit("range", range2);
|
|
1231
|
+
},
|
|
1232
|
+
[dataSource, dataWindow, renderBufferSize]
|
|
1233
|
+
);
|
|
1234
|
+
return {
|
|
1235
|
+
data: data.current,
|
|
1236
|
+
dataRef: data,
|
|
1237
|
+
getSelectedRows,
|
|
1238
|
+
range: rangeRef.current,
|
|
1239
|
+
setRange
|
|
1240
|
+
};
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
// src/useInitialValue.ts
|
|
1244
|
+
var import_react15 = require("react");
|
|
1245
|
+
var useInitialValue = (value) => {
|
|
1246
|
+
const ref = (0, import_react15.useRef)(value);
|
|
1247
|
+
return (0, import_react15.useMemo)(() => ref.current, []);
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
// src/useKeyboardNavigation.ts
|
|
1251
|
+
var import_core = require("@salt-ds/core");
|
|
1252
|
+
var import_react16 = require("react");
|
|
1253
|
+
var rowNavigationKeys = /* @__PURE__ */ new Set([
|
|
1254
|
+
"Home",
|
|
1255
|
+
"End",
|
|
1256
|
+
"PageUp",
|
|
1257
|
+
"PageDown",
|
|
1258
|
+
"ArrowDown",
|
|
1259
|
+
"ArrowUp"
|
|
1260
|
+
]);
|
|
1261
|
+
var cellNavigationKeys = new Set(rowNavigationKeys);
|
|
1262
|
+
cellNavigationKeys.add("ArrowLeft");
|
|
1263
|
+
cellNavigationKeys.add("ArrowRight");
|
|
1264
|
+
var isNavigationKey = (key, navigationStyle) => {
|
|
1265
|
+
switch (navigationStyle) {
|
|
1266
|
+
case "cell":
|
|
1267
|
+
return cellNavigationKeys.has(key);
|
|
1268
|
+
case "row":
|
|
1269
|
+
return rowNavigationKeys.has(key);
|
|
1270
|
+
default:
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
var PageKeys = ["Home", "End", "PageUp", "PageDown"];
|
|
1275
|
+
var isPagingKey = (key) => PageKeys.includes(key);
|
|
1276
|
+
var NULL_CELL_POS = [-1, -1];
|
|
1277
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1278
|
+
var howFarIsRowOutsideViewport = (rowEl, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1279
|
+
if (contentContainer) {
|
|
1280
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1281
|
+
const row = rowEl.getBoundingClientRect();
|
|
1282
|
+
if (row) {
|
|
1283
|
+
if (row.bottom > viewport.bottom) {
|
|
1284
|
+
return ["down", row.bottom - viewport.bottom];
|
|
1285
|
+
} else if (row.top < viewport.top) {
|
|
1286
|
+
return ["up", row.top - viewport.top];
|
|
1287
|
+
} else {
|
|
1288
|
+
return NO_SCROLL_NECESSARY;
|
|
1289
|
+
}
|
|
1290
|
+
} else {
|
|
1291
|
+
throw Error("Whats going on, row not found");
|
|
1292
|
+
}
|
|
1293
|
+
} else {
|
|
1294
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
var howFarIsCellOutsideViewport = (cellEl) => {
|
|
1298
|
+
var _a;
|
|
1299
|
+
const contentContainer = cellEl.closest(".vuuTable-contentContainer");
|
|
1300
|
+
if (contentContainer) {
|
|
1301
|
+
const rowEl = cellEl.closest(".vuuTableRow");
|
|
1302
|
+
if (rowEl) {
|
|
1303
|
+
const result = howFarIsRowOutsideViewport(rowEl, contentContainer);
|
|
1304
|
+
if (result !== NO_SCROLL_NECESSARY) {
|
|
1305
|
+
return result;
|
|
1306
|
+
}
|
|
1307
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1308
|
+
const cell = (_a = cellEl.closest(".vuuTableCell")) == null ? void 0 : _a.getBoundingClientRect();
|
|
1309
|
+
if (cell) {
|
|
1310
|
+
if (cell.right > viewport.right) {
|
|
1311
|
+
return ["right", cell.right + 6 - viewport.right];
|
|
1312
|
+
} else if (cell.left < viewport.left) {
|
|
1313
|
+
return ["left", cell.left - viewport.left];
|
|
1314
|
+
}
|
|
1315
|
+
} else {
|
|
1316
|
+
throw Error("Whats going on, cell not found");
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
return NO_SCROLL_NECESSARY;
|
|
1321
|
+
};
|
|
1322
|
+
function nextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
|
|
1323
|
+
if (key === "ArrowUp") {
|
|
1324
|
+
if (rowIdx > -1) {
|
|
1325
|
+
return [rowIdx - 1, colIdx];
|
|
1326
|
+
} else {
|
|
1327
|
+
return [rowIdx, colIdx];
|
|
1328
|
+
}
|
|
1329
|
+
} else if (key === "ArrowDown") {
|
|
1330
|
+
if (rowIdx === -1) {
|
|
1331
|
+
return [0, colIdx];
|
|
1332
|
+
} else if (rowIdx === rowCount - 1) {
|
|
1333
|
+
return [rowIdx, colIdx];
|
|
1334
|
+
} else {
|
|
1335
|
+
return [rowIdx + 1, colIdx];
|
|
1336
|
+
}
|
|
1337
|
+
} else if (key === "ArrowRight") {
|
|
1338
|
+
if (colIdx < columnCount) {
|
|
1339
|
+
return [rowIdx, colIdx + 1];
|
|
1340
|
+
} else {
|
|
1341
|
+
return [rowIdx, colIdx];
|
|
1342
|
+
}
|
|
1343
|
+
} else if (key === "ArrowLeft") {
|
|
1344
|
+
if (colIdx > 1) {
|
|
1345
|
+
return [rowIdx, colIdx - 1];
|
|
1346
|
+
} else {
|
|
1347
|
+
return [rowIdx, colIdx];
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return [rowIdx, colIdx];
|
|
1351
|
+
}
|
|
1352
|
+
var useKeyboardNavigation = ({
|
|
1353
|
+
columnCount = 0,
|
|
1354
|
+
containerRef,
|
|
1355
|
+
disableFocus = false,
|
|
1356
|
+
defaultHighlightedIndex,
|
|
1357
|
+
disableHighlightOnFocus,
|
|
1358
|
+
highlightedIndex: highlightedIndexProp,
|
|
1359
|
+
navigationStyle,
|
|
1360
|
+
requestScroll,
|
|
1361
|
+
onHighlight,
|
|
1362
|
+
rowCount = 0,
|
|
1363
|
+
viewportRowCount
|
|
1364
|
+
}) => {
|
|
1365
|
+
var _a;
|
|
1366
|
+
const focusedCellPos = (0, import_react16.useRef)([-1, -1]);
|
|
1367
|
+
const focusableCell = (0, import_react16.useRef)();
|
|
1368
|
+
const activeCellPos = (0, import_react16.useRef)([-1, 0]);
|
|
1369
|
+
const highlightedIndexRef = (0, import_react16.useRef)();
|
|
1370
|
+
const [highlightedIndex, setHighlightedIdx] = (0, import_core.useControlled)({
|
|
1371
|
+
controlled: highlightedIndexProp,
|
|
1372
|
+
default: defaultHighlightedIndex,
|
|
1373
|
+
name: "UseKeyboardNavigation"
|
|
1374
|
+
});
|
|
1375
|
+
highlightedIndexRef.current = highlightedIndex;
|
|
1376
|
+
const setHighlightedIndex = (0, import_react16.useCallback)(
|
|
1377
|
+
(idx, fromKeyboard = false) => {
|
|
1378
|
+
onHighlight == null ? void 0 : onHighlight(idx);
|
|
1379
|
+
setHighlightedIdx(idx);
|
|
1380
|
+
if (fromKeyboard) {
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
[onHighlight, setHighlightedIdx]
|
|
1384
|
+
);
|
|
1385
|
+
const getFocusedCell = (element) => element == null ? void 0 : element.closest(
|
|
1386
|
+
"[role='columnHeader'],[role='cell']"
|
|
1387
|
+
);
|
|
1388
|
+
const getTableCellPos = (tableCell) => {
|
|
1389
|
+
var _a2, _b;
|
|
1390
|
+
if (tableCell.role === "columnHeader") {
|
|
1391
|
+
const colIdx = parseInt((_a2 = tableCell.dataset.idx) != null ? _a2 : "-1", 10);
|
|
1392
|
+
return [-1, colIdx];
|
|
1393
|
+
} else {
|
|
1394
|
+
const focusedRow = tableCell.closest("[role='row']");
|
|
1395
|
+
if (focusedRow) {
|
|
1396
|
+
const rowIdx = parseInt((_b = focusedRow.ariaRowIndex) != null ? _b : "-1", 10);
|
|
1397
|
+
const colIdx = Array.from(focusedRow.childNodes).indexOf(tableCell);
|
|
1398
|
+
return [rowIdx, colIdx];
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return NULL_CELL_POS;
|
|
1402
|
+
};
|
|
1403
|
+
const focusCell = (0, import_react16.useCallback)(
|
|
1404
|
+
(cellPos) => {
|
|
1405
|
+
var _a2;
|
|
1406
|
+
if (containerRef.current) {
|
|
1407
|
+
const activeCell = getTableCell(containerRef, cellPos);
|
|
1408
|
+
if (activeCell) {
|
|
1409
|
+
if (activeCell !== focusableCell.current) {
|
|
1410
|
+
(_a2 = focusableCell.current) == null ? void 0 : _a2.removeAttribute("tabindex");
|
|
1411
|
+
focusableCell.current = activeCell;
|
|
1412
|
+
activeCell.setAttribute("tabindex", "0");
|
|
1413
|
+
}
|
|
1414
|
+
const [direction, distance] = howFarIsCellOutsideViewport(activeCell);
|
|
1415
|
+
if (direction && distance) {
|
|
1416
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
1417
|
+
}
|
|
1418
|
+
console.log(`activeCell focus`);
|
|
1419
|
+
activeCell.focus({ preventScroll: true });
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
},
|
|
1423
|
+
// TODO we recreate this function whenever viewportRange changes, which will
|
|
1424
|
+
// be often whilst scrolling - store range in a a ref ?
|
|
1425
|
+
[containerRef, requestScroll]
|
|
1426
|
+
);
|
|
1427
|
+
const setActiveCell = (0, import_react16.useCallback)(
|
|
1428
|
+
(rowIdx, colIdx, fromKeyboard = false) => {
|
|
1429
|
+
const pos = [rowIdx, colIdx];
|
|
1430
|
+
activeCellPos.current = pos;
|
|
1431
|
+
if (navigationStyle === "row") {
|
|
1432
|
+
setHighlightedIdx(rowIdx);
|
|
1433
|
+
} else {
|
|
1434
|
+
focusCell(pos);
|
|
1435
|
+
}
|
|
1436
|
+
if (fromKeyboard) {
|
|
1437
|
+
focusedCellPos.current = pos;
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
[focusCell, navigationStyle, setHighlightedIdx]
|
|
1441
|
+
);
|
|
1442
|
+
const nextPageItemIdx = (0, import_react16.useCallback)(
|
|
1443
|
+
(key, [rowIdx, colIdx]) => new Promise((resolve) => {
|
|
1444
|
+
let newRowIdx = rowIdx;
|
|
1445
|
+
switch (key) {
|
|
1446
|
+
case "PageDown":
|
|
1447
|
+
newRowIdx = Math.min(rowCount - 1, rowIdx + viewportRowCount);
|
|
1448
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "down" });
|
|
1449
|
+
break;
|
|
1450
|
+
case "PageUp":
|
|
1451
|
+
newRowIdx = Math.max(0, rowIdx - viewportRowCount);
|
|
1452
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "up" });
|
|
1453
|
+
break;
|
|
1454
|
+
case "Home":
|
|
1455
|
+
newRowIdx = 0;
|
|
1456
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "home" });
|
|
1457
|
+
break;
|
|
1458
|
+
case "End":
|
|
1459
|
+
newRowIdx = rowCount - 1;
|
|
1460
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "end" });
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
setTimeout(() => {
|
|
1464
|
+
resolve([newRowIdx, colIdx]);
|
|
1465
|
+
}, 90);
|
|
1466
|
+
}),
|
|
1467
|
+
[requestScroll, rowCount, viewportRowCount]
|
|
1468
|
+
);
|
|
1469
|
+
const handleFocus = (0, import_react16.useCallback)(() => {
|
|
1470
|
+
var _a2;
|
|
1471
|
+
if (disableHighlightOnFocus !== true) {
|
|
1472
|
+
if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
|
|
1473
|
+
const focusedCell = getFocusedCell(document.activeElement);
|
|
1474
|
+
if (focusedCell) {
|
|
1475
|
+
focusedCellPos.current = getTableCellPos(focusedCell);
|
|
1476
|
+
if (navigationStyle === "row") {
|
|
1477
|
+
setHighlightedIdx(focusedCellPos.current[0]);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
}, [
|
|
1483
|
+
disableHighlightOnFocus,
|
|
1484
|
+
containerRef,
|
|
1485
|
+
navigationStyle,
|
|
1486
|
+
setHighlightedIdx
|
|
1487
|
+
]);
|
|
1488
|
+
const navigateChildItems = (0, import_react16.useCallback)(
|
|
1489
|
+
async (key) => {
|
|
1490
|
+
const [nextRowIdx, nextColIdx] = isPagingKey(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
|
|
1491
|
+
const [rowIdx, colIdx] = activeCellPos.current;
|
|
1492
|
+
if (nextRowIdx !== rowIdx || nextColIdx !== colIdx) {
|
|
1493
|
+
setActiveCell(nextRowIdx, nextColIdx, true);
|
|
1494
|
+
}
|
|
1495
|
+
},
|
|
1496
|
+
[columnCount, nextPageItemIdx, rowCount, setActiveCell]
|
|
1497
|
+
);
|
|
1498
|
+
const scrollRowIntoViewIfNecessary = (0, import_react16.useCallback)(
|
|
1499
|
+
(rowIndex) => {
|
|
1500
|
+
const { current: container } = containerRef;
|
|
1501
|
+
const activeRow = container == null ? void 0 : container.querySelector(
|
|
1502
|
+
`[aria-rowindex="${rowIndex}"]`
|
|
1503
|
+
);
|
|
1504
|
+
if (activeRow) {
|
|
1505
|
+
const [direction, distance] = howFarIsRowOutsideViewport(activeRow);
|
|
1506
|
+
if (direction && distance) {
|
|
1507
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
[containerRef, requestScroll]
|
|
1512
|
+
);
|
|
1513
|
+
const moveHighlightedRow = (0, import_react16.useCallback)(
|
|
1514
|
+
async (key) => {
|
|
1515
|
+
const { current: highlighted } = highlightedIndexRef;
|
|
1516
|
+
const [nextRowIdx] = isPagingKey(key) ? await nextPageItemIdx(key, [highlighted != null ? highlighted : -1, 0]) : nextCellPos(key, [highlighted != null ? highlighted : -1, 0], columnCount, rowCount);
|
|
1517
|
+
if (nextRowIdx !== highlighted) {
|
|
1518
|
+
setHighlightedIndex(nextRowIdx);
|
|
1519
|
+
scrollRowIntoViewIfNecessary(nextRowIdx);
|
|
1520
|
+
}
|
|
1521
|
+
},
|
|
1522
|
+
[
|
|
1523
|
+
columnCount,
|
|
1524
|
+
nextPageItemIdx,
|
|
1525
|
+
rowCount,
|
|
1526
|
+
scrollRowIntoViewIfNecessary,
|
|
1527
|
+
setHighlightedIndex
|
|
1528
|
+
]
|
|
1529
|
+
);
|
|
1530
|
+
(0, import_react16.useEffect)(() => {
|
|
1531
|
+
if (highlightedIndexProp !== void 0 && highlightedIndexProp !== -1) {
|
|
1532
|
+
scrollRowIntoViewIfNecessary(highlightedIndexProp);
|
|
1533
|
+
}
|
|
1534
|
+
}, [highlightedIndexProp, scrollRowIntoViewIfNecessary]);
|
|
1535
|
+
const handleKeyDown = (0, import_react16.useCallback)(
|
|
1536
|
+
(e) => {
|
|
1537
|
+
if (rowCount > 0 && isNavigationKey(e.key, navigationStyle)) {
|
|
1538
|
+
e.preventDefault();
|
|
1539
|
+
e.stopPropagation();
|
|
1540
|
+
if (navigationStyle === "row") {
|
|
1541
|
+
moveHighlightedRow(e.key);
|
|
1542
|
+
} else {
|
|
1543
|
+
void navigateChildItems(e.key);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
[rowCount, navigationStyle, moveHighlightedRow, navigateChildItems]
|
|
1548
|
+
);
|
|
1549
|
+
const handleClick = (0, import_react16.useCallback)(
|
|
1550
|
+
// Might not be a cell e.g the Settings button
|
|
1551
|
+
(evt) => {
|
|
1552
|
+
const target = evt.target;
|
|
1553
|
+
const focusedCell = getFocusedCell(target);
|
|
1554
|
+
if (focusedCell) {
|
|
1555
|
+
const [rowIdx, colIdx] = getTableCellPos(focusedCell);
|
|
1556
|
+
setActiveCell(rowIdx, colIdx);
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
[setActiveCell]
|
|
1560
|
+
);
|
|
1561
|
+
const handleMouseLeave = (0, import_react16.useCallback)(() => {
|
|
1562
|
+
setHighlightedIndex(-1);
|
|
1563
|
+
}, [setHighlightedIndex]);
|
|
1564
|
+
const handleMouseMove = (0, import_react16.useCallback)(
|
|
1565
|
+
(evt) => {
|
|
1566
|
+
const idx = closestRowIndex(evt.target);
|
|
1567
|
+
if (idx !== -1 && idx !== highlightedIndexRef.current) {
|
|
1568
|
+
setHighlightedIndex(idx);
|
|
1569
|
+
}
|
|
1570
|
+
},
|
|
1571
|
+
[setHighlightedIndex]
|
|
1572
|
+
);
|
|
1573
|
+
const navigate = (0, import_react16.useCallback)(() => {
|
|
1574
|
+
navigateChildItems("ArrowDown");
|
|
1575
|
+
}, [navigateChildItems]);
|
|
1576
|
+
const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
|
|
1577
|
+
(0, import_react16.useEffect)(() => {
|
|
1578
|
+
if (fullyRendered && focusableCell.current === void 0 && !disableFocus) {
|
|
1579
|
+
const { current: container } = containerRef;
|
|
1580
|
+
const cell = (container == null ? void 0 : container.querySelector(headerCellQuery(0))) || (container == null ? void 0 : container.querySelector(dataCellQuery(0, 0)));
|
|
1581
|
+
if (cell) {
|
|
1582
|
+
cell.setAttribute("tabindex", "0");
|
|
1583
|
+
focusableCell.current = cell;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}, [containerRef, disableFocus, fullyRendered]);
|
|
1587
|
+
return {
|
|
1588
|
+
highlightedIndexRef,
|
|
1589
|
+
navigate,
|
|
1590
|
+
onClick: handleClick,
|
|
1591
|
+
onFocus: handleFocus,
|
|
1592
|
+
onKeyDown: handleKeyDown,
|
|
1593
|
+
onMouseLeave: navigationStyle === "row" ? handleMouseLeave : void 0,
|
|
1594
|
+
onMouseMove: navigationStyle === "row" ? handleMouseMove : void 0
|
|
1595
|
+
};
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
// src/useSelection.ts
|
|
1599
|
+
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
1600
|
+
var import_react17 = require("react");
|
|
1601
|
+
var { IDX: IDX2 } = import_vuu_utils11.metadataKeys;
|
|
1602
|
+
var NO_SELECTION = [];
|
|
1603
|
+
var defaultSelectionKeys = ["Enter", " "];
|
|
1604
|
+
var useSelection = ({
|
|
1605
|
+
highlightedIndexRef,
|
|
1606
|
+
selectionKeys = defaultSelectionKeys,
|
|
1607
|
+
selectionModel,
|
|
1608
|
+
onSelect,
|
|
1609
|
+
onSelectionChange
|
|
1610
|
+
}) => {
|
|
1611
|
+
selectionModel === "extended" || selectionModel === "checkbox";
|
|
1612
|
+
const lastActiveRef = (0, import_react17.useRef)(-1);
|
|
1613
|
+
const selectedRef = (0, import_react17.useRef)(NO_SELECTION);
|
|
1614
|
+
const isSelectionEvent = (0, import_react17.useCallback)(
|
|
1615
|
+
(evt) => selectionKeys.includes(evt.key),
|
|
1616
|
+
[selectionKeys]
|
|
1617
|
+
);
|
|
1618
|
+
const handleRowClick = (0, import_react17.useCallback)(
|
|
1619
|
+
(row, rangeSelect, keepExistingSelection) => {
|
|
1620
|
+
const { [IDX2]: idx } = row;
|
|
1621
|
+
const { current: active } = lastActiveRef;
|
|
1622
|
+
const { current: selected } = selectedRef;
|
|
1623
|
+
const selectOperation = (0, import_vuu_utils11.isRowSelected)(row) ? import_vuu_utils11.deselectItem : import_vuu_utils11.selectItem;
|
|
1624
|
+
const newSelected = selectOperation(
|
|
1625
|
+
selectionModel,
|
|
1626
|
+
selected,
|
|
1627
|
+
idx,
|
|
1628
|
+
rangeSelect,
|
|
1629
|
+
keepExistingSelection,
|
|
1630
|
+
active
|
|
1631
|
+
);
|
|
1632
|
+
selectedRef.current = newSelected;
|
|
1633
|
+
lastActiveRef.current = idx;
|
|
1634
|
+
onSelect == null ? void 0 : onSelect(row);
|
|
1635
|
+
onSelectionChange == null ? void 0 : onSelectionChange(newSelected);
|
|
1636
|
+
},
|
|
1637
|
+
[onSelect, onSelectionChange, selectionModel]
|
|
1638
|
+
);
|
|
1639
|
+
const handleKeyDown = (0, import_react17.useCallback)(
|
|
1640
|
+
(e) => {
|
|
1641
|
+
if (isSelectionEvent(e)) {
|
|
1642
|
+
const { current: rowIndex } = highlightedIndexRef;
|
|
1643
|
+
if (rowIndex !== void 0 && rowIndex !== -1) {
|
|
1644
|
+
const rowEl = e.target.querySelector(
|
|
1645
|
+
`[aria-rowindex="${rowIndex}"]`
|
|
1646
|
+
);
|
|
1647
|
+
if (rowEl) {
|
|
1648
|
+
(0, import_vuu_utils11.dispatchMouseEvent)(rowEl, "click");
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
[highlightedIndexRef, isSelectionEvent]
|
|
1654
|
+
);
|
|
1655
|
+
return {
|
|
1656
|
+
onKeyDown: handleKeyDown,
|
|
1657
|
+
onRowClick: handleRowClick
|
|
1658
|
+
};
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// src/useTableContextMenu.ts
|
|
1662
|
+
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
1663
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
1664
|
+
var import_react18 = require("react");
|
|
1665
|
+
var NO_ROWS = [];
|
|
1666
|
+
var useTableContextMenu = ({
|
|
1667
|
+
columns,
|
|
1668
|
+
data,
|
|
1669
|
+
dataSource,
|
|
1670
|
+
getSelectedRows
|
|
1671
|
+
}) => {
|
|
1672
|
+
const [showContextMenu] = (0, import_vuu_popups2.useContextMenu)();
|
|
1673
|
+
const onContextMenu = (0, import_react18.useCallback)(
|
|
1674
|
+
(evt) => {
|
|
1675
|
+
var _a;
|
|
1676
|
+
const target = evt.target;
|
|
1677
|
+
const cellEl = target == null ? void 0 : target.closest("div[role='cell']");
|
|
1678
|
+
const rowEl = target == null ? void 0 : target.closest("div[role='row']");
|
|
1679
|
+
if (cellEl && rowEl) {
|
|
1680
|
+
const { selectedRowsCount } = dataSource;
|
|
1681
|
+
const columnMap = (0, import_vuu_utils12.buildColumnMap)(columns);
|
|
1682
|
+
const rowIndex = parseInt((_a = rowEl.ariaRowIndex) != null ? _a : "-1");
|
|
1683
|
+
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
1684
|
+
const row = data.find(([idx]) => idx === rowIndex);
|
|
1685
|
+
const columnName = columns[cellIndex];
|
|
1686
|
+
showContextMenu(evt, "grid", {
|
|
1687
|
+
columnMap,
|
|
1688
|
+
columnName,
|
|
1689
|
+
row,
|
|
1690
|
+
selectedRows: selectedRowsCount === 0 ? NO_ROWS : getSelectedRows(),
|
|
1691
|
+
viewport: dataSource.viewport
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
[columns, data, dataSource, getSelectedRows, showContextMenu]
|
|
1696
|
+
);
|
|
1697
|
+
return onContextMenu;
|
|
1698
|
+
};
|
|
1699
|
+
|
|
1700
|
+
// src/useTableModel.ts
|
|
1701
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1702
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
1703
|
+
var import_react19 = require("react");
|
|
1704
|
+
var { info } = (0, import_vuu_utils13.logger)("useTableModel");
|
|
1705
|
+
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1706
|
+
var KEY_OFFSET = import_vuu_utils13.metadataKeys.count;
|
|
1707
|
+
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
1708
|
+
var getDataType = (column, tableSchema) => {
|
|
1709
|
+
const schemaColumn = tableSchema == null ? void 0 : tableSchema.columns.find(
|
|
1710
|
+
({ name }) => name === column.name
|
|
1711
|
+
);
|
|
1712
|
+
if (schemaColumn) {
|
|
1713
|
+
return schemaColumn.serverDataType;
|
|
1714
|
+
} else {
|
|
1715
|
+
return column.serverDataType;
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
var numericTypes = ["int", "long", "double"];
|
|
1719
|
+
var getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? void 0 : numericTypes.includes(serverDataType) ? "right" : "left";
|
|
1720
|
+
var isShowColumnSettings = (action) => action.type === "columnSettings";
|
|
1721
|
+
var isShowTableSettings = (action) => action.type === "tableSettings";
|
|
1722
|
+
var columnReducer = (state, action) => {
|
|
1723
|
+
info == null ? void 0 : info(`TableModelReducer ${action.type}`);
|
|
1724
|
+
switch (action.type) {
|
|
1725
|
+
case "init":
|
|
1726
|
+
return init(action);
|
|
1727
|
+
case "moveColumn":
|
|
1728
|
+
return moveColumn(state, action);
|
|
1729
|
+
case "resizeColumn":
|
|
1730
|
+
return resizeColumn(state, action);
|
|
1731
|
+
case "setTableSchema":
|
|
1732
|
+
return setTableSchema(state, action);
|
|
1733
|
+
case "hideColumns":
|
|
1734
|
+
return hideColumns(state, action);
|
|
1735
|
+
case "showColumns":
|
|
1736
|
+
return showColumns(state, action);
|
|
1737
|
+
case "pinColumn":
|
|
1738
|
+
return pinColumn2(state, action);
|
|
1739
|
+
case "updateColumnProp":
|
|
1740
|
+
return updateColumnProp(state, action);
|
|
1741
|
+
case "tableConfig":
|
|
1742
|
+
return updateTableConfig2(state, action);
|
|
1743
|
+
default:
|
|
1744
|
+
console.log(`unhandled action ${action.type}`);
|
|
1745
|
+
return state;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
var useTableModel = (tableConfigProp, dataSource) => {
|
|
1749
|
+
const [state, dispatchColumnAction] = (0, import_react19.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
|
|
1750
|
+
const { columns, headings, tableConfig, ...tableAttributes } = state;
|
|
1751
|
+
return {
|
|
1752
|
+
columns,
|
|
1753
|
+
dispatchColumnAction,
|
|
1754
|
+
headings,
|
|
1755
|
+
tableAttributes,
|
|
1756
|
+
tableConfig
|
|
1757
|
+
};
|
|
1758
|
+
};
|
|
1759
|
+
function init({ dataSource, tableConfig }) {
|
|
1760
|
+
const { columns, ...tableAttributes } = tableConfig;
|
|
1761
|
+
console.log(JSON.stringify(tableAttributes, null, 2));
|
|
1762
|
+
const { config: dataSourceConfig, tableSchema } = dataSource;
|
|
1763
|
+
const runtimeColumns = columns.filter((0, import_vuu_utils13.subscribedOnly)(dataSourceConfig == null ? void 0 : dataSourceConfig.columns)).map(
|
|
1764
|
+
columnDescriptorToRuntimeColumDescriptor(tableAttributes, tableSchema)
|
|
1765
|
+
);
|
|
1766
|
+
const maybePinnedColumns = runtimeColumns.some(import_vuu_utils13.isPinned) ? (0, import_vuu_utils13.sortPinnedColumns)(runtimeColumns) : runtimeColumns;
|
|
1767
|
+
let state = {
|
|
1768
|
+
columns: maybePinnedColumns,
|
|
1769
|
+
headings: (0, import_vuu_utils13.getTableHeadings)(maybePinnedColumns),
|
|
1770
|
+
tableConfig,
|
|
1771
|
+
...tableAttributes
|
|
1772
|
+
};
|
|
1773
|
+
if (dataSourceConfig) {
|
|
1774
|
+
const { columns: _, ...rest } = dataSourceConfig;
|
|
1775
|
+
state = updateTableConfig2(state, {
|
|
1776
|
+
type: "tableConfig",
|
|
1777
|
+
...rest
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
return state;
|
|
1781
|
+
}
|
|
1782
|
+
var getLabel = (label, columnFormatHeader) => {
|
|
1783
|
+
if (columnFormatHeader === "uppercase") {
|
|
1784
|
+
return label.toUpperCase();
|
|
1785
|
+
} else if (columnFormatHeader === "capitalize") {
|
|
1786
|
+
return label[0].toUpperCase() + label.slice(1).toLowerCase();
|
|
1787
|
+
}
|
|
1788
|
+
return label;
|
|
1789
|
+
};
|
|
1790
|
+
var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) => (column, index) => {
|
|
1791
|
+
const { columnDefaultWidth = DEFAULT_COLUMN_WIDTH, columnFormatHeader } = tableAttributes;
|
|
1792
|
+
const serverDataType = getDataType(column, tableSchema);
|
|
1793
|
+
const {
|
|
1794
|
+
align = getDefaultAlignment(serverDataType),
|
|
1795
|
+
key,
|
|
1796
|
+
name,
|
|
1797
|
+
label = (0, import_vuu_utils13.getColumnLabel)(column),
|
|
1798
|
+
width = columnDefaultWidth,
|
|
1799
|
+
...rest
|
|
1800
|
+
} = column;
|
|
1801
|
+
const runtimeColumnWithDefaults = {
|
|
1802
|
+
...rest,
|
|
1803
|
+
align,
|
|
1804
|
+
CellRenderer: (0, import_vuu_utils13.getCellRenderer)(column),
|
|
1805
|
+
HeaderCellLabelRenderer: (0, import_vuu_utils13.getCellRenderer)(column, "col-label"),
|
|
1806
|
+
HeaderCellContentRenderer: (0, import_vuu_utils13.getCellRenderer)(column, "col-content"),
|
|
1807
|
+
clientSideEditValidationCheck: (0, import_vuu_utils13.hasValidationRules)(column.type) ? (0, import_vuu_ui_controls.buildValidationChecker)(column.type.renderer.rules) : void 0,
|
|
1808
|
+
label: getLabel(label, columnFormatHeader),
|
|
1809
|
+
key: key != null ? key : index + KEY_OFFSET,
|
|
1810
|
+
name,
|
|
1811
|
+
originalIdx: index,
|
|
1812
|
+
serverDataType,
|
|
1813
|
+
valueFormatter: (0, import_vuu_utils13.getValueFormatter)(column, serverDataType),
|
|
1814
|
+
width
|
|
1815
|
+
};
|
|
1816
|
+
if ((0, import_vuu_utils13.isGroupColumn)(runtimeColumnWithDefaults)) {
|
|
1817
|
+
runtimeColumnWithDefaults.columns = runtimeColumnWithDefaults.columns.map(
|
|
1818
|
+
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(
|
|
1819
|
+
col,
|
|
1820
|
+
col.key
|
|
1821
|
+
)
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
return runtimeColumnWithDefaults;
|
|
1825
|
+
};
|
|
1826
|
+
function moveColumn(state, { column, moveBy }) {
|
|
1827
|
+
const { columns } = state;
|
|
1828
|
+
if (typeof moveBy === "number") {
|
|
1829
|
+
const idx = columns.indexOf(column);
|
|
1830
|
+
const newColumns = columns.slice();
|
|
1831
|
+
const [movedColumns] = newColumns.splice(idx, 1);
|
|
1832
|
+
newColumns.splice(idx + moveBy, 0, movedColumns);
|
|
1833
|
+
return {
|
|
1834
|
+
...state,
|
|
1835
|
+
columns: newColumns
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
return state;
|
|
1839
|
+
}
|
|
1840
|
+
function hideColumns(state, { columns }) {
|
|
1841
|
+
if (columns.some((col) => col.hidden !== true)) {
|
|
1842
|
+
return columns.reduce((s, c) => {
|
|
1843
|
+
if (c.hidden !== true) {
|
|
1844
|
+
return updateColumnProp(s, {
|
|
1845
|
+
type: "updateColumnProp",
|
|
1846
|
+
column: c,
|
|
1847
|
+
hidden: true
|
|
1848
|
+
});
|
|
1849
|
+
} else {
|
|
1850
|
+
return s;
|
|
1851
|
+
}
|
|
1852
|
+
}, state);
|
|
1853
|
+
} else {
|
|
1854
|
+
return state;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
function showColumns(state, { columns }) {
|
|
1858
|
+
if (columns.some((col) => col.hidden)) {
|
|
1859
|
+
return columns.reduce((s, c) => {
|
|
1860
|
+
if (c.hidden) {
|
|
1861
|
+
return updateColumnProp(s, {
|
|
1862
|
+
type: "updateColumnProp",
|
|
1863
|
+
column: c,
|
|
1864
|
+
hidden: false
|
|
1865
|
+
});
|
|
1866
|
+
} else {
|
|
1867
|
+
return s;
|
|
1868
|
+
}
|
|
1869
|
+
}, state);
|
|
1870
|
+
} else {
|
|
1871
|
+
return state;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
function resizeColumn(state, { column, phase, width }) {
|
|
1875
|
+
const type = "updateColumnProp";
|
|
1876
|
+
const resizing = phase !== "end";
|
|
1877
|
+
switch (phase) {
|
|
1878
|
+
case "begin":
|
|
1879
|
+
return updateColumnProp(state, { type, column, resizing });
|
|
1880
|
+
case "end":
|
|
1881
|
+
return updateColumnProp(state, { type, column, resizing, width });
|
|
1882
|
+
case "resize":
|
|
1883
|
+
return updateColumnProp(state, { type, column, width });
|
|
1884
|
+
default:
|
|
1885
|
+
throw Error(`useTableModel.resizeColumn, invalid resizePhase ${phase}`);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
function setTableSchema(state, { tableSchema }) {
|
|
1889
|
+
const { columns } = state;
|
|
1890
|
+
if (columns.some(columnWithoutDataType)) {
|
|
1891
|
+
const cols = columns.map((column) => {
|
|
1892
|
+
var _a;
|
|
1893
|
+
const serverDataType = getDataType(column, tableSchema);
|
|
1894
|
+
return {
|
|
1895
|
+
...column,
|
|
1896
|
+
align: (_a = column.align) != null ? _a : getDefaultAlignment(serverDataType),
|
|
1897
|
+
serverDataType
|
|
1898
|
+
};
|
|
1899
|
+
});
|
|
1900
|
+
return {
|
|
1901
|
+
...state,
|
|
1902
|
+
columns: cols
|
|
1903
|
+
};
|
|
1904
|
+
} else {
|
|
1905
|
+
return state;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
function pinColumn2(state, action) {
|
|
1909
|
+
let { columns } = state;
|
|
1910
|
+
const { column, pin } = action;
|
|
1911
|
+
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1912
|
+
if (targetColumn) {
|
|
1913
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, pin });
|
|
1914
|
+
columns = (0, import_vuu_utils13.sortPinnedColumns)(columns);
|
|
1915
|
+
return {
|
|
1916
|
+
...state,
|
|
1917
|
+
columns
|
|
1918
|
+
};
|
|
1919
|
+
} else {
|
|
1920
|
+
return state;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
function updateColumnProp(state, action) {
|
|
1924
|
+
let { columns, tableConfig } = state;
|
|
1925
|
+
const { align, column, hidden, label, resizing, width } = action;
|
|
1926
|
+
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1927
|
+
if (targetColumn) {
|
|
1928
|
+
if (align === "left" || align === "right") {
|
|
1929
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, align });
|
|
1930
|
+
}
|
|
1931
|
+
if (typeof label === "string") {
|
|
1932
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, label });
|
|
1933
|
+
}
|
|
1934
|
+
if (typeof resizing === "boolean") {
|
|
1935
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, resizing });
|
|
1936
|
+
}
|
|
1937
|
+
if (typeof hidden === "boolean") {
|
|
1938
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, hidden });
|
|
1939
|
+
}
|
|
1940
|
+
if (typeof width === "number") {
|
|
1941
|
+
columns = (0, import_vuu_utils13.replaceColumn)(columns, { ...targetColumn, width });
|
|
1942
|
+
const targetConfigColumn = tableConfig.columns.find(
|
|
1943
|
+
(col) => col.name === column.name
|
|
1944
|
+
);
|
|
1945
|
+
if (targetConfigColumn) {
|
|
1946
|
+
tableConfig = {
|
|
1947
|
+
...tableConfig,
|
|
1948
|
+
columns: (0, import_vuu_utils13.replaceColumn)(tableConfig.columns, {
|
|
1949
|
+
...targetConfigColumn,
|
|
1950
|
+
width
|
|
1951
|
+
})
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
return {
|
|
1957
|
+
...state,
|
|
1958
|
+
columns,
|
|
1959
|
+
tableConfig
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
1963
|
+
const hasGroupBy = groupBy !== void 0;
|
|
1964
|
+
const hasFilter = typeof (filter == null ? void 0 : filter.filter) === "string";
|
|
1965
|
+
const hasSort = sort && sort.sortDefs.length > 0;
|
|
1966
|
+
let result = state;
|
|
1967
|
+
if (hasGroupBy) {
|
|
1968
|
+
result = {
|
|
1969
|
+
...state,
|
|
1970
|
+
columns: (0, import_vuu_utils13.applyGroupByToColumns)(result.columns, groupBy, confirmed)
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
if (hasSort) {
|
|
1974
|
+
result = {
|
|
1975
|
+
...state,
|
|
1976
|
+
columns: (0, import_vuu_utils13.applySortToColumns)(result.columns, sort)
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
if (hasFilter) {
|
|
1980
|
+
result = {
|
|
1981
|
+
...state,
|
|
1982
|
+
columns: (0, import_vuu_utils13.applyFilterToColumns)(result.columns, filter)
|
|
1983
|
+
};
|
|
1984
|
+
} else if (result.columns.some(import_vuu_utils13.isFilteredColumn)) {
|
|
1985
|
+
result = {
|
|
1986
|
+
...state,
|
|
1987
|
+
columns: (0, import_vuu_utils13.stripFilterFromColumns)(result.columns)
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
return result;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
// src/useTableScroll.ts
|
|
1994
|
+
var import_react20 = require("react");
|
|
1995
|
+
var getPctScroll = (container) => {
|
|
1996
|
+
const { scrollLeft, scrollTop } = container;
|
|
1997
|
+
const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
|
|
1998
|
+
const pctScrollLeft = scrollLeft / (scrollWidth - clientWidth);
|
|
1999
|
+
const pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
2000
|
+
return [pctScrollLeft, pctScrollTop];
|
|
2001
|
+
};
|
|
2002
|
+
var useCallbackRef = ({
|
|
2003
|
+
onAttach,
|
|
2004
|
+
onDetach
|
|
2005
|
+
}) => {
|
|
2006
|
+
const ref = (0, import_react20.useRef)(null);
|
|
2007
|
+
const callbackRef = (0, import_react20.useCallback)(
|
|
2008
|
+
(el) => {
|
|
2009
|
+
if (el) {
|
|
2010
|
+
ref.current = el;
|
|
2011
|
+
onAttach == null ? void 0 : onAttach(el);
|
|
2012
|
+
} else if (ref.current) {
|
|
2013
|
+
const { current: originalRef } = ref;
|
|
2014
|
+
ref.current = el;
|
|
2015
|
+
onDetach == null ? void 0 : onDetach(originalRef);
|
|
2016
|
+
}
|
|
2017
|
+
},
|
|
2018
|
+
[onAttach, onDetach]
|
|
2019
|
+
);
|
|
2020
|
+
return callbackRef;
|
|
2021
|
+
};
|
|
2022
|
+
var useTableScroll = ({
|
|
2023
|
+
maxScrollLeft,
|
|
2024
|
+
maxScrollTop,
|
|
2025
|
+
onHorizontalScroll,
|
|
2026
|
+
onVerticalScroll,
|
|
2027
|
+
rowHeight,
|
|
2028
|
+
viewportRowCount
|
|
2029
|
+
}) => {
|
|
2030
|
+
const contentContainerScrolledRef = (0, import_react20.useRef)(false);
|
|
2031
|
+
const scrollPosRef = (0, import_react20.useRef)({ scrollTop: 0, scrollLeft: 0 });
|
|
2032
|
+
const scrollbarContainerRef = (0, import_react20.useRef)(null);
|
|
2033
|
+
const contentContainerRef = (0, import_react20.useRef)(null);
|
|
2034
|
+
const handleScrollbarContainerScroll = (0, import_react20.useCallback)(() => {
|
|
2035
|
+
const { current: contentContainer } = contentContainerRef;
|
|
2036
|
+
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2037
|
+
const { current: contentContainerScrolled } = contentContainerScrolledRef;
|
|
2038
|
+
if (contentContainerScrolled) {
|
|
2039
|
+
contentContainerScrolledRef.current = false;
|
|
2040
|
+
} else if (contentContainer && scrollbarContainer) {
|
|
2041
|
+
const [pctScrollLeft, pctScrollTop] = getPctScroll(scrollbarContainer);
|
|
2042
|
+
const rootScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2043
|
+
const rootScrollTop = Math.round(pctScrollTop * maxScrollTop);
|
|
2044
|
+
contentContainer.scrollTo({
|
|
2045
|
+
left: rootScrollLeft,
|
|
2046
|
+
top: rootScrollTop,
|
|
2047
|
+
behavior: "auto"
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
}, [maxScrollLeft, maxScrollTop]);
|
|
2051
|
+
const handleContentContainerScroll = (0, import_react20.useCallback)(() => {
|
|
2052
|
+
const { current: contentContainer } = contentContainerRef;
|
|
2053
|
+
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2054
|
+
const { current: scrollPos } = scrollPosRef;
|
|
2055
|
+
if (contentContainer && scrollbarContainer) {
|
|
2056
|
+
const { scrollLeft, scrollTop } = contentContainer;
|
|
2057
|
+
const [pctScrollLeft, pctScrollTop] = getPctScroll(contentContainer);
|
|
2058
|
+
contentContainerScrolledRef.current = true;
|
|
2059
|
+
scrollbarContainer.scrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2060
|
+
scrollbarContainer.scrollTop = Math.round(pctScrollTop * maxScrollTop);
|
|
2061
|
+
if (scrollPos.scrollTop !== scrollTop) {
|
|
2062
|
+
scrollPos.scrollTop = scrollTop;
|
|
2063
|
+
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
2064
|
+
}
|
|
2065
|
+
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
2066
|
+
scrollPos.scrollLeft = scrollLeft;
|
|
2067
|
+
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}, [maxScrollLeft, maxScrollTop, onHorizontalScroll, onVerticalScroll]);
|
|
2071
|
+
const handleAttachScrollbarContainer = (0, import_react20.useCallback)(
|
|
2072
|
+
(el) => {
|
|
2073
|
+
scrollbarContainerRef.current = el;
|
|
2074
|
+
el.addEventListener("scroll", handleScrollbarContainerScroll, {
|
|
2075
|
+
passive: true
|
|
2076
|
+
});
|
|
2077
|
+
},
|
|
2078
|
+
[handleScrollbarContainerScroll]
|
|
2079
|
+
);
|
|
2080
|
+
const handleDetachScrollbarContainer = (0, import_react20.useCallback)(
|
|
2081
|
+
(el) => {
|
|
2082
|
+
scrollbarContainerRef.current = null;
|
|
2083
|
+
el.removeEventListener("scroll", handleScrollbarContainerScroll);
|
|
2084
|
+
},
|
|
2085
|
+
[handleScrollbarContainerScroll]
|
|
2086
|
+
);
|
|
2087
|
+
const handleAttachContentContainer = (0, import_react20.useCallback)(
|
|
2088
|
+
(el) => {
|
|
2089
|
+
contentContainerRef.current = el;
|
|
2090
|
+
el.addEventListener("scroll", handleContentContainerScroll, {
|
|
2091
|
+
passive: true
|
|
2092
|
+
});
|
|
2093
|
+
},
|
|
2094
|
+
[handleContentContainerScroll]
|
|
2095
|
+
);
|
|
2096
|
+
const handleDetachContentContainer = (0, import_react20.useCallback)(
|
|
2097
|
+
(el) => {
|
|
2098
|
+
contentContainerRef.current = null;
|
|
2099
|
+
el.removeEventListener("scroll", handleContentContainerScroll);
|
|
2100
|
+
},
|
|
2101
|
+
[handleContentContainerScroll]
|
|
2102
|
+
);
|
|
2103
|
+
const contentContainerCallbackRef = useCallbackRef({
|
|
2104
|
+
onAttach: handleAttachContentContainer,
|
|
2105
|
+
onDetach: handleDetachContentContainer
|
|
2106
|
+
});
|
|
2107
|
+
const scrollbarContainerCallbackRef = useCallbackRef({
|
|
2108
|
+
onAttach: handleAttachScrollbarContainer,
|
|
2109
|
+
onDetach: handleDetachScrollbarContainer
|
|
2110
|
+
});
|
|
2111
|
+
const requestScroll = (0, import_react20.useCallback)(
|
|
2112
|
+
(scrollRequest) => {
|
|
2113
|
+
const { current: scrollbarContainer } = contentContainerRef;
|
|
2114
|
+
if (scrollbarContainer) {
|
|
2115
|
+
const { scrollLeft, scrollTop } = scrollbarContainer;
|
|
2116
|
+
contentContainerScrolledRef.current = false;
|
|
2117
|
+
if (scrollRequest.type === "scroll-distance") {
|
|
2118
|
+
let newScrollLeft = scrollLeft;
|
|
2119
|
+
let newScrollTop = scrollTop;
|
|
2120
|
+
if (scrollRequest.direction === "up" || scrollRequest.direction === "down") {
|
|
2121
|
+
newScrollTop = Math.min(
|
|
2122
|
+
Math.max(0, scrollTop + scrollRequest.distance),
|
|
2123
|
+
maxScrollTop
|
|
2124
|
+
);
|
|
2125
|
+
} else {
|
|
2126
|
+
newScrollLeft = Math.min(
|
|
2127
|
+
Math.max(0, scrollLeft + scrollRequest.distance),
|
|
2128
|
+
maxScrollLeft
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
scrollbarContainer.scrollTo({
|
|
2132
|
+
top: newScrollTop,
|
|
2133
|
+
left: newScrollLeft,
|
|
2134
|
+
behavior: "smooth"
|
|
2135
|
+
});
|
|
2136
|
+
} else if (scrollRequest.type === "scroll-page") {
|
|
2137
|
+
const { direction } = scrollRequest;
|
|
2138
|
+
const scrollBy = viewportRowCount * (direction === "down" ? rowHeight : -rowHeight);
|
|
2139
|
+
const newScrollTop = Math.min(
|
|
2140
|
+
Math.max(0, scrollTop + scrollBy),
|
|
2141
|
+
maxScrollTop
|
|
2142
|
+
);
|
|
2143
|
+
scrollbarContainer.scrollTo({
|
|
2144
|
+
top: newScrollTop,
|
|
2145
|
+
left: scrollLeft,
|
|
2146
|
+
behavior: "auto"
|
|
2147
|
+
});
|
|
2148
|
+
} else if (scrollRequest.type === "scroll-end") {
|
|
2149
|
+
const { direction } = scrollRequest;
|
|
2150
|
+
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
2151
|
+
scrollbarContainer.scrollTo({
|
|
2152
|
+
top: scrollTo,
|
|
2153
|
+
left: scrollbarContainer.scrollLeft,
|
|
2154
|
+
behavior: "auto"
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
},
|
|
2159
|
+
[maxScrollLeft, maxScrollTop, rowHeight, viewportRowCount]
|
|
2160
|
+
);
|
|
2161
|
+
return {
|
|
2162
|
+
/** Ref to be assigned to ScrollbarContainer */
|
|
2163
|
+
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
2164
|
+
/** Ref to be assigned to ContentContainer */
|
|
2165
|
+
contentContainerRef: contentContainerCallbackRef,
|
|
2166
|
+
/** Scroll the table */
|
|
2167
|
+
requestScroll
|
|
2168
|
+
};
|
|
2169
|
+
};
|
|
2170
|
+
|
|
2171
|
+
// src/useTableViewport.ts
|
|
2172
|
+
var import_react21 = require("react");
|
|
2173
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
2174
|
+
var MAX_RAW_ROWS = 15e5;
|
|
2175
|
+
var UNMEASURED_VIEWPORT = {
|
|
2176
|
+
contentHeight: 0,
|
|
2177
|
+
contentWidth: 0,
|
|
2178
|
+
getRowAtPosition: () => -1,
|
|
2179
|
+
getRowOffset: () => -1,
|
|
2180
|
+
horizontalScrollbarHeight: 0,
|
|
2181
|
+
maxScrollContainerScrollHorizontal: 0,
|
|
2182
|
+
maxScrollContainerScrollVertical: 0,
|
|
2183
|
+
pinnedWidthLeft: 0,
|
|
2184
|
+
pinnedWidthRight: 0,
|
|
2185
|
+
rowCount: 0,
|
|
2186
|
+
setPctScrollTop: () => void 0,
|
|
2187
|
+
totalHeaderHeight: 0,
|
|
2188
|
+
verticalScrollbarWidth: 0,
|
|
2189
|
+
viewportBodyHeight: 0
|
|
2190
|
+
};
|
|
2191
|
+
var measurePinnedColumns = (columns) => {
|
|
2192
|
+
let pinnedWidthLeft = 0;
|
|
2193
|
+
let pinnedWidthRight = 0;
|
|
2194
|
+
let unpinnedWidth = 0;
|
|
2195
|
+
for (const column of columns) {
|
|
2196
|
+
const { hidden, pin, width } = column;
|
|
2197
|
+
const visibleWidth = hidden ? 0 : width;
|
|
2198
|
+
if (pin === "left") {
|
|
2199
|
+
pinnedWidthLeft += visibleWidth;
|
|
2200
|
+
} else if (pin === "right") {
|
|
2201
|
+
pinnedWidthRight += visibleWidth;
|
|
2202
|
+
} else {
|
|
2203
|
+
unpinnedWidth += visibleWidth;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
return {
|
|
2207
|
+
pinnedWidthLeft: pinnedWidthLeft + 4,
|
|
2208
|
+
pinnedWidthRight: pinnedWidthRight + 4,
|
|
2209
|
+
unpinnedWidth
|
|
2210
|
+
};
|
|
2211
|
+
};
|
|
2212
|
+
var useTableViewport = ({
|
|
2213
|
+
columns,
|
|
2214
|
+
headerHeight,
|
|
2215
|
+
headings,
|
|
2216
|
+
rowCount,
|
|
2217
|
+
rowHeight,
|
|
2218
|
+
size
|
|
2219
|
+
}) => {
|
|
2220
|
+
const pctScrollTopRef = (0, import_react21.useRef)(0);
|
|
2221
|
+
const appliedRowCount = Math.min(rowCount, MAX_RAW_ROWS);
|
|
2222
|
+
const appliedContentHeight = appliedRowCount * rowHeight;
|
|
2223
|
+
const virtualContentHeight = rowCount * rowHeight;
|
|
2224
|
+
const virtualisedExtent = virtualContentHeight - appliedContentHeight;
|
|
2225
|
+
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react21.useMemo)(
|
|
2226
|
+
() => measurePinnedColumns(columns),
|
|
2227
|
+
[columns]
|
|
2228
|
+
);
|
|
2229
|
+
const [actualRowOffset, actualRowAtPosition] = (0, import_react21.useMemo)(
|
|
2230
|
+
() => (0, import_vuu_utils14.actualRowPositioning)(rowHeight),
|
|
2231
|
+
[rowHeight]
|
|
2232
|
+
);
|
|
2233
|
+
const [getRowOffset, getRowAtPosition] = (0, import_react21.useMemo)(() => {
|
|
2234
|
+
if (virtualisedExtent) {
|
|
2235
|
+
return (0, import_vuu_utils14.virtualRowPositioning)(
|
|
2236
|
+
rowHeight,
|
|
2237
|
+
virtualisedExtent,
|
|
2238
|
+
pctScrollTopRef
|
|
2239
|
+
);
|
|
2240
|
+
} else {
|
|
2241
|
+
return [actualRowOffset, actualRowAtPosition];
|
|
2242
|
+
}
|
|
2243
|
+
}, [actualRowAtPosition, actualRowOffset, virtualisedExtent, rowHeight]);
|
|
2244
|
+
const setPctScrollTop = (0, import_react21.useCallback)((scrollPct) => {
|
|
2245
|
+
pctScrollTopRef.current = scrollPct;
|
|
2246
|
+
}, []);
|
|
2247
|
+
return (0, import_react21.useMemo)(() => {
|
|
2248
|
+
var _a;
|
|
2249
|
+
if (size) {
|
|
2250
|
+
const headingsDepth = headings.length;
|
|
2251
|
+
const scrollbarSize = 15;
|
|
2252
|
+
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
2253
|
+
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
2254
|
+
const totalHeaderHeight = headerHeight * (1 + headingsDepth);
|
|
2255
|
+
const maxScrollContainerScrollVertical = appliedContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2256
|
+
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
2257
|
+
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
2258
|
+
const count = Number.isInteger(visibleRows) ? visibleRows + 1 : Math.ceil(visibleRows);
|
|
2259
|
+
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
2260
|
+
const verticalScrollbarWidth = appliedContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
2261
|
+
return {
|
|
2262
|
+
contentHeight: appliedContentHeight,
|
|
2263
|
+
getRowAtPosition,
|
|
2264
|
+
getRowOffset,
|
|
2265
|
+
horizontalScrollbarHeight,
|
|
2266
|
+
maxScrollContainerScrollHorizontal,
|
|
2267
|
+
maxScrollContainerScrollVertical,
|
|
2268
|
+
pinnedWidthLeft,
|
|
2269
|
+
pinnedWidthRight,
|
|
2270
|
+
rowCount: count,
|
|
2271
|
+
contentWidth,
|
|
2272
|
+
setPctScrollTop,
|
|
2273
|
+
totalHeaderHeight,
|
|
2274
|
+
verticalScrollbarWidth,
|
|
2275
|
+
viewportBodyHeight
|
|
2276
|
+
};
|
|
2277
|
+
} else {
|
|
2278
|
+
return UNMEASURED_VIEWPORT;
|
|
2279
|
+
}
|
|
2280
|
+
}, [
|
|
2281
|
+
size,
|
|
2282
|
+
headings.length,
|
|
2283
|
+
pinnedWidthLeft,
|
|
2284
|
+
unpinnedWidth,
|
|
2285
|
+
pinnedWidthRight,
|
|
2286
|
+
appliedContentHeight,
|
|
2287
|
+
headerHeight,
|
|
2288
|
+
rowHeight,
|
|
2289
|
+
getRowAtPosition,
|
|
2290
|
+
getRowOffset,
|
|
2291
|
+
setPctScrollTop
|
|
2292
|
+
]);
|
|
2293
|
+
};
|
|
2294
|
+
|
|
2295
|
+
// src/useVirtualViewport.ts
|
|
2296
|
+
var import_react22 = require("react");
|
|
2297
|
+
var useVirtualViewport = ({
|
|
2298
|
+
columns,
|
|
2299
|
+
getRowAtPosition,
|
|
2300
|
+
setRange,
|
|
2301
|
+
viewportMeasurements
|
|
2302
|
+
}) => {
|
|
2303
|
+
const firstRowRef = (0, import_react22.useRef)(0);
|
|
2304
|
+
const { contentWidth, rowCount: viewportRowCount } = viewportMeasurements;
|
|
2305
|
+
const handleVerticalScroll = (0, import_react22.useCallback)(
|
|
2306
|
+
(scrollTop) => {
|
|
2307
|
+
const firstRow = getRowAtPosition(scrollTop);
|
|
2308
|
+
if (firstRow !== firstRowRef.current) {
|
|
2309
|
+
firstRowRef.current = firstRow;
|
|
2310
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2311
|
+
}
|
|
2312
|
+
},
|
|
2313
|
+
[getRowAtPosition, setRange, viewportRowCount]
|
|
2314
|
+
);
|
|
2315
|
+
(0, import_react22.useEffect)(() => {
|
|
2316
|
+
const { current: from } = firstRowRef;
|
|
2317
|
+
const rowRange = { from, to: from + viewportRowCount };
|
|
2318
|
+
setRange(rowRange);
|
|
2319
|
+
}, [setRange, viewportRowCount]);
|
|
2320
|
+
return {
|
|
2321
|
+
onVerticalScroll: handleVerticalScroll
|
|
2322
|
+
};
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
// src/useTable.ts
|
|
2326
|
+
var stripInternalProperties = (tableConfig) => {
|
|
2327
|
+
return tableConfig;
|
|
2328
|
+
};
|
|
2329
|
+
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils15.metadataKeys;
|
|
2330
|
+
var NULL_DRAG_DROP = {
|
|
2331
|
+
draggable: void 0,
|
|
2332
|
+
onMouseDown: void 0
|
|
2333
|
+
};
|
|
2334
|
+
var useNullDragDrop = () => NULL_DRAG_DROP;
|
|
2335
|
+
var addColumn = (tableConfig, column) => ({
|
|
2336
|
+
...tableConfig,
|
|
2337
|
+
columns: tableConfig.columns.concat(column)
|
|
2338
|
+
});
|
|
2339
|
+
var useTable = ({
|
|
2340
|
+
allowDragDrop = false,
|
|
2341
|
+
availableColumns,
|
|
2342
|
+
config,
|
|
2343
|
+
containerRef,
|
|
2344
|
+
dataSource,
|
|
2345
|
+
disableFocus,
|
|
2346
|
+
headerHeight = 25,
|
|
2347
|
+
highlightedIndex: highlightedIndexProp,
|
|
2348
|
+
id,
|
|
2349
|
+
navigationStyle = "cell",
|
|
2350
|
+
onAvailableColumnsChange,
|
|
2351
|
+
onConfigChange,
|
|
2352
|
+
onDragStart,
|
|
2353
|
+
onDrop,
|
|
2354
|
+
onFeatureInvocation,
|
|
2355
|
+
onHighlight,
|
|
2356
|
+
onRowClick: onRowClickProp,
|
|
2357
|
+
onSelect,
|
|
2358
|
+
onSelectionChange,
|
|
2359
|
+
renderBufferSize = 0,
|
|
2360
|
+
rowHeight = 20,
|
|
2361
|
+
selectionModel,
|
|
2362
|
+
size
|
|
2363
|
+
}) => {
|
|
2364
|
+
const [rowCount, setRowCount] = (0, import_react23.useState)(dataSource.size);
|
|
2365
|
+
if (dataSource === void 0) {
|
|
2366
|
+
throw Error("no data source provided to Vuu Table");
|
|
2367
|
+
}
|
|
2368
|
+
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls2.useDragDropNext : useNullDragDrop;
|
|
2369
|
+
const menuBuilder = (0, import_react23.useMemo)(
|
|
2370
|
+
() => buildContextMenuDescriptors(dataSource),
|
|
2371
|
+
[dataSource]
|
|
2372
|
+
);
|
|
2373
|
+
const onDataRowcountChange = (0, import_react23.useCallback)((size2) => {
|
|
2374
|
+
setRowCount(size2);
|
|
2375
|
+
}, []);
|
|
2376
|
+
const {
|
|
2377
|
+
columns: runtimeColumns,
|
|
2378
|
+
dispatchColumnAction,
|
|
2379
|
+
headings,
|
|
2380
|
+
tableAttributes,
|
|
2381
|
+
tableConfig
|
|
2382
|
+
} = useTableModel(config, dataSource);
|
|
2383
|
+
(0, import_vuu_layout2.useLayoutEffectSkipFirst)(() => {
|
|
2384
|
+
dispatchColumnAction({
|
|
2385
|
+
type: "init",
|
|
2386
|
+
dataSource,
|
|
2387
|
+
tableConfig
|
|
2388
|
+
});
|
|
2389
|
+
}, [tableConfig, dataSource, dispatchColumnAction]);
|
|
2390
|
+
const applyTableConfigChange = (0, import_react23.useCallback)(
|
|
2391
|
+
(config2) => {
|
|
2392
|
+
dispatchColumnAction({
|
|
2393
|
+
type: "init",
|
|
2394
|
+
tableConfig: config2,
|
|
2395
|
+
dataSource
|
|
2396
|
+
});
|
|
2397
|
+
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(config2));
|
|
2398
|
+
},
|
|
2399
|
+
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2400
|
+
);
|
|
2401
|
+
const [stateColumns, setStateColumns] = (0, import_react23.useState)();
|
|
2402
|
+
const [columns, setColumnSize] = (0, import_react23.useMemo)(() => {
|
|
2403
|
+
const setSize = (columnName, width) => {
|
|
2404
|
+
const cols = (0, import_vuu_utils15.updateColumn)(runtimeColumns, columnName, { width });
|
|
2405
|
+
setStateColumns(cols);
|
|
2406
|
+
};
|
|
2407
|
+
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2408
|
+
}, [runtimeColumns, stateColumns]);
|
|
2409
|
+
const columnMap = (0, import_react23.useMemo)(
|
|
2410
|
+
() => (0, import_vuu_utils15.buildColumnMap)(dataSource.columns),
|
|
2411
|
+
[dataSource.columns]
|
|
2412
|
+
);
|
|
2413
|
+
const {
|
|
2414
|
+
getRowAtPosition,
|
|
2415
|
+
getRowOffset,
|
|
2416
|
+
setPctScrollTop,
|
|
2417
|
+
...viewportMeasurements
|
|
2418
|
+
} = useTableViewport({
|
|
2419
|
+
columns,
|
|
2420
|
+
headerHeight,
|
|
2421
|
+
headings,
|
|
2422
|
+
rowCount,
|
|
2423
|
+
rowHeight,
|
|
2424
|
+
size
|
|
2425
|
+
});
|
|
2426
|
+
const initialRange = useInitialValue({
|
|
2427
|
+
from: 0,
|
|
2428
|
+
to: viewportMeasurements.rowCount
|
|
2429
|
+
});
|
|
2430
|
+
const onSubscribed = (0, import_react23.useCallback)(
|
|
2431
|
+
({ tableSchema }) => {
|
|
2432
|
+
if (tableSchema) {
|
|
2433
|
+
dispatchColumnAction({
|
|
2434
|
+
type: "setTableSchema",
|
|
2435
|
+
tableSchema
|
|
2436
|
+
});
|
|
2437
|
+
} else {
|
|
2438
|
+
console.log("subscription message with no schema");
|
|
2439
|
+
}
|
|
2440
|
+
},
|
|
2441
|
+
[dispatchColumnAction]
|
|
2442
|
+
);
|
|
2443
|
+
const { data, dataRef, getSelectedRows, range, setRange } = useDataSource({
|
|
2444
|
+
dataSource,
|
|
2445
|
+
onFeatureInvocation,
|
|
2446
|
+
renderBufferSize,
|
|
2447
|
+
onSizeChange: onDataRowcountChange,
|
|
2448
|
+
onSubscribed,
|
|
2449
|
+
range: initialRange
|
|
2450
|
+
});
|
|
2451
|
+
const handleConfigEditedInSettingsPanel = (0, import_react23.useCallback)(
|
|
2452
|
+
(tableConfig2) => {
|
|
2453
|
+
console.log(`settings changed`);
|
|
2454
|
+
dispatchColumnAction({
|
|
2455
|
+
type: "init",
|
|
2456
|
+
tableConfig: tableConfig2,
|
|
2457
|
+
dataSource
|
|
2458
|
+
});
|
|
2459
|
+
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(tableConfig2));
|
|
2460
|
+
},
|
|
2461
|
+
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2462
|
+
);
|
|
2463
|
+
const handleDataSourceConfigChanged = (0, import_react23.useCallback)(
|
|
2464
|
+
(dataSourceConfig) => {
|
|
2465
|
+
dataSource.config = {
|
|
2466
|
+
...dataSource.config,
|
|
2467
|
+
...dataSourceConfig
|
|
2468
|
+
};
|
|
2469
|
+
},
|
|
2470
|
+
[dataSource]
|
|
2471
|
+
);
|
|
2472
|
+
(0, import_react23.useEffect)(() => {
|
|
2473
|
+
dataSource.on("config", (config2, confirmed) => {
|
|
2474
|
+
dispatchColumnAction({
|
|
2475
|
+
type: "tableConfig",
|
|
2476
|
+
...config2,
|
|
2477
|
+
confirmed
|
|
2478
|
+
});
|
|
2479
|
+
});
|
|
2480
|
+
}, [dataSource, dispatchColumnAction]);
|
|
2481
|
+
const handleCreateCalculatedColumn = (0, import_react23.useCallback)(
|
|
2482
|
+
(column) => {
|
|
2483
|
+
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2484
|
+
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2485
|
+
},
|
|
2486
|
+
[dataSource, tableConfig, applyTableConfigChange]
|
|
2487
|
+
);
|
|
2488
|
+
const hideColumns2 = (0, import_react23.useCallback)(
|
|
2489
|
+
(action) => {
|
|
2490
|
+
const { columns: columns2 } = action;
|
|
2491
|
+
const hiddenColumns = columns2.map((c) => c.name);
|
|
2492
|
+
const newTableConfig = {
|
|
2493
|
+
...tableConfig,
|
|
2494
|
+
columns: tableConfig.columns.map(
|
|
2495
|
+
(col) => hiddenColumns.includes(col.name) ? { ...col, hidden: true } : col
|
|
2496
|
+
)
|
|
2497
|
+
};
|
|
2498
|
+
applyTableConfigChange(newTableConfig);
|
|
2499
|
+
},
|
|
2500
|
+
[tableConfig, applyTableConfigChange]
|
|
2501
|
+
);
|
|
2502
|
+
const pinColumn3 = (0, import_react23.useCallback)(
|
|
2503
|
+
(action) => {
|
|
2504
|
+
applyTableConfigChange({
|
|
2505
|
+
...tableConfig,
|
|
2506
|
+
columns: (0, import_vuu_utils15.updateColumn)(tableConfig.columns, {
|
|
2507
|
+
...action.column,
|
|
2508
|
+
pin: action.pin
|
|
2509
|
+
})
|
|
2510
|
+
});
|
|
2511
|
+
},
|
|
2512
|
+
[tableConfig, applyTableConfigChange]
|
|
2513
|
+
);
|
|
2514
|
+
const { showColumnSettingsPanel, showTableSettingsPanel } = (0, import_vuu_table_extras.useTableAndColumnSettings)({
|
|
2515
|
+
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType = "string" }) => ({
|
|
2516
|
+
name,
|
|
2517
|
+
serverDataType
|
|
2518
|
+
})),
|
|
2519
|
+
onAvailableColumnsChange,
|
|
2520
|
+
onConfigChange: handleConfigEditedInSettingsPanel,
|
|
2521
|
+
onCreateCalculatedColumn: handleCreateCalculatedColumn,
|
|
2522
|
+
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2523
|
+
tableConfig
|
|
2524
|
+
});
|
|
2525
|
+
const onPersistentColumnOperation = (0, import_react23.useCallback)(
|
|
2526
|
+
(action) => {
|
|
2527
|
+
if (isShowColumnSettings(action)) {
|
|
2528
|
+
showColumnSettingsPanel(action);
|
|
2529
|
+
} else if (isShowTableSettings(action)) {
|
|
2530
|
+
showTableSettingsPanel();
|
|
2531
|
+
} else {
|
|
2532
|
+
switch (action.type) {
|
|
2533
|
+
case "hideColumns":
|
|
2534
|
+
return hideColumns2(action);
|
|
2535
|
+
case "pinColumn":
|
|
2536
|
+
return pinColumn3(action);
|
|
2537
|
+
default:
|
|
2538
|
+
dispatchColumnAction(action);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
},
|
|
2542
|
+
[
|
|
2543
|
+
dispatchColumnAction,
|
|
2544
|
+
hideColumns2,
|
|
2545
|
+
pinColumn3,
|
|
2546
|
+
showColumnSettingsPanel,
|
|
2547
|
+
showTableSettingsPanel
|
|
2548
|
+
]
|
|
2549
|
+
);
|
|
2550
|
+
const handleContextMenuAction = useHandleTableContextMenu({
|
|
2551
|
+
dataSource,
|
|
2552
|
+
onPersistentColumnOperation
|
|
2553
|
+
});
|
|
2554
|
+
const handleSort = (0, import_react23.useCallback)(
|
|
2555
|
+
(column, extendSort = false, sortType) => {
|
|
2556
|
+
if (dataSource) {
|
|
2557
|
+
dataSource.sort = (0, import_vuu_utils15.applySort)(
|
|
2558
|
+
dataSource.sort,
|
|
2559
|
+
column,
|
|
2560
|
+
extendSort,
|
|
2561
|
+
sortType
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
},
|
|
2565
|
+
[dataSource]
|
|
2566
|
+
);
|
|
2567
|
+
const onResizeColumn = (0, import_react23.useCallback)(
|
|
2568
|
+
(phase, columnName, width) => {
|
|
2569
|
+
const column = columns.find((column2) => column2.name === columnName);
|
|
2570
|
+
if (column) {
|
|
2571
|
+
if (phase === "resize") {
|
|
2572
|
+
if ((0, import_vuu_utils15.isValidNumber)(width)) {
|
|
2573
|
+
setColumnSize(columnName, width);
|
|
2574
|
+
}
|
|
2575
|
+
} else if (phase === "end") {
|
|
2576
|
+
if ((0, import_vuu_utils15.isValidNumber)(width)) {
|
|
2577
|
+
dispatchColumnAction({
|
|
2578
|
+
type: "resizeColumn",
|
|
2579
|
+
phase,
|
|
2580
|
+
column,
|
|
2581
|
+
width
|
|
2582
|
+
});
|
|
2583
|
+
setStateColumns(void 0);
|
|
2584
|
+
onConfigChange == null ? void 0 : onConfigChange(
|
|
2585
|
+
stripInternalProperties(
|
|
2586
|
+
updateTableConfig(tableConfig, {
|
|
2587
|
+
type: "col-size",
|
|
2588
|
+
column,
|
|
2589
|
+
width
|
|
2590
|
+
})
|
|
2591
|
+
)
|
|
2592
|
+
);
|
|
2593
|
+
}
|
|
2594
|
+
} else {
|
|
2595
|
+
setStateColumns(void 0);
|
|
2596
|
+
dispatchColumnAction({
|
|
2597
|
+
type: "resizeColumn",
|
|
2598
|
+
phase,
|
|
2599
|
+
column,
|
|
2600
|
+
width
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
} else {
|
|
2604
|
+
throw Error(
|
|
2605
|
+
`useDataTable.handleColumnResize, column ${columnName} not found`
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
[columns, tableConfig, dispatchColumnAction, onConfigChange, setColumnSize]
|
|
2610
|
+
);
|
|
2611
|
+
const onToggleGroup = (0, import_react23.useCallback)(
|
|
2612
|
+
(row, column) => {
|
|
2613
|
+
const isJson = (0, import_vuu_utils15.isJsonGroup)(column, row);
|
|
2614
|
+
const key = row[KEY];
|
|
2615
|
+
if (row[IS_EXPANDED2]) {
|
|
2616
|
+
dataSource.closeTreeNode(key, true);
|
|
2617
|
+
if (isJson) {
|
|
2618
|
+
const idx = columns.indexOf(column);
|
|
2619
|
+
const rows = dataSource.getRowsAtDepth(idx + 1);
|
|
2620
|
+
if (!rows.some((row2) => row2[IS_EXPANDED2] || row2[IS_LEAF2])) {
|
|
2621
|
+
dispatchColumnAction({
|
|
2622
|
+
type: "hideColumns",
|
|
2623
|
+
columns: columns.slice(idx + 2)
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
} else {
|
|
2628
|
+
dataSource.openTreeNode(key);
|
|
2629
|
+
if (isJson) {
|
|
2630
|
+
const childRows = dataSource.getChildRows(key);
|
|
2631
|
+
const idx = columns.indexOf(column) + 1;
|
|
2632
|
+
const columnsToShow = [columns[idx]];
|
|
2633
|
+
if (childRows.some((row2) => row2[IS_LEAF2])) {
|
|
2634
|
+
columnsToShow.push(columns[idx + 1]);
|
|
2635
|
+
}
|
|
2636
|
+
if (columnsToShow.some((col) => col.hidden)) {
|
|
2637
|
+
dispatchColumnAction({
|
|
2638
|
+
type: "showColumns",
|
|
2639
|
+
columns: columnsToShow
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
},
|
|
2645
|
+
[columns, dataSource, dispatchColumnAction]
|
|
2646
|
+
);
|
|
2647
|
+
const { onVerticalScroll } = useVirtualViewport({
|
|
2648
|
+
columns,
|
|
2649
|
+
getRowAtPosition,
|
|
2650
|
+
setRange,
|
|
2651
|
+
viewportMeasurements
|
|
2652
|
+
});
|
|
2653
|
+
const handleVerticalScroll = (0, import_react23.useCallback)(
|
|
2654
|
+
(scrollTop) => {
|
|
2655
|
+
onVerticalScroll(scrollTop);
|
|
2656
|
+
},
|
|
2657
|
+
[onVerticalScroll]
|
|
2658
|
+
);
|
|
2659
|
+
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2660
|
+
maxScrollLeft: viewportMeasurements.maxScrollContainerScrollHorizontal,
|
|
2661
|
+
maxScrollTop: viewportMeasurements.maxScrollContainerScrollVertical,
|
|
2662
|
+
rowHeight,
|
|
2663
|
+
onVerticalScroll: handleVerticalScroll,
|
|
2664
|
+
viewportRowCount: viewportMeasurements.rowCount
|
|
2665
|
+
});
|
|
2666
|
+
const {
|
|
2667
|
+
highlightedIndexRef,
|
|
2668
|
+
navigate,
|
|
2669
|
+
onFocus: navigationFocus,
|
|
2670
|
+
onKeyDown: navigationKeyDown,
|
|
2671
|
+
...containerProps
|
|
2672
|
+
} = useKeyboardNavigation({
|
|
2673
|
+
columnCount: columns.filter((c) => c.hidden !== true).length,
|
|
2674
|
+
containerRef,
|
|
2675
|
+
disableFocus,
|
|
2676
|
+
highlightedIndex: highlightedIndexProp,
|
|
2677
|
+
navigationStyle,
|
|
2678
|
+
requestScroll,
|
|
2679
|
+
rowCount: dataSource == null ? void 0 : dataSource.size,
|
|
2680
|
+
onHighlight,
|
|
2681
|
+
viewportRange: range,
|
|
2682
|
+
viewportRowCount: viewportMeasurements.rowCount
|
|
2683
|
+
});
|
|
2684
|
+
const {
|
|
2685
|
+
onBlur: editingBlur,
|
|
2686
|
+
onDoubleClick: editingDoubleClick,
|
|
2687
|
+
onKeyDown: editingKeyDown,
|
|
2688
|
+
onFocus: editingFocus
|
|
2689
|
+
} = useCellEditing({
|
|
2690
|
+
navigate
|
|
2691
|
+
});
|
|
2692
|
+
const handleFocus = (0, import_react23.useCallback)(
|
|
2693
|
+
(e) => {
|
|
2694
|
+
navigationFocus();
|
|
2695
|
+
if (!e.defaultPrevented) {
|
|
2696
|
+
editingFocus(e);
|
|
2697
|
+
}
|
|
2698
|
+
},
|
|
2699
|
+
[editingFocus, navigationFocus]
|
|
2700
|
+
);
|
|
2701
|
+
const onContextMenu = useTableContextMenu({
|
|
2702
|
+
columns,
|
|
2703
|
+
data,
|
|
2704
|
+
dataSource,
|
|
2705
|
+
getSelectedRows
|
|
2706
|
+
});
|
|
2707
|
+
const onMoveGroupColumn = (0, import_react23.useCallback)(
|
|
2708
|
+
(columns2) => {
|
|
2709
|
+
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2710
|
+
},
|
|
2711
|
+
[dataSource]
|
|
2712
|
+
);
|
|
2713
|
+
const onRemoveGroupColumn = (0, import_react23.useCallback)(
|
|
2714
|
+
(column) => {
|
|
2715
|
+
if ((0, import_vuu_utils15.isGroupColumn)(column)) {
|
|
2716
|
+
dataSource.groupBy = [];
|
|
2717
|
+
} else {
|
|
2718
|
+
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
2719
|
+
dataSource.groupBy = dataSource.groupBy.filter(
|
|
2720
|
+
(columnName) => columnName !== column.name
|
|
2721
|
+
);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
},
|
|
2725
|
+
[dataSource]
|
|
2726
|
+
);
|
|
2727
|
+
const handleSelectionChange = (0, import_react23.useCallback)(
|
|
2728
|
+
(selected) => {
|
|
2729
|
+
dataSource.select(selected);
|
|
2730
|
+
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
2731
|
+
},
|
|
2732
|
+
[dataSource, onSelectionChange]
|
|
2733
|
+
);
|
|
2734
|
+
const {
|
|
2735
|
+
onKeyDown: selectionHookKeyDown,
|
|
2736
|
+
onRowClick: selectionHookOnRowClick
|
|
2737
|
+
} = useSelection({
|
|
2738
|
+
highlightedIndexRef,
|
|
2739
|
+
onSelect,
|
|
2740
|
+
onSelectionChange: handleSelectionChange,
|
|
2741
|
+
selectionModel
|
|
2742
|
+
});
|
|
2743
|
+
const handleKeyDown = (0, import_react23.useCallback)(
|
|
2744
|
+
(e) => {
|
|
2745
|
+
navigationKeyDown(e);
|
|
2746
|
+
if (!e.defaultPrevented) {
|
|
2747
|
+
editingKeyDown(e);
|
|
2748
|
+
}
|
|
2749
|
+
if (!e.defaultPrevented) {
|
|
2750
|
+
selectionHookKeyDown(e);
|
|
2751
|
+
}
|
|
2752
|
+
},
|
|
2753
|
+
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2754
|
+
);
|
|
2755
|
+
const handleRowClick = (0, import_react23.useCallback)(
|
|
2756
|
+
(row, rangeSelect, keepExistingSelection) => {
|
|
2757
|
+
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2758
|
+
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
2759
|
+
},
|
|
2760
|
+
[onRowClickProp, selectionHookOnRowClick]
|
|
2761
|
+
);
|
|
2762
|
+
(0, import_vuu_layout2.useLayoutEffectSkipFirst)(() => {
|
|
2763
|
+
dispatchColumnAction({
|
|
2764
|
+
type: "init",
|
|
2765
|
+
tableConfig: config,
|
|
2766
|
+
dataSource
|
|
2767
|
+
});
|
|
2768
|
+
}, [config, dataSource, dispatchColumnAction]);
|
|
2769
|
+
const onMoveColumn = (0, import_react23.useCallback)(
|
|
2770
|
+
(columns2) => {
|
|
2771
|
+
const newTableConfig = {
|
|
2772
|
+
...tableConfig,
|
|
2773
|
+
columns: columns2
|
|
2774
|
+
};
|
|
2775
|
+
dispatchColumnAction({
|
|
2776
|
+
type: "init",
|
|
2777
|
+
tableConfig: newTableConfig,
|
|
2778
|
+
dataSource
|
|
2779
|
+
});
|
|
2780
|
+
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(newTableConfig));
|
|
2781
|
+
},
|
|
2782
|
+
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2783
|
+
);
|
|
2784
|
+
const handleDropRow = (0, import_react23.useCallback)(
|
|
2785
|
+
(dragDropState) => {
|
|
2786
|
+
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2787
|
+
},
|
|
2788
|
+
[onDrop]
|
|
2789
|
+
);
|
|
2790
|
+
const handleDataEdited = (0, import_react23.useCallback)(
|
|
2791
|
+
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2792
|
+
[dataSource]
|
|
2793
|
+
);
|
|
2794
|
+
const handleDragStartRow = (0, import_react23.useCallback)(
|
|
2795
|
+
(dragDropState) => {
|
|
2796
|
+
const { initialDragElement } = dragDropState;
|
|
2797
|
+
const rowIndex = initialDragElement.ariaRowIndex;
|
|
2798
|
+
if (rowIndex) {
|
|
2799
|
+
const index = parseInt(rowIndex);
|
|
2800
|
+
const row = dataRef.current.find((row2) => row2[0] === index);
|
|
2801
|
+
if (row) {
|
|
2802
|
+
dragDropState.setPayload(row);
|
|
2803
|
+
} else {
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
onDragStart == null ? void 0 : onDragStart(dragDropState);
|
|
2807
|
+
},
|
|
2808
|
+
[dataRef, onDragStart]
|
|
2809
|
+
);
|
|
2810
|
+
const { onMouseDown: rowDragMouseDown, draggable: draggableRow } = useRowDragDrop({
|
|
2811
|
+
allowDragDrop,
|
|
2812
|
+
containerRef,
|
|
2813
|
+
draggableClassName: `vuuTable`,
|
|
2814
|
+
id,
|
|
2815
|
+
onDragStart: handleDragStartRow,
|
|
2816
|
+
onDrop: handleDropRow,
|
|
2817
|
+
orientation: "vertical",
|
|
2818
|
+
itemQuery: ".vuuTableRow"
|
|
2819
|
+
});
|
|
2820
|
+
return {
|
|
2821
|
+
...containerProps,
|
|
2822
|
+
draggableRow,
|
|
2823
|
+
onBlur: editingBlur,
|
|
2824
|
+
onDoubleClick: editingDoubleClick,
|
|
2825
|
+
onFocus: handleFocus,
|
|
2826
|
+
onKeyDown: handleKeyDown,
|
|
2827
|
+
onMouseDown: rowDragMouseDown,
|
|
2828
|
+
columnMap,
|
|
2829
|
+
columns,
|
|
2830
|
+
data,
|
|
2831
|
+
handleContextMenuAction,
|
|
2832
|
+
headings,
|
|
2833
|
+
highlightedIndex: highlightedIndexRef.current,
|
|
2834
|
+
menuBuilder,
|
|
2835
|
+
onContextMenu,
|
|
2836
|
+
onDataEdited: handleDataEdited,
|
|
2837
|
+
onMoveColumn,
|
|
2838
|
+
onMoveGroupColumn,
|
|
2839
|
+
onRemoveGroupColumn,
|
|
2840
|
+
onRowClick: handleRowClick,
|
|
2841
|
+
onSortColumn: handleSort,
|
|
2842
|
+
onResizeColumn,
|
|
2843
|
+
onToggleGroup,
|
|
2844
|
+
scrollProps,
|
|
2845
|
+
// TODO don't think we need these ...
|
|
2846
|
+
tableAttributes,
|
|
2847
|
+
tableConfig,
|
|
2848
|
+
viewportMeasurements
|
|
2849
|
+
};
|
|
2850
|
+
};
|
|
2851
|
+
|
|
2852
|
+
// src/table-header/TableHeader.tsx
|
|
2853
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
2854
|
+
var import_classnames8 = __toESM(require("classnames"));
|
|
2855
|
+
|
|
2856
|
+
// src/table-header/useTableHeader.ts
|
|
2857
|
+
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
2858
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
2859
|
+
var import_react24 = require("react");
|
|
2860
|
+
var useTableHeader = ({
|
|
2861
|
+
columns,
|
|
2862
|
+
onMoveColumn,
|
|
2863
|
+
onSortColumn,
|
|
2864
|
+
tableConfig
|
|
2865
|
+
}) => {
|
|
2866
|
+
const containerRef = (0, import_react24.useRef)(null);
|
|
2867
|
+
const handleDropColumnHeader = (0, import_react24.useCallback)(
|
|
2868
|
+
(moveFrom, moveTo) => {
|
|
2869
|
+
const column = columns[moveFrom];
|
|
2870
|
+
const orderedColumns = (0, import_vuu_utils16.moveColumnTo)(columns, column, moveTo);
|
|
2871
|
+
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
2872
|
+
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
2873
|
+
const nextColumn = orderedColumns[targetIndex + 1];
|
|
2874
|
+
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
2875
|
+
onMoveColumn((0, import_vuu_utils16.moveColumnTo)(tableConfig.columns, column, insertPos));
|
|
2876
|
+
},
|
|
2877
|
+
[columns, onMoveColumn, tableConfig.columns]
|
|
2878
|
+
);
|
|
2879
|
+
const handleColumnHeaderClick = (0, import_react24.useCallback)(
|
|
2880
|
+
(evt) => {
|
|
2881
|
+
var _a;
|
|
2882
|
+
const targetElement = evt.target;
|
|
2883
|
+
const headerCell = targetElement.closest(
|
|
2884
|
+
".vuuTableHeaderCell"
|
|
2885
|
+
);
|
|
2886
|
+
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
2887
|
+
const column = (0, import_vuu_utils16.visibleColumnAtIndex)(columns, colIdx);
|
|
2888
|
+
const isAdditive = evt.shiftKey;
|
|
2889
|
+
column && onSortColumn(column, isAdditive);
|
|
2890
|
+
},
|
|
2891
|
+
[columns, onSortColumn]
|
|
2892
|
+
);
|
|
2893
|
+
const {
|
|
2894
|
+
onMouseDown: columnHeaderDragMouseDown,
|
|
2895
|
+
draggable: draggableColumn,
|
|
2896
|
+
...dragDropHook
|
|
2897
|
+
} = (0, import_vuu_ui_controls3.useDragDropNext)({
|
|
2898
|
+
allowDragDrop: true,
|
|
2899
|
+
containerRef,
|
|
2900
|
+
draggableClassName: `vuuTable`,
|
|
2901
|
+
onDrop: handleDropColumnHeader,
|
|
2902
|
+
orientation: "horizontal",
|
|
2903
|
+
itemQuery: ".vuuTableHeaderCell"
|
|
2904
|
+
});
|
|
2905
|
+
return {
|
|
2906
|
+
containerRef,
|
|
2907
|
+
draggableColumn,
|
|
2908
|
+
draggedColumnIndex: dragDropHook.draggedItemIndex,
|
|
2909
|
+
onClick: handleColumnHeaderClick,
|
|
2910
|
+
onMouseDown: columnHeaderDragMouseDown
|
|
2911
|
+
};
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
// src/table-header/TableHeader.tsx
|
|
2915
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2916
|
+
var TableHeader = ({
|
|
2917
|
+
classBase: classBase11 = "vuuTable",
|
|
2918
|
+
columns,
|
|
2919
|
+
headings,
|
|
2920
|
+
onMoveColumn,
|
|
2921
|
+
onMoveGroupColumn,
|
|
2922
|
+
onRemoveGroupColumn,
|
|
2923
|
+
onResizeColumn,
|
|
2924
|
+
onSortColumn,
|
|
2925
|
+
tableConfig,
|
|
2926
|
+
tableId
|
|
2927
|
+
}) => {
|
|
2928
|
+
const {
|
|
2929
|
+
containerRef,
|
|
2930
|
+
draggableColumn,
|
|
2931
|
+
draggedColumnIndex,
|
|
2932
|
+
onClick,
|
|
2933
|
+
onMouseDown
|
|
2934
|
+
} = useTableHeader({
|
|
2935
|
+
columns,
|
|
2936
|
+
onMoveColumn,
|
|
2937
|
+
onSortColumn,
|
|
2938
|
+
tableConfig
|
|
2939
|
+
});
|
|
2940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase11}-col-headings`, ref: containerRef, children: [
|
|
2941
|
+
headings.map((colHeaders, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
|
|
2942
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase11}-col-headers`, role: "row", children: [
|
|
2943
|
+
columns.filter(import_vuu_utils17.isNotHidden).map(
|
|
2944
|
+
(col, i) => (0, import_vuu_utils17.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2945
|
+
GroupHeaderCellNext,
|
|
2946
|
+
{
|
|
2947
|
+
column: col,
|
|
2948
|
+
"data-index": i,
|
|
2949
|
+
onMoveColumn: onMoveGroupColumn,
|
|
2950
|
+
onRemoveColumn: onRemoveGroupColumn,
|
|
2951
|
+
onResize: onResizeColumn
|
|
2952
|
+
},
|
|
2953
|
+
col.name
|
|
2954
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2955
|
+
HeaderCell,
|
|
2956
|
+
{
|
|
2957
|
+
className: (0, import_classnames8.default)({
|
|
2958
|
+
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
2959
|
+
}),
|
|
2960
|
+
column: col,
|
|
2961
|
+
"data-index": i,
|
|
2962
|
+
id: `${tableId}-col-${i}`,
|
|
2963
|
+
onClick,
|
|
2964
|
+
onMouseDown,
|
|
2965
|
+
onResize: onResizeColumn
|
|
2966
|
+
},
|
|
2967
|
+
col.name
|
|
2968
|
+
)
|
|
2969
|
+
),
|
|
2970
|
+
draggableColumn
|
|
2971
|
+
] })
|
|
2972
|
+
] });
|
|
2973
|
+
};
|
|
2974
|
+
|
|
2975
|
+
// src/Table.tsx
|
|
2976
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2977
|
+
var classBase7 = "vuuTable";
|
|
2978
|
+
var { IDX: IDX3, RENDER_IDX } = import_vuu_utils18.metadataKeys;
|
|
2979
|
+
var TableCore = ({
|
|
2980
|
+
Row: Row2 = Row,
|
|
2981
|
+
allowDragDrop,
|
|
2982
|
+
availableColumns,
|
|
2983
|
+
config,
|
|
2984
|
+
containerRef,
|
|
2985
|
+
dataSource,
|
|
2986
|
+
disableFocus = false,
|
|
2987
|
+
highlightedIndex: highlightedIndexProp,
|
|
2988
|
+
id: idProp,
|
|
2989
|
+
navigationStyle = "cell",
|
|
2990
|
+
onAvailableColumnsChange,
|
|
2991
|
+
onConfigChange,
|
|
2992
|
+
onDragStart,
|
|
2993
|
+
onDrop,
|
|
2994
|
+
onFeatureInvocation,
|
|
2995
|
+
onHighlight,
|
|
2996
|
+
onRowClick: onRowClickProp,
|
|
2997
|
+
onSelect,
|
|
2998
|
+
onSelectionChange,
|
|
2999
|
+
renderBufferSize = 0,
|
|
3000
|
+
rowHeight = 20,
|
|
3001
|
+
selectionModel = "extended",
|
|
3002
|
+
showColumnHeaders = true,
|
|
3003
|
+
headerHeight = showColumnHeaders ? 25 : 0,
|
|
3004
|
+
size
|
|
3005
|
+
}) => {
|
|
3006
|
+
const id = (0, import_vuu_layout3.useId)(idProp);
|
|
3007
|
+
const {
|
|
3008
|
+
columnMap,
|
|
3009
|
+
columns,
|
|
3010
|
+
data,
|
|
3011
|
+
draggableRow,
|
|
3012
|
+
handleContextMenuAction,
|
|
3013
|
+
headings,
|
|
3014
|
+
highlightedIndex,
|
|
3015
|
+
onDataEdited,
|
|
3016
|
+
onMoveColumn,
|
|
3017
|
+
onMoveGroupColumn,
|
|
3018
|
+
onRemoveGroupColumn,
|
|
3019
|
+
onResizeColumn,
|
|
3020
|
+
onRowClick,
|
|
3021
|
+
onSortColumn,
|
|
3022
|
+
onToggleGroup,
|
|
3023
|
+
menuBuilder,
|
|
3024
|
+
scrollProps,
|
|
3025
|
+
tableAttributes,
|
|
3026
|
+
tableConfig,
|
|
3027
|
+
viewportMeasurements,
|
|
3028
|
+
...tableProps
|
|
3029
|
+
} = useTable({
|
|
3030
|
+
allowDragDrop,
|
|
3031
|
+
availableColumns,
|
|
3032
|
+
config,
|
|
3033
|
+
containerRef,
|
|
3034
|
+
dataSource,
|
|
3035
|
+
disableFocus,
|
|
3036
|
+
headerHeight,
|
|
3037
|
+
highlightedIndex: highlightedIndexProp,
|
|
3038
|
+
id,
|
|
3039
|
+
navigationStyle,
|
|
3040
|
+
onAvailableColumnsChange,
|
|
3041
|
+
onConfigChange,
|
|
3042
|
+
onDragStart,
|
|
3043
|
+
onDrop,
|
|
3044
|
+
onFeatureInvocation,
|
|
3045
|
+
onHighlight,
|
|
3046
|
+
onRowClick: onRowClickProp,
|
|
3047
|
+
onSelect,
|
|
3048
|
+
onSelectionChange,
|
|
3049
|
+
renderBufferSize,
|
|
3050
|
+
rowHeight,
|
|
3051
|
+
selectionModel,
|
|
3052
|
+
size
|
|
3053
|
+
});
|
|
3054
|
+
const className = (0, import_classnames9.default)(`${classBase7}-contentContainer`, {
|
|
3055
|
+
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3056
|
+
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3057
|
+
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
3058
|
+
[`${classBase7}-zebra`]: tableAttributes.zebraStripes
|
|
3059
|
+
// [`${classBase}-loading`]: isDataLoading(tableProps.columns),
|
|
3060
|
+
});
|
|
3061
|
+
const cssVariables = {
|
|
3062
|
+
"--content-height": `${viewportMeasurements.contentHeight}px`,
|
|
3063
|
+
"--content-width": `${viewportMeasurements.contentWidth}px`,
|
|
3064
|
+
"--horizontal-scrollbar-height": `${viewportMeasurements.horizontalScrollbarHeight}px`,
|
|
3065
|
+
"--pinned-width-left": `${viewportMeasurements.pinnedWidthLeft}px`,
|
|
3066
|
+
"--pinned-width-right": `${viewportMeasurements.pinnedWidthRight}px`,
|
|
3067
|
+
"--header-height": `${headerHeight}px`,
|
|
3068
|
+
"--row-height": `${rowHeight}px`,
|
|
3069
|
+
"--total-header-height": `${viewportMeasurements.totalHeaderHeight}px`,
|
|
3070
|
+
"--vertical-scrollbar-width": `${viewportMeasurements.verticalScrollbarWidth}px`,
|
|
3071
|
+
"--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
|
|
3072
|
+
};
|
|
3073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3074
|
+
import_vuu_popups3.ContextMenuProvider,
|
|
3075
|
+
{
|
|
3076
|
+
menuActionHandler: handleContextMenuAction,
|
|
3077
|
+
menuBuilder,
|
|
3078
|
+
children: [
|
|
3079
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3080
|
+
"div",
|
|
3081
|
+
{
|
|
3082
|
+
className: `${classBase7}-scrollbarContainer`,
|
|
3083
|
+
ref: scrollProps.scrollbarContainerRef,
|
|
3084
|
+
style: cssVariables,
|
|
3085
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase7}-scrollbarContent` })
|
|
3086
|
+
}
|
|
3087
|
+
),
|
|
3088
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3089
|
+
"div",
|
|
3090
|
+
{
|
|
3091
|
+
className,
|
|
3092
|
+
ref: scrollProps.contentContainerRef,
|
|
3093
|
+
style: cssVariables,
|
|
3094
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3095
|
+
"div",
|
|
3096
|
+
{
|
|
3097
|
+
...tableProps,
|
|
3098
|
+
className: `${classBase7}-table`,
|
|
3099
|
+
tabIndex: disableFocus ? void 0 : -1,
|
|
3100
|
+
children: [
|
|
3101
|
+
showColumnHeaders ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3102
|
+
TableHeader,
|
|
3103
|
+
{
|
|
3104
|
+
columns,
|
|
3105
|
+
headings,
|
|
3106
|
+
onMoveColumn,
|
|
3107
|
+
onMoveGroupColumn,
|
|
3108
|
+
onRemoveGroupColumn,
|
|
3109
|
+
onResizeColumn,
|
|
3110
|
+
onSortColumn,
|
|
3111
|
+
tableConfig,
|
|
3112
|
+
tableId: id
|
|
3113
|
+
}
|
|
3114
|
+
) : null,
|
|
3115
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase7}-body`, children: data.map((data2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3116
|
+
Row2,
|
|
3117
|
+
{
|
|
3118
|
+
columnMap,
|
|
3119
|
+
columns,
|
|
3120
|
+
highlighted: highlightedIndex === data2[IDX3],
|
|
3121
|
+
onClick: onRowClick,
|
|
3122
|
+
onDataEdited,
|
|
3123
|
+
row: data2,
|
|
3124
|
+
offset: rowHeight * data2[IDX3] + viewportMeasurements.totalHeaderHeight,
|
|
3125
|
+
onToggleGroup,
|
|
3126
|
+
zebraStripes: tableAttributes.zebraStripes
|
|
3127
|
+
},
|
|
3128
|
+
data2[RENDER_IDX]
|
|
3129
|
+
)) })
|
|
3130
|
+
]
|
|
3131
|
+
}
|
|
3132
|
+
)
|
|
3133
|
+
}
|
|
3134
|
+
),
|
|
3135
|
+
draggableRow
|
|
3136
|
+
]
|
|
3137
|
+
}
|
|
3138
|
+
);
|
|
3139
|
+
};
|
|
3140
|
+
var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
3141
|
+
Row: Row2,
|
|
3142
|
+
allowDragDrop,
|
|
3143
|
+
availableColumns,
|
|
3144
|
+
className: classNameProp,
|
|
3145
|
+
config,
|
|
3146
|
+
dataSource,
|
|
3147
|
+
disableFocus,
|
|
3148
|
+
highlightedIndex,
|
|
3149
|
+
id,
|
|
3150
|
+
navigationStyle,
|
|
3151
|
+
onAvailableColumnsChange,
|
|
3152
|
+
onConfigChange,
|
|
3153
|
+
onDragStart,
|
|
3154
|
+
onDrop,
|
|
3155
|
+
onFeatureInvocation,
|
|
3156
|
+
onHighlight,
|
|
3157
|
+
onRowClick,
|
|
3158
|
+
onSelect,
|
|
3159
|
+
onSelectionChange,
|
|
3160
|
+
renderBufferSize,
|
|
3161
|
+
rowHeight,
|
|
3162
|
+
selectionModel,
|
|
3163
|
+
showColumnHeaders,
|
|
3164
|
+
headerHeight,
|
|
3165
|
+
style: styleProp,
|
|
3166
|
+
...htmlAttributes
|
|
3167
|
+
}, forwardedRef) {
|
|
3168
|
+
const containerRef = (0, import_react25.useRef)(null);
|
|
3169
|
+
const [size, setSize] = (0, import_react25.useState)();
|
|
3170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3171
|
+
import_vuu_layout3.MeasuredContainer,
|
|
3172
|
+
{
|
|
3173
|
+
...htmlAttributes,
|
|
3174
|
+
className: (0, import_classnames9.default)(classBase7, classNameProp),
|
|
3175
|
+
id,
|
|
3176
|
+
onResize: setSize,
|
|
3177
|
+
ref: (0, import_core2.useForkRef)(containerRef, forwardedRef),
|
|
3178
|
+
children: size ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3179
|
+
TableCore,
|
|
3180
|
+
{
|
|
3181
|
+
Row: Row2,
|
|
3182
|
+
allowDragDrop,
|
|
3183
|
+
availableColumns,
|
|
3184
|
+
config,
|
|
3185
|
+
containerRef,
|
|
3186
|
+
dataSource,
|
|
3187
|
+
disableFocus,
|
|
3188
|
+
headerHeight,
|
|
3189
|
+
highlightedIndex,
|
|
3190
|
+
id,
|
|
3191
|
+
navigationStyle,
|
|
3192
|
+
onAvailableColumnsChange,
|
|
3193
|
+
onConfigChange,
|
|
3194
|
+
onDragStart,
|
|
3195
|
+
onDrop,
|
|
3196
|
+
onFeatureInvocation,
|
|
3197
|
+
onHighlight,
|
|
3198
|
+
onRowClick,
|
|
3199
|
+
onSelect,
|
|
3200
|
+
onSelectionChange,
|
|
3201
|
+
renderBufferSize,
|
|
3202
|
+
rowHeight,
|
|
3203
|
+
selectionModel,
|
|
3204
|
+
showColumnHeaders,
|
|
3205
|
+
size
|
|
3206
|
+
}
|
|
3207
|
+
) : null
|
|
3208
|
+
}
|
|
3209
|
+
);
|
|
3210
|
+
});
|
|
3211
|
+
|
|
3212
|
+
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3213
|
+
var import_react26 = require("react");
|
|
3214
|
+
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
3215
|
+
var import_core3 = require("@salt-ds/core");
|
|
3216
|
+
|
|
3217
|
+
// src/cell-renderers/cell-utils.ts
|
|
3218
|
+
var dataAndColumnUnchanged = (p, p1) => p.column === p1.column && p.row[p.columnMap[p.column.name]] === p1.row[p1.columnMap[p1.column.name]];
|
|
3219
|
+
|
|
3220
|
+
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3221
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
3222
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3223
|
+
var CheckboxCell = (0, import_react26.memo)(
|
|
3224
|
+
({ column, columnMap, onCommit = import_vuu_ui_controls4.WarnCommit, row }) => {
|
|
3225
|
+
const dataIdx = columnMap[column.name];
|
|
3226
|
+
const isChecked = row[dataIdx];
|
|
3227
|
+
const handleCommit = (0, import_react26.useCallback)(
|
|
3228
|
+
(value) => async (evt) => {
|
|
3229
|
+
const res = await onCommit(value);
|
|
3230
|
+
if (res === true) {
|
|
3231
|
+
(0, import_vuu_utils19.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3232
|
+
}
|
|
3233
|
+
return res;
|
|
3234
|
+
},
|
|
3235
|
+
[onCommit]
|
|
3236
|
+
);
|
|
3237
|
+
return !!column.editable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core3.Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_vuu_ui_controls4.CheckboxIcon, { checked: isChecked, disabled: true });
|
|
3238
|
+
},
|
|
3239
|
+
dataAndColumnUnchanged
|
|
3240
|
+
);
|
|
3241
|
+
CheckboxCell.displayName = "CheckboxCell";
|
|
3242
|
+
(0, import_vuu_utils19.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
|
|
3243
|
+
serverDataType: "boolean"
|
|
3244
|
+
});
|
|
3245
|
+
|
|
3246
|
+
// src/cell-renderers/dropdown-cell/DropdownCell.tsx
|
|
3247
|
+
var import_vuu_data_react = require("@vuu-ui/vuu-data-react");
|
|
3248
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
3249
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
3250
|
+
var import_react27 = require("react");
|
|
3251
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3252
|
+
var classBase8 = "vuuTableDropdownCell";
|
|
3253
|
+
var openKeys = ["Enter", " "];
|
|
3254
|
+
var DropdownCell = (0, import_react27.memo)(
|
|
3255
|
+
function DropdownCell2({
|
|
3256
|
+
column,
|
|
3257
|
+
columnMap,
|
|
3258
|
+
onCommit = import_vuu_ui_controls5.WarnCommit,
|
|
3259
|
+
row
|
|
3260
|
+
}) {
|
|
3261
|
+
const dataIdx = columnMap[column.name];
|
|
3262
|
+
const { initialValue, values } = (0, import_vuu_data_react.useLookupValues)(column, row[dataIdx]);
|
|
3263
|
+
const [value, setValue] = (0, import_react27.useState)(null);
|
|
3264
|
+
const handleSelectionChange = (0, import_react27.useCallback)(
|
|
3265
|
+
(evt, selectedOption) => {
|
|
3266
|
+
if (selectedOption) {
|
|
3267
|
+
setValue(selectedOption);
|
|
3268
|
+
onCommit(selectedOption.value).then((response) => {
|
|
3269
|
+
if (response === true && evt) {
|
|
3270
|
+
(0, import_vuu_utils20.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
},
|
|
3275
|
+
[onCommit]
|
|
3276
|
+
);
|
|
3277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3278
|
+
import_vuu_ui_controls5.Dropdown,
|
|
3279
|
+
{
|
|
3280
|
+
className: classBase8,
|
|
3281
|
+
onSelectionChange: handleSelectionChange,
|
|
3282
|
+
openKeys,
|
|
3283
|
+
selected: value != null ? value : initialValue,
|
|
3284
|
+
source: values,
|
|
3285
|
+
width: column.width - 17
|
|
3286
|
+
}
|
|
3287
|
+
);
|
|
3288
|
+
},
|
|
3289
|
+
dataAndColumnUnchanged
|
|
3290
|
+
);
|
|
3291
|
+
(0, import_vuu_utils20.registerComponent)("dropdown-cell", DropdownCell, "cell-renderer", {});
|
|
3292
|
+
|
|
3293
|
+
// src/cell-renderers/input-cell/InputCell.tsx
|
|
3294
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
3295
|
+
var import_core4 = require("@salt-ds/core");
|
|
3296
|
+
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
3297
|
+
var import_classnames10 = __toESM(require("classnames"));
|
|
3298
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3299
|
+
var classBase9 = "vuuTableInputCell";
|
|
3300
|
+
var WarnCommit3 = () => {
|
|
3301
|
+
console.warn(
|
|
3302
|
+
"onCommit handler has not been provided to InputCell cell renderer"
|
|
3303
|
+
);
|
|
3304
|
+
return Promise.resolve(true);
|
|
3305
|
+
};
|
|
3306
|
+
var InputCell = ({
|
|
3307
|
+
column,
|
|
3308
|
+
columnMap,
|
|
3309
|
+
onCommit = WarnCommit3,
|
|
3310
|
+
row
|
|
3311
|
+
}) => {
|
|
3312
|
+
const dataIdx = columnMap[column.name];
|
|
3313
|
+
const {
|
|
3314
|
+
align = "left",
|
|
3315
|
+
clientSideEditValidationCheck,
|
|
3316
|
+
valueFormatter
|
|
3317
|
+
} = column;
|
|
3318
|
+
const { warningMessage, ...editProps } = (0, import_vuu_ui_controls6.useEditableText)({
|
|
3319
|
+
initialValue: valueFormatter(row[dataIdx]),
|
|
3320
|
+
onCommit,
|
|
3321
|
+
clientSideEditValidationCheck
|
|
3322
|
+
});
|
|
3323
|
+
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `${classBase9}-icon`, "data-icon": "error" }) : void 0;
|
|
3324
|
+
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `${classBase9}-icon`, "data-icon": "error" }) : void 0;
|
|
3325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3326
|
+
import_core4.Input,
|
|
3327
|
+
{
|
|
3328
|
+
...editProps,
|
|
3329
|
+
className: (0, import_classnames10.default)(classBase9, {
|
|
3330
|
+
[`${classBase9}-error`]: warningMessage !== void 0
|
|
3331
|
+
}),
|
|
3332
|
+
endAdornment,
|
|
3333
|
+
startAdornment
|
|
3334
|
+
}
|
|
3335
|
+
);
|
|
3336
|
+
};
|
|
3337
|
+
(0, import_vuu_utils21.registerComponent)("input-cell", InputCell, "cell-renderer", {});
|
|
3338
|
+
|
|
3339
|
+
// src/cell-renderers/lookup-cell/LookupCell.tsx
|
|
3340
|
+
var import_vuu_data_react2 = require("@vuu-ui/vuu-data-react");
|
|
3341
|
+
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
3342
|
+
var import_react28 = require("react");
|
|
3343
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3344
|
+
var LookupCell = (0, import_react28.memo)(
|
|
3345
|
+
function LookupCell2({
|
|
3346
|
+
column,
|
|
3347
|
+
columnMap,
|
|
3348
|
+
row
|
|
3349
|
+
}) {
|
|
3350
|
+
const dataIdx = columnMap[column.name];
|
|
3351
|
+
const { initialValue: value } = (0, import_vuu_data_react2.useLookupValues)(column, row[dataIdx]);
|
|
3352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: value == null ? void 0 : value.label });
|
|
3353
|
+
},
|
|
3354
|
+
dataAndColumnUnchanged
|
|
3355
|
+
);
|
|
3356
|
+
(0, import_vuu_utils22.registerComponent)("lookup-cell", LookupCell, "cell-renderer", {});
|
|
3357
|
+
|
|
3358
|
+
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3359
|
+
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3360
|
+
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3361
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
3362
|
+
var import_react29 = require("react");
|
|
3363
|
+
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3364
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3365
|
+
var classBase10 = "vuuTableToggleCell";
|
|
3366
|
+
var getValueList = ({ name, type }) => {
|
|
3367
|
+
if ((0, import_vuu_utils23.isTypeDescriptor)(type) && (0, import_vuu_utils23.isValueListRenderer)(type.renderer)) {
|
|
3368
|
+
return type.renderer.values;
|
|
3369
|
+
} else {
|
|
3370
|
+
throw Error(
|
|
3371
|
+
`useLookupValues column ${name} has not been configured with a values list`
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
};
|
|
3375
|
+
var ToggleCell = (0, import_react29.memo)(
|
|
3376
|
+
function ToggleCell2({
|
|
3377
|
+
column,
|
|
3378
|
+
columnMap,
|
|
3379
|
+
onCommit = import_vuu_ui_controls7.WarnCommit,
|
|
3380
|
+
row
|
|
3381
|
+
}) {
|
|
3382
|
+
const values = getValueList(column);
|
|
3383
|
+
const dataIdx = columnMap[column.name];
|
|
3384
|
+
const value = row[dataIdx];
|
|
3385
|
+
const handleCommit = (0, import_react29.useCallback)(
|
|
3386
|
+
(evt, value2) => {
|
|
3387
|
+
return onCommit(value2).then((response) => {
|
|
3388
|
+
if (response === true) {
|
|
3389
|
+
(0, import_vuu_utils23.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3390
|
+
}
|
|
3391
|
+
return response;
|
|
3392
|
+
});
|
|
3393
|
+
},
|
|
3394
|
+
[onCommit]
|
|
3395
|
+
);
|
|
3396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3397
|
+
import_vuu_ui_controls8.CycleStateButton,
|
|
3398
|
+
{
|
|
3399
|
+
className: (0, import_classnames11.default)(classBase10, `${classBase10}-${column.name}`),
|
|
3400
|
+
onCommit: handleCommit,
|
|
3401
|
+
value,
|
|
3402
|
+
values,
|
|
3403
|
+
variant: "cta",
|
|
3404
|
+
children: value
|
|
3405
|
+
}
|
|
3406
|
+
);
|
|
3407
|
+
},
|
|
3408
|
+
dataAndColumnUnchanged
|
|
3409
|
+
);
|
|
3410
|
+
(0, import_vuu_utils23.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
3411
|
+
|
|
3412
|
+
// src/useControlledTableNavigation.ts
|
|
3413
|
+
var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
|
|
3414
|
+
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
3415
|
+
var import_react30 = require("react");
|
|
3416
|
+
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3417
|
+
const tableRef = (0, import_react30.useRef)(null);
|
|
3418
|
+
const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls9.useStateRef)(initialValue);
|
|
3419
|
+
const handleKeyDown = (0, import_react30.useCallback)(
|
|
3420
|
+
(e) => {
|
|
3421
|
+
var _a;
|
|
3422
|
+
if (e.key === "ArrowDown") {
|
|
3423
|
+
setHighlightedIndex((index = -1) => Math.min(rowCount - 1, index + 1));
|
|
3424
|
+
} else if (e.key === "ArrowUp") {
|
|
3425
|
+
setHighlightedIndex((index = -1) => Math.max(0, index - 1));
|
|
3426
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
3427
|
+
const { current: rowIdx } = highlightedIndexRef;
|
|
3428
|
+
const rowEl = (_a = tableRef.current) == null ? void 0 : _a.querySelector(
|
|
3429
|
+
`[aria-rowindex="${rowIdx}"]`
|
|
3430
|
+
);
|
|
3431
|
+
if (rowEl) {
|
|
3432
|
+
(0, import_vuu_utils24.dispatchMouseEvent)(rowEl, "click");
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
},
|
|
3436
|
+
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3437
|
+
);
|
|
3438
|
+
const handleHighlight = (0, import_react30.useCallback)(
|
|
3439
|
+
(idx) => {
|
|
3440
|
+
setHighlightedIndex(idx);
|
|
3441
|
+
},
|
|
3442
|
+
[setHighlightedIndex]
|
|
3443
|
+
);
|
|
3444
|
+
return {
|
|
3445
|
+
highlightedIndexRef,
|
|
3446
|
+
onHighlight: handleHighlight,
|
|
3447
|
+
onKeyDown: handleKeyDown,
|
|
3448
|
+
tableRef
|
|
3449
|
+
};
|
|
3450
|
+
};
|
|
2
3451
|
//# sourceMappingURL=index.js.map
|