@economic/taco 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/dist/components/Table3/Table3.d.ts +1 -1
  2. package/dist/components/Table3/components/columns/internal/Actions.d.ts +1 -2
  3. package/dist/components/Table3/components/rows/Row.d.ts +1 -0
  4. package/dist/components/Table3/hooks/features/useRowActions.d.ts +5 -0
  5. package/dist/components/Table3/hooks/useTable.d.ts +2 -0
  6. package/dist/components/Table3/hooks/useTableDataLoader.d.ts +1 -2
  7. package/dist/components/Table3/types.d.ts +0 -2
  8. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +3 -1
  9. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -2
  12. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +6 -15
  14. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +1 -1
  16. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +11 -2
  18. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +32 -20
  20. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowActions.js +10 -0
  22. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowActions.js.map +1 -0
  23. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +1 -1
  24. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +2 -3
  26. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +10 -9
  28. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableDataLoader.js +0 -8
  30. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableDataLoader.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js +4 -0
  32. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  34. package/dist/taco.cjs.development.js +79 -106
  35. package/dist/taco.cjs.development.js.map +1 -1
  36. package/dist/taco.cjs.production.min.js +1 -1
  37. package/dist/taco.cjs.production.min.js.map +1 -1
  38. package/package.json +2 -2
  39. package/types.json +5429 -5459
  40. package/dist/components/Table3/hooks/listeners/useSearchStateListener.d.ts +0 -3
  41. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSearchStateListener.js +0 -51
  42. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSearchStateListener.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/rows/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { Row as RTRow, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { RowContext, useRowContext } from './RowContext';\nimport { useDropTarget } from '../../../../utils/hooks/useDropTarget';\nimport { Table3RowClickHandler, Table3RowDropHandler } from '../../types';\nimport { useFocusManager } from '@react-aria/focus';\nimport { focusableSelector } from '../../util/editing';\n\ntype RowProps<TType = unknown> = Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop'> & {\n index: number;\n isLastRow: boolean;\n onClick?: Table3RowClickHandler<TType>;\n onDrop?: Table3RowDropHandler<TType>;\n row: RTRow<TType>;\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;\n const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];\n // we use non-css hovered state to determine whether to render actions or not, for performance\n const [isHovered, setIsHovered] = React.useState(false);\n\n // rows are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the row\n const memoedProps = {\n // aria-grabbed is being deprecated but there is no current alternative api, we use it until there is\n 'aria-grabbed': isDraggingRow ? true : tableMeta.rowDrag.isEnabled ? false : undefined,\n 'data-current': isCurrentRow,\n 'data-selected': props.row.getIsSelected(),\n draggable: tableMeta.rowDrag.isEnabled,\n index: props.index,\n onClick: tableMeta.rowClick.handleClick,\n onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,\n };\n\n let output = <MemoedRow<TType> {...props} {...memoedProps} />;\n\n if (tableMeta.editing.isEditing && (isCurrentRow || (isHovered && !tableMeta.hoverState.isPaused))) {\n output = (\n <EditingRow\n {...props}\n {...memoedProps}\n isLastRow={props.isLastRow}\n setCurrentRowIndex={tableMeta.currentRow.setCurrentRowIndex}\n />\n );\n }\n\n // we store the row index in context because in a virtualised table the row index and the\n // react table row index do not match when, for example, sorting is applied\n const contextValue = React.useMemo(() => ({ isHovered, setIsHovered, rowIndex: props.index }), [isHovered, props.index]);\n\n return <RowContext.Provider value={contextValue}>{output}</RowContext.Provider>;\n}\n\n// turns out we might need some kind of \"state\" for the focused column, but it doesn't need to be react state that re-renders\nlet lastIndex;\n\nfunction getColumnIndex(focusedElement: Element) {\n if (focusedElement) {\n return focusedElement.closest('[role=cell]')?.getAttribute('data-column-index');\n }\n\n return null;\n}\n\n// This code is needed to avoid multiple rows being hovered at the same time (it happens since we use non-css hovering)\nlet previouslyHoveredIndex: number | undefined;\nconst unhoverPreviousRow = (tableRef: React.RefObject<HTMLDivElement>) => {\n if (previouslyHoveredIndex !== undefined) {\n const mouseoutEvent = new MouseEvent('mouseout', { view: window, bubbles: true, cancelable: true });\n const previouslyHovered = tableRef?.current?.querySelector(`[data-row-index=\"${previouslyHoveredIndex}\"]`);\n previouslyHovered?.dispatchEvent(mouseoutEvent);\n }\n};\n\nfunction EditingRow(props) {\n const { isLastRow, setCurrentRowIndex, virtualiser, ...attributes } = props;\n const focusManager = useFocusManager();\n const focusManagerOptions = { tabbable: true };\n const tableMeta = props.table.options.meta as TableMeta<unknown>;\n\n const handleClickCapture = (event: React.FocusEvent) => {\n lastIndex = getColumnIndex(event.target);\n };\n\n const handleArrowLeftKey = event => {\n let focusedElement: Element;\n if (event.key === 'ArrowLeft' || (event.key === 'Tab' && event.shiftKey)) {\n // Need to stop propagation because \"Tab\" will be handled twice(default browser and programmatic one)\n // and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowLeft\" or \"META + ArrowLeft\" should focus first focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusFirst(focusManagerOptions);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // Should focus previous focusable element, if there is one\n focusedElement = focusManager.focusPrevious(focusManagerOptions);\n\n // Should move to prevoius row and select last focusable element in that row,\n // if there is no previous focusable element in current row\n if (props.index !== 0 && (!focusedElement || !event.currentTarget.contains(focusedElement))) {\n tableMeta.hoverState.pause(true);\n setCurrentRowIndex(props.index - 1);\n setTimeout(() => {\n focusedElement = focusManager.focusLast(focusManagerOptions);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n } else {\n lastIndex = getColumnIndex(focusedElement);\n }\n }\n }\n };\n\n const handleArrowRightKey = event => {\n let focusedElement: Element;\n if (event.key === 'ArrowRight' || (event.key === 'Tab' && !event.shiftKey)) {\n // Need to stop propagation because \"Tab\" will be handled twice(default browser and programmatic one)\n // and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowRight\" or \"META + ArrowRight\" should focus last focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusLast(focusManagerOptions);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // Should focus next focusable element, if there is one\n focusedElement = focusManager.focusNext(focusManagerOptions);\n\n // Should move to next row and select first focusable element in that row,\n // if there is no next focusable element in current row\n if (!isLastRow && (!focusedElement || !event.currentTarget.contains(focusedElement))) {\n tableMeta.hoverState.pause(true);\n setCurrentRowIndex(props.index + 1);\n setTimeout(() => {\n focusedElement = focusManager.focusFirst(focusManagerOptions);\n // Need to update lastIndex when row got changed and first element got selected.\n\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n } else {\n lastIndex = getColumnIndex(focusedElement);\n }\n }\n }\n };\n\n React.useEffect(() => {\n // if some row stuck in hovered state, we heed to unhover it when hover state is paused\n if (tableMeta.hoverState.isPaused) {\n unhoverPreviousRow(props.tableRef);\n }\n }, [tableMeta.hoverState.isPaused]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {\n return;\n }\n\n handleArrowLeftKey(event);\n handleArrowRightKey(event);\n };\n\n // this ensures we focus either on a field or on the same column when keyboard navigating up/down\n React.useEffect(() => {\n if (tableMeta.currentRow.currentRowIndex === props.index) {\n if (lastIndex !== undefined) {\n const lastIndexCell = props.tableRef.current?.querySelector(\n `[role=\"row\"][data-current=\"true\"] [data-column-index=\"${lastIndex}\"]`\n );\n lastIndexCell?.querySelector(focusableSelector)?.focus();\n } else {\n focusManager.focusFirst(focusManagerOptions);\n }\n }\n // Need to subscribe to current row index and check is it a current row,\n // for a situation where hovered row is the next row after current row...\n // In this case row will not be re-rendered if user switch to next row, because hovered row also renders EditingRow.\n }, [tableMeta.currentRow.currentRowIndex]);\n\n return <MemoedRow {...attributes} onClickCapture={handleClickCapture} onKeyDown={handleKeyDown} />;\n}\n\n// Memoization\n\nexport type MemoedRowProps<TType = unknown> = RowProps<TType> & {\n 'aria-grabbed'?: boolean;\n 'data-current': boolean;\n 'data-selected': boolean;\n draggable: boolean;\n index: number;\n};\n\nconst clickableElements = ['input', 'button', 'a', 'select', 'option', 'label', 'textarea'];\n\nconst MemoedRow = React.memo(function MemoedRow<TType = unknown>(props: MemoedRowProps<TType>) {\n const { index, isLastRow: _1, onClick, onClickCapture, onDrop, row, table, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { setIsHovered } = useRowContext();\n\n // we use capture because it also picks up clicks on e.g. select checkboxes\n const handleClickCapture = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (typeof onClickCapture === 'function') {\n onClickCapture(event);\n }\n\n // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable\n requestAnimationFrame(() => tableMeta.currentRow.setCurrentRowIndex(index));\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (typeof onClick === 'function') {\n const clickedElement = event.target as HTMLElement;\n\n if (\n !ref.current?.contains(event.target as HTMLElement) ||\n clickableElements.includes(clickedElement.tagName.toLowerCase()) ||\n clickedElement.closest(clickableElements.map(tag => `[role=row] ${tag}`).join(','))\n ) {\n return;\n }\n\n onClick(row.original);\n }\n };\n\n const handleMouseEnter = () => {\n // When user moving mouse to fast, then some of the rows are getting stuck in hover state,\n // because mouseleave event never got triggered, to avoid this to happen we're saving the index of last hovered row,\n // so that we can unhover it when new row got hovered, and saving it in a variable outside of react to save in performance,\n // since it would be very performance heavy to use state which is bound to mouse events.\n if (previouslyHoveredIndex !== undefined) {\n if (previouslyHoveredIndex !== index) {\n unhoverPreviousRow(tableRef);\n previouslyHoveredIndex = index;\n }\n } else {\n previouslyHoveredIndex = index;\n }\n setIsHovered(true);\n };\n const handleMouseLeave = () => {\n if (previouslyHoveredIndex === index) {\n previouslyHoveredIndex = undefined;\n }\n setIsHovered(false);\n };\n\n const [, dropTargetProps] = useDropTarget(event => onDrop?.(event, row.original));\n\n const className = cn(\n 'group/row contents',\n // resizing column requires dragging, which means the mouse might (on rare occasions) move over rows and trigger hover state\n // that in turn triggers rendering of e.g. row actions, which could cause janky ui - so don't allow mouse interaction when resizing\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n {\n 'hover:cursor-pointer': typeof onClick === 'function',\n }\n );\n\n return (\n <div\n {...attributes}\n {...(onDrop ? dropTargetProps : undefined)}\n className={className}\n data-row-index={index}\n onClick={handleClick}\n onClickCapture={handleClickCapture}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n role=\"row\"\n ref={ref}\n />\n );\n}) as <TType = unknown>(props: MemoedRowProps<TType>) => JSX.Element;\n"],"names":["Row","props","tableMeta","table","options","meta","isCurrentRow","currentRow","currentRowIndex","index","isDraggingRow","rowDrag","dragging","row","id","isHovered","setIsHovered","React","useState","memoedProps","isEnabled","undefined","getIsSelected","draggable","onClick","rowClick","handleClick","onDrop","rowDrop","handleDrop","output","MemoedRow","editing","isEditing","hoverState","isPaused","EditingRow","isLastRow","setCurrentRowIndex","contextValue","useMemo","rowIndex","RowContext","Provider","value","lastIndex","getColumnIndex","focusedElement","closest","getAttribute","previouslyHoveredIndex","unhoverPreviousRow","tableRef","mouseoutEvent","MouseEvent","view","window","bubbles","cancelable","previouslyHovered","current","querySelector","dispatchEvent","virtualiser","attributes","focusManager","useFocusManager","focusManagerOptions","tabbable","handleClickCapture","event","target","handleArrowLeftKey","key","shiftKey","stopPropagation","preventDefault","ctrlKey","metaKey","blur","focusFirst","focusPrevious","currentTarget","contains","pause","setTimeout","focusLast","handleArrowRightKey","focusNext","useEffect","handleKeyDown","isDefaultPrevented","isPropagationStopped","detailModeEditing","lastIndexCell","focusableSelector","focus","onClickCapture","onKeyDown","clickableElements","memo","_1","ref","useRef","useRowContext","requestAnimationFrame","clickedElement","includes","tagName","toLowerCase","map","tag","join","original","handleMouseEnter","handleMouseLeave","dropTargetProps","useDropTarget","className","cn","onMouseEnter","onMouseLeave","role"],"mappings":";;;;;;;SAmBgBA,GAAG,CAAkBC,KAAsB;EACvD,MAAMC,SAAS,GAAGD,KAAK,CAACE,KAAK,CAACC,OAAO,CAACC,IAAwB;EAC9D,MAAMC,YAAY,GAAGJ,SAAS,CAACK,UAAU,CAACC,eAAe,KAAKP,KAAK,CAACQ,KAAK;EACzE,MAAMC,aAAa,GAAGR,SAAS,CAACS,OAAO,CAACC,QAAQ,CAACX,KAAK,CAACY,GAAG,CAACC,EAAE,CAAC;;EAE9D,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAIvD,MAAMC,WAAW,GAAG;;IAEhB,cAAc,EAAET,aAAa,GAAG,IAAI,GAAGR,SAAS,CAACS,OAAO,CAACS,SAAS,GAAG,KAAK,GAAGC,SAAS;IACtF,cAAc,EAAEf,YAAY;IAC5B,eAAe,EAAEL,KAAK,CAACY,GAAG,CAACS,aAAa,EAAE;IAC1CC,SAAS,EAAErB,SAAS,CAACS,OAAO,CAACS,SAAS;IACtCX,KAAK,EAAER,KAAK,CAACQ,KAAK;IAClBe,OAAO,EAAEtB,SAAS,CAACuB,QAAQ,CAACC,WAAW;IACvCC,MAAM,EAAEzB,SAAS,CAAC0B,OAAO,CAACR,SAAS,GAAGlB,SAAS,CAAC0B,OAAO,CAACC,UAAU,GAAGR;GACxE;EAED,IAAIS,MAAM,gBAAGb,6BAACc,SAAS,oBAAY9B,KAAK,EAAMkB,WAAW,EAAI;EAE7D,IAAIjB,SAAS,CAAC8B,OAAO,CAACC,SAAS,K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,KAAK;;KAErC,MAAM;MACHyC,sBAAsB,GAAGzC,KAAK;;IAElCO,YAAY,CAAC,IAAI,CAAC;GACrB;EACD,MAAMmG,gBAAgB,GAAG;IACrB,IAAIjE,sBAAsB,KAAKzC,KAAK,EAAE;MAClCyC,sBAAsB,GAAG7B,SAAS;;IAEtCL,YAAY,CAAC,KAAK,CAAC;GACtB;EAED,MAAM,GAAGoG,eAAe,CAAC,GAAGC,aAAa,CAAC/C,KAAK,IAAI3C,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAG2C,KAAK,EAAEzD,GAAG,CAACoG,QAAQ,CAAC,CAAC;EAEjF,MAAMK,SAAS,GAAGC,EAAE,CAChB,oBAAoB;;;EAGpB,8DAA8D,EAC9D;IACI,sBAAsB,EAAE,OAAO/F,OAAO,KAAK;GAC9C,CACJ;EAED,oBACIP,sDACQ+C,UAAU,EACTrC,MAAM,GAAGyF,eAAe,GAAG/F,SAAS;IACzCiG,SAAS,EAAEA,SAAS;sBACJ7G,KAAK;IACrBe,OAAO,EAAEE,WAAW;IACpBuE,cAAc,EAAE5B,kBAAkB;IAClCmD,YAAY,EAAEN,gBAAgB;IAC9BO,YAAY,EAAEN,gBAAgB;IAC9BO,IAAI,EAAC,KAAK;IACVpB,GAAG,EAAEA;KACP;AAEV,CAAC,CAAmE;;;;"}
1
+ {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/rows/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { Row as RTRow, Table as RTable, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { RowContext, useRowContext } from './RowContext';\nimport { useDropTarget } from '../../../../utils/hooks/useDropTarget';\nimport { Table3RowClickHandler, Table3RowDropHandler } from '../../types';\nimport { useFocusManager } from '@react-aria/focus';\nimport { focusableSelector } from '../../util/editing';\n\ntype RowProps<TType = unknown> = Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDrop'> & {\n index: number;\n isLastRow: boolean;\n measureRef: (el: HTMLElement | null) => void;\n onClick?: Table3RowClickHandler<TType>;\n onDrop?: Table3RowDropHandler<TType>;\n row: RTRow<TType>;\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;\n const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];\n // we use non-css hovered state to determine whether to render actions or not, for performance\n const [isHovered, setIsHovered] = React.useState(false);\n\n // rows are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the row\n const memoedProps = {\n // aria-grabbed is being deprecated but there is no current alternative api, we use it until there is\n 'aria-grabbed': isDraggingRow ? true : tableMeta.rowDrag.isEnabled ? false : undefined,\n 'data-current': isCurrentRow,\n 'data-selected': props.row.getIsSelected(),\n draggable: tableMeta.rowDrag.isEnabled,\n index: props.index,\n onClick: tableMeta.rowClick.handleClick,\n onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,\n };\n\n let output = <MemoedRow<TType> {...props} {...memoedProps} />;\n\n if (tableMeta.editing.isEditing && (isCurrentRow || (isHovered && !tableMeta.hoverState.isPaused))) {\n output = (\n <EditingRow\n {...props}\n {...memoedProps}\n isLastRow={props.isLastRow}\n setCurrentRowIndex={tableMeta.currentRow.setCurrentRowIndex}\n />\n );\n }\n\n // we store the row index in context because in a virtualised table the row index and the\n // react table row index do not match when, for example, sorting is applied\n const contextValue = React.useMemo(() => ({ isHovered, setIsHovered, rowIndex: props.index }), [isHovered, props.index]);\n\n return <RowContext.Provider value={contextValue}>{output}</RowContext.Provider>;\n}\n\n// turns out we might need some kind of \"state\" for the focused column, but it doesn't need to be react state that re-renders\nlet lastIndex;\n\nfunction getColumnIndex(focusedElement: Element) {\n if (focusedElement) {\n return focusedElement.closest('[role=cell]')?.getAttribute('data-column-index');\n }\n\n return null;\n}\n\n// This code is needed to avoid multiple rows being hovered at the same time (it happens since we use non-css hovering)\nlet previouslyHoveredIndex: number | undefined;\nconst unhoverPreviousRow = (tableRef: React.RefObject<HTMLDivElement>) => {\n if (previouslyHoveredIndex !== undefined) {\n const mouseoutEvent = new MouseEvent('mouseout', { view: window, bubbles: true, cancelable: true });\n const previouslyHovered = tableRef?.current?.querySelector(`[data-row-index=\"${previouslyHoveredIndex}\"]`);\n previouslyHovered?.dispatchEvent(mouseoutEvent);\n }\n};\n\nfunction EditingRow(props) {\n const { isLastRow, setCurrentRowIndex, virtualiser, ...attributes } = props;\n const focusManager = useFocusManager();\n const focusManagerOptions = { tabbable: true };\n const tableMeta = props.table.options.meta as TableMeta<unknown>;\n\n const handleClickCapture = (event: React.FocusEvent) => {\n lastIndex = getColumnIndex(event.target);\n };\n\n const handleArrowLeftKey = event => {\n let focusedElement: Element;\n if (event.key === 'ArrowLeft' || (event.key === 'Tab' && event.shiftKey)) {\n // Need to stop propagation because \"Tab\" will be handled twice(default browser and programmatic one)\n // and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowLeft\" or \"META + ArrowLeft\" should focus first focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusFirst(focusManagerOptions);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // Should focus previous focusable element, if there is one\n focusedElement = focusManager.focusPrevious(focusManagerOptions);\n\n // Should move to prevoius row and select last focusable element in that row,\n // if there is no previous focusable element in current row\n if (props.index !== 0 && (!focusedElement || !event.currentTarget.contains(focusedElement))) {\n tableMeta.hoverState.pause(true);\n setCurrentRowIndex(props.index - 1);\n setTimeout(() => {\n focusedElement = focusManager.focusLast(focusManagerOptions);\n // Need to update lastIndex when row got changed and last element got selected.\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n } else {\n lastIndex = getColumnIndex(focusedElement);\n }\n }\n }\n };\n\n const handleArrowRightKey = event => {\n let focusedElement: Element;\n if (event.key === 'ArrowRight' || (event.key === 'Tab' && !event.shiftKey)) {\n // Need to stop propagation because \"Tab\" will be handled twice(default browser and programmatic one)\n // and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,\n // so we don't need default browser behaviour.\n event.stopPropagation();\n event.preventDefault();\n\n // \"CTRL + ArrowRight\" or \"META + ArrowRight\" should focus last focusable element of the row\n if (event.ctrlKey || event.metaKey) {\n event.target.blur();\n focusedElement = focusManager.focusLast(focusManagerOptions);\n lastIndex = getColumnIndex(focusedElement);\n } else {\n // Should focus next focusable element, if there is one\n focusedElement = focusManager.focusNext(focusManagerOptions);\n\n // Should move to next row and select first focusable element in that row,\n // if there is no next focusable element in current row\n if (!isLastRow && (!focusedElement || !event.currentTarget.contains(focusedElement))) {\n tableMeta.hoverState.pause(true);\n setCurrentRowIndex(props.index + 1);\n setTimeout(() => {\n focusedElement = focusManager.focusFirst(focusManagerOptions);\n // Need to update lastIndex when row got changed and first element got selected.\n\n lastIndex = getColumnIndex(focusedElement);\n }, 1);\n } else {\n lastIndex = getColumnIndex(focusedElement);\n }\n }\n }\n };\n\n React.useEffect(() => {\n // if some row stuck in hovered state, we heed to unhover it when hover state is paused\n if (tableMeta.hoverState.isPaused) {\n unhoverPreviousRow(props.tableRef);\n }\n }, [tableMeta.hoverState.isPaused]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {\n return;\n }\n\n handleArrowLeftKey(event);\n handleArrowRightKey(event);\n };\n\n // this ensures we focus either on a field or on the same column when keyboard navigating up/down\n React.useEffect(() => {\n if (tableMeta.currentRow.currentRowIndex === props.index) {\n if (lastIndex !== undefined) {\n const lastIndexCell = props.tableRef.current?.querySelector(\n `[role=\"row\"][data-current=\"true\"] [data-column-index=\"${lastIndex}\"]`\n );\n lastIndexCell?.querySelector(focusableSelector)?.focus();\n } else {\n focusManager.focusFirst(focusManagerOptions);\n }\n }\n // Need to subscribe to current row index and check is it a current row,\n // for a situation where hovered row is the next row after current row...\n // In this case row will not be re-rendered if user switch to next row, because hovered row also renders EditingRow.\n }, [tableMeta.currentRow.currentRowIndex]);\n\n return <MemoedRow {...attributes} onClickCapture={handleClickCapture} onKeyDown={handleKeyDown} />;\n}\n\n// Memoization\n\nexport type MemoedRowProps<TType = unknown> = RowProps<TType> & {\n 'aria-grabbed'?: boolean;\n 'data-current': boolean;\n 'data-selected': boolean;\n draggable: boolean;\n index: number;\n};\n\nconst clickableElements = ['input', 'button', 'a', 'select', 'option', 'label', 'textarea'];\n\nconst MemoedRow = React.memo(function MemoedRow<TType = unknown>(props: MemoedRowProps<TType>) {\n const { index, isLastRow: _1, measureRef, onClick, onClickCapture, onDrop, row, table, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { setIsHovered } = useRowContext();\n\n // we measure the first cell (since the row has display: contents) so that the virtualiser height is correct\n React.useEffect(() => {\n const firstCell = ref.current?.querySelector('[role=cell]:first-child');\n\n if (firstCell) {\n measureRef(firstCell as HTMLElement);\n }\n }, [ref.current]);\n\n // we use capture because it also picks up clicks on e.g. select checkboxes\n const handleClickCapture = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (typeof onClickCapture === 'function') {\n onClickCapture(event);\n }\n\n // do this in the next frame, otherwise it remounts the row and prevents row actions on hover from being clickable\n requestAnimationFrame(() => tableMeta.currentRow.setCurrentRowIndex(index));\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (typeof onClick === 'function') {\n const clickedElement = event.target as HTMLElement;\n\n if (\n !ref.current?.contains(event.target as HTMLElement) ||\n clickableElements.includes(clickedElement.tagName.toLowerCase()) ||\n clickedElement.closest(clickableElements.map(tag => `[role=row] ${tag}`).join(','))\n ) {\n return;\n }\n\n onClick(row.original);\n }\n };\n\n const handleMouseEnter = () => {\n // When user moving mouse to fast, then some of the rows are getting stuck in hover state,\n // because mouseleave event never got triggered, to avoid this to happen we're saving the index of last hovered row,\n // so that we can unhover it when new row got hovered, and saving it in a variable outside of react to save in performance,\n // since it would be very performance heavy to use state which is bound to mouse events.\n if (previouslyHoveredIndex !== undefined) {\n if (previouslyHoveredIndex !== index) {\n unhoverPreviousRow(tableRef);\n previouslyHoveredIndex = index;\n }\n } else {\n previouslyHoveredIndex = index;\n }\n setIsHovered(true);\n };\n const handleMouseLeave = () => {\n if (previouslyHoveredIndex === index) {\n previouslyHoveredIndex = undefined;\n }\n setIsHovered(false);\n };\n\n const [, dropTargetProps] = useDropTarget(event => onDrop?.(event, row.original));\n\n const className = cn(\n 'group/row contents',\n // resizing column requires dragging, which means the mouse might (on rare occasions) move over rows and trigger hover state\n // that in turn triggers rendering of e.g. row actions, which could cause janky ui - so don't allow mouse interaction when resizing\n '[[role=\"table\"][data-resizing=\"true\"]_&]:pointer-events-none',\n {\n 'hover:cursor-pointer': typeof onClick === 'function',\n }\n );\n\n return (\n <div\n {...attributes}\n {...(onDrop ? dropTargetProps : undefined)}\n className={className}\n data-row-index={index}\n onClick={handleClick}\n onClickCapture={handleClickCapture}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n role=\"row\"\n ref={ref}\n />\n );\n}) as <TType = unknown>(props: MemoedRowProps<TType>) => JSX.Element;\n"],"names":["Row","props","tableMeta","table","options","meta","isCurrentRow","currentRow","currentRowIndex","index","isDraggingRow","rowDrag","dragging","row","id","isHovered","setIsHovered","React","useState","memoedProps","isEnabled","undefined","getIsSelected","draggable","onClick","rowClick","handleClick","onDrop","rowDrop","handleDrop","output","MemoedRow","editing","isEditing","hoverState","isPaused","EditingRow","isLastRow","setCurrentRowIndex","contextValue","useMemo","rowIndex","RowContext","Provider","value","lastIndex","getColumnIndex","focusedElement","closest","getAttribute","previouslyHoveredIndex","unhoverPreviousRow","tableRef","mouseoutEvent","MouseEvent","view","window","bubbles","cancelable","previouslyHovered","current","querySelector","dispatchEvent","virtualiser","attributes","focusManager","useFocusManager","focusManagerOptions","tabbable","handleClickCapture","event","target","handleArrowLeftKey","key","shiftKey","stopPropagation","preventDefault","ctrlKey","metaKey","blur","focusFirst","focusPrevious","currentTarget","contains","pause","setTimeout","focusLast","handleArrowRightKey","focusNext","useEffect","handleKeyDown","isDefaultPrevented","isPropagationStopped","detailModeEditing","lastIndexCell","focusableSelector","focus","onClickCapture","onKeyDown","clickableElements","memo","_1","measureRef","ref","useRef","useRowContext","firstCell","requestAnimationFrame","clickedElement","includes","tagName","toLowerCase","map","tag","join","original","handleMouseEnter","handleMouseLeave","dropTargetProps","useDropTarget","className","cn","onMouseEnter","onMouseLeave","role"],"mappings":";;;;;;;SAoBgBA,GAAG,CAAkBC,KAAsB;EACvD,MAAMC,SAAS,GAAGD,KAAK,CAACE,KAAK,CAACC,OAAO,CAACC,IAAwB;EAC9D,MAAMC,YAAY,GAAGJ,SAAS,CAACK,UAAU,CAACC,eAAe,KAAKP,KAAK,CAACQ,KAAK;EACzE,MAAMC,aAAa,GAAGR,SAAS,CAACS,OAAO,CAACC,QAAQ,CAACX,KAAK,CAACY,GAAG,CAACC,EAAE,CAAC;;EAE9D,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;;EAIvD,MAAMC,WAAW,GAAG;;IAEhB,cAAc,EAAET,aAAa,GAAG,IAAI,GAAGR,SAAS,CAACS,OAAO,CAACS,SAAS,GAAG,KAAK,GAAGC,SAAS;IACtF,cAAc,EAAEf,YAAY;IAC5B,eAAe,EAAEL,KAAK,CAACY,GAAG,CAACS,aAAa,EAAE;IAC1CC,SAAS,EAAErB,SAAS,CAACS,OAAO,CAACS,SAAS;IACtCX,KAAK,EAAER,KAAK,CAACQ,KAAK;IAClBe,OAAO,EAAEtB,SAAS,CAACuB,QAAQ,CAACC,WAAW;IACvCC,MAAM,EAAEzB,SAAS,CAAC0B,OAAO,CAAC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EV,CAAC,CAAmE;;;;"}
@@ -26,30 +26,39 @@ function Search(props) {
26
26
  if (firstRowIndex) {
27
27
  scrollTo(firstRowIndex);
28
28
  }
29
- }, [table.getRowModel().rows.length, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)]);
30
- const handleSearch = query => {
31
- const value = String(query !== null && query !== void 0 ? query : '');
32
- tableMeta.search.setQuery(value);
33
- if (tableMeta.search.excludeUnmatchedResults) {
34
- if (value !== null && value !== void 0 && value.length) {
35
- table.setGlobalFilter(value);
36
- } else {
37
- table.resetGlobalFilter();
29
+ }, [tableMeta.search.query, tableMeta.search.excludeUnmatchedResults, table.getRowModel().rows.length, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)]);
30
+ const handleSearch = function (query) {
31
+ try {
32
+ function _temp2() {
33
+ if (tableMeta.search.excludeUnmatchedResults) {
34
+ if (value !== null && value !== void 0 && value.length) {
35
+ table.setGlobalFilter(value);
36
+ } else {
37
+ table.resetGlobalFilter();
38
+ }
39
+ }
40
+ tableMeta.search.setQuery(value);
38
41
  }
39
- } else if (tableMeta.search.loadAll) {
40
- // don't pass the search query because filters when loading all, we need all - not filtered data
41
- tableMeta.search.loadAll(table.getState().sorting, table.getState().columnFilters, undefined);
42
- }
43
- const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, value, table);
44
- if (firstRowIndex) {
45
- scrollTo(firstRowIndex);
42
+ const value = String(query !== null && query !== void 0 ? query : '');
43
+ // load all data if that is possible
44
+ const _temp = function () {
45
+ if (tableMeta.search.loadAll) {
46
+ // don't pass the search query because we need all data - not filtered data
47
+ return Promise.resolve(tableMeta.search.loadAll(table.getState().sorting, table.getState().columnFilters, undefined)).then(function () {});
48
+ }
49
+ }();
50
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
51
+ } catch (e) {
52
+ return Promise.reject(e);
46
53
  }
47
54
  };
48
55
  const handleToggleExcludeUnmatchedResults = enabled => {
49
56
  tableMeta.search.toggleExcludeUnmatchedResults(enabled);
50
57
  if (enabled) {
51
- if (tableMeta.search.query) {
52
- table.setGlobalFilter(tableMeta.search.query);
58
+ var _ref$current2;
59
+ if ((_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && _ref$current2.value) {
60
+ var _ref$current3;
61
+ table.setGlobalFilter((_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.value);
53
62
  } else {
54
63
  table.resetGlobalFilter();
55
64
  }
@@ -57,8 +66,8 @@ function Search(props) {
57
66
  table.resetGlobalFilter();
58
67
  }
59
68
  requestAnimationFrame(() => {
60
- var _ref$current2;
61
- return (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.focus();
69
+ var _ref$current4;
70
+ return (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.focus();
62
71
  });
63
72
  };
64
73
  const handleNextResult = () => {
@@ -136,6 +145,9 @@ function resetHighlightedColumnIndexes(enabled, value, table) {
136
145
  tableMeta.search.setHighlightedColumnIndexes([]);
137
146
  tableMeta.search.setCurrentHighlightColumnIndex(undefined);
138
147
  }
148
+ if (firstRowIndex !== undefined) {
149
+ tableMeta.currentRow.setCurrentRowIndex(firstRowIndex);
150
+ }
139
151
  return firstRowIndex;
140
152
  }
141
153
 
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Switch } from '../../../Switch/Switch';\nimport { globalFilterFn } from '../../util/filtering';\nimport { isDate } from 'date-fns';\nimport { format, parseFromISOString } from '../../../../utils/date';\nimport { SearchInput2 } from '../../../SearchInput2/SearchInput2';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: RTable<TType>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n // update the indexes if the row length changes (e.g. when filtering)\n React.useEffect(() => {\n const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, ref.current?.value, table);\n\n if (firstRowIndex) {\n scrollTo(firstRowIndex);\n }\n }, [\n table.getRowModel().rows.length,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n ]);\n\n const handleSearch = (query: any) => {\n const value = String(query ?? '');\n tableMeta.search.setQuery(value);\n\n if (tableMeta.search.excludeUnmatchedResults) {\n if (value?.length) {\n table.setGlobalFilter(value);\n } else {\n table.resetGlobalFilter();\n }\n } else if (tableMeta.search.loadAll) {\n // don't pass the search query because filters when loading all, we need all - not filtered data\n tableMeta.search.loadAll(table.getState().sorting, table.getState().columnFilters, undefined);\n }\n\n const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, value, table);\n\n if (firstRowIndex) {\n scrollTo(firstRowIndex);\n }\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.toggleExcludeUnmatchedResults(enabled);\n\n if (enabled) {\n if (tableMeta.search.query) {\n table.setGlobalFilter(tableMeta.search.query);\n } else {\n table.resetGlobalFilter();\n }\n } else {\n table.resetGlobalFilter();\n }\n\n requestAnimationFrame(() => ref.current?.focus());\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table3.search.excludeUnmatchedResults}\n checked={tableMeta.search.excludeUnmatchedResults}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes ? tableMeta.search.highlightedColumnIndexes.length : null}\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onSearch={handleSearch}\n placeholder={texts.table3.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={tableMeta.search.query}\n />\n </>\n );\n}\n\nfunction resetHighlightedColumnIndexes<TType = unknown>(enabled: boolean, value: string | undefined, table: RTable<TType>) {\n const tableMeta = table.options.meta as TableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (enabled && value) {\n const rowIndexes: number[] = [];\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n if (\n column.columnDef.meta?.enableSearch &&\n row.original &&\n globalFilterFn(\n // if it's a date, format it first\n isDate(row.original[column.id])\n ? format(row.original[column.id]) ?? ''\n : // if its marked as a date but isn't a date, try to format it\n column.columnDef.meta.dataType === 'datetime'\n ? format(parseFromISOString(row.original[column.id])) ?? ''\n : // otherwise just string compare\n String(row.original[column.id]),\n value\n )\n ) {\n indexes.push([rowIndex, columnIndex]);\n }\n } catch (e) {\n //\n }\n });\n\n if (indexes.length) {\n rowIndexes.push(rowIndex);\n }\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n return firstRowIndex;\n}\n"],"names":["Search","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","scrollTo","rowIndex","align","useEffect","firstRowIndex","resetHighlightedColumnIndexes","search","isHighlightingEnabled","current","value","getRowModel","rows","length","JSON","stringify","getState","sorting","columnVisibility","handleSearch","query","String","setQuery","excludeUnmatchedResults","setGlobalFilter","resetGlobalFilter","loadAll","columnFilters","undefined","handleToggleExcludeUnmatchedResults","enabled","toggleExcludeUnmatchedResults","requestAnimationFrame","focus","handleNextResult","highlightedColumnIndexes","nextIndex","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","table3","checked","onChange","SearchInput2","findCurrent","findTotal","onClickFindPrevious","onClickFindNext","onSearch","placeholder","settingsContent","shortcut","key","shift","indexes","columns","getVisibleLeafColumns","forEach","row","column","columnIndex","columnDef","enableSearch","original","globalFilterFn","isDate","id","format","dataType","parseFromISOString","push","e","setHighlightedColumnIndexes"],"mappings":";;;;;;;;SAcgBA,MAAM,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IA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AAE;;;OAGf,CAAC;KAKL,CAAC;IAEF5E,SAAS,CAACS,MAAM,CAACoE,2BAA2B,CAAClB,OAAO,CAAC;IAErD,IAAIA,OAAO,CAAC5C,MAAM,EAAE;MAChBR,aAAa,GAAGoD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MAC7B3D,SAAS,CAACS,MAAM,CAAC+B,8BAA8B,CAAC,CAAC,CAAC;KACrD,MAAM;MACHxC,SAAS,CAACS,MAAM,CAAC+B,8BAA8B,CAACV,SAAS,CAAC;;GAEjE,MAAM;IACH9B,SAAS,CAACS,MAAM,CAACoE,2BAA2B,CAAC,EAAE,CAAC;IAChD7E,SAAS,CAACS,MAAM,CAAC+B,8BAA8B,CAACV,SAAS,CAAC;;EAG9D,OAAOvB,aAAa;AACxB;;;;"}
1
+ {"version":3,"file":"Search.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Switch } from '../../../Switch/Switch';\nimport { globalFilterFn } from '../../util/filtering';\nimport { isDate } from 'date-fns';\nimport { format, parseFromISOString } from '../../../../utils/date';\nimport { SearchInput2 } from '../../../SearchInput2/SearchInput2';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: RTable<TType>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n // update the indexes if the row length changes (e.g. when filtering)\n React.useEffect(() => {\n const firstRowIndex = resetHighlightedColumnIndexes(tableMeta.search.isHighlightingEnabled, ref.current?.value, table);\n\n if (firstRowIndex) {\n scrollTo(firstRowIndex);\n }\n }, [\n tableMeta.search.query,\n tableMeta.search.excludeUnmatchedResults,\n table.getRowModel().rows.length,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n ]);\n\n const handleSearch = async (query: any) => {\n const value = String(query ?? '');\n\n // load all data if that is possible\n if (tableMeta.search.loadAll) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.search.loadAll(table.getState().sorting, table.getState().columnFilters, undefined);\n }\n\n if (tableMeta.search.excludeUnmatchedResults) {\n if (value?.length) {\n table.setGlobalFilter(value);\n } else {\n table.resetGlobalFilter();\n }\n }\n\n tableMeta.search.setQuery(value);\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.toggleExcludeUnmatchedResults(enabled);\n\n if (enabled) {\n if (ref.current?.value) {\n table.setGlobalFilter(ref.current?.value);\n } else {\n table.resetGlobalFilter();\n }\n } else {\n table.resetGlobalFilter();\n }\n\n requestAnimationFrame(() => ref.current?.focus());\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table3.search.excludeUnmatchedResults}\n checked={tableMeta.search.excludeUnmatchedResults}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes ? tableMeta.search.highlightedColumnIndexes.length : null}\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onSearch={handleSearch}\n placeholder={texts.table3.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={tableMeta.search.query}\n />\n </>\n );\n}\n\nfunction resetHighlightedColumnIndexes<TType = unknown>(enabled: boolean, value: string | undefined, table: RTable<TType>) {\n const tableMeta = table.options.meta as TableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (enabled && value) {\n const rowIndexes: number[] = [];\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n if (\n column.columnDef.meta?.enableSearch &&\n row.original &&\n globalFilterFn(\n // if it's a date, format it first\n isDate(row.original[column.id])\n ? format(row.original[column.id]) ?? ''\n : // if its marked as a date but isn't a date, try to format it\n column.columnDef.meta.dataType === 'datetime'\n ? format(parseFromISOString(row.original[column.id])) ?? ''\n : // otherwise just string compare\n String(row.original[column.id]),\n value\n )\n ) {\n indexes.push([rowIndex, columnIndex]);\n }\n } catch (e) {\n //\n }\n });\n\n if (indexes.length) {\n rowIndexes.push(rowIndex);\n }\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.currentRow.setCurrentRowIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["Search","props","scrollToIndex","table","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","scrollTo","rowIndex","align","useEffect","firstRowIndex","resetHighlightedColumnIndexes","search","isHighlightingEnabled","current","value","query","excludeUnmatchedResults","getRowModel","rows","length","JSON","stringify","getState","sorting","columnVisibility","handleSearch","setGlobalFilter","resetGlobalFilter","setQuery","String","loadAll","columnFilters","undefined","handleToggleExcludeUnmatchedResults","enabled","toggleExcludeUnmatchedResults","requestAnimationFrame","focus","handleNextResult","highlightedColumnIndexes","nextIndex","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","table3","checked","onChange","SearchInput2","findCurrent","findTotal","onClickFindPrevious","onClickFindNext","onSearch","placeholder","settingsContent","shortcut","key","shift","indexes","columns","getVisibleLeafColumns","forEach","row","column","columnIndex","columnDef","enableSearch","original","globalFilterFn","isDate","id","format","dataType","parseFromISOString","push","e","setHighlightedColumnIndexes","currentRow","setCurrentRowIndex"],"mappings":";;;;;;;;SAcgBA,MAAM,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,aAAa;IAAEC;GAAO,GAAGF,KAAK;EACtC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAAwB;EAExD,MAAMC,QAAQ,GAAIC,QAAgB,IAAKX,aAAa,CAACW,QAAQ,EAAE;IAAEC,KAAK,EAAE;GAAU,CAAC;;EAGnFP,cAAK,CAACQ,SAAS,CAAC;;IACZ,MAAMC,aAAa,GAAGC,6BAA6B,CAACR,SAAS,CAACS,MAAM,CAACC,qBAAqB,kBAAEb,GAAG,CAACc,OAAO,iDAAX,a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jE,MAAM;IACH9B,SAAS,CAACS,MAAM,CAACoE,2BAA2B,CAAC,EAAE,CAAC;IAChD7E,SAAS,CAACS,MAAM,CAAC+B,8BAA8B,CAACV,SAAS,CAAC;;EAG9D,IAAIvB,aAAa,KAAKuB,SAAS,EAAE;IAC7B9B,SAAS,CAAC8E,UAAU,CAACC,kBAAkB,CAACxE,aAAa,CAAC;;EAG1D,OAAOA,aAAa;AACxB;;;;"}
@@ -0,0 +1,10 @@
1
+ const ACTIONS_ON_ROW_LENGTH = 4;
2
+ function useRowActions(actionsForRow, actionsForRowLength = ACTIONS_ON_ROW_LENGTH) {
3
+ return {
4
+ actionsForRow,
5
+ actionsForRowLength
6
+ };
7
+ }
8
+
9
+ export { useRowActions };
10
+ //# sourceMappingURL=useRowActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRowActions.js","sources":["../../../../../../../../../src/components/Table3/hooks/features/useRowActions.ts"],"sourcesContent":["import { Table3RowActionRenderer } from '../../types';\n\nconst ACTIONS_ON_ROW_LENGTH = 4;\n\nexport function useRowActions<TType = unknown>(\n actionsForRow?: Table3RowActionRenderer<TType>[],\n actionsForRowLength = ACTIONS_ON_ROW_LENGTH\n) {\n return {\n actionsForRow,\n actionsForRowLength,\n };\n}\n"],"names":["ACTIONS_ON_ROW_LENGTH","useRowActions","actionsForRow","actionsForRowLength"],"mappings":"AAEA,MAAMA,qBAAqB,GAAG,CAAC;SAEfC,aAAa,CACzBC,aAAgD,EAChDC,mBAAmB,GAAGH,qBAAqB;EAE3C,OAAO;IACHE,aAAa;IACbC;GACH;AACL;;;;"}
@@ -99,7 +99,7 @@ function useConvertChildrenToColumns(props, options, editing) {
99
99
  columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));
100
100
  }
101
101
  if ((_props$actionsForRow = props.actionsForRow) !== null && _props$actionsForRow !== void 0 && _props$actionsForRow.length) {
102
- columns.push(columnHelper.display(createRowActionsColumn(props.actionsForRow, props.actionsForRowLength)));
102
+ columns.push(columnHelper.display(createRowActionsColumn()));
103
103
  }
104
104
  if (editing.isEnabled && editing.isEditing) {
105
105
  columns.push(columnHelper.display(createRowEditingActionsColumn()));
@@ -1 +1 @@
1
- {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnDef, ColumnSizingState, createColumnHelper, ColumnSort, VisibilityState } from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n const columnHelper = createColumnHelper<TType>();\n\n const columns: ColumnDef<TType>[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n (React.Children.toArray(props.children) as React.ReactElement<Table3ColumnProps<TType>>[])\n .filter(child => !!child) // remove falsey children\n .forEach(child => {\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && child.props.accessor) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: MIN_COLUMN_SIZE,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: options.enableFiltering ? ('tacoFilter' as any) : undefined,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n // react-table global filtering only samples from row 0 in a dataset for filtering and this\n // leads to some columns being disabled if, e.g., a column in row 0 has an undefined value\n // so we do not use the native enableGlobalFilter property and instead use our own enableSearch\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n });\n }\n });\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(createRowSelectionColumn<TType>(options.enableRowDrag ? props.onRowDrag : undefined))\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>(props.actionsForRow, props.actionsForRowLength)));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","columnHelper","createColumnHelper","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","React","Children","toArray","children","filter","child","forEach","isValidElement","accessor","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","MIN_COLUMN_SIZE","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enableSearch","enableTruncate","headerClassName","menu","renderer","tooltip","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","actionsForRow","length","createRowActionsColumn","actionsForRowLength","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;AAcA,SAASA,YAAY,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;;EAI5B,IAAID,QAAQ,IA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AAEC,mBAAmB;IAAEC,uBAAuB;IAAEC;GAAgB;AACpF;;;;"}
1
+ {"version":3,"file":"useConvertChildrenToColumns.js","sources":["../../../../../../../../src/components/Table3/hooks/useConvertChildrenToColumns.tsx"],"sourcesContent":["import React from 'react';\nimport { ColumnDef, ColumnSizingState, createColumnHelper, ColumnSort, VisibilityState } from '@tanstack/react-table';\nimport { Table3ColumnProps, Table3Props, Table3Options, Table3ColumnDataType, Table3SortFn } from '../types';\nimport { Header } from '../components/columns/header/Header';\nimport { Footer } from '../components/columns/footer/Footer';\nimport { Cell } from '../components/columns/cell/Cell';\nimport { createRowSelectionColumn } from '../components/columns/internal/Selection';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { createRowActionsColumn } from '../components/columns/internal/Actions';\nimport { createRowExpansionColumn } from '../components/columns/internal/Expansion';\nimport { createRowDragColumn } from '../components/columns/internal/Drag';\nimport { createRowEditingActionsColumn } from '../components/columns/internal/EditingActions';\nimport { useEditing } from './features/useEditing';\n\nfunction getSortingFn<TType = unknown>(dataType?: Table3ColumnDataType, customFnOrBuiltIn?: Table3SortFn<TType>) {\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n // some times we alias based on the type\n if (dataType && dataType !== 'boolean') {\n return dataType;\n }\n\n // otherwise fall back to auto\n return 'auto';\n}\n\nexport function useConvertChildrenToColumns<TType = unknown>(\n props: Table3Props<TType>,\n options: Table3Options,\n editing: ReturnType<typeof useEditing>\n) {\n const columnHelper = createColumnHelper<TType>();\n\n const columns: ColumnDef<TType>[] = [];\n const defaultColumnSizing: ColumnSizingState = {};\n const defaultColumnVisibility: VisibilityState = {};\n const defaultSorting: ColumnSort[] = [];\n\n (React.Children.toArray(props.children) as React.ReactElement<Table3ColumnProps<TType>>[])\n .filter(child => !!child) // remove falsey children\n .forEach(child => {\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && child.props.accessor) {\n if (child.props.defaultWidth) {\n defaultColumnSizing[child.props.accessor as string] =\n child.props.defaultWidth === 'grow' ? '1fr' : (child.props.defaultWidth as any);\n }\n\n if (child.props.defaultHidden && options.enableColumnHiding) {\n defaultColumnVisibility[child.props.accessor as string] = false;\n }\n\n if (child.props.sort !== undefined) {\n defaultSorting.push({\n id: child.props.accessor as string,\n desc: child.props.sort === 'desc',\n });\n }\n\n columns.push({\n accessorKey: child.props.accessor,\n id: child.props.accessor as string,\n header: Header,\n cell: Cell,\n footer: Footer,\n // sizing\n minSize: MIN_COLUMN_SIZE,\n enableResizing: child.props.enableResizing ?? true,\n // filtering\n enableColumnFilter: child.props.enableFiltering ?? true,\n filterFn: options.enableFiltering ? ('tacoFilter' as any) : undefined,\n // sorting\n enableSorting: child.props.enableSorting ?? true,\n sortingFn: getSortingFn<TType>(child.props.dataType, child.props.sortFn),\n sortDescFirst: false,\n sortUndefined: 1,\n // visibility\n enableHiding: child.props.enableHiding ?? true,\n // custom options\n meta: {\n align: child.props.align,\n className: child.props.className,\n control: child.props.control,\n dataType: child.props.dataType,\n enableOrdering: child.props.enableOrdering ?? true,\n // react-table global filtering only samples from row 0 in a dataset for filtering and this\n // leads to some columns being disabled if, e.g., a column in row 0 has an undefined value\n // so we do not use the native enableGlobalFilter property and instead use our own enableSearch\n enableSearch: child.props.enableSearch ?? true,\n enableTruncate: child.props.enableTruncate ?? false,\n footer: child.props.footer,\n header: child.props.header,\n headerClassName: child.props.headerClassName,\n menu: child.props.menu,\n renderer: child.props.renderer,\n tooltip: child.props.tooltip,\n },\n });\n }\n });\n\n if (options.enableRowExpansion && props.expandedRowRenderer) {\n columns.unshift(columnHelper.display(createRowExpansionColumn(props.expandedRowRenderer)));\n }\n\n if (options.enableRowSelection) {\n columns.unshift(\n columnHelper.display(createRowSelectionColumn<TType>(options.enableRowDrag ? props.onRowDrag : undefined))\n );\n }\n\n if (options.enableRowDrag && props.onRowDrag) {\n columns.unshift(columnHelper.display(createRowDragColumn(props.onRowDrag)));\n }\n\n if (props.actionsForRow?.length) {\n columns.push(columnHelper.display(createRowActionsColumn<TType>()));\n }\n\n if (editing.isEnabled && editing.isEditing) {\n columns.push(columnHelper.display(createRowEditingActionsColumn<TType>()));\n }\n\n return { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting };\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","useConvertChildrenToColumns","props","options","editing","columnHelper","createColumnHelper","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","React","Children","toArray","children","filter","child","forEach","isValidElement","accessor","defaultWidth","defaultHidden","enableColumnHiding","sort","undefined","push","id","desc","accessorKey","header","Header","cell","Cell","footer","Footer","minSize","MIN_COLUMN_SIZE","enableResizing","enableColumnFilter","enableFiltering","filterFn","enableSorting","sortingFn","sortFn","sortDescFirst","sortUndefined","enableHiding","meta","align","className","control","enableOrdering","enableSearch","enableTruncate","headerClassName","menu","renderer","tooltip","enableRowExpansion","expandedRowRenderer","unshift","display","createRowExpansionColumn","enableRowSelection","createRowSelectionColumn","enableRowDrag","onRowDrag","createRowDragColumn","actionsForRow","length","createRowActionsColumn","isEnabled","isEditing","createRowEditingActionsColumn"],"mappings":";;;;;;;;;;;;AAcA,SAASA,YAAY,CAAkBC,QAA+B,EAAEC,iBAAuC;EAC3G,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;;EAI5B,IAAID,QAAQ,IAAIA,QAAQ,KAAK,SAAS,EAAE;IACpC,OAAOA,QAAQ;;;EAInB,OAAO,MAAM;AACjB;SAEgBM,2BAA2B,CACv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KAAK,CAACd,KAAK,CAACqD,IAAI;UACtBC,QAAQ,EAAExC,KAAK,CAACd,KAAK,CAACsD,QAAQ;UAC9BC,OAAO,EAAEzC,KAAK,CAACd,KAAK,CAACuD;;OAE5B,CAAC;;GAET,CAAC;EAEN,IAAItD,OAAO,CAACuD,kBAAkB,IAAIxD,KAAK,CAACyD,mBAAmB,EAAE;IACzDpD,OAAO,CAACqD,OAAO,CAACvD,YAAY,CAACwD,OAAO,CAACC,wBAAwB,CAAC5D,KAAK,CAACyD,mBAAmB,CAAC,CAAC,CAAC;;EAG9F,IAAIxD,OAAO,CAAC4D,kBAAkB,EAAE;IAC5BxD,OAAO,CAACqD,OAAO,CACXvD,YAAY,CAACwD,OAAO,CAACG,wBAAwB,CAAQ7D,OAAO,CAAC8D,aAAa,GAAG/D,KAAK,CAACgE,SAAS,GAAG1C,SAAS,CAAC,CAAC,CAC7G;;EAGL,IAAIrB,OAAO,CAAC8D,aAAa,IAAI/D,KAAK,CAACgE,SAAS,EAAE;IAC1C3D,OAAO,CAACqD,OAAO,CAACvD,YAAY,CAACwD,OAAO,CAACM,mBAAmB,CAACjE,KAAK,CAACgE,SAAS,CAAC,CAAC,CAAC;;EAG/E,4BAAIhE,KAAK,CAACkE,aAAa,iDAAnB,qBAAqBC,MAAM,EAAE;IAC7B9D,OAAO,CAACkB,IAAI,CAACpB,YAAY,CAACwD,OAAO,CAACS,sBAAsB,EAAS,CAAC,CAAC;;EAGvE,IAAIlE,OAAO,CAACmE,SAAS,IAAInE,OAAO,CAACoE,SAAS,EAAE;IACxCjE,OAAO,CAACkB,IAAI,CAACpB,YAAY,CAACwD,OAAO,CAACY,6BAA6B,EAAS,CAAC,CAAC;;EAG9E,OAAO;IAAElE,OAAO;IAAEC,mBAAmB;IAAEC,uBAAuB;IAAEC;GAAgB;AACpF;;;;"}
@@ -3,6 +3,7 @@ import { isInternalColumn } from '../util/columns.js';
3
3
  import { MIN_COLUMN_SIZE } from '../components/columns/styles.js';
4
4
  import { COLUMN_ID } from '../components/columns/internal/Actions.js';
5
5
 
6
+ const REACT_TABLE_DEFAULT_COLUMN_SIZE_DO_NOT_CHANGE = 150;
6
7
  const useCssGrid = table => {
7
8
  const allVisibleColumns = table.getVisibleLeafColumns();
8
9
  const columnSizing = table.getState().columnSizing;
@@ -16,9 +17,7 @@ const useCssGrid = table => {
16
17
  const width = columnSizing[column.id];
17
18
  if (isInternalColumn(column.id)) {
18
19
  if (column.id === COLUMN_ID) {
19
- // it's important to set a min width so that when the the column width is maintained
20
- // when the current row is scrolled out of the virtualisation view
21
- size = `minmax(${column.getSize()}px, auto)`;
20
+ size = column.getSize() !== REACT_TABLE_DEFAULT_COLUMN_SIZE_DO_NOT_CHANGE ? `minmax(${column.getSize()}px, auto)` : '1fr';
22
21
  } else {
23
22
  size = `${column.getSize()}px`;
24
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCssGrid.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable } from '@tanstack/react-table';\nimport { isInternalColumn } from '../util/columns';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\n\nexport const useCssGrid = <TType = unknown>(table: RTable<TType>) => {\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const length = table.getRowModel().rows.length;\n\n const gridTemplateColumns = React.useMemo(() => {\n return allVisibleColumns.reduce((accum, column, index) => {\n let size;\n const isLastColumn = index === allVisibleColumns.length - 1;\n // column has a getSize function, but it always returns a default value (150), and we want the\n // first render to use auto layout - so we get the size directly from table state where it is undefined\n const width = columnSizing[column.id] as number | '1fr';\n\n if (isInternalColumn(column.id)) {\n if (column.id === ACTIONS_COLUMN_ID) {\n // it's important to set a min width so that when the the column width is maintained\n // when the current row is scrolled out of the virtualisation view\n size = `minmax(${column.getSize()}px, auto)`;\n } else {\n size = `${column.getSize()}px`;\n }\n } else if (width !== undefined) {\n if (width === '1fr') {\n size = 'minmax(max-content, 1fr)';\n } else if (isLastColumn) {\n size = `minmax(${width}px, auto)`;\n } else if (width < MIN_COLUMN_SIZE) {\n // the react-table getResizeHandler function does not respect the minSize property on columns, it is possible\n // to go below the minSize - so we have to prevent it entirely on the grid layout\n size = `${MIN_COLUMN_SIZE}px`;\n } else {\n size = `${width}px`;\n }\n } else {\n size = 'minmax(max-content, auto)';\n }\n\n return `${accum} ${size}`.trim();\n }, '');\n }, [allVisibleColumns, columnSizing]);\n\n const gridTemplateRows = React.useMemo(() => {\n return `min-content repeat(${length}, min-content) 1fr min-content`;\n }, [length]);\n\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n return { style };\n};\n"],"names":["useCssGrid","table","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","length","getRowModel","rows","gridTemplateColumns","React","useMemo","reduce","accum","column","index","size","isLastColumn","width","id","isInternalColumn","ACTIONS_COLUMN_ID","getSize","undefined","MIN_COLUMN_SIZE","trim","gridTemplateRows","style"],"mappings":";;;;;MAMaA,UAAU,GAAqBC,KAAoB;EAC5D,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGH,KAAK,CAACI,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,MAAM,GAAGL,KAAK,CAACM,WAAW,EAAE,CAACC,IAAI,CAACF,MAAM;EAE9C,MAAMG,mBAAmB,GAAGC,cAAK,CAACC,OAAO,CAAC;IACtC,OAAOT,iBAAiB,CAACU,MAAM,CAAC,CAACC,KAAK,EAAEC,MAAM,EAAEC,KAAK;MACjD,IAAIC,IAAI;MACR,MAAMC,YAAY,GAAGF,KAAK,KAAKb,iBAAiB,CAACI,MAAM,GAAG,CAAC;;;MAG3D,MAAMY,KAAK,GAAGd,YAAY,CAACU,MAAM,CAACK,EAAE,CAAmB;MAEvD,IAAIC,gBAAgB,CAACN,MAAM,CAACK,EAAE,CAAC,EAAE;QAC7B,IAAIL,MAAM,CAACK,EAAE,KAAKE,SAAiB,EAAE;;;UAGjCL,IAAI,aAAaF,MAAM,CAACQ,OAAO,aAAa;SAC/C,MAAM;UACHN,IAAI,MAAMF,MAAM,CAACQ,OAAO,MAAM;;OAErC,MAAM,IAAIJ,KAAK,KAAKK,SAAS,EAAE;QAC5B,IAAIL,KAAK,KAAK,KAAK,EAAE;UACjBF,IAAI,GAAG,0BAA0B;SACpC,MAAM,IAAIC,YAAY,EAAE;UACrBD,IAAI,aAAaE,gBAAgB;SACpC,MAAM,IAAIA,KAAK,GAAGM,eAAe,EAAE;;;UAGhCR,IAAI,MAAMQ,mBAAmB;SAChC,MAAM;UACHR,IAAI,MAAME,SAAS;;OAE1B,MAAM;QACHF,IAAI,GAAG,2BAA2B;;MAGtC,UAAUH,SAASG,MAAM,CAACS,IAAI,EAAE;KACnC,EAAE,EAAE,CAAC;GACT,EAAE,CAACvB,iBAAiB,EAAEE,YAAY,CAAC,CAAC;EAErC,MAAMsB,gBAAgB,GAAGhB,cAAK,CAACC,OAAO,CAAC;IACnC,6BAA6BL,sCAAsC;GACtE,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMqB,KAAK,GAAwB;IAC/BlB,mBAAmB;IACnBiB;GACH;EAED,OAAO;IAAEC;GAAO;AACpB;;;;"}
1
+ {"version":3,"file":"useCssGrid.js","sources":["../../../../../../../../src/components/Table3/hooks/useCssGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable } from '@tanstack/react-table';\nimport { isInternalColumn } from '../util/columns';\nimport { MIN_COLUMN_SIZE } from '../components/columns/styles';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\n\nconst REACT_TABLE_DEFAULT_COLUMN_SIZE_DO_NOT_CHANGE = 150;\n\nexport const useCssGrid = <TType = unknown>(table: RTable<TType>) => {\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const length = table.getRowModel().rows.length;\n\n const gridTemplateColumns = React.useMemo(() => {\n return allVisibleColumns.reduce((accum, column, index) => {\n let size;\n const isLastColumn = index === allVisibleColumns.length - 1;\n // column has a getSize function, but it always returns a default value (150), and we want the\n // first render to use auto layout - so we get the size directly from table state where it is undefined\n const width = columnSizing[column.id] as number | '1fr';\n\n if (isInternalColumn(column.id)) {\n if (column.id === ACTIONS_COLUMN_ID) {\n size =\n column.getSize() !== REACT_TABLE_DEFAULT_COLUMN_SIZE_DO_NOT_CHANGE\n ? `minmax(${column.getSize()}px, auto)`\n : '1fr';\n } else {\n size = `${column.getSize()}px`;\n }\n } else if (width !== undefined) {\n if (width === '1fr') {\n size = 'minmax(max-content, 1fr)';\n } else if (isLastColumn) {\n size = `minmax(${width}px, auto)`;\n } else if (width < MIN_COLUMN_SIZE) {\n // the react-table getResizeHandler function does not respect the minSize property on columns, it is possible\n // to go below the minSize - so we have to prevent it entirely on the grid layout\n size = `${MIN_COLUMN_SIZE}px`;\n } else {\n size = `${width}px`;\n }\n } else {\n size = 'minmax(max-content, auto)';\n }\n\n return `${accum} ${size}`.trim();\n }, '');\n }, [allVisibleColumns, columnSizing]);\n\n const gridTemplateRows = React.useMemo(() => {\n return `min-content repeat(${length}, min-content) 1fr min-content`;\n }, [length]);\n\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n return { style };\n};\n"],"names":["REACT_TABLE_DEFAULT_COLUMN_SIZE_DO_NOT_CHANGE","useCssGrid","table","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","length","getRowModel","rows","gridTemplateColumns","React","useMemo","reduce","accum","column","index","size","isLastColumn","width","id","isInternalColumn","ACTIONS_COLUMN_ID","getSize","undefined","MIN_COLUMN_SIZE","trim","gridTemplateRows","style"],"mappings":";;;;;AAMA,MAAMA,6CAA6C,GAAG,GAAG;MAE5CC,UAAU,GAAqBC,KAAoB;EAC5D,MAAMC,iBAAiB,GAAGD,KAAK,C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6BAA6BL,sCAAsC;GACtE,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMqB,KAAK,GAAwB;IAC/BlB,mBAAmB;IACnBiB;GACH;EAED,OAAO;IAAEC;GAAO;AACpB;;;;"}
@@ -15,7 +15,6 @@ import { useCurrentRowListener } from './listeners/useCurrentRowListener.js';
15
15
  import { useColumnFreezing } from './features/useColumnFreezing.js';
16
16
  import { useRowSelection } from './features/useRowSelection.js';
17
17
  import { useRowClick } from './features/useRowClick.js';
18
- import { useSearchStateListener } from './listeners/useSearchStateListener.js';
19
18
  import { useEditing } from './features/useEditing.js';
20
19
  import { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering.js';
21
20
  import { useRowDrop } from './features/useRowDrop.js';
@@ -26,6 +25,7 @@ import { useRowGoto } from './features/useRowGoto.js';
26
25
  import { useServerLoadingListener } from './listeners/useServerLoadingListener.js';
27
26
  import { useEditingStateListener } from './listeners/useEditingStateListener.js';
28
27
  import { useSearch } from './features/useSearch.js';
28
+ import { useRowActions } from './features/useRowActions.js';
29
29
 
30
30
  function useTable(props) {
31
31
  var _ref, _props$defaultSetting, _props$defaultSetting2, _props$defaultSetting3, _props$defaultSetting4, _props$defaultSetting5, _props$defaultSetting6, _props$defaultSetting7, _props$defaultSetting8, _props$defaultSetting9, _props$length;
@@ -59,13 +59,13 @@ function useTable(props) {
59
59
  }
60
60
  // search
61
61
  if (tableOptions.enableGlobalFilter) {
62
- if (props.onSearch) {
63
- tableOptions.manualFiltering = true;
64
- // onSearch is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange
65
- } else {
66
- tableOptions.globalFilterFn = (row, columnId, searchQuery) => globalFilterFn(row.getValue(columnId), searchQuery);
67
- tableOptions.getFilteredRowModel = getFilteredRowModel();
68
- }
62
+ tableOptions.globalFilterFn = (row, columnId, searchQuery) => {
63
+ if (row.original) {
64
+ return globalFilterFn(row.getValue(columnId), searchQuery);
65
+ }
66
+ return false;
67
+ };
68
+ tableOptions.getFilteredRowModel = getFilteredRowModel();
69
69
  }
70
70
  // sorting
71
71
  if (options.enableSorting) {
@@ -85,6 +85,7 @@ function useTable(props) {
85
85
  const fontSize = useFontSize(options.enableFontSize, (_props$defaultSetting4 = props.defaultSettings) === null || _props$defaultSetting4 === void 0 ? void 0 : _props$defaultSetting4.fontSize);
86
86
  const hoverState = usePauseHoverState();
87
87
  const printing = usePrinting(options.enablePrinting, props.loadAll, (_props$defaultSetting5 = props.defaultSettings) === null || _props$defaultSetting5 === void 0 ? void 0 : _props$defaultSetting5.showWarningWhenPrintingLargeDataset);
88
+ const rowActions = useRowActions(props.actionsForRow, props.actionsForRowLength);
88
89
  const rowClick = useRowClick(props.onRowClick);
89
90
  const rowDrag = useRowDrag(options.enableRowDrag);
90
91
  const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);
@@ -127,6 +128,7 @@ function useTable(props) {
127
128
  hoverState,
128
129
  isUsingServer: !!props.loadPage,
129
130
  printing,
131
+ rowActions: rowActions,
130
132
  rowClick: rowClick,
131
133
  rowDrag,
132
134
  rowDrop,
@@ -141,7 +143,6 @@ function useTable(props) {
141
143
  useEditingStateListener(table);
142
144
  useFilteringStateListener(table, props.onFilter);
143
145
  useRowSelectionListener(table, props.onRowSelect);
144
- useSearchStateListener(table, props.onSearch);
145
146
  useSettingsStateListener(table, props.onChangeSettings);
146
147
  useShortcutsListener(table, props.shortcuts);
147
148
  useServerLoadingListener(table, props.loadPage);
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { useSearchStateListener } from './listeners/useSearchStateListener';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n fontSize: ReturnType<typeof useFontSize>;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n className?: Table3ColumnClassNameHandler<TData>;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n defaultWidth?: number;\n enableOrdering: boolean;\n enableSearch: boolean;\n enableTruncate: boolean;\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>) {\n // options\n const options = useTablePreset(props);\n\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (props.onFilter) {\n tableOptions.manualFiltering = true;\n // onFilter is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange\n } else {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n if (props.onSearch) {\n tableOptions.manualFiltering = true;\n // onSearch is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange\n } else {\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) =>\n globalFilterFn(row.getValue(columnId), searchQuery);\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n props.defaultSettings?.columnFreezingIndex ??\n (props.defaultSettings as any)?.frozenColumnCount ??\n props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, props.defaultSettings?.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(\n options.enablePrinting,\n props.loadAll,\n props.defaultSettings?.showWarningWhenPrintingLargeDataset\n );\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n props.defaultSettings?.rowHeight ?? (props.defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, props.defaultSettings?.excludeUnmatchedRecordsInSearch, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n return {\n columnOrder: ensureOrdering<TType>(columns, props.defaultSettings?.columnOrder),\n columnSizing: props.defaultSettings?.columnSizing ?? defaultColumnSizing,\n columnVisibility: props.defaultSettings?.columnVisibility ?? defaultColumnVisibility,\n sorting: props.defaultSettings?.sorting\n ? props.defaultSettings?.sorting.filter(sanitizeSortedColumns)\n : defaultSorting,\n };\n }, []);\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n currentRow,\n editing,\n fontSize,\n hoverState,\n isUsingServer: !!props.loadPage,\n printing,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSearchStateListener(table, props.onSearch);\n useSettingsStateListener(table, props.onChangeSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","manualFiltering","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","onSearch","globalFilterFn","searchQuery","onSort","manualSorting","getSortedRowModel","columnFreezing","useColumnFreezing","defaultSettings","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","id","columnOrder","ensureOrdering","columnSizing","columnVisibility","sorting","table","useReactTable","data","getCoreRowModel","meta","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSearchStateListener","useSettingsStateListener","onChangeSettings","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkGgBA,QAAQ,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI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AACV,KAAK,EAAEpG,KAAK,CAAC+G,WAAW,CAAC;EACjDC,sBAAsB,CAACZ,KAAK,EAAEpG,KAAK,CAAC4B,QAAQ,CAAC;EAC7CqF,wBAAwB,CAACb,KAAK,EAAEpG,KAAK,CAACkH,gBAAgB,CAAC;EACvDC,oBAAoB,CAACf,KAAK,EAAEpG,KAAK,CAACoH,SAAS,CAAC;EAC5CC,wBAAwB,CAACjB,KAAK,EAAEpG,KAAK,CAAC0G,QAAQ,CAAC;EAC/CY,uBAAuB,CAAClB,KAAK,EAAEpG,KAAK,CAAC+B,MAAM,CAAC;EAE5C,OAAO;IAAEqE,KAAK;IAAEmB,MAAM,mBAAEvH,KAAK,CAACuH,MAAM,yDAAIvH,KAAK,CAACsG,IAAI,CAACiB;GAAQ;AAC/D;;;;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n fontSize: ReturnType<typeof useFontSize>;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowActions: ReturnType<typeof useRowActions>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n className?: Table3ColumnClassNameHandler<TData>;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n // @ts-expect-error -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n defaultWidth?: number;\n enableOrdering: boolean;\n enableSearch: boolean;\n enableTruncate: boolean;\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>) {\n // options\n const options = useTablePreset(props);\n\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (props.onFilter) {\n tableOptions.manualFiltering = true;\n // onFilter is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange\n } else {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n if (row.original) {\n return globalFilterFn(row.getValue(columnId), searchQuery);\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n // custom features\n const columnFreezing = useColumnFreezing(\n // temporarily see if deprecated frozenColumnCount is there\n props.defaultSettings?.columnFreezingIndex ??\n (props.defaultSettings as any)?.frozenColumnCount ??\n props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, props.defaultSettings?.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(\n options.enablePrinting,\n props.loadAll,\n props.defaultSettings?.showWarningWhenPrintingLargeDataset\n );\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n // temporarily see if deprecated rowDensity is there\n props.defaultSettings?.rowHeight ?? (props.defaultSettings as any)?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, props.defaultSettings?.excludeUnmatchedRecordsInSearch, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n return {\n columnOrder: ensureOrdering<TType>(columns, props.defaultSettings?.columnOrder),\n columnSizing: props.defaultSettings?.columnSizing ?? defaultColumnSizing,\n columnVisibility: props.defaultSettings?.columnVisibility ?? defaultColumnVisibility,\n sorting: props.defaultSettings?.sorting\n ? props.defaultSettings?.sorting.filter(sanitizeSortedColumns)\n : defaultSorting,\n };\n }, []);\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n currentRow,\n editing,\n fontSize,\n hoverState,\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSettingsStateListener(table, props.onChangeSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","manualFiltering","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","onSort","manualSorting","getSortedRowModel","columnFreezing","useColumnFreezing","defaultSettings","columnFreezingIndex","frozenColumnCount","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","id","columnOrder","ensureOrdering","columnSizing","columnVisibility","sorting","table","useReactTable","data","getCoreRowModel","meta","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSettingsStateListener","onChangeSettings","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAmGgBA,QAAQ,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI9C,IAAId,YAAY,CAACC,mBAAmB,EAAE;IAClC,IAAIJ,KAAK,CAACkB,QAAQ,EAAE;MAChBf,YAAY,CAACgB,eAAe,GAAG,IAAI;;KAEtC,MAAM;MACHhB,YAAY,CAACiB,SAAS,GAAG;QACrBC,UAAU,EAAE,CAACC,GAAiB,EAAEC,QAAgB,EAAEC,MAAW,KAAKC,cAAc,CAACH,GAAG,CAACI,QAAQ,CAACH,QAAQ,CAAC,EAAEC,MAAM;OAClH;MACDrB,YAAY,CAACwB,mBAAmB,GAAGA,mBAAmB,EAAE;;;;EAKhE,IAAIxB,YAAY,CAACM,kBAAkB,EAAE;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5C,OAAO;IAAEyE,KAAK;IAAEkB,MAAM,mBAAE1H,KAAK,CAAC0H,MAAM,yDAAI1H,KAAK,CAAC0G,IAAI,CAACgB;GAAQ;AAC/D;;;;"}
@@ -106,20 +106,12 @@ function useTable3DataLoader(fetch, fetchAll, options = {
106
106
  return Promise.reject(e);
107
107
  }
108
108
  };
109
- const handleSearch = function (query) {
110
- try {
111
- return loadAll(_lastUsedSorting.current, _lastUsedFilters.current, query);
112
- } catch (e) {
113
- return Promise.reject(e);
114
- }
115
- };
116
109
  return [{
117
110
  data,
118
111
  length: length.current,
119
112
  loadAll,
120
113
  loadPage,
121
114
  onFilter: handleFilter,
122
- onSearch: handleSearch,
123
115
  onSort: handleSort,
124
116
  pageSize
125
117
  }, invalidate];