@economic/taco 2.46.5 → 2.46.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/Table3/features/useEditingState.d.ts +1 -1
- package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
- package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -33
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +4 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +5 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
- package/dist/primitives/Table/Core/types.d.ts +1 -0
- package/dist/taco.cjs.development.js +86 -55
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { SkeletonRow } from './BuiltIns/SkeletonRow';\nimport { RowContext } from './RowContext';\nimport { TableRowRenderer, TableRowRendererProps } from '../../types';\n\nexport type RowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n renderer: TableRowRenderer<TType>;\n };\n\n/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const {
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { SkeletonRow } from './BuiltIns/SkeletonRow';\nimport { RowContext } from './RowContext';\nimport { TableRowRenderer, TableRowRendererProps } from '../../types';\n\nexport type RowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n renderer: TableRowRenderer<TType>;\n };\n\n/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */\nexport function Row<TType = unknown>(props: RowProps<TType>) {\n const {\n renderer: RowRenderer,\n cellRenderer: CellRenderer,\n hideInternalColumns = false,\n hideRowActions = false,\n ...displayRowProps\n } = props;\n\n const tableMeta = props.table.options.meta as ReactTableMeta<TType>;\n const isHovered = tableMeta.rowActive.rowHoverIndex === props.index;\n // context - it must be here for cells to read it, since they render alongside the row inside DisplayRow\n const contextValue = React.useMemo(\n () => ({ isHovered, rowIndex: props.index, hideInternalColumns, hideRowActions }),\n [isHovered, props.index, hideInternalColumns, hideRowActions]\n );\n\n if (props.row.original === undefined) {\n return <SkeletonRow {...props} />;\n }\n\n return (\n <RowContext.Provider value={contextValue}>\n <RowRenderer<TType> {...displayRowProps} cellRenderer={CellRenderer} />\n </RowContext.Provider>\n );\n}\n"],"names":["Row","props","renderer","RowRenderer","cellRenderer","CellRenderer","hideInternalColumns","hideRowActions","displayRowProps","tableMeta","table","options","meta","isHovered","rowActive","rowHoverIndex","index","contextValue","React","useMemo","rowIndex","row","original","undefined","SkeletonRow","RowContext","Provider","value"],"mappings":";;;;AAWA;SACgBA,GAAGA,CAAkBC,KAAsB;EACvD,MAAM;IACFC,QAAQ,EAAEC,WAAW;IACrBC,YAAY,EAAEC,YAAY;IAC1BC,mBAAmB,GAAG,KAAK;IAC3BC,cAAc,GAAG,KAAK;IACtB,GAAGC;GACN,GAAGP,KAAK;EAET,MAAMQ,SAAS,GAAGR,KAAK,CAACS,KAAK,CAACC,OAAO,CAACC,IAA6B;EACnE,MAAMC,SAAS,GAAGJ,SAAS,CAACK,SAAS,CAACC,aAAa,KAAKd,KAAK,CAACe,KAAK;;EAEnE,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAC9B,OAAO;IAAEN,SAAS;IAAEO,QAAQ,EAAEnB,KAAK,CAACe,KAAK;IAAEV,mBAAmB;IAAEC;GAAgB,CAAC,EACjF,CAACM,SAAS,EAAEZ,KAAK,CAACe,KAAK,EAAEV,mBAAmB,EAAEC,cAAc,CAAC,CAChE;EAED,IAAIN,KAAK,CAACoB,GAAG,CAACC,QAAQ,KAAKC,SAAS,EAAE;IAClC,oBAAOL,6BAACM,WAAW,oBAAKvB,KAAK,EAAI;;EAGrC,oBACIiB,6BAACO,UAAU,CAACC,QAAQ;IAACC,KAAK,EAAEV;kBACxBC,6BAACf,WAAW,oBAAYK,eAAe;IAAEJ,YAAY,EAAEC;KAAgB,CACrD;AAE9B;;;;"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
|
3
3
|
const RowContext = /*#__PURE__*/React__default.createContext({
|
4
|
+
hideInternalColumns: false,
|
5
|
+
hideRowActions: false,
|
4
6
|
isHovered: false,
|
5
|
-
rowIndex: -1
|
6
|
-
hideRowActions: false
|
7
|
+
rowIndex: -1
|
7
8
|
});
|
8
9
|
|
9
10
|
export { RowContext };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RowContext.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Row/RowContext.tsx"],"sourcesContent":["import React from 'react';\n\ntype RowContextValue = {\n
|
1
|
+
{"version":3,"file":"RowContext.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Row/RowContext.tsx"],"sourcesContent":["import React from 'react';\n\ntype RowContextValue = {\n hideInternalColumns: boolean;\n hideRowActions: boolean;\n isHovered: boolean;\n rowIndex: number;\n};\n\nexport const RowContext = React.createContext<RowContextValue>({\n hideInternalColumns: false,\n hideRowActions: false,\n isHovered: false,\n rowIndex: -1,\n});\n"],"names":["RowContext","React","createContext","hideInternalColumns","hideRowActions","isHovered","rowIndex"],"mappings":";;MASaA,UAAU,gBAAGC,cAAK,CAACC,aAAa,CAAkB;EAC3DC,mBAAmB,EAAE,KAAK;EAC1BC,cAAc,EAAE,KAAK;EACrBC,SAAS,EAAE,KAAK;EAChBC,QAAQ,EAAE,CAAC;CACd;;;;"}
|
@@ -90,12 +90,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
90
90
|
// rendered output
|
91
91
|
let style = {};
|
92
92
|
let content = null;
|
93
|
-
|
93
|
+
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
94
|
+
if (rows.length || table.getBottomRows().length) {
|
94
95
|
style = {
|
95
96
|
height: totalSize,
|
96
97
|
paddingBottom,
|
97
98
|
paddingTop
|
98
99
|
};
|
100
|
+
}
|
101
|
+
// only render non sticky rows
|
102
|
+
if (rows.length) {
|
99
103
|
content = virtualItems.map(virtualRow => {
|
100
104
|
// there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
|
101
105
|
if (!virtualRow) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n if (rows.length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n range => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;AAaA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT,SAAS,CAACa,SAAS,CAACL,MAAM,CAAC,GAAG,GAAG,GAAGG,UAAU,CAACJ,MAAM;;EAGxF,OAAOC,MAAM;AACjB;AAEA;AACA,SAASM,mBAAmBA,CAAkBf,KAAwB,EAAEE,OAA+B;;EACnG,MAAMU,UAAU,IAAAI,oBAAA,GAAGhB,KAAK,CAACa,aAAa,EAAE,cAAAG,oBAAA,cAAAA,oBAAA,GAAI,EAAE;EAC9C,OAAON,oBAAoB,CAACC,MAAM,KAAAM,qBAAA,GAAIf,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEgB,2BAA2B,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,GAAGL,UAAU,CAACJ,MAAM;AACxG;SAEgBW,gBAAgBA,CAC5BC,SAAmC,EACnCpB,KAAwB,EACxBqB,QAAmC,EACnCC,qBAA0C,EAC1CpB,OAA+B;;EAE/B,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CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACvB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACQ,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAG3E,cAAc,GAAGW,SAAS;AACtD;;;;"}
|
1
|
+
{"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (rows.length || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n }\n\n // only render non sticky rows\n if (rows.length) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n range => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;AAaA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT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,OAAO,GAAa,EAAE;IAE5B,IAAIF,cAAc,EAAE;MAChBjF,IAAI,CAACoF,OAAO,CAAC,CAAC/B,GAAG,EAAE1B,KAAK;QACpB,IAAI0B,GAAG,CAACgC,YAAY,EAAE,EAAE;UACpBF,OAAO,CAACG,IAAI,CAAC3D,KAAK,CAAC;;OAE1B,CAAC;;IAGN,OAAOwD,OAAO;GACjB,EAAE,CAACnF,IAAI,CAAC,CAAC;;EAGV,MAAMM,cAAc,GAAGmB,cAAK,CAACC,WAAW,CACpC6D,KAAK;;IACD,MAAMC,mBAAmB,IAAAC,aAAA,GACrB,CAAC,GAAGP,eAAe,CAAC,CAACQ,OAAO,EAAE,CAACC,IAAI,CAAChE,KAAK,IAAI4D,KAAK,CAACK,UAAU,IAAIjE,KAAK,CAAC,cAAA8D,aAAA,cAAAA,aAAA,GAAIP,eAAe,CAAC,CAAC,CAAC;IAEjG,MAAMW,IAAI,GAAG,IAAIC,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACvB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACQ,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAG3E,cAAc,GAAGW,SAAS;AACtD;;;;"}
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
2
2
|
import { TableEmptyStateReason, TableEmptyStateRenderer } from '../../../types';
|
3
3
|
declare type EmptyStateProps = React.HTMLAttributes<HTMLTableSectionElement> & {
|
4
4
|
emptyState?: TableEmptyStateRenderer;
|
5
|
+
isReady: boolean;
|
5
6
|
reason: TableEmptyStateReason;
|
6
7
|
};
|
7
8
|
export declare function EmptyStateBody(props: EmptyStateProps): JSX.Element;
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
declare type RowContextValue = {
|
3
|
+
hideInternalColumns: boolean;
|
4
|
+
hideRowActions: boolean;
|
3
5
|
isHovered: boolean;
|
4
6
|
rowIndex: number;
|
5
|
-
hideRowActions: boolean;
|
6
7
|
};
|
7
8
|
export declare const RowContext: React.Context<RowContextValue>;
|
8
9
|
export {};
|
@@ -9,6 +9,7 @@ export declare type useTableRenderers<TType = unknown> = {
|
|
9
9
|
};
|
10
10
|
export declare type TableRowRendererProps<TType = unknown> = {
|
11
11
|
cellRenderer: TableCellRenderer<TType>;
|
12
|
+
hideInternalColumns?: boolean;
|
12
13
|
hideRowActions?: boolean;
|
13
14
|
index: number;
|
14
15
|
measureRow: (size: number, expansionHeight?: number) => void;
|
@@ -5245,7 +5245,7 @@ const getInputClasses = props => {
|
|
5245
5245
|
const disabled = props.disabled || !!props['aria-disabled'];
|
5246
5246
|
const readOnly = props.readOnly || !!props['aria-readonly'];
|
5247
5247
|
const invalid = props.invalid || !!props['aria-invalid'];
|
5248
|
-
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus
|
5248
|
+
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus:yt-focus',
|
5249
5249
|
// hide the arrow controls on input[type=number]
|
5250
5250
|
'[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', {
|
5251
5251
|
'bg-white': !props.highlighted && !readOnly,
|
@@ -12115,9 +12115,10 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
|
|
12115
12115
|
});
|
12116
12116
|
|
12117
12117
|
const RowContext = /*#__PURE__*/React__default.createContext({
|
12118
|
+
hideInternalColumns: false,
|
12119
|
+
hideRowActions: false,
|
12118
12120
|
isHovered: false,
|
12119
|
-
rowIndex: -1
|
12120
|
-
hideRowActions: false
|
12121
|
+
rowIndex: -1
|
12121
12122
|
});
|
12122
12123
|
|
12123
12124
|
/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
|
@@ -12125,6 +12126,7 @@ function Row(props) {
|
|
12125
12126
|
const {
|
12126
12127
|
renderer: RowRenderer,
|
12127
12128
|
cellRenderer: CellRenderer,
|
12129
|
+
hideInternalColumns = false,
|
12128
12130
|
hideRowActions = false,
|
12129
12131
|
...displayRowProps
|
12130
12132
|
} = props;
|
@@ -12134,8 +12136,9 @@ function Row(props) {
|
|
12134
12136
|
const contextValue = React__default.useMemo(() => ({
|
12135
12137
|
isHovered,
|
12136
12138
|
rowIndex: props.index,
|
12139
|
+
hideInternalColumns,
|
12137
12140
|
hideRowActions
|
12138
|
-
}), [isHovered, props.index, hideRowActions]);
|
12141
|
+
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
12139
12142
|
if (props.row.original === undefined) {
|
12140
12143
|
return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
|
12141
12144
|
}
|
@@ -12233,12 +12236,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
12233
12236
|
// rendered output
|
12234
12237
|
let style = {};
|
12235
12238
|
let content = null;
|
12236
|
-
|
12239
|
+
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
12240
|
+
if (rows.length || table.getBottomRows().length) {
|
12237
12241
|
style = {
|
12238
12242
|
height: totalSize,
|
12239
12243
|
paddingBottom,
|
12240
12244
|
paddingTop
|
12241
12245
|
};
|
12246
|
+
}
|
12247
|
+
// only render non sticky rows
|
12248
|
+
if (rows.length) {
|
12242
12249
|
content = virtualItems.map(virtualRow => {
|
12243
12250
|
// there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
|
12244
12251
|
if (!virtualRow) {
|
@@ -12396,9 +12403,9 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
12396
12403
|
table
|
12397
12404
|
} = context;
|
12398
12405
|
const {
|
12406
|
+
hideRowActions,
|
12399
12407
|
isHovered,
|
12400
|
-
rowIndex
|
12401
|
-
hideRowActions
|
12408
|
+
rowIndex
|
12402
12409
|
} = React__default.useContext(RowContext);
|
12403
12410
|
const tableMeta = table.options.meta;
|
12404
12411
|
const actions = tableMeta.rowActions.rowActions;
|
@@ -12438,6 +12445,12 @@ function Cell$1() {
|
|
12438
12445
|
const {
|
12439
12446
|
texts
|
12440
12447
|
} = useLocalization();
|
12448
|
+
const {
|
12449
|
+
hideInternalColumns
|
12450
|
+
} = React__default.useContext(RowContext);
|
12451
|
+
if (hideInternalColumns) {
|
12452
|
+
return null;
|
12453
|
+
}
|
12441
12454
|
return /*#__PURE__*/React__default.createElement(Icon, {
|
12442
12455
|
"aria-label": texts.table.columns.drag.tooltip,
|
12443
12456
|
name: "drag",
|
@@ -12486,7 +12499,13 @@ function Cell$2(context) {
|
|
12486
12499
|
const {
|
12487
12500
|
texts
|
12488
12501
|
} = useLocalization();
|
12502
|
+
const {
|
12503
|
+
hideInternalColumns
|
12504
|
+
} = React__default.useContext(RowContext);
|
12489
12505
|
const tableMeta = context.table.options.meta;
|
12506
|
+
if (hideInternalColumns) {
|
12507
|
+
return null;
|
12508
|
+
}
|
12490
12509
|
const hasExpandedRow = (_tableMeta$rowExpansi = (_tableMeta$rowExpansi2 = tableMeta.rowExpansion).rowExpansionRenderer) === null || _tableMeta$rowExpansi === void 0 ? void 0 : _tableMeta$rowExpansi.call(_tableMeta$rowExpansi2, context.row.original);
|
12491
12510
|
if (hasExpandedRow) {
|
12492
12511
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === context.row.index;
|
@@ -12576,10 +12595,11 @@ function Cell$3(context) {
|
|
12576
12595
|
table
|
12577
12596
|
} = context;
|
12578
12597
|
const {
|
12598
|
+
hideInternalColumns,
|
12579
12599
|
rowIndex
|
12580
12600
|
} = React__default.useContext(RowContext);
|
12581
12601
|
const tableMeta = table.options.meta;
|
12582
|
-
if (table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
12602
|
+
if (hideInternalColumns || table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
12583
12603
|
return null;
|
12584
12604
|
}
|
12585
12605
|
const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
|
@@ -13815,9 +13835,15 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
|
|
13815
13835
|
function EmptyStateBody(props) {
|
13816
13836
|
const {
|
13817
13837
|
emptyState: Placeholder,
|
13838
|
+
isReady,
|
13818
13839
|
reason,
|
13819
13840
|
...attributes
|
13820
13841
|
} = props;
|
13842
|
+
if (!isReady) {
|
13843
|
+
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
13844
|
+
className: "!auto-rows-fr"
|
13845
|
+
}));
|
13846
|
+
}
|
13821
13847
|
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
13822
13848
|
className: "!auto-rows-fr"
|
13823
13849
|
}), /*#__PURE__*/React__default.createElement("tr", {
|
@@ -16815,7 +16841,7 @@ function Table(props) {
|
|
16815
16841
|
}
|
16816
16842
|
Table.Toolbar = TableToolbar;
|
16817
16843
|
Table.Grid = TableGrid;
|
16818
|
-
function
|
16844
|
+
function getEmptyStateReason(table) {
|
16819
16845
|
if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
|
16820
16846
|
const state = table.instance.getState();
|
16821
16847
|
if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
|
@@ -16838,7 +16864,7 @@ function TableGrid(props) {
|
|
16838
16864
|
const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
|
16839
16865
|
table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
|
16840
16866
|
} : undefined;
|
16841
|
-
const
|
16867
|
+
const emptyStateReason = getEmptyStateReason(table);
|
16842
16868
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
|
16843
16869
|
id: table.id,
|
16844
16870
|
"data-table-font-size": table.meta.fontSize.size,
|
@@ -16859,9 +16885,10 @@ function TableGrid(props) {
|
|
16859
16885
|
key: props.id,
|
16860
16886
|
header: props,
|
16861
16887
|
scrollToIndex: table.renderer.scrollToIndex
|
16862
|
-
}))))))),
|
16888
|
+
}))))))), emptyStateReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
|
16863
16889
|
emptyState: props.table.props.emptyState,
|
16864
|
-
|
16890
|
+
isReady: table.meta.server.isEnabled ? table.meta.server.isReady : true,
|
16891
|
+
reason: emptyStateReason
|
16865
16892
|
})) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
|
16866
16893
|
enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
|
16867
16894
|
table: table.instance,
|
@@ -18505,9 +18532,9 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
18505
18532
|
const onClickOutside = event => {
|
18506
18533
|
if (tableMeta.editing.isEditing) {
|
18507
18534
|
const element = event.target;
|
18508
|
-
const
|
18535
|
+
const isTableOrIsInsideTable = element.tagName === 'TABLE' || element.tagName === 'TBODY' || element.getAttribute('data-taco') === 'backdrop' || element.getAttribute('data-table') === 'editing-toggle' || !document.body.contains(element) || isElementInsideOrTriggeredFromContainer(element, tableRef.current);
|
18509
18536
|
// users can click the white space below rows which could be inside the table, but a valid scenario to save
|
18510
|
-
if (!
|
18537
|
+
if (!isTableOrIsInsideTable) {
|
18511
18538
|
tableMeta.editing.saveChanges(table);
|
18512
18539
|
}
|
18513
18540
|
}
|
@@ -18658,7 +18685,7 @@ function reducer$2(state, action) {
|
|
18658
18685
|
}
|
18659
18686
|
};
|
18660
18687
|
}
|
18661
|
-
case '
|
18688
|
+
case 'insertTemporaryRow':
|
18662
18689
|
{
|
18663
18690
|
const {
|
18664
18691
|
value
|
@@ -18945,14 +18972,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18945
18972
|
}
|
18946
18973
|
});
|
18947
18974
|
}
|
18948
|
-
function
|
18975
|
+
function insertTemporaryRow(data) {
|
18949
18976
|
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
18950
18977
|
const value = {
|
18951
18978
|
...data,
|
18952
18979
|
[rowIdentityAccessor]: newRowId
|
18953
18980
|
};
|
18954
18981
|
dispatch({
|
18955
|
-
type: '
|
18982
|
+
type: 'insertTemporaryRow',
|
18956
18983
|
rowId: newRowId,
|
18957
18984
|
payload: {
|
18958
18985
|
value
|
@@ -19046,12 +19073,42 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19046
19073
|
discardChanges,
|
19047
19074
|
hasSaved,
|
19048
19075
|
// new rows
|
19049
|
-
|
19076
|
+
insertTemporaryRow,
|
19050
19077
|
temporaryRows: state.temporaryRows
|
19051
19078
|
};
|
19052
19079
|
}
|
19053
19080
|
|
19054
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentityAccessor, validator) {
|
19081
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
19082
|
+
const createRow = function (table, scrollToIndex, row) {
|
19083
|
+
try {
|
19084
|
+
if (!handleCreate) {
|
19085
|
+
return Promise.resolve();
|
19086
|
+
}
|
19087
|
+
const tableMeta = table.options.meta;
|
19088
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
|
19089
|
+
if (!saved) {
|
19090
|
+
return;
|
19091
|
+
}
|
19092
|
+
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
19093
|
+
try {
|
19094
|
+
if (changeset) {
|
19095
|
+
const rowId = pendingChangesFns.insertTemporaryRow(changeset);
|
19096
|
+
table.getRow(rowId).pin('bottom');
|
19097
|
+
// set the active row to the new row before toggling editing on
|
19098
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
19099
|
+
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
19100
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
19101
|
+
toggleEditing(true, table, scrollToIndex);
|
19102
|
+
setLastFocusedCellIndex(undefined);
|
19103
|
+
}
|
19104
|
+
} catch (error) {
|
19105
|
+
console.error(error);
|
19106
|
+
}
|
19107
|
+
});
|
19108
|
+
} catch (e) {
|
19109
|
+
return Promise.reject(e);
|
19110
|
+
}
|
19111
|
+
};
|
19055
19112
|
// used to switch the table into editing mode
|
19056
19113
|
const [isEditing, setEditing] = React__default.useState(false);
|
19057
19114
|
// used to switch the editing between "detailed" mode
|
@@ -19089,6 +19146,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentit
|
|
19089
19146
|
toggleEditing: isEnabled ? toggleEditing : () => undefined,
|
19090
19147
|
lastFocusedCellIndex,
|
19091
19148
|
setLastFocusedCellIndex,
|
19149
|
+
createRow,
|
19092
19150
|
createRowButtonRef,
|
19093
19151
|
...pendingChangesFns
|
19094
19152
|
};
|
@@ -19762,7 +19820,7 @@ const RENDERERS$1 = {
|
|
19762
19820
|
cell: Cell$5
|
19763
19821
|
};
|
19764
19822
|
function useTable3(props, ref) {
|
19765
|
-
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.rowIdentityAccessor, props.validator);
|
19823
|
+
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
|
19766
19824
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
19767
19825
|
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
19768
19826
|
const data = React__default.useMemo(() => {
|
@@ -19815,6 +19873,9 @@ function useTable3(props, ref) {
|
|
19815
19873
|
React__default.useEffect(() => {
|
19816
19874
|
if (table.ref.current) {
|
19817
19875
|
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
19876
|
+
if (props.onEditingCreate) {
|
19877
|
+
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, table.renderer.scrollToIndex, row);
|
19878
|
+
}
|
19818
19879
|
}
|
19819
19880
|
}, [table.ref.current]);
|
19820
19881
|
return table;
|
@@ -19972,10 +20033,9 @@ function Editing(props) {
|
|
19972
20033
|
}
|
19973
20034
|
|
19974
20035
|
function CreateNewRow(props) {
|
19975
|
-
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum
|
20036
|
+
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
|
19976
20037
|
const {
|
19977
20038
|
buttonRef,
|
19978
|
-
onEditingCreate: handleEditingCreate,
|
19979
20039
|
scrollToIndex,
|
19980
20040
|
table,
|
19981
20041
|
tableMeta,
|
@@ -19988,44 +20048,16 @@ function CreateNewRow(props) {
|
|
19988
20048
|
const temporaryRowId = (_temporaryRows$0$tabl = (_temporaryRows$ = temporaryRows[0]) === null || _temporaryRows$ === void 0 ? void 0 : _temporaryRows$[tableMeta.rowIdentityAccessor]) !== null && _temporaryRows$0$tabl !== void 0 ? _temporaryRows$0$tabl : '';
|
19989
20049
|
const isDisabled = !!table.getState().globalFilter || !!((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length) || !!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId);
|
19990
20050
|
const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
|
19991
|
-
const
|
20051
|
+
const handleCreate = function () {
|
19992
20052
|
try {
|
19993
|
-
if (
|
20053
|
+
if (isDisabled) {
|
19994
20054
|
return Promise.resolve();
|
19995
20055
|
}
|
19996
|
-
return Promise.resolve(tableMeta.editing.
|
19997
|
-
if (!saved) {
|
19998
|
-
return;
|
19999
|
-
}
|
20000
|
-
const changeset = row !== null && row !== void 0 ? row : handleEditingCreate();
|
20001
|
-
try {
|
20002
|
-
if (changeset) {
|
20003
|
-
const rowId = tableMeta.editing.createRow(changeset);
|
20004
|
-
table.getRow(rowId).pin('bottom');
|
20005
|
-
// set the active row to the new row before toggling editing on
|
20006
|
-
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
20007
|
-
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
20008
|
-
tableMeta.editing.toggleEditing(true, table, scrollToIndex);
|
20009
|
-
tableMeta.editing.setLastFocusedCellIndex(0);
|
20010
|
-
}
|
20011
|
-
} catch (error) {
|
20012
|
-
console.error(error);
|
20013
|
-
}
|
20014
|
-
});
|
20056
|
+
return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
|
20015
20057
|
} catch (e) {
|
20016
20058
|
return Promise.reject(e);
|
20017
20059
|
}
|
20018
20060
|
};
|
20019
|
-
// allow programmatic access to creating rows from outside the table
|
20020
|
-
React__default.useEffect(() => {
|
20021
|
-
var _tableRef$current;
|
20022
|
-
if (tableRef !== null && tableRef !== void 0 && (_tableRef$current = tableRef.current) !== null && _tableRef$current !== void 0 && _tableRef$current.instance) {
|
20023
|
-
tableRef.current.instance.createRow = createRow;
|
20024
|
-
}
|
20025
|
-
}, [tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.instance, createRow]);
|
20026
|
-
const handleCreate = function () {
|
20027
|
-
return createRow();
|
20028
|
-
};
|
20029
20061
|
const shortcut = {
|
20030
20062
|
key: 'Enter',
|
20031
20063
|
meta: true
|
@@ -20148,7 +20180,7 @@ function TemporaryRow(props) {
|
|
20148
20180
|
className: className,
|
20149
20181
|
onKeyDown: handleKeyDown,
|
20150
20182
|
onKeyDownCapture: handleKeyDownCapture,
|
20151
|
-
|
20183
|
+
hideInternalColumns: true,
|
20152
20184
|
hideRowActions: !tableMeta.editing.isEditing
|
20153
20185
|
}))));
|
20154
20186
|
}
|
@@ -20190,7 +20222,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
20190
20222
|
tableRef: table3.ref
|
20191
20223
|
}), /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
20192
20224
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
20193
|
-
onEditingCreate: props.onEditingCreate,
|
20194
20225
|
scrollToIndex: table3.renderer.scrollToIndex,
|
20195
20226
|
table: table3.instance,
|
20196
20227
|
tableMeta: table3.meta,
|